Completed
Push — 247-fix/delete-term-meta ( bfe6ea...f6166d )
by Sudar
10:13 queued 05:33
created

Renderer::render_taxonomy_dropdown()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 23
c 2
b 0
f 0
nc 4
nop 0
dl 0
loc 23
ccs 0
cts 8
cp 0
crap 20
rs 9.552
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
	 * @since 6.1.0 Added $class param.
27
	 *
28
	 * @param string $post_type The post type for which the post status should be displayed.
29
	 * @param string $class     Class to be applied.
30
	 */
31
	protected function render_post_status( $post_type = 'post', $class = 'validate' ) {
32
		$post_statuses = $this->get_post_statuses();
33
		$post_count    = wp_count_posts( $post_type );
34
35
		foreach ( $post_statuses as $post_status ) : ?>
36
			<tr>
37
				<td>
38
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" id="smbd_<?php echo esc_attr( $post_status->name ); ?>"
39
						value="<?php echo esc_attr( $post_status->name ); ?>" type="checkbox" class="<?php echo esc_attr( $class ); ?>">
40
41
					<label for="smbd_<?php echo esc_attr( $post_status->name ); ?>">
42
						<?php echo esc_html( $post_status->label ), ' '; ?>
43
						<?php if ( property_exists( $post_count, $post_status->name ) ) : ?>
44
							(<?php echo absint( $post_count->{ $post_status->name } ) . ' ', __( 'Posts', 'bulk-delete' ); ?>)
45
						<?php endif; ?>
46
					</label>
47
				</td>
48
			</tr>
49
		<?php endforeach;
50
	}
51
52
	/**
53
	 * Render Post Types as radio buttons.
54
	 */
55
	protected function render_post_type_as_radios() {
56
		$post_types = $this->get_post_types();
57
		?>
58
59
		<?php foreach ( $post_types as $post_type ) : ?>
60
61
			<tr>
62
				<td scope="row">
63
					<input type="radio" name="<?php echo esc_attr( $this->field_slug ); ?>_post_type"
64
						value="<?php echo esc_attr( $post_type->name ); ?>"
65
						id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>">
66
67
					<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>">
68
						<?php echo esc_html( $post_type->label ); ?>
69
					</label>
70
				</td>
71
			</tr>
72
73
		<?php endforeach; ?>
74
		<?php
75
	}
76
77
	/**
78
	 * Render Post type with status and post count checkboxes.
79
	 *
80
	 * @since 6.0.1 Added $multiple param.
81
	 * @since 6.1.0 Added $feature  param.
82
	 *
83
	 * @param bool   $multiple_select Whether multiple select should be supported. Default true.
84
	 * @param string $feature         Fetches only post types that supports feature. Default empty.
85
	 */
86
	protected function render_post_type_with_status( $multiple_select = true, $feature = '' ) {
87
		$post_types_by_status = $this->get_post_types_by_status( $feature );
88
89
		$name = 'smbd_' . $this->field_slug;
90
		if ( $multiple_select ) {
91
			$name .= '[]';
92
		}
93
		?>
94
95
		<tr>
96
			<td scope="row" colspan="2">
97
				<select data-placeholder="<?php esc_attr_e( 'Select Post Type', 'bulk-delete' ); ?>"
98
					name="<?php echo esc_attr( $name ); ?>" class="enhanced-post-types-with-status"
99
					<?php if ( $multiple_select ) : ?>
100
						multiple
101
					<?php endif; ?>
102
				>
103
104
				<?php foreach ( $post_types_by_status as $post_type => $all_status ) : ?>
105
					<optgroup label="<?php echo esc_html( $post_type ); ?>">
106
107
					<?php foreach ( $all_status as $status_key => $status_value ) : ?>
108
						<option value="<?php echo esc_attr( $status_key ); ?>">
109
							<?php echo esc_html( $status_value ); ?>
110
						</option>
111
					<?php endforeach; ?>
112
113
					</optgroup>
114
				<?php endforeach; ?>
115
116
				</select>
117
			</td>
118
		</tr>
119
		<?php
120
	}
121
122
	/**
123
	 * Split post type and status.
124
	 *
125
	 * @param string $str Post type and status combination.
126
	 *
127
	 * @return array Post type and status as elements of array.
128
	 */
129 25
	protected function split_post_type_and_status( $str ) {
130 25
		$type_status = array();
131
132 25
		if ( strpos( $str, '|' ) === false ) {
133 17
			$str_arr = explode( '-', $str );
134
		} else {
135 8
			$str_arr = explode( '|', $str );
136
		}
137
138 25
		if ( count( $str_arr ) > 1 ) {
139 17
			$type_status['status'] = end( $str_arr );
140 17
			$type_status['type']   = implode( '-', array_slice( $str_arr, 0, - 1 ) );
141
		} else {
142 8
			$type_status['status'] = 'publish';
143 8
			$type_status['type']   = $str;
144
		}
145
146 25
		return $type_status;
147
	}
