Completed
Pull Request — dev/5.7.0 (#202)
by Rajan
07:38 queued 03:46
created

Bulk_Delete_Posts::delete_posts_by_status()   B

Complexity

Conditions 4
Paths 6

Size

Total Lines 29
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 16
c 1
b 0
f 0
nc 6
nop 1
dl 0
loc 29
ccs 0
cts 16
cp 0
crap 20
rs 8.5806
1
<?php
2
/**
3
 * Utility class for deleting posts.
4
 *
5
 * @author     Sudar
6
 *
7
 * @package    BulkDelete
8
 */
9
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
10
11
class Bulk_Delete_Posts {
12
	/**
13
	 * Render post status box.
14
	 */
15
	public static function render_delete_posts_by_status_box() {
16
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_POST_STATUS ) ) {
17
			/* translators: 1 Number of posts that are deleted. */
18
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
19
20
			return;
21
		}
22
23
		$post_statuses = bd_get_post_statuses();
24
		$post_count    = wp_count_posts();
25
?>
26
		<h4><?php _e( 'Select the post statuses from which you want to delete posts', 'bulk-delete' ); ?></h4>
27
28
		<fieldset class="options">
29
		<table class="optiontable">
30
31
			<?php foreach ( $post_statuses as $post_status ) : ?>
32
				<tr>
33
					<td>
34
						<input name="smbd_post_status[]" id="smbd_<?php echo esc_attr( $post_status->name ); ?>"
35
							value="<?php echo esc_attr( $post_status->name ); ?>" type="checkbox">
36
37
						<label for="smbd_<?php echo esc_attr( $post_status->name ); ?>">
38
							<?php echo esc_html( $post_status->label ), ' '; ?>
39
							<?php if ( property_exists( $post_count, $post_status->name ) ) : ?>
40
								(<?php echo absint( $post_count->{ $post_status->name } ) . ' ', __( 'Posts', 'bulk-delete' ); ?>)
41
							<?php endif; ?>
42
						</label>
43
					</td>
44
				</tr>
45
			<?php endforeach; ?>
46
47
			<?php $sticky_post_count = count( get_option( 'sticky_posts' ) ); ?>
0 ignored issues
show
Bug introduced by
It seems like get_option('sticky_posts') can also be of type false; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
			<?php $sticky_post_count = count( /** @scrutinizer ignore-type */ get_option( 'sticky_posts' ) ); ?>
Loading history...
48
49
			<tr>
50
				<td>
51
					<input name="smbd_sticky" id="smbd_sticky" value="on" type="checkbox">
52
					<label for="smbd_sticky">
53
						<?php echo __( 'All Sticky Posts', 'bulk-delete' ), ' '; ?>
54
						(<?php echo absint( $sticky_post_count ), ' ', __( 'Posts', 'bulk-delete' ); ?>)
55
						<?php echo '<strong>', __( 'Note', 'bulk-delete' ), '</strong>: ', __( 'The date filter will not work for sticky posts', 'bulk-delete' ); ?>
56
					</label>
57
				</td>
58
			</tr>
59
60
		</table>
61
62
		<table class="optiontable">
63
			<?php bd_render_filtering_table_header(); ?>
64
			<?php bd_render_restrict_settings( 'post_status' ); ?>
65
			<?php bd_render_delete_settings( 'post_status' ); ?>
66
			<?php bd_render_limit_settings( 'post_status' ); ?>
67
			<?php bd_render_cron_settings( 'post_status', 'http://bulkwp.com/addons/scheduler-for-deleting-posts-by-status/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-sps' ); ?>
68
		</table>
69
70
		</fieldset>
71
<?php
72
		bd_render_submit_button( 'delete_posts_by_status' );
73
	}
74
75
	/**
76
	 * Delete posts by post status.
77
	 *
78
	 * @since 5.0
79
	 * @static
80
	 *
81
	 * Nonce verification is done in the hook that calls this function.
82
	 * phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
83
	 */
