| @@ -33,10 +33,10 @@ | ||
| 33 | 33 | /* |
| 34 | 34 | * Reindex plugin table |
| 35 | 35 | */ |
| 36 | 36 | public function reindex_table( $return) { |
| 37 | - $nonce = sanitize_text_field(wp_unslash($_POST['nonce'])); | |
| 38 | - if (! wp_verify_nonce($nonce,'wp_chatbot') || ! current_user_can('manage_options')) { | |
| 37 | + $nonce = sanitize_text_field($_POST['nonce']); | |
| 38 | + if (! wp_verify_nonce($nonce,'wp_chatbot')) { | |
| 39 | 39 | wp_send_json(array('success' => false, 'msg' => esc_html__('Failed in Security check', 'chatbot'))); |
| 40 | 40 | wp_die(); |
| 41 | 41 | |
| 42 | 42 | }else{ |
| @@ -135,9 +135,9 @@ | ||
| 135 | 135 | * Check if index table exist |
| 136 | 136 | */ |
| 137 | 137 | private function is_table_not_exist() { |
| 138 | 138 | global $wpdb; |
| 139 | - return ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $this->table_name ) ) ) != $this->table_name ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 139 | + return ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->table_name}'" ) != $this->table_name ); //DB Call OK, No Caching OK | |
| 140 | 140 | } |
| 141 | 141 | /* |
| 142 | 142 | * Create index table |
| 143 | 143 | */ |
| @@ -158,10 +158,9 @@ | ||
| 158 | 158 | dbDelta( $sql ); |
| 159 | 159 | |
| 160 | 160 | $table_report = $wpdb->prefix . 'wpbot_chat_report'; |
| 161 | 161 | |
| 162 | - if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_report ) ) ) != $table_report ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 163 | - // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 162 | + if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_report'" ) != $table_report ) { | |
| 164 | 163 | $sql_report = " |
| 165 | 164 | CREATE TABLE `$table_report` ( |
| 166 | 165 | `id` int(11) NOT NULL AUTO_INCREMENT, |
| 167 | 166 | `user_id` int(11) NOT NULL, |
| @@ -172,9 +171,8 @@ | ||
| 172 | 171 | `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 173 | 172 | PRIMARY KEY (`id`) |
| 174 | 173 | ) $charset_collate AUTO_INCREMENT=1; |
| 175 | 174 | "; |
| 176 | - // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange | |
| 177 | 175 | |
| 178 | 176 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 179 | 177 | dbDelta( $sql_report ); |
| 180 | 178 | } |
| @@ -208,9 +206,9 @@ | ||
| 208 | 206 | $query = "INSERT IGNORE INTO {$this->table_name} |
| 209 | 207 | (`id`, `term`, `term_source`, `type`, `count`, `in_stock`, `visibility`, `lang`) |
| 210 | 208 | VALUES $values |
| 211 | 209 | "; |
| 212 | - $wpdb->query( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared | |
| 210 | + $wpdb->query( $query ); //DB Call OK, No Caching OK | |
| 213 | 211 | } |
| 214 | 212 | } |
| 215 | 213 | /* |
| 216 | 214 | * Update index table |
| @@ -223,9 +221,9 @@ | ||
| 223 | 221 | $slug = 'product'; |
| 224 | 222 | if ( $slug != $post->post_type ) { |
| 225 | 223 | return; |
| 226 | 224 | } |
| 227 | - $wpdb->delete( $this->table_name, array( 'id' => $post_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 225 | + $wpdb->delete( $this->table_name, array( 'id' => $post_id ) ); //DB Call OK, No Caching OK | |
| 228 | 226 | $posts = get_posts( array( |
| 229 | 227 | 'posts_per_page' => -1, |
| 230 | 228 | 'fields' => 'ids', |
| 231 | 229 | 'post_type' => 'product', |
| @@ -259,9 +257,9 @@ | ||
| 259 | 257 | } else { |
| 260 | 258 | $product_id = $product; |
| 261 | 259 | } |
| 262 | 260 | |
| 263 | - $wpdb->delete( $this->table_name, array( 'id' => $product_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 261 | + $wpdb->delete( $this->table_name, array( 'id' => $product_id ) ); //DB Call OK, No Caching OK | |
| 264 | 262 | |
| 265 | 263 | $posts = get_posts( array( |
| 266 | 264 | 'posts_per_page' => -1, |
| 267 | 265 | 'fields' => 'ids', |
| @@ -276,10 +274,10 @@ | ||
| 276 | 274 | /* |
| 277 | 275 | * Cancel index |
| 278 | 276 | */ |
| 279 | 277 | public function cancel_reindex() { |
| 280 | - $nonce = sanitize_text_field(wp_unslash($_POST['nonce'])); | |
| 281 | - if (! wp_verify_nonce($nonce,'wp_chatbot') || ! current_user_can('manage_options')) { | |
| 278 | + $nonce = sanitize_text_field($_POST['nonce']); | |
| 279 | + if (! wp_verify_nonce($nonce,'wp_chatbot')) { | |
| 282 | 280 | wp_send_json(array('success' => false, 'msg' => esc_html__('Failed in Security check', 'chatbot'))); |
| 283 | 281 | wp_die(); |
| 284 | 282 | |
| 285 | 283 | }else{ |