Dropdown list of all shortcodes
Adding this snippet to functions.php your topic WordPress will add a selection menu (custom media_buttons) with an automatically generated list of your short numbers.
And here is the code snippet for WordPress
add_action('media_buttons','add_sc_select',11);
function add_sc_select(){
global $shortcode_tags;
/* ------------------------------------- */
/* enter names of shortcode to exclude bellow */
/* ------------------------------------- */
$exclude = array("wp_caption", "embed");
echo ' <select id="sc_select"><option>Shortcode</option>';
foreach ($shortcode_tags as $key => $val){
if(!in_array($key,$exclude)){
$shortcodes_list .= '<option value="['.$key.'][/'.$key.']">'.$key.'</option>';
}
}
echo $shortcodes_list;
echo '</select>';
}
add_action('admin_head', 'button_js');
function button_js() {
echo '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#sc_select").change(function() {
send_to_editor(jQuery("#sc_select :selected").val());
return false;
});
});
</script>';
}There is also a modified code snippet for inserting your own shortcodes, instead of this list.
add_action('media_buttons','add_sc_select',11);
function add_sc_select(){
echo ' <select id="sc_select">
<option>Shortcode</option>
<option value="[html1][/html1]">[html1]</option>
<option value="[css1][/css1]">[css1]</option>
<option value="[javascript1][/javascript1]">[javascript1]</option>
</select>';
}
add_action('admin_head', 'button_js');
function button_js() {
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
$("#sc_select").change(function() {$("#content").val($("#content").val()+$("#sc_select :selected").val());})
});
</script>';
}
I think that's all, I add these fragments as a section “WordPress technical points” as well as in the section “For plugin development“.
Good luck with developing your own plugins.
/*

- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.