84
	public static function do_delete_posts_by_status() {
85
		$delete_options = array();
86
87
		$delete_options['restrict']     = bd_array_get_bool( $_POST, 'smbd_post_status_restrict', false );
88
		$delete_options['limit_to']     = absint( bd_array_get( $_POST, 'smbd_post_status_limit_to', 0 ) );
89
		$delete_options['force_delete'] = bd_array_get_bool( $_POST, 'smbd_post_status_force_delete', false );
90
91
		$delete_options['date_op'] = bd_array_get( $_POST, 'smbd_post_status_op' );
92
		$delete_options['days']    = absint( bd_array_get( $_POST, 'smbd_post_status_days' ) );
93
94
		$delete_options['post_status'] = array_map( 'sanitize_text_field', bd_array_get( $_POST, 'smbd_post_status', array() ) );
0 ignored issues
show
Bug introduced by
array() of type array is incompatible with the type string expected by parameter $default of bd_array_get(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

94
		$delete_options['post_status'] = array_map( 'sanitize_text_field', bd_array_get( $_POST, 'smbd_post_status', /** @scrutinizer ignore-type */ array() ) );
Loading history...
95
96
		$delete_options['delete-sticky-posts'] = bd_array_get_bool( $_POST, 'smbd_sticky', false );
97
98
		if ( bd_array_get_bool( $_POST, 'smbd_post_status_cron', false ) ) {
99
			$freq = sanitize_text_field( $_POST['smbd_post_status_cron_freq'] );
100
			$time = strtotime( $_POST['smbd_post_status_cron_start'] ) - ( get_option( 'gmt_offset' ) * 60 * 60 );
101
102
			if ( -1 === $freq ) {
0 ignored issues
show
introduced by
The condition -1 === $freq can never be true.
Loading history...
103
				wp_schedule_single_event( $time, Bulk_Delete::CRON_HOOK_POST_STATUS, array( $delete_options ) );
104
			} else {
105
				wp_schedule_event( $time, $freq, Bulk_Delete::CRON_HOOK_POST_STATUS, array( $delete_options ) );
106
			}
107
108
			$msg = __( 'Posts with the selected status are scheduled for deletion.', 'bulk-delete' ) . ' ';
109
110
			/* translators: 1 Url to view cron jobs */
111
			$msg .= sprintf( __( 'See the full list of <a href = "%s">scheduled tasks</a>', 'bulk-delete' ), get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=' . Bulk_Delete::CRON_PAGE_SLUG );
112
		} else {
113
			$deleted_count = self::delete_posts_by_status( $delete_options );
114
115
			/* translators: 1 Number of posts deleted */
116
			$msg = sprintf( _n( 'Deleted %d post with the selected post status', 'Deleted %d posts with the selected post status', $deleted_count, 'bulk-delete' ), $deleted_count );
117
		}
118
119
		add_settings_error(
120
			Bulk_Delete::POSTS_PAGE_SLUG,
121
			'deleted-posts',
122
			$msg,
123
			'updated'
124
		);
125
	} // phpcs:enable
126
127
	/**
128
	 * Delete posts by post status - drafts, pending posts, scheduled posts etc.
129
	 *
130
	 * @since  5.0
131
	 * @static
132
	 *
133
	 * @param array $delete_options Options for deleting posts.
134
	 *
135
	 * @return int $posts_deleted  Number of posts that were deleted
136
	 */
137
	public static function delete_posts_by_status( $delete_options ) {
138
		$delete_options = bd_convert_old_options_for_delete_post_by_status( $delete_options );
139
		$delete_options = apply_filters( 'bd_delete_options', $delete_options );
140
141
		$posts_deleted = 0;
142
143
		if ( $delete_options['delete-sticky-posts'] ) {
144
			$posts_deleted += self::delete_sticky_posts( $delete_options['force_delete'] );
145
		}
146
147
		if ( empty( $delete_options['post_status'] ) ) {
148
			return $posts_deleted;
149
		}
150
151
		$options = array(
152
			'post_status'  => $delete_options['post_status'],
153
			'post__not_in' => get_option( 'sticky_posts' ),
154
		);
155
156
		$options = bd_build_query_options( $delete_options, $options );
157
158
		$post_ids = bd_query( $options );
159
		foreach ( $post_ids as $post_id ) {
160
			wp_delete_post( $post_id, $delete_options['force_delete'] );
161
		}
162
163
		$posts_deleted += count( $post_ids );
164
165
		return $posts_deleted;
166
	}
167
168
	/**
169
	 * Delete all sticky posts.
170
	 *
171
	 * @since 5.6.0
172
	 *
173
	 * @param bool $force_delete Whether to force delete the posts.
174
	 *
175
	 * @return int Number of posts deleted.
176
	 */
177
	public static function delete_sticky_posts( $force_delete ) {
178
		$sticky_post_ids = get_option( 'sticky_posts' );
179
180
		foreach ( $sticky_post_ids as $sticky_post_id ) {
181
			wp_delete_post( $sticky_post_id, $force_delete );
182
		}
183
184
		return count( $sticky_post_ids );
185
	}
186
187
	/**
188
	 * Render Delete posts by category box.
189
	 */
190
	public static function render_delete_posts_by_category_box() {
191
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_CATEGORY ) ) {
192
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
193
194
			return;
195
		}
196
?>
197
        <!-- Category Start-->
198
        <h4><?php _e( 'Select the post type from which you want to delete posts by category', 'bulk-delete' ); ?></h4>
199
        <fieldset class="options">
200
        <table class="optiontable">
201
			<?php bd_render_post_type_dropdown( 'cats' ); ?>
202
        </table>
203
204
        <h4><?php _e( 'Select the categories from which you wan to delete posts', 'bulk-delete' ); ?></h4>
205
        <p><?php _e( 'Note: The post count below for each category is the total number of posts in that category, irrespective of post type', 'bulk-delete' ); ?>.</p>
206
<?php
207
		$max_select2_value_categories = apply_filters( 'max_select2_value_categories', Bulk_Delete::MAX_SELECT2_LIMIT );
208
209
		$categories = get_categories( array(
210
				'hide_empty' => false,
211
				'number'	 => $max_select2_value_categories
212
			)
213
		);
214
?>
215
        <table class="form-table">
216
            <tr>
217
                <td scope="row">
218
                <?php if( count($categories) >= $max_select2_value_categories ){?>
219
					<select class="select2Ajax" name="smbd_cats[]" data-taxonomy="category" multiple data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>">
220
						<option value="all" selected="selected"><?php _e( 'All Categories', 'bulk-delete' ); ?></option>
221
					</select>
222
				<?php }else{?>
223
					<select class="select2" name="smbd_cats[]" multiple data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>">
224
						<option value="all" selected="selected"><?php _e( 'All Categories', 'bulk-delete' ); ?></option>
225
					<?php foreach ( $categories as $category ) { ?>
226
						<option value="<?php echo $category->cat_ID; ?>"><?php echo $category->cat_name, ' (', $category->count, ' ', __( 'Posts', 'bulk-delete' ), ')'; ?></option>
227
					<?php } ?>
228
					</select>
229
				<?php }?>
230
                </td>
231
            </tr>
232
        </table>
233
234
        <table class="optiontable">
235
			<?php bd_render_filtering_table_header(); ?>
236
			<?php bd_render_restrict_settings( 'cats' ); ?>
237
			<?php bd_render_delete_settings( 'cats' ); ?>
238
			<?php bd_render_private_post_settings( 'cats' ); ?>
239
			<?php bd_render_limit_settings( 'cats' ); ?>
240
			<?php bd_render_cron_settings( 'cats', 'http://bulkwp.com/addons/scheduler-for-deleting-posts-by-category/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-sc' ); ?>
241
        </table>
242
243
        </fieldset>
244
<?php
245
		bd_render_submit_button( 'delete_posts_by_category' );
246
	}
