Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_insert_{$this->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 2 times in this file.

Line Code
431            *
432            * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug.
433            *
434            * @since 4.7.0
435            *
436            * @param WP_Term         $term     Inserted or updated term object.
437            * @param WP_REST_Request $request  Request object.
438            * @param bool            $creating True when creating a term, false when updating.
439            */
440           do_action( "rest_insert_{$this->taxonomy}", $term, $request, true );
441
442           $schema = $this->get_item_schema();
443           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
444                $meta_update = $this->meta->update_value( $request['meta'], $term->term_id );
445
446                if ( is_wp_error( $meta_update ) ) {
447                     return $meta_update;
448                }
449           }
 
Line Code
533
534                if ( is_wp_error( $update ) ) {
535                     return $update;
536                }
537           }
538
539           $term = get_term( $term->term_id, $this->taxonomy );
540
541           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
542           do_action( "rest_insert_{$this->taxonomy}", $term, $request, false );
543
544           $schema = $this->get_item_schema();
545           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
546                $meta_update = $this->meta->update_value( $request['meta'], $term->term_id );
547
548                if ( is_wp_error( $meta_update ) ) {
549                     return $meta_update;
550                }
551           }