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
|
21 |
|
protected function initialize() { |
16
|
21 |
|
$this->item_type = 'pages'; |
17
|
21 |
|
$this->field_slug = 'page_status'; |
18
|
21 |
|
$this->meta_box_slug = 'bd_pages_by_status'; |
19
|
21 |
|
$this->action = 'delete_pages_by_status'; |
20
|
21 |
|
$this->cron_hook = 'do-bulk-delete-pages-by-status'; |
21
|
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'; |
22
|
21 |
|
$this->messages = array( |
23
|
21 |
|
'box_label' => __( 'By Page Status', 'bulk-delete' ), |
24
|
21 |
|
'scheduled' => __( 'The selected pages are scheduled for deletion', 'bulk-delete' ), |
25
|
21 |
|
'cron_label' => __( 'Delete Pages By status', 'bulk-delete' ), |
26
|
21 |
|
'confirm_deletion' => __( 'Are you sure you want to delete all the pages from the selected post status?', 'bulk-delete' ), |
27
|
21 |
|
'confirm_scheduled' => __( 'Are you sure you want to schedule deletion for all the pages from the selected post status?', 'bulk-delete' ), |
28
|
21 |
|
'validation_error' => __( 'Please select at least one post status from which pages should be deleted', 'bulk-delete' ), |
29
|
|
|
/* translators: 1 Number of pages deleted */ |
30
|
21 |
|
'deleted_one' => __( 'Deleted %d page from the selected post status', 'bulk-delete' ), |
31
|
|
|
/* translators: 1 Number of pages deleted */ |
32
|
21 |
|
'deleted_multiple' => __( 'Deleted %d pages from the selected post status', 'bulk-delete' ), |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function render() { |
37
|
|
|
?> |
38
|
|
|
<!-- Pages start--> |
39
|
|
|
<h4><?php _e( 'Select the post statuses from which you want to delete pages', 'bulk-delete' ); ?></h4> |
40
|
|
|
|
41
|
|
|
<fieldset class="options"> |
42
|
|
|
<table class="optiontable"> |
43
|
|
|
<?php $this->render_post_status( 'page' ); ?> |
44
|
|
|
</table> |
45
|
|
|
|
46
|
|
|
<table class="optiontable"> |
47
|
|
|
<?php |
48
|
|
|
$this->render_filtering_table_header(); |
49
|
|
|
$this->render_restrict_settings(); |
50
|
|
|
$this->render_delete_settings(); |
51
|
|
|
$this->render_limit_settings(); |
52
|
|
|
$this->render_cron_settings(); |
53
|
|
|
?> |
54
|
|
|
</table> |
55
|
|
|
</fieldset> |
56
|
|
|
|
57
|
|
|
<?php |
58
|
|
|
$this->render_submit_button(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
62
|
|
|
protected function append_to_js_array( $js_array ) { |
63
|
|
|
$js_array['validators'][ $this->action ] = 'validateCheckbox'; |
64
|
|
|
|
65
|
|
|
return $js_array; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected function convert_user_input_to_options( $request, $options ) { |
69
|
|
|
$options['post_status'] = array_map( 'sanitize_text_field', bd_array_get( $request, 'smbd_page_status', array() ) ); |
70
|
|
|
|
71
|
|
|
return $options; |
72
|
|
|
} |
73
|
|
|
|
74
|
21 |
|
protected function build_query( $options ) { |
75
|
21 |
|
if ( empty( $options['post_status'] ) ) { |
76
|
|
|
return array(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
$query = array( |
80
|
21 |
|
'post_type' => 'page', |
81
|
21 |
|
'post_status' => $options['post_status'], |
82
|
|
|
); |
83
|
|
|
|
84
|
21 |
|
return $query; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|