@@ -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,145 +207,145 @@ 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 | - //replace [error_class] |
|
| 281 | + //replace [error_class] |
|
| 282 | 282 | $error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
| 283 | 283 | self::get_more_field_classes( $error_class, $field, $field_id, $html ); |
| 284 | 284 | if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
| 285 | 285 | // there is no error_class shortcode to use for addign fields |
| 286 | 286 | $html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html ); |
| 287 | 287 | } |
| 288 | - $html = str_replace('[error_class]', $error_class, $html); |
|
| 288 | + $html = str_replace('[error_class]', $error_class, $html); |
|
| 289 | 289 | |
| 290 | - //replace [entry_key] |
|
| 291 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 292 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 290 | + //replace [entry_key] |
|
| 291 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 292 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 293 | 293 | |
| 294 | - //replace [input] |
|
| 295 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 296 | - global $frm_vars; |
|
| 297 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 294 | + //replace [input] |
|
| 295 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 296 | + global $frm_vars; |
|
| 297 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 298 | 298 | |
| 299 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 300 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 299 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 300 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 301 | 301 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 302 | 302 | |
| 303 | - $replace_with = ''; |
|
| 303 | + $replace_with = ''; |
|
| 304 | 304 | |
| 305 | - if ( $tag == 'input' ) { |
|
| 306 | - if ( isset($atts['opt']) ) { |
|
| 307 | - $atts['opt']--; |
|
| 308 | - } |
|
| 305 | + if ( $tag == 'input' ) { |
|
| 306 | + if ( isset($atts['opt']) ) { |
|
| 307 | + $atts['opt']--; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 311 | - if ( isset($atts['class']) ) { |
|
| 312 | - unset($atts['class']); |
|
| 313 | - } |
|
| 310 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 311 | + if ( isset($atts['class']) ) { |
|
| 312 | + unset($atts['class']); |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $field['shortcodes'] = $atts; |
|
| 316 | - ob_start(); |
|
| 315 | + $field['shortcodes'] = $atts; |
|
| 316 | + ob_start(); |
|
| 317 | 317 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 318 | - $replace_with = ob_get_contents(); |
|
| 319 | - ob_end_clean(); |
|
| 320 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 321 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 322 | - } |
|
| 318 | + $replace_with = ob_get_contents(); |
|
| 319 | + ob_end_clean(); |
|
| 320 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 321 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 325 | - } |
|
| 324 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | 327 | if ( $form ) { |
| 328 | - $form = (array) $form; |
|
| 328 | + $form = (array) $form; |
|
| 329 | 329 | |
| 330 | - //replace [form_key] |
|
| 331 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 330 | + //replace [form_key] |
|
| 331 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 332 | 332 | |
| 333 | - //replace [form_name] |
|
| 334 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 335 | - } |
|
| 336 | - $html .= "\n"; |
|
| 333 | + //replace [form_name] |
|
| 334 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
| 335 | + } |
|
| 336 | + $html .= "\n"; |
|
| 337 | 337 | |
| 338 | - //Return html if conf_field to prevent loop |
|
| 339 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 340 | - return $html; |
|
| 341 | - } |
|
| 338 | + //Return html if conf_field to prevent loop |
|
| 339 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 340 | + return $html; |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - //If field is in repeating section |
|
| 344 | - if ( $args['section_id'] ) { |
|
| 345 | - $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'] )); |
|
| 346 | - } else { |
|
| 347 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 348 | - } |
|
| 343 | + //If field is in repeating section |
|
| 344 | + if ( $args['section_id'] ) { |
|
| 345 | + $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'] )); |
|
| 346 | + } else { |
|
| 347 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | 350 | self::remove_collapse_shortcode( $html ); |
| 351 | 351 | |
@@ -353,18 +353,18 @@ discard block |
||
| 353 | 353 | $html = do_shortcode( $html ); |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - return $html; |
|
| 357 | - } |
|
| 356 | + return $html; |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | - * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
| 361 | - * |
|
| 362 | - * @since 2.0 |
|
| 363 | - * @param $error_class string, pass by reference |
|
| 364 | - * @param $field array |
|
| 365 | - * @param $field_id int |
|
| 366 | - * @param $html string |
|
| 367 | - */ |
|
| 360 | + * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
| 361 | + * |
|
| 362 | + * @since 2.0 |
|
| 363 | + * @param $error_class string, pass by reference |
|
| 364 | + * @param $field array |
|
| 365 | + * @param $field_id int |
|
| 366 | + * @param $html string |
|
| 367 | + */ |
|
| 368 | 368 | private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) { |
| 369 | 369 | $error_class .= ' frm_' . $field['label'] . '_container'; |
| 370 | 370 | if ( $field['id'] != $field_id ) { |
@@ -428,46 +428,46 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 432 | - if ( $no_vars ) { |
|
| 431 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 432 | + if ( $no_vars ) { |
|
| 433 | 433 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 434 | 434 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 435 | - } else { |
|
| 435 | + } else { |
|
| 436 | 436 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 437 | - } |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | 439 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 440 | - } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 443 | 443 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 444 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 445 | - $args['conditional_check'] = true; |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $prefix = ''; |
|
| 449 | - if ( $args['conditional_check'] ) { |
|
| 450 | - if ( $args['conditional'] ) { |
|
| 451 | - $prefix = 'if '; |
|
| 452 | - } else if ( $args['foreach'] ) { |
|
| 453 | - $prefix = 'foreach '; |
|
| 454 | - } |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 458 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 459 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 460 | - $tag = str_replace(']', '', $tag); |
|
| 461 | - $tags = explode(' ', $tag); |
|
| 462 | - if ( is_array($tags) ) { |
|
| 463 | - $tag = $tags[0]; |
|
| 464 | - } |
|
| 465 | - } else { |
|
| 466 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - return $tag; |
|
| 470 | - } |
|
| 444 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 445 | + $args['conditional_check'] = true; |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $prefix = ''; |
|
| 449 | + if ( $args['conditional_check'] ) { |
|
| 450 | + if ( $args['conditional'] ) { |
|
| 451 | + $prefix = 'if '; |
|
| 452 | + } else if ( $args['foreach'] ) { |
|
| 453 | + $prefix = 'foreach '; |
|
| 454 | + } |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 458 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 459 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 460 | + $tag = str_replace(']', '', $tag); |
|
| 461 | + $tags = explode(' ', $tag); |
|
| 462 | + if ( is_array($tags) ) { |
|
| 463 | + $tag = $tags[0]; |
|
| 464 | + } |
|
| 465 | + } else { |
|
| 466 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + return $tag; |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | 472 | /** |
| 473 | 473 | * Remove [collapse_this] if it's still included after all processing |
@@ -492,124 +492,124 @@ discard block |
||
| 492 | 492 | $class_prefix = 'frm-'; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if ( $lang != 'en' ) { |
|
| 495 | + if ( $lang != 'en' ) { |
|
| 496 | 496 | $api_js_url .= '&hl=' . $lang; |
| 497 | - } |
|
| 497 | + } |
|
| 498 | 498 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 499 | 499 | |
| 500 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 501 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 500 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 501 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 502 | 502 | |
| 503 | 503 | ?> |
| 504 | 504 | <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> |
| 505 | 505 | <?php |
| 506 | - } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | 508 | public static function show_single_option( $field ) { |
| 509 | - $field_name = $field['name']; |
|
| 510 | - $html_id = self::get_html_id($field); |
|
| 511 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 512 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 513 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 509 | + $field_name = $field['name']; |
|
| 510 | + $html_id = self::get_html_id($field); |
|
| 511 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 512 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 513 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 514 | 514 | |
| 515 | - // If this is an "Other" option, get the HTML for it |
|
| 515 | + // If this is an "Other" option, get the HTML for it |
|
| 516 | 516 | if ( self::is_other_opt( $opt_key ) ) { |
| 517 | - // Get string for Other text field, if needed |
|
| 517 | + // Get string for Other text field, if needed |
|
| 518 | 518 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 519 | 519 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 520 | - } else { |
|
| 520 | + } else { |
|
| 521 | 521 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 522 | - } |
|
| 523 | - } |
|
| 524 | - } |
|
| 522 | + } |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | 526 | public static function dropdown_categories( $args ) { |
| 527 | 527 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
| 528 | - $args = wp_parse_args($args, $defaults); |
|
| 528 | + $args = wp_parse_args($args, $defaults); |
|
| 529 | 529 | |
| 530 | - if ( ! $args['field'] ) { |
|
| 531 | - return; |
|
| 532 | - } |
|
| 530 | + if ( ! $args['field'] ) { |
|
| 531 | + return; |
|
| 532 | + } |
|
| 533 | 533 | |
| 534 | - if ( ! $args['name'] ) { |
|
| 534 | + if ( ! $args['name'] ) { |
|
| 535 | 535 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
| 536 | - } |
|
| 536 | + } |
|
| 537 | 537 | |
| 538 | - $id = self::get_html_id($args['field']); |
|
| 539 | - $class = $args['field']['type']; |
|
| 538 | + $id = self::get_html_id($args['field']); |
|
| 539 | + $class = $args['field']['type']; |
|
| 540 | 540 | |
| 541 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 542 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 541 | + $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 542 | + $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 543 | 543 | |
| 544 | - if ( is_array($args['field']['value']) ) { |
|
| 545 | - if ( ! empty($exclude) ) { |
|
| 546 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 547 | - } |
|
| 548 | - $selected = reset($args['field']['value']); |
|
| 549 | - } else { |
|
| 550 | - $selected = $args['field']['value']; |
|
| 551 | - } |
|
| 544 | + if ( is_array($args['field']['value']) ) { |
|
| 545 | + if ( ! empty($exclude) ) { |
|
| 546 | + $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 547 | + } |
|
| 548 | + $selected = reset($args['field']['value']); |
|
| 549 | + } else { |
|
| 550 | + $selected = $args['field']['value']; |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - $tax_atts = array( |
|
| 554 | - 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 555 | - 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 556 | - 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 557 | - ); |
|
| 553 | + $tax_atts = array( |
|
| 554 | + 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 555 | + 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 556 | + 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 557 | + ); |
|
| 558 | 558 | |
| 559 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 559 | + $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 560 | 560 | |
| 561 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 562 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 563 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 564 | - if ( ! $tax_atts['taxonomy'] ) { |
|
| 565 | - return; |
|
| 566 | - } |
|
| 561 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 562 | + $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 563 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 564 | + if ( ! $tax_atts['taxonomy'] ) { |
|
| 565 | + return; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 569 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 570 | - $tax_atts['exclude_tree'] = $exclude; |
|
| 571 | - } |
|
| 572 | - } |
|
| 568 | + // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 569 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 570 | + $tax_atts['exclude_tree'] = $exclude; |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
| 574 | + $dropdown = wp_dropdown_categories($tax_atts); |
|
| 575 | 575 | |
| 576 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 576 | + $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 577 | 577 | |
| 578 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 579 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 580 | - } |
|
| 578 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 579 | + $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | $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 ); |
| 583 | 583 | |
| 584 | - if ( is_array($args['field']['value']) ) { |
|
| 585 | - $skip = true; |
|
| 586 | - foreach ( $args['field']['value'] as $v ) { |
|
| 584 | + if ( is_array($args['field']['value']) ) { |
|
| 585 | + $skip = true; |
|
| 586 | + foreach ( $args['field']['value'] as $v ) { |
|
| 587 | 587 | if ( $skip ) { |
| 588 | - $skip = false; |
|
| 589 | - continue; |
|
| 590 | - } |
|
| 588 | + $skip = false; |
|
| 589 | + continue; |
|
| 590 | + } |
|
| 591 | 591 | $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
| 592 | - unset($v); |
|
| 593 | - } |
|
| 594 | - } |
|
| 592 | + unset($v); |
|
| 593 | + } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - return $dropdown; |
|
| 597 | - } |
|
| 596 | + return $dropdown; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | 599 | public static function get_term_link( $tax_id ) { |
| 600 | - $tax = get_taxonomy($tax_id); |
|
| 601 | - if ( ! $tax ) { |
|
| 602 | - return; |
|
| 603 | - } |
|
| 600 | + $tax = get_taxonomy($tax_id); |
|
| 601 | + if ( ! $tax ) { |
|
| 602 | + return; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | - $link = sprintf( |
|
| 606 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 605 | + $link = sprintf( |
|
| 606 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 607 | 607 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 608 | - ); |
|
| 609 | - unset($tax); |
|
| 608 | + ); |
|
| 609 | + unset($tax); |
|
| 610 | 610 | |
| 611 | - return $link; |
|
| 612 | - } |
|
| 611 | + return $link; |
|
| 612 | + } |
|
| 613 | 613 | |
| 614 | 614 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 615 | 615 | // Remove white space from hide_opt |
@@ -617,198 +617,198 @@ discard block |
||
| 617 | 617 | $hide_opt = rtrim( $hide_opt ); |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | - if ( is_array($observed_value) ) { |
|
| 621 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 622 | - } |
|
| 620 | + if ( is_array($observed_value) ) { |
|
| 621 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | $observed_value = str_replace( '&', '&', $observed_value ); |
| 625 | 625 | $hide_opt = str_replace( '&', '&', $hide_opt ); |
| 626 | 626 | |
| 627 | - $m = false; |
|
| 628 | - if ( $cond == '==' ) { |
|
| 629 | - $m = $observed_value == $hide_opt; |
|
| 630 | - } else if ( $cond == '!=' ) { |
|
| 631 | - $m = $observed_value != $hide_opt; |
|
| 632 | - } else if ( $cond == '>' ) { |
|
| 633 | - $m = $observed_value > $hide_opt; |
|
| 634 | - } else if ( $cond == '<' ) { |
|
| 635 | - $m = $observed_value < $hide_opt; |
|
| 636 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 637 | - $m = stripos($observed_value, $hide_opt); |
|
| 638 | - if ( $cond == 'not LIKE' ) { |
|
| 639 | - $m = ( $m === false ) ? true : false; |
|
| 640 | - } else { |
|
| 641 | - $m = ( $m === false ) ? false : true; |
|
| 642 | - } |
|
| 643 | - } |
|
| 644 | - return $m; |
|
| 645 | - } |
|
| 627 | + $m = false; |
|
| 628 | + if ( $cond == '==' ) { |
|
| 629 | + $m = $observed_value == $hide_opt; |
|
| 630 | + } else if ( $cond == '!=' ) { |
|
| 631 | + $m = $observed_value != $hide_opt; |
|
| 632 | + } else if ( $cond == '>' ) { |
|
| 633 | + $m = $observed_value > $hide_opt; |
|
| 634 | + } else if ( $cond == '<' ) { |
|
| 635 | + $m = $observed_value < $hide_opt; |
|
| 636 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 637 | + $m = stripos($observed_value, $hide_opt); |
|
| 638 | + if ( $cond == 'not LIKE' ) { |
|
| 639 | + $m = ( $m === false ) ? true : false; |
|
| 640 | + } else { |
|
| 641 | + $m = ( $m === false ) ? false : true; |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + return $m; |
|
| 645 | + } |
|
| 646 | 646 | |
| 647 | 647 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 648 | - $m = false; |
|
| 649 | - if ( $cond == '==' ) { |
|
| 650 | - if ( is_array($hide_opt) ) { |
|
| 651 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 652 | - $m = empty($m) ? false : true; |
|
| 653 | - } else { |
|
| 654 | - $m = in_array($hide_opt, $observed_value); |
|
| 655 | - } |
|
| 656 | - } else if ( $cond == '!=' ) { |
|
| 657 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 658 | - } else if ( $cond == '>' ) { |
|
| 659 | - $min = min($observed_value); |
|
| 660 | - $m = $min > $hide_opt; |
|
| 661 | - } else if ( $cond == '<' ) { |
|
| 662 | - $max = max($observed_value); |
|
| 663 | - $m = $max < $hide_opt; |
|
| 664 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 665 | - foreach ( $observed_value as $ob ) { |
|
| 666 | - $m = strpos($ob, $hide_opt); |
|
| 667 | - if ( $m !== false ) { |
|
| 668 | - $m = true; |
|
| 669 | - break; |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - if ( $cond == 'not LIKE' ) { |
|
| 674 | - $m = ( $m === false ) ? true : false; |
|
| 675 | - } |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - return $m; |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - /** |
|
| 682 | - * Replace a few basic shortcodes and field ids |
|
| 683 | - * @since 2.0 |
|
| 684 | - * @return string |
|
| 685 | - */ |
|
| 648 | + $m = false; |
|
| 649 | + if ( $cond == '==' ) { |
|
| 650 | + if ( is_array($hide_opt) ) { |
|
| 651 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 652 | + $m = empty($m) ? false : true; |
|
| 653 | + } else { |
|
| 654 | + $m = in_array($hide_opt, $observed_value); |
|
| 655 | + } |
|
| 656 | + } else if ( $cond == '!=' ) { |
|
| 657 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 658 | + } else if ( $cond == '>' ) { |
|
| 659 | + $min = min($observed_value); |
|
| 660 | + $m = $min > $hide_opt; |
|
| 661 | + } else if ( $cond == '<' ) { |
|
| 662 | + $max = max($observed_value); |
|
| 663 | + $m = $max < $hide_opt; |
|
| 664 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 665 | + foreach ( $observed_value as $ob ) { |
|
| 666 | + $m = strpos($ob, $hide_opt); |
|
| 667 | + if ( $m !== false ) { |
|
| 668 | + $m = true; |
|
| 669 | + break; |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + if ( $cond == 'not LIKE' ) { |
|
| 674 | + $m = ( $m === false ) ? true : false; |
|
| 675 | + } |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + return $m; |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + /** |
|
| 682 | + * Replace a few basic shortcodes and field ids |
|
| 683 | + * @since 2.0 |
|
| 684 | + * @return string |
|
| 685 | + */ |
|
| 686 | 686 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 687 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 688 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 689 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 690 | - } |
|
| 687 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 688 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 689 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 690 | + } |
|
| 691 | 691 | |
| 692 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 693 | - $value = do_shortcode($value); |
|
| 692 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 693 | + $value = do_shortcode($value); |
|
| 694 | 694 | |
| 695 | - return $value; |
|
| 696 | - } |
|
| 695 | + return $value; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | 698 | public static function get_shortcodes( $content, $form_id ) { |
| 699 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 700 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 701 | - } |
|
| 699 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 700 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 703 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 704 | 704 | |
| 705 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 705 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 706 | 706 | |
| 707 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 707 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 708 | 708 | |
| 709 | - return $matches; |
|
| 710 | - } |
|
| 709 | + return $matches; |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | 712 | public static function allowed_shortcodes( $fields = array() ) { |
| 713 | - $tagregexp = array( |
|
| 714 | - 'editlink', 'id', 'key', 'ip', |
|
| 715 | - 'siteurl', 'sitename', 'admin_email', |
|
| 716 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 713 | + $tagregexp = array( |
|
| 714 | + 'editlink', 'id', 'key', 'ip', |
|
| 715 | + 'siteurl', 'sitename', 'admin_email', |
|
| 716 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 717 | 717 | 'parent[-|_]id', |
| 718 | - ); |
|
| 718 | + ); |
|
| 719 | 719 | |
| 720 | - foreach ( $fields as $field ) { |
|
| 721 | - $tagregexp[] = $field->id; |
|
| 722 | - $tagregexp[] = $field->field_key; |
|
| 723 | - } |
|
| 720 | + foreach ( $fields as $field ) { |
|
| 721 | + $tagregexp[] = $field->id; |
|
| 722 | + $tagregexp[] = $field->field_key; |
|
| 723 | + } |
|
| 724 | 724 | |
| 725 | - $tagregexp = implode('|', $tagregexp); |
|
| 726 | - return $tagregexp; |
|
| 727 | - } |
|
| 725 | + $tagregexp = implode('|', $tagregexp); |
|
| 726 | + return $tagregexp; |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | 729 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 730 | - $shortcode_values = array( |
|
| 731 | - 'id' => $entry->id, |
|
| 732 | - 'key' => $entry->item_key, |
|
| 733 | - 'ip' => $entry->ip, |
|
| 734 | - ); |
|
| 730 | + $shortcode_values = array( |
|
| 731 | + 'id' => $entry->id, |
|
| 732 | + 'key' => $entry->item_key, |
|
| 733 | + 'ip' => $entry->ip, |
|
| 734 | + ); |
|
| 735 | 735 | |
| 736 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 737 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 736 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 737 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 738 | 738 | |
| 739 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 739 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 740 | 740 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 741 | - $tags = explode(' ', $tag); |
|
| 742 | - if ( is_array($tags) ) { |
|
| 743 | - $tag = $tags[0]; |
|
| 744 | - } |
|
| 745 | - } else { |
|
| 746 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 747 | - } |
|
| 748 | - |
|
| 749 | - switch ( $tag ) { |
|
| 750 | - case 'id': |
|
| 751 | - case 'key': |
|
| 752 | - case 'ip': |
|
| 753 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 754 | - break; |
|
| 755 | - |
|
| 756 | - case 'user_agent': |
|
| 757 | - case 'user-agent': |
|
| 758 | - $entry->description = maybe_unserialize($entry->description); |
|
| 741 | + $tags = explode(' ', $tag); |
|
| 742 | + if ( is_array($tags) ) { |
|
| 743 | + $tag = $tags[0]; |
|
| 744 | + } |
|
| 745 | + } else { |
|
| 746 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 747 | + } |
|
| 748 | + |
|
| 749 | + switch ( $tag ) { |
|
| 750 | + case 'id': |
|
| 751 | + case 'key': |
|
| 752 | + case 'ip': |
|
| 753 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 754 | + break; |
|
| 755 | + |
|
| 756 | + case 'user_agent': |
|
| 757 | + case 'user-agent': |
|
| 758 | + $entry->description = maybe_unserialize($entry->description); |
|
| 759 | 759 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 760 | - break; |
|
| 761 | - |
|
| 762 | - case 'created_at': |
|
| 763 | - case 'created-at': |
|
| 764 | - case 'updated_at': |
|
| 765 | - case 'updated-at': |
|
| 766 | - if ( isset($atts['format']) ) { |
|
| 767 | - $time_format = ' '; |
|
| 768 | - } else { |
|
| 769 | - $atts['format'] = get_option('date_format'); |
|
| 770 | - $time_format = ''; |
|
| 771 | - } |
|
| 772 | - |
|
| 773 | - $this_tag = str_replace('-', '_', $tag); |
|
| 774 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 775 | - unset($this_tag); |
|
| 776 | - break; |
|
| 777 | - |
|
| 778 | - case 'created_by': |
|
| 779 | - case 'created-by': |
|
| 780 | - case 'updated_by': |
|
| 781 | - case 'updated-by': |
|
| 782 | - $this_tag = str_replace('-', '_', $tag); |
|
| 760 | + break; |
|
| 761 | + |
|
| 762 | + case 'created_at': |
|
| 763 | + case 'created-at': |
|
| 764 | + case 'updated_at': |
|
| 765 | + case 'updated-at': |
|
| 766 | + if ( isset($atts['format']) ) { |
|
| 767 | + $time_format = ' '; |
|
| 768 | + } else { |
|
| 769 | + $atts['format'] = get_option('date_format'); |
|
| 770 | + $time_format = ''; |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + $this_tag = str_replace('-', '_', $tag); |
|
| 774 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 775 | + unset($this_tag); |
|
| 776 | + break; |
|
| 777 | + |
|
| 778 | + case 'created_by': |
|
| 779 | + case 'created-by': |
|
| 780 | + case 'updated_by': |
|
| 781 | + case 'updated-by': |
|
| 782 | + $this_tag = str_replace('-', '_', $tag); |
|
| 783 | 783 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 784 | - unset($this_tag); |
|
| 785 | - break; |
|
| 786 | - |
|
| 787 | - case 'admin_email': |
|
| 788 | - case 'siteurl': |
|
| 789 | - case 'frmurl': |
|
| 790 | - case 'sitename': |
|
| 791 | - case 'get': |
|
| 792 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 793 | - break; |
|
| 794 | - |
|
| 795 | - default: |
|
| 796 | - $field = FrmField::getOne( $tag ); |
|
| 797 | - if ( ! $field ) { |
|
| 798 | - break; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 802 | - |
|
| 803 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 804 | - |
|
| 805 | - $atts['entry_id'] = $entry->id; |
|
| 806 | - $atts['entry_key'] = $entry->item_key; |
|
| 807 | - |
|
| 808 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 809 | - $replace_with = $field->name; |
|
| 810 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 811 | - $replace_with = $field->description; |
|
| 784 | + unset($this_tag); |
|
| 785 | + break; |
|
| 786 | + |
|
| 787 | + case 'admin_email': |
|
| 788 | + case 'siteurl': |
|
| 789 | + case 'frmurl': |
|
| 790 | + case 'sitename': |
|
| 791 | + case 'get': |
|
| 792 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 793 | + break; |
|
| 794 | + |
|
| 795 | + default: |
|
| 796 | + $field = FrmField::getOne( $tag ); |
|
| 797 | + if ( ! $field ) { |
|
| 798 | + break; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 802 | + |
|
| 803 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 804 | + |
|
| 805 | + $atts['entry_id'] = $entry->id; |
|
| 806 | + $atts['entry_key'] = $entry->item_key; |
|
| 807 | + |
|
| 808 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 809 | + $replace_with = $field->name; |
|
| 810 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 811 | + $replace_with = $field->description; |
|
| 812 | 812 | } else { |
| 813 | 813 | $string_value = $replace_with; |
| 814 | 814 | if ( is_array( $replace_with ) ) { |
@@ -822,82 +822,82 @@ discard block |
||
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - unset($field); |
|
| 826 | - break; |
|
| 827 | - } |
|
| 825 | + unset($field); |
|
| 826 | + break; |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | - if ( isset($replace_with) ) { |
|
| 830 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 831 | - } |
|
| 829 | + if ( isset($replace_with) ) { |
|
| 830 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 831 | + } |
|
| 832 | 832 | |
| 833 | - unset($atts, $conditional, $replace_with); |
|
| 833 | + unset($atts, $conditional, $replace_with); |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | return $content; |
| 837 | - } |
|
| 838 | - |
|
| 839 | - /** |
|
| 840 | - * Get the value to replace a few standard shortcodes |
|
| 841 | - * |
|
| 842 | - * @since 2.0 |
|
| 843 | - * @return string |
|
| 844 | - */ |
|
| 845 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 846 | - $new_value = ''; |
|
| 847 | - switch ( $tag ) { |
|
| 848 | - case 'admin_email': |
|
| 849 | - $new_value = get_option('admin_email'); |
|
| 850 | - break; |
|
| 851 | - case 'siteurl': |
|
| 852 | - $new_value = FrmAppHelper::site_url(); |
|
| 853 | - break; |
|
| 854 | - case 'frmurl': |
|
| 855 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 856 | - break; |
|
| 857 | - case 'sitename': |
|
| 858 | - $new_value = FrmAppHelper::site_name(); |
|
| 859 | - break; |
|
| 860 | - case 'get': |
|
| 861 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 862 | - break; |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - return $new_value; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * Process the [get] shortcode |
|
| 870 | - * |
|
| 871 | - * @since 2.0 |
|
| 872 | - * @return string|array |
|
| 873 | - */ |
|
| 874 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 875 | - if ( ! isset($atts['param']) ) { |
|
| 876 | - return ''; |
|
| 877 | - } |
|
| 878 | - |
|
| 879 | - if ( strpos($atts['param'], '[') ) { |
|
| 880 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 881 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 885 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 886 | - |
|
| 887 | - if ( $new_value == '' ) { |
|
| 888 | - if ( ! isset($atts['prev_val']) ) { |
|
| 889 | - $atts['prev_val'] = ''; |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 896 | - $new_value = implode(', ', $new_value); |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - return $new_value; |
|
| 900 | - } |
|
| 837 | + } |
|
| 838 | + |
|
| 839 | + /** |
|
| 840 | + * Get the value to replace a few standard shortcodes |
|
| 841 | + * |
|
| 842 | + * @since 2.0 |
|
| 843 | + * @return string |
|
| 844 | + */ |
|
| 845 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 846 | + $new_value = ''; |
|
| 847 | + switch ( $tag ) { |
|
| 848 | + case 'admin_email': |
|
| 849 | + $new_value = get_option('admin_email'); |
|
| 850 | + break; |
|
| 851 | + case 'siteurl': |
|
| 852 | + $new_value = FrmAppHelper::site_url(); |
|
| 853 | + break; |
|
| 854 | + case 'frmurl': |
|
| 855 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 856 | + break; |
|
| 857 | + case 'sitename': |
|
| 858 | + $new_value = FrmAppHelper::site_name(); |
|
| 859 | + break; |
|
| 860 | + case 'get': |
|
| 861 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 862 | + break; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + return $new_value; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * Process the [get] shortcode |
|
| 870 | + * |
|
| 871 | + * @since 2.0 |
|
| 872 | + * @return string|array |
|
| 873 | + */ |
|
| 874 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 875 | + if ( ! isset($atts['param']) ) { |
|
| 876 | + return ''; |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + if ( strpos($atts['param'], '[') ) { |
|
| 880 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 881 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 885 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 886 | + |
|
| 887 | + if ( $new_value == '' ) { |
|
| 888 | + if ( ! isset($atts['prev_val']) ) { |
|
| 889 | + $atts['prev_val'] = ''; |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 896 | + $new_value = implode(', ', $new_value); |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + return $new_value; |
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | 902 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 903 | 903 | $atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -905,14 +905,14 @@ discard block |
||
| 905 | 905 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 906 | 906 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 907 | 907 | |
| 908 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 909 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 910 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 911 | - if ( is_array($replace_with) ) { |
|
| 912 | - $replace_with = implode("\n", $replace_with); |
|
| 913 | - } |
|
| 914 | - $replace_with = wpautop($replace_with); |
|
| 915 | - } |
|
| 908 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 909 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 910 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 911 | + if ( is_array($replace_with) ) { |
|
| 912 | + $replace_with = implode("\n", $replace_with); |
|
| 913 | + } |
|
| 914 | + $replace_with = wpautop($replace_with); |
|
| 915 | + } |
|
| 916 | 916 | unset( $autop ); |
| 917 | 917 | } else if ( is_array( $replace_with ) ) { |
| 918 | 918 | $replace_with = implode( $atts['sep'], $replace_with ); |
@@ -922,58 +922,58 @@ discard block |
||
| 922 | 922 | } |
| 923 | 923 | |
| 924 | 924 | public static function get_field_types( $type ) { |
| 925 | - $single_input = array( |
|
| 926 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 927 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 928 | - 'user_id', 'tag', 'password', |
|
| 929 | - ); |
|
| 925 | + $single_input = array( |
|
| 926 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 927 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 928 | + 'user_id', 'tag', 'password', |
|
| 929 | + ); |
|
| 930 | 930 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 931 | 931 | $other_type = array( 'divider', 'html', 'break' ); |
| 932 | 932 | |
| 933 | 933 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 934 | 934 | |
| 935 | - $field_types = array(); |
|
| 936 | - if ( in_array($type, $single_input) ) { |
|
| 937 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 938 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 939 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 940 | - } else if ( in_array($type, $other_type) ) { |
|
| 941 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 935 | + $field_types = array(); |
|
| 936 | + if ( in_array($type, $single_input) ) { |
|
| 937 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 938 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 939 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 940 | + } else if ( in_array($type, $other_type) ) { |
|
| 941 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 942 | 942 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 943 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 944 | - } |
|
| 943 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | 946 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 947 | - return $field_types; |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 951 | - foreach ( $inputs as $input ) { |
|
| 952 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 953 | - unset($input); |
|
| 954 | - } |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * Check if current field option is an "other" option |
|
| 959 | - * |
|
| 960 | - * @since 2.0.6 |
|
| 961 | - * |
|
| 962 | - * @param string $opt_key |
|
| 963 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 964 | - */ |
|
| 965 | - public static function is_other_opt( $opt_key ) { |
|
| 966 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - /** |
|
| 970 | - * Get value that belongs in "Other" text box |
|
| 971 | - * |
|
| 972 | - * @since 2.0.6 |
|
| 973 | - * |
|
| 974 | - * @param array $args |
|
| 975 | - */ |
|
| 976 | - public static function get_other_val( $args ) { |
|
| 947 | + return $field_types; |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 951 | + foreach ( $inputs as $input ) { |
|
| 952 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 953 | + unset($input); |
|
| 954 | + } |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * Check if current field option is an "other" option |
|
| 959 | + * |
|
| 960 | + * @since 2.0.6 |
|
| 961 | + * |
|
| 962 | + * @param string $opt_key |
|
| 963 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 964 | + */ |
|
| 965 | + public static function is_other_opt( $opt_key ) { |
|
| 966 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + /** |
|
| 970 | + * Get value that belongs in "Other" text box |
|
| 971 | + * |
|
| 972 | + * @since 2.0.6 |
|
| 973 | + * |
|
| 974 | + * @param array $args |
|
| 975 | + */ |
|
| 976 | + public static function get_other_val( $args ) { |
|
| 977 | 977 | $defaults = array( |
| 978 | 978 | 'opt_key' => 0, 'field' => array(), |
| 979 | 979 | 'parent' => false, 'pointer' => false, |
@@ -1049,20 +1049,20 @@ discard block |
||
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | 1051 | return $other_val; |
| 1052 | - } |
|
| 1053 | - |
|
| 1054 | - /** |
|
| 1055 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1056 | - * Intended for front-end use |
|
| 1057 | - * |
|
| 1058 | - * @since 2.0.6 |
|
| 1059 | - * |
|
| 1060 | - * @param array $args should include field, opt_key and field name |
|
| 1061 | - * @param boolean $other_opt |
|
| 1062 | - * @param string $checked |
|
| 1063 | - * @return string $other_val |
|
| 1064 | - */ |
|
| 1065 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1052 | + } |
|
| 1053 | + |
|
| 1054 | + /** |
|
| 1055 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1056 | + * Intended for front-end use |
|
| 1057 | + * |
|
| 1058 | + * @since 2.0.6 |
|
| 1059 | + * |
|
| 1060 | + * @param array $args should include field, opt_key and field name |
|
| 1061 | + * @param boolean $other_opt |
|
| 1062 | + * @param string $checked |
|
| 1063 | + * @return string $other_val |
|
| 1064 | + */ |
|
| 1065 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1066 | 1066 | //Check if this is an "Other" option |
| 1067 | 1067 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1068 | 1068 | return; |
@@ -1078,8 +1078,8 @@ discard block |
||
| 1078 | 1078 | $checked = 'checked="checked" '; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - return $other_args; |
|
| 1082 | - } |
|
| 1081 | + return $other_args; |
|
| 1082 | + } |
|
| 1083 | 1083 | |
| 1084 | 1084 | /** |
| 1085 | 1085 | * @param array $args |
@@ -1128,8 +1128,8 @@ discard block |
||
| 1128 | 1128 | * @since 2.0.6 |
| 1129 | 1129 | */ |
| 1130 | 1130 | public static function include_other_input( $args ) { |
| 1131 | - if ( ! $args['other_opt'] ) { |
|
| 1132 | - return; |
|
| 1131 | + if ( ! $args['other_opt'] ) { |
|
| 1132 | + return; |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | $classes = array( 'frm_other_input' ); |
@@ -1150,15 +1150,15 @@ discard block |
||
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | /** |
| 1153 | - * Get the HTML id for an "Other" text field |
|
| 1154 | - * Note: This does not affect fields in repeating sections |
|
| 1155 | - * |
|
| 1156 | - * @since 2.0.08 |
|
| 1157 | - * @param string $type - field type |
|
| 1158 | - * @param string $html_id |
|
| 1159 | - * @param string|boolean $opt_key |
|
| 1160 | - * @return string $other_id |
|
| 1161 | - */ |
|
| 1153 | + * Get the HTML id for an "Other" text field |
|
| 1154 | + * Note: This does not affect fields in repeating sections |
|
| 1155 | + * |
|
| 1156 | + * @since 2.0.08 |
|
| 1157 | + * @param string $type - field type |
|
| 1158 | + * @param string $html_id |
|
| 1159 | + * @param string|boolean $opt_key |
|
| 1160 | + * @return string $other_id |
|
| 1161 | + */ |
|
| 1162 | 1162 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1163 | 1163 | $other_id = $html_id; |
| 1164 | 1164 | |
@@ -1216,10 +1216,10 @@ discard block |
||
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | public static function switch_field_ids( $val ) { |
| 1219 | - global $frm_duplicate_ids; |
|
| 1220 | - $replace = array(); |
|
| 1221 | - $replace_with = array(); |
|
| 1222 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1219 | + global $frm_duplicate_ids; |
|
| 1220 | + $replace = array(); |
|
| 1221 | + $replace_with = array(); |
|
| 1222 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1223 | 1223 | $replace[] = '[if ' . $old . ']'; |
| 1224 | 1224 | $replace_with[] = '[if ' . $new . ']'; |
| 1225 | 1225 | $replace[] = '[if ' . $old . ' '; |
@@ -1234,153 +1234,153 @@ discard block |
||
| 1234 | 1234 | $replace_with[] = '[' . $new . ']'; |
| 1235 | 1235 | $replace[] = '[' . $old . ' '; |
| 1236 | 1236 | $replace_with[] = '[' . $new . ' '; |
| 1237 | - unset($old, $new); |
|
| 1238 | - } |
|
| 1237 | + unset($old, $new); |
|
| 1238 | + } |
|
| 1239 | 1239 | if ( is_array( $val ) ) { |
| 1240 | 1240 | foreach ( $val as $k => $v ) { |
| 1241 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1242 | - unset($k, $v); |
|
| 1243 | - } |
|
| 1244 | - } else { |
|
| 1245 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1246 | - } |
|
| 1247 | - |
|
| 1248 | - return $val; |
|
| 1249 | - } |
|
| 1250 | - |
|
| 1251 | - public static function get_us_states() { |
|
| 1252 | - return apply_filters( 'frm_us_states', array( |
|
| 1253 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1254 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1255 | - 'DC' => 'District of Columbia', |
|
| 1256 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1257 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1258 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1259 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1260 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1261 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1262 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1263 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1264 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1265 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1266 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1267 | - ) ); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - public static function get_countries() { |
|
| 1271 | - return apply_filters( 'frm_countries', array( |
|
| 1272 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1273 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1274 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1275 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1276 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1277 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1278 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1279 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1280 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1281 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1282 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1283 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1284 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1285 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1286 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1287 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1288 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1289 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1290 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1291 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1292 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1293 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1294 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1295 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1296 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1297 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1298 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1299 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1300 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1301 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1302 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1303 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1304 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1305 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1306 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1307 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1308 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1309 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1310 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1311 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1312 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1313 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1314 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1315 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1316 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1317 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1318 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1319 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1320 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1321 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1322 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1323 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1324 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1325 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1326 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1327 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1328 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1329 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1330 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1331 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1332 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1333 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1334 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1335 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1336 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1337 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1338 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1339 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1340 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1341 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1342 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1343 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1344 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1345 | - ) ); |
|
| 1346 | - } |
|
| 1241 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1242 | + unset($k, $v); |
|
| 1243 | + } |
|
| 1244 | + } else { |
|
| 1245 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1246 | + } |
|
| 1247 | + |
|
| 1248 | + return $val; |
|
| 1249 | + } |
|
| 1250 | + |
|
| 1251 | + public static function get_us_states() { |
|
| 1252 | + return apply_filters( 'frm_us_states', array( |
|
| 1253 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1254 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1255 | + 'DC' => 'District of Columbia', |
|
| 1256 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1257 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1258 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1259 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1260 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1261 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1262 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1263 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1264 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1265 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1266 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1267 | + ) ); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + public static function get_countries() { |
|
| 1271 | + return apply_filters( 'frm_countries', array( |
|
| 1272 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1273 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1274 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1275 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1276 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1277 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1278 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1279 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1280 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1281 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1282 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1283 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1284 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1285 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1286 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1287 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1288 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1289 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1290 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1291 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1292 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1293 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1294 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1295 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1296 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1297 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1298 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1299 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1300 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1301 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1302 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1303 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1304 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1305 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1306 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1307 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1308 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1309 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1310 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1311 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1312 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1313 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1314 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1315 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1316 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1317 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1318 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1319 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1320 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1321 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1322 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1323 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1324 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1325 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1326 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1327 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1328 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1329 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1330 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1331 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1332 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1333 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1334 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1335 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1336 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1337 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1338 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1339 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1340 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1341 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1342 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1343 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1344 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1345 | + ) ); |
|
| 1346 | + } |
|
| 1347 | 1347 | |
| 1348 | 1348 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1349 | 1349 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1350 | 1350 | |
| 1351 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1352 | - $state_abv = array_keys($states); |
|
| 1353 | - sort($state_abv); |
|
| 1351 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1352 | + $state_abv = array_keys($states); |
|
| 1353 | + sort($state_abv); |
|
| 1354 | 1354 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1355 | 1355 | |
| 1356 | - $states = array_values($states); |
|
| 1357 | - sort($states); |
|
| 1356 | + $states = array_values($states); |
|
| 1357 | + sort($states); |
|
| 1358 | 1358 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1359 | - unset($state_abv, $states); |
|
| 1359 | + unset($state_abv, $states); |
|
| 1360 | 1360 | |
| 1361 | 1361 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1362 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1363 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1364 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1365 | - ); |
|
| 1362 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1363 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1364 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1365 | + ); |
|
| 1366 | 1366 | |
| 1367 | 1367 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1368 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1369 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1370 | - ); |
|
| 1368 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1369 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1370 | + ); |
|
| 1371 | 1371 | |
| 1372 | 1372 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1373 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1374 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1375 | - ); |
|
| 1373 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1374 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1375 | + ); |
|
| 1376 | 1376 | |
| 1377 | 1377 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1378 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1379 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1380 | - ); |
|
| 1378 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1379 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1380 | + ); |
|
| 1381 | 1381 | |
| 1382 | 1382 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1383 | - } |
|
| 1383 | + } |
|
| 1384 | 1384 | |
| 1385 | 1385 | public static function field_selection() { |
| 1386 | 1386 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1417,8 +1417,8 @@ discard block |
||
| 1417 | 1417 | return FrmField::is_required( $field ); |
| 1418 | 1418 | } |
| 1419 | 1419 | |
| 1420 | - public static function maybe_get_field( &$field ) { |
|
| 1420 | + public static function maybe_get_field( &$field ) { |
|
| 1421 | 1421 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1422 | 1422 | FrmField::maybe_get_field( $field ); |
| 1423 | - } |
|
| 1423 | + } |
|
| 1424 | 1424 | } |