PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 4.9.2
Admin and Site Enhancements (ASE) v4.9.2
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-sections-fields.php
admin-site-enhancements / classes Last commit date
class-activation.php 3 years ago class-admin-interface.php 3 years ago class-common-methods.php 3 years ago class-content-management.php 3 years ago class-custom-code.php 3 years ago class-deactivation.php 3 years ago class-disable-components.php 3 years ago class-login-logout.php 3 years ago class-optimizations.php 3 years ago class-security.php 3 years ago class-settings-fields-render.php 3 years ago class-settings-sanitization.php 3 years ago class-settings-sections-fields.php 3 years ago class-utilities.php 3 years ago
class-settings-sections-fields.php
2493 lines
1 <?php
2
3 namespace ASENHA\Classes;
4
5 /**
6 * Class related to registration of settings fields
7 *
8 * @since 2.2.0
9 */
10 class Settings_Sections_Fields {
11
12 /**
13 * Register plugin settings and the corresponding fields
14 *
15 * @link https://wpshout.com/making-an-admin-options-page-with-the-wordpress-settings-api/
16 * @link https://rudrastyh.com/wordpress/creating-options-pages.html
17 * @since 1.0.0
18 */
19 function register_sections_fields() {
20
21 add_settings_section(
22 'main-section', // Section ID
23 '', // Section title. Can be blank.
24 '', // Callback function to output section intro. Can be blank.
25 ASENHA_SLUG // Settings page slug
26 );
27
28 // Register main setttings
29
30 // Instantiate object for sanitization of settings fields values
31 $sanitization = new Settings_Sanitization;
32
33 // Instantiate object for rendering of settings fields for the admin page
34 $render_field = new Settings_Fields_Render;
35
36 register_setting(
37 ASENHA_ID, // Option group or option_page
38 ASENHA_SLUG_U, // Option name in wp_options table
39 array(
40 'type' => 'array', // 'string', 'boolean', 'integer', 'number', 'array', or 'object'
41 'description' => '', // A description of the data attached to this setting.
42 'sanitize_callback' => [ $sanitization, 'sanitize_for_options' ],
43 'show_in_rest' => false,
44 'default' => array(), // When calling get_option()
45 )
46 );
47
48 // =================================================================
49 // Call WordPress globals and set new globals required for the fields
50 // =================================================================
51
52 global $wp_roles, $wpdb, $asenha_public_post_types, $asenha_gutenberg_post_types, $asenha_revisions_post_types;
53
54 $roles = $wp_roles->get_names();
55
56 // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
57 $asenha_public_post_types = array();
58 $public_post_type_names = get_post_types( array( 'public' => true ), 'names' );
59 foreach( $public_post_type_names as $post_type_name ) {
60 $post_type_object = get_post_type_object( $post_type_name );
61 $asenha_public_post_types[$post_type_name] = $post_type_object->label;
62 }
63
64 // 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' )
65 $asenha_gutenberg_post_types = array();
66 $gutenberg_not_applicable_types = array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' );
67 $all_post_types = get_post_types( array(), 'objects' );
68 foreach ( $all_post_types as $post_type_slug => $post_type_info ) {
69 $asenha_gutenberg_post_types[$post_type_slug] = $post_type_info->label;
70 if ( in_array( $post_type_slug, $gutenberg_not_applicable_types ) ) {
71 unset( $asenha_gutenberg_post_types[$post_type_slug] );
72 }
73 }
74
75 // Get array of slugs and plural labels for post types supporting revisions, e.g. array( 'post' => 'Posts', 'page' => 'Pages' )
76 $asenha_revisions_post_types = array();
77 foreach ( get_post_types( array(), 'names' ) as $post_type_slug ) { // post type slug/name
78 if ( post_type_supports( $post_type_slug, 'revisions' ) ) {
79 $post_type_object = get_post_type_object( $post_type_slug );
80 if ( property_exists( $post_type_object, 'label' ) ) {
81 $asenha_revisions_post_types[$post_type_slug] = $post_type_object->label;
82 }
83 }
84 }
85
86 // =================================================================
87 // CONTENT MANAGEMENT
88 // =================================================================
89
90 // Enable Page and Post Duplication
91
92 $field_id = 'enable_duplication';
93 $field_slug = 'enable-duplication';
94
95 add_settings_field(
96 $field_id, // Field ID
97 'Page and Post Duplication', // Field title
98 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
99 ASENHA_SLUG, // Settings page slug
100 'main-section', // Section ID
101 array(
102 'field_id' => $field_id, // Custom argument
103 'field_slug' => $field_slug, // Custom argument
104 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
105 'field_description' => 'Enable one-click duplication of pages, posts and custom posts. The corresponding taxonomy terms and post meta will also be duplicated.', // Custom argument
106 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
107 )
108 );
109
110 // Enable Media Replacement
111
112 $field_id = 'enable_media_replacement';
113 $field_slug = 'enable-media-replacement';
114
115 add_settings_field(
116 $field_id, // Field ID
117 'Media Replacement', // Field title
118 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
119 ASENHA_SLUG, // Settings page slug
120 'main-section', // Section ID
121 array(
122 'field_id' => $field_id, // Custom argument
123 'field_slug' => $field_slug, // Custom argument
124 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
125 '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.', // Custom argument
126 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
127 )
128 );
129
130 // Enable SVG Upload
131
132 $field_id = 'enable_svg_upload';
133 $field_slug = 'enable-svg-upload';
134
135 add_settings_field(
136 $field_id, // Field ID
137 'SVG Upload', // Field title
138 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
139 ASENHA_SLUG, // Settings page slug
140 'main-section', // Section ID
141 array(
142 'field_id' => $field_id, // Custom argument
143 'field_slug' => $field_slug, // Custom argument
144 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
145 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.', // Custom argument
146 'field_options_wrapper' => true, // Custom argument. Add container for additional options
147 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
148 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
149 )
150 );
151
152 $field_id = 'enable_svg_upload_for';
153 $field_slug = 'enable-svg-upload-for';
154
155 if ( is_array( $roles ) ) {
156 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
157
158 add_settings_field(
159 $field_id . '_' . $role_slug, // Field ID
160 '', // Field title
161 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
162 ASENHA_SLUG, // Settings page slug
163 'main-section', // Section ID
164 array(
165 'parent_field_id' => $field_id, // Custom argument
166 'field_id' => $role_slug, // Custom argument
167 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
168 'field_label' => $role_label, // Custom argument
169 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
170 )
171 );
172
173 }
174 }
175
176 // Enable External Permalinks
177
178 $field_id = 'enable_external_permalinks';
179 $field_slug = 'enable-external-permalinks';
180
181 add_settings_field(
182 $field_id, // Field ID
183 'External Permalinks', // Field title
184 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
185 ASENHA_SLUG, // Settings page slug
186 'main-section', // Section ID
187 array(
188 'field_id' => $field_id, // Custom argument
189 'field_slug' => $field_slug, // Custom argument
190 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
191 '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>.', // Custom argument
192 'field_options_wrapper' => true, // Custom argument. Add container for additional options
193 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
194 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
195 )
196 );
197
198 $field_id = 'enable_external_permalinks_for';
199 $field_slug = 'enable-external-permalinks-for';
200
201 if ( is_array( $asenha_public_post_types ) ) {
202 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
203 if ( 'attachment' != $post_type_slug ) {
204 add_settings_field(
205 $field_id . '_' . $post_type_slug, // Field ID
206 '', // Field title
207 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
208 ASENHA_SLUG, // Settings page slug
209 'main-section', // Section ID
210 array(
211 'parent_field_id' => $field_id, // Custom argument
212 'field_id' => $post_type_slug, // Custom argument
213 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
214 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
215 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
216 )
217 );
218 }
219 }
220 }
221
222 // Open All External Links in New Tab
223
224 $field_id = 'external_links_new_tab';
225 $field_slug = 'external-links-new-tab';
226
227 add_settings_field(
228 $field_id, // Field ID
229 'Open All External Links in New Tab', // Field title
230 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
231 ASENHA_SLUG, // Settings page slug
232 'main-section', // Section ID
233 array(
234 'field_id' => $field_id, // Custom argument
235 'field_slug' => $field_slug, // Custom argument
236 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
237 'field_description' => 'Force all links to external sites 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.', // Custom argument
238 'field_options_wrapper' => true, // Custom argument. Add container for additional options
239 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
240 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
241 )
242 );
243
244 // Enable Auto-Publishing of Posts with Missed Schedules
245
246 $field_id = 'enable_missed_schedule_posts_auto_publish';
247 $field_slug = 'enable-missed-schedule-posts-auto-publish';
248
249 add_settings_field(
250 $field_id, // Field ID
251 'Auto-Publish Posts with Missed Schedule', // Field title
252 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
253 ASENHA_SLUG, // Settings page slug
254 'main-section', // Section ID
255 array(
256 'field_id' => $field_id, // Custom argument
257 'field_slug' => $field_slug, // Custom argument
258 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
259 'field_description' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument
260 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
261 )
262 );
263
264
265 // Enhance List Tables
266
267 $field_id = 'enhance_list_tables';
268 $field_slug = 'enhance-list-tables';
269
270 add_settings_field(
271 $field_id, // Field ID
272 'Enhance List Tables', // Field title
273 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
274 ASENHA_SLUG, // Settings page slug
275 'main-section', // Section ID
276 array(
277 'field_id' => $field_id, // Custom argument
278 'field_slug' => $field_slug, // Custom argument
279 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
280 'field_description' => 'Improve the usefulness of listing pages for various post types and taxonomies, media, comments and users by adding / removing columns and elements.', // Custom argument
281 'field_options_wrapper' => true, // Custom argument. Add container for additional options
282 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
283 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
284 )
285 );
286
287 // Show Featured Image Column
288
289 $field_id = 'show_featured_image_column';
290 $field_slug = 'show-featured-image-column';
291
292 add_settings_field(
293 $field_id, // Field ID
294 '', // Field title
295 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
296 ASENHA_SLUG, // Settings page slug
297 'main-section', // Section ID
298 array(
299 'field_id' => $field_id, // Custom argument
300 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
301 'field_label' => 'Show featured image column.', // Custom argument
302 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
303 )
304 );
305
306 // Show Excerpt Column
307
308 $field_id = 'show_excerpt_column';
309 $field_slug = 'show-excerpt-column';
310
311 add_settings_field(
312 $field_id, // Field ID
313 '', // Field title
314 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
315 ASENHA_SLUG, // Settings page slug
316 'main-section', // Section ID
317 array(
318 'field_id' => $field_id, // Custom argument
319 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
320 'field_label' => 'Show excerpt column.', // Custom argument
321 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
322 )
323 );
324
325 // Show ID Column
326
327 $field_id = 'show_id_column';
328 $field_slug = 'show-id-column';
329
330 add_settings_field(
331 $field_id, // Field ID
332 '', // Field title
333 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
334 ASENHA_SLUG, // Settings page slug
335 'main-section', // Section ID
336 array(
337 'field_id' => $field_id, // Custom argument
338 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
339 'field_label' => 'Show ID column.', // Custom argument
340 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
341 )
342 );
343
344 // Show ID in Action Row
345
346 $field_id = 'show_id_in_action_row';
347 $field_slug = 'show-id-in-action_row';
348
349 add_settings_field(
350 $field_id, // Field ID
351 '', // Field title
352 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
353 ASENHA_SLUG, // Settings page slug
354 'main-section', // Section ID
355 array(
356 'field_id' => $field_id, // Custom argument
357 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
358 'field_label' => 'Show ID in action rows along with links for Edit, View, etc.', // Custom argument
359 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
360 )
361 );
362
363 // Show Custom Taxonomy Filters
364
365 $field_id = 'show_custom_taxonomy_filters';
366 $field_slug = 'show-custom-taxonomy-filters';
367
368 add_settings_field(
369 $field_id, // Field ID
370 '', // Field title
371 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
372 ASENHA_SLUG, // Settings page slug
373 'main-section', // Section ID
374 array(
375 'field_id' => $field_id, // Custom argument
376 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
377 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
378 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
379 )
380 );
381
382 // Hide Comments Column
383
384 $field_id = 'hide_comments_column';
385 $field_slug = 'hide-comments-column';
386
387 add_settings_field(
388 $field_id, // Field ID
389 '', // Field title
390 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
391 ASENHA_SLUG, // Settings page slug
392 'main-section', // Section ID
393 array(
394 'field_id' => $field_id, // Custom argument
395 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
396 'field_label' => 'Remove comments column.', // Custom argument
397 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
398 )
399 );
400
401 // Hide Post Tags Column
402
403 $field_id = 'hide_post_tags_column';
404 $field_slug = 'hide-post-tags-column';
405
406 add_settings_field(
407 $field_id, // Field ID
408 '', // Field title
409 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
410 ASENHA_SLUG, // Settings page slug
411 'main-section', // Section ID
412 array(
413 'field_id' => $field_id, // Custom argument
414 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
415 'field_label' => 'Remove tags column (for posts).', // Custom argument
416 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
417 )
418 );
419
420 // =================================================================
421 // ADMIN INTERFACE
422 // =================================================================
423
424 // Hide Admin Notices
425
426 $field_id = 'hide_admin_notices';
427 $field_slug = 'hide-admin-notices';
428
429 add_settings_field(
430 $field_id, // Field ID
431 'Hide Admin Notices', // Field title
432 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
433 ASENHA_SLUG, // Settings page slug
434 'main-section', // Section ID
435 array(
436 'field_id' => $field_id, // Custom argument
437 'field_slug' => $field_slug, // Custom argument
438 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
439 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
440 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
441 )
442 );
443
444 // Disable Dashboard Widgets
445
446 $field_id = 'disable_dashboard_widgets';
447 $field_slug = 'disable-dashboard-widgets';
448
449 add_settings_field(
450 $field_id, // Field ID
451 'Disable Dashboard Widgets', // Field title
452 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
453 ASENHA_SLUG, // Settings page slug
454 'main-section', // Section ID
455 array(
456 'field_id' => $field_id, // Custom argument
457 'field_slug' => $field_slug, // Custom argument
458 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
459 '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. ', // Custom argument
460 'field_options_wrapper' => true, // Custom argument. Add container for additional options
461 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
462 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
463 )
464 );
465
466 $field_id = 'disabled_dashboard_widgets';
467 $field_slug = 'disabled-dashboard-widgets';
468
469 $extra_options = get_option( 'admin_site_enhancements_extra', array() );
470 if ( array_key_exists( 'dashboard_widgets', $extra_options ) ) {
471 $dashboard_widgets = $extra_options['dashboard_widgets'];
472 } else {
473 $admin_interface = new Admin_Interface;
474 $dashboard_widgets = $admin_interface->get_dashboard_widgets();
475 $extra_options['dashboard_widgets'] = $dashboard_widgets;
476 update_option( 'admin_site_enhancements_extra', $extra_options );
477 }
478
479 foreach ( $dashboard_widgets as $widget ) {
480 add_settings_field(
481 $field_id . '_' . $widget['id'], // Field ID
482 '', // Field title
483 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
484 ASENHA_SLUG, // Settings page slug
485 'main-section', // Section ID
486 array(
487 'parent_field_id' => $field_id, // Custom argument
488 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'], // Custom argument
489 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']', // Custom argument
490 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>', // Custom argument
491 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'], // Custom class for the <tr> element
492 )
493 );
494 }
495
496 // Hide or Modify Elements
497
498 $field_id = 'hide_modify_elements';
499 $field_slug = 'hide-modify-elements';
500
501 add_settings_field(
502 $field_id, // Field ID
503 'Clean Up Admin Bar', // Field title
504 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
505 ASENHA_SLUG, // Settings page slug
506 'main-section', // Section ID
507 array(
508 'field_id' => $field_id, // Custom argument
509 'field_slug' => $field_slug, // Custom argument
510 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
511 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
512 'field_options_wrapper' => true, // Custom argument. Add container for additional options
513 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
514 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
515 )
516 );
517
518 $field_id = 'hide_ab_wp_logo_menu';
519 $field_slug = 'hide-ab-wp-logo-menu';
520
521 add_settings_field(
522 $field_id, // Field ID
523 '', // Field title
524 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
525 ASENHA_SLUG, // Settings page slug
526 'main-section', // Section ID
527 array(
528 'field_id' => $field_id, // Custom argument
529 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
530 'field_label' => 'Remove WordPress logo/menu', // Custom argument
531 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
532 )
533 );
534
535 $field_id = 'hide_ab_customize_menu';
536 $field_slug = 'hide-ab-customize-menu';
537
538 add_settings_field(
539 $field_id, // Field ID
540 '', // Field title
541 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
542 ASENHA_SLUG, // Settings page slug
543 'main-section', // Section ID
544 array(
545 'field_id' => $field_id, // Custom argument
546 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
547 'field_label' => 'Remove customize menu', // Custom argument
548 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
549 )
550 );
551
552 $field_id = 'hide_ab_updates_menu';
553 $field_slug = 'hide-ab-updates-menu';
554
555 add_settings_field(
556 $field_id, // Field ID
557 '', // Field title
558 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
559 ASENHA_SLUG, // Settings page slug
560 'main-section', // Section ID
561 array(
562 'field_id' => $field_id, // Custom argument
563 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
564 'field_label' => 'Remove updates counter/link', // Custom argument
565 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
566 )
567 );
568
569 $field_id = 'hide_ab_comments_menu';
570 $field_slug = 'hide-ab-comments-menu';
571
572 add_settings_field(
573 $field_id, // Field ID
574 '', // Field title
575 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
576 ASENHA_SLUG, // Settings page slug
577 'main-section', // Section ID
578 array(
579 'field_id' => $field_id, // Custom argument
580 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
581 'field_label' => 'Remove comments counter/link', // Custom argument
582 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
583 )
584 );
585
586 $field_id = 'hide_ab_new_content_menu';
587 $field_slug = 'hide-ab-new-content-menu';
588
589 add_settings_field(
590 $field_id, // Field ID
591 '', // Field title
592 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
593 ASENHA_SLUG, // Settings page slug
594 'main-section', // Section ID
595 array(
596 'field_id' => $field_id, // Custom argument
597 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
598 'field_label' => 'Remove new content menu', // Custom argument
599 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
600 )
601 );
602
603 $field_id = 'hide_ab_howdy';
604 $field_slug = 'hide-ab-howdy';
605
606 add_settings_field(
607 $field_id, // Field ID
608 '', // Field title
609 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
610 ASENHA_SLUG, // Settings page slug
611 'main-section', // Section ID
612 array(
613 'field_id' => $field_id, // Custom argument
614 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
615 'field_label' => 'Remove \'Howdy\'', // Custom argument
616 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
617 )
618 );
619
620 $field_id = 'hide_help_drawer';
621 $field_slug = 'hide-help-drawer';
622
623 add_settings_field(
624 $field_id, // Field ID
625 '', // Field title
626 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
627 ASENHA_SLUG, // Settings page slug
628 'main-section', // Section ID
629 array(
630 'field_id' => $field_id, // Custom argument
631 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
632 'field_label' => 'Remove the Help tab and drawer', // Custom argument
633 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
634 )
635 );
636
637 // Hide Admin Bar
638
639 $field_id = 'hide_admin_bar';
640 $field_slug = 'hide-admin-bar';
641
642 add_settings_field(
643 $field_id, // Field ID
644 'Hide Admin Bar', // Field title
645 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
646 ASENHA_SLUG, // Settings page slug
647 'main-section', // Section ID
648 array(
649 'field_id' => $field_id, // Custom argument
650 'field_slug' => $field_slug, // Custom argument
651 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
652 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
653 'field_options_wrapper' => true, // Custom argument. Add container for additional options
654 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
655 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
656 )
657 );
658
659 $field_id = 'hide_admin_bar_for';
660 $field_slug = 'hide-admin-bar-for';
661
662 if ( is_array( $roles ) ) {
663 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
664
665 add_settings_field(
666 $field_id . '_' . $role_slug, // Field ID
667 '', // Field title
668 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
669 ASENHA_SLUG, // Settings page slug
670 'main-section', // Section ID
671 array(
672 'parent_field_id' => $field_id, // Custom argument
673 'field_id' => $role_slug, // Custom argument
674 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
675 'field_label' => $role_label, // Custom argument
676 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
677 )
678 );
679
680 }
681 }
682
683 // Customize Admin Menu
684
685 $field_id = 'customize_admin_menu';
686 $field_slug = 'customize-admin-menu';
687
688 add_settings_field(
689 $field_id, // Field ID
690 'Admin Menu Organizer', // Field title
691 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
692 ASENHA_SLUG, // Settings page slug
693 'main-section', // Section ID
694 array(
695 'field_id' => $field_id, // Custom argument
696 'field_slug' => $field_slug, // Custom argument
697 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
698 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
699 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
700 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
701 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
702 )
703 );
704
705 $field_id = 'custom_menu_order';
706 $field_slug = 'custom-menu-order';
707
708 add_settings_field(
709 $field_id, // Field ID
710 '', // Field title
711 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
712 ASENHA_SLUG, // Settings page slug
713 'main-section', // Section ID
714 array(
715 'field_id' => $field_id, // Custom argument
716 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
717 'field_type' => 'sortable-menu', // Custom argument
718 'field_description' => '', // Custom argument
719 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
720 )
721 );
722
723 // =================================================================
724 // LOG IN | LOG OUT
725 // =================================================================
726
727 // Change Login URL
728
729 $field_id = 'change_login_url';
730 $field_slug = 'change-login-url';
731
732 add_settings_field(
733 $field_id, // Field ID
734 'Change Login URL', // Field title
735 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
736 ASENHA_SLUG, // Settings page slug
737 'main-section', // Section ID
738 array(
739 'field_id' => $field_id, // Custom argument
740 'field_slug' => $field_slug, // Custom argument
741 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
742 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
743 'field_options_wrapper' => true, // Custom argument. Add container for additional options
744 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
745 )
746 );
747
748 $field_id = 'custom_login_slug';
749 $field_slug = 'custom-login-slug';
750
751 add_settings_field(
752 $field_id, // Field ID
753 'New URL:', // Field title
754 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
755 ASENHA_SLUG, // Settings page slug
756 'main-section', // Section ID
757 array(
758 'field_id' => $field_id, // Custom argument
759 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
760 'field_type' => 'with-prefix-suffix', // Custom argument
761 'field_prefix' => get_site_url() . '/', // Custom argument
762 'field_suffix' => '/', // Custom argument
763 'field_description' => '', // Custom argument
764 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
765 )
766 );
767
768 // Enable Log In/Out Menu
769
770 $field_id = 'enable_login_logout_menu';
771 $field_slug = 'enable-login-logout-menu';
772
773 add_settings_field(
774 $field_id, // Field ID
775 'Log In/Out Menu', // Field title
776 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
777 ASENHA_SLUG, // Settings page slug
778 'main-section', // Section ID
779 array(
780 'field_id' => $field_id, // Custom argument
781 'field_slug' => $field_slug, // Custom argument
782 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
783 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
784 'field_options_wrapper' => true, // Custom argument. Add container for additional options
785 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
786 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
787 )
788 );
789
790 // Enable Last Login Column
791
792 $field_id = 'enable_last_login_column';
793 $field_slug = 'enable-last-login-column';
794
795 add_settings_field(
796 $field_id, // Field ID
797 'Last Login Column', // Field title
798 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
799 ASENHA_SLUG, // Settings page slug
800 'main-section', // Section ID
801 array(
802 'field_id' => $field_id, // Custom argument
803 'field_slug' => $field_slug, // Custom argument
804 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
805 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument
806 'field_options_wrapper' => true, // Custom argument. Add container for additional options
807 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
808 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
809 )
810 );
811
812 // Redirect After Login
813
814 $field_id = 'redirect_after_login';
815 $field_slug = 'redirect-after-login';
816
817 add_settings_field(
818 $field_id, // Field ID
819 'Redirect After Login', // Field title
820 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
821 ASENHA_SLUG, // Settings page slug
822 'main-section', // Section ID
823 array(
824 'field_id' => $field_id, // Custom argument
825 'field_slug' => $field_slug, // Custom argument
826 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
827 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
828 'field_options_wrapper' => true, // Custom argument. Add container for additional options
829 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
830 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
831 )
832 );
833
834 $field_id = 'redirect_after_login_to_slug';
835 $field_slug = 'redirect-after-login-to-slug';
836
837 add_settings_field(
838 $field_id, // Field ID
839 'Redirect to:', // Field title
840 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
841 ASENHA_SLUG, // Settings page slug
842 'main-section', // Section ID
843 array(
844 'field_id' => $field_id, // Custom argument
845 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
846 'field_type' => 'with-prefix-suffix', // Custom argument
847 'field_prefix' => get_site_url() . '/', // Custom argument
848 'field_suffix' => '/ for:', // Custom argument
849 'field_description' => '', // Custom argument
850 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
851 )
852 );
853
854 $field_id = 'redirect_after_login_for';
855 $field_slug = 'redirect-after-login-for';
856
857 if ( is_array( $roles ) ) {
858 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
859
860 add_settings_field(
861 $field_id . '_' . $role_slug, // Field ID
862 '', // Field title
863 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
864 ASENHA_SLUG, // Settings page slug
865 'main-section', // Section ID
866 array(
867 'parent_field_id' => $field_id, // Custom argument
868 'field_id' => $role_slug, // Custom argument
869 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
870 'field_label' => $role_label, // Custom argument
871 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
872 )
873 );
874
875 }
876 }
877
878 // Redirect After Logout
879
880 $field_id = 'redirect_after_logout';
881 $field_slug = 'redirect-after-logout';
882
883 add_settings_field(
884 $field_id, // Field ID
885 'Redirect After Logout', // Field title
886 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
887 ASENHA_SLUG, // Settings page slug
888 'main-section', // Section ID
889 array(
890 'field_id' => $field_id, // Custom argument
891 'field_slug' => $field_slug, // Custom argument
892 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
893 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
894 'field_options_wrapper' => true, // Custom argument. Add container for additional options
895 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
896 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
897 )
898 );
899
900 $field_id = 'redirect_after_logout_to_slug';
901 $field_slug = 'redirect-after-logout-to-slug';
902
903 add_settings_field(
904 $field_id, // Field ID
905 'Redirect to:', // Field title
906 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
907 ASENHA_SLUG, // Settings page slug
908 'main-section', // Section ID
909 array(
910 'field_id' => $field_id, // Custom argument
911 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
912 'field_type' => 'with-prefix-suffix', // Custom argument
913 'field_prefix' => get_site_url() . '/', // Custom argument
914 'field_suffix' => '/ for:', // Custom argument
915 'field_description' => '', // Custom argument
916 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
917 )
918 );
919
920 $field_id = 'redirect_after_logout_for';
921 $field_slug = 'redirect-after-logout-for';
922
923 if ( is_array( $roles ) ) {
924 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
925
926 add_settings_field(
927 $field_id . '_' . $role_slug, // Field ID
928 '', // Field title
929 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
930 ASENHA_SLUG, // Settings page slug
931 'main-section', // Section ID
932 array(
933 'parent_field_id' => $field_id, // Custom argument
934 'field_id' => $role_slug, // Custom argument
935 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
936 'field_label' => $role_label, // Custom argument
937 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
938 )
939 );
940
941 }
942 }
943
944 // =================================================================
945 // CUSTOM CODE
946 // =================================================================
947
948 // Enable Custom Admin CSS
949
950 $field_id = 'enable_custom_admin_css';
951 $field_slug = 'enable-custom-admin-css';
952
953 add_settings_field(
954 $field_id, // Field ID
955 'Custom Admin CSS', // Field title
956 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
957 ASENHA_SLUG, // Settings page slug
958 'main-section', // Section ID
959 array(
960 'field_id' => $field_id, // Custom argument
961 'field_slug' => $field_slug, // Custom argument
962 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
963 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
964 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
965 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
966 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
967 )
968 );
969
970 $field_id = 'custom_admin_css';
971 $field_slug = 'custom-admin-css';
972
973 add_settings_field(
974 $field_id, // Field ID
975 '', // Field title
976 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
977 ASENHA_SLUG, // Settings page slug
978 'main-section', // Section ID
979 array(
980 'field_id' => $field_id, // Custom argument
981 'field_slug' => $field_slug, // Custom argument
982 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
983 'field_type' => 'textarea', // Custom argument
984 'field_rows' => 30,
985 'field_intro' => '', // Custom argument
986 'field_description' => '', // Custom argument
987 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
988 )
989 );
990
991 // Enable Custom Frontend CSS
992
993 $field_id = 'enable_custom_frontend_css';
994 $field_slug = 'enable-custom-frontend-css';
995
996 add_settings_field(
997 $field_id, // Field ID
998 'Custom Frontend CSS', // Field title
999 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1000 ASENHA_SLUG, // Settings page slug
1001 'main-section', // Section ID
1002 array(
1003 'field_id' => $field_id, // Custom argument
1004 'field_slug' => $field_slug, // Custom argument
1005 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1006 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
1007 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1008 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1009 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1010 )
1011 );
1012
1013 $field_id = 'custom_frontend_css';
1014 $field_slug = 'custom-frontend-css';
1015
1016 add_settings_field(
1017 $field_id, // Field ID
1018 '', // Field title
1019 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1020 ASENHA_SLUG, // Settings page slug
1021 'main-section', // Section ID
1022 array(
1023 'field_id' => $field_id, // Custom argument
1024 'field_slug' => $field_slug, // Custom argument
1025 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1026 'field_type' => 'textarea', // Custom argument
1027 'field_rows' => 30,
1028 'field_intro' => '', // Custom argument
1029 'field_description' => '', // Custom argument
1030 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1031 )
1032 );
1033
1034 // Custom Body Class
1035
1036 $field_id = 'enable_custom_body_class';
1037 $field_slug = 'enable-custom-body-class';
1038
1039 add_settings_field(
1040 $field_id, // Field ID
1041 'Custom Body Class', // Field title
1042 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1043 ASENHA_SLUG, // Settings page slug
1044 'main-section', // Section ID
1045 array(
1046 'field_id' => $field_id, // Custom argument
1047 'field_slug' => $field_slug, // Custom argument
1048 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1049 '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>.', // Custom argument
1050 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1051 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1052 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1053 )
1054 );
1055
1056 $field_id = 'enable_custom_body_class_for';
1057 $field_slug = 'enable-custom-body-class-for';
1058
1059 if ( is_array( $asenha_public_post_types ) ) {
1060 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1061 if ( 'attachment' != $post_type_slug ) {
1062 add_settings_field(
1063 $field_id . '_' . $post_type_slug, // Field ID
1064 '', // Field title
1065 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1066 ASENHA_SLUG, // Settings page slug
1067 'main-section', // Section ID
1068 array(
1069 'parent_field_id' => $field_id, // Custom argument
1070 'field_id' => $post_type_slug, // Custom argument
1071 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1072 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1073 'class' => 'asenha-checkbox asenha-hide-th asenha-half custom-code ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1074 )
1075 );
1076 }
1077 }
1078 }
1079
1080 // Manage ads.txt and app-ads.txt
1081
1082 $field_id = 'manage_ads_appads_txt';
1083 $field_slug = 'manage-ads-appads-txt';
1084
1085 add_settings_field(
1086 $field_id, // Field ID
1087 'Manage ads.txt and app-ads.txt', // Field title
1088 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1089 ASENHA_SLUG, // Settings page slug
1090 'main-section', // Section ID
1091 array(
1092 'field_id' => $field_id, // Custom argument
1093 'field_slug' => $field_slug, // Custom argument
1094 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1095 '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.', // Custom argument
1096 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1097 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1098 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1099 )
1100 );
1101
1102 $field_id = 'ads_txt_content';
1103 $field_slug = 'ads-txt-content';
1104
1105 add_settings_field(
1106 $field_id, // Field ID
1107 '', // Field title
1108 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1109 ASENHA_SLUG, // Settings page slug
1110 'main-section', // Section ID
1111 array(
1112 'field_id' => $field_id, // Custom argument
1113 'field_slug' => $field_slug, // Custom argument
1114 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1115 'field_type' => 'textarea', // Custom argument
1116 'field_rows' => 15,
1117 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
1118 'field_description' => 'Validate with: <a href="https://adstxt.guru/validator/url/?url=' . urlencode( get_site_url( null, 'ads.txt' ) ) . '" target="_blank">adstxt.guru</a> | <a href="https://www.adstxtvalidator.com/ads_txt/' . esc_attr( str_replace( '.', '-', $_SERVER['SERVER_NAME'] ) ) . '" target="_blank">adstxtvalidator.com</a><div class="vspacer"></div>', // Custom argument
1119 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1120 )
1121 );
1122
1123 $field_id = 'app_ads_txt_content';
1124 $field_slug = 'app-ads-txt-content';
1125
1126 add_settings_field(
1127 $field_id, // Field ID
1128 '', // Field title
1129 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1130 ASENHA_SLUG, // Settings page slug
1131 'main-section', // Section ID
1132 array(
1133 'field_id' => $field_id, // Custom argument
1134 'field_slug' => $field_slug, // Custom argument
1135 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1136 'field_type' => 'textarea', // Custom argument
1137 'field_rows' => 15,
1138 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
1139 'field_description' => 'Validate with: <a href="https://adstxt.guru/validator/url/?url=' . urlencode( get_site_url( null, 'app-ads.txt' ) ) . '" target="_blank">adstxt.guru</a>', // Custom argument
1140 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1141 )
1142 );
1143
1144 // Manage robots.txt
1145
1146 $field_id = 'manage_robots_txt';
1147 $field_slug = 'manage-robots-txt';
1148
1149 add_settings_field(
1150 $field_id, // Field ID
1151 'Manage robots.txt', // Field title
1152 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1153 ASENHA_SLUG, // Settings page slug
1154 'main-section', // Section ID
1155 array(
1156 'field_id' => $field_id, // Custom argument
1157 'field_slug' => $field_slug, // Custom argument
1158 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1159 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument
1160 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1161 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1162 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1163 )
1164 );
1165
1166 $field_id = 'robots_txt_content';
1167 $field_slug = 'robots-txt-content';
1168
1169 add_settings_field(
1170 $field_id, // Field ID
1171 '', // Field title
1172 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1173 ASENHA_SLUG, // Settings page slug
1174 'main-section', // Section ID
1175 array(
1176 'field_id' => $field_id, // Custom argument
1177 'field_slug' => $field_slug, // Custom argument
1178 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1179 'field_type' => 'textarea', // Custom argument
1180 'field_rows' => 20,
1181 'field_intro' => '', // Custom argument
1182 'field_description' => 'Validate with: <a href="https://en.ryte.com/free-tools/robots-txt/?refresh=1&url=' . urlencode( get_site_url( null, 'robots.txt' ) ) . '&useragent=Googlebot&submit=Evaluate" target="_blank">ryte.com</a> | <a href="https://serp.tools/tools/robots-txt" target="_blank">serp.tools</a><div class="vspacer"></div>', // Custom argument
1183 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1184 )
1185 );
1186
1187 // Insert <head>, <body> and <footer> code
1188
1189 $field_id = 'insert_head_body_footer_code';
1190 $field_slug = 'insert-head-body-footer-code';
1191
1192 add_settings_field(
1193 $field_id, // Field ID
1194 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
1195 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1196 ASENHA_SLUG, // Settings page slug
1197 'main-section', // Section ID
1198 array(
1199 'field_id' => $field_id, // Custom argument
1200 'field_slug' => $field_slug, // Custom argument
1201 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1202 '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.', // Custom argument
1203 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1204 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1205 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1206 )
1207 );
1208
1209 $field_id = 'head_code_priority';
1210 $field_slug = 'head-code-priority';
1211
1212 add_settings_field(
1213 $field_id, // Field ID
1214 '', // Field title
1215 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1216 ASENHA_SLUG, // Settings page slug
1217 'main-section', // Section ID
1218 array(
1219 'field_id' => $field_id, // Custom argument
1220 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1221 'field_type' => 'with-prefix-suffix', // Custom argument
1222 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1223 'field_suffix' => '', // Custom argument
1224 'field_intro' => '', // Custom argument
1225 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1226 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1227 )
1228 );
1229
1230 $field_id = 'head_code';
1231 $field_slug = 'head-code';
1232
1233 add_settings_field(
1234 $field_id, // Field ID
1235 '', // Field title
1236 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1237 ASENHA_SLUG, // Settings page slug
1238 'main-section', // Section ID
1239 array(
1240 'field_id' => $field_id, // Custom argument
1241 'field_slug' => $field_slug, // Custom argument
1242 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1243 'field_type' => 'textarea', // Custom argument
1244 'field_rows' => 15,
1245 'field_intro' => '', // Custom argument
1246 'field_description' => '', // Custom argument
1247 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1248 )
1249 );
1250
1251 $field_id = 'body_code_priority';
1252 $field_slug = 'body-code-priority';
1253
1254 add_settings_field(
1255 $field_id, // Field ID
1256 '', // Field title
1257 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1258 ASENHA_SLUG, // Settings page slug
1259 'main-section', // Section ID
1260 array(
1261 'field_id' => $field_id, // Custom argument
1262 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1263 'field_type' => 'with-prefix-suffix', // Custom argument
1264 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1265 'field_suffix' => '', // Custom argument
1266 'field_intro' => '', // Custom argument
1267 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1268 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1269 )
1270 );
1271
1272 $field_id = 'body_code';
1273 $field_slug = 'body-code';
1274
1275 add_settings_field(
1276 $field_id, // Field ID
1277 '', // Field title
1278 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1279 ASENHA_SLUG, // Settings page slug
1280 'main-section', // Section ID
1281 array(
1282 'field_id' => $field_id, // Custom argument
1283 'field_slug' => $field_slug, // Custom argument
1284 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1285 'field_type' => 'textarea', // Custom argument
1286 'field_rows' => 15,
1287 'field_intro' => '', // Custom argument
1288 'field_description' => '', // Custom argument
1289 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1290 )
1291 );
1292
1293 $field_id = 'footer_code_priority';
1294 $field_slug = 'footer-code-priority';
1295
1296 add_settings_field(
1297 $field_id, // Field ID
1298 '', // Field title
1299 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1300 ASENHA_SLUG, // Settings page slug
1301 'main-section', // Section ID
1302 array(
1303 'field_id' => $field_id, // Custom argument
1304 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1305 'field_type' => 'with-prefix-suffix', // Custom argument
1306 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1307 'field_suffix' => '', // Custom argument
1308 'field_intro' => '', // Custom argument
1309 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1310 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1311 )
1312 );
1313
1314 $field_id = 'footer_code';
1315 $field_slug = 'footer-code';
1316
1317 add_settings_field(
1318 $field_id, // Field ID
1319 '', // Field title
1320 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1321 ASENHA_SLUG, // Settings page slug
1322 'main-section', // Section ID
1323 array(
1324 'field_id' => $field_id, // Custom argument
1325 'field_slug' => $field_slug, // Custom argument
1326 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1327 'field_type' => 'textarea', // Custom argument
1328 'field_rows' => 15,
1329 'field_intro' => '', // Custom argument
1330 'field_description' => '', // Custom argument
1331 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1332 )
1333 );
1334
1335 // =================================================================
1336 // DISABLE COMPONENTS
1337 // =================================================================
1338
1339 // Disable Gutenberg
1340
1341 $field_id = 'disable_gutenberg';
1342 $field_slug = 'disable-gutenberg';
1343
1344 add_settings_field(
1345 $field_id, // Field ID
1346 'Disable Gutenberg', // Field title
1347 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1348 ASENHA_SLUG, // Settings page slug
1349 'main-section', // Section ID
1350 array(
1351 'field_id' => $field_id, // Custom argument
1352 'field_slug' => $field_slug, // Custom argument
1353 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1354 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
1355 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1356 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1357 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1358 )
1359 );
1360
1361 $field_id = 'disable_gutenberg_for';
1362 $field_slug = 'disable-gutenberg-for';
1363
1364 if ( is_array( $asenha_gutenberg_post_types ) ) {
1365 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1366 add_settings_field(
1367 $field_id . '_' . $post_type_slug, // Field ID
1368 '', // Field title
1369 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1370 ASENHA_SLUG, // Settings page slug
1371 'main-section', // Section ID
1372 array(
1373 'parent_field_id' => $field_id, // Custom argument
1374 'field_id' => $post_type_slug, // Custom argument
1375 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1376 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1377 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1378 )
1379 );
1380 }
1381 }
1382
1383 $field_id = 'disable_gutenberg_frontend_styles';
1384 $field_slug = 'disable-gutenberg-frontend-styles';
1385
1386 add_settings_field(
1387 $field_id, // Field ID
1388 '', // Field title
1389 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1390 ASENHA_SLUG, // Settings page slug
1391 'main-section', // Section ID
1392 array(
1393 'field_id' => $field_id, // Custom argument
1394 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1395 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
1396 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
1397 )
1398 );
1399
1400 // Disable Comments
1401
1402 $field_id = 'disable_comments';
1403 $field_slug = 'disable-comments';
1404
1405 add_settings_field(
1406 $field_id, // Field ID
1407 'Disable Comments', // Field title
1408 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1409 ASENHA_SLUG, // Settings page slug
1410 'main-section', // Section ID
1411 array(
1412 'field_id' => $field_id, // Custom argument
1413 'field_slug' => $field_slug, // Custom argument
1414 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1415 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
1416 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1417 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1418 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1419 )
1420 );
1421
1422 $field_id = 'disable_comments_for';
1423 $field_slug = 'disable-comments-for';
1424
1425 if ( is_array( $asenha_public_post_types ) ) {
1426 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1427 add_settings_field(
1428 $field_id . '_' . $post_type_slug, // Field ID
1429 '', // Field title
1430 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1431 ASENHA_SLUG, // Settings page slug
1432 'main-section', // Section ID
1433 array(
1434 'parent_field_id' => $field_id, // Custom argument
1435 'field_id' => $post_type_slug, // Custom argument
1436 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1437 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1438 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1439 )
1440 );
1441 }
1442 }
1443
1444 // Disable REST API
1445
1446 $field_id = 'disable_rest_api';
1447 $field_slug = 'disable-rest-api';
1448
1449 add_settings_field(
1450 $field_id, // Field ID
1451 'Disable REST API', // Field title
1452 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1453 ASENHA_SLUG, // Settings page slug
1454 'main-section', // Section ID
1455 array(
1456 'field_id' => $field_id, // Custom argument
1457 'field_slug' => $field_slug, // Custom argument
1458 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1459 'field_description' => 'Disable REST API access for non-authenticated users and remove URL traces from &lt;head&gt;, HTTP headers and WP RSD endpoint.', // Custom argument
1460 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1461 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1462 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1463 )
1464 );
1465
1466 // Disable Feeds
1467
1468 $field_id = 'disable_feeds';
1469 $field_slug = 'disable-feeds';
1470
1471 add_settings_field(
1472 $field_id, // Field ID
1473 'Disable Feeds', // Field title
1474 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1475 ASENHA_SLUG, // Settings page slug
1476 'main-section', // Section ID
1477 array(
1478 'field_id' => $field_id, // Custom argument
1479 'field_slug' => $field_slug, // Custom argument
1480 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1481 '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;.', // Custom argument
1482 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1483 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1484 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1485 )
1486 );
1487
1488 // Disable Auto Updates
1489
1490 $field_id = 'disable_all_updates';
1491 $field_slug = 'disable-all-updates';
1492
1493 add_settings_field(
1494 $field_id, // Field ID
1495 'Disable All Updates', // Field title
1496 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1497 ASENHA_SLUG, // Settings page slug
1498 'main-section', // Section ID
1499 array(
1500 'field_id' => $field_id, // Custom argument
1501 'field_slug' => $field_slug, // Custom argument
1502 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1503 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', // Custom argument
1504 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1505 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1506 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1507 )
1508 );
1509
1510 // Disable Smaller Components
1511
1512 $field_id = 'disable_smaller_components';
1513 $field_slug = 'disable-smaller-components';
1514
1515 add_settings_field(
1516 $field_id, // Field ID
1517 'Disable Smaller Components', // Field title
1518 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1519 ASENHA_SLUG, // Settings page slug
1520 'main-section', // Section ID
1521 array(
1522 'field_id' => $field_id, // Custom argument
1523 'field_slug' => $field_slug, // Custom argument
1524 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1525 '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.', // Custom argument
1526 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1527 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1528 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
1529 )
1530 );
1531
1532 $field_id = 'disable_head_generator_tag';
1533 $field_slug = 'disable-head-generator-tag';
1534
1535 add_settings_field(
1536 $field_id, // Field ID
1537 '', // Field title
1538 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1539 ASENHA_SLUG, // Settings page slug
1540 'main-section', // Section ID
1541 array(
1542 'field_id' => $field_id, // Custom argument
1543 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1544 '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).', // Custom argument
1545 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1546 )
1547 );
1548
1549 $field_id = 'disable_head_wlwmanifest_tag';
1550 $field_slug = 'disable-head-wlwmanifest-tag';
1551
1552 add_settings_field(
1553 $field_id, // Field ID
1554 '', // Field title
1555 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1556 ASENHA_SLUG, // Settings page slug
1557 'main-section', // Section ID
1558 array(
1559 'field_id' => $field_id, // Custom argument
1560 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1561 '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.', // Custom argument
1562 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1563 )
1564 );
1565
1566 $field_id = 'disable_head_rsd_tag';
1567 $field_slug = 'disable-head-rsd-tag';
1568
1569 add_settings_field(
1570 $field_id, // Field ID
1571 '', // Field title
1572 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1573 ASENHA_SLUG, // Settings page slug
1574 'main-section', // Section ID
1575 array(
1576 'field_id' => $field_id, // Custom argument
1577 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1578 '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.', // Custom argument
1579 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1580 )
1581 );
1582
1583 $field_id = 'disable_head_shortlink_tag';
1584 $field_slug = 'disable-head-shortlink-tag';
1585
1586 add_settings_field(
1587 $field_id, // Field ID
1588 '', // Field title
1589 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1590 ASENHA_SLUG, // Settings page slug
1591 'main-section', // Section ID
1592 array(
1593 'field_id' => $field_id, // Custom argument
1594 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1595 '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.', // Custom argument
1596 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1597 )
1598 );
1599
1600 $field_id = 'disable_frontend_dashicons';
1601 $field_slug = 'disable-frontend-dashicons';
1602
1603 add_settings_field(
1604 $field_id, // Field ID
1605 '', // Field title
1606 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1607 ASENHA_SLUG, // Settings page slug
1608 'main-section', // Section ID
1609 array(
1610 'field_id' => $field_id, // Custom argument
1611 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1612 'field_label' => 'Disable loading of <strong>dashicons CSS and JS files</strong> on the front-end for public site visitors.', // Custom argument
1613 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1614 )
1615 );
1616
1617 $field_id = 'disable_emoji_support';
1618 $field_slug = 'disable-emoji-support';
1619
1620 add_settings_field(
1621 $field_id, // Field ID
1622 '', // Field title
1623 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1624 ASENHA_SLUG, // Settings page slug
1625 'main-section', // Section ID
1626 array(
1627 'field_id' => $field_id, // Custom argument
1628 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1629 '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.', // Custom argument
1630 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
1631 )
1632 );
1633
1634 // =================================================================
1635 // SECURITY
1636 // =================================================================
1637
1638 // Limit Login Attempts
1639
1640 $field_id = 'limit_login_attempts';
1641 $field_slug = 'limit-login-attempts';
1642
1643 add_settings_field(
1644 $field_id, // Field ID
1645 'Limit Login Attempts', // Field title
1646 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1647 ASENHA_SLUG, // Settings page slug
1648 'main-section', // Section ID
1649 array(
1650 'field_id' => $field_id, // Custom argument
1651 'field_slug' => $field_slug, // Custom argument
1652 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1653 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
1654 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1655 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1656 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1657 )
1658 );
1659
1660 $field_id = 'login_fails_allowed';
1661 $field_slug = 'login-fails-allowed';
1662
1663 add_settings_field(
1664 $field_id, // Field ID
1665 '', // Field title
1666 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1667 ASENHA_SLUG, // Settings page slug
1668 'main-section', // Section ID
1669 array(
1670 'field_id' => $field_id, // Custom argument
1671 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1672 'field_type' => 'with-prefix-suffix', // Custom argument
1673 'field_prefix' => '', // Custom argument
1674 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
1675 'field_description' => '', // Custom argument
1676 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1677 )
1678 );
1679
1680 $field_id = 'login_lockout_maxcount';
1681 $field_slug = 'login-lockout-maxcount';
1682
1683 add_settings_field(
1684 $field_id, // Field ID
1685 '', // Field title
1686 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1687 ASENHA_SLUG, // Settings page slug
1688 'main-section', // Section ID
1689 array(
1690 'field_id' => $field_id, // Custom argument
1691 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1692 'field_type' => 'with-prefix-suffix', // Custom argument
1693 'field_prefix' => '', // Custom argument
1694 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
1695 'field_description' => '', // Custom argument
1696 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1697 )
1698 );
1699
1700 $field_id = 'login_attempts_log_table';
1701 $field_slug = 'login-attempts-log-table';
1702
1703 add_settings_field(
1704 $field_id, // Field ID
1705 '', // Field title
1706 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
1707 ASENHA_SLUG, // Settings page slug
1708 'main-section', // Section ID
1709 array(
1710 'field_id' => $field_id, // Custom argument
1711 'field_slug' => $field_slug, // Custom argument
1712 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1713 'field_type' => 'datatable', // Custom argument
1714 'field_description' => '', // Custom argument
1715 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
1716 'table_title' => 'Failed Login Attempts Log',
1717 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
1718 )
1719 );
1720
1721 // Obfuscate Author Slugs
1722
1723 $field_id = 'obfuscate_author_slugs';
1724 $field_slug = 'obfuscate-author-slugs';
1725
1726 add_settings_field(
1727 $field_id, // Field ID
1728 'Obfuscate Author Slugs', // Field title
1729 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1730 ASENHA_SLUG, // Settings page slug
1731 'main-section', // Section ID
1732 array(
1733 'field_id' => $field_id, // Custom argument
1734 'field_slug' => $field_slug, // Custom argument
1735 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1736 '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.', // Custom argument
1737 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1738 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1739 )
1740 );
1741
1742 // Disable XML-RPC
1743
1744 $field_id = 'disable_xmlrpc';
1745 $field_slug = 'disable-xmlrpc';
1746
1747 add_settings_field(
1748 $field_id, // Field ID
1749 'Disable XML-RPC', // Field title
1750 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1751 ASENHA_SLUG, // Settings page slug
1752 'main-section', // Section ID
1753 array(
1754 'field_id' => $field_id, // Custom argument
1755 'field_slug' => $field_slug, // Custom argument
1756 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1757 '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. ', // Custom argument
1758 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1759 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1760 )
1761 );
1762
1763 // =================================================================
1764 // OPTIMIZATIONS
1765 // =================================================================
1766
1767 // Image Upload Control
1768
1769 $field_id = 'image_upload_control';
1770 $field_slug = 'image-upload-control';
1771
1772 add_settings_field(
1773 $field_id, // Field ID
1774 'Image Upload Control', // Field title
1775 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1776 ASENHA_SLUG, // Settings page slug
1777 'main-section', // Section ID
1778 array(
1779 'field_id' => $field_id, // Custom argument
1780 'field_slug' => $field_slug, // Custom argument
1781 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1782 '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.', // Custom argument
1783 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1784 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1785 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1786 )
1787 );
1788
1789 $field_id = 'image_max_width';
1790 $field_slug = 'image-max-width';
1791
1792 add_settings_field(
1793 $field_id, // Field ID
1794 '', // Field title
1795 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1796 ASENHA_SLUG, // Settings page slug
1797 'main-section', // Section ID
1798 array(
1799 'field_id' => $field_id, // Custom argument
1800 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1801 'field_type' => 'with-prefix-suffix', // Custom argument
1802 'field_prefix' => 'Max width:', // Custom argument
1803 'field_suffix' => 'pixels. <span class="faded">(Default is 1920 pixels)</span>', // Custom argument
1804 'field_intro' => '', // Custom argument
1805 'field_description' => '', // Custom argument
1806 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1807 )
1808 );
1809
1810 $field_id = 'image_max_height';
1811 $field_slug = 'image-max-height';
1812
1813 add_settings_field(
1814 $field_id, // Field ID
1815 '', // Field title
1816 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1817 ASENHA_SLUG, // Settings page slug
1818 'main-section', // Section ID
1819 array(
1820 'field_id' => $field_id, // Custom argument
1821 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1822 'field_type' => 'with-prefix-suffix', // Custom argument
1823 'field_prefix' => 'Max height:', // Custom argument
1824 'field_suffix' => 'pixels <span class="faded">(Default is 1920 pixels)</span>', // Custom argument
1825 'field_intro' => '', // Custom argument
1826 'field_description' => 'To exclude an image from conversion and resizing, append \'-nr\' suffix to the file name, e.g. bird-photo-4k-nr.jpg', // Custom argument
1827 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1828 )
1829 );
1830
1831 // Enable Revisions Control
1832
1833 $field_id = 'enable_revisions_control';
1834 $field_slug = 'enable-revisions-control';
1835
1836 add_settings_field(
1837 $field_id, // Field ID
1838 'Revisions Control', // Field title
1839 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1840 ASENHA_SLUG, // Settings page slug
1841 'main-section', // Section ID
1842 array(
1843 'field_id' => $field_id, // Custom argument
1844 'field_slug' => $field_slug, // Custom argument
1845 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1846 'field_description' => 'Prevent bloating the database by limiting the number of revisions to keep for some or all post types supporting revisions.', // Custom argument
1847 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1848 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1849 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1850 )
1851 );
1852
1853 $field_id = 'revisions_max_number';
1854 $field_slug = 'revisions-max-number';
1855
1856 add_settings_field(
1857 $field_id, // Field ID
1858 '', // Field title
1859 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1860 ASENHA_SLUG, // Settings page slug
1861 'main-section', // Section ID
1862 array(
1863 'field_id' => $field_id, // Custom argument
1864 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1865 'field_type' => 'with-prefix-suffix', // Custom argument
1866 'field_prefix' => 'Limit to', // Custom argument
1867 'field_suffix' => 'revisions for:', // Custom argument
1868 'field_intro' => '', // Custom argument
1869 'field_description' => '', // Custom argument
1870 'class' => 'asenha-number asenha-hide-th extra-narrow optimizations ' . $field_slug, // Custom class for the <tr> element
1871 )
1872 );
1873
1874 $field_id = 'enable_revisions_control_for';
1875 $field_slug = 'enable-revisions-control-for';
1876
1877 if ( is_array( $asenha_revisions_post_types ) ) {
1878 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1879 add_settings_field(
1880 $field_id . '_' . $post_type_slug, // Field ID
1881 '', // Field title
1882 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1883 ASENHA_SLUG, // Settings page slug
1884 'main-section', // Section ID
1885 array(
1886 'parent_field_id' => $field_id, // Custom argument
1887 'field_id' => $post_type_slug, // Custom argument
1888 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1889 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1890 'class' => 'asenha-checkbox asenha-hide-th asenha-half optimizations ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1891 )
1892 );
1893 }
1894 }
1895
1896 // Enable Heartbeat Control
1897
1898 $field_id = 'enable_heartbeat_control';
1899 $field_slug = 'enable-heartbeat-control';
1900
1901 add_settings_field(
1902 $field_id, // Field ID
1903 'Heartbeat Control', // Field title
1904 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1905 ASENHA_SLUG, // Settings page slug
1906 'main-section', // Section ID
1907 array(
1908 'field_id' => $field_id, // Custom argument
1909 'field_slug' => $field_slug, // Custom argument
1910 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1911 '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.', // Custom argument
1912 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1913 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1914 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element
1915 )
1916 );
1917
1918 $field_id = 'heartbeat_control_for_admin_pages';
1919 $field_slug = 'heartbeat-control-for-admin-pages';
1920
1921 add_settings_field(
1922 $field_id, // Field ID
1923 'On admin pages', // Field title
1924 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1925 ASENHA_SLUG, // Settings page slug
1926 'main-section', // Section ID
1927 array(
1928 'field_id' => $field_id, // Custom argument
1929 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1930 // 'field_label' => 'Temporary label', // Custom argument
1931 'field_radios' => array(
1932 'Keep as is' => 'default',
1933 'Modify' => 'modify',
1934 'Disable' => 'disable',
1935 ),
1936 'field_default' => 'default',
1937 'class' => 'asenha-radio-buttons optimizations ' . $field_slug, // Custom class for the <tr> element
1938 ),
1939 );
1940
1941 $field_id = 'heartbeat_interval_for_admin_pages';
1942 $field_slug = 'heartbeat-interval-for-admin-pages';
1943
1944 add_settings_field(
1945 $field_id, // Field ID
1946 '', // Field title
1947 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1948 ASENHA_SLUG, // Settings page slug
1949 'main-section', // Section ID
1950 array(
1951 'field_id' => $field_id, // Custom argument
1952 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1953 'field_type' => 'with-prefix-suffix', // Custom argument
1954 'field_prefix' => 'Set interval to once every', // Custom argument
1955 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>', // Custom argument
1956 'field_select_options' => array(
1957 '15 seconds' => 15,
1958 '30 seconds' => 30,
1959 '1 minute' => 60,
1960 '2 minutes' => 120,
1961 '3 minutes' => 180,
1962 '5 minutes' => 300,
1963 '10 minutes' => 600,
1964 ),
1965 'field_select_default' => 60,
1966 'field_intro' => '', // Custom argument
1967 'field_description' => '', // Custom argument
1968 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1969 'display_none_on_load' => true,
1970 )
1971 );
1972
1973 $field_id = 'heartbeat_control_for_post_edit';
1974 $field_slug = 'heartbeat-control-for-post-edit';
1975
1976 add_settings_field(
1977 $field_id, // Field ID
1978 'On post creation and edit screens', // Field title
1979 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1980 ASENHA_SLUG, // Settings page slug
1981 'main-section', // Section ID
1982 array(
1983 'field_id' => $field_id, // Custom argument
1984 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1985 // 'field_label' => 'Temporary label', // Custom argument
1986 'field_radios' => array(
1987 'Keep as is' => 'default',
1988 'Modify' => 'modify',
1989 'Disable' => 'disable',
1990 ),
1991 'field_default' => 'default',
1992 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1993 ),
1994 );
1995
1996 $field_id = 'heartbeat_interval_for_post_edit';
1997 $field_slug = 'heartbeat-interval-for-post-edit';
1998
1999 add_settings_field(
2000 $field_id, // Field ID
2001 '', // Field title
2002 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
2003 ASENHA_SLUG, // Settings page slug
2004 'main-section', // Section ID
2005 array(
2006 'field_id' => $field_id, // Custom argument
2007 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2008 'field_type' => 'with-prefix-suffix', // Custom argument
2009 'field_prefix' => 'Set interval to once every', // Custom argument
2010 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>', // Custom argument
2011 'field_select_options' => array(
2012 '15 seconds' => 15,
2013 '30 seconds' => 30,
2014 '45 seconds' => 45,
2015 '60 seconds' => 60,
2016 '90 seconds' => 90,
2017 '120 seconds' => 120
2018 ),
2019 'field_select_default' => 15,
2020 'field_intro' => '', // Custom argument
2021 'field_description' => '', // Custom argument
2022 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
2023 'display_none_on_load' => true,
2024 )
2025 );
2026
2027 $field_id = 'heartbeat_control_for_frontend';
2028 $field_slug = 'heartbeat-control-for-frontend';
2029
2030 add_settings_field(
2031 $field_id, // Field ID
2032 'On the frontend', // Field title
2033 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2034 ASENHA_SLUG, // Settings page slug
2035 'main-section', // Section ID
2036 array(
2037 'field_id' => $field_id, // Custom argument
2038 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2039 // 'field_label' => 'Temporary label', // Custom argument
2040 'field_radios' => array(
2041 'Keep as is' => 'default',
2042 'Modify' => 'modify',
2043 'Disable' => 'disable',
2044 ),
2045 'field_default' => 'default',
2046 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
2047 ),
2048 );
2049
2050 $field_id = 'heartbeat_interval_for_frontend';
2051 $field_slug = 'heartbeat-interval-for-frontend';
2052
2053 add_settings_field(
2054 $field_id, // Field ID
2055 '', // Field title
2056 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
2057 ASENHA_SLUG, // Settings page slug
2058 'main-section', // Section ID
2059 array(
2060 'field_id' => $field_id, // Custom argument
2061 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2062 'field_type' => 'with-prefix-suffix', // Custom argument
2063 'field_prefix' => 'Set interval to once every', // Custom argument
2064 'field_suffix' => '', // Custom argument
2065 'field_select_options' => array(
2066 '15 seconds' => 15,
2067 '30 seconds' => 30,
2068 '1 minute' => 60,
2069 '2 minutes' => 120,
2070 '3 minutes' => 180,
2071 '5 minutes' => 300,
2072 '10 minutes' => 600,
2073 ),
2074 'field_select_default' => 60,
2075 'field_intro' => '', // Custom argument
2076 'field_description' => '', // Custom argument
2077 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
2078 'display_none_on_load' => true,
2079 )
2080 );
2081
2082 // =================================================================
2083 // UTILITIES
2084 // =================================================================
2085
2086 // SMTP Email Delivery
2087
2088 $field_id = 'smtp_email_delivery';
2089 $field_slug = 'smtp-email-delivery';
2090
2091 add_settings_field(
2092 $field_id, // Field ID
2093 'SMTP Email Delivery', // Field title
2094 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2095 ASENHA_SLUG, // Settings page slug
2096 'main-section', // Section ID
2097 array(
2098 'field_id' => $field_id, // Custom argument
2099 'field_slug' => $field_slug, // Custom argument
2100 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2101 'field_description' => 'Use external SMTP service to ensure notification and transactional emails from your site are being delivered to inboxes.', // Custom argument
2102 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2103 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
2104 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2105 )
2106 );
2107
2108 $field_id = 'smtp_host';
2109 $field_slug = 'smtp-host';
2110
2111 add_settings_field(
2112 $field_id, // Field ID
2113 '<span class="field-sublabel sublabel-wide">Host</span>', // Field title
2114 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2115 ASENHA_SLUG, // Settings page slug
2116 'main-section', // Section ID
2117 array(
2118 'field_id' => $field_id, // Custom argument
2119 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2120 'field_type' => '', // Custom argument
2121 'field_prefix' => '', // Custom argument
2122 'field_suffix' => '', // Custom argument
2123 'field_description' => '', // Custom argument
2124 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2125 )
2126 );
2127
2128 $field_id = 'smtp_port';
2129 $field_slug = 'smtp-port';
2130
2131 add_settings_field(
2132 $field_id, // Field ID
2133 '<span class="field-sublabel sublabel-wide">Port</span>', // Field title
2134 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
2135 ASENHA_SLUG, // Settings page slug
2136 'main-section', // Section ID
2137 array(
2138 'field_id' => $field_id, // Custom argument
2139 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2140 'field_type' => '', // Custom argument
2141 'field_prefix' => '', // Custom argument
2142 'field_suffix' => '', // Custom argument
2143 'field_intro' => '', // Custom argument
2144 'field_description' => '', // Custom argument
2145 'class' => 'asenha-text with-prefix-suffix narrow utilities ' . $field_slug, // Custom class for the <tr> element
2146 )
2147 );
2148
2149 $field_id = 'smtp_security';
2150 $field_slug = 'smtp-security';
2151
2152 add_settings_field(
2153 $field_id, // Field ID
2154 '<span class="field-sublabel sublabel-wide">Security</span>', // Field title
2155 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2156 ASENHA_SLUG, // Settings page slug
2157 'main-section', // Section ID
2158 array(
2159 'field_id' => $field_id, // Custom argument
2160 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2161 // 'field_label' => 'Temporary label', // Custom argument
2162 'field_radios' => array(
2163 'None' => 'none',
2164 'SSL' => 'ssl',
2165 'TLS' => 'tls',
2166 ),
2167 'field_default' => 'default',
2168 'class' => 'asenha-radio-buttons with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
2169 ),
2170 );
2171
2172 $field_id = 'smtp_username';
2173 $field_slug = 'smtp-username';
2174
2175 add_settings_field(
2176 $field_id, // Field ID
2177 '<span class="field-sublabel sublabel-wide">Username</span>', // Field title
2178 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2179 ASENHA_SLUG, // Settings page slug
2180 'main-section', // Section ID
2181 array(
2182 'field_id' => $field_id, // Custom argument
2183 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2184 'field_type' => '', // Custom argument
2185 'field_prefix' => '', // Custom argument
2186 'field_suffix' => '', // Custom argument
2187 'field_description' => '', // Custom argument
2188 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2189 )
2190 );
2191
2192 $field_id = 'smtp_password';
2193 $field_slug = 'smtp-password';
2194
2195 add_settings_field(
2196 $field_id, // Field ID
2197 '<span class="field-sublabel sublabel-wide">Password</span>', // Field title
2198 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
2199 ASENHA_SLUG, // Settings page slug
2200 'main-section', // Section ID
2201 array(
2202 'field_id' => $field_id, // Custom argument
2203 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2204 'field_type' => '', // Custom argument
2205 'field_prefix' => '', // Custom argument
2206 'field_suffix' => '', // Custom argument
2207 'field_description' => '', // Custom argument
2208 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2209 )
2210 );
2211
2212 $field_id = 'smtp_default_from_name';
2213 $field_slug = 'smtp-default-from-name';
2214
2215 add_settings_field(
2216 $field_id, // Field ID
2217 '<span class="field-sublabel sublabel-wide">FROM name</span>', // Field title
2218 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2219 ASENHA_SLUG, // Settings page slug
2220 'main-section', // Section ID
2221 array(
2222 'field_id' => $field_id, // Custom argument
2223 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2224 'field_type' => '', // Custom argument
2225 'field_prefix' => '', // Custom argument
2226 'field_suffix' => '', // Custom argument
2227 'field_description' => '', // Custom argument
2228 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2229 )
2230 );
2231
2232 $field_id = 'smtp_default_from_email';
2233 $field_slug = 'smtp-default-from-email';
2234
2235 add_settings_field(
2236 $field_id, // Field ID
2237 '<span class="field-sublabel sublabel-wide">FROM email</span>', // Field title
2238 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2239 ASENHA_SLUG, // Settings page slug
2240 'main-section', // Section ID
2241 array(
2242 'field_id' => $field_id, // Custom argument
2243 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2244 'field_type' => '', // Custom argument
2245 'field_prefix' => '', // Custom argument
2246 'field_suffix' => '', // Custom argument
2247 'field_description' => '', // Custom argument
2248 'class' => 'asenha-text with-prefix-suffix wide utilities ' . $field_slug, // Custom class for the <tr> element
2249 )
2250 );
2251
2252 $field_id = 'smtp_default_from_description';
2253 $field_slug = 'smtp-default-from-description';
2254
2255 add_settings_field(
2256 $field_id, // Field ID
2257 '', // Field title
2258 [ $render_field, 'render_description_subfield' ], // Callback to render field with custom arguments in the array below
2259 ASENHA_SLUG, // Settings page slug
2260 'main-section', // Section ID
2261 array(
2262 'field_description' => 'If set, the FROM name/email overrides WordPress core defaults but can still be overridden by plugins that enables custom FROM name/email, e.g. form plugins.', // Custom argument
2263 'class' => 'asenha-description utilities ' . $field_slug, // Custom class for the <tr> element
2264 )
2265 );
2266
2267 $field_id = 'smtp_debug';
2268 $field_slug = 'smtp-debug';
2269
2270 add_settings_field(
2271 $field_id, // Field ID
2272 '', // Field title
2273 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
2274 ASENHA_SLUG, // Settings page slug
2275 'main-section', // Section ID
2276 array(
2277 'field_id' => $field_id, // Custom argument
2278 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2279 'field_label' => 'Enable debug mode and output the debug info into WordPress debug.log file.', // Custom argument
2280 'class' => 'asenha-checkbox asenha-hide-th top-border utilities ' . $field_slug, // Custom class for the <tr> element
2281 )
2282 );
2283
2284 // Multiple User Roles
2285
2286 $field_id = 'multiple_user_roles';
2287 $field_slug = 'multiple-user-roles';
2288
2289 add_settings_field(
2290 $field_id, // Field ID
2291 'Multiple User Roles', // Field title
2292 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2293 ASENHA_SLUG, // Settings page slug
2294 'main-section', // Section ID
2295 array(
2296 'field_id' => $field_id, // Custom argument
2297 'field_slug' => $field_slug, // Custom argument
2298 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2299 '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.', // Custom argument
2300 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2301 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2302 )
2303 );
2304
2305 // View Admin as Role
2306
2307 $field_id = 'view_admin_as_role';
2308 $field_slug = 'view-admin-as-role';
2309
2310 add_settings_field(
2311 $field_id, // Field ID
2312 'View Admin as Role', // Field title
2313 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2314 ASENHA_SLUG, // Settings page slug
2315 'main-section', // Section ID
2316 array(
2317 'field_id' => $field_id, // Custom argument
2318 'field_slug' => $field_slug, // Custom argument
2319 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2320 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
2321 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2322 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2323 )
2324 );
2325
2326 // Enable Password Protection
2327
2328 $field_id = 'enable_password_protection';
2329 $field_slug = 'enable-password-protection';
2330
2331 add_settings_field(
2332 $field_id, // Field ID
2333 'Password Protection', // Field title
2334 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2335 ASENHA_SLUG, // Settings page slug
2336 'main-section', // Section ID
2337 array(
2338 'field_id' => $field_id, // Custom argument
2339 'field_slug' => $field_slug, // Custom argument
2340 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2341 '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.', // Custom argument
2342 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2343 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2344 )
2345 );
2346
2347 $field_id = 'password_protection_password';
2348 $field_slug = 'password-protection-password';
2349
2350 add_settings_field(
2351 $field_id, // Field ID
2352 'Set the password:', // Field title
2353 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
2354 ASENHA_SLUG, // Settings page slug
2355 'main-section', // Section ID
2356 array(
2357 'field_id' => $field_id, // Custom argument
2358 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2359 'field_type' => 'with-prefix-suffix', // Custom argument
2360 'field_prefix' => '', // Custom argument
2361 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>', // Custom argument
2362 'field_description' => '', // Custom argument
2363 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
2364 )
2365 );
2366
2367 // Maintenance Mode
2368
2369 $field_id = 'maintenance_mode';
2370 $field_slug = 'maintenance-mode';
2371
2372 add_settings_field(
2373 $field_id, // Field ID
2374 'Maintenance Mode', // Field title
2375 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2376 ASENHA_SLUG, // Settings page slug
2377 'main-section', // Section ID
2378 array(
2379 'field_id' => $field_id, // Custom argument
2380 'field_slug' => $field_slug, // Custom argument
2381 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2382 '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.', // Custom argument
2383 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2384 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
2385 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2386 )
2387 );
2388
2389 $field_id = 'maintenance_page_heading';
2390 $field_slug = 'maintenance-page-heading';
2391
2392 add_settings_field(
2393 $field_id, // Field ID
2394 'Heading', // Field title
2395 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
2396 ASENHA_SLUG, // Settings page slug
2397 'main-section', // Section ID
2398 array(
2399 'field_id' => $field_id, // Custom argument
2400 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2401 'field_type' => '', // Custom argument
2402 'field_prefix' => '', // Custom argument
2403 'field_suffix' => '', // Custom argument
2404 'field_description' => '', // Custom argument
2405 'field_placeholder' => 'We\'ll be back soon.',
2406 'class' => 'asenha-text utilities full-width ' . $field_slug, // Custom class for the <tr> element
2407 )
2408 );
2409
2410 $field_id = 'maintenance_page_description';
2411 $field_slug = 'maintenance-page-description';
2412
2413 add_settings_field(
2414 $field_id, // Field ID
2415 'Description', // Field title
2416 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
2417 ASENHA_SLUG, // Settings page slug
2418 'main-section', // Section ID
2419 array(
2420 'field_id' => $field_id, // Custom argument
2421 'field_slug' => $field_slug, // Custom argument
2422 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2423 'field_type' => 'textarea', // Custom argument
2424 'field_rows' => 5,
2425 'field_intro' => '', // Custom argument
2426 'field_description' => '', // Custom argument
2427 'field_placeholder' => 'This site is undergoing maintenance for an extended period today. Thanks for your patience.',
2428 'class' => 'asenha-textarea utilities ' . $field_slug, // Custom class for the <tr> element
2429 )
2430 );
2431
2432 $field_id = 'maintenance_page_background';
2433 $field_slug = 'maintenance-page-background';
2434
2435 add_settings_field(
2436 $field_id, // Field ID
2437 'Background', // Field title
2438 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
2439 ASENHA_SLUG, // Settings page slug
2440 'main-section', // Section ID
2441 array(
2442 'field_id' => $field_id, // Custom argument
2443 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
2444 // 'field_label' => 'Temporary label', // Custom argument
2445 'field_radios' => array(
2446 'Stripes' => 'stripes',
2447 'Curves' => 'curves',
2448 'Lines' => 'lines',
2449 ),
2450 'field_default' => 'default',
2451 'class' => 'asenha-radio-buttons utilities ' . $field_slug, // Custom class for the <tr> element
2452 ),
2453 );
2454
2455 $field_id = 'maintenance_mode_description';
2456 $field_slug = 'maintenance-mode-description';
2457
2458 add_settings_field(
2459 $field_id, // Field ID
2460 '', // Field title
2461 [ $render_field, 'render_description_subfield' ], // Callback to render field with custom arguments in the array below
2462 ASENHA_SLUG, // Settings page slug
2463 'main-section', // Section ID
2464 array(
2465 'field_description' => '<div class="asenha-warning"><strong>Please clear your cache</strong> after enabling or disabling maintenance mode. This ensures site visitors see either the maintenance page or the actual content of each page.</div>', // Custom argument
2466 'class' => 'asenha-description utilities ' . $field_slug, // Custom class for the <tr> element
2467 )
2468 );
2469
2470 // Redirect 404 to Homepage
2471
2472 $field_id = 'redirect_404_to_homepage';
2473 $field_slug = 'redirect-404-to-homepage';
2474
2475 add_settings_field(
2476 $field_id, // Field ID
2477 'Redirect 404 to Homepage', // Field title
2478 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
2479 ASENHA_SLUG, // Settings page slug
2480 'main-section', // Section ID
2481 array(
2482 'field_id' => $field_id, // Custom argument
2483 'field_slug' => $field_slug, // Custom argument
2484 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
2485 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
2486 'field_options_wrapper' => true, // Custom argument. Add container for additional options
2487 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
2488 )
2489 );
2490
2491 }
2492
2493 }