Changeset 27827 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 03/28/2014 09:28:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r27473 r27827 25 25 $rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false ); 26 26 } else { 27 28 /** 29 * Filter the post formats rewrite base. 30 * 31 * @since 3.1.0 32 * 33 * @param string $context Context of the rewrite base. Default 'type'. 34 */ 27 35 $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' ); 28 36 $rewrite = array( … … 413 421 add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' ); 414 422 423 /** 424 * Fires after a taxonomy is registered. 425 * 426 * @since 3.3.0 427 * 428 * @param string $taxonomy Taxonomy slug. 429 * @param array|string $object_type Object type or array of object types. 430 * @param array|string $args Array or string of taxonomy registration arguments. 431 */ 415 432 do_action( 'registered_taxonomy', $taxonomy, $object_type, $args ); 416 433 } … … 947 964 } 948 965 949 $_term = apply_filters('get_term', $_term, $taxonomy); 950 $_term = apply_filters("get_$taxonomy", $_term, $taxonomy); 966 /** 967 * Filter a term. 968 * 969 * @since 2.3.0 970 * 971 * @param int|object $_term Term object or ID. 972 * @param string $taxonomy The taxonomy slug. 973 */ 974 $_term = apply_filters( 'get_term', $_term, $taxonomy ); 975 976 /** 977 * Filter a taxonomy. 978 * 979 * The dynamic portion of the filter name, $taxonomy, refers 980 * to the taxonomy slug. 981 * 982 * @since 2.3.0 983 * 984 * @param int|object $_term Term object or ID. 985 * @param string $taxonomy The taxonomy slug. 986 */ 987 $_term = apply_filters( "get_$taxonomy", $_term, $taxonomy ); 951 988 $_term = sanitize_term($_term, $taxonomy, $filter); 952 989 … … 1020 1057 wp_cache_add($term->term_id, $term, $taxonomy); 1021 1058 1022 $term = apply_filters('get_term', $term, $taxonomy); 1023 $term = apply_filters("get_$taxonomy", $term, $taxonomy); 1059 /** This filter is documented in wp-includes/taxonomy.php */ 1060 $term = apply_filters( 'get_term', $term, $taxonomy ); 1061 1062 /** This filter is documented in wp-includes/taxonomy.php */ 1063 $term = apply_filters( "get_$taxonomy", $term, $taxonomy ); 1064 1024 1065 $term = sanitize_term($term, $taxonomy, $filter); 1025 1066 … … 1267 1308 } 1268 1309 1310 /** 1311 * Filter the terms query arguments. 1312 * 1313 * @since 3.1.0 1314 * 1315 * @param array $args An array of arguments. 1316 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1317 */ 1269 1318 $args = apply_filters( 'get_terms_args', $args, $taxonomies ); 1270 1319 … … 1294 1343 $cache = wp_cache_get( $cache_key, 'terms' ); 1295 1344 if ( false !== $cache ) { 1296 $cache = apply_filters('get_terms', $cache, $taxonomies, $args); 1345 1346 /** 1347 * Filter the given taxonomy's terms cache. 1348 * 1349 * @since 2.3.0 1350 * 1351 * @param array $cache Cached array of terms for the given taxonomy. 1352 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1353 * @param array $args An array of arguments to get terms. 1354 */ 1355 $cache = apply_filters( 'get_terms', $cache, $taxonomies, $args ); 1297 1356 return $cache; 1298 1357 } … … 1314 1373 $orderby = 't.name'; 1315 1374 1375 /** 1376 * Filter the ORDERBY clause of the terms query. 1377 * 1378 * @since 2.8.0 1379 * 1380 * @param string $orderby ORDERBY clause of the terms query. 1381 * @param array $args An array of terms query arguments. 1382 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1383 */ 1316 1384 $orderby = apply_filters( 'get_terms_orderby', $orderby, $args, $taxonomies ); 1317 1385 … … 1362 1430 $exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')'; 1363 1431 1432 /** 1433 * Filter the terms to exclude from the terms query. 1434 * 1435 * @since 2.3.0 1436 * 1437 * @param string $exclusions NOT IN clause of the terms query. 1438 * @param array $args An array of terms query arguments. 1439 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1440 */ 1364 1441 $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies ); 1365 1442 … … 1435 1512 $_fields = $fields; 1436 1513 1514 /** 1515 * Filter the fields to select in the terms query. 1516 * 1517 * @since 2.8.0 1518 * 1519 * @param array $selects An array of fields to select for the terms query. 1520 * @param array $args An array of term query arguments. 1521 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1522 */ 1437 1523 $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) ); 1438 1524 … … 1440 1526 1441 1527 $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' ); 1528 1529 /** 1530 * Filter the terms query SQL clauses. 1531 * 1532 * @since 3.1.0 1533 * 1534 * @param array $pieces Terms query SQL clauses. 1535 * @param string|array $taxonomies A taxonomy or array of taxonomies. 1536 * @param array $args An array of terms query arguments. 1537 */ 1442 1538 $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args ); 1443 1539 foreach ( $pieces as $piece ) … … 1460 1556 if ( empty($terms) ) { 1461 1557 wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS ); 1462 $terms = apply_filters('get_terms', array(), $taxonomies, $args); 1558 1559 /** This filter is documented in wp-includes/taxonomy.php */ 1560 $terms = apply_filters( 'get_terms', array(), $taxonomies, $args ); 1463 1561 return $terms; 1464 1562 } … … 1521 1619 wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS ); 1522 1620 1621 /** This filter is documented in wp-includes/taxonomy */ 1523 1622 $terms = apply_filters( 'get_terms', $terms, $taxonomies, $args ); 1524 1623 return $terms; … … 1695 1794 1696 1795 if ( 'edit' == $context ) { 1697 $value = apply_filters("edit_term_{$field}", $value, $term_id, $taxonomy); 1698 $value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id); 1796 1797 /** 1798 * Filter a term field to edit before it is sanitized. 1799 * 1800 * The dynamic portion of the filter name, $field, refers to the term field. 1801 * 1802 * @since 2.3.0 1803 * 1804 * @param mixed $value Value of the term field. 1805 * @param int $term_id Term ID. 1806 * @param string $taxonomy Taxonomy slug. 1807 */ 1808 $value = apply_filters( "edit_term_{$field}", $value, $term_id, $taxonomy ); 1809 1810 /** 1811 * Filter the taxonomy field to edit before it is sanitized. 1812 * 1813 * The dynamic portions of the filter name, $taxonomy, and $field, refer 1814 * to the taxonomy slug and taxonomy field, respectively. 1815 * 1816 * @since 2.3.0 1817 * 1818 * @param mixed $value Value of the taxonomy field to edit. 1819 * @param int $term_id Term ID. 1820 */ 1821 $value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id ); 1699 1822 if ( 'description' == $field ) 1700 1823 $value = esc_html($value); // textarea_escaped … … 1702 1825 $value = esc_attr($value); 1703 1826 } else if ( 'db' == $context ) { 1704 $value = apply_filters("pre_term_{$field}", $value, $taxonomy); 1705 $value = apply_filters("pre_{$taxonomy}_{$field}", $value); 1827 1828 /** 1829 * Filter a term field value before it is sanitized. 1830 * 1831 * The dynamic portion of the filter name, $field, refers to the term field. 1832 * 1833 * @since 2.3.0 1834 * 1835 * @param mixed $value Value of the term field. 1836 * @param string $taxonomy Taxonomy slug. 1837 */ 1838 $value = apply_filters( "pre_term_{$field}", $value, $taxonomy ); 1839 1840 /** 1841 * Filter a taxonomy field before it is sanitized. 1842 * 1843 * The dynamic portions of the filter name, $taxonomy, and $field, refer 1844 * to the taxonomy slug and field name, respectively. 1845 * 1846 * @since 2.3.0 1847 * 1848 * @param mixed $value Value of the taxonomy field. 1849 */ 1850 $value = apply_filters( "pre_{$taxonomy}_{$field}", $value ); 1706 1851 // Back compat filters 1707 if ( 'slug' == $field ) 1708 $value = apply_filters('pre_category_nicename', $value); 1852 if ( 'slug' == $field ) { 1853 /** 1854 * Filter the category nicename before it is sanitized. 1855 * 1856 * Use the pre_{$taxonomy}_{$field} hook instead. 1857 * 1858 * @since 2.0.3 1859 * 1860 * @param string $value The category nicename. 1861 */ 1862 $value = apply_filters( 'pre_category_nicename', $value ); 1863 } 1709 1864 1710 1865 } else if ( 'rss' == $context ) { 1711 $value = apply_filters("term_{$field}_rss", $value, $taxonomy); 1712 $value = apply_filters("{$taxonomy}_{$field}_rss", $value); 1866 1867 /** 1868 * Filter the term field for use in RSS. 1869 * 1870 * The dynamic portion of the filter name, $field, refers to the term field. 1871 * 1872 * @since 2.3.0 1873 * 1874 * @param mixed $value Value of the term field. 1875 * @param string $taxonomy Taxonomy slug. 1876 */ 1877 $value = apply_filters( "term_{$field}_rss", $value, $taxonomy ); 1878 1879 /** 1880 * Filter the taxonomy field for use in RSS. 1881 * 1882 * The dynamic portions of the hook name, $taxonomy, and $field, refer 1883 * to the taxonomy slug and field name, respectively. 1884 * 1885 * @since 2.3.0 1886 * 1887 * @param mixed $value Value of the taxonomy field. 1888 */ 1889 $value = apply_filters( "{$taxonomy}_{$field}_rss", $value ); 1713 1890 } else { 1714 1891 // Use display filters by default. 1715 $value = apply_filters("term_{$field}", $value, $term_id, $taxonomy, $context); 1716 $value = apply_filters("{$taxonomy}_{$field}", $value, $term_id, $context); 1892 1893 /** 1894 * Filter the term field sanitized for display. 1895 * 1896 * The dynamic portion of the filter name, $field, refers to the term field name. 1897 * 1898 * @since 2.3.0 1899 * 1900 * @param mixed $value Value of the term field. 1901 * @param int $term_id Term ID. 1902 * @param string $taxonomy Taxonomy slug. 1903 * @param string $context Context to retrieve the term field value. 1904 */ 1905 $value = apply_filters( "term_{$field}", $value, $term_id, $taxonomy, $context ); 1906 1907 /** 1908 * Filter the taxonomy field sanitized for display. 1909 * 1910 * The dynamic portions of the filter name, $taxonomy, and $field, refer 1911 * to the taxonomy slug and taxonomy field, respectively. 1912 * 1913 * @since 2.3.0 1914 * 1915 * @param mixed $value Value of the taxonomy field. 1916 * @param int $term_id Term ID. 1917 * @param string $context Context to retrieve the taxonomy field value. 1918 */ 1919 $value = apply_filters( "{$taxonomy}_{$field}", $value, $term_id, $context ); 1717 1920 } 1718 1921 … … 1795 1998 * 1796 1999 * @uses $wpdb 1797 * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action1798 * hooks, passing term ID, term taxonomy ID, and deleted term object. 'delete_term'1799 * also gets taxonomy as the third parameter.1800 2000 * 1801 2001 * @param int $term Term ID … … 1841 2041 1842 2042 $edit_tt_ids = $wpdb->get_col( "SELECT `term_taxonomy_id` FROM $wpdb->term_taxonomy WHERE `parent` = " . (int)$term_obj->term_id ); 2043 2044 /** 2045 * Fires immediately before a term to delete's children are reassigned a parent. 2046 * 2047 * @since 2.9.0 2048 * 2049 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term. 2050 */ 1843 2051 do_action( 'edit_term_taxonomies', $edit_tt_ids ); 1844 2052 $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) ); 2053 2054 /** 2055 * Fires immediately after a term to delete's children are reassigned a parent. 2056 * 2057 * @since 2.9.0 2058 * 2059 * @param array $edit_tt_ids An array of term taxonomy IDs for the given term. 2060 */ 1845 2061 do_action( 'edited_term_taxonomies', $edit_tt_ids ); 1846 2062 } … … 1869 2085 $deleted_term = get_term( $term, $taxonomy ); 1870 2086 2087 /** 2088 * Fires immediately before a term taxonomy ID is deleted. 2089 * 2090 * @since 2.9.0 2091 * 2092 * @param int $tt_id Term taxonomy ID. 2093 */ 1871 2094 do_action( 'delete_term_taxonomy', $tt_id ); 1872 2095 $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) ); 2096 2097 /** 2098 * Fires immediately after a term taxonomy ID is deleted. 2099 * 2100 * @since 2.9.0 2101 * 2102 * @param int $tt_id Term taxonomy ID. 2103 */ 1873 2104 do_action( 'deleted_term_taxonomy', $tt_id ); 1874 2105 … … 1879 2110 clean_term_cache($term, $taxonomy); 1880 2111 2112 /** 2113 * Fires after a term is deleted from the database and the cache is cleaned. 2114 * 2115 * @since 2.5.0 2116 * 2117 * @param int $term Term ID. 2118 * @param int $tt_id Term taxonomy ID. 2119 * @param string $taxonomy Taxonomy slug. 2120 * @param mixed $deleted_term Copy of the already-deleted term, in the form specified 2121 * by the parent function. WP_Error otherwise. 2122 */ 1881 2123 do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term ); 2124 2125 /** 2126 * Fires after a term in a specific taxonomy is deleted. 2127 * 2128 * The dynamic portion of the hook name, $taxonomy, refers to the specific 2129 * taxonomy the term belonged to. 2130 * 2131 * @since 2.3.0 2132 * 2133 * @param int $term Term ID. 2134 * @param int $tt_id Term taxonomy ID. 2135 * @param mixed $deleted_term Copy of the already-deleted term, in the form specified 2136 * by the parent function. WP_Error otherwise. 2137 */ 1882 2138 do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term ); 1883 2139 … … 2036 2292 $terms = array(); 2037 2293 2038 return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args); 2294 /** 2295 * Filter the terms for a given object or objects. 2296 * 2297 * @since 2.8.0 2298 * 2299 * @param array $terms An array of terms for the given object or objects. 2300 * @param array|int $object_ids Object ID or array of IDs. 2301 * @param array|string $taxonomies A taxonomy or array of taxonomies. 2302 * @param array $args An array of arguments for retrieving terms for 2303 * the given object(s). 2304 */ 2305 return apply_filters( 'wp_get_object_terms', $terms, $object_ids, $taxonomies, $args ); 2039 2306 } 2040 2307 … … 2090 2357 return new WP_Error('invalid_taxonomy', __('Invalid taxonomy')); 2091 2358 2359 /** 2360 * Filter a term before it is sanitized and inserted into the database. 2361 * 2362 * @since 3.0.0 2363 * 2364 * @param string $term The term to add or update. 2365 * @param string $taxonomy Taxonomy slug. 2366 */ 2092 2367 $term = apply_filters( 'pre_insert_term', $term, $taxonomy ); 2093 2368 if ( is_wp_error( $term ) ) … … 2125 2400 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 2126 2401 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 2402 2403 /** 2404 * Fires immediately before the given terms are edited. 2405 * 2406 * @since 2.9.0 2407 * 2408 * @param int $term_id Term ID. 2409 * @param string $taxonomy Taxonomy slug. 2410 */ 2127 2411 do_action( 'edit_terms', $alias->term_id, $taxonomy ); 2128 2412 $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); 2413 2414 /** 2415 * Fires immediately after the given terms are edited. 2416 * 2417 * @since 2.9.0 2418 * 2419 * @param int $term_id Term ID 2420 * @param string $taxonomy Taxonomy slug. 2421 */ 2129 2422 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2130 2423 } … … 2170 2463 if ( empty($slug) ) { 2171 2464 $slug = sanitize_title($slug, $term_id); 2465 2466 /** This action is documented in wp-includes/taxonomy.php */ 2172 2467 do_action( 'edit_terms', $term_id, $taxonomy ); 2173 2468 $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); 2469 2470 /** This action is documented in wp-includes/taxonomy.php */ 2174 2471 do_action( 'edited_terms', $term_id, $taxonomy ); 2175 2472 } … … 2183 2480 $tt_id = (int) $wpdb->insert_id; 2184 2481 2185 do_action("create_term", $term_id, $tt_id, $taxonomy); 2186 do_action("create_$taxonomy", $term_id, $tt_id); 2187 2188 $term_id = apply_filters('term_id_filter', $term_id, $tt_id); 2482 /** 2483 * Fires immediately after a new term is created, before the term cache is cleaned. 2484 * 2485 * @since 2.3.0 2486 * 2487 * @param int $term_id Term ID. 2488 * @param int $tt_id Term taxonomy ID. 2489 * @param string $taxonomy Taxonomy slug. 2490 */ 2491 do_action( "create_term", $term_id, $tt_id, $taxonomy ); 2492 2493 /** 2494 * Fires after a new term is created for a specific taxonomy. 2495 * 2496 * The dynamic portion of the hook name, $taxonomy, refers 2497 * to the slug of the taxonomy the term was created for. 2498 * 2499 * @since 2.3.0 2500 * 2501 * @param int $term_id Term ID. 2502 * @param int $tt_id Term taxonomy ID. 2503 */ 2504 do_action( "create_$taxonomy", $term_id, $tt_id ); 2505 2506 /** 2507 * Filter the term ID after a new term is created. 2508 * 2509 * @since 2.3.0 2510 * 2511 * @param int $term_id Term ID. 2512 * @param int $tt_id Taxonomy term ID. 2513 */ 2514 $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id ); 2189 2515 2190 2516 clean_term_cache($term_id, $taxonomy); 2191 2517 2192 do_action("created_term", $term_id, $tt_id, $taxonomy); 2193 do_action("created_$taxonomy", $term_id, $tt_id); 2518 /** 2519 * Fires after a new term is created, and after the term cache has been cleaned. 2520 * 2521 * @since 2.3.0 2522 */ 2523 do_action( "created_term", $term_id, $tt_id, $taxonomy ); 2524 2525 /** 2526 * Fires after a new term in a specific taxonomy is created, and after the term 2527 * cache has been cleaned. 2528 * 2529 * @since 2.3.0 2530 * 2531 * @param int $term_id Term ID. 2532 * @param int $tt_id Term taxonomy ID. 2533 */ 2534 do_action( "created_$taxonomy", $term_id, $tt_id ); 2194 2535 2195 2536 return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); … … 2255 2596 if ( $wpdb->get_var( $wpdb->prepare( "SELECT term_taxonomy_id FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id = %d", $object_id, $tt_id ) ) ) 2256 2597 continue; 2598 2599 /** 2600 * Fires immediately before an object-term relationship is added. 2601 * 2602 * @since 2.9.0 2603 * 2604 * @param int $object_id Object ID. 2605 * @param int $tt_id Term taxonomy ID. 2606 */ 2257 2607 do_action( 'add_term_relationship', $object_id, $tt_id ); 2258 2608 $wpdb->insert( $wpdb->term_relationships, array( 'object_id' => $object_id, 'term_taxonomy_id' => $tt_id ) ); 2609 2610 /** 2611 * Fires immediately after an object-term relationship is added. 2612 * 2613 * @since 2.9.0 2614 * 2615 * @param int $object_id Object ID. 2616 * @param int $tt_id Term taxonomy ID. 2617 */ 2259 2618 do_action( 'added_term_relationship', $object_id, $tt_id ); 2260 2619 $new_tt_ids[] = $tt_id; … … 2294 2653 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2295 2654 2296 do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); 2655 /** 2656 * Fires after an object's terms have been set. 2657 * 2658 * @since 2.8.0 2659 * 2660 * @param int $object_id Object ID. 2661 * @param array $terms An array of object terms. 2662 * @param array $tt_ids An array of term taxonomy IDs. 2663 * @param string $taxonomy Taxonomy slug. 2664 * @param bool $append Whether to append new terms to the old terms. 2665 * @param array $old_tt_ids Old array of term taxonomy IDs. 2666 */ 2667 do_action( 'set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ); 2297 2668 return $tt_ids; 2298 2669 } … … 2318 2689 * @since 3.6.0 2319 2690 * @uses $wpdb 2320 *2321 * @uses apply_filters() Calls 'delete_term_relationships' hook with object_id and tt_ids as parameters.2322 * @uses apply_filters() Calls 'deleted_term_relationships' hook with object_id and tt_ids as parameters.2323 2691 * 2324 2692 * @param int $object_id The ID of the object from which the terms will be removed. … … 2363 2731 if ( $tt_ids ) { 2364 2732 $in_tt_ids = "'" . implode( "', '", $tt_ids ) . "'"; 2733 2734 /** 2735 * Fires immediately before an object-term relationship is deleted. 2736 * 2737 * @since 2.9.0 2738 * 2739 * @param int $object_id Object ID. 2740 * @param array $tt_ids An array of term taxonomy IDs. 2741 */ 2365 2742 do_action( 'delete_term_relationships', $object_id, $tt_ids ); 2366 2743 $deleted = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->term_relationships WHERE object_id = %d AND term_taxonomy_id IN ($in_tt_ids)", $object_id ) ); 2744 2745 /** 2746 * Fires immediately after an object-term relationship is deleted. 2747 * 2748 * @since 2.9.0 2749 * 2750 * @param int $object_id Object ID. 2751 * @param array $tt_ids An array of term taxonomy IDs. 2752 */ 2367 2753 do_action( 'deleted_term_relationships', $object_id, $tt_ids ); 2368 2754 wp_update_term_count( $tt_ids, $taxonomy ); … … 2463 2849 * 2464 2850 * @uses $wpdb 2465 * @uses do_action() Will call both 'edit_term' and 'edit_$taxonomy' twice.2466 * @uses apply_filters() Will call the 'term_id_filter' filter and pass the term2467 * id and taxonomy id.2468 2851 * 2469 2852 * @param int $term_id The ID of the term … … 2518 2901 // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. 2519 2902 $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; 2903 2904 /** This action is documented in wp-includes/taxonomy.php */ 2520 2905 do_action( 'edit_terms', $alias->term_id, $taxonomy ); 2521 2906 $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); 2907 2908 /** This action is documented in wp-includes/taxonomy.php */ 2522 2909 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2523 2910 } 2524 2911 } 2525 2912 2526 // Check $parent to see if it will cause a hierarchy loop 2913 /** 2914 * Filter the term parent. 2915 * 2916 * Hook to this filter to see if it will cause a hierarchy loop. 2917 * 2918 * @since 3.1.0 2919 * 2920 * @param int $parent ID of the parent term. 2921 * @param int $term_id Term ID. 2922 * @param string $taxonomy Taxonomy slug. 2923 * @param array $args Compacted array of update arguments for the given term. 2924 * @param array $args An array of update arguments for the given term. 2925 */ 2527 2926 $parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args ); 2528 2927 … … 2537 2936 return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); 2538 2937 } 2938 2939 /** This action is documented in wp-includes/taxonomy.php */ 2539 2940 do_action( 'edit_terms', $term_id, $taxonomy ); 2540 2941 $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); … … 2543 2944 $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); 2544 2945 } 2946 2947 /** This action is documented in wp-includes/taxonomy.php */ 2545 2948 do_action( 'edited_terms', $term_id, $taxonomy ); 2546 2949 2547 2950 $tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id) ); 2951 2952 /** 2953 * Fires immediate before a term-taxonomy relationship is updated. 2954 * 2955 * @since 2.9.0 2956 * 2957 * @param int $tt_id Term taxonomy ID. 2958 * @param string $taxonomy Taxonomy slug. 2959 */ 2548 2960 do_action( 'edit_term_taxonomy', $tt_id, $taxonomy ); 2549 2961 $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) ); 2962 2963 /** 2964 * Fires immediately after a term-taxonomy relationship is updated. 2965 * 2966 * @since 2.9.0 2967 * 2968 * @param int $tt_id Term taxonomy ID. 2969 * @param string $taxonomy Taxonomy slug. 2970 */ 2550 2971 do_action( 'edited_term_taxonomy', $tt_id, $taxonomy ); 2551 2972 … … 2553 2974 $objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) ); 2554 2975 $tax_object = get_taxonomy( $taxonomy ); 2555 foreach ( $tax_object->object_type as $object_type ) 2976 foreach ( $tax_object->object_type as $object_type ) { 2556 2977 clean_object_term_cache( $objects, $object_type ); 2557 2558 do_action("edit_term", $term_id, $tt_id, $taxonomy); 2559 do_action("edit_$taxonomy", $term_id, $tt_id); 2560 2561 $term_id = apply_filters('term_id_filter', $term_id, $tt_id); 2978 } 2979 2980 /** 2981 * Fires after a term has been updated, but before the term cache has been cleaned. 2982 * 2983 * @since 2.3.0 2984 * 2985 * @param int $term_id Term ID. 2986 * @param int $tt_id Term taxonomy ID. 2987 * @param string $taxonomy Taxonomy slug. 2988 */ 2989 do_action( "edit_term", $term_id, $tt_id, $taxonomy ); 2990 2991 /** 2992 * Fires after a term in a specific taxonomy has been updated, but before the term 2993 * cache has been cleaned. 2994 * 2995 * The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug. 2996 * 2997 * @since 2.3.0 2998 * 2999 * @param int $term_id Term ID. 3000 * @param int $tt_id Term taxonomy ID. 3001 */ 3002 do_action( "edit_$taxonomy", $term_id, $tt_id ); 3003 3004 /** This filter is documented in wp-includes/taxonomy.php */ 3005 $term_id = apply_filters( 'term_id_filter', $term_id, $tt_id ); 2562 3006 2563 3007 clean_term_cache($term_id, $taxonomy); 2564 3008 2565 do_action("edited_term", $term_id, $tt_id, $taxonomy); 2566 do_action("edited_$taxonomy", $term_id, $tt_id); 3009 /** 3010 * Fires after a term has been updated, and the term cache has been cleaned. 3011 * 3012 * @since 2.3.0 3013 * 3014 * @param int $term_id Term ID. 3015 * @param int $tt_id Term taxonomy ID. 3016 * @param string $taxonomy Taxonomy slug. 3017 */ 3018 do_action( "edited_term", $term_id, $tt_id, $taxonomy ); 3019 3020 /** 3021 * Fires after a term for a specific taxonomy has been updated, and the term 3022 * cache has been cleaned. 3023 * 3024 * The dynamic portion of the hook name, $taxonomy, refers to the taxonomy slug. 3025 * 3026 * @since 2.3.0 3027 * 3028 * @param int $term_id Term ID. 3029 * @param int $tt_id Term taxonomy ID. 3030 */ 3031 do_action( "edited_$taxonomy", $term_id, $tt_id ); 2567 3032 2568 3033 return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); … … 2684 3149 * 2685 3150 * @see get_object_taxonomies() for more on $object_type 2686 * @uses do_action() Will call action hook named, 'clean_object_term_cache' after completion.2687 * Passes, function params in same order.2688 3151 * 2689 3152 * @param int|array $object_ids Single or list of term object ID(s) … … 2702 3165 } 2703 3166 2704 do_action('clean_object_term_cache', $object_ids, $object_type); 3167 /** 3168 * Fires after the object term cache has been cleaned. 3169 * 3170 * @since 2.5.0 3171 * 3172 * @param array $object_ids An array of object IDs. 3173 * @param string $objet_type Object type. 3174 */ 3175 do_action( 'clean_object_term_cache', $object_ids, $object_type ); 2705 3176 } 2706 3177 … … 2752 3223 } 2753 3224 2754 do_action('clean_term_cache', $ids, $taxonomy); 3225 /** 3226 * Fires once after each taxonomy's term cache has been cleaned. 3227 * 3228 * @since 2.5.0 3229 * 3230 * @param array $ids An array of term IDs. 3231 * @param string $taxonomy Taxonomy slug. 3232 */ 3233 do_action( 'clean_term_cache', $ids, $taxonomy ); 2755 3234 } 2756 3235 … … 3053 3532 $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type IN ('" . implode("', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) ); 3054 3533 3534 /** This action is documented in wp-includes/taxonomy.php */ 3055 3535 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 3056 3536 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 3537 3538 /** This action is documented in wp-includes/taxonomy.php */ 3057 3539 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 3058 3540 } … … 3076 3558 $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) ); 3077 3559 3560 /** This action is documented in wp-includes/taxonomy.php */ 3078 3561 do_action( 'edit_term_taxonomy', $term, $taxonomy ); 3079 3562 $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) ); 3563 3564 /** This action is documented in wp-includes/taxonomy.php */ 3080 3565 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 3081 3566 } … … 3086 3571 * 3087 3572 * @since 2.5.0 3088 *3089 * @uses apply_filters() Calls 'term_link' with term link and term object, and taxonomy parameters.3090 * @uses apply_filters() For the post_tag Taxonomy, Calls 'tag_link' with tag link and tag ID as parameters.3091 * @uses apply_filters() For the category Taxonomy, Calls 'category_link' filter on category link and category ID.3092 3573 * 3093 3574 * @param object|int|string $term … … 3144 3625 } 3145 3626 // Back Compat filters. 3146 if ( 'post_tag' == $taxonomy ) 3627 if ( 'post_tag' == $taxonomy ) { 3628 3629 /** 3630 * Filter the tag link. 3631 * 3632 * @since 2.3.0 3633 * @deprecated 2.5.0 Use 'term_link' instead. 3634 * 3635 * @param string $termlink Tag link URL. 3636 * @param int $term_id Term ID. 3637 */ 3147 3638 $termlink = apply_filters( 'tag_link', $termlink, $term->term_id ); 3148 elseif ( 'category' == $taxonomy ) 3639 } elseif ( 'category' == $taxonomy ) { 3640 3641 /** 3642 * Filter the category link. 3643 * 3644 * @since 1.5.0 3645 * @deprecated 2.5.0 Use 'term_link' instead. 3646 * 3647 * @param string $termlink Category link URL. 3648 * @param int $term_id Term ID. 3649 */ 3149 3650 $termlink = apply_filters( 'category_link', $termlink, $term->term_id ); 3150 3151 return apply_filters('term_link', $termlink, $term, $taxonomy); 3651 } 3652 3653 /** 3654 * Filter the term link. 3655 * 3656 * @since 2.5.0 3657 * 3658 * @param string $termlink Term link URL. 3659 * @param object $term Term object. 3660 * @param string $taxonomy Taxonomy slug. 3661 */ 3662 return apply_filters( 'term_link', $termlink, $term, $taxonomy ); 3152 3663 } 3153 3664 … … 3335 3846 3336 3847 if ( empty( $object_id ) ) { 3337 return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); 3848 3849 /** This filter is documented in wp-includes/taxonomy.php */ 3850 return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type ); 3338 3851 } 3339 3852 … … 3348 3861 } 3349 3862 3350 return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); 3863 /** 3864 * Filter a given object's ancestors. 3865 * 3866 * @since 3.1.0 3867 * 3868 * @param array $ancestors An array of object ancestors. 3869 * @param int $object_id Object ID. 3870 * @param string $object_type Type of object. 3871 */ 3872 return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type ); 3351 3873 } 3352 3874
Note: See TracChangeset
for help on using the changeset viewer.