247
248
	/**
249
	 * Process delete posts by category.
250
	 *
251
	 * @since 5.0
252
	 * @static
253
	 */
254
	public static function do_delete_posts_by_category() {
255
		$delete_options = array();
256
257
		$delete_options['post_type']     = bd_array_get( $_POST, 'smbd_cats_post_type', 'post' );
258
		$delete_options['selected_cats'] = bd_array_get( $_POST, 'smbd_cats' );
259
		$delete_options['restrict']      = bd_array_get_bool( $_POST, 'smbd_cats_restrict', false );
260
		$delete_options['private']       = bd_array_get_bool( $_POST, 'smbd_cats_private', false );
261
		$delete_options['limit_to']      = absint( bd_array_get( $_POST, 'smbd_cats_limit_to', 0 ) );
262
		$delete_options['force_delete']  = bd_array_get_bool( $_POST, 'smbd_cats_force_delete', false );
263
264
		$delete_options['date_op']       = bd_array_get( $_POST, 'smbd_cats_op' );
265
		$delete_options['days']          = absint( bd_array_get( $_POST, 'smbd_cats_days' ) );
266
267
		if ( bd_array_get_bool( $_POST, 'smbd_cats_cron', false ) ) {
268
			$freq = $_POST['smbd_cats_cron_freq'];
269
			$time = strtotime( $_POST['smbd_cats_cron_start'] ) - ( get_option( 'gmt_offset' ) * 60 * 60 );
270
271
			if ( $freq == -1 ) {
272
				wp_schedule_single_event( $time, Bulk_Delete::CRON_HOOK_CATEGORY, array( $delete_options ) );
273
			} else {
274
				wp_schedule_event( $time, $freq , Bulk_Delete::CRON_HOOK_CATEGORY, array( $delete_options ) );
275
			}
276
277
			$msg = __( 'Posts from the selected categories are scheduled for deletion.', 'bulk-delete' ) . ' ' .
278
				sprintf( __( 'See the full list of <a href = "%s">scheduled tasks</a>' , 'bulk-delete' ), get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=' . Bulk_Delete::CRON_PAGE_SLUG );
279
		} else {
280
			$deleted_count = self::delete_posts_by_category( $delete_options );
281
			$msg           = sprintf( _n( 'Deleted %d post from the selected categories', 'Deleted %d posts from the selected categories' , $deleted_count, 'bulk-delete' ), $deleted_count );
282
		}
283
284
		add_settings_error(
285
			Bulk_Delete::POSTS_PAGE_SLUG,
286
			'deleted-posts',
287
			$msg,
288
			'updated'
289
		);
290
	}
291
292
	/**
293
	 * Delete posts by category.
294
	 *
295
	 * @since 5.0
296
	 * @static
297
	 *
298
	 * @param array $delete_options Options for deleting posts
299
	 *
300
	 * @return int $posts_deleted  Number of posts that were deleted
301
	 */
302
	public static function delete_posts_by_category( $delete_options ) {
303
		// Backward compatibility code. Will be removed in Bulk Delete v6.0
304
		$delete_options['post_type'] = bd_array_get( $delete_options, 'post_type', 'post' );
305
306
		if ( array_key_exists( 'cats_op', $delete_options ) ) {
307
			$delete_options['date_op'] = $delete_options['cats_op'];
308
			$delete_options['days']    = $delete_options['cats_days'];
309
		}
310
311
		$delete_options = apply_filters( 'bd_delete_options', $delete_options );
312
313
		$options       = array();
314
		$selected_cats = $delete_options['selected_cats'];
315
		if ( in_array( 'all', $selected_cats ) ) {
316
			$options['category__not__in'] = array(0);
317
		} else {
318
			$options['category__in'] = $selected_cats;
319
		}
320
321
		$options  = bd_build_query_options( $delete_options, $options );
322
		$post_ids = bd_query( $options );
323
324
		foreach ( $post_ids as $post_id ) {
325
			// $force delete parameter to custom post types doesn't work
326
			if ( $delete_options['force_delete'] ) {
327
				wp_delete_post( $post_id, true );
328
			} else {
329
				wp_trash_post( $post_id );
330
			}
331
		}
332
333
		return count( $post_ids );
334
	}
335
336
	/**
337
	 * Render delete posts by tag box.
338
	 */
339
	public static function render_delete_posts_by_tag_box() {
340
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_TAG ) ) {
341
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
342
343
			return;
344
		}
345
346
		$max_select2_value_tags = apply_filters( 'max_select2_value_tags', Bulk_Delete::MAX_SELECT2_LIMIT );
347
348
		$tags = get_tags(
349
			array(
350
				'hide_empty' => false,
351
				'number'	 => $max_select2_value_tags
352
			)
353
		);
354
		if ( count( $tags ) > 0 ) {
355
?>
356
            <h4><?php _e( 'Select the tags from which you want to delete posts', 'bulk-delete' ) ?></h4>
357
358
            <!-- Tags start-->
359
            <fieldset class="options">
360
            <table class="form-table">
361
                <tr>
362
				<td scope="row" colspan="2">
363
					<?php if( count($tags) >= $max_select2_value_tags ){?>
364
					<select class="select2Ajax" name="smbd_tags[]" data-taxonomy="post_tag" multiple data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>">
365
					<option value="all" selected="selected"><?php _e( 'All Tags', 'bulk-delete' ); ?></option>
366
					</select>
367
					<?php } else{ ?>
368
					<select class="select2" name="smbd_tags[]" multiple data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>">
369
						<option value="all" selected="selected"><?php _e( 'All Tags', 'bulk-delete' ); ?></option>
370
					<?php foreach ( $tags as $tag ) { ?>
371
						<option value="<?php echo absint( $tag->term_id ); ?>"><?php echo $tag->name, ' (', $tag->count, ' ', __( 'Posts', 'bulk-delete' ), ')'; ?></option>
372
					<?php } ?>
373
					</select>
374
					<?php } ?>
375
				</td>
376
                </tr>
377
			</table>
378
379
            <table class="optiontable">
380
				<?php bd_render_filtering_table_header(); ?>
381
				<?php bd_render_restrict_settings( 'tags' ); ?>
382
				<?php bd_render_delete_settings( 'tags' ); ?>
383
				<?php bd_render_private_post_settings( 'tags' ); ?>
384
				<?php bd_render_limit_settings( 'tags' ); ?>
385
				<?php bd_render_cron_settings( 'tags', 'http://bulkwp.com/addons/scheduler-for-deleting-posts-by-tag/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-st' ); ?>
386
            </table>
387
            </fieldset>
388
<?php
389
			bd_render_submit_button( 'delete_posts_by_tag' );
390
		} else {
391
?>
392
            <h4><?php _e( "You don't have any posts assigned to tags in this blog.", 'bulk-delete' ) ?></h4>
393
<?php
394
		}
