Skip to content

Commit e2ce2d9

Browse files
committed
After [34444​], wp_get_shortlink() can call get_queried_object_id() instead of using the $wp_query global.
See #14900. git-svn-id: https://develop.svn.wordpress.org/trunk@34445 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e06ca91 commit e2ce2d9

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/wp-includes/link-template.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,8 +3471,6 @@ function rel_canonical() {
34713471
*
34723472
* @since 3.0.0.
34733473
*
3474-
* @global WP_Query $wp_query
3475-
*
34763474
* @param int $id A post or blog id. Default is 0, which means the current post or blog.
34773475
* @param string $context Whether the id is a 'blog' id, 'post' id, or 'media' id.
34783476
* 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) {
34973495
*/
34983496
$shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs );
34993497

3500-
if ( false !== $shortlink )
3498+
if ( false !== $shortlink ) {
35013499
return $shortlink;
3500+
}
35023501

3503-
global $wp_query;
35043502
$post_id = 0;
35053503
if ( 'query' == $context && is_singular() ) {
3506-
$post_id = $wp_query->get_queried_object_id();
3504+
$post_id = get_queried_object_id();
35073505
$post = get_post( $post_id );
35083506
} elseif ( 'post' == $context ) {
35093507
$post = get_post( $id );

0 commit comments

Comments
 (0)