WordPress.org

Making WordPress.org

Changeset 9864


Ignore:
Timestamp:
05/13/2020 05:04:11 AM (8 weeks ago)
Author:
dd32
Message:

Theme Directory: Remove specific SEO fixes that are included in the generic SEO fixes plugin.

See #5173.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r9819 r9864  
    11241124    // If it's outdated, noindex the theme.
    11251125    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' );
    11271127    }
    11281128}
     
    12741274
    12751275/**
    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 /**
    13031276 * Get the current front-end requested URL.
    13041277 */
    13051278function 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();
    13351281
    13361282    if ( $path_only && $link ) {
     
    13451291    return $link;
    13461292}
     1293
     1294/**
     1295 * Filter the WordPress.org SEO plugin Canonical location to respect Theme Directory differences.
     1296 */
     1297function 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}
     1307add_filter( 'wporg_canonical_url', 'wporg_canonical_url' );
     1308
     1309// Theme Directory doesn't support pagination.
     1310add_filter( 'wporg_rel_next_pages', '__return_zero' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php

    r9818 r9864  
    286286
    287287/**
    288  * Outputs `noindex,follow` robots tag for search results and author archives.
    289  */
    290 function wporg_themes_noindex() {
    291     if ( is_search() || is_author() ) {
    292         wp_no_robots();
    293     }
    294 }
    295 add_action( 'wp_head', 'wporg_themes_noindex' );
    296 
    297 /**
    298288 * Overrides feeds to use a custom RSS2 feed which contains the current requests themes.
    299289 */
     
    309299    die();
    310300}
    311 add_filter( 'template_redirect', 'wporg_themes_custom_feed' );
     301add_filter( 'template_redirect', 'wporg_themes_custom_feed', 9999 );
    312302
    313303/**
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/page-upload.php

    r9725 r9864  
    99
    1010// Search engines don't need to index the upload form. Should help prevent users uploading themes they didn't create.
    11 if ( ! function_exists( 'wporg_meta_robots' ) ) {
    12     function wporg_meta_robots() {
    13         return 'noindex';
    14     }
    15 }
     11add_filter( 'wporg_noindex_request', '__return_true' );
    1612
    1713// Use the translated post title.
Note: See TracChangeset for help on using the changeset viewer.