summaryrefslogtreecommitdiffstats
path: root/wp-includes/blocks/navigation-submenu.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-submenu.php
parentAdding upstream version 6.5.5+dfsg1. (diff)
downloadwordpress-23bd21eba100fba4eccff0d3eb058c92bcf55964.tar.xz
wordpress-23bd21eba100fba4eccff0d3eb058c92bcf55964.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-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.
*/