Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. Built from https://develop.svn.wordpress.org/trunk@42343 git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -50,10 +50,16 @@
|
||||
*/
|
||||
function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
$defaults = array(
|
||||
'show_updated' => 0, 'show_description' => 0,
|
||||
'show_images' => 1, 'show_name' => 0,
|
||||
'before' => '<li>', 'after' => '</li>', 'between' => "\n",
|
||||
'show_rating' => 0, 'link_before' => '', 'link_after' => ''
|
||||
'show_updated' => 0,
|
||||
'show_description' => 0,
|
||||
'show_images' => 1,
|
||||
'show_name' => 0,
|
||||
'before' => '<li>',
|
||||
'after' => '</li>',
|
||||
'between' => "\n",
|
||||
'show_rating' => 0,
|
||||
'link_before' => '',
|
||||
'link_after' => '',
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
@@ -72,15 +78,15 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
if ( ! empty( $bookmark->link_url ) ) {
|
||||
$the_link = esc_url( $bookmark->link_url );
|
||||
}
|
||||
$desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) );
|
||||
$name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) );
|
||||
$title = $desc;
|
||||
$desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) );
|
||||
$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 ) ) {
|
||||
$title .= ' (';
|
||||
$title .= sprintf(
|
||||
__('Last updated: %s'),
|
||||
__( 'Last updated: %s' ),
|
||||
date(
|
||||
get_option( 'links_updated_date_format' ),
|
||||
$bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
|
||||
@@ -96,7 +102,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
}
|
||||
$rel = $bookmark->link_rel;
|
||||
if ( '' != $rel ) {
|
||||
$rel = ' rel="' . esc_attr($rel) . '"';
|
||||
$rel = ' rel="' . esc_attr( $rel ) . '"';
|
||||
}
|
||||
$target = $bookmark->link_target;
|
||||
if ( '' != $target ) {
|
||||
@@ -110,7 +116,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
if ( strpos( $bookmark->link_image, 'http' ) === 0 ) {
|
||||
$output .= "<img src=\"$bookmark->link_image\" $alt $title />";
|
||||
} else { // If it's a relative path
|
||||
$output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />";
|
||||
$output .= '<img src="' . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />";
|
||||
}
|
||||
if ( $r['show_name'] ) {
|
||||
$output .= " $name";
|
||||
@@ -199,15 +205,24 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||
*/
|
||||
function wp_list_bookmarks( $args = '' ) {
|
||||
$defaults = array(
|
||||
'orderby' => 'name', 'order' => 'ASC',
|
||||
'limit' => -1, 'category' => '', 'exclude_category' => '',
|
||||
'category_name' => '', 'hide_invisible' => 1,
|
||||
'show_updated' => 0, 'echo' => 1,
|
||||
'categorize' => 1, 'title_li' => __('Bookmarks'),
|
||||
'title_before' => '<h2>', 'title_after' => '</h2>',
|
||||
'category_orderby' => 'name', 'category_order' => 'ASC',
|
||||
'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
|
||||
'category_after' => '</li>'
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
'limit' => -1,
|
||||
'category' => '',
|
||||
'exclude_category' => '',
|
||||
'category_name' => '',
|
||||
'hide_invisible' => 1,
|
||||
'show_updated' => 0,
|
||||
'echo' => 1,
|
||||
'categorize' => 1,
|
||||
'title_li' => __( 'Bookmarks' ),
|
||||
'title_before' => '<h2>',
|
||||
'title_after' => '</h2>',
|
||||
'category_orderby' => 'name',
|
||||
'category_order' => 'ASC',
|
||||
'class' => 'linkcat',
|
||||
'category_before' => '<li id="%id" class="%class">',
|
||||
'category_after' => '</li>',
|
||||
);
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
@@ -217,18 +232,20 @@ function wp_list_bookmarks( $args = '' ) {
|
||||
if ( ! is_array( $r['class'] ) ) {
|
||||
$r['class'] = explode( ' ', $r['class'] );
|
||||
}
|
||||
$r['class'] = array_map( 'sanitize_html_class', $r['class'] );
|
||||
$r['class'] = trim( join( ' ', $r['class'] ) );
|
||||
$r['class'] = array_map( 'sanitize_html_class', $r['class'] );
|
||||
$r['class'] = trim( join( ' ', $r['class'] ) );
|
||||
|
||||
if ( $r['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'],
|
||||
'hierarchical' => 0
|
||||
) );
|
||||
$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'],
|
||||
'hierarchical' => 0,
|
||||
)
|
||||
);
|
||||
if ( empty( $cats ) ) {
|
||||
$r['categorize'] = false;
|
||||
}
|
||||
@@ -237,7 +254,7 @@ function wp_list_bookmarks( $args = '' ) {
|
||||
if ( $r['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( $r, array( 'category' => $cat->term_id ) );
|
||||
$bookmarks = get_bookmarks( $params );
|
||||
if ( empty( $bookmarks ) ) {
|
||||
continue;
|
||||
@@ -272,7 +289,7 @@ function wp_list_bookmarks( $args = '' ) {
|
||||
if ( ! empty( $r['title_li'] ) ) {
|
||||
$output .= str_replace(
|
||||
array( '%id', '%class' ),
|
||||
array( "linkcat-" . $r['category'], $r['class'] ),
|
||||
array( 'linkcat-' . $r['category'], $r['class'] ),
|
||||
$r['category_before']
|
||||
);
|
||||
$output .= $r['title_before'];
|
||||
|
||||
Reference in New Issue
Block a user