render_connected(); } else { $this->render_disconnected(); } } /** * Render the connected state: historical missed checks, chart and stats. * * @since 1.1.0 * @since 1.8.0 Render recorded misses inside the connected widget. */ private function render_connected(): void { $settings_url = admin_url( 'admin.php?page=activelayer-settings' ); $submissions_url = admin_url( 'admin.php?page=activelayer-submissions' ); ?>
dashboard(); ?>
get_queue_stats(); $stats_block = new StatsBlock( $stats ); $stats_block->render(); ?>
summary( ( new ProtectionMonitor() )->scope() ); ?>

get_daily_counts( self::DEFAULT_DAYS ); $stats = Storage::get_instance()->get_queue_stats(); wp_localize_script( 'activelayer-dash-widget', 'activelayerDashWidget', [ 'daily' => $daily, 'stats' => [ 'total' => $stats['total'] ?? 0, 'clean' => $stats['clean'] ?? 0, 'spam' => $stats['spam'] ?? 0, 'failed' => $stats['failed'] ?? 0, ], 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( self::NONCE_ACTION ), ] ); } /** * Handle AJAX request for chart data with a different timespan. * * @since 1.1.0 */ public function ajax_chart_data(): void { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh check_ajax_referer( self::NONCE_ACTION, 'nonce' ); if ( ! current_user_can( 'manage_activelayer' ) ) { wp_send_json_error( [ 'message' => esc_html__( 'Permission denied.', 'activelayer-anti-spam-spam-protection-for-forms-comments' ) ], 403 ); } $days = isset( $_POST['days'] ) ? (int) wp_unslash( $_POST['days'] ) : self::DEFAULT_DAYS; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Cast to int after wp_unslash. if ( ! in_array( $days, self::ALLOWED_DAYS, true ) ) { $days = self::DEFAULT_DAYS; } $daily = Storage::get_instance()->get_daily_counts( $days ); $stats = Storage::get_instance()->get_queue_stats(); wp_send_json_success( [ 'daily' => $daily, 'stats' => [ 'total' => $stats['total'] ?? 0, 'clean' => $stats['clean'] ?? 0, 'spam' => $stats['spam'] ?? 0, 'failed' => $stats['failed'] ?? 0, ], ] ); } }