PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 4.2.1
Admin and Site Enhancements (ASE) v4.2.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
1871 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 if ( array_key_exists( 'dashboard_widgets', $extra_options ) ) {
516 $dashboard_widgets = $extra_options['dashboard_widgets'];
517 } else {
518 $admin_interface = new Admin_Interface;
519 $dashboard_widgets = $admin_interface->get_dashboard_widgets();
520 $extra_options['dashboard_widgets'] = $dashboard_widgets;
521 update_option( 'admin_site_enhancements_extra', $extra_options );
522 }
523
524 foreach ( $dashboard_widgets as $widget ) {
525 add_settings_field(
526 $field_id . '_' . $widget['id'], // Field ID
527 '', // Field title
528 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
529 ASENHA_SLUG, // Settings page slug
530 'main-section', // Section ID
531 array(
532 'parent_field_id' => $field_id, // Custom argument
533 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'], // Custom argument
534 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']', // Custom argument
535 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>', // Custom argument
536 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'], // Custom class for the <tr> element
537 )
538 );
539 }
540
541 // Hide or Modify Elements
542
543 $field_id = 'hide_modify_elements';
544 $field_slug = 'hide-modify-elements';
545
546 add_settings_field(
547 $field_id, // Field ID
548 'Clean Up Admin Bar', // Field title
549 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
550 ASENHA_SLUG, // Settings page slug
551 'main-section', // Section ID
552 array(
553 'field_id' => $field_id, // Custom argument
554 'field_slug' => $field_slug, // Custom argument
555 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
556 'field_description' => 'Remove various elements from the admin bar.', // Custom argument
557 'field_options_wrapper' => true, // Custom argument. Add container for additional options
558 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
559 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
560 )
561 );
562
563 $field_id = 'hide_ab_wp_logo_menu';
564 $field_slug = 'hide-ab-wp-logo-menu';
565
566 add_settings_field(
567 $field_id, // Field ID
568 '', // Field title
569 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
570 ASENHA_SLUG, // Settings page slug
571 'main-section', // Section ID
572 array(
573 'field_id' => $field_id, // Custom argument
574 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
575 'field_label' => 'Remove WordPress logo/menu', // Custom argument
576 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
577 )
578 );
579
580 $field_id = 'hide_ab_customize_menu';
581 $field_slug = 'hide-ab-customize-menu';
582
583 add_settings_field(
584 $field_id, // Field ID
585 '', // Field title
586 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
587 ASENHA_SLUG, // Settings page slug
588 'main-section', // Section ID
589 array(
590 'field_id' => $field_id, // Custom argument
591 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
592 'field_label' => 'Remove customize menu', // Custom argument
593 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
594 )
595 );
596
597 $field_id = 'hide_ab_updates_menu';
598 $field_slug = 'hide-ab-updates-menu';
599
600 add_settings_field(
601 $field_id, // Field ID
602 '', // Field title
603 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
604 ASENHA_SLUG, // Settings page slug
605 'main-section', // Section ID
606 array(
607 'field_id' => $field_id, // Custom argument
608 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
609 'field_label' => 'Remove updates counter/link', // Custom argument
610 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
611 )
612 );
613
614 $field_id = 'hide_ab_comments_menu';
615 $field_slug = 'hide-ab-comments-menu';
616
617 add_settings_field(
618 $field_id, // Field ID
619 '', // Field title
620 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
621 ASENHA_SLUG, // Settings page slug
622 'main-section', // Section ID
623 array(
624 'field_id' => $field_id, // Custom argument
625 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
626 'field_label' => 'Remove comments counter/link', // Custom argument
627 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
628 )
629 );
630
631 $field_id = 'hide_ab_new_content_menu';
632 $field_slug = 'hide-ab-new-content-menu';
633
634 add_settings_field(
635 $field_id, // Field ID
636 '', // Field title
637 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
638 ASENHA_SLUG, // Settings page slug
639 'main-section', // Section ID
640 array(
641 'field_id' => $field_id, // Custom argument
642 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
643 'field_label' => 'Remove new content menu', // Custom argument
644 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
645 )
646 );
647
648 $field_id = 'hide_ab_howdy';
649 $field_slug = 'hide-ab-howdy';
650
651 add_settings_field(
652 $field_id, // Field ID
653 '', // Field title
654 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
655 ASENHA_SLUG, // Settings page slug
656 'main-section', // Section ID
657 array(
658 'field_id' => $field_id, // Custom argument
659 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
660 'field_label' => 'Remove \'Howdy\'', // Custom argument
661 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
662 )
663 );
664
665 // Hide Admin Bar
666
667 $field_id = 'hide_admin_bar';
668 $field_slug = 'hide-admin-bar';
669
670 add_settings_field(
671 $field_id, // Field ID
672 'Hide Admin Bar', // Field title
673 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
674 ASENHA_SLUG, // Settings page slug
675 'main-section', // Section ID
676 array(
677 'field_id' => $field_id, // Custom argument
678 'field_slug' => $field_slug, // Custom argument
679 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
680 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument
681 'field_options_wrapper' => true, // Custom argument. Add container for additional options
682 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
683 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
684 )
685 );
686
687 $field_id = 'hide_admin_bar_for';
688 $field_slug = 'hide-admin-bar-for';
689
690 if ( is_array( $roles ) ) {
691 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
692
693 add_settings_field(
694 $field_id . '_' . $role_slug, // Field ID
695 '', // Field title
696 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
697 ASENHA_SLUG, // Settings page slug
698 'main-section', // Section ID
699 array(
700 'parent_field_id' => $field_id, // Custom argument
701 'field_id' => $role_slug, // Custom argument
702 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
703 'field_label' => $role_label, // Custom argument
704 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
705 )
706 );
707
708 }
709 }
710
711 // Customize Admin Menu
712
713 $field_id = 'customize_admin_menu';
714 $field_slug = 'customize-admin-menu';
715
716 add_settings_field(
717 $field_id, // Field ID
718 'Admin Menu Organizer', // Field title
719 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
720 ASENHA_SLUG, // Settings page slug
721 'main-section', // Section ID
722 array(
723 'field_id' => $field_id, // Custom argument
724 'field_slug' => $field_slug, // Custom argument
725 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
726 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument
727 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
728 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
729 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element
730 )
731 );
732
733 $field_id = 'custom_menu_order';
734 $field_slug = 'custom-menu-order';
735
736 add_settings_field(
737 $field_id, // Field ID
738 '', // Field title
739 [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below
740 ASENHA_SLUG, // Settings page slug
741 'main-section', // Section ID
742 array(
743 'field_id' => $field_id, // Custom argument
744 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
745 'field_type' => 'sortable-menu', // Custom argument
746 'field_description' => '', // Custom argument
747 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element
748 )
749 );
750
751 // =================================================================
752 // LOG IN | LOG OUT
753 // =================================================================
754
755 // Change Login URL
756
757 $field_id = 'change_login_url';
758 $field_slug = 'change-login-url';
759
760 add_settings_field(
761 $field_id, // Field ID
762 'Change Login URL', // Field title
763 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
764 ASENHA_SLUG, // Settings page slug
765 'main-section', // Section ID
766 array(
767 'field_id' => $field_id, // Custom argument
768 'field_slug' => $field_slug, // Custom argument
769 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
770 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument
771 'field_options_wrapper' => true, // Custom argument. Add container for additional options
772 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
773 )
774 );
775
776 $field_id = 'custom_login_slug';
777 $field_slug = 'custom-login-slug';
778
779 add_settings_field(
780 $field_id, // Field ID
781 'New URL:', // Field title
782 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
783 ASENHA_SLUG, // Settings page slug
784 'main-section', // Section ID
785 array(
786 'field_id' => $field_id, // Custom argument
787 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
788 'field_type' => 'with-prefix-suffix', // Custom argument
789 'field_prefix' => get_site_url() . '/', // Custom argument
790 'field_suffix' => '/', // Custom argument
791 'field_description' => '', // Custom argument
792 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
793 )
794 );
795
796 // Enable Log In/Out Menu
797
798 $field_id = 'enable_login_logout_menu';
799 $field_slug = 'enable-login-logout-menu';
800
801 add_settings_field(
802 $field_id, // Field ID
803 'Enable Log In/Out Menu', // Field title
804 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
805 ASENHA_SLUG, // Settings page slug
806 'main-section', // Section ID
807 array(
808 'field_id' => $field_id, // Custom argument
809 'field_slug' => $field_slug, // Custom argument
810 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
811 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument
812 'field_options_wrapper' => true, // Custom argument. Add container for additional options
813 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
814 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
815 )
816 );
817
818 // Enable Last Login Column
819
820 $field_id = 'enable_last_login_column';
821 $field_slug = 'enable-last-login-column';
822
823 add_settings_field(
824 $field_id, // Field ID
825 'Enable Last Login Column', // Field title
826 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
827 ASENHA_SLUG, // Settings page slug
828 'main-section', // Section ID
829 array(
830 'field_id' => $field_id, // Custom argument
831 'field_slug' => $field_slug, // Custom argument
832 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
833 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument
834 'field_options_wrapper' => true, // Custom argument. Add container for additional options
835 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
836 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
837 )
838 );
839
840 // Redirect After Login
841
842 $field_id = 'redirect_after_login';
843 $field_slug = 'redirect-after-login';
844
845 add_settings_field(
846 $field_id, // Field ID
847 'Redirect After Login', // Field title
848 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
849 ASENHA_SLUG, // Settings page slug
850 'main-section', // Section ID
851 array(
852 'field_id' => $field_id, // Custom argument
853 'field_slug' => $field_slug, // Custom argument
854 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
855 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument
856 'field_options_wrapper' => true, // Custom argument. Add container for additional options
857 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
858 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
859 )
860 );
861
862 $field_id = 'redirect_after_login_to_slug';
863 $field_slug = 'redirect-after-login-to-slug';
864
865 add_settings_field(
866 $field_id, // Field ID
867 'Redirect to:', // Field title
868 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
869 ASENHA_SLUG, // Settings page slug
870 'main-section', // Section ID
871 array(
872 'field_id' => $field_id, // Custom argument
873 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
874 'field_type' => 'with-prefix-suffix', // Custom argument
875 'field_prefix' => get_site_url() . '/', // Custom argument
876 'field_suffix' => '/ for:', // Custom argument
877 'field_description' => '', // Custom argument
878 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
879 )
880 );
881
882 $field_id = 'redirect_after_login_for';
883 $field_slug = 'redirect-after-login-for';
884
885 if ( is_array( $roles ) ) {
886 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
887
888 add_settings_field(
889 $field_id . '_' . $role_slug, // Field ID
890 '', // Field title
891 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
892 ASENHA_SLUG, // Settings page slug
893 'main-section', // Section ID
894 array(
895 'parent_field_id' => $field_id, // Custom argument
896 'field_id' => $role_slug, // Custom argument
897 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
898 'field_label' => $role_label, // Custom argument
899 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
900 )
901 );
902
903 }
904 }
905
906 // Redirect After Logout
907
908 $field_id = 'redirect_after_logout';
909 $field_slug = 'redirect-after-logout';
910
911 add_settings_field(
912 $field_id, // Field ID
913 'Redirect After Logout', // Field title
914 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
915 ASENHA_SLUG, // Settings page slug
916 'main-section', // Section ID
917 array(
918 'field_id' => $field_id, // Custom argument
919 'field_slug' => $field_slug, // Custom argument
920 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
921 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument
922 'field_options_wrapper' => true, // Custom argument. Add container for additional options
923 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
924 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element
925 )
926 );
927
928 $field_id = 'redirect_after_logout_to_slug';
929 $field_slug = 'redirect-after-logout-to-slug';
930
931 add_settings_field(
932 $field_id, // Field ID
933 'Redirect to:', // Field title
934 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
935 ASENHA_SLUG, // Settings page slug
936 'main-section', // Section ID
937 array(
938 'field_id' => $field_id, // Custom argument
939 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
940 'field_type' => 'with-prefix-suffix', // Custom argument
941 'field_prefix' => get_site_url() . '/', // Custom argument
942 'field_suffix' => '/ for:', // Custom argument
943 'field_description' => '', // Custom argument
944 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element
945 )
946 );
947
948 $field_id = 'redirect_after_logout_for';
949 $field_slug = 'redirect-after-logout-for';
950
951 if ( is_array( $roles ) ) {
952 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
953
954 add_settings_field(
955 $field_id . '_' . $role_slug, // Field ID
956 '', // Field title
957 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
958 ASENHA_SLUG, // Settings page slug
959 'main-section', // Section ID
960 array(
961 'parent_field_id' => $field_id, // Custom argument
962 'field_id' => $role_slug, // Custom argument
963 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument
964 'field_label' => $role_label, // Custom argument
965 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element
966 )
967 );
968
969 }
970 }
971
972 // =================================================================
973 // CUSTOM CODE
974 // =================================================================
975
976 // Enable Custom Admin CSS
977
978 $field_id = 'enable_custom_admin_css';
979 $field_slug = 'enable-custom-admin-css';
980
981 add_settings_field(
982 $field_id, // Field ID
983 'Enable Custom Admin CSS', // Field title
984 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
985 ASENHA_SLUG, // Settings page slug
986 'main-section', // Section ID
987 array(
988 'field_id' => $field_id, // Custom argument
989 'field_slug' => $field_slug, // Custom argument
990 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
991 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument
992 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
993 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
994 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
995 )
996 );
997
998 $field_id = 'custom_admin_css';
999 $field_slug = 'custom-admin-css';
1000
1001 add_settings_field(
1002 $field_id, // Field ID
1003 '', // Field title
1004 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1005 ASENHA_SLUG, // Settings page slug
1006 'main-section', // Section ID
1007 array(
1008 'field_id' => $field_id, // Custom argument
1009 'field_slug' => $field_slug, // Custom argument
1010 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1011 'field_type' => 'textarea', // Custom argument
1012 'field_intro' => '', // Custom argument
1013 'field_description' => '', // Custom argument
1014 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1015 )
1016 );
1017
1018 // Enable Custom Frontend CSS
1019
1020 $field_id = 'enable_custom_frontend_css';
1021 $field_slug = 'enable-custom-frontend-css';
1022
1023 add_settings_field(
1024 $field_id, // Field ID
1025 'Enable Custom Frontend CSS', // Field title
1026 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1027 ASENHA_SLUG, // Settings page slug
1028 'main-section', // Section ID
1029 array(
1030 'field_id' => $field_id, // Custom argument
1031 'field_slug' => $field_slug, // Custom argument
1032 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1033 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument
1034 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1035 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1036 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1037 )
1038 );
1039
1040 $field_id = 'custom_frontend_css';
1041 $field_slug = 'custom-frontend-css';
1042
1043 add_settings_field(
1044 $field_id, // Field ID
1045 '', // Field title
1046 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1047 ASENHA_SLUG, // Settings page slug
1048 'main-section', // Section ID
1049 array(
1050 'field_id' => $field_id, // Custom argument
1051 'field_slug' => $field_slug, // Custom argument
1052 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1053 'field_type' => 'textarea', // Custom argument
1054 'field_intro' => '', // Custom argument
1055 'field_description' => '', // Custom argument
1056 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1057 )
1058 );
1059
1060 // Manage ads.txt and app-ads.txt
1061
1062 $field_id = 'manage_ads_appads_txt';
1063 $field_slug = 'manage-ads-appads-txt';
1064
1065 add_settings_field(
1066 $field_id, // Field ID
1067 'Manage ads.txt and app-ads.txt', // Field title
1068 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1069 ASENHA_SLUG, // Settings page slug
1070 'main-section', // Section ID
1071 array(
1072 'field_id' => $field_id, // Custom argument
1073 'field_slug' => $field_slug, // Custom argument
1074 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1075 '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
1076 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1077 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1078 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1079 )
1080 );
1081
1082 $field_id = 'ads_txt_content';
1083 $field_slug = 'ads-txt-content';
1084
1085 add_settings_field(
1086 $field_id, // Field ID
1087 '', // Field title
1088 [ $render_field, 'render_textarea_subfield' ], // 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_type' => 'textarea', // Custom argument
1096 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument
1097 '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
1098 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1099 )
1100 );
1101
1102 $field_id = 'app_ads_txt_content';
1103 $field_slug = 'app-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_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument
1117 '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
1118 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1119 )
1120 );
1121
1122 // Manage robots.txt
1123
1124 $field_id = 'manage_robots_txt';
1125 $field_slug = 'manage-robots-txt';
1126
1127 add_settings_field(
1128 $field_id, // Field ID
1129 'Manage robots.txt', // Field title
1130 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1131 ASENHA_SLUG, // Settings page slug
1132 'main-section', // Section ID
1133 array(
1134 'field_id' => $field_id, // Custom argument
1135 'field_slug' => $field_slug, // Custom argument
1136 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1137 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument
1138 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1139 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1140 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1141 )
1142 );
1143
1144 $field_id = 'robots_txt_content';
1145 $field_slug = 'robots-txt-content';
1146
1147 add_settings_field(
1148 $field_id, // Field ID
1149 '', // Field title
1150 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1151 ASENHA_SLUG, // Settings page slug
1152 'main-section', // Section ID
1153 array(
1154 'field_id' => $field_id, // Custom argument
1155 'field_slug' => $field_slug, // Custom argument
1156 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1157 'field_type' => 'textarea', // Custom argument
1158 'field_intro' => '', // Custom argument
1159 '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
1160 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1161 )
1162 );
1163
1164 // Insert <head>, <body> and <footer> code
1165
1166 $field_id = 'insert_head_body_footer_code';
1167 $field_slug = 'insert-head-body-footer-code';
1168
1169 add_settings_field(
1170 $field_id, // Field ID
1171 'Insert &lt;head&gt;, &lt;body&gt; and &lt;footer&gt; Code', // Field title
1172 [ $render_field, 'render_checkbox_toggle' ], // 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_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
1180 'field_options_wrapper' => true, // Custom argument. Add container for additional options.
1181 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1182 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element
1183 )
1184 );
1185
1186 $field_id = 'head_code_priority';
1187 $field_slug = 'head-code-priority';
1188
1189 add_settings_field(
1190 $field_id, // Field ID
1191 '', // Field title
1192 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1193 ASENHA_SLUG, // Settings page slug
1194 'main-section', // Section ID
1195 array(
1196 'field_id' => $field_id, // Custom argument
1197 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1198 'field_type' => 'with-prefix-suffix', // Custom argument
1199 'field_prefix' => '<strong>Code to insert before &lt;/head&gt; with the priority of</strong>', // Custom argument
1200 'field_suffix' => '', // Custom argument
1201 'field_intro' => '', // Custom argument
1202 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/head&gt;', // Custom argument
1203 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1204 )
1205 );
1206
1207 $field_id = 'head_code';
1208 $field_slug = 'head-code';
1209
1210 add_settings_field(
1211 $field_id, // Field ID
1212 '', // Field title
1213 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1214 ASENHA_SLUG, // Settings page slug
1215 'main-section', // Section ID
1216 array(
1217 'field_id' => $field_id, // Custom argument
1218 'field_slug' => $field_slug, // Custom argument
1219 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1220 'field_type' => 'textarea', // Custom argument
1221 'field_intro' => '', // Custom argument
1222 'field_description' => '', // Custom argument
1223 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1224 )
1225 );
1226
1227 $field_id = 'body_code_priority';
1228 $field_slug = 'body-code-priority';
1229
1230 add_settings_field(
1231 $field_id, // Field ID
1232 '', // Field title
1233 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1234 ASENHA_SLUG, // Settings page slug
1235 'main-section', // Section ID
1236 array(
1237 'field_id' => $field_id, // Custom argument
1238 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1239 'field_type' => 'with-prefix-suffix', // Custom argument
1240 'field_prefix' => '<strong>Code to insert after &lt;body&gt; with the priority of</strong>', // Custom argument
1241 'field_suffix' => '', // Custom argument
1242 'field_intro' => '', // Custom argument
1243 'field_description' => 'Default is 10. Smaller number insert code closer to &lt;body&gt;', // Custom argument
1244 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1245 )
1246 );
1247
1248 $field_id = 'body_code';
1249 $field_slug = 'body-code';
1250
1251 add_settings_field(
1252 $field_id, // Field ID
1253 '', // Field title
1254 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1255 ASENHA_SLUG, // Settings page slug
1256 'main-section', // Section ID
1257 array(
1258 'field_id' => $field_id, // Custom argument
1259 'field_slug' => $field_slug, // Custom argument
1260 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1261 'field_type' => 'textarea', // Custom argument
1262 'field_intro' => '', // Custom argument
1263 'field_description' => '', // Custom argument
1264 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1265 )
1266 );
1267
1268 $field_id = 'footer_code_priority';
1269 $field_slug = 'footer-code-priority';
1270
1271 add_settings_field(
1272 $field_id, // Field ID
1273 '', // Field title
1274 [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below
1275 ASENHA_SLUG, // Settings page slug
1276 'main-section', // Section ID
1277 array(
1278 'field_id' => $field_id, // Custom argument
1279 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1280 'field_type' => 'with-prefix-suffix', // Custom argument
1281 'field_prefix' => '<strong>Code to insert in footer section before &lt;/body&gt;: with the priority of</strong>', // Custom argument
1282 'field_suffix' => '', // Custom argument
1283 'field_intro' => '', // Custom argument
1284 'field_description' => 'Default is 10. Larger number insert code closer to &lt;/body&gt;', // Custom argument
1285 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element
1286 )
1287 );
1288
1289 $field_id = 'footer_code';
1290 $field_slug = 'footer-code';
1291
1292 add_settings_field(
1293 $field_id, // Field ID
1294 '', // Field title
1295 [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below
1296 ASENHA_SLUG, // Settings page slug
1297 'main-section', // Section ID
1298 array(
1299 'field_id' => $field_id, // Custom argument
1300 'field_slug' => $field_slug, // Custom argument
1301 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1302 'field_type' => 'textarea', // Custom argument
1303 'field_intro' => '', // Custom argument
1304 'field_description' => '', // Custom argument
1305 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element
1306 )
1307 );
1308
1309 // =================================================================
1310 // DISABLE COMPONENTS
1311 // =================================================================
1312
1313 // Disable Gutenberg
1314
1315 $field_id = 'disable_gutenberg';
1316 $field_slug = 'disable-gutenberg';
1317
1318 add_settings_field(
1319 $field_id, // Field ID
1320 'Disable Gutenberg', // Field title
1321 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1322 ASENHA_SLUG, // Settings page slug
1323 'main-section', // Section ID
1324 array(
1325 'field_id' => $field_id, // Custom argument
1326 'field_slug' => $field_slug, // Custom argument
1327 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1328 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument
1329 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1330 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1331 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1332 )
1333 );
1334
1335 $field_id = 'disable_gutenberg_for';
1336 $field_slug = 'disable-gutenberg-for';
1337
1338 if ( is_array( $asenha_gutenberg_post_types ) ) {
1339 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1340 add_settings_field(
1341 $field_id . '_' . $post_type_slug, // Field ID
1342 '', // Field title
1343 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1344 ASENHA_SLUG, // Settings page slug
1345 'main-section', // Section ID
1346 array(
1347 'parent_field_id' => $field_id, // Custom argument
1348 'field_id' => $post_type_slug, // Custom argument
1349 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1350 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1351 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1352 )
1353 );
1354 }
1355 }
1356
1357 $field_id = 'disable_gutenberg_frontend_styles';
1358 $field_slug = 'disable-gutenberg-frontend-styles';
1359
1360 add_settings_field(
1361 $field_id, // Field ID
1362 '', // Field title
1363 [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below
1364 ASENHA_SLUG, // Settings page slug
1365 'main-section', // Section ID
1366 array(
1367 'field_id' => $field_id, // Custom argument
1368 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1369 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument
1370 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element
1371 )
1372 );
1373
1374 // Disable Comments
1375
1376 $field_id = 'disable_comments';
1377 $field_slug = 'disable-comments';
1378
1379 add_settings_field(
1380 $field_id, // Field ID
1381 'Disable Comments', // Field title
1382 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1383 ASENHA_SLUG, // Settings page slug
1384 'main-section', // Section ID
1385 array(
1386 'field_id' => $field_id, // Custom argument
1387 'field_slug' => $field_slug, // Custom argument
1388 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1389 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument
1390 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1391 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1392 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1393 )
1394 );
1395
1396 $field_id = 'disable_comments_for';
1397 $field_slug = 'disable-comments-for';
1398
1399 if ( is_array( $asenha_public_post_types ) ) {
1400 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
1401 add_settings_field(
1402 $field_id . '_' . $post_type_slug, // Field ID
1403 '', // Field title
1404 [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below
1405 ASENHA_SLUG, // Settings page slug
1406 'main-section', // Section ID
1407 array(
1408 'parent_field_id' => $field_id, // Custom argument
1409 'field_id' => $post_type_slug, // Custom argument
1410 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument
1411 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument
1412 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element
1413 )
1414 );
1415 }
1416 }
1417
1418 // Disable REST API
1419
1420 $field_id = 'disable_rest_api';
1421 $field_slug = 'disable-rest-api';
1422
1423 add_settings_field(
1424 $field_id, // Field ID
1425 'Disable REST API', // Field title
1426 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1427 ASENHA_SLUG, // Settings page slug
1428 'main-section', // Section ID
1429 array(
1430 'field_id' => $field_id, // Custom argument
1431 'field_slug' => $field_slug, // Custom argument
1432 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1433 '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
1434 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1435 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1436 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1437 )
1438 );
1439
1440 // Disable Feeds
1441
1442 $field_id = 'disable_feeds';
1443 $field_slug = 'disable-feeds';
1444
1445 add_settings_field(
1446 $field_id, // Field ID
1447 'Disable Feeds', // Field title
1448 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1449 ASENHA_SLUG, // Settings page slug
1450 'main-section', // Section ID
1451 array(
1452 'field_id' => $field_id, // Custom argument
1453 'field_slug' => $field_slug, // Custom argument
1454 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1455 '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
1456 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1457 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1458 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1459 )
1460 );
1461
1462 // Disable Auto Updates
1463
1464 $field_id = 'disable_all_updates';
1465 $field_slug = 'disable-all-updates';
1466
1467 add_settings_field(
1468 $field_id, // Field ID
1469 'Disable All Updates', // Field title
1470 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1471 ASENHA_SLUG, // Settings page slug
1472 'main-section', // Section ID
1473 array(
1474 'field_id' => $field_id, // Custom argument
1475 'field_slug' => $field_slug, // Custom argument
1476 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1477 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', // Custom argument
1478 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1479 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1480 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element
1481 )
1482 );
1483
1484 // =================================================================
1485 // SECURITY
1486 // =================================================================
1487
1488 // Limit Login Attempts
1489
1490 $field_id = 'limit_login_attempts';
1491 $field_slug = 'limit-login-attempts';
1492
1493 add_settings_field(
1494 $field_id, // Field ID
1495 'Limit Login Attempts', // 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' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // 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 security ' . $field_slug, // Custom class for the <tr> element
1507 )
1508 );
1509
1510 $field_id = 'login_fails_allowed';
1511 $field_slug = 'login-fails-allowed';
1512
1513 add_settings_field(
1514 $field_id, // Field ID
1515 '', // Field title
1516 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1517 ASENHA_SLUG, // Settings page slug
1518 'main-section', // Section ID
1519 array(
1520 'field_id' => $field_id, // Custom argument
1521 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1522 'field_type' => 'with-prefix-suffix', // Custom argument
1523 'field_prefix' => '', // Custom argument
1524 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument
1525 'field_description' => '', // Custom argument
1526 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1527 )
1528 );
1529
1530 $field_id = 'login_lockout_maxcount';
1531 $field_slug = 'login-lockout-maxcount';
1532
1533 add_settings_field(
1534 $field_id, // Field ID
1535 '', // Field title
1536 [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below
1537 ASENHA_SLUG, // Settings page slug
1538 'main-section', // Section ID
1539 array(
1540 'field_id' => $field_id, // Custom argument
1541 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1542 'field_type' => 'with-prefix-suffix', // Custom argument
1543 'field_prefix' => '', // Custom argument
1544 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument
1545 'field_description' => '', // Custom argument
1546 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element
1547 )
1548 );
1549
1550 $field_id = 'login_attempts_log_table';
1551 $field_slug = 'login-attempts-log-table';
1552
1553 add_settings_field(
1554 $field_id, // Field ID
1555 '', // Field title
1556 [ $render_field, 'render_datatable' ], // Callback to render field with custom arguments in the array below
1557 ASENHA_SLUG, // Settings page slug
1558 'main-section', // Section ID
1559 array(
1560 'field_id' => $field_id, // Custom argument
1561 'field_slug' => $field_slug, // Custom argument
1562 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1563 'field_type' => 'datatable', // Custom argument
1564 'field_description' => '', // Custom argument
1565 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element
1566 'table_title' => 'Failed Login Attempts Log',
1567 'table_name' => $wpdb->prefix . 'asenha_failed_logins',
1568 )
1569 );
1570
1571 // Obfuscate Author Slugs
1572
1573 $field_id = 'obfuscate_author_slugs';
1574 $field_slug = 'obfuscate-author-slugs';
1575
1576 add_settings_field(
1577 $field_id, // Field ID
1578 'Obfuscate Author Slugs', // Field title
1579 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1580 ASENHA_SLUG, // Settings page slug
1581 'main-section', // Section ID
1582 array(
1583 'field_id' => $field_id, // Custom argument
1584 'field_slug' => $field_slug, // Custom argument
1585 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1586 '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
1587 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1588 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1589 )
1590 );
1591
1592 // Disable XML-RPC
1593
1594 $field_id = 'disable_xmlrpc';
1595 $field_slug = 'disable-xmlrpc';
1596
1597 add_settings_field(
1598 $field_id, // Field ID
1599 'Disable XML-RPC', // Field title
1600 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1601 ASENHA_SLUG, // Settings page slug
1602 'main-section', // Section ID
1603 array(
1604 'field_id' => $field_id, // Custom argument
1605 'field_slug' => $field_slug, // Custom argument
1606 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1607 '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
1608 'field_options_wrapper' => false, // Custom argument. Add container for additional options
1609 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element
1610 )
1611 );
1612
1613 // =================================================================
1614 // OPTIMIZATIONS
1615 // =================================================================
1616
1617 // Enable Heartbeat Control
1618
1619 $field_id = 'enable_heartbeat_control';
1620 $field_slug = 'enable-heartbeat-control';
1621
1622 add_settings_field(
1623 $field_id, // Field ID
1624 'Enable Heartbeat Control', // Field title
1625 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1626 ASENHA_SLUG, // Settings page slug
1627 'main-section', // Section ID
1628 array(
1629 'field_id' => $field_id, // Custom argument
1630 'field_slug' => $field_slug, // Custom argument
1631 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1632 '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
1633 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1634 'field_options_moreless' => true, // Custom argument. Add show more/less toggler.
1635 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element
1636 )
1637 );
1638
1639 $field_id = 'heartbeat_control_for_admin_pages';
1640 $field_slug = 'heartbeat-control-for-admin-pages';
1641
1642 add_settings_field(
1643 $field_id, // Field ID
1644 'On admin pages', // Field title
1645 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1646 ASENHA_SLUG, // Settings page slug
1647 'main-section', // Section ID
1648 array(
1649 'field_id' => $field_id, // Custom argument
1650 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1651 // 'field_label' => 'Temporary label', // Custom argument
1652 'field_radios' => array(
1653 'Keep as is' => 'default',
1654 'Modify' => 'modify',
1655 'Disable' => 'disable',
1656 ),
1657 'field_default' => 'default',
1658 'class' => 'asenha-radio-buttons optimizations ' . $field_slug, // Custom class for the <tr> element
1659 ),
1660 );
1661
1662 $field_id = 'heartbeat_interval_for_admin_pages';
1663 $field_slug = 'heartbeat-interval-for-admin-pages';
1664
1665 add_settings_field(
1666 $field_id, // Field ID
1667 '', // Field title
1668 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1669 ASENHA_SLUG, // Settings page slug
1670 'main-section', // Section ID
1671 array(
1672 'field_id' => $field_id, // Custom argument
1673 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1674 'field_type' => 'with-prefix-suffix', // Custom argument
1675 'field_prefix' => 'Set interval to once every', // Custom argument
1676 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>', // Custom argument
1677 'field_select_options' => array(
1678 '15 seconds' => 15,
1679 '30 seconds' => 30,
1680 '1 minute' => 60,
1681 '2 minutes' => 120,
1682 '3 minutes' => 180,
1683 '5 minutes' => 300,
1684 '10 minutes' => 600,
1685 ),
1686 'field_select_default' => 60,
1687 'field_intro' => '', // Custom argument
1688 'field_description' => '', // Custom argument
1689 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1690 'display_none_on_load' => true,
1691 )
1692 );
1693
1694 $field_id = 'heartbeat_control_for_post_edit';
1695 $field_slug = 'heartbeat-control-for-post-edit';
1696
1697 add_settings_field(
1698 $field_id, // Field ID
1699 'On post creation and edit screens', // Field title
1700 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1701 ASENHA_SLUG, // Settings page slug
1702 'main-section', // Section ID
1703 array(
1704 'field_id' => $field_id, // Custom argument
1705 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1706 // 'field_label' => 'Temporary label', // Custom argument
1707 'field_radios' => array(
1708 'Keep as is' => 'default',
1709 'Modify' => 'modify',
1710 'Disable' => 'disable',
1711 ),
1712 'field_default' => 'default',
1713 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1714 ),
1715 );
1716
1717 $field_id = 'heartbeat_interval_for_post_edit';
1718 $field_slug = 'heartbeat-interval-for-post-edit';
1719
1720 add_settings_field(
1721 $field_id, // Field ID
1722 '', // Field title
1723 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1724 ASENHA_SLUG, // Settings page slug
1725 'main-section', // Section ID
1726 array(
1727 'field_id' => $field_id, // Custom argument
1728 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1729 'field_type' => 'with-prefix-suffix', // Custom argument
1730 'field_prefix' => 'Set interval to once every', // Custom argument
1731 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>', // Custom argument
1732 'field_select_options' => array(
1733 '15 seconds' => 15,
1734 '30 seconds' => 30,
1735 '45 seconds' => 45,
1736 '60 seconds' => 60,
1737 '90 seconds' => 90,
1738 '120 seconds' => 120
1739 ),
1740 'field_select_default' => 15,
1741 'field_intro' => '', // Custom argument
1742 'field_description' => '', // Custom argument
1743 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1744 'display_none_on_load' => true,
1745 )
1746 );
1747
1748 $field_id = 'heartbeat_control_for_frontend';
1749 $field_slug = 'heartbeat-control-for-frontend';
1750
1751 add_settings_field(
1752 $field_id, // Field ID
1753 'On the frontend', // Field title
1754 [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below
1755 ASENHA_SLUG, // Settings page slug
1756 'main-section', // Section ID
1757 array(
1758 'field_id' => $field_id, // Custom argument
1759 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument
1760 // 'field_label' => 'Temporary label', // Custom argument
1761 'field_radios' => array(
1762 'Keep as is' => 'default',
1763 'Modify' => 'modify',
1764 'Disable' => 'disable',
1765 ),
1766 'field_default' => 'default',
1767 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element
1768 ),
1769 );
1770
1771 $field_id = 'heartbeat_interval_for_frontend';
1772 $field_slug = 'heartbeat-interval-for-frontend';
1773
1774 add_settings_field(
1775 $field_id, // Field ID
1776 '', // Field title
1777 [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below
1778 ASENHA_SLUG, // Settings page slug
1779 'main-section', // Section ID
1780 array(
1781 'field_id' => $field_id, // Custom argument
1782 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1783 'field_type' => 'with-prefix-suffix', // Custom argument
1784 'field_prefix' => 'Set interval to once every', // Custom argument
1785 'field_suffix' => '', // Custom argument
1786 'field_select_options' => array(
1787 '15 seconds' => 15,
1788 '30 seconds' => 30,
1789 '1 minute' => 60,
1790 '2 minutes' => 120,
1791 '3 minutes' => 180,
1792 '5 minutes' => 300,
1793 '10 minutes' => 600,
1794 ),
1795 'field_select_default' => 60,
1796 'field_intro' => '', // Custom argument
1797 'field_description' => '', // Custom argument
1798 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element
1799 'display_none_on_load' => true,
1800 )
1801 );
1802
1803 // =================================================================
1804 // UTILITIES
1805 // =================================================================
1806
1807 // Enable Password Protection
1808
1809 $field_id = 'enable_password_protection';
1810 $field_slug = 'enable-password-protection';
1811
1812 add_settings_field(
1813 $field_id, // Field ID
1814 'Enable Password Protection', // Field title
1815 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1816 ASENHA_SLUG, // Settings page slug
1817 'main-section', // Section ID
1818 array(
1819 'field_id' => $field_id, // Custom argument
1820 'field_slug' => $field_slug, // Custom argument
1821 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1822 '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
1823 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1824 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1825 )
1826 );
1827
1828 $field_id = 'password_protection_password';
1829 $field_slug = 'password-protection-password';
1830
1831 add_settings_field(
1832 $field_id, // Field ID
1833 'Set the password:', // Field title
1834 [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below
1835 ASENHA_SLUG, // Settings page slug
1836 'main-section', // Section ID
1837 array(
1838 'field_id' => $field_id, // Custom argument
1839 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1840 'field_type' => 'with-prefix-suffix', // Custom argument
1841 'field_prefix' => '', // Custom argument
1842 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>', // Custom argument
1843 'field_description' => '', // Custom argument
1844 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element
1845 )
1846 );
1847
1848 // Redirect 404 to Homepage
1849
1850 $field_id = 'redirect_404_to_homepage';
1851 $field_slug = 'redirect-404-to-homepage';
1852
1853 add_settings_field(
1854 $field_id, // Field ID
1855 'Redirect 404 to Homepage', // Field title
1856 [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below
1857 ASENHA_SLUG, // Settings page slug
1858 'main-section', // Section ID
1859 array(
1860 'field_id' => $field_id, // Custom argument
1861 'field_slug' => $field_slug, // Custom argument
1862 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument
1863 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument
1864 'field_options_wrapper' => true, // Custom argument. Add container for additional options
1865 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element
1866 )
1867 );
1868
1869 }
1870
1871 }