-
-
Save pavlo-bondarchuk/8f59e0aa144e01a561d5983568a27b76 to your computer and use it in GitHub Desktop.
Simple return callback generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Simple return callback generator. | |
| * | |
| * Usage: | |
| * add_filter( 'filter_name', __return( 'Return value' ) ); | |
| * add_shortcode( 'year', __return( date( 'Y' ) ) ); | |
| * | |
| * @param mixed $return | |
| * | |
| * @return Closure | |
| */ | |
| function __return( $return = null ) | |
| { | |
| return static function () use ( $return ) { | |
| return $return; | |
| }; | |
| } | |
| if ( defined( 'WP_ENV' ) && WP_ENV !== 'production' && ! is_admin() ) | |
| { | |
| add_filter( 'pre_option_blog_public', '__return_zero' ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment