rcp_bbp_render_meta_box

The Restrict Content Pro - bbPress rcp bbp render meta box function.

Description

rcp_bbp_render_meta_box(); 

Usage

  1. if ( !function_exists( 'rcp_bbp_render_meta_box' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'restrict-content-pro-bbpress/includes/metaboxes.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rcp_bbp_render_meta_box(); 
  7.  

Defined (1)

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

/includes/metaboxes.php  
  1. function rcp_bbp_render_meta_box() { 
  2.  
  3. global $post; 
  4.  
  5. echo '<input type="hidden" name="rcpb_meta_box" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />'; 
  6.  
  7. echo '<table class="form-table">'; 
  8.  
  9. foreach ( rcp_bbp_get_metabox_fields() as $field ) { 
  10.  
  11. // get current post meta data 
  12. $meta = get_post_meta( $post->ID, $field['id'], true ); 
  13.  
  14. echo '<div>'; 
  15. echo '<p><strong>' . $field['name'] . '</strong></p>'; 
  16.  
  17. switch ( $field['type'] ) { 
  18. case 'checkbox': 
  19.  
  20. echo '<input type="checkbox" value="1" name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '"' . checked( $meta, 1, false ) . '/> '; 
  21. break; 
  22.  
  23. case 'select': 
  24.  
  25. echo '<select name="', $field['id'], '" id="', $field['id'], '">'; 
  26. foreach ( $field['options'] as $option ) { 
  27. echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>'; 
  28. echo '</select><br/>'; 
  29. break; 
  30.  
  31. case 'levels': 
  32.  
  33. $selected = is_array( $meta ) ? $meta : array( $meta ); 
  34.  
  35.  
  36. $levels = rcp_get_subscription_levels( 'all' ); 
  37. foreach ( $levels as $level ) { 
  38. echo '<input type="checkbox" value="' . absint( $level->id ) . '"' . checked( true, in_array( $level->id, $selected ), false ) . ' name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '_' . absint( $level->id ) . '" /> '; 
  39. echo '<label for="' . esc_attr( $field['id'] ) . '_' . absint( $level->id ) . '">' . $level->name . '</label><br/>'; 
  40. break; 
  41. echo '<span class="description">' . $field['desc'] . '</div>'; 
  42.  
  43. echo '</div>'; 
  44.  
  45. echo '</table>';