You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plugins/optimization-detective/docs/hooks.md
+15-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
Fires when the Optimization Detective is initializing.
10
10
11
11
This action is useful for loading extension code that depends on Optimization Detective to be running. The version
12
-
of the plugin is passed as the sole argument so that if the required version is not present, the callback can shortcircuit.
12
+
of the plugin is passed as the sole argument so that if the required version is not present, the callback can short-circuit.
13
13
14
14
Example:
15
15
@@ -115,7 +115,7 @@ It is important to note that this action fires _after_ the entire template has b
115
115
other words, it will fire after the `wp_footer` action.
116
116
117
117
This action runs before any of the registered tag visitors have been invoked in the current response. It is useful for
118
-
an extension to gather the required information from the currently-stored URL Metrics for tag visitors to later leverage.
118
+
an extension to gather the required information from the currentlystored URL Metrics for tag visitors to later leverage.
119
119
See [example](https://github.com/WordPress/performance/pull/1921) from the Image Prioritizer plugin where it can be used
120
120
to determine what the common external LCP background-image is for each viewport group up front so that this doesn't have
121
121
to be computed when a tag visitor is invoked.
@@ -187,10 +187,10 @@ The additional attribution data is made available to client-side extension scrip
187
187
Filters the breakpoint max widths to group URL Metrics for various viewports.
188
188
189
189
Each number represents the maximum width (inclusive) for a given breakpoint. So if there is one number, 480, then this means there will be two viewport groupings, one for 0\<=480, and another \>480. If instead there are the two breakpoints defined, 480 and 782, then this means there will be three viewport groups of URL Metrics, one for 0\<=480 (i.e. mobile), another 481\<=782 (i.e. phablet/tablet), and another \>782 (i.e. desktop).
190
-
This array may be empty in which case there are no responsive breakpoints and all URL Metrics are collected in a single group.
190
+
This array may be empty, in which case there are no responsive breakpoints, and all URL Metrics are collected in a single group.
191
191
A breakpoint must be greater than zero or else a usage warning will occur.
192
192
193
-
These default breakpoints are reused from Gutenberg which appear to be used the most in media queries that affect frontend styles.
193
+
These default breakpoints are reused from Gutenberg, which appear to be used the most in media queries that affect frontend styles.
194
194
195
195
### Filter: `od_can_optimize_response` (default: boolean condition, see below)
Filters the sample size for a breakpoint's URL Metrics on a given URL.
228
228
229
-
The filtered value must be greater than zero; otherwise it will be ignored and a usage warning will result.
229
+
The filtered value must be greater than zero; otherwise it will be ignored, and a usage warning will result.
230
230
231
231
You can increase the sample size if you want better guarantees that the applied optimizations will be accurate. During development, it may be helpful to reduce the sample size to 1 (along with setting the `od_url_metric_storage_lock_ttl` and `od_url_metric_freshness_ttl` filters below) so that you don't have to keep reloading the page to collect new URL Metrics to flush out stale ones during active development:
232
232
@@ -240,7 +240,7 @@ add_filter( 'od_url_metrics_breakpoint_sample_size', function (): int {
240
240
241
241
Filters how long the current IP is locked from submitting another URL metric storage REST API request.
242
242
243
-
Filtering the TTL to zero will disable any URL Metric storage locking. This is useful, for example, to disable locking when a user is logged-in with code like the following:
243
+
Filtering the TTL to zero will disable any URL Metric storage locking. This is useful, for example, to disable locking when a user is loggedin with code like the following:
244
244
245
245
```php
246
246
add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
@@ -250,7 +250,7 @@ add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
250
250
251
251
By default, the TTL is zero (0) for authorized users and sixty (60) for everyone else. Whether the current user is authorized is determined by whether the user has the `od_store_url_metric_now` capability. This custom capability by default maps to the `manage_options` primitive capability via the `user_has_cap` filter.
252
252
253
-
During development this is useful to set to zero so you can quickly collect new URL Metrics by reloading the page without having to wait for the storage lock to release:
253
+
During development this is useful to set to zero, so you can quickly collect new URL Metrics by reloading the page without having to wait for the storage lock to release:
254
254
255
255
```php
256
256
add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
Filters the minimum allowed viewport aspect ratio for URL Metrics.
290
290
291
-
The 0.4 value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 when rotated 90 degrees to 9:21 (0.429). During development when you have the DevTools console open on the right, the viewport aspect ratio will be smaller than normal. In this case, you may want to set this to 0:
291
+
The 0.4 value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 when rotated 90 degrees to 9:21 (0.429). During development, when you have the DevTools console open on the right, the viewport aspect ratio will be smaller than normal. In this case, you may want to set this to 0:
292
292
293
293
```php
294
294
add_filter( 'od_minimum_viewport_aspect_ratio', static function (): int {
@@ -312,13 +312,15 @@ add_filter( 'od_maximum_viewport_aspect_ratio', static function (): int {
312
312
313
313
### Filter: `od_template_output_buffer` (default: the HTML response)
314
314
315
-
Filters the template output buffer prior to sending to the client. This filter is added to implement [\#43258](https://core.trac.wordpress.org/ticket/43258) in WordPress core.
315
+
Filters the template output buffer before sending it to the client.
316
+
317
+
This filter is added to implement [\#43258](https://core.trac.wordpress.org/ticket/43258) in WordPress core.
0 commit comments