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