Advertisement
verygoodplugins

Untitled

May 12th, 2016
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. function wpf_render_crm_field_select( $setting, $meta_name, $field_id, $field_sub_id = null ) {
  2.  
  3.     echo '<select id="' . $field_id . (isset($field_sub_id) ? '-' . $field_sub_id : '') . '" class="select4-crm-field" name="' . $meta_name . '[' . $field_id . ']' . (isset($field_sub_id) ? '[' . $field_sub_id . ']' : '') . '[crm_field]" data-placeholder="Select a field">';
  4.  
  5.         echo '<option></option>';
  6.  
  7.         $crm_fields = wp_fusion()->settings->get('crm_fields');
  8.  
  9.         if(!empty( $crm_fields )) {
  10.  
  11.             foreach( $crm_fields as $group_header => $fields ) {
  12.  
  13.                 // For CRMs with separate custom and built in fields
  14.                 if(is_array($fields)) {
  15.                
  16.                     echo '<optgroup label="' . $group_header . '">';
  17.  
  18.                         foreach($crm_fields[$group_header] as $field => $label) {
  19.  
  20.                             if(is_array($label))
  21.                                 $label = $label['label'];
  22.  
  23.                             echo '<option ' . selected(esc_attr( $setting ), $field ) . ' value="' . $field . '">' . $label . '</option>';
  24.                         }
  25.  
  26.  
  27.                     echo '</optgroup>';
  28.  
  29.                 } else {
  30.  
  31.                     $field = $group_header;
  32.                     $label = $field;
  33.  
  34.                     echo '<option ' . selected(esc_attr( $setting ), $field ) . ' value="' . $field . '">' . $label . '</option>';
  35.  
  36.  
  37.                 }
  38.  
  39.             }
  40.  
  41.         }
  42.  
  43.     echo '</select>';
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement