• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_lastpostmodified函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_lastpostmodified函数的典型用法代码示例。如果您正苦于以下问题:PHP get_lastpostmodified函数的具体用法?PHP get_lastpostmodified怎么用?PHP get_lastpostmodified使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_lastpostmodified函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: get_related

 public function get_related($id = '', $filter = array(), $context = 'view')
 {
     $option = get_option('sirp_options');
     $num = !empty($filter['num']) ? (int) $filter['num'] : (int) $option['display_num'];
     $ids = sirp_get_related_posts_id_api($num, $id);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id['ID']);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
开发者ID:Anawaz,项目名称:Simple-Related-Posts,代码行数:31,代码来源:wp-rest-api.php


示例2: get_ranking

 /**
  * Retrieve ranking
  *
  * Overrides the $type to set to 'post', then passes through to the post
  * endpoints.
  *
  * @see WP_JSON_Posts::get_posts()
  */
 public function get_ranking($filter = array(), $context = 'view')
 {
     $ids = sga_ranking_get_date($filter);
     $posts_list = array();
     foreach ($ids as $id) {
         $posts_list[] = get_post($id);
     }
     $response = new WP_JSON_Response();
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (!$this->check_read_permission($post)) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, $context);
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
开发者ID:kantan2015,项目名称:simple-ga-ranking,代码行数:39,代码来源:wp-rest-api.class.php


示例3: test_feed_element

 /**
  * Test the <feed> element to make sure its present and populated
  * with the expected child elements and attributes.
  */
 function test_feed_element()
 {
     $this->go_to('/?feed=atom');
     $feed = $this->do_atom();
     $xml = xml_to_array($feed);
     // Get the <feed> child element of <xml>.
     $atom = xml_find($xml, 'feed');
     // There should only be one <feed> child element.
     $this->assertCount(1, $atom);
     // Verify attributes.
     $this->assertEquals('http://www.w3.org/2005/Atom', $atom[0]['attributes']['xmlns']);
     $this->assertEquals('http://purl.org/syndication/thread/1.0', $atom[0]['attributes']['xmlns:thr']);
     $this->assertEquals(site_url('/wp-atom.php'), $atom[0]['attributes']['xml:base']);
     // Verify the <feed> element is present and contains a <title> child element.
     $title = xml_find($xml, 'feed', 'title');
     $this->assertEquals(get_option('blogname'), $title[0]['content']);
     // Verify the <feed> element is present and contains a <updated> child element.
     $updated = xml_find($xml, 'feed', 'updated');
     $this->assertEquals(strtotime(get_lastpostmodified()), strtotime($updated[0]['content']));
     // Verify the <feed> element is present and contains a <subtitle> child element.
     $subtitle = xml_find($xml, 'feed', 'subtitle');
     $this->assertEquals(get_option('blogdescription'), $subtitle[0]['content']);
     // Verify the <feed> element is present and contains two <link> child elements.
     $link = xml_find($xml, 'feed', 'link');
     $this->assertCount(2, $link);
     // Verify the <feed> element is present and contains a <link rel="alternate"> child element.
     $this->assertEquals('alternate', $link[0]['attributes']['rel']);
     $this->assertEquals(home_url(), $link[0]['attributes']['href']);
     // Verify the <feed> element is present and contains a <link rel="href"> child element.
     $this->assertEquals('self', $link[1]['attributes']['rel']);
     $this->assertEquals(home_url('/?feed=atom'), $link[1]['attributes']['href']);
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:36,代码来源:atom.php


示例4: add_to_index

 /**
  * Add the XML News Sitemap to the Sitemap Index.
  *
  * @param string $str String with Index sitemap content.
  * @return string
  */
 function add_to_index($str)
 {
     $result = strtotime(get_lastpostmodified('gmt'));
     $date = date('c', $result);
     $str .= '<sitemap>' . "\n";
     $str .= '<loc>' . home_url('news-sitemap.xml') . '</loc>' . "\n";
     $str .= '<lastmod>' . $date . '</lastmod>' . "\n";
     $str .= '</sitemap>' . "\n";
     return $str;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:16,代码来源:xml-news-sitemap-class.php


示例5: google_sitemap

/**
 * Google XML Sitemap
 *
 * @author Cor van Noorloos
 * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
 * @link https://github.com/corvannoorloos/google-xml-sitemap
 *
 * @wordpress
 * HiddenPlugin Name: Google XML Sitemap
 * Plugin URI: https://github.com/corvannoorloos/google-xml-sitemap
 * Description: Sitemaps are a way to tell Google about pages on your site we might not otherwise discover. In its simplest terms, a XML Sitemap&mdash;usually called Sitemap, with a capital S&mdash;is a list of the pages on your website. Creating and submitting a Sitemap helps make sure that Google knows about all the pages on your site, including URLs that may not be discoverable by Google's normal crawling process.
 * Author: Cor van Noorloos
 * Version: 0.1.1
 * Author URI: http://corvannoorloos.com/
 * (Bookt) The original file has been modified to output specific entries from BAPI seo data
 */
function google_sitemap()
{
    if (!preg_match('/sitemap\\.xml$/', $_SERVER['REQUEST_URI'])) {
        return;
    }
    global $wpdb;
    $posts = $wpdb->get_results("SELECT ID, post_title, post_modified_gmt\r\n\t\tFROM {$wpdb->posts}\r\n\t\tWHERE post_status = 'publish'\r\n\t\tAND post_type <> 'nav_menu_item'\r\n\t\tAND post_name <> 'hello-world'\r\n\t\tAND post_password = ''\r\n\t\tORDER BY post_type DESC, post_modified DESC\r\n\t\tLIMIT 50000");
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
    echo '<!-- generator="' . home_url('/') . '" -->' . "\n";
    $xml = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 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">' . "\n";
    $xml .= "\t<url>" . "\n";
    $xml .= "\t\t<loc>" . home_url('/') . "</loc>\n";
    $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', get_lastpostmodified('GMT'), false) . "</lastmod>\n";
    $xml .= "\t\t<changefreq>" . 'daily' . "</changefreq>\n";
    $xml .= "\t\t<priority>" . '1' . "</priority>\n";
    $xml .= "\t</url>" . "\n";
    foreach ($posts as $post) {
        if ($post->ID == get_option('page_on_front')) {
            continue;
        }
        if (!empty($post->post_title)) {
            // prevent outputing detail screens which can be determined by seeing if the post has a meta bapikey
            $bapikey = get_post_meta($post->ID, "bapikey", true);
            if (empty($bapikey)) {
                $xml .= "\t<url>\n";
                $xml .= "\t\t<loc>" . get_permalink($post->ID) . "</loc>\n";
                $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $post->post_modified_gmt, false) . "</lastmod>\n";
                $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
                $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
                $xml .= "\t</url>\n";
            }
        }
    }
    // now output the pages from bapi seo data
    global $bapisync;
    global $bapi_all_options;
    foreach ($bapisync->seodata as $seo) {
        if (!empty($seo["entity"]) && !empty($seo["pkid"])) {
            $turl = BAPISync::cleanurl($seo["DetailURL"]);
            $xml .= "\t<url>\n";
            $xml .= "\t\t<loc>" . $bapi_all_options['bapi_site_cdn_domain'] . $turl . "</loc>\n";
            $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $seo["ModifiedOn"]["LongDateTime"], false) . "</lastmod>\n";
            $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
            $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
            $xml .= "\t</url>\n";
        }
    }
    $xml .= '</urlset>';
    echo "{$xml}";
    exit;
}
开发者ID:alfiedawes,项目名称:WP-InstaSites,代码行数:70,代码来源:google-xml-sitemap.php


示例6: find

 public static function find($app)
 {
     $found = 0;
     $posts = array();
     $request_args = $app->request()->get();
     $args = self::convert_request($request_args);
     if ($lastModified = apply_filters('thermal_get_lastpostmodified', get_lastpostmodified('gmt'))) {
         $app->lastModified(strtotime($lastModified . ' GMT'));
     }
     $model = self::model();
     $posts = $model->find($args, $found);
     array_walk($posts, array(__CLASS__, 'format'), 'read');
     return empty($args['no_found_rows']) ? compact('posts', 'found') : compact('posts');
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:14,代码来源:Posts.php


示例7: seo_update_xmlsitemap

/**
 * Xml site Map generator
 * @param array $availables_post_types
 * @return true if success, false otherwise
 */
function seo_update_xmlsitemap($availables_post_types)
{
    $success = false;
    // $xmlsitemappath = trailingslashit(get_home_path()) . "sitemap.xml"; makes error with woocommerce payplug/paypal purchase method
    $xmlsitemappath = trailingslashit(ABSPATH) . "sitemap.xml";
    if (($fp = @fopen($xmlsitemappath, 'w')) !== FALSE) {
        $xml_sitemap = "";
        $xml_sitemap .= '<?xml version="1.0" encoding="UTF-8"?>';
        $xsl = locate_web_ressource(CUSTOM_PLUGIN_TOOLS_FOLDER . SEO_TOOL_NAME . '/xmlsitemap/xmlsitemap.xsl');
        if (!empty($xsl)) {
            $xml_sitemap .= "\n" . '<?xml-stylesheet type="text/xsl" href="' . $xsl . '"?>';
        }
        $xml_sitemap .= "\n" . '<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">';
        // root
        $lm = intval(get_timestamp_from_mysql(get_lastpostmodified('GMT')));
        $date = date('Y-m-d\\TH:i:s+00:00', $lm);
        $xml_sitemap .= "\n\t" . '<url>';
        $xml_sitemap .= "\n\t\t" . '<loc>' . get_bloginfo('url') . '</loc>';
        $xml_sitemap .= "\n\t\t" . '<lastmod>' . $date . '</lastmod>';
        $xml_sitemap .= "\n\t\t" . '<changefreq>weekly</changefreq>';
        $xml_sitemap .= "\n\t\t" . '<priority>1.0</priority>';
        $xml_sitemap .= "\n\t" . '</url>';
        if ($availables_post_types) {
            // posts
            $posts = get_posts(array('numberposts' => -1, 'orderby' => 'modified', 'order' => 'DESC', 'post_type' => $availables_post_types, 'suppress_filters' => true));
            foreach ($posts as $post) {
                $lm = intval(get_timestamp_from_mysql($post->post_modified_gmt));
                $date = date('Y-m-d\\TH:i:s+00:00', $lm);
                $xml_sitemap .= "\n\t" . '<url>';
                $xml_sitemap .= "\n\t\t" . '<loc>' . get_permalink($post->ID) . '</loc>';
                $xml_sitemap .= "\n\t\t" . '<lastmod>' . $date . '</lastmod>';
                $xml_sitemap .= "\n\t\t" . '<changefreq>weekly</changefreq>';
                $xml_sitemap .= "\n\t\t" . '<priority>0.6</priority>';
                $xml_sitemap .= "\n\t" . '</url>';
            }
        }
        $xml_sitemap .= "\n" . '</urlset>';
        // ecriture du fichier
        fwrite($fp, $xml_sitemap);
        fclose($fp);
        $success = true;
    } else {
        trace_err("Impossible d'écrire le fichier : " . trailingslashit(get_home_path()) . "sitemap.xml");
    }
    return $success;
}
开发者ID:studio-montana,项目名称:custom,代码行数:51,代码来源:xmlsitemap.php


示例8: test_channel

 function test_channel()
 {
     $this->go_to('/?feed=rss2');
     $feed = $this->do_rss2();
     $xml = xml_to_array($feed);
     // get the rss -> channel element
     $channel = xml_find($xml, 'rss', 'channel');
     $this->assertTrue(empty($channel[0]['attributes']));
     $title = xml_find($xml, 'rss', 'channel', 'title');
     $this->assertEquals(get_option('blogname'), $title[0]['content']);
     $desc = xml_find($xml, 'rss', 'channel', 'description');
     $this->assertEquals(get_option('blogdescription'), $desc[0]['content']);
     $link = xml_find($xml, 'rss', 'channel', 'link');
     $this->assertEquals(get_option('siteurl'), $link[0]['content']);
     $pubdate = xml_find($xml, 'rss', 'channel', 'lastBuildDate');
     $this->assertEquals(strtotime(get_lastpostmodified()), strtotime($pubdate[0]['content']));
 }
开发者ID:rclilly,项目名称:wordpress-develop,代码行数:17,代码来源:rss2.php


示例9: wpjam_headers

function wpjam_headers($headers, $wp)
{
    if (!is_user_logged_in() && empty($wp->query_vars['feed'])) {
        $headers['Cache-Control'] = 'max-age:600';
        $headers['Expires'] = gmdate('D, d M Y H:i:s', time() + 600) . " GMT";
        $wpjam_timestamp = get_lastpostmodified('GMT') > get_lastcommentmodified('GMT') ? get_lastpostmodified('GMT') : get_lastcommentmodified('GMT');
        $wp_last_modified = mysql2date('D, d M Y H:i:s', $wpjam_timestamp, 0) . ' GMT';
        $wp_etag = '"' . md5($wp_last_modified) . '"';
        $headers['Last-Modified'] = $wp_last_modified;
        $headers['ETag'] = $wp_etag;
        // Support for Conditional GET
        if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
            $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
        } else {
            $client_etag = false;
        }
        $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
        // If string is empty, return 0. If not, attempt to parse into a timestamp
        $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
        // Make a timestamp for our most recent modification...
        $wp_modified_timestamp = strtotime($wp_last_modified);
        $exit_required = false;
        if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
            $status = 304;
            $exit_required = true;
        }
        if ($exit_required) {
            if (!empty($status)) {
                status_header($status);
            }
            foreach ((array) $headers as $name => $field_value) {
                @header("{$name}: {$field_value}");
            }
            if (isset($headers['Last-Modified']) && empty($headers['Last-Modified']) && function_exists('header_remove')) {
                @header_remove('Last-Modified');
            }
            exit;
        }
    }
    return $headers;
}
开发者ID:eric-xujun,项目名称:wordpress,代码行数:41,代码来源:304-speed.php


