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
494            *  - `rest_insert_category`
495            *  - `rest_insert_post_tag`
496            *
497            * @since 4.7.0
498            *
499            * @param WP_Term         $term     Inserted or updated term object.
500            * @param WP_REST_Request $request  Request object.
501            * @param bool            $creating True when creating a term, false when updating.
502            */
503           do_action( "rest_insert_{$this->taxonomy}", $term, $request, true );
504
505           $schema = $this->get_item_schema();
506           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
507                $meta_update = $this->meta->update_value( $request['meta'], $term->term_id );
508
509                if ( is_wp_error( $meta_update ) ) {
510                     return $meta_update;
511                }
512           }
 
Line Code
614
615                if ( is_wp_error( $update ) ) {
616                     return $update;
617                }
618           }
619
620           $term = get_term( $term->term_id, $this->taxonomy );
621
622           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
623           do_action( "rest_insert_{$this->taxonomy}", $term, $request, false );
624
625           $schema = $this->get_item_schema();
626           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
627                $meta_update = $this->meta->update_value( $request['meta'], $term->term_id );
628
629                if ( is_wp_error( $meta_update ) ) {
630                     return $meta_update;
631                }
632           }