PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 3.4.0
Admin and Site Enhancements (ASE) v3.4.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
1359 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_settings_section(
22 'main-section', // Section ID
23 '', // Section title. Can be blank.
24 '', // Callback function to output section intro. Can be blank.
25 ASENHA_SLUG // Settings page slug
26 );
27
28 // Register main setttings
29
30 // Instantiate object for sanitization of settings fields values
31 $sanitization = new Settings_Sanitization;
32
33 // Instantiate object for rendering of settings fields for the admin page
34 $render_field = new Settings_Fields_Render;
35
36 register_setting(
37 ASENHA_ID, // Option group or option_page
38 ASENHA_SLUG_U, // Option name in wp_options table
39 array(
40 'type' => 'array', // 'string', 'boolean', 'integer', 'number', 'array', or 'object'
41 'description' => '', // A description of the data attached to this setting.
42 'sanitize_callback' => [ $sanitization, 'sanitize_for_options' ],
43 'show_in_rest' => false,
44 'default' => array(), // When calling get_option()
45 )
46 );
47
48 // Call WordPress globals required for the fields
49
50 global $wp_roles, $wpdb, $asenha_public_post_types, $asenha_gutenberg_post_types;
51
52 $roles = $wp_roles->get_names();
53
54 // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
55 $asenha_public_post_types = array();
56 $public_post_type_names = get_post_types( array( 'public' => true ), 'names' );
57 foreach( $public_post_type_names as $post_type_name ) {
58 $post_type_object = get_post_type_object( $post_type_name );
59 $asenha_public_post_types[$post_type_name] = $post_type_object->label;
60 }
61
62 // 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' )
63 $asenha_gutenberg_post_types = array();
64 $gutenberg_not_applicable_types = array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' );
65 $all_post_types = get_post_types( array(), 'objects' );
66 foreach ( $all_post_types as $post_type_slug => $post_type_info ) {
67 $asenha_gutenberg_post_types[$post_type_slug] = $post_type_info->label;
68 if ( in_array( $post_type_slug, $gutenberg_not_applicable_types ) ) {
69 unset( $asenha_gutenberg_post_types[$post_type_slug] );
70 }
71 }
72
73 // ===== CONTENT MANAGEMENT =====
74
75 // Enable Page and Post Duplication
76
77 $field_id = 'enable_duplication';
78 $field_slug = 'enable-duplication';
79
80 add_settings_field(
81 $field_id, // Field ID
82 'Enable Page and Post Duplication', // Field title
83 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
84 ASENHA_SLUG, // Settings page slug
85 'main-section', // Section ID
86 array(
87 'field_id' => $field_id, // Custom argument
88 'field_slug' => $field_slug, // Custom argument
89 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
90 '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
91 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
92 )
93 );
94
95 // Enable Media Replacement
96
97 $field_id = 'enable_media_replacement';
98 $field_slug = 'enable-media-replacement';
99
100 add_settings_field(
101 $field_id, // Field ID
102 'Enable Media Replacement', // Field title
103 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
104 ASENHA_SLUG, // Settings page slug
105 'main-section', // Section ID
106 array(
107 'field_id' => $field_id, // Custom argument
108 'field_slug' => $field_slug, // Custom argument
109 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
110 '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
111 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
112 )
113 );
114
115 // Enable SVG Upload
116
117 $field_id = 'enable_svg_upload';
118 $field_slug = 'enable-svg-upload';
119
120 add_settings_field(
121 $field_id, // Field ID
122 'Enable SVG Upload', // Field title
123 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
124 ASENHA_SLUG, // Settings page slug
125 'main-section', // Section ID
126 array(
127 'field_id' => $field_id, // Custom argument
128 'field_slug' => $field_slug, // Custom argument
129 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
130 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.', // Custom argument
131 'field_options_wrapper' => true, // Custom argument. Add container for additional options
132 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
133 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
134 )
135 );
136
137 $field_id = 'enable_svg_upload_for';
138 $field_slug = 'enable-svg-upload-for';
139
140 if ( is_array( $roles ) ) {
141 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
142
143 add_settings_field(
144 $field_id . '_' . $role_slug, // Field ID
145 '', // Field title
146 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
147 ASENHA_SLUG, // Settings page slug
148 'main-section', // Section ID
149 array(
150 'parent_field_id' => $field_id, // Custom argument
151 'field_id' => $role_slug, // Custom argument
152 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
153 'field_label' => $role_label, // Custom argument
154 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
155 )
156 );
157
158 }
159 }
160
161 // Enable Auto-Publishing of Posts with Missed Schedules
162
163 $field_id = 'enable_missed_schedule_posts_auto_publish';
164 $field_slug = 'enable-missed-schedule-posts-auto-publish';
165
166 add_settings_field(
167 $field_id, // Field ID
168 'Enable Auto-Publishing of Posts with Missed Schedule', // Field title
169 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
170 ASENHA_SLUG, // Settings page slug
171 'main-section', // Section ID
172 array(
173 'field_id' => $field_id, // Custom argument
174 'field_slug' => $field_slug, // Custom argument
175 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
176 'field_description' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument
177 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
178 )
179 );
180
181
182 // Enhance List Tables
183
184 $field_id = 'enhance_list_tables';
185 $field_slug = 'enhance-list-tables';
186
187 add_settings_field(
188 $field_id, // Field ID
189 'Enhance List Tables', // Field title
190 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
191 ASENHA_SLUG, // Settings page slug
192 'main-section', // Section ID
193 array(
194 'field_id' => $field_id, // Custom argument
195 'field_slug' => $field_slug, // Custom argument
196 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
197 'field_description' => 'Improve the usefulness of listing pages of various post types by adding / removing columns and elements.', // Custom argument
198 'field_options_wrapper' => true, // Custom argument. Add container for additional options
199 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
200 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
201 )
202 );
203
204 // Show Featured Image Column
205
206 $field_id = 'show_featured_image_column';
207 $field_slug = 'show-featured-image-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 featured image 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 Excerpt Column
224
225 $field_id = 'show_excerpt_column';
226 $field_slug = 'show-excerpt-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 excerpt column.', // Custom argument
238 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
239 )
240 );
241
242 // Show ID Column
243
244 $field_id = 'show_id_column';
245 $field_slug = 'show-id-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' => 'Show ID 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 Comments Column
262
263 $field_id = 'hide_comments_column';
264 $field_slug = 'hide-comments-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 comments column.', // Custom argument
276 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
277 )
278 );
279
280 // Hide Post Tags Column
281
282 $field_id = 'hide_post_tags_column';
283 $field_slug = 'hide-post-tags-column';
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' => 'Remove tags column (for posts).', // Custom argument
295 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
296 )
297 );
298
299 // Show Custom Taxonomy Filters
300
301 $field_id = 'show_custom_taxonomy_filters';
302 $field_slug = 'show-custom-taxonomy-filters';
303
304 add_settings_field(
305 $field_id, // Field ID
306 '', // Field title
307 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
308 ASENHA_SLUG, // Settings page slug
309 'main-section', // Section ID
310 array(
311 'field_id' => $field_id, // Custom argument
312 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
313 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
314 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
315 )
316 );
317
318 // ===== ADMIN INTERFACE =====
319
320 // Hide Admin Notices
321
322 $field_id = 'hide_admin_notices';
323 $field_slug = 'hide-admin-notices';
324
325 add_settings_field(
326 $field_id, // Field ID
327 'Hide Admin Notices', // Field title
328 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
329 ASENHA_SLUG, // Settings page slug
330 'main-section', // Section ID
331 array(
332 'field_id' => $field_id, // Custom argument
333 'field_slug' => $field_slug, // Custom argument
334 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
335 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
336 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
337 )
338 );
339
340 // View Admin as Role
341
342 $field_id = 'view_admin_as_role';
343 $field_slug = 'view-admin-as-role';
344
345 add_settings_field(
346 $field_id, // Field ID
347 'View Admin as Role', // Field title
348 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
349 ASENHA_SLUG, // Settings page slug
350 'main-section', // Section ID
351 array(
352 'field_id' => $field_id, // Custom argument
353 'field_slug' => $field_slug, // Custom argument
354 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
355 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
356 'field_options_wrapper' => true, // Custom argument. Add container for additional options
357 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
358 )
359 );
360
361 // Hide or Modify Elements
362
363 $field_id = 'hide_modify_elements';
364 $field_slug = 'hide-modify-elements';
365
366 add_settings_field(
367 $field_id, // Field ID
368 'Clean Up Admin Bar', // Field title
369 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
370 ASENHA_SLUG, // Settings page slug
371 'main-section', // Section ID
372 array(
373 'field_id' => $field_id, // Custom argument
374 'field_slug' => $field_slug, // Custom argument
375 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
376 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
377 'field_options_wrapper' => true, // Custom argument. Add container for additional options
378 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
379 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
380 )
381 );
382
383 $field_id = 'hide_ab_wp_logo_menu';
384 $field_slug = 'hide-ab-wp-logo-menu';
385
386 add_settings_field(
387 $field_id, // Field ID
388 '', // Field title
389 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
390 ASENHA_SLUG, // Settings page slug
391 'main-section', // Section ID
392 array(
393 'field_id' => $field_id, // Custom argument
394 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
395 'field_label' => 'Remove WordPress logo/menu', // Custom argument
396 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
397 )
398 );
399
400 $field_id = 'hide_ab_customize_menu';
401 $field_slug = 'hide-ab-customize-menu';
402
403 add_settings_field(
404 $field_id, // Field ID
405 '', // Field title
406 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
407 ASENHA_SLUG, // Settings page slug
408 'main-section', // Section ID
409 array(
410 'field_id' => $field_id, // Custom argument
411 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
412 'field_label' => 'Remove customize menu', // Custom argument
413 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
414 )
415 );
416
417 $field_id = 'hide_ab_updates_menu';
418 $field_slug = 'hide-ab-updates-menu';
419
420 add_settings_field(
421 $field_id, // Field ID
422 '', // Field title
423 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
424 ASENHA_SLUG, // Settings page slug
425 'main-section', // Section ID
426 array(
427 'field_id' => $field_id, // Custom argument
428 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
429 'field_label' => 'Remove updates counter/link', // Custom argument
430 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
431 )
432 );
433
434 $field_id = 'hide_ab_comments_menu';
435 $field_slug = 'hide-ab-comments-menu';
436
437 add_settings_field(
438 $field_id, // Field ID
439 '', // Field title
440 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
441 ASENHA_SLUG, // Settings page slug
442 'main-section', // Section ID
443 array(
444 'field_id' => $field_id, // Custom argument
445 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
446 'field_label' => 'Remove comments counter/link', // Custom argument
447 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
448 )
449 );
450
451 $field_id = 'hide_ab_new_content_menu';
452 $field_slug = 'hide-ab-new-content-menu';
453
454 add_settings_field(
455 $field_id, // Field ID
456 '', // Field title
457 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
458 ASENHA_SLUG, // Settings page slug
459 'main-section', // Section ID
460 array(
461 'field_id' => $field_id, // Custom argument
462 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
463 'field_label' => 'Remove new content menu', // Custom argument
464 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
465 )
466 );
467
468 $field_id = 'hide_ab_howdy';
469 $field_slug = 'hide-ab-howdy';
470
471 add_settings_field(
472 $field_id, // Field ID
473 '', // Field title
474 [ $render_field, 'render_checkbox_plain' ], // 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_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
480 'field_label' => 'Remove \'Howdy\'', // Custom argument
481 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
482 )
483 );
484
485 // Hide Admin Bar
486
487 $field_id = 'hide_admin_bar';
488 $field_slug = 'hide-admin-bar';
489
490 add_settings_field(
491 $field_id, // Field ID
492 'Hide Admin Bar', // Field title
493 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
494 ASENHA_SLUG, // Settings page slug
495 'main-section', // Section ID
496 array(
497 'field_id' => $field_id, // Custom argument
498 'field_slug' => $field_slug, // Custom argument
499 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
500 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
501 'field_options_wrapper' => true, // Custom argument. Add container for additional options
502 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
503 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
504 )
505 );
506
507 $field_id = 'hide_admin_bar_for';
508 $field_slug = 'hide-admin-bar-for';
509
510 if ( is_array( $roles ) ) {
511 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
512
513 add_settings_field(
514 $field_id . '_' . $role_slug, // Field ID
515 '', // Field title
516 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
517 ASENHA_SLUG, // Settings page slug
518 'main-section', // Section ID
519 array(
520 'parent_field_id' => $field_id, // Custom argument
521 'field_id' => $role_slug, // Custom argument
522 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
523 'field_label' => $role_label, // Custom argument
524 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
525 )
526 );
527
528 }
529 }
530
531 // Customize Admin Menu
532
533 $field_id = 'customize_admin_menu';
534 $field_slug = 'customize-admin-menu';
535
536 add_settings_field(
537 $field_id, // Field ID
538 'Admin Menu Organizer', // Field title
539 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
540 ASENHA_SLUG, // Settings page slug
541 'main-section', // Section ID
542 array(
543 'field_id' => $field_id, // Custom argument
544 'field_slug' => $field_slug, // Custom argument
545 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
546 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
547 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
548 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
549 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
550 )
551 );
552
553 $field_id = 'custom_menu_order';
554 $field_slug = 'custom-menu-order';
555
556 add_settings_field(
557 $field_id, // Field ID
558 '', // Field title
559 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
560 ASENHA_SLUG, // Settings page slug
561 'main-section', // Section ID
562 array(
563 'field_id' => $field_id, // Custom argument
564 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
565 'field_type' => 'sortable-menu', // Custom argument
566 'field_description' => '', // Custom argument
567 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
568 )
569 );
570
571 // ===== DISABLE COMPONENTS =====
572
573 // Disable Gutenberg
574
575 $field_id = 'disable_gutenberg';
576 $field_slug = 'disable-gutenberg';
577
578 add_settings_field(
579 $field_id, // Field ID
580 'Disable Gutenberg', // Field title
581 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
582 ASENHA_SLUG, // Settings page slug
583 'main-section', // Section ID
584 array(
585 'field_id' => $field_id, // Custom argument
586 'field_slug' => $field_slug, // Custom argument
587 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
588 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
589 'field_options_wrapper' => true, // Custom argument. Add container for additional options
590 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
591 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
592 )
593 );
594
595 $field_id = 'disable_gutenberg_for';
596 $field_slug = 'disable-gutenberg-for';
597
598 if ( is_array( $asenha_gutenberg_post_types ) ) {
599 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
600 add_settings_field(
601 $field_id . '_' . $post_type_slug, // Field ID
602 '', // Field title
603 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
604 ASENHA_SLUG, // Settings page slug
605 'main-section', // Section ID
606 array(
607 'parent_field_id' => $field_id, // Custom argument
608 'field_id' => $post_type_slug, // Custom argument
609 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
610 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
611 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
612 )
613 );
614 }
615 }
616
617 $field_id = 'disable_gutenberg_frontend_styles';
618 $field_slug = 'disable-gutenberg-frontend-styles';
619
620 add_settings_field(
621 $field_id, // Field ID
622 '', // Field title
623 [ $render_field, 'render_checkbox_plain' ], // 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_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
629 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
630 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
631 )
632 );
633
634 // Disable Comments
635
636 $field_id = 'disable_comments';
637 $field_slug = 'disable-comments';
638
639 add_settings_field(
640 $field_id, // Field ID
641 'Disable Comments', // Field title
642 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
643 ASENHA_SLUG, // Settings page slug
644 'main-section', // Section ID
645 array(
646 'field_id' => $field_id, // Custom argument
647 'field_slug' => $field_slug, // Custom argument
648 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
649 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
650 'field_options_wrapper' => true, // Custom argument. Add container for additional options
651 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
652 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
653 )
654 );
655
656 $field_id = 'disable_comments_for';
657 $field_slug = 'disable-comments-for';
658
659 if ( is_array( $asenha_public_post_types ) ) {
660 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
661 add_settings_field(
662 $field_id . '_' . $post_type_slug, // Field ID
663 '', // Field title
664 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
665 ASENHA_SLUG, // Settings page slug
666 'main-section', // Section ID
667 array(
668 'parent_field_id' => $field_id, // Custom argument
669 'field_id' => $post_type_slug, // Custom argument
670 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
671 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
672 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
673 )
674 );
675 }
676 }
677
678 // Disable REST API
679
680 $field_id = 'disable_rest_api';
681 $field_slug = 'disable-rest-api';
682
683 add_settings_field(
684 $field_id, // Field ID
685 'Disable REST API', // Field title
686 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
687 ASENHA_SLUG, // Settings page slug
688 'main-section', // Section ID
689 array(
690 'field_id' => $field_id, // Custom argument
691 'field_slug' => $field_slug, // Custom argument
692 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
693 'field_description' => 'Disable REST API access for non-authenticated users and remove URL traces from &lt;head&gt;, HTTP headers and WP RSD endpoint.', // Custom argument
694 'field_options_wrapper' => true, // Custom argument. Add container for additional options
695 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
696 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
697 )
698 );
699
700 // Disable Feeds
701
702 $field_id = 'disable_feeds';
703 $field_slug = 'disable-feeds';
704
705 add_settings_field(
706 $field_id, // Field ID
707 'Disable Feeds', // Field title
708 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
709 ASENHA_SLUG, // Settings page slug
710 'main-section', // Section ID
711 array(
712 'field_id' => $field_id, // Custom argument
713 'field_slug' => $field_slug, // Custom argument
714 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
715 'field_description' => 'Disable all RSS, Atom and RDF feeds. This includes feeds for posts, categories, tags, comments, authors and search. Also removes traces of feed URLs from &lt;head&gt;.', // Custom argument
716 'field_options_wrapper' => true, // Custom argument. Add container for additional options
717 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
718 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
719 )
720 );
721
722 // ===== SECURITY =====
723
724 // Change Login URL
725
726 $field_id = 'change_login_url';
727 $field_slug = 'change-login-url';
728
729 add_settings_field(
730 $field_id, // Field ID
731 'Change Login URL', // Field title
732 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
733 ASENHA_SLUG, // Settings page slug
734 'main-section', // Section ID
735 array(
736 'field_id' => $field_id, // Custom argument
737 'field_slug' => $field_slug, // Custom argument
738 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
739 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
740 'field_options_wrapper' => true, // Custom argument. Add container for additional options
741 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
742 )
743 );
744
745 $field_id = 'custom_login_slug';
746 $field_slug = 'custom-login-slug';
747
748 add_settings_field(
749 $field_id, // Field ID
750 'New URL:', // Field title
751 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
752 ASENHA_SLUG, // Settings page slug
753 'main-section', // Section ID
754 array(
755 'field_id' => $field_id, // Custom argument
756 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
757 'field_type' => 'with-prefix-suffix', // Custom argument
758 'field_prefix' => get_site_url() . '/', // Custom argument
759 'field_suffix' => '/', // Custom argument
760 'field_description' => '', // Custom argument
761 'class' => 'asenha-text with-prefix-suffix security ' . $field_slug, // Custom class for the <tr> element
762 )
763 );
764
765 // Limit Login Attempts
766
767 $field_id = 'limit_login_attempts';
768 $field_slug = 'limit-login-attempts';
769
770 add_settings_field(
771 $field_id, // Field ID
772 'Limit Login Attempts', // Field title
773 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
774 ASENHA_SLUG, // Settings page slug
775 'main-section', // Section ID
776 array(
777 'field_id' => $field_id, // Custom argument
778 'field_slug' => $field_slug, // Custom argument
779 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
780 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
781 'field_options_wrapper' => true, // Custom argument. Add container for additional options
782 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
783 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
784 )
785 );
786
787 $field_id = 'login_fails_allowed';
788 $field_slug = 'login-fails-allowed';
789
790 add_settings_field(
791 $field_id, // Field ID
792 '', // Field title
793 [ $render_field, 'render_text_subfield' ], // 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_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
799 'field_type' => 'with-prefix-suffix', // Custom argument
800 'field_prefix' => '', // Custom argument
801 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
802 'field_description' => '', // Custom argument
803 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
804 )
805 );
806
807 $field_id = 'login_lockout_maxcount';
808 $field_slug = 'login-lockout-maxcount';
809
810 add_settings_field(
811 $field_id, // Field ID
812 '', // Field title
813 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
814 ASENHA_SLUG, // Settings page slug
815 'main-section', // Section ID
816 array(
817 'field_id' => $field_id, // Custom argument
818 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
819 'field_type' => 'with-prefix-suffix', // Custom argument
820 'field_prefix' => '', // Custom argument
821 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
822 'field_description' => '', // Custom argument
823 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
824 )
825 );
826
827 $field_id = 'login_attempts_log_table';
828 $field_slug = 'login-attempts-log-table';
829
830 add_settings_field(
831 $field_id, // Field ID
832 '', // Field title
833 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
834 ASENHA_SLUG, // Settings page slug
835 'main-section', // Section ID
836 array(
837 'field_id' => $field_id, // Custom argument
838 'field_slug' => $field_slug, // Custom argument
839 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
840 'field_type' => 'datatable', // Custom argument
841 'field_description' => '', // Custom argument
842 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
843 'table_title' => 'Failed Login Attempts Log',
844 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
845 )
846 );
847
848 // Obfuscate Author Slugs
849
850 $field_id = 'obfuscate_author_slugs';
851 $field_slug = 'obfuscate-author-slugs';
852
853 add_settings_field(
854 $field_id, // Field ID
855 'Obfuscate Author Slugs', // Field title
856 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
857 ASENHA_SLUG, // Settings page slug
858 'main-section', // Section ID
859 array(
860 'field_id' => $field_id, // Custom argument
861 'field_slug' => $field_slug, // Custom argument
862 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
863 '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
864 'field_options_wrapper' => false, // Custom argument. Add container for additional options
865 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
866 )
867 );
868
869 // Disable XML-RPC
870
871 $field_id = 'disable_xmlrpc';
872 $field_slug = 'disable-xmlrpc';
873
874 add_settings_field(
875 $field_id, // Field ID
876 'Disable XML-RPC', // Field title
877 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
878 ASENHA_SLUG, // Settings page slug
879 'main-section', // Section ID
880 array(
881 'field_id' => $field_id, // Custom argument
882 'field_slug' => $field_slug, // Custom argument
883 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
884 '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
885 'field_options_wrapper' => false, // Custom argument. Add container for additional options
886 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
887 )
888 );
889
890 // ===== UTILITIES ======
891
892 // Enable Log In/Out Menu
893
894 $field_id = 'enable_login_logout_menu';
895 $field_slug = 'enable-login-logout-menu';
896
897 add_settings_field(
898 $field_id, // Field ID
899 'Enable Log In/Out Menu', // Field title
900 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
901 ASENHA_SLUG, // Settings page slug
902 'main-section', // Section ID
903 array(
904 'field_id' => $field_id, // Custom argument
905 'field_slug' => $field_slug, // Custom argument
906 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
907 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
908 'field_options_wrapper' => true, // Custom argument. Add container for additional options
909 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
910 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
911 )
912 );
913
914 // Redirect After Login
915
916 $field_id = 'redirect_after_login';
917 $field_slug = 'redirect-after-login';
918
919 add_settings_field(
920 $field_id, // Field ID
921 'Redirect After Login', // Field title
922 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
923 ASENHA_SLUG, // Settings page slug
924 'main-section', // Section ID
925 array(
926 'field_id' => $field_id, // Custom argument
927 'field_slug' => $field_slug, // Custom argument
928 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
929 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
930 'field_options_wrapper' => true, // Custom argument. Add container for additional options
931 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
932 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
933 )
934 );
935
936 $field_id = 'redirect_after_login_to_slug';
937 $field_slug = 'redirect-after-login-to-slug';
938
939 add_settings_field(
940 $field_id, // Field ID
941 'Redirect to:', // Field title
942 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
943 ASENHA_SLUG, // Settings page slug
944 'main-section', // Section ID
945 array(
946 'field_id' => $field_id, // Custom argument
947 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
948 'field_type' => 'with-prefix-suffix', // Custom argument
949 'field_prefix' => get_site_url() . '/', // Custom argument
950 'field_suffix' => '/ for:', // Custom argument
951 'field_description' => '', // Custom argument
952 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
953 )
954 );
955
956 $field_id = 'redirect_after_login_for';
957 $field_slug = 'redirect-after-login-for';
958
959 if ( is_array( $roles ) ) {
960 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
961
962 add_settings_field(
963 $field_id . '_' . $role_slug, // Field ID
964 '', // Field title
965 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
966 ASENHA_SLUG, // Settings page slug
967 'main-section', // Section ID
968 array(
969 'parent_field_id' => $field_id, // Custom argument
970 'field_id' => $role_slug, // Custom argument
971 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
972 'field_label' => $role_label, // Custom argument
973 'class' => 'asenha-checkbox asenha-hide-th asenha-half utilities ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
974 )
975 );
976
977 }
978 }
979
980 // Redirect After Logout
981
982 $field_id = 'redirect_after_logout';
983 $field_slug = 'redirect-after-logout';
984
985 add_settings_field(
986 $field_id, // Field ID
987 'Redirect After Logout', // Field title
988 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
989 ASENHA_SLUG, // Settings page slug
990 'main-section', // Section ID
991 array(
992 'field_id' => $field_id, // Custom argument
993 'field_slug' => $field_slug, // Custom argument
994 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
995 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
996 'field_options_wrapper' => true, // Custom argument. Add container for additional options
997 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
998 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
999 )
1000 );
1001
1002 $field_id = 'redirect_after_logout_to_slug';
1003 $field_slug = 'redirect-after-logout-to-slug';
1004
1005 add_settings_field(
1006 $field_id, // Field ID
1007 'Redirect to:', // Field title
1008 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1009 ASENHA_SLUG, // Settings page slug
1010 'main-section', // Section ID
1011 array(
1012 'field_id' => $field_id, // Custom argument
1013 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1014 'field_type' => 'with-prefix-suffix', // Custom argument
1015 'field_prefix' => get_site_url() . '/', // Custom argument
1016 'field_suffix' => '/ for:', // Custom argument
1017 'field_description' => '', // Custom argument
1018 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
1019 )
1020 );
1021
1022 $field_id = 'redirect_after_logout_for';
1023 $field_slug = 'redirect-after-logout-for';
1024
1025 if ( is_array( $roles ) ) {
1026 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
1027
1028 add_settings_field(
1029 $field_id . '_' . $role_slug, // Field ID
1030 '', // Field title
1031 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1032 ASENHA_SLUG, // Settings page slug
1033 'main-section', // Section ID
1034 array(
1035 'parent_field_id' => $field_id, // Custom argument
1036 'field_id' => $role_slug, // Custom argument
1037 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
1038 'field_label' => $role_label, // Custom argument
1039 'class' => 'asenha-checkbox asenha-hide-th asenha-half utilities ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
1040 )
1041 );
1042
1043 }
1044 }
1045
1046 // Redirect 404 to Homepage
1047
1048 $field_id = 'redirect_404_to_homepage';
1049 $field_slug = 'redirect-404-to-homepage';
1050
1051 add_settings_field(
1052 $field_id, // Field ID
1053 'Redirect 404 to Homepage', // Field title
1054 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1055 ASENHA_SLUG, // Settings page slug
1056 'main-section', // Section ID
1057 array(
1058 'field_id' => $field_id, // Custom argument
1059 'field_slug' => $field_slug, // Custom argument
1060 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1061 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
1062 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1063 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1064 )
1065 );
1066
1067 // Enable Custom Admin CSS
1068
1069 $field_id = 'enable_custom_admin_css';
1070 $field_slug = 'enable-custom-admin-css';
1071
1072 add_settings_field(
1073 $field_id, // Field ID
1074 'Enable Custom Admin CSS', // Field title
1075 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1076 ASENHA_SLUG, // Settings page slug
1077 'main-section', // Section ID
1078 array(
1079 'field_id' => $field_id, // Custom argument
1080 'field_slug' => $field_slug, // Custom argument
1081 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1082 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
1083 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1084 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1085 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1086 )
1087 );
1088
1089 $field_id = 'custom_admin_css';
1090 $field_slug = 'custom-admin-css';
1091
1092 add_settings_field(
1093 $field_id, // Field ID
1094 '', // Field title
1095 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1096 ASENHA_SLUG, // Settings page slug
1097 'main-section', // Section ID
1098 array(
1099 'field_id' => $field_id, // Custom argument
1100 'field_slug' => $field_slug, // Custom argument
1101 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1102 'field_type' => 'textarea', // Custom argument
1103 'field_intro' => '', // Custom argument
1104 'field_description' => '', // Custom argument
1105 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1106 )
1107 );
1108
1109 // Enable Custom Frontend CSS
1110
1111 $field_id = 'enable_custom_frontend_css';
1112 $field_slug = 'enable-custom-frontend-css';
1113
1114 add_settings_field(
1115 $field_id, // Field ID
1116 'Enable Custom Frontend CSS', // Field title
1117 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1118 ASENHA_SLUG, // Settings page slug
1119 'main-section', // Section ID
1120 array(
1121 'field_id' => $field_id, // Custom argument
1122 'field_slug' => $field_slug, // Custom argument
1123 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1124 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
1125 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1126 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1127 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1128 )
1129 );
1130
1131 $field_id = 'custom_frontend_css';
1132 $field_slug = 'custom-frontend-css';
1133
1134 add_settings_field(
1135 $field_id, // Field ID
1136 '', // Field title
1137 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1138 ASENHA_SLUG, // Settings page slug
1139 'main-section', // Section ID
1140 array(
1141 'field_id' => $field_id, // Custom argument
1142 'field_slug' => $field_slug, // Custom argument
1143 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1144 'field_type' => 'textarea', // Custom argument
1145 'field_intro' => '', // Custom argument
1146 'field_description' => '', // Custom argument
1147 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1148 )
1149 );
1150
1151 // Manage ads.txt and app-ads.txt
1152
1153 $field_id = 'manage_ads_appads_txt';
1154 $field_slug = 'manage-ads-appads-txt';
1155
1156 add_settings_field(
1157 $field_id, // Field ID
1158 'Manage ads.txt and app-ads.txt', // Field title
1159 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1160 ASENHA_SLUG, // Settings page slug
1161 'main-section', // Section ID
1162 array(
1163 'field_id' => $field_id, // Custom argument
1164 'field_slug' => $field_slug, // Custom argument
1165 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1166 'field_description' => 'Easily edit and validate your <a href="/ads.txt" target="_blank">ads.txt</a> and <a href="/app-ads.txt" target="_blank">app-ads.txt</a> content.', // Custom argument
1167 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1168 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1169 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1170 )
1171 );
1172
1173 $field_id = 'ads_txt_content';
1174 $field_slug = 'ads-txt-content';
1175
1176 add_settings_field(
1177 $field_id, // Field ID
1178 '', // Field title
1179 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1180 ASENHA_SLUG, // Settings page slug
1181 'main-section', // Section ID
1182 array(
1183 'field_id' => $field_id, // Custom argument
1184 'field_slug' => $field_slug, // Custom argument
1185 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1186 'field_type' => 'textarea', // Custom argument
1187 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
1188 'field_description' => 'Validate with: <a href="https://adstxt.guru/validator/url/?url=' . urlencode( get_site_url( null, 'ads.txt' ) ) . '" target="_blank">adstxt.guru</a> | <a href="https://www.adstxtvalidator.com/ads_txt/' . esc_attr( str_replace( '.', '-', $_SERVER['SERVER_NAME'] ) ) . '" target="_blank">adstxtvalidator.com</a><div class="vspacer"></div>', // Custom argument
1189 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1190 )
1191 );
1192
1193 $field_id = 'app_ads_txt_content';
1194 $field_slug = 'app-ads-txt-content';
1195
1196 add_settings_field(
1197 $field_id, // Field ID
1198 '', // Field title
1199 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1200 ASENHA_SLUG, // Settings page slug
1201 'main-section', // Section ID
1202 array(
1203 'field_id' => $field_id, // Custom argument
1204 'field_slug' => $field_slug, // Custom argument
1205 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1206 'field_type' => 'textarea', // Custom argument
1207 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
1208 'field_description' => 'Validate with: <a href="https://adstxt.guru/validator/url/?url=' . urlencode( get_site_url( null, 'app-ads.txt' ) ) . '" target="_blank">adstxt.guru</a>', // Custom argument
1209 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1210 )
1211 );
1212
1213 // Insert <head>, <body> and <footer> code
1214
1215 $field_id = 'insert_head_body_footer_code';
1216 $field_slug = 'insert-head-body-footer-code';
1217
1218 add_settings_field(
1219 $field_id, // Field ID
1220 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
1221 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1222 ASENHA_SLUG, // Settings page slug
1223 'main-section', // Section ID
1224 array(
1225 'field_id' => $field_id, // Custom argument
1226 'field_slug' => $field_slug, // Custom argument
1227 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1228 'field_description' => 'Easily insert &lt;meta&gt;, &lt;link&gt;, &lt;script&gt; and &lt;style&gt; tags, Google Analytics, Tag Manager, AdSense, Ads Conversion and Optimize code, Facebook, TikTok and Twitter pixels, etc.', // Custom argument
1229 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1230 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1231 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1232 )
1233 );
1234
1235 $field_id = 'head_code_priority';
1236 $field_slug = 'head-code-priority';
1237
1238 add_settings_field(
1239 $field_id, // Field ID
1240 '', // Field title
1241 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1242 ASENHA_SLUG, // Settings page slug
1243 'main-section', // Section ID
1244 array(
1245 'field_id' => $field_id, // Custom argument
1246 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1247 'field_type' => 'with-prefix-suffix', // Custom argument
1248 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1249 'field_suffix' => '', // Custom argument
1250 'field_intro' => '', // Custom argument
1251 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1252 'class' => 'asenha-number asenha-hide-th narrow utilities ' . $field_slug, // Custom class for the <tr> element
1253 )
1254 );
1255
1256 $field_id = 'head_code';
1257 $field_slug = 'head-code';
1258
1259 add_settings_field(
1260 $field_id, // Field ID
1261 '', // Field title
1262 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1263 ASENHA_SLUG, // Settings page slug
1264 'main-section', // Section ID
1265 array(
1266 'field_id' => $field_id, // Custom argument
1267 'field_slug' => $field_slug, // Custom argument
1268 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1269 'field_type' => 'textarea', // Custom argument
1270 'field_intro' => '', // Custom argument
1271 'field_description' => '', // Custom argument
1272 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1273 )
1274 );
1275
1276 $field_id = 'body_code_priority';
1277 $field_slug = 'body-code-priority';
1278
1279 add_settings_field(
1280 $field_id, // Field ID
1281 '', // Field title
1282 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1283 ASENHA_SLUG, // Settings page slug
1284 'main-section', // Section ID
1285 array(
1286 'field_id' => $field_id, // Custom argument
1287 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1288 'field_type' => 'with-prefix-suffix', // Custom argument
1289 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1290 'field_suffix' => '', // Custom argument
1291 'field_intro' => '', // Custom argument
1292 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1293 'class' => 'asenha-number asenha-hide-th narrow utilities ' . $field_slug, // Custom class for the <tr> element
1294 )
1295 );
1296
1297 $field_id = 'body_code';
1298 $field_slug = 'body-code';
1299
1300 add_settings_field(
1301 $field_id, // Field ID
1302 '', // Field title
1303 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1304 ASENHA_SLUG, // Settings page slug
1305 'main-section', // Section ID
1306 array(
1307 'field_id' => $field_id, // Custom argument
1308 'field_slug' => $field_slug, // Custom argument
1309 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1310 'field_type' => 'textarea', // Custom argument
1311 'field_intro' => '', // Custom argument
1312 'field_description' => '', // Custom argument
1313 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1314 )
1315 );
1316
1317 $field_id = 'footer_code_priority';
1318 $field_slug = 'footer-code-priority';
1319
1320 add_settings_field(
1321 $field_id, // Field ID
1322 '', // Field title
1323 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1324 ASENHA_SLUG, // Settings page slug
1325 'main-section', // Section ID
1326 array(
1327 'field_id' => $field_id, // Custom argument
1328 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1329 'field_type' => 'with-prefix-suffix', // Custom argument
1330 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1331 'field_suffix' => '', // Custom argument
1332 'field_intro' => '', // Custom argument
1333 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1334 'class' => 'asenha-number asenha-hide-th narrow utilities ' . $field_slug, // Custom class for the <tr> element
1335 )
1336 );
1337
1338 $field_id = 'footer_code';
1339 $field_slug = 'footer-code';
1340
1341 add_settings_field(
1342 $field_id, // Field ID
1343 '', // Field title
1344 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1345 ASENHA_SLUG, // Settings page slug
1346 'main-section', // Section ID
1347 array(
1348 'field_id' => $field_id, // Custom argument
1349 'field_slug' => $field_slug, // Custom argument
1350 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1351 'field_type' => 'textarea', // Custom argument
1352 'field_intro' => '', // Custom argument
1353 'field_description' => '', // Custom argument
1354 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted utilities ' . $field_slug, // Custom class for the <tr> element
1355 )
1356 );
1357 }
1358
1359 }