Opened 9 years ago
Closed 9 years ago
#32380 closed defect (bug) (invalid)
WPTexturize doesn't handle locale switching properly
Reported by: | ivanblagdan | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | wptexturize |
Focuses: | Cc: |
Description
Had some issues with wptexturize() not applying french style quotes on a locale which had them defined via a .po file. The locale was defined in the options for the site on a multisite install.
The issue was tracked down to a plugin firing get_plugin_data(), which in turn fires wptexturize() when parsing out the description from the plugin header comment block. Since wptexturize() stores replacements in the static space and expects them to be populated on the first run, these get baked in with when _x() fired with the default locale. This is the case with most static replacements there, we had a problem with the quotes.
I'm attaching a patch that gives wptexturize a chance to reset itself if the locale changed.
There's also a test in the patch, which simulates the locale change behaviour since otherwise it would require some actual .po localization files to test this.
Attachments (2)
Change History (9)
#3
@
9 years ago
Calling get_locale()
for every instance of wptexturize()
is probably not optimal. If get_locale()
is the only function that modifies the global variable, then we could just call wptexturize('reset', true)
from there.
#4
@
9 years ago
It's also possible that the plugin is just hooking some functions to the wrong actions.
#5
@
9 years ago
You are kind of right on the it being used in a wrong place. Like I said, the plugin was using get_plugin_data() which triggers wp_texturize(). The plugin causing the issue is Crayon, https://wordpress.org/plugins/crayon-syntax-highlighter/, the call in question is in wp_crayon.class.php, line 39. Its basically in global scope, and I'd agree its wrong. I'd argue that its viable though and there should be some safeguard for it.
#7
@
9 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
- Version 4.2.2 deleted
Forwarded to the plugin author at https://wordpress.org/support/topic/plugin-conflicts-with-multisite-translation
Test and Fix for wptexturize not handling locale switching properly.