/**
  * get_post_share_details
  * 
  * Generate post sharing details
  * 
  * @param string $position
  * @return array
  */
 function get_post_share_details($position)
 {
     global $post;
     if ($this->general_options['reset_postdata']) {
         wp_reset_postdata();
     }
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'force_wp_query_postid')) {
         $current_query_id = get_queried_object_id();
         $post = get_post($current_query_id);
     }
     $url = "";
     $title = "";
     $image = "";
     $description = "";
     $title_plain = "";
     $twitter_user = $this->network_options['twitter_user'];
     $twitter_hashtags = $this->network_options['twitter_hashtags'];
     $twitter_customtweet = "";
     $url = $post ? get_permalink() : ESSBUrlHelper::get_current_url('raw');
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'avoid_nextpage')) {
         $url = $post ? get_permalink(get_the_ID()) : ESSBUrlHelper::get_current_url('raw');
     }
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'force_wp_fullurl')) {
         $url = ESSBUrlHelper::get_current_page_url();
     }
     if (ESSBOptionValuesHelper::options_bool_value($this->options, 'always_use_http')) {
         $url = str_replace("https://", "http://", $url);
     }
     if (!defined('ESSB3_LIGHTMODE')) {
         $mycred_referral_activate = ESSBOptionValuesHelper::options_bool_value($this->options, 'mycred_referral_activate');
         if ($mycred_referral_activate && function_exists('mycred_render_affiliate_link')) {
             $url = mycred_render_affiliate_link(array('url' => $url));
         }
     }
     if (isset($post)) {
         $title = esc_attr(urlencode($post->post_title));
         $title_plain = $post->post_title;
         $image = ESSBCoreHelper::get_post_featured_image($post->ID);
         $description = $post->post_excerpt;
         if ($position == "heroshare") {
             if ($description == "") {
                 $working_post_content = $post->post_content;
                 $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, 400);
                 $description = $working_post_content;
             }
         }
     }
     $list_of_articles_mode = false;
     if (is_archive() || is_front_page() || is_search() || is_tag() || is_post_type_archive()) {
         if ($position == "sidebar" || $position == "flyin" || $position == "popup" || $position == "topbar" || $position == "bottombar") {
             if (ESSBOptionValuesHelper::options_bool_value($this->options, 'force_archive_pages')) {
                 $list_of_articles_mode = true;
                 $url = ESSBUrlHelper::get_current_page_url();
                 if (is_front_page()) {
                     $title = get_bloginfo('name');
                     $title_plain = $title;
                     $description = get_bloginfo('description');
                 } else {
                     $title = get_the_archive_title();
                     $title_plain = $title;
                     $description = get_the_archive_description();
                 }
             }
         }
     }
     // apply custom share options
     if ($this->general_options['customshare']) {
         if ($this->general_options['customshare_text'] != '') {
             $title = $this->general_options['customshare_text'];
             $title_plain = $title;
         }
         if ($this->general_options['customshare_url'] != '') {
             $url = $this->general_options['customshare_url'];
         }
         if ($this->general_options['customshare_image'] != '') {
             $image = $this->general_options['customshare_image'];
         }
         if ($this->general_options['customshare_description'] != '') {
             $description = $this->general_options['customshare_description'];
         }
     }
     $twitter_customtweet = $title;
     $post_pin_image = "";
     // apply post custom share options
     if (isset($post) && !$list_of_articles_mode) {
         $twitter_message_tags_to_hashtags = ESSBOptionValuesHelper::options_bool_value($this->options, 'twitter_message_tags_to_hashtags');
         if ($twitter_message_tags_to_hashtags) {
             $post_tags = wp_get_post_tags($post->ID);
             if ($post_tags) {
                 $generated_tags = array();
                 foreach ($post_tags as $tag) {
                     $current_tag = $tag->name;
                     $current_tag = str_replace(' ', '', $current_tag);
                     $generated_tags[] = $current_tag;
                 }
                 if (count($generated_tags) > 0) {
                     $twitter_hashtags = implode(',', $generated_tags);
                 }
             }
         }
         $post_essb_post_share_message = get_post_meta($post->ID, 'essb_post_share_message', true);
         $post_essb_post_share_url = get_post_meta($post->ID, 'essb_post_share_url', true);
         $post_essb_post_share_image = get_post_meta($post->ID, 'essb_post_share_image', true);
         $post_essb_post_share_text = get_post_meta($post->ID, 'essb_post_share_text', true);
         $post_pin_image = get_post_meta($post->ID, 'essb_post_pin_image', true);
         $post_essb_twitter_username = get_post_meta($post->ID, 'essb_post_twitter_username', true);
         $post_essb_twitter_hastags = get_post_meta($post->ID, 'essb_post_twitter_hashtags', true);
         $post_essb_twitter_tweet = get_post_meta($post->ID, 'essb_post_twitter_tweet', true);
         if ($post_essb_post_share_image != '') {
             $image = $post_essb_post_share_image;
         }
         if ($post_essb_post_share_message != '') {
             $description = $post_essb_post_share_message;
         }
         if ($post_essb_post_share_text != '') {
             $title = $post_essb_post_share_text;
             $title_plain = $post_essb_post_share_text;
         }
         if ($post_essb_post_share_url != '') {
             $url = $post_essb_post_share_url;
         }
         if ($post_essb_twitter_hastags != '') {
             $twitter_hashtags = $post_essb_twitter_hastags;
         }
         if ($post_essb_twitter_tweet != '') {
             $twitter_customtweet = $post_essb_twitter_tweet;
         }
         if ($post_essb_twitter_username != '') {
             $twitter_user = $post_essb_twitter_username;
         }
     }
     // inetegration with affiliate plugins is not availalbe as option in easy mode
     if (!defined('ESSB3_LIGHTMODE')) {
         $affwp_active = ESSBOptionValuesHelper::options_bool_value($this->options, 'affwp_active');
         if ($affwp_active) {
             $url = ESSBUrlHelper::generate_affiliatewp_referral_link($url);
         }
         $affs_active = ESSBOptionValuesHelper::options_bool_value($this->options, 'affs_active');
         if ($affs_active) {
             $url = do_shortcode('[affiliates_url]' . $url . '[/affiliates_url]');
         }
     }
     $title = str_replace("'", "\\'", $title);
     $description = str_replace("'", "\\'", $description);
     $twitter_customtweet = str_replace("'", "\\'", $twitter_customtweet);
     $title_plain = str_replace("'", "\\'", $title_plain);
     return array("url" => $url, "title" => $title, "image" => $image, "description" => $description, "twitter_user" => $twitter_user, "twitter_hashtags" => $twitter_hashtags, "twitter_tweet" => $twitter_customtweet, "post_id" => isset($post) ? $post->ID : 0, "user_image_url" => "", "title_plain" => $title_plain, 'short_url_whatsapp' => '', 'short_url_twitter' => '', 'short_url' => '', 'pinterest_image' => $post_pin_image);
 }
 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 .= '…';
         $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();
     }
 }