mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Update @wordpress packages
Update packages to include these bug fixes from Gutenberg: - Image block: Set image display to grid when no alignment sent to properly align caption on resize - Update and align template descriptions - Site Editor - prevent loading state from showing the admin menu. - Add client side routing for Site Editor - Navigation: Add clearance for appender in submenus. - Fix CSS Custom Properties for presets in the site editor - Add/navigation blocks post processing after migration from menu items - Allow selector ordering to ensure theme.json root selector margin takes precedence - Do not remove theme presets if defaults are hidden - Format library: fix unsetting highlight color - FSE: Fix template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity - ColorPalette: Improving accessibility and visibility - Update: Make the color popover on the gradient picker appear as expected - Site Editor: Display a notice if export fails - Fix docs and function naming for gallery block registration in PHP - Switch to addEventListener for load event in the navigation block view script - Fix mistake in _remove_theme_attribute_in_block_template_content - Better synchronisation between Gutenberg and Core code - Move the block page templates hook into compat/5.9 folder - Moves to the template loader hooks and functions into lib/compat folder - Refactor the gutenberg_is_fse_theme function to use wp_is_block_theme - Site Editor: Update support doc URL in Welcome Guide - Global Styles: Add Welcome Guide toggle - Hide remove control point when removing would break gradient control - Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin - Image: Fix resizer controls being hidden in Safari when switching between alignments - Remove Navigation Menus from WP Admin sidebar - Site Editor: Hide the block appender in the Template Part editor - Site Editor: Use server definition for the Template Areas - Synchronize wp_is_block_theme and block-templates block support with Core - E2E: Retry login again after a bad nonce request to prevent intermittent test failures - Fix theme requirement validation with WP 5.8 - Fix WP 5.9 check for conditionally running code - Fix post comment form input width - Border Style Control: Update styling for consistency with border width control - Fix form-submit styles by adding button classes to the submit-button in post-comments block - Site Editor: Fix edit template part link in header dropdown - Move duotone palette to the bottom of global styles gradients - Fix how appearanceTools works - Move WP 5.9 wp-admin menus compatibility code to lib/compat folder - Revert "Site Editor: Set the <title> on the list page to be same as the CPT name" - Site Editor: Document Actions: add SR text to heading 1 - Do not register global styles CPT in WordPress 5.9 - Global Styles: Move the 'Edit colors' button to a standard menu item - Fix styles for previews and patterns - Site Editor: Fix failing E2E test - Templates: Search for old template names in the parent theme too - Remove 4 instances of 'gutenberg' text domain from WordPress core - Fix content loss when ungrouping template parts or reusable blocks - Simplify the RESET_BLOCK action to fix template part focus mode content loss - [Global Styles]: Make Blocks section more distinguishable - Only use block markup for comment form button when using a block theme - Navigation: Fix vertical alignment of page list in modal. - Fix: ToggleGroupControl active state - Remove gutenberg_ prefix from @wordpress/block-library Props ocean90, oandregal, hellofromtonya, youknowriad. See #54487. git-svn-id: https://develop.svn.wordpress.org/trunk@52364 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -311,7 +311,6 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||
array(
|
||||
'css' => 'variables',
|
||||
'__unstableType' => 'presets',
|
||||
'__experimentalNoWrapper' => true,
|
||||
),
|
||||
array(
|
||||
'css' => 'presets',
|
||||
|
||||
@@ -41,7 +41,7 @@ function get_block_theme_folders( $theme_stylesheet = null ) {
|
||||
$root_dir = get_theme_root( $theme_name );
|
||||
$theme_dir = "$root_dir/$theme_name";
|
||||
|
||||
if ( is_readable( $theme_dir . '/block-templates/index.html' ) ) {
|
||||
if ( file_exists( $theme_dir . '/block-templates' ) || file_exists( $theme_dir . '/block-template-parts' ) ) {
|
||||
return array(
|
||||
'wp_template' => 'block-templates',
|
||||
'wp_template_part' => 'block-template-parts',
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Server-side rendering of the `core/gallery` block.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles backwards compatibility for Gallery Blocks,
|
||||
* whose images feature a `data-id` attribute.
|
||||
*
|
||||
* Now that the Gallery Block contains inner Image Blocks,
|
||||
* we add a custom `data-id` attribute before rendering the gallery
|
||||
* so that the Image Block can pick it up in its render_callback.
|
||||
*
|
||||
* @param array $parsed_block The block being rendered.
|
||||
* @return array The migrated block object.
|
||||
*/
|
||||
function block_core_gallery_data_id_backcompatibility( $parsed_block ) {
|
||||
if ( 'core/gallery' === $parsed_block['blockName'] ) {
|
||||
foreach ( $parsed_block['innerBlocks'] as $key => $inner_block ) {
|
||||
if ( 'core/image' === $inner_block['blockName'] ) {
|
||||
if ( ! isset( $parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] ) && isset( $inner_block['attrs']['id'] ) ) {
|
||||
$parsed_block['innerBlocks'][ $key ]['attrs']['data-id'] = esc_attr( $inner_block['attrs']['id'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $parsed_block;
|
||||
}
|
||||
|
||||
add_filter( 'render_block_data', 'block_core_gallery_data_id_backcompatibility' );
|
||||
|
||||
/**
|
||||
* Registers the `core/gallery` block on server.
|
||||
* This render callback needs to be here
|
||||
* so that the gallery styles are loaded in block-based themes.
|
||||
*/
|
||||
function register_block_core_gallery() {
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/gallery',
|
||||
array(
|
||||
'render_callback' => function ( $attributes, $content ) {
|
||||
return $content;
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'init', 'register_block_core_gallery', 20 );
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Server-side rendering of the `core/image` block.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the `core/image` block on the server,
|
||||
* adding a data-id attribute to the element if core/gallery has added on pre-render.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param array $content The block content.
|
||||
* @return string Returns the block content with the data-id attribute added.
|
||||
*/
|
||||
function render_block_core_image( $attributes, $content ) {
|
||||
if ( isset( $attributes['data-id'] ) ) {
|
||||
// Add the data-id="$id" attribute to the img element
|
||||
// to provide backwards compatibility for the Gallery Block,
|
||||
// which now wraps Image Blocks within innerBlocks.
|
||||
// The data-id attribute is added in a core/gallery `render_block_data` hook.
|
||||
$data_id_attribute = 'data-id="' . esc_attr( $attributes['data-id'] ) . '"';
|
||||
if ( ! strpos( $content, $data_id_attribute ) ) {
|
||||
$content = str_replace( '<img', '<img ' . $data_id_attribute . ' ', $content );
|
||||
}
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers the `core/image` block on server.
|
||||
*/
|
||||
function register_block_core_image() {
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/image',
|
||||
array(
|
||||
'render_callback' => 'render_block_core_image',
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'register_block_core_image' );
|
||||
@@ -11,6 +11,8 @@ require ABSPATH . WPINC . '/blocks/block.php';
|
||||
require ABSPATH . WPINC . '/blocks/calendar.php';
|
||||
require ABSPATH . WPINC . '/blocks/categories.php';
|
||||
require ABSPATH . WPINC . '/blocks/file.php';
|
||||
require ABSPATH . WPINC . '/blocks/gallery.php';
|
||||
require ABSPATH . WPINC . '/blocks/image.php';
|
||||
require ABSPATH . WPINC . '/blocks/latest-comments.php';
|
||||
require ABSPATH . WPINC . '/blocks/latest-posts.php';
|
||||
require ABSPATH . WPINC . '/blocks/legacy-widget.php';
|
||||
@@ -64,11 +66,9 @@ function register_core_block_types_from_metadata() {
|
||||
'cover',
|
||||
'embed',
|
||||
'freeform',
|
||||
'gallery',
|
||||
'group',
|
||||
'heading',
|
||||
'html',
|
||||
'image',
|
||||
'list',
|
||||
'media-text',
|
||||
'missing',
|
||||
|
||||
@@ -188,6 +188,12 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
||||
);
|
||||
}
|
||||
|
||||
$aria_label = sprintf(
|
||||
/* translators: Accessibility text. %s: Parent page title. */
|
||||
__( '%s submenu' ),
|
||||
$label
|
||||
);
|
||||
|
||||
$html = '<li ' . $wrapper_attributes . '>';
|
||||
|
||||
// If Submenus open on hover, we render an anchor tag with attributes.
|
||||
@@ -226,11 +232,11 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
||||
if ( $show_submenu_indicators ) {
|
||||
// The submenu icon is rendered in a button here
|
||||
// so that there's a clickable elment to open the submenu.
|
||||
$html .= '<button aria-label="' . $label . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">' . block_core_navigation_submenu_render_submenu_icon() . '</button>';
|
||||
$html .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">' . block_core_navigation_submenu_render_submenu_icon() . '</button>';
|
||||
}
|
||||
} else {
|
||||
// If menus open on click, we render the parent as a button.
|
||||
$html .= '<button aria-label="' . $label . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
||||
$html .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation-item__content wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
||||
|
||||
// Wrap title with span to isolate it from submenu icon.
|
||||
$html .= '<span class="wp-block-navigation-item__label">';
|
||||
|
||||
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '133b84f32422a9ad94c4533f85fa4e87');
|
||||
<?php return array('dependencies' => array(), 'version' => '34d9f07c7910e83c264c6c4406619c5e');
|
||||
@@ -1 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => 'f3cbbfbf9b9c434c39d6f77037d5267c');
|
||||
<?php return array('dependencies' => array(), 'version' => 'd5ab04a497b4f1465f1f0060b6b71ae3');
|
||||
@@ -173,12 +173,17 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
|
||||
}
|
||||
}
|
||||
|
||||
$title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) );
|
||||
$title = wp_kses( $page['title'], wp_kses_allowed_html( 'post' ) );
|
||||
$aria_label = sprintf(
|
||||
/* translators: Accessibility text. %s: Parent page title. */
|
||||
__( '%s submenu' ),
|
||||
$title
|
||||
);
|
||||
|
||||
$markup .= '<li class="wp-block-pages-list__item' . $css_class . '"' . $style_attribute . '>';
|
||||
|
||||
if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) {
|
||||
$markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . $title . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
|
||||
$markup .= '<button aria-label="' . $aria_label . '" class="' . $navigation_child_content_class . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . $title . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>' .
|
||||
'</button>';
|
||||
} else {
|
||||
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . $title . '</a>';
|
||||
@@ -186,7 +191,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
|
||||
|
||||
if ( isset( $page['children'] ) ) {
|
||||
if ( $is_navigation_child && $show_submenu_icons && ! $open_submenus_on_click ) {
|
||||
$markup .= '<button aria-label="' . $title . ' ' . __( 'submenu', 'gutenberg' ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
||||
$markup .= '<button aria-label="' . $aria_label . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">';
|
||||
$markup .= '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
|
||||
$markup .= '</button>';
|
||||
}
|
||||
|
||||
@@ -66,3 +66,20 @@ function register_block_core_post_comments() {
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'register_block_core_post_comments' );
|
||||
|
||||
/**
|
||||
* Use the button block classes for the form-submit button.
|
||||
*
|
||||
* @param array $fields The default comment form arguments.
|
||||
*
|
||||
* @return array Returns the modified fields.
|
||||
*/
|
||||
function post_comments_block_form_defaults( $fields ) {
|
||||
if ( wp_is_block_theme() ) {
|
||||
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link" value="%4$s" />';
|
||||
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
add_filter( 'comment_form_defaults', 'post_comments_block_form_defaults' );
|
||||
|
||||
@@ -30,5 +30,9 @@
|
||||
"link": true
|
||||
}
|
||||
},
|
||||
"style": "wp-block-post-comments"
|
||||
"style": [
|
||||
"wp-block-post-comments",
|
||||
"wp-block-buttons",
|
||||
"wp-block-button"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -64,8 +64,11 @@ function render_block_core_template_part( $attributes ) {
|
||||
} else {
|
||||
// Else, if the template part was provided by the active theme,
|
||||
// render the corresponding file content.
|
||||
$theme_folders = get_block_theme_folders();
|
||||
$template_part_file_path = get_theme_file_path( '/' . $theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
|
||||
$parent_theme_folders = get_block_theme_folders( get_template() );
|
||||
$child_theme_folders = get_block_theme_folders( get_stylesheet() );
|
||||
$child_theme_part_file_path = get_theme_file_path( '/' . $child_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
|
||||
$parent_theme_part_file_path = get_theme_file_path( '/' . $parent_theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
|
||||
$template_part_file_path = 0 === validate_file( $attributes['slug'] ) && file_exists( $child_theme_part_file_path ) ? $child_theme_part_file_path : $parent_theme_part_file_path;
|
||||
if ( 0 === validate_file( $attributes['slug'] ) && file_exists( $template_part_file_path ) ) {
|
||||
$content = file_get_contents( $template_part_file_path );
|
||||
$content = is_string( $content ) && '' !== $content
|
||||
|
||||
@@ -107,7 +107,7 @@ class WP_Theme_JSON {
|
||||
const PRESETS_METADATA = array(
|
||||
array(
|
||||
'path' => array( 'color', 'palette' ),
|
||||
'override' => false,
|
||||
'override' => array( 'color', 'defaultPalette' ),
|
||||
'value_key' => 'color',
|
||||
'css_vars' => '--wp--preset--color--$slug',
|
||||
'classes' => array(
|
||||
@@ -119,7 +119,7 @@ class WP_Theme_JSON {
|
||||
),
|
||||
array(
|
||||
'path' => array( 'color', 'gradients' ),
|
||||
'override' => false,
|
||||
'override' => array( 'color', 'defaultGradients' ),
|
||||
'value_key' => 'gradient',
|
||||
'css_vars' => '--wp--preset--gradient--$slug',
|
||||
'classes' => array( '.has-$slug-gradient-background' => 'background' ),
|
||||
@@ -397,13 +397,16 @@ class WP_Theme_JSON {
|
||||
private static function maybe_opt_in_into_settings( $theme_json ) {
|
||||
$new_theme_json = $theme_json;
|
||||
|
||||
if ( isset( $new_theme_json['settings']['appearanceTools'] ) ) {
|
||||
if (
|
||||
isset( $new_theme_json['settings']['appearanceTools'] ) &&
|
||||
true === $new_theme_json['settings']['appearanceTools']
|
||||
) {
|
||||
self::do_opt_in_into_settings( $new_theme_json['settings'] );
|
||||
}
|
||||
|
||||
if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) {
|
||||
foreach ( $new_theme_json['settings']['blocks'] as &$block ) {
|
||||
if ( isset( $block['appearanceTools'] ) ) {
|
||||
if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) {
|
||||
self::do_opt_in_into_settings( $block );
|
||||
}
|
||||
}
|
||||
@@ -433,7 +436,9 @@ class WP_Theme_JSON {
|
||||
);
|
||||
|
||||
foreach ( $to_opt_in as $path ) {
|
||||
if ( null === _wp_array_get( $context, $path, null ) ) {
|
||||
// Use "unset prop" as a marker instead of "null" because
|
||||
// "null" can be a valid value for some props (e.g. blockGap).
|
||||
if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) {
|
||||
_wp_array_set( $context, $path, true );
|
||||
}
|
||||
}
|
||||
@@ -1502,9 +1507,9 @@ class WP_Theme_JSON {
|
||||
* we remove it from the theme presets.
|
||||
*/
|
||||
$nodes = self::get_setting_nodes( $incoming_data );
|
||||
$slugs_global = self::get_slugs_not_to_override( $this->theme_json );
|
||||
$slugs_global = self::get_default_slugs( $this->theme_json, array( 'settings' ) );
|
||||
foreach ( $nodes as $node ) {
|
||||
$slugs_node = self::get_slugs_not_to_override( $this->theme_json, $node['path'] );
|
||||
$slugs_node = self::get_default_slugs( $this->theme_json, $node['path'] );
|
||||
$slugs = array_merge_recursive( $slugs_global, $slugs_node );
|
||||
|
||||
// Replace the spacing.units.
|
||||
@@ -1516,6 +1521,8 @@ class WP_Theme_JSON {
|
||||
|
||||
// Replace the presets.
|
||||
foreach ( self::PRESETS_METADATA as $preset ) {
|
||||
$override_preset = self::should_override_preset( $this->theme_json, $node['path'], $preset['override'] );
|
||||
|
||||
foreach ( self::VALID_ORIGINS as $origin ) {
|
||||
$path = array_merge( $node['path'], $preset['path'], array( $origin ) );
|
||||
$content = _wp_array_get( $incoming_data, $path, null );
|
||||
@@ -1525,13 +1532,12 @@ class WP_Theme_JSON {
|
||||
|
||||
if (
|
||||
( 'theme' !== $origin ) ||
|
||||
( 'theme' === $origin && $preset['override'] )
|
||||
( 'theme' === $origin && $override_preset )
|
||||
) {
|
||||
_wp_array_set( $this->theme_json, $path, $content );
|
||||
}
|
||||
|
||||
if ( 'theme' === $origin && ! $preset['override'] ) {
|
||||
$content = self::filter_slugs( $content, $preset['path'], $slugs );
|
||||
} else {
|
||||
$slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() );
|
||||
$content = self::filter_slugs( $content, $slugs_for_preset );
|
||||
_wp_array_set( $this->theme_json, $path, $content );
|
||||
}
|
||||
}
|
||||
@@ -1540,13 +1546,55 @@ class WP_Theme_JSON {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slugs for all the presets that cannot be overriden
|
||||
* in the given path. It returns an associative array
|
||||
* Returns whether a presets should be overriden or not.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $theme_json The theme.json like structure to inspect.
|
||||
* @param array $path Path to inspect.
|
||||
* @param bool|array $override Data to compute whether to override the preset.
|
||||
* @return boolean
|
||||
*/
|
||||
private static function should_override_preset( $theme_json, $path, $override ) {
|
||||
if ( is_bool( $override ) ) {
|
||||
return $override;
|
||||
}
|
||||
|
||||
/*
|
||||
* The relationship between whether to override the defaults
|
||||
* and whether the defaults are enabled is inverse:
|
||||
*
|
||||
* - If defaults are enabled => theme presets should not be overriden
|
||||
* - If defaults are disabled => theme presets should be overriden
|
||||
*
|
||||
* For example, a theme sets defaultPalette to false,
|
||||
* making the default palette hidden from the user.
|
||||
* In that case, we want all the theme presets to be present,
|
||||
* so they should override the defaults.
|
||||
*/
|
||||
if ( is_array( $override ) ) {
|
||||
$value = _wp_array_get( $theme_json, array_merge( $path, $override ) );
|
||||
if ( isset( $value ) ) {
|
||||
return ! $value;
|
||||
}
|
||||
|
||||
// Search the top-level key if none was found for this node.
|
||||
$value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $override ) );
|
||||
if ( isset( $value ) ) {
|
||||
return ! $value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default slugs for all the presets in an associative array
|
||||
* whose keys are the preset paths and the leafs is the list of slugs.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* array(
|
||||
* array(
|
||||
* 'color' => array(
|
||||
* 'palette' => array( 'slug-1', 'slug-2' ),
|
||||
* 'gradients' => array( 'slug-3', 'slug-4' ),
|
||||
@@ -1555,26 +1603,23 @@ class WP_Theme_JSON {
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $data A theme.json like structure to inspect.
|
||||
* @param array $node_path The path to inspect. Default `array( 'settings' )`.
|
||||
* @return array An associative array containing the slugs for the given path.
|
||||
* @param array $data A theme.json like structure.
|
||||
* @param array $node_path The path to inspect. It's 'settings' by default.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_slugs_not_to_override( $data, $node_path = array( 'settings' ) ) {
|
||||
private static function get_default_slugs( $data, $node_path ) {
|
||||
$slugs = array();
|
||||
foreach ( self::PRESETS_METADATA as $metadata ) {
|
||||
if ( $metadata['override'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slugs_for_preset = array();
|
||||
$path = array_merge( $node_path, $metadata['path'], array( 'default' ) );
|
||||
$preset = _wp_array_get( $data, $path, null );
|
||||
foreach ( self::PRESETS_METADATA as $metadata ) {
|
||||
$path = array_merge( $node_path, $metadata['path'], array( 'default' ) );
|
||||
$preset = _wp_array_get( $data, $path, null );
|
||||
if ( ! isset( $preset ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slugs_for_preset = array();
|
||||
$slugs_for_preset = array_map(
|
||||
function( $value ) {
|
||||
static function( $value ) {
|
||||
return isset( $value['slug'] ) ? $value['slug'] : null;
|
||||
},
|
||||
$preset
|
||||
@@ -1591,19 +1636,17 @@ class WP_Theme_JSON {
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $node The node with the presets to validate.
|
||||
* @param array $path The path to the preset type to inspect.
|
||||
* @param array $slugs The slugs that should not be overriden.
|
||||
* @return array The new node.
|
||||
*/
|
||||
private static function filter_slugs( $node, $path, $slugs ) {
|
||||
$slugs_for_preset = _wp_array_get( $slugs, $path, array() );
|
||||
if ( empty( $slugs_for_preset ) ) {
|
||||
private static function filter_slugs( $node, $slugs ) {
|
||||
if ( empty( $slugs ) ) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
$new_node = array();
|
||||
foreach ( $node as $value ) {
|
||||
if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs_for_preset, true ) ) {
|
||||
if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) {
|
||||
$new_node[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,6 +563,7 @@ add_action( 'enqueue_block_editor_assets', 'wp_enqueue_registered_block_scripts_
|
||||
add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' );
|
||||
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
|
||||
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_format_library_assets' );
|
||||
add_action( 'enqueue_block_editor_assets', 'wp_enqueue_global_styles_css_custom_properties' );
|
||||
add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' );
|
||||
add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
|
||||
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
|
||||
|
||||
@@ -504,7 +504,7 @@ function create_initial_post_types() {
|
||||
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
|
||||
'has_archive' => false,
|
||||
'show_ui' => wp_is_block_theme(),
|
||||
'show_in_menu' => 'themes.php',
|
||||
'show_in_menu' => false,
|
||||
'show_in_admin_bar' => false,
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => false,
|
||||
|
||||
@@ -2863,3 +2863,14 @@ function wp_add_iframed_editor_assets_html() {
|
||||
|
||||
echo "<script>window.__editorAssets = $editor_assets</script>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that enqueues the CSS Custom Properties coming from theme.json.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*/
|
||||
function wp_enqueue_global_styles_css_custom_properties() {
|
||||
wp_register_style( 'global-styles-css-custom-properties', false, array(), true, true );
|
||||
wp_add_inline_style( 'global-styles-css-custom-properties', wp_get_global_stylesheet( array( 'variables' ) ) );
|
||||
wp_enqueue_style( 'global-styles-css-custom-properties' );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user