Changeset 32453
- Timestamp:
- 05/07/2015 06:13:27 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r32452 r32453 210 210 * @global array $wp_taxonomies The registered taxonomies. 211 211 * 212 * @param string $taxonomy Name of taxonomy object to return 213 * @return object|bool The Taxonomy Object or false if $taxonomy doesn't exist 212 * @param string $taxonomy Name of taxonomy object to return. 213 * @return object|bool The Taxonomy Object or false if $taxonomy doesn't exist. 214 214 */ 215 215 function get_taxonomy( $taxonomy ) { … … 231 231 * @global array $wp_taxonomies The registered taxonomies. 232 232 * 233 * @param string $taxonomy Name of taxonomy object 233 * @param string $taxonomy Name of taxonomy object. 234 234 * @return bool Whether the taxonomy exists. 235 235 */ … … 250 250 * @since 2.3.0 251 251 * 252 * @param string $taxonomy Name of taxonomy object 253 * @return bool Whether the taxonomy is hierarchical 252 * @param string $taxonomy Name of taxonomy object. 253 * @return bool Whether the taxonomy is hierarchical. 254 254 */ 255 255 function is_taxonomy_hierarchical($taxonomy) { … … 320 320 * - _builtin - true if this taxonomy is a native or "built-in" taxonomy. THIS IS FOR INTERNAL USE ONLY! 321 321 * 322 * @todo Document $args as a hash notation. 323 * 322 324 * @since 2.3.0 323 325 * @since 4.2.0 Introduced `show_in_quick_edit` argument. … … 474 476 * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories). 475 477 * 478 * @todo Better documentation for the labels array. 479 * 476 480 * @since 3.0.0 477 481 * 478 * @param object $tax Taxonomy object 479 * @return object object with all the labels as member variables 482 * @param object $tax Taxonomy object. 483 * @return object object with all the labels as member variables. 480 484 */ 481 485 … … 519 523 * @global array $wp_taxonomies The registered taxonomies. 520 524 * 521 * @param string $taxonomy Name of taxonomy object522 * @param string $object_type Name of the object type 523 * @return bool True if successful, false if not 525 * @param string $taxonomy Name of taxonomy object. 526 * @param string $object_type Name of the object type. 527 * @return bool True if successful, false if not. 524 528 */ 525 529 function register_taxonomy_for_object_type( $taxonomy, $object_type) { … … 589 593 * @global wpdb $wpdb WordPress database abstraction object. 590 594 * 591 * @param int|array $term_ids Term id or array of term ids of terms that will be used 592 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names 593 * @param array|string $args Change the order of the object_ids, either ASC or DESC 594 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success 595 * @param int|array $term_ids Term id or array of term ids of terms that will be used. 596 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names. 597 * @param array|string $args Change the order of the object_ids, either ASC or DESC. 598 * @return WP_Error|array If the taxonomy does not exist, then WP_Error will be returned. On success. 595 599 * the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found. 596 600 */ … … 648 652 * Class for generating SQL clauses that filter a primary query according to object taxonomy terms. 649 653 * 650 * `WP_Tax_Query` is a helper that allows primary query classes, such as {@see WP_Query}, to filter654 * `WP_Tax_Query` is a helper that allows primary query classes, such as WP_Query, to filter 651 655 * their results by object metadata, by generating `JOIN` and `WHERE` subclauses to be attached 652 656 * to the primary SQL query string. … … 698 702 * 699 703 * We store this data in a flat array because they are referenced in a 700 * number of places by {@see WP_Query}.704 * number of places by WP_Query. 701 705 * 702 706 * @since 4.1.0 … … 897 901 * Generate SQL clauses to be appended to a main query. 898 902 * 899 * Called by the public {@see WP_Tax_Query::get_sql()}, this method903 * Called by the public WP_Tax_Query::get_sql(), this method 900 904 * is abstracted out to maintain parity with the other Query classes. 901 905 * … … 1018 1022 * @global wpdb $wpdb The WordPress database abstraction object. 1019 1023 * 1020 * @param array $clause Query clause, passed by reference 1024 * @param array $clause Query clause, passed by reference. 1021 1025 * @param array $parent_query Parent query array. 1022 1026 * @return array { … … 1136 1140 * (ie, it's under the scope of the same relation), and (b) the combination 1137 1141 * of operator and relation between the clauses allows for a shared table 1138 * join. In the case of {@see WP_Tax_Query}, this only applies to 'IN'1142 * join. In the case of WP_Tax_Query, this only applies to 'IN' 1139 1143 * clauses that are connected by the relation 'OR'. 1140 1144 * … … 1230 1234 * @param array &$query The single query. 1231 1235 * @param string $resulting_field The resulting field. Accepts 'slug', 'name', 'term_taxonomy_id', 1232 * or 'term_id'. Default :'term_id'.1236 * or 'term_id'. Default 'term_id'. 1233 1237 */ 1234 1238 public function transform_query( &$query, $resulting_field ) { … … 1309 1313 * return a Term object. 1310 1314 * 1311 * 'get_term'hook - Takes two parameters the term Object and the taxonomy name.1315 * {@see 'get_term'} hook - Takes two parameters the term Object and the taxonomy name. 1312 1316 * Must return term object. Used in get_term() as a catch-all filter for every 1313 1317 * $term. 1314 1318 * 1315 * 'get_$taxonomy'hook - Takes two parameters the term Object and the taxonomy1319 * {@see 'get_$taxonomy'} hook - Takes two parameters the term Object and the taxonomy 1316 1320 * name. Must return term object. $taxonomy will be the taxonomy name, so for 1317 1321 * example, if 'category', it would be 'get_category' as the filter name. Useful 1318 1322 * for custom taxonomies or plugging into default taxonomies. 1323 * 1324 * @todo Better formatting for DocBlock 1319 1325 * 1320 1326 * @since 2.3.0 … … 1407 1413 * If $value does not exist, the return value will be false. If $taxonomy exists 1408 1414 * and $field and $value combinations exist, the Term will be returned. 1415 * 1416 * @todo Better formatting for DocBlock. 1409 1417 * 1410 1418 * @since 2.3.0 … … 1480 1488 * @since 2.3.0 1481 1489 * 1482 * @param string $term_id ID of Term to get children1483 * @param string $taxonomy Taxonomy Name 1484 * @return array|WP_Error List of Term IDs. WP_Error returned if $taxonomy does not exist1490 * @param string $term_id ID of Term to get children. 1491 * @param string $taxonomy Taxonomy Name. 1492 * @return array|WP_Error List of Term IDs. WP_Error returned if `$taxonomy` does not exist. 1485 1493 */ 1486 1494 function get_term_children( $term_id, $taxonomy ) { … … 1518 1526 * @since 2.3.0 1519 1527 * 1520 * @param string $field Term field to fetch1521 * @param int $term Term ID1522 * @param string $taxonomy Taxonomy Name 1523 * @param string $context Optional, default is display. Look at sanitize_term_field() for available options.1528 * @param string $field Term field to fetch. 1529 * @param int $term Term ID. 1530 * @param string $taxonomy Taxonomy Name. 1531 * @param string $context Optional, default is display. Look at sanitize_term_field() for available options. 1524 1532 * @return mixed Will return an empty string if $term is not an object or if $field is not set in $term. 1525 1533 */ … … 1547 1555 * @since 2.3.0 1548 1556 * 1549 * @param int|object $id Term ID or Object1550 * @param string $taxonomy Taxonomy Name1557 * @param int|object $id Term ID or object. 1558 * @param string $taxonomy Taxonomy name. 1551 1559 * @return mixed|null|WP_Error Will return empty string if $term is not an object. 1552 1560 */ … … 1569 1577 * well as control the output with a filter. 1570 1578 * 1571 * The 'get_terms'filter will be called when the cache has the term and will1579 * The {@see 'get_terms'} filter will be called when the cache has the term and will 1572 1580 * pass the found term along with the array of $taxonomies and array of $args. 1573 1581 * This filter is also called before the array of terms is passed and will pass 1574 1582 * the array of terms, along with the $taxonomies and $args. 1575 1583 * 1576 * The 'list_terms_exclusions'filter passes the compiled exclusions along with1584 * The {@see 'list_terms_exclusions'} filter passes the compiled exclusions along with 1577 1585 * the $args. 1578 1586 * 1579 * The 'get_terms_orderby' filter passes the ORDER BYclause for the query1587 * The {@see 'get_terms_orderby'} filter passes the `ORDER BY` clause for the query 1580 1588 * along with the $args array. 1581 1589 * … … 1693 1701 * @since 3.1.0 1694 1702 * 1695 * @param array $args An array of arguments.1703 * @param array $args An array of get_term() arguments. 1696 1704 * @param array $taxonomies An array of taxonomies. 1697 1705 */ … … 1725 1733 } 1726 1734 1727 // $args can be whatever, only use the args defined in defaults to compute the key 1735 // $args can be whatever, only use the args defined in defaults to compute the key. 1728 1736 $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : ''; 1729 1737 $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $filter_key ); … … 1744 1752 * @param array $cache Cached array of terms for the given taxonomy. 1745 1753 * @param array $taxonomies An array of taxonomies. 1746 * @param array $args An array of arguments to get terms.1754 * @param array $args An array of get_terms() arguments. 1747 1755 */ 1748 1756 $cache = apply_filters( 'get_terms', $cache, $taxonomies, $args ); … … 1771 1779 $orderby = 't.name'; 1772 1780 } 1781 1773 1782 /** 1774 1783 * Filter the ORDERBY clause of the terms query. … … 1776 1785 * @since 2.8.0 1777 1786 * 1778 * @param string $orderby ORDERBYclause of the terms query.1787 * @param string $orderby `ORDERBY` clause of the terms query. 1779 1788 * @param array $args An array of terms query arguments. 1780 1789 * @param array $taxonomies An array of taxonomies. … … 1848 1857 * @since 2.3.0 1849 1858 * 1850 * @param string $exclusions NOT INclause of the terms query.1859 * @param string $exclusions `NOT IN` clause of the terms query. 1851 1860 * @param array $args An array of terms query arguments. 1852 1861 * @param array $taxonomies An array of taxonomies. … … 1901 1910 $offset = $args['offset']; 1902 1911 1903 // don't limit the query results when we have to descend the family tree1912 // Don't limit the query results when we have to descend the family tree. 1904 1913 if ( $number && ! $hierarchical && ! $child_of && '' === $parent ) { 1905 1914 if ( $offset ) { … … 1976 1985 */ 1977 1986 $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args ); 1987 1978 1988 $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : ''; 1979 1989 $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : ''; … … 2033 2043 } 2034 2044 2035 // It really is empty 2045 // It really is empty. 2036 2046 unset($terms[$k]); 2037 2047 } … … 2150 2160 * @since 3.4.0 2151 2161 * 2152 * @param int|object $term1 ID or object to check if this is the parent term.2153 * @param int|object $term2 The child term.2154 * @param string $taxonomy Taxonomy name that $term1 and $term2belong to.2155 * @return bool Whether $term2 is child of $term12162 * @param int|object $term1 ID or object to check if this is the parent term. 2163 * @param int|object $term2 The child term. 2164 * @param string $taxonomy Taxonomy name that $term1 and `$term2` belong to. 2165 * @return bool Whether `$term2` is a child of `$term1`. 2156 2166 */ 2157 2167 function term_is_ancestor_of( $term1, $term2, $taxonomy ) { … … 2180 2190 * @since 2.3.0 2181 2191 * 2182 * @param array|object $term The term to check 2183 * @param string $taxonomy The taxonomy name to use 2184 * @param string $context Default is 'display'. 2185 * @return array|object Term with all fields sanitized 2192 * @param array|object $term The term to check. 2193 * @param string $taxonomy The taxonomy name to use. 2194 * @param string $context Optional. Context in which to sanitize the term. Accepts 'edit', 'db', 2195 * 'display', 'attribute', or 'js'. Default 'display'. 2196 * @return array|object Term with all fields sanitized. 2186 2197 */ 2187 2198 function sanitize_term($term, $taxonomy, $context = 'display') { … … 2228 2239 * @global wpdb $wpdb WordPress database abstraction object. 2229 2240 * 2230 * @param string $field Term field to sanitize 2231 * @param string $value Search for this term value 2232 * @param int $term_id Term ID 2233 * @param string $taxonomy Taxonomy Name 2234 * @param string $context Either edit, db, display, attribute, or js. 2235 * @return mixed sanitized field 2241 * @param string $field Term field to sanitize. 2242 * @param string $value Search for this term value. 2243 * @param int $term_id Term ID. 2244 * @param string $taxonomy Taxonomy Name. 2245 * @param string $context Context in which to sanitize the term field. Accepts 'edit', 'db', 'display', 2246 * 'attribute', or 'js'. 2247 * @return mixed Sanitized field. 2236 2248 */ 2237 2249 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { … … 2273 2285 */ 2274 2286 $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); 2287 2275 2288 if ( 'description' == $field ) 2276 2289 $value = esc_html($value); // textarea_escaped … … 2302 2315 */ 2303 2316 $value = apply_filters( "pre_{$taxonomy}_{$field}", $value ); 2317 2304 2318 // Back compat filters 2305 2319 if ( 'slug' == $field ) { … … 2333 2347 * Filter the taxonomy field for use in RSS. 2334 2348 * 2335 * The dynamic portions of the hook name, `$taxonomy`, and $field, refer2349 * The dynamic portions of the hook name, `$taxonomy`, and `$field`, refer 2336 2350 * to the taxonomy slug and field name, respectively. 2337 2351 * … … 2361 2375 * Filter the taxonomy field sanitized for display. 2362 2376 * 2363 * The dynamic portions of the filter name, `$taxonomy`, and $field, refer2377 * The dynamic portions of the filter name, `$taxonomy`, and `$field`, refer 2364 2378 * to the taxonomy slug and taxonomy field, respectively. 2365 2379 * … … 2386 2400 * Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true). 2387 2401 * 2402 * @todo Document $args as a hash notation. 2403 * 2388 2404 * @since 2.3.0 2389 2405 * … … 2416 2432 * @since 2.3.0 2417 2433 * 2418 * @param int $object_id The term Object Id that refers to the term 2434 * @param int $object_id The term Object Id that refers to the term. 2419 2435 * @param string|array $taxonomies List of Taxonomy Names or single Taxonomy name. 2420 2436 */ … … 2438 2454 * that term's parent. 2439 2455 * 2440 * The $args'default' will only override the terms found, if there is only one2456 * The `$args` 'default' will only override the terms found, if there is only one 2441 2457 * term found. Any other and the found terms are used. 2442 2458 * … … 2444 2460 * assigned even if the object was not going to be termless 2445 2461 * 2462 * @todo Document $args as a hash notation. 2463 * 2446 2464 * @since 2.3.0 2447 2465 * 2448 2466 * @global wpdb $wpdb WordPress database abstraction object. 2449 2467 * 2450 * @param int $term Term ID2451 * @param string $taxonomy Taxonomy Name2452 * @param array|string $args Optional. Change 'default' term id and override found term ids.2468 * @param int $term Term ID. 2469 * @param string $taxonomy Taxonomy Name. 2470 * @param array|string $args Optional. Change 'default' term id and override found term ids. 2453 2471 * @return bool|WP_Error Returns false if not term; true if completes delete action. 2454 2472 */ … … 2514 2532 */ 2515 2533 do_action( 'edit_term_taxonomies', $edit_tt_ids ); 2534 2516 2535 $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) ); 2517 2536 … … 2545 2564 } 2546 2565 2547 // Clean the relationship caches for all object types using this term 2566 // Clean the relationship caches for all object types using this term. 2548 2567 $tax_object = get_taxonomy( $taxonomy ); 2549 2568 foreach ( $tax_object->object_type as $object_type ) … … 2602 2621 * @param int $tt_id Term taxonomy ID. 2603 2622 * @param mixed $deleted_term Copy of the already-deleted term, in the form specified 2604 * by the parent function. {@see WP_Error}otherwise.2623 * by the parent function. WP_Error otherwise. 2605 2624 */ 2606 2625 do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term ); … … 3199 3218 * @since 3.6.0 3200 3219 * 3201 * @param int $object_id The ID of the object to which the terms will be added.3202 * @param array|int|string $terms The slug(s) or ID(s) of the term(s) to add.3203 * @param array|string $taxonomyTaxonomy name.3220 * @param int $object_id The ID of the object to which the terms will be added. 3221 * @param array|int|string $terms The slug(s) or ID(s) of the term(s) to add. 3222 * @param array|string $taxonomy Taxonomy name. 3204 3223 * @return array|WP_Error Affected Term IDs 3205 3224 */ … … 3215 3234 * @global wpdb $wpdb WordPress database abstraction object. 3216 3235 * 3217 * @param int $object_id The ID of the object from which the terms will be removed.3218 * @param array|int|string $terms The slug(s) or ID(s) of the term(s) to remove.3219 * @param array|string $taxonomyTaxonomy name.3236 * @param int $object_id The ID of the object from which the terms will be removed. 3237 * @param array|int|string $terms The slug(s) or ID(s) of the term(s) to remove. 3238 * @param array|string $taxonomy Taxonomy name. 3220 3239 * @return bool|WP_Error True on success, false or WP_Error on failure. 3221 3240 */ … … 3277 3296 */ 3278 3297 do_action( 'deleted_term_relationships', $object_id, $tt_ids ); 3298 3279 3299 wp_update_term_count( $tt_ids, $taxonomy ); 3280 3300 … … 3288 3308 * Will make slug unique, if it isn't already. 3289 3309 * 3290 * The $slughas to be unique global to every taxonomy, meaning that one3310 * The `$slug` has to be unique global to every taxonomy, meaning that one 3291 3311 * taxonomy term can't have a matching slug with another taxonomy term. Each 3292 3312 * slug has to be globally unique for every taxonomy. … … 3298 3318 * until it finds a number that is truly unique. 3299 3319 * 3300 * The only purpose for $termis for appending a parent, if one exists.3320 * The only purpose for `$term` is for appending a parent, if one exists. 3301 3321 * 3302 3322 * @since 2.3.0 … … 3304 3324 * @global wpdb $wpdb WordPress database abstraction object. 3305 3325 * 3306 * @param string $slug The string that will be tried for a unique slug 3307 * @param object $term The term object that the $slug will belong too 3326 * @param string $slug The string that will be tried for a unique slug. 3327 * @param object $term The term object that the $slug will belong too. 3308 3328 * @return string Will return a true unique slug. 3309 3329 */ 3310 function wp_unique_term_slug( $slug, $term) {3330 function wp_unique_term_slug( $slug, $term ) { 3311 3331 global $wpdb; 3312 3332 … … 3319 3339 } 3320 3340 3321 // If the taxonomy supports hierarchy and the term has a parent, make the slug unique 3322 // by incorporating parent slugs. 3341 /* 3342 * If the taxonomy supports hierarchy and the term has a parent, make the slug unique 3343 * by incorporating parent slugs. 3344 */ 3323 3345 if ( is_taxonomy_hierarchical($term->taxonomy) && !empty($term->parent) ) { 3324 3346 $the_parent = $term->parent; … … 3374 3396 * will be created for you. 3375 3397 * 3376 * For what can be overrode in $args, check the term scheme can contain and stay3398 * For what can be overrode in `$args`, check the term scheme can contain and stay 3377 3399 * away from the term keys. 3378 3400 * … … 3381 3403 * @global wpdb $wpdb WordPress database abstraction object. 3382 3404 * 3383 * @param int $term_idThe ID of the term3384 * @param string $taxonomy The context in which to relate the term to the object.3385 * @param array|string $args Overwrite term field values3405 * @param int $term_id The ID of the term 3406 * @param string $taxonomy The context in which to relate the term to the object. 3407 * @param array|string $args Optional. Array of get_terms() arguments. Default empty array. 3386 3408 * @return array|WP_Error Returns Term ID and Taxonomy Term ID 3387 3409 */ … … 3530 3552 */ 3531 3553 do_action( 'edit_term_taxonomy', $tt_id, $taxonomy ); 3554 3532 3555 $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) ); 3533 3556 … … 3542 3565 do_action( 'edited_term_taxonomy', $tt_id, $taxonomy ); 3543 3566 3544 // Clean the relationship caches for all object types using this term 3567 // Clean the relationship caches for all object types using this term. 3545 3568 $objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) ); 3546 3569 $tax_object = get_taxonomy( $taxonomy ); … … 3639 3662 * @global wpdb $wpdb WordPress database abstraction object. 3640 3663 * 3641 * @param int|array $terms The term_taxonomy_id of the terms3642 * @param string $taxonomy The context of the term.3664 * @param int|array $terms The term_taxonomy_id of the terms. 3665 * @param string $taxonomy The context of the term. 3643 3666 * @return bool If no terms will return false, and if successful will return true. 3644 3667 */ … … 3674 3697 * @since 2.5.0 3675 3698 * 3676 * @param array $termsThe term_taxonomy_id of terms to update.3699 * @param array $terms The term_taxonomy_id of terms to update. 3677 3700 * @param string $taxonomy The context of the term. 3678 3701 * @return bool Always true when complete. … … 3712 3735 * Removes the taxonomy relationship to terms from the cache. 3713 3736 * 3714 * Will remove the entire taxonomy relationship containing term $object_id. The3715 * term IDs have to exist within the taxonomy $object_typefor the deletion to3737 * Will remove the entire taxonomy relationship containing term `$object_id`. The 3738 * term IDs have to exist within the taxonomy `$object_type` for the deletion to 3716 3739 * take place. 3717 3740 * 3718 3741 * @since 2.3.0 3719 3742 * 3720 * @see get_object_taxonomies() for more on $object_type 3721 * 3722 * @param int|array $object_ids Single or list of term object ID(s)3723 * @param array|string $object_type The taxonomy object type 3743 * @see get_object_taxonomies() for more on $object_type. 3744 * 3745 * @param int|array $object_ids Single or list of term object ID(s). 3746 * @param array|string $object_type The taxonomy object type. 3724 3747 */ 3725 3748 function clean_object_term_cache($object_ids, $object_type) { … … 3753 3776 * @global wpdb $wpdb WordPress database abstraction object. 3754 3777 * 3755 * @param int|array $ids Single or list of Term IDs 3756 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context. 3757 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true. 3778 * @param int|array $ids Single or list of Term IDs. 3779 * @param string $taxonomy Optional. Can be empty and will assume `tt_ids`, else will use for context. 3780 * Default empty. 3781 * @param bool $clean_taxonomy Optional. Whether to clean taxonomy wide caches (true), or just individual 3782 * term object caches (false). Default true. 3758 3783 */ 3759 3784 function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { … … 3813 3838 * @since 2.3.0 3814 3839 * 3815 * @param int $id Term object ID 3816 * @param string $taxonomy Taxonomy Name 3817 * @return bool|array Empty array if $terms found, but not $taxonomy. False if nothing is in cache for $taxonomy and $id. 3818 */ 3819 function get_object_term_cache($id, $taxonomy) { 3840 * @param int $id Term object ID. 3841 * @param string $taxonomy Taxonomy name. 3842 * @return bool|array Empty array if $terms found, but not `$taxonomy`. False if nothing is in cache 3843 * for `$taxonomy` and `$id`. 3844 */ 3845 function get_object_term_cache( $id, $taxonomy ) { 3820 3846 $cache = wp_cache_get($id, "{$taxonomy}_relationships"); 3821 3847 return $cache; … … 3834 3860 * @since 2.3.0 3835 3861 * 3836 * @param string|array $object_ids Comma-separated list or array of term object IDs. .3862 * @param string|array $object_ids Comma-separated list or array of term object IDs. 3837 3863 * @param array|string $object_type The taxonomy object type. 3838 3864 * @return null|false Null if `$object_ids` is empty, false if all of the terms in … … 3891 3917 * @since 2.3.0 3892 3918 * 3893 * @param array $terms List of Term objects to change3894 * @param string $taxonomy Optional. Update Term to this taxonomy in cache 3895 */ 3896 function update_term_cache( $terms, $taxonomy = '') {3919 * @param array $terms List of term objects to change. 3920 * @param string $taxonomy Optional. Update Term to this taxonomy in cache. Default empty. 3921 */ 3922 function update_term_cache( $terms, $taxonomy = '' ) { 3897 3923 foreach ( (array) $terms as $term ) { 3898 3924 $term_taxonomy = $taxonomy; … … 3911 3937 * Retrieves children of taxonomy as Term IDs. 3912 3938 * 3913 * @ access private3939 * @ignore 3914 3940 * @since 2.3.0 3915 3941 * 3916 * @param string $taxonomy Taxonomy Name3942 * @param string $taxonomy Taxonomy name. 3917 3943 * @return array Empty if $taxonomy isn't hierarchical or returns children as Term IDs. 3918 3944 */ 3919 function _get_term_hierarchy( $taxonomy) {3945 function _get_term_hierarchy( $taxonomy ) { 3920 3946 if ( !is_taxonomy_hierarchical($taxonomy) ) 3921 3947 return array(); … … 3938 3964 * Get the subset of $terms that are descendants of $term_id. 3939 3965 * 3940 * If $terms is an array of objects, then _get_term_childrenreturns an array of objects.3941 * If $terms is an array of IDs, then _get_term_childrenreturns an array of IDs.3966 * If `$terms` is an array of objects, then _get_term_children() returns an array of objects. 3967 * If `$terms` is an array of IDs, then _get_term_children() returns an array of IDs. 3942 3968 * 3943 3969 * @access private 3944 3970 * @since 2.3.0 3945 3971 * 3946 * @param int $term_id The ancestor term: all returned terms should be descendants of $term_id.3972 * @param int $term_id The ancestor term: all returned terms should be descendants of `$term_id`. 3947 3973 * @param array $terms The set of terms - either an array of term objects or term IDs - from which those that 3948 3974 * are descendants of $term_id will be chosen. 3949 3975 * @param string $taxonomy The taxonomy which determines the hierarchy of the terms. 3950 * @param array $ancestors Term ancestors that have already been identified. Passed by reference, to keep track of 3951 * found terms when recursing the hierarchy. The array of located ancestors is used to prevent 3952 * infinite recursion loops. For performance, term_ids are used as array keys, with 1 as value. 3976 * @param array $ancestors Optional. Term ancestors that have already been identified. Passed by reference, to keep 3977 * track of found terms when recursing the hierarchy. The array of located ancestors is used 3978 * to prevent infinite recursion loops. For performance, `term_ids` are used as array keys, 3979 * with 1 as value. Default empty array. 3953 3980 * @return array The subset of $terms that are descendants of $term_id. 3954 3981 */ … … 4013 4040 * @global wpdb $wpdb WordPress database abstraction object. 4014 4041 * 4015 * @param array $terms List of Term IDs4016 * @param string $taxonomy Term Context4042 * @param array $terms List of term IDs, passed by reference. 4043 * @param string $taxonomy Term context. 4017 4044 * @return null Will break from function if conditions are not met. 4018 4045 */ 4019 function _pad_term_counts( &$terms, $taxonomy) {4046 function _pad_term_counts( &$terms, $taxonomy ) { 4020 4047 global $wpdb; 4021 4048 … … 4038 4065 } 4039 4066 4040 // Get the object and term ids and stick them in a lookup table 4067 // Get the object and term ids and stick them in a lookup table. 4041 4068 $tax_obj = get_taxonomy($taxonomy); 4042 4069 $object_types = esc_sql($tax_obj->object_type); … … 4047 4074 } 4048 4075 4049 // Touch every ancestor's lookup row for each post in each term 4076 // Touch every ancestor's lookup row for each post in each term. 4050 4077 foreach ( $term_ids as $term_id ) { 4051 4078 $child = $term_id; … … 4065 4092 } 4066 4093 4067 // Transfer the touched cells 4094 // Transfer the touched cells. 4068 4095 foreach ( (array) $term_items as $id => $items ) 4069 4096 if ( isset($terms_by_id[$id]) ) … … 4086 4113 * @global wpdb $wpdb WordPress database abstraction object. 4087 4114 * 4088 * @param array $terms List of Term taxonomy IDs 4089 * @param object $taxonomy Current taxonomy object of terms 4115 * @param array $terms List of Term taxonomy IDs. 4116 * @param object $taxonomy Current taxonomy object of terms. 4090 4117 */ 4091 4118 function _update_post_term_count( $terms, $taxonomy ) { … … 4110 4137 $count = 0; 4111 4138 4112 // Attachments can be 'inherit' status, we need to base count off the parent's status if so 4139 // Attachments can be 'inherit' status, we need to base count off the parent's status if so. 4113 4140 if ( $check_attachments ) 4114 4141 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) ); … … 4129 4156 * Will update term count based on number of objects. 4130 4157 * 4131 * Default callback for the link_categorytaxonomy.4158 * Default callback for the 'link_category' taxonomy. 4132 4159 * 4133 4160 * @since 3.3.0 … … 4135 4162 * @global wpdb $wpdb WordPress database abstraction object. 4136 4163 * 4137 * @param array $terms List of Term taxonomy IDs4138 * @param object $taxonomy Current taxonomy object of terms 4164 * @param array $terms List of term taxonomy IDs. 4165 * @param object $taxonomy Current taxonomy object of terms. 4139 4166 */ 4140 4167 function _update_generic_term_count( $terms, $taxonomy ) { … … 4356 4383 * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist. 4357 4384 */ 4358 function get_term_link( $term, $taxonomy = '' ) {4385 function get_term_link( $term, $taxonomy = '' ) { 4359 4386 global $wp_rewrite; 4360 4387 … … 4453 4480 * 4454 4481 * @param array $args { 4455 * Arguments about which post to use and how to format the output. Shares all of the arguments supported by4456 * {@link get_the_taxonomies()}, in addition to the following.4482 * Arguments about which post to use and how to format the output. Shares all of the arguments 4483 * supported by get_the_taxonomies(), in addition to the following. 4457 4484 * 4458 4485 * @type int|WP_Post $post Post ID or object to get taxonomies of. Default current post. … … 4486 4513 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. 4487 4514 * @param array $args { 4488 * Arguments about how to format the list of taxonomies.4515 * Optional. Arguments about how to format the list of taxonomies. Default empty array. 4489 4516 * 4490 4517 * @type string $template Template for displaying a taxonomy label and list of terms. … … 4564 4591 * @since 2.7.0 4565 4592 * 4566 * @param int $object_id ID of the object (post ID, link ID, ...)4567 * @param string $taxonomy Single taxonomy name4568 * @param int|string|array $terms Optional. Term term_id, name, slug or array of said4593 * @param int $object_id ID of the object (post ID, link ID, ...). 4594 * @param string $taxonomy Single taxonomy name. 4595 * @param int|string|array $terms Optional. Term term_id, name, slug or array of said. Default null. 4569 4596 * @return bool|WP_Error WP_Error on input error. 4570 4597 */ … … 4617 4644 * @since 3.0.0 4618 4645 * 4619 * @param string $object_type Object type string 4620 * @param string $taxonomy Single taxonomy name4646 * @param string $object_type Object type string. 4647 * @param string $taxonomy Single taxonomy name. 4621 4648 * @return bool True if object is associated with the taxonomy, otherwise false. 4622 4649 */ … … 4690 4717 4691 4718 /** 4692 * Returns the term's parent's term_ID 4719 * Returns the term's parent's term_ID. 4693 4720 * 4694 4721 * @since 3.1.0 4695 4722 * 4696 * @param int $term_id 4697 * @param string $taxonomy 4698 * 4699 * @return int|bool false on error 4723 * @param int $term_id Term ID. 4724 * @param string $taxonomy Taxonomy name. 4725 * @return int|bool False on error. 4700 4726 */ 4701 4727 function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) { … … 4710 4736 * Prevents loops from forming and breaks those that it finds. 4711 4737 * 4712 * Attached to the wp_update_term_parentfilter.4738 * Attached to the {@see 'wp_update_term_parent'} filter. 4713 4739 * 4714 4740 * @since 3.1.0 4715 4741 * 4716 * @param int $parent term_idof the parent for the term we're checking.4717 * @param int $term_idThe term we're checking.4742 * @param int $parent `term_id` of the parent for the term we're checking. 4743 * @param int $term_id The term we're checking. 4718 4744 * @param string $taxonomy The taxonomy of the term we're checking. 4719 4745 * … … 4725 4751 return 0; 4726 4752 4727 // Can't be its own parent 4753 // Can't be its own parent. 4728 4754 if ( $parent == $term_id ) 4729 4755 return 0; 4730 4756 4731 // Now look for larger loops 4732 4757 // Now look for larger loops. 4733 4758 if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) ) 4734 4759 return $parent; // No loop 4735 4760 4736 // Setting $parent to the given value causes a loop 4761 // Setting $parent to the given value causes a loop. 4737 4762 if ( isset( $loop[$term_id] ) ) 4738 4763 return 0;
Note: See TracChangeset
for help on using the changeset viewer.