[wp-trac] [WordPress Trac] #35206: Allow theme authors to control white space between menu items

WordPress Trac noreply at wordpress.org
Sun Dec 27 03:13:53 UTC 2015


#35206: Allow theme authors to control white space between menu items
------------------------------------------+------------------------------
 Reporter:  peterwilsoncc                 |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Awaiting Review
Component:  Menus                         |     Version:
 Severity:  normal                        |  Resolution:
 Keywords:  needs-unit-tests needs-patch  |     Focuses:  template
------------------------------------------+------------------------------
Changes (by peterwilsoncc):

 * keywords:  has-patch needs-unit-tests => needs-unit-tests needs-patch


Old description:

> Sometimes menu items are best floated, sometimes they're best as inline-
> blocks. Whitespace between the `li`s can have an affect on layout for the
> later.
>
> Let's allow theme authors to control the white space between menu items:
>
> * remove `\n`, `\r`, `\t` string replacement in wp_page_menu since [9246]
> * Introduce `item_before` and `item_after` arguments to
>   - `wp_nav_menu`
>   - `wp_list_pages`
>   - `wp_page_menu`
> * `item_before` defaults to an empty string
> * for the first two functions `item_after` defaults to a line-break to
> match the current behaviour
> * for `wp_page_menu`, `item_after` defaults to an empty string to match
> the current behaviour
>
> Related #27762 and #35107.
>
> Patch will need to follow the resolution of #35107.

New description:

 Sometimes menu items are best floated, sometimes they're best as inline-
 blocks. Whitespace between the `li`s can have an affect on layout for the
 later.

 Let's allow theme authors to control the white space between menu items:

 * remove `\n`, `\r`, `\t` string replacement in wp_page_menu since [9246]
 * allow theme authors to choose between the markup detailed in comment:2

 Related #27762 and #35107.


 ----


 '''original description'''

 Sometimes menu items are best floated, sometimes they're best as inline-
 blocks. Whitespace between the `li`s can have an affect on layout for the
 later.

 Let's allow theme authors to control the white space between menu items:

 * remove `\n`, `\r`, `\t` string replacement in wp_page_menu since [9246]
 * Introduce `item_before` and `item_after` arguments to
   - `wp_nav_menu`
   - `wp_list_pages`
   - `wp_page_menu`
 * `item_before` defaults to an empty string
 * for the first two functions `item_after` defaults to a line-break to
 match the current behaviour
 * for `wp_page_menu`, `item_after` defaults to an empty string to match
 the current behaviour

 Related #27762 and #35107.

 Patch will need to follow the resolution of #35107.

--

Comment:

 The more I think about the initial approach, the less wise I think it is.

 The desired outcome is allowing theme authors to specify a white-spaced
 and no-white-space version of `wp_nav_menu` and `wp_page_menu`. The output
 code (again using self closing `a` tags to save space) becomes:

 white space
 {{{
 <ul>
         <li><a /></li>
         <li><a />
                 <ul class="sub-menu">
                         <li><a /></li>
                         <li><a /></li>
                 </ul>
         </li>
 </ul>
 }}}

 no white space

 {{{
 <ul><li><a /></li><li><a /><ul class="sub-menu"><li><a /></li><li><a
 /></li></ul></li></ul>
 }}}

 `item_before`, `item_after` don't really work as they leave open the
 possibility of malformed markup. Possible options:

 * `whitespaced`: `true`/`false`
 * `indented`: `true`/`false`

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35206#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list