示例10: print_eventlist_feed

    public function print_eventlist_feed()
    {
        header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
        $events = $this->db->get_events($this->options->get('el_feed_upcoming_only') ? 'upcoming' : null);
        // Print feeds
        echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"
		xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
		<channel>
			<title>' . get_bloginfo_rss('name') . '</title>
			<atom:link href="' . apply_filters('self_link', get_bloginfo()) . '" rel="self" type="application/rss+xml" />
			<link>' . get_bloginfo_rss('url') . '</link>
			<description>' . __('Eventlist') . '</description>
			<lastBuildDate>' . mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false) . '</lastBuildDate>
			<language>' . get_option('rss_language') . '</language>
			<sy:updatePeriod>' . apply_filters('rss_update_period', 'hourly') . '</sy:updatePeriod>
			<sy:updateFrequency>' . apply_filters('rss_update_frequency', '1') . '</sy:updateFrequency>
			';
        do_action('rss2_head');
        if (!empty($events)) {
            foreach ($events as $event) {
                echo '
			<item>
				<title>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' - ' . $event->title) . '</title>
				<pubDate>' . mysql2date('D, d M Y H:i:s +0000', $event->start_date, false) . '</pubDate>
				<description>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . '</description>
				' . ('' != $event->details ? '<content:encoded><![CDATA[' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . $event->details . ']]></content:encoded>' : '') . '
			</item>';
            }
        }
        echo '
		</channel>
	</rss>';
    }
开发者ID:geekpondering,项目名称:wtg,代码行数:40,代码来源:feed.php


