Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @wordpress packages #1967

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
05d00b8
Update @wordpress packages
noisysocks Nov 29, 2021
937bbc6
Changes from lib/class-wp-theme-json-gutenberg.php
noisysocks Nov 29, 2021
ccbbb95
Changes from lib/class-wp-theme-json-resolver-gutenberg.php
noisysocks Nov 29, 2021
af9864f
Changes from lib/class-gutenberg-rest-global-styles-controller.php
noisysocks Nov 29, 2021
73f04fc
Changes from lib/compat/wordpress-5.9/class-gutenberg-rest-templates-…
noisysocks Nov 29, 2021
b6a128e
Changes from lib/compat/wordpress-5.9/get-global-styles-and-settings.php
noisysocks Nov 29, 2021
454edad
Changes from lib/compat/wordpress-5.9/rest-active-global-styles.php
noisysocks Nov 29, 2021
bd750cd
Changes from lib/full-site-editing/edit-site-page.php
noisysocks Nov 29, 2021
df3fa80
Changes from lib/global-styles.php
noisysocks Nov 29, 2021
a5d4653
Changes from phpunit/class-gutenberg-rest-template-controller-test.php
noisysocks Nov 29, 2021
df89504
Changes from phpunit/class-wp-theme-json-resolver-test.php
noisysocks Nov 29, 2021
036de73
Changes from phpunit/class-wp-theme-json-test.php
noisysocks Nov 29, 2021
636cd6e
Add support to post types
talldan Nov 24, 2021
260f341
Add author support to templates REST API controller
talldan Nov 24, 2021
882906f
Update unit tests
talldan Nov 24, 2021
d329181
Fix linting issue
talldan Nov 25, 2021
b52d986
Add origin field to templates
talldan Nov 25, 2021
bc2b99d
Handle errors from `prepare_item_for_database` in REST templates cont…
talldan Nov 25, 2021
5f21d38
Update tests to support origin
talldan Nov 25, 2021
4e295cb
Address review feedback
talldan Nov 25, 2021
206a49b
Linting fix
talldan Nov 25, 2021
5108478
Remove empty lines
talldan Nov 29, 2021
1334b85
Move call to maybe_opt_in_into_settings() to right place
noisysocks Nov 29, 2021
e55e5d2
Use WP class names
noisysocks Nov 29, 2021
2de4a1b
Fix 'is_custom' assertions in PHPUnit tests
Mamaduka Nov 29, 2021
70b1faa
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
00f0d4e
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
bd31bb4
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
9140346
Sort keys alphabetically so it is easier to compare
oandregal Nov 29, 2021
8e9e04d
Add missing appearanceTools flag
oandregal Nov 29, 2021
b3f4e8f
Apply class-theme-json.php patch
noisysocks Nov 29, 2021
2da12cb
Apply class-wp-theme-json-resolver.php patch
noisysocks Nov 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
268 changes: 135 additions & 133 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -82,53 +82,53 @@
"@wordpress/api-fetch": "5.2.6",
"@wordpress/autop": "3.2.3",
"@wordpress/blob": "3.2.2",
"@wordpress/block-directory": "3.0.11",
"@wordpress/block-editor": "8.0.5",
"@wordpress/block-library": "6.0.9",
"@wordpress/block-directory": "3.0.12",
"@wordpress/block-editor": "8.0.6",
"@wordpress/block-library": "6.0.10",
"@wordpress/block-serialization-default-parser": "4.2.3",
"@wordpress/blocks": "11.1.4",
"@wordpress/components": "19.0.5",
"@wordpress/components": "19.1.0",
"@wordpress/compose": "5.0.6",
"@wordpress/core-data": "4.0.7",
"@wordpress/customize-widgets": "2.0.11",
"@wordpress/core-data": "4.0.8",
"@wordpress/customize-widgets": "2.0.12",
"@wordpress/data": "6.1.4",
"@wordpress/data-controls": "2.2.7",
"@wordpress/date": "4.2.3",
"@wordpress/deprecated": "3.2.3",
"@wordpress/dom": "3.2.7",
"@wordpress/dom-ready": "3.2.3",
"@wordpress/edit-post": "5.0.11",
"@wordpress/edit-site": "3.0.11",
"@wordpress/edit-widgets": "3.1.6",
"@wordpress/editor": "12.0.8",
"@wordpress/edit-post": "5.0.12",
"@wordpress/edit-site": "3.0.12",
"@wordpress/edit-widgets": "3.1.7",
"@wordpress/editor": "12.0.9",
"@wordpress/element": "4.0.4",
"@wordpress/escape-html": "2.2.3",
"@wordpress/format-library": "3.0.11",
"@wordpress/format-library": "3.0.12",
"@wordpress/hooks": "3.2.2",
"@wordpress/html-entities": "3.2.3",
"@wordpress/i18n": "4.2.4",
"@wordpress/icons": "6.1.1",
"@wordpress/interface": "4.1.7",
"@wordpress/interface": "4.1.8",
"@wordpress/is-shallow-equal": "4.2.1",
"@wordpress/keyboard-shortcuts": "3.0.6",
"@wordpress/keycodes": "3.2.4",
"@wordpress/list-reusable-blocks": "3.0.9",
"@wordpress/list-reusable-blocks": "3.0.10",
"@wordpress/media-utils": "3.0.5",
"@wordpress/notices": "3.2.7",
"@wordpress/nux": "5.0.9",
"@wordpress/nux": "5.0.10",
"@wordpress/plugins": "4.0.6",
"@wordpress/primitives": "3.0.4",
"@wordpress/priority-queue": "2.2.3",
"@wordpress/redux-routine": "4.2.2",
"@wordpress/reusable-blocks": "3.0.11",
"@wordpress/reusable-blocks": "3.0.12",
"@wordpress/rich-text": "5.0.6",
"@wordpress/server-side-render": "3.0.9",
"@wordpress/server-side-render": "3.0.10",
"@wordpress/shortcode": "3.2.3",
"@wordpress/token-list": "2.2.2",
"@wordpress/url": "3.3.1",
"@wordpress/viewport": "4.0.6",
"@wordpress/warning": "2.2.2",
"@wordpress/widgets": "2.0.11",
"@wordpress/widgets": "2.0.12",
"@wordpress/wordcount": "3.2.3",
"backbone": "1.4.0",
"clipboard": "2.0.8",
Expand Down
8 changes: 6 additions & 2 deletions src/wp-admin/site-editor.php
Expand Up @@ -23,8 +23,6 @@
wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) );
}

