Ticket #14760: wp_get_shortlink-3.diff
File wp_get_shortlink-3.diff, 1.1 KB (added by , 13 years ago) |
---|
-
link-template.php
2385 2385 2386 2386 global $wp_query; 2387 2387 $post_id = 0; 2388 if ( 'query' == $context && is_sing le() ) {2388 if ( 'query' == $context && is_singular() ) { 2389 2389 $post_id = $wp_query->get_queried_object_id(); 2390 2390 } elseif ( 'post' == $context ) { 2391 2391 $post = get_post($id); … … 2394 2394 2395 2395 $shortlink = ''; 2396 2396 2397 // Return p= link for posts. 2398 if ( !empty($post_id) && '' != get_option('permalink_structure') ) { 2399 $post = get_post($post_id); 2400 if ( isset($post->post_type) && 'post' == $post->post_type ) 2401 $shortlink = home_url('?p=' . $post->ID); 2397 // Return p= link for all public post types. 2398 if ( !empty($post_id) ) { 2399 if (!isset($post)) { 2400 $post = get_post($post_id); 2401 } 2402 $post_type = get_post_type_object( $post->post_type ); 2403 if ( $post_type->public ) { 2404 $shortlink = home_url('?p=' . $post_id); 2405 } 2402 2406 } 2403 2407 2404 2408 return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs);