Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#19568 closed defect (bug) (duplicate)

Call `_doing_it_wrong` when plugin authors try to call `wp_deregister_script` on `jquery` in the Admin UI

Reported by: georgestephanis's profile georgestephanis Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: General Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

Having found a number of sites breaking because plugin (or theme) authors try to swap out jQuery for a Google Hosted version, and either intentionally or negligence leads to them doing it in the Admin UI, let's add in a _doing_it_wrong() call to tell them to please not to.

Attachments (1)

19568.diff (680 bytes) - added by georgestephanis 13 years ago.

Download all attachments as: .zip

Change History (10)

#1 @scribu
13 years ago

  • Keywords reporter-feedback added

What exactly is the problem with using Google's CDN for loading jQuery in the admin and why would it be worse than doing so on the front-end?

#2 @nacin
13 years ago

There's no noConflict call for the external library. And then there's the issue with registering a version that is incompatible with WordPress (or at least different from the one we include).

It's a bad idea. Front-end is not only something we recommend, but plugins like Google Ajax Libraries take great pains to ensure compatibility.

#3 @scribu
13 years ago

  • Keywords 2nd-opinion added; reporter-feedback removed

The same arguments could be made against doing that on the front-end. There's nothing preventing the Google AJAX Library plugin from ensuring compatibility on the back-end as well.

The only thing I can think of is the script compression and concatenation that's only present in the backend.

So, yeah, there's merit to adding this warning. But is it really such a common problem?

#4 @georgestephanis
13 years ago

I just fixed it on a client's site today where a plugin doing that broke the new 3.3 uploader. Over the last year there have been well over a half dozen sites where I've had to manually step in and fix it.

Yes, it happens a lot, and it breaks things a lot.

#5 @scribu
13 years ago

In your patch, you probably meant in_array( 'jquery', (array) $handle ), rather than the other way around.

#6 @georgestephanis
13 years ago

No, actually.

I figured this way, if there were other handles to warn from deregistering, we could just have an array of things they shouldn't deregister -- rather than just being jquery.

Like if you also wanted to add in jquery-ui and jquery-ui-core or something it would just be

in_array( $handle, array( 'jquery', 'jquery-ui', 'jquery-ui-core' ) )

and then the $handle is passed as an arg to sprintf so it will always display the relevant one in the error message.

#7 @georgestephanis
13 years ago

Can you pass an array of handles to wp_deregister_script() ? I always thought it was just a string.

#8 @toscho
13 years ago

  • Cc info@… added

#9 @nacin
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Let's do more than a warning. Outright ban from doing this: #22896.

Note: See TracTickets for help on using tickets.