/** * Get the total time. * * @since 1.3.0 * * @param string $format Optional. The duration format to return. Specify 'machine' * for microdata-friendly format. Default: 'human'. * @return string|bool $total_time The formatted total time or false on failure. */ public function get_total_time($format = 'human') { $durations_api = new Simmer_Recipe_Durations(); $total_time = $durations_api->get_duration('total', $this->id); if ($total_time) { if ('machine' == $format) { $total_time = $durations_api->format_machine_duration($total_time); } else { $total_time = $durations_api->format_human_duration($total_time); } } /** * Filter the total time. * * @since 1.3.0 * * @param string|bool $total_time The returned time string or false if none set. * @param int $recipe_id The recipe ID. */ $total_time = apply_filters('simmer_get_recipe_total_time', $total_time, $this->id); return $total_time; }
/** * The ingredients meta box HTML. * * @package Simmer\Ingredients */ ?> <?php wp_nonce_field('simmer_save_recipe_meta', 'simmer_nonce'); ?> <?php // Build the formatted times. $durations_api = new Simmer_Recipe_Durations(); $prep_time = (int) $durations_api->get_duration('prep', $recipe->ID); $cook_time = (int) $durations_api->get_duration('cook', $recipe->ID); $total_time = (int) $durations_api->get_duration('total', $recipe->ID); if ($prep_time) { $prep_h = zeroise(floor($prep_time / 60), 2); $prep_m = zeroise($prep_time % 60, 2); } else { $prep_h = ''; $prep_m = ''; } if ($cook_time) { $cook_h = zeroise(floor($cook_time / 60), 2); $cook_m = zeroise($cook_time % 60, 2); } else { $cook_h = ''; $cook_m = '';
/** * Return the given time of a given recipe. * * @since 1.0.0 * * @param string $type The type of time, prep|cook|total. * @param int $recipe_id The recipe's ID. * @return int $time The given recipe time, in minutes. */ function simmer_get_the_time($type, $recipe_id) { _simmer_deprecated_function(__FUNCTION__, '1.3.0'); $durations_api = new Simmer_Recipe_Durations(); $time = $durations_api->get_duration($type, $recipe_id); return $time; }