summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/navigation-submenu.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-includes/blocks/navigation-submenu.php')
-rw-r--r--wp-includes/blocks/navigation-submenu.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/wp-includes/blocks/navigation-submenu.php b/wp-includes/blocks/navigation-submenu.php
index 2ae23a9..92b55e2 100644
--- a/wp-includes/blocks/navigation-submenu.php
+++ b/wp-includes/blocks/navigation-submenu.php
@@ -9,6 +9,8 @@
* 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.
*/
@@ -43,6 +45,8 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
/**
* Returns the top-level submenu SVG chevron icon.
*
+ * @since 5.9.0
+ *
* @return string
*/
function block_core_navigation_submenu_render_submenu_icon() {
@@ -52,6 +56,8 @@ function block_core_navigation_submenu_render_submenu_icon() {
/**
* Renders the `core/navigation-submenu` block.
*
+ * @since 5.9.0
+ *
* @param array $attributes The block attributes.
* @param string $content The saved content.
* @param WP_Block $block The parsed block.
@@ -81,6 +87,13 @@ function render_block_core_navigation_submenu( $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;
+ }
+ }
+
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
$open_on_hover_and_click = isset( $block->context['openSubmenusOnClick'] ) && ! $block->context['openSubmenusOnClick'] &&
@@ -238,6 +251,8 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
/**
* Register the navigation submenu block.
*
+ * @since 5.9.0
+ *
* @uses render_block_core_navigation_submenu()
* @throws WP_Error An WP_Error exception parsing the block definition.
*/