function addthis_display_social_widget($content, $filtered = true, $below_excerpt = false)
 {
     global $addthis_styles, $addthis_new_styles, $post;
     $styles = array_merge($addthis_styles, $addthis_new_styles);
     if (isset($_GET['preview']) && $_GET['preview'] == 1 && ($options = get_transient('addthis_settings'))) {
         $preview = true;
     } else {
         $options = get_option('addthis_settings');
     }
     if (is_home() || is_front_page()) {
         if (isset($options['addthis_showonhome']) && $options['addthis_showonhome'] == true) {
             if (isset($options['addthis_showonexcerpts']) && $options['addthis_showonexcerpts'] == true) {
                 $display = true;
             } else {
                 if (strpos($post->post_content, '<!--more-->') != false) {
                     $display = false;
                 } else {
                     $display = true;
                 }
             }
         } else {
             if (isset($options['addthis_showonexcerpts']) && $options['addthis_showonexcerpts'] == true) {
                 if (strpos($post->post_content, '<!--more-->') != false) {
                     $display = true;
                 } else {
                     $display = false;
                 }
             } else {
                 $display = false;
             }
         }
     } elseif (is_archive() && !is_category()) {
         $display = isset($options['addthis_showonarchives']) && $options['addthis_showonarchives'] == true ? true : false;
     } elseif (is_category()) {
         $display = isset($options['addthis_showoncats']) && $options['addthis_showoncats'] == true ? true : false;
     } elseif (is_page($post->ID)) {
         $display = isset($options['addthis_showonpages']) && $options['addthis_showonpages'] == true ? true : false;
     } elseif (is_single()) {
         $display = true;
     } else {
         $display = false;
     }
     $custom_fields = get_post_custom($post->ID);
     if (isset($custom_fields['addthis_exclude']) && $custom_fields['addthis_exclude'][0] == 'true') {
         $display = false;
     }
     $display = apply_filters('addthis_post_exclude', $display);
     remove_filter('wp_trim_excerpt', 'addthis_remove_tag', 9, 2);
     remove_filter('get_the_excerpt', 'addthis_late_widget');
     $url = get_permalink();
     $title = get_the_title();
     $url_above = "addthis:url='{$url}' ";
     $url_above .= "addthis:title='" . esc_attr($title) . " '";
     $url_below = "addthis:url='{$url}' ";
     $url_below .= "addthis:title='" . esc_attr($title) . " '";
     $above = '';
     $below = '';
     // Still here?  Well let's add some social goodness
     if (isset($options['above']) && $options['above'] != 'none' && $options['above'] != 'disable' && $display) {
         $above = addthis_display_widget_above($styles, $url, $title, $options);
     } elseif ($display) {
         $above = apply_filters('addthis_above_content', '');
     } else {
         $above = '';
     }
     if (isset($options['below']) && $options['below'] != 'none' && $options['below'] != 'disable' && $display && !$below_excerpt) {
         $below = addthis_display_widget_below($styles, $url, $title, $options);
     } elseif ($below_excerpt && $display && $options['below'] != 'none') {
         $below = apply_filters('addthis_below_content', '');
         if ($options['addthis_showonexcerpts'] == true) {
             add_filter('get_the_excerpt', 'addthis_late_widget', 14);
         }
     } elseif ($display) {
         $below = apply_filters('addthis_below_content', '');
     } else {
         $below = '';
     }
     if ($display) {
         if (isset($above)) {
             $content = sprintf($above, $url_above) . $content;
         }
         if (isset($below)) {
             $content = $content . sprintf($below, $url_below);
         }
         if ($filtered == true) {
             add_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 2);
         }
     }
     return $content;
 }
 function addthis_display_social_widget($content, $filtered = true, $excerpt = false)
 {
     global $addthis_styles, $addthis_new_styles, $post;
     global $addThisConfigs;
     $styles = array_merge($addthis_styles, $addthis_new_styles);
     $options = $addThisConfigs->getConfigs();
     $templateType = _addthis_determine_template_type();
     // get configs for this template type
     if (is_string($templateType)) {
         $fieldList = $addThisConfigs->getFieldsForContentTypeSharingLocations($templateType);
         foreach ($fieldList as $key => $field) {
             $fieldList[$field['location']] = $field;
             unset($fieldList[$key]);
         }
         $aboveFieldName = $fieldList['above']['fieldName'];
         $belowFieldName = $fieldList['below']['fieldName'];
         $displayAbove = !empty($options[$aboveFieldName]);
         $displayBelow = !empty($options[$belowFieldName]);
     } else {
         $displayAbove = false;
         $displayBelow = false;
     }
     if ($templateType === 'home') {
         $templateIsAnExcerpt = (bool) (strpos($post->post_content, '<!--more-->') != false);
         if ($templateIsAnExcerpt) {
             if ($displayAbove && !_addthis_excerpt_buttons_enabled_above()) {
                 $displayAbove = false;
             }
             if ($displayBelow && !_addthis_excerpt_buttons_enabled_below()) {
                 $displayBelow = false;
             }
         }
     }
     $custom_fields = get_post_custom($post->ID);
     if (isset($custom_fields['addthis_exclude']) && $custom_fields['addthis_exclude'][0] == 'true') {
         $displayAbove = false;
         $displayBelow = false;
     }
     $displayAbove = apply_filters('addthis_post_exclude', $displayAbove);
     $displayBelow = apply_filters('addthis_post_exclude', $displayBelow);
     $htmlComments = array();
     $htmlCommentLocations = array('above', 'below');
     foreach ($htmlCommentLocations as $location) {
         $htmlComments[$location] = array();
         $search = 'AddThis Sharing Buttons ' . $location;
         $comment = '<!-- ' . $search . ' -->';
         $htmlComments[$location]['search'] = $search;
         $htmlComments[$location]['comment'] = $comment;
     }
     remove_filter('wp_trim_excerpt', 'addthis_remove_tag', 9, 1);
     remove_filter('get_the_excerpt', 'addthis_late_widget');
     $identifier = addthis_get_identifier();
     // Still here?  Well let's add some social goodness
     if (isset($options['above']) && $options['above'] != 'none' && $options['above'] != 'disable' && $displayAbove && (!$excerpt || _addthis_excerpt_buttons_enabled_above()) && strpos($content, $htmlComments['above']['search']) === false) {
         $above = $htmlComments['above']['comment'];
         $above .= addthis_display_widget_above($styles, $options);
     } elseif ($displayAbove) {
         $above = '';
     } else {
         $above = '';
     }
     if (isset($options['below']) && $options['below'] != 'none' && $options['below'] != 'disable' && $displayBelow && (!$excerpt || _addthis_excerpt_buttons_enabled_below()) && strpos($content, $htmlComments['below']['search']) === false) {
         $below = $htmlComments['below']['comment'];
         $below .= addthis_display_widget_below($styles, $options);
     } elseif ($excerpt && $displayBelow && $options['below'] != 'none') {
         $below = '';
         if (_addthis_excerpt_buttons_enabled()) {
             add_filter('get_the_excerpt', 'addthis_late_widget', 14);
         }
     } else {
         $below = '';
     }
     $metaBoxFlag = get_post_meta($post->ID, '_at_widget', TRUE);
     if (!$options['addthis_per_post_enabled'] || $metaBoxFlag == '' || $metaBoxFlag == '1') {
         $metaBoxFlag = true;
     } else {
         $metaBoxFlag = false;
     }
     if ($metaBoxFlag) {
         if ($displayAbove && isset($above)) {
             $content = sprintf($above, $identifier) . $content;
         }
         if ($displayBelow && isset($below)) {
             $content = $content . sprintf($below, $identifier);
         }
     }
     if (($displayAbove || $displayBelow) && $filtered) {
         add_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 1);
     }
     return $content;
 }
 function addthis_display_social_widget($content, $filtered = true, $below_excerpt = false)
 {
     global $addthis_styles, $addthis_new_styles, $post;
     global $addThisConfigs;
     $styles = array_merge($addthis_styles, $addthis_new_styles);
     $options = $addThisConfigs->getConfigs();
     $templateType = _addthis_determine_template_type();
     // get configs for this template type
     if (is_string($templateType)) {
         $fieldList = $addThisConfigs->getFieldsForContentTypeSharingLocations($templateType);
         foreach ($fieldList as $key => $field) {
             $fieldList[$field['location']] = $field;
             unset($fieldList[$key]);
         }
         $aboveFieldName = $fieldList['above']['fieldName'];
         $belowFieldName = $fieldList['below']['fieldName'];
         $displayAbove = isset($options[$aboveFieldName]) && $options[$aboveFieldName] == true ? true : false;
         $displayBelow = isset($options[$belowFieldName]) && $options[$belowFieldName] == true ? true : false;
     } else {
         $displayAbove = false;
         $displayBelow = false;
     }
     if ($templateType === 'home') {
         $templateIsAnExcerpt = (bool) (strpos($post->post_content, '<!--more-->') != false);
         if ($templateIsAnExcerpt) {
             if ($displayAbove && !_addthis_excerpt_buttons_enabled_above()) {
                 $displayAbove = false;
             }
             if ($displayBelow && !_addthis_excerpt_buttons_enabled_below()) {
                 $displayBelow = false;
             }
         }
     }
     $custom_fields = get_post_custom($post->ID);
     if (isset($custom_fields['addthis_exclude']) && $custom_fields['addthis_exclude'][0] == 'true') {
         $displayAbove = false;
         $displayBelow = false;
     }
     $displayAbove = apply_filters('addthis_post_exclude', $displayAbove);
     $displayBelow = apply_filters('addthis_post_exclude', $displayBelow);
     remove_filter('wp_trim_excerpt', 'addthis_remove_tag', 9, 2);
     remove_filter('get_the_excerpt', 'addthis_late_widget');
     $url = get_permalink();
     $title = get_the_title();
     $url_above = "addthis:url='{$url}' ";
     $url_above .= "addthis:title='" . esc_attr($title) . " '";
     $url_below = "addthis:url='{$url}' ";
     $url_below .= "addthis:title='" . esc_attr($title) . " '";
     // Still here?  Well let's add some social goodness
     if (isset($options['above']) && $options['above'] != 'none' && $options['above'] != 'disable' && $displayAbove) {
         $above = addthis_display_widget_above($styles, $url, $title, $options);
     } elseif ($displayAbove) {
         $above = apply_filters('addthis_above_content', '');
     } else {
         $above = '';
     }
     if (isset($options['below']) && $options['below'] != 'none' && $options['below'] != 'disable' && $displayBelow && !$below_excerpt) {
         $below = addthis_display_widget_below($styles, $url, $title, $options);
     } elseif ($below_excerpt && $displayBelow && $options['below'] != 'none') {
         $below = apply_filters('addthis_below_content', '');
         if (_addthis_excerpt_buttons_enabled()) {
             add_filter('get_the_excerpt', 'addthis_late_widget', 14);
         }
     } elseif ($displayBelow) {
         $below = apply_filters('addthis_below_content', '');
     } else {
         $below = '';
     }
     $at_flag = get_post_meta($post->ID, '_at_widget', TRUE);
     if (!$options['addthis_per_post_enabled']) {
         $at_flag = '1';
     }
     if ($at_flag !== '0') {
         if ($displayAbove && isset($above)) {
             $content = sprintf($above, $url_above) . $content;
         }
         if ($displayBelow && isset($below)) {
             $content = $content . sprintf($below, $url_below);
         }
     }
     if (($displayAbove || $displayBelow) && $filtered) {
         add_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 2);
     }
     return $content;
 }