[buddypress-trac] [BuddyPress Trac] #7226: Update BP_buttons class to accept new arg param for $element_type

buddypress-trac noreply at wordpress.org
Wed Aug 24 18:41:38 UTC 2016


#7226: Update BP_buttons class to accept new arg param for $element_type
-------------------------+------------------
 Reporter:  hnla         |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  2.7
Component:  Core         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------

Comment (by r-a-y):

 @hnla - Can you provide some examples of `bp_get_button()` with your new
 parameters?

 Some code review:

 - The patch looks for `li` as a specific `wrapper` and then you set a new
 property called `li_class`.  If you set `wrapper` to `li`, why do you need
 a `li_class` when there is an existing `wrapper_class`?
 - I think `element` should be renamed to `link_element` to be consistent
 with existing properties like `link_id`, `link_rel`, etc.  You're mixing
 `element` with these `link_*` properties on the `$this->contents` line,
 which made me infer that you want to use these `link_*` properties.


 `BP_Button` is starting to get hard to read.

 What if we did something like this?

 {{{#!php
 <?php
 bp_get_button( array(
         // this replaces 'wrapper'
         'parent_element' => 'div',

         // this replaces all 'wrapper_*' params
         'parent_attr' => array(
                 // whatever attributes you want as key / value
                 'id' => 'my-id',
                 'class' => 'parent-class',
         ),

         // this will be the main button element
         'button_element' => 'a',

         // this replaces all 'link_*' params
         'button_attr' => array(
                 'class' => 'generic-button',

                 // data-attr could also live here
                 'data-attr' => array(
                 )
         ),
 ) );
 }}}


 Of course, we'll add backward compatibility so those older parameters will
 still work.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7226#comment:10>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list