Ticket #2215: 2215.diff
File 2215.diff, 5.6 KB (added by , 18 years ago) |
---|
-
wp-includes/template-loader.php
7 7 } else if ( is_trackback() ) { 8 8 include(ABSPATH . '/wp-trackback.php'); 9 9 exit; 10 } else if ( is_404() && get_404_template() ) {11 include( get_404_template());10 } else if ( is_404() && $template = get_404_template() ) { 11 include($template); 12 12 exit; 13 } else if ( is_search() && get_search_template() ) {14 include( get_search_template());13 } else if ( is_search() && $template = get_search_template() ) { 14 include($template); 15 15 exit; 16 } else if ( is_home() && get_home_template() ) {17 include( get_home_template());16 } else if ( is_home() && $template = get_home_template() ) { 17 include($template); 18 18 exit; 19 } else if ( is_attachment() && get_attachment_template() ) {20 include( get_attachment_template());19 } else if ( is_attachment() && $template = get_attachment_template() ) { 20 include($template); 21 21 exit; 22 } else if ( is_single() && get_single_template() ) {22 } else if ( is_single() && $template = get_single_template() ) { 23 23 if ( is_attachment() ) 24 24 add_filter('the_content', 'prepend_attachment'); 25 include( get_single_template());25 include($template); 26 26 exit; 27 } else if ( is_page() && get_page_template() ) {27 } else if ( is_page() && $template = get_page_template() ) { 28 28 if ( is_attachment() ) 29 29 add_filter('the_content', 'prepend_attachment'); 30 include( get_page_template());30 include($template); 31 31 exit; 32 } else if ( is_category() && get_category_template()) {33 include( get_category_template());32 } else if ( is_category() && $template = get_category_template()) { 33 include($template); 34 34 exit; 35 } else if ( is_author() && get_author_template() ) {36 include( get_author_template());35 } else if ( is_author() && $template = get_author_template() ) { 36 include($template); 37 37 exit; 38 } else if ( is_date() && get_date_template() ) {39 include( get_date_template());38 } else if ( is_date() && $template = get_date_template() ) { 39 include($template); 40 40 exit; 41 } else if ( is_archive() && get_archive_template() ) {42 include( get_archive_template());41 } else if ( is_archive() && $template = get_archive_template() ) { 42 include($template); 43 43 exit; 44 } else if ( is_comments_popup() && get_comments_popup_template() ) {45 include( get_comments_popup_template());44 } else if ( is_comments_popup() && $template = get_comments_popup_template() ) { 45 include($template); 46 46 exit; 47 } else if ( is_paged() && get_paged_template() ) {48 include( get_paged_template());47 } else if ( is_paged() && $template = get_paged_template() ) { 48 include($template); 49 49 exit; 50 50 } else if ( file_exists(TEMPLATEPATH . "/index.php") ) { 51 51 if ( is_attachment() ) … … 64 64 } 65 65 } 66 66 67 ?> 67 ?> 68 No newline at end of file -
wp-includes/template-functions-links.php
257 257 258 258 $sql_exclude_cats = ''; 259 259 if ( !empty($excluded_categories) ) { 260 $blah = explode(' and', $excluded_categories);260 $blah = explode(' and ', $excluded_categories); 261 261 foreach ( $blah as $category ) { 262 262 $category = intval($category); 263 $sql_ exclude_cats .= " AND post_category != $category";263 $sql_cat_ids = " OR pc.category_ID='$category'"; 264 264 } 265 $posts_in_ex_cats = $wpdb->get_col("SELECT p.ID from $wpdb->posts p LEFT JOIN $wpdb->post2cat pc ON pc.post_id=p.ID WHERE 1=0 $sql_cat_ids GROUP BY p.ID"); 266 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 265 267 } 266 268 267 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $ sqlcat $sql_exclude_catsORDER BY post_date DESC LIMIT 1");269 return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_status = 'publish' $posts_in_ex_cats_sql ORDER BY post_date DESC LIMIT 1"); 268 270 } 269 271 270 272 function get_next_post($in_same_cat = false, $excluded_categories = '') { … … 288 290 289 291 $sql_exclude_cats = ''; 290 292 if ( !empty($excluded_categories) ) { 291 $blah = explode(' and', $excluded_categories);293 $blah = explode(' and ', $excluded_categories); 292 294 foreach ( $blah as $category ) { 293 295 $category = intval($category); 294 $sql_ exclude_cats .= " AND post_category != $category";296 $sql_cat_ids = " OR pc.category_ID='$category'"; 295 297 } 298 $posts_in_ex_cats = $wpdb->get_col("SELECT p.ID from $wpdb->posts p LEFT JOIN $wpdb->post2cat pc ON pc.post_id=p.ID WHERE 1=0 $sql_cat_ids GROUP BY p.ID"); 299 $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 296 300 } 297 301 298 302 $now = current_time('mysql'); 299 303 300 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $ sqlcat $sql_exclude_catsAND ID != $post->ID ORDER BY post_date ASC LIMIT 1");304 return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 301 305 } 302 306 303 307 … … 324 328 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { 325 329 $post = get_next_post($in_same_cat, $excluded_categories); 326 330 327 if ( !$post ) 331 if ( !$post ) { 328 332 return; 333 } 329 334 330 335 $title = apply_filters('the_title', $post->post_title, $post); 331 336 $string = '<a href="'.get_permalink($post->ID).'">';