Ticket #17185: optimize-verbose-page.diff
File optimize-verbose-page.diff, 3.7 KB (added by , 14 years ago) |
---|
-
wp-includes/rewrite.php
782 782 foreach ( $posts as $id => $post ) { 783 783 // URL => page name 784 784 $uri = get_page_uri($id); 785 $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID , post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ));785 $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ) ); 786 786 if ( !empty($attachments) ) { 787 787 foreach ( $attachments as $attachment ) { 788 788 $attach_uri = get_page_uri($attachment->ID); … … 826 826 if ( is_array( $attachment_uris ) ) { 827 827 foreach ( $attachment_uris as $uri => $pagename ) { 828 828 $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment='); 829 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES ));829 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES, false)); 830 830 } 831 831 } 832 832 if ( is_array( $uris ) ) { 833 833 foreach ( $uris as $uri => $pagename ) { 834 834 $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); 835 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES ));835 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure, EP_PAGES, false)); 836 836 } 837 837 } 838 838 839 // page attachments catch-all 840 $rewrite_rules = array_merge( $rewrite_rules, array( '.+?/attachment/([^/]+)/?$' => 'index.php?attachment=$matches[1]' ) ); 841 839 842 return $rewrite_rules; 840 843 } 841 844 … … 1389 1392 $sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...) 1390 1393 $sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...) 1391 1394 $sub1comment = $sub1 . $commentregex; //and <permalink>/comment-page-xx 1392 //add an ? as we don't have to match that last slash, and finally a $ so we1393 //match to the end of the URL1394 1395 1395 //add another rule to match attachments in the explicit form: 1396 //<permalink>/attachment/some-text 1396 //add another rule to match attachments in the explicit form: <permalink>/attachment/some-text 1397 1397 $sub2 = $submatchbase . '/attachment/([^/]+)/'; 1398 1398 $sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback 1399 1399 $sub2feed = $sub2 . $feedregex; //feeds, <permalink>/attachment/feed/(atom|...) … … 1417 1417 } 1418 1418 1419 1419 //now we've finished with endpoints, finish off the $sub1 and $sub2 matches 1420 //add a ? as we don't have to match that last slash, and finally a $ so we match to the end of the URL 1420 1421 $sub1 .= '?$'; 1421 1422 $sub2 .= '?$'; 1422 1423 … … 1442 1443 //add regexes/queries for attachments, attachment trackbacks and so on 1443 1444 if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages 1444 1445 $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery)); 1445 $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite); 1446 if ( ! $page || ! $this->use_verbose_page_rules ) //individual <permalink>/attachment/stuff only for non-verbose page or non-page rewrites 1447 $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite); 1446 1448 } 1447 1449 } //if($num_toks) 1448 1450 //add the rules for this dir to the accumulating $post_rewrite