Skip to content

Commit 3a6df16

Browse files
Polish hooks.md: punctuation fix, logic simplification, type hints
Co-authored-by: Weston Ruter <[email protected]>
1 parent 3675666 commit 3a6df16

File tree

1 file changed

+3
-3
lines changed
  • plugins/optimization-detective/docs

1 file changed

+3
-3
lines changed

plugins/optimization-detective/docs/hooks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Filters whether the current response can be optimized. By default, detection and
199199
1. It’s not a search template (`is_search()`).
200200
2. It’s not a post embed template (`is_embed()`).
201201
3. It’s not a preview (`is_preview()`).
202-
4. It’s not the Customizer preview (`is_customize_preview()`);
202+
4. It’s not the Customizer preview (`is_customize_preview()`).
203203
5. It’s not the response to a `POST` request.
204204
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.
205205

@@ -208,8 +208,8 @@ The filter now receives an additional `$disabled_flags` parameter that contains
208208
For example, to enable optimization specifically for search pages:
209209

210210
```php
211-
add_filter( 'od_can_optimize_response', function( $can_optimize, $disabled_flags ) {
212-
if ( ! $can_optimize && isset( $disabled_flags['is_search'] ) && $disabled_flags['is_search'] ) {
211+
add_filter( 'od_can_optimize_response', function( $can_optimize, array $disabled_flags ): bool {
212+
if ( ! $can_optimize && $disabled_flags['is_search'] ) {
213213
unset( $disabled_flags['is_search'] );
214214
$can_optimize = count( array_filter( $disabled_flags ) ) === 0;
215215
}

0 commit comments

Comments
 (0)