Commit Graph

40 Commits

Author SHA1 Message Date
Sergey Biryukov
b80ce60f70 Coding Standards: Use pre-increment/decrement for stand-alone statements.
Note: This is enforced by WPCS 3.0.0:

1. There should be no space between an increment/decrement operator and the variable it applies to.
2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:
* [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators]
* [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators]

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56549


git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-09 09:28:26 +00:00
Sergey Biryukov
d8936a9fe7 Coding Standards: Remove superfluous blank lines at the end of various functions.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536], [56547].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56548


git-svn-id: http://core.svn.wordpress.org/trunk@56060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 10:03:21 +00:00
John Blackbourn
ecc08a41f6 Docs: Increase the specificity of types in various inline documentation.
See #54729

Built from https://develop.svn.wordpress.org/trunk@52652


git-svn-id: http://core.svn.wordpress.org/trunk@52241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-30 19:25:03 +00:00
hellofromTonya
a395d4c50e Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in Walker::end_el().
In the parent class, renames the parameter `$object` to `$data_object`.
Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`.

In each child class: renames the parameter to match the parent's method signature.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51780


git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 13:03:55 +00:00
hellofromTonya
7abc752329 Code Modernization: Fix last parameter name mismatches for parent/child classes in Walker::start_el().
The parent class uses `$current_object_id` while most of the child classes use `$id`. As the parent class' is more descriptive, renaming the last parameter in each of child class.

Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- In methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- In cases where the original parameter name was too generic or misleading, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189], [51739].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51779


git-svn-id: http://core.svn.wordpress.org/trunk@51386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-09 12:39:59 +00:00
hellofromTonya
1105ddf965 Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in Walker::start_el().
In the parent class, renames the parameter `$object` to `$data_object`.

Why? `object` is a PHP reserved keyword.

In each child class: renames the corresponding parameter to match the parent's method signature.

Why? 

PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.

Changes for readability:

- `@since` clearly specifies the original parameter name and its new name as well as why the change happened.

- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.

- in cases where the original parameter name was too generic, renamed (when reassigning) to a more descriptive name for use within the method.

Follow-up to [7737], [8900], [8970], [14248], [15077], [16100], [25642], [25644], [37051], [37054], [37056], [46271], [47189].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51739


git-svn-id: http://core.svn.wordpress.org/trunk@51347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-08 15:36:59 +00:00
davidbaumwald
f415fa5ea2 Comments: Remove fourth parameter on remove_filter call.
In `class-walker-comment.php`, a `remove_filter` call on `comment_text` passed a fourth parameter which was not needed.  This change removes the extra argument.

Props diddledan, SergeyBiryukov.
Fixes #53113.
Built from https://develop.svn.wordpress.org/trunk@50816


git-svn-id: http://core.svn.wordpress.org/trunk@50425 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-05 18:54:57 +00:00
John Blackbourn
dd53775247 Comments: Revert the introduction of the opt-in comment approval notification feature.
This reverts the following commits: [50113], [50112], [50109].

See #33717

Built from https://develop.svn.wordpress.org/trunk@50375


git-svn-id: http://core.svn.wordpress.org/trunk@49986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-17 13:08:05 +00:00
John Blackbourn
dad34fe877 Comments: Introduce a method for commenters to opt-in to receiving an email notification when their moderated comment gets approved.
The opt-in form is shown after the comment is submitted and held for moderation.

Sorry this took five years.

Props jeffr0, swissspidy, mrahmadawais, wonderboymusic, jdgrimes, obenland, Monika, imath, garrett-eclipse, johnbillion

Fixes #33717

Built from https://develop.svn.wordpress.org/trunk@50109


git-svn-id: http://core.svn.wordpress.org/trunk@49788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-31 12:50:01 +00:00
Sergey Biryukov
f0ac0275e8 Comments: Further remove unnecessary context switch in Walker_Comment.
Follow-up to [49157].

See #51533.
Built from https://develop.svn.wordpress.org/trunk@49160


git-svn-id: http://core.svn.wordpress.org/trunk@48922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-15 15:26:05 +00:00
Sergey Biryukov
c7d43b7f57 Comments: Remove extra space from the comment link in Walker_Comment.
Props poena, mukesh27, SergeyBiryukov.
See #51533.
Built from https://develop.svn.wordpress.org/trunk@49157


git-svn-id: http://core.svn.wordpress.org/trunk@48919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-15 15:07:09 +00:00
Sergey Biryukov
800f43ebbe Comments: Correct punctuation in "Your comment is awaiting moderation" string in Walker_Comment.
Props llizard.
See #49867.
Built from https://develop.svn.wordpress.org/trunk@48824


git-svn-id: http://core.svn.wordpress.org/trunk@48586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-19 02:27:08 +00:00
Sergey Biryukov
569c006248 Comments: Rename Walker_Comment::comment_text() to ::filter_comment_text() for clarity.
Ensure the comment object is not null before checking its status.

Follow-up to [47887].

See #49956.
Built from https://develop.svn.wordpress.org/trunk@47889


git-svn-id: http://core.svn.wordpress.org/trunk@47663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-02 21:45:10 +00:00
whyisjake
9f86174e08 Comments: Ensure that unmoderated comments won't be search indexed.
After a comment is submitted, only allow a brief window where the comment is live on the site. 

Fixes #49956.
Props: jonkolbert, ayeshrajans, Asif2BD, peterwilsoncc, imath, audrasjb, jonoaldersonwp, whyisjake.

Built from https://develop.svn.wordpress.org/trunk@47887


git-svn-id: http://core.svn.wordpress.org/trunk@47661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-02 20:12:07 +00:00
Sergey Biryukov
7932193708 Coding Standards: Use strict comparison where static strings are involved.
This reduces the number of `WordPress.PHP.StrictComparisons.LooseComparison` issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47808


git-svn-id: http://core.svn.wordpress.org/trunk@47584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 18:42:12 +00:00
Sergey Biryukov
d2a48496d2 Docs: Add missing description for $comment global.
Props immeet94, mukesh27.
Fixes #46928. See #47110.
Built from https://develop.svn.wordpress.org/trunk@46391


git-svn-id: http://core.svn.wordpress.org/trunk@46190 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-04 22:19:57 +00:00
Sergey Biryukov
e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
Sergey Biryukov
16b8d91baa I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.

Includes minor code layout fixes.

Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!

Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926


git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 17:13:59 +00:00
Gary Pendergast
71e3633f3f Comments: Update the message shown when a comment is awaiting moderation.
If the commenter doesn't have cookies set, they won't see the comment preview again. Showing an expanded message will help offset any confusion if they revisit the site later, and their comment is still in moderation, but they can't see it anymore.

Props azaozz, pento.
Fixes #44736.


Built from https://develop.svn.wordpress.org/trunk@44681


git-svn-id: http://core.svn.wordpress.org/trunk@44512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-21 22:46:49 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


Built from https://develop.svn.wordpress.org/trunk@43571


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
John Blackbourn
4a16295dc5 Docs: Standardise the format used for documenting parameters passed by reference.
See #35974, #41017

Built from https://develop.svn.wordpress.org/trunk@41688


git-svn-id: http://core.svn.wordpress.org/trunk@41522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:14:46 +00:00
Drew Jaynes
0860bb2771 Docs: Remove @access notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

Built from https://develop.svn.wordpress.org/trunk@41162


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Sergey Biryukov
eb9cc0c13e I18N: Add translator comments for strings in wp-includes/class-walker-comment.php.
Merge two similar strings.

Props ramiy.
Fixes #37796.
Built from https://develop.svn.wordpress.org/trunk@38342


git-svn-id: http://core.svn.wordpress.org/trunk@38283 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-23 23:33:28 +00:00
Scott Taylor
5efc557eb8 Comments: pass $comment to comment_text() in Walker_Comment::comment() instead of using a function which can skip the cache.
Props rachelbaker.
Fixes #35433.

Built from https://develop.svn.wordpress.org/trunk@37325


git-svn-id: http://core.svn.wordpress.org/trunk@37291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-29 15:47:27 +00:00
Drew Jaynes
0fb5b43307 Docs: Normalize Walker_Comment method parameter docs spacing following [37051].
See #36300.

Built from https://develop.svn.wordpress.org/trunk@37052


git-svn-id: http://core.svn.wordpress.org/trunk@37019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-22 17:46:27 +00:00
Drew Jaynes
69eeedabf9 Docs: Comment display element object types for Walker_Comment are WP_Comment since 4.4.0.
See #36300.

Built from https://develop.svn.wordpress.org/trunk@37051


git-svn-id: http://core.svn.wordpress.org/trunk@37018 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-22 17:44:25 +00:00
Drew Jaynes
7e65fe4f5b Docs: Improve inline documentation syntax for Walker_Comment.
* Marks optional parameters as such
* Improves existing parameter descriptions for clarity
* Syntax improvements

See #36300.

Built from https://develop.svn.wordpress.org/trunk@37050


git-svn-id: http://core.svn.wordpress.org/trunk@37017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-22 17:41:27 +00:00
Drew Jaynes
c4c26e4766 Docs: Standardize the class DocBlock summary for Walker_Comment.
See #36300.

Built from https://develop.svn.wordpress.org/trunk@37049


git-svn-id: http://core.svn.wordpress.org/trunk@37016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-22 17:36:26 +00:00
Drew Jaynes
7b48765674 Docs: Improve inline documentation for properties and methods in Walker_Comment.
Props raimy for the initial patch.
See #36300.

Built from https://develop.svn.wordpress.org/trunk@37048


git-svn-id: http://core.svn.wordpress.org/trunk@37015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-22 17:34:25 +00:00
Drew Jaynes
0fbe903434 Docs: Document the $id parameter for Walker_Comment::start_el(), which is implemented by Walker but unused in the subclass method.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35927


git-svn-id: http://core.svn.wordpress.org/trunk@35891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 17:50:26 +00:00
Scott Taylor
00ade45fd1 Docs: some @global object vernaculars should be converted to the actual object type.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@35013


git-svn-id: http://core.svn.wordpress.org/trunk@34978 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 15:45:25 +00:00
Drew Jaynes
e89737ccfb Docs: Fix wrapping and syntax for a multi-comment in Walker_Comment::display_element().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@34993


git-svn-id: http://core.svn.wordpress.org/trunk@34958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-09 21:03:25 +00:00
Drew Jaynes
e38a6edc61 Docs: Indent an example comment tree in the DocBlock for Walker_Comment::display_element() so it can be properly parsed in Markdown for the Code Reference.
See #32246.

Built from https://develop.svn.wordpress.org/trunk@34992


git-svn-id: http://core.svn.wordpress.org/trunk@34957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-09 21:00:27 +00:00
Drew Jaynes
8df8fb6046 Docs: The Comment API is singular.
See #33701.

Built from https://develop.svn.wordpress.org/trunk@34409


git-svn-id: http://core.svn.wordpress.org/trunk@34373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:43:25 +00:00
Scott Taylor
db4f22bfb5 After [33961], pass $comment to get_comment_link() where possible to avoid extra cache/db lookups.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@34042


git-svn-id: http://core.svn.wordpress.org/trunk@34010 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 06:21:25 +00:00
Scott Taylor
c3f642bea9 After [33961], pass $comment to get_comment_date() where possible to avoid extra cache/db lookups.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@34041


git-svn-id: http://core.svn.wordpress.org/trunk@34009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 06:15:24 +00:00
Scott Taylor
58c3c30e8d After [33961], pass $comment to comment_class() where possible to avoid extra cache/db lookups.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@34040


git-svn-id: http://core.svn.wordpress.org/trunk@34008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 06:12:24 +00:00
Scott Taylor
fc328f5484 After [33961], pass $comment to get_comment_author_link() where possible to avoid extra cache/db lookups.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@34039


git-svn-id: http://core.svn.wordpress.org/trunk@34007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 06:05:24 +00:00
Scott Taylor
67f90df6a4 Walker_Comment should be in its own file. Loaded now via wp-includes/comment.php, which makes it 100% BC.
See #33413.

Built from https://develop.svn.wordpress.org/trunk@33962


git-svn-id: http://core.svn.wordpress.org/trunk@33931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 02:41:24 +00:00