Skip to content

Commit 804d8ac

Browse files
committed
Fix grammar, improve clarity, and standardize phrasing in docs and code.
This addresses issues detected by PhpStorm.
1 parent 3fda75f commit 804d8ac

File tree

5 files changed

+26
-24
lines changed

5 files changed

+26
-24
lines changed

plugins/optimization-detective/docs/hooks.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Fires when the Optimization Detective is initializing.
1010

1111
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 short circuit.
12+
of the plugin is passed as the sole argument so that if the required version is not present, the callback can short-circuit.
1313

1414
Example:
1515

@@ -115,7 +115,7 @@ It is important to note that this action fires _after_ the entire template has b
115115
other words, it will fire after the `wp_footer` action.
116116

117117
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 currently stored URL Metrics for tag visitors to later leverage.
119119
See [example](https://github.com/WordPress/performance/pull/1921) from the Image Prioritizer plugin where it can be used
120120
to determine what the common external LCP background-image is for each viewport group up front so that this doesn't have
121121
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
187187
Filters the breakpoint max widths to group URL Metrics for various viewports.
188188

189189
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.
191191
A breakpoint must be greater than zero or else a usage warning will occur.
192192

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.
194194

195195
### Filter: `od_can_optimize_response` (default: boolean condition, see below)
196196

@@ -217,16 +217,16 @@ add_filter( 'od_can_optimize_response', function( $can_optimize, array $disabled
217217
}, 10, 2 );
218218
```
219219

220-
Note that some conditions cannot be overridden by this filter. Even if the filter returns `true`, optimization will still be disabled when:
220+
Note that this filter cannot override some conditions. Even if the filter returns `true`, optimization will still be disabled when:
221221

222222
1. The REST API for storing URL Metrics is not available.
223-
2. The URL has the `optimization_detective_disabled` query parameter.
223+
2. The URL has the `optimization_detective_disabled` query parameter.
224224

225225
### Filter: `od_url_metrics_breakpoint_sample_size` (default: 3)
226226

227227
Filters the sample size for a breakpoint's URL Metrics on a given URL.
228228

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.
230230

231231
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:
232232

@@ -240,7 +240,7 @@ add_filter( 'od_url_metrics_breakpoint_sample_size', function (): int {
240240

241241
Filters how long the current IP is locked from submitting another URL metric storage REST API request.
242242

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 logged in with code like the following:
244244

245245
```php
246246
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 {
250250

251251
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.
252252

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:
254254

255255
```php
256256
add_filter( 'od_metrics_storage_lock_ttl', function ( int $ttl ): int {
@@ -288,7 +288,7 @@ add_filter( 'od_url_metric_freshness_ttl', '__return_zero' );
288288

289289
Filters the minimum allowed viewport aspect ratio for URL Metrics.
290290

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:
292292

293293
```php
294294
add_filter( 'od_minimum_viewport_aspect_ratio', static function (): int {
@@ -312,13 +312,15 @@ add_filter( 'od_maximum_viewport_aspect_ratio', static function (): int {
312312

313313
### Filter: `od_template_output_buffer` (default: the HTML response)
314314

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.
316318

317319
### Filter: `od_url_metric_schema_element_item_additional_properties` (default: empty array)
318320

319321
Filters additional schema properties which should be allowed for an element's item in a URL Metric.
320322

321-
For example to add a `resizedBoundingClientRect` property:
323+
For example, to add a `resizedBoundingClientRect` property:
322324

323325
```php
324326
<?php
@@ -410,7 +412,7 @@ add_filter( 'od_url_metric_garbage_collection_ttl', '__return_zero' );
410412

411413
Filters the maximum allowed size in bytes for a URL Metric serialized to JSON.
412414

413-
The filtered value must be greater than zero; otherwise it will be ignored and a usage warning will result.
415+
The filtered value must be greater than zero; otherwise it will be ignored, and a usage warning will result.
414416

415417
### Filter: `od_gzip_url_metric_store_request_payloads` (default: `true` if the `gzdecode()` function exists)
416418

plugins/optimization-detective/helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function od_get_disabled_reasons(): array {
176176
}
177177

178178
/**
179-
* Displays the HTML generator meta tag for the Optimization Detective plugin.
179+
* Displays the HTML generator META tag for the Optimization Detective plugin.
180180
*
181181
* See {@see 'wp_head'}.
182182
*
@@ -203,7 +203,7 @@ function od_render_generator_meta_tag(): void {
203203
* @since 0.9.0
204204
* @access private
205205
*
206-
* @param string $src_path Source path, relative to plugin root.
206+
* @param string $src_path Source path, relative to the plugin root.
207207
* @param string|null $min_path Minified path. If not supplied, then '.min' is injected before the file extension in the source path.
208208
* @return string URL to script or stylesheet.
209209
*

plugins/optimization-detective/optimization.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* This is to implement #43258 in core.
1919
*
20-
* This is a hack which would eventually be replaced with something like this in wp-includes/template-loader.php:
20+
* This is a hack that would eventually be replaced with something like this in wp-includes/template-loader.php:
2121
*
2222
* $template = apply_filters( 'template_include', $template );
2323
* + ob_start( 'wp_template_output_buffer_callback' );
@@ -40,7 +40,7 @@ function od_buffer_output( $passthrough ) {
4040
* response as an HTML document, this would result in broken HTML processing.
4141
*
4242
* If this ends up being problematic, then PHP_OUTPUT_HANDLER_FLUSHABLE could be added to the $flags and the
43-
* output buffer callback could check if the phase is PHP_OUTPUT_HANDLER_FLUSH and abort any subsequent
43+
* output buffer callback could check if the phase is PHP_OUTPUT_HANDLER_FLUSH and abort any later
4444
* processing while also emitting a _doing_it_wrong().
4545
*
4646
* The output buffer needs to be removable because WordPress calls wp_ob_end_flush_all() and then calls
@@ -52,13 +52,13 @@ function od_buffer_output( $passthrough ) {
5252

5353
ob_start(
5454
static function ( string $output, ?int $phase ): string {
55-
// When the output is being cleaned (e.g. pending template is replaced with error page), do not send it through the filter.
55+
// When the output is being cleaned (e.g. the pending template is replaced with an error page), do not send it through the filter.
5656
if ( ( $phase & PHP_OUTPUT_HANDLER_CLEAN ) !== 0 ) {
5757
return $output;
5858
}
5959

6060
/**
61-
* Filters the template output buffer prior to sending to the client.
61+
* Filters the template output buffer before sending it to the client.
6262
*
6363
* @since 0.1.0
6464
* @link https://github.com/WordPress/performance/blob/trunk/plugins/optimization-detective/docs/hooks.md#:~:text=Filter%3A%20od_template_output_buffer

plugins/optimization-detective/tests/test-helper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function test_od_generate_media_query( ?int $min_width, ?int $max_width,
8484
}
8585

8686
/**
87-
* Test printing the meta generator tag.
87+
* Test printing the META generator tag.
8888
*
8989
* @covers ::od_render_generator_meta_tag
9090
*/
@@ -98,7 +98,7 @@ public function test_od_render_generator_meta_tag(): void {
9898
}
9999

100100
/**
101-
* Test meta generator tag when query parameter is present.
101+
* Test META generator tag when query parameter is present.
102102
*
103103
* @covers ::od_render_generator_meta_tag
104104
* @covers ::od_get_disabled_reasons
@@ -111,7 +111,7 @@ public function test_od_render_generator_meta_tag_query_param_disabled(): void {
111111
}
112112

113113
/**
114-
* Test printing the meta generator tag when the REST API is not available.
114+
* Test printing the META generator tag when the REST API is not available.
115115
*
116116
* @covers ::od_render_generator_meta_tag
117117
* @covers ::od_get_disabled_reasons

plugins/optimization-detective/tests/test-optimization.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function test_od_buffer_output(): void {
5050
$original = 'Hello World!';
5151
$expected = '¡Hola Mundo!';
5252

53-
// In order to test, a wrapping output buffer is required because ob_get_clean() does not invoke the output
53+
// To test, a wrapping output buffer is required because ob_get_clean() does not invoke the output
5454
// buffer callback. See <https://stackoverflow.com/a/61439514/93579>.
5555
ob_start();
5656

@@ -88,7 +88,7 @@ public function test_od_buffer_with_cleaning_and_attempted_flushing(): void {
8888
$template_middle = ', the middle';
8989
$template_end = ', and the end!';
9090

91-
// In order to test, a wrapping output buffer is required because ob_get_clean() does not invoke the output
91+
// To test, a wrapping output buffer is required because ob_get_clean() does not invoke the output
9292
// buffer callback. See <https://stackoverflow.com/a/61439514/93579>.
9393
$initial_level = ob_get_level();
9494
$this->assertTrue( ob_start() );

0 commit comments

Comments
 (0)