Example #1
0
    function twitter_header()
    {
        global $post;
        if (is_single() || is_page()) {
            $essb_post_twitter_desc = get_post_meta($post->ID, 'essb_post_twitter_desc', true);
            $essb_post_twitter_title = get_post_meta($post->ID, 'essb_post_twiiter_title', true);
            $essb_post_twitter_image = get_post_meta($post->ID, 'essb_post_twiiter_image', true);
            $options = get_option(EasySocialShareButtons::$plugin_settings_name);
            $apply_the_content = isset($options['sso_apply_the_content']) ? $options['sso_apply_the_content'] : 'false';
            easy_share_deactivate();
            if ($essb_post_twitter_desc == '') {
                //$essb_post_og_desc = strip_tags( get_the_excerpt($post->ID));
                $content_post = get_post($post->ID);
                $essb_post_twitter_desc = $content_post->post_content;
                if ($apply_the_content == 'true') {
                    $essb_post_twitter_desc = apply_filters('the_content', $essb_post_twitter_desc);
                }
                //$essb_post_og_desc = strip_shortcodes($essb_post_og_desc);
                $essb_post_twitter_desc = strip_tags($essb_post_twitter_desc);
                $essb_post_twitter_desc = preg_replace('/\\s+/', ' ', $essb_post_twitter_desc);
                $essb_post_twitter_desc = trim($essb_post_twitter_desc);
                $essb_post_twitter_desc = substr($essb_post_twitter_desc, 0, 155);
            }
            easy_share_reactivate();
            if ($essb_post_twitter_title == '') {
                $essb_post_twitter_title = get_the_title();
            }
            if ($essb_post_twitter_image == '') {
                $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full');
                if ($fb_image) {
                    $essb_post_twitter_image = $fb_image[0];
                }
            }
            if ($essb_post_twitter_image == "") {
                $essb_post_twitter_image = $this->default_image;
            }
            $essb_post_twitter_desc = str_replace('"', "", $essb_post_twitter_desc);
            $essb_post_twitter_desc = str_replace('"', "", $essb_post_twitter_desc);
            $essb_post_twitter_desc = str_replace('\'', "'", $essb_post_twitter_desc);
            $essb_twitter_card = $this->card_type == "" ? "summary" : "summary_large_image";
            ?>
<meta property="twitter:card" content="<?php 
            echo addslashes($essb_twitter_card);
            ?>
"/><?php 
            echo "\n";
            ?>
			
<?php 
            if ($this->twitter_user != '') {
                ?>
<meta property="twitter:site" content="@<?php 
                echo addslashes($this->twitter_user);
                ?>
"/><?php 
                echo "\n";
            }
            ?>
<meta property="twitter:title" content="<?php 
            echo addslashes(strip_tags($essb_post_twitter_title));
            ?>
"/><?php 
            echo "\n";
            ?>
<meta property="twitter:description" content="<?php 
            echo addslashes(strip_tags($essb_post_twitter_desc));
            ?>
" /><?php 
            echo "\n";
            ?>
<meta property="twitter:url" content="<?php 
            the_permalink();
            ?>
"/><?php 
            echo "\n";
            if ($essb_post_twitter_image != '' && $essb_twitter_card == "summary_large_image") {
                ?>
<meta property="twitter:image:src" content="<?php 
                echo $essb_post_twitter_image;
                ?>
" /><?php 
                echo "\n";
            }
            ?>
<meta property="twitter:domain" content="<?php 
            bloginfo('name');
            ?>
"/><?php 
            echo "\n";
            ?>
	
<?php 
        }
    }
