Delete Duplicate Posts - Version 4.1.9.3

Version Description

  • Fixed bugs introduced with updating to WordPress 4.9.1 - Thank you to all who reported the problem.
Download this release

Release Info

Developer lkoudal
Plugin Icon 128x128 Delete Duplicate Posts
Version 4.1.9.3
Comparing to
See all releases

Code changes from version 4.1.9.1 to 4.1.9.3

Files changed (2) hide show
  1. delete-duplicate-posts.php +70 -59
  2. readme.txt +9 -3
delete-duplicate-posts.php CHANGED
@@ -4,16 +4,22 @@ Plugin Name: Delete Duplicate Posts
4
  Plugin Script: delete-duplicate-posts.php
5
  Plugin URI: https://cleverplugins.com
6
  Description: Remove duplicate blogposts on your blog! Searches and removes duplicate posts and their post meta tags. You can delete posts, pages and other Custom Post Types enabled on your website.
7
- Version: 4.1.9.1
8
  Author: cleverplugins.com
9
  Author URI: https://cleverplugins.com
10
  Min WP Version: 4.3
11
- Max WP Version: 4.8.2
12
  Text Domain: delete-duplicate-posts
13
  Domain Path: /languages
14
 
15
  == Changelog ==
16
 
 
 
 
 
 
 
17
  = 4.1.9.1 =
18
  * Fix missing 3rd party scripts.
19
 
@@ -81,33 +87,33 @@ Domain Path: /languages
81
 
82
  // Create a helper function for easy SDK access.
83
  function ddp_fs() {
84
- global $ddp_fs;
85
 
86
- if ( ! isset( $ddp_fs ) ) {
87
  // Include Freemius SDK.
88
- require_once dirname(__FILE__) . '/freemius/start.php';
89
-
90
- $ddp_fs = fs_dynamic_init( array(
91
- 'id' => '925',
92
- 'slug' => 'delete-duplicate-posts',
93
- 'type' => 'plugin',
94
- 'public_key' => 'pk_0af9f9e83f00e23728a55430a57dd',
95
- 'is_premium' => false,
96
- 'has_addons' => false,
97
- 'has_paid_plans' => false,
98
- 'menu' => array(
99
- 'slug' => 'delete-duplicate-posts.php',
100
- 'account' => true,
101
- 'contact' => false,
102
- 'support' => false,
103
- 'parent' => array(
104
- 'slug' => 'tools.php',
105
- ),
106
- ),
107
- ) );
108
- }
109
-
110
- return $ddp_fs;
111
  }
112
 
113
  // Init Freemius.
