Commit Graph

56 Commits

Author SHA1 Message Date
Sergey Biryukov 6742d0d7a6 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@47808 602fd350-edb4-49c9-b593-d223f7449a82
2020-05-16 18:40:52 +00:00
Sergey Biryukov 0b4e2c4604 Coding Standards: Use strict type check for `in_array()` and `array_search()` where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.

git-svn-id: https://develop.svn.wordpress.org/trunk@47550 602fd350-edb4-49c9-b593-d223f7449a82
2020-04-05 03:00:44 +00:00
Sergey Biryukov cfc3b57488 Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-29 00:43:23 +00:00
Sergey Biryukov 4c2ee4e9ff Docs: In various `@return` tags, list the expected type first, instead of `false`.
Follow-up to [46696].

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47060 602fd350-edb4-49c9-b593-d223f7449a82
2020-01-11 18:30:58 +00:00
Jonathan Desrosiers 336960897d Build/Test Tools: Introduce automated PHP compatibility checking.
This change introduces a new Composer script, `compat` that will scan the codebase for (detectable) potential PHP compatibility issues using the `PHP_CodeSniffer` and a custom ruleset based off of the `PHPCompayibilityWP` ruleset (`phpcompat.xml.dist`).

The command will be run as a separate job within each Travis build. While many compatibility issues and false positives have already been corrected in this commit and other Trac tickets, there are still some remaining. For that reason, the job is allowed to fail while the remainder of the potential compatibility issues are investigated and addressed. After those are resolved, the job should be set as required to pass to help prevent new compatibility issues from being introduced.

Props desrosj, jrf, all PHPCompatibilityWP and PHPCompatibility contributors.
Fixes #46152.

git-svn-id: https://develop.svn.wordpress.org/trunk@46290 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-25 13:46:55 +00:00
Sergey Biryukov 00b03f2a6f I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.

git-svn-id: https://develop.svn.wordpress.org/trunk@45932 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-03 00:39:13 +00:00
Sergey Biryukov a7513ac8e0 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45926 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-01 17:12:43 +00:00
Sergey Biryukov c76271c49a Docs: Improve documentation for various feed link functions and filters.
Props atachibana, SergeyBiryukov.
Fixes #47862.

git-svn-id: https://develop.svn.wordpress.org/trunk@45781 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-11 17:20:51 +00:00
Sergey Biryukov 9c1123fb26 Docs: Add missing description for `$wp_rewrite` global.
See #45604, #47110.

git-svn-id: https://develop.svn.wordpress.org/trunk@45735 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-04 01:18:54 +00:00
Sergey Biryukov ae8a620efb General: First pass at replacing Codex URLs with a corresponding HelpHub or DevHub article.
Props ianbelanger, tobifjellner, SergeyBiryukov.
See #47771.

git-svn-id: https://develop.svn.wordpress.org/trunk@45674 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-25 22:44:48 +00:00
Gary Pendergast 4503f93961 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45590 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 23:41:16 +00:00
Gary Pendergast ef5a9dfda6 Coding Standards: Fix/ignore the `WordPress.NamingConventions.ValidFunctionName` violations.
See #47632



git-svn-id: https://develop.svn.wordpress.org/trunk@45580 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 08:00:12 +00:00
Sergey Biryukov 774dceac30 Users: In `wp_list_authors()`, check for author's post count before getting author's metadata.
This significantly reduces the number of SQL queries when `wp_list_authors()` is called on a site where the majority of users don't have any posts, e.g. a membership site.

Props billerickson, ianbelanger, dswebsme.
Fixes #45105.

git-svn-id: https://develop.svn.wordpress.org/trunk@45235 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-17 14:49:49 +00:00
Sergey Biryukov fe0db882c5 Docs: Correct parameter types for `the_author()`, `get_the_author_meta()`, and `the_author_meta()`.
Props subrataemfluence.
Fixes #45596.

git-svn-id: https://develop.svn.wordpress.org/trunk@45086 602fd350-edb4-49c9-b593-d223f7449a82
2019-04-01 14:22:06 +00:00
Gary Pendergast cd7d022ae0 Templates: Fix the return value of `get_the_author_posts_link()`.
When the `$authordata` global isn't defined, return an empty string, rather than `void`.

Props mukesh27, subrataemfluence.
Fixes #45597.



git-svn-id: https://develop.svn.wordpress.org/trunk@44616 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 05:53:26 +00:00
Gary Pendergast 2a6e44a306 Docs: Correct the documentation for `wp_list_authors()`.
The `exclude_admin` argument defaults to `true`, not `false`.

Props haruharuharuby.
Fixes #45120.



git-svn-id: https://develop.svn.wordpress.org/trunk@44503 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 06:51:38 +00:00
Gary Pendergast ab3b19d94e Coding Standards: Improve the readability of `get_the_modified_author()`.
Props promz.
Fixes #44951.



git-svn-id: https://develop.svn.wordpress.org/trunk@44461 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-08 05:49:50 +00:00
Gary Pendergast a75d153eee 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
Dominik Schilling (ocean90) 8df8cf2df1 Pinking shears.
See #41057.

git-svn-id: https://develop.svn.wordpress.org/trunk@42843 602fd350-edb4-49c9-b593-d223f7449a82
2018-03-18 14:22:09 +00:00
Drew Jaynes 1b46470b75 Docs: Link to the "Conditional Tags" article in the Theme Developer Handbook from the descriptions for a variety of core conditional tag functions.
These notations largely serve to direct consumers (of both the source and the parsed code reference) to extended information on individual and related conditional tags throughout WordPress. The changeset also standardizes corresponding DocBlock summaries to use third-person singular verbs.

Notations been added for the following functions:

* comments_open()
* email exists()
* has_excerpt()
* has_post_thumbnail()
* has_tag()
* in_category()
* in_the_loop()
* is_404()
* is_active_sidebar()
* is_active_widget()
* is_admin()
* is_admin_bar_showing()
* is_archive()
* is_attachment()
* is_author()
* is_blog_installed()
* is_category()
* is_comments_popup()
* is_date()
* is_day()
* is_dynamic_sidebar()
* is_feed()
* is_front_page()
* is_home()
* is_local_attachment()
* is_main_query
* is_month()
* is_multi_author
* is_new_day()
* is_page()
* is_page_template()
* is_paged()
* is_plugin_active()
* is_plugin_active_for_network()
* is_plugin_inactive()
* is_plugin_page()
* is_post_type_archive()
* is_preview()
* is_rtl()
* is_search()
* is_single()
* is_singular()
* is_sticky()
* is_tag()
* is_tax()
* is_taxonomy_hierarchical()
* is_time()
* is_trackback()
* is_user_logged_in()
* is_year()
* pings_open()
* post_type_exists()
* taxonomy_exists()
* term_exists()
* username exists()
* wp_attachment_is_image()
* wp_script_is()

Props janalwin.
Fixes #43254.


git-svn-id: https://develop.svn.wordpress.org/trunk@42710 602fd350-edb4-49c9-b593-d223f7449a82
2018-02-13 16:53:44 +00:00
Gary Pendergast 8f95800d52 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00
Weston Ruter dbace684e2 Editor: Add CodeMirror-powered code editor with syntax highlighting, linting, and auto-completion.
* Code editor is integrated into the Theme/Plugin Editor, Additional CSS in Customizer, and Custom HTML widget. Code editor is not yet integrated into the post editor, and it may not be until accessibility concerns are addressed.
* The CodeMirror component in the Custom HTML widget is integrated in a similar way to TinyMCE being integrated into the Text widget, adopting the same approach for integrating dynamic JavaScript-initialized fields.
* Linting is performed for JS, CSS, HTML, and JSON via JSHint, CSSLint, HTMLHint, and JSONLint respectively. Linting is not yet supported for PHP.
* When user lacks `unfiltered_html` the capability, the Custom HTML widget will report any Kses-invalid elements and attributes as errors via a custom Kses rule for HTMLHint.
* When linting errors are detected, the user will be prevented from saving the code until the errors are fixed, reducing instances of broken websites.
* The placeholder value is removed from Custom CSS in favor of a fleshed-out section description which now auto-expands when the CSS field is empty. See #39892.
* The CodeMirror library is included as `wp.CodeMirror` to prevent conflicts with any existing `CodeMirror` global.
* An `wp.codeEditor.initialize()` API in JS is provided to convert a `textarea` into CodeMirror, with a `wp_enqueue_code_editor()` function in PHP to manage enqueueing the assets and settings needed to edit a given type of code.
* A user preference is added to manage whether or not "syntax highlighting" is enabled. The feature is opt-out, being enabled by default.
* Allowed file extensions in the theme and plugin editors have been updated to include formats which CodeMirror has modes for: `conf`, `css`, `diff`, `patch`, `html`, `htm`, `http`, `js`, `json`, `jsx`, `less`, `md`, `php`, `phtml`, `php3`, `php4`, `php5`, `php7`, `phps`, `scss`, `sass`, `sh`, `bash`, `sql`, `svg`, `xml`, `yml`, `yaml`, `txt`.

