예제 #1
0
function swp_flipboard_button_html($array)
{
    if (isset($array['options']['newOrderOfIcons']['flipboard']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['flipboard'])) {
        // Collect the Title
        $title = get_post_meta($array['postID'], 'nc_ogTitle', true);
        if (!$title) {
            $title = get_the_title();
        }
        // Collect the Description
        $description = get_post_meta($array['postID'], 'nc_ogDescription', true);
        if (!$description) {
            $description = swp_get_excerpt_by_id($array['postID']);
        }
        ++$array['count'];
        $array['resource']['flipboard'] = '<div class="nc_tweetContainer swp_flipboard" data-id="' . $array['count'] . '" data-network="flipboard">';
        $link = urlencode(urldecode(swp_process_url($array['url'], 'flipboard', $array['postID'])));
        $array['resource']['flipboard'] .= '<a rel="nofollow" href="https://share.flipboard.com/bookmarklet/popout?v=2&title=Tools%20-%20Flipboard&url=' . $link . '" data-link="https://share.flipboard.com/bookmarklet/popout?v=2&title=Tools%20-%20Flipboard&url=' . $link . '" class="nc_tweet flipboard">';
        $array['resource']['flipboard'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-flipboard"></i><span class="swp_share"> ' . __('Flip', 'social-warfare') . '</span></span></span></span>';
        $array['resource']['flipboard'] .= '</a>';
        $array['resource']['flipboard'] .= '</div>';
    }
    return $array;
}
예제 #2
0
파일: email.php 프로젝트: arobbins/sblog
function swp_email_button_html($array)
{
    if (isset($array['options']['newOrderOfIcons']['email']) && !isset($array['buttons']) || isset($array['buttons']) && isset($array['buttons']['email'])) {
        // Collect the Title
        $title = get_post_meta($array['postID'], 'nc_ogTitle', true);
        if (!$title) {
            $title = get_the_title();
        }
        // Collect the Description
        $description = get_post_meta($array['postID'], 'nc_ogDescription', true);
        if (!$description) {
            $description = swp_get_excerpt_by_id($array['postID']);
        }
        ++$array['count'];
        $array['resource']['email'] = '<div class="nc_tweetContainer swp_email" data-id="' . $array['count'] . '" data-network="email">';
        $link = urlencode(urldecode(swp_process_url($array['url'], 'email', $array['postID'])));
        $array['resource']['email'] .= '<a rel="nofollow" href="mailto:?subject=' . str_replace('&amp;', '%26', rawurlencode(html_entity_decode($title, ENT_COMPAT, 'UTF-8'))) . '&body=' . str_replace('&amp;', '%26', rawurlencode(html_entity_decode($description, ENT_COMPAT, 'UTF-8'))) . rawurlencode(' Read here: ') . $link . '" class="nc_tweet">';
        $array['resource']['email'] .= '<span class="swp_count swp_hide"><span class="iconFiller"><span class="spaceManWilly"><i class="sw sw-email"></i><span class="swp_share"> ' . __('Email', 'social-warfare') . '</span></span></span></span>';
        $array['resource']['email'] .= '</a>';
        $array['resource']['email'] .= '</div>';
    }
    return $array;
}
function swp_add_twitter_card($info)
{
    if (is_singular()) {
        // Check if Twitter Cards are Activated
        if ($info['swp_user_options']['swp_twitter_card']) {
            /*****************************************************************
             *                                                                *
             *     YOAST SEO: It rocks, so let's coordinate with it	         *
             *                                                                *
             ******************************************************************/
            // Check if Yoast Exists so we can coordinate output with their plugin accordingly
            if (defined('WPSEO_VERSION')) {
                // Collect their Social Descriptions as backups if they're not defined in ours
                $yoast_twitter_title = get_post_meta($info['postID'], '_yoast_wpseo_twitter-title', true);
                $yoast_twitter_description = get_post_meta($info['postID'], '_yoast_wpseo_twitter-description', true);
                $yoast_twitter_image = get_post_meta($info['postID'], '_yoast_wpseo_twitter-image', true);
                // Collect their SEO fields as 3rd string backups in case we need them
                $yoast_seo_title = get_post_meta($info['postID'], '_yoast_wpseo_title', true);
                $yoast_seo_description = get_post_meta($info['postID'], '_yoast_wpseo_metadesc', true);
                // Cancel their output if ours have been defined so we don't have two sets of tags
                remove_action('wpseo_head', array('WPSEO_Twitter', 'get_instance'), 40);
            }
            /*****************************************************************
             *                                                                *
             *     JET PACK: If ours are activated, disable theirs	         *
             *                                                                *
             ******************************************************************/
            if (class_exists('JetPack')) {
                add_filter('jetpack_disable_twitter_cards', '__return_true', 99);
            }
            /*****************************************************************
             *                                                                *
             *     TWITTER TITLE										         *
             *                                                                *
             ******************************************************************/
            // If the user defined a Social Media title, use it, otherwise check for Yoast's
            if (!$info['title'] && isset($yoast_twitter_title) && $yoast_twitter_title) {
                $info['title'] = $yoast_twitter_title;
                // If not title has been defined, let's check the SEO description as a 3rd string option
            } elseif (!$info['title'] && isset($yoast_seo_title) && $yoast_seo_title) {
                $info['title'] = $yoast_seo_title;
                // If not title has been defined, let's use the post title
            } elseif (!$info['title']) {
                $info['title'] = convert_smart_quotes(htmlspecialchars_decode(get_the_title()));
            }
            /*****************************************************************
             *                                                                *
             *     TWITTER DESCRIPTION								         *
             *                                                                *
             ******************************************************************/
            // Open Graph Description
            if (!$info['description'] && isset($yoast_twitter_description) && $yoast_twitter_description) {
                $info['description'] = $yoast_twitter_description;
                // If not title has been defined, let's check the SEO description as a 3rd string option
            } elseif (!$info['description'] && isset($yoast_seo_description) && $yoast_seo_description) {
                $info['description'] = $yoast_seo_description;
                // If not, then let's use the excerpt
            } elseif (!$info['description']) {
                $info['description'] = convert_smart_quotes(htmlspecialchars_decode(swp_get_excerpt_by_id($info['postID'])));
            }
            /*****************************************************************
             *                                                                *
             *     TWITTER IMAGE								         *
             *                                                                *
             ******************************************************************/
            // Open Graph Description
            if (!$info['imageURL'] && isset($yoast_twitter_image) && $yoast_twitter_image) {
                $info['imageURL'] = $yoast_twitter_image;
            } else {
                // If nothing else is defined, let's use the post Thumbnail as long as we have the URL cached
                $twitter_image = get_post_meta($info['postID'], 'swp_open_thumbnail_url', true);
                if ($twitter_image) {
                    $info['imageURL'] = $twitter_image;
                }
            }
            /*****************************************************************
             *                                                                *
             *     PUT IT ALL TOGETHER						         		 *
             *                                                                *
             ******************************************************************/
            // Check if we have everything we need for a large image summary card
            if ($info['imageURL']) {
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:card" content="summary_large_image">';
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:title" content="' . trim($info['title']) . '">';
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:description" content="' . $info['description'] . '">';
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:image" content="' . $info['imageURL'] . '">';
                if ($info['swp_user_options']['twitterID']) {
                    $info['header_output'] .= PHP_EOL . '<meta name="twitter:site" content="@' . str_replace('@', '', $info['swp_user_options']['twitterID']) . '">';
                }
                if ($info['user_twitter_handle']) {
                    $info['header_output'] .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace('@', '', $info['user_twitter_handle']) . '">';
                }
                // Otherwise create a small summary card
            } else {
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:card" content="summary">';
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:title" content="' . str_replace('"', '\'', $info['title']) . '">';
                $info['header_output'] .= PHP_EOL . '<meta name="twitter:description" content="' . str_replace('"', '\'', $info['description']) . '">';
                if ($info['swp_user_options']['twitterID']) {
                    $info['header_output'] .= PHP_EOL . '<meta name="twitter:site" content="@' . str_replace('@', '', $info['swp_user_options']['twitterID']) . '">';
                }
                if ($info['user_twitter_handle']) {
                    $info['header_output'] .= PHP_EOL . '<meta name="twitter:creator" content="@' . str_replace('@', '', $info['user_twitter_handle']) . '">';
                }
            }
        }
    }
    return $info;
}