@@ -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' => 'default', '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(); |
@@ -183,21 +183,21 @@ discard block |
||
| 183 | 183 | return $msg; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - public static function get_form_fields( $form_id, $error = false ) { |
|
| 187 | - $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 189 | - return $fields; |
|
| 190 | - } |
|
| 186 | + public static function get_form_fields( $form_id, $error = false ) { |
|
| 187 | + $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | + $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 189 | + return $fields; |
|
| 190 | + } |
|
| 191 | 191 | |
| 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,138 +207,138 @@ 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 | - //replace [input] |
|
| 288 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 289 | - global $frm_vars; |
|
| 290 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 287 | + //replace [input] |
|
| 288 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 289 | + global $frm_vars; |
|
| 290 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 291 | 291 | |
| 292 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 293 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 292 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 293 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 294 | 294 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 295 | 295 | |
| 296 | - $replace_with = ''; |
|
| 296 | + $replace_with = ''; |
|
| 297 | 297 | |
| 298 | - if ( $tag == 'input' ) { |
|
| 299 | - if ( isset($atts['opt']) ) { |
|
| 300 | - $atts['opt']--; |
|
| 301 | - } |
|
| 298 | + if ( $tag == 'input' ) { |
|
| 299 | + if ( isset($atts['opt']) ) { |
|
| 300 | + $atts['opt']--; |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 304 | - if ( isset($atts['class']) ) { |
|
| 305 | - unset($atts['class']); |
|
| 306 | - } |
|
| 303 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 304 | + if ( isset($atts['class']) ) { |
|
| 305 | + unset($atts['class']); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $field['shortcodes'] = $atts; |
|
| 309 | - ob_start(); |
|
| 308 | + $field['shortcodes'] = $atts; |
|
| 309 | + ob_start(); |
|
| 310 | 310 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 311 | - $replace_with = ob_get_contents(); |
|
| 312 | - ob_end_clean(); |
|
| 313 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 314 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 315 | - } |
|
| 311 | + $replace_with = ob_get_contents(); |
|
| 312 | + ob_end_clean(); |
|
| 313 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 314 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 318 | - } |
|
| 317 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | if ( $form ) { |
| 321 | - $form = (array) $form; |
|
| 321 | + $form = (array) $form; |
|
| 322 | 322 | |
| 323 | - //replace [form_key] |
|
| 324 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 323 | + //replace [form_key] |
|
| 324 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 325 | 325 | |
| 326 | - //replace [form_name] |
|
| 327 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 328 | - } |
|
| 329 | - $html .= "\n"; |
|
| 326 | + //replace [form_name] |
|
| 327 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
| 328 | + } |
|
| 329 | + $html .= "\n"; |
|
| 330 | 330 | |
| 331 | - //Return html if conf_field to prevent loop |
|
| 332 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 333 | - return $html; |
|
| 334 | - } |
|
| 331 | + //Return html if conf_field to prevent loop |
|
| 332 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 333 | + return $html; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - //If field is in repeating section |
|
| 337 | - if ( $args['section_id'] ) { |
|
| 338 | - $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'] )); |
|
| 339 | - } else { |
|
| 340 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 341 | - } |
|
| 336 | + //If field is in repeating section |
|
| 337 | + if ( $args['section_id'] ) { |
|
| 338 | + $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'] )); |
|
| 339 | + } else { |
|
| 340 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | 343 | self::remove_collapse_shortcode( $html ); |
| 344 | 344 | |
@@ -346,8 +346,8 @@ discard block |
||
| 346 | 346 | $html = do_shortcode( $html ); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return $html; |
|
| 350 | - } |
|
| 349 | + return $html; |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | 353 | * Add classes to a field div |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | * @param array $errors |
| 360 | 360 | * @param string $html |
| 361 | 361 | */ |
| 362 | - private static function add_field_div_classes( $field_id, $field, $errors, &$html ) { |
|
| 363 | - $classes = self::get_field_div_classes( $field_id, $field, $errors, $html ); |
|
| 362 | + private static function add_field_div_classes( $field_id, $field, $errors, &$html ) { |
|
| 363 | + $classes = self::get_field_div_classes( $field_id, $field, $errors, $html ); |
|
| 364 | 364 | |
| 365 | 365 | if ( $field[ 'type' ] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
| 366 | 366 | // there is no error_class shortcode for HTML fields |
@@ -401,46 +401,46 @@ discard block |
||
| 401 | 401 | return $classes; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 405 | - if ( $no_vars ) { |
|
| 404 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 405 | + if ( $no_vars ) { |
|
| 406 | 406 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 407 | 407 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 408 | - } else { |
|
| 408 | + } else { |
|
| 409 | 409 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 410 | - } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 413 | - } |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 416 | 416 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 417 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 418 | - $args['conditional_check'] = true; |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - $prefix = ''; |
|
| 422 | - if ( $args['conditional_check'] ) { |
|
| 423 | - if ( $args['conditional'] ) { |
|
| 424 | - $prefix = 'if '; |
|
| 425 | - } else if ( $args['foreach'] ) { |
|
| 426 | - $prefix = 'foreach '; |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 431 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 432 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 433 | - $tag = str_replace(']', '', $tag); |
|
| 434 | - $tags = explode(' ', $tag); |
|
| 435 | - if ( is_array($tags) ) { |
|
| 436 | - $tag = $tags[0]; |
|
| 437 | - } |
|
| 438 | - } else { |
|
| 439 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $tag; |
|
| 443 | - } |
|
| 417 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 418 | + $args['conditional_check'] = true; |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + $prefix = ''; |
|
| 422 | + if ( $args['conditional_check'] ) { |
|
| 423 | + if ( $args['conditional'] ) { |
|
| 424 | + $prefix = 'if '; |
|
| 425 | + } else if ( $args['foreach'] ) { |
|
| 426 | + $prefix = 'foreach '; |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 431 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 432 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 433 | + $tag = str_replace(']', '', $tag); |
|
| 434 | + $tags = explode(' ', $tag); |
|
| 435 | + if ( is_array($tags) ) { |
|
| 436 | + $tag = $tags[0]; |
|
| 437 | + } |
|
| 438 | + } else { |
|
| 439 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $tag; |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | 446 | * Remove [collapse_this] if it's still included after all processing |
@@ -465,124 +465,124 @@ discard block |
||
| 465 | 465 | $class_prefix = 'frm-'; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if ( $lang != 'en' ) { |
|
| 468 | + if ( $lang != 'en' ) { |
|
| 469 | 469 | $api_js_url .= '&hl=' . $lang; |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 472 | 472 | |
| 473 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 474 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 473 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 474 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 475 | 475 | |
| 476 | 476 | ?> |
| 477 | 477 | <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> |
| 478 | 478 | <?php |
| 479 | - } |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | 481 | public static function show_single_option( $field ) { |
| 482 | - $field_name = $field['name']; |
|
| 483 | - $html_id = self::get_html_id($field); |
|
| 484 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 485 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 486 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 482 | + $field_name = $field['name']; |
|
| 483 | + $html_id = self::get_html_id($field); |
|
| 484 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 485 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 486 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 487 | 487 | |
| 488 | - // If this is an "Other" option, get the HTML for it |
|
| 488 | + // If this is an "Other" option, get the HTML for it |
|
| 489 | 489 | if ( self::is_other_opt( $opt_key ) ) { |
| 490 | - // Get string for Other text field, if needed |
|
| 490 | + // Get string for Other text field, if needed |
|
| 491 | 491 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 492 | 492 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 493 | - } else { |
|
| 493 | + } else { |
|
| 494 | 494 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 495 | - } |
|
| 496 | - } |
|
| 497 | - } |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | 499 | public static function dropdown_categories( $args ) { |
| 500 | 500 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
| 501 | - $args = wp_parse_args($args, $defaults); |
|
| 501 | + $args = wp_parse_args($args, $defaults); |
|
| 502 | 502 | |
| 503 | - if ( ! $args['field'] ) { |
|
| 504 | - return; |
|
| 505 | - } |
|
| 503 | + if ( ! $args['field'] ) { |
|
| 504 | + return; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - if ( ! $args['name'] ) { |
|
| 507 | + if ( ! $args['name'] ) { |
|
| 508 | 508 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
| 509 | - } |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | - $id = self::get_html_id($args['field']); |
|
| 512 | - $class = $args['field']['type']; |
|
| 511 | + $id = self::get_html_id($args['field']); |
|
| 512 | + $class = $args['field']['type']; |
|
| 513 | 513 | |
| 514 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 515 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 514 | + $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 515 | + $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 516 | 516 | |
| 517 | - if ( is_array($args['field']['value']) ) { |
|
| 518 | - if ( ! empty($exclude) ) { |
|
| 519 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 520 | - } |
|
| 521 | - $selected = reset($args['field']['value']); |
|
| 522 | - } else { |
|
| 523 | - $selected = $args['field']['value']; |
|
| 524 | - } |
|
| 517 | + if ( is_array($args['field']['value']) ) { |
|
| 518 | + if ( ! empty($exclude) ) { |
|
| 519 | + $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 520 | + } |
|
| 521 | + $selected = reset($args['field']['value']); |
|
| 522 | + } else { |
|
| 523 | + $selected = $args['field']['value']; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - $tax_atts = array( |
|
| 527 | - 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 528 | - 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 529 | - 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 530 | - ); |
|
| 526 | + $tax_atts = array( |
|
| 527 | + 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 528 | + 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 529 | + 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 530 | + ); |
|
| 531 | 531 | |
| 532 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 532 | + $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 533 | 533 | |
| 534 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 535 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 536 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 537 | - if ( ! $tax_atts['taxonomy'] ) { |
|
| 538 | - return; |
|
| 539 | - } |
|
| 534 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 535 | + $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 536 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 537 | + if ( ! $tax_atts['taxonomy'] ) { |
|
| 538 | + return; |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 542 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 543 | - $tax_atts['exclude_tree'] = $exclude; |
|
| 544 | - } |
|
| 545 | - } |
|
| 541 | + // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 542 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 543 | + $tax_atts['exclude_tree'] = $exclude; |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
| 547 | + $dropdown = wp_dropdown_categories($tax_atts); |
|
| 548 | 548 | |
| 549 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 549 | + $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 550 | 550 | |
| 551 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 552 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 553 | - } |
|
| 551 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 552 | + $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | 555 | $dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown ); |
| 556 | 556 | |
| 557 | - if ( is_array($args['field']['value']) ) { |
|
| 558 | - $skip = true; |
|
| 559 | - foreach ( $args['field']['value'] as $v ) { |
|
| 557 | + if ( is_array($args['field']['value']) ) { |
|
| 558 | + $skip = true; |
|
| 559 | + foreach ( $args['field']['value'] as $v ) { |
|
| 560 | 560 | if ( $skip ) { |
| 561 | - $skip = false; |
|
| 562 | - continue; |
|
| 563 | - } |
|
| 561 | + $skip = false; |
|
| 562 | + continue; |
|
| 563 | + } |
|
| 564 | 564 | $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
| 565 | - unset($v); |
|
| 566 | - } |
|
| 567 | - } |
|
| 565 | + unset($v); |
|
| 566 | + } |
|
| 567 | + } |
|
| 568 | 568 | |
| 569 | - return $dropdown; |
|
| 570 | - } |
|
| 569 | + return $dropdown; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | 572 | public static function get_term_link( $tax_id ) { |
| 573 | - $tax = get_taxonomy($tax_id); |
|
| 574 | - if ( ! $tax ) { |
|
| 575 | - return; |
|
| 576 | - } |
|
| 573 | + $tax = get_taxonomy($tax_id); |
|
| 574 | + if ( ! $tax ) { |
|
| 575 | + return; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - $link = sprintf( |
|
| 579 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 578 | + $link = sprintf( |
|
| 579 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 580 | 580 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 581 | - ); |
|
| 582 | - unset($tax); |
|
| 581 | + ); |
|
| 582 | + unset($tax); |
|
| 583 | 583 | |
| 584 | - return $link; |
|
| 585 | - } |
|
| 584 | + return $link; |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | 587 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 588 | 588 | // Remove white space from hide_opt |
@@ -593,195 +593,195 @@ discard block |
||
| 593 | 593 | $observed_value = wp_kses_post( $observed_value ); |
| 594 | 594 | $hide_opt = wp_kses_post( $hide_opt ); |
| 595 | 595 | |
| 596 | - if ( is_array($observed_value) ) { |
|
| 597 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - $m = false; |
|
| 601 | - if ( $cond == '==' ) { |
|
| 602 | - $m = $observed_value == $hide_opt; |
|
| 603 | - } else if ( $cond == '!=' ) { |
|
| 604 | - $m = $observed_value != $hide_opt; |
|
| 605 | - } else if ( $cond == '>' ) { |
|
| 606 | - $m = $observed_value > $hide_opt; |
|
| 607 | - } else if ( $cond == '<' ) { |
|
| 608 | - $m = $observed_value < $hide_opt; |
|
| 609 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 610 | - $m = stripos($observed_value, $hide_opt); |
|
| 611 | - if ( $cond == 'not LIKE' ) { |
|
| 612 | - $m = ( $m === false ) ? true : false; |
|
| 613 | - } else { |
|
| 614 | - $m = ( $m === false ) ? false : true; |
|
| 615 | - } |
|
| 616 | - } |
|
| 617 | - return $m; |
|
| 618 | - } |
|
| 596 | + if ( is_array($observed_value) ) { |
|
| 597 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + $m = false; |
|
| 601 | + if ( $cond == '==' ) { |
|
| 602 | + $m = $observed_value == $hide_opt; |
|
| 603 | + } else if ( $cond == '!=' ) { |
|
| 604 | + $m = $observed_value != $hide_opt; |
|
| 605 | + } else if ( $cond == '>' ) { |
|
| 606 | + $m = $observed_value > $hide_opt; |
|
| 607 | + } else if ( $cond == '<' ) { |
|
| 608 | + $m = $observed_value < $hide_opt; |
|
| 609 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 610 | + $m = stripos($observed_value, $hide_opt); |
|
| 611 | + if ( $cond == 'not LIKE' ) { |
|
| 612 | + $m = ( $m === false ) ? true : false; |
|
| 613 | + } else { |
|
| 614 | + $m = ( $m === false ) ? false : true; |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | + return $m; |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | 620 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 621 | - $m = false; |
|
| 622 | - if ( $cond == '==' ) { |
|
| 623 | - if ( is_array($hide_opt) ) { |
|
| 624 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 625 | - $m = empty($m) ? false : true; |
|
| 626 | - } else { |
|
| 627 | - $m = in_array($hide_opt, $observed_value); |
|
| 628 | - } |
|
| 629 | - } else if ( $cond == '!=' ) { |
|
| 630 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 631 | - } else if ( $cond == '>' ) { |
|
| 632 | - $min = min($observed_value); |
|
| 633 | - $m = $min > $hide_opt; |
|
| 634 | - } else if ( $cond == '<' ) { |
|
| 635 | - $max = max($observed_value); |
|
| 636 | - $m = $max < $hide_opt; |
|
| 637 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 638 | - foreach ( $observed_value as $ob ) { |
|
| 639 | - $m = strpos($ob, $hide_opt); |
|
| 640 | - if ( $m !== false ) { |
|
| 641 | - $m = true; |
|
| 642 | - break; |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - if ( $cond == 'not LIKE' ) { |
|
| 647 | - $m = ( $m === false ) ? true : false; |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - |
|
| 651 | - return $m; |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - /** |
|
| 655 | - * Replace a few basic shortcodes and field ids |
|
| 656 | - * @since 2.0 |
|
| 657 | - * @return string |
|
| 658 | - */ |
|
| 621 | + $m = false; |
|
| 622 | + if ( $cond == '==' ) { |
|
| 623 | + if ( is_array($hide_opt) ) { |
|
| 624 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 625 | + $m = empty($m) ? false : true; |
|
| 626 | + } else { |
|
| 627 | + $m = in_array($hide_opt, $observed_value); |
|
| 628 | + } |
|
| 629 | + } else if ( $cond == '!=' ) { |
|
| 630 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 631 | + } else if ( $cond == '>' ) { |
|
| 632 | + $min = min($observed_value); |
|
| 633 | + $m = $min > $hide_opt; |
|
| 634 | + } else if ( $cond == '<' ) { |
|
| 635 | + $max = max($observed_value); |
|
| 636 | + $m = $max < $hide_opt; |
|
| 637 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 638 | + foreach ( $observed_value as $ob ) { |
|
| 639 | + $m = strpos($ob, $hide_opt); |
|
| 640 | + if ( $m !== false ) { |
|
| 641 | + $m = true; |
|
| 642 | + break; |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + if ( $cond == 'not LIKE' ) { |
|
| 647 | + $m = ( $m === false ) ? true : false; |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + |
|
| 651 | + return $m; |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + /** |
|
| 655 | + * Replace a few basic shortcodes and field ids |
|
| 656 | + * @since 2.0 |
|
| 657 | + * @return string |
|
| 658 | + */ |
|
| 659 | 659 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 660 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 661 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 662 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 663 | - } |
|
| 660 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 661 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 662 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 666 | - $value = do_shortcode($value); |
|
| 665 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 666 | + $value = do_shortcode($value); |
|
| 667 | 667 | |
| 668 | - return $value; |
|
| 669 | - } |
|
| 668 | + return $value; |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | 671 | public static function get_shortcodes( $content, $form_id ) { |
| 672 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 673 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 674 | - } |
|
| 672 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 673 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 674 | + } |
|
| 675 | 675 | |
| 676 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 676 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 677 | 677 | |
| 678 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 678 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 679 | 679 | |
| 680 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 680 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 681 | 681 | |
| 682 | - return $matches; |
|
| 683 | - } |
|
| 682 | + return $matches; |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | 685 | public static function allowed_shortcodes( $fields = array() ) { |
| 686 | - $tagregexp = array( |
|
| 687 | - 'editlink', 'id', 'key', 'ip', |
|
| 688 | - 'siteurl', 'sitename', 'admin_email', |
|
| 689 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 686 | + $tagregexp = array( |
|
| 687 | + 'editlink', 'id', 'key', 'ip', |
|
| 688 | + 'siteurl', 'sitename', 'admin_email', |
|
| 689 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 690 | 690 | 'parent[-|_]id', |
| 691 | - ); |
|
| 691 | + ); |
|
| 692 | 692 | |
| 693 | - foreach ( $fields as $field ) { |
|
| 694 | - $tagregexp[] = $field->id; |
|
| 695 | - $tagregexp[] = $field->field_key; |
|
| 696 | - } |
|
| 693 | + foreach ( $fields as $field ) { |
|
| 694 | + $tagregexp[] = $field->id; |
|
| 695 | + $tagregexp[] = $field->field_key; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - $tagregexp = implode('|', $tagregexp); |
|
| 699 | - return $tagregexp; |
|
| 700 | - } |
|
| 698 | + $tagregexp = implode('|', $tagregexp); |
|
| 699 | + return $tagregexp; |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | 702 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 703 | - $shortcode_values = array( |
|
| 704 | - 'id' => $entry->id, |
|
| 705 | - 'key' => $entry->item_key, |
|
| 706 | - 'ip' => $entry->ip, |
|
| 707 | - ); |
|
| 703 | + $shortcode_values = array( |
|
| 704 | + 'id' => $entry->id, |
|
| 705 | + 'key' => $entry->item_key, |
|
| 706 | + 'ip' => $entry->ip, |
|
| 707 | + ); |
|
| 708 | 708 | |
| 709 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 710 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 709 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 710 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 711 | 711 | |
| 712 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 712 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 713 | 713 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 714 | - $tags = explode(' ', $tag); |
|
| 715 | - if ( is_array($tags) ) { |
|
| 716 | - $tag = $tags[0]; |
|
| 717 | - } |
|
| 718 | - } else { |
|
| 719 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - switch ( $tag ) { |
|
| 723 | - case 'id': |
|
| 724 | - case 'key': |
|
| 725 | - case 'ip': |
|
| 726 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 727 | - break; |
|
| 728 | - |
|
| 729 | - case 'user_agent': |
|
| 730 | - case 'user-agent': |
|
| 731 | - $entry->description = maybe_unserialize($entry->description); |
|
| 714 | + $tags = explode(' ', $tag); |
|
| 715 | + if ( is_array($tags) ) { |
|
| 716 | + $tag = $tags[0]; |
|
| 717 | + } |
|
| 718 | + } else { |
|
| 719 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + switch ( $tag ) { |
|
| 723 | + case 'id': |
|
| 724 | + case 'key': |
|
| 725 | + case 'ip': |
|
| 726 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 727 | + break; |
|
| 728 | + |
|
| 729 | + case 'user_agent': |
|
| 730 | + case 'user-agent': |
|
| 731 | + $entry->description = maybe_unserialize($entry->description); |
|
| 732 | 732 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 733 | - break; |
|
| 734 | - |
|
| 735 | - case 'created_at': |
|
| 736 | - case 'created-at': |
|
| 737 | - case 'updated_at': |
|
| 738 | - case 'updated-at': |
|
| 739 | - if ( isset($atts['format']) ) { |
|
| 740 | - $time_format = ' '; |
|
| 741 | - } else { |
|
| 742 | - $atts['format'] = get_option('date_format'); |
|
| 743 | - $time_format = ''; |
|
| 744 | - } |
|
| 745 | - |
|
| 746 | - $this_tag = str_replace('-', '_', $tag); |
|
| 747 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 748 | - unset($this_tag); |
|
| 749 | - break; |
|
| 750 | - |
|
| 751 | - case 'created_by': |
|
| 752 | - case 'created-by': |
|
| 753 | - case 'updated_by': |
|
| 754 | - case 'updated-by': |
|
| 755 | - $this_tag = str_replace('-', '_', $tag); |
|
| 733 | + break; |
|
| 734 | + |
|
| 735 | + case 'created_at': |
|
| 736 | + case 'created-at': |
|
| 737 | + case 'updated_at': |
|
| 738 | + case 'updated-at': |
|
| 739 | + if ( isset($atts['format']) ) { |
|
| 740 | + $time_format = ' '; |
|
| 741 | + } else { |
|
| 742 | + $atts['format'] = get_option('date_format'); |
|
| 743 | + $time_format = ''; |
|
| 744 | + } |
|
| 745 | + |
|
| 746 | + $this_tag = str_replace('-', '_', $tag); |
|
| 747 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 748 | + unset($this_tag); |
|
| 749 | + break; |
|
| 750 | + |
|
| 751 | + case 'created_by': |
|
| 752 | + case 'created-by': |
|
| 753 | + case 'updated_by': |
|
| 754 | + case 'updated-by': |
|
| 755 | + $this_tag = str_replace('-', '_', $tag); |
|
| 756 | 756 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 757 | - unset($this_tag); |
|
| 758 | - break; |
|
| 759 | - |
|
| 760 | - case 'admin_email': |
|
| 761 | - case 'siteurl': |
|
| 762 | - case 'frmurl': |
|
| 763 | - case 'sitename': |
|
| 764 | - case 'get': |
|
| 765 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 766 | - break; |
|
| 767 | - |
|
| 768 | - default: |
|
| 769 | - $field = FrmField::getOne( $tag ); |
|
| 770 | - if ( ! $field ) { |
|
| 771 | - break; |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 775 | - |
|
| 776 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 777 | - |
|
| 778 | - $atts['entry_id'] = $entry->id; |
|
| 779 | - $atts['entry_key'] = $entry->item_key; |
|
| 780 | - |
|
| 781 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 782 | - $replace_with = $field->name; |
|
| 783 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 784 | - $replace_with = $field->description; |
|
| 757 | + unset($this_tag); |
|
| 758 | + break; |
|
| 759 | + |
|
| 760 | + case 'admin_email': |
|
| 761 | + case 'siteurl': |
|
| 762 | + case 'frmurl': |
|
| 763 | + case 'sitename': |
|
| 764 | + case 'get': |
|
| 765 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 766 | + break; |
|
| 767 | + |
|
| 768 | + default: |
|
| 769 | + $field = FrmField::getOne( $tag ); |
|
| 770 | + if ( ! $field ) { |
|
| 771 | + break; |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 775 | + |
|
| 776 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 777 | + |
|
| 778 | + $atts['entry_id'] = $entry->id; |
|
| 779 | + $atts['entry_key'] = $entry->item_key; |
|
| 780 | + |
|
| 781 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 782 | + $replace_with = $field->name; |
|
| 783 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 784 | + $replace_with = $field->description; |
|
| 785 | 785 | } else { |
| 786 | 786 | $string_value = $replace_with; |
| 787 | 787 | if ( is_array( $replace_with ) ) { |
@@ -795,82 +795,82 @@ discard block |
||
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - unset($field); |
|
| 799 | - break; |
|
| 800 | - } |
|
| 798 | + unset($field); |
|
| 799 | + break; |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - if ( isset($replace_with) ) { |
|
| 803 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 804 | - } |
|
| 802 | + if ( isset($replace_with) ) { |
|
| 803 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - unset($atts, $conditional, $replace_with); |
|
| 806 | + unset($atts, $conditional, $replace_with); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | return $content; |
| 810 | - } |
|
| 811 | - |
|
| 812 | - /** |
|
| 813 | - * Get the value to replace a few standard shortcodes |
|
| 814 | - * |
|
| 815 | - * @since 2.0 |
|
| 816 | - * @return string |
|
| 817 | - */ |
|
| 818 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 819 | - $new_value = ''; |
|
| 820 | - switch ( $tag ) { |
|
| 821 | - case 'admin_email': |
|
| 822 | - $new_value = get_option('admin_email'); |
|
| 823 | - break; |
|
| 824 | - case 'siteurl': |
|
| 825 | - $new_value = FrmAppHelper::site_url(); |
|
| 826 | - break; |
|
| 827 | - case 'frmurl': |
|
| 828 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 829 | - break; |
|
| 830 | - case 'sitename': |
|
| 831 | - $new_value = FrmAppHelper::site_name(); |
|
| 832 | - break; |
|
| 833 | - case 'get': |
|
| 834 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 835 | - break; |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - return $new_value; |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - /** |
|
| 842 | - * Process the [get] shortcode |
|
| 843 | - * |
|
| 844 | - * @since 2.0 |
|
| 845 | - * @return string|array |
|
| 846 | - */ |
|
| 847 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 848 | - if ( ! isset($atts['param']) ) { |
|
| 849 | - return ''; |
|
| 850 | - } |
|
| 851 | - |
|
| 852 | - if ( strpos($atts['param'], '[') ) { |
|
| 853 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 854 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 858 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 859 | - |
|
| 860 | - if ( $new_value == '' ) { |
|
| 861 | - if ( ! isset($atts['prev_val']) ) { |
|
| 862 | - $atts['prev_val'] = ''; |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 869 | - $new_value = implode(', ', $new_value); |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - return $new_value; |
|
| 873 | - } |
|
| 810 | + } |
|
| 811 | + |
|
| 812 | + /** |
|
| 813 | + * Get the value to replace a few standard shortcodes |
|
| 814 | + * |
|
| 815 | + * @since 2.0 |
|
| 816 | + * @return string |
|
| 817 | + */ |
|
| 818 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 819 | + $new_value = ''; |
|
| 820 | + switch ( $tag ) { |
|
| 821 | + case 'admin_email': |
|
| 822 | + $new_value = get_option('admin_email'); |
|
| 823 | + break; |
|
| 824 | + case 'siteurl': |
|
| 825 | + $new_value = FrmAppHelper::site_url(); |
|
| 826 | + break; |
|
| 827 | + case 'frmurl': |
|
| 828 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 829 | + break; |
|
| 830 | + case 'sitename': |
|
| 831 | + $new_value = FrmAppHelper::site_name(); |
|
| 832 | + break; |
|
| 833 | + case 'get': |
|
| 834 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 835 | + break; |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + return $new_value; |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + /** |
|
| 842 | + * Process the [get] shortcode |
|
| 843 | + * |
|
| 844 | + * @since 2.0 |
|
| 845 | + * @return string|array |
|
| 846 | + */ |
|
| 847 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 848 | + if ( ! isset($atts['param']) ) { |
|
| 849 | + return ''; |
|
| 850 | + } |
|
| 851 | + |
|
| 852 | + if ( strpos($atts['param'], '[') ) { |
|
| 853 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 854 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 858 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 859 | + |
|
| 860 | + if ( $new_value == '' ) { |
|
| 861 | + if ( ! isset($atts['prev_val']) ) { |
|
| 862 | + $atts['prev_val'] = ''; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 869 | + $new_value = implode(', ', $new_value); |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + return $new_value; |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | 875 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 876 | 876 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -878,14 +878,14 @@ discard block |
||
| 878 | 878 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 879 | 879 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 880 | 880 | |
| 881 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 882 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 883 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 884 | - if ( is_array($replace_with) ) { |
|
| 885 | - $replace_with = implode("\n", $replace_with); |
|
| 886 | - } |
|
| 887 | - $replace_with = wpautop($replace_with); |
|
| 888 | - } |
|
| 881 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 882 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 883 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 884 | + if ( is_array($replace_with) ) { |
|
| 885 | + $replace_with = implode("\n", $replace_with); |
|
| 886 | + } |
|
| 887 | + $replace_with = wpautop($replace_with); |
|
| 888 | + } |
|
| 889 | 889 | unset( $autop ); |
| 890 | 890 | } else if ( is_array( $replace_with ) ) { |
| 891 | 891 | $replace_with = implode( $sep, $replace_with ); |
@@ -895,58 +895,58 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | public static function get_field_types( $type ) { |
| 898 | - $single_input = array( |
|
| 899 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 900 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 901 | - 'user_id', 'tag', 'password', |
|
| 902 | - ); |
|
| 898 | + $single_input = array( |
|
| 899 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 900 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 901 | + 'user_id', 'tag', 'password', |
|
| 902 | + ); |
|
| 903 | 903 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 904 | 904 | $other_type = array( 'html', 'break' ); |
| 905 | 905 | |
| 906 | 906 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 907 | 907 | |
| 908 | - $field_types = array(); |
|
| 909 | - if ( in_array($type, $single_input) ) { |
|
| 910 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 911 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 912 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 913 | - } else if ( in_array($type, $other_type) ) { |
|
| 914 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 908 | + $field_types = array(); |
|
| 909 | + if ( in_array($type, $single_input) ) { |
|
| 910 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 911 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 912 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 913 | + } else if ( in_array($type, $other_type) ) { |
|
| 914 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 915 | 915 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 916 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 917 | - } |
|
| 916 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 917 | + } |
|
| 918 | 918 | |
| 919 | 919 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 920 | - return $field_types; |
|
| 921 | - } |
|
| 922 | - |
|
| 923 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 924 | - foreach ( $inputs as $input ) { |
|
| 925 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 926 | - unset($input); |
|
| 927 | - } |
|
| 928 | - } |
|
| 929 | - |
|
| 930 | - /** |
|
| 931 | - * Check if current field option is an "other" option |
|
| 932 | - * |
|
| 933 | - * @since 2.0.6 |
|
| 934 | - * |
|
| 935 | - * @param string $opt_key |
|
| 936 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 937 | - */ |
|
| 938 | - public static function is_other_opt( $opt_key ) { |
|
| 939 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 940 | - } |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * Get value that belongs in "Other" text box |
|
| 944 | - * |
|
| 945 | - * @since 2.0.6 |
|
| 946 | - * |
|
| 947 | - * @param array $args |
|
| 948 | - */ |
|
| 949 | - public static function get_other_val( $args ) { |
|
| 920 | + return $field_types; |
|
| 921 | + } |
|
| 922 | + |
|
| 923 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 924 | + foreach ( $inputs as $input ) { |
|
| 925 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 926 | + unset($input); |
|
| 927 | + } |
|
| 928 | + } |
|
| 929 | + |
|
| 930 | + /** |
|
| 931 | + * Check if current field option is an "other" option |
|
| 932 | + * |
|
| 933 | + * @since 2.0.6 |
|
| 934 | + * |
|
| 935 | + * @param string $opt_key |
|
| 936 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 937 | + */ |
|
| 938 | + public static function is_other_opt( $opt_key ) { |
|
| 939 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 940 | + } |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * Get value that belongs in "Other" text box |
|
| 944 | + * |
|
| 945 | + * @since 2.0.6 |
|
| 946 | + * |
|
| 947 | + * @param array $args |
|
| 948 | + */ |
|
| 949 | + public static function get_other_val( $args ) { |
|
| 950 | 950 | $defaults = array( |
| 951 | 951 | 'opt_key' => 0, 'field' => array(), |
| 952 | 952 | 'parent' => false, 'pointer' => false, |
@@ -1022,20 +1022,20 @@ discard block |
||
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | return $other_val; |
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - /** |
|
| 1028 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1029 | - * Intended for front-end use |
|
| 1030 | - * |
|
| 1031 | - * @since 2.0.6 |
|
| 1032 | - * |
|
| 1033 | - * @param array $args should include field, opt_key and field name |
|
| 1034 | - * @param boolean $other_opt |
|
| 1035 | - * @param string $checked |
|
| 1036 | - * @return string $other_val |
|
| 1037 | - */ |
|
| 1038 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + /** |
|
| 1028 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1029 | + * Intended for front-end use |
|
| 1030 | + * |
|
| 1031 | + * @since 2.0.6 |
|
| 1032 | + * |
|
| 1033 | + * @param array $args should include field, opt_key and field name |
|
| 1034 | + * @param boolean $other_opt |
|
| 1035 | + * @param string $checked |
|
| 1036 | + * @return string $other_val |
|
| 1037 | + */ |
|
| 1038 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1039 | 1039 | //Check if this is an "Other" option |
| 1040 | 1040 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1041 | 1041 | return; |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | $checked = 'checked="checked" '; |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - return $other_args; |
|
| 1055 | - } |
|
| 1054 | + return $other_args; |
|
| 1055 | + } |
|
| 1056 | 1056 | |
| 1057 | 1057 | /** |
| 1058 | 1058 | * @param array $args |
@@ -1101,8 +1101,8 @@ discard block |
||
| 1101 | 1101 | * @since 2.0.6 |
| 1102 | 1102 | */ |
| 1103 | 1103 | public static function include_other_input( $args ) { |
| 1104 | - if ( ! $args['other_opt'] ) { |
|
| 1105 | - return; |
|
| 1104 | + if ( ! $args['other_opt'] ) { |
|
| 1105 | + return; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | $classes = array( 'frm_other_input' ); |
@@ -1123,15 +1123,15 @@ discard block |
||
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | /** |
| 1126 | - * Get the HTML id for an "Other" text field |
|
| 1127 | - * Note: This does not affect fields in repeating sections |
|
| 1128 | - * |
|
| 1129 | - * @since 2.0.08 |
|
| 1130 | - * @param string $type - field type |
|
| 1131 | - * @param string $html_id |
|
| 1132 | - * @param string|boolean $opt_key |
|
| 1133 | - * @return string $other_id |
|
| 1134 | - */ |
|
| 1126 | + * Get the HTML id for an "Other" text field |
|
| 1127 | + * Note: This does not affect fields in repeating sections |
|
| 1128 | + * |
|
| 1129 | + * @since 2.0.08 |
|
| 1130 | + * @param string $type - field type |
|
| 1131 | + * @param string $html_id |
|
| 1132 | + * @param string|boolean $opt_key |
|
| 1133 | + * @return string $other_id |
|
| 1134 | + */ |
|
| 1135 | 1135 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1136 | 1136 | $other_id = $html_id; |
| 1137 | 1137 | |
@@ -1189,10 +1189,10 @@ discard block |
||
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | public static function switch_field_ids( $val ) { |
| 1192 | - global $frm_duplicate_ids; |
|
| 1193 | - $replace = array(); |
|
| 1194 | - $replace_with = array(); |
|
| 1195 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1192 | + global $frm_duplicate_ids; |
|
| 1193 | + $replace = array(); |
|
| 1194 | + $replace_with = array(); |
|
| 1195 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1196 | 1196 | $replace[] = '[if ' . $old . ']'; |
| 1197 | 1197 | $replace_with[] = '[if ' . $new . ']'; |
| 1198 | 1198 | $replace[] = '[if ' . $old . ' '; |
@@ -1207,153 +1207,153 @@ discard block |
||
| 1207 | 1207 | $replace_with[] = '[' . $new . ']'; |
| 1208 | 1208 | $replace[] = '[' . $old . ' '; |
| 1209 | 1209 | $replace_with[] = '[' . $new . ' '; |
| 1210 | - unset($old, $new); |
|
| 1211 | - } |
|
| 1210 | + unset($old, $new); |
|
| 1211 | + } |
|
| 1212 | 1212 | if ( is_array( $val ) ) { |
| 1213 | 1213 | foreach ( $val as $k => $v ) { |
| 1214 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1215 | - unset($k, $v); |
|
| 1216 | - } |
|
| 1217 | - } else { |
|
| 1218 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - return $val; |
|
| 1222 | - } |
|
| 1223 | - |
|
| 1224 | - public static function get_us_states() { |
|
| 1225 | - return apply_filters( 'frm_us_states', array( |
|
| 1226 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1227 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1228 | - 'DC' => 'District of Columbia', |
|
| 1229 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1230 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1231 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1232 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1233 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1234 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1235 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1236 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1237 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1238 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1239 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1240 | - ) ); |
|
| 1241 | - } |
|
| 1242 | - |
|
| 1243 | - public static function get_countries() { |
|
| 1244 | - return apply_filters( 'frm_countries', array( |
|
| 1245 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1246 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1247 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1248 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1249 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1250 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1251 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1252 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1253 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1254 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1255 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1256 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1257 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1258 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1259 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1260 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1261 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1262 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1263 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1264 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1265 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1266 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1267 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1268 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1269 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1270 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1271 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1272 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1273 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1274 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1275 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1276 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1277 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1278 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1279 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1280 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1281 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1282 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1283 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1284 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1285 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1286 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1287 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1288 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1289 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1290 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1291 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1292 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1293 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1294 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1295 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1296 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1297 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1298 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1299 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1300 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1301 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1302 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1303 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1304 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1305 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1306 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1307 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1308 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1309 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1310 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1311 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1312 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1313 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1314 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1315 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1316 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1317 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1318 | - ) ); |
|
| 1319 | - } |
|
| 1214 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1215 | + unset($k, $v); |
|
| 1216 | + } |
|
| 1217 | + } else { |
|
| 1218 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + return $val; |
|
| 1222 | + } |
|
| 1223 | + |
|
| 1224 | + public static function get_us_states() { |
|
| 1225 | + return apply_filters( 'frm_us_states', array( |
|
| 1226 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1227 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1228 | + 'DC' => 'District of Columbia', |
|
| 1229 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1230 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1231 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1232 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1233 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1234 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1235 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1236 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1237 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1238 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1239 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1240 | + ) ); |
|
| 1241 | + } |
|
| 1242 | + |
|
| 1243 | + public static function get_countries() { |
|
| 1244 | + return apply_filters( 'frm_countries', array( |
|
| 1245 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1246 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1247 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1248 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1249 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1250 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1251 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1252 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1253 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1254 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1255 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1256 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1257 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1258 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1259 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1260 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1261 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1262 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1263 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1264 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1265 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1266 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1267 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1268 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1269 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1270 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1271 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1272 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1273 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1274 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1275 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1276 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1277 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1278 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1279 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1280 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1281 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1282 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1283 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1284 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1285 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1286 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1287 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1288 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1289 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1290 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1291 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1292 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1293 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1294 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1295 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1296 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1297 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1298 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1299 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1300 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1301 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1302 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1303 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1304 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1305 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1306 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1307 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1308 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1309 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1310 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1311 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1312 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1313 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1314 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1315 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1316 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1317 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1318 | + ) ); |
|
| 1319 | + } |
|
| 1320 | 1320 | |
| 1321 | 1321 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1322 | 1322 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1323 | 1323 | |
| 1324 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1325 | - $state_abv = array_keys($states); |
|
| 1326 | - sort($state_abv); |
|
| 1324 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1325 | + $state_abv = array_keys($states); |
|
| 1326 | + sort($state_abv); |
|
| 1327 | 1327 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1328 | 1328 | |
| 1329 | - $states = array_values($states); |
|
| 1330 | - sort($states); |
|
| 1329 | + $states = array_values($states); |
|
| 1330 | + sort($states); |
|
| 1331 | 1331 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1332 | - unset($state_abv, $states); |
|
| 1332 | + unset($state_abv, $states); |
|
| 1333 | 1333 | |
| 1334 | 1334 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1335 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1336 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1337 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1338 | - ); |
|
| 1335 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1336 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1337 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1338 | + ); |
|
| 1339 | 1339 | |
| 1340 | 1340 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1341 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1342 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1343 | - ); |
|
| 1341 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1342 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1343 | + ); |
|
| 1344 | 1344 | |
| 1345 | 1345 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1346 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1347 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1348 | - ); |
|
| 1346 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1347 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1348 | + ); |
|
| 1349 | 1349 | |
| 1350 | 1350 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1351 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1352 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1353 | - ); |
|
| 1351 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1352 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1353 | + ); |
|
| 1354 | 1354 | |
| 1355 | 1355 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1356 | - } |
|
| 1356 | + } |
|
| 1357 | 1357 | |
| 1358 | 1358 | public static function field_selection() { |
| 1359 | 1359 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1390,8 +1390,8 @@ discard block |
||
| 1390 | 1390 | return FrmField::is_required( $field ); |
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | - public static function maybe_get_field( &$field ) { |
|
| 1393 | + public static function maybe_get_field( &$field ) { |
|
| 1394 | 1394 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1395 | 1395 | FrmField::maybe_get_field( $field ); |
| 1396 | - } |
|
| 1396 | + } |
|
| 1397 | 1397 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,12 +7,12 @@ 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); |
|
| 10 | + if ( strpos( $type, '|' ) ) { |
|
| 11 | + list( $type, $setting ) = explode( '|', $type ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array(); |
| 18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | if ( $var == 'field_options' ) { |
| 21 | 21 | $values['field_options'] = array(); |
| 22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 23 | + $values['field_options'][$opt_var] = $opt_default; |
|
| 24 | + unset( $opt_var, $opt_default ); |
|
| 25 | 25 | } |
| 26 | 26 | } else { |
| 27 | - $values[ $var ] = $default; |
|
| 27 | + $values[$var] = $default; |
|
| 28 | 28 | } |
| 29 | - unset($var, $default); |
|
| 29 | + unset( $var, $default ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
| 33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 34 | 34 | $values['field_options']['data_type'] = $setting; |
| 35 | 35 | } else { |
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 36 | + $values['field_options'][$setting] = 1; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 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 ]; |
|
| 61 | + if ( isset( $fields[$type] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset( $fields ); |
|
| 66 | 66 | |
| 67 | 67 | return $values; |
| 68 | 68 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 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); |
|
| 91 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset( $var, $default ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $values['options'] = $record->options; |
| 101 | 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 | 106 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 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); |
|
| 111 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
| 112 | + unset( $opt, $default ); |
|
| 113 | 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 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 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 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | 155 | $values['form_id'] = $form_id; |
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 156 | + $values['options'] = maybe_serialize( $field->options ); |
|
| 157 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
| 158 | 158 | |
| 159 | 159 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 160 | + $values[$col] = $field->{$col}; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,21 +171,21 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $conf_msg = __( 'The entered values do not match', 'formidable' ); |
| 173 | 173 | $defaults = array( |
| 174 | - 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | - 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ), |
|
| 174 | + 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | + 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ), |
|
| 176 | 176 | 'blank' => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ), |
| 177 | 177 | 'conf_msg' => array( 'full' => $conf_msg, 'part' => $conf_msg ), |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | $msg = FrmField::get_option( $field, $error ); |
| 181 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 181 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 182 | 182 | $msg = do_shortcode( $msg ); |
| 183 | 183 | return $msg; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | public static function get_form_fields( $form_id, $error = false ) { |
| 187 | - $fields = FrmField::get_all_for_form($form_id); |
|
| 188 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 187 | + $fields = FrmField::get_all_for_form( $form_id ); |
|
| 188 | + $fields = apply_filters( 'frm_get_paged_fields', $fields, $form_id, $error ); |
|
| 189 | 189 | return $fields; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | 210 | } else { |
| 211 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
| 211 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 214 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
| 215 | 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 | 220 | $defaults = array( |
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -223,42 +223,42 @@ discard block |
||
| 223 | 223 | 'field_plus_id' => '', |
| 224 | 224 | 'section_id' => '', |
| 225 | 225 | ); |
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 226 | + $args = wp_parse_args( $args, $defaults ); |
|
| 227 | 227 | $field_name = $args['field_name']; |
| 228 | 228 | $field_id = $args['field_id']; |
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 229 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 231 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
| 232 | 232 | $field_name .= '[]'; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //replace [id] |
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 236 | + $html = str_replace( '[id]', $field_id, $html ); |
|
| 237 | 237 | |
| 238 | 238 | // Remove the for attribute for captcha |
| 239 | 239 | if ( $field['type'] == 'captcha' ) { |
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 240 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // set the label for |
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 244 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
| 245 | 245 | |
| 246 | 246 | //replace [key] |
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 247 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
| 248 | 248 | |
| 249 | 249 | //replace [description] and [required_label] and [error] |
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | 251 | if ( ! is_array( $errors ) ) { |
| 252 | 252 | $errors = array(); |
| 253 | 253 | } |
| 254 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
| 254 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
| 255 | 255 | |
| 256 | 256 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
| 257 | 257 | if ( $field['type'] == 'divider' ) { |
| 258 | 258 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
| 259 | 259 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
| 260 | 260 | } else { |
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 261 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
@@ -268,41 +268,41 @@ discard block |
||
| 268 | 268 | |
| 269 | 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 | 273 | //replace [label_position] |
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 274 | + $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form ); |
|
| 275 | 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 | 278 | //replace [field_name] |
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 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 | 283 | //replace [entry_key] |
| 284 | 284 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 285 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
| 286 | 286 | |
| 287 | 287 | //replace [input] |
| 288 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 288 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 289 | 289 | global $frm_vars; |
| 290 | 290 | $frm_settings = FrmAppHelper::get_settings(); |
| 291 | 291 | |
| 292 | 292 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 293 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 293 | + $atts = shortcode_parse_atts( $shortcodes[2][$short_key] ); |
|
| 294 | 294 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 295 | 295 | |
| 296 | 296 | $replace_with = ''; |
| 297 | 297 | |
| 298 | 298 | if ( $tag == 'input' ) { |
| 299 | - if ( isset($atts['opt']) ) { |
|
| 300 | - $atts['opt']--; |
|
| 299 | + if ( isset( $atts['opt'] ) ) { |
|
| 300 | + $atts['opt'] --; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 304 | - if ( isset($atts['class']) ) { |
|
| 305 | - unset($atts['class']); |
|
| 303 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
| 304 | + if ( isset( $atts['class'] ) ) { |
|
| 305 | + unset( $atts['class'] ); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | $field['shortcodes'] = $atts; |
@@ -311,33 +311,33 @@ discard block |
||
| 311 | 311 | $replace_with = ob_get_contents(); |
| 312 | 312 | ob_end_clean(); |
| 313 | 313 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
| 314 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 314 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 317 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | if ( $form ) { |
| 321 | 321 | $form = (array) $form; |
| 322 | 322 | |
| 323 | 323 | //replace [form_key] |
| 324 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 324 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
| 325 | 325 | |
| 326 | 326 | //replace [form_name] |
| 327 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 327 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
| 328 | 328 | } |
| 329 | 329 | $html .= "\n"; |
| 330 | 330 | |
| 331 | 331 | //Return html if conf_field to prevent loop |
| 332 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 332 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
| 333 | 333 | return $html; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | //If field is in repeating section |
| 337 | 337 | if ( $args['section_id'] ) { |
| 338 | - $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'] )); |
|
| 338 | + $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'] ) ); |
|
| 339 | 339 | } else { |
| 340 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 340 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) ); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | self::remove_collapse_shortcode( $html ); |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | private static function add_field_div_classes( $field_id, $field, $errors, &$html ) { |
| 363 | 363 | $classes = self::get_field_div_classes( $field_id, $field, $errors, $html ); |
| 364 | 364 | |
| 365 | - if ( $field[ 'type' ] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
|
| 365 | + if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
|
| 366 | 366 | // there is no error_class shortcode for HTML fields |
| 367 | 367 | $html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $classes, $html ); |
| 368 | 368 | } |
@@ -382,14 +382,14 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | private static function get_field_div_classes( $field_id, $field, $errors, $html ) { |
| 384 | 384 | // Add error class |
| 385 | - $classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
| 385 | + $classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
| 386 | 386 | |
| 387 | 387 | // Add label position class |
| 388 | 388 | $classes .= ' frm_' . $field['label'] . '_container'; |
| 389 | 389 | |
| 390 | 390 | // Add CSS layout classes |
| 391 | 391 | if ( ! empty( $field['classes'] ) ) { |
| 392 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
| 392 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
| 393 | 393 | $classes .= ' frm_form_field'; |
| 394 | 394 | } |
| 395 | 395 | $classes .= ' ' . $field['classes']; |
@@ -428,15 +428,15 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 431 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 432 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 433 | - $tag = str_replace(']', '', $tag); |
|
| 434 | - $tags = explode(' ', $tag); |
|
| 435 | - if ( is_array($tags) ) { |
|
| 431 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
| 432 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
| 433 | + $tag = str_replace( ']', '', $tag ); |
|
| 434 | + $tags = explode( ' ', $tag ); |
|
| 435 | + if ( is_array( $tags ) ) { |
|
| 436 | 436 | $tag = $tags[0]; |
| 437 | 437 | } |
| 438 | 438 | } else { |
| 439 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 439 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | return $tag; |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | public static function show_single_option( $field ) { |
| 482 | 482 | $field_name = $field['name']; |
| 483 | - $html_id = self::get_html_id($field); |
|
| 483 | + $html_id = self::get_html_id( $field ); |
|
| 484 | 484 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 485 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 486 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 485 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 486 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 487 | 487 | |
| 488 | 488 | // If this is an "Other" option, get the HTML for it |
| 489 | 489 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | |
| 499 | 499 | public static function dropdown_categories( $args ) { |
| 500 | 500 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
| 501 | - $args = wp_parse_args($args, $defaults); |
|
| 501 | + $args = wp_parse_args( $args, $defaults ); |
|
| 502 | 502 | |
| 503 | 503 | if ( ! $args['field'] ) { |
| 504 | 504 | return; |
@@ -508,17 +508,17 @@ discard block |
||
| 508 | 508 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $id = self::get_html_id($args['field']); |
|
| 511 | + $id = self::get_html_id( $args['field'] ); |
|
| 512 | 512 | $class = $args['field']['type']; |
| 513 | 513 | |
| 514 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 515 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 514 | + $exclude = ( is_array( $args['field']['exclude_cat'] ) ) ? implode( ',', $args['field']['exclude_cat'] ) : $args['field']['exclude_cat']; |
|
| 515 | + $exclude = apply_filters( 'frm_exclude_cats', $exclude, $args['field'] ); |
|
| 516 | 516 | |
| 517 | - if ( is_array($args['field']['value']) ) { |
|
| 518 | - if ( ! empty($exclude) ) { |
|
| 519 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 517 | + if ( is_array( $args['field']['value'] ) ) { |
|
| 518 | + if ( ! empty( $exclude ) ) { |
|
| 519 | + $args['field']['value'] = array_diff( $args['field']['value'], explode( ',', $exclude ) ); |
|
| 520 | 520 | } |
| 521 | - $selected = reset($args['field']['value']); |
|
| 521 | + $selected = reset( $args['field']['value'] ); |
|
| 522 | 522 | } else { |
| 523 | 523 | $selected = $args['field']['value']; |
| 524 | 524 | } |
@@ -529,40 +529,40 @@ discard block |
||
| 529 | 529 | 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
| 530 | 530 | ); |
| 531 | 531 | |
| 532 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 532 | + $tax_atts = apply_filters( 'frm_dropdown_cat', $tax_atts, $args['field'] ); |
|
| 533 | 533 | |
| 534 | 534 | if ( FrmAppHelper::pro_is_installed() ) { |
| 535 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 536 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 535 | + $post_type = FrmProFormsHelper::post_type( $args['field']['form_id'] ); |
|
| 536 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy( $post_type, $args['field'] ); |
|
| 537 | 537 | if ( ! $tax_atts['taxonomy'] ) { |
| 538 | 538 | return; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
| 542 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 542 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical( $tax_atts['taxonomy'] ) ) { |
|
| 543 | 543 | $tax_atts['exclude_tree'] = $exclude; |
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
| 547 | + $dropdown = wp_dropdown_categories( $tax_atts ); |
|
| 548 | 548 | |
| 549 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 549 | + $add_html = FrmFieldsController::input_html( $args['field'], false ); |
|
| 550 | 550 | |
| 551 | 551 | if ( FrmAppHelper::pro_is_installed() ) { |
| 552 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 552 | + $add_html .= FrmProFieldsController::input_html( $args['field'], false ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | $dropdown = str_replace( "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' class='" . esc_attr( $class ) . "'", "<select name='" . esc_attr( $args['name'] ) . "' id='" . esc_attr( $id ) . "' " . $add_html, $dropdown ); |
| 556 | 556 | |
| 557 | - if ( is_array($args['field']['value']) ) { |
|
| 557 | + if ( is_array( $args['field']['value'] ) ) { |
|
| 558 | 558 | $skip = true; |
| 559 | 559 | foreach ( $args['field']['value'] as $v ) { |
| 560 | 560 | if ( $skip ) { |
| 561 | 561 | $skip = false; |
| 562 | 562 | continue; |
| 563 | 563 | } |
| 564 | - $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
|
| 565 | - unset($v); |
|
| 564 | + $dropdown = str_replace( ' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
|
| 565 | + unset( $v ); |
|
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | public static function get_term_link( $tax_id ) { |
| 573 | - $tax = get_taxonomy($tax_id); |
|
| 573 | + $tax = get_taxonomy( $tax_id ); |
|
| 574 | 574 | if ( ! $tax ) { |
| 575 | 575 | return; |
| 576 | 576 | } |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
| 580 | 580 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 581 | 581 | ); |
| 582 | - unset($tax); |
|
| 582 | + unset( $tax ); |
|
| 583 | 583 | |
| 584 | 584 | return $link; |
| 585 | 585 | } |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | $observed_value = wp_kses_post( $observed_value ); |
| 594 | 594 | $hide_opt = wp_kses_post( $hide_opt ); |
| 595 | 595 | |
| 596 | - if ( is_array($observed_value) ) { |
|
| 597 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 596 | + if ( is_array( $observed_value ) ) { |
|
| 597 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | $m = false; |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | } else if ( $cond == '<' ) { |
| 608 | 608 | $m = $observed_value < $hide_opt; |
| 609 | 609 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 610 | - $m = stripos($observed_value, $hide_opt); |
|
| 610 | + $m = stripos( $observed_value, $hide_opt ); |
|
| 611 | 611 | if ( $cond == 'not LIKE' ) { |
| 612 | 612 | $m = ( $m === false ) ? true : false; |
| 613 | 613 | } else { |
@@ -620,23 +620,23 @@ discard block |
||
| 620 | 620 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 621 | 621 | $m = false; |
| 622 | 622 | if ( $cond == '==' ) { |
| 623 | - if ( is_array($hide_opt) ) { |
|
| 624 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 625 | - $m = empty($m) ? false : true; |
|
| 623 | + if ( is_array( $hide_opt ) ) { |
|
| 624 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
| 625 | + $m = empty( $m ) ? false : true; |
|
| 626 | 626 | } else { |
| 627 | - $m = in_array($hide_opt, $observed_value); |
|
| 627 | + $m = in_array( $hide_opt, $observed_value ); |
|
| 628 | 628 | } |
| 629 | 629 | } else if ( $cond == '!=' ) { |
| 630 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 630 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
| 631 | 631 | } else if ( $cond == '>' ) { |
| 632 | - $min = min($observed_value); |
|
| 632 | + $min = min( $observed_value ); |
|
| 633 | 633 | $m = $min > $hide_opt; |
| 634 | 634 | } else if ( $cond == '<' ) { |
| 635 | - $max = max($observed_value); |
|
| 635 | + $max = max( $observed_value ); |
|
| 636 | 636 | $m = $max < $hide_opt; |
| 637 | 637 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 638 | 638 | foreach ( $observed_value as $ob ) { |
| 639 | - $m = strpos($ob, $hide_opt); |
|
| 639 | + $m = strpos( $ob, $hide_opt ); |
|
| 640 | 640 | if ( $m !== false ) { |
| 641 | 641 | $m = true; |
| 642 | 642 | break; |
@@ -657,27 +657,27 @@ discard block |
||
| 657 | 657 | * @return string |
| 658 | 658 | */ |
| 659 | 659 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 660 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 660 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
| 661 | 661 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
| 662 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 662 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 666 | - $value = do_shortcode($value); |
|
| 665 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
| 666 | + $value = do_shortcode( $value ); |
|
| 667 | 667 | |
| 668 | 668 | return $value; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | public static function get_shortcodes( $content, $form_id ) { |
| 672 | 672 | if ( FrmAppHelper::pro_is_installed() ) { |
| 673 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 673 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
| 677 | 677 | |
| 678 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 678 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
| 679 | 679 | |
| 680 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 680 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
| 681 | 681 | |
| 682 | 682 | return $matches; |
| 683 | 683 | } |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | $tagregexp[] = $field->field_key; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $tagregexp = implode('|', $tagregexp); |
|
| 698 | + $tagregexp = implode( '|', $tagregexp ); |
|
| 699 | 699 | return $tagregexp; |
| 700 | 700 | } |
| 701 | 701 | |
@@ -707,28 +707,28 @@ discard block |
||
| 707 | 707 | ); |
| 708 | 708 | |
| 709 | 709 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 710 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 710 | + $atts = shortcode_parse_atts( $shortcodes[3][$short_key] ); |
|
| 711 | 711 | |
| 712 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 713 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
| 714 | - $tags = explode(' ', $tag); |
|
| 715 | - if ( is_array($tags) ) { |
|
| 712 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
| 713 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
| 714 | + $tags = explode( ' ', $tag ); |
|
| 715 | + if ( is_array( $tags ) ) { |
|
| 716 | 716 | $tag = $tags[0]; |
| 717 | 717 | } |
| 718 | 718 | } else { |
| 719 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 719 | + $tag = $shortcodes[2][$short_key]; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | switch ( $tag ) { |
| 723 | 723 | case 'id': |
| 724 | 724 | case 'key': |
| 725 | 725 | case 'ip': |
| 726 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 726 | + $replace_with = $shortcode_values[$tag]; |
|
| 727 | 727 | break; |
| 728 | 728 | |
| 729 | 729 | case 'user_agent': |
| 730 | 730 | case 'user-agent': |
| 731 | - $entry->description = maybe_unserialize($entry->description); |
|
| 731 | + $entry->description = maybe_unserialize( $entry->description ); |
|
| 732 | 732 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 733 | 733 | break; |
| 734 | 734 | |
@@ -736,25 +736,25 @@ discard block |
||
| 736 | 736 | case 'created-at': |
| 737 | 737 | case 'updated_at': |
| 738 | 738 | case 'updated-at': |
| 739 | - if ( isset($atts['format']) ) { |
|
| 739 | + if ( isset( $atts['format'] ) ) { |
|
| 740 | 740 | $time_format = ' '; |
| 741 | 741 | } else { |
| 742 | - $atts['format'] = get_option('date_format'); |
|
| 742 | + $atts['format'] = get_option( 'date_format' ); |
|
| 743 | 743 | $time_format = ''; |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - $this_tag = str_replace('-', '_', $tag); |
|
| 747 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 748 | - unset($this_tag); |
|
| 746 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 747 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
| 748 | + unset( $this_tag ); |
|
| 749 | 749 | break; |
| 750 | 750 | |
| 751 | 751 | case 'created_by': |
| 752 | 752 | case 'created-by': |
| 753 | 753 | case 'updated_by': |
| 754 | 754 | case 'updated-by': |
| 755 | - $this_tag = str_replace('-', '_', $tag); |
|
| 755 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 756 | 756 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 757 | - unset($this_tag); |
|
| 757 | + unset( $this_tag ); |
|
| 758 | 758 | break; |
| 759 | 759 | |
| 760 | 760 | case 'admin_email': |
@@ -771,16 +771,16 @@ discard block |
||
| 771 | 771 | break; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 774 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
| 775 | 775 | |
| 776 | 776 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
| 777 | 777 | |
| 778 | 778 | $atts['entry_id'] = $entry->id; |
| 779 | 779 | $atts['entry_key'] = $entry->item_key; |
| 780 | 780 | |
| 781 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 781 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
| 782 | 782 | $replace_with = $field->name; |
| 783 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 783 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
| 784 | 784 | $replace_with = $field->description; |
| 785 | 785 | } else { |
| 786 | 786 | $string_value = $replace_with; |
@@ -795,15 +795,15 @@ discard block |
||
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - unset($field); |
|
| 798 | + unset( $field ); |
|
| 799 | 799 | break; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if ( isset($replace_with) ) { |
|
| 803 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 802 | + if ( isset( $replace_with ) ) { |
|
| 803 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | - unset($atts, $conditional, $replace_with); |
|
| 806 | + unset( $atts, $conditional, $replace_with ); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | return $content; |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | $new_value = ''; |
| 820 | 820 | switch ( $tag ) { |
| 821 | 821 | case 'admin_email': |
| 822 | - $new_value = get_option('admin_email'); |
|
| 822 | + $new_value = get_option( 'admin_email' ); |
|
| 823 | 823 | break; |
| 824 | 824 | case 'siteurl': |
| 825 | 825 | $new_value = FrmAppHelper::site_url(); |
@@ -845,28 +845,28 @@ discard block |
||
| 845 | 845 | * @return string|array |
| 846 | 846 | */ |
| 847 | 847 | public static function process_get_shortcode( $atts, $return_array = false ) { |
| 848 | - if ( ! isset($atts['param']) ) { |
|
| 848 | + if ( ! isset( $atts['param'] ) ) { |
|
| 849 | 849 | return ''; |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - if ( strpos($atts['param'], '[') ) { |
|
| 853 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 854 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 852 | + if ( strpos( $atts['param'], '[' ) ) { |
|
| 853 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
| 854 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 857 | + $new_value = FrmAppHelper::get_param( $atts['param'], '' ); |
|
| 858 | 858 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
| 859 | 859 | |
| 860 | 860 | if ( $new_value == '' ) { |
| 861 | - if ( ! isset($atts['prev_val']) ) { |
|
| 861 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
| 862 | 862 | $atts['prev_val'] = ''; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 865 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 869 | - $new_value = implode(', ', $new_value); |
|
| 868 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
| 869 | + $new_value = implode( ', ', $new_value ); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | return $new_value; |
@@ -879,12 +879,12 @@ discard block |
||
| 879 | 879 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 880 | 880 | |
| 881 | 881 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
| 882 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 883 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 884 | - if ( is_array($replace_with) ) { |
|
| 885 | - $replace_with = implode("\n", $replace_with); |
|
| 882 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
| 883 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
| 884 | + if ( is_array( $replace_with ) ) { |
|
| 885 | + $replace_with = implode( "\n", $replace_with ); |
|
| 886 | 886 | } |
| 887 | - $replace_with = wpautop($replace_with); |
|
| 887 | + $replace_with = wpautop( $replace_with ); |
|
| 888 | 888 | } |
| 889 | 889 | unset( $autop ); |
| 890 | 890 | } else if ( is_array( $replace_with ) ) { |
@@ -906,14 +906,14 @@ discard block |
||
| 906 | 906 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 907 | 907 | |
| 908 | 908 | $field_types = array(); |
| 909 | - if ( in_array($type, $single_input) ) { |
|
| 909 | + if ( in_array( $type, $single_input ) ) { |
|
| 910 | 910 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 911 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 911 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
| 912 | 912 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 913 | - } else if ( in_array($type, $other_type) ) { |
|
| 913 | + } else if ( in_array( $type, $other_type ) ) { |
|
| 914 | 914 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 915 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
| 916 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 915 | + } else if ( isset( $field_selection[$type] ) ) { |
|
| 916 | + $field_types[$type] = $field_selection[$type]; |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -922,8 +922,8 @@ discard block |
||
| 922 | 922 | |
| 923 | 923 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 924 | 924 | foreach ( $inputs as $input ) { |
| 925 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 926 | - unset($input); |
|
| 925 | + $field_types[$input] = $fields[$input]; |
|
| 926 | + unset( $input ); |
|
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | 929 | |
@@ -968,21 +968,21 @@ discard block |
||
| 968 | 968 | // Check posted vals before checking saved values |
| 969 | 969 | |
| 970 | 970 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 971 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 971 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 972 | 972 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 973 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 973 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 974 | 974 | } else { |
| 975 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 975 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 976 | 976 | } |
| 977 | 977 | return $other_val; |
| 978 | 978 | |
| 979 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 979 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 980 | 980 | // For normal fields |
| 981 | 981 | |
| 982 | 982 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 983 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 983 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 984 | 984 | } else { |
| 985 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 985 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 986 | 986 | } |
| 987 | 987 | return $other_val; |
| 988 | 988 | } |
@@ -991,8 +991,8 @@ discard block |
||
| 991 | 991 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 992 | 992 | // Check if there is an "other" val in saved value and make sure the |
| 993 | 993 | // "other" val is not equal to the Other checkbox option |
| 994 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 995 | - $other_val = $field['value'][ $opt_key ]; |
|
| 994 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 995 | + $other_val = $field['value'][$opt_key]; |
|
| 996 | 996 | } |
| 997 | 997 | } else { |
| 998 | 998 | /** |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | // Multi-select dropdowns - key is not preserved |
| 1005 | 1005 | if ( is_array( $field['value'] ) ) { |
| 1006 | 1006 | $o_key = array_search( $temp_val, $field['value'] ); |
| 1007 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 1008 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 1007 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 1008 | + unset( $field['value'][$o_key], $o_key ); |
|
| 1009 | 1009 | } |
| 1010 | 1010 | } else if ( $temp_val == $field['value'] ) { |
| 1011 | 1011 | // For radio and regular dropdowns |
@@ -1062,7 +1062,7 @@ discard block |
||
| 1062 | 1062 | private static function set_other_name( $args, &$other_args ) { |
| 1063 | 1063 | //Set up name for other field |
| 1064 | 1064 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
| 1065 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
| 1065 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
| 1066 | 1066 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
| 1067 | 1067 | |
| 1068 | 1068 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1088,7 +1088,7 @@ discard block |
||
| 1088 | 1088 | // Count should only be greater than 3 if inside of a repeating section |
| 1089 | 1089 | if ( count( $temp_array ) > 3 ) { |
| 1090 | 1090 | $parent = str_replace( ']', '', $temp_array[1] ); |
| 1091 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
| 1091 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | // Get text for "other" text field |
@@ -1207,15 +1207,15 @@ discard block |
||
| 1207 | 1207 | $replace_with[] = '[' . $new . ']'; |
| 1208 | 1208 | $replace[] = '[' . $old . ' '; |
| 1209 | 1209 | $replace_with[] = '[' . $new . ' '; |
| 1210 | - unset($old, $new); |
|
| 1210 | + unset( $old, $new ); |
|
| 1211 | 1211 | } |
| 1212 | 1212 | if ( is_array( $val ) ) { |
| 1213 | 1213 | foreach ( $val as $k => $v ) { |
| 1214 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1215 | - unset($k, $v); |
|
| 1214 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1215 | + unset( $k, $v ); |
|
| 1216 | 1216 | } |
| 1217 | 1217 | } else { |
| 1218 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1218 | + $val = str_replace( $replace, $replace_with, $val ); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | return $val; |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | 'DC' => 'District of Columbia', |
| 1229 | 1229 | 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
| 1230 | 1230 | 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
| 1231 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1231 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', |
|
| 1232 | 1232 | 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
| 1233 | 1233 | 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
| 1234 | 1234 | 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
@@ -1319,35 +1319,35 @@ discard block |
||
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1322 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1322 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1323 | 1323 | |
| 1324 | 1324 | $states = FrmFieldsHelper::get_us_states(); |
| 1325 | - $state_abv = array_keys($states); |
|
| 1326 | - sort($state_abv); |
|
| 1327 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1325 | + $state_abv = array_keys( $states ); |
|
| 1326 | + sort( $state_abv ); |
|
| 1327 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1328 | 1328 | |
| 1329 | - $states = array_values($states); |
|
| 1330 | - sort($states); |
|
| 1331 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1332 | - unset($state_abv, $states); |
|
| 1329 | + $states = array_values( $states ); |
|
| 1330 | + sort( $states ); |
|
| 1331 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1332 | + unset( $state_abv, $states ); |
|
| 1333 | 1333 | |
| 1334 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1334 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1335 | 1335 | __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
| 1336 | 1336 | __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
| 1337 | 1337 | __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
| 1338 | 1338 | ); |
| 1339 | 1339 | |
| 1340 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1340 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1341 | 1341 | __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1342 | 1342 | __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1343 | 1343 | ); |
| 1344 | 1344 | |
| 1345 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1345 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1346 | 1346 | __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1347 | 1347 | __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1348 | 1348 | ); |
| 1349 | 1349 | |
| 1350 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1350 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1351 | 1351 | __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1352 | 1352 | __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1353 | 1353 | ); |