[wp-trac] [WordPress Trac] #65398: calling wp_enqueue_code_editor() inside wp_localize_script() triggers the script since v7.0 (was: "Special Characters must be escaped" warning in Theme File Editor for functions.php)

WordPress Trac noreply at wordpress.org
Thu Jun 4 15:41:38 UTC 2026


#65398: calling wp_enqueue_code_editor() inside wp_localize_script() triggers the
script since v7.0
--------------------------+----------------------
 Reporter:  terraGirl     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Themes        |     Version:  7.0
 Severity:  minor         |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------

Comment (by terraGirl):

 @ankitkumarshah

 I traced the issue back to a change in behaviour between v6.9 and v7.0.

 This is the code that triggers the issue: calling wp_enqueue_code_editor()
 inside the wp_localize_script() function:

 {{{
 add_action( 'admin_enqueue_scripts', 'enqueue_admin_assets' );

 function enqueue_admin_assets() {

         wp_register_script(
                 'test-script',
                 plugin_dir_url( __FILE__ ) . 'js/test-script.js',
                 array(),
                 '1.0.0',
                 true
         );

         wp_localize_script( 'test-script', 'testScriptData', array(
                 'code_editor' => wp_enqueue_code_editor(['type' =>
 'text/html']),
         ) );

 }
 }}}

 pre-7.0 this did not run the code_editor. Tested with 6.9.4
 in 7.0+ it runs the code_editor

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65398#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list