Passed
Pull Request — dev/6.0.0 (#557)
by Sudar
02:56
created

Renderer::render_post_reassign_settings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 17
ccs 0
cts 5
cp 0
crap 2
rs 9.7333
c 0
b 0
f 0
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 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
					)
136
				);
137
				?>
138
			</td>
139
		</tr>
140
		<?php
141
	}
142
143
	/**
144
	 * Render user role dropdown.
145
	 *
146
	 * @param bool $show_users_with_no_roles Should users with no user roles be shown? Default false.
147
	 */
148
	protected function render_user_role_dropdown( $show_users_with_no_roles = false ) {
149
		$roles       = get_editable_roles();
150
		$users_count = count_users();
151
		?>
152
153
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown"
154
				multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>">
155
156
			<?php foreach ( $roles as $role => $role_details ) : ?>
157
				<option value="<?php echo esc_attr( $role ); ?>">
158
					<?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role, $users_count ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?>
159
				</option>
160
			<?php endforeach; ?>
161
162
			<?php if ( $show_users_with_no_roles ) : ?>
163
				<?php if ( isset( $users_count['avail_roles']['none'] ) && $users_count['avail_roles']['none'] > 0 ) : ?>
164
					<option value="none">
165
						<?php echo __( 'No role', 'bulk-delete' ), ' (', absint( $users_count['avail_roles']['none'] ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?>
166
					</option>
167
				<?php endif; ?>
168
			<?php endif; ?>
169
		</select>
170
171
		<?php
172
	}
173
174
	/**
175
	 * Render Post type dropdown.
176
	 */
177
	protected function render_post_type_dropdown() {
178
		bd_render_post_type_dropdown( $this->field_slug );
179
	}
180
181
	/**
182
	 * Render Taxonomy dropdown.
183
	 */
184
	protected function render_taxonomy_dropdown() {
185
		$taxonomies = get_taxonomies( array(), 'objects' );
186
		?>
187
188
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy" class="enhanced-taxonomy-list" data-placeholder="<?php _e( 'Select Taxonomy', 'bulk-delete' ); ?>">
189
			<?php foreach ( $taxonomies as $taxonomy ) : ?>
190
				<option value="<?php echo esc_attr( $taxonomy->name ); ?>">
191
					<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?>
192
				</option>
193
			<?php endforeach; ?>
194
		</select>
195
		<?php
196
	}
197
198
	/**
199
	 * Render Category dropdown.
200
	 */
201
	protected function render_category_dropdown() {
202
		$categories = $this->get_categories();
203
		?>
204
205
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>"
206
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>"
207
				data-taxonomy="category" multiple>
208
209
			<option value="all">
210
				<?php _e( 'All Categories', 'bulk-delete' ); ?>
211
			</option>
212
213
			<?php foreach ( $categories as $category ) : ?>
214
				<option value="<?php echo absint( $category->cat_ID ); ?>">
215
					<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
216
				</option>
217
			<?php endforeach; ?>
218
219
		</select>
220
		<?php
221
	}
222
223
	/**
224
	 * Render String based comparison operators dropdown.
225
	 */
226
	protected function render_string_comparison_operators() {
227
		?>
228
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
229
			<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option>
230
			<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
231
			<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option>
232
			<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option>
233
			<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option>
234
			<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option>
235
		</select>
236
		<?php
237
	}
238
239
	/**
240
	 * Render number based comparison operators dropdown.
241
	 */
242
	protected function render_number_comparison_operators() {
243
		?>
244
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
245
			<option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option>
246
			<option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
247
			<option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option>
248
			<option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option>
249
		</select>
250
		<?php
251
	}
252
253
	/**
254
	 * Render data types dropdown.
255
	 */
256
	protected function render_data_types_dropdown() {
257
		?>
258
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type">
259
			<option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option>
260
			<option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option>
261
			<option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option>
262
		</select>
263
		<?php
264
	}
265
	/**
266
	 * Render numeric comparison operators dropdown.
267
	 *
268
	 * @param string $class     Class to be applied.
269
	 * @param array  $operators List of Operators needed.
270
	 */
271
	protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) {
272
		$all_numeric_operators = array(
273
			'='           => 'equal to',
274
			'!='          => 'not equal to',
275
			'<'           => 'less than',
276
			'<='          => 'less than or equal to',
277
			'>'           => 'greater than',
278
			'>='          => 'greater than or equal to',
279
			'IN'          => 'In',
280
			'NOT IN'      => 'Not In',
281
			'BETWEEN'     => 'Between',
282
			'NOT BETWEEN' => 'Not Between',
283
			'EXISTS'      => 'Exists',
284
			'NOT EXISTS'  => 'Not Exists',
285
		);
286
		if ( in_array( 'all', $operators, true ) ) {
287
			$operators = array_keys( $all_numeric_operators );
288
		}
289
		?>
290
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>">
291
		<?php
292
		foreach ( $operators as $operator ) {
293
			echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>';
294
		}
295
		?>
296
		</select>
297
		<?php
298
	}
