1

I have a plugin that displays some content onto the front end of the site after applying the_content filter to the block of text. I do this for formatting and maintaining links and images etc.

When I display my content on the front end of the site, other plugins that are hooked into the_content cause conflicts. For example, sharedaddy by jetpack hooks into the_content and displays share buttons wherever the_content is being used.

I can manually disable it by removing the filter, but this is less than ideal as I'm sure not all of my users are using sharedaddy. So rather than adding the remove_filter for sharedaddy, is there a way I can just simply remove all filters hooked into the_content for my specific plugin?

I am displaying my content like so:

<?php echo apply_filters('the_content' , $this->optionVal['custom-message']); ?>

1 Answer 1

4

If this is only for certain content areas, create your own filter, and base it off the original the_content filter.

Put this in your functions.php (found in wp-includes/default-filters.php)

add_filter( 'se152488_the_content', 'wptexturize'        );
add_filter( 'se152488_the_content', 'convert_smilies'    );
add_filter( 'se152488_the_content', 'convert_chars'      );
add_filter( 'se152488_the_content', 'wpautop'            );
add_filter( 'se152488_the_content', 'shortcode_unautop'  );
add_filter( 'se152488_the_content', 'prepend_attachment' );

Then use the same filter. Feel free to rename it, but give it a prefix so there are no conflicts.

<?php 
   echo apply_filters('se152488_the_content' , $this->optionVal['custom-message']); 
?>

You have to be either inclusive, or exclusive for this kind of thing, so if there are other filters you WANT from plugins you'll have to manually add them as well.

1
  • Very interesting....I was just looking into duplicating the existing the_content filter, and renaming it and adding it to my plugin. I will have a look at this solution and see what I can come up with. I will report back here shortly. Thanks for the response Eric!
    – EHerman
    Jul 2, 2014 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.