コード例 #1
0
/** 
 * Shortcode for Social Counter.
 */
function the_champ_counter_shortcode($params)
{
    // notify if counter is disabled
    if (the_champ_social_counter_enabled()) {
        extract(shortcode_atts(array('style' => '', 'type' => 'horizontal', 'left' => '0', 'right' => '0', 'top' => '100', 'url' => '', 'align' => 'left', 'title' => ''), $params));
        if ($type == 'horizontal' && !the_champ_horizontal_counter_enabled() || $type == 'vertical' && !the_champ_vertical_counter_enabled()) {
            return;
        }
        global $post;
        if ($url) {
            $targetUrl = $url;
            $postId = 0;
        } elseif (get_permalink($post->ID)) {
            $targetUrl = get_permalink($post->ID);
            $postId = $post->ID;
        } else {
            $targetUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
            $postId = 0;
        }
        $alignmentOffset = 0;
        if ($left) {
            $alignmentOffset = $left;
        } elseif ($right) {
            $alignmentOffset = $right;
        }
        global $theChampCounterOptions;
        $html = '<div class="the_champ_counter_container the_champ_' . $type . '_counter' . ($type == 'vertical' && isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . '" ss-offset="' . $alignmentOffset . '" ';
        $verticalOffsets = '';
        if ($type == 'vertical') {
            $verticalOffsets = $align . ': ' . ${$align} . 'px; top: ' . $top . 'px;';
        }
        // style
        if ($style != "" || $verticalOffsets != '') {
            $html .= 'style="';
            if (strpos($style, 'background') === false) {
                $html .= '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;';
            }
            $html .= $verticalOffsets;
            $html .= $style;
            $html .= '"';
        }
        $html .= '>';
        if ($type == 'horizontal' && $title != '') {
            $html .= '<div style="font-weight:bold">' . ucfirst($title) . '</div>';
        }
        $counterUrl = $targetUrl;
        if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
            $counterUrl = wp_get_shortlink();
            // if bit.ly integration enabled, generate bit.ly short url
        } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
            $shortUrl = the_champ_generate_counter_bitly_url($targetUrl, $postId);
            if ($shortUrl) {
                $counterUrl = $shortUrl;
            }
        }
        $html .= the_champ_prepare_counter_html($targetUrl, $type, $counterUrl);
        $html .= '</div>';
        return $html;
    }
}
コード例 #2
0
ファイル: shortcode.php プロジェクト: eq0rip/Hamroreview.com
/** 
 * Shortcode for Social Counter.
 */
function the_champ_counter_shortcode($params)
{
    // notify if counter is disabled
    if (the_champ_social_counter_enabled()) {
        extract(shortcode_atts(array('style' => '', 'type' => 'horizontal', 'left' => '0', 'top' => '100', 'url' => ''), $params));
        if ($type == 'horizontal' && !the_champ_horizontal_counter_enabled() || $type == 'vertical' && !the_champ_vertical_counter_enabled()) {
            return;
        }
        global $post;
        $targetUrl = $url ? $url : get_permalink($post->ID);
        $html = '<div class="the_champ_counter_container the_champ_' . $type . '_counter" ';
        $verticalOffsets = '';
        if ($type == 'vertical') {
            $verticalOffsets = 'left: ' . $left . 'px; top: ' . $top . 'px;';
        }
        // style
        if ($style != "" || $verticalOffsets != '') {
            $html .= 'style="';
            if (strpos($style, 'background') === false) {
                $html .= 'box-shadow: none;';
            }
            $html .= $verticalOffsets;
            $html .= $style;
            $html .= '"';
        }
        $html .= '>';
        global $theChampCounterOptions;
        $counterUrl = $targetUrl;
        // if bit.ly integration enabled, generate bit.ly short url
        if (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
            $shortUrl = the_champ_generate_counter_bitly_url($targetUrl);
            if ($shortUrl) {
                $counterUrl = $shortUrl;
            }
        }
        $html .= the_champ_prepare_counter_html($targetUrl, $type, $counterUrl);
        $html .= '</div>';
        return $html;
    }
}
コード例 #3
0
ファイル: helper.php プロジェクト: vanlong200880/uni
/**
 * Check if Facebook Like/Recommend is enabled
 */
