示例#1
0
 /**
  * Get the instructions.
  *
  * @since 1.3.0
  *
  * @param array $args {
  *     Optional. An array of arguments.
  *
  *     @type bool $exclude_headings Whether returned instructions should exclude headings. Default 'false'.
  * }
  * @return array $instructions An array of the recipe's instructions. An empty array is returned when there
  *                             are no instructions for the recipe.
  */
 public function get_instructions($args = array())
 {
     $defaults = array('exclude_headings' => false);
     $args = wp_parse_args($args, $defaults);
     /**
      * Filter the recipe's instructions query args.
      *
      * @since 1.3.3
      *
      * @param array $args      The recipe's instructions query args. @see Simmer_Recipe::get_instructions().
      * @param int   $recipe_id The recipe ID.
      */
     $args = apply_filters('simmer_get_recipe_instructions_args', $args, $this->id);
     $items = $this->get_items('instruction');
     $instructions = array();
     foreach ($items as $item) {
         // Exclude headings if set to do so in the args.
         if ($args['exclude_headings'] && simmer_get_recipe_item_meta($item->recipe_item_id, 'is_heading', true)) {
             continue;
         }
         $instructions[] = new Simmer_Recipe_Instruction($item);
     }
     /**
      * Filter a recipe's retrieved instructions.
      *
      * @since 1.3.0
      *
      * @param array $instructions The retrieved instructions.
      * @param int   $recipe_id    The recipe ID.
      */
     $instructions = apply_filters('simmer_get_recipe_instructions', $instructions, $this->id);
     return $instructions;
 }
 /**
  * Determine if the instruction is a heading.
  *
  * @since 1.3.0
  *
  * @param  bool   $raw        Whether to get the heading status unaltered from the database.
  * @return string $is_heading Whether the instruction is a heading..
  */
 public function is_heading($raw = false)
 {
     $is_heading = simmer_get_recipe_item_meta($this->id, 'is_heading', true);
     if ($raw) {
         return $is_heading;
     }
     $is_heading = apply_filters('simmer_recipe_instruction_is_heading', $is_heading, $this->id);
     return $is_heading;
 }