Exemplo n.º 1
0
/**
 * Get the repeating schedule of the given post_id.
 *
 * @param int $post_id The id of the post you want to check.
 * @return array|null The schedule to repeat by, or null if invalid.
 */
function get_repeating_schedule($post_id)
{
    if (!is_repeating_post($post_id)) {
        return;
    }
    $repeating_schedule = get_post_meta($post_id, 'hm-post-repeat', true);
    $schedules = get_repeating_schedules();
    // Backwards compatibility with 0.3 when we only supported weekly
    if ('1' === $repeating_schedule) {
        $repeating_schedule = 'weekly';
    }
    if (array_key_exists($repeating_schedule, $schedules)) {
        return $schedules[$repeating_schedule];
    }
}
 function test_add_custom_repeating_schedule()
 {
     add_filter('hm_post_repeat_schedules', function ($schedules) {
         $schedules['yearly'] = array('interval' => '1 year', 'display' => 'Yearly');
         return $schedules;
     });
     $this->assertTrue(key_exists('yearly', get_repeating_schedules()));
 }