Make WordPress Core


Ignore:
Timestamp:
09/12/2023 07:18:34 PM (3 weeks ago)
Author:
flixos90
Message:

Posts, Post Types: Avoid unnecessarily parsing blocks twice in wp_trim_excerpt().

All blocks relevant for the excerpt are already being parsed in excerpt_remove_blocks(). Therefore running do_blocks() on the post content only to create the excerpt is unnecessary and wasteful from a performance perspective.

Props thekt12, spacedmonkey, mukesh27, joemcgill.
Fixes #58682.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r56559 r56560  
    957957 */
    958958function excerpt_remove_blocks( $content ) {
     959    if ( ! has_blocks( $content ) ) {
     960        return $content;
     961    }
     962
    959963    $allowed_inner_blocks = array(
    960964        // Classic blocks have their blockName set to null.
Note: See TracChangeset for help on using the changeset viewer.