Passed
Push — 672-feature/user-removal-in-su... ( 947941 )
by
unknown
05:27
created

Renderer::render_sticky_action_settings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
ccs 0
cts 4
cp 0
crap 2
rs 9.7998
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
				<optgroup label="<?php esc_attr_e( 'Custom Taxonomies', 'bulk-delete' ); ?>">
229
					<?php foreach ( $custom_taxonomies as $taxonomy ) : ?>
230
						<option value="<?php echo esc_attr( $taxonomy->name ); ?>">
231
							<?php echo esc_html( $taxonomy->label . ' (' . $taxonomy->name . ')' ); ?>
232
						</option>
233
					<?php endforeach; ?>
234
				</optgroup>
235
			</select>
236
		<?php
237
	}
238
239
	/**
240
	 * Render Category dropdown.
241
	 */
242
	protected function render_category_dropdown() {
243
		$categories = $this->get_categories();
244
		?>
245
246
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_category[]" data-placeholder="<?php _e( 'Select Categories', 'bulk-delete' ); ?>"
247
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $categories ), 'select2-taxonomy' ) ); ?>"
248
				data-taxonomy="category" multiple>
249
250
			<option value="all">
251
				<?php _e( 'All Categories', 'bulk-delete' ); ?>
252
			</option>
253
254
			<?php foreach ( $categories as $category ) : ?>
255
				<option value="<?php echo absint( $category->cat_ID ); ?>">
256
					<?php echo esc_html( $category->cat_name ), ' (', absint( $category->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
257
				</option>
258
			<?php endforeach; ?>
259
260
		</select>
261
		<?php
262
	}
263
264
	/**
265
	 * Render String based comparison operators dropdown.
266
	 */
267
	protected function render_string_comparison_operators() {
268
		?>
269
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
270
			<option value="equal_to"><?php _e( 'equal to', 'bulk-delete' ); ?></option>
271
			<option value="not_equal_to"><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
272
			<option value="starts_with"><?php _e( 'starts with', 'bulk-delete' ); ?></option>
273
			<option value="ends_with"><?php _e( 'ends with', 'bulk-delete' ); ?></option>
274
			<option value="contains"><?php _e( 'contains', 'bulk-delete' ); ?></option>
275
			<option value="not_contains"><?php _e( 'not contains', 'bulk-delete' ); ?></option>
276
		</select>
277
		<?php
278
	}
279
280
	/**
281
	 * Render number based comparison operators dropdown.
282
	 */
283
	protected function render_number_comparison_operators() {
284
		?>
285
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator">
286
			<option value="="><?php _e( 'equal to', 'bulk-delete' ); ?></option>
287
			<option value="!="><?php _e( 'not equal to', 'bulk-delete' ); ?></option>
288
			<option value="<"><?php _e( 'less than', 'bulk-delete' ); ?></option>
289
			<option value=">"><?php _e( 'greater than', 'bulk-delete' ); ?></option>
290
		</select>
291
		<?php
292
	}
293
294
	/**
295
	 * Render data types dropdown.
296
	 */
297
	protected function render_data_types_dropdown() {
298
		?>
299
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_type" class="meta-type">
300
			<option value="numeric"><?php _e( 'Number', 'bulk-delete' ); ?></option>
301
			<option value="string"><?php _e( 'Character', 'bulk-delete' ); ?></option>
302
			<option value="date"><?php _e( 'Date', 'bulk-delete' ); ?></option>
303
		</select>
304
		<?php
305
	}
306
	/**
307
	 * Render numeric comparison operators dropdown.
308
	 *
309
	 * @param string $class     Class to be applied.
310
	 * @param array  $operators List of Operators needed.
311
	 */
312
	protected function render_numeric_operators_dropdown( $class = 'numeric', $operators = array( 'all' ) ) {
313
		$all_numeric_operators = array(
314
			'='           => 'equal to',
315
			'!='          => 'not equal to',
316
			'<'           => 'less than',
317
			'<='          => 'less than or equal to',
318
			'>'           => 'greater than',
319
			'>='          => 'greater than or equal to',
320
			'IN'          => 'in',
321
			'NOT IN'      => 'not in',
322
			'BETWEEN'     => 'between',
323
			'NOT BETWEEN' => 'not between',
324
			'EXISTS'      => 'exists',
325
			'NOT EXISTS'  => 'not exists',
326
		);
327
		if ( in_array( 'all', $operators, true ) ) {
328
			$operators = array_keys( $all_numeric_operators );
329
		}
330
		?>
331
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class= "<?php echo esc_attr( $class ); ?>">
332
		<?php
333
		foreach ( $operators as $operator ) {
334
			echo '<option value="' . $operator . '">' . __( $all_numeric_operators[ $operator ], 'bulk-delete' ) . '</option>';
335
		}
336
		?>
337
		</select>
338
		<?php
339
	}
340
	/**
341
	 * Render string comparison operators dropdown.
342
	 *
343
	 * @param string $class     Class to be applied.
344
	 * @param array  $operators List of Operators needed.
345
	 */
346
	protected function render_string_operators_dropdown( $class = 'string', $operators = array( 'all' ) ) {
347
		// STARTS_WITH and ENDS_WITH operators needs a handler as SQL does not support these operators in queries.
348
		$all_string_operators = array(
349
			'='           => 'equal to',
350
			'!='          => 'not equal to',
351
			'IN'          => 'in',
352
			'NOT IN'      => 'not in',
353
			'LIKE'        => 'contains',
354
			'NOT LIKE'    => 'not contains',
355
			'EXISTS'      => 'exists',
356
			'NOT EXISTS'  => 'not exists',
357
			'STARTS_WITH' => 'starts with',
358
			'ENDS_WITH'   => 'ends with',
359
		);
360
		if ( in_array( 'all', $operators, true ) ) {
361
			$operators = array_keys( $all_string_operators );
362
		}
363
		?>
364
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>_operator" class="<?php echo esc_attr( $class ); ?>">
365
		<?php
366
		foreach ( $operators as $operator ) {
367
			echo '<option value="' . $operator . '">' . __( $all_string_operators[ $operator ], 'bulk-delete' ) . '</option>';
368
		}
369
		?>
370
		</select>
371
		<?php
372
	}
373
374
	/**
375
	 * Render Tags dropdown.
376
	 */
377
	protected function render_tags_dropdown() {
378
		$tags = $this->get_tags();
379
		?>
380
381
		<select name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" data-placeholder="<?php _e( 'Select Tags', 'bulk-delete' ); ?>"
382
				class="<?php echo sanitize_html_class( $this->enable_ajax_if_needed_to_dropdown_class_name( count( $tags ), 'select2-taxonomy' ) ); ?>"
383
				data-taxonomy="post_tag" multiple>
384
385
			<option value="all">
386
				<?php _e( 'All Tags', 'bulk-delete' ); ?>
387
			</option>
388
389
			<?php foreach ( $tags as $tag ) : ?>
390
				<option value="<?php echo absint( $tag->term_id ); ?>">
391
					<?php echo esc_html( $tag->name ), ' (', absint( $tag->count ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
392
				</option>
393
			<?php endforeach; ?>
394
		</select>
395
		<?php
396
	}
397
398
	/**
399
	 * Get the class name for select2 dropdown based on the number of items present.
400
	 *
401
	 * @param int    $count      The number of items present.
402
	 * @param string $class_name Primary class name.
403
	 *
404
	 * @return string Class name.
405
	 */
406
	protected function enable_ajax_if_needed_to_dropdown_class_name( $count, $class_name ) {
407
		if ( $count >= $this->get_enhanced_select_threshold() ) {
408
			$class_name .= '-ajax';
409
		}
410
411
		return $class_name;
412
	}
413
414
	/**
415
	 * Render Sticky Posts dropdown.
416
	 */
417
	protected function render_sticky_posts_dropdown() {
418
		$sticky_posts = $this->get_sticky_posts();
419
		?>
420
421
		<table class="optiontable">
422
			<?php if ( count( $sticky_posts ) > 1 ) : ?>
423
				<tr>
424
					<td scope="row">
425
						<label>
426
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="all">
427
							<?php echo __( 'All sticky posts', 'bulk-delete' ), ' (', count( $sticky_posts ), ' ', __( 'Posts', 'bulk-delete' ), ')'; ?>
428
						</label>
429
					</td>
430
				</tr>
431
			<?php endif; ?>
432
433
			<?php foreach ( $sticky_posts as $post ) : ?>
434
				<?php $author = get_userdata( $post->post_author ); ?>
435
				<tr>
436
					<td scope="row">
437
						<label>
438
							<input type="checkbox" name="smbd_<?php echo esc_attr( $this->field_slug ); ?>[]" value="<?php echo absint( $post->ID ); ?>">
439
							<?php
440
								echo esc_html( $post->post_title ), ' - ',
441
									__( '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

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

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