Changeset 1605 for trunk/wp-includes/template-functions-links.php
- Timestamp:
- 09/05/2004 02:41:01 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-links.php
r1557 r1605 27 27 } 28 28 29 function get_permalink($id=false) { 30 global $post, $wpdb; 31 global $querystring_start, $querystring_equal; 32 33 $rewritecode = array( 34 '%year%', 35 '%monthnum%', 36 '%day%', 37 '%hour%', 38 '%minute%', 39 '%second%', 40 '%postname%', 41 '%post_id%', 42 '%category%', 43 '%author%', 44 '%pagename%' 45 ); 46 47 if ($id) { 48 $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); 49 } else { 50 $idpost = $post; 51 } 52 53 $permalink = get_settings('permalink_structure'); 54 55 if ('' != $permalink) { 56 if ($idpost->post_status == 'static') { 57 $permalink = page_permastruct(); 58 } 59 60 $unixtime = strtotime($idpost->post_date); 61 62 $cats = get_the_category($idpost->ID); 63 $category = $cats[0]->category_nicename; 64 $authordata = get_userdata($idpost->post_author); 65 $author = $authordata->user_nicename; 66 67 $rewritereplace = array( 68 date('Y', $unixtime), 69 date('m', $unixtime), 70 date('d', $unixtime), 71 date('H', $unixtime), 72 date('i', $unixtime), 73 date('s', $unixtime), 74 $idpost->post_name, 75 $idpost->ID, 76 $category, 77 $author, 78 $idpost->post_name, 79 ); 80 return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); 81 } else { // if they're not using the fancy permalink option 82 $permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID; 83 if ($idpost->post_status == 'static') { 84 $permalink .= $querystring_separator . "static=1"; 85 } 86 return $permalink; 87 } 29 function get_permalink($id = false) { 30 global $post, $wpdb; 31 32 $rewritecode = array( 33 '%year%', 34 '%monthnum%', 35 '%day%', 36 '%hour%', 37 '%minute%', 38 '%second%', 39 '%postname%', 40 '%post_id%', 41 '%category%', 42 '%author%', 43 '%pagename%' 44 ); 45 46 if ($id) { 47 $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); 48 } else { 49 $idpost = $post; 50 } 51 52 $permalink = get_settings('permalink_structure'); 53 54 if ('' != $permalink) { 55 if ($idpost->post_status == 'static') 56 $permalink = page_permastruct(); 57 58 $unixtime = strtotime($idpost->post_date); 59 60 $cats = get_the_category($idpost->ID); 61 $category = $cats[0]->category_nicename; 62 $authordata = get_userdata($idpost->post_author); 63 $author = $authordata->user_nicename; 64 $rewritereplace = 65 array( 66 date('Y', $unixtime), 67 date('m', $unixtime), 68 date('d', $unixtime), 69 date('H', $unixtime), 70 date('i', $unixtime), 71 date('s', $unixtime), 72 $idpost->post_name, 73 $idpost->ID, 74 $category, 75 $author, 76 $idpost->post_name, 77 ); 78 return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); 79 } else { // if they're not using the fancy permalink option 80 $permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID; 81 if ($idpost->post_status == 'static') 82 $permalink .= '&static=1'; 83 return $permalink; 84 } 88 85 } 89 86
Note: See TracChangeset
for help on using the changeset viewer.