Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active December 10, 2015 12:08
Show Gist options
  • Save hissy/4431991 to your computer and use it in GitHub Desktop.
Save hissy/4431991 to your computer and use it in GitHub Desktop.
make sharebar plugin compatible with 3.5
function sharebar($print = true){
global $wpdb, $post;
$sharebar_hide = get_post_meta($post->ID, 'sharebar_hide', true);
$sbg = get_option('sharebar_sbg');
$sborder = get_option('sharebar_sborder');
if(empty($sharebar_hide)) {
$credit = get_option('sharebar_credit');
$str = '<ul id="sharebar" style="background:#'.$sbg.';border-color:#'.$sborder.';">';
$results = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC"); $str .= "\n";
foreach($results as $result){ $str .= '<li>'.sharebar_filter($result->big).'</li>'; }
if($credit) $str .= '<li class="credit"><a href="http://devgrow.com/sharebar" target="_blank">Sharebar</a></li>';
$str .= '</ul>';
if($print) echo $str; else return $str;
}
}
function sharebar_horizontal($print = true){
if(get_option('sharebar_horizontal')){
global $wpdb;
$str = '<ul id="sharebarx">';
$results = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."sharebar WHERE enabled=1 ORDER BY position, id ASC"); $str .= "\n";
foreach($results as $result) { $str .= '<li>'.sharebar_filter($result->small).'</li>'; }
$str .= '</ul>';
if($print) echo $str; else return $str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment