1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Utility functions for displaying form. |
4
|
|
|
* |
5
|
|
|
* @since 5.5 |
6
|
|
|
* @author Sudar |
7
|
|
|
* @package BulkDelete\Ui |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Render filtering table header. |
14
|
|
|
* |
15
|
|
|
* @since 5.5 |
16
|
|
|
*/ |
17
|
|
|
function bd_render_filtering_table_header() { |
18
|
|
|
?> |
19
|
|
|
<tr> |
20
|
|
|
<td colspan="2"> |
21
|
|
|
<h4><?php _e( 'Choose your filtering options', 'bulk-delete' ); ?></h4> |
22
|
|
|
</td> |
23
|
|
|
</tr> |
24
|
|
|
<?php |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Render "restrict by created date" dropdown. |
29
|
|
|
* |
30
|
|
|
* @since 5.5 |
31
|
|
|
* @param string $slug The slug to be used in field names. |
32
|
|
|
* @param string $item (optional) Item for which form is displayed. Default is 'posts'. |
33
|
|
|
*/ |
34
|
|
|
function bd_render_restrict_settings( $slug, $item = 'posts' ) { |
35
|
|
|
?> |
36
|
|
|
<tr> |
37
|
|
|
<td scope="row"> |
38
|
|
|
<input name="smbd_<?php echo $slug; ?>_restrict" id="smbd_<?php echo $slug; ?>_restrict" value="true" type="checkbox"> |
39
|
|
|
</td> |
40
|
|
|
<td> |
41
|
|
|
<?php printf( __( 'Only restrict to %s which are ', 'bulk-delete' ), $item );?> |
42
|
|
|
<select name="smbd_<?php echo $slug; ?>_op" id="smbd_<?php echo $slug; ?>_op" disabled> |
43
|
|
|
<option value="before"><?php _e( 'older than', 'bulk-delete' );?></option> |
44
|
|
|
<option value="after"><?php _e( 'posted within last', 'bulk-delete' );?></option> |
45
|
|
|
</select> |
46
|
|
|
<input type="number" name="smbd_<?php echo $slug; ?>_days" id="smbd_<?php echo $slug; ?>_days" class="screen-per-page" disabled value="0" min="0"><?php _e( 'days', 'bulk-delete' );?> |
47
|
|
|
</td> |
48
|
|
|
</tr> |
49
|
|
|
<?php |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Render "force delete" setting fields. |
54
|
|
|
* |
55
|
|
|
* @since 5.5 |
56
|
|
|
* @param string $slug The slug to be used in field names. |
57
|
|
|
*/ |
58
|
|
|
function bd_render_delete_settings( $slug ) { |
59
|
|
|
?> |
60
|
|
|
<tr> |
61
|
|
|
<td scope="row" colspan="2"> |
62
|
|
|
<input name="smbd_<?php echo $slug; ?>_force_delete" value="false" type="radio" checked> <?php _e( 'Move to Trash', 'bulk-delete' ); ?> |
63
|
|
|
<input name="smbd_<?php echo $slug; ?>_force_delete" value="true" type="radio"> <?php _e( 'Delete permanently', 'bulk-delete' ); ?> |
64
|
|
|
</td> |
65
|
|
|
</tr> |
66
|
|
|
<?php |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Render the "private post" setting fields. |
71
|
|
|
* |
72
|
|
|
* @since 5.5 |
73
|
|
|
* @param string $slug The slug to be used in field names. |
74
|
|
|
*/ |
75
|
|
|
function bd_render_private_post_settings( $slug ) { |
76
|
|
|
?> |
77
|
|
|
<tr> |
78
|
|
|
<td scope="row" colspan="2"> |
79
|
|
|
<input name="smbd_<?php echo $slug; ?>_private" value="false" type="radio" checked> <?php _e( 'Public posts', 'bulk-delete' ); ?> |
80
|
|
|
<input name="smbd_<?php echo $slug; ?>_private" value="true" type="radio"> <?php _e( 'Private Posts', 'bulk-delete' ); ?> |
81
|
|
|
</td> |
82
|
|
|
</tr> |
83
|
|
|
<?php |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Render the "limit" setting fields. |
88
|
|
|
* |
89
|
|
|
* @since 5.5 |
90
|
|
|
* @param string $slug The slug to be used in field names. |
91
|
|
|
* @param string $item (Optional) Item type. Possible values are 'posts', 'pages', 'users' |
92
|
|
|
*/ |
93
|
|
|
function bd_render_limit_settings( $slug, $item = 'posts' ) { |
94
|
|
|
?> |
95
|
|
|
<tr> |
96
|
|
|
<td scope="row"> |
97
|
|
|
<input name="smbd_<?php echo $slug; ?>_limit" id="smbd_<?php echo $slug; ?>_limit" value="true" type="checkbox"> |
98
|
|
|
</td> |
99
|
|
|
<td> |
100
|
|
|
<?php _e( 'Only delete first ', 'bulk-delete' );?> |
101
|
|
|
<input type="number" name="smbd_<?php echo $slug; ?>_limit_to" id="smbd_<?php echo $slug; ?>_limit_to" class="screen-per-page" disabled value="0" min="0"> <?php echo $item;?>. |
102
|
|
|
<?php printf( __( 'Use this option if there are more than 1000 %s and the script timesout.', 'bulk-delete' ), $item ); ?> |
103
|
|
|
</td> |
104
|
|
|
</tr> |
105
|
|
|
<?php |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Render cron setting fields. |
110
|
|
|
* |
111
|
|
|
* @since 5.5 |
112
|
|
|
* @param string $slug The slug to be used in field names. |
113
|
|
|
* @param string $addon_url Url for the pro addon. |
114
|
|
|
*/ |
115
|
|
|
function bd_render_cron_settings( $slug, $addon_url ) { |
116
|
|
|
$pro_class = 'bd-' . str_replace( '_', '-', $slug ) . '-pro'; |
117
|
|
|
?> |
118
|
|
|
<tr> |
119
|
|
|
<td scope="row" colspan="2"> |
120
|
|
|
<input name="smbd_<?php echo $slug; ?>_cron" value="false" type="radio" checked="checked"> <?php _e( 'Delete now', 'bulk-delete' ); ?> |
121
|
|
|
<input name="smbd_<?php echo $slug; ?>_cron" value="true" type="radio" id="smbd_<?php echo $slug; ?>_cron" disabled > <?php _e( 'Schedule', 'bulk-delete' ); ?> |
122
|
|
|
<input name="smbd_<?php echo $slug; ?>_cron_start" id="smbd_<?php echo $slug; ?>_cron_start" value="now" type="text" disabled><?php _e( 'repeat ', 'bulk-delete' );?> |
123
|
|
|
<select name="smbd_<?php echo $slug; ?>_cron_freq" id="smbd_<?php echo $slug; ?>_cron_freq" disabled> |
124
|
|
|
<option value="-1"><?php _e( "Don't repeat", 'bulk-delete' ); ?></option> |
125
|
|
|
<?php |
126
|
|
|
$schedules = wp_get_schedules(); |
127
|
|
|
foreach ( $schedules as $key => $value ) { |
128
|
|
|
?> |
129
|
|
|
<option value="<?php echo $key; ?>"><?php echo $value['display']; ?></option> |
130
|
|
|
<?php } ?> |
131
|
|
|
</select> |
132
|
|
|
<span class="<?php echo sanitize_html_class( apply_filters( 'bd_pro_class', $pro_class, $slug ) ); ?>" style="color:red"><?php _e( 'Only available in Pro Addon', 'bulk-delete' ); ?> <a href="<?php echo $addon_url; ?>">Buy now</a></span> |
133
|
|
|
</td> |
134
|
|
|
</tr> |
135
|
|
|
|
136
|
|
|
<tr> |
137
|
|
|
<td scope="row" colspan="2"> |
138
|
|
|
<?php _e( 'Enter time in <strong>Y-m-d H:i:s</strong> format or enter <strong>now</strong> to use current time', 'bulk-delete' );?> |
139
|
|
|
</td> |
140
|
|
|
</tr> |
141
|
|
|
<?php |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* Render the submit button. |
146
|
|
|
* |
147
|
|
|
* @since 5.5 |
148
|
|
|
* @param string $action The action attribute of the submit button. |
149
|
|
|
*/ |
150
|
|
|
function bd_render_submit_button( $action ) { |
151
|
|
|
?> |
152
|
|
|
<p class="submit"> |
153
|
|
|
<button type="submit" name="bd_action" value="<?php echo esc_attr( $action ); ?>" class="button-primary"><?php _e( 'Bulk Delete ', 'bulk-delete' ); ?>»</button> |
154
|
|
|
</p> |
155
|
|
|
<?php |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Render the post type dropdown. |
160
|
|
|
* |
161
|
|
|
* @since 5.5 |
162
|
|
|
* @param string $slug The slug to be used in field names. |
163
|
|
|
*/ |
164
|
|
|
function bd_render_post_type_dropdown( $slug ) { |
165
|
|
|
$types = get_post_types( array( '_builtin' => false ), 'names' ); |
166
|
|
|
array_unshift( $types, 'page' ); |
167
|
|
|
array_unshift( $types, 'post' ); |
168
|
|
|
?> |
169
|
|
|
<tr> |
170
|
|
|
<td scope="row" > |
171
|
|
|
<select class="select2" name="smbd_<?php echo $slug; ?>_post_type"> |
172
|
|
|
<?php foreach ( $types as $type ) { ?> |
173
|
|
|
<option value="<?php echo esc_attr( $type ); ?>"><?php echo esc_html( $type ); ?></option> |
174
|
|
|
<?php } ?> |
175
|
|
|
</select> |
176
|
|
|
</td> |
177
|
|
|
</tr> |
178
|
|
|
<?php |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
|