summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/navigation-link
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/blocks/navigation-link.php59
-rw-r--r--wp-includes/blocks/navigation-link/block.json9
-rw-r--r--wp-includes/blocks/navigation-link/editor-rtl.css2
-rw-r--r--wp-includes/blocks/navigation-link/editor-rtl.min.css2
-rw-r--r--wp-includes/blocks/navigation-link/editor.css2
-rw-r--r--wp-includes/blocks/navigation-link/editor.min.css2
-rw-r--r--wp-includes/blocks/navigation-link/style-rtl.css22
-rw-r--r--wp-includes/blocks/navigation-link/style-rtl.min.css2
-rw-r--r--wp-includes/blocks/navigation-link/style.css22
-rw-r--r--wp-includes/blocks/navigation-link/style.min.css2
10 files changed, 108 insertions, 16 deletions
diff --git a/wp-includes/blocks/navigation-link.php b/wp-includes/blocks/navigation-link.php
index 5333ab6..4ed54fc 100644
--- a/wp-includes/blocks/navigation-link.php
+++ b/wp-includes/blocks/navigation-link.php
@@ -1,6 +1,6 @@
<?php
/**
- * Server-side rendering of the `core/navigation-link` block.
+ * Server-side registering and rendering of the `core/navigation-link` block.
*
* @package WordPress
*/
@@ -132,6 +132,10 @@ function block_core_navigation_link_maybe_urldecode( $url ) {
$query_params = wp_parse_args( $query );
foreach ( $query_params as $query_param ) {
+ $can_query_param_be_encoded = is_string( $query_param ) && ! empty( $query_param );
+ if ( ! $can_query_param_be_encoded ) {
+ continue;
+ }
if ( rawurldecode( $query_param ) !== $query_param ) {
$is_url_encoded = true;
break;
@@ -323,19 +327,40 @@ function build_variation_for_navigation_link( $entity, $kind ) {
}
/**
- * Register the navigation link block.
+ * Filters the registered variations for a block type.
+ * Returns the dynamically built variations for all post-types and taxonomies.
*
- * @uses render_block_core_navigation()
- * @throws WP_Error An WP_Error exception parsing the block definition.
+ * @since 6.5.0
+ *
+ * @param array $variations Array of registered variations for a block type.
+ * @param WP_Block_Type $block_type The full block type object.
*/
-function register_block_core_navigation_link() {
+function block_core_navigation_link_filter_variations( $variations, $block_type ) {
+ if ( 'core/navigation-link' !== $block_type->name ) {
+ return $variations;
+ }
+
+ $generated_variations = block_core_navigation_link_build_variations();
+ return array_merge( $variations, $generated_variations );
+}
+
+/**
+ * Returns an array of variations for the navigation link block.
+ *
+ * @since 6.5.0
+ *
+ * @return array
+ */
+function block_core_navigation_link_build_variations() {
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'objects' );
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'objects' );
- // Use two separate arrays as a way to order the variations in the UI.
- // Known variations (like Post Link and Page Link) are added to the
- // `built_ins` array. Variations for custom post types and taxonomies are
- // added to the `variations` array and will always appear after `built-ins.
+ /*
+ * Use two separate arrays as a way to order the variations in the UI.
+ * Known variations (like Post Link and Page Link) are added to the
+ * `built_ins` array. Variations for custom post types and taxonomies are
+ * added to the `variations` array and will always appear after `built-ins.
+ */
$built_ins = array();
$variations = array();
@@ -360,12 +385,26 @@ function register_block_core_navigation_link() {
}
}
+ return array_merge( $built_ins, $variations );
+}
+
+/**
+ * Registers the navigation link block.
+ *
+ * @uses render_block_core_navigation_link()
+ * @throws WP_Error An WP_Error exception parsing the block definition.
+ */
+function register_block_core_navigation_link() {
register_block_type_from_metadata(
__DIR__ . '/navigation-link',
array(
'render_callback' => 'render_block_core_navigation_link',
- 'variations' => array_merge( $built_ins, $variations ),
)
);
}
add_action( 'init', 'register_block_core_navigation_link' );
+/**
+ * Creates all variations for post types / taxonomies dynamically (= each time when variations are requested).
+ * Do not use variation_callback, to also account for unregistering post types/taxonomies later on.
+ */
+add_action( 'get_block_type_variations', 'block_core_navigation_link_filter_variations', 10, 2 );
diff --git a/wp-includes/blocks/navigation-link/block.json b/wp-includes/blocks/navigation-link/block.json
index b2cbeae..2762bd2 100644
--- a/wp-includes/blocks/navigation-link/block.json
+++ b/wp-includes/blocks/navigation-link/block.json
@@ -5,6 +5,11 @@
"title": "Custom Link",
"category": "design",
"parent": [ "core/navigation" ],
+ "allowedBlocks": [
+ "core/navigation-link",
+ "core/navigation-submenu",
+ "core/page-list"
+ ],
"description": "Add a page, link, or another item to your navigation.",
"textdomain": "default",
"attributes": {
@@ -71,6 +76,10 @@
"__experimentalDefaultControls": {
"fontSize": true
}
+ },
+ "renaming": false,
+ "interactivity": {
+ "clientNavigation": true
}
},
"editorStyle": "wp-block-navigation-link-editor",
diff --git a/wp-includes/blocks/navigation-link/editor-rtl.css b/wp-includes/blocks/navigation-link/editor-rtl.css
index c7811c0..8f15cd2 100644
--- a/wp-includes/blocks/navigation-link/editor-rtl.css
+++ b/wp-includes/blocks/navigation-link/editor-rtl.css
@@ -39,7 +39,7 @@
}
.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{
--wp-underline-color:var(--wp-admin-theme-color);
- background-image:linear-gradient(-45deg, transparent 20%, var(--wp-underline-color) 30%, var(--wp-underline-color) 36%, transparent 46%), linear-gradient(-135deg, transparent 54%, var(--wp-underline-color) 64%, var(--wp-underline-color) 70%, transparent 80%);
+ background-image:linear-gradient(-45deg, #0000 20%, var(--wp-underline-color) 30%, var(--wp-underline-color) 36%, #0000 46%), linear-gradient(-135deg, #0000 54%, var(--wp-underline-color) 64%, var(--wp-underline-color) 70%, #0000 80%);
background-position:100% 100%;
background-repeat:repeat-x;
background-size:6px 3px;
diff --git a/wp-includes/blocks/navigation-link/editor-rtl.min.css b/wp-includes/blocks/navigation-link/editor-rtl.min.css
index 78accfe..9b02cee 100644
--- a/wp-includes/blocks/navigation-link/editor-rtl.min.css
+++ b/wp-includes/blocks/navigation-link/editor-rtl.min.css
@@ -1 +1 @@
-.wp-block-navigation .block-list-appender{position:relative}.wp-block-navigation .has-child{cursor:pointer}.wp-block-navigation .has-child .wp-block-navigation__submenu-container{z-index:28}.wp-block-navigation .has-child:hover .wp-block-navigation__submenu-container{z-index:29}.wp-block-navigation .has-child.has-child-selected>.wp-block-navigation__submenu-container,.wp-block-navigation .has-child.is-selected>.wp-block-navigation__submenu-container{height:auto!important;min-width:200px!important;opacity:1!important;overflow:visible!important;visibility:visible!important;width:auto!important}.wp-block-navigation-item .wp-block-navigation-item__content{cursor:text}.wp-block-navigation-item.is-editing,.wp-block-navigation-item.is-selected{min-width:20px}.wp-block-navigation-item .block-list-appender{margin:16px 16px 16px auto}.wp-block-navigation-link__invalid-item{color:#000}.wp-block-navigation-link__placeholder{background-image:none!important;box-shadow:none!important;position:relative;text-decoration:none!important}.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:var(--wp-admin-theme-color);background-image:linear-gradient(-45deg,transparent 20%,var(--wp-underline-color) 30%,var(--wp-underline-color) 36%,transparent 46%),linear-gradient(-135deg,transparent 54%,var(--wp-underline-color) 64%,var(--wp-underline-color) 70%,transparent 80%);background-position:100% 100%;background-repeat:repeat-x;background-size:6px 3px;padding-bottom:.1em}.is-dark-theme .wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:#fff}.wp-block-navigation-link__placeholder.wp-block-navigation-item__content{cursor:pointer}.link-control-transform{border-top:1px solid #ccc;padding:0 16px 8px}.link-control-transform__subheading{color:#1e1e1e;font-size:11px;font-weight:500;margin-bottom:1.5em;text-transform:uppercase}.link-control-transform__items{display:flex;justify-content:space-between}.link-control-transform__item{flex-basis:33%;flex-direction:column;gap:8px;height:auto} \ No newline at end of file
+.wp-block-navigation .block-list-appender{position:relative}.wp-block-navigation .has-child{cursor:pointer}.wp-block-navigation .has-child .wp-block-navigation__submenu-container{z-index:28}.wp-block-navigation .has-child:hover .wp-block-navigation__submenu-container{z-index:29}.wp-block-navigation .has-child.has-child-selected>.wp-block-navigation__submenu-container,.wp-block-navigation .has-child.is-selected>.wp-block-navigation__submenu-container{height:auto!important;min-width:200px!important;opacity:1!important;overflow:visible!important;visibility:visible!important;width:auto!important}.wp-block-navigation-item .wp-block-navigation-item__content{cursor:text}.wp-block-navigation-item.is-editing,.wp-block-navigation-item.is-selected{min-width:20px}.wp-block-navigation-item .block-list-appender{margin:16px 16px 16px auto}.wp-block-navigation-link__invalid-item{color:#000}.wp-block-navigation-link__placeholder{background-image:none!important;box-shadow:none!important;position:relative;text-decoration:none!important}.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:var(--wp-admin-theme-color);background-image:linear-gradient(-45deg,#0000 20%,var(--wp-underline-color) 30%,var(--wp-underline-color) 36%,#0000 46%),linear-gradient(-135deg,#0000 54%,var(--wp-underline-color) 64%,var(--wp-underline-color) 70%,#0000 80%);background-position:100% 100%;background-repeat:repeat-x;background-size:6px 3px;padding-bottom:.1em}.is-dark-theme .wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:#fff}.wp-block-navigation-link__placeholder.wp-block-navigation-item__content{cursor:pointer}.link-control-transform{border-top:1px solid #ccc;padding:0 16px 8px}.link-control-transform__subheading{color:#1e1e1e;font-size:11px;font-weight:500;margin-bottom:1.5em;text-transform:uppercase}.link-control-transform__items{display:flex;justify-content:space-between}.link-control-transform__item{flex-basis:33%;flex-direction:column;gap:8px;height:auto} \ No newline at end of file
diff --git a/wp-includes/blocks/navigation-link/editor.css b/wp-includes/blocks/navigation-link/editor.css
index e1faecb..b1dc052 100644
--- a/wp-includes/blocks/navigation-link/editor.css
+++ b/wp-includes/blocks/navigation-link/editor.css
@@ -39,7 +39,7 @@
}
.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{
--wp-underline-color:var(--wp-admin-theme-color);
- background-image:linear-gradient(45deg, transparent 20%, var(--wp-underline-color) 30%, var(--wp-underline-color) 36%, transparent 46%), linear-gradient(135deg, transparent 54%, var(--wp-underline-color) 64%, var(--wp-underline-color) 70%, transparent 80%);
+ background-image:linear-gradient(45deg, #0000 20%, var(--wp-underline-color) 30%, var(--wp-underline-color) 36%, #0000 46%), linear-gradient(135deg, #0000 54%, var(--wp-underline-color) 64%, var(--wp-underline-color) 70%, #0000 80%);
background-position:0 100%;
background-repeat:repeat-x;
background-size:6px 3px;
diff --git a/wp-includes/blocks/navigation-link/editor.min.css b/wp-includes/blocks/navigation-link/editor.min.css
index 92e6313..faea0f6 100644
--- a/wp-includes/blocks/navigation-link/editor.min.css
+++ b/wp-includes/blocks/navigation-link/editor.min.css
@@ -1 +1 @@
-.wp-block-navigation .block-list-appender{position:relative}.wp-block-navigation .has-child{cursor:pointer}.wp-block-navigation .has-child .wp-block-navigation__submenu-container{z-index:28}.wp-block-navigation .has-child:hover .wp-block-navigation__submenu-container{z-index:29}.wp-block-navigation .has-child.has-child-selected>.wp-block-navigation__submenu-container,.wp-block-navigation .has-child.is-selected>.wp-block-navigation__submenu-container{height:auto!important;min-width:200px!important;opacity:1!important;overflow:visible!important;visibility:visible!important;width:auto!important}.wp-block-navigation-item .wp-block-navigation-item__content{cursor:text}.wp-block-navigation-item.is-editing,.wp-block-navigation-item.is-selected{min-width:20px}.wp-block-navigation-item .block-list-appender{margin:16px auto 16px 16px}.wp-block-navigation-link__invalid-item{color:#000}.wp-block-navigation-link__placeholder{background-image:none!important;box-shadow:none!important;position:relative;text-decoration:none!important}.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:var(--wp-admin-theme-color);background-image:linear-gradient(45deg,transparent 20%,var(--wp-underline-color) 30%,var(--wp-underline-color) 36%,transparent 46%),linear-gradient(135deg,transparent 54%,var(--wp-underline-color) 64%,var(--wp-underline-color) 70%,transparent 80%);background-position:0 100%;background-repeat:repeat-x;background-size:6px 3px;padding-bottom:.1em}.is-dark-theme .wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:#fff}.wp-block-navigation-link__placeholder.wp-block-navigation-item__content{cursor:pointer}.link-control-transform{border-top:1px solid #ccc;padding:0 16px 8px}.link-control-transform__subheading{color:#1e1e1e;font-size:11px;font-weight:500;margin-bottom:1.5em;text-transform:uppercase}.link-control-transform__items{display:flex;justify-content:space-between}.link-control-transform__item{flex-basis:33%;flex-direction:column;gap:8px;height:auto} \ No newline at end of file
+.wp-block-navigation .block-list-appender{position:relative}.wp-block-navigation .has-child{cursor:pointer}.wp-block-navigation .has-child .wp-block-navigation__submenu-container{z-index:28}.wp-block-navigation .has-child:hover .wp-block-navigation__submenu-container{z-index:29}.wp-block-navigation .has-child.has-child-selected>.wp-block-navigation__submenu-container,.wp-block-navigation .has-child.is-selected>.wp-block-navigation__submenu-container{height:auto!important;min-width:200px!important;opacity:1!important;overflow:visible!important;visibility:visible!important;width:auto!important}.wp-block-navigation-item .wp-block-navigation-item__content{cursor:text}.wp-block-navigation-item.is-editing,.wp-block-navigation-item.is-selected{min-width:20px}.wp-block-navigation-item .block-list-appender{margin:16px auto 16px 16px}.wp-block-navigation-link__invalid-item{color:#000}.wp-block-navigation-link__placeholder{background-image:none!important;box-shadow:none!important;position:relative;text-decoration:none!important}.wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:var(--wp-admin-theme-color);background-image:linear-gradient(45deg,#0000 20%,var(--wp-underline-color) 30%,var(--wp-underline-color) 36%,#0000 46%),linear-gradient(135deg,#0000 54%,var(--wp-underline-color) 64%,var(--wp-underline-color) 70%,#0000 80%);background-position:0 100%;background-repeat:repeat-x;background-size:6px 3px;padding-bottom:.1em}.is-dark-theme .wp-block-navigation-link__placeholder .wp-block-navigation-link__placeholder-text span{--wp-underline-color:#fff}.wp-block-navigation-link__placeholder.wp-block-navigation-item__content{cursor:pointer}.link-control-transform{border-top:1px solid #ccc;padding:0 16px 8px}.link-control-transform__subheading{color:#1e1e1e;font-size:11px;font-weight:500;margin-bottom:1.5em;text-transform:uppercase}.link-control-transform__items{display:flex;justify-content:space-between}.link-control-transform__item{flex-basis:33%;flex-direction:column;gap:8px;height:auto} \ No newline at end of file
diff --git a/wp-includes/blocks/navigation-link/style-rtl.css b/wp-includes/blocks/navigation-link/style-rtl.css
index c1a6879..ffeffa5 100644
--- a/wp-includes/blocks/navigation-link/style-rtl.css
+++ b/wp-includes/blocks/navigation-link/style-rtl.css
@@ -3,4 +3,26 @@
}
.wp-block-navigation .wp-block-navigation-item__description{
display:none;
+}
+
+.link-ui-tools{
+ border-top:1px solid #f0f0f0;
+ padding:8px;
+}
+
+.link-ui-block-inserter{
+ padding-top:8px;
+}
+
+.link-ui-block-inserter__back{
+ margin-right:8px;
+ text-transform:uppercase;
+}
+
+.components-popover-pointer-events-trap{
+ background-color:initial;
+ cursor:pointer;
+ inset:0;
+ position:fixed;
+ z-index:1000000;
} \ No newline at end of file
diff --git a/wp-includes/blocks/navigation-link/style-rtl.min.css b/wp-includes/blocks/navigation-link/style-rtl.min.css
index 6515ef8..752908c 100644
--- a/wp-includes/blocks/navigation-link/style-rtl.min.css
+++ b/wp-includes/blocks/navigation-link/style-rtl.min.css
@@ -1 +1 @@
-.wp-block-navigation .wp-block-navigation-item__label{overflow-wrap:break-word}.wp-block-navigation .wp-block-navigation-item__description{display:none} \ No newline at end of file
+.wp-block-navigation .wp-block-navigation-item__label{overflow-wrap:break-word}.wp-block-navigation .wp-block-navigation-item__description{display:none}.link-ui-tools{border-top:1px solid #f0f0f0;padding:8px}.link-ui-block-inserter{padding-top:8px}.link-ui-block-inserter__back{margin-right:8px;text-transform:uppercase}.components-popover-pointer-events-trap{background-color:initial;cursor:pointer;inset:0;position:fixed;z-index:1000000} \ No newline at end of file
diff --git a/wp-includes/blocks/navigation-link/style.css b/wp-includes/blocks/navigation-link/style.css
index c1a6879..a136b2c 100644
--- a/wp-includes/blocks/navigation-link/style.css
+++ b/wp-includes/blocks/navigation-link/style.css
@@ -3,4 +3,26 @@
}
.wp-block-navigation .wp-block-navigation-item__description{
display:none;
+}
+
+.link-ui-tools{
+ border-top:1px solid #f0f0f0;
+ padding:8px;
+}
+
+.link-ui-block-inserter{
+ padding-top:8px;
+}
+
+.link-ui-block-inserter__back{
+ margin-left:8px;
+ text-transform:uppercase;
+}
+
+.components-popover-pointer-events-trap{
+ background-color:initial;
+ cursor:pointer;
+ inset:0;
+ position:fixed;
+ z-index:1000000;
} \ No newline at end of file
diff --git a/wp-includes/blocks/navigation-link/style.min.css b/wp-includes/blocks/navigation-link/style.min.css
index 6515ef8..c58d937 100644
--- a/wp-includes/blocks/navigation-link/style.min.css
+++ b/wp-includes/blocks/navigation-link/style.min.css
@@ -1 +1 @@
-.wp-block-navigation .wp-block-navigation-item__label{overflow-wrap:break-word}.wp-block-navigation .wp-block-navigation-item__description{display:none} \ No newline at end of file
+.wp-block-navigation .wp-block-navigation-item__label{overflow-wrap:break-word}.wp-block-navigation .wp-block-navigation-item__description{display:none}.link-ui-tools{border-top:1px solid #f0f0f0;padding:8px}.link-ui-block-inserter{padding-top:8px}.link-ui-block-inserter__back{margin-left:8px;text-transform:uppercase}.components-popover-pointer-events-trap{background-color:initial;cursor:pointer;inset:0;position:fixed;z-index:1000000} \ No newline at end of file