Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/wp-includes/class-wp-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ public static function editor( $content, $editor_id, $settings = array() ) {
self::$editor_buttons_css = false;
}

if ( ! empty( $set['quicktags'] ) ) {
wp_print_styles( 'buttons' );
}

if ( ! empty( $set['editor_css'] ) ) {
echo $set['editor_css'] . "\n";
}
Expand Down
57 changes: 57 additions & 0 deletions tests/phpunit/tests/editor/wpEditors.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,61 @@ public function wp_link_query_callback( $results ) {
)
);
}

/**
* Tests that buttons.css is force-printed when quicktags is enabled in wp_editor().
*
* @ticket 64841
*
* @covers ::editor
*/
public function test_wp_editor_prints_buttons_style_when_quicktags_enabled() {
$old_wp_styles = $GLOBALS['wp_styles'] ?? null;
$GLOBALS['wp_styles'] = new WP_Styles();
wp_default_styles( $GLOBALS['wp_styles'] );

$output = get_echo(
'wp_editor',
array(
'',
'test_editor_quicktags',
array(
'quicktags' => true,
),
)
);

$GLOBALS['wp_styles'] = $old_wp_styles;

$this->assertStringContainsString( "id='buttons-css'", $output );
}

/**
* Tests that buttons.css is not force-printed when quicktags is disabled in wp_editor().
*
* @ticket 64841
*
* @covers ::editor
*/
public function test_wp_editor_does_not_print_buttons_style_when_quicktags_disabled() {
$old_wp_styles = $GLOBALS['wp_styles'] ?? null;
$GLOBALS['wp_styles'] = new WP_Styles();
wp_default_styles( $GLOBALS['wp_styles'] );

$output = get_echo(
'wp_editor',
array(
'',
'test_editor_no_quicktags',
array(
'quicktags' => false,
'media_buttons' => false,
),
)
);

$GLOBALS['wp_styles'] = $old_wp_styles;

$this->assertStringNotContainsString( "id='buttons-css'", $output );
}
}
Loading