Formatting cleanups. Props Viper007Bond. fixes #8703

git-svn-id: http://svn.automattic.com/wordpress/trunk@11062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-04-22 22:56:52 +00:00
parent 7fd61e13df
commit 4789a46bfe
1 changed files with 43 additions and 45 deletions

View File

@ -940,11 +940,11 @@ function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $ex
$title = apply_filters('the_title', $title, $post);
$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
$link .= $title;
$link .= attribute_escape( $title );
$link .= "' href='" . get_permalink($post) . "' />\n";
$adjacent = $previous ? 'previous' : 'next';
return apply_filters( "{$adjacent}_post_rel_link", $link );
$adjacent = $previous ? 'previous' : 'next';
return apply_filters( "{$adjacent}_post_rel_link", $link );
}
/**
@ -1001,36 +1001,34 @@ function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_c
* @return object
*/
function get_boundary_post($in_same_cat = false, $excluded_categories = '', $start = true) {
global $post, $wpdb;
global $post, $wpdb;
if( empty($post) || !is_single() || is_attachment() )
return null;
if ( empty($post) || !is_single() || is_attachment() )
return null;
$cat_array = array();
$excluded_categories = array();
if ( !empty($in_same_cat) || !empty($excluded_categories) ) {
if ( !empty($in_same_cat) ) {
$cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids');
}
if ( !empty($in_same_cat) || !empty($excluded_categories) ) {
if ( !empty($in_same_cat) ) {
$cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids');
}
if ( !empty($excluded_categories) ) {
$excluded_categories = array_map('intval', explode(',', $excluded_categories));
if ( !empty($excluded_categories) ) {
$excluded_categories = array_map('intval', explode(',', $excluded_categories));
if ( !empty($cat_array) ) {
$excluded_categories = array_diff($excluded_categories, $cat_array);
}
if ( !empty($cat_array) )
$excluded_categories = array_diff($excluded_categories, $cat_array);
$inverse_cats = array();
foreach ( $excluded_categories as $excluded_category) {
$inverse_cats[] = $excluded_category * -1;
}
$excluded_categories = $inverse_cats;
}
}
$inverse_cats = array();
foreach ( $excluded_categories as $excluded_category)
$inverse_cats[] = $excluded_category * -1;
$excluded_categories = $inverse_cats;
}
}
$categories = array_merge($cat_array, $excluded_categories);
$order = $start ? 'ASC' : 'DESC';
$order = $start ? 'ASC' : 'DESC';
return get_posts("numberposts=1&order=$order&orderby=ID&category=$categories");
}
@ -1049,28 +1047,28 @@ function get_boundary_post($in_same_cat = false, $excluded_categories = '', $sta
* @return string
*/
function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
$posts = get_boundary_post($in_same_cat,$excluded_categories,$start);
$posts = get_boundary_post($in_same_cat,$excluded_categories,$start);
// Even though we limited get_posts to return only 1 item it still returns an array of objects.
$post = $posts[0];
if ( empty($post) )
return;
if ( empty($post) )
return;
if ( empty($post->post_title) )
$post->post_title = $start ? __('First Post') : __('Last Post');
if ( empty($post->post_title) )
$post->post_title = $start ? __('First Post') : __('Last Post');
$date = mysql2date(get_option('date_format'), $post->post_date);
$date = mysql2date(get_option('date_format'), $post->post_date);
$title = str_replace('%title', $post->post_title, $title);
$title = str_replace('%date', $date, $title);
$title = apply_filters('the_title', $title, $post);
$title = str_replace('%title', $post->post_title, $title);
$title = str_replace('%date', $date, $title);
$title = apply_filters('the_title', $title, $post);
$link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
$link .= $title;
$link .= "' href='" . get_permalink($post) . "' />\n";
$link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
$link .= attribute_escape($title);
$link .= "' href='" . get_permalink($post) . "' />\n";
$boundary = $start ? 'start' : 'end';
return apply_filters( "{$boundary}_post_rel_link", $link );
$boundary = $start ? 'start' : 'end';
return apply_filters( "{$boundary}_post_rel_link", $link );
}
/**
@ -1122,17 +1120,17 @@ function get_parent_post_rel_link($title = '%title') {
if ( empty($post) )
return;
$date = mysql2date(get_option('date_format'), $post->post_date);
$date = mysql2date(get_option('date_format'), $post->post_date);
$title = str_replace('%title', $post->post_title, $title);
$title = str_replace('%date', $date, $title);
$title = apply_filters('the_title', $title, $post);
$title = str_replace('%title', $post->post_title, $title);
$title = str_replace('%date', $date, $title);
$title = apply_filters('the_title', $title, $post);
$link = "<link rel='up' title='";
$link .= $title;
$link .= "' href='" . get_permalink($post) . "' />\n";
$link = "<link rel='up' title='";
$link .= attribute_escape( $title );
$link .= "' href='" . get_permalink($post) . "' />\n";
return apply_filters( "parent_post_rel_link", $link );
return apply_filters( "parent_post_rel_link", $link );
}
/**