do_action( ‘wp_enqueue_code_editor’, array $settings )

Fires when scripts and styles are enqueued for the code editor.

Parameters

$settingsarray
Settings for the enqueued code editor.

Source

do_action( 'wp_enqueue_code_editor', $settings );

Changelog

VersionDescription
4.9.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
    /*
     * 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 )
            )
        );
    } );

You must log in before being able to contribute a note or feedback.