Esempio n. 1
0
 /**
  * @covers WPSEO_News_Sitemap::add_to_index
  */
 public function test_add_to_index()
 {
     $output = $this->instance->add_to_index('');
     $output_date = new DateTime(get_lastpostdate('gmt'), new DateTimeZone(new WPSEO_News_Sitemap_Timezone()));
     $expected_output = '<sitemap>' . "\n";
     $expected_output .= '<loc>' . home_url('news-sitemap.xml') . '</loc>' . "\n";
     $expected_output .= '<lastmod>' . htmlspecialchars($output_date->format('c')) . '</lastmod>' . "\n";
     $expected_output .= '</sitemap>' . "\n";
     $this->assertEquals($expected_output, $output);
 }
Esempio n. 2
0
 /**
  * Add the XML News Sitemap to the Sitemap Index.
  *
  * @param string $str String with Index sitemap content.
  *
  * @return string
  */
 public function add_to_index($str)
 {
     $date = new DateTime(get_lastpostdate('gmt'), new DateTimeZone(new WPSEO_News_Sitemap_Timezone()));
     /**
      * Filter: 'wpseo_news_sitemap_name' - Allow filtering the news sitemap XML URL
      *
      * @api string $news_sitemap_xml The news sitemap XML URL
      */
     $news_sitemap_xml = WPSEO_News::get_sitemap_name();
     $str .= '<sitemap>' . "\n";
     $str .= '<loc>' . $news_sitemap_xml . '</loc>' . "\n";
     $str .= '<lastmod>' . htmlspecialchars($date->format('c')) . '</lastmod>' . "\n";
     $str .= '</sitemap>' . "\n";
     return $str;
 }
 /**
  * Handles daily ping
  */
 public function SendPingDaily()
 {
     $this->LoadOptions();
     $blogUpdate = strtotime(get_lastpostdate('blog'));
     $lastPing = $this->GetOption('i_lastping');
     $yesterday = time() - 60 * 60 * 24;
     if ($blogUpdate >= $yesterday && ($lastPing == 0 || $lastPing <= $yesterday)) {
         $this->SendPing();
     }
     if ($this->GetOption('b_stats')) {
         $this->SendStats();
     }
 }
    function get_feed($page = 1, $post_type = 'post')
    {
        global $post, $wp, $wp_query, $posts, $wpdb, $blog_id;
        log_app('function', "get_feed({$page}, '{$post_type}')");
        ob_start();
        if (!isset($page)) {
            $page = 1;
        }
        $page = (int) $page;
        $count = get_option('posts_per_rss');
        wp('what_to_show=posts&posts_per_page=' . $count . '&offset=' . ($count * ($page - 1) . '&orderby=modified'));
        $post = $GLOBALS['post'];
        $posts = $GLOBALS['posts'];
        $wp = $GLOBALS['wp'];
        $wp_query = $GLOBALS['wp_query'];
        $wpdb = $GLOBALS['wpdb'];
        $blog_id = (int) $GLOBALS['blog_id'];
        log_app('function', "query_posts(# " . print_r($wp_query, true) . "#)");
        log_app('function', "total_count(# {$wp_query->max_num_pages} #)");
        $last_page = $wp_query->max_num_pages;
        $next_page = $page + 1 > $last_page ? NULL : $page + 1;
        $prev_page = $page - 1 < 1 ? NULL : $page - 1;
        $last_page = (int) $last_page == 1 || (int) $last_page == 0 ? NULL : (int) $last_page;
        $self_page = $page > 1 ? $page : NULL;
        ?>
<feed xmlns="<?php 
        echo $this->ATOM_NS;
        ?>
" xmlns:app="<?php 
        echo $this->ATOMPUB_NS;
        ?>
" xml:lang="<?php 
        echo get_option('rss_language');
        ?>
">
<id><?php 
        $this->the_entries_url();
        ?>
</id>
<updated><?php 
        echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastpostmodified('GMT'));
        ?>
