Embeds: Allow embedding static front pages and pages having a child page with an embed slug.

This makes `embed` a special slug that can't be used for new pages/posts. When `https://example.com/foo/embed/` is an existing page, embeds fall back to `https://example.com/foo/?embed=true`.
Adds unit tests.

Fixes #34971.

git-svn-id: https://develop.svn.wordpress.org/trunk@36307 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler
2016-01-15 07:55:19 +00:00
parent ee60e36a2c
commit d80a3c7ccd
10 changed files with 241 additions and 27 deletions
+5 -1
View File
@@ -1022,6 +1022,10 @@ class WP_Rewrite {
$feedmatch2 = $match . $feedregex2;
$feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
// Create query and regex for embeds.
$embedmatch = $match . $embedregex;
$embedquery = $embedindex . '?' . $query . '&embed=true';
// If asked to, turn the feed queries into comment feed ones.
if ( $forcomments ) {
$feedquery .= '&withcomments=1';
@@ -1033,7 +1037,7 @@ class WP_Rewrite {
// ...adding on /feed/ regexes => queries
if ( $feed ) {
$rewrite = array( $feedmatch => $feedquery, $feedmatch2 => $feedquery2 );
$rewrite = array( $feedmatch => $feedquery, $feedmatch2 => $feedquery2, $embedmatch => $embedquery );
}
//...and /page/xx ones