Skip to content

Instantly share code, notes, and snippets.

@KnowTheCodePro
Created March 24, 2016 17:25
Show Gist options
  • Save KnowTheCodePro/77af2863cb58ef05a81f to your computer and use it in GitHub Desktop.
Save KnowTheCodePro/77af2863cb58ef05a81f to your computer and use it in GitHub Desktop.
WordPress Docx - apply_filters - Testing when no callbacks are registered.
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