bp_ap_rtmedia_add_edit_fields

The BuddyPress Activity Privacy bp ap rtmedia add edit fields function.

Description

bp_ap_rtmedia_add_edit_fields(); 

Usage

  1. if ( !function_exists( 'bp_ap_rtmedia_add_edit_fields' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-activity-privacy/includes/bp-activity-privacy-integrations.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_ap_rtmedia_add_edit_fields(); 
  7.  

Defined (1)

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

/includes/bp-activity-privacy-integrations.php  
  1. function bp_ap_rtmedia_add_edit_fields() { 
  2. global $bp, $rtmedia_query, $rtmedia_media; 
  3.  
  4. if ( isset($rtmedia_media) ) { 
  5. $activity_id = $rtmedia_media->activity_id; 
  6. /** 
  7. if ( isset( $rtmedia_query->query[ 'context' ] ) && $rtmedia_query->query[ 'context' ] == 'group' ) { 
  8. //if context is group i.e editing a group media, dont show the privacy dropdown 
  9. // group media 
  10. } else { 
  11. // profile media 
  12. */ 
  13.  
  14. $visibility = bp_activity_get_meta( $activity_id, 'activity-privacy' ); 
  15.  
  16. global $bp_activity_privacy; 
  17.  
  18. if ($rtmedia_media->context == 'group') 
  19. $group_id = $rtmedia_media->context_id; 
  20. else  
  21. $group_id = null; 
  22.  
  23. //if is not a group activity or a new blog post 
  24. if( !isset( $group_id ) ) 
  25. $visibility_levels = bp_get_profile_activity_visibility_levels();  
  26. else 
  27. $visibility_levels = bp_get_groups_activity_visibility_levels(); 
  28.  
  29. //sort visibility_levels by position  
  30. uasort ($visibility_levels, 'bp_activity_privacy_cmp_position'); 
  31.  
  32. $html = '<select class="bp-ap-media-selectbox" name="visibility" >'; 
  33. foreach ($visibility_levels as $visibility_level) { 
  34. if( $visibility_level["disabled"] ) 
  35. continue; 
  36. $html .= '<option class="" ' . ( $visibility_level['id'] == $visibility ? " selected='selected'" : '' ) . ' value="' . $visibility_level["id"] . '">' . $visibility_level["label"] . '</option>'; 
  37. $html .= '</select>'; 
  38.  
  39. $html = apply_filters( 'bp_get_update_activitiy_visibility_selectbox', $html ); 
  40.  
  41. echo "<div class=''><label for='privacy'>" . __( 'Privacy : ', 'rtmedia' ) . "</label> " . $html . " </div>"; 
  42.