示例11: post_notify

 /**
  * Handles publishing or updating a post
  *
  * @param  string $post_id the post id
  * @return bool   whether the request worked
  */
 public static function post_notify($post_id)
 {
     global $wpdb;
     $post = get_post($post_id);
     $url = get_permalink($post_id);
     $tags = wp_get_post_tags($post_id, array('fields' => 'names'));
     $categories = array_map(array('ShareaholicNotifier', 'post_notify_iterator'), get_the_category($post_id));
     if (function_exists('has_post_thumbnail') && has_post_thumbnail($post_id)) {
         $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large');
     } else {
         $featured_image = ShareaholicUtilities::post_first_image();
         if (!$featured_image) {
             $featured_image = '';
         }
     }
     if ($post->post_author) {
         $author_data = get_userdata($post->post_author);
         $author_name = $author_data->display_name;
     }
     $notification = array('url' => $url, 'api_key' => ShareaholicUtilities::get_option('api_key'), 'content' => array('title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'body' => $post->post_content, 'featured-image-url' => $featured_image), 'metadata' => array('author-id' => $post->post_author, 'author-name' => $author_name, 'post-type' => $post->post_type, 'post-id' => $post_id, 'post-tags' => $tags, 'post-categories' => $categories, 'post-language' => get_bloginfo('language'), 'published' => $post->post_date_gmt, 'updated' => get_lastpostmodified('GMT'), 'visibility' => $post->post_status), 'diagnostics' => array('platform' => 'wordpress', 'platform-version' => get_bloginfo('version'), 'shareaholic-version' => Shareaholic::VERSION, 'wp-multisite' => is_multisite(), 'wp-theme' => get_option('template'), 'wp-posts-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'post' AND post_status = 'publish'"), 'wp-pages-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} where post_type = 'page' AND post_status = 'publish'"), 'wp-comments-total' => wp_count_comments()->approved, 'wp-users-total' => $wpdb->get_var("SELECT count(ID) FROM {$wpdb->users}")));
     return self::send_notification($notification);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:28,代码来源:notifier.php


