[buddypress-trac] [BuddyPress Trac] #8716: bp_nouveau_get_activity_entry_buttons not targeting given $activity_id

buddypress-trac noreply at wordpress.org
Tue Jul 5 12:36:38 UTC 2022


#8716: bp_nouveau_get_activity_entry_buttons not targeting given $activity_id
----------------------------+-----------------------------
 Reporter:  bouncingsprout  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Activity        |    Version:
 Severity:  normal          |   Keywords:
----------------------------+-----------------------------
 When we filter on bp_nouveau_get_activity_entry_buttons, I would expect
 the activity ID passed to be usable, so we can offer a bespoke button for
 a particular activity, or set of activities.

 Thus, I would expect the following code to add a button only where the
 activity ID is 575:
 {{{#!php
 <?php
 add_filter( 'bp_nouveau_get_activity_entry_buttons', 'add_button', 999, 2
 );
 function add_button( $buttons, $activity_id ) {
         echo 'This is activity ID: ' . bp_get_activity_id();
         if ( $activity_id == '575' ) {

                 $buttons['new'] = array(
                         'id'          => 'new',
                         'component'   => 'activity',
                         'button_attr' => array(
                                 'data-id'    => bp_get_activity_id(),
                         ),
                         'link_text'   => sprintf(
                                 '<span>%1$s</span>',
                                 'Shouldn\'t exist more than once, so we
 can test against activity ID each time',
                         ),
                 );

                 return $buttons;
         } else {
                 return $buttons;
         }
 }
 }}}

 The button correctly appears on activity 575, but then also for each
 activity afterwards. Worse, the data-id attribute is permanently 575,
 meaning no actions can be taken on that activity, using that method (for
 instance, via ajax).

 Screenshot attached of the result. Clean install of BuddyPress, default
 theme.

 If this ''is'' expected behaviour, there may be some scope to clear up why
 we are passing an unusable activity ID in comments/docs.

 Thanks everyone!

 Ben Roberts

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8716>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list