WordPress.org

Plugin Directory

Changeset 627800


Ignore:
Timestamp:
11/20/12 17:34:31 (17 months ago)
Author:
jblz
Message:

Jetpack: Notifications - Attempt to use core or plugin javascript libraries if already registered (Backbone, Underscore, Mustache).

File:
1 edited

Legend:

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

    r621844 r627800  
    7474            return; 
    7575        add_action( 'admin_bar_menu', array( &$this, 'admin_bar_menu'), 120 ); 
    76         add_action( 'wp_head', array( &$this, 'styles_and_scripts') ); 
     76        add_action( 'wp_head', array( &$this, 'styles_and_scripts'), 120 ); 
    7777        add_action( 'admin_head', array( &$this, 'styles_and_scripts') ); 
    7878    } 
     
    8383 
    8484        $this->print_js(); 
     85 
     86        // attempt to use core or plugin libraries if registered 
     87        if ( wp_script_is( 'mustache', 'registered' ) ) { 
     88            if ( !wp_script_is( 'mustache', 'queue' ) ) { 
     89                wp_enqueue_script( 'mustache' ); 
     90            } 
     91        } 
     92        else { 
     93            wp_enqueue_script( 'mustache', $this->wpcom_static_url( '/wp-content/js/mustache.js' ), null, JETPACK_NOTES__CACHE_BUSTER ); 
     94        } 
     95 
     96        if ( wp_script_is( 'underscore', 'registered' ) ) { 
     97            if ( !wp_script_is( 'underscore', 'queue' ) ) { 
     98                wp_enqueue_script( 'underscore' ); 
     99            } 
     100        } 
     101        else { 
     102            wp_enqueue_script( 'underscore', $this->wpcom_static_url( '/wp-content/js/underscore.js' ), null, JETPACK_NOTES__CACHE_BUSTER ); 
     103        } 
     104        if ( wp_script_is( 'backbone', 'registered' ) ) { 
     105            if ( !wp_script_is( 'backbone', 'queue' ) ) { 
     106                wp_enqueue_script( 'backbone' ); 
     107            } 
     108        } 
     109        else { 
     110            wp_enqueue_script( 'backbone', $this->wpcom_static_url( '/wp-content/js/backbone.js' ), array( 'jquery', 'underscore' ), JETPACK_NOTES__CACHE_BUSTER ); 
     111        } 
     112 
    85113        wp_enqueue_script( 'notes-postmessage', $this->wpcom_static_url( '/wp-content/js/postmessage.js' ), array(), JETPACK_NOTES__CACHE_BUSTER ); 
    86         wp_enqueue_script( 'mustache', $this->wpcom_static_url( '/wp-content/js/mustache.js' ), null, JETPACK_NOTES__CACHE_BUSTER ); 
    87         wp_enqueue_script( 'underscore', $this->wpcom_static_url( '/wp-content/js/underscore.js' ), null, JETPACK_NOTES__CACHE_BUSTER ); 
    88         wp_enqueue_script( 'backbone', $this->wpcom_static_url( '/wp-content/js/backbone.js' ), array( 'jquery', 'underscore' ), JETPACK_NOTES__CACHE_BUSTER ); 
    89114        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 ); 
    90115        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 ); 
Note: See TracChangeset for help on using the changeset viewer.