Make WordPress Core


Ignore:
Timestamp:
05/15/2014 02:04:50 AM (10 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in _walk_bookmarks().

See #22400.

File:
1 edited

Legend:

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

    r27916 r28404  
    4848 * @return string Formatted output in HTML
    4949 */
    50 function _walk_bookmarks($bookmarks, $args = '' ) {
     50function _walk_bookmarks( $bookmarks, $args = '' ) {
    5151    $defaults = array(
    5252        'show_updated' => 0, 'show_description' => 0,
     
    5757
    5858    $r = wp_parse_args( $args, $defaults );
    59     extract( $r, EXTR_SKIP );
    6059
    6160    $output = ''; // Blank string to start with.
    6261
    6362    foreach ( (array) $bookmarks as $bookmark ) {
    64         if ( !isset($bookmark->recently_updated) )
     63        if ( ! isset( $bookmark->recently_updated ) ) {
    6564            $bookmark->recently_updated = false;
    66         $output .= $before;
    67         if ( $show_updated && $bookmark->recently_updated )
     65        }
     66        $output .= $r['before'];
     67        if ( $r['show_updated'] && $bookmark->recently_updated ) {
    6868            $output .= '<em>';
    69 
     69        }
    7070        $the_link = '#';
    71         if ( !empty($bookmark->link_url) )
    72             $the_link = esc_url($bookmark->link_url);
    73 
    74         $desc = esc_attr(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display'));
    75         $name = esc_attr(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display'));
     71        if ( ! empty( $bookmark->link_url ) ) {
     72            $the_link = esc_url( $bookmark->link_url );
     73        }
     74        $desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) );
     75        $name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
    7676        $title = $desc;
    7777
    78         if ( $show_updated )
    79             if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) {
     78        if ( $r['show_updated'] ) {
     79            if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) {
    8080                $title .= ' (';
    81                 $title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)));
     81                $title .= sprintf(
     82                    __('Last updated: %s'),
     83                    date(
     84                        get_option( 'links_updated_date_format' ),
     85                        $bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
     86                    )
     87                );
    8288                $title .= ')';
    8389            }
    84 
    85         $alt = ' alt="' . $name . ( $show_description ? ' ' . $title : '' ) . '"';
    86 
    87         if ( '' != $title )
     90        }
     91        $alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"';
     92
     93        if ( '' != $title ) {
    8894            $title = ' title="' . $title . '"';
    89 
     95        }
    9096        $rel = $bookmark->link_rel;
    91         if ( '' != $rel )
     97        if ( '' != $rel ) {
    9298            $rel = ' rel="' . esc_attr($rel) . '"';
    93 
     99        }
    94100        $target = $bookmark->link_target;
    95         if ( '' != $target )
     101        if ( '' != $target ) {
    96102            $target = ' target="' . $target . '"';
    97 
     103        }
    98104        $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
    99105
    100         $output .= $link_before;
    101 
    102         if ( $bookmark->link_image != null && $show_images ) {
    103             if ( strpos($bookmark->link_image, 'http') === 0 )
     106        $output .= $r['link_before'];
     107
     108        if ( $bookmark->link_image != null && $r['show_images'] ) {
     109            if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
    104110                $output .= "<img src=\"$bookmark->link_image\" $alt $title />";
    105             else // If it's a relative path
     111            } else { // If it's a relative path
    106112                $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
    107 
    108             if ( $show_name )
     113            }
     114            if ( $r['show_name'] ) {
    109115                $output .= " $name";
     116            }
    110117        } else {
    111118            $output .= $name;
    112119        }
    113120
    114         $output .= $link_after;
     121        $output .= $r['link_after'];
    115122
    116123        $output .= '</a>';
    117124
    118         if ( $show_updated && $bookmark->recently_updated )
     125        if ( $r['show_updated'] && $bookmark->recently_updated ) {
    119126            $output .= '</em>';
    120 
    121         if ( $show_description && '' != $desc )
    122             $output .= $between . $desc;
    123 
    124         if ( $show_rating )
    125             $output .= $between . sanitize_bookmark_field('link_rating', $bookmark->link_rating, $bookmark->link_id, 'display');
    126 
    127         $output .= "$after\n";
     127        }
     128
     129        if ( $r['show_description'] && '' != $desc ) {
     130            $output .= $r['between'] . $desc;
     131        }
     132
     133        if ( $r['show_rating'] ) {
     134            $output .= $r['between'] . sanitize_bookmark_field(
     135                'link_rating',
     136                $bookmark->link_rating,
     137                $bookmark->link_id,
     138                'display'
     139            );
     140        }
     141        $output .= $r['$after'] . "\n";
    128142    } // end while
    129143
Note: See TracChangeset for help on using the changeset viewer.