Changeset 2958 for trunk/wp-includes/classes.php
- Timestamp:
- 10/20/2005 08:48:32 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/classes.php (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r2938 r2958 30 30 var $is_comments_popup = false; 31 31 var $is_admin = false; 32 var $is_ object = false;32 var $is_subpost = false; 33 33 34 34 function init_query_flags() { … … 50 50 $this->is_paged = false; 51 51 $this->is_admin = false; 52 $this->is_ object = false;52 $this->is_subpost = false; 53 53 } 54 54 … … 91 91 $qv['p'] = (int) $qv['p']; 92 92 93 if ( ('' != $qv['subpost']) || $qv['subpost_id'] ) { 94 $this->is_single = true; 95 $this->is_subpost = true; 96 } 97 93 98 if ('' != $qv['name']) { 94 99 $this->is_single = true; … … 97 102 } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) { 98 103 // If year, month, day, hour, minute, and second are set, a single 99 // post is being queried.104 // post is being queried. 100 105 $this->is_single = true; 101 106 } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) { … … 209 214 } 210 215 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)) { 212 217 $this->is_home = true; 213 218 } … … 336 341 $q['name'] = $q['pagename']; 337 342 $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 } 340 348 341 349 if ( (int) $q['w'] ) { … … 346 354 if ( intval($q['comments_popup']) ) 347 355 $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']; 348 360 349 361 // If a post number is specified, load that post … … 517 529 } 518 530 519 if ($this->is_page) { 531 if ( $this->is_subpost ) { 532 $where .= ' AND (post_status = "object")'; 533 } elseif ($this->is_page) { 520 534 $where .= ' AND (post_status = "static")'; 521 535 } elseif ($this->is_single) { … … 530 544 } 531 545 532 if (! $this->is_ object )546 if (! $this->is_subpost ) 533 547 $where .= ' AND post_status != "object"'; 534 548 … … 576 590 // Check post status to determine if post should be displayed. 577 591 if ($this->is_single) { 578 if ('publish' != $this->posts[0]->post_status) { 592 $status = get_post_status($this->posts[0]); 593 if ('publish' != $status) { 579 594 if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) { 580 595 // User must be logged in to view unpublished posts. 581 596 $this->posts = array(); 582 597 } else { 583 if ('draft' == $ this->posts[0]->post_status) {598 if ('draft' == $status) { 584 599 // User must have edit permissions on the draft to preview. 585 600 if (! user_can_edit_post($user_ID, $this->posts[0]->ID)) 586 601 $this->posts = array(); 587 } elseif ('private' == $ this->posts[0]->post_status) {602 } elseif ('private' == $status) { 588 603 if ($this->posts[0]->post_author != $user_ID) 589 604 $this->posts = array(); … … 822 837 var $queryreplace = 823 838 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 ); 837 852 838 853 var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom'); … … 846 861 847 862 function using_index_permalinks() { 848 if (empty($this->permalink_structure)) {863 if (empty($this->permalink_structure)) { 849 864 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 } 856 871 857 return false;872 return false; 858 873 } 859 874 … … 866 881 867 882 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)) { 872 887 $match_prefix = '$' . $this->matches . '['; 873 888 $match_suffix = ']'; 874 }875 876 return "$match_prefix$number$match_suffix";889 } 890 891 return "$match_prefix$number$match_suffix"; 877 892 } 878 893 … … 898 913 } 899 914 900 if (empty($this->permalink_structure)) {915 if (empty($this->permalink_structure)) { 901 916 $this->date_structure = ''; 902 917 return false; … … 974 989 } 975 990 976 if (empty($this->permalink_structure)) {991 if (empty($this->permalink_structure)) { 977 992 $this->category_structure = ''; 978 993 return false; … … 994 1009 } 995 1010 996 if (empty($this->permalink_structure)) {1011 if (empty($this->permalink_structure)) { 997 1012 $this->author_structure = ''; 998 1013 return false; … … 1009 1024 } 1010 1025 1011 if (empty($this->permalink_structure)) {1026 if (empty($this->permalink_structure)) { 1012 1027 $this->search_structure = ''; 1013 1028 return false; … … 1024 1039 } 1025 1040 1026 if (empty($this->permalink_structure)) {1041 if (empty($this->permalink_structure)) { 1027 1042 $this->page_structure = ''; 1028 1043 return false; … … 1039 1054 } 1040 1055 1041 if (empty($this->permalink_structure)) {1056 if (empty($this->permalink_structure)) { 1042 1057 $this->feed_structure = ''; 1043 1058 return false; … … 1054 1069 } 1055 1070 1056 if (empty($this->permalink_structure)) {1071 if (empty($this->permalink_structure)) { 1057 1072 $this->comment_feed_structure = ''; 1058 1073 return false; … … 1159 1174 $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; 1160 1175 $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); 1161 1190 $match = $match . '(/[0-9]+)?/?$'; 1162 1191 $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1); … … 1169 1198 1170 1199 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); 1172 1203 } 1173 1204 } … … 1232 1263 do_action('generate_rewrite_rules', array(&$this)); 1233 1264 $this->rules = apply_filters('rewrite_rules_array', $this->rules); 1265 1234 1266 return $this->rules; 1235 1267 } … … 1330 1362 1331 1363 class 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'); 1333 1365 1334 1366 var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging'); … … 1398 1430 // If the requesting file is the anchor of the match, prepend it 1399 1431 // 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)) { 1401 1433 $request_match = $req_uri . '/' . $request; 1434 die("$request_match $match<br />"); 1402 1435 } 1403 1436
Note: See TracChangeset
for help on using the changeset viewer.