Make WordPress Core


Ignore:
Timestamp:
03/28/2014 09:28:23 PM (10 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/taxonomy.php.

Props kpdesign for some minor language tweaks.
Fixes #27505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r27473 r27827  
    2525        $rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false );
    2626    } 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         */
    2735        $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' );
    2836        $rewrite = array(
     
    413421    add_filter( 'wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term' );
    414422
     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     */
    415432    do_action( 'registered_taxonomy', $taxonomy, $object_type, $args );
    416433}
     
    947964    }
    948965
    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 );
    951988    $_term = sanitize_term($_term, $taxonomy, $filter);
    952989
     
    10201057    wp_cache_add($term->term_id, $term, $taxonomy);
    10211058
    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
    10241065    $term = sanitize_term($term, $taxonomy, $filter);
    10251066
     
    12671308    }
    12681309
     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     */
    12691318    $args = apply_filters( 'get_terms_args', $args, $taxonomies );
    12701319
     
    12941343    $cache = wp_cache_get( $cache_key, 'terms' );
    12951344    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 );
    12971356        return $cache;
    12981357    }
     
    13141373        $orderby = 't.name';
    13151374
     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     */
    13161384    $orderby = apply_filters( 'get_terms_orderby', $orderby, $args, $taxonomies );
    13171385
     
    13621430        $exclusions = ' AND t.term_id NOT IN (' . $exclusions . ')';
    13631431
     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     */
    13641441    $exclusions = apply_filters( 'list_terms_exclusions', $exclusions, $args, $taxonomies );
    13651442
     
    14351512    $_fields = $fields;
    14361513
     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     */
    14371523    $fields = implode( ', ', apply_filters( 'get_terms_fields', $selects, $args, $taxonomies ) );
    14381524
     
    14401526
    14411527    $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     */
    14421538    $clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
    14431539    foreach ( $pieces as $piece )
     
    14601556    if ( empty($terms) ) {
    14611557        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 );
    14631561        return $terms;
    14641562    }
     
    15211619    wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
    15221620
     1621    /** This filter is documented in wp-includes/taxonomy */
    15231622    $terms = apply_filters( 'get_terms', $terms, $taxonomies, $args );
    15241623    return $terms;
     
    16951794
    16961795    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 );
    16991822        if ( 'description' == $field )
    17001823            $value = esc_html($value); // textarea_escaped
     
    17021825            $value = esc_attr($value);
    17031826    } 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 );
    17061851        // 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        }
    17091864
    17101865    } 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 );
    17131890    } else {
    17141891        // 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 );
    17171920    }
    17181921
     
    17951998 *
    17961999 * @uses $wpdb
    1797  * @uses do_action() Calls both 'delete_term' and 'delete_$taxonomy' action
    1798  *  hooks, passing term ID, term taxonomy ID, and deleted term object. 'delete_term'
    1799  *  also gets taxonomy as the third parameter.
    18002000 *
    18012001 * @param int $term Term ID
     
    18412041
    18422042        $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         */
    18432051        do_action( 'edit_term_taxonomies', $edit_tt_ids );
    18442052        $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         */
    18452061        do_action( 'edited_term_taxonomies', $edit_tt_ids );
    18462062    }
     
    18692085    $deleted_term = get_term( $term, $taxonomy );
    18702086
     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     */
    18712094    do_action( 'delete_term_taxonomy', $tt_id );
    18722095    $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     */
    18732104    do_action( 'deleted_term_taxonomy', $tt_id );
    18742105
     
    18792110    clean_term_cache($term, $taxonomy);
    18802111
     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     */
    18812123    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     */
    18822138    do_action( "delete_$taxonomy", $term, $tt_id, $deleted_term );
    18832139
     
    20362292        $terms = array();
    20372293
    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 );
    20392306}
    20402307
     
    20902357        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy'));
    20912358
     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     */
    20922367    $term = apply_filters( 'pre_insert_term', $term, $taxonomy );
    20932368        if ( is_wp_error( $term ) )
     
    21252400            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
    21262401            $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             */
    21272411            do_action( 'edit_terms', $alias->term_id, $taxonomy );
    21282412            $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             */
    21292422            do_action( 'edited_terms', $alias->term_id, $taxonomy );
    21302423        }
     
    21702463    if ( empty($slug) ) {
    21712464        $slug = sanitize_title($slug, $term_id);
     2465
     2466        /** This action is documented in wp-includes/taxonomy.php */
    21722467        do_action( 'edit_terms', $term_id, $taxonomy );
    21732468        $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
     2469
     2470        /** This action is documented in wp-includes/taxonomy.php */
    21742471        do_action( 'edited_terms', $term_id, $taxonomy );
    21752472    }
     
    21832480    $tt_id = (int) $wpdb->insert_id;
    21842481
    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 );
    21892515
    21902516    clean_term_cache($term_id, $taxonomy);
    21912517
    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 );
    21942535
    21952536    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
     
    22552596        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 ) ) )
    22562597            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         */
    22572607        do_action( 'add_term_relationship', $object_id, $tt_id );
    22582608        $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         */
    22592618        do_action( 'added_term_relationship', $object_id, $tt_id );
    22602619        $new_tt_ids[] = $tt_id;
     
    22942653    wp_cache_delete( $object_id, $taxonomy . '_relationships' );
    22952654
    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 );
    22972668    return $tt_ids;
    22982669}
     
    23182689 * @since 3.6.0
    23192690 * @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.
    23232691 *
    23242692 * @param int $object_id The ID of the object from which the terms will be removed.
     
    23632731    if ( $tt_ids ) {
    23642732        $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         */
    23652742        do_action( 'delete_term_relationships', $object_id, $tt_ids );
    23662743        $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         */
    23672753        do_action( 'deleted_term_relationships', $object_id, $tt_ids );
    23682754        wp_update_term_count( $tt_ids, $taxonomy );
     
    24632849 *
    24642850 * @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 term
    2467  *  id and taxonomy id.
    24682851 *
    24692852 * @param int $term_id The ID of the term
     
    25182901            // The alias isn't in a group, so let's create a new one and firstly add the alias term to it.
    25192902            $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
     2903
     2904            /** This action is documented in wp-includes/taxonomy.php */
    25202905            do_action( 'edit_terms', $alias->term_id, $taxonomy );
    25212906            $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) );
     2907
     2908            /** This action is documented in wp-includes/taxonomy.php */
    25222909            do_action( 'edited_terms', $alias->term_id, $taxonomy );
    25232910        }
    25242911    }
    25252912
    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     */
    25272926    $parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args );
    25282927
     
    25372936            return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug));
    25382937    }
     2938
     2939    /** This action is documented in wp-includes/taxonomy.php */
    25392940    do_action( 'edit_terms', $term_id, $taxonomy );
    25402941    $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) );
     
    25432944        $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) );
    25442945    }
     2946
     2947    /** This action is documented in wp-includes/taxonomy.php */
    25452948    do_action( 'edited_terms', $term_id, $taxonomy );
    25462949
    25472950    $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     */
    25482960    do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
    25492961    $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     */
    25502971    do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
    25512972
     
    25532974    $objects = $wpdb->get_col( $wpdb->prepare( "SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $tt_id ) );
    25542975    $tax_object = get_taxonomy( $taxonomy );
    2555     foreach ( $tax_object->object_type as $object_type )
     2976    foreach ( $tax_object->object_type as $object_type ) {
    25562977        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 );
    25623006
    25633007    clean_term_cache($term_id, $taxonomy);
    25643008
    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 );
    25673032
    25683033    return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id);
     
    26843149 *
    26853150 * @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.
    26883151 *
    26893152 * @param int|array $object_ids Single or list of term object ID(s)
     
    27023165    }
    27033166
    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 );
    27053176}
    27063177
     
    27523223        }
    27533224
    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 );
    27553234    }
    27563235
     
    30533532            $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 ) );
    30543533
     3534        /** This action is documented in wp-includes/taxonomy.php */
    30553535        do_action( 'edit_term_taxonomy', $term, $taxonomy );
    30563536        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
     3537
     3538        /** This action is documented in wp-includes/taxonomy.php */
    30573539        do_action( 'edited_term_taxonomy', $term, $taxonomy );
    30583540    }
     
    30763558        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
    30773559
     3560        /** This action is documented in wp-includes/taxonomy.php */
    30783561        do_action( 'edit_term_taxonomy', $term, $taxonomy );
    30793562        $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
     3563
     3564        /** This action is documented in wp-includes/taxonomy.php */
    30803565        do_action( 'edited_term_taxonomy', $term, $taxonomy );
    30813566    }
     
    30863571 *
    30873572 * @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.
    30923573 *
    30933574 * @param object|int|string $term
     
    31443625    }
    31453626    // 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         */
    31473638        $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         */
    31493650        $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 );
    31523663}
    31533664
     
    33353846
    33363847    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 );
    33383851    }
    33393852
     
    33483861    }
    33493862
    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 );
    33513873}
    33523874
Note: See TracChangeset for help on using the changeset viewer.