From ca3bfb34f98947171599b80f8ea8e19c0bd5bed3 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 2 Feb 2013 03:01:20 +0000 Subject: [PATCH] Do not allow accidental or negligent deregistering of critical scripts in the admin. (Defined for now as jQuery and jQuery UI.) Show minimal remorse if the correct hook is used. see #22896. git-svn-id: https://develop.svn.wordpress.org/trunk@23378 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.wp-scripts.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index 591f050803..c6b5bbb9c4 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -111,6 +111,25 @@ function wp_deregister_script( $handle ) { $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', + ); + + 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 ); }