I want to create a popup shortcode in admin panel.
I already create the shortcode button and a popup on button click.
I want to display in the popup (not in the shortcode button), all my custom shortcodes that I have created in a dropdown list.
I really don’t know how to get my shortcodes name with a loop like this for example:
<tbody>
<select id="shortcode-generator-select">
<option value="raw"></option>
<?php foreach( $shortcode as $shortcode ) : ?>
<option value="<?php echo $shortcode['name']; ?>"><?php echo $shortcode['title']; ?> </option>
<?php endforeach; ?>
</select>
</tbody>
I just want to understand what is the way to create a popup shortcode generator.
You get all shortcodes, there are registered in WordPress with the default function in the global
$shortcode_tags
. You can loop about this shortcodes and filter via tag or functiion.If the
$function
is a array, then can also read the parameters. See the source below. I think the source is easier to understand as my english 😉shortcodes get added to the global $shortcode_tags array as they are registred/added. Therefore you can access them thusly:
The array uses shortcode tags as the keys and the function called as the value, you’ll probably have to figure out some way to further process them to get any meaningful information, and in fact since you state that you only want to list your own custom shortcodes, then this is probably the wrong approach anyhow.