wc_nav_menu_inner_blocks()
Hide menu items in navigation blocks conditionally.
Does the same thing as wc_nav_menu_items but for block themes.
Хуков нет.
Возвращает
\WP_Block_list
.
Использование
wc_nav_menu_inner_blocks( $inner_blocks );
- $inner_blocks(\WP_Block_list) (обязательный)
- Inner blocks.
Список изменений
С версии 9.3.0 | Введена. |
Код wc_nav_menu_inner_blocks() wc nav menu inner blocks WC 9.3.3
function wc_nav_menu_inner_blocks( $inner_blocks ) { $logout_endpoint = get_option( 'woocommerce_logout_endpoint', 'customer-logout' ); if ( ! empty( $logout_endpoint ) && $inner_blocks ) { foreach ( $inner_blocks as $inner_block_key => $inner_block ) { $url = $inner_block->parsed_block['attrs']['url'] ?? ''; $path = wp_parse_url( $url, PHP_URL_PATH ) ?? ''; $query = wp_parse_url( $url, PHP_URL_QUERY ) ?? ''; $is_logout_link = strstr( $path, $logout_endpoint ) || strstr( $query, $logout_endpoint ); if ( ! $is_logout_link ) { continue; } if ( is_user_logged_in() ) { $inner_block->parsed_block['attrs']['url'] = wp_nonce_url( $inner_block->parsed_block['attrs']['url'], 'customer-logout' ); } else { unset( $inner_blocks[ $inner_block_key ] ); } } } return $inner_blocks; }