PluginProbe
CookieAdmin – Cookie Consent Banner / 1.2.3
CookieAdmin – Cookie Consent Banner v1.2.3
1.2.3 1.2.2 1.2.1 1.2.0 1.1.9 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
← All changes | includes/admin/scan.php +42 -7 1.1.91.2.3 View file →
@@ -54,8 +54,13 @@
54 54
55 55 if(empty($data->description)){
56 56 $data->description = 'Not Available';
57 57 }
58 +
59 + $patterns = !empty($data->patterns) ? $data->patterns : '';
60 + if(!empty($patterns)){
61 + $patterns = strtr($patterns, ['[' => '', ']' => '', '"' => '']);
62 + }
58 63
59 64 $categorized[$data->category] .= '<tr><td>'.esc_html($data->cookie_name).'</td><td>'.esc_html($data->description).'</td><td>'.esc_html($exp).'</td><td> <span class="dashicons dashicons-edit cookieadmin_edit_icon" id="edit_'.esc_attr($data->id).'"></span> <span class="dashicons dashicons-trash cookieadmin_delete_icon" id="delete_'.esc_attr($data->id).'"></span> </td></tr>';
60 65
61 66 $categorized_cookies[$data->id]['id'] = $data->id;
@@ -62,8 +67,9 @@
62 67 $categorized_cookies[$data->id]['cookie_name'] = $data->cookie_name;
63 68 $categorized_cookies[$data->id]['description'] = $data->description;
64 69 $categorized_cookies[$data->id]['category'] = $data->category;
65 70 $categorized_cookies[$data->id]['expires'] = $expires;
71 + $categorized_cookies[$data->id]['patterns'] = $patterns;
66 72
67 73 }
68 74
69 75 wp_register_script('cookieadmin_categorized_cookies', '', array('jquery'), COOKIEADMIN_VERSION, true);
@@ -172,10 +178,19 @@
172 178
173 179 <div class="cookieadmin_form-group">
174 180 <label for="duration">'.esc_html__('Duration', 'cookieadmin').'</label>
175 181 <input type="number" min=0 id="cookieadmin-dialog-cookie-duration" Placeholder="'.esc_html__('Set 0 for Session or expiry in days', 'cookieadmin').'">
176 - </div>
177 - </div>
182 + </div>';
183 +
184 + if(empty($cookieadmin_requires_pro)){
185 + echo '<div class="cookieadmin_form-group">
186 + <label for="patterns">'.esc_html__('Scripts patterns', 'cookieadmin').'</label>
187 + <span>'.__('If scripts has "src" attribute then paste the src or add comma separated patterns to match the scripts. Try choosing log patterns to block only targeted script', 'cookieadmin').'</span>
188 + <br /><span><strong>'.__('Note: ', 'cookieadmin').'</strong>'.__('Wildcards (*, ?, ^, % etc) are not allowed', 'cookieadmin').'</span>
189 + <textarea id="cookieadmin-dialog-cookie-patterns" Placeholder="'.esc_attr__('https://connect.facebook.net/en_US/fbevents.js OR fbq.push, window.facebookSignals', 'cookieadmin').'"></textarea>
190 + </div>';
191 + }
192 + echo '</div>
178 193 <div class="cookieadmin_modal-footer">
179 194 <span id="cookieadmin-message"></span>
180 195 <button class="cookieadmin-btn cookieadmin-btn-primary" id="cookieadmin_dialog_save_btn" form="edit-cookie-form">'.esc_html__('Save', 'cookieadmin').'</button>
181 196 </div>
@@ -449,11 +464,13 @@
449 464 );
450 465 }
451 466
452 467 $cookie_info = map_deep(wp_unslash($_REQUEST['cookie_info']), 'sanitize_text_field');
468 + // $scan_timestamp = $wpdb->get_col($wpdb->prepare("SELECT scan_timestamp FROM {$table_name} WHERE id = %d", $cookie_info['id']));
453 469
454 - $scan_timestamp = $wpdb->get_col($wpdb->prepare("SELECT scan_timestamp FROM {$table_name} WHERE id = %d", $cookie_info['id']));
455 -
470 + $scanned_cookies = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE id = %d", $cookie_info['id']));
471 + $scan_timestamp = !empty($scanned_cookies->scan_timestamp) ? $scanned_cookies->scan_timestamp : 0;
472 +
456 473 if(empty($scan_timestamp)){
457 474 wp_send_json(['success' => false,
458 475 'data' => null,
459 476 'message' => __('Error : Invalid cookie record', 'cookieadmin')]
@@ -459,16 +476,34 @@
459 476 'message' => __('Error : Invalid cookie record', 'cookieadmin')]
460 477 );
461 478 }
462 479
463 - $calculated_expiry_seconds = ($cookie_info['duration'] * 86400) + $scan_timestamp[0];
480 + $calculated_expiry_seconds = ($cookie_info['duration'] * 86400) + $scan_timestamp;
464 481 $calculated_expiry = date('Y-m-d H:i:s', $calculated_expiry_seconds);
482 +
483 + // Update the additional patterns into the saved patterns
484 + $patterns = '[]';
485 + if(!empty($cookie_info['patterns'])){
486 + $script_patterns = explode(',', $cookie_info['patterns']);
487 + if(!empty($script_patterns) && is_array($script_patterns)){
488 + foreach($script_patterns as $pat){
489 + if(strlen(str_replace(['*', '?', '^', '%'], '', $pat)) < strlen($pat)){
490 + continue;
491 + }
492 + // do not ad comma if the saved pattern is empty
493 + $comma = ($patterns === '[]') ? '' : ', ';
494 + $patterns = str_replace(']', $comma . '"' .(string) trim($pat).'"]', $patterns);
495 + }
496 + }
497 + }else{
498 + $patterns = !empty($scanned_cookies->patterns) ? $scanned_cookies->patterns : '[]';
499 + }
465 500
466 501 $resp = $wpdb->update(
467 502 $table_name,
468 - [ 'cookie_name' => $cookie_info['name'], 'description' => $cookie_info['description'], 'expires' => $calculated_expiry, 'category' => $cookie_info['type'], 'edited' => 1], // Data to update
503 + [ 'cookie_name' => $cookie_info['name'], 'description' => $cookie_info['description'], 'expires' => $calculated_expiry, 'category' => $cookie_info['type'], 'patterns' => $patterns, 'edited' => 1], // Data to update
469 504 [ 'id' => $cookie_info['id'] ], // WHERE
470 - [ '%s', '%s', '%s', '%s', '%d' ], // Format for the data
505 + [ '%s', '%s', '%s', '%s', '%s', '%d' ], // Format for the data
471 506 [ '%d' ] // Format for the WHERE clause
472 507 );
473 508
474 509 if ($wpdb->last_error || $resp === false) {