15, 'redirection' => 0, // Never follow redirects to other hosts or private addresses. 'user-agent' => 'QWSpeedCache-Preload/' . ( defined( 'QWSC_VERSION' ) ? QWSC_VERSION : '1.0' ), 'headers' => array( 'X-QWSC-Preload' => '1' ), ) ); $code = is_wp_error( $res ) ? 0 : (int) wp_remote_retrieve_response_code( $res ); if ( $code >= 200 && $code < 400 ) { $done++; } else { $failed++; } do_action( 'qwsc_preload_response', $url, $code ); } $stats = get_option( self::STATS_OPTION, array() ); if ( ! is_array( $stats ) ) { $stats = array(); } $stats['last_run'] = time(); $stats['done'] = (int) ( $stats['done'] ?? 0 ) + $done; $stats['failed'] = (int) ( $stats['failed'] ?? 0 ) + $failed; $stats['remaining'] = Queue::count(); update_option( self::STATS_OPTION, $stats, false ); update_option( 'qwsc_last_preload', time(), false ); do_action( 'qwsc_preload_batch_finished', $done, $failed, Queue::count() ); if ( Queue::count() > 0 ) { $this->schedule_process( 15 ); } } /** * Free build: schedule is always off (Pro feature). */ public static function sync_schedule( $schedule = 'off', $force = false ) { $hook = 'qwsc_preload_scheduled'; $ts = wp_next_scheduled( $hook ); if ( $ts ) { wp_unschedule_event( $ts, $hook ); } // Intentionally do not schedule — scheduled preload is Pro-only. } }