// Used in the HTML title tag.
$title = __( 'Editor (beta)' );
$parent_file = 'themes.php';

// Flag that we're loading the block editor.
Expand Down Expand Up @@ -59,6 +57,9 @@ static function( $classes ) {
wp_die( __( 'Invalid post type.' ) );
}

// Used in the HTML title tag.
$title = $post_type->labels->name;

$preload_paths = array(
'/',
'/wp/v2/types/' . $post_type->name . '?context=edit',
Expand All @@ -81,6 +82,9 @@ static function( $classes ) {

} else {

// Used in the HTML title tag.
$title = __( 'Editor (beta)' );

$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id();
$active_theme = wp_get_theme()->get_stylesheet();
$preload_paths = array(
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/assets/script-loader-packages.php

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/wp-includes/block-editor.php
Expand Up @@ -338,26 +338,26 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
// These settings may need to be updated based on data coming from theme.json sources.
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
$colors_by_origin = $editor_settings['__experimentalFeatures']['color']['palette'];
$editor_settings['colors'] = isset( $colors_by_origin['user'] ) ?
$colors_by_origin['user'] : (
$editor_settings['colors'] = isset( $colors_by_origin['custom'] ) ?
$colors_by_origin['custom'] : (
isset( $colors_by_origin['theme'] ) ?
$colors_by_origin['theme'] :
$colors_by_origin['default']
);
}
if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
$gradients_by_origin = $editor_settings['__experimentalFeatures']['color']['gradients'];
$editor_settings['gradients'] = isset( $gradients_by_origin['user'] ) ?
$gradients_by_origin['user'] : (
$editor_settings['gradients'] = isset( $gradients_by_origin['custom'] ) ?
$gradients_by_origin['custom'] : (
isset( $gradients_by_origin['theme'] ) ?
$gradients_by_origin['theme'] :
$gradients_by_origin['default']
);
}
if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
$font_sizes_by_origin = $editor_settings['__experimentalFeatures']['typography']['fontSizes'];
$editor_settings['fontSizes'] = isset( $font_sizes_by_origin['user'] ) ?
$font_sizes_by_origin['user'] : (
$editor_settings['fontSizes'] = isset( $font_sizes_by_origin['custom'] ) ?
$font_sizes_by_origin['custom'] : (
isset( $font_sizes_by_origin['theme'] ) ?
$font_sizes_by_origin['theme'] :
$font_sizes_by_origin['default']
Expand Down
4 changes: 4 additions & 0 deletions src/wp-includes/block-template-utils.php
Expand Up @@ -525,19 +525,23 @@ function _build_block_template_result_from_post( $post ) {
$has_theme_file = wp_get_theme()->get_stylesheet() === $theme &&
null !== _get_block_template_file( $post->post_type, $post->post_name );

$origin = get_post_meta( $post->ID, 'origin', true );

$template = new WP_Block_Template();
$template->wp_id = $post->ID;
$template->id = $theme . '//' . $post->post_name;
$template->theme = $theme;
$template->content = $post->post_content;
$template->slug = $post->post_name;
$template->source = 'custom';
$template->origin = ! empty( $origin ) ? $origin : null;
$template->type = $post->post_type;
$template->description = $post->post_excerpt;
$template->title = $post->post_title;
$template->status = $post->post_status;
$template->has_theme_file = $has_theme_file;
$template->is_custom = true;
$template->author = $post->post_author;

if ( 'wp_template' === $post->post_type && isset( $default_template_types[ $template->slug ] ) ) {
$template->is_custom = false;
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/blocks/calendar.php
Expand Up @@ -85,7 +85,7 @@ function block_core_calendar_has_published_posts() {
}

// On single sites we try our own cached option first.
$has_published_posts = get_option( 'gutenberg_calendar_block_has_published_posts', null );
$has_published_posts = get_option( 'wp_calendar_block_has_published_posts', null );
if ( null !== $has_published_posts ) {
return (bool) $has_published_posts;
}
Expand All @@ -103,7 +103,7 @@ function block_core_calendar_has_published_posts() {
function block_core_calendar_update_has_published_posts() {
global $wpdb;
$has_published_posts = (bool) $wpdb->get_var( "SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
update_option( 'gutenberg_calendar_block_has_published_posts', $has_published_posts );
update_option( 'wp_calendar_block_has_published_posts', $has_published_posts );
return $has_published_posts;
}

Expand Down
142 changes: 128 additions & 14 deletions src/wp-includes/blocks/navigation.php
Expand Up @@ -9,7 +9,8 @@
* Build an array with CSS classes and inline styles defining the colors
* which will be applied to the navigation markup in the front-end.
*
* @param array $attributes Navigation block attributes.
* @param array $attributes Navigation block attributes.
*
* @return array Colors CSS classes and inline styles.
*/
function block_core_navigation_build_css_colors( $attributes ) {
Expand Down Expand Up @@ -99,7 +100,8 @@ function block_core_navigation_build_css_colors( $attributes ) {
* Build an array with CSS classes and inline styles defining the font sizes
* which will be applied to the navigation markup in the front-end.
*
* @param array $attributes Navigation block attributes.
* @param array $attributes Navigation block attributes.
*
* @return array Font size CSS classes and inline styles.
*/
function block_core_navigation_build_css_font_sizes( $attributes ) {
Expand Down Expand Up @@ -132,6 +134,100 @@ function block_core_navigation_render_submenu_icon() {
return '<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>';
}


/**
* Finds the first non-empty `wp_navigation` Post.
*
* @return WP_Post|null the first non-empty Navigation or null.
*/
function block_core_navigation_get_first_non_empty_navigation() {
// Order and orderby args set to mirror those in `wp_get_nav_menus`
// see:
// - https://github.com/WordPress/wordpress-develop/blob/ba943e113d3b31b121f77a2d30aebe14b047c69d/src/wp-includes/nav-menu.php#L613-L619.
// - https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters.
$navigation_posts = get_posts(
array(
'post_type' => 'wp_navigation',
'order' => 'ASC',
'orderby' => 'name',
'posts_per_page' => 1, // only the first post.
's' => '<!-- wp:', // look for block indicators to ensure we only include non-empty Navigations.
)
);
return count( $navigation_posts ) ? $navigation_posts[0] : null;

}

/**
* Filter out empty "null" blocks from the block list.
* 'parse_blocks' includes a null block with '\n\n' as the content when
* it encounters whitespace. This is not a bug but rather how the parser
* is designed.
*
* @param array $parsed_blocks the parsed blocks to be normalized.
* @return array the normalized parsed blocks.
*/
function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
$filtered = array_filter(
$parsed_blocks,
function( $block ) {
return isset( $block['blockName'] );
}
);

// Reset keys.
return array_values( $filtered );
}

/**
* Retrieves the appropriate fallback to be used on the front of the
* site when there is no menu assigned to the Nav block.
*
* This aims to mirror how the fallback mechanic for wp_nav_menu works.
* See https://developer.wordpress.org/reference/functions/wp_nav_menu/#more-information.
*
* @return array the array of blocks to be used as a fallback.
*/
function block_core_navigation_get_fallback_blocks() {
$page_list_fallback = array(
array(
'blockName' => 'core/page-list',
'attrs' => array(
'__unstableMaxPages' => 4,
),
),
);

$registry = WP_Block_Type_Registry::get_instance();

// If `core/page-list` is not registered then return empty blocks.
$fallback_blocks = $registry->is_registered( 'core/page-list' ) ? $page_list_fallback : array();

// Default to a list of Pages.

$navigation_post = block_core_navigation_get_first_non_empty_navigation();

// Prefer using the first non-empty Navigation as fallback if available.
if ( $navigation_post ) {
$maybe_fallback = block_core_navigation_filter_out_empty_blocks( parse_blocks( $navigation_post->post_content ) );

// Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
// In this case default to the (Page List) fallback.
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
}

/**
* Filters the fallback experience for the Navigation block.
*
* Returning a falsey value will opt out of the fallback and cause the block not to render.
* To customise the blocks provided return an array of blocks - these should be valid
* children of the `core/navigation` block.
*
* @param array[] default fallback blocks provided by the default block mechanic.
*/
return apply_filters( 'block_core_navigation_render_fallback', $fallback_blocks );
}

/**
* Renders the `core/navigation` block on server.
*
Expand All @@ -142,6 +238,11 @@ function block_core_navigation_render_submenu_icon() {
* @return string Returns the post content with the legacy widget added.
*/
function render_block_core_navigation( $attributes, $content, $block ) {

// Flag used to indicate whether the rendered output is considered to be
// a fallback (i.e. the block has no menu associated with it).
$is_fallback = false;

/**
* Deprecated:
* The rgbTextColor and rgbBackgroundColor attributes
Expand Down Expand Up @@ -187,13 +288,17 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$area = $block->context['navigationArea'];
$mapping = get_option( 'wp_navigation_areas', array() );
if ( ! empty( $mapping[ $area ] ) ) {
$attributes['navigationMenuId'] = $mapping[ $area ];
$attributes['ref'] = $mapping[ $area ];
}
}

// Load inner blocks from the navigation post.
// Ensure that blocks saved with the legacy ref attribute name (navigationMenuId) continue to render.
if ( array_key_exists( 'navigationMenuId', $attributes ) ) {
$navigation_post = get_post( $attributes['navigationMenuId'] );
$attributes['ref'] = $attributes['navigationMenuId'];
}
// Load inner blocks from the navigation post.
if ( array_key_exists( 'ref', $attributes ) ) {
$navigation_post = get_post( $attributes['ref'] );
if ( ! isset( $navigation_post ) ) {
return '';
}
Expand All @@ -202,20 +307,26 @@ function render_block_core_navigation( $attributes, $content, $block ) {

// 'parse_blocks' includes a null block with '\n\n' as the content when
// it encounters whitespace. This code strips it.
$compacted_blocks = array_filter(
$parsed_blocks,
function( $block ) {
return isset( $block['blockName'] );
}
);
$compacted_blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );

// TODO - this uses the full navigation block attributes for the
// context which could be refined.
$inner_blocks = new WP_Block_List( $compacted_blocks, $attributes );
}

// If there are no inner blocks then fallback to rendering an appropriate fallback.
if ( empty( $inner_blocks ) ) {
return '';
$is_fallback = true; // indicate we are rendering the fallback.

$fallback_blocks = block_core_navigation_get_fallback_blocks();

// Fallback my have been filtered so do basic test for validity.
if ( empty( $fallback_blocks ) || ! is_array( $fallback_blocks ) ) {
return '';
}

$inner_blocks = new WP_Block_List( $fallback_blocks, $attributes );

}

// Restore legacy classnames for submenu positioning.
Expand All @@ -234,7 +345,8 @@ function( $block ) {
$colors['css_classes'],
$font_sizes['css_classes'],
$is_responsive_menu ? array( 'is-responsive' ) : array(),
$layout_class ? array( $layout_class ) : array()
$layout_class ? array( $layout_class ) : array(),
$is_fallback ? array( 'is-fallback' ) : array()
);

$inner_blocks_html = '';
Expand Down Expand Up @@ -323,8 +435,8 @@ function( $block ) {
/**
* Register the navigation block.
*
* @uses render_block_core_navigation()
* @throws WP_Error An WP_Error exception parsing the block definition.
* @uses render_block_core_navigation()
*/
function register_block_core_navigation() {
register_block_type_from_metadata(
Expand All @@ -341,6 +453,7 @@ function register_block_core_navigation() {
* Filter that changes the parsed attribute values of navigation blocks contain typographic presets to contain the values directly.
*
* @param array $parsed_block The block being rendered.
*
* @return array The block being rendered without typographic presets.
*/
function block_core_navigation_typographic_presets_backcompatibility( $parsed_block ) {
Expand All @@ -364,6 +477,7 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl
}
}
}

return $parsed_block;
}

Expand Down