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