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