Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d5bf984
Add all disabled reasons to Optimization Detective meta generator tag
ShyamGadde Apr 9, 2025
2a65043
Fix function documentation wording
ShyamGadde Apr 9, 2025
10161e5
Merge branch 'trunk' into update/od-meta-generator-tag
ShyamGadde Apr 9, 2025
74a7607
Add test coverage annotation for od_get_disabled_reasons helper function
ShyamGadde Apr 9, 2025
c0214cf
Add tests for meta generator tag with different disabled reasons
ShyamGadde Apr 9, 2025
bae1198
Enhance meta generator tag to include all nested reasons for Optimiza…
ShyamGadde Apr 10, 2025
9c097f6
Reintroduce od_can_optimize_response as a wrapper for od_get_cannot_o…
ShyamGadde Apr 10, 2025
9467eea
Consolidate all disabled reason checks into od_get_disabled_reasons f…
ShyamGadde Apr 10, 2025
57969e1
Add test for is_embed
ShyamGadde Apr 10, 2025
28264af
Enhance od_can_optimize_response filter with disabled_flags parameter
ShyamGadde Apr 14, 2025
291f732
Merge branch 'trunk' into update/od-meta-generator-tag
ShyamGadde Apr 17, 2025
0bfde54
Merge branch 'trunk' into update/od-meta-generator-tag
ShyamGadde Apr 21, 2025
673ddf4
Improve comments for clarity on disabled conditions
ShyamGadde Apr 21, 2025
62009d1
Improve comments for clarity on disabled condition for customizer pre…
ShyamGadde Apr 21, 2025
471b1e2
Use wp_array_slice_assoc to simplify reason extraction
ShyamGadde Apr 21, 2025
9171d30
Improve function documentation with explicit array shapes
ShyamGadde Apr 21, 2025
9b5ef72
Update hooks documentation for od_can_optimize_response filter
ShyamGadde Apr 21, 2025
3675666
Merge branch 'trunk' into update/od-meta-generator-tag
ShyamGadde Apr 24, 2025
3a6df16
Polish hooks.md: punctuation fix, logic simplification, type hints
ShyamGadde Apr 24, 2025
c51fc54
Add support for dynamic view transition names for global elements, an…
felixarntz Apr 30, 2025
3d7681e
Merge branch 'trunk' into enhance/view-transition-names-support
felixarntz Apr 30, 2025
b6a7d94
Fix incorrect readme.txt stable tag.
felixarntz May 1, 2025
8545b4f
Add type declarations for view transitions JS code.
felixarntz May 1, 2025
3ca288e
Fix TypeScript errors by explicitly annotating parameter type.
felixarntz May 1, 2025
ec2904e
Skip confusing ESLint errors in View Transitions JS for now.
felixarntz May 1, 2025
eaf9060
Fix window handling in TypeScript.
felixarntz May 1, 2025
fab65d7
Fix PHPUnit test error.
felixarntz May 1, 2025
78f24ec
Fix missing defined ESLint types instead of disabling rule.
felixarntz May 5, 2025
a843357
Use win and doc aliases
westonruter May 5, 2025
b970e29
Merge branch 'trunk' into enhance/view-transition-names-support
felixarntz May 6, 2025
cba9665
Merge pull request #1999 from WordPress/enhance/view-transition-names…
felixarntz May 7, 2025
ca4a1c7
Remove duplicated word in comment
westonruter May 7, 2025
f065ce6
Remove unnecessary string casting
westonruter May 7, 2025
2f24014
Add test case for od_can_optimize_response filter and disabled_flags
westonruter May 7, 2025
afaf3ce
Add test assertions for od_get_disabled_reasons
westonruter May 7, 2025
3fda75f
Use non_get_request instead of not_get_request
westonruter May 7, 2025
804d8ac
Fix grammar, improve clarity, and standardize phrasing in docs and code.
westonruter May 7, 2025
8a4987d
Merge pull request #1979 from ShyamGadde/update/od-meta-generator-tag
westonruter May 8, 2025
562361f
Fix typos and clarify grammar in documentation and comments
westonruter May 8, 2025
ec4941d
Merge pull request #2005 from WordPress/improve/od-static-issues
westonruter May 8, 2025
4279a01
Merge pull request #2001 from WordPress/add/win-aliases
westonruter May 8, 2025
6d08640
Bump @wordpress/prettier-config from 4.22.0 to 4.23.0
dependabot[bot] May 12, 2025
0fafe77
Bump squizlabs/php_codesniffer from 3.12.2 to 3.13.0
dependabot[bot] May 12, 2025
aee7308
Merge pull request #2008 from WordPress/dependabot/npm_and_yarn/wordp…
westonruter May 13, 2025
6d61b6f
Merge pull request #2011 from WordPress/dependabot/composer/squizlabs…
westonruter May 13, 2025
4e470ac
Bump @wordpress/scripts from 30.15.0 to 30.16.0
dependabot[bot] May 13, 2025
a9f0958
Merge pull request #2009 from WordPress/dependabot/npm_and_yarn/wordp…
mukeshpanchal27 May 13, 2025
901d7a2
Bump @wordpress/env from 10.22.0 to 10.23.0
dependabot[bot] May 13, 2025
d1d72ed
Merge pull request #2007 from WordPress/dependabot/npm_and_yarn/wordp…
mukeshpanchal27 May 13, 2025
2f07c38
Merge branch 'trunk' into fix/conflict
mukeshpanchal27 May 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ const config = {
'/dist',
'/**/*.min.js',
],
overrides: [
...( wpConfig?.overrides || [] ),
{
files: [ 'plugins/view-transitions/js/**/*.js' ],
rules: {
'jsdoc/no-undefined-types': [
'error',
{ definedTypes: [ 'PageSwapEvent', 'PageRevealEvent' ] },
],
},
},
],
};

module.exports = config;
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

400 changes: 204 additions & 196 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"@octokit/rest": "^21.1.1",
"@playwright/test": "^1.51.1",
"@wordpress/e2e-test-utils-playwright": "^1.21.0",
"@wordpress/env": "^10.22.0",
"@wordpress/prettier-config": "^4.20.0",
"@wordpress/scripts": "^30.15.0",
"@wordpress/env": "^10.23.0",
"@wordpress/prettier-config": "^4.23.0",
"@wordpress/scripts": "^30.16.0",
"commander": "13.1.0",
"copy-webpack-plugin": "^13.0.0",
"css-minimizer-webpack-plugin": "^7.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Representation of the measurements taken from a single client's visit to a specific URL without additionalProperties allowed.
*
* This is used exclusively in the REST API endpoint for capturing new URL Metrics to prevent invalid additional data from being
* submitted in the request. For URL Metrics which have been stored the looser OD_URL_Metric class is used instead.
* submitted in the request. For URL Metrics which have been stored, the looser OD_URL_Metric class is used instead.
*
* @phpstan-import-type JSONSchema from OD_URL_Metric
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function __get( string $name ) {
throw new Error(
esc_html(
sprintf(
/* translators: %s is class member variable name */
/* translators: %s is the class member variable name */
__( 'Unknown property %s.', 'optimization-detective' ),
__CLASS__ . '::$' . $name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function __get( string $name ) {
throw new Error(
esc_html(
sprintf(
/* translators: %s is class member variable name */
/* translators: %s is the class member variable name */
__( 'Unknown property %s.', 'optimization-detective' ),
__CLASS__ . '::$' . $name
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class OD_URL_Metric_Group_Collection implements Countable, IteratorAggrega
* value of 1, and the breakpoints are used as the maximum viewport widths for the viewport groups, with the addition of
* a final viewport group which has a maximum viewport width of infinity.
*
* This array may be empty in which case there are no responsive breakpoints and all URL Metrics are collected in a
* This array may be empty, in which case there are no responsive breakpoints, and all URL Metrics are collected in a
* single group.
*
* @since 0.1.0
Expand Down Expand Up @@ -153,7 +153,7 @@ public function __construct( array $url_metrics, string $current_etag, array $br
*/
$this->breakpoints = $breakpoints;

// Set sample size.
// Set the sample size.
if ( $sample_size <= 0 ) {
throw new InvalidArgumentException(
esc_html(
Expand Down Expand Up @@ -211,7 +211,7 @@ public function get_sample_size(): int {
}

/**
* Gets the freshness age (TTL) for a given URL Metric..
* Gets the freshness age (TTL) for a given URL Metric.
*
* @since 1.0.0
*
Expand All @@ -224,7 +224,7 @@ public function get_freshness_ttl(): int {
/**
* Gets the first URL Metric group (with the lowest minimum viewport width, e.g. for mobile).
*
* This group normally represents viewports for mobile devices. This group always has a minimum viewport width of 0
* This group normally represents viewports for mobile devices. This group always has a minimum viewport width of 0,
* and the maximum viewport width corresponds to the smallest defined breakpoint returned by
* {@see od_get_breakpoint_max_widths()}.
*
Expand All @@ -241,7 +241,7 @@ public function get_first_group(): OD_URL_Metric_Group {
*
* This group normally represents viewports for desktop devices. This group always has a minimum viewport width
* defined as one greater than the largest breakpoint returned by {@see od_get_breakpoint_max_widths()}.
* The maximum viewport width of this group is always `null`, or in other words it is unbounded.
* The maximum viewport width of this group is always `null`, or in other words, it is unbounded.
*
* @since 0.7.0
*
Expand Down Expand Up @@ -404,7 +404,7 @@ public function is_every_group_populated(): bool {
/**
* Checks whether every group is complete (full sample of non-stale URL Metrics).
*
* Completeness means the full sample size of URL Metrics has been collected,
* Completeness means the full sample size of URL Metrics has been collected;
* none of the collected URL Metrics are stale (with a mismatching ETag or a
* timestamp older than the freshness TTL).
*
Expand Down Expand Up @@ -520,9 +520,9 @@ public function get_common_lcp_element(): ?OD_Element {
/**
* Gets all elements from all URL Metrics from all groups keyed by the elements' XPaths.
*
* This is an O(n^3) function so its results must be cached. This being said, the number of groups should be 4 (one
* more than the default number of breakpoints) and the number of URL Metrics for each group should be 3
* (the default sample size). Therefore, given the number (n) of visited elements on the page this will only
* This is an O(n^3) function, so its results must be cached. This being said, the number of groups should be 4 (one
* more than the default number of breakpoints), and the number of URL Metrics for each group should be 3
* (the default sample size). Therefore, given the number (n) of visited elements on the page, this will only
* end up running n*4*3 times.
*
* @since 0.7.0
Expand Down Expand Up @@ -584,8 +584,8 @@ public function get_all_element_max_intersection_ratios(): array {
*
* An element is positioned in the initial viewport if its `boundingClientRect.top` is less than the
* `viewport.height` for any of its recorded URL Metrics. Note that even though the element may be positioned in the
* initial viewport, it may not actually be visible. It could be occluded as a latter slide in a carousel in which
* case it will have intersectionRatio of 0. Or the element may not be visible due to it or an ancestor having the
* initial viewport, it may not actually be visible. It could be occluded as a latter slide in a carousel, in which
* case it will have an intersectionRatio of 0. Or the element may not be visible due to it or an ancestor having the
* `visibility:hidden` style, such as in the case of a dropdown navigation menu. When, for example, an IMG element
* is positioned in any initial viewport, it should not get `loading=lazy` but rather `fetchpriority=low`.
* Furthermore, the element may be positioned _above_ the initial viewport or to the left or right of the viewport,
Expand Down Expand Up @@ -624,7 +624,7 @@ public function get_all_elements_positioned_in_any_initial_viewport(): array {
* @since 0.3.0
*
* @param string $xpath XPath for the element.
* @return float|null Max intersection ratio of null if tag is unknown (not captured).
* @return float|null Max intersection ratio or null if the tag is unknown (not captured).
*/
public function get_element_max_intersection_ratio( string $xpath ): ?float {
return $this->get_all_element_max_intersection_ratios()[ $xpath ] ?? null;
Expand All @@ -636,7 +636,7 @@ public function get_element_max_intersection_ratio( string $xpath ): ?float {
* @since 0.7.0
*
* @param string $xpath XPath for the element.
* @return bool|null Whether element is positioned in any initial viewport of null if unknown.
* @return bool|null Whether an element is positioned in any initial viewport or null if unknown.
*/
public function is_element_positioned_in_any_initial_viewport( string $xpath ): ?bool {
return $this->get_all_elements_positioned_in_any_initial_viewport()[ $xpath ] ?? null;
Expand All @@ -651,8 +651,8 @@ public function is_element_positioned_in_any_initial_viewport( string $xpath ):
*/
public function get_flattened_url_metrics(): array {
// The duplication of iterator_to_array is not a mistake. This collection is an
// iterator and the collection contains iterator instances. So to flatten the
// two levels of iterators we need to nest calls to iterator_to_array().
// iterator, and the collection contains iterator instances. So to flatten the
// two levels of iterators, we need to nest calls to iterator_to_array().
return array_merge(
...array_map(
'iterator_to_array',
Expand Down
10 changes: 5 additions & 5 deletions plugins/optimization-detective/class-od-url-metric-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static function ( OD_URL_Metric $a, OD_URL_Metric $b ): int {
/**
* Determines whether the URL Metric group is complete.
*
* A group is complete if it has the full sample size of URL Metrics
* A group is complete if it has the full sample size of URL Metrics,
* and all of these URL Metrics are fresh (with a current ETag and a
* timestamp that is not older than the freshness TTL).
*
Expand Down Expand Up @@ -322,15 +322,15 @@ public function get_lcp_element(): ?OD_Element {

$result = ( function () {

// No metrics have been gathered for this group so there is no LCP element.
// No metrics have been gathered for this group, so there is no LCP element.
if ( count( $this->url_metrics ) === 0 ) {
return null;
}

// The following arrays all share array indices.

/**
* Seen breadcrumbs counts.
* Seen breadcrumb counts.
*
* @var array<int, non-empty-string> $seen_breadcrumbs
*/
Expand All @@ -350,7 +350,7 @@ public function get_lcp_element(): ?OD_Element {
*/
$breadcrumb_element = array();

// Prefer to use URL Metrics which have a current ETag.
// Prefer to use URL Metrics, which have a current ETag.
$url_metrics = array_filter(
$this->url_metrics,
function ( OD_URL_Metric $url_metric ): bool {
Expand Down Expand Up @@ -459,7 +459,7 @@ public function get_all_element_max_intersection_ratios(): array {
* @since 0.9.0
*
* @param string $xpath XPath for the element.
* @return float|null Max intersection ratio of null if tag is unknown (not captured).
* @return float|null Max intersection ratio or null if the tag is unknown (not captured).
*/
public function get_element_max_intersection_ratio( string $xpath ): ?float {
return $this->get_all_element_max_intersection_ratios()[ $xpath ] ?? null;
Expand Down
8 changes: 4 additions & 4 deletions plugins/optimization-detective/class-od-url-metric.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static function get_json_schema(): array {
)
);

// The spec allows these to be negative but this doesn't make sense in the context of intersectionRect and boundingClientRect.
// The spec allows these to be negative, but this doesn't make sense in the context of intersectionRect and boundingClientRect.
$dom_rect_properties['width']['minimum'] = 0.0;
$dom_rect_properties['height']['minimum'] = 0.0;

Expand Down Expand Up @@ -312,9 +312,9 @@ public static function get_json_schema(): array {
),
),
// Additional root properties may be added to the schema via the od_url_metric_schema_root_additional_properties filter.
// Therefore, additionalProperties is set to true so that additional properties defined in the extended schema may persist
// Therefore, `additionalProperties` is set to true so that additional properties defined in the extended schema may persist
// in a stored URL Metric even when the extension is deactivated. For REST API requests, the OD_Strict_URL_Metric
// which sets this to false so that newly-submitted URL Metrics only ever include the known properties.
// which sets this to false so that newly submitted URL Metrics only ever include the known properties.
'additionalProperties' => true,
);

Expand Down Expand Up @@ -364,7 +364,7 @@ public static function get_json_schema(): array {
protected static function extend_schema_with_optional_properties( array $properties_schema, array $additional_properties, string $filter_name ): array {
$doing_it_wrong = static function ( string $message ) use ( $filter_name ): void {
_doing_it_wrong(
esc_html( "Filter: '{$filter_name}'" ),
esc_html( "Filter: '$filter_name'" ),
esc_html( $message ),
'Optimization Detective 0.6.0'
);
Expand Down
2 changes: 2 additions & 0 deletions plugins/optimization-detective/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @package optimization-detective
*
* @since 1.0.0
*
* @noinspection PhpUnused
*/

// @codeCoverageIgnoreStart
Expand Down
Loading
Loading