Making WordPress.org

Changeset 6658


Ignore:
Timestamp:
02/16/2018 06:55:40 AM (6 years ago)
Author:
obenland
Message:

Main: Serve stats script from CDN.

See #3046.

File:
1 edited

Legend:

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

    r6656 r6658  
    8989
    9090/**
     91 * Filters an enqueued script's fully-qualified URL.
     92 *
     93 * @param string $src    The source URL of the enqueued script.
     94 * @param string $handle The script's registered handle.
     95 * @return string
     96 */
     97function script_src( $src, $handle ) {
     98    $cdn_handles = [
     99        'wporg-page-stats',
     100    ];
     101
     102    // Use CDN url.
     103    if ( in_array( $handle, $cdn_handles, true ) ) {
     104        $src = str_replace( get_home_url(), 'https://s.w.org', $src );
     105    }
     106
     107    return $src;
     108}
     109add_filter( 'script_loader_src', __NAMESPACE__ . '\script_src', 10, 2 );
     110
     111/**
    91112 * Extend the default WordPress body classes.
    92113 *
Note: See TracChangeset for help on using the changeset viewer.