WordPress.org

Making WordPress.org

Changeset 6211


Ignore:
Timestamp:
12/03/2017 05:42:32 PM (20 months ago)
Author:
obenland
Message:

WPorg: Opt out of global header styles.

Moves to using the CDN for main theme styles and only loads the dependencies it really needs.

See #2861.

File:
1 edited

Legend:

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

    r6202 r6211  
    5858    ) ) );
    5959
     60    add_theme_support( 'wp4-styles' );
     61
    6062    $GLOBALS['pagetitle'] = __( 'WordPress.org', 'wporg' );
    6163}
     
    7981function scripts() {
    8082    $suffix = is_rtl() ? '-rtl' : '';
    81     wp_enqueue_style( 'wporg-style', get_stylesheet_directory_uri() . "/css/style{$suffix}.css", [], time() );
     83    wp_enqueue_style( 'wporg-style', get_stylesheet_directory_uri() . "/css/style{$suffix}.css", ['dashicons', 'open-sans'], '20171202' );
    8284
    8385    //wp_enqueue_script( 'wporg-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
     
    103105
    104106/**
     107 * Filters an enqueued style's fully-qualified URL.
     108 *
     109 * @param string $src    The source URL of the enqueued style.
     110 * @param string $handle The style's registered handle.
     111 */
     112function style_src( $src, $handle ) {
     113    // Use CDN url.
     114    if ( in_array( $handle, ['wporg-style', 'dashicons'], true ) ) {
     115        $src = str_replace( get_home_url(), 'https://s.w.org', $src );
     116    }
     117
     118    // Remove version argument.
     119    if ( in_array( $handle, ['open-sans'], true ) ) {
     120        $src = remove_query_arg( 'ver', $src );
     121    }
     122
     123    return $src;
     124}
     125add_filter( 'style_loader_src', __NAMESPACE__ . '\style_src', 10, 2 );
     126
     127/**
    105128 * Add postMessage support for site title and description for the Theme Customizer.
    106129 *
Note: See TracChangeset for help on using the changeset viewer.