bp_activity_admin_edit_metabox_type

Activity type metabox for the Activity admin edit screen.

Description

bp_activity_admin_edit_metabox_type( (object) $item ); 

Parameters (1)

0. $item (object)
Activity item.

Usage

  1. if ( !function_exists( 'bp_activity_admin_edit_metabox_type' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-admin.php'; 
  3.  
  4. // Activity item. 
  5. $item = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_activity_admin_edit_metabox_type($item); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-admin.php  
  1. function bp_activity_admin_edit_metabox_type( $item ) { 
  2. $bp =buddypress); 
  3.  
  4. $actions = array(); 
  5. $selected = $item->type; 
  6.  
  7. // Walk through the registered actions, and build an array of actions/values. 
  8. foreach ( bp_activity_get_actions() as $action ) { 
  9. $action = array_values( (array) $action ); 
  10.  
  11. for ( $i = 0, $i_count = count( $action ); $i < $i_count; $i++ ) 
  12. $actions[ $action[$i]['key'] ] = $action[$i]['value']; 
  13.  
  14. // This was a mis-named activity type from before BP 1.6. 
  15. unset( $actions['friends_register_activity_action'] ); 
  16.  
  17. // Sort array by the human-readable value. 
  18. natsort( $actions ); 
  19.  
  20. /** 
  21. * If the activity type is not registered properly (eg, a plugin has 
  22. * not called bp_activity_set_action()), add the raw type to the end 
  23. * of the list. 
  24. */ 
  25. if ( ! isset( $actions[ $selected ] ) ) { 
  26. _doing_it_wrong( __FUNCTION__, sprintf( __( 'This activity item has a type (%s) that is not registered using bp_activity_set_action(), so no label is available.', buddypress ), $selected ), '2.0.0' ); 
  27. $actions[ $selected ] = $selected; 
  28.  
  29. ?> 
  30.  
  31. <label for="bp-activities-type" class="screen-reader-text"><?php 
  32. /** translators: accessibility text */ 
  33. esc_html_e( 'Select activity type', buddypress ); 
  34. ?></label> 
  35. <select name="bp-activities-type" id="bp-activities-type"> 
  36. <?php foreach ( $actions as $k => $v ) : ?> 
  37. <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $k, $selected ); ?>><?php echo esc_html( $v ); ?></option> 
  38. <?php endforeach; ?> 
  39. </select> 
  40.  
  41. <?php