', $name, $hint, @in_array($name, $socialit_plugopts['bookmark'])?'checked="checked" ':"", $name, $name ); } function socialit_change_plus_apos($content){ $content = str_replace('+','%20',$content); $content = str_replace("’","'",$content); return $content; } // returns the option tag for a form select element // $opts array expecting keys: field, value, text function socialit_form_select_option($opts) { global $socialit_plugopts; $opts = array_merge( array( 'field'=>'', 'value'=>'', 'text'=>'', ), $opts ); return sprintf('%s', ($socialit_plugopts[$opts['field']]==$opts['value'])?' selected="selected"':"", $opts['value'], $opts['text'] ); } // given an array $options of data and $field to feed into sexy_form_select_option function socialit_select_option_group($field, $options) { $h=''; foreach ($options as $value => $text) { $h .= socialit_form_select_option(array( 'field' => $field, 'value' => $value, 'text' => $text, )); } return $h; } //curl, file get contents or nothing, used for short url and for updater function socialit_nav_browse($url, $use_POST_method = false, $POST_data = null){ if (function_exists('curl_init')) { // Use cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); if($use_POST_method){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_data); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_TIMEOUT, 3); $source = trim(curl_exec($ch)); curl_close($ch); } elseif (function_exists('file_get_contents')) { // use file_get_contents() $source = trim(file_get_contents($url)); } else { $source = null; } return $source; } //check for updates, as bbpress doesnt check itself :( function socialit_update_check(){ $latest_ver = socialit_nav_browse("http://gaut.am/uploads/plugins/updater.php?pid=1&chk=ver&soft=bb¤t=".SOCIALIT_vNum); if($latest_ver && version_compare($latest_ver, SOCIALIT_vNum, '>')){ return $latest_ver; }else{ return false; } } //add sidebar link to settings page function socialit_menu_link() { if (function_exists('bb_admin_add_submenu')) { bb_admin_add_submenu( __( 'Social It' ), 'administrate', 'socialit_settings_page', 'options-general.php' ); } } //get current page rss link, code taken from functions.bb-template.php in bb-includes, posts' rss prefered instead of topics' function socialit_get_current_rss_link(){ switch (bb_get_location()) { case 'profile-page': if ( $tab = isset($_GET['tab']) ? $_GET['tab'] : bb_get_path(2) ) if ($tab != 'favorites') break; $feed = get_favorites_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); break; case 'topic-page': $feed = get_topic_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); break; case 'tag-page': if (bb_is_tag()) { $feed = bb_get_tag_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); } break; case 'forum-page': $feed = bb_get_forum_posts_rss_link(0, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); break; case 'front-page': $feed = bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); break; case 'view-page': global $bb_views, $view; if ($bb_views[$view]['feed']) { $feed = bb_get_view_rss_link(null, BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); } break; default: $feed = bb_get_posts_rss_link(BB_URI_CONTEXT_LINK_ALTERNATE_HREF + BB_URI_CONTEXT_BB_FEED); break; } return $feed; } //gets current URL, returns string, taken from Support Forum Plugin function socialit_get_current_url(){ $schema = 'http://'; if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { $schema = 'https://'; } if ($querystring = $_SERVER['QUERYSTRING']) { $querystring = ltrim($querystring, '?&'); $querystring = rtrim($querystring, '&'); if ($querystring) { $querystring = '?' . $querystring; } } $uri = $schema . $_SERVER['HTTP_HOST'] . rtrim($_SERVER['REQUEST_URI'], '?&') . $querystring; return $uri; } //write settings page function socialit_settings_page() { global $socialit_plugopts, $socialit_bookmarks_data, $bbdb; echo "\n\n".''."\n"; echo ''; //some links $donate_link = "http://gaut.am/donate/"; $twitter_link = "http://twitter.com/Gaut_am"; // processing form submission $status_message = ""; $error_message = ""; //check for updates if(socialit_update_check()){ //update available echo '
'. __( 'New version of Social It is available! Please download the latest version ', 'socialit' ) . '' . __( 'here', 'socialit' ) . '
'; //box cant (shouldnt) be closed } //import functionality if(isset($_POST['import'])) { if ( isset($_FILES['socialit_import_file']) && !empty($_FILES['socialit_import_file']['name']) ) { $socialit_imported_options = join('', file($_FILES['socialit_import_file']['tmp_name'])); $code = '$socialit_imported_options = '.$socialit_imported_options.';'; if(@eval('return true;'.$code)){ if ( eval($code) === null ) { if($_POST['export_short_urls'] != "on"){ unset($socialit_imported_options['shorturls']); } bb_update_option(SOCIALIT_OPTIONS, $socialit_imported_options); $status_message = __( 'Social It Options Imported Successfully!', 'socialit' ); }else{ $error_message = __( 'Social It Options Import failed!', 'socialit' ); } }else{ $error_message = __( 'Found syntax errors in file being imported. Social It Options Import failed!', 'socialit' ); } }else{ $error_message = __( 'Did not receive any file to be imported. Social It Options Import failed!', 'socialit' ); } } //changes have been saved if(isset($_POST['save_changes'])) { $status_message = __( 'Your changes have been saved successfully!', 'socialit' ); $errmsgmap = array( 'bookmark' => __('You can\'t display the menu if you don\'t choose a few sites to add to it!', 'socialit'), ); // adding to err msg map if twittley is enabled. if (in_array('socialit-twittley', $_POST['bookmark'])) { $errmsgmap['twittcat'] = __('You need to select the primary category for any articles submitted to Twittley.', 'socialit'); $errmsgmap['defaulttags'] = __('You need to set at least 1 default tag for any articles submitted to Twittley.', 'socialit'); } foreach ($errmsgmap as $field=>$msg) { if ($_POST[$field] == '') { $error_message = $msg; break; } } if (!$error_message) { foreach (array( 'topic', 'xtrastyle', 'reloption', 'targetopt', 'bookmark', 'twittid', 'ybuzzcat', 'ybuzzmed', 'twittcat', 'defaulttags', 'bgimg-yes', 'mobile-hide', 'bgimg', 'feed', 'expand', 'autocenter', 'sfpnonres', 'sfpres', 'sfpnonsup', 'shorty', ) as $field) $socialit_plugopts[$field] = $_POST[$field]; /* Short URLs */ $socialit_plugopts['shortyapi']['snip']['user'] = trim($_POST['shortyapiuser-snip']); $socialit_plugopts['shortyapi']['snip']['key'] = trim($_POST['shortyapikey-snip']); $socialit_plugopts['shortyapi']['bitly']['user'] = trim($_POST['shortyapiuser-bitly']); $socialit_plugopts['shortyapi']['bitly']['key'] = trim($_POST['shortyapikey-bitly']); $socialit_plugopts['shortyapi']['supr']['chk'] = $_POST['shortyapichk-supr']; $socialit_plugopts['shortyapi']['supr']['user'] = trim($_POST['shortyapiuser-supr']); $socialit_plugopts['shortyapi']['supr']['key'] = trim($_POST['shortyapikey-supr']); $socialit_plugopts['shortyapi']['trim']['chk'] = $_POST['shortyapichk-trim']; $socialit_plugopts['shortyapi']['trim']['user'] = trim($_POST['shortyapiuser-trim']); $socialit_plugopts['shortyapi']['trim']['pass'] = trim($_POST['shortyapipass-trim']); $socialit_plugopts['shortyapi']['tinyarrow']['chk'] = $_POST['shortyapichk-tinyarrow']; $socialit_plugopts['shortyapi']['tinyarrow']['user'] = trim($_POST['shortyapiuser-tinyarrow']); $socialit_plugopts['shortyapi']['cligs']['chk'] = $_POST['shortyapichk-cligs']; $socialit_plugopts['shortyapi']['cligs']['key'] = trim($_POST['shortyapikey-cligs']); /* Short URLs End */ bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts); //update options } if ($_POST['clearShortUrls']) { $count = count($socialit_plugopts['shorturls']); $socialit_plugopts['shorturls'] = array(); bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts); echo '
'.$count. __(' Short URL(s) have been reset.', 'socialit') . '
'; } } //if there was an error, if ($error_message != '') { echo '
'.$error_message.'
X
'; } elseif ($status_message != '') { echo '
'.$status_message.' | '. __( 'Maybe you would consider', 'socialit' ) .' '. __( 'donating', 'socialit' ) .' ' . __( 'or following me on', 'socialit' ) . ' Twitter?
X
'; } ?>
  • ALL short URLs. - Are you sure?', 'socialit'); ?>
     

    class="hidden">
    class="hidden"> name="shortyapichk-trim" id="shortyapichk-trim" type="checkbox" value="1" /> Track Generated Links?
    class="hidden">
    class="hidden">
    class="hidden"> name="shortyapichk-tinyarrow" id="shortyapichk-tinyarrow" type="checkbox" value="1" /> Track Generated Links?
    class="hidden">
    class="hidden"> name="shortyapichk-cligs" id="shortyapichk-cligs" type="checkbox" value="1" /> Track Generated Links?
    class="hidden">
    class="hidden"> name="shortyapichk-supr" id="shortyapichk-supr" type="checkbox" value="1" /> Track Generated Links?
    class="hidden">

    <?php _e('Click here for help with this option', 'socialit'); ?>


  • name="bgimg-yes" id="bgimg-yes" type="checkbox" value="yes" />
    class="hidden">

  • <?php if(function_exists('selfserv_socialit')) { selfserv_socialit(); } ?>

    isActive()){ ?>

    : <?php _e('Click here for help with this option', 'socialit'); ?>




:

  • ( )

Top Donors

$value) { $url=str_replace(strtoupper($key), $value, $url); } return sprintf( '
  • %s
  • ', $name, $url, $socialit_plugopts['reloption'], $socialit_plugopts['targetopt']=="_blank"?' class="external"':'', $socialit_bookmarks_data[$name]['share'], $socialit_bookmarks_data[$name]['share'] ); } //shows an option to the topic creator/mod+ whether to hide the social bookmarking menu on the particular topic or not function socialit_hide_show($parts){ $topic = get_topic(get_topic_id()); if($topic && bb_current_user_can('delete_topic', $topic->topic_id)){ if(bb_get_topicmeta($topic->topic_id, 'hide_socialit') == 'true'){ $display = esc_html( __('Show Social It Menu', 'socialit') ); $uri = socialit_get_current_url()."?socialit_hide_show=1&shs_opt=1&tid=".$topic->topic_id; } else { $display = esc_html( __('Hide Social It Menu', 'socialit') ); $uri = socialit_get_current_url()."?socialit_hide_show=1&shs_opt=2&tid=".$topic->topic_id; } $uri = esc_url(bb_nonce_url($uri, 'socialit_hide_show_'.$topic->topic_id)); $parts[] = '[' . $display . ']'; return $parts; } return $parts; } //does appropiate action for the above function function socialit_hide_show_do(){ if(bb_is_topic() && $_GET['socialit_hide_show'] == "1" && isset($_GET['shs_opt']) && isset($_GET['tid']) && bb_current_user_can('moderate')){ $topic = get_topic($_GET['tid']); if(bb_verify_nonce($_GET['_wpnonce'], 'socialit_hide_show_'.$topic->topic_id)){ if($_GET['shs_opt'] == "2"){ bb_update_topicmeta($topic->topic_id, 'hide_socialit', 'true'); }else{ bb_delete_topicmeta($topic->topic_id, 'hide_socialit'); } }else{ _e('Sorry, but that could not be done.', 'socialit'); exit; } wp_redirect(get_topic_link($topic->topic_id)); } } function get_socialit() { global $socialit_plugopts, $bbdb, $public_tags, $socialit_is_mobile, $socialit_is_bot; $dont_get_si = false; $topic = get_topic(get_topic_id()); if((class_exists('Support_Forum')) && ($topic)){ //compatibility with Support Forum plugin for bbPress $support_forum = new Support_Forum(); if($support_forum->isActive() && in_array($topic->forum_id, $support_forum->enabled)){ if(($socialit_plugopts['sfpnonres'] == "no" && $support_forum->getTopicStatus() == "no") || ($socialit_plugopts['sfpres'] == "no" && $support_forum->getTopicStatus() == "yes") || ($socialit_plugopts['sfpnonsup'] == "no" && $support_forum->getTopicStatus() == "mu")){ $dont_get_si = true; } } } if($socialit_plugopts['mobile-hide']=='yes' && ($socialit_is_mobile || $socialit_is_bot)) { $dont_get_si = true; } if(bb_is_topic() && bb_get_topicmeta($topic->topic_id, 'hide_socialit') == true){ $dont_get_si = true; } if(!$dont_get_si){ if(bb_is_topic()){ $perms = urlencode(get_topic_link()); $title = get_topic_title(); $feedperms = strtolower($perms); // Grab post tags for Twittley tags. If there aren't any, use default tags set in plugin options page $get_tags = bb_get_topic_tags(get_topic_id()); if ($get_tags){ foreach($get_tags as $tag) { $keywords = $keywords.$tag->name.','; } } $topic_id_ft = get_topic_id(); //topic id for getting text $first_post = (int) $bbdb->get_var("SELECT post_id FROM $bbdb->posts WHERE topic_id = $topic_id_ft ORDER BY post_id ASC LIMIT 1"); $socialit_content = get_post_text($first_post); }else{ $perms = socialit_get_current_url(); $title = bb_get_title(); $feedperms = strtolower($perms); $socialit_content = bb_get_option('description'); } if (strlen($title) >= 80) { $short_title = urlencode(substr($title, 0, 80)."[..]"); }else{ $short_title = urlencode($title); } $title = urlencode($title); $site_name = bb_get_option('name'); $socialit_content = urlencode(substr(strip_tags(strip_shortcodes($socialit_content)),0,300)); $socialit_content = socialit_change_plus_apos($socialit_content); $mail_subject = socialit_change_plus_apos($title); $post_summary = stripslashes($socialit_content); if (!empty($keywords)) { $d_tags = $keywords; }else { $d_tags = $socialit_plugopts['defaulttags']; } $site_name = bb_get_option('name'); $y_cat = $socialit_plugopts['ybuzzcat']; $y_med = $socialit_plugopts['ybuzzmed']; $t_cat = $socialit_plugopts['twittcat']; $current_rss_link = socialit_get_current_rss_link(); // Temporary fix for bug that breaks layout when using NextGen Gallery plugin if( (strpos($post_summary, '[') || strpos($post_summary, ']')) ) { $post_summary = ""; } if( (strpos($socialit_content, '[') || strpos($socialit_content,']')) ) { $socialit_content = ""; } // select the background if(!isset($socialit_plugopts['bgimg-yes'])) { $bgchosen = ''; } elseif($socialit_plugopts['bgimg'] == 'sexy') { $bgchosen = ' social-it-bg-sexy'; } elseif($socialit_plugopts['bgimg'] == 'caring') { $bgchosen = ' social-it-bg-caring'; } elseif($socialit_plugopts['bgimg'] == 'care-old') { $bgchosen = ' social-it-bg-caring-old'; } elseif($socialit_plugopts['bgimg'] == 'love') { $bgchosen = ' social-it-bg-love'; } elseif($socialit_plugopts['bgimg'] == 'wealth') { $bgchosen = ' social-it-bg-wealth'; } elseif($socialit_plugopts['bgimg'] == 'enjoy') { $bgchosen = ' social-it-bg-enjoy'; } $style=($socialit_plugopts['autocenter'])?'':' style="'.__($socialit_plugopts['xtrastyle']).'"'; $isfeed = bb_is_feed(); if ($isfeed) $style=''; // do not add inline styles to the feed. $expand = $socialit_plugopts['expand']?' social-it-expand':''; if ($socialit_plugopts['autocenter'] == 1) { $autocenter=' social-it-center'; } elseif ($socialit_plugopts['autocenter'] == 2) { $autocenter=' social-it-spaced'; } else { $autocenter=''; } //write the menu $socials = "\n\n".''."\n".'
    '."\n\n"; return $socials; } } // This function is what allows people to insert the menu wherever they please rather than above/below a post... function selfserv_socialit() { echo get_socialit(); } //write the code function socialit_public() { if(bb_get_topicmeta(get_topic_id(), 'hide_socialit') == true) { echo "\n\n".''."\n\n"; }else{ global $socialit_plugopts; echo "\n\n".''."\n"; wp_register_style('social-it', SOCIALIT_PLUGPATH.'css/style.css', false, SOCIALIT_vNum, 'all'); wp_print_styles('social-it'); if ($socialit_plugopts['expand'] || $socialit_plugopts['autocenter'] || $socialit_plugopts['targetopt']=='_blank') { wp_register_script('social-it-public-js', SOCIALIT_PLUGPATH."js/social-it-public.js", array('jquery'), SOCIALIT_vNum); wp_print_scripts('social-it-public-js'); } echo ''."\n\n"; } } //styles for admin area function socialit_admin() { if($_GET['plugin'] == 'socialit_settings_page'){ echo "\n\n".''."\n"; wp_register_style('social-it', SOCIALIT_PLUGPATH.'css/admin-style.css', false, SOCIALIT_vNum, 'all'); wp_print_styles('social-it'); if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false)){ //ie, as usual, doesnt render the css properly :| and creates problems for the developers wp_register_style('ie-social-it', SOCIALIT_PLUGPATH.'css/ie7-admin-style.css', false, SOCIALIT_vNum, 'all'); wp_print_styles('ie-social-it'); } echo ''; //loads newer version of jquery. bbpress uses old version echo ''; //ui core & sortable script not included in bbpress :-( echo ''; echo ''; //social-it admin js script echo ''."\n\n"; } } function socialit_insert_in_post($post_content) { global $socialit_plugopts, $bbdb; // decide whether or not to generate the bookmarks. $istopic = bb_is_topic(); if (($istopic && $socialit_plugopts['topic'] == 1) || (bb_is_feed() && $socialit_plugopts['feed'] == 1) && (bb_get_topicmeta(get_topic_id(), 'hide_socialit') != "true")){ //socials should be generated and added $post_id_fc = get_post_id(); //post id for check if(bb_is_first($post_id_fc)){ $post_content .= get_socialit(); } } return $post_content; } ?>