Skip to content
Closed
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
44 changes: 20 additions & 24 deletions src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ class WP_Theme_JSON {
* @since 6.5.0 Added `aspect-ratio` property.
* @since 6.6.0 Added `background-[image|position|repeat|size]` properties.
* @since 6.7.0 Added `background-attachment` property.
*
* @var array
*/
const PROPERTIES_METADATA = array(
Expand Down Expand Up @@ -307,7 +306,6 @@ class WP_Theme_JSON {
*
* @since 6.2.0
* @since 6.6.0 Added background-image properties.
*
* @var array
*/
const INDIRECT_PROPERTIES_METADATA = array(
Expand Down Expand Up @@ -339,6 +337,7 @@ class WP_Theme_JSON {
* setting key.
*
* @since 5.9.0
* @var array
*/
const PROTECTED_PROPERTIES = array(
'spacing.blockGap' => array( 'spacing', 'blockGap' ),
Expand Down Expand Up @@ -475,7 +474,6 @@ class WP_Theme_JSON {
* The valid properties for fontFamilies under settings key.
*
* @since 6.5.0
*
* @var array
*/
const FONT_FAMILY_SCHEMA = array(
Expand Down Expand Up @@ -517,7 +515,6 @@ class WP_Theme_JSON {
* @since 6.3.0 Added support for `typography.textColumns`.
* @since 6.5.0 Added support for `dimensions.aspectRatio`.
* @since 6.6.0 Added `background` sub properties to top-level only.
*
* @var array
*/
const VALID_STYLES = array(
Expand Down Expand Up @@ -591,6 +588,7 @@ class WP_Theme_JSON {
*
* @since 6.1.0
* @since 6.2.0 Added support for ':link' and ':any-link'.
* @var array
*/
const VALID_ELEMENT_PSEUDO_SELECTORS = array(
'link' => array( ':link', ':any-link', ':visited', ':hover', ':focus', ':active' ),
Expand Down Expand Up @@ -938,7 +936,6 @@ protected static function do_opt_in_into_settings( &$context ) {
* @return array The sanitized output.
*/
protected static function sanitize( $input, $valid_block_names, $valid_element_names, $valid_variations ) {

$output = array();

if ( ! is_array( $input ) ) {
Expand Down Expand Up @@ -2311,7 +2308,7 @@ protected static function flatten_tree( $tree, $prefix = '', $token = '--' ) {
* @param array $theme_json Theme JSON array.
* @param string $selector The style block selector.
* @param boolean $use_root_padding Whether to add custom properties at root level.
* @return array Returns the modified $declarations.
* @return array Returns the modified $declarations.
*/
protected static function compute_style_properties( $styles, $settings = array(), $properties = null, $theme_json = null, $selector = null, $use_root_padding = null ) {
if ( empty( $styles ) ) {
Expand Down Expand Up @@ -2815,7 +2812,6 @@ private static function get_block_nodes( $theme_json, $selectors = array(), $opt
* Fixed custom CSS output in block style variations.
*
* @param array $block_metadata Metadata about the block to get styles for.
*
* @return string Styles for the block.
*/
public function get_styles_for_block( $block_metadata ) {
Expand Down Expand Up @@ -3040,9 +3036,9 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
$use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments'];

/*
* If there are content and wide widths in theme.json, output them
* as custom properties on the body element so all blocks can use them.
*/
* If there are content and wide widths in theme.json, output them
* as custom properties on the body element so all blocks can use them.
*/
if ( isset( $settings['layout']['contentSize'] ) || isset( $settings['layout']['wideSize'] ) ) {
$content_size = isset( $settings['layout']['contentSize'] ) ? $settings['layout']['contentSize'] : $settings['layout']['wideSize'];
$content_size = static::is_safe_css_declaration( 'max-width', $content_size ) ? $content_size : 'initial';
Expand All @@ -3053,13 +3049,13 @@ public function get_root_layout_rules( $selector, $block_metadata ) {
}

/*
* Reset default browser margin on the body element.
* This is set on the body selector **before** generating the ruleset
* from the `theme.json`. This is to ensure that if the `theme.json` declares
* `margin` in its `spacing` declaration for the `body` element then these
* user-generated values take precedence in the CSS cascade.
* @link https://github.com/WordPress/gutenberg/issues/36147.
*/
* Reset default browser margin on the body element.
* This is set on the body selector **before** generating the ruleset
* from the `theme.json`. This is to ensure that if the `theme.json` declares
* `margin` in its `spacing` declaration for the `body` element then these
* user-generated values take precedence in the CSS cascade.
* @link https://github.com/WordPress/gutenberg/issues/36147.
*/
$css .= ':where(body) { margin: 0; }';

if ( $use_root_padding ) {
Expand Down Expand Up @@ -3469,8 +3465,8 @@ protected static function filter_slugs( $node, $slugs ) {
* @since 6.6.0 Updated to allow variation element styles and $origin parameter.
*
* @param array $theme_json Structure to sanitize.
* @param string $origin Optional. What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
* @param string $origin Optional. What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
* @return array Sanitized structure.
*/
public static function remove_insecure_properties( $theme_json, $origin = 'theme' ) {
Expand Down Expand Up @@ -4202,6 +4198,7 @@ private static function compute_spacing_sizes( $spacing_scale ) {
* For example, `var:preset|color|vivid-green-cyan` becomes `var(--wp--preset--color--vivid-green-cyan)`.
*
* @since 6.3.0
*
* @param string $value The variable such as var:preset|color|vivid-green-cyan to convert.
* @return string The converted variable.
*/
Expand All @@ -4227,7 +4224,8 @@ private static function convert_custom_properties( $value ) {
* It is recursive and modifies the input in-place.
*
* @since 6.3.0
* @param array $tree Input to process.
*
* @param array $tree Input to process.
* @return array The modified $tree.
*/
private static function resolve_custom_css_format( $tree ) {
Expand All @@ -4251,7 +4249,6 @@ private static function resolve_custom_css_format( $tree ) {
*
* @param object $block_type The block type.
* @param string $root_selector The block's root selector.
*
* @return array The custom selectors set by the block.
*/
protected static function get_block_selectors( $block_type, $root_selector ) {
Expand Down Expand Up @@ -4310,9 +4307,8 @@ protected static function get_block_element_selectors( $root_selector ) {
*
* @param object $metadata The related block metadata containing selectors.
* @param object $node A merged theme.json node for block or variation.
*
* @return array The style declarations for the node's features with custom
* selectors.
* selectors.
*/
protected function get_feature_declarations_for_node( $metadata, &$node ) {
$declarations = array();
Expand Down Expand Up @@ -4470,8 +4466,8 @@ private static function convert_variables_to_value( $styles, $values ) {
* Resolves the values of CSS variables in the given styles.
*
* @since 6.3.0
* @param WP_Theme_JSON $theme_json The theme json resolver.
*
* @param WP_Theme_JSON $theme_json The theme json resolver.
* @return WP_Theme_JSON The $theme_json with resolved variables.
*/
public static function resolve_variables( $theme_json ) {
Expand Down
Loading