Code Modernization: Rename parameters that use reserved keywords in `wp-includes/taxonomy.php`.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit: * Renames the `$object` parameter to `$object_type` in `get_object_taxonomies()`. * Renames the `$parent` parameter to `$parent_term` in: * `term_exists()` * `wp_check_term_hierarchy_for_loops()` Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #56788. Built from https://develop.svn.wordpress.org/trunk@55011 git-svn-id: http://core.svn.wordpress.org/trunk@54544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b57ef14af1
commit
c178ececac
|
@ -264,26 +264,26 @@ function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' )
|
|||
*
|
||||
* @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies.
|
||||
*
|
||||
* @param string|string[]|WP_Post $object Name of the type of taxonomy object, or an object (row from posts)
|
||||
* @param string $output Optional. The type of output to return in the array. Accepts either
|
||||
* 'names' or 'objects'. Default 'names'.
|
||||
* @param string|string[]|WP_Post $object_type Name of the type of taxonomy object, or an object (row from posts).
|
||||
* @param string $output Optional. The type of output to return in the array. Accepts either
|
||||
* 'names' or 'objects'. Default 'names'.
|
||||
* @return string[]|WP_Taxonomy[] The names or objects of all taxonomies of `$object_type`.
|
||||
*/
|
||||
function get_object_taxonomies( $object, $output = 'names' ) {
|
||||
function get_object_taxonomies( $object_type, $output = 'names' ) {
|
||||
global $wp_taxonomies;
|
||||
|
||||
if ( is_object( $object ) ) {
|
||||
if ( 'attachment' === $object->post_type ) {
|
||||
return get_attachment_taxonomies( $object, $output );
|
||||
if ( is_object( $object_type ) ) {
|
||||
if ( 'attachment' === $object_type->post_type ) {
|
||||
return get_attachment_taxonomies( $object_type, $output );
|
||||
}
|
||||
$object = $object->post_type;
|
||||
$object_type = $object_type->post_type;
|
||||
}
|
||||
|
||||
$object = (array) $object;
|
||||
$object_type = (array) $object_type;
|
||||
|
||||
$taxonomies = array();
|
||||
foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
|
||||
if ( array_intersect( $object, (array) $tax_obj->object_type ) ) {
|
||||
if ( array_intersect( $object_type, (array) $tax_obj->object_type ) ) {
|
||||
if ( 'names' === $output ) {
|
||||
$taxonomies[] = $tax_name;
|
||||
} else {
|
||||
|
@ -1497,15 +1497,15 @@ function unregister_term_meta( $taxonomy, $meta_key ) {
|
|||
*
|
||||
* @global bool $_wp_suspend_cache_invalidation
|
||||
*
|
||||
* @param int|string $term The term to check. Accepts term ID, slug, or name.
|
||||
* @param string $taxonomy Optional. The taxonomy name to use.
|
||||
* @param int $parent Optional. ID of parent term under which to confine the exists search.
|
||||
* @param int|string $term The term to check. Accepts term ID, slug, or name.
|
||||
* @param string $taxonomy Optional. The taxonomy name to use.
|
||||
* @param int $parent_term Optional. ID of parent term under which to confine the exists search.
|
||||
* @return mixed Returns null if the term does not exist.
|
||||
* Returns the term ID if no taxonomy is specified and the term ID exists.
|
||||
* Returns an array of the term ID and the term taxonomy ID if the taxonomy is specified and the pairing exists.
|
||||
* Returns 0 if term ID 0 is passed to the function.
|
||||
*/
|
||||
function term_exists( $term, $taxonomy = '', $parent = null ) {
|
||||
function term_exists( $term, $taxonomy = '', $parent_term = null ) {
|
||||
global $_wp_suspend_cache_invalidation;
|
||||
|
||||
if ( null === $term ) {
|
||||
|
@ -1538,14 +1538,14 @@ function term_exists( $term, $taxonomy = '', $parent = null ) {
|
|||
*
|
||||
* @since 6.0.0
|
||||
*
|
||||
* @param array $defaults An array of arguments passed to get_terms().
|
||||
* @param int|string $term The term to check. Accepts term ID, slug, or name.
|
||||
* @param string $taxonomy The taxonomy name to use. An empty string indicates
|
||||
* the search is against all taxonomies.
|
||||
* @param int|null $parent ID of parent term under which to confine the exists search.
|
||||
* Null indicates the search is unconfined.
|
||||
* @param array $defaults An array of arguments passed to get_terms().
|
||||
* @param int|string $term The term to check. Accepts term ID, slug, or name.
|
||||
* @param string $taxonomy The taxonomy name to use. An empty string indicates
|
||||
* the search is against all taxonomies.
|
||||
* @param int|null $parent_term ID of parent term under which to confine the exists search.
|
||||
* Null indicates the search is unconfined.
|
||||
*/
|
||||
$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent );
|
||||
$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent_term );
|
||||
|
||||
if ( is_int( $term ) ) {
|
||||
if ( 0 === $term ) {
|
||||
|
@ -1559,8 +1559,8 @@ function term_exists( $term, $taxonomy = '', $parent = null ) {
|
|||
return null;
|
||||
}
|
||||
|
||||
if ( ! empty( $taxonomy ) && is_numeric( $parent ) ) {
|
||||
$defaults['parent'] = (int) $parent;
|
||||
if ( ! empty( $taxonomy ) && is_numeric( $parent_term ) ) {
|
||||
$defaults['parent'] = (int) $parent_term;
|
||||
}
|
||||
|
||||
$args = wp_parse_args( array( 'slug' => sanitize_title( $term ) ), $defaults );
|
||||
|
@ -3214,7 +3214,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param int $parent ID of the parent term.
|
||||
* @param int $parent_term ID of the parent term.
|
||||
* @param int $term_id Term ID.
|
||||
* @param string $taxonomy Taxonomy slug.
|
||||
* @param array $parsed_args An array of potentially altered update arguments for the given term.
|
||||
|
@ -4940,29 +4940,29 @@ function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
|
|||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param int $parent `term_id` of the parent for the term we're checking.
|
||||
* @param int $term_id The term we're checking.
|
||||
* @param string $taxonomy The taxonomy of the term we're checking.
|
||||
* @param int $parent_term `term_id` of the parent for the term we're checking.
|
||||
* @param int $term_id The term we're checking.
|
||||
* @param string $taxonomy The taxonomy of the term we're checking.
|
||||
* @return int The new parent for the term.
|
||||
*/
|
||||
function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
|
||||
function wp_check_term_hierarchy_for_loops( $parent_term, $term_id, $taxonomy ) {
|
||||
// Nothing fancy here - bail.
|
||||
if ( ! $parent ) {
|
||||
if ( ! $parent_term ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Can't be its own parent.
|
||||
if ( $parent === $term_id ) {
|
||||
if ( $parent_term === $term_id ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Now look for larger loops.
|
||||
$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) );
|
||||
$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent_term, array( $taxonomy ) );
|
||||
if ( ! $loop ) {
|
||||
return $parent; // No loop.
|
||||
return $parent_term; // No loop.
|
||||
}
|
||||
|
||||
// Setting $parent to the given value causes a loop.
|
||||
// Setting $parent_term to the given value causes a loop.
|
||||
if ( isset( $loop[ $term_id ] ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -4972,7 +4972,7 @@ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
|
|||
wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
|
||||
}
|
||||
|
||||
return $parent;
|
||||
return $parent_term;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-alpha-55010';
|
||||
$wp_version = '6.2-alpha-55011';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue