Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 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:

Description

	
 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
7 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.

<?php
// 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
wp_enqueue_style('one-dark');
Last edited 7 years ago by willrad (previous) (diff)

#2 @willrad
7 years ago

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

#3 @SergeyBiryukov
7 years ago

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