__return_empty_string()WP 3.7.0

Simply returns an empty string:". Helper function of WordPress.

Useful for returning an empty string to filters easily.

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.000001 sec (speed of light) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.11, WP 4.9.7

No Hooks.

Return

String. Empty string.

Usage

add_filter( 'filter_name', '__return_empty_string' );

Examples

0

#1 Example of usage

Let's say, we should always return an empty string in the filter 'my_filter'. Then, use this code:

add_filter( 'my_filter', '__return_empty_string' );

Other variants for the same result:

// пример анонимной функции
add_filter( 'my_filter', create_function('','return "";') );

// or so for php 5.3+
add_filter( 'my_filter', function(){ return ''; } );

// or so, with the registration of real function
add_filter( 'my_filter', 'my_return_function' );
function my_return_function(){
	return '';
}

Notes

Changelog

Since 3.7.0 Introduced.

__return_empty_string() code WP 6.4.3

function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
	return '';
}