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