WP Bulk Delete - Version 1.1.2

Version Description

Download this release

Release Info

Developer Dharm1025
Plugin Icon 128x128 WP Bulk Delete
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: xylus
3
  Donate link: http://xylusthemes.com
4
  Tags: delete, bulk, clean, bulk delete, bulk clean, posts delete, delete all, mass delete, posts delete, delete posts, delete comments, delete users, delete meta, delete taxonomy, delete revision, wp clean, clean trash, bulk user delete, delete all, delete all users, delete all comments, delete all posts, trash, clean spam, delete with condition, delete with filter, remove
5
  Requires at least: 3.9
6
- Tested up to: 4.7
7
- Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -117,8 +117,7 @@ We are working on providing more options :)
117
  #### Support
118
 
119
  * If you have found a bug/issue or have a feature request, then post them in [Support ticket][1]
120
- * If you have a question about the plugin usage or need help to troubleshoot, then post about it in our [BulkWP Support forums][1]
121
- * If you have a question about any of the addon or need help to troubleshoot the addons, then post about it in our [WP Bulk delete Support][1]
122
  * If you like the Plugin, then kindly leave a review/feedback at [WordPress repo page][2]. This will help more people to discover the plugin.
123
  * Checkout other [WordPress Plugins][3] that we have written
124
 
@@ -164,6 +163,9 @@ We are working on providing more options :)
164
 
165
  == Changelog ==
166
 
 
 
 
167
  = 1.1.1 =
168
  * Added: post count after posttypes
169
 
3
  Donate link: http://xylusthemes.com
4
  Tags: delete, bulk, clean, bulk delete, bulk clean, posts delete, delete all, mass delete, posts delete, delete posts, delete comments, delete users, delete meta, delete taxonomy, delete revision, wp clean, clean trash, bulk user delete, delete all, delete all users, delete all comments, delete all posts, trash, clean spam, delete with condition, delete with filter, remove
5
  Requires at least: 3.9
6
+ Tested up to: 4.8
7
+ Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
117
  #### Support
118
 
119
  * If you have found a bug/issue or have a feature request, then post them in [Support ticket][1]
120
+ * If you have a question about plugin or need help to troubleshoot plugin, then post about it in our [WP Bulk delete Support][1]
 
121
  * If you like the Plugin, then kindly leave a review/feedback at [WordPress repo page][2]. This will help more people to discover the plugin.
122
  * Checkout other [WordPress Plugins][3] that we have written
123
 
163
 
164
  == Changelog ==
165
 
166
+ = 1.1.1 =
167
+ * FIXES: Some bug fixes in delete users
168
+
169
  = 1.1.1 =
170
  * Added: post count after posttypes
171
 