148
149
	/**
150
	 * Render post reassign settings.
151
	 */
152
	protected function render_post_reassign_settings() {
153
		?>
154
		<tr>
155
			<td scope="row" colspan="2">
156
				<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="false" type="radio"
157
					checked="checked" class="post-reassign"> <?php _e( 'Also delete all posts of the users', 'bulk-delete' ); ?></label>
158
				<label><input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" value="true" type="radio"
159
					id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_post_reassign" class="post-reassign"> <?php _e( 'Re-assign the posts to', 'bulk-delete' ); ?></label>
160
				<?php
161
				wp_dropdown_users(
162
					array(
163
						'name'             => 'smbd_' . esc_attr( $this->field_slug ) . '_reassign_user_id',
164
						'class'            => 'reassign-user',
165
						'show_option_none' => __( 'Select User', 'bulk-delete' ),
166
					)
167
				);
168
				?>
169
			</td>
170
		</tr>
171
		<?php
172
	}
173
174
	/**
175
	 * Render user role dropdown.
176
	 *
177
	 * @param bool $show_users_with_no_roles Should users with no user roles be shown? Default false.
178
	 */
179
	protected function render_user_role_dropdown( $show_users_with_no_roles = false ) {
180
		$roles       = get_editable_roles();
181
		$users_count = count_users();
182
		?>
183
184
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_roles[]" class="enhanced-role-dropdown"
185
				multiple="multiple" data-placeholder="<?php _e( 'Select User Role', 'bulk-delete' ); ?>">
186
187
			<?php foreach ( $roles as $role => $role_details ) : ?>
188
				<option value="<?php echo esc_attr( $role ); ?>">
189
					<?php echo esc_html( $role_details['name'] ), ' (', absint( $this->get_user_count_by_role( $role, $users_count ) ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?>
190
				</option>
191
			<?php endforeach; ?>
192
193
			<?php if ( $show_users_with_no_roles ) : ?>
194
				<?php if ( isset( $users_count['avail_roles']['none'] ) && $users_count['avail_roles']['none'] > 0 ) : ?>
195
					<option value="none">
196
						<?php echo __( 'No role', 'bulk-delete' ), ' (', absint( $users_count['avail_roles']['none'] ), ' ', __( 'Users', 'bulk-delete' ), ')'; ?>
197
					</option>
198
				<?php endif; ?>
199
			<?php endif; ?>
200
		</select>
201
202
		<?php
203
	}
204
205
	/**
206
	 * Render Post type dropdown.
207
	 */
208
	protected function render_post_type_dropdown() {
209
		bd_render_post_type_dropdown( $this->field_slug );
210
	}
211
212
	/**
213
	 * Render Taxonomy dropdown.
214
	 */
215
	protected function render_taxonomy_dropdown() {
216
		$builtin_taxonomies = get_taxonomies( array( '_builtin' => true ), 'objects' );
217
		$custom_taxonomies  = get_taxonomies( array( '_builtin' => false ), 'objects' );
218
		?>
219
			<select class="enhanced-dropdown" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_taxonomy">
220
				<optgroup label="<?php esc_attr_e( 'Built-in Taxonomies', 'bulk-delete' ); ?>">
221
					<?php foreach ( $builtin_taxonomies as $taxonomy ) : ?>
222
						<option value="<?php echo esc_attr( $taxonomy->name ); ?>">
223
							<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?>
224
						</option>
225
					<?php endforeach; ?>
226
				</optgroup>
227
228
				<?php if ( ! empty( $custom_taxonomies ) ): ?>
229
					<optgroup label="<?php esc_attr_e( 'Custom Taxonomies', 'bulk-delete' ); ?>">
230
						<?php foreach ( $custom_taxonomies as $taxonomy ) : ?>
231
							<option value="<?php echo esc_attr( $taxonomy->name ); ?>">
232
								<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?>
233
							</option>
234
						<?php endforeach; ?>
235
					</optgroup>
236
				<?php endif; ?>
237
			</select>
238
		<?php
239
	}
240
241
	/**
242
	 * Render Category dropdown.
243
	 */
244
	protected function render_category_dropdown() {
245
		$categories = $this->get_categories();
246
		?>
247
248
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>"
249
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>"
250
				data-taxonomy="category" multiple>
251
252
			<option value="all">
253
				<?php _e( 'All Categories', 'bulk-delete' ); ?>
254
			</option>
255
256
			<?php foreach ( $categories as $category ) : ?>
257
				<option value="<?php echo absint( $category->cat_ID ); ?>">
258
					<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
259
				</option>
260
			<?php endforeach; ?>
261
262
		</select>
263
		<?php
264
	}
265
266
	/**
267
	 * Render String based comparison operators dropdown.
268
	 */
269
	protected function render_string_comparison_operators() {
270
		?>
271
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
272
			<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option>
273
			<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
274
			<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option>
275
			<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option>
276
			<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option>
277
			<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option>
278
		</select>
279
		<?php
280
	}
281
282
	/**
283
	 * Render number based comparison operators dropdown.
284
	 */
285
	protected function render_number_comparison_operators() {
286
		?>
287
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
288
			<option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option>
289
			<option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
290
			<option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option>
291
			<option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option>
292
		</select>
293
		<?php
294
	}
295
296
	/**
297
	 * Render data types dropdown.
298
	 */
299
	protected function render_data_types_dropdown() {
300
		?>
301
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type">
302
			<option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option>
303
			<option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option>
304
			<option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option>
305
		</select>
306
		<?php
307
	}
308
	/**
309
	 * Render numeric comparison operators dropdown.
310
	 *
311
	 * @param string $class     Class to be applied.
312
	 * @param array  $operators List of Operators needed.
313
	 */
314
	protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) {
315
		$all_numeric_operators = array(
316
			'='           => 'equal to',
317
			'!='          => 'not equal to',
318
			'<'           => 'less than',
319
			'<='          => 'less than or equal to',
320
			'>'           => 'greater than',
321
			'>='          => 'greater than or equal to',
322
			'IN'          => 'in',
323
			'NOT IN'      => 'not in',
324
			'BETWEEN'     => 'between',
325
			'NOT BETWEEN' => 'not between',
326
			'EXISTS'      => 'exists',
327
			'NOT EXISTS'  => 'not exists',
328
		);
329
		if ( in_array( 'all', $operators, true ) ) {
330
			$operators = array_keys( $all_numeric_operators );
331
		}
332
		?>
333
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>">
334
		<?php
335
		foreach ( $operators as $operator ) {
336
			echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>';
337
		}
338
		?>
339
		</select>
340
		<?php
341
	}
