options = $options; $this->public_class_object = $public_class_object; } /** * Shortcode for Social Sharing. */ public function follow_icons_shortcode( $params ) { if ( $this->public_class_object->is_amp_page() ) { return; } extract( shortcode_atts( array( 'style' => '', 'width' => '32', 'height' => '32', 'shape' => 'square', 'social_networks' => '', 'type' => 'standard', 'theme' => '', 'left' => '0', 'right' => '0', 'top' => '100', 'align' => 'left', 'title' => '' ), $params ) ); $svg = array( 'facebook' => '', 'twitter' => '', 'instagram' => '', 'parler' => '', 'pinterest' => '', 'behance' => '', 'flickr' => '', 'foursquare' => '', 'github' => '', 'linkedin' => '', 'linkedin_company' => '', 'medium' => '', 'mewe' => '', 'odnoklassniki' => '', 'telegram' => '', 'tumblr' => '', 'vimeo' => '', 'vkontakte' => '', 'whatsapp' => '', 'xing' => '', 'youtube' => '', 'youtube_channel' => '', 'rss_feed' => '', 'gab' => '', 'gettr' => '', 'x' => '', 'yelp' => '', 'threads' => '', 'tiktok' => '', 'google_maps' => '', 'snapchat' => '', 'google_news' => '', 'mastodon' => '', 'line' => '', 'bluesky' => '', 'micro.blog' => '', ); $bg_color = array( 'facebook' => '0765FE', 'twitter' => '55acee', 'instagram' => '53beee', 'parler' => '892E5E', 'pinterest' => 'cc2329', 'behance' => '053eff', 'flickr' => 'ff0084', 'foursquare' => 'f94877', 'github' => '2a2a2a', 'linkedin' => '0077b5', 'linkedin_company' => '0077b5', 'medium' => '2a2a2a', 'mewe' => '007da1', 'odnoklassniki' => 'f2720c', 'telegram' => '3da5f1', 'tumblr' => '29435d', 'vimeo' => '1ab7ea', 'vkontakte' => '0077FF', 'whatsapp' => '55eb4c', 'xing' => '00797d', 'youtube' => 'ff0000', 'youtube_channel' => 'ff0000', 'rss_feed' => 'e3702d', 'gab' => '25CC80', 'gettr' => 'E50000', 'truth_social' => '6700ed', 'x' => '2a2a2a', 'yelp' => 'ff1a1a', 'threads' => '2a2a2a', 'tiktok' => '2a2a2a', 'google_maps' => '34a853', 'snapchat' => 'ffe900', 'google_news' => '55acee', 'line' => '00c300', 'mastodon' => '6364FF', 'bluesky' => '0085ff', 'micro.blog' => 'ff8800', ); $html = ''; if ( $social_networks ) { $networks = explode( ',', esc_attr( $social_networks ) ); $icon_style = 'width:' . esc_attr( $width ) . 'px;height:' . esc_attr( $height ) . 'px;' . ( $shape == 'round' ? 'border-radius:999px;' : '' ); if ( $theme == '' ) { $icon_theme = $theme; } elseif ( $theme == 'standard' ) { $icon_theme = $theme . '_'; } elseif ( $theme == 'floating' ) { $icon_theme = $theme . '_'; } $html .= '
'; if ( ! empty( $title ) ) { if ( $type == 'floating' ) { $html .= '
'; } $html .= esc_html( $title ); if ( $type == 'floating' ) { $html .= '
'; } } $html .= '
'; // follow icons foreach ( $networks as $value ) { $networks_link = explode( '=', trim( $value ) ); $anchor_title = ucfirst( trim( $networks_link[0] ) ); if ( strpos( $anchor_title, '_' ) !== false ) { $title_parts = explode( '_', $anchor_title ); foreach ( $title_parts as $key => $value ) { $title_parts[$key] = ucfirst( $value ); } $anchor_title = implode( ' ', $title_parts ); } $html .= '' . $svg[strtolower( trim( $networks_link[0] ) )] . ''; } $html .= '
'; $html .= '
'; $html .= '
'; } return $html; } /** * Shortcode for Social Sharing * * @since 1.0 */ public function sharing_shortcode( $params ) { extract( shortcode_atts( array( 'style' => '', 'type' => 'standard', 'left' => '0', 'right' => '0', 'top' => '100', 'url' => '', 'count' => 0, 'align' => 'left', 'title' => '', 'total_shares' => 'OFF' ), $params ) ); $type = strtolower( $type ); if ( ( $type == 'standard' && ! isset( $this->options['hor_enable'] ) ) || ( $type == 'floating' && ! isset( $this->options['vertical_enable'] ) ) || ( ! isset( $this->options['amp_enable'] ) && $this->public_class_object->is_amp_page() ) ) { return; } global $post; if ( ! is_object( $post ) ) { return; } if ( $url && $this->public_class_object->validate_url( $url ) !== false ) { $target_url = esc_attr( $url ); $post_id = 0; } elseif ( is_front_page() ) { $target_url = esc_url( home_url() ); $post_id = 0; } elseif ( ! is_singular() && $type == 'vertical' ) { $target_url = esc_url_raw( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ); $post_id = 0; } elseif ( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] ) { $target_url = esc_url_raw( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ); $post_id = $post->ID; } elseif ( get_permalink( $post->ID ) ) { $target_url = get_permalink( $post->ID ); $post_id = $post->ID; } else { $target_url = esc_url_raw( $this->public_class_object->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ); $post_id = 0; } $share_count_url = $target_url; if ( $url == '' && is_singular() ) { $share_count_url = get_permalink( $post->ID ); } $custom_post_url = $this->public_class_object->apply_target_share_url_filter( $target_url, esc_attr( $type ), false ); if ( $custom_post_url != $target_url ) { $target_url = $custom_post_url; $share_count_url = $target_url; } // generate short url $short_url = $this->public_class_object->get_short_url( $target_url, $post_id ); $alignment_offset = 0; if ( $left) { $alignment_offset = $left; } elseif ( $right) { $alignment_offset = $right; } // share count transient ID $this->public_class_object->share_count_transient_id = $this->public_class_object->get_share_count_transient_id( $target_url ); $cached_share_count = $this->public_class_object->get_cached_share_count( $this->public_class_object->share_count_transient_id ); if ( isset( $this->options['js_when_needed'] ) && ! wp_script_is( 'heateor_sss_sharing_js' ) ) { $in_footer = isset( $this->options['footer_script'] ) ? true : false; $inline_script = 'function heateorSssLoadEvent(e) {var t=window.onload;if (typeof window.onload!="function") {window.onload=e}else{window.onload=function() {t();e()}}};'; $inline_script .= 'var heateorSssSharingAjaxUrl = \''. get_admin_url() .'admin-ajax.php\', heateorSssCloseIconPath = \''. plugins_url( '../images/close.png', __FILE__ ) .'\', heateorSssPluginIconPath = \''. plugins_url( '../images/logo.png', __FILE__ ) .'\', heateorSssHorizontalSharingCountEnable = '. ( isset( $this->options['hor_enable'] ) && ( isset( $this->options['horizontal_counts'] ) || isset( $this->options['horizontal_total_shares'] ) ) ? 1 : 0 ) .', heateorSssVerticalSharingCountEnable = '. ( isset( $this->options['vertical_enable'] ) && ( isset( $this->options['vertical_counts'] ) || isset( $this->options['vertical_total_shares'] ) ) ? 1 : 0 ) .', heateorSssSharingOffset = '. ( isset( $this->options['alignment'] ) && $this->options['alignment'] != '' && isset( $this->options[$this->options['alignment'].'_offset'] ) && $this->options[$this->options['alignment'].'_offset'] != '' ? intval( $this->options[$this->options['alignment'].'_offset'] ) : 0 ) . '; var heateorSssMobileStickySharingEnabled = ' . ( isset( $this->options['vertical_enable'] ) && isset( $this->options['bottom_mobile_sharing'] ) && $this->options['horizontal_screen_width'] != '' ? 1 : 0 ) . ';'; $inline_script .= 'var heateorSssCopyLinkMessage = "' . htmlspecialchars( __( 'Link copied.', 'sassy-social-share' ), ENT_QUOTES ) . '";'; if ( isset( $this->options['horizontal_counts'] ) && isset( $this->options['horizontal_counter_position'] ) ) { $inline_script .= in_array( $this->options['horizontal_counter_position'], array( 'inner_left', 'inner_right' ) ) ? 'var heateorSssReduceHorizontalSvgWidth = true;' : ''; $inline_script .= in_array( $this->options['horizontal_counter_position'], array( 'inner_top', 'inner_bottom' ) ) ? 'var heateorSssReduceHorizontalSvgHeight = true;' : ''; } if ( isset( $this->options['vertical_counts'] ) ) { $inline_script .= isset( $this->options['vertical_counter_position'] ) && in_array( $this->options['vertical_counter_position'], array( 'inner_left', 'inner_right' ) ) ? 'var heateorSssReduceVerticalSvgWidth = true;' : ''; $inline_script .= ! isset( $this->options['vertical_counter_position'] ) || in_array( $this->options['vertical_counter_position'], array( 'inner_top', 'inner_bottom' ) ) ? 'var heateorSssReduceVerticalSvgHeight = true;' : ''; } $inline_script .= 'var heateorSssUrlCountFetched = [], heateorSssSharesText = \''. htmlspecialchars( __( 'Shares', 'sassy-social-share' ), ENT_QUOTES ) . '\', heateorSssShareText = \'' . htmlspecialchars( __( 'Share', 'sassy-social-share' ), ENT_QUOTES ) . '\';'; $inline_script .= 'function heateorSssPopup(e) {window.open(e,"popUpWindow","height=400,width=600,left=400,top=100,resizable,scrollbars,toolbar=0,personalbar=0,menubar=no,location=no,directories=no,status")}'; if ( $this->public_class_object->facebook_like_recommend_enabled() || $this->public_class_object->facebook_share_enabled() ) { $inline_script .= 'function heateorSssInitiateFB() {FB.init({appId:"",channelUrl:"",status:!0,cookie:!0,xfbml:!0,version:"v23.0"})}window.fbAsyncInit=function() {heateorSssInitiateFB(),' . ( defined( 'HEATEOR_SOCIAL_SHARE_MYCRED_INTEGRATION_VERSION' ) && $this->public_class_object->facebook_like_recommend_enabled() ? 1 : 0 ) . '&&(FB.Event.subscribe("edge.create",function(e) {heateorSsmiMycredPoints("Facebook_like_recommend","",e?e:"")}),FB.Event.subscribe("edge.remove",function(e) {heateorSsmiMycredPoints("Facebook_like_recommend","",e?e:"","Minus point(s) for undoing Facebook like-recommend")}) ),'. ( defined( 'HEATEOR_SHARING_GOOGLE_ANALYTICS_VERSION' ) ? 1 : 0 ) .'&&(FB.Event.subscribe("edge.create",function(e) {heateorSsgaSocialPluginsTracking("Facebook","Like",e?e:"")}),FB.Event.subscribe("edge.remove",function(e) {heateorSsgaSocialPluginsTracking("Facebook","Unlike",e?e:"")}) )},function(e) {var n,i="facebook-jssdk",o=e.getElementsByTagName("script")[0];e.getElementById(i)||(n=e.createElement("script"),n.id=i,n.async=!0,n.src="//connect.facebook.net/'. ( $this->options['language'] ? $this->options['language'] : 'en_GB' ) .'/sdk.js",o.parentNode.insertBefore(n,o) )}(document);'; } wp_enqueue_script( 'heateor_sss_sharing_js', plugins_url( '../public/js/sassy-social-share-public.js', __FILE__ ), array( 'jquery' ), $this->public_class_object->version, $in_footer ); wp_add_inline_script( 'heateor_sss_sharing_js', $inline_script, $position = 'before' ); } $html = '
public_class_object->is_amp_page() ? "" : "data-heateor-sss-href='" . esc_url( isset( $share_count_url ) && $share_count_url ? $share_count_url : $target_url ) . "'" ) . ( ( $cached_share_count === false || $this->public_class_object->is_amp_page() ) ? "" : 'data-heateor-sss-no-counts="1" ' ); $vertical_offsets = ''; if ( $type == 'floating' ) { $vertical_offsets = esc_attr( $align ) . ': ' . esc_attr( $$align ) . 'px; top: ' . esc_attr( $top ) . 'px;width:' . ( ( $this->options['vertical_sharing_size'] ? $this->options['vertical_sharing_size'] : '35' ) + 4 ) . "px;"; } // style if ( $style != "" || $vertical_offsets != '' ) { $html .= 'style="'; if ( strpos( $style, 'background' ) === false ) { $html .= '-webkit-box-shadow:none;box-shadow:none;'; } $html .= $vertical_offsets; $html .= esc_attr( $style ); $html .= '"'; } $html .= '>'; if ( $type == 'standard' && $title != '' ) { $html .= '
' . esc_html( ucfirst( $title ) ) . '
'; } $html .= $this->public_class_object->prepare_sharing_html( $short_url ? $short_url : $target_url, $type == 'standard' ? 'horizontal' : 'vertical', $count, $total_shares == 'ON' ? 1 : 0 ); $html .= '
'; if ( ( $count || $total_shares == 'ON' ) && $cached_share_count === false ) { $html .= ''; } return $html; } }