示例#1
0
 /**
  * This function will be used to insert content where shortcode is used.
  * Shortcode [Social9_Share]
  * Shortcode [Oss_Share]
  * 
  * @global type $post
  * @global type $oss_share_settings
  * @param type $params
  * @return type
  */
 public static function sharing_shortcode($params)
 {
     global $post, $oss_share_settings;
     if (is_object($post)) {
         $ossMeta = get_post_meta($post->ID, '_oss_meta', true);
         // if sharing disabled on this page/post, return content unaltered.
         if (isset($ossMeta['sharing']) && $ossMeta['sharing'] == 1 && !is_front_page()) {
             return;
         }
     }
     // Default parameters for shortcode.
     $default = array('style' => '', 'type' => 'horizontal');
     // Extracting parameters.
     extract(shortcode_atts($default, $params));
     if ($style != '') {
         $style = 'style="' . $style . '"';
     }
     if ($type == 'vertical' && $oss_share_settings['vertical_enable'] == '1') {
         $styleVerticalLayout = '';
         $position = isset($params['position']) ? $params['position'] : 'top_left';
         if ($position == 'top_left') {
             $styleVerticalLayout = 'style=top:10px;position:fixed!important;left:0px';
         } else {
             if ($position == 'top_right') {
                 $styleVerticalLayout = 'style=top:10px;position:fixed!important;right:0px';
             } else {
                 if ($position == 'bottom_left') {
                     $styleVerticalLayout = 'style=bottom:0px;position:fixed!important;left:0px';
                 } else {
                     if ($position == 'bottom_right') {
                         $styleVerticalLayout = 'style=bottom:0px;position:fixed!important;right:0px';
                     } else {
                         if ($position == 'middle_right') {
                             $styleVerticalLayout = 'style=position:fixed!important;right:0px;top:200px;';
                         } else {
                             if ($position == 'middle_left') {
                                 $styleVerticalLayout = 'style=position:fixed!important;left:0px;top:200px;';
                             }
                         }
                     }
                 }
             }
         }
         OSS_Common_Sharing::vertical_sharing();
         $unique_id = uniqid();
         OSS_Vertical_Sharing::$position['class'][] = $unique_id;
         $share = OSS_Vertical_Sharing::get_vertical_sharing('oss_ver_share_shortcode ' . $unique_id, $styleVerticalLayout);
     }
     if ($type == 'horizontal' && $oss_share_settings['horizontal_enable'] == '1') {
         OSS_Common_Sharing::horizontal_sharing();
         $share = '<div class="oss_title_replace oss_horizontal_share" ' . $style . ' data-share-titles="' . get_the_title($post->ID) . '" data-share-description="' . substr(wp_strip_all_tags($post->post_content), '0', 100) . '" data-share-imageurl="' . wp_get_attachment_url(get_post_thumbnail_id()) . '" data-share-url="' . get_permalink($post->ID) . '"></div>';
     }
     return isset($share) ? $share : '';
 }
 /**
  * Outputs the content of the widget
  *
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     global $post;
     if (is_object($post)) {
         $ossMeta = get_post_meta($post->ID, '_oss_meta', true);
         // If sharing disabled on this page/post, return content unaltered.
         if (isset($ossMeta['sharing']) && $ossMeta['sharing'] == 1 && !is_front_page()) {
             return;
         }
     }
     extract($args);
     if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) {
         return;
     }
     $unique_id = uniqid();
     OSS_Vertical_Sharing::$position['class'][] = $unique_id;
     OSS_Common_Sharing::vertical_sharing();
     echo OSS_Vertical_Sharing::get_vertical_sharing('oss_ver_share_widget ' . $unique_id, '');
 }
示例#3
0
        /**
         * Get OpenSocialShare Vertical Simple Social Sharing div and script.
         * 
         * @global type $post
         * @global type $oss_share_settings
         * @global type $oss_api_settings
         * @return type
         */
        public static function get_vertical_sharing_script()
        {
            global $post, $oss_share_settings, $oss_api_settings;
            if (is_object($post)) {
                $ossMeta = get_post_meta($post->ID, '_oss_meta', true);
                // If sharing disabled on this page/post, return content unaltered.
                if (isset($ossMeta['sharing']) && $ossMeta['sharing'] == '1' && !is_front_page()) {
                    return;
                }
            }
            $is_mobile = self::mobile_detect();
            if ($is_mobile && isset($oss_share_settings['mobile_enable']) && $oss_share_settings['mobile_enable'] == '1') {
                return;
            }
            $position = OSS_Vertical_Sharing::get_vertical_position();
            if (isset(OSS_Vertical_Sharing::$position['class'])) {
                foreach (OSS_Vertical_Sharing::$position['class'] as $key => $value) {
                    $position[$value]['class'] = $value;
                }
            }
            if (isset($position)) {
                foreach ($position as $key => $value) {
                    if ($value) {
                        switch ($key) {
                            case 'top_left':
                                $params = array('top' => '0px', 'right' => '', 'bottom' => '', 'left' => '0px');
                                $class = OSS_Vertical_Sharing::$params['top_left']['class'];
                                break;
                            case 'top_right':
                                $params = array('top' => '', 'right' => '0px', 'bottom' => '', 'left' => '');
                                $class = OSS_Vertical_Sharing::$params['top_right']['class'];
                                break;
                            case 'middle_right':
                                $params = array('top' => '', 'right' => '0px', 'bottom' => '', 'left' => '');
                                $class = OSS_Vertical_Sharing::$params['middle_right']['class'];
                                break;
                            case 'middle_left':
                                $params = array('top' => '', 'right' => '0px', 'bottom' => '', 'left' => '');
                                $class = OSS_Vertical_Sharing::$params['middle_left']['class'];
                                break;
                            case 'bottom_left':
                                $params = array('top' => '', 'right' => '', 'bottom' => '0px', 'left' => '0px');
                                $class = OSS_Vertical_Sharing::$params['bottom_left']['class'];
                                break;
                            case 'bottom_right':
                                $params = array('top' => '', 'right' => '0px', 'bottom' => '0px', 'left' => '');
                                $class = OSS_Vertical_Sharing::$params['bottom_right']['class'];
                                break;
                            default:
                                $params = array('top' => '', 'right' => '', 'bottom' => '', 'left' => '');
                                $class = $position[$key]['class'];
                                break;
                        }
                        if (isset($params)) {
                            $top = $params['top'] ? $params['top'] : '';
                            $right = $params['right'];
                            $bottom = $params['bottom'];
                            $left = $params['left'];
                            $hybrid = false;
                            $theme = $oss_share_settings['vertical_share_interface'];
                            switch ($theme) {
                                case '32-v':
                                    $size = '32';
                                    $widgetTheme = '0';
                                    $countertype = '0';
                                    break;
                                case '16-v':
                                    $size = '16';
                                    $widgetTheme = '0';
                                    $countertype = '0';
                                    break;
                                case 'hybrid-v-h':
                                    $hybrid = true;
                                    $size = '32';
                                    $countertype = "1";
                                    $widgetTheme = '1';
                                    break;
                                case 'hybrid-v-v':
                                    $hybrid = true;
                                    $size = '32';
                                    $countertype = "0";
                                    $widgetTheme = '1';
                                    break;
                                default:
                                    $size = '32';
                                    $top = 'top';
                                    $left = 'left';
                                    break;
                            }
                            $verticalShare = '';
                            if (isset($oss_share_settings['emailMessage']) && $oss_share_settings['emailMessage'] != '') {
                                $verticalShare .= 'emailMessage:"' . $oss_share_settings['emailMessage'] . '",';
                            }
                            if (isset($oss_share_settings['emailSubject']) && $oss_share_settings['emailSubject'] != '') {
                                $verticalShare .= 'emailSubject:"' . $oss_share_settings['emailSubject'] . '",';
                            }
                            if ($oss_share_settings['emailcontent'] != '') {
                                $verticalShare .= 'isEmailContentReadOnly:' . $oss_share_settings['emailcontent'] . ',';
                            }
                            if ($oss_share_settings['mobile_enable'] != '') {
                                $verticalShare .= 'isMobileFriendly:' . $oss_share_settings['mobile_enable'] . ',';
                            }
                            if ($oss_share_settings['isTotalShare'] != '') {
                                $verticalShare .= 'isTotalShare:' . $oss_share_settings['isTotalShare'] . ',';
                            }
                            if (isset($oss_share_settings['facebookAppId']) && $oss_share_settings['facebookAppId'] != '') {
                                $verticalShare .= 'facebookAppId:"' . $oss_share_settings['facebookAppId'] . '",';
                            }
                            if ($oss_share_settings['shortenUrl'] != '') {
                                $verticalShare .= 'isShortenUrl:' . $oss_share_settings['shortenUrl'] . ',';
                            }
                            if ($oss_share_settings['isOpenSingleWindow'] != '') {
                                $verticalShare .= 'isOpenSingleWindow:' . $oss_share_settings['isOpenSingleWindow'] . ',';
                            }
                            if (!empty($oss_share_settings['popupHeightWidth']) && !empty($oss_share_settings['popupWindowHeight']) && !empty($oss_share_settings['popupWindowWidth'])) {
                                $popUpWindow = '{height:' . $oss_share_settings['popupWindowHeight'] . ',width :' . $oss_share_settings['popupWindowWidth'] . '}';
                                $verticalShare .= 'popupWindowSize:' . $popUpWindow . ',';
                            }
                            if (isset($oss_share_settings['twittermention']) && $oss_share_settings['twittermention'] != '') {
                                $verticalShare .= 'twittermention:"' . $oss_share_settings['twittermention'] . '",';
                            }
                            if (isset($oss_share_settings['twitterhashtags']) && $oss_share_settings['twitterhashtags'] != '') {
                                $verticalShare .= 'twitterhashtag:"' . $oss_share_settings['twitterhashtags'] . '",';
                            }
                            if (isset($oss_share_settings['customOptions']) && $oss_share_settings['customOptions'] != '') {
                                $verticalShare .= $oss_share_settings['customOptions'] . ',';
                            }
                            $scriptVertical = '{name:';
                            if ($oss_share_settings['vertical_share_interface'] == 'hybrid-v-v' && $oss_share_settings['vertical_sharing_providers']['Hybrid']['Facebook Like'] == 'Facebook Like' && $oss_share_settings['facebookPage'] != '' || $oss_share_settings['vertical_share_interface'] == 'hybrid-v-h' && $oss_share_settings['vertical_sharing_providers']['Hybrid']['Facebook Like'] == 'Facebook Like' && $oss_share_settings['facebookPage'] != '') {
                                foreach ($oss_share_settings['vertical_sharing_providers']['Hybrid'] as $key => $value) {
                                    if ($key == 'Facebook Like') {
                                        $scriptVertical .= '"' . $value . '"' . ',';
                                        $scriptVertical .= 'url:' . '"' . $oss_share_settings['facebookPage'] . '"';
                                        $scriptVertical .= '},';
                                    } else {
                                        $scriptVertical .= '"' . $value . '"' . ',';
                                    }
                                }
                                $scriptVertical = substr($scriptVertical, 0, -1);
                            }
                            ?>
                            <script type="text/javascript">
        var shareWidgetVertical = new OpenSocialShare();
        shareWidgetVertical.init({
             <?php 
                            echo $verticalShare;
                            ?>
                 
            isCounterWidgetTheme: <?php 
                            echo $widgetTheme;
                            ?>
, // 0 or 1 - standard themes or counter widget themes
            isHorizontalCounter: <?php 
                            echo $countertype;
                            ?>
, // 0 or 1 - counter on top or counter to right - counter themes only
            isHorizontalLayout: 0, // 0 or 1 - vertical layout or horizontal layout
            widgetIconSize: "<?php 
                            echo $size;
                            ?>
", // "16" or "32" - 16px or 32px standard themes only
            widgetStyle: "square", //"image", "square" or "responsive" - standard themes only
           
            providers: {
                
                   top: ["<?php 
                            if (isset($oss_share_settings['vertical_rearrange_providers'])) {
                                echo implode('","', $oss_share_settings['vertical_rearrange_providers']);
                            }
                            ?>
"]
                },
            widgets: {
                 //all : _private.getAllButtonName(_private.widgetConfig),
         <?php 
                            if ($oss_share_settings['vertical_share_interface'] == 'hybrid-v-v' && $oss_share_settings['vertical_sharing_providers']['Hybrid']['Facebook Like'] == 'Facebook Like' && $oss_share_settings['facebookPage'] != '' || $oss_share_settings['vertical_share_interface'] == 'hybrid-v-h' && $oss_share_settings['vertical_sharing_providers']['Hybrid']['Facebook Like'] == 'Facebook Like' && $oss_share_settings['facebookPage'] != '') {
                                ?>
                 top: [<?php 
                                echo $scriptVertical;
                                ?>
]
         <?php 
                            } else {
                                ?>
             top: ["<?php 
                                echo implode('","', $oss_share_settings['vertical_sharing_providers']['Hybrid']);
                                ?>
"]
         <?php 
                            }
                            ?>
             },
           
            theme: 'OpenSocialShareDefaultTheme',  
        });
        shareWidgetVertical.injectInterface(".<?php 
                            echo $class;
                            ?>
");
        shareWidgetVertical.setWidgetTheme(".<?php 
                            echo $class;
                            ?>
");
    </script>
                        
                            <?php 
                        }
                    }
                }
            }
        }