Make WordPress Core


Ignore:
Timestamp:
10/20/2005 08:48:32 PM (21 years ago)
Author:
ryan
Message:

Image fu from Andy. fixes #1776

File:
1 edited

Legend:

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

    r2938 r2958  
    3030    var $is_comments_popup = false;
    3131    var $is_admin = false;
    32     var $is_object = false;
     32    var $is_subpost = false;
    3333
    3434    function init_query_flags() {
     
    5050        $this->is_paged = false;
    5151        $this->is_admin = false;
    52         $this->is_object = false;
     52        $this->is_subpost = false;
    5353    }
    5454   
     
    9191        $qv['p'] =  (int) $qv['p'];
    9292
     93        if ( ('' != $qv['subpost']) || $qv['subpost_id'] ) {
     94            $this->is_single = true;
     95            $this->is_subpost = true;
     96        }
     97
    9398        if ('' != $qv['name']) {
    9499            $this->is_single = true;
     
    97102        } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
    98103            // If year, month, day, hour, minute, and second are set, a single
    99           // post is being queried.       
     104            // post is being queried.       
    100105            $this->is_single = true;
    101106        } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
     
    209214        }
    210215
    211         if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
     216        if ( ! ($this->is_subpost || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
    212217            $this->is_home = true;
    213218        }
     
    336341            $q['name'] = $q['pagename'];
    337342            $where .= " AND post_name = '" . $q['pagename'] . "'";
    338         }
    339 
     343        } elseif ('' != $q['subpost']) {
     344            $q['subpost'] = sanitize_title($q['subpost']);
     345            $q['name'] = $q['subpost'];
     346            $where .= " AND post_name = '" . $q['subpost'] . "'";
     347        }
    340348
    341349        if ( (int) $q['w'] ) {
     
    346354        if ( intval($q['comments_popup']) )
    347355            $q['p'] = intval($q['comments_popup']);
     356
     357        // If a subpost is requested by number, let it supercede any post number.
     358        if ( ($q['subpost_id'] != '') && (intval($q['subpost_id']) != 0) )
     359            $q['p'] = (int) $q['subpost_id'];
    348360
    349361        // If a post number is specified, load that post
     
    517529        }
    518530
    519         if ($this->is_page) {
     531        if ( $this->is_subpost ) {
     532            $where .= ' AND (post_status = "object")';
     533        } elseif ($this->is_page) {
    520534            $where .= ' AND (post_status = "static")';
    521535        } elseif ($this->is_single) {
     
    530544        }
    531545
    532         if (! $this->is_object )
     546        if (! $this->is_subpost )
    533547            $where .= ' AND post_status != "object"';
    534548
     
    576590        // Check post status to determine if post should be displayed.
    577591        if ($this->is_single) {
    578             if ('publish' != $this->posts[0]->post_status) {
     592            $status = get_post_status($this->posts[0]);
     593            if ('publish' != $status) {
    579594                if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
    580595                    // User must be logged in to view unpublished posts.
    581596                    $this->posts = array();
    582597                } else {
    583                     if ('draft' == $this->posts[0]->post_status) {
     598                    if ('draft' == $status) {
    584599                        // User must have edit permissions on the draft to preview.
    585600                        if (! user_can_edit_post($user_ID, $this->posts[0]->ID))
    586601                            $this->posts = array();
    587                     } elseif ('private' == $this->posts[0]->post_status) {
     602                    } elseif ('private' == $status) {
    588603                        if ($this->posts[0]->post_author != $user_ID)
    589604                            $this->posts = array();
     
    822837    var $queryreplace =
    823838        array (
    824                      'year=',
    825                      'monthnum=',
    826                      'day=',
    827                      'hour=',
    828                      'minute=',
    829                      'second=',
    830                      'name=',
    831                      'p=',
    832                      'category_name=',
    833                      'author_name=',
    834                      'pagename=',
    835                      's='
    836                      );
     839                    'year=',
     840                    'monthnum=',
     841                    'day=',
     842                    'hour=',
     843                    'minute=',
     844                    'second=',
     845                    'name=',
     846                    'p=',
     847                    'category_name=',
     848                    'author_name=',
     849                    'pagename=',
     850                    's='
     851                    );
    837852
    838853    var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom');
     
    846861
    847862    function using_index_permalinks() {
    848     if (empty($this->permalink_structure)) {
     863        if (empty($this->permalink_structure)) {
    849864            return false;
    850     }
    851 
    852     // If the index is not in the permalink, we're using mod_rewrite.
    853     if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
    854       return true;
    855     }
     865        }
     866
     867        // If the index is not in the permalink, we're using mod_rewrite.
     868        if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
     869            return true;
     870        }
    856871   
    857     return false;
     872        return false;
    858873    }
    859874
     
    866881
    867882    function preg_index($number) {
    868     $match_prefix = '$';
    869     $match_suffix = '';
    870    
    871     if (! empty($this->matches)) {
     883        $match_prefix = '$';
     884        $match_suffix = '';
     885
     886        if (! empty($this->matches)) {
    872887            $match_prefix = '$' . $this->matches . '[';
    873888            $match_suffix = ']';
    874     }       
    875    
    876     return "$match_prefix$number$match_suffix";       
     889        }       
     890
     891        return "$match_prefix$number$match_suffix";       
    877892    }
    878893
     
    898913        }
    899914
    900     if (empty($this->permalink_structure)) {
     915        if (empty($this->permalink_structure)) {
    901916            $this->date_structure = '';
    902917            return false;
     
    974989        }
    975990
    976     if (empty($this->permalink_structure)) {
     991        if (empty($this->permalink_structure)) {
    977992            $this->category_structure = '';
    978993            return false;
     
    9941009        }
    9951010
    996     if (empty($this->permalink_structure)) {
     1011        if (empty($this->permalink_structure)) {
    9971012            $this->author_structure = '';
    9981013            return false;
     
    10091024        }
    10101025
    1011     if (empty($this->permalink_structure)) {
     1026        if (empty($this->permalink_structure)) {
    10121027            $this->search_structure = '';
    10131028            return false;
     
    10241039        }
    10251040
    1026     if (empty($this->permalink_structure)) {
     1041        if (empty($this->permalink_structure)) {
    10271042            $this->page_structure = '';
    10281043            return false;
     
    10391054        }
    10401055
    1041     if (empty($this->permalink_structure)) {
     1056        if (empty($this->permalink_structure)) {
    10421057            $this->feed_structure = '';
    10431058            return false;
     
    10541069        }
    10551070
    1056     if (empty($this->permalink_structure)) {
     1071        if (empty($this->permalink_structure)) {
    10571072            $this->comment_feed_structure = '';
    10581073            return false;
     
    11591174                    $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
    11601175                    $match = rtrim($match, '/');
     1176                    $submatchbase = str_replace(array('(',')'),'',$match);
     1177                    $sub1 = $submatchbase . '/([^/]+)/';
     1178                    $sub1tb = $sub1 . $trackbackregex;
     1179                    $sub1feed = $sub1 . $feedregex;
     1180                    $sub1feed2 = $sub1 . $feedregex2;
     1181                    $sub1 .= '?$';
     1182                    $sub2 = $submatchbase . '/subpost/([^/]+)/';
     1183                    $sub2tb = $sub2 . $trackbackregex;
     1184                    $sub2feed = $sub2 . $feedregex;
     1185                    $sub2feed2 = $sub2 . $feedregex2;
     1186                    $sub2 .= '?$';
     1187                    $subquery = $index . '?subpost=' . $this->preg_index(1);
     1188                    $subtbquery = $subquery . '&tb=1';
     1189                    $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    11611190                    $match = $match . '(/[0-9]+)?/?$';
    11621191                    $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
     
    11691198
    11701199                if ($post) {
    1171                     $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite;
     1200                    $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite +
     1201                        array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery) +
     1202                        array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery);
    11721203                }
    11731204            }
     
    12321263        do_action('generate_rewrite_rules', array(&$this));
    12331264        $this->rules = apply_filters('rewrite_rules_array', $this->rules);
     1265
    12341266        return $this->rules;
    12351267    }
     
    13301362
    13311363class WP {
    1332     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');
     1364    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', 'subpost', 'subpost_id');
    13331365
    13341366    var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging');
     
    13981430                    // If the requesting file is the anchor of the match, prepend it
    13991431                    // to the path info.
    1400                     if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
     1432                    if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request)) {
    14011433                        $request_match = $req_uri . '/' . $request;
     1434die("$request_match $match<br />");
    14021435                    }
    14031436
Note: See TracChangeset for help on using the changeset viewer.