PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 4.9.2
Admin and Site Enhancements (ASE) v4.9.2
9.1.0 9.0.2 9.0.1 9.0.0 8.9.2 8.9.1 8.9.0 8.8.8 8.8.7 8.8.6 8.8.5 8.8.4 8.8.3 8.8.2 8.8.1 8.8.0 8.7.3 8.7.2 8.7.1 8.2.1 8.2.2 8.2.3 8.3.0 8.3.1 8.3.2 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0 8.6.1 8.6.2 8.7.0 5.0.1 5.0.2 5.0.2.1 5.0.2.2 5.0.2.3 5.0.2.4 5.1.0 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.8.0 5.8.1 6.0.0 6.0.3 6.0.4 6.0.5 6.0.5.1 6.0.6 6.0.7 6.0.8.1 6.1.0 6.1.3 6.2.0 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.3.0 6.3.1 6.3.2 6.4.0 6.5.0 6.5.1 6.6.0 6.7.0 6.8.0 6.8.2 6.8.3 6.9.0 6.9.1 6.9.10 6.9.11 6.9.12 6.9.13.1 6.9.13.2 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.2 7.0.2.1 7.0.2.2 7.0.2.3 7.0.3 7.1.0 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2.0 7.2.1 7.3.0 7.3.1 7.3.2 7.3.3 7.4.0 7.4.2 7.4.4 7.4.5 7.4.6 7.4.7 7.4.8 7.5.0 7.5.1 7.5.2 7.5.3 7.5.4 7.6.0 7.6.1 7.6.1.1 7.6.10 7.6.11 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / classes / class-settings-sanitization.php
admin-site-enhancements / classes Last commit date
class-activation.php 3 years ago class-admin-interface.php 3 years ago class-common-methods.php 3 years ago class-content-management.php 3 years ago class-custom-code.php 3 years ago class-deactivation.php 3 years ago class-disable-components.php 3 years ago class-login-logout.php 3 years ago class-optimizations.php 3 years ago class-security.php 3 years ago class-settings-fields-render.php 3 years ago class-settings-sanitization.php 3 years ago class-settings-sections-fields.php 3 years ago class-utilities.php 3 years ago
class-settings-sanitization.php
522 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 /**
13 * Sanitize options
14 *
15 * @since 1.0.0
16 */
17 function sanitize_for_options( $options ) {
18
19 // Call WordPress globals required for validating the fields
20 global $wp_roles, $asenha_public_post_types, $asenha_gutenberg_post_types, $asenha_revisions_post_types;
21 $roles = $wp_roles->get_names();
22
23 // =================================================================
24 // CONTENT MANAGEMENT
25 // =================================================================
26
27 // Enable Page and Post Duplication
28 if ( ! isset( $options['enable_duplication'] ) ) $options['enable_duplication'] = false;
29 $options['enable_duplication'] = ( 'on' == $options['enable_duplication'] ? true : false );
30
31 // Enable Media Replacement
32 if ( ! isset( $options['enable_media_replacement'] ) ) $options['enable_media_replacement'] = false;
33 $options['enable_media_replacement'] = ( 'on' == $options['enable_media_replacement'] ? true : false );
34
35 // Enable SVG Upload
36 if ( ! isset( $options['enable_svg_upload'] ) ) $options['enable_svg_upload'] = false;
37 $options['enable_svg_upload'] = ( 'on' == $options['enable_svg_upload'] ? true : false );
38
39 if ( is_array( $roles ) ) {
40 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
41 if ( ! isset( $options['enable_svg_upload_for'][$role_slug] ) ) $options['enable_svg_upload_for'][$role_slug] = false;
42 $options['enable_svg_upload_for'][$role_slug] = ( 'on' == $options['enable_svg_upload_for'][$role_slug] ? true : false );
43 }
44 }
45
46 // Enable External Permalinks
47 if ( ! isset( $options['enable_external_permalinks'] ) ) $options['enable_external_permalinks'] = false;
48 $options['enable_external_permalinks'] = ( 'on' == $options['enable_external_permalinks'] ? true : false );
49
50 if ( is_array( $asenha_public_post_types ) ) {
51 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
52 if ( ! isset( $options['enable_external_permalinks_for'][$post_type_slug] ) ) $options['enable_external_permalinks_for'][$post_type_slug] = false;
53 $options['enable_external_permalinks_for'][$post_type_slug] = ( 'on' == $options['enable_external_permalinks_for'][$post_type_slug] ? true : false );
54 }
55 }
56
57 // Open All External Links in New Tab
58 if ( ! isset( $options['external_links_new_tab'] ) ) $options['external_links_new_tab'] = false;
59 $options['external_links_new_tab'] = ( 'on' == $options['external_links_new_tab'] ? true : false );
60
61 // Enable Auto-Publishing of Posts with Missed Schedules
62 if ( ! isset( $options['enable_missed_schedule_posts_auto_publish'] ) ) $options['enable_missed_schedule_posts_auto_publish'] = false;
63 $options['enable_missed_schedule_posts_auto_publish'] = ( 'on' == $options['enable_missed_schedule_posts_auto_publish'] ? true : false );
64
65 // Enhance List Tables
66 if ( ! isset( $options['enhance_list_tables'] ) ) $options['enhance_list_tables'] = false;
67 $options['enhance_list_tables'] = ( 'on' == $options['enhance_list_tables'] ? true : false );
68
69 // Show Featured Image Column
70 if ( ! isset( $options['show_featured_image_column'] ) ) $options['show_featured_image_column'] = false;
71 $options['show_featured_image_column'] = ( 'on' == $options['show_featured_image_column'] ? true : false );
72
73 // Show Excerpt Column
74 if ( ! isset( $options['show_excerpt_column'] ) ) $options['show_excerpt_column'] = false;
75 $options['show_excerpt_column'] = ( 'on' == $options['show_excerpt_column'] ? true : false );
76
77 // Show ID Column
78 if ( ! isset( $options['show_id_column'] ) ) $options['show_id_column'] = false;
79 $options['show_id_column'] = ( 'on' == $options['show_id_column'] ? true : false );
80
81 // Show ID in Action Row
82 if ( ! isset( $options['show_id_in_action_row'] ) ) $options['show_id_in_action_row'] = false;
83 $options['show_id_in_action_row'] = ( 'on' == $options['show_id_in_action_row'] ? true : false );
84
85 // Show Custom Taxonomy Filters
86 if ( ! isset( $options['show_custom_taxonomy_filters'] ) ) $options['show_custom_taxonomy_filters'] = false;
87 $options['show_custom_taxonomy_filters'] = ( 'on' == $options['show_custom_taxonomy_filters'] ? true : false );
88
89 // Hide Comments Column
90 if ( ! isset( $options['hide_comments_column'] ) ) $options['hide_comments_column'] = false;
91 $options['hide_comments_column'] = ( 'on' == $options['hide_comments_column'] ? true : false );
92
93 // Hide Post Tags Column
94 if ( ! isset( $options['hide_post_tags_column'] ) ) $options['hide_post_tags_column'] = false;
95 $options['hide_post_tags_column'] = ( 'on' == $options['hide_post_tags_column'] ? true : false );
96
97 // =================================================================
98 // ADMIN INTERFACE
99 // =================================================================
100
101 // Hide Admin Notices
102 if ( ! isset( $options['hide_admin_notices'] ) ) $options['hide_admin_notices'] = false;
103 $options['hide_admin_notices'] = ( 'on' == $options['hide_admin_notices'] ? true : false );
104
105 // Hide Admin Bar
106 if ( ! isset( $options['hide_admin_bar'] ) ) $options['hide_admin_bar'] = false;
107 $options['hide_admin_bar'] = ( 'on' == $options['hide_admin_bar'] ? true : false );
108
109 if ( is_array( $roles ) ) {
110 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
111 if ( ! isset( $options['hide_admin_bar_for'][$role_slug] ) ) $options['hide_admin_bar_for'][$role_slug] = false;
112 $options['hide_admin_bar_for'][$role_slug] = ( 'on' == $options['hide_admin_bar_for'][$role_slug] ? true : false );
113 }
114 }
115
116 // Disable Dashboard Widgets
117 if ( ! isset( $options['disable_dashboard_widgets'] ) ) $options['disable_dashboard_widgets'] = false;
118 $options['disable_dashboard_widgets'] = ( 'on' == $options['disable_dashboard_widgets'] ? true : false );
119
120 $extra_options = get_option( 'admin_site_enhancements_extra', array() );
121 $dashboard_widgets = $extra_options['dashboard_widgets'];
122
123 if ( is_array( $dashboard_widgets ) ) {
124 foreach ( $dashboard_widgets as $widget ) {
125 if ( ! isset( $options['disabled_dashboard_widgets'][$widget['id'].'__'.$widget['context'].'__'.$widget['priority']] ) ) $options['disabled_dashboard_widgets'][$widget['id'].'__'.$widget['context'].'__'.$widget['priority']] = false;
126 $options['disabled_dashboard_widgets'][$widget['id'].'__'.$widget['context'].'__'.$widget['priority']] = ( 'on' == $options['disabled_dashboard_widgets'][$widget['id'].'__'.$widget['context'].'__'.$widget['priority']] ? true : false );
127 }
128 }
129
130 // Hide or Modify Elements
131
132 if ( ! isset( $options['hide_modify_elements'] ) ) $options['hide_modify_elements'] = false;
133 $options['hide_modify_elements'] = ( 'on' == $options['hide_modify_elements'] ? true : false );
134
135 if ( ! isset( $options['hide_ab_wp_logo_menu'] ) ) $options['hide_ab_wp_logo_menu'] = false;
136 $options['hide_ab_wp_logo_menu'] = ( 'on' == $options['hide_ab_wp_logo_menu'] ? true : false );
137
138 if ( ! isset( $options['hide_ab_customize_menu'] ) ) $options['hide_ab_customize_menu'] = false;
139 $options['hide_ab_customize_menu'] = ( 'on' == $options['hide_ab_customize_menu'] ? true : false );
140
141 if ( ! isset( $options['hide_ab_comments_menu'] ) ) $options['hide_ab_comments_menu'] = false;
142 $options['hide_ab_comments_menu'] = ( 'on' == $options['hide_ab_comments_menu'] ? true : false );
143
144 if ( ! isset( $options['hide_ab_updates_menu'] ) ) $options['hide_ab_updates_menu'] = false;
145 $options['hide_ab_updates_menu'] = ( 'on' == $options['hide_ab_updates_menu'] ? true : false );
146
147 if ( ! isset( $options['hide_ab_new_content_menu'] ) ) $options['hide_ab_new_content_menu'] = false;
148 $options['hide_ab_new_content_menu'] = ( 'on' == $options['hide_ab_new_content_menu'] ? true : false );
149
150 if ( ! isset( $options['hide_ab_howdy'] ) ) $options['hide_ab_howdy'] = false;
151 $options['hide_ab_howdy'] = ( 'on' == $options['hide_ab_howdy'] ? true : false );
152
153 if ( ! isset( $options['hide_help_drawer'] ) ) $options['hide_help_drawer'] = false;
154 $options['hide_help_drawer'] = ( 'on' == $options['hide_help_drawer'] ? true : false );
155
156 // Customize Admin Menu
157
158 if ( ! isset( $options['customize_admin_menu'] ) ) $options['customize_admin_menu'] = false;
159 $options['customize_admin_menu'] = ( 'on' == $options['customize_admin_menu'] ? true : false );
160
161 if ( ! isset( $options['custom_menu_order'] ) ) $options['custom_menu_order'] = '';
162 // The following fields are added on rendering of custom_menu_order field
163 if ( ! isset( $options['custom_menu_titles'] ) ) $options['custom_menu_titles'] = '';
164 if ( ! isset( $options['custom_menu_hidden'] ) ) $options['custom_menu_hidden'] = '';
165
166 // =================================================================
167 // LOG IN | LOG OUT
168 // =================================================================
169
170 // Change Login URL
171 if ( ! isset( $options['change_login_url'] ) ) $options['change_login_url'] = false;
172 $options['change_login_url'] = ( 'on' == $options['change_login_url'] ? true : false );
173
174 if ( ! isset( $options['custom_login_slug'] ) ) $options['custom_login_slug'] = 'backend';
175 $options['custom_login_slug'] = ( ! empty( $options['custom_login_slug'] ) ) ? sanitize_text_field( $options['custom_login_slug'] ) : 'backend';
176
177 // Enable Login Logout Menu
178 if ( ! isset( $options['enable_login_logout_menu'] ) ) $options['enable_login_logout_menu'] = false;
179 $options['enable_login_logout_menu'] = ( 'on' == $options['enable_login_logout_menu'] ? true : false );
180
181 // Redirect After Login
182 if ( ! isset( $options['redirect_after_login'] ) ) $options['redirect_after_login'] = false;
183 $options['redirect_after_login'] = ( 'on' == $options['redirect_after_login'] ? true : false );
184
185 if ( ! isset( $options['redirect_after_login_to_slug'] ) ) $options['redirect_after_login_to_slug'] = '';
186 $options['redirect_after_login_to_slug'] = ( ! empty( $options['redirect_after_login_to_slug'] ) ) ? sanitize_text_field( $options['redirect_after_login_to_slug'] ) : '';
187
188 if ( is_array( $roles ) ) {
189 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
190 if ( ! isset( $options['redirect_after_login_for'][$role_slug] ) ) $options['redirect_after_login_for'][$role_slug] = false;
191 $options['redirect_after_login_for'][$role_slug] = ( 'on' == $options['redirect_after_login_for'][$role_slug] ? true : false );
192 }
193 }
194
195 // Redirect After Logout
196 if ( ! isset( $options['redirect_after_logout'] ) ) $options['redirect_after_logout'] = false;
197 $options['redirect_after_logout'] = ( 'on' == $options['redirect_after_logout'] ? true : false );
198
199 if ( ! isset( $options['redirect_after_logout_to_slug'] ) ) $options['redirect_after_logout_to_slug'] = '';
200 $options['redirect_after_logout_to_slug'] = ( ! empty( $options['redirect_after_logout_to_slug'] ) ) ? sanitize_text_field( $options['redirect_after_logout_to_slug'] ) : '';
201
202 if ( is_array( $roles ) ) {
203 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
204 if ( ! isset( $options['redirect_after_logout_for'][$role_slug] ) ) $options['redirect_after_logout_for'][$role_slug] = false;
205 $options['redirect_after_logout_for'][$role_slug] = ( 'on' == $options['redirect_after_logout_for'][$role_slug] ? true : false );
206 }
207 }
208
209 // Enable Last Login Column
210 if ( ! isset( $options['enable_last_login_column'] ) ) $options['enable_last_login_column'] = false;
211 $options['enable_last_login_column'] = ( 'on' == $options['enable_last_login_column'] ? true : false );
212
213 // =================================================================
214 // CUSTOM CODE
215 // =================================================================
216
217 // Enable Custom Admin CSS
218 if ( ! isset( $options['enable_custom_admin_css'] ) ) $options['enable_custom_admin_css'] = false;
219 $options['enable_custom_admin_css'] = ( 'on' == $options['enable_custom_admin_css'] ? true : false );
220
221 if ( ! isset( $options['custom_admin_css'] ) ) $options['custom_admin_css'] = '';
222 $options['custom_admin_css'] = ( ! empty( $options['custom_admin_css'] ) ) ? $options['custom_admin_css'] : '';
223
224 // Enable Custom Frontend CSS
225 if ( ! isset( $options['enable_custom_frontend_css'] ) ) $options['enable_custom_frontend_css'] = false;
226 $options['enable_custom_frontend_css'] = ( 'on' == $options['enable_custom_frontend_css'] ? true : false );
227
228 if ( ! isset( $options['custom_frontend_css'] ) ) $options['custom_frontend_css'] = '';
229 $options['custom_frontend_css'] = ( ! empty( $options['custom_frontend_css'] ) ) ? $options['custom_frontend_css'] : '';
230
231 // Custom Body Class
232 if ( ! isset( $options['enable_custom_body_class'] ) ) $options['enable_custom_body_class'] = false;
233 $options['enable_custom_body_class'] = ( 'on' == $options['enable_custom_body_class'] ? true : false );
234
235 if ( is_array( $asenha_public_post_types ) ) {
236 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
237 if ( ! isset( $options['enable_custom_body_class_for'][$post_type_slug] ) ) $options['enable_custom_body_class_for'][$post_type_slug] = false;
238 $options['enable_custom_body_class_for'][$post_type_slug] = ( 'on' == $options['enable_custom_body_class_for'][$post_type_slug] ? true : false );
239 }
240 }
241
242 // Manage ads.txt and app-ads.txt
243 if ( ! isset( $options['manage_ads_appads_txt'] ) ) $options['manage_ads_appads_txt'] = false;
244 $options['manage_ads_appads_txt'] = ( 'on' == $options['manage_ads_appads_txt'] ? true : false );
245
246 if ( ! isset( $options['ads_txt_content'] ) ) $options['ads_txt_content'] = '';
247 $options['ads_txt_content'] = ( ! empty( $options['ads_txt_content'] ) ) ? $options['ads_txt_content'] : '';
248
249 if ( ! isset( $options['app_ads_txt_content'] ) ) $options['app_ads_txt_content'] = '';
250 $options['app_ads_txt_content'] = ( ! empty( $options['app_ads_txt_content'] ) ) ? $options['app_ads_txt_content'] : '';
251
252 // Manage robots.txt
253 if ( ! isset( $options['manage_robots_txt'] ) ) $options['manage_robots_txt'] = false;
254 $options['manage_robots_txt'] = ( 'on' == $options['manage_robots_txt'] ? true : false );
255
256 if ( ! isset( $options['robots_txt_content'] ) ) {
257 $options['robots_txt_content'] = '';
258 } else {
259 if ( ! empty( $options['robots_txt_content'] ) ) {
260 $options['robots_txt_content'] = $options['robots_txt_content'];
261 $is_robots_txt_real_file = is_file( ABSPATH . 'robots.txt' );
262 // rename real robots.txt file if it exists and Mange robots.txt is enabled
263 if ( $is_robots_txt_real_file && ( 'on' == $options['manage_robots_txt'] ) ) {
264 $robots_txt_backup_filename = 'robots_backup_' . date('Y_m_d__H_i', time()) . '.txt';
265 $extra_options = get_option( ASENHA_SLUG_U . '_extra', array() );
266 $extra_options['robots_txt_backup_file_name'] = $robots_txt_backup_filename;
267 update_option( ASENHA_SLUG_U. '_extra', $extra_options );
268 rename( ABSPATH . 'robots.txt', ABSPATH . $robots_txt_backup_filename );
269 } elseif ( 'on' != $options['manage_robots_txt'] ) {
270 $extra_options = get_option( ASENHA_SLUG_U. '_extra', array() );
271 if ( array_key_exists( 'robots_txt_backup_file_name', $extra_options ) ) {
272 if ( is_file( ABSPATH . $extra_options['robots_txt_backup_file_name'] ) ) {
273 rename( ABSPATH . $extra_options['robots_txt_backup_file_name'], ABSPATH . 'robots.txt' );
274 }
275 }
276 }
277 } else {
278 $options['robots_txt_content'] = '';
279 }
280 }
281
282 // Insert <head>, <body> and <footer> code
283 if ( ! isset( $options['insert_head_body_footer_code'] ) ) $options['insert_head_body_footer_code'] = false;
284 $options['insert_head_body_footer_code'] = ( 'on' == $options['insert_head_body_footer_code'] ? true : false );
285
286 if ( ! isset( $options['head_code_priority'] ) ) $options['head_code_priority'] = '';
287 $options['head_code_priority'] = ( isset( $options['head_code_priority'] ) ) ? $options['head_code_priority'] : 10;
288
289 if ( ! isset( $options['head_code'] ) ) $options['head_code'] = '';
290 $options['head_code'] = ( ! empty( $options['head_code'] ) ) ? $options['head_code'] : '';
291
292 if ( ! isset( $options['body_code_priority'] ) ) $options['body_code_priority'] = '';
293 $options['body_code_priority'] = ( isset( $options['body_code_priority'] ) ) ? $options['body_code_priority'] : 10;
294
295 if ( ! isset( $options['body_code'] ) ) $options['body_code'] = '';
296 $options['body_code'] = ( ! empty( $options['body_code'] ) ) ? $options['body_code'] : '';
297
298 if ( ! isset( $options['footer_code_priority'] ) ) $options['footer_code_priority'] = '';
299 $options['footer_code_priority'] = ( isset( $options['footer_code_priority'] ) ) ? $options['footer_code_priority'] : 10;
300
301 if ( ! isset( $options['footer_code'] ) ) $options['footer_code'] = '';
302 $options['footer_code'] = ( ! empty( $options['footer_code'] ) ) ? $options['footer_code'] : '';
303
304 // =================================================================
305 // DISABLE COMPONENTS
306 // =================================================================
307
308 // Disable Gutenberg
309 if ( ! isset( $options['disable_gutenberg'] ) ) $options['disable_gutenberg'] = false;
310 $options['disable_gutenberg'] = ( 'on' == $options['disable_gutenberg'] ? true : false );
311
312 if ( is_array( $asenha_gutenberg_post_types ) ) {
313 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post,
314 if ( ! isset( $options['disable_gutenberg_for'][$post_type_slug] ) ) $options['disable_gutenberg_for'][$post_type_slug] = false;
315 $options['disable_gutenberg_for'][$post_type_slug] = ( 'on' == $options['disable_gutenberg_for'][$post_type_slug] ? true : false );
316 }
317 }
318
319 if ( ! isset( $options['disable_gutenberg_frontend_styles'] ) ) $options['disable_gutenberg_frontend_styles'] = false;
320 $options['disable_gutenberg_frontend_styles'] = ( 'on' == $options['disable_gutenberg_frontend_styles'] ? true : false );
321
322 // Disable Comments
323 if ( ! isset( $options['disable_comments'] ) ) $options['disable_comments'] = false;
324 $options['disable_comments'] = ( 'on' == $options['disable_comments'] ? true : false );
325
326 if ( is_array( $asenha_public_post_types ) ) {
327 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
328 if ( ! isset( $options['disable_comments_for'][$post_type_slug] ) ) $options['disable_comments_for'][$post_type_slug] = false;
329 $options['disable_comments_for'][$post_type_slug] = ( 'on' == $options['disable_comments_for'][$post_type_slug] ? true : false );
330 }
331 }
332
333 // Disable REST API
334 if ( ! isset( $options['disable_rest_api'] ) ) $options['disable_rest_api'] = false;
335 $options['disable_rest_api'] = ( 'on' == $options['disable_rest_api'] ? true : false );
336
337 // Disable Feeds
338 if ( ! isset( $options['disable_feeds'] ) ) $options['disable_feeds'] = false;
339 $options['disable_feeds'] = ( 'on' == $options['disable_feeds'] ? true : false );
340
341 // Disable Auto Updates
342 if ( ! isset( $options['disable_all_updates'] ) ) $options['disable_all_updates'] = false;
343 $options['disable_all_updates'] = ( 'on' == $options['disable_all_updates'] ? true : false );
344
345 // Disable Smaller Components
346
347 if ( ! isset( $options['disable_smaller_components'] ) ) $options['disable_smaller_components'] = false;
348 $options['disable_smaller_components'] = ( 'on' == $options['disable_smaller_components'] ? true : false );
349
350 if ( ! isset( $options['disable_head_generator_tag'] ) ) $options['disable_head_generator_tag'] = false;
351 $options['disable_head_generator_tag'] = ( 'on' == $options['disable_head_generator_tag'] ? true : false );
352
353 if ( ! isset( $options['disable_head_wlwmanifest_tag'] ) ) $options['disable_head_wlwmanifest_tag'] = false;
354 $options['disable_head_wlwmanifest_tag'] = ( 'on' == $options['disable_head_wlwmanifest_tag'] ? true : false );
355
356 if ( ! isset( $options['disable_head_rsd_tag'] ) ) $options['disable_head_rsd_tag'] = false;
357 $options['disable_head_rsd_tag'] = ( 'on' == $options['disable_head_rsd_tag'] ? true : false );
358
359 if ( ! isset( $options['disable_head_shortlink_tag'] ) ) $options['disable_head_shortlink_tag'] = false;
360 $options['disable_head_shortlink_tag'] = ( 'on' == $options['disable_head_shortlink_tag'] ? true : false );
361
362 if ( ! isset( $options['disable_frontend_dashicons'] ) ) $options['disable_frontend_dashicons'] = false;
363 $options['disable_frontend_dashicons'] = ( 'on' == $options['disable_frontend_dashicons'] ? true : false );
364
365 if ( ! isset( $options['disable_emoji_support'] ) ) $options['disable_emoji_support'] = false;
366 $options['disable_emoji_support'] = ( 'on' == $options['disable_emoji_support'] ? true : false );
367
368 // =================================================================
369 // SECURITY
370 // =================================================================
371
372 // Limit Login Attempts
373 if ( ! isset( $options['limit_login_attempts'] ) ) $options['limit_login_attempts'] = false;
374 $options['limit_login_attempts'] = ( 'on' == $options['limit_login_attempts'] ? true : false );
375
376 if ( ! isset( $options['login_fails_allowed'] ) ) $options['login_fails_allowed'] = 3;
377 $options['login_fails_allowed'] = ( ! empty( $options['login_fails_allowed'] ) ) ? sanitize_text_field( $options['login_fails_allowed'] ) : 3;
378
379 if ( ! isset( $options['login_lockout_maxcount'] ) ) $options['login_lockout_maxcount'] = 3;
380 $options['login_lockout_maxcount'] = ( ! empty( $options['login_lockout_maxcount'] ) ) ? sanitize_text_field( $options['login_lockout_maxcount'] ) : 3;
381
382 if ( ! isset( $options['login_attempts_log_table'] ) ) $options['login_attempts_log_table'] = '';
383 $options['login_attempts_log_table'] = '';
384
385 // Obfuscate Author Slugs
386 if ( ! isset( $options['obfuscate_author_slugs'] ) ) $options['obfuscate_author_slugs'] = false;
387 $options['obfuscate_author_slugs'] = ( 'on' == $options['obfuscate_author_slugs'] ? true : false );
388
389 // Disable XML-RPC
390 if ( ! isset( $options['disable_xmlrpc'] ) ) $options['disable_xmlrpc'] = false;
391 $options['disable_xmlrpc'] = ( 'on' == $options['disable_xmlrpc'] ? true : false );
392
393 // =================================================================
394 // OPTIMIZATIONS
395 // =================================================================
396
397 // Image Upload Control
398 if ( ! isset( $options['image_upload_control'] ) ) $options['image_upload_control'] = false;
399 $options['image_upload_control'] = ( 'on' == $options['image_upload_control'] ? true : false );
400
401 if ( ! isset( $options['image_max_width'] ) ) $options['image_max_width'] = 1920;
402 $options['image_max_width'] = ( ! empty( $options['image_max_width'] ) ) ? sanitize_text_field( $options['image_max_width'] ) : 1920;
403
404 if ( ! isset( $options['image_max_height'] ) ) $options['image_max_height'] = 1920;
405 $options['image_max_height'] = ( ! empty( $options['image_max_height'] ) ) ? sanitize_text_field( $options['image_max_height'] ) : 1920;
406
407 // Enable Revisions Control
408 if ( ! isset( $options['enable_revisions_control'] ) ) $options['enable_revisions_control'] = false;
409 $options['enable_revisions_control'] = ( 'on' == $options['enable_revisions_control'] ? true : false );
410
411 if ( ! isset( $options['revisions_max_number'] ) ) $options['revisions_max_number'] = 10;
412 $options['revisions_max_number'] = ( ! empty( $options['revisions_max_number'] ) ) ? sanitize_text_field( $options['revisions_max_number'] ) : 10;
413
414 if ( is_array( $asenha_revisions_post_types ) ) {
415 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post,
416 if ( ! isset( $options['enable_revisions_control_for'][$post_type_slug] ) ) $options['enable_revisions_control_for'][$post_type_slug] = false;
417 $options['enable_revisions_control_for'][$post_type_slug] = ( 'on' == $options['enable_revisions_control_for'][$post_type_slug] ? true : false );
418 }
419 }
420
421 // Enable Heartbeat Control
422 if ( ! isset( $options['enable_heartbeat_control'] ) ) $options['enable_heartbeat_control'] = false;
423 $options['enable_heartbeat_control'] = ( 'on' == $options['enable_heartbeat_control'] ? true : false );
424
425 if ( ! isset( $options['heartbeat_control_for_admin_pages'] ) ) $options['enable_heartbeat_control'] = 'default';
426 if ( ! isset( $options['heartbeat_control_for_post_edit'] ) ) $options['heartbeat_control_for_post_edit'] = 'default';
427 if ( ! isset( $options['heartbeat_control_for_frontend'] ) ) $options['heartbeat_control_for_frontend'] = 'default';
428
429 if ( ! isset( $options['heartbeat_interval_for_admin_pages'] ) ) $options['heartbeat_interval_for_admin_pages'] = 60;
430 $options['heartbeat_interval_for_admin_pages'] = ( ! empty( $options['heartbeat_interval_for_admin_pages'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_admin_pages'] ) : 60;
431
432 if ( ! isset( $options['heartbeat_interval_for_post_edit'] ) ) $options['heartbeat_interval_for_post_edit'] = 15;
433 $options['heartbeat_interval_for_post_edit'] = ( ! empty( $options['heartbeat_interval_for_post_edit'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_post_edit'] ) : 15;
434
435 if ( ! isset( $options['heartbeat_interval_for_frontend'] ) ) $options['heartbeat_interval_for_frontend'] = 60;
436 $options['heartbeat_interval_for_frontend'] = ( ! empty( $options['heartbeat_interval_for_frontend'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_frontend'] ) : 60;
437
438 // =================================================================
439 // UTILITIES
440 // =================================================================
441
442 // SMTP Email Delivery
443 if ( ! isset( $options['smtp_email_delivery'] ) ) $options['smtp_email_delivery'] = false;
444 $options['smtp_email_delivery'] = ( 'on' == $options['smtp_email_delivery'] ? true : false );
445
446 if ( ! isset( $options['smtp_host'] ) ) $options['smtp_host'] = '';
447 $options['smtp_host'] = ( ! empty( $options['smtp_host'] ) ) ? sanitize_text_field( $options['smtp_host'] ) : '';
448
449 if ( ! isset( $options['smtp_port'] ) ) $options['smtp_port'] = '';
450 $options['smtp_port'] = ( ! empty( $options['smtp_port'] ) ) ? $options['smtp_port'] : '';
451
452 if ( ! isset( $options['smtp_security'] ) ) $options['smtp_security'] = 'none';
453 $options['smtp_security'] = ( ! empty( $options['smtp_security'] ) ) ? $options['smtp_security'] : 'none';
454
455 if ( ! isset( $options['smtp_username'] ) ) $options['smtp_username'] = '';
456 $options['smtp_username'] = ( ! empty( $options['smtp_username'] ) ) ? sanitize_text_field( $options['smtp_username'] ) : '';
457
458 if ( ! isset( $options['smtp_password'] ) ) $options['smtp_password'] = base64_encode('');
459 $options['smtp_password'] = ( ! empty( $options['smtp_password'] ) ) ? base64_encode( $options['smtp_password'] ) : base64_encode('');
460
461 if ( ! isset( $options['smtp_default_from_name'] ) ) $options['smtp_default_from_name'] = '';
462 $options['smtp_default_from_name'] = ( ! empty( $options['smtp_default_from_name'] ) ) ? sanitize_text_field( $options['smtp_default_from_name'] ) : '';
463
464 if ( ! isset( $options['smtp_default_from_email'] ) ) $options['smtp_default_from_email'] = '';
465 $options['smtp_default_from_email'] = ( ! empty( $options['smtp_default_from_email'] ) ) ? sanitize_text_field( $options['smtp_default_from_email'] ) : '';
466
467 if ( ! isset( $options['smtp_default_from_description'] ) ) $options['smtp_default_from_description'] = '';
468
469 if ( ! isset( $options['smtp_debug'] ) ) $options['smtp_debug'] = false;
470 $options['smtp_debug'] = ( 'on' == $options['smtp_debug'] ? true : false );
471
472 // Multiple User Roles
473 if ( ! isset( $options['multiple_user_roles'] ) ) $options['multiple_user_roles'] = false;
474 $options['multiple_user_roles'] = ( 'on' == $options['multiple_user_roles'] ? true : false );
475
476 // View Admin as Role
477 if ( ! isset( $options['view_admin_as_role'] ) ) $options['view_admin_as_role'] = false;
478 $options['view_admin_as_role'] = ( 'on' == $options['view_admin_as_role'] ? true : false );
479
480 // Enable Password Protection
481 if ( ! isset( $options['enable_password_protection'] ) ) $options['enable_password_protection'] = false;
482 $options['enable_password_protection'] = ( 'on' == $options['enable_password_protection'] ? true : false );
483
484 if ( ! isset( $options['password_protection_password'] ) ) $options['password_protection_password'] = base64_encode('secret');
485 $options['password_protection_password'] = ( ! empty( $options['password_protection_password'] ) ) ? base64_encode( $options['password_protection_password'] ) : base64_encode('secret');
486
487 // Redirect 404 to Homepage
488 if ( ! isset( $options['maintenance_mode'] ) ) $options['maintenance_mode'] = false;
489 $options['maintenance_mode'] = ( 'on' == $options['maintenance_mode'] ? true : false );
490
491 if ( ! isset( $options['maintenance_page_heading'] ) ) $options['maintenance_page_heading'] = 'We\'ll be back soon.';
492 $options['maintenance_page_heading'] = ( ! empty( $options['maintenance_page_heading'] ) ) ? sanitize_text_field( $options['maintenance_page_heading'] ) : 'We\'ll be back soon.';
493
494 if ( ! isset( $options['maintenance_page_description'] ) ) $options['maintenance_page_description'] = 'This site is undergoing maintenance for an extended period today. Thanks for your patience.';
495 $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.';
496
497 if ( ! isset( $options['maintenance_page_background'] ) ) $options['maintenance_page_background'] = 'stripes';
498 $options['maintenance_page_background'] = ( ! empty( $options['maintenance_page_background'] ) ) ? $options['maintenance_page_background'] : 'stripes';
499
500 if ( ! isset( $options['maintenance_mode_description'] ) ) $options['maintenance_mode_description'] = '';
501
502 // Redirect 404 to Homepage
503 if ( ! isset( $options['redirect_404_to_homepage'] ) ) $options['redirect_404_to_homepage'] = false;
504 $options['redirect_404_to_homepage'] = ( 'on' == $options['redirect_404_to_homepage'] ? true : false );
505
506 return $options;
507
508 }
509
510 /**
511 * Sanitize checkbox field. For reference purpose. Not currently in use.
512 *
513 * @since 1.0.0
514 */
515 function asenha_sanitize_checkbox_field( $value ) {
516
517 // 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)
518 return 'on' === $value ? true : false;
519
520 }
521
522 }