This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
before_wp_tiny_mce action
Fires immediately before the TinyMCE settings are printed. To use the before_wp_tiny_mce action, first, you have to register it using add_action. You can write this code into functions.php
of your activated theme or in a custom WordPress Plugin.
We at WePlugins, always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
Example 1: Adding Custom TinyMCE Settings
In this example, we define a function weplugins_execute_on_before_wp_tiny_mce_event
, which takes 1 parameter and is registered using add_action
. The first parameter before_wp_tiny_mce is the name of the hook, the second parameter weplugins_execute_on_before_wp_tiny_mce_event is the name of the function to be called, the third parameter is the priority, and the last is the number of arguments to be passed in the registered function.
function weplugins_execute_on_before_wp_tiny_mce_event($mce_settings){ // Custom code to modify TinyMCE settings } // Add the action add_action("before_wp_tiny_mce", "weplugins_execute_on_before_wp_tiny_mce_event", 10, 1);
Example 2: Removing a Hook Callback
Sometimes, you have to remove a registered hook, so you can use remove_action
to remove before_wp_tiny_mce action. Below is how you can do it:
remove_action("before_wp_tiny_mce", "weplugins_execute_on_before_wp_tiny_mce_event", 10, 1);
Please ensure you provide the same callback function name, priority, and number of arguments while removing the hook callback.
Example 3: Custom Functionality on TinyMCE Load
Here is another way you can utilize this hook to add your custom functionality when TinyMCE loads:
function weplugins_custom_tinymce_function($mce_settings){ // Implement your custom functionality } add_action("before_wp_tiny_mce", "weplugins_custom_tinymce_function", 15, 1);
Parameters
- $mce_settings: (array) TinyMCE settings array.
If you’re having any trouble using this hook, please Contact Us for further assistance. Our team would be happy to help with customization needs.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.