1

I'm creating my first plugin. So far everything is great, but my shortcode is something like this [BIMS] and that acronym might not be easy to remember, or appeal to everyone. I'd like to include an option to have them input their own replacement shortcode.

What is the proper code to allow them to use their own shortcode text yet bring up my function?

  • The function of the plugin for this example would just output a predefined string in place of the shortcode. I have everything coded as is, I would just like the option of them using their own user defined shortcode rather than mine. – Branndon May 20 '13 at 22:43
  • How do you plan to have the users choose the name for their version of the shortcode? You will have to give them a way to choose the name and the register the shortcode under that name. – s_ha_dum May 20 '13 at 22:47
1

Save the shortcode name in an option, and use that when you add the shortcode:

add_shortcode( 
    get_option( 'your_plugin_option', 'default_shortcode_name' ), 
    'your_shortcode_callback'
);
  • It worked, I just had to slightly modify it since mine was defined in a class : ` add_shortcode( get_option( 'your_plugin_option' ), array( 'PLUGIN_Options', 'your_shortcode_callback' ) );` – Branndon May 21 '13 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.