Make WordPress Core


Ignore:
Timestamp:
02/02/2013 03:01:20 AM (12 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.wp-scripts.php

    r23377 r23378  
    112112    }
    113113
     114    // Do not allow accidental or negligent deregistering of critical scripts in the admin. Show minimal remorse if the correct hook is used.
     115    if ( is_admin() && 'admin_enqueue_scripts' !== current_filter() ) {
     116        $no = array(
     117            'jquery', 'jquery-core', 'jquery-migrate', 'jquery-ui-core', 'jquery-ui-accordion',
     118            'jquery-ui-autocomplete', 'jquery-ui-button', 'jquery-ui-datepicker', 'jquery-ui-dialog',
     119            'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-menu', 'jquery-ui-mouse',
     120            'jquery-ui-position', 'jquery-ui-progressbar', 'jquery-ui-resizable', 'jquery-ui-selectable',
     121            'jquery-ui-slider', 'jquery-ui-sortable', 'jquery-ui-spinner', 'jquery-ui-tabs',
     122            'jquery-ui-tooltip', 'jquery-ui-widget',
     123        );
     124
     125        if ( in_array( $handle, $no ) ) {
     126            $message = sprintf( 'Do not deregister the %1$s script in the administration area. To target the frontend theme, use the %2$s hook.',
     127                "<code>$handle</code>", '<code>wp_enqueue_scripts</code>' );
     128            _doing_it_wrong( __FUNCTION__, $message, '3.6' );
     129            return;
     130        }
     131    }
     132
    114133    $wp_scripts->remove( $handle );
    115134}
Note: See TracChangeset for help on using the changeset viewer.