@wordpress/block-library 8.28.6 → 8.28.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/heading/index.js +4 -3
- package/build/heading/index.js.map +1 -1
- package/build/navigation/edit/index.js +11 -15
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/edit.js +1 -0
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +1 -0
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build-module/heading/index.js +4 -3
- package/build-module/heading/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +11 -15
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -0
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +1 -0
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/package.json +4 -4
- package/src/heading/index.js +4 -3
- package/src/navigation/edit/index.js +48 -50
- package/src/navigation/index.php +51 -27
- package/src/navigation-link/edit.js +1 -0
- package/src/navigation-submenu/edit.js +1 -0
package/src/navigation/index.php
CHANGED
|
@@ -135,9 +135,9 @@ class WP_Navigation_Block_Renderer {
|
|
|
135
135
|
if ( static::does_block_need_a_list_item_wrapper( $inner_block ) ) {
|
|
136
136
|
return '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
return $inner_block_content;
|
|
140
138
|
}
|
|
139
|
+
|
|
140
|
+
return $inner_block_content;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
@@ -543,8 +543,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
543
543
|
/**
|
|
544
544
|
* Gets the nav element directives.
|
|
545
545
|
*
|
|
546
|
-
* @param bool
|
|
547
|
-
* @param array $attributes The block attributes.
|
|
546
|
+
* @param bool $is_interactive Whether the block is interactive.
|
|
548
547
|
* @return string the directives for the navigation element.
|
|
549
548
|
*/
|
|
550
549
|
private static function get_nav_element_directives( $is_interactive ) {
|
|
@@ -1458,17 +1457,33 @@ function block_core_navigation_set_ignored_hooked_blocks_metadata( $inner_blocks
|
|
|
1458
1457
|
/**
|
|
1459
1458
|
* Updates the post meta with the list of ignored hooked blocks when the navigation is created or updated via the REST API.
|
|
1460
1459
|
*
|
|
1460
|
+
* @access private
|
|
1461
|
+
* @since 6.5.0
|
|
1462
|
+
*
|
|
1461
1463
|
* @param stdClass $post Post object.
|
|
1464
|
+
* @return stdClass The updated post object.
|
|
1462
1465
|
*/
|
|
1463
1466
|
function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
|
|
1464
|
-
|
|
1465
|
-
|
|
1467
|
+
/*
|
|
1468
|
+
* In this scenario the user has likely tried to create a navigation via the REST API.
|
|
1469
|
+
* In which case we won't have a post ID to work with and store meta against.
|
|
1470
|
+
*/
|
|
1471
|
+
if ( empty( $post->ID ) ) {
|
|
1472
|
+
return $post;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
/*
|
|
1476
|
+
* We run the Block Hooks mechanism to inject the `metadata.ignoredHookedBlocks` attribute into
|
|
1477
|
+
* all anchor blocks. For the root level, we create a mock Navigation and extract them from there.
|
|
1478
|
+
*/
|
|
1466
1479
|
$blocks = parse_blocks( $post->post_content );
|
|
1467
1480
|
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1481
|
+
/*
|
|
1482
|
+
* Block Hooks logic requires a `WP_Post` object (rather than the `stdClass` with the updates that
|
|
1483
|
+
* we're getting from the `rest_pre_insert_wp_navigation` filter) as its second argument (to be
|
|
1484
|
+
* used as context for hooked blocks insertion).
|
|
1485
|
+
* We thus have to look it up from the DB,based on `$post->ID`.
|
|
1486
|
+
*/
|
|
1472
1487
|
$markup = block_core_navigation_set_ignored_hooked_blocks_metadata( $blocks, get_post( $post->ID ) );
|
|
1473
1488
|
|
|
1474
1489
|
$root_nav_block = parse_blocks( $markup )[0];
|
|
@@ -1489,22 +1504,28 @@ function block_core_navigation_update_ignore_hooked_blocks_meta( $post ) {
|
|
|
1489
1504
|
return $post;
|
|
1490
1505
|
}
|
|
1491
1506
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1507
|
+
/*
|
|
1508
|
+
* Before adding our filter, we verify if it's already added in Core.
|
|
1509
|
+
* However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
|
|
1510
|
+
* Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
|
|
1511
|
+
*/
|
|
1512
|
+
$rest_insert_wp_navigation_core_callback = 'block_core_navigation_' . 'update_ignore_hooked_blocks_meta'; // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found
|
|
1496
1513
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1514
|
+
/*
|
|
1515
|
+
* Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
|
1516
|
+
* that are not present in Gutenberg's WP 6.5 compatibility layer.
|
|
1517
|
+
*/
|
|
1499
1518
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_pre_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
|
|
1500
|
-
add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta'
|
|
1519
|
+
add_filter( 'rest_pre_insert_wp_navigation', 'block_core_navigation_update_ignore_hooked_blocks_meta' );
|
|
1501
1520
|
}
|
|
1502
1521
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1522
|
+
/*
|
|
1523
|
+
* Previous versions of Gutenberg were attaching the block_core_navigation_update_ignore_hooked_blocks_meta
|
|
1524
|
+
* function to the `rest_insert_wp_navigation` _action_ (rather than the `rest_pre_insert_wp_navigation` _filter_).
|
|
1525
|
+
* To avoid collisions, we need to remove the filter from that action if it's present.
|
|
1526
|
+
*/
|
|
1506
1527
|
if ( has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback ) ) {
|
|
1507
|
-
remove_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback
|
|
1528
|
+
remove_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_callback );
|
|
1508
1529
|
}
|
|
1509
1530
|
|
|
1510
1531
|
/**
|
|
@@ -1512,7 +1533,6 @@ if ( has_filter( 'rest_insert_wp_navigation', $rest_insert_wp_navigation_core_ca
|
|
|
1512
1533
|
*
|
|
1513
1534
|
* @param WP_REST_Response $response The response object.
|
|
1514
1535
|
* @param WP_Post $post Post object.
|
|
1515
|
-
* @param WP_REST_Request $request Request object.
|
|
1516
1536
|
* @return WP_REST_Response The response object.
|
|
1517
1537
|
*/
|
|
1518
1538
|
function block_core_navigation_insert_hooked_blocks_into_rest_response( $response, $post ) {
|
|
@@ -1531,13 +1551,17 @@ function block_core_navigation_insert_hooked_blocks_into_rest_response( $respons
|
|
|
1531
1551
|
return $response;
|
|
1532
1552
|
}
|
|
1533
1553
|
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1554
|
+
/*
|
|
1555
|
+
* Before adding our filter, we verify if it's already added in Core.
|
|
1556
|
+
* However, during the build process, Gutenberg automatically prefixes our functions with "gutenberg_".
|
|
1557
|
+
* Therefore, we concatenate the Core's function name to circumvent this prefix for our check.
|
|
1558
|
+
*/
|
|
1537
1559
|
$rest_prepare_wp_navigation_core_callback = 'block_core_navigation_' . 'insert_hooked_blocks_into_rest_response';
|
|
1538
1560
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1561
|
+
/*
|
|
1562
|
+
* Injection of hooked blocks into the Navigation block relies on some functions present in WP >= 6.5
|
|
1563
|
+
* that are not present in Gutenberg's WP 6.5 compatibility layer.
|
|
1564
|
+
*/
|
|
1541
1565
|
if ( function_exists( 'set_ignored_hooked_blocks_metadata' ) && ! has_filter( 'rest_prepare_wp_navigation', $rest_prepare_wp_navigation_core_callback ) ) {
|
|
1542
1566
|
add_filter( 'rest_prepare_wp_navigation', 'block_core_navigation_insert_hooked_blocks_into_rest_response', 10, 3 );
|
|
1543
1567
|
}
|