/** * Unused admin notice. * * @return void */ function swp_admin_notice() { _deprecated_function('swp_admin_notice', '2.1.0'); if (!is_swp_registered()) { echo '<div class="notice is-dismissable swp_register_admin_notice"><p>Your copy of Social Warfare is not registered. Navigate to the <a href="/wp-admin/admin.php?page=social-warfare"><b>Social Warfare Settings Page</b></a> and select the "Register" tab to register now! You can view and manage your purchased licences on the <a target="_blank" href="https://warfareplugins.com/my-account/">My Account</a> page of the Warfare Plugins website. If you have any issues, please contact us and we\'ll be happy to help.</p></div>'; } }
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 . '®istrationCode=' . 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() . '®istrationCode=' . $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; } } }
/** * Build the options fields. * * @param array $meta_boxes The existing meta boxes. * @return array $meta_boxes The modified meta boxes. */ function swp_register_meta_boxes($meta_boxes) { global $swp_user_options; $prefix = 'nc_'; $options = $swp_user_options; $twitter_id = isset($options['twitterID']) ? $options['twitterID'] : false; $twitter_handle = _swp_get_twitter_handle($twitter_id); // Setup our meta box using an array. $meta_boxes[0] = array('id' => 'socialWarfare', 'title' => __('Social Warfare Custom Options', 'social-warfare'), 'pages' => swp_get_post_types(), 'context' => 'normal', 'priority' => apply_filters('swp_metabox_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' => $twitter_id ? 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> ' . __('Floating Buttons', '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 $meta_boxes; }
/** * Load admin scripts and styles. * * @since 1.0.0 * @access public * @param string $screen The ID of the current admin screen. * @return void */ function enqueueSocialWarfareAdminScripts($screen) { $screens = array('toplevel_page_social-warfare', 'post.php', 'post-new.php'); if (!in_array($screen, $screens, true)) { return; } enqueueSocialWarfareScripts(); $suffix = swp_get_suffix(); wp_enqueue_style('social_warfare_admin', SWP_PLUGIN_URL . "/css/admin{$suffix}.css", array(), SWP_VERSION); wp_enqueue_script('social_warfare_admin_script', SWP_PLUGIN_URL . "/js/admin{$suffix}.js", array('jquery'), SWP_VERSION); wp_localize_script('social_warfare_admin_script', 'swp_localize_admin', array('swp_characters_remaining' => __('Characters Remaining', 'social-warfare'))); if (!is_swp_registered()) { wp_enqueue_script('jquery-ui-tooltip'); wp_enqueue_style('jquery-ui-tooltip-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css', array()); } }
/** * 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'; $options['shop_order'] = 'none'; $options['shop_order_refund'] = 'none'; $options['shop_coupon'] = 'none'; $options['shop_webhook'] = 'none'; if ($admin || true === is_swp_registered()) { if ('totes' === $options['swTotesFormat']) { $options['swTotesFormat'] = 'totesalt'; } } else { $options['swp_twitter_card'] = false; $options['visualTheme'] = 'flatFresh'; $options['dColorSet'] = 'fullColor'; $options['iColorSet'] = 'fullColor'; $options['oColorSet'] = 'fullColor'; $options['sideDColorSet'] = 'fullColor'; $options['sideIColorSet'] = 'fullColor'; $options['sideOColorSet'] = 'fullColor'; $options['floatStyleSource'] = true; $options['buttonSize'] = 1; $options['buttonFloat'] = 'fullWidth'; $options['cttTheme'] = 'style1'; $options['twitter_shares'] = false; $options['recover_shares'] = false; $options['googleAnalytics'] = false; $options['linkShortening'] = false; $options['minTotes'] = 0; $options['swp_click_tracking'] = false; $options['orderOfIconsSelect'] = 'manual'; $options['pinit_toggle'] = false; $options['pinit_location_horizontal'] = 'center'; $options['pinit_location_vertical'] = 'top'; $options['emphasize_icons'] = 0; $options['floatLeftMobile'] = 'off'; } return $options; }
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; }
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); wp_enqueue_style('social_warfare_admin'); wp_enqueue_script('social_warfare_script', swp_PLUGIN_DIR . '/script.min.js', array('jquery'), swp_VERSION); wp_enqueue_script('social_warfare_admin_script', swp_PLUGIN_DIR . '/admin.js', array('jquery'), swp_VERSION); if (!is_swp_registered()) { wp_enqueue_script('jquery-ui-tooltip'); wp_enqueue_style('jquery-ui-tooltip-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css', array()); } }
function swp_pinit($info) { if ($info['swp_user_options']['pinit_toggle'] == true && is_swp_registered()) { $info['footer_output'] .= 'swp_pinit=true;swp_pinit_h_location="' . $info['swp_user_options']['pinit_location_horizontal'] . '";swp_pinit_v_location="' . $info['swp_user_options']['pinit_location_vertical'] . '";'; } else { $info['footer_output'] .= 'swp_pinit=false;'; } return $info; }
/** * THE SHARE BUTTONS FUNCTION: * * This function accepts an array of parameters resulting in the outputting of * the Social Warfare Buttons. * * * ACCEPTED PARAMETERS : * * content : The post content to which we append the buttons * : (string) * * where : Used to overwrite the default location in relation to the content * : ( above | below | both | none ) * * echo : Used to print or store the variables. * : ( true | false ) */ function social_warfare_buttons($array = array()) { global $swp_user_options; // 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_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() && !is_front_page()) { // 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); } if (isset($array['scale'])) { $scale = $array['scale']; } else { $scale = $options['buttonSize']; } // 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 $i = 0; 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; } } $button_set_array[$i] = $button; ++$i; } // 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); } // Filter the premium buttons out of the array if the plugin is not registered if (false === is_swp_registered()) { $icons_array = apply_filters('swp_button_options', $icons_array); foreach ($icons_array['content'] as $button => $value) { if (true === $value['premium']) { unset($buttonsArray['options']['newOrderOfIcons'][$button]); } } } // 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'] . ' scale-' . $scale * 100 . ' scale-' . $options['buttonFloat'] . '" data-position="' . $options['location_post'] . '" data-float="' . $floatOption . '" data-count="' . $buttonsArray['count'] . '" data-floatColor="' . $options['floatBgColor'] . '" data-emphasize="' . $options['emphasize_icons'] . '">'; // 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($buttonsArray['buttons']) && isset($buttonsArray['buttons']['totes']) && $buttonsArray['totes'] >= $options['minTotes'] || $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']; } } }
* @copyright Copyright (c) 2016, Warfare Plugins, LLC * @license GPL-3.0+ * @since 1.0.0 */ $premium_code = ''; $email = ''; if (!empty($swp_user_options['emailAddress'])) { $email = $swp_user_options['emailAddress']; } if (!empty($swp_user_options['premiumCode'])) { $premium_code = $swp_user_options['premiumCode']; } ?> <div class="registration-wrapper" registration="<?php echo absint(is_swp_registered()); ?> "> <h2><?php esc_html_e('Premium Registration', 'social-warfare'); ?> </h2> <div class="sw-grid sw-col-940 swp_is_not_registered"> <div class="sw-red-notice"> <?php _e('This copy of Social Warfare is NOT registered. <a target="_blank" href="https://warfareplugins.com">Click here</a> to purchase a license or add your account info below.', 'social-warfare'); ?> </div>
function swp_get_user_options($admin = false) { // Fetch the global options array global $swp_user_options; // Reset the Order of Icons Options if (isset($swp_user_options['orderOfIcons'])) { unset($swp_user_options['orderOfIcons']); update_option('socialWarfareOptions', $swp_user_options); } // Force the plugin off on certain post types $swp_user_options['locationattachment'] = 'none'; $swp_user_options['locationrevision'] = 'none'; $swp_user_options['nav_menu_item'] = 'none'; $swp_user_options['shop_order'] = 'none'; $swp_user_options['shop_order_refund'] = 'none'; $swp_user_options['shop_coupon'] = 'none'; $swp_user_options['shop_webhook'] = 'none'; // If this is the admin page or if the plugin is registered if ($admin == true || is_swp_registered() == true) { if (!isset($swp_user_options['locationSite'])) { $swp_user_options['locationSite'] = 'both'; } if (!isset($swp_user_options['totes'])) { $swp_user_options['totes'] = true; } if (!isset($swp_user_options['totesEach'])) { $swp_user_options['totesEach'] = true; } if (!isset($swp_user_options['twitterID'])) { $swp_user_options['twitterID'] = false; } if (!isset($swp_user_options['swp_twitter_card'])) { $swp_user_options['swp_twitter_card'] = true; } if (!isset($swp_user_options['visualTheme'])) { $swp_user_options['visualTheme'] = 'flatFresh'; } if (!isset($swp_user_options['dColorSet'])) { $swp_user_options['dColorSet'] = 'fullColor'; } if (!isset($swp_user_options['iColorSet'])) { $swp_user_options['iColorSet'] = 'fullColor'; } if (!isset($swp_user_options['oColorSet'])) { $swp_user_options['oColorSet'] = 'fullColor'; } if (!isset($swp_user_options['sideDColorSet'])) { $swp_user_options['sideDColorSet'] = 'fullColor'; } if (!isset($swp_user_options['sideIColorSet'])) { $swp_user_options['sideIColorSet'] = 'fullColor'; } if (!isset($swp_user_options['sideOColorSet'])) { $swp_user_options['sideOColorSet'] = 'fullColor'; } if (!isset($swp_user_options['floatStyleSource'])) { $swp_user_options['floatStyleSource'] = true; } if (!isset($swp_user_options['buttonSize'])) { $swp_user_options['buttonSize'] = 1; } if (!isset($swp_user_options['buttonFloat'])) { $swp_user_options['buttonFloat'] = 'fullWidth'; } if (!isset($swp_user_options['sideReveal'])) { $swp_user_options['sideReveal'] = 'slide'; } if (!isset($swp_user_options['swp_float_scr_sz'])) { $swp_user_options['swp_float_scr_sz'] = 1100; } if (!isset($swp_user_options['cttTheme'])) { $swp_user_options['cttTheme'] = 'style1'; } if (!isset($swp_user_options['twitter_shares'])) { $swp_user_options['twitter_shares'] = false; } if (!isset($swp_user_options['float'])) { $swp_user_options['float'] = true; } if (!isset($swp_user_options['floatOption'])) { $swp_user_options['floatOption'] = 'bottom'; } if (!isset($swp_user_options['floatBgColor'])) { $swp_user_options['floatBgColor'] = '#ffffff'; } if (!isset($swp_user_options['floatStyle'])) { $swp_user_options['floatStyle'] = 'default'; } if (!isset($swp_user_options['customColor'])) { $swp_user_options['customColor'] = '#000000'; } if (!isset($swp_user_options['recover_shares'])) { $swp_user_options['recover_shares'] = false; } if (!isset($swp_user_options['recovery_format'])) { $swp_user_options['recovery_format'] = 'unchanged'; } if (!isset($swp_user_options['recovery_protocol'])) { $swp_user_options['recovery_protocol'] = 'unchanged'; } if (!isset($swp_user_options['recovery_prefix'])) { $swp_user_options['recovery_prefix'] = 'unchanged'; } if (!isset($swp_user_options['swDecimals'])) { $swp_user_options['swDecimals'] = 0; } if (!isset($swp_user_options['swp_decimal_separator'])) { $swp_user_options['swp_decimal_separator'] = 'period'; } if (!isset($swp_user_options['swTotesFormat'])) { $swp_user_options['swTotesFormat'] = 'totesalt'; } if ($swp_user_options['swTotesFormat'] == 'totes') { $swp_user_options['swTotesFormat'] = 'totesalt'; } if (!isset($swp_user_options['googleAnalytics'])) { $swp_user_options['googleAnalytics'] = false; } if (!isset($swp_user_options['dashboardShares'])) { $swp_user_options['dashboardShares'] = true; } if (!isset($swp_user_options['linkShortening'])) { $swp_user_options['linkShortening'] = false; } if (!isset($swp_user_options['minTotes'])) { $swp_user_options['minTotes'] = 0; } if (!isset($swp_user_options['cacheMethod'])) { $swp_user_options['cacheMethod'] = 'advanced'; } if (!isset($swp_user_options['rawNumbers'])) { $swp_user_options['rawNumbers'] = false; } if (!isset($swp_user_options['notShowing'])) { $swp_user_options['notShowing'] = false; } if (!isset($swp_user_options['visualEditorBug'])) { $swp_user_options['visualEditorBug'] = false; } if (!isset($swp_user_options['loopFix'])) { $swp_user_options['loopFix'] = false; } if (!isset($swp_user_options['sniplyBuster'])) { $swp_user_options['sniplyBuster'] = false; } if (!isset($swp_user_options['analyticsMedium'])) { $swp_user_options['analyticsMedium'] = 'social'; } if (!isset($swp_user_options['analyticsCampaign'])) { $swp_user_options['analyticsCampaign'] = 'SocialWarfare'; } if (!isset($swp_user_options['swp_click_tracking'])) { $swp_user_options['swp_click_tracking'] = false; } if (!isset($swp_user_options['orderOfIconsSelect'])) { $swp_user_options['orderOfIconsSelect'] = 'manual'; } if (!isset($swp_user_options['pinit_toggle'])) { $swp_user_options['pinit_toggle'] = false; } if (!isset($swp_user_options['pinit_location_horizontal'])) { $swp_user_options['pinit_location_horizontal'] = 'center'; } if (!isset($swp_user_options['pinit_location_vertical'])) { $swp_user_options['pinit_location_vertical'] = 'top'; } // If it's not registered } else { if (!isset($swp_user_options['locationSite'])) { $swp_user_options['locationSite'] = 'both'; } if (!isset($swp_user_options['totes'])) { $swp_user_options['totes'] = true; } if (!isset($swp_user_options['totesEach'])) { $swp_user_options['totesEach'] = true; } if (!isset($swp_user_options['twitterID'])) { $swp_user_options['twitterID'] = false; } $swp_user_options['swp_twitter_card'] = false; $swp_user_options['visualTheme'] = 'flatFresh'; $swp_user_options['dColorSet'] = 'fullColor'; $swp_user_options['iColorSet'] = 'fullColor'; $swp_user_options['oColorSet'] = 'fullColor'; $swp_user_options['sideDColorSet'] = 'fullColor'; $swp_user_options['sideIColorSet'] = 'fullColor'; $swp_user_options['sideOColorSet'] = 'fullColor'; $swp_user_options['floatStyleSource'] = true; $swp_user_options['buttonSize'] = 1; $swp_user_options['buttonFloat'] = 'fullWidth'; if (!isset($swp_user_options['sideReveal'])) { $swp_user_options['sideReveal'] = 'slide'; } if (!isset($swp_user_options['swp_float_scr_sz'])) { $swp_user_options['swp_float_scr_sz'] = 1100; } $swp_user_options['cttTheme'] = 'style1'; $swp_user_options['twitter_shares'] = false; if (!isset($swp_user_options['float'])) { $swp_user_options['float'] = true; } if (!isset($swp_user_options['floatOption'])) { $swp_user_options['floatOption'] = 'bottom'; } if (!isset($swp_user_options['floatBgColor'])) { $swp_user_options['floatBgColor'] = '#ffffff'; } if (!isset($swp_user_options['floatStyle'])) { $swp_user_options['floatStyle'] = 'default'; } if (!isset($swp_user_options['customColor'])) { $swp_user_options['customColor'] = '#000000'; } $swp_user_options['recover_shares'] = false; if (!isset($swp_user_options['recovery_format'])) { $swp_user_options['recovery_format'] = 'unchanged'; } if (!isset($swp_user_options['recovery_protocol'])) { $swp_user_options['recovery_protocol'] = 'unchanged'; } if (!isset($swp_user_options['recovery_prefix'])) { $swp_user_options['recovery_prefix'] = 'unchanged'; } if (!isset($swp_user_options['swDecimals'])) { $swp_user_options['swDecimals'] = 0; } if (!isset($swp_user_options['swp_decimal_separator'])) { $swp_user_options['swp_decimal_separator'] = 'period'; } if (!isset($swp_user_options['swTotesFormat'])) { $swp_user_options['swTotesFormat'] = 'totesalt'; } if ($swp_user_options['swTotesFormat'] == 'totes') { $swp_user_options['swTotesFormat'] = 'totesalt'; } $swp_user_options['googleAnalytics'] = false; if (!isset($swp_user_options['dashboardShares'])) { $swp_user_options['dashboardShares'] = true; } $swp_user_options['linkShortening'] = false; $swp_user_options['minTotes'] = 0; if (!isset($swp_user_options['cacheMethod'])) { $swp_user_options['cacheMethod'] = 'advanced'; } if (!isset($swp_user_options['rawNumbers'])) { $swp_user_options['rawNumbers'] = false; } if (!isset($swp_user_options['notShowing'])) { $swp_user_options['notShowing'] = false; } if (!isset($swp_user_options['visualEditorBug'])) { $swp_user_options['visualEditorBug'] = false; } if (!isset($swp_user_options['loopFix'])) { $swp_user_options['loopFix'] = false; } if (!isset($swp_user_options['sniplyBuster'])) { $swp_user_options['sniplyBuster'] = false; } if (!isset($swp_user_options['analyticsMedium'])) { $swp_user_options['analyticsMedium'] = 'social'; } if (!isset($swp_user_options['analyticsCampaign'])) { $swp_user_options['analyticsCampaign'] = 'SocialWarfare'; } $swp_user_options['swp_click_tracking'] = false; $swp_user_options['orderOfIconsSelect'] = 'manual'; $swp_user_options['pinit_toggle'] = false; $swp_user_options['pinit_location_horizontal'] = 'center'; $swp_user_options['pinit_location_vertical'] = 'top'; } if (!isset($swp_user_options['newOrderOfIcons'])) { $swp_user_options['newOrderOfIcons']['active'] = array("twitter" => "Twitter", "linkedIn" => "LinkedIn", "pinterest" => "Pinterest", "facebook" => "Facebook", "googlePlus" => "Google Plus"); } elseif (isset($swp_user_options['newOrderOfIcons']) && is_swp_registered() == false) { $swp_options_page = array('tabs' => array('links' => array()), 'options' => array()); $swp_options_page = apply_filters('swp_options', $swp_options_page); foreach ($swp_options_page['options']['swp_display']['buttons']['content'] as $key => $value) { if (isset($swp_user_options['newOrderOfIcons'][$key]) && $value['premium'] == true) { unset($swp_user_options['newOrderOfIcons'][$key]); } } } return $swp_user_options; }
/** * A Function to Parse the Array & Build the Options Page */ function swp_build_options_page() { global $swp_user_options; // Create all of the options in one giant array. $swp_options_page = array('tabs' => array('links' => array()), 'options' => array()); // Fetch the global options array // global $swp_options_page; $swp_options_page = apply_filters('swp_options', $swp_options_page); /** * Build the header menu */ // Wrapper for the entire content area echo '<div class="sw-header-wrapper">'; echo '<div class="sw-grid sw-col-940 sw-top-menu">'; echo '<div class="sw-grid sw-col-700">'; echo '<img class="sw-header-logo" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/social-warfare-light.png" />'; echo '<ul class="sw-header-menu">'; $i = 0; foreach ($swp_options_page['tabs']['links'] as $key => $value) { ++$i; echo '<li' . ($i == 1 ? ' class="sw-active-tab"' : '') . '><a class="sw-tab-selector" href="#" data-link="' . $key . '"><span>' . $value . '</span></a></li>'; } echo '</ul>'; echo '</div>'; echo '<div class="sw-grid sw-col-220 sw-fit">'; echo '<a href="#" class="button sw-navy-button sw-save-settings">Save Changes</a>'; echo '</div>'; echo '<div class="sw-clearfix"></div>'; echo '</div>'; echo '</div>'; /** * Build the Tab Container */ echo '<div class="sw-admin-wrapper" sw-registered="' . absint(is_swp_registered()) . '">'; echo '<form class="sw-admin-settings-form">'; // Wrapper for the left 3/4 non-sidebar content echo '<div class="sw-tabs-container sw-grid sw-col-700">'; if (_swp_is_debug('register')) { var_dump(swp_check_registration_status()); } // Loop through the options tabs and build the options page foreach ($swp_options_page['options'] as $tab_name => $tab_options) { // Individual Tab Container - Full Width echo '<div id="' . $tab_name . '" class="sw-admin-tab sw-grid sw-col-940">'; // Loop through and output each option module for this tab foreach ($tab_options as $key => $option) { /** * Title Module */ if ($option['type'] == 'title') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<h2>' . $option['content'] . '</h2>'; echo '<div class="sw-premium-blocker" title="test"></div>'; echo '</div>'; } /** * Description Module */ if ($option['type'] == 'paragraph') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<p class="sw-subtitle">' . $option['content'] . '</p>'; echo '<div class="sw-premium-blocker no-icon"></div>'; echo '</div>'; } /** * Image Module */ if ($option['type'] == 'image') { echo '<img src="' . $option['content'] . '">'; } /** * Image Upload Module */ if ($option['type'] == 'image_upload') { // Fetch the value if (isset($swp_user_options[$key])) { $value = $swp_user_options[$key]; } else { $value = $option['default']; } // Create a whole parent container echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; // Title goes on the left echo '<div class="sw-grid sw-col-300">'; echo '<p class="sw-checkbox-label">Custom Button Image</p>'; echo '</div>'; // Button goes in the middle echo '<div class="sw-grid sw-col-300">'; echo '<label for="upload_image"> <input class="swp_upload_image_field" type="text" size="36" name="' . $key . '" value="' . $value . '" /> <a class="swp_upload_image_button button sw-navy-button" for="' . $key . '" type="button" value="Upload Image" />Upload Image</a> </label>'; echo '</div>'; // Preview goes on the right echo '<div class="sw-grid sw-col-300 sw-fit">'; echo '<div class="sw-preview-container">'; if ($value) { echo '<img class="sw-admin-image-preview" src="' . $value . '" />'; echo '<div class="sw-delete-image"></div>'; } echo '</div>'; echo '</div>'; echo '</div>'; } /** * Buttons Module */ if ($option['type'] == 'buttons') { // The Active Buttons echo '<div class="sw-grid sw-col-300">'; echo '<h3 class="sw-buttons-toggle">' . __('Active', 'social-warfare') . '</h3>'; echo '</div>'; echo '<div class="sw-grid sw-col-620 sw-fit">'; echo '<div class="sw-active sw-buttons-sort">'; // Check if we have saved settings to use if (isset($swp_user_options['newOrderOfIcons'])) { // Loop through each active button foreach ($swp_user_options['newOrderOfIcons'] as $key => $value) { echo '<i class="sw-s sw-' . $key . '-icon" data-network="' . $key . '" premium-button="' . $option['content'][$key]['premium'] . '"></i>'; } // Use defaults if nothing is saved } else { // Loop through the available buttons foreach ($option['content'] as $key => $value) { if ($value['default'] == true) { echo '<i class="sw-s sw-' . $key . '-icon" data-network="' . $key . '" premium-button="' . $option['content'][$key]['premium'] . '"></i>'; } } } echo '</div>'; echo '</div>'; echo '<div class="sw-clearfix"></div>'; // The Inactive Buttons echo '<div class="sw-grid sw-col-300">'; echo '<h3 class="sw-buttons-toggle">' . __('Inactive', 'social-warfare') . '</h3>'; echo '</div>'; echo '<div class="sw-grid sw-col-620 sw-fit">'; echo '<div class="sw-inactive sw-buttons-sort">'; // Check if we have saved settings to use if (isset($swp_user_options['newOrderOfIcons'])) { // Loop through each active button foreach ($option['content'] as $key => $value) { if (!isset($swp_user_options['newOrderOfIcons'][$key])) { echo '<i class="sw-s sw-' . $key . '-icon" data-network="' . $key . '" premium-button="' . $option['content'][$key]['premium'] . '"></i>'; } } // Use defaults if nothing is saved } else { // Loop through the available buttons foreach ($option['content'] as $key => $value) { if ($value['default'] == false) { echo '<i class="sw-s sw-' . $key . '-icon" data-network="' . $key . '" premium-button="' . $option['content'][$key]['premium'] . '"></i>'; } } } echo '</div>'; echo '</div>'; // The Inactive Buttons echo '<div class="sw-grid sw-col-940 sw-premium-buttons sw-option-container" premium="1">'; echo '<div class="sw-grid sw-col-300">'; echo '<h3 class="sw-buttons-toggle">Premium</h3>'; echo '</div>'; echo '<div class="sw-grid sw-col-620 sw-fit">'; echo '<div class="sw-inactive sw-buttons-sort">'; // Loop through the available buttons foreach ($option['content'] as $key => $value) { if ($option['content'][$key]['premium'] == true) { echo '<i class="sw-s sw-' . $key . '-icon" data-network="' . $key . '"></i>'; } } echo '</div>'; echo '</div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } /** * Checkbox Module */ if ($option['type'] == 'checkbox') { // Check for a default value if (isset($swp_user_options[$key]) && $swp_user_options[$key] == true) { $status = 'on'; $selected = 'checked'; } elseif (isset($swp_user_options[$key]) && $swp_user_options[$key] == false) { $status = 'off'; $selected = ''; } elseif ($option['default'] == true) { $status = 'on'; $selected = 'checked'; } else { $status = 'off'; $selected = ''; } // Check for four-fourths size if ($option['size'] == 'four-fourths') { echo '<div class="sw-grid sw-col-620"><h2 class="sw-h-label">' . $option['title'] . '</h2><p class="sw-subtext-label">' . $option['description'] . '</p></div>'; echo '<div class="sw-grid sw-col-300 sw-fit">'; echo '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $key . '"><div class="sw-checkbox-on">' . __('ON', 'social-warfare') . '</div><div class="sw-checkbox-off">' . __('OFF', 'social-warfare') . '</div></div>'; echo '<input type="checkbox" class="sw-hidden" name="' . $key . '" id="' . $key . '" ' . $selected . '>'; echo '</div>'; // Check for three-fourths-advanced size } elseif ($option['size'] == 'two-thirds-advanced') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="two-thirds-advanced">'; echo '<div class="sw-grid sw-col-300"><h2 class="sw-h-label">' . $option['title'] . '</h2><p class="sw-subtext-label">' . $option['description'] . '</p></div>'; echo '<div class="sw-grid sw-col-300">'; echo '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $key . '"><div class="sw-checkbox-on">' . __('ON', 'social-warfare') . '</div><div class="sw-checkbox-off">' . __('OFF', 'social-warfare') . '</div></div>'; echo '<input type="checkbox" class="sw-hidden" name="' . $key . '" id="' . $key . '" ' . $selected . '>'; echo '</div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; echo '</div>'; echo '<div class="sw-clearfix"></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; // Check for two-fourths size } elseif ($option['size'] == 'two-fourths') { if ($last_size == 'two-fourths') { $last_size = ''; $fit = 'sw-fit'; } else { $last_size = 'two-fourths'; $fit = ''; } echo '<div class="sw-grid sw-col-460 sw-option-container sw-fit ' . $key . '_wrapper" ' . ($option['dep'] ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' premium=' . $option['premium'] . '>'; echo '<div class="sw-grid sw-col-460"><p class="sw-checkbox-label">' . $option['content'] . '</p></div>'; echo '<div class="sw-grid sw-col-460 sw-fit">'; echo '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $key . '"><div class="sw-checkbox-on">' . __('ON', 'social-warfare') . '</div><div class="sw-checkbox-off">' . __('OFF', 'social-warfare') . '</div></div>'; echo '<input type="checkbox" class="sw-hidden" name="' . $key . '" id="' . $key . '" ' . $selected . '>'; echo '</div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; // All others } else { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' premium=' . $option['premium'] . '>'; if (isset($option['header']) && $option['header'] == true) { echo '<div class="sw-grid sw-col-300"><h2 class="sw-h-label">' . $option['content'] . '</h2></div>'; } else { echo '<div class="sw-grid sw-col-300"><p class="sw-checkbox-label">' . $option['content'] . '</p></div>'; } echo '<div class="sw-grid sw-col-300">'; echo '<div class="sw-checkbox-toggle" status="' . $status . '" field="#' . $key . '"><div class="sw-checkbox-on">' . __('ON', 'social-warfare') . '</div><div class="sw-checkbox-off">' . __('OFF', 'social-warfare') . '</div></div>'; echo '<input type="checkbox" class="sw-hidden" name="' . $key . '" id="' . $key . '" ' . $selected . '>'; echo '</div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } } /** * Input Module */ if ($option['type'] == 'input' && isset($option['size']) && $option['size'] == 'two-thirds') { if (isset($swp_user_options[$key])) { $value = $swp_user_options[$key]; } else { $value = $option['default']; } echo '<div class="sw-grid sw-col-940 sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-input-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-300"><input name="' . $key . '" type="text" class="sw-admin-input" ' . (isset($option['default']) ? 'placeholder="' . $option['default'] . '"' : '') . ' value="' . $value . '" /></div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '<div class="sw-clearfix"></div>'; echo '</div>'; } elseif ($option['type'] == 'input' && isset($option['size']) && $option['size'] == 'two-fourths') { if (isset($swp_user_options[$key])) { $value = $swp_user_options[$key]; } else { $value = $option['default']; } if ($last_size == 'two-fourths') { $last_size = ''; $fit = 'sw-fit'; } else { $last_size = 'two-fourths'; $fit = ''; } echo '<div class="sw-grid sw-col-460 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-460"><p class="sw-input-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-460 sw-fit"><input name="' . $key . '" type="text" class="sw-admin-input" placeholder="0" value="' . $value . '" /></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } elseif ($option['type'] == 'input' && isset($option['secondary'])) { if (isset($swp_user_options[$option['primary']])) { $value = $swp_user_options[$option['primary']]; } elseif (isset($option['default'])) { $value = $option['default']; } if (isset($swp_user_options[$option['secondary']])) { $value2 = $swp_user_options[$option['secondary']]; } elseif (isset($option['default_2'])) { $value2 = $option['default_2']; } echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-input-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-300"><input name="' . $option['primary'] . '" type="text" class="sw-admin-input" ' . (isset($option['default']) ? 'placeholder="' . $option['default'] . '"' : '') . ' value="' . $value . '" /></div>'; echo '<div class="sw-grid sw-col-300 sw-fit"><input name="' . $option['secondary'] . '" type="text" class="sw-admin-input" ' . (isset($option['default_2']) ? 'placeholder="' . $option['default_2'] . '"' : '') . ' value="' . $value2 . '" /></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } /** * Select Module */ if ($option['type'] == 'select' && isset($option['secondary'])) { if (isset($swp_user_options[$option['primary']])) { $value = $swp_user_options[$option['primary']]; } else { $value = $option['default']; } if (isset($swp_user_options[$option['secondary']])) { $value2 = $swp_user_options[$option['secondary']]; } else { $value2 = $option['default_2']; } echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-input-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-300">'; echo '<select name="' . $option['primary'] . '">'; if (!isset($option['default'])) { echo '<option value="">Select...</option>'; } foreach ($option['content'] as $select_key => $select_value) { echo '<option value="' . $select_key . '" ' . ($value == $select_key ? 'selected' : '') . '>' . $select_value . '</option>'; } echo '</select>'; echo '</div>'; echo '<div class="sw-grid sw-col-300 sw-fit">'; echo '<select name="' . $option['secondary'] . '">'; if (!isset($option['default_2'])) { echo '<option value="">Select...</option>'; } foreach ($option['content_2'] as $select_key => $select_value) { echo '<option value="' . $select_key . '" ' . ($value2 == $select_key ? 'selected' : '') . '>' . $select_value . '</option>'; } echo '</select>'; echo '</div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } elseif ($option['type'] == 'select' && $option['size'] == 'two-fourths') { if (isset($swp_user_options[$key])) { $value = $swp_user_options[$key]; } else { $value = $option['default']; } if ($last_size == 'two-fourths') { $last_size = ''; $fit = 'sw-fit'; } else { $last_size = 'two-fourths'; $fit = ''; } echo '<div class="sw-grid sw-col-460 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-460"><p class="sw-checkbox-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-460 sw-fit"><select name="' . $key . '">'; if (!isset($option['default'])) { echo '<option value="">Select...</option>'; } foreach ($option['content'] as $select_key => $select_value) { echo '<option value="' . $select_key . '" ' . ($value == $select_key ? 'selected' : '') . '>' . $select_value . '</option>'; } echo '</select></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } elseif ($option['type'] == 'select' && $option['size'] == 'two-thirds') { if (isset($swp_user_options[$key])) { $value = $swp_user_options[$key]; } else { $value = $option['default']; } echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-checkbox-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-300"><select name="' . $key . '">'; if (!isset($option['default'])) { echo '<option value="">Select...</option>'; } foreach ($option['content'] as $select_key => $select_value) { echo '<option value="' . $select_key . '" ' . ($value == $select_key ? 'selected' : '') . '>' . $select_value . '</option>'; } echo '</select></div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } /** * Three-Wide Column Labels Module */ if ($option['type'] == 'column_labels') { if ($option['columns'] == 3) { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-select-label sw-short sw-no-padding">' . $option['column_1'] . '</p></div>'; echo '<div class="sw-grid sw-col-300"><p class="sw-select-label sw-short sw-no-padding">' . $option['column_2'] . '</p></div>'; echo '<div class="sw-grid sw-col-300 sw-fit"><p class="sw-select-label sw-short sw-no-padding">' . $option['column_3'] . '</p></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } } /** * Divider Module */ if ($option['type'] == 'divider') { echo '<div class="sw-clearfix"></div><div class="sw-admin-divider sw-clearfix"></div>'; } /** * HTML Module */ if ($option['type'] == 'html') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo $option['content']; echo '<div class="sw-premium-blocker"></div>'; echo '<div class="sw-clearfix"></div></div>'; } /** * Authentication / Button Module */ if ($option['type'] == 'authentication') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; echo '<div class="sw-grid sw-col-300"><p class="sw-authenticate-label">' . $option['name'] . '</p></div>'; echo '<div class="sw-grid sw-col-300">'; if (isset($swp_user_options[$option['dependant']]) && $swp_user_options[$option['dependant']] != '') { echo '<a class="button sw-green-button" href="' . $option['link'] . '">' . __('Connected', 'social-warfare') . '</a>'; } else { echo '<a class="button sw-navy-button" href="' . $option['link'] . '">' . __('Authenticated', 'social-warfare') . '</a>'; } echo '</div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } /** * Plugin Registration Module */ if ('plugin_registration' === $option['type']) { require_once SWP_PLUGIN_DIR . '/functions/admin/views/options-registration.php'; } /** * Twitter Registration Module */ if ($option['type'] == 'tweet_counts') { echo '<div class="sw-grid sw-col-940 sw-fit sw-option-container ' . $key . '_wrapper" ' . (isset($option['dep']) ? 'dep="' . $option['dep'] . '" dep_val=\'' . json_encode($option['dep_val']) . '\'' : '') . ' ' . (isset($option['premium']) ? 'premium="' . $option['premium'] . '"' : '') . '>'; // Check for a default value if (isset($swp_user_options['twitter_shares']) && $swp_user_options['twitter_shares'] == true) { $status = 'on'; $selected = 'checked'; } elseif (isset($swp_user_options['twitter_shares']) && $swp_user_options['twitter_shares'] == false) { $status = 'off'; $selected = ''; } else { $status = 'off'; $selected = ''; } // Begin Registration Wrapper echo '<div class="tweet-count-wrapper" registration="false">'; // Registration Title echo '<h2>' . __('Tweet Count Registration', 'social-warfare') . '</h2>'; // Open the IS NOT Activated container echo '<div class="sw-grid sw-col-940 swp_tweets_not_activated" dep="twitter_shares" dep_val="[false]">'; // The Warning Notice & Instructions echo '<p class="sw-subtitle sw-registration-text">' . __('In order to allow Social Warfare to track tweet counts, we\'ve partnered with NewShareCounts.com. Follow the steps below to register with NewShareCounts and allow us to track your Twitter shares.', 'social-warfare') . '</p>'; echo '<p class="sw-subtitle sw-registration-text sw-italic">Step 1: <a style="float:none;" class="button sw-navy-button" href="http://newsharecounts.com" target="_blank">' . __('Click here to visit NewShareCounts.com', 'social-warfare') . '</a><br />' . __('Step 2: At NewShareCounts.com, Enter your domain and click the "Sign In With Twitter" button.', 'social-warfare') . '<img class="sw-tweet-count-demo" src="' . SWP_PLUGIN_URL . '/images/admin-options-page/new_share_counts.png" /><br />' . __('Step 3: Flip the switch below to "ON" and then save changes.', 'social-warfare') . '</p>'; // Close the IS NOT ACTIVATED container echo '</div>'; // Checkbox Module echo '<div class="sw-grid sw-col-300"><p class="sw-checkbox-label">Tweet Counts</p></div>'; echo '<div class="sw-grid sw-col-300">'; echo '<div class="sw-checkbox-toggle" status="' . $status . '" field="#twitter_shares"><div class="sw-checkbox-on">' . __('ON', 'social-warfare') . '</div><div class="sw-checkbox-off">' . __('OFF', 'social-warfare') . '</div></div>'; echo '<input type="checkbox" class="sw-hidden" name="twitter_shares" id="twitter_shares" ' . $selected . ' />'; echo '</div>'; echo '<div class="sw-grid sw-col-300 sw-fit"></div>'; // Close the Registration Wrapper echo '</div>'; echo '<div class="sw-premium-blocker"></div>'; echo '</div>'; } /** * Close the Tab Container */ // Add a divider element if necessary if (isset($option['divider']) && $option['divider'] == true) { echo '<div class="sw-clearfix"></div><div class="sw-admin-divider sw-clearfix"></div>'; } if (isset($option['size']) && $option['size'] != 'two-fourths') { $last_size = ''; } // Close the loop } // Close the tab container echo '</div>'; } echo '</form>'; echo '</div>'; /** * System Status Generator */ if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugins = get_plugins(); $pluginList = ''; foreach ($plugins as $plugin) { $pluginList .= '<tr><td><b>' . $plugin['Name'] . '</b></td><td>' . $plugin['Version'] . '</td></tr>'; } if (function_exists('fsockopen')) { $fsockopen = '<span style="color:green;">Enabled</span>'; } else { $fsockopen = '<span style="color:red;">Disabled</span>'; } if (function_exists('curl_version')) { $curl_version = curl_version(); $curl_status = '<span style="color:green;">Enabled: v' . $curl_version['version'] . '</span>'; } else { $curl_status = '<span style="color:red;">Disabled</span>'; } $theme = wp_get_theme(); $system_status = ' <table style="width:100%;"> <tr><td><h2>Environment Statuses</h2></td><td></td></tr> <tr><td><b>Home URL</b></td><td>' . get_home_url() . '</td></tr> <tr><td><b>Site URL</b></td><td>' . get_site_url() . '</td></tr> <tr><td><b>WordPress Version</b></td><td>' . get_bloginfo('version') . '</td></tr> <tr><td><b>PHP Version</b></td><td>' . phpversion() . '</td></tr> <tr><td><b>WP Memory Limit</b></td><td>' . WP_MEMORY_LIMIT . '</td></tr> <tr><td><b>Social Warfare Version</b></td><td>' . SWP_VERSION . '</td></tr> <tr><td><h2>Connection Statuses</h2></td><td></td></tr> <tr><td><b>fsockopen</b></td><td>' . $fsockopen . '</td></tr> <tr><td><b>cURL</b></td><td>' . $curl_status . '</td></tr> <tr><td><h2>Plugin Statuses</h2></td><td></td></tr> <tr><td><b>Theme Name</b></td><td>' . $theme['Name'] . '</td></tr> <tr><td><b>Theme Version</b></td><td>' . $theme['Version'] . '</td></tr> <tr><td><b>Active Plugins</b></td><td></td></tr> <tr><td><b>Number of Active Plugins</b></td><td>' . count($plugins) . '</td></tr> ' . $pluginList . ' </table> '; /** * The Right Sidebar */ echo '<div class="sw-admin-sidebar sw-grid sw-col-220 sw-fit">'; echo '<a href="https://warfareplugins.com/affiliates/" target="_blank"><img src="' . SWP_PLUGIN_URL . '/images/admin-options-page/affiliate-300x150.jpg"></a>'; echo '<a href="https://warfareplugins.com/walkthrough/" target="_blank"><img src="' . SWP_PLUGIN_URL . '/images/admin-options-page/starter-guide-300x150.jpg"></a>'; echo '<a href="https://warfareplugins.com/how-to-measure-social-media-roi-using-google-analytics/" target="_blank"><img src="' . SWP_PLUGIN_URL . '/images/admin-options-page/measure-roi-300x150.jpg"></a>'; echo '<p class="sw-support-notice sw-italic">' . __('Need help? Check out our <a href="https://warfareplugins.com/support/" target="_blank">Knowledgebase.', 'social-warfare') . '</a></p>'; echo '<p class="sw-support-notice sw-italic">' . __('Opening a support ticket? Copy your System Status by clicking the button below.', 'social-warfare') . '</p>'; echo '<a href="#" class="button sw-blue-button sw-system-status">' . __('Get System Status', 'social-warfare') . '</a>'; // Sytem Status Container echo '<div class="sw-clearfix"></div>'; echo '<div class="system-status-wrapper">'; echo '<h4>' . __('Press Ctrl+C to Copy this information.', 'social-warfare') . '</h4>'; echo '<div class="system-status-container">' . $system_status . '</div>'; echo '</div>'; echo '</div>'; echo '</div>'; }
/** * Check if the site is registered at our server. * * @since unknown * @global $swp_user_options * @return bool */ function swp_check_registration_status() { global $swp_user_options; $options = $swp_user_options; // Bail early if no premium code exists. if (empty($options['premiumCode'])) { return false; } $domain = swp_get_site_url(); $email = $options['emailAddress']; $args = array('activity' => 'check_registration', 'emailAddress' => $email, 'domain' => $domain, 'registrationCode' => swp_get_registration_key($domain)); $response = swp_get_registration_api($args, false); $status = is_swp_registered(); // If the response is negative, unregister the plugin.... if (!$response || 'false' === $response) { if (swp_register_plugin($email, $domain)) { $status = true; } else { swp_unregister_plugin($email, $options['premiumCode']); $status = false; } } return $status; }
function swp_pinit($info) { if ($info['swp_user_options']['pinit_toggle'] == true && is_swp_registered()) { $info['footer_output'] .= 'swp_pinit=true; swp_pinit_h_location="' . $info['swp_user_options']['pinit_location_horizontal'] . '"; swp_pinit_v_location="' . $info['swp_user_options']['pinit_location_vertical'] . '"; sw_pinit_min_width=' . str_replace('px', '', $info['swp_user_options']['pinit_min_width']) . '; sw_pinit_min_height=' . str_replace('px', '', $info['swp_user_options']['pinit_min_height']) . ';'; } else { $info['footer_output'] .= 'swp_pinit=false;'; } return $info; }
/** * ************************************************************** * * * Side Fixed Floater Function * * * ******************************************************************/ function socialWarfareSideFloat() { global $swp_user_options; // Get the options...or create them if they don't exist wp_reset_query(); $postID = get_the_ID(); $options = $swp_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; // Filter the premium buttons out of the array if the plugin is not registered if (false === is_swp_registered()) { $icons_array = apply_filters('swp_button_options', $icons_array); foreach ($icons_array['content'] as $button => $value) { if (true === $value['premium']) { unset($buttonsArray['options']['newOrderOfIcons'][$button]); } } } $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'] . '" data-mobileFloat="' . $options['floatLeftMobile'] . '">'; // 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; } }
function swp_pinterest_button_html($array) { // If we've already generated this button, just use our existing html if (isset($_GLOBALS['sw']['buttons'][$array['postID']]['pinterest'])) { $array['resource']['pinterest'] = $_GLOBALS['sw']['buttons'][$array['postID']]['pinterest']; // If not, let's check if Facebook is activated and create the button HTML } elseif ($array['options']['newOrderOfIcons']['pinterest'] && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['pinterest'])) { $array['totes'] += $array['shares']['pinterest']; ++$array['count']; $pi = get_post_meta($array['postID'], 'nc_pinterestImage', true); // Pinterest Username $pinterest_username = $array['options']['pinterestID']; if (isset($pinterest_username) && $pinterest_username != '') { $pu = ' via @' . str_replace('@', '', $pinterest_username); } else { $pu = ''; } if (swp_is_cache_fresh($array['postID']) == false) { // Check if an image ID has been provided $array['imageID'] = get_post_meta($array['postID'], 'nc_pinterestImage', true); if ($array['imageID']) { $array['imageURL'] = wp_get_attachment_url($array['imageID']); delete_post_meta($array['postID'], 'swp_pinterest_image_url'); update_post_meta($array['postID'], 'swp_pinterest_image_url', $array['imageURL']); // else: // $array['imageURL'] = wp_get_attachment_url( get_post_thumbnail_id( $array['postID'] ) ); // delete_post_meta($array['postID'],'swp_pinterest_image_url'); } } else { // Check if we have a cached Open Graph Image URL $array['imageURL'] = get_post_meta($array['postID'], 'swp_pinterest_image_url', true); // If not, let's check to see if we have an ID to generate one if (!$array['imageURL']) { // Check for an Open Graph Image ID $array['imageID'] = get_post_meta($array['postID'], 'nc_pinterestImage', true); if ($array['imageID']) { // If we find one, let's convert it to a link and cache it for next time $array['imageURL'] = wp_get_attachment_url($array['imageID']); delete_post_meta($array['postID'], 'swp_pinterest_image_url'); update_post_meta($array['postID'], 'swp_pinterest_image_url', $array['imageURL']); } else { // If we don't find one, let's see if we can use a post thumbnail $array['imageURL'] = wp_get_attachment_url(get_post_thumbnail_id($array['postID'])); } } } $pd = get_post_meta($array['postID'], 'nc_pinterestDescription', true); if ($array['imageURL']) { $pi = '&media=' . urlencode(html_entity_decode($array['imageURL'], ENT_COMPAT, 'UTF-8')); } else { $pi = ''; } $pinterestLink = $array['url']; $title = strip_tags(get_the_title($array['postID'])); $title = str_replace('|', '', $title); if ($pi != '' && is_swp_registered()) { $a = '<a data-link="https://pinterest.com/pin/create/button/?url=' . $pinterestLink . '' . $pi . '&description=' . ($pd != '' ? urlencode(html_entity_decode($pd . $pu, ENT_COMPAT, 'UTF-8')) : urlencode(html_entity_decode($title . $pu, ENT_COMPAT, 'UTF-8'))) . '" class="nc_tweet" data-count="0">'; } else { $a = '<a onClick="var e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e);" class="nc_tweet noPop">'; } $array['resource']['pinterest'] = '<div class="nc_tweetContainer nc_pinterest" data-id="' . $array['count'] . '" data-network="pinterest">'; $array['resource']['pinterest'] .= $a; if ($array['options']['totesEach'] && $array['shares']['totes'] >= $array['options']['minTotes'] && $array['shares']['pinterest'] > 0) { $array['resource']['pinterest'] .= '<span class="iconFiller">'; $array['resource']['pinterest'] .= '<span class="spaceManWilly" style="width:55px;">'; $array['resource']['pinterest'] .= '<i class="sw sw-pinterest"></i>'; $array['resource']['pinterest'] .= '<span class="swp_share"> ' . __('Pin', 'social-warfare') . '</span>'; $array['resource']['pinterest'] .= '</span></span>'; $array['resource']['pinterest'] .= '<span class="swp_count">' . swp_kilomega($array['shares']['pinterest']) . '</span>'; } else { $array['resource']['pinterest'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly" style="width:55px;"><i class="sw sw-pinterest"></i><span class="swp_share"> ' . __('Pin', 'social-warfare') . '</span></span></span></span>'; } $array['resource']['pinterest'] .= '</a>'; $array['resource']['pinterest'] .= '</div>'; // Store these buttons so that we don't have to generate them for each set $_GLOBALS['sw']['buttons'][$array['postID']]['pinterest'] = $array['resource']['pinterest']; } return $array; }
$info = apply_filters('swp_meta_tags', $info); if ($info['header_output']) { echo PHP_EOL . '<!-- Open Graph Meta Tags & Twitter Card generated by Social Warfare v' . SWP_VERSION . ' http://warfareplugins.com -->'; echo $info['header_output']; echo PHP_EOL . '<!-- Open Graph Meta Tags & Twitter Card generated by Social Warfare v' . SWP_VERSION . ' http://warfareplugins.com -->' . PHP_EOL . PHP_EOL; } } /** *************************************************************** * * * Queue Up our Open Graph Hooks * * * */ // Queue up our header hook function if (is_swp_registered()) { add_filter('swp_meta_tags', 'swp_open_graph_tags', 1); add_filter('swp_meta_tags', 'swp_add_twitter_card', 2); } add_filter('swp_meta_tags', 'swp_frame_buster', 3); add_filter('swp_meta_tags', 'swp_output_custom_color', 4); add_filter('swp_meta_tags', 'swp_output_font_css', 5); // add_filter( 'swp_meta_tags' , 'swp_output_cache_trigger' , 6 ); add_action('admin_head', 'swp_output_font_css', 10); // Disable Simple Podcast Press Open Graph tags if (is_plugin_active('simple-podcast-press/simple-podcast-press.php')) { global $ob_wp_simplepodcastpress; remove_action('wp_head', array($ob_wp_simplepodcastpress, 'spp_open_graph'), 1); } /** * **************************************************************