Ticket #6746: get_permalink_cached.diff
File get_permalink_cached.diff, 1.6 KB (added by , 16 years ago) |
---|
-
wp-includes/link-template.php
61 61 $post = &get_post($id); 62 62 63 63 if ( empty($post->ID) ) return FALSE; 64 65 if ( $permalink = wp_cache_get($post->ID, 'permalinks') ) { 66 return $permalink; 67 } 64 68 65 if ( $post->post_type == 'page' ) 66 return get_page_link($post->ID, $leavename); 67 elseif ($post->post_type == 'attachment') 68 return get_attachment_link($post->ID); 69 if ( $post->post_type == 'page' ) { 70 $permalink = get_page_link($post->ID, $leavename); 71 wp_cache_add($post->ID, $permalink, 'permalinks'); 72 return $permalink; 73 } elseif ($post->post_type == 'attachment') { 74 $permalink = get_attachment_link($post->ID); 75 wp_cache_add($post->ID, $permalink, 'permalinks'); 76 return $permalink; 77 } 69 78 70 79 $permalink = get_option('permalink_structure'); 71 80 … … 112 121 ); 113 122 $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); 114 123 $permalink = user_trailingslashit($permalink, 'single'); 115 return apply_filters('post_link', $permalink, $post); 124 $permalink = apply_filters('post_link', $permalink, $post); 125 wp_cache_add($post->ID, $permalink, 'permalinks'); 126 return $permalink; 116 127 } else { // if they're not using the fancy permalink option 117 128 $permalink = get_option('home') . '/?p=' . $post->ID; 118 return apply_filters('post_link', $permalink, $post); 129 $permalink = apply_filters('post_link', $permalink, $post); 130 wp_cache_add($post->ID, $permalink, 'permalinks'); 131 return $permalink; 119 132 } 120 133 } 121 134