wp_enqueue_editor()
Outputs scripts, styles, and default settings for the WordPress TinyMCE editor. Which can then be initialized on any textarea field after the page loads.
To initialize the visual editor, use the Javascript method wp.editor.initialize(), located in wp-admin/js/editor.js
The function should be called before the action wp_enqueue_editor
No Hooks.
Returns
null. Nothing (null)
Usage
wp_enqueue_editor();
Examples
#1 Example of connecting and initializing the editor
<?php
// connect styles, scripts
wp_enqueue_editor();
// run the script
add_action( 'wp_footer', function(){
?>
<script>
var id = textarea.attr( 'id' );
wp.editor.initialize( id, {
tinymce: {
wpautop: true
},
quicktags: true
});
</script>
<?php
}, 99);
Changelog
| Since 4.8.0 | Introduced. |
wp_enqueue_editor() wp enqueue editor code WP 6.9.1
function wp_enqueue_editor() {
if ( ! class_exists( '_WP_Editors', false ) ) {
require ABSPATH . WPINC . '/class-wp-editor.php';
}
_WP_Editors::enqueue_default_editor();
}