Opened 3 years ago
Last modified 7 weeks ago
#54721 reopened defect (bug)
wptexturize caches the result of run_wptexturize preventing themes from using this if a plugin has already called get_plugin_data
Reported by: | tremlas | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8.2 |
Component: | Formatting | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description
One of the plugins I use is simple_sitemap. This plugin (quite reasonably) uses get_plugin_data during its initialization. get_plugin_data makes calls to wptexturize as part of its operation. The plugin's initialization runs before the theme's functions.php is executed. Since wptexturize caches the result of the run_wptexturize filter, the theme is no longer able to disable wptexturize's function and hence gets unwanted smart quotes.
There is a workaround for the theme whereby it makes a dummy call to wptexturize with reset set to true. This makes the wptexturize implementation reinitialize and hence re-execute the call to the run_wptexturize filter. However the documentation states that this flag is designed for unit testing and hence this seems to be less than ideal.
(In passing I'll note that this caching of the result also prevents plugins from using it to temporarily disable the function by adding and then removing the filter should it be required.)
I've left the ticket type as 'defect' but it would be reasonable to argue that this is actually a request for a minor enhancement - if so please change the type field.
I've found a scenario where the reset logic doesn't work.
If
wptexturize()
has already been run and therun_texturize
filter had been set to__return_false
by an activated plugin then it's not possible to use the
$reset
parameter since the following code is executed before anything else.This problem happens to occur in my own PHPUnit tests where I tried to re-enable wptexturize's processing using:
... which is ironic.
Also, the comment
isn't completely true.
It's run when $reset is true and $run_texturize is true.