395
	}
396
397
	/**
398
	 * Process Delete Posts by tag request.
399
	 *
400
	 * @static
401
	 *
402
	 * @since 5.0
403
	 */
404
	public static function do_delete_posts_by_tag() {
405
		$delete_options                  = array();
406
		$delete_options['selected_tags'] = bd_array_get( $_POST, 'smbd_tags' );
407
		$delete_options['restrict']      = bd_array_get_bool( $_POST, 'smbd_tags_restrict', false );
408
		$delete_options['private']       = bd_array_get( $_POST, 'smbd_tags_private' );
409
		$delete_options['limit_to']      = absint( bd_array_get( $_POST, 'smbd_tags_limit_to', 0 ) );
410
		$delete_options['force_delete']  = bd_array_get_bool( $_POST, 'smbd_tags_force_delete', false );
411
412
		$delete_options['date_op']       = bd_array_get( $_POST, 'smbd_tags_op' );
413
		$delete_options['days']          = absint( bd_array_get( $_POST, 'smbd_tags_days' ) );
414
415
		if ( bd_array_get( $_POST, 'smbd_tags_cron', 'false' ) == 'true' ) {
416
			$freq = $_POST['smbd_tags_cron_freq'];
417
			$time = strtotime( $_POST['smbd_tags_cron_start'] ) - ( get_option( 'gmt_offset' ) * 60 * 60 );
418
419
			if ( $freq == -1 ) {
420
				wp_schedule_single_event( $time, Bulk_Delete::CRON_HOOK_TAG, array( $delete_options ) );
421
			} else {
422
				wp_schedule_event( $time, $freq, Bulk_Delete::CRON_HOOK_TAG, array( $delete_options ) );
423
			}
424
			$msg = __( 'Posts from the selected tags are scheduled for deletion.', 'bulk-delete' ) . ' ' .
425
				sprintf( __( 'See the full list of <a href = "%s">scheduled tasks</a>' , 'bulk-delete' ), get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=' . Bulk_Delete::CRON_PAGE_SLUG );
426
		} else {
427
			$deleted_count = self::delete_posts_by_tag( $delete_options );
428
			$msg           = sprintf( _n( 'Deleted %d post from the selected tags', 'Deleted %d posts from the selected tags' , $deleted_count, 'bulk-delete' ), $deleted_count );
429
		}
430
431
		add_settings_error(
432
			Bulk_Delete::POSTS_PAGE_SLUG,
433
			'deleted-posts',
434
			$msg,
435
			'updated'
436
		);
437
	}
438
439
	/**
440
	 * Delete posts by tag.
441
	 *
442
	 * @since 5.0
443
	 * @static
444
	 *
445
	 * @param array $delete_options Options for deleting posts
446
	 *
447
	 * @return int $posts_deleted  Number of posts that were deleted
448
	 */
449
	public static function delete_posts_by_tag( $delete_options ) {
450
		// Backward compatibility code. Will be removed in Bulk Delete v6.0
451
		if ( array_key_exists( 'tags_op', $delete_options ) ) {
452
			$delete_options['date_op'] = $delete_options['tags_op'];
453
			$delete_options['days']    = $delete_options['tags_days'];
454
		}
455
456
		$delete_options = apply_filters( 'bd_delete_options', $delete_options );
457
458
		$options       = array();
459
		$selected_tags = $delete_options['selected_tags'];
460
		if ( in_array( 'all', $selected_tags ) ) {
461
			$options['tag__not__in'] = array(0);
462
		} else {
463
			$options['tag__in'] = $selected_tags;
464
		}
465
466
		$options  = bd_build_query_options( $delete_options, $options );
467
		$post_ids = bd_query( $options );
468
		foreach ( $post_ids as $post_id ) {
469
			wp_delete_post( $post_id, $delete_options['force_delete'] );
470
		}
471
472
		return count( $post_ids );
473
	}
474
475
	/**
476
	 * Render delete by custom taxonomy box.
477
	 */
478
	public static function render_delete_posts_by_taxonomy_box() {
479
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_TAX ) ) {
480
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
481
482
			return;
483
		}
484
485
		$taxs =  get_taxonomies( array(
486
				'public'   => true,
487
				'_builtin' => false,
488
			), 'objects'
489
		);
490
491
		$terms_array = array();
