PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 2.7.0
Admin and Site Enhancements (ASE) v2.7.0
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-sections-fields.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-deactivation.php 3 years ago class-disable-components.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-sections-fields.php
998 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class related to registration of settings fields
7 *
8 * @since 2.2.0
9 */
10 class Settings_Sections_Fields {
11
12 /**
13 * Register plugin settings and the corresponding fields
14 *
15 * @link https://wpshout.com/making-an-admin-options-page-with-the-wordpress-settings-api/
16 * @link https://rudrastyh.com/wordpress/creating-options-pages.html
17 * @since 1.0.0
18 */
19 function register_sections_fields() {
20
21 // Add "Content Management" section
22
23 add_settings_section(
24 'main-section', // Section ID
25 '', // Section title. Can be blank.
26 '', // Callback function to output section intro. Can be blank.
27 ASENHA_SLUG // Settings page slug
28 );
29
30 // Register main setttings
31
32 // Instantiate object for sanitization of settings fields values
33 $sanitization = new Settings_Sanitization;
34
35 // Instantiate object for rendering of settings fields for the admin page
36 $render_field = new Settings_Fields_Render;
37
38 register_setting(
39 ASENHA_ID, // Option group or option_page
40 ASENHA_SLUG_U, // Option name in wp_options table
41 array(
42 'type' => 'array', // 'string', 'boolean', 'integer', 'number', 'array', or 'object'
43 'description' => '', // A description of the data attached to this setting.
44 'sanitize_callback' => [ $sanitization, 'sanitize_for_options' ],
45 'show_in_rest' => false,
46 'default' => array(), // When calling get_option()
47 )
48 );
49
50 // Call WordPress globals required for the fields
51
52 global $wp_roles, $wpdb, $asenha_public_post_types;
53
54 $roles = $wp_roles->get_names();
55
56 // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
57 $asenha_public_post_types = array();
58 $public_post_type_names = get_post_types( array( 'public' => true ), 'names' );
59 foreach( $public_post_type_names as $post_type_name ) {
60 $post_type_object = get_post_type_object( $post_type_name );
61 $asenha_public_post_types[$post_type_name] = $post_type_object->label;
62 }
63
64 // ===== CONTENT MANAGEMENT =====
65
66 // Enable Page and Post Duplication
67
68 $field_id = 'enable_duplication';
69 $field_slug = 'enable-duplication';
70
71 add_settings_field(
72 $field_id, // Field ID
73 'Enable Page and Post Duplication', // Field title
74 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
75 ASENHA_SLUG, // Settings page slug
76 'main-section', // Section ID
77 array(
78 'field_id' => $field_id, // Custom argument
79 'field_slug' => $field_slug, // Custom argument
80 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
81 'field_description' => 'Enable one-click duplication of pages, posts and custom posts. The corresponding taxonomy terms and post meta will also be duplicated.', // Custom argument
82 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
83 )
84 );
85
86 // Enable Media Replacement
87
88 $field_id = 'enable_media_replacement';
89 $field_slug = 'enable-media-replacement';
90
91 add_settings_field(
92 $field_id, // Field ID
93 'Enable Media Replacement', // Field title
94 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
95 ASENHA_SLUG, // Settings page slug
96 'main-section', // Section ID
97 array(
98 'field_id' => $field_id, // Custom argument
99 'field_slug' => $field_slug, // Custom argument
100 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
101 'field_description' => 'Easily replace any type of media file with a new one while retaining the existing media ID, publish date and file name. So, no existing links will break.', // Custom argument
102 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
103 )
104 );
105
106 // Enable SVG Upload
107
108 $field_id = 'enable_svg_upload';
109 $field_slug = 'enable-svg-upload';
110
111 add_settings_field(
112 $field_id, // Field ID
113 'Enable SVG Upload', // Field title
114 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
115 ASENHA_SLUG, // Settings page slug
116 'main-section', // Section ID
117 array(
118 'field_id' => $field_id, // Custom argument
119 'field_slug' => $field_slug, // Custom argument
120 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
121 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.', // Custom argument
122 'field_options_wrapper' => true, // Custom argument. Add container for additional options
123 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
124 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
125 )
126 );
127
128 $field_id = 'enable_svg_upload_for';
129 $field_slug = 'enable-svg-upload-for';
130
131 if ( is_array( $roles ) ) {
132 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
133
134 add_settings_field(
135 $field_id . '_' . $role_slug, // Field ID
136 '', // Field title
137 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
138 ASENHA_SLUG, // Settings page slug
139 'main-section', // Section ID
140 array(
141 'parent_field_id' => $field_id, // Custom argument
142 'field_id' => $role_slug, // Custom argument
143 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
144 'field_label' => $role_label, // Custom argument
145 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
146 )
147 );
148
149 }
150 }
151
152 // Enhance List Tables
153
154 $field_id = 'enhance_list_tables';
155 $field_slug = 'enhance-list-tables';
156
157 add_settings_field(
158 $field_id, // Field ID
159 'Enhance List Tables', // Field title
160 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
161 ASENHA_SLUG, // Settings page slug
162 'main-section', // Section ID
163 array(
164 'field_id' => $field_id, // Custom argument
165 'field_slug' => $field_slug, // Custom argument
166 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
167 'field_description' => 'Improve the usefulness of listing pages of various post types by adding / removing columns and elements.', // Custom argument
168 'field_options_wrapper' => true, // Custom argument. Add container for additional options
169 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
170 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
171 )
172 );
173
174 // Show Featured Image Column
175
176 $field_id = 'show_featured_image_column';
177 $field_slug = 'show-featured-image-column';
178
179 add_settings_field(
180 $field_id, // Field ID
181 '', // Field title
182 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
183 ASENHA_SLUG, // Settings page slug
184 'main-section', // Section ID
185 array(
186 'field_id' => $field_id, // Custom argument
187 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
188 'field_label' => 'Show featured image column.', // Custom argument
189 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
190 )
191 );
192
193 // Show Excerpt Column
194
195 $field_id = 'show_excerpt_column';
196 $field_slug = 'show-excerpt-column';
197
198 add_settings_field(
199 $field_id, // Field ID
200 '', // Field title
201 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
202 ASENHA_SLUG, // Settings page slug
203 'main-section', // Section ID
204 array(
205 'field_id' => $field_id, // Custom argument
206 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
207 'field_label' => 'Show excerpt column.', // Custom argument
208 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
209 )
210 );
211
212 // Show ID Column
213
214 $field_id = 'show_id_column';
215 $field_slug = 'show-id-column';
216
217 add_settings_field(
218 $field_id, // Field ID
219 '', // Field title
220 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
221 ASENHA_SLUG, // Settings page slug
222 'main-section', // Section ID
223 array(
224 'field_id' => $field_id, // Custom argument
225 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
226 'field_label' => 'Show ID column.', // Custom argument
227 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
228 )
229 );
230
231 // Hide Comments Column
232
233 $field_id = 'hide_comments_column';
234 $field_slug = 'hide-comments-column';
235
236 add_settings_field(
237 $field_id, // Field ID
238 '', // Field title
239 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
240 ASENHA_SLUG, // Settings page slug
241 'main-section', // Section ID
242 array(
243 'field_id' => $field_id, // Custom argument
244 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
245 'field_label' => 'Remove comments column.', // Custom argument
246 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
247 )
248 );
249
250 // Hide Post Tags Column
251
252 $field_id = 'hide_post_tags_column';
253 $field_slug = 'hide-post-tags-column';
254
255 add_settings_field(
256 $field_id, // Field ID
257 '', // Field title
258 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
259 ASENHA_SLUG, // Settings page slug
260 'main-section', // Section ID
261 array(
262 'field_id' => $field_id, // Custom argument
263 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
264 'field_label' => 'Remove tags column (for posts).', // Custom argument
265 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
266 )
267 );
268
269 // Show Custom Taxonomy Filters
270
271 $field_id = 'show_custom_taxonomy_filters';
272 $field_slug = 'show-custom-taxonomy-filters';
273
274 add_settings_field(
275 $field_id, // Field ID
276 '', // Field title
277 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
278 ASENHA_SLUG, // Settings page slug
279 'main-section', // Section ID
280 array(
281 'field_id' => $field_id, // Custom argument
282 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
283 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
284 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
285 )
286 );
287
288 // ===== ADMIN INTERFACE =====
289
290 // Hide Admin Notices
291
292 $field_id = 'hide_admin_notices';
293 $field_slug = 'hide-admin-notices';
294
295 add_settings_field(
296 $field_id, // Field ID
297 'Hide Admin Notices', // Field title
298 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
299 ASENHA_SLUG, // Settings page slug
300 'main-section', // Section ID
301 array(
302 'field_id' => $field_id, // Custom argument
303 'field_slug' => $field_slug, // Custom argument
304 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
305 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
306 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
307 )
308 );
309
310 // View Admin as Role
311
312 $field_id = 'view_admin_as_role';
313 $field_slug = 'view-admin-as-role';
314
315 add_settings_field(
316 $field_id, // Field ID
317 'View Admin as Role', // Field title
318 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
319 ASENHA_SLUG, // Settings page slug
320 'main-section', // Section ID
321 array(
322 'field_id' => $field_id, // Custom argument
323 'field_slug' => $field_slug, // Custom argument
324 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
325 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
326 'field_options_wrapper' => true, // Custom argument. Add container for additional options
327 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
328 )
329 );
330
331 // Hide or Modify Elements
332
333 $field_id = 'hide_modify_elements';
334 $field_slug = 'hide-modify-elements';
335
336 add_settings_field(
337 $field_id, // Field ID
338 'Clean Up Admin Bar', // Field title
339 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
340 ASENHA_SLUG, // Settings page slug
341 'main-section', // Section ID
342 array(
343 'field_id' => $field_id, // Custom argument
344 'field_slug' => $field_slug, // Custom argument
345 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
346 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
347 'field_options_wrapper' => true, // Custom argument. Add container for additional options
348 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
349 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
350 )
351 );
352
353 $field_id = 'hide_ab_wp_logo_menu';
354 $field_slug = 'hide-ab-wp-logo-menu';
355
356 add_settings_field(
357 $field_id, // Field ID
358 '', // Field title
359 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
360 ASENHA_SLUG, // Settings page slug
361 'main-section', // Section ID
362 array(
363 'field_id' => $field_id, // Custom argument
364 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
365 'field_label' => 'Remove WordPress logo/menu', // Custom argument
366 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
367 )
368 );
369
370 $field_id = 'hide_ab_customize_menu';
371 $field_slug = 'hide-ab-customize-menu';
372
373 add_settings_field(
374 $field_id, // Field ID
375 '', // Field title
376 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
377 ASENHA_SLUG, // Settings page slug
378 'main-section', // Section ID
379 array(
380 'field_id' => $field_id, // Custom argument
381 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
382 'field_label' => 'Remove customize menu', // Custom argument
383 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
384 )
385 );
386
387 $field_id = 'hide_ab_updates_menu';
388 $field_slug = 'hide-ab-updates-menu';
389
390 add_settings_field(
391 $field_id, // Field ID
392 '', // Field title
393 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
394 ASENHA_SLUG, // Settings page slug
395 'main-section', // Section ID
396 array(
397 'field_id' => $field_id, // Custom argument
398 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
399 'field_label' => 'Remove updates counter/link', // Custom argument
400 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
401 )
402 );
403
404 $field_id = 'hide_ab_comments_menu';
405 $field_slug = 'hide-ab-comments-menu';
406
407 add_settings_field(
408 $field_id, // Field ID
409 '', // Field title
410 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
411 ASENHA_SLUG, // Settings page slug
412 'main-section', // Section ID
413 array(
414 'field_id' => $field_id, // Custom argument
415 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
416 'field_label' => 'Remove comments counter/link', // Custom argument
417 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
418 )
419 );
420
421 $field_id = 'hide_ab_new_content_menu';
422 $field_slug = 'hide-ab-new-content-menu';
423
424 add_settings_field(
425 $field_id, // Field ID
426 '', // Field title
427 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
428 ASENHA_SLUG, // Settings page slug
429 'main-section', // Section ID
430 array(
431 'field_id' => $field_id, // Custom argument
432 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
433 'field_label' => 'Remove new content menu', // Custom argument
434 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
435 )
436 );
437
438 $field_id = 'hide_ab_howdy';
439 $field_slug = 'hide-ab-howdy';
440
441 add_settings_field(
442 $field_id, // Field ID
443 '', // Field title
444 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
445 ASENHA_SLUG, // Settings page slug
446 'main-section', // Section ID
447 array(
448 'field_id' => $field_id, // Custom argument
449 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
450 'field_label' => 'Remove \'Howdy\'', // Custom argument
451 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
452 )
453 );
454
455 // Hide Admin Bar
456
457 $field_id = 'hide_admin_bar';
458 $field_slug = 'hide-admin-bar';
459
460 add_settings_field(
461 $field_id, // Field ID
462 'Hide Admin Bar', // Field title
463 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
464 ASENHA_SLUG, // Settings page slug
465 'main-section', // Section ID
466 array(
467 'field_id' => $field_id, // Custom argument
468 'field_slug' => $field_slug, // Custom argument
469 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
470 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
471 'field_options_wrapper' => true, // Custom argument. Add container for additional options
472 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
473 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
474 )
475 );
476
477 $field_id = 'hide_admin_bar_for';
478 $field_slug = 'hide-admin-bar-for';
479
480 if ( is_array( $roles ) ) {
481 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
482
483 add_settings_field(
484 $field_id . '_' . $role_slug, // Field ID
485 '', // Field title
486 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
487 ASENHA_SLUG, // Settings page slug
488 'main-section', // Section ID
489 array(
490 'parent_field_id' => $field_id, // Custom argument
491 'field_id' => $role_slug, // Custom argument
492 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
493 'field_label' => $role_label, // Custom argument
494 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
495 )
496 );
497
498 }
499 }
500
501 // Customize Admin Menu
502
503 $field_id = 'customize_admin_menu';
504 $field_slug = 'customize-admin-menu';
505
506 add_settings_field(
507 $field_id, // Field ID
508 'Admin Menu Organizer', // Field title
509 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
510 ASENHA_SLUG, // Settings page slug
511 'main-section', // Section ID
512 array(
513 'field_id' => $field_id, // Custom argument
514 'field_slug' => $field_slug, // Custom argument
515 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
516 'field_description' => 'Customize the order of the admin menu and optionally hide some items.', // Custom argument
517 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
518 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
519 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
520 )
521 );
522
523 $field_id = 'custom_menu_order';
524 $field_slug = 'custom-menu-order';
525
526 add_settings_field(
527 $field_id, // Field ID
528 '', // Field title
529 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
530 ASENHA_SLUG, // Settings page slug
531 'main-section', // Section ID
532 array(
533 'field_id' => $field_id, // Custom argument
534 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
535 'field_type' => 'sortable-menu', // Custom argument
536 'field_description' => '', // Custom argument
537 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
538 )
539 );
540
541 // ===== DISABLE COMPONENTS =====
542
543 // Disable Comments
544
545 $field_id = 'disable_comments';
546 $field_slug = 'disable-comments';
547
548 add_settings_field(
549 $field_id, // Field ID
550 'Disable Comments', // Field title
551 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
552 ASENHA_SLUG, // Settings page slug
553 'main-section', // Section ID
554 array(
555 'field_id' => $field_id, // Custom argument
556 'field_slug' => $field_slug, // Custom argument
557 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
558 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
559 'field_options_wrapper' => true, // Custom argument. Add container for additional options
560 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
561 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
562 )
563 );
564
565 $field_id = 'disable_comments_for';
566 $field_slug = 'disable-comments-for';
567
568 if ( is_array( $asenha_public_post_types ) ) {
569 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
570 add_settings_field(
571 $field_id . '_' . $post_type_slug, // Field ID
572 '', // Field title
573 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
574 ASENHA_SLUG, // Settings page slug
575 'main-section', // Section ID
576 array(
577 'parent_field_id' => $field_id, // Custom argument
578 'field_id' => $post_type_slug, // Custom argument
579 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
580 'field_label' => $post_type_label, // Custom argument
581 'class' => 'asenha-checkbox asenha-hide-th asenha-half utilities ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
582 )
583 );
584 }
585 }
586
587 // ===== SECURITY =====
588
589 // Change Login URL
590
591 $field_id = 'change_login_url';
592 $field_slug = 'change-login-url';
593
594 add_settings_field(
595 $field_id, // Field ID
596 'Change Login URL', // Field title
597 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
598 ASENHA_SLUG, // Settings page slug
599 'main-section', // Section ID
600 array(
601 'field_id' => $field_id, // Custom argument
602 'field_slug' => $field_slug, // Custom argument
603 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
604 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
605 'field_options_wrapper' => true, // Custom argument. Add container for additional options
606 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
607 )
608 );
609
610 $field_id = 'custom_login_slug';
611 $field_slug = 'custom-login-slug';
612
613 add_settings_field(
614 $field_id, // Field ID
615 'New URL:', // Field title
616 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
617 ASENHA_SLUG, // Settings page slug
618 'main-section', // Section ID
619 array(
620 'field_id' => $field_id, // Custom argument
621 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
622 'field_type' => 'with-prefix-suffix', // Custom argument
623 'field_prefix' => get_site_url() . '/', // Custom argument
624 'field_suffix' => '/', // Custom argument
625 'field_description' => '', // Custom argument
626 'class' => 'asenha-text with-prefix-suffix security ' . $field_slug, // Custom class for the <tr> element
627 )
628 );
629
630 // Limit Login Attempts
631
632 $field_id = 'limit_login_attempts';
633 $field_slug = 'limit-login-attempts';
634
635 add_settings_field(
636 $field_id, // Field ID
637 'Limit Login Attempts', // Field title
638 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
639 ASENHA_SLUG, // Settings page slug
640 'main-section', // Section ID
641 array(
642 'field_id' => $field_id, // Custom argument
643 'field_slug' => $field_slug, // Custom argument
644 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
645 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
646 'field_options_wrapper' => true, // Custom argument. Add container for additional options
647 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
648 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
649 )
650 );
651
652 $field_id = 'login_fails_allowed';
653 $field_slug = 'login-fails-allowed';
654
655 add_settings_field(
656 $field_id, // Field ID
657 '', // Field title
658 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
659 ASENHA_SLUG, // Settings page slug
660 'main-section', // Section ID
661 array(
662 'field_id' => $field_id, // Custom argument
663 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
664 'field_type' => 'with-prefix-suffix', // Custom argument
665 'field_prefix' => '', // Custom argument
666 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
667 'field_description' => '', // Custom argument
668 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
669 )
670 );
671
672 $field_id = 'login_lockout_maxcount';
673 $field_slug = 'login-lockout-maxcount';
674
675 add_settings_field(
676 $field_id, // Field ID
677 '', // Field title
678 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
679 ASENHA_SLUG, // Settings page slug
680 'main-section', // Section ID
681 array(
682 'field_id' => $field_id, // Custom argument
683 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
684 'field_type' => 'with-prefix-suffix', // Custom argument
685 'field_prefix' => '', // Custom argument
686 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
687 'field_description' => '', // Custom argument
688 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
689 )
690 );
691
692 $field_id = 'login_attempts_log_table';
693 $field_slug = 'login-attempts-log-table';
694
695 add_settings_field(
696 $field_id, // Field ID
697 '', // Field title
698 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
699 ASENHA_SLUG, // Settings page slug
700 'main-section', // Section ID
701 array(
702 'field_id' => $field_id, // Custom argument
703 'field_slug' => $field_slug, // Custom argument
704 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
705 'field_type' => 'datatable', // Custom argument
706 'field_description' => '', // Custom argument
707 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
708 'table_title' => 'Failed Login Attempts Log',
709 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
710 )
711 );
712
713 // Obfuscate Author Slugs
714
715 $field_id = 'obfuscate_author_slugs';
716 $field_slug = 'obfuscate-author-slugs';
717
718 add_settings_field(
719 $field_id, // Field ID
720 'Obfuscate Author Slugs', // Field title
721 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
722 ASENHA_SLUG, // Settings page slug
723 'main-section', // Section ID
724 array(
725 'field_id' => $field_id, // Custom argument
726 'field_slug' => $field_slug, // Custom argument
727 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
728 'field_description' => 'Obfuscate publicly exposed author page URLs that shows the user slugs / usernames, e.g. <em>sitename.com/author/username1/</em> into <em>sitename.com/author/a6r5b8ytu9gp34bv/</em>, and output 404 errors for the original URLs. Also obfuscates in /wp-json/wp/v2/users/ REST API endpoint.', // Custom argument
729 'field_options_wrapper' => false, // Custom argument. Add container for additional options
730 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
731 )
732 );
733
734 // Disable XML-RPC
735
736 $field_id = 'disable_xmlrpc';
737 $field_slug = 'disable-xmlrpc';
738
739 add_settings_field(
740 $field_id, // Field ID
741 'Disable XML-RPC', // Field title
742 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
743 ASENHA_SLUG, // Settings page slug
744 'main-section', // Section ID
745 array(
746 'field_id' => $field_id, // Custom argument
747 'field_slug' => $field_slug, // Custom argument
748 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
749 'field_description' => 'Protect your site from brute force, DOS and DDOS attacks via <a href="https://kinsta.com/blog/xmlrpc-php/#what-is-xmlrpcphp" target="_blank">XML-RPC</a>. Also disables trackbacks and pingbacks. ', // Custom argument
750 'field_options_wrapper' => false, // Custom argument. Add container for additional options
751 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
752 )
753 );
754
755 // ===== UTILITIES ======
756
757 // Redirect After Login
758
759 $field_id = 'redirect_after_login';
760 $field_slug = 'redirect-after-login';
761
762 add_settings_field(
763 $field_id, // Field ID
764 'Redirect After Login', // Field title
765 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
766 ASENHA_SLUG, // Settings page slug
767 'main-section', // Section ID
768 array(
769 'field_id' => $field_id, // Custom argument
770 'field_slug' => $field_slug, // Custom argument
771 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
772 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
773 'field_options_wrapper' => true, // Custom argument. Add container for additional options
774 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
775 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
776 )
777 );
778
779 $field_id = 'redirect_after_login_to_slug';
780 $field_slug = 'redirect-after-login-to-slug';
781
782 add_settings_field(
783 $field_id, // Field ID
784 'Redirect to:', // Field title
785 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
786 ASENHA_SLUG, // Settings page slug
787 'main-section', // Section ID
788 array(
789 'field_id' => $field_id, // Custom argument
790 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
791 'field_type' => 'with-prefix-suffix', // Custom argument
792 'field_prefix' => get_site_url() . '/', // Custom argument
793 'field_suffix' => '/ for:', // Custom argument
794 'field_description' => '', // Custom argument
795 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
796 )
797 );
798
799 $field_id = 'redirect_after_login_for';
800 $field_slug = 'redirect-after-login-for';
801
802 if ( is_array( $roles ) ) {
803 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
804
805 add_settings_field(
806 $field_id . '_' . $role_slug, // Field ID
807 '', // Field title
808 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
809 ASENHA_SLUG, // Settings page slug
810 'main-section', // Section ID
811 array(
812 'parent_field_id' => $field_id, // Custom argument
813 'field_id' => $role_slug, // Custom argument
814 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
815 'field_label' => $role_label, // Custom argument
816 'class' => 'asenha-checkbox asenha-hide-th asenha-half utilities ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
817 )
818 );
819
820 }
821 }
822
823 // Redirect After Logout
824
825 $field_id = 'redirect_after_logout';
826 $field_slug = 'redirect-after-logout';
827
828 add_settings_field(
829 $field_id, // Field ID
830 'Redirect After Logout', // Field title
831 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
832 ASENHA_SLUG, // Settings page slug
833 'main-section', // Section ID
834 array(
835 'field_id' => $field_id, // Custom argument
836 'field_slug' => $field_slug, // Custom argument
837 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
838 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
839 'field_options_wrapper' => true, // Custom argument. Add container for additional options
840 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
841 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
842 )
843 );
844
845 $field_id = 'redirect_after_logout_to_slug';
846 $field_slug = 'redirect-after-logout-to-slug';
847
848 add_settings_field(
849 $field_id, // Field ID
850 'Redirect to:', // Field title
851 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
852 ASENHA_SLUG, // Settings page slug
853 'main-section', // Section ID
854 array(
855 'field_id' => $field_id, // Custom argument
856 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
857 'field_type' => 'with-prefix-suffix', // Custom argument
858 'field_prefix' => get_site_url() . '/', // Custom argument
859 'field_suffix' => '/ for:', // Custom argument
860 'field_description' => '', // Custom argument
861 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
862 )
863 );
864
865 $field_id = 'redirect_after_logout_for';
866 $field_slug = 'redirect-after-logout-for';
867
868 if ( is_array( $roles ) ) {
869 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
870
871 add_settings_field(
872 $field_id . '_' . $role_slug, // Field ID
873 '', // Field title
874 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
875 ASENHA_SLUG, // Settings page slug
876 'main-section', // Section ID
877 array(
878 'parent_field_id' => $field_id, // Custom argument
879 'field_id' => $role_slug, // Custom argument
880 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
881 'field_label' => $role_label, // Custom argument
882 'class' => 'asenha-checkbox asenha-hide-th asenha-half utilities ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
883 )
884 );
885
886 }
887 }
888
889 // Redirect 404 to Homepage
890
891 $field_id = 'redirect_404_to_homepage';
892 $field_slug = 'redirect-404-to-homepage';
893
894 add_settings_field(
895 $field_id, // Field ID
896 'Redirect 404 to Homepage', // Field title
897 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
898 ASENHA_SLUG, // Settings page slug
899 'main-section', // Section ID
900 array(
901 'field_id' => $field_id, // Custom argument
902 'field_slug' => $field_slug, // Custom argument
903 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
904 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
905 'field_options_wrapper' => true, // Custom argument. Add container for additional options
906 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
907 )
908 );
909
910 // Enable Custom Admin CSS
911
912 $field_id = 'enable_custom_admin_css';
913 $field_slug = 'enable-custom-admin-css';
914
915 add_settings_field(
916 $field_id, // Field ID
917 'Enable Custom Admin CSS', // Field title
918 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
919 ASENHA_SLUG, // Settings page slug
920 'main-section', // Section ID
921 array(
922 'field_id' => $field_id, // Custom argument
923 'field_slug' => $field_slug, // Custom argument
924 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
925 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
926 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
927 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
928 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
929 )
930 );
931
932 $field_id = 'custom_admin_css';
933 $field_slug = 'custom-admin-css';
934
935 add_settings_field(
936 $field_id, // Field ID
937 '', // Field title
938 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
939 ASENHA_SLUG, // Settings page slug
940 'main-section', // Section ID
941 array(
942 'field_id' => $field_id, // Custom argument
943 'field_slug' => $field_slug, // Custom argument
944 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
945 'field_type' => 'textarea', // Custom argument
946 'field_prefix' => '', // Custom argument
947 'field_suffix' => '', // Custom argument
948 'field_description' => '', // Custom argument
949 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
950 )
951 );
952
953 // Enable Custom Frontend CSS
954
955 $field_id = 'enable_custom_frontend_css';
956 $field_slug = 'enable-custom-frontend-css';
957
958 add_settings_field(
959 $field_id, // Field ID
960 'Enable Custom Frontend CSS', // Field title
961 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
962 ASENHA_SLUG, // Settings page slug
963 'main-section', // Section ID
964 array(
965 'field_id' => $field_id, // Custom argument
966 'field_slug' => $field_slug, // Custom argument
967 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
968 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
969 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
970 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
971 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
972 )
973 );
974
975 $field_id = 'custom_frontend_css';
976 $field_slug = 'custom-frontend-css';
977
978 add_settings_field(
979 $field_id, // Field ID
980 '', // Field title
981 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
982 ASENHA_SLUG, // Settings page slug
983 'main-section', // Section ID
984 array(
985 'field_id' => $field_id, // Custom argument
986 'field_slug' => $field_slug, // Custom argument
987 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
988 'field_type' => 'textarea', // Custom argument
989 'field_prefix' => '', // Custom argument
990 'field_suffix' => '', // Custom argument
991 'field_description' => '', // Custom argument
992 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
993 )
994 );
995
996 }
997
998 }