Last active
March 11, 2018 19:29
-
-
Save anthonybudd/f42cb2722eb4876919f682a9a160c4ee to your computer and use it in GitHub Desktop.
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 ExampleAction extends WP_AJAX{ | |
protected $action = 'example-action'; | |
protected function run(){ | |
if($this->has('name')){ | |
update_option('name', $this->get('name')); | |
} | |
} | |
} | |
ExampleAction::listen(); | |
ExampleAction::url(); // http://example.com/wp-admin/admin-ajax.php?action=example-action | |
ExampleAction::url(['name' => 'Anthony Budd']); // http://example.com/wp-admin/admin-ajax.php?action=example-action&name=Anthony%20Budd | |
// Example: | |
// <a href="<?= ExampleAction::url(['name' => 'Anthony Budd']) ?>">Link</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment