bp_docs_access_options_helper

The BuddyPress Docs bp docs access options helper function.

Description

bp_docs_access_options_helper( $settings_field, (int) $doc_id = 0, (int) $group_id = 0 ); 

Parameters (3)

0. $settings_field
The settings field.
1. $doc_id — Optional. (int)
The doc id.
2. $group_id — Optional. (int)
The group id.

Usage

  1. if ( !function_exists( 'bp_docs_access_options_helper' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-docs/includes/templatetags.php'; 
  3.  
  4. // The settings field. 
  5. $settings_field = null; 
  6.  
  7. // The doc id. 
  8. $doc_id = -1; 
  9.  
  10. // The group id. 
  11. $group_id = -1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_docs_access_options_helper($settings_field, $doc_id, $group_id); 
  15.  

Defined (1)

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

/includes/templatetags.php  
  1. function bp_docs_access_options_helper( $settings_field, $doc_id = 0, $group_id = 0 ) { 
  2. if ( $group_id ) { 
  3. $settings_type = 'raw'; 
  4. } else { 
  5. $settings_type = 'default'; 
  6.  
  7. $doc_settings = bp_docs_get_doc_settings( $doc_id, $settings_type, $group_id ); 
  8.  
  9. // If this is a failed form submission, check the submitted values first 
  10. if ( ! empty( buddypress()->bp_docs->submitted_data->settings->{$settings_field['name']} ) ) { 
  11. $setting = buddypress()->bp_docs->submitted_data->settings->{$settings_field['name']}; 
  12. } else { 
  13. $setting = isset( $doc_settings[ $settings_field['name'] ] ) ? $doc_settings[ $settings_field['name'] ] : ''; 
  14.  
  15. ?> 
  16. <tr class="bp-docs-access-row bp-docs-access-row-<?php echo esc_attr( $settings_field['name'] ) ?>"> 
  17. <td class="desc-column"> 
  18. <label for="settings-<?php echo esc_attr( $settings_field['name'] ) ?>"><?php echo esc_html( $settings_field['label'] ) ?></label> 
  19. </td> 
  20.  
  21. <td class="content-column"> 
  22. <select name="settings[<?php echo esc_attr( $settings_field['name'] ) ?>]" id="settings-<?php echo esc_attr( $settings_field['name'] ) ?>"> 
  23. <?php $access_options = bp_docs_get_access_options( $settings_field['name'], $doc_id, $group_id ) ?> 
  24. <?php foreach ( $access_options as $key => $option ) : ?> 
  25. <?php 
  26. $selected = selected( $setting, $option['name'], false ); 
  27. if ( empty( $setting ) && ! empty( $option['default'] ) ) { 
  28. $selected = selected( 1, 1, false ); 
  29. ?> 
  30. <option value="<?php echo esc_attr( $option['name'] ) ?>" <?php echo $selected ?>><?php echo esc_attr( $option['label'] ) ?></option> 
  31. <?php endforeach ?> 
  32. </select> 
  33. </td> 
  34. </tr> 
  35.  
  36. <?php