Plugin Directory

Changeset 697833

Timestamp:
04/15/2013 01:45:08 PM (11 years ago)
Author:
jblz
Message:

Jetpack: Notes Module: Clean up script enqueues and use core versions of underscore and backbone on wpcom as fallbacks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/modules/notes.php

    r697154 r697833  
    129129
    130130        // attempt to use core or plugin libraries if registered
    131         if ( wp_script_is( 'mustache', 'registered' ) ) {
    132             if ( !wp_script_is( 'mustache', 'queue' ) ) {
    133                 wp_enqueue_script( 'mustache' );
    134             }
     131        if ( !wp_script_is( 'mustache', 'registered' ) ) {
     132            wp_register_script( 'mustache', $this->wpcom_static_url( '/wp-content/js/mustache.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
    135133        }
    136         else {
    137             wp_enqueue_script( 'mustache', $this->wpcom_static_url( '/wp-content/js/mustache.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
     134        if ( !wp_script_is( 'underscore', 'registered' ) ) {
     135            wp_register_script( 'underscore', $this->wpcom_static_url( '/wp-includes/js/underscore.min.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
     136        }
     137        if ( !wp_script_is( 'backbone', 'registered' ) ) {
     138            wp_register_script( 'backbone', $this->wpcom_static_url( '/wp-includes/js/backbone.min.js' ), array( 'underscore' ), JETPACK_NOTES__CACHE_BUSTER );
    138139        }
    139140
    140         if ( wp_script_is( 'underscore', 'registered' ) ) {
    141             if ( !wp_script_is( 'underscore', 'queue' ) ) {
    142                 wp_enqueue_script( 'underscore' );
    143             }
    144         }
    145         else {
    146             wp_enqueue_script( 'underscore', $this->wpcom_static_url( '/wp-content/js/underscore.js' ), null, JETPACK_NOTES__CACHE_BUSTER );
    147         }
    148         if ( wp_script_is( 'backbone', 'registered' ) ) {
    149             if ( !wp_script_is( 'backbone', 'queue' ) ) {
    150                 wp_enqueue_script( 'backbone' );
    151             }
    152         }
    153         else {
    154             wp_enqueue_script( 'backbone', $this->wpcom_static_url( '/wp-content/js/backbone.js' ), array( 'jquery', 'underscore' ), JETPACK_NOTES__CACHE_BUSTER );
    155         }
    156 
    157         wp_enqueue_script( 'notes-rest-common', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/notes-rest-common.js' ), array( 'backbone', 'mustache', 'jquery.spin' ), JETPACK_NOTES__CACHE_BUSTER );
    158         wp_enqueue_script( 'notes-admin-bar-rest', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/admin-bar-rest.js' ), array( 'jquery', 'underscore', 'backbone', 'jquery.spin' ), JETPACK_NOTES__CACHE_BUSTER );
     141        wp_register_script( 'notes-rest-common', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/notes-rest-common.js' ), array( 'jquery', 'underscore', 'backbone', 'mustache', 'jquery.spin' ), JETPACK_NOTES__CACHE_BUSTER );
     142        wp_enqueue_script( 'notes-admin-bar-rest', $this->wpcom_static_url( '/wp-content/mu-plugins/notes/admin-bar-rest.js' ), array( 'notes-rest-common' ), JETPACK_NOTES__CACHE_BUSTER );
    159143    }
    160144
Note: See TracChangeset for help on using the changeset viewer.