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:
Gary Pendergast
2017-11-30 23:11:00 +00:00
parent 62be7ad218
commit aaf99e6913
610 changed files with 55731 additions and 43711 deletions

View File

@@ -35,7 +35,10 @@ class Walker_Category extends Walker {
* @see Walker::$db_fields
* @todo Decouple this
*/
public $db_fields = array ('parent' => 'parent', 'id' => 'term_id');
public $db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
);
/**
* Starts the list before the elements are added.
@@ -50,10 +53,11 @@ class Walker_Category extends Walker {
* value is 'list'. See wp_list_categories(). Default empty array.
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
if ( 'list' != $args['style'] )
if ( 'list' != $args['style'] ) {
return;
}
$indent = str_repeat("\t", $depth);
$indent = str_repeat( "\t", $depth );
$output .= "$indent<ul class='children'>\n";
}
@@ -70,10 +74,11 @@ class Walker_Category extends Walker {
* value is 'list'. See wp_list_categories(). Default empty array.
*/
public function end_lvl( &$output, $depth = 0, $args = array() ) {
if ( 'list' != $args['style'] )
if ( 'list' != $args['style'] ) {
return;
}
$indent = str_repeat("\t", $depth);
$indent = str_repeat( "\t", $depth );
$output .= "$indent</ul>\n";
}
@@ -129,10 +134,10 @@ class Walker_Category extends Walker {
$link .= '<a href="' . esc_url( get_term_feed_link( $category->term_id, $category->taxonomy, $args['feed_type'] ) ) . '"';
if ( empty( $args['feed'] ) ) {
$alt = ' alt="' . sprintf(__( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
$alt = ' alt="' . sprintf( __( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
} else {
$alt = ' alt="' . $args['feed'] . '"';
$name = $args['feed'];
$alt = ' alt="' . $args['feed'] . '"';
$name = $args['feed'];
$link .= empty( $args['title'] ) ? '' : $args['title'];
}
@@ -154,7 +159,7 @@ class Walker_Category extends Walker {
$link .= ' (' . number_format_i18n( $category->count ) . ')';
}
if ( 'list' == $args['style'] ) {
$output .= "\t<li";
$output .= "\t<li";
$css_classes = array(
'cat-item',
'cat-item-' . $category->term_id,
@@ -162,10 +167,12 @@ class Walker_Category extends Walker {
if ( ! empty( $args['current_category'] ) ) {
// 'current_category' can be an array, so we use `get_terms()`.
$_current_terms = get_terms( $category->taxonomy, array(
'include' => $args['current_category'],
'hide_empty' => false,
) );
$_current_terms = get_terms(
$category->taxonomy, array(
'include' => $args['current_category'],
'hide_empty' => false,
)
);
foreach ( $_current_terms as $_current_term ) {
if ( $category->term_id == $_current_term->term_id ) {
@@ -175,7 +182,7 @@ class Walker_Category extends Walker {
}
while ( $_current_term->parent ) {
if ( $category->term_id == $_current_term->parent ) {
$css_classes[] = 'current-cat-ancestor';
$css_classes[] = 'current-cat-ancestor';
break;
}
$_current_term = get_term( $_current_term->parent, $category->taxonomy );
@@ -197,7 +204,7 @@ class Walker_Category extends Walker {
*/
$css_classes = implode( ' ', apply_filters( 'category_css_class', $css_classes, $category, $depth, $args ) );
$output .= ' class="' . $css_classes . '"';
$output .= ' class="' . $css_classes . '"';
$output .= ">$link\n";
} elseif ( isset( $args['separator'] ) ) {
$output .= "\t$link" . $args['separator'] . "\n";
@@ -220,8 +227,9 @@ class Walker_Category extends Walker {
* to output. See wp_list_categories(). Default empty array.
*/
public function end_el( &$output, $page, $depth = 0, $args = array() ) {
if ( 'list' != $args['style'] )
if ( 'list' != $args['style'] ) {
return;
}
$output .= "</li>\n";
}