PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 5.3.2
Admin and Site Enhancements (ASE) v5.3.2
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
3171 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',
23 // Section ID
24 '',
25 // Section title. Can be blank.
26 '',
27 // Callback function to output section intro. Can be blank.
28 ASENHA_SLUG
29 );
30 // Register main setttings
31 // Instantiate object for sanitization of settings fields values
32 $sanitization = new Settings_Sanitization();
33 // Instantiate object for rendering of settings fields for the admin page
34 $render_field = new Settings_Fields_Render();
35 register_setting(
36 ASENHA_ID,
37 // Option group or option_page
38 ASENHA_SLUG_U,
39 // Option name in wp_options table
40 array(
41 'type' => 'array',
42 'description' => '',
43 'sanitize_callback' => [ $sanitization, 'sanitize_for_options' ],
44 'show_in_rest' => false,
45 'default' => array(),
46 )
47 );
48 // =================================================================
49 // Call WordPress globals and set new globals required for the fields
50 // =================================================================
51 global
52 $wp_roles,
53 $wpdb,
54 $asenha_public_post_types,
55 $asenha_gutenberg_post_types,
56 $asenha_revisions_post_types
57 ;
58 $roles = $wp_roles->get_names();
59 // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
60 $asenha_public_post_types = array();
61 $public_post_type_names = get_post_types( array(
62 'public' => true,
63 ), 'names' );
64 foreach ( $public_post_type_names as $post_type_name ) {
65 $post_type_object = get_post_type_object( $post_type_name );
66 $asenha_public_post_types[$post_type_name] = $post_type_object->label;
67 }
68 // 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' )
69 $asenha_gutenberg_post_types = array();
70 $gutenberg_not_applicable_types = array(
71 'attachment',
72 'revision',
73 'nav_menu_item',
74 'custom_css',
75 'customize_changeset',
76 'oembed_cache',
77 'user_request',
78 'wp_block'
79 );
80 $all_post_types = get_post_types( array(), 'objects' );
81 foreach ( $all_post_types as $post_type_slug => $post_type_info ) {
82 $asenha_gutenberg_post_types[$post_type_slug] = $post_type_info->label;
83 if ( in_array( $post_type_slug, $gutenberg_not_applicable_types ) ) {
84 unset( $asenha_gutenberg_post_types[$post_type_slug] );
85 }
86 }
87 // Get array of slugs and plural labels for post types supporting revisions, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
88 $asenha_revisions_post_types = array();
89 foreach ( get_post_types( array(), 'names' ) as $post_type_slug ) {
90 // post type slug/name
91
92 if ( post_type_supports( $post_type_slug, 'revisions' ) ) {
93 $post_type_object = get_post_type_object( $post_type_slug );
94 if ( property_exists( $post_type_object, 'label' ) ) {
95 $asenha_revisions_post_types[$post_type_slug] = $post_type_object->label;
96 }
97 }
98
99 }
100 // Enable Content Duplication
101 $field_id = 'enable_duplication';
102 $field_slug = 'enable-duplication';
103 add_settings_field(
104 $field_id,
105 // Field ID
106 'Content Duplication',
107 // Field title
108 [ $render_field, 'render_checkbox_toggle' ],
109 // Callback to render field with custom arguments in the array below
110 ASENHA_SLUG,
111 // Settings page slug
112 'main-section',
113 // Section ID
114 array(
115 'option_name' => ASENHA_SLUG_U,
116 'field_id' => $field_id,
117 'field_slug' => $field_slug,
118 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
119 'field_description' => 'Enable one-click duplication of pages, posts and custom posts. The corresponding taxonomy terms and post meta will also be duplicated.',
120 'class' => 'asenha-toggle content-management ' . $field_slug,
121 )
122 );
123 // Content Order
124 $field_id = 'content_order';
125 $field_slug = 'content-order';
126 add_settings_field(
127 $field_id,
128 // Field ID
129 'Content Order',
130 // Field title
131 [ $render_field, 'render_checkbox_toggle' ],
132 // Callback to render field with custom arguments in the array below
133 ASENHA_SLUG,
134 // Settings page slug
135 'main-section',
136 // Section ID
137 array(
138 'option_name' => ASENHA_SLUG_U,
139 'field_id' => $field_id,
140 'field_slug' => $field_slug,
141 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
142 'field_description' => 'Enable custom ordering of various "hierarchical" content types or those supporting "page attributes". Useful for displaying them in the desired order in wp-admin and on the frontend.',
143 'field_options_wrapper' => true,
144 'field_options_moreless' => true,
145 'class' => 'asenha-toggle content-management ' . $field_slug,
146 )
147 );
148 // $field_id = 'content_order_subfields_heading';
149 // $field_slug = 'content-order-subfields-heading';
150 // add_settings_field(
151 // $field_id, // Field ID
152 // '', // Field title
153 // [ $render_field, 'render_subfields_heading' ], // Callback to render field with custom arguments in the array below
154 // ASENHA_SLUG, // Settings page slug
155 // 'main-section', // Section ID
156 // array(
157 // 'subfields_heading' => 'Custom Post Types (Non-Hierarchical)', // Custom argument
158 // 'class' => 'asenha-heading shift-more-up content-management ' . $field_slug, // Custom class for the <tr> element
159 // )
160 // );
161 $field_id = 'content_order_for';
162 $field_slug = 'content-order-for';
163 if ( is_array( $asenha_public_post_types ) ) {
164 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
165 // e.g. $post_type_slug is post, $post_type_label is Posts
166 $is_hierarchical_label = ( is_post_type_hierarchical( $post_type_slug ) ? ' <span class="faded">- Hierarchical</span>' : '' );
167 if ( post_type_supports( $post_type_slug, 'page-attributes' ) || is_post_type_hierarchical( $post_type_slug ) ) {
168 add_settings_field(
169 $field_id . '_' . $post_type_slug,
170 // Field ID
171 '',
172 // Field title
173 [ $render_field, 'render_checkbox_subfield' ],
174 // Callback to render field with custom arguments in the array below
175 ASENHA_SLUG,
176 // Settings page slug
177 'main-section',
178 // Section ID
179 array(
180 'option_name' => ASENHA_SLUG_U,
181 'parent_field_id' => $field_id,
182 'field_id' => $post_type_slug,
183 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
184 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>' . $is_hierarchical_label,
185 'class' => 'asenha-checkbox asenha-hide-th asenha-half content-management ' . $field_slug . ' ' . $post_type_slug,
186 )
187 );
188 }
189 }
190 }
191 // Enable Media Replacement
192 $field_id = 'enable_media_replacement';
193 $field_slug = 'enable-media-replacement';
194 add_settings_field(
195 $field_id,
196 // Field ID
197 'Media Replacement',
198 // Field title
199 [ $render_field, 'render_checkbox_toggle' ],
200 // Callback to render field with custom arguments in the array below
201 ASENHA_SLUG,
202 // Settings page slug
203 'main-section',
204 // Section ID
205 array(
206 'option_name' => ASENHA_SLUG_U,
207 'field_id' => $field_id,
208 'field_slug' => $field_slug,
209 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
210 '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.',
211 'class' => 'asenha-toggle content-management ' . $field_slug,
212 )
213 );
214 // Enable SVG Upload
215 $field_id = 'enable_svg_upload';
216 $field_slug = 'enable-svg-upload';
217 add_settings_field(
218 $field_id,
219 // Field ID
220 'SVG Upload',
221 // Field title
222 [ $render_field, 'render_checkbox_toggle' ],
223 // Callback to render field with custom arguments in the array below
224 ASENHA_SLUG,
225 // Settings page slug
226 'main-section',
227 // Section ID
228 array(
229 'option_name' => ASENHA_SLUG_U,
230 'field_id' => $field_id,
231 'field_slug' => $field_slug,
232 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
233 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.',
234 'field_options_wrapper' => true,
235 'field_options_moreless' => true,
236 'class' => 'asenha-toggle content-management ' . $field_slug,
237 )
238 );
239 $field_id = 'enable_svg_upload_for';
240 $field_slug = 'enable-svg-upload-for';
241 if ( is_array( $roles ) ) {
242 foreach ( $roles as $role_slug => $role_label ) {
243 // e.g. $role_slug is administrator, $role_label is Administrator
244 add_settings_field(
245 $field_id . '_' . $role_slug,
246 // Field ID
247 '',
248 // Field title
249 [ $render_field, 'render_checkbox_subfield' ],
250 // Callback to render field with custom arguments in the array below
251 ASENHA_SLUG,
252 // Settings page slug
253 'main-section',
254 // Section ID
255 array(
256 'option_name' => ASENHA_SLUG_U,
257 'parent_field_id' => $field_id,
258 'field_id' => $role_slug,
259 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
260 'field_label' => $role_label,
261 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug,
262 )
263 );
264 }
265 }
266 // Enable External Permalinks
267 $field_id = 'enable_external_permalinks';
268 $field_slug = 'enable-external-permalinks';
269 add_settings_field(
270 $field_id,
271 // Field ID
272 'External Permalinks',
273 // Field title
274 [ $render_field, 'render_checkbox_toggle' ],
275 // Callback to render field with custom arguments in the array below
276 ASENHA_SLUG,
277 // Settings page slug
278 'main-section',
279 // Section ID
280 array(
281 'option_name' => ASENHA_SLUG_U,
282 'field_id' => $field_id,
283 'field_slug' => $field_slug,
284 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
285 'field_description' => 'Enable pages, posts and/or custom post types to have permalinks that point to external URLs. The rel="noopener noreferrer nofollow" attribute will also be added for enhanced security and SEO benefits. Compatible with links added using <a href="https://wordpress.org/plugins/page-links-to/" target="_blank">Page Links To</a>.',
286 'field_options_wrapper' => true,
287 'field_options_moreless' => true,
288 'class' => 'asenha-toggle content-management ' . $field_slug,
289 )
290 );
291 $field_id = 'enable_external_permalinks_for';
292 $field_slug = 'enable-external-permalinks-for';
293 if ( is_array( $asenha_public_post_types ) ) {
294 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
295 // e.g. $post_type_slug is post, $post_type_label is Posts
296 if ( 'attachment' != $post_type_slug ) {
297 add_settings_field(
298 $field_id . '_' . $post_type_slug,
299 // Field ID
300 '',
301 // Field title
302 [ $render_field, 'render_checkbox_subfield' ],
303 // Callback to render field with custom arguments in the array below
304 ASENHA_SLUG,
305 // Settings page slug
306 'main-section',
307 // Section ID
308 array(
309 'option_name' => ASENHA_SLUG_U,
310 'parent_field_id' => $field_id,
311 'field_id' => $post_type_slug,
312 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
313 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
314 'class' => 'asenha-checkbox asenha-hide-th asenha-half content-management ' . $field_slug . ' ' . $post_type_slug,
315 )
316 );
317 }
318 }
319 }
320 // Open All External Links in New Tab
321 $field_id = 'external_links_new_tab';
322 $field_slug = 'external-links-new-tab';
323 add_settings_field(
324 $field_id,
325 // Field ID
326 'Open All External Links in New Tab',
327 // Field title
328 [ $render_field, 'render_checkbox_toggle' ],
329 // Callback to render field with custom arguments in the array below
330 ASENHA_SLUG,
331 // Settings page slug
332 'main-section',
333 // Section ID
334 array(
335 'option_name' => ASENHA_SLUG_U,
336 'field_id' => $field_id,
337 'field_slug' => $field_slug,
338 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
339 'field_description' => 'Force all links to external sites to open in new browser tab via target="_blank" attribute. The rel="noopener noreferrer nofollow" attribute will also be added for enhanced security and SEO benefits.',
340 'field_options_wrapper' => true,
341 'field_options_moreless' => true,
342 'class' => 'asenha-toggle content-management ' . $field_slug,
343 )
344 );
345 // Enable Auto-Publishing of Posts with Missed Schedules
346 $field_id = 'enable_missed_schedule_posts_auto_publish';
347 $field_slug = 'enable-missed-schedule-posts-auto-publish';
348 add_settings_field(
349 $field_id,
350 // Field ID
351 'Auto-Publish Posts with Missed Schedule',
352 // Field title
353 [ $render_field, 'render_checkbox_toggle' ],
354 // Callback to render field with custom arguments in the array below
355 ASENHA_SLUG,
356 // Settings page slug
357 'main-section',
358 // Section ID
359 array(
360 'option_name' => ASENHA_SLUG_U,
361 'field_id' => $field_id,
362 'field_slug' => $field_slug,
363 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
364 'field_description' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.',
365 'class' => 'asenha-toggle content-management ' . $field_slug,
366 )
367 );
368 // Enhance List Tables
369 $field_id = 'enhance_list_tables';
370 $field_slug = 'enhance-list-tables';
371 add_settings_field(
372 $field_id,
373 // Field ID
374 'Enhance List Tables',
375 // Field title
376 [ $render_field, 'render_checkbox_toggle' ],
377 // Callback to render field with custom arguments in the array below
378 ASENHA_SLUG,
379 // Settings page slug
380 'main-section',
381 // Section ID
382 array(
383 'option_name' => ASENHA_SLUG_U,
384 'field_id' => $field_id,
385 'field_slug' => $field_slug,
386 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
387 'field_description' => 'Improve the usefulness of listing pages for various post types and taxonomies, media, comments and users by adding / removing columns and elements.',
388 'field_options_wrapper' => true,
389 'field_options_moreless' => true,
390 'class' => 'asenha-toggle content-management ' . $field_slug,
391 )
392 );
393 // Show Featured Image Column
394 $field_id = 'show_featured_image_column';
395 $field_slug = 'show-featured-image-column';
396 add_settings_field(
397 $field_id,
398 // Field ID
399 '',
400 // Field title
401 [ $render_field, 'render_checkbox_plain' ],
402 // Callback to render field with custom arguments in the array below
403 ASENHA_SLUG,
404 // Settings page slug
405 'main-section',
406 // Section ID
407 array(
408 'option_name' => ASENHA_SLUG_U,
409 'field_id' => $field_id,
410 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
411 'field_label' => 'Show featured image column.',
412 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
413 )
414 );
415 // Show Excerpt Column
416 $field_id = 'show_excerpt_column';
417 $field_slug = 'show-excerpt-column';
418 add_settings_field(
419 $field_id,
420 // Field ID
421 '',
422 // Field title
423 [ $render_field, 'render_checkbox_plain' ],
424 // Callback to render field with custom arguments in the array below
425 ASENHA_SLUG,
426 // Settings page slug
427 'main-section',
428 // Section ID
429 array(
430 'option_name' => ASENHA_SLUG_U,
431 'field_id' => $field_id,
432 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
433 'field_label' => 'Show excerpt column.',
434 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
435 )
436 );
437 // Show ID Column
438 $field_id = 'show_id_column';
439 $field_slug = 'show-id-column';
440 add_settings_field(
441 $field_id,
442 // Field ID
443 '',
444 // Field title
445 [ $render_field, 'render_checkbox_plain' ],
446 // Callback to render field with custom arguments in the array below
447 ASENHA_SLUG,
448 // Settings page slug
449 'main-section',
450 // Section ID
451 array(
452 'option_name' => ASENHA_SLUG_U,
453 'field_id' => $field_id,
454 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
455 'field_label' => 'Show ID column.',
456 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
457 )
458 );
459 // Show ID in Action Row
460 $field_id = 'show_id_in_action_row';
461 $field_slug = 'show-id-in-action_row';
462 add_settings_field(
463 $field_id,
464 // Field ID
465 '',
466 // Field title
467 [ $render_field, 'render_checkbox_plain' ],
468 // Callback to render field with custom arguments in the array below
469 ASENHA_SLUG,
470 // Settings page slug
471 'main-section',
472 // Section ID
473 array(
474 'option_name' => ASENHA_SLUG_U,
475 'field_id' => $field_id,
476 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
477 'field_label' => 'Show ID in action rows along with links for Edit, View, etc.',
478 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
479 )
480 );
481 // Show Custom Taxonomy Filters
482 $field_id = 'show_custom_taxonomy_filters';
483 $field_slug = 'show-custom-taxonomy-filters';
484 add_settings_field(
485 $field_id,
486 // Field ID
487 '',
488 // Field title
489 [ $render_field, 'render_checkbox_plain' ],
490 // Callback to render field with custom arguments in the array below
491 ASENHA_SLUG,
492 // Settings page slug
493 'main-section',
494 // Section ID
495 array(
496 'option_name' => ASENHA_SLUG_U,
497 'field_id' => $field_id,
498 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
499 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.',
500 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
501 )
502 );
503 // Hide Comments Column
504 $field_id = 'hide_comments_column';
505 $field_slug = 'hide-comments-column';
506 add_settings_field(
507 $field_id,
508 // Field ID
509 '',
510 // Field title
511 [ $render_field, 'render_checkbox_plain' ],
512 // Callback to render field with custom arguments in the array below
513 ASENHA_SLUG,
514 // Settings page slug
515 'main-section',
516 // Section ID
517 array(
518 'option_name' => ASENHA_SLUG_U,
519 'field_id' => $field_id,
520 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
521 'field_label' => 'Remove comments column.',
522 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
523 )
524 );
525 // Hide Post Tags Column
526 $field_id = 'hide_post_tags_column';
527 $field_slug = 'hide-post-tags-column';
528 add_settings_field(
529 $field_id,
530 // Field ID
531 '',
532 // Field title
533 [ $render_field, 'render_checkbox_plain' ],
534 // Callback to render field with custom arguments in the array below
535 ASENHA_SLUG,
536 // Settings page slug
537 'main-section',
538 // Section ID
539 array(
540 'option_name' => ASENHA_SLUG_U,
541 'field_id' => $field_id,
542 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
543 'field_label' => 'Remove tags column (for posts).',
544 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug,
545 )
546 );
547 // =================================================================
548 // ADMIN INTERFACE
549 // =================================================================
550 // Hide Admin Notices
551 $field_id = 'hide_admin_notices';
552 $field_slug = 'hide-admin-notices';
553 add_settings_field(
554 $field_id,
555 // Field ID
556 'Hide Admin Notices',
557 // Field title
558 [ $render_field, 'render_checkbox_toggle' ],
559 // Callback to render field with custom arguments in the array below
560 ASENHA_SLUG,
561 // Settings page slug
562 'main-section',
563 // Section ID
564 array(
565 'option_name' => ASENHA_SLUG_U,
566 'field_id' => $field_id,
567 'field_slug' => $field_slug,
568 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
569 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.',
570 'class' => 'asenha-toggle admin-interface ' . $field_slug,
571 )
572 );
573 // Disable Dashboard Widgets
574 $field_id = 'disable_dashboard_widgets';
575 $field_slug = 'disable-dashboard-widgets';
576 add_settings_field(
577 $field_id,
578 // Field ID
579 'Disable Dashboard Widgets',
580 // Field title
581 [ $render_field, 'render_checkbox_toggle' ],
582 // Callback to render field with custom arguments in the array below
583 ASENHA_SLUG,
584 // Settings page slug
585 'main-section',
586 // Section ID
587 array(
588 'option_name' => ASENHA_SLUG_U,
589 'field_id' => $field_id,
590 'field_slug' => $field_slug,
591 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
592 '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. ',
593 'field_options_wrapper' => true,
594 'field_options_moreless' => true,
595 'class' => 'asenha-toggle admin-interface ' . $field_slug,
596 )
597 );
598 $field_id = 'disabled_dashboard_widgets';
599 $field_slug = 'disabled-dashboard-widgets';
600 $extra_options = get_option( 'admin_site_enhancements_extra', array() );
601
602 if ( array_key_exists( 'dashboard_widgets', $extra_options ) ) {
603 $dashboard_widgets = $extra_options['dashboard_widgets'];
604 } else {
605 $admin_interface = new Admin_Interface();
606 $dashboard_widgets = $admin_interface->get_dashboard_widgets();
607 $extra_options['dashboard_widgets'] = $dashboard_widgets;
608 update_option( 'admin_site_enhancements_extra', $extra_options );
609 }
610
611 foreach ( $dashboard_widgets as $widget ) {
612 add_settings_field(
613 $field_id . '_' . $widget['id'],
614 // Field ID
615 '',
616 // Field title
617 [ $render_field, 'render_checkbox_subfield' ],
618 // Callback to render field with custom arguments in the array below
619 ASENHA_SLUG,
620 // Settings page slug
621 'main-section',
622 // Section ID
623 array(
624 'option_name' => ASENHA_SLUG_U,
625 'parent_field_id' => $field_id,
626 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'],
627 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']',
628 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>',
629 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'],
630 )
631 );
632 }
633 // Hide or Modify Elements
634 $field_id = 'hide_modify_elements';
635 $field_slug = 'hide-modify-elements';
636 add_settings_field(
637 $field_id,
638 // Field ID
639 'Clean Up Admin Bar',
640 // Field title
641 [ $render_field, 'render_checkbox_toggle' ],
642 // Callback to render field with custom arguments in the array below
643 ASENHA_SLUG,
644 // Settings page slug
645 'main-section',
646 // Section ID
647 array(
648 'option_name' => ASENHA_SLUG_U,
649 'field_id' => $field_id,
650 'field_slug' => $field_slug,
651 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
652 'field_description' => 'Remove various elements from the admin bar.',
653 'field_options_wrapper' => true,
654 'field_options_moreless' => true,
655 'class' => 'asenha-toggle admin-interface ' . $field_slug,
656 )
657 );
658 $field_id = 'hide_ab_wp_logo_menu';
659 $field_slug = 'hide-ab-wp-logo-menu';
660 add_settings_field(
661 $field_id,
662 // Field ID
663 '',
664 // Field title
665 [ $render_field, 'render_checkbox_plain' ],
666 // Callback to render field with custom arguments in the array below
667 ASENHA_SLUG,
668 // Settings page slug
669 'main-section',
670 // Section ID
671 array(
672 'option_name' => ASENHA_SLUG_U,
673 'field_id' => $field_id,
674 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
675 'field_label' => 'Remove WordPress logo/menu',
676 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
677 )
678 );
679 $field_id = 'hide_ab_customize_menu';
680 $field_slug = 'hide-ab-customize-menu';
681 add_settings_field(
682 $field_id,
683 // Field ID
684 '',
685 // Field title
686 [ $render_field, 'render_checkbox_plain' ],
687 // Callback to render field with custom arguments in the array below
688 ASENHA_SLUG,
689 // Settings page slug
690 'main-section',
691 // Section ID
692 array(
693 'option_name' => ASENHA_SLUG_U,
694 'field_id' => $field_id,
695 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
696 'field_label' => 'Remove customize menu',
697 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
698 )
699 );
700 $field_id = 'hide_ab_updates_menu';
701 $field_slug = 'hide-ab-updates-menu';
702 add_settings_field(
703 $field_id,
704 // Field ID
705 '',
706 // Field title
707 [ $render_field, 'render_checkbox_plain' ],
708 // Callback to render field with custom arguments in the array below
709 ASENHA_SLUG,
710 // Settings page slug
711 'main-section',
712 // Section ID
713 array(
714 'option_name' => ASENHA_SLUG_U,
715 'field_id' => $field_id,
716 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
717 'field_label' => 'Remove updates counter/link',
718 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
719 )
720 );
721 $field_id = 'hide_ab_comments_menu';
722 $field_slug = 'hide-ab-comments-menu';
723 add_settings_field(
724 $field_id,
725 // Field ID
726 '',
727 // Field title
728 [ $render_field, 'render_checkbox_plain' ],
729 // Callback to render field with custom arguments in the array below
730 ASENHA_SLUG,
731 // Settings page slug
732 'main-section',
733 // Section ID
734 array(
735 'option_name' => ASENHA_SLUG_U,
736 'field_id' => $field_id,
737 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
738 'field_label' => 'Remove comments counter/link',
739 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
740 )
741 );
742 $field_id = 'hide_ab_new_content_menu';
743 $field_slug = 'hide-ab-new-content-menu';
744 add_settings_field(
745 $field_id,
746 // Field ID
747 '',
748 // Field title
749 [ $render_field, 'render_checkbox_plain' ],
750 // Callback to render field with custom arguments in the array below
751 ASENHA_SLUG,
752 // Settings page slug
753 'main-section',
754 // Section ID
755 array(
756 'option_name' => ASENHA_SLUG_U,
757 'field_id' => $field_id,
758 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
759 'field_label' => 'Remove new content menu',
760 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
761 )
762 );
763 $field_id = 'hide_ab_howdy';
764 $field_slug = 'hide-ab-howdy';
765 add_settings_field(
766 $field_id,
767 // Field ID
768 '',
769 // Field title
770 [ $render_field, 'render_checkbox_plain' ],
771 // Callback to render field with custom arguments in the array below
772 ASENHA_SLUG,
773 // Settings page slug
774 'main-section',
775 // Section ID
776 array(
777 'option_name' => ASENHA_SLUG_U,
778 'field_id' => $field_id,
779 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
780 'field_label' => 'Remove \'Howdy\'',
781 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
782 )
783 );
784 $field_id = 'hide_help_drawer';
785 $field_slug = 'hide-help-drawer';
786 add_settings_field(
787 $field_id,
788 // Field ID
789 '',
790 // Field title
791 [ $render_field, 'render_checkbox_plain' ],
792 // Callback to render field with custom arguments in the array below
793 ASENHA_SLUG,
794 // Settings page slug
795 'main-section',
796 // Section ID
797 array(
798 'option_name' => ASENHA_SLUG_U,
799 'field_id' => $field_id,
800 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
801 'field_label' => 'Remove the Help tab and drawer',
802 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
803 )
804 );
805 // Hide Admin Bar
806 $field_id = 'hide_admin_bar';
807 $field_slug = 'hide-admin-bar';
808 add_settings_field(
809 $field_id,
810 // Field ID
811 'Hide Admin Bar',
812 // Field title
813 [ $render_field, 'render_checkbox_toggle' ],
814 // Callback to render field with custom arguments in the array below
815 ASENHA_SLUG,
816 // Settings page slug
817 'main-section',
818 // Section ID
819 array(
820 'option_name' => ASENHA_SLUG_U,
821 'field_id' => $field_id,
822 'field_slug' => $field_slug,
823 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
824 'field_description' => 'Hide admin bar on the front end for all or some user roles.',
825 'field_options_wrapper' => true,
826 'field_options_moreless' => true,
827 'class' => 'asenha-toggle admin-interface ' . $field_slug,
828 )
829 );
830 $field_id = 'hide_admin_bar_for';
831 $field_slug = 'hide-admin-bar-for';
832 if ( is_array( $roles ) ) {
833 foreach ( $roles as $role_slug => $role_label ) {
834 // e.g. $role_slug is administrator, $role_label is Administrator
835 add_settings_field(
836 $field_id . '_' . $role_slug,
837 // Field ID
838 '',
839 // Field title
840 [ $render_field, 'render_checkbox_subfield' ],
841 // Callback to render field with custom arguments in the array below
842 ASENHA_SLUG,
843 // Settings page slug
844 'main-section',
845 // Section ID
846 array(
847 'option_name' => ASENHA_SLUG_U,
848 'parent_field_id' => $field_id,
849 'field_id' => $role_slug,
850 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
851 'field_label' => $role_label,
852 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug,
853 )
854 );
855 }
856 }
857 // Wider Admin Menu
858 $field_id = 'wider_admin_menu';
859 $field_slug = 'wider-admin-menu';
860 add_settings_field(
861 $field_id,
862 // Field ID
863 'Wider Admin Menu',
864 // Field title
865 [ $render_field, 'render_checkbox_toggle' ],
866 // Callback to render field with custom arguments in the array below
867 ASENHA_SLUG,
868 // Settings page slug
869 'main-section',
870 // Section ID
871 array(
872 'option_name' => ASENHA_SLUG_U,
873 'field_id' => $field_id,
874 'field_slug' => $field_slug,
875 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
876 'field_description' => 'Give the admin menu more room to better accommodate wider items.',
877 'field_options_wrapper' => true,
878 'class' => 'asenha-toggle admin-interface ' . $field_slug,
879 )
880 );
881 $field_id = 'admin_menu_width';
882 $field_slug = 'admin-menu-width';
883 add_settings_field(
884 $field_id,
885 // Field ID
886 '',
887 // Field title
888 [ $render_field, 'render_select_subfield' ],
889 // Callback to render field with custom arguments in the array below
890 ASENHA_SLUG,
891 // Settings page slug
892 'main-section',
893 // Section ID
894 array(
895 'option_name' => ASENHA_SLUG_U,
896 'field_id' => $field_id,
897 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
898 'field_type' => 'with-prefix-suffix',
899 'field_prefix' => 'Set width to',
900 'field_suffix' => '<span class="faded">(Default is 160px)</span>',
901 'field_select_options' => array(
902 '180px' => '180px',
903 '200px' => '200px',
904 '220px' => '220px',
905 '240px' => '240px',
906 '260px' => '260px',
907 '280px' => '280px',
908 '300px' => '300px',
909 ),
910 'field_select_default' => 200,
911 'field_intro' => '',
912 'field_description' => '',
913 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up admin-interface ' . $field_slug,
914 'display_none_on_load' => true,
915 )
916 );
917 // Admin Menu Organizer
918 $field_id = 'customize_admin_menu';
919 $field_slug = 'customize-admin-menu';
920 add_settings_field(
921 $field_id,
922 // Field ID
923 'Admin Menu Organizer',
924 // Field title
925 [ $render_field, 'render_checkbox_toggle' ],
926 // Callback to render field with custom arguments in the array below
927 ASENHA_SLUG,
928 // Settings page slug
929 'main-section',
930 // Section ID
931 array(
932 'option_name' => ASENHA_SLUG_U,
933 'field_id' => $field_id,
934 'field_slug' => $field_slug,
935 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
936 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.',
937 'field_options_wrapper' => true,
938 'field_options_moreless' => true,
939 'class' => 'asenha-toggle admin-interface ' . $field_slug,
940 )
941 );
942 $field_id = 'custom_menu_order';
943 $field_slug = 'custom-menu-order';
944 add_settings_field(
945 $field_id,
946 // Field ID
947 '',
948 // Field title
949 [ $render_field, 'render_sortable_menu' ],
950 // Callback to render field with custom arguments in the array below
951 ASENHA_SLUG,
952 // Settings page slug
953 'main-section',
954 // Section ID
955 array(
956 'option_name' => ASENHA_SLUG_U,
957 'field_id' => $field_id,
958 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
959 'field_type' => 'sortable-menu',
960 'field_description' => '',
961 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug,
962 )
963 );
964 // =================================================================
965 // LOG IN | LOG OUT
966 // =================================================================
967 // Change Login URL
968 $field_id = 'change_login_url';
969 $field_slug = 'change-login-url';
970 add_settings_field(
971 $field_id,
972 // Field ID
973 'Change Login URL',
974 // Field title
975 [ $render_field, 'render_checkbox_toggle' ],
976 // Callback to render field with custom arguments in the array below
977 ASENHA_SLUG,
978 // Settings page slug
979 'main-section',
980 // Section ID
981 array(
982 'option_name' => ASENHA_SLUG_U,
983 'field_id' => $field_id,
984 'field_slug' => $field_slug,
985 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
986 'field_description' => 'Default is ' . get_site_url() . '/wp-login.php',
987 'field_options_wrapper' => true,
988 'class' => 'asenha-toggle login-logout ' . $field_slug,
989 )
990 );
991 $field_id = 'custom_login_slug';
992 $field_slug = 'custom-login-slug';
993 add_settings_field(
994 $field_id,
995 // Field ID
996 'New URL:',
997 // Field title
998 [ $render_field, 'render_text_subfield' ],
999 // Callback to render field with custom arguments in the array below
1000 ASENHA_SLUG,
1001 // Settings page slug
1002 'main-section',
1003 // Section ID
1004 array(
1005 'option_name' => ASENHA_SLUG_U,
1006 'field_id' => $field_id,
1007 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1008 'field_type' => 'with-prefix-suffix',
1009 'field_prefix' => get_site_url() . '/',
1010 'field_suffix' => '',
1011 'field_description' => '',
1012 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug,
1013 )
1014 );
1015 // Enable Log In/Out Menu
1016 $field_id = 'enable_login_logout_menu';
1017 $field_slug = 'enable-login-logout-menu';
1018 add_settings_field(
1019 $field_id,
1020 // Field ID
1021 'Log In/Out Menu',
1022 // Field title
1023 [ $render_field, 'render_checkbox_toggle' ],
1024 // Callback to render field with custom arguments in the array below
1025 ASENHA_SLUG,
1026 // Settings page slug
1027 'main-section',
1028 // Section ID
1029 array(
1030 'option_name' => ASENHA_SLUG_U,
1031 'field_id' => $field_id,
1032 'field_slug' => $field_slug,
1033 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1034 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.',
1035 'field_options_wrapper' => true,
1036 'field_options_moreless' => true,
1037 'class' => 'asenha-toggle login-logout ' . $field_slug,
1038 )
1039 );
1040 // Enable Last Login Column
1041 $field_id = 'enable_last_login_column';
1042 $field_slug = 'enable-last-login-column';
1043 add_settings_field(
1044 $field_id,
1045 // Field ID
1046 'Last Login Column',
1047 // Field title
1048 [ $render_field, 'render_checkbox_toggle' ],
1049 // Callback to render field with custom arguments in the array below
1050 ASENHA_SLUG,
1051 // Settings page slug
1052 'main-section',
1053 // Section ID
1054 array(
1055 'option_name' => ASENHA_SLUG_U,
1056 'field_id' => $field_id,
1057 'field_slug' => $field_slug,
1058 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1059 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.',
1060 'field_options_wrapper' => true,
1061 'field_options_moreless' => true,
1062 'class' => 'asenha-toggle login-logout ' . $field_slug,
1063 )
1064 );
1065 // Redirect After Login
1066 $field_id = 'redirect_after_login';
1067 $field_slug = 'redirect-after-login';
1068 add_settings_field(
1069 $field_id,
1070 // Field ID
1071 'Redirect After Login',
1072 // Field title
1073 [ $render_field, 'render_checkbox_toggle' ],
1074 // Callback to render field with custom arguments in the array below
1075 ASENHA_SLUG,
1076 // Settings page slug
1077 'main-section',
1078 // Section ID
1079 array(
1080 'option_name' => ASENHA_SLUG_U,
1081 'field_id' => $field_id,
1082 'field_slug' => $field_slug,
1083 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1084 'field_description' => 'Set custom redirect URL for all or some user roles after login.',
1085 'field_options_wrapper' => true,
1086 'field_options_moreless' => true,
1087 'class' => 'asenha-toggle login-logout ' . $field_slug,
1088 )
1089 );
1090 $field_id = 'redirect_after_login_to_slug';
1091 $field_slug = 'redirect-after-login-to-slug';
1092 add_settings_field(
1093 $field_id,
1094 // Field ID
1095 'Redirect to:',
1096 // Field title
1097 [ $render_field, 'render_text_subfield' ],
1098 // Callback to render field with custom arguments in the array below
1099 ASENHA_SLUG,
1100 // Settings page slug
1101 'main-section',
1102 // Section ID
1103 array(
1104 'option_name' => ASENHA_SLUG_U,
1105 'field_id' => $field_id,
1106 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1107 'field_type' => 'with-prefix-suffix',
1108 'field_prefix' => get_site_url() . '/',
1109 'field_suffix' => ' for:',
1110 'field_description' => '',
1111 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug,
1112 )
1113 );
1114 $field_id = 'redirect_after_login_for';
1115 $field_slug = 'redirect-after-login-for';
1116 if ( is_array( $roles ) ) {
1117 foreach ( $roles as $role_slug => $role_label ) {
1118 // e.g. $role_slug is administrator, $role_label is Administrator
1119 add_settings_field(
1120 $field_id . '_' . $role_slug,
1121 // Field ID
1122 '',
1123 // Field title
1124 [ $render_field, 'render_checkbox_subfield' ],
1125 // Callback to render field with custom arguments in the array below
1126 ASENHA_SLUG,
1127 // Settings page slug
1128 'main-section',
1129 // Section ID
1130 array(
1131 'option_name' => ASENHA_SLUG_U,
1132 'parent_field_id' => $field_id,
1133 'field_id' => $role_slug,
1134 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
1135 'field_label' => $role_label,
1136 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug,
1137 )
1138 );
1139 }
1140 }
1141 // Redirect After Logout
1142 $field_id = 'redirect_after_logout';
1143 $field_slug = 'redirect-after-logout';
1144 add_settings_field(
1145 $field_id,
1146 // Field ID
1147 'Redirect After Logout',
1148 // Field title
1149 [ $render_field, 'render_checkbox_toggle' ],
1150 // Callback to render field with custom arguments in the array below
1151 ASENHA_SLUG,
1152 // Settings page slug
1153 'main-section',
1154 // Section ID
1155 array(
1156 'option_name' => ASENHA_SLUG_U,
1157 'field_id' => $field_id,
1158 'field_slug' => $field_slug,
1159 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1160 'field_description' => 'Set custom redirect URL for all or some user roles after logout.',
1161 'field_options_wrapper' => true,
1162 'field_options_moreless' => true,
1163 'class' => 'asenha-toggle login-logout ' . $field_slug,
1164 )
1165 );
1166 $field_id = 'redirect_after_logout_to_slug';
1167 $field_slug = 'redirect-after-logout-to-slug';
1168 add_settings_field(
1169 $field_id,
1170 // Field ID
1171 'Redirect to:',
1172 // Field title
1173 [ $render_field, 'render_text_subfield' ],
1174 // Callback to render field with custom arguments in the array below
1175 ASENHA_SLUG,
1176 // Settings page slug
1177 'main-section',
1178 // Section ID
1179 array(
1180 'option_name' => ASENHA_SLUG_U,
1181 'field_id' => $field_id,
1182 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1183 'field_type' => 'with-prefix-suffix',
1184 'field_prefix' => get_site_url() . '/',
1185 'field_suffix' => ' for:',
1186 'field_description' => '',
1187 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug,
1188 )
1189 );
1190 $field_id = 'redirect_after_logout_for';
1191 $field_slug = 'redirect-after-logout-for';
1192 if ( is_array( $roles ) ) {
1193 foreach ( $roles as $role_slug => $role_label ) {
1194 // e.g. $role_slug is administrator, $role_label is Administrator
1195 add_settings_field(
1196 $field_id . '_' . $role_slug,
1197 // Field ID
1198 '',
1199 // Field title
1200 [ $render_field, 'render_checkbox_subfield' ],
1201 // Callback to render field with custom arguments in the array below
1202 ASENHA_SLUG,
1203 // Settings page slug
1204 'main-section',
1205 // Section ID
1206 array(
1207 'option_name' => ASENHA_SLUG_U,
1208 'parent_field_id' => $field_id,
1209 'field_id' => $role_slug,
1210 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
1211 'field_label' => $role_label,
1212 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug,
1213 )
1214 );
1215 }
1216 }
1217 // =================================================================
1218 // CUSTOM CODE
1219 // =================================================================
1220 // Enable Custom Admin CSS
1221 $field_id = 'enable_custom_admin_css';
1222 $field_slug = 'enable-custom-admin-css';
1223 add_settings_field(
1224 $field_id,
1225 // Field ID
1226 'Custom Admin CSS',
1227 // Field title
1228 [ $render_field, 'render_checkbox_toggle' ],
1229 // Callback to render field with custom arguments in the array below
1230 ASENHA_SLUG,
1231 // Settings page slug
1232 'main-section',
1233 // Section ID
1234 array(
1235 'option_name' => ASENHA_SLUG_U,
1236 'field_id' => $field_id,
1237 'field_slug' => $field_slug,
1238 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1239 'field_description' => 'Add custom CSS on all admin pages for all user roles.',
1240 'field_options_wrapper' => true,
1241 'field_options_moreless' => true,
1242 'class' => 'asenha-toggle custom-code ' . $field_slug,
1243 )
1244 );
1245 $field_id = 'custom_admin_css';
1246 $field_slug = 'custom-admin-css';
1247 add_settings_field(
1248 $field_id,
1249 // Field ID
1250 '',
1251 // Field title
1252 [ $render_field, 'render_textarea_subfield' ],
1253 // Callback to render field with custom arguments in the array below
1254 ASENHA_SLUG,
1255 // Settings page slug
1256 'main-section',
1257 // Section ID
1258 array(
1259 'option_name' => ASENHA_SLUG_U,
1260 'field_id' => $field_id,
1261 'field_slug' => $field_slug,
1262 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1263 'field_type' => 'textarea',
1264 'field_rows' => 30,
1265 'field_intro' => '',
1266 'field_description' => '',
1267 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1268 )
1269 );
1270 // Enable Custom Frontend CSS
1271 $field_id = 'enable_custom_frontend_css';
1272 $field_slug = 'enable-custom-frontend-css';
1273 add_settings_field(
1274 $field_id,
1275 // Field ID
1276 'Custom Frontend CSS',
1277 // Field title
1278 [ $render_field, 'render_checkbox_toggle' ],
1279 // Callback to render field with custom arguments in the array below
1280 ASENHA_SLUG,
1281 // Settings page slug
1282 'main-section',
1283 // Section ID
1284 array(
1285 'option_name' => ASENHA_SLUG_U,
1286 'field_id' => $field_id,
1287 'field_slug' => $field_slug,
1288 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1289 'field_description' => 'Add custom CSS on all frontend pages for all user roles.',
1290 'field_options_wrapper' => true,
1291 'field_options_moreless' => true,
1292 'class' => 'asenha-toggle custom-code ' . $field_slug,
1293 )
1294 );
1295 $field_id = 'custom_frontend_css';
1296 $field_slug = 'custom-frontend-css';
1297 add_settings_field(
1298 $field_id,
1299 // Field ID
1300 '',
1301 // Field title
1302 [ $render_field, 'render_textarea_subfield' ],
1303 // Callback to render field with custom arguments in the array below
1304 ASENHA_SLUG,
1305 // Settings page slug
1306 'main-section',
1307 // Section ID
1308 array(
1309 'option_name' => ASENHA_SLUG_U,
1310 'field_id' => $field_id,
1311 'field_slug' => $field_slug,
1312 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1313 'field_type' => 'textarea',
1314 'field_rows' => 30,
1315 'field_intro' => '',
1316 'field_description' => '',
1317 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1318 )
1319 );
1320 // Custom Body Class
1321 $field_id = 'enable_custom_body_class';
1322 $field_slug = 'enable-custom-body-class';
1323 add_settings_field(
1324 $field_id,
1325 // Field ID
1326 'Custom Body Class',
1327 // Field title
1328 [ $render_field, 'render_checkbox_toggle' ],
1329 // Callback to render field with custom arguments in the array below
1330 ASENHA_SLUG,
1331 // Settings page slug
1332 'main-section',
1333 // Section ID
1334 array(
1335 'option_name' => ASENHA_SLUG_U,
1336 'field_id' => $field_id,
1337 'field_slug' => $field_slug,
1338 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1339 '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>.',
1340 'field_options_wrapper' => true,
1341 'field_options_moreless' => true,
1342 'class' => 'asenha-toggle custom-code ' . $field_slug,
1343 )
1344 );
1345 $field_id = 'enable_custom_body_class_for';
1346 $field_slug = 'enable-custom-body-class-for';
1347 if ( is_array( $asenha_public_post_types ) ) {
1348 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
1349 // e.g. $post_type_slug is post, $post_type_label is Posts
1350 if ( 'attachment' != $post_type_slug ) {
1351 add_settings_field(
1352 $field_id . '_' . $post_type_slug,
1353 // Field ID
1354 '',
1355 // Field title
1356 [ $render_field, 'render_checkbox_subfield' ],
1357 // Callback to render field with custom arguments in the array below
1358 ASENHA_SLUG,
1359 // Settings page slug
1360 'main-section',
1361 // Section ID
1362 array(
1363 'option_name' => ASENHA_SLUG_U,
1364 'parent_field_id' => $field_id,
1365 'field_id' => $post_type_slug,
1366 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1367 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1368 'class' => 'asenha-checkbox asenha-hide-th asenha-half custom-code ' . $field_slug . ' ' . $post_type_slug,
1369 )
1370 );
1371 }
1372 }
1373 }
1374 // Manage ads.txt and app-ads.txt
1375 $field_id = 'manage_ads_appads_txt';
1376 $field_slug = 'manage-ads-appads-txt';
1377 add_settings_field(
1378 $field_id,
1379 // Field ID
1380 'Manage ads.txt and app-ads.txt',
1381 // Field title
1382 [ $render_field, 'render_checkbox_toggle' ],
1383 // Callback to render field with custom arguments in the array below
1384 ASENHA_SLUG,
1385 // Settings page slug
1386 'main-section',
1387 // Section ID
1388 array(
1389 'option_name' => ASENHA_SLUG_U,
1390 'field_id' => $field_id,
1391 'field_slug' => $field_slug,
1392 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1393 '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.',
1394 'field_options_wrapper' => true,
1395 'field_options_moreless' => true,
1396 'class' => 'asenha-toggle custom-code ' . $field_slug,
1397 )
1398 );
1399 $field_id = 'ads_txt_content';
1400 $field_slug = 'ads-txt-content';
1401 add_settings_field(
1402 $field_id,
1403 // Field ID
1404 '',
1405 // Field title
1406 [ $render_field, 'render_textarea_subfield' ],
1407 // Callback to render field with custom arguments in the array below
1408 ASENHA_SLUG,
1409 // Settings page slug
1410 'main-section',
1411 // Section ID
1412 array(
1413 'option_name' => ASENHA_SLUG_U,
1414 'field_id' => $field_id,
1415 'field_slug' => $field_slug,
1416 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1417 'field_type' => 'textarea',
1418 'field_rows' => 15,
1419 'field_intro' => '<strong>Your ads.txt content:</strong>',
1420 '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>',
1421 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1422 )
1423 );
1424 $field_id = 'app_ads_txt_content';
1425 $field_slug = 'app-ads-txt-content';
1426 add_settings_field(
1427 $field_id,
1428 // Field ID
1429 '',
1430 // Field title
1431 [ $render_field, 'render_textarea_subfield' ],
1432 // Callback to render field with custom arguments in the array below
1433 ASENHA_SLUG,
1434 // Settings page slug
1435 'main-section',
1436 // Section ID
1437 array(
1438 'option_name' => ASENHA_SLUG_U,
1439 'field_id' => $field_id,
1440 'field_slug' => $field_slug,
1441 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1442 'field_type' => 'textarea',
1443 'field_rows' => 15,
1444 'field_intro' => '<strong>Your app-ads.txt content:</strong>',
1445 '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>',
1446 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1447 )
1448 );
1449 // Manage robots.txt
1450 $field_id = 'manage_robots_txt';
1451 $field_slug = 'manage-robots-txt';
1452 add_settings_field(
1453 $field_id,
1454 // Field ID
1455 'Manage robots.txt',
1456 // Field title
1457 [ $render_field, 'render_checkbox_toggle' ],
1458 // Callback to render field with custom arguments in the array below
1459 ASENHA_SLUG,
1460 // Settings page slug
1461 'main-section',
1462 // Section ID
1463 array(
1464 'option_name' => ASENHA_SLUG_U,
1465 'field_id' => $field_id,
1466 'field_slug' => $field_slug,
1467 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1468 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.',
1469 'field_options_wrapper' => true,
1470 'field_options_moreless' => true,
1471 'class' => 'asenha-toggle custom-code ' . $field_slug,
1472 )
1473 );
1474 $field_id = 'robots_txt_content';
1475 $field_slug = 'robots-txt-content';
1476 add_settings_field(
1477 $field_id,
1478 // Field ID
1479 '',
1480 // Field title
1481 [ $render_field, 'render_textarea_subfield' ],
1482 // Callback to render field with custom arguments in the array below
1483 ASENHA_SLUG,
1484 // Settings page slug
1485 'main-section',
1486 // Section ID
1487 array(
1488 'option_name' => ASENHA_SLUG_U,
1489 'field_id' => $field_id,
1490 'field_slug' => $field_slug,
1491 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1492 'field_type' => 'textarea',
1493 'field_rows' => 20,
1494 'field_intro' => '',
1495 '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>',
1496 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1497 )
1498 );
1499 // Insert <head>, <body> and <footer> code
1500 $field_id = 'insert_head_body_footer_code';
1501 $field_slug = 'insert-head-body-footer-code';
1502 add_settings_field(
1503 $field_id,
1504 // Field ID
1505 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code',
1506 // Field title
1507 [ $render_field, 'render_checkbox_toggle' ],
1508 // Callback to render field with custom arguments in the array below
1509 ASENHA_SLUG,
1510 // Settings page slug
1511 'main-section',
1512 // Section ID
1513 array(
1514 'option_name' => ASENHA_SLUG_U,
1515 'field_id' => $field_id,
1516 'field_slug' => $field_slug,
1517 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1518 '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.',
1519 'field_options_wrapper' => true,
1520 'field_options_moreless' => true,
1521 'class' => 'asenha-toggle custom-code ' . $field_slug,
1522 )
1523 );
1524 $field_id = 'head_code_priority';
1525 $field_slug = 'head-code-priority';
1526 add_settings_field(
1527 $field_id,
1528 // Field ID
1529 '',
1530 // Field title
1531 [ $render_field, 'render_number_subfield' ],
1532 // Callback to render field with custom arguments in the array below
1533 ASENHA_SLUG,
1534 // Settings page slug
1535 'main-section',
1536 // Section ID
1537 array(
1538 'option_name' => ASENHA_SLUG_U,
1539 'field_id' => $field_id,
1540 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1541 'field_type' => 'with-prefix-suffix',
1542 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>',
1543 'field_suffix' => '',
1544 'field_intro' => '',
1545 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;',
1546 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1547 )
1548 );
1549 $field_id = 'head_code';
1550 $field_slug = 'head-code';
1551 add_settings_field(
1552 $field_id,
1553 // Field ID
1554 '',
1555 // Field title
1556 [ $render_field, 'render_textarea_subfield' ],
1557 // Callback to render field with custom arguments in the array below
1558 ASENHA_SLUG,
1559 // Settings page slug
1560 'main-section',
1561 // Section ID
1562 array(
1563 'option_name' => ASENHA_SLUG_U,
1564 'field_id' => $field_id,
1565 'field_slug' => $field_slug,
1566 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1567 'field_type' => 'textarea',
1568 'field_rows' => 15,
1569 'field_intro' => '',
1570 'field_description' => '',
1571 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1572 )
1573 );
1574 $field_id = 'body_code_priority';
1575 $field_slug = 'body-code-priority';
1576 add_settings_field(
1577 $field_id,
1578 // Field ID
1579 '',
1580 // Field title
1581 [ $render_field, 'render_number_subfield' ],
1582 // Callback to render field with custom arguments in the array below
1583 ASENHA_SLUG,
1584 // Settings page slug
1585 'main-section',
1586 // Section ID
1587 array(
1588 'option_name' => ASENHA_SLUG_U,
1589 'field_id' => $field_id,
1590 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1591 'field_type' => 'with-prefix-suffix',
1592 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>',
1593 'field_suffix' => '',
1594 'field_intro' => '',
1595 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;',
1596 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1597 )
1598 );
1599 $field_id = 'body_code';
1600 $field_slug = 'body-code';
1601 add_settings_field(
1602 $field_id,
1603 // Field ID
1604 '',
1605 // Field title
1606 [ $render_field, 'render_textarea_subfield' ],
1607 // Callback to render field with custom arguments in the array below
1608 ASENHA_SLUG,
1609 // Settings page slug
1610 'main-section',
1611 // Section ID
1612 array(
1613 'option_name' => ASENHA_SLUG_U,
1614 'field_id' => $field_id,
1615 'field_slug' => $field_slug,
1616 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1617 'field_type' => 'textarea',
1618 'field_rows' => 15,
1619 'field_intro' => '',
1620 'field_description' => '',
1621 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1622 )
1623 );
1624 $field_id = 'footer_code_priority';
1625 $field_slug = 'footer-code-priority';
1626 add_settings_field(
1627 $field_id,
1628 // Field ID
1629 '',
1630 // Field title
1631 [ $render_field, 'render_number_subfield' ],
1632 // Callback to render field with custom arguments in the array below
1633 ASENHA_SLUG,
1634 // Settings page slug
1635 'main-section',
1636 // Section ID
1637 array(
1638 'option_name' => ASENHA_SLUG_U,
1639 'field_id' => $field_id,
1640 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1641 'field_type' => 'with-prefix-suffix',
1642 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>',
1643 'field_suffix' => '',
1644 'field_intro' => '',
1645 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;',
1646 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1647 )
1648 );
1649 $field_id = 'footer_code';
1650 $field_slug = 'footer-code';
1651 add_settings_field(
1652 $field_id,
1653 // Field ID
1654 '',
1655 // Field title
1656 [ $render_field, 'render_textarea_subfield' ],
1657 // Callback to render field with custom arguments in the array below
1658 ASENHA_SLUG,
1659 // Settings page slug
1660 'main-section',
1661 // Section ID
1662 array(
1663 'option_name' => ASENHA_SLUG_U,
1664 'field_id' => $field_id,
1665 'field_slug' => $field_slug,
1666 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1667 'field_type' => 'textarea',
1668 'field_rows' => 15,
1669 'field_intro' => '',
1670 'field_description' => '',
1671 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1672 )
1673 );
1674 // =================================================================
1675 // DISABLE COMPONENTS
1676 // =================================================================
1677 // Disable Gutenberg
1678 $field_id = 'disable_gutenberg';
1679 $field_slug = 'disable-gutenberg';
1680 add_settings_field(
1681 $field_id,
1682 // Field ID
1683 'Disable Gutenberg',
1684 // Field title
1685 [ $render_field, 'render_checkbox_toggle' ],
1686 // Callback to render field with custom arguments in the array below
1687 ASENHA_SLUG,
1688 // Settings page slug
1689 'main-section',
1690 // Section ID
1691 array(
1692 'option_name' => ASENHA_SLUG_U,
1693 'field_id' => $field_id,
1694 'field_slug' => $field_slug,
1695 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1696 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.',
1697 'field_options_wrapper' => true,
1698 'field_options_moreless' => true,
1699 'class' => 'asenha-toggle disable-components ' . $field_slug,
1700 )
1701 );
1702 $field_id = 'disable_gutenberg_for';
1703 $field_slug = 'disable-gutenberg-for';
1704 if ( is_array( $asenha_gutenberg_post_types ) ) {
1705 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) {
1706 // e.g. $post_type_slug is post, $post_type_label is Posts
1707 add_settings_field(
1708 $field_id . '_' . $post_type_slug,
1709 // Field ID
1710 '',
1711 // Field title
1712 [ $render_field, 'render_checkbox_subfield' ],
1713 // Callback to render field with custom arguments in the array below
1714 ASENHA_SLUG,
1715 // Settings page slug
1716 'main-section',
1717 // Section ID
1718 array(
1719 'option_name' => ASENHA_SLUG_U,
1720 'parent_field_id' => $field_id,
1721 'field_id' => $post_type_slug,
1722 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1723 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1724 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug,
1725 )
1726 );
1727 }
1728 }
1729 $field_id = 'disable_gutenberg_frontend_styles';
1730 $field_slug = 'disable-gutenberg-frontend-styles';
1731 add_settings_field(
1732 $field_id,
1733 // Field ID
1734 '',
1735 // Field title
1736 [ $render_field, 'render_checkbox_plain' ],
1737 // Callback to render field with custom arguments in the array below
1738 ASENHA_SLUG,
1739 // Settings page slug
1740 'main-section',
1741 // Section ID
1742 array(
1743 'option_name' => ASENHA_SLUG_U,
1744 'field_id' => $field_id,
1745 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1746 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.',
1747 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug,
1748 )
1749 );
1750 // Disable Block-Based Widgets Screen
1751 $field_id = 'disable_block_widgets';
1752 $field_slug = 'disable-block-widgets';
1753 add_settings_field(
1754 $field_id,
1755 // Field ID
1756 'Disable Block-Based Widgets Settings Screen',
1757 // Field title
1758 [ $render_field, 'render_checkbox_toggle' ],
1759 // Callback to render field with custom arguments in the array below
1760 ASENHA_SLUG,
1761 // Settings page slug
1762 'main-section',
1763 // Section ID
1764 array(
1765 'option_name' => ASENHA_SLUG_U,
1766 'field_id' => $field_id,
1767 'field_slug' => $field_slug,
1768 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1769 'field_description' => 'Restores the classic widgets settings screen when using a classic (non-block) theme. This has no effect on block themes.',
1770 'field_options_wrapper' => true,
1771 'field_options_moreless' => true,
1772 'class' => 'asenha-toggle disable-components ' . $field_slug,
1773 )
1774 );
1775 // Disable Comments
1776 $field_id = 'disable_comments';
1777 $field_slug = 'disable-comments';
1778 add_settings_field(
1779 $field_id,
1780 // Field ID
1781 'Disable Comments',
1782 // Field title
1783 [ $render_field, 'render_checkbox_toggle' ],
1784 // Callback to render field with custom arguments in the array below
1785 ASENHA_SLUG,
1786 // Settings page slug
1787 'main-section',
1788 // Section ID
1789 array(
1790 'option_name' => ASENHA_SLUG_U,
1791 'field_id' => $field_id,
1792 'field_slug' => $field_slug,
1793 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1794 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.',
1795 'field_options_wrapper' => true,
1796 'field_options_moreless' => true,
1797 'class' => 'asenha-toggle disable-components ' . $field_slug,
1798 )
1799 );
1800 $field_id = 'disable_comments_for';
1801 $field_slug = 'disable-comments-for';
1802 if ( is_array( $asenha_public_post_types ) ) {
1803 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
1804 // e.g. $post_type_slug is post, $post_type_label is Posts
1805 add_settings_field(
1806 $field_id . '_' . $post_type_slug,
1807 // Field ID
1808 '',
1809 // Field title
1810 [ $render_field, 'render_checkbox_subfield' ],
1811 // Callback to render field with custom arguments in the array below
1812 ASENHA_SLUG,
1813 // Settings page slug
1814 'main-section',
1815 // Section ID
1816 array(
1817 'option_name' => ASENHA_SLUG_U,
1818 'parent_field_id' => $field_id,
1819 'field_id' => $post_type_slug,
1820 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1821 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1822 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug,
1823 )
1824 );
1825 }
1826 }
1827 // Disable REST API
1828 $field_id = 'disable_rest_api';
1829 $field_slug = 'disable-rest-api';
1830 add_settings_field(
1831 $field_id,
1832 // Field ID
1833 'Disable REST API',
1834 // Field title
1835 [ $render_field, 'render_checkbox_toggle' ],
1836 // Callback to render field with custom arguments in the array below
1837 ASENHA_SLUG,
1838 // Settings page slug
1839 'main-section',
1840 // Section ID
1841 array(
1842 'option_name' => ASENHA_SLUG_U,
1843 'field_id' => $field_id,
1844 'field_slug' => $field_slug,
1845 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1846 'field_description' => 'Disable REST API access for non-authenticated users and remove URL traces from &lt;head&gt;, HTTP headers and WP RSD endpoint.',
1847 'field_options_wrapper' => true,
1848 'field_options_moreless' => true,
1849 'class' => 'asenha-toggle disable-components ' . $field_slug,
1850 )
1851 );
1852 // Disable Feeds
1853 $field_id = 'disable_feeds';
1854 $field_slug = 'disable-feeds';
1855 add_settings_field(
1856 $field_id,
1857 // Field ID
1858 'Disable Feeds',
1859 // Field title
1860 [ $render_field, 'render_checkbox_toggle' ],
1861 // Callback to render field with custom arguments in the array below
1862 ASENHA_SLUG,
1863 // Settings page slug
1864 'main-section',
1865 // Section ID
1866 array(
1867 'option_name' => ASENHA_SLUG_U,
1868 'field_id' => $field_id,
1869 'field_slug' => $field_slug,
1870 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1871 '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;.',
1872 'field_options_wrapper' => true,
1873 'field_options_moreless' => true,
1874 'class' => 'asenha-toggle disable-components ' . $field_slug,
1875 )
1876 );
1877 // Disable Auto Updates
1878 $field_id = 'disable_all_updates';
1879 $field_slug = 'disable-all-updates';
1880 add_settings_field(
1881 $field_id,
1882 // Field ID
1883 'Disable All Updates',
1884 // Field title
1885 [ $render_field, 'render_checkbox_toggle' ],
1886 // Callback to render field with custom arguments in the array below
1887 ASENHA_SLUG,
1888 // Settings page slug
1889 'main-section',
1890 // Section ID
1891 array(
1892 'option_name' => ASENHA_SLUG_U,
1893 'field_id' => $field_id,
1894 'field_slug' => $field_slug,
1895 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1896 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.',
1897 'field_options_wrapper' => true,
1898 'field_options_moreless' => true,
1899 'class' => 'asenha-toggle disable-components ' . $field_slug,
1900 )
1901 );
1902 // Disable Smaller Components
1903 $field_id = 'disable_smaller_components';
1904 $field_slug = 'disable-smaller-components';
1905 add_settings_field(
1906 $field_id,
1907 // Field ID
1908 'Disable Smaller Components',
1909 // Field title
1910 [ $render_field, 'render_checkbox_toggle' ],
1911 // Callback to render field with custom arguments in the array below
1912 ASENHA_SLUG,
1913 // Settings page slug
1914 'main-section',
1915 // Section ID
1916 array(
1917 'option_name' => ASENHA_SLUG_U,
1918 'field_id' => $field_id,
1919 'field_slug' => $field_slug,
1920 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1921 'field_description' => 'Prevent smaller components from running or loading. Make the site more secure, load slightly faster and be more optimized for crawling by search engines.',
1922 'field_options_wrapper' => true,
1923 'field_options_moreless' => true,
1924 'class' => 'asenha-toggle admin-interface ' . $field_slug,
1925 )
1926 );
1927 $field_id = 'disable_head_generator_tag';
1928 $field_slug = 'disable-head-generator-tag';
1929 add_settings_field(
1930 $field_id,
1931 // Field ID
1932 '',
1933 // Field title
1934 [ $render_field, 'render_checkbox_plain' ],
1935 // Callback to render field with custom arguments in the array below
1936 ASENHA_SLUG,
1937 // Settings page slug
1938 'main-section',
1939 // Section ID
1940 array(
1941 'option_name' => ASENHA_SLUG_U,
1942 'field_id' => $field_id,
1943 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1944 '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).',
1945 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
1946 )
1947 );
1948 $field_id = 'disable_head_wlwmanifest_tag';
1949 $field_slug = 'disable-head-wlwmanifest-tag';
1950 add_settings_field(
1951 $field_id,
1952 // Field ID
1953 '',
1954 // Field title
1955 [ $render_field, 'render_checkbox_plain' ],
1956 // Callback to render field with custom arguments in the array below
1957 ASENHA_SLUG,
1958 // Settings page slug
1959 'main-section',
1960 // Section ID
1961 array(
1962 'option_name' => ASENHA_SLUG_U,
1963 'field_id' => $field_id,
1964 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1965 '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.',
1966 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
1967 )
1968 );
1969 $field_id = 'disable_head_rsd_tag';
1970 $field_slug = 'disable-head-rsd-tag';
1971 add_settings_field(
1972 $field_id,
1973 // Field ID
1974 '',
1975 // Field title
1976 [ $render_field, 'render_checkbox_plain' ],
1977 // Callback to render field with custom arguments in the array below
1978 ASENHA_SLUG,
1979 // Settings page slug
1980 'main-section',
1981 // Section ID
1982 array(
1983 'option_name' => ASENHA_SLUG_U,
1984 'field_id' => $field_id,
1985 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1986 '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.',
1987 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
1988 )
1989 );
1990 $field_id = 'disable_head_shortlink_tag';
1991 $field_slug = 'disable-head-shortlink-tag';
1992 add_settings_field(
1993 $field_id,
1994 // Field ID
1995 '',
1996 // Field title
1997 [ $render_field, 'render_checkbox_plain' ],
1998 // Callback to render field with custom arguments in the array below
1999 ASENHA_SLUG,
2000 // Settings page slug
2001 'main-section',
2002 // Section ID
2003 array(
2004 'option_name' => ASENHA_SLUG_U,
2005 'field_id' => $field_id,
2006 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2007 '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.',
2008 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
2009 )
2010 );
2011 $field_id = 'disable_frontend_dashicons';
2012 $field_slug = 'disable-frontend-dashicons';
2013 add_settings_field(
2014 $field_id,
2015 // Field ID
2016 '',
2017 // Field title
2018 [ $render_field, 'render_checkbox_plain' ],
2019 // Callback to render field with custom arguments in the array below
2020 ASENHA_SLUG,
2021 // Settings page slug
2022 'main-section',
2023 // Section ID
2024 array(
2025 'option_name' => ASENHA_SLUG_U,
2026 'field_id' => $field_id,
2027 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2028 'field_label' => 'Disable loading of <strong>dashicons CSS and JS files</strong> on the front-end for public site visitors.',
2029 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
2030 )
2031 );
2032 $field_id = 'disable_emoji_support';
2033 $field_slug = 'disable-emoji-support';
2034 add_settings_field(
2035 $field_id,
2036 // Field ID
2037 '',
2038 // Field title
2039 [ $render_field, 'render_checkbox_plain' ],
2040 // Callback to render field with custom arguments in the array below
2041 ASENHA_SLUG,
2042 // Settings page slug
2043 'main-section',
2044 // Section ID
2045 array(
2046 'option_name' => ASENHA_SLUG_U,
2047 'field_id' => $field_id,
2048 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2049 '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.',
2050 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug,
2051 )
2052 );
2053 // =================================================================
2054 // SECURITY
2055 // =================================================================
2056 // Limit Login Attempts
2057 $field_id = 'limit_login_attempts';
2058 $field_slug = 'limit-login-attempts';
2059 add_settings_field(
2060 $field_id,
2061 // Field ID
2062 'Limit Login Attempts',
2063 // Field title
2064 [ $render_field, 'render_checkbox_toggle' ],
2065 // Callback to render field with custom arguments in the array below
2066 ASENHA_SLUG,
2067 // Settings page slug
2068 'main-section',
2069 // Section ID
2070 array(
2071 'option_name' => ASENHA_SLUG_U,
2072 'field_id' => $field_id,
2073 'field_slug' => $field_slug,
2074 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2075 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.',
2076 'field_options_wrapper' => true,
2077 'field_options_moreless' => true,
2078 'class' => 'asenha-toggle security ' . $field_slug,
2079 )
2080 );
2081 $field_id = 'login_fails_allowed';
2082 $field_slug = 'login-fails-allowed';
2083 add_settings_field(
2084 $field_id,
2085 // Field ID
2086 '',
2087 // Field title
2088 [ $render_field, 'render_text_subfield' ],
2089 // Callback to render field with custom arguments in the array below
2090 ASENHA_SLUG,
2091 // Settings page slug
2092 'main-section',
2093 // Section ID
2094 array(
2095 'option_name' => ASENHA_SLUG_U,
2096 'field_id' => $field_id,
2097 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2098 'field_type' => 'with-prefix-suffix',
2099 'field_prefix' => '',
2100 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout',
2101 'field_description' => '',
2102 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug,
2103 )
2104 );
2105 $field_id = 'login_lockout_maxcount';
2106 $field_slug = 'login-lockout-maxcount';
2107 add_settings_field(
2108 $field_id,
2109 // Field ID
2110 '',
2111 // Field title
2112 [ $render_field, 'render_text_subfield' ],
2113 // Callback to render field with custom arguments in the array below
2114 ASENHA_SLUG,
2115 // Settings page slug
2116 'main-section',
2117 // Section ID
2118 array(
2119 'option_name' => ASENHA_SLUG_U,
2120 'field_id' => $field_id,
2121 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2122 'field_type' => 'with-prefix-suffix',
2123 'field_prefix' => '',
2124 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours',
2125 'field_description' => '',
2126 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug,
2127 )
2128 );
2129 $field_id = 'login_attempts_log_table';
2130 $field_slug = 'login-attempts-log-table';
2131 add_settings_field(
2132 $field_id,
2133 // Field ID
2134 '',
2135 // Field title
2136 [ $render_field, 'render_datatable' ],
2137 // Callback to render field with custom arguments in the array below
2138 ASENHA_SLUG,
2139 // Settings page slug
2140 'main-section',
2141 // Section ID
2142 array(
2143 'option_name' => ASENHA_SLUG_U,
2144 'field_id' => $field_id,
2145 'field_slug' => $field_slug,
2146 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2147 'field_type' => 'datatable',
2148 'field_description' => '',
2149 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug,
2150 'table_title' => 'Failed Login Attempts Log',
2151 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
2152 )
2153 );
2154 // Obfuscate Author Slugs
2155 $field_id = 'obfuscate_author_slugs';
2156 $field_slug = 'obfuscate-author-slugs';
2157 add_settings_field(
2158 $field_id,
2159 // Field ID
2160 'Obfuscate Author Slugs',
2161 // Field title
2162 [ $render_field, 'render_checkbox_toggle' ],
2163 // Callback to render field with custom arguments in the array below
2164 ASENHA_SLUG,
2165 // Settings page slug
2166 'main-section',
2167 // Section ID
2168 array(
2169 'option_name' => ASENHA_SLUG_U,
2170 'field_id' => $field_id,
2171 'field_slug' => $field_slug,
2172 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2173 '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.',
2174 'field_options_wrapper' => false,
2175 'class' => 'asenha-toggle security ' . $field_slug,
2176 )
2177 );
2178 // Disable XML-RPC
2179 $field_id = 'disable_xmlrpc';
2180 $field_slug = 'disable-xmlrpc';
2181 add_settings_field(
2182 $field_id,
2183 // Field ID
2184 'Disable XML-RPC',
2185 // Field title
2186 [ $render_field, 'render_checkbox_toggle' ],
2187 // Callback to render field with custom arguments in the array below
2188 ASENHA_SLUG,
2189 // Settings page slug
2190 'main-section',
2191 // Section ID
2192 array(
2193 'option_name' => ASENHA_SLUG_U,
2194 'field_id' => $field_id,
2195 'field_slug' => $field_slug,
2196 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2197 '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. ',
2198 'field_options_wrapper' => false,
2199 'class' => 'asenha-toggle security ' . $field_slug,
2200 )
2201 );
2202 // =================================================================
2203 // OPTIMIZATIONS
2204 // =================================================================
2205 // Image Upload Control
2206 $field_id = 'image_upload_control';
2207 $field_slug = 'image-upload-control';
2208 add_settings_field(
2209 $field_id,
2210 // Field ID
2211 'Image Upload Control',
2212 // Field title
2213 [ $render_field, 'render_checkbox_toggle' ],
2214 // Callback to render field with custom arguments in the array below
2215 ASENHA_SLUG,
2216 // Settings page slug
2217 'main-section',
2218 // Section ID
2219 array(
2220 'option_name' => ASENHA_SLUG_U,
2221 'field_id' => $field_id,
2222 'field_slug' => $field_slug,
2223 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2224 '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.',
2225 'field_options_wrapper' => true,
2226 'field_options_moreless' => true,
2227 'class' => 'asenha-toggle optimizations ' . $field_slug,
2228 )
2229 );
2230 $field_id = 'image_max_width';
2231 $field_slug = 'image-max-width';
2232 add_settings_field(
2233 $field_id,
2234 // Field ID
2235 '',
2236 // Field title
2237 [ $render_field, 'render_number_subfield' ],
2238 // Callback to render field with custom arguments in the array below
2239 ASENHA_SLUG,
2240 // Settings page slug
2241 'main-section',
2242 // Section ID
2243 array(
2244 'option_name' => ASENHA_SLUG_U,
2245 'field_id' => $field_id,
2246 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2247 'field_type' => 'with-prefix-suffix',
2248 'field_prefix' => 'Max width:',
2249 'field_suffix' => 'pixels. <span class="faded">(Default is 1920 pixels)</span>',
2250 'field_intro' => '',
2251 'field_description' => '',
2252 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug,
2253 )
2254 );
2255 $field_id = 'image_max_height';
2256 $field_slug = 'image-max-height';
2257 add_settings_field(
2258 $field_id,
2259 // Field ID
2260 '',
2261 // Field title
2262 [ $render_field, 'render_number_subfield' ],
2263 // Callback to render field with custom arguments in the array below
2264 ASENHA_SLUG,
2265 // Settings page slug
2266 'main-section',
2267 // Section ID
2268 array(
2269 'option_name' => ASENHA_SLUG_U,
2270 'field_id' => $field_id,
2271 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2272 'field_type' => 'with-prefix-suffix',
2273 'field_prefix' => 'Max height:',
2274 'field_suffix' => 'pixels <span class="faded">(Default is 1920 pixels)</span>',
2275 'field_intro' => '',
2276 'field_description' => 'To exclude an image from conversion and resizing, append \'-nr\' suffix to the file name, e.g. bird-photo-4k-nr.jpg',
2277 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug,
2278 )
2279 );
2280 // Enable Revisions Control
2281 $field_id = 'enable_revisions_control';
2282 $field_slug = 'enable-revisions-control';
2283 add_settings_field(
2284 $field_id,
2285 // Field ID
2286 'Revisions Control',
2287 // Field title
2288 [ $render_field, 'render_checkbox_toggle' ],
2289 // Callback to render field with custom arguments in the array below
2290 ASENHA_SLUG,
2291 // Settings page slug
2292 'main-section',
2293 // Section ID
2294 array(
2295 'option_name' => ASENHA_SLUG_U,
2296 'field_id' => $field_id,
2297 'field_slug' => $field_slug,
2298 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2299 'field_description' => 'Prevent bloating the database by limiting the number of revisions to keep for some or all post types supporting revisions.',
2300 'field_options_wrapper' => true,
2301 'field_options_moreless' => true,
2302 'class' => 'asenha-toggle optimizations ' . $field_slug,
2303 )
2304 );
2305 $field_id = 'revisions_max_number';
2306 $field_slug = 'revisions-max-number';
2307 add_settings_field(
2308 $field_id,
2309 // Field ID
2310 '',
2311 // Field title
2312 [ $render_field, 'render_number_subfield' ],
2313 // Callback to render field with custom arguments in the array below
2314 ASENHA_SLUG,
2315 // Settings page slug
2316 'main-section',
2317 // Section ID
2318 array(
2319 'option_name' => ASENHA_SLUG_U,
2320 'field_id' => $field_id,
2321 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2322 'field_type' => 'with-prefix-suffix',
2323 'field_prefix' => 'Limit to',
2324 'field_suffix' => 'revisions for:',
2325 'field_intro' => '',
2326 'field_description' => '',
2327 'class' => 'asenha-number asenha-hide-th extra-narrow optimizations ' . $field_slug,
2328 )
2329 );
2330 $field_id = 'enable_revisions_control_for';
2331 $field_slug = 'enable-revisions-control-for';
2332 if ( is_array( $asenha_revisions_post_types ) ) {
2333 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) {
2334 // e.g. $post_type_slug is post, $post_type_label is Posts
2335 add_settings_field(
2336 $field_id . '_' . $post_type_slug,
2337 // Field ID
2338 '',
2339 // Field title
2340 [ $render_field, 'render_checkbox_subfield' ],
2341 // Callback to render field with custom arguments in the array below
2342 ASENHA_SLUG,
2343 // Settings page slug
2344 'main-section',
2345 // Section ID
2346 array(
2347 'option_name' => ASENHA_SLUG_U,
2348 'parent_field_id' => $field_id,
2349 'field_id' => $post_type_slug,
2350 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
2351 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
2352 'class' => 'asenha-checkbox asenha-hide-th asenha-half optimizations ' . $field_slug . ' ' . $post_type_slug,
2353 )
2354 );
2355 }
2356 }
2357 // Enable Heartbeat Control
2358 $field_id = 'enable_heartbeat_control';
2359 $field_slug = 'enable-heartbeat-control';
2360 add_settings_field(
2361 $field_id,
2362 // Field ID
2363 'Heartbeat Control',
2364 // Field title
2365 [ $render_field, 'render_checkbox_toggle' ],
2366 // Callback to render field with custom arguments in the array below
2367 ASENHA_SLUG,
2368 // Settings page slug
2369 'main-section',
2370 // Section ID
2371 array(
2372 'option_name' => ASENHA_SLUG_U,
2373 'field_id' => $field_id,
2374 'field_slug' => $field_slug,
2375 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2376 '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.',
2377 'field_options_wrapper' => true,
2378 'field_options_moreless' => true,
2379 'class' => 'asenha-toggle optimizations ' . $field_slug,
2380 )
2381 );
2382 $field_id = 'heartbeat_control_for_admin_pages';
2383 $field_slug = 'heartbeat-control-for-admin-pages';
2384 add_settings_field(
2385 $field_id,
2386 // Field ID
2387 'On admin pages',
2388 // Field title
2389 [ $render_field, 'render_radio_buttons_subfield' ],
2390 // Callback to render field with custom arguments in the array below
2391 ASENHA_SLUG,
2392 // Settings page slug
2393 'main-section',
2394 // Section ID
2395 array(
2396 'option_name' => ASENHA_SLUG_U,
2397 'field_id' => $field_id,
2398 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2399 'field_radios' => array(
2400 'Keep as is' => 'default',
2401 'Modify' => 'modify',
2402 'Disable' => 'disable',
2403 ),
2404 'field_default' => 'default',
2405 'class' => 'asenha-radio-buttons optimizations ' . $field_slug,
2406 )
2407 );
2408 $field_id = 'heartbeat_interval_for_admin_pages';
2409 $field_slug = 'heartbeat-interval-for-admin-pages';
2410 add_settings_field(
2411 $field_id,
2412 // Field ID
2413 '',
2414 // Field title
2415 [ $render_field, 'render_select_subfield' ],
2416 // Callback to render field with custom arguments in the array below
2417 ASENHA_SLUG,
2418 // Settings page slug
2419 'main-section',
2420 // Section ID
2421 array(
2422 'option_name' => ASENHA_SLUG_U,
2423 'field_id' => $field_id,
2424 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2425 'field_type' => 'with-prefix-suffix',
2426 'field_prefix' => 'Set interval to once every',
2427 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>',
2428 'field_select_options' => array(
2429 '15 seconds' => 15,
2430 '30 seconds' => 30,
2431 '1 minute' => 60,
2432 '2 minutes' => 120,
2433 '3 minutes' => 180,
2434 '5 minutes' => 300,
2435 '10 minutes' => 600,
2436 ),
2437 'field_select_default' => 60,
2438 'field_intro' => '',
2439 'field_description' => '',
2440 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2441 'display_none_on_load' => true,
2442 )
2443 );
2444 $field_id = 'heartbeat_control_for_post_edit';
2445 $field_slug = 'heartbeat-control-for-post-edit';
2446 add_settings_field(
2447 $field_id,
2448 // Field ID
2449 'On post creation and edit screens',
2450 // Field title
2451 [ $render_field, 'render_radio_buttons_subfield' ],
2452 // Callback to render field with custom arguments in the array below
2453 ASENHA_SLUG,
2454 // Settings page slug
2455 'main-section',
2456 // Section ID
2457 array(
2458 'option_name' => ASENHA_SLUG_U,
2459 'field_id' => $field_id,
2460 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2461 'field_radios' => array(
2462 'Keep as is' => 'default',
2463 'Modify' => 'modify',
2464 'Disable' => 'disable',
2465 ),
2466 'field_default' => 'default',
2467 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug,
2468 )
2469 );
2470 $field_id = 'heartbeat_interval_for_post_edit';
2471 $field_slug = 'heartbeat-interval-for-post-edit';
2472 add_settings_field(
2473 $field_id,
2474 // Field ID
2475 '',
2476 // Field title
2477 [ $render_field, 'render_select_subfield' ],
2478 // Callback to render field with custom arguments in the array below
2479 ASENHA_SLUG,
2480 // Settings page slug
2481 'main-section',
2482 // Section ID
2483 array(
2484 'option_name' => ASENHA_SLUG_U,
2485 'field_id' => $field_id,
2486 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2487 'field_type' => 'with-prefix-suffix',
2488 'field_prefix' => 'Set interval to once every',
2489 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>',
2490 'field_select_options' => array(
2491 '15 seconds' => 15,
2492 '30 seconds' => 30,
2493 '45 seconds' => 45,
2494 '60 seconds' => 60,
2495 '90 seconds' => 90,
2496 '120 seconds' => 120,
2497 ),
2498 'field_select_default' => 15,
2499 'field_intro' => '',
2500 'field_description' => '',
2501 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2502 'display_none_on_load' => true,
2503 )
2504 );
2505 $field_id = 'heartbeat_control_for_frontend';
2506 $field_slug = 'heartbeat-control-for-frontend';
2507 add_settings_field(
2508 $field_id,
2509 // Field ID
2510 'On the frontend',
2511 // Field title
2512 [ $render_field, 'render_radio_buttons_subfield' ],
2513 // Callback to render field with custom arguments in the array below
2514 ASENHA_SLUG,
2515 // Settings page slug
2516 'main-section',
2517 // Section ID
2518 array(
2519 'option_name' => ASENHA_SLUG_U,
2520 'field_id' => $field_id,
2521 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2522 'field_radios' => array(
2523 'Keep as is' => 'default',
2524 'Modify' => 'modify',
2525 'Disable' => 'disable',
2526 ),
2527 'field_default' => 'default',
2528 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug,
2529 )
2530 );
2531 $field_id = 'heartbeat_interval_for_frontend';
2532 $field_slug = 'heartbeat-interval-for-frontend';
2533 add_settings_field(
2534 $field_id,
2535 // Field ID
2536 '',
2537 // Field title
2538 [ $render_field, 'render_select_subfield' ],
2539 // Callback to render field with custom arguments in the array below
2540 ASENHA_SLUG,
2541 // Settings page slug
2542 'main-section',
2543 // Section ID
2544 array(
2545 'option_name' => ASENHA_SLUG_U,
2546 'field_id' => $field_id,
2547 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2548 'field_type' => 'with-prefix-suffix',
2549 'field_prefix' => 'Set interval to once every',
2550 'field_suffix' => '',
2551 'field_select_options' => array(
2552 '15 seconds' => 15,
2553 '30 seconds' => 30,
2554 '1 minute' => 60,
2555 '2 minutes' => 120,
2556 '3 minutes' => 180,
2557 '5 minutes' => 300,
2558 '10 minutes' => 600,
2559 ),
2560 'field_select_default' => 60,
2561 'field_intro' => '',
2562 'field_description' => '',
2563 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2564 'display_none_on_load' => true,
2565 )
2566 );
2567 // =================================================================
2568 // UTILITIES
2569 // =================================================================
2570 // SMTP Email Delivery
2571 $field_id = 'smtp_email_delivery';
2572 $field_slug = 'smtp-email-delivery';
2573 add_settings_field(
2574 $field_id,
2575 // Field ID
2576 'Email Delivery',
2577 // Field title
2578 [ $render_field, 'render_checkbox_toggle' ],
2579 // Callback to render field with custom arguments in the array below
2580 ASENHA_SLUG,
2581 // Settings page slug
2582 'main-section',
2583 // Section ID
2584 array(
2585 'option_name' => ASENHA_SLUG_U,
2586 'field_id' => $field_id,
2587 'field_slug' => $field_slug,
2588 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2589 'field_description' => 'Set custom sender name and email. Optionally use external SMTP service to ensure notification and transactional emails from your site are being delivered to inboxes.',
2590 'field_options_wrapper' => true,
2591 'field_options_moreless' => true,
2592 'class' => 'asenha-toggle utilities ' . $field_slug,
2593 )
2594 );
2595 $field_id = 'smtp_default_from_description';
2596 $field_slug = 'smtp-default-from-description';
2597 add_settings_field(
2598 $field_id,
2599 // Field ID
2600 '',
2601 // Field title
2602 [ $render_field, 'render_description_subfield' ],
2603 // Callback to render field with custom arguments in the array below
2604 ASENHA_SLUG,
2605 // Settings page slug
2606 'main-section',
2607 // Section ID
2608 array(
2609 'option_name' => ASENHA_SLUG_U,
2610 'field_description' => 'If set, the following sender name/email overrides WordPress core defaults but can still be overridden by other plugins that enables custom sender name/email, e.g. form plugins.',
2611 'class' => 'asenha-description utilities ' . $field_slug,
2612 )
2613 );
2614 $field_id = 'smtp_default_from_name';
2615 $field_slug = 'smtp-default-from-name';
2616 add_settings_field(
2617 $field_id,
2618 // Field ID
2619 '<span class="field-sublabel sublabel-wide">Sender name</span>',
2620 // Field title
2621 [ $render_field, 'render_text_subfield' ],
2622 // Callback to render field with custom arguments in the array below
2623 ASENHA_SLUG,
2624 // Settings page slug
2625 'main-section',
2626 // Section ID
2627 array(
2628 'option_name' => ASENHA_SLUG_U,
2629 'field_id' => $field_id,
2630 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2631 'field_type' => '',
2632 'field_prefix' => '',
2633 'field_suffix' => '',
2634 'field_description' => '',
2635 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2636 )
2637 );
2638 $field_id = 'smtp_default_from_email';
2639 $field_slug = 'smtp-default-from-email';
2640 add_settings_field(
2641 $field_id,
2642 // Field ID
2643 '<span class="field-sublabel sublabel-wide">Sender email</span>',
2644 // Field title
2645 [ $render_field, 'render_text_subfield' ],
2646 // Callback to render field with custom arguments in the array below
2647 ASENHA_SLUG,
2648 // Settings page slug
2649 'main-section',
2650 // Section ID
2651 array(
2652 'option_name' => ASENHA_SLUG_U,
2653 'field_id' => $field_id,
2654 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2655 'field_type' => '',
2656 'field_prefix' => '',
2657 'field_suffix' => '',
2658 'field_description' => '',
2659 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2660 )
2661 );
2662 $field_id = 'smtp_force_from';
2663 $field_slug = 'smtp-force-from';
2664 add_settings_field(
2665 $field_id,
2666 // Field ID
2667 '',
2668 // Field title
2669 [ $render_field, 'render_checkbox_plain' ],
2670 // Callback to render field with custom arguments in the array below
2671 ASENHA_SLUG,
2672 // Settings page slug
2673 'main-section',
2674 // Section ID
2675 array(
2676 'option_name' => ASENHA_SLUG_U,
2677 'field_id' => $field_id,
2678 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2679 'field_label' => 'Force the usage of the sender name/email defined above. It will override those set by other plugins.',
2680 'class' => 'asenha-checkbox asenha-hide-th bottom-border utilities ' . $field_slug,
2681 )
2682 );
2683 $field_id = 'smtp_description';
2684 $field_slug = 'smtp--description';
2685 add_settings_field(
2686 $field_id,
2687 // Field ID
2688 '',
2689 // Field title
2690 [ $render_field, 'render_description_subfield' ],
2691 // Callback to render field with custom arguments in the array below
2692 ASENHA_SLUG,
2693 // Settings page slug
2694 'main-section',
2695 // Section ID
2696 array(
2697 'option_name' => ASENHA_SLUG_U,
2698 'field_description' => 'If set, the following SMTP service/account wil be used to deliver your emails.',
2699 'class' => 'asenha-description utilities ' . $field_slug,
2700 )
2701 );
2702 $field_id = 'smtp_host';
2703 $field_slug = 'smtp-host';
2704 add_settings_field(
2705 $field_id,
2706 // Field ID
2707 '<span class="field-sublabel sublabel-wide">Host</span>',
2708 // Field title
2709 [ $render_field, 'render_text_subfield' ],
2710 // Callback to render field with custom arguments in the array below
2711 ASENHA_SLUG,
2712 // Settings page slug
2713 'main-section',
2714 // Section ID
2715 array(
2716 'option_name' => ASENHA_SLUG_U,
2717 'field_id' => $field_id,
2718 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2719 'field_type' => '',
2720 'field_prefix' => '',
2721 'field_suffix' => '',
2722 'field_description' => '',
2723 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2724 )
2725 );
2726 $field_id = 'smtp_port';
2727 $field_slug = 'smtp-port';
2728 add_settings_field(
2729 $field_id,
2730 // Field ID
2731 '<span class="field-sublabel sublabel-wide">Port</span>',
2732 // Field title
2733 [ $render_field, 'render_number_subfield' ],
2734 // Callback to render field with custom arguments in the array below
2735 ASENHA_SLUG,
2736 // Settings page slug
2737 'main-section',
2738 // Section ID
2739 array(
2740 'option_name' => ASENHA_SLUG_U,
2741 'field_id' => $field_id,
2742 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2743 'field_type' => '',
2744 'field_prefix' => '',
2745 'field_suffix' => '',
2746 'field_intro' => '',
2747 'field_description' => '',
2748 'class' => 'asenha-text with-prefix-suffix narrow utilities ' . $field_slug,
2749 )
2750 );
2751 $field_id = 'smtp_security';
2752 $field_slug = 'smtp-security';
2753 add_settings_field(
2754 $field_id,
2755 // Field ID
2756 '<span class="field-sublabel sublabel-wide">Security</span>',
2757 // Field title
2758 [ $render_field, 'render_radio_buttons_subfield' ],
2759 // Callback to render field with custom arguments in the array below
2760 ASENHA_SLUG,
2761 // Settings page slug
2762 'main-section',
2763 // Section ID
2764 array(
2765 'option_name' => ASENHA_SLUG_U,
2766 'field_id' => $field_id,
2767 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2768 'field_radios' => array(
2769 'None' => 'none',
2770 'SSL' => 'ssl',
2771 'TLS' => 'tls',
2772 ),
2773 'field_default' => 'default',
2774 'class' => 'asenha-radio-buttons with-prefix-suffix utilities ' . $field_slug,
2775 )
2776 );
2777 $field_id = 'smtp_username';
2778 $field_slug = 'smtp-username';
2779 add_settings_field(
2780 $field_id,
2781 // Field ID
2782 '<span class="field-sublabel sublabel-wide">Username</span>',
2783 // Field title
2784 [ $render_field, 'render_text_subfield' ],
2785 // Callback to render field with custom arguments in the array below
2786 ASENHA_SLUG,
2787 // Settings page slug
2788 'main-section',
2789 // Section ID
2790 array(
2791 'option_name' => ASENHA_SLUG_U,
2792 'field_id' => $field_id,
2793 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2794 'field_type' => '',
2795 'field_prefix' => '',
2796 'field_suffix' => '',
2797 'field_description' => '',
2798 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2799 )
2800 );
2801 $field_id = 'smtp_password';
2802 $field_slug = 'smtp-password';
2803 add_settings_field(
2804 $field_id,
2805 // Field ID
2806 '<span class="field-sublabel sublabel-wide">Password</span>',
2807 // Field title
2808 [ $render_field, 'render_password_subfield' ],
2809 // Callback to render field with custom arguments in the array below
2810 ASENHA_SLUG,
2811 // Settings page slug
2812 'main-section',
2813 // Section ID
2814 array(
2815 'option_name' => ASENHA_SLUG_U,
2816 'field_id' => $field_id,
2817 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2818 'field_type' => '',
2819 'field_prefix' => '',
2820 'field_suffix' => '',
2821 'field_description' => '',
2822 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2823 )
2824 );
2825 $field_id = 'smtp_debug';
2826 $field_slug = 'smtp-debug';
2827 add_settings_field(
2828 $field_id,
2829 // Field ID
2830 '',
2831 // Field title
2832 [ $render_field, 'render_checkbox_plain' ],
2833 // Callback to render field with custom arguments in the array below
2834 ASENHA_SLUG,
2835 // Settings page slug
2836 'main-section',
2837 // Section ID
2838 array(
2839 'option_name' => ASENHA_SLUG_U,
2840 'field_id' => $field_id,
2841 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2842 'field_label' => 'Enable debug mode and output the debug info into WordPress debug.log file.',
2843 'class' => 'asenha-checkbox asenha-hide-th bottom-border utilities ' . $field_slug,
2844 )
2845 );
2846 $field_id = 'smtp_send_test_email_description';
2847 $field_slug = 'smtp-send-test-email-description';
2848 add_settings_field(
2849 $field_id,
2850 // Field ID
2851 '',
2852 // Field title
2853 [ $render_field, 'render_description_subfield' ],
2854 // Callback to render field with custom arguments in the array below
2855 ASENHA_SLUG,
2856 // Settings page slug
2857 'main-section',
2858 // Section ID
2859 array(
2860 'option_name' => ASENHA_SLUG_U,
2861 'field_description' => 'After saving the settings above, check if everything is configured properly below.',
2862 'class' => 'asenha-description utilities ' . $field_slug,
2863 )
2864 );
2865 $field_id = 'smtp_send_test_email_to';
2866 $field_slug = 'smtp-send-test-email-to';
2867 add_settings_field(
2868 $field_id,
2869 // Field ID
2870 '<span class="field-sublabel sublabel-wide">Send a test email to</span>',
2871 // Field title
2872 [ $render_field, 'render_custom_html' ],
2873 // Callback to render field with custom arguments in the array below
2874 ASENHA_SLUG,
2875 // Settings page slug
2876 'main-section',
2877 // Section ID
2878 array(
2879 'html' => '<input type="text" id="test-email-to" class="asenha-subfield-text" name="" placeholder="" value=""><a id="send-test-email" class="button send-test-email">Send Now</a>',
2880 'class' => 'asenha-html wide utilities ' . $field_slug,
2881 )
2882 );
2883 $field_id = 'smtp_send_test_email_result';
2884 $field_slug = 'smtp-send-test-email-result';
2885 add_settings_field(
2886 $field_id,
2887 // Field ID
2888 '',
2889 // Field title
2890 [ $render_field, 'render_description_subfield' ],
2891 // Callback to render field with custom arguments in the array below
2892 ASENHA_SLUG,
2893 // Settings page slug
2894 'main-section',
2895 // Section ID
2896 array(
2897 'option_name' => ASENHA_SLUG_U,
2898 'field_description' => '<div id="ajax-result" class="ajax-result-div" style="display:none;">
2899 <div class="sending-test-email"><img src="' . ASENHA_URL . 'assets/img/oval.svg" id="sending-test-email-spinner" class="spinner-img">Sending test email...</div>
2900 <div id="test-email-success" class="test-email-success" style="display:none;"><span class="dashicons dashicons-yes"></span> <span>Test email was successfully processed</span>.<br />Please check the destination email\'s inbox to verify successful delivery.</div>
2901 <div id="test-email-failed" class="test-email-failed" style="display:none;"><span class="dashicons dashicons-no-alt"></span> <span>Oops, something went wrong</span>.<br />Please double check your settings and the destination email address.</div></div>',
2902 'class' => 'asenha-description utilities ' . $field_slug,
2903 )
2904 );
2905 // Multiple User Roles
2906 $field_id = 'multiple_user_roles';
2907 $field_slug = 'multiple-user-roles';
2908 add_settings_field(
2909 $field_id,
2910 // Field ID
2911 'Multiple User Roles',
2912 // Field title
2913 [ $render_field, 'render_checkbox_toggle' ],
2914 // Callback to render field with custom arguments in the array below
2915 ASENHA_SLUG,
2916 // Settings page slug
2917 'main-section',
2918 // Section ID
2919 array(
2920 'option_name' => ASENHA_SLUG_U,
2921 'field_id' => $field_id,
2922 'field_slug' => $field_slug,
2923 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2924 'field_description' => 'Enable assignment of multiple roles during user account creation and editing. This maybe useful for working with roles not defined in WordPress core, e.g. from e-commerce or LMS plugins.',
2925 'field_options_wrapper' => true,
2926 'class' => 'asenha-toggle utilities ' . $field_slug,
2927 )
2928 );
2929 // View Admin as Role
2930 $field_id = 'view_admin_as_role';
2931 $field_slug = 'view-admin-as-role';
2932 add_settings_field(
2933 $field_id,
2934 // Field ID
2935 'View Admin as Role',
2936 // Field title
2937 [ $render_field, 'render_checkbox_toggle' ],
2938 // Callback to render field with custom arguments in the array below
2939 ASENHA_SLUG,
2940 // Settings page slug
2941 'main-section',
2942 // Section ID
2943 array(
2944 'option_name' => ASENHA_SLUG_U,
2945 'field_id' => $field_id,
2946 'field_slug' => $field_slug,
2947 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2948 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.',
2949 'field_options_moreless' => true,
2950 'field_options_wrapper' => true,
2951 'class' => 'asenha-toggle utilities ' . $field_slug,
2952 )
2953 );
2954 $current_user = wp_get_current_user();
2955 $current_user_username = $current_user->user_login;
2956 $field_id = 'view_admin_as_role_description';
2957 $field_slug = 'view-admin-as-role-description';
2958 add_settings_field(
2959 $field_id,
2960 // Field ID
2961 '',
2962 // Field title
2963 [ $render_field, 'render_description_subfield' ],
2964 // Callback to render field with custom arguments in the array below
2965 ASENHA_SLUG,
2966 // Settings page slug
2967 'main-section',
2968 // Section ID
2969 array(
2970 'option_name' => ASENHA_SLUG_U,
2971 'field_description' => '<div class="asenha-warning"><strong>If something goes wrong</strong> and you need to regain access to your account as an administrator, please visit the following URL: <br /><strong>' . get_site_url( null, '/?reset-for=' ) . $current_user_username . '</strong></div>',
2972 'class' => 'asenha-description utilities ' . $field_slug,
2973 )
2974 );
2975 // Enable Password Protection
2976 $field_id = 'enable_password_protection';
2977 $field_slug = 'enable-password-protection';
2978 add_settings_field(
2979 $field_id,
2980 // Field ID
2981 'Password Protection',
2982 // Field title
2983 [ $render_field, 'render_checkbox_toggle' ],
2984 // Callback to render field with custom arguments in the array below
2985 ASENHA_SLUG,
2986 // Settings page slug
2987 'main-section',
2988 // Section ID
2989 array(
2990 'option_name' => ASENHA_SLUG_U,
2991 'field_id' => $field_id,
2992 'field_slug' => $field_slug,
2993 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2994 '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.',
2995 'field_options_moreless' => true,
2996 'field_options_wrapper' => true,
2997 'class' => 'asenha-toggle utilities ' . $field_slug,
2998 )
2999 );
3000 $field_id = 'password_protection_password';
3001 $field_slug = 'password-protection-password';
3002 add_settings_field(
3003 $field_id,
3004 // Field ID
3005 'Set the password:',
3006 // Field title
3007 [ $render_field, 'render_password_subfield' ],
3008 // Callback to render field with custom arguments in the array below
3009 ASENHA_SLUG,
3010 // Settings page slug
3011 'main-section',
3012 // Section ID
3013 array(
3014 'option_name' => ASENHA_SLUG_U,
3015 'field_id' => $field_id,
3016 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3017 'field_type' => 'with-prefix-suffix',
3018 'field_prefix' => '',
3019 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>',
3020 'field_description' => '',
3021 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug,
3022 )
3023 );
3024 // Maintenance Mode
3025 $field_id = 'maintenance_mode';
3026 $field_slug = 'maintenance-mode';
3027 add_settings_field(
3028 $field_id,
3029 // Field ID
3030 'Maintenance Mode',
3031 // Field title
3032 [ $render_field, 'render_checkbox_toggle' ],
3033 // Callback to render field with custom arguments in the array below
3034 ASENHA_SLUG,
3035 // Settings page slug
3036 'main-section',
3037 // Section ID
3038 array(
3039 'option_name' => ASENHA_SLUG_U,
3040 'field_id' => $field_id,
3041 'field_slug' => $field_slug,
3042 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3043 '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.',
3044 'field_options_wrapper' => true,
3045 'field_options_moreless' => true,
3046 'class' => 'asenha-toggle utilities ' . $field_slug,
3047 )
3048 );
3049 $field_id = 'maintenance_page_heading';
3050 $field_slug = 'maintenance-page-heading';
3051 add_settings_field(
3052 $field_id,
3053 // Field ID
3054 'Heading',
3055 // Field title
3056 [ $render_field, 'render_text_subfield' ],
3057 // Callback to render field with custom arguments in the array below
3058 ASENHA_SLUG,
3059 // Settings page slug
3060 'main-section',
3061 // Section ID
3062 array(
3063 'option_name' => ASENHA_SLUG_U,
3064 'field_id' => $field_id,
3065 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3066 'field_type' => '',
3067 'field_prefix' => '',
3068 'field_suffix' => '',
3069 'field_description' => '',
3070 'field_placeholder' => 'We\'ll be back soon.',
3071 'class' => 'asenha-text utilities full-width ' . $field_slug,
3072 )
3073 );
3074 $field_id = 'maintenance_page_description';
3075 $field_slug = 'maintenance-page-description';
3076 add_settings_field(
3077 $field_id,
3078 // Field ID
3079 'Description',
3080 // Field title
3081 [ $render_field, 'render_textarea_subfield' ],
3082 // Callback to render field with custom arguments in the array below
3083 ASENHA_SLUG,
3084 // Settings page slug
3085 'main-section',
3086 // Section ID
3087 array(
3088 'option_name' => ASENHA_SLUG_U,
3089 'field_id' => $field_id,
3090 'field_slug' => $field_slug,
3091 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3092 'field_type' => 'textarea',
3093 'field_rows' => 5,
3094 'field_intro' => '',
3095 'field_description' => '',
3096 'field_placeholder' => 'This site is undergoing maintenance for an extended period today. Thanks for your patience.',
3097 'class' => 'asenha-textarea utilities ' . $field_slug,
3098 )
3099 );
3100 $field_id = 'maintenance_page_background';
3101 $field_slug = 'maintenance-page-background';
3102 add_settings_field(
3103 $field_id,
3104 // Field ID
3105 'Background',
3106 // Field title
3107 [ $render_field, 'render_radio_buttons_subfield' ],
3108 // Callback to render field with custom arguments in the array below
3109 ASENHA_SLUG,
3110 // Settings page slug
3111 'main-section',
3112 // Section ID
3113 array(
3114 'option_name' => ASENHA_SLUG_U,
3115 'field_id' => $field_id,
3116 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3117 'field_radios' => array(
3118 'Stripes' => 'stripes',
3119 'Curves' => 'curves',
3120 'Lines' => 'lines',
3121 ),
3122 'field_default' => 'default',
3123 'class' => 'asenha-radio-buttons utilities ' . $field_slug,
3124 )
3125 );
3126 $field_id = 'maintenance_mode_description';
3127 $field_slug = 'maintenance-mode-description';
3128 add_settings_field(
3129 $field_id,
3130 // Field ID
3131 '',
3132 // Field title
3133 [ $render_field, 'render_description_subfield' ],
3134 // Callback to render field with custom arguments in the array below
3135 ASENHA_SLUG,
3136 // Settings page slug
3137 'main-section',
3138 // Section ID
3139 array(
3140 'option_name' => ASENHA_SLUG_U,
3141 '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>',
3142 'class' => 'asenha-description utilities ' . $field_slug,
3143 )
3144 );
3145 // Redirect 404 to Homepage
3146 $field_id = 'redirect_404_to_homepage';
3147 $field_slug = 'redirect-404-to-homepage';
3148 add_settings_field(
3149 $field_id,
3150 // Field ID
3151 'Redirect 404 to Homepage',
3152 // Field title
3153 [ $render_field, 'render_checkbox_toggle' ],
3154 // Callback to render field with custom arguments in the array below
3155 ASENHA_SLUG,
3156 // Settings page slug
3157 'main-section',
3158 // Section ID
3159 array(
3160 'option_name' => ASENHA_SLUG_U,
3161 'field_id' => $field_id,
3162 'field_slug' => $field_slug,
3163 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3164 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.',
3165 'field_options_wrapper' => true,
3166 'class' => 'asenha-toggle utilities ' . $field_slug,
3167 )
3168 );
3169 }
3170
3171 }