Total Complexity | 55 |
Total Lines | 620 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like Renderer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Renderer, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
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() { |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Render Post type with status and post count checkboxes. |
||
76 | */ |
||
77 | protected function render_post_type_with_status() { |
||
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 | protected function split_post_type_and_status( $str ) { |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Render post reassign settings. |
||
121 | */ |
||
122 | protected function render_post_reassign_settings() { |
||
123 | ?> |
||
124 | <tr> |
||
125 | <td scope="row" colspan="2"> |
||
126 | <label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="false" type="radio" |
||
127 | checked="checked" class="post-reassign"> <?php _e( 'Also delete all posts of the users', 'bulk-delete' ); ?></label> |
||
128 | <label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="true" type="radio" |
||
129 | id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" class="post-reassign"> <?php _e( 'Re-assign the posts to', 'bulk-delete' ); ?></label> |
||
130 | <?php |
||
131 | wp_dropdown_users( |
||
132 | array( |
||
133 | 'name' => 'smbd_' . esc_attr( $this->field_slug ) . '_reassign_user_id', |
||
134 | 'class' => 'reassign-user', |
||
135 | 'show_option_none' => __( 'Select User', 'bulk-delete' ), |
||
136 | ) |
||
137 | ); |
||
138 | ?> |
||
139 | </td> |
||
140 | </tr> |
||
141 | <?php |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Render user role dropdown. |
||
146 | * |
||
147 | * @param bool $show_users_with_no_roles Should users with no user roles be shown? Default false. |
||
148 | */ |
||
149 | protected function render_user_role_dropdown( $show_users_with_no_roles = false ) { |
||
150 | $roles = get_editable_roles(); |
||
151 | $users_count = count_users(); |
||
152 | ?> |
||
153 | |||
154 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown" |
||
155 | multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>"> |
||
156 | |||
157 | <?php foreach ( $roles as $role => $role_details ) : ?> |
||
158 | <option value="<?php echo esc_attr( $role ); ?>"> |
||
159 | <?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role, $users_count ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?> |
||
160 | </option> |
||
161 | <?php endforeach; ?> |
||
162 | |||
163 | <?php if ( $show_users_with_no_roles ) : ?> |
||
164 | <?php if ( isset( $users_count['avail_roles']['none'] ) && $users_count['avail_roles']['none'] > 0 ) : ?> |
||
165 | <option value="none"> |
||
166 | <?php echo __( 'No role', 'bulk-delete' ), ' (', absint( $users_count['avail_roles']['none'] ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?> |
||
167 | </option> |
||
168 | <?php endif; ?> |
||
169 | <?php endif; ?> |
||
170 | </select> |
||
171 | |||
172 | <?php |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * Render Post type dropdown. |
||
177 | */ |
||
178 | protected function render_post_type_dropdown() { |
||
179 | bd_render_post_type_dropdown( $this->field_slug ); |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * Render Taxonomy dropdown. |
||
184 | */ |
||
185 | protected function render_taxonomy_dropdown() { |
||
186 | $taxonomies = get_taxonomies( array(), 'objects' ); |
||
187 | ?> |
||
188 | |||
189 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy" class="enhanced-taxonomy-list" data-placeholder="<?php _e( 'Select Taxonomy', 'bulk-delete' ); ?>"> |
||
190 | <?php foreach ( $taxonomies as $taxonomy ) : ?> |
||
191 | <option value="<?php echo esc_attr( $taxonomy->name ); ?>"> |
||
192 | <?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?> |
||
193 | </option> |
||
194 | <?php endforeach; ?> |
||
195 | </select> |
||
196 | <?php |
||
197 | } |
||
198 | |||
199 | /** |
||
200 | * Render Category dropdown. |
||
201 | */ |
||
202 | protected function render_category_dropdown() { |
||
203 | $categories = $this->get_categories(); |
||
204 | ?> |
||
205 | |||
206 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>" |
||
207 | class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>" |
||
208 | data-taxonomy="category" multiple> |
||
209 | |||
210 | <option value="all"> |
||
211 | <?php _e( 'All Categories', 'bulk-delete' ); ?> |
||
212 | </option> |
||
213 | |||
214 | <?php foreach ( $categories as $category ) : ?> |
||
215 | <option value="<?php echo absint( $category->cat_ID ); ?>"> |
||
216 | <?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
||
217 | </option> |
||
218 | <?php endforeach; ?> |
||
219 | |||
220 | </select> |
||
221 | <?php |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * Render String based comparison operators dropdown. |
||
226 | */ |
||
227 | protected function render_string_comparison_operators() { |
||
228 | ?> |
||
229 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
||
230 | <option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
||
231 | <option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
||
232 | <option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option> |
||
233 | <option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option> |
||
234 | <option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option> |
||
235 | <option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option> |
||
236 | </select> |
||
237 | <?php |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * Render number based comparison operators dropdown. |
||
242 | */ |
||
243 | protected function render_number_comparison_operators() { |
||
244 | ?> |
||
245 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator"> |
||
246 | <option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option> |
||
247 | <option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option> |
||
248 | <option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option> |
||
249 | <option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option> |
||
250 | </select> |
||
251 | <?php |
||
252 | } |
||
253 | |||
254 | /** |
||
255 | * Render data types dropdown. |
||
256 | */ |
||
257 | protected function render_data_types_dropdown() { |
||
258 | ?> |
||
259 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type"> |
||
260 | <option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option> |
||
261 | <option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option> |
||
262 | <option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option> |
||
263 | </select> |
||
264 | <?php |
||
265 | } |
||
266 | /** |
||
267 | * Render numeric comparison operators dropdown. |
||
268 | * |
||
269 | * @param string $class Class to be applied. |
||
270 | * @param array $operators List of Operators needed. |
||
271 | */ |
||
272 | protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) { |
||
273 | $all_numeric_operators = array( |
||
274 | '=' => 'equal to', |
||
275 | '!=' => 'not equal to', |
||
276 | '<' => 'less than', |
||
277 | '<=' => 'less than or equal to', |
||
278 | '>' => 'greater than', |
||
279 | '>=' => 'greater than or equal to', |
||
280 | 'IN' => 'in', |
||
281 | 'NOT IN' => 'not in', |
||
282 | 'BETWEEN' => 'between', |
||
283 | 'NOT BETWEEN' => 'not between', |
||
284 | 'EXISTS' => 'exists', |
||
285 | 'NOT EXISTS' => 'not exists', |
||
286 | ); |
||
287 | if ( in_array( 'all', $operators, true ) ) { |
||
288 | $operators = array_keys( $all_numeric_operators ); |
||
289 | } |
||
290 | ?> |
||
291 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>"> |
||
292 | <?php |
||
293 | foreach ( $operators as $operator ) { |
||
294 | echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>'; |
||
295 | } |
||
296 | ?> |
||
297 | </select> |
||
298 | <?php |
||
299 | } |
||
300 | /** |
||
301 | * Render string comparison operators dropdown. |
||
302 | * |
||
303 | * @param string $class Class to be applied. |
||
304 | * @param array $operators List of Operators needed. |
||
305 | */ |
||
306 | protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) { |
||
307 | // STARTS_WITH and ENDS_WITH operators needs a handler as SQL does not support these operators in queries. |
||
308 | $all_string_operators = array( |
||
309 | '=' => 'equal to', |
||
310 | '!=' => 'not equal to', |
||
311 | 'IN' => 'in', |
||
312 | 'NOT IN' => 'not in', |
||
313 | 'LIKE' => 'contains', |
||
314 | 'NOT LIKE' => 'not contains', |
||
315 | 'EXISTS' => 'exists', |
||
316 | 'NOT EXISTS' => 'not exists', |
||
317 | 'STARTS_WITH' => 'starts with', |
||
318 | 'ENDS_WITH' => 'ends with', |
||
319 | ); |
||
320 | if ( in_array( 'all', $operators, true ) ) { |
||
321 | $operators = array_keys( $all_string_operators ); |
||
322 | } |
||
323 | ?> |
||
324 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>"> |
||
325 | <?php |
||
326 | foreach ( $operators as $operator ) { |
||
327 | echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>'; |
||
328 | } |
||
329 | ?> |
||
330 | </select> |
||
331 | <?php |
||
332 | } |
||
333 | |||
334 | /** |
||
335 | * Render Tags dropdown. |
||
336 | */ |
||
337 | protected function render_tags_dropdown() { |
||
338 | $tags = $this->get_tags(); |
||
339 | ?> |
||
340 | |||
341 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>" |
||
342 | class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>" |
||
343 | data-taxonomy="post_tag" multiple> |
||
344 | |||
345 | <option value="all"> |
||
346 | <?php _e( 'All Tags', 'bulk-delete' ); ?> |
||
347 | </option> |
||
348 | |||
349 | <?php foreach ( $tags as $tag ) : ?> |
||
350 | <option value="<?php echo absint( $tag->term_id ); ?>"> |
||
351 | <?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
||
352 | </option> |
||
353 | <?php endforeach; ?> |
||
354 | </select> |
||
355 | <?php |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * Get the class name for select2 dropdown based on the number of items present. |
||
360 | * |
||
361 | * @param int $count The number of items present. |
||
362 | * @param string $class_name Primary class name. |
||
363 | * |
||
364 | * @return string Class name. |
||
365 | */ |
||
366 | protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) { |
||
367 | if ( $count >= $this->get_enhanced_select_threshold() ) { |
||
368 | $class_name .= '-ajax'; |
||
369 | } |
||
370 | |||
371 | return $class_name; |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * Render Sticky Posts dropdown. |
||
376 | */ |
||
377 | protected function render_sticky_posts_dropdown() { |
||
378 | $sticky_posts = $this->get_sticky_posts(); |
||
379 | ?> |
||
380 | |||
381 | <table class="optiontable"> |
||
382 | <?php if ( count( $sticky_posts ) > 1 ) : ?> |
||
383 | <tr> |
||
384 | <td scope="row"> |
||
385 | <label> |
||
386 | <input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all"> |
||
387 | <?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?> |
||
388 | </label> |
||
389 | </td> |
||
390 | </tr> |
||
391 | <?php endif; ?> |
||
392 | |||
393 | <?php foreach ( $sticky_posts as $post ) : ?> |
||
394 | <?php $author = get_userdata( $post->post_author ); ?> |
||
395 | <tr> |
||
396 | <td scope="row"> |
||
397 | <label> |
||
398 | <input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>"> |
||
399 | <?php |
||
400 | echo esc_html( $post->post_title ), ' - ', |
||
401 | __( 'Published on', 'bulk-delete' ), ' ', get_the_date( get_option( 'date_format' ), $post->ID ), |
||
402 | __( ' by ', 'bulk-delete' ), esc_html( $author->display_name ); |
||
403 | ?> |
||
404 | </label> |
||
405 | </td> |
||
406 | </tr> |
||
407 | <?php endforeach; ?> |
||
408 | </table> |
||
409 | <?php |
||
410 | } |
||
411 | |||
412 | /** |
||
413 | * Renders exclude sticky posts checkbox. |
||
414 | */ |
||
415 | protected function render_exclude_sticky_settings() { |
||
416 | if ( $this->are_sticky_posts_present() ) : // phpcs:ignore?> |
||
417 | <tr> |
||
418 | <td scope="row"> |
||
419 | <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"> |
||
420 | </td> |
||
421 | <td> |
||
422 | <label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky"><?php _e( 'Exclude sticky posts', 'bulk-delete' ); ?></label> |
||
423 | </td> |
||
424 | </tr> |
||
425 | <?php endif; // phpcs:ignore?> |
||
426 | <?php |
||
427 | } |
||
428 | |||
429 | /** |
||
430 | * Render Post Types as checkboxes. |
||
431 | * |
||
432 | * @since 5.6.0 |
||
433 | * |
||
434 | * @param string $name Name of post type checkboxes. |
||
435 | */ |
||
436 | protected function render_post_type_checkboxes( $name ) { |
||
437 | $post_types = bd_get_post_types(); |
||
438 | ?> |
||
439 | |||
440 | <?php foreach ( $post_types as $post_type ) : ?> |
||
441 | |||
442 | <tr> |
||
443 | <td scope="row"> |
||
444 | <input type="checkbox" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $post_type->name ); ?>" |
||
445 | id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>" checked> |
||
446 | |||
447 | <label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>"> |
||
448 | <?php echo esc_html( $post_type->label ); ?> |
||
449 | </label> |
||
450 | </td> |
||
451 | </tr> |
||
452 | |||
453 | <?php endforeach; ?> |
||
454 | <?php |
||
455 | } |
||
456 | |||
457 | /** |
||
458 | * Render the "private post" setting fields. |
||
459 | */ |
||
460 | protected function render_private_post_settings() { |
||
461 | bd_render_private_post_settings( $this->field_slug ); |
||
462 | } |
||
463 | |||
464 | /** |
||
465 | * Get the threshold after which enhanced select should be used. |
||
466 | * |
||
467 | * @return int Threshold. |
||
468 | */ |
||
469 | protected function get_enhanced_select_threshold() { |
||
478 | } |
||
479 | |||
480 | /** |
||
481 | * Render sticky settings. |
||
482 | */ |
||
483 | protected function render_sticky_action_settings() { |
||
484 | ?> |
||
485 | <tr> |
||
486 | <td scope="row" colspan="2"> |
||
487 | <label> |
||
488 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="unsticky" type="radio" checked> |
||
489 | <?php _e( 'Remove Sticky', 'bulk-delete' ); ?> |
||
490 | </label> |
||
491 | <label> |
||
492 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="delete" type="radio"> |
||
493 | <?php _e( 'Delete Post', 'bulk-delete' ); ?> |
||
494 | </label> |
||
495 | </td> |
||
496 | </tr> |
||
497 | <?php |
||
498 | } |
||
499 | |||
500 | /** |
||
501 | * Render filtering table header. |
||
502 | */ |
||
503 | protected function render_filtering_table_header() { |
||
504 | bd_render_filtering_table_header(); |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * Render restrict settings. |
||
509 | */ |
||
510 | protected function render_restrict_settings() { |
||
511 | bd_render_restrict_settings( $this->field_slug, $this->item_type ); |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * Render delete settings. |
||
516 | */ |
||
517 | protected function render_delete_settings() { |
||
518 | bd_render_delete_settings( $this->field_slug ); |
||
519 | /** |
||
520 | * This action is primarily for adding delete attachment settings. |
||
521 | * |
||
522 | * @since 6.0.0 |
||
523 | * |
||
524 | * @param \BulkWP\BulkDelete\Core\Base\BaseModule The delete module. |
||
525 | */ |
||
526 | do_action( 'bd_render_attachment_settings', $this ); |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * Render limit settings. |
||
531 | * |
||
532 | * @param string $item_type Item Type to be displayed in label. |
||
533 | */ |
||
534 | protected function render_limit_settings( $item_type = '' ) { |
||
535 | if ( empty( $item_type ) ) { |
||
536 | $item_type = $this->item_type; |
||
537 | } |
||
538 | bd_render_limit_settings( $this->field_slug, $item_type ); |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * Render cron settings based on whether scheduler is present or not. |
||
543 | */ |
||
544 | protected function render_cron_settings() { |
||
545 | $pro_class = ''; |
||
546 | |||
547 | $disabled_attr = 'disabled'; |
||
548 | if ( empty( $this->scheduler_url ) ) { |
||
549 | $disabled_attr = ''; |
||
550 | } |
||
551 | ?> |
||
552 | |||
553 | <tr> |
||
554 | <td scope="row" colspan="2"> |
||
555 | <label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="false" type="radio" |
||
556 | checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?></label> |
||
557 | <label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="true" type="radio" |
||
558 | id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" <?php echo esc_attr( $disabled_attr ); ?>> <?php _e( 'Schedule', 'bulk-delete' ); ?></label> |
||
559 | <input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" |
||
560 | id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value="now" |
||
561 | type="text" <?php echo esc_attr( $disabled_attr ); ?> autocomplete="off"><?php _e( 'repeat ', 'bulk-delete' ); ?> |
||
562 | |||
563 | <select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" |
||
564 | id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" <?php echo esc_attr( $disabled_attr ); ?>> |
||
565 | |||
566 | <option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option> |
||
567 | <?php |
||
568 | /** |
||
569 | * List of cron schedules. |
||
570 | * |
||
571 | * @since 6.0.0 |
||
572 | * |
||
573 | * @param array $cron_schedules List of cron schedules. |
||
574 | * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
||
575 | */ |
||
576 | $cron_schedules = apply_filters( 'bd_cron_schedules', wp_get_schedules(), $this ); |
||
577 | ?> |
||
578 | |||
579 | <?php foreach ( $cron_schedules as $key => $value ) : ?> |
||
580 | <option |
||
581 | value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['display'] ); ?></option> |
||
582 | <?php endforeach; ?> |
||
583 | </select> |
||
584 | |||
585 | <?php if ( ! empty( $this->scheduler_url ) ) : ?> |
||
586 | <?php |
||
587 | $pro_class = 'bd-' . str_replace( '_', '-', $this->field_slug ) . '-pro'; |
||
588 | |||
589 | /** |
||
590 | * HTML class of the span that displays the 'Pro only feature' message. |
||
591 | * |
||
592 | * @since 6.0.0 |
||
593 | * |
||
594 | * @param string $pro_class HTML class. |
||
595 | * @param string $field_slug Field Slug of module. |
||
596 | * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module Module. |
||
597 | */ |
||
598 | $pro_class = apply_filters( 'bd_pro_only_feature_class', $pro_class, $this->field_slug, $this ) |
||
599 | ?> |
||
600 | |||
601 | <span class="<?php echo sanitize_html_class( $pro_class ); ?>" style="color:red"> |
||
602 | <?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a |
||
603 | href="<?php echo esc_url( $this->scheduler_url ); ?>">Buy now</a> |
||
604 | </span> |
||
605 | <?php endif; ?> |
||
606 | </td> |
||
607 | </tr> |
||
608 | |||
609 | <tr |
||
610 | <?php if ( ! empty( $pro_class ) ) : ?> |
||
611 | class="<?php echo sanitize_html_class( $pro_class ); ?>" style="display: none;" |
||
612 | <?php endif; ?> |
||
613 | > |
||
614 | |||
615 | <td scope="row" colspan="2"> |
||
616 | <?php |
||
617 | _e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time.', 'bulk-delete' ); |
||
618 | |||
619 | $markup = __( 'Want to add new a Cron schedule?', 'bulk-delete' ) . ' ' . |
||
620 | '<a href="https://bulkwp.com/docs/add-a-new-cron-schedule/" target="_blank" rel="noopener">' . __( 'Find out how', 'bulk-delete' ) . '</a>'; |
||
621 | |||
622 | $content = __( 'Learn how to add your desired Cron schedule.', 'bulk-delete' ); |
||
623 | echo ' ', bd_generate_help_tooltip( $markup, $content ); |
||
624 | ?> |
||
625 | </td> |
||
626 | </tr> |
||
627 | <?php |
||
628 | } |
||
629 | |||
630 | /** |
||
631 | * Render submit button. |
||
632 | */ |
||
633 | protected function render_submit_button() { |
||
635 | } |
||
636 | } |
||
637 |