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
This change reinstates the previous de facto behavior of `category_description()`.
See [40979], [42364]. Because `term_description()` no longer passes `$taxonomy` to
`get_term_field()`, the parameter is no longer needed and has been deprecated.
Fixes#42605. See #42771.
Built from https://develop.svn.wordpress.org/trunk@42368
git-svn-id: http://core.svn.wordpress.org/trunk@42197 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Prior to 4.9, this function was accidentally taxonomy-agnostic in most cases.
The fix in [40979] caused a regression in this function. For backward
compatibility, we make it explicit that the query is by ID only.
See #42771.
Built from https://develop.svn.wordpress.org/trunk@42367
git-svn-id: http://core.svn.wordpress.org/trunk@42196 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Prior to version 4.9, a quirk in the implementation of `get_term()` caused
`get_category_link( 123 )` to fetch the taxonomy archive link for term 123
even if 123 is not in the 'category' taxonomy. The quirk was fixed in [40979];
see #40671. This bugfix introduced a regression for theme authors who were
expecting the old behavior.
By lifting the 'category' restriction, we allow the template function to work
in the old way.
Fixes#42717. See #42771.
Built from https://develop.svn.wordpress.org/trunk@42364
git-svn-id: http://core.svn.wordpress.org/trunk@42193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
- improves accessibility using an aria-label attribute to match the information conveyed visually with the one exposed to assistive technologies
- adds an option in the widget to display the item counts, consistently with what other widgets already do (Archives, Categories)
Props adamsoucie, emirpprime, Samantha Miller., MikeLittle, rianrietveld, sami.keijonen, adamsilverstein, westonruter, afercia.
See #24766.
Fixes#35566.
Built from https://develop.svn.wordpress.org/trunk@40816
git-svn-id: http://core.svn.wordpress.org/trunk@40674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`get_category_link()` is a wrapper for `get_term_link()`. Using the
unwrapped function makes more sense semantically (it's taxonomy-
agnostic) and it's also more parsimonious (the `WP_Error` check in
`get_category_link()` is redundant with similar checks just before
in `get_term_link()`).
Props keesiemeijer.
Fixes#17069.
Built from https://develop.svn.wordpress.org/trunk@39593
git-svn-id: http://core.svn.wordpress.org/trunk@39533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In addition to `wp_list_filter()` for filtering a list of objects, and `wp_list_pluck()` for plucking a certain field out of each object in a list, this new function can be used for sorting a list of objects by specific fields. These functions are now all contained within the new `WP_List_Util()` class and `wp_list_sort()` is used in various parts of core for sorting lists.
This was previously committed in [38859] but got reverted in [38862] and [38863]. To fix the previous issues, `wp_list_sort()` supports now an additional argument to preserve array keys via `uasort()`.
Props flixos90, DrewAPicture, jorbin.
Fixes#37128.
Built from https://develop.svn.wordpress.org/trunk@38928
git-svn-id: http://core.svn.wordpress.org/trunk@38871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In addition to `wp_list_filter()` for filtering a list of objects, and `wp_list_pluck()` for plucking a certain field out of each object in a list, this new function can be used for sorting a list of objects by specific fields. These functions are now all contained within the new `WP_List_Util()` class and `wp_list_sort()` is used in various parts of core for sorting lists.
Props flixos90, DrewAPicture, jorbin.
Fixes#37128.
Built from https://develop.svn.wordpress.org/trunk@38859
git-svn-id: http://core.svn.wordpress.org/trunk@38802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Previously, objects containing all data about a term were stored in each
object's term cache. Besides being wasteful, this approach caused invalidation
issues, as when a modified term count required a flush for all objects
belonging to the term.
Backward compatibility is maintained for plugins that continue to put object
data directly into the `{$taxonomy}_relationships` cache bucket.
Fixes#36814.
Built from https://develop.svn.wordpress.org/trunk@37573
git-svn-id: http://core.svn.wordpress.org/trunk@37541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
[34696] introduced a regression whereby comma-separated values for 'exclude'
and 'exclude_tree' would be handled improperly when merging the two parameters,
resulting in category IDs being incorrectly dropped from the combined array.
Props gblsm, hnle.
Fixes#35156.
Built from https://develop.svn.wordpress.org/trunk@36005
git-svn-id: http://core.svn.wordpress.org/trunk@35970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`wp_get_object_terms()` can return a `WP_Error` object. As such, the
`get_the_terms()` cache wrapper should handle them properly. To wit:
* Don't try to map an error object to `get_term()`. Introduced in [35032].
* Don't cache an error object as taxonomy relationships. Introduced in at least [16487], maybe earlier.
Props stephenharris.
Fixes#34723.
Built from https://develop.svn.wordpress.org/trunk@35850
git-svn-id: http://core.svn.wordpress.org/trunk@35814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The data stored in the cache should be raw database query results, not
`WP_Term` objects (which may be modified by plugins, and may contain additional
properties that shouldn't be cached).
If term relationships caches were handled in `wp_get_object_terms()` - where
a database query takes place - it would be straightforward to cache raw data.
See #34239. Since, in fact, `get_the_terms()` caches the value it gets from
`wp_get_object_terms()`, we need a technique that allows us to get raw data
from a `WP_Term` object. Mirroring `WP_User`, we introduce a `data` property
on term objects, which `get_the_terms()` uses to fetch cacheable term info.
Fixes#34262.
Built from https://develop.svn.wordpress.org/trunk@35032
git-svn-id: http://core.svn.wordpress.org/trunk@34997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The 'exclude_tree' parameter must be compatible with 'hierarchical';
previously, 'hierarchical' canceled it out. This changeset also makes it so
that 'exclude_tree' is compatible with 'exclude'. When both are passed, and
'hierarchical' is true, the descendant trees of terms in both parameters will
be excluded from matched terms.
Props tott, webord, MikeHansenMe.
Fixes#12981.
Built from https://develop.svn.wordpress.org/trunk@34696
git-svn-id: http://core.svn.wordpress.org/trunk@34660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Used to filter categories as structured data, before building markup in
`get_the_category_list()`.
We use this filter in addition to upstream filters (such as
'get_the_categories'`) because those upstream filters are used in numerous
contexts, while `'the_category_list'` is always used for generating markup
for display.
Props KevinB, ericlewis, SergeyBiryukov, DrewAPicture.
Fixes#9227.
Built from https://develop.svn.wordpress.org/trunk@34625
git-svn-id: http://core.svn.wordpress.org/trunk@34589 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When generating a `<ul>` using `wp_list_categories()`, a title `<li>` element
is put at the top of the term list. Current behavior is that this title `<li>`
appears even when no terms are found. The new `hide_title_if_no_cats` param
allows developers to specify that the title should be hidden when the term list
is empty.
Props vilkatis.
Fixes#33460.
Built from https://develop.svn.wordpress.org/trunk@33764
git-svn-id: http://core.svn.wordpress.org/trunk@33732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As of [32484], `wp_dropdown_categories()` uses the `$value_field` value to
decide whether a given `<option>` should be 'selected'. However, `$value_field`
can refer to a value that is a string, such as a category's slug. This causes
problems when doing a loose comparison (`==`) with the value of the `'selected'`
parameter, which defaults to `0`, because when doing a loose comparison
between an integer and a string, PHP will cast the string to an integer. This
creates false matches, resulting in `<option>` elements getting a 'selected'
attribute incorrectly.
We address the issue by casting the comparison values to strings, and then
using the strict comparison operator `===`.
Fixes#33452 for trunk.
Built from https://develop.svn.wordpress.org/trunk@33681
git-svn-id: http://core.svn.wordpress.org/trunk@33648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This filter allows developers to modify the data that is used to create tag
clouds, without having to manipulate the tag cloud markup directly.
As part of the refactor, this changeset also adds a few unit tests for the way
`wp_generate_tag_cloud()` generates the 'title' attribute, as well as
improvements to output escaping.
Props flixos90, ysalame.
Fixes#24656.
Built from https://develop.svn.wordpress.org/trunk@32996
git-svn-id: http://core.svn.wordpress.org/trunk@32967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* Clarify/add some `return` docs.
* In `walk_category_tree()` and `walk_category_dropdown_tree()`, make behavior consistent and don't pass `$walker` by-reference - it is no longer necessary to do that with object instances.
See #32444.
Built from https://develop.svn.wordpress.org/trunk@32531
git-svn-id: http://core.svn.wordpress.org/trunk@32501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In PHP 5.3.0, `is_a()` is no longer deprecated, and will therefore no longer throw `E_STRICT` warnings.
To avoid warnings in PHP < 5.3.0, convert all `is_a()` calls to `$var instanceof WP_Class` calls.
`instanceof` does not throw any error if the variable being tested is not an object, it simply returns `false`.
Props markoheijnen, wonderboymusic.
Fixes#25672.
Built from https://develop.svn.wordpress.org/trunk@31188
git-svn-id: http://core.svn.wordpress.org/trunk@31169 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This enhancement requires a modification in the way that `wp_dropdown_categories()`
prepares its arguments for `get_terms()`, so that its unrelated 'name' param is
not mistaken for the new 'name' argument in `get_terms()`.
Props danielbachhuber.
Fixes#30611.
Built from https://develop.svn.wordpress.org/trunk@31024
git-svn-id: http://core.svn.wordpress.org/trunk@31005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The new 'value_field' parameter makes it possible to set term slugs (or some
other term property) as the 'value' attribute of the option elements generated
by `wp_dropdown_categories()`. This additional flexibility reduces the effort
required to translate term_id to other term fields when processing form
submissions that include values from taxonomy dropdowns. See #30865 for a
use case.
Props collinsinternet.
Fixes#30306.
Built from https://develop.svn.wordpress.org/trunk@31006
git-svn-id: http://core.svn.wordpress.org/trunk@30987 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/trunk@30105
git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd