Eliminate use of `extract()` in `wp_list_bookmarks()`.
See #22400. Built from https://develop.svn.wordpress.org/trunk@28405 git-svn-id: http://core.svn.wordpress.org/trunk@28232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
748765c5ad
commit
9d6eeca015
|
@ -138,7 +138,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||||
'display'
|
'display'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$output .= $r['$after'] . "\n";
|
$output .= $r['after'] . "\n";
|
||||||
} // end while
|
} // end while
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
@ -210,7 +210,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
|
||||||
* @return string|null Will only return if echo option is set to not echo.
|
* @return string|null Will only return if echo option is set to not echo.
|
||||||
* Default is not return anything.
|
* Default is not return anything.
|
||||||
*/
|
*/
|
||||||
function wp_list_bookmarks($args = '') {
|
function wp_list_bookmarks( $args = '' ) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'orderby' => 'name', 'order' => 'ASC',
|
'orderby' => 'name', 'order' => 'ASC',
|
||||||
'limit' => -1, 'category' => '', 'exclude_category' => '',
|
'limit' => -1, 'category' => '', 'exclude_category' => '',
|
||||||
|
@ -224,24 +224,36 @@ function wp_list_bookmarks($args = '') {
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
extract( $r, EXTR_SKIP );
|
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if ( $categorize ) {
|
if ( $r['categorize'] ) {
|
||||||
$cats = get_terms( 'link_category', array( 'name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0 ) );
|
$cats = get_terms( 'link_category', array(
|
||||||
if ( empty( $cats ) )
|
'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 ) ) {
|
||||||
$categorize = false;
|
$categorize = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $categorize ) {
|
if ( $categorize ) {
|
||||||
// Split the bookmarks into ul's for each category
|
// Split the bookmarks into ul's for each category
|
||||||
foreach ( (array) $cats as $cat ) {
|
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);
|
$bookmarks = get_bookmarks( $params );
|
||||||
if ( empty($bookmarks) )
|
if ( empty( $bookmarks ) ) {
|
||||||
continue;
|
continue;
|
||||||
$output .= str_replace(array('%id', '%class'), array("linkcat-$cat->term_id", $class), $category_before);
|
}
|
||||||
|
$output .= str_replace(
|
||||||
|
array( '%id', '%class' ),
|
||||||
|
array( "linkcat-$cat->term_id", $r['class'] ),
|
||||||
|
$r['category_before']
|
||||||
|
);
|
||||||
/**
|
/**
|
||||||
* Filter the bookmarks category name.
|
* Filter the bookmarks category name.
|
||||||
*
|
*
|
||||||
|
@ -251,22 +263,34 @@ function wp_list_bookmarks($args = '') {
|
||||||
*/
|
*/
|
||||||
$catname = apply_filters( 'link_category', $cat->name );
|
$catname = apply_filters( 'link_category', $cat->name );
|
||||||
|
|
||||||
$output .= "$title_before$catname$title_after\n\t<ul class='xoxo blogroll'>\n";
|
$output .= $r['title_before'];
|
||||||
$output .= _walk_bookmarks($bookmarks, $r);
|
$output .= $catname;
|
||||||
$output .= "\n\t</ul>\n$category_after\n";
|
$output .= $r['title_after'];
|
||||||
|
$output .= "\n\t<ul class='xoxo blogroll'>\n";
|
||||||
|
$output .= _walk_bookmarks( $bookmarks, $r );
|
||||||
|
$output .= "\n\t</ul>\n";
|
||||||
|
$output .= $r['category_after'] . "\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//output one single list using title_li for the title
|
//output one single list using title_li for the title
|
||||||
$bookmarks = get_bookmarks($r);
|
$bookmarks = get_bookmarks( $r );
|
||||||
|
|
||||||
if ( !empty($bookmarks) ) {
|
if ( ! empty( $bookmarks ) ) {
|
||||||
if ( !empty( $title_li ) ){
|
if ( ! empty( $r['title_li'] ) ) {
|
||||||
$output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);
|
$output .= str_replace(
|
||||||
$output .= "$title_before$title_li$title_after\n\t<ul class='xoxo blogroll'>\n";
|
array( '%id', '%class' ),
|
||||||
$output .= _walk_bookmarks($bookmarks, $r);
|
array( "linkcat-" . $r['category'], $r['class'] ),
|
||||||
$output .= "\n\t</ul>\n$category_after\n";
|
$r['category_before']
|
||||||
|
);
|
||||||
|
$output .= $r['title_before'];
|
||||||
|
$output .= $r['title_li'];
|
||||||
|
$output .= $r['title_after'];
|
||||||
|
$output .= "\n\t<ul class='xoxo blogroll'>\n";
|
||||||
|
$output .= _walk_bookmarks( $bookmarks, $r );
|
||||||
|
$output .= "\n\t</ul>\n";
|
||||||
|
$output .= $r['category_after'] . "\n";
|
||||||
} else {
|
} else {
|
||||||
$output .= _walk_bookmarks($bookmarks, $r);
|
$output .= _walk_bookmarks( $bookmarks, $r );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,11 +300,12 @@ function wp_list_bookmarks($args = '') {
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*
|
*
|
||||||
* @param string $output The HTML list of bookmarks.
|
* @param string $html The HTML list of bookmarks.
|
||||||
*/
|
*/
|
||||||
$output = apply_filters( 'wp_list_bookmarks', $output );
|
$html = apply_filters( 'wp_list_bookmarks', $output );
|
||||||
|
|
||||||
if ( !$echo )
|
if ( ! $r['echo'] ) {
|
||||||
return $output;
|
return $html;
|
||||||
echo $output;
|
}
|
||||||
|
echo $html;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue