[wp-trac] [WordPress Trac] #34751: Improve the readability of the default arguments of the wp_list_categories()
WordPress Trac
noreply at wordpress.org
Fri Nov 20 10:53:31 UTC 2015
#34751: Improve the readability of the default arguments of the
wp_list_categories()
-------------------------+-----------------------------
Reporter: birgire | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
When skimming through the defaults arguments of some core functions, it's
easy to miss some attributes, because there are multiple arguments per
line.
Here's an example how the default arguments of the
{{{wp_list_categories()}}} are written out:
{{{
$defaults = array(
'show_option_all' => '', 'show_option_none' => __('No
categories'),
'orderby' => 'name', 'order' => 'ASC',
'style' => 'list',
'show_count' => 0, 'hide_empty' => 1,
'use_desc_for_title' => 1, 'child_of' => 0,
'feed' => '', 'feed_type' => '',
'feed_image' => '', 'exclude' => '',
'exclude_tree' => '', 'current_category' => 0,
'hierarchical' => true, 'title_li' => __( 'Categories' ),
'hide_title_if_empty' => false,
'echo' => 1, 'depth' => 0,
'separator' => '<br />',
'taxonomy' => 'category'
);
}}}
I think it would improve readability if we only had a single argument per
line:
{{{
$defaults = array(
'show_option_all' => '',
'show_option_none' => __('No categories'),
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'current_category' => 0,
'hierarchical' => true,
'title_li' => __( 'Categories' ),
'hide_title_if_empty' => false,
'echo' => 1, 'depth' => 0,
'separator' => '<br />',
'taxonomy' => 'category'
);
}}}
Even better to have it alphabetically ordered:
{{{
$defaults = array(
'child_of' => 0,
'current_category' => 0,
'depth' => 0,
'echo' => 1,
'exclude' => '',
'exclude_tree' => '',
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'hide_empty' => 1,
'hide_title_if_empty' => false,
'hierarchical' => true,
'orderby' => 'name',
'order' => 'ASC',
'show_option_all' => '',
'show_option_none' => __('No categories'),
'style' => 'list',
'show_count' => 0,
'separator' => '<br />',
'taxonomy' => 'category'
'title_li' => __( 'Categories' ),
'use_desc_for_title' => 1,
);
}}}
I actually prefer this:
{{{
$defaults = array(
'child_of' => 0,
'current_category' => 0,
'depth' => 0,
'echo' => 1,
'exclude' => '',
'exclude_tree' => '',
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'hide_empty' => 1,
'hide_title_if_empty' => false,
'hierarchical' => true,
'orderby' => 'name',
'order' => 'ASC',
'show_option_all' => '',
'show_option_none' => __('No categories'),
'style' => 'list',
'show_count' => 0,
'separator' => '<br />',
'taxonomy' => 'category'
'title_li' => __( 'Categories' ),
'use_desc_for_title' => 1,
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34751>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list