本文整理汇总了PHP中get_post_modified_time函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_modified_time函数的具体用法?PHP get_post_modified_time怎么用?PHP get_post_modified_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_modified_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: column_default
/**
* Renders the columns.
*
* @since 1.0.0
* @param array $form
* @param string $column_name
* @return string
*/
public function column_default($form, $column_name)
{
switch ($column_name) {
case 'id':
$value = $form->ID;
break;
case 'shortcode':
$value = '[wpforms id="' . $form->ID . '"]';
break;
case 'created':
$value = get_the_date(get_option('date_format'), $form);
break;
case 'modified':
$value = get_post_modified_time(get_option('date_format'), false, $form);
break;
case 'author':
$author = get_userdata($form->post_author);
$value = $author->display_name;
break;
case 'php':
$value = '<code style="display:block;font-size:11px;">if( function_exists( \'wpforms_get\' ) ){ wpforms_get( ' . $form->ID . ' ); }</code>';
break;
default:
$value = '';
}
return apply_filters('wpforms_overview_table_column_value', $value, $form, $column_name);
}
示例2: get_modified_date
public function get_modified_date()
{
if (!$this->id) {
return '';
}
return date_i18n(get_option('date_format'), get_post_modified_time('U', false, $this->id));
}
示例3: get_the_modified_date
function get_the_modified_date($d = '') {
if ( '' == $d )
$the_time = get_post_modified_time(get_option('date_format'));
else
$the_time = get_post_modified_time($d);
return apply_filters('get_the_modified_date', $the_time, $d);
}
示例4: create_sitemap
/**
* Function to create sitemap.xml file in root directory
*
*/
public function create_sitemap($post_id, $post, $update)
{
// only create a site map if the post is new or no file exists
if (wp_is_post_revision($post_id) || is_file($this->path())) {
// return false;
}
$post_types = get_post_types(array('public' => true, 'publicly_queryable' => true));
$nodes = array();
$posts = \Timber::get_posts(array('numberposts' => -1, 'orderby' => array('type', 'modified'), 'post_type' => $post_types, 'order' => 'DESC', 'post_status' => 'publish'));
foreach ($posts as &$post) {
$nodes[] = array('loc' => $post->link, 'lastmod' => get_post_modified_time('c', false, $post), 'changefreq' => $this->get_post_change_frequency($post), 'priority' => $this->get_priority($post));
}
$taxonomies = get_taxonomies(array('public' => true, 'publicly_queryable' => true));
$terms = \Timber::get_terms(array('taxonomy' => $taxonomies, 'hide_empty' => false));
foreach ($terms as &$term) {
$lastest_post = $term->get_post(array('numberposts' => 1));
$nodes[] = array('loc' => get_term_link($term), 'lastmod' => get_post_modified_time('c', false, $lastest_post), 'changefreq' => $this->change_frequency, 'priority' => $this->get_priority($term));
}
$data = array('nodes' => $nodes);
$sitemap = \Timber::compile('sitemap-xml.twig', $data);
$path = $this->path();
if ($fp = fopen($path, 'w')) {
fwrite($fp, $sitemap);
fclose($fp);
}
}
示例5: __construct
/**
* Get things started
*
* @access public
* @since 2.7
* @return void/
*/
public function __construct($sub_id)
{
global $ninja_forms_fields;
// Bail if the sub doesn't exist.
$sub = get_post($sub_id);
if (!is_object($sub)) {
return false;
}
// Set our sub id
$this->sub_id = $sub_id;
// Populate our fields
$this->fields = array();
$this->retrieve_fields();
// Setup our form id var
$this->form_id = $this->get_meta('_form_id');
// Setup our action var
$this->action = $this->get_meta('_action');
// Setup our sequential id
$this->seq_num = $this->get_meta('_seq_num');
// Setup our user_id var
$this->user_id = $sub->post_author;
// Setup our date submitted var
$this->date_submitted = get_the_time('Y-m-d G:i:s', $sub_id);
// Setup our date modified var
$this->date_modified = get_post_modified_time('Y-m-d G:i:s', false, $sub_id);
}
示例6: widget
public function widget($args, $instance)
{
query_posts(array('post_type' => 'resource', 'posts_per_page' => 10));
?>
<ul>
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
//Grab postmeta
$post_meta = get_post_meta(get_the_ID());
//print_r($post_meta); die();
if ($post_meta[type][0] == 'External link') {
?>
<li>
<i class="fa fa-external-link" title="active"></i>
<h5><a href="<?php
echo $post_meta[link_to_resource][0];
?>
" target="_blank"><?php
the_title();
?>
</a></h5>
<p><span class="updated">Last updated <?php
echo human_time_diff(get_post_modified_time('U', $post->ID), current_time('timestamp'));
?>
ago</span></p>
</li>
<?php
} else {
?>
<li>
<i class="fa fa-file" title="active"></i>
<h5><a href="<?php
echo $post_meta[link_to_production_brief][0];
?>
" target="_blank"><?php
the_title();
?>
</a></h5>
<p><span class="updated">Last updated <?php
echo human_time_diff(get_post_modified_time('U', $post->ID), current_time('timestamp'));
?>
ago</span></p>
</li>
<?php
}
}
?>
</ul>
<?php
}
wp_reset_query();
}
示例7: page_audit
function page_audit($new_status, $old_status, $post)
{
error_log("Test");
if ($new_status == 'trash') {
$uid = get_current_user_id();
$post_id = $ip = $date = get_post_modified_time();
error_log("uuid: {$uid}");
}
}
示例8: listing_page__get_the_modified_date
public function listing_page__get_the_modified_date($the_date, $d = '')
{
if (!$this->listing_id) {
return $the_date;
}
if (!$d) {
$d = get_option('date_format');
}
//remove_filter( 'get_the_modified_date', array( &$this, 'listing_page__get_the_modified_date' ), 10, 2 );
return get_post_modified_time($d, false, $this->listing_id, true);
}
示例9: build_metadata
private function build_metadata()
{
$metadata = array('@context' => 'http://schema.org', '@type' => 'BlogPosting', 'mainEntityOfPage' => get_permalink($this->ID), 'headline' => get_the_title($this->ID), 'datePublished' => get_the_date('c', $this->ID), 'dateModified' => get_post_modified_time('c', false, $this->post), 'author' => array('@type' => 'Person', 'name' => $this->author->display_name), 'publisher' => array('@type' => 'Organization', 'name' => get_bloginfo('name')));
$post_image_id = $this->get_post_image_id();
if ($post_image_id) {
$post_image = wp_get_attachment_image_src($post_image_id, 'full');
if ($post_image) {
$metadata['image'] = array('@type' => 'ImageObject', 'url' => $post_image[0], 'width' => $post_image[1], 'height' => $post_image[2]);
}
}
return $metadata;
}
示例10: RecentRevisions
function RecentRevisions()
{
global $wpdb;
$widget_options = RecentRevisions_Options();
$request = "SELECT {$wpdb->posts}.*, display_name as authorname " . "FROM {$wpdb->posts} LEFT JOIN {$wpdb->users} ON {$wpdb->posts}.post_author={$wpdb->users}.ID " . "WHERE (post_type='post' OR (post_type ='revision' AND post_name NOT LIKE '%-autosave')) " . "AND post_status IN('publish', 'inherit')";
$request .= "ORDER BY post_modified_gmt DESC " . "LIMIT " . $widget_options['items'];
$posts = $wpdb->get_results($request);
// Use Date format of WP Preferences
$date_format = get_option('date_format') . ' ' . get_option('time_format');
if ($posts) {
echo "\t\t\t\t<ul id='recent-revisions-list'>\n";
foreach ($posts as $post) {
$post_id = $post->post_type == 'post' ? $post->ID : $post->post_parent;
//make the line
$title = get_the_title($post_id);
$post_meta = sprintf('%s', '<a href="post.php?post=' . $post_id . '&action=edit">' . ($title ? $title : __('(no title)')) . '</a> ');
if ($widget_options['showauthor']) {
$post_meta .= sprintf(__('by %s', 'recent-revisions'), '<strong>' . $post->authorname . '</strong> ');
}
if ($widget_options['showdatetime']) {
// $post_meta .= $post->post_modified_gmt;
$post_meta .= sprintf(__('— %s', 'recent-revisions'), '' . get_post_modified_time($date_format, $widget_options['tz_gmt'], $post->ID, true));
if ($widget_options['tz_gmt']) {
$post_meta .= ' GMT';
}
}
if ($widget_options['showdiff']) {
$request = "SELECT ID FROM {$wpdb->posts} WHERE post_type='revision' AND post_parent=" . $post_id . ' AND post_modified_gmt < "' . $post->post_modified_gmt . '" ORDER BY post_modified_gmt DESC LIMIT 1 ';
$rev = $wpdb->get_row($request);
if (is_null($rev)) {
// No previous revision found
$post_meta .= ' (' . __('new', 'recent-revisions') . ')';
} else {
$prevId = $rev->ID;
$post_meta .= ' (<a href="revision.php?action=diff&post_type=page&right=' . $post->ID . '&left=' . $prevId . '">' . __('diff', 'recent-revisions') . '</a>)';
}
}
//print it out
?>
<li class='post-meta'><?php
echo $post_meta;
?>
</li>
<?php
}
//end the line
echo "</ul>\n";
//but if you got no lines....
} else {
echo '<p>' . __("You don't have any revisions! Are revisions enabled in wp-config.php? Check that WP_POST_REVISIONS is true or >0. ", 'recent-revisions') . "</p>\n";
//echo "<p> You don't have any revisions! Are revisions enabled in wp-config.php? Check that WP_POST_REVISIONS is true or >0. </p>\n";
}
}
示例11: get_all_post_meta
/**
* Get all metadata for a post.
*
* @param \WP_Post $post The post.
* @return array
*/
public static function get_all_post_meta($post)
{
$tags = [['name' => 'description', 'content' => self::get_post_meta_description($post)], ['property' => 'og:locale', 'content' => get_locale()], ['property' => 'og:type', 'content' => 'article'], ['property' => 'og:title', 'content' => self::get_post_og_title($post)], ['property' => 'og:description', 'content' => self::get_post_og_description($post)], ['property' => 'og:url', 'content' => get_permalink($post->ID)], ['property' => 'og:site_name', 'content' => get_bloginfo('title')], ['property' => 'og:updated_time', 'content' => get_post_modified_time('c', true, $post)], ['name' => 'twitter:card', 'content' => self::get_twitter_card_type()], ['name' => 'twitter:title', 'content' => self::get_post_twitter_title($post)], ['name' => 'twitter:description', 'content' => self::get_post_twitter_description($post)]];
$og_image = self::get_post_og_image($post);
$twitter_image = self::get_post_twitter_image($post);
if (!empty($og_image)) {
$og_image_size = getimagesize($og_image);
$tags = array_merge($tags, [['property' => 'og:image', 'content' => $og_image], ['property' => 'og:image:width', 'content' => $og_image_size[0]], ['property' => 'og:image:height', 'content' => $og_image_size[1]]]);
}
if (!empty($twitter_image)) {
$twitter_image_size = getimagesize($twitter_image);
$tags = array_merge($tags, [['name' => 'twitter:image', 'content' => $twitter_image], ['name' => 'twitter:image:width', 'content' => $twitter_image_size[0]], ['name' => 'twitter:image:height', 'content' => $twitter_image_size[1]]]);
}
$tags = array_merge($tags, Site::webmaster_tools());
return ['title' => self::get_post_meta_title($post), 'tags' => $tags];
}
示例12: build_post_data
private function build_post_data()
{
$post_title = get_the_title($this->ID);
$post_publish_timestamp = get_the_date('U', $this->ID);
$post_modified_timestamp = get_post_modified_time('U', false, $this->post);
$post_author = get_userdata($this->post->post_author);
$this->add_data(array('post' => $this->post, 'post_id' => $this->ID, 'post_title' => $post_title, 'post_publish_timestamp' => $post_publish_timestamp, 'post_modified_timestamp' => $post_modified_timestamp, 'post_author' => $post_author));
$metadata = array('@context' => 'http://schema.org', '@type' => 'BlogPosting', 'mainEntityOfPage' => $this->get('canonical_url'), 'publisher' => array('@type' => 'Organization', 'name' => $this->get('blog_name')), 'headline' => $post_title, 'datePublished' => date('c', $post_publish_timestamp), 'dateModified' => date('c', $post_modified_timestamp), 'author' => array('@type' => 'Person', 'name' => $post_author->display_name));
$site_icon_url = $this->get('site_icon_url');
if ($site_icon_url) {
$metadata['publisher']['logo'] = array('@type' => 'ImageObject', 'url' => $site_icon_url, 'height' => self::SITE_ICON_SIZE, 'width' => self::SITE_ICON_SIZE);
}
$image_metadata = $this->get_post_image_metadata();
if ($image_metadata) {
$metadata['image'] = $image_metadata;
}
$this->add_data_by_key('metadata', apply_filters('amp_post_template_metadata', $metadata, $this->post));
}
示例13: ubik_meta_date
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));
}
示例14: get_page_modified
/**
* Retrieves page date the same way it is retrieved in native panel :
* see /wp-admin/includes/class-wp-posts-list-table.php
*/
private static function get_page_modified($post)
{
global $mode;
if ('0000-00-00 00:00:00' == $post->post_modified) {
$t_time = $h_time = __('Unpublished');
$time_diff = 0;
} else {
$t_time = get_post_modified_time(__('Y/m/d g:i:s A'), false, $post, true);
$m_time = $post->post_modified;
$time = get_post_modified_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);
}
}
$page_date = '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, 'apm-last-modified', $mode) . '</abbr>';
return $page_date;
}
示例15: get_the_modified_time
/**
* Retrieve the time at which the post was last modified.
*
* @since 2.0.0
*
* @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
* @return string
*/
function get_the_modified_time($d = '')
{
if ('' == $d) {
$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
} else {
$the_time = get_post_modified_time($d, null, null, true);
}
return apply_filters('get_the_modified_time', $the_time, $d);
}