function addthis_display_widget_below($styles, $options)
 {
     $below = '';
     if ($options['addthis_below_enabled'] == true) {
         if (isset($styles[$options['below']])) {
             if (isset($options['below_chosen_list'], $options['below_auto_services']) && !$options['below_auto_services'] && strlen($options['below_chosen_list']) != 0) {
                 if (isset($options['below']) && $options['below'] == 'large_toolbox') {
                     $belowOptions['size'] = '32';
                 } elseif (isset($options['below']) && $options['below'] == 'small_toolbox') {
                     $belowOptions['size'] = '16';
                 }
                 $belowOptions['type'] = $options['below'];
                 $belowOptions['services'] = $options['below_chosen_list'];
                 $below = addthis_custom_toolbox($belowOptions);
             } else {
                 $below = $styles[$options['below']]['src'];
             }
         } elseif ($options['below'] == 'custom') {
             $belowOptions['size'] = $options['below_custom_size'];
             $belowOptions['services'] = $options['below_custom_services'];
             $belowOptions['preferred'] = $options['below_custom_preferred'];
             $belowOptions['more'] = $options['below_custom_more'];
             $below = addthis_custom_toolbox($belowOptions);
         } elseif ($options['below'] == 'custom_string') {
             $custom = preg_replace('/<\\s*div\\s*/', '<div %1$s ', $options['below_custom_string']);
             $below = $custom;
         }
     }
     return $below;
 }
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()) {
        $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' && $display) {
        if (isset($styles[$options['above']])) {
            $above = apply_filters('addthis_above_content', $styles[$options['above']]['src']);
        } elseif ($options['above'] == 'custom') {
            $aboveOptions['size'] = $options['above_custom_size'];
            if ($options['above_do_custom_services']) {
                $aboveOptions['services'] = $options['above_custom_services'];
            }
            if ($options['above_do_custom_preferred']) {
                $aboveOptions['preferred'] = $options['above_custom_preferred'];
            }
            $aboveOptions['more'] = $options['above_custom_more'];
            $above = apply_filters('addthis_above_content', addthis_custom_toolbox($aboveOptions, $url, $title));
        } elseif ($options['above'] == 'custom_string') {
            $custom = preg_replace('/<\\s*div\\s*/', '<div %s ', $options['above_custom_string']);
            $above = apply_filters('addthis_above_content', $custom);
        }
    } elseif ($display) {
        $above = apply_filters('addthis_above_content', '');
    } else {
        $above = '';
    }
    if (isset($options['below']) && $options['below'] != 'none' && $display && !$below_excerpt) {
        if (isset($styles[$options['below']])) {
            $below = apply_filters('addthis_below_content', $styles[$options['below']]['src']);
        } elseif ($options['below'] == 'custom') {
            $belowOptions['size'] = $options['below_custom_size'];
            $belowOptions['services'] = $options['below_custom_services'];
            $belowOptions['preferred'] = $options['below_custom_preferred'];
            $belowOptions['more'] = $options['below_custom_more'];
            $below = apply_filters('addthis_below_content', addthis_custom_toolbox($belowOptions, $url, $title));
        } elseif ($options['below'] == 'custom_string') {
            $custom = preg_replace('/<\\s*div\\s*/', '<div %s ', $options['below_custom_string']);
            $below = apply_filters('addthis_below_content', $custom);
        }
    } 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)) {
            if ($options['above'] == 'custom') {
                $content = $above . $content;
            } else {
                $content = sprintf($above, $url_above) . $content;
            }
        }
        if (isset($below)) {
            if ($options['below'] == 'custom') {
                $content = $content . $below;
            } else {
                $content = $content . sprintf($below, $url_below);
            }
        }
        if ($filtered == true) {
            add_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 2);
        }
    }
    return $content;
}
function addthis_display_after_title($title, $filtered = true)
{
    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');
    }
    $custom_fields = get_post_custom($post->ID);
    if (isset($custom_fields['addthis_exclude']) && $custom_fields['addthis_exclude'][0] == 'true') {
        $display = false;
    } else {
        $display = true;
    }
    $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();
    $url_above = "addthis:url='{$url}' ";
    $url_above .= "addthis:title='" . esc_attr($title) . " '";
    $above = '';
    if (isset($options['above']) && $options['above'] != 'none' && $options['above'] != 'disable' && $display) {
        if (isset($styles[$options['above']])) {
            $above = apply_filters('addthis_above_content', $styles[$options['above']]['src']);
        } elseif ($options['above'] == 'custom') {
            $aboveOptions['size'] = $options['above_custom_size'];
            if ($options['above_do_custom_services']) {
                $aboveOptions['services'] = $options['above_custom_services'];
            }
            if ($options['above_do_custom_preferred']) {
                $aboveOptions['preferred'] = $options['above_custom_preferred'];
            }
            $aboveOptions['more'] = $options['above_custom_more'];
            $aboveOptions['addthis_options'] = $options['addthis_options'];
            $above = apply_filters('addthis_above_content', addthis_custom_toolbox($aboveOptions, $url, $title));
        }
        if (isset($options['above_chosen_list']) && strlen($options['above_chosen_list']) != 0) {
            if (isset($options['above']) && $options['above'] == 'large_toolbox') {
                $aboveOptions['size'] = '32';
            } elseif (isset($options['above']) && $options['above'] == 'small_toolbox') {
                $aboveOptions['size'] = '16';
            }
            $aboveOptions['type'] = $options['above'];
            $aboveOptions['services'] = $options['above_chosen_list'];
            $aboveOptions['addthis_options'] = $options['addthis_options'];
            $above = apply_filters('addthis_above_content', addthis_custom_toolbox($aboveOptions, $url, $title));
        }
    } elseif ($display) {
        $above = apply_filters('addthis_above_content', '');
    } else {
        $above = '';
    }
    if ($display) {
        if (isset($above)) {
            if (in_the_loop() && $title == $post->post_title) {
                if ($options['above'] == 'custom') {
                    $title .= $above;
                } else {
                    $title .= sprintf($above, $url_above);
                }
            }
        }
        if ($filtered == true) {
            add_filter('wp_trim_excerpt', 'addthis_remove_tag', 11, 2);
        }
    }
    return $title;
}
 function addthis_display_widget_below($styles, $url, $title, $options)
 {
     $below = '';
     if (isset($styles[$options['below']])) {
         if (isset($options['below_chosen_list']) && strlen($options['below_chosen_list']) != 0) {
             if (isset($options['below']) && $options['below'] == 'large_toolbox') {
                 $belowOptions['size'] = '32';
             } elseif (isset($options['below']) && $options['below'] == 'small_toolbox') {
                 $belowOptions['size'] = '16';
             }
             $belowOptions['type'] = $options['below'];
             $belowOptions['services'] = $options['below_chosen_list'];
             if (isset($options['addthis_options'])) {
                 $belowOptions['addthis_options'] = $options['addthis_options'];
             } else {
                 $belowOptions['addthis_options'] = '';
             }
             $below = apply_filters('addthis_above_content', addthis_custom_toolbox($belowOptions, $url, $title));
         } else {
             $below = apply_filters('addthis_below_content', $styles[$options['below']]['src']);
         }
     } elseif ($options['below'] == 'custom') {
         $belowOptions['size'] = $options['below_custom_size'];
         $belowOptions['services'] = $options['below_custom_services'];
         $belowOptions['preferred'] = $options['below_custom_preferred'];
         $belowOptions['more'] = $options['below_custom_more'];
         $belowOptions['addthis_options'] = $options['addthis_options'];
         $below = apply_filters('addthis_below_content', addthis_custom_toolbox($belowOptions, $url, $title));
     } elseif ($options['below'] == 'custom_string') {
         $custom = preg_replace('/<\\s*div\\s*/', '<div %1$s ', $options['below_custom_string']);
         $below = apply_filters('addthis_below_content', $custom);
     }
     return $below;
 }