X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-includes/functions.wp-scripts.php
diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php
index 49b760f0..32778ab5 100644
--- a/wp-includes/functions.wp-scripts.php
+++ b/wp-includes/functions.wp-scripts.php
@@ -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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
+ "$handle
", 'wp_enqueue_scripts
' );
+ _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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '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.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'login_enqueue_scripts
' ), '3.3' );
$wp_scripts = new WP_Scripts();
}