Skip to content

Commit 7f3e44d

Browse files
committed
Merge branch 'trunk' into feature/1511-incorporate-layout-constraints-from-ancestors
2 parents 6e9f892 + 291e1b2 commit 7f3e44d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+574
-196
lines changed

.github/workflows/php-test-plugins.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
fi
8888
- name: Upload single site coverage reports to Codecov
8989
if: ${{ matrix.coverage == true }}
90-
uses: codecov/codecov-action@v4
90+
uses: codecov/codecov-action@v5
9191
with:
9292
token: ${{ secrets.CODECOV_TOKEN }}
9393
files: coverage-${{ github.sha }}.xml
@@ -96,7 +96,7 @@ jobs:
9696
fail_ci_if_error: true
9797
- name: Upload multisite coverage reports to Codecov
9898
if: ${{ matrix.coverage == true }}
99-
uses: codecov/codecov-action@v4
99+
uses: codecov/codecov-action@v5
100100
with:
101101
token: ${{ secrets.CODECOV_TOKEN }}
102102
files: coverage-multisite-${{ github.sha }}.xml

composer.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 16 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
},
1313
"devDependencies": {
1414
"@octokit/rest": "^21.0.2",
15-
"@wordpress/env": "^10.11.0",
16-
"@wordpress/prettier-config": "^4.11.0",
17-
"@wordpress/scripts": "^30.4.0",
15+
"@wordpress/env": "^10.12.0",
16+
"@wordpress/prettier-config": "^4.12.0",
17+
"@wordpress/scripts": "^30.5.1",
1818
"commander": "12.1.0",
1919
"copy-webpack-plugin": "^12.0.2",
2020
"fast-glob": "^3.3.2",
2121
"fs-extra": "^11.2.0",
22-
"husky": "^9.1.6",
22+
"husky": "^9.1.7",
2323
"lint-staged": "^15.2.10",
2424
"lodash": "4.17.21",
2525
"micromatch": "^4.0.8",

plugins/embed-optimizer/class-embed-optimizer-tag-visitor.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ private function is_embed_wrapper( OD_HTML_Tag_Processor $processor ): bool {
8181
* Otherwise, if the embed is not in any initial viewport, it will add lazy-loading logic.
8282
*
8383
* @since 0.2.0
84+
* @since n.e.x.t Adds preconnect links for each viewport group and skips if the element is not in the viewport for that group.
8485
*
8586
* @param OD_Tag_Visitor_Context $context Tag visitor context.
8687
* @return bool Whether the tag should be tracked in URL Metrics.
@@ -109,7 +110,8 @@ public function __invoke( OD_Tag_Visitor_Context $context ): bool {
109110
&&
110111
$context->url_metric_group_collection->get_last_group()->count() > 0
111112
) {
112-
$max_intersection_ratio = $context->url_metric_group_collection->get_element_max_intersection_ratio( self::get_embed_wrapper_xpath( $processor->get_xpath() ) );
113+
$embed_wrapper_xpath = self::get_embed_wrapper_xpath( $processor->get_xpath() );
114+
$max_intersection_ratio = $context->url_metric_group_collection->get_element_max_intersection_ratio( $embed_wrapper_xpath );
113115
if ( $max_intersection_ratio > 0 ) {
114116
/*
115117
* The following embeds have been chosen for optimization due to their relative popularity among all embed types.
@@ -171,12 +173,20 @@ public function __invoke( OD_Tag_Visitor_Context $context ): bool {
171173
}
172174

173175
foreach ( $preconnect_hrefs as $preconnect_href ) {
174-
$context->link_collection->add_link(
175-
array(
176-
'rel' => 'preconnect',
177-
'href' => $preconnect_href,
178-
)
179-
);
176+
foreach ( $context->url_metric_group_collection as $group ) {
177+
if ( ! ( $group->get_element_max_intersection_ratio( $embed_wrapper_xpath ) > 0.0 ) ) {
178+
continue;
179+
}
180+
181+
$context->link_collection->add_link(
182+
array(
183+
'rel' => 'preconnect',
184+
'href' => $preconnect_href,
185+
),
186+
$group->get_minimum_viewport_width(),
187+
$group->get_maximum_viewport_width()
188+
);
189+
}
180190
}
181191
} elseif ( embed_optimizer_update_markup( $processor, false ) && ! $this->added_lazy_script ) {
182192
$processor->append_body_html( wp_get_inline_script_tag( embed_optimizer_get_lazy_load_script(), array( 'type' => 'module' ) ) );

plugins/embed-optimizer/hooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function embed_optimizer_add_non_optimization_detective_hooks(): void {
4242
* @param string $optimization_detective_version Current version of the optimization detective plugin.
4343
*/
4444
function embed_optimizer_init_optimization_detective( string $optimization_detective_version ): void {
45-
$required_od_version = '0.7.0';
45+
$required_od_version = '0.9.0';
4646
if ( version_compare( (string) strtok( $optimization_detective_version, '-' ), $required_od_version, '<' ) ) {
4747
add_action(
4848
'admin_notices',

plugins/embed-optimizer/readme.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plu
6767

6868
== Changelog ==
6969

70-
= n.e.x.t =
71-
72-
**Enhancements**
73-
74-
* Serve unminified scripts when `SCRIPT_DEBUG` is enabled. ([1643](https://github.com/WordPress/performance/pull/1643))
75-
7670
= 0.3.0 =
7771

7872
**Enhancements**

plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport-without-resized-data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
<head>
3434
<meta charset="utf-8">
3535
<title>...</title>
36-
<link data-od-added-tag rel="preconnect" href="https://syndication.twitter.com">
3736
<link data-od-added-tag rel="preconnect" href="https://pbs.twimg.com">
37+
<link data-od-added-tag rel="preconnect" href="https://syndication.twitter.com">
3838
</head>
3939
<body>
4040
<figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter">

plugins/embed-optimizer/tests/test-cases/single-twitter-embed-inside-viewport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
@media (min-width: 601px) and (max-width: 782px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
4040
@media (min-width: 783px) { #embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8 { min-height: 500px; } }
4141
</style>
42-
<link data-od-added-tag rel="preconnect" href="https://syndication.twitter.com">
4342
<link data-od-added-tag rel="preconnect" href="https://pbs.twimg.com">
43+
<link data-od-added-tag rel="preconnect" href="https://syndication.twitter.com">
4444
</head>
4545
<body>
4646
<figure data-od-added-id id="embed-optimizer-a7659db28ecaa36ddee6ae66857dabd8" class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter">

0 commit comments

Comments
 (0)