• Resolved Cyberchicken

    (@cyberchicken)


    Do you know when you are experimenting with many different plugins, and disabling one of them leaves you with a

    [shortcode …]

    in the middle of a page?

    I didn’t want to delete it and lose the crafted arguments.
    I wanted to hide it, but felt uneasy with common html comments because I think they are not meant to hide disabled code and give away information that shouldn’t.

    I then wrote an itsy bitsy tiny little almost inaudible shortcode:

    function wpcomments_shortcode($atts, $content) { return '';}
    add_shortcode('comment','wpcomments_shortcode');

    and it works!
    I can add

    [comment]
    whatever rubbish I wanna keep for myself
    [/comment]

    and nothing is rendered.

    My questions are just:
    am I the first to feel the need? to make this?
    is there already another technique?
    why not to make it core? (and add a button in TinyMCE) it’s just 4 lines of code!

    Thank you for your attention

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    WordPress itself only contains a few shortcodes, which never get disabled unless you do it programmatically. Since there are literally thousands of shortcodes out there in plugins and themes (ugh), it doesn’t make much sense for WordPress core to add something like this, and this would likely be considered an edge case my most people.

    Glad to hear you found a solution though!

    David_G

    (@questas_admin)

    @mindctrl could you use that snippet that cyberchicken made and create a plugin like what is shown in this thread? Just curious, I don’t know anything about creating a plugin.
    https://wordpress.org/support/topic/auto-logout-password-protected-pages-and-posts?replies=3

    Yes you could. You can also use Pluginception to create custom plugins: https://wordpress.org/plugins/pluginception/

    David_G

    (@questas_admin)

    @mindctrl one last question then. Can I then take a snippet from my child theme’s function.php file and use that as a plugin?

    It depends on the code, but usually you can do that without any modification to the code.

    David_G

    (@questas_admin)

    It would be nice while developing a site to be able to turn on/off a php snippet at will. Thanks.

    Thread Starter Cyberchicken

    (@cyberchicken)

    it doesn’t make much sense for WordPress core to add something like this, and this would likely be considered an edge case my most people.

    I don’t know mindctrl. I imagine it is the ancient war of slick vs bloated.

    Let’s put it this way: there’s this need (an edge case, I agree); I am able to implement a quick solution, but there’s a slice of user who have the need but aren’t able to make up the patch by themselves. Also consider that I alway use ftp, child themes and muplugins, but my simple 3 lines patch would have been a pita to deploy without them.
    So I think that THIS is a situation where ther slightly-above-average user would shouts “WOW they really thought of everything” (as I did myself many times).

    I KNOW there are Hundreds of things to manage before this, but I think it’s also a question of communication, of being friendly with the user, of marketing.

    What do you think?

    Thanks heaps mate,
    Some ladies who manage the wordpress site at work wanted to hide some shortcode without deleting it.
    Your solution works great.

    Thread Starter Cyberchicken

    (@cyberchicken)

    I’m really glad 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘commenting out Shortcodes and whatever’ is closed to new replies.