Ticket #14760: wp_get_shortlink-2.diff
File wp_get_shortlink-2.diff, 1.1 KB (added by , 14 years ago) |
---|
-
wp-includes/link-template.php
2379 2379 2380 2380 global $wp_query; 2381 2381 $post_id = 0; 2382 if ( 'query' == $context && is_sing le() ) {2382 if ( 'query' == $context && is_singular() ) { 2383 2383 $post_id = $wp_query->get_queried_object_id(); 2384 2384 } elseif ( 'post' == $context ) { 2385 2385 $post = get_post($id); … … 2388 2388 2389 2389 $shortlink = ''; 2390 2390 2391 // Return p= link for posts.2391 // Return p= link for all public post types. 2392 2392 if ( !empty($post_id) && '' != get_option('permalink_structure') ) { 2393 $post = get_post($post_id); 2394 if ( isset($post->post_type) && 'post' == $post->post_type ) 2395 $shortlink = home_url('?p=' . $post->ID); 2393 if (!isset($post)) { 2394 $post = get_post($post_id); 2395 } 2396 $post_type = get_post_type_object( $post->post_type ); 2397 if ( $post_type->public ) { 2398 $shortlink = home_url('?p=' . $post_id); 2399 } 2396 2400 } 2397 2401 2398 2402 return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs);