Passed
Pull Request — dev/6.0.0 (#575)
by
unknown
28:51 queued 13:49
created

Renderer   B

Complexity

Total Complexity 50

Size/Duplication

Total Lines 576
Duplicated Lines 0 %

Test Coverage

Coverage 5.93%

Importance

Changes 0
Metric Value
eloc 321
dl 0
loc 576
ccs 7
cts 118
cp 0.0593
rs 8.4
c 0
b 0
f 0
wmc 50

27 Methods

Rating   Name   Duplication   Size   Complexity  
A render_user_role_dropdown() 0 13 2
A render_post_type_as_radios() 0 20 2
A render_post_type_dropdown() 0 2 1
A render_post_type_with_status() 0 14 3
A render_string_comparison_operators() 0 9 1
A split_post_type_and_status() 0 14 2
A render_category_dropdown() 0 18 2
A render_number_comparison_operators() 0 7 1
A render_post_status() 0 16 3
A render_taxonomy_dropdown() 0 11 2
A get_enhanced_select_threshold() 0 9 1
A render_data_types_dropdown() 0 6 1
A render_tags_dropdown() 0 18 2
A render_sticky_posts_dropdown() 0 32 3
A enable_ajax_if_needed_to_dropdown_class_name() 0 6 2
A render_private_post_settings() 0 2 1
A render_filtering_table_header() 0 2 1
A render_delete_settings() 0 10 1
A render_post_type_checkboxes() 0 19 2
A render_exclude_sticky_settings() 0 12 2
A render_restrict_settings() 0 2 1
A render_sticky_action_settings() 0 12 1
A render_submit_button() 0 2 1
A render_limit_settings() 0 5 2
A render_cron_settings() 0 77 4
A render_numeric_operators_dropdown() 0 26 3
A render_string_operators_dropdown() 0 22 3

How to fix   Complexity   

Complex Class

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
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" data-placeholder="Select Post Type" 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 user role dropdown.
121
	 */
122
	protected function render_user_role_dropdown() {
123
		global $wp_roles;
124
		?>
125
126
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown"
127
				multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>">
128
129
			<?php foreach ( $wp_roles->roles as $role => $role_details ) : ?>
130
				<option value="<?php echo esc_attr( $role ); ?>">
131
					<?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?>
132
				</option>
133
			<?php endforeach; ?>
134
		</select>
135
136
		<?php
137
	}
138
139
	/**
140
	 * Render Post type dropdown.
141
	 */
142
	protected function render_post_type_dropdown() {
143
		bd_render_post_type_dropdown( $this->field_slug );
144
	}
145
146
	/**
147
	 * Render Taxonomy dropdown.
148
	 */
149
	protected function render_taxonomy_dropdown() {
150
		$taxonomies = get_taxonomies( array(), 'objects' );
151
		?>
152
153
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy" class="enhanced-taxonomy-list" data-placeholder="<?php _e( 'Select Taxonomy', 'bulk-delete' ); ?>">
154
			<?php foreach ( $taxonomies as $taxonomy ) : ?>
155
				<option value="<?php echo esc_attr( $taxonomy->name ); ?>">
156
					<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?>
157
				</option>
158
			<?php endforeach; ?>
159
		</select>
160
		<?php
161
	}
162
163
	/**
164
	 * Render Category dropdown.
165
	 */
166
	protected function render_category_dropdown() {
167
		$categories = $this->get_categories();
168
		?>
169
170
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>"
171
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>"
172
				data-taxonomy="category" multiple>
173
174
			<option value="all">
175
				<?php _e( 'All Categories', 'bulk-delete' ); ?>
176
			</option>
177
178
			<?php foreach ( $categories as $category ) : ?>
179
				<option value="<?php echo absint( $category->cat_ID ); ?>">
180
					<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
181
				</option>
182
			<?php endforeach; ?>
183
184
		</select>
185
		<?php
186
	}
187
188
	/**
189
	 * Render String based comparison operators dropdown.
190
	 */
191
	protected function render_string_comparison_operators() {
192
		?>
193
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
194
			<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option>
195
			<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
196
			<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option>
197
			<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option>
198
			<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option>
199
			<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option>
200
		</select>
201
		<?php
202
	}
203
204
	/**
205
	 * Render number based comparison operators dropdown.
206
	 */
207
	protected function render_number_comparison_operators() {
208
		?>
209
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
210
			<option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option>
211
			<option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
212
			<option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option>
213
			<option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option>
214
		</select>
215
		<?php
216
	}
217
218
	/**
219
	 * Render data types dropdown.
220
	 */
221
	protected function render_data_types_dropdown() {
222
		?>
223
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type">
224
			<option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option>
225
			<option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option>
226
			<option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option>
227
		</select>
228
		<?php
229
	}
230
	/**
231
	 * Render numeric comparison operators dropdown.
232
	 *
233
	 * @param string $class     Class to be applied.
234
	 * @param array  $operators List of Operators needed.
235
	 */
236
	protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) {
237
		$all_numeric_operators = array(
238
			'='           => 'equal to',
239
			'!='          => 'not equal to',
240
			'<'           => 'less than',
241
			'<='          => 'less than or equal to',
242
			'>'           => 'greater than',
243
			'>='          => 'greater than or equal to',
244
			'IN'          => 'In',
245
			'NOT IN'      => 'Not In',
246
			'BETWEEN'     => 'Between',
247
			'NOT BETWEEN' => 'Not Between',
248
			'EXISTS'      => 'Exists',
249
			'NOT EXISTS'  => 'Not Exists',
250
		);
251
		if ( in_array( 'all', $operators, true ) ) {
252
			$operators = array_keys( $all_numeric_operators );
253
		}
254
		?>
255
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>">
256
		<?php
257
		foreach ( $operators as $operator ) {
258
			echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>';
259
		}
260
		?>
261
		</select>
262
		<?php
263
	}
