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