Example #2
0
    function ogmeta_header()
    {
        global $post;
        if (is_single() || is_page()) {
            easy_share_deactivate();
            $essb_post_og_desc = get_post_meta($post->ID, 'essb_post_og_desc', true);
            $essb_post_og_title = get_post_meta($post->ID, 'essb_post_og_title', true);
            $essb_post_og_image = get_post_meta($post->ID, 'essb_post_og_image', true);
            $essb_post_og_video = get_post_meta($post->ID, 'essb_post_og_video', true);
            // sso_apply_the_content
            $options = get_option(EasySocialShareButtons::$plugin_settings_name);
            $apply_the_content = isset($options['sso_apply_the_content']) ? $options['sso_apply_the_content'] : 'false';
            if ($essb_post_og_desc == '') {
                // $essb_post_og_desc = strip_tags( get_the_excerpt($post->ID));
                $content_post = get_post($post->ID);
                $essb_post_og_desc = $content_post->post_content;
                if ($apply_the_content == 'true') {
                    $essb_post_og_desc = apply_filters('the_content', $essb_post_og_desc);
                }
                //$essb_post_og_desc = strip_shortcodes($essb_post_og_desc);
                $post_shortdesc = $content_post->post_excerpt;
                if ($post_shortdesc != '') {
                    $essb_post_og_desc = $post_shortdesc;
                }
                $essb_post_og_desc = strip_tags($essb_post_og_desc);
                $essb_post_og_desc = preg_replace('/\\s+/', ' ', $essb_post_og_desc);
                $essb_post_og_desc = trim($essb_post_og_desc);
                $essb_post_og_desc = substr($essb_post_og_desc, 0, 155);
            }
            if ($essb_post_og_title == '') {
                $essb_post_og_title = get_the_title();
            }
            if ($essb_post_og_image == '') {
                $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full');
                if ($fb_image) {
                    $essb_post_og_image = $fb_image[0];
                }
            }
            if ($essb_post_og_image == "") {
                $essb_post_og_image = $this->default_image;
            }
            $essb_post_og_desc = str_replace('"', "", $essb_post_og_desc);
            $essb_post_og_desc = str_replace('&quot;', "", $essb_post_og_desc);
            $essb_post_og_desc = str_replace('\'', "&#8217;", $essb_post_og_desc);
            $essb_og_locate = $this->get_og_locate();
            if ($this->fbapp != '') {
                print '<meta property="fb:app_id" content="' . $this->fbapp . '"/>';
            }
            if ($this->fbadmins != '') {
                print '<meta property="fb:admins" content="' . $this->fbadmins . '"/>';
            }
            ?>
<meta property="og:title" content="<?php 
            echo addslashes(strip_tags($essb_post_og_title));
            ?>
" />
<meta property="og:description" content="<?php 
            echo addslashes(strip_tags($essb_post_og_desc));
            ?>
" />
<meta property="og:url" content="<?php 
            the_permalink();
            ?>
" />
<?php 
            if ($essb_post_og_image != '') {
                ?>
<meta property="og:image" content="<?php 
                echo $essb_post_og_image;
                ?>
" />
<?php 
            }
            if ($essb_post_og_video != '') {
                ?>
<meta property="og:video" content="<?php 
                echo $essb_post_og_video;
                ?>
" />
<?php 
            }
            ?>
<meta property="og:type" content="<?php 
            if (is_single() || is_page()) {
                echo "article";
            } else {
                echo "website";
            }
            ?>
" />
<meta property="og:site_name" content="<?php 
            bloginfo('name');
            ?>
" />
<?php 
            if (is_singular()) {
                $this->og_tags();
                $this->og_category();
                $this->og_publish_date();
                if ($this->fbpage != '') {
                    print '<meta property="article:publisher" content="' . $this->fbpage . '"/>';
                }
            }
            easy_share_reactivate();
        }
    }
 private function loadPostSettings()
 {
     global $post;
     if (is_single() || is_page()) {
         easy_share_deactivate();
         // loading post default data
         $this->post_title = get_the_title();
         $this->site_name = get_bloginfo('name');
         $this->post_url = get_permalink($post->ID);
         $content_post = get_post($post->ID);
         $working_post_content = $content_post->post_content;
         if ($this->apply_the_content) {
             $working_post_content = apply_filters('the_content', $working_post_content);
         }
         //$essb_post_og_desc = strip_shortcodes($essb_post_og_desc);
         $post_shortdesc = $content_post->post_excerpt;
         if ($post_shortdesc != '') {
             $working_post_content = $post_shortdesc;
         }
         $working_post_content = strip_tags($working_post_content);
         $working_post_content = preg_replace('/\\s+/', ' ', $working_post_content);
         $working_post_content = strip_shortcodes($working_post_content);
         $working_post_content = trim($working_post_content);
         $working_post_content = substr($working_post_content, 0, 300);
         $working_post_content .= '&hellip;';
         $this->post_description = $working_post_content;
         $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full');
         if ($fb_image) {
             $this->post_image = $fb_image[0];
         }
         if ($this->post_image == "") {
             $this->post_image = $this->default_image;
         }
         // end loading post defaults
         if ($this->ogtags_active) {
             $this->fb_description = get_post_meta($post->ID, 'essb_post_og_desc', true);
             $this->fb_title = get_post_meta($post->ID, 'essb_post_og_title', true);
             $this->fb_image = get_post_meta($post->ID, 'essb_post_og_image', true);
             // since 2.0
             $this->fb_video_url = get_post_meta($post->ID, 'essb_post_og_video', true);
             $this->fb_video_h = get_post_meta($post->ID, 'essb_post_og_video_h', true);
             $this->fb_video_w = get_post_meta($post->ID, 'essb_post_og_w', true);
             if ($this->fb_description == "") {
                 $this->fb_description = $this->post_description;
             }
             if ($this->fb_title == "") {
                 $this->fb_title = $this->post_title;
             }
             if ($this->fb_image == "") {
                 $this->fb_image = $this->post_image;
             }
         }
         if ($this->twitter_cards_active) {
             $this->twitter_description = get_post_meta($post->ID, 'essb_post_twitter_desc', true);
             $this->twitter_title = get_post_meta($post->ID, 'essb_post_twitter_title', true);
             $this->twitter_image = get_post_meta($post->ID, 'essb_post_twitter_image', true);
             if ($this->twitter_description == "") {
                 $this->twitter_description = $this->fb_description;
             }
             if ($this->twitter_title == "") {
                 $this->twitter_title = $this->fb_title;
             }
             if ($this->twitter_image == "") {
                 $this->twitter_image = $this->fb_image;
             }
             if ($this->twitter_description == "") {
                 $this->twitter_description = $this->post_description;
             }
             if ($this->twitter_title == "") {
                 $this->twitter_title = $this->post_title;
             }
             if ($this->twitter_image == "") {
                 $this->twitter_image = $this->post_image;
             }
         }
         if ($this->google_markup) {
             $this->google_description = get_post_meta($post->ID, 'essb_post_google_desc', true);
             $this->google_title = get_post_meta($post->ID, 'essb_post_google_title', true);
             $this->google_image = get_post_meta($post->ID, 'essb_post_google_image', true);
             if ($this->google_description == "") {
                 $this->google_description = $this->fb_description;
             }
             if ($this->google_title == "") {
                 $this->google_title = $this->fb_title;
             }
             if ($this->google_image == "") {
                 $this->google_image = $this->fb_image;
             }
             if ($this->google_description == "") {
                 $this->google_description = $this->post_description;
             }
             if ($this->google_title == "") {
                 $this->google_title = $this->post_title;
             }
             if ($this->google_image == "") {
                 $this->google_image = $this->post_image;
             }
         }
         easy_share_reactivate();
     }
 }
 private function loadPostSettings()
 {
     global $post;
     if (is_single() || is_page()) {
         easy_share_deactivate();
         // loading post default data
         $this->post_title = get_the_title();
         $this->site_name = get_bloginfo('name');
         $this->post_url = get_permalink($post->ID);
         $content_post = get_post($post->ID);
         $working_post_content = $content_post->post_content;
         if ($this->apply_the_content) {
             $working_post_content = apply_filters('the_content', $working_post_content);
         }
         //$essb_post_og_desc = strip_shortcodes($essb_post_og_desc);
         $post_shortdesc = $content_post->post_excerpt;
         if ($post_shortdesc != '') {
             $working_post_content = $post_shortdesc;
         }
         if (is_attachment() && empty($working_post_content)) {
             $attachment_alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
             if (!empty($attachment_alt_text)) {
                 $working_post_content = $attachment_alt_text;
             }
         }
         $working_post_content = strip_tags($working_post_content);
         $working_post_content = preg_replace('/\\s+/', ' ', $working_post_content);
         $working_post_content = strip_shortcodes($working_post_content);
         $working_post_content = trim($working_post_content);
         $working_post_content = substr($working_post_content, 0, 300);
         $working_post_content .= '&hellip;';
         $this->post_description = $working_post_content;
         if (defined('WPSEO_VERSION')) {
             // Collect their Social Descriptions as backups if they're not defined in ours
             $this->yoast_og_title = get_post_meta($post->ID, '_yoast_wpseo_opengraph-title', true);
             $this->yoast_og_description = get_post_meta($post->ID, '_yoast_wpseo_opengraph-description', true);
             $this->yoast_og_image = get_post_meta($post->ID, '_yoast_wpseo_opengraph-image', true);
             // Collect their SEO fields as 3rd string backups in case we need them
             $this->yoast_seo_title = get_post_meta($post->ID, '_yoast_wpseo_title', true);
             $this->yoast_seo_description = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
             if (empty($this->yoast_og_description)) {
                 $this->yoast_og_description = $this->yoast_seo_description;
             }
             if (empty($this->yoast_og_title)) {
                 $this->yoast_og_title = $this->yoast_seo_title;
             }
         }
         //$fb_image = wp_get_attachment_image_src ( get_post_thumbnail_id ( get_the_ID () ), 'full' );
         //if ($fb_image) {
         //	$this->post_image = $fb_image [0];
         //}
         $this->post_image = ESSBCoreHelper::get_post_featured_image(get_the_ID());
         if ($this->post_image == "") {
             $this->post_image = $this->default_image;
         }
         // end loading post defaults
         if ($this->ogtags_active) {
             $this->fb_description = get_post_meta($post->ID, 'essb_post_og_desc', true);
             $this->fb_title = get_post_meta($post->ID, 'essb_post_og_title', true);
             $this->fb_image = get_post_meta($post->ID, 'essb_post_og_image', true);
             // since 2.0
             $this->fb_video_url = get_post_meta($post->ID, 'essb_post_og_video', true);
             $this->fb_video_h = get_post_meta($post->ID, 'essb_post_og_video_h', true);
             $this->fb_video_w = get_post_meta($post->ID, 'essb_post_og_w', true);
             $onpost_fb_authorship = get_post_meta($post->ID, 'essb_post_og_author_of_post', true);
             if (!empty($onpost_fb_authorship)) {
                 $this->fb_author_profile = get_post_meta($post->ID, 'essb_post_og_author_of_post', true);
             }
             if (empty($this->fb_description) && !empty($this->yoast_og_description)) {
                 $this->fb_description = $this->yoast_og_description;
             }
             if (empty($this->fb_title) && !empty($this->yoast_og_title)) {
                 $this->fb_title = $this->yoast_og_title;
             }
             if (empty($this->fb_image) && !empty($this->yoast_og_image)) {
                 $this->fb_image = $this->yoast_og_image;
             }
             if ($this->fb_description == "") {
                 $this->fb_description = $this->post_description;
             }
             if ($this->fb_title == "") {
                 $this->fb_title = $this->post_title;
             }
             if ($this->fb_image == "") {
                 $this->fb_image = $this->post_image;
             }
         }
         if ($this->twitter_cards_active) {
             $this->twitter_description = get_post_meta($post->ID, 'essb_post_twitter_desc', true);
             $this->twitter_title = get_post_meta($post->ID, 'essb_post_twitter_title', true);
             $this->twitter_image = get_post_meta($post->ID, 'essb_post_twitter_image', true);
             if ($this->twitter_description == "") {
                 $this->twitter_description = $this->fb_description;
             }
             if ($this->twitter_title == "") {
                 $this->twitter_title = $this->fb_title;
             }
             if ($this->twitter_image == "") {
                 $this->twitter_image = $this->fb_image;
             }
             if (empty($this->twitter_description) && !empty($this->yoast_og_description)) {
                 $this->twitter_description = $this->yoast_og_description;
             }
             if (empty($this->twitter_title) && !empty($this->yoast_og_title)) {
                 $this->twitter_title = $this->yoast_og_title;
             }
             if (empty($this->twitter_image) && !empty($this->yoast_og_image)) {
                 $this->twitter_image = $this->yoast_og_image;
             }
             if ($this->twitter_image == "") {
                 $this->twitter_image = $this->post_image;
             }
             if ($this->twitter_description == "") {
                 $this->twitter_description = $this->post_description;
             }
             if ($this->twitter_title == "") {
                 $this->twitter_title = $this->post_title;
             }
         }
         if ($this->google_markup) {
             $this->google_description = get_post_meta($post->ID, 'essb_post_google_desc', true);
             $this->google_title = get_post_meta($post->ID, 'essb_post_google_title', true);
             $this->google_image = get_post_meta($post->ID, 'essb_post_google_image', true);
             if ($this->google_description == "") {
                 $this->google_description = $this->fb_description;
             }
             if ($this->google_title == "") {
                 $this->google_title = $this->fb_title;
             }
             if ($this->google_image == "") {
                 $this->google_image = $this->fb_image;
             }
             if (empty($this->google_description) && !empty($this->yoast_og_description)) {
                 $this->google_description = $this->yoast_og_description;
             }
             if (empty($this->google_title) && !empty($this->yoast_og_title)) {
                 $this->google_title = $this->yoast_og_title;
             }
             if (empty($this->google_image) && !empty($this->yoast_og_image)) {
                 $this->google_image = $this->yoast_og_image;
             }
             if ($this->google_description == "") {
                 $this->google_description = $this->post_description;
             }
             if ($this->google_title == "") {
                 $this->google_title = $this->post_title;
             }
             if ($this->google_image == "") {
                 $this->google_image = $this->post_image;
             }
         }
         easy_share_reactivate();
     }
 }