/** * Get the next scheduled repeat post * * @param int $post_id The id of a repeat or repeating post * @return Int|Bool Return the original repeating post_id or false if it can't find it */ function get_repeating_post($post_id) { $original_post_id = false; // Are we publishing a repeat post if (is_repeat_post($post_id)) { $original_post_id = get_post($post_id)->post_parent; } elseif (is_repeating_post($post_id)) { $original_post_id = $post_id; } return $original_post_id; }
function test_repeating_post_interval_monthly() { $_POST['hm-post-repeat'] = 'monthly'; $post = $this->factory->post->create_and_get(); $this->assertTrue(is_repeating_post($post->ID)); $future_posts = get_posts(array('post_status' => 'future')); $this->assertCount(1, $future_posts); $repeat_post = reset($future_posts); $this->assertTrue(is_repeat_post($repeat_post->ID)); $next_post_date = date('Y-m-d H:i:s', strtotime($post->post_date . ' + 1 month')); $this->assertSame($repeat_post->post_date, $next_post_date); }