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 |
|---|---|
| 1615 | $term_group = 0; |
| 1616 | if ( $alias_of ) { |
| 1617 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
| 1618 | if ( $alias->term_group ) { |
| 1619 | // The alias we want is already in a group, so let's use that one. |
| 1620 | $term_group = $alias->term_group; |
| 1621 | } else { |
| 1622 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
| 1623 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
| 1624 | do_action( 'edit_terms', $alias->term_id ); |
| 1625 | $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); |
| 1626 | do_action( 'edited_terms', $alias->term_id ); |
| 1627 | } |
| 1628 | } |
| 1629 | |
| 1630 | if ( $term_id = term_exists($slug) ) { |
| 1631 | $existing_term = $wpdb->get_row( $wpdb->prepare( "SELECT name FROM $wpdb->terms WHERE term_id = %d", $term_id), ARRAY_A ); |
| 1632 | // We've got an existing term in the same taxonomy, which matches the name of the new term: |
| 1633 | if ( is_taxonomy_hierarchical($taxonomy) && $existing_term['name'] == $name && term_exists( (int) $term_id, $taxonomy ) ) { |
| Line | Code |
| 1656 | $slug = wp_unique_term_slug($slug, (object) $args); |
| 1657 | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
| 1658 | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
| 1659 | $term_id = (int) $wpdb->insert_id; |
| 1660 | } |
| 1661 | |
| 1662 | // Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string. |
| 1663 | if ( empty($slug) ) { |
| 1664 | $slug = sanitize_title($slug, $term_id); |
| 1665 | do_action( 'edit_terms', $term_id ); |
| 1666 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
| 1667 | do_action( 'edited_terms', $term_id ); |
| 1668 | } |
| 1669 | |
| 1670 | $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 ) ); |
| 1671 | |
| 1672 | if ( !empty($tt_id) ) |
| 1673 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
| 1674 | |
| Line | Code |
| 1924 | |
| 1925 | if ( $alias_of ) { |
| 1926 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
| 1927 | if ( $alias->term_group ) { |
| 1928 | // The alias we want is already in a group, so let's use that one. |
| 1929 | $term_group = $alias->term_group; |
| 1930 | } else { |
| 1931 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
| 1932 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
| 1933 | do_action( 'edit_terms', $alias->term_id ); |
| 1934 | $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); |
| 1935 | do_action( 'edited_terms', $alias->term_id ); |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | // Check for duplicate slug |
| 1940 | $id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) ); |
| 1941 | if ( $id && ($id != $term_id) ) { |
| 1942 | // If an empty slug was passed or the parent changed, reset the slug to something unique. |
| 1943 | // Otherwise, bail. |
| 1944 | if ( $empty_slug || ( $parent != $term['parent']) ) |
| 1945 | $slug = wp_unique_term_slug($slug, (object) $args); |
| 1946 | else |
| 1947 | return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
| 1948 | } |
| 1949 | do_action( 'edit_terms', $term_id ); |
| 1950 | $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); |
| 1951 | if ( empty($slug) ) { |
| 1952 | $slug = sanitize_title($name, $term_id); |
| 1953 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
| 1954 | } |
| 1955 | do_action( 'edited_terms', $term_id ); |
| 1956 | |
| 1957 | $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) ); |
| 1958 | do_action( 'edit_term_taxonomy', $tt_id, $taxonomy ); |