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 |
---|---|
1383 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
1384 | if ( $alias->term_group ) { |
1385 | // The alias we want is already in a group, so let's use that one. |
1386 | $term_group = $alias->term_group; |
1387 | } else { |
1388 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
1389 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
1390 | do_action( 'edit_terms', $alias->term_id ); |
1391 | $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); |
1392 | do_action( 'edited_terms', $alias->term_id ); |
1393 | } |
1394 | } |
1395 |
|
1396 | if ( ! $term_id = is_term($slug) ) { |
1397 | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
1398 | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
1399 | $term_id = (int) $wpdb->insert_id; |
1400 | } else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) { |
1401 | // If the taxonomy supports hierarchy and the term has a parent, make the slug unique |
Line | Code |
1404 | if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) ) |
1405 | return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error); |
1406 | $term_id = (int) $wpdb->insert_id; |
1407 | } |
1408 |
|
1409 | if ( empty($slug) ) { |
1410 | $slug = sanitize_title($slug, $term_id); |
1411 | do_action( 'edit_terms', $term_id ); |
1412 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
1413 | do_action( 'edited_terms', $term_id ); |
1414 | } |
1415 |
|
1416 | $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 ) ); |
1417 |
|
1418 | if ( !empty($tt_id) ) |
1419 | return array('term_id' => $term_id, 'term_taxonomy_id' => $tt_id); |
1420 |
|
1421 | $wpdb->insert( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent') + array( 'count' => 0 ) ); |
1422 | $tt_id = (int) $wpdb->insert_id; |
Line | Code |
1660 | $alias = $wpdb->get_row( $wpdb->prepare( "SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $alias_of) ); |
1661 | if ( $alias->term_group ) { |
1662 | // The alias we want is already in a group, so let's use that one. |
1663 | $term_group = $alias->term_group; |
1664 | } else { |
1665 | // The alias isn't in a group, so let's create a new one and firstly add the alias term to it. |
1666 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1; |
1667 | do_action( 'edit_terms', $alias->term_id ); |
1668 | $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); |
1669 | do_action( 'edited_terms', $alias->term_id ); |
1670 | } |
1671 | } |
1672 |
|
1673 | // Check for duplicate slug |
1674 | $id = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM $wpdb->terms WHERE slug = %s", $slug ) ); |
1675 | if ( $id && ($id != $term_id) ) { |
1676 | // If an empty slug was passed or the parent changed, reset the slug to something unique. |
1677 | // Otherwise, bail. |
1678 | if ( $empty_slug || ( $parent != $term->parent) ) |
Line | Code |
1680 | else |
1681 | return new WP_Error('duplicate_term_slug', sprintf(__('The slug “%s” is already in use by another term'), $slug)); |
1682 | } |
1683 | do_action( 'edit_terms', $term_id ); |
1684 | $wpdb->update($wpdb->terms, compact( 'name', 'slug', 'term_group' ), compact( 'term_id' ) ); |
1685 | if ( empty($slug) ) { |
1686 | $slug = sanitize_title($name, $term_id); |
1687 | $wpdb->update( $wpdb->terms, compact( 'slug' ), compact( 'term_id' ) ); |
1688 | } |
1689 | do_action( 'edited_terms', $term_id ); |
1690 |
|
1691 | $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) ); |
1692 | do_action( 'edit_term_taxonomy', $tt_id ); |
1693 | $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) ); |
1694 | do_action( 'edited_term_taxonomy', $tt_id ); |
1695 |
|
1696 | do_action("edit_term", $term_id, $tt_id, $taxonomy); |
1697 | do_action("edit_$taxonomy", $term_id, $tt_id); |
1698 |
|