Skip to content

Commit dc609a3

Browse files
committed
Remove unused bookmarks and logic to set them
1 parent 9506133 commit dc609a3

1 file changed

Lines changed: 1 addition & 35 deletions

File tree

src/wp-includes/script-loader.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3737,23 +3737,6 @@ function wp_hoist_late_printed_styles(): void {
37373737
return;
37383738
}
37393739

3740-
// Capture the styles enqueued at the enqueue_block_assets action, so that non-core block styles and global styles can be inserted afterwards during hoisting.
3741-
$style_handles_at_enqueue_block_assets = array();
3742-
add_action(
3743-
'enqueue_block_assets',
3744-
static function () use ( &$style_handles_at_enqueue_block_assets ) {
3745-
$style_handles_at_enqueue_block_assets = wp_styles()->queue;
3746-
},
3747-
PHP_INT_MIN
3748-
);
3749-
add_action(
3750-
'enqueue_block_assets',
3751-
static function () use ( &$style_handles_at_enqueue_block_assets ) {
3752-
$style_handles_at_enqueue_block_assets = array_values( array_diff( wp_styles()->queue, $style_handles_at_enqueue_block_assets ) );
3753-
},
3754-
PHP_INT_MAX
3755-
);
3756-
37573740
/*
37583741
* Add a placeholder comment into the inline styles for wp-block-library, after which the late block styles
37593742
* can be hoisted from the footer to be printed in the header by means of a filter below on the template enhancement
@@ -3864,7 +3847,7 @@ static function () use ( $capture_late_styles ) {
38643847
// Replace placeholder with the captured late styles.
38653848
add_filter(
38663849
'wp_template_enhancement_output_buffer',
3867-
static function ( $buffer ) use ( $placeholder, &$style_handles_at_enqueue_block_assets, &$printed_core_block_styles, &$printed_other_block_styles, &$printed_global_styles, &$printed_late_styles ) {
3850+
static function ( $buffer ) use ( $placeholder, &$printed_core_block_styles, &$printed_other_block_styles, &$printed_global_styles, &$printed_late_styles ) {
38683851

38693852
// Anonymous subclass of WP_HTML_Tag_Processor which exposes underlying bookmark spans.
38703853
$processor = new class( $buffer ) extends WP_HTML_Tag_Processor {
@@ -3943,23 +3926,6 @@ public function replace( string $text ): void {
39433926
} elseif ( 'HEAD' === $processor->get_tag() && $processor->is_tag_closer() ) {
39443927
$processor->set_bookmark( 'head_end' );
39453928
break;
3946-
} elseif ( ( 'STYLE' === $processor->get_tag() || 'LINK' === $processor->get_tag() ) && $processor->get_attribute( 'id' ) ) {
3947-
$id = (string) $processor->get_attribute( 'id' );
3948-
$handle = null;
3949-
if ( 'STYLE' === $processor->get_tag() ) {
3950-
if ( preg_match( '/^(.+)-inline-css$/', $id, $matches ) ) {
3951-
$handle = $matches[1];
3952-
}
3953-
} elseif ( preg_match( '/^(.+)-css$/', $id, $matches ) ) {
3954-
$handle = $matches[1];
3955-
}
3956-
3957-
if ( $handle && in_array( $handle, $style_handles_at_enqueue_block_assets, true ) ) {
3958-
if ( ! $processor->has_bookmark( 'first_style_at_enqueue_block_assets' ) ) {
3959-
$processor->set_bookmark( 'first_style_at_enqueue_block_assets' );
3960-
}
3961-
$processor->set_bookmark( 'last_style_at_enqueue_block_assets' );
3962-
}
39633929
}
39643930
}
39653931

0 commit comments

Comments
 (0)