492
		if ( count( $taxs ) > 0 ) {
493
			foreach ( $taxs as $tax ) {
494
				$terms = get_terms( $tax->name );
495
				if ( count( $terms ) > 0 ) {
0 ignored issues
show
Bug introduced by
It seems like $terms can also be of type WP_Error; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

495
				if ( count( /** @scrutinizer ignore-type */ $terms ) > 0 ) {
Loading history...
496
					$terms_array[$tax->name] = $terms;
497
				}
498
			}
499
		}
500
501
		if ( count( $terms_array ) > 0 ) {
502
?>
503
        <!-- Custom tax Start-->
504
        <h4><?php _e( 'Select the post type from which you want to delete posts by custom taxonomy', 'bulk-delete' ); ?></h4>
505
506
        <fieldset class="options">
507
            <table class="optiontable">
508
				<?php bd_render_post_type_dropdown( 'tax' ); ?>
509
            </table>
510
511
            <h4><?php _e( 'Select the taxonomies from which you want to delete posts', 'bulk-delete' ) ?></h4>
512
513
            <table class="optiontable">
514
<?php
515
			foreach ( $terms_array as $tax => $terms ) {
516
?>
517
                <tr>
518
                    <td scope="row" >
519
                        <input name="smbd_taxs" value="<?php echo $tax; ?>" type="radio" class="custom-tax">
520
                    </td>
521
                    <td>
522
                        <label for="smbd_taxs"><?php echo $taxs[$tax]->labels->name; ?> </label>
523
                    </td>
524
                </tr>
525
<?php
526
			}
527
?>
528
            </table>
529
530
            <h4><?php _e( 'The selected taxonomy has the following terms. Select the terms from which you want to delete posts', 'bulk-delete' ) ?></h4>
531
            <p><?php _e( 'Note: The post count below for each term is the total number of posts in that term, irrespective of post type', 'bulk-delete' ); ?>.</p>
532
<?php
533
			foreach ( $terms_array as $tax => $terms ) {
534
?>
535
            <table class="optiontable terms_<?php echo $tax;?> terms">
536
<?php
537
				foreach ( $terms as $term ) {
538
?>
539
                    <tr>
540
                        <td scope="row" >
541
                            <input name="smbd_tax_terms[]" value="<?php echo $term->slug; ?>" type="checkbox" class="terms">
542
                        </td>
543
                        <td>
544
                            <label for="smbd_tax_terms"><?php echo $term->name; ?> (<?php echo $term->count . ' '; _e( 'Posts', 'bulk-delete' ); ?>)</label>
545
                        </td>
546
                    </tr>
547
<?php
548
				}
549
?>
550
            </table>
551
<?php
552
			}
553
?>
554
            <table class="optiontable">
555
				<?php bd_render_filtering_table_header(); ?>
556
				<?php bd_render_restrict_settings( 'taxs' ); ?>
557
				<?php bd_render_delete_settings( 'taxs' ); ?>
558
				<?php bd_render_private_post_settings( 'taxs' ); ?>
559
				<?php bd_render_limit_settings( 'taxs' ); ?>
560
				<?php bd_render_cron_settings( 'taxs', 'http://bulkwp.com/addons/scheduler-for-deleting-posts-by-taxonomy/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-stx' ); ?>
561
            </table>
562
563
            </fieldset>
564
<?php
565
			bd_render_submit_button( 'delete_posts_by_taxonomy' );
566
		} else {
567
?>
568
            <h4><?php _e( "This WordPress installation doesn't have any non-empty custom taxonomies defined", 'bulk-delete' ) ?></h4>
569
<?php
570
		}
571
	}
572
573
	/**
574
	 * Process Delete posts by Taxonomy Request.
575
	 *
576
	 * @static
577
	 *
578
	 * @since 5.0
579
	 */
580
	public static function do_delete_posts_by_taxonomy() {
581
		$delete_options                       = array();
582
		$delete_options['post_type']          = bd_array_get( $_POST, 'smbd_tax_post_type', 'post' );
583
		$delete_options['selected_taxs']      = bd_array_get( $_POST, 'smbd_taxs' );
584
		$delete_options['selected_tax_terms'] = bd_array_get( $_POST, 'smbd_tax_terms' );
585
		$delete_options['restrict']           = bd_array_get_bool( $_POST, 'smbd_taxs_restrict', false );
586
		$delete_options['private']            = bd_array_get_bool( $_POST, 'smbd_taxs_private' );
587
		$delete_options['limit_to']           = absint( bd_array_get( $_POST, 'smbd_taxs_limit_to', 0 ) );
588
		$delete_options['force_delete']       = bd_array_get_bool( $_POST, 'smbd_taxs_force_delete', false );
589
590
		$delete_options['date_op']            = bd_array_get( $_POST, 'smbd_taxs_op' );
591
		$delete_options['days']               = absint( bd_array_get( $_POST, 'smbd_taxs_days' ) );
592
593
		if ( bd_array_get( $_POST, 'smbd_taxs_cron', 'false' ) == 'true' ) {
594
			$freq = $_POST['smbd_taxs_cron_freq'];
595
			$time = strtotime( $_POST['smbd_taxs_cron_start'] ) - ( get_option( 'gmt_offset' ) * 60 * 60 );
596
597
			if ( $freq == -1 ) {
598
				wp_schedule_single_event( $time, Bulk_Delete::CRON_HOOK_TAXONOMY, array( $delete_options ) );
599
			} else {
600
				wp_schedule_event( $time, $freq, Bulk_Delete::CRON_HOOK_TAXONOMY, array( $delete_options ) );
601
			}
602
			$msg = __( 'Posts from the selected custom taxonomies are scheduled for deletion.', 'bulk-delete' ) . ' ' .
603
				sprintf( __( 'See the full list of <a href = "%s">scheduled tasks</a>' , 'bulk-delete' ), get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=' . Bulk_Delete::CRON_PAGE_SLUG );
604
		} else {
605
			$deleted_count = self::delete_posts_by_taxonomy( $delete_options );
606
			$msg           = sprintf( _n( 'Deleted %d post from the selected custom taxonomies', 'Deleted %d posts from the selected custom taxonomies' , $deleted_count, 'bulk-delete' ), $deleted_count );
607
		}
608
609
		add_settings_error(
610
			Bulk_Delete::POSTS_PAGE_SLUG,
611
			'deleted-posts',
612
			$msg,
613
			'updated'
614
		);
615
	}
616
617
	/**
618
	 * Delete posts by custom taxonomy.
619
	 *
620
	 * @since 5.0
621
	 * @static
622
	 *
623
	 * @param array $delete_options Options for deleting posts
624
	 *
625
	 * @return int $posts_deleted  Number of posts that were deleted
626
	 */
627
	public static function delete_posts_by_taxonomy( $delete_options ) {
628
		// For compatibility reasons set default post type to 'post'
629
		$post_type = bd_array_get( $delete_options, 'post_type', 'post' );
630
631
		if ( array_key_exists( 'taxs_op', $delete_options ) ) {
632
			$delete_options['date_op'] = $delete_options['taxs_op'];
633
			$delete_options['days']    = $delete_options['taxs_days'];
634
		}
635
636
		$delete_options = apply_filters( 'bd_delete_options', $delete_options );
637
638
		$selected_taxs      = $delete_options['selected_taxs'];
639
		$selected_tax_terms = $delete_options['selected_tax_terms'];
640
641
		$options = array(
642
			'post_status' => 'publish',
643
			'post_type'   => $post_type,
644
			'tax_query'   => array(
645
				array(
646
					'taxonomy' => $selected_taxs,
647
					'terms'    => $selected_tax_terms,
648
					'field'    => 'slug',
649
				),
650
			),
651
		);
652
653
		$options  = bd_build_query_options( $delete_options, $options );
654
		$post_ids = bd_query( $options );
655
		foreach ( $post_ids as $post_id ) {
656
			// $force delete parameter to custom post types doesn't work
657
			if ( $delete_options['force_delete'] ) {
658
				wp_delete_post( $post_id, true );
659
			} else {
660
				wp_trash_post( $post_id );
661
			}
662
		}
663
664
		return count( $post_ids );
665
	}
666
667
	/**
668
	 * Render delete by custom post type box.
669
	 *
670
	 * @static
671
	 */
672
	public static function render_delete_posts_by_post_type_box() {
673
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_POST_TYPE ) ) {
674
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
675
676
			return;
677
		}
