class-activation.php
2 years ago
class-admin-columns-manager.php
2 years ago
class-admin-menu-organizer.php
2 years ago
class-auto-publish-posts-with-missed-schedule.php
2 years ago
class-avif-upload.php
2 years ago
class-change-login-url.php
2 years ago
class-cleanup-admin-bar.php
2 years ago
class-code-snippets-manager.php
2 years ago
class-common-methods.php
2 years ago
class-content-duplication.php
2 years ago
class-content-order.php
2 years ago
class-custom-admin-footer-text.php
2 years ago
class-custom-body-class.php
2 years ago
class-custom-content-types.php
2 years ago
class-custom-css.php
2 years ago
class-custom-nav-menu-items-in-new-tab.php
2 years ago
class-deactivation.php
2 years ago
class-disable-comments.php
2 years ago
class-disable-dashboard-widgets.php
2 years ago
class-disable-feeds.php
2 years ago
class-disable-gutenberg.php
2 years ago
class-disable-rest-api.php
2 years ago
class-disable-smaller-components.php
2 years ago
class-disable-updates.php
2 years ago
class-disable-xml-rpc.php
2 years ago
class-display-system-summary.php
2 years ago
class-email-address-obfuscator.php
2 years ago
class-email-delivery.php
2 years ago
class-enhance-list-tables.php
2 years ago
class-external-permalinks.php
2 years ago
class-heartbeat-control.php
2 years ago
class-hide-admin-bar.php
2 years ago
class-hide-admin-notices.php
2 years ago
class-image-sizes-panel.php
2 years ago
class-image-upload-control.php
2 years ago
class-insert-head-body-footer-code.php
2 years ago
class-last-login-column.php
2 years ago
class-limit-login-attempts.php
2 years ago
class-login-id-type.php
2 years ago
class-login-logout-menu.php
2 years ago
class-maintenance-mode.php
2 years ago
class-manage-ads-appads-txt.php
2 years ago
class-manage-robots-txt.php
2 years ago
class-media-replacement.php
2 years ago
class-multiple-user-roles.php
2 years ago
class-obfuscate-author-slugs.php
2 years ago
class-open-external-links-in-new-tab.php
2 years ago
class-password-protection.php
2 years ago
class-redirect-after-login.php
2 years ago
class-redirect-after-logout.php
2 years ago
class-redirect-fourofour.php
2 years ago
class-revisions-control.php
2 years ago
class-search-engines-visibility.php
2 years ago
class-settings-fields-render.php
2 years ago
class-settings-sanitization.php
2 years ago
class-settings-sections-fields.php
2 years ago
class-show-custom-taxonomy-filters.php
2 years ago
class-site-identity-on-login-page.php
2 years ago
class-svg-upload.php
2 years ago
class-various-admin-ui-enhancements.php
2 years ago
class-view-admin-as-role.php
2 years ago
class-wider-admin-menu.php
2 years ago
class-settings-sanitization.php
769 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | /** |
| 6 | * Class related to sanitization of settings fields for saving as options |
| 7 | * |
| 8 | * @since 2.2.0 |
| 9 | */ |
| 10 | class Settings_Sanitization { |
| 11 | /** |
| 12 | * Sanitize options |
| 13 | * |
| 14 | * @since 1.0.0 |
| 15 | */ |
| 16 | function sanitize_for_options( $options ) { |
| 17 | // Call WordPress globals required for validating the fields |
| 18 | global |
| 19 | $wp_roles, |
| 20 | $asenha_public_post_types, |
| 21 | $asenha_nonpublic_post_types, |
| 22 | $asenha_gutenberg_post_types, |
| 23 | $asenha_revisions_post_types, |
| 24 | $active_plugin_slugs |
| 25 | ; |
| 26 | $roles = $wp_roles->get_names(); |
| 27 | $options_extra = get_option( ASENHA_SLUG_U . '_extra', array() ); |
| 28 | if ( false === $options_extra ) { |
| 29 | add_option( ASENHA_SLUG_U . '_extra', array(), true ); |
| 30 | } |
| 31 | // Content Duplication |
| 32 | if ( !isset( $options['enable_duplication'] ) ) { |
| 33 | $options['enable_duplication'] = false; |
| 34 | } |
| 35 | $options['enable_duplication'] = ( 'on' == $options['enable_duplication'] ? true : false ); |
| 36 | if ( !isset( $options['duplication_redirect_destination'] ) ) { |
| 37 | $options['duplication_redirect_destination'] = 'edit'; |
| 38 | } |
| 39 | // Content Order |
| 40 | if ( !isset( $options['content_order'] ) ) { |
| 41 | $options['content_order'] = false; |
| 42 | } |
| 43 | $options['content_order'] = ( 'on' == $options['content_order'] ? true : false ); |
| 44 | if ( is_array( $asenha_public_post_types ) ) { |
| 45 | foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { |
| 46 | // e.g. $post_type_slug is post, $post_type_label is Posts |
| 47 | if ( post_type_supports( $post_type_slug, 'page-attributes' ) || is_post_type_hierarchical( $post_type_slug ) ) { |
| 48 | if ( !isset( $options['content_order_for'][$post_type_slug] ) ) { |
| 49 | $options['content_order_for'][$post_type_slug] = false; |
| 50 | } |
| 51 | $options['content_order_for'][$post_type_slug] = ( 'on' == $options['content_order_for'][$post_type_slug] ? true : false ); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | // Enable Media Replacement |
| 56 | if ( !isset( $options['enable_media_replacement'] ) ) { |
| 57 | $options['enable_media_replacement'] = false; |
| 58 | } |
| 59 | $options['enable_media_replacement'] = ( 'on' == $options['enable_media_replacement'] ? true : false ); |
| 60 | // Enable SVG Upload |
| 61 | if ( !isset( $options['enable_svg_upload'] ) ) { |
| 62 | $options['enable_svg_upload'] = false; |
| 63 | } |
| 64 | $options['enable_svg_upload'] = ( 'on' == $options['enable_svg_upload'] ? true : false ); |
| 65 | if ( is_array( $roles ) ) { |
| 66 | foreach ( $roles as $role_slug => $role_label ) { |
| 67 | // e.g. $role_slug is administrator, $role_label is Administrator |
| 68 | if ( !isset( $options['enable_svg_upload_for'][$role_slug] ) ) { |
| 69 | $options['enable_svg_upload_for'][$role_slug] = false; |
| 70 | } |
| 71 | $options['enable_svg_upload_for'][$role_slug] = ( 'on' == $options['enable_svg_upload_for'][$role_slug] ? true : false ); |
| 72 | } |
| 73 | } |
| 74 | // Enable SVG Upload |
| 75 | if ( !isset( $options['enable_avif_upload'] ) ) { |
| 76 | $options['enable_avif_upload'] = false; |
| 77 | } |
| 78 | $options['enable_avif_upload'] = ( 'on' == $options['enable_avif_upload'] ? true : false ); |
| 79 | // Enable External Permalinks |
| 80 | if ( !isset( $options['enable_external_permalinks'] ) ) { |
| 81 | $options['enable_external_permalinks'] = false; |
| 82 | } |
| 83 | $options['enable_external_permalinks'] = ( 'on' == $options['enable_external_permalinks'] ? true : false ); |
| 84 | if ( is_array( $asenha_public_post_types ) ) { |
| 85 | foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { |
| 86 | // e.g. $post_type_slug is post, $post_type_label is Posts |
| 87 | if ( !isset( $options['enable_external_permalinks_for'][$post_type_slug] ) ) { |
| 88 | $options['enable_external_permalinks_for'][$post_type_slug] = false; |
| 89 | } |
| 90 | $options['enable_external_permalinks_for'][$post_type_slug] = ( 'on' == $options['enable_external_permalinks_for'][$post_type_slug] ? true : false ); |
| 91 | } |
| 92 | } |
| 93 | // Open All External Links in New Tab |
| 94 | if ( !isset( $options['external_links_new_tab'] ) ) { |
| 95 | $options['external_links_new_tab'] = false; |
| 96 | } |
| 97 | $options['external_links_new_tab'] = ( 'on' == $options['external_links_new_tab'] ? true : false ); |
| 98 | // Allow Custom Nav Menu Items to Open in New Tab |
| 99 | if ( !isset( $options['custom_nav_menu_items_new_tab'] ) ) { |
| 100 | $options['custom_nav_menu_items_new_tab'] = false; |
| 101 | } |
| 102 | $options['custom_nav_menu_items_new_tab'] = ( 'on' == $options['custom_nav_menu_items_new_tab'] ? true : false ); |
| 103 | // Enable Auto-Publishing of Posts with Missed Schedules |
| 104 | if ( !isset( $options['enable_missed_schedule_posts_auto_publish'] ) ) { |
| 105 | $options['enable_missed_schedule_posts_auto_publish'] = false; |
| 106 | } |
| 107 | $options['enable_missed_schedule_posts_auto_publish'] = ( 'on' == $options['enable_missed_schedule_posts_auto_publish'] ? true : false ); |
| 108 | // ================================================================= |
| 109 | // ADMIN INTERFACE |
| 110 | // ================================================================= |
| 111 | // Hide or Modify Elements / Clean Up Admin Bar |
| 112 | if ( !isset( $options['hide_modify_elements'] ) ) { |
| 113 | $options['hide_modify_elements'] = false; |
| 114 | } |
| 115 | $options['hide_modify_elements'] = ( 'on' == $options['hide_modify_elements'] ? true : false ); |
| 116 | if ( !isset( $options['hide_ab_wp_logo_menu'] ) ) { |
| 117 | $options['hide_ab_wp_logo_menu'] = false; |
| 118 | } |
| 119 | $options['hide_ab_wp_logo_menu'] = ( 'on' == $options['hide_ab_wp_logo_menu'] ? true : false ); |
| 120 | if ( !isset( $options['hide_ab_customize_menu'] ) ) { |
| 121 | $options['hide_ab_customize_menu'] = false; |
| 122 | } |
| 123 | $options['hide_ab_customize_menu'] = ( 'on' == $options['hide_ab_customize_menu'] ? true : false ); |
| 124 | if ( !isset( $options['hide_ab_comments_menu'] ) ) { |
| 125 | $options['hide_ab_comments_menu'] = false; |
| 126 | } |
| 127 | $options['hide_ab_comments_menu'] = ( 'on' == $options['hide_ab_comments_menu'] ? true : false ); |
| 128 | if ( !isset( $options['hide_ab_updates_menu'] ) ) { |
| 129 | $options['hide_ab_updates_menu'] = false; |
| 130 | } |
| 131 | $options['hide_ab_updates_menu'] = ( 'on' == $options['hide_ab_updates_menu'] ? true : false ); |
| 132 | if ( !isset( $options['hide_ab_new_content_menu'] ) ) { |
| 133 | $options['hide_ab_new_content_menu'] = false; |
| 134 | } |
| 135 | $options['hide_ab_new_content_menu'] = ( 'on' == $options['hide_ab_new_content_menu'] ? true : false ); |
| 136 | if ( !isset( $options['hide_ab_howdy'] ) ) { |
| 137 | $options['hide_ab_howdy'] = false; |
| 138 | } |
| 139 | $options['hide_ab_howdy'] = ( 'on' == $options['hide_ab_howdy'] ? true : false ); |
| 140 | if ( !isset( $options['hide_help_drawer'] ) ) { |
| 141 | $options['hide_help_drawer'] = false; |
| 142 | } |
| 143 | $options['hide_help_drawer'] = ( 'on' == $options['hide_help_drawer'] ? true : false ); |
| 144 | // Hide Admin Notices |
| 145 | if ( !isset( $options['hide_admin_notices'] ) ) { |
| 146 | $options['hide_admin_notices'] = false; |
| 147 | } |
| 148 | $options['hide_admin_notices'] = ( 'on' == $options['hide_admin_notices'] ? true : false ); |
| 149 | // Disable Dashboard Widgets |
| 150 | if ( !isset( $options['disable_dashboard_widgets'] ) ) { |
| 151 | $options['disable_dashboard_widgets'] = false; |
| 152 | } |
| 153 | $options['disable_dashboard_widgets'] = ( 'on' == $options['disable_dashboard_widgets'] ? true : false ); |
| 154 | $dashboard_widgets = $options_extra['dashboard_widgets']; |
| 155 | if ( is_array( $dashboard_widgets ) ) { |
| 156 | foreach ( $dashboard_widgets as $widget ) { |
| 157 | if ( !isset( $options['disabled_dashboard_widgets'][$widget['id'] . '__' . $widget['context'] . '__' . $widget['priority']] ) ) { |
| 158 | $options['disabled_dashboard_widgets'][$widget['id'] . '__' . $widget['context'] . '__' . $widget['priority']] = false; |
| 159 | } |
| 160 | $options['disabled_dashboard_widgets'][$widget['id'] . '__' . $widget['context'] . '__' . $widget['priority']] = ( 'on' == $options['disabled_dashboard_widgets'][$widget['id'] . '__' . $widget['context'] . '__' . $widget['priority']] ? true : false ); |
| 161 | } |
| 162 | } |
| 163 | if ( !isset( $options['disable_welcome_panel_in_dashboard'] ) ) { |
| 164 | $options['disable_welcome_panel_in_dashboard'] = false; |
| 165 | } |
| 166 | $options['disable_welcome_panel_in_dashboard'] = ( 'on' == $options['disable_welcome_panel_in_dashboard'] ? true : false ); |
| 167 | // Hide Admin Bar |
| 168 | if ( !isset( $options['hide_admin_bar'] ) ) { |
| 169 | $options['hide_admin_bar'] = false; |
| 170 | } |
| 171 | $options['hide_admin_bar'] = ( 'on' == $options['hide_admin_bar'] ? true : false ); |
| 172 | if ( is_array( $roles ) ) { |
| 173 | foreach ( $roles as $role_slug => $role_label ) { |
| 174 | // e.g. $role_slug is administrator, $role_label is Administrator |
| 175 | // on the frontend |
| 176 | if ( !isset( $options['hide_admin_bar_for'][$role_slug] ) ) { |
| 177 | $options['hide_admin_bar_for'][$role_slug] = false; |
| 178 | } |
| 179 | $options['hide_admin_bar_for'][$role_slug] = ( 'on' == $options['hide_admin_bar_for'][$role_slug] ? true : false ); |
| 180 | } |
| 181 | } |
| 182 | // Wider Admin Menu |
| 183 | if ( !isset( $options['wider_admin_menu'] ) ) { |
| 184 | $options['wider_admin_menu'] = false; |
| 185 | } |
| 186 | $options['wider_admin_menu'] = ( 'on' == $options['wider_admin_menu'] ? true : false ); |
| 187 | if ( !isset( $options['admin_menu_width'] ) ) { |
| 188 | $options['admin_menu_width'] = 200; |
| 189 | } |
| 190 | $options['admin_menu_width'] = ( !empty( $options['admin_menu_width'] ) ? sanitize_text_field( $options['admin_menu_width'] ) : 200 ); |
| 191 | // Admin Menu Organizer |
| 192 | if ( !isset( $options['customize_admin_menu'] ) ) { |
| 193 | $options['customize_admin_menu'] = false; |
| 194 | } |
| 195 | $options['customize_admin_menu'] = ( 'on' == $options['customize_admin_menu'] ? true : false ); |
| 196 | if ( !isset( $options['custom_menu_order'] ) ) { |
| 197 | $options['custom_menu_order'] = ''; |
| 198 | } |
| 199 | // The following fields are added on rendering of custom_menu_order field |
| 200 | if ( !isset( $options['custom_menu_titles'] ) ) { |
| 201 | $options['custom_menu_titles'] = ''; |
| 202 | } |
| 203 | if ( !isset( $options['custom_menu_hidden'] ) ) { |
| 204 | $options['custom_menu_hidden'] = ''; |
| 205 | } |
| 206 | // Enhance List Tables |
| 207 | if ( !isset( $options['enhance_list_tables'] ) ) { |
| 208 | $options['enhance_list_tables'] = false; |
| 209 | } |
| 210 | $options['enhance_list_tables'] = ( 'on' == $options['enhance_list_tables'] ? true : false ); |
| 211 | // Show Featured Image Column |
| 212 | if ( !isset( $options['show_featured_image_column'] ) ) { |
| 213 | $options['show_featured_image_column'] = false; |
| 214 | } |
| 215 | $options['show_featured_image_column'] = ( 'on' == $options['show_featured_image_column'] ? true : false ); |
| 216 | // Show Excerpt Column |
| 217 | if ( !isset( $options['show_excerpt_column'] ) ) { |
| 218 | $options['show_excerpt_column'] = false; |
| 219 | } |
| 220 | $options['show_excerpt_column'] = ( 'on' == $options['show_excerpt_column'] ? true : false ); |
| 221 | // Show ID Column |
| 222 | if ( !isset( $options['show_id_column'] ) ) { |
| 223 | $options['show_id_column'] = false; |
| 224 | } |
| 225 | $options['show_id_column'] = ( 'on' == $options['show_id_column'] ? true : false ); |
| 226 | // Show File Size Column in Media Library |
| 227 | if ( !isset( $options['show_file_size_column'] ) ) { |
| 228 | $options['show_file_size_column'] = false; |
| 229 | } |
| 230 | $options['show_file_size_column'] = ( 'on' == $options['show_file_size_column'] ? true : false ); |
| 231 | // Show ID in Action Row |
| 232 | if ( !isset( $options['show_id_in_action_row'] ) ) { |
| 233 | $options['show_id_in_action_row'] = false; |
| 234 | } |
| 235 | $options['show_id_in_action_row'] = ( 'on' == $options['show_id_in_action_row'] ? true : false ); |
| 236 | // Show Custom Taxonomy Filters |
| 237 | if ( !isset( $options['show_custom_taxonomy_filters'] ) ) { |
| 238 | $options['show_custom_taxonomy_filters'] = false; |
| 239 | } |
| 240 | $options['show_custom_taxonomy_filters'] = ( 'on' == $options['show_custom_taxonomy_filters'] ? true : false ); |
| 241 | // Hide Comments Column |
| 242 | if ( !isset( $options['hide_comments_column'] ) ) { |
| 243 | $options['hide_comments_column'] = false; |
| 244 | } |
| 245 | $options['hide_comments_column'] = ( 'on' == $options['hide_comments_column'] ? true : false ); |
| 246 | // Hide Post Tags Column |
| 247 | if ( !isset( $options['hide_post_tags_column'] ) ) { |
| 248 | $options['hide_post_tags_column'] = false; |
| 249 | } |
| 250 | $options['hide_post_tags_column'] = ( 'on' == $options['hide_post_tags_column'] ? true : false ); |
| 251 | // Custom Admin Footer Text |
| 252 | if ( !isset( $options['custom_admin_footer_text'] ) ) { |
| 253 | $options['custom_admin_footer_text'] = false; |
| 254 | } |
| 255 | $options['custom_admin_footer_text'] = ( 'on' == $options['custom_admin_footer_text'] ? true : false ); |
| 256 | if ( !isset( $options['custom_admin_footer_left'] ) ) { |
| 257 | $options['custom_admin_footer_left'] = ''; |
| 258 | } |
| 259 | $options['custom_admin_footer_left'] = ( !empty( $options['custom_admin_footer_left'] ) ? wp_kses_post( $options['custom_admin_footer_left'] ) : '' ); |
| 260 | if ( !isset( $options['custom_admin_footer_right'] ) ) { |
| 261 | $options['custom_admin_footer_right'] = ''; |
| 262 | } |
| 263 | $options['custom_admin_footer_right'] = ( !empty( $options['custom_admin_footer_right'] ) ? wp_kses_post( $options['custom_admin_footer_right'] ) : '' ); |
| 264 | // Various Admin Enhancements |
| 265 | if ( !isset( $options['various_admin_ui_enhancements'] ) ) { |
| 266 | $options['various_admin_ui_enhancements'] = false; |
| 267 | } |
| 268 | $options['various_admin_ui_enhancements'] = ( 'on' == $options['various_admin_ui_enhancements'] ? true : false ); |
| 269 | // Media Library Infinite Scrolling |
| 270 | if ( !isset( $options['media_library_infinite_scrolling'] ) ) { |
| 271 | $options['media_library_infinite_scrolling'] = false; |
| 272 | } |
| 273 | $options['media_library_infinite_scrolling'] = ( 'on' == $options['media_library_infinite_scrolling'] ? true : false ); |
| 274 | // Display Active Plugins First |
| 275 | if ( !isset( $options['display_active_plugins_first'] ) ) { |
| 276 | $options['display_active_plugins_first'] = false; |
| 277 | } |
| 278 | $options['display_active_plugins_first'] = ( 'on' == $options['display_active_plugins_first'] ? true : false ); |
| 279 | // ================================================================= |
| 280 | // LOG IN | LOG OUT |
| 281 | // ================================================================= |
| 282 | // Change Login URL |
| 283 | if ( !isset( $options['change_login_url'] ) ) { |
| 284 | $options['change_login_url'] = false; |
| 285 | } |
| 286 | $options['change_login_url'] = ( 'on' == $options['change_login_url'] ? true : false ); |
| 287 | if ( !isset( $options['custom_login_slug'] ) ) { |
| 288 | $options['custom_login_slug'] = 'backend'; |
| 289 | } |
| 290 | $options['custom_login_slug'] = ( !empty( $options['custom_login_slug'] ) ? sanitize_text_field( trim( $options['custom_login_slug'], '/' ) ) : 'backend' ); |
| 291 | // Login ID Type |
| 292 | if ( !isset( $options['login_id_type_restriction'] ) ) { |
| 293 | $options['login_id_type_restriction'] = false; |
| 294 | } |
| 295 | $options['login_id_type_restriction'] = ( 'on' == $options['login_id_type_restriction'] ? true : false ); |
| 296 | if ( !isset( $options['login_id_type'] ) ) { |
| 297 | $options['login_id_type'] = 'username'; |
| 298 | } |
| 299 | $options['login_id_type'] = ( !empty( $options['login_id_type'] ) ? sanitize_text_field( $options['login_id_type'] ) : 'username' ); |
| 300 | // Use Site Identity on the Login Page |
| 301 | if ( !isset( $options['site_identity_on_login'] ) ) { |
| 302 | $options['site_identity_on_login'] = false; |
| 303 | } |
| 304 | $options['site_identity_on_login'] = ( 'on' == $options['site_identity_on_login'] ? true : false ); |
| 305 | // Enable Login Logout Menu |
| 306 | if ( !isset( $options['enable_login_logout_menu'] ) ) { |
| 307 | $options['enable_login_logout_menu'] = false; |
| 308 | } |
| 309 | $options['enable_login_logout_menu'] = ( 'on' == $options['enable_login_logout_menu'] ? true : false ); |
| 310 | // Redirect After Login |
| 311 | if ( !isset( $options['redirect_after_login'] ) ) { |
| 312 | $options['redirect_after_login'] = false; |
| 313 | } |
| 314 | $options['redirect_after_login'] = ( 'on' == $options['redirect_after_login'] ? true : false ); |
| 315 | if ( !isset( $options['redirect_after_login_to_slug'] ) ) { |
| 316 | $options['redirect_after_login_to_slug'] = ''; |
| 317 | } |
| 318 | $options['redirect_after_login_to_slug'] = ( !empty( $options['redirect_after_login_to_slug'] ) ? sanitize_text_field( $options['redirect_after_login_to_slug'] ) : '' ); |
| 319 | if ( is_array( $roles ) ) { |
| 320 | foreach ( $roles as $role_slug => $role_label ) { |
| 321 | // e.g. $role_slug is administrator, $role_label is Administrator |
| 322 | if ( !isset( $options['redirect_after_login_for'][$role_slug] ) ) { |
| 323 | $options['redirect_after_login_for'][$role_slug] = false; |
| 324 | } |
| 325 | $options['redirect_after_login_for'][$role_slug] = ( 'on' == $options['redirect_after_login_for'][$role_slug] ? true : false ); |
| 326 | } |
| 327 | } |
| 328 | // Redirect After Logout |
| 329 | if ( !isset( $options['redirect_after_logout'] ) ) { |
| 330 | $options['redirect_after_logout'] = false; |
| 331 | } |
| 332 | $options['redirect_after_logout'] = ( 'on' == $options['redirect_after_logout'] ? true : false ); |
| 333 | if ( !isset( $options['redirect_after_logout_to_slug'] ) ) { |
| 334 | $options['redirect_after_logout_to_slug'] = ''; |
| 335 | } |
| 336 | $options['redirect_after_logout_to_slug'] = ( !empty( $options['redirect_after_logout_to_slug'] ) ? sanitize_text_field( $options['redirect_after_logout_to_slug'] ) : '' ); |
| 337 | if ( is_array( $roles ) ) { |
| 338 | foreach ( $roles as $role_slug => $role_label ) { |
| 339 | // e.g. $role_slug is administrator, $role_label is Administrator |
| 340 | if ( !isset( $options['redirect_after_logout_for'][$role_slug] ) ) { |
| 341 | $options['redirect_after_logout_for'][$role_slug] = false; |
| 342 | } |
| 343 | $options['redirect_after_logout_for'][$role_slug] = ( 'on' == $options['redirect_after_logout_for'][$role_slug] ? true : false ); |
| 344 | } |
| 345 | } |
| 346 | // Enable Last Login Column |
| 347 | if ( !isset( $options['enable_last_login_column'] ) ) { |
| 348 | $options['enable_last_login_column'] = false; |
| 349 | } |
| 350 | $options['enable_last_login_column'] = ( 'on' == $options['enable_last_login_column'] ? true : false ); |
| 351 | // Enable Custom Admin CSS |
| 352 | if ( !isset( $options['enable_custom_admin_css'] ) ) { |
| 353 | $options['enable_custom_admin_css'] = false; |
| 354 | } |
| 355 | $options['enable_custom_admin_css'] = ( 'on' == $options['enable_custom_admin_css'] ? true : false ); |
| 356 | if ( !isset( $options['custom_admin_css'] ) ) { |
| 357 | $options['custom_admin_css'] = ''; |
| 358 | } |
| 359 | $options['custom_admin_css'] = ( !empty( $options['custom_admin_css'] ) ? $options['custom_admin_css'] : '' ); |
| 360 | // Enable Custom Frontend CSS |
| 361 | if ( !isset( $options['enable_custom_frontend_css'] ) ) { |
| 362 | $options['enable_custom_frontend_css'] = false; |
| 363 | } |
| 364 | $options['enable_custom_frontend_css'] = ( 'on' == $options['enable_custom_frontend_css'] ? true : false ); |
| 365 | if ( !isset( $options['custom_frontend_css'] ) ) { |
| 366 | $options['custom_frontend_css'] = ''; |
| 367 | } |
| 368 | $options['custom_frontend_css'] = ( !empty( $options['custom_frontend_css'] ) ? $options['custom_frontend_css'] : '' ); |
| 369 | // Custom Body Class |
| 370 | if ( !isset( $options['enable_custom_body_class'] ) ) { |
| 371 | $options['enable_custom_body_class'] = false; |
| 372 | } |
| 373 | $options['enable_custom_body_class'] = ( 'on' == $options['enable_custom_body_class'] ? true : false ); |
| 374 | if ( is_array( $asenha_public_post_types ) ) { |
| 375 | foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { |
| 376 | // e.g. $post_type_slug is post, $post_type_label is Posts |
| 377 | if ( !isset( $options['enable_custom_body_class_for'][$post_type_slug] ) ) { |
| 378 | $options['enable_custom_body_class_for'][$post_type_slug] = false; |
| 379 | } |
| 380 | $options['enable_custom_body_class_for'][$post_type_slug] = ( 'on' == $options['enable_custom_body_class_for'][$post_type_slug] ? true : false ); |
| 381 | } |
| 382 | } |
| 383 | // Manage ads.txt and app-ads.txt |
| 384 | if ( !isset( $options['manage_ads_appads_txt'] ) ) { |
| 385 | $options['manage_ads_appads_txt'] = false; |
| 386 | } |
| 387 | $options['manage_ads_appads_txt'] = ( 'on' == $options['manage_ads_appads_txt'] ? true : false ); |
| 388 | if ( !isset( $options['ads_txt_content'] ) ) { |
| 389 | $options['ads_txt_content'] = ''; |
| 390 | } |
| 391 | $options['ads_txt_content'] = ( !empty( $options['ads_txt_content'] ) ? $options['ads_txt_content'] : '' ); |
| 392 | if ( !isset( $options['app_ads_txt_content'] ) ) { |
| 393 | $options['app_ads_txt_content'] = ''; |
| 394 | } |
| 395 | $options['app_ads_txt_content'] = ( !empty( $options['app_ads_txt_content'] ) ? $options['app_ads_txt_content'] : '' ); |
| 396 | // Manage robots.txt |
| 397 | if ( !isset( $options['manage_robots_txt'] ) ) { |
| 398 | $options['manage_robots_txt'] = false; |
| 399 | } |
| 400 | $options['manage_robots_txt'] = ( 'on' == $options['manage_robots_txt'] ? true : false ); |
| 401 | if ( !isset( $options['robots_txt_content'] ) ) { |
| 402 | $options['robots_txt_content'] = ''; |
| 403 | } else { |
| 404 | if ( !empty( $options['robots_txt_content'] ) ) { |
| 405 | $options['robots_txt_content'] = $options['robots_txt_content']; |
| 406 | $is_robots_txt_real_file = is_file( ABSPATH . 'robots.txt' ); |
| 407 | // rename real robots.txt file if it exists and Mange robots.txt is enabled |
| 408 | if ( $is_robots_txt_real_file && 'on' == $options['manage_robots_txt'] ) { |
| 409 | $robots_txt_backup_filename = 'robots_backup_' . date( 'Y_m_d__H_i', time() ) . '.txt'; |
| 410 | $options_extra = get_option( ASENHA_SLUG_U . '_extra', array() ); |
| 411 | $options_extra['robots_txt_backup_file_name'] = $robots_txt_backup_filename; |
| 412 | update_option( ASENHA_SLUG_U . '_extra', $options_extra, true ); |
| 413 | rename( ABSPATH . 'robots.txt', ABSPATH . $robots_txt_backup_filename ); |
| 414 | } elseif ( 'on' != $options['manage_robots_txt'] ) { |
| 415 | $options_extra = get_option( ASENHA_SLUG_U . '_extra', array() ); |
| 416 | if ( array_key_exists( 'robots_txt_backup_file_name', $options_extra ) ) { |
| 417 | if ( is_file( ABSPATH . $options_extra['robots_txt_backup_file_name'] ) ) { |
| 418 | rename( ABSPATH . $options_extra['robots_txt_backup_file_name'], ABSPATH . 'robots.txt' ); |
| 419 | } |
| 420 | } |
| 421 | } |
| 422 | } else { |
| 423 | $options['robots_txt_content'] = ''; |
| 424 | } |
| 425 | } |
| 426 | // Insert <head>, <body> and <footer> code |
| 427 | if ( !isset( $options['insert_head_body_footer_code'] ) ) { |
| 428 | $options['insert_head_body_footer_code'] = false; |
| 429 | } |
| 430 | $options['insert_head_body_footer_code'] = ( 'on' == $options['insert_head_body_footer_code'] ? true : false ); |
| 431 | if ( !isset( $options['head_code_priority'] ) ) { |
| 432 | $options['head_code_priority'] = 10; |
| 433 | } |
| 434 | $options['head_code_priority'] = ( !empty( $options['head_code_priority'] ) ? $options['head_code_priority'] : 10 ); |
| 435 | if ( !isset( $options['head_code'] ) ) { |
| 436 | $options['head_code'] = ''; |
| 437 | } |
| 438 | $options['head_code'] = ( !empty( $options['head_code'] ) ? $options['head_code'] : '' ); |
| 439 | if ( !isset( $options['body_code_priority'] ) ) { |
| 440 | $options['body_code_priority'] = 10; |
| 441 | } |
| 442 | $options['body_code_priority'] = ( !empty( $options['body_code_priority'] ) ? $options['body_code_priority'] : 10 ); |
| 443 | if ( !isset( $options['body_code'] ) ) { |
| 444 | $options['body_code'] = ''; |
| 445 | } |
| 446 | $options['body_code'] = ( !empty( $options['body_code'] ) ? $options['body_code'] : '' ); |
| 447 | if ( !isset( $options['footer_code_priority'] ) ) { |
| 448 | $options['footer_code_priority'] = 10; |
| 449 | } |
| 450 | $options['footer_code_priority'] = ( !empty( $options['footer_code_priority'] ) ? $options['footer_code_priority'] : 10 ); |
| 451 | if ( !isset( $options['footer_code'] ) ) { |
| 452 | $options['footer_code'] = ''; |
| 453 | } |
| 454 | $options['footer_code'] = ( !empty( $options['footer_code'] ) ? $options['footer_code'] : '' ); |
| 455 | // ================================================================= |
| 456 | // DISABLE COMPONENTS |
| 457 | // ================================================================= |
| 458 | // Disable Gutenberg |
| 459 | if ( !isset( $options['disable_gutenberg'] ) ) { |
| 460 | $options['disable_gutenberg'] = false; |
| 461 | } |
| 462 | $options['disable_gutenberg'] = ( 'on' == $options['disable_gutenberg'] ? true : false ); |
| 463 | if ( is_array( $asenha_gutenberg_post_types ) ) { |
| 464 | foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { |
| 465 | // e.g. $post_type_slug is post, |
| 466 | if ( !isset( $options['disable_gutenberg_for'][$post_type_slug] ) ) { |
| 467 | $options['disable_gutenberg_for'][$post_type_slug] = false; |
| 468 | } |
| 469 | $options['disable_gutenberg_for'][$post_type_slug] = ( 'on' == $options['disable_gutenberg_for'][$post_type_slug] ? true : false ); |
| 470 | } |
| 471 | } |
| 472 | if ( !isset( $options['disable_gutenberg_frontend_styles'] ) ) { |
| 473 | $options['disable_gutenberg_frontend_styles'] = false; |
| 474 | } |
| 475 | $options['disable_gutenberg_frontend_styles'] = ( 'on' == $options['disable_gutenberg_frontend_styles'] ? true : false ); |
| 476 | // Disable Comments |
| 477 | if ( !isset( $options['disable_comments'] ) ) { |
| 478 | $options['disable_comments'] = false; |
| 479 | } |
| 480 | $options['disable_comments'] = ( 'on' == $options['disable_comments'] ? true : false ); |
| 481 | if ( is_array( $asenha_public_post_types ) ) { |
| 482 | foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { |
| 483 | // e.g. $post_type_slug is post, $post_type_label is Posts |
| 484 | if ( !isset( $options['disable_comments_for'][$post_type_slug] ) ) { |
| 485 | $options['disable_comments_for'][$post_type_slug] = false; |
| 486 | } |
| 487 | $options['disable_comments_for'][$post_type_slug] = ( 'on' == $options['disable_comments_for'][$post_type_slug] ? true : false ); |
| 488 | } |
| 489 | } |
| 490 | // Disable REST API |
| 491 | if ( !isset( $options['disable_rest_api'] ) ) { |
| 492 | $options['disable_rest_api'] = false; |
| 493 | } |
| 494 | $options['disable_rest_api'] = ( 'on' == $options['disable_rest_api'] ? true : false ); |
| 495 | // Disable Feeds |
| 496 | if ( !isset( $options['disable_feeds'] ) ) { |
| 497 | $options['disable_feeds'] = false; |
| 498 | } |
| 499 | $options['disable_feeds'] = ( 'on' == $options['disable_feeds'] ? true : false ); |
| 500 | // Disable Auto Updates |
| 501 | if ( !isset( $options['disable_all_updates'] ) ) { |
| 502 | $options['disable_all_updates'] = false; |
| 503 | } |
| 504 | $options['disable_all_updates'] = ( 'on' == $options['disable_all_updates'] ? true : false ); |
| 505 | // Disable Smaller Components |
| 506 | if ( !isset( $options['disable_smaller_components'] ) ) { |
| 507 | $options['disable_smaller_components'] = false; |
| 508 | } |
| 509 | $options['disable_smaller_components'] = ( 'on' == $options['disable_smaller_components'] ? true : false ); |
| 510 | if ( !isset( $options['disable_head_generator_tag'] ) ) { |
| 511 | $options['disable_head_generator_tag'] = false; |
| 512 | } |
| 513 | $options['disable_head_generator_tag'] = ( 'on' == $options['disable_head_generator_tag'] ? true : false ); |
| 514 | if ( !isset( $options['disable_resource_version_number'] ) ) { |
| 515 | $options['disable_resource_version_number'] = false; |
| 516 | } |
| 517 | $options['disable_resource_version_number'] = ( 'on' == $options['disable_resource_version_number'] ? true : false ); |
| 518 | if ( !isset( $options['disable_head_wlwmanifest_tag'] ) ) { |
| 519 | $options['disable_head_wlwmanifest_tag'] = false; |
| 520 | } |
| 521 | $options['disable_head_wlwmanifest_tag'] = ( 'on' == $options['disable_head_wlwmanifest_tag'] ? true : false ); |
| 522 | if ( !isset( $options['disable_head_rsd_tag'] ) ) { |
| 523 | $options['disable_head_rsd_tag'] = false; |
| 524 | } |
| 525 | $options['disable_head_rsd_tag'] = ( 'on' == $options['disable_head_rsd_tag'] ? true : false ); |
| 526 | if ( !isset( $options['disable_head_shortlink_tag'] ) ) { |
| 527 | $options['disable_head_shortlink_tag'] = false; |
| 528 | } |
| 529 | $options['disable_head_shortlink_tag'] = ( 'on' == $options['disable_head_shortlink_tag'] ? true : false ); |
| 530 | if ( !isset( $options['disable_frontend_dashicons'] ) ) { |
| 531 | $options['disable_frontend_dashicons'] = false; |
| 532 | } |
| 533 | $options['disable_frontend_dashicons'] = ( 'on' == $options['disable_frontend_dashicons'] ? true : false ); |
| 534 | if ( !isset( $options['disable_emoji_support'] ) ) { |
| 535 | $options['disable_emoji_support'] = false; |
| 536 | } |
| 537 | $options['disable_emoji_support'] = ( 'on' == $options['disable_emoji_support'] ? true : false ); |
| 538 | if ( !isset( $options['disable_jquery_migrate'] ) ) { |
| 539 | $options['disable_jquery_migrate'] = false; |
| 540 | } |
| 541 | $options['disable_jquery_migrate'] = ( 'on' == $options['disable_jquery_migrate'] ? true : false ); |
| 542 | if ( !isset( $options['disable_block_widgets'] ) ) { |
| 543 | $options['disable_block_widgets'] = false; |
| 544 | } |
| 545 | $options['disable_block_widgets'] = ( 'on' == $options['disable_block_widgets'] ? true : false ); |
| 546 | // ================================================================= |
| 547 | // SECURITY |
| 548 | // ================================================================= |
| 549 | // Limit Login Attempts |
| 550 | if ( !isset( $options['limit_login_attempts'] ) ) { |
| 551 | $options['limit_login_attempts'] = false; |
| 552 | } |
| 553 | $options['limit_login_attempts'] = ( 'on' == $options['limit_login_attempts'] ? true : false ); |
| 554 | if ( !isset( $options['login_fails_allowed'] ) ) { |
| 555 | $options['login_fails_allowed'] = 3; |
| 556 | } |
| 557 | $options['login_fails_allowed'] = ( !empty( $options['login_fails_allowed'] ) ? sanitize_text_field( $options['login_fails_allowed'] ) : 3 ); |
| 558 | if ( !isset( $options['login_lockout_maxcount'] ) ) { |
| 559 | $options['login_lockout_maxcount'] = 3; |
| 560 | } |
| 561 | $options['login_lockout_maxcount'] = ( !empty( $options['login_lockout_maxcount'] ) ? sanitize_text_field( $options['login_lockout_maxcount'] ) : 3 ); |
| 562 | if ( !isset( $options['login_attempts_log_table'] ) ) { |
| 563 | $options['login_attempts_log_table'] = ''; |
| 564 | } |
| 565 | $options['login_attempts_log_table'] = ''; |
| 566 | // Obfuscate Author Slugs |
| 567 | if ( !isset( $options['obfuscate_author_slugs'] ) ) { |
| 568 | $options['obfuscate_author_slugs'] = false; |
| 569 | } |
| 570 | $options['obfuscate_author_slugs'] = ( 'on' == $options['obfuscate_author_slugs'] ? true : false ); |
| 571 | // Obfuscate Email Address |
| 572 | if ( !isset( $options['obfuscate_email_address'] ) ) { |
| 573 | $options['obfuscate_email_address'] = false; |
| 574 | } |
| 575 | $options['obfuscate_email_address'] = ( 'on' == $options['obfuscate_email_address'] ? true : false ); |
| 576 | if ( !isset( $options['obfuscate_email_address_in_content'] ) ) { |
| 577 | $options['obfuscate_email_address_in_content'] = false; |
| 578 | } |
| 579 | $options['obfuscate_email_address_in_content'] = ( 'on' == $options['obfuscate_email_address_in_content'] ? true : false ); |
| 580 | // Disable XML-RPC |
| 581 | if ( !isset( $options['disable_xmlrpc'] ) ) { |
| 582 | $options['disable_xmlrpc'] = false; |
| 583 | } |
| 584 | $options['disable_xmlrpc'] = ( 'on' == $options['disable_xmlrpc'] ? true : false ); |
| 585 | // ================================================================= |
| 586 | // OPTIMIZATIONS |
| 587 | // ================================================================= |
| 588 | // Image Upload Control |
| 589 | if ( !isset( $options['image_upload_control'] ) ) { |
| 590 | $options['image_upload_control'] = false; |
| 591 | } |
| 592 | $options['image_upload_control'] = ( 'on' == $options['image_upload_control'] ? true : false ); |
| 593 | if ( !isset( $options['image_max_width'] ) ) { |
| 594 | $options['image_max_width'] = 1920; |
| 595 | } |
| 596 | $options['image_max_width'] = ( !empty( $options['image_max_width'] ) ? sanitize_text_field( $options['image_max_width'] ) : 1920 ); |
| 597 | if ( !isset( $options['image_max_height'] ) ) { |
| 598 | $options['image_max_height'] = 1920; |
| 599 | } |
| 600 | $options['image_max_height'] = ( !empty( $options['image_max_height'] ) ? sanitize_text_field( $options['image_max_height'] ) : 1920 ); |
| 601 | // Enable Revisions Control |
| 602 | if ( !isset( $options['enable_revisions_control'] ) ) { |
| 603 | $options['enable_revisions_control'] = false; |
| 604 | } |
| 605 | $options['enable_revisions_control'] = ( 'on' == $options['enable_revisions_control'] ? true : false ); |
| 606 | if ( !isset( $options['revisions_max_number'] ) ) { |
| 607 | $options['revisions_max_number'] = 10; |
| 608 | } |
| 609 | $options['revisions_max_number'] = ( !empty( $options['revisions_max_number'] ) ? sanitize_text_field( $options['revisions_max_number'] ) : 10 ); |
| 610 | if ( is_array( $asenha_revisions_post_types ) ) { |
| 611 | foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { |
| 612 | // e.g. $post_type_slug is post, |
| 613 | if ( !isset( $options['enable_revisions_control_for'][$post_type_slug] ) ) { |
| 614 | $options['enable_revisions_control_for'][$post_type_slug] = false; |
| 615 | } |
| 616 | $options['enable_revisions_control_for'][$post_type_slug] = ( 'on' == $options['enable_revisions_control_for'][$post_type_slug] ? true : false ); |
| 617 | } |
| 618 | } |
| 619 | // Enable Heartbeat Control |
| 620 | if ( !isset( $options['enable_heartbeat_control'] ) ) { |
| 621 | $options['enable_heartbeat_control'] = false; |
| 622 | } |
| 623 | $options['enable_heartbeat_control'] = ( 'on' == $options['enable_heartbeat_control'] ? true : false ); |
| 624 | if ( !isset( $options['heartbeat_control_for_admin_pages'] ) ) { |
| 625 | $options['heartbeat_control_for_admin_pages'] = 'default'; |
| 626 | } |
| 627 | if ( !isset( $options['heartbeat_control_for_post_edit'] ) ) { |
| 628 | $options['heartbeat_control_for_post_edit'] = 'default'; |
| 629 | } |
| 630 | if ( !isset( $options['heartbeat_control_for_frontend'] ) ) { |
| 631 | $options['heartbeat_control_for_frontend'] = 'default'; |
| 632 | } |
| 633 | if ( !isset( $options['heartbeat_interval_for_admin_pages'] ) ) { |
| 634 | $options['heartbeat_interval_for_admin_pages'] = 60; |
| 635 | } |
| 636 | $options['heartbeat_interval_for_admin_pages'] = ( !empty( $options['heartbeat_interval_for_admin_pages'] ) ? sanitize_text_field( $options['heartbeat_interval_for_admin_pages'] ) : 60 ); |
| 637 | if ( !isset( $options['heartbeat_interval_for_post_edit'] ) ) { |
| 638 | $options['heartbeat_interval_for_post_edit'] = 15; |
| 639 | } |
| 640 | $options['heartbeat_interval_for_post_edit'] = ( !empty( $options['heartbeat_interval_for_post_edit'] ) ? sanitize_text_field( $options['heartbeat_interval_for_post_edit'] ) : 15 ); |
| 641 | if ( !isset( $options['heartbeat_interval_for_frontend'] ) ) { |
| 642 | $options['heartbeat_interval_for_frontend'] = 60; |
| 643 | } |
| 644 | $options['heartbeat_interval_for_frontend'] = ( !empty( $options['heartbeat_interval_for_frontend'] ) ? sanitize_text_field( $options['heartbeat_interval_for_frontend'] ) : 60 ); |
| 645 | // ================================================================= |
| 646 | // UTILITIES |
| 647 | // ================================================================= |
| 648 | // SMTP Email Delivery |
| 649 | if ( !isset( $options['smtp_email_delivery'] ) ) { |
| 650 | $options['smtp_email_delivery'] = false; |
| 651 | } |
| 652 | $options['smtp_email_delivery'] = ( 'on' == $options['smtp_email_delivery'] ? true : false ); |
| 653 | if ( !isset( $options['smtp_host'] ) ) { |
| 654 | $options['smtp_host'] = ''; |
| 655 | } |
| 656 | $options['smtp_host'] = ( !empty( $options['smtp_host'] ) ? sanitize_text_field( $options['smtp_host'] ) : '' ); |
| 657 | if ( !isset( $options['smtp_port'] ) ) { |
| 658 | $options['smtp_port'] = ''; |
| 659 | } |
| 660 | $options['smtp_port'] = ( !empty( $options['smtp_port'] ) ? $options['smtp_port'] : '' ); |
| 661 | if ( !isset( $options['smtp_security'] ) ) { |
| 662 | $options['smtp_security'] = 'none'; |
| 663 | } |
| 664 | $options['smtp_security'] = ( !empty( $options['smtp_security'] ) ? $options['smtp_security'] : 'none' ); |
| 665 | if ( !isset( $options['smtp_username'] ) ) { |
| 666 | $options['smtp_username'] = ''; |
| 667 | } |
| 668 | $options['smtp_username'] = ( !empty( $options['smtp_username'] ) ? sanitize_text_field( $options['smtp_username'] ) : '' ); |
| 669 | if ( !isset( $options['smtp_password'] ) ) { |
| 670 | $options['smtp_password'] = ''; |
| 671 | } |
| 672 | $options['smtp_password'] = ( !empty( $options['smtp_password'] ) ? $options['smtp_password'] : '' ); |
| 673 | if ( !isset( $options['smtp_default_from_name'] ) ) { |
| 674 | $options['smtp_default_from_name'] = ''; |
| 675 | } |
| 676 | $options['smtp_default_from_name'] = ( !empty( $options['smtp_default_from_name'] ) ? sanitize_text_field( $options['smtp_default_from_name'] ) : '' ); |
| 677 | if ( !isset( $options['smtp_default_from_email'] ) ) { |
| 678 | $options['smtp_default_from_email'] = ''; |
| 679 | } |
| 680 | $options['smtp_default_from_email'] = ( !empty( $options['smtp_default_from_email'] ) ? sanitize_text_field( $options['smtp_default_from_email'] ) : '' ); |
| 681 | if ( !isset( $options['smtp_default_from_description'] ) ) { |
| 682 | $options['smtp_default_from_description'] = ''; |
| 683 | } |
| 684 | if ( !isset( $options['smtp_force_from'] ) ) { |
| 685 | $options['smtp_force_from'] = false; |
| 686 | } |
| 687 | $options['smtp_force_from'] = ( 'on' == $options['smtp_force_from'] ? true : false ); |
| 688 | if ( !isset( $options['smtp_bypass_ssl_verification'] ) ) { |
| 689 | $options['smtp_bypass_ssl_verification'] = false; |
| 690 | } |
| 691 | $options['smtp_bypass_ssl_verification'] = ( 'on' == $options['smtp_bypass_ssl_verification'] ? true : false ); |
| 692 | if ( !isset( $options['smtp_debug'] ) ) { |
| 693 | $options['smtp_debug'] = false; |
| 694 | } |
| 695 | $options['smtp_debug'] = ( 'on' == $options['smtp_debug'] ? true : false ); |
| 696 | // Multiple User Roles |
| 697 | if ( !isset( $options['multiple_user_roles'] ) ) { |
| 698 | $options['multiple_user_roles'] = false; |
| 699 | } |
| 700 | $options['multiple_user_roles'] = ( 'on' == $options['multiple_user_roles'] ? true : false ); |
| 701 | // Image Sizes Panel |
| 702 | if ( !isset( $options['image_sizes_panel'] ) ) { |
| 703 | $options['image_sizes_panel'] = false; |
| 704 | } |
| 705 | $options['image_sizes_panel'] = ( 'on' == $options['image_sizes_panel'] ? true : false ); |
| 706 | // View Admin as Role |
| 707 | if ( !isset( $options['view_admin_as_role'] ) ) { |
| 708 | $options['view_admin_as_role'] = false; |
| 709 | } |
| 710 | $options['view_admin_as_role'] = ( 'on' == $options['view_admin_as_role'] ? true : false ); |
| 711 | // Enable Password Protection |
| 712 | if ( !isset( $options['enable_password_protection'] ) ) { |
| 713 | $options['enable_password_protection'] = false; |
| 714 | } |
| 715 | $options['enable_password_protection'] = ( 'on' == $options['enable_password_protection'] ? true : false ); |
| 716 | if ( !isset( $options['password_protection_password'] ) ) { |
| 717 | $options['password_protection_password'] = 'secret'; |
| 718 | } |
| 719 | $options['password_protection_password'] = ( !empty( $options['password_protection_password'] ) ? $options['password_protection_password'] : 'secret' ); |
| 720 | // Maintenance Mode |
| 721 | if ( !isset( $options['maintenance_mode'] ) ) { |
| 722 | $options['maintenance_mode'] = false; |
| 723 | } |
| 724 | $options['maintenance_mode'] = ( 'on' == $options['maintenance_mode'] ? true : false ); |
| 725 | if ( !isset( $options['maintenance_page_heading'] ) ) { |
| 726 | $options['maintenance_page_heading'] = 'We\'ll be back soon.'; |
| 727 | } |
| 728 | $options['maintenance_page_heading'] = ( !empty( $options['maintenance_page_heading'] ) ? sanitize_text_field( $options['maintenance_page_heading'] ) : 'We\'ll be back soon.' ); |
| 729 | if ( !isset( $options['maintenance_page_description'] ) ) { |
| 730 | $options['maintenance_page_description'] = 'This site is undergoing maintenance for an extended period today. Thanks for your patience.'; |
| 731 | } |
| 732 | $options['maintenance_page_description'] = ( !empty( $options['maintenance_page_description'] ) ? sanitize_text_field( $options['maintenance_page_description'] ) : 'This site is undergoing maintenance for an extended period today. Thanks for your patience.' ); |
| 733 | if ( !isset( $options['maintenance_page_background'] ) ) { |
| 734 | $options['maintenance_page_background'] = 'stripes'; |
| 735 | } |
| 736 | $options['maintenance_page_background'] = ( !empty( $options['maintenance_page_background'] ) ? $options['maintenance_page_background'] : 'stripes' ); |
| 737 | if ( !isset( $options['maintenance_mode_description'] ) ) { |
| 738 | $options['maintenance_mode_description'] = ''; |
| 739 | } |
| 740 | // Redirect 404 to Homepage |
| 741 | if ( !isset( $options['redirect_404_to_homepage'] ) ) { |
| 742 | $options['redirect_404_to_homepage'] = false; |
| 743 | } |
| 744 | $options['redirect_404_to_homepage'] = ( 'on' == $options['redirect_404_to_homepage'] ? true : false ); |
| 745 | // Show System Summary in At a Glance Dashboard Widget |
| 746 | if ( !isset( $options['display_system_summary'] ) ) { |
| 747 | $options['display_system_summary'] = false; |
| 748 | } |
| 749 | $options['display_system_summary'] = ( 'on' == $options['display_system_summary'] ? true : false ); |
| 750 | // Search Engines Visibility Status |
| 751 | if ( !isset( $options['search_engine_visibility_status'] ) ) { |
| 752 | $options['search_engine_visibility_status'] = false; |
| 753 | } |
| 754 | $options['search_engine_visibility_status'] = ( 'on' == $options['search_engine_visibility_status'] ? true : false ); |
| 755 | return $options; |
| 756 | } |
| 757 | |
| 758 | /** |
| 759 | * Sanitize checkbox field. For reference purpose. Not currently in use. |
| 760 | * |
| 761 | * @since 1.0.0 |
| 762 | */ |
| 763 | function asenha_sanitize_checkbox_field( $value ) { |
| 764 | // A checked checkbox field will originally be saved as an 'on' value in the option. We transform that into true (shown as 1) or false (shown as empty value) |
| 765 | return ( 'on' === $value ? true : false ); |
| 766 | } |
| 767 | |
| 768 | } |
| 769 |