Support » Plugins » Hacks » Adding a simple dropdown to MCE toolbar?

  • I’m trying to add a dropdown menu to the MCE editors via a plugin. Unfortunately, it is showing up with some strange placement/alignment:

    This seems like it should be simple, but I’ve been racking my brains trying to figure it out.

    I tried add_action(‘media_buttons’ …) and add_action(‘media_buttons_context’ …), but it always aligns strangely. I don’t care where the button is, per se. I just want it visible on both the Visual and HTML editors.

    What am I doing wrong? Incidently, if I uncomment the /img/ua2.png button, it displays fine with correct alignment. Is there a better way to do this?

    add_action('media_buttons','upsell_add_sc_select', 11);
    function upsell_add_sc_select(){
        $include = array(1 => "Ad #1", 2 => "Ad #2"); //test array
        echo '<select id="upsell_add_select">&nbsp;<option>Upsell Ads</option>';
        foreach ($include as $key => $val){
        	$upsell_ad_id = explode("#", $key);
    		echo '<option value="[upsellad id='.$key.']">'.$val.'</option>';
    	echo '</select>';
    	//echo '<a href="#"><img src="/img/ua2.png" /></a>';
    add_action('admin_head', 'button_js');
    function button_js() {
    	echo '<script type="text/javascript">
    	   jQuery("#upsell_add_select").change(function() {
    			  send_to_editor(jQuery("#upsell_add_select :selected").val());
            		  return false;
Viewing 1 replies (of 1 total)
  • For the record, this is what the upsell_add_sc_select() function is outputting, which looks fine to me:

    <select id="upsell_add_select"><option>Upsell Ads</option><option value="[upsellad id=1]">Ad #1</option><option value="[upsellad id=2]">Ad #2</option></select>

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a simple dropdown to MCE toolbar?’ is closed to new replies.