Exemplo n.º 1
0
function haku_get_tweets($user, $number = 3, $haku_tweets = array())
{
    require ABSPATH . WPINC . '/class-simplepie.php';
    $user = str_replace('@', '', $user);
    $tweets_feed = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.atom?screen_name=' . $user . '&count=' . $number);
    if (!is_wp_error($tweets_feed)) {
        $tweets_count = $tweets_feed->get_item_quantity($number);
        $tweets_rss = $tweets_feed->get_items(0, $tweets_count);
    }
    if (!empty($tweets_count)) {
        foreach ($tweets_rss as $tweet) {
            $haku_tweets[] = array('content' => html_entity_decode($tweet->get_content()), 'link' => html_entity_decode($tweet->get_permalink()), 'datetime' => $tweet->get_date(DATE_W3C), 'date' => haku_nice_date($tweet->get_date('U'), true));
        }
    }
    return $haku_tweets;
}
Exemplo n.º 2
0
    function widget($args, $instance)
    {
        extract($args);
        $title = $instance['title'];
        $number = $instance['number'];
        $orderby = $instance['orderby'];
        $order = $instance['order'];
        $nasc_latests_config = array('posts_per_page' => $number, 'orderby' => $orderby, 'order' => $order, 'post_status' => 'publish', 'ignore_sticky_posts' => 1);
        $nasc_latests = new WP_Query($nasc_latests_config);
        /*
        	Before widget
        */
        echo $before_widget;
        if ($title) {
            echo $before_title . retro_filter($title) . $after_title;
        }
        ?>
		
		<!-- Latests widget -->
		
		<ul>
			
			<?php 
        if ($nasc_latests->have_posts()) {
            while ($nasc_latests->have_posts()) {
                $nasc_latests->the_post();
                ?>
			
			<!-- Article -->
			<li>
				<h4><a title="<?php 
                printf(__('Permanent Link to %s', 'haku'), get_the_title());
                ?>
" href="<?php 
                the_permalink();
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				<span>
					<time datetime="<?php 
                the_time(DATE_W3C);
                ?>
"><?php 
                echo haku_nice_date(get_the_time('U'));
                ?>
</time>, 
					<?php 
                comments_popup_link(__('No Comments', 'haku'), __('1 Comment', 'haku'), __('% Comments', 'haku'));
                ?>
				</span>
			</li>
			<!-- end: Article -->
			
			<?php 
            }
        }
        wp_reset_postdata();
        ?>
						
		</ul>

		<!-- end: Latests widget -->
		
		<?php 
        /*
        	After widget
        */
        echo $after_widget;
    }