--- a/wp/wp-includes/bookmark-template.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/bookmark-template.php Tue Dec 15 13:49:49 2020 +0100
@@ -22,7 +22,7 @@
* @since 2.1.0
* @access private
*
- * @param array $bookmarks List of bookmarks to traverse.
+ * @param array $bookmarks List of bookmarks to traverse.
* @param string|array $args {
* Optional. Bookmarks arguments.
*
@@ -62,7 +62,7 @@
'link_after' => '',
);
- $r = wp_parse_args( $args, $defaults );
+ $parsed_args = wp_parse_args( $args, $defaults );
$output = ''; // Blank string to start with.
@@ -70,8 +70,8 @@
if ( ! isset( $bookmark->recently_updated ) ) {
$bookmark->recently_updated = false;
}
- $output .= $r['before'];
- if ( $r['show_updated'] && $bookmark->recently_updated ) {
+ $output .= $parsed_args['before'];
+ if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
$output .= '<em>';
}
$the_link = '#';
@@ -82,12 +82,13 @@
$name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
$title = $desc;
- if ( $r['show_updated'] ) {
- if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) {
+ if ( $parsed_args['show_updated'] ) {
+ if ( '00' !== substr( $bookmark->link_updated_f, 0, 2 ) ) {
$title .= ' (';
$title .= sprintf(
+ /* translators: %s: Date and time of last update. */
__( 'Last updated: %s' ),
- date(
+ gmdate(
get_option( 'links_updated_date_format' ),
$bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
)
@@ -95,58 +96,58 @@
$title .= ')';
}
}
- $alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"';
+ $alt = ' alt="' . $name . ( $parsed_args['show_description'] ? ' ' . $title : '' ) . '"';
- if ( '' != $title ) {
+ if ( '' !== $title ) {
$title = ' title="' . $title . '"';
}
$rel = $bookmark->link_rel;
- if ( '' != $rel ) {
+ if ( '' !== $rel ) {
$rel = ' rel="' . esc_attr( $rel ) . '"';
}
$target = $bookmark->link_target;
- if ( '' != $target ) {
+ if ( '' !== $target ) {
$target = ' target="' . $target . '"';
}
$output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>';
- $output .= $r['link_before'];
+ $output .= $parsed_args['link_before'];
- if ( $bookmark->link_image != null && $r['show_images'] ) {
+ if ( null != $bookmark->link_image && $parsed_args['show_images'] ) {
if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
- } else { // If it's a relative path
+ } else { // If it's a relative path.
$output .= '<img src="' . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />";
}
- if ( $r['show_name'] ) {
+ if ( $parsed_args['show_name'] ) {
$output .= " $name";
}
} else {
$output .= $name;
}
- $output .= $r['link_after'];
+ $output .= $parsed_args['link_after'];
$output .= '</a>';
- if ( $r['show_updated'] && $bookmark->recently_updated ) {
+ if ( $parsed_args['show_updated'] && $bookmark->recently_updated ) {
$output .= '</em>';
}
- if ( $r['show_description'] && '' != $desc ) {
- $output .= $r['between'] . $desc;
+ if ( $parsed_args['show_description'] && '' !== $desc ) {
+ $output .= $parsed_args['between'] . $desc;
}
- if ( $r['show_rating'] ) {
- $output .= $r['between'] . sanitize_bookmark_field(
+ if ( $parsed_args['show_rating'] ) {
+ $output .= $parsed_args['between'] . sanitize_bookmark_field(
'link_rating',
$bookmark->link_rating,
$bookmark->link_id,
'display'
);
}
- $output .= $r['after'] . "\n";
- } // end while
+ $output .= $parsed_args['after'] . "\n";
+ } // End while.
return $output;
}
@@ -172,7 +173,7 @@
* Accepts 'ASC' (ascending) or 'DESC' (descending). Default 'ASC'.
* @type int $limit Amount of bookmarks to display. Accepts 1+ or -1 for all.
* Default -1.
- * @type string $category Comma-separated list of category ids to include links from.
+ * @type string $category Comma-separated list of category IDs to include links from.
* Default empty.
* @type string $category_name Category to retrieve links for by name. Default empty.
* @type int|bool $hide_invisible Whether to show or hide links marked as 'invisible'. Accepts
@@ -201,7 +202,7 @@
* $categorize is true. Accepts 'ASC' (ascending) or 'DESC' (descending).
* Default 'ASC'.
* }
- * @return string|void Will only return if echo option is set to not echo. Default is not return anything.
+ * @return void|string Void if 'echo' argument is true, HTML list of bookmarks if 'echo' is false.
*/
function wp_list_bookmarks( $args = '' ) {
$defaults = array(
@@ -225,45 +226,45 @@
'category_after' => '</li>',
);
- $r = wp_parse_args( $args, $defaults );
+ $parsed_args = wp_parse_args( $args, $defaults );
$output = '';
- if ( ! is_array( $r['class'] ) ) {
- $r['class'] = explode( ' ', $r['class'] );
+ if ( ! is_array( $parsed_args['class'] ) ) {
+ $parsed_args['class'] = explode( ' ', $parsed_args['class'] );
}
- $r['class'] = array_map( 'sanitize_html_class', $r['class'] );
- $r['class'] = trim( join( ' ', $r['class'] ) );
+ $parsed_args['class'] = array_map( 'sanitize_html_class', $parsed_args['class'] );
+ $parsed_args['class'] = trim( join( ' ', $parsed_args['class'] ) );
- if ( $r['categorize'] ) {
+ if ( $parsed_args['categorize'] ) {
$cats = get_terms(
- 'link_category',
array(
- 'name__like' => $r['category_name'],
- 'include' => $r['category'],
- 'exclude' => $r['exclude_category'],
- 'orderby' => $r['category_orderby'],
- 'order' => $r['category_order'],
+ 'taxonomy' => 'link_category',
+ 'name__like' => $parsed_args['category_name'],
+ 'include' => $parsed_args['category'],
+ 'exclude' => $parsed_args['exclude_category'],
+ 'orderby' => $parsed_args['category_orderby'],
+ 'order' => $parsed_args['category_order'],
'hierarchical' => 0,
)
);
if ( empty( $cats ) ) {
- $r['categorize'] = false;
+ $parsed_args['categorize'] = false;
}
}
- if ( $r['categorize'] ) {
- // Split the bookmarks into ul's for each category
+ if ( $parsed_args['categorize'] ) {
+ // Split the bookmarks into ul's for each category.
foreach ( (array) $cats as $cat ) {
- $params = array_merge( $r, array( 'category' => $cat->term_id ) );
+ $params = array_merge( $parsed_args, array( 'category' => $cat->term_id ) );
$bookmarks = get_bookmarks( $params );
if ( empty( $bookmarks ) ) {
continue;
}
$output .= str_replace(
array( '%id', '%class' ),
- array( "linkcat-$cat->term_id", $r['class'] ),
- $r['category_before']
+ array( "linkcat-$cat->term_id", $parsed_args['class'] ),
+ $parsed_args['category_before']
);
/**
* Filters the category name.
@@ -274,34 +275,34 @@
*/
$catname = apply_filters( 'link_category', $cat->name );
- $output .= $r['title_before'];
+ $output .= $parsed_args['title_before'];
$output .= $catname;
- $output .= $r['title_after'];
+ $output .= $parsed_args['title_after'];
$output .= "\n\t<ul class='xoxo blogroll'>\n";
- $output .= _walk_bookmarks( $bookmarks, $r );
+ $output .= _walk_bookmarks( $bookmarks, $parsed_args );
$output .= "\n\t</ul>\n";
- $output .= $r['category_after'] . "\n";
+ $output .= $parsed_args['category_after'] . "\n";
}
} else {
- //output one single list using title_li for the title
- $bookmarks = get_bookmarks( $r );
+ // Output one single list using title_li for the title.
+ $bookmarks = get_bookmarks( $parsed_args );
if ( ! empty( $bookmarks ) ) {
- if ( ! empty( $r['title_li'] ) ) {
+ if ( ! empty( $parsed_args['title_li'] ) ) {
$output .= str_replace(
array( '%id', '%class' ),
- array( 'linkcat-' . $r['category'], $r['class'] ),
- $r['category_before']
+ array( 'linkcat-' . $parsed_args['category'], $parsed_args['class'] ),
+ $parsed_args['category_before']
);
- $output .= $r['title_before'];
- $output .= $r['title_li'];
- $output .= $r['title_after'];
+ $output .= $parsed_args['title_before'];
+ $output .= $parsed_args['title_li'];
+ $output .= $parsed_args['title_after'];
$output .= "\n\t<ul class='xoxo blogroll'>\n";
- $output .= _walk_bookmarks( $bookmarks, $r );
+ $output .= _walk_bookmarks( $bookmarks, $parsed_args );
$output .= "\n\t</ul>\n";
- $output .= $r['category_after'] . "\n";
+ $output .= $parsed_args['category_after'] . "\n";
} else {
- $output .= _walk_bookmarks( $bookmarks, $r );
+ $output .= _walk_bookmarks( $bookmarks, $parsed_args );
}
}
}
@@ -315,8 +316,9 @@
*/
$html = apply_filters( 'wp_list_bookmarks', $output );
- if ( ! $r['echo'] ) {
+ if ( $parsed_args['echo'] ) {
+ echo $html;
+ } else {
return $html;
}
- echo $html;
}