Plugin Directory

Hide Broken Shortcodes

Version: 1.6 Prevent broken shortcodes from appearing in posts and pages.

Filters

The plugin is further customizable via two filters. Typically, these customizations would be put into your active theme's functions.php file, or used by another plugin.

hide_broken_shortcode

The 'hide_broken_shortcode' filter allows you to customize what, if anything, gets displayed when a broken shortcode is encountered. Your hooking function can be sent 3 arguments:

Arguments :

  • $default (string): The default display text (what the plugin would display by default)
  • $shortcode (string): The name of the shortcode
  • The text bookended by opening and closing broken shortcodes, if present

Example:

add_filter( 'hide_broken_shortcode', 'hbs_handler', 10, 3 );
function hbs_handler( $default, $shortcode, $content ) {
    return ''; // Don't show the shortcode or text bookended by the shortcode
}

hide_broken_shortcodes_filters

The 'hide_broken_shortcodes_filters' filter allows you to customize what filters to hook to find text with potential broken shortcodes. The two default filters are 'the_content' and 'widget_text'. Your hooking function will only be sent one argument: the array of filters.

Example:

add_filter( 'hide_broken_shortcodes_filters', 'hbs_filter' );
function hbs_filter( $filters_array ) {
    $filters_array[] = 'the_title'; // Assuming you've activated shortcode support in post titles
    return $filters_array;
}

Requires: 2.5 or higher
Compatible up to: 3.5.1
Last Updated: 2012-12-11
Downloads: 2,607

Ratings

4 stars
4.4 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
0,1,0
100,1,1