do_action( 'wp_enqueue_code_editor', array $settings )
Fires when scripts and styles are enqueued for the code editor.
Description Description
Parameters Parameters
- $settings
-
(array) Settings for the enqueued code editor.
Source Source
Changelog Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
/* * See https://make.wordpress.org/core/2017/10/22/code-editing-improvements-in-wordpress-4-9/ */ add_action( 'admin_enqueue_scripts', function() { if ( 'profile' !== get_current_screen()->id ) { return; } // Enqueue code editor and settings for manipulating HTML. $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); // Bail if user disabled CodeMirror. if ( false === $settings ) { return; } wp_add_inline_script( 'code-editor', sprintf( 'jQuery( function() { wp.codeEditor.initialize( "description", %s ); } );', wp_json_encode( $settings ) ) ); } );Expand full source codeCollapse full source code