@MWP\WordPress\AjaxHandler( action="ajax_action_name", for={"users","guests"} )
Using this annotation will register your function as a callback for an ajax call. It can be configured to respond to both logged in and guest users.
@Params
action="ajax_action_name"
(required) – The ‘action’ ajax parameter that is needed to invoke the callback
for={"users","guests"}
(optional) / {default: “users”, “guests”} – The type of users who can access the callback
@Example
/**
* Return the current users member id
*
* @MWP\WordPress\AjaxHandler( action="get_my_userid" )
*
* @return void
*/
public function respondWithUserID()
{
// Send user id, or 0 if user is not logged in
wp_send_json( get_current_user_id() );
}