264
	/**
265
	 * Render string comparison operators dropdown.
266
	 *
267
	 * @param string $class     Class to be applied.
268
	 * @param array  $operators List of Operators needed.
269
	 */
270
	protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) {
271
		$all_string_operators = array(
272
			'='          => 'equal to',
273
			'!='         => 'not equal to',
274
			'IN'         => 'In',
275
			'NOT IN'     => 'Not In',
276
			'LIKE'       => 'Like',
277
			'NOT LIKE'   => 'Not Like',
278
			'EXISTS'     => 'Exists',
279
			'NOT EXISTS' => 'Not Exists',
280
		);
281
		if ( in_array( 'all', $operators, true ) ) {
282
			$operators = array_keys( $all_string_operators );
283
		}
284
		?>
285
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>">
286
		<?php
287
		foreach ( $operators as $operator ) {
288
			echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>';
289
		}
290
		?>
291
		</select>
292
		<?php
293
	}
294
295
	/**
296
	 * Render Tags dropdown.
297
	 */
298
	protected function render_tags_dropdown() {
299
		$tags = $this->get_tags();
300
		?>
301
302
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>"
303
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>"
304
				data-taxonomy="post_tag" multiple>
305
306
			<option value="all">
307
				<?php _e( 'All Tags', 'bulk-delete' ); ?>
308
			</option>
309
310
			<?php foreach ( $tags as $tag ) : ?>
311
				<option value="<?php echo absint( $tag->term_id ); ?>">
312
					<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
313
				</option>
314
			<?php endforeach; ?>
315
		</select>
316
		<?php
317
	}
318
319
	/**
320
	 * Get the class name for select2 dropdown based on the number of items present.
321
	 *
322
	 * @param int    $count      The number of items present.
323
	 * @param string $class_name Primary class name.
324
	 *
325
	 * @return string Class name.
326
	 */
327
	protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) {
328
		if ( $count >= $this->get_enhanced_select_threshold() ) {
329
			$class_name .= '-ajax';
330
		}
331
332
		return $class_name;
333
	}
334
335
	/**
336
	 * Render Sticky Posts dropdown.
337
	 */
