$value_mix_string) { $_array_temp = explode('->', $value_mix_string); if(!empty($_array_temp)) { $_name = (isset($_array_temp[0])) ? $_array_temp[0] : ''; $_value = (isset($_array_temp[1])) ? $_array_temp[1] : ''; if($_name !== '') { $_value_array[$_name] = $_value; } } } } $current_input_name_val = (isset($_value_array['input_name'])) ? $_value_array['input_name'] : 'CP_FIELD_' . rand(00, 99); $current_input_label_val = (isset($_value_array['input_label'])) ? $_value_array['input_label'] : ''; $accordion_label = ($current_input_label_val != '') ? $current_input_label_val : $current_input_name_val; $is_hidden = $is_dropdown = $need_placeholder = $is_textarea = false; $output .= '
'; $output .= '
'.$accordion_label.'
'; $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $current_input_placeholder = (isset($_value_array['input_placeholder'])) ? $_value_array['input_placeholder'] : ''; $placeholder_style = ($need_placeholder) ? 'style="display:block"' : 'style="display:none"'; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $dropdown_style_for_options = ($is_dropdown) ? 'style="display:block"' : 'style="display:none"'; $current_dropdown_options = (isset($_value_array['dropdown_options'])) ? $_value_array['dropdown_options'] : __( 'Enter Your Options Here', 'smile' ); $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $hidden_style_for_require = ($is_hidden) ? 'style="display:none"' : ''; $hidden_style_for_row = ($is_textarea) ? 'style="display:block"' : 'style="display:none"'; $current_row_value = (isset($_value_array['row_value'])) ? $_value_array['row_value'] : ''; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $current_input_val = (isset($_value_array['input_require'])) ? $_value_array['input_require'] : 'true'; $checked = ($current_input_val === 'true' || $current_input_val === true) ? 'checked="checked"' : ''; $output .= ''; $output .= ' '; $output .= '
'; $hidden_style_for_hidden = ($is_hidden) ? 'style="display:block"' : 'style="display:none"'; $current_hidden_val = (isset($_value_array['hidden_value'])) ? $_value_array['hidden_value'] : ''; $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; $output .= '
'; $output .= '
'; return $output; } function multi_box_settings_field($name, $settings, $value) { $input_name = $name; $type = isset($settings['type']) ? $settings['type'] : ''; $class = isset($settings['class']) ? $settings['class'] : ''; $uniq = uniqid(); $output = '
'; $output .= ''; $output .= '
'; $boxes = explode(';', $value); if(!empty($boxes)) { foreach ($boxes as $key => $box_value) { $output .= render_multi_box($uniq, $box_value); } } $output .= '
'; $output .= '
Add New Field
'; $output .= '
'; return $output; } add_action( 'wp_ajax_repeat_multi_box', 'repeat_multi_box_callback' ); function repeat_multi_box_callback() { $uniq = $_POST['id']; if($uniq === '') { $response['type'] = 'error'; $response['message'] = 'No wrapper ID found'; echo json_encode($response); die(); } $value = ''; $output = render_multi_box($uniq, $value); $response['type'] = 'success'; $response['message'] = $output; echo json_encode($response); die(); } // function to convert dropdown string to array function mb_dropdown_string_to_array($string) { $lines = explode(PHP_EOL, $string); $array = array(); foreach ($lines as $key => $line) { $line = trim($line); if($line === '') continue; $temp = array(); $line_to_array = explode('+', $line); $label = (isset($line_to_array[0])) ? ucfirst($line_to_array[0]) : ucfirst($line); $value = (isset($line_to_array[1])) ? $line_to_array[1] : $line; $temp['label'] = trim($label); $temp['value'] = trim($value); array_push($array, $temp); } return $array; }