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
1935 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | /** |
| 6 | * Class related to registration of settings fields |
| 7 | * |
| 8 | * @since 2.2.0 |
| 9 | */ |
| 10 | class Settings_Sections_Fields { |
| 11 | |
| 12 | /** |
| 13 | * Register plugin settings and the corresponding fields |
| 14 | * |
| 15 | * @link https://wpshout.com/making-an-admin-options-page-with-the-wordpress-settings-api/ |
| 16 | * @link https://rudrastyh.com/wordpress/creating-options-pages.html |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | function register_sections_fields() { |
| 20 | |
| 21 | add_settings_section( |
| 22 | 'main-section', // Section ID |
| 23 | '', // Section title. Can be blank. |
| 24 | '', // Callback function to output section intro. Can be blank. |
| 25 | ASENHA_SLUG // Settings page slug |
| 26 | ); |
| 27 | |
| 28 | // Register main setttings |
| 29 | |
| 30 | // Instantiate object for sanitization of settings fields values |
| 31 | $sanitization = new Settings_Sanitization; |
| 32 | |
| 33 | // Instantiate object for rendering of settings fields for the admin page |
| 34 | $render_field = new Settings_Fields_Render; |
| 35 | |
| 36 | register_setting( |
| 37 | ASENHA_ID, // Option group or option_page |
| 38 | ASENHA_SLUG_U, // Option name in wp_options table |
| 39 | array( |
| 40 | 'type' => 'array', // 'string', 'boolean', 'integer', 'number', 'array', or 'object' |
| 41 | 'description' => '', // A description of the data attached to this setting. |
| 42 | 'sanitize_callback' => [ $sanitization, 'sanitize_for_options' ], |
| 43 | 'show_in_rest' => false, |
| 44 | 'default' => array(), // When calling get_option() |
| 45 | ) |
| 46 | ); |
| 47 | |
| 48 | // ================================================================= |
| 49 | // Call WordPress globals and set new globals required for the fields |
| 50 | // ================================================================= |
| 51 | |
| 52 | global $wp_roles, $wpdb, $asenha_public_post_types, $asenha_gutenberg_post_types, $asenha_revisions_post_types; |
| 53 | |
| 54 | $roles = $wp_roles->get_names(); |
| 55 | |
| 56 | // Get array of slugs and plural labels for public post types, e.g. array( 'post' => 'Posts', 'page' => 'Pages' ) |
| 57 | $asenha_public_post_types = array(); |
| 58 | $public_post_type_names = get_post_types( array( 'public' => true ), 'names' ); |
| 59 | foreach( $public_post_type_names as $post_type_name ) { |
| 60 | $post_type_object = get_post_type_object( $post_type_name ); |
| 61 | $asenha_public_post_types[$post_type_name] = $post_type_object->label; |
| 62 | } |
| 63 | |
| 64 | // Get array of slugs and plural labels for post types that can be edited with the Gutenberg block editor, e.g. array( 'post' => 'Posts', 'page' => 'Pages' ) |
| 65 | $asenha_gutenberg_post_types = array(); |
| 66 | $gutenberg_not_applicable_types = array( 'attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wp_block' ); |
| 67 | $all_post_types = get_post_types( array(), 'objects' ); |
| 68 | foreach ( $all_post_types as $post_type_slug => $post_type_info ) { |
| 69 | $asenha_gutenberg_post_types[$post_type_slug] = $post_type_info->label; |
| 70 | if ( in_array( $post_type_slug, $gutenberg_not_applicable_types ) ) { |
| 71 | unset( $asenha_gutenberg_post_types[$post_type_slug] ); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Get array of slugs and plural labels for post types supporting revisions, e.g. array( 'post' => 'Posts', 'page' => 'Pages' ) |
| 76 | $asenha_revisions_post_types = array(); |
| 77 | foreach ( get_post_types( array(), 'names' ) as $post_type_slug ) { // post type slug/name |
| 78 | if ( post_type_supports( $post_type_slug, 'revisions' ) ) { |
| 79 | $post_type_object = get_post_type_object( $post_type_slug ); |
| 80 | if ( property_exists( $post_type_object, 'label' ) ) { |
| 81 | $asenha_revisions_post_types[$post_type_slug] = $post_type_object->label; |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | // ================================================================= |
| 87 | // CONTENT MANAGEMENT |
| 88 | // ================================================================= |
| 89 | |
| 90 | // Enable Page and Post Duplication |
| 91 | |
| 92 | $field_id = 'enable_duplication'; |
| 93 | $field_slug = 'enable-duplication'; |
| 94 | |
| 95 | add_settings_field( |
| 96 | $field_id, // Field ID |
| 97 | 'Page and Post Duplication', // Field title |
| 98 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 99 | ASENHA_SLUG, // Settings page slug |
| 100 | 'main-section', // Section ID |
| 101 | array( |
| 102 | 'field_id' => $field_id, // Custom argument |
| 103 | 'field_slug' => $field_slug, // Custom argument |
| 104 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 105 | 'field_description' => 'Enable one-click duplication of pages, posts and custom posts. The corresponding taxonomy terms and post meta will also be duplicated.', // Custom argument |
| 106 | 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element |
| 107 | ) |
| 108 | ); |
| 109 | |
| 110 | // Enable Media Replacement |
| 111 | |
| 112 | $field_id = 'enable_media_replacement'; |
| 113 | $field_slug = 'enable-media-replacement'; |
| 114 | |
| 115 | add_settings_field( |
| 116 | $field_id, // Field ID |
| 117 | 'Media Replacement', // Field title |
| 118 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 119 | ASENHA_SLUG, // Settings page slug |
| 120 | 'main-section', // Section ID |
| 121 | array( |
| 122 | 'field_id' => $field_id, // Custom argument |
| 123 | 'field_slug' => $field_slug, // Custom argument |
| 124 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 125 | 'field_description' => 'Easily replace any type of media file with a new one while retaining the existing media ID, publish date and file name. So, no existing links will break.', // Custom argument |
| 126 | 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element |
| 127 | ) |
| 128 | ); |
| 129 | |
| 130 | // Enable SVG Upload |
| 131 | |
| 132 | $field_id = 'enable_svg_upload'; |
| 133 | $field_slug = 'enable-svg-upload'; |
| 134 | |
| 135 | add_settings_field( |
| 136 | $field_id, // Field ID |
| 137 | 'SVG Upload', // Field title |
| 138 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 139 | ASENHA_SLUG, // Settings page slug |
| 140 | 'main-section', // Section ID |
| 141 | array( |
| 142 | 'field_id' => $field_id, // Custom argument |
| 143 | 'field_slug' => $field_slug, // Custom argument |
| 144 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 145 | 'field_description' => 'Allow some or all user roles to upload SVG files, which will then be sanitized to keep things secure.', // Custom argument |
| 146 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 147 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 148 | 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element |
| 149 | ) |
| 150 | ); |
| 151 | |
| 152 | $field_id = 'enable_svg_upload_for'; |
| 153 | $field_slug = 'enable-svg-upload-for'; |
| 154 | |
| 155 | if ( is_array( $roles ) ) { |
| 156 | foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator |
| 157 | |
| 158 | add_settings_field( |
| 159 | $field_id . '_' . $role_slug, // Field ID |
| 160 | '', // Field title |
| 161 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 162 | ASENHA_SLUG, // Settings page slug |
| 163 | 'main-section', // Section ID |
| 164 | array( |
| 165 | 'parent_field_id' => $field_id, // Custom argument |
| 166 | 'field_id' => $role_slug, // Custom argument |
| 167 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument |
| 168 | 'field_label' => $role_label, // Custom argument |
| 169 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element |
| 170 | ) |
| 171 | ); |
| 172 | |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // Enable External Permalinks |
| 177 | |
| 178 | $field_id = 'enable_external_permalinks'; |
| 179 | $field_slug = 'enable-external-permalinks'; |
| 180 | |
| 181 | add_settings_field( |
| 182 | $field_id, // Field ID |
| 183 | 'External Permalinks', // Field title |
| 184 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 185 | ASENHA_SLUG, // Settings page slug |
| 186 | 'main-section', // Section ID |
| 187 | array( |
| 188 | 'field_id' => $field_id, // Custom argument |
| 189 | 'field_slug' => $field_slug, // Custom argument |
| 190 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 191 | 'field_description' => 'Enable pages, posts and/or custom post types to have permalinks that point to external URLs. 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 Auto-Publishing of Posts with Missed Schedules |
| 223 | |
| 224 | $field_id = 'enable_missed_schedule_posts_auto_publish'; |
| 225 | $field_slug = 'enable-missed-schedule-posts-auto-publish'; |
| 226 | |
| 227 | add_settings_field( |
| 228 | $field_id, // Field ID |
| 229 | 'Auto-Publish Posts with Missed Schedule', // 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' => 'Trigger publishing of scheduled posts of all types marked with "missed schedule", anytime the site is visited.', // Custom argument |
| 238 | 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element |
| 239 | ) |
| 240 | ); |
| 241 | |
| 242 | |
| 243 | // Enhance List Tables |
| 244 | |
| 245 | $field_id = 'enhance_list_tables'; |
| 246 | $field_slug = 'enhance-list-tables'; |
| 247 | |
| 248 | add_settings_field( |
| 249 | $field_id, // Field ID |
| 250 | 'Enhance List Tables', // Field title |
| 251 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 252 | ASENHA_SLUG, // Settings page slug |
| 253 | 'main-section', // Section ID |
| 254 | array( |
| 255 | 'field_id' => $field_id, // Custom argument |
| 256 | 'field_slug' => $field_slug, // Custom argument |
| 257 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 258 | 'field_description' => 'Improve the usefulness of listing pages of various post types by adding / removing columns and elements.', // Custom argument |
| 259 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 260 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 261 | 'class' => 'asenha-toggle content-management ' . $field_slug, // Custom class for the <tr> element |
| 262 | ) |
| 263 | ); |
| 264 | |
| 265 | // Show Featured Image Column |
| 266 | |
| 267 | $field_id = 'show_featured_image_column'; |
| 268 | $field_slug = 'show-featured-image-column'; |
| 269 | |
| 270 | add_settings_field( |
| 271 | $field_id, // Field ID |
| 272 | '', // Field title |
| 273 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 274 | ASENHA_SLUG, // Settings page slug |
| 275 | 'main-section', // Section ID |
| 276 | array( |
| 277 | 'field_id' => $field_id, // Custom argument |
| 278 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 279 | 'field_label' => 'Show featured image column.', // Custom argument |
| 280 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 281 | ) |
| 282 | ); |
| 283 | |
| 284 | // Show Excerpt Column |
| 285 | |
| 286 | $field_id = 'show_excerpt_column'; |
| 287 | $field_slug = 'show-excerpt-column'; |
| 288 | |
| 289 | add_settings_field( |
| 290 | $field_id, // Field ID |
| 291 | '', // Field title |
| 292 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 293 | ASENHA_SLUG, // Settings page slug |
| 294 | 'main-section', // Section ID |
| 295 | array( |
| 296 | 'field_id' => $field_id, // Custom argument |
| 297 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 298 | 'field_label' => 'Show excerpt column.', // Custom argument |
| 299 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 300 | ) |
| 301 | ); |
| 302 | |
| 303 | // Show ID Column |
| 304 | |
| 305 | $field_id = 'show_id_column'; |
| 306 | $field_slug = 'show-id-column'; |
| 307 | |
| 308 | add_settings_field( |
| 309 | $field_id, // Field ID |
| 310 | '', // Field title |
| 311 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 312 | ASENHA_SLUG, // Settings page slug |
| 313 | 'main-section', // Section ID |
| 314 | array( |
| 315 | 'field_id' => $field_id, // Custom argument |
| 316 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 317 | 'field_label' => 'Show ID column.', // Custom argument |
| 318 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 319 | ) |
| 320 | ); |
| 321 | |
| 322 | // Hide Comments Column |
| 323 | |
| 324 | $field_id = 'hide_comments_column'; |
| 325 | $field_slug = 'hide-comments-column'; |
| 326 | |
| 327 | add_settings_field( |
| 328 | $field_id, // Field ID |
| 329 | '', // Field title |
| 330 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 331 | ASENHA_SLUG, // Settings page slug |
| 332 | 'main-section', // Section ID |
| 333 | array( |
| 334 | 'field_id' => $field_id, // Custom argument |
| 335 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 336 | 'field_label' => 'Remove comments column.', // Custom argument |
| 337 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 338 | ) |
| 339 | ); |
| 340 | |
| 341 | // Hide Post Tags Column |
| 342 | |
| 343 | $field_id = 'hide_post_tags_column'; |
| 344 | $field_slug = 'hide-post-tags-column'; |
| 345 | |
| 346 | add_settings_field( |
| 347 | $field_id, // Field ID |
| 348 | '', // Field title |
| 349 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 350 | ASENHA_SLUG, // Settings page slug |
| 351 | 'main-section', // Section ID |
| 352 | array( |
| 353 | 'field_id' => $field_id, // Custom argument |
| 354 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 355 | 'field_label' => 'Remove tags column (for posts).', // Custom argument |
| 356 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 357 | ) |
| 358 | ); |
| 359 | |
| 360 | // Show Custom Taxonomy Filters |
| 361 | |
| 362 | $field_id = 'show_custom_taxonomy_filters'; |
| 363 | $field_slug = 'show-custom-taxonomy-filters'; |
| 364 | |
| 365 | add_settings_field( |
| 366 | $field_id, // Field ID |
| 367 | '', // Field title |
| 368 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 369 | ASENHA_SLUG, // Settings page slug |
| 370 | 'main-section', // Section ID |
| 371 | array( |
| 372 | 'field_id' => $field_id, // Custom argument |
| 373 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 374 | 'field_label' => 'Show additional filter(s) for hierarchical, custom taxonomies.', // Custom argument |
| 375 | 'class' => 'asenha-checkbox asenha-hide-th content-management ' . $field_slug, // Custom class for the <tr> element |
| 376 | ) |
| 377 | ); |
| 378 | |
| 379 | // ================================================================= |
| 380 | // ADMIN INTERFACE |
| 381 | // ================================================================= |
| 382 | |
| 383 | // Hide Admin Notices |
| 384 | |
| 385 | $field_id = 'hide_admin_notices'; |
| 386 | $field_slug = 'hide-admin-notices'; |
| 387 | |
| 388 | add_settings_field( |
| 389 | $field_id, // Field ID |
| 390 | 'Hide Admin Notices', // Field title |
| 391 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 392 | ASENHA_SLUG, // Settings page slug |
| 393 | 'main-section', // Section ID |
| 394 | array( |
| 395 | 'field_id' => $field_id, // Custom argument |
| 396 | 'field_slug' => $field_slug, // Custom argument |
| 397 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 398 | 'field_description' => 'Clean up admin pages by moving notices into a separate panel easily accessible via the admin bar.', // Custom argument |
| 399 | 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 400 | ) |
| 401 | ); |
| 402 | |
| 403 | // Disable Dashboard Widgets |
| 404 | |
| 405 | $field_id = 'disable_dashboard_widgets'; |
| 406 | $field_slug = 'disable-dashboard-widgets'; |
| 407 | |
| 408 | add_settings_field( |
| 409 | $field_id, // Field ID |
| 410 | 'Disable Dashboard Widgets', // Field title |
| 411 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 412 | ASENHA_SLUG, // Settings page slug |
| 413 | 'main-section', // Section ID |
| 414 | array( |
| 415 | 'field_id' => $field_id, // Custom argument |
| 416 | 'field_slug' => $field_slug, // Custom argument |
| 417 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 418 | '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 |
| 419 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 420 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 421 | 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 422 | ) |
| 423 | ); |
| 424 | |
| 425 | $field_id = 'disabled_dashboard_widgets'; |
| 426 | $field_slug = 'disabled-dashboard-widgets'; |
| 427 | |
| 428 | $extra_options = get_option( 'admin_site_enhancements_extra', array() ); |
| 429 | if ( array_key_exists( 'dashboard_widgets', $extra_options ) ) { |
| 430 | $dashboard_widgets = $extra_options['dashboard_widgets']; |
| 431 | } else { |
| 432 | $admin_interface = new Admin_Interface; |
| 433 | $dashboard_widgets = $admin_interface->get_dashboard_widgets(); |
| 434 | $extra_options['dashboard_widgets'] = $dashboard_widgets; |
| 435 | update_option( 'admin_site_enhancements_extra', $extra_options ); |
| 436 | } |
| 437 | |
| 438 | foreach ( $dashboard_widgets as $widget ) { |
| 439 | add_settings_field( |
| 440 | $field_id . '_' . $widget['id'], // Field ID |
| 441 | '', // Field title |
| 442 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 443 | ASENHA_SLUG, // Settings page slug |
| 444 | 'main-section', // Section ID |
| 445 | array( |
| 446 | 'parent_field_id' => $field_id, // Custom argument |
| 447 | 'field_id' => $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'], // Custom argument |
| 448 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . '][' . $widget['id'] . '__' . $widget['context'] . '__' . $widget['priority'] . ']', // Custom argument |
| 449 | 'field_label' => $widget['title'] . ' <span class="faded">(' . $widget['id'] . ')</span>', // Custom argument |
| 450 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug . ' ' . $widget['id'], // Custom class for the <tr> element |
| 451 | ) |
| 452 | ); |
| 453 | } |
| 454 | |
| 455 | // Hide or Modify Elements |
| 456 | |
| 457 | $field_id = 'hide_modify_elements'; |
| 458 | $field_slug = 'hide-modify-elements'; |
| 459 | |
| 460 | add_settings_field( |
| 461 | $field_id, // Field ID |
| 462 | 'Clean Up Admin Bar', // Field title |
| 463 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 464 | ASENHA_SLUG, // Settings page slug |
| 465 | 'main-section', // Section ID |
| 466 | array( |
| 467 | 'field_id' => $field_id, // Custom argument |
| 468 | 'field_slug' => $field_slug, // Custom argument |
| 469 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 470 | 'field_description' => 'Remove various elements from the admin bar.', // Custom argument |
| 471 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 472 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 473 | 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 474 | ) |
| 475 | ); |
| 476 | |
| 477 | $field_id = 'hide_ab_wp_logo_menu'; |
| 478 | $field_slug = 'hide-ab-wp-logo-menu'; |
| 479 | |
| 480 | add_settings_field( |
| 481 | $field_id, // Field ID |
| 482 | '', // Field title |
| 483 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 484 | ASENHA_SLUG, // Settings page slug |
| 485 | 'main-section', // Section ID |
| 486 | array( |
| 487 | 'field_id' => $field_id, // Custom argument |
| 488 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 489 | 'field_label' => 'Remove WordPress logo/menu', // Custom argument |
| 490 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 491 | ) |
| 492 | ); |
| 493 | |
| 494 | $field_id = 'hide_ab_customize_menu'; |
| 495 | $field_slug = 'hide-ab-customize-menu'; |
| 496 | |
| 497 | add_settings_field( |
| 498 | $field_id, // Field ID |
| 499 | '', // Field title |
| 500 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 501 | ASENHA_SLUG, // Settings page slug |
| 502 | 'main-section', // Section ID |
| 503 | array( |
| 504 | 'field_id' => $field_id, // Custom argument |
| 505 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 506 | 'field_label' => 'Remove customize menu', // Custom argument |
| 507 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 508 | ) |
| 509 | ); |
| 510 | |
| 511 | $field_id = 'hide_ab_updates_menu'; |
| 512 | $field_slug = 'hide-ab-updates-menu'; |
| 513 | |
| 514 | add_settings_field( |
| 515 | $field_id, // Field ID |
| 516 | '', // Field title |
| 517 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 518 | ASENHA_SLUG, // Settings page slug |
| 519 | 'main-section', // Section ID |
| 520 | array( |
| 521 | 'field_id' => $field_id, // Custom argument |
| 522 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 523 | 'field_label' => 'Remove updates counter/link', // Custom argument |
| 524 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 525 | ) |
| 526 | ); |
| 527 | |
| 528 | $field_id = 'hide_ab_comments_menu'; |
| 529 | $field_slug = 'hide-ab-comments-menu'; |
| 530 | |
| 531 | add_settings_field( |
| 532 | $field_id, // Field ID |
| 533 | '', // Field title |
| 534 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 535 | ASENHA_SLUG, // Settings page slug |
| 536 | 'main-section', // Section ID |
| 537 | array( |
| 538 | 'field_id' => $field_id, // Custom argument |
| 539 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 540 | 'field_label' => 'Remove comments counter/link', // Custom argument |
| 541 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 542 | ) |
| 543 | ); |
| 544 | |
| 545 | $field_id = 'hide_ab_new_content_menu'; |
| 546 | $field_slug = 'hide-ab-new-content-menu'; |
| 547 | |
| 548 | add_settings_field( |
| 549 | $field_id, // Field ID |
| 550 | '', // Field title |
| 551 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 552 | ASENHA_SLUG, // Settings page slug |
| 553 | 'main-section', // Section ID |
| 554 | array( |
| 555 | 'field_id' => $field_id, // Custom argument |
| 556 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 557 | 'field_label' => 'Remove new content menu', // Custom argument |
| 558 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 559 | ) |
| 560 | ); |
| 561 | |
| 562 | $field_id = 'hide_ab_howdy'; |
| 563 | $field_slug = 'hide-ab-howdy'; |
| 564 | |
| 565 | add_settings_field( |
| 566 | $field_id, // Field ID |
| 567 | '', // Field title |
| 568 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 569 | ASENHA_SLUG, // Settings page slug |
| 570 | 'main-section', // Section ID |
| 571 | array( |
| 572 | 'field_id' => $field_id, // Custom argument |
| 573 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 574 | 'field_label' => 'Remove \'Howdy\'', // Custom argument |
| 575 | 'class' => 'asenha-checkbox asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 576 | ) |
| 577 | ); |
| 578 | |
| 579 | // Hide Admin Bar |
| 580 | |
| 581 | $field_id = 'hide_admin_bar'; |
| 582 | $field_slug = 'hide-admin-bar'; |
| 583 | |
| 584 | add_settings_field( |
| 585 | $field_id, // Field ID |
| 586 | 'Hide Admin Bar', // Field title |
| 587 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 588 | ASENHA_SLUG, // Settings page slug |
| 589 | 'main-section', // Section ID |
| 590 | array( |
| 591 | 'field_id' => $field_id, // Custom argument |
| 592 | 'field_slug' => $field_slug, // Custom argument |
| 593 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 594 | 'field_description' => 'Hide admin bar on the front end for all or some user roles.', // Custom argument |
| 595 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 596 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 597 | 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 598 | ) |
| 599 | ); |
| 600 | |
| 601 | $field_id = 'hide_admin_bar_for'; |
| 602 | $field_slug = 'hide-admin-bar-for'; |
| 603 | |
| 604 | if ( is_array( $roles ) ) { |
| 605 | foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator |
| 606 | |
| 607 | add_settings_field( |
| 608 | $field_id . '_' . $role_slug, // Field ID |
| 609 | '', // Field title |
| 610 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 611 | ASENHA_SLUG, // Settings page slug |
| 612 | 'main-section', // Section ID |
| 613 | array( |
| 614 | 'parent_field_id' => $field_id, // Custom argument |
| 615 | 'field_id' => $role_slug, // Custom argument |
| 616 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument |
| 617 | 'field_label' => $role_label, // Custom argument |
| 618 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half admin-interface ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element |
| 619 | ) |
| 620 | ); |
| 621 | |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | // Customize Admin Menu |
| 626 | |
| 627 | $field_id = 'customize_admin_menu'; |
| 628 | $field_slug = 'customize-admin-menu'; |
| 629 | |
| 630 | add_settings_field( |
| 631 | $field_id, // Field ID |
| 632 | 'Admin Menu Organizer', // Field title |
| 633 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 634 | ASENHA_SLUG, // Settings page slug |
| 635 | 'main-section', // Section ID |
| 636 | array( |
| 637 | 'field_id' => $field_id, // Custom argument |
| 638 | 'field_slug' => $field_slug, // Custom argument |
| 639 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 640 | 'field_description' => 'Customize the order of the admin menu and optionally change menu item title or hide some items.', // Custom argument |
| 641 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 642 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 643 | 'class' => 'asenha-toggle admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 644 | ) |
| 645 | ); |
| 646 | |
| 647 | $field_id = 'custom_menu_order'; |
| 648 | $field_slug = 'custom-menu-order'; |
| 649 | |
| 650 | add_settings_field( |
| 651 | $field_id, // Field ID |
| 652 | '', // Field title |
| 653 | [ $render_field, 'render_sortable_menu' ], // Callback to render field with custom arguments in the array below |
| 654 | ASENHA_SLUG, // Settings page slug |
| 655 | 'main-section', // Section ID |
| 656 | array( |
| 657 | 'field_id' => $field_id, // Custom argument |
| 658 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 659 | 'field_type' => 'sortable-menu', // Custom argument |
| 660 | 'field_description' => '', // Custom argument |
| 661 | 'class' => 'asenha-sortable asenha-hide-th admin-interface ' . $field_slug, // Custom class for the <tr> element |
| 662 | ) |
| 663 | ); |
| 664 | |
| 665 | // ================================================================= |
| 666 | // LOG IN | LOG OUT |
| 667 | // ================================================================= |
| 668 | |
| 669 | // Change Login URL |
| 670 | |
| 671 | $field_id = 'change_login_url'; |
| 672 | $field_slug = 'change-login-url'; |
| 673 | |
| 674 | add_settings_field( |
| 675 | $field_id, // Field ID |
| 676 | 'Change Login URL', // Field title |
| 677 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 678 | ASENHA_SLUG, // Settings page slug |
| 679 | 'main-section', // Section ID |
| 680 | array( |
| 681 | 'field_id' => $field_id, // Custom argument |
| 682 | 'field_slug' => $field_slug, // Custom argument |
| 683 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 684 | 'field_description' => 'Default is ' . get_site_url() . '/wp-admin/', // Custom argument |
| 685 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 686 | 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element |
| 687 | ) |
| 688 | ); |
| 689 | |
| 690 | $field_id = 'custom_login_slug'; |
| 691 | $field_slug = 'custom-login-slug'; |
| 692 | |
| 693 | add_settings_field( |
| 694 | $field_id, // Field ID |
| 695 | 'New URL:', // Field title |
| 696 | [ $render_field, 'render_text_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 | 'field_id' => $field_id, // Custom argument |
| 701 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 702 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 703 | 'field_prefix' => get_site_url() . '/', // Custom argument |
| 704 | 'field_suffix' => '/', // Custom argument |
| 705 | 'field_description' => '', // Custom argument |
| 706 | 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element |
| 707 | ) |
| 708 | ); |
| 709 | |
| 710 | // Enable Log In/Out Menu |
| 711 | |
| 712 | $field_id = 'enable_login_logout_menu'; |
| 713 | $field_slug = 'enable-login-logout-menu'; |
| 714 | |
| 715 | add_settings_field( |
| 716 | $field_id, // Field ID |
| 717 | 'Log In/Out Menu', // Field title |
| 718 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 719 | ASENHA_SLUG, // Settings page slug |
| 720 | 'main-section', // Section ID |
| 721 | array( |
| 722 | 'field_id' => $field_id, // Custom argument |
| 723 | 'field_slug' => $field_slug, // Custom argument |
| 724 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 725 | 'field_description' => 'Enable log in, log out and dynamic log in/out menu item for addition to any menu.', // Custom argument |
| 726 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 727 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 728 | 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element |
| 729 | ) |
| 730 | ); |
| 731 | |
| 732 | // Enable Last Login Column |
| 733 | |
| 734 | $field_id = 'enable_last_login_column'; |
| 735 | $field_slug = 'enable-last-login-column'; |
| 736 | |
| 737 | add_settings_field( |
| 738 | $field_id, // Field ID |
| 739 | 'Last Login Column', // Field title |
| 740 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 741 | ASENHA_SLUG, // Settings page slug |
| 742 | 'main-section', // Section ID |
| 743 | array( |
| 744 | 'field_id' => $field_id, // Custom argument |
| 745 | 'field_slug' => $field_slug, // Custom argument |
| 746 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 747 | 'field_description' => 'Log when users on the site last logged in and display the date and time in the users list table.', // Custom argument |
| 748 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 749 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 750 | 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element |
| 751 | ) |
| 752 | ); |
| 753 | |
| 754 | // Redirect After Login |
| 755 | |
| 756 | $field_id = 'redirect_after_login'; |
| 757 | $field_slug = 'redirect-after-login'; |
| 758 | |
| 759 | add_settings_field( |
| 760 | $field_id, // Field ID |
| 761 | 'Redirect After Login', // Field title |
| 762 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 763 | ASENHA_SLUG, // Settings page slug |
| 764 | 'main-section', // Section ID |
| 765 | array( |
| 766 | 'field_id' => $field_id, // Custom argument |
| 767 | 'field_slug' => $field_slug, // Custom argument |
| 768 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 769 | 'field_description' => 'Set custom redirect URL for all or some user roles after login.', // Custom argument |
| 770 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 771 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 772 | 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element |
| 773 | ) |
| 774 | ); |
| 775 | |
| 776 | $field_id = 'redirect_after_login_to_slug'; |
| 777 | $field_slug = 'redirect-after-login-to-slug'; |
| 778 | |
| 779 | add_settings_field( |
| 780 | $field_id, // Field ID |
| 781 | 'Redirect to:', // 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' => '/ for:', // 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 | $field_id = 'redirect_after_login_for'; |
| 797 | $field_slug = 'redirect-after-login-for'; |
| 798 | |
| 799 | if ( is_array( $roles ) ) { |
| 800 | foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator |
| 801 | |
| 802 | add_settings_field( |
| 803 | $field_id . '_' . $role_slug, // Field ID |
| 804 | '', // Field title |
| 805 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 806 | ASENHA_SLUG, // Settings page slug |
| 807 | 'main-section', // Section ID |
| 808 | array( |
| 809 | 'parent_field_id' => $field_id, // Custom argument |
| 810 | 'field_id' => $role_slug, // Custom argument |
| 811 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument |
| 812 | 'field_label' => $role_label, // Custom argument |
| 813 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element |
| 814 | ) |
| 815 | ); |
| 816 | |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | // Redirect After Logout |
| 821 | |
| 822 | $field_id = 'redirect_after_logout'; |
| 823 | $field_slug = 'redirect-after-logout'; |
| 824 | |
| 825 | add_settings_field( |
| 826 | $field_id, // Field ID |
| 827 | 'Redirect After Logout', // Field title |
| 828 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 829 | ASENHA_SLUG, // Settings page slug |
| 830 | 'main-section', // Section ID |
| 831 | array( |
| 832 | 'field_id' => $field_id, // Custom argument |
| 833 | 'field_slug' => $field_slug, // Custom argument |
| 834 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 835 | 'field_description' => 'Set custom redirect URL for all or some user roles after logout.', // Custom argument |
| 836 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 837 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 838 | 'class' => 'asenha-toggle login-logout ' . $field_slug, // Custom class for the <tr> element |
| 839 | ) |
| 840 | ); |
| 841 | |
| 842 | $field_id = 'redirect_after_logout_to_slug'; |
| 843 | $field_slug = 'redirect-after-logout-to-slug'; |
| 844 | |
| 845 | add_settings_field( |
| 846 | $field_id, // Field ID |
| 847 | 'Redirect to:', // Field title |
| 848 | [ $render_field, 'render_text_subfield' ], // 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_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 854 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 855 | 'field_prefix' => get_site_url() . '/', // Custom argument |
| 856 | 'field_suffix' => '/ for:', // Custom argument |
| 857 | 'field_description' => '', // Custom argument |
| 858 | 'class' => 'asenha-text with-prefix-suffix login-logout ' . $field_slug, // Custom class for the <tr> element |
| 859 | ) |
| 860 | ); |
| 861 | |
| 862 | $field_id = 'redirect_after_logout_for'; |
| 863 | $field_slug = 'redirect-after-logout-for'; |
| 864 | |
| 865 | if ( is_array( $roles ) ) { |
| 866 | foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator |
| 867 | |
| 868 | add_settings_field( |
| 869 | $field_id . '_' . $role_slug, // Field ID |
| 870 | '', // Field title |
| 871 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 872 | ASENHA_SLUG, // Settings page slug |
| 873 | 'main-section', // Section ID |
| 874 | array( |
| 875 | 'parent_field_id' => $field_id, // Custom argument |
| 876 | 'field_id' => $role_slug, // Custom argument |
| 877 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $role_slug . ']', // Custom argument |
| 878 | 'field_label' => $role_label, // Custom argument |
| 879 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half login-logout ' . $field_slug . ' ' . $role_slug, // Custom class for the <tr> element |
| 880 | ) |
| 881 | ); |
| 882 | |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | // ================================================================= |
| 887 | // CUSTOM CODE |
| 888 | // ================================================================= |
| 889 | |
| 890 | // Enable Custom Admin CSS |
| 891 | |
| 892 | $field_id = 'enable_custom_admin_css'; |
| 893 | $field_slug = 'enable-custom-admin-css'; |
| 894 | |
| 895 | add_settings_field( |
| 896 | $field_id, // Field ID |
| 897 | 'Custom Admin CSS', // Field title |
| 898 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 899 | ASENHA_SLUG, // Settings page slug |
| 900 | 'main-section', // Section ID |
| 901 | array( |
| 902 | 'field_id' => $field_id, // Custom argument |
| 903 | 'field_slug' => $field_slug, // Custom argument |
| 904 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 905 | 'field_description' => 'Add custom CSS on all admin pages for all user roles.', // Custom argument |
| 906 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 907 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 908 | 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element |
| 909 | ) |
| 910 | ); |
| 911 | |
| 912 | $field_id = 'custom_admin_css'; |
| 913 | $field_slug = 'custom-admin-css'; |
| 914 | |
| 915 | add_settings_field( |
| 916 | $field_id, // Field ID |
| 917 | '', // Field title |
| 918 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 919 | ASENHA_SLUG, // Settings page slug |
| 920 | 'main-section', // Section ID |
| 921 | array( |
| 922 | 'field_id' => $field_id, // Custom argument |
| 923 | 'field_slug' => $field_slug, // Custom argument |
| 924 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 925 | 'field_type' => 'textarea', // Custom argument |
| 926 | 'field_intro' => '', // Custom argument |
| 927 | 'field_description' => '', // Custom argument |
| 928 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 929 | ) |
| 930 | ); |
| 931 | |
| 932 | // Enable Custom Frontend CSS |
| 933 | |
| 934 | $field_id = 'enable_custom_frontend_css'; |
| 935 | $field_slug = 'enable-custom-frontend-css'; |
| 936 | |
| 937 | add_settings_field( |
| 938 | $field_id, // Field ID |
| 939 | 'Custom Frontend CSS', // Field title |
| 940 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 941 | ASENHA_SLUG, // Settings page slug |
| 942 | 'main-section', // Section ID |
| 943 | array( |
| 944 | 'field_id' => $field_id, // Custom argument |
| 945 | 'field_slug' => $field_slug, // Custom argument |
| 946 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 947 | 'field_description' => 'Add custom CSS on all frontend pages for all user roles.', // Custom argument |
| 948 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 949 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 950 | 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element |
| 951 | ) |
| 952 | ); |
| 953 | |
| 954 | $field_id = 'custom_frontend_css'; |
| 955 | $field_slug = 'custom-frontend-css'; |
| 956 | |
| 957 | add_settings_field( |
| 958 | $field_id, // Field ID |
| 959 | '', // Field title |
| 960 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 961 | ASENHA_SLUG, // Settings page slug |
| 962 | 'main-section', // Section ID |
| 963 | array( |
| 964 | 'field_id' => $field_id, // Custom argument |
| 965 | 'field_slug' => $field_slug, // Custom argument |
| 966 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 967 | 'field_type' => 'textarea', // Custom argument |
| 968 | 'field_intro' => '', // Custom argument |
| 969 | 'field_description' => '', // Custom argument |
| 970 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 971 | ) |
| 972 | ); |
| 973 | |
| 974 | // Manage ads.txt and app-ads.txt |
| 975 | |
| 976 | $field_id = 'manage_ads_appads_txt'; |
| 977 | $field_slug = 'manage-ads-appads-txt'; |
| 978 | |
| 979 | add_settings_field( |
| 980 | $field_id, // Field ID |
| 981 | 'Manage ads.txt and app-ads.txt', // Field title |
| 982 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 983 | ASENHA_SLUG, // Settings page slug |
| 984 | 'main-section', // Section ID |
| 985 | array( |
| 986 | 'field_id' => $field_id, // Custom argument |
| 987 | 'field_slug' => $field_slug, // Custom argument |
| 988 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 989 | '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 |
| 990 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 991 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 992 | 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element |
| 993 | ) |
| 994 | ); |
| 995 | |
| 996 | $field_id = 'ads_txt_content'; |
| 997 | $field_slug = 'ads-txt-content'; |
| 998 | |
| 999 | add_settings_field( |
| 1000 | $field_id, // Field ID |
| 1001 | '', // Field title |
| 1002 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1003 | ASENHA_SLUG, // Settings page slug |
| 1004 | 'main-section', // Section ID |
| 1005 | array( |
| 1006 | 'field_id' => $field_id, // Custom argument |
| 1007 | 'field_slug' => $field_slug, // Custom argument |
| 1008 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1009 | 'field_type' => 'textarea', // Custom argument |
| 1010 | 'field_intro' => '<strong>Your ads.txt content:</strong>', // Custom argument |
| 1011 | '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 |
| 1012 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1013 | ) |
| 1014 | ); |
| 1015 | |
| 1016 | $field_id = 'app_ads_txt_content'; |
| 1017 | $field_slug = 'app-ads-txt-content'; |
| 1018 | |
| 1019 | add_settings_field( |
| 1020 | $field_id, // Field ID |
| 1021 | '', // Field title |
| 1022 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1023 | ASENHA_SLUG, // Settings page slug |
| 1024 | 'main-section', // Section ID |
| 1025 | array( |
| 1026 | 'field_id' => $field_id, // Custom argument |
| 1027 | 'field_slug' => $field_slug, // Custom argument |
| 1028 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1029 | 'field_type' => 'textarea', // Custom argument |
| 1030 | 'field_intro' => '<strong>Your app-ads.txt content:</strong>', // Custom argument |
| 1031 | '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 |
| 1032 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1033 | ) |
| 1034 | ); |
| 1035 | |
| 1036 | // Manage robots.txt |
| 1037 | |
| 1038 | $field_id = 'manage_robots_txt'; |
| 1039 | $field_slug = 'manage-robots-txt'; |
| 1040 | |
| 1041 | add_settings_field( |
| 1042 | $field_id, // Field ID |
| 1043 | 'Manage robots.txt', // Field title |
| 1044 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1045 | ASENHA_SLUG, // Settings page slug |
| 1046 | 'main-section', // Section ID |
| 1047 | array( |
| 1048 | 'field_id' => $field_id, // Custom argument |
| 1049 | 'field_slug' => $field_slug, // Custom argument |
| 1050 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1051 | 'field_description' => 'Easily edit and validate your <a href="/robots.txt" target="_blank">robots.txt</a> content.', // Custom argument |
| 1052 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 1053 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1054 | 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1055 | ) |
| 1056 | ); |
| 1057 | |
| 1058 | $field_id = 'robots_txt_content'; |
| 1059 | $field_slug = 'robots-txt-content'; |
| 1060 | |
| 1061 | add_settings_field( |
| 1062 | $field_id, // Field ID |
| 1063 | '', // Field title |
| 1064 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1065 | ASENHA_SLUG, // Settings page slug |
| 1066 | 'main-section', // Section ID |
| 1067 | array( |
| 1068 | 'field_id' => $field_id, // Custom argument |
| 1069 | 'field_slug' => $field_slug, // Custom argument |
| 1070 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1071 | 'field_type' => 'textarea', // Custom argument |
| 1072 | 'field_intro' => '', // Custom argument |
| 1073 | '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 |
| 1074 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1075 | ) |
| 1076 | ); |
| 1077 | |
| 1078 | // Insert <head>, <body> and <footer> code |
| 1079 | |
| 1080 | $field_id = 'insert_head_body_footer_code'; |
| 1081 | $field_slug = 'insert-head-body-footer-code'; |
| 1082 | |
| 1083 | add_settings_field( |
| 1084 | $field_id, // Field ID |
| 1085 | 'Insert <head>, <body> and <footer> Code', // Field title |
| 1086 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1087 | ASENHA_SLUG, // Settings page slug |
| 1088 | 'main-section', // Section ID |
| 1089 | array( |
| 1090 | 'field_id' => $field_id, // Custom argument |
| 1091 | 'field_slug' => $field_slug, // Custom argument |
| 1092 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1093 | 'field_description' => 'Easily insert <meta>, <link>, <script> and <style> tags, Google Analytics, Tag Manager, AdSense, Ads Conversion and Optimize code, Facebook, TikTok and Twitter pixels, etc.', // Custom argument |
| 1094 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options. |
| 1095 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1096 | 'class' => 'asenha-toggle custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1097 | ) |
| 1098 | ); |
| 1099 | |
| 1100 | $field_id = 'head_code_priority'; |
| 1101 | $field_slug = 'head-code-priority'; |
| 1102 | |
| 1103 | add_settings_field( |
| 1104 | $field_id, // Field ID |
| 1105 | '', // Field title |
| 1106 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1107 | ASENHA_SLUG, // Settings page slug |
| 1108 | 'main-section', // Section ID |
| 1109 | array( |
| 1110 | 'field_id' => $field_id, // Custom argument |
| 1111 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1112 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1113 | 'field_prefix' => '<strong>Code to insert before </head> with the priority of</strong>', // Custom argument |
| 1114 | 'field_suffix' => '', // Custom argument |
| 1115 | 'field_intro' => '', // Custom argument |
| 1116 | 'field_description' => 'Default is 10. Larger number insert code closer to </head>', // Custom argument |
| 1117 | 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1118 | ) |
| 1119 | ); |
| 1120 | |
| 1121 | $field_id = 'head_code'; |
| 1122 | $field_slug = 'head-code'; |
| 1123 | |
| 1124 | add_settings_field( |
| 1125 | $field_id, // Field ID |
| 1126 | '', // Field title |
| 1127 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1128 | ASENHA_SLUG, // Settings page slug |
| 1129 | 'main-section', // Section ID |
| 1130 | array( |
| 1131 | 'field_id' => $field_id, // Custom argument |
| 1132 | 'field_slug' => $field_slug, // Custom argument |
| 1133 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1134 | 'field_type' => 'textarea', // Custom argument |
| 1135 | 'field_intro' => '', // Custom argument |
| 1136 | 'field_description' => '', // Custom argument |
| 1137 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1138 | ) |
| 1139 | ); |
| 1140 | |
| 1141 | $field_id = 'body_code_priority'; |
| 1142 | $field_slug = 'body-code-priority'; |
| 1143 | |
| 1144 | add_settings_field( |
| 1145 | $field_id, // Field ID |
| 1146 | '', // Field title |
| 1147 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1148 | ASENHA_SLUG, // Settings page slug |
| 1149 | 'main-section', // Section ID |
| 1150 | array( |
| 1151 | 'field_id' => $field_id, // Custom argument |
| 1152 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1153 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1154 | 'field_prefix' => '<strong>Code to insert after <body> with the priority of</strong>', // Custom argument |
| 1155 | 'field_suffix' => '', // Custom argument |
| 1156 | 'field_intro' => '', // Custom argument |
| 1157 | 'field_description' => 'Default is 10. Smaller number insert code closer to <body>', // Custom argument |
| 1158 | 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1159 | ) |
| 1160 | ); |
| 1161 | |
| 1162 | $field_id = 'body_code'; |
| 1163 | $field_slug = 'body-code'; |
| 1164 | |
| 1165 | add_settings_field( |
| 1166 | $field_id, // Field ID |
| 1167 | '', // Field title |
| 1168 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1169 | ASENHA_SLUG, // Settings page slug |
| 1170 | 'main-section', // Section ID |
| 1171 | array( |
| 1172 | 'field_id' => $field_id, // Custom argument |
| 1173 | 'field_slug' => $field_slug, // Custom argument |
| 1174 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1175 | 'field_type' => 'textarea', // Custom argument |
| 1176 | 'field_intro' => '', // Custom argument |
| 1177 | 'field_description' => '', // Custom argument |
| 1178 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1179 | ) |
| 1180 | ); |
| 1181 | |
| 1182 | $field_id = 'footer_code_priority'; |
| 1183 | $field_slug = 'footer-code-priority'; |
| 1184 | |
| 1185 | add_settings_field( |
| 1186 | $field_id, // Field ID |
| 1187 | '', // Field title |
| 1188 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1189 | ASENHA_SLUG, // Settings page slug |
| 1190 | 'main-section', // Section ID |
| 1191 | array( |
| 1192 | 'field_id' => $field_id, // Custom argument |
| 1193 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1194 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1195 | 'field_prefix' => '<strong>Code to insert in footer section before </body>: with the priority of</strong>', // Custom argument |
| 1196 | 'field_suffix' => '', // Custom argument |
| 1197 | 'field_intro' => '', // Custom argument |
| 1198 | 'field_description' => 'Default is 10. Larger number insert code closer to </body>', // Custom argument |
| 1199 | 'class' => 'asenha-number asenha-hide-th narrow custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1200 | ) |
| 1201 | ); |
| 1202 | |
| 1203 | $field_id = 'footer_code'; |
| 1204 | $field_slug = 'footer-code'; |
| 1205 | |
| 1206 | add_settings_field( |
| 1207 | $field_id, // Field ID |
| 1208 | '', // Field title |
| 1209 | [ $render_field, 'render_textarea_subfield' ], // Callback to render field with custom arguments in the array below |
| 1210 | ASENHA_SLUG, // Settings page slug |
| 1211 | 'main-section', // Section ID |
| 1212 | array( |
| 1213 | 'field_id' => $field_id, // Custom argument |
| 1214 | 'field_slug' => $field_slug, // Custom argument |
| 1215 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1216 | 'field_type' => 'textarea', // Custom argument |
| 1217 | 'field_intro' => '', // Custom argument |
| 1218 | 'field_description' => '', // Custom argument |
| 1219 | 'class' => 'asenha-textarea asenha-hide-th syntax-highlighted custom-code ' . $field_slug, // Custom class for the <tr> element |
| 1220 | ) |
| 1221 | ); |
| 1222 | |
| 1223 | // ================================================================= |
| 1224 | // DISABLE COMPONENTS |
| 1225 | // ================================================================= |
| 1226 | |
| 1227 | // Disable Gutenberg |
| 1228 | |
| 1229 | $field_id = 'disable_gutenberg'; |
| 1230 | $field_slug = 'disable-gutenberg'; |
| 1231 | |
| 1232 | add_settings_field( |
| 1233 | $field_id, // Field ID |
| 1234 | 'Disable Gutenberg', // Field title |
| 1235 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1236 | ASENHA_SLUG, // Settings page slug |
| 1237 | 'main-section', // Section ID |
| 1238 | array( |
| 1239 | 'field_id' => $field_id, // Custom argument |
| 1240 | 'field_slug' => $field_slug, // Custom argument |
| 1241 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1242 | 'field_description' => 'Disable the Gutenberg block editor for some or all applicable post types.', // Custom argument |
| 1243 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1244 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1245 | 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1246 | ) |
| 1247 | ); |
| 1248 | |
| 1249 | $field_id = 'disable_gutenberg_for'; |
| 1250 | $field_slug = 'disable-gutenberg-for'; |
| 1251 | |
| 1252 | if ( is_array( $asenha_gutenberg_post_types ) ) { |
| 1253 | foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts |
| 1254 | add_settings_field( |
| 1255 | $field_id . '_' . $post_type_slug, // Field ID |
| 1256 | '', // Field title |
| 1257 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 1258 | ASENHA_SLUG, // Settings page slug |
| 1259 | 'main-section', // Section ID |
| 1260 | array( |
| 1261 | 'parent_field_id' => $field_id, // Custom argument |
| 1262 | 'field_id' => $post_type_slug, // Custom argument |
| 1263 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument |
| 1264 | 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument |
| 1265 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element |
| 1266 | ) |
| 1267 | ); |
| 1268 | } |
| 1269 | } |
| 1270 | |
| 1271 | $field_id = 'disable_gutenberg_frontend_styles'; |
| 1272 | $field_slug = 'disable-gutenberg-frontend-styles'; |
| 1273 | |
| 1274 | add_settings_field( |
| 1275 | $field_id, // Field ID |
| 1276 | '', // Field title |
| 1277 | [ $render_field, 'render_checkbox_plain' ], // Callback to render field with custom arguments in the array below |
| 1278 | ASENHA_SLUG, // Settings page slug |
| 1279 | 'main-section', // Section ID |
| 1280 | array( |
| 1281 | 'field_id' => $field_id, // Custom argument |
| 1282 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 1283 | 'field_label' => 'Also disable frontend block styles / CSS files for the selected post types.', // Custom argument |
| 1284 | 'class' => 'asenha-checkbox asenha-hide-th asenha-th-border-top disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1285 | ) |
| 1286 | ); |
| 1287 | |
| 1288 | // Disable Comments |
| 1289 | |
| 1290 | $field_id = 'disable_comments'; |
| 1291 | $field_slug = 'disable-comments'; |
| 1292 | |
| 1293 | add_settings_field( |
| 1294 | $field_id, // Field ID |
| 1295 | 'Disable Comments', // Field title |
| 1296 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1297 | ASENHA_SLUG, // Settings page slug |
| 1298 | 'main-section', // Section ID |
| 1299 | array( |
| 1300 | 'field_id' => $field_id, // Custom argument |
| 1301 | 'field_slug' => $field_slug, // Custom argument |
| 1302 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1303 | 'field_description' => 'Disable comments for some or all public post types. When disabled, existing comments will also be hidden on the frontend.', // Custom argument |
| 1304 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1305 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1306 | 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1307 | ) |
| 1308 | ); |
| 1309 | |
| 1310 | $field_id = 'disable_comments_for'; |
| 1311 | $field_slug = 'disable-comments-for'; |
| 1312 | |
| 1313 | if ( is_array( $asenha_public_post_types ) ) { |
| 1314 | foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts |
| 1315 | add_settings_field( |
| 1316 | $field_id . '_' . $post_type_slug, // Field ID |
| 1317 | '', // Field title |
| 1318 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 1319 | ASENHA_SLUG, // Settings page slug |
| 1320 | 'main-section', // Section ID |
| 1321 | array( |
| 1322 | 'parent_field_id' => $field_id, // Custom argument |
| 1323 | 'field_id' => $post_type_slug, // Custom argument |
| 1324 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument |
| 1325 | 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument |
| 1326 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half disable-components ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element |
| 1327 | ) |
| 1328 | ); |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | // Disable REST API |
| 1333 | |
| 1334 | $field_id = 'disable_rest_api'; |
| 1335 | $field_slug = 'disable-rest-api'; |
| 1336 | |
| 1337 | add_settings_field( |
| 1338 | $field_id, // Field ID |
| 1339 | 'Disable REST API', // Field title |
| 1340 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1341 | ASENHA_SLUG, // Settings page slug |
| 1342 | 'main-section', // Section ID |
| 1343 | array( |
| 1344 | 'field_id' => $field_id, // Custom argument |
| 1345 | 'field_slug' => $field_slug, // Custom argument |
| 1346 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1347 | 'field_description' => 'Disable REST API access for non-authenticated users and remove URL traces from <head>, HTTP headers and WP RSD endpoint.', // Custom argument |
| 1348 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1349 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1350 | 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1351 | ) |
| 1352 | ); |
| 1353 | |
| 1354 | // Disable Feeds |
| 1355 | |
| 1356 | $field_id = 'disable_feeds'; |
| 1357 | $field_slug = 'disable-feeds'; |
| 1358 | |
| 1359 | add_settings_field( |
| 1360 | $field_id, // Field ID |
| 1361 | 'Disable Feeds', // Field title |
| 1362 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1363 | ASENHA_SLUG, // Settings page slug |
| 1364 | 'main-section', // Section ID |
| 1365 | array( |
| 1366 | 'field_id' => $field_id, // Custom argument |
| 1367 | 'field_slug' => $field_slug, // Custom argument |
| 1368 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1369 | '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 <head>.', // Custom argument |
| 1370 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1371 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1372 | 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1373 | ) |
| 1374 | ); |
| 1375 | |
| 1376 | // Disable Auto Updates |
| 1377 | |
| 1378 | $field_id = 'disable_all_updates'; |
| 1379 | $field_slug = 'disable-all-updates'; |
| 1380 | |
| 1381 | add_settings_field( |
| 1382 | $field_id, // Field ID |
| 1383 | 'Disable All Updates', // Field title |
| 1384 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1385 | ASENHA_SLUG, // Settings page slug |
| 1386 | 'main-section', // Section ID |
| 1387 | array( |
| 1388 | 'field_id' => $field_id, // Custom argument |
| 1389 | 'field_slug' => $field_slug, // Custom argument |
| 1390 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1391 | 'field_description' => 'Completely disable core, theme and plugin updates and auto-updates. Will also disable update checks, notices and emails.', // Custom argument |
| 1392 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1393 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1394 | 'class' => 'asenha-toggle disable-components ' . $field_slug, // Custom class for the <tr> element |
| 1395 | ) |
| 1396 | ); |
| 1397 | |
| 1398 | // ================================================================= |
| 1399 | // SECURITY |
| 1400 | // ================================================================= |
| 1401 | |
| 1402 | // Limit Login Attempts |
| 1403 | |
| 1404 | $field_id = 'limit_login_attempts'; |
| 1405 | $field_slug = 'limit-login-attempts'; |
| 1406 | |
| 1407 | add_settings_field( |
| 1408 | $field_id, // Field ID |
| 1409 | 'Limit Login Attempts', // Field title |
| 1410 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1411 | ASENHA_SLUG, // Settings page slug |
| 1412 | 'main-section', // Section ID |
| 1413 | array( |
| 1414 | 'field_id' => $field_id, // Custom argument |
| 1415 | 'field_slug' => $field_slug, // Custom argument |
| 1416 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1417 | 'field_description' => 'Prevent brute force attacks by limiting the number of failed login attempts allowed per IP address.', // Custom argument |
| 1418 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1419 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1420 | 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element |
| 1421 | ) |
| 1422 | ); |
| 1423 | |
| 1424 | $field_id = 'login_fails_allowed'; |
| 1425 | $field_slug = 'login-fails-allowed'; |
| 1426 | |
| 1427 | add_settings_field( |
| 1428 | $field_id, // Field ID |
| 1429 | '', // Field title |
| 1430 | [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below |
| 1431 | ASENHA_SLUG, // Settings page slug |
| 1432 | 'main-section', // Section ID |
| 1433 | array( |
| 1434 | 'field_id' => $field_id, // Custom argument |
| 1435 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1436 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1437 | 'field_prefix' => '', // Custom argument |
| 1438 | 'field_suffix' => 'failed login attempts allowed before 15 minutes lockout', // Custom argument |
| 1439 | 'field_description' => '', // Custom argument |
| 1440 | 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element |
| 1441 | ) |
| 1442 | ); |
| 1443 | |
| 1444 | $field_id = 'login_lockout_maxcount'; |
| 1445 | $field_slug = 'login-lockout-maxcount'; |
| 1446 | |
| 1447 | add_settings_field( |
| 1448 | $field_id, // Field ID |
| 1449 | '', // Field title |
| 1450 | [ $render_field, 'render_text_subfield' ], // Callback to render field with custom arguments in the array below |
| 1451 | ASENHA_SLUG, // Settings page slug |
| 1452 | 'main-section', // Section ID |
| 1453 | array( |
| 1454 | 'field_id' => $field_id, // Custom argument |
| 1455 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1456 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1457 | 'field_prefix' => '', // Custom argument |
| 1458 | 'field_suffix' => 'lockout(s) will block further login attempts for 24 hours', // Custom argument |
| 1459 | 'field_description' => '', // Custom argument |
| 1460 | 'class' => 'asenha-text with-prefix-suffix narrow no-margin security ' . $field_slug, // Custom class for the <tr> element |
| 1461 | ) |
| 1462 | ); |
| 1463 | |
| 1464 | $field_id = 'login_attempts_log_table'; |
| 1465 | $field_slug = 'login-attempts-log-table'; |
| 1466 | |
| 1467 | add_settings_field( |
| 1468 | $field_id, // Field ID |
| 1469 | '', // Field title |
| 1470 | [ $render_field, 'render_datatable' ], // 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_type' => 'datatable', // Custom argument |
| 1478 | 'field_description' => '', // Custom argument |
| 1479 | 'class' => 'asenha-text datatable asenha-hide-th security ' . $field_slug, // Custom class for the <tr> element |
| 1480 | 'table_title' => 'Failed Login Attempts Log', |
| 1481 | 'table_name' => $wpdb->prefix . 'asenha_failed_logins', |
| 1482 | ) |
| 1483 | ); |
| 1484 | |
| 1485 | // Obfuscate Author Slugs |
| 1486 | |
| 1487 | $field_id = 'obfuscate_author_slugs'; |
| 1488 | $field_slug = 'obfuscate-author-slugs'; |
| 1489 | |
| 1490 | add_settings_field( |
| 1491 | $field_id, // Field ID |
| 1492 | 'Obfuscate Author Slugs', // Field title |
| 1493 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1494 | ASENHA_SLUG, // Settings page slug |
| 1495 | 'main-section', // Section ID |
| 1496 | array( |
| 1497 | 'field_id' => $field_id, // Custom argument |
| 1498 | 'field_slug' => $field_slug, // Custom argument |
| 1499 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1500 | '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 |
| 1501 | 'field_options_wrapper' => false, // Custom argument. Add container for additional options |
| 1502 | 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element |
| 1503 | ) |
| 1504 | ); |
| 1505 | |
| 1506 | // Disable XML-RPC |
| 1507 | |
| 1508 | $field_id = 'disable_xmlrpc'; |
| 1509 | $field_slug = 'disable-xmlrpc'; |
| 1510 | |
| 1511 | add_settings_field( |
| 1512 | $field_id, // Field ID |
| 1513 | 'Disable XML-RPC', // Field title |
| 1514 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1515 | ASENHA_SLUG, // Settings page slug |
| 1516 | 'main-section', // Section ID |
| 1517 | array( |
| 1518 | 'field_id' => $field_id, // Custom argument |
| 1519 | 'field_slug' => $field_slug, // Custom argument |
| 1520 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1521 | '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 |
| 1522 | 'field_options_wrapper' => false, // Custom argument. Add container for additional options |
| 1523 | 'class' => 'asenha-toggle security ' . $field_slug, // Custom class for the <tr> element |
| 1524 | ) |
| 1525 | ); |
| 1526 | |
| 1527 | // ================================================================= |
| 1528 | // OPTIMIZATIONS |
| 1529 | // ================================================================= |
| 1530 | |
| 1531 | // Image Upload Control |
| 1532 | |
| 1533 | $field_id = 'image_upload_control'; |
| 1534 | $field_slug = 'image-upload-control'; |
| 1535 | |
| 1536 | add_settings_field( |
| 1537 | $field_id, // Field ID |
| 1538 | 'Image Upload Control', // Field title |
| 1539 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1540 | ASENHA_SLUG, // Settings page slug |
| 1541 | 'main-section', // Section ID |
| 1542 | array( |
| 1543 | 'field_id' => $field_id, // Custom argument |
| 1544 | 'field_slug' => $field_slug, // Custom argument |
| 1545 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1546 | 'field_description' => 'Resize newly uploaded, large images to a smaller dimension and delete originally uploaded files. BMPs and non-transparent PNGs will be converted to JPGs and resized.', // Custom argument |
| 1547 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1548 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1549 | 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1550 | ) |
| 1551 | ); |
| 1552 | |
| 1553 | $field_id = 'image_max_width'; |
| 1554 | $field_slug = 'image-max-width'; |
| 1555 | |
| 1556 | add_settings_field( |
| 1557 | $field_id, // Field ID |
| 1558 | '', // Field title |
| 1559 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1560 | ASENHA_SLUG, // Settings page slug |
| 1561 | 'main-section', // Section ID |
| 1562 | array( |
| 1563 | 'field_id' => $field_id, // Custom argument |
| 1564 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1565 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1566 | 'field_prefix' => 'Max width:', // Custom argument |
| 1567 | 'field_suffix' => 'pixels. <span class="faded">(Default is 1920 pixels)</span>', // Custom argument |
| 1568 | 'field_intro' => '', // Custom argument |
| 1569 | 'field_description' => '', // Custom argument |
| 1570 | 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1571 | ) |
| 1572 | ); |
| 1573 | |
| 1574 | $field_id = 'image_max_height'; |
| 1575 | $field_slug = 'image-max-height'; |
| 1576 | |
| 1577 | add_settings_field( |
| 1578 | $field_id, // Field ID |
| 1579 | '', // Field title |
| 1580 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1581 | ASENHA_SLUG, // Settings page slug |
| 1582 | 'main-section', // Section ID |
| 1583 | array( |
| 1584 | 'field_id' => $field_id, // Custom argument |
| 1585 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1586 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1587 | 'field_prefix' => 'Max height:', // Custom argument |
| 1588 | 'field_suffix' => 'pixels <span class="faded">(Default is 1920 pixels)</span>', // Custom argument |
| 1589 | 'field_intro' => '', // Custom argument |
| 1590 | 'field_description' => 'To exclude an image from conversion and resizing, append \'-nr\' suffix to the file name, e.g. bird-photo-4k-nr.jpg', // Custom argument |
| 1591 | 'class' => 'asenha-number asenha-hide-th narrow optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1592 | ) |
| 1593 | ); |
| 1594 | |
| 1595 | // Enable Revisions Control |
| 1596 | |
| 1597 | $field_id = 'enable_revisions_control'; |
| 1598 | $field_slug = 'enable-revisions-control'; |
| 1599 | |
| 1600 | add_settings_field( |
| 1601 | $field_id, // Field ID |
| 1602 | 'Revisions Control', // Field title |
| 1603 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1604 | ASENHA_SLUG, // Settings page slug |
| 1605 | 'main-section', // Section ID |
| 1606 | array( |
| 1607 | 'field_id' => $field_id, // Custom argument |
| 1608 | 'field_slug' => $field_slug, // Custom argument |
| 1609 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1610 | 'field_description' => 'Prevent bloating the database by limiting the number of revisions to keep for some or all post types supporting revisions.', // Custom argument |
| 1611 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1612 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1613 | 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1614 | ) |
| 1615 | ); |
| 1616 | |
| 1617 | $field_id = 'revisions_max_number'; |
| 1618 | $field_slug = 'revisions-max-number'; |
| 1619 | |
| 1620 | add_settings_field( |
| 1621 | $field_id, // Field ID |
| 1622 | '', // Field title |
| 1623 | [ $render_field, 'render_number_subfield' ], // Callback to render field with custom arguments in the array below |
| 1624 | ASENHA_SLUG, // Settings page slug |
| 1625 | 'main-section', // Section ID |
| 1626 | array( |
| 1627 | 'field_id' => $field_id, // Custom argument |
| 1628 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1629 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1630 | 'field_prefix' => 'Limit to', // Custom argument |
| 1631 | 'field_suffix' => 'revisions for:', // Custom argument |
| 1632 | 'field_intro' => '', // Custom argument |
| 1633 | 'field_description' => '', // Custom argument |
| 1634 | 'class' => 'asenha-number asenha-hide-th extra-narrow optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1635 | ) |
| 1636 | ); |
| 1637 | |
| 1638 | $field_id = 'enable_revisions_control_for'; |
| 1639 | $field_slug = 'enable-revisions-control-for'; |
| 1640 | |
| 1641 | if ( is_array( $asenha_revisions_post_types ) ) { |
| 1642 | foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts |
| 1643 | add_settings_field( |
| 1644 | $field_id . '_' . $post_type_slug, // Field ID |
| 1645 | '', // Field title |
| 1646 | [ $render_field, 'render_checkbox_subfield' ], // Callback to render field with custom arguments in the array below |
| 1647 | ASENHA_SLUG, // Settings page slug |
| 1648 | 'main-section', // Section ID |
| 1649 | array( |
| 1650 | 'parent_field_id' => $field_id, // Custom argument |
| 1651 | 'field_id' => $post_type_slug, // Custom argument |
| 1652 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .'][' . $post_type_slug . ']', // Custom argument |
| 1653 | 'field_label' => $post_type_label . ' <span class="faded">('. $post_type_slug .')</span>', // Custom argument |
| 1654 | 'class' => 'asenha-checkbox asenha-hide-th asenha-half optimizations ' . $field_slug . ' ' . $post_type_slug, // Custom class for the <tr> element |
| 1655 | ) |
| 1656 | ); |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | // Enable Heartbeat Control |
| 1661 | |
| 1662 | $field_id = 'enable_heartbeat_control'; |
| 1663 | $field_slug = 'enable-heartbeat-control'; |
| 1664 | |
| 1665 | add_settings_field( |
| 1666 | $field_id, // Field ID |
| 1667 | 'Heartbeat Control', // Field title |
| 1668 | [ $render_field, 'render_checkbox_toggle' ], // 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_slug' => $field_slug, // Custom argument |
| 1674 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1675 | '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 |
| 1676 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1677 | 'field_options_moreless' => true, // Custom argument. Add show more/less toggler. |
| 1678 | 'class' => 'asenha-toggle optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1679 | ) |
| 1680 | ); |
| 1681 | |
| 1682 | $field_id = 'heartbeat_control_for_admin_pages'; |
| 1683 | $field_slug = 'heartbeat-control-for-admin-pages'; |
| 1684 | |
| 1685 | add_settings_field( |
| 1686 | $field_id, // Field ID |
| 1687 | 'On admin pages', // Field title |
| 1688 | [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below |
| 1689 | ASENHA_SLUG, // Settings page slug |
| 1690 | 'main-section', // Section ID |
| 1691 | array( |
| 1692 | 'field_id' => $field_id, // Custom argument |
| 1693 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 1694 | // 'field_label' => 'Temporary label', // Custom argument |
| 1695 | 'field_radios' => array( |
| 1696 | 'Keep as is' => 'default', |
| 1697 | 'Modify' => 'modify', |
| 1698 | 'Disable' => 'disable', |
| 1699 | ), |
| 1700 | 'field_default' => 'default', |
| 1701 | 'class' => 'asenha-radio-buttons optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1702 | ), |
| 1703 | ); |
| 1704 | |
| 1705 | $field_id = 'heartbeat_interval_for_admin_pages'; |
| 1706 | $field_slug = 'heartbeat-interval-for-admin-pages'; |
| 1707 | |
| 1708 | add_settings_field( |
| 1709 | $field_id, // Field ID |
| 1710 | '', // Field title |
| 1711 | [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below |
| 1712 | ASENHA_SLUG, // Settings page slug |
| 1713 | 'main-section', // Section ID |
| 1714 | array( |
| 1715 | 'field_id' => $field_id, // Custom argument |
| 1716 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1717 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1718 | 'field_prefix' => 'Set interval to once every', // Custom argument |
| 1719 | 'field_suffix' => '<span class="faded">(Default is 1 minute)</span>', // Custom argument |
| 1720 | 'field_select_options' => array( |
| 1721 | '15 seconds' => 15, |
| 1722 | '30 seconds' => 30, |
| 1723 | '1 minute' => 60, |
| 1724 | '2 minutes' => 120, |
| 1725 | '3 minutes' => 180, |
| 1726 | '5 minutes' => 300, |
| 1727 | '10 minutes' => 600, |
| 1728 | ), |
| 1729 | 'field_select_default' => 60, |
| 1730 | 'field_intro' => '', // Custom argument |
| 1731 | 'field_description' => '', // Custom argument |
| 1732 | 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1733 | 'display_none_on_load' => true, |
| 1734 | ) |
| 1735 | ); |
| 1736 | |
| 1737 | $field_id = 'heartbeat_control_for_post_edit'; |
| 1738 | $field_slug = 'heartbeat-control-for-post-edit'; |
| 1739 | |
| 1740 | add_settings_field( |
| 1741 | $field_id, // Field ID |
| 1742 | 'On post creation and edit screens', // Field title |
| 1743 | [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below |
| 1744 | ASENHA_SLUG, // Settings page slug |
| 1745 | 'main-section', // Section ID |
| 1746 | array( |
| 1747 | 'field_id' => $field_id, // Custom argument |
| 1748 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 1749 | // 'field_label' => 'Temporary label', // Custom argument |
| 1750 | 'field_radios' => array( |
| 1751 | 'Keep as is' => 'default', |
| 1752 | 'Modify' => 'modify', |
| 1753 | 'Disable' => 'disable', |
| 1754 | ), |
| 1755 | 'field_default' => 'default', |
| 1756 | 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element |
| 1757 | ), |
| 1758 | ); |
| 1759 | |
| 1760 | $field_id = 'heartbeat_interval_for_post_edit'; |
| 1761 | $field_slug = 'heartbeat-interval-for-post-edit'; |
| 1762 | |
| 1763 | add_settings_field( |
| 1764 | $field_id, // Field ID |
| 1765 | '', // Field title |
| 1766 | [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below |
| 1767 | ASENHA_SLUG, // Settings page slug |
| 1768 | 'main-section', // Section ID |
| 1769 | array( |
| 1770 | 'field_id' => $field_id, // Custom argument |
| 1771 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1772 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1773 | 'field_prefix' => 'Set interval to once every', // Custom argument |
| 1774 | 'field_suffix' => '<span class="faded">(Default is 15 seconds)</span>', // Custom argument |
| 1775 | 'field_select_options' => array( |
| 1776 | '15 seconds' => 15, |
| 1777 | '30 seconds' => 30, |
| 1778 | '45 seconds' => 45, |
| 1779 | '60 seconds' => 60, |
| 1780 | '90 seconds' => 90, |
| 1781 | '120 seconds' => 120 |
| 1782 | ), |
| 1783 | 'field_select_default' => 15, |
| 1784 | 'field_intro' => '', // Custom argument |
| 1785 | 'field_description' => '', // Custom argument |
| 1786 | 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1787 | 'display_none_on_load' => true, |
| 1788 | ) |
| 1789 | ); |
| 1790 | |
| 1791 | $field_id = 'heartbeat_control_for_frontend'; |
| 1792 | $field_slug = 'heartbeat-control-for-frontend'; |
| 1793 | |
| 1794 | add_settings_field( |
| 1795 | $field_id, // Field ID |
| 1796 | 'On the frontend', // Field title |
| 1797 | [ $render_field, 'render_radio_buttons_subfield' ], // Callback to render field with custom arguments in the array below |
| 1798 | ASENHA_SLUG, // Settings page slug |
| 1799 | 'main-section', // Section ID |
| 1800 | array( |
| 1801 | 'field_id' => $field_id, // Custom argument |
| 1802 | 'field_name' => ASENHA_SLUG_U . '[' . $field_id . ']', // Custom argument |
| 1803 | // 'field_label' => 'Temporary label', // Custom argument |
| 1804 | 'field_radios' => array( |
| 1805 | 'Keep as is' => 'default', |
| 1806 | 'Modify' => 'modify', |
| 1807 | 'Disable' => 'disable', |
| 1808 | ), |
| 1809 | 'field_default' => 'default', |
| 1810 | 'class' => 'asenha-radio-buttons optimizations top-border ' . $field_slug, // Custom class for the <tr> element |
| 1811 | ), |
| 1812 | ); |
| 1813 | |
| 1814 | $field_id = 'heartbeat_interval_for_frontend'; |
| 1815 | $field_slug = 'heartbeat-interval-for-frontend'; |
| 1816 | |
| 1817 | add_settings_field( |
| 1818 | $field_id, // Field ID |
| 1819 | '', // Field title |
| 1820 | [ $render_field, 'render_select_subfield' ], // Callback to render field with custom arguments in the array below |
| 1821 | ASENHA_SLUG, // Settings page slug |
| 1822 | 'main-section', // Section ID |
| 1823 | array( |
| 1824 | 'field_id' => $field_id, // Custom argument |
| 1825 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1826 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1827 | 'field_prefix' => 'Set interval to once every', // Custom argument |
| 1828 | 'field_suffix' => '', // Custom argument |
| 1829 | 'field_select_options' => array( |
| 1830 | '15 seconds' => 15, |
| 1831 | '30 seconds' => 30, |
| 1832 | '1 minute' => 60, |
| 1833 | '2 minutes' => 120, |
| 1834 | '3 minutes' => 180, |
| 1835 | '5 minutes' => 300, |
| 1836 | '10 minutes' => 600, |
| 1837 | ), |
| 1838 | 'field_select_default' => 60, |
| 1839 | 'field_intro' => '', // Custom argument |
| 1840 | 'field_description' => '', // Custom argument |
| 1841 | 'class' => 'asenha-number asenha-hide-th extra-narrow shift-up optimizations ' . $field_slug, // Custom class for the <tr> element |
| 1842 | 'display_none_on_load' => true, |
| 1843 | ) |
| 1844 | ); |
| 1845 | |
| 1846 | // ================================================================= |
| 1847 | // UTILITIES |
| 1848 | // ================================================================= |
| 1849 | |
| 1850 | // View Admin as Role |
| 1851 | |
| 1852 | $field_id = 'view_admin_as_role'; |
| 1853 | $field_slug = 'view-admin-as-role'; |
| 1854 | |
| 1855 | add_settings_field( |
| 1856 | $field_id, // Field ID |
| 1857 | 'View Admin as Role', // Field title |
| 1858 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1859 | ASENHA_SLUG, // Settings page slug |
| 1860 | 'main-section', // Section ID |
| 1861 | array( |
| 1862 | 'field_id' => $field_id, // Custom argument |
| 1863 | 'field_slug' => $field_slug, // Custom argument |
| 1864 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1865 | 'field_description' => 'View admin pages and the site (logged-in) as one of the non-administrator user roles.', // Custom argument |
| 1866 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1867 | 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element |
| 1868 | ) |
| 1869 | ); |
| 1870 | |
| 1871 | // Enable Password Protection |
| 1872 | |
| 1873 | $field_id = 'enable_password_protection'; |
| 1874 | $field_slug = 'enable-password-protection'; |
| 1875 | |
| 1876 | add_settings_field( |
| 1877 | $field_id, // Field ID |
| 1878 | 'Password Protection', // Field title |
| 1879 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1880 | ASENHA_SLUG, // Settings page slug |
| 1881 | 'main-section', // Section ID |
| 1882 | array( |
| 1883 | 'field_id' => $field_id, // Custom argument |
| 1884 | 'field_slug' => $field_slug, // Custom argument |
| 1885 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1886 | '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 |
| 1887 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1888 | 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element |
| 1889 | ) |
| 1890 | ); |
| 1891 | |
| 1892 | $field_id = 'password_protection_password'; |
| 1893 | $field_slug = 'password-protection-password'; |
| 1894 | |
| 1895 | add_settings_field( |
| 1896 | $field_id, // Field ID |
| 1897 | 'Set the password:', // Field title |
| 1898 | [ $render_field, 'render_password_subfield' ], // Callback to render field with custom arguments in the array below |
| 1899 | ASENHA_SLUG, // Settings page slug |
| 1900 | 'main-section', // Section ID |
| 1901 | array( |
| 1902 | 'field_id' => $field_id, // Custom argument |
| 1903 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1904 | 'field_type' => 'with-prefix-suffix', // Custom argument |
| 1905 | 'field_prefix' => '', // Custom argument |
| 1906 | 'field_suffix' => '<span class="faded">(Default is \'secret\')</span>', // Custom argument |
| 1907 | 'field_description' => '', // Custom argument |
| 1908 | 'class' => 'asenha-text with-prefix-suffix utilities ' . $field_slug, // Custom class for the <tr> element |
| 1909 | ) |
| 1910 | ); |
| 1911 | |
| 1912 | // Redirect 404 to Homepage |
| 1913 | |
| 1914 | $field_id = 'redirect_404_to_homepage'; |
| 1915 | $field_slug = 'redirect-404-to-homepage'; |
| 1916 | |
| 1917 | add_settings_field( |
| 1918 | $field_id, // Field ID |
| 1919 | 'Redirect 404 to Homepage', // Field title |
| 1920 | [ $render_field, 'render_checkbox_toggle' ], // Callback to render field with custom arguments in the array below |
| 1921 | ASENHA_SLUG, // Settings page slug |
| 1922 | 'main-section', // Section ID |
| 1923 | array( |
| 1924 | 'field_id' => $field_id, // Custom argument |
| 1925 | 'field_slug' => $field_slug, // Custom argument |
| 1926 | 'field_name' => ASENHA_SLUG_U . '['. $field_id .']', // Custom argument |
| 1927 | 'field_description' => 'Perform 301 (permanent) redirect to the homepage for all 404 (not found) pages.', // Custom argument |
| 1928 | 'field_options_wrapper' => true, // Custom argument. Add container for additional options |
| 1929 | 'class' => 'asenha-toggle utilities ' . $field_slug, // Custom class for the <tr> element |
| 1930 | ) |
| 1931 | ); |
| 1932 | |
| 1933 | } |
| 1934 | |
| 1935 | } |