Changeset 9865
- Timestamp:
- 05/13/2020 05:07:19 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-breathe/functions.php
r9847 r9865 38 38 39 39 /** 40 * Outputs a 'noindex,follow' `meta` tag when appropriate. 41 * 42 * Currently applies to: 43 * - date-based archives 44 * - search results 45 * - Author archives 46 * - 'mentions' taxonomy 47 * - tag archives with fewer than 3 posts 48 */ 49 function no_robots() { 50 if ( 51 is_search() 52 || 53 is_author() 54 || 55 is_date() 56 || 57 is_tax( 'mentions' ) 58 || 59 is_tag() 60 ) { 61 wp_no_robots(); 62 } 63 } 64 add_action( 'wp_head', __NAMESPACE__ . '\no_robots', 9 ); 65 66 67 /** 68 * Outputs `<link rel="canonical">` tags where needed. 69 */ 70 function rel_canonical() { 71 $canonical = false; 72 $queried_object = get_queried_object(); 73 74 if ( is_tax() || is_tag() || is_category() ) { 75 $canonical = get_term_link( $queried_object ); 76 } elseif ( is_singular() ) { 77 $canonical = get_permalink( $queried_object ); 78 } elseif ( is_front_page() ) { 79 $canonical = home_url( '/' ); 80 } 81 82 if ( $canonical && get_query_var( 'paged' ) > 1 ) { 83 $canonical .= 'page/' . (int) get_query_var( 'paged' ) . '/'; 84 } 85 86 if ( $canonical ) { 87 printf( '<link rel="canonical" href="%s">' . "\n", esc_url( $canonical ) ); 88 } 89 } 90 add_action( 'wp_head', __NAMESPACE__ . '\rel_canonical' ); 40 * noindex the Mentions archives. 41 */ 42 function no_robots( $noindex ) { 43 if ( is_tax( 'mentions' ) ) { 44 $noindex = true; 45 } 46 47 return $noindex; 48 } 49 add_filter( 'wporg_noindex_request', __NAMESPACE__ . '\no_robots' ); 91 50 92 51 /**
Note: See TracChangeset
for help on using the changeset viewer.