mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Editor: Update Packages with the latest bug fixes for 6.5 beta 2.
It includes all the backports from this Gutenberg PR https://github.com/WordPress/gutenberg/pull/59197 Props youknowriad, get_dave. See #60315. git-svn-id: https://develop.svn.wordpress.org/trunk@57663 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
18b21c34c8
commit
c84cddb432
3573
package-lock.json
generated
3573
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
144
package.json
144
package.json
@ -27,12 +27,12 @@
|
|||||||
"@lodder/grunt-postcss": "^3.1.1",
|
"@lodder/grunt-postcss": "^3.1.1",
|
||||||
"@playwright/test": "1.32.0",
|
"@playwright/test": "1.32.0",
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
||||||
"@wordpress/babel-preset-default": "7.35.0",
|
"@wordpress/babel-preset-default": "7.35.1",
|
||||||
"@wordpress/dependency-extraction-webpack-plugin": "5.2.0",
|
"@wordpress/dependency-extraction-webpack-plugin": "5.2.1",
|
||||||
"@wordpress/e2e-test-utils": "10.22.0",
|
"@wordpress/e2e-test-utils": "10.22.1",
|
||||||
"@wordpress/e2e-test-utils-playwright": "0.19.0",
|
"@wordpress/e2e-test-utils-playwright": "0.19.1",
|
||||||
"@wordpress/prettier-config": "3.8.0",
|
"@wordpress/prettier-config": "3.8.1",
|
||||||
"@wordpress/scripts": "27.2.0",
|
"@wordpress/scripts": "27.2.1",
|
||||||
"autoprefixer": "10.4.17",
|
"autoprefixer": "10.4.17",
|
||||||
"chalk": "5.3.0",
|
"chalk": "5.3.0",
|
||||||
"check-node-version": "4.2.1",
|
"check-node-version": "4.2.1",
|
||||||
@ -78,72 +78,72 @@
|
|||||||
"webpack-livereload-plugin": "3.0.2"
|
"webpack-livereload-plugin": "3.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@wordpress/a11y": "3.51.0",
|
"@wordpress/a11y": "3.51.1",
|
||||||
"@wordpress/annotations": "2.51.1",
|
"@wordpress/annotations": "2.51.2",
|
||||||
"@wordpress/api-fetch": "6.48.0",
|
"@wordpress/api-fetch": "6.48.1",
|
||||||
"@wordpress/autop": "3.51.0",
|
"@wordpress/autop": "3.51.1",
|
||||||
"@wordpress/blob": "3.51.0",
|
"@wordpress/blob": "3.51.1",
|
||||||
"@wordpress/block-directory": "4.28.1",
|
"@wordpress/block-directory": "4.28.2",
|
||||||
"@wordpress/block-editor": "12.19.1",
|
"@wordpress/block-editor": "12.19.2",
|
||||||
"@wordpress/block-library": "8.28.1",
|
"@wordpress/block-library": "8.28.2",
|
||||||
"@wordpress/block-serialization-default-parser": "4.51.0",
|
"@wordpress/block-serialization-default-parser": "4.51.1",
|
||||||
"@wordpress/blocks": "12.28.1",
|
"@wordpress/blocks": "12.28.2",
|
||||||
"@wordpress/commands": "0.22.1",
|
"@wordpress/commands": "0.22.2",
|
||||||
"@wordpress/components": "26.0.1",
|
"@wordpress/components": "26.0.2",
|
||||||
"@wordpress/compose": "6.28.0",
|
"@wordpress/compose": "6.28.1",
|
||||||
"@wordpress/core-commands": "0.20.1",
|
"@wordpress/core-commands": "0.20.2",
|
||||||
"@wordpress/core-data": "6.28.1",
|
"@wordpress/core-data": "6.28.2",
|
||||||
"@wordpress/customize-widgets": "4.28.1",
|
"@wordpress/customize-widgets": "4.28.2",
|
||||||
"@wordpress/data": "9.21.0",
|
"@wordpress/data": "9.21.1",
|
||||||
"@wordpress/data-controls": "3.20.0",
|
"@wordpress/data-controls": "3.20.1",
|
||||||
"@wordpress/dataviews": "0.5.1",
|
"@wordpress/dataviews": "0.5.2",
|
||||||
"@wordpress/date": "4.51.0",
|
"@wordpress/date": "4.51.1",
|
||||||
"@wordpress/deprecated": "3.51.0",
|
"@wordpress/deprecated": "3.51.1",
|
||||||
"@wordpress/dom": "3.51.0",
|
"@wordpress/dom": "3.51.1",
|
||||||
"@wordpress/dom-ready": "3.51.0",
|
"@wordpress/dom-ready": "3.51.1",
|
||||||
"@wordpress/edit-post": "7.28.1",
|
"@wordpress/edit-post": "7.28.2",
|
||||||
"@wordpress/edit-site": "5.28.1",
|
"@wordpress/edit-site": "5.28.2",
|
||||||
"@wordpress/edit-widgets": "5.28.1",
|
"@wordpress/edit-widgets": "5.28.2",
|
||||||
"@wordpress/editor": "13.28.1",
|
"@wordpress/editor": "13.28.2",
|
||||||
"@wordpress/element": "5.28.0",
|
"@wordpress/element": "5.28.1",
|
||||||
"@wordpress/escape-html": "2.51.0",
|
"@wordpress/escape-html": "2.51.1",
|
||||||
"@wordpress/format-library": "4.28.1",
|
"@wordpress/format-library": "4.28.2",
|
||||||
"@wordpress/hooks": "3.51.0",
|
"@wordpress/hooks": "3.51.1",
|
||||||
"@wordpress/html-entities": "3.51.0",
|
"@wordpress/html-entities": "3.51.1",
|
||||||
"@wordpress/i18n": "4.51.0",
|
"@wordpress/i18n": "4.51.1",
|
||||||
"@wordpress/icons": "9.42.0",
|
"@wordpress/icons": "9.42.1",
|
||||||
"@wordpress/interactivity": "5.0.0",
|
"@wordpress/interactivity": "5.0.1",
|
||||||
"@wordpress/interactivity-router": "1.1.0",
|
"@wordpress/interactivity-router": "1.1.1",
|
||||||
"@wordpress/interface": "5.28.1",
|
"@wordpress/interface": "5.28.2",
|
||||||
"@wordpress/is-shallow-equal": "4.51.0",
|
"@wordpress/is-shallow-equal": "4.51.1",
|
||||||
"@wordpress/keyboard-shortcuts": "4.28.0",
|
"@wordpress/keyboard-shortcuts": "4.28.1",
|
||||||
"@wordpress/keycodes": "3.51.0",
|
"@wordpress/keycodes": "3.51.1",
|
||||||
"@wordpress/list-reusable-blocks": "4.28.1",
|
"@wordpress/list-reusable-blocks": "4.28.2",
|
||||||
"@wordpress/media-utils": "4.42.0",
|
"@wordpress/media-utils": "4.42.1",
|
||||||
"@wordpress/notices": "4.19.0",
|
"@wordpress/notices": "4.19.1",
|
||||||
"@wordpress/nux": "8.13.1",
|
"@wordpress/nux": "8.13.2",
|
||||||
"@wordpress/patterns": "1.12.1",
|
"@wordpress/patterns": "1.12.2",
|
||||||
"@wordpress/plugins": "6.19.1",
|
"@wordpress/plugins": "6.19.2",
|
||||||
"@wordpress/preferences": "3.28.1",
|
"@wordpress/preferences": "3.28.2",
|
||||||
"@wordpress/preferences-persistence": "1.43.0",
|
"@wordpress/preferences-persistence": "1.43.1",
|
||||||
"@wordpress/primitives": "3.49.0",
|
"@wordpress/primitives": "3.49.1",
|
||||||
"@wordpress/priority-queue": "2.51.0",
|
"@wordpress/priority-queue": "2.51.1",
|
||||||
"@wordpress/private-apis": "0.33.0",
|
"@wordpress/private-apis": "0.33.1",
|
||||||
"@wordpress/redux-routine": "4.51.0",
|
"@wordpress/redux-routine": "4.51.1",
|
||||||
"@wordpress/reusable-blocks": "4.28.1",
|
"@wordpress/reusable-blocks": "4.28.2",
|
||||||
"@wordpress/rich-text": "6.28.1",
|
"@wordpress/rich-text": "6.28.2",
|
||||||
"@wordpress/router": "0.20.0",
|
"@wordpress/router": "0.20.1",
|
||||||
"@wordpress/server-side-render": "4.28.1",
|
"@wordpress/server-side-render": "4.28.2",
|
||||||
"@wordpress/shortcode": "3.51.0",
|
"@wordpress/shortcode": "3.51.1",
|
||||||
"@wordpress/style-engine": "1.34.0",
|
"@wordpress/style-engine": "1.34.1",
|
||||||
"@wordpress/sync": "0.13.0",
|
"@wordpress/sync": "0.13.1",
|
||||||
"@wordpress/token-list": "2.51.0",
|
"@wordpress/token-list": "2.51.1",
|
||||||
"@wordpress/undo-manager": "0.11.0",
|
"@wordpress/undo-manager": "0.11.1",
|
||||||
"@wordpress/url": "3.52.0",
|
"@wordpress/url": "3.52.1",
|
||||||
"@wordpress/viewport": "5.28.0",
|
"@wordpress/viewport": "5.28.1",
|
||||||
"@wordpress/warning": "2.51.0",
|
"@wordpress/warning": "2.51.1",
|
||||||
"@wordpress/widgets": "3.28.1",
|
"@wordpress/widgets": "3.28.2",
|
||||||
"@wordpress/wordcount": "3.51.0",
|
"@wordpress/wordcount": "3.51.1",
|
||||||
"backbone": "1.5.0",
|
"backbone": "1.5.0",
|
||||||
"clipboard": "2.0.11",
|
"clipboard": "2.0.11",
|
||||||
"core-js-url-browser": "3.6.4",
|
"core-js-url-browser": "3.6.4",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -234,9 +234,6 @@
|
|||||||
'link'
|
'link'
|
||||||
),
|
),
|
||||||
'textdomain' => 'default',
|
'textdomain' => 'default',
|
||||||
'usesContext' => array(
|
|
||||||
'pattern/overrides'
|
|
||||||
),
|
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'tagName' => array(
|
'tagName' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
@ -2218,9 +2215,6 @@
|
|||||||
'subtitle'
|
'subtitle'
|
||||||
),
|
),
|
||||||
'textdomain' => 'default',
|
'textdomain' => 'default',
|
||||||
'usesContext' => array(
|
|
||||||
'pattern/overrides'
|
|
||||||
),
|
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'textAlign' => array(
|
'textAlign' => array(
|
||||||
'type' => 'string'
|
'type' => 'string'
|
||||||
@ -2369,8 +2363,7 @@
|
|||||||
'usesContext' => array(
|
'usesContext' => array(
|
||||||
'allowResize',
|
'allowResize',
|
||||||
'imageCrop',
|
'imageCrop',
|
||||||
'fixedHeight',
|
'fixedHeight'
|
||||||
'pattern/overrides'
|
|
||||||
),
|
),
|
||||||
'description' => 'Insert an image to make a visual statement.',
|
'description' => 'Insert an image to make a visual statement.',
|
||||||
'keywords' => array(
|
'keywords' => array(
|
||||||
@ -3621,8 +3614,7 @@
|
|||||||
),
|
),
|
||||||
'textdomain' => 'default',
|
'textdomain' => 'default',
|
||||||
'usesContext' => array(
|
'usesContext' => array(
|
||||||
'postId',
|
'postId'
|
||||||
'pattern/overrides'
|
|
||||||
),
|
),
|
||||||
'attributes' => array(
|
'attributes' => array(
|
||||||
'align' => array(
|
'align' => array(
|
||||||
|
|||||||
@ -8,7 +8,6 @@
|
|||||||
"description": "Prompt visitors to take action with a button-style link.",
|
"description": "Prompt visitors to take action with a button-style link.",
|
||||||
"keywords": [ "link" ],
|
"keywords": [ "link" ],
|
||||||
"textdomain": "default",
|
"textdomain": "default",
|
||||||
"usesContext": [ "pattern/overrides" ],
|
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"tagName": {
|
"tagName": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
@ -68,15 +68,30 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
|
|||||||
* @since 6.3.0
|
* @since 6.3.0
|
||||||
*/
|
*/
|
||||||
function register_block_core_footnotes() {
|
function register_block_core_footnotes() {
|
||||||
$post_types = get_post_types(
|
register_block_type_from_metadata(
|
||||||
|
__DIR__ . '/footnotes',
|
||||||
array(
|
array(
|
||||||
'show_in_rest' => true,
|
'render_callback' => 'render_block_core_footnotes',
|
||||||
'public' => true,
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
add_action( 'init', 'register_block_core_footnotes' );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the footnotes meta field required for footnotes to work.
|
||||||
|
*
|
||||||
|
* @since 6.5.0
|
||||||
|
*/
|
||||||
|
function register_block_core_footnotes_post_meta() {
|
||||||
|
$post_types = get_post_types( array( 'show_in_rest' => true ) );
|
||||||
foreach ( $post_types as $post_type ) {
|
foreach ( $post_types as $post_type ) {
|
||||||
// Only register the meta field if the post type supports the editor, custom fields, and revisions.
|
// Only register the meta field if the post type supports the editor, custom fields, and revisions.
|
||||||
if ( post_type_supports( $post_type, 'editor' ) && post_type_supports( $post_type, 'custom-fields' ) && post_type_supports( $post_type, 'revisions' ) ) {
|
if (
|
||||||
|
post_type_supports( $post_type, 'editor' ) &&
|
||||||
|
post_type_supports( $post_type, 'custom-fields' ) &&
|
||||||
|
post_type_supports( $post_type, 'revisions' )
|
||||||
|
) {
|
||||||
register_post_meta(
|
register_post_meta(
|
||||||
$post_type,
|
$post_type,
|
||||||
'footnotes',
|
'footnotes',
|
||||||
@ -89,14 +104,12 @@ function register_block_core_footnotes() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
register_block_type_from_metadata(
|
|
||||||
__DIR__ . '/footnotes',
|
|
||||||
array(
|
|
||||||
'render_callback' => 'render_block_core_footnotes',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
add_action( 'init', 'register_block_core_footnotes' );
|
/**
|
||||||
|
* Most post types are registered at priority 10, so use priority 20 here in
|
||||||
|
* order to catch them.
|
||||||
|
*/
|
||||||
|
add_action( 'init', 'register_block_core_footnotes_post_meta', 20 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the footnotes field to the revisions display.
|
* Adds the footnotes field to the revisions display.
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
"description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
|
"description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
|
||||||
"keywords": [ "title", "subtitle" ],
|
"keywords": [ "title", "subtitle" ],
|
||||||
"textdomain": "default",
|
"textdomain": "default",
|
||||||
"usesContext": [ "pattern/overrides" ],
|
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"textAlign": {
|
"textAlign": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@ -4,12 +4,7 @@
|
|||||||
"name": "core/image",
|
"name": "core/image",
|
||||||
"title": "Image",
|
"title": "Image",
|
||||||
"category": "media",
|
"category": "media",
|
||||||
"usesContext": [
|
"usesContext": [ "allowResize", "imageCrop", "fixedHeight" ],
|
||||||
"allowResize",
|
|
||||||
"imageCrop",
|
|
||||||
"fixedHeight",
|
|
||||||
"pattern/overrides"
|
|
||||||
],
|
|
||||||
"description": "Insert an image to make a visual statement.",
|
"description": "Insert an image to make a visual statement.",
|
||||||
"keywords": [ "img", "photo", "picture" ],
|
"keywords": [ "img", "photo", "picture" ],
|
||||||
"textdomain": "default",
|
"textdomain": "default",
|
||||||
|
|||||||
@ -392,7 +392,6 @@ function block_core_navigation_link_build_variations() {
|
|||||||
* Registers the navigation link block.
|
* Registers the navigation link block.
|
||||||
*
|
*
|
||||||
* @uses render_block_core_navigation_link()
|
* @uses render_block_core_navigation_link()
|
||||||
* @uses build_navigation_link_block_variations()
|
|
||||||
* @throws WP_Error An WP_Error exception parsing the block definition.
|
* @throws WP_Error An WP_Error exception parsing the block definition.
|
||||||
*/
|
*/
|
||||||
function register_block_core_navigation_link() {
|
function register_block_core_navigation_link() {
|
||||||
|
|||||||
@ -218,7 +218,7 @@ class WP_Navigation_Block_Renderer {
|
|||||||
// it encounters whitespace. This code strips it.
|
// it encounters whitespace. This code strips it.
|
||||||
$blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
|
$blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
|
||||||
|
|
||||||
if ( function_exists( 'get_hooked_block_markup' ) ) {
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) ) {
|
||||||
// Run Block Hooks algorithm to inject hooked blocks.
|
// Run Block Hooks algorithm to inject hooked blocks.
|
||||||
$markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post );
|
$markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post );
|
||||||
$root_nav_block = parse_blocks( $markup )[0];
|
$root_nav_block = parse_blocks( $markup )[0];
|
||||||
@ -390,25 +390,16 @@ class WP_Navigation_Block_Renderer {
|
|||||||
$text_decoration = $attributes['style']['typography']['textDecoration'] ?? null;
|
$text_decoration = $attributes['style']['typography']['textDecoration'] ?? null;
|
||||||
$text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );
|
$text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );
|
||||||
|
|
||||||
// Sets the is-collapsed class when the navigation is set to always use the overlay.
|
|
||||||
// This saves us from needing to do this check in the view.js file (see the collapseNav function).
|
|
||||||
$is_collapsed_class = static::is_always_overlay( $attributes ) ? array( 'is-collapsed' ) : array();
|
|
||||||
|
|
||||||
$classes = array_merge(
|
$classes = array_merge(
|
||||||
$colors['css_classes'],
|
$colors['css_classes'],
|
||||||
$font_sizes['css_classes'],
|
$font_sizes['css_classes'],
|
||||||
$is_responsive_menu ? array( 'is-responsive' ) : array(),
|
$is_responsive_menu ? array( 'is-responsive' ) : array(),
|
||||||
$layout_class ? array( $layout_class ) : array(),
|
$layout_class ? array( $layout_class ) : array(),
|
||||||
$text_decoration ? array( $text_decoration_class ) : array(),
|
$text_decoration ? array( $text_decoration_class ) : array()
|
||||||
$is_collapsed_class
|
|
||||||
);
|
);
|
||||||
return implode( ' ', $classes );
|
return implode( ' ', $classes );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function is_always_overlay( $attributes ) {
|
|
||||||
return isset( $attributes['overlayMenu'] ) && 'always' === $attributes['overlayMenu'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get styles for the navigation block.
|
* Get styles for the navigation block.
|
||||||
*
|
*
|
||||||
@ -435,12 +426,16 @@ class WP_Navigation_Block_Renderer {
|
|||||||
$colors = block_core_navigation_build_css_colors( $attributes );
|
$colors = block_core_navigation_build_css_colors( $attributes );
|
||||||
$modal_unique_id = wp_unique_id( 'modal-' );
|
$modal_unique_id = wp_unique_id( 'modal-' );
|
||||||
|
|
||||||
|
$is_hidden_by_default = isset( $attributes['overlayMenu'] ) && 'always' === $attributes['overlayMenu'];
|
||||||
|
|
||||||
$responsive_container_classes = array(
|
$responsive_container_classes = array(
|
||||||
'wp-block-navigation__responsive-container',
|
'wp-block-navigation__responsive-container',
|
||||||
|
$is_hidden_by_default ? 'hidden-by-default' : '',
|
||||||
implode( ' ', $colors['overlay_css_classes'] ),
|
implode( ' ', $colors['overlay_css_classes'] ),
|
||||||
);
|
);
|
||||||
$open_button_classes = array(
|
$open_button_classes = array(
|
||||||
'wp-block-navigation__responsive-container-open',
|
'wp-block-navigation__responsive-container-open',
|
||||||
|
$is_hidden_by_default ? 'always-shown' : '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
|
$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
|
||||||
@ -538,7 +533,7 @@ class WP_Navigation_Block_Renderer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ( $is_responsive_menu ) {
|
if ( $is_responsive_menu ) {
|
||||||
$nav_element_directives = static::get_nav_element_directives( $is_interactive, $attributes );
|
$nav_element_directives = static::get_nav_element_directives( $is_interactive );
|
||||||
$wrapper_attributes .= ' ' . $nav_element_directives;
|
$wrapper_attributes .= ' ' . $nav_element_directives;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +547,7 @@ class WP_Navigation_Block_Renderer {
|
|||||||
* @param array $attributes The block attributes.
|
* @param array $attributes The block attributes.
|
||||||
* @return string the directives for the navigation element.
|
* @return string the directives for the navigation element.
|
||||||
*/
|
*/
|
||||||
private static function get_nav_element_directives( $is_interactive, $attributes ) {
|
private static function get_nav_element_directives( $is_interactive ) {
|
||||||
if ( ! $is_interactive ) {
|
if ( ! $is_interactive ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -569,16 +564,6 @@ class WP_Navigation_Block_Renderer {
|
|||||||
data-wp-interactive="core/navigation"'
|
data-wp-interactive="core/navigation"'
|
||||||
. $nav_element_context;
|
. $nav_element_context;
|
||||||
|
|
||||||
/*
|
|
||||||
* When the navigation's 'overlayMenu' attribute is set to 'always', JavaScript
|
|
||||||
* is not needed for collapsing the menu because the class is set manually.
|
|
||||||
*/
|
|
||||||
if ( ! static::is_always_overlay( $attributes ) ) {
|
|
||||||
$nav_element_directives .= 'data-wp-init="callbacks.initNav"';
|
|
||||||
$nav_element_directives .= ' '; // space separator
|
|
||||||
$nav_element_directives .= 'data-wp-class--is-collapsed="context.isCollapsed"';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $nav_element_directives;
|
return $nav_element_directives;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1024,7 +1009,7 @@ function block_core_navigation_get_fallback_blocks() {
|
|||||||
// In this case default to the (Page List) fallback.
|
// In this case default to the (Page List) fallback.
|
||||||
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
|
$fallback_blocks = ! empty( $maybe_fallback ) ? $maybe_fallback : $fallback_blocks;
|
||||||
|
|
||||||
if ( function_exists( 'get_hooked_block_markup' ) ) {
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) ) {
|
||||||
// Run Block Hooks algorithm to inject hooked blocks.
|
// Run Block Hooks algorithm to inject hooked blocks.
|
||||||
// We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks.
|
// We have to run it here because we need the post ID of the Navigation block to track ignored hooked blocks.
|
||||||
$markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post );
|
$markup = block_core_navigation_insert_hooked_blocks( $fallback_blocks, $navigation_post );
|
||||||
@ -1369,24 +1354,27 @@ function block_core_navigation_get_most_recently_published_navigation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert hooked blocks into a Navigation block.
|
* Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the inner blocks.
|
||||||
*
|
*
|
||||||
* Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
|
* @param string $serialized_block The serialized markup of a block and its inner blocks.
|
||||||
* this function inserts hooked blocks into it, and returns the serialized inner blocks in a
|
* @return string
|
||||||
* mock Navigation block wrapper.
|
*/
|
||||||
*
|
function block_core_navigation_remove_serialized_parent_block( $serialized_block ) {
|
||||||
* If there are any hooked blocks that need to be inserted as the Navigation block's first or last
|
$start = strpos( $serialized_block, '-->' ) + strlen( '-->' );
|
||||||
* children, the `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is checked to see if any
|
$end = strrpos( $serialized_block, '<!--' );
|
||||||
* of those hooked blocks should be exempted from insertion.
|
return substr( $serialized_block, $start, $end - $start );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock a parsed block for the Navigation block given its inner blocks and the `wp_navigation` post object.
|
||||||
|
* The `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is queried to add the `metadata.ignoredHookedBlocks` attribute.
|
||||||
*
|
*
|
||||||
* @param array $inner_blocks Parsed inner blocks of a Navigation block.
|
* @param array $inner_blocks Parsed inner blocks of a Navigation block.
|
||||||
* @param WP_Post $post `wp_navigation` post object corresponding to the block.
|
* @param WP_Post $post `wp_navigation` post object corresponding to the block.
|
||||||
* @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
|
*
|
||||||
|
* @return array the normalized parsed blocks.
|
||||||
*/
|
*/
|
||||||
function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
|
function block_core_navigation_mock_parsed_block( $inner_blocks, $post ) {
|
||||||
$before_block_visitor = null;
|
|
||||||
$after_block_visitor = null;
|
|
||||||
$hooked_blocks = get_hooked_blocks();
|
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
|
|
||||||
if ( isset( $post->ID ) ) {
|
if ( isset( $post->ID ) ) {
|
||||||
@ -1405,15 +1393,62 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
|
|||||||
'innerBlocks' => $inner_blocks,
|
'innerBlocks' => $inner_blocks,
|
||||||
'innerContent' => array_fill( 0, count( $inner_blocks ), null ),
|
'innerContent' => array_fill( 0, count( $inner_blocks ), null ),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return $mock_anchor_parent_block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert hooked blocks into a Navigation block.
|
||||||
|
*
|
||||||
|
* Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
|
||||||
|
* this function inserts hooked blocks into it, and returns the serialized inner blocks in a
|
||||||
|
* mock Navigation block wrapper.
|
||||||
|
*
|
||||||
|
* If there are any hooked blocks that need to be inserted as the Navigation block's first or last
|
||||||
|
* children, the `wp_navigation` post's `_wp_ignored_hooked_blocks` meta is checked to see if any
|
||||||
|
* of those hooked blocks should be exempted from insertion.
|
||||||
|
*
|
||||||
|
* @param array $inner_blocks Parsed inner blocks of a Navigation block.
|
||||||
|
* @param WP_Post $post `wp_navigation` post object corresponding to the block.
|
||||||
|
* @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
|
||||||
|
*/
|
||||||
|
function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
|
||||||
|
$mock_navigation_block = block_core_navigation_mock_parsed_block( $inner_blocks, $post );
|
||||||
|
$hooked_blocks = get_hooked_blocks();
|
||||||
$before_block_visitor = null;
|
$before_block_visitor = null;
|
||||||
$after_block_visitor = null;
|
$after_block_visitor = null;
|
||||||
|
|
||||||
if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
|
if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
|
||||||
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $post );
|
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $post, 'insert_hooked_blocks' );
|
||||||
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $post );
|
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $post, 'insert_hooked_blocks' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return traverse_and_serialize_block( $mock_anchor_parent_block, $before_block_visitor, $after_block_visitor );
|
return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert ignoredHookedBlocks meta into the Navigation block and its inner blocks.
|
||||||
|
*
|
||||||
|
* Given a Navigation block's inner blocks and its corresponding `wp_navigation` post object,
|
||||||
|
* this function inserts ignoredHookedBlocks meta into it, and returns the serialized inner blocks in a
|
||||||
|
* mock Navigation block wrapper.
|
||||||
|
*
|
||||||
|
* @param array $inner_blocks Parsed inner blocks of a Navigation block.
|
||||||
|
* @param WP_Post $post `wp_navigation` post object corresponding to the block.
|
||||||
|
* @return string Serialized inner blocks in mock Navigation block wrapper, with hooked blocks inserted, if any.
|
||||||
|
*/
|
||||||
|
function block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks, $post ) {
|
||||||
|
$mock_navigation_block = block_core_navigation_mock_parsed_block( $inner_blocks, $post );
|
||||||
|
$hooked_blocks = get_hooked_blocks();
|
||||||
|
$before_block_visitor = null;
|
||||||
|
$after_block_visitor = null;
|
||||||
|
|
||||||
|
if ( ! empty( $hooked_blocks ) || has_filter( 'hooked_block_types' ) ) {
|
||||||
|
$before_block_visitor = make_before_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
|
||||||
|
$after_block_visitor = make_after_block_visitor( $hooked_blocks, $post, 'set_ignored_hooked_blocks_metadata' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return traverse_and_serialize_block( $mock_navigation_block, $before_block_visitor, $after_block_visitor );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1422,12 +1457,11 @@ function block_core_navigation_insert_hooked_blocks( $inner_blocks, $post ) {
|
|||||||
* @param WP_Post $post Post object.
|
* @param WP_Post $post Post object.
|
||||||
*/
|
*/
|
||||||
function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
|
function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
|
||||||
// We run the Block Hooks mechanism so it will return the list of ignored hooked blocks
|
// We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
|
||||||
// in the mock root Navigation block's metadata attribute.
|
// all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
|
||||||
// We ignore the rest of the returned `$markup`; `$post->post_content` already has the hooked
|
|
||||||
// blocks inserted, whereas `$markup` will have them inserted twice.
|
|
||||||
$blocks = parse_blocks( $post->post_content );
|
$blocks = parse_blocks( $post->post_content );
|
||||||
$markup = block_core_navigation_insert_hooked_blocks( $blocks, $post );
|
$markup = block_core_navigation_set_ignored_hooked_blocks_metadata( $blocks, $post );
|
||||||
|
|
||||||
$root_nav_block = parse_blocks( $markup )[0];
|
$root_nav_block = parse_blocks( $markup )[0];
|
||||||
$ignored_hooked_blocks = isset( $root_nav_block['attrs']['metadata']['ignoredHookedBlocks'] )
|
$ignored_hooked_blocks = isset( $root_nav_block['attrs']['metadata']['ignoredHookedBlocks'] )
|
||||||
? $root_nav_block['attrs']['metadata']['ignoredHookedBlocks']
|
? $root_nav_block['attrs']['metadata']['ignoredHookedBlocks']
|
||||||
@ -1441,6 +1475,15 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
|
|||||||
}
|
}
|
||||||
update_post_meta( $post->ID, '_wp_ignored_hooked_blocks', json_encode( $ignored_hooked_blocks ) );
|
update_post_meta( $post->ID, '_wp_ignored_hooked_blocks', json_encode( $ignored_hooked_blocks ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$serialized_inner_blocks = block_core_navigation_remove_serialized_parent_block( $markup );
|
||||||
|
|
||||||
|
wp_update_post(
|
||||||
|
array(
|
||||||
|
'ID' => $post->ID,
|
||||||
|
'post_content' => $serialized_inner_blocks,
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before adding our filter, we verify if it's already added in Core.
|
// Before adding our filter, we verify if it's already added in Core.
|
||||||
@ -1450,7 +1493,7 @@ $rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ig
|
|||||||
|
|
||||||
// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
||||||
// that are not present in Gutenberg's WP 6.5 compatibility layer.
|
// that are not present in Gutenberg's WP 6.5 compatibility layer.
|
||||||
if ( function_exists( 'get_hooked_block_markup' ) && ! has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
|
||||||
add_action( 'rest_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10, 3 );
|
add_action( 'rest_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta', 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1470,9 +1513,7 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons
|
|||||||
$content = block_core_navigation_insert_hooked_blocks( $parsed_blocks, $post );
|
$content = block_core_navigation_insert_hooked_blocks( $parsed_blocks, $post );
|
||||||
|
|
||||||
// Remove mock Navigation block wrapper.
|
// Remove mock Navigation block wrapper.
|
||||||
$start = strpos( $content, '-->' ) + strlen( '-->' );
|
$content = block_core_navigation_remove_serialized_parent_block( $content );
|
||||||
$end = strrpos( $content, '<!--' );
|
|
||||||
$content = substr( $content, $start, $end - $start );
|
|
||||||
|
|
||||||
$response->data['content']['raw'] = $content;
|
$response->data['content']['raw'] = $content;
|
||||||
$response->data['content']['rendered'] = apply_filters( 'the_content', $content );
|
$response->data['content']['rendered'] = apply_filters( 'the_content', $content );
|
||||||
@ -1487,6 +1528,6 @@ $rest_prepare_wp_navigation_core_callback = 'block_core_navigation_' . 'insert_h
|
|||||||
|
|
||||||
// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
// Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
||||||
// that are not present in Gutenberg's WP 6.5 compatibility layer.
|
// that are not present in Gutenberg's WP 6.5 compatibility layer.
|
||||||
if ( function_exists( 'get_hooked_block_markup' ) && ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) ) {
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) ) {
|
||||||
add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
|
add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
"description": "Start with the basic building block of all narrative.",
|
"description": "Start with the basic building block of all narrative.",
|
||||||
"keywords": [ "text" ],
|
"keywords": [ "text" ],
|
||||||
"textdomain": "default",
|
"textdomain": "default",
|
||||||
"usesContext": [ "postId", "pattern/overrides" ],
|
"usesContext": [ "postId" ],
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"align": {
|
"align": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|||||||
@ -188,7 +188,7 @@ function render_block_core_search( $attributes ) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$form_directives = '
|
$form_directives = '
|
||||||
data-wp-interactive=\'"core/search"\''
|
data-wp-interactive="core/search"'
|
||||||
. $form_context .
|
. $form_context .
|
||||||
'data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
|
'data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
|
||||||
data-wp-on--keydown="actions.handleSearchKeydown"
|
data-wp-on--keydown="actions.handleSearchKeydown"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user