Ticket #16687: 16687.diff
File 16687.diff, 5.5 KB (added by , 14 years ago) |
---|
-
wp-includes/class-wp.php
15 15 * @access public 16 16 * @var array 17 17 */ 18 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type' );18 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'post_or_root_page'); 19 19 20 20 /** 21 21 * Private query variables. -
wp-includes/post.php
3172 3172 if ( empty($pages) ) 3173 3173 return $null; 3174 3174 3175 if ( 1 == count($pages) ) 3176 return get_page($pages[0]->ID, $output, $post_type); 3177 3175 3178 foreach ( $pages as $page ) { 3176 3179 $path = '/' . $leaf_path; 3177 3180 $curpage = $page; … … 3180 3183 $curpage = wp_cache_get( $post_parent, 'posts' ); 3181 3184 if ( false === $curpage ) 3182 3185 $curpage = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE ID = %d and post_type = %s", $post_parent, $post_type ) ); 3186 if ( ! $curpage ) 3187 break; 3183 3188 $path = '/' . $curpage->post_name . $path; 3184 3189 } 3185 3190 -
wp-includes/query.php
1634 1634 } 1635 1635 } 1636 1636 1637 if ( ! empty( $qv['post_or_root_page'] ) ) { 1638 $qv['post_type'] = array( 'post', 'page' ); 1639 $qv['post_parent'] = 0; 1640 } 1641 1637 1642 if ( !empty($qv['post_type']) ) { 1638 1643 if ( is_array($qv['post_type']) ) 1639 1644 $qv['post_type'] = array_map('sanitize_key', $qv['post_type']); … … 2106 2111 } else { 2107 2112 $reqpage = get_page_by_path($q['pagename']); 2108 2113 } 2109 if ( !empty($reqpage) ) 2114 if ( !empty($reqpage) ) { 2110 2115 $reqpage = $reqpage->ID; 2111 else 2112 $reqpage = 0; 2116 } else { 2117 // Assume it's a post attachment. 2118 $this->is_attachment = true; 2119 $post_type = $q['post_type'] = 'attachment'; 2120 $q['attachment'] = $q['name'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); 2121 $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; 2122 } 2113 2123 } 2114 2124 2115 2125 $page_for_posts = get_option('page_for_posts'); 2116 if ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts) ) {2126 if ( isset($reqpage) && ( ('page' != get_option('show_on_front') ) || empty($page_for_posts) || ( $reqpage != $page_for_posts ) ) ) { 2117 2127 $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) ); 2118 2128 $q['name'] = $q['pagename']; 2119 2129 $where .= " AND ($wpdb->posts.ID = '$reqpage')"; -
wp-includes/rewrite.php
597 597 */ 598 598 var $use_verbose_page_rules = true; 599 599 600 var $use_verbose_attachment_rules = false; 601 600 602 /** 601 603 * Permalink structure search for preg_replace. 602 604 * … … 1440 1442 $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite); 1441 1443 1442 1444 //add regexes/queries for attachments, attachment trackbacks and so on 1443 if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages1445 if ( ! $page && ! $this->use_verbose_attachment_rules ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages 1444 1446 $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery)); 1445 1447 $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite); 1446 1448 } … … 1908 1910 $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) ); 1909 1911 1910 1912 // Enable generic rules for pages if permalink structure doesn't begin with a wildcard. 1911 if ( preg_match("/^[^%]*%(?: postname|category|tag|author)%/", $this->permalink_structure) )1912 1913 if ( preg_match("/^[^%]*%(?:category|tag|author)%/", $this->permalink_structure) ) 1914 $this->use_verbose_page_rules = true; 1913 1915 else 1914 1916 $this->use_verbose_page_rules = false; 1917 1918 // In the event the permalink structure atarts with /%postname% do a post||page post_type query 1919 if ( strpos($this->permalink_structure, '/%postname%') == 0 ) { 1920 $this->add_rewrite_tag('%postname%', "([^/]+)", 'post_or_root_page=1&name='); 1921 $this->use_verbose_attachment_rules = true; 1922 } 1915 1923 } 1916 1924 1917 1925 /**