Make WordPress Core


Ignore:
Timestamp:
02/21/2024 06:48:30 PM (3 months ago)
Author:
joemcgill
Message:

Editor: Load pattern content only when used.

Previously, the content for all registered patterns would get loaded on each request when the patterns are registered. Instead, this stores the path the pattern file during registration and reads the content the first time the pattern is used, which is a performance optimization.

Props thekt12, spacedmonkey, gziolo, aristath, joemcgill.
Fixes #59532.

File:
1 edited

Legend:

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

    r57353 r57683  
    392392            }
    393393
    394             // The actual pattern content is the output of the file.
    395             ob_start();
    396             include $file_path;
    397             $pattern_data['content'] = ob_get_clean();
    398             if ( ! $pattern_data['content'] ) {
    399                 continue;
    400             }
     394            $pattern_data['file_path'] = $file_path;
    401395
    402396            // Translate the pattern metadata.
Note: See TracChangeset for help on using the changeset viewer.