コード例 #1
0
function show_share_buttons($content)
{
    // globals
    global $post, $sssPO;
    // variables
    $htmlContent = $content;
    $htmlShareButtons = '';
    $arrSettings = $sssPO->sssp_options;
    // placement on posts
    if (is_single()) {
        //Enable only for Post page
        // post id
        $intPostID = get_the_ID();
        // if post type is download (EDD clashes)
        if (get_post_type($intPostID) == "download") {
            // check for and remove added text
            preg_match_all("/>(.*?)>/", $strPageTitle, $matches);
            $title = $matches[0][0];
            $title = ltrim($title, '>');
            $title = rtrim($title, '</span>');
            $strPageTitle = $title;
        }
        // ssba div
        $htmlShareButtons = '<!-- Start Simple Share microsolutionsbd.com --><div class="sssp-wrap">';
        if (!empty($arrSettings['sssp_title'])) {
            $htmlShareButtons .= '<h3>' . $arrSettings['sssp_title'] . '</h3>';
        }
        // left align by default
        $htmlShareButtons .= '<div class="share-links">';
        // use wordpress functions for page/post details
        $urlCurrentPage = get_permalink($post->ID);
        $strPageTitle = get_the_title($post->ID);
        // the buttons!
        $htmlShareButtons .= get_share_buttons($arrSettings, $urlCurrentPage, $strPageTitle, $intPostID);
        // close center if set
        $htmlShareButtons .= '</div>';
        $htmlShareButtons .= '</div>';
        // switch for placement of ssba
        switch ($arrSettings['sssp_position']) {
            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;
        }
    }
    // return content and share buttons
    return $htmlContent;
}
コード例 #2
0
ファイル: ssba_buttons.php プロジェクト: ardleo/kelasKayu
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;
}
コード例 #3
0
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;
}