Make WordPress Core

Ticket #16687: 16687.diff

File 16687.diff, 5.5 KB (added by dd32, 14 years ago)
  • wp-includes/class-wp.php

     
    1515         * @access public
    1616         * @var array
    1717         */
    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');
    1919
    2020        /**
    2121         * Private query variables.
  • wp-includes/post.php

     
    31723172        if ( empty($pages) )
    31733173                return $null;
    31743174
     3175        if ( 1 == count($pages) )
     3176                return get_page($pages[0]->ID, $output, $post_type);           
     3177
    31753178        foreach ( $pages as $page ) {
    31763179                $path = '/' . $leaf_path;
    31773180                $curpage = $page;
     
    31803183                        $curpage = wp_cache_get( $post_parent, 'posts' );
    31813184                        if ( false === $curpage )
    31823185                                $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;
    31833188                        $path = '/' . $curpage->post_name . $path;
    31843189                }
    31853190
  • wp-includes/query.php

     
    16341634                        }
    16351635                }
    16361636
     1637                if ( ! empty( $qv['post_or_root_page'] ) ) {
     1638                        $qv['post_type'] = array( 'post', 'page' );
     1639                        $qv['post_parent'] = 0;
     1640                }
     1641
    16371642                if ( !empty($qv['post_type']) ) {
    16381643                        if ( is_array($qv['post_type']) )
    16391644                                $qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
     
    21062111                                } else {
    21072112                                        $reqpage = get_page_by_path($q['pagename']);
    21082113                                }
    2109                                 if ( !empty($reqpage) )
     2114                                if ( !empty($reqpage) ) {
    21102115                                        $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                                }
    21132123                        }
    21142124
    21152125                        $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 ) ) ) {
    21172127                                $q['pagename'] = sanitize_title_for_query( wp_basename( $q['pagename'] ) );
    21182128                                $q['name'] = $q['pagename'];
    21192129                                $where .= " AND ($wpdb->posts.ID = '$reqpage')";
  • wp-includes/rewrite.php

     
    597597         */
    598598        var $use_verbose_page_rules = true;
    599599
     600        var $use_verbose_attachment_rules = false;
     601
    600602        /**
    601603         * Permalink structure search for preg_replace.
    602604         *
     
    14401442                                        $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
    14411443
    14421444                                        //add regexes/queries for attachments, attachment trackbacks and so on
    1443                                         if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
     1445                                        if ( ! $page && ! $this->use_verbose_attachment_rules ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
    14441446                                                $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
    14451447                                        $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
    14461448                                }
     
    19081910                $this->use_trailing_slashes = ( '/' == substr($this->permalink_structure, -1, 1) );
    19091911
    19101912                // 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                          $this->use_verbose_page_rules = true;
     1913                if ( preg_match("/^[^%]*%(?:category|tag|author)%/", $this->permalink_structure) )
     1914                        $this->use_verbose_page_rules = true;
    19131915                else
    19141916                        $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                }
    19151923        }
    19161924
    19171925        /**