function swp_check_registration_status()
{
    // Fetch the User's Options Array
    $swp_user_options = swp_get_user_options();
    // Fetch URL of the home page
    $homeURL = get_home_url();
    // Create a Registration Code from the Domain Name
    $regCode = md5($homeURL);
    // IF the plugin thinks that it is already registered....
    if (is_swp_registered()) {
        // Construct the request URL
        $url = 'https://warfareplugins.com/registration-api/?activity=check_registration&emailAddress=' . $swp_user_options['emailAddress'] . '&domain=' . $homeURL . '&registrationCode=' . md5($homeURL);
        // Send the link and load the response
        $response = swp_file_get_contents_curl($url);
        // If the response is negative, unregister the plugin....
        if ($response == 'false') {
            // Set the premium code to null
            $swp_user_options['premiumCode'] = '';
            // Update the options array with the premium code nulled
            update_option('socialWarfareOptions', $swp_user_options);
        }
        // If the codes didn't match, but a premium code does exist
    } elseif (isset($swp_user_options['premiumCode'])) {
        // Attemp to unregister this from the Warfare Plugins Server
        $url = 'https://warfareplugins.com/registration-api/?activity=unregister&emailAddress=' . $swp_user_options['emailAddress'] . '&premiumCode=' . $swp_user_options['premiumCode'];
        // Parse the response
        $response = swp_file_get_contents_curl($url);
        $response = json_decode($response, true);
        // If it unregistered, let's try to auto-reregister it....
        if ($response['status'] == 'Success') {
            // Attempt to reregister it
            $url = 'https://warfareplugins.com/registration-api/?activity=register&emailAddress=' . $swp_user_options['emailAddress'] . '&domain=' . get_home_url() . '&registrationCode=' . $regCode;
            // Parse the response
            $response = swp_file_get_contents_curl($url);
            $response = json_decode($response, true);
            // IF the registration attempt was successful....
            if ($response['status'] == 'Success') {
                // Save our updated options
                $swp_user_options['premiumCode'] == $response['premiumCode'];
                // Update the options storing in our new updated Premium Code
                update_option('socialWarfareOptions', $swp_user_options);
                return true;
                // IF the registration attempt was NOT successful
            } else {
                // Set the premium code to null
                $swp_user_options['premiumCode'] = '';
                // Update the options array with the premium code nulled
                update_option('socialWarfareOptions', $swp_user_options);
                return false;
            }
            // IF it wasn't able to unregister
        } else {
            // Set the premium code to null
            $swp_user_options['premiumCode'] = '';
            // Update the options array with the premium code nulled
            update_option('socialWarfareOptions', $swp_user_options);
            return false;
        }
    }
}
function swp_format_twitter_response($response)
{
    // Fetch the user's options
    $swp_user_options = swp_get_user_options();
    // If the user has enabled Twitter shares....
    if ($swp_user_options['twitter_shares']) {
        // Debugging
        if (isset($_GET['swp_twitter_debug']) && $_GET['swp_twitter_debug'] == true) {
            echo '<b>Response:</b> ' . $response . '<br />';
        }
        // Parse the response to get the actual number
        $response = json_decode($response, true);
        return isset($response['count']) ? intval($response['count']) : 0;
        // If the user has not enabled Twitter shares....
    } else {
        // Return the number 0
        return 0;
    }
}
function clickToTweetShortcode($atts)
{
    $url = swp_process_url(get_permalink(), 'twitter', get_the_ID());
    strpos($atts['tweet'], 'http') !== false ? $urlParam = '&url=/' : ($urlParam = '&url=' . $url);
    $atts['tweet'] = rtrim($atts['tweet']);
    $options = swp_get_user_options();
    $user_twitter_handle = get_post_meta(get_the_ID(), 'swp_twitter_username', true);
    if (!$user_twitter_handle) {
        $user_twitter_handle = $options['twitterID'];
    }
    if (isset($atts['theme']) && $atts['theme'] != 'default') {
        $theme = $atts['theme'];
    } else {
        $theme = $options['cttTheme'];
    }
    return '
		<div class="sw-tweet-clear"></div>
		<a class="swp_CTT ' . $theme . '" href="https://twitter.com/share?text=' . urlencode(html_entity_decode($atts['tweet'], ENT_COMPAT, 'UTF-8')) . $urlParam . '' . ($user_twitter_handle ? '&via=' . str_replace('@', '', $user_twitter_handle) : '') . '" data-link="https://twitter.com/share?text=' . urlencode(html_entity_decode($atts['tweet'], ENT_COMPAT, 'UTF-8')) . $urlParam . '' . ($user_twitter_handle ? '&via=' . str_replace('@', '', $user_twitter_handle) : '') . '" target="_blank"><span class="sw-click-to-tweet"><span class="sw-ctt-text">' . $atts['quote'] . '</span><span class="sw-ctt-btn">' . __('Click To Tweet', 'social-warfare') . '<i class="sw sw-twitter"></i></span></span></a>';
}
function swp_kilomega($val)
{
    // Fetch the user assigned options
    $options = swp_get_user_options();
    // Check if we even have a value to format
    if ($val) {
        // Check if the value is less than 1,000....
        if ($val < 1000) {
            // If less than 1,000 just format and kick it back
            return number_format($val);
            // Check if the value is greater than 1,000 and less than 1,000,000....
        } elseif ($val < 1000000) {
            // Start by deviding the value by 1,000
            $val = intval($val) / 1000;
            // If the decimal separator is a period
            if ($options['swp_decimal_separator'] == 'period') {
                // Then format the number to the appropriate number of decimals
                return number_format($val, $options['swDecimals'], '.', ',') . 'K';
                // If the decimal separator is a comma
            } else {
                // Then format the number to the appropriate number of decimals
                return number_format($val, $options['swDecimals'], ',', '.') . 'K';
            }
            // Check if the value is greater than 1,000,000....
        } else {
            // Start by deviding the value by 1,000,000
            $val = intval($val) / 1000000;
            // If the decimal separator is a period
            if ($options['swp_decimal_separator'] == 'period') {
                // Then format the number to the appropriate number of decimals
                return number_format($val, $options['swDecimals'], '.', ',') . 'M';
                // If the decimal separator is a comma
            } else {
                // Then format the number to the appropriate number of decimals
                return number_format($val, $options['swDecimals'], ',', '.') . 'M';
            }
        }
        // If there is no value, return a zero
    } else {
        return 0;
    }
}
function swp_register_meta_boxes($meta_boxes)
{
    // Setup the prefix to avoid conflicts
    $prefix = 'nc_';
    $options = swp_get_user_options();
    $postTypes = swp_get_post_types();
    foreach ($postTypes as $key => $value) {
        $postType[] = $key;
    }
    $postType[] = 'page';
    $postType[] = 'post';
    /*****************************************************************
                                                                    
               FETCH THE TWITTER HANDLE FOR TWEET COUNTS         
                                                                    
    ******************************************************************/
    // Fetch the Twitter handle for the Post Author if it exists
    if (isset($_GET['post'])) {
        $post_id = $_GET['post'];
        $author_id = swp_get_author($post_id);
        $twitter_handle = get_the_author_meta('swp_twitter', $author_id);
        // Fetch the Twitter handle for the logged in user if the above fails
    } else {
        $logged_in_user = get_current_user_id();
        $twitter_handle = get_the_author_meta('swp_twitter', $logged_in_user);
    }
    // Fetch the site-wide Twitter Handle if both of the above fail
    if (!$twitter_handle) {
        $twitter_handle = $options['twitterID'];
    }
    /*****************************************************************
                                                                    
               BUILD THE OPTIONS FIELDS         
                                                                    
    ******************************************************************/
    // Setup our meta box using an array
    $meta_boxes[0] = array('id' => 'socialWarfare', 'title' => __('Social Warfare Custom Options', 'social-warfare'), 'pages' => $postType, 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('name' => '<span class="dashicons dashicons-share"></span> ' . __('Social Media Image', 'social-warfare'), 'desc' => __('Add an image that is optimized for maximum exposure on Facebook, Google+ and LinkedIn. We recommend 1,200px by 628px.', 'social-warfare'), 'id' => $prefix . 'ogImage', 'type' => 'image_advanced', 'clone' => false, 'class' => $prefix . 'ogImageWrapper', 'max_file_uploads' => 1), array('name' => '<span class="dashicons dashicons-share"></span> ' . __('Social Media Title', 'social-warfare'), 'desc' => __('Add a title that will populate the open graph meta tag which will be used when users share your content onto Facebook, LinkedIn, and Google+. If nothing is provided here, we will use the post title as a backup.', 'social-warfare'), 'id' => $prefix . 'ogTitle', 'type' => 'textarea', 'class' => $prefix . 'ogTitleWrapper', 'clone' => false), array('name' => '<span class="dashicons dashicons-share"></span> ' . __('Social Media Description', 'social-warfare'), 'desc' => __('Add a description that will populate the open graph meta tag which will be used when users share your content onto Facebook, LinkedIn, and Google Plus.', 'social-warfare'), 'id' => $prefix . 'ogDescription', 'class' => $prefix . 'ogDescriptionWrapper', 'type' => 'textarea', 'clone' => false), array('name' => 'divider', 'id' => 'divider', 'type' => 'divider'), array('name' => '<i class="sw sw-pinterest"></i> ' . __('Pinterest Image', 'social-warfare'), 'desc' => __('Add an image that is optimized for maximum exposure on Pinterest. We recommend using an image that is formatted in a 2:3 aspect ratio like 735x1102.', 'social-warfare'), 'id' => $prefix . 'pinterestImage', 'class' => $prefix . 'pinterestImageWrapper', 'type' => 'image_advanced', 'clone' => false, 'max_file_uploads' => 1), array('name' => '<i class="sw sw-pinterest"></i>' . __('Pinterest Description', 'social-warfare'), 'desc' => __('Craft a customized description that will be used when this post is shared on Pinterest. Leave this blank to use the title of the post.', 'social-warfare'), 'id' => $prefix . 'pinterestDescription', 'class' => $prefix . 'pinterestDescriptionWrapper', 'type' => 'textarea', 'clone' => false), array('name' => '<i class="sw sw-twitter"></i> ' . __('Custom Tweet', 'social-warfare'), 'desc' => $options['twitterID'] ? sprintf(__('If this is left blank your post title will be used. Based on your username (@%1$s), <span class="tweetLinkSection">a link being added,</span> and the current content above, your tweet has %2$s characters remaining.', 'social-warfare'), str_replace('@', '', $twitter_handle), '<span class="counterNumber">140</span>') : sprintf(__('If this is left blank your post title will be used. <span ="tweetLinkSection">Based on a link being added, and</span> the current content above, your tweet has %s characters remaining.', 'social-warfare'), '<span class="counterNumber">140</span>'), 'id' => $prefix . 'customTweet', 'class' => $prefix . 'customTweetWrapper', 'type' => 'textarea', 'clone' => false), array('name' => '<span class="dashicons dashicons-randomize"></span> ' . __('Horizontal Buttons Location', 'social-warfare'), 'id' => $prefix . 'postLocation', 'class' => $prefix . 'postLocationWrapper', 'type' => 'select', 'options' => array('default' => __('Default', 'social-warfare'), 'above' => __('Above the Content', 'social-warfare'), 'below' => __('Below the Content', 'social-warfare'), 'both' => __('Both Above and Below the Content', 'social-warfare'), 'none' => __('None/Manual Placement', 'social-warfare')), 'clone' => false, 'std' => 'default'), array('name' => '<span class="dashicons dashicons-randomize"></span> ' . __('Side Floating Buttons Location', 'social-warfare'), 'id' => $prefix . 'floatLocation', 'class' => $prefix . 'floatLocationWrapper', 'type' => 'select', 'options' => array('default' => __('Default', 'social-warfare'), 'on' => __('On', 'social-warfare'), 'off' => __('Off', 'social-warfare')), 'clone' => false, 'std' => 'default'), array('name' => 'divider2', 'id' => 'divider2', 'type' => 'divider'), array('name' => $twitter_handle, 'id' => 'twitterID', 'class' => 'twitterIDWrapper', 'type' => 'hidden', 'std' => $twitter_handle), array('name' => is_swp_registered() ? 'true' : 'false', 'id' => is_swp_registered() ? 'true' : 'false', 'class' => 'registrationWrapper', 'type' => 'hidden', 'std' => is_swp_registered() ? 'true' : 'false')));
    // Return the meta boxes
    return $meta_boxes;
}
Example #6
0
function swp_bitly_oauth_callback()
{
    // Fetch the User's Options Array
    $swp_user_options = swp_get_user_options();
    // Set the premium code to null
    $swp_user_options['bitly_access_token'] = $_GET['access_token'];
    // Update the options array with the premium code nulled
    update_option('socialWarfareOptions', $swp_user_options);
    echo admin_url('admin.php?page=social-warfare');
}
function socialWarfareSideFloat()
{
    // Get the options...or create them if they don't exist
    wp_reset_query();
    $postID = get_the_ID();
    $options = swp_get_user_options();
    $postType = get_post_type($postID);
    if (is_singular()) {
        $postType = get_post_type($postID);
        if (isset($options['float_location_' . $postType])) {
            $visibility = $options['float_location_' . $postType];
        } else {
            $visibility = 'on';
        }
    } else {
        $visibility = 'on';
    }
    if (is_singular() && get_post_status($postID) == 'publish' && get_post_meta($postID, 'nc_floatLocation', true) != 'off' && $visibility == 'on' && !is_home()) {
        // Acquire the social stats from the networks
        // Acquire the social stats from the networks
        if (isset($array['url'])) {
            $buttonsArray['url'] = $array['url'];
        } else {
            $buttonsArray['url'] = get_permalink($postID);
        }
        if ($options['float'] && is_singular()) {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        if ($options['floatStyleSource'] == true) {
            $options['sideDColorSet'] = $options['dColorSet'];
            $options['sideIColorSet'] = $options['iColorSet'];
            $options['sideOColorSet'] = $options['oColorSet'];
        }
        // Setup the buttons array to pass into the 'swp_network_buttons' hook
        $buttonsArray['shares'] = get_social_warfare_shares($postID);
        $buttonsArray['count'] = 0;
        $buttonsArray['totes'] = 0;
        $buttonsArray['options'] = $options;
        if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes']) {
            ++$buttonsArray['count'];
        }
        $buttonsArray['resource'] = array();
        $buttonsArray['postID'] = $postID;
        $buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
        // Create the social panel
        $assets = '<div class="nc_socialPanelSide nc_socialPanel swp_' . $options['floatStyle'] . ' swp_d_' . $options['sideDColorSet'] . ' swp_i_' . $options['sideIColorSet'] . ' swp_o_' . $options['sideOColorSet'] . ' ' . $options['sideReveal'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-screen-width="' . $options['swp_float_scr_sz'] . '" data-transition="' . $options['sideReveal'] . '">';
        // Display Total Shares if the Threshold has been met
        if ($options['totes'] && $buttonsArray['totes'] >= $options['minTotes']) {
            $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="6" >';
            $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . '</span><span class="swp_label"> ' . __('Shares', 'social-warfare') . '</span>';
            $assets .= '</div>';
        }
        $i = 0;
        // Sort the buttons according to the user's preferences
        if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
            foreach ($buttonsArray['buttons'] as $key => $value) {
                if (isset($buttonsArray['resource'][$key]) && $i < 5) {
                    $assets .= $buttonsArray['resource'][$key];
                }
                ++$i;
            }
        } elseif ($options['orderOfIconsSelect'] == 'manual') {
            foreach ($options['newOrderOfIcons'] as $key => $value) {
                if (isset($buttonsArray['resource'][$key]) && $i < 5) {
                    $assets .= $buttonsArray['resource'][$key];
                }
                ++$i;
            }
        } elseif ($options['orderOfIconsSelect'] == 'dynamic') {
            arsort($buttonsArray['shares']);
            foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                if (isset($buttonsArray['resource'][$thisIcon]) && $i < 5) {
                    $assets .= $buttonsArray['resource'][$thisIcon];
                }
                ++$i;
            }
        }
        // Close the Social Panel
        $assets .= '</div>';
        echo $assets;
    }
}
//);
// Add settings link on plugin page
function swp_settings_link($links)
{
    $settings_link = '<a href="admin.php?page=social-warfare">Settings</a>';
    array_unshift($links, $settings_link);
    return $links;
}
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_{$plugin}", 'swp_settings_link');
/*****************************************************************
*                                                                *
*   ENQUEUE: SCRIPTS AND STYLES									 *
*                                                                *
******************************************************************/
$swp_user_options = swp_get_user_options();
add_action('wp_enqueue_scripts', 'enqueueSocialWarfareScripts');
function enqueueSocialWarfareScripts()
{
    global $swp_user_options;
    wp_enqueue_script('social_warfare_script', swp_PLUGIN_DIR . '/script.min.js', array('jquery'), swp_VERSION);
    wp_register_style('social_warfare', swp_PLUGIN_DIR . '/css/style.css', array(), swp_VERSION);
    wp_enqueue_style('social_warfare');
}
// Enqueue admin and Click to Tweet Styles
add_action('admin_enqueue_scripts', 'enqueueSocialWarfareAdminScripts');
function enqueueSocialWarfareAdminScripts()
{
    wp_register_style('social_warfare', swp_PLUGIN_DIR . '/css/style.css', array(), swp_VERSION);
    wp_enqueue_style('social_warfare');
    wp_register_style('social_warfare_admin', swp_PLUGIN_DIR . '/css/admin.css', array(), swp_VERSION);
function social_warfare_buttons($array = array())
{
    // Setup the default Array parameters
    if (!isset($array['where'])) {
        $array['where'] = 'default';
    }
    if (!isset($array['echo'])) {
        $array['echo'] = true;
    }
    if (!isset($array['content'])) {
        $array['content'] = false;
    }
    // Get the options...or create them if they don't exist
    if (isset($array['post_id'])) {
        $postID = $array['post_id'];
    } else {
        $postID = get_the_ID();
    }
    $options = swp_get_user_options();
    // Check to see if display location was specifically defined for this post
    $specWhere = get_post_meta($postID, 'nc_postLocation', true);
    if (!$specWhere) {
        $specWhere = 'default';
    }
    if ($array['where'] == 'default') {
        // If we are on a single page or post
        if (is_singular() && !is_home() && !is_archive()) {
            // Make sure this is the main loop
            //if( get_permalink( $postID ) == swp_get_current_url() ) :
            // Check if a specific display value has not been set for this specific post
            if ($specWhere == 'default' || $specWhere == '') {
                $postType = get_post_type($postID);
                if (isset($options['location_' . $postType])) {
                    $array['where'] = $options['location_' . $postType];
                } else {
                    $array['where'] = 'none';
                }
            } else {
                $array['where'] = $specWhere;
            }
            // If it's not the main loop
            //else:
            //	$array['where'] = 'none';
            //endif;
            // If we are on an archive or home page
        } else {
            $array['where'] = $options['locationSite'];
        }
    }
    // Disable the buttons on Buddy Press pages
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $array['content'];
        // Disable the buttons if the location is set to "None / Manual"
    } elseif ($array['where'] == 'none' && !isset($array['devs'])) {
        return $array['content'];
        // Disable the button if we're not in the loop, unless there is no content which means the function was called by a developer.
    } elseif ((!is_main_query() || !in_the_loop()) && !isset($array['devs'])) {
        return $array['content'];
        // Don't do anything if we're in the admin section
    } elseif (is_admin()) {
        return $array['content'];
        // If all the checks pass, let's make us some buttons!
    } else {
        // Set the options for the horizontal floating bar
        $postType = get_post_type($postID);
        $spec_float_where = get_post_meta($postID, 'nc_floatLocation', true);
        if (isset($array['float']) && $array['float'] == 'ignore') {
            $floatOption = 'float_ignore';
        } elseif ($spec_float_where == 'off' && $options['buttonFloat'] != 'float_ignore') {
            $floatOption = 'floatNone';
        } elseif ($options['float'] && is_singular() && $options['float_location_' . $postType] == 'on') {
            $floatOption = 'float' . ucfirst($options['floatOption']);
        } else {
            $floatOption = 'floatNone';
        }
        // Disable the plugin on feeds, search results, and non-published content
        if (!is_feed() && !is_search() && get_post_status($postID) == 'publish') {
            // Acquire the social stats from the networks
            if (isset($array['url'])) {
                $buttonsArray['url'] = $array['url'];
            } else {
                $buttonsArray['url'] = get_permalink($postID);
            }
            // Fetch the share counts
            $buttonsArray['shares'] = get_social_warfare_shares($postID);
            // Pass the swp_options into the array so we can pass it into the filter
            $buttonsArray['options'] = $options;
            // Customize which buttosn we're going to display
            if (isset($array['buttons'])) {
                // Fetch the global names and keys
                $swp_options = array();
                $swp_available_options = apply_filters('swp_options', $swp_options);
                $available_buttons = $swp_available_options['options']['swp_display']['buttons']['content'];
                // Split the comma separated list into an array
                $button_set_array = explode(',', $array['buttons']);
                // Match the names in the list to their appropriate system-wide keys
                foreach ($button_set_array as $button) {
                    // Trim the network name in case of white space
                    $button = trim($button);
                    // Convert the names to their systme-wide keys
                    if (recursive_array_search($button, $available_buttons)) {
                        $key = recursive_array_search($button, $available_buttons);
                        // Store the result in the array that gets passed to the HTML generator
                        $buttonsArray['buttons'][$key] = $button;
                        // Declare a default share count of zero. This will be overriden later
                        if (!isset($buttonsArray['shares'][$key])) {
                            $buttonsArray['shares'][$key] = 0;
                        }
                    }
                }
                // Manually turn the total shares on or off
                if (array_search('Total', $button_set_array)) {
                    $buttonsArray['buttons']['totes'] = 'Total';
                }
            }
            // Setup the buttons array to pass into the 'swp_network_buttons' hook
            $buttonsArray['count'] = 0;
            $buttonsArray['totes'] = 0;
            if ($buttonsArray['options']['totes'] && $buttonsArray['shares']['totes'] >= $buttonsArray['options']['minTotes'] && !isset($array['buttons']) || isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
            }
            $buttonsArray['resource'] = array();
            $buttonsArray['postID'] = $postID;
            // Disable the subtitles plugin to avoid letting them inject their subtitle into our share titles
            if (is_plugin_active('subtitles/subtitles.php') && class_exists('Subtitles')) {
                remove_filter('the_title', array(Subtitles::getinstance(), 'the_subtitle'), 10, 2);
            }
            // This array will contain the HTML for all of the individual buttons
            $buttonsArray = apply_filters('swp_network_buttons', $buttonsArray);
            // Create the social panel
            $assets = '<div class="nc_socialPanel swp_' . $options['visualTheme'] . ' swp_d_' . $options['dColorSet'] . ' swp_i_' . $options['iColorSet'] . ' swp_o_' . $options['oColorSet'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-scale="' . $options['buttonSize'] . '" data-align="' . $options['buttonFloat'] . '">';
            // Setup the total shares count if it's on the left
            if ($options['totes'] && $options['swTotesFormat'] == 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($array['buttons']) || $options['swTotesFormat'] == 'totesAltLeft' && isset($array['buttons']) && isset($array['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                $assets .= '</div>';
            }
            // Sort the buttons according to the user's preferences
            if (isset($buttonsArray) && isset($buttonsArray['buttons'])) {
                foreach ($buttonsArray['buttons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'manual') {
                foreach ($options['newOrderOfIcons'] as $key => $value) {
                    if (isset($buttonsArray['resource'][$key])) {
                        $assets .= $buttonsArray['resource'][$key];
                    }
                }
            } elseif ($options['orderOfIconsSelect'] == 'dynamic') {
                arsort($buttonsArray['shares']);
                foreach ($buttonsArray['shares'] as $thisIcon => $status) {
                    if (isset($buttonsArray['resource'][$thisIcon])) {
                        $assets .= $buttonsArray['resource'][$thisIcon];
                    }
                }
            }
            // Create the Total Shares Box if it's on the right
            if ($options['totes'] && $options['swTotesFormat'] != 'totesAltLeft' && $buttonsArray['totes'] >= $options['minTotes'] && !isset($buttonsArray['buttons']) || $options['swTotesFormat'] != 'totesAltLeft' && isset($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes']) {
                ++$buttonsArray['count'];
                if ($options['swTotesFormat'] == 'totes') {
                    $assets .= '<div class="nc_tweetContainer totes" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count">' . swp_kilomega($buttonsArray['totes']) . ' <span class="swp_label">' . __('Shares', 'social-warfare') . '</span></span>';
                    $assets .= '</div>';
                } else {
                    $assets .= '<div class="nc_tweetContainer totes totesalt" data-id="' . $buttonsArray['count'] . '" >';
                    $assets .= '<span class="swp_count"><span class="swp_label">' . __('Shares', 'social-warfare') . '</span> ' . swp_kilomega($buttonsArray['totes']) . '</span>';
                    $assets .= '</div>';
                }
            }
            // Close the Social Panel
            $assets .= '</div>';
            // Reset the cache timestamp if needed
            if (swp_is_cache_fresh($postID) == false) {
                delete_post_meta($postID, 'swp_cache_timestamp');
                update_post_meta($postID, 'swp_cache_timestamp', floor(date('U') / 60 / 60));
            }
            if (isset($array['genesis'])) {
                if ($array['where'] == 'below' && $array['genesis'] == 'below') {
                    return $assets;
                } elseif ($array['where'] == 'above' && $array['genesis'] == 'above') {
                    return $assets;
                } elseif ($array['where'] == 'both') {
                    return $assets;
                } elseif ($array['where'] == 'none') {
                    return false;
                }
            } else {
                if ($array['echo'] == false && $array['where'] != 'none') {
                    return $assets;
                } elseif ($array['content'] === false) {
                    echo $assets;
                } elseif ($array['where'] == 'below') {
                    $content = $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'above') {
                    $content = $assets . '' . $array['content'];
                    return $content;
                } elseif ($array['where'] == 'both') {
                    $content = $assets . '' . $array['content'] . '' . $assets;
                    return $content;
                } elseif ($array['where'] == 'none') {
                    return $array['content'];
                }
            }
        } else {
            return $array['content'];
        }
    }
}
function swp_click_tracking($info)
{
    $swp_options = swp_get_user_options();
    if ($swp_options['swp_click_tracking'] == 1) {
        $info['footer_output'] .= 'if (typeof ga == "function") { jQuery(document).on("click",".nc_tweet",function(event) {var network = jQuery(this).parents(".nc_tweetContainer").attr("data-network");ga("send", "event", "social_media", "swp_" + network + "_share" );});}';
    }
    return $info;
}
function swp_get_alt_permalink($post = 0, $leavename = false)
{
    // Fetch the Social Warfare user's options
    $swp_user_options = swp_get_user_options();
    $rewritecode = array('%year%', '%monthnum%', '%day%', '%hour%', '%minute%', '%second%', $leavename ? '' : '%postname%', '%post_id%', '%category%', '%author%', $leavename ? '' : '%pagename%');
    if (is_object($post) && isset($post->filter) && 'sample' == $post->filter) {
        $sample = true;
    } else {
        $post = get_post($post);
        $sample = false;
    }
    if (empty($post->ID)) {
        return false;
    }
    if ($post->post_type == 'page') {
        return get_page_link($post, $leavename, $sample);
    } elseif ($post->post_type == 'attachment') {
        return get_attachment_link($post, $leavename);
    } elseif (in_array($post->post_type, get_post_types(array('_builtin' => false)))) {
        return get_post_permalink($post, $leavename, $sample);
    }
    // Build the structure
    $structure = $swp_user_options['recovery_format'];
    if ($structure == 'custom') {
        $permalink = $swp_user_options['recovery_custom_format'];
    } elseif ($structure == 'unchanged') {
        $permalink = get_option('permalink_structure');
    } elseif ($structure == 'default') {
        $permalink = '';
    } elseif ($structure == 'day_and_name') {
        $permalink = '/%year%/%monthnum%/%day%/%postname%/';
    } elseif ($structure == 'month_and_name') {
        $permalink = '/%year%/%monthnum%/%postname%/';
    } elseif ($structure == 'numeric') {
        $permalink = '/archives/%post_id%';
    } elseif ($structure == 'post_name') {
        $permalink = '/%postname%/';
    } else {
        $permalink = get_option('permalink_structure');
    }
    /**
     * Filter the permalink structure for a post before token replacement occurs.
     *
     * Only applies to posts with post_type of 'post'.
     *
     * @since 3.0.0
     *
     * @param string  $permalink The site's permalink structure.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     */
    $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename);
    if ('' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future'))) {
        $unixtime = strtotime($post->post_date);
        $category = '';
        if (strpos($permalink, '%category%') !== false) {
            $cats = get_the_category($post->ID);
            if ($cats) {
                usort($cats, '_usort_terms_by_ID');
                // order by ID
                /**
                 * Filter the category that gets used in the %category% permalink token.
                 *
                 * @since 3.5.0
                 *
                 * @param stdClass $cat  The category to use in the permalink.
                 * @param array    $cats Array of all categories associated with the post.
                 * @param WP_Post  $post The post in question.
                 */
                $category_object = apply_filters('post_link_category', $cats[0], $cats, $post);
                $category_object = get_term($category_object, 'category');
                $category = $category_object->slug;
                if ($parent = $category_object->parent) {
                    $category = get_category_parents($parent, false, '/', true) . $category;
                }
            }
            // show default category in permalinks, without
            // having to assign it explicitly
            if (empty($category)) {
                $default_category = get_term(get_option('default_category'), 'category');
                $category = is_wp_error($default_category) ? '' : $default_category->slug;
            }
        }
        $author = '';
        if (strpos($permalink, '%author%') !== false) {
            $authordata = get_userdata($post->post_author);
            $author = $authordata->user_nicename;
        }
        $date = explode(" ", date('Y m d H i s', $unixtime));
        $rewritereplace = array($date[0], $date[1], $date[2], $date[3], $date[4], $date[5], $post->post_name, $post->ID, $category, $author, $post->post_name);
        $permalink = home_url(str_replace($rewritecode, $rewritereplace, $permalink));
        if ($structure != 'custom') {
            $permalink = user_trailingslashit($permalink, 'single');
        }
    } else {
        // if they're not using the fancy permalink option
        $permalink = home_url('?p=' . $post->ID);
    }
    /**
     * Filter the permalink for a post.
     *
     * Only applies to posts with post_type of 'post'.
     *
     * @since 1.5.0
     *
     * @param string  $permalink The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     */
    $url = apply_filters('post_link', $permalink, $post, $leavename);
    // Filter the Protocol
    if ($swp_user_options['recovery_protocol'] == 'https' && strpos($url, 'https') === false) {
        $url = str_replace('http', 'https', $url);
    } elseif ($swp_user_options['recovery_protocol'] == 'http' && strpos($url, 'https') !== false) {
        $url = str_replace('https', 'http', $url);
    }
    // Filter the prefix
    if ($swp_user_options['recovery_prefix'] == 'unchanged') {
    } elseif ($swp_user_options['recovery_prefix'] == 'www' && strpos($url, 'www') === false) {
        $url = str_replace('http://', 'http://www.', $url);
        $url = str_replace('https://', 'https://www.', $url);
    } elseif ($swp_user_options['recovery_prefix'] == 'nonwww' && strpos($url, 'www') !== false) {
        $url = str_replace('http://www.', 'http://', $url);
        $url = str_replace('https://www.', 'https://', $url);
    }
    // Filter out the subdomain
    if (isset($swp_user_options['recovery_subdomain']) && $swp_user_options['recovery_subdomain'] != '') {
        $url = str_replace($swp_user_options['recovery_subdomain'] . '.', '', $url);
    }
    return $url;
}
Example #12
0
<?php

/**
 * Functions for getting and setting the plugin's options.
 *
 * @package   SocialWarfare\Functions
 * @copyright Copyright (c) 2016, Warfare Plugins, LLC
 * @license   GPL-3.0+
 * @since     1.0.0
 */
global $swp_user_options;
/**
 * $swp_user_options Fetch the available options that the user has set
 * @var array An array of available options from the options page
 */
$swp_user_options = swp_get_user_options(is_admin());
/**
 * A function to adjust the options and ensure that defaults are set
 *
 * @param  boolean $admin A boolean value to determine if it's being called in the admin or elsewhere
 * @return array $options The modified options array
 */
function swp_get_user_options($admin = false)
{
    $options = get_option('socialWarfareOptions', array());
    $defaults = array('locationSite' => 'both', 'totes' => true, 'totesEach' => true, 'twitterID' => false, 'swp_twitter_card' => true, 'visualTheme' => 'flatFresh', 'dColorSet' => 'fullColor', 'iColorSet' => 'fullColor', 'oColorSet' => 'fullColor', 'sideDColorSet' => 'fullColor', 'sideIColorSet' => 'fullColor', 'sideOColorSet' => 'fullColor', 'floatStyleSource' => true, 'buttonSize' => 1, 'buttonFloat' => 'fullWidth', 'sideReveal' => 'slide', 'swp_float_scr_sz' => 1100, 'cttTheme' => 'style1', 'twitter_shares' => false, 'float' => true, 'floatOption' => 'bottom', 'floatBgColor' => '#ffffff', 'floatStyle' => 'default', 'customColor' => '#000000', 'recover_shares' => false, 'recovery_format' => 'unchanged', 'recovery_protocol' => 'unchanged', 'recovery_prefix' => 'unchanged', 'swDecimals' => 0, 'swp_decimal_separator' => 'period', 'swTotesFormat' => 'totesalt', 'googleAnalytics' => false, 'dashboardShares' => true, 'linkShortening' => false, 'minTotes' => 0, 'cacheMethod' => 'advanced', 'rawNumbers' => false, 'notShowing' => false, 'visualEditorBug' => false, 'loopFix' => false, 'sniplyBuster' => false, 'analyticsMedium' => 'social', 'analyticsCampaign' => 'SocialWarfare', 'swp_click_tracking' => false, 'orderOfIconsSelect' => 'manual', 'pinit_toggle' => false, 'pinit_location_horizontal' => 'center', 'pinit_location_vertical' => 'top', 'pinit_min_width' => '200', 'pinit_min_height' => '200', 'emphasize_icons' => 0, 'sideCustomColor' => '#ffffff', 'floatLeftMobile' => 'bottom', 'newOrderOfIcons' => array('active' => array('twitter' => 'Twitter', 'linkedIn' => 'LinkedIn', 'pinterest' => 'Pinterest', 'facebook' => 'Facebook', 'googlePlus' => 'Google Plus')));
    $options = array_merge($defaults, $options);
    // Force the plugin off on certain post types.
    $options['locationattachment'] = 'none';
    $options['locationrevision'] = 'none';
    $options['nav_menu_item'] = 'none';
function get_social_warfare_shares($postID)
{
    // Set the initial options
    $options = swp_get_user_options();
    $url = get_permalink($postID);
    // $url				= 'https://youtu.be/jjK1aUU2Dx4';
    /*****************************************************************
    *                                                                *
    *        Check the Cache		                    			 *
    *                                                                *
    ******************************************************************/
    $freshCache = swp_is_cache_fresh($postID);
    // $freshCache = false;
    /*****************************************************************
    *                                                                *
    *       Setup the Networks Array that we'll loop through		 *
    *                                                                *
    ******************************************************************/
    // Initiate the ShareCount class
    $shares['totes'] = 0;
    // Queue up the networks that are available
    $availableNetworks = $options['newOrderOfIcons'];
    $networks = array();
    foreach ($availableNetworks as $key => $value) {
        if ($options['newOrderOfIcons'][$key]) {
            $networks[] = $key;
        }
    }
    /*****************************************************************
    *                                                                *
    *       Loop through the Networks                    			 *
    *                                                                *
    ******************************************************************/
    // Loop through the networks and fetch their share counts
    foreach ($networks as $network) {
        // Check if we can used the cached share numbers
        if ($freshCache == true) {
            $shares[$network] = get_post_meta($postID, '_' . $network . '_shares', true);
            // If cache is expired, fetch new and update the cache
        } else {
            $old_shares[$network] = get_post_meta($postID, '_' . $network . '_shares', true);
            $share_links[$network] = call_user_func('swp_' . $network . '_request_link', $url);
        }
    }
    // Recover Shares From Previously Used URL Patterns
    if ($options['recover_shares'] == true && $freshCache == false) {
        $alternateURL = swp_get_alt_permalink($postID);
        $alternateURL = apply_filters('swp_recovery_filter', $alternateURL);
        // Debug the Alternate URL being checked
        if (isset($_GET['swp_recovery_debug']) && $_GET['swp_recovery_debug'] == true) {
            echo $alternateURL;
        }
        foreach ($networks as $network) {
            $old_share_links[$network] = call_user_func('swp_' . $network . '_request_link', $alternateURL);
        }
    }
    if ($freshCache == true) {
        if (get_post_meta($postID, '_totes', true)) {
            $shares['totes'] = get_post_meta($postID, '_totes', true);
        } else {
            $shares['totes'] = 0;
        }
    } else {
        // Fetch all the share counts asyncrounously
        $raw_shares_array = swp_fetch_shares_via_curl_multi($share_links);
        if ($options['recover_shares'] == true) {
            $old_raw_shares_array = swp_fetch_shares_via_curl_multi($old_share_links);
        }
        foreach ($networks as $network) {
            if (!isset($raw_shares_array[$network])) {
                $raw_shares_array[$network] = 0;
            }
            if (!isset($old_raw_shares_array[$network])) {
                $old_raw_shares_array[$network] = 0;
            }
            $shares[$network] = call_user_func('swp_format_' . $network . '_response', $raw_shares_array[$network]);
            if ($options['recover_shares'] == true) {
                $recovered_shares[$network] = call_user_func('swp_format_' . $network . '_response', $old_raw_shares_array[$network]);
                if ($shares[$network] != $recovered_shares[$network]) {
                    $shares[$network] = $shares[$network] + $recovered_shares[$network];
                }
            }
            if ($shares[$network] <= $old_shares[$network]) {
                $shares[$network] = $old_shares[$network];
            } else {
                delete_post_meta($postID, '_' . $network . '_shares');
                update_post_meta($postID, '_' . $network . '_shares', $shares[$network]);
            }
            $shares['totes'] += $shares[$network];
        }
    }
    /*****************************************************************
    *                                                                *
    *       Update the Cache and Return the Share Counts   			 *
    *                                                                *
    ******************************************************************/
    if ($freshCache != true) {
        // Clean out the previously used custom meta fields
        delete_post_meta($postID, '_totes');
        // Add the new data to the custom meta fields
        update_post_meta($postID, '_totes', $shares['totes']);
    }
    // Return the share counts
    return $shares;
}
function swp_get_single_option($key)
{
    $option = swp_get_user_options();
    return $option[$key];
}
Example #15
0
function swp_bitly_oauth_callback()
{
    $options = swp_get_user_options();
    // Set the premium code to null
    $options['bitly_access_token'] = $_GET['access_token'];
    // Update the options array with the premium code nulled
    swp_update_options($options);
    echo admin_url('admin.php?page=social-warfare');
}
 function form($instance)
 {
     // Default Title
     if (isset($instance['title'])) {
         $title = esc_attr($instance['title']);
     } else {
         $title = 'Popular Posts';
     }
     // Default Count
     if (isset($instance['count'])) {
         $count = esc_attr($instance['count']);
     } else {
         $count = '10';
     }
     // Default Timeframe
     if (isset($instance['timeframe'])) {
         $timeframe = esc_attr($instance['timeframe']);
     } else {
         $timeframe = '0';
     }
     // Default Title
     if (isset($instance['network'])) {
         $network = esc_attr($instance['network']);
     } else {
         $network = 'totes';
     }
     // Default showCount
     if (isset($instance['showCount'])) {
         $showCount = esc_attr($instance['showCount']);
     } else {
         $showCount = 'true';
     }
     // Default countLabel
     if (isset($instance['countLabel'])) {
         $countLabel = esc_attr($instance['countLabel']);
     } else {
         $countLabel = 'Total Shares';
     }
     // Default Style
     if (isset($instance['style'])) {
         $style = esc_attr($instance['style']);
     } else {
         $style = 'style_01';
     }
     // Default Thumbnails toggle
     if (isset($instance['thumbnails'])) {
         $thumbnails = esc_attr($instance['thumbnails']);
     } else {
         $thumbnails = 'true';
     }
     // Default Thumbnail size
     if (isset($instance['thumb_size'])) {
         $thumb_size = esc_attr($instance['thumb_size']);
     } else {
         $thumb_size = '100';
     }
     // Default Font Size
     if (isset($instance['font_size'])) {
         $font_size = esc_attr($instance['font_size']);
     } else {
         $font_size = '100';
     }
     // Default Custom Background
     if (isset($instance['custom_bg'])) {
         $custom_bg = esc_attr($instance['custom_bg']);
     } else {
         $custom_bg = '#ffffff';
     }
     // Default Custom Link
     if (isset($instance['custom_link'])) {
         $custom_link = esc_attr($instance['custom_link']);
     } else {
         $custom_link = '#000000';
     }
     // Fetch the Social Warfare Options
     $options = swp_get_user_options();
     // Fetch the networks that are active on this blog
     $availableNetworks = $options['newOrderOfIcons'];
     // Build the Widget Form
     $form = '<div class="swp_popular_post_options">';
     // The Widget Title Field
     $form .= '<p class="title">';
     $form .= '<label for="' . $this->get_field_id('title') . '">Widget Title</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . $title . '" />';
     $form .= '</p>';
     // Number of Posts to Display Field
     $form .= '<p class="count">';
     $form .= '<label for="' . $this->get_field_id('count') . '">How many posts would you like to display?</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('count') . '" name="' . $this->get_field_name('count') . '" type="number" value="' . $count . '" min="0" />';
     $form .= '</p>';
     // Age of the pots to display field
     $form .= '<p class="timeframe">';
     $form .= '<label for="' . $this->get_field_id('timeframe') . '">What is maximum age of a post (in days) that you would like to include (0 = Unlimited)?</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('timeframe') . '" name="' . $this->get_field_name('timeframe') . '" value="' . $timeframe . '" type="number" min="0">';
     $form .= '</p>';
     // Which networks to use as the basis field
     $form .= '<p class="network">';
     $form .= '<label for="' . $this->get_field_id('network') . '">Which network would you like to base your posts popularity on?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('network') . '" name="' . $this->get_field_name('network') . '">';
     $form .= '<option value="totes"' . ($network == 'totes' ? 'selected' : '') . '>All Networks</option>';
     foreach ($availableNetworks as $key => $value) {
         if ($options[$key]) {
             if ($network == $key . '_shares') {
                 $form .= '<option value="' . $key . '_shares" selected>' . $value . '</option>';
             } else {
                 $form .= '<option value="' . $key . '_shares">' . $value . '</option>';
             }
         }
     }
     $form .= '</select>';
     $form .= '</p>';
     // Display the share count toggle field
     $form .= '<p class="showCount">';
     $form .= '<label for="' . $this->get_field_id('showCount') . '">Would you like to show the count?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('showCount') . '" name="' . $this->get_field_name('showCount') . '">';
     $form .= '<option value="true" ' . ($showCount == 'true' ? 'selected' : '') . '>Yes</option>';
     $form .= '<option value="false" ' . ($showCount == 'false' ? 'selected' : '') . '>No</option>';
     $form .= '</select>';
     $form .= '</p>';
     // Count Label Field
     $form .= '<p ' . ($showCount == 'false' ? 'style="display:none;"' : '') . ' class="countLabel">';
     $form .= '<label for="' . $this->get_field_id('countLabel') . '">Count Number Label</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('countLabel') . '" name="' . $this->get_field_name('countLabel') . '" type="text" value="' . $countLabel . '" />';
     $form .= '</p>';
     // Post thumbnails toggle field
     $form .= '<p class="thumbnails">';
     $form .= '<label for="' . $this->get_field_id('thumbnails') . '">Would you like to display thumbnails?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('thumbnails') . '" name="' . $this->get_field_name('thumbnails') . '">';
     $form .= '<option value="true" ' . ($thumbnails == 'true' ? 'selected' : '') . '>Yes</option>';
     $form .= '<option value="false" ' . ($thumbnails == 'false' ? 'selected' : '') . '>No</option>';
     $form .= '</select>';
     $form .= '</p>';
     // Thumbnails size field
     $form .= '<p ' . ($thumbnails == 'false' ? 'style="display:none;"' : '') . ' class="thumb_size">';
     $form .= '<label for="' . $this->get_field_id('thumb_size') . '">What size would you like your thumbnails?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('thumb_size') . '" name="' . $this->get_field_name('thumb_size') . '">';
     $form .= '<option value="50" ' . ($thumb_size == '50' ? 'selected' : '') . '>50px</option>';
     $form .= '<option value="60" ' . ($thumb_size == '60' ? 'selected' : '') . '>60px</option>';
     $form .= '<option value="70" ' . ($thumb_size == '70' ? 'selected' : '') . '>70px</option>';
     $form .= '<option value="80" ' . ($thumb_size == '80' ? 'selected' : '') . '>80px</option>';
     $form .= '<option value="90" ' . ($thumb_size == '90' ? 'selected' : '') . '>90px</option>';
     $form .= '<option value="100" ' . ($thumb_size == '100' ? 'selected' : '') . '>100px</option>';
     $form .= '<option value="110" ' . ($thumb_size == '110' ? 'selected' : '') . '>110px</option>';
     $form .= '<option value="120" ' . ($thumb_size == '120' ? 'selected' : '') . '>120px</option>';
     $form .= '<option value="130" ' . ($thumb_size == '130' ? 'selected' : '') . '>130px</option>';
     $form .= '<option value="140" ' . ($thumb_size == '140' ? 'selected' : '') . '>140px</option>';
     $form .= '<option value="150" ' . ($thumb_size == '150' ? 'selected' : '') . '>150px</option>';
     $form .= '</select>';
     $form .= '</p>';
     // Font size field
     $form .= '<p class="font_size">';
     $form .= '<label for="' . $this->get_field_id('font_size') . '">What size would you like the font?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('font_size') . '" name="' . $this->get_field_name('font_size') . '">';
     $form .= '<option value="50" ' . ($font_size == '50' ? 'selected' : '') . '>50%</option>';
     $form .= '<option value="60" ' . ($font_size == '60' ? 'selected' : '') . '>60%</option>';
     $form .= '<option value="70" ' . ($font_size == '70' ? 'selected' : '') . '>70%</option>';
     $form .= '<option value="80" ' . ($font_size == '80' ? 'selected' : '') . '>80%</option>';
     $form .= '<option value="90" ' . ($font_size == '90' ? 'selected' : '') . '>90%</option>';
     $form .= '<option value="100" ' . ($font_size == '100' ? 'selected' : '') . '>100%</option>';
     $form .= '<option value="110" ' . ($font_size == '110' ? 'selected' : '') . '>110%</option>';
     $form .= '<option value="120" ' . ($font_size == '120' ? 'selected' : '') . '>120%</option>';
     $form .= '<option value="130" ' . ($font_size == '130' ? 'selected' : '') . '>130%</option>';
     $form .= '<option value="140" ' . ($font_size == '140' ? 'selected' : '') . '>140%</option>';
     $form .= '<option value="150" ' . ($font_size == '150' ? 'selected' : '') . '>150%</option>';
     $form .= '</select>';
     $form .= '</p>';
     // Color Scheme Field
     $form .= '<p class="style">';
     $form .= '<label for="' . $this->get_field_id('style') . '">Which color scheme would you like to use?</label>';
     $form .= '<select class="widefat" id="' . $this->get_field_id('style') . '" name="' . $this->get_field_name('style') . '">';
     $form .= '<option value="style_01" ' . ($style == 'style_01' ? 'selected' : '') . '>Vanilla (No Styling)</option>';
     $form .= '<option value="style_02" ' . ($style == 'style_02' ? 'selected' : '') . '>Inspired by Twitter</option>';
     $form .= '<option value="style_03" ' . ($style == 'style_03' ? 'selected' : '') . '>Inspired by Facebook</option>';
     $form .= '<option value="style_04" ' . ($style == 'style_04' ? 'selected' : '') . '>Inspired by Google Plus</option>';
     $form .= '<option value="style_05" ' . ($style == 'style_05' ? 'selected' : '') . '>Inspired by LinkedIn</option>';
     $form .= '<option value="style_06" ' . ($style == 'style_06' ? 'selected' : '') . '>Inspired by Pinterest</option>';
     $form .= '<option value="style_07" ' . ($style == 'style_07' ? 'selected' : '') . '>Don\'t Stop Believin\'</option>';
     $form .= '<option value="style_08" ' . ($style == 'style_08' ? 'selected' : '') . '>Thunderstruck</option>';
     $form .= '<option value="style_09" ' . ($style == 'style_09' ? 'selected' : '') . '>Livin\' On A Prayer</option>';
     $form .= '<option value="custom" ' . ($style == 'custom' ? 'selected' : '') . '>Custom</option>';
     $form .= '</select>';
     $form .= '</p>';
     // Custom Background Color Field
     $form .= '<p ' . ($style != 'custom' ? 'style="display:none;"' : '') . ' class="custom_bg">';
     $form .= '<label for="' . $this->get_field_id('custom_bg') . '">Custom Background Color</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('custom_bg') . '" name="' . $this->get_field_name('custom_bg') . '" type="text" value="' . $custom_bg . '" />';
     $form .= '</p>';
     // Custom Link Color Field
     $form .= '<p ' . ($style != 'custom' ? 'style="display:none;"' : '') . ' class="custom_link">';
     $form .= '<label for="' . $this->get_field_id('custom_link') . '">Custom Link Color</label>';
     $form .= '<input class="widefat" id="' . $this->get_field_id('custom_link') . '" name="' . $this->get_field_name('custom_link') . '" type="text" value="' . $custom_link . '" />';
     $form .= '</p>';
     // Close the Div
     $form .= '</div>';
     // Output the form fields
     echo $form;
 }