configuration panel for more settings. This plugin is inspired from the SexyBookmarks plugin for Wordpress. This plugin is also compatible with Support Forum plugin.
Version: 1.1
Author: Gautam
Author URI: http://www.gaut.am/
Original Social It bbPress Plugin Copyright 2009 Gautam (email : admin@gaut.am) (website: http://gaut.am)
Original SexyBookmarks Plugin Copyright 2009 Eight7Teen (email : josh@eight7teen.com), Norman Yung (www.robotwithaheart.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
Main PHP File for
Social It plugin (for bbPress) by www.gaut.am
*/
define('SOCIALIT_OPTIONS','Social-It');
define('SOCIALIT_vNum','1.1');
define('SOCIALIT_PLUGPATH', bb_get_option('uri').trim(str_replace(array(trim(BBPATH,"/\\"),"\\"),array("","/"),dirname(__FILE__)),' /\\').'/'); //thanks ck for this
require_once('bookmarks-data.php');
//reload
$socialit_plugopts = bb_get_option(SOCIALIT_OPTIONS);
if(!$socialit_plugopts){
//add defaults to an array
$socialit_plugopts = array(
'reloption' => 'nofollow', // 'nofollow', or ''
'targetopt' => '_blank', // '_blank' or '_self'
'bgimg-yes' => 'yes', // 'yes' or blank
'bgimg' => 'caring', // 'sexy', 'caring', 'wealth'
'shorty' => 'trim',
'topic' => '1',
'bookmark' => array_keys($socialit_bookmarks_data),
'xtrastyle' => '',
'feed' => '0', // 1 or 0
'expand' => '1',
'autocenter' => '0',
'ybuzzcat' => 'science',
'ybuzzmed' => 'text',
'twittcat' => 'Internet',
'default_tags' => '',
'warn-choice' => '',
'sfpnonres' => 'yes',
'sfpres' => 'yes',
'sfpnonsup' => 'yes',
'shorturls' => array(),
);
bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
}
//curl, file get contents or nothing, used for short url and for updater
function socialit_nav_browse($url){
if (function_exists('curl_init')) {
// Use cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$source = curl_exec($ch);
curl_close($ch);
} elseif (function_exists('file_get_contents')) { // use file_get_contents()
$source = file_get_contents($url);
} else {
$source = null;
}
return $source;
}
//check for updates, as bbpress doesnt check itself :(
function socialit_update_check(){
$latest_ver = trim(socialit_nav_browse("http://gaut.am/uploads/plugins/updater.php?pid=1&chk=ver&soft=bb¤t=".SOCIALIT_vNum));
if($latest_ver){
if(SOCIALIT_vNum < $latest_ver){
return $latest_ver;
}else{
return false;
}
}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' );
}
}
function socialit_network_input_select($name, $hint) {
global $socialit_plugopts;
return sprintf('',
$name,
$hint,
@in_array($name, $socialit_plugopts['bookmark'])?'checked="checked" ':"",
$name,
$name
);
}
//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() {
echo '
Social It
';
global $socialit_plugopts, $socialit_bookmarks_data, $bbdb;
$donate_link = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6590760";
$twitter_link = "http://twitter.com/gautam_2011";
// 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 here.
'; //box cant be closed
}
if(isset($_POST['save_changes'])) {
$status_message = 'Your changes have been saved successfully! | Maybe you would consider donating or following me on Twitter?';
//was there an error?
if($_POST['bookmark'] == '') {
$error_message = 'You can\'t display the menu if you don\'t choose a few sites to add to it!';
}
elseif($_POST['twittcat'] == '' && in_array('socialit-twittley', $socialit_plugopts['bookmark'])) {
$error_message = 'You need to select the primary category for any articles submitted to Twittley.';
}
elseif($_POST['defaulttags'] == '' && in_array('socialit-twittley', $socialit_plugopts['bookmark'])) {
$error_message = 'You need to set at least 1 default tag for any articles submitted to Twittley.';
}
else {
$socialit_plugopts['topic'] = $_POST['topic'];
$socialit_plugopts['xtrastyle'] = $_POST['xtrastyle'];
$socialit_plugopts['reloption'] = $_POST['reloption'];
$socialit_plugopts['targetopt'] = $_POST['targetopt'];
$socialit_plugopts['bookmark'] = $_POST['bookmark'];
$socialit_plugopts['shorty'] = $_POST['shorty'];
$socialit_plugopts['twittid'] = $_POST['twittid'];
$socialit_plugopts['twittcat'] = $_POST['twittcat'];
$socialit_plugopts['defaulttags'] = $_POST['defaulttags'];
$socialit_plugopts['ybuzzcat'] = $_POST['ybuzzcat'];
$socialit_plugopts['ybuzzmed'] = $_POST['ybuzzmed'];
$socialit_plugopts['bgimg-yes'] = $_POST['bgimg-yes'];
$socialit_plugopts['bgimg'] = $_POST['bgimg'];
$socialit_plugopts['feed'] = $_POST['feed'];
$socialit_plugopts['expand'] = $_POST['expand'];
$socialit_plugopts['autocenter'] = $_POST['autocenter'];
$socialit_plugopts['sfpnonres'] = $_POST['sfpnonres'];
$socialit_plugopts['sfpres'] = $_POST['sfpres'];
$socialit_plugopts['sfpnonsup'] = $_POST['sfpnonsup'];
bb_update_option(SOCIALIT_OPTIONS, $socialit_plugopts);
}
if(in_array('socialit-yahoobuzz', $socialit_plugopts['bookmark'])) {
$ybuzz_default_class = "";
}
else {
$ybuzz_default_class = "hidden";
}
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.
';
}
}
//if there was an error,
if ($error_message != '') {
echo '
'.$error_message.'
';
} elseif ($status_message != '') {
echo '
'.$status_message.'
';
}
?>
Support by Donating
We've got big plans for Social It, but we can't implement any of them without the proper funding!
I'm sure you're aware that the development and continued support for this plugin is a non-payingjob, and as such, all donations or contributions are greatly appreciated! Top 5 donors will be listed on the plugin settings page (this page).
';
//echo $socials;
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() {
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'){
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
}
}
function socialit_insert_in_post($post_content) {
global $socialit_plugopts, $bbdb;
// decide whether or not to generate the bookmarks.
if ((bb_is_topic() && $socialit_plugopts['topic'] == 1) || (bb_is_feed() && $socialit_plugopts['feed'] == 1)){ //socials should be generated and added
$post_id_fc = get_post_id(); //post id for check
if(bb_is_first($post_id_fc)){
echo $post_content.get_socialit();
}else{
echo $post_content;
}
}else{
echo $post_content;
}
}
//add actions/filters
add_action('bb_admin_menu_generator', 'socialit_menu_link'); //link in settings
add_action('bb_admin_head', 'socialit_admin'); //admin css
add_action('bb_head', 'socialit_public'); //public css
add_filter('post_text', 'socialit_insert_in_post'); //to insert social it automatically below the first post of every topic
?>
Support by Donating
We've got big plans for Social It, but we can't implement any of them without the proper funding!
I'm sure you're aware that the development and continued support for this plugin is a non-paying job, and as such, all donations or contributions are greatly appreciated! Top 5 donors will be listed on the plugin settings page (this page).
Even if you do not want to donate, you can follow me on Twitter or check my website for latest updates.
Top Donors
None till now! Donate now to get to this list and your name with your website link will be here in the next release!
Plugin Inspiration
This plugin is inspired from SexyBookmarks plugin for Wordpress made by Josh & Norman. They have really worked hard on this.
Help
You can see the Plugin Information here, FAQ here, Usage & Installation How-To Guide here, and Ask for Help here.