function realistic_time_ago() { global $post; $date = get_post_time('G', true, $post); // Array of time period chunks $chunks = array(array(60 * 60 * 24 * 365, __('year', 'realistic'), __('years', 'realistic')), array(60 * 60 * 24 * 30, __('month', 'realistic'), __('months', 'realistic')), array(60 * 60 * 24 * 7, __('week', 'realistic'), __('weeks', 'realistic')), array(60 * 60 * 24, __('day', 'realistic'), __('days', 'realistic')), array(60 * 60, __('hour', 'realistic'), __('hours', 'realistic')), array(60, __('minute', 'realistic'), __('minutes', 'realistic')), array(1, __('second', 'realistic'), __('seconds', 'realistic'))); if (!is_numeric($date)) { $time_chunks = explode(':', str_replace(' ', ':', $date)); $date_chunks = explode('-', str_replace(' ', '-', $date)); $date = gmmktime((int) $time_chunks[1], (int) $time_chunks[2], (int) $time_chunks[3], (int) $date_chunks[1], (int) $date_chunks[2], (int) $date_chunks[0]); } $current_time = current_time('mysql', $gmt = 0); $newer_date = strtotime($current_time); // Difference in seconds $since = $newer_date - $date; // Something went wrong with date calculation and we ended up with a negative date. if (0 > $since) { return __('sometime', 'realistic'); } //Step one: the first chunk for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; // Finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { break; } } // Set output var $output = 1 == $count ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; if (!(int) trim($output)) { $output = '0 ' . __('seconds', 'realistic'); } $output .= __(' ago', 'realistic'); return $output; }
public function getPostData() { $fooName = 'bbp_get_' . $this->postType . '_content'; $content = $fooName($this->postId); $return = array('autor' => array('isCurrentUser' => $this->autorId == get_current_user_id(), 'url' => bp_core_get_user_domain($this->autorId), 'avatar' => bp_core_fetch_avatar(array('item_id' => $autorId, 'height' => $imgSize, 'width' => $imgSize)), 'name' => bbp_get_reply_author_display_name($this->postId)), 'type' => $this->postType, 'attachmentList' => $this->_getAttachmentList(), 'sContent' => bbp_get_reply_content($this->postId), 'id' => $this->postId, 'likes' => 0, 'sDate' => get_post_time('j F ', false, $this->postId, true) . __('at', 'qode') . get_post_time(' H:i', false, $this->postId, true), 'sContentShort' => mb_substr($content, 0, 500), 'sContent' => $content, 'like' => get_post_meta($this->postId, 'likes', true), 'isLiked' => get_post_meta($this->postId, 'like_' . $autorId, true)); return $return; }
function column_date($post) { if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } if ('excerpt' == $mode) { echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); } else { echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; } echo '<br />'; if ('publish' == $post->post_status) { _e('Published'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; } else { _e('Scheduled'); } } else { _e('Last Modified'); } }
function sp_get_time($post = 0, $format = null) { if (null == $format) { $format = get_option('time_format'); } return get_post_time($format, false, $post, true); }
function column_date($post) { $html = ''; if ('0000-00-00 00:00:00' == $post->post_date) { $t_time = $h_time = __('Unpublished', 'jetpack'); $time_diff = 0; } else { $t_time = date(__('Y/m/d g:i:s A', 'jetpack'), mysql2date('G', $post->post_date)); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago', 'jetpack'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d', 'jetpack'), $m_time); } } $html .= '<abbr title="' . esc_attr($t_time) . '">' . esc_html($h_time) . '</abbr>'; $html .= '<br />'; if ('publish' == $post->post_status) { $html .= esc_html__('Published', 'jetpack'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { $html .= '<strong class="attention">' . esc_html__('Missed schedule', 'jetpack') . '</strong>'; } else { $html .= esc_html__('Scheduled', 'jetpack'); } } else { $html .= esc_html__('Last Modified', 'jetpack'); } return $html; }
function maybe_add_robots() { global $post; if (is_singular() && bbp_is_topic($post->ID) && bbp_is_topic_closed($post->ID) && time() - get_post_time('U', true, $post) > YEAR_IN_SECONDS) { echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; } }
/** * 作用: 显示历史相同日文章 * 来源: 自产 * URL: */ function apip_sameday_post() { global $wpdb; $month = get_post_time('m'); $day = get_post_time('j'); $id = get_the_ID(); global $apip_options; $limit = $apip_options['local_definition_count'] ? $apip_options['local_definition_count'] : 5; $ret = '<ul class = "apip-history-content">'; $sql = "select ID, year(post_date) as h_year, post_title FROM \r\n {$wpdb->posts} WHERE post_password = '' AND post_type = 'post' AND post_status = 'publish' \r\n AND month(post_date)='{$month}' AND day(post_date)='{$day}' AND ID != '{$id}' \r\n order by post_date LIMIT {$limit}"; $history_posts = $wpdb->get_results($sql); $rcount = $limit - count($history_posts); if ($rcount > 0) { $random_posts = apip_random_post(get_the_ID(), $rcount); } foreach ($history_posts as $history_post) { $ret = $ret . '<li><span>' . $history_post->h_year . ': <span><a class="sameday-post" href="' . get_permalink($history_post->ID) . '">'; $ret = $ret . $history_post->post_title . '</a></li>'; } if ($rcount > 0) { foreach ($random_posts as $random_post) { $ret = $ret . '<li><span>RAND: </span><a class="sameday-post" href="' . get_permalink($random_post->ID) . '">'; $ret = $ret . $random_post->post_title . '</a></li>'; } } $ret = $ret . '</ul>'; return $ret; }
/** * WP filter handler. Returns: * - Relative date. * - Absolute date with `$this->wp_fallback` format, if relative is not suitable. * * @param int $wp_time - Timestamp? * @return string */ public function get_time($wp_time) { global $post; $time = get_post_time('U', true, $post); $diff = $this->diff($time, null, true, false, $this->wp_fallback); return !is_int($diff) ? $diff : $wp_time; }
function widget($args, $instance) { global $post; /* PRINT THE WIDGET */ extract($args, EXTR_SKIP); $title = !empty($instance['title']) ? $instance['title'] : ''; if (!is_single()) { return; } echo $before_widget; if (!empty($title)) { echo $before_title; echo $title; echo $after_title; } $name = get_the_author_meta('display_name', $post->post_author); echo '<div class="large-icons">'; echo '<ul>'; edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'myThemes'), '<li>', '</li>'); echo '<li><a href="' . get_day_link(get_post_time('Y', false, $post->ID), get_post_time('m', false, $post->ID), get_post_time('d', false, $post->ID)) . '">'; echo '<time datetime="' . get_post_time('Y-m-d', false, $post->ID) . '"><i class="icon-calendar"></i>' . get_post_time(get_option('date_format'), false, $post->ID) . '</time></a></li>'; echo '<li><a href="' . get_author_posts_url($post->post_author) . '" title="' . __('Writed by ', 'myThemes') . ' ' . $name . '"><i class="icon-user-5"></i>' . $name . '</a></li>'; if ($post->comment_status == 'open') { $nr = get_comments_number($post->ID); if ($nr == 1) { $comments = $nr . ' ' . __('Comment', 'myThemes'); } else { $comments = $nr . ' ' . __('Comments', 'myThemes'); } echo '<li><a href="' . get_comments_link($post->ID) . '"><i class="icon-comment"></i>' . $comments . '</a></li>'; } echo '</ul>'; echo '</div>'; echo $after_widget; }
function write_here_time_edit($edit = 1, $for_post = 1, $tab_index = 0, $multi = 0) { global $wp_locale, $comment; // Get post ID from URL and assign it to 'get_post' to get post info $post_id = $_REQUEST['post']; $post = get_post($post_id); if ($for_post) { $edit = !(in_array($post->post_status, array('draft', 'pending')) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt)); } $tab_index_attribute = ''; if ((int) $tab_index > 0) { $tab_index_attribute = " tabindex=\"{$tab_index}\""; } // todo: Remove this? // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; // Assign published date of posts instead of current time $time_adj = get_post_time('U', true, $post_id); $post_date = $post->post_date; $jj = $edit ? mysql2date('d', $post_date, false) : gmdate('d', $time_adj); $mm = $edit ? mysql2date('m', $post_date, false) : gmdate('m', $time_adj); $aa = $edit ? mysql2date('Y', $post_date, false) : gmdate('Y', $time_adj); $hh = $edit ? mysql2date('H', $post_date, false) : gmdate('H', $time_adj); $mn = $edit ? mysql2date('i', $post_date, false) : gmdate('i', $time_adj); $ss = $edit ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj); $cur_jj = gmdate('d', $time_adj); $cur_mm = gmdate('m', $time_adj); $cur_aa = gmdate('Y', $time_adj); $cur_hh = gmdate('H', $time_adj); $cur_mn = gmdate('i', $time_adj); $month = '<label><span class="screen-reader-text">' . __('Month') . '</span><select ' . ($multi ? '' : 'id="mm" ') . 'name="mm"' . $tab_index_attribute . ">\n"; for ($i = 1; $i < 13; $i = $i + 1) { $monthnum = zeroise($i, 2); $monthtext = $wp_locale->get_month_abbrev($wp_locale->get_month($i)); $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected($monthnum, $mm, false) . '>'; /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ $month .= sprintf(__('%1$s-%2$s'), $monthnum, $monthtext) . "</option>\n"; } $month .= '</select></label>'; $day = '<label><span class="screen-reader-text">' . __('Day') . '</span><input type="text" ' . ($multi ? '' : 'id="jj" ') . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; $year = '<label><span class="screen-reader-text">' . __('Year') . '</span><input type="text" ' . ($multi ? '' : 'id="aa" ') . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>'; $hour = '<label><span class="screen-reader-text">' . __('Hour') . '</span><input type="text" ' . ($multi ? '' : 'id="hh" ') . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; $minute = '<label><span class="screen-reader-text">' . __('Minute') . '</span><input type="text" ' . ($multi ? '' : 'id="mn" ') . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>'; echo '<div class="timestamp-wrap">'; /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ printf(__('%1$s %2$s, %3$s @ %4$s:%5$s'), $month, $day, $year, $hour, $minute); echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; if ($multi) { return; } echo "\n\n"; $map = array('mm' => array($mm, $cur_mm), 'jj' => array($jj, $cur_jj), 'aa' => array($aa, $cur_aa), 'hh' => array($hh, $cur_hh), 'mn' => array($mn, $cur_mn)); foreach ($map as $timeunit => $value) { list($unit, $curr) = $value; echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n"; $cur_timeunit = 'cur_' . $timeunit; echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n"; } }
function get_post_data($post_object) { global $post; $post = $post_object; setup_postdata($post); $post_class = get_post_class(); $post_data = array('author' => get_the_author(), 'author_url' => get_author_posts_url(get_the_author_meta('ID')), 'classes' => join(' ', $post_class), 'content' => get_the_content(), 'date' => get_the_date(), 'datetime' => get_post_time('c', true), 'excerpt' => get_the_excerpt(), 'json_url' => '/wp-json/wp/v2/posts/' . get_the_ID(), 'title' => get_the_title(), 'link' => str_replace(home_url(), '', get_the_permalink())); return $post_data; }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Popular Posts', 'heal') : $instance['title'], $instance, $this->id_base); $count = empty($instance['count']) ? 5 : $instance['count']; echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="popular-post"> <?php $pc = new WP_Query('orderby=comment_count&posts_per_page=' . $count . ''); while ($pc->have_posts()) { $pc->the_post(); ?> <li> <?php if (has_post_thumbnail()) { the_post_thumbnail('widget-thumb'); } else { echo '<img src="' . get_template_directory_uri() . '/assets/images/no-img-thumb.jpg">'; } ?> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "><?php the_title(); ?> </a> <br/ > <time class="post-meta-element" datetime="<?php echo get_post_time('U', true); ?> "><?php echo get_the_date('j F, Y'); ?> </time> | <span class="popular-post-comment"> <?php comments_popup_link('No Comments;', '1 Comment', '% Comments'); ?> </span> </li> <?php } ?> <?php wp_reset_query(); ?> </ul><!-- /.latest-post --> <?php echo $after_widget; }
public function listing_page__get_the_date($the_date, $d = '') { if (!$this->listing_id) { return $the_date; } if (!$d) { $d = get_option('date_format'); } //remove_filter( 'get_the_date', array( &$this, 'listing_page__get_the_date' ), 10, 2 ); return get_post_time($d, $this->listing_id); }
/** * Prints HTML with meta information for the current post-date/time and author. */ function simple_life_posted_on() { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>'; if (get_the_time('U') !== get_the_modified_time('U')) { $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>'; } $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date())); $posted_on = sprintf('%s', '<i class="fa fa-calendar" aria-hidden="true"></i> <a href="' . esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))) . '" rel="bookmark">' . $time_string . '</a>'); $byline = sprintf('<i class="fa fa-user" aria-hidden="true"></i> %s', '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>'); echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. }
function dynamictime() { global $post; $date = $post->post_date; $time = get_post_time('G', true, $post); $mytime = time() - $time; if ($mytime > 0 && $mytime < 24 * 60 * 60) { $mytimestamp = sprintf(__('%s ago'), human_time_diff($time)); } else { $mytimestamp = date(get_option('date_format'), strtotime($date)); } return $mytimestamp; }
function gardenia_entry_meta() { $gardenia_categories_list = get_the_category_list(',', ''); $gardenia_tag_list = get_the_tag_list('', ','); $gardenia_author = get_the_author(); $gardenia_author_url = esc_url(get_author_posts_url(get_the_author_meta('ID'))); $gardenia_comments = wp_count_comments(get_the_ID()); $gardenia_date = sprintf('<time datetime="%1$s">%2$s</time>', sanitize_text_field(get_the_date('c')), esc_html(get_the_date())); ?> <div class="fancy_categories"> <div class="glyphicon glyphicon-user color"><a href="<?php echo $gardenia_author_url; ?> " rel="tag"><?php echo $gardenia_author; ?> </a></div> <div class="glyphicon glyphicon-calendar color"><a href="<?php echo esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))); ?> " rel="tag"><?php echo $gardenia_date; ?> </a></div> <?php if (!empty($gardenia_tag_list)) { ?> <div class="glyphicon glyphicon-tag color"><?php echo $gardenia_tag_list; ?> </div><?php } ?> <?php if (!empty($gardenia_categories_list)) { ?> <div class="glyphicon glyphicon-folder-open color"><?php echo $gardenia_categories_list; ?> </div><?php } ?> <div class="glyphicon glyphicon-comment color"><span class="comment"><?php comments_number(__('No Comments', 'gardenia'), __('1 Comment', 'gardenia'), __('% Comments', 'gardenia')); ?> </span></div> </div> <?php }
function tcc_time_flags($post_id = 0) { //判斷時間軸 $t1 = date("Y-m-d H:i:s",mktime(date("H"), date("i"), date("s"), date("m"), date("d") - 7, date("Y"))); // 7天內新訊息 $t2 = get_post_time('Y-m-d H:i:s'); if ($t1 < $t2) { echo "<span class='glyphicon glyphicon-ok-sign aria-hidden='true' title='" . __('New', 'tcc') . "' style='color:green;'></span>"; } if (get_post_meta($post_id, '_expiration', true) != '') { $t1 = date("Y-m-d H:i:s",mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 7, date("Y"))); // 7天內到期 $t2 = date_format(date_create(get_post_meta($post_id, '_expiration', true)), 'Y-m-d H:i:s'); if ($t1 > $t2) { echo "<span class='glyphicon glyphicon-time' aria-hidden='true' title='" . __('Upcoming', 'tcc') . "' style='color:red;'></span>"; } } }
function wpbppost_meta() { ?> <ul class="post-meta inline-list"> <li> Posted: <a href="<?php echo get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j')); ?> "> <?php printf('<time datetime="%1$s">%2$s</time>', esc_attr(get_the_date('c')), esc_html(get_the_date())); ?> </a> </li> <li> <?php the_tags('Tags: ', ', ', ''); ?> </li> <li> <?php $categories = get_the_category(); $separator = ', '; $output = ''; if (!empty($categories)) { foreach ($categories as $category) { $output .= '<a href="' . esc_url(get_category_link($category->term_id)) . '" alt="' . esc_attr(sprintf(__('View all posts in %s', 'textdomain'), $category->name)) . '">' . esc_html($category->name) . '</a>' . $separator; } echo 'Categories: '; echo trim($output, $separator); } ?> </li> <li> Author: <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> "><?php echo get_the_author_meta('display_name'); ?> </a> </li> </ul> <?php }
function avocation_entry_meta() { $avocation_category_list = get_the_category_list(', ', ' <i class="fa fa-list-all"></i> '); $avocation_tag_list = get_the_tag_list('<i class="fa fa-tags"></i> ', ' , '); $avocation_date = sprintf('<time datetime="%1$s">%2$s</time>', esc_attr(get_the_date('c')), esc_html(get_the_date())); $avocation_author = sprintf('<a href="%1$s" title="%2$s" >%3$s</a>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'avocation'), get_the_author())), get_the_author()); if ($avocation_category_list) { $avocation_utility_text = '<div class="blog-meta"><ul><li><a href=' . esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))) . ' > <i class="fa fa-calendar"></i> %3$s </a></li> <li> <i class="fa fa-user"></i> %4$s </li> <li> %2$s </li> <li> <i class="fa fa-list-alt"></i> %1$s </li> <li> <i class="fa fa-comment"></i> ' . avocation_comment_number_custom() . '</li></ul></div>'; } elseif ($avocation_tag_list) { $avocation_utility_text = '<div class="blog-meta"><ul><li><a href=' . esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))) . ' > <i class="fa fa-calendar"></i> %3$s </a></li> <li> <i class="fa fa-user"></i> %4$s </li> </li> <li> %2$s </li> <li> %1$s </li> <li> <i class="fa fa-comment"></i> ' . avocation_comment_number_custom() . '</li></ul></div>'; } else { $avocation_utility_text = '<div class="blog-meta"><ul><li><a href=' . esc_url(get_day_link(get_post_time('Y'), get_post_time('m'), get_post_time('j'))) . ' > <i class="fa fa-calendar"></i> %3$s </a></li> <li> <i class="fa fa-user"></i> %4$s </li> <li> <i class="fa fa-comment"></i> ' . avocation_comment_number_custom() . '</li></ul></div>'; } printf($avocation_utility_text, $avocation_category_list, $avocation_tag_list, $avocation_date, $avocation_author); }
/** * Filters the month name and month code tags */ public static function filter_post_link($permalink, $post) { if (false === strpos($permalink, '%monthname%') && false === strpos($permalink, '%monthcode%')) { return $permalink; } try { $monthindex = intval(get_post_time('n', "GMT" == false, $post->ID)); $monthname = self::$monthnames[$monthindex - 1]; $monthcode = self::$monthcodes[$monthindex - 1]; $permalink = str_replace('%monthname%', $monthname, $permalink); $permalink = str_replace('%monthcode%', $monthcode, $permalink); return $permalink; } catch (Exception $e) { return $permalink; } }
function widget($args, $instance) { global $post; /* PRINT THE WIDGET */ extract($args, EXTR_SKIP); $instance = wp_parse_args((array) $instance, array('title' => '')); $title = esc_attr($instance['title']); if (!is_single()) { return; } echo $before_widget; if (!empty($title)) { echo $before_title; echo apply_filters('widget_title', $title, $instance, $this->id_base); echo $after_title; } $name = get_the_author_meta('display_name', $post->post_author); echo '<div class="large-icons">'; echo '<ul>'; edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'myThemes'), '<li>', '</li>'); echo '<li><a href="' . get_day_link(get_post_time('Y', false, $post->ID), get_post_time('m', false, $post->ID), get_post_time('d', false, $post->ID)) . '">'; echo '<time datetime="' . get_post_time('Y-m-d', false, $post->ID) . '"><i class="icon-calendar"></i>' . get_post_time(get_option('date_format'), false, $post->ID) . '</time></a></li>'; echo '<li><a href="' . get_author_posts_url($post->post_author) . '" title="' . __('Writed by ', 'myThemes') . ' ' . $name . '"><i class="icon-user-5"></i>' . $name . '</a></li>'; if ($post->comment_status == 'open') { $nr = get_comments_number($post->ID); if ($nr == 1) { $comments = $nr . ' ' . __('Comment', 'myThemes'); } else { $comments = $nr . ' ' . __('Comments', 'myThemes'); } echo '<li><a href="' . get_comments_link($post->ID) . '"><i class="icon-comment"></i>' . $comments . '</a></li>'; } if (function_exists('stats_get_csv')) { $args = array('days' => -1, 'post_id' => $post->ID); $result = stats_get_csv('postviews', $args); $views = $result[0]['views']; $nr_views = number_format_i18n($views); $label_views = __('views', 'myThemes'); if ($nr_views == 1) { $label_views = __('view', 'myThemes'); } echo '<li><i class="icon-eye-2"></i> ' . $nr_views . ' ' . $label_views . '</li>'; } echo '</ul>'; echo '</div>'; echo $after_widget; }
/** * get meta information for current post */ function teaberry_entry_meta() { /* used between list items */ $cats = get_the_category_list(', '); $tags = get_the_tag_list('', ', '); $date = sprintf('<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>', esc_url(get_month_link(get_post_time('Y'), get_post_time('m'))), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date())); $name = sprintf('<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'teaberry'), get_the_author())), get_the_author()); /* make meta text */ if ($tags) { $text = __('Added in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry'); } elseif ($cats) { $text = __('Added in %1$s on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry'); } else { $text = __('Added on %3$s<span class="by-author"> by %4$s</span>. ', 'teaberry'); } printf($text, $cats, $tags, $date, $name); }
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post = NULL) { if ($_REQUEST['wps_send_subscribe'] == 'yes') { if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) { global $wpdb, $table_prefix, $sms, $wps_options; if ($_REQUEST['wps_subscribe_group'] == 'all') { $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes"); } else { $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes WHERE group_ID = '{$_REQUEST['wps_subscribe_group']}'"); } $template_vars = array('title_post' => get_the_title($post->ID), 'url_post' => wp_get_shortlink($post->ID), 'date_post' => get_post_time('Y-m-d', true, $post->ID, true)); $sms->msg = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $_REQUEST['wps_custom_text']); $sms->SendSMS(); } } return $post; }
function widget($args, $instance) { global $post; /* PRINT THE WIDGET */ extract($args, EXTR_SKIP); $instance = wp_parse_args((array) $instance, array('title' => '')); $title = $instance['title']; if (!is_single()) { return; } echo $before_widget; if (!empty($title)) { echo $before_title; echo apply_filters('widget_title', esc_attr($title), $instance, $this->id_base); echo $after_title; } $y = esc_attr(get_post_time('Y', false, $post->ID)); $m = esc_attr(get_post_time('m', false, $post->ID)); $d = esc_attr(get_post_time('d', false, $post->ID)); $name = get_the_author_meta('display_name', $post->post_author); $dtime = get_post_time('Y-m-d', false, $post->ID); $ptime = get_post_time(esc_attr(get_option('date_format')), false, $post->ID, true); echo '<div class="large-icons">'; echo '<ul>'; edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'treeson'), '<li>', '</li>'); echo '<li><a href="' . esc_url(get_day_link($y, $m, $d)) . '">'; echo '<time datetime="' . esc_attr($dtime) . '"><i class="icon-calendar"></i>' . esc_html($ptime) . '</time></a></li>'; echo '<li><a href="' . esc_url(get_author_posts_url($post->post_author)) . '" title="' . sprintf(__('Writed by %s', 'treeson'), esc_attr($name)) . '"><i class="icon-user-5"></i>' . esc_html($name) . '</a></li>'; if ($post->comment_status == 'open') { $nr = get_comments_number($post->ID); echo '<li>'; echo '<a href="' . esc_url(get_comments_link($post->ID)) . '">'; echo '<i class="icon-comment"></i>'; echo sprintf(_nx('%s Comment', '%s Comments', absint($nr), 'Number of comment(s) from widget "myThemes: Meta Details"', 'treeson'), number_format_i18n(absint($nr))); echo '</a></li>'; } if (function_exists('stats_get_csv')) { $args = array('days' => -1, 'post_id' => $post->ID); $result = stats_get_csv('postviews', $args); $views = $result[0]['views']; echo '<li><i class="icon-eye-2"></i> ' . sprintf(_n('%s view', '%s views', absint($views), 'treeson'), number_format_i18n(absint($views))) . '</li>'; } echo '</ul>'; echo '</div>'; echo $after_widget; }
function dynamictime($p = null) { global $post; if (!$p) { $p = $post; } // pass the post object as the first parameter, defaults to the current post if left empty $date = $p->post_date; $time = get_post_time('G', true, $p); $mytime = time() - $time; if ($mytime > 0 && $mytime < 7 * 24 * 60 * 60) { // use twitter like date format if not older than one week (7 days) $mytimestamp = sprintf(__('%s ago', 'djp2015'), human_time_diff($time)); } else { $mytimestamp = date_i18n(get_option('date_format'), strtotime($date)); } return $mytimestamp; }
function ubik_meta_date($format = '') { // Get the time $published = get_post_time(); $updated = get_post_modified_time(); // Set the time zone offset $offset = (int) get_option('gmt_offset') * 60 * 60; if (empty($offset)) { $offset = 0; } // In case something goes horribly awry // Initialize variables $published_html = $updated_html = ''; $published_class = 'published dt-published'; // Microformats classes $updated_class = 'updated dt-updated'; // No need to display updated when the timestamps are identical if ($published === $updated) { $updated = ''; } // Grace period; allows for the used of the updated time instead of the published time when the difference is less than a specified time period (defaults to 3 hours) if (apply_filters('ubik_meta_date_grace_period', false) === true && !empty($updated)) { if ($updated - $published <= apply_filters('ubik_meta_date_grace_period_length', 10800)) { $published_class .= ' ' . $updated_class; $published = $updated; $updated = ''; } } // Default format if (empty($format)) { $format = sprintf(_x('%1$s, %2$s', 'date, time', 'ubik'), get_option('date_format'), get_option('time_format')); } // Generate HTML output for both dates if (is_int($published)) { $published_display = apply_filters('ubik_meta_date_published', date($format, $published), $published); $published_html = '<time class="' . $published_class . '" itemprop="datePublished" datetime="' . date('c', $published - $offset) . '">' . $published_display . '</time>'; } if (is_int($updated)) { $updated_display = apply_filters('ubik_meta_date_updated', date($format, $updated), $updated); $updated_html = '<time class="' . $updated_class . '" itemprop="dateModified" datetime="' . date('c', $updated - $offset) . '">' . $updated_display . '</time>'; } // Populate the date array return apply_filters('ubik_meta_date', array('published' => apply_filters('ubik_meta_date_published_html', $published_html), 'updated' => apply_filters('ubik_meta_date_updated_html', $updated_html), 'published_raw' => $published, 'updated_raw' => $updated)); }
function wp_sms_subscribe_send($wp_sms_new_status = NULL, $wp_sms_old_status = NULL, $post_ID = NULL) { if ($_REQUEST['subscribe_post'] == 'yes') { if ('publish' == $wp_sms_new_status && 'publish' != $wp_sms_old_status) { global $wpdb, $table_prefix, $sms; $sms->to = $wpdb->get_col("SELECT mobile FROM {$table_prefix}sms_subscribes"); $string = get_option('wp_sms_text_template'); $template_vars = array('title_post' => get_the_title($post_ID), 'url_post' => wp_get_shortlink($post_ID), 'date_post' => get_post_time(get_option('date_format'), true, $post_ID)); $final_message = preg_replace('/%(.*?)%/ime', "\$template_vars['\$1']", $string); if (get_option('wp_sms_text_template')) { $sms->msg = $final_message; } else { $sms->msg = get_the_title($post_ID); } $sms->SendSMS(); } } return $post_ID; }
public function add_html($string, $format) { // If a Unix timestamp was requested, then don't modify it as it's most likely being used for PHP and not display // Also don't do anything for feeds if ('U' === $format || is_feed()) { return $string; } // Populate the format if missing if (empty($format)) { switch (current_filter()) { case 'get_the_date': case 'get_comment_date': $format = get_option('date_format'); break; case 'get_post_time': case 'get_comment_time': $format = get_option('time_format'); break; default: return $string; } } // Get the GMT unfiltered value remove_filter(current_filter(), array(&$this, 'add_html'), 1, 2); switch (current_filter()) { case 'get_the_date': case 'get_post_time': $gmttime = get_post_time('c', true); break; case 'get_comment_date': case 'get_comment_time': $gmttime = get_comment_time('c', true); break; default: $gmttime = false; // Gotta add the filter back } add_filter(current_filter(), array(&$this, 'add_html'), 1, 2); if (!$gmttime) { return $string; } return '<span class="localtime" data-ltformat="' . esc_attr($format) . '" data-lttime="' . esc_attr($gmttime) . '">' . $string . '</span>'; }
/** * Populate # of Articles on Print Issue post list table * * @uses manage_print-issue_posts_custom_column, get_post_meta * @return void */ function populate_print_issue_cpt_columns($colname, $post_id) { $post = get_post($post_id); if ('modified' === $colname) { $t_time = get_the_time(__('Y/m/d g:i:s a')); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } echo esc_html($h_time); } if ('custom-date' === $colname) { echo esc_html(get_the_date()); } }
/** * ************************************************************** * * * CACHe CHECKING FUNCTION * * * ******************************************************************/ function swp_is_cache_fresh($post_id, $output = false, $ajax = false) { global $swp_user_options; // Bail early if it's a crawl bot. If so, ONLY SERVE CACHED RESULTS FOR MAXIMUM SPEED. if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', wp_unslash($_SERVER['HTTP_USER_AGENT']))) { return true; } $options = $swp_user_options; $fresh_cache = false; // Bail if output isn't being forced and legacy caching isn't enabled. if (!$output && 'legacy' !== $options['cacheMethod']) { if ('rebuild' !== get_query_var('swp_cache')) { $fresh_cache = true; } return $fresh_cache; } // Always be TRUE if we're not on a single.php otherwise we could end up // Rebuilding multiple page caches which will cost a lot of time. if (!is_singular() && !$ajax) { return true; } $post_age = floor(date('U') - get_post_time('U', false, $post_id)); if ($post_age < 21 * 86400) { $hours = 1; } elseif ($post_age < 60 * 86400) { $hours = 4; } else { $hours = 12; } $time = floor(date('U') / 60 / 60); $last_checked = get_post_meta($post_id, 'swp_cache_timestamp', true); if ($last_checked > $time - $hours && $last_checked > 390000) { $fresh_cache = true; } else { $fresh_cache = false; } return $fresh_cache; }