Changeset 14104 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php
- Timestamp:
- 10/10/2024 03:43:26 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php
r13635 r14104 55 55 56 56 if ( substr( get_locale(), 0, 2 ) === 'en' ) { 57 return array( 58 'forums' => array( 59 array( 60 'label' => __( 'Welcome to Support', 'wporg-forums' ), 61 'url' => '/welcome/', 62 ), 63 array( 64 'label' => __( 'Guidelines', 'wporg-forums' ), 65 'url' => '/guidelines/', 66 ), 67 array( 68 'label' => __( 'Get Involved', 'wporg-forums' ), 69 'url' => 'https://make.wordpress.org/support/handbook/contributing-to-the-wordpress-forums/', 70 ) 57 $menu = array( 58 array( 59 'label' => __( 'Welcome to Support', 'wporg-forums' ), 60 'url' => '/welcome/', 61 ), 62 array( 63 'label' => __( 'Guidelines', 'wporg-forums' ), 64 'url' => '/guidelines/', 65 ), 66 array( 67 'label' => __( 'Get involved', 'wporg-forums' ), 68 'url' => 'https://make.wordpress.org/support/handbook/contributing-to-the-wordpress-forums/', 71 69 ), 72 70 ); 73 71 } else { 74 72 $local_nav_menu_object = wporg_support_get_local_nav_menu_object(); 75 $menu_items_fallback = array( 76 'forums' => array( 77 array( 78 'label' => __( 'Get Involved', 'wporg-forums' ), 79 'url' => 'https://make.wordpress.org/support/handbook/contributing-to-the-wordpress-forums/', 80 ) 73 $menu = array( 74 array( 75 'label' => __( 'Get involved', 'wporg-forums' ), 76 'url' => 'https://make.wordpress.org/support/handbook/contributing-to-the-wordpress-forums/', 81 77 ), 82 78 ); 83 79 80 if ( ! is_user_logged_in() ) { 81 global $wp; 82 $redirect_url = home_url( $wp->request ); 83 $menu[] = array( 84 'label' => __( 'Log in', 'wporg-forums' ), 85 'url' => wp_login_url( $redirect_url ), 86 'className' => 'has-separator', 87 ); 88 } 89 84 90 if ( ! $local_nav_menu_object ) { 85 return $menu_items_fallback;91 return array( 'forums' => $menu ); 86 92 } 87 93 … … 89 95 90 96 if ( ! $menu_items || empty( $menu_items ) ) { 91 return $menu_items_fallback; 92 } 93 94 return array( 95 'forums' => array_map( 96 function( $menu_item ) { 97 return array( 98 'label' => esc_html( $menu_item->title ), 99 'url' => esc_url( $menu_item->url ) 100 ); 101 }, 102 // Limit local nav items to 3 103 array_slice( $menu_items, 0, 3 ) 104 ) 97 return array( 'forums' => $menu ); 98 } 99 100 $menu = array_map( 101 function( $menu_item ) { 102 return array( 103 'label' => esc_html( $menu_item->title ), 104 'url' => esc_url( $menu_item->url ) 105 ); 106 }, 107 // Limit local nav items to 3 108 array_slice( $menu_items, 0, 3 ) 105 109 ); 106 110 } 111 112 if ( ! is_user_logged_in() ) { 113 global $wp; 114 $redirect_url = home_url( $wp->request ); 115 $menu[] = array( 116 'label' => __( 'Log in', 'wporg-forums' ), 117 'url' => wp_login_url( $redirect_url ), 118 'className' => 'has-separator', 119 ); 120 } 121 122 return array( 'forums' => $menu ); 107 123 } 108 124 add_filter( 'wporg_block_navigation_menus', 'wporg_support_add_site_navigation_menus' );
Note: See TracChangeset
for help on using the changeset viewer.