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

WordPress Trac noreply at wordpress.org
Wed Jul 19 21:01:09 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):

 It is worth noting that even in core, the `wp_filter_content_tags()`
 function is only called before `do_shortcode()` in 2 places:
 * on `the_content` filter
 * on `widget_text_content` filter
 * on `widget_block_content` filter

 For block templates, `wp_filter_content_tags()` is already called after
 `do_shortcode()`, and for block template parts, `do_shortcode()` is not
 called at all.

 Based on that, I am proposing the following fix for this ticket:
 * Change the hook priority of `wp_filter_content_tags` to a higher value
 (>=12) on the `the_content`, `widget_text_content`, and
 `widget_block_content` filters.
 * Remove the workaround added in [56214].
 * Instead, add `do_shortcode` to the list of contexts in
 `wp_get_loading_optimization_attributes()` where the clause returns early
 if `doing_filter( 'the_content' )`.

 This will ensure that tags from shortcodes will be processed together with
 the other content, in the same way.

 cc @joemcgill @spacedmonkey

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


More information about the wp-trac mailing list