function the_champ_facebook_like_rec_enabled()
{
    global $theChampCounterOptions;
    if (the_champ_social_counter_enabled() && (the_champ_horizontal_counter_enabled() && isset($theChampCounterOptions['horizontal_providers']) && (in_array('facebook_like', $theChampCounterOptions['horizontal_providers']) || in_array('facebook_recommend', $theChampCounterOptions['horizontal_providers'])) || the_champ_vertical_counter_enabled() && isset($theChampCounterOptions['vertical_providers']) && (in_array('facebook_like', $theChampCounterOptions['vertical_providers']) || in_array('facebook_recommend', $theChampCounterOptions['vertical_providers'])))) {
        return true;
    }
    return false;
}
コード例 #4
0
ファイル: widget.php プロジェクト: eq0rip/Hamroreview.com
 /** This is rendered widget content */
 function widget($args, $instance)
 {
     // return if counter is disabled
     if (!the_champ_social_counter_enabled() || !the_champ_vertical_counter_enabled()) {
         return;
     }
     extract($args);
     if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) {
         return;
     }
     global $theChampCounterOptions, $post;
     if (isset($instance['target_url'])) {
         if ($instance['target_url'] == 'default') {
             $counterUrl = is_home() ? site_url() : get_permalink($post->ID);
         } elseif ($instance['target_url'] == 'homepage') {
             $counterUrl = site_url();
         } elseif ($instance['target_url'] == 'custom') {
             $counterUrl = isset($instance['target_url_custom']) ? trim($instance['target_url_custom']) : get_permalink($post->ID);
         }
     } else {
         $counterUrl = get_permalink($post->ID);
     }
     echo "<div class='the_champ_counter_container the_champ_vertical_counter' style='" . (isset($instance['alignment']) && $instance['alignment'] != '' && isset($instance[$instance['alignment'] . '_offset']) ? $instance['alignment'] . ': ' . ($instance[$instance['alignment'] . '_offset'] == '' ? 0 : $instance[$instance['alignment'] . '_offset']) . 'px;' : '') . (isset($instance['top_offset']) ? 'top: ' . ($instance['top_offset'] == '' ? 0 : $instance['top_offset']) . 'px;' : '') . (isset($instance['vertical_bg']) && $instance['vertical_bg'] != '' ? 'background-color: ' . $instance['vertical_bg'] . ';' : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "' >";
     // if bit.ly integration enabled, generate bit.ly short url
     $shortUrl = $counterUrl;
     if (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
         $tempShortUrl = the_champ_generate_counter_bitly_url($counterUrl);
         if ($tempShortUrl) {
             $shortUrl = $tempShortUrl;
         }
     }
     //echo $before_widget;
     echo the_champ_prepare_counter_html($counterUrl, 'vertical', $shortUrl);
     echo "</div>";
     //echo $after_widget;
 }
コード例 #5
0
ファイル: widget.php プロジェクト: supahseppe/path-of-gaming
 /** This is rendered widget content */
 public function widget($args, $instance)
 {
     // return if counter is disabled
     if (!the_champ_social_counter_enabled() || !the_champ_vertical_counter_enabled()) {
         return;
     }
     extract($args);
     if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) {
         return;
     }
     global $theChampCounterOptions, $post;
     $postId = $post->ID;
     if (isset($instance['target_url'])) {
         if ($instance['target_url'] == 'default') {
             if (is_home()) {
                 $counterUrl = site_url();
                 $postId = 0;
             } elseif (get_permalink($post->ID)) {
                 $counterUrl = get_permalink($post->ID);
             } else {
                 $counterUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
             }
         } elseif ($instance['target_url'] == 'homepage') {
             $counterUrl = site_url();
             $postId = 0;
         } elseif ($instance['target_url'] == 'custom') {
             $counterUrl = isset($instance['target_url_custom']) ? trim($instance['target_url_custom']) : get_permalink($post->ID);
             $postId = 0;
         }
     } else {
         $counterUrl = get_permalink($post->ID);
     }
     $ssOffset = 0;
     if (isset($instance['alignment']) && isset($instance[$instance['alignment'] . '_offset'])) {
         $ssOffset = $instance[$instance['alignment'] . '_offset'];
     }
     echo "<div class='the_champ_counter_container the_champ_vertical_counter" . (isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . "' ss-offset='" . $ssOffset . "' style='" . (isset($instance['alignment']) && $instance['alignment'] != '' && isset($instance[$instance['alignment'] . '_offset']) ? $instance['alignment'] . ': ' . ($instance[$instance['alignment'] . '_offset'] == '' ? 0 : $instance[$instance['alignment'] . '_offset']) . 'px;' : '') . (isset($instance['top_offset']) ? 'top: ' . ($instance['top_offset'] == '' ? 0 : $instance['top_offset']) . 'px;' : '') . (isset($instance['vertical_bg']) && $instance['vertical_bg'] != '' ? 'background-color: ' . $instance['vertical_bg'] . ';' : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "' >";
     // if bit.ly integration enabled, generate bit.ly short url
     $shortUrl = $counterUrl;
     if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
         $shortUrl = wp_get_shortlink();
         // if bit.ly integration enabled, generate bit.ly short url
     } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
         $tempShortUrl = the_champ_generate_counter_bitly_url($counterUrl, $postId);
         if ($tempShortUrl) {
             $shortUrl = $tempShortUrl;
         }
     }
     //echo $before_widget;
     echo the_champ_prepare_counter_html($counterUrl, 'vertical', $shortUrl);
     echo "</div>";
     //echo $after_widget;
 }