Make WordPress Core

Ticket #16687: no_verbose_ver1.diff

File no_verbose_ver1.diff, 3.8 KB (added by Otto42, 14 years ago)

Make verbose page rules not quite so verbose anymore

  • wp-includes/class-wp.php

     
    189189                                // Don't try to match against AtomPub calls
    190190                                if ( $req_uri == 'wp-app.php' )
    191191                                        break;
    192 
     192 
    193193                                // If the requesting file is the anchor of the match, prepend it
    194194                                // to the path info.
    195195                                if ( (! empty($req_uri)) && (strpos($match, $req_uri) === 0) && ($req_uri != $request) )
     
    197197
    198198                                if ( preg_match("#^$match#", $request_match, $matches) ||
    199199                                        preg_match("#^$match#", urldecode($request_match), $matches) ) {
     200                                       
     201                                        if ( $wp_rewrite->use_verbose_page_rules == true && strpos( $query, 'pagename' ) !== false ) {
     202                                                // this is a verbose page match, lets check to be sure about it
     203                                                if ( ! get_page_by_path($request_match) ) continue;
     204                                        }
     205                                       
    200206                                        // Got a match.
    201207                                        $this->matched_rule = $match;
    202 
     208       
    203209                                        // Trim the query of everything up to the '?'.
    204210                                        $query = preg_replace("!^.+\?!", '', $query);
    205211
  • wp-includes/rewrite.php

     
    306306        // Look for matches.
    307307        $request_match = $request;
    308308        foreach ( (array)$rewrite as $match => $query) {
     309
     310                if ( $wp_rewrite->use_verbose_page_rules == true && strpos( $query, 'pagename' ) !== false ) {
     311                        // this is a verbose page match, lets check to be sure about it
     312                        if ( ! get_page_by_path($request_match) )
     313                                continue;
     314                }
     315
    309316                // If the requesting file is the anchor of the match, prepend it
    310317                // to the path info.
    311318                if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
     
    813820                $rewrite_rules = array();
    814821                $page_structure = $this->get_page_permastruct();
    815822
    816                 if ( ! $this->use_verbose_page_rules ) {
    817                         $this->add_rewrite_tag('%pagename%', "(.+?)", 'pagename=');
    818                         $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    819                         return $rewrite_rules;
    820                 }
    821 
    822                 $page_uris = $this->page_uri_index();
    823                 $uris = $page_uris[0];
    824                 $attachment_uris = $page_uris[1];
    825 
    826                 if ( is_array( $attachment_uris ) ) {
    827                         foreach ( $attachment_uris as $uri => $pagename ) {
    828                                 $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
    829                                 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    830                         }
    831                 }
    832                 if ( is_array( $uris ) ) {
    833                         foreach ( $uris as $uri => $pagename ) {
    834                                 $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
    835                                 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    836                         }
    837                 }
    838 
     823                $this->add_rewrite_tag('%pagename%', "(.+?)", 'pagename=');
     824                $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES));
    839825                return $rewrite_rules;
    840826        }
    841827
     
    15581544
    15591545                // Put them together.
    15601546                if ( $this->use_verbose_page_rules )
    1561                         $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
     1547                        $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules);
    15621548                else
    15631549                        $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite,  $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
    15641550