__return_zero() WP 3.0.0
Simply returns 0. Helper function of WordPress. Useful for use in filters.
All such helper functions:
__return_false() — returns false.
__return_true() — returns true.
__return_empty_array() — returns an empty: array().
__return_zero() — returns the number 0.
__return_null() — returns NULL.
__return_empty_string() — returns an empty string: ''.
1 time = 0.000001s = speed of light | 50000 times = 0.00s = speed of light | PHP 7.1.11, WP 4.9.7
No Hooks.
Return
Int. 0.
Usage
__return_zero() // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore;
Examples
#1 Example of how to use function
Suppose we need return 0 in filter example_filter
. Use this code:
add_filter( 'my_filter', '__return_zero' );
The same can be written in a different way:
// anonymous function (php 5.3+) add_filter( 'my_filter', function(){ return 0; } ); // or so, with function registration add_filter( 'my_filter', 'my_return_function' ); function my_return_function(){ return 0; }
Changelog
Since 3.0.0 | Introduced. |
Code of __return_zero() return zero WP 5.6
function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
return 0;
}Related Functions
From tag: __return (helper functions)
More from category: Helper Functions
- build_query()
- get_page_hierarchy()
- get_temp_dir()
- human_readable_duration()
- is_email()
- is_php_version_compatible()
- is_serialized()
- is_serialized_string()
- is_wp_version_compatible()
- map_deep()
- maybe_serialize()
- maybe_unserialize()
- path_join()
- seems_utf8()
- stripslashes_deep()
- timer_stop()
- urlencode_deep()
- wp_array_slice_assoc()
- wp_basename()
- wp_debug_backtrace_summary()
- wp_doing_ajax()
- wp_extract_urls()
- wp_filter_object_list()
- wp_generate_uuid4()
- wp_html_split()
- wp_is_json_request()
- wp_is_numeric_array()
- wp_is_uuid()
- wp_json_encode()
- wp_kses_array_lc()
- wp_kses_hair()
- wp_kses_uri_attributes()
- wp_list_filter()
- wp_list_pluck()
- wp_list_sort()
- wp_make_link_relative()
- wp_mkdir_p()
- wp_normalize_path()