Beispiel #1
0
function mailchimpSF_request_handler()
{
    if (isset($_POST['mcsf_action'])) {
        switch ($_POST['mcsf_action']) {
            case 'logout':
                // Check capability & Verify nonce
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'mc_logout')) {
                    wp_die('Cheatin’ huh?');
                }
                // erase API Key
                update_option('mc_apikey', '');
                break;
            case 'update_mc_apikey':
                // Check capability & Verify nonce
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_mc_api_key')) {
                    wp_die('Cheatin’ huh?');
                }
                mailchimpSF_set_api_key(strip_tags(stripslashes($_POST['mc_apikey'])));
                break;
            case 'reset_list':
                // Check capability & Verify nonce
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'reset_mailchimp_list')) {
                    wp_die('Cheatin’ huh?');
                }
                mailchimpSF_reset_list_settings();
                break;
            case 'change_form_settings':
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_general_form_settings')) {
                    wp_die('Cheatin’ huh?');
                }
                // Update the form settings
                mailchimpSF_save_general_form_settings();
                break;
            case 'mc_submit_signup_form':
                // Validate nonce
                if (!wp_verify_nonce($_POST['_mc_submit_signup_form_nonce'], 'mc_submit_signup_form')) {
                    wp_die('Cheatin’ huh?');
                }
                // Attempt the signup
                mailchimpSF_signup_submit();
                // Do a different action for html vs. js
                switch ($_POST['mc_submit_type']) {
                    case 'html':
                        /* Allow to fall through.  The widget will pick up the 
                         * global message left over from the signup_submit function */
                        break;
                    case 'js':
                        if (!headers_sent()) {
                            //just in case...
                            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT', true, 200);
                        }
                        echo mailchimpSF_global_msg();
                        // Don't esc_html this, b/c we've already escaped it
                        exit;
                }
        }
    }
}
function mailchimpSF_request_handler()
{
    if (isset($_POST['mcsf_action'])) {
        switch ($_POST['mcsf_action']) {
            case 'login':
                $key = trim($_POST['mailchimpSF_api_key']);
                try {
                    $api = new MailChimp_API($key);
                } catch (Exception $e) {
                    $msg = "<strong class='mc_error_msg'>" . $e->getMessage() . "</strong>";
                    mailchimpSF_global_msg($msg);
                    break;
                }
                $key = mailchimpSF_verify_key($api);
                if (is_wp_error($key)) {
                    $msg = "<strong class='mc_error_msg'>" . $key->get_error_message() . "</strong>";
                    mailchimpSF_global_msg($msg);
                }
                break;
            case 'logout':
                // Check capability & Verify nonce
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'mc_logout')) {
                    wp_die('Cheatin&rsquo; huh?');
                }
                // erase auth information
                $options = array('mc_api_key', 'mc_sopresto_user', 'mc_sopresto_public_key', 'mc_sopresto_secret_key');
                mailchimpSF_delete_options($options);
                break;
            case 'change_form_settings':
                if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_general_form_settings')) {
                    wp_die('Cheatin&rsquo; huh?');
                }
                // Update the form settings
                mailchimpSF_save_general_form_settings();
                break;
            case 'mc_submit_signup_form':
                // Validate nonce
                if (!wp_verify_nonce($_POST['_mc_submit_signup_form_nonce'], 'mc_submit_signup_form')) {
                    wp_die('Cheatin&rsquo; huh?');
                }
                // Attempt the signup
                mailchimpSF_signup_submit();
                // Do a different action for html vs. js
                switch ($_POST['mc_submit_type']) {
                    case 'html':
                        /* Allow to fall through.  The widget will pick up the
                         * global message left over from the signup_submit function */
                    /* Allow to fall through.  The widget will pick up the
                     * global message left over from the signup_submit function */
                    case 'js':
                        if (!headers_sent()) {
                            //just in case...
                            header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT', true, 200);
                        }
                        echo mailchimpSF_global_msg();
                        // Don't esc_html this, b/c we've already escaped it
                        exit;
                }
        }
    }
}