init_constants(); } public function init_constants(){ $this->settings_fields = THFAQF_Utils::get_settings_fields(); $this->cell_props_L = array( 'label_cell_props' => 'width="20%"', 'input_cell_props' => 'width="27%"', 'input_width' => '250px', ); $this->cell_props_R = array( 'label_cell_props' => 'width="20%"', 'input_cell_props' => 'width="27%"', 'input_width' => '250px', ); $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->cell_props_CPL = array( 'label_cell_props' => 'width="20%"', 'input_cell_props' => 'width="27%"', ); $this->cell_props_CPR = array( 'label_cell_props' => 'width="15%"', 'input_cell_props' => 'width="32%"', ); } public function render_form_field_element($field, $settings=array(), $atts=array(), $render_cell=true, $render_tooltip=true){ if($field && is_array($field)){ $ftype = isset($field['type']) ? $field['type'] : 'text'; $name = isset($field['name']) ? $field['name'] : ''; if(is_array($settings) && isset($settings[$name])){ if($ftype === 'checkbox' || $ftype === 'switch'){ $field['checked'] = $settings[$name]; }else{ $field['value'] = esc_attr($settings[$name]); } } if($ftype == 'checkbox'){ $this->render_form_field_element_checkbox($name, $field, $atts, $render_cell); return true; } $args = shortcode_atts( array( 'label_cell_props' => '', 'input_cell_props' => '', 'label_cell_th' => false, 'input_width' => '', 'input_name_prefix' => '', 'input_name_suffix' => '' ), $atts ); $input_class = isset($field['class']) ? $field['class'] : array(); if($ftype == 'multiselect'){ $input_class[] = 'thpladmin-enhanced-multi-select'; $args['input_name_suffix'] = $args['input_name_suffix'].'[]'; }else if($ftype == 'colorpicker'){ $input_class[] = 'thpladmin-colorpicker'; } $fname = $args['input_name_prefix'].$name.$args['input_name_suffix']; $flabel = isset($field['label']) ? __($field['label'], 'advanced-faq-manager') : ''; $fvalue = isset($field['value']) ? $field['value'] : ''; $input_width = $args['input_width'] ? 'width:'.$args['input_width'].';' : ''; $field_props = 'name="'. $fname .'" value="'. $fvalue .'" style="'. $input_width .'"'; $field_props .= isset($field['placeholder']) && !empty($field['placeholder']) ? ' placeholder="'.$field['placeholder'].'"' : ''; $field_props .= is_array($input_class) && !empty($input_class) ? ' class="'.implode(" ", $input_class).'"' : ''; $required_html = isset($field['required']) && $field['required'] ? '*' : ''; $field_html = ''; if(isset($field['onchange']) && !empty($field['onchange'])){ $field_props .= ' onchange="'.$field['onchange'].'"'; } if($ftype == 'text'){ $field_html = ''; }else if($ftype == 'number'){ $field_html = ''; }else if($ftype == 'textarea'){ $field_html = ''; }else if($ftype == 'select'){ $field_html = ''; }else if($ftype == 'multiselect'){ $fvalue_arr = $fvalue ? explode(',', $fvalue) : array(); $field_html = ''; }else if($ftype == 'colorpicker'){ $prev_style = $fvalue ? 'background-color:'.$fvalue.';' : ''; $field_html = ''; $field_html .= ''; }else if($ftype == 'switch'){ $field_props .= isset($field['checked']) && $field['checked'] ? ' checked' : ''; $field_html .= ''; } if($render_cell){ $label_cell_props = !empty($args['label_cell_props']) ? ' '.$args['label_cell_props'] : ''; $input_cell_props = !empty($args['input_cell_props']) ? ' '.$args['input_cell_props'] : ''; ?>