678
679
		$types_array = array();
680
681
		$types = get_post_types( array(
682
				'_builtin' => false,
683
			), 'names'
684
		);
685
686
		if ( count( $types ) > 0 ) {
687
			foreach ( $types as $type ) {
688
				$post_count = wp_count_posts( $type );
689
				if ( $post_count->publish > 0 ) {
690
					$types_array["$type-publish"] = $post_count->publish;
691
				}
692
				if ( $post_count->future > 0 ) {
693
					$types_array["$type-future"] = $post_count->future;
694
				}
695
				if ( $post_count->pending > 0 ) {
696
					$types_array["$type-pending"] = $post_count->pending;
697
				}
698
				if ( $post_count->draft > 0 ) {
699
					$types_array["$type-draft"] = $post_count->draft;
700
				}
701
				if ( $post_count->private > 0 ) {
702
					$types_array["$type-private"] = $post_count->private;
703
				}
704
			}
705
		}
706
707
		if ( count( $types_array ) > 0 ) {
708
?>
709
            <!-- Custom post type Start-->
710
            <h4><?php _e( 'Select the custom post types from which you want to delete posts', 'bulk-delete' ) ?></h4>
711
712
            <fieldset class="options">
713
            <table class="optiontable">
714
<?php
715
			foreach ( $types_array as $type => $count ) {
716
?>
717
                <tr>
718
                    <td scope="row" >
719
                        <input name="smbd_types[]" value="<?php echo $type; ?>" type="checkbox">
720
                    </td>
721
                    <td>
722
						<label for="smbd_types"><?php echo BD_Util::display_post_type_status( $type ), ' (', $count, ')'; ?></label>
723
                    </td>
724
                </tr>
725
<?php
726
			}
727
728
			bd_render_filtering_table_header();
729
			bd_render_restrict_settings( 'types' );
730
			bd_render_delete_settings( 'types' );
731
			bd_render_limit_settings( 'types' );
732
			bd_render_cron_settings( 'types', 'http://bulkwp.com/addons/scheduler-for-deleting-posts-by-post-type/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-spt' );
733
?>
734
            </table>
735
            </fieldset>
736
<?php
737
			bd_render_submit_button( 'delete_posts_by_post_type' );
738
		} else {
739
            printf( '<h4>%s</h4>', __( "This WordPress installation doesn't have any non-empty custom post types", 'bulk-delete' ) );
740
		}
741
	}
742
743
	/**
744
	 * Process request to delete posts by post type.
745
	 *
746
	 * @static
747
	 *
748
	 * @since 5.0
749
	 */
750
	public static function do_delete_posts_by_post_type() {
751
		$delete_options                   = array();
752
753
		$delete_options['selected_types'] = bd_array_get( $_POST, 'smbd_types' );
754
		$delete_options['restrict']       = bd_array_get_bool( $_POST, 'smbd_types_restrict', false );
755
		$delete_options['limit_to']       = absint( bd_array_get( $_POST, 'smbd_types_limit_to', 0 ) );
756
		$delete_options['force_delete']   = bd_array_get_bool( $_POST, 'smbd_types_force_delete', false );
757
758
		$delete_options['date_op']        = bd_array_get( $_POST, 'smbd_types_op' );
759
		$delete_options['days']           = absint( bd_array_get( $_POST, 'smbd_types_days' ) );
760
761
		if ( bd_array_get( $_POST, 'smbd_types_cron', 'false' ) == 'true' ) {
762
			$freq = $_POST['smbd_types_cron_freq'];
763
			$time = strtotime( $_POST['smbd_types_cron_start'] ) - ( get_option( 'gmt_offset' ) * 60 * 60 );
764
765
			if ( $freq == -1 ) {
766
				wp_schedule_single_event( $time, Bulk_Delete::CRON_HOOK_POST_TYPE, array( $delete_options ) );
767
			} else {
768
				wp_schedule_event( $time, $freq, Bulk_Delete::CRON_HOOK_POST_TYPE, array( $delete_options ) );
769
			}
770
771
			$msg = __( 'Posts from the selected custom post type are scheduled for deletion.', 'bulk-delete' ) . ' ' .
772
				sprintf( __( 'See the full list of <a href = "%s">scheduled tasks</a>' , 'bulk-delete' ), get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=' . Bulk_Delete::CRON_PAGE_SLUG );
773
		} else {
774
			$deleted_count = self::delete_posts_by_post_type( $delete_options );
775
			$msg           = sprintf( _n( 'Deleted %d post from the selected custom post type', 'Deleted %d posts from the selected custom post type' , $deleted_count, 'bulk-delete' ), $deleted_count );
776
		}
777
778
		add_settings_error(
779
			Bulk_Delete::POSTS_PAGE_SLUG,
780
			'deleted-posts',
781
			$msg,
782
			'updated'
783
		);
784
	}
785
786
	/**
787
	 * Delete posts by custom post type.
788
	 *
789
	 * @static
790
	 *
791
	 * @since  5.0
792
	 *
793
	 * @param array $delete_options Options for deleting posts
794
	 *
795
	 * @return int $posts_deleted  Number of posts that were deleted
796
	 */
797
	public static function delete_posts_by_post_type( $delete_options ) {
798
		// Backward compatibility code. Will be removed in Bulk Delete v6.0
799
		if ( array_key_exists( 'types_op', $delete_options ) ) {
800
			$delete_options['date_op'] = $delete_options['types_op'];
801
			$delete_options['days']    = $delete_options['types_days'];
802
		}
803
804
		$delete_options = apply_filters( 'bd_delete_options', $delete_options );
805
806
		$count          = 0;
807
		$selected_types = $delete_options['selected_types'];
808
809
		foreach ( $selected_types as $selected_type ) {
810
			$type_status = BD_Util::split_post_type_status( $selected_type );
811
812
			$type        = $type_status['type'];
813
			$status      = $type_status['status'];
814
815
			$options = array(
816
				'post_status' => $status,
817
				'post_type'   => $type,
818
			);
819
820
			$options  = bd_build_query_options( $delete_options, $options );
821
			$post_ids = bd_query( $options );
822
			foreach ( $post_ids as $post_id ) {
823
				// $force delete parameter to custom post types doesn't work
824
				if ( $delete_options['force_delete'] ) {
825
					wp_delete_post( $post_id, true );
826
				} else {
827
					wp_trash_post( $post_id );
828
				}
829
			}
830
831
			$count += count( $post_ids );
832
		}
833
834
		return $count;
835
	}
836
837
	/**
838
	 * Render delete by url box.
839
	 *
840
	 * @static
841
	 */
842
	public static function render_delete_posts_by_url_box() {
843
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_URL ) ) {
844
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
845
846
			return;
847
		}
848
?>
849
        <!-- URLs start-->
850
        <h4><?php _e( 'Delete posts and pages that have the following Permalink', 'bulk-delete' ); ?></h4>
851
852
        <fieldset class="options">
853
        <table class="optiontable">
854
            <tr>
855
                <td scope="row" colspan="2">
856
                    <label for="smdb_specific_pages"><?php _e( 'Enter one post url (not post ids) per line', 'bulk-delete' ); ?></label>
857
                    <br>
858
                    <textarea style="width: 450px; height: 80px;" id="smdb_specific_pages_urls" name="smdb_specific_pages_urls" rows="5" columns="80"></textarea>
859
                </td>
860
            </tr>
861
862
			<?php bd_render_filtering_table_header(); ?>
863
			<?php bd_render_delete_settings( 'specific' ); ?>
864
865
        </table>
866
        </fieldset>
867
<?php
868
		bd_render_submit_button( 'delete_posts_by_url' );
869
	}
870
871
	/**
872
	 * Delete posts by url.
873
	 *
874
	 * @static
875
	 *
876
	 * @since 5.0
877
	 */
878
	public static function do_delete_posts_by_url() {
879
		$force_delete = bd_array_get_bool( $_POST, 'smbd_specific_force_delete', false );
880
881
		$urls = preg_split( '/\r\n|\r|\n/', bd_array_get( $_POST, 'smdb_specific_pages_urls' ) );
882
		foreach ( $urls as $url ) {
883
			$checkedurl = $url;
884
			if ( substr( $checkedurl , 0, 1 ) == '/' ) {
885
				$checkedurl = get_site_url() . $checkedurl ;
886
			}
887
			$postid = url_to_postid( $checkedurl );
888
			wp_delete_post( $postid, $force_delete );
889
		}
890
891
		$deleted_count = count( $urls );
892
		$msg           = sprintf( _n( 'Deleted %d post with the specified urls', 'Deleted %d posts with the specified urls' , $deleted_count, 'bulk-delete' ), $deleted_count );
893
894
		add_settings_error(
895
			Bulk_Delete::POSTS_PAGE_SLUG,
896
			'deleted-posts',
897
			$msg,
898
			'updated'
899
		);
900
	}
901
902
	/**
903
	 * Render delete by post revisions box.
904
	 *
905
	 * @static
906
	 */
907
	public static function render_posts_by_revision_box() {
908
		global $wpdb;
909
910
		if ( BD_Util::is_posts_box_hidden( Bulk_Delete::BOX_POST_REVISION ) ) {
911
			printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-delete' ), 'admin.php?page=' . Bulk_Delete::POSTS_PAGE_SLUG );
912
913
			return;
914
		}
915
916
		$revisions = $wpdb->get_var( "select count(*) from $wpdb->posts where post_type = 'revision'" );
917
?>
918
        <!-- Post Revisions start-->
919
        <h4><?php _e( 'Select the posts which you want to delete', 'bulk-delete' ); ?></h4>
920
921
        <fieldset class="options">
922
        <table class="optiontable">
923
            <tr>
924
                <td>
925
                    <input name="smbd_revisions" id ="smbd_revisions" value="revisions" type="checkbox">
926
                    <label for="smbd_revisions"><?php _e( 'All Revisions', 'bulk-delete' ); ?> (<?php echo $revisions . ' '; _e( 'Revisions', 'bulk-delete' ); ?>)</label>
927
                </td>
928
            </tr>
929
930
        </table>
931
        </fieldset>
932
<?php
933
		bd_render_submit_button( 'delete_posts_by_revision' );
934
	}
935
936
	/**
937
	 * Process delete revisions request.
938
	 *
939
	 * @static
940
	 *
941
	 * @since 5.0
942
	 */
943
	public static function do_delete_posts_by_revision() {
944
		$delete_options = array( 'revisions' => bd_array_get( $_POST, 'smbd_revisions' ) );
945
946
		$deleted_count = self::delete_posts_by_revision( $delete_options );
947
948
		$msg = sprintf( _n( 'Deleted %d post revision', 'Deleted %d post revisions' , $deleted_count, 'bulk-delete' ), $deleted_count );
949
950
		add_settings_error(
951
			Bulk_Delete::POSTS_PAGE_SLUG,
952
			'deleted-posts',
953
			$msg,
954
			'updated'
955
		);
956
	}
957
958
	/**
959
	 * Delete all post revisions.
960
	 *
961
	 * @since 5.0
962
	 * @static
963
	 *
964
	 * @param array $delete_options
965
	 *
966
	 * @return int The number of posts that were deleted
967
	 */
968
	public static function delete_posts_by_revision( $delete_options ) {
969
		global $wpdb;
970
971
		// Revisions
972
		if ( 'revisions' == $delete_options['revisions'] ) {
973
			$revisions = $wpdb->get_results( "select ID from $wpdb->posts where post_type = 'revision'" );
974
975
			foreach ( $revisions as $revision ) {
976
				wp_delete_post( $revision->ID );
977
			}
978
979
			return count( $revisions );
980
		}
981
982
		return 0;
983
	}
984
985
	/**
986
	 * Filter JS Array and add validation hooks.
987
	 *
988
	 * @since 5.4
989
	 * @static
990
	 *
991
	 * @param array $js_array JavaScript Array
992
	 *
993
	 * @return array Modified JavaScript Array
994
	 */
995
	public static function filter_js_array( $js_array ) {
996
		$js_array['msg']['deletePostsWarning'] = __( 'Are you sure you want to delete all the posts based on the selected option?', 'bulk-delete' );
997
		$js_array['msg']['selectPostOption']   = __( 'Please select posts from at least one option', 'bulk-delete' );
998
999
		$js_array['validators']['delete_posts_by_category'] = 'validateSelect2';
1000
		$js_array['error_msg']['delete_posts_by_category']  = 'selectCategory';
1001
		$js_array['msg']['selectCategory']                  = __( 'Please select at least one category', 'bulk-delete' );
1002
1003
		$js_array['validators']['delete_posts_by_tag']     = 'validateSelect2';
1004
		$js_array['error_msg']['delete_posts_by_category'] = 'selectTag';
1005
		$js_array['msg']['selectTag']                      = __( 'Please select at least one tag', 'bulk-delete' );
1006
1007
		$js_array['validators']['delete_posts_by_url'] = 'validateUrl';
1008
		$js_array['error_msg']['delete_posts_by_url']  = 'enterUrl';
1009
		$js_array['msg']['enterUrl']                   = __( 'Please enter at least one post url', 'bulk-delete' );
1010
1011
		$js_array['dt_iterators'][] = '_cats';
1012
		$js_array['dt_iterators'][] = '_tags';
1013
		$js_array['dt_iterators'][] = '_taxs';
1014
		$js_array['dt_iterators'][] = '_types';
1015
		$js_array['dt_iterators'][] = '_post_status';
1016
1017
		return $js_array;
1018
	}
1019
1020
	/**
1021
	 * Process delete cron job request.
1022
	 * This should ideally go in a separate class. But I was
1023
	 * lazy to create a separate class for a single function.
1024
	 *
1025
	 * @since 5.0
1026
	 * @static
1027
	 */
1028
	public static function do_delete_cron() {
1029
		$cron_id    = absint( $_GET['cron_id'] );
1030
		$cron_items = BD_Util::get_cron_schedules();
1031
		wp_unschedule_event( $cron_items[$cron_id]['timestamp'], $cron_items[$cron_id]['type'], $cron_items[$cron_id]['args'] );
1032
1033
		$msg = __( 'The selected scheduled job was successfully deleted ', 'bulk-delete' );
1034
1035
		add_settings_error(
1036
			Bulk_Delete::CRON_PAGE_SLUG,
1037
			'deleted-cron',
1038
			$msg,
1039
			'updated'
1040
		);
1041
	}
1042
}
1043
1044
// hooks
1045 1
add_action( 'bd_delete_posts_by_status'    , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_status' ) );
1046 1
add_action( 'bd_delete_posts_by_category'  , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_category' ) );
1047 1
add_action( 'bd_delete_posts_by_tag'       , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_tag' ) );
1048 1
add_action( 'bd_delete_posts_by_taxonomy'  , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_taxonomy' ) );
1049 1
add_action( 'bd_delete_posts_by_post_type' , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_post_type' ) );
1050 1
add_action( 'bd_delete_posts_by_url'       , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_url' ) );
1051 1
add_action( 'bd_delete_posts_by_revision'  , array( 'Bulk_Delete_Posts', 'do_delete_posts_by_revision' ) );
1052
1053 1
add_action( 'bd_delete_cron'               , array( 'Bulk_Delete_Posts', 'do_delete_cron' ) );
1054 1
add_filter( 'bd_javascript_array'          , array( 'Bulk_Delete_Posts', 'filter_js_array' ) );
1055
?>
1056