コード例 #1
0
ファイル: synved-social.php プロジェクト: jonpetersen/PHTC
 function render_social_markup($params = null)
 {
     echo synved_social_follow_markup(null, null, $params);
 }
コード例 #2
0
function synved_social_wp_the_content($content, $id = null)
{
    $exclude = false;
    $exclude_share = false;
    $exclude_follow = false;
    $extra_after = null;
    $extra_before = null;
    $separator_after = null;
    $separator_before = null;
    if ($id == null) {
        $id = get_the_ID();
        if ($id == null) {
            global $post;
            $id = $post->ID;
        }
    }
    if ($id != null) {
        $exclude = get_post_meta($id, 'synved_social_exclude', true) == 'yes' ? true : false;
        $exclude_share = get_post_meta($id, 'synved_social_exclude_share', true) == 'yes' ? true : false;
        $exclude_follow = get_post_meta($id, 'synved_social_exclude_follow', true) == 'yes' ? true : false;
        if (!$exclude_share && synved_option_get('synved_social', 'automatic_share_single')) {
            $exclude_share = !(is_singular(synved_option_get('synved_social', 'automatic_share_post_types')) && (is_single($id) || is_page($id)));
        }
        if (!$exclude_follow && synved_option_get('synved_social', 'automatic_follow_single')) {
            $exclude_follow = !(is_singular(synved_option_get('synved_social', 'automatic_follow_post_types')) && (is_single($id) || is_page($id)));
        }
    }
    if ($exclude == false) {
        if ($exclude_share == false && synved_option_get('synved_social', 'automatic_share')) {
            $post_type = get_post_type();
            $type_list = synved_option_get('synved_social', 'automatic_share_post_types');
            if (in_array($post_type, $type_list)) {
                $position = synved_option_get('synved_social', 'automatic_share_position');
                $position_before = in_array($position, array('before_post', 'after_before_post'));
                $position_after = in_array($position, array('after_post', 'after_before_post'));
                $prefix = synved_option_get('synved_social', 'automatic_share_prefix');
                $postfix = synved_option_get('synved_social', 'automatic_share_postfix');
                if ($position_after) {
                    $markup = synved_social_share_markup();
                    if (trim($markup) != null) {
                        $markup = $prefix . $markup . $postfix;
                        $extra_after .= $markup;
                    }
                }
                if ($position_before) {
                    $markup = synved_social_share_markup();
                    if (trim($markup) != null) {
                        $markup = $prefix . $markup . $postfix;
                        $extra_before .= $markup;
                    }
                }
            }
        }
        $separator = synved_option_get('synved_social', 'automatic_append_separator');
        if ($extra_after != null) {
            $separator_after = $separator;
        }
        if ($extra_before != null) {
            $separator_before = $separator;
        }
        if ($exclude_follow == false && synved_option_get('synved_social', 'automatic_follow')) {
            $post_type = get_post_type();
            $type_list = synved_option_get('synved_social', 'automatic_follow_post_types');
            if (in_array($post_type, $type_list)) {
                $position = synved_option_get('synved_social', 'automatic_follow_position');
                $position_before = in_array($position, array('before_post', 'after_before_post'));
                $position_after = in_array($position, array('after_post', 'after_before_post'));
                $prefix = synved_option_get('synved_social', 'automatic_follow_prefix');
                $postfix = synved_option_get('synved_social', 'automatic_follow_postfix');
                if ($position_after) {
                    $markup = synved_social_follow_markup();
                    if (trim($markup) != null) {
                        $markup = $prefix . $markup . $postfix;
                        if (synved_option_get('synved_social', 'automatic_follow_before_share')) {
                            $extra_after = $markup . $separator_after . $extra_after;
                        } else {
                            $extra_after .= $separator_after . $markup;
                        }
                    }
                }
                if ($position_before) {
                    $markup = synved_social_follow_markup();
                    if (trim($markup) != null) {
                        $markup = $prefix . $markup . $postfix;
                        if (synved_option_get('synved_social', 'automatic_follow_before_share')) {
                            $extra_before = $markup . $separator_before . $extra_before;
                        } else {
                            $extra_before .= $separator_before . $markup;
                        }
                    }
                }
            }
        }
        $prefix = synved_option_get('synved_social', 'automatic_append_prefix');
        $postfix = synved_option_get('synved_social', 'automatic_append_postfix');
        if ($extra_after != null) {
            $content .= $prefix . $extra_after . $postfix;
        }
        if ($extra_before != null) {
            $content = $prefix . $extra_before . $postfix . $content;
        }
    }
    return $content;
}