コード例 #1
0
 function process_like_button_code($atts, $content = '')
 {
     global $wp_current_filter;
     // Check allowed
     $allow = $this->data->get_option('wdfb_button', 'allow_facebook_button');
     if (!apply_filters('wdfb-show_facebook_button', $allow)) {
         return '';
     }
     // Check nesting (i.e. posts within post, reformatted with apply_filters)
     $filters = array_count_values($wp_current_filter);
     if (isset($filters['the_content']) && $filters['the_content'] > 1) {
         return '';
     }
     $atts = shortcode_atts(array('forced' => false), $atts);
     $forced = $atts['forced'] && 'no' != $atts['forced'] ? true : false;
     $in_types = $this->data->get_option('wdfb_button', 'not_in_post_types');
     $in_types = is_array($in_types) ? $in_types : array();
     $post_type = get_post_type();
     if ($post_type && in_array(get_post_type(), $in_types) && !$forced) {
         return '';
     }
     $is_activity = defined('BP_VERSION') && isset($filters['bp_get_activity_content_body']);
     if ($is_activity && !@in_array('_buddypress_activity', $in_types)) {
         return '';
     }
     // Reverse logic for BuddyPress Activity check.
     $send = $this->data->get_option('wdfb_button', 'show_send_button');
     $layout = $this->data->get_option('wdfb_button', 'button_appearance');
     $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     /*
     		$width = ("standard" == $layout) ? 300 : (
     			("button_count" == $layout) ? 150 : 60
     		);
     */
     $width = 450;
     $width = apply_filters('wdfb-like_button-width', $width);
     $scheme = $this->data->get_option('wdfb_button', 'color_scheme');
     $scheme = $scheme ? $scheme : 'light';
     if (is_home() && $this->data->get_option('wdfb_button', 'show_on_front_page') || is_archive() && $this->data->get_option('wdfb_button', 'show_on_archive_page') || defined('BP_VERSION') && $is_activity && !wdfb_is_single_bp_activity()) {
         $tmp_url = $is_activity && function_exists('bp_activity_get_permalink') ? bp_activity_get_permalink(bp_get_activity_id()) : (in_the_loop() ? get_permalink() : false);
         $href = !empty($tmp_url) ? $tmp_url : $url;
         $locale = wdfb_get_locale();
         $height = "box_count" == $layout ? 60 : 25;
         $height = apply_filters('wdfb-like_button-height', $height);
         $use_xfbml = false;
         if (defined('BP_VERSION') && $is_activity && !wdfb_is_single_bp_activity() && $this->data->get_option('wdfb_button', 'bp_activity_xfbml') || is_home() && $this->data->get_option('wdfb_button', 'show_on_front_page') && $this->data->get_option('wdfb_button', 'shared_pages_use_xfbml') || is_archive() && $this->data->get_option('wdfb_button', 'show_on_archive_page') && $this->data->get_option('wdfb_button', 'shared_pages_use_xfbml')) {
             $use_xfbml = true;
         }
         $href = apply_filters('wdfb-like_button-href_attribute', WDFB_PROTOCOL . preg_replace('/^https?:\\/\\//', '', $href));
         return $use_xfbml ? '<div class="wdfb_like_button">' . wdfb_get_fb_plugin_markup('like', compact(array('href', 'send', 'layout', 'width', 'scheme'))) . '</div>' : "<div class='wdfb_like_button'><iframe src='http://www.facebook.com/plugins/like.php?&amp;href=" . rawurlencode($href) . "&amp;send=false&amp;layout={$layout}&amp;show_faces=false&amp;action=like&amp;colorscheme={$scheme}&amp;font&amp;height={$height}&amp;width={$width}&amp;locale={$locale}' scrolling='no' frameborder='0' style='border:none; overflow:hidden; height:{$height}px; width:{$width}px;' allowTransparency='true'></iframe></div>";
     }
     $href = apply_filters('wdfb-like_button-href_attribute', WDFB_PROTOCOL . preg_replace('/^https?:\\/\\//', '', $url));
     return '<div class="wdfb_like_button">' . wdfb_get_fb_plugin_markup('like', compact(array('href', 'send', 'layout', 'width', 'scheme'))) . '</div>';
 }
コード例 #2
0
/**
 * Description abstraction, to make sure we sugarcoat the BP uglyness.
 */
function wdfb_get_singular_description()
{
    $content = '';
    if (wdfb_is_single_bp_activity()) {
        $activity = bp_activity_get_specific(array('activity_ids' => bp_current_action(), 'show_hidden' => true, 'spam' => 'ham_only'));
        $activity = empty($activity['activities'][0]) || bp_action_variables() ? '' : $activity['activities'][0];
        $content = apply_filters_ref_array('bp_get_activity_content_body', array($activity->content, &$activity));
    } else {
        global $post;
        $content = $post->post_excerpt ? $post->post_excerpt : strip_shortcodes($post->post_content);
    }
    return htmlspecialchars(wp_strip_all_tags($content), ENT_QUOTES);
}