Advertisement
Guest User

example plugin

a guest
Jan 27th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. class my_class {
  2.   public $output
  3.   public function __construct() {
  4.     $this->output .= '<form method="post" action="' . admin_url('admin-post.php') . '">;
  5.    $this->output .= '<input type="hidden" name="action" value="do_something"/>';
  6.    $this->output .= '<input type="submit" value="click here"/>';
  7.    $this->output .= '</form>';
  8.    add_action('admin_post_do_something', array(&$this, 'do_something'));
  9.    add_action('admin_post_nopriv_do_something', array(&$this, 'do_something'));
  10.    add_action('admin_post_nopriv_register_do_something', array(&$this, 'do_something'));
  11.  }
  12.  public function do_something() {
  13. //This doesn't get called, whenever I click the button which is displayed through display_form() from another class which is registered as a shortcode (which works), then admin-post.php in wp-admin/admin-post.php returns a blank screen.
  14.     status_header(200);
  15.     die('success');
  16.   }
  17.   public function display_form() {
  18.     return $this->output;
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement