PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 3.6.1
Admin and Site Enhancements (ASE) v3.6.1
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-fields-render.php
admin-site-enhancements / classes Last commit date
class-activation.php 3 years ago class-admin-interface.php 3 years ago class-common-methods.php 3 years ago class-content-management.php 3 years ago class-custom-code.php 3 years ago class-deactivation.php 3 years ago class-disable-components.php 3 years ago class-login-logout.php 3 years ago class-security.php 3 years ago class-settings-fields-render.php 3 years ago class-settings-sanitization.php 3 years ago class-settings-sections-fields.php 3 years ago class-utilities.php 3 years ago
class-settings-fields-render.php
627 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class related to rendering of settings fields on the admin page
7 *
8 * @since 2.2.0
9 */
10 class Settings_Fields_Render {
11
12 /**
13 * Render checkbox field as a toggle/switcher
14 *
15 * @since 1.0.0
16 */
17 function render_checkbox_toggle( $args ) {
18
19 $options = get_option( ASENHA_SLUG_U, array() );
20
21 $field_name = $args['field_name'];
22 $field_description = $args['field_description'];
23 $field_option_value = ( array_key_exists( $args['field_id'], $options ) ) ? $options[$args['field_id']] : false;
24
25 echo '<input type="checkbox" id="' . esc_attr( $field_name ) . '" class="asenha-field-checkbox" name="' . esc_attr( $field_name ) . '" ' . checked( $field_option_value, true, false ) . '>';
26 echo '<label for="' . esc_attr( $field_name ) . '"></label>';
27
28 // For field with additional options / sub-fields, we add a wrapper to enclose field descriptions
29 if ( array_key_exists( 'field_options_wrapper', $args ) && $args['field_options_wrapper'] ) {
30 // For when the options / sub-fields occupy lengthy vertical space, we add show all / less toggler
31 if ( array_key_exists( 'field_options_moreless', $args ) && $args['field_options_moreless'] ) {
32 echo '<div class="asenha-field-with-options field-show-more">';
33 echo '<a id="' . $args['field_slug'] . '-show-moreless" class="show-more-less show-more" href="#">Expand &#9660;</a>';
34 echo '<div class="asenha-field-options-wrapper wrapper-show-more">';
35 } else {
36 echo '<div class="asenha-field-with-options">';
37 echo '<div class="asenha-field-options-wrapper">';
38 }
39
40 }
41
42 echo '<div class="asenha-field-description">' . wp_kses_post( $field_description ) . '</div>';
43
44 // For field with additional options / sub-fields, we add wrapper for them
45 if ( array_key_exists( 'field_options_wrapper', $args ) && $args['field_options_wrapper'] ) {
46 echo '<div class="asenha-subfields" style="display:none"></div>';
47 }
48
49
50 // For field with additional options / sub-fields, we add a wrapper to enclose field descriptions
51 if ( array_key_exists( 'field_options_wrapper', $args ) && $args['field_options_wrapper'] ) {
52 echo '</div>';
53 echo '</div>';
54 }
55
56 }
57
58 /**
59 * Render checkbox field as sub-field of a toggle/switcher checkbox
60 *
61 * @since 1.9.0
62 */
63 function render_checkbox_plain( $args ) {
64
65 $options = get_option( ASENHA_SLUG_U, array() );
66
67 $field_name = $args['field_name'];
68 $field_label = $args['field_label'];
69 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : false;
70
71 echo '<input type="checkbox" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-checkbox" name="' . esc_attr( $field_name ) . '" ' . checked( $field_option_value, true, false ) . '>';
72 echo '<label for="' . esc_attr( $field_name ) . '" class="asenha-subfield-checkbox-label">' . wp_kses_post( $field_label ) . '</label>';
73
74 }
75
76 /**
77 * Render checkbox field as sub-field of a toggle/switcher checkbox
78 *
79 * @since 1.3.0
80 */
81 function render_checkbox_subfield( $args ) {
82
83 $options = get_option( ASENHA_SLUG_U, array() );
84
85 $field_name = $args['field_name'];
86 $field_label = $args['field_label'];
87 $field_option_value = ( isset( $options[$args['parent_field_id']][$args['field_id']] ) ) ? $options[$args['parent_field_id']][$args['field_id']] : false;
88
89 echo '<input type="checkbox" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-checkbox" name="' . esc_attr( $field_name ) . '" ' . checked( $field_option_value, true, false ) . '>';
90 echo '<label for="' . esc_attr( $field_name ) . '" class="asenha-subfield-checkbox-label">' . wp_kses_post( $field_label ) . '</label>';
91
92 }
93
94 /**
95 * Render text field as sub-field of a toggle/switcher checkbox
96 *
97 * @since 1.4.0
98 */
99 function render_text_subfield( $args ) {
100
101 $options = get_option( ASENHA_SLUG_U, array() );
102
103 $field_id = $args['field_id'];
104 $field_name = $args['field_name'];
105 $field_type = $args['field_type'];
106 $field_prefix = $args['field_prefix'];
107 $field_suffix = $args['field_suffix'];
108 $field_description = $args['field_description'];
109 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : '';
110
111 if ( ! empty( $field_prefix ) && ! empty( $field_suffix ) ) {
112 $field_classname = ' with-prefix with-suffix';
113 } elseif ( ! empty( $field_prefix ) && empty( $field_suffix ) ) {
114 $field_classname = ' with-prefix';
115 } elseif ( empty( $field_prefix ) && ! empty( $field_suffix ) ) {
116 $field_classname = ' with-suffix';
117 } else {
118 $field_classname = '';
119 }
120
121 if ( $field_id == 'custom_login_slug' ) {
122 $placeholder = 'e.g. backend';
123 } elseif ( $field_id == 'redirect_after_login_to_slug' ) {
124 $placeholder = 'e.g. my-account';
125 } elseif ( $field_id == 'redirect_after_logout_to_slug' ) {
126 $placeholder = 'e.g. come-visit-again';
127 } elseif ( $field_id == 'login_fails_allowed' ) {
128 $placeholder = '3';
129 } elseif ( $field_id == 'login_lockout_maxcount' ) {
130 $placeholder = '3';
131 } else {
132 $placeholder = '';
133 }
134
135 echo $field_prefix . '<input type="text" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-text' . esc_attr( $field_classname ) . '" name="' . esc_attr( $field_name ) . '" placeholder="' . esc_attr( $placeholder ) . '" value="' . esc_attr( $field_option_value ) . '">' . $field_suffix;
136 echo '<label for="' . esc_attr( $field_name ) . '" class="asenha-subfield-checkbox-label">' . esc_html( $field_description ) . '</label>';
137
138 }
139
140 /**
141 * Render number field as sub-field of a toggle/switcher checkbox
142 *
143 * @since 1.4.0
144 */
145 function render_number_subfield( $args ) {
146
147 $options = get_option( ASENHA_SLUG_U, array() );
148
149 $field_id = $args['field_id'];
150 $field_name = $args['field_name'];
151 $field_type = $args['field_type'];
152 $field_prefix = $args['field_prefix'];
153 $field_suffix = $args['field_suffix'];
154 $field_intro = $args['field_intro'];
155 $field_description = $args['field_description'];
156 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : '';
157
158 if ( ! empty( $field_prefix ) && ! empty( $field_suffix ) ) {
159 $field_classname = ' with-prefix with-suffix';
160 } elseif ( ! empty( $field_prefix ) && empty( $field_suffix ) ) {
161 $field_classname = ' with-prefix';
162 } elseif ( empty( $field_prefix ) && ! empty( $field_suffix ) ) {
163 $field_classname = ' with-suffix';
164 } else {
165 $field_classname = '';
166 }
167
168 if ( ( $field_id == 'head_code_priority' ) || ( $field_id == 'body_code_priority' ) || ( $field_id == 'footer_code_priority' ) ) {
169 $placeholder = '10';
170 } else {
171 $placeholder = '';
172 }
173
174 echo '<div class="asenha-subfield-number-wrapper">';
175
176 if ( ! empty( $field_intro ) ) {
177 echo '<div class="asenha-subfield-number-intro">' . wp_kses_post( $field_intro ) . '</div>';
178 }
179
180 echo '<div>' . $field_prefix . '<input type="number" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-number' . esc_attr( $field_classname ) . '" name="' . esc_attr( $field_name ) . '" placeholder="' . esc_attr( $placeholder ) . '" value="' . esc_attr( $field_option_value ) . '">' . $field_suffix . '</div>';
181
182 if ( ! empty( $field_description ) ) {
183 echo '<div class="asenha-subfield-number-description">' . wp_kses_post( $field_description ) . '</div>';
184 }
185
186 echo '</div>';
187
188 }
189
190 /**
191 * Render textarea field as sub-field of a toggle/switcher checkbox
192 *
193 * @since 2.3.0
194 */
195 function render_textarea_subfield( $args ) {
196
197 $options = get_option( ASENHA_SLUG_U, array() );
198
199 $field_id = $args['field_id'];
200 $field_slug = $args['field_slug'];
201 $field_name = $args['field_name'];
202 $field_type = $args['field_type'];
203 $field_intro = $args['field_intro'];
204 $field_description = $args['field_description'];
205
206 // Always load textarea content from robots.txt URL
207 if ( 'robots_txt_content' == $field_id ) {
208
209 if ( array_key_exists( 'manage_robots_txt', $options ) && ! $options['manage_robots_txt'] ) {
210 if ( array_key_exists( 'robots_txt_content', $options ) && $options['robots_txt_content'] ) {
211 $field_option_value = $options['robots_txt_content'];
212 }
213 }
214
215 if ( array_key_exists( 'manage_robots_txt', $options ) && $options['manage_robots_txt'] ) {
216 $robots_txt_content = wp_remote_get( get_site_url() . '/robots.txt' );
217 $robots_txt_content = esc_textarea( trim( wp_remote_retrieve_body( $robots_txt_content ) ) );
218 $field_option_value = $robots_txt_content;
219 }
220
221 } else {
222 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : '';
223 }
224
225 echo '<div class="asenha-subfield-textarea-wrapper">';
226
227 if ( ! empty( $field_intro ) ) {
228 echo '<div class="asenha-subfield-textarea-intro">' . wp_kses_post( $field_intro ) . '</div>';
229 }
230
231
232 echo '<textarea rows="30" class="asenha-subfield-textarea" id="' . esc_attr( $field_name ) . '" name="' . esc_attr( $field_name ) . '">' . esc_textarea( $field_option_value ) . '</textarea>';
233
234 if ( ! empty( $field_description ) ) {
235 echo '<div class="asenha-subfield-textarea-description">' . wp_kses_post( $field_description ) . '</div>';
236 }
237
238 echo '</div>';
239
240 }
241
242 /**
243 * Render sortable menu field
244 *
245 * @since 2.0.0
246 */
247 function render_sortable_menu( $args ) {
248
249 ?>
250 <div class="subfield-description">Drag and drop menu items to the desired position. Optionally change item titles or hide some items until "Show All" at the bottom of the admin menu is clicked.</div>
251 <ul id="custom-admin-menu" class="menu ui-sortable">
252 <?php
253
254 global $menu;
255 global $submenu;
256 $common_methods = new Common_Methods;
257 $options = get_option( ASENHA_SLUG_U, array() );
258
259 // Set menu items to be excluded from title renaming. These are from WordPress core.
260 $renaming_not_allowed = array( 'menu-dashboard', 'menu-pages', 'menu-posts', 'menu-media', 'menu-comments', 'menu-appearance', 'menu-plugins', 'menu-users', 'menu-tools', 'menu-settings' );
261
262 // Get custom menu item titles
263 if ( array_key_exists( 'custom_menu_titles', $options ) ) {
264 $custom_menu_titles = $options['custom_menu_titles'];
265 $custom_menu_titles = explode( ',', $custom_menu_titles );
266 } else {
267 $custom_menu_titles = array();
268 }
269
270 // Get hidden menu items
271 if ( array_key_exists( 'custom_menu_hidden', $options ) ) {
272 $hidden_menu = $options['custom_menu_hidden'];
273 $hidden_menu = explode( ',', $hidden_menu );
274 } else {
275 $hidden_menu = array();
276 }
277
278 $i = 1;
279
280 // Check if there's an existing custom menu order data stored in options
281
282 if ( array_key_exists( 'custom_menu_order', $options ) ) {
283
284 $custom_menu = $options['custom_menu_order'];
285 $custom_menu = explode( ',', $custom_menu );
286
287 $menu_key_in_use = array();
288
289 // Render sortables with data in custom menu order
290
291 foreach ( $custom_menu as $custom_menu_item ) {
292
293 foreach ( $menu as $menu_key => $menu_info ) {
294
295 if ( false !== strpos( $menu_info[4], 'wp-menu-separator' ) ) {
296 $menu_item_id = $menu_info[2];
297 } else {
298 $menu_item_id = $menu_info[5];
299 }
300
301 if ( $custom_menu_item == $menu_item_id ) {
302
303 ?>
304 <li id="<?php echo esc_attr( $menu_item_id ); ?>" class="menu-item menu-item-depth-0">
305 <div class="menu-item-bar">
306 <div class="menu-item-handle ui-sortable-handle">
307 <div class="item-title">
308 <span class="menu-item-title">
309 <?php
310
311 if ( false !== strpos( $menu_info[4], 'wp-menu-separator' ) ) {
312 $separator_name = $menu_info[2];
313 $separator_name = str_replace( 'separator', 'Separator-', $separator_name );
314 $separator_name = str_replace( '--last', '-Last', $separator_name );
315 echo '~~ ' . esc_html( $separator_name ) . ' ~~';
316 } else {
317 if ( in_array( $menu_item_id, $renaming_not_allowed ) ) {
318 // echo wp_kses_post( $menu_info[0] );
319 echo wp_kses_post( $common_methods->strip_html_tags_and_content( $menu_info[0] ) );
320 } else {
321
322 // Get defaul/custom menu item title
323 foreach ( $custom_menu_titles as $custom_menu_title ) {
324
325 // At this point, $custom_menu_title value looks like toplevel_page_snippets__Code Snippets
326
327 $custom_menu_title = explode( '__', $custom_menu_title );
328
329 if ( $custom_menu_title[0] == $menu_item_id ) {
330 $menu_item_title = $common_methods->strip_html_tags_and_content( $custom_menu_title[1] ); // e.g. Code Snippets
331 break; // stop foreach loop so $menu_item_title is not overwritten in the next iteration
332 } else {
333 $menu_item_title = $common_methods->strip_html_tags_and_content( $menu_info[0] );
334 }
335
336 }
337
338 ?>
339 <input type="text" value="<?php echo wp_kses_post( $menu_item_title ); ?>" class="menu-item-custom-title" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
340 <?php
341 }
342 }
343
344 ?>
345 </span>
346 <label class="menu-item-checkbox-label">
347 <?php
348 if ( in_array( $custom_menu_item, $hidden_menu ) ) {
349 ?>
350 <input type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>" checked>
351 <span>Hide</span>
352 <?php
353 } else {
354 ?>
355 <input type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
356 <span>Hide</span>
357 <?php
358 }
359 ?>
360 </label>
361 </div>
362 </div>
363 </div>
364 <?php
365
366 $i = 1;
367
368 if ( array_key_exists( $menu_info[2], $submenu ) && @is_countable( $submenu[$menu_info[2]] ) && @sizeof( $submenu[$menu_info[2]] ) > 0 ) {
369 ?>
370 <div class="menu-item-settings wp-clearfix" style="display:none;">
371 <?php
372
373 foreach ( $submenu[$menu_info[2]] as $submenu_item ) {
374
375 $i++;
376
377 // echo $submenu_item[0];
378
379 }
380 ?>
381 </div>
382 <?php
383
384 }
385 ?>
386 </li>
387
388 <?php
389
390 $menu_key_in_use[] = $menu_key;
391
392 }
393
394 }
395
396 }
397
398 // Render the rest of the current menu towards the end of the sortables
399
400 foreach ( $menu as $menu_key => $menu_info ) {
401
402 if ( ! in_array( $menu_key, $menu_key_in_use ) ) {
403
404 $menu_item_id = $menu_info[5];
405 $menu_item_title = $menu_info[0];
406
407 // Exclude Show All/Less toggles
408
409 if ( false === strpos( $menu_item_id, 'toplevel_page_asenha_' ) ) {
410
411 ?>
412 <li id="<?php echo esc_attr( $menu_item_id ); ?>" class="menu-item menu-item-depth-0">
413 <div class="menu-item-bar">
414 <div class="menu-item-handle ui-sortable-handle">
415 <div class="item-title">
416 <span class="menu-item-title">
417 <input type="text" value="<?php echo wp_kses_post( $menu_item_title ); ?>" class="menu-item-custom-title" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
418 </span>
419 <label class="menu-item-checkbox-label">
420 <input type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
421 <span>Hide</span>
422 </label>
423 </div>
424 </div>
425 </div>
426 <?php
427
428 }
429
430 $i = 1;
431
432 if ( array_key_exists( $menu_info[2], $submenu ) && @is_countable( $submenu[$menu_info[2]] ) && @sizeof( $submenu[$menu_info[2]] ) > 0 ) {
433 ?>
434 <div class="menu-item-settings wp-clearfix" style="display:none;">
435 <?php
436
437 foreach ( $submenu[$menu_info[2]] as $submenu_item ) {
438
439 $i++;
440
441 // echo $submenu_item[0];
442
443 }
444 ?>
445 </div>
446 <?php
447
448 }
449 ?>
450 </li>
451
452 <?php
453
454 }
455
456 }
457
458 } else {
459
460 // Render sortables with existing items in the admin menu
461
462 foreach ( $menu as $menu_key => $menu_info ) {
463
464 if ( false !== strpos( $menu_info[4], 'wp-menu-separator' ) ) {
465 $menu_item_id = $menu_info[2];
466 } else {
467 $menu_item_id = $menu_info[5];
468 }
469
470 ?>
471 <li id="<?php echo esc_attr( $menu_item_id ); ?>" class="menu-item menu-item-depth-0">
472 <div class="menu-item-bar">
473 <div class="menu-item-handle ui-sortable-handle">
474 <div class="item-title">
475 <span class="menu-item-title">
476 <?php
477
478 if ( false !== strpos( $menu_info[4], 'wp-menu-separator' ) ) {
479 $separator_name = $menu_info[2];
480 $separator_name = str_replace( 'separator', 'Separator-', $separator_name );
481 $separator_name = str_replace( '--last', '-Last', $separator_name );
482 echo '~~ ' . esc_html( $separator_name ) . ' ~~';
483 } else {
484 if ( in_array( $menu_item_id, $renaming_not_allowed ) ) {
485 echo wp_kses_post( $common_methods->strip_html_tags_and_content( $menu_info[0] ) );
486 } else {
487 ?>
488 <input type="text" value="<?php echo wp_kses_post( $common_methods->strip_html_tags_and_content( $menu_info[0] ) ); ?>" class="menu-item-custom-title" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
489 <?php
490 }
491 }
492
493 ?>
494 </span>
495 <label class="menu-item-checkbox-label">
496 <input type="checkbox" class="menu-item-checkbox" data-menu-item-id="<?php echo esc_attr( $menu_item_id ); ?>">
497 <span>Hide</span>
498 </label>
499 </div>
500 </div>
501 </div>
502 <?php
503
504 $i = 1;
505
506 if ( array_key_exists( $menu_info[2], $submenu ) && @is_countable( $submenu[$menu_info[2]] ) && @sizeof( $submenu[$menu_info[2]] ) > 0 ) {
507 ?>
508 <div class="menu-item-settings wp-clearfix" style="display:none;">
509 <?php
510
511 foreach ( $submenu[$menu_info[2]] as $submenu_item ) {
512
513 $i++;
514
515 // echo $submenu_item[0];
516
517 }
518 ?>
519 </div>
520 <?php
521
522 }
523 ?>
524 </li>
525
526 <?php
527
528 }
529
530
531 }
532
533
534 ?>
535 </ul>
536 <?php
537
538 $field_id = $args['field_id'];
539 $field_name = $args['field_name'];
540 $field_description = $args['field_description'];
541 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : '';
542
543 // Hidden input field to store custom menu order (from options as is, or sortupdate) upon clicking Save Changes.
544 echo '<input type="hidden" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-text" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_option_value ) . '">';
545
546 $field_id = 'custom_menu_titles';
547 $field_name = ASENHA_SLUG_U . '['. $field_id .']';
548 $field_option_value = ( isset( $options[$field_id] ) ) ? $options[$field_id] : '';
549
550 // Hidden input field to store custom menu titles (from options as is, or custom values entered on each non-WP-default menu items.
551 echo '<input type="hidden" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-text" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_option_value ) . '">';
552
553 $field_id = 'custom_menu_hidden';
554 $field_name = ASENHA_SLUG_U . '['. $field_id .']';
555 $field_option_value = ( isset( $options[$field_id] ) ) ? $options[$field_id] : '';
556
557 // Hidden input field to store hidden menu itmes (from options as is, or 'Hide' checkbox clicks) upon clicking Save Changes.
558 echo '<input type="hidden" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-text" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_option_value ) . '">';
559
560 }
561
562 /**
563 * Render textarea field as sub-field of a toggle/switcher checkbox
564 *
565 * @since 2.3.0
566 */
567 function render_datatable( $args ) {
568
569 global $wpdb;
570
571 $options = get_option( ASENHA_SLUG_U, array() );
572
573 $field_id = $args['field_id'];
574 $field_slug = $args['field_slug'];
575 $field_name = $args['field_name'];
576 $field_type = $args['field_type'];
577 $field_description = $args['field_description'];
578 $table_title = $args['table_title'];
579 $table_name = $args['table_name'];
580 $field_option_value = ( isset( $options[$args['field_id']] ) ) ? $options[$args['field_id']] : '';
581
582 ?>
583 <table id="login-attempts-log" class="wp-list-table widefat striped datatable">
584 <thead>
585 <tr class="datatable-tr">
586 <th class="datatable-th">IP Address<br />Last Username</th>
587 <th class="datatable-th">Attempts<br />Lockouts</th>
588 <th class="datatable-th">Last Attempt On</th>
589 </tr>
590 </thead>
591 <tbody>
592 <?php
593
594 $limit = 1000;
595
596 $sql = $wpdb->prepare( "SELECT * FROM {$table_name} ORDER BY unixtime DESC LIMIT %d", array( $limit ) );
597
598 $entries = $wpdb->get_results( $sql, ARRAY_A );
599
600 foreach( $entries as $entry ) {
601
602 $unixtime = $entry['unixtime'];
603 if ( function_exists( 'wp_date' ) ) {
604 $date = wp_date( 'F j, Y', $unixtime );
605 $time = wp_date( 'H:i:s', $unixtime );
606 } else {
607 $date = date_i18n( 'F j, Y', $unixtime );
608 $time = date_i18n( 'H:i:s', $unixtime );
609 }
610 ?>
611 <tr class="datatable-tr">
612 <td class="datatable-td"><?php echo esc_html( $entry['ip_address'] ); ?><br /><?php echo esc_html( $entry['username'] ); ?></td>
613 <td class="datatable-td"><?php echo esc_html( $entry['fail_count'] ); ?><br /><?php echo esc_html( $entry['lockout_count'] ); ?></td>
614 <td class="datatable-td"><?php echo esc_html( $date ); ?><br /><?php echo esc_html( $time ); ?></td>
615 </tr>
616 <?php
617 }
618
619 ?>
620 </tbody>
621 </table>
622 <?php
623
624 echo '<input type="hidden" id="' . esc_attr( $field_name ) . '" class="asenha-subfield-datatable" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $field_option_value ) . '">';
625 }
626
627 }