[buddypress-trac] [BuddyPress Trac] #7218: Only load component action and screen code when we're on the component's page

buddypress-trac noreply at wordpress.org
Tue Dec 12 04:15:03 UTC 2017


#7218: Only load component action and screen code when we're on the component's
page
-----------------------------+-----------------------
 Reporter:  r-a-y            |       Owner:
     Type:  enhancement      |      Status:  reopened
 Priority:  normal           |   Milestone:  3.0
Component:  Core             |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch early  |
-----------------------------+-----------------------

Comment (by r-a-y):

 No Git branch I'm afraid.  I've been waiting for things to die down on the
 bp-forums retirement front before refreshing my patches and looking into
 this some more.

 About the proposed new class changes, perhaps you can provide a code
 sample on how you see things structured.

 Are you thinking something like:

 {{{#!php
 <?php
 // sample new action class
 class BP_Activity_Action_Delete {
         // intentional, empty constructor
         protected function __construct() {}

         // static init
         public static function do( $activity_id ) {
                 return $whatever;
         }
 }

 // In bp-activity-actions.php, we'd call on the action class here
 function bp_activity_action_delete_activity( $activity_id = 0 ) {

         // Not viewing activity or action is not delete.
         if ( ! bp_is_activity_component() || ! bp_is_current_action(
 'delete' ) ) {
                 return false;
         }

         if ( empty( $activity_id ) && bp_action_variable( 0 ) ) {
                 $activity_id = (int) bp_action_variable( 0 );
         }

         // Not viewing a specific activity item.
         if ( empty( $activity_id ) ) {
                 return false;
         }

         return BP_Activity_Action_Delete::do( $activity_id );
 }
 add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
 }}}

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


More information about the buddypress-trac mailing list