Docs: Update the description for the `$legacy` parameter of `wp_count_terms()` for consistency with `get_terms()`.

Follow-up to [48840].

See #36399.

git-svn-id: https://develop.svn.wordpress.org/trunk@48843 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-08-23 00:06:04 +00:00
parent 153d07b93a
commit 380145e073
1 changed files with 22 additions and 8 deletions

View File

@ -1170,10 +1170,11 @@ function get_term_to_edit( $id, $taxonomy ) {
* @internal The `$deprecated` parameter is parsed for backward compatibility only.
*
* @param array|string $args Optional. Array or string of arguments. See WP_Term_Query::__construct()
* for information on accepted arguments. Default empty.
* @param array|string $deprecated Argument array, when using the legacy function parameter format. If present,
* this parameter will be interpreted as `$args`, and the first function parameter
* will be parsed as a taxonomy or array of taxonomies.
* for information on accepted arguments. Default empty array.
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
* If present, this parameter will be interpreted as `$args`, and the first
* function parameter will be parsed as a taxonomy or array of taxonomies.
* Default empty.
* @return WP_Term[]|int|WP_Error Array of WP_Term instances, a count thereof,
* or WP_Error if any of the taxonomies do not exist.
*/
@ -1732,16 +1733,29 @@ function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
* @since 2.3.0
* @since 5.6.0 Changed the function signature so that the `$args` array can be provided as the first parameter.
*
* @internal The `$deprecated` parameter is parsed for backward compatibility only.
*
* @param array|string $args Optional. Array of arguments that get passed to get_terms().
* Default empty array.
* @param array|string $deprecated Taxonomy name.
* @param array|string $deprecated Optional. Argument array, when using the legacy function parameter format.
* If present, this parameter will be interpreted as `$args`, and the first
* function parameter will be parsed as a taxonomy or array of taxonomies.
* Default empty.
* @return array|int|WP_Error Number of terms in that taxonomy or WP_Error if the taxonomy does not exist.
*/
function wp_count_terms( $args = array(), $deprecated = array() ) {
// Check whether function is used with legacy signature `$taxonomy` and `$args`.
$use_legacy_args = $args && ( is_string( $args ) && taxonomy_exists( $args ) || is_array( $args ) && wp_is_numeric_array( $args ) );
function wp_count_terms( $args = array(), $deprecated = '' ) {
$use_legacy_args = false;
// Check whether function is used with legacy signature: `$taxonomy` and `$args`.
if ( $args
&& ( is_string( $args ) && taxonomy_exists( $args )
|| is_array( $args ) && wp_is_numeric_array( $args ) )
) {
$use_legacy_args = true;
}
$defaults = array( 'hide_empty' => false );
if ( $use_legacy_args ) {
$defaults['taxonomy'] = $args;
$args = $deprecated;