Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Wordpress Shortcode Button

  • 09-05-2012 12:31PM
    #1
    Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭


    Im trying to create a shortcode button that when clicked will add some text to the current location of the cursor in the editor below.

    I have been looking at the tutorial http://wp.tutsplus.com/tutorials/theme-development/wordpress-shortcodes-the-right-way/ - the last section at the bottom deals with adding a button the makes a link out of selected text.

    Im trying to modify this to just add text when clicked but cant get it to work.

    I replaced the last function in the customcodes.js with this but its not working properly. Any ideas?
    (function() {  
            tinymce.create('tinymce.plugins.quote', {  
                init : function(ed, url) {  
                    ed.addButton('quote', {  
                        title : '€',  
                        image : url+'/image.png',  
                        onclick : function() {  
                         return 'Text Text Text '; 
          
                        }  
                    });  
                },  
                createControl : function(n, cm) {  
                    return null;  
                },  
            });  
            tinymce.PluginManager.add('quote', tinymce.plugins.quote);  
        })();  
    


Comments

  • Registered Users, Registered Users 2 Posts: 6,652 ✭✭✭daymobrew


    Axwell wrote: »
    Im trying to modify this to just add text when clicked but cant get it to work.
    Two questions:
    1) Could you get the example in the WPTuts article working?
    2) Are there any errors or warnings displayed in Firebug or Error Console?


Advertisement