Skip to content

Commit 6da3ddc

Browse files
committed
Remove development mode for all except od_can_optimize_response()
1 parent 7a82f95 commit 6da3ddc

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

plugins/optimization-detective/readme.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ add_filter( 'od_can_optimize_response', '__return_true' );
104104

105105
**Filter:** `od_url_metrics_breakpoint_sample_size` (default: 3)
106106

107-
Filters the sample size for a breakpoint's URL Metrics on a given URL. The sample size must be greater than zero. In plugin development mode, the default is 1. You can increase the sample size if you want better guarantees that the applied optimizations will be accurate:
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:
108108

109109
`
110110
<?php
111111
add_filter( 'od_url_metrics_breakpoint_sample_size', function (): int {
112-
return 10;
112+
return 1;
113113
} );
114114
`
115115

@@ -126,7 +126,7 @@ add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
126126

127127
**Filter:** `od_url_metric_freshness_ttl` (default: 1 day in seconds)
128128

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. In plugin development mode, this is set to zero by default. If your site content does not change frequently, you may want to increase the TTL to a week:
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:
130130

131131
`
132132
<?php
@@ -135,17 +135,33 @@ add_filter( 'od_url_metric_freshness_ttl', static function (): int {
135135
} );
136136
`
137137

138+
During development, this can be useful to set to zero:
139+
140+
`
141+
<?php
142+
add_filter( 'od_url_metric_freshness_ttl', static function (): int {
143+
return 0;
144+
} );
145+
`
146+
138147
**Filter:** `od_minimum_viewport_aspect_ratio` (default: 0.4)
139148

140149
Filters the minimum allowed viewport aspect ratio for URL Metrics.
141150

142-
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). When in plugin development mode, the default value is 0; this is to account for Dev Tools likely being open.
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 you may want to set this to 0 to account Dev Tools likely being open and docked to the right:
152+
153+
`
154+
<?php
155+
add_filter( 'od_minimum_viewport_aspect_ratio', static function (): int {
156+
return 0;
157+
} );
158+
`
143159

144160
**Filter:** `od_maximum_viewport_aspect_ratio` (default: 2.5)
145161

146162
Filters the maximum allowed viewport aspect ratio for URL Metrics.
147163

148-
The 2.5 value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 (2.333). When in plugin development mode, the default value is PHP_INT_MAX; this is to account for Dev Tools likely being open.
164+
The 2.5 value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 (2.333).
149165

150166
During development when you have the DevTools console open on the bottom, for example, the viewport aspect ratio larger than normal. In this case, you may want to increase the maximum aspect ratio:
151167

