[wp-trac] [WordPress Trac] #25294: Changeset 25323 causes AJAX errors in WP Admin
WordPress Trac
noreply at wordpress.org
Thu Sep 12 15:37:08 UTC 2013
#25294: Changeset 25323 causes AJAX errors in WP Admin
-------------------------------+--------------------
Reporter: needle | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.6.2
Component: General | Version: 3.6.1
Severity: major | Resolution:
Keywords: reporter-feedback |
-------------------------------+--------------------
Comment (by nacin):
Here's what's happening:
* Admin in English attaches a filter to the `locale` filter that causes a
call to `wp_get_referer()` whenever `get_locale()` is called. This is
perfectly reasonable and done properly (more on that in a moment). It is
trying to change which locale to load, after all.
* Another plugin (well, probably many plugins) is calling `get_locale()`
too early, probably to immediately load its textdomain. Because a plugin
(in this case, Admin in English) may be filtering `get_locale()` to change
functionality, calling this function before `plugins_loaded` is a bad, bad
idea. If a plugin needs to load their textdomain, they should wait until
*at least* `plugins_loaded`. Ideally, though, you should wait until after
WordPress sets up its own locale (because why not?). The call to
`load_default_textdomain()` and the initialization of `$wp_locale` occurs
after all of this. The next hook that follows it is `after_setup_theme`,
or you can just wait until `init`. (I could go for an `setup_locale` hook,
probably.)
So, two ways to prevent this:
* The only thing a plugin should be doing on inclusion is `add_action()`
and `add_filter()`. Admin in English is doing this. This would have
prevented other plugins from causing problems.
* Even better, the only thing a plugin should be doing on inclusion is
'''one''' `add_action()`, to `plugins_loaded` (or, if they can get away
with it, `init`), and then attach all other hooks then. If Admin in
English were doing this, this also would have been avoided.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25294#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list