public function prepare_item_for_database( $request ) {
		$prepared_term = new stdClass;

		$schema = $this->get_item_schema();
		if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) {
			$prepared_term->name = $request['name'];
		}

		if ( isset( $request['slug'] ) && ! empty( $schema['properties']['slug'] ) ) {
			$prepared_term->slug = $request['slug'];
		}

		if ( isset( $request['taxonomy'] ) && ! empty( $schema['properties']['taxonomy'] ) ) {
			$prepared_term->taxonomy = $request['taxonomy'];
		}

		if ( isset( $request['description'] ) && ! empty( $schema['properties']['description'] ) ) {
			$prepared_term->description = $request['description'];
		}

		if ( isset( $request['parent'] ) && ! empty( $schema['properties']['parent'] ) ) {
			$parent_term_id = 0;
			$parent_term = get_term( (int) $request['parent'], $this->taxonomy );

			if ( $parent_term ) {
				$parent_term_id = $parent_term->term_id;
			}

			$prepared_term->parent = $parent_term_id;
		}

		/**
		 * Filters term data before inserting term via the REST API.
		 *
		 * @param object          $prepared_term Term object.
		 * @param WP_REST_Request $request       Request object.
		 */
		return apply_filters( "rest_pre_insert_{$this->taxonomy}", $prepared_term, $request );
	}
public function prepare_item_for_database( $request ) {
		$prepared_term = new stdClass;

		$schema = $this->get_item_schema();
		if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) {
			$prepared_term->name = $request['name'];
		}

		if ( isset( $request['slug'] ) && ! empty( $schema['properties']['slug'] ) ) {
			$prepared_term->slug = $request['slug'];
		}

		if ( isset( $request['taxonomy'] ) && ! empty( $schema['properties']['taxonomy'] ) ) {
			$prepared_term->taxonomy = $request['taxonomy'];
		}

		if ( isset( $request['description'] ) && ! empty( $schema['properties']['description'] ) ) {
			$prepared_term->description = $request['description'];
		}

		if ( isset( $request['parent'] ) && ! empty( $schema['properties']['parent'] ) ) {
			$parent_term_id = 0;
			$parent_term = get_term( (int) $request['parent'], $this->taxonomy );

			if ( $parent_term ) {
				$parent_term_id = $parent_term->term_id;
			}

			$prepared_term->parent = $parent_term_id;
		}

		/**
		 * Filters term data before inserting term via the REST API.
		 *
		 * @param object          $prepared_term Term object.
		 * @param WP_REST_Request $request       Request object.
		 */
		return apply_filters( "rest_pre_insert_{$this->taxonomy}", $prepared_term, $request );
	}
public function prepare_item_for_database ( $ request ) { $ prepared_term = new stdClass ; $ schema = $ this -> get_item_schema ( ) ; if ( isset ( $ request [ 'name' ] ) && ! empty ( $ schema [ 'properties' ] [ 'name' ] ) ) { $ prepared_term -> name = $ request [ 'name' ] ; } if ( isset ( $ request [ 'slug' ] ) && ! empty ( $ schema [ 'properties' ] [ 'slug' ] ) ) { $ prepared_term -> slug = $ request [ 'slug' ] ; } if ( isset ( $ request [ 'taxonomy' ] ) && ! empty ( $ schema [ 'properties' ] [ 'taxonomy' ] ) ) { $ prepared_term -> taxonomy = $ request [ 'taxonomy' ] ; } if ( isset ( $ request [ 'description' ] ) && ! empty ( $ schema [ 'properties' ] [ 'description' ] ) ) { $ prepared_term -> description = $ request [ 'description' ] ; } if ( isset ( $ request [ 'parent' ] ) && ! empty ( $ schema [ 'properties' ] [ 'parent' ] ) ) { $ parent_term_id = 0 ; $ parent_term = get_term ( ( int ) $ request [ 'parent' ] , $ this -> taxonomy ) ; if ( $ parent_term ) { $ parent_term_id = $ parent_term -> term_id ; } $ prepared_term -> parent = $ parent_term_id ; } /**
		 * Filters term data before inserting term via the REST API.
		 *
		 * @param object          $prepared_term Term object.
		 * @param WP_REST_Request $request       Request object.
		 */ return apply_filters ( "rest_pre_insert_{$this->taxonomy}" , $ prepared_term , $ request ) ; }
Prepares a single term for create or update.

@param WP_REST_Request $request Request object.
@return object $prepared_term Term object.
Prepares a single term for create or update .