示例#1
0
function xt_socialshare($params = array())
{
    global $post, $XT_SocialShare;
    $is_endless_template = xt_is_endless_template();
    $enabled = (bool) xt_option('xtss_enabled');
    $xtss_box = null;
    if ($enabled) {
        $networks = array();
        $networks_data = xt_option('xtss_networks');
        $params = shortcode_atts(array('show_title' => xt_option('xtss_show_title'), 'title' => xt_option('xtss_title'), 'skin' => xt_option('xtss_skin'), 'align' => xt_option('xtss_align'), 'layout' => xt_option('xtss_layout'), 'is_fullwidth' => xt_option('xtss_is_fullwidth'), 'size' => $is_endless_template ? 'small' : xt_option('xtss_size'), 'radius' => xt_option('xtss_radius'), 'rounded' => xt_option('xtss_rounded'), 'show_names' => xt_option('xtss_show_names'), 'show_shares' => xt_option('xtss_show_shares'), 'show_total_shares' => xt_option('xtss_show_total_shares')), $params);
        if (!empty($networks_data)) {
            $networks = $networks_data['enabled'];
        }
        $post_id = get_the_ID();
        $blogname = get_bloginfo('name');
        $url = get_permalink($post_id);
        $title = get_the_title($post_id);
        $excerpt = get_the_excerpt();
        $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'th-large');
        $media = '';
        if (!empty($thumb[0])) {
            $media = $thumb[0];
        }
        $config = array('twitter' => array('via' => xt_option('xtss_twitter_username'), 'text' => $title), 'pinterest' => array('description' => $title, 'media' => $media), 'linkedin' => array('title' => $title, 'summary' => $excerpt, 'source' => $blogname));
        if (empty($XT_SocialShare)) {
            $XT_SocialShare = new XT_SocialShare($params, $networks);
        } else {
            $XT_SocialShare->setParams($params);
            $XT_SocialShare->setSelected($networks);
        }
        $xtss_box = $XT_SocialShare->render($url, $config, true);
    }
    return $xtss_box;
}