prefix . 'affcf_submissions'; // Get filter parameters. // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Reading GET parameters for filtering/pagination display only, not for actions $filter_form = isset( $_GET['filter_form'] ) ? absint( wp_unslash( $_GET['filter_form'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $filter_user = isset( $_GET['filter_user'] ) ? absint( wp_unslash( $_GET['filter_user'] ) ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $filter_type = isset( $_GET['filter_type'] ) ? sanitize_text_field( wp_unslash( $_GET['filter_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $filter_date = isset( $_GET['filter_date'] ) ? sanitize_text_field( wp_unslash( $_GET['filter_date'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended // Pagination. $current_page = isset( $_GET['paged'] ) ? absint( wp_unslash( $_GET['paged'] ) ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Recommended // phpcs:enable WordPress.Security.NonceVerification.Recommended $items_per_page = 20; $offset = ( $current_page - 1 ) * $items_per_page; // Build query. $where = array( '1=1' ); if ( $filter_form ) { $where[] = $wpdb->prepare( 's.form_id = %d', $filter_form ); } if ( $filter_user ) { $where[] = $wpdb->prepare( 's.user_id = %d', $filter_user ); } if ( $filter_type ) { $where[] = $wpdb->prepare( 's.submission_type = %s', $filter_type ); } if ( $filter_date ) { switch ( $filter_date ) { case 'today': $where[] = 'DATE(s.submission_date) = CURDATE()'; break; case 'week': $where[] = 's.submission_date >= DATE_SUB(NOW(), INTERVAL 7 DAY)'; break; case 'month': $where[] = 's.submission_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)'; break; } } $where_clause = implode( ' AND ', $where ); // Get total count. // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Table name from $wpdb->prefix, $where_clause built from prepared statements above $total = $wpdb->get_var( "SELECT COUNT(*) FROM {$submissions_table} s WHERE {$where_clause}" ); // Get submissions. // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Table names from $wpdb->prefix, $where_clause built from prepared statements above $submissions = $wpdb->get_results( $wpdb->prepare( "SELECT s.*, p.post_title, p.post_status, u.display_name as user_name, f.form_name FROM {$submissions_table} s LEFT JOIN {$wpdb->posts} p ON s.post_id = p.ID LEFT JOIN {$wpdb->users} u ON s.user_id = u.ID LEFT JOIN {$wpdb->prefix}affcf_forms f ON s.form_id = f.id WHERE {$where_clause} ORDER BY s.submission_date DESC LIMIT %d OFFSET %d", $items_per_page, $offset ) ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter // Get all forms for filter. // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Simple query for admin filter dropdown, no user input $forms = $wpdb->get_results( "SELECT id, form_name FROM {$wpdb->prefix}affcf_forms ORDER BY form_name" ); // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching // Calculate pagination. $total_pages = ceil( $total / $items_per_page ); ?>


prefix, simple statistics queries $stats = array( 'total' => $wpdb->get_var( "SELECT COUNT(*) FROM {$submissions_table}" ), 'today' => $wpdb->get_var( "SELECT COUNT(*) FROM {$submissions_table} WHERE DATE(submission_date) = CURDATE()" ), 'week' => $wpdb->get_var( "SELECT COUNT(*) FROM {$submissions_table} WHERE submission_date >= DATE_SUB(NOW(), INTERVAL 7 DAY)" ), 'month' => $wpdb->get_var( "SELECT COUNT(*) FROM {$submissions_table} WHERE submission_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)" ), ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching ?>

id ); ?> post_title ) : ?> post_title ); ?> user_name ) : ?> user_name ); ?> form_name ) : ?> form_name ); ?> submission_type ) : ?> array( 'bg' => '#d5f0dd', 'color' => '#00712b', 'label' => __( 'Published', 'airy-frontend-forms' ), ), 'pending' => array( 'bg' => '#fcf3cf', 'color' => '#94660c', 'label' => __( 'Pending', 'airy-frontend-forms' ), ), 'draft' => array( 'bg' => '#e5e5e5', 'color' => '#555', 'label' => __( 'Draft', 'airy-frontend-forms' ), ), 'trash' => array( 'bg' => '#fbe4e5', 'color' => '#901b1e', 'label' => __( 'Trashed', 'airy-frontend-forms' ), ), ); // Handle deleted posts (post_status is null from LEFT JOIN when post is deleted). if ( null === $submission->post_status ) { $status_info = array( 'bg' => '#f0f0f1', 'color' => '#646970', 'label' => __( '(Post Deleted)', 'airy-frontend-forms' ), ); } elseif ( isset( $status_colors[ $submission->post_status ] ) ) { // Use predefined status colors. $status_info = $status_colors[ $submission->post_status ]; } else { // Unknown status - use default styling. $status_info = array( 'bg' => '#e5e5e5', 'color' => '#555', 'label' => ucfirst( $submission->post_status ), ); } ?> submission_date ), time() ) . ' ' . __( 'ago', 'airy-frontend-forms' ) ); ?> ip_address ?? 'N/A' ); ?> post_id ) : ?>
1 ) : ?>
add_query_arg( 'paged', '%#%' ), 'format' => '', 'prev_text' => __( '«', 'airy-frontend-forms' ), 'next_text' => __( '»', 'airy-frontend-forms' ), 'total' => $total_pages, 'current' => $current_page, ) ) ); ?>