Make WordPress Core

Changeset 3791


Ignore:
Timestamp:
05/22/2006 10:06:06 PM (19 years ago)
Author:
ryan
Message:

Handle robots.txt requests and obey blog_plubic setting.

Location:
trunk/wp-includes
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r3789 r3791  
    7474
    7575class WP {
    76     var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview');
     76    var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
    7777
    7878    var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
  • trunk/wp-includes/default-filters.php

    r3788 r3791  
    9595add_action('do_feed_atom', 'do_feed_atom', 10, 1);
    9696add_action('do_pings', 'do_all_pings', 10, 1);
     97add_action('do_robots', 'do_robots');
    9798?>
  • trunk/wp-includes/functions.php

    r3758 r3791  
    16561656}
    16571657
     1658function do_robots() {
     1659    if ( '1' != get_option('blog_public') ) {
     1660        echo "User-agent: *\n";
     1661        echo "Disallow: /\n";
     1662    } else {
     1663        echo "User-agent: *\n";
     1664        echo "Disallow:\n";
     1665    }
     1666}
     1667
    16581668function is_blog_installed() {
    16591669    global $wpdb;
  • trunk/wp-includes/query.php

    r3772 r3791  
    156156
    157157    return $wp_query->is_preview;
     158}
     159
     160function is_robots() {
     161    global $wp_query;
     162
     163    return $wp_query->is_robots;
    158164}
    159165
     
    273279    var $is_admin = false;
    274280    var $is_attachment = false;
     281    var $is_robots = false;
    275282
    276283    function init_query_flags() {
     
    293300        $this->is_admin = false;
    294301        $this->is_attachment = false;
     302        $this->is_robots = false;
    295303    }
    296304
     
    320328            $this->query = $query;
    321329            $this->query_vars = $qv;
     330        }
     331
     332        if ( ! empty($qv['robots']) ) {
     333            $this->is_robots = true;
     334            return;
    322335        }
    323336
  • trunk/wp-includes/rewrite.php

    r3712 r3791  
    697697        }
    698698
     699        // robots.txt
     700        $robots_rewrite = array('robots.txt$' => $this->index . '?robots=1');
     701
    699702        // Post
    700703        $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure, EP_PERMALINK);
     
    731734
    732735        // Put them together.
    733         $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
     736        $this->rules = array_merge($robots_rewrite, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
    734737
    735738        do_action('generate_rewrite_rules', array(&$this));
  • trunk/wp-includes/template-loader.php

    r3638 r3791  
    22if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
    33    do_action('template_redirect');
    4     if ( is_feed() ) {
     4    if ( is_robots() ) {
     5        do_action('do_robots');
     6        exit;
     7    } else if ( is_feed() ) {
    58        do_feed();
    69        exit;
     
    5659} else {
    5760    // Process feeds and trackbacks even if not using themes.
    58     if ( is_feed() ) {
     61    if ( is_robots() ) {
     62        do_action('do_robots');
     63        exit;
     64    } else if ( is_feed() ) {
    5965        do_feed();
    6066        exit;
Note: See TracChangeset for help on using the changeset viewer.