configuration panel for more settings. Version: 4.0.6.2 Author: Shareaholic Author URI: http://www.shareaholic.com Credits & Thanks: http://www.shareaholic.com/tools/wordpress/credits */ define('SHRSB_vNum','4.0.6.2'); /* * @note Make sure to include files first as there may be dependencies */ require_once 'includes/bookmarks-data.php'; // contains all bookmark templates require_once 'includes/html-helpers.php'; // helper functions for html output require_once 'includes/helper-functions.php'; // helper functions for backend //require_once 'includes/widget.php'; // widget /* * @ For Debugging Purpose */ if((isset($_GET['sb_debug']) || isset($_POST['sb_debug']) ) ){ //Global Debugging Variable $shrsb_debug = array(); $method = isset($_GET)? "get" : "post"; //true for get, false for post $shrsb_debug['dump_type'] = shrsb_get_value($method, "sb_dump"); $shrsb_debug['dump_type'] = shrsb_get_value($method, "dump_type"); $shrsb_debug['sb_script'] = shrsb_get_value($method, "sb_script", false); $shrsb_debug['sb_die'] = shrsb_get_value($method, "sb_die", false); $shrsb_debug['sb_log'] = shrsb_get_value($method, "sb_log", false); shrsb_dump_settings(); } /* * @desc Create Text Domain For Translations */ load_plugin_textdomain('shrsb', false, basename(dirname(__FILE__)) . '/languages/'); /* * Newer versions of WordPress include this class already * However, we've kept this here for people who are using older versions * This will mimick JSON support for PHP4 and below */ if ( !class_exists('SERVICES_JSON') ) { if ( !function_exists('json_decode') ){ function json_decode($content, $assoc=false){ require_once 'includes/JSON.php'; if ( $assoc ){ $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); } else { $json = new Services_JSON; } return $json->decode($content); } } if ( !function_exists('json_encode') ){ function json_encode($content){ require_once 'includes/JSON.php'; $json = new Services_JSON; return $json->encode($content); } } } /* * @desc Setting path for Shareaholic WP Plugin directory */ // Because we load assets via javascript, we can't rely on the Wordpress HTTPS plugin to do our http => https URL conversions. // Consequently, we check here if this is an https (ssl) page load. If it is, we use the https prefix instead of http. if ( !defined('WP_CONTENT_URL') ) { define('SHRSB_PLUGPATH', shrsb_correct_protocol(get_option('siteurl').'/wp-content/plugins/'.plugin_basename(dirname(__FILE__)).'/')); define('SHRSB_PLUGDIR', ABSPATH.'/wp-content/plugins/'.plugin_basename(dirname(__FILE__)).'/'); } else { define('SHRSB_PLUGPATH', shrsb_correct_protocol(WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)).'/')); define('SHRSB_PLUGDIR',WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__)).'/'); } /* * @desc Setting path for Shareaholic Upload directory (local WP) */ if ( !function_exists('wp_upload_dir') ) { define('SHRSB_UPLOADPATH_DEFAULT', shrb_addTrailingChar(get_option('siteurl'),"/").'wp-content/uploads/shareaholic/'); define('SHRSB_UPLOADDIR_DEFAULT', shrb_addTrailingChar(ABSPATH,"/").'wp-content/uploads/shareaholic/'); } else { $upload_path = wp_upload_dir(); if(!$upload_path["error"]){ define('SHRSB_UPLOADPATH_DEFAULT',shrb_addTrailingChar($upload_path['baseurl'],"/").'shareaholic/'); define('SHRSB_UPLOADDIR_DEFAULT',shrb_addTrailingChar($upload_path['basedir'],"/").'shareaholic/'); }else { define('SHRSB_UPLOADPATH_DEFAULT',shrb_addTrailingChar(SHRSB_PLUGPATH,"/")); define('SHRSB_UPLOADDIR_DEFAULT',shrb_addTrailingChar(SHRSB_PLUGDIR,"/")); } } /* * @desc Most Popular Services List * @note To change the most popular list also change the "Most Popular" link click handler in shareaholic-admin.js */ $shrsb_most_popular = array ( 'shr-facebook', 'shr-twitter', 'shr-linkedin', 'shr-googlebookmarks', 'shr-delicious', 'shr-stumbleupon', 'shr-reddit', 'shr-gmail', 'shr-mail', 'shr-printfriendly' ); $defaultLikeButtonOrder = array( 'shr-fb-like', 'shr-fb-send', 'shr-plus-one' ); /* * @desc Set default options */ $shrsb_plugopts = array( 'position' => 'below', // below, above, or manual 'reloption' => 'nofollow', // 'nofollow', or '' 'targetopt' => '_blank', // 'blank' or 'self' 'perfoption' => '1', // performance script (GA) 'showShareCount' => '1', // fb/twit share count 'likeButtonSetTop' => '0', // Include like button below the Post Title 'fbLikeButtonTop' => '0', // Include fb like button 'fbSendButtonTop' => '0', // Include fb like button 'googlePlusOneButtonTop' => '0', // Include Google Plus One button 'likeButtonSetSizeTop' => "1", // Size of like buttons 'likeButtonSetCountTop' => "true", // Show count with +1 button 'likeButtonOrderTop' => $defaultLikeButtonOrder, 'likeButtonSetAlignmentTop' => '0', // Alignment 0 => left, 1 => right 'likeButtonSetBottom' => '1', // Include like button below the Post 'fbLikeButtonBottom' => '0', // Include fb like button 'fbSendButtonBottom' => '0', // Include fb like button 'googlePlusOneButtonBottom' => '0', // Include Google Plus One button 'likeButtonSetSizeBottom' => "1", // Size of like buttons 'likeButtonSetCountBottom' => "true", // Show count with +1 button 'likeButtonOrderBottom' => $defaultLikeButtonOrder, 'likeButtonSetAlignmentBottom' => '0', // Alignment 0 => left, 1 => right 'fbNameSpace' => '1', // Add fb name space to the html 'preventminify' => '1', // prevent wp_minify from minifying the js 'shrlink' => '1', // show promo link 'bgimg-yes' => 'yes', // 'yes' or blank 'mobile-hide' => '', // 'yes' or blank 'bgimg' => 'caring', // default bg image 'shorty' => 'google', // default shortener 'pageorpost' => 'postpageindexcategory', 'bookmark' => $shrsb_most_popular,//array_keys($shrsb_bookmarks_data), // pulled from bookmarks-data.php 'feed' => '0', // 1 or 0 'expand' => '1', 'autocenter' => '1', 'tweetconfig' => '${title} - ${short_link} via @Shareaholic', // Custom configuration of tweet 'warn-choice' => '', 'doNotIncludeJQuery' => '', 'custom-mods' => '', 'scriptInFooter' => '', 'shareaholic-javascript' => '1', 'shrbase' => 'http://www.shareaholic.com', 'apikey' => '8afa39428933be41f8afdb8ea21a495c', 'designer_toolTips' => '1', 'tip_bg_color' => '#000000', // tooltip background color 'tip_text_color' => '#ffffff', // tooltip text color // comma delimited list of service ids for publisher javascript 'service' => '', 'spritegen_path' => SHRSB_UPLOADDIR_DEFAULT, 'ogtags' => '1' ); //add to database $shrsb_plugopts['tweetconfig'] = urlencode($shrsb_plugopts['tweetconfig']); add_option('SexyBookmarks', $shrsb_plugopts); add_option('SHRSB_apikey', $shrsb_plugopts['apikey']); add_option('SHRSB_CustomSprite', ''); add_option('SHRSB_DefaultSprite',true); //reload from database $shrsb_plugopts = get_option('SexyBookmarks'); //Remove the propeller Service if(isset ($shrsb_plugopts) && isset($shrsb_plugopts['service'])){ $services = explode(',', $shrsb_plugopts['service']); if(!empty($services)){ foreach ($services as $k => $v){ if($v == '77'){ unset ($services[$k]); } } $shrsb_plugopts['service'] = implode(',', $services ); } } /* * @note Make sure spritegen_path is defined */ if(!isset($shrsb_plugopts['spritegen_path'])) { $shrsb_plugopts['spritegen_path'] = SHRSB_UPLOADDIR_DEFAULT; }else{ if($shrsb_plugopts['spritegen_path'] == 'SHRSB_UPLOADDIR_DEFAULT') $shrsb_plugopts['spritegen_path'] = SHRSB_UPLOADDIR_DEFAULT; } //Check for POST if(isset($_POST['save_changes']) ){ //Define the default path for Spritegen Directory if(isset($_POST['spritegen_path']) && $_POST['spritegen_path'] != SHRSB_UPLOADDIR_DEFAULT){ //Create the Directory $p = shrb_addTrailingChar(stripslashes($_POST['spritegen_path']),"/"); define('SHRSB_UPLOADDIR', $p); define('SHRSB_UPLOADPATH', shr_dir_to_path($p)); }else{ define('SHRSB_UPLOADDIR', SHRSB_UPLOADDIR_DEFAULT); define('SHRSB_UPLOADPATH', SHRSB_UPLOADPATH_DEFAULT); } }else{ if( isset($_POST['reset_all_options'])|| (isset($shrsb_plugopts['spritegen_path']) && $shrsb_plugopts['spritegen_path'] == SHRSB_UPLOADDIR_DEFAULT) ){ // For Reseting the data Or First Time Install define('SHRSB_UPLOADDIR', SHRSB_UPLOADDIR_DEFAULT); define('SHRSB_UPLOADPATH', SHRSB_UPLOADPATH_DEFAULT); }else{ $p = shrb_addTrailingChar(stripslashes($shrsb_plugopts['spritegen_path']),"/"); define('SHRSB_UPLOADDIR', $p); define('SHRSB_UPLOADPATH', shr_dir_to_path($p)); } } // Some new default options may not be present in the database. // Add them if they aren't. if(!isset($shrsb_plugopts['designer_toolTips'])) { $shrsb_plugopts['designer_toolTips'] = '1'; $shrsb_plugopts['tip_bg_color'] = '#000000'; // tooltip background color $shrsb_plugopts['tip_text_color'] = '#ffffff'; // tooltip text color } if(!isset($shrsb_plugopts['likeButtonSetTop'])) { $shrsb_plugopts['likeButtonSetTop'] = '0'; // Include fb like button $shrsb_plugopts['fbLikeButtonTop'] = '0'; // if fb like button is included. Include in bottom right by default $shrsb_plugopts['fbSendButtonTop' ] = '0'; // Include fb like button $shrsb_plugopts['googlePlusOneButtonTop' ] = '0'; // Include Google Plus One button $shrsb_plugopts['likeButtonSetSizeTop' ] = "1"; // Size of like buttons $shrsb_plugopts['likeButtonSetCountTop'] = "true"; // Show count with +1 button $shrsb_plugopts['likeButtonOrderTop' ] = $defaultLikeButtonOrder; $shrsb_plugopts['likeButtonSetAlignmentTop' ] = '0'; // Alignment 0 => left, 1 => right $shrsb_plugopts['likeButtonSetBottom'] = '1'; // Include fb like button $shrsb_plugopts['fbLikeButtonBottom'] = '0'; // if fb like button is included. Include in bottom right by default $shrsb_plugopts['fbSendButtonBottom' ] = '0'; // Include fb like button $shrsb_plugopts['googlePlusOneButtonBottom' ] = '0'; // Include Google Plus One button $shrsb_plugopts['likeButtonSetSizeBottom' ] = "1"; // Size of like buttons $shrsb_plugopts['likeButtonSetCountBottom'] = "true"; // Show count with +1 button $shrsb_plugopts['likeButtonOrderBottom' ] = $defaultLikeButtonOrder; $shrsb_plugopts['likeButtonSetAlignmentBottom' ] = '0'; // Alignment 0 => left, 1 => right } if(!isset($shrsb_plugopts['ogtags'])) { $shrsb_plugopts['ogtags'] = "1"; } if(!isset($shrsb_plugopts['fbNameSpace'])) { $shrsb_plugopts['fbNameSpace'] = "1"; } if(!isset($shrsb_plugopts['preventminify'])) { $shrsb_plugopts['preventminify'] = "1"; } if($shrsb_plugopts['fbNameSpace'] == '1') { add_filter('language_attributes', 'shrsb_addFBNameSpace'); } $shrsb_plugopts['tweetconfig'] = urldecode($shrsb_plugopts['tweetconfig']); $shrsb_plugopts['apikey'] = get_option('SHRSB_apikey'); $shrsb_custom_sprite = get_option('SHRSB_CustomSprite'); $shrsb_version = get_option('SHRSBvNum'); // code to remove redundant data fields from the database if(isset($shrsb_plugopts['twittcat'])) { $shrsb_plugopts['ybuzzcat'] = ''; $shrsb_plugopts['ybuzzmed'] = ''; $shrsb_plugopts['twittcat'] = ''; $shrsb_plugopts['defaulttags'] = ''; } // Some databases got corrupted. This will set things in place. if($shrsb_plugopts['shrbase'] != 'http://www.shareaholic.com'){ $shrsb_plugopts['shrbase'] = 'http://www.shareaholic.com'; } // Reset depreciated url shorteners if($shrsb_plugopts['shorty'] == 'slly' || $shrsb_plugopts['shorty'] == 'cligs' || $shrsb_plugopts['shorty'] == 'snip' || $shrsb_plugopts['shorty'] == 'tinyarrow' || $shrsb_plugopts['shorty'] == 'b2l' || $shrsb_plugopts['shorty'] == 'trim' || $shrsb_plugopts['shorty'] == 'e7t') { $shrsb_plugopts['shortyapi']['snip']['user'] = ''; $shrsb_plugopts['shortyapi']['snip']['key'] = ''; $shrsb_plugopts['shortyapi']['trim']['chk'] = ''; $shrsb_plugopts['shortyapi']['trim']['user'] = ''; $shrsb_plugopts['shortyapi']['trim']['pass'] = ''; $shrsb_plugopts['shortyapi']['tinyarrow']['chk'] = ''; $shrsb_plugopts['shortyapi']['tinyarrow']['user'] = ''; $shrsb_plugopts['shortyapi']['cligs']['chk'] = ''; $shrsb_plugopts['shortyapi']['cligs']['key'] = ''; } /* * @desc Re-name values */ if($shrsb_plugopts['shorty'] == 'tiny') { $shrsb_plugopts['shorty'] = 'tinyurl'; } if($shrsb_plugopts['shorty'] == 'googl') { $shrsb_plugopts['shorty'] = 'google'; } /* * @desc Fix short URLs corrupt value */ if(isset($shrsb_plugopts['shortyapi'])){ if(strpos($shrsb_plugopts['shortyapi']['bitly']['user'],"sexybookmarks/sexy-bookmarks.php")) { $shrsb_plugopts['shortyapi']['bitly']['user'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['bitly']['key'],"sexybookmarks/sexy-bookmarks.php")) { $shrsb_plugopts['shortyapi']['bitly']['key'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['jmp']['user'],"sexybookmarks/sexy-bookmarks.php")) { $shrsb_plugopts['shortyapi']['jmp']['user'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['jmp']['key'],"sexybookmarks/sexy-bookmarks.php") ) { $shrsb_plugopts['shortyapi']['jmp']['key'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['supr']['chk'],"sexybookmarks/sexy-bookmarks.php") ) { $shrsb_plugopts['shortyapi']['supr']['chk'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['supr']['user'],"sexybookmarks/sexy-bookmarks.php") ) { $shrsb_plugopts['shortyapi']['supr']['user'] = ""; } if(strpos($shrsb_plugopts['shortyapi']['supr']['key'],"sexybookmarks/sexy-bookmarks.php") ) { $shrsb_plugopts['shortyapi']['supr']['key'] = ""; } }/* Short URLs End */ // if the version number is set and is not the latest, then call the upgrade function if(false !== $shrsb_version && $shrsb_version !== SHRSB_vNum ) { update_option('SHRSB_DefaultSprite',true); add_action('admin_notices', 'shrsb_Upgrade', 12); } $default_spritegen = get_option('SHRSB_DefaultSprite'); if(!is_writable(SHRSB_UPLOADDIR)) { //add_action('admin_notices', 'shrsb_SpritegenNotice', 12); } //if(false !== $shrsb_version && $shrsb_version !== SHRSB_vNum && SHRSB_vNum === '3.3.11' ) { // // This is specific till 3.3.11 to over ride existing customers to beta mode // if($shrsb_plugopts['shareaholic-javascript'] !== '1') { // $shrsb_plugopts['shareaholic-javascript'] = '1'; // update_option('SexyBookmarks', $shrsb_plugopts); // } //} function shrsb_Upgrade() { global $shrsb_plugopts; if (shrsb_get_current_user_role()=="Administrator"){ // check if sprite files are not present, ask the user to re-save setting. if($shrsb_plugopts['shareaholic-javascript'] == '1' || (!file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png') || !file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css'))) { echo '
'.sprintf(__('NOTICE: Shareaholic was just updated... Please visit the %sPlugin Options Page%s and re-save your preferences.', 'shrsb'), '', '').'
'; } } } function shrsb_SpritegenNotice() { if (shrsb_get_current_user_role()=="Administrator"){ echo '
'.sprintf(__('NOTICE: Your spritegen directory isn\'t writable... Please %sCHMOD%s your spritegen directory to ensure that Shareaholic remains working like a charm...', 'shrsb'), '', '').'
'; } } //add activation hook to remove all old and non-existent options from database if necessary function shrsb_Activate() { if(false === get_option('SHRSBvNum') || get_option('SHRSBvNum') == '') { delete_option('SexyBookmarks'); delete_option('SexyCustomSprite'); delete_option('SEXY_SPONSORS'); delete_option('SHRSB_CustomSprite'); } if(!file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png') || !file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css')) { delete_option('SHRSB_CustomSprite'); } } register_activation_hook( __FILE__, 'shrsb_Activate' ); //add deactivation hook to update the version number option so that options won't be deleted again upon upgrading function shrsb_deActivate() { if(false !== get_option('SHRSBvNum') || get_option('SHRSBvNum') != '') { update_option('SHRSBvNum', SHRSB_vNum); } } register_deactivation_hook( __FILE__, 'shrsb_deActivate' ); //add update notice to the main dashboard area so it's visible throughout function showUpdateNotice() { //If the option doesn't exist yet, it means the old naming scheme was found and scrubbed... Let's alert the user to update their settings if(!get_option('SHRSBvNum') || get_option('SHRSBvNum') == '') { echo '
'.sprintf(__('NOTICE: Shareaholic needs to be configured... Please visit the %sPlugin Options Page%s and set your preferences.', 'shrsb'), '', '').'
'; } } /* * @desc Adds "SexyBookmarks" options on each post */ function _add_meta_box_options() { if( shrsb_get_current_user_role() == "Administrator" || shrsb_get_current_user_role() == "Editor") { //"Hide options on each post add_meta_box( 'hide_options_meta', __( 'Shareaholic', 'shrsb' ), '_hide_options_meta_box_content', 'page', 'advanced', 'high' ); add_meta_box( 'hide_options_meta', __( 'Shareaholic', 'shrsb' ), '_hide_options_meta_box_content', 'post', 'advanced', 'high' ); } } add_action( 'admin_init', '_add_meta_box_options' ); function _hide_options_meta_box_content() { global $post; $hide_sexy = get_post_meta( $post->ID, 'Hide SexyBookmarks',true); $hide_ogtags = get_post_meta( $post->ID, 'Hide OgTags',true); if ( isset( $hide_sexy ) && $hide_sexy == 1 ) $hide_sexy = ' checked="checked"'; else $hide_sexy = ''; if ( isset( $hide_ogtags ) && $hide_ogtags == 1 ) $hide_ogtags = ' checked="checked"'; else $hide_ogtags = ''; //"Hide SexyBookmarks" option on each post echo '

