This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Example extends WP_AJAX | |
{ | |
protected $action = 'example'; | |
protected function run(){ | |
echo $this->has('foo'); // (bool) TRUE | |
echo $this->has('baz'); // (bool) FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Example extends WP_AJAX | |
{ | |
protected $action = 'example'; | |
protected function run(){ | |
echo $this->requestType(); // 'GET' | |
echo $this->requestType('GET'); // (bool) TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Example extends WP_AJAX | |
{ | |
protected $action = 'example'; | |
protected function run(){ | |
$user = wp_get_current_user(); | |
$this->JSONResponse($user); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //functions.php | |
WP_AJAX::WP_HeadAjaxURL(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //functions.php | |
Example::listen(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class CreatePost extends WP_AJAX | |
{ | |
protected $action = 'create_post'; | |
protected function run(){ | |
if($this->isLoggedIn()){ | |
$post = [ | |
'post_status' => 'publish' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class Example extends WP_AJAX | |
{ | |
protected $action = 'example'; | |
protected function run(){ | |
echo "Success!"; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //functions.php | |
add_action('wp_head', ['WP_AJAX', 'ajaxURL']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function seedHook(){ | |
if(@$_REQUEST['seed'] === 'true'){ | |
for($i = 0; $i < 50; $i++){ | |
Product::insert([ | |
"title" => "Product ". (count(Product::all())+1), | |
"color" => array_values(["green", "red", "blue"])[rand(0, 2)], | |
"price" => rand(50, 2000), | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Product::register(); | |
function randomString($length = 10) { | |
return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length); | |
} | |
function seedButton($wp_admin_bar){ | |
$wp_admin_bar->add_node([ |