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