• Resolved Travis

    (@tjtaylor)


    Greetings,

    My plugin RSS Retriever, located here: https://www.ads-software.com/plugins/wp-rss-retriever/ is a simple shortcode plugin which fetchs and displays an RSS feed.

    I’ve had a few requests to add support for using the shortcode inside a text widget. The following filter will do this:

    add_filter( 'widget_text', 'do_shortcode' );

    However, I’m not sure what would be the proper, or WordPress way, of doing this. Should I just add another attribute to the shortcode, something like “widget=true” or is there a more recommended way of doing this? I don’t want to clutter the shortcode with too many attributes…

    Thanks for any help!
    – Travis

Viewing 2 replies - 1 through 2 (of 2 total)
  • Some thoughts on the subject:

    1. It probably makes sense to offer the attribute for the shortcode,
    2. But it also makes sense to offer a Settings Page in the Admin panels with the option, as most plugin users prefer Settings, in my experience
    3. You could also just ALWAYS add the Filter as it shouldn’t hurt anyone who doesn’t need it
    4. Finally, at the risk of sounding self-serving, you could suggest my plugin as an alternative to adding the functionality to your plugin. I say this because some of my plugins have got too complex because I added functionality to my plugin that was already available in another plugin.
    Thread Starter Travis

    (@tjtaylor)

    Thanks for your reply!

    I think I’m going to add the filter to the plugin by default, since like you said, I can’t imagine it conflicting with anything else. I actually thought shortcodes worked inside text-widgets by default.

    And if they want to insert them anywhere else, I will surely refer them to your plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Proper way to add_filter with shortcode’ is closed to new replies.