/** * The javascript to loaded at front end. */ function the_champ_frontend_scripts() { global $theChampFacebookOptions, $theChampLoginOptions; // general (required) scripts wp_enqueue_script('the_champ_ss_general_scripts', plugins_url('js/front/social_login/general.js', __FILE__), false, THE_CHAMP_SS_VERSION); $websiteUrl = site_url(); ?> <script> var theChampSiteUrl = '<?php echo $websiteUrl; ?> '; </script> <?php // scripts used for common Social Login functionality if (the_champ_social_login_enabled() && !is_user_logged_in()) { $loadingImagePath = plugins_url('images/ajax_loader.gif', __FILE__); $theChampAjaxUrl = get_admin_url() . 'admin-ajax.php'; $redirectionUrl = esc_attr(the_champ_get_login_redirection_url()); $regRedirectionUrl = esc_attr(the_champ_get_login_redirection_url('', true)); ?> <script> var theChampLoadingImgPath = '<?php echo $loadingImagePath; ?> '; var theChampAjaxUrl = '<?php echo $theChampAjaxUrl; ?> '; var theChampRedirectionUrl = '<?php echo $redirectionUrl; ?> '; var theChampRegRedirectionUrl = '<?php echo $regRedirectionUrl; ?> '; </script> <?php $userVerified = false; $ajaxUrl = 'admin-ajax.php'; $notification = ''; if (isset($_GET['SuperSocializerVerified']) || isset($_GET['SuperSocializerUnverified'])) { $userVerified = true; $ajaxUrl = add_query_arg(array('height' => 60, 'width' => 300, 'action' => 'the_champ_notify', 'message' => urlencode(isset($_GET['SuperSocializerUnverified']) ? __('Please verify your email address to login.', 'Super-Socializer') : __('Your email has been verified. Now you can login to your account', 'Super-Socializer'))), 'admin-ajax.php'); $notification = __('Notification', 'Super-Socializer'); } $emailPopup = false; $emailAjaxUrl = 'admin-ajax.php'; $emailPopupTitle = ''; $emailPopupErrorMessage = ''; $emailPopupUniqueId = ''; $emailPopupVerifyMessage = ''; if (isset($_GET['SuperSocializerEmail']) && isset($_GET['par']) && trim($_GET['par']) != '') { $emailPopup = true; $emailAjaxUrl = add_query_arg(array('height' => isset($theChampLoginOptions['popup_height']) && $theChampLoginOptions['popup_height'] != '' ? $theChampLoginOptions['popup_height'] : 210, 'width' => 300, 'action' => 'the_champ_ask_email'), 'admin-ajax.php'); $emailPopupTitle = __('Email required', 'Super-Socializer'); $emailPopupErrorMessage = isset($theChampLoginOptions["email_error_message"]) ? $theChampLoginOptions["email_error_message"] : ""; $emailPopupUniqueId = isset($_GET['par']) ? trim(esc_attr($_GET['par'])) : ''; $emailPopupVerifyMessage = __('Please check your email inbox to complete the registration.', 'Super-Socializer'); } ?> <script> var theChampVerified = <?php echo intval($userVerified); ?> ; var theChampAjaxUrl = '<?php echo admin_url() . $ajaxUrl; ?> '; var theChampPopupTitle = '<?php echo $notification; ?> '; var theChampEmailPopup = <?php echo intval($emailPopup); ?> ; var theChampEmailAjaxUrl = '<?php echo admin_url() . $emailAjaxUrl; ?> '; var theChampEmailPopupTitle = '<?php echo $emailPopupTitle; ?> '; var theChampEmailPopupErrorMsg = '<?php echo htmlspecialchars($emailPopupErrorMessage, ENT_QUOTES); ?> '; var theChampEmailPopupUniqueId = '<?php echo $emailPopupUniqueId; ?> '; var theChampEmailPopupVerifyMessage = '<?php echo $emailPopupVerifyMessage; ?> '; var theChampTwitterRedirect = '<?php echo urlencode(the_champ_get_valid_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); ?> '; </script> <?php wp_enqueue_script('the_champ_sl_common', plugins_url('js/front/social_login/common.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); } // Google+ scripts if (the_champ_social_login_provider_enabled('google') && !is_user_logged_in()) { $googleKey = isset($theChampLoginOptions['google_key']) ? $theChampLoginOptions['google_key'] : ''; ?> <script>var theChampGoogleKey = '<?php echo $googleKey; ?> '; var theChampGoogleErrorMessage = '<?php _e('Follow steps 11 and 12 at GooglePlus app configuration page, about to open', 'Super-Socializer'); ?> ' </script> <?php wp_enqueue_script('the_champ_sl_google', plugins_url('js/front/social_login/google.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); } // Linkedin scripts if (the_champ_social_login_provider_enabled('linkedin') && !is_user_logged_in()) { ?> <script type="text/javascript" src="//platform.linkedin.com/in.js"> api_key: <?php echo isset($theChampLoginOptions['li_key']) ? $theChampLoginOptions['li_key'] : ''; ?> onLoad: theChampLinkedInOnLoad </script> <?php wp_enqueue_script('the_champ_sl_linkedin', plugins_url('js/front/social_login/linkedin.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); } // Vkontakte scripts if (the_champ_social_login_provider_enabled('vkontakte') && !is_user_logged_in()) { ?> <div id="vk_api_transport"></div> <script> var theChampVkKey = '<?php echo isset($theChampLoginOptions["vk_key"]) && $theChampLoginOptions["vk_key"] != "" ? $theChampLoginOptions["vk_key"] : 0; ?> ' </script> <?php wp_enqueue_script('the_champ_sl_vkontakte', plugins_url('js/front/social_login/vkontakte.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); } // Instagram scripts if (the_champ_social_login_provider_enabled('instagram')) { ?> <script> var theChampInstaId = '<?php echo isset($theChampLoginOptions["insta_id"]) && $theChampLoginOptions["insta_id"] != "" ? $theChampLoginOptions["insta_id"] : 0; ?> '; var theChampTwitterRedirect = '<?php echo urlencode(the_champ_get_valid_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])); ?> '; </script> <?php wp_enqueue_script('the_champ_sl_instagram', plugins_url('js/front/social_login/instagram.js', __FILE__), false, THE_CHAMP_SS_VERSION); } // Facebook scripts if (the_champ_facebook_plugin_enabled()) { ?> <div id="fb-root"></div> <script> var theChampFBKey = '<?php echo isset($theChampLoginOptions["fb_key"]) && $theChampLoginOptions["fb_key"] != "" ? $theChampLoginOptions["fb_key"] : ""; ?> '; var theChampFBLang = '<?php echo isset($theChampFacebookOptions["comment_lang"]) && $theChampFacebookOptions["comment_lang"] != '' ? $theChampFacebookOptions["comment_lang"] : "en_US"; ?> '; </script> <?php wp_enqueue_script('the_champ_fb_sdk', plugins_url('js/front/facebook/sdk.js', __FILE__), false, THE_CHAMP_SS_VERSION); } if (the_champ_social_login_provider_enabled('facebook') && !is_user_logged_in()) { ?> <script> var theChampFacebookScope = 'email<?php echo isset($theChampFacebookOptions["enable_fbfeed"]) && $theChampFacebookOptions["enable_fbfeed"] == 1 ? ", publish_actions" : ""; ?> '; var theChampFBFeedEnabled = <?php echo the_champ_facebook_feed_enabled() ? 'true' : 'false'; ?> ; </script> <?php wp_enqueue_script('the_champ_sl_facebook', plugins_url('js/front/social_login/facebook.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); } // Facebook commenting if (the_champ_facebook_commenting_enabled()) { global $post; if (isset($theChampFacebookOptions['urlToComment']) && $theChampFacebookOptions['urlToComment'] != '') { $commentUrl = $theChampFacebookOptions['urlToComment']; } elseif (isset($post->ID) && $post->ID) { $commentUrl = get_permalink($post->ID); } else { $commentUrl = esc_attr(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); } if ($post) { $postMeta = get_post_meta($post->ID, '_the_champ_meta', true); } ?> <script>var theChampFBCommentUrl = '<?php echo $commentUrl; ?> '; var theChampFBCommentColor = '<?php echo isset($theChampFacebookOptions['comment_color']) && $theChampFacebookOptions['comment_color'] != '' ? $theChampFacebookOptions["comment_color"] : ''; ?> '; var theChampFBCommentNumPosts = '<?php echo isset($theChampFacebookOptions['comment_numposts']) && $theChampFacebookOptions['comment_numposts'] != '' ? $theChampFacebookOptions["comment_numposts"] : ''; ?> '; var theChampFBCommentWidth = '<?php echo isset($theChampFacebookOptions['comment_width']) && $theChampFacebookOptions['comment_width'] != '' ? $theChampFacebookOptions["comment_width"] : '100%'; ?> '; var theChampFBCommentOrderby = '<?php echo isset($theChampFacebookOptions['comment_orderby']) && $theChampFacebookOptions['comment_orderby'] != '' ? $theChampFacebookOptions["comment_orderby"] : ''; ?> '; var theChampFBCommentMobile = '<?php echo isset($theChampFacebookOptions['comment_mobile']) && $theChampFacebookOptions['comment_mobile'] != '' ? $theChampFacebookOptions["comment_mobile"] : ''; ?> '; var theChampFBAppID = '<?php echo isset($theChampLoginOptions['fb_key']) && $theChampLoginOptions['fb_key'] != '' ? $theChampLoginOptions['fb_key'] : ''; ?> '; var theChampSiteUrl = '<?php echo site_url(); ?> '; var theChampWPCommentingContent = ''; var theChampFBCommentingContent = ''; var theChampCommentingHandle = false; var theChampCommentingDisabled = <?php echo isset($postMeta) && isset($postMeta['fb_comments']) && $postMeta['fb_comments'] == 1 ? 1 : 0; ?> </script> <?php wp_enqueue_script('the_champ_fb_commenting', plugins_url('js/front/facebook/commenting.js', __FILE__), false, THE_CHAMP_SS_VERSION); } // Facebook feed posts if (the_champ_facebook_feed_enabled()) { ?> <script> var theChampFacebookFeedMsg = '<?php echo htmlspecialchars(str_replace("%website-name%", get_option("blogname"), $theChampFacebookOptions['feedMessage']), ENT_QUOTES); ?> '; var theChampFBFeedName = '<?php echo isset($theChampFacebookOptions['feed_name']) && $theChampFacebookOptions['feed_name'] != '' ? htmlspecialchars($theChampFacebookOptions['feed_name'], ENT_QUOTES) : ''; ?> '; var theChampFBFeedDesc = '<?php echo isset($theChampFacebookOptions['feed_description']) && $theChampFacebookOptions['feed_description'] != '' ? htmlspecialchars(trim(preg_replace("/\r?\n/", '\\n', $theChampFacebookOptions['feed_description'])), ENT_QUOTES) : ''; ?> '; var theChampFBFeedLink = '<?php echo isset($theChampFacebookOptions['feed_link']) && $theChampFacebookOptions['feed_link'] != '' ? $theChampFacebookOptions['feed_link'] : ''; ?> '; var theChampFBFeedSource = '<?php echo isset($theChampFacebookOptions['feedSource']) && $theChampFacebookOptions['feedSource'] != '' ? $theChampFacebookOptions['feedSource'] : ''; ?> '; var theChampFBFeedPicture = '<?php echo isset($theChampFacebookOptions['feedPicture']) && $theChampFacebookOptions['feedPicture'] != '' ? $theChampFacebookOptions['feedPicture'] : ''; ?> '; var theChampFBFeedCaption = '<?php echo isset($theChampFacebookOptions['feed_caption']) && $theChampFacebookOptions['feed_caption'] != '' ? htmlspecialchars($theChampFacebookOptions['feed_caption'], ENT_QUOTES) : ''; ?> '; </script> <?php wp_enqueue_script('the_champ_fb_feed', plugins_url('js/front/facebook/feed.js', __FILE__), false, THE_CHAMP_SS_VERSION); } // sharing script if (the_champ_social_sharing_enabled()) { global $theChampSharingOptions, $post; ?> <script> var theChampSharingAjaxUrl = '<?php echo get_admin_url(); ?> admin-ajax.php'; var theChampCloseIconPath = '<?php echo plugins_url('images/close.png', __FILE__); ?> '; var theChampPluginIconPath = '<?php echo plugins_url('images/logo.png', __FILE__); ?> '; var theChampHorizontalSharingCountEnable = <?php echo isset($theChampSharingOptions['horizontal_counts']) ? 1 : 0; ?> ; var theChampVerticalSharingCountEnable = <?php echo isset($theChampSharingOptions['vertical_counts']) ? 1 : 0; ?> ; </script> <?php wp_enqueue_script('the_champ_share_counts', plugins_url('js/front/sharing/sharing.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION); } }
/** * Check if any Facebook plugin is enabled. */ function the_champ_facebook_plugin_enabled() { global $theChampFacebookOptions, $theChampCounterOptions; if (the_champ_social_login_provider_enabled('facebook') || the_champ_facebook_commenting_enabled() || the_champ_facebook_like_rec_enabled()) { return true; } else { return false; } }
/** * Shortcode for Social Login. */ function the_champ_fb_commenting_shortcode($params) { if (the_champ_facebook_commenting_enabled()) { extract(shortcode_atts(array('style' => '', 'url' => get_permalink(), 'num_posts' => '', 'width' => ''), $params)); $html = '<div style="' . $style . '" id="the_champ_fb_commenting"> <div class="fb-comments" data-href="' . ($url == '' ? the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url) . '"'; $html .= ' data-numposts="' . $num_posts . '"'; $html .= ' data-width="' . ($width == '' ? '100%' : $width) . '"'; $html .= ' ></div></div>'; return $html; } }