| 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 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Bulk Delete Buddy Press pending users.  This module is shown only when BuddyPress plugin is | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * installed and active. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @since 6.2.0. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class DeleteBPPendingUsersModule extends UsersModule { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	 * Initialize and setup variables. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	protected function initialize() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		$this->item_type     = 'users'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		$this->field_slug    = 'bp_pending_user'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		$this->meta_box_slug = 'bd_bp_users_by_meta'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		$this->action        = 'delete_bp_pending_users'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		$this->messages      = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 			'box_label'        => __( 'Delete Pending Users', 'bulk-delete' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 			'confirm_deletion' => __( 'Are you sure you want to delete all the Buddy Press pending users?', 'bulk-delete' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 			/* translators: 1 Number of users deleted */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 			'deleted_one'      => __( 'Deleted %d Buddy Press pending user', 'bulk-delete' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 			/* translators: 1 Number of users deleted */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			'deleted_multiple' => __( 'Deleted %d Buddy Press pending users', 'bulk-delete' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	 * Render delete users box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	public function render() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		$count = \BP_Signup::count_signups(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		<!-- Users Start--> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		<h4><?php _e( 'Delete ' . esc_attr( $count ) . ' pending users signed up via buddy press', 'bulk-delete' ); ?></h4> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 		<fieldset class="options"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 			<table class="optiontable"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 				$this->render_filtering_table_header(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 				$this->render_user_login_restrict_settings( false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			</table> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		</fieldset> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		<!-- Users end--> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		$this->render_submit_button(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	protected function convert_user_input_to_options( $request, $options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		return $options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	protected function append_to_js_array( $js_array ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		$js_array['validators'][ $this->action ] = 'noValidation'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		return $js_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 |  |  | 	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	protected function build_query( $options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		// Left empty on purpose. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	// phpcs:ignore Squiz.Commenting.FunctionComment.Missing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	protected function do_delete( $options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 		global $wpdb; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 		$table_name = $wpdb->prefix . 'users'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 		$count      = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		$date_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		if ( $options['registered_restrict'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			$date_query = $this->get_date_query( $options ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		$ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$table_name} WHERE user_status = %d {$date_query}", 2 ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		foreach ( $ids as $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 			$deleted = wp_delete_user( $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			if ( $deleted ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 				$count++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		$table_name = $wpdb->prefix . 'signups'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 		$date_query = str_replace( 'user_registered', 'registered', $date_query ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 		$wpdb->get_col( $wpdb->prepare( "DELETE FROM {$table_name} WHERE active = %d {$date_query}", 0 ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		return $count; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	 * Returns date query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 	 * @param array $options Delete Options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	 * @return string $date_query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 	protected function get_date_query( $options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		$date_query = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		switch ( $options['registered_date_op'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			case 'before': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				$operator   = '<'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				$date       = date( 'Y-m-d', strtotime( '-' . $options['registered_days'] . ' days' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				$date_query = 'AND user_registered ' . $operator . " '" . $date . "'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			case 'after': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 				$operator   = 'between'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 				$start_date = date( 'Y-m-d', strtotime( '-' . $options['registered_days'] . ' days' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				$end_date   = date( 'Y-m-d', strtotime( 'now' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 				$date_query = 'AND user_registered ' . $operator . " '" . $start_date . "' AND '" . $end_date . "'"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		return $date_query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 126 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 127 |  |  |  | 
            
                        
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