Ejemplo n.º 1
0
function the_champ_account_linking()
{
    if (is_user_logged_in()) {
        wp_enqueue_style('the-champ-frontend-css', plugins_url('css/front.css', __FILE__), false, THE_CHAMP_SS_VERSION);
        global $theChampFacebookOptions, $theChampLoginOptions, $user_ID;
        ?>

		<script>function theChampLoadEvent(e){var t=window.onload;if(typeof window.onload!="function"){window.onload=e}else{window.onload=function(){t();e()}}}</script>
		<?php 
        // 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 theChampLinkingRedirection = '<?php 
        echo the_champ_get_http() . $_SERVER["HTTP_HOST"] . html_entity_decode(esc_url(remove_query_arg(array('linked'))));
        ?>
'; var theChampSiteUrl = '<?php 
        echo $websiteUrl;
        ?>
'; var theChampVerified = 0; var theChampAjaxUrl = '<?php 
        echo admin_url();
        ?>
/admin-ajax.php'; var theChampPopupTitle = ''; var theChampEmailPopup = 0; var theChampEmailAjaxUrl = '<?php 
        echo admin_url();
        ?>
/admin-ajax.php'; var theChampEmailPopupTitle = ''; var theChampEmailPopupErrorMsg = ''; var theChampEmailPopupUniqueId = ''; var theChampEmailPopupVerifyMessage = ''; var theChampTwitterRedirect = '<?php 
        echo urlencode(the_champ_get_valid_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . html_entity_decode(esc_url(remove_query_arg(array('linked'))))));
        ?>
';</script>
		<?php 
        // scripts used for common Social Login functionality
        if (the_champ_social_login_enabled()) {
            $loadingImagePath = plugins_url('images/ajax_loader.gif', __FILE__);
            $theChampAjaxUrl = get_admin_url() . 'admin-ajax.php';
            $redirectionUrl = the_champ_get_login_redirection_url();
            $regRedirectionUrl = 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 = '';
            wp_enqueue_script('the_champ_modernizer', plugins_url('js/modernizr.custom.82187.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
            wp_enqueue_script('the_champ_sl_common', plugins_url('js/front/social_login/common.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        }
        // linking functions
        wp_enqueue_script('the_champ_ss_linking_script', plugins_url('js/front/social_login/linking.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        // Google+ scripts
        if (the_champ_social_login_provider_enabled('google')) {
            $googleKey = isset($theChampLoginOptions['google_key']) ? $theChampLoginOptions['google_key'] : '';
            ?>

			<script>var theChampGoogleKey = '<?php 
            echo $googleKey;
            ?>
' </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')) {
            ?>

			<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')) {
            ?>

			<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;
            ?>
' </script>
			<?php 
            wp_enqueue_script('the_champ_sl_instagram', plugins_url('js/front/social_login/instagram.js', __FILE__), false, THE_CHAMP_SS_VERSION);
        }
        if (the_champ_social_login_provider_enabled('facebook')) {
            ?>

			<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";
            ?>
';
			var theChampFacebookScope = 'email';
			</script>
			<?php 
            wp_enqueue_script('the_champ_fb_sdk', plugins_url('js/front/facebook/sdk.js', __FILE__), false, THE_CHAMP_SS_VERSION);
            wp_enqueue_script('the_champ_sl_facebook', plugins_url('js/front/social_login/facebook.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        }
        $html = '<style type="text/css">
			table.superSocializerTable td{
				padding: 10px;
			}
		</style>';
        $html .= '<div class="metabox-holder columns-2 super-socializer-linking-container" id="post-body">
            <div class="stuffbox" style="width:60%; padding-bottom:10px">
                <div class="inside" style="padding:0">
                    <table class="form-table editcomment superSocializerTable">
                        <tbody>';
        if (isset($_GET['linked'])) {
            if ($_GET['linked'] == 1) {
                $html .= '<tr>
	                        		<td colspan="2" style="color: green">' . __('Account linked successfully', 'Super-Socializer') . '</td>
	                        	</tr>';
            } elseif ($_GET['linked'] == 0) {
                $html .= '<tr>
	                        		<td colspan="2" style="color: red">' . __('Account already exists or linked', 'Super-Socializer') . '</td>
	                        	</tr>';
            }
        }
        $icons_container = '<div class="the_champ_login_container"><ul class="the_champ_login_ul">';
        $existingProviders = array();
        $primarySocialNetwork = get_user_meta($user_ID, 'thechamp_provider', true);
        if ($primarySocialNetwork) {
            $html .= '<tr>
								<td colspan="2">' . __('You are already connected with', 'Super-Socializer') . ' <strong>' . ucfirst($primarySocialNetwork) . '</strong> ' . __('as primary social network', 'Super-Socializer') . '</td>
							</tr>';
        }
        $existingProviders[] = $primarySocialNetwork;
        $linkedAccounts = get_user_meta($user_ID, 'thechamp_linked_accounts', true);
        if ($linkedAccounts) {
            $linkedAccounts = maybe_unserialize($linkedAccounts);
            $linkedProviders = array_keys($linkedAccounts);
            $existingProviders = array_merge($existingProviders, $linkedProviders);
        }
        if (isset($theChampLoginOptions['providers'])) {
            $existingProviders = array_diff($theChampLoginOptions['providers'], $existingProviders);
        }
        if (count($existingProviders) > 0) {
            $html .= '<tr>
                            <td colspan="2"><strong>' . __('Link your social account to login to your account at this website', 'Super-Socializer') . '</strong><br/>';
            foreach ($existingProviders as $provider) {
                $icons_container .= '<li><i ';
                // id
                if ($provider == 'google') {
                    $icons_container .= 'id="theChamp' . ucfirst($provider) . 'Button" ';
                }
                // class
                $icons_container .= 'class="theChampLogin theChamp' . ucfirst($provider) . 'Background theChamp' . ucfirst($provider) . 'Login" ';
                $icons_container .= 'alt="Login with ';
                $icons_container .= ucfirst($provider);
                $icons_container .= '" title="Login with ';
                if ($provider == 'live') {
                    $icons_container .= 'Windows Live';
                } else {
                    $icons_container .= ucfirst($provider);
                }
                if (current_filter() == 'comment_form_top') {
                    $icons_container .= '" onclick="theChampCommentFormLogin = true; theChampInitiateLogin(this)" >';
                } else {
                    $icons_container .= '" onclick="theChampInitiateLogin(this)" >';
                }
                $icons_container .= '<div class="theChampLoginSvg theChamp' . ucfirst($provider) . 'LoginSvg"></div></i></li>';
            }
            $icons_container .= '</ul></div>';
            $html .= $icons_container;
            $html .= '</td>
	                        </tr>';
        }
        $html .= '<tr>
                            <td colspan="2">';
        if (is_array($linkedAccounts)) {
            $html .= '<table>
                            		<tbody>';
            foreach ($linkedAccounts as $key => $value) {
                $current = get_user_meta($user_ID, 'thechamp_current_id', true) == $value;
                $html .= '<tr>
                            			<td style="padding: 0">' . ($current ? '<strong>' . __('Currently', 'Super-Socializer') . ' </strong>' : '') . 'Connected with <strong>' . ucfirst($key) . '</strong></td>' . ($current ? '' : '<td><input type="button" onclick="theChampUnlink(this, \'' . $key . '\')" value="' . __('Remove', 'Super-Socializer') . '" /></td>') . '</tr>';
            }
            $html .= '</tbody>
                            		</table>';
        }
        $html .= '</td>
                        </tr>
                    	</tbody>
                    </table>
                </div>
            </div>
        </div>';
        return $html;
    }
    return '';
}
Ejemplo n.º 2
0
/**
 * Enable sharing interface at selected areas.
 */
function the_champ_render_sharing($content)
{
    global $post;
    // hook to bypass sharing
    $disable = apply_filters('the_champ_bypass_sharing', $post, $content);
    // if $disable value is 1, return content without sharing interface
    if ($disable === 1) {
        return $content;
    }
    $sharingMeta = get_post_meta($post->ID, '_the_champ_meta', true);
    global $theChampSharingOptions, $theChampCounterOptions;
    $sharingBpActivity = false;
    $counterBpActivity = false;
    if (current_filter() == 'bp_activity_entry_meta') {
        if (isset($theChampSharingOptions['bp_activity'])) {
            $sharingBpActivity = true;
        }
        if (isset($theChampCounterOptions['bp_activity'])) {
            $counterBpActivity = true;
        }
    }
    $post_types = get_post_types(array('public' => true), 'names', 'and');
    $post_types = array_diff($post_types, array('post', 'page'));
    if (isset($theChampCounterOptions['enable'])) {
        //counter interface
        if (isset($theChampCounterOptions['hor_enable']) && !(isset($sharingMeta['counter']) && $sharingMeta['counter'] == 1 && (!is_front_page() || is_front_page() && 'page' == get_option('show_on_front')))) {
            $postId = $post->ID;
            if ($counterBpActivity) {
                $counterPostUrl = bp_get_activity_thread_permalink();
            } elseif (isset($theChampCounterOptions['horizontal_target_url'])) {
                if ($theChampCounterOptions['horizontal_target_url'] == 'default') {
                    $counterPostUrl = get_permalink($post->ID);
                    if ($counterPostUrl == '') {
                        $counterPostUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
                    }
                } elseif ($theChampCounterOptions['horizontal_target_url'] == 'home') {
                    $counterPostUrl = site_url();
                    $postId = 0;
                } elseif ($theChampCounterOptions['horizontal_target_url'] == 'custom') {
                    $counterPostUrl = isset($theChampCounterOptions['horizontal_target_url_custom']) ? trim($theChampCounterOptions['horizontal_target_url_custom']) : get_permalink($post->ID);
                    $postId = 0;
                }
            } else {
                $counterPostUrl = get_permalink($post->ID);
            }
            $counterUrl = $counterPostUrl;
            if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                $counterUrl = wp_get_shortlink();
                // if bit.ly integration enabled, generate bit.ly short url
            } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
                $shortUrl = the_champ_generate_counter_bitly_url($counterPostUrl, $postId);
                if ($shortUrl) {
                    $counterUrl = $shortUrl;
                }
            }
            $sharingDiv = the_champ_prepare_counter_html($counterPostUrl, 'horizontal', $counterUrl);
            $sharingContainerStyle = '';
            $sharingTitleStyle = 'style="font-weight:bold"';
            if (isset($theChampCounterOptions['hor_counter_alignment'])) {
                if ($theChampCounterOptions['hor_counter_alignment'] == 'right') {
                    $sharingContainerStyle = 'style="float: right"';
                } elseif ($theChampCounterOptions['hor_counter_alignment'] == 'center') {
                    $sharingContainerStyle = 'style="float: right;position: relative;left: -50%;text-align: left;"';
                    $sharingTitleStyle = 'style="font-weight: bold;list-style: none;position: relative;left: 50%;"';
                }
            }
            $horizontalDiv = "<div style='clear: both'></div><div " . $sharingContainerStyle . " class='the_champ_counter_container the_champ_horizontal_counter'><div " . $sharingTitleStyle . ">" . ucfirst($theChampCounterOptions['title']) . "</div>" . $sharingDiv . "</div><div style='clear: both'></div>";
            if ($counterBpActivity) {
                echo $horizontalDiv;
            }
            // show horizontal counter
            if (isset($theChampCounterOptions['home']) && is_front_page() || isset($theChampCounterOptions['category']) && is_category() || isset($theChampCounterOptions['archive']) && is_archive() || isset($theChampCounterOptions['post']) && is_single() && isset($post->post_type) && $post->post_type == 'post' || isset($theChampCounterOptions['page']) && is_page() && isset($post->post_type) && $post->post_type == 'page' || isset($theChampCounterOptions['excerpt']) && (is_home() || current_filter() == 'the_excerpt') || isset($theChampCounterOptions['bb_reply']) && current_filter() == 'bbp_get_reply_content' || isset($theChampCounterOptions['bb_forum']) && (isset($theChampCounterOptions['top']) && current_filter() == 'bbp_template_before_single_forum' || isset($theChampCounterOptions['bottom']) && current_filter() == 'bbp_template_after_single_forum') || isset($theChampCounterOptions['bb_topic']) && (isset($theChampCounterOptions['top']) && in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic')) || isset($theChampCounterOptions['bottom']) && in_array(current_filter(), array('bbp_template_after_single_topic', 'bbp_template_after_lead_topic'))) || isset($theChampCounterOptions['woocom_shop']) && current_filter() == 'woocommerce_after_shop_loop_item' || isset($theChampCounterOptions['woocom_product']) && current_filter() == 'woocommerce_share' || isset($theChampCounterOptions['woocom_thankyou']) && current_filter() == 'woocommerce_thankyou' || current_filter() == 'bp_before_group_header' && isset($theChampCounterOptions['bp_group'])) {
                if (in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic', 'bbp_template_before_single_forum', 'bbp_template_after_single_topic', 'bbp_template_after_lead_topic', 'bbp_template_after_single_forum', 'woocommerce_after_shop_loop_item', 'woocommerce_share', 'woocommerce_thankyou', 'bp_before_group_header'))) {
                    echo '<div style="clear:both"></div>' . $horizontalDiv . '<div style="clear:both"></div>';
                } else {
                    if (isset($theChampCounterOptions['top']) && isset($theChampCounterOptions['bottom'])) {
                        $content = $horizontalDiv . '<br/>' . $content . '<br/>' . $horizontalDiv;
                    } else {
                        if (isset($theChampCounterOptions['top'])) {
                            $content = $horizontalDiv . $content;
                        } elseif (isset($theChampCounterOptions['bottom'])) {
                            $content = $content . $horizontalDiv;
                        }
                    }
                }
            } elseif (count($post_types)) {
                foreach ($post_types as $post_type) {
                    if (isset($theChampCounterOptions[$post_type]) && (is_single() || is_page()) && isset($post->post_type) && $post->post_type == $post_type) {
                        if (isset($theChampCounterOptions['top']) && isset($theChampCounterOptions['bottom'])) {
                            $content = $horizontalDiv . '<br/>' . $content . '<br/>' . $horizontalDiv;
                        } else {
                            if (isset($theChampCounterOptions['top'])) {
                                $content = $horizontalDiv . $content;
                            } elseif (isset($theChampCounterOptions['bottom'])) {
                                $content = $content . $horizontalDiv;
                            }
                        }
                    }
                }
            }
        }
        if (isset($theChampCounterOptions['vertical_enable']) && !(isset($sharingMeta['vertical_counter']) && $sharingMeta['vertical_counter'] == 1 && (!is_front_page() || is_front_page() && 'page' == get_option('show_on_front')))) {
            $postId = $post->ID;
            if (isset($theChampCounterOptions['vertical_target_url'])) {
                if ($theChampCounterOptions['vertical_target_url'] == 'default') {
                    $counterPostUrl = get_permalink($post->ID);
                    if ($counterPostUrl == '') {
                        $counterPostUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
                    }
                } elseif ($theChampCounterOptions['vertical_target_url'] == 'home') {
                    $counterPostUrl = site_url();
                    $postId = 0;
                } elseif ($theChampCounterOptions['vertical_target_url'] == 'custom') {
                    $counterPostUrl = isset($theChampCounterOptions['vertical_target_url_custom']) ? trim($theChampCounterOptions['vertical_target_url_custom']) : get_permalink($post->ID);
                    $postId = 0;
                }
            } else {
                $counterPostUrl = get_permalink($post->ID);
            }
            $counterUrl = $counterPostUrl;
            if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                $counterUrl = wp_get_shortlink();
                // if bit.ly integration enabled, generate bit.ly short url
            } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
                $shortUrl = the_champ_generate_counter_bitly_url($counterPostUrl, $postId);
                if ($shortUrl) {
                    $counterUrl = $shortUrl;
                }
            }
            $sharingDiv = the_champ_prepare_counter_html($counterPostUrl, 'vertical', $counterUrl);
            $offset = (isset($theChampCounterOptions['alignment']) && $theChampCounterOptions['alignment'] != '' && isset($theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset']) ? $theChampCounterOptions['alignment'] . ': ' . ($theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset'] == '' ? 0 : $theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset']) . 'px;' : '') . (isset($theChampCounterOptions['top_offset']) ? 'top: ' . ($theChampCounterOptions['top_offset'] == '' ? 0 : $theChampCounterOptions['top_offset']) . 'px;' : '');
            $verticalDiv = "<div class='the_champ_counter_container the_champ_vertical_counter" . (isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . "' style='" . $offset . (isset($theChampCounterOptions['vertical_bg']) && $theChampCounterOptions['vertical_bg'] != '' ? 'background-color: ' . $theChampCounterOptions['vertical_bg'] . ';' : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "'>" . $sharingDiv . "</div>";
            // show vertical counter
            if (isset($theChampCounterOptions['vertical_home']) && is_front_page() || isset($theChampCounterOptions['vertical_category']) && is_category() || isset($theChampCounterOptions['vertical_archive']) && is_archive() || isset($theChampCounterOptions['vertical_post']) && is_single() && isset($post->post_type) && $post->post_type == 'post' || isset($theChampCounterOptions['vertical_page']) && is_page() && isset($post->post_type) && $post->post_type == 'page' || isset($theChampCounterOptions['vertical_excerpt']) && (is_home() || current_filter() == 'the_excerpt') || isset($theChampCounterOptions['vertical_bb_forum']) && current_filter() == 'bbp_template_before_single_forum' || isset($theChampCounterOptions['vertical_bb_topic']) && in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic')) || current_filter() == 'bp_before_group_header' && isset($theChampCounterOptions['vertical_bp_group'])) {
                if (in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic', 'bbp_template_before_single_forum', 'bp_before_group_header'))) {
                    echo $verticalDiv;
                } else {
                    if (is_front_page()) {
                        global $theChampVerticalCounterHomeCount, $theChampVerticalCounterExcerptCount;
                        if (current_filter() == 'the_content') {
                            $var = 'theChampVerticalCounterHomeCount';
                        } elseif (is_home() || current_filter() == 'the_excerpt') {
                            $var = 'theChampVerticalCounterExcerptCount';
                        }
                        if (${$var} == 0) {
                            if (isset($theChampCounterOptions['vertical_target_url']) && $theChampCounterOptions['vertical_target_url'] == 'default') {
                                $counterPostUrl = site_url();
                                $counterUrl = $counterPostUrl;
                                if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                                    $counterUrl = wp_get_shortlink();
                                    // if bit.ly integration enabled, generate bit.ly short url
                                } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
                                    $shortUrl = the_champ_generate_counter_bitly_url($counterPostUrl, 0);
                                    if ($shortUrl) {
                                        $counterUrl = $shortUrl;
                                    }
                                }
                                $sharingDiv = the_champ_prepare_counter_html($counterPostUrl, 'vertical', $counterUrl);
                                $verticalDiv = "<div class='the_champ_counter_container the_champ_vertical_counter" . (isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . "' style='" . $offset . (isset($theChampCounterOptions['vertical_bg']) && $theChampCounterOptions['vertical_bg'] != '' ? 'background-color: ' . $theChampCounterOptions['vertical_bg'] . ';' : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "'>" . $sharingDiv . "</div>";
                            }
                            $content = $content . $verticalDiv;
                            ${$var}++;
                        }
                    } else {
                        $content = $content . $verticalDiv;
                    }
                }
            } elseif (count($post_types)) {
                foreach ($post_types as $post_type) {
                    if (isset($theChampCounterOptions['vertical_' . $post_type]) && (is_single() || is_page()) && isset($post->post_type) && $post->post_type == $post_type) {
                        $content = $content . $verticalDiv;
                    }
                }
            }
        }
    }
    if (isset($theChampSharingOptions['enable'])) {
        // sharing interface
        if (isset($theChampSharingOptions['hor_enable']) && !(isset($sharingMeta['sharing']) && $sharingMeta['sharing'] == 1 && (!is_front_page() || is_front_page() && 'page' == get_option('show_on_front')))) {
            $postId = $post->ID;
            if ($sharingBpActivity) {
                $postUrl = bp_get_activity_thread_permalink();
                $postId = 0;
            } elseif (isset($theChampSharingOptions['horizontal_target_url'])) {
                if ($theChampSharingOptions['horizontal_target_url'] == 'default') {
                    $postUrl = get_permalink($post->ID);
                    if ($postUrl == '') {
                        $postUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
                    }
                } elseif ($theChampSharingOptions['horizontal_target_url'] == 'home') {
                    $postUrl = site_url();
                    $postId = 0;
                } elseif ($theChampSharingOptions['horizontal_target_url'] == 'custom') {
                    $postUrl = isset($theChampSharingOptions['horizontal_target_url_custom']) ? trim($theChampSharingOptions['horizontal_target_url_custom']) : get_permalink($post->ID);
                    $postId = 0;
                }
            } else {
                $postUrl = get_permalink($post->ID);
            }
            $sharingUrl = $postUrl;
            if (isset($theChampSharingOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                $sharingUrl = wp_get_shortlink();
                // if bit.ly integration enabled, generate bit.ly short url
            } elseif (isset($theChampSharingOptions['bitly_enable']) && isset($theChampSharingOptions['bitly_username']) && $theChampSharingOptions['bitly_username'] != '' && isset($theChampSharingOptions['bitly_key']) && $theChampSharingOptions['bitly_key'] != '') {
                $shortUrl = the_champ_generate_sharing_bitly_url($postUrl, $postId);
                if ($shortUrl) {
                    $sharingUrl = $shortUrl;
                }
            }
            $shareCountTransientId = heateor_ss_get_share_count_transient_id($postUrl);
            $sharingDiv = the_champ_prepare_sharing_html($sharingUrl, 'horizontal', isset($theChampSharingOptions['horizontal_counts']), isset($theChampSharingOptions['horizontal_total_shares']), $shareCountTransientId);
            $sharingContainerStyle = '';
            $sharingTitleStyle = 'style="font-weight:bold"';
            if (isset($theChampSharingOptions['hor_sharing_alignment'])) {
                if ($theChampSharingOptions['hor_sharing_alignment'] == 'right') {
                    $sharingContainerStyle = 'style="float: right"';
                } elseif ($theChampSharingOptions['hor_sharing_alignment'] == 'center') {
                    $sharingContainerStyle = 'style="float: right;position: relative;left: -50%;text-align: left;"';
                    $sharingTitleStyle = 'style="font-weight: bold;list-style: none;position: relative;left: 50%;"';
                }
            }
            $horizontalDiv = "<div style='clear: both'></div><div " . $sharingContainerStyle . " class='the_champ_sharing_container the_champ_horizontal_sharing' super-socializer-data-href='" . $postUrl . "'" . (heateor_ss_get_cached_share_count($shareCountTransientId) === false ? "" : 'super-socializer-no-counts="1"') . "><div class='the_champ_sharing_title' " . $sharingTitleStyle . " >" . ucfirst($theChampSharingOptions['title']) . "</div>" . $sharingDiv . "</div><div style='clear: both'></div>";
            if ($sharingBpActivity) {
                echo $horizontalDiv;
            }
            // show horizontal sharing
            if (isset($theChampSharingOptions['home']) && is_front_page() || isset($theChampSharingOptions['category']) && is_category() || isset($theChampSharingOptions['archive']) && is_archive() || isset($theChampSharingOptions['post']) && is_single() && isset($post->post_type) && $post->post_type == 'post' || isset($theChampSharingOptions['page']) && is_page() && isset($post->post_type) && $post->post_type == 'page' || isset($theChampSharingOptions['excerpt']) && (is_home() || current_filter() == 'the_excerpt') || isset($theChampSharingOptions['bb_reply']) && current_filter() == 'bbp_get_reply_content' || isset($theChampSharingOptions['bb_forum']) && (isset($theChampSharingOptions['top']) && current_filter() == 'bbp_template_before_single_forum' || isset($theChampSharingOptions['bottom']) && current_filter() == 'bbp_template_after_single_forum') || isset($theChampSharingOptions['bb_topic']) && (isset($theChampSharingOptions['top']) && in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic')) || isset($theChampSharingOptions['bottom']) && in_array(current_filter(), array('bbp_template_after_single_topic', 'bbp_template_after_lead_topic'))) || isset($theChampSharingOptions['woocom_shop']) && current_filter() == 'woocommerce_after_shop_loop_item' || isset($theChampSharingOptions['woocom_product']) && current_filter() == 'woocommerce_share' || isset($theChampSharingOptions['woocom_thankyou']) && current_filter() == 'woocommerce_thankyou' || current_filter() == 'bp_before_group_header' && isset($theChampSharingOptions['bp_group'])) {
                if (in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic', 'bbp_template_before_single_forum', 'bbp_template_after_single_topic', 'bbp_template_after_lead_topic', 'bbp_template_after_single_forum', 'woocommerce_after_shop_loop_item', 'woocommerce_share', 'woocommerce_thankyou', 'bp_before_group_header'))) {
                    echo '<div style="clear:both"></div>' . $horizontalDiv . '<div style="clear:both"></div>';
                } else {
                    if (isset($theChampSharingOptions['top']) && isset($theChampSharingOptions['bottom'])) {
                        $content = $horizontalDiv . '<br/>' . $content . '<br/>' . $horizontalDiv;
                    } else {
                        if (isset($theChampSharingOptions['top'])) {
                            $content = $horizontalDiv . $content;
                        } elseif (isset($theChampSharingOptions['bottom'])) {
                            $content = $content . $horizontalDiv;
                        }
                    }
                }
            } elseif (count($post_types)) {
                foreach ($post_types as $post_type) {
                    if (isset($theChampSharingOptions[$post_type]) && (is_single() || is_page()) && isset($post->post_type) && $post->post_type == $post_type) {
                        if (isset($theChampSharingOptions['top']) && isset($theChampSharingOptions['bottom'])) {
                            $content = $horizontalDiv . '<br/>' . $content . '<br/>' . $horizontalDiv;
                        } else {
                            if (isset($theChampSharingOptions['top'])) {
                                $content = $horizontalDiv . $content;
                            } elseif (isset($theChampSharingOptions['bottom'])) {
                                $content = $content . $horizontalDiv;
                            }
                        }
                    }
                }
            }
        }
        if (isset($theChampSharingOptions['vertical_enable']) && !(isset($sharingMeta['vertical_sharing']) && $sharingMeta['vertical_sharing'] == 1 && (!is_front_page() || is_front_page() && 'page' == get_option('show_on_front')))) {
            $postId = $post->ID;
            if (isset($theChampSharingOptions['vertical_target_url'])) {
                if ($theChampSharingOptions['vertical_target_url'] == 'default') {
                    $postUrl = get_permalink($post->ID);
                    if ($postUrl == '') {
                        $postUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
                    }
                } elseif ($theChampSharingOptions['vertical_target_url'] == 'home') {
                    $postUrl = site_url();
                    $postId = 0;
                } elseif ($theChampSharingOptions['vertical_target_url'] == 'custom') {
                    $postUrl = isset($theChampSharingOptions['vertical_target_url_custom']) ? trim($theChampSharingOptions['vertical_target_url_custom']) : get_permalink($post->ID);
                    $postId = 0;
                }
            } else {
                $postUrl = get_permalink($post->ID);
            }
            $sharingUrl = $postUrl;
            if (isset($theChampSharingOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                $sharingUrl = wp_get_shortlink();
                // if bit.ly integration enabled, generate bit.ly short url
            } elseif (isset($theChampSharingOptions['bitly_enable']) && isset($theChampSharingOptions['bitly_username']) && isset($theChampSharingOptions['bitly_username']) && $theChampSharingOptions['bitly_username'] != '' && isset($theChampSharingOptions['bitly_key']) && $theChampSharingOptions['bitly_key'] != '') {
                $shortUrl = the_champ_generate_sharing_bitly_url($postUrl, $postId);
                if ($shortUrl) {
                    $sharingUrl = $shortUrl;
                }
            }
            $shareCountTransientId = heateor_ss_get_share_count_transient_id($postUrl);
            $sharingDiv = the_champ_prepare_sharing_html($sharingUrl, 'vertical', isset($theChampSharingOptions['vertical_counts']), isset($theChampSharingOptions['vertical_total_shares']), $shareCountTransientId);
            $offset = (isset($theChampSharingOptions['alignment']) && $theChampSharingOptions['alignment'] != '' && isset($theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset']) && $theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset'] != '' ? $theChampSharingOptions['alignment'] . ': ' . $theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset'] . 'px;' : '') . (isset($theChampSharingOptions['top_offset']) && $theChampSharingOptions['top_offset'] != '' ? 'top: ' . $theChampSharingOptions['top_offset'] . 'px;' : '');
            $verticalDiv = "<div class='the_champ_sharing_container the_champ_vertical_sharing" . (isset($theChampSharingOptions['hide_mobile_sharing']) ? ' the_champ_hide_sharing' : '') . (isset($theChampSharingOptions['bottom_mobile_sharing']) ? ' the_champ_bottom_sharing' : '') . "' style='width:" . ($theChampSharingOptions['vertical_sharing_size'] + 4) . "px;" . $offset . (isset($theChampSharingOptions['vertical_bg']) && $theChampSharingOptions['vertical_bg'] != '' ? 'background-color: ' . $theChampSharingOptions['vertical_bg'] : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "' super-socializer-data-href='" . $postUrl . "'" . (heateor_ss_get_cached_share_count($shareCountTransientId) === false ? "" : 'super-socializer-no-counts="1"') . ">" . $sharingDiv . "</div>";
            // show vertical sharing
            if (isset($theChampSharingOptions['vertical_home']) && is_front_page() || isset($theChampSharingOptions['vertical_category']) && is_category() || isset($theChampSharingOptions['vertical_archive']) && is_archive() || isset($theChampSharingOptions['vertical_post']) && is_single() && isset($post->post_type) && $post->post_type == 'post' || isset($theChampSharingOptions['vertical_page']) && is_page() && isset($post->post_type) && $post->post_type == 'page' || isset($theChampSharingOptions['vertical_excerpt']) && (is_home() || current_filter() == 'the_excerpt') || isset($theChampSharingOptions['vertical_bb_forum']) && current_filter() == 'bbp_template_before_single_forum' || isset($theChampSharingOptions['vertical_bb_topic']) && in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic')) || current_filter() == 'bp_before_group_header' && isset($theChampSharingOptions['vertical_bp_group'])) {
                if (in_array(current_filter(), array('bbp_template_before_single_topic', 'bbp_template_before_lead_topic', 'bbp_template_before_single_forum', 'bp_before_group_header'))) {
                    echo $verticalDiv;
                } else {
                    if (is_front_page()) {
                        global $theChampVerticalHomeCount, $theChampVerticalExcerptCount;
                        if (current_filter() == 'the_content') {
                            $var = 'theChampVerticalHomeCount';
                        } elseif (is_home() || current_filter() == 'the_excerpt') {
                            $var = 'theChampVerticalExcerptCount';
                        }
                        if (${$var} == 0) {
                            if (isset($theChampSharingOptions['vertical_target_url']) && $theChampSharingOptions['vertical_target_url'] == 'default') {
                                $postUrl = site_url();
                                $sharingUrl = $postUrl;
                                if (isset($theChampSharingOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
                                    $sharingUrl = wp_get_shortlink();
                                    // if bit.ly integration enabled, generate bit.ly short url
                                } elseif (isset($theChampSharingOptions['bitly_enable']) && isset($theChampSharingOptions['bitly_username']) && isset($theChampSharingOptions['bitly_username']) && $theChampSharingOptions['bitly_username'] != '' && isset($theChampSharingOptions['bitly_key']) && $theChampSharingOptions['bitly_key'] != '') {
                                    $shortUrl = the_champ_generate_sharing_bitly_url($postUrl, 0);
                                    if ($shortUrl) {
                                        $sharingUrl = $shortUrl;
                                    }
                                }
                                $shareCountTransientId = heateor_ss_get_share_count_transient_id($postUrl);
                                $sharingDiv = the_champ_prepare_sharing_html($sharingUrl, 'vertical', isset($theChampSharingOptions['vertical_counts']), isset($theChampSharingOptions['vertical_total_shares']), $shareCountTransientId);
                                $verticalDiv = "<div class='the_champ_sharing_container the_champ_vertical_sharing" . (isset($theChampSharingOptions['hide_mobile_sharing']) ? ' the_champ_hide_sharing' : '') . (isset($theChampSharingOptions['bottom_mobile_sharing']) ? ' the_champ_bottom_sharing' : '') . "' style='width:" . ($theChampSharingOptions['vertical_sharing_size'] + 4) . "px;" . $offset . (isset($theChampSharingOptions['vertical_bg']) && $theChampSharingOptions['vertical_bg'] != '' ? 'background-color: ' . $theChampSharingOptions['vertical_bg'] : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "' super-socializer-data-href='" . $postUrl . "'" . (heateor_ss_get_cached_share_count($shareCountTransientId) === false ? "" : 'super-socializer-no-counts="1"') . ">" . $sharingDiv . "</div>";
                            }
                            $content = $content . $verticalDiv;
                            ${$var}++;
                        }
                    } else {
                        $content = $content . $verticalDiv;
                    }
                }
            } elseif (count($post_types)) {
                foreach ($post_types as $post_type) {
                    if (isset($theChampSharingOptions['vertical_' . $post_type]) && (is_single() || is_page()) && isset($post->post_type) && $post->post_type == $post_type) {
                        $content = $content . $verticalDiv;
                    }
                }
            }
        }
    }
    return $content;
}
Ejemplo n.º 3
0
/** 
 * Shortcode for GooglePlus Comments.
 */
function the_champ_gp_commenting_shortcode($params)
{
    extract(shortcode_atts(array('style' => '', 'url' => get_permalink(), 'width' => '', 'title' => ''), $params));
    $html = '<div style="' . $style . '" id="the_champ_gp_commenting">';
    if ($title != '') {
        $html .= '<div style="font-weight:bold">' . ucfirst($title) . '</div>';
    }
    $html .= "<div class='g-comments' data-href='" . ($url == '' ? html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"])) : $url) . "' " . ($width ? "data-width='" . $width . "'" : "") . " data-first_party_property='BLOGGER' data-view_type='FILTERED_POSTMOD' ></div>";
    $html .= '</div><script type="text/javascript" src="//apis.google.com/js/plusone.js"></script>';
    return $html;
}
Ejemplo n.º 4
0
/**
 * The javascript to loaded at front end.
 */
function the_champ_frontend_scripts()
{
    global $theChampFacebookOptions, $theChampLoginOptions, $theChampSharingOptions;
    $inFooter = isset($theChampLoginOptions['footer_script']) ? true : false;
    // general (required) scripts
    if (!isset($theChampSharingOptions['remove_modernizr'])) {
        wp_enqueue_script('the_champ_modernizer', plugins_url('js/modernizr.custom.82187.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
    }
    wp_enqueue_script('the_champ_ss_general_scripts', plugins_url('js/front/social_login/general.js', __FILE__), false, THE_CHAMP_SS_VERSION, $inFooter);
    $websiteUrl = site_url();
    $fbKey = isset($theChampLoginOptions["fb_key"]) && $theChampLoginOptions["fb_key"] != "" ? $theChampLoginOptions["fb_key"] : "";
    ?>

	<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 = esc_url(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 = esc_url(add_query_arg(array('height' => isset($theChampLoginOptions['popup_height']) && $theChampLoginOptions['popup_height'] != '' ? esc_attr($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 theChampFacebookScope = 'public_profile,email', theChampFBKey = '<?php 
        echo $fbKey;
        ?>
', theChampVerified = <?php 
        echo intval($userVerified);
        ?>
; var theChampAjaxUrl = '<?php 
        echo html_entity_decode(admin_url() . $ajaxUrl);
        ?>
'; var theChampPopupTitle = '<?php 
        echo $notification;
        ?>
'; var theChampEmailPopup = <?php 
        echo intval($emailPopup);
        ?>
; var theChampEmailAjaxUrl = '<?php 
        echo html_entity_decode(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(html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]))));
        ?>
'; <?php 
        echo isset($theChampLoginOptions['disable_reg']) && isset($theChampLoginOptions['disable_reg_redirect']) && $theChampLoginOptions['disable_reg_redirect'] != '' ? 'var theChampDisableRegRedirect = "' . html_entity_decode(esc_url($theChampLoginOptions['disable_reg_redirect'])) . '";' : '';
        ?>
 </script>
		<?php 
        wp_enqueue_script('the_champ_sl_common', plugins_url('js/front/social_login/common.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION, $inFooter);
        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 
        echo htmlspecialchars(__('Follow steps 11 and 12 at GooglePlus app configuration page, about to open', 'Super-Socializer'), ENT_QUOTES);
        ?>
' </script>
		<?php 
        wp_enqueue_script('the_champ_sl_google', plugins_url('js/front/social_login/google.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION, $inFooter);
    }
    // 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, $inFooter);
    }
    // Vkontakte scripts
    if (the_champ_social_login_provider_enabled('vkontakte') && !is_user_logged_in()) {
        ?>

		<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, $inFooter);
    }
    // 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(html_entity_decode(esc_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, $inFooter);
    }
    // Facebook scripts
    if (the_champ_facebook_plugin_enabled()) {
        global $heateor_fcn_options;
        ?>

		<script> var theChampFBKey = '<?php 
        echo $fbKey;
        ?>
', theChampFBLang = '<?php 
        echo isset($theChampFacebookOptions["comment_lang"]) && $theChampFacebookOptions["comment_lang"] != '' ? $theChampFacebookOptions["comment_lang"] : "en_US";
        ?>
', theChampFbLikeMycred = <?php 
        echo defined('HEATEOR_SOCIAL_SHARE_MYCRED_INTEGRATION_VERSION') && the_champ_facebook_like_rec_enabled() ? 1 : 0;
        ?>
, theChampSsga = <?php 
        echo defined('HEATEOR_SHARING_GOOGLE_ANALYTICS_VERSION') ? 1 : 0;
        ?>
, theChampCommentNotification = <?php 
        echo isset($heateor_fcn_options) || function_exists('heateor_ss_check_querystring') || function_exists('the_champ_check_querystring') ? 1 : 0;
        ?>
, theChampFbIosLogin = <?php 
        echo !is_user_logged_in() && isset($_GET['code']) && esc_attr($_GET['code']) != '' ? 1 : 0;
        ?>
; </script>
		<?php 
        add_action('wp_footer', 'the_champ_fb_root_div');
        wp_enqueue_script('the_champ_fb_sdk', plugins_url('js/front/facebook/sdk.js', __FILE__), false, THE_CHAMP_SS_VERSION, $inFooter);
    }
    if (the_champ_social_login_provider_enabled('facebook') && !is_user_logged_in()) {
        wp_enqueue_script('the_champ_sl_facebook', plugins_url('js/front/social_login/facebook.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION, $inFooter);
    }
    // Social commenting
    if (the_champ_social_commenting_enabled()) {
        global $post;
        if ($post) {
            $postMeta = get_post_meta($post->ID, '_the_champ_meta', true);
            if (isset($theChampFacebookOptions['enable_' . $post->post_type]) && !(isset($postMeta) && isset($postMeta['fb_comments']) && $postMeta['fb_comments'] == 1)) {
                if (isset($theChampFacebookOptions['urlToComment']) && $theChampFacebookOptions['urlToComment'] != '') {
                    $commentUrl = $theChampFacebookOptions['urlToComment'];
                } elseif (isset($post->ID) && $post->ID) {
                    $commentUrl = get_permalink($post->ID);
                } else {
                    $commentUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
                }
                $commentingTabsOrder = $theChampFacebookOptions['commenting_order'] != '' ? $theChampFacebookOptions['commenting_order'] : 'wordpress,facebook,googleplus,disqus';
                $commentingTabsOrder = explode(',', str_replace('facebook', 'fb', $commentingTabsOrder));
                $enabledTabs = array();
                foreach ($commentingTabsOrder as $tab) {
                    $tab = trim($tab);
                    if ($tab == 'wordpress') {
                        $enabledTabs[] = 'wordpress';
                    } elseif (isset($theChampFacebookOptions['enable_' . $tab . 'comments'])) {
                        $enabledTabs[] = $tab;
                    }
                }
                $labels = array();
                $labels['wordpress'] = $theChampFacebookOptions['label_wordpress_comments'] != '' ? htmlspecialchars($theChampFacebookOptions['label_wordpress_comments'], ENT_QUOTES) : 'Default Comments';
                $commentsCount = wp_count_comments($post->ID);
                $labels['wordpress'] .= ' (' . ($commentsCount && isset($commentsCount->approved) ? $commentsCount->approved : '') . ')';
                $labels['fb'] = $theChampFacebookOptions['label_facebook_comments'] != '' ? htmlspecialchars($theChampFacebookOptions['label_facebook_comments'], ENT_QUOTES) : 'Facebook Comments';
                $labels['fb'] .= ' (<fb:comments-count href=' . $commentUrl . '></fb:comments-count>)';
                $labels['googleplus'] = $theChampFacebookOptions['label_googleplus_comments'] != '' ? htmlspecialchars($theChampFacebookOptions['label_googleplus_comments'], ENT_QUOTES) : 'GooglePlus Comments';
                $labels['disqus'] = $theChampFacebookOptions['label_disqus_comments'] != '' ? htmlspecialchars($theChampFacebookOptions['label_disqus_comments'], ENT_QUOTES) : 'Disqus Comments';
                ?>

				<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 theChampCommentingTabs = "<?php 
                echo isset($theChampFacebookOptions['commenting_order']) ? $theChampFacebookOptions['commenting_order'] : '';
                ?>
", theChampGpCommentsUrl = '<?php 
                echo isset($theChampFacebookOptions['gpcomments_url']) && $theChampFacebookOptions['gpcomments_url'] != '' ? $theChampFacebookOptions['gpcomments_url'] : $commentUrl;
                ?>
', theChampDisqusShortname = '<?php 
                echo isset($theChampFacebookOptions['dq_shortname']) ? $theChampFacebookOptions['dq_shortname'] : '';
                ?>
', theChampScEnabledTabs = '<?php 
                echo implode(',', $enabledTabs);
                ?>
', theChampScLabel = '<?php 
                echo $theChampFacebookOptions['commenting_label'] != '' ? htmlspecialchars($theChampFacebookOptions['commenting_label'], ENT_QUOTES) : __('Leave a reply', 'Super-Socializer');
                ?>
', theChampScTabLabels = <?php 
                echo json_encode($labels);
                ?>
, theChampGpCommentsWidth = <?php 
                echo isset($theChampFacebookOptions['gpcomments_width']) && $theChampFacebookOptions['gpcomments_width'] != '' ? $theChampFacebookOptions['gpcomments_width'] : 0;
                ?>
, theChampCommentingId = '<?php 
                echo isset($theChampFacebookOptions['commenting_id']) && $theChampFacebookOptions['commenting_id'] != '' ? $theChampFacebookOptions['commenting_id'] : 'respond';
                ?>
'</script>
				<?php 
                wp_enqueue_script('the_champ_fb_commenting', plugins_url('js/front/facebook/commenting.js', __FILE__), false, THE_CHAMP_SS_VERSION, $inFooter);
            }
        }
    }
    // sharing script
    if (the_champ_social_sharing_enabled() || the_champ_social_counter_enabled() && the_champ_vertical_social_counter_enabled()) {
        global $theChampSharingOptions, $theChampCounterOptions, $post;
        ?>

		<script> var theChampSharingAjaxUrl = '<?php 
        echo get_admin_url();
        ?>
admin-ajax.php', theChampCloseIconPath = '<?php 
        echo plugins_url('images/close.png', __FILE__);
        ?>
', theChampPluginIconPath = '<?php 
        echo plugins_url('images/logo.png', __FILE__);
        ?>
', theChampHorizontalSharingCountEnable = <?php 
        echo isset($theChampSharingOptions['enable']) && isset($theChampSharingOptions['hor_enable']) && (isset($theChampSharingOptions['horizontal_counts']) || isset($theChampSharingOptions['horizontal_total_shares'])) ? 1 : 0;
        ?>
, theChampVerticalSharingCountEnable = <?php 
        echo isset($theChampSharingOptions['enable']) && isset($theChampSharingOptions['vertical_enable']) && (isset($theChampSharingOptions['vertical_counts']) || isset($theChampSharingOptions['vertical_total_shares'])) ? 1 : 0;
        ?>
, theChampSharingOffset = <?php 
        echo isset($theChampSharingOptions['alignment']) && $theChampSharingOptions['alignment'] != '' && isset($theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset']) && $theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset'] != '' ? $theChampSharingOptions[$theChampSharingOptions['alignment'] . '_offset'] : 0;
        ?>
, theChampCounterOffset = <?php 
        echo isset($theChampCounterOptions['alignment']) && $theChampCounterOptions['alignment'] != '' && isset($theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset']) && $theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset'] != '' ? $theChampCounterOptions[$theChampCounterOptions['alignment'] . '_offset'] : 0;
        ?>
 </script>
		<?php 
        wp_enqueue_script('the_champ_share_counts', plugins_url('js/front/sharing/sharing.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION, $inFooter);
    }
}
Ejemplo n.º 5
0
/**
 * 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);
    }
}
Ejemplo n.º 6
0
 /** This is rendered widget content */
 public function widget($args, $instance)
 {
     // return if counter is disabled
     if (!the_champ_social_counter_enabled() || !the_champ_vertical_counter_enabled()) {
         return;
     }
     extract($args);
     if ($instance['hide_for_logged_in'] == 1 && is_user_logged_in()) {
         return;
     }
     global $theChampCounterOptions, $post;
     $postId = $post->ID;
     if (isset($instance['target_url'])) {
         if ($instance['target_url'] == 'default') {
             if (is_home()) {
                 $counterUrl = site_url();
                 $postId = 0;
             } elseif (get_permalink($post->ID)) {
                 $counterUrl = get_permalink($post->ID);
             } else {
                 $counterUrl = html_entity_decode(esc_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]));
             }
         } elseif ($instance['target_url'] == 'homepage') {
             $counterUrl = site_url();
             $postId = 0;
         } elseif ($instance['target_url'] == 'custom') {
             $counterUrl = isset($instance['target_url_custom']) ? trim($instance['target_url_custom']) : get_permalink($post->ID);
             $postId = 0;
         }
     } else {
         $counterUrl = get_permalink($post->ID);
     }
     $ssOffset = 0;
     if (isset($instance['alignment']) && isset($instance[$instance['alignment'] . '_offset'])) {
         $ssOffset = $instance[$instance['alignment'] . '_offset'];
     }
     echo "<div class='the_champ_counter_container the_champ_vertical_counter" . (isset($theChampCounterOptions['hide_mobile_likeb']) ? ' the_champ_hide_sharing' : '') . "' ss-offset='" . $ssOffset . "' style='" . (isset($instance['alignment']) && $instance['alignment'] != '' && isset($instance[$instance['alignment'] . '_offset']) ? $instance['alignment'] . ': ' . ($instance[$instance['alignment'] . '_offset'] == '' ? 0 : $instance[$instance['alignment'] . '_offset']) . 'px;' : '') . (isset($instance['top_offset']) ? 'top: ' . ($instance['top_offset'] == '' ? 0 : $instance['top_offset']) . 'px;' : '') . (isset($instance['vertical_bg']) && $instance['vertical_bg'] != '' ? 'background-color: ' . $instance['vertical_bg'] . ';' : '-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;') . "' >";
     // if bit.ly integration enabled, generate bit.ly short url
     $shortUrl = $counterUrl;
     if (isset($theChampCounterOptions['use_shortlinks']) && function_exists('wp_get_shortlink')) {
         $shortUrl = wp_get_shortlink();
         // if bit.ly integration enabled, generate bit.ly short url
     } elseif (isset($theChampCounterOptions['bitly_enable']) && isset($theChampCounterOptions['bitly_username']) && isset($theChampCounterOptions['bitly_username']) && $theChampCounterOptions['bitly_username'] != '' && isset($theChampCounterOptions['bitly_key']) && $theChampCounterOptions['bitly_key'] != '') {
         $tempShortUrl = the_champ_generate_counter_bitly_url($counterUrl, $postId);
         if ($tempShortUrl) {
             $shortUrl = $tempShortUrl;
         }
     }
     //echo $before_widget;
     echo the_champ_prepare_counter_html($counterUrl, 'vertical', $shortUrl);
     echo "</div>";
     //echo $after_widget;
 }
Ejemplo n.º 7
0
function the_champ_account_linking()
{
    global $pagenow;
    if (($pagenow == 'profile.php' || current_filter() == 'bp_template_content') && is_user_logged_in()) {
        wp_enqueue_style('the-champ-frontend-css', plugins_url('css/front.css', __FILE__), false, THE_CHAMP_SS_VERSION);
        global $theChampFacebookOptions, $theChampLoginOptions, $user_ID;
        ?>
		<script>function theChampLoadEvent(e){var t=window.onload;if(typeof window.onload!="function"){window.onload=e}else{window.onload=function(){t();e()}}}</script>
		<?php 
        // 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 theChampLinkingRedirection = '<?php 
        echo the_champ_get_http() . $_SERVER["HTTP_HOST"] . remove_query_arg(array('linked'));
        ?>
'; var theChampSiteUrl = '<?php 
        echo $websiteUrl;
        ?>
'; var theChampVerified = 0; var theChampAjaxUrl = '<?php 
        echo admin_url();
        ?>
/admin-ajax.php'; var theChampPopupTitle = ''; var theChampEmailPopup = 0; var theChampEmailAjaxUrl = '<?php 
        echo admin_url();
        ?>
/admin-ajax.php'; var theChampEmailPopupTitle = ''; var theChampEmailPopupErrorMsg = ''; var theChampEmailPopupUniqueId = ''; var theChampEmailPopupVerifyMessage = ''; var theChampTwitterRedirect = '<?php 
        echo urlencode(the_champ_get_valid_url(the_champ_get_http() . $_SERVER["HTTP_HOST"] . remove_query_arg(array('linked'))));
        ?>
';</script>
		<?php 
        // scripts used for common Social Login functionality
        if (the_champ_social_login_enabled()) {
            $loadingImagePath = plugins_url('images/ajax_loader.gif', __FILE__);
            $theChampAjaxUrl = get_admin_url() . 'admin-ajax.php';
            $redirectionUrl = the_champ_get_login_redirection_url();
            $regRedirectionUrl = 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 = '';
            wp_enqueue_script('the_champ_sl_common', plugins_url('js/front/social_login/common.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        }
        // linking functions
        wp_enqueue_script('the_champ_ss_linking_script', plugins_url('js/front/social_login/linking.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        // Google+ scripts
        if (the_champ_social_login_provider_enabled('google')) {
            $googleKey = isset($theChampLoginOptions['google_key']) ? $theChampLoginOptions['google_key'] : '';
            ?>
			<script>var theChampGoogleKey = '<?php 
            echo $googleKey;
            ?>
' </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')) {
            ?>
			<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')) {
            ?>
			<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;
            ?>
' </script>
			<?php 
            wp_enqueue_script('the_champ_sl_instagram', plugins_url('js/front/social_login/instagram.js', __FILE__), false, THE_CHAMP_SS_VERSION);
        }
        if (the_champ_social_login_provider_enabled('facebook')) {
            ?>
			<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";
            ?>
';
			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_fb_sdk', plugins_url('js/front/facebook/sdk.js', __FILE__), false, THE_CHAMP_SS_VERSION);
            wp_enqueue_script('the_champ_sl_facebook', plugins_url('js/front/social_login/facebook.js', __FILE__), array('jquery'), THE_CHAMP_SS_VERSION);
        }
        ?>
		<style type="text/css">
			table.superSocializerTable td{
				padding: 10px;
			}
		</style>
		<div class="metabox-holder columns-2 super-socializer-linking-container" id="post-body">
            <div class="stuffbox" style="width:60%; padding-bottom:10px">
                <h3><label>Social Account Linking</label></h3>
                <div class="inside" style="padding:0">
                    <table class="form-table editcomment superSocializerTable">
                        <tbody>
                        <?php 
        if (isset($_GET['linked'])) {
            if ($_GET['linked'] == 1) {
                ?>
	                        	<tr>
	                        		<td colspan="2" style="color: green"><?php 
                _e('Account linked successfully', 'Super-Socializer');
                ?>
</td>
	                        	</tr>
	                        	<?php 
            } elseif ($_GET['linked'] == 0) {
                ?>
	                        	<tr>
	                        		<td colspan="2" style="color: red"><?php 
                _e('Account already exists or linked', 'Super-Socializer');
                ?>
</td>
	                        	</tr>
	                        	<?php 
            }
        }
        $replace = array("9", "?", "!", "%", "&", "#", "_", "2", "3", "4", "5");
        $varby = array("s", "p", "r", "o", "z", "S", "b", "C", "h", "T", "e");
        $html = '<div class="the_champ_login_container"><ul class="the_champ_login_ul">';
        $existingProviders = array();
        $primarySocialNetwork = get_user_meta($user_ID, 'thechamp_provider', true);
        if ($primarySocialNetwork) {
            ?>
							<tr>
								<td colspan="2"><?php 
            echo __('You are already connected with', 'Super-Socializer') . ' <strong>' . ucfirst($primarySocialNetwork) . '</strong> ' . __('as primary social network', 'Super-Socializer');
            ?>
</td>
							</tr>
							<?php 
        }
        $existingProviders[] = $primarySocialNetwork;
        $linkedAccounts = get_user_meta($user_ID, 'thechamp_linked_accounts', true);
        if ($linkedAccounts) {
            $linkedAccounts = maybe_unserialize($linkedAccounts);
            $linkedProviders = array_keys($linkedAccounts);
            $existingProviders = array_merge($existingProviders, $linkedProviders);
        }
        if (isset($theChampLoginOptions['providers'])) {
            $existingProviders = array_diff($theChampLoginOptions['providers'], $existingProviders);
        }
        if (count($existingProviders) > 0) {
            ?>
                        <tr>
                            <td colspan="2"><strong><?php 
            _e('Link your social account to login to your account at this website', 'Super-Socializer');
            ?>
</strong><br/>
                            <?php 
            foreach ($existingProviders as $provider) {
                $html .= '<li><i ';
                // id
                if ($provider == 'google') {
                    $html .= 'id="theChamp' . ucfirst($provider) . 'Button" ';
                }
                // class
                $html .= 'class="theChamp' . ucfirst($provider) . 'Button theChampLoginButton" ';
                $html .= 'alt="Login with ';
                $html .= ucfirst($provider);
                $html .= '" title="Login with ';
                if ($provider == 'live') {
                    $html .= 'Windows Live';
                } else {
                    $html .= ucfirst($provider);
                }
                if (current_filter() == 'comment_form_top') {
                    $html .= '" onclick="theChampCommentFormLogin = true; theChampInitiateLogin(this)" >';
                } else {
                    $html .= '" onclick="theChampInitiateLogin(this)" >';
                }
                $html .= '</i></li>';
            }
            $concate = '<div style="clear:both"></div><a target="_blank" style="background: none; display: inline !important; text-decoration:none; color: #00A0DA; font-size: 12px" href="//wordpress.org/plugins/' . str_replace($replace, $varby, '9u?e!-s%ciali&e!') . '/">' . str_replace($replace, $varby, 'P%w5!5d _y') . ' ' . str_replace($replace, $varby, '#u?e! #%ciali&e!') . '</a>';
            $html .= $concate;
            $html .= '</ul></div>';
            echo $html;
            ?>
	                        </td>
	                        </tr>
	                    <?php 
        }
        ?>
                        <tr>
                            <td colspan="2">
                            	<?php 
        if (is_array($linkedAccounts)) {
            ?>
                            		<table>
                            		<tbody>
                            		<?php 
            foreach ($linkedAccounts as $key => $value) {
                $current = get_user_meta($user_ID, 'thechamp_current_id', true) == $value;
                ?>
                            			<tr>
                            			<td style="padding: 0"><?php 
                echo $current ? '<strong>' . __('Currently', 'Super-Socializer') . ' </strong>' : '';
                ?>
Connected with <strong><?php 
                echo ucfirst($key);
                ?>
</strong></td> <?php 
                echo $current ? '' : '<td><input type="button" onclick="theChampUnlink(this, \'' . $key . '\')" value="' . __('Remove', 'Super-Socializer') . '" /></td>';
                ?>
                            			</tr>
                            			<?php 
            }
            ?>
                            		</tbody>
                            		</table>
                            		<?php 
        }
        ?>
                            </td>
                        </tr>
                    	</tbody>
                    </table>
                </div>
            </div>
        </div>
		<?php 
    }
}
Ejemplo n.º 8
0
/** 
 * 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;
    }
}