Changeset 25489
- Timestamp:
- 09/19/2013 01:56:16 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/taxonomy.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r25483 r25489 2021 2021 2022 2022 /** 2023 * Adds a new term to the database. Optionally marks it as an alias of an existing term. 2024 * 2025 * Error handling is assigned for the nonexistence of the $taxonomy and $term 2026 * parameters before inserting. If both the term id and taxonomy exist 2027 * previously, then an array will be returned that contains the term id and the 2028 * contents of what is returned. The keys of the array are 'term_id' and 2029 * 'term_taxonomy_id' containing numeric values. 2030 * 2031 * It is assumed that the term does not yet exist or the above will apply. The 2032 * term will be first added to the term table and then related to the taxonomy 2033 * if everything is well. If everything is correct, then several actions will be 2034 * run prior to a filter and then several actions will be run after the filter 2035 * is run. 2036 * 2037 * The arguments decide how the term is handled based on the $args parameter. 2038 * The following is a list of the available overrides and the defaults. 2039 * 2040 * 'alias_of'. There is no default, but if added, expected is the slug that the 2041 * term will be an alias of. Expected to be a string. 2042 * 2043 * 'description'. There is no default. If exists, will be added to the database 2044 * along with the term. Expected to be a string. 2045 * 2046 * 'parent'. Expected to be numeric and default is 0 (zero). Will assign value 2047 * of 'parent' to the term. 2048 * 2049 * 'slug'. Expected to be a string. There is no default. 2050 * 2051 * If 'slug' argument exists then the slug will be checked to see if it is not 2052 * a valid term. If that check succeeds (it is not a valid term), then it is 2053 * added and the term id is given. If it fails, then a check is made to whether 2054 * the taxonomy is hierarchical and the parent argument is not empty. If the 2055 * second check succeeds, the term will be inserted and the term id will be 2056 * given. 2057 * 2058 * @package WordPress 2059 * @subpackage Taxonomy 2023 * Add a new term to the database. 2024 * 2025 * A non-existent term is inserted in the following sequence: 2026 * 1. The term is added to the term table, then related to the taxonomy. 2027 * 2. If everything is correct, several actions are fired. 2028 * 3. The 'term_id_filter' is evaluated. 2029 * 4. The term cache is cleaned. 2030 * 5. Several more actions are fired. 2031 * 6. An array is returned containing the term_id and term_taxonomy_id. 2032 * 2033 * If the 'slug' argument is not empty, then it will be checked to see if the term 2034 * is invalid. If it is not a valid, existing term, it is added and the term_id is given. 2035 * If the taxonomy is hierarchical, and the 'parent' argument is not empty, the term 2036 * will be inserted and the term_id will be given. 2037 2038 * Error handling: 2039 * If $taxonomy does not exist -- or $term is numeric or empty, 2040 * a WP_Error object will be returned. 2041 * 2042 * If the term already exists, the term slug is not unique, or both the term id and taxonomy 2043 * already exist, a WP_Error object will be returned. 2044 * 2045 * @global wpdb $wpdb The WordPress database object. 2046 2060 2047 * @since 2.3.0 2061 * @uses $wpdb 2062 * 2063 * @uses apply_filters() Calls 'pre_insert_term' hook with term and taxonomy as parameters. 2064 * @uses do_action() Calls 'create_term' hook with the term id and taxonomy id as parameters. 2065 * @uses do_action() Calls 'create_$taxonomy' hook with term id and taxonomy id as parameters. 2066 * @uses apply_filters() Calls 'term_id_filter' hook with term id and taxonomy id as parameters. 2067 * @uses do_action() Calls 'created_term' hook with the term id and taxonomy id as parameters. 2068 * @uses do_action() Calls 'created_$taxonomy' hook with term id and taxonomy id as parameters. 2069 * 2070 * @param string $term The term to add or update. 2071 * @param string $taxonomy The taxonomy to which to add the term 2072 * @param array|string $args Change the values of the inserted term 2073 * @return array|WP_Error The Term ID and Term Taxonomy ID 2048 * 2049 * @param string $term The term to add or update. 2050 * @param string $taxonomy The taxonomy to which to add the term 2051 * @param array|string $args { 2052 * Arguments to change values of the inserted term. 2053 * 2054 * @type string 'alias_of' Slug of the term to make this term an alias of. 2055 * Default empty string. Accepts a term slug. 2056 * @type string 'description' The term description. 2057 * Default empty string. 2058 * @type int 'parent' The id of the parent term. 2059 * Default 0. 2060 * @type string 'slug' The term slug to use. 2061 * Default empty string. 2062 * } 2063 * @return array|WP_Error An array containing the term_id and term_taxonomy_id, WP_Error otherwise. 2074 2064 */ 2075 2065 function wp_insert_term( $term, $taxonomy, $args = array() ) {
Note: See TracChangeset
for help on using the changeset viewer.