|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Pages\Modules; |
|
4
|
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Pages\PagesModule; |
|
6
|
|
|
|
|
7
|
1 |
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Delete Pages by Status Module. |
|
11
|
|
|
* |
|
12
|
|
|
* @since 6.0.0 |
|
13
|
|
|
*/ |
|
14
|
|
|
class DeletePagesByStatusModule extends PagesModule { |
|
15
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
16
|
21 |
|
protected function initialize() { |
|
17
|
21 |
|
$this->item_type = 'pages'; |
|
18
|
21 |
|
$this->field_slug = 'page_status'; |
|
19
|
21 |
|
$this->meta_box_slug = 'bd_pages_by_status'; |
|
20
|
21 |
|
$this->action = 'delete_pages_by_status'; |
|
21
|
21 |
|
$this->cron_hook = 'do-bulk-delete-pages-by-status'; |
|
22
|
21 |
|
$this->scheduler_url = 'https://bulkwp.com/addons/scheduler-for-deleting-pages-by-status/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-sp'; |
|
23
|
21 |
|
$this->messages = array( |
|
24
|
21 |
|
'box_label' => __( 'By Page Status', 'bulk-delete' ), |
|
25
|
21 |
|
'scheduled' => __( 'The selected pages are scheduled for deletion', 'bulk-delete' ), |
|
26
|
21 |
|
'cron_label' => __( 'Delete Pages By status', 'bulk-delete' ), |
|
27
|
21 |
|
'confirm_deletion' => __( 'Are you sure you want to delete all the pages from the selected post status?', 'bulk-delete' ), |
|
28
|
21 |
|
'confirm_scheduled' => __( 'Are you sure you want to schedule deletion for all the pages from the selected post status?', 'bulk-delete' ), |
|
29
|
21 |
|
'validation_error' => __( 'Please select at least one post status from which pages should be deleted', 'bulk-delete' ), |
|
30
|
|
|
/* translators: 1 Number of pages deleted */ |
|
31
|
21 |
|
'deleted_one' => __( 'Deleted %d page from the selected post status', 'bulk-delete' ), |
|
32
|
|
|
/* translators: 1 Number of pages deleted */ |
|
33
|
21 |
|
'deleted_multiple' => __( 'Deleted %d pages from the selected post status', 'bulk-delete' ), |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
38
|
|
|
public function render() { |
|
39
|
|
|
?> |
|
40
|
|
|
<!-- Pages start--> |
|
41
|
|
|
<h4><?php _e( 'Select the post statuses from which you want to delete pages', 'bulk-delete' ); ?></h4> |
|
42
|
|
|
|
|
43
|
|
|
<fieldset class="options"> |
|
44
|
|
|
<table class="optiontable"> |
|
45
|
|
|
<?php $this->render_post_status( 'page' ); ?> |
|
46
|
|
|
</table> |
|
47
|
|
|
|
|
48
|
|
|
<table class="optiontable"> |
|
49
|
|
|
<?php |
|
50
|
|
|
$this->render_filtering_table_header(); |
|
51
|
|
|
$this->render_restrict_settings(); |
|
52
|
|
|
$this->render_delete_settings(); |
|
53
|
|
|
$this->render_limit_settings(); |
|
54
|
|
|
$this->render_cron_settings(); |
|
55
|
|
|
?> |
|
56
|
|
|
</table> |
|
57
|
|
|
</fieldset> |
|
58
|
|
|
|
|
59
|
|
|
<?php |
|
60
|
|
|
$this->render_submit_button(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
64
|
|
|
protected function append_to_js_array( $js_array ) { |
|
65
|
|
|
$js_array['validators'][ $this->action ] = 'validateCheckbox'; |
|
66
|
|
|
|
|
67
|
|
|
return $js_array; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
71
|
|
|
protected function convert_user_input_to_options( $request, $options ) { |
|
72
|
|
|
$options['post_status'] = array_map( 'sanitize_text_field', bd_array_get( $request, 'smbd_page_status', array() ) ); |
|
73
|
|
|
|
|
74
|
|
|
return $options; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
78
|
21 |
|
protected function build_query( $options ) { |
|
79
|
21 |
|
if ( empty( $options['post_status'] ) ) { |
|
80
|
|
|
return array(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
$query = array( |
|
84
|
21 |
|
'post_type' => 'page', |
|
85
|
21 |
|
'post_status' => $options['post_status'], |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
21 |
|
return $query; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
92
|
|
|
protected function get_non_standard_input_key_map() { |
|
93
|
|
|
$prefix = $this->get_ui_input_prefix(); |
|
94
|
|
|
|
|
95
|
|
|
$prefix_without_underscore_at_end = substr( $prefix, 0, -1 ); |
|
96
|
|
|
|
|
97
|
|
|
return array( |
|
98
|
|
|
$prefix_without_underscore_at_end => $prefix . 'status', |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
|
103
|
|
|
protected function prepare_cli_input( $input ) { |
|
104
|
|
|
// Handle multiple post statuses. |
|
105
|
|
|
$input['status'] = explode( ',', $input['status'] ); |
|
106
|
|
|
|
|
107
|
|
|
return parent::prepare_cli_input( $input ); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|