</updated>
<title type="text"><?php 
        bloginfo_rss('name');
        ?>
</title>
<subtitle type="text"><?php 
        bloginfo_rss("description");
        ?>
</subtitle>
<link rel="first" type="<?php 
        echo $this->ATOM_CONTENT_TYPE;
        ?>
" href="<?php 
        $this->the_entries_url();
        ?>
" />
<?php 
        if (isset($prev_page)) {
            ?>
<link rel="previous" type="<?php 
            echo $this->ATOM_CONTENT_TYPE;
            ?>
" href="<?php 
            $this->the_entries_url($prev_page);
            ?>
" />
<?php 
        }
        if (isset($next_page)) {
            ?>
<link rel="next" type="<?php 
            echo $this->ATOM_CONTENT_TYPE;
            ?>
" href="<?php 
            $this->the_entries_url($next_page);
            ?>
" />
<?php 
        }
        ?>
<link rel="last" type="<?php 
        echo $this->ATOM_CONTENT_TYPE;
        ?>
" href="<?php 
        $this->the_entries_url($last_page);
        ?>
" />
<link rel="self" type="<?php 
        echo $this->ATOM_CONTENT_TYPE;
        ?>
" href="<?php 
        $this->the_entries_url($self_page);
        ?>
" />
<rights type="text">Copyright <?php 
        echo mysql2date('Y', get_lastpostdate('blog'));
        ?>
</rights>
<?php 
        the_generator('atom');
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $this->echo_entry();
            }
        }
        ?>
</feed>
<?php 
        $feed = ob_get_contents();
        ob_end_clean();
        return $feed;
    }
Esempio n. 5
0
 /**
  * Handles daily ping
  */
 public function SendPingDaily()
 {
     $this->LoadOptions();
     $blogUpdate = strtotime(get_lastpostdate('blog'));
     $lastPing = $this->GetOption('i_lastping');
     $yesterday = time() - 60 * 60 * 24;
     if ($blogUpdate >= $yesterday && ($lastPing == 0 || $lastPing <= $yesterday)) {
         $this->SendPing();
     }
     //Send statistics if enabled (disabled by default)
     if ($this->GetOption('b_stats')) {
         $this->SendStats();
     }
     //Cache the support feed so there is no delay when loading the user interface
     if ($this->GetOption('i_supportfeed')) {
         $last = $this->GetOption('i_supportfeed_cache');
         if ($last <= time() - $this->GetSupportFeedCacheLifetime()) {
             $supportFeed = $this->GetSupportFeed();
             if (!is_wp_error($supportFeed) && $supportFeed) {
                 $this->SetOption('i_supportfeed_cache', time());
                 $this->SaveOptions();
             }
         }
     }
 }
Esempio n. 6
0
/**
 * Get the timestamp of the last time any post was modified.
 *
 * The server timezone is the default and is the difference between GMT and
 * server time. The 'blog' value is just when the last post was modified. The
 * 'gmt' is when the last post was modified in GMT time.
 *
 * @since 1.2.0
 * @since 4.4.0 The `$post_type` argument was added.
 *
 * @param string $timezone  Optional. The timezone for the timestamp. See {@see get_lastpostdate()}
 *                          for information on accepted values.
 *                          Default 'server'.
 * @param string $post_type Optional. The post type to check. Default 'any'.
 * @return string The timestamp.
 */
