/** * Outputs the content of the widget * * @param array $args * @param array $instance */ function widget($args, $instance) { global $post, $loginradius_share_settings; if (is_object($post)) { $lrMeta = get_post_meta($post->ID, '_login_radius_meta', true); // If sharing disabled on this page/post, return content unaltered. if (isset($lrMeta['sharing']) && $lrMeta['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']; } LR_Common_Sharing::horizontal_sharing(); echo '<div class="lr_horizontal_share"></div>'; if (!empty($instance['after_widget_content'])) { echo $instance['after_widget_content']; } echo $after_widget; }
/** * This function will be used to insert content where shortcode is used. * Shortcode [LoginRadius_Share] * * @global type $post * @global type $loginradius_share_settings * @param type $params * @return type */ public static function sharing_shortcode($params) { global $post, $loginradius_share_settings; if (is_object($post)) { $lrMeta = get_post_meta($post->ID, '_login_radius_meta', true); // if sharing disabled on this page/post, return content unaltered. if (isset($lrMeta['sharing']) && $lrMeta['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' && $loginradius_share_settings['vertical_enable'] == '1') { LR_Common_Sharing::vertical_sharing(); $unique_id = uniqid(); LR_Vertical_Sharing::$position['class'][] = $unique_id; $share = LR_Vertical_Sharing::get_vertical_sharing('lr_ver_share_shortcode ' . $unique_id, $style); } if ($type == 'horizontal' && $loginradius_share_settings['horizontal_enable'] == '1') { LR_Common_Sharing::horizontal_sharing(); $share = '<div class="lr_horizontal_share" ' . $style . ' data-share-url="' . get_permalink($post->ID) . '" data-counter-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)) { $lrMeta = get_post_meta($post->ID, '_login_radius_meta', true); // If sharing disabled on this page/post, return content unaltered. if (isset($lrMeta['sharing']) && $lrMeta['sharing'] == 1 && !is_front_page()) { return; } } extract($args); if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) { return; } $unique_id = uniqid(); LR_Vertical_Sharing::$position['class'][] = $unique_id; LR_Common_Sharing::vertical_sharing(); echo LR_Vertical_Sharing::get_vertical_sharing('lr_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)) { $lrMeta = get_post_meta($post->ID, '_login_radius_meta', true); // if sharing disabled on this page/post, return content unaltered. if (isset($lrMeta['sharing']) && $lrMeta['sharing'] == 1 && !is_front_page()) { return $content; } } LR_Common_Sharing::vertical_sharing(); $position = self::get_vertical_position(); if ($position['top_left']) { $class = uniqid('lr_'); self::$params['top_left']['class'] = $class; $content .= self::get_vertical_sharing($class); } if ($position['top_right']) { $class = uniqid('lr_'); self::$params['top_right']['class'] = $class; $content .= self::get_vertical_sharing($class); } if ($position['bottom_left']) { $class = uniqid('lr_'); self::$params['bottom_left']['class'] = $class; $content .= self::get_vertical_sharing($class); } if ($position['bottom_right']) { $class = uniqid('lr_'); self::$params['bottom_right']['class'] = $class; $content .= self::get_vertical_sharing($class); } echo $content; }
/** * Output Sharing <div> for the content. * * @global type $post * @global type $loginradius_share_settings * @param type $content * @return string */ function loginradius_share_horizontal_content($content) { global $post, $loginradius_share_settings; $return = ''; $top = false; $bottom = false; if (is_object($post)) { $lrMeta = get_post_meta($post->ID, '_login_radius_meta', true); // if sharing disabled on this page/post, return content unaltered. if (isset($lrMeta['sharing']) && $lrMeta['sharing'] == '1' && !is_front_page()) { return $content; } } LR_Common_Sharing::horizontal_sharing(); if (current_filter() == 'the_content') { // Show on Post. if (is_single() && $post->post_type == 'post' && (isset($loginradius_share_settings['lr-clicker-hr-post']) && $loginradius_share_settings['lr-clicker-hr-post'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Posts']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Posts']['Bottom'])) { $bottom = true; } } // Show on Custom Post Types if (is_single() && $post->post_type != 'post' && (isset($loginradius_share_settings['lr-clicker-hr-custom']) && $loginradius_share_settings['lr-clicker-hr-custom'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Custom']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Custom']['Bottom'])) { $bottom = true; } } // Show on home Page. if (is_front_page() && (isset($loginradius_share_settings['lr-clicker-hr-home']) && $loginradius_share_settings['lr-clicker-hr-home'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Home']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Home']['Bottom'])) { $bottom = true; } } // Show on Static Page. if (is_page() && (isset($loginradius_share_settings['lr-clicker-hr-static']) && $loginradius_share_settings['lr-clicker-hr-static'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Pages']['Top'])) { $top = true; } if (isset($loginradius_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($loginradius_share_settings['lr-clicker-hr-excerpts']) && $loginradius_share_settings['lr-clicker-hr-excerpts'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Bottom'])) { $bottom = true; } } // Show on Excerpts Page. if (has_excerpt($post->ID) && (isset($loginradius_share_settings['lr-clicker-hr-excerpts']) && $loginradius_share_settings['lr-clicker-hr-excerpts'] == '1')) { if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Bottom'])) { $bottom = true; } } } if (current_filter() == 'get_the_excerpt' && isset($loginradius_share_settings['lr-clicker-hr-excerpts']) && $loginradius_share_settings['lr-clicker-hr-excerpts'] == '1') { if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Top'])) { $top = true; } if (isset($loginradius_share_settings['horizontal_position']['Excerpts']['Bottom'])) { $bottom = true; } } if ($top) { $return = '<div class="lr_horizontal_share" data-share-url="' . get_permalink($post->ID) . '" data-counter-url="' . get_permalink($post->ID) . '"></div>'; } $return .= $content; if ($bottom) { $return .= '<div class="lr_horizontal_share" data-share-url="' . get_permalink($post->ID) . '" data-counter-url="' . get_permalink($post->ID) . '"></div>'; } return $return; }