WordPress.org

Make WordPress Core

Changeset 11062


Ignore:
Timestamp:
04/22/2009 10:56:52 PM (9 years ago)
Author:
ryan
Message:

Formatting cleanups. Props Viper007Bond. fixes #8703

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r11049 r11062  
    941941
    942942    $link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
    943     $link .= $title;
     943    $link .= attribute_escape( $title );
    944944    $link .= "' href='" . get_permalink($post) . "' />\n";
    945945
    946         $adjacent = $previous ? 'previous' : 'next';
    947         return apply_filters( "{$adjacent}_post_rel_link", $link );
     946    $adjacent = $previous ? 'previous' : 'next';
     947    return apply_filters( "{$adjacent}_post_rel_link", $link );
    948948}
    949949
     
    10021002 */
    10031003function get_boundary_post($in_same_cat = false, $excluded_categories = '', $start = true) {
    1004         global $post, $wpdb;
    1005 
    1006         if( empty($post) || !is_single() || is_attachment() )
    1007                 return null;
     1004    global $post, $wpdb;
     1005
     1006    if ( empty($post) || !is_single() || is_attachment() )
     1007        return null;
    10081008
    10091009    $cat_array = array();
    10101010    $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    }
    10301028
    10311029    $categories = array_merge($cat_array, $excluded_categories);
    10321030
    1033         $order = $start ? 'ASC' : 'DESC';
     1031    $order = $start ? 'ASC' : 'DESC';
    10341032
    10351033    return get_posts("numberposts=1&order=$order&orderby=ID&category=$categories");
     
    10501048 */
    10511049function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $start = true) {
    1052         $posts = get_boundary_post($in_same_cat,$excluded_categories,$start);
     1050    $posts = get_boundary_post($in_same_cat,$excluded_categories,$start);
    10531051    // Even though we limited get_posts to return only 1 item it still returns an array of objects.
    10541052    $post = $posts[0];
    10551053
    1056         if ( empty($post) )
    1057                 return;
    1058 
    1059         if ( empty($post->post_title) )
    1060                 $post->post_title = $start ? __('First Post') : __('Last Post');
    1061 
    1062         $date = mysql2date(get_option('date_format'), $post->post_date);
    1063 
    1064         $title = str_replace('%title', $post->post_title, $title);
    1065         $title = str_replace('%date', $date, $title);
    1066         $title = apply_filters('the_title', $title, $post);
    1067 
    1068         $link = $start ? "<link rel='start' title='" : "<link rel='end' title='";
    1069         $link .= $title;
    1070         $link .= "' href='" . get_permalink($post) . "' />\n";
    1071 
    1072         $boundary = $start ? 'start' : 'end';
    1073         return apply_filters( "{$boundary}_post_rel_link", $link );
     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 );
    10741072}
    10751073
     
    11231121        return;
    11241122
    1125         $date = mysql2date(get_option('date_format'), $post->post_date);
    1126 
    1127         $title = str_replace('%title', $post->post_title, $title);
    1128         $title = str_replace('%date', $date, $title);
    1129         $title = apply_filters('the_title', $title, $post);
    1130 
    1131         $link = "<link rel='up' title='";
    1132         $link .= $title;
    1133         $link .= "' href='" . get_permalink($post) . "' />\n";
    1134 
    1135         return apply_filters( "parent_post_rel_link", $link );
     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 );
    11361134}
    11371135
Note: See TracChangeset for help on using the changeset viewer.