338
	protected function render_sticky_posts_dropdown() {
339
		$sticky_posts = $this->get_sticky_posts();
340
		?>
341
342
		<table class="optiontable">
343
			<?php if ( count( $sticky_posts ) > 1 ) : ?>
344
				<tr>
345
					<td scope="row">
346
						<label>
347
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all">
348
							<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
349
						</label>
350
					</td>
351
				</tr>
352
			<?php endif; ?>
353
354
			<?php foreach ( $sticky_posts as $post ) : ?>
355
				<?php $author = get_userdata( $post->post_author ); ?>
356
				<tr>
357
					<td scope="row">
358
						<label>
359
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>">
360
							<?php
361
								echo esc_html( $post->post_title ), ' - ',
362
									__( 'Published on', 'bulk-delete' ), ' ', get_the_date( get_option( 'date_format' ), $post->ID ),
0 ignored issues
show
Bug introduced by
Are you sure get_the_date(get_option(...te_format'), $post->ID) of type false|string can be used in echo? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

362
									__( 'Published on', 'bulk-delete' ), ' ', /** @scrutinizer ignore-type */ get_the_date( get_option( 'date_format' ), $post->ID ),
Loading history...
Bug introduced by
It seems like get_option('date_format') can also be of type false; however, parameter $d of get_the_date() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

362
									__( 'Published on', 'bulk-delete' ), ' ', get_the_date( /** @scrutinizer ignore-type */ get_option( 'date_format' ), $post->ID ),
Loading history...
363
									__( ' by ', 'bulk-delete' ), esc_html( $author->display_name );
364
							?>
365
						</label>
366
					</td>
367
				</tr>
368
			<?php endforeach; ?>
369
		</table>
370
		<?php
371
	}
372
373
	/**
374
	 * Renders exclude sticky posts checkbox.
375
	 */
376
	protected function render_exclude_sticky_settings() {
377
		if ( $this->are_sticky_posts_present() ) : // phpcs:ignore?>
378
		<tr>
379
			<td scope="row">
380
				<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">
381
			</td>
382
			<td>
383
				<label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky"><?php _e( 'Exclude sticky posts', 'bulk-delete' ); ?></label>
384
			</td>
385
		</tr>
386
		<?php endif; // phpcs:ignore?>
387
		<?php
388
	}
389
390
	/**
391
	 * Render Post Types as checkboxes.
392
	 *
393
	 * @since 5.6.0
394
	 *
395
	 * @param string $name Name of post type checkboxes.
396
	 */
397
	protected function render_post_type_checkboxes( $name ) {
398
		$post_types = bd_get_post_types();
399
		?>
400
401
		<?php foreach ( $post_types as $post_type ) : ?>
402
403
		<tr>
404
			<td scope="row">
405
				<input type="checkbox" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $post_type->name ); ?>"
406
					id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>" checked>
407
408
				<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>">
409
					<?php echo esc_html( $post_type->label ); ?>
410
				</label>
411
			</td>
412
		</tr>
413
414
		<?php endforeach; ?>
415
		<?php
416
	}
417
418
	/**
419
	 * Render the "private post" setting fields.
420
	 */
421
	protected function render_private_post_settings() {
422
		bd_render_private_post_settings( $this->field_slug );
423
	}
424
425
	/**
426
	 * Get the threshold after which enhanced select should be used.
427
	 *
428
	 * @return int Threshold.
429
	 */
430
	protected function get_enhanced_select_threshold() {
431
		/**
432
		 * Filter the enhanced select threshold.
433
		 *
434
		 * @since 6.0.0
435
		 *
436
		 * @param int Threshold.
437
		 */
438
		return apply_filters( 'bd_enhanced_select_threshold', 1000 );
439
	}
440
441
	/**
442
	 * Render sticky settings.
443
	 */
444
	protected function render_sticky_action_settings() {
445
		?>
446
		<tr>
447
			<td scope="row" colspan="2">
448
				<label>
449
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="unsticky" type="radio" checked>
450
					<?php _e( 'Remove Sticky', 'bulk-delete' ); ?>
451
				</label>
452
				<label>
453
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="delete" type="radio">
454
					<?php _e( 'Delete Post', 'bulk-delete' ); ?>
455
				</label>
456
			</td>
457
		</tr>
458
		<?php
459
	}
460
461
	/**
462
	 * Render filtering table header.
463
	 */
464
	protected function render_filtering_table_header() {
465
		bd_render_filtering_table_header();
466
	}
467
468
	/**
469
	 * Render restrict settings.
470
	 */
471
	protected function render_restrict_settings() {
472
		bd_render_restrict_settings( $this->field_slug, $this->item_type );
473
	}
474
475
	/**
476
	 * Render delete settings.
477
	 */
478
	protected function render_delete_settings() {
479
		bd_render_delete_settings( $this->field_slug );
480
		/**
481
		 * This action is primarily for adding delete attachment settings.
482
		 *
483
		 * @since 6.0.0
484
		 *
485
		 * @param \BulkWP\BulkDelete\Core\Base\BaseModule The delete module.
486
		 */
487
		do_action( 'bd_render_attachment_settings', $this );
488
	}
489
490
	/**
491
	 * Render limit settings.
492
	 *
493
	 * @param string $item_type Item Type to be displayed in label.
494
	 */
495
	protected function render_limit_settings( $item_type = '' ) {
496
		if ( empty( $item_type ) ) {
497
			$item_type = $this->item_type;
498
		}
499
		bd_render_limit_settings( $this->field_slug, $item_type );
500
	}
501
502
	/**
503
	 * Render cron settings based on whether scheduler is present or not.
504
	 */
505
	protected function render_cron_settings() {
506
		$pro_class = '';
507
508
		$disabled_attr = 'disabled';
509
		if ( empty( $this->scheduler_url ) ) {
510
			$disabled_attr = '';
511
		}
512
		?>
513
514
		<tr>
515
			<td scope="row" colspan="2">
516
				<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="false" type="radio"
517
					checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?></label>
518
				<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="true" type="radio"
519
					id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" <?php echo esc_attr( $disabled_attr ); ?>> <?php _e( 'Schedule', 'bulk-delete' ); ?></label>
520
				<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start"
521
					id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value="now"
522
					type="text" <?php echo esc_attr( $disabled_attr ); ?>><?php _e( 'repeat ', 'bulk-delete' ); ?>
523
524
				<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq"
525
						id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" <?php echo esc_attr( $disabled_attr ); ?>>
526
527
					<option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option>
528
					<?php
529
					/**
530
					 * List of cron schedules.
531
					 *
532
					 * @since 6.0.0
533
					 *
534
					 * @param array                                   $cron_schedules List of cron schedules.
535
					 * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module         Module.
536
					 */
537
					$cron_schedules = apply_filters( 'bd_cron_schedules', wp_get_schedules(), $this );
538
					?>
539
540
					<?php foreach ( $cron_schedules as $key => $value ) : ?>
541
						<option
542
							value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['display'] ); ?></option>
543
					<?php endforeach; ?>
544
				</select>
545
546
				<?php if ( ! empty( $this->scheduler_url ) ) : ?>
547
					<?php
548
					$pro_class = 'bd-' . str_replace( '_', '-', $this->field_slug ) . '-pro';
549
550
					/**
551
					 * HTML class of the span that displays the 'Pro only feature' message.
552
					 *
553
					 * @since 6.0.0
554
					 *
555
					 * @param string                                  $pro_class  HTML class.
556
					 * @param string                                  $field_slug Field Slug of module.
557
					 * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module     Module.
558
					 */
559
					$pro_class = apply_filters( 'bd_pro_only_feature_class', $pro_class, $this->field_slug, $this )
560
					?>
561
562
					<span class="<?php echo sanitize_html_class( $pro_class ); ?>" style="color:red">
563
						<?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a
564
							href="<?php echo esc_url( $this->scheduler_url ); ?>">Buy now</a>
565
					</span>
566
				<?php endif; ?>
567
			</td>
568
		</tr>
569
570
		<tr class="<?php echo sanitize_html_class( $pro_class ); ?>" style="display: none;">
571
			<td scope="row" colspan="2">
572
				<?php
573
				_e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time.', 'bulk-delete' );
574
575
				$markup = __( 'Want to add new a Cron schedule?', 'bulk-delete' ) . '&nbsp' .
576
					'<a href="https://bulkwp.com/docs/add-a-new-cron-schedule/" target="_blank" rel="noopener">' . __( 'Find out how', 'bulk-delete' ) . '</a>';
577
578
				$content = __( 'Learn how to add your desired Cron schedule.', 'bulk-delete' );
579
				echo '&nbsp', bd_generate_help_tooltip( $markup, $content );
580
				?>
581
			</td>
582
		</tr>
583
		<?php
584
	}
585
586
	/**
587
	 * Render submit button.
588
	 */
589
	protected function render_submit_button() {
590
		bd_render_submit_button( $this->action );
591
	}
592
}
593