/**
  * Outputs the content of the widget
  *
  * @param array $args
  * @param array $instance
  */
 function widget($args, $instance)
 {
     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;
         }
     }
     extract($args);
     if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) {
         return;
     }
     echo $before_widget;
     if (!empty($instance['before_widget_content'])) {
         echo $instance['before_widget_content'];
     }
     OSS_Common_Sharing::horizontal_sharing();
     echo '<div class="oss_horizontal_share"></div>';
     if (!empty($instance['after_widget_content'])) {
         echo $instance['after_widget_content'];
     }
     echo $after_widget;
 }
Пример #2
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, '');
 }
 /**
  * Output Sharing for the content.
  * 
  * @global type $post
  * @param type $content
  * @return type
  */
 function vertical_page_content($content)
 {
     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 $content;
         }
     }
     OSS_Common_Sharing::vertical_sharing();
     $position = self::get_vertical_position();
     if ($position['top_left']) {
         $class = uniqid('oss_');
         self::$params['top_left']['class'] = $class;
         $style = 'style="position: fixed;top: 0px;left: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     if ($position['top_right']) {
         $class = uniqid('oss_');
         self::$params['top_right']['class'] = $class;
         $style = 'style="position: fixed;top: 0px;right: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     if ($position['middle_right']) {
         $class = uniqid('oss_');
         self::$params['middle_right']['class'] = $class;
         $style = 'style="position: fixed;top: 200px;right: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     if ($position['middle_left']) {
         $class = uniqid('oss_');
         self::$params['middle_left']['class'] = $class;
         $style = 'style="position: fixed;top: 200px;left: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     if ($position['bottom_left']) {
         $class = uniqid('oss_');
         self::$params['bottom_left']['class'] = $class;
         $style = 'style="position: fixed;bottom: 0px;left: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     if ($position['bottom_right']) {
         $class = uniqid('oss_');
         self::$params['bottom_right']['class'] = $class;
         $style = 'style="position: fixed;bottom: 0px;right: 0;"';
         $content .= self::get_vertical_sharing($class, $style);
     }
     echo $content;
 }
 /**
  * Output Sharing <div> for the content.
  * 
  * @global type $post
  * @global type $oss_share_settings
  * @param type $content
  * @return string
  */
 function opensocialshare_share_horizontal_content($content)
 {
     global $post, $oss_share_settings;
     $return = '';
     $top = false;
     $bottom = false;
     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 $content;
         }
     }
     OSS_Common_Sharing::horizontal_sharing();
     if (current_filter() == 'the_content') {
         // Show on Post.
         if (is_single() && $post->post_type == 'post' && (isset($oss_share_settings['oss-clicker-hr-post']) && $oss_share_settings['oss-clicker-hr-post'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Posts']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Posts']['Bottom'])) {
                 $bottom = true;
             }
         }
         // Show on Custom Post Types
         if (is_single() && $post->post_type != 'post' && (isset($oss_share_settings['oss-clicker-hr-custom']) && $oss_share_settings['oss-clicker-hr-custom'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Custom']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Custom']['Bottom'])) {
                 $bottom = true;
             }
         }
         // Show on home Page.
         if (is_front_page() && (isset($oss_share_settings['oss-clicker-hr-home']) && $oss_share_settings['oss-clicker-hr-home'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Home']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Home']['Bottom'])) {
                 $bottom = true;
             }
         }
         // Show on Static Page.
         if (is_page() && (isset($oss_share_settings['oss-clicker-hr-static']) && $oss_share_settings['oss-clicker-hr-static'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Pages']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Pages']['Bottom'])) {
                 $bottom = true;
             }
         }
         // Show on Posts Page when a static page is the front.
         if (is_home() && !is_front_page() && (isset($oss_share_settings['oss-clicker-hr-excerpts']) && $oss_share_settings['oss-clicker-hr-excerpts'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Excerpts']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Excerpts']['Bottom'])) {
                 $bottom = true;
             }
         }
         // Show on Excerpts Page.
         if (has_excerpt($post->ID) && (isset($oss_share_settings['oss-clicker-hr-excerpts']) && $oss_share_settings['oss-clicker-hr-excerpts'] == '1')) {
             if (isset($oss_share_settings['horizontal_position']['Excerpts']['Top'])) {
                 $top = true;
             }
             if (isset($oss_share_settings['horizontal_position']['Excerpts']['Bottom'])) {
                 $bottom = true;
             }
         }
     }
     if (current_filter() == 'get_the_excerpt' && isset($oss_share_settings['oss-clicker-hr-excerpts']) && $oss_share_settings['oss-clicker-hr-excerpts'] == '1') {
         if (isset($oss_share_settings['horizontal_position']['Excerpts']['Top'])) {
             $top = true;
         }
         if (isset($oss_share_settings['horizontal_position']['Excerpts']['Bottom'])) {
             $bottom = true;
         }
     }
     if ($top) {
         $return = '<div  class="oss_horizontal_share oss_title_replace" 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 .= $content;
     if ($bottom) {
         $return .= '<div  class="oss_horizontal_share oss_title_replace" 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 $return;
 }