PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 7.5.2
Admin and Site Enhancements (ASE) v7.5.2
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-sections-fields.php
admin-site-enhancements / classes Last commit date
class-activation.php 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-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
3393 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 | LOG OUT
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 // Enable 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 // Redirect After Login
1339 $field_id = 'redirect_after_login';
1340 $field_slug = 'redirect-after-login';
1341 add_settings_field(
1342 $field_id,
1343 __( 'Redirect After Login', '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' => __( 'Set custom redirect URL for all or some user roles after login.', 'admin-site-enhancements' ),
1354 'field_options_wrapper' => true,
1355 'field_options_moreless' => true,
1356 'class' => 'asenha-toggle login-logout ' . $field_slug,
1357 )
1358 );
1359 $field_id = 'redirect_after_login_to_slug';
1360 $field_slug = 'redirect-after-login-to-slug';
1361 add_settings_field(
1362 $field_id,
1363 __( 'Redirect to:', 'admin-site-enhancements' ),
1364 // Field title
1365 [$render_field, 'render_text_subfield'],
1366 ASENHA_SLUG,
1367 'main-section',
1368 array(
1369 'option_name' => ASENHA_SLUG_U,
1370 'field_id' => $field_id,
1371 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1372 'field_type' => 'with-prefix-suffix',
1373 'field_prefix' => site_url() . '/',
1374 'field_suffix' => __( 'for:', 'admin-site-enhancements' ),
1375 'field_placeholder' => '',
1376 'field_description' => '',
1377 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug,
1378 )
1379 );
1380 $field_id = 'redirect_after_login_for';
1381 $field_slug = 'redirect-after-login-for';
1382 if ( is_array( $roles ) ) {
1383 foreach ( $roles as $role_slug => $role_label ) {
1384 // e.g. $role_slug is administrator, $role_label is Administrator
1385 add_settings_field(
1386 $field_id . '_' . $role_slug,
1387 '',
1388 // Field title
1389 [$render_field, 'render_checkbox_subfield'],
1390 ASENHA_SLUG,
1391 'main-section',
1392 array(
1393 'option_name' => ASENHA_SLUG_U,
1394 'parent_field_id' => $field_id,
1395 'field_id' => $role_slug,
1396 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
1397 'field_label' => $role_label,
1398 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug,
1399 )
1400 );
1401 }
1402 }
1403 // Redirect After Logout
1404 $field_id = 'redirect_after_logout';
1405 $field_slug = 'redirect-after-logout';
1406 add_settings_field(
1407 $field_id,
1408 __( 'Redirect After Logout', 'admin-site-enhancements' ),
1409 // Field title
1410 [$render_field, 'render_checkbox_toggle'],
1411 ASENHA_SLUG,
1412 'main-section',
1413 array(
1414 'option_name' => ASENHA_SLUG_U,
1415 'field_id' => $field_id,
1416 'field_slug' => $field_slug,
1417 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1418 'field_description' => __( 'Set custom redirect URL for all or some user roles after logout.', 'admin-site-enhancements' ),
1419 'field_options_wrapper' => true,
1420 'field_options_moreless' => true,
1421 'class' => 'asenha-toggle login-logout ' . $field_slug,
1422 )
1423 );
1424 $field_id = 'redirect_after_logout_to_slug';
1425 $field_slug = 'redirect-after-logout-to-slug';
1426 add_settings_field(
1427 $field_id,
1428 __( 'Redirect to:', 'admin-site-enhancements' ),
1429 // Field title
1430 [$render_field, 'render_text_subfield'],
1431 ASENHA_SLUG,
1432 'main-section',
1433 array(
1434 'option_name' => ASENHA_SLUG_U,
1435 'field_id' => $field_id,
1436 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1437 'field_type' => 'with-prefix-suffix',
1438 'field_prefix' => site_url() . '/',
1439 'field_suffix' => __( 'for:', 'admin-site-enhancements' ),
1440 'field_description' => '',
1441 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug,
1442 )
1443 );
1444 $field_id = 'redirect_after_logout_for';
1445 $field_slug = 'redirect-after-logout-for';
1446 if ( is_array( $roles ) ) {
1447 foreach ( $roles as $role_slug => $role_label ) {
1448 // e.g. $role_slug is administrator, $role_label is Administrator
1449 add_settings_field(
1450 $field_id . '_' . $role_slug,
1451 '',
1452 // Field title
1453 [$render_field, 'render_checkbox_subfield'],
1454 ASENHA_SLUG,
1455 'main-section',
1456 array(
1457 'option_name' => ASENHA_SLUG_U,
1458 'parent_field_id' => $field_id,
1459 'field_id' => $role_slug,
1460 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $role_slug . ']',
1461 'field_label' => $role_label,
1462 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug,
1463 )
1464 );
1465 }
1466 }
1467 // Enable Custom Admin CSS
1468 $field_id = 'enable_custom_admin_css';
1469 $field_slug = 'enable-custom-admin-css';
1470 add_settings_field(
1471 $field_id,
1472 __( 'Custom Admin CSS', 'admin-site-enhancements' ),
1473 // Field title
1474 [$render_field, 'render_checkbox_toggle'],
1475 ASENHA_SLUG,
1476 'main-section',
1477 array(
1478 'option_name' => ASENHA_SLUG_U,
1479 'field_id' => $field_id,
1480 'field_slug' => $field_slug,
1481 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1482 'field_description' => __( 'Add custom CSS on all admin pages for all user roles.', 'admin-site-enhancements' ),
1483 'field_options_wrapper' => true,
1484 'field_options_moreless' => true,
1485 'class' => 'asenha-toggle custom-code ' . $field_slug,
1486 )
1487 );
1488 $field_id = 'custom_admin_css';
1489 $field_slug = 'custom-admin-css';
1490 add_settings_field(
1491 $field_id,
1492 '',
1493 // Field title
1494 [$render_field, 'render_textarea_subfield'],
1495 ASENHA_SLUG,
1496 'main-section',
1497 array(
1498 'option_name' => ASENHA_SLUG_U,
1499 'field_id' => $field_id,
1500 'field_slug' => $field_slug,
1501 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1502 'field_type' => 'textarea',
1503 'field_rows' => 30,
1504 'field_intro' => '',
1505 'field_description' => '',
1506 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1507 )
1508 );
1509 // Enable Custom Frontend CSS
1510 $field_id = 'enable_custom_frontend_css';
1511 $field_slug = 'enable-custom-frontend-css';
1512 add_settings_field(
1513 $field_id,
1514 __( 'Custom Frontend CSS', 'admin-site-enhancements' ),
1515 // Field title
1516 [$render_field, 'render_checkbox_toggle'],
1517 ASENHA_SLUG,
1518 'main-section',
1519 array(
1520 'option_name' => ASENHA_SLUG_U,
1521 'field_id' => $field_id,
1522 'field_slug' => $field_slug,
1523 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1524 'field_description' => __( 'Add custom CSS on all frontend pages for all user roles.', 'admin-site-enhancements' ),
1525 'field_options_wrapper' => true,
1526 'field_options_moreless' => true,
1527 'class' => 'asenha-toggle custom-code ' . $field_slug,
1528 )
1529 );
1530 $field_id = 'custom_frontend_css';
1531 $field_slug = 'custom-frontend-css';
1532 add_settings_field(
1533 $field_id,
1534 '',
1535 // Field title
1536 [$render_field, 'render_textarea_subfield'],
1537 ASENHA_SLUG,
1538 'main-section',
1539 array(
1540 'option_name' => ASENHA_SLUG_U,
1541 'field_id' => $field_id,
1542 'field_slug' => $field_slug,
1543 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1544 'field_type' => 'textarea',
1545 'field_rows' => 30,
1546 'field_intro' => '',
1547 'field_description' => '',
1548 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1549 )
1550 );
1551 // Insert <head>, <body> and <footer> code
1552 $field_id = 'insert_head_body_footer_code';
1553 $field_slug = 'insert-head-body-footer-code';
1554 add_settings_field(
1555 $field_id,
1556 /* translators: keep &lt;head&gt; &lt;body&gt; &lt;footer&gt; as is in the translation */
1557 __( 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', 'admin-site-enhancements' ),
1558 // Field title
1559 [$render_field, 'render_checkbox_toggle'],
1560 ASENHA_SLUG,
1561 'main-section',
1562 array(
1563 'option_name' => ASENHA_SLUG_U,
1564 'field_id' => $field_id,
1565 'field_slug' => $field_slug,
1566 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1567 'field_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' ),
1568 'field_options_wrapper' => true,
1569 'field_options_moreless' => true,
1570 'class' => 'asenha-toggle custom-code ' . $field_slug,
1571 )
1572 );
1573 $field_id = 'head_code_priority';
1574 $field_slug = 'head-code-priority';
1575 add_settings_field(
1576 $field_id,
1577 '',
1578 // Field title
1579 [$render_field, 'render_number_subfield'],
1580 ASENHA_SLUG,
1581 'main-section',
1582 array(
1583 'option_name' => ASENHA_SLUG_U,
1584 'field_id' => $field_id,
1585 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1586 'field_type' => 'with-prefix-suffix',
1587 'field_prefix' => __( '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', 'admin-site-enhancements' ),
1588 'field_suffix' => '',
1589 'field_intro' => '',
1590 'field_placeholder' => '10',
1591 'field_min' => 0,
1592 'field_max' => PHP_INT_MAX,
1593 'field_description' => __( 'Default is 10. Larger number insert code closer to &lt;/head&gt;', 'admin-site-enhancements' ),
1594 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1595 )
1596 );
1597 $field_id = 'head_code';
1598 $field_slug = 'head-code';
1599 add_settings_field(
1600 $field_id,
1601 '',
1602 // Field title
1603 [$render_field, 'render_textarea_subfield'],
1604 ASENHA_SLUG,
1605 'main-section',
1606 array(
1607 'option_name' => ASENHA_SLUG_U,
1608 'field_id' => $field_id,
1609 'field_slug' => $field_slug,
1610 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1611 'field_type' => 'textarea',
1612 'field_rows' => 15,
1613 'field_intro' => '',
1614 'field_description' => '',
1615 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1616 )
1617 );
1618 $field_id = 'body_code_priority';
1619 $field_slug = 'body-code-priority';
1620 add_settings_field(
1621 $field_id,
1622 '',
1623 // Field title
1624 [$render_field, 'render_number_subfield'],
1625 ASENHA_SLUG,
1626 'main-section',
1627 array(
1628 'option_name' => ASENHA_SLUG_U,
1629 'field_id' => $field_id,
1630 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1631 'field_type' => 'with-prefix-suffix',
1632 'field_prefix' => __( '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', 'admin-site-enhancements' ),
1633 'field_suffix' => '',
1634 'field_intro' => '',
1635 'field_placeholder' => '10',
1636 'field_min' => 0,
1637 'field_max' => PHP_INT_MAX,
1638 'field_description' => __( 'Default is 10. Smaller number insert code closer to &lt;body&gt;', 'admin-site-enhancements' ),
1639 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1640 )
1641 );
1642 $field_id = 'body_code';
1643 $field_slug = 'body-code';
1644 add_settings_field(
1645 $field_id,
1646 '',
1647 // Field title
1648 [$render_field, 'render_textarea_subfield'],
1649 ASENHA_SLUG,
1650 'main-section',
1651 array(
1652 'option_name' => ASENHA_SLUG_U,
1653 'field_id' => $field_id,
1654 'field_slug' => $field_slug,
1655 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1656 'field_type' => 'textarea',
1657 'field_rows' => 15,
1658 'field_intro' => '',
1659 'field_description' => '',
1660 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1661 )
1662 );
1663 $field_id = 'footer_code_priority';
1664 $field_slug = 'footer-code-priority';
1665 add_settings_field(
1666 $field_id,
1667 '',
1668 // Field title
1669 [$render_field, 'render_number_subfield'],
1670 ASENHA_SLUG,
1671 'main-section',
1672 array(
1673 'option_name' => ASENHA_SLUG_U,
1674 'field_id' => $field_id,
1675 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1676 'field_type' => 'with-prefix-suffix',
1677 'field_prefix' => __( '<strong>Code to insert in footer section before &lt;/body&gt; with the priority of</strong>', 'admin-site-enhancements' ),
1678 'field_suffix' => '',
1679 'field_intro' => '',
1680 'field_placeholder' => '10',
1681 'field_min' => 0,
1682 'field_max' => PHP_INT_MAX,
1683 'field_description' => __( 'Default is 10. Larger number insert code closer to &lt;/body&gt;', 'admin-site-enhancements' ),
1684 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug,
1685 )
1686 );
1687 $field_id = 'footer_code';
1688 $field_slug = 'footer-code';
1689 add_settings_field(
1690 $field_id,
1691 '',
1692 // Field title
1693 [$render_field, 'render_textarea_subfield'],
1694 ASENHA_SLUG,
1695 'main-section',
1696 array(
1697 'option_name' => ASENHA_SLUG_U,
1698 'field_id' => $field_id,
1699 'field_slug' => $field_slug,
1700 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1701 'field_type' => 'textarea',
1702 'field_rows' => 15,
1703 'field_intro' => '',
1704 'field_description' => '',
1705 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1706 )
1707 );
1708 // Custom Body Class
1709 $field_id = 'enable_custom_body_class';
1710 $field_slug = 'enable-custom-body-class';
1711 add_settings_field(
1712 $field_id,
1713 __( 'Custom Body Class', 'admin-site-enhancements' ),
1714 // Field title
1715 [$render_field, 'render_checkbox_toggle'],
1716 ASENHA_SLUG,
1717 'main-section',
1718 array(
1719 'option_name' => ASENHA_SLUG_U,
1720 'field_id' => $field_id,
1721 'field_slug' => $field_slug,
1722 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1723 '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' ),
1724 'field_options_wrapper' => true,
1725 'field_options_moreless' => true,
1726 'class' => 'asenha-toggle custom-code ' . $field_slug,
1727 )
1728 );
1729 $field_id = 'enable_custom_body_class_for';
1730 $field_slug = 'enable-custom-body-class-for';
1731 if ( is_array( $asenha_public_post_types ) ) {
1732 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
1733 // e.g. $post_type_slug is post, $post_type_label is Posts
1734 if ( 'attachment' != $post_type_slug ) {
1735 add_settings_field(
1736 $field_id . '_' . $post_type_slug,
1737 '',
1738 // Field title
1739 [$render_field, 'render_checkbox_subfield'],
1740 ASENHA_SLUG,
1741 'main-section',
1742 array(
1743 'option_name' => ASENHA_SLUG_U,
1744 'parent_field_id' => $field_id,
1745 'field_id' => $post_type_slug,
1746 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1747 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1748 'class' => 'asenha-checkbox asenha-hide-th asenha-half custom-code ' . $field_slug . ' ' . $post_type_slug,
1749 )
1750 );
1751 }
1752 }
1753 }
1754 // Manage ads.txt and app-ads.txt
1755 $field_id = 'manage_ads_appads_txt';
1756 $field_slug = 'manage-ads-appads-txt';
1757 add_settings_field(
1758 $field_id,
1759 __( 'Manage ads.txt and app-ads.txt', 'admin-site-enhancements' ),
1760 // Field title
1761 [$render_field, 'render_checkbox_toggle'],
1762 ASENHA_SLUG,
1763 'main-section',
1764 array(
1765 'option_name' => ASENHA_SLUG_U,
1766 'field_id' => $field_id,
1767 'field_slug' => $field_slug,
1768 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1769 'field_description' => __( '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' ),
1770 'field_options_wrapper' => true,
1771 'field_options_moreless' => true,
1772 'class' => 'asenha-toggle custom-code ' . $field_slug,
1773 )
1774 );
1775 $field_id = 'ads_txt_content';
1776 $field_slug = 'ads-txt-content';
1777 $ads_txt_url_urlencoded = urlencode( site_url( 'ads.txt' ) );
1778 $ads_txt_str_replaced = str_replace( '.', '-', sanitize_text_field( $_SERVER['SERVER_NAME'] ) );
1779 add_settings_field(
1780 $field_id,
1781 '',
1782 // Field title
1783 [$render_field, 'render_textarea_subfield'],
1784 ASENHA_SLUG,
1785 'main-section',
1786 array(
1787 'option_name' => ASENHA_SLUG_U,
1788 'field_id' => $field_id,
1789 'field_slug' => $field_slug,
1790 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1791 'field_type' => 'textarea',
1792 'field_rows' => 15,
1793 'field_intro' => __( '<strong>Your ads.txt content:</strong>', 'admin-site-enhancements' ),
1794 '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>',
1795 'admin-site-enhancements',
1796 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1797 )
1798 );
1799 $field_id = 'app_ads_txt_content';
1800 $field_slug = 'app-ads-txt-content';
1801 $appads_txt_url_urlencoded = urlencode( site_url( 'app-ads.txt' ) );
1802 add_settings_field(
1803 $field_id,
1804 '',
1805 // Field title
1806 [$render_field, 'render_textarea_subfield'],
1807 ASENHA_SLUG,
1808 'main-section',
1809 array(
1810 'option_name' => ASENHA_SLUG_U,
1811 'field_id' => $field_id,
1812 'field_slug' => $field_slug,
1813 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1814 'field_type' => 'textarea',
1815 'field_rows' => 15,
1816 'field_intro' => __( '<strong>Your app-ads.txt content:</strong>', 'admin-site-enhancements' ),
1817 'field_description' => __( 'Validate with:', 'admin-site-enhancements' ) . ' <a href="https://adstxt.guru/validator/url/?url=' . $appads_txt_url_urlencoded . '" target="_blank">adstxt.guru</a>',
1818 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1819 )
1820 );
1821 // Manage robots.txt
1822 $field_id = 'manage_robots_txt';
1823 $field_slug = 'manage-robots-txt';
1824 add_settings_field(
1825 $field_id,
1826 __( 'Manage robots.txt', 'admin-site-enhancements' ),
1827 // Field title
1828 [$render_field, 'render_checkbox_toggle'],
1829 ASENHA_SLUG,
1830 'main-section',
1831 array(
1832 'option_name' => ASENHA_SLUG_U,
1833 'field_id' => $field_id,
1834 'field_slug' => $field_slug,
1835 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1836 'field_description' => __( 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', 'admin-site-enhancements' ),
1837 'field_options_wrapper' => true,
1838 'field_options_moreless' => true,
1839 'class' => 'asenha-toggle custom-code ' . $field_slug,
1840 )
1841 );
1842 $field_id = 'robots_txt_content';
1843 $field_slug = 'robots-txt-content';
1844 $robots_txt_url_urlencoded = urlencode( site_url( 'robots.txt' ) );
1845 add_settings_field(
1846 $field_id,
1847 '',
1848 // Field title
1849 [$render_field, 'render_textarea_subfield'],
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_type' => 'textarea',
1858 'field_rows' => 20,
1859 'field_intro' => '',
1860 'field_description' => __( 'Validate with:', 'admin-site-enhancements' ) . ' <a href="https://en.ryte.com/free-tools/robots-txt/?refresh=1&url=' . $robots_txt_url_urlencoded . '&useragent=Googlebot&submit=Evaluate" target="_blank">ryte.com</a> | <a href="https://serp.tools/tools/robots-txt" target="_blank">serp.tools</a><div class="vspacer"></div>',
1861 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug,
1862 )
1863 );
1864 // =================================================================
1865 // DISABLE COMPONENTS
1866 // =================================================================
1867 // Disable Gutenberg
1868 $field_id = 'disable_gutenberg';
1869 $field_slug = 'disable-gutenberg';
1870 add_settings_field(
1871 $field_id,
1872 __( 'Disable Gutenberg', 'admin-site-enhancements' ),
1873 // Field title
1874 [$render_field, 'render_checkbox_toggle'],
1875 ASENHA_SLUG,
1876 'main-section',
1877 array(
1878 'option_name' => ASENHA_SLUG_U,
1879 'field_id' => $field_id,
1880 'field_slug' => $field_slug,
1881 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1882 'field_description' => __( 'Disable the Gutenberg block editor for some or all applicable post types.', 'admin-site-enhancements' ),
1883 'field_options_wrapper' => true,
1884 'field_options_moreless' => true,
1885 'class' => 'asenha-toggle disable-components ' . $field_slug,
1886 )
1887 );
1888 $field_id = 'disable_gutenberg_for';
1889 $field_slug = 'disable-gutenberg-for';
1890 if ( is_array( $asenha_gutenberg_post_types ) ) {
1891 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) {
1892 // e.g. $post_type_slug is post, $post_type_label is Posts
1893 add_settings_field(
1894 $field_id . '_' . $post_type_slug,
1895 '',
1896 // Field title
1897 [$render_field, 'render_checkbox_subfield'],
1898 ASENHA_SLUG,
1899 'main-section',
1900 array(
1901 'option_name' => ASENHA_SLUG_U,
1902 'parent_field_id' => $field_id,
1903 'field_id' => $post_type_slug,
1904 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1905 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1906 'class' => 'asenha-checkbox asenha-checkbox-item asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug,
1907 )
1908 );
1909 }
1910 }
1911 $field_id = 'disable_gutenberg_frontend_styles';
1912 $field_slug = 'disable-gutenberg-frontend-styles';
1913 add_settings_field(
1914 $field_id,
1915 '',
1916 // Field title
1917 [$render_field, 'render_checkbox_plain'],
1918 ASENHA_SLUG,
1919 'main-section',
1920 array(
1921 'option_name' => ASENHA_SLUG_U,
1922 'field_id' => $field_id,
1923 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1924 'field_label' => __( 'Also disable frontend block styles / CSS files for the selected post types.', 'admin-site-enhancements' ),
1925 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug,
1926 )
1927 );
1928 // Disable Comments
1929 $field_id = 'disable_comments';
1930 $field_slug = 'disable-comments';
1931 add_settings_field(
1932 $field_id,
1933 __( 'Disable Comments', 'admin-site-enhancements' ),
1934 // Field title
1935 [$render_field, 'render_checkbox_toggle'],
1936 ASENHA_SLUG,
1937 'main-section',
1938 array(
1939 'option_name' => ASENHA_SLUG_U,
1940 'field_id' => $field_id,
1941 'field_slug' => $field_slug,
1942 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1943 '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' ),
1944 'field_options_wrapper' => true,
1945 'field_options_moreless' => true,
1946 'class' => 'asenha-toggle disable-components ' . $field_slug,
1947 )
1948 );
1949 $field_id = 'disable_comments_for';
1950 $field_slug = 'disable-comments-for';
1951 if ( is_array( $asenha_public_post_types ) ) {
1952 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) {
1953 // e.g. $post_type_slug is post, $post_type_label is Posts
1954 add_settings_field(
1955 $field_id . '_' . $post_type_slug,
1956 '',
1957 // Field title
1958 [$render_field, 'render_checkbox_subfield'],
1959 ASENHA_SLUG,
1960 'main-section',
1961 array(
1962 'option_name' => ASENHA_SLUG_U,
1963 'parent_field_id' => $field_id,
1964 'field_id' => $post_type_slug,
1965 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
1966 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
1967 'class' => 'asenha-checkbox asenha-checkbox-item asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug,
1968 )
1969 );
1970 }
1971 }
1972 // Disable REST API
1973 $field_id = 'disable_rest_api';
1974 $field_slug = 'disable-rest-api';
1975 add_settings_field(
1976 $field_id,
1977 __( 'Disable REST API', 'admin-site-enhancements' ),
1978 // Field title
1979 [$render_field, 'render_checkbox_toggle'],
1980 ASENHA_SLUG,
1981 'main-section',
1982 array(
1983 'option_name' => ASENHA_SLUG_U,
1984 'field_id' => $field_id,
1985 'field_slug' => $field_slug,
1986 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
1987 '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' ),
1988 'field_options_wrapper' => true,
1989 'field_options_moreless' => true,
1990 'class' => 'asenha-toggle disable-components ' . $field_slug,
1991 )
1992 );
1993 // Disable Feeds
1994 $field_id = 'disable_feeds';
1995 $field_slug = 'disable-feeds';
1996 add_settings_field(
1997 $field_id,
1998 __( 'Disable Feeds', '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 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' ),
2009 'field_options_wrapper' => true,
2010 'field_options_moreless' => true,
2011 'class' => 'asenha-toggle disable-components ' . $field_slug,
2012 )
2013 );
2014 // Disable Auto Updates
2015 $field_id = 'disable_all_updates';
2016 $field_slug = 'disable-all-updates';
2017 add_settings_field(
2018 $field_id,
2019 __( 'Disable All Updates', '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' => __( 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', '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 Smaller Components
2036 $field_id = 'disable_smaller_components';
2037 $field_slug = 'disable-smaller-components';
2038 add_settings_field(
2039 $field_id,
2040 __( 'Disable Smaller Components', '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' => __( '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' ),
2051 'field_options_wrapper' => true,
2052 'field_options_moreless' => true,
2053 'class' => 'asenha-toggle disable-components ' . $field_slug,
2054 )
2055 );
2056 $field_id = 'disable_head_generator_tag';
2057 $field_slug = 'disable-head-generator-tag';
2058 add_settings_field(
2059 $field_id,
2060 '',
2061 // Field title
2062 [$render_field, 'render_checkbox_plain'],
2063 ASENHA_SLUG,
2064 'main-section',
2065 array(
2066 'option_name' => ASENHA_SLUG_U,
2067 'field_id' => $field_id,
2068 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2069 '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' ),
2070 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2071 )
2072 );
2073 $field_id = 'disable_feed_generator_tag';
2074 $field_slug = 'disable-feed-generator-tag';
2075 add_settings_field(
2076 $field_id,
2077 '',
2078 // Field title
2079 [$render_field, 'render_checkbox_plain'],
2080 ASENHA_SLUG,
2081 'main-section',
2082 array(
2083 'option_name' => ASENHA_SLUG_U,
2084 'field_id' => $field_id,
2085 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2086 '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' ),
2087 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2088 )
2089 );
2090 $field_id = 'disable_resource_version_number';
2091 $field_slug = 'disable-resource-version-number';
2092 add_settings_field(
2093 $field_id,
2094 '',
2095 // Field title
2096 [$render_field, 'render_checkbox_plain'],
2097 ASENHA_SLUG,
2098 'main-section',
2099 array(
2100 'option_name' => ASENHA_SLUG_U,
2101 'field_id' => $field_id,
2102 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2103 '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' ),
2104 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2105 )
2106 );
2107 $field_id = 'disable_head_wlwmanifest_tag';
2108 $field_slug = 'disable-head-wlwmanifest-tag';
2109 add_settings_field(
2110 $field_id,
2111 '',
2112 // Field title
2113 [$render_field, 'render_checkbox_plain'],
2114 ASENHA_SLUG,
2115 'main-section',
2116 array(
2117 'option_name' => ASENHA_SLUG_U,
2118 'field_id' => $field_id,
2119 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2120 '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' ),
2121 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2122 )
2123 );
2124 $field_id = 'disable_head_rsd_tag';
2125 $field_slug = 'disable-head-rsd-tag';
2126 add_settings_field(
2127 $field_id,
2128 '',
2129 // Field title
2130 [$render_field, 'render_checkbox_plain'],
2131 ASENHA_SLUG,
2132 'main-section',
2133 array(
2134 'option_name' => ASENHA_SLUG_U,
2135 'field_id' => $field_id,
2136 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2137 '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' ),
2138 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2139 )
2140 );
2141 $field_id = 'disable_head_shortlink_tag';
2142 $field_slug = 'disable-head-shortlink-tag';
2143 add_settings_field(
2144 $field_id,
2145 '',
2146 // Field title
2147 [$render_field, 'render_checkbox_plain'],
2148 ASENHA_SLUG,
2149 'main-section',
2150 array(
2151 'option_name' => ASENHA_SLUG_U,
2152 'field_id' => $field_id,
2153 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2154 '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' ),
2155 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2156 )
2157 );
2158 $field_id = 'disable_frontend_dashicons';
2159 $field_slug = 'disable-frontend-dashicons';
2160 add_settings_field(
2161 $field_id,
2162 '',
2163 // Field title
2164 [$render_field, 'render_checkbox_plain'],
2165 ASENHA_SLUG,
2166 'main-section',
2167 array(
2168 'option_name' => ASENHA_SLUG_U,
2169 'field_id' => $field_id,
2170 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2171 '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' ),
2172 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2173 )
2174 );
2175 $field_id = 'disable_emoji_support';
2176 $field_slug = 'disable-emoji-support';
2177 add_settings_field(
2178 $field_id,
2179 '',
2180 // Field title
2181 [$render_field, 'render_checkbox_plain'],
2182 ASENHA_SLUG,
2183 'main-section',
2184 array(
2185 'option_name' => ASENHA_SLUG_U,
2186 'field_id' => $field_id,
2187 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2188 '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' ),
2189 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2190 )
2191 );
2192 $field_id = 'disable_jquery_migrate';
2193 $field_slug = 'disable-jquery-migrate';
2194 add_settings_field(
2195 $field_id,
2196 '',
2197 // Field title
2198 [$render_field, 'render_checkbox_plain'],
2199 ASENHA_SLUG,
2200 'main-section',
2201 array(
2202 'option_name' => ASENHA_SLUG_U,
2203 'field_id' => $field_id,
2204 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2205 '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' ),
2206 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2207 )
2208 );
2209 $field_id = 'disable_block_widgets';
2210 $field_slug = 'disable-block-widgets';
2211 add_settings_field(
2212 $field_id,
2213 '',
2214 // Field title
2215 [$render_field, 'render_checkbox_plain'],
2216 ASENHA_SLUG,
2217 'main-section',
2218 array(
2219 'option_name' => ASENHA_SLUG_U,
2220 'field_id' => $field_id,
2221 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2222 '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' ),
2223 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2224 )
2225 );
2226 $field_id = 'disable_lazy_load';
2227 $field_slug = 'disable-lazy-load';
2228 add_settings_field(
2229 $field_id,
2230 '',
2231 // Field title
2232 [$render_field, 'render_checkbox_plain'],
2233 ASENHA_SLUG,
2234 'main-section',
2235 array(
2236 'option_name' => ASENHA_SLUG_U,
2237 'field_id' => $field_id,
2238 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2239 'field_label' => __( 'Disable <strong>lazy loading of images</strong> that was natively added since WordPress v5.5.', 'admin-site-enhancements' ),
2240 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2241 )
2242 );
2243 $field_id = 'disable_plugin_theme_editor';
2244 $field_slug = 'disable-plugin-theme-editor';
2245 $is_wpconfig_writeable = $wp_config->wpconfig_file( 'writeability' );
2246 $disallow_file_edit_exists = $wp_config->exists( 'constant', 'DISALLOW_FILE_EDIT' );
2247 if ( $is_wpconfig_writeable ) {
2248 $field_label = __( 'Disable the <strong>plugin and theme editor</strong>.', 'admin-site-enhancements' );
2249 } else {
2250 if ( $disallow_file_edit_exists ) {
2251 $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' );
2252 } else {
2253 $field_label = __( 'Disable the <strong>plugin and theme editor</strong>.', 'admin-site-enhancements' );
2254 }
2255 }
2256 add_settings_field(
2257 $field_id,
2258 '',
2259 // Field title
2260 [$render_field, 'render_checkbox_plain'],
2261 ASENHA_SLUG,
2262 'main-section',
2263 array(
2264 'option_name' => ASENHA_SLUG_U,
2265 'field_id' => $field_id,
2266 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2267 'field_label' => $field_label,
2268 'class' => 'asenha-checkbox asenha-hide-th disable-components ' . $field_slug,
2269 )
2270 );
2271 // =================================================================
2272 // SECURITY
2273 // =================================================================
2274 // Limit Login Attempts
2275 $field_id = 'limit_login_attempts';
2276 $field_slug = 'limit-login-attempts';
2277 add_settings_field(
2278 $field_id,
2279 __( 'Limit Login Attempts', 'admin-site-enhancements' ),
2280 // Field title
2281 [$render_field, 'render_checkbox_toggle'],
2282 ASENHA_SLUG,
2283 'main-section',
2284 array(
2285 'option_name' => ASENHA_SLUG_U,
2286 'field_id' => $field_id,
2287 'field_slug' => $field_slug,
2288 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2289 'field_description' => __( 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', 'admin-site-enhancements' ),
2290 'field_options_wrapper' => true,
2291 'field_options_moreless' => true,
2292 'class' => 'asenha-toggle security ' . $field_slug,
2293 )
2294 );
2295 $field_id = 'login_fails_allowed';
2296 $field_slug = 'login-fails-allowed';
2297 add_settings_field(
2298 $field_id,
2299 '',
2300 // Field title
2301 [$render_field, 'render_number_subfield'],
2302 ASENHA_SLUG,
2303 'main-section',
2304 array(
2305 'option_name' => ASENHA_SLUG_U,
2306 'field_id' => $field_id,
2307 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2308 'field_type' => 'with-prefix-suffix',
2309 'field_prefix' => '',
2310 'field_suffix' => __( 'failed login attempts allowed before 15 minutes lockout', 'admin-site-enhancements' ),
2311 'field_intro' => '',
2312 'field_placeholder' => '3',
2313 'field_min' => 1,
2314 'field_max' => 10,
2315 'field_description' => '',
2316 'class' => 'asenha-text with-prefix-suffix extra-narrow no-margin security ' . $field_slug,
2317 )
2318 );
2319 $field_id = 'login_lockout_maxcount';
2320 $field_slug = 'login-lockout-maxcount';
2321 add_settings_field(
2322 $field_id,
2323 '',
2324 // Field title
2325 [$render_field, 'render_number_subfield'],
2326 ASENHA_SLUG,
2327 'main-section',
2328 array(
2329 'option_name' => ASENHA_SLUG_U,
2330 'field_id' => $field_id,
2331 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2332 'field_type' => 'with-prefix-suffix',
2333 'field_prefix' => '',
2334 'field_suffix' => __( 'lockout(s) will block further login attempts for 24 hours', 'admin-site-enhancements' ),
2335 'field_intro' => '',
2336 'field_placeholder' => '3',
2337 'field_min' => 1,
2338 'field_max' => 10,
2339 'field_description' => '',
2340 'class' => 'asenha-text with-prefix-suffix extra-narrow no-margin security ' . $field_slug,
2341 )
2342 );
2343 $field_id = 'login_attempts_log_table';
2344 $field_slug = 'login-attempts-log-table';
2345 add_settings_field(
2346 $field_id,
2347 __( 'Failed login attempts:', 'admin-site-enhancements' ),
2348 // Field title
2349 [$render_field, 'render_datatable'],
2350 ASENHA_SLUG,
2351 'main-section',
2352 array(
2353 'option_name' => ASENHA_SLUG_U,
2354 'field_id' => $field_id,
2355 'field_slug' => $field_slug,
2356 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2357 'field_type' => 'datatable',
2358 'field_description' => '',
2359 'class' => 'asenha-text datatable margin-top-16 security ' . $field_slug,
2360 'table_title' => __( 'Failed Login Attempts Log', 'admin-site-enhancements' ),
2361 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
2362 )
2363 );
2364 // Obfuscate Author Slugs
2365 $field_id = 'obfuscate_author_slugs';
2366 $field_slug = 'obfuscate-author-slugs';
2367 add_settings_field(
2368 $field_id,
2369 __( 'Obfuscate Author Slugs', 'admin-site-enhancements' ),
2370 // Field title
2371 [$render_field, 'render_checkbox_toggle'],
2372 ASENHA_SLUG,
2373 'main-section',
2374 array(
2375 'option_name' => ASENHA_SLUG_U,
2376 'field_id' => $field_id,
2377 'field_slug' => $field_slug,
2378 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2379 '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' ),
2380 'field_options_wrapper' => false,
2381 'class' => 'asenha-toggle security ' . $field_slug,
2382 )
2383 );
2384 // Obfuscate Email Address
2385 $field_id = 'obfuscate_email_address';
2386 $field_slug = 'obfuscate-email-address';
2387 add_settings_field(
2388 $field_id,
2389 __( 'Email Address Obfuscator', 'admin-site-enhancements' ),
2390 // Field title
2391 [$render_field, 'render_checkbox_toggle'],
2392 ASENHA_SLUG,
2393 'main-section',
2394 array(
2395 'option_name' => ASENHA_SLUG_U,
2396 'field_id' => $field_id,
2397 'field_slug' => $field_slug,
2398 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2399 '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' ),
2400 'field_options_wrapper' => true,
2401 'field_options_moreless' => true,
2402 'class' => 'asenha-toggle security ' . $field_slug,
2403 )
2404 );
2405 $field_id = 'obfuscate_email_address_description';
2406 $field_slug = 'obfuscate-email-address-description';
2407 $field_description = __( 'Use a shortcode like the following examples to display an email address on the frontend of your site:
2408 <ul>
2409 <li><strong>[obfuscate email="john@example.com"]</strong> to display the email on it\'s own line</li>
2410 <li><strong>[obfuscate email="john@example.com" display="inline"]</strong> to show the email inline</li>
2411 </ul>', 'admin-site-enhancements' );
2412 add_settings_field(
2413 $field_id,
2414 '',
2415 // Field title
2416 [$render_field, 'render_description_subfield'],
2417 ASENHA_SLUG,
2418 'main-section',
2419 array(
2420 'option_name' => ASENHA_SLUG_U,
2421 'field_description' => $field_description,
2422 'class' => 'asenha-description security ' . $field_slug,
2423 )
2424 );
2425 // Disable XML-RPC
2426 $field_id = 'disable_xmlrpc';
2427 $field_slug = 'disable-xmlrpc';
2428 add_settings_field(
2429 $field_id,
2430 __( 'Disable XML-RPC', 'admin-site-enhancements' ),
2431 // Field title
2432 [$render_field, 'render_checkbox_toggle'],
2433 ASENHA_SLUG,
2434 'main-section',
2435 array(
2436 'option_name' => ASENHA_SLUG_U,
2437 'field_id' => $field_id,
2438 'field_slug' => $field_slug,
2439 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2440 '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' ),
2441 'field_options_wrapper' => false,
2442 'class' => 'asenha-toggle security ' . $field_slug,
2443 )
2444 );
2445 // =================================================================
2446 // OPTIMIZATIONS
2447 // =================================================================
2448 // Image Upload Control
2449 $field_id = 'image_upload_control';
2450 $field_slug = 'image-upload-control';
2451 add_settings_field(
2452 $field_id,
2453 __( 'Image Upload Control', 'admin-site-enhancements' ),
2454 // Field title
2455 [$render_field, 'render_checkbox_toggle'],
2456 ASENHA_SLUG,
2457 'main-section',
2458 array(
2459 'option_name' => ASENHA_SLUG_U,
2460 'field_id' => $field_id,
2461 'field_slug' => $field_slug,
2462 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2463 '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' ),
2464 'field_options_wrapper' => true,
2465 'field_options_moreless' => true,
2466 'class' => 'asenha-toggle optimizations ' . $field_slug,
2467 )
2468 );
2469 $field_id = 'image_max_width';
2470 $field_slug = 'image-max-width';
2471 add_settings_field(
2472 $field_id,
2473 '',
2474 // Field title
2475 [$render_field, 'render_number_subfield'],
2476 ASENHA_SLUG,
2477 'main-section',
2478 array(
2479 'option_name' => ASENHA_SLUG_U,
2480 'field_id' => $field_id,
2481 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2482 'field_type' => 'with-prefix-suffix',
2483 'field_prefix' => __( 'Max width:', 'admin-site-enhancements' ),
2484 'field_suffix' => __( 'pixels. <span class="faded">(Default is 1920 pixels)</span>', 'admin-site-enhancements' ),
2485 'field_intro' => '',
2486 'field_placeholder' => '1920',
2487 'field_min' => 100,
2488 'field_max' => 3840,
2489 'field_description' => '',
2490 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug,
2491 )
2492 );
2493 $field_id = 'image_max_height';
2494 $field_slug = 'image-max-height';
2495 add_settings_field(
2496 $field_id,
2497 '',
2498 // Field title
2499 [$render_field, 'render_number_subfield'],
2500 ASENHA_SLUG,
2501 'main-section',
2502 array(
2503 'option_name' => ASENHA_SLUG_U,
2504 'field_id' => $field_id,
2505 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2506 'field_type' => 'with-prefix-suffix',
2507 'field_prefix' => __( 'Max height:', 'admin-site-enhancements' ),
2508 'field_suffix' => __( 'pixels <span class="faded">(Default is 1920 pixels)</span>', 'admin-site-enhancements' ),
2509 'field_intro' => '',
2510 'field_placeholder' => '1920',
2511 'field_min' => 100,
2512 'field_max' => 3840,
2513 'class' => 'asenha-number asenha-hide-th narrow margin-bottom-4 optimizations ' . $field_slug,
2514 )
2515 );
2516 $field_id = 'image_upload_control_description';
2517 $field_slug = 'image-upload-control-description';
2518 $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' );
2519 add_settings_field(
2520 $field_id,
2521 '',
2522 // Field title
2523 [$render_field, 'render_description_subfield'],
2524 ASENHA_SLUG,
2525 'main-section',
2526 array(
2527 'option_name' => ASENHA_SLUG_U,
2528 'field_description' => $field_description,
2529 'class' => 'asenha-description top-border optimizations ' . $field_slug,
2530 )
2531 );
2532 // Enable Revisions Control
2533 $field_id = 'enable_revisions_control';
2534 $field_slug = 'enable-revisions-control';
2535 add_settings_field(
2536 $field_id,
2537 __( 'Revisions Control', 'admin-site-enhancements' ),
2538 // Field title
2539 [$render_field, 'render_checkbox_toggle'],
2540 ASENHA_SLUG,
2541 'main-section',
2542 array(
2543 'option_name' => ASENHA_SLUG_U,
2544 'field_id' => $field_id,
2545 'field_slug' => $field_slug,
2546 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2547 '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' ),
2548 'field_options_wrapper' => true,
2549 'field_options_moreless' => true,
2550 'class' => 'asenha-toggle optimizations ' . $field_slug,
2551 )
2552 );
2553 $field_id = 'revisions_max_number';
2554 $field_slug = 'revisions-max-number';
2555 add_settings_field(
2556 $field_id,
2557 '',
2558 // Field title
2559 [$render_field, 'render_number_subfield'],
2560 ASENHA_SLUG,
2561 'main-section',
2562 array(
2563 'option_name' => ASENHA_SLUG_U,
2564 'field_id' => $field_id,
2565 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2566 'field_type' => 'with-prefix-suffix',
2567 'field_prefix' => __( 'Limit to', 'admin-site-enhancements' ),
2568 'field_suffix' => __( 'revisions for:', 'admin-site-enhancements' ),
2569 'field_intro' => '',
2570 'field_placeholder' => '10',
2571 'field_min' => 1,
2572 'field_max' => 100,
2573 'field_description' => '',
2574 'class' => 'asenha-number asenha-hide-th extra-narrow optimizations ' . $field_slug,
2575 )
2576 );
2577 $field_id = 'enable_revisions_control_for';
2578 $field_slug = 'enable-revisions-control-for';
2579 if ( is_array( $asenha_revisions_post_types ) ) {
2580 // Exclude Bricks builder template CPT as revisions are handled via a constant
2581 // Ref: https://academy.bricksbuilder.io/article/revisions/
2582 unset($asenha_revisions_post_types['bricks_template']);
2583 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) {
2584 // e.g. $post_type_slug is post, $post_type_label is Posts
2585 add_settings_field(
2586 $field_id . '_' . $post_type_slug,
2587 '',
2588 // Field title
2589 [$render_field, 'render_checkbox_subfield'],
2590 ASENHA_SLUG,
2591 'main-section',
2592 array(
2593 'option_name' => ASENHA_SLUG_U,
2594 'parent_field_id' => $field_id,
2595 'field_id' => $post_type_slug,
2596 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $post_type_slug . ']',
2597 'field_label' => $post_type_label . ' <span class="faded">(' . $post_type_slug . ')</span>',
2598 'class' => 'asenha-checkbox asenha-hide-th asenha-half optimizations ' . $field_slug . ' ' . $post_type_slug,
2599 )
2600 );
2601 }
2602 }
2603 // Enable Heartbeat Control
2604 $field_id = 'enable_heartbeat_control';
2605 $field_slug = 'enable-heartbeat-control';
2606 add_settings_field(
2607 $field_id,
2608 __( 'Heartbeat Control', 'admin-site-enhancements' ),
2609 // Field title
2610 [$render_field, 'render_checkbox_toggle'],
2611 ASENHA_SLUG,
2612 'main-section',
2613 array(
2614 'option_name' => ASENHA_SLUG_U,
2615 'field_id' => $field_id,
2616 'field_slug' => $field_slug,
2617 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2618 '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' ),
2619 'field_options_wrapper' => true,
2620 'field_options_moreless' => true,
2621 'class' => 'asenha-toggle optimizations ' . $field_slug,
2622 )
2623 );
2624 $field_id = 'heartbeat_control_for_admin_pages';
2625 $field_slug = 'heartbeat-control-for-admin-pages';
2626 add_settings_field(
2627 $field_id,
2628 __( 'On admin pages', 'admin-site-enhancements' ),
2629 // Field title
2630 [$render_field, 'render_radio_buttons_subfield'],
2631 ASENHA_SLUG,
2632 'main-section',
2633 array(
2634 'option_name' => ASENHA_SLUG_U,
2635 'field_id' => $field_id,
2636 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2637 'field_radios' => array(
2638 __( 'Keep as is', 'admin-site-enhancements' ) => 'default',
2639 __( 'Modify', 'admin-site-enhancements' ) => 'modify',
2640 __( 'Disable', 'admin-site-enhancements' ) => 'disable',
2641 ),
2642 'field_default' => 'default',
2643 'class' => 'asenha-radio-buttons optimizations ' . $field_slug,
2644 )
2645 );
2646 $field_id = 'heartbeat_interval_for_admin_pages';
2647 $field_slug = 'heartbeat-interval-for-admin-pages';
2648 add_settings_field(
2649 $field_id,
2650 '',
2651 // Field title
2652 [$render_field, 'render_select_subfield'],
2653 ASENHA_SLUG,
2654 'main-section',
2655 array(
2656 'option_name' => ASENHA_SLUG_U,
2657 'field_id' => $field_id,
2658 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2659 'field_type' => 'with-prefix-suffix',
2660 'field_prefix' => __( 'Set interval to once every', 'admin-site-enhancements' ),
2661 'field_suffix' => __( '<span class="faded">(Default is 1 minute)</span>', 'admin-site-enhancements' ),
2662 'field_select_options' => array(
2663 __( '15 seconds', 'admin-site-enhancements' ) => 15,
2664 __( '30 seconds', 'admin-site-enhancements' ) => 30,
2665 __( '1 minute', 'admin-site-enhancements' ) => 60,
2666 __( '2 minutes', 'admin-site-enhancements' ) => 120,
2667 __( '3 minutes', 'admin-site-enhancements' ) => 180,
2668 __( '5 minutes', 'admin-site-enhancements' ) => 300,
2669 __( '10 minutes', 'admin-site-enhancements' ) => 600,
2670 ),
2671 'field_select_default' => 60,
2672 'field_intro' => '',
2673 'field_description' => '',
2674 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2675 'display_none_on_load' => true,
2676 )
2677 );
2678 $field_id = 'heartbeat_control_for_post_edit';
2679 $field_slug = 'heartbeat-control-for-post-edit';
2680 add_settings_field(
2681 $field_id,
2682 __( 'On post creation and edit screens', 'admin-site-enhancements' ),
2683 // Field title
2684 [$render_field, 'render_radio_buttons_subfield'],
2685 ASENHA_SLUG,
2686 'main-section',
2687 array(
2688 'option_name' => ASENHA_SLUG_U,
2689 'field_id' => $field_id,
2690 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2691 'field_radios' => array(
2692 __( 'Keep as is', 'admin-site-enhancements' ) => 'default',
2693 __( 'Modify', 'admin-site-enhancements' ) => 'modify',
2694 __( 'Disable', 'admin-site-enhancements' ) => 'disable',
2695 ),
2696 'field_default' => 'default',
2697 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug,
2698 )
2699 );
2700 $field_id = 'heartbeat_interval_for_post_edit';
2701 $field_slug = 'heartbeat-interval-for-post-edit';
2702 add_settings_field(
2703 $field_id,
2704 '',
2705 // Field title
2706 [$render_field, 'render_select_subfield'],
2707 ASENHA_SLUG,
2708 'main-section',
2709 array(
2710 'option_name' => ASENHA_SLUG_U,
2711 'field_id' => $field_id,
2712 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2713 'field_type' => 'with-prefix-suffix',
2714 'field_prefix' => __( 'Set interval to once every', 'admin-site-enhancements' ),
2715 'field_suffix' => __( '<span class="faded">(Default is 15 seconds)</span>', 'admin-site-enhancements' ),
2716 'field_select_options' => array(
2717 __( '15 seconds', 'admin-site-enhancements' ) => 15,
2718 __( '30 seconds', 'admin-site-enhancements' ) => 30,
2719 __( '45 seconds', 'admin-site-enhancements' ) => 45,
2720 __( '60 seconds', 'admin-site-enhancements' ) => 60,
2721 __( '90 seconds', 'admin-site-enhancements' ) => 90,
2722 __( '120 seconds', 'admin-site-enhancements' ) => 120,
2723 ),
2724 'field_select_default' => 15,
2725 'field_intro' => '',
2726 'field_description' => '',
2727 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2728 'display_none_on_load' => true,
2729 )
2730 );
2731 $field_id = 'heartbeat_control_for_frontend';
2732 $field_slug = 'heartbeat-control-for-frontend';
2733 add_settings_field(
2734 $field_id,
2735 __( 'On the frontend', 'admin-site-enhancements' ),
2736 // Field title
2737 [$render_field, 'render_radio_buttons_subfield'],
2738 ASENHA_SLUG,
2739 'main-section',
2740 array(
2741 'option_name' => ASENHA_SLUG_U,
2742 'field_id' => $field_id,
2743 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2744 'field_radios' => array(
2745 __( 'Keep as is', 'admin-site-enhancements' ) => 'default',
2746 __( 'Modify', 'admin-site-enhancements' ) => 'modify',
2747 __( 'Disable', 'admin-site-enhancements' ) => 'disable',
2748 ),
2749 'field_default' => 'default',
2750 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug,
2751 )
2752 );
2753 $field_id = 'heartbeat_interval_for_frontend';
2754 $field_slug = 'heartbeat-interval-for-frontend';
2755 add_settings_field(
2756 $field_id,
2757 '',
2758 // Field title
2759 [$render_field, 'render_select_subfield'],
2760 ASENHA_SLUG,
2761 'main-section',
2762 array(
2763 'option_name' => ASENHA_SLUG_U,
2764 'field_id' => $field_id,
2765 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2766 'field_type' => 'with-prefix-suffix',
2767 'field_prefix' => __( 'Set interval to once every', 'admin-site-enhancements' ),
2768 'field_suffix' => '',
2769 'field_select_options' => array(
2770 __( '15 seconds', 'admin-site-enhancements' ) => 15,
2771 __( '30 seconds', 'admin-site-enhancements' ) => 30,
2772 __( '1 minute', 'admin-site-enhancements' ) => 60,
2773 __( '2 minutes', 'admin-site-enhancements' ) => 120,
2774 __( '3 minutes', 'admin-site-enhancements' ) => 180,
2775 __( '5 minutes', 'admin-site-enhancements' ) => 300,
2776 __( '10 minutes', 'admin-site-enhancements' ) => 600,
2777 ),
2778 'field_select_default' => 60,
2779 'field_intro' => '',
2780 'field_description' => '',
2781 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug,
2782 'display_none_on_load' => true,
2783 )
2784 );
2785 // =================================================================
2786 // UTILITIES
2787 // =================================================================
2788 // SMTP Email Delivery
2789 $field_id = 'smtp_email_delivery';
2790 $field_slug = 'smtp-email-delivery';
2791 add_settings_field(
2792 $field_id,
2793 __( 'Email Delivery', 'admin-site-enhancements' ),
2794 // Field title
2795 [$render_field, 'render_checkbox_toggle'],
2796 ASENHA_SLUG,
2797 'main-section',
2798 array(
2799 'option_name' => ASENHA_SLUG_U,
2800 'field_id' => $field_id,
2801 'field_slug' => $field_slug,
2802 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2803 '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' ),
2804 'field_options_wrapper' => true,
2805 'field_options_moreless' => true,
2806 'class' => 'asenha-toggle utilities ' . $field_slug,
2807 )
2808 );
2809 $field_id = 'smtp_default_from_description';
2810 $field_slug = 'smtp-default-from-description';
2811 add_settings_field(
2812 $field_id,
2813 '',
2814 // Field title
2815 [$render_field, 'render_description_subfield'],
2816 ASENHA_SLUG,
2817 'main-section',
2818 array(
2819 'option_name' => ASENHA_SLUG_U,
2820 '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' ),
2821 'class' => 'asenha-description utilities ' . $field_slug,
2822 )
2823 );
2824 $field_id = 'smtp_default_from_name';
2825 $field_slug = 'smtp-default-from-name';
2826 add_settings_field(
2827 $field_id,
2828 __( '<span class="field-sublabel sublabel-wide">Sender name</span>', 'admin-site-enhancements' ),
2829 // Field title
2830 [$render_field, 'render_text_subfield'],
2831 ASENHA_SLUG,
2832 'main-section',
2833 array(
2834 'option_name' => ASENHA_SLUG_U,
2835 'field_id' => $field_id,
2836 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2837 'field_type' => '',
2838 'field_prefix' => '',
2839 'field_suffix' => '',
2840 'field_description' => '',
2841 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2842 )
2843 );
2844 $field_id = 'smtp_default_from_email';
2845 $field_slug = 'smtp-default-from-email';
2846 add_settings_field(
2847 $field_id,
2848 __( '<span class="field-sublabel sublabel-wide">Sender email</span>', 'admin-site-enhancements' ),
2849 // Field title
2850 [$render_field, 'render_text_subfield'],
2851 ASENHA_SLUG,
2852 'main-section',
2853 array(
2854 'option_name' => ASENHA_SLUG_U,
2855 'field_id' => $field_id,
2856 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2857 'field_type' => '',
2858 'field_prefix' => '',
2859 'field_suffix' => '',
2860 'field_description' => '',
2861 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2862 )
2863 );
2864 $field_id = 'smtp_force_from';
2865 $field_slug = 'smtp-force-from';
2866 add_settings_field(
2867 $field_id,
2868 '',
2869 // Field title
2870 [$render_field, 'render_checkbox_plain'],
2871 ASENHA_SLUG,
2872 'main-section',
2873 array(
2874 'option_name' => ASENHA_SLUG_U,
2875 'field_id' => $field_id,
2876 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2877 'field_label' => __( 'Force the usage of the sender name/email defined above. It will override those set by other plugins.', 'admin-site-enhancements' ),
2878 'class' => 'asenha-checkbox asenha-hide-th utilities ' . $field_slug,
2879 )
2880 );
2881 $field_id = 'smtp_description';
2882 $field_slug = 'smtp--description';
2883 add_settings_field(
2884 $field_id,
2885 '',
2886 // Field title
2887 [$render_field, 'render_description_subfield'],
2888 ASENHA_SLUG,
2889 'main-section',
2890 array(
2891 'option_name' => ASENHA_SLUG_U,
2892 'field_description' => __( 'If set, the following SMTP service/account wil be used to deliver your emails.', 'admin-site-enhancements' ),
2893 'class' => 'asenha-description top-border utilities ' . $field_slug,
2894 )
2895 );
2896 $field_id = 'smtp_host';
2897 $field_slug = 'smtp-host';
2898 add_settings_field(
2899 $field_id,
2900 __( '<span class="field-sublabel sublabel-wide">Host</span>', 'admin-site-enhancements' ),
2901 // Field title
2902 [$render_field, 'render_text_subfield'],
2903 ASENHA_SLUG,
2904 'main-section',
2905 array(
2906 'option_name' => ASENHA_SLUG_U,
2907 'field_id' => $field_id,
2908 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2909 'field_type' => '',
2910 'field_prefix' => '',
2911 'field_suffix' => '',
2912 'field_description' => '',
2913 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2914 )
2915 );
2916 $field_id = 'smtp_port';
2917 $field_slug = 'smtp-port';
2918 add_settings_field(
2919 $field_id,
2920 __( '<span class="field-sublabel sublabel-wide">Port</span>', 'admin-site-enhancements' ),
2921 // Field title
2922 [$render_field, 'render_number_subfield'],
2923 ASENHA_SLUG,
2924 'main-section',
2925 array(
2926 'option_name' => ASENHA_SLUG_U,
2927 'field_id' => $field_id,
2928 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2929 'field_type' => '',
2930 'field_prefix' => '',
2931 'field_suffix' => '',
2932 'field_intro' => '',
2933 'field_description' => '',
2934 'field_min' => 1,
2935 'field_max' => 100000,
2936 'class' => 'asenha-text with-prefix-suffix narrow utilities ' . $field_slug,
2937 )
2938 );
2939 $field_id = 'smtp_security';
2940 $field_slug = 'smtp-security';
2941 add_settings_field(
2942 $field_id,
2943 __( '<span class="field-sublabel sublabel-wide">Security</span>', 'admin-site-enhancements' ),
2944 // Field title
2945 [$render_field, 'render_radio_buttons_subfield'],
2946 ASENHA_SLUG,
2947 'main-section',
2948 array(
2949 'option_name' => ASENHA_SLUG_U,
2950 'field_id' => $field_id,
2951 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2952 'field_radios' => array(
2953 __( 'None', 'admin-site-enhancements' ) => 'none',
2954 __( 'SSL', 'admin-site-enhancements' ) => 'ssl',
2955 __( 'TLS', 'admin-site-enhancements' ) => 'tls',
2956 ),
2957 'field_default' => 'default',
2958 'class' => 'asenha-radio-buttons with-prefix-suffix utilities ' . $field_slug,
2959 )
2960 );
2961 $field_id = 'smtp_username';
2962 $field_slug = 'smtp-username';
2963 add_settings_field(
2964 $field_id,
2965 __( '<span class="field-sublabel sublabel-wide">Username</span>', 'admin-site-enhancements' ),
2966 // Field title
2967 [$render_field, 'render_text_subfield'],
2968 ASENHA_SLUG,
2969 'main-section',
2970 array(
2971 'option_name' => ASENHA_SLUG_U,
2972 'field_id' => $field_id,
2973 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2974 'field_type' => '',
2975 'field_prefix' => '',
2976 'field_suffix' => '',
2977 'field_description' => '',
2978 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2979 )
2980 );
2981 $field_id = 'smtp_password';
2982 $field_slug = 'smtp-password';
2983 add_settings_field(
2984 $field_id,
2985 __( '<span class="field-sublabel sublabel-wide">Password</span>', 'admin-site-enhancements' ),
2986 // Field title
2987 [$render_field, 'render_password_subfield'],
2988 ASENHA_SLUG,
2989 'main-section',
2990 array(
2991 'option_name' => ASENHA_SLUG_U,
2992 'field_id' => $field_id,
2993 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
2994 'field_type' => '',
2995 'field_prefix' => '',
2996 'field_suffix' => '',
2997 'field_description' => '',
2998 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug,
2999 )
3000 );
3001 $field_id = 'smtp_bypass_ssl_verification';
3002 $field_slug = 'smtp-bypass-ssl-verification';
3003 add_settings_field(
3004 $field_id,
3005 '',
3006 // Field title
3007 [$render_field, 'render_checkbox_plain'],
3008 ASENHA_SLUG,
3009 'main-section',
3010 array(
3011 'option_name' => ASENHA_SLUG_U,
3012 'field_id' => $field_id,
3013 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3014 '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' ),
3015 'class' => 'asenha-checkbox asenha-hide-th margin-top-8 utilities ' . $field_slug,
3016 )
3017 );
3018 $field_id = 'smtp_debug';
3019 $field_slug = 'smtp-debug';
3020 add_settings_field(
3021 $field_id,
3022 '',
3023 // Field title
3024 [$render_field, 'render_checkbox_plain'],
3025 ASENHA_SLUG,
3026 'main-section',
3027 array(
3028 'option_name' => ASENHA_SLUG_U,
3029 'field_id' => $field_id,
3030 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3031 'field_label' => __( 'Enable debug mode and output the debug info into WordPress debug.log file.', 'admin-site-enhancements' ),
3032 'class' => 'asenha-checkbox asenha-hide-th bottom-border utilities ' . $field_slug,
3033 )
3034 );
3035 $field_id = 'smtp_send_test_email_description';
3036 $field_slug = 'smtp-send-test-email-description';
3037 add_settings_field(
3038 $field_id,
3039 '',
3040 // Field title
3041 [$render_field, 'render_description_subfield'],
3042 ASENHA_SLUG,
3043 'main-section',
3044 array(
3045 'option_name' => ASENHA_SLUG_U,
3046 'field_description' => __( 'After saving the settings above, check if everything is configured properly below.', 'admin-site-enhancements' ),
3047 'class' => 'asenha-description utilities ' . $field_slug,
3048 )
3049 );
3050 $field_id = 'smtp_send_test_email_to';
3051 $field_slug = 'smtp-send-test-email-to';
3052 add_settings_field(
3053 $field_id,
3054 __( '<span class="field-sublabel sublabel-wide">Send a test email to</span>', 'admin-site-enhancements' ),
3055 // Field title
3056 [$render_field, 'render_custom_html'],
3057 ASENHA_SLUG,
3058 'main-section',
3059 array(
3060 '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>',
3061 'class' => 'asenha-html wide utilities ' . $field_slug,
3062 )
3063 );
3064 $field_id = 'smtp_send_test_email_result';
3065 $field_slug = 'smtp-send-test-email-result';
3066 add_settings_field(
3067 $field_id,
3068 '',
3069 // Field title
3070 [$render_field, 'render_description_subfield'],
3071 ASENHA_SLUG,
3072 'main-section',
3073 array(
3074 'option_name' => ASENHA_SLUG_U,
3075 'field_description' => '<div id="ajax-result" class="ajax-result-div" style="display:none;">
3076 <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>
3077 <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>
3078 <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>',
3079 'class' => 'asenha-description utilities ' . $field_slug,
3080 )
3081 );
3082 // Multiple User Roles
3083 $field_id = 'multiple_user_roles';
3084 $field_slug = 'multiple-user-roles';
3085 add_settings_field(
3086 $field_id,
3087 __( 'Multiple User Roles', 'admin-site-enhancements' ),
3088 // Field title
3089 [$render_field, 'render_checkbox_toggle'],
3090 ASENHA_SLUG,
3091 'main-section',
3092 array(
3093 'option_name' => ASENHA_SLUG_U,
3094 'field_id' => $field_id,
3095 'field_slug' => $field_slug,
3096 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3097 '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' ),
3098 'field_options_wrapper' => true,
3099 'class' => 'asenha-toggle utilities ' . $field_slug,
3100 )
3101 );
3102 // Image Sizes Panel
3103 $field_id = 'image_sizes_panel';
3104 $field_slug = 'image-sizes-panel';
3105 add_settings_field(
3106 $field_id,
3107 __( 'Image Sizes Panel', 'admin-site-enhancements' ),
3108 // Field title
3109 [$render_field, 'render_checkbox_toggle'],
3110 ASENHA_SLUG,
3111 'main-section',
3112 array(
3113 'option_name' => ASENHA_SLUG_U,
3114 'field_id' => $field_id,
3115 'field_slug' => $field_slug,
3116 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3117 'field_description' => __( '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' ),
3118 'field_options_wrapper' => true,
3119 'class' => 'asenha-toggle utilities ' . $field_slug,
3120 )
3121 );
3122 // View Admin as Role
3123 $field_id = 'view_admin_as_role';
3124 $field_slug = 'view-admin-as-role';
3125 add_settings_field(
3126 $field_id,
3127 __( 'View Admin as Role', 'admin-site-enhancements' ),
3128 // Field title
3129 [$render_field, 'render_checkbox_toggle'],
3130 ASENHA_SLUG,
3131 'main-section',
3132 array(
3133 'option_name' => ASENHA_SLUG_U,
3134 'field_id' => $field_id,
3135 'field_slug' => $field_slug,
3136 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3137 'field_description' => __( 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', 'admin-site-enhancements' ),
3138 'field_options_moreless' => true,
3139 'field_options_wrapper' => true,
3140 'class' => 'asenha-toggle utilities ' . $field_slug,
3141 )
3142 );
3143 $current_user = wp_get_current_user();
3144 $current_user_username = $current_user->user_login;
3145 $field_id = 'view_admin_as_role_description';
3146 $field_slug = 'view-admin-as-role-description';
3147 $role_reset_link = site_url( '/?reset-for=' ) . $current_user_username;
3148 add_settings_field(
3149 $field_id,
3150 '',
3151 // Field title
3152 [$render_field, 'render_description_subfield'],
3153 ASENHA_SLUG,
3154 'main-section',
3155 array(
3156 'option_name' => ASENHA_SLUG_U,
3157 'field_description' => '<div class="asenha-warning"><strong>' . sprintf(
3158 /* translators: %s is URL of the role reset link */
3159 __( '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' ),
3160 $role_reset_link
3161 ) . '</div>',
3162 'class' => 'asenha-description utilities ' . $field_slug,
3163 )
3164 );
3165 // Enable Password Protection
3166 $field_id = 'enable_password_protection';
3167 $field_slug = 'enable-password-protection';
3168 add_settings_field(
3169 $field_id,
3170 __( 'Password Protection', 'admin-site-enhancements' ),
3171 // Field title
3172 [$render_field, 'render_checkbox_toggle'],
3173 ASENHA_SLUG,
3174 'main-section',
3175 array(
3176 'option_name' => ASENHA_SLUG_U,
3177 'field_id' => $field_id,
3178 'field_slug' => $field_slug,
3179 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3180 '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' ),
3181 'field_options_moreless' => true,
3182 'field_options_wrapper' => true,
3183 'class' => 'asenha-toggle utilities ' . $field_slug,
3184 )
3185 );
3186 $field_id = 'password_protection_password';
3187 $field_slug = 'password-protection-password';
3188 add_settings_field(
3189 $field_id,
3190 __( 'Set the password:', 'admin-site-enhancements' ),
3191 // Field title
3192 [$render_field, 'render_password_subfield'],
3193 ASENHA_SLUG,
3194 'main-section',
3195 array(
3196 'option_name' => ASENHA_SLUG_U,
3197 'field_id' => $field_id,
3198 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3199 'field_type' => 'with-prefix-suffix',
3200 'field_prefix' => '',
3201 'field_suffix' => '<span class="faded">' . __( '(Default is \'secret\')', 'admin-site-enhancements' ) . '</span>',
3202 'field_description' => '',
3203 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug,
3204 )
3205 );
3206 // Maintenance Mode
3207 $field_id = 'maintenance_mode';
3208 $field_slug = 'maintenance-mode';
3209 add_settings_field(
3210 $field_id,
3211 __( 'Maintenance Mode', 'admin-site-enhancements' ),
3212 // Field title
3213 [$render_field, 'render_checkbox_toggle'],
3214 ASENHA_SLUG,
3215 'main-section',
3216 array(
3217 'option_name' => ASENHA_SLUG_U,
3218 'field_id' => $field_id,
3219 'field_slug' => $field_slug,
3220 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3221 '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' ),
3222 'field_options_wrapper' => true,
3223 'field_options_moreless' => true,
3224 'class' => 'asenha-toggle utilities ' . $field_slug,
3225 )
3226 );
3227 $field_id = 'maintenance_page_type_custom';
3228 $field_slug = 'maintenance-page-type-custom';
3229 add_settings_field(
3230 $field_id,
3231 '',
3232 // Field title
3233 [$render_field, 'render_custom_html'],
3234 ASENHA_SLUG,
3235 'main-section',
3236 array(
3237 'html' => '<div class="subfields-container subfields-in-column maintenance-page-type-custom"></div>',
3238 )
3239 );
3240 $field_id = 'maintenance_page_heading';
3241 $field_slug = 'maintenance-page-heading';
3242 add_settings_field(
3243 $field_id,
3244 __( 'Heading', 'admin-site-enhancements' ),
3245 // Field title
3246 [$render_field, 'render_text_subfield'],
3247 ASENHA_SLUG,
3248 'main-section',
3249 array(
3250 'option_name' => ASENHA_SLUG_U,
3251 'field_id' => $field_id,
3252 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3253 'field_type' => '',
3254 'field_prefix' => '',
3255 'field_suffix' => '',
3256 'field_description' => '',
3257 'field_placeholder' => __( 'We\'ll be back soon.', 'admin-site-enhancements' ),
3258 'class' => 'asenha-text utilities full-width margin-bottom-20 ' . $field_slug,
3259 )
3260 );
3261 $field_id = 'maintenance_page_description';
3262 $field_slug = 'maintenance-page-description';
3263 add_settings_field(
3264 $field_id,
3265 __( 'Description', 'admin-site-enhancements' ),
3266 // Field title
3267 [$render_field, 'render_textarea_subfield'],
3268 ASENHA_SLUG,
3269 'main-section',
3270 array(
3271 'option_name' => ASENHA_SLUG_U,
3272 'field_id' => $field_id,
3273 'field_slug' => $field_slug,
3274 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3275 'field_type' => 'textarea',
3276 'field_rows' => 5,
3277 'field_intro' => '',
3278 'field_description' => '',
3279 'field_placeholder' => __( 'This site is undergoing maintenance for an extended period today. Thanks for your patience.', 'admin-site-enhancements' ),
3280 'class' => 'asenha-textarea utilities ' . $field_slug,
3281 )
3282 );
3283 $field_id = 'maintenance_page_background';
3284 $field_slug = 'maintenance-page-background';
3285 $field_radios = array(
3286 __( 'Stripes', 'admin-site-enhancements' ) => 'stripes',
3287 __( 'Curves', 'admin-site-enhancements' ) => 'curves',
3288 __( 'Lines', 'admin-site-enhancements' ) => 'lines',
3289 );
3290 add_settings_field(
3291 $field_id,
3292 __( 'Background', 'admin-site-enhancements' ),
3293 // Field title
3294 [$render_field, 'render_radio_buttons_subfield'],
3295 ASENHA_SLUG,
3296 'main-section',
3297 array(
3298 'option_name' => ASENHA_SLUG_U,
3299 'field_id' => $field_id,
3300 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3301 'field_radios' => $field_radios,
3302 'field_default' => 'default',
3303 'class' => 'asenha-radio-buttons margin-top-12 utilities ' . $field_slug,
3304 )
3305 );
3306 $field_id = 'maintenance_mode_description';
3307 $field_slug = 'maintenance-mode-description';
3308 add_settings_field(
3309 $field_id,
3310 '',
3311 // Field title
3312 [$render_field, 'render_description_subfield'],
3313 ASENHA_SLUG,
3314 'main-section',
3315 array(
3316 'option_name' => ASENHA_SLUG_U,
3317 '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>',
3318 'class' => 'asenha-description utilities ' . $field_slug,
3319 )
3320 );
3321 // Redirect 404 to Homepage
3322 $field_id = 'redirect_404_to_homepage';
3323 $field_slug = 'redirect-404-to-homepage';
3324 $module_title = __( 'Redirect 404 to Homepage', 'admin-site-enhancements' );
3325 $module_description = __( 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', 'admin-site-enhancements' );
3326 $field_options_wrapper = false;
3327 $field_options_moreless = false;
3328 add_settings_field(
3329 $field_id,
3330 $module_title,
3331 // Field title
3332 [$render_field, 'render_checkbox_toggle'],
3333 ASENHA_SLUG,
3334 'main-section',
3335 array(
3336 'option_name' => ASENHA_SLUG_U,
3337 'field_id' => $field_id,
3338 'field_slug' => $field_slug,
3339 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3340 'field_description' => $module_description,
3341 'field_options_wrapper' => $field_options_wrapper,
3342 'field_options_moreless' => $field_options_moreless,
3343 'class' => 'asenha-toggle utilities ' . $field_slug,
3344 )
3345 );
3346 // Display System Summary
3347 $field_id = 'display_system_summary';
3348 $field_slug = 'display-system-summary';
3349 $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' );
3350 add_settings_field(
3351 $field_id,
3352 __( 'Display System Summary', 'admin-site-enhancements' ),
3353 // Field title
3354 [$render_field, 'render_checkbox_toggle'],
3355 ASENHA_SLUG,
3356 'main-section',
3357 array(
3358 'option_name' => ASENHA_SLUG_U,
3359 'field_id' => $field_id,
3360 'field_slug' => $field_slug,
3361 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3362 'field_description' => $module_description,
3363 'field_options_wrapper' => true,
3364 'class' => 'asenha-toggle utilities ' . $field_slug,
3365 )
3366 );
3367 // Search Engines Visibility Status
3368 $field_id = 'search_engine_visibility_status';
3369 $field_slug = 'search-engine-visibility-status';
3370 $field_options_moreless = false;
3371 $field_options_wrapper = false;
3372 add_settings_field(
3373 $field_id,
3374 __( 'Search Engines Visibility Status', 'admin-site-enhancements' ),
3375 // Field title
3376 [$render_field, 'render_checkbox_toggle'],
3377 ASENHA_SLUG,
3378 'main-section',
3379 array(
3380 'option_name' => ASENHA_SLUG_U,
3381 'field_id' => $field_id,
3382 'field_slug' => $field_slug,
3383 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']',
3384 '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' ),
3385 'field_options_moreless' => $field_options_moreless,
3386 'field_options_wrapper' => $field_options_wrapper,
3387 'class' => 'asenha-toggle utilities ' . $field_slug,
3388 )
3389 );
3390 }
3391
3392 }
3393