1. Home
  2. Docs
  3. Application Framework
  4. Annotations Reference
  5. Action


@MWP\WordPress\Action( for="action_name", priority=10, args=1 )

Using this annotation will add your function as a callback for a core WordPress action. It is analogous to using add_action() in WordPress.


for="action_name" (required) – The core WordPress action to attach the method to
priority=10 (optional) / {default: 10} – The priority of your callback
args=1 (optional) / {default: 1} – The number of arguments your callback expects
output=true (optional) / {default: false} – Automatically output the return value of your method

@Example Code

 * Examine an updated post
 * @MWP\WordPress\Action( for="post_updated", args=3 )
 * @param   int     $post_ID        The id of the post
 * @param   object  $post_after     The post object after the update
 * @param   object  $post_before    The post object before the update
 * @return  void
public function examinePost( $post_ID, $post_after, $post_before )
    echo 'Post ID:';

    echo 'Post Object AFTER update:';

    echo 'Post Object BEFORE update:';
Was this article helpful to you? Yes No

How can we help?