5 * MINUTE_IN_SECONDS, 'display' => __( 'Every five minutes (Ojelio)', 'ojelio' ), ); return $schedules; } /** Scheduled while the site is connected, and not otherwise. */ public static function keep_scheduled() { $scheduled = wp_next_scheduled( self::EVENT ); if ( Connection::get() && ! $scheduled ) { wp_schedule_event( time() + MINUTE_IN_SECONDS, self::SCHEDULE, self::EVENT ); } elseif ( ! Connection::get() && $scheduled ) { self::unschedule(); } } public static function unschedule() { wp_clear_scheduled_hook( self::EVENT ); } public static function check() { foreach ( Videos::pending_posts() as $post_id ) { // Asked about at most once a minute each; the editor asks more often while it is open. foreach ( Videos::refresh( $post_id, MINUTE_IN_SECONDS ) as $video ) { if ( 'completed' === $video['status'] && Videos::needs_work( $video ) ) { Media::schedule( $post_id, $video['id'] ); } } } } }