is_amp() ) { return; } // Enqueue the navigation script. wp_enqueue_script( 'buddyx-navigation', get_theme_file_uri( '/assets/js/navigation.min.js' ), array(), buddyx()->get_asset_version( get_theme_file_path( '/assets/js/navigation.min.js' ) ), true ); wp_script_add_data( 'buddyx-navigation', 'async', true ); wp_script_add_data( 'buddyx-navigation', 'precache', true ); wp_localize_script( 'buddyx-navigation', 'buddyxScreenReaderText', array( 'expand' => esc_attr__( 'Expand child menu', 'buddyx' ), 'collapse' => esc_attr__( 'Collapse child menu', 'buddyx' ), ) ); } /** * AMP accessibility. */ public function action_wp_head_amp_script() { if ( ! buddyx()->is_amp() ) { ?> is_amp() ) { return; } // Print the minified script. ?> ` element * @param WP_Post $item the current menu item * * @return array Modified HTML attributes */ public function filter_nav_menu_link_attributes_aria_current( array $atts, $item ): array { if ( isset( $item->current ) ) { if ( $item->current ) { $atts['aria-current'] = 'page'; } } elseif ( ! empty( $item->ID ) ) { global $post; if ( ! empty( $post->ID ) && (int) $post->ID === (int) $item->ID ) { $atts['aria-current'] = 'page'; } } return $atts; } }