Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Floating Social Icon
<?php
class qa_fsocialicon_admin {
function option_default($option) {
switch($option) {
case 'fsocialicon_css':
return '
<style>
#pageshare {position:fixed; bottom:15%; margin-left:-71px; float:left; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;background-color:#fff;padding:0 0 2px 0;z-index:10;}
#pageshare .sbutton {float:left;clear:both;margin:5px 5px 0 5px;}
.fb_share_count_top {width:48px !important;}
.fb_share_count_top, .fb_share_count_inner {-moz-border-radius:3px;-webkit-border-radius:3px;}
.FBConnectButton_Small, .FBConnectButton_RTL_Small {width:49px !important; -moz-border-radius:3px;/*bs-fsmsb*/-webkit-border-radius:3px;}
.FBConnectButton_Small .FBConnectButton_Text {padding:2px 2px 3px !important;-moz-border-radius:3px;-webkit-border-radius:3px;font-size:8px;}
</style>';
default:
return null;
}
}
function allow_template($template)
{
return ($template!='admin');
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('fsocialicon_reset')) {
foreach($_POST as $i => $v) {
$def = $this->option_default($i);
if($def !== null) qa_opt($i,$def);
}
$ok = qa_lang('admin/options_reset');
}
if (qa_clicked('fsocialicon_save')) {
qa_opt('fsocialicon',(bool)qa_post_text('fsocialicon'));
qa_opt('fsocialicon_css',qa_post_text('fsocialicon_css'));
$ok = qa_lang('admin/options_saved');
}
$fields[] = array(
'label' => 'Show Floating Icon',
'tags' => 'id="fsocialicon" name="fsocialicon"',
'value' => qa_opt('fsocialicon'),
'type' => 'checkbox'
);
$fields[] = array(
'label' => 'Floating Icon css',
'tags' => 'id="fsocialicon_css" name="fsocialicon_css"',
'value' => qa_opt('fsocialicon_css'),
'type' => 'textarea',
'rows' => 10
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang('admin/save_options_button'),
'tags' => 'NAME="fsocialicon_save"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="fsocialicon_reset"',
),
),
);
}
}
<?php
class qa_html_theme_layer extends qa_html_theme_base {
function head_custom() {
qa_html_theme_base::head_custom();
if(qa_opt('fsocialicon')) {
$this->output(qa_opt('fsocialicon_css'));
}
}
function a_fsocialicon($q_view)
{
if(qa_opt('fsocialicon') && isset($q_view['answers'])) {
$this->output('<div class="qa-ac-count">');
qa_html_theme_base::a_fsocialicon($q_view);
<div id='pageshare' title="Get this from Googlegenius.In">
<div class='sbutton' id='fb'><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>
<div class='sbutton' id='rt'><script src="http://tweetmeme.com/i/scripts/button.js" type='text/javascript'></script></div>
<div class='sbutton' id='su'><script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script></div>
<div class='sbutton' id='digg' style='margin-left:3px;width:48px'><script src='http://widgets.digg.com/buttons.js' type='text/javascript'></script><a class="DiggThisButton DiggMedium"></a></div>
<div class='sbutton' id='gplusone'><script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="tall"></g:plusone></div>
<div style="clear: both;font-size: 9px;text-align:center;">Get <a href="http://www.googlegenius.in/">widget</a></div>
<!-- Do not remove this link -->
</div>
$this->output('</div>');
}
else
qa_html_theme_base::a_fsocialicon($q_view);
}
}
<?php
/*
Plugin Name: Floating Social Icon
Plugin URI: https://googlegenius.in
Plugin Update Check URI: https://googlegenius.in
Plugin Description: Adds social sharing buttons to questions
Plugin Version: 1.0
Plugin Date: 2012-07-16
Plugin Author: Robin Sharaya
Plugin Author URI:
Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.3
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_layer('qa-fsocialicon-layer.php', 'Floating Social Icon Layer');
qa_register_plugin_module('module', 'qa-fsocialicon-admin.php', 'qa_fsocialicon_admin', 'Floating Social Icon Admin');
/*
Omit PHP closing tag to help avoid accidental output
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment