Пример #1
0
/** 
 * Function to return the most recent comments
 *
 * @uses get_comments() return array List of comments
 */
function dp_list_comments_widget($args = '', $echo = false)
{
    global $comments, $comment;
    $defaults = array('title' => __('Recent Comments', 'dp'), 'number' => 5, 'show_date' => true, 'show_avatar' => true, 'avatar_size' => 48, 'comment_length' => 80);
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $comments = get_comments(array('number' => $number, 'status' => 'approve', 'type' => 'comment'));
    $output = '<ul' . ($show_avatar ? ' class="has-avatar"' : '') . '>';
    if ($comments) {
        foreach ($comments as $comment) {
            $output .= '<li>';
            if ($show_avatar) {
                $output .= get_avatar($comment->comment_author_email, $avatar_size);
            }
            $output .= '<div class="data">';
            $output .= '<span class="author"><a href="' . get_comment_link() . '">' . get_comment_author() . '</a></span> ';
            if ($show_date) {
                $output .= '<span class="date">' . sprintf(__('%s ago', 'dp'), human_time(get_comment_time('U'))) . '</span> ';
            }
            $output .= ' <p class="excerpt">' . mb_strimwidth(strip_tags(apply_filters('comment_content', $comment->comment_content)), 0, $comment_length, "...") . '</p>';
            $output .= '</div></li>';
        }
    }
    $output .= '</ul>';
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
Пример #2
0
	<img src="/avatar/view/<?php 
echo $user_id;
?>
/1" class="left" alt="" style="margin-top:-20px;">
	<div class="left" style="margin-left:10px; color:#eee; padding:10px 0">
		<h3 class="fancy_stats_header"><?php 
echo $username;
?>
's foresting statistics</h3>
		<ul>
			<li><span class="quiet">Leaderboard place</span>: #<?php 
echo $leaderboard_place;
?>
</li>
			<li><span class="quiet">Last Hunted</span>: <?php 
echo human_time($hunter_data['last_hunt']);
?>
</li>
			<?php 
foreach ($forest_stats as $key => $value) {
    ?>
				<li><span class="quiet">Total <?php 
    echo $key;
    ?>
s owned</span>: <?php 
    echo $caught_stats[$key];
    ?>
/<?php 
    echo $value;
    ?>
</li>
Пример #3
0
?>
		<div class="author-box cf">
			<?php 
echo get_avatar($user_id, 64);
?>

			<div class="data">
				<h1 class="display-name"><?php 
the_author_meta('display_name', $user_id);
?>
</h1>
			
				<div class="meta">
				<?php 
if ($user_registered = get_the_author_meta('user_registered', $user_id)) {
    echo '<span class="joined">' . sprintf(__('Joined %s ago', 'dp'), human_time(strtotime($user_registered))) . '</span>';
}
if ($location = get_the_author_meta('location', $user_id)) {
    echo ' <span class="sep">/</span> <span class="location">' . $location . '</span>';
}
?>
				</div>
			
				<div class="links">
				<?php 
if ($twitter = get_the_author_meta('twitter', $user_id)) {
    echo '<a class="twitter" href="' . $twitter . '">' . __('Twitter', 'dp') . '</a> ';
}
if ($facebook = get_the_author_meta('facebook', $user_id)) {
    echo '<a class="facebook" href="' . $facebook . '">' . __('Facebook', 'dp') . '</a> ';
}
Пример #4
0
function format_date($date)
{
    global $BTC_PROXY;

    $obj = new DateTime($date, new DateTimeZone('UTC'));
    $obj->setTimezone(new DateTimeZone($BTC_PROXY['timezone']));

    if ($BTC_PROXY['date_format'] != "human") {
        return $obj->format($BTC_PROXY['date_format']);
    } else {
        $now = new DateTime("now", new DateTimeZone('UTC'));
        $now->setTimezone(new DateTimeZone($BTC_PROXY['timezone']));
        $timespan = $now->getTimestamp() - $obj->getTimestamp();
        return human_time($timespan);
    }
}
Пример #5
0
/**
 * Sub-function to human_time to show a bit more accuracy
 *
 * @return void
 * @author Tyler Diaz
 **/
function _datadate($date)
{
    if (time() - 86400 > strtotime($date)) {
        return human_time($date) . ' (<small>' . date("M jS, Y", strtotime($date)) . '</small>)';
    } else {
        return human_time($date);
    }
}
Пример #6
0
    ?>
			<div class="clearfix">
				<strong class="left" style="font-size:14px; line-height:1.8">
					(<?php 
    echo $topic['short_name'];
    ?>
) <a href="/topic/view/<?php 
    echo $topic['topic_id'];
    ?>
"><?php 
    echo $topic['topic_title'];
    ?>
</a>
				</strong>
				<span class="right" style="font-size:12px; color:#777; line-height:1.8">Posted <?php 
    echo human_time($topic['topic_time']);
    ?>
</span>
			</div>
			<?php 
}
?>
		</div>
	</div>
<div class="row">
	<span class="left large breath"><?php 
echo $this->pagination->create_links();
?>
</span>
</div>
Пример #7
0
 /**
  * New function
  *
  * Description of new function
  *
  * @access  public
  * @param   none
  * @return  output
  */
 public function get_user_data($user_id = 0)
 {
     if (!is_numeric($user_id)) {
         show_error('User ID must be a number!');
     }
     $user_query = $this->db->select('users.user_id, users.username, sessions.last_activity, users.user_last_login, users.user_level, friends.friendship_id')->join('sessions', 'users.user_id = sessions.user_id', 'LEFT')->join('friends', 'friends.friend_id = users.user_id', 'LEFT')->limit(1)->where(array('users.user_id' => $user_id))->get('users');
     if ($user_query->num_rows() > 0) {
         $user_data = $user_query->row_array();
         $user_data['user_last_login'] = human_time($user_data['user_last_login']);
         $user_data['username_clean'] = urlencode($user_data['username']);
         $this->output->set_content_type('application/json')->set_output(json_encode($user_data, JSON_NUMERIC_CHECK));
     } else {
         show_error('user could not be found.');
     }
 }
Пример #8
0
            } else {
                ?>
									<span title="You do not enough palladium to purchase this item" class="inactive_buy_now_button magicTip">Buy now</span>
								<?php 
            }
            ?>
								<!-- <button type="submit" class="bid_button">Bid</button> -->
							<?php 
        }
        ?>
						</td>
						<td class="item_timestamp"><span><?php 
        echo human_time($item['finishes_at'], TRUE);
        ?>
