Wordpress plugins
Hide Broken Shortcodes

Hide Broken Shortcodes

Version : 1.8.1
Tested up to : 4.7.6
Number of download : 8711
Author : Scott Reilly

Screenshots

Hide Broken Shortcodes
Hide Broken Shortcodes
Hide Broken Shortcodes
Hide Broken Shortcodes

By default in WordPress, if the plugin that provides the functionality to handle any given shortcode is disabled, or if a shortcode is improperly defined in the content (such as with a typo), then the shortcode in question will appear on the site in its entirety, unprocessed by WordPress. At best this reveals unsightly code-like text to visitors and at worst can potentially expose information not intended to be seen by visitors. This plugin prevents unhandled shortcodes from appearing in the content of a post or page. If the shortcode is of the self-closing variety, then the shortcode tag and its attributes are not displayed and nothing is shown in their place. If the shortcode is of the enclosing variety (an opening and closing tag bookend some text or markup), then the text that is being enclosed will be shown, but the shortcode tag and attributes that surround the text will not be displayed. See the Filters section for more customization tips. Links: Plugin Homepage | Plugin Directory Page | Author Homepage Filters The plugin is further customizable via two filters. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). 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: /** * Don't show broken shortcodes or the content they wrap. * * @param string $default The text to display in place of the broken shortcode. * @param string $shortcode The name of the shortcode. * @param array $m The regex match array for the shortcode. * @return string */ function hbs_handler( $default, $shortcode, $m ) { return ''; // Don't show the shortcode or text bookended by the shortcode } add_filter( 'hide_broken_shortcode', 'hbs_handler', 10, 3 ); 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 three default filters are ‘the_content’, ‘the_excerpt’, and ‘widget_text’. Your hooking function will only be sent one argument: the array of filters. Example: /** * Make Hide Broken Shortcodes also filter 'the_title'. * * @param array $filters_array The filters the plugin will handle. * @return array */ function hbs_filter( $filters_array ) { $filters_array[] = 'the_title'; // Assuming you've activated shortcode support in post titles return $filters_array; } add_filter( 'hide_broken_shortcodes_filters', 'hbs_filter' );

Download now