PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 4.7.4
Admin and Site Enhancements (ASE) v4.7.4
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-optimizations.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
2450 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 // =================================================================
49 // Call WordPress globals and set new globals required for the fields
50 // =================================================================
51
52 global $wp_roles, $wpdb, $asenha_public_post_types, $asenha_gutenberg_post_types, $asenha_revisions_post_types;
53
54 $roles = $wp_roles->get_names();
55
56 // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
57 $asenha_public_post_types = array();
58 $public_post_type_names = get_post_types( array( 'public' => true ), 'names' );
59 foreach( $public_post_type_names as $post_type_name ) {
60 $post_type_object = get_post_type_object( $post_type_name );
61 $asenha_public_post_types[$post_type_name] = $post_type_object->label;
62 }
63
64 // Get array of slugs and plural labels for post types that can be edited with the Gutenberg block editor, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
65 $asenha_gutenberg_post_types = array();
66 $gutenberg_not_applicable_types = array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' );
67 $all_post_types = get_post_types( array(), 'objects' );
68 foreach ( $all_post_types as $post_type_slug => $post_type_info ) {
69 $asenha_gutenberg_post_types[$post_type_slug] = $post_type_info->label;
70 if ( in_array( $post_type_slug, $gutenberg_not_applicable_types ) ) {
71 unset( $asenha_gutenberg_post_types[$post_type_slug] );
72 }
73 }
74
75 // Get array of slugs and plural labels for post types supporting revisions, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
76 $asenha_revisions_post_types = array();
77 foreach ( get_post_types( array(), 'names' ) as $post_type_slug ) { // post type slug/name
78 if ( post_type_supports( $post_type_slug, 'revisions' ) ) {
79 $post_type_object = get_post_type_object( $post_type_slug );
80 if ( property_exists( $post_type_object, 'label' ) ) {
81 $asenha_revisions_post_types[$post_type_slug] = $post_type_object->label;
82 }
83 }
84 }
85
86 // =================================================================
87 // CONTENT MANAGEMENT
88 // =================================================================
89
90 // Enable Page and Post Duplication
91
92 $field_id = 'enable_duplication';
93 $field_slug = 'enable-duplication';
94
95 add_settings_field(
96 $field_id, // Field ID
97 'Page and Post Duplication', // Field title
98 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
99 ASENHA_SLUG, // Settings page slug
100 'main-section', // Section ID
101 array(
102 'field_id' => $field_id, // Custom argument
103 'field_slug' => $field_slug, // Custom argument
104 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
105 '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
106 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
107 )
108 );
109
110 // Enable Media Replacement
111
112 $field_id = 'enable_media_replacement';
113 $field_slug = 'enable-media-replacement';
114
115 add_settings_field(
116 $field_id, // Field ID
117 'Media Replacement', // Field title
118 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
119 ASENHA_SLUG, // Settings page slug
120 'main-section', // Section ID
121 array(
122 'field_id' => $field_id, // Custom argument
123 'field_slug' => $field_slug, // Custom argument
124 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
125 '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
126 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
127 )
128 );
129
130 // Enable SVG Upload
131
132 $field_id = 'enable_svg_upload';
133 $field_slug = 'enable-svg-upload';
134
135 add_settings_field(
136 $field_id, // Field ID
137 'SVG Upload', // Field title
138 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
139 ASENHA_SLUG, // Settings page slug
140 'main-section', // Section ID
141 array(
142 'field_id' => $field_id, // Custom argument
143 'field_slug' => $field_slug, // Custom argument
144 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
145 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.', // Custom argument
146 'field_options_wrapper' => true, // Custom argument. Add container for additional options
147 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
148 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
149 )
150 );
151
152 $field_id = 'enable_svg_upload_for';
153 $field_slug = 'enable-svg-upload-for';
154
155 if ( is_array( $roles ) ) {
156 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
157
158 add_settings_field(
159 $field_id . '_' . $role_slug, // Field ID
160 '', // Field title
161 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
162 ASENHA_SLUG, // Settings page slug
163 'main-section', // Section ID
164 array(
165 'parent_field_id' => $field_id, // Custom argument
166 'field_id' => $role_slug, // Custom argument
167 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
168 'field_label' => $role_label, // Custom argument
169 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
170 )
171 );
172
173 }
174 }
175
176 // Enable External Permalinks
177
178 $field_id = 'enable_external_permalinks';
179 $field_slug = 'enable-external-permalinks';
180
181 add_settings_field(
182 $field_id, // Field ID
183 'External Permalinks', // Field title
184 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
185 ASENHA_SLUG, // Settings page slug
186 'main-section', // Section ID
187 array(
188 'field_id' => $field_id, // Custom argument
189 'field_slug' => $field_slug, // Custom argument
190 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
191 'field_description' => 'Enable pages, posts and/or custom post types to have permalinks that point to external URLs. Compatible with links added using <a href="https://wordpress.org/plugins/page-links-to/" target="_blank">Page Links To</a>.', // Custom argument
192 'field_options_wrapper' => true, // Custom argument. Add container for additional options
193 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
194 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
195 )
196 );
197
198 $field_id = 'enable_external_permalinks_for';
199 $field_slug = 'enable-external-permalinks-for';
200
201 if ( is_array( $asenha_public_post_types ) ) {
202 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
203 if ( 'attachment' != $post_type_slug ) {
204 add_settings_field(
205 $field_id . '_' . $post_type_slug, // Field ID
206 '', // Field title
207 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
208 ASENHA_SLUG, // Settings page slug
209 'main-section', // Section ID
210 array(
211 'parent_field_id' => $field_id, // Custom argument
212 'field_id' => $post_type_slug, // Custom argument
213 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
214 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
215 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
216 )
217 );
218 }
219 }
220 }
221
222 // Enable Auto-Publishing of Posts with Missed Schedules
223
224 $field_id = 'enable_missed_schedule_posts_auto_publish';
225 $field_slug = 'enable-missed-schedule-posts-auto-publish';
226
227 add_settings_field(
228 $field_id, // Field ID
229 'Auto-Publish Posts with Missed Schedule', // Field title
230 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
231 ASENHA_SLUG, // Settings page slug
232 'main-section', // Section ID
233 array(
234 'field_id' => $field_id, // Custom argument
235 'field_slug' => $field_slug, // Custom argument
236 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
237 'field_description' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument
238 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
239 )
240 );
241
242
243 // Enhance List Tables
244
245 $field_id = 'enhance_list_tables';
246 $field_slug = 'enhance-list-tables';
247
248 add_settings_field(
249 $field_id, // Field ID
250 'Enhance List Tables', // Field title
251 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
252 ASENHA_SLUG, // Settings page slug
253 'main-section', // Section ID
254 array(
255 'field_id' => $field_id, // Custom argument
256 'field_slug' => $field_slug, // Custom argument
257 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
258 'field_description' => 'Improve the usefulness of listing pages for various post types and taxonomies, media, comments and users by adding / removing columns and elements.', // Custom argument
259 'field_options_wrapper' => true, // Custom argument. Add container for additional options
260 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
261 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
262 )
263 );
264
265 // Show Featured Image Column
266
267 $field_id = 'show_featured_image_column';
268 $field_slug = 'show-featured-image-column';
269
270 add_settings_field(
271 $field_id, // Field ID
272 '', // Field title
273 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
274 ASENHA_SLUG, // Settings page slug
275 'main-section', // Section ID
276 array(
277 'field_id' => $field_id, // Custom argument
278 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
279 'field_label' => 'Show featured image column.', // Custom argument
280 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
281 )
282 );
283
284 // Show Excerpt Column
285
286 $field_id = 'show_excerpt_column';
287 $field_slug = 'show-excerpt-column';
288
289 add_settings_field(
290 $field_id, // Field ID
291 '', // Field title
292 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
293 ASENHA_SLUG, // Settings page slug
294 'main-section', // Section ID
295 array(
296 'field_id' => $field_id, // Custom argument
297 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
298 'field_label' => 'Show excerpt column.', // Custom argument
299 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
300 )
301 );
302
303 // Show ID Column
304
305 $field_id = 'show_id_column';
306 $field_slug = 'show-id-column';
307
308 add_settings_field(
309 $field_id, // Field ID
310 '', // Field title
311 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
312 ASENHA_SLUG, // Settings page slug
313 'main-section', // Section ID
314 array(
315 'field_id' => $field_id, // Custom argument
316 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
317 'field_label' => 'Show ID column.', // Custom argument
318 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
319 )
320 );
321
322 // Show ID in Action Row
323
324 $field_id = 'show_id_in_action_row';
325 $field_slug = 'show-id-in-action_row';
326
327 add_settings_field(
328 $field_id, // Field ID
329 '', // Field title
330 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
331 ASENHA_SLUG, // Settings page slug
332 'main-section', // Section ID
333 array(
334 'field_id' => $field_id, // Custom argument
335 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
336 'field_label' => 'Show ID in action rows along with links for Edit, View, etc.', // Custom argument
337 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
338 )
339 );
340
341 // Show Custom Taxonomy Filters
342
343 $field_id = 'show_custom_taxonomy_filters';
344 $field_slug = 'show-custom-taxonomy-filters';
345
346 add_settings_field(
347 $field_id, // Field ID
348 '', // Field title
349 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
350 ASENHA_SLUG, // Settings page slug
351 'main-section', // Section ID
352 array(
353 'field_id' => $field_id, // Custom argument
354 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
355 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
356 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
357 )
358 );
359
360 // Hide Comments Column
361
362 $field_id = 'hide_comments_column';
363 $field_slug = 'hide-comments-column';
364
365 add_settings_field(
366 $field_id, // Field ID
367 '', // Field title
368 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
369 ASENHA_SLUG, // Settings page slug
370 'main-section', // Section ID
371 array(
372 'field_id' => $field_id, // Custom argument
373 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
374 'field_label' => 'Remove comments column.', // Custom argument
375 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
376 )
377 );
378
379 // Hide Post Tags Column
380
381 $field_id = 'hide_post_tags_column';
382 $field_slug = 'hide-post-tags-column';
383
384 add_settings_field(
385 $field_id, // Field ID
386 '', // Field title
387 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
388 ASENHA_SLUG, // Settings page slug
389 'main-section', // Section ID
390 array(
391 'field_id' => $field_id, // Custom argument
392 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
393 'field_label' => 'Remove tags column (for posts).', // Custom argument
394 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
395 )
396 );
397
398 // =================================================================
399 // ADMIN INTERFACE
400 // =================================================================
401
402 // Hide Admin Notices
403
404 $field_id = 'hide_admin_notices';
405 $field_slug = 'hide-admin-notices';
406
407 add_settings_field(
408 $field_id, // Field ID
409 'Hide Admin Notices', // Field title
410 [ $render_field, 'render_checkbox_toggle' ], // 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_slug' => $field_slug, // Custom argument
416 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
417 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
418 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
419 )
420 );
421
422 // Disable Dashboard Widgets
423
424 $field_id = 'disable_dashboard_widgets';
425 $field_slug = 'disable-dashboard-widgets';
426
427 add_settings_field(
428 $field_id, // Field ID
429 'Disable Dashboard Widgets', // Field title
430 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
431 ASENHA_SLUG, // Settings page slug
432 'main-section', // Section ID
433 array(
434 'field_id' => $field_id, // Custom argument
435 'field_slug' => $field_slug, // Custom argument
436 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
437 'field_description' => 'Clean up and speed up the dashboard by completely disabling some or all widgets. Disabled widgets won\'t load any assets nor show up under Screen Options. ', // Custom argument
438 'field_options_wrapper' => true, // Custom argument. Add container for additional options
439 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
440 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
441 )
442 );
443
444 $field_id = 'disabled_dashboard_widgets';
445 $field_slug = 'disabled-dashboard-widgets';
446
447 $extra_options = get_option( 'admin_site_enhancements_extra', array() );
448 if ( array_key_exists( 'dashboard_widgets', $extra_options ) ) {
449 $dashboard_widgets = $extra_options['dashboard_widgets'];
450 } else {
451 $admin_interface = new Admin_Interface;
452 $dashboard_widgets = $admin_interface->get_dashboard_widgets();
453 $extra_options['dashboard_widgets'] = $dashboard_widgets;
454 update_option( 'admin_site_enhancements_extra', $extra_options );
455 }
456
457 foreach ( $dashboard_widgets as $widget ) {
458 add_settings_field(
459 $field_id . '_' . $widget['id'], // Field ID
460 '', // Field title
461 [ $render_field, 'render_checkbox_subfield' ], // 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 'parent_field_id' => $field_id, // Custom argument
466 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'], // Custom argument
467 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']', // Custom argument
468 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>', // Custom argument
469 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'], // Custom class for the <tr> element
470 )
471 );
472 }
473
474 // Hide or Modify Elements
475
476 $field_id = 'hide_modify_elements';
477 $field_slug = 'hide-modify-elements';
478
479 add_settings_field(
480 $field_id, // Field ID
481 'Clean Up Admin Bar', // Field title
482 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
483 ASENHA_SLUG, // Settings page slug
484 'main-section', // Section ID
485 array(
486 'field_id' => $field_id, // Custom argument
487 'field_slug' => $field_slug, // Custom argument
488 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
489 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
490 'field_options_wrapper' => true, // Custom argument. Add container for additional options
491 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
492 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
493 )
494 );
495
496 $field_id = 'hide_ab_wp_logo_menu';
497 $field_slug = 'hide-ab-wp-logo-menu';
498
499 add_settings_field(
500 $field_id, // Field ID
501 '', // Field title
502 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
503 ASENHA_SLUG, // Settings page slug
504 'main-section', // Section ID
505 array(
506 'field_id' => $field_id, // Custom argument
507 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
508 'field_label' => 'Remove WordPress logo/menu', // Custom argument
509 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
510 )
511 );
512
513 $field_id = 'hide_ab_customize_menu';
514 $field_slug = 'hide-ab-customize-menu';
515
516 add_settings_field(
517 $field_id, // Field ID
518 '', // Field title
519 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
520 ASENHA_SLUG, // Settings page slug
521 'main-section', // Section ID
522 array(
523 'field_id' => $field_id, // Custom argument
524 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
525 'field_label' => 'Remove customize menu', // Custom argument
526 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
527 )
528 );
529
530 $field_id = 'hide_ab_updates_menu';
531 $field_slug = 'hide-ab-updates-menu';
532
533 add_settings_field(
534 $field_id, // Field ID
535 '', // Field title
536 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
537 ASENHA_SLUG, // Settings page slug
538 'main-section', // Section ID
539 array(
540 'field_id' => $field_id, // Custom argument
541 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
542 'field_label' => 'Remove updates counter/link', // Custom argument
543 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
544 )
545 );
546
547 $field_id = 'hide_ab_comments_menu';
548 $field_slug = 'hide-ab-comments-menu';
549
550 add_settings_field(
551 $field_id, // Field ID
552 '', // Field title
553 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
554 ASENHA_SLUG, // Settings page slug
555 'main-section', // Section ID
556 array(
557 'field_id' => $field_id, // Custom argument
558 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
559 'field_label' => 'Remove comments counter/link', // Custom argument
560 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
561 )
562 );
563
564 $field_id = 'hide_ab_new_content_menu';
565 $field_slug = 'hide-ab-new-content-menu';
566
567 add_settings_field(
568 $field_id, // Field ID
569 '', // Field title
570 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
571 ASENHA_SLUG, // Settings page slug
572 'main-section', // Section ID
573 array(
574 'field_id' => $field_id, // Custom argument
575 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
576 'field_label' => 'Remove new content menu', // Custom argument
577 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
578 )
579 );
580
581 $field_id = 'hide_ab_howdy';
582 $field_slug = 'hide-ab-howdy';
583
584 add_settings_field(
585 $field_id, // Field ID
586 '', // Field title
587 [ $render_field, 'render_checkbox_plain' ], // 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_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
593 'field_label' => 'Remove \'Howdy\'', // Custom argument
594 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
595 )
596 );
597
598 $field_id = 'hide_help_drawer';
599 $field_slug = 'hide-help-drawer';
600
601 add_settings_field(
602 $field_id, // Field ID
603 '', // Field title
604 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
605 ASENHA_SLUG, // Settings page slug
606 'main-section', // Section ID
607 array(
608 'field_id' => $field_id, // Custom argument
609 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
610 'field_label' => 'Remove the Help tab and drawer', // Custom argument
611 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
612 )
613 );
614
615 // Hide Admin Bar
616
617 $field_id = 'hide_admin_bar';
618 $field_slug = 'hide-admin-bar';
619
620 add_settings_field(
621 $field_id, // Field ID
622 'Hide Admin Bar', // Field title
623 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
624 ASENHA_SLUG, // Settings page slug
625 'main-section', // Section ID
626 array(
627 'field_id' => $field_id, // Custom argument
628 'field_slug' => $field_slug, // Custom argument
629 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
630 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
631 'field_options_wrapper' => true, // Custom argument. Add container for additional options
632 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
633 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
634 )
635 );
636
637 $field_id = 'hide_admin_bar_for';
638 $field_slug = 'hide-admin-bar-for';
639
640 if ( is_array( $roles ) ) {
641 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
642
643 add_settings_field(
644 $field_id . '_' . $role_slug, // Field ID
645 '', // Field title
646 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
647 ASENHA_SLUG, // Settings page slug
648 'main-section', // Section ID
649 array(
650 'parent_field_id' => $field_id, // Custom argument
651 'field_id' => $role_slug, // Custom argument
652 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
653 'field_label' => $role_label, // Custom argument
654 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
655 )
656 );
657
658 }
659 }
660
661 // Customize Admin Menu
662
663 $field_id = 'customize_admin_menu';
664 $field_slug = 'customize-admin-menu';
665
666 add_settings_field(
667 $field_id, // Field ID
668 'Admin Menu Organizer', // Field title
669 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
670 ASENHA_SLUG, // Settings page slug
671 'main-section', // Section ID
672 array(
673 'field_id' => $field_id, // Custom argument
674 'field_slug' => $field_slug, // Custom argument
675 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
676 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
677 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
678 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
679 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
680 )
681 );
682
683 $field_id = 'custom_menu_order';
684 $field_slug = 'custom-menu-order';
685
686 add_settings_field(
687 $field_id, // Field ID
688 '', // Field title
689 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
690 ASENHA_SLUG, // Settings page slug
691 'main-section', // Section ID
692 array(
693 'field_id' => $field_id, // Custom argument
694 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
695 'field_type' => 'sortable-menu', // Custom argument
696 'field_description' => '', // Custom argument
697 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
698 )
699 );
700
701 // =================================================================
702 // LOG IN | LOG OUT
703 // =================================================================
704
705 // Change Login URL
706
707 $field_id = 'change_login_url';
708 $field_slug = 'change-login-url';
709
710 add_settings_field(
711 $field_id, // Field ID
712 'Change Login URL', // Field title
713 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
714 ASENHA_SLUG, // Settings page slug
715 'main-section', // Section ID
716 array(
717 'field_id' => $field_id, // Custom argument
718 'field_slug' => $field_slug, // Custom argument
719 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
720 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
721 'field_options_wrapper' => true, // Custom argument. Add container for additional options
722 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
723 )
724 );
725
726 $field_id = 'custom_login_slug';
727 $field_slug = 'custom-login-slug';
728
729 add_settings_field(
730 $field_id, // Field ID
731 'New URL:', // Field title
732 [ $render_field, 'render_text_subfield' ], // 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_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
738 'field_type' => 'with-prefix-suffix', // Custom argument
739 'field_prefix' => get_site_url() . '/', // Custom argument
740 'field_suffix' => '/', // Custom argument
741 'field_description' => '', // Custom argument
742 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
743 )
744 );
745
746 // Enable Log In/Out Menu
747
748 $field_id = 'enable_login_logout_menu';
749 $field_slug = 'enable-login-logout-menu';
750
751 add_settings_field(
752 $field_id, // Field ID
753 'Log In/Out Menu', // Field title
754 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
755 ASENHA_SLUG, // Settings page slug
756 'main-section', // Section ID
757 array(
758 'field_id' => $field_id, // Custom argument
759 'field_slug' => $field_slug, // Custom argument
760 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
761 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
762 'field_options_wrapper' => true, // Custom argument. Add container for additional options
763 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
764 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
765 )
766 );
767
768 // Enable Last Login Column
769
770 $field_id = 'enable_last_login_column';
771 $field_slug = 'enable-last-login-column';
772
773 add_settings_field(
774 $field_id, // Field ID
775 'Last Login Column', // Field title
776 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
777 ASENHA_SLUG, // Settings page slug
778 'main-section', // Section ID
779 array(
780 'field_id' => $field_id, // Custom argument
781 'field_slug' => $field_slug, // Custom argument
782 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
783 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument
784 'field_options_wrapper' => true, // Custom argument. Add container for additional options
785 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
786 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
787 )
788 );
789
790 // Redirect After Login
791
792 $field_id = 'redirect_after_login';
793 $field_slug = 'redirect-after-login';
794
795 add_settings_field(
796 $field_id, // Field ID
797 'Redirect After Login', // Field title
798 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
799 ASENHA_SLUG, // Settings page slug
800 'main-section', // Section ID
801 array(
802 'field_id' => $field_id, // Custom argument
803 'field_slug' => $field_slug, // Custom argument
804 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
805 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
806 'field_options_wrapper' => true, // Custom argument. Add container for additional options
807 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
808 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
809 )
810 );
811
812 $field_id = 'redirect_after_login_to_slug';
813 $field_slug = 'redirect-after-login-to-slug';
814
815 add_settings_field(
816 $field_id, // Field ID
817 'Redirect to:', // Field title
818 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
819 ASENHA_SLUG, // Settings page slug
820 'main-section', // Section ID
821 array(
822 'field_id' => $field_id, // Custom argument
823 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
824 'field_type' => 'with-prefix-suffix', // Custom argument
825 'field_prefix' => get_site_url() . '/', // Custom argument
826 'field_suffix' => '/ for:', // Custom argument
827 'field_description' => '', // Custom argument
828 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
829 )
830 );
831
832 $field_id = 'redirect_after_login_for';
833 $field_slug = 'redirect-after-login-for';
834
835 if ( is_array( $roles ) ) {
836 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
837
838 add_settings_field(
839 $field_id . '_' . $role_slug, // Field ID
840 '', // Field title
841 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
842 ASENHA_SLUG, // Settings page slug
843 'main-section', // Section ID
844 array(
845 'parent_field_id' => $field_id, // Custom argument
846 'field_id' => $role_slug, // Custom argument
847 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
848 'field_label' => $role_label, // Custom argument
849 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
850 )
851 );
852
853 }
854 }
855
856 // Redirect After Logout
857
858 $field_id = 'redirect_after_logout';
859 $field_slug = 'redirect-after-logout';
860
861 add_settings_field(
862 $field_id, // Field ID
863 'Redirect After Logout', // Field title
864 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
865 ASENHA_SLUG, // Settings page slug
866 'main-section', // Section ID
867 array(
868 'field_id' => $field_id, // Custom argument
869 'field_slug' => $field_slug, // Custom argument
870 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
871 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
872 'field_options_wrapper' => true, // Custom argument. Add container for additional options
873 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
874 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
875 )
876 );
877
878 $field_id = 'redirect_after_logout_to_slug';
879 $field_slug = 'redirect-after-logout-to-slug';
880
881 add_settings_field(
882 $field_id, // Field ID
883 'Redirect to:', // Field title
884 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
885 ASENHA_SLUG, // Settings page slug
886 'main-section', // Section ID
887 array(
888 'field_id' => $field_id, // Custom argument
889 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
890 'field_type' => 'with-prefix-suffix', // Custom argument
891 'field_prefix' => get_site_url() . '/', // Custom argument
892 'field_suffix' => '/ for:', // Custom argument
893 'field_description' => '', // Custom argument
894 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
895 )
896 );
897
898 $field_id = 'redirect_after_logout_for';
899 $field_slug = 'redirect-after-logout-for';
900
901 if ( is_array( $roles ) ) {
902 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
903
904 add_settings_field(
905 $field_id . '_' . $role_slug, // Field ID
906 '', // Field title
907 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
908 ASENHA_SLUG, // Settings page slug
909 'main-section', // Section ID
910 array(
911 'parent_field_id' => $field_id, // Custom argument
912 'field_id' => $role_slug, // Custom argument
913 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
914 'field_label' => $role_label, // Custom argument
915 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
916 )
917 );
918
919 }
920 }
921
922 // =================================================================
923 // CUSTOM CODE
924 // =================================================================
925
926 // Enable Custom Admin CSS
927
928 $field_id = 'enable_custom_admin_css';
929 $field_slug = 'enable-custom-admin-css';
930
931 add_settings_field(
932 $field_id, // Field ID
933 'Custom Admin CSS', // Field title
934 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
935 ASENHA_SLUG, // Settings page slug
936 'main-section', // Section ID
937 array(
938 'field_id' => $field_id, // Custom argument
939 'field_slug' => $field_slug, // Custom argument
940 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
941 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
942 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
943 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
944 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
945 )
946 );
947
948 $field_id = 'custom_admin_css';
949 $field_slug = 'custom-admin-css';
950
951 add_settings_field(
952 $field_id, // Field ID
953 '', // Field title
954 [ $render_field, 'render_textarea_subfield' ], // 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_type' => 'textarea', // Custom argument
962 'field_rows' => 30,
963 'field_intro' => '', // Custom argument
964 'field_description' => '', // Custom argument
965 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
966 )
967 );
968
969 // Enable Custom Frontend CSS
970
971 $field_id = 'enable_custom_frontend_css';
972 $field_slug = 'enable-custom-frontend-css';
973
974 add_settings_field(
975 $field_id, // Field ID
976 'Custom Frontend CSS', // Field title
977 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
978 ASENHA_SLUG, // Settings page slug
979 'main-section', // Section ID
980 array(
981 'field_id' => $field_id, // Custom argument
982 'field_slug' => $field_slug, // Custom argument
983 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
984 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
985 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
986 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
987 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
988 )
989 );
990
991 $field_id = 'custom_frontend_css';
992 $field_slug = 'custom-frontend-css';
993
994 add_settings_field(
995 $field_id, // Field ID
996 '', // Field title
997 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
998 ASENHA_SLUG, // Settings page slug
999 'main-section', // Section ID
1000 array(
1001 'field_id' => $field_id, // Custom argument
1002 'field_slug' => $field_slug, // Custom argument
1003 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1004 'field_type' => 'textarea', // Custom argument
1005 'field_rows' => 30,
1006 'field_intro' => '', // Custom argument
1007 'field_description' => '', // Custom argument
1008 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1009 )
1010 );
1011
1012 // Custom Body Class
1013
1014 $field_id = 'enable_custom_body_class';
1015 $field_slug = 'enable-custom-body-class';
1016
1017 add_settings_field(
1018 $field_id, // Field ID
1019 'Custom Body Class', // Field title
1020 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1021 ASENHA_SLUG, // Settings page slug
1022 'main-section', // Section ID
1023 array(
1024 'field_id' => $field_id, // Custom argument
1025 'field_slug' => $field_slug, // Custom argument
1026 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1027 'field_description' => 'Add custom &lt;body&gt; class(es) on the singular view of some or all public post types. Compatible with classes already added using <a href="https://wordpress.org/plugins/wp-custom-body-class" target="_blank">Custom Body Class plugin</a>.', // Custom argument
1028 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1029 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1030 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1031 )
1032 );
1033
1034 $field_id = 'enable_custom_body_class_for';
1035 $field_slug = 'enable-custom-body-class-for';
1036
1037 if ( is_array( $asenha_public_post_types ) ) {
1038 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1039 if ( 'attachment' != $post_type_slug ) {
1040 add_settings_field(
1041 $field_id . '_' . $post_type_slug, // Field ID
1042 '', // Field title
1043 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1044 ASENHA_SLUG, // Settings page slug
1045 'main-section', // Section ID
1046 array(
1047 'parent_field_id' => $field_id, // Custom argument
1048 'field_id' => $post_type_slug, // Custom argument
1049 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1050 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1051 'class' => 'asenha-checkbox asenha-hide-th asenha-half custom-code ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1052 )
1053 );
1054 }
1055 }
1056 }
1057
1058 // Manage ads.txt and app-ads.txt
1059
1060 $field_id = 'manage_ads_appads_txt';
1061 $field_slug = 'manage-ads-appads-txt';
1062
1063 add_settings_field(
1064 $field_id, // Field ID
1065 'Manage ads.txt and app-ads.txt', // Field title
1066 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1067 ASENHA_SLUG, // Settings page slug
1068 'main-section', // Section ID
1069 array(
1070 'field_id' => $field_id, // Custom argument
1071 'field_slug' => $field_slug, // Custom argument
1072 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1073 '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
1074 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1075 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1076 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1077 )
1078 );
1079
1080 $field_id = 'ads_txt_content';
1081 $field_slug = 'ads-txt-content';
1082
1083 add_settings_field(
1084 $field_id, // Field ID
1085 '', // Field title
1086 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1087 ASENHA_SLUG, // Settings page slug
1088 'main-section', // Section ID
1089 array(
1090 'field_id' => $field_id, // Custom argument
1091 'field_slug' => $field_slug, // Custom argument
1092 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1093 'field_type' => 'textarea', // Custom argument
1094 'field_rows' => 15,
1095 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
1096 '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
1097 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1098 )
1099 );
1100
1101 $field_id = 'app_ads_txt_content';
1102 $field_slug = 'app-ads-txt-content';
1103
1104 add_settings_field(
1105 $field_id, // Field ID
1106 '', // Field title
1107 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1108 ASENHA_SLUG, // Settings page slug
1109 'main-section', // Section ID
1110 array(
1111 'field_id' => $field_id, // Custom argument
1112 'field_slug' => $field_slug, // Custom argument
1113 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1114 'field_type' => 'textarea', // Custom argument
1115 'field_rows' => 15,
1116 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
1117 '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
1118 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1119 )
1120 );
1121
1122 // Manage robots.txt
1123
1124 $field_id = 'manage_robots_txt';
1125 $field_slug = 'manage-robots-txt';
1126
1127 add_settings_field(
1128 $field_id, // Field ID
1129 'Manage robots.txt', // Field title
1130 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1131 ASENHA_SLUG, // Settings page slug
1132 'main-section', // Section ID
1133 array(
1134 'field_id' => $field_id, // Custom argument
1135 'field_slug' => $field_slug, // Custom argument
1136 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1137 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument
1138 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1139 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1140 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1141 )
1142 );
1143
1144 $field_id = 'robots_txt_content';
1145 $field_slug = 'robots-txt-content';
1146
1147 add_settings_field(
1148 $field_id, // Field ID
1149 '', // Field title
1150 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1151 ASENHA_SLUG, // Settings page slug
1152 'main-section', // Section ID
1153 array(
1154 'field_id' => $field_id, // Custom argument
1155 'field_slug' => $field_slug, // Custom argument
1156 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1157 'field_type' => 'textarea', // Custom argument
1158 'field_rows' => 20,
1159 'field_intro' => '', // Custom argument
1160 '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
1161 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1162 )
1163 );
1164
1165 // Insert <head>, <body> and <footer> code
1166
1167 $field_id = 'insert_head_body_footer_code';
1168 $field_slug = 'insert-head-body-footer-code';
1169
1170 add_settings_field(
1171 $field_id, // Field ID
1172 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
1173 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1174 ASENHA_SLUG, // Settings page slug
1175 'main-section', // Section ID
1176 array(
1177 'field_id' => $field_id, // Custom argument
1178 'field_slug' => $field_slug, // Custom argument
1179 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1180 '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
1181 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1182 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1183 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1184 )
1185 );
1186
1187 $field_id = 'head_code_priority';
1188 $field_slug = 'head-code-priority';
1189
1190 add_settings_field(
1191 $field_id, // Field ID
1192 '', // Field title
1193 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1194 ASENHA_SLUG, // Settings page slug
1195 'main-section', // Section ID
1196 array(
1197 'field_id' => $field_id, // Custom argument
1198 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1199 'field_type' => 'with-prefix-suffix', // Custom argument
1200 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1201 'field_suffix' => '', // Custom argument
1202 'field_intro' => '', // Custom argument
1203 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1204 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1205 )
1206 );
1207
1208 $field_id = 'head_code';
1209 $field_slug = 'head-code';
1210
1211 add_settings_field(
1212 $field_id, // Field ID
1213 '', // Field title
1214 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1215 ASENHA_SLUG, // Settings page slug
1216 'main-section', // Section ID
1217 array(
1218 'field_id' => $field_id, // Custom argument
1219 'field_slug' => $field_slug, // Custom argument
1220 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1221 'field_type' => 'textarea', // Custom argument
1222 'field_rows' => 15,
1223 'field_intro' => '', // Custom argument
1224 'field_description' => '', // Custom argument
1225 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1226 )
1227 );
1228
1229 $field_id = 'body_code_priority';
1230 $field_slug = 'body-code-priority';
1231
1232 add_settings_field(
1233 $field_id, // Field ID
1234 '', // Field title
1235 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1236 ASENHA_SLUG, // Settings page slug
1237 'main-section', // Section ID
1238 array(
1239 'field_id' => $field_id, // Custom argument
1240 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1241 'field_type' => 'with-prefix-suffix', // Custom argument
1242 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1243 'field_suffix' => '', // Custom argument
1244 'field_intro' => '', // Custom argument
1245 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1246 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1247 )
1248 );
1249
1250 $field_id = 'body_code';
1251 $field_slug = 'body-code';
1252
1253 add_settings_field(
1254 $field_id, // Field ID
1255 '', // Field title
1256 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1257 ASENHA_SLUG, // Settings page slug
1258 'main-section', // Section ID
1259 array(
1260 'field_id' => $field_id, // Custom argument
1261 'field_slug' => $field_slug, // Custom argument
1262 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1263 'field_type' => 'textarea', // Custom argument
1264 'field_rows' => 15,
1265 'field_intro' => '', // Custom argument
1266 'field_description' => '', // Custom argument
1267 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1268 )
1269 );
1270
1271 $field_id = 'footer_code_priority';
1272 $field_slug = 'footer-code-priority';
1273
1274 add_settings_field(
1275 $field_id, // Field ID
1276 '', // Field title
1277 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1278 ASENHA_SLUG, // Settings page slug
1279 'main-section', // Section ID
1280 array(
1281 'field_id' => $field_id, // Custom argument
1282 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1283 'field_type' => 'with-prefix-suffix', // Custom argument
1284 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1285 'field_suffix' => '', // Custom argument
1286 'field_intro' => '', // Custom argument
1287 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1288 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1289 )
1290 );
1291
1292 $field_id = 'footer_code';
1293 $field_slug = 'footer-code';
1294
1295 add_settings_field(
1296 $field_id, // Field ID
1297 '', // Field title
1298 [ $render_field, 'render_textarea_subfield' ], // 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_type' => 'textarea', // Custom argument
1306 'field_rows' => 15,
1307 'field_intro' => '', // Custom argument
1308 'field_description' => '', // Custom argument
1309 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1310 )
1311 );
1312
1313 // =================================================================
1314 // DISABLE COMPONENTS
1315 // =================================================================
1316
1317 // Disable Gutenberg
1318
1319 $field_id = 'disable_gutenberg';
1320 $field_slug = 'disable-gutenberg';
1321
1322 add_settings_field(
1323 $field_id, // Field ID
1324 'Disable Gutenberg', // Field title
1325 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1326 ASENHA_SLUG, // Settings page slug
1327 'main-section', // Section ID
1328 array(
1329 'field_id' => $field_id, // Custom argument
1330 'field_slug' => $field_slug, // Custom argument
1331 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1332 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
1333 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1334 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1335 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1336 )
1337 );
1338
1339 $field_id = 'disable_gutenberg_for';
1340 $field_slug = 'disable-gutenberg-for';
1341
1342 if ( is_array( $asenha_gutenberg_post_types ) ) {
1343 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1344 add_settings_field(
1345 $field_id . '_' . $post_type_slug, // Field ID
1346 '', // Field title
1347 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1348 ASENHA_SLUG, // Settings page slug
1349 'main-section', // Section ID
1350 array(
1351 'parent_field_id' => $field_id, // Custom argument
1352 'field_id' => $post_type_slug, // Custom argument
1353 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1354 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1355 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1356 )
1357 );
1358 }
1359 }
1360
1361 $field_id = 'disable_gutenberg_frontend_styles';
1362 $field_slug = 'disable-gutenberg-frontend-styles';
1363
1364 add_settings_field(
1365 $field_id, // Field ID
1366 '', // Field title
1367 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1368 ASENHA_SLUG, // Settings page slug
1369 'main-section', // Section ID
1370 array(
1371 'field_id' => $field_id, // Custom argument
1372 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1373 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
1374 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
1375 )
1376 );
1377
1378 // Disable Comments
1379
1380 $field_id = 'disable_comments';
1381 $field_slug = 'disable-comments';
1382
1383 add_settings_field(
1384 $field_id, // Field ID
1385 'Disable Comments', // Field title
1386 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1387 ASENHA_SLUG, // Settings page slug
1388 'main-section', // Section ID
1389 array(
1390 'field_id' => $field_id, // Custom argument
1391 'field_slug' => $field_slug, // Custom argument
1392 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1393 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
1394 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1395 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1396 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1397 )
1398 );
1399
1400 $field_id = 'disable_comments_for';
1401 $field_slug = 'disable-comments-for';
1402
1403 if ( is_array( $asenha_public_post_types ) ) {
1404 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1405 add_settings_field(
1406 $field_id . '_' . $post_type_slug, // Field ID
1407 '', // Field title
1408 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1409 ASENHA_SLUG, // Settings page slug
1410 'main-section', // Section ID
1411 array(
1412 'parent_field_id' => $field_id, // Custom argument
1413 'field_id' => $post_type_slug, // Custom argument
1414 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1415 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1416 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1417 )
1418 );
1419 }
1420 }
1421
1422 // Disable REST API
1423
1424 $field_id = 'disable_rest_api';
1425 $field_slug = 'disable-rest-api';
1426
1427 add_settings_field(
1428 $field_id, // Field ID
1429 'Disable REST API', // Field title
1430 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1431 ASENHA_SLUG, // Settings page slug
1432 'main-section', // Section ID
1433 array(
1434 'field_id' => $field_id, // Custom argument
1435 'field_slug' => $field_slug, // Custom argument
1436 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1437 '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
1438 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1439 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1440 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1441 )
1442 );
1443
1444 // Disable Feeds
1445
1446 $field_id = 'disable_feeds';
1447 $field_slug = 'disable-feeds';
1448
1449 add_settings_field(
1450 $field_id, // Field ID
1451 'Disable Feeds', // Field title
1452 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1453 ASENHA_SLUG, // Settings page slug
1454 'main-section', // Section ID
1455 array(
1456 'field_id' => $field_id, // Custom argument
1457 'field_slug' => $field_slug, // Custom argument
1458 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1459 '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
1460 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1461 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1462 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1463 )
1464 );
1465
1466 // Disable Auto Updates
1467
1468 $field_id = 'disable_all_updates';
1469 $field_slug = 'disable-all-updates';
1470
1471 add_settings_field(
1472 $field_id, // Field ID
1473 'Disable All Updates', // Field title
1474 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1475 ASENHA_SLUG, // Settings page slug
1476 'main-section', // Section ID
1477 array(
1478 'field_id' => $field_id, // Custom argument
1479 'field_slug' => $field_slug, // Custom argument
1480 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1481 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', // Custom argument
1482 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1483 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1484 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1485 )
1486 );
1487
1488 // Disable Smaller Components
1489
1490 $field_id = 'disable_smaller_components';
1491 $field_slug = 'disable-smaller-components';
1492
1493 add_settings_field(
1494 $field_id, // Field ID
1495 'Disable Smaller Components', // Field title
1496 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1497 ASENHA_SLUG, // Settings page slug
1498 'main-section', // Section ID
1499 array(
1500 'field_id' => $field_id, // Custom argument
1501 'field_slug' => $field_slug, // Custom argument
1502 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1503 'field_description' => 'Prevent smaller components from running or loading. Make the site more secure and load slightly faster.', // Custom argument
1504 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1505 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1506 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
1507 )
1508 );
1509
1510 $field_id = 'disable_head_generator_tag';
1511 $field_slug = 'disable-head-generator-tag';
1512
1513 add_settings_field(
1514 $field_id, // Field ID
1515 '', // Field title
1516 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1517 ASENHA_SLUG, // Settings page slug
1518 'main-section', // Section ID
1519 array(
1520 'field_id' => $field_id, // Custom argument
1521 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1522 'field_label' => 'Disable the <strong>generator &lt;meta&gt; tag</strong> in &lt;head&gt;, which discloses the WordPress version number. Older versions(s) might contain unpatched security loophole(s).', // Custom argument
1523 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1524 )
1525 );
1526
1527 $field_id = 'disable_head_wlwmanifest_tag';
1528 $field_slug = 'disable-head-wlwmanifest-tag';
1529
1530 add_settings_field(
1531 $field_id, // Field ID
1532 '', // Field title
1533 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1534 ASENHA_SLUG, // Settings page slug
1535 'main-section', // Section ID
1536 array(
1537 'field_id' => $field_id, // Custom argument
1538 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1539 'field_label' => 'Disable the <strong>Windows Live Writer (WLW) manifest &lt;link&gt; tag</strong> in &lt;head&gt;. The WLW app was discontinued in 2017.', // Custom argument
1540 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1541 )
1542 );
1543
1544 $field_id = 'disable_head_rsd_tag';
1545 $field_slug = 'disable-head-rsd-tag';
1546
1547 add_settings_field(
1548 $field_id, // Field ID
1549 '', // Field title
1550 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1551 ASENHA_SLUG, // Settings page slug
1552 'main-section', // Section ID
1553 array(
1554 'field_id' => $field_id, // Custom argument
1555 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1556 'field_label' => 'Disable the <strong>Really Simple Discovery (RSD) &lt;link&gt; tag</strong> in &lt;head&gt;. It\'s not needed if your site is not using pingback or remote (XML-RPC) client to manage posts.', // Custom argument
1557 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1558 )
1559 );
1560
1561 $field_id = 'disable_head_shortlink_tag';
1562 $field_slug = 'disable-head-shortlink-tag';
1563
1564 add_settings_field(
1565 $field_id, // Field ID
1566 '', // Field title
1567 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1568 ASENHA_SLUG, // Settings page slug
1569 'main-section', // Section ID
1570 array(
1571 'field_id' => $field_id, // Custom argument
1572 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1573 'field_label' => 'Disable the default <strong>WordPress shortlink &lt;link&gt; tag</strong> in &lt;head&gt;. Ignored by search engines and has minimal practical use case. Usually, a dedicated shortlink plugin or service is preferred that allows for nice names in the short links and tracking of clicks when sharing the link on social media.', // Custom argument
1574 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1575 )
1576 );
1577
1578 $field_id = 'disable_frontend_dashicons';
1579 $field_slug = 'disable-frontend-dashicons';
1580
1581 add_settings_field(
1582 $field_id, // Field ID
1583 '', // Field title
1584 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1585 ASENHA_SLUG, // Settings page slug
1586 'main-section', // Section ID
1587 array(
1588 'field_id' => $field_id, // Custom argument
1589 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1590 'field_label' => 'Disable loading of <strong>dashicons CSS and JS files</strong> on the front-end for public site visitors.', // Custom argument
1591 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1592 )
1593 );
1594
1595 $field_id = 'disable_emoji_support';
1596 $field_slug = 'disable-emoji-support';
1597
1598 add_settings_field(
1599 $field_id, // Field ID
1600 '', // Field title
1601 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1602 ASENHA_SLUG, // Settings page slug
1603 'main-section', // Section ID
1604 array(
1605 'field_id' => $field_id, // Custom argument
1606 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1607 'field_label' => 'Disable <strong>emoji support for pages, posts and custom post types</strong> on the admin and frontend. The support is primarily useful for older browsers that do not have native support for it. Most modern browsers across different OSes and devices now have native support for it.', // Custom argument
1608 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1609 )
1610 );
1611
1612 // =================================================================
1613 // SECURITY
1614 // =================================================================
1615
1616 // Limit Login Attempts
1617
1618 $field_id = 'limit_login_attempts';
1619 $field_slug = 'limit-login-attempts';
1620
1621 add_settings_field(
1622 $field_id, // Field ID
1623 'Limit Login Attempts', // Field title
1624 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1625 ASENHA_SLUG, // Settings page slug
1626 'main-section', // Section ID
1627 array(
1628 'field_id' => $field_id, // Custom argument
1629 'field_slug' => $field_slug, // Custom argument
1630 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1631 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
1632 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1633 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1634 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1635 )
1636 );
1637
1638 $field_id = 'login_fails_allowed';
1639 $field_slug = 'login-fails-allowed';
1640
1641 add_settings_field(
1642 $field_id, // Field ID
1643 '', // Field title
1644 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1645 ASENHA_SLUG, // Settings page slug
1646 'main-section', // Section ID
1647 array(
1648 'field_id' => $field_id, // Custom argument
1649 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1650 'field_type' => 'with-prefix-suffix', // Custom argument
1651 'field_prefix' => '', // Custom argument
1652 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
1653 'field_description' => '', // Custom argument
1654 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1655 )
1656 );
1657
1658 $field_id = 'login_lockout_maxcount';
1659 $field_slug = 'login-lockout-maxcount';
1660
1661 add_settings_field(
1662 $field_id, // Field ID
1663 '', // Field title
1664 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1665 ASENHA_SLUG, // Settings page slug
1666 'main-section', // Section ID
1667 array(
1668 'field_id' => $field_id, // Custom argument
1669 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1670 'field_type' => 'with-prefix-suffix', // Custom argument
1671 'field_prefix' => '', // Custom argument
1672 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
1673 'field_description' => '', // Custom argument
1674 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1675 )
1676 );
1677
1678 $field_id = 'login_attempts_log_table';
1679 $field_slug = 'login-attempts-log-table';
1680
1681 add_settings_field(
1682 $field_id, // Field ID
1683 '', // Field title
1684 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
1685 ASENHA_SLUG, // Settings page slug
1686 'main-section', // Section ID
1687 array(
1688 'field_id' => $field_id, // Custom argument
1689 'field_slug' => $field_slug, // Custom argument
1690 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1691 'field_type' => 'datatable', // Custom argument
1692 'field_description' => '', // Custom argument
1693 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
1694 'table_title' => 'Failed Login Attempts Log',
1695 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
1696 )
1697 );
1698
1699 // Obfuscate Author Slugs
1700
1701 $field_id = 'obfuscate_author_slugs';
1702 $field_slug = 'obfuscate-author-slugs';
1703
1704 add_settings_field(
1705 $field_id, // Field ID
1706 'Obfuscate Author Slugs', // Field title
1707 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1708 ASENHA_SLUG, // Settings page slug
1709 'main-section', // Section ID
1710 array(
1711 'field_id' => $field_id, // Custom argument
1712 'field_slug' => $field_slug, // Custom argument
1713 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1714 '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
1715 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1716 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1717 )
1718 );
1719
1720 // Disable XML-RPC
1721
1722 $field_id = 'disable_xmlrpc';
1723 $field_slug = 'disable-xmlrpc';
1724
1725 add_settings_field(
1726 $field_id, // Field ID
1727 'Disable XML-RPC', // Field title
1728 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1729 ASENHA_SLUG, // Settings page slug
1730 'main-section', // Section ID
1731 array(
1732 'field_id' => $field_id, // Custom argument
1733 'field_slug' => $field_slug, // Custom argument
1734 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1735 '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
1736 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1737 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1738 )
1739 );
1740
1741 // =================================================================
1742 // OPTIMIZATIONS
1743 // =================================================================
1744
1745 // Image Upload Control
1746
1747 $field_id = 'image_upload_control';
1748 $field_slug = 'image-upload-control';
1749
1750 add_settings_field(
1751 $field_id, // Field ID
1752 'Image Upload Control', // Field title
1753 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1754 ASENHA_SLUG, // Settings page slug
1755 'main-section', // Section ID
1756 array(
1757 'field_id' => $field_id, // Custom argument
1758 'field_slug' => $field_slug, // Custom argument
1759 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1760 'field_description' => 'Resize newly uploaded, large images to a smaller dimension and delete originally uploaded files. BMPs and non-transparent PNGs will be converted to JPGs and resized.', // Custom argument
1761 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1762 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1763 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1764 )
1765 );
1766
1767 $field_id = 'image_max_width';
1768 $field_slug = 'image-max-width';
1769
1770 add_settings_field(
1771 $field_id, // Field ID
1772 '', // Field title
1773 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1774 ASENHA_SLUG, // Settings page slug
1775 'main-section', // Section ID
1776 array(
1777 'field_id' => $field_id, // Custom argument
1778 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1779 'field_type' => 'with-prefix-suffix', // Custom argument
1780 'field_prefix' => 'Max width:', // Custom argument
1781 'field_suffix' => 'pixels. <span class="faded">(Default is 1920 pixels)</span>', // Custom argument
1782 'field_intro' => '', // Custom argument
1783 'field_description' => '', // Custom argument
1784 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1785 )
1786 );
1787
1788 $field_id = 'image_max_height';
1789 $field_slug = 'image-max-height';
1790
1791 add_settings_field(
1792 $field_id, // Field ID
1793 '', // Field title
1794 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1795 ASENHA_SLUG, // Settings page slug
1796 'main-section', // Section ID
1797 array(
1798 'field_id' => $field_id, // Custom argument
1799 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1800 'field_type' => 'with-prefix-suffix', // Custom argument
1801 'field_prefix' => 'Max height:', // Custom argument
1802 'field_suffix' => 'pixels <span class="faded">(Default is 1920 pixels)</span>', // Custom argument
1803 'field_intro' => '', // Custom argument
1804 'field_description' => 'To exclude an image from conversion and resizing, append \'-nr\' suffix to the file name, e.g. bird-photo-4k-nr.jpg', // Custom argument
1805 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1806 )
1807 );
1808
1809 // Enable Revisions Control
1810
1811 $field_id = 'enable_revisions_control';
1812 $field_slug = 'enable-revisions-control';
1813
1814 add_settings_field(
1815 $field_id, // Field ID
1816 'Revisions Control', // Field title
1817 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1818 ASENHA_SLUG, // Settings page slug
1819 'main-section', // Section ID
1820 array(
1821 'field_id' => $field_id, // Custom argument
1822 'field_slug' => $field_slug, // Custom argument
1823 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1824 'field_description' => 'Prevent bloating the database by limiting the number of revisions to keep for some or all post types supporting revisions.', // Custom argument
1825 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1826 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1827 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1828 )
1829 );
1830
1831 $field_id = 'revisions_max_number';
1832 $field_slug = 'revisions-max-number';
1833
1834 add_settings_field(
1835 $field_id, // Field ID
1836 '', // Field title
1837 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1838 ASENHA_SLUG, // Settings page slug
1839 'main-section', // Section ID
1840 array(
1841 'field_id' => $field_id, // Custom argument
1842 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1843 'field_type' => 'with-prefix-suffix', // Custom argument
1844 'field_prefix' => 'Limit to', // Custom argument
1845 'field_suffix' => 'revisions for:', // Custom argument
1846 'field_intro' => '', // Custom argument
1847 'field_description' => '', // Custom argument
1848 'class' => 'asenha-number asenha-hide-th extra-narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1849 )
1850 );
1851
1852 $field_id = 'enable_revisions_control_for';
1853 $field_slug = 'enable-revisions-control-for';
1854
1855 if ( is_array( $asenha_revisions_post_types ) ) {
1856 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1857 add_settings_field(
1858 $field_id . '_' . $post_type_slug, // Field ID
1859 '', // Field title
1860 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1861 ASENHA_SLUG, // Settings page slug
1862 'main-section', // Section ID
1863 array(
1864 'parent_field_id' => $field_id, // Custom argument
1865 'field_id' => $post_type_slug, // Custom argument
1866 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1867 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1868 'class' => 'asenha-checkbox asenha-hide-th asenha-half optimizations ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1869 )
1870 );
1871 }
1872 }
1873
1874 // Enable Heartbeat Control
1875
1876 $field_id = 'enable_heartbeat_control';
1877 $field_slug = 'enable-heartbeat-control';
1878
1879 add_settings_field(
1880 $field_id, // Field ID
1881 'Heartbeat Control', // Field title
1882 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1883 ASENHA_SLUG, // Settings page slug
1884 'main-section', // Section ID
1885 array(
1886 'field_id' => $field_id, // Custom argument
1887 'field_slug' => $field_slug, // Custom argument
1888 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1889 'field_description' => 'Modify the interval of the WordPress heartbeat API or disable it on admin pages, post creation/edit screens and/or the frontend. This will help reduce CPU load on the server.', // Custom argument
1890 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1891 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1892 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1893 )
1894 );
1895
1896 $field_id = 'heartbeat_control_for_admin_pages';
1897 $field_slug = 'heartbeat-control-for-admin-pages';
1898
1899 add_settings_field(
1900 $field_id, // Field ID
1901 'On admin pages', // Field title
1902 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1903 ASENHA_SLUG, // Settings page slug
1904 'main-section', // Section ID
1905 array(
1906 'field_id' => $field_id, // Custom argument
1907 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1908 // 'field_label' => 'Temporary label', // Custom argument
1909 'field_radios' => array(
1910 'Keep as is' => 'default',
1911 'Modify' => 'modify',
1912 'Disable' => 'disable',
1913 ),
1914 'field_default' => 'default',
1915 'class' => 'asenha-radio-buttons optimizations ' . $field_slug, // Custom class for the <tr> element
1916 ),
1917 );
1918
1919 $field_id = 'heartbeat_interval_for_admin_pages';
1920 $field_slug = 'heartbeat-interval-for-admin-pages';
1921
1922 add_settings_field(
1923 $field_id, // Field ID
1924 '', // Field title
1925 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1926 ASENHA_SLUG, // Settings page slug
1927 'main-section', // Section ID
1928 array(
1929 'field_id' => $field_id, // Custom argument
1930 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1931 'field_type' => 'with-prefix-suffix', // Custom argument
1932 'field_prefix' => 'Set interval to once every', // Custom argument
1933 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>', // Custom argument
1934 'field_select_options' => array(
1935 '15 seconds' => 15,
1936 '30 seconds' => 30,
1937 '1 minute' => 60,
1938 '2 minutes' => 120,
1939 '3 minutes' => 180,
1940 '5 minutes' => 300,
1941 '10 minutes' => 600,
1942 ),
1943 'field_select_default' => 60,
1944 'field_intro' => '', // Custom argument
1945 'field_description' => '', // Custom argument
1946 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1947 'display_none_on_load' => true,
1948 )
1949 );
1950
1951 $field_id = 'heartbeat_control_for_post_edit';
1952 $field_slug = 'heartbeat-control-for-post-edit';
1953
1954 add_settings_field(
1955 $field_id, // Field ID
1956 'On post creation and edit screens', // Field title
1957 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1958 ASENHA_SLUG, // Settings page slug
1959 'main-section', // Section ID
1960 array(
1961 'field_id' => $field_id, // Custom argument
1962 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1963 // 'field_label' => 'Temporary label', // Custom argument
1964 'field_radios' => array(
1965 'Keep as is' => 'default',
1966 'Modify' => 'modify',
1967 'Disable' => 'disable',
1968 ),
1969 'field_default' => 'default',
1970 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1971 ),
1972 );
1973
1974 $field_id = 'heartbeat_interval_for_post_edit';
1975 $field_slug = 'heartbeat-interval-for-post-edit';
1976
1977 add_settings_field(
1978 $field_id, // Field ID
1979 '', // Field title
1980 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1981 ASENHA_SLUG, // Settings page slug
1982 'main-section', // Section ID
1983 array(
1984 'field_id' => $field_id, // Custom argument
1985 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1986 'field_type' => 'with-prefix-suffix', // Custom argument
1987 'field_prefix' => 'Set interval to once every', // Custom argument
1988 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>', // Custom argument
1989 'field_select_options' => array(
1990 '15 seconds' => 15,
1991 '30 seconds' => 30,
1992 '45 seconds' => 45,
1993 '60 seconds' => 60,
1994 '90 seconds' => 90,
1995 '120 seconds' => 120
1996 ),
1997 'field_select_default' => 15,
1998 'field_intro' => '', // Custom argument
1999 'field_description' => '', // Custom argument
2000 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
2001 'display_none_on_load' => true,
2002 )
2003 );
2004
2005 $field_id = 'heartbeat_control_for_frontend';
2006 $field_slug = 'heartbeat-control-for-frontend';
2007
2008 add_settings_field(
2009 $field_id, // Field ID
2010 'On the frontend', // Field title
2011 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2012 ASENHA_SLUG, // Settings page slug
2013 'main-section', // Section ID
2014 array(
2015 'field_id' => $field_id, // Custom argument
2016 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2017 // 'field_label' => 'Temporary label', // Custom argument
2018 'field_radios' => array(
2019 'Keep as is' => 'default',
2020 'Modify' => 'modify',
2021 'Disable' => 'disable',
2022 ),
2023 'field_default' => 'default',
2024 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
2025 ),
2026 );
2027
2028 $field_id = 'heartbeat_interval_for_frontend';
2029 $field_slug = 'heartbeat-interval-for-frontend';
2030
2031 add_settings_field(
2032 $field_id, // Field ID
2033 '', // Field title
2034 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
2035 ASENHA_SLUG, // Settings page slug
2036 'main-section', // Section ID
2037 array(
2038 'field_id' => $field_id, // Custom argument
2039 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2040 'field_type' => 'with-prefix-suffix', // Custom argument
2041 'field_prefix' => 'Set interval to once every', // Custom argument
2042 'field_suffix' => '', // Custom argument
2043 'field_select_options' => array(
2044 '15 seconds' => 15,
2045 '30 seconds' => 30,
2046 '1 minute' => 60,
2047 '2 minutes' => 120,
2048 '3 minutes' => 180,
2049 '5 minutes' => 300,
2050 '10 minutes' => 600,
2051 ),
2052 'field_select_default' => 60,
2053 'field_intro' => '', // Custom argument
2054 'field_description' => '', // Custom argument
2055 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
2056 'display_none_on_load' => true,
2057 )
2058 );
2059
2060 // =================================================================
2061 // UTILITIES
2062 // =================================================================
2063
2064 // SMTP Email Delivery
2065
2066 $field_id = 'smtp_email_delivery';
2067 $field_slug = 'smtp-email-delivery';
2068
2069 add_settings_field(
2070 $field_id, // Field ID
2071 'SMTP Email Delivery', // Field title
2072 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2073 ASENHA_SLUG, // Settings page slug
2074 'main-section', // Section ID
2075 array(
2076 'field_id' => $field_id, // Custom argument
2077 'field_slug' => $field_slug, // Custom argument
2078 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2079 'field_description' => 'Use external SMTP service to ensure notification and transactional emails from your site are being delivered to inboxes.', // Custom argument
2080 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2081 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
2082 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2083 )
2084 );
2085
2086 $field_id = 'smtp_host';
2087 $field_slug = 'smtp-host';
2088
2089 add_settings_field(
2090 $field_id, // Field ID
2091 '<span class="field-sublabel sublabel-wide">Host</span>', // Field title
2092 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2093 ASENHA_SLUG, // Settings page slug
2094 'main-section', // Section ID
2095 array(
2096 'field_id' => $field_id, // Custom argument
2097 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2098 'field_type' => '', // Custom argument
2099 'field_prefix' => '', // Custom argument
2100 'field_suffix' => '', // Custom argument
2101 'field_description' => '', // Custom argument
2102 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2103 )
2104 );
2105
2106 $field_id = 'smtp_port';
2107 $field_slug = 'smtp-port';
2108
2109 add_settings_field(
2110 $field_id, // Field ID
2111 '<span class="field-sublabel sublabel-wide">Port</span>', // Field title
2112 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
2113 ASENHA_SLUG, // Settings page slug
2114 'main-section', // Section ID
2115 array(
2116 'field_id' => $field_id, // Custom argument
2117 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2118 'field_type' => '', // Custom argument
2119 'field_prefix' => '', // Custom argument
2120 'field_suffix' => '', // Custom argument
2121 'field_intro' => '', // Custom argument
2122 'field_description' => '', // Custom argument
2123 'class' => 'asenha-text with-prefix-suffix narrow utilities ' . $field_slug, // Custom class for the <tr> element
2124 )
2125 );
2126
2127 $field_id = 'smtp_security';
2128 $field_slug = 'smtp-security';
2129
2130 add_settings_field(
2131 $field_id, // Field ID
2132 '<span class="field-sublabel sublabel-wide">Security</span>', // Field title
2133 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2134 ASENHA_SLUG, // Settings page slug
2135 'main-section', // Section ID
2136 array(
2137 'field_id' => $field_id, // Custom argument
2138 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2139 // 'field_label' => 'Temporary label', // Custom argument
2140 'field_radios' => array(
2141 'None' => 'none',
2142 'SSL' => 'ssl',
2143 'TLS' => 'tls',
2144 ),
2145 'field_default' => 'default',
2146 'class' => 'asenha-radio-buttons with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
2147 ),
2148 );
2149
2150 $field_id = 'smtp_username';
2151 $field_slug = 'smtp-username';
2152
2153 add_settings_field(
2154 $field_id, // Field ID
2155 '<span class="field-sublabel sublabel-wide">Username</span>', // Field title
2156 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2157 ASENHA_SLUG, // Settings page slug
2158 'main-section', // Section ID
2159 array(
2160 'field_id' => $field_id, // Custom argument
2161 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2162 'field_type' => '', // Custom argument
2163 'field_prefix' => '', // Custom argument
2164 'field_suffix' => '', // Custom argument
2165 'field_description' => '', // Custom argument
2166 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2167 )
2168 );
2169
2170 $field_id = 'smtp_password';
2171 $field_slug = 'smtp-password';
2172
2173 add_settings_field(
2174 $field_id, // Field ID
2175 '<span class="field-sublabel sublabel-wide">Password</span>', // Field title
2176 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
2177 ASENHA_SLUG, // Settings page slug
2178 'main-section', // Section ID
2179 array(
2180 'field_id' => $field_id, // Custom argument
2181 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2182 'field_type' => '', // Custom argument
2183 'field_prefix' => '', // Custom argument
2184 'field_suffix' => '', // Custom argument
2185 'field_description' => '', // Custom argument
2186 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2187 )
2188 );
2189
2190 $field_id = 'smtp_default_from_name';
2191 $field_slug = 'smtp-default-from-name';
2192
2193 add_settings_field(
2194 $field_id, // Field ID
2195 '<span class="field-sublabel sublabel-wide">FROM name</span>', // Field title
2196 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2197 ASENHA_SLUG, // Settings page slug
2198 'main-section', // Section ID
2199 array(
2200 'field_id' => $field_id, // Custom argument
2201 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2202 'field_type' => '', // Custom argument
2203 'field_prefix' => '', // Custom argument
2204 'field_suffix' => '', // Custom argument
2205 'field_description' => '', // Custom argument
2206 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2207 )
2208 );
2209
2210 $field_id = 'smtp_default_from_email';
2211 $field_slug = 'smtp-default-from-email';
2212
2213 add_settings_field(
2214 $field_id, // Field ID
2215 '<span class="field-sublabel sublabel-wide">FROM email</span>', // Field title
2216 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2217 ASENHA_SLUG, // Settings page slug
2218 'main-section', // Section ID
2219 array(
2220 'field_id' => $field_id, // Custom argument
2221 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2222 'field_type' => '', // Custom argument
2223 'field_prefix' => '', // Custom argument
2224 'field_suffix' => '', // Custom argument
2225 'field_description' => '', // Custom argument
2226 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2227 )
2228 );
2229
2230 $field_id = 'smtp_default_from_description';
2231 $field_slug = 'smtp-default-from-description';
2232
2233 add_settings_field(
2234 $field_id, // Field ID
2235 '', // Field title
2236 [ $render_field, 'render_description_subfield' ], // Callback to render field with custom arguments in the array below
2237 ASENHA_SLUG, // Settings page slug
2238 'main-section', // Section ID
2239 array(
2240 'field_description' => 'If set, the FROM name/email overrides WordPress core defaults but can still be overridden by plugins that enables custom FROM name/email, e.g. form plugins.', // Custom argument
2241 'class' => 'asenha-description utilities ' . $field_slug, // Custom class for the <tr> element
2242 )
2243 );
2244
2245 $field_id = 'smtp_debug';
2246 $field_slug = 'smtp-debug';
2247
2248 add_settings_field(
2249 $field_id, // Field ID
2250 '', // Field title
2251 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
2252 ASENHA_SLUG, // Settings page slug
2253 'main-section', // Section ID
2254 array(
2255 'field_id' => $field_id, // Custom argument
2256 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2257 'field_label' => 'Enable debug mode and output the debug info into WordPress debug.log file.', // Custom argument
2258 'class' => 'asenha-checkbox asenha-hide-th top-border utilities ' . $field_slug, // Custom class for the <tr> element
2259 )
2260 );
2261
2262 // View Admin as Role
2263
2264 $field_id = 'view_admin_as_role';
2265 $field_slug = 'view-admin-as-role';
2266
2267 add_settings_field(
2268 $field_id, // Field ID
2269 'View Admin as Role', // Field title
2270 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2271 ASENHA_SLUG, // Settings page slug
2272 'main-section', // Section ID
2273 array(
2274 'field_id' => $field_id, // Custom argument
2275 'field_slug' => $field_slug, // Custom argument
2276 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2277 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
2278 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2279 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2280 )
2281 );
2282
2283 // Enable Password Protection
2284
2285 $field_id = 'enable_password_protection';
2286 $field_slug = 'enable-password-protection';
2287
2288 add_settings_field(
2289 $field_id, // Field ID
2290 'Password Protection', // Field title
2291 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2292 ASENHA_SLUG, // Settings page slug
2293 'main-section', // Section ID
2294 array(
2295 'field_id' => $field_id, // Custom argument
2296 'field_slug' => $field_slug, // Custom argument
2297 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2298 'field_description' => 'Password-protect the entire site to hide the content from public view and search engine bots / crawlers. Logged-in administrators can still access the site as usual.', // Custom argument
2299 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2300 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2301 )
2302 );
2303
2304 $field_id = 'password_protection_password';
2305 $field_slug = 'password-protection-password';
2306
2307 add_settings_field(
2308 $field_id, // Field ID
2309 'Set the password:', // Field title
2310 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
2311 ASENHA_SLUG, // Settings page slug
2312 'main-section', // Section ID
2313 array(
2314 'field_id' => $field_id, // Custom argument
2315 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2316 'field_type' => 'with-prefix-suffix', // Custom argument
2317 'field_prefix' => '', // Custom argument
2318 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>', // Custom argument
2319 'field_description' => '', // Custom argument
2320 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
2321 )
2322 );
2323
2324 // Maintenance Mode
2325
2326 $field_id = 'maintenance_mode';
2327 $field_slug = 'maintenance-mode';
2328
2329 add_settings_field(
2330 $field_id, // Field ID
2331 'Maintenance Mode', // Field title
2332 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2333 ASENHA_SLUG, // Settings page slug
2334 'main-section', // Section ID
2335 array(
2336 'field_id' => $field_id, // Custom argument
2337 'field_slug' => $field_slug, // Custom argument
2338 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2339 'field_description' => 'Show a customizable maintenance page on the frontend while performing a brief maintenance to your site. Logged-in administrators can still view the site as usual.', // Custom argument
2340 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2341 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
2342 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2343 )
2344 );
2345
2346 $field_id = 'maintenance_page_heading';
2347 $field_slug = 'maintenance-page-heading';
2348
2349 add_settings_field(
2350 $field_id, // Field ID
2351 'Heading', // Field title
2352 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2353 ASENHA_SLUG, // Settings page slug
2354 'main-section', // Section ID
2355 array(
2356 'field_id' => $field_id, // Custom argument
2357 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2358 'field_type' => '', // Custom argument
2359 'field_prefix' => '', // Custom argument
2360 'field_suffix' => '', // Custom argument
2361 'field_description' => '', // Custom argument
2362 'field_placeholder' => 'We\'ll be back soon.',
2363 'class' => 'asenha-text utilities full-width ' . $field_slug, // Custom class for the <tr> element
2364 )
2365 );
2366
2367 $field_id = 'maintenance_page_description';
2368 $field_slug = 'maintenance-page-description';
2369
2370 add_settings_field(
2371 $field_id, // Field ID
2372 'Description', // Field title
2373 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
2374 ASENHA_SLUG, // Settings page slug
2375 'main-section', // Section ID
2376 array(
2377 'field_id' => $field_id, // Custom argument
2378 'field_slug' => $field_slug, // Custom argument
2379 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2380 'field_type' => 'textarea', // Custom argument
2381 'field_rows' => 5,
2382 'field_intro' => '', // Custom argument
2383 'field_description' => '', // Custom argument
2384 'field_placeholder' => 'This site is undergoing maintenance for an extended period today. Thanks for your patience.',
2385 'class' => 'asenha-textarea utilities ' . $field_slug, // Custom class for the <tr> element
2386 )
2387 );
2388
2389 $field_id = 'maintenance_page_background';
2390 $field_slug = 'maintenance-page-background';
2391
2392 add_settings_field(
2393 $field_id, // Field ID
2394 'Background', // Field title
2395 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2396 ASENHA_SLUG, // Settings page slug
2397 'main-section', // Section ID
2398 array(
2399 'field_id' => $field_id, // Custom argument
2400 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2401 // 'field_label' => 'Temporary label', // Custom argument
2402 'field_radios' => array(
2403 'Stripes' => 'stripes',
2404 'Curves' => 'curves',
2405 'Lines' => 'lines',
2406 ),
2407 'field_default' => 'default',
2408 'class' => 'asenha-radio-buttons utilities ' . $field_slug, // Custom class for the <tr> element
2409 ),
2410 );
2411
2412 $field_id = 'maintenance_mode_description';
2413 $field_slug = 'maintenance-mode-description';
2414
2415 add_settings_field(
2416 $field_id, // Field ID
2417 '', // Field title
2418 [ $render_field, 'render_description_subfield' ], // Callback to render field with custom arguments in the array below
2419 ASENHA_SLUG, // Settings page slug
2420 'main-section', // Section ID
2421 array(
2422 'field_description' => '<div class="asenha-warning"><strong>Please clear your cache</strong> after enabling or disabling maintenance mode. This ensures site visitors see either the maintenance page or the actual content of each page.</div>', // Custom argument
2423 'class' => 'asenha-description utilities ' . $field_slug, // Custom class for the <tr> element
2424 )
2425 );
2426
2427 // Redirect 404 to Homepage
2428
2429 $field_id = 'redirect_404_to_homepage';
2430 $field_slug = 'redirect-404-to-homepage';
2431
2432 add_settings_field(
2433 $field_id, // Field ID
2434 'Redirect 404 to Homepage', // Field title
2435 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2436 ASENHA_SLUG, // Settings page slug
2437 'main-section', // Section ID
2438 array(
2439 'field_id' => $field_id, // Custom argument
2440 'field_slug' => $field_slug, // Custom argument
2441 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2442 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
2443 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2444 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2445 )
2446 );
2447
2448 }
2449
2450 }