]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/functions.wp-scripts.php
Wordpress 3.6-scripts
[autoinstalls/wordpress.git] / wp-includes / functions.wp-scripts.php
index 49b760f04ae80b3cc8155fb65b63cee753fc8bca..32778ab5a215fa46eefdc52e494b11a366d76ed7 100644 (file)
@@ -27,7 +27,7 @@ function wp_print_scripts( $handles = false ) {
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
 
                if ( !$handles )
                        return array(); // No need to instantiate if nothing is there.
@@ -54,7 +54,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
                $wp_scripts = new WP_Scripts();
        }
 
@@ -66,7 +66,7 @@ function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_f
 /**
  * Wrapper for $wp_scripts->localize().
  *
- * Used to localizes a script.
+ * Used to localize a script.
  * Works only if the script has already been added.
  * Accepts an associative array $l10n and creates JS object:
  * "$object_name" = {
@@ -88,7 +88,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
 
                return false;
        }
@@ -107,10 +107,30 @@ function wp_deregister_script( $handle ) {
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
                $wp_scripts = new WP_Scripts();
        }
 
+       // Do not allow accidental or negligent deregistering of critical scripts in the admin. Show minimal remorse if the correct hook is used.
+       if ( is_admin() && 'admin_enqueue_scripts' !== current_filter() ) {
+               $no = array(
+                       'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion',
+                       'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog',
+                       'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse',
+                       'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable',
+                       'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs',
+                       'jquery-ui-tooltip', 'jquery-ui-widget',
+                       'underscore', 'backbone',
+               );
+
+               if ( in_array( $handle, $no ) ) {
+                       $message = sprintf( __( 'Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.' ),
+                               "<code>$handle</code>", '<code>wp_enqueue_scripts</code>' );
+                       _doing_it_wrong( __FUNCTION__, $message, '3.6' );
+                       return;
+               }
+       }
+
        $wp_scripts->remove( $handle );
 }
 
@@ -127,7 +147,7 @@ function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
                $wp_scripts = new WP_Scripts();
        }
 
@@ -151,7 +171,7 @@ function wp_dequeue_script( $handle ) {
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
                $wp_scripts = new WP_Scripts();
        }
 
@@ -177,7 +197,7 @@ function wp_script_is( $handle, $list = 'enqueued' ) {
        if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
                if ( ! did_action( 'init' ) )
                        _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
-                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
+                               '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
                $wp_scripts = new WP_Scripts();
        }