Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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