Changeset 9864 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
- Timestamp:
- 05/13/2020 05:04:11 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r9819 r9864 1124 1124 // If it's outdated, noindex the theme. 1125 1125 if ( time() - strtotime( $theme->last_updated ) > 2 * YEAR_IN_SECONDS ) { 1126 echo "<meta name='robots' content='noindex,follow' />\n";1126 add_filter( 'wporg_noindex_request', '__return_true' ); 1127 1127 } 1128 1128 } … … 1274 1274 1275 1275 /** 1276 * Outputs X-Robots-Tag with noindex for feeds.1277 */1278 function wporg_themes_noindex_for_feeds() {1279 if ( is_tag() ) {1280 header( 'X-Robots-Tag: noindex' );1281 }1282 if ( is_search() ) {1283 header( 'X-Robots-Tag: noindex, follow' );1284 }1285 }1286 add_action( 'themes_custom_feed_head', 'wporg_themes_noindex_for_feeds' );1287 1288 /**1289 * Outputs a <link rel="canonical"> on archive pages.1290 */1291 function wporg_themes_archive_rel_canonical_link() {1292 if ( $url = wporg_themes_get_current_url() ) {1293 printf(1294 '<link rel="canonical" href="%s">' . "\n",1295 esc_url( $url )1296 );1297 }1298 }1299 add_action( 'wp_head', 'wporg_themes_archive_rel_canonical_link' );1300 remove_action( 'wp_head', 'rel_canonical' );1301 1302 /**1303 1276 * Get the current front-end requested URL. 1304 1277 */ 1305 1278 function wporg_themes_get_current_url( $path_only = false ) { 1306 $queried_object = get_queried_object(); 1307 $link = false; 1308 1309 if ( get_query_var( 'browse' ) && WPORG_THEMES_DEFAULT_BROWSE === get_query_var( 'browse' ) ) { 1310 $link = home_url( '/' ); 1311 } elseif ( get_query_var( 'browse' ) ) { 1312 // The browse/% urls on the Theme directory are front-page-query alterations. 1313 $link = home_url( 'browse/' . get_query_var( 'browse' ) . '/' ); 1314 } elseif ( is_author() ) { 1315 // On WordPress.org get_author_posts_url() returns profile.wordpress.org links. Build it manually. 1316 $link = home_url( 'author/' . $queried_object->user_nicename . '/' ); 1317 } elseif ( is_tax() || is_tag() || is_category() ) { 1318 $link = get_term_link( $queried_object ); 1319 } elseif ( is_singular() ) { 1320 $link = get_permalink( $queried_object ); 1321 } elseif ( is_search() ) { 1322 $link = home_url( 'search/' . urlencode( get_query_var( 's' ) ) . '/' ); 1323 } elseif ( is_front_page() ) { 1324 $link = home_url( '/' ); 1325 } 1326 1327 1328 if ( $link && is_paged() ) { 1329 if ( false !== stripos( $link, '?' ) ) { 1330 $link = add_query_arg( 'paged', (int) get_query_var( 'paged' ), $link ); 1331 } else { 1332 $link = rtrim( $link, '/' ) . '/page/' . (int) get_query_var( 'paged' ) . '/'; 1333 } 1334 } 1279 // Back-compat: TODO: Used by hreflang links. 1280 $link = \WordPressdotorg\SEO\Canonical\get_canonical_url(); 1335 1281 1336 1282 if ( $path_only && $link ) { … … 1345 1291 return $link; 1346 1292 } 1293 1294 /** 1295 * Filter the WordPress.org SEO plugin Canonical location to respect Theme Directory differences. 1296 */ 1297 function wporg_canonical_url( $url ) { 1298 if ( get_query_var( 'browse' ) && WPORG_THEMES_DEFAULT_BROWSE === get_query_var( 'browse' ) ) { 1299 $url = home_url( '/' ); 1300 } elseif ( get_query_var( 'browse' ) ) { 1301 // The browse/% urls on the Theme directory are front-page-query alterations. 1302 $url = home_url( 'browse/' . get_query_var( 'browse' ) . '/' ); 1303 } 1304 1305 return $url; 1306 } 1307 add_filter( 'wporg_canonical_url', 'wporg_canonical_url' ); 1308 1309 // Theme Directory doesn't support pagination. 1310 add_filter( 'wporg_rel_next_pages', '__return_zero' );
Note: See TracChangeset
for help on using the changeset viewer.