Changeset 1385
- Timestamp:
- 06/04/2004 02:36:46 AM (20 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/template-functions-category.php
r1375 r1385 1 1 <?php 2 2 3 function get_the_category( ) {3 function get_the_category($id = false) { 4 4 global $post, $wpdb, $category_cache; 5 if ($category_cache[$post->ID]) { 6 return $category_cache[$post->ID]; 5 6 if (! $id) { 7 $id = $post->ID; 8 } 9 10 if ($category_cache[$id]) { 11 return $category_cache[$id]; 7 12 } else { 8 13 $categories = $wpdb->get_results(" 9 14 SELECT category_id, cat_name, category_nicename, category_description, category_parent 10 15 FROM $wpdb->categories, $wpdb->post2cat 11 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $ post->ID16 WHERE $wpdb->post2cat.category_id = cat_ID AND $wpdb->post2cat.post_id = $id 12 17 "); 13 18 -
trunk/wp-includes/template-functions-links.php
r1384 r1385 39 39 '%second%', 40 40 '%postname%', 41 '%post_id%' 41 '%post_id%', 42 '%category%' 42 43 ); 43 if (!$id) { 44 if ('' != get_settings('permalink_structure')) { 45 $unixtime = strtotime($post->post_date); 46 $rewritereplace = array( 47 date('Y', $unixtime), 48 date('m', $unixtime), 49 date('d', $unixtime), 50 date('H', $unixtime), 51 date('i', $unixtime), 52 date('s', $unixtime), 53 $post->post_name, 54 $post->ID 55 ); 56 return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); 57 } else { // if they're not using the fancy permalink option 58 return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$post->ID; 59 } 60 } else { // if an ID is given 61 $idpost = $wpdb->get_row("SELECT post_date, post_name FROM $wpdb->posts WHERE ID = $id"); 62 if ('' != get_settings('permalink_structure')) { 44 45 if ($id) { 46 $idpost = $wpdb->get_row("SELECT ID, post_date, post_name FROM $wpdb->posts WHERE ID = $id"); 47 } else { 48 $idpost = $post; 49 } 50 51 if ('' != get_settings('permalink_structure')) { 63 52 $unixtime = strtotime($idpost->post_date); 64 $rewritereplace = array( 65 date('Y', $unixtime), 66 date('m', $unixtime), 67 date('d', $unixtime), 68 date('H', $unixtime), 69 date('i', $unixtime), 70 date('s', $unixtime), 71 $idpost->post_name, 72 $id 73 ); 74 return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); 75 } else { 76 return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$id; 77 } 53 54 $cats = get_the_category($idpost->ID); 55 $category = $cats[0]->category_nicename; 56 57 $rewritereplace = array( 58 date('Y', $unixtime), 59 date('m', $unixtime), 60 date('d', $unixtime), 61 date('H', $unixtime), 62 date('i', $unixtime), 63 date('s', $unixtime), 64 $idpost->post_name, 65 $idpost->ID, 66 $category 67 ); 68 return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure')); 69 } else { // if they're not using the fancy permalink option 70 return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID; 78 71 } 79 72 }
Note: See TracChangeset
for help on using the changeset viewer.