init_constants(); } private function init_constants(){ $this->cell_props = array( 'label_cell_props' => 'class="label"', 'input_cell_props' => 'class="field"', 'input_width' => '260px', ); $this->cell_props_TA = array( 'label_cell_props' => 'class="label"', 'input_cell_props' => 'class="field"', 'input_width' => '260px', 'rows' => 10, 'cols' => 29, ); $this->cell_props_CP = array( 'label_cell_props' => 'class="label"', 'input_cell_props' => 'class="field"', 'input_width' => '223px', ); $this->cell_props_CB = array( 'label_props' => 'style="margin-right: 40px;"', ); $this->cell_props_CBS = array( 'label_props' => 'style="margin-right: 15px;"', ); $this->cell_props_CBL = array( 'label_props' => 'style="margin-right: 52px;"', ); $this->field_props = $this->get_field_form_props(); $this->field_props_display = $this->get_field_form_props_display(); } public function render_form_field_element($field, $args = array(), $render_cell = true){ if($field && is_array($field)){ $defaults = array( 'label_cell_props' => 'class="label"', 'input_cell_props' => 'class="field"', 'label_cell_colspan' => '', 'input_cell_colspan' => '', ); $args = wp_parse_args( $args, $defaults ); $ftype = isset($field['type']) ? $field['type'] : 'text'; $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : ''; $sub_label = isset($field['sub_label']) && !empty($field['sub_label']) ? __($field['sub_label'], 'woo-checkout-field-editor-pro') : ''; $tooltip = isset($field['hint_text']) && !empty($field['hint_text']) ? __($field['hint_text'], 'woo-checkout-field-editor-pro') : ''; $field_html = ''; if($ftype == 'text'){ $field_html = $this->render_form_field_element_inputtext($field, $args); }else if($ftype == 'textarea'){ $field_html = $this->render_form_field_element_textarea($field, $args); }else if($ftype == 'select'){ $field_html = $this->render_form_field_element_select($field, $args); }else if($ftype == 'multiselect'){ $field_html = $this->render_form_field_element_multiselect($field, $args); }else if($ftype == 'colorpicker'){ $field_html = $this->render_form_field_element_colorpicker($field, $args); }else if($ftype == 'checkbox'){ $field_html = $this->render_form_field_element_checkbox($field, $args, $render_cell); $flabel = ' '; }else if($ftype == 'number'){ $field_html = $this->render_form_field_element_number($field, $args); } if($render_cell){ $required_html = isset($field['required']) && $field['required'] ? '*' : ''; $label_cell_props = !empty($args['label_cell_props']) ? $args['label_cell_props'] : ''; $input_cell_props = !empty($args['input_cell_props']) ? $args['input_cell_props'] : ''; ?> >
render_form_fragment_tooltip($tooltip); ?> > '', 'input_name_prefix' => 'i_', 'input_name_suffix' => '', ); $args = wp_parse_args( $args, $defaults ); $ftype = isset($field['type']) ? $field['type'] : 'text'; $input_class = ''; if($ftype == 'text'){ $input_class = 'thwcfd-inputtext'; }else if($ftype == 'number'){ $input_class = 'thwcfd-inputtext'; }else if($ftype == 'select'){ $input_class = 'thwcfd-select'; }else if($ftype == 'multiselect' || $ftype == 'multiselect_grouped'){ $input_class = 'thwcfd-select thwcfd-enhanced-multi-select'; }else if($ftype == 'colorpicker'){ $input_class = 'thwcfd-color thpladmin-colorpick'; } if($ftype == 'multiselect' || $ftype == 'multiselect_grouped'){ $args['input_name_suffix'] = $args['input_name_suffix'].'[]'; } $fname = $args['input_name_prefix'].$field['name'].$args['input_name_suffix']; $fvalue = isset($field['value']) ? esc_html($field['value']) : ''; $input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : ''; $field_props = 'name="'. $fname .'" style="'. $input_width .'"'; $field_props .= !empty($input_class) ? ' class="'. $input_class .'"' : ''; $field_props .= $ftype == 'textarea' ? '' : ' value="'. $fvalue .'"'; $field_props .= $ftype == 'multiselect_grouped' ? ' data-value="'. $fvalue .'"' : ''; $field_props .= ( isset($field['placeholder']) && !empty($field['placeholder']) ) ? ' placeholder="'.$field['placeholder'].'"' : ''; $field_props .= ( isset($field['onchange']) && !empty($field['onchange']) ) ? ' onchange="'.$field['onchange'].'"' : ''; if( $ftype == 'number' ){ $min = isset( $field['min'] ) ? $field['min'] : ''; $max = isset( $field['max'] ) ? $field['max'] : ''; $field_props .= ' min="'.$min.'" max="'.$max.'"'; } return $field_props; } private function render_form_field_element_inputtext($field, $atts = array()){ $field_html = ''; if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; } return $field_html; } private function render_form_field_element_textarea($field, $args = array()){ $field_html = ''; if($field && is_array($field)){ $args = wp_parse_args( $args, array( 'rows' => '5', 'cols' => '29', )); $fvalue = isset($field['value']) ? $field['value'] : ''; $field_props = $this->prepare_form_field_props($field, $args); $field_html = ''; } return $field_html; } private function render_form_field_element_select($field, $atts = array()){ $field_html = ''; if($field && is_array($field)){ $fvalue = isset($field['value']) ? $field['value'] : ''; $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; } return $field_html; } private function render_form_field_element_multiselect($field, $atts = array()){ $field_html = ''; if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; } return $field_html; } private function render_form_field_element_multiselect_grouped($field, $atts = array()){ $field_html = ''; if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; } return $field_html; } private function render_form_field_element_radio($field, $atts = array()){ $field_html = ''; /*if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; }*/ return $field_html; } private function render_form_field_element_checkbox($field, $atts = array(), $render_cell = true){ $field_html = ''; if($field && is_array($field)){ $args = shortcode_atts( array( 'label_props' => '', 'cell_props' => '', 'input_props' => '', 'id_prefix' => 'a_f', 'render_input_cell' => false, ), $atts ); $fid = $args['id_prefix']. $field['name']; $flabel = isset($field['label']) && !empty($field['label']) ? __($field['label'], 'woo-checkout-field-editor-pro') : ''; $field_props = $this->prepare_form_field_props($field, $atts); $field_props .= isset($field['checked']) && $field['checked'] === 1 ? ' checked' : ''; $field_props .= $args['input_props']; $field_html = ''; $field_html .= ''; } if(!$render_cell && $args['render_input_cell']){ return ''. $field_html .''; }else{ return $field_html; } } private function render_form_field_element_colorpicker($field, $atts = array()){ $field_html = ''; if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; $field_html .= ''; } return $field_html; } private function render_form_field_element_number($field, $atts = array() ){ $field_html = ''; if($field && is_array($field)){ $field_props = $this->prepare_form_field_props($field, $atts); $field_html = ''; } return $field_html; } public function render_form_fragment_tooltip($tooltip = false){ if($tooltip){ ?> 6, 'padding-top' => '5px', 'border-style' => 'dashed', 'border-width' => '1px', 'border-color' => '#e6e6e6', 'content' => '', ), $atts ); $style = $args['padding-top'] ? 'padding-top:'.$args['padding-top'].';' : ''; $style .= $args['border-style'] ? ' border-bottom:'.$args['border-width'].' '.$args['border-style'].' '.$args['border-color'].';' : ''; ?>   prepare_settings_row_class( $field ); ?> render_form_field_element($field, $this->cell_props); ?> prepare_settings_row_class( $field ); ?> render_form_field_element($field, $this->cell_props_TA); ?> prepare_settings_row_class( $field ); ?> render_form_field_element($field, $this->cell_props_CB, false); ?> render_form_field_element($field, $this->cell_props_CP); ?>