Skip to content

Instantly share code, notes, and snippets.

View anthonybudd's full-sized avatar

Anthony C. Budd anthonybudd

View GitHub Profile
<?php
$client = Aws\Ec2\Ec2Client::factory([
'region' => 'eu-west-1',
'version' => '2016-11-15',
'credentials' => [
'key' => 'YOUR KEY',
'secret' => 'YOUR SECRET',
]
]);
<?php
class City extends WP_Model
{
public $postType = 'city';
public $attributes = [
'latitude',
'longitude'
];
<?php
Class City extends WP_Model{
public $postType = 'city';
public $attributes = [
'population',
];
public $filter = [
'population'
<?php //functions.php
add_action("wp_ajax_example", "exampleAJAX");
add_action("wp_ajax_nopriv_example", "exampleAJAX");
function exampleAJAX(){
echo "Success!";
}
$.post(ajaxurl, {action: "example"})
.done(function(data) {
console.log(data)
});
<?php
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
echo $this->get('foo'); // 'bar'
echo $this->get('baz'); // NULL
<?php
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
echo $this->has('foo'); // (bool) TRUE
echo $this->has('baz'); // (bool) FALSE
<?php
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
echo $this->requestType(); // 'GET'
echo $this->requestType('GET'); // (bool) TRUE
<?php
Class Example extends WP_AJAX
{
protected $action = 'example';
protected function run(){
$user = wp_get_current_user();
$this->JSONResponse($user);
}
<?php //functions.php
WP_AJAX::WP_HeadAjaxURL();