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/readme.txt
+27-8Lines changed: 27 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -92,9 +92,10 @@ Filters whether the current response can be optimized. By default, detection and
92
92
2. It’s not a post embed template (`is_embed()`).
93
93
3. It’s not the Customizer preview (`is_customize_preview()`)
94
94
4. It’s not the response to a `POST` request.
95
-
5. The user is not an administrator (`current_user_can( 'customize' )`).
95
+
5. The user is not an administrator (`current_user_can( 'customize' )`), unless you're in plugin development mode (`wp_is_development_mode( 'plugin' )`).
96
+
6. There is at least one queried post on the page. This is used to facilitate the purging of page caches after a new URL Metric is stored.
96
97
97
-
During development, you may want to force this to always be enabled:
98
+
To force every response to be optimized regardless of the conditions above, you can do:
Filters the sample size for a breakpoint's URL Metrics on a given URL. The sample size must be greater than zero. During development, it may be helpful to reduce the sample size to 1:
107
+
Filters the sample size for a breakpoint's URL Metrics on a given URL. The sample size must be greater than zero. 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:
107
108
108
109
`
109
110
<?php
@@ -125,30 +126,48 @@ add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
125
126
126
127
**Filter:** `od_url_metric_freshness_ttl` (default: 1 day in seconds)
127
128
128
-
Filters the freshness age (TTL) for a given URL Metric. The freshness TTL must be at least zero, in which it considers URL Metrics to always be stale. In practice, the value should be at least an hour. During development, this can be useful to set to zero:
129
+
Filters the freshness age (TTL) for a given URL Metric. The freshness TTL must be at least zero, in which it considers URL Metrics to always be stale. In practice, the value should be at least an hour. If your site content does not change frequently, you may want to increase the TTL to a week:
add_filter( 'od_url_metric_freshness_ttl', static function (): int {
134
+
return WEEK_IN_SECONDS;
135
+
} );
136
+
`
137
+
138
+
During development, this can be useful to set to zero so that you don't have to wait for new URL Metrics to be requested when engineering a new optimization:
139
+
140
+
`
141
+
<?php
142
+
add_filter( 'od_url_metric_freshness_ttl', static function (): int {
Filters the minimum allowed viewport aspect ratio for URL Metrics.
138
150
139
-
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).
151
+
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:
152
+
153
+
`
154
+
<?php
155
+
add_filter( 'od_minimum_viewport_aspect_ratio', static function (): int {
Filters the maximum allowed viewport aspect ratio for URL Metrics.
144
163
145
164
The 2.5 value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 (2.333).
146
165
147
-
During development when you have the DevTools console open, for example, the viewport aspect ratio will be wider than normal. In this case, you may want to increase the maximum aspect ratio:
166
+
During development when you have the DevTools console open on the bottom, for example, the viewport aspect ratio will be larger than normal. In this case, you may want to increase the maximum aspect ratio:
148
167
149
168
`
150
169
<?php
151
-
add_filter( 'od_maximum_viewport_aspect_ratio', function () {
170
+
add_filter( 'od_maximum_viewport_aspect_ratio', static function (): int {
0 commit comments