CMB2_Type_File_List

CMB file_list field type.

Defined (1)

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

/vendor/wordimpress/maps-builder-core/includes/libraries/metabox/includes/types/CMB2_Type_File_List.php  
  1. class CMB2_Type_File_List extends CMB2_Type_File_Base { 
  2.  
  3. public function render() { 
  4. $field = $this->field; 
  5.  
  6. $meta_value = $field->escaped_value(); 
  7. $name = $this->_name(); 
  8. $img_size = $field->args( 'preview_size' ); 
  9. $query_args = $field->args( 'query_args' ); 
  10. $output = ''; 
  11.  
  12. $output .= parent::render( array( 
  13. 'type' => 'hidden',  
  14. 'class' => 'cmb2-upload-file cmb2-upload-list',  
  15. 'size' => 45, 'desc' => '', 'value' => '',  
  16. 'data-previewsize' => is_array( $img_size ) ? sprintf( '[%s]', implode( ', ', $img_size ) ) : 50,  
  17. 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '',  
  18. 'js_dependencies' => 'media-editor',  
  19. ) ); 
  20.  
  21. $output .= parent::render( array( 
  22. 'type' => 'button',  
  23. 'class' => 'cmb2-upload-button button cmb2-upload-list',  
  24. 'value' => esc_html( $this->_text( 'add_upload_files_text', __( 'Add or Upload Files', 'cmb2' ) ) ),  
  25. 'name' => '', 'id' => '',  
  26. ) ); 
  27.  
  28. $output .= '<ul id="' . $this->_id( '-status' ) . '" class="cmb2-media-status cmb-attach-list">'; 
  29.  
  30. if ( $meta_value && is_array( $meta_value ) ) { 
  31.  
  32. foreach ( $meta_value as $id => $fullurl ) { 
  33. $id_input = parent::render( array( 
  34. 'type' => 'hidden',  
  35. 'value' => $fullurl,  
  36. 'name' => $name . '[' . $id . ']',  
  37. 'id' => 'filelist-' . $id,  
  38. 'data-id' => $id,  
  39. 'desc' => '',  
  40. 'class' => false,  
  41. ) ); 
  42.  
  43. if ( $this->is_valid_img_ext( $fullurl ) ) { 
  44.  
  45. $output .= $this->img_status_output( array( 
  46. 'image' => wp_get_attachment_image( $id, $img_size ),  
  47. 'tag' => 'li',  
  48. 'id_input' => $id_input,  
  49. ) ); 
  50.  
  51. } else { 
  52.  
  53. $output .= $this->file_status_output( array( 
  54. 'value' => $fullurl,  
  55. 'tag' => 'li',  
  56. 'id_input' => $id_input,  
  57. ) ); 
  58.  
  59.  
  60. $output .= '</ul>'; 
  61.  
  62. return $this->rendered( $output ); 
  63.