__return_false()
Simply returns false. Helper function of WordPress.
Used in filters when you want to specify a function that always returns false.
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: ''.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
false
.
Usage
__return_false();
Examples
#1 Return false in the filter
Let's say we have a filter 'show_admin_bar' and we need to return false in the value of this filter. To do this, we can write a specific function or use the auxiliary function __return_false():
add_filter( 'show_admin_bar', '__return_false' );
The same result can be reached with following codes:
// with ananimous function (php 5.3+) add_filter( 'show_admin_bar', function(){ return false; } ); // or so, with register finction in php add_filter( 'show_admin_bar', 'my_return_function' ); function my_return_function(){ return false; }
Notes
- See: __return_true()
Changelog
Since 3.0.0 | Introduced. |
__return_false() return false code WP 6.7.1
function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore return false; }