WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 4 times in this file.
Line | Code |
---|---|
2073 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
2074 | if ( $alias->term_group ) { |
2075 | // The alias we want is already in a group, so let's use that one. |
2076 | $term_group = $alias->term_group; |
2077 | } else { |
2078 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
2079 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
2080 | do_action( 'edit_terms', $alias->term_id ); |
2081 | $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); |
2082 | do_action( 'edited_terms', $alias->term_id ); |
2083 | } |
2084 | } |
2085 |
|
2086 | if ( $term_id = term_exists($slug) ) { |
2087 | $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); |
2088 | // We've got an existing term in the same taxonomy, which matches the name of the new term: |
2089 | if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && $exists = term_exists( (int) $term_id, $taxonomy ) ) { |
2090 | // Hierarchical, and it matches an existing term, Do not allow same "name" in the same level. |
2091 | $siblings = get_terms($taxonomy, array('fields' => 'names', 'get' => 'all', 'parent' => (int)$parent) ); |
Line | Code |
2114 | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
2115 | $term_id = (int) $wpdb->insert_id; |
2116 | } |
2117 |
|
2118 | // Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string. |
2119 | if ( empty($slug) ) { |
2120 | $slug = sanitize_title($slug, $term_id); |
2121 | do_action( 'edit_terms', $term_id ); |
2122 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
2123 | do_action( 'edited_terms', $term_id ); |
2124 | } |
2125 |
|
2126 | $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 ) ); |
2127 |
|
2128 | if ( !empty($tt_id) ) |
2129 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
2130 |
|
2131 | $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) ); |
2132 | $tt_id = (int) $wpdb->insert_id; |
Line | Code |
2388 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
2389 | if ( $alias->term_group ) { |
2390 | // The alias we want is already in a group, so let's use that one. |
2391 | $term_group = $alias->term_group; |
2392 | } else { |
2393 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
2394 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
2395 | do_action( 'edit_terms', $alias->term_id ); |
2396 | $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); |
2397 | do_action( 'edited_terms', $alias->term_id ); |
2398 | } |
2399 | } |
2400 |
|
2401 | // Check $parent to see if it will cause a hierarchy loop |
2402 | $parent = apply_filters( 'wp_update_term_parent', $parent, $term_id, $taxonomy, compact( array_keys( $args ) ), $args ); |
2403 |
|
2404 | // Check for duplicate slug |
2405 | $id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) ); |
2406 | if ( $id && ($id != $term_id) ) { |
Line | Code |
2411 | else |
2412 | return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
2413 | } |
2414 | do_action( 'edit_terms', $term_id ); |
2415 | $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); |
2416 | if ( empty($slug) ) { |
2417 | $slug = sanitize_title($name, $term_id); |
2418 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
2419 | } |
2420 | do_action( 'edited_terms', $term_id ); |
2421 |
|
2422 | $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) ); |
2423 | do_action( 'edit_term_taxonomy', $tt_id, $taxonomy ); |
2424 | $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) ); |
2425 | do_action( 'edited_term_taxonomy', $tt_id, $taxonomy ); |
2426 |
|
2427 | do_action("edit_term", $term_id, $tt_id, $taxonomy); |
2428 | do_action("edit_$taxonomy", $term_id, $tt_id); |
2429 |
|