WordPress.org

Forums

[resolved] List of shortcodes already in use? (6 posts)

  1. Trishah
    Member
    Posted 2 years ago #

    Is there a list somewhere of the shortcodes that are already in use? I'm thinking about developing my second plugin and I'd like to make sure the shortcode is not already being used before I start.

  2. michael.mariart
    Member
    Posted 2 years ago #

    I don't think that there's no official list of shortcodes. I haven't seen one before anyway. Even if there is, it will never be complete because each theme and each plugin can add their own shortcodes at any time, so it will depened totally on what combination of theme and plugins you use.

    The best way around this is to use something that's got the least change of collisions for your own shortcodes. As an example, if yu're pluign is called "trishahdeesgreatnewplugin' you could have all of it's shortcodes prefixed with 'tdgnp', so they'd be something like

    [tdgnp_myshortcode][/tdgnp_myshortcode]

    That's really about the best way to do it.

  3. Chris
    Member
    Posted 2 years ago #

    Shortcodes are being stored in a global variable/array. So you could do something like this:

    global $shortcode_tag;
    if( !in_array( 'myNewShortcode', $shortcode_tag ) ) {
    ...add myNewShortcode...
    }

    For a case insensitive check you would have to aim for the "slug" which is also stored in $shortcode_tag

  4. Chris
    Member
    Posted 2 years ago #

    I was a bit slower than Michael :) But he's right: Prefixing should always be the way to go.

  5. Chris
    Member
    Posted 2 years ago #

    I don't mean to spam but actually my code from above was wrong^^, sry. It would have to be
    if( !key_exists( 'myNewShortCode', $shortcode_tag ) ) {...

  6. Trishah
    Member
    Posted 2 years ago #

    "trishahdeesgreatnewplugin"

    LOL

    And Chris, correcting code is NEVER spam :)

    I can see why creating such a list might be futile... OTOH, having a searchable db that allows for submissions and tracking would be great... but I'm NOT volunteering for the admin job on that one! lol

    But until some brave soul does tackle such a product, I think that prefixing is the way to go.

    Thanks for your input!

Topic Closed

This topic has been closed to new replies.

About this Topic