Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

List all available shortcodes, including from plugins and themes WordPress

  • SOLVED

I just found this plugin: [[LINK href="http://wordpress.org/extend/plugins/shortcode-reference/"]]http://wordpress.org/extend/plugins/shortcode-reference/[[/LINK]]

I think it's a great idea.

I tested it out and it seems there are some deprecated functions or some stuff messed up in there. It hasn't been updated since late 2011.

I haven't looked through the code, but I was wondering if you could give it a glance and update the plugin to make it work with the latest version (3.4.1).

Hopefully this helps others too, because having such functionality would be cool.

P.S. if you have a code snippet or some other alternative to add to functions.php or anything else, that'd be fine too. Just some way to get a list of all available WordPress shortcodes (including ones from other ACTIVE plugins and themes).

P.P.S. If you could do this, then I just had a thought -- what about getting this working and then having a piggyback function that FINDS shortcodes in posts, pages, CPTs, etc. that are no longer valid/active shortcodes?


Thank you!

Answers (4)

2012-07-19

Hai Bui answers:

You can print all shortcodes by putting this in a template:

<?php
global $shortcode_tags;
echo "<pre>";
print_r($shortcode_tags);
echo "</pre>";
?>


Clifford P comments:

How would this go in functions.php or something like that so that it shows up in the wp-admin area when writing posts or whenever there's a text input box (not sure if I worded that properly)?

Thanks.


Hai Bui comments:

Yes, try this

function add_shortcodes_metaboxes() {
add_meta_box('available_shortcodes', 'Available Shortcodes', 'available_shortcodes', 'page', 'side', 'default');
add_meta_box('available_shortcodes', 'Available Shortcodes', 'available_shortcodes', 'post', 'side', 'default');
}
add_action( 'add_meta_boxes', 'add_shortcodes_metaboxes' );
function available_shortcodes() {
global $shortcode_tags;
foreach ($shortcode_tags as $shortcode_tag => $description) {
echo $shortcode_tag.'<br/>';
};
}


Clifford P comments:

I've included both of your functions.php code and now see this: http://screencast.com/t/PmJ1jNN3d

I think both accomplish the same thing: list available shortcodes (in plain text).
However, the plugin has extra functionality/lookup about each shortcode. I supposed that's a nice feature of the plugin, but I don't think I was clear on what I was (ideally) wanting (which isn't even part of the plugin, but I thought/wish it was): <strong>is there a way to make each shortcode "clickable" to insert them into the post?</strong> The plugin at least gives details of each shortcode's parameters: http://screencast.com/t/JwzbEhbs (video)

While I am appreciative so far, I'm sure I could have found these 2 snippets on some code sites around the web. I'm looking for a bit more, that's why I thought it'd be good to piggyback off an already existing plugin.

If something cannot be done, please provide a bit of a technical explanation.

Also, just for kicks, I thought I'd share this other plugin I just came across, which is along the lines of my initial question's "P.P.S." :)
[[LINK href="http://wordpress.org/extend/plugins/dx-shortcode-freezer/"]]http://wordpress.org/extend/plugins/dx-shortcode-freezer/[[/LINK]]


Hai Bui comments:

I can fix that plugin but it won't work perfectly anyways. Many (not all) plugins only register the shortcodes for the front-end, we cannot find them in WP backend with any type of code.
Are you still interested?


Clifford P comments:

Yes, I'd like to see what can be done.

For my own reference, do you have a link to a tutorial or something about how/when/why to register shortcodes to both the front-end and the back-end?

Thank you.


Hai Bui comments:

There were a few problems with the plugin:
- The code to get the plugin path/url is incorrect. That's why js and css files weren't loaded
- a small css issue
I fixed it and uploaded it [[LINK href="http://haibui.com/shortcode-reference.zip"]]here[[/LINK]]

The plugin is still not totally compliant with WordPress Coding Standards but it works fine now.

About adding shortcodes for frontend only, they use this:

if (!is_admin()) {
add_shortcode( 'someshortcode', 'someshortcode_function' );
function someshortcode_function() {
//shortcode processing here
}
}

On the backend, that shortcode will never be added and we cannot find them with any code.


Clifford P comments:

1) Are you saying I should no longer be seeing these error codes: http://screencast.com/t/fNuGIIwAQKx ? Do you see the error codes?

2) So if the code didn't have the (!is_admin()) part, this plugin could find it, right? Good info. Thanks.


Hai Bui comments:

Yes, it works for me, no errors like in http://screencast.com/t/fNuGIIwAQKx
anyways, I guess where the errors come from and made some tweaks, please download the plugin again from that link and try it, if it still has error, I give up...


Clifford P comments:

No more errors showing up on that plugin. Thanks. So what's the summary of what you fixed or added?


Hai Bui comments:

After checking it again, I found the plugin has too many flaws, it shows no errors now but still not works correctly (when getting plugin info). I'm sorry, I cannot spend more time on this unless you raise the prize...


Clifford P comments:

Well thank you very much for your efforts and for the improvements you did make, whatever they were. I'll provide the .zip download to the current author and hopefully that'll motivate them to make the additional improvements you say it needs. Many thanks. :-)

2012-07-19

Arthur Araújo answers:

Hi Clifford,

You got some error? Its plugin works for me, im using 4.3.1.


Clifford P comments:

With WP_DEBUG true, I see this: http://screencast.com/t/oHhJSt0Z3jb (image)

Even with WP_DEBUG false, I see this: http://screencast.com/t/nRAeUTYMQcOT (video of WP shortcodes and then a shortcode of the only other activated plugin).


Arthur Araújo comments:

Do you want something like this?


add_action('add_meta_boxes','__shortcode_meta_box_action');
function __shortcode_meta_box_action() {
add_meta_box('shortcode_overview_container2',__('Shortcode reference','ShortcodesAutoreference'), '__shortcode_meta_box', 'post','side');
add_meta_box('shortcode_overview_container2',__('Shortcode reference','ShortcodesAutoreference'), '__shortcode_meta_box', 'page','side');
add_meta_box('shortcode_overview_container2',__('Shortcode reference','ShortcodesAutoreference'), '__shortcode_meta_box', 'link','side');
}

function __shortcode_meta_box() {
global $shortcode_tags;
foreach($shortcode_tags as $tagname=>$tag)
echo "<div>[$tagname]</div>";
}

2012-07-20

oosolen answers:

Le Liebo avec des chandails

2012-07-22

cbagscoach answers:

Eine Welle der coolen Style