/** * 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, ''); }
/** * Get LoginRadius Vertical Simple Social Sharing div and script. * * @global type $post * @global type $loginradius_share_settings * @global type $loginradius_api_settings * @return type */ public static function get_vertical_sharing_script() { global $post, $loginradius_share_settings, $loginradius_api_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; } } $is_mobile = self::mobile_detect(); if ($is_mobile && isset($loginradius_share_settings['mobile_enable']) && $loginradius_share_settings['mobile_enable'] == '1') { return; } $position = LR_Vertical_Sharing::get_vertical_position(); if (isset(LR_Vertical_Sharing::$position['class'])) { foreach (LR_Vertical_Sharing::$position['class'] as $key => $value) { $position[$value]['class'] = $value; } } if (isset($position)) { foreach ($position as $key => $value) { switch ($key) { case 'top_left': if ($value) { $params = array('top' => '0px', 'right' => '', 'bottom' => '', 'left' => '0px'); $class = LR_Vertical_Sharing::$params['top_left']['class']; } break; case 'top_right': if ($value) { $params = array('top' => '0px', 'right' => '0px', 'bottom' => '', 'left' => ''); $class = LR_Vertical_Sharing::$params['top_right']['class']; } break; case 'bottom_left': if ($value) { $params = array('top' => '', 'right' => '', 'bottom' => '0px', 'left' => '0px'); $class = LR_Vertical_Sharing::$params['bottom_left']['class']; } break; case 'bottom_right': if ($value) { $params = array('top' => '', 'right' => '0px', 'bottom' => '0px', 'left' => ''); $class = LR_Vertical_Sharing::$params['bottom_right']['class']; } break; default: if ($value) { $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 = $loginradius_share_settings['vertical_share_interface']; switch ($theme) { case '32-v': $size = '32'; break; case '16-v': $size = '16'; break; case 'hybrid-v-h': $hybrid = true; $size = '32'; $countertype = "horizontal"; break; case 'hybrid-v-v': $hybrid = true; $size = '32'; $countertype = "vertical"; break; default: $size = '32'; $top = 'top'; $left = 'left'; break; } if ($hybrid == false) { ?> <script type="text/javascript"> LoginRadius.util.ready(function () { $i = $SS.Interface.Simplefloat; $i.top = '<?php echo $top; ?> '; $i.right = '<?php echo $right; ?> '; $i.bottom = '<?php echo $bottom; ?> '; $i.left = '<?php echo $left; ?> '; $SS.Providers.Top = ["<?php echo implode('","', $loginradius_share_settings['vertical_rearrange_providers']); ?> "]; $u = LoginRadius.user_settings; <?php if (isset($loginradius_api_settings['LoginRadius_apikey']) && !empty($loginradius_api_settings['LoginRadius_apikey'])) { ?> $u.apikey = "<?php echo $loginradius_api_settings['LoginRadius_apikey']; ?> "; <?php } ?> $i.size = "<?php echo $size; ?> "; $u.isMobileFriendly = <?php echo isset($loginradius_share_settings['mobile_enable']) && $loginradius_share_settings['mobile_enable'] == '1' ? 'true' : 'false'; ?> ; $i.show("<?php echo $class; ?> "); }); </script> <?php } else { ?> <script type="text/javascript"> LoginRadius.util.ready(function () { $i = $SC.Interface.simple; $i.top = '<?php echo $top; ?> '; $i.right = '<?php echo $right; ?> '; $i.bottom = '<?php echo $bottom; ?> '; $i.left = '<?php echo $left; ?> '; $SC.Providers.Selected = ["<?php echo implode('","', $loginradius_share_settings['vertical_sharing_providers']['Hybrid']); ?> "]; $u = LoginRadius.user_settings; $i.countertype = "<?php echo $countertype; ?> "; $u.isMobileFriendly = <?php echo isset($loginradius_share_settings['mobile_enable']) && $loginradius_share_settings['mobile_enable'] == '1' ? 'true' : 'false'; ?> ; <?php if (isset($loginradius_api_settings['LoginRadius_apikey']) && !empty($loginradius_api_settings['LoginRadius_apikey'])) { ?> $u.apikey = "<?php echo $loginradius_api_settings['LoginRadius_apikey']; ?> "; <?php } ?> $i.isHorizontal = false; $i.size = "<?php echo $size; ?> "; $i.show("<?php echo $class; ?> "); }); </script> <?php } } } } }