Shortlinks: Use the home URL for a page on front.

This will result in 'Get Shortlink' hiding by default, as it will match the permalink (also the home URL).

fixes #26871.

Built from https://develop.svn.wordpress.org/trunk@27802


git-svn-id: http://core.svn.wordpress.org/trunk@27637 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-03-28 02:59:14 +00:00
parent c3ca81ba94
commit f62f720f0c
1 changed files with 6 additions and 2 deletions

View File

@ -2788,8 +2788,12 @@ function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) {
// Return p= link for all public post types.
if ( ! empty( $post_id ) ) {
$post_type = get_post_type_object( $post->post_type );
if ( $post_type->public )
$shortlink = home_url('?p=' . $post_id);
if ( 'page' === $post->post_type && $post->ID == get_option( 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {
$shortlink = home_url( '/' );
} elseif ( $post_type->public ) {
$shortlink = home_url( '?p=' . $post_id );
}
}
return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs);