How to remove a filter that is an anonymous object?

That’s a very good question. It goes down to the dark heart of the plugin API and best programming practices. For the following answer I created a simple plugin to illustrate the problem with easy to read code. <?php # -*- coding: utf-8 -*- /* Plugin Name: Anonymous OOP Action */ if ( ! class_exists( … Read more

remove_action or remove_filter with external classes?

The best thing to do here is to use a static class. The following code should be instructional: class MyClass { function __construct() { add_action( ‘wp_footer’, array( $this, ‘my_action’ ) ); } function my_action() { print ‘<h1>’ . __class__ . ‘ – ‘ . __function__ . ‘</h1>’; } } new MyClass(); class MyStaticClass { public … Read more

Disable emojicons introduced with WP 4.2

We will hook into init and remove actions as followed: function disable_wp_emojicons() { // all actions related to emojis remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ ); remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 ); remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ ); remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ ); remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ ); remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ ); remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ ); // filter to remove TinyMCE emojis add_filter( … Read more