Block Editor: Remove repetitive calls to `file_get_contents()` in block editor settings.
The `get_default_block_editor_settings()` function used to repeatedly get the `default-editor-styles.css` file contents without any implementation to avoid this. This commit utilizes a static variable to remove repetitive calls made during the same request. In tests ran on the front page of a site using Xdebug & Webgrind, the total `file_get_contents()` invocation count goes down from 181 to 93, and total self cost (the time that the function is responsible for) goes down from 160 ms to 93 ms. Follow-up to [52042]. Props aristath, mukesh27. Fixes #56637. Built from https://develop.svn.wordpress.org/trunk@54291 git-svn-id: http://core.svn.wordpress.org/trunk@53850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4d6518c2d5
commit
8cb55f5451
|
@ -192,12 +192,17 @@ function get_default_block_editor_settings() {
|
|||
// These styles are used if the "no theme styles" options is triggered or on
|
||||
// themes without their own editor styles.
|
||||
$default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css';
|
||||
if ( file_exists( $default_editor_styles_file ) ) {
|
||||
$default_editor_styles = array(
|
||||
array( 'css' => file_get_contents( $default_editor_styles_file ) ),
|
||||
);
|
||||
} else {
|
||||
|
||||
static $default_editor_styles_file_contents = false;
|
||||
if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) {
|
||||
$default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file );
|
||||
}
|
||||
|
||||
$default_editor_styles = array();
|
||||
if ( $default_editor_styles_file_contents ) {
|
||||
$default_editor_styles = array(
|
||||
array( 'css' => $default_editor_styles_file_contents ),
|
||||
);
|
||||
}
|
||||
|
||||
$editor_settings = array(
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-beta1-54290';
|
||||
$wp_version = '6.1-beta1-54291';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue