| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | +// Exit if accessed directly | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) exit; | |
| 2 | 4 | |
| 3 | 5 | /* |
| 4 | 6 | * Handle field output. |
| 5 | 7 | * |
| @@ -16,9 +18,9 @@ | ||
| 16 | 18 | if ($field['field'] == 'Select2') { |
| 17 | 19 | wp_enqueue_script('wppb_sl2_lib_js', WPPB_PLUGIN_URL . 'assets/js/select2/select2.min.js', array('jquery')); |
| 18 | 20 | wp_enqueue_style('wppb_sl2_lib_css', WPPB_PLUGIN_URL . 'assets/css/select2/select2.min.css'); |
| 19 | 21 | |
| 20 | - wp_enqueue_script( 'wppb_sl2_js', WPPB_PLUGIN_URL.'front-end/default-fields/select2/select2.js', array('jquery'), PROFILE_BUILDER_VERSION, true ); | |
| 22 | + wp_enqueue_script( 'wppb_sl2_js', WPPB_PLUGIN_URL.'front-end/default-fields/select2/select2.js', array('jquery', 'wp-hooks'), PROFILE_BUILDER_VERSION, true ); | |
| 21 | 23 | wp_enqueue_style( 'wppb_sl2_css', WPPB_PLUGIN_URL.'front-end/default-fields/select2/select2.css', false, PROFILE_BUILDER_VERSION ); |
| 22 | 24 | |
| 23 | 25 | |
| 24 | 26 | $field['labels'] = apply_filters('wppb_select2_labels', $field['labels'], $form_location, $field, $user_id, $field_check_errors, $request_data); |
| @@ -40,8 +42,11 @@ | ||
| 40 | 42 | $input_value = (!empty($field['default-option']) ? esc_attr(trim($field['default-option'])) : ''); |
| 41 | 43 | |
| 42 | 44 | $input_value = (isset($request_data[wppb_handle_meta_name($field['meta-name'])]) ? esc_attr(stripslashes(trim($request_data[wppb_handle_meta_name($field['meta-name'])]))) : $input_value); |
| 43 | 45 | |
| 46 | + $input_value = html_entity_decode( htmlspecialchars_decode( $input_value, ENT_QUOTES ), ENT_QUOTES ); | |
| 47 | + $input_value = apply_filters( 'wppb_form_select2_field_value', $input_value, $field, $form_location ); | |
| 48 | + | |
| 44 | 49 | if ($form_location != 'back_end') { |
| 45 | 50 | $error_mark = (($field['required'] == 'Yes') ? '<span class="wppb-required" title="' . wppb_required_field_error($field["field-title"]) . '">*</span>' : ''); |
| 46 | 51 | |
| 47 | 52 | if (array_key_exists($field['id'], $field_check_errors)) |
| @@ -47,10 +52,10 @@ | ||
| 47 | 52 | if (array_key_exists($field['id'], $field_check_errors)) |
| 48 | 53 | $error_mark = '<img src="' . WPPB_PLUGIN_URL . 'assets/images/pencil_delete.png" title="' . wppb_required_field_error($field["field-title"]) . '"/>'; |
| 49 | 54 | |
| 50 | 55 | $output = ' |
| 51 | - <label for="' . esc_attr($field['meta-name']) . '">' . $item_title . $error_mark . '</label> | |
| 52 | - <select name="' . esc_attr($field['meta-name']) . '" id="' . esc_attr($field['meta-name']) . '" class="custom_field_select2" ' . $extra_attr . ' data-wppb-select2-arguments=\'' . json_encode($arguments) . '\'>'; | |
| 56 | + <label for="' . esc_attr(wppb_handle_meta_name($field['meta-name'])) . '">' . $item_title . $error_mark . '</label> | |
| 57 | + <select name="' . esc_attr($field['meta-name']) . '" id="' . esc_attr(wppb_handle_meta_name($field['meta-name'])) . '" class="custom_field_select2" ' . $extra_attr . ' data-wppb-select2-arguments=\'' . json_encode($arguments) . '\'>'; | |
| 53 | 58 | |
| 54 | 59 | $extra_select_option = apply_filters('wppb_extra_select_option', '', $field, $item_title); |
| 55 | 60 | if (!empty($extra_select_option)) { |
| 56 | 61 | $output .= $extra_select_option; |
| @@ -72,13 +77,13 @@ | ||
| 72 | 77 | |
| 73 | 78 | } else { |
| 74 | 79 | $item_title = (($field['required'] == 'Yes') ? $item_title . ' <span class="description">(' . __('required', 'profile-builder') . ')</span>' : $item_title); |
| 75 | 80 | $output = ' |
| 76 | - <table class="form-table wppb-select2"> | |
| 81 | + <table class="form-table"> | |
| 77 | 82 | <tr> |
| 78 | - <th><label for="' . esc_attr($field['meta-name']) . '">' . $item_title . '</label></th> | |
| 83 | + <th><label for="' . esc_attr(wppb_handle_meta_name($field['meta-name'])) . '">' . $item_title . '</label></th> | |
| 79 | 84 | <td> |
| 80 | - <select name="' . esc_attr($field['meta-name']) . '" class="custom_field_select2" id="' . esc_attr($field['meta-name']) . '" ' . $extra_attr . ' data-wppb-select2-arguments=\'' . json_encode($arguments) . '\'>'; | |
| 85 | + <select name="' . esc_attr($field['meta-name']) . '" class="custom_field_select2 wppb-select2" id="' . esc_attr(wppb_handle_meta_name($field['meta-name'])) . '" ' . $extra_attr . ' data-wppb-select2-arguments=\'' . json_encode($arguments) . '\'>'; | |
| 81 | 86 | |
| 82 | 87 | foreach ($select2_values as $key => $value) { |
| 83 | 88 | $output .= '<option value="' . esc_attr(trim($value)) . '" class="custom_field_select2_option" '; |
| 84 | 89 | |