Changeset 7106 for sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php
- Timestamp:
- 04/13/2018 05:24:28 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php
r7055 r7106 9 9 add_filter( 'get_custom_logo', __NAMESPACE__ . '\set_custom_logo' ); 10 10 add_filter( 'body_class', __NAMESPACE__ . '\add_body_classes' ); 11 add_filter( 'the_title', __NAMESPACE__ . '\internationalize_titles' ); 12 add_filter( 'document_title_parts', __NAMESPACE__ . '\internationalize_document_titles' ); 11 13 add_filter( 'wp_get_nav_menu_items', __NAMESPACE__ . '\internationalize_menu_items' ); 12 14 … … 106 108 * Internationalize the menu item titles. 107 109 * 110 * @param string $title 111 * 112 * @return string 113 */ 114 function internationalize_titles( $title ) { 115 switch ( $title ) { 116 case 'WP15': 117 // translators: The title of the wp15.wordpress.net website. 118 $title = esc_html__( 'WP15', 'wp15' ); 119 break; 120 121 case 'WordPress turns 15 on May 27, 2018': 122 // translators: The tagline for the wp15.wordpress.net website. 123 $title = esc_html__( 'WordPress turns 15 on May 27, 2018', 'wp15' ); 124 break; 125 126 case 'About': 127 // translators: The name of the page that describes the WP15 celebrations. 128 $title = esc_html__( 'About', 'wp15' ); 129 break; 130 131 case 'Live': 132 // translators: The name of the page that displays the #wp15 social media posts in real time. 133 $title = esc_html_x( 'Live', 'verb', 'wp15' ); 134 break; 135 136 case 'Swag': 137 // translators: "Swag" is a term for promotional items. This is the title of the page. 138 $title = esc_html__( 'Swag', 'wp15' ); 139 break; 140 } 141 142 return $title; 143 } 144 145 /** 146 * Internationalize the document's `<title>` element. 147 * 148 * @param array $title_parts 149 * 150 * @return array 151 */ 152 function internationalize_document_titles( $title_parts ) { 153 $title_parts['title'] = internationalize_titles( $title_parts['title'] ); 154 155 if ( isset( $title_parts['site'] ) ) { 156 $title_parts['site'] = internationalize_titles( $title_parts['site'] ); 157 } 158 159 if ( isset( $title_parts['tagline'] ) ) { 160 $title_parts['tagline'] = internationalize_titles( $title_parts['tagline'] ); 161 } 162 163 return $title_parts; 164 } 165 166 /** 167 * Internationalize the menu item titles. 168 * 108 169 * @param array $items 109 170 * … … 112 173 function internationalize_menu_items( $items ) { 113 174 foreach ( $items as $item ) { 114 switch ( $item->title ) { 115 case 'About': 116 // translators: The name of the page that describes the WP15 celebrations. 117 $item->title = esc_html__( 'About', 'wp15' ); 118 break; 119 120 case 'Live': 121 // translators: The name of the page that displays the #wp15 social media posts in real time. 122 $item->title = esc_html_x( 'Live', 'verb', 'wp15' ); 123 break; 124 125 case 'Swag': 126 // translators: "Swag" is a term for promotional items. This is the title of the page. 127 $item->title = esc_html__( 'Swag', 'wp15' ); 128 break; 129 } 175 $item->post_title = internationalize_titles( $item->post_title ); 130 176 } 131 177
Note: See TracChangeset
for help on using the changeset viewer.