</span><br />Posted <?php 
        echo human_time($item['published_at']);
        ?>
</td>
					</tr>
				<?php 
    }
    ?>
			<?php 
} else {
    ?>
				<div style="border:2px solid #ddd; padding:20px; margin:10px; text-align:center; font-family:arial; font-size:17px; color:#555; border-radius:6px; -moz-border-radius:6px; -webkit-border-radius:6px; line-height:80px;">
					There are no items listed in the marketplace at this moment
				</div>
			<?php 
}
?>
Пример #9
0
		<div style="width:630px; float:left; background:transparent; padding:8px 2px 5px 10px;">
			<div class="clearfix">
				<strong class="left" style="font-size:14px; line-height:1.8">
					Posted in <a href="/topic/view/<?php 
    echo $post['tp_id'];
    ?>
/<?php 
    echo floor($post['tps_id'] / 12) * 12 . '#' . $post['ps_id'];
    ?>
"><?php 
    echo $post['topic_title'];
    ?>
</a>
				</strong>
				<span class="right" style="font-size:12px; color:#777; line-height:1.8">Posted <?php 
    echo human_time($post['post_time']);
    ?>
</span>
			</div>
			<p style="color:#333;">
				<?php 
    echo parse_bbcode(stripslashes(nl2br($post['post_body'])));
    ?>
			</p>
		</div>
	</div>
<?php 
}
?>
<div class="row">
	<span class="left large breath"><?php 
Пример #10
0
?>
				</ul>
			</div>
			<div>
				<ul id="dashboard_notifications">
					<?php 
foreach ($notifications as $notification) {
    ?>
						<li><a href="<?php 
    echo $notification['attatchment_url'];
    ?>
"><?php 
    echo $notification['notification_text'];
    ?>
</a> <span style="font-size:12px; color:#888;">(<?php 
    echo human_time($notification['timestamp']);
    ?>
)</span></li>
					<?php 
}
?>
				</ul>
			</div>
		</div>
	</div>
	<div style="overflow:hidden">
		<div style="background:#ccc; width:246px; float:left; height:130px; margin-left:10px; margin-bottom:10px; color:#888; border-radius:4px;">
			<h4 style="text-align:center; line-height:100px; font-weight:normal; text-shadow:1px 1px 0 #ddd">Coming soon</h4>
		</div>
		<div style="background:#ccc; width:246px; float:left; height:130px; margin-left:10px; margin-bottom:10px; color:#888; border-radius:4px;">
			<h4 style="text-align:center; line-height:100px; font-weight:normal; text-shadow:1px 1px 0 #ddd">Coming sooner</h4>
Пример #11
0
    echo $url;
    ?>
" target="_blank">
                <?php 
    echo '@' . $sname;
    ?>
              </a>
            </small>
          </h5>
          <?php 
    echo make_links($tweet->text);
    ?>
      </div>
      <div class="col-sm-2 tweet-time">
        <?php 
    echo human_time($tweet->created_at);
    ?>
      </div>
    </div>
    <?php 
}
?>

    <?php 
// echo '<pre>' . print_r($tweets, true) . '</pre>';
?>
  </div>

  <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
Пример #12
0
 function human_datetime_split($ts)
 {
     return human_time($ts) . '<BR>' . human_date($ts);
 }
Пример #13
0
 /**
  * New function
  *
  * Description of new function
  *
  * @access  public
  * @param   none
  * @return  output
  */
 public function poll_updates()
 {
     $json_response = array();
     if (strtotime($this->cache->get('marketplace_last_item')) > strtotime($this->input->post('timestamp'))) {
         $json_response['timestamp'] = date('Y-m-d H:i:s', time());
         $marketplace_items = $this->db->select('id, username, item_thumbnail, item_name, price, item_type, item_id, finishes_at, published_at')->limit(6)->order_by('id', 'DESC')->get_where('marketplace_items', array('finishes_at >' => date('Y-m-d H:i:s', time()), 'published_at >' => date('Y-m-d H:i:s', strtotime($this->input->post('timestamp'))), 'purchased' => 0, 'cancled' => 0))->result_array();
         $formatted_items = array();
         foreach ($marketplace_items as $key => $item) {
             $formatted_items[$key] = array('button_class' => $this->system->userdata['user_palladium'] >= $item['price'] ? 'buy_now_button' : 'inactive_buy_now_button', 'time_left' => human_time($item['finishes_at'], TRUE), 'time_published' => human_time($item['published_at']), 'url_username' => urlencode($item['username']));
             $formatted_items[$key] = array_merge($formatted_items[$key], $item);
         }
         $json_response['items'] = $formatted_items;
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($json_response, JSON_NUMERIC_CHECK));
 }
Пример #14
0
    function widget($args, $instance)
    {
        if (!is_singular()) {
            return;
        }
        $cache = wp_cache_get('dp_widget_related_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $style = isset($instance['style']) ? $instance['style'] : 'list';
        extract($args);
        ob_start();
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);
        ?>
		
		<?php 
        echo $before_widget;
        ?>
		
		<?php 
        $r = dp_related_posts(array('number' => $instance['posts_per_page'], 'fields' => 'object'));
        if (!$r || !is_object($r) || !$r->have_posts()) {
            return;
        }
        ?>
		
		<?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		
		<ul class="<?php 
        echo 'post-' . $style;
        ?>
">
			<?php 
        while ($r->have_posts()) {
            $r->the_post();
            $item_format = is_video() ? 'video' : 'post';
            ?>
			<li class="item cf <?php 
            echo 'item-' . $item_format;
            ?>
">
				<?php 
            $image_size = $style == 'list-full' ? 'custom-medium' : 'custom-small';
            dp_thumb_html($image_size);
            ?>
				
				<div class="data">
					<h4 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            echo esc_attr(get_the_title());
            ?>
"><?php 
            the_title();
            ?>
</a></h4>
				
					<p class="meta">
						<span class="author"><?php 
            _e('Added by', 'dp');
            ?>
 <?php 
            the_author_posts_link();
            ?>
</span>
						<span class="time"><?php 
            printf(__('%s ago', 'dp'), human_time(get_the_time('U')));
            ?>
</span>
					</p>
					
					<p class="stats"><?php 
            echo dp_get_post_stats();
            ?>
</p>
				</div>
			</li>
			<?php 
        }
        wp_reset_query();
        ?>
		</ul>
		
		<?php 
        echo $after_widget;
        ?>
		
		<?php 
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('dp_widget_related_posts', $cache, 'widget');
    }
