-
-
Save KnowTheCodePro/77af2863cb58ef05a81f to your computer and use it in GitHub Desktop.
WordPress Docx - apply_filters - Testing when no callbacks are registered.
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
add_filter( 'knowthecode', function( $value ){ | |
d( 'in the filter knowthecode ' . $value ); | |
}, 52 ); | |
add_action( 'loop_start', __NAMESPACE__ . '\demo_no_callbacks' ); | |
function demo_no_callbacks() { | |
echo 'in demo_no_callbacks<br>'; | |
global $wp_filter; | |
d( $wp_filter['knowthecode'] ); | |
remove_all_filters( 'knowthecode' ); | |
d( $wp_filter['knowthecode'] ); | |
d( array_key_exists( 'knowthecode', $wp_filter ) ); | |
$value = apply_filters( 'knowthecode', 'Hello there' ); | |
echo 'back from apply_filters'; | |
d( $value ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment