__return_true()

Returns true.

Description

Useful for returning true to filters easily.

See also

Return

(true) True.

More Information

Usage:
<?php 
// This will add a filter on `example_filter` that returns true
add_filter( 'example_filter', '__return_true' ); 
?>

Source

File: wp-includes/functions.php

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

Changelog

Version Description
3.0.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/__return_true