示例#1
0
/**
 * Get a specific instruction.
 *
 * @since 1.0.0
 *
 * @param  int    $instruction_id The instruction item ID.
 * @return object $instruction    The single instruction item.
 */
function simmer_get_instruction($instruction_id)
{
    _simmer_deprecated_function(__FUNCTION__, '1.3.0', 'simmer_get_recipe_instruction');
    return simmer_get_recipe_instruction($instruction_id);
}
 /**
  * Update an existing instruction.
  *
  * @since 1.3.0
  *
  * @param int   $instruction_id The ID for the instruction to update.
  * @param array $args {
  *     The updated instruction values.
  *
  *     @type int    $recipe_id   The recipe ID.
  *     @type string $description The instruction description.
  *     @type bool   $is_heading' Whether the instruction is a heading.
  *     @type int    $order       The instruction order number.
  * }
  * @return int|bool $result The instruction ID or false on failure.
  */
 public function update_instruction($instruction_id, $args)
 {
     $exists = simmer_get_recipe_instruction($instruction_id);
     if (!$exists) {
         return false;
     }
     $item_args = array();
     if (isset($args['recipe_id'])) {
         $recipe_id = absint($args['recipe_id']);
         if ($recipe_id) {
             $item_args['recipe_id'] = $recipe_id;
         }
     }
     if (isset($args['order'])) {
         if (is_numeric($args['order'])) {
             $item_args['recipe_item_order'] = absint($args['order']);
         }
     }
     if (!empty($item_args)) {
         simmer_update_recipe_item($instruction_id, $item_args);
     }
     if (isset($args['description'])) {
         if (!empty($args['description'])) {
             simmer_update_recipe_item_meta($instruction_id, 'description', $args['description']);
         } else {
             simmer_delete_recipe_item_meta($instruction_id, 'description');
         }
     }
     if (isset($args['is_heading'])) {
         simmer_update_recipe_item_meta($instruction_id, 'is_heading', (bool) $args['is_heading']);
     }
     return $instruction_id;
 }