示例12: tax_query

 public function tax_query($data)
 {
     $allowed = array('post_type', 'tax_query');
     foreach ($data as $key => $value) {
         if (!in_array($key, $allowed)) {
             unset($data[$key]);
         }
     }
     if (!is_array($data) || empty($data) || !isset($data['tax_query'])) {
         return new WP_Error('jp_api_tax_query', __('Invalid tax query.'), array('status' => 500));
     }
     $post_query = new WP_Query();
     $posts_list = $post_query->query($data);
     $response = new WP_JSON_Response();
     $response->query_navigation_headers($post_query);
     if (!$posts_list) {
         $response->set_data(array());
         return $response;
     }
     // holds all the posts data
     $struct = array();
     $response->header('Last-Modified', mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT');
     foreach ($posts_list as $post) {
         $post = get_object_vars($post);
         // Do we have permission to read this post?
         if (json_check_post_permission($post, 'read')) {
             continue;
         }
         $response->link_header('item', json_url('/posts/' . $post['ID']), array('title' => $post['post_title']));
         $post_data = $this->prepare_post($post, 'view');
         if (is_wp_error($post_data)) {
             continue;
         }
         $struct[] = $post_data;
     }
     $response->set_data($struct);
     return $response;
 }
开发者ID:shelob9,项目名称:jp-tax-query,代码行数:38,代码来源:class-jp-tax-query.php


示例13: google_sitemap

/**
 * Google XML Sitemap
 *
 * @since 0.1.1
 *
 * @global type $wpdb
 *
 * @return type
 */
function google_sitemap()
{
    if (!preg_match('/sitemap\\.xml$/', $_SERVER['REQUEST_URI'])) {
        return;
    }
    global $wpdb;
    $posts = $wpdb->get_results("SELECT ID, post_title, post_modified_gmt\r\n    FROM {$wpdb->posts}\r\n    WHERE post_status = 'publish'\r\n    AND post_password = ''\r\n    ORDER BY post_type DESC, post_modified DESC\r\n    LIMIT 50000");
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . "\n";
    echo '<!-- generator="' . home_url('/') . '" -->' . "\n";
    $xml = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 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">' . "\n";
    $xml .= "\t<url>" . "\n";
    $xml .= "\t\t<loc>" . home_url('/') . "</loc>\n";
    $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', get_lastpostmodified('GMT'), false) . "</lastmod>\n";
    $xml .= "\t\t<changefreq>" . 'daily' . "</changefreq>\n";
    $xml .= "\t\t<priority>" . '1' . "</priority>\n";
    $xml .= "\t</url>" . "\n";
    foreach ($posts as $post) {
        if ($post->ID == get_option('page_on_front')) {
            continue;
        }
        if (!empty($post->post_title)) {
            $xml .= "\t<url>\n";
            $xml .= "\t\t<loc>" . get_permalink($post->ID) . "</loc>\n";
            $xml .= "\t\t<lastmod>" . mysql2date('Y-m-d\\TH:i:s+00:00', $post->post_modified_gmt, false) . "</lastmod>\n";
            $xml .= "\t\t<changefreq>" . 'weekly' . "</changefreq>\n";
            $xml .= "\t\t<priority>" . '0.8' . "</priority>\n";
            $xml .= "\t</url>\n";
        }
    }
    $xml .= '</urlset>';
    echo "{$xml}";
    exit;
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:45,代码来源:google-xml-sitemap.php


示例14: feed

    function feed()
    {
        $title = sprintf('%s log', $this->name);
        header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
        echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . ">\r\n";
        ?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
	<title><?php 
        echo $title . ' - ';
        bloginfo_rss('name');
        ?>
</title>
	<link><?php 
        bloginfo_rss('url');
        ?>
</link>
	<description><?php 
        bloginfo_rss("description");
        ?>
</description>
	<pubDate><?php 
        echo htmlspecialchars(mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false));
        ?>
</pubDate>
	<generator><?php 
        echo htmlspecialchars('http://wordpress.org/?v=');
        bloginfo_rss('version');
        ?>
</generator>
	<language><?php 
        echo get_option('rss_language');
        ?>
</language>
<?php 
        if (count($this->items) > 0) {
            foreach ($this->items as $log) {
                ?>
	<item>
		<title><![CDATA[<?php 
                echo $log->url;
                ?>
]]></title>
		<link><![CDATA[<?php 
                bloginfo('home');
                echo $log->url;
                ?>
]]></link>
		<pubDate><?php 
                echo mysql2date('D, d M Y H:i:s +0000', $log->created_at, false);
                ?>
</pubDate>
		<guid isPermaLink="false"><?php 
                print $log->id;
                ?>
</guid>
		<description><![CDATA[<?php 
                echo $log->url;
                ?>
]]></description>
		<content:encoded><![CDATA[<?php 
                if ($log->referrer) {
                    echo 'Referred by ' . $log->referrer;
                }
                ?>
]]></content:encoded>
	</item>
		<?php 
            }
        }
        ?>
</channel>
</rss>
<?php 
        die;
    }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:79,代码来源:rss.php


示例15: send_headers

 function send_headers()
 {
     @header('X-Pingback: ' . get_bloginfo('pingback_url'));
     if (is_user_logged_in()) {
         nocache_headers();
     }
     if (!empty($this->query_vars['error']) && '404' == $this->query_vars['error']) {
         status_header(404);
         if (!is_user_logged_in()) {
             nocache_headers();
         }
         @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
     } else {
         if (empty($this->query_vars['feed'])) {
             @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
         } else {
             // We're showing a feed, so WP is indeed the only thing that last changed
             if (!empty($this->query_vars['withcomments']) || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
             } else {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             }
             $wp_etag = '"' . md5($wp_last_modified) . '"';
             @header("Last-Modified: {$wp_last_modified}");
             @header("ETag: {$wp_etag}");
             // Support for Conditional GET
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
             } else {
                 $client_etag = false;
             }
             $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             // If string is empty, return 0. If not, attempt to parse into a timestamp
             $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
             // Make a timestamp for our most recent modification...
             $wp_modified_timestamp = strtotime($wp_last_modified);
             if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
                 status_header(304);
                 exit;
             }
         }
     }
     do_action_ref_array('send_headers', array(&$this));
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:44,代码来源:classes.php


