Making WordPress.org

Changeset 12674


Ignore:
Timestamp:
06/22/2023 03:40:17 AM (2 years ago)
Author:
dd32
Message:

Main Theme: Remove the hreflang pages from rosetta news pages and any custom rosetta pages that wouldn't exist elsewhere.

Fixes #7084.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/functions.php

    r11448 r12674  
    171171 */
    172172function body_class( $classes ) {
    173     if ( is_page() ) {
     173    if ( is_page() && get_queried_object() ) {
    174174        $page = get_queried_object();
    175175
     
    292292
    293293/**
     294 * Disables hreflang tags on instances of this theme, unless it's a page that has localised variants.
     295 *
     296 * This takes the reverse approach of the function name.
     297 * Instead of maybe removing it, it removes it unless a specific criteria is met.
     298 *
     299 * The criteria is that...
     300 *  - It's a page
     301 *  - It's not the hosting page
     302 *  - It's not a rosetta page owned by anyone other than wordpressdotorg (These are the globally synced pages).
     303 */
     304function maybe_remove_hreflang_tags() {
     305    if (
     306        ! is_page() ||
     307        is_page( 'hosting' ) ||
     308        // Exclude custom localised pages.
     309        // Only include posts authored by `wordPressdotorg` which are using a page template.
     310        (
     311            defined( 'IS_ROSETTA_NETWORK' ) && IS_ROSETTA_NETWORK &&
     312            get_user_by( 'slug', 'wordpressdotorg' )->ID != get_post()->post_author
     313        )
     314    ) {
     315        remove_action( 'wp_head', 'WordPressdotorg\Theme\hreflang_link_attributes' );
     316    }
     317}
     318add_action( 'wp_head', __NAMESPACE__ . '\maybe_remove_hreflang_tags', 1 );
     319
     320/**
    294321 * Custom template tags.
    295322 */
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-hosting.php

    r12670 r12674  
    1313    return new \WP_Error();
    1414} );
    15 
    16 // Disable hreflangs, this page has no localised variants.
    17 remove_action( 'wp_head', 'WordPressdotorg\Theme\hreflang_link_attributes' );
    1815
    1916/* See inc/page-meta-descriptions.php for the meta description for this page. */
Note: See TracChangeset for help on using the changeset viewer.