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
401            *
402            * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug.
403            *
404            * @since 4.7.0
405            *
406            * @param WP_Term         $term     Inserted or updated term object.
407            * @param WP_REST_Request $request  Request object.
408            * @param bool            $creating True when creating a term, false when updating.
409            */
410           do_action( "rest_insert_{$this->taxonomy}", $term, $request, true );
411
412           $schema = $this->get_item_schema();
413           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
414                $meta_update = $this->meta->update_value( $request['meta'], (int) $request['id'] );
415
416                if ( is_wp_error( $meta_update ) ) {
417                     return $meta_update;
418                }
419           }
 
Line Code
495
496                if ( is_wp_error( $update ) ) {
497                     return $update;
498                }
499           }
500
501           $term = get_term( (int) $request['id'], $this->taxonomy );
502
503           /* This action is documented in lib/endpoints/class-wp-rest-terms-controller.php */
504           do_action( "rest_insert_{$this->taxonomy}", $term, $request, false );
505
506           $schema = $this->get_item_schema();
507           if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
508                $meta_update = $this->meta->update_value( $request['meta'], (int) $request['id'] );
509
510                if ( is_wp_error( $meta_update ) ) {
511                     return $meta_update;
512                }
513           }