function show_share_buttons($content, $booShortCode = FALSE, $atts = '') { // globals global $post; // variables $htmlContent = $content; $pattern = get_shortcode_regex(); // ssba_hide shortcode is in the post content and instance is not called by shortcode ssba if (isset($post->post_content) && preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array('ssba_hide', $matches[2]) && $booShortCode == FALSE) { // exit the function returning the content without the buttons return $content; } // get sbba settings $arrSettings = get_ssba_settings(); // placement on pages/posts/categories/archives/homepage if (!is_home() && !is_front_page() && is_page() && $arrSettings['ssba_pages'] == 'Y' || is_single() && $arrSettings['ssba_posts'] == 'Y' || is_category() && $arrSettings['ssba_cats_archs'] == 'Y' || is_archive() && $arrSettings['ssba_cats_archs'] == 'Y' || (is_home() || is_front_page()) && $arrSettings['ssba_homepage'] == 'Y' || $booShortCode == TRUE) { // if not shortcode if (isset($atts['widget']) && $atts['widget'] == 'Y') { // use widget share text $strShareText = $arrSettings['ssba_widget_text']; } else { // use normal share text $strShareText = $arrSettings['ssba_share_text']; } // post id $intPostID = get_the_ID(); // ssba div $htmlShareButtons = '<!-- Simple Share Buttons Adder (' . SSBA_VERSION . ') simplesharebuttons.com --><div class="ssba ssba-wrap">'; // center if set so $htmlShareButtons .= '<div style="text-align:' . $arrSettings['ssba_align'] . '">'; // add custom text if set and set to placement above or left if ($strShareText != '' && ($arrSettings['ssba_text_placement'] == 'above' || $arrSettings['ssba_text_placement'] == 'left')) { // check if user has left share link box checked if ($arrSettings['ssba_link_to_ssb'] == 'Y') { // share text with link $htmlShareButtons .= '<a href="https://simplesharebuttons.com" target="_blank">' . $strShareText . '</a>'; } else { // share text $htmlShareButtons .= $strShareText; } $arrSettings['ssba_text_placement'] == 'above' ? $htmlShareButtons .= '<br/>' : NULL; } // if running standard if ($booShortCode == FALSE) { // use wordpress functions for page/post details $urlCurrentPage = get_permalink($post->ID); $strPageTitle = get_the_title($post->ID); } else { // using shortcode // set page URL and title as set by user or get if needed $urlCurrentPage = isset($atts['url']) ? $atts['url'] : ssba_current_url($atts); $strPageTitle = isset($atts['title']) ? $atts['title'] : get_the_title(); } // strip any unwanted tags from the page title $strPageTitle = esc_attr(strip_tags($strPageTitle)); // the buttons! $htmlShareButtons .= get_share_buttons($arrSettings, $urlCurrentPage, $strPageTitle, $intPostID); // add custom text if set and set to placement right or below if ($strShareText != '' && ($arrSettings['ssba_text_placement'] == 'right' || $arrSettings['ssba_text_placement'] == 'below')) { $arrSettings['ssba_text_placement'] == 'below' ? $htmlShareButtons .= '<br/>' : NULL; // check if user has checked share link option if ($arrSettings['ssba_link_to_ssb'] == 'Y') { // share text with link $htmlShareButtons .= '<a href="https://simplesharebuttons.com" target="_blank">' . $strShareText . '</a>'; } else { // share text $htmlShareButtons .= $strShareText; } } // close center if set $htmlShareButtons .= '</div>'; $htmlShareButtons .= '</div>'; // if not using shortcode if ($booShortCode == FALSE) { // switch for placement of ssba switch ($arrSettings['ssba_before_or_after']) { case 'before': // before the content $htmlContent = $htmlShareButtons . $content; break; case 'after': // after the content $htmlContent = $content . $htmlShareButtons; break; case 'both': // before and after the content $htmlContent = $htmlShareButtons . $content . $htmlShareButtons; break; } } else { // just return buttons $htmlContent = $htmlShareButtons; } } // return content and share buttons return $htmlContent; }
function ssba_settings() { // check if user has the rights to manage options if (!current_user_can('manage_options')) { // permissions message wp_die(__('You do not have sufficient permissions to access this page.')); } // if a post has been made if (isset($_POST['ssbaData'])) { // get posted data $ssbaPost = $_POST['ssbaData']; parse_str($ssbaPost, $ssbaPost); // if the nonce doesn't check out... if (!isset($ssbaPost['ssba_save_nonce']) || !wp_verify_nonce($ssbaPost['ssba_save_nonce'], 'ssba_save_settings')) { die('There was no nonce provided, or the one provided did not verify.'); } // prepare array $arrOptions = array('ssba_image_set' => $ssbaPost['ssba_image_set'], 'ssba_size' => $ssbaPost['ssba_size'], 'ssba_pages' => isset($ssbaPost['ssba_pages']) ? $ssbaPost['ssba_pages'] : NULL, 'ssba_posts' => isset($ssbaPost['ssba_posts']) ? $ssbaPost['ssba_posts'] : NULL, 'ssba_cats_archs' => isset($ssbaPost['ssba_cats_archs']) ? $ssbaPost['ssba_cats_archs'] : NULL, 'ssba_homepage' => isset($ssbaPost['ssba_homepage']) ? $ssbaPost['ssba_homepage'] : NULL, 'ssba_excerpts' => isset($ssbaPost['ssba_excerpts']) ? $ssbaPost['ssba_excerpts'] : NULL, 'ssba_align' => isset($ssbaPost['ssba_align']) ? $ssbaPost['ssba_align'] : NULL, 'ssba_padding' => $ssbaPost['ssba_padding'], 'ssba_before_or_after' => $ssbaPost['ssba_before_or_after'], 'ssba_additional_css' => $ssbaPost['ssba_additional_css'], 'ssba_custom_styles' => $ssbaPost['ssba_custom_styles'], 'ssba_custom_styles_enabled' => $ssbaPost['ssba_custom_styles_enabled'], 'ssba_email_message' => stripslashes_deep($ssbaPost['ssba_email_message']), 'ssba_twitter_text' => stripslashes_deep($ssbaPost['ssba_twitter_text']), 'ssba_buffer_text' => stripslashes_deep($ssbaPost['ssba_buffer_text']), 'ssba_flattr_user_id' => stripslashes_deep($ssbaPost['ssba_flattr_user_id']), 'ssba_flattr_url' => stripslashes_deep($ssbaPost['ssba_flattr_url']), 'ssba_share_new_window' => isset($ssbaPost['ssba_share_new_window']) ? $ssbaPost['ssba_share_new_window'] : NULL, 'ssba_link_to_ssb' => isset($ssbaPost['ssba_link_to_ssb']) ? $ssbaPost['ssba_link_to_ssb'] : NULL, 'ssba_show_share_count' => isset($ssbaPost['ssba_show_share_count']) ? $ssbaPost['ssba_show_share_count'] : NULL, 'ssba_share_count_style' => $ssbaPost['ssba_share_count_style'], 'ssba_share_count_css' => $ssbaPost['ssba_share_count_css'], 'ssba_share_count_once' => isset($ssbaPost['ssba_share_count_once']) ? $ssbaPost['ssba_share_count_once'] : NULL, 'ssba_widget_text' => $ssbaPost['ssba_widget_text'], 'ssba_rel_nofollow' => isset($ssbaPost['ssba_rel_nofollow']) ? $ssbaPost['ssba_rel_nofollow'] : NULL, 'ssba_default_pinterest' => isset($ssbaPost['ssba_default_pinterest']) ? $ssbaPost['ssba_default_pinterest'] : NULL, 'ssba_pinterest_featured' => isset($ssbaPost['ssba_pinterest_featured']) ? $ssbaPost['ssba_pinterest_featured'] : NULL, 'ssba_content_priority' => isset($ssbaPost['ssba_content_priority']) ? $ssbaPost['ssba_content_priority'] : NULL, 'ssba_div_padding' => $ssbaPost['ssba_div_padding'], 'ssba_div_rounded_corners' => isset($ssbaPost['ssba_div_rounded_corners']) ? $ssbaPost['ssba_div_rounded_corners'] : NULL, 'ssba_border_width' => $ssbaPost['ssba_border_width'], 'ssba_div_border' => $ssbaPost['ssba_div_border'], 'ssba_div_background' => $ssbaPost['ssba_div_background'], 'ssba_share_text' => stripslashes_deep($ssbaPost['ssba_share_text']), 'ssba_text_placement' => $ssbaPost['ssba_text_placement'], 'ssba_font_family' => $ssbaPost['ssba_font_family'], 'ssba_font_color' => $ssbaPost['ssba_font_color'], 'ssba_font_size' => $ssbaPost['ssba_font_size'], 'ssba_font_weight' => $ssbaPost['ssba_font_weight'], 'ssba_selected_buttons' => $ssbaPost['ssba_selected_buttons']); // prepare array of buttons $arrButtons = json_decode(get_option('ssba_buttons'), true); // loop through each button foreach ($arrButtons as $button => $arrButton) { // add custom button to array of options $arrOptions['ssba_custom_' . $button] = $ssbaPost['ssba_custom_' . $button]; } // save the settings ssba_update_options($arrOptions); // return success return true; } // include then run the upgrade script include_once plugin_dir_path(SSBA_FILE) . '/inc/ssba_admin_panel.php'; // query the db for current ssba settings $arrSettings = get_ssba_settings(); // --------- ADMIN PANEL ------------ // ssba_admin_panel($arrSettings); }
/ __| '_ \ / _` | '__/ _ \ '_ \| | | | __| __/ _ \| '_ \/ __| \__ \ | | | (_| | | | __/ |_) | |_| | |_| || (_) | | | \__ \ |___/_| |_|\__,_|_| \___|_.__/ \__,_|\__|\__\___/|_| |_|___/ */ //====================================================================== // CONSTANTS //====================================================================== define('SSBA_FILE', __FILE__); define('SSBA_ROOT', dirname(__FILE__)); define('SSBA_VERSION', '6.3'); //====================================================================== // SSBA SETTINGS //====================================================================== // make sure we have settings ready // this has been introduced to exclude from excerpts $arrSettings = get_ssba_settings(); //====================================================================== // INCLUDES //====================================================================== include_once plugin_dir_path(__FILE__) . '/inc/ssba_admin_bits.php'; include_once plugin_dir_path(__FILE__) . '/inc/ssba_buttons.php'; include_once plugin_dir_path(__FILE__) . '/inc/ssba_styles.php'; include_once plugin_dir_path(__FILE__) . '/inc/ssba_widget.php'; include_once plugin_dir_path(__FILE__) . '/inc/ssba_database.php'; //====================================================================== // ACTIVATE/DEACTIVATE HOOKS //====================================================================== // run the activation function upon activation of the plugin register_activation_hook(__FILE__, 'ssba_activate'); // register deactivation hook register_uninstall_hook(__FILE__, 'ssba_uninstall');
function show_share_buttons($content, $booShortCode = FALSE, $atts = '') { // globals global $post; // variables $htmlContent = $content; $htmlShareButtons = ''; $strIsWhatFunction = ''; $pattern = get_shortcode_regex(); // ssba_hide shortcode is in the post content and instance is not called by shortcode ssba if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array('ssba_hide', $matches[2]) && $booShortCode == FALSE) { // exit the function returning the content without the buttons return $content; } // get sbba settings $arrSettings = get_ssba_settings(); // placement on pages/posts/categories/archives/homepage if (is_page() && $arrSettings['ssba_pages'] == 'Y' || is_single() && $arrSettings['ssba_posts'] == 'Y' || is_category() && $arrSettings['ssba_cats_archs'] == 'Y' || is_archive() && $arrSettings['ssba_cats_archs'] == 'Y' || is_home() && $arrSettings['ssba_homepage'] == 'Y' || $booShortCode == TRUE) { // ssba div $htmlShareButtons .= '<!-- I got these buttons from simplesharebuttons.com --><div id="ssba">'; // center if set so $htmlShareButtons .= $arrSettings['ssba_align'] == 'center' ? '<center>' : NULL; // add custom text if set and set to placement above or left if ($arrSettings['ssba_share_text'] != '' && ($arrSettings['ssba_text_placement'] == 'above' || $arrSettings['ssba_text_placement'] == 'left')) { // check if user has left share link box checked if ($arrSettings['ssba_link_to_ssb'] == 'Y') { // share text with link $htmlShareButtons .= '<a href="http://www.simplesharebuttons.com" target="_blank" class="ssba_tooptip" id="ssba_tooptip""><span>www.simplesharebuttons.com</span>' . $arrSettings['ssba_share_text']; } else { // share text $htmlShareButtons .= $arrSettings['ssba_share_text']; } $arrSettings['ssba_text_placement'] == 'above' ? $htmlShareButtons .= '<br/>' : NULL; } // if running standard if ($booShortCode == FALSE) { // use wordpress functions for page/post details $urlCurrentPage = get_permalink($post->ID); $strPageTitle = get_the_title($post->ID); } else { if ($booShortCode == TRUE) { // if using shortcode // if custom attributes have been set if ($atts['url'] != '') { // set page URL and title as set by user $urlCurrentPage = isset($atts['url']) ? $atts['url'] : ssba_current_url(); $strPageTitle = isset($atts['title']) ? $atts['title'] : NULL; } else { // get page name and url from functions $urlCurrentPage = ssba_current_url(); $strPageTitle = $_SERVER["SERVER_NAME"]; } } } // the buttons! $htmlShareButtons .= get_share_buttons($arrSettings, $urlCurrentPage, $strPageTitle); // add custom text if set and set to placement right or below if ($arrSettings['ssba_share_text'] != '' && ($arrSettings['ssba_text_placement'] == 'right' || $arrSettings['ssba_text_placement'] == 'below')) { $arrSettings['ssba_text_placement'] == 'below' ? $htmlShareButtons .= '<br/>' : NULL; // check if user has left share link box checked if ($arrSettings['ssba_link_to_ssb'] == 'Y') { // share text with link $htmlShareButtons .= '<a href="http://www.simplesharebuttons.com" target="_blank" class="ssba_tooptip" id="ssba_tooptip""><span>www.simplesharebuttons.com</span>' . $arrSettings['ssba_share_text']; } else { // share text $htmlShareButtons .= $arrSettings['ssba_share_text']; } } // close center if set $htmlShareButtons .= $arrSettings['ssba_align'] == 'center' ? '</center>' : NULL; $htmlShareButtons .= '</div>'; // if not using shortcode if ($booShortCode == FALSE) { // switch for placement of ssba switch ($arrSettings['ssba_before_or_after']) { case 'before': // before the content $htmlContent = $htmlShareButtons . $content; break; case 'after': // after the content $htmlContent = $content . $htmlShareButtons; break; case 'both': // before and after the content $htmlContent = $htmlShareButtons . $content . $htmlShareButtons; break; } } else { // just return buttons $htmlContent = $htmlShareButtons; } } // return content and share buttons return $htmlContent; }
function get_ssba_style() { // query the db for current ssba settings $arrSettings = get_ssba_settings(); // if the sharethis terms have been accepted if ($arrSettings['accepted_sharethis_terms'] == 'Y') { // if a facebook app id has been set if ($arrSettings['facebook_app_id'] != '') { $src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6&appID=' . $arrSettings['facebook_app_id']; } else { $src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6'; } // if an app id has been entered if ($arrSettings['facebook_app_id'] != '') { // init facebook echo "<script>window.fbAsyncInit = function() {\n FB.init({\n appId : '" . $arrSettings['facebook_app_id'] . "',\n xfbml : true,\n version : 'v2.6'\n });\n };</script>"; } // include facebook js sdk echo "<script>(function(d, s, id){\n var js, fjs = d.getElementsByTagName(s)[0];\n if (d.getElementById(id)) {return;}\n js = d.createElement(s); js.id = id;\n js.src = \"" . $src . "\";\n fjs.parentNode.insertBefore(js, fjs);\n }(document, 'script', 'facebook-jssdk'));</script>"; // if an app id has been entered if ($arrSettings['facebook_app_id'] != '') { // if facebook insights have been enabled if ($arrSettings['facebook_insights'] == 'Y') { // add facebook meta tag echo '<meta property="fb:app_id" content="' . $arrSettings['facebook_app_id'] . '" />'; } } } // 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) . ' } .fb_iframe_widget span { width: 146px !important; }'; // 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 custom styles $htmlSSBAStyle .= $arrSettings['ssba_custom_styles']; } // close style tag $htmlSSBAStyle .= '</style>'; // return echo $htmlSSBAStyle; }
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 custom styles $htmlSSBAStyle .= $arrSettings['ssba_custom_styles']; } // close style tag $htmlSSBAStyle .= '</style>'; // return echo $htmlSSBAStyle; }