'; //For Hiding the OG tags for specific posts echo '

'; } function _hide_options_meta_box_save( $post_id ) { if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; // Record sharing disable if (isset($_POST['post_type']) && !isset($_POST['_inline_edit']) && ('post' == $_POST['post_type'] || 'page' == $_POST['post_type'] )) { if ( current_user_can( 'edit_post', $post_id ) ) { if ( isset( $_POST['hide_sexy'] ) ) { update_post_meta( $post_id, 'Hide SexyBookmarks', 1 ); } else { //delete_post_meta( $post_id, 'Hide SexyBookmarks' ); update_post_meta( $post_id, 'Hide SexyBookmarks', 0 ); } if ( isset( $_POST['hide_ogtags'] ) ) { update_post_meta( $post_id, 'Hide OgTags', 1 ); } else { //delete_post_meta( $post_id, 'Hide OgTags' ); update_post_meta( $post_id, 'Hide OgTags', 0 ); } } } return $post_id; } add_action( 'save_post', '_hide_options_meta_box_save' ); add_action('admin_notices', 'showUpdateNotice', 12); /* * @desc Checks to see if wp-minify is installed, if so, whitelist our files */ function exclude_from_minify_list() { $minify_opts = get_option("wp_minify"); if(is_array($minify_opts) && is_array($minify_opts["js_exclude"])) { $bfound = false; foreach($minify_opts["js_exclude"] as $url) { if($url == 'jquery.shareaholic-publishers-sb.min.js') { $bfound = true; } } if(!$bfound) { array_push($minify_opts["js_exclude"],'jquery.shareaholic-publishers-sb.min.js'); } update_option("wp_minify", $minify_opts); } } function shrsb_likeButtonSetHTML($pos = 'Bottom') { // $pos = Bottom/Top global $shrsb_plugopts; ?> $v) { $pairs[] = implode('=', array(urlencode($k), urlencode($v))); } return implode('&', $pairs); } /** * Make a local copy of all shareaholic resources */ function shrsb_refresh_cache() { global $shrsb_plugopts, $shrsb_bgimg_map, $default_spritegen; $script = _shrsb_fetch_content('/media/js/jquery.shareaholic-publishers-sb.min.js', '/jquery.shareaholic-publishers-sb.min.js', true); // Sort services to make request more cacheable. $services = explode(',', $shrsb_plugopts['service']); sort($services, SORT_NUMERIC); $services = implode(',', $services); $sprite_opts = array( 'v' => 2, 'apikey' => $shrsb_plugopts['apikey'], 'service' => $services, 'bgimg' => $shrsb_bgimg_map[$shrsb_plugopts['bgimg']]['url'], 'bgimg_padding' => $shrsb_bgimg_map[$shrsb_plugopts['bgimg']]['padding'] ); // save as css so mime types work on normal servers $css = _shrsb_fetch_content('/api/sprite/?'._make_params($sprite_opts), '/sprite.css', true); $sprite_opts['apitype'] = 'png'; $png = _shrsb_fetch_content('/api/sprite/?'._make_params($sprite_opts), '/sprite.png', true); if(!$script || !$css || !$png) { update_option('SHRSB_DefaultSprite',true); $default_spritegen = true; } else { update_option('SHRSB_DefaultSprite',false); $default_spritegen = false; } } //write settings page function shrsb_settings_page() { global $shrsb_plugopts, $shrsb_bookmarks_data, $wpdb, $shrsb_custom_sprite,$shrsb_most_popular,$defaultLikeButtonOrder; // Add all the global varaible declarations for the $shrsb_plugopts default options e.g. $shrsb_most_popular,$defaultLikeButtonOrder echo '

