Twenty Twenty: Avoid PHP warnings in 8.1 due to incorrect usage of `wp_add_inline_style()`.
This changeset adjusts the logic to use a more defensive approach, to avoid passing potentially invalid values to `wp_add_inline_style()`. Props flixos90, mukesh27, costdev, swissspidy, poena, sabernhardt. Fixes #57777. Built from https://develop.svn.wordpress.org/trunk@55427 git-svn-id: http://core.svn.wordpress.org/trunk@54960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
58d7cd099e
commit
26ab805ad4
|
@ -25,7 +25,7 @@ if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) {
|
|||
* @since Twenty Twenty 1.0
|
||||
*
|
||||
* @param string $type Whether to return CSS for the "front-end", "block-editor", or "classic-editor".
|
||||
* @return void
|
||||
* @return string|null Custom CSS, or null if not applicable.
|
||||
*/
|
||||
public static function get_non_latin_css( $type = 'front-end' ) {
|
||||
|
||||
|
@ -105,7 +105,7 @@ if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) {
|
|||
|
||||
// Return if the selected language has no fallback fonts.
|
||||
if ( empty( $font_family[ $locale ] ) ) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) {
|
|||
|
||||
// Return if the specified type doesn't exist.
|
||||
if ( empty( $elements[ $type ] ) ) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return the specified styles.
|
||||
|
|
|
@ -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' ) );
|
||||
$customizer_css = twentytwenty_get_customizer_css( 'front-end' );
|
||||
if ( $customizer_css ) {
|
||||
wp_add_inline_style( 'twentytwenty-style', $customizer_css );
|
||||
}
|
||||
|
||||
// Add print CSS.
|
||||
wp_enqueue_style( 'twentytwenty-print-style', get_template_directory_uri() . '/print.css', null, $theme_version, 'print' );
|
||||
|
@ -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' ) );
|
||||
$customizer_css = twentytwenty_get_customizer_css( 'block-editor' );
|
||||
if ( $customizer_css ) {
|
||||
wp_add_inline_style( 'twentytwenty-block-editor-styles', $customizer_css );
|
||||
}
|
||||
|
||||
// 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' ) );
|
||||
$custom_css = TwentyTwenty_Non_Latin_Languages::get_non_latin_css( 'block-editor' );
|
||||
if ( $custom_css ) {
|
||||
wp_add_inline_style( 'twentytwenty-block-editor-styles', $custom_css );
|
||||
}
|
||||
|
||||
// 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 );
|
||||
|
@ -465,6 +474,10 @@ function twentytwenty_add_classic_editor_customizer_styles( $mce_init ) {
|
|||
|
||||
$styles = twentytwenty_get_customizer_css( 'classic-editor' );
|
||||
|
||||
if ( ! $styles ) {
|
||||
return $mce_init;
|
||||
}
|
||||
|
||||
if ( ! isset( $mce_init['content_style'] ) ) {
|
||||
$mce_init['content_style'] = $styles . ' ';
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-beta3-55426';
|
||||
$wp_version = '6.2-beta3-55427';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue