|
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
|
|
|
protected function render_post_type_with_status() { |
|
78
|
|
|
$post_types_by_status = $this->get_post_types_by_status(); |
|
79
|
|
|
?> |
|
80
|
|
|
<tr> |
|
81
|
|
|
<td scope="row" colspan="2"> |
|
82
|
|
|
<select class="enhanced-post-types-with-status" multiple="multiple" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]"> |
|
83
|
|
|
<?php foreach ( $post_types_by_status as $post_type => $all_status ) : ?> |
|
84
|
|
|
<optgroup label="<?php echo esc_html( $post_type ); ?>"> |
|
85
|
|
|
<?php foreach ( $all_status as $status_key => $status_value ) : ?> |
|
86
|
|
|
<option value="<?php echo esc_attr( $status_key ); ?>"><?php echo esc_html( $status_value ); ?></option> |
|
87
|
|
|
<?php endforeach; ?> |
|
88
|
|
|
</optgroup> |
|
89
|
|
|
<?php endforeach; ?> |
|
90
|
|
|
</select> |
|
91
|
|
|
</td> |
|
92
|
|
|
</tr> |
|
93
|
|
|
<?php |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Split post type and status. |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $str Post type and status combination. |
|
100
|
|
|
* |
|
101
|
|
|
* @return array Post type and status as elements of array. |
|
102
|
|
|
*/ |
|
103
|
9 |
|
protected function split_post_type_and_status( $str ) { |
|
104
|
9 |
|
$type_status = array(); |
|
105
|
|
|
|
|
106
|
9 |
|
$str_arr = explode( '-', $str ); |
|
107
|
|
|
|
|
108
|
9 |
|
if ( count( $str_arr ) > 1 ) { |
|
109
|
|
|
$type_status['status'] = end( $str_arr ); |
|
110
|
|
|
$type_status['type'] = implode( '-', array_slice( $str_arr, 0, - 1 ) ); |
|
111
|
|
|
} else { |
|
112
|
9 |
|
$type_status['status'] = 'publish'; |
|
113
|
9 |
|
$type_status['type'] = $str; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
9 |
|
return $type_status; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Render content settings. |
|
121
|
|
|
*/ |
|
122
|
|
|
protected function render_content_settings() { |
|
123
|
|
|
?> |
|
124
|
|
|
<tr> |
|
125
|
|
|
<td scope="row" colspan="2"> |
|
126
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_content" value="false" type="radio" |
|
127
|
|
|
checked="checked" class="delete-content"> <?php _e( 'Also delete all posts of the users', 'bulk-delete' ); ?></label> |
|
128
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_content" value="true" type="radio" |
|
129
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_content" class="delete-content"> <?php _e( 'Re-assign the posts to', 'bulk-delete' ); ?></label> |
|
130
|
|
|
<?php wp_dropdown_users( array( 'name' => 'smbd_' . esc_attr( $this->field_slug ) . '_reassign_user_id', 'class' => 'reassign-user') ); ?> |
|
131
|
|
|
</td> |
|
132
|
|
|
</tr> |
|
133
|
|
|
<?php |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Render user role dropdown. |
|
138
|
|
|
*/ |
|
139
|
|
|
protected function render_user_role_dropdown() { |
|
140
|
|
|
global $wp_roles; |
|
141
|
|
|
?> |
|
142
|
|
|
|
|
143
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown" |
|
144
|
|
|
multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>"> |
|
145
|
|
|
|
|
146
|
|
|
<?php foreach ( $wp_roles->roles as $role => $role_details ) : ?> |
|
147
|
|
|
<option value="<?php echo esc_attr( $role ); ?>"> |
|
148
|
|
|
<?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?> |
|
149
|
|
|
</option> |
|
150
|
|
|
<?php endforeach; ?> |
|
151
|
|
|
</select> |
|
152
|
|
|
|
|
153
|
|
|
<?php |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Render Post type dropdown. |
|
158
|
|
|
*/ |
|
159
|
|
|
protected function render_post_type_dropdown() { |
|
160
|
|
|
bd_render_post_type_dropdown( $this->field_slug ); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Render Taxonomy dropdown. |
|
165
|
|
|
*/ |
|
166
|
|
|
protected function render_taxonomy_dropdown() { |
|
167
|
|
|
$taxonomies = get_taxonomies( array(), 'objects' ); |
|
168
|
|
|
?> |
|
169
|
|
|
|
|
170
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy" class="enhanced-taxonomy-list" data-placeholder="<?php _e( 'Select Taxonomy', 'bulk-delete' ); ?>"> |
|
171
|
|
|
<?php foreach ( $taxonomies as $taxonomy ) : ?> |
|
172
|
|
|
<option value="<?php echo esc_attr( $taxonomy->name ); ?>"> |
|
173
|
|
|
<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?> |
|
174
|
|
|
</option> |
|
175
|
|
|
<?php endforeach; ?> |
|
176
|
|
|
</select> |
|
177
|
|
|
<?php |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Render Category dropdown. |
|
182
|
|
|
*/ |
|
183
|
|
|
protected function render_category_dropdown() { |
|
184
|
|
|
$categories = $this->get_categories(); |
|
185
|
|
|
?> |
|
186
|
|
|
|
|
187
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>" |
|
188
|
|
|
class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>" |
|
189
|
|
|
data-taxonomy="category" multiple> |
|
190
|
|
|
|
|
191
|
|
|
<option value="all"> |
|
192
|
|
|
<?php _e( 'All Categories', 'bulk-delete' ); ?> |
|
193
|
|
|
</option> |
|
194
|
|
|
|
|
195
|
|
|
<?php foreach ( $categories as $category ) : ?> |
|
196
|
|
|
<option value="<?php echo absint( $category->cat_ID ); ?>"> |
|
197
|
|
|
<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
|
198
|
|
|
</option> |
|
199
|
|
|
<?php endforeach; ?> |
|
200
|
|
|
|
|
201
|
|
|
</select> |
|
202
|
|
|
<?php |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
/** |
|
206
|
|
|
* Render String based comparison operators dropdown. |
|
207
|
|
|
*/ |
|
208
|
|
|
protected function render_string_comparison_operators() { |
|
209
|
|
|
?> |
|
210
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
|
211
|
|
|
<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
|
212
|
|
|
<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
|
213
|
|
|
<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option> |
|
214
|
|
|
<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option> |
|
215
|
|
|
<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option> |
|
216
|
|
|
<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option> |
|
217
|
|
|
</select> |
|
218
|
|
|
<?php |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
/** |
|
222
|
|
|
* Render number based comparison operators dropdown. |
|
223
|
|
|
*/ |
|
224
|
|
|
protected function render_number_comparison_operators() { |
|
225
|
|
|
?> |
|
226
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
|
227
|
|
|
<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
|
228
|
|
|
<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
|
229
|
|
|
<option value="less_than"><?php _e( 'less than', 'bulk-delete' ); ?></option> |
|
230
|
|
|
<option value="greater_than"><?php _e( 'greater than', 'bulk-delete' ); ?></option> |
|
231
|
|
|
</select> |
|
232
|
|
|
<?php |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Render Tags dropdown. |
|
237
|
|
|
*/ |
|
238
|
|
|
protected function render_tags_dropdown() { |
|
239
|
|
|
$tags = $this->get_tags(); |
|
240
|
|
|
?> |
|
241
|
|
|
|
|
242
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>" |
|
243
|
|
|
class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>" |
|
244
|
|
|
data-taxonomy="post_tag" multiple> |
|
245
|
|
|
|
|
246
|
|
|
<option value="all"> |
|
247
|
|
|
<?php _e( 'All Tags', 'bulk-delete' ); ?> |
|
248
|
|
|
</option> |
|
249
|
|
|
|
|
250
|
|
|
<?php foreach ( $tags as $tag ) : ?> |
|
251
|
|
|
<option value="<?php echo absint( $tag->term_id ); ?>"> |
|
252
|
|
|
<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
|
253
|
|
|
</option> |
|
254
|
|
|
<?php endforeach; ?> |
|
255
|
|
|
</select> |
|
256
|
|
|
<?php |
|
257
|
|
|
} |
|
258
|
|
|
|
|
259
|
|
|
/** |
|
260
|
|
|
* Get the class name for select2 dropdown based on the number of items present. |
|
261
|
|
|
* |
|
262
|
|
|
* @param int $count The number of items present. |
|
263
|
|
|
* @param string $class_name Primary class name. |
|
264
|
|
|
* |
|
265
|
|
|
* @return string Class name. |
|
266
|
|
|
*/ |
|
267
|
|
|
protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) { |
|
268
|
|
|
if ( $count >= $this->get_enhanced_select_threshold() ) { |
|
269
|
|
|
$class_name .= '-ajax'; |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
return $class_name; |
|
273
|
|
|
} |
|
274
|
|
|
|
|
275
|
|
|
/** |
|
276
|
|
|
* Render Sticky Posts dropdown. |
|
277
|
|
|
*/ |
|
278
|
|
|
protected function render_sticky_posts_dropdown() { |
|
279
|
|
|
$sticky_posts = $this->get_sticky_posts(); |
|
280
|
|
|
?> |
|
281
|
|
|
|
|
282
|
|
|
<table class="optiontable"> |
|
283
|
|
|
<?php if ( count( $sticky_posts ) > 1 ) : ?> |
|
284
|
|
|
<tr> |
|
285
|
|
|
<td scope="row"> |
|
286
|
|
|
<label> |
|
287
|
|
|
<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all"> |
|
288
|
|
|
<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
|
289
|
|
|
</label> |
|
290
|
|
|
</td> |
|
291
|
|
|
</tr> |
|
292
|
|
|
<?php endif; ?> |
|
293
|
|
|
|
|
294
|
|
|
<?php foreach ( $sticky_posts as $post ) : ?> |
|
295
|
|
|
<?php $author = get_userdata( $post->post_author ); ?> |
|
296
|
|
|
<tr> |
|
297
|
|
|
<td scope="row"> |
|
298
|
|
|
<label> |
|
299
|
|
|
<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>"> |
|
300
|
|
|
<?php |
|
301
|
|
|
echo esc_html( $post->post_title ), ' - ', |
|
302
|
|
|
__( 'Published on', 'bulk-delete' ), ' ', get_the_date( get_option( 'date_format' ), $post->ID ), |
|
|
|
|
|
|
303
|
|
|
__( ' by ', 'bulk-delete' ), esc_html( $author->display_name ); |
|
304
|
|
|
?> |
|
305
|
|
|
</label> |
|
306
|
|
|
</td> |
|
307
|
|
|
</tr> |
|
308
|
|
|
<?php endforeach; ?> |
|
309
|
|
|
</table> |
|
310
|
|
|
<?php |
|
311
|
|
|
} |
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* Renders exclude sticky posts checkbox. |
|
315
|
|
|
*/ |
|
316
|
|
|
protected function render_exclude_sticky_settings() { |
|
317
|
|
|
if ( $this->are_sticky_posts_present() ) : // phpcs:ignore?> |
|
318
|
|
|
<tr> |
|
319
|
|
|
<td scope="row"> |
|
320
|
|
|
<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"> |
|
321
|
|
|
</td> |
|
322
|
|
|
<td> |
|
323
|
|
|
<label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky"><?php _e( 'Exclude sticky posts', 'bulk-delete' ); ?></label> |
|
324
|
|
|
</td> |
|
325
|
|
|
</tr> |
|
326
|
|
|
<?php endif; // phpcs:ignore?> |
|
327
|
|
|
<?php |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
/** |
|
331
|
|
|
* Render Post Types as checkboxes. |
|
332
|
|
|
* |
|
333
|
|
|
* @since 5.6.0 |
|
334
|
|
|
* |
|
335
|
|
|
* @param string $name Name of post type checkboxes. |
|
336
|
|
|
*/ |
|
337
|
|
|
protected function render_post_type_checkboxes( $name ) { |
|
338
|
|
|
$post_types = bd_get_post_types(); |
|
339
|
|
|
?> |
|
340
|
|
|
|
|
341
|
|
|
<?php foreach ( $post_types as $post_type ) : ?> |
|
342
|
|
|
|
|
343
|
|
|
<tr> |
|
344
|
|
|
<td scope="row"> |
|
345
|
|
|
<input type="checkbox" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $post_type->name ); ?>" |
|
346
|
|
|
id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>" checked> |
|
347
|
|
|
|
|
348
|
|
|
<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>"> |
|
349
|
|
|
<?php echo esc_html( $post_type->label ); ?> |
|
350
|
|
|
</label> |
|
351
|
|
|
</td> |
|
352
|
|
|
</tr> |
|
353
|
|
|
|
|
354
|
|
|
<?php endforeach; ?> |
|
355
|
|
|
<?php |
|
356
|
|
|
} |
|
357
|
|
|
|
|
358
|
|
|
/** |
|
359
|
|
|
* Render the "private post" setting fields. |
|
360
|
|
|
*/ |
|
361
|
|
|
protected function render_private_post_settings() { |
|
362
|
|
|
bd_render_private_post_settings( $this->field_slug ); |
|
363
|
|
|
} |
|
364
|
|
|
|
|
365
|
|
|
/** |
|
366
|
|
|
* Get the threshold after which enhanced select should be used. |
|
367
|
|
|
* |
|
368
|
|
|
* @return int Threshold. |
|
369
|
|
|
*/ |
|
370
|
|
|
protected function get_enhanced_select_threshold() { |
|
371
|
|
|
/** |
|
372
|
|
|
* Filter the enhanced select threshold. |
|
373
|
|
|
* |
|
374
|
|
|
* @since 6.0.0 |
|
375
|
|
|
* |
|
376
|
|
|
* @param int Threshold. |
|
377
|
|
|
*/ |
|
378
|
|
|
return apply_filters( 'bd_enhanced_select_threshold', 1000 ); |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
/** |
|
382
|
|
|
* Render sticky settings. |
|
383
|
|
|
*/ |
|
384
|
|
|
protected function render_sticky_action_settings() { |
|
385
|
|
|
?> |
|
386
|
|
|
<tr> |
|
387
|
|
|
<td scope="row" colspan="2"> |
|
388
|
|
|
<label> |
|
389
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="unsticky" type="radio" checked> |
|
390
|
|
|
<?php _e( 'Remove Sticky', 'bulk-delete' ); ?> |
|
391
|
|
|
</label> |
|
392
|
|
|
<label> |
|
393
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="delete" type="radio"> |
|
394
|
|
|
<?php _e( 'Delete Post', 'bulk-delete' ); ?> |
|
395
|
|
|
</label> |
|
396
|
|
|
</td> |
|
397
|
|
|
</tr> |
|
398
|
|
|
<?php |
|
399
|
|
|
} |
|
400
|
|
|
|
|
401
|
|
|
/** |
|
402
|
|
|
* Render filtering table header. |
|
403
|
|
|
*/ |
|
404
|
|
|
protected function render_filtering_table_header() { |
|
405
|
|
|
bd_render_filtering_table_header(); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
/** |
|
409
|
|
|
* Render restrict settings. |
|
410
|
|
|
*/ |
|
411
|
|
|
protected function render_restrict_settings() { |
|
412
|
|
|
bd_render_restrict_settings( $this->field_slug, $this->item_type ); |
|
413
|
|
|
} |
|
414
|
|
|
|
|
415
|
|
|
/** |
|
416
|
|
|
* Render delete settings. |
|
417
|
|
|
*/ |
|
418
|
|
|
protected function render_delete_settings() { |
|
419
|
|
|
bd_render_delete_settings( $this->field_slug ); |
|
420
|
|
|
/** |
|
421
|
|
|
* This action is primarily for adding delete attachment settings. |
|
422
|
|
|
* |
|
423
|
|
|
* @since 6.0.0 |
|
424
|
|
|
* |
|
425
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule The delete module. |
|
426
|
|
|
*/ |
|
427
|
|
|
do_action( 'bd_render_attachment_settings', $this ); |
|
428
|
|
|
} |
|
429
|
|
|
|
|
430
|
|
|
/** |
|
431
|
|
|
* Render limit settings. |
|
432
|
|
|
*/ |
|
433
|
|
|
protected function render_limit_settings() { |
|
434
|
|
|
bd_render_limit_settings( $this->field_slug, $this->item_type ); |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* Render cron settings based on whether scheduler is present or not. |
|
439
|
|
|
*/ |
|
440
|
|
|
protected function render_cron_settings() { |
|
441
|
|
|
$disabled_attr = 'disabled'; |
|
442
|
|
|
if ( empty( $this->scheduler_url ) ) { |
|
443
|
|
|
$disabled_attr = ''; |
|
444
|
|
|
} |
|
445
|
|
|
?> |
|
446
|
|
|
|
|
447
|
|
|
<tr> |
|
448
|
|
|
<td scope="row" colspan="2"> |
|
449
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="false" type="radio" |
|
450
|
|
|
checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?></label> |
|
451
|
|
|
<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="true" type="radio" |
|
452
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" <?php echo esc_attr( $disabled_attr ); ?>> <?php _e( 'Schedule', 'bulk-delete' ); ?></label> |
|
453
|
|
|
<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" |
|
454
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value="now" |
|
455
|
|
|
type="text" <?php echo esc_attr( $disabled_attr ); ?>><?php _e( 'repeat ', 'bulk-delete' ); ?> |
|
456
|
|
|
|
|
457
|
|
|
<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" |
|
458
|
|
|
id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" <?php echo esc_attr( $disabled_attr ); ?>> |
|
459
|
|
|
|
|
460
|
|
|
<option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option> |
|
461
|
|
|
<?php |
|
462
|
|
|
/** |
|
463
|
|
|
* List of cron schedules. |
|
464
|
|
|
* |
|
465
|
|
|
* @since 6.0.0 |
|
466
|
|
|
* |
|
467
|
|
|
* @param array $cron_schedules List of cron schedules. |
|
468
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
|
469
|
|
|
*/ |
|
470
|
|
|
$cron_schedules = apply_filters( 'bd_cron_schedules', wp_get_schedules(), $this ); |
|
471
|
|
|
?> |
|
472
|
|
|
|
|
473
|
|
|
<?php foreach ( $cron_schedules as $key => $value ) : ?> |
|
474
|
|
|
<option |
|
475
|
|
|
value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['display'] ); ?></option> |
|
476
|
|
|
<?php endforeach; ?> |
|
477
|
|
|
</select> |
|
478
|
|
|
|
|
479
|
|
|
<?php if ( ! empty( $this->scheduler_url ) ) : ?> |
|
480
|
|
|
<?php |
|
481
|
|
|
$pro_class = 'bd-' . str_replace( '_', '-', $this->field_slug ) . '-pro'; |
|
482
|
|
|
|
|
483
|
|
|
/** |
|
484
|
|
|
* HTML class of the span that displays the 'Pro only feature' message. |
|
485
|
|
|
* |
|
486
|
|
|
* @since 6.0.0 |
|
487
|
|
|
* |
|
488
|
|
|
* @param string $pro_class HTML class. |
|
489
|
|
|
* @param string $field_slug Field Slug of module. |
|
490
|
|
|
* @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
|
491
|
|
|
*/ |
|
492
|
|
|
apply_filters( 'bd_pro_only_feature_class', $pro_class, $this->field_slug, $this ) |
|
493
|
|
|
?> |
|
494
|
|
|
|
|
495
|
|
|
<span class="<?php echo sanitize_html_class( $pro_class ); ?>" style="color:red"> |
|
496
|
|
|
<?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a |
|
497
|
|
|
href="<?php echo esc_url( $this->scheduler_url ); ?>">Buy now</a> |
|
498
|
|
|
</span> |
|
499
|
|
|
<?php endif; ?> |
|
500
|
|
|
</td> |
|
501
|
|
|
</tr> |
|
502
|
|
|
|
|
503
|
|
|
<tr class="<?php echo sanitize_html_class( $pro_class ); ?>" style="display: none;"> |
|
|
|
|
|
|
504
|
|
|
<td scope="row" colspan="2"> |
|
505
|
|
|
<?php |
|
506
|
|
|
_e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time.', 'bulk-delete' ); |
|
507
|
|
|
$link = '<a href="https://bulkwp.com/docs/add-a-new-cron-schedule/">' . __( 'Click here', 'bulk-delete' ) . '</a>'; |
|
508
|
|
|
$markup = sprintf( __( 'Want to add new a Cron schedule? %s', 'bulk-delete' ), $link ); |
|
509
|
|
|
|
|
510
|
|
|
$content = __( 'Learn how to add your desired Cron schedule.', 'bulk-delete' ); |
|
511
|
|
|
echo ' ' . bd_generate_help_tooltip( $markup, $content ); |
|
512
|
|
|
?> |
|
513
|
|
|
</td> |
|
514
|
|
|
</tr> |
|
515
|
|
|
<?php |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
/** |
|
519
|
|
|
* Render submit button. |
|
520
|
|
|
*/ |
|
521
|
|
|
protected function render_submit_button() { |
|
522
|
|
|
bd_render_submit_button( $this->action ); |
|
523
|
|
|
} |
|
524
|
|
|
} |
|
525
|
|
|
|