@@ -189,7 +195,7 @@ if (!class_exists('delete_duplicate_posts')) {
189
  if (!$limit<>'') $limit=10; //defaults to 10!
190
  if ($manualrun=='1') $limit=9999;
191
  $order=$this->options['ddp_keep'];
192
- if (($order<>'oldest') OR ($order<>'latest')) { // verify default value has been set.
193
  $this->options['ddp_keep']='oldest';
194
  }
195
 
@@ -213,15 +219,15 @@ if (!class_exists('delete_duplicate_posts')) {
213
  $query="select bad_rows.ID, bad_rows.post_title, post_type
214
  from $table_name as bad_rows
215
  inner join (
216
- select post_title,id, ".$minmax." as save_this_post_id
217
- from $table_name
218
- WHERE (
219
- `post_status` = 'publish'
220
- AND
221
- `post_type` in (".$ddp_pts.")
222
- )
223
- group by post_title
224
- having count(*) > 1
225
  ) as good_rows on good_rows.post_title = bad_rows.post_title
226
  and good_rows.save_this_post_id <> bad_rows.id
227
  and (bad_rows.post_status='publish' OR bad_rows.post_status='draft')
@@ -423,17 +429,18 @@ if (!class_exists('delete_duplicate_posts')) {
423
 
424
  if (isset($_POST['ddp_pts'])) {
425
  $optionArray = $_POST['ddp_pts'];
 
426
  for ($i=0; $i<count($optionArray); $i++) {
427
- $posttypes[] = $optionArray[$i];
428
  }
429
  }
430
 
431
  $this->options['ddp_enabled'] = ($_POST['ddp_enabled']=='on')?true:false;
432
  $this->options['ddp_statusmail'] = ( (isset($_POST['ddp_statusmail'])) && ($_POST['ddp_statusmail']=='on'))?true:false;
433
- $this->options['ddp_schedule'] = esc_sql($_POST['ddp_schedule']);
434
- $this->options['ddp_keep'] = esc_sql($_POST['ddp_keep']);
435
- $this->options['ddp_pts'] = esc_sql($posttypes);
436
- $this->options['ddp_limit'] = $_POST['ddp_limit'];
437
  if (isset($this->options['ddp_enabled'])) {
438
  wp_clear_scheduled_hook('ddp_cron');
439
  $interval = $this->options['ddp_schedule'];
@@ -441,6 +448,7 @@ if (!class_exists('delete_duplicate_posts')) {
441
  wp_schedule_event(time(), $interval, 'ddp_cron');
442
  $nextscheduled = wp_next_scheduled('ddp_cron');
443
  }
 
444
  $this->saveAdminOptions();
445
  echo '<div class="updated fade"><p>'.__('Your changes were successfully saved.','delete-duplicate-posts').'</p></div>';
446
  }
@@ -467,13 +475,14 @@ if (!class_exists('delete_duplicate_posts')) {
467
  <div style="float:right; max-width: 300px;">
468
  <a href="https://cleverplugins.com" target="_blank"><img src='<?php echo plugin_dir_url(__FILE__); ?>cleverpluginslogo.png' height="54" width="300" alt="<?php _e('Visit cleverplugins.com','delete-duplicate-posts'); ?>"></a>
469
  <p>Have you checked out our free SEO Booster plugin? <a href="https://wordpress.org/plugins/seo-booster/" target="_blank">wordpress.org/plugins/seo-booster/</a><br/>
 
470
  Or <a href="<?php echo admin_url('plugin-install.php?s=seo+booster+cleverplugins.com&tab=search&type=term'); ?>" target="_blank">click here to install now</a></p>
471
- </div>
472
- <h2>Delete Duplicate Posts v <?php echo $version; ?></h2>
473
- <div id="dashboard">
474
- <?php
475
- if ($this->options['ddp_enabled'] ) {
476
- $nextscheduled = wp_next_scheduled('ddp_cron');
477
  if (!$nextscheduled<>'') { // plugin active, but the cron needs to be activated also..
478
  wp_clear_scheduled_hook('ddp_cron');
479
  $interval = $this->options['ddp_schedule'];
@@ -488,7 +497,8 @@ if (!class_exists('delete_duplicate_posts')) {
488
 
489
  // get custom post types and loop for queary.
490
  $ddp_pts_arr = $this->options['ddp_pts'];
491
- if ($ddp_pts_arr) {
 
492
  $ddp_pts = '';
493
  foreach ($ddp_pts_arr as $key => $dpa ) {
494
  $ddp_pts .= '"'.$dpa.'",';
@@ -501,7 +511,8 @@ if (!class_exists('delete_duplicate_posts')) {
501
  $ddp_pts = rtrim($ddp_pts,',' );
502
 
503
  $order=$this->options['ddp_keep'];
504
- if (($order<>'oldest') OR ($order<>'latest')) { // verify default value has been set.
 
505
  $this->options['ddp_keep']='oldest';
506
  }
507
 
@@ -514,15 +525,15 @@ if (!class_exists('delete_duplicate_posts')) {
514
  $query="select bad_rows.ID, bad_rows.post_title, post_type
515
  from $table_name as bad_rows
516
  inner join (
517
- select post_title,id, ".$minmax." as save_this_post_id
518
- from $table_name
519
- WHERE (
520
- `post_status` = 'publish'
521
- AND
522
- `post_type` in (".$ddp_pts.")
523
- )
524
- group by post_title
525
- having count(*) > 1
526
  ) as good_rows on good_rows.post_title = bad_rows.post_title
527
  and good_rows.save_this_post_id <> bad_rows.id
528
  and (bad_rows.post_status='publish' OR bad_rows.post_status='draft')
4
  Plugin Script: delete-duplicate-posts.php
5
  Plugin URI: https://cleverplugins.com
6
  Description: Remove duplicate blogposts on your blog! Searches and removes duplicate posts and their post meta tags. You can delete posts, pages and other Custom Post Types enabled on your website.
7
+ Version: 4.1.9.3
8
  Author: cleverplugins.com
9
  Author URI: https://cleverplugins.com
10
  Min WP Version: 4.3
11
+ Max WP Version: 4.9.1
12
  Text Domain: delete-duplicate-posts
13
  Domain Path: /languages
14
 
15
  == Changelog ==
16
 
17
+ = 4.1.9.3 =
18
+ * Fixed bugs introduced with updating to WordPress 4.9.1 - Thank you to all who reported the problem.
19
+
20
+ = 4.1.9.2 =
21
+ * Fixed esc_sql() for WordPress 4.8.3
22
+
23
  = 4.1.9.1 =
24
  * Fix missing 3rd party scripts.
25
 
87
 
88
  // Create a helper function for easy SDK access.
89
  function ddp_fs() {
90
+ global $ddp_fs;
91
 
92
+ if ( ! isset( $ddp_fs ) ) {
93
  // Include Freemius SDK.
94
+ require_once dirname(__FILE__) . '/freemius/start.php';
95
+
96
+ $ddp_fs = fs_dynamic_init( array(
97
+ 'id' => '925',
98
+ 'slug' => 'delete-duplicate-posts',
99
+ 'type' => 'plugin',
100
+ 'public_key' => 'pk_0af9f9e83f00e23728a55430a57dd',
101
+ 'is_premium' => false,
102
+ 'has_addons' => false,
103
+ 'has_paid_plans' => false,
104
+ 'menu' => array(
105
+ 'slug' => 'delete-duplicate-posts.php',
106
+ 'account' => true,
107
+ 'contact' => false,
108
+ 'support' => false,
109
+ 'parent' => array(
110
+ 'slug' => 'tools.php',
111
+ ),
112
+ ),
113
+ ) );
114
+ }
115
+
116
+ return $ddp_fs;
117
  }
118
 
119
  // Init Freemius.
195
  if (!$limit<>'') $limit=10; //defaults to 10!
196
  if ($manualrun=='1') $limit=9999;
197
  $order=$this->options['ddp_keep'];
198
+ if (($order<>'oldest') AND ($order<>'latest')) { // verify default value has been set.
199
  $this->options['ddp_keep']='oldest';
200
  }
201
 
219
  $query="select bad_rows.ID, bad_rows.post_title, post_type
220
  from $table_name as bad_rows
221
  inner join (
222
+ select post_title,id, ".$minmax." as save_this_post_id
223
+ from $table_name
224
+ WHERE (
225
+ `post_status` = 'publish'
226
+ AND
227
+ `post_type` in (".$ddp_pts.")
228
+ )
229
+ group by post_title
230
+ having count(*) > 1
231
  ) as good_rows on good_rows.post_title = bad_rows.post_title
232
  and good_rows.save_this_post_id <> bad_rows.id
233
  and (bad_rows.post_status='publish' OR bad_rows.post_status='draft')
429
 
430
  if (isset($_POST['ddp_pts'])) {
431
  $optionArray = $_POST['ddp_pts'];
432
+ //$posttypes = $_POST['ddp_pts'];
433
  for ($i=0; $i<count($optionArray); $i++) {
434
+ $posttypes[] = sanitize_text_field($optionArray[$i]);
435
  }
436
  }
437
 
438
  $this->options['ddp_enabled'] = ($_POST['ddp_enabled']=='on')?true:false;
439
  $this->options['ddp_statusmail'] = ( (isset($_POST['ddp_statusmail'])) && ($_POST['ddp_statusmail']=='on'))?true:false;
440
+ $this->options['ddp_schedule'] = sanitize_text_field($_POST['ddp_schedule']);
441
+ $this->options['ddp_keep'] = sanitize_text_field($_POST['ddp_keep']);
442
+ $this->options['ddp_pts'] = $posttypes;
443
+ $this->options['ddp_limit'] = sanitize_text_field($_POST['ddp_limit']);
444
  if (isset($this->options['ddp_enabled'])) {
445
  wp_clear_scheduled_hook('ddp_cron');
446
  $interval = $this->options['ddp_schedule'];
448
  wp_schedule_event(time(), $interval, 'ddp_cron');
449
  $nextscheduled = wp_next_scheduled('ddp_cron');
450
  }
451
+
452
  $this->saveAdminOptions();
453
  echo '<div class="updated fade"><p>'.__('Your changes were successfully saved.','delete-duplicate-posts').'</p></div>';
454
  }
475
  <div style="float:right; max-width: 300px;">
476
  <a href="https://cleverplugins.com" target="_blank"><img src='<?php echo plugin_dir_url(__FILE__); ?>cleverpluginslogo.png' height="54" width="300" alt="<?php _e('Visit cleverplugins.com','delete-duplicate-posts'); ?>"></a>
477
  <p>Have you checked out our free SEO Booster plugin? <a href="https://wordpress.org/plugins/seo-booster/" target="_blank">wordpress.org/plugins/seo-booster/</a><br/>
478
+ <p>Read more on <a href="https://cleverplugins.com/">cleverplugins.com</a><br/>
479
  Or <a href="<?php echo admin_url('plugin-install.php?s=seo+booster+cleverplugins.com&tab=search&type=term'); ?>" target="_blank">click here to install now</a></p>
480
+ </div>
481
+ <h2>Delete Duplicate Posts v <?php echo $version; ?></h2>
482
+ <div id="dashboard">
483
+ <?php
484
+ if ($this->options['ddp_enabled'] ) {
485
+ $nextscheduled = wp_next_scheduled('ddp_cron');
486
  if (!$nextscheduled<>'') { // plugin active, but the cron needs to be activated also..
487
  wp_clear_scheduled_hook('ddp_cron');
488
  $interval = $this->options['ddp_schedule'];
497
 
498
  // get custom post types and loop for queary.
499
  $ddp_pts_arr = $this->options['ddp_pts'];
500
+
501
+ if ((isset($ddp_pts_arr)) && (is_array($ddp_pts_arr)) ) {
502
  $ddp_pts = '';
503
  foreach ($ddp_pts_arr as $key => $dpa ) {
504
  $ddp_pts .= '"'.$dpa.'",';
511
  $ddp_pts = rtrim($ddp_pts,',' );
512
 
513
  $order=$this->options['ddp_keep'];
514
+
515
+ if (($order<>'oldest') AND ($order<>'latest')) { // verify default value has been set.
516
  $this->options['ddp_keep']='oldest';
517
  }
518
 
525
  $query="select bad_rows.ID, bad_rows.post_title, post_type
526
  from $table_name as bad_rows
527
  inner join (
528
+ select post_title,id, ".$minmax." as save_this_post_id
529
+ from $table_name
530
+ WHERE (
531
+ `post_status` = 'publish'
532
+ AND
533
+ `post_type` in (".$ddp_pts.")
534
+ )
535
+ group by post_title
536
+ having count(*) > 1
537
  ) as good_rows on good_rows.post_title = bad_rows.post_title
538
  and good_rows.save_this_post_id <> bad_rows.id
539
  and (bad_rows.post_status='publish' OR bad_rows.post_status='draft')
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: lkoudal,freemius
3
  Tags: delete duplicate posts, delete duplicate,
4
  Donate link: https://cleverplugins.com
5
  Requires at least: 4.3
6
- Tested up to: 4.8.2
7
- Stable tag: 4.1.9.1
8
  Requires PHP: 5.6
9
 
10
 
@@ -38,6 +38,12 @@ You should restore the backup you took of your website before you ran this tool.
38
 
39
  == Changelog ==
40
 
 
 
 
 
 
 
41
  = 4.1.9.1 =
42
  * Fix missing 3rd party scripts.
43
 
@@ -152,4 +158,4 @@ You should restore the backup you took of your website before you ran this tool.
152
  * First release
153
 
154
  == Upgrade Notice ==
155
- Major rewrite that fixes many bugs and adds new features!
3
  Tags: delete duplicate posts, delete duplicate,
4
  Donate link: https://cleverplugins.com
5
  Requires at least: 4.3
6
+ Tested up to: 4.9.1
7
+ Stable tag: 4.1.9.3
8
  Requires PHP: 5.6
9
 
10
 
38
 
39
  == Changelog ==
40
 
41
+ = 4.1.9.3 =
42
+ * Fixed bugs introduced with updating to WordPress 4.9.1 - Thank you to all who reported the problem.
43
+
44
+ = 4.1.9.2 =
45
+ * Fixed esc_sql() for WordPress 4.8.3
46
+
47
  = 4.1.9.1 =
48
  * Fix missing 3rd party scripts.
49
 
158
  * First release
159
 
160
  == Upgrade Notice ==
161
+ 4.1.9.3 Fixes major bug introduced with WordPress 4.9 - Update now!