1

I need a list-box for shortcodes in visual editor. With WP 3.8 I got it working like :

            createControl : function(n, cm) {
            switch (n) {

    case 'example':
            var mlb = cm.createListBox('example', {
                title : 'Example Shortcode',
                onselect : function(v) {
                   tinyMCE.activeEditor.selection.setContent(v);
                 }
            });

            // Add some values to the list box
    mlb.add('Shortcode', '[shortcode]Some Content Here[/shortcode]');

    // Return the new listbox instance
            return mlb;
    }

But these are not showing up in WP 3.9beta2. How to get it working?

Thanks in Advance.

  • 1
    Got it working with : editor.addButton('OwnStyling', { type: 'listbox', text: 'Stylesheet', icon: false, onselect: function(e) { editor.insertContent(this.value()); }, values: [ {text: 'Menu item 1', value: 'Some text 1'}, {text: 'Menu item 2', value: 'Some text 2'}, {text: 'Menu item 3', value: 'Some text 3'} ], onPostRender: function() { // Select the second item by default } }); – SweetCoder Mar 25 '14 at 2:23
  • 1
    It would have been nicer if you posted the solution as a properly formatted answer and then mark it as accepted :) – cenk Jan 8 '16 at 18:36

Your Answer

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

Browse other questions tagged or ask your own question.