@@ 209-230 (lines=22) @@ | ||
206 | // try to send actions until we run out of things to send, |
|
207 | // or have to wait more than 15s before sending again, |
|
208 | // or we hit a lock or some other sending issue |
|
209 | static function do_cron_sync() { |
|
210 | if ( ! self::sync_allowed() ) { |
|
211 | return; |
|
212 | } |
|
213 | ||
214 | self::initialize_sender(); |
|
215 | ||
216 | do { |
|
217 | $next_sync_time = self::$sender->get_next_sync_time( 'sync' ); |
|
218 | ||
219 | if ( $next_sync_time ) { |
|
220 | $delay = $next_sync_time - time() + 1; |
|
221 | if ( $delay > 15 ) { |
|
222 | break; |
|
223 | } elseif ( $delay > 0 ) { |
|
224 | sleep( $delay ); |
|
225 | } |
|
226 | } |
|
227 | ||
228 | $result = self::$sender->do_sync(); |
|
229 | } while ( $result ); |
|
230 | } |
|
231 | ||
232 | static function do_cron_full_sync() { |
|
233 | if ( ! self::sync_allowed() ) { |
|
@@ 232-253 (lines=22) @@ | ||
229 | } while ( $result ); |
|
230 | } |
|
231 | ||
232 | static function do_cron_full_sync() { |
|
233 | if ( ! self::sync_allowed() ) { |
|
234 | return; |
|
235 | } |
|
236 | ||
237 | self::initialize_sender(); |
|
238 | ||
239 | do { |
|
240 | $next_sync_time = self::$sender->get_next_sync_time( 'full_sync' ); |
|
241 | ||
242 | if ( $next_sync_time ) { |
|
243 | $delay = $next_sync_time - time() + 1; |
|
244 | if ( $delay > 15 ) { |
|
245 | break; |
|
246 | } elseif ( $delay > 0 ) { |
|
247 | sleep( $delay ); |
|
248 | } |
|
249 | } |
|
250 | ||
251 | $result = self::$sender->do_full_sync(); |
|
252 | } while ( $result ); |
|
253 | } |
|
254 | ||
255 | static function initialize_listener() { |
|
256 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |