Last active
December 11, 2016 20:01
Star
You must be signed in to star a gist
See https://frankiejarrett.com/2016/12/experimenting-with-magic-return-methods-on-wordpress-filters/
This file contains 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
<?php | |
function __return_value( $value ) { | |
return create_function( '', sprintf( 'return %s;', var_export( $value, true ) ) ); | |
} |
This file contains 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
<?php | |
function __return_value( $value ) { | |
return function () use ( $value ) { | |
return $value; | |
}; | |
} |
This file contains 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
<?php | |
add_filter( 'section_count', __return_value( 5 ) ); | |
add_filter( 'allowed_properties', __return_value( array( 'foo', 'bar', 'baz' ) ) ); | |
add_filter( 'cup_overfloweth_amount', __return_value( 1.5 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This.