Make WordPress Core


Ignore:
Timestamp:
07/10/2024 06:17:44 AM (12 months ago)
Author:
isabel_brison
Message:

Editor: enqueue block custom CSS only when block renders on the page.

Updates the global styles custom CSS handling logic to be consistent with other global styles and take advantage of conditional enqueuing of block styles.

Props isabel_brison, aaronrobertshaw, andrewserong.
Fixes #61395.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r58685 r58703  
    14241424        }
    14251425
     1426        // Load the custom CSS last so it has the highest specificity.
     1427        if ( in_array( 'custom-css', $types, true ) ) {
     1428            // Add the global styles root CSS.
     1429            $stylesheet .= _wp_array_get( $this->theme_json, array( 'styles', 'css' ) );
     1430        }
     1431
    14261432        return $stylesheet;
    14271433    }
     
    14681474     *
    14691475     * @since 6.2.0
     1476     * @deprecated 6.7.0 Use {@see 'get_stylesheet'} instead.
    14701477     *
    14711478     * @return string The global styles custom CSS.
    14721479     */
    14731480    public function get_custom_css() {
     1481        _deprecated_function( __METHOD__, '6.7.0', 'get_stylesheet' );
    14741482        // Add the global styles root CSS.
    14751483        $stylesheet = isset( $this->theme_json['styles']['css'] ) ? $this->theme_json['styles']['css'] : '';
     
    26932701                'features'   => $feature_selectors,
    26942702                'variations' => $variation_selectors,
     2703                'css'        => $selector,
    26952704            );
    26962705
     
    29092918        }
    29102919
    2911         // 7. Generate and append any custom CSS rules pertaining to nested block style variations.
     2920        // 7. Generate and append any custom CSS rules.
    29122921        if ( isset( $node['css'] ) && ! $is_root_selector ) {
    29132922            $block_rules .= $this->process_blocks_custom_css( $node['css'], $selector );
Note: See TracChangeset for help on using the changeset viewer.