diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/blocks/calendar.php --- a/wp/wp-includes/blocks/calendar.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/blocks/calendar.php Fri Sep 05 18:40:08 2025 +0200 @@ -8,6 +8,11 @@ /** * Renders the `core/calendar` block on server. * + * @since 5.2.0 + * + * @global int $monthnum. + * @global int $year. + * * @param array $attributes The block attributes. * * @return string Returns the block content. @@ -30,33 +35,54 @@ if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) { $permalink_structure = get_option( 'permalink_structure' ); if ( - strpos( $permalink_structure, '%monthnum%' ) !== false && - strpos( $permalink_structure, '%year%' ) !== false + str_contains( $permalink_structure, '%monthnum%' ) && + str_contains( $permalink_structure, '%year%' ) ) { - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited $monthnum = $attributes['month']; - // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited - $year = $attributes['year']; + $year = $attributes['year']; } } + $color_block_styles = array(); + + // Text color. + $preset_text_color = array_key_exists( 'textColor', $attributes ) ? "var:preset|color|{$attributes['textColor']}" : null; + $custom_text_color = $attributes['style']['color']['text'] ?? null; + $color_block_styles['text'] = $preset_text_color ? $preset_text_color : $custom_text_color; + + // Background Color. + $preset_background_color = array_key_exists( 'backgroundColor', $attributes ) ? "var:preset|color|{$attributes['backgroundColor']}" : null; + $custom_background_color = $attributes['style']['color']['background'] ?? null; + $color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color; + + // Generate color styles and classes. + $styles = wp_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) ); + $inline_styles = empty( $styles['css'] ) ? '' : sprintf( ' style="%s"', esc_attr( $styles['css'] ) ); + $classnames = empty( $styles['classnames'] ) ? '' : ' ' . esc_attr( $styles['classnames'] ); + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classnames .= ' has-link-color'; + } + // Apply color classes and styles to the calendar. + $calendar = str_replace( '