From 09d8fe1b09106ec64ec34b7063239450e6c78a34 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 28 Mar 2014 02:58:53 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@27802 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 5f50166c6e..9fb017b5b1 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -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);