Skip to content

Instantly share code, notes, and snippets.

@jonathanbardo
Last active December 11, 2016 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanbardo/3990cbea53664701af82c94041c10abc to your computer and use it in GitHub Desktop.
Save jonathanbardo/3990cbea53664701af82c94041c10abc to your computer and use it in GitHub Desktop.
If WordPress required PHP >= 5.3
<?php
if ( ! function_exists( '__return' ) ) {
function __return( $return ) {
return function() use ( $return ) {
return $return;
};
};
}
add_filter( 'YOUR_FILTER', __return( 'YOURSTRING' ) );
// The above is so much cleaner than doing
add_filter( 'YOUR_FILTER', function() { return 'YOURSTRING'; } );
@fjarrett
Copy link

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment