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