-
Notifications
You must be signed in to change notification settings - Fork 9
/
options.php
26 lines (25 loc) · 1.73 KB
/
options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( isset( $_POST ) && ! empty( $_POST ) ) {
if ( ! current_user_can( 'edit_surveys' ) || ! wp_verify_nonce( $_POST['_nonce'], 'awesome-surveys-update-options' ) ) {
wp_die( __( 'Cheatin’ uh?', 'wordpress' ), 403 );
}
$plugin_options = Awesome_Surveys_Admin::$options;
$posted_options = $_POST['options'];
$options_to_save = wp_parse_args( $_POST['options'], $plugin_options );
/*
TO DO: There's got to be a better way to handle all of this
*/
$options_to_save['general_options']['include_css'] = absint( $options_to_save['general_options']['include_css'] );
$options_to_save['email_options']['enable_emails'] = absint( $options_to_save['email_options']['enable_emails'] );
$options_to_save['email_options']['enable_respondent_email'] = absint( $options_to_save['email_options']['enable_respondent_email'] );
$options_to_save['email_options']['email_subject'] = sanitize_text_field( $options_to_save['email_options']['email_subject'] );
$options_to_save['email_options']['mail_to'] = sanitize_email( $options_to_save['email_options']['mail_to'] );
$options_to_save['email_options']['respondent_email_message'] = wp_filter_kses( $options_to_save['email_options']['respondent_email_message'] );
$options_to_save['general_options']['enable_captcha'] = absint( $options_to_save['general_options']['enable_captcha'] );
$options_to_save['general_options']['captcha_site_key'] = sanitize_text_field( $options_to_save['general_options']['captcha_site_key'] );
$options_to_save['general_options']['captcha_secret_key'] = sanitize_text_field( $options_to_save['general_options']['captcha_secret_key'] );
update_option( 'wwm_awesome_surveys_options', $options_to_save );
}