From e2ce2d90fdb1642985576f3d2c897d45d7f24e60 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 20:08:49 +0000 Subject: [PATCH] =?UTF-8?q?After=20[34444=E2=80=8B],=20`wp=5Fget=5Fshortli?= =?UTF-8?q?nk()`=20can=20call=20`get=5Fqueried=5Fobject=5Fid()`=20instead?= =?UTF-8?q?=20of=20using=20the=20`$wp=5Fquery`=20global.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See #14900. git-svn-id: https://develop.svn.wordpress.org/trunk@34445 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 1f3844f6c8..84b7d69ccd 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -3471,8 +3471,6 @@ function rel_canonical() { * * @since 3.0.0. * - * @global WP_Query $wp_query - * * @param int $id A post or blog id. Default is 0, which means the current post or blog. * @param string $context Whether the id is a 'blog' id, 'post' id, or 'media' id. * If 'post', the post_type of the post is consulted. @@ -3497,13 +3495,13 @@ function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { */ $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); - if ( false !== $shortlink ) + if ( false !== $shortlink ) { return $shortlink; + } - global $wp_query; $post_id = 0; if ( 'query' == $context && is_singular() ) { - $post_id = $wp_query->get_queried_object_id(); + $post_id = get_queried_object_id(); $post = get_post( $post_id ); } elseif ( 'post' == $context ) { $post = get_post( $id );