Пример #1
0
function ts_the_recent_tweets()
{
    ?>
	<?php 
    if (get_post_meta(ts_get_current_id(), 'show_recent_tweet_footer', true) == 'yes') {
        $tweets = ts_get_recent_tweet();
        if ($tweets['is_error'] == 'true' && ot_get_option('show_recent_tweet_footer_show_errors') == 'yes') {
            ?>
			<aside class='wrapper blue'>
				<section class='container blue-radial-grad widget widget_single_tweet'>
					<div class='grid_12'>
						<div class='widget_single_tweet-container'>
							<article id="recent-tweets" class='item'>
								<ul class="slides">
									<li><div class="message"><?php 
            echo $tweets['error'];
            ?>
</div></li>
								</ul>
							</article>
						</div>
					</div>
				</section>
			</aside>

		<?php 
        } elseif (!empty($tweets['tweets'])) {
            $tweets['tweets'] = json_decode($tweets['tweets']);
            if (is_array($tweets['tweets']) && count($tweets['tweets']) > 0) {
                ?>
				<aside class='wrapper blue'>
					<section class='container blue-radial-grad widget widget_single_tweet'>
						<div class='pagination'>
							<span class='prev-t3'></span>
							<span class='next-t3'></span>
						</div>
						<div class='grid_12'>
							<div class='widget_single_tweet-container'>
								<article id="recent-tweets" class='item'>
									<ul class="slides">
										<?php 
                $i = 0;
                foreach ($tweets['tweets'] as $tweet) {
                    ?>
											<li <?php 
                    echo $i > 0 ? 'style="display: none;"' : '';
                    ?>
>
												<?php 
                    $datetime = $tweet->created_at;
                    $date = date('M d, Y', strtotime($datetime));
                    $time = date('g:ia', strtotime($datetime));
                    $tweet_text = $tweet->text;
                    // check if any entites exist and if so, replace then with hyperlinked versions
                    if (!empty($tweet->entities->urls) || !empty($tweet->entities->hashtags) || !empty($tweet->entities->user_mentions)) {
                        foreach ($tweet->entities->urls as $url) {
                            $find = $url->url;
                            $replace = '<a href="' . $find . '">' . $find . '</a>';
                            $tweet_text = str_replace($find, $replace, $tweet_text);
                        }
                        foreach ($tweet->entities->hashtags as $hashtag) {
                            $find = '#' . $hashtag->text;
                            $replace = '<a href="http://twitter.com/#!/search/%23' . $hashtag->text . '">' . $find . '</a>';
                            $tweet_text = str_replace($find, $replace, $tweet_text);
                        }
                        foreach ($tweet->entities->user_mentions as $user_mention) {
                            $find = "@" . $user_mention->screen_name;
                            $replace = '<a href="http://twitter.com/' . $user_mention->screen_name . '">' . $find . '</a>';
                            $tweet_text = str_ireplace($find, $replace, $tweet_text);
                        }
                    }
                    ?>
												<div class="message"><?php 
                    echo $tweet_text;
                    ?>
</div>
												<footer class="time"><?php 
                    echo $tweet->created_at;
                    ?>
</footer>
											</li>
											<?php 
                    $i++;
                    ?>
										<?php 
                }
                ?>
									</ul>
								</article>
								<script>
									jQuery(document).ready(function($) {

										$('footer.time').each(function() {
											var date = new Date($(this).html()),
											diff = (((new Date()).getTime() - date.getTime()) / 1000),
											day_diff = Math.floor(diff / 86400);

											if ( isNaN(day_diff) || day_diff < 0)
											{
												jQuery('footer.time').html('');
											}

											difference_text = day_diff == 0 && (
												diff < 60 && "<?php 
                _e('just now', 'circles');
                ?>
" ||
												diff < 120 && "<?php 
                _e('1 minute ago', 'circles');
                ?>
" ||
												diff < 3600 && Math.floor( diff / 60 ) + " <?php 
                _e('minutes ago', 'circles');
                ?>
" ||
												diff < 7200 && "<?php 
                _e('1 hour ago', 'circles');
                ?>
" ||
												diff < 86400 && Math.floor( diff / 3600 ) + " <?php 
                _e('hours ago', 'circles');
                ?>
") ||
												day_diff == 1 && "<?php 
                _e('Yesterday', 'circles');
                ?>
" ||
												day_diff < 7 && day_diff + " <?php 
                _e('days ago', 'circles');
                ?>
" ||
												day_diff < 31 && Math.ceil( day_diff / 7 ) + " <?php 
                _e('weeks ago', 'circles');
                ?>
" ||
												day_diff < 365 && Math.ceil( day_diff / 30 ) + " <?php 
                _e('months ago', 'circles');
                ?>
" ||
												day_diff < 730  && "<?php 
                _e('1 year ago', 'circles');
                ?>
" ||
												day_diff >= 730  && Math.ceil( day_diff / 365 ) + " <?php 
                _e('years ago', 'circles');
                ?>
";

											$(this).html(difference_text);
										});
									});


								</script>
							</div>
						</div>
					</section>
				</aside>
			<?php 
            }
        }
        ?>
	<?php 
    }
}
Пример #2
0
										<div class='column_post-category'>
											<span>
												<?php 
            echo $categories;
            ?>
											</span>
										</div>
									<?php 
        }
        ?>
								</footer>
								<div class="column_post-body">

									<?php 
        $length = 'regular';
        $page_length = get_post_meta(ts_get_current_id(), 'excerpt_length', true);
        if (!empty($page_length)) {
            $length = $page_length;
        }
        ts_the_excerpt_theme($length);
        ?>

								</div>
							</div>
						</article>
					<?php 
    }
    ?>
				<?php 
}
?>
Пример #3
0
/**
 * Get position of the sidebar defined for single post or page
 *
 * @return string sidebar position, possible values: left, right, both, no
 *
 * @since framework 1.0
 */
function ts_get_single_post_sidebar_position()
{
    return get_post_meta(ts_get_current_id(), 'sidebar_position_single', true);
}
Пример #4
0
/**
 * Get one of the registered sidebar, depends on Theme options or single post settings
 * Used when sidebar is defined in OptionTree and attached to single post or page using metaboxes
 * Function gets left_sidebar or right_sidebar (these are names of metaboxes not sidebars ids!)
 *
 * @param string sidebar position left or right
 * @param string default default sidebar is not set
 * @return string/bool return string sidebar id or false if sidebar doesn't exists
 * 
 * @since framework 1.0
 */
function ts_get_single_post_sidebar_id($position, $default = 'main')
{
    $sidebar = get_post_meta(ts_get_current_id(), $position, true);
    if (empty($sidebar)) {
        $sidebar = $default;
    }
    return $sidebar;
}