plugins/optimization-detective/storage/class-od-storage-lock.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ final class OD_Storage_Lock {
2323
* Gets the TTL (in seconds) for the URL Metric storage lock.
2424
*
2525
* @since 0.1.0
26-
* @since n.e.x.t The TTL is zero when in 'plugin' development mode.
2726
* @access private
2827
*
2928
* @return int TTL in seconds, greater than or equal to zero. A value of zero means that the storage lock should be disabled and thus that transients must not be used.
@@ -44,7 +43,7 @@ public static function get_ttl(): int {
4443
*
4544
* @param int $ttl TTL.
4645
*/
47-
$ttl = (int) apply_filters( 'od_url_metric_storage_lock_ttl', wp_is_development_mode( 'plugin' ) ? 0 : MINUTE_IN_SECONDS );
46+
$ttl = (int) apply_filters( 'od_url_metric_storage_lock_ttl', MINUTE_IN_SECONDS );
4847
return max( 0, $ttl );
4948
}
5049

plugins/optimization-detective/storage/data.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* When a URL Metric expires it is eligible to be replaced by a newer one if its viewport lies within the same breakpoint.
1717
*
1818
* @since 0.1.0
19-
* @since n.e.x.t The freshness TTL is set to zero when in 'plugin' development mode.
2019
* @access private
2120
*
2221
* @return int Expiration TTL in seconds.
@@ -32,7 +31,7 @@ function od_get_url_metric_freshness_ttl(): int {
3231
*
3332
* @param int $ttl Expiration TTL in seconds. Defaults to 1 day.
3433
*/
35-
$freshness_ttl = (int) apply_filters( 'od_url_metric_freshness_ttl', wp_is_development_mode( 'plugin' ) ? 0 : DAY_IN_SECONDS );
34+
$freshness_ttl = (int) apply_filters( 'od_url_metric_freshness_ttl', DAY_IN_SECONDS );
3635

3736
if ( $freshness_ttl < 0 ) {
3837
_doing_it_wrong(
@@ -186,7 +185,6 @@ function od_verify_url_metrics_storage_hmac( string $hmac, string $slug, string
186185
* Gets the minimum allowed viewport aspect ratio for URL Metrics.
187186
*
188187
* @since 0.6.0
189-
* @since n.e.x.t The default of 0 is used when in plugin development mode.
190188
* @access private
191189
*
192190
* @return float Minimum viewport aspect ratio for URL Metrics.
@@ -195,22 +193,20 @@ function od_get_minimum_viewport_aspect_ratio(): float {
195193
/**
196194
* Filters the minimum allowed viewport aspect ratio for URL Metrics.
197195
*
198-
* The 0.4 default value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 when
199-
* rotated 90 degrees to 9:21 (0.429). When in plugin development mode, the default value is 0; this is to account
200-
* for Dev Tools likely being open.
196+
* The 0.4 default value is intended to accommodate the phone with the greatest known aspect
197+
* ratio at 21:9 when rotated 90 degrees to 9:21 (0.429).
201198
*
202199
* @since 0.6.0
203200
*
204201
* @param float $minimum_viewport_aspect_ratio Minimum viewport aspect ratio.
205202
*/
206-
return (float) apply_filters( 'od_minimum_viewport_aspect_ratio', wp_is_development_mode( 'plugin' ) ? 0 : 0.4 );
203+
return (float) apply_filters( 'od_minimum_viewport_aspect_ratio', 0.4 );
207204
}
208205

209206
/**
210207
* Gets the maximum allowed viewport aspect ratio for URL Metrics.
211208
*
212209
* @since 0.6.0
213-
* @since n.e.x.t The default of PHP_INT_MAX is used when in plugin development mode.
214210
* @access private
215211
*
216212
* @return float Maximum viewport aspect ratio for URL Metrics.
@@ -219,14 +215,14 @@ function od_get_maximum_viewport_aspect_ratio(): float {
219215
/**
220216
* Filters the maximum allowed viewport aspect ratio for URL Metrics.
221217
*
222-
* The 2.5 default value is intended to accommodate the phone with the greatest known aspect ratio at 21:9 (2.333).
223-
* When in plugin development mode, the default value is PHP_INT_MAX; this is to account for Dev Tools likely being open.
218+
* The 2.5 default value is intended to accommodate the phone with the greatest known aspect
219+
* ratio at 21:9 (2.333).
224220
*
225221
* @since 0.6.0
226222
*
227223
* @param float $maximum_viewport_aspect_ratio Maximum viewport aspect ratio.
228224
*/
229-
return (float) apply_filters( 'od_maximum_viewport_aspect_ratio', wp_is_development_mode( 'plugin' ) ? PHP_INT_MAX : 2.5 );
225+
return (float) apply_filters( 'od_maximum_viewport_aspect_ratio', 2.5 );
230226
}
231227

232228
/**
@@ -319,7 +315,6 @@ static function ( $original_breakpoint ) use ( $function_name ): int {
319315
* total of 6 URL Metrics stored for a given URL: 3 for mobile and 3 for desktop.
320316
*
321317
* @since 0.1.0
322-
* @since n.e.x.t The sample size is set to 1 when in 'plugin' development mode.
323318
* @access private
324319
*
325320
* @return int Sample size.
@@ -334,7 +329,7 @@ function od_get_url_metrics_breakpoint_sample_size(): int {
334329
*
335330
* @param int $sample_size Sample size. Defaults to 3.
336331
*/
337-
$sample_size = (int) apply_filters( 'od_url_metrics_breakpoint_sample_size', wp_is_development_mode( 'plugin' ) ? 1 : 3 );
332+
$sample_size = (int) apply_filters( 'od_url_metrics_breakpoint_sample_size', 3 );
338333

339334
if ( $sample_size <= 0 ) {
340335
_doing_it_wrong(

0 commit comments

Comments
 (0)