@@ -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 ( 'data' == $type ) { |
|
| 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 ( 'data' == $type ) { |
|
| 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,87 +84,87 @@ 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', |
| 126 | - 'in_section' => 0, |
|
| 127 | - ); |
|
| 126 | + 'in_section' => 0, |
|
| 127 | + ); |
|
| 128 | 128 | |
| 129 | 129 | if ( $limit ) { |
| 130 | - return $field_options; |
|
| 130 | + return $field_options; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - global $wpdb; |
|
| 133 | + global $wpdb; |
|
| 134 | 134 | |
| 135 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 136 | 136 | |
| 137 | 137 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 138 | 138 | |
| 139 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 139 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 140 | 140 | |
| 141 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 142 | - return array( |
|
| 143 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 141 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 142 | + return array( |
|
| 143 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 144 | 144 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
| 145 | 145 | 'field_order' => $field_count + 1, 'required' => false, |
| 146 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 147 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 146 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 147 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 148 | 148 | 'field_options' => $field_options, |
| 149 | - ); |
|
| 150 | - } |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 153 | - global $wpdb; |
|
| 152 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 153 | + global $wpdb; |
|
| 154 | 154 | |
| 155 | 155 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 156 | - $values['form_id'] = $form_id; |
|
| 157 | - $values['options'] = maybe_serialize($field->options); |
|
| 158 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 159 | - |
|
| 160 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 161 | - $values[ $col ] = $field->{$col}; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @since 2.0 |
|
| 167 | - */ |
|
| 156 | + $values['form_id'] = $form_id; |
|
| 157 | + $values['options'] = maybe_serialize($field->options); |
|
| 158 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 159 | + |
|
| 160 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 161 | + $values[ $col ] = $field->{$col}; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @since 2.0 |
|
| 167 | + */ |
|
| 168 | 168 | public static function get_error_msg( $field, $error ) { |
| 169 | 169 | $frm_settings = FrmAppHelper::get_settings(); |
| 170 | 170 | $default_settings = $frm_settings->default_options(); |
@@ -182,21 +182,21 @@ discard block |
||
| 182 | 182 | return $msg; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public static function get_form_fields( $form_id, $error = false ) { |
|
| 186 | - $fields = FrmField::get_all_for_form($form_id); |
|
| 187 | - $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 188 | - return $fields; |
|
| 189 | - } |
|
| 185 | + public static function get_form_fields( $form_id, $error = false ) { |
|
| 186 | + $fields = FrmField::get_all_for_form($form_id); |
|
| 187 | + $fields = apply_filters('frm_get_paged_fields', $fields, $form_id, $error); |
|
| 188 | + return $fields; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | public static function get_default_html( $type = 'text' ) { |
| 192 | 192 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 193 | 193 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 194 | - $for = ''; |
|
| 194 | + $for = ''; |
|
| 195 | 195 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 196 | - $for = 'for="field_[key]"'; |
|
| 197 | - } |
|
| 196 | + $for = 'for="field_[key]"'; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - $default_html = <<<DEFAULT_HTML |
|
| 199 | + $default_html = <<<DEFAULT_HTML |
|
| 200 | 200 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 201 | 201 | <label $for class="frm_primary_label">[field_name] |
| 202 | 202 | <span class="frm_required">[required_label]</span> |
@@ -206,145 +206,145 @@ discard block |
||
| 206 | 206 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 207 | 207 | </div> |
| 208 | 208 | DEFAULT_HTML; |
| 209 | - } else { |
|
| 209 | + } else { |
|
| 210 | 210 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 211 | - } |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 214 | - } |
|
| 213 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 217 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 217 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | 218 | |
| 219 | - $defaults = array( |
|
| 219 | + $defaults = array( |
|
| 220 | 220 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 221 | 221 | 'field_id' => $field['id'], |
| 222 | - 'field_plus_id' => '', |
|
| 223 | - 'section_id' => '', |
|
| 224 | - ); |
|
| 225 | - $args = wp_parse_args($args, $defaults); |
|
| 226 | - $field_name = $args['field_name']; |
|
| 227 | - $field_id = $args['field_id']; |
|
| 228 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 222 | + 'field_plus_id' => '', |
|
| 223 | + 'section_id' => '', |
|
| 224 | + ); |
|
| 225 | + $args = wp_parse_args($args, $defaults); |
|
| 226 | + $field_name = $args['field_name']; |
|
| 227 | + $field_id = $args['field_id']; |
|
| 228 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 229 | 229 | |
| 230 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 231 | - $field_name .= '[]'; |
|
| 232 | - } |
|
| 230 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 231 | + $field_name .= '[]'; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - //replace [id] |
|
| 235 | - $html = str_replace('[id]', $field_id, $html); |
|
| 234 | + //replace [id] |
|
| 235 | + $html = str_replace('[id]', $field_id, $html); |
|
| 236 | 236 | |
| 237 | - // Remove the for attribute for captcha |
|
| 238 | - if ( $field['type'] == 'captcha' ) { |
|
| 239 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 240 | - } |
|
| 237 | + // Remove the for attribute for captcha |
|
| 238 | + if ( $field['type'] == 'captcha' ) { |
|
| 239 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - // set the label for |
|
| 243 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 242 | + // set the label for |
|
| 243 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 244 | 244 | |
| 245 | - //replace [key] |
|
| 246 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 245 | + //replace [key] |
|
| 246 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 247 | 247 | |
| 248 | - //replace [description] and [required_label] and [error] |
|
| 248 | + //replace [description] and [required_label] and [error] |
|
| 249 | 249 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 250 | - if ( ! is_array( $errors ) ) { |
|
| 251 | - $errors = array(); |
|
| 252 | - } |
|
| 250 | + if ( ! is_array( $errors ) ) { |
|
| 251 | + $errors = array(); |
|
| 252 | + } |
|
| 253 | 253 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 254 | 254 | |
| 255 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 256 | - if ( $field['type'] == 'divider' ) { |
|
| 257 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 258 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 259 | - } else { |
|
| 260 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 261 | - } |
|
| 262 | - } |
|
| 255 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 256 | + if ( $field['type'] == 'divider' ) { |
|
| 257 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 258 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 259 | + } else { |
|
| 260 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
| 265 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 266 | - } |
|
| 265 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - //replace [required_class] |
|
| 268 | + //replace [required_class] |
|
| 269 | 269 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 270 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 270 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | 271 | |
| 272 | - //replace [label_position] |
|
| 273 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 274 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 272 | + //replace [label_position] |
|
| 273 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 274 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 275 | 275 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 276 | 276 | |
| 277 | - //replace [field_name] |
|
| 278 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 277 | + //replace [field_name] |
|
| 278 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 279 | 279 | |
| 280 | - //replace [error_class] |
|
| 280 | + //replace [error_class] |
|
| 281 | 281 | $error_class = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
| 282 | 282 | self::get_more_field_classes( $error_class, $field, $field_id, $html ); |
| 283 | 283 | if ( $field['type'] == 'html' && strpos( $html, '[error_class]' ) === false ) { |
| 284 | 284 | // there is no error_class shortcode to use for addign fields |
| 285 | 285 | $html = str_replace( 'class="frm_form_field', 'class="frm_form_field ' . $error_class, $html ); |
| 286 | 286 | } |
| 287 | - $html = str_replace('[error_class]', $error_class, $html); |
|
| 287 | + $html = str_replace('[error_class]', $error_class, $html); |
|
| 288 | 288 | |
| 289 | - //replace [entry_key] |
|
| 290 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 291 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 289 | + //replace [entry_key] |
|
| 290 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 291 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 292 | 292 | |
| 293 | - //replace [input] |
|
| 294 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 295 | - global $frm_vars; |
|
| 296 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 293 | + //replace [input] |
|
| 294 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 295 | + global $frm_vars; |
|
| 296 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 297 | 297 | |
| 298 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 299 | - $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 298 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 299 | + $atts = shortcode_parse_atts( $shortcodes[2][ $short_key ] ); |
|
| 300 | 300 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 301 | 301 | |
| 302 | - $replace_with = ''; |
|
| 302 | + $replace_with = ''; |
|
| 303 | 303 | |
| 304 | - if ( $tag == 'input' ) { |
|
| 305 | - if ( isset($atts['opt']) ) { |
|
| 306 | - $atts['opt']--; |
|
| 307 | - } |
|
| 304 | + if ( $tag == 'input' ) { |
|
| 305 | + if ( isset($atts['opt']) ) { |
|
| 306 | + $atts['opt']--; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 310 | - if ( isset($atts['class']) ) { |
|
| 311 | - unset($atts['class']); |
|
| 312 | - } |
|
| 309 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 310 | + if ( isset($atts['class']) ) { |
|
| 311 | + unset($atts['class']); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $field['shortcodes'] = $atts; |
|
| 315 | - ob_start(); |
|
| 314 | + $field['shortcodes'] = $atts; |
|
| 315 | + ob_start(); |
|
| 316 | 316 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 317 | - $replace_with = ob_get_contents(); |
|
| 318 | - ob_end_clean(); |
|
| 319 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 320 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 321 | - } |
|
| 317 | + $replace_with = ob_get_contents(); |
|
| 318 | + ob_end_clean(); |
|
| 319 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 320 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 324 | - } |
|
| 323 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | if ( $form ) { |
| 327 | - $form = (array) $form; |
|
| 327 | + $form = (array) $form; |
|
| 328 | 328 | |
| 329 | - //replace [form_key] |
|
| 330 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 329 | + //replace [form_key] |
|
| 330 | + $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 331 | 331 | |
| 332 | - //replace [form_name] |
|
| 333 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 334 | - } |
|
| 335 | - $html .= "\n"; |
|
| 332 | + //replace [form_name] |
|
| 333 | + $html = str_replace('[form_name]', $form['name'], $html); |
|
| 334 | + } |
|
| 335 | + $html .= "\n"; |
|
| 336 | 336 | |
| 337 | - //Return html if conf_field to prevent loop |
|
| 338 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 339 | - return $html; |
|
| 340 | - } |
|
| 337 | + //Return html if conf_field to prevent loop |
|
| 338 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 339 | + return $html; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - //If field is in repeating section |
|
| 343 | - if ( $args['section_id'] ) { |
|
| 344 | - $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'] )); |
|
| 345 | - } else { |
|
| 346 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 347 | - } |
|
| 342 | + //If field is in repeating section |
|
| 343 | + if ( $args['section_id'] ) { |
|
| 344 | + $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'] )); |
|
| 345 | + } else { |
|
| 346 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | 349 | self::remove_collapse_shortcode( $html ); |
| 350 | 350 | |
@@ -352,18 +352,18 @@ discard block |
||
| 352 | 352 | $html = do_shortcode( $html ); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - return $html; |
|
| 356 | - } |
|
| 355 | + return $html; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | /** |
| 359 | - * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
| 360 | - * |
|
| 361 | - * @since 2.0 |
|
| 362 | - * @param $error_class string, pass by reference |
|
| 363 | - * @param $field array |
|
| 364 | - * @param $field_id int |
|
| 365 | - * @param $html string |
|
| 366 | - */ |
|
| 359 | + * Add more classes to certain fields (like confirmation fields, other fields, repeating fields, etc.) |
|
| 360 | + * |
|
| 361 | + * @since 2.0 |
|
| 362 | + * @param $error_class string, pass by reference |
|
| 363 | + * @param $field array |
|
| 364 | + * @param $field_id int |
|
| 365 | + * @param $html string |
|
| 366 | + */ |
|
| 367 | 367 | private static function get_more_field_classes( &$error_class, $field, $field_id, $html ) { |
| 368 | 368 | $error_class .= ' frm_' . $field['label'] . '_container'; |
| 369 | 369 | if ( $field['id'] != $field_id ) { |
@@ -427,46 +427,46 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 431 | - if ( $no_vars ) { |
|
| 430 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 431 | + if ( $no_vars ) { |
|
| 432 | 432 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 433 | 433 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 434 | - } else { |
|
| 434 | + } else { |
|
| 435 | 435 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 436 | - } |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 439 | - } |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 442 | 442 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 443 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 444 | - $args['conditional_check'] = true; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - $prefix = ''; |
|
| 448 | - if ( $args['conditional_check'] ) { |
|
| 449 | - if ( $args['conditional'] ) { |
|
| 450 | - $prefix = 'if '; |
|
| 451 | - } else if ( $args['foreach'] ) { |
|
| 452 | - $prefix = 'foreach '; |
|
| 453 | - } |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 457 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 458 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 459 | - $tag = str_replace(']', '', $tag); |
|
| 460 | - $tags = explode(' ', $tag); |
|
| 461 | - if ( is_array($tags) ) { |
|
| 462 | - $tag = $tags[0]; |
|
| 463 | - } |
|
| 464 | - } else { |
|
| 465 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - return $tag; |
|
| 469 | - } |
|
| 443 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 444 | + $args['conditional_check'] = true; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + $prefix = ''; |
|
| 448 | + if ( $args['conditional_check'] ) { |
|
| 449 | + if ( $args['conditional'] ) { |
|
| 450 | + $prefix = 'if '; |
|
| 451 | + } else if ( $args['foreach'] ) { |
|
| 452 | + $prefix = 'foreach '; |
|
| 453 | + } |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 457 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 458 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 459 | + $tag = str_replace(']', '', $tag); |
|
| 460 | + $tags = explode(' ', $tag); |
|
| 461 | + if ( is_array($tags) ) { |
|
| 462 | + $tag = $tags[0]; |
|
| 463 | + } |
|
| 464 | + } else { |
|
| 465 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + return $tag; |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | 471 | /** |
| 472 | 472 | * Remove [collapse_this] if it's still included after all processing |
@@ -479,128 +479,128 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | public static function display_recaptcha( $field ) { |
| 482 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 483 | - $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field); |
|
| 482 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 483 | + $lang = apply_filters('frm_recaptcha_lang', $frm_settings->re_lang, $field); |
|
| 484 | 484 | |
| 485 | - $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit'; |
|
| 486 | - if ( $lang != 'en' ) { |
|
| 485 | + $api_js_url = 'https://www.google.com/recaptcha/api.js?onload=frmRecaptcha&render=explicit'; |
|
| 486 | + if ( $lang != 'en' ) { |
|
| 487 | 487 | $api_js_url .= '&hl=' . $lang; |
| 488 | - } |
|
| 489 | - $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url); |
|
| 488 | + } |
|
| 489 | + $api_js_url = apply_filters('frm_recpatcha_js_url', $api_js_url); |
|
| 490 | 490 | |
| 491 | - wp_register_script('recaptcha-api', $api_js_url, '', true); |
|
| 492 | - wp_enqueue_script('recaptcha-api'); |
|
| 491 | + wp_register_script('recaptcha-api', $api_js_url, '', true); |
|
| 492 | + wp_enqueue_script('recaptcha-api'); |
|
| 493 | 493 | |
| 494 | 494 | ?> |
| 495 | 495 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="frm-g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>"></div> |
| 496 | 496 | <?php |
| 497 | - } |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | 499 | public static function show_single_option( $field ) { |
| 500 | - $field_name = $field['name']; |
|
| 501 | - $html_id = self::get_html_id($field); |
|
| 502 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 503 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 504 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 500 | + $field_name = $field['name']; |
|
| 501 | + $html_id = self::get_html_id($field); |
|
| 502 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 503 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 504 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 505 | 505 | |
| 506 | - // If this is an "Other" option, get the HTML for it |
|
| 506 | + // If this is an "Other" option, get the HTML for it |
|
| 507 | 507 | if ( self::is_other_opt( $opt_key ) ) { |
| 508 | - // Get string for Other text field, if needed |
|
| 508 | + // Get string for Other text field, if needed |
|
| 509 | 509 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 510 | 510 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 511 | - } else { |
|
| 511 | + } else { |
|
| 512 | 512 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 513 | - } |
|
| 514 | - } |
|
| 515 | - } |
|
| 513 | + } |
|
| 514 | + } |
|
| 515 | + } |
|
| 516 | 516 | |
| 517 | 517 | public static function dropdown_categories( $args ) { |
| 518 | 518 | $defaults = array( 'field' => false, 'name' => false, 'show_option_all' => ' ' ); |
| 519 | - $args = wp_parse_args($args, $defaults); |
|
| 519 | + $args = wp_parse_args($args, $defaults); |
|
| 520 | 520 | |
| 521 | - if ( ! $args['field'] ) { |
|
| 522 | - return; |
|
| 523 | - } |
|
| 521 | + if ( ! $args['field'] ) { |
|
| 522 | + return; |
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - if ( ! $args['name'] ) { |
|
| 525 | + if ( ! $args['name'] ) { |
|
| 526 | 526 | $args['name'] = 'item_meta[' . $args['field']['id'] . ']'; |
| 527 | - } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - $id = self::get_html_id($args['field']); |
|
| 530 | - $class = $args['field']['type']; |
|
| 529 | + $id = self::get_html_id($args['field']); |
|
| 530 | + $class = $args['field']['type']; |
|
| 531 | 531 | |
| 532 | - $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 533 | - $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 532 | + $exclude = (is_array($args['field']['exclude_cat'])) ? implode(',', $args['field']['exclude_cat']) : $args['field']['exclude_cat']; |
|
| 533 | + $exclude = apply_filters('frm_exclude_cats', $exclude, $args['field']); |
|
| 534 | 534 | |
| 535 | - if ( is_array($args['field']['value']) ) { |
|
| 536 | - if ( ! empty($exclude) ) { |
|
| 537 | - $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 538 | - } |
|
| 539 | - $selected = reset($args['field']['value']); |
|
| 540 | - } else { |
|
| 541 | - $selected = $args['field']['value']; |
|
| 542 | - } |
|
| 535 | + if ( is_array($args['field']['value']) ) { |
|
| 536 | + if ( ! empty($exclude) ) { |
|
| 537 | + $args['field']['value'] = array_diff($args['field']['value'], explode(',', $exclude)); |
|
| 538 | + } |
|
| 539 | + $selected = reset($args['field']['value']); |
|
| 540 | + } else { |
|
| 541 | + $selected = $args['field']['value']; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - $tax_atts = array( |
|
| 545 | - 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 546 | - 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 547 | - 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 548 | - ); |
|
| 544 | + $tax_atts = array( |
|
| 545 | + 'show_option_all' => $args['show_option_all'], 'hierarchical' => 1, 'name' => $args['name'], |
|
| 546 | + 'id' => $id, 'exclude' => $exclude, 'class' => $class, 'selected' => $selected, |
|
| 547 | + 'hide_empty' => false, 'echo' => 0, 'orderby' => 'name', |
|
| 548 | + ); |
|
| 549 | 549 | |
| 550 | - $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 550 | + $tax_atts = apply_filters('frm_dropdown_cat', $tax_atts, $args['field']); |
|
| 551 | 551 | |
| 552 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 553 | - $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 554 | - $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 555 | - if ( ! $tax_atts['taxonomy'] ) { |
|
| 556 | - return; |
|
| 557 | - } |
|
| 552 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 553 | + $post_type = FrmProFormsHelper::post_type($args['field']['form_id']); |
|
| 554 | + $tax_atts['taxonomy'] = FrmProAppHelper::get_custom_taxonomy($post_type, $args['field']); |
|
| 555 | + if ( ! $tax_atts['taxonomy'] ) { |
|
| 556 | + return; |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | - // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 560 | - if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 561 | - $tax_atts['exclude_tree'] = $exclude; |
|
| 562 | - } |
|
| 563 | - } |
|
| 559 | + // If field type is dropdown (not Dynamic), exclude children when parent is excluded |
|
| 560 | + if ( $args['field']['type'] != 'data' && is_taxonomy_hierarchical($tax_atts['taxonomy']) ) { |
|
| 561 | + $tax_atts['exclude_tree'] = $exclude; |
|
| 562 | + } |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - $dropdown = wp_dropdown_categories($tax_atts); |
|
| 565 | + $dropdown = wp_dropdown_categories($tax_atts); |
|
| 566 | 566 | |
| 567 | - $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 567 | + $add_html = FrmFieldsController::input_html($args['field'], false); |
|
| 568 | 568 | |
| 569 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 570 | - $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 571 | - } |
|
| 569 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 570 | + $add_html .= FrmProFieldsController::input_html($args['field'], false); |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | 573 | $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 ); |
| 574 | 574 | |
| 575 | - if ( is_array($args['field']['value']) ) { |
|
| 576 | - $skip = true; |
|
| 577 | - foreach ( $args['field']['value'] as $v ) { |
|
| 575 | + if ( is_array($args['field']['value']) ) { |
|
| 576 | + $skip = true; |
|
| 577 | + foreach ( $args['field']['value'] as $v ) { |
|
| 578 | 578 | if ( $skip ) { |
| 579 | - $skip = false; |
|
| 580 | - continue; |
|
| 581 | - } |
|
| 579 | + $skip = false; |
|
| 580 | + continue; |
|
| 581 | + } |
|
| 582 | 582 | $dropdown = str_replace(' value="' . esc_attr( $v ) . '"', ' value="' . esc_attr( $v ) . '" selected="selected"', $dropdown ); |
| 583 | - unset($v); |
|
| 584 | - } |
|
| 585 | - } |
|
| 583 | + unset($v); |
|
| 584 | + } |
|
| 585 | + } |
|
| 586 | 586 | |
| 587 | - return $dropdown; |
|
| 588 | - } |
|
| 587 | + return $dropdown; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | 590 | public static function get_term_link( $tax_id ) { |
| 591 | - $tax = get_taxonomy($tax_id); |
|
| 592 | - if ( ! $tax ) { |
|
| 593 | - return; |
|
| 594 | - } |
|
| 591 | + $tax = get_taxonomy($tax_id); |
|
| 592 | + if ( ! $tax ) { |
|
| 593 | + return; |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - $link = sprintf( |
|
| 597 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 596 | + $link = sprintf( |
|
| 597 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 598 | 598 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 599 | - ); |
|
| 600 | - unset($tax); |
|
| 599 | + ); |
|
| 600 | + unset($tax); |
|
| 601 | 601 | |
| 602 | - return $link; |
|
| 603 | - } |
|
| 602 | + return $link; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | 605 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 606 | 606 | // Remove white space from hide_opt |
@@ -608,195 +608,195 @@ discard block |
||
| 608 | 608 | $hide_opt = rtrim( $hide_opt ); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if ( is_array($observed_value) ) { |
|
| 612 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - $m = false; |
|
| 616 | - if ( $cond == '==' ) { |
|
| 617 | - $m = $observed_value == $hide_opt; |
|
| 618 | - } else if ( $cond == '!=' ) { |
|
| 619 | - $m = $observed_value != $hide_opt; |
|
| 620 | - } else if ( $cond == '>' ) { |
|
| 621 | - $m = $observed_value > $hide_opt; |
|
| 622 | - } else if ( $cond == '<' ) { |
|
| 623 | - $m = $observed_value < $hide_opt; |
|
| 624 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 625 | - $m = stripos($observed_value, $hide_opt); |
|
| 626 | - if ( $cond == 'not LIKE' ) { |
|
| 627 | - $m = ( $m === false ) ? true : false; |
|
| 628 | - } else { |
|
| 629 | - $m = ( $m === false ) ? false : true; |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - return $m; |
|
| 633 | - } |
|
| 611 | + if ( is_array($observed_value) ) { |
|
| 612 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + $m = false; |
|
| 616 | + if ( $cond == '==' ) { |
|
| 617 | + $m = $observed_value == $hide_opt; |
|
| 618 | + } else if ( $cond == '!=' ) { |
|
| 619 | + $m = $observed_value != $hide_opt; |
|
| 620 | + } else if ( $cond == '>' ) { |
|
| 621 | + $m = $observed_value > $hide_opt; |
|
| 622 | + } else if ( $cond == '<' ) { |
|
| 623 | + $m = $observed_value < $hide_opt; |
|
| 624 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 625 | + $m = stripos($observed_value, $hide_opt); |
|
| 626 | + if ( $cond == 'not LIKE' ) { |
|
| 627 | + $m = ( $m === false ) ? true : false; |
|
| 628 | + } else { |
|
| 629 | + $m = ( $m === false ) ? false : true; |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | + return $m; |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | 635 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 636 | - $m = false; |
|
| 637 | - if ( $cond == '==' ) { |
|
| 638 | - if ( is_array($hide_opt) ) { |
|
| 639 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 640 | - $m = empty($m) ? false : true; |
|
| 641 | - } else { |
|
| 642 | - $m = in_array($hide_opt, $observed_value); |
|
| 643 | - } |
|
| 644 | - } else if ( $cond == '!=' ) { |
|
| 645 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 646 | - } else if ( $cond == '>' ) { |
|
| 647 | - $min = min($observed_value); |
|
| 648 | - $m = $min > $hide_opt; |
|
| 649 | - } else if ( $cond == '<' ) { |
|
| 650 | - $max = max($observed_value); |
|
| 651 | - $m = $max < $hide_opt; |
|
| 652 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 653 | - foreach ( $observed_value as $ob ) { |
|
| 654 | - $m = strpos($ob, $hide_opt); |
|
| 655 | - if ( $m !== false ) { |
|
| 656 | - $m = true; |
|
| 657 | - break; |
|
| 658 | - } |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - if ( $cond == 'not LIKE' ) { |
|
| 662 | - $m = ( $m === false ) ? true : false; |
|
| 663 | - } |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - return $m; |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - /** |
|
| 670 | - * Replace a few basic shortcodes and field ids |
|
| 671 | - * @since 2.0 |
|
| 672 | - * @return string |
|
| 673 | - */ |
|
| 636 | + $m = false; |
|
| 637 | + if ( $cond == '==' ) { |
|
| 638 | + if ( is_array($hide_opt) ) { |
|
| 639 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 640 | + $m = empty($m) ? false : true; |
|
| 641 | + } else { |
|
| 642 | + $m = in_array($hide_opt, $observed_value); |
|
| 643 | + } |
|
| 644 | + } else if ( $cond == '!=' ) { |
|
| 645 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 646 | + } else if ( $cond == '>' ) { |
|
| 647 | + $min = min($observed_value); |
|
| 648 | + $m = $min > $hide_opt; |
|
| 649 | + } else if ( $cond == '<' ) { |
|
| 650 | + $max = max($observed_value); |
|
| 651 | + $m = $max < $hide_opt; |
|
| 652 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 653 | + foreach ( $observed_value as $ob ) { |
|
| 654 | + $m = strpos($ob, $hide_opt); |
|
| 655 | + if ( $m !== false ) { |
|
| 656 | + $m = true; |
|
| 657 | + break; |
|
| 658 | + } |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + if ( $cond == 'not LIKE' ) { |
|
| 662 | + $m = ( $m === false ) ? true : false; |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + return $m; |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + /** |
|
| 670 | + * Replace a few basic shortcodes and field ids |
|
| 671 | + * @since 2.0 |
|
| 672 | + * @return string |
|
| 673 | + */ |
|
| 674 | 674 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 675 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 676 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 677 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 678 | - } |
|
| 675 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 676 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 677 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 681 | - $value = do_shortcode($value); |
|
| 680 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 681 | + $value = do_shortcode($value); |
|
| 682 | 682 | |
| 683 | - return $value; |
|
| 684 | - } |
|
| 683 | + return $value; |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | public static function get_shortcodes( $content, $form_id ) { |
| 687 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 688 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 689 | - } |
|
| 687 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 688 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 691 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 692 | 692 | |
| 693 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 693 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 694 | 694 | |
| 695 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 695 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 696 | 696 | |
| 697 | - return $matches; |
|
| 698 | - } |
|
| 697 | + return $matches; |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | 700 | public static function allowed_shortcodes( $fields = array() ) { |
| 701 | - $tagregexp = array( |
|
| 702 | - 'editlink', 'id', 'key', 'ip', |
|
| 703 | - 'siteurl', 'sitename', 'admin_email', |
|
| 704 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 701 | + $tagregexp = array( |
|
| 702 | + 'editlink', 'id', 'key', 'ip', |
|
| 703 | + 'siteurl', 'sitename', 'admin_email', |
|
| 704 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 705 | 705 | 'parent[-|_]id', |
| 706 | - ); |
|
| 706 | + ); |
|
| 707 | 707 | |
| 708 | - foreach ( $fields as $field ) { |
|
| 709 | - $tagregexp[] = $field->id; |
|
| 710 | - $tagregexp[] = $field->field_key; |
|
| 711 | - } |
|
| 708 | + foreach ( $fields as $field ) { |
|
| 709 | + $tagregexp[] = $field->id; |
|
| 710 | + $tagregexp[] = $field->field_key; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - $tagregexp = implode('|', $tagregexp); |
|
| 714 | - return $tagregexp; |
|
| 715 | - } |
|
| 713 | + $tagregexp = implode('|', $tagregexp); |
|
| 714 | + return $tagregexp; |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | 717 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 718 | - $shortcode_values = array( |
|
| 719 | - 'id' => $entry->id, |
|
| 720 | - 'key' => $entry->item_key, |
|
| 721 | - 'ip' => $entry->ip, |
|
| 722 | - ); |
|
| 718 | + $shortcode_values = array( |
|
| 719 | + 'id' => $entry->id, |
|
| 720 | + 'key' => $entry->item_key, |
|
| 721 | + 'ip' => $entry->ip, |
|
| 722 | + ); |
|
| 723 | 723 | |
| 724 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 725 | - $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 724 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 725 | + $atts = shortcode_parse_atts( $shortcodes[3][ $short_key ] ); |
|
| 726 | 726 | |
| 727 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 727 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 728 | 728 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 729 | - $tags = explode(' ', $tag); |
|
| 730 | - if ( is_array($tags) ) { |
|
| 731 | - $tag = $tags[0]; |
|
| 732 | - } |
|
| 733 | - } else { |
|
| 734 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - switch ( $tag ) { |
|
| 738 | - case 'id': |
|
| 739 | - case 'key': |
|
| 740 | - case 'ip': |
|
| 741 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 742 | - break; |
|
| 743 | - |
|
| 744 | - case 'user_agent': |
|
| 745 | - case 'user-agent': |
|
| 746 | - $entry->description = maybe_unserialize($entry->description); |
|
| 729 | + $tags = explode(' ', $tag); |
|
| 730 | + if ( is_array($tags) ) { |
|
| 731 | + $tag = $tags[0]; |
|
| 732 | + } |
|
| 733 | + } else { |
|
| 734 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + switch ( $tag ) { |
|
| 738 | + case 'id': |
|
| 739 | + case 'key': |
|
| 740 | + case 'ip': |
|
| 741 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 742 | + break; |
|
| 743 | + |
|
| 744 | + case 'user_agent': |
|
| 745 | + case 'user-agent': |
|
| 746 | + $entry->description = maybe_unserialize($entry->description); |
|
| 747 | 747 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 748 | - break; |
|
| 749 | - |
|
| 750 | - case 'created_at': |
|
| 751 | - case 'created-at': |
|
| 752 | - case 'updated_at': |
|
| 753 | - case 'updated-at': |
|
| 754 | - if ( isset($atts['format']) ) { |
|
| 755 | - $time_format = ' '; |
|
| 756 | - } else { |
|
| 757 | - $atts['format'] = get_option('date_format'); |
|
| 758 | - $time_format = ''; |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - $this_tag = str_replace('-', '_', $tag); |
|
| 762 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 763 | - unset($this_tag); |
|
| 764 | - break; |
|
| 765 | - |
|
| 766 | - case 'created_by': |
|
| 767 | - case 'created-by': |
|
| 768 | - case 'updated_by': |
|
| 769 | - case 'updated-by': |
|
| 770 | - $this_tag = str_replace('-', '_', $tag); |
|
| 748 | + break; |
|
| 749 | + |
|
| 750 | + case 'created_at': |
|
| 751 | + case 'created-at': |
|
| 752 | + case 'updated_at': |
|
| 753 | + case 'updated-at': |
|
| 754 | + if ( isset($atts['format']) ) { |
|
| 755 | + $time_format = ' '; |
|
| 756 | + } else { |
|
| 757 | + $atts['format'] = get_option('date_format'); |
|
| 758 | + $time_format = ''; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + $this_tag = str_replace('-', '_', $tag); |
|
| 762 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 763 | + unset($this_tag); |
|
| 764 | + break; |
|
| 765 | + |
|
| 766 | + case 'created_by': |
|
| 767 | + case 'created-by': |
|
| 768 | + case 'updated_by': |
|
| 769 | + case 'updated-by': |
|
| 770 | + $this_tag = str_replace('-', '_', $tag); |
|
| 771 | 771 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 772 | - unset($this_tag); |
|
| 773 | - break; |
|
| 774 | - |
|
| 775 | - case 'admin_email': |
|
| 776 | - case 'siteurl': |
|
| 777 | - case 'frmurl': |
|
| 778 | - case 'sitename': |
|
| 779 | - case 'get': |
|
| 780 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 781 | - break; |
|
| 782 | - |
|
| 783 | - default: |
|
| 784 | - $field = FrmField::getOne( $tag ); |
|
| 785 | - if ( ! $field ) { |
|
| 786 | - break; |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 790 | - |
|
| 791 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 792 | - |
|
| 793 | - $atts['entry_id'] = $entry->id; |
|
| 794 | - $atts['entry_key'] = $entry->item_key; |
|
| 795 | - |
|
| 796 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 797 | - $replace_with = $field->name; |
|
| 798 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 799 | - $replace_with = $field->description; |
|
| 772 | + unset($this_tag); |
|
| 773 | + break; |
|
| 774 | + |
|
| 775 | + case 'admin_email': |
|
| 776 | + case 'siteurl': |
|
| 777 | + case 'frmurl': |
|
| 778 | + case 'sitename': |
|
| 779 | + case 'get': |
|
| 780 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 781 | + break; |
|
| 782 | + |
|
| 783 | + default: |
|
| 784 | + $field = FrmField::getOne( $tag ); |
|
| 785 | + if ( ! $field ) { |
|
| 786 | + break; |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 790 | + |
|
| 791 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 792 | + |
|
| 793 | + $atts['entry_id'] = $entry->id; |
|
| 794 | + $atts['entry_key'] = $entry->item_key; |
|
| 795 | + |
|
| 796 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 797 | + $replace_with = $field->name; |
|
| 798 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 799 | + $replace_with = $field->description; |
|
| 800 | 800 | } else { |
| 801 | 801 | $string_value = $replace_with; |
| 802 | 802 | if ( is_array( $replace_with ) ) { |
@@ -810,82 +810,82 @@ discard block |
||
| 810 | 810 | } |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - unset($field); |
|
| 814 | - break; |
|
| 815 | - } |
|
| 813 | + unset($field); |
|
| 814 | + break; |
|
| 815 | + } |
|
| 816 | 816 | |
| 817 | - if ( isset($replace_with) ) { |
|
| 818 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 819 | - } |
|
| 817 | + if ( isset($replace_with) ) { |
|
| 818 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | - unset($atts, $conditional, $replace_with); |
|
| 821 | + unset($atts, $conditional, $replace_with); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | return $content; |
| 825 | - } |
|
| 826 | - |
|
| 827 | - /** |
|
| 828 | - * Get the value to replace a few standard shortcodes |
|
| 829 | - * |
|
| 830 | - * @since 2.0 |
|
| 831 | - * @return string |
|
| 832 | - */ |
|
| 833 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 834 | - $new_value = ''; |
|
| 835 | - switch ( $tag ) { |
|
| 836 | - case 'admin_email': |
|
| 837 | - $new_value = get_option('admin_email'); |
|
| 838 | - break; |
|
| 839 | - case 'siteurl': |
|
| 840 | - $new_value = FrmAppHelper::site_url(); |
|
| 841 | - break; |
|
| 842 | - case 'frmurl': |
|
| 843 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 844 | - break; |
|
| 845 | - case 'sitename': |
|
| 846 | - $new_value = FrmAppHelper::site_name(); |
|
| 847 | - break; |
|
| 848 | - case 'get': |
|
| 849 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 850 | - break; |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - return $new_value; |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - /** |
|
| 857 | - * Process the [get] shortcode |
|
| 858 | - * |
|
| 859 | - * @since 2.0 |
|
| 860 | - * @return string|array |
|
| 861 | - */ |
|
| 862 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 863 | - if ( ! isset($atts['param']) ) { |
|
| 864 | - return ''; |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - if ( strpos($atts['param'], '[') ) { |
|
| 868 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 869 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 870 | - } |
|
| 871 | - |
|
| 872 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 873 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 874 | - |
|
| 875 | - if ( $new_value == '' ) { |
|
| 876 | - if ( ! isset($atts['prev_val']) ) { |
|
| 877 | - $atts['prev_val'] = ''; |
|
| 878 | - } |
|
| 879 | - |
|
| 880 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 884 | - $new_value = implode(', ', $new_value); |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - return $new_value; |
|
| 888 | - } |
|
| 825 | + } |
|
| 826 | + |
|
| 827 | + /** |
|
| 828 | + * Get the value to replace a few standard shortcodes |
|
| 829 | + * |
|
| 830 | + * @since 2.0 |
|
| 831 | + * @return string |
|
| 832 | + */ |
|
| 833 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 834 | + $new_value = ''; |
|
| 835 | + switch ( $tag ) { |
|
| 836 | + case 'admin_email': |
|
| 837 | + $new_value = get_option('admin_email'); |
|
| 838 | + break; |
|
| 839 | + case 'siteurl': |
|
| 840 | + $new_value = FrmAppHelper::site_url(); |
|
| 841 | + break; |
|
| 842 | + case 'frmurl': |
|
| 843 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 844 | + break; |
|
| 845 | + case 'sitename': |
|
| 846 | + $new_value = FrmAppHelper::site_name(); |
|
| 847 | + break; |
|
| 848 | + case 'get': |
|
| 849 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 850 | + break; |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + return $new_value; |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | + * Process the [get] shortcode |
|
| 858 | + * |
|
| 859 | + * @since 2.0 |
|
| 860 | + * @return string|array |
|
| 861 | + */ |
|
| 862 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 863 | + if ( ! isset($atts['param']) ) { |
|
| 864 | + return ''; |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + if ( strpos($atts['param'], '[') ) { |
|
| 868 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 869 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 870 | + } |
|
| 871 | + |
|
| 872 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 873 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 874 | + |
|
| 875 | + if ( $new_value == '' ) { |
|
| 876 | + if ( ! isset($atts['prev_val']) ) { |
|
| 877 | + $atts['prev_val'] = ''; |
|
| 878 | + } |
|
| 879 | + |
|
| 880 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 884 | + $new_value = implode(', ', $new_value); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + return $new_value; |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | 890 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 891 | 891 | $atts['sep'] = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -893,14 +893,14 @@ discard block |
||
| 893 | 893 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 894 | 894 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 895 | 895 | |
| 896 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 897 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 898 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 899 | - if ( is_array($replace_with) ) { |
|
| 900 | - $replace_with = implode("\n", $replace_with); |
|
| 901 | - } |
|
| 902 | - $replace_with = wpautop($replace_with); |
|
| 903 | - } |
|
| 896 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 897 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 898 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 899 | + if ( is_array($replace_with) ) { |
|
| 900 | + $replace_with = implode("\n", $replace_with); |
|
| 901 | + } |
|
| 902 | + $replace_with = wpautop($replace_with); |
|
| 903 | + } |
|
| 904 | 904 | unset( $autop ); |
| 905 | 905 | } else if ( is_array( $replace_with ) ) { |
| 906 | 906 | $replace_with = implode( $atts['sep'], $replace_with ); |
@@ -910,57 +910,57 @@ discard block |
||
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | public static function get_field_types( $type ) { |
| 913 | - $single_input = array( |
|
| 914 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 915 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 916 | - 'user_id', 'tag', 'password', |
|
| 917 | - ); |
|
| 913 | + $single_input = array( |
|
| 914 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 915 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 916 | + 'user_id', 'tag', 'password', |
|
| 917 | + ); |
|
| 918 | 918 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale' ); |
| 919 | 919 | $other_type = array( 'divider', 'html', 'break' ); |
| 920 | 920 | |
| 921 | 921 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 922 | 922 | |
| 923 | - $field_types = array(); |
|
| 924 | - if ( in_array($type, $single_input) ) { |
|
| 925 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 926 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 927 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 928 | - } else if ( in_array($type, $other_type) ) { |
|
| 929 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 923 | + $field_types = array(); |
|
| 924 | + if ( in_array($type, $single_input) ) { |
|
| 925 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 926 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 927 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 928 | + } else if ( in_array($type, $other_type) ) { |
|
| 929 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 930 | 930 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 931 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 932 | - } |
|
| 933 | - |
|
| 934 | - return $field_types; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 938 | - foreach ( $inputs as $input ) { |
|
| 939 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 940 | - unset($input); |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * Check if current field option is an "other" option |
|
| 946 | - * |
|
| 947 | - * @since 2.0.6 |
|
| 948 | - * |
|
| 949 | - * @param string $opt_key |
|
| 950 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 951 | - */ |
|
| 952 | - public static function is_other_opt( $opt_key ) { |
|
| 953 | - return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 954 | - } |
|
| 955 | - |
|
| 956 | - /** |
|
| 957 | - * Get value that belongs in "Other" text box |
|
| 958 | - * |
|
| 959 | - * @since 2.0.6 |
|
| 960 | - * |
|
| 961 | - * @param array $args |
|
| 962 | - */ |
|
| 963 | - public static function get_other_val( $args ) { |
|
| 931 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 932 | + } |
|
| 933 | + |
|
| 934 | + return $field_types; |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 938 | + foreach ( $inputs as $input ) { |
|
| 939 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 940 | + unset($input); |
|
| 941 | + } |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + /** |
|
| 945 | + * Check if current field option is an "other" option |
|
| 946 | + * |
|
| 947 | + * @since 2.0.6 |
|
| 948 | + * |
|
| 949 | + * @param string $opt_key |
|
| 950 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 951 | + */ |
|
| 952 | + public static function is_other_opt( $opt_key ) { |
|
| 953 | + return $opt_key && strpos( $opt_key, 'other' ) !== false; |
|
| 954 | + } |
|
| 955 | + |
|
| 956 | + /** |
|
| 957 | + * Get value that belongs in "Other" text box |
|
| 958 | + * |
|
| 959 | + * @since 2.0.6 |
|
| 960 | + * |
|
| 961 | + * @param array $args |
|
| 962 | + */ |
|
| 963 | + public static function get_other_val( $args ) { |
|
| 964 | 964 | $defaults = array( |
| 965 | 965 | 'opt_key' => 0, 'field' => array(), |
| 966 | 966 | 'parent' => false, 'pointer' => false, |
@@ -1036,20 +1036,20 @@ discard block |
||
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | return $other_val; |
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - /** |
|
| 1042 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1043 | - * Intended for front-end use |
|
| 1044 | - * |
|
| 1045 | - * @since 2.0.6 |
|
| 1046 | - * |
|
| 1047 | - * @param array $args should include field, opt_key and field name |
|
| 1048 | - * @param boolean $other_opt |
|
| 1049 | - * @param string $checked |
|
| 1050 | - * @return string $other_val |
|
| 1051 | - */ |
|
| 1052 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + /** |
|
| 1042 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 1043 | + * Intended for front-end use |
|
| 1044 | + * |
|
| 1045 | + * @since 2.0.6 |
|
| 1046 | + * |
|
| 1047 | + * @param array $args should include field, opt_key and field name |
|
| 1048 | + * @param boolean $other_opt |
|
| 1049 | + * @param string $checked |
|
| 1050 | + * @return string $other_val |
|
| 1051 | + */ |
|
| 1052 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 1053 | 1053 | //Check if this is an "Other" option |
| 1054 | 1054 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 1055 | 1055 | return; |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | $checked = 'checked="checked" '; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - return $other_args; |
|
| 1069 | - } |
|
| 1068 | + return $other_args; |
|
| 1069 | + } |
|
| 1070 | 1070 | |
| 1071 | 1071 | /** |
| 1072 | 1072 | * @param array $args |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | * @since 2.0.6 |
| 1116 | 1116 | */ |
| 1117 | 1117 | public static function include_other_input( $args ) { |
| 1118 | - if ( ! $args['other_opt'] ) { |
|
| 1119 | - return; |
|
| 1118 | + if ( ! $args['other_opt'] ) { |
|
| 1119 | + return; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | $classes = array( 'frm_other_input' ); |
@@ -1137,15 +1137,15 @@ discard block |
||
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | 1139 | /** |
| 1140 | - * Get the HTML id for an "Other" text field |
|
| 1141 | - * Note: This does not affect fields in repeating sections |
|
| 1142 | - * |
|
| 1143 | - * @since 2.0.08 |
|
| 1144 | - * @param string $type - field type |
|
| 1145 | - * @param string $html_id |
|
| 1146 | - * @param string|boolean $opt_key |
|
| 1147 | - * @return string $other_id |
|
| 1148 | - */ |
|
| 1140 | + * Get the HTML id for an "Other" text field |
|
| 1141 | + * Note: This does not affect fields in repeating sections |
|
| 1142 | + * |
|
| 1143 | + * @since 2.0.08 |
|
| 1144 | + * @param string $type - field type |
|
| 1145 | + * @param string $html_id |
|
| 1146 | + * @param string|boolean $opt_key |
|
| 1147 | + * @return string $other_id |
|
| 1148 | + */ |
|
| 1149 | 1149 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1150 | 1150 | $other_id = $html_id; |
| 1151 | 1151 | |
@@ -1203,10 +1203,10 @@ discard block |
||
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | public static function switch_field_ids( $val ) { |
| 1206 | - global $frm_duplicate_ids; |
|
| 1207 | - $replace = array(); |
|
| 1208 | - $replace_with = array(); |
|
| 1209 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1206 | + global $frm_duplicate_ids; |
|
| 1207 | + $replace = array(); |
|
| 1208 | + $replace_with = array(); |
|
| 1209 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1210 | 1210 | $replace[] = '[if ' . $old . ']'; |
| 1211 | 1211 | $replace_with[] = '[if ' . $new . ']'; |
| 1212 | 1212 | $replace[] = '[if ' . $old . ' '; |
@@ -1221,153 +1221,153 @@ discard block |
||
| 1221 | 1221 | $replace_with[] = '[' . $new . ']'; |
| 1222 | 1222 | $replace[] = '[' . $old . ' '; |
| 1223 | 1223 | $replace_with[] = '[' . $new . ' '; |
| 1224 | - unset($old, $new); |
|
| 1225 | - } |
|
| 1224 | + unset($old, $new); |
|
| 1225 | + } |
|
| 1226 | 1226 | if ( is_array( $val ) ) { |
| 1227 | 1227 | foreach ( $val as $k => $v ) { |
| 1228 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1229 | - unset($k, $v); |
|
| 1230 | - } |
|
| 1231 | - } else { |
|
| 1232 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - return $val; |
|
| 1236 | - } |
|
| 1237 | - |
|
| 1238 | - public static function get_us_states() { |
|
| 1239 | - return apply_filters( 'frm_us_states', array( |
|
| 1240 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1241 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1242 | - 'DC' => 'District of Columbia', |
|
| 1243 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1244 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1245 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1246 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1247 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1248 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1249 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1250 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1251 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1252 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1253 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1254 | - ) ); |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - public static function get_countries() { |
|
| 1258 | - return apply_filters( 'frm_countries', array( |
|
| 1259 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1260 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1261 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1262 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1263 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1264 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1265 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1266 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1267 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1268 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1269 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1270 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1271 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1272 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1273 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1274 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1275 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1276 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1277 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1278 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1279 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1280 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1281 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1282 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1283 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1284 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1285 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1286 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1287 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1288 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1289 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1290 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1291 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1292 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1293 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1294 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1295 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1296 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1297 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1298 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1299 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1300 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1301 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1302 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1303 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1304 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1305 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1306 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1307 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1308 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1309 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1310 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1311 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1312 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1313 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1314 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1315 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1316 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1317 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1318 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1319 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1320 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1321 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1322 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1323 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1324 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1325 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1326 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1327 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1328 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1329 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1330 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1331 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1332 | - ) ); |
|
| 1333 | - } |
|
| 1228 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1229 | + unset($k, $v); |
|
| 1230 | + } |
|
| 1231 | + } else { |
|
| 1232 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + return $val; |
|
| 1236 | + } |
|
| 1237 | + |
|
| 1238 | + public static function get_us_states() { |
|
| 1239 | + return apply_filters( 'frm_us_states', array( |
|
| 1240 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1241 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1242 | + 'DC' => 'District of Columbia', |
|
| 1243 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1244 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1245 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1246 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1247 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1248 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1249 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1250 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1251 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1252 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1253 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1254 | + ) ); |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + public static function get_countries() { |
|
| 1258 | + return apply_filters( 'frm_countries', array( |
|
| 1259 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1260 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1261 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1262 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1263 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1264 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1265 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1266 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1267 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1268 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1269 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1270 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1271 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1272 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1273 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1274 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1275 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1276 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1277 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1278 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1279 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1280 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1281 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1282 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1283 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1284 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1285 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1286 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1287 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1288 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1289 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1290 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1291 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1292 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1293 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1294 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1295 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1296 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1297 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1298 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1299 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1300 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1301 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1302 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1303 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1304 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1305 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1306 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1307 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1308 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1309 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1310 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1311 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1312 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1313 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1314 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1315 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1316 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1317 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1318 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1319 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1320 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1321 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1322 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1323 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1324 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1325 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1326 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1327 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1328 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1329 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1330 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1331 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1332 | + ) ); |
|
| 1333 | + } |
|
| 1334 | 1334 | |
| 1335 | 1335 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1336 | 1336 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1337 | 1337 | |
| 1338 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1339 | - $state_abv = array_keys($states); |
|
| 1340 | - sort($state_abv); |
|
| 1338 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1339 | + $state_abv = array_keys($states); |
|
| 1340 | + sort($state_abv); |
|
| 1341 | 1341 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1342 | 1342 | |
| 1343 | - $states = array_values($states); |
|
| 1344 | - sort($states); |
|
| 1343 | + $states = array_values($states); |
|
| 1344 | + sort($states); |
|
| 1345 | 1345 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1346 | - unset($state_abv, $states); |
|
| 1346 | + unset($state_abv, $states); |
|
| 1347 | 1347 | |
| 1348 | 1348 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1349 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1350 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1351 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1352 | - ); |
|
| 1349 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1350 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1351 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1352 | + ); |
|
| 1353 | 1353 | |
| 1354 | 1354 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1355 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1356 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1357 | - ); |
|
| 1355 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1356 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1357 | + ); |
|
| 1358 | 1358 | |
| 1359 | 1359 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1360 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1361 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1362 | - ); |
|
| 1360 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1361 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1362 | + ); |
|
| 1363 | 1363 | |
| 1364 | 1364 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1365 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1366 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1367 | - ); |
|
| 1365 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1366 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1367 | + ); |
|
| 1368 | 1368 | |
| 1369 | 1369 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1370 | - } |
|
| 1370 | + } |
|
| 1371 | 1371 | |
| 1372 | 1372 | public static function field_selection() { |
| 1373 | 1373 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::field_selection' ); |
@@ -1404,8 +1404,8 @@ discard block |
||
| 1404 | 1404 | return FrmField::is_required( $field ); |
| 1405 | 1405 | } |
| 1406 | 1406 | |
| 1407 | - public static function maybe_get_field( &$field ) { |
|
| 1407 | + public static function maybe_get_field( &$field ) { |
|
| 1408 | 1408 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1409 | 1409 | FrmField::maybe_get_field( $field ); |
| 1410 | - } |
|
| 1410 | + } |
|
| 1411 | 1411 | } |
@@ -1,91 +1,91 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | - /** |
|
| 5 | - * Trigger plugin-wide hook loading |
|
| 6 | - */ |
|
| 7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | - |
|
| 10 | - $trigger_hooks = $hooks; |
|
| 11 | - $hooks = (array) $hooks; |
|
| 12 | - |
|
| 13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | - if ( is_admin() ) { |
|
| 15 | - $hooks[] = 'load_admin_hooks'; |
|
| 16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | - $hooks[] = 'load_ajax_hooks'; |
|
| 18 | - $hooks[] = 'load_form_hooks'; |
|
| 19 | - } |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - if ( is_multisite() ) { |
|
| 23 | - $hooks[] = 'load_multisite_hooks'; |
|
| 24 | - } |
|
| 25 | - } else { |
|
| 26 | - // Make sure the hooks are only triggered once |
|
| 27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 28 | - } |
|
| 29 | - unset( $trigger_hooks ); |
|
| 30 | - |
|
| 31 | - // Instansiate Controllers |
|
| 32 | - foreach ( $controllers as $c ) { |
|
| 33 | - foreach ( $hooks as $hook ) { |
|
| 4 | + /** |
|
| 5 | + * Trigger plugin-wide hook loading |
|
| 6 | + */ |
|
| 7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | + |
|
| 10 | + $trigger_hooks = $hooks; |
|
| 11 | + $hooks = (array) $hooks; |
|
| 12 | + |
|
| 13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | + if ( is_admin() ) { |
|
| 15 | + $hooks[] = 'load_admin_hooks'; |
|
| 16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | + $hooks[] = 'load_ajax_hooks'; |
|
| 18 | + $hooks[] = 'load_form_hooks'; |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + if ( is_multisite() ) { |
|
| 23 | + $hooks[] = 'load_multisite_hooks'; |
|
| 24 | + } |
|
| 25 | + } else { |
|
| 26 | + // Make sure the hooks are only triggered once |
|
| 27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 28 | + } |
|
| 29 | + unset( $trigger_hooks ); |
|
| 30 | + |
|
| 31 | + // Instansiate Controllers |
|
| 32 | + foreach ( $controllers as $c ) { |
|
| 33 | + foreach ( $hooks as $hook ) { |
|
| 34 | 34 | call_user_func( array( $c, $hook ) ); |
| 35 | 35 | unset( $hook ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | unset( $c ); |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public static function trigger_load_form_hooks() { |
|
| 43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | - } |
|
| 42 | + public static function trigger_load_form_hooks() { |
|
| 43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | public static function load_hooks() { |
| 47 | - if ( ! is_admin() ) { |
|
| 48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | - |
|
| 54 | - // Entries controller |
|
| 55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | - |
|
| 61 | - // Form Actions Controller |
|
| 62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 47 | + if ( ! is_admin() ) { |
|
| 48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | + |
|
| 54 | + // Entries controller |
|
| 55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | + |
|
| 61 | + // Form Actions Controller |
|
| 62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 64 | 64 | |
| 65 | - // Forms Controller |
|
| 66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 65 | + // Forms Controller |
|
| 66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 72 | 72 | |
| 73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 74 | 74 | |
| 75 | - // Form Shortcodes |
|
| 76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 75 | + // Form Shortcodes |
|
| 76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 77 | 77 | |
| 78 | - // Styles Controller |
|
| 79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | - } |
|
| 78 | + // Styles Controller |
|
| 79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | public static function load_admin_hooks() { |
| 86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); |
| 91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
@@ -94,122 +94,122 @@ discard block |
||
| 94 | 94 | // Addons Controller |
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 96 | 96 | |
| 97 | - // Entries Controller |
|
| 98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 97 | + // Entries Controller |
|
| 98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 103 | 103 | |
| 104 | - // Fields Controller |
|
| 105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 104 | + // Fields Controller |
|
| 105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 106 | 106 | |
| 107 | - // Form Actions Controller |
|
| 108 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | - } |
|
| 111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 107 | + // Form Actions Controller |
|
| 108 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | + } |
|
| 111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 112 | 112 | |
| 113 | - // Forms Controller |
|
| 114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 113 | + // Forms Controller |
|
| 114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 116 | 116 | |
| 117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 120 | 120 | |
| 121 | - // Forms Model |
|
| 122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 121 | + // Forms Model |
|
| 122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 123 | 123 | |
| 124 | - // Settings Controller |
|
| 125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 124 | + // Settings Controller |
|
| 125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 127 | 127 | |
| 128 | - // Styles Controller |
|
| 129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 128 | + // Styles Controller |
|
| 129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 131 | 131 | |
| 132 | - // XML Controller |
|
| 133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | - } |
|
| 132 | + // XML Controller |
|
| 133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | public static function load_ajax_hooks() { |
| 137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 142 | 142 | |
| 143 | 143 | // Addons |
| 144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 146 | 146 | add_action( 'wp_ajax_frm_fill_licenses', 'FrmAddonsController::get_licenses' ); |
| 147 | 147 | |
| 148 | - // Fields Controller |
|
| 149 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 150 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | - |
|
| 162 | - // Form Actions Controller |
|
| 163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | - |
|
| 166 | - // Forms Controller |
|
| 148 | + // Fields Controller |
|
| 149 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 150 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | + |
|
| 162 | + // Form Actions Controller |
|
| 163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | + |
|
| 166 | + // Forms Controller |
|
| 167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
| 170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
| 171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | - |
|
| 176 | - // Styles Controller |
|
| 177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | + |
|
| 176 | + // Styles Controller |
|
| 177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 183 | 183 | |
| 184 | - // XML Controller |
|
| 184 | + // XML Controller |
|
| 185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | - } |
|
| 187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | public static function load_form_hooks() { |
| 191 | - // Fields Controller |
|
| 192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 191 | + // Fields Controller |
|
| 192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 196 | 196 | |
| 197 | 197 | // Forms Controller |
| 198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 199 | 199 | |
| 200 | - // Styles Controller |
|
| 201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | - } |
|
| 200 | + // Styles Controller |
|
| 201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function load_view_hooks() { |
| 205 | - // Hooks go here when a view is loaded |
|
| 206 | - } |
|
| 205 | + // Hooks go here when a view is loaded |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function load_multisite_hooks() { |
| 209 | 209 | add_action( 'init', 'FrmAppController::front_head' ); |
| 210 | 210 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 211 | 211 | |
| 212 | - // drop tables when mu site is deleted |
|
| 213 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 214 | - } |
|
| 212 | + // drop tables when mu site is deleted |
|
| 213 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 214 | + } |
|
| 215 | 215 | } |
@@ -2,59 +2,59 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 5 | + public static function load_field() { |
|
| 6 | 6 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 7 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 8 | 8 | |
| 9 | - $fields = $_POST['field']; |
|
| 10 | - if ( empty( $fields ) ) { |
|
| 11 | - wp_die(); |
|
| 12 | - } |
|
| 9 | + $fields = $_POST['field']; |
|
| 10 | + if ( empty( $fields ) ) { |
|
| 11 | + wp_die(); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - $_GET['page'] = 'formidable'; |
|
| 15 | - $fields = stripslashes_deep( $fields ); |
|
| 14 | + $_GET['page'] = 'formidable'; |
|
| 15 | + $fields = stripslashes_deep( $fields ); |
|
| 16 | 16 | |
| 17 | - $ajax = true; |
|
| 17 | + $ajax = true; |
|
| 18 | 18 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 19 | - $path = FrmAppHelper::plugin_path(); |
|
| 20 | - $field_html = array(); |
|
| 21 | - |
|
| 22 | - foreach ( $fields as $field ) { |
|
| 23 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | - $field = json_decode( $field, true ); |
|
| 25 | - if ( ! isset( $field['id'] ) ) { |
|
| 26 | - // this field may have already been loaded |
|
| 27 | - continue; |
|
| 28 | - } |
|
| 19 | + $path = FrmAppHelper::plugin_path(); |
|
| 20 | + $field_html = array(); |
|
| 21 | + |
|
| 22 | + foreach ( $fields as $field ) { |
|
| 23 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 24 | + $field = json_decode( $field, true ); |
|
| 25 | + if ( ! isset( $field['id'] ) ) { |
|
| 26 | + // this field may have already been loaded |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $field_id = absint( $field['id'] ); |
|
| 30 | + $field_id = absint( $field['id'] ); |
|
| 31 | 31 | |
| 32 | - if ( ! isset( $field['value'] ) ) { |
|
| 33 | - $field['value'] = ''; |
|
| 34 | - } |
|
| 32 | + if ( ! isset( $field['value'] ) ) { |
|
| 33 | + $field['value'] = ''; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | $field_name = 'item_meta[' . $field_id . ']'; |
| 37 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 38 | 38 | |
| 39 | - ob_start(); |
|
| 39 | + ob_start(); |
|
| 40 | 40 | include( $path . '/classes/views/frm-forms/add_field.php' ); |
| 41 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | - ob_end_clean(); |
|
| 43 | - } |
|
| 41 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 42 | + ob_end_clean(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - unset($path); |
|
| 45 | + unset($path); |
|
| 46 | 46 | |
| 47 | - echo json_encode($field_html); |
|
| 47 | + echo json_encode($field_html); |
|
| 48 | 48 | |
| 49 | - wp_die(); |
|
| 50 | - } |
|
| 49 | + wp_die(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Create a new field with ajax |
| 54 | 54 | */ |
| 55 | - public static function create() { |
|
| 55 | + public static function create() { |
|
| 56 | 56 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 57 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 57 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 58 | 58 | |
| 59 | 59 | $field_type = FrmAppHelper::get_post_param( 'field_type', '', 'sanitize_text_field' ); |
| 60 | 60 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
@@ -62,72 +62,72 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $field = self::include_new_field( $field_type, $form_id, $section_id ); |
| 64 | 64 | |
| 65 | - // this hook will allow for multiple fields to be added at once |
|
| 66 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 65 | + // this hook will allow for multiple fields to be added at once |
|
| 66 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 67 | 67 | |
| 68 | - wp_die(); |
|
| 69 | - } |
|
| 68 | + wp_die(); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Set up and create a new field |
|
| 73 | - * |
|
| 74 | - * @param string $field_type |
|
| 75 | - * @param integer $form_id |
|
| 76 | - * @param int $section_id |
|
| 77 | - * @return array |
|
| 78 | - */ |
|
| 71 | + /** |
|
| 72 | + * Set up and create a new field |
|
| 73 | + * |
|
| 74 | + * @param string $field_type |
|
| 75 | + * @param integer $form_id |
|
| 76 | + * @param int $section_id |
|
| 77 | + * @return array |
|
| 78 | + */ |
|
| 79 | 79 | public static function include_new_field( $field_type, $form_id, $section_id = 0 ) { |
| 80 | - $values = array(); |
|
| 81 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 82 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 83 | - } |
|
| 80 | + $values = array(); |
|
| 81 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 82 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | $field_values = FrmFieldsHelper::setup_new_vars( $field_type, $form_id ); |
| 86 | 86 | $field_values['field_options']['in_section'] = $section_id; |
| 87 | - $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 87 | + $field_values = apply_filters( 'frm_before_field_created', $field_values ); |
|
| 88 | 88 | |
| 89 | - $field_id = FrmField::create( $field_values ); |
|
| 89 | + $field_id = FrmField::create( $field_values ); |
|
| 90 | 90 | |
| 91 | - if ( ! $field_id ) { |
|
| 92 | - return false; |
|
| 93 | - } |
|
| 91 | + if ( ! $field_id ) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 95 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 96 | 96 | |
| 97 | - return $field; |
|
| 98 | - } |
|
| 97 | + return $field; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | public static function edit_name( $field = 'name', $id = '' ) { |
| 101 | 101 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 102 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 102 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 103 | 103 | |
| 104 | - if ( empty($field) ) { |
|
| 105 | - $field = 'name'; |
|
| 106 | - } |
|
| 104 | + if ( empty($field) ) { |
|
| 105 | + $field = 'name'; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - if ( empty($id) ) { |
|
| 108 | + if ( empty($id) ) { |
|
| 109 | 109 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 110 | 110 | $id = str_replace( 'field_label_', '', $id ); |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | 113 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 114 | 114 | $value = trim( $value ); |
| 115 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 116 | - // set blank value if there is no content |
|
| 117 | - $value = ''; |
|
| 118 | - } |
|
| 115 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 116 | + // set blank value if there is no content |
|
| 117 | + $value = ''; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | 120 | FrmField::update( $id, array( $field => $value ) ); |
| 121 | 121 | |
| 122 | 122 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 123 | 123 | |
| 124 | 124 | echo stripslashes( wp_kses_post( $value ) ); |
| 125 | - wp_die(); |
|
| 126 | - } |
|
| 125 | + wp_die(); |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - public static function update_ajax_option() { |
|
| 128 | + public static function update_ajax_option() { |
|
| 129 | 129 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 130 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 130 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 131 | 131 | |
| 132 | 132 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 133 | 133 | if ( ! $field_id ) { |
@@ -142,141 +142,141 @@ discard block |
||
| 142 | 142 | unset($new_val); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - FrmField::update( $field_id, array( |
|
| 146 | - 'field_options' => $field->field_options, |
|
| 145 | + FrmField::update( $field_id, array( |
|
| 146 | + 'field_options' => $field->field_options, |
|
| 147 | 147 | 'form_id' => $field->form_id, |
| 148 | - ) ); |
|
| 149 | - wp_die(); |
|
| 150 | - } |
|
| 148 | + ) ); |
|
| 149 | + wp_die(); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - public static function duplicate() { |
|
| 152 | + public static function duplicate() { |
|
| 153 | 153 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 154 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 154 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 155 | 155 | |
| 156 | - global $wpdb; |
|
| 156 | + global $wpdb; |
|
| 157 | 157 | |
| 158 | 158 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 159 | 159 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 160 | 160 | |
| 161 | 161 | $copy_field = FrmField::getOne( $field_id ); |
| 162 | - if ( ! $copy_field ) { |
|
| 163 | - wp_die(); |
|
| 164 | - } |
|
| 162 | + if ( ! $copy_field ) { |
|
| 163 | + wp_die(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | do_action( 'frm_duplicate_field', $copy_field, $form_id ); |
| 167 | 167 | do_action( 'frm_duplicate_field_' . $copy_field->type, $copy_field, $form_id ); |
| 168 | 168 | |
| 169 | - $values = array( 'id' => $form_id ); |
|
| 170 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 169 | + $values = array( 'id' => $form_id ); |
|
| 170 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 171 | 171 | |
| 172 | 172 | $field_count = FrmDb::get_count( $wpdb->prefix . 'frm_fields fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 173 | 173 | |
| 174 | - $values['field_order'] = $field_count + 1; |
|
| 174 | + $values['field_order'] = $field_count + 1; |
|
| 175 | 175 | |
| 176 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 177 | - wp_die(); |
|
| 178 | - } |
|
| 176 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 177 | + wp_die(); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - self::include_single_field($field_id, $values); |
|
| 180 | + self::include_single_field($field_id, $values); |
|
| 181 | 181 | |
| 182 | - wp_die(); |
|
| 183 | - } |
|
| 182 | + wp_die(); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Load a single field in the form builder along with all needed variables |
|
| 187 | - */ |
|
| 188 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 185 | + /** |
|
| 186 | + * Load a single field in the form builder along with all needed variables |
|
| 187 | + */ |
|
| 188 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 189 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 190 | 190 | $field_name = 'item_meta[' . $field_id . ']'; |
| 191 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | - if ( $field['type'] == 'html' ) { |
|
| 194 | - $field['stop_filter'] = true; |
|
| 195 | - } |
|
| 191 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 192 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 193 | + if ( $field['type'] == 'html' ) { |
|
| 194 | + $field['stop_filter'] = true; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php' ); |
| 198 | 198 | |
| 199 | - return $field; |
|
| 200 | - } |
|
| 199 | + return $field; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - public static function destroy() { |
|
| 202 | + public static function destroy() { |
|
| 203 | 203 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 204 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 204 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 205 | 205 | |
| 206 | 206 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 207 | 207 | FrmField::destroy( $field_id ); |
| 208 | - wp_die(); |
|
| 209 | - } |
|
| 208 | + wp_die(); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /* Field Options */ |
|
| 211 | + /* Field Options */ |
|
| 212 | 212 | |
| 213 | - //Add Single Option or Other Option |
|
| 214 | - public static function add_option() { |
|
| 213 | + //Add Single Option or Other Option |
|
| 214 | + public static function add_option() { |
|
| 215 | 215 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 216 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 216 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 217 | 217 | |
| 218 | 218 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 219 | 219 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 220 | 220 | |
| 221 | - //Get the field |
|
| 222 | - $field = FrmField::getOne($id); |
|
| 221 | + //Get the field |
|
| 222 | + $field = FrmField::getOne($id); |
|
| 223 | 223 | |
| 224 | 224 | if ( ! empty( $field->options ) ) { |
| 225 | 225 | $keys = array_keys( $field->options ); |
| 226 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 227 | - } else { |
|
| 228 | - $last = 0; |
|
| 229 | - } |
|
| 230 | - $opt_key = $last + 1; |
|
| 226 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 227 | + } else { |
|
| 228 | + $last = 0; |
|
| 229 | + } |
|
| 230 | + $opt_key = $last + 1; |
|
| 231 | 231 | |
| 232 | - if ( 'other' == $opt_type ) { |
|
| 232 | + if ( 'other' == $opt_type ) { |
|
| 233 | 233 | $opt = esc_html__( 'Other', 'formidable' ); |
| 234 | - $other_val = ''; |
|
| 235 | - $opt_key = 'other_' . $opt_key; |
|
| 236 | - |
|
| 237 | - //Update value of "other" in DB |
|
| 238 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 239 | - $field_options['other'] = 1; |
|
| 240 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 241 | - } else { |
|
| 234 | + $other_val = ''; |
|
| 235 | + $opt_key = 'other_' . $opt_key; |
|
| 236 | + |
|
| 237 | + //Update value of "other" in DB |
|
| 238 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 239 | + $field_options['other'] = 1; |
|
| 240 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 241 | + } else { |
|
| 242 | 242 | $first_opt = reset( $field->options ); |
| 243 | 243 | $next_opt = count( $field->options ); |
| 244 | - if ( $first_opt != '' ) { |
|
| 245 | - $next_opt++; |
|
| 246 | - } |
|
| 244 | + if ( $first_opt != '' ) { |
|
| 245 | + $next_opt++; |
|
| 246 | + } |
|
| 247 | 247 | $opt = esc_html__( 'Option', 'formidable' ) . ' ' . $next_opt; |
| 248 | - unset($next_opt); |
|
| 249 | - } |
|
| 250 | - $field_val = $opt; |
|
| 248 | + unset($next_opt); |
|
| 249 | + } |
|
| 250 | + $field_val = $opt; |
|
| 251 | 251 | $field->options[ $opt_key ] = $opt; |
| 252 | 252 | |
| 253 | - //Update options in DB |
|
| 253 | + //Update options in DB |
|
| 254 | 254 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 255 | 255 | |
| 256 | - $field_data = $field; |
|
| 257 | - $field = array( |
|
| 258 | - 'type' => $field_data->type, |
|
| 259 | - 'id' => $id, |
|
| 260 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 261 | - 'form_id' => $field_data->form_id, |
|
| 262 | - 'field_key' => $field_data->field_key, |
|
| 263 | - ); |
|
| 256 | + $field_data = $field; |
|
| 257 | + $field = array( |
|
| 258 | + 'type' => $field_data->type, |
|
| 259 | + 'id' => $id, |
|
| 260 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 261 | + 'form_id' => $field_data->form_id, |
|
| 262 | + 'field_key' => $field_data->field_key, |
|
| 263 | + ); |
|
| 264 | 264 | |
| 265 | 265 | $field_name = 'item_meta[' . $id . ']'; |
| 266 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 267 | - $checked = ''; |
|
| 266 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 267 | + $checked = ''; |
|
| 268 | 268 | |
| 269 | - if ( 'other' == $opt_type ) { |
|
| 269 | + if ( 'other' == $opt_type ) { |
|
| 270 | 270 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 271 | - } else { |
|
| 271 | + } else { |
|
| 272 | 272 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 273 | - } |
|
| 274 | - wp_die(); |
|
| 275 | - } |
|
| 273 | + } |
|
| 274 | + wp_die(); |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - public static function edit_option() { |
|
| 277 | + public static function edit_option() { |
|
| 278 | 278 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 279 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 279 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 280 | 280 | |
| 281 | 281 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 282 | 282 | $ids = explode( '-', $element_id ); |
@@ -284,43 +284,43 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ) ); |
| 286 | 286 | if ( strpos( $element_id, 'key_' ) ) { |
| 287 | - $new_value = $update_value; |
|
| 288 | - } else { |
|
| 289 | - $new_label = $update_value; |
|
| 290 | - } |
|
| 287 | + $new_value = $update_value; |
|
| 288 | + } else { |
|
| 289 | + $new_label = $update_value; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - $field = FrmField::getOne($id); |
|
| 293 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 292 | + $field = FrmField::getOne($id); |
|
| 293 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 294 | 294 | |
| 295 | - $this_opt_id = end($ids); |
|
| 295 | + $this_opt_id = end($ids); |
|
| 296 | 296 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 297 | 297 | $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ); |
| 298 | 298 | |
| 299 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 300 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 299 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 300 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 301 | 301 | |
| 302 | - if ( ! isset( $new_label ) ) { |
|
| 303 | - $new_label = $label; |
|
| 304 | - } |
|
| 302 | + if ( ! isset( $new_label ) ) { |
|
| 303 | + $new_label = $label; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - if ( isset($new_value) || isset($value) ) { |
|
| 307 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 308 | - } |
|
| 306 | + if ( isset($new_value) || isset($value) ) { |
|
| 307 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | 310 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 311 | 311 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 312 | - } else { |
|
| 312 | + } else { |
|
| 313 | 313 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | 316 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 317 | 317 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 318 | - wp_die(); |
|
| 319 | - } |
|
| 318 | + wp_die(); |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | - public static function delete_option() { |
|
| 321 | + public static function delete_option() { |
|
| 322 | 322 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 323 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 323 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 324 | 324 | |
| 325 | 325 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 326 | 326 | $field = FrmField::getOne( $field_id ); |
@@ -328,310 +328,310 @@ discard block |
||
| 328 | 328 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 329 | 329 | |
| 330 | 330 | $options = $field->options; |
| 331 | - unset( $options[ $opt_key ] ); |
|
| 332 | - $response = array( 'other' => true ); |
|
| 331 | + unset( $options[ $opt_key ] ); |
|
| 332 | + $response = array( 'other' => true ); |
|
| 333 | 333 | |
| 334 | - //If the deleted option is an "other" option |
|
| 334 | + //If the deleted option is an "other" option |
|
| 335 | 335 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 336 | - //Assume all other options are gone, unless proven otherwise |
|
| 337 | - $other = false; |
|
| 336 | + //Assume all other options are gone, unless proven otherwise |
|
| 337 | + $other = false; |
|
| 338 | 338 | |
| 339 | - //Check if all other options are really gone |
|
| 340 | - foreach ( $options as $o_key => $o_val ) { |
|
| 341 | - //If there is still an other option in the field, set other to true |
|
| 339 | + //Check if all other options are really gone |
|
| 340 | + foreach ( $options as $o_key => $o_val ) { |
|
| 341 | + //If there is still an other option in the field, set other to true |
|
| 342 | 342 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 343 | - $other = true; |
|
| 344 | - break; |
|
| 345 | - } |
|
| 346 | - unset( $o_key, $o_val ); |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - //If all other options are gone |
|
| 350 | - if ( false === $other ) { |
|
| 351 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 352 | - $field_options['other'] = 0; |
|
| 343 | + $other = true; |
|
| 344 | + break; |
|
| 345 | + } |
|
| 346 | + unset( $o_key, $o_val ); |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + //If all other options are gone |
|
| 350 | + if ( false === $other ) { |
|
| 351 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 352 | + $field_options['other'] = 0; |
|
| 353 | 353 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 354 | - $response = array( 'other' => false ); |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - echo json_encode( $response ); |
|
| 354 | + $response = array( 'other' => false ); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + echo json_encode( $response ); |
|
| 358 | 358 | |
| 359 | 359 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 360 | 360 | |
| 361 | - wp_die(); |
|
| 362 | - } |
|
| 361 | + wp_die(); |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - public static function import_choices() { |
|
| 365 | - FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 364 | + public static function import_choices() { |
|
| 365 | + FrmAppHelper::permission_check( 'frm_edit_forms', 'hide' ); |
|
| 366 | 366 | |
| 367 | 367 | $field_id = absint( $_REQUEST['field_id'] ); |
| 368 | 368 | |
| 369 | - global $current_screen, $hook_suffix; |
|
| 369 | + global $current_screen, $hook_suffix; |
|
| 370 | 370 | |
| 371 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 372 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 373 | - $hook_suffix = ''; |
|
| 374 | - set_current_screen(); |
|
| 375 | - } |
|
| 371 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 372 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 373 | + $hook_suffix = ''; |
|
| 374 | + set_current_screen(); |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 378 | - register_admin_color_schemes(); |
|
| 379 | - } |
|
| 377 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 378 | + register_admin_color_schemes(); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - $hook_suffix = $admin_body_class = ''; |
|
| 381 | + $hook_suffix = $admin_body_class = ''; |
|
| 382 | 382 | |
| 383 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 384 | - $admin_body_class .= ' folded'; |
|
| 385 | - } |
|
| 383 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 384 | + $admin_body_class .= ' folded'; |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 388 | - $admin_body_class .= ' admin-bar'; |
|
| 389 | - } |
|
| 387 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 388 | + $admin_body_class .= ' admin-bar'; |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - if ( is_rtl() ) { |
|
| 392 | - $admin_body_class .= ' rtl'; |
|
| 393 | - } |
|
| 391 | + if ( is_rtl() ) { |
|
| 392 | + $admin_body_class .= ' rtl'; |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 396 | - $prepop = array(); |
|
| 397 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 395 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 396 | + $prepop = array(); |
|
| 397 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 398 | 398 | |
| 399 | - $field = FrmField::getOne($field_id); |
|
| 399 | + $field = FrmField::getOne($field_id); |
|
| 400 | 400 | |
| 401 | - wp_enqueue_script( 'utils' ); |
|
| 401 | + wp_enqueue_script( 'utils' ); |
|
| 402 | 402 | wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css' ); |
| 403 | - FrmAppHelper::load_admin_wide_js(); |
|
| 403 | + FrmAppHelper::load_admin_wide_js(); |
|
| 404 | 404 | |
| 405 | 405 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/import_choices.php' ); |
| 406 | - wp_die(); |
|
| 407 | - } |
|
| 406 | + wp_die(); |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - public static function import_options() { |
|
| 409 | + public static function import_options() { |
|
| 410 | 410 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 411 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 412 | 412 | |
| 413 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 414 | - return; |
|
| 415 | - } |
|
| 413 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 414 | + return; |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | 417 | $field_id = absint( $_POST['field_id'] ); |
| 418 | - $field = FrmField::getOne($field_id); |
|
| 418 | + $field = FrmField::getOne($field_id); |
|
| 419 | 419 | |
| 420 | 420 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 421 | - return; |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 425 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 426 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 427 | - if ( $field['separate_value'] ) { |
|
| 428 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 429 | - if ( strpos($opt, '|') !== false ) { |
|
| 430 | - $vals = explode('|', $opt); |
|
| 431 | - if ( $vals[0] != $vals[1] ) { |
|
| 432 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 433 | - } |
|
| 434 | - unset($vals); |
|
| 435 | - } |
|
| 436 | - unset($opt_key, $opt); |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - //Keep other options after bulk update |
|
| 441 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 442 | - $other_array = array(); |
|
| 443 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 444 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 445 | - $other_array[ $opt_key ] = $opt; |
|
| 446 | - } |
|
| 447 | - unset($opt_key, $opt); |
|
| 448 | - } |
|
| 449 | - if ( ! empty($other_array) ) { |
|
| 450 | - $opts = array_merge( $opts, $other_array); |
|
| 451 | - } |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 455 | - |
|
| 456 | - $field['options'] = $opts; |
|
| 457 | - $field_name = $field['name']; |
|
| 458 | - |
|
| 459 | - // Get html_id which will be used in single-option.php |
|
| 460 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 461 | - |
|
| 462 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 421 | + return; |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 425 | + $opts = stripslashes_deep($_POST['opts']); |
|
| 426 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
| 427 | + if ( $field['separate_value'] ) { |
|
| 428 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 429 | + if ( strpos($opt, '|') !== false ) { |
|
| 430 | + $vals = explode('|', $opt); |
|
| 431 | + if ( $vals[0] != $vals[1] ) { |
|
| 432 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 433 | + } |
|
| 434 | + unset($vals); |
|
| 435 | + } |
|
| 436 | + unset($opt_key, $opt); |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + //Keep other options after bulk update |
|
| 441 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 442 | + $other_array = array(); |
|
| 443 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 444 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 445 | + $other_array[ $opt_key ] = $opt; |
|
| 446 | + } |
|
| 447 | + unset($opt_key, $opt); |
|
| 448 | + } |
|
| 449 | + if ( ! empty($other_array) ) { |
|
| 450 | + $opts = array_merge( $opts, $other_array); |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 455 | + |
|
| 456 | + $field['options'] = $opts; |
|
| 457 | + $field_name = $field['name']; |
|
| 458 | + |
|
| 459 | + // Get html_id which will be used in single-option.php |
|
| 460 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 461 | + |
|
| 462 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 463 | 463 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php' ); |
| 464 | - } else { |
|
| 465 | - FrmFieldsHelper::show_single_option($field); |
|
| 466 | - } |
|
| 464 | + } else { |
|
| 465 | + FrmFieldsHelper::show_single_option($field); |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - wp_die(); |
|
| 469 | - } |
|
| 468 | + wp_die(); |
|
| 469 | + } |
|
| 470 | 470 | |
| 471 | - public static function update_order() { |
|
| 471 | + public static function update_order() { |
|
| 472 | 472 | FrmAppHelper::permission_check('frm_edit_forms'); |
| 473 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 473 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 474 | 474 | |
| 475 | 475 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 476 | 476 | foreach ( (array) $fields as $position => $item ) { |
| 477 | 477 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 478 | 478 | } |
| 479 | - wp_die(); |
|
| 480 | - } |
|
| 479 | + wp_die(); |
|
| 480 | + } |
|
| 481 | 481 | |
| 482 | 482 | public static function change_type( $type ) { |
| 483 | - $type_switch = array( |
|
| 484 | - 'scale' => 'radio', |
|
| 485 | - '10radio' => 'radio', |
|
| 486 | - 'rte' => 'textarea', |
|
| 487 | - 'website' => 'url', |
|
| 488 | - ); |
|
| 489 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 490 | - $type = $type_switch[ $type ]; |
|
| 491 | - } |
|
| 483 | + $type_switch = array( |
|
| 484 | + 'scale' => 'radio', |
|
| 485 | + '10radio' => 'radio', |
|
| 486 | + 'rte' => 'textarea', |
|
| 487 | + 'website' => 'url', |
|
| 488 | + ); |
|
| 489 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 490 | + $type = $type_switch[ $type ]; |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | 493 | $frm_field_selection = FrmField::field_selection(); |
| 494 | - $types = array_keys($frm_field_selection); |
|
| 495 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 496 | - $type = 'text'; |
|
| 497 | - } |
|
| 494 | + $types = array_keys($frm_field_selection); |
|
| 495 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 496 | + $type = 'text'; |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - return $type; |
|
| 500 | - } |
|
| 499 | + return $type; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | public static function display_field_options( $display ) { |
| 503 | 503 | switch ( $display['type'] ) { |
| 504 | - case 'captcha': |
|
| 505 | - $display['required'] = false; |
|
| 506 | - $display['invalid'] = true; |
|
| 507 | - $display['default_blank'] = false; |
|
| 504 | + case 'captcha': |
|
| 505 | + $display['required'] = false; |
|
| 506 | + $display['invalid'] = true; |
|
| 507 | + $display['default_blank'] = false; |
|
| 508 | 508 | $display['captcha_size'] = true; |
| 509 | - break; |
|
| 510 | - case 'radio': |
|
| 511 | - $display['default_blank'] = false; |
|
| 512 | - break; |
|
| 513 | - case 'text': |
|
| 514 | - case 'textarea': |
|
| 515 | - $display['size'] = true; |
|
| 516 | - $display['clear_on_focus'] = true; |
|
| 517 | - break; |
|
| 518 | - case 'select': |
|
| 519 | - $display['size'] = true; |
|
| 520 | - break; |
|
| 521 | - case 'url': |
|
| 522 | - case 'website': |
|
| 523 | - case 'email': |
|
| 524 | - $display['size'] = true; |
|
| 525 | - $display['clear_on_focus'] = true; |
|
| 526 | - $display['invalid'] = true; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return $display; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - public static function input_html( $field, $echo = true ) { |
|
| 533 | - $class = array(); //$field['type']; |
|
| 534 | - self::add_input_classes($field, $class); |
|
| 535 | - |
|
| 536 | - $add_html = array(); |
|
| 537 | - self::add_html_size($field, $add_html); |
|
| 538 | - self::add_html_length($field, $add_html); |
|
| 539 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 509 | + break; |
|
| 510 | + case 'radio': |
|
| 511 | + $display['default_blank'] = false; |
|
| 512 | + break; |
|
| 513 | + case 'text': |
|
| 514 | + case 'textarea': |
|
| 515 | + $display['size'] = true; |
|
| 516 | + $display['clear_on_focus'] = true; |
|
| 517 | + break; |
|
| 518 | + case 'select': |
|
| 519 | + $display['size'] = true; |
|
| 520 | + break; |
|
| 521 | + case 'url': |
|
| 522 | + case 'website': |
|
| 523 | + case 'email': |
|
| 524 | + $display['size'] = true; |
|
| 525 | + $display['clear_on_focus'] = true; |
|
| 526 | + $display['invalid'] = true; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return $display; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + public static function input_html( $field, $echo = true ) { |
|
| 533 | + $class = array(); //$field['type']; |
|
| 534 | + self::add_input_classes($field, $class); |
|
| 535 | + |
|
| 536 | + $add_html = array(); |
|
| 537 | + self::add_html_size($field, $add_html); |
|
| 538 | + self::add_html_length($field, $add_html); |
|
| 539 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 540 | 540 | self::add_validation_messages( $field, $add_html ); |
| 541 | 541 | |
| 542 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 542 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 543 | 543 | |
| 544 | 544 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 545 | 545 | |
| 546 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 546 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 547 | 547 | |
| 548 | 548 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 549 | 549 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 550 | 550 | |
| 551 | - if ( $echo ) { |
|
| 552 | - echo $add_html; |
|
| 553 | - } |
|
| 551 | + if ( $echo ) { |
|
| 552 | + echo $add_html; |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | - return $add_html; |
|
| 556 | - } |
|
| 555 | + return $add_html; |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | 558 | private static function add_input_classes( $field, array &$class ) { |
| 559 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 560 | - $class[] = $field['input_class']; |
|
| 561 | - } |
|
| 559 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 560 | + $class[] = $field['input_class']; |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 564 | - return; |
|
| 565 | - } |
|
| 563 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 564 | + return; |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - global $frm_vars; |
|
| 567 | + global $frm_vars; |
|
| 568 | 568 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
| 569 | - $class[] = 'dyn_default_value'; |
|
| 570 | - } |
|
| 569 | + $class[] = 'dyn_default_value'; |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 573 | - $class[] = 'auto_width'; |
|
| 574 | - } |
|
| 575 | - } |
|
| 572 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 573 | + $class[] = 'auto_width'; |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | 577 | private static function add_html_size( $field, array &$add_html ) { |
| 578 | 578 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
| 579 | - return; |
|
| 580 | - } |
|
| 579 | + return; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 583 | - return; |
|
| 584 | - } |
|
| 582 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 583 | + return; |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | - if ( is_numeric($field['size']) ) { |
|
| 587 | - $field['size'] .= 'px'; |
|
| 588 | - } |
|
| 586 | + if ( is_numeric($field['size']) ) { |
|
| 587 | + $field['size'] .= 'px'; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 591 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 590 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 591 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 592 | 592 | $add_html['style'] = 'style="width:' . esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) . '"'; |
| 593 | 593 | |
| 594 | - self::add_html_cols($field, $add_html); |
|
| 595 | - } |
|
| 594 | + self::add_html_cols($field, $add_html); |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | private static function add_html_cols( $field, array &$add_html ) { |
| 598 | 598 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 599 | - return; |
|
| 600 | - } |
|
| 599 | + return; |
|
| 600 | + } |
|
| 601 | 601 | |
| 602 | - // convert to cols for textareas |
|
| 603 | - $calc = array( |
|
| 604 | - '' => 9, |
|
| 605 | - 'px' => 9, |
|
| 606 | - 'rem' => 0.444, |
|
| 607 | - 'em' => 0.544, |
|
| 608 | - ); |
|
| 602 | + // convert to cols for textareas |
|
| 603 | + $calc = array( |
|
| 604 | + '' => 9, |
|
| 605 | + 'px' => 9, |
|
| 606 | + 'rem' => 0.444, |
|
| 607 | + 'em' => 0.544, |
|
| 608 | + ); |
|
| 609 | 609 | |
| 610 | - // include "col" for valid html |
|
| 611 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 610 | + // include "col" for valid html |
|
| 611 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 612 | 612 | |
| 613 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 614 | - return; |
|
| 615 | - } |
|
| 613 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 614 | + return; |
|
| 615 | + } |
|
| 616 | 616 | |
| 617 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 617 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 618 | 618 | |
| 619 | 619 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 620 | - } |
|
| 620 | + } |
|
| 621 | 621 | |
| 622 | 622 | private static function add_html_length( $field, array &$add_html ) { |
| 623 | - // check for max setting and if this field accepts maxlength |
|
| 623 | + // check for max setting and if this field accepts maxlength |
|
| 624 | 624 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 625 | - return; |
|
| 626 | - } |
|
| 625 | + return; |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 629 | - // don't load on form builder page |
|
| 630 | - return; |
|
| 631 | - } |
|
| 628 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 629 | + // don't load on form builder page |
|
| 630 | + return; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 634 | - } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 637 | 637 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
@@ -639,35 +639,35 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | $default_value_array = is_array( $field['default_value'] ); |
| 642 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 642 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 643 | 643 | if ( $default_value_array ) { |
| 644 | 644 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 645 | 645 | } |
| 646 | 646 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 647 | - return; |
|
| 648 | - } |
|
| 647 | + return; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | if ( $default_value_array ) { |
| 651 | 651 | // don't include a json placeholder |
| 652 | 652 | return; |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 655 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 656 | 656 | |
| 657 | 657 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 658 | - // use HMTL5 placeholder with js fallback |
|
| 658 | + // use HMTL5 placeholder with js fallback |
|
| 659 | 659 | $add_html['placeholder'] = 'placeholder="' . esc_attr( $field['default_value'] ) . '"'; |
| 660 | - wp_enqueue_script('jquery-placeholder'); |
|
| 661 | - } else if ( ! $frm_settings->use_html ) { |
|
| 660 | + wp_enqueue_script('jquery-placeholder'); |
|
| 661 | + } else if ( ! $frm_settings->use_html ) { |
|
| 662 | 662 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 663 | 663 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $val ) . '"'; |
| 664 | - $class[] = 'frm_toggle_default'; |
|
| 664 | + $class[] = 'frm_toggle_default'; |
|
| 665 | 665 | |
| 666 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 667 | - $class[] = 'frm_default'; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - } |
|
| 666 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 667 | + $class[] = 'frm_default'; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | 671 | |
| 672 | 672 | private static function add_validation_messages( $field, array &$add_html ) { |
| 673 | 673 | if ( FrmField::is_required( $field ) ) { |
@@ -688,44 +688,44 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 692 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 693 | - return; |
|
| 694 | - } |
|
| 691 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 692 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 693 | + return; |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 697 | - if ( 'opt' === $k ) { |
|
| 698 | - continue; |
|
| 699 | - } |
|
| 696 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 697 | + if ( 'opt' === $k ) { |
|
| 698 | + continue; |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 702 | - $add_html[] = $v; |
|
| 703 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 702 | + $add_html[] = $v; |
|
| 703 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 704 | 704 | $add_html[ $k ] = str_replace( $k . '="', $k . '="' . $v, $add_html[ $k ] ); |
| 705 | - } else { |
|
| 705 | + } else { |
|
| 706 | 706 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 707 | - } |
|
| 708 | - |
|
| 709 | - unset($k, $v); |
|
| 710 | - } |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 714 | - if ( is_array( $opt ) ) { |
|
| 715 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 716 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 717 | - } else { |
|
| 718 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 719 | - } |
|
| 720 | - } |
|
| 721 | - return $opt; |
|
| 722 | - } |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + unset($k, $v); |
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 714 | + if ( is_array( $opt ) ) { |
|
| 715 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 716 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 717 | + } else { |
|
| 718 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 719 | + } |
|
| 720 | + } |
|
| 721 | + return $opt; |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | 724 | public static function check_label( $opt ) { |
| 725 | - if ( is_array($opt) ) { |
|
| 726 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 727 | - } |
|
| 725 | + if ( is_array($opt) ) { |
|
| 726 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | - return $opt; |
|
| 730 | - } |
|
| 729 | + return $opt; |
|
| 730 | + } |
|
| 731 | 731 | } |