Making WordPress.org

Changeset 9868


Ignore:
Timestamp:
05/13/2020 05:15:32 AM (4 years ago)
Author:
dd32
Message:

Remove the Facebook/twitter canonical redirect as it's included in the SEO fixes plugin, rename this so it's more obvious as it's purpose.

See #5173.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/wporg-redirects.php

    r9867 r9868  
    11<?php
    2 
    3 /**
    4  * Custom Canonical redirect for Facebook and Twitter referrers.
    5  */
    6 add_action( 'template_redirect', function() {
    7 
    8     // Only run on pages with canonical enabled.
    9     if ( ! has_action( 'template_redirect', 'redirect_canonical' ) ) {
    10         return;
    11     }
    12 
    13     $url = false;
    14     if ( isset( $_GET['fbclid'] ) ) {
    15         $url = remove_query_arg( 'fbclid' ) . '#utm_medium=referral&utm_source=facebook.com&utm_content=social';
    16     } elseif ( isset( $_GET['__twitter_impression'] ) ) {
    17         $url = remove_query_arg( '__twitter_impression' ) . '#utm_medium=referral&utm_source=twitter.com&utm_content=social';
    18     }
    19 
    20     if ( $url ) {
    21         wp_safe_redirect( $url, 301 );
    22         exit;
    23     }
    24 
    25 }, 9 ); // Before redirect_canonical();
    262
    273/*
Note: See TracChangeset for help on using the changeset viewer.