Props westonruter, georgestephanis, obenland, melchoyce, pixolin, mizejewski, michelleweber, afercia, grahamarmfield, samikeijonen, rianrietveld, iseulde.
See #38707.
Fixes #12423, #39892.


git-svn-id: https://develop.svn.wordpress.org/trunk@41376 602fd350-edb4-49c9-b593-d223f7449a82
2017-09-13 06:07:48 +00:00
Drew Jaynes 814936e641 Docs: List out accepted values for the `$field` parameter in `get_the_author_meta()`.
Props choongsavvii.
Fixes #38258.


git-svn-id: https://develop.svn.wordpress.org/trunk@40952 602fd350-edb4-49c9-b593-d223f7449a82
2017-06-26 18:23:52 +00:00
Drew Jaynes 5741c2f6c1 Docs: Clarify that `get_the_author_meta()` can also return an empty string.
h/t aurovrata.
See #41017


git-svn-id: https://develop.svn.wordpress.org/trunk@40899 602fd350-edb4-49c9-b593-d223f7449a82
2017-06-13 02:32:15 +00:00
Pascal Birchler 8d611dde0d Themes: Fix incorrect annotation for `__clear_multi_author_cache()` function.
Props flixos90.
See #40063.
Fixes #40262.



git-svn-id: https://develop.svn.wordpress.org/trunk@40334 602fd350-edb4-49c9-b593-d223f7449a82
2017-03-25 15:46:10 +00:00
John Blackbourn 5f645d2f34 Docs: Add and correct `@since` docs for a variety of functions and methods.
Props keesiemeijer, chris_dev
Fixes #39343, #39357, #39344
See #39130


git-svn-id: https://develop.svn.wordpress.org/trunk@39638 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-27 09:20:11 +00:00
John Blackbourn ca92da24da General: Use interpolation instead of concatenation for all dynamic hook names.
This fixes the rendering of the hook names on developer.wordpress.org.

Props keesiemeijer
Fixes #39148


git-svn-id: https://develop.svn.wordpress.org/trunk@39600 602fd350-edb4-49c9-b593-d223f7449a82
2016-12-14 04:17:38 +00:00
Sergey Biryukov 364754b01b I18N: Add translator comments for strings in `wp-includes/author-template.php`.
Props ramiy.
Fixes #37795.

git-svn-id: https://develop.svn.wordpress.org/trunk@38341 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-23 23:17:32 +00:00
Sergey Biryukov 920f29616a Docs: Use 3-digit, x.x.x-style semantic versioning for `_doing_it_wrong()`, `_deprecated_function()`, `_deprecated_argument()`, and `_deprecated_file()` throughout core.
Props metodiew.
Fixes #36495.

git-svn-id: https://develop.svn.wordpress.org/trunk@37985 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 12:39:01 +00:00
Sergey Biryukov 8ae60fd26c Docs: In `wp_list_authors()`, clarify that `include` and `exclude` arguments can also be an array.
Fix duplicated `exclude` argument description.

Props birgire.
Fixes #37239.

git-svn-id: https://develop.svn.wordpress.org/trunk@37949 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 14:33:03 +00:00
Drew Jaynes 23ecafeae9 Docs: Standardize filter docs in wp-includes/author-template.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.


git-svn-id: https://develop.svn.wordpress.org/trunk@37495 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-22 18:24:23 +00:00
Drew Jaynes 195572596b Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.


git-svn-id: https://develop.svn.wordpress.org/trunk@37431 602fd350-edb4-49c9-b593-d223f7449a82
2016-05-13 18:40:19 +00:00
Eric Andrew Lewis 27361e6ffe Networks and sites: Replace "blog" usage with "site" in docs.
Multisite functions use the term "blog" to refer to what we now call a "site," e.g. `get_current_blog_id()`. These functions are here to stay because of our commitment to backwards compatibility. What we can do is set the documentation straight.

See #35417.


git-svn-id: https://develop.svn.wordpress.org/trunk@36417 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-28 03:50:26 +00:00
Drew Jaynes 203199de6f Docs: Add missing parameter notations to the DocBlock for `get_author_posts_url()`.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@35993 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-17 17:29:39 +00:00
Sergey Biryukov c98179fb82 Remove `<code>` tag from translatable string in `the_author()`.
Add translator commment.

Props ramiy.
See #34573.


git-svn-id: https://develop.svn.wordpress.org/trunk@35545 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-05 23:37:29 +00:00
Drew Jaynes 0cb7c0bd9f Docs: Add missing descriptions for the `$wpdb` global in DocBlocks all the places.
See #32246.


