WordPress.org

Ready to get started?Download WordPress

Forums

Is a shortcode already in use? (5 posts)

  1. dartiss
    Member
    Posted 1 year ago #

    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.

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Why not test to see if the other plugin is active?

  3. dartiss
    Member
    Posted 1 year ago #

    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.

  4. jonradio
    Member
    Posted 1 year ago #

    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.

  5. dartiss
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.