diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe-2024/content-pledge.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe-2024/content-pledge.php index b680eeccd8..c39ff9103d 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe-2024/content-pledge.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe-2024/content-pledge.php @@ -1,6 +1,6 @@ isFile() ) { + require $file->getPathname(); + } + } +} +add_action( 'init', __NAMESPACE__ . '\wporg_breathe_register_patterns' ); + +/** + * Get the primary navigation menu object if it exists. + */ +function wporg_breathe_get_local_nav_menu_object() { + $local_nav_menu_locations = get_nav_menu_locations(); + $local_nav_menu_object = isset( $local_nav_menu_locations['primary'] ) + ? wp_get_nav_menu_object( $local_nav_menu_locations['primary'] ) + : false; + + return $local_nav_menu_object; +} + +/** + * Provide a list of local navigation menus. + */ +function wporg_breathe_add_site_navigation_menus( $menus ) { + if ( is_admin() ) { + return; + } + $local_nav_menu_object = wporg_breathe_get_local_nav_menu_object(); + + if ( ! $local_nav_menu_object ) { + return array(); + } + + $menu_items = wp_get_nav_menu_items( $local_nav_menu_object->term_id ); + + if ( ! $menu_items || empty( $menu_items ) ) { + return array(); + } + + return array( + 'breathe' => array_map( + function( $menu_item ) { + return array( + 'label' => esc_html( $menu_item->title ), + 'url' => esc_url( $menu_item->url ) + ); + }, + // Limit local nav items to 4 + array_slice( $menu_items, 0, 4 ) + ) + ); +} +add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\wporg_breathe_add_site_navigation_menus' ); + /** * Add postMessage support for site title and description in the customizer. * @@ -285,7 +344,7 @@ function welcome_box() { id="make-welcome-toggle" data-show="" data-hide="" - > + >