Пример #15
0
the_title();
?>
</a></h2>
			
			<p class="entry-meta">
				<span class="author vcard">
				<?php 
printf('<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'dp'), get_the_author())), get_the_author());
?>
				</span>
				
				<time class="entry-date" datetime="<?php 
echo esc_attr(get_the_date('c'));
?>
"><?php 
printf(__('%s ago', 'dp'), human_time(get_the_time('U')));
?>
</time></a>
			</p>
					
			<p class="stats"><?php 
echo dp_get_post_stats();
?>
</p>

			<p class="entry-summary"><?php 
dp_excerpt();
?>
</p>
		</div>
	</div><!-- end #post-<?php 
Пример #16
0
					By: <a href="/user/<?php 
        echo urlencode($topic['username']);
        ?>
" class="quiet_link"><?php 
        echo $topic['username'];
        ?>
</a> &ndash; <?php 
        echo number_format($topic['total_posts']);
        ?>
 <?php 
        echo $topic['total_posts'] > 1 ? 'replies' : 'reply';
        ?>
				</td>
				<td>
					<span class="large"><?php 
        echo human_time($topic['last_post']);
        ?>
</span>
					<br />
					by <?php 
        echo substr($topic['last_post_username'], 0, 18);
        ?>
 |
					<?php 
        echo anchor('topic/view/' . $topic['topic_id'] . '/' . get_topic_page($topic['total_posts']) . '/#footer', 'View post &rsaquo;');
        ?>
					<?php 
        if ($staff == true) {
            ?>
					<div class="checkbox_holder">
						<input class="multi_select" type="checkbox" name="topic_id[]" value="<?php 
Пример #17
0
				<h4 class="pull-left">Spotlight Topic</h4>
			</div>
			<div class="clearfix widget_content" style="background:#ffa;">
				<div class="media">
					<a class="pull-left" href="#"><img class="media-object" src="http://crysandrea.com/images/avatars/<?php 
    echo $spotlight_topic['user_id'];
    ?>
_headshot.png" width="42" height="42"></a>
					<div class="media-body">
						<div style="margin-bottom:2px;">
							<small>
							<strong class="media-heading"><?php 
    echo anchor('/user/' . urlencode($spotlight_topic['username']), $spotlight_topic['username']);
    ?>
</strong> &#8901; <span class="muted"><?php 
    echo human_time($spotlight_topic['timestamp']);
    ?>
</span>
							</small>
						</div>
						<?php 
    echo anchor('/topic/view/' . $spotlight_topic['topic_id'], $spotlight_topic['topic_title']);
    ?>
					</div>
				</div>
			</div>
		</div>
		<?php 
}
?>
Пример #18
0
/**
 * Custom Comment Callback
 *
 * @since 1.0
 */
function dp_comment_callback($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    ?>
	<li <?php 
    comment_class('cf');
    ?>
 id="comment-<?php 
    comment_ID();
    ?>
">
		<div id="comment-div-<?php 
    comment_ID();
    ?>
" class="comment-div cf">
		<div class="comment-inner">
			<?php 
    if ($args['avatar_size'] != 0) {
        echo '<div class="comment-avatar">' . get_avatar($comment, $args['avatar_size']) . '</div>';
    }
    ?>

			<div class="comment-meta">
				<span class="comment-author"><?php 
    printf(__('<cite class="fn">%s</cite>', 'dp'), get_comment_author_link());
    ?>
</span>
				<a class="comment-time" href="<?php 
    echo '#comment-' . $comment->comment_ID;
    ?>
"><?php 
    printf(__('%s ago', 'dp'), human_time(get_comment_time('U')));
    ?>
</a>
				<?php 
    edit_comment_link(__('Edit', 'dp'), ' <span class="sep">/</span> ', '');
    ?>
			</div>

			<div class="comment-content">
				<?php 
    if ($comment->comment_approved == '0') {
        ?>
					<p class="comment-awaiting-moderation"><?php 
        _e('Your comment is awaiting moderation.', 'dp');
        ?>
</p>
				<?php 
    }
    ?>
		
				<?php 
    comment_text();
    ?>
			</div>
			
			<div class="comment-actions">
				<?php 
    comment_reply_link(array_merge($args, array('add_below' => 'comment-div', 'depth' => $depth, 'max_depth' => $args['max_depth'])));
    ?>
			</div>
		</div>
		</div><!-- end .comment-div -->
<?php 
}
Пример #19
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('dp_widget_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $style = isset($instance['style']) ? $instance['style'] : 'list';
        extract($args);
        ob_start();
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);
        $query_args = $instance;
        $query_args['no_found_rows'] = true;
        $query_args = dp_parse_query_args($query_args);
        $r = new WP_Query(apply_filters('dp_widget_posts_args', $query_args));
        if ($r->have_posts()) {
            ?>
		
		<?php 
            echo $before_widget;
            ?>
		
		<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
		
		<ul class="<?php 
            echo 'post-' . $style;
            ?>
">
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                $item_format = is_video() ? 'video' : 'post';
                ?>
			<li class="item cf <?php 
                echo 'item-' . $item_format;
                ?>
">
				<?php 
                $image_size = $style == 'list-full' ? 'custom-medium' : 'custom-small';
                dp_thumb_html($image_size);
                ?>
				
				<div class="data">
					<h4 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title());
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				
					<p class="meta">
						<span class="author"><?php 
                _e('Added by', 'dp');
                ?>
 <?php 
                the_author_posts_link();
                ?>
</span>
						<span class="time"><?php 
                printf(__('%s ago', 'dp'), human_time(get_the_time('U')));
                ?>
</span>
					</p>
					
					<p class="stats"><?php 
                echo dp_get_post_stats();
                ?>
</p>
				</div>
			</li>
			<?php 
            }
            ?>
		</ul>
		
		<?php 
            echo $after_widget;
            ?>
		
		<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('dp_widget_posts', $cache, 'widget');
    }
Пример #20
0
function list_status($start = NULL, $limit = 50)
{
    $last = last_post_id();
    if ($limit > 0) {
        if (!$start) {
            $start = $last + 1;
        }
        $step = -1;
    } else {
        $limit = -$limit;
        if (!$start) {
            $start = $last - $limit;
        }
        if ($start < 0) {
            $start = 0;
        }
        $n = $last - $start;
        if ($limit > $n) {
            $limit = $n;
        }
        $step = 1;
    }
    $start += $step;
    $ret = array();
    $id = $start;
    while ($limit > 0 && $id > 0 && $id <= $last) {
        if (data_exists("status/post_{$id}")) {
            $item = json_decode(data_read("status/post_{$id}"), true);
            $item['id'] = $id;
            $item['type_lang'] = LANG($item['type']);
            $item['human_time'] = human_time($item['date']);
            $ret[] = $item;
            $limit--;
        }
        $id += $step;
    }
    if ($step > 0) {
        $ret = array_reverse($ret);
    }
    return $ret;
}
Пример #21
0
function format_time($format, $time)
{
    $time = mysql_to_unix('0000-00-00 ' . $time);
    $return = human_time($format, $time);
    return $return;
}
Пример #22
0
function multi_twitter($widget)
{
    if (!class_exists('Codebird')) {
        require 'lib/codebird.php';
    }
    // Initialize Codebird with our keys.  We'll wait and
    // pass the token when we make an actual request
    Codebird::setConsumerKey($widget['consumer_key'], $widget['consumer_secret']);
    $cb = Codebird::getInstance();
    $output = '';
    // Get our root upload directory and create cache if necessary
    $upload = wp_upload_dir();
    $upload_dir = $upload['basedir'] . "/cache";
    if (!file_exists($upload_dir)) {
        if (!mkdir($upload_dir)) {
            $output .= '<span style="color: red;">' . sprintf(__('Could not create dir "%s"; please create this directory.', 'multi-twitter-widget'), $upload_dir) . '</span>';
            return $output;
        }
    }
    // split the accounts and search terms specified in the widget
    $accounts = explode(" ", $widget['users']);
    $terms = explode(", ", $widget['terms']);
    $output .= '<ul class="multi-twitter">';
    // Parse the accounts and CRUD cache
    $feeds = null;
    foreach ($accounts as $account) {
        if ($account != "") {
            $cache = false;
            // Assume the cache is empty
            $cFile = "{$upload_dir}/users_{$account}.txt";
            if (file_exists($cFile)) {
                $modtime = filemtime($cFile);
                $timeago = time() - 1800;
                // 30 minutes ago
                // Check if length is less than new limit
                $str = file_get_contents($cFile);
                $content = unserialize($str);
                $length = count($content);
                if ($modtime < $timeago or $length != $widget['user_limit']) {
                    // Set to false just in case as the cache needs to be renewed
                    $cache = false;
                } else {
                    // The cache is not too old so the cache can be used.
                    $cache = true;
                }
            }
            // begin
            if ($cache === false) {
                $cb->setToken($widget['access_token'], $widget['access_token_secret']);
                $params = array('screen_name' => $account, 'count' => $widget['user_limit']);
                // let Codebird make an authenticated request  Result is json
                $reply = $cb->statuses_userTimeline($params);
                // turn the json into an array
                $json = json_decode($reply, true);
                $length = count($json);
                for ($i = 0; $i < $length; $i++) {
                    // add it to the feeds array
                    $feeds[] = $json[$i];
                    // prepare it for caching
                    $content[] = $json[$i];
                }
                // Let's save our data into uploads/cache/
                $fp = fopen($cFile, 'w');
                if (!$fp) {
                    $output .= '<li style="color: red;">' . sprintf(__('Permission to write cache dir to <em>%s</em> not granted.', 'multi-twitter-widget'), $cFile) . '</li>';
                } else {
                    $str = serialize($content);
                    fwrite($fp, $str);
                }
                fclose($fp);
                $content = null;
            } else {
                //cache is true let's load the data from the cached file
                $str = file_get_contents($cFile);
                $content = unserialize($str);
                $length = count($content);
                // echo $length;
                for ($i = 0; $i < $length; $i++) {
                    // add it to the feeds array
                    $feeds[] = $content[$i];
                }
            }
        }
        // end account empty check
    }
    // end accounts foreach
    // Parse the terms and CRUD cache
    foreach ($terms as $term) {
        if ($term != "") {
            $cache = false;
            // Assume the cache is empty
            $cFile = "{$upload_dir}/term_{$term}.txt";
            if (file_exists($cFile)) {
                $modtime = filemtime($cFile);
                $timeago = time() - 1800;
                // 30 minutes ago
                // Check if length is less than new limit
                $str = file_get_contents($cFile);
                $content = unserialize($str);
                $length = count($content);
                if ($modtime < $timeago or $length != $widget['term_limit']) {
                    // Set to false just in case as the cache needs to be renewed
                    $cache = false;
                } else {
                    // The cache is not too old so the cache can be used.
                    $cache = true;
                }
            }
            if ($cache === false) {
                $cb->setToken($widget['access_token'], $widget['access_token_secret']);
                $search_params = array('q' => $term, 'count' => $widget['term_limit']);
                $reply = $cb->search_tweets($search_params);
                $json = json_decode($reply, true);
                $length = count($json['statuses']);
                for ($i = 0; $i < $length; $i++) {
                    // add it to the feeds array
                    $feeds[] = $json['statuses'][$i];
                    // prepare it for caching
                    $content[] = $json['statuses'][$i];
                }
                if ($content === false) {
                    // Content couldn't be retrieved... Do something..
                    $output .= '<li>' . __('Content could not be retrieved; Twitter API failed.', 'multi-twitter-widget') . '</li>';
                } else {
                    // Let's save our data into uploads/cache/
                    $fp = fopen($cFile, 'w');
                    if (!$fp) {
                        $output .= '<li style="color: red;">' . sprintf(__('Permission to write cache dir to <em>%s</em> not granted.', 'multi-twitter-widget'), $cFile) . '</li>';
                    } else {
                        fwrite($fp, serialize($content));
                    }
                    fclose($fp);
                    $content = null;
                }
            } else {
                //cache is true let's load the data from the cached file
                $str = file_get_contents($cFile);
                $content = unserialize($str);
                $length = count($content);
                for ($i = 0; $i < $length; $i++) {
                    // add it to the feeds array
                    $feeds[] = $content[$i];
                }
            }
        }
        // end terms empty check
    }
    // end terms foreach
    // Sort our $feeds array
    if ($widget['sort_by_date']) {
        usort($feeds, "feed_sort");
    }
    // Split array and output results
    $i = 1;
    // format the tweet for display
    foreach ($feeds as $feed) {
        if (!empty($feed)) {
            $output .= '<li class="tweet clearfix" style="margin-bottom:8px;">' . '<a href="http://twitter.com/' . $feed['user']['screen_name'] . '">' . '<img class="twitter-avatar" src="' . $feed['user']['profile_image_url'] . '" width="40" height="40" alt="' . $feed['user']['screen_name'] . '" />' . '</a>';
            $output .= '<span class="tweet-userName">' . $feed['user']['name'] . '</span>';
            if ($widget['date']) {
                $output .= '<span class="tweet-time">' . human_time(strtotime($feed['created_at'])) . '</span>';
            }
            $output .= '<span class="tweet-message">' . format_tweet($feed['text'], $widget) . '</span>';
            $output .= '</li>';
        }
    }
    $output .= '</ul>';
    if ($widget['credits'] === true) {
        $output .= '<hr /><strong>' . __('Development by', 'multi-twitter-widget') . '</strong> ' . '<a href="http://twitter.com/thinkclay" target="_blank">Clay McIlrath</a>, ' . '<a href="http://twitter.com/roger_hamilton" target="_blank">Roger Hamilton</a>, ' . '<a href="http://twitter.com/wrought/" target="_blank">Matt Senate</a>, and ' . '<a href="http://twitter.com/cviebrock/" target="_blank">Colin Viebrock</a>.';
    }
    if ($widget['styles'] === true) {
        $output .= '<style type="text/css">' . '.twitter-avatar { clear: both; float: left; padding: 6px 12px 2px 0; }' . '.twitter{background:none;}' . '.tweet{min-height:48px;margin:0!important;}' . '.tweet a{text-decoration:underline;}' . '.tweet-userName{padding-top:7px;font-size:12px;line-height:0;color:#454545;font-family:Arial,sans-serif;font-weight:700;margin-bottom:10px;margin-left:8px;float:left;min-width:50px;}' . '.twitter-avatar{width:48px;height:48px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;padding:0!important;}' . '.tweet-time{color:#8A8A8A;float:left;margin-top:-3px;font-size:11px!important;}' . '.tweet-message{font-size:11px;line-height:14px;color:#333;font-family:Arial,sans-serif;word-wrap:break-word;margin-top:-30px!important;width:200px;margin-left:58px;}' . '</style>';
    }
    echo $output;
}
Пример #23
0
<div class="clearfix">
	<div id="bug_showcase" class="center_shine">
 		<div id="cover_pane"></div>
		<div id="forest_levelup_bubble">
			<h4>You are now level <strong id="new_level_amount">12</strong></h4>
			<h5>You can now catch <strong id="new_bug_possibilities">2</strong> different type of bugs. Your energy has also been fully restored.</h5>
			<a href="#" id="close_levelup_bubble">Ok! Continue hunting &rsaquo;</a>
		</div>
		<div class="forest_success_bubble"><img src="/images/icons/forest/success.png" alt="" /> <span></span></div>
		<div class="forest_alert_bubble"><img src="/images/icons/forest/alert.png" alt="" /> <span></span></div>
		<div class="forest_ajax_bubble"><img src="/images/icons/forest/activity_indicator.gif" alt=""></div>
		<div class="hunt_placeholder" style="text-align:center;">
			<br />
			<h2 style="line-height:1.4;">Ready to start hunting?</h2>
			<h4>You energy will fully restore in about <span id="energy_time_left"> <?php 
echo substr(human_time(date("Y-m-d H:i:s", time() + $recover_time_left), TRUE), 0, -4);
?>
</span></h4>
			<a href="#" id="start_hunting" class="main_button">Start hunting</a>
		</div>
		<div class="hide hunt_template">
			<img src="/images/insects/unset.gif" alt="" width="180" height="180" id="bug_image" />
			<h5 id="capture_title">Just letting you know this is a...</h5>
			<h2 id="bug_name">Placeholder bug</h2>
			<p id="bug_description">“Never mind me, I'm just here to take the place of a bug you're about to find...”</p><br />
			<p id="bug_data"><img src="/images/icons/little_palladium.png" style="margin-top:-3px" width="18" height="18" alt=""> <span id="total_bug_value">16</span> palladium &bull; Rarity: <span id="bug_rarity">Uncommon</span></p><br />
		</div>
	</div>
	<div id="forest_sidebar">
		<div class="before_hunting">
			<h2 id="before_you_go">Before you go bug hunting...</h2>