function get_lastpostmodified($timezone = 'server', $post_type = 'any')
{
    /**
     * Pre-filter the return value of get_lastpostmodified() before the query is run.
     *
     * @since 4.4.0
     *
     * @param string $lastpostmodified Date the last post was modified.
     *                                 Returning anything other than false will short-circuit the function.
     * @param string $timezone         Location to use for getting the post modified date.
     *                                 See {@see get_lastpostdate()} for accepted `$timezone` values.
     * @param string $post_type        The post type to check.
     */
    $lastpostmodified = apply_filters('pre_get_lastpostmodified', false, $timezone, $post_type);
    if (false !== $lastpostmodified) {
        return $lastpostmodified;
    }
    $lastpostmodified = _get_last_post_time($timezone, 'modified', $post_type);
    $lastpostdate = get_lastpostdate($timezone);
    if ($lastpostdate > $lastpostmodified) {
        $lastpostmodified = $lastpostdate;
    }
    /**
     * Filter the date the last post was modified.
     *
     * @since 2.3.0
     *
     * @param string $lastpostmodified Date the last post was modified.
     * @param string $timezone         Location to use for getting the post modified date.
     *                                 See {@see get_lastpostdate()} for accepted `$timezone` values.
     */
    return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
}
header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
$more = 1;

?>
<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
<feed version="0.3"
  xmlns="http://purl.org/atom/ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="<?php echo get_option('rss_language'); ?>"
  >
	<title><?php bloginfo_rss('name') ?></title>
	<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
	<tagline><?php bloginfo_rss("description") ?></tagline>
	<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></modified>
	<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></copyright>
	<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
	
	<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
	<entry>
	  	<author>
			<name><?php the_author() ?></name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
		<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
		<id><?php the_guid(); ?></id>
		<modified><?php the_time('Y-m-d\TH:i:s\Z'); ?></modified>
		<issued>  <?php the_time('Y-m-d\TH:i:s\Z'); ?></issued>
		<?php the_category_rss('rdf') ?>
		<summary type="<?php bloginfo('html_type'); ?>" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if (!get_settings('rss_use_excerpt')) : ?>
Esempio n. 8
0
<?php

include 'includes/connection.php';
require './wp-blog-header.php';
header("Content-type: text/xml");
header('HTTP/1.1 200 OK');
$posts_to_show = 1000;
// 获取文章数量
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<?xml-stylesheet type="text/xsl" href="/sitemap.xsl"?>';
// XSL地址
echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
?>
<!-- generated-on=<?php 
echo get_lastpostdate('blog');
?>
 Modified Gimhoy(http://blog.gimhoy.com)-->
  <url>
      <loc><?php 
echo get_home_url();
?>
</loc>
      <lastmod><?php 
$ltime = get_lastpostmodified(GMT);
$ltime = gmdate('Y-m-d\\TH:i:s+00:00', strtotime($ltime));
echo $ltime;
?>
</lastmod>
      <changefreq>daily</changefreq>
      <priority>1.0</priority>
  </url>
function get_lastpostmodified($timezone = 'server') {
	global $cache_lastpostmodified, $pagenow, $wpdb;
	$add_seconds_blog = get_settings('gmt_offset') * 3600;
	$add_seconds_server = date('Z');
	$now = current_time('mysql', 1);
	if ( !isset($cache_lastpostmodified[$timezone]) ) {
		switch(strtolower($timezone)) {
			case 'gmt':
				$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
				break;
			case 'blog':
				$lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
				break;
			case 'server':
				$lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
				break;
		}
		$lastpostdate = get_lastpostdate($timezone);
		if ( $lastpostdate > $lastpostmodified ) {
			$lastpostmodified = $lastpostdate;
		}
		$cache_lastpostmodified[$timezone] = $lastpostmodified;
	} else {
		$lastpostmodified = $cache_lastpostmodified[$timezone];
	}
	return $lastpostmodified;
}
 function get_lastpostmodified()
 {
     static $cache_lastpostmodified;
     if (!isset($cache_lastpostmodified[wp_id()]) || !$GLOBALS['use_cache']) {
         $criteria =& new CriteriaCompo(new Criteria('post_date', current_time('mysql'), "<="));
         $criteria->add(new Criteria('post_status', 'publish'));
         $criteria->setSort('post_modified');
         $criteria->setOrder('DESC');
         $criteria->setLimit(1);
         $postHandler =& wp_handler('Post');
         $postObjects =& $postHandler->getObjects($criteria, false, 'post_modified');
         $lastpostmodified = $postObjects[0]->getVar('post_modified');
         $lastpostdate = get_lastpostdate();
         if ($lastpostmodified < $lastpostdate) {
             $cache_lastpostmodified[wp_id()] = $lastpostmodified = $lastpostdate;
         } else {
             $cache_lastpostmodified[wp_id()] = $lastpostmodified;
         }
     } else {
         $lastpostmodified = $GLOBALS['lastpostmodified'][wp_id()];
     }
     return $lastpostmodified;
 }
Esempio n. 11
0
echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>
"/>
    <link rel="alternate" type="<?php 
bloginfo('html_type');
?>
" href="<?php 
bloginfo_rss('home');
?>
/"/>
    <updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastpostmodified('GMT'), false);
