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