@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.
@Params
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;
}