$model->storage_days ?? 30, 'class' => \WP_Defender\Model\Setting\Firewall::class, ); return $data; } /** * Cron for delete old log. */ public function firewall_clean_up_logs() { $settings = new \WP_Defender\Model\Setting\Firewall(); /** * Filter Count days for IP logs to be saved to DB. * * @since 2.3 * * @param string */ $storage_days = apply_filters( 'ip_lockout_logs_store_backward', $settings->storage_days ); if ( ! is_numeric( $storage_days ) ) { return; } $time_string = '-' . $storage_days . ' days'; $timestamp = $this->local_to_utc( $time_string ); \WP_Defender\Model\Lockout_Log::remove_logs( $timestamp, 50 ); } /** * Cron for clean up temporary IP block list. */ public function firewall_clean_up_temporary_ip_blocklist() { $models = Lockout_Ip::get_bulk( Lockout_Ip::STATUS_BLOCKED ); foreach( $models as $model ) { $model->status = Lockout_Ip::STATUS_NORMAL; $model->save(); } } /** * Update temporary IP blocklist of Firewall, clear cron job. * The interval settings value is updated once. * * @param string $new_interval */ public function update_cron_schedule_interval( $new_interval ) { $settings = new \WP_Defender\Model\Setting\Firewall(); // If a new interval is different from the saved value, we need to clear the cron job. if ( $new_interval !== $settings->ip_blocklist_cleanup_interval ) { update_site_option( 'wpdef_clear_schedule_firewall_cleanup_temp_blocklist_ips', true ); } } }