<?php defined('ABSPATH') or die('No direct access permitted'); // call scripts add function add_action( 'wp_enqueue_scripts', 'ssba_page_scripts' ); // add css scripts for page/post use function ssba_page_scripts() { // ssba.min.js wp_enqueue_script('ssba', plugins_url('js/ssba.min.js', SSBA_FILE), array('jquery'), false, true); } // add CSS to the head add_action( 'wp_head', 'get_ssba_style' ); // generate style function get_ssba_style() { // query the db for current ssba settings $arrSettings = get_ssba_settings(); // css style $htmlSSBAStyle = '<style type="text/css">'; // check if custom styles haven't been set if ($arrSettings['ssba_custom_styles_enabled'] != 'Y') { // use set options $htmlSSBAStyle .= ' .ssba { ' . ($arrSettings['ssba_div_padding'] != '' ? 'padding: ' . $arrSettings['ssba_div_padding'] . 'px;' : NULL) . ' ' . ($arrSettings['ssba_border_width'] != '' ? 'border: ' . $arrSettings['ssba_border_width'] . 'px solid ' . $arrSettings['ssba_div_border'] . ';' : NULL) . ' ' . ($arrSettings['ssba_div_background'] != '' ? 'background-color: ' . $arrSettings['ssba_div_background'] . ';' : NULL) . ' ' . ($arrSettings['ssba_div_rounded_corners'] == 'Y' ? '-moz-border-radius: 10px; -webkit-border-radius: 10px; -khtml-border-radius: 10px; border-radius: 10px; -o-border-radius: 10px;' : NULL) . ' } .ssba img { width: ' . $arrSettings['ssba_size'] . 'px !important; padding: ' . $arrSettings['ssba_padding'] . 'px; border: 0; box-shadow: none !important; display: inline !important; vertical-align: middle; } .ssba, .ssba a { text-decoration:none; border:0; ' . ($arrSettings['ssba_div_background'] == '' ? 'background: none;' : NULL) . ' ' . ($arrSettings['ssba_font_family'] != '' ? 'font-family: ' . $arrSettings['ssba_font_family'] . ';' : NULL) . ' ' . ($arrSettings['ssba_font_size'] != '' ? 'font-size: ' . $arrSettings['ssba_font_size'] . 'px;' : NULL) . ' ' . ($arrSettings['ssba_font_color'] != '' ? 'color: ' . $arrSettings['ssba_font_color'] . '!important;' : NULL) . ' ' . ($arrSettings['ssba_font_weight'] != '' ? 'font-weight: ' . $arrSettings['ssba_font_weight'] . ';' : NULL) . ' }'; // if counters option is set to Y if ($arrSettings['ssba_show_share_count'] == 'Y') { // styles that apply to all counter css sets $htmlSSBAStyle .= '.ssba_sharecount:after, .ssba_sharecount:before { right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; } .ssba_sharecount:after { border-color: rgba(224, 221, 221, 0); border-right-color: #f5f5f5; border-width: 5px; top: 50%; margin-top: -5px; } .ssba_sharecount:before { border-color: rgba(85, 94, 88, 0); border-right-color: #e0dddd; border-width: 6px; top: 50%; margin-top: -6px; } .ssba_sharecount { font: 11px Arial, Helvetica, sans-serif; padding: 5px; -khtml-border-radius: 6px; -o-border-radius: 6px; -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; position: relative; border: 1px solid #e0dddd;'; // if default counter style has been chosen if ($arrSettings['ssba_share_count_style'] == 'default') { // style share count $htmlSSBAStyle .= 'color: #555e58; background: #f5f5f5; } .ssba_sharecount:after { border-right-color: #f5f5f5; }'; } elseif ($arrSettings['ssba_share_count_style'] == 'white') { // show white style share counts $htmlSSBAStyle .= 'color: #555e58; background: #ffffff; } .ssba_sharecount:after { border-right-color: #ffffff; }'; } elseif ($arrSettings['ssba_share_count_style'] == 'blue') { // show blue style share counts $htmlSSBAStyle .= 'color: #ffffff; background: #42a7e2; } .ssba_sharecount:after { border-right-color: #42a7e2; }'; } } // if there's any additional css if ($arrSettings['ssba_additional_css'] != '') { // add the additional CSS $htmlSSBAStyle .= $arrSettings['ssba_additional_css']; } } // else use set options else { // use custom styles $htmlSSBAStyle .= $arrSettings['ssba_custom_styles']; } // close style tag $htmlSSBAStyle .= '</style>'; // return echo $htmlSSBAStyle; }