PluginProbe
Bulk Delete / trunk
Bulk Delete vtrunk
6.12 trunk 0.2 0.3 0.4 0.6 0.7 0.8 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.2.1 2.2.2 3.0 3.1 All 64 releases
bulk-delete / include / Core / Posts / Modules / DeletePostsByStatusModule.php

DeletePostsByStatusModule.php in Bulk Delete trunk, at include/Core/Posts/Modules/DeletePostsByStatusModule.php

81 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BulkWP\BulkDelete\Core\Posts\Modules;
4
5 use BulkWP\BulkDelete\Core\Posts\PostsModule;
6
7 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
8
9 /**
10 * Delete Posts by Status Module.
11 *
12 * @since 6.0.0
13 */
14 class DeletePostsByStatusModule extends PostsModule {
15 protected function initialize() {
16 $this->item_type = 'posts';
17 $this->field_slug = 'post_status';
18 $this->meta_box_slug = 'bd_posts_by_status';
19 $this->action = 'delete_posts_by_status';
20 $this->cron_hook = 'do-bulk-delete-post-status';
21 $this->scheduler_url = 1;
22 $this->messages = array(
23 'box_label' => __( 'By Post Status', 'bulk-delete' ),
24 'scheduled' => __( 'The selected posts are scheduled for deletion', 'bulk-delete' ),
25 'cron_label' => __( 'Delete Post By Status', 'bulk-delete' ),
26 'validation_error' => __( 'Please select at least one post status from which posts should be deleted', 'bulk-delete' ),
27 'confirm_deletion' => __( 'Are you sure you want to delete all the posts from the selected post status?', 'bulk-delete' ),
28 'confirm_scheduled' => __( 'Are you sure you want to schedule deletion of all the posts from the selected post status?', 'bulk-delete' ),
29 /* translators: 1 Number of posts deleted */
30 'deleted_one' => __( 'Deleted %d post from the selected post status', 'bulk-delete' ),
31 /* translators: 1 Number of posts deleted */
32 'deleted_multiple' => __( 'Deleted %d posts from the selected post status', 'bulk-delete' ),
33 );
34 }
35
36 public function render() {
37 ?>
38 <h4><?php esc_html_e( 'Select the post statuses from which you want to delete posts', 'bulk-delete' ); ?></h4>
39
40 <fieldset class="options">
41
42 <table class="optiontable">
43 <?php $this->render_post_status(); ?>
44 </table>
45
46 <table class="optiontable">
47 <?php
48 $this->render_filtering_table_header();
49 $this->render_restrict_settings();
50 $this->render_exclude_sticky_settings();
51 $this->render_delete_settings();
52 $this->render_limit_settings();
53 $this->render_cron_settings();
54 ?>
55 </table>
56
57 </fieldset>
58
59 <?php
60 $this->render_submit_button();
61 }
62
63 protected function convert_user_input_to_options( $request, $options ) {
64 $options['post_status'] = array_map( 'sanitize_text_field', bd_array_get( $request, 'smbd_' . $this->field_slug, array() ) );
65
66 return $options;
67 }
68
69 protected function build_query( $options ) {
70 if ( empty( $options['post_status'] ) ) {
71 return array();
72 }
73
74 $query = array(
75 'post_status' => $options['post_status'],
76 );
77
78 return $query;
79 }
80 }
81