Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twenty Twenty: inline styles type #20

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/wp-content/themes/twentytwenty/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ function twentytwenty_register_styles() {
wp_style_add_data( 'twentytwenty-style', 'rtl', 'replace' );

// Add output of Customizer settings as inline style.
wp_add_inline_style( 'twentytwenty-style', twentytwenty_get_customizer_css( 'front-end' ) );
$front_end_styles = twentytwenty_get_customizer_css( 'front-end' );
if ( $front_end_styles ) {
wp_add_inline_style( 'twentytwenty-style', $front_end_styles );
}

// Add print CSS.
wp_enqueue_style( 'twentytwenty-print-style', get_template_directory_uri() . '/print.css', null, $theme_version, 'print' );
Expand Down Expand Up @@ -424,10 +427,16 @@ function twentytwenty_block_editor_styles() {
wp_style_add_data( 'twentytwenty-block-editor-styles', 'rtl', 'replace' );

// Add inline style from the Customizer.
wp_add_inline_style( 'twentytwenty-block-editor-styles', twentytwenty_get_customizer_css( 'block-editor' ) );
$block_editor_styles = twentytwenty_get_customizer_css( 'block-editor' );
if ( $block_editor_styles ) {
wp_add_inline_style( 'twentytwenty-block-editor-styles', $block_editor_styles );
}

// Add inline style for non-latin fonts.
wp_add_inline_style( 'twentytwenty-block-editor-styles', TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'block-editor' ) );
$non_latin_fonts = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'block-editor' );
if ( $non_latin_fonts ) {
wp_add_inline_style( 'twentytwenty-block-editor-styles', $non_latin_fonts );
}

// Enqueue the editor script.
wp_enqueue_script( 'twentytwenty-block-editor-script', get_theme_file_uri( '/assets/js/editor-script-block.js' ), array( 'wp-blocks', 'wp-dom' ), wp_get_theme()->get( 'Version' ), true );
Expand Down Expand Up @@ -465,6 +474,11 @@ function twentytwenty_add_classic_editor_customizer_styles( $mce_init ) {

$styles = twentytwenty_get_customizer_css( 'classic-editor' );

// Return if there are no styles to add.
if ( ! $styles ) {
return $mce_init;
}

if ( ! isset( $mce_init['content_style'] ) ) {
$mce_init['content_style'] = $styles . ' ';
} else {
Expand Down