299
	/**
300
	 * Render string comparison operators dropdown.
301
	 *
302
	 * @param string $class     Class to be applied.
303
	 * @param array  $operators List of Operators needed.
304
	 */
305
	protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) {
306
		// STARTS_WITH and ENDS_WITH operators needs a handler as SQL does not support these operators in queries.
307
		$all_string_operators = array(
308
			'='           => 'Equal To',
309
			'!='          => 'Not Equal To',
310
			'IN'          => 'In',
311
			'NOT IN'      => 'Not In',
312
			'LIKE'        => 'Contains',
313
			'NOT LIKE'    => 'Not Contains',
314
			'EXISTS'      => 'Exists',
315
			'NOT EXISTS'  => 'Not Exists',
316
			'STARTS_WITH' => 'Starts With',
317
			'ENDS_WITH'   => 'Ends With',
318
		);
319
		if ( in_array( 'all', $operators, true ) ) {
320
			$operators = array_keys( $all_string_operators );
321
		}
322
		?>
323
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>">
324
		<?php
325
		foreach ( $operators as $operator ) {
326
			echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>';
327
		}
328
		?>
329
		</select>
330
		<?php
331
	}
332
333
	/**
334
	 * Render Tags dropdown.
335
	 */
336
	protected function render_tags_dropdown() {
337
		$tags = $this->get_tags();
338
		?>
339
340
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>"
341
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>"
342
				data-taxonomy="post_tag" multiple>
343
344
			<option value="all">
345
				<?php _e( 'All Tags', 'bulk-delete' ); ?>
346
			</option>
347
348
			<?php foreach ( $tags as $tag ) : ?>
349
				<option value="<?php echo absint( $tag->term_id ); ?>">
350
					<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
351
				</option>
352
			<?php endforeach; ?>
353
		</select>
354
		<?php
355
	}
356
357
	/**
358
	 * Get the class name for select2 dropdown based on the number of items present.
359
	 *
360
	 * @param int    $count      The number of items present.
361
	 * @param string $class_name Primary class name.
362
	 *
363
	 * @return string Class name.
364
	 */
365
	protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) {
366
		if ( $count >= $this->get_enhanced_select_threshold() ) {
367
			$class_name .= '-ajax';
368
		}
369
370
		return $class_name;
371
	}
372
373
	/**
374
	 * Render Sticky Posts dropdown.
375
	 */
376
	protected function render_sticky_posts_dropdown() {
377
		$sticky_posts = $this->get_sticky_posts();
378
		?>
379
380
		<table class="optiontable">
381
			<?php if ( count( $sticky_posts ) > 1 ) : ?>
382
				<tr>
383
					<td scope="row">
384
						<label>
385
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all">
386
							<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
387
						</label>
388
					</td>
389
				</tr>
390
			<?php endif; ?>
391
392
			<?php foreach ( $sticky_posts as $post ) : ?>
393
				<?php $author = get_userdata( $post->post_author ); ?>
394
				<tr>
395
					<td scope="row">
396
						<label>
397
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>">
398
							<?php
399
								echo esc_html( $post->post_title ), ' - ',
400
									__( 'Published on', 'bulk-delete' ), ' ', get_the_date( get_option( 'date_format' ), $post->ID ),
0 ignored issues
show
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

400
									__( 'Published on', 'bulk-delete' ), ' ', get_the_date( /** @scrutinizer ignore-type */ get_option( 'date_format' ), $post->ID ),
Loading history...
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

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