Shareaholic Settings

'; //Defaults - set if not present if (!isset($_POST['reset_all_options'])){$_POST['reset_all_options'] = '1';} if (!isset($_POST['shrsbresetallwarn-choice'])){$_POST['shrsbresetallwarn-choice'] = 'no';} if (!isset($_POST['custom-mods']) || $shrsb_plugopts['custom-mods'] == ""){$_POST['custom-mods'] = 'no';} if($_POST['reset_all_options'] == '0') { echo '
'.__("WARNING: You are about to reset all settings to their default state! Do you wish to continue?", "shrsb").'
 
'; } //Reset all options to default settings if user clicks the reset button if($_POST['shrsbresetallwarn-choice'] == "yes") { //check for reset button click delete_option('SexyBookmarks'); $shrsb_plugopts = array( 'position' => 'below', // below, above, or manual 'reloption' => 'nofollow', // 'nofollow', or '' 'targetopt' => '_blank', // 'blank' or 'self' 'perfoption' => '1', // performance script (GA) 'showShareCount' => '1', // fb/twit share count 'likeButtonSetTop' => '0', // Include like button below the Post Title 'fbLikeButtonTop' => '0', // Include fb like button 'fbSendButtonTop' => '0', // Include fb like button 'googlePlusOneButtonTop' => '0', // Include Google Plus One button 'likeButtonSetSizeTop' => "1", // Size of like buttons 'likeButtonSetCountTop' => "true", // Show count with +1 button 'likeButtonOrderTop' => $defaultLikeButtonOrder, 'likeButtonSetAlignmentTop' => '0', // Alignment 0 => left, 1 => right 'likeButtonSetBottom' => '1', // Include like button below the Post 'fbLikeButtonBottom' => '0', // Include fb like button 'fbSendButtonBottom' => '0', // Include fb like button 'googlePlusOneButtonBottom' => '0', // Include Google Plus One button 'likeButtonSetSizeBottom' => "1", // Size of like buttons 'likeButtonSetCountBottom' => "true", // Show count with +1 button 'likeButtonOrderBottom' => $defaultLikeButtonOrder, 'likeButtonSetAlignmentBottom' => '0', // Alignment 0 => left, 1 => right 'fbNameSpace' => '1', // Add fb name space to the html 'preventminify' => '1', // prevent wp_minify from minifying the js 'shrlink' => '1', // show promo link 'bgimg-yes' => 'yes', // 'yes' or blank 'mobile-hide' => '', // 'yes' or blank 'bgimg' => 'caring', // default bg image 'shorty' => 'google', // default shortener 'pageorpost' => 'postpageindexcategory', 'bookmark' => $shrsb_most_popular ,//array_keys($shrsb_bookmarks_data), 'feed' => '0', // 1 or 0 'expand' => '1', 'autocenter' => '1', 'tweetconfig' => '${title} - ${short_link} via @Shareaholic', // Custom configuration of tweet 'warn-choice' => '', 'doNotIncludeJQuery' => '', 'custom-mods' => '', 'scriptInFooter' => '', 'shareaholic-javascript' => '1', 'shrbase' => 'http://www.shareaholic.com', 'apikey' => get_option('SHRSB_apikey'), 'service' => '', 'designer_toolTips' => '1', 'tip_bg_color' => '#000000', // tooltip background color 'tip_text_color' => '#ffffff', // tooltip text color 'spritegen_path' => SHRSB_UPLOADDIR_DEFAULT, 'ogtags' => '1' //OgTags ); $shrsb_plugopts['tweetconfig'] = urlencode($shrsb_plugopts['tweetconfig']); if($shrsb_plugopts['preventminify'] == '1') { exclude_from_minify_list(); } /* Short URLs */ $shrsb_plugopts['shortyapi']['bitly']['user'] = ""; $shrsb_plugopts['shortyapi']['bitly']['key'] = ""; $shrsb_plugopts['shortyapi']['jmp']['user'] = ""; $shrsb_plugopts['shortyapi']['jmp']['key'] = ""; $shrsb_plugopts['shortyapi']['supr']['chk'] = "0"; $shrsb_plugopts['shortyapi']['supr']['user'] = ""; $shrsb_plugopts['shortyapi']['supr']['key'] = ""; /* Short URLs End */ update_option('SexyBookmarks', $shrsb_plugopts); $shrsb_plugopts['tweetconfig'] = urldecode($shrsb_plugopts['tweetconfig']); delete_option('SHRSB_CustomSprite'); echo '
'.__('All settings have been reset to their default values.', 'shrsb').'
'; } // create folders for custom mods // then copy original files into new folders if($_POST['custom-mods'] == 'yes' || $shrsb_plugopts['custom-mods'] == 'yes') { if(is_admin() === true && !is_dir(WP_CONTENT_DIR.'/sexy-mods')) { $shrsb_oldloc = SHRSB_PLUGDIR; $shrsb_newloc = WP_CONTENT_DIR.'/sexy-mods/'; wp_mkdir_p(WP_CONTENT_DIR.'/sexy-mods'); wp_mkdir_p(WP_CONTENT_DIR.'/sexy-mods/css'); wp_mkdir_p(WP_CONTENT_DIR.'/sexy-mods/images'); wp_mkdir_p(WP_CONTENT_DIR.'/sexy-mods/js'); copy($shrsb_oldloc.'css/style-dev.css', $shrsb_newloc.'css/style.css'); copy($shrsb_oldloc.'js/sexy-bookmarks-public.js', $shrsb_newloc.'js/sexy-bookmarks-public.js'); copy($shrsb_oldloc.'images/shr-sprite.png', $shrsb_newloc.'images/shr-sprite.png'); copy($shrsb_oldloc.'images/share-enjoy.png', $shrsb_newloc.'images/share-enjoy.png'); copy($shrsb_oldloc.'images/share-german.png', $shrsb_newloc.'images/share-german.png'); copy($shrsb_oldloc.'images/share-love-hearts.png', $shrsb_newloc.'images/share-love-hearts.png'); copy($shrsb_oldloc.'images/share-wealth.png', $shrsb_newloc.'images/share-wealth.png'); copy($shrsb_oldloc.'images/sharing-caring-hearts.png', $shrsb_newloc.'images/sharing-caring-hearts.png'); copy($shrsb_oldloc.'images/sharing-caring.png', $shrsb_newloc.'images/sharing-caring.png'); copy($shrsb_oldloc.'images/sharing-shr.png', $shrsb_newloc.'images/sharing-shr.png'); } } // processing form submission $status_message = ""; $error_message = ""; if(isset($_POST['save_changes'])) { if(isset($_POST['bookmark']['shr-fleck'])) { unset($_POST['bookmark']['shr-fleck']); } $_POST['pageorpost'] = shrsb_set_content_type(); // Set success message $status_message = __('Your changes have been saved successfully!', 'shrsb'); $errmsgmap = array( 'position'=>__('Please choose where you would like the menu to be displayed.', 'shrsb'), 'bookmark'=>__("You can't display the menu if you don't choose a few sites to add to it!", 'shrsb'), 'pageorpost'=>__('Please choose where you want the menu displayed.', 'shrsb'), ); foreach ($errmsgmap as $field=>$msg) { if ($_POST[$field] == '') { $error_message = $msg; break; } } // Twitter friendly Links & YOURLs Plugins: check to see if they have the plugin activated if ($_POST['shorty'] == 'tflp' && !function_exists('permalink_to_twitter_link')) { $error_message = sprintf(__('You must first download and activate the %sTwitter Friendly Links Plugin%s before hosting your own short URLs...', 'shrsb'), '', ''); } elseif ($_POST['shorty'] == 'yourls' && !function_exists('wp_ozh_yourls_raw_url')) { $error_message = sprintf(__('You must first download and activate the %sYOURLS Plugin%s before hosting your own short URLs...', 'shrsb'), '', ''); } if ( isset($_POST['bookmark']) && is_array($_POST['bookmark']) && sizeof($_POST['bookmark']) > 0 && $shrsb_plugopts['shareaholic-javascript'] == '1') { $service_ids = array(); foreach ( $_POST['bookmark'] as $bm ) { if ($this_id = $shrsb_bookmarks_data[$bm]['id']) { $service_ids[] = $this_id; } } $shrsb_plugopts['service'] = implode(',', $service_ids); shrsb_refresh_cache(); _shrsb_copy_file(SHRSB_UPLOADDIR.'index.html', SHRSB_PLUGDIR.'spritegen_default/index.html'); _shrsb_copy_file(SHRSB_UPLOADDIR.'spritegen/index.html', SHRSB_PLUGDIR.'spritegen_default/index.html'); } if (!$error_message) { //generate a new sprite, to reduce the size of the image if(shrsb_preFlight_Checks()) { if ( isset($_POST['bookmark']) && is_array($_POST['bookmark']) and sizeof($_POST['bookmark']) > 0 ) { $spritegen_opts = '&service='; foreach ( $_POST['bookmark'] as $bm ) { $spritegen_opts .= substr($bm, 4) . ','; } $spritegen_opts = substr($spritegen_opts,0,-1); $spritegen_opts .= '&bgimg=' . $_POST['bgimg'] . '&expand=' . $_POST['expand']; $save_return[0] = get_sprite_file($spritegen_opts, 'png'); $save_return[1] = get_sprite_file($spritegen_opts, 'css'); } if($save_return[0] == 2 || $save_return[1] == 2) { echo '
'.__('WARNING: The request for a custom sprite has timed out. Reverting to default sprite files.', 'shrsb').'
'; $shrsb_custom_sprite = ''; $status_message = __('Changes saved successfully. However, you should try to generate a custom sprite again later.', 'shrsb'); } elseif($save_return[0] == 1 || $save_return[1] == 1) { if (!is_writable(SHRSB_UPLOADDIR.'spritegen')) { echo '
'.sprintf(__('WARNING: Your %sspritegen folder%s is not writeable by the server! %sNeed Help?%s', 'shrsb'), '','','', '').'
'; $shrsb_custom_sprite = ''; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } elseif(file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png') && is_writable(SHRSB_UPLOADDIR.'spritegen') && !is_writable(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png')) { echo '
'.sprintf(__('WARNING: You need to delete the current custom sprite %s before the plugin can write to the folder. %sNeed Help?%s', 'shrsb'), '('.SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png)','', '').'
'; $shrsb_custom_sprite = ''; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } elseif(file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css') && is_writable(SHRSB_UPLOADDIR.'spritegen') && !is_writable(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css')) { echo '
'.sprintf(__('WARNING: You need to delete the current custom stylesheet %s before the plugin can write to the folder. %sNeed Help?%s', 'shrsb'), '('.SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css)','', '').'
'; $shrsb_custom_sprite = ''; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } } else { $shrsb_custom_sprite = SHRSB_UPLOADPATH.'spritegen/shr-custom-sprite.css'; } } else{ if (!is_writable(SHRSB_UPLOADDIR.'spritegen')) { echo '
'.sprintf(__('WARNING: Your %sspritegen folder%s is not writeable by the server! %sNeed Help?%s', 'shrsb'), '','','', '').'
'; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } elseif(file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png') && is_writable(SHRSB_UPLOADDIR.'spritegen') && !is_writable(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png')) { echo '
'.sprintf(__('WARNING: You need to delete the current custom sprite %s before the plugin can write to the folder. %sNeed Help?%s', 'shrsb'), '('.SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png)','', '').'
'; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } elseif(file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css') && is_writable(SHRSB_UPLOADDIR.'spritegen') && !is_writable(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css')) { echo '
'.sprintf(__('WARNING: You need to delete the current custom stylesheet %s before the plugin can write to the folder. %sNeed Help?%s', 'shrsb'), '('.SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css)','', '').'
'; $status_message = __('Changes saved successfully. However, settings are not optimal until you resolve the issue listed above.', 'shrsb'); } } foreach (array( 'position', 'reloption', 'targetopt', 'bookmark', 'shorty', 'pageorpost', 'tweetconfig', 'bgimg-yes', 'mobile-hide', 'bgimg', 'feed', 'expand', 'doNotIncludeJQuery', 'autocenter', 'custom-mods', 'scriptInFooter', 'shareaholic-javascript', 'shrbase', 'showShareCount', 'likeButtonSetTop','fbLikeButtonTop','fbSendButtonTop','googlePlusOneButtonTop','likeButtonSetSizeTop','likeButtonSetCountTop', 'likeButtonOrderTop','likeButtonSetAlignmentTop', 'likeButtonSetBottom','fbLikeButtonBottom','fbSendButtonBottom','googlePlusOneButtonBottom','likeButtonSetSizeBottom','likeButtonSetCountBottom', 'likeButtonOrderBottom','likeButtonSetAlignmentBottom', 'fbNameSpace','designer_toolTips' , 'tip_bg_color', 'tip_text_color' , 'preventminify', 'shrlink', 'perfoption','spritegen_path', 'apikey','ogtags' )as $field) { if(isset($_POST[$field])) { // this is to prevent warning if $_POST[$field] is not defined $shrsb_plugopts[$field] = $_POST[$field]; } else { $shrsb_plugopts[$field] = NULL; } } /* * @note WordPress autoescapes (= adds slashes) to all post data. This is a workaround for that. */ $shrsb_plugopts['tweetconfig'] = stripslashes($shrsb_plugopts['tweetconfig']); $shrsb_plugopts['spritegen_path'] = shrb_addTrailingChar(stripslashes($shrsb_plugopts['spritegen_path']),'/'); /* Short URLs */ //trim also at the same time as at times while copying, some whitespace also gets copied //check fields dont need trim function $shrsb_plugopts['shortyapi']['bitly']['user'] = trim(htmlspecialchars($_POST['shortyapiuser-bitly'], ENT_QUOTES)); $shrsb_plugopts['shortyapi']['bitly']['key'] = trim(htmlspecialchars($_POST['shortyapikey-bitly'], ENT_QUOTES)); $shrsb_plugopts['shortyapi']['jmp']['user'] = trim(htmlspecialchars($_POST['shortyapiuser-jmp'], ENT_QUOTES)); $shrsb_plugopts['shortyapi']['jmp']['key'] = trim(htmlspecialchars($_POST['shortyapikey-jmp'], ENT_QUOTES)); $shrsb_plugopts['shortyapi']['supr']['chk'] = htmlspecialchars($_POST['shortyapichk-supr'][0], ENT_QUOTES); $shrsb_plugopts['shortyapi']['supr']['user'] = trim(htmlspecialchars($_POST['shortyapiuser-supr'], ENT_QUOTES)); $shrsb_plugopts['shortyapi']['supr']['key'] = trim(htmlspecialchars($_POST['shortyapikey-supr'], ENT_QUOTES)); /* Short URLs End */ $shrsb_plugopts['tweetconfig'] = urlencode($shrsb_plugopts['tweetconfig']); if($shrsb_plugopts['preventminify'] == '1') { exclude_from_minify_list(); } update_option('SexyBookmarks', $shrsb_plugopts); $shrsb_plugopts['tweetconfig'] = urldecode($shrsb_plugopts['tweetconfig']); update_option('SHRSB_CustomSprite', $shrsb_custom_sprite); update_option('SHRSBvNum', SHRSB_vNum); } }//Closed Save //if there was an error, construct error messages if ($error_message != '') { echo '
'.$error_message.'
'; } elseif ($status_message != '') { echo '
'.$status_message.'
'; } ?>
> ', '') : ""; ?>
>
>
  • New! Did you know that content from this website has been shared time(s) in the past day(s)?', 'shrsb')); ?>



    Access detailed %ssocial engagement analytics%s about your website for FREE right now!

    You have been selected to preview the upcoming premium analytics add-on for SexyBookmarks for FREE for a limited time - so hurry before it is too late! These analytics are designed to help you grow your traffic and referrals.', 'shrsb'), '', ''); ?>
    •  | 
    •  | 
    •  
  • *
    *
    *

    ', ''); ?>
    *
  • *
    *

    *

  • class="hide">

    Twitter!


    ${title}', '${short_link}'); ?>


    ${title} - ${short_link} (via @Shareaholic)

    RT @Shareaholic: ${title} - ${short_link}




    class="hidden">
    class="hidden">
    class="hidden"> name="shortyapichk-supr[]" id="shortyapichk-supr" type="checkbox" value="1" />
    class="hidden">
  • ', ''); ?>

    1. SexyBookmarks)', 'shrsb'); ?>
    name="custom-mods" id="custom-mods" type="checkbox" value="yes" />
    name="bgimg-yes" id="bgimg-yes" type="checkbox" value="yes" />
  • value="1" /> value="1" /> value="1" />

  • ', ''); ?>
    />
    />
    />
    />

  • '.sprintf(__('NOTICE: We have noticed that you are using an old version of PHP. It is highly recommended that you upgrade to PHP 5 or higher to avail certain advanced Shareaholic features. Also, if you do not upgrade to PHP 5 you will not be able to run WordPress 3.2+', 'shrsb'), '', '').'
    '; } } require_once 'includes/shrsb_authentication_page.php'; require_once 'includes/shrsb_analytics_page.php'; function shrsb_requires_resave() { global $shrsb_plugopts,$default_spritegen; $resave_required = false; if(($shrsb_plugopts['shareaholic-javascript'] == '1' //new mode && $default_spritegen) || ($shrsb_plugopts['shareaholic-javascript'] != '1' //old mode && !(file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.png') && file_exists(SHRSB_UPLOADDIR.'spritegen/shr-custom-sprite.css') ) ) ){ $resave_required = true; } return $resave_required; } /* * @desc Check for chmod for new-custom and old-custom mode only */ function shrsb_requires_chmod($mode = NULL) { return !(is_writable(SHRSB_UPLOADDIR.'spritegen')); } function shrsb_requires_phpupdate() { return (strnatcmp(phpversion(),'5.0') < 0); } function shrsb_account_page() { global $shrsb_plugopts; $apikey = $_POST['apikey'] ? $_POST['apikey'] : $shrsb_plugopts['apikey'] ; $bAuth = shrsb_authenticate_user($apikey); shrsb_authentication_page($bAuth ? $apikey : null); } function shrsb_authenticate_user($api_key = null) { $shr_pub_class = SHR_PUB_PRO::getInstance(); $auth = $shr_pub_class->set_api_key($api_key); return $auth; } //add sidebar link to settings page add_action('admin_menu', 'shrsb_menu_link'); /* * @desc Show Shareaholic Menu on WP Admin Dashboard */ function shrsb_menu_link() { if (function_exists('add_menu_page')) { $shrsb_admin_page = add_menu_page( __( 'Shareaholic for Publishers', 'shrsb' ), __( 'Shareaholic', 'shrsb' ), 'administrator', basename(__FILE__), 'shrsb_settings_page', SHRSB_PLUGPATH.'images/shareaholic_16x16.png'); add_submenu_page( basename(__FILE__), __( 'SexyBookmarks' ), __( 'SexyBookmarks', 'shrsb' ), 'administrator', basename(__FILE__), 'shrsb_settings_page' ); /* $shrsb_analytics_page = add_submenu_page( basename(__FILE__), __( 'Social Analytics' ), __( 'Social Analytics', 'shrsb' ), 'administrator', 'shareaholic_analytics.php', 'shrsb_analytics_page' ); $shrsb_account_page = add_submenu_page( basename(__FILE__), __( 'My Account' ), __( 'My Account', 'shrsb' ), 'administrator', 'shareaholic_account.php', 'shrsb_account_page' ); */ add_action( "admin_print_scripts-$shrsb_admin_page", 'shrsb_admin_scripts' ); add_action( "admin_print_styles-$shrsb_admin_page", 'shrsb_admin_styles' ); //add_action( "admin_print_styles-$shrsb_account_page", 'shrsb_admin_styles' ); //add_action( "admin_print_styles-$shrsb_analytics_page", 'shrsb_admin_styles' ); } } //styles and scripts for admin area function shrsb_admin_scripts() { wp_enqueue_script('shareaholic-admin-js', SHRSB_PLUGPATH.'js/shareaholic-admin.min.js', array('jquery','jquery-ui-sortable'), SHRSB_vNum, true); echo get_googleanalytics(); } /* * @desc Add promo bar for browser extensions */ function shrsb_show_promo(){ if (is_admin()) { wp_enqueue_script('shareaholic-promo', SHRSB_PLUGPATH.'js/shareaholic-promo.min.js', array('jquery'), SHRSB_vNum, false); wp_enqueue_style('shareaholic-promo', SHRSB_PLUGPATH.'css/shareaholic-promo.css', false, SHRSB_vNum); } } add_action('set_current_user', 'shrsb_show_promo'); //Change the directory path to webpath function shr_dir_to_path($dir){ if(!$dir){ return false; } $path = get_option("siteurl"); if(substr($path, -1) != '/'){ $path .= '/'; } $path .= substr($dir , strlen(ABSPATH)); return $path; } function shrsb_first_image() { global $post, $posts; $og_first_img = ''; ob_start(); ob_end_clean(); if ($post == null) return false; else { $output = preg_match_all('//i', $post->post_content, $matches); if(isset($matches) && isset($matches[1]) && isset($matches[1][0]) ){ $og_first_img = $matches[1][0]; } if(empty($og_first_img)){ // return false if nothing there, makes life easier return false; } return $og_first_img; } } /* * @desc For setting the content type which are enablled */ function shrsb_set_content_type() { $type = ""; $content = $_POST['content_type']; if(empty ($content)){ $type = "postpageindexcategory"; }else{ $n = count($content); for($i = 0; $i < $n; $i++){ $type .= $content[$i]; } } return $type; } /* * @desc For adding Open Graph tags to each post (http://ogp.me/) */ function shrsb_add_ogtags_head() { global $post,$shrsb_plugopts; // check to see if ogtags are enabled or not if (!isset($shrsb_plugopts['ogtags']) || empty($shrsb_plugopts['ogtags'])) { echo "\n\n".''."\n\n"; }else{ //Check whther OG Tags enabled for this post if(($ogtags_meta = get_post_meta($post->ID, 'Hide OgTags',true)) == 1) { echo "\n\n".''."\n\n"; return; } echo "\n\n".''."\n\n"; // do url stuff // if (is_home() || is_front_page() ) { // echo "\t\n"; // }else{ // if ($post != null) // echo "\t\n"; // } // do title stuff // if (is_home() || is_front_page() ) { // echo "\t\n"; // }else{ // echo "\t\n"; // } // do additional randoms // echo "\t\n"; // do descriptions // if (is_singular('post')) { // if (has_excerpt($post->ID)) { // echo "\t\n"; // }else{ // echo "\t\n"; // } // }else{ // echo "\t\n"; // } // do ogp type // if (is_singular('post')) { // echo "\t\n"; // }else{ // echo "\t\n"; // } // og Image Tag if (is_home()) { if (isset($options['wpfbogp_fallback_img']) && $options['wpfbogp_fallback_img'] != '') { echo "\t\n"; }else{ echo "\t\n"; } } else { if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) { $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' ); echo "\t\n"; }elseif (( shrsb_first_image() !== false ) && (is_singular())) { echo "\t\n"; }else{ echo "\t".''."\n"; } } echo "\n\n\n"; } } // end function add_action('wp_head','shrsb_add_ogtags_head',10); function shrsb_admin_styles() { global $shrsb_plugopts; if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false)) { wp_enqueue_style('ie-old-sexy-bookmarks', SHRSB_PLUGPATH.'css/ie7-admin-style.css', false, SHRSB_vNum); } wp_enqueue_style('sexy-bookmarks', SHRSB_PLUGPATH.'css/admin-style.css', false, SHRSB_vNum); } // Add the 'Settings' link to the plugin page, taken from yourls plugin by ozh function shrsb_admin_plugin_actions($links) { $links[] = ''.__('Settings', 'shrsb').''; return $links; } add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'shrsb_admin_plugin_actions', -10); require_once "includes/public.php"; ?>