342
	/**
343
	 * Render string comparison operators dropdown.
344
	 *
345
	 * @param string $class     Class to be applied.
346
	 * @param array  $operators List of Operators needed.
347
	 */
348
	protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) {
349
		// STARTS_WITH and ENDS_WITH operators needs a handler as SQL does not support these operators in queries.
350
		$all_string_operators = array(
351
			'='           => 'equal to',
352
			'!='          => 'not equal to',
353
			'IN'          => 'in',
354
			'NOT IN'      => 'not in',
355
			'LIKE'        => 'contains',
356
			'NOT LIKE'    => 'not contains',
357
			'EXISTS'      => 'exists',
358
			'NOT EXISTS'  => 'not exists',
359
			'STARTS_WITH' => 'starts with',
360
			'ENDS_WITH'   => 'ends with',
361
		);
362
		if ( in_array( 'all', $operators, true ) ) {
363
			$operators = array_keys( $all_string_operators );
364
		}
365
		?>
366
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>">
367
		<?php
368
		foreach ( $operators as $operator ) {
369
			echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>';
370
		}
371
		?>
372
		</select>
373
		<?php
374
	}
375
376
	/**
377
	 * Render Tags dropdown.
378
	 */
379
	protected function render_tags_dropdown() {
380
		$tags = $this->get_tags();
381
		?>
382
383
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>"
384
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>"
385
				data-taxonomy="post_tag" multiple>
386
387
			<option value="all">
388
				<?php _e( 'All Tags', 'bulk-delete' ); ?>
389
			</option>
390
391
			<?php foreach ( $tags as $tag ) : ?>
392
				<option value="<?php echo absint( $tag->term_id ); ?>">
393
					<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
394
				</option>
395
			<?php endforeach; ?>
396
		</select>
397
		<?php
398
	}
399
400
	/**
401
	 * Get the class name for select2 dropdown based on the number of items present.
402
	 *
403
	 * @param int    $count      The number of items present.
404
	 * @param string $class_name Primary class name.
405
	 *
406
	 * @return string Class name.
407
	 */
408
	protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) {
409
		if ( $count >= $this->get_enhanced_select_threshold() ) {
410
			$class_name .= '-ajax';
411
		}
412
413
		return $class_name;
414
	}
415
416
	/**
417
	 * Render Sticky Posts dropdown.
418
	 */
419
	protected function render_sticky_posts_dropdown() {
420
		$sticky_posts = $this->get_sticky_posts();
421
		?>
422
423
		<table class="optiontable">
424
			<?php if ( count( $sticky_posts ) > 1 ) : ?>
425
				<tr>
426
					<td scope="row">
427
						<label>
428
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all">
429
							<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
430
						</label>
431
					</td>
432
				</tr>
433
			<?php endif; ?>
434
435
			<?php foreach ( $sticky_posts as $post ) : ?>
436
				<?php $author = get_userdata( $post->post_author ); ?>
437
				<tr>
438
					<td scope="row">
439
						<label>
440
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>">
441
							<?php
442
								echo esc_html( $post->post_title ), ' - ',
443
									__( '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

443
									__( '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

443
									__( 'Published on', 'bulk-delete' ), ' ', get_the_date( /** @scrutinizer ignore-type */ get_option( 'date_format' ), $post->ID ),
Loading history...
444
									__( ' by ', 'bulk-delete' ), esc_html( $author->display_name );
445
							?>
446
						</label>
447
					</td>
448
				</tr>
449
			<?php endforeach; ?>
450
		</table>
451
		<?php
452
	}
453
454
	/**
455
	 * Renders exclude sticky posts checkbox.
456
	 */
457
	protected function render_exclude_sticky_settings() {
458
		if ( $this->are_sticky_posts_present() ) : // phpcs:ignore?>
459
		<tr>
460
			<td scope="row">
461
				<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">
462
			</td>
463
			<td>
464
				<label for="smbd_<?php echo esc_attr( $this->field_slug ); ?>_exclude_sticky"><?php _e( 'Exclude sticky posts', 'bulk-delete' ); ?></label>
465
			</td>
466
		</tr>
467
		<?php endif; // phpcs:ignore?>
468
		<?php
469
	}
470
471
	/**
472
	 * Render Post Types as checkboxes.
473
	 *
474
	 * @since 5.6.0
475
	 *
476
	 * @param string $name Name of post type checkboxes.
477
	 */
478
	protected function render_post_type_checkboxes( $name ) {
479
		$post_types = bd_get_post_types();
480
		?>
481
482
		<?php foreach ( $post_types as $post_type ) : ?>
483
484
		<tr>
485
			<td scope="row">
486
				<input type="checkbox" name="<?php echo esc_attr( $name ); ?>[]" value="<?php echo esc_attr( $post_type->name ); ?>"
487
					id="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>" checked>
488
489
				<label for="smbd_post_type_<?php echo esc_html( $post_type->name ); ?>">
490
					<?php echo esc_html( $post_type->label ); ?>
491
				</label>
492
			</td>
493
		</tr>
494
495
		<?php endforeach; ?>
496
		<?php
497
	}
498
499
	/**
500
	 * Render the "private post" setting fields.
501
	 */
502
	protected function render_private_post_settings() {
503
		bd_render_private_post_settings( $this->field_slug );
504
	}
505
506
	/**
507
	 * Render sticky settings.
508
	 */
509
	protected function render_sticky_action_settings() {
510
		?>
511
		<tr>
512
			<td scope="row" colspan="2">
513
				<label>
514
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="unsticky" type="radio" checked>
515
					<?php _e( 'Remove Sticky', 'bulk-delete' ); ?>
516
				</label>
517
				<label>
518
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_sticky_action" value="delete" type="radio">
519
					<?php _e( 'Delete Post', 'bulk-delete' ); ?>
520
				</label>
521
			</td>
522
		</tr>
523
		<?php
524
	}
525
526
	/**
527
	 * Render filtering table header.
528
	 */
529
	protected function render_filtering_table_header() {
530
		bd_render_filtering_table_header();
531
	}
532
533
	/**
534
	 * Render restrict settings.
535
	 */
536
	protected function render_restrict_settings() {
537
		bd_render_restrict_settings( $this->field_slug, $this->item_type );
538
	}
539
540
	/**
541
	 * Render delete settings.
542
	 *
543
	 * @since 6.1.0 Added $hide_trash  param.
544
	 *
545
	 * @param bool $hide_trash Show/Hide Move to trash radio button. Default false.
546
	 */
547
	protected function render_delete_settings( $hide_trash = false ) {
548
		bd_render_delete_settings( $this->field_slug, $hide_trash );
549
		/**
550
		 * This action is primarily for adding delete attachment settings.
551
		 *
552
		 * @since 6.0.0
553
		 *
554
		 * @param \BulkWP\BulkDelete\Core\Base\BaseModule The delete module.
555
		 */
556
		do_action( 'bd_render_attachment_settings', $this );
557
	}
558
559
	/**
560
	 * Render limit settings.
561
	 *
562
	 * @param string $item_type Item Type to be displayed in label.
563
	 */
564
	protected function render_limit_settings( $item_type = '' ) {
565
		if ( empty( $item_type ) ) {
566
			$item_type = $this->item_type;
567
		}
568
		bd_render_limit_settings( $this->field_slug, $item_type );
569
	}
570
571
	/**
572
	 * Render cron settings based on whether scheduler is present or not.
573
	 */
574
	protected function render_cron_settings() {
575
		$pro_class = '';
576
577
		$disabled_attr = 'disabled';
578
		if ( empty( $this->scheduler_url ) ) {
579
			$disabled_attr = '';
580
		}
581
		?>
582
583
		<tr>
584
			<td scope="row" colspan="2">
585
				<label>
586
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="false" type="radio"
587
					checked="checked" class="schedule-deletion">
588
					<?php _e( 'Delete now', 'bulk-delete' ); ?>
589
				</label>
590
591
				<label>
592
					<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" value="true" type="radio"
593
					class="schedule-deletion" id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron" <?php echo esc_attr( $disabled_attr ); ?>>
594
					<?php _e( 'Schedule', 'bulk-delete' ); ?>
595
				</label>
596
597
				<input name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start"
598
					id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_start" value="now"
599
					type="text" <?php echo esc_attr( $disabled_attr ); ?> autocomplete="off"><?php _e( 'repeat ', 'bulk-delete' ); ?>
600
601
				<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq"
602
						id="smbd_<?php echo esc_attr( $this->field_slug ); ?>_cron_freq" <?php echo esc_attr( $disabled_attr ); ?>>
603
604
					<option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option>
605
					<?php
606
					/**
607
					 * List of cron schedules.
608
					 *
609
					 * @since 6.0.0
610
					 *
611
					 * @param array                                   $cron_schedules List of cron schedules.
612
					 * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module         Module.
613
					 */
614
					$cron_schedules = apply_filters( 'bd_cron_schedules', wp_get_schedules(), $this );
615
					?>
616
617
					<?php foreach ( $cron_schedules as $key => $value ) : ?>
618
						<option
619
							value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['display'] ); ?></option>
620
					<?php endforeach; ?>
621
				</select>
622
623
				<?php if ( ! empty( $this->scheduler_url ) ) : ?>
624
					<?php
625
					$pro_class = 'bd-' . str_replace( '_', '-', $this->field_slug ) . '-pro';
626
627
					/**
628
					 * HTML class of the span that displays the 'Pro only feature' message.
629
					 *
630
					 * @since 6.0.0
631
					 *
632
					 * @param string                                  $pro_class  HTML class.
633
					 * @param string                                  $field_slug Field Slug of module.
634
					 * @param \BulkWP\BulkDelete\Core\Base\BaseModule $module     Module.
635
					 */
636
					$pro_class = apply_filters( 'bd_pro_only_feature_class', $pro_class, $this->field_slug, $this )
637
					?>
638
639
					<span class="<?php echo sanitize_html_class( $pro_class ); ?>" style="color:red">
640
						<?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a
641
							href="<?php echo esc_url( $this->scheduler_url ); ?>" target="_blank">Buy now</a>
642
					</span>
643
				<?php endif; ?>
644
			</td>
645
		</tr>
646
647
		<tr
648
		<?php if ( ! empty( $pro_class ) ) : ?>
649
			class="<?php echo sanitize_html_class( $pro_class ); ?>" style="display: none;"
650
		<?php endif; ?>
651
		>
652
653
			<td scope="row" colspan="2">
654
				<?php
655
				_e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time.', 'bulk-delete' );
656
657
				$markup = __( 'Want to add new a Cron schedule?', 'bulk-delete' ) . '&nbsp' .
658
					'<a href="https://bulkwp.com/docs/add-a-new-cron-schedule/?utm_campaign=Docs&utm_medium=wpadmin&utm_source=tooltip&utm_content=cron-schedule" target="_blank" rel="noopener">' . __( 'Find out how', 'bulk-delete' ) . '</a>';
659
660
				$content = __( 'Learn how to add your desired Cron schedule.', 'bulk-delete' );
661
				echo '&nbsp', bd_generate_help_tooltip( $markup, $content );
662
				?>
663
			</td>
664
		</tr>
665
		<?php
666
	}
667
668
	/**
669
	 * Render submit button.
670
	 */
671
	protected function render_submit_button() {
672
		bd_render_submit_button( $this->action );
673
	}
674
}
675