WordPress.org

Make WordPress Core

Ticket #5319: single-post-content-feed-r6307.patch

File single-post-content-feed-r6307.patch, 2.3 KB (added by tellyworth, 6 years ago)
  • wordpress/wp-includes/rewrite.php

     
    511511                //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/? 
    512512                $feedregex2 = ''; 
    513513                foreach ($this->feeds as $feed_name) { 
    514                         $feedregex2 .= $feed_name . '|'; 
     514                        $feedregexgroup .= $feed_name . '|'; 
    515515                } 
    516                 $feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$'; 
     516                $feedregexgroup = '(' . trim($feedregexgroup, '|') .  ')'; 
     517                $feedregex2 = $feedregexgroup . '/?$'; 
    517518                //$feedregex is identical but with /feed/ added on as well, so URLs like <permalink>/feed/atom 
    518519                //and <permalink>/atom are both possible 
    519                 $feedregex = $this->feed_base  . '/' . $feedregex2; 
     520                $feedregex = $this->feed_base  . '/' . $feedregexgroup . '/?$'; 
     521                //$feedregex3 has the 'post' item included also 
     522                $feedregex3 = $feedregexgroup . '/post/?$'; 
    520523 
    521524                //build a regex to match the trackback and page/xx parts of URLs 
    522525                $trackbackregex = 'trackback/?$'; 
     
    653656                                        //create query and regex for trackback 
    654657                                        $trackbackmatch = $match . $trackbackregex; 
    655658                                        $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; 
     659                                        //create query and regex for the single post feed 
     660                                        $postfeedmatch = $match . $feedregex3; 
     661                                        $postfeedquery = $query . '&feed=' .$this->preg_index(5) . '&withoutcomments=1'; 
     662 
    656663                                        //trim slashes from the end of the regex for this dir 
    657664                                        $match = rtrim($match, '/'); 
    658665                                        //get rid of brackets 
     
    711718 
    712719                                        //add regexes/queries for attachments, attachment trackbacks and so on 
    713720                                        if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages 
    714                                                 $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery)); 
     721                                                $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $postfeedmatch => $postfeedquery)); 
    715722                                        $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery)); 
    716723                                } 
    717724                        } //if($num_toks)