mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
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:
@@ -478,13 +478,6 @@ function url_to_postid( $url ) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
// Check to see if we are using rewrite rules
|
||||
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
||||
|
||||
// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
|
||||
if ( empty($rewrite) )
|
||||
return 0;
|
||||
|
||||
// Get rid of the #anchor
|
||||
$url_split = explode('#', $url);
|
||||
$url = $url_split[0];
|
||||
@@ -504,6 +497,21 @@ function url_to_postid( $url ) {
|
||||
if ( false === strpos(home_url(), '://www.') )
|
||||
$url = str_replace('://www.', '://', $url);
|
||||
|
||||
if ( trim( $url, '/' ) === home_url() && 'page' == get_option( 'show_on_front' ) ) {
|
||||
$page_on_front = get_option( 'page_on_front' );
|
||||
|
||||
if ( $page_on_front && get_post( $page_on_front ) instanceof WP_Post ) {
|
||||
return (int) $page_on_front;
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if we are using rewrite rules
|
||||
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
||||
|
||||
// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
|
||||
if ( empty($rewrite) )
|
||||
return 0;
|
||||
|
||||
// Strip 'index.php/' if we're not using path info permalinks
|
||||
if ( !$wp_rewrite->using_index_permalinks() )
|
||||
$url = str_replace( $wp_rewrite->index . '/', '', $url );
|
||||
|
||||
Reference in New Issue
Block a user