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


@MWP\WordPress\Filter( for="filter_name", priority=10, args=1 )

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


for="filter_name" (required) – The core wordpress filter 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

@Example Code

 * Add classes to the <body> html element
 * @MWP\WordPress\Filter( for="body_class" )
 * @param   array    $classes        An array of classes to add to body
 * @return  array
public function addBodyClass( $classes )
    $classes[] = 'my-custom-class';
    return $classes;
Was this article helpful to you? Yes No

How can we help?