Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    @brand-dedication : Hi Noahj,

    The plugin has indirect support for hiding broken shortcodes as they may appear in other places, via the hide_broken_shortcodes_filters filter.

    In your case, this would be accomplished with a few lines of (untested) code added somewhere on the site (perhaps in an mu-plugin, or less ideally in the theme’s functions.php file):

    /**
     * Hides broken shortcodes that appear in WooCommerce product short descriptions.
     *
     * @param array $filters Filters that get their broken shortcodes hidden.
     * @return array
     */
    function hide_broken_shortcodes_in_woocommerce_short_description( $filters ) {
    	$filters[] = 'woocommerce_short_description';
    	return $filters;
    }
    add_filter( 'hide_broken_shortcodes_filters', 'hide_broken_shortcodes_in_woocommerce_short_description' );

    The point of the hide_broken_shortcodes_filters filter was to provide a way for the plugin’s functionality to be able to be extended to other places. There are probably hundreds of other situations where broken shortcodes could/should be hidden, but accounting for them all is not feasible.

    You could argue that WooCommerce is a large enough plugin that it should warrant exception. It’s something I could be swayed about at some point, but currently there haven’t been any other identical requests from others for this.

    Does the above code get you the results you wanted? I only skimmed the WooCommerce code to find what looks like the relevant bit, so I may not have chosen the appropriate filter.

    Thread Starter brand-dedication

    (@brand-dedication)

    Hey Scott,

    Thanks for the details and snippet.

    Okay. I missed that this was with the intent to extend with a custom filter as needed.

    No need to add support for it. I can take it from here.

    Appreciate it!

    Plugin Author Scott Reilly

    (@coffee2code)

    WordPress & Plugin Developer

    Hi Noahj,

    Glad you’re all set. If the plugin already had a settings UI, I’d consider adding a field for users to input the names of other filters to run the plugin against. I suppose I can add such a textarea in Settings -> Reading. I’ll mull it over.

    Thread Starter brand-dedication

    (@brand-dedication)

    Thanks.

    That’s a good idea.

    Yeah, if you find the time I’ll lookout for the update.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Apply same filter to Woocommerce Product Short Descriptions’ is closed to new replies.