git-svn-id: https://develop.svn.wordpress.org/trunk@35170 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-14 23:43:10 +00:00
Drew Jaynes 3edc3b46f2 Introduce `get_the_author_posts_link()`, which returns the HTML link to the author page for the current post's author.
`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.

Adds tests for the new function.

Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes #30355.


git-svn-id: https://develop.svn.wordpress.org/trunk@34677 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 01:48:47 +00:00
Boone Gorges abb1cef395 Pass the original `$user_id` variable to the filter in `get_the_author_meta()`.
Props dlh, chriscct7.
Fixes #32481.

git-svn-id: https://develop.svn.wordpress.org/trunk@32594 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-25 13:05:21 +00:00
Scott Taylor 39ef6a72c5 Use `void` instead of `null` where appropriate when pipe-delimiting `@return` types. If a `@return` only contains `void`, remove it.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32568 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-24 05:39:47 +00:00
Scott Taylor 339d3be328 Add missing doc blocks to `author-template.php`.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32538 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-22 04:13:35 +00:00
Scott Taylor ff1eabd7e1 In `author-template.php`, clarify/add some `return` docs.
See #32444.


git-svn-id: https://develop.svn.wordpress.org/trunk@32526 602fd350-edb4-49c9-b593-d223f7449a82
2015-05-21 20:09:44 +00:00
Dominik Schilling (ocean90) b0d6757918 Use HTTPS URLs for codex.wordpress.org.
see #27115.

git-svn-id: https://develop.svn.wordpress.org/trunk@32116 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-12 21:28:58 +00:00
Boone Gorges b2332718a1 When passing `$full` to `get_posts_by_author_sql()`, make sure a 'post_type' clause is included in results.
This change makes the 'post_type' clause in `wp_list_authors()` redundant, so
we remove it. Third-party plugins using `get_posts_by_author_sql()` may have
similarly redundant clauses, but this won't change the results returned by the
SQL queries.

Also adds unit tests for `get_posts_by_author_sql()`.

Props pbearne.
Fixes #30354.

git-svn-id: https://develop.svn.wordpress.org/trunk@31653 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 01:14:31 +00:00
Scott Taylor 865185903b There are some random `add_action()` and `add_filter()` calls littered around some files in `wp-includes/`. These should be moved to `wp-includes/default-filters.php` with the rest of the registered hooks. It seems like this was the best practice for awhile and then we randomly stopped. This file loads way before any of the includes, so the hooks will be registered for any request that loads WordPress, even `SHORTINIT` - a lot of the hooks registered won't run anyways (that's already the case).
See #30947.


git-svn-id: https://develop.svn.wordpress.org/trunk@31168 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 16:39:39 +00:00
Sergey Biryukov 907be55276 Pass post type to count_user_posts() in get_the_author_posts().
props Caspie, tyxla.
fixes #30904.

git-svn-id: https://develop.svn.wordpress.org/trunk@31098 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-08 19:52:52 +00:00
Drew Jaynes (DrewAPicture) 3cc10d77a0 Remove redundant and erroneous `@uses` tag from most core inline documentation.
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.

Fixes #30191.


git-svn-id: https://develop.svn.wordpress.org/trunk@30105 602fd350-edb4-49c9-b593-d223f7449a82
2014-10-30 01:04:55 +00:00
Drew Jaynes (DrewAPicture) 75ff222c93 Convert documentation of default arguments in `wp_list_authors()` to the hash-notation style.
Props Viper007Bond.
Fixes #28684.


git-svn-id: https://develop.svn.wordpress.org/trunk@28909 602fd350-edb4-49c9-b593-d223f7449a82
2014-06-29 22:33:46 +00:00
Scott Taylor 540826e4e3 Eliminate use of `extract()` in `wp_list_authors()`.
See #22400.


git-svn-id: https://develop.svn.wordpress.org/trunk@28392 602fd350-edb4-49c9-b593-d223f7449a82
2014-05-13 06:01:33 +00:00
Scott Taylor b70967302b In `get_the_author_posts()`, if there is no current `$post`, return `0` and bail.
Props krogsgard, aaroncampbell.
Fixes #27998.



git-svn-id: https://develop.svn.wordpress.org/trunk@28362 602fd350-edb4-49c9-b593-d223f7449a82
2014-05-11 00:25:29 +00:00
Scott Taylor eda51bf856 Remove duplicate variable setting for `$link` in `wp_list_authors()`.
See #27882.



git-svn-id: https://develop.svn.wordpress.org/trunk@28265 602fd350-edb4-49c9-b593-d223f7449a82
2014-05-06 03:51:42 +00:00