示例16: send_headers

 /**
  * Send additional HTTP headers for caching, content type, etc.
  *
  * Sets the X-Pingback header, 404 status (if 404), Content-type. If showing
  * a feed, it will also send last-modified, etag, and 304 status if needed.
  *
  * @since 2.0.0
  */
 function send_headers()
 {
     $headers = array('X-Pingback' => get_bloginfo('pingback_url'));
     $status = null;
     $exit_required = false;
     if (is_user_logged_in()) {
         $headers = array_merge($headers, wp_get_nocache_headers());
     }
     if (!empty($this->query_vars['error'])) {
         $status = (int) $this->query_vars['error'];
         if (404 === $status) {
             if (!is_user_logged_in()) {
                 $headers = array_merge($headers, wp_get_nocache_headers());
             }
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } elseif (in_array($status, array(403, 500, 502, 503))) {
             $exit_required = true;
         }
     } else {
         if (empty($this->query_vars['feed'])) {
             $headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
         } else {
             // We're showing a feed, so WP is indeed the only thing that last changed
             if (!empty($this->query_vars['withcomments']) || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
             } else {
                 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             }
             $wp_etag = '"' . md5($wp_last_modified) . '"';
             $headers['Last-Modified'] = $wp_last_modified;
             $headers['ETag'] = $wp_etag;
             // Support for Conditional GET
             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
                 $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
             } else {
                 $client_etag = false;
             }
             $client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
             // If string is empty, return 0. If not, attempt to parse into a timestamp
             $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
             // Make a timestamp for our most recent modification...
             $wp_modified_timestamp = strtotime($wp_last_modified);
             if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
                 $status = 304;
                 $exit_required = true;
             }
         }
     }
     $headers = apply_filters('wp_headers', $headers, $this);
     if (!empty($status)) {
         status_header($status);
     }
     foreach ((array) $headers as $name => $field_value) {
         @header("{$name}: {$field_value}");
     }
     if ($exit_required) {
         exit;
     }
     do_action_ref_array('send_headers', array(&$this));
 }
开发者ID:ryanmerritt,项目名称:WordPress,代码行数:68,代码来源:class-wp.php


示例17: process_conditionals

 /**
  * Process conditionals for posts.
  *
  * @since 2.2.0
  */
 function process_conditionals()
 {
     if (empty($this->params)) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
         return;
     }
     switch ($this->params[0]) {
         case $this->ENTRY_PATH:
             global $post;
             $post = wp_get_single_post($this->params[1]);
             $wp_last_modified = get_post_modified_time('D, d M Y H:i:s', true);
             $post = NULL;
             break;
         case $this->ENTRIES_PATH:
             $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
             break;
         default:
             return;
     }
     $wp_etag = md5($wp_last_modified);
     @header("Last-Modified: {$wp_last_modified}");
     @header("ETag: {$wp_etag}");
     // Support for Conditional GET
     if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
         $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     } else {
         $client_etag = false;
     }
     $client_last_modified = trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
     // If string is empty, return 0. If not, attempt to parse into a timestamp
     $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
     // Make a timestamp for our most recent modification...
     $wp_modified_timestamp = strtotime($wp_last_modified);
     if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
         status_header(304);
         exit;
     }
 }
开发者ID:thomashorta31,项目名称:BHS,代码行数:45,代码来源:wp-app.php


示例18: get_lastpostdate

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>
<?php 
header("Content-type: text/xml");
$myposts = get_posts("numberposts=" . $posts_to_show);
foreach ($myposts as $post) {
    ?>
  <url>
      <loc><?php 
    the_permalink();
开发者ID:houzhenggang,项目名称:WordPress-on-BAE,代码行数:31,代码来源:sitemap.php


示例19: asxs_sitemap2

function asxs_sitemap2()
{
    $Index_Sitemap_url = home_url('/sitemap.xml', $scheme = 'relative');
    $Normal_Sitemap_urltype = home_url('/sitemap_part_', $scheme = 'relative');
    $uri = rtrim($_SERVER['REQUEST_URI'], '/');
    $Index_S = $Index_Sitemap_url == $uri ? true : false;
    $Normal_S = stristr($uri, $Normal_Sitemap_urltype) && strstr($uri, '.xml') ? true : false;
    if (!$Index_S && !$Normal_S) {
        return;
    }
    global $wpdb;
    $xml = array();
    header("HTTP/1.1 200 OK");
    header('X-Robots-Tag: noindex, follow', true);
    header('Content-Type: text/xml');
    echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?>' . '<!-- generator="' . home_url('/') . ' (' . basename(__FILE__) . ')" -->' . "\n";
    $default = 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xm 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_latest_theme_version函数代码示例发布时间:2022-05-15
下一篇:
PHP get_lastpostdate函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap