options = $options; $this->version = $version; } /** * Hook the plugin function on 'init' event. * * @since 1.0.0 */ public function init() { // Javascript for front-end of website add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ) ); // inline style for front-end of website add_action( 'wp_enqueue_scripts', array( $this, 'frontend_inline_style' ) ); // stylesheet files for front-end of website add_action( 'wp_enqueue_scripts', array( $this, 'frontend_css' ) ); if ( isset( $this->options['amp_enable'] ) && function_exists( 'is_amp_endpoint' ) ) { add_action( 'wp_print_styles', array( $this, 'frontend_amp_css' ) ); add_action( 'amp_post_template_css', array( $this, 'frontend_amp_css' ) ); } } /** * Javascript files to load at front end. * * @since 1.0.0 */ public function frontend_scripts() { if ( ! ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) && ! ( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() ) ) { $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()}}}; '; global $post; if ( $post ) { $sharing_meta = get_post_meta( $post->ID, '_heateor_sss_meta', true ); if ( is_front_page() || ! isset( $sharing_meta['sharing'] ) || $sharing_meta['sharing'] != 1 || ! isset( $sharing_meta['vertical_sharing'] ) || $sharing_meta['vertical_sharing'] != 1 ) { $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'] != '' ? $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->facebook_like_recommend_enabled() || $this->facebook_share_enabled() ) { $inline_script .= 'function heateorSssInitiateFB() {FB.init({appId:"",channelUrl:"",status:!0,cookie:!0,xfbml:!0,version:"v3.0"})}window.fbAsyncInit=function() {heateorSssInitiateFB(),' . ( defined( 'HEATEOR_SOCIAL_SHARE_MYCRED_INTEGRATION_VERSION' ) && $this->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_US' ) .'/sdk.js",o.parentNode.insertBefore(n,o) )}(document);'; } if ( current_filter() == 'amp_post_template_head' ) { // default post url global $post; $post_url = html_entity_decode( esc_url( $this->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ) ); if ( $this->options['horizontal_target_url'] == 'default' ) { $post_url = get_permalink( $post->ID ); if ( $post_url == '' ) { $post_url = html_entity_decode( esc_url( $this->get_http_protocol() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ) ); } } elseif ( $this->options['horizontal_target_url'] == 'home' ) { $post_url = home_url(); } elseif ( $this->options['horizontal_target_url'] == 'custom' ) { $post_url = $this->options['horizontal_target_url_custom'] ? $this->options['horizontal_target_url_custom'] : get_permalink( $post->ID ); } $sharing_url = $this->get_short_url( $post_url, $post->ID ); $post_title = $post->post_title; $post_title = $this->sanitize_post_title( $post_title ); $inline_script .= 'var heateorSssAmpTargetUrl = \''. $post_url .'\'; heateorSssLoadEvent( function(){ var moreIcons = document.getElementsByClassName("heateorSssMoreBackground"); for(var i = 0; i < moreIcons.length; i++){ moreIcons[i].onclick = function(){ heateorSssMoreSharingPopup(null, \''. ( $sharing_url ? $sharing_url : $post_url) .'\', \''. $post_title .'\', \''. $this->sanitize_post_title( $this->wpseo_twitter_title( $post ) ) .'\') } } var printIcons = document.getElementsByClassName("heateorSssPrintBackground"); for(var i = 0; i < printIcons.length; i++){ printIcons[i].onclick = function(){ window.print(); } } var pinterestIcons = document.getElementsByClassName("heateorSssPinterestBackground"); for(var i = 0; i < pinterestIcons.length; i++){ pinterestIcons[i].onclick = function(){ var e = document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e); } } } ); function heateorSssCapitaliseFirstLetter(e) { return e.charAt(0).toUpperCase() + e.slice(1) } /** * Search sharing services */ function heateorSssFilterSharing(val) { var sharingServices = document.getElementById(\'heateor_sss_sharing_more_content\').getElementsByTagName(\'a\'); for(var i = 0; i < sharingServices.length; i++){ if (sharingServices[i].innerText.toLowerCase().indexOf(val.toLowerCase()) != -1) { sharingServices[i].parentNode.style.display = \'block\'; //jQuery(this).parent().css(\'display\', \'block\'); } else { sharingServices[i].parentNode.style.display = \'none\'; } } }; function heateorSssMoreSharingPopup(elem, postUrl, postTitle, twitterTitle){ postUrl = encodeURIComponent(postUrl); concate = \'
\'; var heateorSssMoreSharingServices = { facebook: { title: "Facebook", locale: "en-US", redirect_url: "http://www.facebook.com/sharer.php?u=" + postUrl + "&t=" + postTitle + "&v=3", }, twitter: { title: "Twitter", locale: "en-US", redirect_url: "http://twitter.com/intent/tweet?text=" + (twitterTitle ? twitterTitle : postTitle) + " " + postUrl, }, linkedin: { title: "Linkedin", locale: "en-US", redirect_url: "http://www.linkedin.com/shareArticle?mini=true&url=" + postUrl + "&title=" + postTitle, }, pinterest: { title: "Pinterest", locale: "en-US", redirect_url: "https://pinterest.com/pin/create/button/?url=" + postUrl + "&media=${media_link}&description=" + postTitle, bookmarklet_url: "javascript:void((function(){var e=document.createElement(\'script\');e.setAttribute(\'type\',\'text/javascript\');e.setAttribute(\'charset\',\'UTF-8\');e.setAttribute(\'src\',\'//assets.pinterest.com/js/pinmarklet.js?r=\'+Math.random()*99999999);document.body.appendChild(e)})());" }, CopyLink: { title: "Copy Link", locale: "en-US", redirect_url: "", bookmarklet_url: "" }, Diaspora: { title: "Diaspora", locale: "en-US", redirect_url: "https://joindiaspora.com/bookmarklet?url=" + postUrl + "&title=" + postTitle + "&v=1" }, Douban: { title: "Douban", locale: "en-US", redirect_url: "https://www.douban.com/share/service?name="+postTitle+"&href="+postUrl+"&image=&updated=&bm=&url="+postUrl+"&title="+postTitle+"&sel=" }, Draugiem: { title: "Draugiem", locale: "en-US", redirect_url: "https://www.draugiem.lv/say/ext/add.php?link="+postUrl+"&title="+postTitle }, Facebook_Messenger: { title: "Facebook Messenger", locale: "en-US", redirect_url: "https://www.facebook.com/dialog/send?app_id=1904103319867886&display=popup&link="+postUrl+"&redirect_uri="+postUrl }, Google_Classroom: { title: "Google Classroom", locale: "en-US", redirect_url: "https://classroom.google.com/u/0/share?url="+postUrl }, Kik: { title: "Kik", locale: "en-US", redirect_url: "https://www.kik.com/send/article/?app_name=Share&text=&title="+postTitle+"&url="+postUrl }, Papaly: { title: "Papaly", locale: "en-US", redirect_url: "https://papaly.com/api/share.html?url="+postUrl+"&title="+postTitle }, Polyvore: { title: "Polyvore", locale: "en-US", bookmarklet_url: "javascript:(function(){function e(a){var c=window;if(c.PolyvoreClipper){c.PolyvoreClipper.run()}else{var b=a.createElement(\'script\');c._polyvoreMode=\'prod\';c._polyvoreHost=\'www.polyvore.com\';b.src=\'http://akwww.polyvorecdn.com/rsrc/clipper.js?\'+Math.floor((new Date()).getTime()/86400000);a.body.appendChild(b)}}try{e(document)}catch(g){}for(var f=0;f