[wp-trac] [WordPress Trac] #58853: Fix shortcode output not receiving image (and other) optimizations

WordPress Trac noreply at wordpress.org
Wed Jul 19 20:56:21 UTC 2023


#58853: Fix shortcode output not receiving image (and other) optimizations
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:  flixos90
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:  6.4
Component:  Media                                |     Version:  5.5
 Severity:  normal                               |  Resolution:
 Keywords:  2nd-opinion needs-patch needs-unit-  |     Focuses:
  tests                                          |  performance
-------------------------------------------------+-------------------------

Comment (by flixos90):

 I did a search for `wp_filter_content_tags` (function and filter) through
 the plugin directory and put the results in
 [https://docs.google.com/spreadsheets/d/1BiTHxbE3J62DE94zcr9ddXEe68SFvVQkKolgqWYEXDo/edit
 this spreadsheet]. Here's a summary:

 * Out of all plugins with 10,000+ installs, only 28 plugins use
 `wp_filter_content_tags` in any way. I took a closer look at them:
     * 10 plugins call the function on custom content without calling
 `do_shortcode()` on the same content at all. So there is no problem here.
     * 14 plugins call the function on custom content and then call
 `do_shortcode()` on the same content. So effectively they are doing the
 same thing wrong as core. If we reverse the order in core, such plugins
 should be recommended to reverse the order as well, that said there would
 be no backward compatibility implications on them if core made the change.
     * 4 plugins call the function on custom content ''after'' calling
 `do_shortcode()` before. So those plugins are effectively already doing
 the right thing, even though core arguably does not. So there's obviously
 no problem here either.
     * Only a single plugin uses `wp_filter_content_tags` in any way that
 is related to the `the_content` filter, and even that is only a check for
 `has_filter( 'the_content', 'wp_filter_content_tags' )`. In other words,
 even if core changed the hook priority of the filter, that code would
 still work the same as before.
 * In the entire plugin directory, there are zero calls to `remove_filter(
 'the_content', 'wp_filter_content_tags'`.

 Based on this research, I think it is reasonable to change the hook
 priority of `wp_filter_content_tags` on `the_content`, basically to
 anything later than `11`, which is used by `do_shortcode`. We can discuss
 whether we want to use `12` or a much higher number. Even though the
 function has existed since WordPress 5.5, in WordPress that's relatively
 new, and the low usage across plugins confirms that. For example, changing
 the hook priority of `do_shortcode` on `the_content` would ''not'' be
 possible because it's heavily used with the hook priority of `11` in
 plugins (even a short glimpse at the plugins analyzed above confirmed
 that).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/58853#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list