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.


Top ↑

Source Source

File: wp-includes/general-template.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Guido Scialfa
    /*
     * 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.