Copy_Recipe_Parts::copy_recipe_part( $recipe_id,  $new_recipe_id,  $type )


Parameters Parameters

$recipe_id

(Required)

$new_recipe_id

(Required)

$type

(Required)


Top ↑

Return Return

(bool)


Source Source

File: src/core/admin/class-copy-recipe-parts.php

	public function copy_recipe_part( $recipe_id, $new_recipe_id, $type ) {
		$recipe_parts = get_posts(
			array(
				'post_parent' => $recipe_id,
				'post_type'   => $type,
				'post_status' => array( 'draft', 'publish' ),
				'order_by'    => 'ID',
				'order'       => 'ASC',
			)
		);

		if ( empty( $recipe_parts ) ) {
			return false;
		}

		foreach ( $recipe_parts as $recipe_part ) {
			if ( $type !== $recipe_part->post_type ) {
				continue;
			}

			$new_id = $this->copy( $recipe_part->ID, $new_recipe_id );

			if ( 'uo-trigger' === $recipe_part->post_type ) {
				$this->trigger_tokens[ $recipe_part->ID ] = $new_id;
			}
		}

		return true;
	}