/**
  * Add a new instruction.
  *
  * @since 1.3.0
  *
  * @param  int      $recipe_id   The recipe ID.
  * @param  string   $description The instruction description.
  * @param  bool     $is_heading  Optional. Whether the instruction is a heading.
  * @param  int      $order       Optional. The instruction order number.
  * @return int|bool $result      The new instruction's ID or false on failure.
  */
 public function add_instruction($recipe_id, $description, $is_heading = false, $order = 0)
 {
     if (!absint($recipe_id)) {
         return false;
     }
     // Try adding the item to the database.
     $item_id = simmer_add_recipe_item($recipe_id, 'instruction', $order);
     // If successful, add the metadata.
     if ($item_id) {
         simmer_add_recipe_item_meta($item_id, 'description', $description);
         simmer_add_recipe_item_meta($item_id, 'is_heading', (bool) $is_heading);
     }
     return $item_id;
 }
 /**
  * Add a new ingredient.
  *
  * @since 1.3.0
  *
  * @param  int      $recipe_id   The recipe ID.
  * @param  string   $description The ingredient description.
  * @param  float    $amount      Optional. The ingredient amount.
  * @param  string   $unit        Optional. The ingredient unit.
  * @param  bool     $is_heading  Optional. Whether the ingredient is a heading.
  * @param  int      $order       Optional. The ingredient order number.
  * @return int|bool $result      The new ingredient's ID or false on failure.
  */
 public function add_ingredient($recipe_id, $description, $amount = null, $unit = '', $is_heading = false, $order = 0)
 {
     if (!absint($recipe_id)) {
         return false;
     }
     // Try adding the item to the database.
     $item_id = simmer_add_recipe_item($recipe_id, 'ingredient', $order);
     // If successful, add the metadata.
     if ($item_id) {
         simmer_add_recipe_item_meta($item_id, 'description', $description);
         $amount = floatval($amount);
         if (!empty($amount)) {
             simmer_add_recipe_item_meta($item_id, 'amount', $amount);
         }
         $unit = sanitize_text_field($unit);
         if (!empty($unit)) {
             simmer_add_recipe_item_meta($item_id, 'unit', $unit);
         }
         simmer_add_recipe_item_meta($item_id, 'is_heading', (bool) $is_heading);
     }
     return $item_id;
 }