?>
</updated>
    <rights>Copyright <?php 
echo mysql2date('Y', get_lastpostdate('blog'), 0);
?>
</rights>
    <generator uri="http://wordpress.org/" version="<?php 
bloginfo_rss('version');
?>
">WordPress</generator>
    <?php 
do_action('atom_head');
$items_count = 0;
if ($posts) {
    foreach ($posts as $post) {
        start_wp();
        ?>
    <entry>
        <title type="html"><![CDATA[ <?php 
 function get_last_post_date()
 {
     $ret = array();
     // get_lastpostdate built in function retrieves date for whatever post type while we
     // want posts not to break the archive display
     // if no posts are available we use get_lastpostdate to prevent interpreter to throw errors
     // and we expect a 404 page in FE
     $args = array('posts_per_page' => 1, 'offset' => 0, 'category' => '', 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => array('publish', 'private'), 'suppress_filters' => false);
     $posts = get_posts($args);
     if ($posts && isset($posts[0])) {
         $date = $posts[0]->post_date;
     } else {
         $date = get_lastpostdate('blog');
     }
     $lastpost = strtotime($date);
     $ret['year'] = date('Y', $lastpost);
     $ret['month'] = date('m', $lastpost);
     $ret['day'] = date('d', $lastpost);
     return (object) $ret;
 }
Esempio n. 13
0
	<subtitle type="xhtml">	
		<div xmlns="http://www.w3.org/1999/xhtml">
			<strong><?php 
bloginfo_rss('description');
?>
</strong><br /><br />
			Insert more <strong>info</strong> about your blog here.
		</div>
	</subtitle>
	
	<updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastpostmodified('gmt'), false);
?>
</updated>
	<rights>Copyright <?php 
echo mysql2date('Y', get_lastpostdate('gmt'), false);
?>
 <?php 
bloginfo_rss('name');
?>
</rights>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.5/</creativeCommons:license>
	<generator uri="http://wordpress.org/" version="<?php 
bloginfo_rss('version');
?>
">WordPress</generator>

	<author>
		<name><?php 
bloginfo_rss('name');
?>
        $lastpostdate = mysql2date('U', $lastpostdate);
        $otherdate = date('Y-m-d H:i:s', $lastpostdate - ($posts_per_page - 1) * 86400);
        $where .= ' AND post_date > \'' . $otherdate . '\'';
    }
}
if (!empty($postend) && $postend > $poststart && !$m && empty($monthnum) && empty($year) && empty($day) && !$w && !$whichcat && !$s && !$p) {
    if ($what_to_show == 'posts' || $what_to_show == 'paged' && !$paged) {
        $poststart = intval($poststart);
        $postend = intval($postend);
        $limposts = $postend - $poststart;
        $limits = ' LIMIT ' . $poststart . ',' . $limposts;
    } elseif ($what_to_show == 'days') {
        $poststart = intval($poststart);
        $postend = intval($postend);
        $limposts = $postend - $poststart;
        $lastpostdate = get_lastpostdate();
        $lastpostdate = mysql2date('Y-m-d 00:00:00', $lastpostdate);
        $lastpostdate = mysql2date('U', $lastpostdate);
        $startdate = date('Y-m-d H:i:s', $lastpostdate - ($poststart - 1) * 86400);
        $otherdate = date('Y-m-d H:i:s', $lastpostdate - ($postend - 1) * 86400);
        $where .= ' AND post_date > \'' . $otherdate . '\' AND post_date < \'' . $startdate . '\'';
    }
} else {
    if ($what_to_show == 'paged' && !$p && !$more) {
        if ($pagenow != 'post.php') {
            $pgstrt = '';
            if ($paged) {
                $pgstrt = (intval($paged) - 1) * $posts_per_page . ', ';
            }
            $limits = 'LIMIT ' . $pgstrt . $posts_per_page;
        } else {
        $_lastpostdate = mysql2date('U', $_lastpostdate);
        $_otherdate = date('Y-m-d H:i:s', $_lastpostdate - ($GLOBALS['posts_per_page'] - 1) * 86400);
        $_criteria->add(new Criteria('post_date', $_otherdate, '>'));
    }
}
if (test_param('postend') && get_param('postend') > get_param('poststart') && !test_param('m') && !test_param('monthnum') && !test_param('year') && !test_param('day') && !test_param('w') && !test_param('cat') && !test_param('category_name') && !test_param('s') && !test_param('p')) {
    if ($GLOBALS['what_to_show'] == 'posts' || $GLOBALS['what_to_show'] == 'paged' && !test_param('paged')) {
        $_poststart = intval(get_param('poststart'));
        $_postend = intval(get_param('postend'));
        $_criteria_limit = $_postend - $_poststart;
        $_criteria_start = $_poststart;
    } elseif ($GLOBALS['what_to_show'] == 'days') {
        $_poststart = intval(get_param('poststart'));
        $_postend = intval(get_param('postend'));
        $_limposts = $_postend - $_poststart;
        $_lastpostdate = mysql2date('Y-m-d 00:00:00', get_lastpostdate());
        $_lastpostdate = mysql2date('U', $_lastpostdate);
        $_startdate = date('Y-m-d H:i:s', $_lastpostdate - ($_poststart - 1) * 86400);
        $_otherdate = date('Y-m-d H:i:s', $_lastpostdate - ($_postend - 1) * 86400);
        $_criteria->add(new Criteria('post_date', $_startdate, '<'));
        $_criteria->add(new Criteria('post_date', $_otherdate, '>'));
    }
} else {
    if ($GLOBALS['what_to_show'] == 'paged' && !test_param('p') && !test_param('more')) {
        if ($GLOBALS['pagenow'] != 'post.php') {
            if (test_param('paged')) {
                $_criteria_start = (intval(get_param('paged')) - 1) * $GLOBALS['posts_per_page'];
            }
            $_criteria_limit = $GLOBALS['posts_per_page'];
        } else {
            if (test_param('m') || test_param('p') || test_param('w') || test_param('s') || test_param('cat') || test_param('category_name')) {
Esempio n. 16
0
/**
 * get_lastpostmodified() - {@internal Missing Short Description}}
 *
 * {@internal Missing Long Description}}
 *
 * @package WordPress
 * @subpackage Post
 * @since 1.2
 *
 * @uses $wpdb
 * @uses $blog_id
 * @uses apply_filters() Calls 'get_lastpostmodified' filter
 *
 * @global mixed $cache_lastpostmodified Stores the date the last post was modified
 * @global mixed $pagenow The current page being viewed
 *
 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
 * @return string The date the post was last modified.
 */
function get_lastpostmodified($timezone = 'server')
{
    global $cache_lastpostmodified, $wpdb, $blog_id;
    $add_seconds_server = date('Z');
    if (!isset($cache_lastpostmodified[$blog_id][$timezone])) {
        switch (strtolower($timezone)) {
            case 'gmt':
                $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
                break;
            case 'blog':
                $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
                break;
            case 'server':
                $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '{$add_seconds_server}' SECOND) FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
                break;
        }
        $lastpostdate = get_lastpostdate($timezone);
        if ($lastpostdate > $lastpostmodified) {
            $lastpostmodified = $lastpostdate;
        }
        $cache_lastpostmodified[$blog_id][$timezone] = $lastpostmodified;
    } else {
        $lastpostmodified = $cache_lastpostmodified[$blog_id][$timezone];
    }
    return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
}
Esempio n. 17
0
 /**
  * @param $gsg GoogleSitemapGenerator
  */
 public function Index($gsg)
 {
     global $wpdb, $wp_version;
     $blogUpdate = strtotime(get_lastpostdate('blog'));
     $gsg->AddSitemap("misc", null, $blogUpdate);
     if ($gsg->GetOption("in_arch")) {
         $gsg->AddSitemap("archives", null, $blogUpdate);
     }
     if ($gsg->GetOption("in_auth")) {
         $gsg->AddSitemap("authors", null, $blogUpdate);
     }
     $taxonomies = $this->GetEnabledTaxonomies($gsg);
     foreach ($taxonomies as $tax) {
         $gsg->AddSitemap("tax", $tax);
     }
     $pages = $gsg->GetPages();
     if (count($pages) > 0) {
         $gsg->AddSitemap("externals", null, $blogUpdate);
     }
     $enabledPostTypes = $gsg->GetActivePostTypes();
     if (count($enabledPostTypes) > 0) {
         //Add filter to remove password protected posts
         add_filter('posts_search', array($this, 'FilterPassword'), 10, 2);
         //Add filter to remove fields
         add_filter('posts_fields', array($this, 'FilterIndexFields'), 10, 2);
         //Add filter to group
         add_filter('posts_groupby', array($this, 'FilterIndexGroup'), 10, 2);
         foreach ($enabledPostTypes as $postType) {
             $qp = $this->BuildPostQuery($gsg, $postType);
             $qp['cache_results'] = false;
             $posts = @get_posts($qp);
             if ($posts) {
                 foreach ($posts as $post) {
                     $gsg->AddSitemap("pt", $postType . "-" . sprintf("%04d-%02d", $post->year, $post->month), $gsg->GetTimestampFromMySql($post->last_mod));
                 }
             }
         }
         //Remove the filters again
         remove_filter('posts_where', array($this, 'FilterPassword'), 10, 2);
         remove_filter('posts_fields', array($this, 'FilterIndexFields'), 10, 2);
         remove_filter('posts_groupby', array($this, 'FilterIndexGroup'), 10, 2);
     }
 }
Esempio n. 18
0
/**
 * Retrieve last post modified date depending on timezone.
 *
 * The server timezone is the default and is the difference between GMT and
 * server time. The 'blog' value is just when the last post was modified. The
 * 'gmt' is when the last post was modified in GMT time.
 *
 * @since 1.2.0
 * @uses $wpdb
 * @uses $blog_id
 * @uses apply_filters() Calls 'get_lastpostmodified' filter
 *
 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
 * @return string The date the post was last modified.
 */
function get_lastpostmodified($timezone = 'server')
{
    global $wpdb;
    $add_seconds_server = date('Z');
    $timezone = strtolower($timezone);
    $lastpostmodified = wp_cache_get("lastpostmodified:{$timezone}", 'timeinfo');
    if ($lastpostmodified) {
        return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
    }
    switch (strtolower($timezone)) {
        case 'gmt':
            $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1");
            break;
        case 'blog':
            $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1");
            break;
        case 'server':
            $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '{$add_seconds_server}' SECOND) FROM {$wpdb->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1");
            break;
    }
    $lastpostdate = get_lastpostdate($timezone);
    if ($lastpostdate > $lastpostmodified) {
        $lastpostmodified = $lastpostdate;
    }
    if ($lastpostmodified) {
        wp_cache_set("lastpostmodified:{$timezone}", $lastpostmodified, 'timeinfo');
    }
    return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
}
?>
</title>
	<link><?php 
bloginfo_rss('url');
?>
</link>
	<description><?php 
bloginfo_rss('description');
?>
</description>
	<language><?php 
echo get_settings('rss_language') ? get_settings('rss_language') : 'en';
?>
</language>
	<copyright>Copyright <?php 
echo mysql2date('Y', get_lastpostdate());
?>
</copyright>
	<pubDate><?php 
echo gmdate('r');
?>
</pubDate>
	<generator>http://wordpress.xwd.jp/?v=<?php 
echo $GLOBALS['wp_version'];
?>
</generator>

	<?php 
if ($GLOBALS['posts']) {
    foreach ($GLOBALS['posts'] as $GLOBALS['post']) {
        start_wp();
Esempio n. 20
0
/**
 * Get the timestamp of the last time any post was modified.
 *
 * The server timezone is the default and is the difference between GMT and
 * server time. The 'blog' value is just when the last post was modified. The
 * 'gmt' is when the last post was modified in GMT time.
 *
 * @since 1.2.0
 *
 * @param string $timezone Optional. The timezone for the timestamp. Uses the server's internal timezone.
 *                         Accepts 'server', 'blog', 'gmt'. or 'server'. 'server' uses the server's
 *                         internal timezone. 'blog' uses the `post_modified` field, which proxies
 *                         to the timezone set for the site. 'gmt' uses the `post_modified_gmt` field.
 *                         Default 'server'.
 * @return string The timestamp.
 */
function get_lastpostmodified($timezone = 'server')
{
    $lastpostmodified = _get_last_post_time($timezone, 'modified');
    $lastpostdate = get_lastpostdate($timezone);
    if ($lastpostdate > $lastpostmodified) {
        $lastpostmodified = $lastpostdate;
    }
    /**
     * Filter the date the last post was modified.
     *
     * @since 2.3.0
     *
     * @param string $lastpostmodified Date the last post was modified.
     * @param string $timezone         Location to use for getting the post modified date.
     *                                 See {@see get_lastpostmodified()} for accepted `$timezone` values.
     */
    return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
}
Esempio n. 21
0
	function get_feed($page = 1, $post_type = 'post') {
		global $post, $wp, $wp_query, $posts, $wpdb, $blog_id, $post_cache;
		log_app('function',"get_feed($page, '$post_type')");
		ob_start();

		if(!isset($page)) {
			$page = 1;
		}
		$page = (int) $page;

		$count = get_option('posts_per_rss');
		$query = "paged=$page&posts_per_page=$count&order=DESC";
		if($post_type == 'attachment') {
			$query .= "&post_type=$post_type";
		}
		query_posts($query);
		$post = $GLOBALS['post'];
		$posts = $GLOBALS['posts'];
		$wp = $GLOBALS['wp'];
		$wp_query = $GLOBALS['wp_query'];
		$wpdb = $GLOBALS['wpdb'];
		$blog_id = (int) $GLOBALS['blog_id'];
		$post_cache = $GLOBALS['post_cache'];


		$total_count = $this->get_posts_count();
		$last_page = (int) ceil($total_count / $count);
		$next_page = (($page + 1) > $last_page) ? NULL : $page + 1;
		$prev_page = ($page - 1) < 1 ? NULL : $page - 1; 
		$last_page = ((int)$last_page == 1 || (int)$last_page == 0) ? NULL : (int) $last_page;
?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://purl.org/atom/app#" xml:lang="<?php echo get_option('rss_language'); ?>">
<id><?php $this->the_entries_url() ?></id>
<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
<title type="text"><?php bloginfo_rss('name') ?></title>
<subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
<link rel="first" type="application/atom+xml" href="<?php $this->the_entries_url() ?>" />
<?php if(isset($prev_page)): ?>
<link rel="previous" type="application/atom+xml" href="<?php $this->the_entries_url($prev_page) ?>" />
<?php endif; ?>
<?php if(isset($next_page)): ?>
<link rel="next" type="application/atom+xml" href="<?php $this->the_entries_url($next_page) ?>" />
<?php endif; ?>
<link rel="last" type="application/atom+xml" href="<?php $this->the_entries_url($last_page) ?>" />
<link rel="self" type="application/atom+xml" href="<?php $this->the_entries_url() ?>" />
<rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights>
<generator uri="http://wordpress.com/" version="1.0.5-dc">WordPress.com Atom API</generator>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); 
$post = $GLOBALS['post'];
?>
<entry>
		<id><?php the_guid($post->ID); ?></id>
		<title type="html"><![CDATA[<?php the_title() ?>]]></title>
		<updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated>
		<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
		<app:control>
			<app:draft><?php echo ($GLOBALS['post']->post_status == 'draft' ? 'yes' : 'no') ?></app:draft>
		</app:control>
		<author>
			<name><?php the_author()?></name>
			<email><?php the_author_email()?></email>
	<?php if (get_the_author_url() && get_the_author_url() != 'http://') { ?>
		 <uri><?php the_author_url()?></uri>
	<?php } ?>
		</author>
	<?php if($GLOBALS['post']->post_status == 'attachment') { ?>
		<link rel="edit" href="<?php $this->the_entry_url() ?>" />
		<link rel="edit-media" href="<?php $this->the_media_url() ?>" />
	<?php } else { ?>
		<link href="<?php permalink_single_rss() ?>" />
		<link rel="edit" href="<?php $this->the_entry_url() ?>" />
	<?php } ?>
	<?php foreach(get_the_category() as $category) { ?>
	 <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->cat_name?>" />
	<?php } ?>   <summary type="html"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
	<?php if ( strlen( $GLOBALS['post']->post_content ) ) : ?>
	<content type="html"><![CDATA[<?php echo get_the_content('', 0, '') ?>]]></content>
<?php endif; ?>
	</entry>
<?php
	endwhile; 
	endif;
?></feed>
<?php 
		$feed = ob_get_contents();
		ob_end_clean();
		return $feed;
	}
Esempio n. 22
0
/**
 * Retrieve last post modified date depending on timezone.
 *
 * The server timezone is the default and is the difference between GMT and
 * server time. The 'blog' value is just when the last post was modified. The
 * 'gmt' is when the last post was modified in GMT time.
 *
 * @since 1.2.0
 * @uses apply_filters() Calls 'get_lastpostmodified' filter
 *
 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
 * @return string The date the post was last modified.
 */
function get_lastpostmodified($timezone = 'server')
{
    $lastpostmodified = _get_last_post_time($timezone, 'modified');
    $lastpostdate = get_lastpostdate($timezone);
    if ($lastpostdate > $lastpostmodified) {
        $lastpostmodified = $lastpostdate;
    }
    return apply_filters('get_lastpostmodified', $lastpostmodified, $timezone);
}
Esempio n. 23
0
bloginfo('rss2_url');
?>
"><?php 
_e('RSS Feed', 'depo-squared');
?>
</a>
	</p>
</div>
<p class="archives">

<?php 
_e('View more by category:');
$variable = wp_list_categories('echo=0&show_count=1&title_li=&style=none&number=10&orderby=count&order=desc');
$variable = str_replace('<br />', ', ', trim($variable));
echo ' ' . rtrim($variable, ', ') . '. ';
$last_post_date = get_lastpostdate('blog');
_e('Or by month:');
?>
 <a href="<?php 
bloginfo('url');
?>
/<?php 
echo mysql2date('Y/m', $last_post_date);
?>
/"><?php 
echo mysql2date('F Y', $last_post_date);
?>
</a>.
	<?php 
_e('Or visit the');
?>