1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Users\Modules; |
4
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Users\UsersModule; |
6
|
|
|
|
7
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
8
|
|
|
|
9
|
|
|
if ( ! class_exists( '\Buddy Press' ) ) { |
10
|
|
|
return; |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Bulk Delete Buddy Press pending users. |
15
|
|
|
* |
16
|
|
|
* @since 6.2.0. |
17
|
|
|
*/ |
18
|
|
|
class DeleteBPPendingUsersModule extends UsersModule { |
19
|
|
|
/** |
20
|
|
|
* Initialize and setup variables. |
21
|
|
|
*/ |
22
|
|
|
protected function initialize() { |
23
|
|
|
$this->item_type = 'users'; |
24
|
|
|
$this->field_slug = 'bp_pending_user'; |
25
|
|
|
$this->meta_box_slug = 'bd_bp_users_by_meta'; |
26
|
|
|
$this->action = 'delete_bp_pending_users'; |
27
|
|
|
$this->messages = array( |
28
|
|
|
'box_label' => __( 'Delete Pending Users', 'bulk-delete' ), |
29
|
|
|
'confirm_deletion' => __( 'Are you sure you want to delete all the Buddy Press pending users?', 'bulk-delete' ), |
30
|
|
|
/* translators: 1 Number of users deleted */ |
31
|
|
|
'deleted_one' => __( 'Deleted %d Buddy Press pending user', 'bulk-delete' ), |
32
|
|
|
/* translators: 1 Number of users deleted */ |
33
|
|
|
'deleted_multiple' => __( 'Deleted %d Buddy Press pending users', 'bulk-delete' ), |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Render delete users box. |
39
|
|
|
*/ |
40
|
|
|
public function render() { |
41
|
|
|
$count = \BP_Signup::count_signups(); |
|
|
|
|
42
|
|
|
?> |
43
|
|
|
<!-- Users Start--> |
44
|
|
|
<h4><?php _e( 'Delete ' . esc_attr( $count ) . ' pending users signed up via buddy press', 'bulk-delete' ); ?></h4> |
45
|
|
|
|
46
|
|
|
<fieldset class="options"> |
47
|
|
|
<table class="optiontable"> |
48
|
|
|
<?php |
49
|
|
|
$this->render_filtering_table_header(); |
50
|
|
|
$this->render_user_login_restrict_settings( false ); |
51
|
|
|
?> |
52
|
|
|
</table> |
53
|
|
|
</fieldset> |
54
|
|
|
<!-- Users end--> |
55
|
|
|
|
56
|
|
|
<?php |
57
|
|
|
$this->render_submit_button(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
61
|
|
|
protected function convert_user_input_to_options( $request, $options ) { |
62
|
|
|
return $options; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
66
|
|
|
protected function append_to_js_array( $js_array ) { |
67
|
|
|
$js_array['validators'][ $this->action ] = 'noValidation'; |
68
|
|
|
|
69
|
|
|
return $js_array; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
73
|
|
|
protected function build_query( $options ) { |
74
|
|
|
// Left empty on purpose. |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
78
|
|
|
protected function do_delete( $options ) { |
79
|
|
|
global $wpdb; |
80
|
|
|
$table_name = $wpdb->prefix . 'users'; |
81
|
|
|
$count = 0; |
82
|
|
|
$date_query = ''; |
83
|
|
|
|
84
|
|
|
if ( $options['registered_restrict'] ) { |
85
|
|
|
$date_query = $this->get_date_query( $options ); |
86
|
|
|
} |
87
|
|
|
$ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID from {$table_name} where user_status = %d {$date_query}", 2 ) ); |
88
|
|
|
|
89
|
|
|
foreach ( $ids as $id ) { |
90
|
|
|
$deleted = wp_delete_user( $id ); |
91
|
|
|
if ( $deleted ) { |
92
|
|
|
$count++; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
//$status = $wpdb->delete( $wpdb->prefix . 'signups', array( 'active' => 0 ), '%d' ); |
96
|
|
|
return $count; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
protected function get_date_query( $options ) { |
100
|
|
|
$date_query = ''; |
101
|
|
|
switch ( $options['registered_date_op'] ) { |
102
|
|
|
case 'before': |
103
|
|
|
$operator = '<'; |
104
|
|
|
$date = date( 'Y-m-d', strtotime( '-' . $options['registered_days'] . ' days' ) ); |
105
|
|
|
$date_query = 'AND user_registered ' . $operator . ' ' . $date; |
106
|
|
|
break; |
107
|
|
|
case 'after': |
108
|
|
|
$operator = 'between'; |
109
|
|
|
$start_date = date( 'Y-m-d', strtotime( '-' . $options['registered_days'] . ' days' ) ); |
110
|
|
|
$end_date = date( 'Y-m-d', strtotime( 'now' ) ); |
111
|
|
|
$date_query = 'AND user_registered ' . $operator . ' ' . $start_date . 'AND ' . $end_date; |
112
|
|
|
break; |
113
|
|
|
|
114
|
|
|
} |
115
|
|
|
return $date_query; |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths