9/21/2023 0 Comments Wordpress tinymce windowmanager![]() This function basically gives WordPress the path to our JS file (which we will create next) so that TinyMCE can use it and load our plugin. The next task we want to do is make the dobsondev_tinymce_example_add_tinymce_plugin function that we call in our main function (it’s the first add_filter( … ) call). For this plugin I opted to put all the buttons on the third row to differentiate them from the rest of the default buttons but you can change that number to change the row.Ĭhange the number in mce_buttons_ to change the row the buttons appear in Adding the Plugin File to TinyMCE This denotes the row that the buttons will appear on. One very important thing to note is the number 3 at the end of mce_buttons_3 in the add_filter( ‘mce_buttons_3’, ‘dobsondev_tinymce_example_register_buttons’ ) call. You can see the code below:Īfter this main function we only have to create the two functions that we call in our add_filter( … ) function calls before we are done with our main plugin file. This function is added as an action to the admin_head since we only need to load our plugin when editing a post or page which takes place on the admin side. The first three steps are done with simple checks and the one is done by simply calling the add_filter( … ) function built into WordPress. Calls the filter functions that will add our custom buttons.Checks that we are editing a post or page.Checks that the current user has permissions to edit posts and pages.Next up we have what I call the main function for our custom TinyMCE plugin. I’m not sure why but I’ve always used really long slugs, but if you are making your own version of the plugin feel free to change that to whatever works for you (but make sure it’s unique!). This can easily be done with the following code (all code in this tutorial will be taken directly from the example plugin):Īll code examples are taken directly from the example plugin!Īs you can see I use dobsondev_tinymce_example as the slug for my function titles. The CSS will be required when we want to use custom icons as well as dashicons for our menu items. The first call I want to make in my main plugin file is the call that hooks in our CSS file. The basic information for the plugin is as follows: Hooking in the CSS Since I’ve called my plugin “DobsonDev WordPress TinyMCE Example” and I’ve named the folder dobsondev-wordpress-tinymce-example, I’ve opted to name my main file dobsondev-wordpress-tinymce-example.php. Add a folder for our custom icon image files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |