mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-08 06:20:04 +00:00
Feeds/Links: fix feed links for unattached attachments.
Adds unit tests. Props wonderboymusic, iworks. Fixes #33693. Built from https://develop.svn.wordpress.org/trunk@34336 git-svn-id: http://core.svn.wordpress.org/trunk@34300 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2b3c283040
commit
8d2abbffac
@ -622,22 +622,35 @@ function get_post_comments_feed_link($post_id = 0, $feed = '') {
|
||||
if ( empty( $feed ) )
|
||||
$feed = get_default_feed();
|
||||
|
||||
$post = get_post( $post_id );
|
||||
$unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
|
||||
|
||||
if ( '' != get_option('permalink_structure') ) {
|
||||
if ( 'page' == get_option('show_on_front') && $post_id == get_option('page_on_front') )
|
||||
$url = _get_page_link( $post_id );
|
||||
else
|
||||
$url = get_permalink($post_id);
|
||||
|
||||
$url = trailingslashit($url) . 'feed';
|
||||
if ( $feed != get_default_feed() )
|
||||
$url .= "/$feed";
|
||||
$url = user_trailingslashit($url, 'single_feed');
|
||||
if ( $unattached ) {
|
||||
$url = home_url( '/feed/' );
|
||||
if ( $feed !== get_default_feed() ) {
|
||||
$url .= "$feed/";
|
||||
}
|
||||
$url = add_query_arg( 'attachment_id', $post_id, $url );
|
||||
} else {
|
||||
$url = trailingslashit($url) . 'feed';
|
||||
if ( $feed != get_default_feed() )
|
||||
$url .= "/$feed";
|
||||
$url = user_trailingslashit($url, 'single_feed');
|
||||
}
|
||||
} else {
|
||||
$type = get_post_field('post_type', $post_id);
|
||||
if ( 'page' == $type )
|
||||
if ( $unattached ) {
|
||||
$url = add_query_arg( array( 'feed' => $feed, 'attachment_id' => $post_id ), home_url( '/' ) );
|
||||
} elseif ( 'page' == $post->post_type ) {
|
||||
$url = add_query_arg( array( 'feed' => $feed, 'page_id' => $post_id ), home_url( '/' ) );
|
||||
else
|
||||
} else {
|
||||
$url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34335';
|
||||
$wp_version = '4.4-alpha-34336';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user