PluginProbe ʕ •ᴥ•ʔ
Admin and Site Enhancements (ASE) / 3.9.1
Admin and Site Enhancements (ASE) v3.9.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 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
370 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 // Enable Revisions Control
58 if ( ! isset( $options['enable_revisions_control'] ) ) $options['enable_revisions_control'] = false;
59 $options['enable_revisions_control'] = ( 'on' == $options['enable_revisions_control'] ? true : false );
60
61 if ( ! isset( $options['revisions_max_number'] ) ) $options['revisions_max_number'] = 10;
62 $options['revisions_max_number'] = ( ! empty( $options['revisions_max_number'] ) ) ? sanitize_text_field( $options['revisions_max_number'] ) : 10;
63
64 if ( is_array( $asenha_revisions_post_types ) ) {
65 foreach ( $asenha_revisions_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post,
66 if ( ! isset( $options['enable_revisions_control_for'][$post_type_slug] ) ) $options['enable_revisions_control_for'][$post_type_slug] = false;
67 $options['enable_revisions_control_for'][$post_type_slug] = ( 'on' == $options['enable_revisions_control_for'][$post_type_slug] ? true : false );
68 }
69 }
70
71 // Enable Auto-Publishing of Posts with Missed Schedules
72 if ( ! isset( $options['enable_missed_schedule_posts_auto_publish'] ) ) $options['enable_missed_schedule_posts_auto_publish'] = false;
73 $options['enable_missed_schedule_posts_auto_publish'] = ( 'on' == $options['enable_missed_schedule_posts_auto_publish'] ? true : false );
74
75 // Enhance List Tables
76 if ( ! isset( $options['enhance_list_tables'] ) ) $options['enhance_list_tables'] = false;
77 $options['enhance_list_tables'] = ( 'on' == $options['enhance_list_tables'] ? true : false );
78
79 // Show Featured Image Column
80 if ( ! isset( $options['show_featured_image_column'] ) ) $options['show_featured_image_column'] = false;
81 $options['show_featured_image_column'] = ( 'on' == $options['show_featured_image_column'] ? true : false );
82
83 // Show Excerpt Column
84 if ( ! isset( $options['show_excerpt_column'] ) ) $options['show_excerpt_column'] = false;
85 $options['show_excerpt_column'] = ( 'on' == $options['show_excerpt_column'] ? true : false );
86
87 // Show ID Column
88 if ( ! isset( $options['show_id_column'] ) ) $options['show_id_column'] = false;
89 $options['show_id_column'] = ( 'on' == $options['show_id_column'] ? true : false );
90
91 // Hide Comments Column
92 if ( ! isset( $options['hide_comments_column'] ) ) $options['hide_comments_column'] = false;
93 $options['hide_comments_column'] = ( 'on' == $options['hide_comments_column'] ? true : false );
94
95 // Hide Post Tags Column
96 if ( ! isset( $options['hide_post_tags_column'] ) ) $options['hide_post_tags_column'] = false;
97 $options['hide_post_tags_column'] = ( 'on' == $options['hide_post_tags_column'] ? true : false );
98
99 // Show Custom Taxonomy Filters
100 if ( ! isset( $options['show_custom_taxonomy_filters'] ) ) $options['show_custom_taxonomy_filters'] = false;
101 $options['show_custom_taxonomy_filters'] = ( 'on' == $options['show_custom_taxonomy_filters'] ? true : false );
102
103 // =================================================================
104 // ADMIN INTERFACE
105 // =================================================================
106
107 // Hide Admin Notices
108 if ( ! isset( $options['hide_admin_notices'] ) ) $options['hide_admin_notices'] = false;
109 $options['hide_admin_notices'] = ( 'on' == $options['hide_admin_notices'] ? true : false );
110
111 // Hide Admin Bar
112 if ( ! isset( $options['hide_admin_bar'] ) ) $options['hide_admin_bar'] = false;
113 $options['hide_admin_bar'] = ( 'on' == $options['hide_admin_bar'] ? true : false );
114
115 if ( is_array( $roles ) ) {
116 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
117 if ( ! isset( $options['hide_admin_bar_for'][$role_slug] ) ) $options['hide_admin_bar_for'][$role_slug] = false;
118 $options['hide_admin_bar_for'][$role_slug] = ( 'on' == $options['hide_admin_bar_for'][$role_slug] ? true : false );
119 }
120 }
121
122 // View Admin as Role
123 if ( ! isset( $options['view_admin_as_role'] ) ) $options['view_admin_as_role'] = false;
124 $options['view_admin_as_role'] = ( 'on' == $options['view_admin_as_role'] ? true : false );
125
126 // Hide or Modify Elements
127
128 if ( ! isset( $options['hide_modify_elements'] ) ) $options['hide_modify_elements'] = false;
129 $options['hide_modify_elements'] = ( 'on' == $options['hide_modify_elements'] ? true : false );
130
131 if ( ! isset( $options['hide_ab_wp_logo_menu'] ) ) $options['hide_ab_wp_logo_menu'] = false;
132 $options['hide_ab_wp_logo_menu'] = ( 'on' == $options['hide_ab_wp_logo_menu'] ? true : false );
133
134 if ( ! isset( $options['hide_ab_customize_menu'] ) ) $options['hide_ab_customize_menu'] = false;
135 $options['hide_ab_customize_menu'] = ( 'on' == $options['hide_ab_customize_menu'] ? true : false );
136
137 if ( ! isset( $options['hide_ab_comments_menu'] ) ) $options['hide_ab_comments_menu'] = false;
138 $options['hide_ab_comments_menu'] = ( 'on' == $options['hide_ab_comments_menu'] ? true : false );
139
140 if ( ! isset( $options['hide_ab_updates_menu'] ) ) $options['hide_ab_updates_menu'] = false;
141 $options['hide_ab_updates_menu'] = ( 'on' == $options['hide_ab_updates_menu'] ? true : false );
142
143 if ( ! isset( $options['hide_ab_new_content_menu'] ) ) $options['hide_ab_new_content_menu'] = false;
144 $options['hide_ab_new_content_menu'] = ( 'on' == $options['hide_ab_new_content_menu'] ? true : false );
145
146 if ( ! isset( $options['hide_ab_howdy'] ) ) $options['hide_ab_howdy'] = false;
147 $options['hide_ab_howdy'] = ( 'on' == $options['hide_ab_howdy'] ? true : false );
148
149 // Customize Admin Menu
150
151 if ( ! isset( $options['customize_admin_menu'] ) ) $options['customize_admin_menu'] = false;
152 $options['customize_admin_menu'] = ( 'on' == $options['customize_admin_menu'] ? true : false );
153
154 if ( ! isset( $options['custom_menu_order'] ) ) $options['custom_menu_order'] = '';
155 // The following fields are added on rendering of custom_menu_order field
156 if ( ! isset( $options['custom_menu_titles'] ) ) $options['custom_menu_titles'] = '';
157 if ( ! isset( $options['custom_menu_hidden'] ) ) $options['custom_menu_hidden'] = '';
158
159 // =================================================================
160 // LOG IN | LOG OUT
161 // =================================================================
162
163 // Change Login URL
164 if ( ! isset( $options['change_login_url'] ) ) $options['change_login_url'] = false;
165 $options['change_login_url'] = ( 'on' == $options['change_login_url'] ? true : false );
166
167 if ( ! isset( $options['custom_login_slug'] ) ) $options['custom_login_slug'] = 'backend';
168 $options['custom_login_slug'] = ( ! empty( $options['custom_login_slug'] ) ) ? sanitize_text_field( $options['custom_login_slug'] ) : 'backend';
169
170 // Enable Login Logout Menu
171 if ( ! isset( $options['enable_login_logout_menu'] ) ) $options['enable_login_logout_menu'] = false;
172 $options['enable_login_logout_menu'] = ( 'on' == $options['enable_login_logout_menu'] ? true : false );
173
174 // Redirect After Login
175 if ( ! isset( $options['redirect_after_login'] ) ) $options['redirect_after_login'] = false;
176 $options['redirect_after_login'] = ( 'on' == $options['redirect_after_login'] ? true : false );
177
178 if ( ! isset( $options['redirect_after_login_to_slug'] ) ) $options['redirect_after_login_to_slug'] = '';
179 $options['redirect_after_login_to_slug'] = ( ! empty( $options['redirect_after_login_to_slug'] ) ) ? sanitize_text_field( $options['redirect_after_login_to_slug'] ) : '';
180
181 if ( is_array( $roles ) ) {
182 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
183 if ( ! isset( $options['redirect_after_login_for'][$role_slug] ) ) $options['redirect_after_login_for'][$role_slug] = false;
184 $options['redirect_after_login_for'][$role_slug] = ( 'on' == $options['redirect_after_login_for'][$role_slug] ? true : false );
185 }
186 }
187
188 // Redirect After Logout
189 if ( ! isset( $options['redirect_after_logout'] ) ) $options['redirect_after_logout'] = false;
190 $options['redirect_after_logout'] = ( 'on' == $options['redirect_after_logout'] ? true : false );
191
192 if ( ! isset( $options['redirect_after_logout_to_slug'] ) ) $options['redirect_after_logout_to_slug'] = '';
193 $options['redirect_after_logout_to_slug'] = ( ! empty( $options['redirect_after_logout_to_slug'] ) ) ? sanitize_text_field( $options['redirect_after_logout_to_slug'] ) : '';
194
195 if ( is_array( $roles ) ) {
196 foreach ( $roles as $role_slug => $role_label ) { // e.g. $role_slug is administrator, $role_label is Administrator
197 if ( ! isset( $options['redirect_after_logout_for'][$role_slug] ) ) $options['redirect_after_logout_for'][$role_slug] = false;
198 $options['redirect_after_logout_for'][$role_slug] = ( 'on' == $options['redirect_after_logout_for'][$role_slug] ? true : false );
199 }
200 }
201
202 // Enable Last Login Column
203 if ( ! isset( $options['enable_last_login_column'] ) ) $options['enable_last_login_column'] = false;
204 $options['enable_last_login_column'] = ( 'on' == $options['enable_last_login_column'] ? true : false );
205
206 // =================================================================
207 // CUSTOM CODE
208 // =================================================================
209
210 // Enable Custom Admin CSS
211 if ( ! isset( $options['enable_custom_admin_css'] ) ) $options['enable_custom_admin_css'] = false;
212 $options['enable_custom_admin_css'] = ( 'on' == $options['enable_custom_admin_css'] ? true : false );
213
214 if ( ! isset( $options['custom_admin_css'] ) ) $options['custom_admin_css'] = '';
215 $options['custom_admin_css'] = ( ! empty( $options['custom_admin_css'] ) ) ? $options['custom_admin_css'] : '';
216
217 // Enable Custom Frontend CSS
218 if ( ! isset( $options['enable_custom_frontend_css'] ) ) $options['enable_custom_frontend_css'] = false;
219 $options['enable_custom_frontend_css'] = ( 'on' == $options['enable_custom_frontend_css'] ? true : false );
220
221 if ( ! isset( $options['custom_frontend_css'] ) ) $options['custom_frontend_css'] = '';
222 $options['custom_frontend_css'] = ( ! empty( $options['custom_frontend_css'] ) ) ? $options['custom_frontend_css'] : '';
223
224 // Manage ads.txt and app-ads.txt
225 if ( ! isset( $options['manage_ads_appads_txt'] ) ) $options['manage_ads_appads_txt'] = false;
226 $options['manage_ads_appads_txt'] = ( 'on' == $options['manage_ads_appads_txt'] ? true : false );
227
228 if ( ! isset( $options['ads_txt_content'] ) ) $options['ads_txt_content'] = '';
229 $options['ads_txt_content'] = ( ! empty( $options['ads_txt_content'] ) ) ? $options['ads_txt_content'] : '';
230
231 if ( ! isset( $options['app_ads_txt_content'] ) ) $options['app_ads_txt_content'] = '';
232 $options['app_ads_txt_content'] = ( ! empty( $options['app_ads_txt_content'] ) ) ? $options['app_ads_txt_content'] : '';
233
234 // Manage robots.txt
235 if ( ! isset( $options['manage_robots_txt'] ) ) $options['manage_robots_txt'] = false;
236 $options['manage_robots_txt'] = ( 'on' == $options['manage_robots_txt'] ? true : false );
237
238 if ( ! isset( $options['robots_txt_content'] ) ) $options['robots_txt_content'] = '';
239 $options['robots_txt_content'] = ( ! empty( $options['robots_txt_content'] ) ) ? $options['robots_txt_content'] : '';
240
241 // Insert <head>, <body> and <footer> code
242 if ( ! isset( $options['insert_head_body_footer_code'] ) ) $options['insert_head_body_footer_code'] = false;
243 $options['insert_head_body_footer_code'] = ( 'on' == $options['insert_head_body_footer_code'] ? true : false );
244
245 if ( ! isset( $options['head_code_priority'] ) ) $options['head_code_priority'] = '';
246 $options['head_code_priority'] = ( isset( $options['head_code_priority'] ) ) ? $options['head_code_priority'] : 10;
247
248 if ( ! isset( $options['head_code'] ) ) $options['head_code'] = '';
249 $options['head_code'] = ( ! empty( $options['head_code'] ) ) ? $options['head_code'] : '';
250
251 if ( ! isset( $options['body_code_priority'] ) ) $options['body_code_priority'] = '';
252 $options['body_code_priority'] = ( isset( $options['body_code_priority'] ) ) ? $options['body_code_priority'] : 10;
253
254 if ( ! isset( $options['body_code'] ) ) $options['body_code'] = '';
255 $options['body_code'] = ( ! empty( $options['body_code'] ) ) ? $options['body_code'] : '';
256
257 if ( ! isset( $options['footer_code_priority'] ) ) $options['footer_code_priority'] = '';
258 $options['footer_code_priority'] = ( isset( $options['footer_code_priority'] ) ) ? $options['footer_code_priority'] : 10;
259
260 if ( ! isset( $options['footer_code'] ) ) $options['footer_code'] = '';
261 $options['footer_code'] = ( ! empty( $options['footer_code'] ) ) ? $options['footer_code'] : '';
262
263 // =================================================================
264 // DISABLE COMPONENTS
265 // =================================================================
266
267 // Disable Gutenberg
268 if ( ! isset( $options['disable_gutenberg'] ) ) $options['disable_gutenberg'] = false;
269 $options['disable_gutenberg'] = ( 'on' == $options['disable_gutenberg'] ? true : false );
270
271 if ( is_array( $asenha_gutenberg_post_types ) ) {
272 foreach ( $asenha_gutenberg_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post,
273 if ( ! isset( $options['disable_gutenberg_for'][$post_type_slug] ) ) $options['disable_gutenberg_for'][$post_type_slug] = false;
274 $options['disable_gutenberg_for'][$post_type_slug] = ( 'on' == $options['disable_gutenberg_for'][$post_type_slug] ? true : false );
275 }
276 }
277
278 if ( ! isset( $options['disable_gutenberg_frontend_styles'] ) ) $options['disable_gutenberg_frontend_styles'] = false;
279 $options['disable_gutenberg_frontend_styles'] = ( 'on' == $options['disable_gutenberg_frontend_styles'] ? true : false );
280
281 // Disable Comments
282 if ( ! isset( $options['disable_comments'] ) ) $options['disable_comments'] = false;
283 $options['disable_comments'] = ( 'on' == $options['disable_comments'] ? true : false );
284
285 if ( is_array( $asenha_public_post_types ) ) {
286 foreach ( $asenha_public_post_types as $post_type_slug => $post_type_label ) { // e.g. $post_type_slug is post, $post_type_label is Posts
287 if ( ! isset( $options['disable_comments_for'][$post_type_slug] ) ) $options['disable_comments_for'][$post_type_slug] = false;
288 $options['disable_comments_for'][$post_type_slug] = ( 'on' == $options['disable_comments_for'][$post_type_slug] ? true : false );
289 }
290 }
291
292 // Disable REST API
293 if ( ! isset( $options['disable_rest_api'] ) ) $options['disable_rest_api'] = false;
294 $options['disable_rest_api'] = ( 'on' == $options['disable_rest_api'] ? true : false );
295
296 // Disable Feeds
297 if ( ! isset( $options['disable_feeds'] ) ) $options['disable_feeds'] = false;
298 $options['disable_feeds'] = ( 'on' == $options['disable_feeds'] ? true : false );
299
300 // =================================================================
301 // SECURITY
302 // =================================================================
303
304 // Limit Login Attempts
305 if ( ! isset( $options['limit_login_attempts'] ) ) $options['limit_login_attempts'] = false;
306 $options['limit_login_attempts'] = ( 'on' == $options['limit_login_attempts'] ? true : false );
307
308 if ( ! isset( $options['login_fails_allowed'] ) ) $options['login_fails_allowed'] = 3;
309 $options['login_fails_allowed'] = ( ! empty( $options['login_fails_allowed'] ) ) ? sanitize_text_field( $options['login_fails_allowed'] ) : 3;
310
311 if ( ! isset( $options['login_lockout_maxcount'] ) ) $options['login_lockout_maxcount'] = 3;
312 $options['login_lockout_maxcount'] = ( ! empty( $options['login_lockout_maxcount'] ) ) ? sanitize_text_field( $options['login_lockout_maxcount'] ) : 3;
313
314 if ( ! isset( $options['login_attempts_log_table'] ) ) $options['login_attempts_log_table'] = '';
315 $options['login_attempts_log_table'] = '';
316
317 // Obfuscate Author Slugs
318 if ( ! isset( $options['obfuscate_author_slugs'] ) ) $options['obfuscate_author_slugs'] = false;
319 $options['obfuscate_author_slugs'] = ( 'on' == $options['obfuscate_author_slugs'] ? true : false );
320
321 // Disable XML-RPC
322 if ( ! isset( $options['disable_xmlrpc'] ) ) $options['disable_xmlrpc'] = false;
323 $options['disable_xmlrpc'] = ( 'on' == $options['disable_xmlrpc'] ? true : false );
324
325 // =================================================================
326 // OPTIMIZATIONS
327 // =================================================================
328
329 // Enable Heartbeat Control
330 if ( ! isset( $options['enable_heartbeat_control'] ) ) $options['enable_heartbeat_control'] = false;
331 $options['enable_heartbeat_control'] = ( 'on' == $options['enable_heartbeat_control'] ? true : false );
332
333 if ( ! isset( $options['heartbeat_control_for_admin_pages'] ) ) $options['enable_heartbeat_control'] = 'default';
334 if ( ! isset( $options['heartbeat_control_for_post_edit'] ) ) $options['heartbeat_control_for_post_edit'] = 'default';
335 if ( ! isset( $options['heartbeat_control_for_frontend'] ) ) $options['heartbeat_control_for_frontend'] = 'default';
336
337 if ( ! isset( $options['heartbeat_interval_for_admin_pages'] ) ) $options['heartbeat_interval_for_admin_pages'] = 60;
338 $options['heartbeat_interval_for_admin_pages'] = ( ! empty( $options['heartbeat_interval_for_admin_pages'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_admin_pages'] ) : 60;
339
340 if ( ! isset( $options['heartbeat_interval_for_post_edit'] ) ) $options['heartbeat_interval_for_post_edit'] = 15;
341 $options['heartbeat_interval_for_post_edit'] = ( ! empty( $options['heartbeat_interval_for_post_edit'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_post_edit'] ) : 15;
342
343 if ( ! isset( $options['heartbeat_interval_for_frontend'] ) ) $options['heartbeat_interval_for_frontend'] = 60;
344 $options['heartbeat_interval_for_frontend'] = ( ! empty( $options['heartbeat_interval_for_frontend'] ) ) ? sanitize_text_field( $options['heartbeat_interval_for_frontend'] ) : 60;
345
346 // =================================================================
347 // UTILITIES
348 // =================================================================
349
350 // Redirect 404 to Homepage
351 if ( ! isset( $options['redirect_404_to_homepage'] ) ) $options['redirect_404_to_homepage'] = false;
352 $options['redirect_404_to_homepage'] = ( 'on' == $options['redirect_404_to_homepage'] ? true : false );
353
354 return $options;
355
356 }
357
358 /**
359 * Sanitize checkbox field. For reference purpose. Not currently in use.
360 *
361 * @since 1.0.0
362 */
363 function asenha_sanitize_checkbox_field( $value ) {
364
365 // 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)
366 return 'on' === $value ? true : false;
367
368 }
369
370 }