Changeset 11146 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php
- Timestamp:
- 07/21/2021 04:36:29 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php
r11145 r11146 10 10 add_action( 'wp_head', __NAMESPACE__ . '\generate_block_editor_styles_html' ); 11 11 add_action( 'wp_head', __NAMESPACE__ . '\add_social_meta_tags' ); 12 add_filter( 'document_title_parts', __NAMESPACE__ . '\set_document_title' ); 12 13 add_action( 'body_class', __NAMESPACE__ . '\body_class', 10, 2 ); 13 14 add_action( 'pre_get_posts', __NAMESPACE__ . '\pre_get_posts' ); … … 321 322 } 322 323 } 324 325 /** 326 * Append an optimized site name. 327 * 328 * @param array $title { 329 * The document title parts. 330 * 331 * @type string $title Title of the viewed page. 332 * @type string $page Optional. Page number if paginated. 333 * @type string $tagline Optional. Site description when on home page. 334 * @type string $site Optional. Site title when not on home page. 335 * } 336 * @return array Filtered title parts. 337 */ 338 function set_document_title( $title ) { 339 global $wp_query; 340 341 if ( is_front_page() ) { 342 $title['title'] = __( 'Block Pattern Directory', 'wporg-patterns' ); 343 $title['tagline'] = __( 'WordPress.org', 'wporg-patterns' ); 344 } else { 345 if ( is_singular( POST_TYPE ) ) { 346 $title['title'] .= ' - ' . __( 'Block Pattern', 'wporg-patterns' ); 347 } elseif ( is_tax() ) { 348 /* translators: Taxonomy term name */ 349 $title['title'] = sprintf( __( 'Block Patterns: %s', 'wporg-patterns' ), $title['title'] ); 350 } elseif ( is_author() ) { 351 /* translators: Author name */ 352 $title['title'] = sprintf( __( 'Block Patterns by %s', 'wporg-patterns' ), $title['title'] ); 353 } 354 355 // If results are paged and the max number of pages is known. 356 if ( is_paged() && $wp_query->max_num_pages ) { 357 // translators: 1: current page number, 2: total number of pages 358 $title['page'] = sprintf( 359 __( 'Page %1$s of %2$s', 'wporg-patterns' ), 360 get_query_var( 'paged' ), 361 $wp_query->max_num_pages 362 ); 363 } 364 365 $title['site'] = __( 'WordPress.org', 'wporg-patterns' ); 366 } 367 368 return $title; 369 }
Note: See TracChangeset
for help on using the changeset viewer.