CMB2_Type_Text

CMB text 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_Text.php  
  1. class CMB2_Type_Text extends CMB2_Type_Base { 
  2.  
  3. /** 
  4. * The type of field 
  5. * @var string 
  6. */ 
  7. public $type = 'input'; 
  8.  
  9. /** 
  10. * Constructor 
  11. * @since 2.2.2 
  12. * @param CMB2_Types $types 
  13. * @param array $args 
  14. */ 
  15. public function __construct( CMB2_Types $types, $args = array(), $type = '' ) { 
  16. parent::__construct( $types, $args ); 
  17. $this->type = $type ? $type : $this->type; 
  18.  
  19. /** 
  20. * Handles outputting an 'input' element 
  21. * @since 1.1.0 
  22. * @param array $args Override arguments 
  23. * @return string Form input element 
  24. */ 
  25. public function render( $args = array() ) { 
  26. $args = empty( $args ) ? $this->args : $args; 
  27. $a = $this->parse_args( $this->type, array( 
  28. 'type' => 'text',  
  29. 'class' => 'regular-text',  
  30. 'name' => $this->_name(),  
  31. 'id' => $this->_id(),  
  32. 'value' => $this->field->escaped_value(),  
  33. 'desc' => $this->_desc( true ),  
  34. 'js_dependencies' => array(),  
  35. ), $args ); 
  36.  
  37. if ( ! empty( $a['js_dependencies'] ) ) { 
  38. CMB2_JS::add_dependencies( $a['js_dependencies'] ); 
  39.  
  40. return $this->rendered( 
  41. sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc', 'js_dependencies' ) ), $a['desc'] ) 
  42. );