Skip to:
Content

BuddyPress.org

Changeset 8192


Ignore:
Timestamp:
03/28/2014 11:14:15 PM (10 years ago)
Author:
r-a-y
Message:

Introduce bp_activity_admin_get_activity_actions().

This function walks through all currently registered activity actions
and returns a flattened array of the activity actions.

Format returned is:

Array(

'activity_update' => 'Posted a new status update',
...

)

See #5484

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-admin.php

    r8085 r8192  
    459459        // Activity type
    460460        if ( ! empty( $_POST['bp-activities-type'] ) ) {
    461             $actions  = array();
    462 
    463             // Walk through the registered actions, and build an array of actions/values.
    464             foreach ( $bp->activity->actions as $action ) {
    465                 $action = array_values( (array) $action );
    466 
    467                 for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ )
    468                     $actions[] = $action[$i]['key'];
     461            $actions = bp_activity_admin_get_activity_actions();
     462
     463            // Check that the new type is a registered activity type
     464            if ( in_array( $_POST['bp-activities-type'], $actions ) ) {
     465                $activity->type = $_POST['bp-activities-type'];
    469466            }
    470 
    471             // This was a mis-named activity type from before BP 1.6
    472             unset( $actions['friends_register_activity_action'] );
    473 
    474             // Check that the new type is a registered activity type
    475             if ( in_array( $_POST['bp-activities-type'], $actions ) )
    476                 $activity->type = $_POST['bp-activities-type'];
    477467        }
    478468
     
    737727
    738728/**
     729 * Get flattened array of all registered activity actions.
     730 *
     731 * Format is [activity_type] => Pretty name for activity type.
     732 *
     733 * @since BuddyPress (2.0.0)
     734 *
     735 * @return array
     736 */
     737function bp_activity_admin_get_activity_actions() {
     738    $actions  = array();
     739
     740    // Walk through the registered actions, and build an array of actions/values.
     741    foreach ( buddypress()->activity->actions as $action ) {
     742        $action = array_values( (array) $action );
     743
     744        for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) {
     745            $actions[ $action[$i]['key'] ] = $action[$i]['value'];
     746        }
     747    }
     748
     749    // This was a mis-named activity type from before BP 1.6
     750    unset( $actions['friends_register_activity_action'] );
     751
     752    // Sort array by the human-readable value
     753    natsort( $actions );
     754
     755    return $actions;
     756}
     757
     758/**
    739759 * Activity type metabox for the Activity admin edit screen
    740760 *
Note: See TracChangeset for help on using the changeset viewer.