__return_true() WordPress Function

The __return_true() function is a simple function that returns the boolean value true. This function is often used as a placeholder for other functions that have not yet been implemented.

__return_true() #

Returns true.


Description

Useful for returning true to filters easily.

Top ↑

See also


Top ↑

Return

(true) True.


Top ↑

More Information

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

Top ↑

Source

File: wp-includes/functions.php

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

Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More