mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-25 13:44:30 +00:00
Update @wordpress packages
Update packages to include these bug fixes from Gutenberg: - FSE: Add welcome guide - Update theme styles for the code block - Add feature flag to toggle the new site editor sidebar - Add templates list page for site editor - Cover Block: Fix default background dim - E2E: Add more Cover block tests - Cover Block: Fix regressions - Post Comments Form: ensure typography styles are applied to child elements - Navigation: Fix space-between - Fix background colours in nested submenus. - Fix duplicate custom classnames in navigation submenu block - Fix colour rendering in Navigation overlay - Fix: Add ability to opt out of Core color palette V2 - Change @package to WordPress in block-library - Make the core color palette opt-in for themes with not theme.json - Remove textdomain from calendar block - Page List block: fix space before href attribute - Try: Let Featured Image block inherit dimensions, look like a placeholder - [Global Styles]: Add block icon next to blocks list - Page List: Use core entities instead of direct apiFetch - Site Editor: Stabilize export endpoint - Fix mobile horizontal scrollbar. - Multi-entity save: Only set site entity to pending if really saving - Add page list to navigation direct insert conditions - Implement "Add New" for templates list in Site Editor - Post Featured Image: Remove withNotices HOC - Fix page list missing button styles when set to open on click. - Make appender fixed position to avoid jumps in the UI - Color UI component: reorder palettes and update names (core by defaults, user by custom) - Remove the Styles link in Site Editor - GlobalStyles sidebar: do not show default palette if theme opts-out - Only render the site editor canvas when the global styles are ready. - Global Styles: rename core origin key to default for presets - Clarify i18n context for PostTemplateActions's "New" label - Revert erroneous native editor package version bumps - Try: Hide the columns inserter in pattern previews. - Fix site editor region navigation - Update navigation sidebar responsiveness - Add _wp_array_set and _wp_to_kebab_case to 5.8 compat - Make user able to change all color palette origins - Site Editor: Update hrefs to not specifically refer to themes.php?page=gutenberg-edit-site - Site Editor: Validate the postType query argument - Navigation: Scale submenu icon. - Move the theme editor under tools for FSE themes - Deprecate navigation areas See #54487. git-svn-id: https://develop.svn.wordpress.org/trunk@52232 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -212,19 +212,13 @@ if ( wp_is_block_template_theme() ) {
|
||||
'edit_theme_options',
|
||||
'site-editor.php',
|
||||
);
|
||||
|
||||
$submenu['themes.php'][7] = array(
|
||||
__( 'Styles' ),
|
||||
'edit_theme_options',
|
||||
'site-editor.php?styles=open',
|
||||
);
|
||||
}
|
||||
|
||||
// Hide Customize link on block themes unless a plugin or theme is using
|
||||
// customize_register to add a setting.
|
||||
if ( ! wp_is_block_template_theme() || has_action( 'customize_register' ) ) {
|
||||
$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
|
||||
$position = wp_is_block_template_theme() ? 8 : 6;
|
||||
$position = wp_is_block_template_theme() ? 7 : 6;
|
||||
|
||||
$submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );
|
||||
}
|
||||
@@ -249,17 +243,24 @@ unset( $appearance_cap );
|
||||
|
||||
// Add 'Theme Editor' to the bottom of the Appearance menu.
|
||||
if ( ! is_multisite() ) {
|
||||
// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
|
||||
add_action( 'admin_menu', '_add_themes_utility_last', 101 );
|
||||
}
|
||||
/**
|
||||
* Adds the 'Theme Editor' link to the bottom of the Appearance menu.
|
||||
* Adds the 'Theme Editor' link to the bottom of the Appearance or Tools menu.
|
||||
*
|
||||
* @access private
|
||||
* @since 3.0.0
|
||||
* @since 5.9.0 'Theme Editor' link has moved to the Tools menu when a block theme is active.
|
||||
*/
|
||||
function _add_themes_utility_last() {
|
||||
// Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook.
|
||||
add_submenu_page( 'themes.php', __( 'Theme Editor' ), __( 'Theme Editor' ), 'edit_themes', 'theme-editor.php' );
|
||||
add_submenu_page(
|
||||
wp_is_block_template_theme() ? 'tools.php' : 'themes.php',
|
||||
__( 'Theme Editor' ),
|
||||
__( 'Theme Editor' ),
|
||||
'edit_themes',
|
||||
'theme-editor.php'
|
||||
);
|
||||
}
|
||||
|
||||
$count = '';
|
||||
|
||||
@@ -40,61 +40,90 @@ add_filter(
|
||||
);
|
||||
|
||||
$block_editor_context = new WP_Block_Editor_Context();
|
||||
|
||||
$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id();
|
||||
$active_theme = wp_get_theme()->get_stylesheet();
|
||||
$preload_paths = array(
|
||||
array( '/wp/v2/media', 'OPTIONS' ),
|
||||
'/',
|
||||
'/wp/v2/types?context=edit',
|
||||
'/wp/v2/taxonomies?context=edit',
|
||||
'/wp/v2/pages?context=edit',
|
||||
'/wp/v2/categories?context=edit',
|
||||
'/wp/v2/posts?context=edit',
|
||||
'/wp/v2/tags?context=edit',
|
||||
'/wp/v2/templates?context=edit',
|
||||
'/wp/v2/template-parts?context=edit',
|
||||
'/wp/v2/settings',
|
||||
'/wp/v2/themes?context=edit&status=active',
|
||||
'/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit',
|
||||
'/wp/v2/global-styles/' . $active_global_styles_id,
|
||||
'/wp/v2/themes/' . $active_theme . '/global-styles',
|
||||
'/wp/v2/block-navigation-areas?context=edit',
|
||||
$custom_settings = array(
|
||||
'siteUrl' => site_url(),
|
||||
'postsPerPage' => get_option( 'posts_per_page' ),
|
||||
'styles' => get_block_editor_theme_styles(),
|
||||
'defaultTemplateTypes' => get_default_block_template_types(),
|
||||
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
|
||||
'__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
|
||||
'__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
|
||||
);
|
||||
$editor_settings = get_block_editor_settings( $custom_settings, $block_editor_context );
|
||||
|
||||
$areas = get_option( 'wp_navigation_areas', array() );
|
||||
$active_areas = array_intersect_key( $areas, get_navigation_areas() );
|
||||
foreach ( $active_areas as $post_id ) {
|
||||
if ( $post_id ) {
|
||||
$preload_paths[] = add_query_arg( 'context', 'edit', rest_get_route_for_post( $post_id ) );
|
||||
if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) {
|
||||
|
||||
$post_type = get_post_type_object( $_GET['postType'] );
|
||||
|
||||
if ( ! $post_type ) {
|
||||
wp_die( __( 'Invalid post type.' ) );
|
||||
}
|
||||
|
||||
$preload_paths = array(
|
||||
'/',
|
||||
'/wp/v2/types/' . $post_type->name . '?context=edit',
|
||||
'/wp/v2/types?context=edit',
|
||||
'/wp/v2/' . $post_type->rest_base . '?context=edit',
|
||||
);
|
||||
|
||||
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
|
||||
|
||||
wp_add_inline_script(
|
||||
'wp-edit-site',
|
||||
sprintf(
|
||||
'wp.domReady( function() {
|
||||
wp.editSite.initializeList( "site-editor", "%s", %s );
|
||||
} );',
|
||||
$post_type->name,
|
||||
wp_json_encode( $editor_settings )
|
||||
)
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id();
|
||||
$active_theme = wp_get_theme()->get_stylesheet();
|
||||
$preload_paths = array(
|
||||
array( '/wp/v2/media', 'OPTIONS' ),
|
||||
'/',
|
||||
'/wp/v2/types?context=edit',
|
||||
'/wp/v2/taxonomies?context=edit',
|
||||
'/wp/v2/pages?context=edit',
|
||||
'/wp/v2/categories?context=edit',
|
||||
'/wp/v2/posts?context=edit',
|
||||
'/wp/v2/tags?context=edit',
|
||||
'/wp/v2/templates?context=edit',
|
||||
'/wp/v2/template-parts?context=edit',
|
||||
'/wp/v2/settings',
|
||||
'/wp/v2/themes?context=edit&status=active',
|
||||
'/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit',
|
||||
'/wp/v2/global-styles/' . $active_global_styles_id,
|
||||
'/wp/v2/themes/' . $active_theme . '/global-styles',
|
||||
'/wp/v2/block-navigation-areas?context=edit',
|
||||
);
|
||||
|
||||
$areas = get_option( 'wp_navigation_areas', array() );
|
||||
$active_areas = array_intersect_key( $areas, get_navigation_areas() );
|
||||
foreach ( $active_areas as $post_id ) {
|
||||
if ( $post_id ) {
|
||||
$preload_paths[] = add_query_arg( 'context', 'edit', rest_get_route_for_post( $post_id ) );
|
||||
}
|
||||
}
|
||||
|
||||
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
|
||||
|
||||
wp_add_inline_script(
|
||||
'wp-edit-site',
|
||||
sprintf(
|
||||
'wp.domReady( function() {
|
||||
wp.editSite.initializeEditor( "site-editor", %s );
|
||||
} );',
|
||||
wp_json_encode( $editor_settings )
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
|
||||
|
||||
$editor_settings = get_block_editor_settings(
|
||||
array(
|
||||
'siteUrl' => site_url(),
|
||||
'postsPerPage' => get_option( 'posts_per_page' ),
|
||||
'styles' => get_block_editor_theme_styles(),
|
||||
'defaultTemplateTypes' => get_default_block_template_types(),
|
||||
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
|
||||
'__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
|
||||
'__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
|
||||
),
|
||||
$block_editor_context
|
||||
);
|
||||
|
||||
wp_add_inline_script(
|
||||
'wp-edit-site',
|
||||
sprintf(
|
||||
'wp.domReady( function() {
|
||||
wp.editSite.initialize( "site-editor", %s );
|
||||
} );',
|
||||
wp_json_encode( $editor_settings )
|
||||
)
|
||||
);
|
||||
|
||||
// Preload server-registered block schemas.
|
||||
wp_add_inline_script(
|
||||
'wp-blocks',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -342,7 +342,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||
$colors_by_origin['user'] : (
|
||||
isset( $colors_by_origin['theme'] ) ?
|
||||
$colors_by_origin['theme'] :
|
||||
$colors_by_origin['core']
|
||||
$colors_by_origin['default']
|
||||
);
|
||||
}
|
||||
if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
|
||||
@@ -351,7 +351,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||
$gradients_by_origin['user'] : (
|
||||
isset( $gradients_by_origin['theme'] ) ?
|
||||
$gradients_by_origin['theme'] :
|
||||
$gradients_by_origin['core']
|
||||
$gradients_by_origin['default']
|
||||
);
|
||||
}
|
||||
if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
|
||||
@@ -360,7 +360,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||
$font_sizes_by_origin['user'] : (
|
||||
isset( $font_sizes_by_origin['theme'] ) ?
|
||||
$font_sizes_by_origin['theme'] :
|
||||
$font_sizes_by_origin['core']
|
||||
$font_sizes_by_origin['default']
|
||||
);
|
||||
}
|
||||
if ( isset( $editor_settings['__experimentalFeatures']['color']['custom'] ) ) {
|
||||
|
||||
@@ -19,7 +19,7 @@ function render_block_core_calendar( $attributes ) {
|
||||
// when there are no published posts on the site.
|
||||
if ( ! block_core_calendar_has_published_posts() ) {
|
||||
if ( is_user_logged_in() ) {
|
||||
return '<div>' . __( 'The calendar block is hidden because there are no published posts.', 'gutenberg' ) . '</div>';
|
||||
return '<div>' . __( 'The calendar block is hidden because there are no published posts.' ) . '</div>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
/**
|
||||
* Server-side rendering of the `core/navigation-area` block.
|
||||
*
|
||||
* @package gutenberg
|
||||
* @deprecated 5.9.0 See https://github.com/WordPress/gutenberg/issues/36524
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Server-side rendering of the `core/navigation-link` block.
|
||||
*
|
||||
* @package gutenberg
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Server-side rendering of the `core/navigation-submenu` block.
|
||||
*
|
||||
* @package gutenberg
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ function block_core_navigation_submenu_build_css_colors( $context, $attributes )
|
||||
'inline_styles' => '',
|
||||
);
|
||||
|
||||
$is_sub_menu = isset( $attributes['isTopLevelLink'] ) ? ( ! $attributes['isTopLevelLink'] ) : false;
|
||||
$is_sub_menu = isset( $attributes['isTopLevelItem'] ) ? ( ! $attributes['isTopLevelItem'] ) : false;
|
||||
|
||||
// Text color.
|
||||
$named_text_color = null;
|
||||
@@ -150,12 +150,6 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
||||
$has_submenu = count( $block->inner_blocks ) > 0;
|
||||
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === $attributes['id'] );
|
||||
|
||||
$class_name = ! empty( $attributes['className'] ) ? implode( ' ', (array) $attributes['className'] ) : false;
|
||||
|
||||
if ( false !== $class_name ) {
|
||||
$css_classes .= ' ' . $class_name;
|
||||
}
|
||||
|
||||
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
|
||||
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
|
||||
$open_on_hover_and_click = isset( $block->context['openSubmenusOnClick'] ) && ! $block->context['openSubmenusOnClick'] &&
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Server-side rendering of the `core/navigation` block.
|
||||
*
|
||||
* @package gutenberg
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -14,8 +14,10 @@
|
||||
*/
|
||||
function block_core_navigation_build_css_colors( $attributes ) {
|
||||
$colors = array(
|
||||
'css_classes' => array(),
|
||||
'inline_styles' => '',
|
||||
'css_classes' => array(),
|
||||
'inline_styles' => '',
|
||||
'overlay_css_classes' => array(),
|
||||
'overlay_inline_styles' => '',
|
||||
);
|
||||
|
||||
// Text color.
|
||||
@@ -54,6 +56,42 @@ function block_core_navigation_build_css_colors( $attributes ) {
|
||||
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $attributes['customBackgroundColor'] );
|
||||
}
|
||||
|
||||
// Overlay text color.
|
||||
$has_named_overlay_text_color = array_key_exists( 'overlayTextColor', $attributes );
|
||||
$has_custom_overlay_text_color = array_key_exists( 'customOverlayTextColor', $attributes );
|
||||
|
||||
// If has overlay text color.
|
||||
if ( $has_custom_overlay_text_color || $has_named_overlay_text_color ) {
|
||||
// Add has-text-color class.
|
||||
$colors['overlay_css_classes'][] = 'has-text-color';
|
||||
}
|
||||
|
||||
if ( $has_named_overlay_text_color ) {
|
||||
// Add the overlay color class.
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-color', $attributes['overlayTextColor'] );
|
||||
} elseif ( $has_custom_overlay_text_color ) {
|
||||
// Add the custom overlay color inline style.
|
||||
$colors['overlay_inline_styles'] .= sprintf( 'color: %s;', $attributes['customOverlayTextColor'] );
|
||||
}
|
||||
|
||||
// Overlay background color.
|
||||
$has_named_overlay_background_color = array_key_exists( 'overlayBackgroundColor', $attributes );
|
||||
$has_custom_overlay_background_color = array_key_exists( 'customOverlayBackgroundColor', $attributes );
|
||||
|
||||
// If has overlay background color.
|
||||
if ( $has_custom_overlay_background_color || $has_named_overlay_background_color ) {
|
||||
// Add has-background class.
|
||||
$colors['overlay_css_classes'][] = 'has-background';
|
||||
}
|
||||
|
||||
if ( $has_named_overlay_background_color ) {
|
||||
// Add the overlay background-color class.
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-background-color', $attributes['overlayBackgroundColor'] );
|
||||
} elseif ( $has_custom_overlay_background_color ) {
|
||||
// Add the custom overlay background-color inline style.
|
||||
$colors['overlay_inline_styles'] .= sprintf( 'background-color: %s;', $attributes['customOverlayBackgroundColor'] );
|
||||
}
|
||||
|
||||
return $colors;
|
||||
}
|
||||
|
||||
@@ -247,6 +285,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
$responsive_container_classes = array(
|
||||
'wp-block-navigation__responsive-container',
|
||||
$is_hidden_by_default ? 'hidden-by-default' : '',
|
||||
implode( ' ', $colors['overlay_css_classes'] ),
|
||||
);
|
||||
$open_button_classes = array(
|
||||
'wp-block-navigation__responsive-container-open',
|
||||
@@ -255,7 +294,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
|
||||
$responsive_container_markup = sprintf(
|
||||
'<button aria-expanded="false" aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
|
||||
<div class="%5$s" id="modal-%1$s">
|
||||
<div class="%5$s" style="%7$s" id="modal-%1$s">
|
||||
<div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
|
||||
<div class="wp-block-navigation__responsive-dialog" role="dialog" aria-modal="true" aria-labelledby="modal-%1$s-title" >
|
||||
<button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
|
||||
@@ -270,7 +309,8 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
||||
__( 'Open menu' ), // Open button label.
|
||||
__( 'Close menu' ), // Close button label.
|
||||
implode( ' ', $responsive_container_classes ),
|
||||
implode( ' ', $open_button_classes )
|
||||
implode( ' ', $open_button_classes ),
|
||||
$colors['overlay_inline_styles']
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
|
||||
@@ -34,7 +34,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
||||
|
||||
if ( $has_named_text_color ) {
|
||||
// Add the color class.
|
||||
$colors['css_classes'][] = sprintf( 'has-%s-color', gutenberg_experimental_to_kebab_case( $context['textColor'] ) );
|
||||
$colors['css_classes'][] = sprintf( 'has-%s-color', _wp_to_kebab_case( $context['textColor'] ) );
|
||||
} elseif ( $has_picked_text_color ) {
|
||||
$colors['inline_styles'] .= sprintf( 'color: %s;', $context['customTextColor'] );
|
||||
} elseif ( $has_custom_text_color ) {
|
||||
@@ -55,7 +55,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
||||
|
||||
if ( $has_named_background_color ) {
|
||||
// Add the background-color class.
|
||||
$colors['css_classes'][] = sprintf( 'has-%s-background-color', gutenberg_experimental_to_kebab_case( $context['backgroundColor'] ) );
|
||||
$colors['css_classes'][] = sprintf( 'has-%s-background-color', _wp_to_kebab_case( $context['backgroundColor'] ) );
|
||||
} elseif ( $has_picked_background_color ) {
|
||||
$colors['inline_styles'] .= sprintf( 'background-color: %s;', $context['customBackgroundColor'] );
|
||||
} elseif ( $has_custom_background_color ) {
|
||||
@@ -74,7 +74,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
||||
|
||||
// Give overlay colors priority, fall back to Navigation block colors, then global styles.
|
||||
if ( $has_named_overlay_text_color ) {
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-color', gutenberg_experimental_to_kebab_case( $context['overlayTextColor'] ) );
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-color', _wp_to_kebab_case( $context['overlayTextColor'] ) );
|
||||
} elseif ( $has_picked_overlay_text_color ) {
|
||||
$colors['overlay_inline_styles'] .= sprintf( 'color: %s;', $context['customOverlayTextColor'] );
|
||||
}
|
||||
@@ -89,7 +89,7 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
||||
}
|
||||
|
||||
if ( $has_named_overlay_background_color ) {
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-background-color', gutenberg_experimental_to_kebab_case( $context['overlayBackgroundColor'] ) );
|
||||
$colors['overlay_css_classes'][] = sprintf( 'has-%s-background-color', _wp_to_kebab_case( $context['overlayBackgroundColor'] ) );
|
||||
} elseif ( $has_picked_overlay_background_color ) {
|
||||
$colors['overlay_inline_styles'] .= sprintf( 'background-color: %s;', $context['customOverlayBackgroundColor'] );
|
||||
}
|
||||
@@ -182,7 +182,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
|
||||
) . '<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 . '>' . wp_kses(
|
||||
$markup .= '<a class="wp-block-pages-list__item__link' . $navigation_child_content_class . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . wp_kses(
|
||||
$page['title'],
|
||||
wp_kses_allowed_html( 'post' )
|
||||
) . '</a>';
|
||||
|
||||
@@ -136,7 +136,7 @@ class WP_Theme_JSON_Resolver {
|
||||
|
||||
$config = self::read_json_file( __DIR__ . '/theme.json' );
|
||||
$config = self::translate( $config );
|
||||
self::$core = new WP_Theme_JSON( $config, 'core' );
|
||||
self::$core = new WP_Theme_JSON( $config, 'default' );
|
||||
|
||||
return self::$core;
|
||||
}
|
||||
@@ -182,7 +182,32 @@ class WP_Theme_JSON_Resolver {
|
||||
* So we take theme supports, transform it to theme.json shape
|
||||
* and merge the self::$theme upon that.
|
||||
*/
|
||||
$theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_default_block_editor_settings() );
|
||||
$theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_default_block_editor_settings() );
|
||||
if ( ! self::theme_has_support() ) {
|
||||
if ( ! isset( $theme_support_data['settings']['color'] ) ) {
|
||||
$theme_support_data['settings']['color'] = array();
|
||||
}
|
||||
|
||||
$default_palette = false;
|
||||
if ( current_theme_supports( 'default-color-palette' ) ) {
|
||||
$default_palette = true;
|
||||
}
|
||||
if ( ! isset( $theme_support_data['settings']['color']['palette'] ) ) {
|
||||
// If the theme does not have any palette, we still want to show the core one.
|
||||
$default_palette = true;
|
||||
}
|
||||
$theme_support_data['settings']['color']['defaultPalette'] = $default_palette;
|
||||
|
||||
$default_gradients = false;
|
||||
if ( current_theme_supports( 'default-gradient-presets' ) ) {
|
||||
$default_gradients = true;
|
||||
}
|
||||
if ( ! isset( $theme_support_data['settings']['color']['gradients'] ) ) {
|
||||
// If the theme does not have any gradients, we still want to show the core ones.
|
||||
$default_gradients = true;
|
||||
}
|
||||
$theme_support_data['settings']['color']['defaultGradients'] = $default_gradients;
|
||||
}
|
||||
$with_theme_supports = new WP_Theme_JSON( $theme_support_data );
|
||||
$with_theme_supports->merge( self::$theme );
|
||||
|
||||
@@ -293,7 +318,7 @@ class WP_Theme_JSON_Resolver {
|
||||
|
||||
/**
|
||||
* There are three sources of data (origins) for a site:
|
||||
* core, theme, and user. The user's has higher priority
|
||||
* default, theme, and user. The user's has higher priority
|
||||
* than the theme's, and the theme's higher than core's.
|
||||
*
|
||||
* Unlike the getters {@link get_core_data},
|
||||
|
||||
@@ -51,7 +51,7 @@ class WP_Theme_JSON {
|
||||
* @var string[]
|
||||
*/
|
||||
const VALID_ORIGINS = array(
|
||||
'core',
|
||||
'default',
|
||||
'theme',
|
||||
'user',
|
||||
);
|
||||
@@ -220,15 +220,17 @@ class WP_Theme_JSON {
|
||||
'width' => null,
|
||||
),
|
||||
'color' => array(
|
||||
'background' => null,
|
||||
'custom' => null,
|
||||
'customDuotone' => null,
|
||||
'customGradient' => null,
|
||||
'duotone' => null,
|
||||
'gradients' => null,
|
||||
'link' => null,
|
||||
'palette' => null,
|
||||
'text' => null,
|
||||
'background' => null,
|
||||
'custom' => null,
|
||||
'customDuotone' => null,
|
||||
'customGradient' => null,
|
||||
'defaultGradients' => null,
|
||||
'defaultPalette' => null,
|
||||
'duotone' => null,
|
||||
'gradients' => null,
|
||||
'link' => null,
|
||||
'palette' => null,
|
||||
'text' => null,
|
||||
),
|
||||
'custom' => null,
|
||||
'layout' => array(
|
||||
@@ -324,7 +326,7 @@ class WP_Theme_JSON {
|
||||
*
|
||||
* @param array $theme_json A structure that follows the theme.json schema.
|
||||
* @param string $origin Optional. What source of data this object represents.
|
||||
* One of 'core', 'theme', or 'user'. Default 'theme'.
|
||||
* One of 'default', 'theme', or 'user'. Default 'theme'.
|
||||
*/
|
||||
public function __construct( $theme_json = array(), $origin = 'theme' ) {
|
||||
if ( ! in_array( $origin, self::VALID_ORIGINS, true ) ) {
|
||||
@@ -343,7 +345,9 @@ class WP_Theme_JSON {
|
||||
$path = array_merge( $node['path'], $preset_metadata['path'] );
|
||||
$preset = _wp_array_get( $this->theme_json, $path, null );
|
||||
if ( null !== $preset ) {
|
||||
_wp_array_set( $this->theme_json, $path, array( $origin => $preset ) );
|
||||
if ( 'user' !== $origin || isset( $preset[0] ) ) {
|
||||
_wp_array_set( $this->theme_json, $path, array( $origin => $preset ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1472,46 +1476,48 @@ class WP_Theme_JSON {
|
||||
private static function remove_insecure_settings( $input ) {
|
||||
$output = array();
|
||||
foreach ( self::PRESETS_METADATA as $preset_metadata ) {
|
||||
$presets = _wp_array_get( $input, $preset_metadata['path'], null );
|
||||
if ( null === $presets ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( self::VALID_ORIGINS as $origin ) {
|
||||
$path_with_origin = array_merge( $preset_metadata['path'], array( $origin ) );
|
||||
$presets = _wp_array_get( $input, $path_with_origin, null );
|
||||
if ( null === $presets ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$escaped_preset = array();
|
||||
foreach ( $presets as $preset ) {
|
||||
if (
|
||||
esc_attr( esc_html( $preset['name'] ) ) === $preset['name'] &&
|
||||
sanitize_html_class( $preset['slug'] ) === $preset['slug']
|
||||
) {
|
||||
$value = null;
|
||||
if ( isset( $preset_metadata['value_key'] ) ) {
|
||||
$value = $preset[ $preset_metadata['value_key'] ];
|
||||
} elseif (
|
||||
isset( $preset_metadata['value_func'] ) &&
|
||||
is_callable( $preset_metadata['value_func'] )
|
||||
$escaped_preset = array();
|
||||
foreach ( $presets as $preset ) {
|
||||
if (
|
||||
esc_attr( esc_html( $preset['name'] ) ) === $preset['name'] &&
|
||||
sanitize_html_class( $preset['slug'] ) === $preset['slug']
|
||||
) {
|
||||
$value = call_user_func( $preset_metadata['value_func'], $preset );
|
||||
}
|
||||
$value = null;
|
||||
if ( isset( $preset_metadata['value_key'] ) ) {
|
||||
$value = $preset[ $preset_metadata['value_key'] ];
|
||||
} elseif (
|
||||
isset( $preset_metadata['value_func'] ) &&
|
||||
is_callable( $preset_metadata['value_func'] )
|
||||
) {
|
||||
$value = call_user_func( $preset_metadata['value_func'], $preset );
|
||||
}
|
||||
|
||||
$preset_is_valid = true;
|
||||
foreach ( $preset_metadata['properties'] as $property ) {
|
||||
if ( ! self::is_safe_css_declaration( $property, $value ) ) {
|
||||
$preset_is_valid = false;
|
||||
break;
|
||||
$preset_is_valid = true;
|
||||
foreach ( $preset_metadata['properties'] as $property ) {
|
||||
if ( ! self::is_safe_css_declaration( $property, $value ) ) {
|
||||
$preset_is_valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $preset_is_valid ) {
|
||||
$escaped_preset[] = $preset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $preset_is_valid ) {
|
||||
$escaped_preset[] = $preset;
|
||||
}
|
||||
if ( ! empty( $escaped_preset ) ) {
|
||||
_wp_array_set( $output, $path_with_origin, $escaped_preset );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $escaped_preset ) ) {
|
||||
_wp_array_set( $output, $preset_metadata['path'], $escaped_preset );
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,14 +105,14 @@ function wp_get_global_stylesheet( $types = array() ) {
|
||||
$types = array( 'variables', 'styles', 'presets' );
|
||||
}
|
||||
|
||||
$origins = array( 'core', 'theme', 'user' );
|
||||
$origins = array( 'default', 'theme', 'user' );
|
||||
if ( ! $supports_theme_json && ! $supports_link_color ) {
|
||||
// In this case we only enqueue the core presets (CSS Custom Properties + the classes).
|
||||
$origins = array( 'core' );
|
||||
$origins = array( 'default' );
|
||||
} elseif ( ! $supports_theme_json && $supports_link_color ) {
|
||||
// For the legacy link color feature to work, the CSS Custom Properties
|
||||
// should be in scope (either the core or the theme ones).
|
||||
$origins = array( 'core', 'theme' );
|
||||
$origins = array( 'default', 'theme' );
|
||||
}
|
||||
|
||||
$tree = WP_Theme_JSON_Resolver::get_merged_data();
|
||||
|
||||
@@ -357,7 +357,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_template_theme(),
|
||||
'show_in_menu' => 'themes.php',
|
||||
'show_in_menu' => false,
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => false,
|
||||
'rest_base' => 'templates',
|
||||
@@ -416,7 +416,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_template_theme(),
|
||||
'show_in_menu' => 'themes.php',
|
||||
'show_in_menu' => false,
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => false,
|
||||
'rest_base' => 'template-parts',
|
||||
|
||||
Reference in New Issue
Block a user