1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\Base\Mixin; |
4
|
|
|
|
5
|
1 |
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Container of all Render methods. |
9
|
|
|
* |
10
|
|
|
* Ideally this should be a Trait. Since Bulk Delete still supports PHP 5.3, this is implemented as a class. |
11
|
|
|
* Once the minimum requirement is increased to PHP 5.3, this will be changed into a Trait. |
12
|
|
|
* |
13
|
|
|
* @since 6.0.0 |
14
|
|
|
*/ |
15
|
|
|
abstract class Renderer extends Fetcher { |
16
|
|
|
/** |
17
|
|
|
* Slug for the form fields. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $field_slug; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Render post status including custom post status. |
25
|
|
|
* |
26
|
|
|
* @param string $post_type The post type for which the post status should be displayed. |
27
|
|
|
*/ |
28
|
|
|
protected function render_post_status( $post_type = 'post' ) { |
29
|
|
|
$post_statuses = $this->get_post_statuses(); |
30
|
|
|
$post_count = wp_count_posts( $post_type ); |
31
|
|
|
|
32
|
|
|
foreach ( $post_statuses as $post_status ) : ?> |
33
|
|
|
<tr> |
34
|
|
|
<td> |
35
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" id="smbd_<?php echo esc_attr( $post_status->name ); ?>" |
36
|
|
|
value="<?php echo esc_attr( $post_status->name ); ?>" type="checkbox"> |
37
|
|
|
|
38
|
|
|
<label for="smbd_<?php echo esc_attr( $post_status->name ); ?>"> |
39
|
|
|
<?php echo esc_html( $post_status->label ), ' '; ?> |
40
|
|
|
<?php if ( property_exists( $post_count, $post_status->name ) ) : ?> |
41
|
|
|
(<?php echo absint( $post_count->{ $post_status->name } ) . ' ', __( 'Posts', 'bulk-delete' ); ?>) |
42
|
|
|
<?php endif; ?> |
43
|
|
|
</label> |
44
|
|
|
</td> |
45
|
|
|
</tr> |
46
|
|
|
<?php endforeach; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Render Post Types as radio buttons. |
51
|
|
|
*/ |
52
|
|
|
protected function render_post_type_as_radios() { |
53
|
|
|
$post_types = $this->get_post_types(); |
54
|
|
|
?> |
55
|
|
|
|
56
|
|
|
<?php foreach ( $post_types as $post_type ) : ?> |
57
|
|
|
|
58
|
|
|
<tr> |
59
|
|
|
<td scope="row"> |
60
|
|
|
<input type="radio" name="<?php echo esc_attr( $this->field_slug ); ?>_post_type" |
61
|
|
|
value="<?php echo esc_attr( $post_type->name ); ?>" |
62
|
|
|
id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>"> |
63
|
|
|
|
64
|
|
|
<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>"> |
65
|
|
|
<?php echo esc_html( $post_type->label ); ?> |
66
|
|
|
</label> |
67
|
|
|
</td> |
68
|
|
|
</tr> |
69
|
|
|
|
70
|
|
|
<?php endforeach; ?> |
71
|
|
|
<?php |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Render Post type with status and post count checkboxes. |
76
|
|
|
* |
77
|
|
|
* @since 6.0.1 Added $multiple param. |
78
|
|
|
* |
79
|
|
|
* @param bool $multiple_select Whether multiple select should be supported. Default true. |
80
|
|
|
*/ |
81
|
|
|
protected function render_post_type_with_status( $multiple_select = true ) { |
82
|
|
|
$post_types_by_status = $this->get_post_types_by_status(); |
83
|
|
|
|
84
|
|
|
$name = 'smbd_' . $this->field_slug; |
85
|
|
|
if ( $multiple_select ) { |
86
|
|
|
$name .= '[]'; |
87
|
|
|
} |
88
|
|
|
?> |
89
|
|
|
|
90
|
|
|
<tr> |
91
|
|
|
<td scope="row" colspan="2"> |
92
|
|
|
<select data-placeholder="<?php esc_attr_e( 'Select Post Type', 'bulk-delete' ); ?>" |
93
|
|
|
name="<?php echo esc_attr( $name ); ?> "class="enhanced-post-types-with-status" |
94
|
|
|
<?php if ( $multiple_select ) : ?> |
95
|
|
|
multiple |
96
|
|
|
<?php endif; ?> |
97
|
|
|
> |
98
|
|
|
|
99
|
|
|
<?php foreach ( $post_types_by_status as $post_type => $all_status ) : ?> |
100
|
|
|
<optgroup label="<?php echo esc_html( $post_type ); ?>"> |
101
|
|
|
|
102
|
|
|
<?php foreach ( $all_status as $status_key => $status_value ) : ?> |
103
|
9 |
|
<option value="<?php echo esc_attr( $status_key ); ?>"> |
104
|
9 |
|
<?php echo esc_html( $status_value ); ?> |
105
|
|
|
</option> |
106
|
9 |
|
<?php endforeach; ?> |
107
|
|
|
|
108
|
9 |
|
</optgroup> |
109
|
|
|
<?php endforeach; ?> |
110
|
|
|
|
111
|
|
|
</select> |
112
|
9 |
|
</td> |
113
|
9 |
|
</tr> |
114
|
|
|
<?php |
115
|
|
|
} |
116
|
9 |
|
|
117
|
|
|
/** |
118
|
|
|
* Split post type and status. |
119
|
|
|
* |
120
|
|
|
* @param string $str Post type and status combination. |
121
|
|
|
* |
122
|
|
|
* @return array Post type and status as elements of array. |
123
|
|
|
*/ |
124
|
|
|
protected function split_post_type_and_status( $str ) { |
125
|
|
|
$type_status = array(); |
126
|
|
|
|
127
|
|
|
$str_arr = explode( '-', $str ); |
128
|
|
|
|
129
|
|
|
if ( count( $str_arr ) > 1 ) { |
130
|
|
|
$type_status['status'] = end( $str_arr ); |
131
|
|
|
$type_status['type'] = implode( '-', array_slice( $str_arr, 0, - 1 ) ); |
132
|
|
|
} else { |
133
|
|
|
$type_status['status'] = 'publish'; |
134
|
|
|
$type_status['type'] = $str; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
return $type_status; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Render post reassign settings. |
142
|
|
|
*/ |
143
|
|
|
protected function render_post_reassign_settings() { |
144
|
|
|
?> |
145
|
|
|
<tr> |
146
|
|
|
<td scope="row" colspan="2"> |
147
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="false" type="radio" |
148
|
|
|
checked="checked" class="post-reassign"> <?php _e( 'Also delete all posts of the users', 'bulk-delete' ); ?></label> |
149
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="true" type="radio" |
150
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" class="post-reassign"> <?php _e( 'Re-assign the posts to', 'bulk-delete' ); ?></label> |
151
|
|
|
<?php |
152
|
|
|
wp_dropdown_users( |
153
|
|
|
array( |
154
|
|
|
'name' => 'smbd_' . esc_attr( $this->field_slug ) . '_reassign_user_id', |
155
|
|
|
'class' => 'reassign-user', |
156
|
|
|
'show_option_none' => __( 'Select User', 'bulk-delete' ), |
157
|
|
|
) |
158
|
|
|
); |
159
|
|
|
?> |
160
|
|
|
</td> |
161
|
|
|
</tr> |
162
|
|
|
<?php |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Render user role dropdown. |
167
|
|
|
* |
168
|
|
|
* @param bool $show_users_with_no_roles Should users with no user roles be shown? Default false. |
169
|
|
|
*/ |
170
|
|
|
protected function render_user_role_dropdown( $show_users_with_no_roles = false ) { |
171
|
|
|
$roles = get_editable_roles(); |
172
|
|
|
$users_count = count_users(); |
173
|
|
|
?> |
174
|
|
|
|
175
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown" |
176
|
|
|
multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>"> |
177
|
|
|
|
178
|
|
|
<?php foreach ( $roles as $role => $role_details ) : ?> |
179
|
|
|
<option value="<?php echo esc_attr( $role ); ?>"> |
180
|
|
|
<?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role, $users_count ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?> |
181
|
|
|
</option> |
182
|
|
|
<?php endforeach; ?> |
183
|
|
|
|
184
|
|
|
<?php if ( $show_users_with_no_roles ) : ?> |
185
|
|
|
<?php if ( isset( $users_count['avail_roles']['none'] ) && $users_count['avail_roles']['none'] > 0 ) : ?> |
186
|
|
|
<option value="none"> |
187
|
|
|
<?php echo __( 'No role', 'bulk-delete' ), ' (', absint( $users_count['avail_roles']['none'] ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?> |
188
|
|
|
</option> |
189
|
|
|
<?php endif; ?> |
190
|
|
|
<?php endif; ?> |
191
|
|
|
</select> |
192
|
|
|
|
193
|
|
|
<?php |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* Render Post type dropdown. |
198
|
|
|
*/ |
199
|
|
|
protected function render_post_type_dropdown() { |
200
|
|
|
bd_render_post_type_dropdown( $this->field_slug ); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Render Taxonomy dropdown. |
205
|
|
|
*/ |
206
|
|
|
protected function render_taxonomy_dropdown() { |
207
|
|
|
$taxonomies = get_taxonomies( array(), 'objects' ); |
208
|
|
|
?> |
209
|
|
|
|
210
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy" class="enhanced-taxonomy-list" data-placeholder="<?php _e( 'Select Taxonomy', 'bulk-delete' ); ?>"> |
211
|
|
|
<?php foreach ( $taxonomies as $taxonomy ) : ?> |
212
|
|
|
<option value="<?php echo esc_attr( $taxonomy->name ); ?>"> |
213
|
|
|
<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?> |
214
|
|
|
</option> |
215
|
|
|
<?php endforeach; ?> |
216
|
|
|
</select> |
217
|
|
|
<?php |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Render Category dropdown. |
222
|
|
|
*/ |
223
|
|
|
protected function render_category_dropdown() { |
224
|
|
|
$categories = $this->get_categories(); |
225
|
|
|
?> |
226
|
|
|
|
227
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>" |
228
|
|
|
class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>" |
229
|
|
|
data-taxonomy="category" multiple> |
230
|
|
|
|
231
|
|
|
<option value="all"> |
232
|
|
|
<?php _e( 'All Categories', 'bulk-delete' ); ?> |
233
|
|
|
</option> |
234
|
|
|
|
235
|
|
|
<?php foreach ( $categories as $category ) : ?> |
236
|
|
|
<option value="<?php echo absint( $category->cat_ID ); ?>"> |
237
|
|
|
<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
238
|
|
|
</option> |
239
|
|
|
<?php endforeach; ?> |
240
|
|
|
|
241
|
|
|
</select> |
242
|
|
|
<?php |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Render String based comparison operators dropdown. |
247
|
|
|
*/ |
248
|
|
|
protected function render_string_comparison_operators() { |
249
|
|
|
?> |
250
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
251
|
|
|
<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
252
|
|
|
<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
253
|
|
|
<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option> |
254
|
|
|
<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option> |
255
|
|
|
<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option> |
256
|
|
|
<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option> |
257
|
|
|
</select> |
258
|
|
|
<?php |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
/** |
262
|
|
|
* Render number based comparison operators dropdown. |
263
|
|
|
*/ |
264
|
|
|
protected function render_number_comparison_operators() { |
265
|
|
|
?> |
266
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
267
|
|
|
<option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
268
|
|
|
<option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
269
|
|
|
<option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option> |
270
|
|
|
<option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option> |
271
|
|
|
</select> |
272
|
|
|
<?php |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Render data types dropdown. |
277
|
|
|
*/ |
278
|
|
|
protected function render_data_types_dropdown() { |
279
|
|
|
?> |
280
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type"> |
281
|
|
|
<option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option> |
282
|
|
|
<option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option> |
283
|
|
|
<option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option> |
284
|
|
|
</select> |
285
|
|
|
<?php |
286
|
|
|
} |
287
|
|
|
/** |
288
|
|
|
* Render numeric comparison operators dropdown. |
289
|
|
|
* |
290
|
|
|
* @param string $class Class to be applied. |
291
|
|
|
* @param array $operators List of Operators needed. |
292
|
|
|
*/ |
293
|
|
|
protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) { |
294
|
|
|
$all_numeric_operators = array( |
295
|
|
|
'=' => 'equal to', |
296
|
|
|
'!=' => 'not equal to', |
297
|
|
|
'<' => 'less than', |
298
|
|
|
'<=' => 'less than or equal to', |
299
|
|
|
'>' => 'greater than', |
300
|
|
|
'>=' => 'greater than or equal to', |
301
|
|
|
'IN' => 'in', |
302
|
|
|
'NOT IN' => 'not in', |
303
|
|
|
'BETWEEN' => 'between', |
304
|
|
|
'NOT BETWEEN' => 'not between', |
305
|
|
|
'EXISTS' => 'exists', |
306
|
|
|
'NOT EXISTS' => 'not exists', |
307
|
|
|
); |
308
|
|
|
if ( in_array( 'all', $operators, true ) ) { |
309
|
|
|
$operators = array_keys( $all_numeric_operators ); |
310
|
|
|
} |
311
|
|
|
?> |
312
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>"> |
313
|
|
|
<?php |
314
|
|
|
foreach ( $operators as $operator ) { |
315
|
|
|
echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>'; |
316
|
|
|
} |
317
|
|
|
?> |
318
|
|
|
</select> |
319
|
|
|
<?php |
320
|
|
|
} |
321
|
|
|
/** |
322
|
|
|
* Render string comparison operators dropdown. |
323
|
|
|
* |
324
|
|
|
* @param string $class Class to be applied. |
325
|
|
|
* @param array $operators List of Operators needed. |
326
|
|
|
*/ |
327
|
|
|
protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) { |
328
|
|
|
// STARTS_WITH and ENDS_WITH operators needs a handler as SQL does not support these operators in queries. |
329
|
|
|
$all_string_operators = array( |
330
|
|
|
'=' => 'equal to', |
331
|
|
|
'!=' => 'not equal to', |
332
|
|
|
'IN' => 'in', |
333
|
|
|
'NOT IN' => 'not in', |
334
|
|
|
'LIKE' => 'contains', |
335
|
|
|
'NOT LIKE' => 'not contains', |
336
|
|
|
'EXISTS' => 'exists', |
337
|
|
|
'NOT EXISTS' => 'not exists', |
338
|
|
|
'STARTS_WITH' => 'starts with', |
339
|
|
|
'ENDS_WITH' => 'ends with', |
340
|
|
|
); |
341
|
|
|
if ( in_array( 'all', $operators, true ) ) { |
342
|
|
|
$operators = array_keys( $all_string_operators ); |
343
|
|
|
} |
344
|
|
|
?> |
345
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>"> |
346
|
|
|
<?php |
347
|
|
|
foreach ( $operators as $operator ) { |
348
|
|
|
echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>'; |
349
|
|
|
} |
350
|
|
|
?> |
351
|
|
|
</select> |
352
|
|
|
<?php |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* Render Tags dropdown. |
357
|
|
|
*/ |
358
|
|
|
protected function render_tags_dropdown() { |
359
|
|
|
$tags = $this->get_tags(); |
360
|
|
|
?> |
361
|
|
|
|
362
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>" |
363
|
|
|
class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>" |
364
|
|
|
data-taxonomy="post_tag" multiple> |
365
|
|
|
|
366
|
|
|
<option value="all"> |
367
|
|
|
<?php _e( 'All Tags', 'bulk-delete' ); ?> |
368
|
|
|
</option> |
369
|
|
|
|
370
|
|
|
<?php foreach ( $tags as $tag ) : ?> |
371
|
|
|
<option value="<?php echo absint( $tag->term_id ); ?>"> |
372
|
|
|
<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
373
|
|
|
</option> |
374
|
|
|
<?php endforeach; ?> |
375
|
|
|
</select> |
376
|
|
|
<?php |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Get the class name for select2 dropdown based on the number of items present. |
381
|
|
|
* |
382
|
|
|
* @param int $count The number of items present. |
383
|
|
|
* @param string $class_name Primary class name. |
384
|
|
|
* |
385
|
|
|
* @return string Class name. |
386
|
|
|
*/ |
387
|
|
|
protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) { |
388
|
|
|
if ( $count >= $this->get_enhanced_select_threshold() ) { |
389
|
|
|
$class_name .= '-ajax'; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
return $class_name; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Render Sticky Posts dropdown. |
397
|
|
|
*/ |
398
|
|
|
protected function render_sticky_posts_dropdown() { |
399
|
|
|
$sticky_posts = $this->get_sticky_posts(); |
400
|
|
|
?> |
401
|
|
|
|
402
|
|
|
<table class="optiontable"> |
403
|
|
|
<?php if ( count( $sticky_posts ) > 1 ) : ?> |
404
|
|
|
<tr> |
405
|
|
|
<td scope="row"> |
406
|
|
|
<label> |
407
|
|
|
<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all"> |
408
|
|
|
<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
409
|
|
|
</label> |
410
|
|
|
</td> |
411
|
|
|
</tr> |
412
|
|
|
<?php endif; ?> |
413
|
|
|
|
414
|
|
|
<?php foreach ( $sticky_posts as $post ) : ?> |
415
|
|
|
<?php $author = get_userdata( $post->post_author ); ?> |
416
|
|
|
<tr> |
417
|
|
|
<td scope="row"> |
418
|
|
|
<label> |
419
|
|
|
<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>"> |
420
|
|
|
<?php |
421
|
|
|
echo esc_html( $post->post_title ), ' - ', |
422
|
|
|
__( 'Published on', 'bulk-delete' ), ' ', get_the_date( get_option( 'date_format' ), $post->ID ), |
|
|
|
|
423
|
|
|
__( ' by ', 'bulk-delete' ), esc_html( $author->display_name ); |
424
|
|
|
?> |
425
|
|
|
</label> |
426
|
|
|
</td> |
427
|
|
|
</tr> |
428
|
|
|
<?php endforeach; ?> |
429
|
|
|
</table> |
430
|
|
|
<?php |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* Renders exclude sticky posts checkbox. |
435
|
|
|
*/ |
436
|
|
|
protected function render_exclude_sticky_settings() { |
437
|
|
|
if ( $this->are_sticky_posts_present() ) : // phpcs:ignore?> |
438
|
|
|
<tr> |
439
|
|
|
<td scope="row"> |
440
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky" value="true" type="checkbox"> |
441
|
|
|
</td> |
442
|
|
|
<td> |
443
|
|
|
<label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky"><?php _e( 'Exclude sticky posts', 'bulk-delete' ); ?></label> |
444
|
|
|
</td> |
445
|
|
|
</tr> |
446
|
|
|
<?php endif; // phpcs:ignore?> |
447
|
|
|
<?php |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
/** |
451
|
|
|
* Render Post Types as checkboxes. |
452
|
|
|
* |
453
|
|
|
* @since 5.6.0 |
454
|
|
|
* |
455
|
|
|
* @param string $name Name of post type checkboxes. |
456
|
|
|
*/ |
457
|
|
|
protected function render_post_type_checkboxes( $name ) { |
458
|
|
|
$post_types = bd_get_post_types(); |
459
|
|
|
?> |
460
|
|
|
|
461
|
|
|
<?php foreach ( $post_types as $post_type ) : ?> |
462
|
|
|
|
463
|
|
|
<tr> |
464
|
|
|
<td scope="row"> |
465
|
|
|
<input type="checkbox" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $post_type->name ); ?>" |
466
|
|
|
id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>" checked> |
467
|
|
|
|
468
|
|
|
<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>"> |
469
|
|
|
<?php echo esc_html( $post_type->label ); ?> |
470
|
|
|
</label> |
471
|
|
|
</td> |
472
|
|
|
</tr> |
473
|
|
|
|
474
|
|
|
<?php endforeach; ?> |
475
|
|
|
<?php |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Render the "private post" setting fields. |
480
|
|
|
*/ |
481
|
|
|
protected function render_private_post_settings() { |
482
|
|
|
bd_render_private_post_settings( $this->field_slug ); |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
/** |
486
|
|
|
* Render sticky settings. |
487
|
|
|
*/ |
488
|
|
|
protected function render_sticky_action_settings() { |
489
|
|
|
?> |
490
|
|
|
<tr> |
491
|
|
|
<td scope="row" colspan="2"> |
492
|
|
|
<label> |
493
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="unsticky" type="radio" checked> |
494
|
|
|
<?php _e( 'Remove Sticky', 'bulk-delete' ); ?> |
495
|
|
|
</label> |
496
|
|
|
<label> |
497
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="delete" type="radio"> |
498
|
|
|
<?php _e( 'Delete Post', 'bulk-delete' ); ?> |
499
|
|
|
</label> |
500
|
|
|
</td> |
501
|
|
|
</tr> |
502
|
|
|
<?php |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* Render filtering table header. |
507
|
|
|
*/ |
508
|
|
|
protected function render_filtering_table_header() { |
509
|
|
|
bd_render_filtering_table_header(); |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Render restrict settings. |
514
|
|
|
*/ |
515
|
|
|
protected function render_restrict_settings() { |
516
|
|
|
bd_render_restrict_settings( $this->field_slug, $this->item_type ); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
520
|
|
|
* Render delete settings. |
521
|
|
|
*/ |
522
|
|
|
protected function render_delete_settings() { |
523
|
|
|
bd_render_delete_settings( $this->field_slug ); |
524
|
|
|
/** |
525
|
|
|
* This action is primarily for adding delete attachment settings. |
526
|
|
|
* |
527
|
|
|
* @since 6.0.0 |
528
|
|
|
* |
529
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule The delete module. |
530
|
|
|
*/ |
531
|
|
|
do_action( 'bd_render_attachment_settings', $this ); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* Render limit settings. |
536
|
|
|
* |
537
|
|
|
* @param string $item_type Item Type to be displayed in label. |
538
|
|
|
*/ |
539
|
|
|
protected function render_limit_settings( $item_type = '' ) { |
540
|
|
|
if ( empty( $item_type ) ) { |
541
|
|
|
$item_type = $this->item_type; |
542
|
|
|
} |
543
|
|
|
bd_render_limit_settings( $this->field_slug, $item_type ); |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* Render cron settings based on whether scheduler is present or not. |
548
|
|
|
*/ |
549
|
|
|
protected function render_cron_settings() { |
550
|
|
|
$pro_class = ''; |
551
|
|
|
|
552
|
|
|
$disabled_attr = 'disabled'; |
553
|
|
|
if ( empty( $this->scheduler_url ) ) { |
554
|
|
|
$disabled_attr = ''; |
555
|
|
|
} |
556
|
|
|
?> |
557
|
|
|
|
558
|
|
|
<tr> |
559
|
|
|
<td scope="row" colspan="2"> |
560
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="false" type="radio" |
561
|
|
|
checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?></label> |
562
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="true" type="radio" |
563
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" <?php echo esc_attr( $disabled_attr ); ?>> <?php _e( 'Schedule', 'bulk-delete' ); ?></label> |
564
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" |
565
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value="now" |
566
|
|
|
type="text" <?php echo esc_attr( $disabled_attr ); ?> autocomplete="off"><?php _e( 'repeat ', 'bulk-delete' ); ?> |
567
|
|
|
|
568
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" |
569
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" <?php echo esc_attr( $disabled_attr ); ?>> |
570
|
|
|
|
571
|
|
|
<option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option> |
572
|
|
|
<?php |
573
|
|
|
/** |
574
|
|
|
* List of cron schedules. |
575
|
|
|
* |
576
|
|
|
* @since 6.0.0 |
577
|
|
|
* |
578
|
|
|
* @param array $cron_schedules List of cron schedules. |
579
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
580
|
|
|
*/ |
581
|
|
|
$cron_schedules = apply_filters( 'bd_cron_schedules', wp_get_schedules(), $this ); |
582
|
|
|
?> |
583
|
|
|
|
584
|
|
|
<?php foreach ( $cron_schedules as $key => $value ) : ?> |
585
|
|
|
<option |
586
|
|
|
value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['display'] ); ?></option> |
587
|
|
|
<?php endforeach; ?> |
588
|
|
|
</select> |
589
|
|
|
|
590
|
|
|
<?php if ( ! empty( $this->scheduler_url ) ) : ?> |
591
|
|
|
<?php |
592
|
|
|
$pro_class = 'bd-' . str_replace( '_', '-', $this->field_slug ) . '-pro'; |
593
|
|
|
|
594
|
|
|
/** |
595
|
|
|
* HTML class of the span that displays the 'Pro only feature' message. |
596
|
|
|
* |
597
|
|
|
* @since 6.0.0 |
598
|
|
|
* |
599
|
|
|
* @param string $pro_class HTML class. |
600
|
|
|
* @param string $field_slug Field Slug of module. |
601
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
602
|
|
|
*/ |
603
|
|
|
$pro_class = apply_filters( 'bd_pro_only_feature_class', $pro_class, $this->field_slug, $this ) |
604
|
|
|
?> |
605
|
|
|
|
606
|
|
|
<span class="<?php echo sanitize_html_class( $pro_class ); ?>" style="color:red"> |
607
|
|
|
<?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a |
608
|
|
|
href="<?php echo esc_url( $this->scheduler_url ); ?>">Buy now</a> |
609
|
|
|
</span> |
610
|
|
|
<?php endif; ?> |
611
|
|
|
</td> |
612
|
|
|
</tr> |
613
|
|
|
|
614
|
|
|
<tr |
615
|
|
|
<?php if ( ! empty( $pro_class ) ) : ?> |
616
|
|
|
class="<?php echo sanitize_html_class( $pro_class ); ?>" style="display: none;" |
617
|
|
|
<?php endif; ?> |
618
|
|
|
> |
619
|
|
|
|
620
|
|
|
<td scope="row" colspan="2"> |
621
|
|
|
<?php |
622
|
|
|
_e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time.', 'bulk-delete' ); |
623
|
|
|
|
624
|
|
|
$markup = __( 'Want to add new a Cron schedule?', 'bulk-delete' ) . ' ' . |
625
|
|
|
'<a href="https://bulkwp.com/docs/add-a-new-cron-schedule/" target="_blank" rel="noopener">' . __( 'Find out how', 'bulk-delete' ) . '</a>'; |
626
|
|
|
|
627
|
|
|
$content = __( 'Learn how to add your desired Cron schedule.', 'bulk-delete' ); |
628
|
|
|
echo ' ', bd_generate_help_tooltip( $markup, $content ); |
629
|
|
|
?> |
630
|
|
|
</td> |
631
|
|
|
</tr> |
632
|
|
|
<?php |
633
|
|
|
} |
634
|
|
|
|
635
|
|
|
/** |
636
|
|
|
* Render submit button. |
637
|
|
|
*/ |
638
|
|
|
protected function render_submit_button() { |
639
|
|
|
bd_render_submit_button( $this->action ); |
640
|
|
|
} |
641
|
|
|
} |
642
|
|
|
|