Helper functions for WP filters

Helper functions for WP filters

If you need some default values for WordPress filters you can use such helper functions:

__return_false() — returns logical FALSE.
__return_true() — returns logical TRUE.
__return_empty_array() — returns an empty array: array().
__return_zero() — returns a number 0.
__return_null() — returns NULL.
__return_empty_string() — returns an empty string: ”.

Example:

add_filter( 'custom_menu_order', '__return_true' );

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.