'Form Input', 'description'=>'Form Input description', 'icon_class'=>"fa fa-pencil-square-o", 'container'=>false, 'has_content'=>false, 'group'=>'form', 'defaults'=>array('placeholder'=>'an input'), ); parent::__construct($id_base,$name,$options); } function element($instance,$content=''){ $instance=shortcode_atts( array( 'type'=>'text', 'placeholder'=>'', 'name'=>'', 'value'=>'', 'class'=>'', 'id'=>'', 'label'=>'', 'label_right'=>'' ) ,$instance ); $label=$instance['label']; if($label&&!$instance['id']){ $instance['id']='ve-input-'.$instance['type'].'-'.uniqid (); } $label_right=$instance['label_right']; unset($instance['label']); unset($instance['label_right']); $Atts=''; foreach($instance as $_name=>$_value){ $Atts.=$this->html_attr($_name,$_value); } if($label&&!$label_right){ printf('',$instance['id'],$label); } printf('',$Atts); if($label&&$label_right){ printf('',$instance['id'],$label); } } function preview($instance,$content=''){ if(isset($instance['type'])&&$instance['type']=='hidden'){ $instance=shortcode_atts( array( 'name'=>'', 'value'=>'', ) ,$instance ); //$this->addClass(''); printf('Hidden input: %s=%s',$instance['name'],$instance['value']); }else{ $this->element($instance,$content); } } function getEditWrapperClass($instance){ if(isset($instance['type'])&&$instance['type']=='hidden'){ return 've-hidden-input'; } return ''; } private function html_attr($name,$value){ if($name&&$value) return sprintf(' %s="%s"',$name,esc_attr($value)); return ''; } function form($instance,$content=''){ $instance=shortcode_atts(array( 'type'=>'text', 'placeholder'=>'', 'name'=>'', 'value'=>'', 'class'=>'', 'id'=>'', 'label'=>'', 'label_right'=>'' ),$instance); $input_types=array( 'text'=>'Text', 'radio'=>'Radio', 'checkbox'=>'checkbox', 'hidden'=>'hidden', ); ?>