includes/ajax-functions.php CHANGED
@@ -104,7 +104,7 @@ function wpbd_render_terms_by_taxonomy() {
104
  $terms = array();
105
  if ( $post_taxo != '' ) {
106
  if( taxonomy_exists( $post_taxo ) ){
107
- $terms = get_terms( $post_taxo, array( 'hide_empty' => false ) );
108
  }
109
  }
110
  if( ! empty( $terms ) ){
104
  $terms = array();
105
  if ( $post_taxo != '' ) {
106
  if( taxonomy_exists( $post_taxo ) ){
107
+ $terms = get_terms( $post_taxo, array( 'hide_empty' => true ) );
108
  }
109
  }
110
  if( ! empty( $terms ) ){
includes/class-delete-api.php CHANGED
@@ -37,18 +37,18 @@ class WPBD_Delete_API {
37
  global $wpdb;
38
  if( ! empty( $data['delete_post_type'] ) && ! empty( $data['delete_post_status'] ) ){
39
 
40
- $post_types = ( $data['delete_post_type'] ) ? $data['delete_post_type'] : array();
41
  if( ! is_array( $post_types ) ){
42
  $post_types = array( $post_types );
43
  }
44
  $post_types = array_map('esc_sql', $post_types );
45
 
46
- $post_status = ( $data['delete_post_status'] ) ? array_map('esc_sql', $data['delete_post_status'] ) : array();
47
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
48
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
49
  $delete_authors = isset( $data['delete_authors'] ) ? array_map( 'intval', $data['delete_authors'] ) : array();
50
- $delete_type = ( $data['delete_type'] )?$data['delete_type']:'trash';
51
- $limit_post = ( $data['limit_post'] ) ? absint( $data['limit_post'] ) : '';
52
 
53
  // BY Taxonomy.
54
  $post_taxonomy = isset( $data['post_taxonomy'] ) ? esc_sql( $data['post_taxonomy'] ) : '';
@@ -111,7 +111,7 @@ class WPBD_Delete_API {
111
  * @param array $data Posts Id.
112
  * @return array | deleted posts count.
113
  */
114
- public function do_delete_posts( $post_ids = array(), $force_delete = 'false') {
115
  $post_delete_count = 0;
116
 
117
  if ( ! empty( $post_ids ) ){
@@ -402,16 +402,16 @@ class WPBD_Delete_API {
402
  if( empty( $data['delete_user_roles'] ) && ( $data['user_meta_key'] == '' || $data['user_meta_value'] == '' ) ){
403
  return array();
404
  }
405
- $delete_user_roles = ( $data['delete_user_roles'] ) ? $data['delete_user_roles'] : array();
406
  $delete_user_roles = array_map('esc_sql', $delete_user_roles );
407
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
408
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
409
  $limit_user = isset( $data['limit_user'] ) ? absint( $data['limit_user'] ) : '';
410
 
411
  // By Usermeta.
412
- $user_meta_key = ( $data['user_meta_key'] ) ? esc_sql( $data['user_meta_key'] ) : '';
413
- $user_meta_value = ( $data['user_meta_value'] ) ? esc_sql( $data['user_meta_value'] ) : '';
414
- $user_meta_compare = ( $data['user_meta_compare'] ) ? $data['user_meta_compare'] : 'equal_to_str';
415
 
416
  // Query Generation.
417
  $query = "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users ";
@@ -421,11 +421,7 @@ class WPBD_Delete_API {
421
  }
422
 
423
  if( !empty( $delete_user_roles ) ){
424
- $i = 1;
425
- foreach ($delete_user_roles as $delete_user_role ) {
426
- $query .= " INNER JOIN $wpdb->usermeta AS mt{$i} ON ( $wpdb->users.ID = mt{$i}.user_id )";
427
- $i++;
428
- }
429
  }
430
 
431
  $query .= ' WHERE 1=1 ';
@@ -504,11 +500,9 @@ class WPBD_Delete_API {
504
  }
505
 
506
  if( !empty( $delete_user_roles ) ){
507
- $j = 1;
508
  $subquery = array();
509
  foreach ($delete_user_roles as $delete_user_role ) {
510
- $subquery[]= "( mt{$j}.meta_key = '{$wpdb->prefix}capabilities' AND mt{$j}.meta_value LIKE '%\"{$delete_user_role}\"%' )";
511
- $j++;
512
  }
513
  $subquery = implode( ' OR ', $subquery );
514
  $query .= " AND ( {$subquery} )";
@@ -571,10 +565,10 @@ class WPBD_Delete_API {
571
  public function get_delete_comment_count( $data = array() ){
572
  global $wpdb;
573
  $comment_delete_count = 0;
574
- $delete_comment_status = ( $data['delete_comment_status'] ) ? $data['delete_comment_status'] : array();
575
  $delete_comment_status = array_map('esc_sql', $delete_comment_status );
576
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
577
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
578
 
579
  if ( ! empty( $data ) ){
580
 
@@ -631,10 +625,10 @@ class WPBD_Delete_API {
631
  global $wpdb;
632
 
633
  $comment_delete_count = 0;
634
- $delete_comment_status = ( $data['delete_comment_status'] ) ? $data['delete_comment_status'] : array();
635
  $delete_comment_status = array_map('esc_sql', $delete_comment_status );
636
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
637
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
638
 
639
  if ( ! empty( $data ) ){
640
 
@@ -692,9 +686,9 @@ class WPBD_Delete_API {
692
  global $wpdb;
693
  if( ! empty( $data['meta_post_type'] ) && ! empty( $data['custom_field_key'] ) ){
694
 
695
- $post_type = ( $data['meta_post_type'] ) ? esc_sql( $data['meta_post_type'] ) : '';
696
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
697
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
698
 
699
  // Post Query Generation.
700
  $postquery = "SELECT DISTINCT $wpdb->posts.ID FROM $wpdb->posts ";
@@ -766,8 +760,8 @@ class WPBD_Delete_API {
766
  global $wpdb;
767
  if( $data['custom_field_key'] != '' ){
768
 
769
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
770
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
771
 
772
  // Post Query Generation.
773
  $commentquery = "SELECT DISTINCT $wpdb->comments.comment_ID FROM $wpdb->comments WHERE 1 = 1";
@@ -837,9 +831,9 @@ class WPBD_Delete_API {
837
  global $wpdb;
838
  if( $data['custom_field_key'] != '' && !empty( $data['delete_user_roles'] ) ){
839
 
840
- $delete_user_roles = ( $data['delete_user_roles'] ) ? $data['delete_user_roles'] : array();
841
- $delete_start_date = ( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
842
- $delete_end_date = ( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
843
 
844
  $userquery = "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users ";
845
 
37
  global $wpdb;
38
  if( ! empty( $data['delete_post_type'] ) && ! empty( $data['delete_post_status'] ) ){
39
 
40
+ $post_types = isset( $data['delete_post_type'] ) ? $data['delete_post_type'] : array();
41
  if( ! is_array( $post_types ) ){
42
  $post_types = array( $post_types );
43
  }
44
  $post_types = array_map('esc_sql', $post_types );
45
 
46
+ $post_status = isset( $data['delete_post_status'] ) ? array_map('esc_sql', $data['delete_post_status'] ) : array();
47
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
48
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
49
  $delete_authors = isset( $data['delete_authors'] ) ? array_map( 'intval', $data['delete_authors'] ) : array();
50
+ $delete_type = isset( $data['delete_type'] )?$data['delete_type']:'trash';
51
+ $limit_post = isset( $data['limit_post'] ) ? absint( $data['limit_post'] ) : '';
52
 
53
  // BY Taxonomy.
54
  $post_taxonomy = isset( $data['post_taxonomy'] ) ? esc_sql( $data['post_taxonomy'] ) : '';
111
  * @param array $data Posts Id.
112
  * @return array | deleted posts count.
113
  */
114
+ public function do_delete_posts( $post_ids = array(), $force_delete = false ) {
115
  $post_delete_count = 0;
116
 
117
  if ( ! empty( $post_ids ) ){
402
  if( empty( $data['delete_user_roles'] ) && ( $data['user_meta_key'] == '' || $data['user_meta_value'] == '' ) ){
403
  return array();
404
  }
405
+ $delete_user_roles = isset( $data['delete_user_roles'] ) ? $data['delete_user_roles'] : array();
406
  $delete_user_roles = array_map('esc_sql', $delete_user_roles );
407
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
408
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
409
  $limit_user = isset( $data['limit_user'] ) ? absint( $data['limit_user'] ) : '';
410
 
411
  // By Usermeta.
412
+ $user_meta_key = isset( $data['user_meta_key'] ) ? esc_sql( $data['user_meta_key'] ) : '';
413
+ $user_meta_value = isset( $data['user_meta_value'] ) ? esc_sql( $data['user_meta_value'] ) : '';
414
+ $user_meta_compare = isset( $data['user_meta_compare'] ) ? $data['user_meta_compare'] : 'equal_to_str';
415
 
416
  // Query Generation.
417
  $query = "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users ";
421
  }
422
 
423
  if( !empty( $delete_user_roles ) ){
424
+ $query .= " INNER JOIN $wpdb->usermeta AS mt_roles ON ( $wpdb->users.ID = mt_roles.user_id )";
 
 
 
 
425
  }
426
 
427
  $query .= ' WHERE 1=1 ';
500
  }
501
 
502
  if( !empty( $delete_user_roles ) ){
 
503
  $subquery = array();
504
  foreach ($delete_user_roles as $delete_user_role ) {
505
+ $subquery[] = "( mt_roles.meta_key = '{$wpdb->prefix}capabilities' AND mt_roles.meta_value LIKE '%".'\"'.$delete_user_role.'\"%'."' )";
 
506
  }
507
  $subquery = implode( ' OR ', $subquery );
508
  $query .= " AND ( {$subquery} )";
565
  public function get_delete_comment_count( $data = array() ){
566
  global $wpdb;
567
  $comment_delete_count = 0;
568
+ $delete_comment_status = isset( $data['delete_comment_status'] ) ? $data['delete_comment_status'] : array();
569
  $delete_comment_status = array_map('esc_sql', $delete_comment_status );
570
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
571
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
572
 
573
  if ( ! empty( $data ) ){
574
 
625
  global $wpdb;
626
 
627
  $comment_delete_count = 0;
628
+ $delete_comment_status = isset( $data['delete_comment_status'] ) ? $data['delete_comment_status'] : array();
629
  $delete_comment_status = array_map('esc_sql', $delete_comment_status );
630
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
631
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
632
 
633
  if ( ! empty( $data ) ){
634
 
686
  global $wpdb;
687
  if( ! empty( $data['meta_post_type'] ) && ! empty( $data['custom_field_key'] ) ){
688
 
689
+ $post_type = isset( $data['meta_post_type'] ) ? esc_sql( $data['meta_post_type'] ) : '';
690
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
691
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
692
 
693
  // Post Query Generation.
694
  $postquery = "SELECT DISTINCT $wpdb->posts.ID FROM $wpdb->posts ";
760
  global $wpdb;
761
  if( $data['custom_field_key'] != '' ){
762
 
763
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
764
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
765
 
766
  // Post Query Generation.
767
  $commentquery = "SELECT DISTINCT $wpdb->comments.comment_ID FROM $wpdb->comments WHERE 1 = 1";
831
  global $wpdb;
832
  if( $data['custom_field_key'] != '' && !empty( $data['delete_user_roles'] ) ){
833
 
834
+ $delete_user_roles = isset( $data['delete_user_roles'] ) ? $data['delete_user_roles'] : array();
835
+ $delete_start_date = isset( $data['delete_start_date'] ) ? esc_sql( $data['delete_start_date'] ) : '';
836
+ $delete_end_date = isset( $data['delete_end_date'] ) ? esc_sql( $data['delete_end_date'] ) : '';
837
 
838
  $userquery = "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users ";
839
 
includes/common-functions.php CHANGED
@@ -113,7 +113,7 @@ add_action( 'wpbd_display_available_in_pro', 'wpbd_display_available_in_pro' );
113
  function wpbd_get_posttype_post_count( $posttye ){
114
  if( $posttye != '' ){
115
  global $wpdb;
116
- $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = %s", esc_attr( $posttye ) ) );
117
  return $count;
118
  }
119
  return 0;
113
  function wpbd_get_posttype_post_count( $posttye ){
114
  if( $posttye != '' ){
115
  global $wpdb;
116
+ $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = %s AND `post_status` NOT IN ('trash', 'auto-draft')", esc_attr( $posttye ) ) );
117
  return $count;
118
  }
119
  return 0;
includes/delele-users-form-functions.php CHANGED
@@ -84,12 +84,14 @@ function wpdb_render_delete_users_userroles(){
84
  <?php
85
  if( ! empty( $userroles['avail_roles'] ) ){
86
  foreach ($userroles['avail_roles'] as $userrole => $count ) {
 
87
  ?>
88
  <input name="delete_user_roles[]" class="delete_user_roles" id="user_role_<?php echo $userrole; ?>" type="checkbox" value="<?php echo $userrole; ?>" >
89
  <label for="user_role_<?php echo $userrole; ?>">
90
  <?php echo $userrole . ' ' . sprintf( __( '( %s Users )', 'wp-bulk-delete' ), $count ); ?>
91
  </label><br/>
92
- <?php
 
93
  }
94
  }
95
  ?>
84
  <?php
85
  if( ! empty( $userroles['avail_roles'] ) ){
86
  foreach ($userroles['avail_roles'] as $userrole => $count ) {
87
+ if( $userrole != 'none' ){
88
  ?>
89
  <input name="delete_user_roles[]" class="delete_user_roles" id="user_role_<?php echo $userrole; ?>" type="checkbox" value="<?php echo $userrole; ?>" >
90
  <label for="user_role_<?php echo $userrole; ?>">
91
  <?php echo $userrole . ' ' . sprintf( __( '( %s Users )', 'wp-bulk-delete' ), $count ); ?>
92
  </label><br/>
93
+ <?php
94
+ }
95
  }
96
  }
97
  ?>
wp-bulk-delete.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP Bulk Delete
4
  * Plugin URI: http://xylusthemes.com/plugins/wp-bulk-delete/
5
  * Description: Bulk delete and cleanup anything like posts, comments, users, meta fields, taxonomy terms. with powerful filter options.
6
- * Version: 1.1.1
7
  * Author: Xylus Themes
8
  * Author URI: http://xylusthemes.com
9
  * License: GPL-2.0+
3
  * Plugin Name: WP Bulk Delete
4
  * Plugin URI: http://xylusthemes.com/plugins/wp-bulk-delete/
5
  * Description: Bulk delete and cleanup anything like posts, comments, users, meta fields, taxonomy terms. with powerful filter options.
6
+ * Version: 1.1.2
7
  * Author: Xylus Themes
8
  * Author URI: http://xylusthemes.com
9
  * License: GPL-2.0+