bp_docs_doc_associated_group_markup

Outputs the markup for the Associated Group settings section.

Description

bp_docs_doc_associated_group_markup(); 

Usage

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

Defined (1)

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

/includes/templatetags.php  
  1. function bp_docs_doc_associated_group_markup() { 
  2. global $groups_template; 
  3.  
  4. $old_gt = $groups_template; 
  5.  
  6. // First, try to set the preselected group by looking at the URL params 
  7. $selected_group_slug = isset( $_GET['group'] ) ? $_GET['group'] : ''; 
  8.  
  9. // Support for BP Group Hierarchy 
  10. if ( false !== $slash = strrpos( $selected_group_slug, '/' ) ) { 
  11. $selected_group_slug = substr( $selected_group_slug, $slash + 1 ); 
  12.  
  13. $selected_group = BP_Groups_Group::get_id_from_slug( $selected_group_slug ); 
  14. if ( $selected_group && ! current_user_can( 'bp_docs_associate_with_group', $selected_group ) ) { 
  15. $selected_group = 0; 
  16.  
  17. // If the selected group is still 0, see if there's something in the db 
  18. if ( ! $selected_group && is_singular() ) { 
  19. $selected_group = bp_docs_get_associated_group_id( get_the_ID() ); 
  20.  
  21. // Last check: if this is a second attempt at a newly created Doc,  
  22. // there may be a previously submitted value 
  23. if ( empty( $selected_group ) && ! empty( buddypress()->bp_docs->submitted_data->associated_group_id ) ) { 
  24. $selected_group = buddypress()->bp_docs->submitted_data->associated_group_id; 
  25.  
  26. $selected_group = intval( $selected_group ); 
  27.  
  28. ?> 
  29. <tr> 
  30. <td class="desc-column"> 
  31. <label for="associated_group_id"><?php _e( 'Which group should this Doc be associated with?', 'bp-docs' ) ?></label> 
  32. <span class="description"><?php _e( '(Optional) Note that the Access settings available for this Doc may be limited by the privacy settings of the group you choose.', 'bp-docs' ) ?></span> 
  33. </td> 
  34.  
  35. <td class="content-column"> 
  36. 'name' => 'associated_group_id',  
  37. 'id' => 'associated_group_id',  
  38. 'selected' => $selected_group,  
  39. ) ) ?> 
  40.  
  41. <div id="associated_group_summary"> 
  42. </div> 
  43. </td> 
  44. </tr> 
  45. <?php 
  46.  
  47. $groups_template = $old_gt;