Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: edit_term_taxonomy

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 3 times in this file.

Line Code
3320       * Fires immediate before a term-taxonomy relationship is updated.
3321       *
3322       * @since 2.9.0
3323       * @since 6.1.0 The `$args` parameter was added.
3324       *
3325       * @param int    $tt_id    Term taxonomy ID.
3326       * @param string $taxonomy Taxonomy slug.
3327       * @param array  $args     Arguments passed to wp_update_term().
3328       */
3329      do_action( 'edit_term_taxonomy', $tt_id, $taxonomy, $args );
3330
3331      $wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
3332
3333      /**
3334       * Fires immediately after a term-taxonomy relationship is updated.
3335       *
3336       * @since 2.9.0
3337       * @since 6.1.0 The `$args` parameter was added.
3338       *
 
Line Code
4115                $count += (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status IN ('" . implode( "', '", $post_statuses ) . "') OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) IN ('" . implode( "', '", $post_statuses ) . "') ) ) AND post_type = 'attachment' AND term_taxonomy_id = %d", $term ) );
4116           }
4117
4118           if ( $object_types ) {
4119                // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.QuotedDynamicPlaceholderGeneration
4120                $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 IN ('" . implode( "', '", $post_statuses ) . "') AND post_type IN ('" . implode( "', '", $object_types ) . "') AND term_taxonomy_id = %d", $term ) );
4121           }
4122
4123           /** This action is documented in wp-includes/taxonomy.php */
4124           do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
4125           $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
4126
4127           /** This action is documented in wp-includes/taxonomy.php */
4128           do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
4129      }
4130 }
4131
4132 /**
4133  * Updates term count based on number of objects.
 
Line Code
4142  * @param WP_Taxonomy $taxonomy Current taxonomy object of terms.
4143  */
4144 function _update_generic_term_count( $terms, $taxonomy ) {
4145      global $wpdb;
4146
4147      foreach ( (array) $terms as $term ) {
4148           $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) );
4149
4150           /** This action is documented in wp-includes/taxonomy.php */
4151           do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
4152           $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
4153
4154           /** This action is documented in wp-includes/taxonomy.php */
4155           do_action( 'edited_term_taxonomy', $term, $taxonomy->name );
4156      }
4157 }
4158
4159 /**
4160  * Creates a new term for a term_taxonomy item that currently shares its term