summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/navigation-link.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:18 +0000
commit0e41b5d52fdc6af6442816b5f465c9db9f84e126 (patch)
treee139a90049b158d4eed892d1662ee7f5c358fa31 /wp-includes/blocks/navigation-link.php
parentAdding upstream version 6.5.5+dfsg1. (diff)
downloadwordpress-0e41b5d52fdc6af6442816b5f465c9db9f84e126.tar.xz
wordpress-0e41b5d52fdc6af6442816b5f465c9db9f84e126.zip
Adding upstream version 6.6.1+dfsg1.upstream/6.6.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/blocks/navigation-link.php')
-rw-r--r--wp-includes/blocks/navigation-link.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/wp-includes/blocks/navigation-link.php b/wp-includes/blocks/navigation-link.php
index 4ed54fc..5653e04 100644
--- a/wp-includes/blocks/navigation-link.php
+++ b/wp-includes/blocks/navigation-link.php
@@ -9,6 +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.
*
+ * @since 5.9.0
+ *
* @param array $context Navigation block context.
* @param array $attributes Block attributes.
* @param bool $is_sub_menu Whether the link is part of a sub-menu.
@@ -79,6 +81,8 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is
* 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.
*
+ * @since 5.9.0
+ *
* @param array $context Navigation block context.
* @return array Font size CSS classes and inline styles.
*/
@@ -113,6 +117,8 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
/**
* Returns the top-level submenu SVG chevron icon.
*
+ * @since 5.9.0
+ *
* @return string
*/
function block_core_navigation_link_render_submenu_icon() {
@@ -122,6 +128,8 @@ function block_core_navigation_link_render_submenu_icon() {
/**
* Decodes a url if it's encoded, returning the same url if not.
*
+ * @since 6.2.0
+ *
* @param string $url The url to decode.
*
* @return string $url Returns the decoded url.
@@ -153,6 +161,8 @@ function block_core_navigation_link_maybe_urldecode( $url ) {
/**
* Renders the `core/navigation-link` block.
*
+ * @since 5.9.0
+ *
* @param array $attributes The block attributes.
* @param string $content The saved content.
* @param WP_Block $block The parsed block.
@@ -188,6 +198,13 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
$kind = empty( $attributes['kind'] ) ? 'post_type' : str_replace( '-', '_', $attributes['kind'] );
$is_active = ! empty( $attributes['id'] ) && get_queried_object_id() === (int) $attributes['id'] && ! empty( get_queried_object()->$kind );
+ if ( is_post_type_archive() ) {
+ $queried_archive_link = get_post_type_archive_link( get_queried_object()->name );
+ if ( $attributes['url'] === $queried_archive_link ) {
+ $is_active = true;
+ }
+ }
+
$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => $css_classes . ' wp-block-navigation-item' . ( $has_submenu ? ' has-child' : '' ) .
@@ -269,6 +286,8 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
/**
* Returns a navigation link variation
*
+ * @since 5.9.0
+ *
* @param WP_Taxonomy|WP_Post_Type $entity post type or taxonomy entity.
* @param string $kind string of value 'taxonomy' or 'post-type'.
*
@@ -391,6 +410,8 @@ function block_core_navigation_link_build_variations() {
/**
* Registers the navigation link block.
*
+ * @since 5.9.0
+ *
* @uses render_block_core_navigation_link()
* @throws WP_Error An WP_Error exception parsing the block definition.
*/