Make WordPress Core

Ticket #50561: 50561.2.diff

File 50561.2.diff, 3.2 KB (added by sabernhardt, 4 years ago)

slight revision: using Yoda condition for the http absolute URL check

  • src/wp-includes/bookmark-template.php

     
    5050 */
    5151function _walk_bookmarks( $bookmarks, $args = '' ) {
    5252        $defaults = array(
    53                 'show_updated'     => 0,
     53                'show_updated'     => 0, // Unused.
    5454                'show_description' => 0,
    5555                'show_images'      => 1,
    5656                'show_name'        => 0,
     
    6767        $output = ''; // Blank string to start with.
    6868
    6969        foreach ( (array) $bookmarks as $bookmark ) {
    70                 if ( ! isset( $bookmark->recently_updated ) ) {
    71                         $bookmark->recently_updated = false;
    72                 }
    7370                $output .= $parsed_args['before'];
    74                 if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
    75                         $output .= '<em>';
    76                 }
    7771                $the_link = '#';
    7872                if ( ! empty( $bookmark->link_url ) ) {
    7973                        $the_link = esc_url( $bookmark->link_url );
     
    8074                }
    8175                $desc  = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) );
    8276                $name  = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
    83                 $title = $desc;
    8477
    85                 if ( $parsed_args['show_updated'] ) {
    86                         if ( '00' !== substr( $bookmark->link_updated_f, 0, 2 ) ) {
    87                                 $title .= ' (';
    88                                 $title .= sprintf(
    89                                         /* translators: %s: Date and time of last update. */
    90                                         __( 'Last updated: %s' ),
    91                                         gmdate(
    92                                                 get_option( 'links_updated_date_format' ),
    93                                                 $bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
    94                                         )
    95                                 );
    96                                 $title .= ')';
    97                         }
    98                 }
    99                 $alt = ' alt="' . $name . ( $parsed_args['show_description'] ? ' ' . $title : '' ) . '"';
    100 
    101                 if ( '' !== $title ) {
    102                         $title = ' title="' . $title . '"';
    103                 }
    10478                $rel = $bookmark->link_rel;
    10579                if ( '' !== $rel ) {
    10680                        $rel = ' rel="' . esc_attr( $rel ) . '"';
     
    10983                if ( '' !== $target ) {
    11084                        $target = ' target="' . $target . '"';
    11185                }
    112                 $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
     86                $output .= '<a href="' . $the_link . '"' . $rel . $target . '>';
    11387
    11488                $output .= $parsed_args['link_before'];
    11589
    11690                if ( null != $bookmark->link_image && $parsed_args['show_images'] ) {
    117                         if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
    118                                 $output .= "<img src=\"$bookmark->link_image\" $alt $title />";
     91                        if ( 0 === strpos( $bookmark->link_image, 'http' ) ) {
     92                                $linked_image = $bookmark->link_image;
    11993                        } else { // If it's a relative path.
    120                                 $output .= '<img src="' . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />";
     94                                $linked_image = site_url( $bookmark->link_image );
    12195                        }
    12296                        if ( $parsed_args['show_name'] ) {
    123                                 $output .= " $name";
     97                                $output .= '<img src="' . $linked_image . '" alt="" /> ' . $name;
     98                        } else {
     99                                $output .= '<img src="' . $linked_image . '" alt="' . $name . '" />';
    124100                        }
    125101                } else {
    126102                        $output .= $name;
     
    130106
    131107                $output .= '</a>';
    132108
    133                 if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
    134                         $output .= '</em>';
    135                 }
    136 
    137109                if ( $parsed_args['show_description'] && '' !== $desc ) {
    138110                        $output .= $parsed_args['between'] . $desc;
    139111                }