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