Changeset 2478 for trunk/wp-includes/template-functions-links.php
- Timestamp:
- 03/27/2005 08:45:01 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-links.php
r2422 r2478 23 23 } 24 24 25 function get_permalink($id = false) { 26 global $post, $wpdb; 27 25 function get_permalink($id = 0) { 28 26 $rewritecode = array( 29 27 '%year%', … … 40 38 ); 41 39 42 if ($id) { 43 $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); 44 } else { 45 $idpost = $post; 40 $post = & get_post($id); 41 if ($post->post_status == 'static') { 42 return get_page_link($post->ID); 46 43 } 47 44 48 if ($idpost->post_status == 'static') {49 return get_page_link($idpost->ID);50 }51 52 45 $permalink = get_settings('permalink_structure'); 53 46 54 47 if ('' != $permalink) { 55 $unixtime = strtotime($ idpost->post_date);48 $unixtime = strtotime($post->post_date); 56 49 57 50 $category = ''; 58 51 if (strstr($permalink, '%category%')) { 59 $cats = get_the_category($ idpost->ID);52 $cats = get_the_category($post->ID); 60 53 $category = $cats[0]->category_nicename; 61 54 if ($parent=$cats[0]->category_parent) $category = get_category_parents($parent, FALSE, '/', TRUE) . $category; 62 55 } 63 56 64 $authordata = get_userdata($ idpost->post_author);57 $authordata = get_userdata($post->post_author); 65 58 $author = $authordata->user_nicename; 66 59 $rewritereplace = … … 72 65 date('i', $unixtime), 73 66 date('s', $unixtime), 74 $ idpost->post_name,75 $ idpost->ID,67 $post->post_name, 68 $post->ID, 76 69 $category, 77 70 $author, 78 $ idpost->post_name,71 $post->post_name, 79 72 ); 80 return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $ idpost);73 return apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); 81 74 } else { // if they're not using the fancy permalink option 82 $permalink = get_settings('home') . '/?p=' . $ idpost->ID;83 return apply_filters('post_link', $permalink, $ idpost);75 $permalink = get_settings('home') . '/?p=' . $post->ID; 76 return apply_filters('post_link', $permalink, $post); 84 77 } 85 78 }
Note: See TracChangeset
for help on using the changeset viewer.