PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 3.6.1
Admin and Site Enhancements (ASE) v3.6.1
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-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-custom-code.php 3 years ago class-deactivation.php 3 years ago class-disable-components.php 3 years ago class-login-logout.php 3 years ago class-security.php 3 years ago class-settings-fields-render.php 3 years ago class-settings-sanitization.php 3 years ago class-settings-sections-fields.php 3 years ago class-utilities.php 3 years ago
class-settings-sections-fields.php
1442 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 // =================================================================
74 // CONTENT MANAGEMENT
75 // =================================================================
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 // Enable Auto-Publishing of Posts with Missed Schedules
164
165 $field_id = 'enable_missed_schedule_posts_auto_publish';
166 $field_slug = 'enable-missed-schedule-posts-auto-publish';
167
168 add_settings_field(
169 $field_id, // Field ID
170 'Enable Auto-Publishing of Posts with Missed Schedule', // 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' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument
179 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
180 )
181 );
182
183
184 // Enhance List Tables
185
186 $field_id = 'enhance_list_tables';
187 $field_slug = 'enhance-list-tables';
188
189 add_settings_field(
190 $field_id, // Field ID
191 'Enhance List Tables', // Field title
192 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
193 ASENHA_SLUG, // Settings page slug
194 'main-section', // Section ID
195 array(
196 'field_id' => $field_id, // Custom argument
197 'field_slug' => $field_slug, // Custom argument
198 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
199 'field_description' => 'Improve the usefulness of listing pages of various post types by adding / removing columns and elements.', // Custom argument
200 'field_options_wrapper' => true, // Custom argument. Add container for additional options
201 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
202 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
203 )
204 );
205
206 // Show Featured Image Column
207
208 $field_id = 'show_featured_image_column';
209 $field_slug = 'show-featured-image-column';
210
211 add_settings_field(
212 $field_id, // Field ID
213 '', // Field title
214 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
215 ASENHA_SLUG, // Settings page slug
216 'main-section', // Section ID
217 array(
218 'field_id' => $field_id, // Custom argument
219 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
220 'field_label' => 'Show featured image column.', // Custom argument
221 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
222 )
223 );
224
225 // Show Excerpt Column
226
227 $field_id = 'show_excerpt_column';
228 $field_slug = 'show-excerpt-column';
229
230 add_settings_field(
231 $field_id, // Field ID
232 '', // Field title
233 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
234 ASENHA_SLUG, // Settings page slug
235 'main-section', // Section ID
236 array(
237 'field_id' => $field_id, // Custom argument
238 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
239 'field_label' => 'Show excerpt column.', // Custom argument
240 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
241 )
242 );
243
244 // Show ID Column
245
246 $field_id = 'show_id_column';
247 $field_slug = 'show-id-column';
248
249 add_settings_field(
250 $field_id, // Field ID
251 '', // Field title
252 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
253 ASENHA_SLUG, // Settings page slug
254 'main-section', // Section ID
255 array(
256 'field_id' => $field_id, // Custom argument
257 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
258 'field_label' => 'Show ID column.', // Custom argument
259 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
260 )
261 );
262
263 // Hide Comments Column
264
265 $field_id = 'hide_comments_column';
266 $field_slug = 'hide-comments-column';
267
268 add_settings_field(
269 $field_id, // Field ID
270 '', // Field title
271 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
272 ASENHA_SLUG, // Settings page slug
273 'main-section', // Section ID
274 array(
275 'field_id' => $field_id, // Custom argument
276 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
277 'field_label' => 'Remove comments column.', // Custom argument
278 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
279 )
280 );
281
282 // Hide Post Tags Column
283
284 $field_id = 'hide_post_tags_column';
285 $field_slug = 'hide-post-tags-column';
286
287 add_settings_field(
288 $field_id, // Field ID
289 '', // Field title
290 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
291 ASENHA_SLUG, // Settings page slug
292 'main-section', // Section ID
293 array(
294 'field_id' => $field_id, // Custom argument
295 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
296 'field_label' => 'Remove tags column (for posts).', // Custom argument
297 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
298 )
299 );
300
301 // Show Custom Taxonomy Filters
302
303 $field_id = 'show_custom_taxonomy_filters';
304 $field_slug = 'show-custom-taxonomy-filters';
305
306 add_settings_field(
307 $field_id, // Field ID
308 '', // Field title
309 [ $render_field, 'render_checkbox_plain' ], // 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_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
315 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
316 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
317 )
318 );
319
320 // =================================================================
321 // ADMIN INTERFACE
322 // =================================================================
323
324 // Hide Admin Notices
325
326 $field_id = 'hide_admin_notices';
327 $field_slug = 'hide-admin-notices';
328
329 add_settings_field(
330 $field_id, // Field ID
331 'Hide Admin Notices', // Field title
332 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
333 ASENHA_SLUG, // Settings page slug
334 'main-section', // Section ID
335 array(
336 'field_id' => $field_id, // Custom argument
337 'field_slug' => $field_slug, // Custom argument
338 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
339 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
340 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
341 )
342 );
343
344 // View Admin as Role
345
346 $field_id = 'view_admin_as_role';
347 $field_slug = 'view-admin-as-role';
348
349 add_settings_field(
350 $field_id, // Field ID
351 'View Admin as Role', // Field title
352 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
353 ASENHA_SLUG, // Settings page slug
354 'main-section', // Section ID
355 array(
356 'field_id' => $field_id, // Custom argument
357 'field_slug' => $field_slug, // Custom argument
358 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
359 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
360 'field_options_wrapper' => true, // Custom argument. Add container for additional options
361 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
362 )
363 );
364
365 // Hide or Modify Elements
366
367 $field_id = 'hide_modify_elements';
368 $field_slug = 'hide-modify-elements';
369
370 add_settings_field(
371 $field_id, // Field ID
372 'Clean Up Admin Bar', // Field title
373 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
374 ASENHA_SLUG, // Settings page slug
375 'main-section', // Section ID
376 array(
377 'field_id' => $field_id, // Custom argument
378 'field_slug' => $field_slug, // Custom argument
379 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
380 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
381 'field_options_wrapper' => true, // Custom argument. Add container for additional options
382 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
383 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
384 )
385 );
386
387 $field_id = 'hide_ab_wp_logo_menu';
388 $field_slug = 'hide-ab-wp-logo-menu';
389
390 add_settings_field(
391 $field_id, // Field ID
392 '', // Field title
393 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
394 ASENHA_SLUG, // Settings page slug
395 'main-section', // Section ID
396 array(
397 'field_id' => $field_id, // Custom argument
398 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
399 'field_label' => 'Remove WordPress logo/menu', // Custom argument
400 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
401 )
402 );
403
404 $field_id = 'hide_ab_customize_menu';
405 $field_slug = 'hide-ab-customize-menu';
406
407 add_settings_field(
408 $field_id, // Field ID
409 '', // Field title
410 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
411 ASENHA_SLUG, // Settings page slug
412 'main-section', // Section ID
413 array(
414 'field_id' => $field_id, // Custom argument
415 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
416 'field_label' => 'Remove customize menu', // Custom argument
417 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
418 )
419 );
420
421 $field_id = 'hide_ab_updates_menu';
422 $field_slug = 'hide-ab-updates-menu';
423
424 add_settings_field(
425 $field_id, // Field ID
426 '', // Field title
427 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
428 ASENHA_SLUG, // Settings page slug
429 'main-section', // Section ID
430 array(
431 'field_id' => $field_id, // Custom argument
432 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
433 'field_label' => 'Remove updates counter/link', // Custom argument
434 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
435 )
436 );
437
438 $field_id = 'hide_ab_comments_menu';
439 $field_slug = 'hide-ab-comments-menu';
440
441 add_settings_field(
442 $field_id, // Field ID
443 '', // Field title
444 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
445 ASENHA_SLUG, // Settings page slug
446 'main-section', // Section ID
447 array(
448 'field_id' => $field_id, // Custom argument
449 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
450 'field_label' => 'Remove comments counter/link', // Custom argument
451 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
452 )
453 );
454
455 $field_id = 'hide_ab_new_content_menu';
456 $field_slug = 'hide-ab-new-content-menu';
457
458 add_settings_field(
459 $field_id, // Field ID
460 '', // Field title
461 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
462 ASENHA_SLUG, // Settings page slug
463 'main-section', // Section ID
464 array(
465 'field_id' => $field_id, // Custom argument
466 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
467 'field_label' => 'Remove new content menu', // Custom argument
468 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
469 )
470 );
471
472 $field_id = 'hide_ab_howdy';
473 $field_slug = 'hide-ab-howdy';
474
475 add_settings_field(
476 $field_id, // Field ID
477 '', // Field title
478 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
479 ASENHA_SLUG, // Settings page slug
480 'main-section', // Section ID
481 array(
482 'field_id' => $field_id, // Custom argument
483 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
484 'field_label' => 'Remove \'Howdy\'', // Custom argument
485 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
486 )
487 );
488
489 // Hide Admin Bar
490
491 $field_id = 'hide_admin_bar';
492 $field_slug = 'hide-admin-bar';
493
494 add_settings_field(
495 $field_id, // Field ID
496 'Hide Admin Bar', // Field title
497 [ $render_field, 'render_checkbox_toggle' ], // 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 'field_id' => $field_id, // Custom argument
502 'field_slug' => $field_slug, // Custom argument
503 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
504 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
505 'field_options_wrapper' => true, // Custom argument. Add container for additional options
506 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
507 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
508 )
509 );
510
511 $field_id = 'hide_admin_bar_for';
512 $field_slug = 'hide-admin-bar-for';
513
514 if ( is_array( $roles ) ) {
515 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
516
517 add_settings_field(
518 $field_id . '_' . $role_slug, // Field ID
519 '', // Field title
520 [ $render_field, 'render_checkbox_subfield' ], // 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 'parent_field_id' => $field_id, // Custom argument
525 'field_id' => $role_slug, // Custom argument
526 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
527 'field_label' => $role_label, // Custom argument
528 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
529 )
530 );
531
532 }
533 }
534
535 // Customize Admin Menu
536
537 $field_id = 'customize_admin_menu';
538 $field_slug = 'customize-admin-menu';
539
540 add_settings_field(
541 $field_id, // Field ID
542 'Admin Menu Organizer', // Field title
543 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
544 ASENHA_SLUG, // Settings page slug
545 'main-section', // Section ID
546 array(
547 'field_id' => $field_id, // Custom argument
548 'field_slug' => $field_slug, // Custom argument
549 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
550 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
551 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
552 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
553 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
554 )
555 );
556
557 $field_id = 'custom_menu_order';
558 $field_slug = 'custom-menu-order';
559
560 add_settings_field(
561 $field_id, // Field ID
562 '', // Field title
563 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
564 ASENHA_SLUG, // Settings page slug
565 'main-section', // Section ID
566 array(
567 'field_id' => $field_id, // Custom argument
568 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
569 'field_type' => 'sortable-menu', // Custom argument
570 'field_description' => '', // Custom argument
571 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
572 )
573 );
574
575 // =================================================================
576 // LOG IN | LOG OUT
577 // =================================================================
578
579 // Change Login URL
580
581 $field_id = 'change_login_url';
582 $field_slug = 'change-login-url';
583
584 add_settings_field(
585 $field_id, // Field ID
586 'Change Login URL', // Field title
587 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
588 ASENHA_SLUG, // Settings page slug
589 'main-section', // Section ID
590 array(
591 'field_id' => $field_id, // Custom argument
592 'field_slug' => $field_slug, // Custom argument
593 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
594 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
595 'field_options_wrapper' => true, // Custom argument. Add container for additional options
596 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
597 )
598 );
599
600 $field_id = 'custom_login_slug';
601 $field_slug = 'custom-login-slug';
602
603 add_settings_field(
604 $field_id, // Field ID
605 'New URL:', // Field title
606 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
607 ASENHA_SLUG, // Settings page slug
608 'main-section', // Section ID
609 array(
610 'field_id' => $field_id, // Custom argument
611 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
612 'field_type' => 'with-prefix-suffix', // Custom argument
613 'field_prefix' => get_site_url() . '/', // Custom argument
614 'field_suffix' => '/', // Custom argument
615 'field_description' => '', // Custom argument
616 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
617 )
618 );
619
620 // Enable Log In/Out Menu
621
622 $field_id = 'enable_login_logout_menu';
623 $field_slug = 'enable-login-logout-menu';
624
625 add_settings_field(
626 $field_id, // Field ID
627 'Enable Log In/Out Menu', // Field title
628 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
629 ASENHA_SLUG, // Settings page slug
630 'main-section', // Section ID
631 array(
632 'field_id' => $field_id, // Custom argument
633 'field_slug' => $field_slug, // Custom argument
634 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
635 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
636 'field_options_wrapper' => true, // Custom argument. Add container for additional options
637 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
638 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
639 )
640 );
641
642 // Enable Last Login Column
643
644 $field_id = 'enable_last_login_column';
645 $field_slug = 'enable-last-login-column';
646
647 add_settings_field(
648 $field_id, // Field ID
649 'Enable Last Login Column', // Field title
650 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
651 ASENHA_SLUG, // Settings page slug
652 'main-section', // Section ID
653 array(
654 'field_id' => $field_id, // Custom argument
655 'field_slug' => $field_slug, // Custom argument
656 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
657 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument
658 'field_options_wrapper' => true, // Custom argument. Add container for additional options
659 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
660 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
661 )
662 );
663
664 // Redirect After Login
665
666 $field_id = 'redirect_after_login';
667 $field_slug = 'redirect-after-login';
668
669 add_settings_field(
670 $field_id, // Field ID
671 'Redirect After Login', // Field title
672 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
673 ASENHA_SLUG, // Settings page slug
674 'main-section', // Section ID
675 array(
676 'field_id' => $field_id, // Custom argument
677 'field_slug' => $field_slug, // Custom argument
678 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
679 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
680 'field_options_wrapper' => true, // Custom argument. Add container for additional options
681 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
682 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
683 )
684 );
685
686 $field_id = 'redirect_after_login_to_slug';
687 $field_slug = 'redirect-after-login-to-slug';
688
689 add_settings_field(
690 $field_id, // Field ID
691 'Redirect to:', // Field title
692 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
693 ASENHA_SLUG, // Settings page slug
694 'main-section', // Section ID
695 array(
696 'field_id' => $field_id, // Custom argument
697 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
698 'field_type' => 'with-prefix-suffix', // Custom argument
699 'field_prefix' => get_site_url() . '/', // Custom argument
700 'field_suffix' => '/ for:', // Custom argument
701 'field_description' => '', // Custom argument
702 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
703 )
704 );
705
706 $field_id = 'redirect_after_login_for';
707 $field_slug = 'redirect-after-login-for';
708
709 if ( is_array( $roles ) ) {
710 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
711
712 add_settings_field(
713 $field_id . '_' . $role_slug, // Field ID
714 '', // Field title
715 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
716 ASENHA_SLUG, // Settings page slug
717 'main-section', // Section ID
718 array(
719 'parent_field_id' => $field_id, // Custom argument
720 'field_id' => $role_slug, // Custom argument
721 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
722 'field_label' => $role_label, // Custom argument
723 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
724 )
725 );
726
727 }
728 }
729
730 // Redirect After Logout
731
732 $field_id = 'redirect_after_logout';
733 $field_slug = 'redirect-after-logout';
734
735 add_settings_field(
736 $field_id, // Field ID
737 'Redirect After Logout', // Field title
738 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
739 ASENHA_SLUG, // Settings page slug
740 'main-section', // Section ID
741 array(
742 'field_id' => $field_id, // Custom argument
743 'field_slug' => $field_slug, // Custom argument
744 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
745 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
746 'field_options_wrapper' => true, // Custom argument. Add container for additional options
747 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
748 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
749 )
750 );
751
752 $field_id = 'redirect_after_logout_to_slug';
753 $field_slug = 'redirect-after-logout-to-slug';
754
755 add_settings_field(
756 $field_id, // Field ID
757 'Redirect to:', // Field title
758 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
759 ASENHA_SLUG, // Settings page slug
760 'main-section', // Section ID
761 array(
762 'field_id' => $field_id, // Custom argument
763 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
764 'field_type' => 'with-prefix-suffix', // Custom argument
765 'field_prefix' => get_site_url() . '/', // Custom argument
766 'field_suffix' => '/ for:', // Custom argument
767 'field_description' => '', // Custom argument
768 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
769 )
770 );
771
772 $field_id = 'redirect_after_logout_for';
773 $field_slug = 'redirect-after-logout-for';
774
775 if ( is_array( $roles ) ) {
776 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
777
778 add_settings_field(
779 $field_id . '_' . $role_slug, // Field ID
780 '', // Field title
781 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
782 ASENHA_SLUG, // Settings page slug
783 'main-section', // Section ID
784 array(
785 'parent_field_id' => $field_id, // Custom argument
786 'field_id' => $role_slug, // Custom argument
787 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
788 'field_label' => $role_label, // Custom argument
789 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
790 )
791 );
792
793 }
794 }
795
796 // =================================================================
797 // CUSTOM CODE
798 // =================================================================
799
800 // Enable Custom Admin CSS
801
802 $field_id = 'enable_custom_admin_css';
803 $field_slug = 'enable-custom-admin-css';
804
805 add_settings_field(
806 $field_id, // Field ID
807 'Enable Custom Admin CSS', // Field title
808 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
809 ASENHA_SLUG, // Settings page slug
810 'main-section', // Section ID
811 array(
812 'field_id' => $field_id, // Custom argument
813 'field_slug' => $field_slug, // Custom argument
814 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
815 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
816 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
817 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
818 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
819 )
820 );
821
822 $field_id = 'custom_admin_css';
823 $field_slug = 'custom-admin-css';
824
825 add_settings_field(
826 $field_id, // Field ID
827 '', // Field title
828 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
829 ASENHA_SLUG, // Settings page slug
830 'main-section', // Section ID
831 array(
832 'field_id' => $field_id, // Custom argument
833 'field_slug' => $field_slug, // Custom argument
834 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
835 'field_type' => 'textarea', // Custom argument
836 'field_intro' => '', // Custom argument
837 'field_description' => '', // Custom argument
838 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
839 )
840 );
841
842 // Enable Custom Frontend CSS
843
844 $field_id = 'enable_custom_frontend_css';
845 $field_slug = 'enable-custom-frontend-css';
846
847 add_settings_field(
848 $field_id, // Field ID
849 'Enable Custom Frontend CSS', // Field title
850 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
851 ASENHA_SLUG, // Settings page slug
852 'main-section', // Section ID
853 array(
854 'field_id' => $field_id, // Custom argument
855 'field_slug' => $field_slug, // Custom argument
856 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
857 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
858 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
859 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
860 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
861 )
862 );
863
864 $field_id = 'custom_frontend_css';
865 $field_slug = 'custom-frontend-css';
866
867 add_settings_field(
868 $field_id, // Field ID
869 '', // Field title
870 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
871 ASENHA_SLUG, // Settings page slug
872 'main-section', // Section ID
873 array(
874 'field_id' => $field_id, // Custom argument
875 'field_slug' => $field_slug, // Custom argument
876 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
877 'field_type' => 'textarea', // Custom argument
878 'field_intro' => '', // Custom argument
879 'field_description' => '', // Custom argument
880 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
881 )
882 );
883
884 // Manage ads.txt and app-ads.txt
885
886 $field_id = 'manage_ads_appads_txt';
887 $field_slug = 'manage-ads-appads-txt';
888
889 add_settings_field(
890 $field_id, // Field ID
891 'Manage ads.txt and app-ads.txt', // Field title
892 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
893 ASENHA_SLUG, // Settings page slug
894 'main-section', // Section ID
895 array(
896 'field_id' => $field_id, // Custom argument
897 'field_slug' => $field_slug, // Custom argument
898 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
899 '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
900 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
901 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
902 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
903 )
904 );
905
906 $field_id = 'ads_txt_content';
907 $field_slug = 'ads-txt-content';
908
909 add_settings_field(
910 $field_id, // Field ID
911 '', // Field title
912 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
913 ASENHA_SLUG, // Settings page slug
914 'main-section', // Section ID
915 array(
916 'field_id' => $field_id, // Custom argument
917 'field_slug' => $field_slug, // Custom argument
918 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
919 'field_type' => 'textarea', // Custom argument
920 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
921 '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
922 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
923 )
924 );
925
926 $field_id = 'app_ads_txt_content';
927 $field_slug = 'app-ads-txt-content';
928
929 add_settings_field(
930 $field_id, // Field ID
931 '', // Field title
932 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
933 ASENHA_SLUG, // Settings page slug
934 'main-section', // Section ID
935 array(
936 'field_id' => $field_id, // Custom argument
937 'field_slug' => $field_slug, // Custom argument
938 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
939 'field_type' => 'textarea', // Custom argument
940 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
941 '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
942 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
943 )
944 );
945
946 // Manage robots.txt
947
948 $field_id = 'manage_robots_txt';
949 $field_slug = 'manage-robots-txt';
950
951 add_settings_field(
952 $field_id, // Field ID
953 'Manage robots.txt', // Field title
954 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
955 ASENHA_SLUG, // Settings page slug
956 'main-section', // Section ID
957 array(
958 'field_id' => $field_id, // Custom argument
959 'field_slug' => $field_slug, // Custom argument
960 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
961 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument
962 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
963 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
964 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
965 )
966 );
967
968 $field_id = 'robots_txt_content';
969 $field_slug = 'robots-txt-content';
970
971 add_settings_field(
972 $field_id, // Field ID
973 '', // Field title
974 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
975 ASENHA_SLUG, // Settings page slug
976 'main-section', // Section ID
977 array(
978 'field_id' => $field_id, // Custom argument
979 'field_slug' => $field_slug, // Custom argument
980 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
981 'field_type' => 'textarea', // Custom argument
982 'field_intro' => '', // Custom argument
983 'field_description' => 'Validate with: <a href="https://en.ryte.com/free-tools/robots-txt/?refresh=1&url=' . urlencode( get_site_url( null, 'robots.txt' ) ) . '&useragent=Googlebot&submit=Evaluate" target="_blank">ryte.com</a> | <a href="https://serp.tools/tools/robots-txt" target="_blank">serp.tools</a><div class="vspacer"></div>', // Custom argument
984 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
985 )
986 );
987
988 // Insert <head>, <body> and <footer> code
989
990 $field_id = 'insert_head_body_footer_code';
991 $field_slug = 'insert-head-body-footer-code';
992
993 add_settings_field(
994 $field_id, // Field ID
995 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
996 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
997 ASENHA_SLUG, // Settings page slug
998 'main-section', // Section ID
999 array(
1000 'field_id' => $field_id, // Custom argument
1001 'field_slug' => $field_slug, // Custom argument
1002 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1003 '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
1004 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1005 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1006 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1007 )
1008 );
1009
1010 $field_id = 'head_code_priority';
1011 $field_slug = 'head-code-priority';
1012
1013 add_settings_field(
1014 $field_id, // Field ID
1015 '', // Field title
1016 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1017 ASENHA_SLUG, // Settings page slug
1018 'main-section', // Section ID
1019 array(
1020 'field_id' => $field_id, // Custom argument
1021 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1022 'field_type' => 'with-prefix-suffix', // Custom argument
1023 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1024 'field_suffix' => '', // Custom argument
1025 'field_intro' => '', // Custom argument
1026 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1027 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1028 )
1029 );
1030
1031 $field_id = 'head_code';
1032 $field_slug = 'head-code';
1033
1034 add_settings_field(
1035 $field_id, // Field ID
1036 '', // Field title
1037 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1038 ASENHA_SLUG, // Settings page slug
1039 'main-section', // Section ID
1040 array(
1041 'field_id' => $field_id, // Custom argument
1042 'field_slug' => $field_slug, // Custom argument
1043 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1044 'field_type' => 'textarea', // Custom argument
1045 'field_intro' => '', // Custom argument
1046 'field_description' => '', // Custom argument
1047 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1048 )
1049 );
1050
1051 $field_id = 'body_code_priority';
1052 $field_slug = 'body-code-priority';
1053
1054 add_settings_field(
1055 $field_id, // Field ID
1056 '', // Field title
1057 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1058 ASENHA_SLUG, // Settings page slug
1059 'main-section', // Section ID
1060 array(
1061 'field_id' => $field_id, // Custom argument
1062 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1063 'field_type' => 'with-prefix-suffix', // Custom argument
1064 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1065 'field_suffix' => '', // Custom argument
1066 'field_intro' => '', // Custom argument
1067 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1068 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1069 )
1070 );
1071
1072 $field_id = 'body_code';
1073 $field_slug = 'body-code';
1074
1075 add_settings_field(
1076 $field_id, // Field ID
1077 '', // Field title
1078 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1079 ASENHA_SLUG, // Settings page slug
1080 'main-section', // Section ID
1081 array(
1082 'field_id' => $field_id, // Custom argument
1083 'field_slug' => $field_slug, // Custom argument
1084 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1085 'field_type' => 'textarea', // Custom argument
1086 'field_intro' => '', // Custom argument
1087 'field_description' => '', // Custom argument
1088 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1089 )
1090 );
1091
1092 $field_id = 'footer_code_priority';
1093 $field_slug = 'footer-code-priority';
1094
1095 add_settings_field(
1096 $field_id, // Field ID
1097 '', // Field title
1098 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1099 ASENHA_SLUG, // Settings page slug
1100 'main-section', // Section ID
1101 array(
1102 'field_id' => $field_id, // Custom argument
1103 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1104 'field_type' => 'with-prefix-suffix', // Custom argument
1105 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1106 'field_suffix' => '', // Custom argument
1107 'field_intro' => '', // Custom argument
1108 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1109 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1110 )
1111 );
1112
1113 $field_id = 'footer_code';
1114 $field_slug = 'footer-code';
1115
1116 add_settings_field(
1117 $field_id, // Field ID
1118 '', // Field title
1119 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1120 ASENHA_SLUG, // Settings page slug
1121 'main-section', // Section ID
1122 array(
1123 'field_id' => $field_id, // Custom argument
1124 'field_slug' => $field_slug, // Custom argument
1125 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1126 'field_type' => 'textarea', // Custom argument
1127 'field_intro' => '', // Custom argument
1128 'field_description' => '', // Custom argument
1129 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1130 )
1131 );
1132
1133 // =================================================================
1134 // DISABLE COMPONENTS
1135 // =================================================================
1136
1137 // Disable Gutenberg
1138
1139 $field_id = 'disable_gutenberg';
1140 $field_slug = 'disable-gutenberg';
1141
1142 add_settings_field(
1143 $field_id, // Field ID
1144 'Disable Gutenberg', // Field title
1145 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1146 ASENHA_SLUG, // Settings page slug
1147 'main-section', // Section ID
1148 array(
1149 'field_id' => $field_id, // Custom argument
1150 'field_slug' => $field_slug, // Custom argument
1151 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1152 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
1153 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1154 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1155 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1156 )
1157 );
1158
1159 $field_id = 'disable_gutenberg_for';
1160 $field_slug = 'disable-gutenberg-for';
1161
1162 if ( is_array( $asenha_gutenberg_post_types ) ) {
1163 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1164 add_settings_field(
1165 $field_id . '_' . $post_type_slug, // Field ID
1166 '', // Field title
1167 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1168 ASENHA_SLUG, // Settings page slug
1169 'main-section', // Section ID
1170 array(
1171 'parent_field_id' => $field_id, // Custom argument
1172 'field_id' => $post_type_slug, // Custom argument
1173 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1174 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1175 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1176 )
1177 );
1178 }
1179 }
1180
1181 $field_id = 'disable_gutenberg_frontend_styles';
1182 $field_slug = 'disable-gutenberg-frontend-styles';
1183
1184 add_settings_field(
1185 $field_id, // Field ID
1186 '', // Field title
1187 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1188 ASENHA_SLUG, // Settings page slug
1189 'main-section', // Section ID
1190 array(
1191 'field_id' => $field_id, // Custom argument
1192 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1193 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
1194 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
1195 )
1196 );
1197
1198 // Disable Comments
1199
1200 $field_id = 'disable_comments';
1201 $field_slug = 'disable-comments';
1202
1203 add_settings_field(
1204 $field_id, // Field ID
1205 'Disable Comments', // Field title
1206 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1207 ASENHA_SLUG, // Settings page slug
1208 'main-section', // Section ID
1209 array(
1210 'field_id' => $field_id, // Custom argument
1211 'field_slug' => $field_slug, // Custom argument
1212 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1213 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
1214 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1215 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1216 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1217 )
1218 );
1219
1220 $field_id = 'disable_comments_for';
1221 $field_slug = 'disable-comments-for';
1222
1223 if ( is_array( $asenha_public_post_types ) ) {
1224 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1225 add_settings_field(
1226 $field_id . '_' . $post_type_slug, // Field ID
1227 '', // Field title
1228 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1229 ASENHA_SLUG, // Settings page slug
1230 'main-section', // Section ID
1231 array(
1232 'parent_field_id' => $field_id, // Custom argument
1233 'field_id' => $post_type_slug, // Custom argument
1234 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1235 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1236 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1237 )
1238 );
1239 }
1240 }
1241
1242 // Disable REST API
1243
1244 $field_id = 'disable_rest_api';
1245 $field_slug = 'disable-rest-api';
1246
1247 add_settings_field(
1248 $field_id, // Field ID
1249 'Disable REST API', // Field title
1250 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1251 ASENHA_SLUG, // Settings page slug
1252 'main-section', // Section ID
1253 array(
1254 'field_id' => $field_id, // Custom argument
1255 'field_slug' => $field_slug, // Custom argument
1256 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1257 '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
1258 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1259 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1260 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1261 )
1262 );
1263
1264 // Disable Feeds
1265
1266 $field_id = 'disable_feeds';
1267 $field_slug = 'disable-feeds';
1268
1269 add_settings_field(
1270 $field_id, // Field ID
1271 'Disable Feeds', // Field title
1272 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1273 ASENHA_SLUG, // Settings page slug
1274 'main-section', // Section ID
1275 array(
1276 'field_id' => $field_id, // Custom argument
1277 'field_slug' => $field_slug, // Custom argument
1278 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1279 '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
1280 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1281 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1282 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1283 )
1284 );
1285
1286 // =================================================================
1287 // SECURITY
1288 // =================================================================
1289
1290 // Limit Login Attempts
1291
1292 $field_id = 'limit_login_attempts';
1293 $field_slug = 'limit-login-attempts';
1294
1295 add_settings_field(
1296 $field_id, // Field ID
1297 'Limit Login Attempts', // Field title
1298 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1299 ASENHA_SLUG, // Settings page slug
1300 'main-section', // Section ID
1301 array(
1302 'field_id' => $field_id, // Custom argument
1303 'field_slug' => $field_slug, // Custom argument
1304 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1305 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
1306 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1307 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1308 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1309 )
1310 );
1311
1312 $field_id = 'login_fails_allowed';
1313 $field_slug = 'login-fails-allowed';
1314
1315 add_settings_field(
1316 $field_id, // Field ID
1317 '', // Field title
1318 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1319 ASENHA_SLUG, // Settings page slug
1320 'main-section', // Section ID
1321 array(
1322 'field_id' => $field_id, // Custom argument
1323 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1324 'field_type' => 'with-prefix-suffix', // Custom argument
1325 'field_prefix' => '', // Custom argument
1326 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
1327 'field_description' => '', // Custom argument
1328 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1329 )
1330 );
1331
1332 $field_id = 'login_lockout_maxcount';
1333 $field_slug = 'login-lockout-maxcount';
1334
1335 add_settings_field(
1336 $field_id, // Field ID
1337 '', // Field title
1338 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1339 ASENHA_SLUG, // Settings page slug
1340 'main-section', // Section ID
1341 array(
1342 'field_id' => $field_id, // Custom argument
1343 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1344 'field_type' => 'with-prefix-suffix', // Custom argument
1345 'field_prefix' => '', // Custom argument
1346 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
1347 'field_description' => '', // Custom argument
1348 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1349 )
1350 );
1351
1352 $field_id = 'login_attempts_log_table';
1353 $field_slug = 'login-attempts-log-table';
1354
1355 add_settings_field(
1356 $field_id, // Field ID
1357 '', // Field title
1358 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
1359 ASENHA_SLUG, // Settings page slug
1360 'main-section', // Section ID
1361 array(
1362 'field_id' => $field_id, // Custom argument
1363 'field_slug' => $field_slug, // Custom argument
1364 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1365 'field_type' => 'datatable', // Custom argument
1366 'field_description' => '', // Custom argument
1367 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
1368 'table_title' => 'Failed Login Attempts Log',
1369 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
1370 )
1371 );
1372
1373 // Obfuscate Author Slugs
1374
1375 $field_id = 'obfuscate_author_slugs';
1376 $field_slug = 'obfuscate-author-slugs';
1377
1378 add_settings_field(
1379 $field_id, // Field ID
1380 'Obfuscate Author Slugs', // Field title
1381 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1382 ASENHA_SLUG, // Settings page slug
1383 'main-section', // Section ID
1384 array(
1385 'field_id' => $field_id, // Custom argument
1386 'field_slug' => $field_slug, // Custom argument
1387 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1388 '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
1389 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1390 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1391 )
1392 );
1393
1394 // Disable XML-RPC
1395
1396 $field_id = 'disable_xmlrpc';
1397 $field_slug = 'disable-xmlrpc';
1398
1399 add_settings_field(
1400 $field_id, // Field ID
1401 'Disable XML-RPC', // Field title
1402 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1403 ASENHA_SLUG, // Settings page slug
1404 'main-section', // Section ID
1405 array(
1406 'field_id' => $field_id, // Custom argument
1407 'field_slug' => $field_slug, // Custom argument
1408 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1409 '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
1410 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1411 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1412 )
1413 );
1414
1415 // =================================================================
1416 // UTILITIES
1417 // =================================================================
1418
1419 // Redirect 404 to Homepage
1420
1421 $field_id = 'redirect_404_to_homepage';
1422 $field_slug = 'redirect-404-to-homepage';
1423
1424 add_settings_field(
1425 $field_id, // Field ID
1426 'Redirect 404 to Homepage', // Field title
1427 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1428 ASENHA_SLUG, // Settings page slug
1429 'main-section', // Section ID
1430 array(
1431 'field_id' => $field_id, // Custom argument
1432 'field_slug' => $field_slug, // Custom argument
1433 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1434 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
1435 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1436 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1437 )
1438 );
1439
1440 }
1441
1442 }