PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 4.2.0
Admin and Site Enhancements (ASE) v4.2.0
9.1.1 9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-sections-fields.php
admin-site-enhancements / classes Last commit date
class-activation.php 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
1864 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 'Enable 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 'Enable 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 'Enable 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 'Enable 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. 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 // Enable Revisions Control
223
224 $field_id = 'enable_revisions_control';
225 $field_slug = 'enable-revisions-control';
226
227 add_settings_field(
228 $field_id, // Field ID
229 'Enable Revisions Control', // 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' => 'Prevent bloating the database by limiting the number of revisions to keep for some or all post types supporting revisions.', // 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 $field_id = 'revisions_max_number';
245 $field_slug = 'revisions-max-number';
246
247 add_settings_field(
248 $field_id, // Field ID
249 '', // Field title
250 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
251 ASENHA_SLUG, // Settings page slug
252 'main-section', // Section ID
253 array(
254 'field_id' => $field_id, // Custom argument
255 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
256 'field_type' => 'with-prefix-suffix', // Custom argument
257 'field_prefix' => 'Limit to', // Custom argument
258 'field_suffix' => 'revisions for:', // Custom argument
259 'field_intro' => '', // Custom argument
260 'field_description' => '', // Custom argument
261 'class' => 'asenha-number asenha-hide-th extra-narrow content-management ' . $field_slug, // Custom class for the <tr> element
262 )
263 );
264
265 $field_id = 'enable_revisions_control_for';
266 $field_slug = 'enable-revisions-control-for';
267
268 if ( is_array( $asenha_revisions_post_types ) ) {
269 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
270 add_settings_field(
271 $field_id . '_' . $post_type_slug, // Field ID
272 '', // Field title
273 [ $render_field, 'render_checkbox_subfield' ], // 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 'parent_field_id' => $field_id, // Custom argument
278 'field_id' => $post_type_slug, // Custom argument
279 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
280 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
281 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
282 )
283 );
284 }
285 }
286
287 // Enable Auto-Publishing of Posts with Missed Schedules
288
289 $field_id = 'enable_missed_schedule_posts_auto_publish';
290 $field_slug = 'enable-missed-schedule-posts-auto-publish';
291
292 add_settings_field(
293 $field_id, // Field ID
294 'Enable Auto-Publishing of Posts with Missed Schedule', // Field title
295 [ $render_field, 'render_checkbox_toggle' ], // 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_slug' => $field_slug, // Custom argument
301 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
302 'field_description' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument
303 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
304 )
305 );
306
307
308 // Enhance List Tables
309
310 $field_id = 'enhance_list_tables';
311 $field_slug = 'enhance-list-tables';
312
313 add_settings_field(
314 $field_id, // Field ID
315 'Enhance List Tables', // Field title
316 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
317 ASENHA_SLUG, // Settings page slug
318 'main-section', // Section ID
319 array(
320 'field_id' => $field_id, // Custom argument
321 'field_slug' => $field_slug, // Custom argument
322 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
323 'field_description' => 'Improve the usefulness of listing pages of various post types by adding / removing columns and elements.', // Custom argument
324 'field_options_wrapper' => true, // Custom argument. Add container for additional options
325 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
326 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
327 )
328 );
329
330 // Show Featured Image Column
331
332 $field_id = 'show_featured_image_column';
333 $field_slug = 'show-featured-image-column';
334
335 add_settings_field(
336 $field_id, // Field ID
337 '', // Field title
338 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
339 ASENHA_SLUG, // Settings page slug
340 'main-section', // Section ID
341 array(
342 'field_id' => $field_id, // Custom argument
343 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
344 'field_label' => 'Show featured image column.', // Custom argument
345 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
346 )
347 );
348
349 // Show Excerpt Column
350
351 $field_id = 'show_excerpt_column';
352 $field_slug = 'show-excerpt-column';
353
354 add_settings_field(
355 $field_id, // Field ID
356 '', // Field title
357 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
358 ASENHA_SLUG, // Settings page slug
359 'main-section', // Section ID
360 array(
361 'field_id' => $field_id, // Custom argument
362 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
363 'field_label' => 'Show excerpt column.', // Custom argument
364 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
365 )
366 );
367
368 // Show ID Column
369
370 $field_id = 'show_id_column';
371 $field_slug = 'show-id-column';
372
373 add_settings_field(
374 $field_id, // Field ID
375 '', // Field title
376 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
377 ASENHA_SLUG, // Settings page slug
378 'main-section', // Section ID
379 array(
380 'field_id' => $field_id, // Custom argument
381 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
382 'field_label' => 'Show ID column.', // Custom argument
383 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
384 )
385 );
386
387 // Hide Comments Column
388
389 $field_id = 'hide_comments_column';
390 $field_slug = 'hide-comments-column';
391
392 add_settings_field(
393 $field_id, // Field ID
394 '', // Field title
395 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
396 ASENHA_SLUG, // Settings page slug
397 'main-section', // Section ID
398 array(
399 'field_id' => $field_id, // Custom argument
400 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
401 'field_label' => 'Remove comments column.', // Custom argument
402 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
403 )
404 );
405
406 // Hide Post Tags Column
407
408 $field_id = 'hide_post_tags_column';
409 $field_slug = 'hide-post-tags-column';
410
411 add_settings_field(
412 $field_id, // Field ID
413 '', // Field title
414 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
415 ASENHA_SLUG, // Settings page slug
416 'main-section', // Section ID
417 array(
418 'field_id' => $field_id, // Custom argument
419 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
420 'field_label' => 'Remove tags column (for posts).', // Custom argument
421 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
422 )
423 );
424
425 // Show Custom Taxonomy Filters
426
427 $field_id = 'show_custom_taxonomy_filters';
428 $field_slug = 'show-custom-taxonomy-filters';
429
430 add_settings_field(
431 $field_id, // Field ID
432 '', // Field title
433 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
434 ASENHA_SLUG, // Settings page slug
435 'main-section', // Section ID
436 array(
437 'field_id' => $field_id, // Custom argument
438 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
439 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument
440 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element
441 )
442 );
443
444 // =================================================================
445 // ADMIN INTERFACE
446 // =================================================================
447
448 // Hide Admin Notices
449
450 $field_id = 'hide_admin_notices';
451 $field_slug = 'hide-admin-notices';
452
453 add_settings_field(
454 $field_id, // Field ID
455 'Hide Admin Notices', // Field title
456 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
457 ASENHA_SLUG, // Settings page slug
458 'main-section', // Section ID
459 array(
460 'field_id' => $field_id, // Custom argument
461 'field_slug' => $field_slug, // Custom argument
462 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
463 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument
464 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
465 )
466 );
467
468 // View Admin as Role
469
470 $field_id = 'view_admin_as_role';
471 $field_slug = 'view-admin-as-role';
472
473 add_settings_field(
474 $field_id, // Field ID
475 'View Admin as Role', // Field title
476 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
477 ASENHA_SLUG, // Settings page slug
478 'main-section', // Section ID
479 array(
480 'field_id' => $field_id, // Custom argument
481 'field_slug' => $field_slug, // Custom argument
482 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
483 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument
484 'field_options_wrapper' => true, // Custom argument. Add container for additional options
485 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
486 )
487 );
488
489 // Disable Dashboard Widgets
490
491 $field_id = 'disable_dashboard_widgets';
492 $field_slug = 'disable-dashboard-widgets';
493
494 add_settings_field(
495 $field_id, // Field ID
496 'Disable Dashboard Widgets', // Field title
497 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
498 ASENHA_SLUG, // Settings page slug
499 'main-section', // Section ID
500 array(
501 'field_id' => $field_id, // Custom argument
502 'field_slug' => $field_slug, // Custom argument
503 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
504 '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
505 'field_options_wrapper' => true, // Custom argument. Add container for additional options
506 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
507 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
508 )
509 );
510
511 $field_id = 'disabled_dashboard_widgets';
512 $field_slug = 'disabled-dashboard-widgets';
513
514 $extra_options = get_option( 'admin_site_enhancements_extra', array() );
515 $dashboard_widgets = $extra_options['dashboard_widgets'];
516
517 foreach ( $dashboard_widgets as $widget ) {
518 add_settings_field(
519 $field_id . '_' . $widget['id'], // Field ID
520 '', // Field title
521 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
522 ASENHA_SLUG, // Settings page slug
523 'main-section', // Section ID
524 array(
525 'parent_field_id' => $field_id, // Custom argument
526 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'], // Custom argument
527 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']', // Custom argument
528 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>', // Custom argument
529 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'], // Custom class for the <tr> element
530 )
531 );
532 }
533
534 // Hide or Modify Elements
535
536 $field_id = 'hide_modify_elements';
537 $field_slug = 'hide-modify-elements';
538
539 add_settings_field(
540 $field_id, // Field ID
541 'Clean Up Admin Bar', // Field title
542 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
543 ASENHA_SLUG, // Settings page slug
544 'main-section', // Section ID
545 array(
546 'field_id' => $field_id, // Custom argument
547 'field_slug' => $field_slug, // Custom argument
548 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
549 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
550 'field_options_wrapper' => true, // Custom argument. Add container for additional options
551 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
552 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
553 )
554 );
555
556 $field_id = 'hide_ab_wp_logo_menu';
557 $field_slug = 'hide-ab-wp-logo-menu';
558
559 add_settings_field(
560 $field_id, // Field ID
561 '', // Field title
562 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
563 ASENHA_SLUG, // Settings page slug
564 'main-section', // Section ID
565 array(
566 'field_id' => $field_id, // Custom argument
567 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
568 'field_label' => 'Remove WordPress logo/menu', // Custom argument
569 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
570 )
571 );
572
573 $field_id = 'hide_ab_customize_menu';
574 $field_slug = 'hide-ab-customize-menu';
575
576 add_settings_field(
577 $field_id, // Field ID
578 '', // Field title
579 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
580 ASENHA_SLUG, // Settings page slug
581 'main-section', // Section ID
582 array(
583 'field_id' => $field_id, // Custom argument
584 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
585 'field_label' => 'Remove customize menu', // Custom argument
586 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
587 )
588 );
589
590 $field_id = 'hide_ab_updates_menu';
591 $field_slug = 'hide-ab-updates-menu';
592
593 add_settings_field(
594 $field_id, // Field ID
595 '', // Field title
596 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
597 ASENHA_SLUG, // Settings page slug
598 'main-section', // Section ID
599 array(
600 'field_id' => $field_id, // Custom argument
601 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
602 'field_label' => 'Remove updates counter/link', // Custom argument
603 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
604 )
605 );
606
607 $field_id = 'hide_ab_comments_menu';
608 $field_slug = 'hide-ab-comments-menu';
609
610 add_settings_field(
611 $field_id, // Field ID
612 '', // Field title
613 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
614 ASENHA_SLUG, // Settings page slug
615 'main-section', // Section ID
616 array(
617 'field_id' => $field_id, // Custom argument
618 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
619 'field_label' => 'Remove comments counter/link', // Custom argument
620 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
621 )
622 );
623
624 $field_id = 'hide_ab_new_content_menu';
625 $field_slug = 'hide-ab-new-content-menu';
626
627 add_settings_field(
628 $field_id, // Field ID
629 '', // Field title
630 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
631 ASENHA_SLUG, // Settings page slug
632 'main-section', // Section ID
633 array(
634 'field_id' => $field_id, // Custom argument
635 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
636 'field_label' => 'Remove new content menu', // Custom argument
637 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
638 )
639 );
640
641 $field_id = 'hide_ab_howdy';
642 $field_slug = 'hide-ab-howdy';
643
644 add_settings_field(
645 $field_id, // Field ID
646 '', // Field title
647 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
648 ASENHA_SLUG, // Settings page slug
649 'main-section', // Section ID
650 array(
651 'field_id' => $field_id, // Custom argument
652 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
653 'field_label' => 'Remove \'Howdy\'', // Custom argument
654 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
655 )
656 );
657
658 // Hide Admin Bar
659
660 $field_id = 'hide_admin_bar';
661 $field_slug = 'hide-admin-bar';
662
663 add_settings_field(
664 $field_id, // Field ID
665 'Hide Admin Bar', // Field title
666 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
667 ASENHA_SLUG, // Settings page slug
668 'main-section', // Section ID
669 array(
670 'field_id' => $field_id, // Custom argument
671 'field_slug' => $field_slug, // Custom argument
672 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
673 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
674 'field_options_wrapper' => true, // Custom argument. Add container for additional options
675 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
676 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
677 )
678 );
679
680 $field_id = 'hide_admin_bar_for';
681 $field_slug = 'hide-admin-bar-for';
682
683 if ( is_array( $roles ) ) {
684 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
685
686 add_settings_field(
687 $field_id . '_' . $role_slug, // Field ID
688 '', // Field title
689 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
690 ASENHA_SLUG, // Settings page slug
691 'main-section', // Section ID
692 array(
693 'parent_field_id' => $field_id, // Custom argument
694 'field_id' => $role_slug, // Custom argument
695 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
696 'field_label' => $role_label, // Custom argument
697 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
698 )
699 );
700
701 }
702 }
703
704 // Customize Admin Menu
705
706 $field_id = 'customize_admin_menu';
707 $field_slug = 'customize-admin-menu';
708
709 add_settings_field(
710 $field_id, // Field ID
711 'Admin Menu Organizer', // Field title
712 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
713 ASENHA_SLUG, // Settings page slug
714 'main-section', // Section ID
715 array(
716 'field_id' => $field_id, // Custom argument
717 'field_slug' => $field_slug, // Custom argument
718 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
719 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
720 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
721 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
722 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
723 )
724 );
725
726 $field_id = 'custom_menu_order';
727 $field_slug = 'custom-menu-order';
728
729 add_settings_field(
730 $field_id, // Field ID
731 '', // Field title
732 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
733 ASENHA_SLUG, // Settings page slug
734 'main-section', // Section ID
735 array(
736 'field_id' => $field_id, // Custom argument
737 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
738 'field_type' => 'sortable-menu', // Custom argument
739 'field_description' => '', // Custom argument
740 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
741 )
742 );
743
744 // =================================================================
745 // LOG IN | LOG OUT
746 // =================================================================
747
748 // Change Login URL
749
750 $field_id = 'change_login_url';
751 $field_slug = 'change-login-url';
752
753 add_settings_field(
754 $field_id, // Field ID
755 'Change Login URL', // Field title
756 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
757 ASENHA_SLUG, // Settings page slug
758 'main-section', // Section ID
759 array(
760 'field_id' => $field_id, // Custom argument
761 'field_slug' => $field_slug, // Custom argument
762 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
763 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
764 'field_options_wrapper' => true, // Custom argument. Add container for additional options
765 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
766 )
767 );
768
769 $field_id = 'custom_login_slug';
770 $field_slug = 'custom-login-slug';
771
772 add_settings_field(
773 $field_id, // Field ID
774 'New URL:', // Field title
775 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
776 ASENHA_SLUG, // Settings page slug
777 'main-section', // Section ID
778 array(
779 'field_id' => $field_id, // Custom argument
780 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
781 'field_type' => 'with-prefix-suffix', // Custom argument
782 'field_prefix' => get_site_url() . '/', // Custom argument
783 'field_suffix' => '/', // Custom argument
784 'field_description' => '', // Custom argument
785 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
786 )
787 );
788
789 // Enable Log In/Out Menu
790
791 $field_id = 'enable_login_logout_menu';
792 $field_slug = 'enable-login-logout-menu';
793
794 add_settings_field(
795 $field_id, // Field ID
796 'Enable Log In/Out Menu', // Field title
797 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
798 ASENHA_SLUG, // Settings page slug
799 'main-section', // Section ID
800 array(
801 'field_id' => $field_id, // Custom argument
802 'field_slug' => $field_slug, // Custom argument
803 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
804 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
805 'field_options_wrapper' => true, // Custom argument. Add container for additional options
806 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
807 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
808 )
809 );
810
811 // Enable Last Login Column
812
813 $field_id = 'enable_last_login_column';
814 $field_slug = 'enable-last-login-column';
815
816 add_settings_field(
817 $field_id, // Field ID
818 'Enable Last Login Column', // Field title
819 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
820 ASENHA_SLUG, // Settings page slug
821 'main-section', // Section ID
822 array(
823 'field_id' => $field_id, // Custom argument
824 'field_slug' => $field_slug, // Custom argument
825 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
826 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument
827 'field_options_wrapper' => true, // Custom argument. Add container for additional options
828 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
829 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
830 )
831 );
832
833 // Redirect After Login
834
835 $field_id = 'redirect_after_login';
836 $field_slug = 'redirect-after-login';
837
838 add_settings_field(
839 $field_id, // Field ID
840 'Redirect After Login', // Field title
841 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
842 ASENHA_SLUG, // Settings page slug
843 'main-section', // Section ID
844 array(
845 'field_id' => $field_id, // Custom argument
846 'field_slug' => $field_slug, // Custom argument
847 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
848 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
849 'field_options_wrapper' => true, // Custom argument. Add container for additional options
850 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
851 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
852 )
853 );
854
855 $field_id = 'redirect_after_login_to_slug';
856 $field_slug = 'redirect-after-login-to-slug';
857
858 add_settings_field(
859 $field_id, // Field ID
860 'Redirect to:', // Field title
861 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
862 ASENHA_SLUG, // Settings page slug
863 'main-section', // Section ID
864 array(
865 'field_id' => $field_id, // Custom argument
866 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
867 'field_type' => 'with-prefix-suffix', // Custom argument
868 'field_prefix' => get_site_url() . '/', // Custom argument
869 'field_suffix' => '/ for:', // Custom argument
870 'field_description' => '', // Custom argument
871 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
872 )
873 );
874
875 $field_id = 'redirect_after_login_for';
876 $field_slug = 'redirect-after-login-for';
877
878 if ( is_array( $roles ) ) {
879 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
880
881 add_settings_field(
882 $field_id . '_' . $role_slug, // Field ID
883 '', // Field title
884 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
885 ASENHA_SLUG, // Settings page slug
886 'main-section', // Section ID
887 array(
888 'parent_field_id' => $field_id, // Custom argument
889 'field_id' => $role_slug, // Custom argument
890 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
891 'field_label' => $role_label, // Custom argument
892 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
893 )
894 );
895
896 }
897 }
898
899 // Redirect After Logout
900
901 $field_id = 'redirect_after_logout';
902 $field_slug = 'redirect-after-logout';
903
904 add_settings_field(
905 $field_id, // Field ID
906 'Redirect After Logout', // Field title
907 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
908 ASENHA_SLUG, // Settings page slug
909 'main-section', // Section ID
910 array(
911 'field_id' => $field_id, // Custom argument
912 'field_slug' => $field_slug, // Custom argument
913 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
914 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
915 'field_options_wrapper' => true, // Custom argument. Add container for additional options
916 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
917 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
918 )
919 );
920
921 $field_id = 'redirect_after_logout_to_slug';
922 $field_slug = 'redirect-after-logout-to-slug';
923
924 add_settings_field(
925 $field_id, // Field ID
926 'Redirect to:', // Field title
927 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
928 ASENHA_SLUG, // Settings page slug
929 'main-section', // Section ID
930 array(
931 'field_id' => $field_id, // Custom argument
932 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
933 'field_type' => 'with-prefix-suffix', // Custom argument
934 'field_prefix' => get_site_url() . '/', // Custom argument
935 'field_suffix' => '/ for:', // Custom argument
936 'field_description' => '', // Custom argument
937 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
938 )
939 );
940
941 $field_id = 'redirect_after_logout_for';
942 $field_slug = 'redirect-after-logout-for';
943
944 if ( is_array( $roles ) ) {
945 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
946
947 add_settings_field(
948 $field_id . '_' . $role_slug, // Field ID
949 '', // Field title
950 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
951 ASENHA_SLUG, // Settings page slug
952 'main-section', // Section ID
953 array(
954 'parent_field_id' => $field_id, // Custom argument
955 'field_id' => $role_slug, // Custom argument
956 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
957 'field_label' => $role_label, // Custom argument
958 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
959 )
960 );
961
962 }
963 }
964
965 // =================================================================
966 // CUSTOM CODE
967 // =================================================================
968
969 // Enable Custom Admin CSS
970
971 $field_id = 'enable_custom_admin_css';
972 $field_slug = 'enable-custom-admin-css';
973
974 add_settings_field(
975 $field_id, // Field ID
976 'Enable Custom Admin CSS', // Field title
977 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
978 ASENHA_SLUG, // Settings page slug
979 'main-section', // Section ID
980 array(
981 'field_id' => $field_id, // Custom argument
982 'field_slug' => $field_slug, // Custom argument
983 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
984 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
985 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
986 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
987 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
988 )
989 );
990
991 $field_id = 'custom_admin_css';
992 $field_slug = 'custom-admin-css';
993
994 add_settings_field(
995 $field_id, // Field ID
996 '', // Field title
997 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
998 ASENHA_SLUG, // Settings page slug
999 'main-section', // Section ID
1000 array(
1001 'field_id' => $field_id, // Custom argument
1002 'field_slug' => $field_slug, // Custom argument
1003 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1004 'field_type' => 'textarea', // Custom argument
1005 'field_intro' => '', // Custom argument
1006 'field_description' => '', // Custom argument
1007 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1008 )
1009 );
1010
1011 // Enable Custom Frontend CSS
1012
1013 $field_id = 'enable_custom_frontend_css';
1014 $field_slug = 'enable-custom-frontend-css';
1015
1016 add_settings_field(
1017 $field_id, // Field ID
1018 'Enable Custom Frontend CSS', // Field title
1019 [ $render_field, 'render_checkbox_toggle' ], // 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_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
1027 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1028 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1029 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1030 )
1031 );
1032
1033 $field_id = 'custom_frontend_css';
1034 $field_slug = 'custom-frontend-css';
1035
1036 add_settings_field(
1037 $field_id, // Field ID
1038 '', // Field title
1039 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1040 ASENHA_SLUG, // Settings page slug
1041 'main-section', // Section ID
1042 array(
1043 'field_id' => $field_id, // Custom argument
1044 'field_slug' => $field_slug, // Custom argument
1045 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1046 'field_type' => 'textarea', // Custom argument
1047 'field_intro' => '', // Custom argument
1048 'field_description' => '', // Custom argument
1049 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1050 )
1051 );
1052
1053 // Manage ads.txt and app-ads.txt
1054
1055 $field_id = 'manage_ads_appads_txt';
1056 $field_slug = 'manage-ads-appads-txt';
1057
1058 add_settings_field(
1059 $field_id, // Field ID
1060 'Manage ads.txt and app-ads.txt', // Field title
1061 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1062 ASENHA_SLUG, // Settings page slug
1063 'main-section', // Section ID
1064 array(
1065 'field_id' => $field_id, // Custom argument
1066 'field_slug' => $field_slug, // Custom argument
1067 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1068 '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
1069 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1070 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1071 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1072 )
1073 );
1074
1075 $field_id = 'ads_txt_content';
1076 $field_slug = 'ads-txt-content';
1077
1078 add_settings_field(
1079 $field_id, // Field ID
1080 '', // Field title
1081 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1082 ASENHA_SLUG, // Settings page slug
1083 'main-section', // Section ID
1084 array(
1085 'field_id' => $field_id, // Custom argument
1086 'field_slug' => $field_slug, // Custom argument
1087 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1088 'field_type' => 'textarea', // Custom argument
1089 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
1090 '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
1091 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1092 )
1093 );
1094
1095 $field_id = 'app_ads_txt_content';
1096 $field_slug = 'app-ads-txt-content';
1097
1098 add_settings_field(
1099 $field_id, // Field ID
1100 '', // Field title
1101 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1102 ASENHA_SLUG, // Settings page slug
1103 'main-section', // Section ID
1104 array(
1105 'field_id' => $field_id, // Custom argument
1106 'field_slug' => $field_slug, // Custom argument
1107 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1108 'field_type' => 'textarea', // Custom argument
1109 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
1110 '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
1111 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1112 )
1113 );
1114
1115 // Manage robots.txt
1116
1117 $field_id = 'manage_robots_txt';
1118 $field_slug = 'manage-robots-txt';
1119
1120 add_settings_field(
1121 $field_id, // Field ID
1122 'Manage robots.txt', // Field title
1123 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1124 ASENHA_SLUG, // Settings page slug
1125 'main-section', // Section ID
1126 array(
1127 'field_id' => $field_id, // Custom argument
1128 'field_slug' => $field_slug, // Custom argument
1129 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1130 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument
1131 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1132 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1133 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1134 )
1135 );
1136
1137 $field_id = 'robots_txt_content';
1138 $field_slug = 'robots-txt-content';
1139
1140 add_settings_field(
1141 $field_id, // Field ID
1142 '', // Field title
1143 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1144 ASENHA_SLUG, // Settings page slug
1145 'main-section', // Section ID
1146 array(
1147 'field_id' => $field_id, // Custom argument
1148 'field_slug' => $field_slug, // Custom argument
1149 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1150 'field_type' => 'textarea', // Custom argument
1151 'field_intro' => '', // Custom argument
1152 '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
1153 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1154 )
1155 );
1156
1157 // Insert <head>, <body> and <footer> code
1158
1159 $field_id = 'insert_head_body_footer_code';
1160 $field_slug = 'insert-head-body-footer-code';
1161
1162 add_settings_field(
1163 $field_id, // Field ID
1164 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
1165 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1166 ASENHA_SLUG, // Settings page slug
1167 'main-section', // Section ID
1168 array(
1169 'field_id' => $field_id, // Custom argument
1170 'field_slug' => $field_slug, // Custom argument
1171 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1172 '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
1173 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1174 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1175 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1176 )
1177 );
1178
1179 $field_id = 'head_code_priority';
1180 $field_slug = 'head-code-priority';
1181
1182 add_settings_field(
1183 $field_id, // Field ID
1184 '', // Field title
1185 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1186 ASENHA_SLUG, // Settings page slug
1187 'main-section', // Section ID
1188 array(
1189 'field_id' => $field_id, // Custom argument
1190 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1191 'field_type' => 'with-prefix-suffix', // Custom argument
1192 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1193 'field_suffix' => '', // Custom argument
1194 'field_intro' => '', // Custom argument
1195 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1196 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1197 )
1198 );
1199
1200 $field_id = 'head_code';
1201 $field_slug = 'head-code';
1202
1203 add_settings_field(
1204 $field_id, // Field ID
1205 '', // Field title
1206 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1207 ASENHA_SLUG, // Settings page slug
1208 'main-section', // Section ID
1209 array(
1210 'field_id' => $field_id, // Custom argument
1211 'field_slug' => $field_slug, // Custom argument
1212 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1213 'field_type' => 'textarea', // Custom argument
1214 'field_intro' => '', // Custom argument
1215 'field_description' => '', // Custom argument
1216 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1217 )
1218 );
1219
1220 $field_id = 'body_code_priority';
1221 $field_slug = 'body-code-priority';
1222
1223 add_settings_field(
1224 $field_id, // Field ID
1225 '', // Field title
1226 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1227 ASENHA_SLUG, // Settings page slug
1228 'main-section', // Section ID
1229 array(
1230 'field_id' => $field_id, // Custom argument
1231 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1232 'field_type' => 'with-prefix-suffix', // Custom argument
1233 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1234 'field_suffix' => '', // Custom argument
1235 'field_intro' => '', // Custom argument
1236 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1237 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1238 )
1239 );
1240
1241 $field_id = 'body_code';
1242 $field_slug = 'body-code';
1243
1244 add_settings_field(
1245 $field_id, // Field ID
1246 '', // Field title
1247 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1248 ASENHA_SLUG, // Settings page slug
1249 'main-section', // Section ID
1250 array(
1251 'field_id' => $field_id, // Custom argument
1252 'field_slug' => $field_slug, // Custom argument
1253 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1254 'field_type' => 'textarea', // Custom argument
1255 'field_intro' => '', // Custom argument
1256 'field_description' => '', // Custom argument
1257 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1258 )
1259 );
1260
1261 $field_id = 'footer_code_priority';
1262 $field_slug = 'footer-code-priority';
1263
1264 add_settings_field(
1265 $field_id, // Field ID
1266 '', // Field title
1267 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1268 ASENHA_SLUG, // Settings page slug
1269 'main-section', // Section ID
1270 array(
1271 'field_id' => $field_id, // Custom argument
1272 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1273 'field_type' => 'with-prefix-suffix', // Custom argument
1274 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1275 'field_suffix' => '', // Custom argument
1276 'field_intro' => '', // Custom argument
1277 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1278 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1279 )
1280 );
1281
1282 $field_id = 'footer_code';
1283 $field_slug = 'footer-code';
1284
1285 add_settings_field(
1286 $field_id, // Field ID
1287 '', // Field title
1288 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1289 ASENHA_SLUG, // Settings page slug
1290 'main-section', // Section ID
1291 array(
1292 'field_id' => $field_id, // Custom argument
1293 'field_slug' => $field_slug, // Custom argument
1294 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1295 'field_type' => 'textarea', // Custom argument
1296 'field_intro' => '', // Custom argument
1297 'field_description' => '', // Custom argument
1298 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1299 )
1300 );
1301
1302 // =================================================================
1303 // DISABLE COMPONENTS
1304 // =================================================================
1305
1306 // Disable Gutenberg
1307
1308 $field_id = 'disable_gutenberg';
1309 $field_slug = 'disable-gutenberg';
1310
1311 add_settings_field(
1312 $field_id, // Field ID
1313 'Disable Gutenberg', // Field title
1314 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1315 ASENHA_SLUG, // Settings page slug
1316 'main-section', // Section ID
1317 array(
1318 'field_id' => $field_id, // Custom argument
1319 'field_slug' => $field_slug, // Custom argument
1320 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1321 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
1322 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1323 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1324 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1325 )
1326 );
1327
1328 $field_id = 'disable_gutenberg_for';
1329 $field_slug = 'disable-gutenberg-for';
1330
1331 if ( is_array( $asenha_gutenberg_post_types ) ) {
1332 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1333 add_settings_field(
1334 $field_id . '_' . $post_type_slug, // Field ID
1335 '', // Field title
1336 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1337 ASENHA_SLUG, // Settings page slug
1338 'main-section', // Section ID
1339 array(
1340 'parent_field_id' => $field_id, // Custom argument
1341 'field_id' => $post_type_slug, // Custom argument
1342 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1343 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1344 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1345 )
1346 );
1347 }
1348 }
1349
1350 $field_id = 'disable_gutenberg_frontend_styles';
1351 $field_slug = 'disable-gutenberg-frontend-styles';
1352
1353 add_settings_field(
1354 $field_id, // Field ID
1355 '', // Field title
1356 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1357 ASENHA_SLUG, // Settings page slug
1358 'main-section', // Section ID
1359 array(
1360 'field_id' => $field_id, // Custom argument
1361 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1362 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
1363 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
1364 )
1365 );
1366
1367 // Disable Comments
1368
1369 $field_id = 'disable_comments';
1370 $field_slug = 'disable-comments';
1371
1372 add_settings_field(
1373 $field_id, // Field ID
1374 'Disable Comments', // Field title
1375 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1376 ASENHA_SLUG, // Settings page slug
1377 'main-section', // Section ID
1378 array(
1379 'field_id' => $field_id, // Custom argument
1380 'field_slug' => $field_slug, // Custom argument
1381 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1382 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
1383 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1384 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1385 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1386 )
1387 );
1388
1389 $field_id = 'disable_comments_for';
1390 $field_slug = 'disable-comments-for';
1391
1392 if ( is_array( $asenha_public_post_types ) ) {
1393 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1394 add_settings_field(
1395 $field_id . '_' . $post_type_slug, // Field ID
1396 '', // Field title
1397 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1398 ASENHA_SLUG, // Settings page slug
1399 'main-section', // Section ID
1400 array(
1401 'parent_field_id' => $field_id, // Custom argument
1402 'field_id' => $post_type_slug, // Custom argument
1403 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1404 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1405 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1406 )
1407 );
1408 }
1409 }
1410
1411 // Disable REST API
1412
1413 $field_id = 'disable_rest_api';
1414 $field_slug = 'disable-rest-api';
1415
1416 add_settings_field(
1417 $field_id, // Field ID
1418 'Disable REST API', // Field title
1419 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1420 ASENHA_SLUG, // Settings page slug
1421 'main-section', // Section ID
1422 array(
1423 'field_id' => $field_id, // Custom argument
1424 'field_slug' => $field_slug, // Custom argument
1425 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1426 '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
1427 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1428 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1429 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1430 )
1431 );
1432
1433 // Disable Feeds
1434
1435 $field_id = 'disable_feeds';
1436 $field_slug = 'disable-feeds';
1437
1438 add_settings_field(
1439 $field_id, // Field ID
1440 'Disable Feeds', // Field title
1441 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1442 ASENHA_SLUG, // Settings page slug
1443 'main-section', // Section ID
1444 array(
1445 'field_id' => $field_id, // Custom argument
1446 'field_slug' => $field_slug, // Custom argument
1447 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1448 '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
1449 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1450 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1451 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1452 )
1453 );
1454
1455 // Disable Auto Updates
1456
1457 $field_id = 'disable_all_updates';
1458 $field_slug = 'disable-all-updates';
1459
1460 add_settings_field(
1461 $field_id, // Field ID
1462 'Disable All Updates', // Field title
1463 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1464 ASENHA_SLUG, // Settings page slug
1465 'main-section', // Section ID
1466 array(
1467 'field_id' => $field_id, // Custom argument
1468 'field_slug' => $field_slug, // Custom argument
1469 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1470 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', // Custom argument
1471 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1472 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1473 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1474 )
1475 );
1476
1477 // =================================================================
1478 // SECURITY
1479 // =================================================================
1480
1481 // Limit Login Attempts
1482
1483 $field_id = 'limit_login_attempts';
1484 $field_slug = 'limit-login-attempts';
1485
1486 add_settings_field(
1487 $field_id, // Field ID
1488 'Limit Login Attempts', // Field title
1489 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1490 ASENHA_SLUG, // Settings page slug
1491 'main-section', // Section ID
1492 array(
1493 'field_id' => $field_id, // Custom argument
1494 'field_slug' => $field_slug, // Custom argument
1495 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1496 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument
1497 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1498 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1499 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1500 )
1501 );
1502
1503 $field_id = 'login_fails_allowed';
1504 $field_slug = 'login-fails-allowed';
1505
1506 add_settings_field(
1507 $field_id, // Field ID
1508 '', // Field title
1509 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1510 ASENHA_SLUG, // Settings page slug
1511 'main-section', // Section ID
1512 array(
1513 'field_id' => $field_id, // Custom argument
1514 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1515 'field_type' => 'with-prefix-suffix', // Custom argument
1516 'field_prefix' => '', // Custom argument
1517 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
1518 'field_description' => '', // Custom argument
1519 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1520 )
1521 );
1522
1523 $field_id = 'login_lockout_maxcount';
1524 $field_slug = 'login-lockout-maxcount';
1525
1526 add_settings_field(
1527 $field_id, // Field ID
1528 '', // Field title
1529 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1530 ASENHA_SLUG, // Settings page slug
1531 'main-section', // Section ID
1532 array(
1533 'field_id' => $field_id, // Custom argument
1534 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1535 'field_type' => 'with-prefix-suffix', // Custom argument
1536 'field_prefix' => '', // Custom argument
1537 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
1538 'field_description' => '', // Custom argument
1539 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1540 )
1541 );
1542
1543 $field_id = 'login_attempts_log_table';
1544 $field_slug = 'login-attempts-log-table';
1545
1546 add_settings_field(
1547 $field_id, // Field ID
1548 '', // Field title
1549 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
1550 ASENHA_SLUG, // Settings page slug
1551 'main-section', // Section ID
1552 array(
1553 'field_id' => $field_id, // Custom argument
1554 'field_slug' => $field_slug, // Custom argument
1555 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1556 'field_type' => 'datatable', // Custom argument
1557 'field_description' => '', // Custom argument
1558 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
1559 'table_title' => 'Failed Login Attempts Log',
1560 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
1561 )
1562 );
1563
1564 // Obfuscate Author Slugs
1565
1566 $field_id = 'obfuscate_author_slugs';
1567 $field_slug = 'obfuscate-author-slugs';
1568
1569 add_settings_field(
1570 $field_id, // Field ID
1571 'Obfuscate Author Slugs', // Field title
1572 [ $render_field, 'render_checkbox_toggle' ], // 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_slug' => $field_slug, // Custom argument
1578 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1579 '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
1580 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1581 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1582 )
1583 );
1584
1585 // Disable XML-RPC
1586
1587 $field_id = 'disable_xmlrpc';
1588 $field_slug = 'disable-xmlrpc';
1589
1590 add_settings_field(
1591 $field_id, // Field ID
1592 'Disable XML-RPC', // Field title
1593 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1594 ASENHA_SLUG, // Settings page slug
1595 'main-section', // Section ID
1596 array(
1597 'field_id' => $field_id, // Custom argument
1598 'field_slug' => $field_slug, // Custom argument
1599 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1600 '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
1601 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1602 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1603 )
1604 );
1605
1606 // =================================================================
1607 // OPTIMIZATIONS
1608 // =================================================================
1609
1610 // Enable Heartbeat Control
1611
1612 $field_id = 'enable_heartbeat_control';
1613 $field_slug = 'enable-heartbeat-control';
1614
1615 add_settings_field(
1616 $field_id, // Field ID
1617 'Enable Heartbeat Control', // Field title
1618 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1619 ASENHA_SLUG, // Settings page slug
1620 'main-section', // Section ID
1621 array(
1622 'field_id' => $field_id, // Custom argument
1623 'field_slug' => $field_slug, // Custom argument
1624 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1625 '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
1626 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1627 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1628 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
1629 )
1630 );
1631
1632 $field_id = 'heartbeat_control_for_admin_pages';
1633 $field_slug = 'heartbeat-control-for-admin-pages';
1634
1635 add_settings_field(
1636 $field_id, // Field ID
1637 'On admin pages', // Field title
1638 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1639 ASENHA_SLUG, // Settings page slug
1640 'main-section', // Section ID
1641 array(
1642 'field_id' => $field_id, // Custom argument
1643 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1644 // 'field_label' => 'Temporary label', // Custom argument
1645 'field_radios' => array(
1646 'Keep as is' => 'default',
1647 'Modify' => 'modify',
1648 'Disable' => 'disable',
1649 ),
1650 'field_default' => 'default',
1651 'class' => 'asenha-radio-buttons optimizations ' . $field_slug, // Custom class for the <tr> element
1652 ),
1653 );
1654
1655 $field_id = 'heartbeat_interval_for_admin_pages';
1656 $field_slug = 'heartbeat-interval-for-admin-pages';
1657
1658 add_settings_field(
1659 $field_id, // Field ID
1660 '', // Field title
1661 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1662 ASENHA_SLUG, // Settings page slug
1663 'main-section', // Section ID
1664 array(
1665 'field_id' => $field_id, // Custom argument
1666 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1667 'field_type' => 'with-prefix-suffix', // Custom argument
1668 'field_prefix' => 'Set interval to once every', // Custom argument
1669 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>', // Custom argument
1670 'field_select_options' => array(
1671 '15 seconds' => 15,
1672 '30 seconds' => 30,
1673 '1 minute' => 60,
1674 '2 minutes' => 120,
1675 '3 minutes' => 180,
1676 '5 minutes' => 300,
1677 '10 minutes' => 600,
1678 ),
1679 'field_select_default' => 60,
1680 'field_intro' => '', // Custom argument
1681 'field_description' => '', // Custom argument
1682 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1683 'display_none_on_load' => true,
1684 )
1685 );
1686
1687 $field_id = 'heartbeat_control_for_post_edit';
1688 $field_slug = 'heartbeat-control-for-post-edit';
1689
1690 add_settings_field(
1691 $field_id, // Field ID
1692 'On post creation and edit screens', // Field title
1693 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1694 ASENHA_SLUG, // Settings page slug
1695 'main-section', // Section ID
1696 array(
1697 'field_id' => $field_id, // Custom argument
1698 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1699 // 'field_label' => 'Temporary label', // Custom argument
1700 'field_radios' => array(
1701 'Keep as is' => 'default',
1702 'Modify' => 'modify',
1703 'Disable' => 'disable',
1704 ),
1705 'field_default' => 'default',
1706 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1707 ),
1708 );
1709
1710 $field_id = 'heartbeat_interval_for_post_edit';
1711 $field_slug = 'heartbeat-interval-for-post-edit';
1712
1713 add_settings_field(
1714 $field_id, // Field ID
1715 '', // Field title
1716 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1717 ASENHA_SLUG, // Settings page slug
1718 'main-section', // Section ID
1719 array(
1720 'field_id' => $field_id, // Custom argument
1721 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1722 'field_type' => 'with-prefix-suffix', // Custom argument
1723 'field_prefix' => 'Set interval to once every', // Custom argument
1724 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>', // Custom argument
1725 'field_select_options' => array(
1726 '15 seconds' => 15,
1727 '30 seconds' => 30,
1728 '45 seconds' => 45,
1729 '60 seconds' => 60,
1730 '90 seconds' => 90,
1731 '120 seconds' => 120
1732 ),
1733 'field_select_default' => 15,
1734 'field_intro' => '', // Custom argument
1735 'field_description' => '', // Custom argument
1736 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1737 'display_none_on_load' => true,
1738 )
1739 );
1740
1741 $field_id = 'heartbeat_control_for_frontend';
1742 $field_slug = 'heartbeat-control-for-frontend';
1743
1744 add_settings_field(
1745 $field_id, // Field ID
1746 'On the frontend', // Field title
1747 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1748 ASENHA_SLUG, // Settings page slug
1749 'main-section', // Section ID
1750 array(
1751 'field_id' => $field_id, // Custom argument
1752 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1753 // 'field_label' => 'Temporary label', // Custom argument
1754 'field_radios' => array(
1755 'Keep as is' => 'default',
1756 'Modify' => 'modify',
1757 'Disable' => 'disable',
1758 ),
1759 'field_default' => 'default',
1760 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1761 ),
1762 );
1763
1764 $field_id = 'heartbeat_interval_for_frontend';
1765 $field_slug = 'heartbeat-interval-for-frontend';
1766
1767 add_settings_field(
1768 $field_id, // Field ID
1769 '', // Field title
1770 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1771 ASENHA_SLUG, // Settings page slug
1772 'main-section', // Section ID
1773 array(
1774 'field_id' => $field_id, // Custom argument
1775 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1776 'field_type' => 'with-prefix-suffix', // Custom argument
1777 'field_prefix' => 'Set interval to once every', // Custom argument
1778 'field_suffix' => '', // Custom argument
1779 'field_select_options' => array(
1780 '15 seconds' => 15,
1781 '30 seconds' => 30,
1782 '1 minute' => 60,
1783 '2 minutes' => 120,
1784 '3 minutes' => 180,
1785 '5 minutes' => 300,
1786 '10 minutes' => 600,
1787 ),
1788 'field_select_default' => 60,
1789 'field_intro' => '', // Custom argument
1790 'field_description' => '', // Custom argument
1791 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1792 'display_none_on_load' => true,
1793 )
1794 );
1795
1796 // =================================================================
1797 // UTILITIES
1798 // =================================================================
1799
1800 // Enable Password Protection
1801
1802 $field_id = 'enable_password_protection';
1803 $field_slug = 'enable-password-protection';
1804
1805 add_settings_field(
1806 $field_id, // Field ID
1807 'Enable Password Protection', // Field title
1808 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1809 ASENHA_SLUG, // Settings page slug
1810 'main-section', // Section ID
1811 array(
1812 'field_id' => $field_id, // Custom argument
1813 'field_slug' => $field_slug, // Custom argument
1814 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1815 '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 normally.', // Custom argument
1816 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1817 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1818 )
1819 );
1820
1821 $field_id = 'password_protection_password';
1822 $field_slug = 'password-protection-password';
1823
1824 add_settings_field(
1825 $field_id, // Field ID
1826 'Set the password:', // Field title
1827 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
1828 ASENHA_SLUG, // Settings page slug
1829 'main-section', // Section ID
1830 array(
1831 'field_id' => $field_id, // Custom argument
1832 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1833 'field_type' => 'with-prefix-suffix', // Custom argument
1834 'field_prefix' => '', // Custom argument
1835 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>', // Custom argument
1836 'field_description' => '', // Custom argument
1837 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
1838 )
1839 );
1840
1841 // Redirect 404 to Homepage
1842
1843 $field_id = 'redirect_404_to_homepage';
1844 $field_slug = 'redirect-404-to-homepage';
1845
1846 add_settings_field(
1847 $field_id, // Field ID
1848 'Redirect 404 to Homepage', // Field title
1849 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1850 ASENHA_SLUG, // Settings page slug
1851 'main-section', // Section ID
1852 array(
1853 'field_id' => $field_id, // Custom argument
1854 'field_slug' => $field_slug, // Custom argument
1855 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1856 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
1857 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1858 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1859 )
1860 );
1861
1862 }
1863
1864 }