I am writing a plugin that has variables that I would like to localize for use within TinyMCE. The logical choice seemed to me to localise them with the enqueued TinyMCE script itself like so:

public function localize_variables() {
    wp_localize_script( 'tinymce', 'varName', 'value' );
add_action( 'admin_enqueue_scripts', 'localize_variables' );

However I can't find where TinyMCE is being enqueued!

I put this little function at the bottom of my functions page and ran it on my Admin edit posts page:

function my_inspect_scripts() {
    global $wp_scripts;
add_action( 'wp_print_scripts', 'my_inspect_scripts' );

After going through the data dump I noticed that TinyMCE was not in the list of scripts being enqueued! However the script its self was being loaded as a resource within the browser.

I feel like I am missing something here.


1 Answer 1


Looks as though Tiny MCE is not enqueued. Looks like it is loaded through the _WP_Editors class in class-wp-editor.php.

There is a action hook in there called before_wp_tiny_mce where you can output a script with some localised variables... This is what I am going to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.