Making WordPress.org

Changeset 6656


Ignore:
Timestamp:
02/16/2018 05:39:59 AM (7 years ago)
Author:
obenland
Message:

Main: Load stats script only when needed.

See [6654].

File:
1 edited

Legend:

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

    r6654 r6656  
    7373 */
    7474function scripts() {
    75     wp_enqueue_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', [], null, true );
    76     wp_enqueue_script( 'wporg-page-stats', get_theme_file_uri( '/js/page-stats.js' ), [ 'jquery', 'google-charts'], 1, true );
    77     wp_localize_script( 'wporg-page-stats', 'wporgPageStats', [
    78         'trunk'         => number_format( WP_CORE_STABLE_BRANCH + 0.1, 1 ), /* trunk */
    79         'beta'          => number_format( WP_CORE_STABLE_BRANCH + 0.2, 1 ), /* trunk w/ beta-tester plugin */
    80         'wpVersions'    => ___( 'WordPress Version', 'wporg' ),
    81         'phpVersions'   => ___( 'PHP Versions', 'wporg' ),
    82         'mysqlVersions' => ___( 'MySQL Version', 'wporg' ),
    83         'locales'       => ___( 'Locales', 'wporg' ),
    84     ] );
     75    if ( is_page( 'stats' ) ) {
     76        wp_enqueue_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', [], null, true );
     77        wp_enqueue_script( 'wporg-page-stats', get_theme_file_uri( '/js/page-stats.js' ), [ 'jquery', 'google-charts'], 1, true );
     78        wp_localize_script( 'wporg-page-stats', 'wporgPageStats', [
     79            'trunk'         => number_format( WP_CORE_STABLE_BRANCH + 0.1, 1 ), /* trunk */
     80            'beta'          => number_format( WP_CORE_STABLE_BRANCH + 0.2, 1 ), /* trunk w/ beta-tester plugin */
     81            'wpVersions'    => ___( 'WordPress Version', 'wporg' ),
     82            'phpVersions'   => ___( 'PHP Versions', 'wporg' ),
     83            'mysqlVersions' => ___( 'MySQL Version', 'wporg' ),
     84            'locales'       => ___( 'Locales', 'wporg' ),
     85        ] );
     86    }
    8587}
    8688add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\scripts' );
Note: See TracChangeset for help on using the changeset viewer.