@@ -2,129 +2,129 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 61 | 61 | |
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | - // this hook will allow for multiple fields to be added at once |
|
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 64 | + // this hook will allow for multiple fields to be added at once |
|
| 65 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 66 | 66 | |
| 67 | - wp_die(); |
|
| 68 | - } |
|
| 67 | + wp_die(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Set up and create a new field |
|
| 72 | - * |
|
| 73 | - * @param string $field_type |
|
| 74 | - * @param integer $form_id |
|
| 75 | - * @return array|bool |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Set up and create a new field |
|
| 72 | + * |
|
| 73 | + * @param string $field_type |
|
| 74 | + * @param integer $form_id |
|
| 75 | + * @return array|bool |
|
| 76 | + */ |
|
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | - $values = array(); |
|
| 79 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | - } |
|
| 78 | + $values = array(); |
|
| 79 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 84 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 84 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 85 | 85 | |
| 86 | - $field_id = FrmField::create( $field_values ); |
|
| 86 | + $field_id = FrmField::create( $field_values ); |
|
| 87 | 87 | |
| 88 | - if ( ! $field_id ) { |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 88 | + if ( ! $field_id ) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 93 | 93 | |
| 94 | - return $field; |
|
| 95 | - } |
|
| 94 | + return $field; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | 98 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 99 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 99 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 102 | - $field = 'name'; |
|
| 103 | - } |
|
| 101 | + if ( empty($field) ) { |
|
| 102 | + $field = 'name'; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty($id) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | - // set blank value if there is no content |
|
| 114 | - $value = ''; |
|
| 115 | - } |
|
| 112 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 113 | + // set blank value if there is no content |
|
| 114 | + $value = ''; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | FrmField::update( $id, array( $field => $value ) ); |
| 118 | 118 | |
| 119 | 119 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 120 | 120 | |
| 121 | 121 | echo stripslashes( wp_kses_post( $value ) ); |
| 122 | - wp_die(); |
|
| 123 | - } |
|
| 122 | + wp_die(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - public static function update_ajax_option() { |
|
| 125 | + public static function update_ajax_option() { |
|
| 126 | 126 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 127 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 127 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 130 | 130 | if ( ! $field_id ) { |
@@ -139,252 +139,252 @@ discard block |
||
| 139 | 139 | unset($new_val); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - FrmField::update( $field_id, array( |
|
| 143 | - 'field_options' => $field->field_options, |
|
| 142 | + FrmField::update( $field_id, array( |
|
| 143 | + 'field_options' => $field->field_options, |
|
| 144 | 144 | 'form_id' => $field->form_id, |
| 145 | - ) ); |
|
| 146 | - wp_die(); |
|
| 147 | - } |
|
| 145 | + ) ); |
|
| 146 | + wp_die(); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - public static function duplicate() { |
|
| 149 | + public static function duplicate() { |
|
| 150 | 150 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 151 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 151 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 152 | 152 | |
| 153 | - global $wpdb; |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 156 | 156 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 157 | 157 | |
| 158 | 158 | $copy_field = FrmField::getOne( $field_id ); |
| 159 | - if ( ! $copy_field ) { |
|
| 160 | - wp_die(); |
|
| 161 | - } |
|
| 159 | + if ( ! $copy_field ) { |
|
| 160 | + wp_die(); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 164 | 164 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
| 165 | 165 | |
| 166 | 166 | $values = array(); |
| 167 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 167 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 168 | 168 | |
| 169 | 169 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 170 | 170 | |
| 171 | - $values['field_order'] = $field_count + 1; |
|
| 171 | + $values['field_order'] = $field_count + 1; |
|
| 172 | 172 | |
| 173 | - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 173 | + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values ); |
|
| 174 | 174 | |
| 175 | 175 | $field_id = FrmField::create( $values ); |
| 176 | 176 | if ( ! $field_id ) { |
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - self::include_single_field($field_id, $values); |
|
| 180 | + self::include_single_field($field_id, $values); |
|
| 181 | 181 | |
| 182 | - wp_die(); |
|
| 183 | - } |
|
| 182 | + wp_die(); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Load a single field in the form builder along with all needed variables |
|
| 187 | - */ |
|
| 188 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 185 | + /** |
|
| 186 | + * Load a single field in the form builder along with all needed variables |
|
| 187 | + */ |
|
| 188 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
| 191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | - if ( $field['type'] == 'html' ) { |
|
| 194 | - $field['stop_filter'] = true; |
|
| 195 | - } |
|
| 191 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | + if ( $field['type'] == 'html' ) { |
|
| 194 | + $field['stop_filter'] = true; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 198 | 198 | |
| 199 | - return $field; |
|
| 200 | - } |
|
| 199 | + return $field; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - public static function destroy() { |
|
| 202 | + public static function destroy() { |
|
| 203 | 203 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 204 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 204 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 205 | 205 | |
| 206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 207 | 207 | FrmField::destroy( $field_id ); |
| 208 | - wp_die(); |
|
| 209 | - } |
|
| 208 | + wp_die(); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /* Field Options */ |
|
| 211 | + /* Field Options */ |
|
| 212 | 212 | |
| 213 | - //Add Single Option or Other Option |
|
| 214 | - public static function add_option() { |
|
| 213 | + //Add Single Option or Other Option |
|
| 214 | + public static function add_option() { |
|
| 215 | 215 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 216 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 216 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 217 | 217 | |
| 218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 220 | 220 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
| 221 | 221 | |
| 222 | - $field = FrmField::getOne($id); |
|
| 222 | + $field = FrmField::getOne($id); |
|
| 223 | 223 | |
| 224 | - if ( 'other' == $opt_type ) { |
|
| 224 | + if ( 'other' == $opt_type ) { |
|
| 225 | 225 | $opt = __( 'Other', 'formidable' ); |
| 226 | - $other_val = ''; |
|
| 227 | - $opt_key = 'other_' . $opt_key; |
|
| 228 | - } else { |
|
| 226 | + $other_val = ''; |
|
| 227 | + $opt_key = 'other_' . $opt_key; |
|
| 228 | + } else { |
|
| 229 | 229 | $opt = __( 'New Option', 'formidable' ); |
| 230 | - } |
|
| 231 | - $field_val = $opt; |
|
| 230 | + } |
|
| 231 | + $field_val = $opt; |
|
| 232 | 232 | |
| 233 | - $field_data = $field; |
|
| 233 | + $field_data = $field; |
|
| 234 | 234 | $field = (array) $field; |
| 235 | 235 | $field['separate_value'] = isset( $field_data->field_options['separate_value'] ) ? $field_data->field_options['separate_value'] : 0; |
| 236 | 236 | unset( $field_data ); |
| 237 | 237 | |
| 238 | 238 | $field_name = 'item_meta[' . $id . ']'; |
| 239 | 239 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 240 | - $checked = ''; |
|
| 240 | + $checked = ''; |
|
| 241 | 241 | |
| 242 | - if ( 'other' == $opt_type ) { |
|
| 242 | + if ( 'other' == $opt_type ) { |
|
| 243 | 243 | include( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 244 | - } else { |
|
| 244 | + } else { |
|
| 245 | 245 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 246 | - } |
|
| 247 | - wp_die(); |
|
| 248 | - } |
|
| 246 | + } |
|
| 247 | + wp_die(); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - public static function edit_option() { |
|
| 250 | + public static function edit_option() { |
|
| 251 | 251 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 252 | - } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - public static function delete_option() { |
|
| 254 | + public static function delete_option() { |
|
| 255 | 255 | _deprecated_function( __FUNCTION__, '2.3' ); |
| 256 | - } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - public static function import_choices() { |
|
| 259 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 258 | + public static function import_choices() { |
|
| 259 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 260 | 260 | |
| 261 | 261 | $field_id = absint( $_REQUEST['field_id'] ); |
| 262 | 262 | |
| 263 | - global $current_screen, $hook_suffix; |
|
| 263 | + global $current_screen, $hook_suffix; |
|
| 264 | 264 | |
| 265 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 266 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 267 | - $hook_suffix = ''; |
|
| 268 | - set_current_screen(); |
|
| 269 | - } |
|
| 265 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 266 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 267 | + $hook_suffix = ''; |
|
| 268 | + set_current_screen(); |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 272 | - register_admin_color_schemes(); |
|
| 273 | - } |
|
| 271 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 272 | + register_admin_color_schemes(); |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | $hook_suffix = ''; |
| 276 | 276 | $admin_body_class = ''; |
| 277 | 277 | |
| 278 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 279 | - $admin_body_class .= ' folded'; |
|
| 280 | - } |
|
| 278 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 279 | + $admin_body_class .= ' folded'; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 283 | - $admin_body_class .= ' admin-bar'; |
|
| 284 | - } |
|
| 282 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 283 | + $admin_body_class .= ' admin-bar'; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - if ( is_rtl() ) { |
|
| 287 | - $admin_body_class .= ' rtl'; |
|
| 288 | - } |
|
| 286 | + if ( is_rtl() ) { |
|
| 287 | + $admin_body_class .= ' rtl'; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 291 | - $prepop = array(); |
|
| 292 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 290 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 291 | + $prepop = array(); |
|
| 292 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 293 | 293 | |
| 294 | - $field = FrmField::getOne($field_id); |
|
| 294 | + $field = FrmField::getOne($field_id); |
|
| 295 | 295 | |
| 296 | - wp_enqueue_script( 'utils' ); |
|
| 296 | + wp_enqueue_script( 'utils' ); |
|
| 297 | 297 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 298 | - FrmAppHelper::load_admin_wide_js(); |
|
| 298 | + FrmAppHelper::load_admin_wide_js(); |
|
| 299 | 299 | |
| 300 | 300 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 301 | - wp_die(); |
|
| 302 | - } |
|
| 301 | + wp_die(); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - public static function import_options() { |
|
| 304 | + public static function import_options() { |
|
| 305 | 305 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 306 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 306 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 307 | 307 | |
| 308 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 309 | - return; |
|
| 310 | - } |
|
| 308 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 309 | + return; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | 312 | $field_id = absint( $_POST['field_id'] ); |
| 313 | - $field = FrmField::getOne($field_id); |
|
| 313 | + $field = FrmField::getOne($field_id); |
|
| 314 | 314 | |
| 315 | 315 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 316 | - return; |
|
| 317 | - } |
|
| 316 | + return; |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 319 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 320 | 320 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 321 | 321 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 322 | 322 | $opts = array_map( 'trim', $opts ); |
| 323 | 323 | |
| 324 | - if ( $field['separate_value'] ) { |
|
| 325 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 326 | - if ( strpos($opt, '|') !== false ) { |
|
| 327 | - $vals = explode('|', $opt); |
|
| 328 | - if ( $vals[0] != $vals[1] ) { |
|
| 329 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 330 | - } |
|
| 331 | - unset($vals); |
|
| 332 | - } |
|
| 333 | - unset($opt_key, $opt); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - //Keep other options after bulk update |
|
| 338 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 339 | - $other_array = array(); |
|
| 340 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 324 | + if ( $field['separate_value'] ) { |
|
| 325 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 326 | + if ( strpos($opt, '|') !== false ) { |
|
| 327 | + $vals = explode('|', $opt); |
|
| 328 | + if ( $vals[0] != $vals[1] ) { |
|
| 329 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 330 | + } |
|
| 331 | + unset($vals); |
|
| 332 | + } |
|
| 333 | + unset($opt_key, $opt); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + //Keep other options after bulk update |
|
| 338 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 339 | + $other_array = array(); |
|
| 340 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 341 | 341 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 342 | 342 | $other_array[ $opt_key ] = $opt; |
| 343 | 343 | } |
| 344 | - unset($opt_key, $opt); |
|
| 345 | - } |
|
| 346 | - if ( ! empty($other_array) ) { |
|
| 347 | - $opts = array_merge( $opts, $other_array); |
|
| 348 | - } |
|
| 349 | - } |
|
| 344 | + unset($opt_key, $opt); |
|
| 345 | + } |
|
| 346 | + if ( ! empty($other_array) ) { |
|
| 347 | + $opts = array_merge( $opts, $other_array); |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - $field['options'] = $opts; |
|
| 351 | + $field['options'] = $opts; |
|
| 352 | 352 | |
| 353 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 353 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 354 | 354 | $field_name = 'item_meta[' . $field['id'] . ']'; |
| 355 | 355 | |
| 356 | 356 | // Get html_id which will be used in single-option.php |
| 357 | 357 | $html_id = FrmFieldsHelper::get_html_id( $field ); |
| 358 | 358 | |
| 359 | 359 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 360 | - } else { |
|
| 361 | - FrmFieldsHelper::show_single_option($field); |
|
| 362 | - } |
|
| 360 | + } else { |
|
| 361 | + FrmFieldsHelper::show_single_option($field); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - wp_die(); |
|
| 365 | - } |
|
| 364 | + wp_die(); |
|
| 365 | + } |
|
| 366 | 366 | |
| 367 | - public static function update_order() { |
|
| 367 | + public static function update_order() { |
|
| 368 | 368 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 369 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 369 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 370 | 370 | |
| 371 | 371 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 372 | 372 | foreach ( (array) $fields as $position => $item ) { |
| 373 | 373 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 374 | 374 | } |
| 375 | - wp_die(); |
|
| 376 | - } |
|
| 375 | + wp_die(); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | 378 | public static function change_type( $type ) { |
| 379 | - $type_switch = array( |
|
| 380 | - 'scale' => 'radio', |
|
| 381 | - '10radio' => 'radio', |
|
| 382 | - 'rte' => 'textarea', |
|
| 383 | - 'website' => 'url', |
|
| 384 | - ); |
|
| 385 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 386 | - $type = $type_switch[ $type ]; |
|
| 387 | - } |
|
| 379 | + $type_switch = array( |
|
| 380 | + 'scale' => 'radio', |
|
| 381 | + '10radio' => 'radio', |
|
| 382 | + 'rte' => 'textarea', |
|
| 383 | + 'website' => 'url', |
|
| 384 | + ); |
|
| 385 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 386 | + $type = $type_switch[ $type ]; |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | $pro_fields = FrmField::pro_field_selection(); |
| 390 | 390 | $types = array_keys( $pro_fields ); |
@@ -392,137 +392,137 @@ discard block |
||
| 392 | 392 | $type = 'text'; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - return $type; |
|
| 396 | - } |
|
| 395 | + return $type; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | 398 | public static function display_field_options( $display ) { |
| 399 | 399 | switch ( $display['type'] ) { |
| 400 | - case 'captcha': |
|
| 401 | - $display['required'] = false; |
|
| 402 | - $display['invalid'] = true; |
|
| 403 | - $display['default_blank'] = false; |
|
| 400 | + case 'captcha': |
|
| 401 | + $display['required'] = false; |
|
| 402 | + $display['invalid'] = true; |
|
| 403 | + $display['default_blank'] = false; |
|
| 404 | 404 | $display['captcha_size'] = true; |
| 405 | - break; |
|
| 406 | - case 'radio': |
|
| 407 | - $display['default_blank'] = false; |
|
| 408 | - break; |
|
| 409 | - case 'text': |
|
| 410 | - case 'textarea': |
|
| 411 | - $display['size'] = true; |
|
| 412 | - $display['clear_on_focus'] = true; |
|
| 413 | - break; |
|
| 414 | - case 'select': |
|
| 415 | - $display['size'] = true; |
|
| 416 | - break; |
|
| 417 | - case 'url': |
|
| 418 | - case 'website': |
|
| 419 | - case 'email': |
|
| 420 | - $display['size'] = true; |
|
| 421 | - $display['clear_on_focus'] = true; |
|
| 422 | - $display['invalid'] = true; |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - return $display; |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - public static function input_html( $field, $echo = true ) { |
|
| 429 | - $class = array(); //$field['type']; |
|
| 430 | - self::add_input_classes($field, $class); |
|
| 431 | - |
|
| 432 | - $add_html = array(); |
|
| 433 | - self::add_html_size($field, $add_html); |
|
| 434 | - self::add_html_length($field, $add_html); |
|
| 435 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 405 | + break; |
|
| 406 | + case 'radio': |
|
| 407 | + $display['default_blank'] = false; |
|
| 408 | + break; |
|
| 409 | + case 'text': |
|
| 410 | + case 'textarea': |
|
| 411 | + $display['size'] = true; |
|
| 412 | + $display['clear_on_focus'] = true; |
|
| 413 | + break; |
|
| 414 | + case 'select': |
|
| 415 | + $display['size'] = true; |
|
| 416 | + break; |
|
| 417 | + case 'url': |
|
| 418 | + case 'website': |
|
| 419 | + case 'email': |
|
| 420 | + $display['size'] = true; |
|
| 421 | + $display['clear_on_focus'] = true; |
|
| 422 | + $display['invalid'] = true; |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + return $display; |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + public static function input_html( $field, $echo = true ) { |
|
| 429 | + $class = array(); //$field['type']; |
|
| 430 | + self::add_input_classes($field, $class); |
|
| 431 | + |
|
| 432 | + $add_html = array(); |
|
| 433 | + self::add_html_size($field, $add_html); |
|
| 434 | + self::add_html_length($field, $add_html); |
|
| 435 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 436 | 436 | self::add_validation_messages( $field, $add_html ); |
| 437 | 437 | |
| 438 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 438 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 439 | 439 | |
| 440 | 440 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 441 | 441 | |
| 442 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 442 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 443 | 443 | |
| 444 | 444 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 445 | 445 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 446 | 446 | |
| 447 | - if ( $echo ) { |
|
| 448 | - echo $add_html; |
|
| 449 | - } |
|
| 447 | + if ( $echo ) { |
|
| 448 | + echo $add_html; |
|
| 449 | + } |
|
| 450 | 450 | |
| 451 | - return $add_html; |
|
| 452 | - } |
|
| 451 | + return $add_html; |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | 454 | private static function add_input_classes( $field, array &$class ) { |
| 455 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 456 | - $class[] = $field['input_class']; |
|
| 457 | - } |
|
| 455 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 456 | + $class[] = $field['input_class']; |
|
| 457 | + } |
|
| 458 | 458 | |
| 459 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 460 | - return; |
|
| 461 | - } |
|
| 459 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 460 | + return; |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 464 | - $class[] = 'auto_width'; |
|
| 465 | - } |
|
| 466 | - } |
|
| 463 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 464 | + $class[] = 'auto_width'; |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | 468 | private static function add_html_size( $field, array &$add_html ) { |
| 469 | 469 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden', 'file', 'lookup' ) ) ) { |
| 470 | - return; |
|
| 471 | - } |
|
| 470 | + return; |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 474 | - return; |
|
| 475 | - } |
|
| 473 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 474 | + return; |
|
| 475 | + } |
|
| 476 | 476 | |
| 477 | - if ( is_numeric($field['size']) ) { |
|
| 478 | - $field['size'] .= 'px'; |
|
| 479 | - } |
|
| 477 | + if ( is_numeric($field['size']) ) { |
|
| 478 | + $field['size'] .= 'px'; |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 482 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 481 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 482 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 483 | 483 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 484 | 484 | |
| 485 | - self::add_html_cols($field, $add_html); |
|
| 486 | - } |
|
| 485 | + self::add_html_cols($field, $add_html); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | 488 | private static function add_html_cols( $field, array &$add_html ) { |
| 489 | 489 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 490 | - return; |
|
| 491 | - } |
|
| 490 | + return; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - // convert to cols for textareas |
|
| 494 | - $calc = array( |
|
| 495 | - '' => 9, |
|
| 496 | - 'px' => 9, |
|
| 497 | - 'rem' => 0.444, |
|
| 498 | - 'em' => 0.544, |
|
| 499 | - ); |
|
| 493 | + // convert to cols for textareas |
|
| 494 | + $calc = array( |
|
| 495 | + '' => 9, |
|
| 496 | + 'px' => 9, |
|
| 497 | + 'rem' => 0.444, |
|
| 498 | + 'em' => 0.544, |
|
| 499 | + ); |
|
| 500 | 500 | |
| 501 | - // include "col" for valid html |
|
| 502 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 501 | + // include "col" for valid html |
|
| 502 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 503 | 503 | |
| 504 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 505 | - return; |
|
| 506 | - } |
|
| 504 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 505 | + return; |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 508 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 509 | 509 | |
| 510 | 510 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 511 | - } |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | 513 | private static function add_html_length( $field, array &$add_html ) { |
| 514 | - // check for max setting and if this field accepts maxlength |
|
| 514 | + // check for max setting and if this field accepts maxlength |
|
| 515 | 515 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden', 'file' ) ) ) { |
| 516 | - return; |
|
| 517 | - } |
|
| 516 | + return; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 520 | - // don't load on form builder page |
|
| 521 | - return; |
|
| 522 | - } |
|
| 519 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 520 | + // don't load on form builder page |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | 524 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 528 | 528 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -530,35 +530,35 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | $default_value_array = is_array( $field['default_value'] ); |
| 533 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 533 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 534 | 534 | if ( $default_value_array ) { |
| 535 | 535 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 536 | 536 | } |
| 537 | 537 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 538 | - return; |
|
| 539 | - } |
|
| 538 | + return; |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | 541 | if ( $default_value_array ) { |
| 542 | 542 | // don't include a json placeholder |
| 543 | 543 | return; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 546 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 547 | 547 | |
| 548 | 548 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 549 | - // use HMTL5 placeholder with js fallback |
|
| 549 | + // use HMTL5 placeholder with js fallback |
|
| 550 | 550 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 551 | - wp_enqueue_script('jquery-placeholder'); |
|
| 552 | - } else if ( ! $frm_settings->use_html ) { |
|
| 551 | + wp_enqueue_script('jquery-placeholder'); |
|
| 552 | + } else if ( ! $frm_settings->use_html ) { |
|
| 553 | 553 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 554 | 554 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 555 | - $class[] = 'frm_toggle_default'; |
|
| 555 | + $class[] = 'frm_toggle_default'; |
|
| 556 | 556 | |
| 557 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 558 | - $class[] = 'frm_default'; |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - } |
|
| 557 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 558 | + $class[] = 'frm_default'; |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | 563 | private static function add_validation_messages( $field, array &$add_html ) { |
| 564 | 564 | if ( FrmField::is_required( $field ) ) { |
@@ -572,44 +572,44 @@ discard block |
||
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 576 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 577 | - return; |
|
| 578 | - } |
|
| 575 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 576 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 577 | + return; |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 581 | - if ( 'opt' === $k ) { |
|
| 582 | - continue; |
|
| 583 | - } |
|
| 580 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 581 | + if ( 'opt' === $k ) { |
|
| 582 | + continue; |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 586 | - $add_html[] = $v; |
|
| 587 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 585 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 586 | + $add_html[] = $v; |
|
| 587 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 588 | 588 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 589 | - } else { |
|
| 589 | + } else { |
|
| 590 | 590 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 591 | - } |
|
| 592 | - |
|
| 593 | - unset($k, $v); |
|
| 594 | - } |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 598 | - if ( is_array( $opt ) ) { |
|
| 599 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 600 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 601 | - } else { |
|
| 602 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - return $opt; |
|
| 606 | - } |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + unset($k, $v); |
|
| 594 | + } |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 598 | + if ( is_array( $opt ) ) { |
|
| 599 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 600 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 601 | + } else { |
|
| 602 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + return $opt; |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | public static function check_label( $opt ) { |
| 609 | - if ( is_array($opt) ) { |
|
| 610 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 611 | - } |
|
| 609 | + if ( is_array($opt) ) { |
|
| 610 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - return $opt; |
|
| 614 | - } |
|
| 613 | + return $opt; |
|
| 614 | + } |
|
| 615 | 615 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | 5 | public static function load_field() { |
| 6 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 6 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 7 | 7 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 8 | 8 | |
| 9 | 9 | $fields = $_POST['field']; |
@@ -34,17 +34,17 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 38 | 38 | |
| 39 | 39 | ob_start(); |
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + $field_html[$field_id] = ob_get_contents(); |
|
| 42 | 42 | ob_end_clean(); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset( $path ); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode( $field_html ); |
|
| 48 | 48 | |
| 49 | 49 | wp_die(); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | 55 | public static function create() { |
| 56 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 56 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 57 | 57 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $field = self::include_new_field( $field_type, $form_id ); |
| 63 | 63 | |
| 64 | 64 | // this hook will allow for multiple fields to be added at once |
| 65 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + do_action( 'frm_after_field_created', $field, $form_id ); |
|
| 66 | 66 | |
| 67 | 67 | wp_die(); |
| 68 | 68 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | public static function include_new_field( $field_type, $form_id ) { |
| 78 | 78 | $values = array(); |
| 79 | 79 | if ( FrmAppHelper::pro_is_installed() ) { |
| 80 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 80 | + $values['post_type'] = FrmProFormsHelper::post_type( $form_id ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
@@ -89,27 +89,27 @@ discard block |
||
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 92 | + $field = self::include_single_field( $field_id, $values, $form_id ); |
|
| 93 | 93 | |
| 94 | 94 | return $field; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public static function edit_name( $field = 'name', $id = '' ) { |
| 98 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 98 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 99 | 99 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 100 | 100 | |
| 101 | - if ( empty($field) ) { |
|
| 101 | + if ( empty( $field ) ) { |
|
| 102 | 102 | $field = 'name'; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( empty($id) ) { |
|
| 105 | + if ( empty( $id ) ) { |
|
| 106 | 106 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 107 | 107 | $id = str_replace( 'field_label_', '', $id ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 111 | 111 | $value = trim( $value ); |
| 112 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 112 | + if ( trim( strip_tags( $value ) ) == '' ) { |
|
| 113 | 113 | // set blank value if there is no content |
| 114 | 114 | $value = ''; |
| 115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | public static function update_ajax_option() { |
| 126 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 126 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 127 | 127 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 128 | 128 | |
| 129 | 129 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | if ( isset( $_POST['separate_value'] ) ) { |
| 137 | 137 | $new_val = FrmField::is_option_true( $field, 'separate_value' ) ? 0 : 1; |
| 138 | 138 | $field->field_options['separate_value'] = $new_val; |
| 139 | - unset($new_val); |
|
| 139 | + unset( $new_val ); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | FrmField::update( $field_id, array( |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | public static function duplicate() { |
| 150 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 150 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 151 | 151 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 152 | 152 | |
| 153 | 153 | global $wpdb; |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | wp_die(); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - self::include_single_field($field_id, $values); |
|
| 180 | + self::include_single_field( $field_id, $values ); |
|
| 181 | 181 | |
| 182 | 182 | wp_die(); |
| 183 | 183 | } |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * Load a single field in the form builder along with all needed variables |
| 187 | 187 | */ |
| 188 | 188 | public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
| 189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 189 | + $field = FrmFieldsHelper::setup_edit_vars( FrmField::getOne( $field_id ) ); |
|
| 190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
| 191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 191 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 192 | 192 | $id = $form_id ? $form_id : $field['form_id']; |
| 193 | 193 | if ( $field['type'] == 'html' ) { |
| 194 | 194 | $field['stop_filter'] = true; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public static function destroy() { |
| 203 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 203 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 204 | 204 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 205 | 205 | |
| 206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
@@ -212,14 +212,14 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | //Add Single Option or Other Option |
| 214 | 214 | public static function add_option() { |
| 215 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 215 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 216 | 216 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 217 | 217 | |
| 218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 220 | 220 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'absint' ); |
| 221 | 221 | |
| 222 | - $field = FrmField::getOne($id); |
|
| 222 | + $field = FrmField::getOne( $id ); |
|
| 223 | 223 | |
| 224 | 224 | if ( 'other' == $opt_type ) { |
| 225 | 225 | $opt = __( 'Other', 'formidable' ); |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
| 291 | 291 | $prepop = array(); |
| 292 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 292 | + FrmFieldsHelper::get_bulk_prefilled_opts( $prepop ); |
|
| 293 | 293 | |
| 294 | - $field = FrmField::getOne($field_id); |
|
| 294 | + $field = FrmField::getOne( $field_id ); |
|
| 295 | 295 | |
| 296 | 296 | wp_enqueue_script( 'utils' ); |
| 297 | 297 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
@@ -302,35 +302,35 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | public static function import_options() { |
| 305 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 305 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 306 | 306 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 307 | 307 | |
| 308 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 308 | + if ( ! is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 309 | 309 | return; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $field_id = absint( $_POST['field_id'] ); |
| 313 | - $field = FrmField::getOne($field_id); |
|
| 313 | + $field = FrmField::getOne( $field_id ); |
|
| 314 | 314 | |
| 315 | 315 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 316 | 316 | return; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 319 | + $field = FrmFieldsHelper::setup_edit_vars( $field ); |
|
| 320 | 320 | $opts = FrmAppHelper::get_param( 'opts', '', 'post', 'wp_kses_post' ); |
| 321 | 321 | $opts = explode( "\n", rtrim( $opts, "\n" ) ); |
| 322 | 322 | $opts = array_map( 'trim', $opts ); |
| 323 | 323 | |
| 324 | 324 | if ( $field['separate_value'] ) { |
| 325 | 325 | foreach ( $opts as $opt_key => $opt ) { |
| 326 | - if ( strpos($opt, '|') !== false ) { |
|
| 327 | - $vals = explode('|', $opt); |
|
| 326 | + if ( strpos( $opt, '|' ) !== false ) { |
|
| 327 | + $vals = explode( '|', $opt ); |
|
| 328 | 328 | if ( $vals[0] != $vals[1] ) { |
| 329 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 329 | + $opts[$opt_key] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 330 | 330 | } |
| 331 | - unset($vals); |
|
| 331 | + unset( $vals ); |
|
| 332 | 332 | } |
| 333 | - unset($opt_key, $opt); |
|
| 333 | + unset( $opt_key, $opt ); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | $other_array = array(); |
| 340 | 340 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 341 | 341 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 342 | - $other_array[ $opt_key ] = $opt; |
|
| 342 | + $other_array[$opt_key] = $opt; |
|
| 343 | 343 | } |
| 344 | - unset($opt_key, $opt); |
|
| 344 | + unset( $opt_key, $opt ); |
|
| 345 | 345 | } |
| 346 | - if ( ! empty($other_array) ) { |
|
| 347 | - $opts = array_merge( $opts, $other_array); |
|
| 346 | + if ( ! empty( $other_array ) ) { |
|
| 347 | + $opts = array_merge( $opts, $other_array ); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
@@ -358,14 +358,14 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 360 | 360 | } else { |
| 361 | - FrmFieldsHelper::show_single_option($field); |
|
| 361 | + FrmFieldsHelper::show_single_option( $field ); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | wp_die(); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | public static function update_order() { |
| 368 | - FrmAppHelper::permission_check('frm_edit_forms'); |
|
| 368 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); |
|
| 369 | 369 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 370 | 370 | |
| 371 | 371 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | 'rte' => 'textarea', |
| 383 | 383 | 'website' => 'url', |
| 384 | 384 | ); |
| 385 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 386 | - $type = $type_switch[ $type ]; |
|
| 385 | + if ( isset( $type_switch[$type] ) ) { |
|
| 386 | + $type = $type_switch[$type]; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $pro_fields = FrmField::pro_field_selection(); |
@@ -427,19 +427,19 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | public static function input_html( $field, $echo = true ) { |
| 429 | 429 | $class = array(); //$field['type']; |
| 430 | - self::add_input_classes($field, $class); |
|
| 430 | + self::add_input_classes( $field, $class ); |
|
| 431 | 431 | |
| 432 | 432 | $add_html = array(); |
| 433 | - self::add_html_size($field, $add_html); |
|
| 434 | - self::add_html_length($field, $add_html); |
|
| 435 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 433 | + self::add_html_size( $field, $add_html ); |
|
| 434 | + self::add_html_length( $field, $add_html ); |
|
| 435 | + self::add_html_placeholder( $field, $add_html, $class ); |
|
| 436 | 436 | self::add_validation_messages( $field, $add_html ); |
| 437 | 437 | |
| 438 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 438 | + $class = apply_filters( 'frm_field_classes', implode( ' ', $class ), $field ); |
|
| 439 | 439 | |
| 440 | 440 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 441 | 441 | |
| 442 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 442 | + self::add_shortcodes_to_html( $field, $add_html ); |
|
| 443 | 443 | |
| 444 | 444 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 445 | 445 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | private static function add_input_classes( $field, array &$class ) { |
| 455 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 455 | + if ( isset( $field['input_class'] ) && ! empty( $field['input_class'] ) ) { |
|
| 456 | 456 | $class[] = $field['input_class']; |
| 457 | 457 | } |
| 458 | 458 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 463 | + if ( isset( $field['size'] ) && $field['size'] > 0 ) { |
|
| 464 | 464 | $class[] = 'auto_width'; |
| 465 | 465 | } |
| 466 | 466 | } |
@@ -470,19 +470,19 @@ discard block |
||
| 470 | 470 | return; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 473 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 474 | 474 | return; |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - if ( is_numeric($field['size']) ) { |
|
| 477 | + if ( is_numeric( $field['size'] ) ) { |
|
| 478 | 478 | $field['size'] .= 'px'; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 481 | + $important = apply_filters( 'frm_use_important_width', 1, $field ); |
|
| 482 | 482 | // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
| 483 | 483 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 484 | 484 | |
| 485 | - self::add_html_cols($field, $add_html); |
|
| 485 | + self::add_html_cols( $field, $add_html ); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | private static function add_html_cols( $field, array &$add_html ) { |
@@ -499,13 +499,13 @@ discard block |
||
| 499 | 499 | ); |
| 500 | 500 | |
| 501 | 501 | // include "col" for valid html |
| 502 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 502 | + $unit = trim( preg_replace( '/[0-9]+/', '', $field['size'] ) ); |
|
| 503 | 503 | |
| 504 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 504 | + if ( ! isset( $calc[$unit] ) ) { |
|
| 505 | 505 | return; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 508 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[$unit]; |
|
| 509 | 509 | |
| 510 | 510 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 511 | 511 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | return; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 519 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 520 | 520 | // don't load on form builder page |
| 521 | 521 | return; |
| 522 | 522 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 549 | 549 | // use HMTL5 placeholder with js fallback |
| 550 | 550 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 551 | - wp_enqueue_script('jquery-placeholder'); |
|
| 551 | + wp_enqueue_script( 'jquery-placeholder' ); |
|
| 552 | 552 | } else if ( ! $frm_settings->use_html ) { |
| 553 | 553 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 554 | 554 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
@@ -582,15 +582,15 @@ discard block |
||
| 582 | 582 | continue; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 585 | + if ( is_numeric( $k ) && strpos( $v, '=' ) ) { |
|
| 586 | 586 | $add_html[] = $v; |
| 587 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 588 | - $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
|
| 587 | + } else if ( ! empty( $k ) && isset( $add_html[$k] ) ) { |
|
| 588 | + $add_html[$k] = str_replace( $k . '="', $k . '="' . $v, $add_html[$k] ); |
|
| 589 | 589 | } else { |
| 590 | - $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 590 | + $add_html[$k] = $k . '="' . esc_attr( $v ) . '"'; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - unset($k, $v); |
|
| 593 | + unset( $k, $v ); |
|
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
@@ -606,8 +606,8 @@ discard block |
||
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | public static function check_label( $opt ) { |
| 609 | - if ( is_array($opt) ) { |
|
| 610 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 609 | + if ( is_array( $opt ) ) { |
|
| 610 | + $opt = ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | return $opt; |
@@ -7,71 +7,71 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | - |
|
| 17 | - $values = array(); |
|
| 18 | - |
|
| 19 | - foreach ( $defaults as $var => $default ) { |
|
| 20 | - if ( $var == 'field_options' ) { |
|
| 21 | - $values['field_options'] = array(); |
|
| 22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $values[ $var ] = $default; |
|
| 28 | - } |
|
| 29 | - unset($var, $default); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | - $values['field_options']['data_type'] = $setting; |
|
| 35 | - } else { |
|
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | - $values['options'] = serialize( array( |
|
| 42 | - __( 'Option 1', 'formidable' ), |
|
| 43 | - __( 'Option 2', 'formidable' ), |
|
| 44 | - ) ); |
|
| 45 | - } else if ( $type == 'select' ) { |
|
| 46 | - $values['options'] = serialize( array( |
|
| 47 | - '', __( 'Option 1', 'formidable' ), |
|
| 48 | - ) ); |
|
| 49 | - } else if ( $type == 'textarea' ) { |
|
| 50 | - $values['field_options']['max'] = '5'; |
|
| 51 | - } else if ( $type == 'captcha' ) { |
|
| 52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | - $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | - } else if ( 'url' == $type ) { |
|
| 55 | - $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | - } |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | + |
|
| 17 | + $values = array(); |
|
| 18 | + |
|
| 19 | + foreach ( $defaults as $var => $default ) { |
|
| 20 | + if ( $var == 'field_options' ) { |
|
| 21 | + $values['field_options'] = array(); |
|
| 22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | + unset($opt_var, $opt_default); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $values[ $var ] = $default; |
|
| 28 | + } |
|
| 29 | + unset($var, $default); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | + $values['field_options']['data_type'] = $setting; |
|
| 35 | + } else { |
|
| 36 | + $values['field_options'][ $setting ] = 1; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | + $values['options'] = serialize( array( |
|
| 42 | + __( 'Option 1', 'formidable' ), |
|
| 43 | + __( 'Option 2', 'formidable' ), |
|
| 44 | + ) ); |
|
| 45 | + } else if ( $type == 'select' ) { |
|
| 46 | + $values['options'] = serialize( array( |
|
| 47 | + '', __( 'Option 1', 'formidable' ), |
|
| 48 | + ) ); |
|
| 49 | + } else if ( $type == 'textarea' ) { |
|
| 50 | + $values['field_options']['max'] = '5'; |
|
| 51 | + } else if ( $type == 'captcha' ) { |
|
| 52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | + $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | + } else if ( 'url' == $type ) { |
|
| 55 | + $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $fields = FrmField::field_selection(); |
| 59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 59 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 60 | 60 | |
| 61 | - if ( isset( $fields[ $type ] ) ) { |
|
| 62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | - } |
|
| 61 | + if ( isset( $fields[ $type ] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset($fields); |
|
| 66 | 66 | |
| 67 | - return $values; |
|
| 68 | - } |
|
| 67 | + return $values; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | public static function get_html_id( $field, $plus = '' ) { |
| 71 | 71 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 74 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 75 | 75 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
| 76 | 76 | $defaults = array( |
| 77 | 77 | 'name' => $record->name, |
@@ -84,86 +84,86 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | if ( $doing_ajax ) { |
| 87 | - $values = $values + $defaults; |
|
| 88 | - $values['form_name'] = ''; |
|
| 87 | + $values = $values + $defaults; |
|
| 88 | + $values['form_name'] = ''; |
|
| 89 | 89 | } else { |
| 90 | 90 | foreach ( $defaults as $var => $default ) { |
| 91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | - unset($var, $default); |
|
| 93 | - } |
|
| 91 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset($var, $default); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | unset( $defaults ); |
| 99 | 99 | |
| 100 | - $values['options'] = $record->options; |
|
| 101 | - $values['field_options'] = $record->field_options; |
|
| 100 | + $values['options'] = $record->options; |
|
| 101 | + $values['field_options'] = $record->field_options; |
|
| 102 | 102 | |
| 103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 103 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 104 | 104 | |
| 105 | 105 | if ( $values['type'] == 'captcha' ) { |
| 106 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | - } |
|
| 106 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | foreach ( $defaults as $opt => $default ) { |
| 111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | - unset($opt, $default); |
|
| 113 | - } |
|
| 111 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | + unset($opt, $default); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 115 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 116 | 116 | |
| 117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | - $field_options = array( |
|
| 122 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 120 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | + $field_options = array( |
|
| 122 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 125 | 125 | 'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light', |
| 126 | - ); |
|
| 126 | + ); |
|
| 127 | 127 | |
| 128 | 128 | if ( $limit ) { |
| 129 | - return $field_options; |
|
| 129 | + return $field_options; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - global $wpdb; |
|
| 132 | + global $wpdb; |
|
| 133 | 133 | |
| 134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 134 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | 135 | |
| 136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 137 | 137 | |
| 138 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 138 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 139 | 139 | |
| 140 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | - return array( |
|
| 142 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 140 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | + return array( |
|
| 142 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 143 | 143 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
| 144 | 144 | 'field_order' => $field_count + 1, 'required' => false, |
| 145 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 145 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 147 | 147 | 'field_options' => $field_options, |
| 148 | - ); |
|
| 149 | - } |
|
| 148 | + ); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | - global $wpdb; |
|
| 151 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | + global $wpdb; |
|
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | - $values['form_id'] = $form_id; |
|
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | - |
|
| 159 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @since 2.0 |
|
| 166 | - */ |
|
| 155 | + $values['form_id'] = $form_id; |
|
| 156 | + $values['options'] = maybe_serialize($field->options); |
|
| 157 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | + |
|
| 159 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | + $values[ $col ] = $field->{$col}; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @since 2.0 |
|
| 166 | + */ |
|
| 167 | 167 | public static function get_error_msg( $field, $error ) { |
| 168 | 168 | $frm_settings = FrmAppHelper::get_settings(); |
| 169 | 169 | $default_settings = $frm_settings->default_options(); |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | public static function get_default_html( $type = 'text' ) { |
| 193 | 193 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 194 | 194 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 195 | - $for = ''; |
|
| 195 | + $for = ''; |
|
| 196 | 196 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 197 | - $for = 'for="field_[key]"'; |
|
| 198 | - } |
|
| 197 | + $for = 'for="field_[key]"'; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $default_html = <<<DEFAULT_HTML |
|
| 200 | + $default_html = <<<DEFAULT_HTML |
|
| 201 | 201 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 202 | 202 | <label $for class="frm_primary_label">[field_name] |
| 203 | 203 | <span class="frm_required">[required_label]</span> |
@@ -207,82 +207,82 @@ discard block |
||
| 207 | 207 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | - } else { |
|
| 210 | + } else { |
|
| 211 | 211 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | - } |
|
| 214 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 219 | 219 | |
| 220 | - $defaults = array( |
|
| 220 | + $defaults = array( |
|
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 222 | 222 | 'field_id' => $field['id'], |
| 223 | - 'field_plus_id' => '', |
|
| 224 | - 'section_id' => '', |
|
| 225 | - ); |
|
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 227 | - $field_name = $args['field_name']; |
|
| 228 | - $field_id = $args['field_id']; |
|
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 223 | + 'field_plus_id' => '', |
|
| 224 | + 'section_id' => '', |
|
| 225 | + ); |
|
| 226 | + $args = wp_parse_args($args, $defaults); |
|
| 227 | + $field_name = $args['field_name']; |
|
| 228 | + $field_id = $args['field_id']; |
|
| 229 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | - $field_name .= '[]'; |
|
| 233 | - } |
|
| 231 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | + $field_name .= '[]'; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - //replace [id] |
|
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 235 | + //replace [id] |
|
| 236 | + $html = str_replace('[id]', $field_id, $html); |
|
| 237 | 237 | |
| 238 | - // Remove the for attribute for captcha |
|
| 239 | - if ( $field['type'] == 'captcha' ) { |
|
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | - } |
|
| 238 | + // Remove the for attribute for captcha |
|
| 239 | + if ( $field['type'] == 'captcha' ) { |
|
| 240 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - // set the label for |
|
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 243 | + // set the label for |
|
| 244 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 245 | 245 | |
| 246 | - //replace [key] |
|
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 246 | + //replace [key] |
|
| 247 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 248 | 248 | |
| 249 | - //replace [description] and [required_label] and [error] |
|
| 249 | + //replace [description] and [required_label] and [error] |
|
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | - if ( ! is_array( $errors ) ) { |
|
| 252 | - $errors = array(); |
|
| 253 | - } |
|
| 251 | + if ( ! is_array( $errors ) ) { |
|
| 252 | + $errors = array(); |
|
| 253 | + } |
|
| 254 | 254 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 255 | 255 | |
| 256 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | - if ( $field['type'] == 'divider' ) { |
|
| 258 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | - } else { |
|
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | - } |
|
| 263 | - } |
|
| 256 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | + if ( $field['type'] == 'divider' ) { |
|
| 258 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | + } else { |
|
| 261 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
| 266 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | - } |
|
| 266 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - //replace [required_class] |
|
| 269 | + //replace [required_class] |
|
| 270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 272 | 272 | |
| 273 | - //replace [label_position] |
|
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 273 | + //replace [label_position] |
|
| 274 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 277 | 277 | |
| 278 | - //replace [field_name] |
|
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 278 | + //replace [field_name] |
|
| 279 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | - //replace [entry_key] |
|
| 284 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 283 | + //replace [entry_key] |
|
| 284 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 286 | 286 | |
| 287 | 287 | if ( $form ) { |
| 288 | 288 | $form = (array) $form; |
@@ -296,57 +296,57 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | self::process_wp_shortcodes( $html ); |
| 298 | 298 | |
| 299 | - //replace [input] |
|
| 300 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | - global $frm_vars; |
|
| 302 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 299 | + //replace [input] |
|
| 300 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | + global $frm_vars; |
|
| 302 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 303 | 303 | |
| 304 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 304 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 306 | 306 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 307 | 307 | |
| 308 | - $replace_with = ''; |
|
| 308 | + $replace_with = ''; |
|
| 309 | 309 | |
| 310 | - if ( $tag == 'input' ) { |
|
| 311 | - if ( isset($atts['opt']) ) { |
|
| 312 | - $atts['opt']--; |
|
| 313 | - } |
|
| 310 | + if ( $tag == 'input' ) { |
|
| 311 | + if ( isset($atts['opt']) ) { |
|
| 312 | + $atts['opt']--; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | - if ( isset($atts['class']) ) { |
|
| 317 | - unset($atts['class']); |
|
| 318 | - } |
|
| 315 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | + if ( isset($atts['class']) ) { |
|
| 317 | + unset($atts['class']); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - $field['shortcodes'] = $atts; |
|
| 321 | - ob_start(); |
|
| 320 | + $field['shortcodes'] = $atts; |
|
| 321 | + ob_start(); |
|
| 322 | 322 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 323 | - $replace_with = ob_get_contents(); |
|
| 324 | - ob_end_clean(); |
|
| 325 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | - } |
|
| 323 | + $replace_with = ob_get_contents(); |
|
| 324 | + ob_end_clean(); |
|
| 325 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | - } |
|
| 329 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - $html .= "\n"; |
|
| 332 | + $html .= "\n"; |
|
| 333 | 333 | |
| 334 | - //Return html if conf_field to prevent loop |
|
| 335 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | - return $html; |
|
| 337 | - } |
|
| 334 | + //Return html if conf_field to prevent loop |
|
| 335 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | + return $html; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - //If field is in repeating section |
|
| 340 | - if ( $args['section_id'] ) { |
|
| 341 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | - } else { |
|
| 343 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | - } |
|
| 339 | + //If field is in repeating section |
|
| 340 | + if ( $args['section_id'] ) { |
|
| 341 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | + } else { |
|
| 343 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | self::remove_collapse_shortcode( $html ); |
| 347 | 347 | |
| 348 | - return $html; |
|
| 349 | - } |
|
| 348 | + return $html; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * This filters shortcodes in the field HTML |
@@ -411,46 +411,46 @@ discard block |
||
| 411 | 411 | return $classes; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 415 | - if ( $no_vars ) { |
|
| 414 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 415 | + if ( $no_vars ) { |
|
| 416 | 416 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 417 | 417 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 418 | - } else { |
|
| 418 | + } else { |
|
| 419 | 419 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 420 | - } |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 423 | - } |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 426 | 426 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 427 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 428 | - $args['conditional_check'] = true; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - $prefix = ''; |
|
| 432 | - if ( $args['conditional_check'] ) { |
|
| 433 | - if ( $args['conditional'] ) { |
|
| 434 | - $prefix = 'if '; |
|
| 435 | - } else if ( $args['foreach'] ) { |
|
| 436 | - $prefix = 'foreach '; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 441 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 442 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 443 | - $tag = str_replace(']', '', $tag); |
|
| 444 | - $tags = explode(' ', $tag); |
|
| 445 | - if ( is_array($tags) ) { |
|
| 446 | - $tag = $tags[0]; |
|
| 447 | - } |
|
| 448 | - } else { |
|
| 449 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - return $tag; |
|
| 453 | - } |
|
| 427 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 428 | + $args['conditional_check'] = true; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + $prefix = ''; |
|
| 432 | + if ( $args['conditional_check'] ) { |
|
| 433 | + if ( $args['conditional'] ) { |
|
| 434 | + $prefix = 'if '; |
|
| 435 | + } else if ( $args['foreach'] ) { |
|
| 436 | + $prefix = 'foreach '; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 441 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 442 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 443 | + $tag = str_replace(']', '', $tag); |
|
| 444 | + $tags = explode(' ', $tag); |
|
| 445 | + if ( is_array($tags) ) { |
|
| 446 | + $tag = $tags[0]; |
|
| 447 | + } |
|
| 448 | + } else { |
|
| 449 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + return $tag; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | /** |
| 456 | 456 | * Remove [collapse_this] if it's still included after all processing |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 490 | 490 | |
| 491 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 492 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 491 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 492 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 493 | 493 | |
| 494 | 494 | // for reverse compatability |
| 495 | 495 | $field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size']; |
@@ -497,40 +497,40 @@ discard block |
||
| 497 | 497 | ?> |
| 498 | 498 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div> |
| 499 | 499 | <?php |
| 500 | - } |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | public static function show_single_option( $field ) { |
| 503 | - $field_name = $field['name']; |
|
| 504 | - $html_id = self::get_html_id($field); |
|
| 505 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 506 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 507 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 503 | + $field_name = $field['name']; |
|
| 504 | + $html_id = self::get_html_id($field); |
|
| 505 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 506 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 507 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 508 | 508 | |
| 509 | - // If this is an "Other" option, get the HTML for it |
|
| 509 | + // If this is an "Other" option, get the HTML for it |
|
| 510 | 510 | if ( self::is_other_opt( $opt_key ) ) { |
| 511 | - // Get string for Other text field, if needed |
|
| 511 | + // Get string for Other text field, if needed |
|
| 512 | 512 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 513 | 513 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 514 | - } else { |
|
| 514 | + } else { |
|
| 515 | 515 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 516 | - } |
|
| 517 | - } |
|
| 518 | - } |
|
| 516 | + } |
|
| 517 | + } |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | 520 | public static function get_term_link( $tax_id ) { |
| 521 | - $tax = get_taxonomy($tax_id); |
|
| 522 | - if ( ! $tax ) { |
|
| 523 | - return; |
|
| 524 | - } |
|
| 521 | + $tax = get_taxonomy($tax_id); |
|
| 522 | + if ( ! $tax ) { |
|
| 523 | + return; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - $link = sprintf( |
|
| 527 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 526 | + $link = sprintf( |
|
| 527 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 528 | 528 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 529 | - ); |
|
| 530 | - unset($tax); |
|
| 529 | + ); |
|
| 530 | + unset($tax); |
|
| 531 | 531 | |
| 532 | - return $link; |
|
| 533 | - } |
|
| 532 | + return $link; |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 536 | 536 | // Remove white space from hide_opt |
@@ -541,195 +541,195 @@ discard block |
||
| 541 | 541 | $observed_value = wp_kses_post( $observed_value ); |
| 542 | 542 | $hide_opt = wp_kses_post( $hide_opt ); |
| 543 | 543 | |
| 544 | - if ( is_array($observed_value) ) { |
|
| 545 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - $m = false; |
|
| 549 | - if ( $cond == '==' ) { |
|
| 550 | - $m = $observed_value == $hide_opt; |
|
| 551 | - } else if ( $cond == '!=' ) { |
|
| 552 | - $m = $observed_value != $hide_opt; |
|
| 553 | - } else if ( $cond == '>' ) { |
|
| 554 | - $m = $observed_value > $hide_opt; |
|
| 555 | - } else if ( $cond == '<' ) { |
|
| 556 | - $m = $observed_value < $hide_opt; |
|
| 557 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 558 | - $m = stripos($observed_value, $hide_opt); |
|
| 559 | - if ( $cond == 'not LIKE' ) { |
|
| 560 | - $m = ( $m === false ) ? true : false; |
|
| 561 | - } else { |
|
| 562 | - $m = ( $m === false ) ? false : true; |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - return $m; |
|
| 566 | - } |
|
| 544 | + if ( is_array($observed_value) ) { |
|
| 545 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + $m = false; |
|
| 549 | + if ( $cond == '==' ) { |
|
| 550 | + $m = $observed_value == $hide_opt; |
|
| 551 | + } else if ( $cond == '!=' ) { |
|
| 552 | + $m = $observed_value != $hide_opt; |
|
| 553 | + } else if ( $cond == '>' ) { |
|
| 554 | + $m = $observed_value > $hide_opt; |
|
| 555 | + } else if ( $cond == '<' ) { |
|
| 556 | + $m = $observed_value < $hide_opt; |
|
| 557 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 558 | + $m = stripos($observed_value, $hide_opt); |
|
| 559 | + if ( $cond == 'not LIKE' ) { |
|
| 560 | + $m = ( $m === false ) ? true : false; |
|
| 561 | + } else { |
|
| 562 | + $m = ( $m === false ) ? false : true; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + return $m; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 569 | - $m = false; |
|
| 570 | - if ( $cond == '==' ) { |
|
| 571 | - if ( is_array($hide_opt) ) { |
|
| 572 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 573 | - $m = empty($m) ? false : true; |
|
| 574 | - } else { |
|
| 575 | - $m = in_array($hide_opt, $observed_value); |
|
| 576 | - } |
|
| 577 | - } else if ( $cond == '!=' ) { |
|
| 578 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 579 | - } else if ( $cond == '>' ) { |
|
| 580 | - $min = min($observed_value); |
|
| 581 | - $m = $min > $hide_opt; |
|
| 582 | - } else if ( $cond == '<' ) { |
|
| 583 | - $max = max($observed_value); |
|
| 584 | - $m = $max < $hide_opt; |
|
| 585 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 586 | - foreach ( $observed_value as $ob ) { |
|
| 587 | - $m = strpos($ob, $hide_opt); |
|
| 588 | - if ( $m !== false ) { |
|
| 589 | - $m = true; |
|
| 590 | - break; |
|
| 591 | - } |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - if ( $cond == 'not LIKE' ) { |
|
| 595 | - $m = ( $m === false ) ? true : false; |
|
| 596 | - } |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - return $m; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * Replace a few basic shortcodes and field ids |
|
| 604 | - * @since 2.0 |
|
| 605 | - * @return string |
|
| 606 | - */ |
|
| 569 | + $m = false; |
|
| 570 | + if ( $cond == '==' ) { |
|
| 571 | + if ( is_array($hide_opt) ) { |
|
| 572 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 573 | + $m = empty($m) ? false : true; |
|
| 574 | + } else { |
|
| 575 | + $m = in_array($hide_opt, $observed_value); |
|
| 576 | + } |
|
| 577 | + } else if ( $cond == '!=' ) { |
|
| 578 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 579 | + } else if ( $cond == '>' ) { |
|
| 580 | + $min = min($observed_value); |
|
| 581 | + $m = $min > $hide_opt; |
|
| 582 | + } else if ( $cond == '<' ) { |
|
| 583 | + $max = max($observed_value); |
|
| 584 | + $m = $max < $hide_opt; |
|
| 585 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 586 | + foreach ( $observed_value as $ob ) { |
|
| 587 | + $m = strpos($ob, $hide_opt); |
|
| 588 | + if ( $m !== false ) { |
|
| 589 | + $m = true; |
|
| 590 | + break; |
|
| 591 | + } |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + if ( $cond == 'not LIKE' ) { |
|
| 595 | + $m = ( $m === false ) ? true : false; |
|
| 596 | + } |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + return $m; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * Replace a few basic shortcodes and field ids |
|
| 604 | + * @since 2.0 |
|
| 605 | + * @return string |
|
| 606 | + */ |
|
| 607 | 607 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 608 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 609 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 610 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 611 | - } |
|
| 608 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 609 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 610 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 614 | - $value = do_shortcode($value); |
|
| 613 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 614 | + $value = do_shortcode($value); |
|
| 615 | 615 | |
| 616 | - return $value; |
|
| 617 | - } |
|
| 616 | + return $value; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | public static function get_shortcodes( $content, $form_id ) { |
| 620 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 621 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 622 | - } |
|
| 620 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 621 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 624 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 625 | 625 | |
| 626 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 626 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 627 | 627 | |
| 628 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 628 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 629 | 629 | |
| 630 | - return $matches; |
|
| 631 | - } |
|
| 630 | + return $matches; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | public static function allowed_shortcodes( $fields = array() ) { |
| 634 | - $tagregexp = array( |
|
| 635 | - 'editlink', 'id', 'key', 'ip', |
|
| 636 | - 'siteurl', 'sitename', 'admin_email', |
|
| 637 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 634 | + $tagregexp = array( |
|
| 635 | + 'editlink', 'id', 'key', 'ip', |
|
| 636 | + 'siteurl', 'sitename', 'admin_email', |
|
| 637 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 638 | 638 | 'parent[-|_]id', |
| 639 | - ); |
|
| 639 | + ); |
|
| 640 | 640 | |
| 641 | - foreach ( $fields as $field ) { |
|
| 642 | - $tagregexp[] = $field->id; |
|
| 643 | - $tagregexp[] = $field->field_key; |
|
| 644 | - } |
|
| 641 | + foreach ( $fields as $field ) { |
|
| 642 | + $tagregexp[] = $field->id; |
|
| 643 | + $tagregexp[] = $field->field_key; |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - $tagregexp = implode('|', $tagregexp); |
|
| 647 | - return $tagregexp; |
|
| 648 | - } |
|
| 646 | + $tagregexp = implode('|', $tagregexp); |
|
| 647 | + return $tagregexp; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 651 | - $shortcode_values = array( |
|
| 652 | - 'id' => $entry->id, |
|
| 653 | - 'key' => $entry->item_key, |
|
| 654 | - 'ip' => $entry->ip, |
|
| 655 | - ); |
|
| 651 | + $shortcode_values = array( |
|
| 652 | + 'id' => $entry->id, |
|
| 653 | + 'key' => $entry->item_key, |
|
| 654 | + 'ip' => $entry->ip, |
|
| 655 | + ); |
|
| 656 | 656 | |
| 657 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 658 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 657 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 658 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 659 | 659 | |
| 660 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 660 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 661 | 661 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 662 | - $tags = explode(' ', $tag); |
|
| 663 | - if ( is_array($tags) ) { |
|
| 664 | - $tag = $tags[0]; |
|
| 665 | - } |
|
| 666 | - } else { |
|
| 667 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - switch ( $tag ) { |
|
| 671 | - case 'id': |
|
| 672 | - case 'key': |
|
| 673 | - case 'ip': |
|
| 674 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 675 | - break; |
|
| 676 | - |
|
| 677 | - case 'user_agent': |
|
| 678 | - case 'user-agent': |
|
| 679 | - $entry->description = maybe_unserialize($entry->description); |
|
| 662 | + $tags = explode(' ', $tag); |
|
| 663 | + if ( is_array($tags) ) { |
|
| 664 | + $tag = $tags[0]; |
|
| 665 | + } |
|
| 666 | + } else { |
|
| 667 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + switch ( $tag ) { |
|
| 671 | + case 'id': |
|
| 672 | + case 'key': |
|
| 673 | + case 'ip': |
|
| 674 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 675 | + break; |
|
| 676 | + |
|
| 677 | + case 'user_agent': |
|
| 678 | + case 'user-agent': |
|
| 679 | + $entry->description = maybe_unserialize($entry->description); |
|
| 680 | 680 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 681 | - break; |
|
| 682 | - |
|
| 683 | - case 'created_at': |
|
| 684 | - case 'created-at': |
|
| 685 | - case 'updated_at': |
|
| 686 | - case 'updated-at': |
|
| 687 | - if ( isset($atts['format']) ) { |
|
| 688 | - $time_format = ' '; |
|
| 689 | - } else { |
|
| 690 | - $atts['format'] = get_option('date_format'); |
|
| 691 | - $time_format = ''; |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - $this_tag = str_replace('-', '_', $tag); |
|
| 695 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 696 | - unset($this_tag); |
|
| 697 | - break; |
|
| 698 | - |
|
| 699 | - case 'created_by': |
|
| 700 | - case 'created-by': |
|
| 701 | - case 'updated_by': |
|
| 702 | - case 'updated-by': |
|
| 703 | - $this_tag = str_replace('-', '_', $tag); |
|
| 681 | + break; |
|
| 682 | + |
|
| 683 | + case 'created_at': |
|
| 684 | + case 'created-at': |
|
| 685 | + case 'updated_at': |
|
| 686 | + case 'updated-at': |
|
| 687 | + if ( isset($atts['format']) ) { |
|
| 688 | + $time_format = ' '; |
|
| 689 | + } else { |
|
| 690 | + $atts['format'] = get_option('date_format'); |
|
| 691 | + $time_format = ''; |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + $this_tag = str_replace('-', '_', $tag); |
|
| 695 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 696 | + unset($this_tag); |
|
| 697 | + break; |
|
| 698 | + |
|
| 699 | + case 'created_by': |
|
| 700 | + case 'created-by': |
|
| 701 | + case 'updated_by': |
|
| 702 | + case 'updated-by': |
|
| 703 | + $this_tag = str_replace('-', '_', $tag); |
|
| 704 | 704 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 705 | - unset($this_tag); |
|
| 706 | - break; |
|
| 707 | - |
|
| 708 | - case 'admin_email': |
|
| 709 | - case 'siteurl': |
|
| 710 | - case 'frmurl': |
|
| 711 | - case 'sitename': |
|
| 712 | - case 'get': |
|
| 713 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 714 | - break; |
|
| 715 | - |
|
| 716 | - default: |
|
| 717 | - $field = FrmField::getOne( $tag ); |
|
| 718 | - if ( ! $field ) { |
|
| 719 | - break; |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 723 | - |
|
| 724 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 725 | - |
|
| 726 | - $atts['entry_id'] = $entry->id; |
|
| 727 | - $atts['entry_key'] = $entry->item_key; |
|
| 728 | - |
|
| 729 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 730 | - $replace_with = $field->name; |
|
| 731 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 732 | - $replace_with = $field->description; |
|
| 705 | + unset($this_tag); |
|
| 706 | + break; |
|
| 707 | + |
|
| 708 | + case 'admin_email': |
|
| 709 | + case 'siteurl': |
|
| 710 | + case 'frmurl': |
|
| 711 | + case 'sitename': |
|
| 712 | + case 'get': |
|
| 713 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 714 | + break; |
|
| 715 | + |
|
| 716 | + default: |
|
| 717 | + $field = FrmField::getOne( $tag ); |
|
| 718 | + if ( ! $field ) { |
|
| 719 | + break; |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 723 | + |
|
| 724 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 725 | + |
|
| 726 | + $atts['entry_id'] = $entry->id; |
|
| 727 | + $atts['entry_key'] = $entry->item_key; |
|
| 728 | + |
|
| 729 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 730 | + $replace_with = $field->name; |
|
| 731 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 732 | + $replace_with = $field->description; |
|
| 733 | 733 | } else { |
| 734 | 734 | $string_value = $replace_with; |
| 735 | 735 | if ( is_array( $replace_with ) ) { |
@@ -743,82 +743,82 @@ discard block |
||
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - unset($field); |
|
| 747 | - break; |
|
| 748 | - } |
|
| 746 | + unset($field); |
|
| 747 | + break; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - if ( isset($replace_with) ) { |
|
| 751 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 752 | - } |
|
| 750 | + if ( isset($replace_with) ) { |
|
| 751 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - unset($atts, $conditional, $replace_with); |
|
| 754 | + unset($atts, $conditional, $replace_with); |
|
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | return $content; |
| 758 | - } |
|
| 759 | - |
|
| 760 | - /** |
|
| 761 | - * Get the value to replace a few standard shortcodes |
|
| 762 | - * |
|
| 763 | - * @since 2.0 |
|
| 764 | - * @return string |
|
| 765 | - */ |
|
| 766 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 767 | - $new_value = ''; |
|
| 768 | - switch ( $tag ) { |
|
| 769 | - case 'admin_email': |
|
| 770 | - $new_value = get_option('admin_email'); |
|
| 771 | - break; |
|
| 772 | - case 'siteurl': |
|
| 773 | - $new_value = FrmAppHelper::site_url(); |
|
| 774 | - break; |
|
| 775 | - case 'frmurl': |
|
| 776 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 777 | - break; |
|
| 778 | - case 'sitename': |
|
| 779 | - $new_value = FrmAppHelper::site_name(); |
|
| 780 | - break; |
|
| 781 | - case 'get': |
|
| 782 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 783 | - break; |
|
| 784 | - } |
|
| 785 | - |
|
| 786 | - return $new_value; |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - /** |
|
| 790 | - * Process the [get] shortcode |
|
| 791 | - * |
|
| 792 | - * @since 2.0 |
|
| 793 | - * @return string|array |
|
| 794 | - */ |
|
| 795 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 796 | - if ( ! isset($atts['param']) ) { |
|
| 797 | - return ''; |
|
| 798 | - } |
|
| 799 | - |
|
| 800 | - if ( strpos($atts['param'], '[') ) { |
|
| 801 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 802 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 806 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 807 | - |
|
| 808 | - if ( $new_value == '' ) { |
|
| 809 | - if ( ! isset($atts['prev_val']) ) { |
|
| 810 | - $atts['prev_val'] = ''; |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 817 | - $new_value = implode(', ', $new_value); |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - return $new_value; |
|
| 821 | - } |
|
| 758 | + } |
|
| 759 | + |
|
| 760 | + /** |
|
| 761 | + * Get the value to replace a few standard shortcodes |
|
| 762 | + * |
|
| 763 | + * @since 2.0 |
|
| 764 | + * @return string |
|
| 765 | + */ |
|
| 766 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 767 | + $new_value = ''; |
|
| 768 | + switch ( $tag ) { |
|
| 769 | + case 'admin_email': |
|
| 770 | + $new_value = get_option('admin_email'); |
|
| 771 | + break; |
|
| 772 | + case 'siteurl': |
|
| 773 | + $new_value = FrmAppHelper::site_url(); |
|
| 774 | + break; |
|
| 775 | + case 'frmurl': |
|
| 776 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 777 | + break; |
|
| 778 | + case 'sitename': |
|
| 779 | + $new_value = FrmAppHelper::site_name(); |
|
| 780 | + break; |
|
| 781 | + case 'get': |
|
| 782 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 783 | + break; |
|
| 784 | + } |
|
| 785 | + |
|
| 786 | + return $new_value; |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * Process the [get] shortcode |
|
| 791 | + * |
|
| 792 | + * @since 2.0 |
|
| 793 | + * @return string|array |
|
| 794 | + */ |
|
| 795 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 796 | + if ( ! isset($atts['param']) ) { |
|
| 797 | + return ''; |
|
| 798 | + } |
|
| 799 | + |
|
| 800 | + if ( strpos($atts['param'], '[') ) { |
|
| 801 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 802 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 806 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 807 | + |
|
| 808 | + if ( $new_value == '' ) { |
|
| 809 | + if ( ! isset($atts['prev_val']) ) { |
|
| 810 | + $atts['prev_val'] = ''; |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 817 | + $new_value = implode(', ', $new_value); |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + return $new_value; |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | 823 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 824 | 824 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -826,14 +826,14 @@ discard block |
||
| 826 | 826 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 827 | 827 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 828 | 828 | |
| 829 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 830 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 831 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 832 | - if ( is_array($replace_with) ) { |
|
| 833 | - $replace_with = implode("\n", $replace_with); |
|
| 834 | - } |
|
| 835 | - $replace_with = wpautop($replace_with); |
|
| 836 | - } |
|
| 829 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 830 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 831 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 832 | + if ( is_array($replace_with) ) { |
|
| 833 | + $replace_with = implode("\n", $replace_with); |
|
| 834 | + } |
|
| 835 | + $replace_with = wpautop($replace_with); |
|
| 836 | + } |
|
| 837 | 837 | unset( $autop ); |
| 838 | 838 | } else if ( is_array( $replace_with ) ) { |
| 839 | 839 | $replace_with = implode( $sep, $replace_with ); |
@@ -843,37 +843,37 @@ discard block |
||
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | public static function get_field_types( $type ) { |
| 846 | - $single_input = array( |
|
| 847 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 848 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 849 | - 'user_id', 'tag', 'password', |
|
| 850 | - ); |
|
| 846 | + $single_input = array( |
|
| 847 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 848 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 849 | + 'user_id', 'tag', 'password', |
|
| 850 | + ); |
|
| 851 | 851 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 852 | 852 | $other_type = array( 'html', 'break' ); |
| 853 | 853 | |
| 854 | 854 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 855 | 855 | |
| 856 | - $field_types = array(); |
|
| 857 | - if ( in_array($type, $single_input) ) { |
|
| 858 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 859 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 860 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 861 | - } else if ( in_array($type, $other_type) ) { |
|
| 862 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 856 | + $field_types = array(); |
|
| 857 | + if ( in_array($type, $single_input) ) { |
|
| 858 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 859 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 860 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 861 | + } else if ( in_array($type, $other_type) ) { |
|
| 862 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 863 | 863 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 864 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 865 | - } |
|
| 864 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 865 | + } |
|
| 866 | 866 | |
| 867 | 867 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 868 | - return $field_types; |
|
| 869 | - } |
|
| 868 | + return $field_types; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 872 | - foreach ( $inputs as $input ) { |
|
| 873 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 874 | - unset($input); |
|
| 875 | - } |
|
| 876 | - } |
|
| 871 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 872 | + foreach ( $inputs as $input ) { |
|
| 873 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 874 | + unset($input); |
|
| 875 | + } |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | 878 | /** |
| 879 | 879 | * Check if current field option is an "other" option |
@@ -887,14 +887,14 @@ discard block |
||
| 887 | 887 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - /** |
|
| 891 | - * Get value that belongs in "Other" text box |
|
| 892 | - * |
|
| 893 | - * @since 2.0.6 |
|
| 894 | - * |
|
| 895 | - * @param array $args |
|
| 896 | - */ |
|
| 897 | - public static function get_other_val( $args ) { |
|
| 890 | + /** |
|
| 891 | + * Get value that belongs in "Other" text box |
|
| 892 | + * |
|
| 893 | + * @since 2.0.6 |
|
| 894 | + * |
|
| 895 | + * @param array $args |
|
| 896 | + */ |
|
| 897 | + public static function get_other_val( $args ) { |
|
| 898 | 898 | $defaults = array( |
| 899 | 899 | 'opt_key' => 0, 'field' => array(), |
| 900 | 900 | 'parent' => false, 'pointer' => false, |
@@ -970,20 +970,20 @@ discard block |
||
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | return $other_val; |
| 973 | - } |
|
| 974 | - |
|
| 975 | - /** |
|
| 976 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 977 | - * Intended for front-end use |
|
| 978 | - * |
|
| 979 | - * @since 2.0.6 |
|
| 980 | - * |
|
| 981 | - * @param array $args should include field, opt_key and field name |
|
| 982 | - * @param boolean $other_opt |
|
| 983 | - * @param string $checked |
|
| 984 | - * @return string $other_val |
|
| 985 | - */ |
|
| 986 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + /** |
|
| 976 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 977 | + * Intended for front-end use |
|
| 978 | + * |
|
| 979 | + * @since 2.0.6 |
|
| 980 | + * |
|
| 981 | + * @param array $args should include field, opt_key and field name |
|
| 982 | + * @param boolean $other_opt |
|
| 983 | + * @param string $checked |
|
| 984 | + * @return string $other_val |
|
| 985 | + */ |
|
| 986 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 987 | 987 | //Check if this is an "Other" option |
| 988 | 988 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 989 | 989 | return; |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | $checked = 'checked="checked" '; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - return $other_args; |
|
| 1003 | - } |
|
| 1002 | + return $other_args; |
|
| 1003 | + } |
|
| 1004 | 1004 | |
| 1005 | 1005 | /** |
| 1006 | 1006 | * @param array $args |
@@ -1050,8 +1050,8 @@ discard block |
||
| 1050 | 1050 | * @since 2.0.6 |
| 1051 | 1051 | */ |
| 1052 | 1052 | public static function include_other_input( $args ) { |
| 1053 | - if ( ! $args['other_opt'] ) { |
|
| 1054 | - return; |
|
| 1053 | + if ( ! $args['other_opt'] ) { |
|
| 1054 | + return; |
|
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | $classes = array( 'frm_other_input' ); |
@@ -1072,15 +1072,15 @@ discard block |
||
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | /** |
| 1075 | - * Get the HTML id for an "Other" text field |
|
| 1076 | - * Note: This does not affect fields in repeating sections |
|
| 1077 | - * |
|
| 1078 | - * @since 2.0.08 |
|
| 1079 | - * @param string $type - field type |
|
| 1080 | - * @param string $html_id |
|
| 1081 | - * @param string|boolean $opt_key |
|
| 1082 | - * @return string $other_id |
|
| 1083 | - */ |
|
| 1075 | + * Get the HTML id for an "Other" text field |
|
| 1076 | + * Note: This does not affect fields in repeating sections |
|
| 1077 | + * |
|
| 1078 | + * @since 2.0.08 |
|
| 1079 | + * @param string $type - field type |
|
| 1080 | + * @param string $html_id |
|
| 1081 | + * @param string|boolean $opt_key |
|
| 1082 | + * @return string $other_id |
|
| 1083 | + */ |
|
| 1084 | 1084 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1085 | 1085 | $other_id = $html_id; |
| 1086 | 1086 | |
@@ -1138,10 +1138,10 @@ discard block |
||
| 1138 | 1138 | } |
| 1139 | 1139 | |
| 1140 | 1140 | public static function switch_field_ids( $val ) { |
| 1141 | - global $frm_duplicate_ids; |
|
| 1142 | - $replace = array(); |
|
| 1143 | - $replace_with = array(); |
|
| 1144 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1141 | + global $frm_duplicate_ids; |
|
| 1142 | + $replace = array(); |
|
| 1143 | + $replace_with = array(); |
|
| 1144 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1145 | 1145 | $replace[] = '[if ' . $old . ']'; |
| 1146 | 1146 | $replace_with[] = '[if ' . $new . ']'; |
| 1147 | 1147 | $replace[] = '[if ' . $old . ' '; |
@@ -1156,153 +1156,153 @@ discard block |
||
| 1156 | 1156 | $replace_with[] = '[' . $new . ']'; |
| 1157 | 1157 | $replace[] = '[' . $old . ' '; |
| 1158 | 1158 | $replace_with[] = '[' . $new . ' '; |
| 1159 | - unset($old, $new); |
|
| 1160 | - } |
|
| 1159 | + unset($old, $new); |
|
| 1160 | + } |
|
| 1161 | 1161 | if ( is_array( $val ) ) { |
| 1162 | 1162 | foreach ( $val as $k => $v ) { |
| 1163 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1164 | - unset($k, $v); |
|
| 1165 | - } |
|
| 1166 | - } else { |
|
| 1167 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - return $val; |
|
| 1171 | - } |
|
| 1172 | - |
|
| 1173 | - public static function get_us_states() { |
|
| 1174 | - return apply_filters( 'frm_us_states', array( |
|
| 1175 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1176 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1177 | - 'DC' => 'District of Columbia', |
|
| 1178 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1179 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1180 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1181 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1182 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1183 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1184 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1185 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1186 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1187 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1188 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1189 | - ) ); |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - public static function get_countries() { |
|
| 1193 | - return apply_filters( 'frm_countries', array( |
|
| 1194 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1195 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1196 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1197 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1198 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1199 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1200 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1201 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1202 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1203 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1204 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1205 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1206 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1207 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1208 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1209 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1210 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1211 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1212 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1213 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1214 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1215 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1216 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1217 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1218 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1219 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1220 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1221 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1222 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1223 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1224 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1225 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1226 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1227 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1228 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1229 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1230 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1231 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1232 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1233 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1234 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1235 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1236 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1237 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1238 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1239 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1240 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1241 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1242 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1243 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1244 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1245 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1246 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1247 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1248 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1249 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1250 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1251 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1252 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1253 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1254 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1255 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1256 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1257 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1258 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1259 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1260 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1261 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1262 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1263 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1264 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1265 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1266 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1267 | - ) ); |
|
| 1268 | - } |
|
| 1163 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1164 | + unset($k, $v); |
|
| 1165 | + } |
|
| 1166 | + } else { |
|
| 1167 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + return $val; |
|
| 1171 | + } |
|
| 1172 | + |
|
| 1173 | + public static function get_us_states() { |
|
| 1174 | + return apply_filters( 'frm_us_states', array( |
|
| 1175 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1176 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1177 | + 'DC' => 'District of Columbia', |
|
| 1178 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1179 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1180 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1181 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1182 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1183 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1184 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1185 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1186 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1187 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1188 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1189 | + ) ); |
|
| 1190 | + } |
|
| 1191 | + |
|
| 1192 | + public static function get_countries() { |
|
| 1193 | + return apply_filters( 'frm_countries', array( |
|
| 1194 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1195 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1196 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1197 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1198 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1199 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1200 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1201 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1202 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1203 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1204 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1205 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1206 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1207 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1208 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1209 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1210 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1211 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1212 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1213 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1214 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1215 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1216 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1217 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1218 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1219 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1220 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1221 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1222 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1223 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1224 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1225 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1226 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1227 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1228 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1229 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1230 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1231 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1232 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1233 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1234 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1235 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1236 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1237 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1238 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1239 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1240 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1241 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1242 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1243 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1244 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1245 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1246 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1247 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1248 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1249 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1250 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1251 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1252 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1253 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1254 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1255 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1256 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1257 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1258 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1259 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1260 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1261 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1262 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1263 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1264 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1265 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1266 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1267 | + ) ); |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | 1270 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1271 | 1271 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1272 | 1272 | |
| 1273 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1274 | - $state_abv = array_keys($states); |
|
| 1275 | - sort($state_abv); |
|
| 1273 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1274 | + $state_abv = array_keys($states); |
|
| 1275 | + sort($state_abv); |
|
| 1276 | 1276 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1277 | 1277 | |
| 1278 | - $states = array_values($states); |
|
| 1279 | - sort($states); |
|
| 1278 | + $states = array_values($states); |
|
| 1279 | + sort($states); |
|
| 1280 | 1280 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1281 | - unset($state_abv, $states); |
|
| 1281 | + unset($state_abv, $states); |
|
| 1282 | 1282 | |
| 1283 | 1283 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1284 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1285 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1286 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1287 | - ); |
|
| 1284 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1285 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1286 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1287 | + ); |
|
| 1288 | 1288 | |
| 1289 | 1289 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1290 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1291 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1292 | - ); |
|
| 1290 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1291 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1292 | + ); |
|
| 1293 | 1293 | |
| 1294 | 1294 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1295 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1296 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1297 | - ); |
|
| 1295 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1296 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1297 | + ); |
|
| 1298 | 1298 | |
| 1299 | 1299 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1300 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1301 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1302 | - ); |
|
| 1300 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1301 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1302 | + ); |
|
| 1303 | 1303 | |
| 1304 | 1304 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1305 | - } |
|
| 1305 | + } |
|
| 1306 | 1306 | |
| 1307 | 1307 | public static function field_selection() { |
| 1308 | 1308 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1339,10 +1339,10 @@ discard block |
||
| 1339 | 1339 | return FrmField::is_required( $field ); |
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - public static function maybe_get_field( &$field ) { |
|
| 1342 | + public static function maybe_get_field( &$field ) { |
|
| 1343 | 1343 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1344 | 1344 | FrmField::maybe_get_field( $field ); |
| 1345 | - } |
|
| 1345 | + } |
|
| 1346 | 1346 | |
| 1347 | 1347 | public static function dropdown_categories( $args ) { |
| 1348 | 1348 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |