コード例 #1
0
function rotatingtweets_display_shortcode($atts, $content = null, $code = "", $print = FALSE)
{
    // $atts    ::= twitter_id,include_rts,exclude_replies, $tweet_count,$show_follow
    /**
    	Possible values for get_cforms_entries()
    	$screen_name :: [text]	Twitter user name
    	$include_rts :: [boolean] include RTS - optional
    	$exclude_replies :: [boolean] exclude replies - optional
    	$tweet_count :: [integer] number of tweets to show - optional - default 5
    	$show_follow :: [boolean] show follow button
    	$no_show_count :: [boolean] remove count from follow button
    	$no_show_screen_name :: [boolean] remove screen name from follow button
    */
    $args = shortcode_atts(array('screen_name' => '', 'url' => 'http://twitter.com/twitter', 'include_rts' => FALSE, 'exclude_replies' => FALSE, 'tweet_count' => 5, 'show_follow' => FALSE, 'timeout' => 4000, 'no_show_count' => FALSE, 'no_show_screen_name' => FALSE, 'show_meta_timestamp' => TRUE, 'show_meta_screen_name' => TRUE, 'show_meta_via' => TRUE, 'show_meta_reply_retweet_favorite' => FALSE, 'show_meta_prev_next' => FALSE, 'rotation_type' => 'scrollUp', 'official_format' => FALSE, 'links_in_new_window' => FALSE, 'url_length' => 29, 'search' => FALSE, 'list' => FALSE, 'get_favorites' => FALSE, 'ratelimit' => FALSE, 'next' => __('next', 'rotatingtweets'), 'prev' => __('prev', 'rotatingtweets'), 'middot' => ' · ', 'np_pos' => 'top', 'speed' => 1000, 'offset' => 0, 'link_all_text' => FALSE, 'no_rotate' => FALSE, 'show_media' => FALSE, 'screen_name_plural' => 0, 'tweet_length' => 0, 'carousel_horizontal' => 0, 'carousel_count' => 0, 'carousel_responsive' => 0, 'no_emoji' => 0), $atts);
    extract($args);
    if (empty($screen_name) && empty($search) && !empty($url)) {
        $screen_name = rotatingtweets_link_to_screenname($url);
        $args['screen_name'] = $screen_name;
        if (WP_DEBUG) {
            echo "<!-- {$url} => {$screen_name} -->";
        }
    }
    if (empty($screen_name)) {
        $screen_name = 'twitter';
    }
    # Makes sure the scripts are listed
    rotatingtweets_enqueue_scripts();
    $tweets = rotatingtweets_get_tweets($screen_name, $include_rts, $exclude_replies, $get_favorites, $search, $list);
    $returnstring = rotating_tweets_display($tweets, $args, $print);
    return $returnstring;
}
コード例 #2
0
function rotatingtweets_display_shortcode($atts, $content = null, $code = "", $print = FALSE)
{
    // $atts    ::= twitter_id,include_rts,exclude_replies, $tweet_count,$show_follow
    /**
    	Possible values for get_cforms_entries()
    	$screen_name :: [text]	Twitter user name
    	$include_rts :: [boolean] include RTS - optional
    	$exclude_replies :: [boolean] exclude replies - optional
    	$tweet_count :: [integer] number of tweets to show - optional - default 5
    	$show_follow :: [boolean] show follow button
    	$no_show_count :: [boolean] remove count from follow button
    	$no_show_screen_name :: [boolean] remove screen name from follow button
    */
    $args = shortcode_atts(array('screen_name' => '', 'url' => 'http://twitter.com/twitter', 'include_rts' => FALSE, 'only_rts' => FALSE, 'exclude_replies' => FALSE, 'tweet_count' => 5, 'show_follow' => FALSE, 'timeout' => 4000, 'no_show_count' => FALSE, 'no_show_screen_name' => FALSE, 'show_meta_timestamp' => TRUE, 'show_meta_screen_name' => TRUE, 'show_meta_via' => TRUE, 'show_meta_reply_retweet_favorite' => FALSE, 'show_meta_prev_next' => FALSE, 'show_meta_tweet_counter' => FALSE, 'show_meta_pager' => FALSE, 'show_meta_pager_blob' => '<a href="#">&bull;</a>', 'rotation_type' => 'scrollUp', 'official_format' => FALSE, 'links_in_new_window' => FALSE, 'url_length' => 29, 'search' => FALSE, 'list' => FALSE, 'get_favorites' => FALSE, 'ratelimit' => FALSE, 'next' => __('next', 'rotatingtweets'), 'prev' => __('prev', 'rotatingtweets'), 'middot' => ' &middot; ', 'np_pos' => 'top', 'speed' => 1000, 'offset' => 0, 'link_all_text' => FALSE, 'no_rotate' => FALSE, 'show_media' => FALSE, 'screen_name_plural' => 0, 'tweet_length' => 0, 'carousel_horizontal' => 0, 'carousel_count' => 0, 'carousel_responsive' => 0, 'no_emoji' => 0, 'show_tco_link' => 0, 'w3tc_render_to' => '', 'official_format_override' => FALSE, 'no_cache' => FALSE, 'text_cache_id' => FALSE, 'profile_image_size' => 'normal', 'shuffle' => 0, 'merge_cache' => TRUE, 'rtw_display_order' => 'info,main,media,meta', 'collection' => FALSE), $atts, 'rotatingtweets');
    extract($args);
    if (empty($screen_name) && empty($search) && !empty($url) && empty($collection)) {
        $screen_name = rotatingtweets_link_to_screenname($url);
        $args['screen_name'] = $screen_name;
        if (WP_DEBUG) {
            echo "<!-- {$url} => {$screen_name} -->";
        }
    }
    if ($only_rts) {
        $include_rts = true;
    }
    $args['w3tc_render_to'] = str_replace('widget', 'shortcode', $args['w3tc_render_to']);
    if (!$args['text_cache_id']) {
        $args['text_cache_id'] = "rt-sc-" . md5(serialize($args));
    }
    $args['displaytype'] = 'shortcode';
    if (empty($screen_name)) {
        $screen_name = 'twitter';
    }
    # Makes sure the scripts are listed
    rotatingtweets_enqueue_scripts();
    $returnstring = rotatingtweets_get_transient($args['text_cache_id']);
    if (strlen($returnstring) == 0) {
        $tweets = rotatingtweets_get_tweets($screen_name, $include_rts, $exclude_replies, $get_favorites, $search, $list, $args['merge_cache'], $collection);
        $returnstring = rotating_tweets_display($tweets, $args, $print);
    } elseif (WP_DEBUG) {
        $returnstring .= "<!-- Transient " . $args['text_cache_id'] . " loaded -->";
    }
    return $returnstring;
}