PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.1
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.1
8.8.1 8.8.0 8.7.9 8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 All 537 releases
← All changes | includes/admin/templates/email_subscription.php +46 -26 8.6.6 → 8.8.1 View file →
@@ -21,13 +21,16 @@
21 21 include ABSPATH . 'wp-includes/pluggable.php';
22 22 }
23 23
24 24 $table = $wpdb->prefix . 'wpbot_subscription';
25 + $table_sql = esc_sql( $table );
25 26
26 - if ( isset( $_POST['wpbot_email_subscription_remove'] ) && $_POST['wpbot_email_subscription_remove'] == '1' ) {
27 + if ( isset( $_POST['wpbot_email_subscription_remove'] ) && '1' === $_POST['wpbot_email_subscription_remove'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
28 + check_admin_referer( 'wpbot_email_subscription_delete', 'wpbot_email_subscription_nonce' );
27 29 if ( current_user_can( 'manage_options' ) && isset( $_POST['emails'] ) && is_array( $_POST['emails'] ) ) {
28 - foreach ( $_POST['emails'] as $email_id ) {
29 - $wpdb->delete( $table, array( 'id' => intval( $email_id ) ), array( '%d' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
30 + $email_ids = array_map( 'absint', wp_unslash( $_POST['emails'] ) );
31 + foreach ( $email_ids as $email_id ) {
32 + $wpdb->delete( $table, array( 'id' => $email_id ), array( '%d' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
30 33 }
31 34 echo '<script>window.location.href="' . esc_url_raw( admin_url( 'admin.php?page=email-subscription&msg=success' ) ) . '";</script>';
32 35 exit;
33 36 }
@@ -35,20 +38,36 @@
35 38
36 39 $current_user = wp_get_current_user();
37 40 $url = admin_url( 'edit.php?post_type=sld&page=qcsld_click_list' );
38 41 $customPagHTML = '';
39 - // Main Report Area
40 - $sql1 = $wpdb->prepare( 'SELECT count(*) FROM %i where 1', $table );
41 -
42 - $total = $wpdb->get_var( $sql1 ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
42 + // Main Report Area — cache total count (invalidated when subscriptions change).
43 + $total_cache_key = 'wpbot_email_sub_total';
44 + $total = wp_cache_get( $total_cache_key, 'wpbot' );
45 + if ( false === $total ) {
46 + $total = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
47 + 'SELECT COUNT(*) FROM `' . $table_sql . '`' // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
48 + );
49 + wp_cache_set( $total_cache_key, $total, 'wpbot', 300 );
50 + }
43 51 $items_per_page = 50;
44 52
45 - $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;// phpcs:ignore WordPress.Security.NonceVerification.Missing
53 + $page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1; // phpcs:ignore WordPress.Security.NonceVerification.Missing
46 54 $offset = ( $page * $items_per_page ) - $items_per_page;
47 55
48 - $sql = $wpdb->prepare( 'SELECT * FROM %i where 1 order by id desc LIMIT %d, %d', $table, $offset, $items_per_page );
56 + // Cache paginated rows per page number.
57 + $rows_cache_key = 'wpbot_email_sub_rows_p' . $page;
58 + $rows = wp_cache_get( $rows_cache_key, 'wpbot' );
59 + if ( false === $rows ) {
60 + $rows = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
61 + $wpdb->prepare(
62 + 'SELECT * FROM `' . $table_sql . '` ORDER BY id DESC LIMIT %d, %d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
63 + $offset,
64 + $items_per_page
65 + )
66 + );
67 + wp_cache_set( $rows_cache_key, $rows, 'wpbot', 300 );
68 + }
49 69
50 - $rows = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
51 70 $totalPage = ceil( $total / $items_per_page );
52 71
53 72 if ( $totalPage > 1 ) {
54 73 $customPagHTML = '<div><span class="wpbot_pagination">Page ' . esc_html( $page ) . ' of ' . esc_html( $totalPage ) . '</span>' . paginate_links(
@@ -54,10 +73,10 @@
54 73 $customPagHTML = '<div><span class="wpbot_pagination">Page ' . esc_html( $page ) . ' of ' . esc_html( $totalPage ) . '</span>' . paginate_links(
55 74 array(
56 75 'base' => add_query_arg( 'cpage', '%#%' ),
57 76 'format' => '',
58 - 'prev_text' => esc_html__( '&laquo;' ),
59 - 'next_text' => esc_html__( '&raquo;' ),
77 + 'prev_text' => esc_html__( '&laquo;', 'chatbot' ),
78 + 'next_text' => esc_html__( '&raquo;', 'chatbot' ),
60 79 'total' => esc_html( $totalPage ),
61 80 'current' => esc_html( $page ),
62 81 )
63 82 ) . '</div>';
@@ -66,9 +85,9 @@
66 85
67 86 ?>
68 87 <div class="qchero_sliders_list_wrapper wpbot-userdata-page">
69 88 <div class="sld_menu_title">
70 - <h2><?php echo esc_html__( 'User Data', 'wpchatbot' ); ?></h2>
89 + <h2><?php echo esc_html__( 'User Data', 'chatbot' ); ?></h2>
71 90 </div>
72 91
73 92 <?php if ( $customPagHTML != '' ) : ?>
74 93 <div class="sld_menu_title sld_menu_title_align wpbot-userdata-toolbar">
@@ -82,14 +101,15 @@
82 101 }
83 102 ?>
84 103
85 104 <form id="wpcs_form_sessions" class="wpbot-userdata-form" action="<?php echo esc_url( $mainurl ); ?>" method="POST">
86 - <input type="hidden" name="wpbot_email_subscription_remove" />
105 + <?php wp_nonce_field( 'wpbot_email_subscription_delete', 'wpbot_email_subscription_nonce' ); ?>
106 + <input type="hidden" name="wpbot_email_subscription_remove" value="1" />
87 107
88 108 <div class="wpbot-userdata-actions">
89 - <button type="button" class="button-primary" id="wpbot_submit_email_form"><?php echo esc_html__( 'Delete', 'wpchatbot' ); ?></button>
90 - <a class="button-primary wpbot-userdata-export" href="<?php echo esc_url( admin_url( 'admin-post.php?action=wpbprint.csv' ) ); ?>"><?php echo esc_html__( 'Export All Contacts', 'wpchatbot' ); ?></a>
91 - <span class="wpbot-userdata-total"><?php echo esc_html__( 'Total', 'wpchatbot' ); ?> <strong><?php echo esc_html( $total ); ?></strong></span>
109 + <button type="button" class="button-primary" id="wpbot_submit_email_form"><?php echo esc_html__( 'Delete', 'chatbot' ); ?></button>
110 + <a class="button-primary wpbot-userdata-export" href="<?php echo esc_url( admin_url( 'admin-post.php?action=wpbprint.csv' ) ); ?>"><?php echo esc_html__( 'Export All Contacts', 'chatbot' ); ?></a>
111 + <span class="wpbot-userdata-total"><?php echo esc_html__( 'Total', 'chatbot' ); ?> <strong><?php echo esc_html( $total ); ?></strong></span>
92 112 </div>
93 113
94 114 <div class="qchero_slider_table_area">
95 115 <div class="sld_payment_table">
@@ -99,18 +119,18 @@
99 119 <input type="checkbox" id="wpbot_checked_all" />
100 120 </div>
101 121
102 122 <div class="sld_payment_cell">
103 - <?php echo esc_html__( 'Date', 'wpchatbot' ); ?>
123 + <?php echo esc_html__( 'Date', 'chatbot' ); ?>
104 124 </div>
105 125 <div class="sld_payment_cell">
106 - <?php echo esc_html__( 'Name', 'wpchatbot' ); ?>
126 + <?php echo esc_html__( 'Name', 'chatbot' ); ?>
107 127 </div>
108 128 <div class="sld_payment_cell">
109 - <?php echo esc_html__( 'Email', 'wpchatbot' ); ?>
129 + <?php echo esc_html__( 'Email', 'chatbot' ); ?>
110 130 </div>
111 131 <div class="sld_payment_cell">
112 - <?php echo esc_html__( 'Phone', 'wpchatbot' ); ?>
132 + <?php echo esc_html__( 'Phone', 'chatbot' ); ?>
113 133 </div>
114 134
115 135 </div>
116 136
@@ -124,23 +144,23 @@
124 144 <input type="checkbox" name="emails[]" class="wpbot_email_checkbox" value="<?php echo absint( $row->id ); ?>" />
125 145 </div>
126 146
127 147 <div class="sld_payment_cell">
128 - <div class="sld_responsive_head"><?php echo esc_html__( 'Date', 'wpchatbot' ); ?></div>
129 - <?php echo esc_html( date( 'm/d/Y', strtotime( $row->date ) ) ); ?>
148 + <div class="sld_responsive_head"><?php echo esc_html__( 'Date', 'chatbot' ); ?></div>
149 + <?php echo esc_html( gmdate( 'm/d/Y', strtotime( $row->date ) ) ); ?>
130 150 </div>
131 151 <div class="sld_payment_cell">
132 - <div class="sld_responsive_head"><?php echo esc_html__( 'Name', 'wpchatbot' ); ?></div>
152 + <div class="sld_responsive_head"><?php echo esc_html__( 'Name', 'chatbot' ); ?></div>
133 153 <?php echo esc_html( $row->name ); ?>
134 154 </div>
135 155 <div class="sld_payment_cell">
136 - <div class="sld_responsive_head"><?php echo esc_html__( 'Email', 'wpchatbot' ); ?></div>
156 + <div class="sld_responsive_head"><?php echo esc_html__( 'Email', 'chatbot' ); ?></div>
137 157 <?php
138 158 echo esc_html( $row->email );
139 159 ?>
140 160 </div>
141 161 <div class="sld_payment_cell">
142 - <div class="sld_responsive_head"><?php echo esc_html__( 'Phone', 'wpchatbot' ); ?></div>
162 + <div class="sld_responsive_head"><?php echo esc_html__( 'Phone', 'chatbot' ); ?></div>
143 163 <?php
144 164 echo esc_html( $row->phone );
145 165
146 166 ?>