Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#42753 closed defect (bug) (invalid)

possible bug in filter wp_code_editor_setting

Reported by: willrad's profile willrad Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9
Component: Editor Keywords:
Focuses: Cc:


 function readonly_wp_code_editor_settings( $settings ) {
	$new_settings =
		array( 'codemirror' => array( 'readOnly' => 'true' ) );
	$settings = array_merge( $settings, $new_settings );
	return $settings;
add_filter( 'wp_code_editor_settings', 'readonly_wp_code_editor_settings' );

 function theme_code_editor_settings( $settings ) {
	$new_settings =
		array( 'codemirror' => array( 'theme' => 'vibrant-ink' ) );
	$settings = array_merge( $settings, $new_settings );
	return $settings;

add_filter( 'wp_code_editor_settings', 'theme_code_editor_settings' );

wp_enqueue_style( 'vibrant-ink', plugin_dir_url( __FILE__ ) . 'vibrant-ink.css' );

Trying to set this filter turns off linting, bracket matching etc in the plugin and theme editors. The setting is set correctly as expected but no bracket matching.

Anyone have this problem? I want to set a custom theme and the above happens. There is an optional argument for the filter but it doesn't change what I'm after anyways.

Change History (3)

#1 @willrad
5 years ago

  • Component changed from Editor to TinyMCE

Using $args instead produces the right results from the filter. The class gets renamed and styling is overridden with linting\hinting intact.

// filter used with $args
add_filter( 'wp_code_editor_settings', function( $args ) {

// send an empty array with it??
if (!is_array($settings))$settings = array($settings);

$args['codemirror']['theme'] = 'one-dark';
return array_merge($settings,$args);

// register stylesheet
wp_register_style('one-dark', plugin_dir_url( __FILE__ ) . 'one-dark.css', array(), '1');

// enqueue stylesheet
Last edited 5 years ago by willrad (previous) (diff)

#2 @willrad
5 years ago

  • Component changed from TinyMCE to Editor
  • Resolution set to invalid
  • Status changed from new to closed

#3 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.