|
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
|
6 |
|
protected function initialize() { |
|
16
|
6 |
|
$this->item_type = 'pages'; |
|
17
|
6 |
|
$this->field_slug = 'pages'; |
|
18
|
6 |
|
$this->meta_box_slug = 'bd_pages_by_status'; |
|
19
|
6 |
|
$this->action = 'delete_pages_by_status'; |
|
20
|
6 |
|
$this->cron_hook = 'do-bulk-delete-pages-by-status'; |
|
21
|
6 |
|
$this->scheduler_url = 'http://bulkwp.com/addons/scheduler-for-deleting-pages-by-status/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-sp'; |
|
22
|
6 |
|
$this->messages = array( |
|
23
|
6 |
|
'box_label' => __( 'By Page Status', 'bulk-delete' ), |
|
24
|
6 |
|
'scheduled' => __( 'The selected pages are scheduled for deletion', 'bulk-delete' ), |
|
25
|
|
|
); |
|
26
|
6 |
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function render() { |
|
29
|
|
|
$pages_count = wp_count_posts( 'page' ); |
|
30
|
|
|
$pages = $pages_count->publish; |
|
31
|
|
|
$page_drafts = $pages_count->draft; |
|
32
|
|
|
$page_future = $pages_count->future; |
|
33
|
|
|
$page_pending = $pages_count->pending; |
|
34
|
|
|
$page_private = $pages_count->private; |
|
35
|
|
|
?> |
|
36
|
|
|
<!-- Pages start--> |
|
37
|
|
|
<h4><?php _e( 'Select the status from which you want to delete pages', 'bulk-delete' ); ?></h4> |
|
38
|
|
|
|
|
39
|
|
|
<fieldset class="options"> |
|
40
|
|
|
<table class="optiontable"> |
|
41
|
|
|
<tr> |
|
42
|
|
|
<td> |
|
43
|
|
|
<input name="smbd_published_pages" value="published_pages" type="checkbox"> |
|
44
|
|
|
<label for="smbd_published_pages"><?php _e( 'All Published Pages', 'bulk-delete' ); ?> (<?php echo $pages . ' '; _e( 'Pages', 'bulk-delete' ); ?>)</label> |
|
45
|
|
|
</td> |
|
46
|
|
|
</tr> |
|
47
|
|
|
|
|
48
|
|
|
<tr> |
|
49
|
|
|
<td> |
|
50
|
|
|
<input name="smbd_draft_pages" value="draft_pages" type="checkbox"> |
|
51
|
|
|
<label for="smbd_draft_pages"><?php _e( 'All Draft Pages', 'bulk-delete' ); ?> (<?php echo $page_drafts . ' '; _e( 'Pages', 'bulk-delete' ); ?>)</label> |
|
52
|
|
|
</td> |
|
53
|
|
|
</tr> |
|
54
|
|
|
|
|
55
|
|
|
<tr> |
|
56
|
|
|
<td> |
|
57
|
|
|
<input name="smbd_future_pages" value="scheduled_pages" type="checkbox"> |
|
58
|
|
|
<label for="smbd_future_pages"><?php _e( 'All Scheduled Pages', 'bulk-delete' ); ?> (<?php echo $page_future . ' '; _e( 'Pages', 'bulk-delete' ); ?>)</label> |
|
59
|
|
|
</td> |
|
60
|
|
|
</tr> |
|
61
|
|
|
|
|
62
|
|
|
<tr> |
|
63
|
|
|
<td> |
|
64
|
|
|
<input name="smbd_pending_pages" value="pending_pages" type="checkbox"> |
|
65
|
|
|
<label for="smbd_pending_pages"><?php _e( 'All Pending Pages', 'bulk-delete' ); ?> (<?php echo $page_pending . ' '; _e( 'Pages', 'bulk-delete' ); ?>)</label> |
|
66
|
|
|
</td> |
|
67
|
|
|
</tr> |
|
68
|
|
|
|
|
69
|
|
|
<tr> |
|
70
|
|
|
<td> |
|
71
|
|
|
<input name="smbd_private_pages" value="private_pages" type="checkbox"> |
|
72
|
|
|
<label for="smbd_private_pages"><?php _e( 'All Private Pages', 'bulk-delete' ); ?> (<?php echo $page_private . ' '; _e( 'Pages', 'bulk-delete' ); ?>)</label> |
|
73
|
|
|
</td> |
|
74
|
|
|
</tr> |
|
75
|
|
|
</table> |
|
76
|
|
|
|
|
77
|
|
|
<table class="optiontable"> |
|
78
|
|
|
<?php |
|
79
|
|
|
$this->render_filtering_table_header(); |
|
80
|
|
|
$this->render_restrict_settings(); |
|
81
|
|
|
$this->render_delete_settings(); |
|
82
|
|
|
$this->render_limit_settings(); |
|
83
|
|
|
$this->render_cron_settings(); |
|
84
|
|
|
?> |
|
85
|
|
|
</table> |
|
86
|
|
|
</fieldset> |
|
87
|
|
|
<?php |
|
88
|
|
|
$this->render_submit_button(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
protected function convert_user_input_to_options( $request, $options ) { |
|
92
|
|
|
$options['publish'] = bd_array_get( $request, 'smbd_published_pages' ); |
|
93
|
|
|
$options['drafts'] = bd_array_get( $request, 'smbd_draft_pages' ); |
|
94
|
|
|
$options['pending'] = bd_array_get( $request, 'smbd_pending_pages' ); |
|
95
|
|
|
$options['future'] = bd_array_get( $request, 'smbd_future_pages' ); |
|
96
|
|
|
$options['private'] = bd_array_get( $request, 'smbd_private_pages' ); |
|
97
|
|
|
|
|
98
|
|
|
return $options; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
6 |
|
protected function build_query( $options ) { |
|
102
|
6 |
|
$post_status = array(); |
|
103
|
|
|
|
|
104
|
|
|
// published pages |
|
105
|
6 |
|
if ( 'published_pages' == $options['publish'] ) { |
|
106
|
5 |
|
$post_status[] = 'publish'; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
// Drafts |
|
110
|
6 |
|
if ( 'draft_pages' == $options['drafts'] ) { |
|
111
|
5 |
|
$post_status[] = 'draft'; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
// Pending pages |
|
115
|
6 |
|
if ( 'pending_pages' == $options['pending'] ) { |
|
116
|
|
|
$post_status[] = 'pending'; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
// Future pages |
|
120
|
6 |
|
if ( 'future_pages' == $options['future'] ) { |
|
121
|
|
|
$post_status[] = 'future'; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
// Private pages |
|
125
|
6 |
|
if ( 'private_pages' == $options['private'] ) { |
|
126
|
1 |
|
$post_status[] = 'private'; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
$query = array( |
|
130
|
6 |
|
'post_type' => 'page', |
|
131
|
6 |
|
'post_status' => $post_status, |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
6 |
|
return $query; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
protected function get_success_message( $items_deleted ) { |
|
138
|
|
|
/* translators: 1 Number of pages deleted */ |
|
139
|
|
|
return _n( 'Deleted %d page with the selected page status', 'Deleted %d pages with the selected page status', $items_deleted, 'bulk-delete' ); |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|