diff options
Diffstat (limited to 'wp-includes/blocks/navigation-link.php')
-rw-r--r-- | wp-includes/blocks/navigation-link.php | 21 |
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. */ |