Skip to content

Commit 22e4f55

Browse files
committed
WP/EnqueuedResourceParameters: fix some inaccuracies and typos in code comments
1 parent a9c5c8f commit 22e4f55

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
use WordPressCS\WordPress\AbstractFunctionParameterSniff;
1616

1717
/**
18-
* This checks the enqueued 4th and 5th parameters to make sure the version and in_footer are set.
18+
* This checks that the 4th ($ver) parameter is set for all enqueued resources and that the 5th ($in_footer) parameter
19+
* is set for wp_register_script() and wp_enqueue_script().
1920
*
2021
* If a source ($src) value is passed, then version ($ver) needs to have non-falsy value.
21-
* If a source ($src) value is passed a check for in footer ($in_footer), warn the user if the value is falsy.
22+
* If a source ($src) value is passed, then it is recommended to explicitly set the $in_footer parameter.
2223
*
2324
* @link https://developer.wordpress.org/reference/functions/wp_register_script/
2425
* @link https://developer.wordpress.org/reference/functions/wp_enqueue_script/
@@ -66,7 +67,7 @@ final class EnqueuedResourceParametersSniff extends AbstractFunctionParameterSni
6667
/**
6768
* Token codes which are "safe" to accept to determine whether a version would evaluate to `false`.
6869
*
69-
* This array is enriched with the several of the PHPCS token arrays in the register() method.
70+
* This array is enriched with several of the PHPCS token arrays in the register() method.
7071
*
7172
* @var array<int|string, int|string>
7273
*/
@@ -88,7 +89,8 @@ final class EnqueuedResourceParametersSniff extends AbstractFunctionParameterSni
8889
/**
8990
* Returns an array of tokens this test wants to listen for.
9091
*
91-
* Overloads and calls the parent method to allow for adding additional tokens to the $safe_tokens property.
92+
* Overloads and calls the parent method to allow for adding additional tokens to the
93+
* $false_tokens and $safe_tokens properties.
9294
*
9395
* @return array
9496
*/
@@ -165,8 +167,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
165167
/*
166168
* In footer Check
167169
*
168-
* Check to make sure that $in_footer is set to true.
169-
* It will warn the user to make sure it is intended.
170+
* Check to make sure that $in_footer is explicitly set.
171+
* Warn the user if it is not set.
170172
*
171173
* Only wp_register_script and wp_enqueue_script need this check,
172174
* as this parameter is not available to wp_register_style and wp_enqueue_style.

WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.1.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array
2929
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), function() { }, true ); // OK.
3030
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), $version, true ); // OK.
3131

32-
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0' ); // Warning - In Footer is set to a falsy (default) value.
32+
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0' ); // Warning - $in_footer is not explicitly set.
3333
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0', false ); // OK.
3434
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0', null ); // OK.
3535
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0', 0 ); // OK.

0 commit comments

Comments
 (0)