Changeset 55011
- Timestamp:
- 12/21/2022 02:34:13 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r54855 r55011 265 265 * @global WP_Taxonomy[] $wp_taxonomies The registered taxonomies. 266 266 * 267 * @param string|string[]|WP_Post $object Name of the type of taxonomy object, or an object (row from posts)268 * @param string $output Optional. The type of output to return in the array. Accepts either269 * 'names' or 'objects'. Default 'names'.267 * @param string|string[]|WP_Post $object_type Name of the type of taxonomy object, or an object (row from posts). 268 * @param string $output Optional. The type of output to return in the array. Accepts either 269 * 'names' or 'objects'. Default 'names'. 270 270 * @return string[]|WP_Taxonomy[] The names or objects of all taxonomies of `$object_type`. 271 271 */ 272 function get_object_taxonomies( $object , $output = 'names' ) {272 function get_object_taxonomies( $object_type, $output = 'names' ) { 273 273 global $wp_taxonomies; 274 274 275 if ( is_object( $object ) ) {276 if ( 'attachment' === $object ->post_type ) {277 return get_attachment_taxonomies( $object , $output );278 } 279 $object = $object->post_type;280 } 281 282 $object = (array) $object;275 if ( is_object( $object_type ) ) { 276 if ( 'attachment' === $object_type->post_type ) { 277 return get_attachment_taxonomies( $object_type, $output ); 278 } 279 $object_type = $object_type->post_type; 280 } 281 282 $object_type = (array) $object_type; 283 283 284 284 $taxonomies = array(); 285 285 foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) { 286 if ( array_intersect( $object , (array) $tax_obj->object_type ) ) {286 if ( array_intersect( $object_type, (array) $tax_obj->object_type ) ) { 287 287 if ( 'names' === $output ) { 288 288 $taxonomies[] = $tax_name; … … 1498 1498 * @global bool $_wp_suspend_cache_invalidation 1499 1499 * 1500 * @param int|string $term The term to check. Accepts term ID, slug, or name.1501 * @param string $taxonomy Optional. The taxonomy name to use.1502 * @param int $parent 1500 * @param int|string $term The term to check. Accepts term ID, slug, or name. 1501 * @param string $taxonomy Optional. The taxonomy name to use. 1502 * @param int $parent_term Optional. ID of parent term under which to confine the exists search. 1503 1503 * @return mixed Returns null if the term does not exist. 1504 1504 * Returns the term ID if no taxonomy is specified and the term ID exists. … … 1506 1506 * Returns 0 if term ID 0 is passed to the function. 1507 1507 */ 1508 function term_exists( $term, $taxonomy = '', $parent = null ) {1508 function term_exists( $term, $taxonomy = '', $parent_term = null ) { 1509 1509 global $_wp_suspend_cache_invalidation; 1510 1510 … … 1539 1539 * @since 6.0.0 1540 1540 * 1541 * @param array $defaults An array of arguments passed to get_terms().1542 * @param int|string $term The term to check. Accepts term ID, slug, or name.1543 * @param string $taxonomy The taxonomy name to use. An empty string indicates1544 * the search is against all taxonomies.1545 * @param int|null $parent 1546 * Null indicates the search is unconfined.1547 */ 1548 $defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent );1541 * @param array $defaults An array of arguments passed to get_terms(). 1542 * @param int|string $term The term to check. Accepts term ID, slug, or name. 1543 * @param string $taxonomy The taxonomy name to use. An empty string indicates 1544 * the search is against all taxonomies. 1545 * @param int|null $parent_term ID of parent term under which to confine the exists search. 1546 * Null indicates the search is unconfined. 1547 */ 1548 $defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent_term ); 1549 1549 1550 1550 if ( is_int( $term ) ) { … … 1560 1560 } 1561 1561 1562 if ( ! empty( $taxonomy ) && is_numeric( $parent ) ) {1563 $defaults['parent'] = (int) $parent ;1562 if ( ! empty( $taxonomy ) && is_numeric( $parent_term ) ) { 1563 $defaults['parent'] = (int) $parent_term; 1564 1564 } 1565 1565 … … 3215 3215 * @since 3.1.0 3216 3216 * 3217 * @param int $parent 3217 * @param int $parent_term ID of the parent term. 3218 3218 * @param int $term_id Term ID. 3219 3219 * @param string $taxonomy Taxonomy slug. … … 4941 4941 * @since 3.1.0 4942 4942 * 4943 * @param int $parent 4944 * @param int $term_id The term we're checking.4945 * @param string $taxonomy The taxonomy of the term we're checking.4943 * @param int $parent_term `term_id` of the parent for the term we're checking. 4944 * @param int $term_id The term we're checking. 4945 * @param string $taxonomy The taxonomy of the term we're checking. 4946 4946 * @return int The new parent for the term. 4947 4947 */ 4948 function wp_check_term_hierarchy_for_loops( $parent , $term_id, $taxonomy ) {4948 function wp_check_term_hierarchy_for_loops( $parent_term, $term_id, $taxonomy ) { 4949 4949 // Nothing fancy here - bail. 4950 if ( ! $parent ) {4950 if ( ! $parent_term ) { 4951 4951 return 0; 4952 4952 } 4953 4953 4954 4954 // Can't be its own parent. 4955 if ( $parent === $term_id ) {4955 if ( $parent_term === $term_id ) { 4956 4956 return 0; 4957 4957 } 4958 4958 4959 4959 // Now look for larger loops. 4960 $loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent , array( $taxonomy ) );4960 $loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent_term, array( $taxonomy ) ); 4961 4961 if ( ! $loop ) { 4962 return $parent ; // No loop.4963 } 4964 4965 // Setting $parent to the given value causes a loop.4962 return $parent_term; // No loop. 4963 } 4964 4965 // Setting $parent_term to the given value causes a loop. 4966 4966 if ( isset( $loop[ $term_id ] ) ) { 4967 4967 return 0; … … 4973 4973 } 4974 4974 4975 return $parent ;4975 return $parent_term; 4976 4976 } 4977 4977
Note: See TracChangeset
for help on using the changeset viewer.