Support » Plugins » Hacks » Is a shortcode already in use?

  • If there a way to find out the callback function name of a shortcode?

    I have a plugin which uses a shortcode that often clashes with another, which uses the same one. It would be useful to be able to detect from the plugin if the shortcode is directed at the alternative plugin and warn the user.

    David.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Why not test to see if the other plugin is active?

    Thread Starter David Artiss

    (@dartiss)

    That’s the simplest solution but although it’s one that causes the most issues, there are others so a more generic way of checking would be better.

    David.

    At first glance, the global $shortcode_tag looks like the answer to your question. But then you will discover that, in the Codex, it has been removed from the list of globals that you “should use”.

    If you have the patience, this is a good read on why the global is not reliable:
    http://www.wpquestions.com/question/show/id/4307
    And why there appears to be no reliable way to determine shortcodes in use.

    The short answer is that shortcodes are being conditionally defined by plugins. In the most simple case, a plugin will use is_admin() to determine whether to define the shortcode. If true, for Admin panels only. If false, for everything but Admin panels. Backend/Frontend in some vocabularies.

    Thread Starter David Artiss

    (@dartiss)

    Of course. I understand now.

    You can only detect the shortcode usage, obviously, if they’ve been registered – as many plugins (my own included) only register them when it’s no admin. it’s a bit tough to know if they’re in use within the admin panel.

    David.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Is a shortcode already in use?’ is closed to new replies.