function ssba_settings()
{
    // check if user has the rights to manage options
    if (!current_user_can('manage_options')) {
        // permissions message
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // if a post has been made
    if (isset($_POST['ssbaData'])) {
        // get posted data
        $ssbaPost = $_POST['ssbaData'];
        parse_str($ssbaPost, $ssbaPost);
        // if the nonce doesn't check out...
        if (!isset($ssbaPost['ssba_save_nonce']) || !wp_verify_nonce($ssbaPost['ssba_save_nonce'], 'ssba_save_settings')) {
            die('There was no nonce provided, or the one provided did not verify.');
        }
        // prepare array
        $arrOptions = array('ssba_image_set' => $ssbaPost['ssba_image_set'], 'ssba_size' => $ssbaPost['ssba_size'], 'ssba_pages' => isset($ssbaPost['ssba_pages']) ? $ssbaPost['ssba_pages'] : NULL, 'ssba_posts' => isset($ssbaPost['ssba_posts']) ? $ssbaPost['ssba_posts'] : NULL, 'ssba_cats_archs' => isset($ssbaPost['ssba_cats_archs']) ? $ssbaPost['ssba_cats_archs'] : NULL, 'ssba_homepage' => isset($ssbaPost['ssba_homepage']) ? $ssbaPost['ssba_homepage'] : NULL, 'ssba_excerpts' => isset($ssbaPost['ssba_excerpts']) ? $ssbaPost['ssba_excerpts'] : NULL, 'ssba_align' => isset($ssbaPost['ssba_align']) ? $ssbaPost['ssba_align'] : NULL, 'ssba_padding' => $ssbaPost['ssba_padding'], 'ssba_before_or_after' => $ssbaPost['ssba_before_or_after'], 'ssba_additional_css' => $ssbaPost['ssba_additional_css'], 'ssba_custom_styles' => $ssbaPost['ssba_custom_styles'], 'ssba_custom_styles_enabled' => $ssbaPost['ssba_custom_styles_enabled'], 'ssba_email_message' => stripslashes_deep($ssbaPost['ssba_email_message']), 'ssba_twitter_text' => stripslashes_deep($ssbaPost['ssba_twitter_text']), 'ssba_buffer_text' => stripslashes_deep($ssbaPost['ssba_buffer_text']), 'ssba_flattr_user_id' => stripslashes_deep($ssbaPost['ssba_flattr_user_id']), 'ssba_flattr_url' => stripslashes_deep($ssbaPost['ssba_flattr_url']), 'ssba_share_new_window' => isset($ssbaPost['ssba_share_new_window']) ? $ssbaPost['ssba_share_new_window'] : NULL, 'ssba_link_to_ssb' => isset($ssbaPost['ssba_link_to_ssb']) ? $ssbaPost['ssba_link_to_ssb'] : NULL, 'ssba_show_share_count' => isset($ssbaPost['ssba_show_share_count']) ? $ssbaPost['ssba_show_share_count'] : NULL, 'ssba_share_count_style' => $ssbaPost['ssba_share_count_style'], 'ssba_share_count_css' => $ssbaPost['ssba_share_count_css'], 'ssba_share_count_once' => isset($ssbaPost['ssba_share_count_once']) ? $ssbaPost['ssba_share_count_once'] : NULL, 'ssba_widget_text' => $ssbaPost['ssba_widget_text'], 'ssba_rel_nofollow' => isset($ssbaPost['ssba_rel_nofollow']) ? $ssbaPost['ssba_rel_nofollow'] : NULL, 'ssba_default_pinterest' => isset($ssbaPost['ssba_default_pinterest']) ? $ssbaPost['ssba_default_pinterest'] : NULL, 'ssba_pinterest_featured' => isset($ssbaPost['ssba_pinterest_featured']) ? $ssbaPost['ssba_pinterest_featured'] : NULL, 'ssba_content_priority' => isset($ssbaPost['ssba_content_priority']) ? $ssbaPost['ssba_content_priority'] : NULL, 'ssba_div_padding' => $ssbaPost['ssba_div_padding'], 'ssba_div_rounded_corners' => isset($ssbaPost['ssba_div_rounded_corners']) ? $ssbaPost['ssba_div_rounded_corners'] : NULL, 'ssba_border_width' => $ssbaPost['ssba_border_width'], 'ssba_div_border' => $ssbaPost['ssba_div_border'], 'ssba_div_background' => $ssbaPost['ssba_div_background'], 'ssba_share_text' => stripslashes_deep($ssbaPost['ssba_share_text']), 'ssba_text_placement' => $ssbaPost['ssba_text_placement'], 'ssba_font_family' => $ssbaPost['ssba_font_family'], 'ssba_font_color' => $ssbaPost['ssba_font_color'], 'ssba_font_size' => $ssbaPost['ssba_font_size'], 'ssba_font_weight' => $ssbaPost['ssba_font_weight'], 'ssba_selected_buttons' => $ssbaPost['ssba_selected_buttons']);
        // prepare array of buttons
        $arrButtons = json_decode(get_option('ssba_buttons'), true);
        // loop through each button
        foreach ($arrButtons as $button => $arrButton) {
            // add custom button to array of options
            $arrOptions['ssba_custom_' . $button] = $ssbaPost['ssba_custom_' . $button];
        }
        // save the settings
        ssba_update_options($arrOptions);
        // return success
        return true;
    }
    // include then run the upgrade script
    include_once plugin_dir_path(SSBA_FILE) . '/inc/ssba_admin_panel.php';
    // query the db for current ssba settings
    $arrSettings = get_ssba_settings();
    // --------- ADMIN PANEL ------------ //
    ssba_admin_panel($arrSettings);
}
function ssba_settings()
{
    //' check if user has the rights to manage options
    if (!current_user_can('manage_options')) {
        // permissions message
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    // variables
    $htmlSettingsSaved = '';
    // check for submitted form
    if (isset($_POST['ssba_options'])) {
        // if the nonce doesn't check out...
        if (!isset($_POST['ssba_save_nonce']) || !wp_verify_nonce($_POST['ssba_save_nonce'], 'ssba_save_settings')) {
            // don't save data
            print 'Sorry, your nonce did not verify.';
            exit;
        } else {
            // everything seems to check out
            // update existing ssba settings
            update_option('ssba_image_set', $_POST['ssba_image_set']);
            update_option('ssba_size', $_POST['ssba_size']);
            update_option('ssba_pages', isset($_POST['ssba_pages']) ? $_POST['ssba_pages'] : NULL);
            update_option('ssba_posts', isset($_POST['ssba_posts']) ? $_POST['ssba_posts'] : NULL);
            update_option('ssba_cats_archs', isset($_POST['ssba_cats_archs']) ? $_POST['ssba_cats_archs'] : NULL);
            update_option('ssba_homepage', isset($_POST['ssba_homepage']) ? $_POST['ssba_homepage'] : NULL);
            update_option('ssba_excerpts', isset($_POST['ssba_excerpts']) ? $_POST['ssba_excerpts'] : NULL);
            update_option('ssba_align', isset($_POST['ssba_align']) ? $_POST['ssba_align'] : NULL);
            update_option('ssba_padding', $_POST['ssba_padding']);
            update_option('ssba_before_or_after', $_POST['ssba_before_or_after']);
            update_option('ssba_custom_styles', $_POST['ssba_custom_styles']);
            update_option('ssba_email_message', stripslashes_deep($_POST['ssba_email_message']));
            update_option('ssba_twitter_text', stripslashes_deep($_POST['ssba_twitter_text']));
            update_option('ssba_buffer_text', stripslashes_deep($_POST['ssba_buffer_text']));
            update_option('ssba_flattr_user_id', stripslashes_deep($_POST['ssba_flattr_user_id']));
            update_option('ssba_flattr_url', stripslashes_deep($_POST['ssba_flattr_url']));
            update_option('ssba_share_new_window', isset($_POST['ssba_share_new_window']) ? $_POST['ssba_share_new_window'] : NULL);
            update_option('ssba_link_to_ssb', isset($_POST['ssba_link_to_ssb']) ? $_POST['ssba_link_to_ssb'] : NULL);
            update_option('ssba_show_share_count', isset($_POST['ssba_show_share_count']) ? $_POST['ssba_show_share_count'] : NULL);
            update_option('ssba_share_count_style', $_POST['ssba_share_count_style']);
            update_option('ssba_share_count_css', $_POST['ssba_share_count_css']);
            update_option('ssba_share_count_once', isset($_POST['ssba_share_count_once']) ? $_POST['ssba_share_count_once'] : NULL);
            update_option('ssba_widget_text', $_POST['ssba_widget_text']);
            update_option('ssba_rel_nofollow', isset($_POST['ssba_rel_nofollow']) ? $_POST['ssba_rel_nofollow'] : NULL);
            update_option('ssba_default_pinterest', isset($_POST['ssba_default_pinterest']) ? $_POST['ssba_default_pinterest'] : NULL);
            update_option('ssba_pinterest_featured', isset($_POST['ssba_pinterest_featured']) ? $_POST['ssba_pinterest_featured'] : NULL);
            // share container
            update_option('ssba_div_padding', $_POST['ssba_div_padding']);
            update_option('ssba_div_rounded_corners', isset($_POST['ssba_div_rounded_corners']) ? $_POST['ssba_div_rounded_corners'] : NULL);
            update_option('ssba_border_width', $_POST['ssba_border_width']);
            update_option('ssba_div_border', $_POST['ssba_div_border']);
            update_option('ssba_div_background', $_POST['ssba_div_background']);
            // text
            update_option('ssba_share_text', stripslashes_deep($_POST['ssba_share_text']));
            update_option('ssba_text_placement', $_POST['ssba_text_placement']);
            update_option('ssba_font_family', $_POST['ssba_font_family']);
            update_option('ssba_font_color', $_POST['ssba_font_color']);
            update_option('ssba_font_size', $_POST['ssba_font_size']);
            update_option('ssba_font_weight', $_POST['ssba_font_weight']);
            // include
            update_option('ssba_selected_buttons', $_POST['ssba_selected_buttons']);
            // custom images
            update_option('ssba_custom_email', $_POST['ssba_custom_email']);
            update_option('ssba_custom_google', $_POST['ssba_custom_google']);
            update_option('ssba_custom_facebook', $_POST['ssba_custom_facebook']);
            update_option('ssba_custom_twitter', $_POST['ssba_custom_twitter']);
            update_option('ssba_custom_diggit', $_POST['ssba_custom_diggit']);
            update_option('ssba_custom_linkedin', $_POST['ssba_custom_linkedin']);
            update_option('ssba_custom_reddit', $_POST['ssba_custom_reddit']);
            update_option('ssba_custom_stumbleupon', $_POST['ssba_custom_stumbleupon']);
            update_option('ssba_custom_pinterest', $_POST['ssba_custom_pinterest']);
            update_option('ssba_custom_buffer', $_POST['ssba_custom_buffer']);
            update_option('ssba_custom_flattr', $_POST['ssba_custom_flattr']);
            update_option('ssba_custom_tumblr', $_POST['ssba_custom_tumblr']);
            update_option('ssba_custom_print', $_POST['ssba_custom_print']);
            update_option('ssba_custom_vk', $_POST['ssba_custom_vk']);
            update_option('ssba_custom_yummly', $_POST['ssba_custom_yummly']);
            // show settings saved message
            $htmlSettingsSaved = '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>Your settings have been saved. <a href="' . site_url() . '">Visit your site</a> to see how your buttons look!</strong></p></div>';
        }
    }
    // include then run the upgrade script
    include_once plugin_dir_path(__FILE__) . '/inc/ssba_admin_panel.php';
    // query the db for current ssba settings
    $arrSettings = get_ssba_settings();
    // --------- ADMIN PANEL ------------ //
    ssba_admin_panel($arrSettings, $htmlSettingsSaved);
}