Changeset 11062
- Timestamp:
- 04/22/2009 10:56:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r11049 r11062 941 941 942 942 $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='"; 943 $link .= $title;943 $link .= attribute_escape( $title ); 944 944 $link .= "' href='" . get_permalink($post) . "' />\n"; 945 945 946 947 946 $adjacent = $previous ? 'previous' : 'next'; 947 return apply_filters( "{$adjacent}_post_rel_link", $link ); 948 948 } 949 949 … … 1002 1002 */ 1003 1003 function get_boundary_post($in_same_cat = false, $excluded_categories = '', $start = true) { 1004 1005 1006 if( empty($post) || !is_single() || is_attachment() )1007 1004 global $post, $wpdb; 1005 1006 if ( empty($post) || !is_single() || is_attachment() ) 1007 return null; 1008 1008 1009 1009 $cat_array = array(); 1010 1010 $excluded_categories = array(); 1011 if ( !empty($in_same_cat) || !empty($excluded_categories) ) { 1012 if ( !empty($in_same_cat) ) { 1013 $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids'); 1014 } 1015 1016 if ( !empty($excluded_categories) ) { 1017 $excluded_categories = array_map('intval', explode(',', $excluded_categories)); 1018 1019 if ( !empty($cat_array) ) { 1020 $excluded_categories = array_diff($excluded_categories, $cat_array); 1021 } 1022 1023 $inverse_cats = array(); 1024 foreach ( $excluded_categories as $excluded_category) { 1025 $inverse_cats[] = $excluded_category * -1; 1026 } 1027 $excluded_categories = $inverse_cats; 1028 } 1029 } 1011 if ( !empty($in_same_cat) || !empty($excluded_categories) ) { 1012 if ( !empty($in_same_cat) ) { 1013 $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids'); 1014 } 1015 1016 if ( !empty($excluded_categories) ) { 1017 $excluded_categories = array_map('intval', explode(',', $excluded_categories)); 1018 1019 if ( !empty($cat_array) ) 1020 $excluded_categories = array_diff($excluded_categories, $cat_array); 1021 1022 $inverse_cats = array(); 1023 foreach ( $excluded_categories as $excluded_category) 1024 $inverse_cats[] = $excluded_category * -1; 1025 $excluded_categories = $inverse_cats; 1026 } 1027 } 1030 1028 1031 1029 $categories = array_merge($cat_array, $excluded_categories); 1032 1030 1033 1031 $order = $start ? 'ASC' : 'DESC'; 1034 1032 1035 1033 return get_posts("numberposts=1&order=$order&orderby=ID&category=$categories"); … … 1050 1048 */ 1051 1049 function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) { 1052 1050 $posts = get_boundary_post($in_same_cat,$excluded_categories,$start); 1053 1051 // Even though we limited get_posts to return only 1 item it still returns an array of objects. 1054 1052 $post = $posts[0]; 1055 1053 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 $link .= $title;1070 1071 1072 1073 1054 if ( empty($post) ) 1055 return; 1056 1057 if ( empty($post->post_title) ) 1058 $post->post_title = $start ? __('First Post') : __('Last Post'); 1059 1060 $date = mysql2date(get_option('date_format'), $post->post_date); 1061 1062 $title = str_replace('%title', $post->post_title, $title); 1063 $title = str_replace('%date', $date, $title); 1064 $title = apply_filters('the_title', $title, $post); 1065 1066 $link = $start ? "<link rel='start' title='" : "<link rel='end' title='"; 1067 $link .= attribute_escape($title); 1068 $link .= "' href='" . get_permalink($post) . "' />\n"; 1069 1070 $boundary = $start ? 'start' : 'end'; 1071 return apply_filters( "{$boundary}_post_rel_link", $link ); 1074 1072 } 1075 1073 … … 1123 1121 return; 1124 1122 1125 1126 1127 1128 1129 1130 1131 1132 $link .= $title;1133 1134 1135 1123 $date = mysql2date(get_option('date_format'), $post->post_date); 1124 1125 $title = str_replace('%title', $post->post_title, $title); 1126 $title = str_replace('%date', $date, $title); 1127 $title = apply_filters('the_title', $title, $post); 1128 1129 $link = "<link rel='up' title='"; 1130 $link .= attribute_escape( $title ); 1131 $link .= "' href='" . get_permalink($post) . "' />\n"; 1132 1133 return apply_filters( "parent_post_rel_link", $link ); 1136 1134 } 1137 1135
Note: See TracChangeset
for help on using the changeset viewer.