@@ -75,7 +75,7 @@ |
||
| 75 | 75 | /** |
| 76 | 76 | * FrmFieldValueSelector constructor |
| 77 | 77 | * |
| 78 | - * @param int|string $field_id |
|
| 78 | + * @param integer $field_id |
|
| 79 | 79 | */ |
| 80 | 80 | public function __construct( $field_id, $args ) { |
| 81 | 81 | $this->set_html_name( $args ); |
@@ -1,262 +1,262 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('ABSPATH') ) { |
| 3 | - die('You are not allowed to call this page directly.'); |
|
| 3 | + die('You are not allowed to call this page directly.'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmForm { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return int|boolean id on success or false on failure |
|
| 10 | - */ |
|
| 11 | - public static function create( $values ) { |
|
| 12 | - global $wpdb; |
|
| 8 | + /** |
|
| 9 | + * @return int|boolean id on success or false on failure |
|
| 10 | + */ |
|
| 11 | + public static function create( $values ) { |
|
| 12 | + global $wpdb; |
|
| 13 | 13 | |
| 14 | - $new_values = array( |
|
| 14 | + $new_values = array( |
|
| 15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 16 | - 'name' => $values['name'], |
|
| 17 | - 'description' => $values['description'], |
|
| 18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 16 | + 'name' => $values['name'], |
|
| 17 | + 'description' => $values['description'], |
|
| 18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | - ); |
|
| 22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 25 | + ); |
|
| 26 | 26 | |
| 27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 29 | 29 | |
| 30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 33 | 33 | |
| 34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | - $new_values['options'] = serialize($options); |
|
| 34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | + $new_values['options'] = serialize($options); |
|
| 36 | 36 | |
| 37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | - // $new_values['id'] = $values['id']; |
|
| 37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
| 38 | + // $new_values['id'] = $values['id']; |
|
| 39 | 39 | |
| 40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 41 | 41 | |
| 42 | - $id = $wpdb->insert_id; |
|
| 42 | + $id = $wpdb->insert_id; |
|
| 43 | 43 | |
| 44 | 44 | // Clear form caching |
| 45 | 45 | self::clear_form_cache(); |
| 46 | 46 | |
| 47 | - return $id; |
|
| 48 | - } |
|
| 47 | + return $id; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return int|boolean ID on success or false on failure |
|
| 52 | - */ |
|
| 53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | - global $wpdb; |
|
| 50 | + /** |
|
| 51 | + * @return int|boolean ID on success or false on failure |
|
| 52 | + */ |
|
| 53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
| 54 | + global $wpdb; |
|
| 55 | 55 | |
| 56 | - $values = self::getOne( $id, $blog_id ); |
|
| 57 | - if ( ! $values ) { |
|
| 58 | - return false; |
|
| 59 | - } |
|
| 56 | + $values = self::getOne( $id, $blog_id ); |
|
| 57 | + if ( ! $values ) { |
|
| 58 | + return false; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
| 61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
| 62 | 62 | |
| 63 | - $new_values = array( |
|
| 63 | + $new_values = array( |
|
| 64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 65 | - 'name' => $values->name, |
|
| 66 | - 'description' => $values->description, |
|
| 67 | - 'status' => $template ? 'published' : 'draft', |
|
| 68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | - 'created_at' => current_time('mysql', 1), |
|
| 71 | - 'is_template' => $template ? 1 : 0, |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - if ( $blog_id ) { |
|
| 75 | - $new_values['status'] = 'published'; |
|
| 76 | - $new_options = maybe_unserialize($values->options); |
|
| 77 | - $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | - $new_options['copy'] = false; |
|
| 79 | - $new_values['options'] = $new_options; |
|
| 80 | - } else { |
|
| 81 | - $new_values['options'] = $values->options; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if ( is_array($new_values['options']) ) { |
|
| 85 | - $new_values['options'] = serialize($new_values['options']); |
|
| 86 | - } |
|
| 65 | + 'name' => $values->name, |
|
| 66 | + 'description' => $values->description, |
|
| 67 | + 'status' => $template ? 'published' : 'draft', |
|
| 68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
| 69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
| 70 | + 'created_at' => current_time('mysql', 1), |
|
| 71 | + 'is_template' => $template ? 1 : 0, |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + if ( $blog_id ) { |
|
| 75 | + $new_values['status'] = 'published'; |
|
| 76 | + $new_options = maybe_unserialize($values->options); |
|
| 77 | + $new_options['email_to'] = get_option('admin_email'); |
|
| 78 | + $new_options['copy'] = false; |
|
| 79 | + $new_values['options'] = $new_options; |
|
| 80 | + } else { |
|
| 81 | + $new_values['options'] = $values->options; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if ( is_array($new_values['options']) ) { |
|
| 85 | + $new_values['options'] = serialize($new_values['options']); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
| 89 | 89 | |
| 90 | - if ( $query_results ) { |
|
| 90 | + if ( $query_results ) { |
|
| 91 | 91 | // Clear form caching |
| 92 | 92 | self::clear_form_cache(); |
| 93 | 93 | |
| 94 | - $form_id = $wpdb->insert_id; |
|
| 95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 94 | + $form_id = $wpdb->insert_id; |
|
| 95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 96 | 96 | |
| 97 | - // update form settings after fields are created |
|
| 97 | + // update form settings after fields are created |
|
| 98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
| 99 | - return $form_id; |
|
| 100 | - } |
|
| 99 | + return $form_id; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - return false; |
|
| 103 | - } |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | public static function after_duplicate( $form_id, $values ) { |
| 106 | 106 | $new_opts = maybe_unserialize( $values['options'] ); |
| 107 | 107 | $values['options'] = $new_opts; |
| 108 | 108 | |
| 109 | - if ( isset($new_opts['success_msg']) ) { |
|
| 110 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 111 | - } |
|
| 109 | + if ( isset($new_opts['success_msg']) ) { |
|
| 110 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 113 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 114 | 114 | |
| 115 | - if ( $new_opts != $values['options'] ) { |
|
| 116 | - global $wpdb; |
|
| 115 | + if ( $new_opts != $values['options'] ) { |
|
| 116 | + global $wpdb; |
|
| 117 | 117 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
| 118 | - } |
|
| 119 | - } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * @return int|boolean |
|
| 123 | - */ |
|
| 124 | - public static function update( $id, $values, $create_link = false ) { |
|
| 125 | - global $wpdb; |
|
| 121 | + /** |
|
| 122 | + * @return int|boolean |
|
| 123 | + */ |
|
| 124 | + public static function update( $id, $values, $create_link = false ) { |
|
| 125 | + global $wpdb; |
|
| 126 | 126 | |
| 127 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 128 | - $values['status'] = 'published'; |
|
| 129 | - } |
|
| 127 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
| 128 | + $values['status'] = 'published'; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - if ( isset($values['form_key']) ) { |
|
| 131 | + if ( isset($values['form_key']) ) { |
|
| 132 | 132 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 133 | - } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
| 136 | 136 | |
| 137 | - $new_values = self::set_update_options( array(), $values); |
|
| 137 | + $new_values = self::set_update_options( array(), $values); |
|
| 138 | 138 | |
| 139 | - foreach ( $values as $value_key => $value ) { |
|
| 139 | + foreach ( $values as $value_key => $value ) { |
|
| 140 | 140 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
| 141 | 141 | $new_values[ $value_key ] = $value; |
| 142 | - } |
|
| 143 | - } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 146 | - $new_values['status'] = $values['new_status']; |
|
| 147 | - } |
|
| 145 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
| 146 | + $new_values['status'] = $values['new_status']; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - if ( ! empty( $new_values ) ) { |
|
| 149 | + if ( ! empty( $new_values ) ) { |
|
| 150 | 150 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
| 151 | - if ( $query_results ) { |
|
| 151 | + if ( $query_results ) { |
|
| 152 | 152 | self::clear_form_cache(); |
| 153 | - } |
|
| 154 | - } else { |
|
| 155 | - $query_results = true; |
|
| 156 | - } |
|
| 157 | - unset($new_values); |
|
| 153 | + } |
|
| 154 | + } else { |
|
| 155 | + $query_results = true; |
|
| 156 | + } |
|
| 157 | + unset($new_values); |
|
| 158 | 158 | |
| 159 | - $values = self::update_fields($id, $values); |
|
| 159 | + $values = self::update_fields($id, $values); |
|
| 160 | 160 | |
| 161 | 161 | do_action( 'frm_update_form', $id, $values ); |
| 162 | 162 | do_action( 'frm_update_form_' . $id, $values ); |
| 163 | 163 | |
| 164 | - return $query_results; |
|
| 165 | - } |
|
| 164 | + return $query_results; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * @return array |
|
| 169 | - */ |
|
| 167 | + /** |
|
| 168 | + * @return array |
|
| 169 | + */ |
|
| 170 | 170 | public static function set_update_options( $new_values, $values ) { |
| 171 | - if ( ! isset($values['options']) ) { |
|
| 172 | - return $new_values; |
|
| 173 | - } |
|
| 171 | + if ( ! isset($values['options']) ) { |
|
| 172 | + return $new_values; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 176 | 176 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 177 | 177 | |
| 178 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 179 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 180 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 181 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 178 | + $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 179 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 180 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 181 | + $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 182 | 182 | |
| 183 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 184 | - $new_values['options'] = serialize($options); |
|
| 183 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 184 | + $new_values['options'] = serialize($options); |
|
| 185 | 185 | |
| 186 | - return $new_values; |
|
| 187 | - } |
|
| 186 | + return $new_values; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * @return array |
|
| 192 | - */ |
|
| 190 | + /** |
|
| 191 | + * @return array |
|
| 192 | + */ |
|
| 193 | 193 | public static function update_fields( $id, $values ) { |
| 194 | 194 | |
| 195 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 196 | - return $values; |
|
| 197 | - } |
|
| 195 | + if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 196 | + return $values; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 200 | - if ( empty($all_fields) ) { |
|
| 201 | - return $values; |
|
| 202 | - } |
|
| 199 | + $all_fields = FrmField::get_all_for_form($id); |
|
| 200 | + if ( empty($all_fields) ) { |
|
| 201 | + return $values; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - if ( ! isset($values['item_meta']) ) { |
|
| 205 | - $values['item_meta'] = array(); |
|
| 206 | - } |
|
| 204 | + if ( ! isset($values['item_meta']) ) { |
|
| 205 | + $values['item_meta'] = array(); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - $field_array = array(); |
|
| 209 | - $existing_keys = array_keys($values['item_meta']); |
|
| 210 | - foreach ( $all_fields as $fid ) { |
|
| 211 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 208 | + $field_array = array(); |
|
| 209 | + $existing_keys = array_keys($values['item_meta']); |
|
| 210 | + foreach ( $all_fields as $fid ) { |
|
| 211 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 212 | 212 | $values['item_meta'][ $fid->id ] = ''; |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | $field_array[ $fid->id ] = $fid; |
| 215 | - } |
|
| 216 | - unset($all_fields); |
|
| 215 | + } |
|
| 216 | + unset($all_fields); |
|
| 217 | 217 | |
| 218 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 218 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
| 219 | 219 | if ( isset( $field_array[ $field_id ] ) ) { |
| 220 | 220 | $field = $field_array[ $field_id ]; |
| 221 | - } else { |
|
| 222 | - $field = FrmField::getOne($field_id); |
|
| 223 | - } |
|
| 221 | + } else { |
|
| 222 | + $field = FrmField::getOne($field_id); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - if ( ! $field ) { |
|
| 226 | - continue; |
|
| 227 | - } |
|
| 225 | + if ( ! $field ) { |
|
| 226 | + continue; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | 229 | $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
| 230 | 230 | if ( $is_settings_page ) { |
| 231 | - //updating the settings page |
|
| 231 | + //updating the settings page |
|
| 232 | 232 | if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
| 233 | 233 | $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
| 234 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 234 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 235 | 235 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 236 | - } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
| 237 | - $prev_opts = $field->field_options; |
|
| 238 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 239 | - if ( $prev_opts != $field->field_options ) { |
|
| 236 | + } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
| 237 | + $prev_opts = $field->field_options; |
|
| 238 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 239 | + if ( $prev_opts != $field->field_options ) { |
|
| 240 | 240 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 241 | - } |
|
| 242 | - unset($prev_opts); |
|
| 243 | - } |
|
| 244 | - } |
|
| 241 | + } |
|
| 242 | + unset($prev_opts); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | 246 | if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) { |
| 247 | - continue; |
|
| 248 | - } |
|
| 247 | + continue; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - //updating the form |
|
| 250 | + //updating the form |
|
| 251 | 251 | $update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true ); |
| 252 | 252 | unset( $update_options['custom_html'] ); // don't check for POST html |
| 253 | 253 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 254 | 254 | |
| 255 | 255 | foreach ( $update_options as $opt => $default ) { |
| 256 | 256 | $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
| 257 | - } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 259 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 260 | 260 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
| 261 | 261 | |
| 262 | 262 | $new_field = array( |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | FrmField::update( $field_id, $new_field ); |
| 270 | 270 | |
| 271 | - FrmField::delete_form_transient($field->form_id); |
|
| 272 | - } |
|
| 271 | + FrmField::delete_form_transient($field->form_id); |
|
| 272 | + } |
|
| 273 | 273 | self::clear_form_cache(); |
| 274 | 274 | |
| 275 | - return $values; |
|
| 276 | - } |
|
| 275 | + return $values; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | 278 | private static function prepare_field_update_values( $field, $values, &$new_field ) { |
| 279 | 279 | $field_cols = array( |
@@ -286,113 +286,113 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - /** |
|
| 290 | - * @param string $status |
|
| 291 | - * @return int|boolean |
|
| 292 | - */ |
|
| 289 | + /** |
|
| 290 | + * @param string $status |
|
| 291 | + * @return int|boolean |
|
| 292 | + */ |
|
| 293 | 293 | public static function set_status( $id, $status ) { |
| 294 | - if ( 'trash' == $status ) { |
|
| 295 | - return self::trash($id); |
|
| 296 | - } |
|
| 294 | + if ( 'trash' == $status ) { |
|
| 295 | + return self::trash($id); |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | $statuses = array( 'published', 'draft', 'trash' ); |
| 299 | - if ( ! in_array( $status, $statuses ) ) { |
|
| 300 | - return false; |
|
| 301 | - } |
|
| 299 | + if ( ! in_array( $status, $statuses ) ) { |
|
| 300 | + return false; |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - global $wpdb; |
|
| 303 | + global $wpdb; |
|
| 304 | 304 | |
| 305 | - if ( is_array($id) ) { |
|
| 305 | + if ( is_array($id) ) { |
|
| 306 | 306 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
| 307 | 307 | FrmDb::get_where_clause_and_values( $where ); |
| 308 | 308 | array_unshift( $where['values'], $status ); |
| 309 | 309 | |
| 310 | 310 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
| 311 | - } else { |
|
| 311 | + } else { |
|
| 312 | 312 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
| 313 | 313 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) ); |
| 314 | - } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - if ( $query_results ) { |
|
| 316 | + if ( $query_results ) { |
|
| 317 | 317 | self::clear_form_cache(); |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - return $query_results; |
|
| 321 | - } |
|
| 320 | + return $query_results; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * @return int|boolean |
|
| 325 | - */ |
|
| 323 | + /** |
|
| 324 | + * @return int|boolean |
|
| 325 | + */ |
|
| 326 | 326 | public static function trash( $id ) { |
| 327 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
| 328 | - return self::destroy( $id ); |
|
| 329 | - } |
|
| 327 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
| 328 | + return self::destroy( $id ); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - $form = self::getOne($id); |
|
| 332 | - if ( ! $form ) { |
|
| 333 | - return false; |
|
| 334 | - } |
|
| 331 | + $form = self::getOne($id); |
|
| 332 | + if ( ! $form ) { |
|
| 333 | + return false; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - $options = $form->options; |
|
| 337 | - $options['trash_time'] = time(); |
|
| 336 | + $options = $form->options; |
|
| 337 | + $options['trash_time'] = time(); |
|
| 338 | 338 | |
| 339 | - global $wpdb; |
|
| 340 | - $query_results = $wpdb->update( |
|
| 339 | + global $wpdb; |
|
| 340 | + $query_results = $wpdb->update( |
|
| 341 | 341 | $wpdb->prefix . 'frm_forms', |
| 342 | 342 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
| 343 | 343 | array( 'id' => $id ) |
| 344 | - ); |
|
| 344 | + ); |
|
| 345 | 345 | |
| 346 | - $wpdb->update( |
|
| 346 | + $wpdb->update( |
|
| 347 | 347 | $wpdb->prefix . 'frm_forms', |
| 348 | 348 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
| 349 | 349 | array( 'parent_form_id' => $id ) |
| 350 | - ); |
|
| 350 | + ); |
|
| 351 | 351 | |
| 352 | - if ( $query_results ) { |
|
| 352 | + if ( $query_results ) { |
|
| 353 | 353 | self::clear_form_cache(); |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - return $query_results; |
|
| 357 | - } |
|
| 356 | + return $query_results; |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * @return int|boolean |
|
| 361 | - */ |
|
| 359 | + /** |
|
| 360 | + * @return int|boolean |
|
| 361 | + */ |
|
| 362 | 362 | public static function destroy( $id ) { |
| 363 | - global $wpdb; |
|
| 363 | + global $wpdb; |
|
| 364 | 364 | |
| 365 | - $form = self::getOne($id); |
|
| 366 | - if ( ! $form ) { |
|
| 367 | - return false; |
|
| 368 | - } |
|
| 365 | + $form = self::getOne($id); |
|
| 366 | + if ( ! $form ) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 369 | 369 | $id = $form->id; |
| 370 | 370 | |
| 371 | - // Disconnect the entries from this form |
|
| 371 | + // Disconnect the entries from this form |
|
| 372 | 372 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 373 | - foreach ( $entries as $entry_id ) { |
|
| 374 | - FrmEntry::destroy($entry_id); |
|
| 375 | - unset($entry_id); |
|
| 376 | - } |
|
| 373 | + foreach ( $entries as $entry_id ) { |
|
| 374 | + FrmEntry::destroy($entry_id); |
|
| 375 | + unset($entry_id); |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - // Disconnect the fields from this form |
|
| 378 | + // Disconnect the fields from this form |
|
| 379 | 379 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
| 380 | 380 | |
| 381 | 381 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
| 382 | - if ( $query_results ) { |
|
| 383 | - // Delete all form actions linked to this form |
|
| 384 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 385 | - $action_control->destroy($id, 'all'); |
|
| 382 | + if ( $query_results ) { |
|
| 383 | + // Delete all form actions linked to this form |
|
| 384 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
| 385 | + $action_control->destroy($id, 'all'); |
|
| 386 | 386 | |
| 387 | 387 | // Clear form caching |
| 388 | 388 | self::clear_form_cache(); |
| 389 | 389 | |
| 390 | 390 | do_action( 'frm_destroy_form', $id ); |
| 391 | 391 | do_action( 'frm_destroy_form_' . $id ); |
| 392 | - } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - return $query_results; |
|
| 395 | - } |
|
| 394 | + return $query_results; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | 398 | * Delete trashed forms based on how long they have been trashed |
@@ -424,47 +424,47 @@ discard block |
||
| 424 | 424 | return $count; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * @return string form name |
|
| 429 | - */ |
|
| 430 | - public static function getName( $id ) { |
|
| 431 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 432 | - if ( $form ) { |
|
| 433 | - $r = stripslashes($form->name); |
|
| 434 | - return $r; |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 438 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 439 | - $r = stripslashes($r); |
|
| 440 | - |
|
| 441 | - return $r; |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * @param string $key |
|
| 446 | - * @return int form id |
|
| 447 | - */ |
|
| 427 | + /** |
|
| 428 | + * @return string form name |
|
| 429 | + */ |
|
| 430 | + public static function getName( $id ) { |
|
| 431 | + $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 432 | + if ( $form ) { |
|
| 433 | + $r = stripslashes($form->name); |
|
| 434 | + return $r; |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
| 438 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
| 439 | + $r = stripslashes($r); |
|
| 440 | + |
|
| 441 | + return $r; |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * @param string $key |
|
| 446 | + * @return int form id |
|
| 447 | + */ |
|
| 448 | 448 | public static function getIdByKey( $key ) { |
| 449 | - $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
| 450 | - return $id; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 454 | - * @param int $id |
|
| 455 | - * @return string form key |
|
| 456 | - */ |
|
| 449 | + $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
| 450 | + return $id; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + /** |
|
| 454 | + * @param int $id |
|
| 455 | + * @return string form key |
|
| 456 | + */ |
|
| 457 | 457 | public static function getKeyById( $id ) { |
| 458 | - $id = (int) $id; |
|
| 459 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 460 | - if ( $cache ) { |
|
| 461 | - return $cache->form_key; |
|
| 462 | - } |
|
| 458 | + $id = (int) $id; |
|
| 459 | + $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 460 | + if ( $cache ) { |
|
| 461 | + return $cache->form_key; |
|
| 462 | + } |
|
| 463 | 463 | |
| 464 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 464 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
| 465 | 465 | |
| 466 | - return $key; |
|
| 467 | - } |
|
| 466 | + return $key; |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | 469 | /** |
| 470 | 470 | * If $form is numeric, get the form object |
@@ -477,47 +477,47 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - /** |
|
| 481 | - * @return object form |
|
| 482 | - */ |
|
| 483 | - public static function getOne( $id, $blog_id = false ) { |
|
| 484 | - global $wpdb; |
|
| 480 | + /** |
|
| 481 | + * @return object form |
|
| 482 | + */ |
|
| 483 | + public static function getOne( $id, $blog_id = false ) { |
|
| 484 | + global $wpdb; |
|
| 485 | 485 | |
| 486 | - if ( $blog_id && is_multisite() ) { |
|
| 487 | - global $wpmuBaseTablePrefix; |
|
| 486 | + if ( $blog_id && is_multisite() ) { |
|
| 487 | + global $wpmuBaseTablePrefix; |
|
| 488 | 488 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
| 489 | 489 | |
| 490 | 490 | $table_name = $prefix . 'frm_forms'; |
| 491 | - } else { |
|
| 491 | + } else { |
|
| 492 | 492 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 493 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 494 | - if ( $cache ) { |
|
| 495 | - if ( isset($cache->options) ) { |
|
| 496 | - $cache->options = maybe_unserialize($cache->options); |
|
| 497 | - } |
|
| 493 | + $cache = wp_cache_get($id, 'frm_form'); |
|
| 494 | + if ( $cache ) { |
|
| 495 | + if ( isset($cache->options) ) { |
|
| 496 | + $cache->options = maybe_unserialize($cache->options); |
|
| 497 | + } |
|
| 498 | 498 | |
| 499 | - return stripslashes_deep($cache); |
|
| 500 | - } |
|
| 501 | - } |
|
| 499 | + return stripslashes_deep($cache); |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - if ( is_numeric($id) ) { |
|
| 504 | - $where = array( 'id' => $id ); |
|
| 505 | - } else { |
|
| 506 | - $where = array( 'form_key' => $id ); |
|
| 507 | - } |
|
| 503 | + if ( is_numeric($id) ) { |
|
| 504 | + $where = array( 'id' => $id ); |
|
| 505 | + } else { |
|
| 506 | + $where = array( 'form_key' => $id ); |
|
| 507 | + } |
|
| 508 | 508 | |
| 509 | - $results = FrmDb::get_row( $table_name, $where ); |
|
| 509 | + $results = FrmDb::get_row( $table_name, $where ); |
|
| 510 | 510 | |
| 511 | - if ( isset($results->options) ) { |
|
| 511 | + if ( isset($results->options) ) { |
|
| 512 | 512 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
| 513 | - $results->options = maybe_unserialize($results->options); |
|
| 514 | - } |
|
| 515 | - return stripslashes_deep($results); |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * @return object|array of objects |
|
| 520 | - */ |
|
| 513 | + $results->options = maybe_unserialize($results->options); |
|
| 514 | + } |
|
| 515 | + return stripslashes_deep($results); |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * @return object|array of objects |
|
| 520 | + */ |
|
| 521 | 521 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
| 522 | 522 | if ( is_array( $where ) && ! empty( $where ) ) { |
| 523 | 523 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) ); |
@@ -541,8 +541,8 @@ discard block |
||
| 541 | 541 | $results = reset( $results ); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - return stripslashes_deep($results); |
|
| 545 | - } |
|
| 544 | + return stripslashes_deep($results); |
|
| 545 | + } |
|
| 546 | 546 | |
| 547 | 547 | /** |
| 548 | 548 | * Get all published forms |
@@ -560,47 +560,47 @@ discard block |
||
| 560 | 560 | return $forms; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - /** |
|
| 564 | - * @return int count of forms |
|
| 565 | - */ |
|
| 566 | - public static function get_count() { |
|
| 567 | - global $wpdb; |
|
| 563 | + /** |
|
| 564 | + * @return int count of forms |
|
| 565 | + */ |
|
| 566 | + public static function get_count() { |
|
| 567 | + global $wpdb; |
|
| 568 | 568 | |
| 569 | - $cache_key = 'frm_form_counts'; |
|
| 569 | + $cache_key = 'frm_form_counts'; |
|
| 570 | 570 | |
| 571 | - $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
| 572 | - if ( false !== $counts ) { |
|
| 573 | - return $counts; |
|
| 574 | - } |
|
| 571 | + $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
| 572 | + if ( false !== $counts ) { |
|
| 573 | + return $counts; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
| 576 | + $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
| 577 | 577 | |
| 578 | 578 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
| 579 | - $counts = array_fill_keys( $statuses, 0 ); |
|
| 579 | + $counts = array_fill_keys( $statuses, 0 ); |
|
| 580 | 580 | |
| 581 | - foreach ( $results as $row ) { |
|
| 582 | - if ( 'trash' != $row->status ) { |
|
| 583 | - if ( $row->is_template ) { |
|
| 581 | + foreach ( $results as $row ) { |
|
| 582 | + if ( 'trash' != $row->status ) { |
|
| 583 | + if ( $row->is_template ) { |
|
| 584 | 584 | $counts['template']++; |
| 585 | - } else { |
|
| 585 | + } else { |
|
| 586 | 586 | $counts['published']++; |
| 587 | - } |
|
| 588 | - } else { |
|
| 587 | + } |
|
| 588 | + } else { |
|
| 589 | 589 | $counts['trash']++; |
| 590 | - } |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - if ( 'draft' == $row->status ) { |
|
| 592 | + if ( 'draft' == $row->status ) { |
|
| 593 | 593 | $counts['draft']++; |
| 594 | - } |
|
| 594 | + } |
|
| 595 | 595 | |
| 596 | - unset($row); |
|
| 597 | - } |
|
| 596 | + unset($row); |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - $counts = (object) $counts; |
|
| 599 | + $counts = (object) $counts; |
|
| 600 | 600 | FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' ); |
| 601 | 601 | |
| 602 | - return $counts; |
|
| 603 | - } |
|
| 602 | + return $counts; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | 605 | /** |
| 606 | 606 | * Clear form caching |
@@ -613,14 +613,14 @@ discard block |
||
| 613 | 613 | FrmAppHelper::cache_delete_group( 'frm_form' ); |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - /** |
|
| 617 | - * @return array of errors |
|
| 618 | - */ |
|
| 616 | + /** |
|
| 617 | + * @return array of errors |
|
| 618 | + */ |
|
| 619 | 619 | public static function validate( $values ) { |
| 620 | - $errors = array(); |
|
| 620 | + $errors = array(); |
|
| 621 | 621 | |
| 622 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 623 | - } |
|
| 622 | + return apply_filters('frm_validate_form', $errors, $values); |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | public static function get_params( $form = null ) { |
| 626 | 626 | global $frm_vars; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 3 | - die('You are not allowed to call this page directly.'); |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + die( 'You are not allowed to call this page directly.' ); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmForm { |
@@ -15,24 +15,24 @@ discard block |
||
| 15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
| 16 | 16 | 'name' => $values['name'], |
| 17 | 17 | 'description' => $values['description'], |
| 18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
| 19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
| 20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
| 18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
| 19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
| 20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
| 21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
| 22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
| 23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
| 24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
| 22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
| 23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
| 24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 29 | 29 | |
| 30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
| 31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
| 32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
| 33 | 33 | |
| 34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 35 | - $new_values['options'] = serialize($options); |
|
| 34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
| 35 | + $new_values['options'] = serialize( $options ); |
|
| 36 | 36 | |
| 37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
| 38 | 38 | // $new_values['id'] = $values['id']; |
@@ -67,22 +67,22 @@ discard block |
||
| 67 | 67 | 'status' => $template ? 'published' : 'draft', |
| 68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
| 69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
| 70 | - 'created_at' => current_time('mysql', 1), |
|
| 70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
| 71 | 71 | 'is_template' => $template ? 1 : 0, |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | if ( $blog_id ) { |
| 75 | 75 | $new_values['status'] = 'published'; |
| 76 | - $new_options = maybe_unserialize($values->options); |
|
| 77 | - $new_options['email_to'] = get_option('admin_email'); |
|
| 76 | + $new_options = maybe_unserialize( $values->options ); |
|
| 77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
| 78 | 78 | $new_options['copy'] = false; |
| 79 | 79 | $new_values['options'] = $new_options; |
| 80 | 80 | } else { |
| 81 | 81 | $new_values['options'] = $values->options; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - if ( is_array($new_values['options']) ) { |
|
| 85 | - $new_values['options'] = serialize($new_values['options']); |
|
| 84 | + if ( is_array( $new_values['options'] ) ) { |
|
| 85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | self::clear_form_cache(); |
| 93 | 93 | |
| 94 | 94 | $form_id = $wpdb->insert_id; |
| 95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
| 95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
| 96 | 96 | |
| 97 | 97 | // update form settings after fields are created |
| 98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | $new_opts = maybe_unserialize( $values['options'] ); |
| 107 | 107 | $values['options'] = $new_opts; |
| 108 | 108 | |
| 109 | - if ( isset($new_opts['success_msg']) ) { |
|
| 110 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 109 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
| 110 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 113 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
| 114 | 114 | |
| 115 | 115 | if ( $new_opts != $values['options'] ) { |
| 116 | 116 | global $wpdb; |
@@ -128,17 +128,17 @@ discard block |
||
| 128 | 128 | $values['status'] = 'published'; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( isset($values['form_key']) ) { |
|
| 131 | + if ( isset( $values['form_key'] ) ) { |
|
| 132 | 132 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
| 136 | 136 | |
| 137 | - $new_values = self::set_update_options( array(), $values); |
|
| 137 | + $new_values = self::set_update_options( array(), $values ); |
|
| 138 | 138 | |
| 139 | 139 | foreach ( $values as $value_key => $value ) { |
| 140 | 140 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
| 141 | - $new_values[ $value_key ] = $value; |
|
| 141 | + $new_values[$value_key] = $value; |
|
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | } else { |
| 155 | 155 | $query_results = true; |
| 156 | 156 | } |
| 157 | - unset($new_values); |
|
| 157 | + unset( $new_values ); |
|
| 158 | 158 | |
| 159 | - $values = self::update_fields($id, $values); |
|
| 159 | + $values = self::update_fields( $id, $values ); |
|
| 160 | 160 | |
| 161 | 161 | do_action( 'frm_update_form', $id, $values ); |
| 162 | 162 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | * @return array |
| 169 | 169 | */ |
| 170 | 170 | public static function set_update_options( $new_values, $values ) { |
| 171 | - if ( ! isset($values['options']) ) { |
|
| 171 | + if ( ! isset( $values['options'] ) ) { |
|
| 172 | 172 | return $new_values; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 176 | 176 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 177 | 177 | |
| 178 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 179 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 180 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 181 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 178 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
| 179 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
| 180 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
| 181 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
| 182 | 182 | |
| 183 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 184 | - $new_values['options'] = serialize($options); |
|
| 183 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
| 184 | + $new_values['options'] = serialize( $options ); |
|
| 185 | 185 | |
| 186 | 186 | return $new_values; |
| 187 | 187 | } |
@@ -192,54 +192,54 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public static function update_fields( $id, $values ) { |
| 194 | 194 | |
| 195 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 195 | + if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
| 196 | 196 | return $values; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 200 | - if ( empty($all_fields) ) { |
|
| 199 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
| 200 | + if ( empty( $all_fields ) ) { |
|
| 201 | 201 | return $values; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if ( ! isset($values['item_meta']) ) { |
|
| 204 | + if ( ! isset( $values['item_meta'] ) ) { |
|
| 205 | 205 | $values['item_meta'] = array(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | $field_array = array(); |
| 209 | - $existing_keys = array_keys($values['item_meta']); |
|
| 209 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
| 210 | 210 | foreach ( $all_fields as $fid ) { |
| 211 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 212 | - $values['item_meta'][ $fid->id ] = ''; |
|
| 211 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
| 212 | + $values['item_meta'][$fid->id] = ''; |
|
| 213 | 213 | } |
| 214 | - $field_array[ $fid->id ] = $fid; |
|
| 214 | + $field_array[$fid->id] = $fid; |
|
| 215 | 215 | } |
| 216 | - unset($all_fields); |
|
| 216 | + unset( $all_fields ); |
|
| 217 | 217 | |
| 218 | 218 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
| 219 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
| 220 | - $field = $field_array[ $field_id ]; |
|
| 219 | + if ( isset( $field_array[$field_id] ) ) { |
|
| 220 | + $field = $field_array[$field_id]; |
|
| 221 | 221 | } else { |
| 222 | - $field = FrmField::getOne($field_id); |
|
| 222 | + $field = FrmField::getOne( $field_id ); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | if ( ! $field ) { |
| 226 | 226 | continue; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
| 229 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
| 230 | 230 | if ( $is_settings_page ) { |
| 231 | 231 | //updating the settings page |
| 232 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
| 233 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
| 234 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 232 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
| 233 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
| 234 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 235 | 235 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 236 | 236 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
| 237 | 237 | $prev_opts = $field->field_options; |
| 238 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 238 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 239 | 239 | if ( $prev_opts != $field->field_options ) { |
| 240 | 240 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 241 | 241 | } |
| 242 | - unset($prev_opts); |
|
| 242 | + unset( $prev_opts ); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
@@ -253,11 +253,11 @@ discard block |
||
| 253 | 253 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 254 | 254 | |
| 255 | 255 | foreach ( $update_options as $opt => $default ) { |
| 256 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
| 256 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 260 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
| 259 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
| 260 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
| 261 | 261 | |
| 262 | 262 | $new_field = array( |
| 263 | 263 | 'field_options' => $field->field_options, |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | FrmField::update( $field_id, $new_field ); |
| 270 | 270 | |
| 271 | - FrmField::delete_form_transient($field->form_id); |
|
| 271 | + FrmField::delete_form_transient( $field->form_id ); |
|
| 272 | 272 | } |
| 273 | 273 | self::clear_form_cache(); |
| 274 | 274 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | ); |
| 283 | 283 | foreach ( $field_cols as $col => $default ) { |
| 284 | 284 | $default = ( $default === '' ) ? $field->{$col} : $default; |
| 285 | - $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default; |
|
| 285 | + $new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default; |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -292,17 +292,17 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public static function set_status( $id, $status ) { |
| 294 | 294 | if ( 'trash' == $status ) { |
| 295 | - return self::trash($id); |
|
| 295 | + return self::trash( $id ); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
| 298 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
| 299 | 299 | if ( ! in_array( $status, $statuses ) ) { |
| 300 | 300 | return false; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | global $wpdb; |
| 304 | 304 | |
| 305 | - if ( is_array($id) ) { |
|
| 305 | + if ( is_array( $id ) ) { |
|
| 306 | 306 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
| 307 | 307 | FrmDb::get_where_clause_and_values( $where ); |
| 308 | 308 | array_unshift( $where['values'], $status ); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | return self::destroy( $id ); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $form = self::getOne($id); |
|
| 331 | + $form = self::getOne( $id ); |
|
| 332 | 332 | if ( ! $form ) { |
| 333 | 333 | return false; |
| 334 | 334 | } |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | public static function destroy( $id ) { |
| 363 | 363 | global $wpdb; |
| 364 | 364 | |
| 365 | - $form = self::getOne($id); |
|
| 365 | + $form = self::getOne( $id ); |
|
| 366 | 366 | if ( ! $form ) { |
| 367 | 367 | return false; |
| 368 | 368 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | // Disconnect the entries from this form |
| 372 | 372 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 373 | 373 | foreach ( $entries as $entry_id ) { |
| 374 | - FrmEntry::destroy($entry_id); |
|
| 375 | - unset($entry_id); |
|
| 374 | + FrmEntry::destroy( $entry_id ); |
|
| 375 | + unset( $entry_id ); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // Disconnect the fields from this form |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | if ( $query_results ) { |
| 383 | 383 | // Delete all form actions linked to this form |
| 384 | 384 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 385 | - $action_control->destroy($id, 'all'); |
|
| 385 | + $action_control->destroy( $id, 'all' ); |
|
| 386 | 386 | |
| 387 | 387 | // Clear form caching |
| 388 | 388 | self::clear_form_cache(); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $form->options = maybe_unserialize( $form->options ); |
| 417 | 417 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
| 418 | 418 | self::destroy( $form->id ); |
| 419 | - $count++; |
|
| 419 | + $count ++; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | unset( $form ); |
@@ -428,15 +428,15 @@ discard block |
||
| 428 | 428 | * @return string form name |
| 429 | 429 | */ |
| 430 | 430 | public static function getName( $id ) { |
| 431 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 431 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 432 | 432 | if ( $form ) { |
| 433 | - $r = stripslashes($form->name); |
|
| 433 | + $r = stripslashes( $form->name ); |
|
| 434 | 434 | return $r; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
| 438 | 438 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
| 439 | - $r = stripslashes($r); |
|
| 439 | + $r = stripslashes( $r ); |
|
| 440 | 440 | |
| 441 | 441 | return $r; |
| 442 | 442 | } |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | */ |
| 457 | 457 | public static function getKeyById( $id ) { |
| 458 | 458 | $id = (int) $id; |
| 459 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 459 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 460 | 460 | if ( $cache ) { |
| 461 | 461 | return $cache->form_key; |
| 462 | 462 | } |
@@ -490,17 +490,17 @@ discard block |
||
| 490 | 490 | $table_name = $prefix . 'frm_forms'; |
| 491 | 491 | } else { |
| 492 | 492 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 493 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 493 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
| 494 | 494 | if ( $cache ) { |
| 495 | - if ( isset($cache->options) ) { |
|
| 496 | - $cache->options = maybe_unserialize($cache->options); |
|
| 495 | + if ( isset( $cache->options ) ) { |
|
| 496 | + $cache->options = maybe_unserialize( $cache->options ); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - return stripslashes_deep($cache); |
|
| 499 | + return stripslashes_deep( $cache ); |
|
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - if ( is_numeric($id) ) { |
|
| 503 | + if ( is_numeric( $id ) ) { |
|
| 504 | 504 | $where = array( 'id' => $id ); |
| 505 | 505 | } else { |
| 506 | 506 | $where = array( 'form_key' => $id ); |
@@ -508,11 +508,11 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $results = FrmDb::get_row( $table_name, $where ); |
| 510 | 510 | |
| 511 | - if ( isset($results->options) ) { |
|
| 511 | + if ( isset( $results->options ) ) { |
|
| 512 | 512 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
| 513 | - $results->options = maybe_unserialize($results->options); |
|
| 513 | + $results->options = maybe_unserialize( $results->options ); |
|
| 514 | 514 | } |
| 515 | - return stripslashes_deep($results); |
|
| 515 | + return stripslashes_deep( $results ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | $results = reset( $results ); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - return stripslashes_deep($results); |
|
| 544 | + return stripslashes_deep( $results ); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | /** |
@@ -581,19 +581,19 @@ discard block |
||
| 581 | 581 | foreach ( $results as $row ) { |
| 582 | 582 | if ( 'trash' != $row->status ) { |
| 583 | 583 | if ( $row->is_template ) { |
| 584 | - $counts['template']++; |
|
| 584 | + $counts['template'] ++; |
|
| 585 | 585 | } else { |
| 586 | - $counts['published']++; |
|
| 586 | + $counts['published'] ++; |
|
| 587 | 587 | } |
| 588 | 588 | } else { |
| 589 | - $counts['trash']++; |
|
| 589 | + $counts['trash'] ++; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | if ( 'draft' == $row->status ) { |
| 593 | - $counts['draft']++; |
|
| 593 | + $counts['draft'] ++; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - unset($row); |
|
| 596 | + unset( $row ); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | $counts = (object) $counts; |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | public static function validate( $values ) { |
| 620 | 620 | $errors = array(); |
| 621 | 621 | |
| 622 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 622 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | public static function get_params( $form = null ) { |
@@ -631,11 +631,11 @@ discard block |
||
| 631 | 631 | self::maybe_get_form( $form ); |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
| 635 | - return $frm_vars['form_params'][ $form->id ]; |
|
| 634 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
| 635 | + return $frm_vars['form_params'][$form->id]; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 638 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 639 | 639 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
| 640 | 640 | |
| 641 | 641 | $default_values = array( |
@@ -653,15 +653,15 @@ discard block |
||
| 653 | 653 | //if there are two forms on the same page, make sure not to submit both |
| 654 | 654 | foreach ( $default_values as $var => $default ) { |
| 655 | 655 | if ( $var == 'action' ) { |
| 656 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 656 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 657 | 657 | } else { |
| 658 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 658 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 659 | 659 | } |
| 660 | 660 | unset( $var, $default ); |
| 661 | 661 | } |
| 662 | 662 | } else { |
| 663 | 663 | foreach ( $default_values as $var => $default ) { |
| 664 | - $values[ $var ] = $default; |
|
| 664 | + $values[$var] = $default; |
|
| 665 | 665 | unset( $var, $default ); |
| 666 | 666 | } |
| 667 | 667 | } |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | public static function list_page_params() { |
| 677 | 677 | $values = array(); |
| 678 | 678 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
| 679 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 679 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | return $values; |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
| 697 | 697 | 'keep_post' => '', |
| 698 | 698 | ) as $var => $default ) { |
| 699 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 699 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | return $values; |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | $small_form = new stdClass(); |
| 754 | 754 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
| 755 | 755 | $small_form->{$var} = $form->{$var}; |
| 756 | - unset($var); |
|
| 756 | + unset( $var ); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | $frm_vars['forms_loaded'][] = $small_form; |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | $frm_vars['load_css'] = true; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 766 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | public static function show_submit( $form ) { |
@@ -777,6 +777,6 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | public static function get_option( $atts ) { |
| 779 | 779 | $form = $atts['form']; |
| 780 | - return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default']; |
|
| 780 | + return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default']; |
|
| 781 | 781 | } |
| 782 | 782 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class FrmField { |
| 7 | 7 | |
| 8 | - static $use_cache = true; |
|
| 8 | + static $use_cache = true; |
|
| 9 | 9 | static $transient_size = 200; |
| 10 | 10 | |
| 11 | 11 | public static function field_selection() { |
@@ -52,39 +52,39 @@ discard block |
||
| 52 | 52 | )); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function create( $values, $return = true ) { |
|
| 56 | - global $wpdb, $frm_duplicate_ids; |
|
| 55 | + public static function create( $values, $return = true ) { |
|
| 56 | + global $wpdb, $frm_duplicate_ids; |
|
| 57 | 57 | |
| 58 | - $new_values = array(); |
|
| 59 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
| 58 | + $new_values = array(); |
|
| 59 | + $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
| 60 | 60 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 61 | 61 | |
| 62 | 62 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 63 | 63 | $new_values[ $col ] = $values[ $col ]; |
| 64 | - } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $new_values['options'] = $values['options']; |
|
| 66 | + $new_values['options'] = $values['options']; |
|
| 67 | 67 | |
| 68 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
| 69 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
| 70 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
| 71 | - $new_values['field_options'] = $values['field_options']; |
|
| 72 | - $new_values['created_at'] = current_time('mysql', 1); |
|
| 68 | + $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
| 69 | + $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
| 70 | + $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
| 71 | + $new_values['field_options'] = $values['field_options']; |
|
| 72 | + $new_values['created_at'] = current_time('mysql', 1); |
|
| 73 | 73 | |
| 74 | 74 | if ( isset( $values['id'] ) ) { |
| 75 | 75 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
| 76 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
| 77 | - } |
|
| 76 | + $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | foreach ( $new_values as $k => $v ) { |
| 80 | - if ( is_array( $v ) ) { |
|
| 80 | + if ( is_array( $v ) ) { |
|
| 81 | 81 | $new_values[ $k ] = serialize( $v ); |
| 82 | 82 | } |
| 83 | - unset( $k, $v ); |
|
| 84 | - } |
|
| 83 | + unset( $k, $v ); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 87 | - // $new_values['id'] = $values['id']; |
|
| 86 | + //if(isset($values['id']) and is_numeric($values['id'])) |
|
| 87 | + // $new_values['id'] = $values['id']; |
|
| 88 | 88 | |
| 89 | 89 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_fields', $new_values ); |
| 90 | 90 | $new_id = 0; |
@@ -105,22 +105,22 @@ discard block |
||
| 105 | 105 | } else { |
| 106 | 106 | return false; |
| 107 | 107 | } |
| 108 | - } |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 111 | - global $frm_duplicate_ids; |
|
| 110 | + public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) { |
|
| 111 | + global $frm_duplicate_ids; |
|
| 112 | 112 | |
| 113 | 113 | $where = array( array( 'or' => 1, 'fi.form_id' => $old_form_id, 'fr.parent_form_id' => $old_form_id ) ); |
| 114 | 114 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
| 115 | 115 | |
| 116 | - foreach ( (array) $fields as $field ) { |
|
| 117 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
| 118 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
| 119 | - $new_key = rtrim($new_key, 2); |
|
| 120 | - } |
|
| 116 | + foreach ( (array) $fields as $field ) { |
|
| 117 | + $new_key = ($copy_keys) ? $field->field_key : ''; |
|
| 118 | + if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
| 119 | + $new_key = rtrim($new_key, 2); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - $values = array(); |
|
| 123 | - FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 122 | + $values = array(); |
|
| 123 | + FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key ); |
|
| 124 | 124 | |
| 125 | 125 | // If this is a repeating section, create new form |
| 126 | 126 | if ( self::is_repeating_field( $field ) ) { |
@@ -139,16 +139,16 @@ discard block |
||
| 139 | 139 | $values['form_id'] = $new_repeat_form_id; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $values = apply_filters('frm_duplicated_field', $values); |
|
| 143 | - $new_id = self::create($values); |
|
| 144 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 145 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 146 | - unset($field); |
|
| 147 | - } |
|
| 148 | - } |
|
| 142 | + $values = apply_filters('frm_duplicated_field', $values); |
|
| 143 | + $new_id = self::create($values); |
|
| 144 | + $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 145 | + $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 146 | + unset($field); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | public static function update( $id, $values ) { |
| 151 | - global $wpdb; |
|
| 151 | + global $wpdb; |
|
| 152 | 152 | |
| 153 | 153 | $id = absint( $id ); |
| 154 | 154 | |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( isset($values['required']) ) { |
|
| 160 | - $values['required'] = (int) $values['required']; |
|
| 161 | - } |
|
| 159 | + if ( isset($values['required']) ) { |
|
| 160 | + $values['required'] = (int) $values['required']; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | 163 | self::preserve_format_option_backslashes( $values ); |
| 164 | 164 | |
@@ -175,41 +175,41 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) ); |
| 177 | 177 | |
| 178 | - $form_id = 0; |
|
| 178 | + $form_id = 0; |
|
| 179 | 179 | if ( isset( $values['form_id'] ) ) { |
| 180 | - $form_id = absint( $values['form_id'] ); |
|
| 180 | + $form_id = absint( $values['form_id'] ); |
|
| 181 | 181 | } else { |
| 182 | - $field = self::getOne($id); |
|
| 183 | - if ( $field ) { |
|
| 184 | - $form_id = $field->form_id; |
|
| 185 | - } |
|
| 186 | - unset($field); |
|
| 187 | - } |
|
| 188 | - unset($values); |
|
| 182 | + $field = self::getOne($id); |
|
| 183 | + if ( $field ) { |
|
| 184 | + $form_id = $field->form_id; |
|
| 185 | + } |
|
| 186 | + unset($field); |
|
| 187 | + } |
|
| 188 | + unset($values); |
|
| 189 | 189 | |
| 190 | 190 | if ( $query_results ) { |
| 191 | - wp_cache_delete( $id, 'frm_field' ); |
|
| 192 | - if ( $form_id ) { |
|
| 193 | - self::delete_form_transient( $form_id ); |
|
| 194 | - } |
|
| 195 | - } |
|
| 191 | + wp_cache_delete( $id, 'frm_field' ); |
|
| 192 | + if ( $form_id ) { |
|
| 193 | + self::delete_form_transient( $form_id ); |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - return $query_results; |
|
| 198 | - } |
|
| 197 | + return $query_results; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * Keep backslashes in the phone format option |
|
| 202 | - * |
|
| 203 | - * @since 2.0.8 |
|
| 204 | - * @param $values array - pass by reference |
|
| 205 | - */ |
|
| 201 | + * Keep backslashes in the phone format option |
|
| 202 | + * |
|
| 203 | + * @since 2.0.8 |
|
| 204 | + * @param $values array - pass by reference |
|
| 205 | + */ |
|
| 206 | 206 | private static function preserve_format_option_backslashes( &$values ) { |
| 207 | 207 | if ( isset( $values['field_options']['format'] ) ) { |
| 208 | 208 | $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] ); |
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - public static function destroy( $id ) { |
|
| 212 | + public static function destroy( $id ) { |
|
| 213 | 213 | global $wpdb; |
| 214 | 214 | |
| 215 | 215 | do_action( 'frm_before_destroy_field', $id ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id=%d', $id ) ); |
| 226 | 226 | return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) ); |
| 227 | - } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | 229 | public static function delete_form_transient( $form_id ) { |
| 230 | 230 | $form_id = absint( $form_id ); |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | FrmAppHelper::cache_delete_group( 'frm_field' ); |
| 240 | 240 | |
| 241 | - $form = FrmForm::getOne($form_id); |
|
| 242 | - if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 243 | - self::delete_form_transient( $form->parent_form_id ); |
|
| 244 | - } |
|
| 245 | - } |
|
| 241 | + $form = FrmForm::getOne($form_id); |
|
| 242 | + if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
|
| 243 | + self::delete_form_transient( $form->parent_form_id ); |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * If $field is numeric, get the field object |
@@ -258,131 +258,131 @@ discard block |
||
| 258 | 258 | return null; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - global $wpdb; |
|
| 261 | + global $wpdb; |
|
| 262 | 262 | |
| 263 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
| 263 | + $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
| 264 | 264 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
| 265 | 265 | |
| 266 | - $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 266 | + $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
|
| 267 | 267 | |
| 268 | - if ( empty($results) ) { |
|
| 269 | - return $results; |
|
| 270 | - } |
|
| 268 | + if ( empty($results) ) { |
|
| 269 | + return $results; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - if ( is_numeric($id) ) { |
|
| 272 | + if ( is_numeric($id) ) { |
|
| 273 | 273 | FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' ); |
| 274 | - } else if ( $results ) { |
|
| 274 | + } else if ( $results ) { |
|
| 275 | 275 | FrmAppHelper::set_cache( $results->id, $results, 'frm_field' ); |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | 278 | self::prepare_options( $results ); |
| 279 | 279 | |
| 280 | - return stripslashes_deep($results); |
|
| 281 | - } |
|
| 280 | + return stripslashes_deep($results); |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Get the field type by key or id |
|
| 285 | - * @param int|string The field id or key |
|
| 283 | + /** |
|
| 284 | + * Get the field type by key or id |
|
| 285 | + * @param int|string The field id or key |
|
| 286 | 286 | * @param mixed $col The name of the column in the fields database table |
| 287 | - */ |
|
| 288 | - public static function get_type( $id, $col = 'type' ) { |
|
| 289 | - $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
| 290 | - if ( $field ) { |
|
| 291 | - $type = $field->{$col}; |
|
| 292 | - } else { |
|
| 293 | - $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - return $type; |
|
| 297 | - } |
|
| 287 | + */ |
|
| 288 | + public static function get_type( $id, $col = 'type' ) { |
|
| 289 | + $field = FrmAppHelper::check_cache( $id, 'frm_field' ); |
|
| 290 | + if ( $field ) { |
|
| 291 | + $type = $field->{$col}; |
|
| 292 | + } else { |
|
| 293 | + $type = FrmDb::get_var( 'frm_fields', array( 'or' => 1, 'id' => $id, 'field_key' => $id ), $col ); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + return $type; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | 299 | public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) { |
| 300 | - if ( ! $form_id ) { |
|
| 301 | - return array(); |
|
| 302 | - } |
|
| 300 | + if ( ! $form_id ) { |
|
| 301 | + return array(); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | 304 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_sub, 'inc_repeat' => $inc_sub ) ); |
| 305 | 305 | if ( ! empty( $results ) ) { |
| 306 | - $fields = array(); |
|
| 307 | - $count = 0; |
|
| 308 | - foreach ( $results as $result ) { |
|
| 309 | - if ( $type != $result->type ) { |
|
| 310 | - continue; |
|
| 311 | - } |
|
| 306 | + $fields = array(); |
|
| 307 | + $count = 0; |
|
| 308 | + foreach ( $results as $result ) { |
|
| 309 | + if ( $type != $result->type ) { |
|
| 310 | + continue; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | 313 | $fields[ $result->id ] = $result; |
| 314 | - $count++; |
|
| 315 | - if ( $limit == 1 ) { |
|
| 316 | - $fields = $result; |
|
| 317 | - break; |
|
| 318 | - } |
|
| 314 | + $count++; |
|
| 315 | + if ( $limit == 1 ) { |
|
| 316 | + $fields = $result; |
|
| 317 | + break; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 321 | - break; |
|
| 322 | - } |
|
| 320 | + if ( ! empty($limit) && $count >= $limit ) { |
|
| 321 | + break; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - unset($result); |
|
| 325 | - } |
|
| 326 | - return stripslashes_deep($fields); |
|
| 327 | - } |
|
| 324 | + unset($result); |
|
| 325 | + } |
|
| 326 | + return stripslashes_deep($fields); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - self::$use_cache = false; |
|
| 329 | + self::$use_cache = false; |
|
| 330 | 330 | |
| 331 | 331 | $where = array( 'fi.form_id' => (int) $form_id, 'fi.type' => $type ); |
| 332 | 332 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
| 333 | 333 | $results = self::getAll( $where, 'field_order', $limit ); |
| 334 | - self::$use_cache = true; |
|
| 335 | - self::include_sub_fields($results, $inc_sub, $type); |
|
| 334 | + self::$use_cache = true; |
|
| 335 | + self::include_sub_fields($results, $inc_sub, $type); |
|
| 336 | 336 | |
| 337 | - return $results; |
|
| 338 | - } |
|
| 337 | + return $results; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | 340 | public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) { |
| 341 | - if ( ! (int) $form_id ) { |
|
| 342 | - return array(); |
|
| 343 | - } |
|
| 341 | + if ( ! (int) $form_id ) { |
|
| 342 | + return array(); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
| 346 | 346 | if ( ! empty( $results ) ) { |
| 347 | - if ( empty($limit) ) { |
|
| 347 | + if ( empty($limit) ) { |
|
| 348 | 348 | return $results; |
| 349 | - } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - $fields = array(); |
|
| 352 | - $count = 0; |
|
| 353 | - foreach ( $results as $result ) { |
|
| 351 | + $fields = array(); |
|
| 352 | + $count = 0; |
|
| 353 | + foreach ( $results as $result ) { |
|
| 354 | 354 | $fields[ $result->id ] = $result; |
| 355 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 356 | - break; |
|
| 357 | - } |
|
| 358 | - } |
|
| 355 | + if ( ! empty($limit) && $count >= $limit ) { |
|
| 356 | + break; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | 360 | return $fields; |
| 361 | - } |
|
| 361 | + } |
|
| 362 | 362 | |
| 363 | - self::$use_cache = false; |
|
| 363 | + self::$use_cache = false; |
|
| 364 | 364 | |
| 365 | 365 | $where = array( 'fi.form_id' => absint( $form_id ) ); |
| 366 | 366 | self::maybe_include_repeating_fields( $inc_repeat, $where ); |
| 367 | 367 | $results = self::getAll( $where, 'field_order', $limit ); |
| 368 | 368 | |
| 369 | - self::$use_cache = true; |
|
| 369 | + self::$use_cache = true; |
|
| 370 | 370 | |
| 371 | 371 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
| 372 | 372 | |
| 373 | - if ( empty($limit) ) { |
|
| 373 | + if ( empty($limit) ) { |
|
| 374 | 374 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
| 375 | - } |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | 377 | return $results; |
| 378 | - } |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | 380 | /** |
| 381 | - * If repeating fields should be included, adjust $where accordingly |
|
| 382 | - * |
|
| 383 | - * @param string $inc_repeat |
|
| 384 | - * @param array $where - pass by reference |
|
| 385 | - */ |
|
| 381 | + * If repeating fields should be included, adjust $where accordingly |
|
| 382 | + * |
|
| 383 | + * @param string $inc_repeat |
|
| 384 | + * @param array $where - pass by reference |
|
| 385 | + */ |
|
| 386 | 386 | private static function maybe_include_repeating_fields( $inc_repeat, &$where ) { |
| 387 | 387 | if ( $inc_repeat == 'include' ) { |
| 388 | 388 | $form_id = $where['fi.form_id']; |
@@ -393,77 +393,77 @@ discard block |
||
| 393 | 393 | |
| 394 | 394 | public static function include_sub_fields( &$results, $inc_embed, $type = 'all' ) { |
| 395 | 395 | if ( 'include' != $inc_embed || empty( $results ) ) { |
| 396 | - return; |
|
| 397 | - } |
|
| 396 | + return; |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - $form_fields = $results; |
|
| 399 | + $form_fields = $results; |
|
| 400 | 400 | $index_offset = 1; |
| 401 | - foreach ( $form_fields as $k => $field ) { |
|
| 402 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
| 403 | - continue; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - if ( $type == 'all' ) { |
|
| 407 | - $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 408 | - } else { |
|
| 409 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - if ( ! empty($sub_fields) ) { |
|
| 401 | + foreach ( $form_fields as $k => $field ) { |
|
| 402 | + if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + if ( $type == 'all' ) { |
|
| 407 | + $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
|
| 408 | + } else { |
|
| 409 | + $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + if ( ! empty($sub_fields) ) { |
|
| 413 | 413 | $index = $k + $index_offset; |
| 414 | 414 | $index_offset += count( $sub_fields ); |
| 415 | 415 | array_splice($results, $index, 0, $sub_fields); |
| 416 | - } |
|
| 417 | - unset($field, $sub_fields); |
|
| 418 | - } |
|
| 419 | - } |
|
| 416 | + } |
|
| 417 | + unset($field, $sub_fields); |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | 421 | public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) { |
| 422 | 422 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
| 423 | - if ( self::$use_cache ) { |
|
| 424 | - // make sure old cache doesn't get saved as a transient |
|
| 425 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
| 426 | - if ( false !== $results ) { |
|
| 427 | - return stripslashes_deep($results); |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - global $wpdb; |
|
| 432 | - |
|
| 433 | - if ( $blog_id && is_multisite() ) { |
|
| 434 | - global $wpmuBaseTablePrefix; |
|
| 435 | - if ( $wpmuBaseTablePrefix ) { |
|
| 423 | + if ( self::$use_cache ) { |
|
| 424 | + // make sure old cache doesn't get saved as a transient |
|
| 425 | + $results = wp_cache_get($cache_key, 'frm_field'); |
|
| 426 | + if ( false !== $results ) { |
|
| 427 | + return stripslashes_deep($results); |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + global $wpdb; |
|
| 432 | + |
|
| 433 | + if ( $blog_id && is_multisite() ) { |
|
| 434 | + global $wpmuBaseTablePrefix; |
|
| 435 | + if ( $wpmuBaseTablePrefix ) { |
|
| 436 | 436 | $prefix = $wpmuBaseTablePrefix . $blog_id . '_'; |
| 437 | - } else { |
|
| 438 | - $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 439 | - } |
|
| 437 | + } else { |
|
| 438 | + $prefix = $wpdb->get_blog_prefix( $blog_id ); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | 441 | $table_name = $prefix . 'frm_fields'; |
| 442 | 442 | $form_table_name = $prefix . 'frm_forms'; |
| 443 | 443 | } else { |
| 444 | 444 | $table_name = $wpdb->prefix . 'frm_fields'; |
| 445 | 445 | $form_table_name = $wpdb->prefix . 'frm_forms'; |
| 446 | - } |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | 448 | if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) { |
| 449 | 449 | $order_by = ' ORDER BY ' . $order_by; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 452 | + $limit = FrmAppHelper::esc_limit($limit); |
|
| 453 | 453 | |
| 454 | - $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 455 | - $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 454 | + $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
|
| 455 | + $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
|
| 456 | 456 | |
| 457 | - if ( is_array($where) ) { |
|
| 458 | - $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
| 457 | + if ( is_array($where) ) { |
|
| 458 | + $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
|
| 459 | 459 | } else { |
| 460 | 460 | // if the query is not an array, then it has already been prepared |
| 461 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 461 | + $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 462 | 462 | |
| 463 | 463 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
| 464 | 464 | $results = $wpdb->$function_name( $query ); |
| 465 | - } |
|
| 466 | - unset( $where ); |
|
| 465 | + } |
|
| 466 | + unset( $where ); |
|
| 467 | 467 | |
| 468 | 468 | self::format_field_results( $results ); |
| 469 | 469 | |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | - * @since 2.0.09 |
|
| 705 | - */ |
|
| 704 | + * @since 2.0.09 |
|
| 705 | + */ |
|
| 706 | 706 | public static function is_repeating_field( $field ) { |
| 707 | 707 | if ( is_array( $field ) ) { |
| 708 | 708 | $is_repeating_field = ( 'divider' == $field['type'] ); |
@@ -712,14 +712,14 @@ discard block |
||
| 712 | 712 | return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) ); |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | - /** |
|
| 716 | - * @param string $key |
|
| 717 | - * @return int field id |
|
| 718 | - */ |
|
| 715 | + /** |
|
| 716 | + * @param string $key |
|
| 717 | + * @return int field id |
|
| 718 | + */ |
|
| 719 | 719 | public static function get_id_by_key( $key ) { |
| 720 | - $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 721 | - return $id; |
|
| 722 | - } |
|
| 720 | + $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) ); |
|
| 721 | + return $id; |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | 724 | /** |
| 725 | 725 | * @param string $id |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | static $transient_size = 200; |
| 10 | 10 | |
| 11 | 11 | public static function field_selection() { |
| 12 | - $fields = apply_filters('frm_available_fields', array( |
|
| 12 | + $fields = apply_filters( 'frm_available_fields', array( |
|
| 13 | 13 | 'text' => __( 'Single Line Text', 'formidable' ), |
| 14 | 14 | 'textarea' => __( 'Paragraph Text', 'formidable' ), |
| 15 | 15 | 'checkbox' => __( 'Checkboxes', 'formidable' ), |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | 'email' => __( 'Email Address', 'formidable' ), |
| 19 | 19 | 'url' => __( 'Website/URL', 'formidable' ), |
| 20 | 20 | 'captcha' => __( 'reCAPTCHA', 'formidable' ), |
| 21 | - )); |
|
| 21 | + ) ); |
|
| 22 | 22 | |
| 23 | 23 | return $fields; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function pro_field_selection() { |
| 27 | - return apply_filters('frm_pro_available_fields', array( |
|
| 27 | + return apply_filters( 'frm_pro_available_fields', array( |
|
| 28 | 28 | 'end_divider' => array( |
| 29 | 29 | 'name' => __( 'End Section', 'formidable' ), |
| 30 | 30 | 'switch_from' => 'divider', |
@@ -49,36 +49,36 @@ discard block |
||
| 49 | 49 | 'tag' => __( 'Tags', 'formidable' ), |
| 50 | 50 | 'credit_card' => __( 'Credit Card', 'formidable' ), |
| 51 | 51 | 'address' => __( 'Address', 'formidable' ), |
| 52 | - )); |
|
| 52 | + ) ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public static function create( $values, $return = true ) { |
| 56 | 56 | global $wpdb, $frm_duplicate_ids; |
| 57 | 57 | |
| 58 | 58 | $new_values = array(); |
| 59 | - $key = isset($values['field_key']) ? $values['field_key'] : $values['name']; |
|
| 59 | + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name']; |
|
| 60 | 60 | $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 61 | 61 | |
| 62 | 62 | foreach ( array( 'name', 'description', 'type', 'default_value' ) as $col ) { |
| 63 | - $new_values[ $col ] = $values[ $col ]; |
|
| 63 | + $new_values[$col] = $values[$col]; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $new_values['options'] = $values['options']; |
| 67 | 67 | |
| 68 | - $new_values['field_order'] = isset($values['field_order']) ? (int) $values['field_order'] : null; |
|
| 69 | - $new_values['required'] = isset($values['required']) ? (int) $values['required'] : 0; |
|
| 70 | - $new_values['form_id'] = isset($values['form_id']) ? (int) $values['form_id'] : null; |
|
| 68 | + $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
|
| 69 | + $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
|
| 70 | + $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
|
| 71 | 71 | $new_values['field_options'] = $values['field_options']; |
| 72 | - $new_values['created_at'] = current_time('mysql', 1); |
|
| 72 | + $new_values['created_at'] = current_time( 'mysql', 1 ); |
|
| 73 | 73 | |
| 74 | 74 | if ( isset( $values['id'] ) ) { |
| 75 | - $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
|
| 76 | - $new_values = apply_filters('frm_duplicated_field', $new_values); |
|
| 75 | + $frm_duplicate_ids[$values['field_key']] = $new_values['field_key']; |
|
| 76 | + $new_values = apply_filters( 'frm_duplicated_field', $new_values ); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | foreach ( $new_values as $k => $v ) { |
| 80 | 80 | if ( is_array( $v ) ) { |
| 81 | - $new_values[ $k ] = serialize( $v ); |
|
| 81 | + $new_values[$k] = serialize( $v ); |
|
| 82 | 82 | } |
| 83 | 83 | unset( $k, $v ); |
| 84 | 84 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | if ( $query_results ) { |
| 101 | 101 | if ( isset( $values['id'] ) ) { |
| 102 | - $frm_duplicate_ids[ $values['id'] ] = $new_id; |
|
| 102 | + $frm_duplicate_ids[$values['id']] = $new_id; |
|
| 103 | 103 | } |
| 104 | 104 | return $new_id; |
| 105 | 105 | } else { |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $fields = self::getAll( $where, 'field_order', '', $blog_id ); |
| 115 | 115 | |
| 116 | 116 | foreach ( (array) $fields as $field ) { |
| 117 | - $new_key = ($copy_keys) ? $field->field_key : ''; |
|
| 118 | - if ( $copy_keys && substr($field->field_key, -1) == 2 ) { |
|
| 119 | - $new_key = rtrim($new_key, 2); |
|
| 117 | + $new_key = ( $copy_keys ) ? $field->field_key : ''; |
|
| 118 | + if ( $copy_keys && substr( $field->field_key, -1 ) == 2 ) { |
|
| 119 | + $new_key = rtrim( $new_key, 2 ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | $values = array(); |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $values['form_id'] = $new_repeat_form_id; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - $values = apply_filters('frm_duplicated_field', $values); |
|
| 143 | - $new_id = self::create($values); |
|
| 144 | - $frm_duplicate_ids[ $field->id ] = $new_id; |
|
| 145 | - $frm_duplicate_ids[ $field->field_key ] = $new_id; |
|
| 146 | - unset($field); |
|
| 142 | + $values = apply_filters( 'frm_duplicated_field', $values ); |
|
| 143 | + $new_id = self::create( $values ); |
|
| 144 | + $frm_duplicate_ids[$field->id] = $new_id; |
|
| 145 | + $frm_duplicate_ids[$field->field_key] = $new_id; |
|
| 146 | + unset( $field ); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $values['field_key'] = FrmAppHelper::get_unique_key( $values['field_key'], $wpdb->prefix . 'frm_fields', 'field_key', $id ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( isset($values['required']) ) { |
|
| 159 | + if ( isset( $values['required'] ) ) { |
|
| 160 | 160 | $values['required'] = (int) $values['required']; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | // serialize array values |
| 170 | 170 | foreach ( array( 'default_value', 'field_options', 'options' ) as $opt ) { |
| 171 | - if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) { |
|
| 172 | - $values[ $opt ] = serialize( $values[ $opt ] ); |
|
| 171 | + if ( isset( $values[$opt] ) && is_array( $values[$opt] ) ) { |
|
| 172 | + $values[$opt] = serialize( $values[$opt] ); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | if ( isset( $values['form_id'] ) ) { |
| 180 | 180 | $form_id = absint( $values['form_id'] ); |
| 181 | 181 | } else { |
| 182 | - $field = self::getOne($id); |
|
| 182 | + $field = self::getOne( $id ); |
|
| 183 | 183 | if ( $field ) { |
| 184 | 184 | $form_id = $field->form_id; |
| 185 | 185 | } |
| 186 | - unset($field); |
|
| 186 | + unset( $field ); |
|
| 187 | 187 | } |
| 188 | - unset($values); |
|
| 188 | + unset( $values ); |
|
| 189 | 189 | |
| 190 | 190 | if ( $query_results ) { |
| 191 | 191 | wp_cache_delete( $id, 'frm_field' ); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | FrmAppHelper::cache_delete_group( 'frm_field' ); |
| 240 | 240 | |
| 241 | - $form = FrmForm::getOne($form_id); |
|
| 241 | + $form = FrmForm::getOne( $form_id ); |
|
| 242 | 242 | if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) { |
| 243 | 243 | self::delete_form_transient( $form->parent_form_id ); |
| 244 | 244 | } |
@@ -260,16 +260,16 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | global $wpdb; |
| 262 | 262 | |
| 263 | - $where = is_numeric($id) ? 'id=%d' : 'field_key=%s'; |
|
| 263 | + $where = is_numeric( $id ) ? 'id=%d' : 'field_key=%s'; |
|
| 264 | 264 | $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); |
| 265 | 265 | |
| 266 | 266 | $results = FrmAppHelper::check_cache( $id, 'frm_field', $query, 'get_row', 0 ); |
| 267 | 267 | |
| 268 | - if ( empty($results) ) { |
|
| 268 | + if ( empty( $results ) ) { |
|
| 269 | 269 | return $results; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( is_numeric($id) ) { |
|
| 272 | + if ( is_numeric( $id ) ) { |
|
| 273 | 273 | FrmAppHelper::set_cache( $results->field_key, $results, 'frm_field' ); |
| 274 | 274 | } else if ( $results ) { |
| 275 | 275 | FrmAppHelper::set_cache( $results->id, $results, 'frm_field' ); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | self::prepare_options( $results ); |
| 279 | 279 | |
| 280 | - return stripslashes_deep($results); |
|
| 280 | + return stripslashes_deep( $results ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -310,20 +310,20 @@ discard block |
||
| 310 | 310 | continue; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $fields[ $result->id ] = $result; |
|
| 314 | - $count++; |
|
| 313 | + $fields[$result->id] = $result; |
|
| 314 | + $count ++; |
|
| 315 | 315 | if ( $limit == 1 ) { |
| 316 | 316 | $fields = $result; |
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 320 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
| 321 | 321 | break; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - unset($result); |
|
| 324 | + unset( $result ); |
|
| 325 | 325 | } |
| 326 | - return stripslashes_deep($fields); |
|
| 326 | + return stripslashes_deep( $fields ); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | self::$use_cache = false; |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | self::maybe_include_repeating_fields( $inc_sub, $where ); |
| 333 | 333 | $results = self::getAll( $where, 'field_order', $limit ); |
| 334 | 334 | self::$use_cache = true; |
| 335 | - self::include_sub_fields($results, $inc_sub, $type); |
|
| 335 | + self::include_sub_fields( $results, $inc_sub, $type ); |
|
| 336 | 336 | |
| 337 | 337 | return $results; |
| 338 | 338 | } |
@@ -344,15 +344,15 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | $results = self::get_fields_from_transients( $form_id, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
| 346 | 346 | if ( ! empty( $results ) ) { |
| 347 | - if ( empty($limit) ) { |
|
| 347 | + if ( empty( $limit ) ) { |
|
| 348 | 348 | return $results; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | $fields = array(); |
| 352 | 352 | $count = 0; |
| 353 | 353 | foreach ( $results as $result ) { |
| 354 | - $fields[ $result->id ] = $result; |
|
| 355 | - if ( ! empty($limit) && $count >= $limit ) { |
|
| 354 | + $fields[$result->id] = $result; |
|
| 355 | + if ( ! empty( $limit ) && $count >= $limit ) { |
|
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | self::include_sub_fields( $results, $inc_embed, 'all' ); |
| 372 | 372 | |
| 373 | - if ( empty($limit) ) { |
|
| 373 | + if ( empty( $limit ) ) { |
|
| 374 | 374 | self::set_field_transient( $results, $form_id, 0, array( 'inc_embed' => $inc_embed, 'inc_repeat' => $inc_repeat ) ); |
| 375 | 375 | } |
| 376 | 376 | |
@@ -399,22 +399,22 @@ discard block |
||
| 399 | 399 | $form_fields = $results; |
| 400 | 400 | $index_offset = 1; |
| 401 | 401 | foreach ( $form_fields as $k => $field ) { |
| 402 | - if ( 'form' != $field->type || ! isset($field->field_options['form_select']) ) { |
|
| 402 | + if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) { |
|
| 403 | 403 | continue; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | if ( $type == 'all' ) { |
| 407 | 407 | $sub_fields = self::get_all_for_form( $field->field_options['form_select'] ); |
| 408 | 408 | } else { |
| 409 | - $sub_fields = self::get_all_types_in_form($field->form_id, $type); |
|
| 409 | + $sub_fields = self::get_all_types_in_form( $field->form_id, $type ); |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - if ( ! empty($sub_fields) ) { |
|
| 412 | + if ( ! empty( $sub_fields ) ) { |
|
| 413 | 413 | $index = $k + $index_offset; |
| 414 | 414 | $index_offset += count( $sub_fields ); |
| 415 | - array_splice($results, $index, 0, $sub_fields); |
|
| 415 | + array_splice( $results, $index, 0, $sub_fields ); |
|
| 416 | 416 | } |
| 417 | - unset($field, $sub_fields); |
|
| 417 | + unset( $field, $sub_fields ); |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
@@ -422,9 +422,9 @@ discard block |
||
| 422 | 422 | $cache_key = maybe_serialize( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id; |
| 423 | 423 | if ( self::$use_cache ) { |
| 424 | 424 | // make sure old cache doesn't get saved as a transient |
| 425 | - $results = wp_cache_get($cache_key, 'frm_field'); |
|
| 425 | + $results = wp_cache_get( $cache_key, 'frm_field' ); |
|
| 426 | 426 | if ( false !== $results ) { |
| 427 | - return stripslashes_deep($results); |
|
| 427 | + return stripslashes_deep( $results ); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
@@ -449,16 +449,16 @@ discard block |
||
| 449 | 449 | $order_by = ' ORDER BY ' . $order_by; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 452 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
| 453 | 453 | |
| 454 | 454 | $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi LEFT OUTER JOIN {$form_table_name} fr ON fi.form_id=fr.id"; |
| 455 | 455 | $query_type = ( $limit == ' LIMIT 1' || $limit == 1 ) ? 'row' : 'results'; |
| 456 | 456 | |
| 457 | - if ( is_array($where) ) { |
|
| 457 | + if ( is_array( $where ) ) { |
|
| 458 | 458 | $results = FrmDb::get_var( $table_name . ' fi LEFT OUTER JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', array( 'order_by' => $order_by, 'limit' => $limit ), '', $query_type ); |
| 459 | 459 | } else { |
| 460 | 460 | // if the query is not an array, then it has already been prepared |
| 461 | - $query .= FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 461 | + $query .= FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 462 | 462 | |
| 463 | 463 | $function_name = ( $query_type == 'row' ) ? 'get_row' : 'get_results'; |
| 464 | 464 | $results = $wpdb->$function_name( $query ); |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | FrmAppHelper::set_cache( $result->id, $result, 'frm_field' ); |
| 482 | 482 | FrmAppHelper::set_cache( $result->field_key, $result, 'frm_field' ); |
| 483 | 483 | |
| 484 | - $results[ $r_key ]->field_options = maybe_unserialize( $result->field_options ); |
|
| 485 | - $results[ $r_key ]->options = maybe_unserialize( $result->options ); |
|
| 486 | - $results[ $r_key ]->default_value = maybe_unserialize( $result->default_value ); |
|
| 484 | + $results[$r_key]->field_options = maybe_unserialize( $result->field_options ); |
|
| 485 | + $results[$r_key]->options = maybe_unserialize( $result->options ); |
|
| 486 | + $results[$r_key]->default_value = maybe_unserialize( $result->default_value ); |
|
| 487 | 487 | |
| 488 | 488 | unset( $r_key, $result ); |
| 489 | 489 | } |
@@ -502,8 +502,8 @@ discard block |
||
| 502 | 502 | private static function prepare_options( &$results ) { |
| 503 | 503 | $results->field_options = maybe_unserialize( $results->field_options ); |
| 504 | 504 | |
| 505 | - $results->options = maybe_unserialize($results->options); |
|
| 506 | - $results->default_value = maybe_unserialize($results->default_value); |
|
| 505 | + $results->options = maybe_unserialize( $results->options ); |
|
| 506 | + $results->default_value = maybe_unserialize( $results->default_value ); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | if ( count( $next_fields ) >= self::$transient_size ) { |
| 532 | 532 | // if this transient is full, check for another |
| 533 | - $next++; |
|
| 533 | + $next ++; |
|
| 534 | 534 | self::get_next_transient( $fields, $base_name, $next ); |
| 535 | 535 | } |
| 536 | 536 | } |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | return; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $next++; |
|
| 559 | + $next ++; |
|
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
@@ -586,8 +586,8 @@ discard block |
||
| 586 | 586 | $is_multi_value_field = ( |
| 587 | 587 | $field['type'] == 'checkbox' || |
| 588 | 588 | $field['type'] == 'address' || |
| 589 | - ( $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
| 590 | - ( $field['type'] == 'lookup' && isset($field['data_type']) && $field['data_type'] == 'checkbox' ) || |
|
| 589 | + ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
| 590 | + ( $field['type'] == 'lookup' && isset( $field['data_type'] ) && $field['data_type'] == 'checkbox' ) || |
|
| 591 | 591 | self::is_multiple_select( $field ) |
| 592 | 592 | ); |
| 593 | 593 | |
@@ -612,9 +612,9 @@ discard block |
||
| 612 | 612 | */ |
| 613 | 613 | public static function is_multiple_select( $field ) { |
| 614 | 614 | if ( is_array( $field ) ) { |
| 615 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select') ) ); |
|
| 615 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field['type'] == 'select' || ( $field['type'] == 'data' && isset( $field['data_type'] ) && $field['data_type'] == 'select' ) ) ); |
|
| 616 | 616 | } else { |
| 617 | - return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset($field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select') ) ); |
|
| 617 | + return self::is_option_true( $field, 'multiple' ) && ( ( $field->type == 'select' || ( $field->type == 'data' && isset( $field->field_options['data_type'] ) && $field->field_options['data_type'] == 'select' ) ) ); |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | |
@@ -661,23 +661,23 @@ discard block |
||
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | public static function is_option_true_in_array( $field, $option ) { |
| 664 | - return isset( $field[ $option ] ) && $field[ $option ]; |
|
| 664 | + return isset( $field[$option] ) && $field[$option]; |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | public static function is_option_true_in_object( $field, $option ) { |
| 668 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ]; |
|
| 668 | + return isset( $field->field_options[$option] ) && $field->field_options[$option]; |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | public static function is_option_empty_in_array( $field, $option ) { |
| 672 | - return ! isset( $field[ $option ] ) || empty( $field[ $option ] ); |
|
| 672 | + return ! isset( $field[$option] ) || empty( $field[$option] ); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | public static function is_option_empty_in_object( $field, $option ) { |
| 676 | - return ! isset( $field->field_options[ $option ] ) || empty( $field->field_options[ $option ] ); |
|
| 676 | + return ! isset( $field->field_options[$option] ) || empty( $field->field_options[$option] ); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | public static function is_option_value_in_object( $field, $option ) { |
| 680 | - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != ''; |
|
| 680 | + return isset( $field->field_options[$option] ) && $field->field_options[$option] != ''; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -693,11 +693,11 @@ discard block |
||
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | public static function get_option_in_array( $field, $option ) { |
| 696 | - return $field[ $option ]; |
|
| 696 | + return $field[$option]; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | public static function get_option_in_object( $field, $option ) { |
| 700 | - return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : ''; |
|
| 700 | + return isset( $field->field_options[$option] ) ? $field->field_options[$option] : ''; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -1,11 +1,11 @@ |
||
| 1 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($values); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>> |
|
| 1 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $values ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container" <?php echo apply_filters( 'frm_form_attributes', '', $form ); ?>> |
|
| 2 | 2 | <?php |
| 3 | 3 | if ( ! isset( $include_form_tag ) || $include_form_tag ) { |
| 4 | 4 | ?> |
| 5 | -<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?>> |
|
| 5 | +<form enctype="<?php echo esc_attr( apply_filters( 'frm_form_enctype', 'multipart/form-data', $form ) ) ?>" method="post" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" id="form_<?php echo esc_attr( $form->form_key ) ?>" <?php echo $frm_settings->use_html ? '' : 'action=""'; ?>> |
|
| 6 | 6 | <?php |
| 7 | 7 | } else { ?> |
| 8 | -<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action('frm_form_classes', $form) ?>" > |
|
| 8 | +<div id="form_<?php echo esc_attr( $form->form_key ) ?>" class="frm-show-form <?php do_action( 'frm_form_classes', $form ) ?>" > |
|
| 9 | 9 | <?php |
| 10 | 10 | } |
| 11 | 11 | |
@@ -23,30 +23,30 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function import_xml( $file ) { |
| 26 | - $defaults = array( |
|
| 27 | - 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
| 28 | - 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
| 29 | - 'styles' => 0, |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - $imported = array( |
|
| 33 | - 'imported' => $defaults, |
|
| 26 | + $defaults = array( |
|
| 27 | + 'forms' => 0, 'fields' => 0, 'terms' => 0, |
|
| 28 | + 'posts' => 0, 'views' => 0, 'actions' => 0, |
|
| 29 | + 'styles' => 0, |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + $imported = array( |
|
| 33 | + 'imported' => $defaults, |
|
| 34 | 34 | 'updated' => $defaults, |
| 35 | 35 | 'forms' => array(), |
| 36 | 36 | 'terms' => array(), |
| 37 | - ); |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - unset($defaults); |
|
| 39 | + unset($defaults); |
|
| 40 | 40 | |
| 41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 42 | - define('WP_IMPORTING', true); |
|
| 43 | - } |
|
| 42 | + define('WP_IMPORTING', true); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
| 46 | - return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 47 | - } |
|
| 46 | + return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $dom = new DOMDocument; |
|
| 49 | + $dom = new DOMDocument; |
|
| 50 | 50 | $success = $dom->loadXML( file_get_contents( $file ) ); |
| 51 | 51 | if ( ! $success ) { |
| 52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
@@ -64,45 +64,45 @@ discard block |
||
| 64 | 64 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 67 | + // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
|
| 68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 69 | - // grab cats, tags, and terms, or forms or posts |
|
| 70 | - if ( isset($xml->{$item_type} ) ) { |
|
| 69 | + // grab cats, tags, and terms, or forms or posts |
|
| 70 | + if ( isset($xml->{$item_type} ) ) { |
|
| 71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
| 72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 73 | 73 | unset( $function_name, $xml->{$item_type} ); |
| 74 | - } |
|
| 75 | - } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 77 | + $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 78 | 78 | |
| 79 | - return $return; |
|
| 80 | - } |
|
| 79 | + return $return; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | public static function import_xml_terms( $terms, $imported ) { |
| 83 | - foreach ( $terms as $t ) { |
|
| 83 | + foreach ( $terms as $t ) { |
|
| 84 | 84 | if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) { |
| 85 | - continue; |
|
| 85 | + continue; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $parent = self::get_term_parent_id( $t ); |
| 89 | 89 | |
| 90 | 90 | $term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array( |
| 91 | - 'slug' => (string) $t->term_slug, |
|
| 92 | - 'description' => (string) $t->term_description, |
|
| 91 | + 'slug' => (string) $t->term_slug, |
|
| 92 | + 'description' => (string) $t->term_description, |
|
| 93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
| 94 | - )); |
|
| 94 | + )); |
|
| 95 | 95 | |
| 96 | 96 | if ( $term && is_array( $term ) ) { |
| 97 | - $imported['imported']['terms']++; |
|
| 97 | + $imported['imported']['terms']++; |
|
| 98 | 98 | $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | unset( $term, $t ); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return $imported; |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @since 2.0.8 |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | self::put_child_forms_first( $forms ); |
| 128 | 128 | |
| 129 | 129 | foreach ( $forms as $item ) { |
| 130 | - $form = self::fill_form( $item ); |
|
| 130 | + $form = self::fill_form( $item ); |
|
| 131 | 131 | |
| 132 | 132 | self::update_custom_style_setting_on_import( $form ); |
| 133 | 133 | |
| 134 | - $this_form = self::maybe_get_form( $form ); |
|
| 134 | + $this_form = self::maybe_get_form( $form ); |
|
| 135 | 135 | |
| 136 | 136 | $old_id = false; |
| 137 | 137 | $form_fields = false; |
@@ -143,35 +143,35 @@ discard block |
||
| 143 | 143 | $form_fields = self::get_form_fields( $form_id ); |
| 144 | 144 | } else { |
| 145 | 145 | $form_id = FrmForm::create( $form ); |
| 146 | - if ( $form_id ) { |
|
| 147 | - $imported['imported']['forms']++; |
|
| 148 | - // Keep track of whether this specific form was updated or not |
|
| 146 | + if ( $form_id ) { |
|
| 147 | + $imported['imported']['forms']++; |
|
| 148 | + // Keep track of whether this specific form was updated or not |
|
| 149 | 149 | $imported['form_status'][ $form_id ] = 'imported'; |
| 150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 151 | - } |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported ); |
| 155 | 155 | |
| 156 | 156 | self::delete_removed_fields( $form_fields ); |
| 157 | 157 | |
| 158 | - // Update field ids/keys to new ones |
|
| 158 | + // Update field ids/keys to new ones |
|
| 159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 160 | 160 | |
| 161 | 161 | $imported['forms'][ (int) $item->id ] = $form_id; |
| 162 | 162 | |
| 163 | - // Send pre 2.0 form options through function that creates actions |
|
| 164 | - self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 163 | + // Send pre 2.0 form options through function that creates actions |
|
| 164 | + self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
|
| 165 | 165 | |
| 166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 167 | 167 | |
| 168 | - unset($form, $item); |
|
| 168 | + unset($form, $item); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
| 172 | 172 | |
| 173 | 173 | return $imported; |
| 174 | - } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | 176 | private static function fill_form( $item ) { |
| 177 | 177 | $form = array( |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | - * Put child forms first so they will be imported before parents |
|
| 243 | - * |
|
| 244 | - * @since 2.0.16 |
|
| 245 | - * @param array $forms |
|
| 246 | - */ |
|
| 242 | + * Put child forms first so they will be imported before parents |
|
| 243 | + * |
|
| 244 | + * @since 2.0.16 |
|
| 245 | + * @param array $forms |
|
| 246 | + */ |
|
| 247 | 247 | private static function put_child_forms_first( &$forms ) { |
| 248 | 248 | $child_forms = array(); |
| 249 | 249 | $regular_forms = array(); |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | - * Keep track of all imported child forms |
|
| 266 | - * |
|
| 267 | - * @since 2.0.16 |
|
| 268 | - * @param int $form_id |
|
| 269 | - * @param int $parent_form_id |
|
| 270 | - * @param array $child_forms |
|
| 271 | - */ |
|
| 265 | + * Keep track of all imported child forms |
|
| 266 | + * |
|
| 267 | + * @since 2.0.16 |
|
| 268 | + * @param int $form_id |
|
| 269 | + * @param int $parent_form_id |
|
| 270 | + * @param array $child_forms |
|
| 271 | + */ |
|
| 272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 273 | 273 | if ( $parent_form_id ) { |
| 274 | 274 | $child_forms[ $form_id ] = $parent_form_id; |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
| 279 | - * Update the parent_form_id on imported child forms |
|
| 280 | - * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 281 | - * |
|
| 282 | - * @since 2.0.6 |
|
| 283 | - * @param array $imported_forms |
|
| 284 | - * @param array $child_forms |
|
| 285 | - */ |
|
| 279 | + * Update the parent_form_id on imported child forms |
|
| 280 | + * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported |
|
| 281 | + * |
|
| 282 | + * @since 2.0.6 |
|
| 283 | + * @param array $imported_forms |
|
| 284 | + * @param array $child_forms |
|
| 285 | + */ |
|
| 286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 288 | 288 | |
@@ -296,28 +296,28 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
| 299 | - * Import all fields for a form |
|
| 300 | - * @since 2.0.13 |
|
| 301 | - * |
|
| 302 | - * TODO: Cut down on params |
|
| 303 | - */ |
|
| 299 | + * Import all fields for a form |
|
| 300 | + * @since 2.0.13 |
|
| 301 | + * |
|
| 302 | + * TODO: Cut down on params |
|
| 303 | + */ |
|
| 304 | 304 | private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) { |
| 305 | 305 | $in_section = 0; |
| 306 | 306 | |
| 307 | 307 | foreach ( $xml_fields as $field ) { |
| 308 | 308 | $f = self::fill_field( $field, $form_id ); |
| 309 | 309 | |
| 310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
| 311 | - 'text', 'email', 'url', 'textarea', |
|
| 312 | - 'number','phone', 'date', 'time', |
|
| 313 | - 'hidden', 'password', 'tag', 'image', |
|
| 314 | - )) ) { |
|
| 315 | - if ( count($f['default_value']) === 1 ) { |
|
| 310 | + if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
| 311 | + 'text', 'email', 'url', 'textarea', |
|
| 312 | + 'number','phone', 'date', 'time', |
|
| 313 | + 'hidden', 'password', 'tag', 'image', |
|
| 314 | + )) ) { |
|
| 315 | + if ( count($f['default_value']) === 1 ) { |
|
| 316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
| 317 | - } else { |
|
| 318 | - $f['default_value'] = reset($f['default_value']); |
|
| 319 | - } |
|
| 320 | - } |
|
| 317 | + } else { |
|
| 318 | + $f['default_value'] = reset($f['default_value']); |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | 322 | self::maybe_update_in_section_variable( $in_section, $f ); |
| 323 | 323 | self::maybe_update_form_select( $f, $imported ); |
@@ -396,12 +396,12 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | - * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 400 | - * |
|
| 401 | - * @since 2.0.16 |
|
| 402 | - * @param array $f |
|
| 403 | - * @param array $imported |
|
| 404 | - */ |
|
| 399 | + * Switch the form_select on a repeating field or embedded form if it needs to be switched |
|
| 400 | + * |
|
| 401 | + * @since 2.0.16 |
|
| 402 | + * @param array $f |
|
| 403 | + * @param array $imported |
|
| 404 | + */ |
|
| 405 | 405 | private static function maybe_update_form_select( &$f, $imported ) { |
| 406 | 406 | if ( ! isset( $imported['forms'] ) ) { |
| 407 | 407 | return; |
@@ -453,13 +453,13 @@ discard block |
||
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /** |
| 456 | - * Updates the custom style setting on import |
|
| 457 | - * Convert the post slug to an ID |
|
| 458 | - * |
|
| 459 | - * @since 2.0.19 |
|
| 460 | - * @param array $form |
|
| 461 | - * |
|
| 462 | - */ |
|
| 456 | + * Updates the custom style setting on import |
|
| 457 | + * Convert the post slug to an ID |
|
| 458 | + * |
|
| 459 | + * @since 2.0.19 |
|
| 460 | + * @param array $form |
|
| 461 | + * |
|
| 462 | + */ |
|
| 463 | 463 | private static function update_custom_style_setting_on_import( &$form ) { |
| 464 | 464 | if ( ! isset( $form['options']['custom_style'] ) ) { |
| 465 | 465 | return; |
@@ -513,16 +513,16 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | public static function import_xml_views( $views, $imported ) { |
| 516 | - $imported['posts'] = array(); |
|
| 517 | - $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 516 | + $imported['posts'] = array(); |
|
| 517 | + $form_action_type = FrmFormActionsController::$action_post_type; |
|
| 518 | 518 | |
| 519 | - $post_types = array( |
|
| 520 | - 'frm_display' => 'views', |
|
| 521 | - $form_action_type => 'actions', |
|
| 522 | - 'frm_styles' => 'styles', |
|
| 523 | - ); |
|
| 519 | + $post_types = array( |
|
| 520 | + 'frm_display' => 'views', |
|
| 521 | + $form_action_type => 'actions', |
|
| 522 | + 'frm_styles' => 'styles', |
|
| 523 | + ); |
|
| 524 | 524 | |
| 525 | - foreach ( $views as $item ) { |
|
| 525 | + foreach ( $views as $item ) { |
|
| 526 | 526 | $post = array( |
| 527 | 527 | 'post_title' => (string) $item->title, |
| 528 | 528 | 'post_name' => (string) $item->post_name, |
@@ -541,52 +541,52 @@ discard block |
||
| 541 | 541 | 'post_date' => (string) $item->post_date, |
| 542 | 542 | 'post_date_gmt' => (string) $item->post_date_gmt, |
| 543 | 543 | 'ping_status' => (string) $item->ping_status, |
| 544 | - 'postmeta' => array(), |
|
| 545 | - 'tax_input' => array(), |
|
| 544 | + 'postmeta' => array(), |
|
| 545 | + 'tax_input' => array(), |
|
| 546 | 546 | ); |
| 547 | 547 | |
| 548 | - $old_id = $post['post_id']; |
|
| 549 | - self::populate_post($post, $item, $imported); |
|
| 548 | + $old_id = $post['post_id']; |
|
| 549 | + self::populate_post($post, $item, $imported); |
|
| 550 | 550 | |
| 551 | 551 | unset($item); |
| 552 | 552 | |
| 553 | 553 | $post_id = false; |
| 554 | - if ( $post['post_type'] == $form_action_type ) { |
|
| 555 | - $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 554 | + if ( $post['post_type'] == $form_action_type ) { |
|
| 555 | + $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] ); |
|
| 556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
| 557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 558 | 558 | } |
| 559 | - unset($action_control); |
|
| 560 | - } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 561 | - // Properly encode post content before inserting the post |
|
| 562 | - $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 559 | + unset($action_control); |
|
| 560 | + } else if ( $post['post_type'] == 'frm_styles' ) { |
|
| 561 | + // Properly encode post content before inserting the post |
|
| 562 | + $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
|
| 563 | 563 | $custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : ''; |
| 564 | - $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 564 | + $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] ); |
|
| 565 | 565 | |
| 566 | - // Create/update post now |
|
| 567 | - $post_id = wp_insert_post( $post ); |
|
| 566 | + // Create/update post now |
|
| 567 | + $post_id = wp_insert_post( $post ); |
|
| 568 | 568 | self::maybe_update_custom_css( $custom_css ); |
| 569 | - } else { |
|
| 570 | - // Create/update post now |
|
| 571 | - $post_id = wp_insert_post( $post ); |
|
| 572 | - } |
|
| 569 | + } else { |
|
| 570 | + // Create/update post now |
|
| 571 | + $post_id = wp_insert_post( $post ); |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | - if ( ! is_numeric($post_id) ) { |
|
| 575 | - continue; |
|
| 576 | - } |
|
| 574 | + if ( ! is_numeric($post_id) ) { |
|
| 575 | + continue; |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - self::update_postmeta($post, $post_id); |
|
| 578 | + self::update_postmeta($post, $post_id); |
|
| 579 | 579 | |
| 580 | - $this_type = 'posts'; |
|
| 580 | + $this_type = 'posts'; |
|
| 581 | 581 | if ( isset( $post_types[ $post['post_type'] ] ) ) { |
| 582 | 582 | $this_type = $post_types[ $post['post_type'] ]; |
| 583 | - } |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 586 | - $imported['updated'][ $this_type ]++; |
|
| 587 | - } else { |
|
| 588 | - $imported['imported'][ $this_type ]++; |
|
| 589 | - } |
|
| 585 | + if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 586 | + $imported['updated'][ $this_type ]++; |
|
| 587 | + } else { |
|
| 588 | + $imported['imported'][ $this_type ]++; |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | 591 | $imported['posts'][ (int) $old_id ] = $post_id; |
| 592 | 592 | |
@@ -598,16 +598,16 @@ discard block |
||
| 598 | 598 | self::maybe_update_stylesheet( $imported ); |
| 599 | 599 | |
| 600 | 600 | return $imported; |
| 601 | - } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - private static function populate_post( &$post, $item, $imported ) { |
|
| 603 | + private static function populate_post( &$post, $item, $imported ) { |
|
| 604 | 604 | if ( isset($item->attachment_url) ) { |
| 605 | 605 | $post['attachment_url'] = (string) $item->attachment_url; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
| 609 | - // update to new form id |
|
| 610 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 609 | + // update to new form id |
|
| 610 | + $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // Don't allow default styles to take over a site's default style |
@@ -616,144 +616,144 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | foreach ( $item->postmeta as $meta ) { |
| 619 | - self::populate_postmeta($post, $meta, $imported); |
|
| 619 | + self::populate_postmeta($post, $meta, $imported); |
|
| 620 | 620 | unset($meta); |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - self::populate_taxonomies($post, $item); |
|
| 623 | + self::populate_taxonomies($post, $item); |
|
| 624 | 624 | |
| 625 | - self::maybe_editing_post($post); |
|
| 626 | - } |
|
| 625 | + self::maybe_editing_post($post); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | - private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 629 | - global $frm_duplicate_ids; |
|
| 628 | + private static function populate_postmeta( &$post, $meta, $imported ) { |
|
| 629 | + global $frm_duplicate_ids; |
|
| 630 | 630 | |
| 631 | - $m = array( |
|
| 631 | + $m = array( |
|
| 632 | 632 | 'key' => (string) $meta->meta_key, |
| 633 | 633 | 'value' => (string) $meta->meta_value, |
| 634 | 634 | ); |
| 635 | 635 | |
| 636 | 636 | //switch old form and field ids to new ones |
| 637 | 637 | if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
| 638 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 638 | + $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 639 | 639 | } else { |
| 640 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 640 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 641 | 641 | |
| 642 | - if ( ! empty($frm_duplicate_ids) ) { |
|
| 642 | + if ( ! empty($frm_duplicate_ids) ) { |
|
| 643 | 643 | |
| 644 | - if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 645 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 646 | - } else if ( $m['key'] == 'frm_options' ) { |
|
| 644 | + if ( $m['key'] == 'frm_dyncontent' ) { |
|
| 645 | + $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 646 | + } else if ( $m['key'] == 'frm_options' ) { |
|
| 647 | 647 | |
| 648 | 648 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 649 | 649 | if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
| 650 | 650 | $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - $check_dup_array = array(); |
|
| 655 | - if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 656 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 657 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 658 | - } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 659 | - $check_dup_array[] = 'order_by'; |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 664 | - $check_dup_array[] = 'where'; |
|
| 665 | - } |
|
| 666 | - |
|
| 667 | - foreach ( $check_dup_array as $check_k ) { |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + $check_dup_array = array(); |
|
| 655 | + if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
|
| 656 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 657 | + $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 658 | + } else if ( is_array( $m['value']['order_by'] ) ) { |
|
| 659 | + $check_dup_array[] = 'order_by'; |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) { |
|
| 664 | + $check_dup_array[] = 'where'; |
|
| 665 | + } |
|
| 666 | + |
|
| 667 | + foreach ( $check_dup_array as $check_k ) { |
|
| 668 | 668 | foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
| 669 | 669 | if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
| 670 | 670 | $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
| 671 | - } |
|
| 672 | - unset($mk, $mv); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 676 | - } |
|
| 671 | + } |
|
| 672 | + unset($mk, $mv); |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + } |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | if ( ! is_array($m['value']) ) { |
| 680 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 680 | + $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
| 684 | - } |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * Add terms to post |
|
| 688 | - * @param array $post by reference |
|
| 689 | - * @param object $item The XML object data |
|
| 690 | - */ |
|
| 691 | - private static function populate_taxonomies( &$post, $item ) { |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + /** |
|
| 687 | + * Add terms to post |
|
| 688 | + * @param array $post by reference |
|
| 689 | + * @param object $item The XML object data |
|
| 690 | + */ |
|
| 691 | + private static function populate_taxonomies( &$post, $item ) { |
|
| 692 | 692 | foreach ( $item->category as $c ) { |
| 693 | 693 | $att = $c->attributes(); |
| 694 | 694 | if ( ! isset( $att['nicename'] ) ) { |
| 695 | - continue; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - $taxonomy = (string) $att['domain']; |
|
| 699 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 700 | - $name = (string) $att['nicename']; |
|
| 701 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 702 | - if ( $h_term ) { |
|
| 703 | - $name = $h_term->term_id; |
|
| 704 | - } |
|
| 705 | - unset($h_term); |
|
| 706 | - } else { |
|
| 707 | - $name = (string) $c; |
|
| 708 | - } |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + $taxonomy = (string) $att['domain']; |
|
| 699 | + if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 700 | + $name = (string) $att['nicename']; |
|
| 701 | + $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 702 | + if ( $h_term ) { |
|
| 703 | + $name = $h_term->term_id; |
|
| 704 | + } |
|
| 705 | + unset($h_term); |
|
| 706 | + } else { |
|
| 707 | + $name = (string) $c; |
|
| 708 | + } |
|
| 709 | 709 | |
| 710 | 710 | if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
| 711 | 711 | $post['tax_input'][ $taxonomy ] = array(); |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | $post['tax_input'][ $taxonomy ][] = $name; |
| 715 | - unset($name); |
|
| 715 | + unset($name); |
|
| 716 | 716 | } |
| 717 | - } |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - /** |
|
| 720 | - * Edit post if the key and created time match |
|
| 721 | - */ |
|
| 722 | - private static function maybe_editing_post( &$post ) { |
|
| 719 | + /** |
|
| 720 | + * Edit post if the key and created time match |
|
| 721 | + */ |
|
| 722 | + private static function maybe_editing_post( &$post ) { |
|
| 723 | 723 | $match_by = array( |
| 724 | - 'post_type' => $post['post_type'], |
|
| 725 | - 'name' => $post['post_name'], |
|
| 726 | - 'post_status' => $post['post_status'], |
|
| 727 | - 'posts_per_page' => 1, |
|
| 724 | + 'post_type' => $post['post_type'], |
|
| 725 | + 'name' => $post['post_name'], |
|
| 726 | + 'post_status' => $post['post_status'], |
|
| 727 | + 'posts_per_page' => 1, |
|
| 728 | 728 | ); |
| 729 | 729 | |
| 730 | 730 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 731 | - $match_by['include'] = $post['post_id']; |
|
| 732 | - unset($match_by['name']); |
|
| 731 | + $match_by['include'] = $post['post_id']; |
|
| 732 | + unset($match_by['name']); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | $editing = get_posts($match_by); |
| 736 | 736 | |
| 737 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 738 | - // set the id of the post to edit |
|
| 739 | - $post['ID'] = current($editing)->ID; |
|
| 740 | - } |
|
| 741 | - } |
|
| 737 | + if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 738 | + // set the id of the post to edit |
|
| 739 | + $post['ID'] = current($editing)->ID; |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - private static function update_postmeta( &$post, $post_id ) { |
|
| 744 | - foreach ( $post['postmeta'] as $k => $v ) { |
|
| 745 | - if ( '_edit_last' == $k ) { |
|
| 746 | - $v = FrmAppHelper::get_user_id_param($v); |
|
| 747 | - } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 748 | - //change the attachment ID |
|
| 749 | - $v = FrmProXMLHelper::get_file_id($v); |
|
| 750 | - } |
|
| 743 | + private static function update_postmeta( &$post, $post_id ) { |
|
| 744 | + foreach ( $post['postmeta'] as $k => $v ) { |
|
| 745 | + if ( '_edit_last' == $k ) { |
|
| 746 | + $v = FrmAppHelper::get_user_id_param($v); |
|
| 747 | + } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
|
| 748 | + //change the attachment ID |
|
| 749 | + $v = FrmProXMLHelper::get_file_id($v); |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | - update_post_meta($post_id, $k, $v); |
|
| 752 | + update_post_meta($post_id, $k, $v); |
|
| 753 | 753 | |
| 754 | - unset($k, $v); |
|
| 755 | - } |
|
| 756 | - } |
|
| 754 | + unset($k, $v); |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | 759 | * If a template includes custom css, let's include it. |
@@ -786,72 +786,72 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - /** |
|
| 790 | - * @param string $message |
|
| 791 | - */ |
|
| 789 | + /** |
|
| 790 | + * @param string $message |
|
| 791 | + */ |
|
| 792 | 792 | public static function parse_message( $result, &$message, &$errors ) { |
| 793 | - if ( is_wp_error($result) ) { |
|
| 794 | - $errors[] = $result->get_error_message(); |
|
| 795 | - } else if ( ! $result ) { |
|
| 796 | - return; |
|
| 797 | - } |
|
| 798 | - |
|
| 799 | - if ( ! is_array($result) ) { |
|
| 800 | - $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
| 801 | - return; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - $t_strings = array( |
|
| 805 | - 'imported' => __( 'Imported', 'formidable' ), |
|
| 806 | - 'updated' => __( 'Updated', 'formidable' ), |
|
| 807 | - ); |
|
| 808 | - |
|
| 809 | - $message = '<ul>'; |
|
| 810 | - foreach ( $result as $type => $results ) { |
|
| 793 | + if ( is_wp_error($result) ) { |
|
| 794 | + $errors[] = $result->get_error_message(); |
|
| 795 | + } else if ( ! $result ) { |
|
| 796 | + return; |
|
| 797 | + } |
|
| 798 | + |
|
| 799 | + if ( ! is_array($result) ) { |
|
| 800 | + $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
|
| 801 | + return; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + $t_strings = array( |
|
| 805 | + 'imported' => __( 'Imported', 'formidable' ), |
|
| 806 | + 'updated' => __( 'Updated', 'formidable' ), |
|
| 807 | + ); |
|
| 808 | + |
|
| 809 | + $message = '<ul>'; |
|
| 810 | + foreach ( $result as $type => $results ) { |
|
| 811 | 811 | if ( ! isset( $t_strings[ $type ] ) ) { |
| 812 | - // only print imported and updated |
|
| 813 | - continue; |
|
| 814 | - } |
|
| 812 | + // only print imported and updated |
|
| 813 | + continue; |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | - $s_message = array(); |
|
| 817 | - foreach ( $results as $k => $m ) { |
|
| 818 | - self::item_count_message($m, $k, $s_message); |
|
| 819 | - unset($k, $m); |
|
| 820 | - } |
|
| 816 | + $s_message = array(); |
|
| 817 | + foreach ( $results as $k => $m ) { |
|
| 818 | + self::item_count_message($m, $k, $s_message); |
|
| 819 | + unset($k, $m); |
|
| 820 | + } |
|
| 821 | 821 | |
| 822 | - if ( ! empty($s_message) ) { |
|
| 822 | + if ( ! empty($s_message) ) { |
|
| 823 | 823 | $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
| 824 | - $message .= implode(', ', $s_message); |
|
| 825 | - $message .= '</li>'; |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - |
|
| 829 | - if ( $message == '<ul>' ) { |
|
| 830 | - $message = ''; |
|
| 831 | - $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 832 | - } else { |
|
| 833 | - $message .= '</ul>'; |
|
| 834 | - } |
|
| 835 | - } |
|
| 824 | + $message .= implode(', ', $s_message); |
|
| 825 | + $message .= '</li>'; |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | + |
|
| 829 | + if ( $message == '<ul>' ) { |
|
| 830 | + $message = ''; |
|
| 831 | + $errors[] = __( 'Nothing was imported or updated', 'formidable' ); |
|
| 832 | + } else { |
|
| 833 | + $message .= '</ul>'; |
|
| 834 | + } |
|
| 835 | + } |
|
| 836 | 836 | |
| 837 | 837 | public static function item_count_message( $m, $type, &$s_message ) { |
| 838 | - if ( ! $m ) { |
|
| 839 | - return; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - $strings = array( |
|
| 843 | - 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 844 | - 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 845 | - 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 846 | - 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 847 | - 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 848 | - 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 849 | - 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 850 | - 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 851 | - ); |
|
| 838 | + if ( ! $m ) { |
|
| 839 | + return; |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + $strings = array( |
|
| 843 | + 'forms' => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ), |
|
| 844 | + 'fields' => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ), |
|
| 845 | + 'items' => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ), |
|
| 846 | + 'views' => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ), |
|
| 847 | + 'posts' => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ), |
|
| 848 | + 'styles' => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ), |
|
| 849 | + 'terms' => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ), |
|
| 850 | + 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
|
| 851 | + ); |
|
| 852 | 852 | |
| 853 | 853 | $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
| 854 | - } |
|
| 854 | + } |
|
| 855 | 855 | |
| 856 | 856 | /** |
| 857 | 857 | * Prepare the form options for export |
@@ -882,16 +882,16 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | public static function cdata( $str ) { |
| 885 | - $str = maybe_unserialize($str); |
|
| 886 | - if ( is_array($str) ) { |
|
| 887 | - $str = json_encode($str); |
|
| 885 | + $str = maybe_unserialize($str); |
|
| 886 | + if ( is_array($str) ) { |
|
| 887 | + $str = json_encode($str); |
|
| 888 | 888 | } else if ( seems_utf8( $str ) == false ) { |
| 889 | 889 | $str = utf8_encode( $str ); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if ( is_numeric($str) ) { |
|
| 893 | - return $str; |
|
| 894 | - } |
|
| 892 | + if ( is_numeric($str) ) { |
|
| 893 | + return $str; |
|
| 894 | + } |
|
| 895 | 895 | |
| 896 | 896 | self::remove_invalid_characters_from_xml( $str ); |
| 897 | 897 | |
@@ -912,58 +912,58 @@ discard block |
||
| 912 | 912 | $str = str_replace( '\x1F', '', $str ); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 916 | - // Get post type |
|
| 917 | - $post_type = FrmFormActionsController::$action_post_type; |
|
| 918 | - |
|
| 919 | - // Set up imported index, if not set up yet |
|
| 920 | - if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 921 | - $imported['imported']['actions'] = 0; |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - // Migrate post settings to action |
|
| 925 | - self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 926 | - |
|
| 927 | - // Migrate email settings to action |
|
| 928 | - self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 929 | - } |
|
| 930 | - |
|
| 931 | - /** |
|
| 932 | - * Migrate post settings to form action |
|
| 933 | - * |
|
| 934 | - * @param string $post_type |
|
| 935 | - */ |
|
| 936 | - private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 937 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 938 | - return; |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - $new_action = array( |
|
| 942 | - 'post_type' => $post_type, |
|
| 943 | - 'post_excerpt' => 'wppost', |
|
| 915 | + public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) { |
|
| 916 | + // Get post type |
|
| 917 | + $post_type = FrmFormActionsController::$action_post_type; |
|
| 918 | + |
|
| 919 | + // Set up imported index, if not set up yet |
|
| 920 | + if ( ! isset( $imported['imported']['actions'] ) ) { |
|
| 921 | + $imported['imported']['actions'] = 0; |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + // Migrate post settings to action |
|
| 925 | + self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 926 | + |
|
| 927 | + // Migrate email settings to action |
|
| 928 | + self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch ); |
|
| 929 | + } |
|
| 930 | + |
|
| 931 | + /** |
|
| 932 | + * Migrate post settings to form action |
|
| 933 | + * |
|
| 934 | + * @param string $post_type |
|
| 935 | + */ |
|
| 936 | + private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 937 | + if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 938 | + return; |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + $new_action = array( |
|
| 942 | + 'post_type' => $post_type, |
|
| 943 | + 'post_excerpt' => 'wppost', |
|
| 944 | 944 | 'post_title' => __( 'Create Posts', 'formidable' ), |
| 945 | - 'menu_order' => $form_id, |
|
| 946 | - 'post_status' => 'publish', |
|
| 947 | - 'post_content' => array(), |
|
| 945 | + 'menu_order' => $form_id, |
|
| 946 | + 'post_status' => 'publish', |
|
| 947 | + 'post_content' => array(), |
|
| 948 | 948 | 'post_name' => $form_id . '_wppost_1', |
| 949 | - ); |
|
| 949 | + ); |
|
| 950 | 950 | |
| 951 | - $post_settings = array( |
|
| 952 | - 'post_type', 'post_category', 'post_content', |
|
| 953 | - 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
| 951 | + $post_settings = array( |
|
| 952 | + 'post_type', 'post_category', 'post_content', |
|
| 953 | + 'post_excerpt', 'post_title', 'post_name', 'post_date', |
|
| 954 | 954 | 'post_status', 'post_custom_fields', 'post_password', |
| 955 | - ); |
|
| 955 | + ); |
|
| 956 | 956 | |
| 957 | - foreach ( $post_settings as $post_setting ) { |
|
| 957 | + foreach ( $post_settings as $post_setting ) { |
|
| 958 | 958 | if ( isset( $form_options[ $post_setting ] ) ) { |
| 959 | 959 | $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
| 960 | - } |
|
| 961 | - unset($post_setting); |
|
| 962 | - } |
|
| 960 | + } |
|
| 961 | + unset($post_setting); |
|
| 962 | + } |
|
| 963 | 963 | |
| 964 | 964 | $new_action['event'] = array( 'create', 'update' ); |
| 965 | 965 | |
| 966 | - if ( $switch ) { |
|
| 966 | + if ( $switch ) { |
|
| 967 | 967 | // Fields with string or int saved |
| 968 | 968 | $basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' ); |
| 969 | 969 | |
@@ -971,22 +971,22 @@ discard block |
||
| 971 | 971 | $array_fields = array( 'post_category', 'post_custom_fields' ); |
| 972 | 972 | |
| 973 | 973 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 974 | - } |
|
| 975 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 974 | + } |
|
| 975 | + $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 976 | 976 | |
| 977 | - $exists = get_posts( array( |
|
| 978 | - 'name' => $new_action['post_name'], |
|
| 979 | - 'post_type' => $new_action['post_type'], |
|
| 980 | - 'post_status' => $new_action['post_status'], |
|
| 981 | - 'numberposts' => 1, |
|
| 982 | - ) ); |
|
| 977 | + $exists = get_posts( array( |
|
| 978 | + 'name' => $new_action['post_name'], |
|
| 979 | + 'post_type' => $new_action['post_type'], |
|
| 980 | + 'post_status' => $new_action['post_status'], |
|
| 981 | + 'numberposts' => 1, |
|
| 982 | + ) ); |
|
| 983 | 983 | |
| 984 | - if ( ! $exists ) { |
|
| 984 | + if ( ! $exists ) { |
|
| 985 | 985 | // this isn't an email, but we need to use a class that will always be included |
| 986 | 986 | FrmAppHelper::save_json_post( $new_action ); |
| 987 | - $imported['imported']['actions']++; |
|
| 988 | - } |
|
| 989 | - } |
|
| 987 | + $imported['imported']['actions']++; |
|
| 988 | + } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | /** |
| 992 | 992 | * Switch old field IDs for new field IDs in emails and post |
@@ -999,211 +999,211 @@ discard block |
||
| 999 | 999 | * @return string $post_content - new field IDs |
| 1000 | 1000 | */ |
| 1001 | 1001 | private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) { |
| 1002 | - global $frm_duplicate_ids; |
|
| 1002 | + global $frm_duplicate_ids; |
|
| 1003 | 1003 | |
| 1004 | - // If there aren't IDs that were switched, end now |
|
| 1005 | - if ( ! $frm_duplicate_ids ) { |
|
| 1006 | - return; |
|
| 1007 | - } |
|
| 1004 | + // If there aren't IDs that were switched, end now |
|
| 1005 | + if ( ! $frm_duplicate_ids ) { |
|
| 1006 | + return; |
|
| 1007 | + } |
|
| 1008 | 1008 | |
| 1009 | - // Get old IDs |
|
| 1010 | - $old = array_keys( $frm_duplicate_ids ); |
|
| 1009 | + // Get old IDs |
|
| 1010 | + $old = array_keys( $frm_duplicate_ids ); |
|
| 1011 | 1011 | |
| 1012 | - // Get new IDs |
|
| 1013 | - $new = array_values( $frm_duplicate_ids ); |
|
| 1012 | + // Get new IDs |
|
| 1013 | + $new = array_values( $frm_duplicate_ids ); |
|
| 1014 | 1014 | |
| 1015 | - // Do a str_replace with each item to set the new IDs |
|
| 1016 | - foreach ( $post_content as $key => $setting ) { |
|
| 1017 | - if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1018 | - // Replace old IDs with new IDs |
|
| 1015 | + // Do a str_replace with each item to set the new IDs |
|
| 1016 | + foreach ( $post_content as $key => $setting ) { |
|
| 1017 | + if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
|
| 1018 | + // Replace old IDs with new IDs |
|
| 1019 | 1019 | $post_content[ $key ] = str_replace( $old, $new, $setting ); |
| 1020 | - } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1021 | - foreach ( $setting as $k => $val ) { |
|
| 1022 | - // Replace old IDs with new IDs |
|
| 1020 | + } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
|
| 1021 | + foreach ( $setting as $k => $val ) { |
|
| 1022 | + // Replace old IDs with new IDs |
|
| 1023 | 1023 | $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
| 1024 | - } |
|
| 1025 | - } |
|
| 1026 | - unset( $key, $setting ); |
|
| 1027 | - } |
|
| 1028 | - return $post_content; |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1032 | - // No old notifications or autoresponders to carry over |
|
| 1024 | + } |
|
| 1025 | + } |
|
| 1026 | + unset( $key, $setting ); |
|
| 1027 | + } |
|
| 1028 | + return $post_content; |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
|
| 1032 | + // No old notifications or autoresponders to carry over |
|
| 1033 | 1033 | if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) { |
| 1034 | - return; |
|
| 1035 | - } |
|
| 1034 | + return; |
|
| 1035 | + } |
|
| 1036 | 1036 | |
| 1037 | - // Initialize notifications array |
|
| 1038 | - $notifications = array(); |
|
| 1037 | + // Initialize notifications array |
|
| 1038 | + $notifications = array(); |
|
| 1039 | 1039 | |
| 1040 | - // Migrate regular notifications |
|
| 1041 | - self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1040 | + // Migrate regular notifications |
|
| 1041 | + self::migrate_notifications_to_action( $form_options, $form_id, $notifications ); |
|
| 1042 | 1042 | |
| 1043 | - // Migrate autoresponders |
|
| 1044 | - self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1043 | + // Migrate autoresponders |
|
| 1044 | + self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications ); |
|
| 1045 | 1045 | |
| 1046 | - if ( empty( $notifications ) ) { |
|
| 1047 | - return; |
|
| 1048 | - } |
|
| 1046 | + if ( empty( $notifications ) ) { |
|
| 1047 | + return; |
|
| 1048 | + } |
|
| 1049 | 1049 | |
| 1050 | - foreach ( $notifications as $new_notification ) { |
|
| 1051 | - $new_notification['post_type'] = $post_type; |
|
| 1052 | - $new_notification['post_excerpt'] = 'email'; |
|
| 1050 | + foreach ( $notifications as $new_notification ) { |
|
| 1051 | + $new_notification['post_type'] = $post_type; |
|
| 1052 | + $new_notification['post_excerpt'] = 'email'; |
|
| 1053 | 1053 | $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
| 1054 | - $new_notification['menu_order'] = $form_id; |
|
| 1055 | - $new_notification['post_status'] = 'publish'; |
|
| 1054 | + $new_notification['menu_order'] = $form_id; |
|
| 1055 | + $new_notification['post_status'] = 'publish'; |
|
| 1056 | 1056 | |
| 1057 | - // Switch field IDs and keys, if needed |
|
| 1058 | - if ( $switch ) { |
|
| 1057 | + // Switch field IDs and keys, if needed |
|
| 1058 | + if ( $switch ) { |
|
| 1059 | 1059 | |
| 1060 | 1060 | // Switch field IDs in email conditional logic |
| 1061 | 1061 | self::switch_email_contition_field_ids( $new_notification['post_content'] ); |
| 1062 | 1062 | |
| 1063 | 1063 | // Switch all other field IDs in email |
| 1064 | - $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1065 | - } |
|
| 1066 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | - |
|
| 1068 | - $exists = get_posts( array( |
|
| 1069 | - 'name' => $new_notification['post_name'], |
|
| 1070 | - 'post_type' => $new_notification['post_type'], |
|
| 1071 | - 'post_status' => $new_notification['post_status'], |
|
| 1072 | - 'numberposts' => 1, |
|
| 1073 | - ) ); |
|
| 1074 | - |
|
| 1075 | - if ( empty($exists) ) { |
|
| 1064 | + $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
|
| 1065 | + } |
|
| 1066 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | + |
|
| 1068 | + $exists = get_posts( array( |
|
| 1069 | + 'name' => $new_notification['post_name'], |
|
| 1070 | + 'post_type' => $new_notification['post_type'], |
|
| 1071 | + 'post_status' => $new_notification['post_status'], |
|
| 1072 | + 'numberposts' => 1, |
|
| 1073 | + ) ); |
|
| 1074 | + |
|
| 1075 | + if ( empty($exists) ) { |
|
| 1076 | 1076 | FrmAppHelper::save_json_post( $new_notification ); |
| 1077 | - $imported['imported']['actions']++; |
|
| 1078 | - } |
|
| 1079 | - unset($new_notification); |
|
| 1080 | - } |
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1084 | - if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1085 | - // add old settings into notification array |
|
| 1077 | + $imported['imported']['actions']++; |
|
| 1078 | + } |
|
| 1079 | + unset($new_notification); |
|
| 1080 | + } |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1084 | + if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) { |
|
| 1085 | + // add old settings into notification array |
|
| 1086 | 1086 | $form_options['notification'] = array( 0 => $form_options ); |
| 1087 | - } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1088 | - // make sure it's in the correct format |
|
| 1087 | + } else if ( isset( $form_options['notification']['email_to'] ) ) { |
|
| 1088 | + // make sure it's in the correct format |
|
| 1089 | 1089 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1090 | - } |
|
| 1090 | + } |
|
| 1091 | 1091 | |
| 1092 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1093 | - foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1092 | + if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1093 | + foreach ( $form_options['notification'] as $email_key => $notification ) { |
|
| 1094 | 1094 | |
| 1095 | - $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
| 1095 | + $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
|
| 1096 | 1096 | |
| 1097 | - // Format the email data |
|
| 1098 | - self::format_email_data( $atts, $notification ); |
|
| 1097 | + // Format the email data |
|
| 1098 | + self::format_email_data( $atts, $notification ); |
|
| 1099 | 1099 | |
| 1100 | 1100 | if ( isset( $notification['twilio'] ) && $notification['twilio'] ) { |
| 1101 | 1101 | do_action( 'frm_create_twilio_action', $atts, $notification ); |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - // Setup the new notification |
|
| 1105 | - $new_notification = array(); |
|
| 1106 | - self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1104 | + // Setup the new notification |
|
| 1105 | + $new_notification = array(); |
|
| 1106 | + self::setup_new_notification( $new_notification, $notification, $atts ); |
|
| 1107 | 1107 | |
| 1108 | - $notifications[] = $new_notification; |
|
| 1109 | - } |
|
| 1110 | - } |
|
| 1111 | - } |
|
| 1108 | + $notifications[] = $new_notification; |
|
| 1109 | + } |
|
| 1110 | + } |
|
| 1111 | + } |
|
| 1112 | 1112 | |
| 1113 | - private static function format_email_data( &$atts, $notification ) { |
|
| 1114 | - // Format email_to |
|
| 1115 | - self::format_email_to_data( $atts, $notification ); |
|
| 1113 | + private static function format_email_data( &$atts, $notification ) { |
|
| 1114 | + // Format email_to |
|
| 1115 | + self::format_email_to_data( $atts, $notification ); |
|
| 1116 | 1116 | |
| 1117 | - // Format the reply to email and name |
|
| 1118 | - $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
| 1119 | - foreach ( $reply_fields as $f => $val ) { |
|
| 1117 | + // Format the reply to email and name |
|
| 1118 | + $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
|
| 1119 | + foreach ( $reply_fields as $f => $val ) { |
|
| 1120 | 1120 | if ( isset( $notification[ $f ] ) ) { |
| 1121 | 1121 | $atts[ $f ] = $notification[ $f ]; |
| 1122 | 1122 | if ( 'custom' == $notification[ $f ] ) { |
| 1123 | 1123 | $atts[ $f ] = $notification[ 'cust_' . $f ]; |
| 1124 | 1124 | } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
| 1125 | 1125 | $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
| 1126 | - } |
|
| 1127 | - } |
|
| 1128 | - unset( $f, $val ); |
|
| 1129 | - } |
|
| 1126 | + } |
|
| 1127 | + } |
|
| 1128 | + unset( $f, $val ); |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - // Format event |
|
| 1131 | + // Format event |
|
| 1132 | 1132 | $atts['event'] = array( 'create' ); |
| 1133 | - if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1134 | - $atts['event'][] = 'update'; |
|
| 1135 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1133 | + if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
|
| 1134 | + $atts['event'][] = 'update'; |
|
| 1135 | + } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1136 | 1136 | $atts['event'] = array( 'update' ); |
| 1137 | - } |
|
| 1138 | - } |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | 1139 | |
| 1140 | - private static function format_email_to_data( &$atts, $notification ) { |
|
| 1141 | - if ( isset( $notification['email_to'] ) ) { |
|
| 1140 | + private static function format_email_to_data( &$atts, $notification ) { |
|
| 1141 | + if ( isset( $notification['email_to'] ) ) { |
|
| 1142 | 1142 | $atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] ); |
| 1143 | - } else { |
|
| 1144 | - $atts['email_to'] = array(); |
|
| 1145 | - } |
|
| 1143 | + } else { |
|
| 1144 | + $atts['email_to'] = array(); |
|
| 1145 | + } |
|
| 1146 | 1146 | |
| 1147 | - if ( isset( $notification['also_email_to'] ) ) { |
|
| 1148 | - $email_fields = (array) $notification['also_email_to']; |
|
| 1149 | - $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1150 | - unset( $email_fields ); |
|
| 1151 | - } |
|
| 1147 | + if ( isset( $notification['also_email_to'] ) ) { |
|
| 1148 | + $email_fields = (array) $notification['also_email_to']; |
|
| 1149 | + $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] ); |
|
| 1150 | + unset( $email_fields ); |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | - foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1153 | + foreach ( $atts['email_to'] as $key => $email_field ) { |
|
| 1154 | 1154 | |
| 1155 | - if ( is_numeric( $email_field ) ) { |
|
| 1155 | + if ( is_numeric( $email_field ) ) { |
|
| 1156 | 1156 | $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
| 1157 | - } |
|
| 1157 | + } |
|
| 1158 | 1158 | |
| 1159 | - if ( strpos( $email_field, '|') ) { |
|
| 1160 | - $email_opt = explode( '|', $email_field ); |
|
| 1161 | - if ( isset( $email_opt[0] ) ) { |
|
| 1159 | + if ( strpos( $email_field, '|') ) { |
|
| 1160 | + $email_opt = explode( '|', $email_field ); |
|
| 1161 | + if ( isset( $email_opt[0] ) ) { |
|
| 1162 | 1162 | $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
| 1163 | - } |
|
| 1164 | - unset( $email_opt ); |
|
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1171 | - // Set up new notification |
|
| 1172 | - $new_notification = array( |
|
| 1173 | - 'post_content' => array( |
|
| 1174 | - 'email_to' => $atts['email_to'], |
|
| 1175 | - 'event' => $atts['event'], |
|
| 1176 | - ), |
|
| 1163 | + } |
|
| 1164 | + unset( $email_opt ); |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
|
| 1171 | + // Set up new notification |
|
| 1172 | + $new_notification = array( |
|
| 1173 | + 'post_content' => array( |
|
| 1174 | + 'email_to' => $atts['email_to'], |
|
| 1175 | + 'event' => $atts['event'], |
|
| 1176 | + ), |
|
| 1177 | 1177 | 'post_name' => $atts['form_id'] . '_email_' . $atts['email_key'], |
| 1178 | - ); |
|
| 1178 | + ); |
|
| 1179 | 1179 | |
| 1180 | - // Add more fields to the new notification |
|
| 1181 | - $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1182 | - foreach ( $add_fields as $add_field ) { |
|
| 1180 | + // Add more fields to the new notification |
|
| 1181 | + $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
|
| 1182 | + foreach ( $add_fields as $add_field ) { |
|
| 1183 | 1183 | if ( isset( $notification[ $add_field ] ) ) { |
| 1184 | 1184 | $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
| 1185 | - } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1185 | + } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
|
| 1186 | 1186 | $new_notification['post_content'][ $add_field ] = 0; |
| 1187 | - } else { |
|
| 1187 | + } else { |
|
| 1188 | 1188 | $new_notification['post_content'][ $add_field ] = ''; |
| 1189 | - } |
|
| 1190 | - unset( $add_field ); |
|
| 1191 | - } |
|
| 1189 | + } |
|
| 1190 | + unset( $add_field ); |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | 1193 | // Set reply to |
| 1194 | 1194 | $new_notification['post_content']['reply_to'] = $atts['reply_to']; |
| 1195 | 1195 | |
| 1196 | - // Set from |
|
| 1196 | + // Set from |
|
| 1197 | 1197 | if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) { |
| 1198 | 1198 | $new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>'; |
| 1199 | - } |
|
| 1200 | - } |
|
| 1199 | + } |
|
| 1200 | + } |
|
| 1201 | 1201 | |
| 1202 | 1202 | /** |
| 1203 | - * Switch field IDs in pre-2.0 email conditional logic |
|
| 1204 | - * |
|
| 1205 | - * @param $post_content array, pass by reference |
|
| 1206 | - */ |
|
| 1203 | + * Switch field IDs in pre-2.0 email conditional logic |
|
| 1204 | + * |
|
| 1205 | + * @param $post_content array, pass by reference |
|
| 1206 | + */ |
|
| 1207 | 1207 | private static function switch_email_contition_field_ids( &$post_content ) { |
| 1208 | 1208 | // Switch field IDs in conditional logic |
| 1209 | 1209 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
@@ -1216,36 +1216,36 @@ discard block |
||
| 1216 | 1216 | } |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | - private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1220 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1221 | - // migrate autoresponder |
|
| 1222 | - |
|
| 1223 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1224 | - if ( strpos($email_field, '|') ) { |
|
| 1225 | - // data from entries field |
|
| 1226 | - $email_field = explode('|', $email_field); |
|
| 1227 | - if ( isset($email_field[1]) ) { |
|
| 1228 | - $email_field = $email_field[1]; |
|
| 1229 | - } |
|
| 1230 | - } |
|
| 1231 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1219 | + private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
|
| 1220 | + if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1221 | + // migrate autoresponder |
|
| 1222 | + |
|
| 1223 | + $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1224 | + if ( strpos($email_field, '|') ) { |
|
| 1225 | + // data from entries field |
|
| 1226 | + $email_field = explode('|', $email_field); |
|
| 1227 | + if ( isset($email_field[1]) ) { |
|
| 1228 | + $email_field = $email_field[1]; |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | + if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1232 | 1232 | $email_field = '[' . $email_field . ']'; |
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - $notification = $form_options; |
|
| 1236 | - $new_notification2 = array( |
|
| 1237 | - 'post_content' => array( |
|
| 1238 | - 'email_message' => $notification['ar_email_message'], |
|
| 1239 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1240 | - 'email_to' => $email_field, |
|
| 1241 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1242 | - 'inc_user_info' => 0, |
|
| 1243 | - ), |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + $notification = $form_options; |
|
| 1236 | + $new_notification2 = array( |
|
| 1237 | + 'post_content' => array( |
|
| 1238 | + 'email_message' => $notification['ar_email_message'], |
|
| 1239 | + 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1240 | + 'email_to' => $email_field, |
|
| 1241 | + 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1242 | + 'inc_user_info' => 0, |
|
| 1243 | + ), |
|
| 1244 | 1244 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1245 | - ); |
|
| 1245 | + ); |
|
| 1246 | 1246 | |
| 1247 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1248 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1247 | + $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1248 | + $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1249 | 1249 | |
| 1250 | 1250 | if ( ! empty( $reply_to ) ) { |
| 1251 | 1251 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | $new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>'; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - $notifications[] = $new_notification2; |
|
| 1259 | - unset( $new_notification2 ); |
|
| 1260 | - } |
|
| 1261 | - } |
|
| 1258 | + $notifications[] = $new_notification2; |
|
| 1259 | + unset( $new_notification2 ); |
|
| 1260 | + } |
|
| 1261 | + } |
|
| 1262 | 1262 | } |
| 1263 | 1263 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | 'terms' => array(), |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - unset($defaults); |
|
| 39 | + unset( $defaults ); |
|
| 40 | 40 | |
| 41 | 41 | if ( ! defined( 'WP_IMPORTING' ) ) { |
| 42 | - define('WP_IMPORTING', true); |
|
| 42 | + define( 'WP_IMPORTING', true ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if ( ! class_exists( 'DOMDocument' ) ) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( ! function_exists('simplexml_import_dom') ) { |
|
| 55 | + if ( ! function_exists( 'simplexml_import_dom' ) ) { |
|
| 56 | 56 | return new WP_Error( 'SimpleXML_parse_error', __( 'Your server is missing the simplexml_import_dom function', 'formidable' ), libxml_get_errors() ); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order |
| 68 | 68 | foreach ( array( 'term', 'form', 'view' ) as $item_type ) { |
| 69 | 69 | // grab cats, tags, and terms, or forms or posts |
| 70 | - if ( isset($xml->{$item_type} ) ) { |
|
| 70 | + if ( isset( $xml->{$item_type} ) ) { |
|
| 71 | 71 | $function_name = 'import_xml_' . $item_type . 's'; |
| 72 | 72 | $imported = self::$function_name( $xml->{$item_type}, $imported ); |
| 73 | 73 | unset( $function_name, $xml->{$item_type} ); |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $return = apply_filters('frm_importing_xml', $imported, $xml ); |
|
| 77 | + $return = apply_filters( 'frm_importing_xml', $imported, $xml ); |
|
| 78 | 78 | |
| 79 | 79 | return $return; |
| 80 | 80 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | 'slug' => (string) $t->term_slug, |
| 92 | 92 | 'description' => (string) $t->term_description, |
| 93 | 93 | 'parent' => empty( $parent ) ? 0 : $parent, |
| 94 | - )); |
|
| 94 | + ) ); |
|
| 95 | 95 | |
| 96 | 96 | if ( $term && is_array( $term ) ) { |
| 97 | - $imported['imported']['terms']++; |
|
| 98 | - $imported['terms'][ (int) $t->term_id ] = $term['term_id']; |
|
| 97 | + $imported['imported']['terms'] ++; |
|
| 98 | + $imported['terms'][(int) $t->term_id] = $term['term_id']; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | unset( $term, $t ); |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | } else { |
| 145 | 145 | $form_id = FrmForm::create( $form ); |
| 146 | 146 | if ( $form_id ) { |
| 147 | - $imported['imported']['forms']++; |
|
| 147 | + $imported['imported']['forms'] ++; |
|
| 148 | 148 | // Keep track of whether this specific form was updated or not |
| 149 | - $imported['form_status'][ $form_id ] = 'imported'; |
|
| 149 | + $imported['form_status'][$form_id] = 'imported'; |
|
| 150 | 150 | self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms ); |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | // Update field ids/keys to new ones |
| 159 | 159 | do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) ); |
| 160 | 160 | |
| 161 | - $imported['forms'][ (int) $item->id ] = $form_id; |
|
| 161 | + $imported['forms'][(int) $item->id] = $form_id; |
|
| 162 | 162 | |
| 163 | 163 | // Send pre 2.0 form options through function that creates actions |
| 164 | 164 | self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true ); |
| 165 | 165 | |
| 166 | 166 | do_action( 'frm_after_import_form', $form_id, $form ); |
| 167 | 167 | |
| 168 | - unset($form, $item); |
|
| 168 | + unset( $form, $item ); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms ); |
@@ -207,18 +207,18 @@ discard block |
||
| 207 | 207 | private static function update_form( $this_form, $form, &$imported ) { |
| 208 | 208 | $form_id = $this_form->id; |
| 209 | 209 | FrmForm::update( $form_id, $form ); |
| 210 | - $imported['updated']['forms']++; |
|
| 210 | + $imported['updated']['forms'] ++; |
|
| 211 | 211 | // Keep track of whether this specific form was updated or not |
| 212 | - $imported['form_status'][ $form_id ] = 'updated'; |
|
| 212 | + $imported['form_status'][$form_id] = 'updated'; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | private static function get_form_fields( $form_id ) { |
| 216 | 216 | $form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' ); |
| 217 | 217 | $old_fields = array(); |
| 218 | 218 | foreach ( $form_fields as $f ) { |
| 219 | - $old_fields[ $f->id ] = $f; |
|
| 220 | - $old_fields[ $f->field_key ] = $f->id; |
|
| 221 | - unset($f); |
|
| 219 | + $old_fields[$f->id] = $f; |
|
| 220 | + $old_fields[$f->field_key] = $f->id; |
|
| 221 | + unset( $f ); |
|
| 222 | 222 | } |
| 223 | 223 | $form_fields = $old_fields; |
| 224 | 224 | return $form_fields; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $regular_forms = array(); |
| 250 | 250 | |
| 251 | 251 | foreach ( $forms as $form ) { |
| 252 | - $parent_form_id = isset( $form->parent_form_id) ? (int) $form->parent_form_id : 0; |
|
| 252 | + $parent_form_id = isset( $form->parent_form_id ) ? (int) $form->parent_form_id : 0; |
|
| 253 | 253 | |
| 254 | 254 | if ( $parent_form_id ) { |
| 255 | 255 | $child_forms[] = $form; |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) { |
| 273 | 273 | if ( $parent_form_id ) { |
| 274 | - $child_forms[ $form_id ] = $parent_form_id; |
|
| 274 | + $child_forms[$form_id] = $parent_form_id; |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) { |
| 287 | 287 | foreach ( $child_forms as $child_form_id => $old_parent_form_id ) { |
| 288 | 288 | |
| 289 | - if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) { |
|
| 289 | + if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) { |
|
| 290 | 290 | // Update all children with this old parent_form_id |
| 291 | - $new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ]; |
|
| 291 | + $new_parent_form_id = (int) $imported_forms[$old_parent_form_id]; |
|
| 292 | 292 | |
| 293 | 293 | FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) ); |
| 294 | 294 | } |
@@ -307,15 +307,15 @@ discard block |
||
| 307 | 307 | foreach ( $xml_fields as $field ) { |
| 308 | 308 | $f = self::fill_field( $field, $form_id ); |
| 309 | 309 | |
| 310 | - if ( is_array($f['default_value']) && in_array($f['type'], array( |
|
| 310 | + if ( is_array( $f['default_value'] ) && in_array( $f['type'], array( |
|
| 311 | 311 | 'text', 'email', 'url', 'textarea', |
| 312 | - 'number','phone', 'date', 'time', |
|
| 312 | + 'number', 'phone', 'date', 'time', |
|
| 313 | 313 | 'hidden', 'password', 'tag', 'image', |
| 314 | - )) ) { |
|
| 315 | - if ( count($f['default_value']) === 1 ) { |
|
| 314 | + ) ) ) { |
|
| 315 | + if ( count( $f['default_value'] ) === 1 ) { |
|
| 316 | 316 | $f['default_value'] = '[' . reset( $f['default_value'] ) . ']'; |
| 317 | 317 | } else { |
| 318 | - $f['default_value'] = reset($f['default_value']); |
|
| 318 | + $f['default_value'] = reset( $f['default_value'] ); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -323,27 +323,27 @@ discard block |
||
| 323 | 323 | self::maybe_update_form_select( $f, $imported ); |
| 324 | 324 | self::maybe_update_get_values_form_setting( $imported, $f ); |
| 325 | 325 | |
| 326 | - if ( ! empty($this_form) ) { |
|
| 326 | + if ( ! empty( $this_form ) ) { |
|
| 327 | 327 | // check for field to edit by field id |
| 328 | - if ( isset( $form_fields[ $f['id'] ] ) ) { |
|
| 328 | + if ( isset( $form_fields[$f['id']] ) ) { |
|
| 329 | 329 | FrmField::update( $f['id'], $f ); |
| 330 | - $imported['updated']['fields']++; |
|
| 330 | + $imported['updated']['fields'] ++; |
|
| 331 | 331 | |
| 332 | - unset( $form_fields[ $f['id'] ] ); |
|
| 332 | + unset( $form_fields[$f['id']] ); |
|
| 333 | 333 | |
| 334 | 334 | //unset old field key |
| 335 | - if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 336 | - unset( $form_fields[ $f['field_key'] ] ); |
|
| 335 | + if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 336 | + unset( $form_fields[$f['field_key']] ); |
|
| 337 | 337 | } |
| 338 | - } else if ( isset( $form_fields[ $f['field_key'] ] ) ) { |
|
| 338 | + } else if ( isset( $form_fields[$f['field_key']] ) ) { |
|
| 339 | 339 | // check for field to edit by field key |
| 340 | - unset($f['id']); |
|
| 340 | + unset( $f['id'] ); |
|
| 341 | 341 | |
| 342 | - FrmField::update( $form_fields[ $f['field_key'] ], $f ); |
|
| 343 | - $imported['updated']['fields']++; |
|
| 342 | + FrmField::update( $form_fields[$f['field_key']], $f ); |
|
| 343 | + $imported['updated']['fields'] ++; |
|
| 344 | 344 | |
| 345 | - unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id |
|
| 346 | - unset( $form_fields[ $f['field_key'] ] ); //unset old field key |
|
| 345 | + unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id |
|
| 346 | + unset( $form_fields[$f['field_key']] ); //unset old field key |
|
| 347 | 347 | } else { |
| 348 | 348 | // if no matching field id or key in this form, create the field |
| 349 | 349 | self::create_imported_field( $f, $imported ); |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | 'name' => (string) $field->name, |
| 363 | 363 | 'description' => (string) $field->description, |
| 364 | 364 | 'type' => (string) $field->type, |
| 365 | - 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value), |
|
| 365 | + 'default_value' => FrmAppHelper::maybe_json_decode( (string) $field->default_value ), |
|
| 366 | 366 | 'field_order' => (int) $field->field_order, |
| 367 | 367 | 'form_id' => (int) $form_id, |
| 368 | 368 | 'required' => (int) $field->required, |
| 369 | - 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options), |
|
| 369 | + 'options' => FrmAppHelper::maybe_json_decode( (string) $field->options ), |
|
| 370 | 370 | 'field_options' => FrmAppHelper::maybe_json_decode( (string) $field->field_options ), |
| 371 | 371 | ); |
| 372 | 372 | } |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) { |
| 411 | 411 | if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) { |
| 412 | 412 | $form_select = $f['field_options']['form_select']; |
| 413 | - if ( isset( $imported['forms'][ $form_select ] ) ) { |
|
| 414 | - $f['field_options']['form_select'] = $imported['forms'][ $form_select ]; |
|
| 413 | + if ( isset( $imported['forms'][$form_select] ) ) { |
|
| 414 | + $f['field_options']['form_select'] = $imported['forms'][$form_select]; |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) { |
| 433 | 433 | $old_form = $f['field_options']['get_values_form']; |
| 434 | - if ( isset( $imported['forms'][ $old_form ] ) ) { |
|
| 435 | - $f['field_options']['get_values_form'] = $imported['forms'][ $old_form ]; |
|
| 434 | + if ( isset( $imported['forms'][$old_form] ) ) { |
|
| 435 | + $f['field_options']['get_values_form'] = $imported['forms'][$old_form]; |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | private static function create_imported_field( $f, &$imported ) { |
| 448 | 448 | $new_id = FrmField::create( $f ); |
| 449 | 449 | if ( $new_id != false ) { |
| 450 | - $imported['imported']['fields']++; |
|
| 450 | + $imported['imported']['fields'] ++; |
|
| 451 | 451 | do_action( 'frm_after_field_is_imported', $f, $new_id ); |
| 452 | 452 | } |
| 453 | 453 | } |
@@ -546,9 +546,9 @@ discard block |
||
| 546 | 546 | ); |
| 547 | 547 | |
| 548 | 548 | $old_id = $post['post_id']; |
| 549 | - self::populate_post($post, $item, $imported); |
|
| 549 | + self::populate_post( $post, $item, $imported ); |
|
| 550 | 550 | |
| 551 | - unset($item); |
|
| 551 | + unset( $item ); |
|
| 552 | 552 | |
| 553 | 553 | $post_id = false; |
| 554 | 554 | if ( $post['post_type'] == $form_action_type ) { |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | if ( $action_control && is_object( $action_control ) ) { |
| 557 | 557 | $post_id = $action_control->maybe_create_action( $post, $imported['form_status'] ); |
| 558 | 558 | } |
| 559 | - unset($action_control); |
|
| 559 | + unset( $action_control ); |
|
| 560 | 560 | } else if ( $post['post_type'] == 'frm_styles' ) { |
| 561 | 561 | // Properly encode post content before inserting the post |
| 562 | 562 | $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] ); |
@@ -571,24 +571,24 @@ discard block |
||
| 571 | 571 | $post_id = wp_insert_post( $post ); |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if ( ! is_numeric($post_id) ) { |
|
| 574 | + if ( ! is_numeric( $post_id ) ) { |
|
| 575 | 575 | continue; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - self::update_postmeta($post, $post_id); |
|
| 578 | + self::update_postmeta( $post, $post_id ); |
|
| 579 | 579 | |
| 580 | 580 | $this_type = 'posts'; |
| 581 | - if ( isset( $post_types[ $post['post_type'] ] ) ) { |
|
| 582 | - $this_type = $post_types[ $post['post_type'] ]; |
|
| 581 | + if ( isset( $post_types[$post['post_type']] ) ) { |
|
| 582 | + $this_type = $post_types[$post['post_type']]; |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - if ( isset($post['ID']) && $post_id == $post['ID'] ) { |
|
| 586 | - $imported['updated'][ $this_type ]++; |
|
| 585 | + if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) { |
|
| 586 | + $imported['updated'][$this_type] ++; |
|
| 587 | 587 | } else { |
| 588 | - $imported['imported'][ $this_type ]++; |
|
| 588 | + $imported['imported'][$this_type] ++; |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $imported['posts'][ (int) $old_id ] = $post_id; |
|
| 591 | + $imported['posts'][(int) $old_id] = $post_id; |
|
| 592 | 592 | |
| 593 | 593 | do_action( 'frm_after_import_view', $post_id, $post ); |
| 594 | 594 | |
@@ -601,13 +601,13 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | private static function populate_post( &$post, $item, $imported ) { |
| 604 | - if ( isset($item->attachment_url) ) { |
|
| 604 | + if ( isset( $item->attachment_url ) ) { |
|
| 605 | 605 | $post['attachment_url'] = (string) $item->attachment_url; |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) { |
|
| 608 | + if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) { |
|
| 609 | 609 | // update to new form id |
| 610 | - $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ]; |
|
| 610 | + $post['menu_order'] = $imported['forms'][(int) $post['menu_order']]; |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | // Don't allow default styles to take over a site's default style |
@@ -616,13 +616,13 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | foreach ( $item->postmeta as $meta ) { |
| 619 | - self::populate_postmeta($post, $meta, $imported); |
|
| 620 | - unset($meta); |
|
| 619 | + self::populate_postmeta( $post, $meta, $imported ); |
|
| 620 | + unset( $meta ); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - self::populate_taxonomies($post, $item); |
|
| 623 | + self::populate_taxonomies( $post, $item ); |
|
| 624 | 624 | |
| 625 | - self::maybe_editing_post($post); |
|
| 625 | + self::maybe_editing_post( $post ); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | private static function populate_postmeta( &$post, $meta, $imported ) { |
@@ -634,27 +634,27 @@ discard block |
||
| 634 | 634 | ); |
| 635 | 635 | |
| 636 | 636 | //switch old form and field ids to new ones |
| 637 | - if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) { |
|
| 638 | - $m['value'] = $imported['forms'][ (int) $m['value'] ]; |
|
| 637 | + if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) { |
|
| 638 | + $m['value'] = $imported['forms'][(int) $m['value']]; |
|
| 639 | 639 | } else { |
| 640 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 640 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 641 | 641 | |
| 642 | - if ( ! empty($frm_duplicate_ids) ) { |
|
| 642 | + if ( ! empty( $frm_duplicate_ids ) ) { |
|
| 643 | 643 | |
| 644 | 644 | if ( $m['key'] == 'frm_dyncontent' ) { |
| 645 | - $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']); |
|
| 645 | + $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] ); |
|
| 646 | 646 | } else if ( $m['key'] == 'frm_options' ) { |
| 647 | 647 | |
| 648 | 648 | foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) { |
| 649 | - if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) { |
|
| 650 | - $m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ]; |
|
| 649 | + if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) { |
|
| 650 | + $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]]; |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | $check_dup_array = array(); |
| 655 | 655 | if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) { |
| 656 | - if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) { |
|
| 657 | - $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ]; |
|
| 656 | + if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) { |
|
| 657 | + $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']]; |
|
| 658 | 658 | } else if ( is_array( $m['value']['order_by'] ) ) { |
| 659 | 659 | $check_dup_array[] = 'order_by'; |
| 660 | 660 | } |
@@ -665,22 +665,22 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | foreach ( $check_dup_array as $check_k ) { |
| 668 | - foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) { |
|
| 669 | - if ( isset( $frm_duplicate_ids[ $mv ] ) ) { |
|
| 670 | - $m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ]; |
|
| 668 | + foreach ( (array) $m['value'][$check_k] as $mk => $mv ) { |
|
| 669 | + if ( isset( $frm_duplicate_ids[$mv] ) ) { |
|
| 670 | + $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv]; |
|
| 671 | 671 | } |
| 672 | - unset($mk, $mv); |
|
| 672 | + unset( $mk, $mv ); |
|
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if ( ! is_array($m['value']) ) { |
|
| 680 | - $m['value'] = FrmAppHelper::maybe_json_decode($m['value']); |
|
| 679 | + if ( ! is_array( $m['value'] ) ) { |
|
| 680 | + $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] ); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | - $post['postmeta'][ (string) $meta->meta_key ] = $m['value']; |
|
| 683 | + $post['postmeta'][(string) $meta->meta_key] = $m['value']; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
@@ -696,23 +696,23 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | $taxonomy = (string) $att['domain']; |
| 699 | - if ( is_taxonomy_hierarchical($taxonomy) ) { |
|
| 699 | + if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
|
| 700 | 700 | $name = (string) $att['nicename']; |
| 701 | - $h_term = get_term_by('slug', $name, $taxonomy); |
|
| 701 | + $h_term = get_term_by( 'slug', $name, $taxonomy ); |
|
| 702 | 702 | if ( $h_term ) { |
| 703 | 703 | $name = $h_term->term_id; |
| 704 | 704 | } |
| 705 | - unset($h_term); |
|
| 705 | + unset( $h_term ); |
|
| 706 | 706 | } else { |
| 707 | 707 | $name = (string) $c; |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | - if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) { |
|
| 711 | - $post['tax_input'][ $taxonomy ] = array(); |
|
| 710 | + if ( ! isset( $post['tax_input'][$taxonomy] ) ) { |
|
| 711 | + $post['tax_input'][$taxonomy] = array(); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - $post['tax_input'][ $taxonomy ][] = $name; |
|
| 715 | - unset($name); |
|
| 714 | + $post['tax_input'][$taxonomy][] = $name; |
|
| 715 | + unset( $name ); |
|
| 716 | 716 | } |
| 717 | 717 | } |
| 718 | 718 | |
@@ -729,29 +729,29 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) { |
| 731 | 731 | $match_by['include'] = $post['post_id']; |
| 732 | - unset($match_by['name']); |
|
| 732 | + unset( $match_by['name'] ); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - $editing = get_posts($match_by); |
|
| 735 | + $editing = get_posts( $match_by ); |
|
| 736 | 736 | |
| 737 | - if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) { |
|
| 737 | + if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) { |
|
| 738 | 738 | // set the id of the post to edit |
| 739 | - $post['ID'] = current($editing)->ID; |
|
| 739 | + $post['ID'] = current( $editing )->ID; |
|
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | private static function update_postmeta( &$post, $post_id ) { |
| 744 | 744 | foreach ( $post['postmeta'] as $k => $v ) { |
| 745 | 745 | if ( '_edit_last' == $k ) { |
| 746 | - $v = FrmAppHelper::get_user_id_param($v); |
|
| 746 | + $v = FrmAppHelper::get_user_id_param( $v ); |
|
| 747 | 747 | } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) { |
| 748 | 748 | //change the attachment ID |
| 749 | - $v = FrmProXMLHelper::get_file_id($v); |
|
| 749 | + $v = FrmProXMLHelper::get_file_id( $v ); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - update_post_meta($post_id, $k, $v); |
|
| 752 | + update_post_meta( $post_id, $k, $v ); |
|
| 753 | 753 | |
| 754 | - unset($k, $v); |
|
| 754 | + unset( $k, $v ); |
|
| 755 | 755 | } |
| 756 | 756 | } |
| 757 | 757 | |
@@ -790,13 +790,13 @@ discard block |
||
| 790 | 790 | * @param string $message |
| 791 | 791 | */ |
| 792 | 792 | public static function parse_message( $result, &$message, &$errors ) { |
| 793 | - if ( is_wp_error($result) ) { |
|
| 793 | + if ( is_wp_error( $result ) ) { |
|
| 794 | 794 | $errors[] = $result->get_error_message(); |
| 795 | 795 | } else if ( ! $result ) { |
| 796 | 796 | return; |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | - if ( ! is_array($result) ) { |
|
| 799 | + if ( ! is_array( $result ) ) { |
|
| 800 | 800 | $message = is_string( $result ) ? $result : print_r( $result, 1 ); |
| 801 | 801 | return; |
| 802 | 802 | } |
@@ -808,20 +808,20 @@ discard block |
||
| 808 | 808 | |
| 809 | 809 | $message = '<ul>'; |
| 810 | 810 | foreach ( $result as $type => $results ) { |
| 811 | - if ( ! isset( $t_strings[ $type ] ) ) { |
|
| 811 | + if ( ! isset( $t_strings[$type] ) ) { |
|
| 812 | 812 | // only print imported and updated |
| 813 | 813 | continue; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | 816 | $s_message = array(); |
| 817 | 817 | foreach ( $results as $k => $m ) { |
| 818 | - self::item_count_message($m, $k, $s_message); |
|
| 819 | - unset($k, $m); |
|
| 818 | + self::item_count_message( $m, $k, $s_message ); |
|
| 819 | + unset( $k, $m ); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - if ( ! empty($s_message) ) { |
|
| 823 | - $message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> '; |
|
| 824 | - $message .= implode(', ', $s_message); |
|
| 822 | + if ( ! empty( $s_message ) ) { |
|
| 823 | + $message .= '<li><strong>' . $t_strings[$type] . ':</strong> '; |
|
| 824 | + $message .= implode( ', ', $s_message ); |
|
| 825 | 825 | $message .= '</li>'; |
| 826 | 826 | } |
| 827 | 827 | } |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | 'actions' => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ), |
| 851 | 851 | ); |
| 852 | 852 | |
| 853 | - $s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 853 | + $s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type ); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | /** |
@@ -882,14 +882,14 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | public static function cdata( $str ) { |
| 885 | - $str = maybe_unserialize($str); |
|
| 886 | - if ( is_array($str) ) { |
|
| 887 | - $str = json_encode($str); |
|
| 885 | + $str = maybe_unserialize( $str ); |
|
| 886 | + if ( is_array( $str ) ) { |
|
| 887 | + $str = json_encode( $str ); |
|
| 888 | 888 | } else if ( seems_utf8( $str ) == false ) { |
| 889 | 889 | $str = utf8_encode( $str ); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if ( is_numeric($str) ) { |
|
| 892 | + if ( is_numeric( $str ) ) { |
|
| 893 | 893 | return $str; |
| 894 | 894 | } |
| 895 | 895 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * @param string $post_type |
| 935 | 935 | */ |
| 936 | 936 | private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) { |
| 937 | - if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) { |
|
| 937 | + if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) { |
|
| 938 | 938 | return; |
| 939 | 939 | } |
| 940 | 940 | |
@@ -955,10 +955,10 @@ discard block |
||
| 955 | 955 | ); |
| 956 | 956 | |
| 957 | 957 | foreach ( $post_settings as $post_setting ) { |
| 958 | - if ( isset( $form_options[ $post_setting ] ) ) { |
|
| 959 | - $new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ]; |
|
| 958 | + if ( isset( $form_options[$post_setting] ) ) { |
|
| 959 | + $new_action['post_content'][$post_setting] = $form_options[$post_setting]; |
|
| 960 | 960 | } |
| 961 | - unset($post_setting); |
|
| 961 | + unset( $post_setting ); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | $new_action['event'] = array( 'create', 'update' ); |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | $new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields ); |
| 974 | 974 | } |
| 975 | - $new_action['post_content'] = json_encode($new_action['post_content']); |
|
| 975 | + $new_action['post_content'] = json_encode( $new_action['post_content'] ); |
|
| 976 | 976 | |
| 977 | 977 | $exists = get_posts( array( |
| 978 | 978 | 'name' => $new_action['post_name'], |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | if ( ! $exists ) { |
| 985 | 985 | // this isn't an email, but we need to use a class that will always be included |
| 986 | 986 | FrmAppHelper::save_json_post( $new_action ); |
| 987 | - $imported['imported']['actions']++; |
|
| 987 | + $imported['imported']['actions'] ++; |
|
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | |
@@ -1016,11 +1016,11 @@ discard block |
||
| 1016 | 1016 | foreach ( $post_content as $key => $setting ) { |
| 1017 | 1017 | if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) { |
| 1018 | 1018 | // Replace old IDs with new IDs |
| 1019 | - $post_content[ $key ] = str_replace( $old, $new, $setting ); |
|
| 1019 | + $post_content[$key] = str_replace( $old, $new, $setting ); |
|
| 1020 | 1020 | } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) { |
| 1021 | 1021 | foreach ( $setting as $k => $val ) { |
| 1022 | 1022 | // Replace old IDs with new IDs |
| 1023 | - $post_content[ $key ][ $k ] = str_replace( $old, $new, $val ); |
|
| 1023 | + $post_content[$key][$k] = str_replace( $old, $new, $val ); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | unset( $key, $setting ); |
@@ -1050,7 +1050,7 @@ discard block |
||
| 1050 | 1050 | foreach ( $notifications as $new_notification ) { |
| 1051 | 1051 | $new_notification['post_type'] = $post_type; |
| 1052 | 1052 | $new_notification['post_excerpt'] = 'email'; |
| 1053 | - $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1053 | + $new_notification['post_title'] = __( 'Email Notification', 'formidable' ); |
|
| 1054 | 1054 | $new_notification['menu_order'] = $form_id; |
| 1055 | 1055 | $new_notification['post_status'] = 'publish'; |
| 1056 | 1056 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | // Switch all other field IDs in email |
| 1064 | 1064 | $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] ); |
| 1065 | 1065 | } |
| 1066 | - $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1066 | + $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] ); |
|
| 1067 | 1067 | |
| 1068 | 1068 | $exists = get_posts( array( |
| 1069 | 1069 | 'name' => $new_notification['post_name'], |
@@ -1072,11 +1072,11 @@ discard block |
||
| 1072 | 1072 | 'numberposts' => 1, |
| 1073 | 1073 | ) ); |
| 1074 | 1074 | |
| 1075 | - if ( empty($exists) ) { |
|
| 1075 | + if ( empty( $exists ) ) { |
|
| 1076 | 1076 | FrmAppHelper::save_json_post( $new_notification ); |
| 1077 | - $imported['imported']['actions']++; |
|
| 1077 | + $imported['imported']['actions'] ++; |
|
| 1078 | 1078 | } |
| 1079 | - unset($new_notification); |
|
| 1079 | + unset( $new_notification ); |
|
| 1080 | 1080 | } |
| 1081 | 1081 | } |
| 1082 | 1082 | |
@@ -1089,7 +1089,7 @@ discard block |
||
| 1089 | 1089 | $form_options['notification'] = array( 0 => $form_options['notification'] ); |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) { |
|
| 1092 | + if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) { |
|
| 1093 | 1093 | foreach ( $form_options['notification'] as $email_key => $notification ) { |
| 1094 | 1094 | |
| 1095 | 1095 | $atts = array( 'email_to' => '', 'reply_to' => '', 'reply_to_name' => '', 'event' => '', 'form_id' => $form_id, 'email_key' => $email_key ); |
@@ -1117,12 +1117,12 @@ discard block |
||
| 1117 | 1117 | // Format the reply to email and name |
| 1118 | 1118 | $reply_fields = array( 'reply_to' => '', 'reply_to_name' => '' ); |
| 1119 | 1119 | foreach ( $reply_fields as $f => $val ) { |
| 1120 | - if ( isset( $notification[ $f ] ) ) { |
|
| 1121 | - $atts[ $f ] = $notification[ $f ]; |
|
| 1122 | - if ( 'custom' == $notification[ $f ] ) { |
|
| 1123 | - $atts[ $f ] = $notification[ 'cust_' . $f ]; |
|
| 1124 | - } else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) { |
|
| 1125 | - $atts[ $f ] = '[' . $atts[ $f ] . ']'; |
|
| 1120 | + if ( isset( $notification[$f] ) ) { |
|
| 1121 | + $atts[$f] = $notification[$f]; |
|
| 1122 | + if ( 'custom' == $notification[$f] ) { |
|
| 1123 | + $atts[$f] = $notification['cust_' . $f]; |
|
| 1124 | + } else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) { |
|
| 1125 | + $atts[$f] = '[' . $atts[$f] . ']'; |
|
| 1126 | 1126 | } |
| 1127 | 1127 | } |
| 1128 | 1128 | unset( $f, $val ); |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | $atts['event'] = array( 'create' ); |
| 1133 | 1133 | if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) { |
| 1134 | 1134 | $atts['event'][] = 'update'; |
| 1135 | - } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) { |
|
| 1135 | + } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) { |
|
| 1136 | 1136 | $atts['event'] = array( 'update' ); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1153,18 +1153,18 @@ discard block |
||
| 1153 | 1153 | foreach ( $atts['email_to'] as $key => $email_field ) { |
| 1154 | 1154 | |
| 1155 | 1155 | if ( is_numeric( $email_field ) ) { |
| 1156 | - $atts['email_to'][ $key ] = '[' . $email_field . ']'; |
|
| 1156 | + $atts['email_to'][$key] = '[' . $email_field . ']'; |
|
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | - if ( strpos( $email_field, '|') ) { |
|
| 1159 | + if ( strpos( $email_field, '|' ) ) { |
|
| 1160 | 1160 | $email_opt = explode( '|', $email_field ); |
| 1161 | 1161 | if ( isset( $email_opt[0] ) ) { |
| 1162 | - $atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1162 | + $atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']'; |
|
| 1163 | 1163 | } |
| 1164 | 1164 | unset( $email_opt ); |
| 1165 | 1165 | } |
| 1166 | 1166 | } |
| 1167 | - $atts['email_to'] = implode(', ', $atts['email_to']); |
|
| 1167 | + $atts['email_to'] = implode( ', ', $atts['email_to'] ); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | private static function setup_new_notification( &$new_notification, $notification, $atts ) { |
@@ -1180,12 +1180,12 @@ discard block |
||
| 1180 | 1180 | // Add more fields to the new notification |
| 1181 | 1181 | $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' ); |
| 1182 | 1182 | foreach ( $add_fields as $add_field ) { |
| 1183 | - if ( isset( $notification[ $add_field ] ) ) { |
|
| 1184 | - $new_notification['post_content'][ $add_field ] = $notification[ $add_field ]; |
|
| 1183 | + if ( isset( $notification[$add_field] ) ) { |
|
| 1184 | + $new_notification['post_content'][$add_field] = $notification[$add_field]; |
|
| 1185 | 1185 | } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) { |
| 1186 | - $new_notification['post_content'][ $add_field ] = 0; |
|
| 1186 | + $new_notification['post_content'][$add_field] = 0; |
|
| 1187 | 1187 | } else { |
| 1188 | - $new_notification['post_content'][ $add_field ] = ''; |
|
| 1188 | + $new_notification['post_content'][$add_field] = ''; |
|
| 1189 | 1189 | } |
| 1190 | 1190 | unset( $add_field ); |
| 1191 | 1191 | } |
@@ -1209,26 +1209,26 @@ discard block |
||
| 1209 | 1209 | if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) { |
| 1210 | 1210 | foreach ( $post_content['conditions'] as $email_key => $val ) { |
| 1211 | 1211 | if ( is_numeric( $email_key ) ) { |
| 1212 | - $post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1212 | + $post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) ); |
|
| 1213 | 1213 | } |
| 1214 | - unset( $email_key, $val); |
|
| 1214 | + unset( $email_key, $val ); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) { |
| 1220 | - if ( isset($form_options['auto_responder']) && $form_options['auto_responder'] && isset($form_options['ar_email_message']) && $form_options['ar_email_message'] ) { |
|
| 1220 | + if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) { |
|
| 1221 | 1221 | // migrate autoresponder |
| 1222 | 1222 | |
| 1223 | - $email_field = isset($form_options['ar_email_to']) ? $form_options['ar_email_to'] : 0; |
|
| 1224 | - if ( strpos($email_field, '|') ) { |
|
| 1223 | + $email_field = isset( $form_options['ar_email_to'] ) ? $form_options['ar_email_to'] : 0; |
|
| 1224 | + if ( strpos( $email_field, '|' ) ) { |
|
| 1225 | 1225 | // data from entries field |
| 1226 | - $email_field = explode('|', $email_field); |
|
| 1227 | - if ( isset($email_field[1]) ) { |
|
| 1226 | + $email_field = explode( '|', $email_field ); |
|
| 1227 | + if ( isset( $email_field[1] ) ) { |
|
| 1228 | 1228 | $email_field = $email_field[1]; |
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | - if ( is_numeric($email_field) && ! empty($email_field) ) { |
|
| 1231 | + if ( is_numeric( $email_field ) && ! empty( $email_field ) ) { |
|
| 1232 | 1232 | $email_field = '[' . $email_field . ']'; |
| 1233 | 1233 | } |
| 1234 | 1234 | |
@@ -1236,16 +1236,16 @@ discard block |
||
| 1236 | 1236 | $new_notification2 = array( |
| 1237 | 1237 | 'post_content' => array( |
| 1238 | 1238 | 'email_message' => $notification['ar_email_message'], |
| 1239 | - 'email_subject' => isset($notification['ar_email_subject']) ? $notification['ar_email_subject'] : '', |
|
| 1239 | + 'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '', |
|
| 1240 | 1240 | 'email_to' => $email_field, |
| 1241 | - 'plain_text' => isset($notification['ar_plain_text']) ? $notification['ar_plain_text'] : 0, |
|
| 1241 | + 'plain_text' => isset( $notification['ar_plain_text'] ) ? $notification['ar_plain_text'] : 0, |
|
| 1242 | 1242 | 'inc_user_info' => 0, |
| 1243 | 1243 | ), |
| 1244 | 1244 | 'post_name' => $form_id . '_email_' . count( $notifications ), |
| 1245 | 1245 | ); |
| 1246 | 1246 | |
| 1247 | - $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : ''; |
|
| 1248 | - $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : ''; |
|
| 1247 | + $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : ''; |
|
| 1248 | + $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : ''; |
|
| 1249 | 1249 | |
| 1250 | 1250 | if ( ! empty( $reply_to ) ) { |
| 1251 | 1251 | $new_notification2['post_content']['reply_to'] = $reply_to; |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmEntryValidate { |
| 4 | - public static function validate( $values, $exclude = false ) { |
|
| 5 | - FrmEntry::sanitize_entry_post( $values ); |
|
| 6 | - $errors = array(); |
|
| 4 | + public static function validate( $values, $exclude = false ) { |
|
| 5 | + FrmEntry::sanitize_entry_post( $values ); |
|
| 6 | + $errors = array(); |
|
| 7 | 7 | |
| 8 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 9 | - $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 10 | - return $errors; |
|
| 11 | - } |
|
| 8 | + if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 9 | + $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
|
| 10 | + return $errors; |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | 13 | if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
| 14 | - $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 15 | - } |
|
| 14 | + $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | self::set_item_key( $values ); |
| 18 | 18 | |
@@ -69,24 +69,24 @@ discard block |
||
| 69 | 69 | return FrmField::getAll( $where, 'field_order' ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 73 | - $defaults = array( |
|
| 74 | - 'id' => $posted_field->id, |
|
| 75 | - 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 76 | - 'key_pointer' => '', // the pointer in the posted array |
|
| 77 | - 'exclude' => array(), // exclude these field types from validation |
|
| 78 | - ); |
|
| 79 | - $args = wp_parse_args( $args, $defaults ); |
|
| 72 | + public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
|
| 73 | + $defaults = array( |
|
| 74 | + 'id' => $posted_field->id, |
|
| 75 | + 'parent_field_id' => '', // the id of the repeat or embed form |
|
| 76 | + 'key_pointer' => '', // the pointer in the posted array |
|
| 77 | + 'exclude' => array(), // exclude these field types from validation |
|
| 78 | + ); |
|
| 79 | + $args = wp_parse_args( $args, $defaults ); |
|
| 80 | 80 | |
| 81 | - if ( empty($args['parent_field_id']) ) { |
|
| 81 | + if ( empty($args['parent_field_id']) ) { |
|
| 82 | 82 | $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
| 83 | - } else { |
|
| 84 | - // value is from a nested form |
|
| 85 | - $value = $values; |
|
| 86 | - } |
|
| 83 | + } else { |
|
| 84 | + // value is from a nested form |
|
| 85 | + $value = $values; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // Check for values in "Other" fields |
|
| 89 | - FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 88 | + // Check for values in "Other" fields |
|
| 89 | + FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
|
| 90 | 90 | |
| 91 | 91 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 92 | 92 | |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | $value = reset($value); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 98 | + if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
|
| 99 | 99 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 100 | - } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 101 | - $_POST['item_name'] = $value; |
|
| 102 | - } |
|
| 100 | + } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
|
| 101 | + $_POST['item_name'] = $value; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | if ( $value != '' ) { |
| 105 | 105 | self::validate_url_field( $errors, $posted_field, $value, $args ); |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 111 | + FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 112 | 112 | |
| 113 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 113 | + self::validate_recaptcha($errors, $posted_field, $args); |
|
| 114 | 114 | |
| 115 | 115 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 116 | 116 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
| 117 | - } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
| 120 | 120 | if ( FrmField::is_option_true_in_object( $field, 'default_blank' ) && $value == $field->default_value ) { |
@@ -124,32 +124,32 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public static function validate_url_field( &$errors, $field, &$value, $args ) { |
| 126 | 126 | if ( $value == '' || ! in_array( $field->type, array( 'website', 'url', 'image' ) ) ) { |
| 127 | - return; |
|
| 128 | - } |
|
| 127 | + return; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - if ( trim($value) == 'http://' ) { |
|
| 131 | - $value = ''; |
|
| 132 | - } else { |
|
| 133 | - $value = esc_url_raw( $value ); |
|
| 130 | + if ( trim($value) == 'http://' ) { |
|
| 131 | + $value = ''; |
|
| 132 | + } else { |
|
| 133 | + $value = esc_url_raw( $value ); |
|
| 134 | 134 | $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value; |
| 135 | - } |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - // validate the url format |
|
| 137 | + // validate the url format |
|
| 138 | 138 | if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
| 139 | 139 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 140 | 140 | } |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | public static function validate_email_field( &$errors, $field, $value, $args ) { |
| 144 | - if ( $value == '' || $field->type != 'email' ) { |
|
| 145 | - return; |
|
| 146 | - } |
|
| 144 | + if ( $value == '' || $field->type != 'email' ) { |
|
| 145 | + return; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - //validate the email format |
|
| 149 | - if ( ! is_email($value) ) { |
|
| 148 | + //validate the email format |
|
| 149 | + if ( ! is_email($value) ) { |
|
| 150 | 150 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
| 151 | - } |
|
| 152 | - } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | 154 | public static function validate_number_field( &$errors, $field, $value, $args ) { |
| 155 | 155 | //validate the number format |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | public static function validate_recaptcha( &$errors, $field, $args ) { |
| 246 | - if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 247 | - return; |
|
| 248 | - } |
|
| 246 | + if ( $field->type != 'captcha' || FrmAppHelper::is_admin() || apply_filters( 'frm_is_field_hidden', false, $field, stripslashes_deep( $_POST ) ) ) { |
|
| 247 | + return; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | $frm_settings = FrmAppHelper::get_settings(); |
| 251 | 251 | if ( empty( $frm_settings->pubkey ) ) { |
@@ -253,61 +253,61 @@ discard block |
||
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 257 | - // If captcha is missing, check if it was already verified |
|
| 256 | + if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 257 | + // If captcha is missing, check if it was already verified |
|
| 258 | 258 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 259 | - // There was no captcha submitted |
|
| 259 | + // There was no captcha submitted |
|
| 260 | 260 | $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
| 261 | - } |
|
| 262 | - return; |
|
| 263 | - } |
|
| 261 | + } |
|
| 262 | + return; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - $arg_array = array( |
|
| 266 | - 'body' => array( |
|
| 265 | + $arg_array = array( |
|
| 266 | + 'body' => array( |
|
| 267 | 267 | 'secret' => $frm_settings->privkey, |
| 268 | 268 | 'response' => $_POST['g-recaptcha-response'], |
| 269 | 269 | 'remoteip' => FrmAppHelper::get_ip_address(), |
| 270 | 270 | ), |
| 271 | 271 | ); |
| 272 | - $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 273 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 272 | + $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
|
| 273 | + $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 274 | 274 | |
| 275 | - if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 276 | - // What happens when the CAPTCHA was entered incorrectly |
|
| 275 | + if ( isset( $response['success'] ) && ! $response['success'] ) { |
|
| 276 | + // What happens when the CAPTCHA was entered incorrectly |
|
| 277 | 277 | $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
| 278 | - } else if ( is_wp_error( $resp ) ) { |
|
| 278 | + } else if ( is_wp_error( $resp ) ) { |
|
| 279 | 279 | $error_string = $resp->get_error_message(); |
| 280 | 280 | $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
| 281 | 281 | $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
| 282 | - } |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * check for spam |
|
| 287 | - * @param boolean $exclude |
|
| 288 | - * @param array $values |
|
| 289 | - * @param array $errors by reference |
|
| 290 | - */ |
|
| 291 | - public static function spam_check( $exclude, $values, &$errors ) { |
|
| 292 | - if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 293 | - // only check spam if there are no other errors |
|
| 294 | - return; |
|
| 295 | - } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * check for spam |
|
| 287 | + * @param boolean $exclude |
|
| 288 | + * @param array $values |
|
| 289 | + * @param array $errors by reference |
|
| 290 | + */ |
|
| 291 | + public static function spam_check( $exclude, $values, &$errors ) { |
|
| 292 | + if ( ! empty( $exclude ) || ! isset( $values['item_meta'] ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { |
|
| 293 | + // only check spam if there are no other errors |
|
| 294 | + return; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | 297 | if ( self::is_honeypot_spam() || self::is_spam_bot() ) { |
| 298 | 298 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( self::blacklist_check( $values ) ) { |
|
| 302 | - $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
| 303 | - } |
|
| 301 | + if ( self::blacklist_check( $values ) ) { |
|
| 302 | + $errors['spam'] = __( 'Your entry appears to be blacklist spam!', 'formidable' ); |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - if ( self::is_akismet_spam( $values ) ) { |
|
| 305 | + if ( self::is_akismet_spam( $values ) ) { |
|
| 306 | 306 | if ( self::is_akismet_enabled_for_user( $values['form_id'] ) ) { |
| 307 | 307 | $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); |
| 308 | 308 | } |
| 309 | - } |
|
| 310 | - } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | 312 | private static function is_honeypot_spam() { |
| 313 | 313 | $honeypot_value = FrmAppHelper::get_param( 'frm_verify', '', 'get', 'sanitize_text_field' ); |
@@ -329,15 +329,15 @@ discard block |
||
| 329 | 329 | return ( isset( $form->options['akismet'] ) && ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] != 'logged' || ! is_user_logged_in() ) ); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public static function blacklist_check( $values ) { |
|
| 333 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 334 | - return false; |
|
| 335 | - } |
|
| 332 | + public static function blacklist_check( $values ) { |
|
| 333 | + if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 334 | + return false; |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 338 | - if ( empty( $mod_keys ) ) { |
|
| 339 | - return false; |
|
| 340 | - } |
|
| 337 | + $mod_keys = trim( get_option( 'blacklist_keys' ) ); |
|
| 338 | + if ( empty( $mod_keys ) ) { |
|
| 339 | + return false; |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | 342 | $content = FrmEntriesHelper::entry_array_to_string( $values ); |
| 343 | 343 | if ( empty( $content ) ) { |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $user_info = self::get_spam_check_user_info( $values ); |
| 350 | 350 | |
| 351 | 351 | return wp_blacklist_check( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent ); |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | 355 | * Check entries for Akismet spam |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | FrmEntry::sanitize_entry_post( $values ); |
| 6 | 6 | $errors = array(); |
| 7 | 7 | |
| 8 | - if ( ! isset($values['form_id']) || ! isset($values['item_meta']) ) { |
|
| 8 | + if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
|
| 9 | 9 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
| 10 | 10 | return $errors; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { |
|
| 13 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values['frm_submit_entry_' . $values['form_id']] ) || ! wp_verify_nonce( $values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce' ) ) ) { |
|
| 14 | 14 | $errors['form'] = __( 'You do not have permission to do that', 'formidable' ); |
| 15 | 15 | } |
| 16 | 16 | |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | $args = wp_parse_args( $args, $defaults ); |
| 69 | 69 | |
| 70 | - if ( empty($args['parent_field_id']) ) { |
|
| 71 | - $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; |
|
| 70 | + if ( empty( $args['parent_field_id'] ) ) { |
|
| 71 | + $value = isset( $values['item_meta'][$args['id']] ) ? $values['item_meta'][$args['id']] : ''; |
|
| 72 | 72 | } else { |
| 73 | 73 | // value is from a nested form |
| 74 | 74 | $value = $values; |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 81 | 81 | |
| 82 | 82 | // Reset arrays with only one value if it's not a field where array keys need to be preserved |
| 83 | - if ( is_array($value) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 84 | - $value = reset($value); |
|
| 83 | + if ( is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) ) { |
|
| 84 | + $value = reset( $value ); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | if ( $posted_field->required == '1' && ! is_array( $value ) && trim( $value ) == '' ) { |
| 88 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 88 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
|
| 89 | 89 | } else if ( $posted_field->type == 'text' && ! isset( $_POST['item_name'] ) ) { |
| 90 | 90 | $_POST['item_name'] = $value; |
| 91 | 91 | } |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - FrmEntriesHelper::set_posted_value($posted_field, $value, $args); |
|
| 100 | + FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
|
| 101 | 101 | |
| 102 | - self::validate_recaptcha($errors, $posted_field, $args); |
|
| 102 | + self::validate_recaptcha( $errors, $posted_field, $args ); |
|
| 103 | 103 | |
| 104 | 104 | $errors = apply_filters( 'frm_validate_' . $posted_field->type . '_field_entry', $errors, $posted_field, $value, $args ); |
| 105 | 105 | $errors = apply_filters( 'frm_validate_field_entry', $errors, $posted_field, $value, $args ); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( trim($value) == 'http://' ) { |
|
| 119 | + if ( trim( $value ) == 'http://' ) { |
|
| 120 | 120 | $value = ''; |
| 121 | 121 | } else { |
| 122 | 122 | $value = esc_url_raw( $value ); |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // validate the url format |
| 127 | - if ( ! preg_match('/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value) ) { |
|
| 128 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 127 | + if ( ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) { |
|
| 128 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | //validate the email format |
| 138 | - if ( ! is_email($value) ) { |
|
| 139 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 138 | + if ( ! is_email( $value ) ) { |
|
| 139 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( ! is_numeric( $value) ) { |
|
| 150 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 149 | + if ( ! is_numeric( $value ) ) { |
|
| 150 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // validate number settings |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | if ( $frm_settings->use_html && isset( $field->field_options['minnum'] ) && isset( $field->field_options['maxnum'] ) ) { |
| 158 | 158 | //minnum maxnum |
| 159 | 159 | if ( (float) $value < $field->field_options['minnum'] ) { |
| 160 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a higher number', 'formidable' ); |
|
| 160 | + $errors['field' . $args['id']] = __( 'Please select a higher number', 'formidable' ); |
|
| 161 | 161 | } else if ( (float) $value > $field->field_options['maxnum'] ) { |
| 162 | - $errors[ 'field' . $args['id'] ] = __( 'Please select a lower number', 'formidable' ); |
|
| 162 | + $errors['field' . $args['id']] = __( 'Please select a lower number', 'formidable' ); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $pattern = self::phone_format( $field ); |
| 172 | 172 | |
| 173 | 173 | if ( ! preg_match( $pattern, $value ) ) { |
| 174 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 174 | + $errors['field' . $args['id']] = FrmFieldsHelper::get_error_msg( $field, 'invalid' ); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if ( ! isset($_POST['g-recaptcha-response']) ) { |
|
| 245 | + if ( ! isset( $_POST['g-recaptcha-response'] ) ) { |
|
| 246 | 246 | // If captcha is missing, check if it was already verified |
| 247 | 247 | if ( ! isset( $_POST['recaptcha_checked'] ) || ! wp_verify_nonce( $_POST['recaptcha_checked'], 'frm_ajax' ) ) { |
| 248 | 248 | // There was no captcha submitted |
| 249 | - $errors[ 'field' . $args['id'] ] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 249 | + $errors['field' . $args['id']] = __( 'The captcha is missing from this form', 'formidable' ); |
|
| 250 | 250 | } |
| 251 | 251 | return; |
| 252 | 252 | } |
@@ -259,15 +259,15 @@ discard block |
||
| 259 | 259 | ), |
| 260 | 260 | ); |
| 261 | 261 | $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $arg_array ); |
| 262 | - $response = json_decode(wp_remote_retrieve_body( $resp ), true); |
|
| 262 | + $response = json_decode( wp_remote_retrieve_body( $resp ), true ); |
|
| 263 | 263 | |
| 264 | 264 | if ( isset( $response['success'] ) && ! $response['success'] ) { |
| 265 | 265 | // What happens when the CAPTCHA was entered incorrectly |
| 266 | - $errors[ 'field' . $args['id'] ] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 266 | + $errors['field' . $args['id']] = ( ! isset( $field->field_options['invalid'] ) || $field->field_options['invalid'] == '' ) ? $frm_settings->re_msg : $field->field_options['invalid']; |
|
| 267 | 267 | } else if ( is_wp_error( $resp ) ) { |
| 268 | 268 | $error_string = $resp->get_error_message(); |
| 269 | - $errors[ 'field' . $args['id'] ] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 270 | - $errors[ 'field' . $args['id'] ] .= ' ' . $error_string; |
|
| 269 | + $errors['field' . $args['id']] = __( 'There was a problem verifying your recaptcha', 'formidable' ); |
|
| 270 | + $errors['field' . $args['id']] .= ' ' . $error_string; |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | private static function is_akismet_spam( $values ) { |
| 312 | 312 | global $wpcom_api_key; |
| 313 | - return ( is_callable('Akismet::http_post') && ( get_option('wordpress_api_key') || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 313 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | private static function is_akismet_enabled_for_user( $form_id ) { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | public static function blacklist_check( $values ) { |
| 322 | - if ( ! apply_filters('frm_check_blacklist', true, $values) ) { |
|
| 322 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| 376 | 376 | $datas['referrer'] = isset( $_SERVER['HTTP_REFERER'] ) ? FrmAppHelper::get_server_value( 'HTTP_REFERER' ) : false; |
| 377 | 377 | $datas['blog_lang'] = get_locale(); |
| 378 | - $datas['blog_charset'] = get_option('blog_charset'); |
|
| 378 | + $datas['blog_charset'] = get_option( 'blog_charset' ); |
|
| 379 | 379 | |
| 380 | 380 | if ( akismet_test_mode() ) { |
| 381 | 381 | $datas['is_test'] = 'true'; |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | |
| 430 | 430 | // Send any potentially useful $_SERVER vars, but avoid sending junk we don't need. |
| 431 | 431 | if ( $include_value ) { |
| 432 | - $datas[ $key ] = $value; |
|
| 432 | + $datas[$key] = $value; |
|
| 433 | 433 | } |
| 434 | 434 | unset( $key, $value ); |
| 435 | 435 | } |
@@ -10,41 +10,41 @@ discard block |
||
| 10 | 10 | <?php |
| 11 | 11 | |
| 12 | 12 | } else if ( $field['type'] == 'radio' ) { |
| 13 | - $read_only = false; |
|
| 13 | + $read_only = false; |
|
| 14 | 14 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
| 15 | - $read_only = true; ?> |
|
| 15 | + $read_only = true; ?> |
|
| 16 | 16 | <input type="hidden" value="<?php echo esc_attr( $field['value'] ) ?>" name="<?php echo esc_attr( $field_name ) ?>" /> |
| 17 | 17 | <?php |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 20 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 22 | - } else if ( is_array($field['options']) ) { |
|
| 23 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 22 | + } else if ( is_array($field['options']) ) { |
|
| 23 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
| 25 | - continue; |
|
| 26 | - } |
|
| 25 | + continue; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 28 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
| 31 | 31 | |
| 32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 34 | - } |
|
| 35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 34 | + } |
|
| 35 | + $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 36 | 36 | |
| 37 | - $other_opt = false; |
|
| 38 | - $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
| 39 | - ?> |
|
| 37 | + $other_opt = false; |
|
| 38 | + $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
|
| 39 | + ?> |
|
| 40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
| 41 | - echo $checked; |
|
| 42 | - do_action('frm_field_input_html', $field); |
|
| 41 | + echo $checked; |
|
| 42 | + do_action('frm_field_input_html', $field); |
|
| 43 | 43 | ?>/><?php |
| 44 | 44 | |
| 45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 46 | 46 | echo ' ' . $opt . '</label>'; |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | FrmFieldsHelper::include_other_input( array( |
| 50 | 50 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -53,58 +53,58 @@ discard block |
||
| 53 | 53 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
| 54 | 54 | ) ); |
| 55 | 55 | |
| 56 | - unset( $other_opt, $other_args ); |
|
| 56 | + unset( $other_opt, $other_args ); |
|
| 57 | 57 | ?></div> |
| 58 | 58 | <?php |
| 59 | - } |
|
| 60 | - } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | } else if ( $field['type'] == 'select' ) { |
| 62 | 62 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php' ); |
| 63 | 63 | } else if ( $field['type'] == 'checkbox' ) { |
| 64 | - $checked_values = $field['value']; |
|
| 65 | - $read_only = false; |
|
| 64 | + $checked_values = $field['value']; |
|
| 65 | + $read_only = false; |
|
| 66 | 66 | |
| 67 | 67 | if ( FrmField::is_read_only( $field ) && ! FrmAppHelper::is_admin() ) { |
| 68 | - $read_only = true; |
|
| 69 | - if ( $checked_values ) { |
|
| 70 | - foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 68 | + $read_only = true; |
|
| 69 | + if ( $checked_values ) { |
|
| 70 | + foreach ( (array) $checked_values as $checked_value ) { ?> |
|
| 71 | 71 | <input type="hidden" value="<?php echo esc_attr( $checked_value ) ?>" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 72 | 72 | <?php |
| 73 | - } |
|
| 74 | - } else { ?> |
|
| 73 | + } |
|
| 74 | + } else { ?> |
|
| 75 | 75 | <input type="hidden" value="" name="<?php echo esc_attr( $field_name ) ?>[]" /> |
| 76 | 76 | <?php |
| 77 | - } |
|
| 78 | - } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 80 | + if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 82 | - } else if ( $field['options'] ) { |
|
| 83 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 85 | - continue; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 91 | - |
|
| 92 | - // Check if other opt, and get values for other field if needed |
|
| 93 | - $other_opt = false; |
|
| 82 | + } else if ( $field['options'] ) { |
|
| 83 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 84 | + if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | + $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 91 | + |
|
| 92 | + // Check if other opt, and get values for other field if needed |
|
| 93 | + $other_opt = false; |
|
| 94 | 94 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field', 'field_name', 'opt_key' ), $other_opt, $checked ); |
| 95 | 95 | |
| 96 | - ?> |
|
| 96 | + ?> |
|
| 97 | 97 | <div class="<?php echo esc_attr( apply_filters( 'frm_checkbox_class', 'frm_checkbox', $field, $field_val ) ) ?>" id="<?php echo esc_attr( FrmFieldsHelper::get_checkbox_id( $field, $opt_key ) ) ?>"><?php |
| 98 | 98 | |
| 99 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 100 | - ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 101 | - } |
|
| 99 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 100 | + ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 104 | 104 | |
| 105 | - if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 105 | + if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
|
| 106 | 106 | echo ' ' . $opt . '</label>'; |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | FrmFieldsHelper::include_other_input( array( |
| 110 | 110 | 'other_opt' => $other_opt, 'read_only' => $read_only, |
@@ -113,17 +113,17 @@ discard block |
||
| 113 | 113 | 'html_id' => $html_id, 'opt_key' => $opt_key, |
| 114 | 114 | ) ); |
| 115 | 115 | |
| 116 | - unset( $other_opt, $other_args, $checked ); |
|
| 116 | + unset( $other_opt, $other_args, $checked ); |
|
| 117 | 117 | |
| 118 | - ?></div> |
|
| 118 | + ?></div> |
|
| 119 | 119 | <?php |
| 120 | - } |
|
| 121 | - } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | 122 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 123 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 124 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 125 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 126 | - } |
|
| 123 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 124 | + if ( ! empty($frm_settings->pubkey) ) { |
|
| 125 | + FrmFieldsHelper::display_recaptcha($field); |
|
| 126 | + } |
|
| 127 | 127 | } else { |
| 128 | 128 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
| 129 | 129 | do_action( 'frm_form_field_' . $field['type'], $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php if ( in_array( $field['type'], array( 'email', 'url', 'text' ) ) ) { ?> |
| 2 | -<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action('frm_field_input_html', $field) ?>/> |
|
| 2 | +<input type="<?php echo ( $frm_settings->use_html || $field['type'] == 'password' ) ? $field['type'] : 'text'; ?>" id="<?php echo esc_attr( $html_id ) ?>" name="<?php echo esc_attr( $field_name ) ?>" value="<?php echo esc_attr( $field['value'] ) ?>" <?php do_action( 'frm_field_input_html', $field ) ?>/> |
|
| 3 | 3 | <?php } else if ( $field['type'] == 'textarea' ) { ?> |
| 4 | 4 | <textarea name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id ) ?>" <?php |
| 5 | 5 | if ( $field['max'] ) { |
| 6 | 6 | echo 'rows="' . esc_attr( $field['max'] ) . '" '; |
| 7 | 7 | } |
| 8 | -do_action('frm_field_input_html', $field); |
|
| 9 | -?>><?php echo FrmAppHelper::esc_textarea($field['value']) ?></textarea> |
|
| 8 | +do_action( 'frm_field_input_html', $field ); |
|
| 9 | +?>><?php echo FrmAppHelper::esc_textarea( $field['value'] ) ?></textarea> |
|
| 10 | 10 | <?php |
| 11 | 11 | |
| 12 | 12 | } else if ( $field['type'] == 'radio' ) { |
@@ -17,29 +17,29 @@ discard block |
||
| 17 | 17 | <?php |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 20 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 21 | 21 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 22 | - } else if ( is_array($field['options']) ) { |
|
| 22 | + } else if ( is_array( $field['options'] ) ) { |
|
| 23 | 23 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 24 | 24 | if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] != $opt_key ) ) { |
| 25 | 25 | continue; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 29 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); ?> |
|
| 28 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 29 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); ?> |
|
| 30 | 30 | <div class="<?php echo esc_attr( apply_filters( 'frm_radio_class', 'frm_radio', $field, $field_val ) ) ?>"><?php |
| 31 | 31 | |
| 32 | 32 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 33 | 33 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 34 | 34 | } |
| 35 | - $checked = FrmAppHelper::check_selected($field['value'], $field_val) ? 'checked="checked" ' : ' '; |
|
| 35 | + $checked = FrmAppHelper::check_selected( $field['value'], $field_val ) ? 'checked="checked" ' : ' '; |
|
| 36 | 36 | |
| 37 | 37 | $other_opt = false; |
| 38 | 38 | $other_args = FrmFieldsHelper::prepare_other_input( compact( 'field_name', 'opt_key', 'field' ), $other_opt, $checked ); |
| 39 | 39 | ?> |
| 40 | 40 | <input type="radio" name="<?php echo esc_attr( $field_name ) ?>" id="<?php echo esc_attr( $html_id . '-' . $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php |
| 41 | 41 | echo $checked; |
| 42 | - do_action('frm_field_input_html', $field); |
|
| 42 | + do_action( 'frm_field_input_html', $field ); |
|
| 43 | 43 | ?>/><?php |
| 44 | 44 | |
| 45 | 45 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
@@ -77,17 +77,17 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( isset($field['post_field']) && $field['post_field'] == 'post_category' ) { |
|
| 80 | + if ( isset( $field['post_field'] ) && $field['post_field'] == 'post_category' ) { |
|
| 81 | 81 | do_action( 'frm_after_checkbox', array( 'field' => $field, 'field_name' => $field_name, 'type' => $field['type'] ) ); |
| 82 | 82 | } else if ( $field['options'] ) { |
| 83 | 83 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 84 | - if ( isset($atts) && isset($atts['opt']) && ($atts['opt'] !== $opt_key) ) { |
|
| 84 | + if ( isset( $atts ) && isset( $atts['opt'] ) && ( $atts['opt'] !== $opt_key ) ) { |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 89 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 90 | - $checked = FrmAppHelper::check_selected($checked_values, $field_val) ? ' checked="checked"' : ''; |
|
| 88 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 89 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 90 | + $checked = FrmAppHelper::check_selected( $checked_values, $field_val ) ? ' checked="checked"' : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check if other opt, and get values for other field if needed |
| 93 | 93 | $other_opt = false; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | ?><label for="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>"><?php |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action('frm_field_input_html', $field) ?> /><?php |
|
| 103 | + ?><input type="checkbox" name="<?php echo esc_attr( $field_name ) ?>[<?php echo ( $other_opt ? esc_attr( $opt_key ) : '' ) ?>]" id="<?php echo esc_attr( $html_id ) ?>-<?php echo esc_attr( $opt_key ) ?>" value="<?php echo esc_attr( $field_val ) ?>" <?php echo $checked ?> <?php do_action( 'frm_field_input_html', $field ) ?> /><?php |
|
| 104 | 104 | |
| 105 | 105 | if ( ! isset( $atts ) || ! isset( $atts['label'] ) || $atts['label'] ) { |
| 106 | 106 | echo ' ' . $opt . '</label>'; |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | } else if ( $field['type'] == 'captcha' && ! FrmAppHelper::is_admin() ) { |
| 123 | 123 | $frm_settings = FrmAppHelper::get_settings(); |
| 124 | - if ( ! empty($frm_settings->pubkey) ) { |
|
| 125 | - FrmFieldsHelper::display_recaptcha($field); |
|
| 124 | + if ( ! empty( $frm_settings->pubkey ) ) { |
|
| 125 | + FrmFieldsHelper::display_recaptcha( $field ); |
|
| 126 | 126 | } |
| 127 | 127 | } else { |
| 128 | 128 | do_action( 'frm_form_fields', $field, $field_name, compact( 'errors', 'html_id' ) ); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | </div> |
| 6 | 6 | </div> |
| 7 | 7 | <?php |
| 8 | - return; |
|
| 8 | + return; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | global $frm_vars; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } else { |
| 37 | 37 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
| 38 | 38 | } |
| 39 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
| 39 | + do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | // close open collapsible toggle div |
| 63 | 63 | if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
| 64 | - echo "</div>\n"; |
|
| 65 | - unset($frm_vars['collapse_div']); |
|
| 64 | + echo "</div>\n"; |
|
| 65 | + unset($frm_vars['collapse_div']); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( empty($values) || ! isset($values['fields']) || empty($values['fields']) ) { ?> |
|
| 3 | -<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class($form); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
| 2 | +if ( empty( $values ) || ! isset( $values['fields'] ) || empty( $values['fields'] ) ) { ?> |
|
| 3 | +<div class="frm_forms <?php echo FrmFormsHelper::get_form_style_class( $form ); ?>" id="frm_form_<?php echo esc_attr( $form->id ) ?>_container"> |
|
| 4 | 4 | <div class="frm_error_style"><strong><?php _e( 'Oops!', 'formidable' ) ?></strong> <?php printf( __( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ), '<a href="' . esc_url( admin_url( '?page=formidable&frm_action=edit&id=' . $form->id ) ) . '">', '</a>' ) ?> |
| 5 | 5 | </div> |
| 6 | 6 | </div> |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>"> |
| 19 | 19 | <fieldset> |
| 20 | 20 | <?php echo FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ); ?> |
| 21 | -<?php do_action( 'frm_after_title', compact('form') ) ?> |
|
| 22 | -<input type="hidden" name="frm_action" value="<?php echo esc_attr($form_action) ?>" /> |
|
| 23 | -<input type="hidden" name="form_id" value="<?php echo esc_attr($form->id) ?>" /> |
|
| 24 | -<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr($frm_hide_fields) ?>" /> |
|
| 25 | -<input type="hidden" name="form_key" value="<?php echo esc_attr($form->form_key) ?>" /> |
|
| 21 | +<?php do_action( 'frm_after_title', compact( 'form' ) ) ?> |
|
| 22 | +<input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ) ?>" /> |
|
| 23 | +<input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ) ?>" /> |
|
| 24 | +<input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ) ?>" value="<?php echo esc_attr( $frm_hide_fields ) ?>" /> |
|
| 25 | +<input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ) ?>" /> |
|
| 26 | 26 | <input type="hidden" name="item_meta[0]" value="" /> |
| 27 | 27 | <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?> |
| 28 | -<input type="text" class="frm_hidden" id="frm_verify" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param('frm_verify' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> /> |
|
| 28 | +<input type="text" class="frm_hidden" id="frm_verify" name="frm_verify" value="<?php echo esc_attr( FrmAppHelper::get_param( 'frm_verify' ) ) ?>" <?php FrmFormsHelper::maybe_hide_inline() ?> /> |
|
| 29 | 29 | |
| 30 | 30 | <?php if ( isset( $id ) ) { ?><input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /><?php } |
| 31 | 31 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } else { |
| 37 | 37 | do_action( 'frm_show_other_field_type', $field, $form, array( 'action' => $form_action ) ); |
| 38 | 38 | } |
| 39 | - do_action('frm_get_field_scripts', $field, $form, $form->id); |
|
| 39 | + do_action( 'frm_get_field_scripts', $field, $form, $form->id ); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | if ( FrmAppHelper::is_admin() ) { ?> |
| 45 | 45 | <div class="frm_form_field form-field"> |
| 46 | 46 | <label class="frm_primary_label"><?php _e( 'Entry Key', 'formidable' ) ?></label> |
| 47 | -<input type="text" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
| 47 | +<input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
| 48 | 48 | </div> |
| 49 | 49 | <?php } else { ?> |
| 50 | -<input type="hidden" name="item_key" value="<?php echo esc_attr($values['item_key']) ?>" /> |
|
| 50 | +<input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ) ?>" /> |
|
| 51 | 51 | <?php } |
| 52 | 52 | |
| 53 | -do_action('frm_entry_form', $form, $form_action, $errors); |
|
| 53 | +do_action( 'frm_entry_form', $form, $form_action, $errors ); |
|
| 54 | 54 | |
| 55 | 55 | global $frm_vars; |
| 56 | 56 | // close open section div |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // close open collapsible toggle div |
| 63 | -if ( isset($frm_vars['collapse_div']) && $frm_vars['collapse_div'] ) { |
|
| 63 | +if ( isset( $frm_vars['collapse_div'] ) && $frm_vars['collapse_div'] ) { |
|
| 64 | 64 | echo "</div>\n"; |
| 65 | - unset($frm_vars['collapse_div']); |
|
| 65 | + unset( $frm_vars['collapse_div'] ); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | -echo FrmFormsHelper::replace_shortcodes($values['after_html'], $form); |
|
| 68 | +echo FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ); |
|
| 69 | 69 | |
| 70 | 70 | if ( FrmForm::show_submit( $form ) ) { |
| 71 | 71 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | </fieldset> |
| 79 | 79 | </div> |
| 80 | 80 | <?php |
| 81 | -if ( has_action('frm_entries_footer_scripts') ) { |
|
| 81 | +if ( has_action( 'frm_entries_footer_scripts' ) ) { |
|
| 82 | 82 | ?><script type="text/javascript"><?php |
| 83 | 83 | do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); |
| 84 | 84 | ?></script><?php |
@@ -7,71 +7,71 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | - |
|
| 17 | - $values = array(); |
|
| 18 | - |
|
| 19 | - foreach ( $defaults as $var => $default ) { |
|
| 20 | - if ( $var == 'field_options' ) { |
|
| 21 | - $values['field_options'] = array(); |
|
| 22 | - foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $values[ $var ] = $default; |
|
| 28 | - } |
|
| 29 | - unset($var, $default); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | - if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | - $values['field_options']['data_type'] = $setting; |
|
| 35 | - } else { |
|
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | - $values['options'] = serialize( array( |
|
| 42 | - __( 'Option 1', 'formidable' ), |
|
| 43 | - __( 'Option 2', 'formidable' ), |
|
| 44 | - ) ); |
|
| 45 | - } else if ( $type == 'select' ) { |
|
| 46 | - $values['options'] = serialize( array( |
|
| 47 | - '', __( 'Option 1', 'formidable' ), |
|
| 48 | - ) ); |
|
| 49 | - } else if ( $type == 'textarea' ) { |
|
| 50 | - $values['field_options']['max'] = '5'; |
|
| 51 | - } else if ( $type == 'captcha' ) { |
|
| 52 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | - $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | - } else if ( 'url' == $type ) { |
|
| 55 | - $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | - } |
|
| 10 | + if ( strpos($type, '|') ) { |
|
| 11 | + list($type, $setting) = explode('|', $type); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 16 | + |
|
| 17 | + $values = array(); |
|
| 18 | + |
|
| 19 | + foreach ( $defaults as $var => $default ) { |
|
| 20 | + if ( $var == 'field_options' ) { |
|
| 21 | + $values['field_options'] = array(); |
|
| 22 | + foreach ( $default as $opt_var => $opt_default ) { |
|
| 23 | + $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | + unset($opt_var, $opt_default); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $values[ $var ] = $default; |
|
| 28 | + } |
|
| 29 | + unset($var, $default); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( isset( $setting ) && ! empty( $setting ) ) { |
|
| 33 | + if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
|
| 34 | + $values['field_options']['data_type'] = $setting; |
|
| 35 | + } else { |
|
| 36 | + $values['field_options'][ $setting ] = 1; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ( $type == 'radio' || $type == 'checkbox' ) { |
|
| 41 | + $values['options'] = serialize( array( |
|
| 42 | + __( 'Option 1', 'formidable' ), |
|
| 43 | + __( 'Option 2', 'formidable' ), |
|
| 44 | + ) ); |
|
| 45 | + } else if ( $type == 'select' ) { |
|
| 46 | + $values['options'] = serialize( array( |
|
| 47 | + '', __( 'Option 1', 'formidable' ), |
|
| 48 | + ) ); |
|
| 49 | + } else if ( $type == 'textarea' ) { |
|
| 50 | + $values['field_options']['max'] = '5'; |
|
| 51 | + } else if ( $type == 'captcha' ) { |
|
| 52 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 53 | + $values['invalid'] = $frm_settings->re_msg; |
|
| 54 | + } else if ( 'url' == $type ) { |
|
| 55 | + $values['name'] = __( 'Website', 'formidable' ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | $fields = FrmField::field_selection(); |
| 59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 59 | + $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 60 | 60 | |
| 61 | - if ( isset( $fields[ $type ] ) ) { |
|
| 62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | - } |
|
| 61 | + if ( isset( $fields[ $type ] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset($fields); |
|
| 66 | 66 | |
| 67 | - return $values; |
|
| 68 | - } |
|
| 67 | + return $values; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | public static function get_html_id( $field, $plus = '' ) { |
| 71 | 71 | return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field ); |
| 72 | - } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 74 | + public static function setup_edit_vars( $record, $doing_ajax = false ) { |
|
| 75 | 75 | $values = array( 'id' => $record->id, 'form_id' => $record->form_id ); |
| 76 | 76 | $defaults = array( |
| 77 | 77 | 'name' => $record->name, |
@@ -84,86 +84,86 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | if ( $doing_ajax ) { |
| 87 | - $values = $values + $defaults; |
|
| 88 | - $values['form_name'] = ''; |
|
| 87 | + $values = $values + $defaults; |
|
| 88 | + $values['form_name'] = ''; |
|
| 89 | 89 | } else { |
| 90 | 90 | foreach ( $defaults as $var => $default ) { |
| 91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | - unset($var, $default); |
|
| 93 | - } |
|
| 91 | + $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset($var, $default); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
| 96 | - } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | unset( $defaults ); |
| 99 | 99 | |
| 100 | - $values['options'] = $record->options; |
|
| 101 | - $values['field_options'] = $record->field_options; |
|
| 100 | + $values['options'] = $record->options; |
|
| 101 | + $values['field_options'] = $record->field_options; |
|
| 102 | 102 | |
| 103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 103 | + $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 104 | 104 | |
| 105 | 105 | if ( $values['type'] == 'captcha' ) { |
| 106 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | - $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | - } |
|
| 106 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 107 | + $defaults['invalid'] = $frm_settings->re_msg; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | 110 | foreach ( $defaults as $opt => $default ) { |
| 111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | - unset($opt, $default); |
|
| 113 | - } |
|
| 111 | + $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | + unset($opt, $default); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 115 | + $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 116 | 116 | |
| 117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 118 | - } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | - $field_options = array( |
|
| 122 | - 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | - 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | - 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 120 | + public static function get_default_field_opts( $type, $field, $limit = false ) { |
|
| 121 | + $field_options = array( |
|
| 122 | + 'size' => '', 'max' => '', 'label' => '', 'blank' => '', |
|
| 123 | + 'required_indicator' => '*', 'invalid' => '', 'separate_value' => 0, |
|
| 124 | + 'clear_on_focus' => 0, 'default_blank' => 0, 'classes' => '', |
|
| 125 | 125 | 'custom_html' => '', 'captcha_size' => 'normal', 'captcha_theme' => 'light', |
| 126 | - ); |
|
| 126 | + ); |
|
| 127 | 127 | |
| 128 | 128 | if ( $limit ) { |
| 129 | - return $field_options; |
|
| 129 | + return $field_options; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - global $wpdb; |
|
| 132 | + global $wpdb; |
|
| 133 | 133 | |
| 134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 134 | + $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 135 | 135 | |
| 136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 137 | 137 | |
| 138 | - $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 138 | + $field_count = FrmDb::get_var( 'frm_fields', array( 'form_id' => $form_id ), 'field_order', array( 'order_by' => 'field_order DESC' ) ); |
|
| 139 | 139 | |
| 140 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | - return array( |
|
| 142 | - 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 140 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 141 | + return array( |
|
| 142 | + 'name' => __( 'Untitled', 'formidable' ), 'description' => '', |
|
| 143 | 143 | 'field_key' => $key, 'type' => $type, 'options' => '', 'default_value' => '', |
| 144 | 144 | 'field_order' => $field_count + 1, 'required' => false, |
| 145 | - 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | - 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 145 | + 'blank' => $frm_settings->blank_msg, 'unique_msg' => $frm_settings->unique_msg, |
|
| 146 | + 'invalid' => __( 'This field is invalid', 'formidable' ), 'form_id' => $form_id, |
|
| 147 | 147 | 'field_options' => $field_options, |
| 148 | - ); |
|
| 149 | - } |
|
| 148 | + ); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | - global $wpdb; |
|
| 151 | + public static function fill_field( &$values, $field, $form_id, $new_key = '' ) { |
|
| 152 | + global $wpdb; |
|
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | - $values['form_id'] = $form_id; |
|
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | - |
|
| 159 | - foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @since 2.0 |
|
| 166 | - */ |
|
| 155 | + $values['form_id'] = $form_id; |
|
| 156 | + $values['options'] = maybe_serialize($field->options); |
|
| 157 | + $values['default_value'] = maybe_serialize($field->default_value); |
|
| 158 | + |
|
| 159 | + foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
|
| 160 | + $values[ $col ] = $field->{$col}; |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @since 2.0 |
|
| 166 | + */ |
|
| 167 | 167 | public static function get_error_msg( $field, $error ) { |
| 168 | 168 | $frm_settings = FrmAppHelper::get_settings(); |
| 169 | 169 | $default_settings = $frm_settings->default_options(); |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | public static function get_default_html( $type = 'text' ) { |
| 193 | 193 | if ( apply_filters( 'frm_normal_field_type_html', true, $type ) ) { |
| 194 | 194 | $input = ( in_array( $type, array( 'radio', 'checkbox', 'data' ) ) ) ? '<div class="frm_opt_container">[input]</div>' : '[input]'; |
| 195 | - $for = ''; |
|
| 195 | + $for = ''; |
|
| 196 | 196 | if ( ! in_array( $type, array( 'radio', 'checkbox', 'data', 'scale' ) ) ) { |
| 197 | - $for = 'for="field_[key]"'; |
|
| 198 | - } |
|
| 197 | + $for = 'for="field_[key]"'; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $default_html = <<<DEFAULT_HTML |
|
| 200 | + $default_html = <<<DEFAULT_HTML |
|
| 201 | 201 | <div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]"> |
| 202 | 202 | <label $for class="frm_primary_label">[field_name] |
| 203 | 203 | <span class="frm_required">[required_label]</span> |
@@ -207,82 +207,82 @@ discard block |
||
| 207 | 207 | [if error]<div class="frm_error">[error]</div>[/if error] |
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | - } else { |
|
| 210 | + } else { |
|
| 211 | 211 | $default_html = apply_filters('frm_other_custom_html', '', $type); |
| 212 | - } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | - } |
|
| 214 | + return apply_filters('frm_custom_html', $default_html, $type); |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | + $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 219 | 219 | |
| 220 | - $defaults = array( |
|
| 220 | + $defaults = array( |
|
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
| 222 | 222 | 'field_id' => $field['id'], |
| 223 | - 'field_plus_id' => '', |
|
| 224 | - 'section_id' => '', |
|
| 225 | - ); |
|
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 227 | - $field_name = $args['field_name']; |
|
| 228 | - $field_id = $args['field_id']; |
|
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 223 | + 'field_plus_id' => '', |
|
| 224 | + 'section_id' => '', |
|
| 225 | + ); |
|
| 226 | + $args = wp_parse_args($args, $defaults); |
|
| 227 | + $field_name = $args['field_name']; |
|
| 228 | + $field_id = $args['field_id']; |
|
| 229 | + $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | - $field_name .= '[]'; |
|
| 233 | - } |
|
| 231 | + if ( FrmField::is_multiple_select($field) ) { |
|
| 232 | + $field_name .= '[]'; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - //replace [id] |
|
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 235 | + //replace [id] |
|
| 236 | + $html = str_replace('[id]', $field_id, $html); |
|
| 237 | 237 | |
| 238 | - // Remove the for attribute for captcha |
|
| 239 | - if ( $field['type'] == 'captcha' ) { |
|
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | - } |
|
| 238 | + // Remove the for attribute for captcha |
|
| 239 | + if ( $field['type'] == 'captcha' ) { |
|
| 240 | + $html = str_replace(' for="field_[key]"', '', $html); |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - // set the label for |
|
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 243 | + // set the label for |
|
| 244 | + $html = str_replace('field_[key]', $html_id, $html); |
|
| 245 | 245 | |
| 246 | - //replace [key] |
|
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 246 | + //replace [key] |
|
| 247 | + $html = str_replace('[key]', $field['field_key'], $html); |
|
| 248 | 248 | |
| 249 | - //replace [description] and [required_label] and [error] |
|
| 249 | + //replace [description] and [required_label] and [error] |
|
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | - if ( ! is_array( $errors ) ) { |
|
| 252 | - $errors = array(); |
|
| 253 | - } |
|
| 251 | + if ( ! is_array( $errors ) ) { |
|
| 252 | + $errors = array(); |
|
| 253 | + } |
|
| 254 | 254 | $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
| 255 | 255 | |
| 256 | - //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | - if ( $field['type'] == 'divider' ) { |
|
| 258 | - if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | - $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | - } else { |
|
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | - } |
|
| 263 | - } |
|
| 256 | + //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
|
| 257 | + if ( $field['type'] == 'divider' ) { |
|
| 258 | + if ( FrmField::is_option_true( $field, 'description' ) ) { |
|
| 259 | + $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
|
| 260 | + } else { |
|
| 261 | + $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | 265 | foreach ( array( 'description' => $field['description'], 'required_label' => $required, 'error' => $error ) as $code => $value ) { |
| 266 | - self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | - } |
|
| 266 | + self::remove_inline_conditions( ( $value && $value != '' ), $code, $value, $html ); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - //replace [required_class] |
|
| 269 | + //replace [required_class] |
|
| 270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | + $html = str_replace('[required_class]', $required_class, $html); |
|
| 272 | 272 | |
| 273 | - //replace [label_position] |
|
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | - $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 273 | + //replace [label_position] |
|
| 274 | + $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 275 | + $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
|
| 276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 277 | 277 | |
| 278 | - //replace [field_name] |
|
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 278 | + //replace [field_name] |
|
| 279 | + $html = str_replace('[field_name]', $field['name'], $html); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | - //replace [entry_key] |
|
| 284 | - $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 283 | + //replace [entry_key] |
|
| 284 | + $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
|
| 285 | + $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 286 | 286 | |
| 287 | 287 | if ( $form ) { |
| 288 | 288 | $form = (array) $form; |
@@ -296,57 +296,57 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | self::process_wp_shortcodes( $html ); |
| 298 | 298 | |
| 299 | - //replace [input] |
|
| 300 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | - global $frm_vars; |
|
| 302 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 299 | + //replace [input] |
|
| 300 | + preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 301 | + global $frm_vars; |
|
| 302 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 303 | 303 | |
| 304 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 304 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 305 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 306 | 306 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 307 | 307 | |
| 308 | - $replace_with = ''; |
|
| 308 | + $replace_with = ''; |
|
| 309 | 309 | |
| 310 | - if ( $tag == 'input' ) { |
|
| 311 | - if ( isset($atts['opt']) ) { |
|
| 312 | - $atts['opt']--; |
|
| 313 | - } |
|
| 310 | + if ( $tag == 'input' ) { |
|
| 311 | + if ( isset($atts['opt']) ) { |
|
| 312 | + $atts['opt']--; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | - if ( isset($atts['class']) ) { |
|
| 317 | - unset($atts['class']); |
|
| 318 | - } |
|
| 315 | + $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | + if ( isset($atts['class']) ) { |
|
| 317 | + unset($atts['class']); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - $field['shortcodes'] = $atts; |
|
| 321 | - ob_start(); |
|
| 320 | + $field['shortcodes'] = $atts; |
|
| 321 | + ob_start(); |
|
| 322 | 322 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php' ); |
| 323 | - $replace_with = ob_get_contents(); |
|
| 324 | - ob_end_clean(); |
|
| 325 | - } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | - } |
|
| 323 | + $replace_with = ob_get_contents(); |
|
| 324 | + ob_end_clean(); |
|
| 325 | + } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
|
| 326 | + $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | - } |
|
| 329 | + $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - $html .= "\n"; |
|
| 332 | + $html .= "\n"; |
|
| 333 | 333 | |
| 334 | - //Return html if conf_field to prevent loop |
|
| 335 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | - return $html; |
|
| 337 | - } |
|
| 334 | + //Return html if conf_field to prevent loop |
|
| 335 | + if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 336 | + return $html; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - //If field is in repeating section |
|
| 340 | - if ( $args['section_id'] ) { |
|
| 341 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | - } else { |
|
| 343 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | - } |
|
| 339 | + //If field is in repeating section |
|
| 340 | + if ( $args['section_id'] ) { |
|
| 341 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 342 | + } else { |
|
| 343 | + $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | self::remove_collapse_shortcode( $html ); |
| 347 | 347 | |
| 348 | - return $html; |
|
| 349 | - } |
|
| 348 | + return $html; |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * This filters shortcodes in the field HTML |
@@ -411,46 +411,46 @@ discard block |
||
| 411 | 411 | return $classes; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 415 | - if ( $no_vars ) { |
|
| 414 | + public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) { |
|
| 415 | + if ( $no_vars ) { |
|
| 416 | 416 | $html = str_replace( '[if ' . $code . ']', '', $html ); |
| 417 | 417 | $html = str_replace( '[/if ' . $code . ']', '', $html ); |
| 418 | - } else { |
|
| 418 | + } else { |
|
| 419 | 419 | $html = preg_replace( '/(\[if\s+' . $code . '\])(.*?)(\[\/if\s+' . $code . '\])/mis', '', $html ); |
| 420 | - } |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | $html = str_replace( '[' . $code . ']', $replace_with, $html ); |
| 423 | - } |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | 425 | public static function get_shortcode_tag( $shortcodes, $short_key, $args ) { |
| 426 | 426 | $args = wp_parse_args( $args, array( 'conditional' => false, 'conditional_check' => false, 'foreach' => false ) ); |
| 427 | - if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 428 | - $args['conditional_check'] = true; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - $prefix = ''; |
|
| 432 | - if ( $args['conditional_check'] ) { |
|
| 433 | - if ( $args['conditional'] ) { |
|
| 434 | - $prefix = 'if '; |
|
| 435 | - } else if ( $args['foreach'] ) { |
|
| 436 | - $prefix = 'foreach '; |
|
| 437 | - } |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 441 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 442 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 443 | - $tag = str_replace(']', '', $tag); |
|
| 444 | - $tags = explode(' ', $tag); |
|
| 445 | - if ( is_array($tags) ) { |
|
| 446 | - $tag = $tags[0]; |
|
| 447 | - } |
|
| 448 | - } else { |
|
| 449 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - return $tag; |
|
| 453 | - } |
|
| 427 | + if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) { |
|
| 428 | + $args['conditional_check'] = true; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + $prefix = ''; |
|
| 432 | + if ( $args['conditional_check'] ) { |
|
| 433 | + if ( $args['conditional'] ) { |
|
| 434 | + $prefix = 'if '; |
|
| 435 | + } else if ( $args['foreach'] ) { |
|
| 436 | + $prefix = 'foreach '; |
|
| 437 | + } |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + $with_tags = $args['conditional_check'] ? 3 : 2; |
|
| 441 | + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 442 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 443 | + $tag = str_replace(']', '', $tag); |
|
| 444 | + $tags = explode(' ', $tag); |
|
| 445 | + if ( is_array($tags) ) { |
|
| 446 | + $tag = $tags[0]; |
|
| 447 | + } |
|
| 448 | + } else { |
|
| 449 | + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + return $tag; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | 455 | /** |
| 456 | 456 | * Remove [collapse_this] if it's still included after all processing |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | $api_js_url = apply_filters( 'frm_recaptcha_js_url', $api_js_url ); |
| 490 | 490 | |
| 491 | - wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 492 | - wp_enqueue_script( 'recaptcha-api' ); |
|
| 491 | + wp_register_script( 'recaptcha-api', $api_js_url, '', true ); |
|
| 492 | + wp_enqueue_script( 'recaptcha-api' ); |
|
| 493 | 493 | |
| 494 | 494 | // for reverse compatability |
| 495 | 495 | $field['captcha_size'] = ( $field['captcha_size'] == 'default' ) ? 'normal' : $field['captcha_size']; |
@@ -497,40 +497,40 @@ discard block |
||
| 497 | 497 | ?> |
| 498 | 498 | <div id="field_<?php echo esc_attr( $field['field_key'] ) ?>" class="<?php echo esc_attr( $class_prefix ) ?>g-recaptcha" data-sitekey="<?php echo esc_attr( $frm_settings->pubkey ) ?>" data-size="<?php echo esc_attr( $field['captcha_size'] ) ?>" data-theme="<?php echo esc_attr( $field['captcha_theme'] ) ?>"></div> |
| 499 | 499 | <?php |
| 500 | - } |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | public static function show_single_option( $field ) { |
| 503 | - $field_name = $field['name']; |
|
| 504 | - $html_id = self::get_html_id($field); |
|
| 505 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 506 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 507 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 503 | + $field_name = $field['name']; |
|
| 504 | + $html_id = self::get_html_id($field); |
|
| 505 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 506 | + $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 507 | + $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 508 | 508 | |
| 509 | - // If this is an "Other" option, get the HTML for it |
|
| 509 | + // If this is an "Other" option, get the HTML for it |
|
| 510 | 510 | if ( self::is_other_opt( $opt_key ) ) { |
| 511 | - // Get string for Other text field, if needed |
|
| 511 | + // Get string for Other text field, if needed |
|
| 512 | 512 | $other_val = self::get_other_val( compact( 'opt_key', 'field' ) ); |
| 513 | 513 | require( FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/other-option.php' ); |
| 514 | - } else { |
|
| 514 | + } else { |
|
| 515 | 515 | require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' ); |
| 516 | - } |
|
| 517 | - } |
|
| 518 | - } |
|
| 516 | + } |
|
| 517 | + } |
|
| 518 | + } |
|
| 519 | 519 | |
| 520 | 520 | public static function get_term_link( $tax_id ) { |
| 521 | - $tax = get_taxonomy($tax_id); |
|
| 522 | - if ( ! $tax ) { |
|
| 523 | - return; |
|
| 524 | - } |
|
| 521 | + $tax = get_taxonomy($tax_id); |
|
| 522 | + if ( ! $tax ) { |
|
| 523 | + return; |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - $link = sprintf( |
|
| 527 | - __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 526 | + $link = sprintf( |
|
| 527 | + __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
|
| 528 | 528 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 529 | - ); |
|
| 530 | - unset($tax); |
|
| 529 | + ); |
|
| 530 | + unset($tax); |
|
| 531 | 531 | |
| 532 | - return $link; |
|
| 533 | - } |
|
| 532 | + return $link; |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | public static function value_meets_condition( $observed_value, $cond, $hide_opt ) { |
| 536 | 536 | // Remove white space from hide_opt |
@@ -541,199 +541,199 @@ discard block |
||
| 541 | 541 | $observed_value = wp_kses_post( $observed_value ); |
| 542 | 542 | $hide_opt = wp_kses_post( $hide_opt ); |
| 543 | 543 | |
| 544 | - if ( is_array($observed_value) ) { |
|
| 545 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - $m = false; |
|
| 549 | - if ( $cond == '==' ) { |
|
| 550 | - $m = $observed_value == $hide_opt; |
|
| 551 | - } else if ( $cond == '!=' ) { |
|
| 552 | - $m = $observed_value != $hide_opt; |
|
| 553 | - } else if ( $cond == '>' ) { |
|
| 554 | - $m = $observed_value > $hide_opt; |
|
| 555 | - } else if ( $cond == '<' ) { |
|
| 556 | - $m = $observed_value < $hide_opt; |
|
| 557 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 558 | - $m = stripos($observed_value, $hide_opt); |
|
| 559 | - if ( $cond == 'not LIKE' ) { |
|
| 560 | - $m = ( $m === false ) ? true : false; |
|
| 561 | - } else { |
|
| 562 | - $m = ( $m === false ) ? false : true; |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - return $m; |
|
| 566 | - } |
|
| 544 | + if ( is_array($observed_value) ) { |
|
| 545 | + return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + $m = false; |
|
| 549 | + if ( $cond == '==' ) { |
|
| 550 | + $m = $observed_value == $hide_opt; |
|
| 551 | + } else if ( $cond == '!=' ) { |
|
| 552 | + $m = $observed_value != $hide_opt; |
|
| 553 | + } else if ( $cond == '>' ) { |
|
| 554 | + $m = $observed_value > $hide_opt; |
|
| 555 | + } else if ( $cond == '<' ) { |
|
| 556 | + $m = $observed_value < $hide_opt; |
|
| 557 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 558 | + $m = stripos($observed_value, $hide_opt); |
|
| 559 | + if ( $cond == 'not LIKE' ) { |
|
| 560 | + $m = ( $m === false ) ? true : false; |
|
| 561 | + } else { |
|
| 562 | + $m = ( $m === false ) ? false : true; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + return $m; |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 569 | - $m = false; |
|
| 570 | - if ( $cond == '==' ) { |
|
| 571 | - if ( is_array($hide_opt) ) { |
|
| 572 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 573 | - $m = empty($m) ? false : true; |
|
| 574 | - } else { |
|
| 575 | - $m = in_array($hide_opt, $observed_value); |
|
| 576 | - } |
|
| 577 | - } else if ( $cond == '!=' ) { |
|
| 578 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 579 | - } else if ( $cond == '>' ) { |
|
| 580 | - $min = min($observed_value); |
|
| 581 | - $m = $min > $hide_opt; |
|
| 582 | - } else if ( $cond == '<' ) { |
|
| 583 | - $max = max($observed_value); |
|
| 584 | - $m = $max < $hide_opt; |
|
| 585 | - } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 586 | - foreach ( $observed_value as $ob ) { |
|
| 587 | - $m = strpos($ob, $hide_opt); |
|
| 588 | - if ( $m !== false ) { |
|
| 589 | - $m = true; |
|
| 590 | - break; |
|
| 591 | - } |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - if ( $cond == 'not LIKE' ) { |
|
| 595 | - $m = ( $m === false ) ? true : false; |
|
| 596 | - } |
|
| 597 | - } |
|
| 598 | - |
|
| 599 | - return $m; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * Replace a few basic shortcodes and field ids |
|
| 604 | - * @since 2.0 |
|
| 605 | - * @return string |
|
| 606 | - */ |
|
| 569 | + $m = false; |
|
| 570 | + if ( $cond == '==' ) { |
|
| 571 | + if ( is_array($hide_opt) ) { |
|
| 572 | + $m = array_intersect($hide_opt, $observed_value); |
|
| 573 | + $m = empty($m) ? false : true; |
|
| 574 | + } else { |
|
| 575 | + $m = in_array($hide_opt, $observed_value); |
|
| 576 | + } |
|
| 577 | + } else if ( $cond == '!=' ) { |
|
| 578 | + $m = ! in_array($hide_opt, $observed_value); |
|
| 579 | + } else if ( $cond == '>' ) { |
|
| 580 | + $min = min($observed_value); |
|
| 581 | + $m = $min > $hide_opt; |
|
| 582 | + } else if ( $cond == '<' ) { |
|
| 583 | + $max = max($observed_value); |
|
| 584 | + $m = $max < $hide_opt; |
|
| 585 | + } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
|
| 586 | + foreach ( $observed_value as $ob ) { |
|
| 587 | + $m = strpos($ob, $hide_opt); |
|
| 588 | + if ( $m !== false ) { |
|
| 589 | + $m = true; |
|
| 590 | + break; |
|
| 591 | + } |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + if ( $cond == 'not LIKE' ) { |
|
| 595 | + $m = ( $m === false ) ? true : false; |
|
| 596 | + } |
|
| 597 | + } |
|
| 598 | + |
|
| 599 | + return $m; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * Replace a few basic shortcodes and field ids |
|
| 604 | + * @since 2.0 |
|
| 605 | + * @return string |
|
| 606 | + */ |
|
| 607 | 607 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 608 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 609 | - $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 610 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 611 | - } |
|
| 608 | + if ( strpos($value, '[sitename]') !== false ) { |
|
| 609 | + $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
|
| 610 | + $value = str_replace('[sitename]', $new_value, $value); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 614 | - $value = do_shortcode($value); |
|
| 613 | + $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 614 | + $value = do_shortcode($value); |
|
| 615 | 615 | |
| 616 | - return $value; |
|
| 617 | - } |
|
| 616 | + return $value; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | public static function get_shortcodes( $content, $form_id ) { |
| 620 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 621 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 622 | - } |
|
| 620 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 621 | + return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 624 | + $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
|
| 625 | 625 | |
| 626 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 626 | + $tagregexp = self::allowed_shortcodes($fields); |
|
| 627 | 627 | |
| 628 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 628 | + preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 629 | 629 | |
| 630 | - return $matches; |
|
| 631 | - } |
|
| 630 | + return $matches; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | public static function allowed_shortcodes( $fields = array() ) { |
| 634 | - $tagregexp = array( |
|
| 635 | - 'editlink', 'id', 'key', 'ip', |
|
| 636 | - 'siteurl', 'sitename', 'admin_email', |
|
| 637 | - 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 634 | + $tagregexp = array( |
|
| 635 | + 'editlink', 'id', 'key', 'ip', |
|
| 636 | + 'siteurl', 'sitename', 'admin_email', |
|
| 637 | + 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', |
|
| 638 | 638 | 'parent[-|_]id', |
| 639 | - ); |
|
| 639 | + ); |
|
| 640 | 640 | |
| 641 | - foreach ( $fields as $field ) { |
|
| 642 | - $tagregexp[] = $field->id; |
|
| 643 | - $tagregexp[] = $field->field_key; |
|
| 644 | - } |
|
| 641 | + foreach ( $fields as $field ) { |
|
| 642 | + $tagregexp[] = $field->id; |
|
| 643 | + $tagregexp[] = $field->field_key; |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | - $tagregexp = implode('|', $tagregexp); |
|
| 647 | - return $tagregexp; |
|
| 648 | - } |
|
| 646 | + $tagregexp = implode('|', $tagregexp); |
|
| 647 | + return $tagregexp; |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | 650 | public static function replace_content_shortcodes( $content, $entry, $shortcodes ) { |
| 651 | - $shortcode_values = array( |
|
| 652 | - 'id' => $entry->id, |
|
| 653 | - 'key' => $entry->item_key, |
|
| 654 | - 'ip' => $entry->ip, |
|
| 655 | - ); |
|
| 651 | + $shortcode_values = array( |
|
| 652 | + 'id' => $entry->id, |
|
| 653 | + 'key' => $entry->item_key, |
|
| 654 | + 'ip' => $entry->ip, |
|
| 655 | + ); |
|
| 656 | 656 | |
| 657 | - foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 657 | + foreach ( $shortcodes[0] as $short_key => $tag ) { |
|
| 658 | 658 | if ( empty( $tag ) ) { |
| 659 | 659 | continue; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 662 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 663 | 663 | |
| 664 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 664 | + if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 665 | 665 | $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
| 666 | - $tags = explode(' ', $tag); |
|
| 667 | - if ( is_array($tags) ) { |
|
| 668 | - $tag = $tags[0]; |
|
| 669 | - } |
|
| 670 | - } else { |
|
| 671 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - switch ( $tag ) { |
|
| 675 | - case 'id': |
|
| 676 | - case 'key': |
|
| 677 | - case 'ip': |
|
| 678 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 679 | - break; |
|
| 680 | - |
|
| 681 | - case 'user_agent': |
|
| 682 | - case 'user-agent': |
|
| 683 | - $entry->description = maybe_unserialize($entry->description); |
|
| 666 | + $tags = explode(' ', $tag); |
|
| 667 | + if ( is_array($tags) ) { |
|
| 668 | + $tag = $tags[0]; |
|
| 669 | + } |
|
| 670 | + } else { |
|
| 671 | + $tag = $shortcodes[2][ $short_key ]; |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + switch ( $tag ) { |
|
| 675 | + case 'id': |
|
| 676 | + case 'key': |
|
| 677 | + case 'ip': |
|
| 678 | + $replace_with = $shortcode_values[ $tag ]; |
|
| 679 | + break; |
|
| 680 | + |
|
| 681 | + case 'user_agent': |
|
| 682 | + case 'user-agent': |
|
| 683 | + $entry->description = maybe_unserialize($entry->description); |
|
| 684 | 684 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 685 | - break; |
|
| 686 | - |
|
| 687 | - case 'created_at': |
|
| 688 | - case 'created-at': |
|
| 689 | - case 'updated_at': |
|
| 690 | - case 'updated-at': |
|
| 691 | - if ( isset($atts['format']) ) { |
|
| 692 | - $time_format = ' '; |
|
| 693 | - } else { |
|
| 694 | - $atts['format'] = get_option('date_format'); |
|
| 695 | - $time_format = ''; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - $this_tag = str_replace('-', '_', $tag); |
|
| 699 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 700 | - unset($this_tag); |
|
| 701 | - break; |
|
| 702 | - |
|
| 703 | - case 'created_by': |
|
| 704 | - case 'created-by': |
|
| 705 | - case 'updated_by': |
|
| 706 | - case 'updated-by': |
|
| 707 | - $this_tag = str_replace('-', '_', $tag); |
|
| 685 | + break; |
|
| 686 | + |
|
| 687 | + case 'created_at': |
|
| 688 | + case 'created-at': |
|
| 689 | + case 'updated_at': |
|
| 690 | + case 'updated-at': |
|
| 691 | + if ( isset($atts['format']) ) { |
|
| 692 | + $time_format = ' '; |
|
| 693 | + } else { |
|
| 694 | + $atts['format'] = get_option('date_format'); |
|
| 695 | + $time_format = ''; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + $this_tag = str_replace('-', '_', $tag); |
|
| 699 | + $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 700 | + unset($this_tag); |
|
| 701 | + break; |
|
| 702 | + |
|
| 703 | + case 'created_by': |
|
| 704 | + case 'created-by': |
|
| 705 | + case 'updated_by': |
|
| 706 | + case 'updated-by': |
|
| 707 | + $this_tag = str_replace('-', '_', $tag); |
|
| 708 | 708 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 709 | - unset($this_tag); |
|
| 710 | - break; |
|
| 711 | - |
|
| 712 | - case 'admin_email': |
|
| 713 | - case 'siteurl': |
|
| 714 | - case 'frmurl': |
|
| 715 | - case 'sitename': |
|
| 716 | - case 'get': |
|
| 717 | - $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 718 | - break; |
|
| 719 | - |
|
| 720 | - default: |
|
| 721 | - $field = FrmField::getOne( $tag ); |
|
| 722 | - if ( ! $field ) { |
|
| 723 | - break; |
|
| 724 | - } |
|
| 725 | - |
|
| 726 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 727 | - |
|
| 728 | - $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 729 | - |
|
| 730 | - $atts['entry_id'] = $entry->id; |
|
| 731 | - $atts['entry_key'] = $entry->item_key; |
|
| 732 | - |
|
| 733 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 734 | - $replace_with = $field->name; |
|
| 735 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 736 | - $replace_with = $field->description; |
|
| 709 | + unset($this_tag); |
|
| 710 | + break; |
|
| 711 | + |
|
| 712 | + case 'admin_email': |
|
| 713 | + case 'siteurl': |
|
| 714 | + case 'frmurl': |
|
| 715 | + case 'sitename': |
|
| 716 | + case 'get': |
|
| 717 | + $replace_with = self::dynamic_default_values( $tag, $atts ); |
|
| 718 | + break; |
|
| 719 | + |
|
| 720 | + default: |
|
| 721 | + $field = FrmField::getOne( $tag ); |
|
| 722 | + if ( ! $field ) { |
|
| 723 | + break; |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 727 | + |
|
| 728 | + $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
|
| 729 | + |
|
| 730 | + $atts['entry_id'] = $entry->id; |
|
| 731 | + $atts['entry_key'] = $entry->item_key; |
|
| 732 | + |
|
| 733 | + if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 734 | + $replace_with = $field->name; |
|
| 735 | + } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 736 | + $replace_with = $field->description; |
|
| 737 | 737 | } else { |
| 738 | 738 | $string_value = $replace_with; |
| 739 | 739 | if ( is_array( $replace_with ) ) { |
@@ -747,82 +747,82 @@ discard block |
||
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - unset($field); |
|
| 751 | - break; |
|
| 752 | - } |
|
| 750 | + unset($field); |
|
| 751 | + break; |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - if ( isset($replace_with) ) { |
|
| 755 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 756 | - } |
|
| 754 | + if ( isset($replace_with) ) { |
|
| 755 | + $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 756 | + } |
|
| 757 | 757 | |
| 758 | - unset($atts, $conditional, $replace_with); |
|
| 758 | + unset($atts, $conditional, $replace_with); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | return $content; |
| 762 | - } |
|
| 763 | - |
|
| 764 | - /** |
|
| 765 | - * Get the value to replace a few standard shortcodes |
|
| 766 | - * |
|
| 767 | - * @since 2.0 |
|
| 768 | - * @return string |
|
| 769 | - */ |
|
| 770 | - public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 771 | - $new_value = ''; |
|
| 772 | - switch ( $tag ) { |
|
| 773 | - case 'admin_email': |
|
| 774 | - $new_value = get_option('admin_email'); |
|
| 775 | - break; |
|
| 776 | - case 'siteurl': |
|
| 777 | - $new_value = FrmAppHelper::site_url(); |
|
| 778 | - break; |
|
| 779 | - case 'frmurl': |
|
| 780 | - $new_value = FrmAppHelper::plugin_url(); |
|
| 781 | - break; |
|
| 782 | - case 'sitename': |
|
| 783 | - $new_value = FrmAppHelper::site_name(); |
|
| 784 | - break; |
|
| 785 | - case 'get': |
|
| 786 | - $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 787 | - break; |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - return $new_value; |
|
| 791 | - } |
|
| 792 | - |
|
| 793 | - /** |
|
| 794 | - * Process the [get] shortcode |
|
| 795 | - * |
|
| 796 | - * @since 2.0 |
|
| 797 | - * @return string|array |
|
| 798 | - */ |
|
| 799 | - public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 800 | - if ( ! isset($atts['param']) ) { |
|
| 801 | - return ''; |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - if ( strpos($atts['param'], '[') ) { |
|
| 805 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 806 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 810 | - $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 811 | - |
|
| 812 | - if ( $new_value == '' ) { |
|
| 813 | - if ( ! isset($atts['prev_val']) ) { |
|
| 814 | - $atts['prev_val'] = ''; |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 821 | - $new_value = implode(', ', $new_value); |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - return $new_value; |
|
| 825 | - } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + /** |
|
| 765 | + * Get the value to replace a few standard shortcodes |
|
| 766 | + * |
|
| 767 | + * @since 2.0 |
|
| 768 | + * @return string |
|
| 769 | + */ |
|
| 770 | + public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) { |
|
| 771 | + $new_value = ''; |
|
| 772 | + switch ( $tag ) { |
|
| 773 | + case 'admin_email': |
|
| 774 | + $new_value = get_option('admin_email'); |
|
| 775 | + break; |
|
| 776 | + case 'siteurl': |
|
| 777 | + $new_value = FrmAppHelper::site_url(); |
|
| 778 | + break; |
|
| 779 | + case 'frmurl': |
|
| 780 | + $new_value = FrmAppHelper::plugin_url(); |
|
| 781 | + break; |
|
| 782 | + case 'sitename': |
|
| 783 | + $new_value = FrmAppHelper::site_name(); |
|
| 784 | + break; |
|
| 785 | + case 'get': |
|
| 786 | + $new_value = self::process_get_shortcode( $atts, $return_array ); |
|
| 787 | + break; |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + return $new_value; |
|
| 791 | + } |
|
| 792 | + |
|
| 793 | + /** |
|
| 794 | + * Process the [get] shortcode |
|
| 795 | + * |
|
| 796 | + * @since 2.0 |
|
| 797 | + * @return string|array |
|
| 798 | + */ |
|
| 799 | + public static function process_get_shortcode( $atts, $return_array = false ) { |
|
| 800 | + if ( ! isset($atts['param']) ) { |
|
| 801 | + return ''; |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + if ( strpos($atts['param'], '[') ) { |
|
| 805 | + $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 806 | + $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 810 | + $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
|
| 811 | + |
|
| 812 | + if ( $new_value == '' ) { |
|
| 813 | + if ( ! isset($atts['prev_val']) ) { |
|
| 814 | + $atts['prev_val'] = ''; |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + if ( is_array($new_value) && ! $return_array ) { |
|
| 821 | + $new_value = implode(', ', $new_value); |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + return $new_value; |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | 827 | public static function get_display_value( $replace_with, $field, $atts = array() ) { |
| 828 | 828 | $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
@@ -830,14 +830,14 @@ discard block |
||
| 830 | 830 | $replace_with = apply_filters( 'frm_get_' . $field->type . '_display_value', $replace_with, $field, $atts ); |
| 831 | 831 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 832 | 832 | |
| 833 | - if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 834 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 835 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 836 | - if ( is_array($replace_with) ) { |
|
| 837 | - $replace_with = implode("\n", $replace_with); |
|
| 838 | - } |
|
| 839 | - $replace_with = wpautop($replace_with); |
|
| 840 | - } |
|
| 833 | + if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
|
| 834 | + $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 835 | + if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 836 | + if ( is_array($replace_with) ) { |
|
| 837 | + $replace_with = implode("\n", $replace_with); |
|
| 838 | + } |
|
| 839 | + $replace_with = wpautop($replace_with); |
|
| 840 | + } |
|
| 841 | 841 | unset( $autop ); |
| 842 | 842 | } else if ( is_array( $replace_with ) ) { |
| 843 | 843 | $replace_with = implode( $sep, $replace_with ); |
@@ -847,37 +847,37 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | public static function get_field_types( $type ) { |
| 850 | - $single_input = array( |
|
| 851 | - 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 852 | - 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 853 | - 'user_id', 'tag', 'password', |
|
| 854 | - ); |
|
| 850 | + $single_input = array( |
|
| 851 | + 'text', 'textarea', 'rte', 'number', 'email', 'url', |
|
| 852 | + 'image', 'file', 'date', 'phone', 'hidden', 'time', |
|
| 853 | + 'user_id', 'tag', 'password', |
|
| 854 | + ); |
|
| 855 | 855 | $multiple_input = array( 'radio', 'checkbox', 'select', 'scale', 'lookup' ); |
| 856 | 856 | $other_type = array( 'html', 'break' ); |
| 857 | 857 | |
| 858 | 858 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 859 | 859 | |
| 860 | - $field_types = array(); |
|
| 861 | - if ( in_array($type, $single_input) ) { |
|
| 862 | - self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 863 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 864 | - self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 865 | - } else if ( in_array($type, $other_type) ) { |
|
| 866 | - self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 860 | + $field_types = array(); |
|
| 861 | + if ( in_array($type, $single_input) ) { |
|
| 862 | + self::field_types_for_input( $single_input, $field_selection, $field_types ); |
|
| 863 | + } else if ( in_array($type, $multiple_input) ) { |
|
| 864 | + self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
|
| 865 | + } else if ( in_array($type, $other_type) ) { |
|
| 866 | + self::field_types_for_input( $other_type, $field_selection, $field_types ); |
|
| 867 | 867 | } else if ( isset( $field_selection[ $type ] ) ) { |
| 868 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 869 | - } |
|
| 868 | + $field_types[ $type ] = $field_selection[ $type ]; |
|
| 869 | + } |
|
| 870 | 870 | |
| 871 | 871 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
| 872 | - return $field_types; |
|
| 873 | - } |
|
| 872 | + return $field_types; |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 876 | - foreach ( $inputs as $input ) { |
|
| 877 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 878 | - unset($input); |
|
| 879 | - } |
|
| 880 | - } |
|
| 875 | + private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
|
| 876 | + foreach ( $inputs as $input ) { |
|
| 877 | + $field_types[ $input ] = $fields[ $input ]; |
|
| 878 | + unset($input); |
|
| 879 | + } |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | 883 | * Check if current field option is an "other" option |
@@ -891,14 +891,14 @@ discard block |
||
| 891 | 891 | return $opt_key && strpos( $opt_key, 'other_' ) === 0; |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | - /** |
|
| 895 | - * Get value that belongs in "Other" text box |
|
| 896 | - * |
|
| 897 | - * @since 2.0.6 |
|
| 898 | - * |
|
| 899 | - * @param array $args |
|
| 900 | - */ |
|
| 901 | - public static function get_other_val( $args ) { |
|
| 894 | + /** |
|
| 895 | + * Get value that belongs in "Other" text box |
|
| 896 | + * |
|
| 897 | + * @since 2.0.6 |
|
| 898 | + * |
|
| 899 | + * @param array $args |
|
| 900 | + */ |
|
| 901 | + public static function get_other_val( $args ) { |
|
| 902 | 902 | $defaults = array( |
| 903 | 903 | 'opt_key' => 0, 'field' => array(), |
| 904 | 904 | 'parent' => false, 'pointer' => false, |
@@ -974,20 +974,20 @@ discard block |
||
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | return $other_val; |
| 977 | - } |
|
| 978 | - |
|
| 979 | - /** |
|
| 980 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 981 | - * Intended for front-end use |
|
| 982 | - * |
|
| 983 | - * @since 2.0.6 |
|
| 984 | - * |
|
| 985 | - * @param array $args should include field, opt_key and field name |
|
| 986 | - * @param boolean $other_opt |
|
| 987 | - * @param string $checked |
|
| 988 | - * @return string $other_val |
|
| 989 | - */ |
|
| 990 | - public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + /** |
|
| 980 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 981 | + * Intended for front-end use |
|
| 982 | + * |
|
| 983 | + * @since 2.0.6 |
|
| 984 | + * |
|
| 985 | + * @param array $args should include field, opt_key and field name |
|
| 986 | + * @param boolean $other_opt |
|
| 987 | + * @param string $checked |
|
| 988 | + * @return string $other_val |
|
| 989 | + */ |
|
| 990 | + public static function prepare_other_input( $args, &$other_opt, &$checked ) { |
|
| 991 | 991 | //Check if this is an "Other" option |
| 992 | 992 | if ( ! self::is_other_opt( $args['opt_key'] ) ) { |
| 993 | 993 | return; |
@@ -1003,8 +1003,8 @@ discard block |
||
| 1003 | 1003 | $checked = 'checked="checked" '; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - return $other_args; |
|
| 1007 | - } |
|
| 1006 | + return $other_args; |
|
| 1007 | + } |
|
| 1008 | 1008 | |
| 1009 | 1009 | /** |
| 1010 | 1010 | * @param array $args |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | * @since 2.0.6 |
| 1055 | 1055 | */ |
| 1056 | 1056 | public static function include_other_input( $args ) { |
| 1057 | - if ( ! $args['other_opt'] ) { |
|
| 1058 | - return; |
|
| 1057 | + if ( ! $args['other_opt'] ) { |
|
| 1058 | + return; |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | $classes = array( 'frm_other_input' ); |
@@ -1076,15 +1076,15 @@ discard block |
||
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | /** |
| 1079 | - * Get the HTML id for an "Other" text field |
|
| 1080 | - * Note: This does not affect fields in repeating sections |
|
| 1081 | - * |
|
| 1082 | - * @since 2.0.08 |
|
| 1083 | - * @param string $type - field type |
|
| 1084 | - * @param string $html_id |
|
| 1085 | - * @param string|boolean $opt_key |
|
| 1086 | - * @return string $other_id |
|
| 1087 | - */ |
|
| 1079 | + * Get the HTML id for an "Other" text field |
|
| 1080 | + * Note: This does not affect fields in repeating sections |
|
| 1081 | + * |
|
| 1082 | + * @since 2.0.08 |
|
| 1083 | + * @param string $type - field type |
|
| 1084 | + * @param string $html_id |
|
| 1085 | + * @param string|boolean $opt_key |
|
| 1086 | + * @return string $other_id |
|
| 1087 | + */ |
|
| 1088 | 1088 | public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) { |
| 1089 | 1089 | $other_id = $html_id; |
| 1090 | 1090 | |
@@ -1142,10 +1142,10 @@ discard block |
||
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | public static function switch_field_ids( $val ) { |
| 1145 | - global $frm_duplicate_ids; |
|
| 1146 | - $replace = array(); |
|
| 1147 | - $replace_with = array(); |
|
| 1148 | - foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1145 | + global $frm_duplicate_ids; |
|
| 1146 | + $replace = array(); |
|
| 1147 | + $replace_with = array(); |
|
| 1148 | + foreach ( (array) $frm_duplicate_ids as $old => $new ) { |
|
| 1149 | 1149 | $replace[] = '[if ' . $old . ']'; |
| 1150 | 1150 | $replace_with[] = '[if ' . $new . ']'; |
| 1151 | 1151 | $replace[] = '[if ' . $old . ' '; |
@@ -1160,153 +1160,153 @@ discard block |
||
| 1160 | 1160 | $replace_with[] = '[' . $new . ']'; |
| 1161 | 1161 | $replace[] = '[' . $old . ' '; |
| 1162 | 1162 | $replace_with[] = '[' . $new . ' '; |
| 1163 | - unset($old, $new); |
|
| 1164 | - } |
|
| 1163 | + unset($old, $new); |
|
| 1164 | + } |
|
| 1165 | 1165 | if ( is_array( $val ) ) { |
| 1166 | 1166 | foreach ( $val as $k => $v ) { |
| 1167 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1168 | - unset($k, $v); |
|
| 1169 | - } |
|
| 1170 | - } else { |
|
| 1171 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1172 | - } |
|
| 1173 | - |
|
| 1174 | - return $val; |
|
| 1175 | - } |
|
| 1176 | - |
|
| 1177 | - public static function get_us_states() { |
|
| 1178 | - return apply_filters( 'frm_us_states', array( |
|
| 1179 | - 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1180 | - 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1181 | - 'DC' => 'District of Columbia', |
|
| 1182 | - 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1183 | - 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1184 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1185 | - 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1186 | - 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1187 | - 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1188 | - 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1189 | - 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1190 | - 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1191 | - 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1192 | - 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1193 | - ) ); |
|
| 1194 | - } |
|
| 1195 | - |
|
| 1196 | - public static function get_countries() { |
|
| 1197 | - return apply_filters( 'frm_countries', array( |
|
| 1198 | - __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1199 | - __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1200 | - __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1201 | - __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1202 | - __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1203 | - __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1204 | - __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1205 | - __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1206 | - __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1207 | - __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1208 | - __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1209 | - __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1210 | - __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1211 | - __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1212 | - __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1213 | - __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1214 | - __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1215 | - __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1216 | - __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1217 | - __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1218 | - __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1219 | - __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1220 | - __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1221 | - __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1222 | - __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1223 | - __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1224 | - __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1225 | - __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1226 | - __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1227 | - __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1228 | - __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1229 | - __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1230 | - __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1231 | - __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1232 | - __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1233 | - __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1234 | - __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1235 | - __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1236 | - __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1237 | - __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1238 | - __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1239 | - __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1240 | - __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1241 | - __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1242 | - __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1243 | - __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1244 | - __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1245 | - __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1246 | - __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1247 | - __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1248 | - __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1249 | - __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1250 | - __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1251 | - __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1252 | - __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1253 | - __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1254 | - __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1255 | - __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1256 | - __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1257 | - __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1258 | - __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1259 | - __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1260 | - __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1261 | - __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1262 | - __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1263 | - __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1264 | - __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1265 | - __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1266 | - __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1267 | - __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1268 | - __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1269 | - __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1270 | - __( 'Zimbabwe', 'formidable' ), |
|
| 1271 | - ) ); |
|
| 1272 | - } |
|
| 1167 | + $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1168 | + unset($k, $v); |
|
| 1169 | + } |
|
| 1170 | + } else { |
|
| 1171 | + $val = str_replace($replace, $replace_with, $val); |
|
| 1172 | + } |
|
| 1173 | + |
|
| 1174 | + return $val; |
|
| 1175 | + } |
|
| 1176 | + |
|
| 1177 | + public static function get_us_states() { |
|
| 1178 | + return apply_filters( 'frm_us_states', array( |
|
| 1179 | + 'AL' => 'Alabama', 'AK' => 'Alaska', 'AR' => 'Arkansas', 'AZ' => 'Arizona', |
|
| 1180 | + 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', |
|
| 1181 | + 'DC' => 'District of Columbia', |
|
| 1182 | + 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
|
| 1183 | + 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
|
| 1184 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1185 | + 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
|
| 1186 | + 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
|
| 1187 | + 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
|
| 1188 | + 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', |
|
| 1189 | + 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', |
|
| 1190 | + 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', |
|
| 1191 | + 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', |
|
| 1192 | + 'WI' => 'Wisconsin', 'WY' => 'Wyoming', |
|
| 1193 | + ) ); |
|
| 1194 | + } |
|
| 1195 | + |
|
| 1196 | + public static function get_countries() { |
|
| 1197 | + return apply_filters( 'frm_countries', array( |
|
| 1198 | + __( 'Afghanistan', 'formidable' ), __( 'Albania', 'formidable' ), __( 'Algeria', 'formidable' ), |
|
| 1199 | + __( 'American Samoa', 'formidable' ), __( 'Andorra', 'formidable' ), __( 'Angola', 'formidable' ), |
|
| 1200 | + __( 'Anguilla', 'formidable' ), __( 'Antarctica', 'formidable' ), __( 'Antigua and Barbuda', 'formidable' ), |
|
| 1201 | + __( 'Argentina', 'formidable' ), __( 'Armenia', 'formidable' ), __( 'Aruba', 'formidable' ), |
|
| 1202 | + __( 'Australia', 'formidable' ), __( 'Austria', 'formidable' ), __( 'Azerbaijan', 'formidable' ), |
|
| 1203 | + __( 'Bahamas', 'formidable' ), __( 'Bahrain', 'formidable' ), __( 'Bangladesh', 'formidable' ), |
|
| 1204 | + __( 'Barbados', 'formidable' ), __( 'Belarus', 'formidable' ), __( 'Belgium', 'formidable' ), |
|
| 1205 | + __( 'Belize', 'formidable' ), __( 'Benin', 'formidable' ), __( 'Bermuda', 'formidable' ), |
|
| 1206 | + __( 'Bhutan', 'formidable' ), __( 'Bolivia', 'formidable' ), __( 'Bosnia and Herzegovina', 'formidable' ), |
|
| 1207 | + __( 'Botswana', 'formidable' ), __( 'Brazil', 'formidable' ), __( 'Brunei', 'formidable' ), |
|
| 1208 | + __( 'Bulgaria', 'formidable' ), __( 'Burkina Faso', 'formidable' ), __( 'Burundi', 'formidable' ), |
|
| 1209 | + __( 'Cambodia', 'formidable' ), __( 'Cameroon', 'formidable' ), __( 'Canada', 'formidable' ), |
|
| 1210 | + __( 'Cape Verde', 'formidable' ), __( 'Cayman Islands', 'formidable' ), __( 'Central African Republic', 'formidable' ), |
|
| 1211 | + __( 'Chad', 'formidable' ), __( 'Chile', 'formidable' ), __( 'China', 'formidable' ), |
|
| 1212 | + __( 'Colombia', 'formidable' ), __( 'Comoros', 'formidable' ), __( 'Congo', 'formidable' ), |
|
| 1213 | + __( 'Costa Rica', 'formidable' ), __( 'Côte d\'Ivoire', 'formidable' ), __( 'Croatia', 'formidable' ), |
|
| 1214 | + __( 'Cuba', 'formidable' ), __( 'Cyprus', 'formidable' ), __( 'Czech Republic', 'formidable' ), |
|
| 1215 | + __( 'Denmark', 'formidable' ), __( 'Djibouti', 'formidable' ), __( 'Dominica', 'formidable' ), |
|
| 1216 | + __( 'Dominican Republic', 'formidable' ), __( 'East Timor', 'formidable' ), __( 'Ecuador', 'formidable' ), |
|
| 1217 | + __( 'Egypt', 'formidable' ), __( 'El Salvador', 'formidable' ), __( 'Equatorial Guinea', 'formidable' ), |
|
| 1218 | + __( 'Eritrea', 'formidable' ), __( 'Estonia', 'formidable' ), __( 'Ethiopia', 'formidable' ), |
|
| 1219 | + __( 'Fiji', 'formidable' ), __( 'Finland', 'formidable' ), __( 'France', 'formidable' ), |
|
| 1220 | + __( 'French Guiana', 'formidable' ), __( 'French Polynesia', 'formidable' ), __( 'Gabon', 'formidable' ), |
|
| 1221 | + __( 'Gambia', 'formidable' ), __( 'Georgia', 'formidable' ), __( 'Germany', 'formidable' ), |
|
| 1222 | + __( 'Ghana', 'formidable' ), __( 'Gibraltar', 'formidable' ), __( 'Greece', 'formidable' ), |
|
| 1223 | + __( 'Greenland', 'formidable' ), __( 'Grenada', 'formidable' ), __( 'Guam', 'formidable' ), |
|
| 1224 | + __( 'Guatemala', 'formidable' ), __( 'Guinea', 'formidable' ), __( 'Guinea-Bissau', 'formidable' ), |
|
| 1225 | + __( 'Guyana', 'formidable' ), __( 'Haiti', 'formidable' ), __( 'Honduras', 'formidable' ), |
|
| 1226 | + __( 'Hong Kong', 'formidable' ), __( 'Hungary', 'formidable' ), __( 'Iceland', 'formidable' ), |
|
| 1227 | + __( 'India', 'formidable' ), __( 'Indonesia', 'formidable' ), __( 'Iran', 'formidable' ), |
|
| 1228 | + __( 'Iraq', 'formidable' ), __( 'Ireland', 'formidable' ), __( 'Israel', 'formidable' ), |
|
| 1229 | + __( 'Italy', 'formidable' ), __( 'Jamaica', 'formidable' ), __( 'Japan', 'formidable' ), |
|
| 1230 | + __( 'Jordan', 'formidable' ), __( 'Kazakhstan', 'formidable' ), __( 'Kenya', 'formidable' ), |
|
| 1231 | + __( 'Kiribati', 'formidable' ), __( 'North Korea', 'formidable' ), __( 'South Korea', 'formidable' ), |
|
| 1232 | + __( 'Kuwait', 'formidable' ), __( 'Kyrgyzstan', 'formidable' ), __( 'Laos', 'formidable' ), |
|
| 1233 | + __( 'Latvia', 'formidable' ), __( 'Lebanon', 'formidable' ), __( 'Lesotho', 'formidable' ), |
|
| 1234 | + __( 'Liberia', 'formidable' ), __( 'Libya', 'formidable' ), __( 'Liechtenstein', 'formidable' ), |
|
| 1235 | + __( 'Lithuania', 'formidable' ), __( 'Luxembourg', 'formidable' ), __( 'Macedonia', 'formidable' ), |
|
| 1236 | + __( 'Madagascar', 'formidable' ), __( 'Malawi', 'formidable' ), __( 'Malaysia', 'formidable' ), |
|
| 1237 | + __( 'Maldives', 'formidable' ), __( 'Mali', 'formidable' ), __( 'Malta', 'formidable' ), |
|
| 1238 | + __( 'Marshall Islands', 'formidable' ), __( 'Mauritania', 'formidable' ), __( 'Mauritius', 'formidable' ), |
|
| 1239 | + __( 'Mexico', 'formidable' ), __( 'Micronesia', 'formidable' ), __( 'Moldova', 'formidable' ), |
|
| 1240 | + __( 'Monaco', 'formidable' ), __( 'Mongolia', 'formidable' ), __( 'Montenegro', 'formidable' ), |
|
| 1241 | + __( 'Montserrat', 'formidable' ), __( 'Morocco', 'formidable' ), __( 'Mozambique', 'formidable' ), |
|
| 1242 | + __( 'Myanmar', 'formidable' ), __( 'Namibia', 'formidable' ), __( 'Nauru', 'formidable' ), |
|
| 1243 | + __( 'Nepal', 'formidable' ), __( 'Netherlands', 'formidable' ), __( 'New Zealand', 'formidable' ), |
|
| 1244 | + __( 'Nicaragua', 'formidable' ), __( 'Niger', 'formidable' ), __( 'Nigeria', 'formidable' ), |
|
| 1245 | + __( 'Norway', 'formidable' ), __( 'Northern Mariana Islands', 'formidable' ), __( 'Oman', 'formidable' ), |
|
| 1246 | + __( 'Pakistan', 'formidable' ), __( 'Palau', 'formidable' ), __( 'Palestine', 'formidable' ), |
|
| 1247 | + __( 'Panama', 'formidable' ), __( 'Papua New Guinea', 'formidable' ), __( 'Paraguay', 'formidable' ), |
|
| 1248 | + __( 'Peru', 'formidable' ), __( 'Philippines', 'formidable' ), __( 'Poland', 'formidable' ), |
|
| 1249 | + __( 'Portugal', 'formidable' ), __( 'Puerto Rico', 'formidable' ), __( 'Qatar', 'formidable' ), |
|
| 1250 | + __( 'Romania', 'formidable' ), __( 'Russia', 'formidable' ), __( 'Rwanda', 'formidable' ), |
|
| 1251 | + __( 'Saint Kitts and Nevis', 'formidable' ), __( 'Saint Lucia', 'formidable' ), |
|
| 1252 | + __( 'Saint Vincent and the Grenadines', 'formidable' ), __( 'Samoa', 'formidable' ), |
|
| 1253 | + __( 'San Marino', 'formidable' ), __( 'Sao Tome and Principe', 'formidable' ), __( 'Saudi Arabia', 'formidable' ), |
|
| 1254 | + __( 'Senegal', 'formidable' ), __( 'Serbia and Montenegro', 'formidable' ), __( 'Seychelles', 'formidable' ), |
|
| 1255 | + __( 'Sierra Leone', 'formidable' ), __( 'Singapore', 'formidable' ), __( 'Slovakia', 'formidable' ), |
|
| 1256 | + __( 'Slovenia', 'formidable' ), __( 'Solomon Islands', 'formidable' ), __( 'Somalia', 'formidable' ), |
|
| 1257 | + __( 'South Africa', 'formidable' ), __( 'South Sudan', 'formidable' ), |
|
| 1258 | + __( 'Spain', 'formidable' ), __( 'Sri Lanka', 'formidable' ), |
|
| 1259 | + __( 'Sudan', 'formidable' ), __( 'Suriname', 'formidable' ), __( 'Swaziland', 'formidable' ), |
|
| 1260 | + __( 'Sweden', 'formidable' ), __( 'Switzerland', 'formidable' ), __( 'Syria', 'formidable' ), |
|
| 1261 | + __( 'Taiwan', 'formidable' ), __( 'Tajikistan', 'formidable' ), __( 'Tanzania', 'formidable' ), |
|
| 1262 | + __( 'Thailand', 'formidable' ), __( 'Togo', 'formidable' ), __( 'Tonga', 'formidable' ), |
|
| 1263 | + __( 'Trinidad and Tobago', 'formidable' ), __( 'Tunisia', 'formidable' ), __( 'Turkey', 'formidable' ), |
|
| 1264 | + __( 'Turkmenistan', 'formidable' ), __( 'Tuvalu', 'formidable' ), __( 'Uganda', 'formidable' ), |
|
| 1265 | + __( 'Ukraine', 'formidable' ), __( 'United Arab Emirates', 'formidable' ), __( 'United Kingdom', 'formidable' ), |
|
| 1266 | + __( 'United States', 'formidable' ), __( 'Uruguay', 'formidable' ), __( 'Uzbekistan', 'formidable' ), |
|
| 1267 | + __( 'Vanuatu', 'formidable' ), __( 'Vatican City', 'formidable' ), __( 'Venezuela', 'formidable' ), |
|
| 1268 | + __( 'Vietnam', 'formidable' ), __( 'Virgin Islands, British', 'formidable' ), |
|
| 1269 | + __( 'Virgin Islands, U.S.', 'formidable' ), __( 'Yemen', 'formidable' ), __( 'Zambia', 'formidable' ), |
|
| 1270 | + __( 'Zimbabwe', 'formidable' ), |
|
| 1271 | + ) ); |
|
| 1272 | + } |
|
| 1273 | 1273 | |
| 1274 | 1274 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1275 | 1275 | $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
| 1276 | 1276 | |
| 1277 | - $states = FrmFieldsHelper::get_us_states(); |
|
| 1278 | - $state_abv = array_keys($states); |
|
| 1279 | - sort($state_abv); |
|
| 1277 | + $states = FrmFieldsHelper::get_us_states(); |
|
| 1278 | + $state_abv = array_keys($states); |
|
| 1279 | + sort($state_abv); |
|
| 1280 | 1280 | $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
| 1281 | 1281 | |
| 1282 | - $states = array_values($states); |
|
| 1283 | - sort($states); |
|
| 1282 | + $states = array_values($states); |
|
| 1283 | + sort($states); |
|
| 1284 | 1284 | $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
| 1285 | - unset($state_abv, $states); |
|
| 1285 | + unset($state_abv, $states); |
|
| 1286 | 1286 | |
| 1287 | 1287 | $prepop[ __( 'Age', 'formidable' ) ] = array( |
| 1288 | - __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1289 | - __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1290 | - __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1291 | - ); |
|
| 1288 | + __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
|
| 1289 | + __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
|
| 1290 | + __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
|
| 1291 | + ); |
|
| 1292 | 1292 | |
| 1293 | 1293 | $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
| 1294 | - __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1295 | - __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1296 | - ); |
|
| 1294 | + __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1295 | + __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1296 | + ); |
|
| 1297 | 1297 | |
| 1298 | 1298 | $prepop[ __( 'Importance', 'formidable' ) ] = array( |
| 1299 | - __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1300 | - __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1301 | - ); |
|
| 1299 | + __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1300 | + __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1301 | + ); |
|
| 1302 | 1302 | |
| 1303 | 1303 | $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
| 1304 | - __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1305 | - __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1306 | - ); |
|
| 1304 | + __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
|
| 1305 | + __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
|
| 1306 | + ); |
|
| 1307 | 1307 | |
| 1308 | 1308 | $prepop = apply_filters( 'frm_bulk_field_choices', $prepop ); |
| 1309 | - } |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | 1311 | /** |
| 1312 | 1312 | * Display a field value selector |
@@ -1316,10 +1316,10 @@ discard block |
||
| 1316 | 1316 | * @param int $selector_field_id |
| 1317 | 1317 | * @param array $selector_args |
| 1318 | 1318 | */ |
| 1319 | - public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1320 | - $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1321 | - $field_value_selector->display(); |
|
| 1322 | - } |
|
| 1319 | + public static function display_field_value_selector( $selector_field_id, $selector_args ) { |
|
| 1320 | + $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args ); |
|
| 1321 | + $field_value_selector->display(); |
|
| 1322 | + } |
|
| 1323 | 1323 | |
| 1324 | 1324 | /** |
| 1325 | 1325 | * Convert a field object to a flat array |
@@ -1372,10 +1372,10 @@ discard block |
||
| 1372 | 1372 | return FrmField::is_required( $field ); |
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | - public static function maybe_get_field( &$field ) { |
|
| 1375 | + public static function maybe_get_field( &$field ) { |
|
| 1376 | 1376 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmField::maybe_get_field' ); |
| 1377 | 1377 | FrmField::maybe_get_field( $field ); |
| 1378 | - } |
|
| 1378 | + } |
|
| 1379 | 1379 | |
| 1380 | 1380 | public static function dropdown_categories( $args ) { |
| 1381 | 1381 | _deprecated_function( __FUNCTION__, '2.02.07', 'FrmProPost::get_category_dropdown' ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | public static function setup_new_vars( $type = '', $form_id = '' ) { |
| 9 | 9 | |
| 10 | - if ( strpos($type, '|') ) { |
|
| 11 | - list($type, $setting) = explode('|', $type); |
|
| 10 | + if ( strpos( $type, '|' ) ) { |
|
| 11 | + list( $type, $setting ) = explode( '|', $type ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $defaults = self::get_default_field_opts($type, $form_id); |
|
| 15 | - $defaults['field_options']['custom_html'] = self::get_default_html($type); |
|
| 14 | + $defaults = self::get_default_field_opts( $type, $form_id ); |
|
| 15 | + $defaults['field_options']['custom_html'] = self::get_default_html( $type ); |
|
| 16 | 16 | |
| 17 | 17 | $values = array(); |
| 18 | 18 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | if ( $var == 'field_options' ) { |
| 21 | 21 | $values['field_options'] = array(); |
| 22 | 22 | foreach ( $default as $opt_var => $opt_default ) { |
| 23 | - $values['field_options'][ $opt_var ] = $opt_default; |
|
| 24 | - unset($opt_var, $opt_default); |
|
| 23 | + $values['field_options'][$opt_var] = $opt_default; |
|
| 24 | + unset( $opt_var, $opt_default ); |
|
| 25 | 25 | } |
| 26 | 26 | } else { |
| 27 | - $values[ $var ] = $default; |
|
| 27 | + $values[$var] = $default; |
|
| 28 | 28 | } |
| 29 | - unset($var, $default); |
|
| 29 | + unset( $var, $default ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( isset( $setting ) && ! empty( $setting ) ) { |
| 33 | 33 | if ( in_array( $type, array( 'data', 'lookup' ) ) ) { |
| 34 | 34 | $values['field_options']['data_type'] = $setting; |
| 35 | 35 | } else { |
| 36 | - $values['field_options'][ $setting ] = 1; |
|
| 36 | + $values['field_options'][$setting] = 1; |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $fields = FrmField::field_selection(); |
| 59 | - $fields = array_merge($fields, FrmField::pro_field_selection()); |
|
| 59 | + $fields = array_merge( $fields, FrmField::pro_field_selection() ); |
|
| 60 | 60 | |
| 61 | - if ( isset( $fields[ $type ] ) ) { |
|
| 62 | - $values['name'] = is_array( $fields[ $type ] ) ? $fields[ $type ]['name'] : $fields[ $type ]; |
|
| 61 | + if ( isset( $fields[$type] ) ) { |
|
| 62 | + $values['name'] = is_array( $fields[$type] ) ? $fields[$type]['name'] : $fields[$type]; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - unset($fields); |
|
| 65 | + unset( $fields ); |
|
| 66 | 66 | |
| 67 | 67 | return $values; |
| 68 | 68 | } |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | $values['form_name'] = ''; |
| 89 | 89 | } else { |
| 90 | 90 | foreach ( $defaults as $var => $default ) { |
| 91 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | - unset($var, $default); |
|
| 91 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'htmlspecialchars' ); |
|
| 92 | + unset( $var, $default ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $values['form_name'] = $record->form_id ? FrmForm::getName( $record->form_id ) : ''; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $values['options'] = $record->options; |
| 101 | 101 | $values['field_options'] = $record->field_options; |
| 102 | 102 | |
| 103 | - $defaults = self::get_default_field_opts($values['type'], $record, true); |
|
| 103 | + $defaults = self::get_default_field_opts( $values['type'], $record, true ); |
|
| 104 | 104 | |
| 105 | 105 | if ( $values['type'] == 'captcha' ) { |
| 106 | 106 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | foreach ( $defaults as $opt => $default ) { |
| 111 | - $values[ $opt ] = isset( $record->field_options[ $opt ] ) ? $record->field_options[ $opt ] : $default; |
|
| 112 | - unset($opt, $default); |
|
| 111 | + $values[$opt] = isset( $record->field_options[$opt] ) ? $record->field_options[$opt] : $default; |
|
| 112 | + unset( $opt, $default ); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $values['custom_html'] = (isset($record->field_options['custom_html'])) ? $record->field_options['custom_html'] : self::get_default_html($record->type); |
|
| 115 | + $values['custom_html'] = ( isset( $record->field_options['custom_html'] ) ) ? $record->field_options['custom_html'] : self::get_default_html( $record->type ); |
|
| 116 | 116 | |
| 117 | 117 | return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) ); |
| 118 | 118 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | global $wpdb; |
| 133 | 133 | |
| 134 | - $form_id = (is_numeric($field)) ? $field : $field->form_id; |
|
| 134 | + $form_id = ( is_numeric( $field ) ) ? $field : $field->form_id; |
|
| 135 | 135 | |
| 136 | 136 | $key = is_numeric( $field ) ? FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_fields', 'field_key' ) : $field->field_key; |
| 137 | 137 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' ); |
| 155 | 155 | $values['form_id'] = $form_id; |
| 156 | - $values['options'] = maybe_serialize($field->options); |
|
| 157 | - $values['default_value'] = maybe_serialize($field->default_value); |
|
| 156 | + $values['options'] = maybe_serialize( $field->options ); |
|
| 157 | + $values['default_value'] = maybe_serialize( $field->default_value ); |
|
| 158 | 158 | |
| 159 | 159 | foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) { |
| 160 | - $values[ $col ] = $field->{$col}; |
|
| 160 | + $values[$col] = $field->{$col}; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $conf_msg = __( 'The entered values do not match', 'formidable' ); |
| 173 | 173 | $defaults = array( |
| 174 | - 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | - 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ) ), |
|
| 174 | + 'unique_msg' => array( 'full' => $default_settings['unique_msg'], 'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ) ), |
|
| 175 | + 'invalid' => array( 'full' => __( 'This field is invalid', 'formidable' ), 'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ) ), |
|
| 176 | 176 | 'blank' => array( 'full' => $frm_settings->blank_msg, 'part' => $frm_settings->blank_msg ), |
| 177 | 177 | 'conf_msg' => array( 'full' => $conf_msg, 'part' => $conf_msg ), |
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | $msg = FrmField::get_option( $field, $error ); |
| 181 | - $msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg; |
|
| 181 | + $msg = empty( $msg ) ? $defaults[$error]['part'] : $msg; |
|
| 182 | 182 | $msg = do_shortcode( $msg ); |
| 183 | 183 | return $msg; |
| 184 | 184 | } |
@@ -208,14 +208,14 @@ discard block |
||
| 208 | 208 | </div> |
| 209 | 209 | DEFAULT_HTML; |
| 210 | 210 | } else { |
| 211 | - $default_html = apply_filters('frm_other_custom_html', '', $type); |
|
| 211 | + $default_html = apply_filters( 'frm_other_custom_html', '', $type ); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - return apply_filters('frm_custom_html', $default_html, $type); |
|
| 214 | + return apply_filters( 'frm_custom_html', $default_html, $type ); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public static function replace_shortcodes( $html, $field, $errors = array(), $form = false, $args = array() ) { |
| 218 | - $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form); |
|
| 218 | + $html = apply_filters( 'frm_before_replace_shortcodes', $html, $field, $errors, $form ); |
|
| 219 | 219 | |
| 220 | 220 | $defaults = array( |
| 221 | 221 | 'field_name' => 'item_meta[' . $field['id'] . ']', |
@@ -223,42 +223,42 @@ discard block |
||
| 223 | 223 | 'field_plus_id' => '', |
| 224 | 224 | 'section_id' => '', |
| 225 | 225 | ); |
| 226 | - $args = wp_parse_args($args, $defaults); |
|
| 226 | + $args = wp_parse_args( $args, $defaults ); |
|
| 227 | 227 | $field_name = $args['field_name']; |
| 228 | 228 | $field_id = $args['field_id']; |
| 229 | - $html_id = self::get_html_id($field, $args['field_plus_id']); |
|
| 229 | + $html_id = self::get_html_id( $field, $args['field_plus_id'] ); |
|
| 230 | 230 | |
| 231 | - if ( FrmField::is_multiple_select($field) ) { |
|
| 231 | + if ( FrmField::is_multiple_select( $field ) ) { |
|
| 232 | 232 | $field_name .= '[]'; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | //replace [id] |
| 236 | - $html = str_replace('[id]', $field_id, $html); |
|
| 236 | + $html = str_replace( '[id]', $field_id, $html ); |
|
| 237 | 237 | |
| 238 | 238 | // Remove the for attribute for captcha |
| 239 | 239 | if ( $field['type'] == 'captcha' ) { |
| 240 | - $html = str_replace(' for="field_[key]"', '', $html); |
|
| 240 | + $html = str_replace( ' for="field_[key]"', '', $html ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // set the label for |
| 244 | - $html = str_replace('field_[key]', $html_id, $html); |
|
| 244 | + $html = str_replace( 'field_[key]', $html_id, $html ); |
|
| 245 | 245 | |
| 246 | 246 | //replace [key] |
| 247 | - $html = str_replace('[key]', $field['field_key'], $html); |
|
| 247 | + $html = str_replace( '[key]', $field['field_key'], $html ); |
|
| 248 | 248 | |
| 249 | 249 | //replace [description] and [required_label] and [error] |
| 250 | 250 | $required = FrmField::is_required( $field ) ? $field['required_indicator'] : ''; |
| 251 | 251 | if ( ! is_array( $errors ) ) { |
| 252 | 252 | $errors = array(); |
| 253 | 253 | } |
| 254 | - $error = isset( $errors[ 'field' . $field_id ] ) ? $errors[ 'field' . $field_id ] : false; |
|
| 254 | + $error = isset( $errors['field' . $field_id] ) ? $errors['field' . $field_id] : false; |
|
| 255 | 255 | |
| 256 | 256 | //If field type is section heading, add class so a bottom margin can be added to either the h3 or description |
| 257 | 257 | if ( $field['type'] == 'divider' ) { |
| 258 | 258 | if ( FrmField::is_option_true( $field, 'description' ) ) { |
| 259 | 259 | $html = str_replace( 'frm_description', 'frm_description frm_section_spacing', $html ); |
| 260 | 260 | } else { |
| 261 | - $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html); |
|
| 261 | + $html = str_replace( '[label_position]', '[label_position] frm_section_spacing', $html ); |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
@@ -268,53 +268,53 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | //replace [required_class] |
| 270 | 270 | $required_class = FrmField::is_required( $field ) ? ' frm_required_field' : ''; |
| 271 | - $html = str_replace('[required_class]', $required_class, $html); |
|
| 271 | + $html = str_replace( '[required_class]', $required_class, $html ); |
|
| 272 | 272 | |
| 273 | 273 | //replace [label_position] |
| 274 | - $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form); |
|
| 274 | + $field['label'] = apply_filters( 'frm_html_label_position', $field['label'], $field, $form ); |
|
| 275 | 275 | $field['label'] = ( $field['label'] && $field['label'] != '' ) ? $field['label'] : 'top'; |
| 276 | 276 | $html = str_replace( '[label_position]', ( ( in_array( $field['type'], array( 'divider', 'end_divider', 'break' ) ) ) ? $field['label'] : ' frm_primary_label' ), $html ); |
| 277 | 277 | |
| 278 | 278 | //replace [field_name] |
| 279 | - $html = str_replace('[field_name]', $field['name'], $html); |
|
| 279 | + $html = str_replace( '[field_name]', $field['name'], $html ); |
|
| 280 | 280 | |
| 281 | 281 | self::add_field_div_classes( $field_id, $field, $errors, $html ); |
| 282 | 282 | |
| 283 | 283 | //replace [entry_key] |
| 284 | 284 | $entry_key = FrmAppHelper::simple_get( 'entry', 'sanitize_title' ); |
| 285 | - $html = str_replace('[entry_key]', $entry_key, $html); |
|
| 285 | + $html = str_replace( '[entry_key]', $entry_key, $html ); |
|
| 286 | 286 | |
| 287 | 287 | if ( $form ) { |
| 288 | 288 | $form = (array) $form; |
| 289 | 289 | |
| 290 | 290 | //replace [form_key] |
| 291 | - $html = str_replace('[form_key]', $form['form_key'], $html); |
|
| 291 | + $html = str_replace( '[form_key]', $form['form_key'], $html ); |
|
| 292 | 292 | |
| 293 | 293 | //replace [form_name] |
| 294 | - $html = str_replace('[form_name]', $form['name'], $html); |
|
| 294 | + $html = str_replace( '[form_name]', $form['name'], $html ); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | self::process_wp_shortcodes( $html ); |
| 298 | 298 | |
| 299 | 299 | //replace [input] |
| 300 | - preg_match_all("/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER); |
|
| 300 | + preg_match_all( "/\[(input|deletelink)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER ); |
|
| 301 | 301 | global $frm_vars; |
| 302 | 302 | $frm_settings = FrmAppHelper::get_settings(); |
| 303 | 303 | |
| 304 | 304 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 305 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 305 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 306 | 306 | $tag = self::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) ); |
| 307 | 307 | |
| 308 | 308 | $replace_with = ''; |
| 309 | 309 | |
| 310 | 310 | if ( $tag == 'input' ) { |
| 311 | - if ( isset($atts['opt']) ) { |
|
| 312 | - $atts['opt']--; |
|
| 311 | + if ( isset( $atts['opt'] ) ) { |
|
| 312 | + $atts['opt'] --; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $field['input_class'] = isset($atts['class']) ? $atts['class'] : ''; |
|
| 316 | - if ( isset($atts['class']) ) { |
|
| 317 | - unset($atts['class']); |
|
| 315 | + $field['input_class'] = isset( $atts['class'] ) ? $atts['class'] : ''; |
|
| 316 | + if ( isset( $atts['class'] ) ) { |
|
| 317 | + unset( $atts['class'] ); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $field['shortcodes'] = $atts; |
@@ -323,24 +323,24 @@ discard block |
||
| 323 | 323 | $replace_with = ob_get_contents(); |
| 324 | 324 | ob_end_clean(); |
| 325 | 325 | } else if ( $tag == 'deletelink' && FrmAppHelper::pro_is_installed() ) { |
| 326 | - $replace_with = FrmProEntriesController::entry_delete_link($atts); |
|
| 326 | + $replace_with = FrmProEntriesController::entry_delete_link( $atts ); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - $html = str_replace( $shortcodes[0][ $short_key ], $replace_with, $html ); |
|
| 329 | + $html = str_replace( $shortcodes[0][$short_key], $replace_with, $html ); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $html .= "\n"; |
| 333 | 333 | |
| 334 | 334 | //Return html if conf_field to prevent loop |
| 335 | - if ( isset($field['conf_field']) && $field['conf_field'] == 'stop' ) { |
|
| 335 | + if ( isset( $field['conf_field'] ) && $field['conf_field'] == 'stop' ) { |
|
| 336 | 336 | return $html; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | //If field is in repeating section |
| 340 | 340 | if ( $args['section_id'] ) { |
| 341 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] )); |
|
| 341 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id'] ) ); |
|
| 342 | 342 | } else { |
| 343 | - $html = apply_filters('frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form )); |
|
| 343 | + $html = apply_filters( 'frm_replace_shortcodes', $html, $field, array( 'errors' => $errors, 'form' => $form ) ); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | self::remove_collapse_shortcode( $html ); |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | private static function get_field_div_classes( $field_id, $field, $errors, $html ) { |
| 394 | 394 | // Add error class |
| 395 | - $classes = isset( $errors[ 'field' . $field_id ] ) ? ' frm_blank_field' : ''; |
|
| 395 | + $classes = isset( $errors['field' . $field_id] ) ? ' frm_blank_field' : ''; |
|
| 396 | 396 | |
| 397 | 397 | // Add label position class |
| 398 | 398 | $classes .= ' frm_' . $field['label'] . '_container'; |
| 399 | 399 | |
| 400 | 400 | // Add CSS layout classes |
| 401 | 401 | if ( ! empty( $field['classes'] ) ) { |
| 402 | - if ( ! strpos( $html, 'frm_form_field ') ) { |
|
| 402 | + if ( ! strpos( $html, 'frm_form_field ' ) ) { |
|
| 403 | 403 | $classes .= ' frm_form_field'; |
| 404 | 404 | } |
| 405 | 405 | $classes .= ' ' . $field['classes']; |
@@ -438,15 +438,15 @@ discard block |
||
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $with_tags = $args['conditional_check'] ? 3 : 2; |
| 441 | - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) { |
|
| 442 | - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] ); |
|
| 443 | - $tag = str_replace(']', '', $tag); |
|
| 444 | - $tags = explode(' ', $tag); |
|
| 445 | - if ( is_array($tags) ) { |
|
| 441 | + if ( ! empty( $shortcodes[$with_tags][$short_key] ) ) { |
|
| 442 | + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][$short_key] ); |
|
| 443 | + $tag = str_replace( ']', '', $tag ); |
|
| 444 | + $tags = explode( ' ', $tag ); |
|
| 445 | + if ( is_array( $tags ) ) { |
|
| 446 | 446 | $tag = $tags[0]; |
| 447 | 447 | } |
| 448 | 448 | } else { |
| 449 | - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ]; |
|
| 449 | + $tag = $shortcodes[$with_tags - 1][$short_key]; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | return $tag; |
@@ -501,10 +501,10 @@ discard block |
||
| 501 | 501 | |
| 502 | 502 | public static function show_single_option( $field ) { |
| 503 | 503 | $field_name = $field['name']; |
| 504 | - $html_id = self::get_html_id($field); |
|
| 504 | + $html_id = self::get_html_id( $field ); |
|
| 505 | 505 | foreach ( $field['options'] as $opt_key => $opt ) { |
| 506 | - $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field); |
|
| 507 | - $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field); |
|
| 506 | + $field_val = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field ); |
|
| 507 | + $opt = apply_filters( 'frm_field_label_seen', $opt, $opt_key, $field ); |
|
| 508 | 508 | |
| 509 | 509 | // If this is an "Other" option, get the HTML for it |
| 510 | 510 | if ( self::is_other_opt( $opt_key ) ) { |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | public static function get_term_link( $tax_id ) { |
| 521 | - $tax = get_taxonomy($tax_id); |
|
| 521 | + $tax = get_taxonomy( $tax_id ); |
|
| 522 | 522 | if ( ! $tax ) { |
| 523 | 523 | return; |
| 524 | 524 | } |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | __( 'Please add options from the WordPress "%1$s" page', 'formidable' ), |
| 528 | 528 | '<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>' |
| 529 | 529 | ); |
| 530 | - unset($tax); |
|
| 530 | + unset( $tax ); |
|
| 531 | 531 | |
| 532 | 532 | return $link; |
| 533 | 533 | } |
@@ -541,8 +541,8 @@ discard block |
||
| 541 | 541 | $observed_value = wp_kses_post( $observed_value ); |
| 542 | 542 | $hide_opt = wp_kses_post( $hide_opt ); |
| 543 | 543 | |
| 544 | - if ( is_array($observed_value) ) { |
|
| 545 | - return self::array_value_condition($observed_value, $cond, $hide_opt); |
|
| 544 | + if ( is_array( $observed_value ) ) { |
|
| 545 | + return self::array_value_condition( $observed_value, $cond, $hide_opt ); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | $m = false; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | } else if ( $cond == '<' ) { |
| 556 | 556 | $m = $observed_value < $hide_opt; |
| 557 | 557 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 558 | - $m = stripos($observed_value, $hide_opt); |
|
| 558 | + $m = stripos( $observed_value, $hide_opt ); |
|
| 559 | 559 | if ( $cond == 'not LIKE' ) { |
| 560 | 560 | $m = ( $m === false ) ? true : false; |
| 561 | 561 | } else { |
@@ -568,23 +568,23 @@ discard block |
||
| 568 | 568 | public static function array_value_condition( $observed_value, $cond, $hide_opt ) { |
| 569 | 569 | $m = false; |
| 570 | 570 | if ( $cond == '==' ) { |
| 571 | - if ( is_array($hide_opt) ) { |
|
| 572 | - $m = array_intersect($hide_opt, $observed_value); |
|
| 573 | - $m = empty($m) ? false : true; |
|
| 571 | + if ( is_array( $hide_opt ) ) { |
|
| 572 | + $m = array_intersect( $hide_opt, $observed_value ); |
|
| 573 | + $m = empty( $m ) ? false : true; |
|
| 574 | 574 | } else { |
| 575 | - $m = in_array($hide_opt, $observed_value); |
|
| 575 | + $m = in_array( $hide_opt, $observed_value ); |
|
| 576 | 576 | } |
| 577 | 577 | } else if ( $cond == '!=' ) { |
| 578 | - $m = ! in_array($hide_opt, $observed_value); |
|
| 578 | + $m = ! in_array( $hide_opt, $observed_value ); |
|
| 579 | 579 | } else if ( $cond == '>' ) { |
| 580 | - $min = min($observed_value); |
|
| 580 | + $min = min( $observed_value ); |
|
| 581 | 581 | $m = $min > $hide_opt; |
| 582 | 582 | } else if ( $cond == '<' ) { |
| 583 | - $max = max($observed_value); |
|
| 583 | + $max = max( $observed_value ); |
|
| 584 | 584 | $m = $max < $hide_opt; |
| 585 | 585 | } else if ( $cond == 'LIKE' || $cond == 'not LIKE' ) { |
| 586 | 586 | foreach ( $observed_value as $ob ) { |
| 587 | - $m = strpos($ob, $hide_opt); |
|
| 587 | + $m = strpos( $ob, $hide_opt ); |
|
| 588 | 588 | if ( $m !== false ) { |
| 589 | 589 | $m = true; |
| 590 | 590 | break; |
@@ -605,27 +605,27 @@ discard block |
||
| 605 | 605 | * @return string |
| 606 | 606 | */ |
| 607 | 607 | public static function basic_replace_shortcodes( $value, $form, $entry ) { |
| 608 | - if ( strpos($value, '[sitename]') !== false ) { |
|
| 608 | + if ( strpos( $value, '[sitename]' ) !== false ) { |
|
| 609 | 609 | $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES ); |
| 610 | - $value = str_replace('[sitename]', $new_value, $value); |
|
| 610 | + $value = str_replace( '[sitename]', $new_value, $value ); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $value = apply_filters('frm_content', $value, $form, $entry); |
|
| 614 | - $value = do_shortcode($value); |
|
| 613 | + $value = apply_filters( 'frm_content', $value, $form, $entry ); |
|
| 614 | + $value = do_shortcode( $value ); |
|
| 615 | 615 | |
| 616 | 616 | return $value; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | public static function get_shortcodes( $content, $form_id ) { |
| 620 | 620 | if ( FrmAppHelper::pro_is_installed() ) { |
| 621 | - return FrmProDisplaysHelper::get_shortcodes($content, $form_id); |
|
| 621 | + return FrmProDisplaysHelper::get_shortcodes( $content, $form_id ); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id, 'fi.type not' => FrmField::no_save_fields() ) ); |
| 625 | 625 | |
| 626 | - $tagregexp = self::allowed_shortcodes($fields); |
|
| 626 | + $tagregexp = self::allowed_shortcodes( $fields ); |
|
| 627 | 627 | |
| 628 | - preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER); |
|
| 628 | + preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER ); |
|
| 629 | 629 | |
| 630 | 630 | return $matches; |
| 631 | 631 | } |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | $tagregexp[] = $field->field_key; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $tagregexp = implode('|', $tagregexp); |
|
| 646 | + $tagregexp = implode( '|', $tagregexp ); |
|
| 647 | 647 | return $tagregexp; |
| 648 | 648 | } |
| 649 | 649 | |
@@ -659,28 +659,28 @@ discard block |
||
| 659 | 659 | continue; |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] ); |
|
| 662 | + $atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] ); |
|
| 663 | 663 | |
| 664 | - if ( ! empty( $shortcodes[3][ $short_key ] ) ) { |
|
| 665 | - $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][ $short_key ] ); |
|
| 666 | - $tags = explode(' ', $tag); |
|
| 667 | - if ( is_array($tags) ) { |
|
| 664 | + if ( ! empty( $shortcodes[3][$short_key] ) ) { |
|
| 665 | + $tag = str_replace( array( '[', ']' ), '', $shortcodes[0][$short_key] ); |
|
| 666 | + $tags = explode( ' ', $tag ); |
|
| 667 | + if ( is_array( $tags ) ) { |
|
| 668 | 668 | $tag = $tags[0]; |
| 669 | 669 | } |
| 670 | 670 | } else { |
| 671 | - $tag = $shortcodes[2][ $short_key ]; |
|
| 671 | + $tag = $shortcodes[2][$short_key]; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | switch ( $tag ) { |
| 675 | 675 | case 'id': |
| 676 | 676 | case 'key': |
| 677 | 677 | case 'ip': |
| 678 | - $replace_with = $shortcode_values[ $tag ]; |
|
| 678 | + $replace_with = $shortcode_values[$tag]; |
|
| 679 | 679 | break; |
| 680 | 680 | |
| 681 | 681 | case 'user_agent': |
| 682 | 682 | case 'user-agent': |
| 683 | - $entry->description = maybe_unserialize($entry->description); |
|
| 683 | + $entry->description = maybe_unserialize( $entry->description ); |
|
| 684 | 684 | $replace_with = FrmEntryFormat::get_browser( $entry->description['browser'] ); |
| 685 | 685 | break; |
| 686 | 686 | |
@@ -688,25 +688,25 @@ discard block |
||
| 688 | 688 | case 'created-at': |
| 689 | 689 | case 'updated_at': |
| 690 | 690 | case 'updated-at': |
| 691 | - if ( isset($atts['format']) ) { |
|
| 691 | + if ( isset( $atts['format'] ) ) { |
|
| 692 | 692 | $time_format = ' '; |
| 693 | 693 | } else { |
| 694 | - $atts['format'] = get_option('date_format'); |
|
| 694 | + $atts['format'] = get_option( 'date_format' ); |
|
| 695 | 695 | $time_format = ''; |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - $this_tag = str_replace('-', '_', $tag); |
|
| 699 | - $replace_with = FrmAppHelper::get_formatted_time($entry->{$this_tag}, $atts['format'], $time_format); |
|
| 700 | - unset($this_tag); |
|
| 698 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 699 | + $replace_with = FrmAppHelper::get_formatted_time( $entry->{$this_tag}, $atts['format'], $time_format ); |
|
| 700 | + unset( $this_tag ); |
|
| 701 | 701 | break; |
| 702 | 702 | |
| 703 | 703 | case 'created_by': |
| 704 | 704 | case 'created-by': |
| 705 | 705 | case 'updated_by': |
| 706 | 706 | case 'updated-by': |
| 707 | - $this_tag = str_replace('-', '_', $tag); |
|
| 707 | + $this_tag = str_replace( '-', '_', $tag ); |
|
| 708 | 708 | $replace_with = self::get_display_value( $entry->{$this_tag}, (object) array( 'type' => 'user_id' ), $atts ); |
| 709 | - unset($this_tag); |
|
| 709 | + unset( $this_tag ); |
|
| 710 | 710 | break; |
| 711 | 711 | |
| 712 | 712 | case 'admin_email': |
@@ -723,16 +723,16 @@ discard block |
||
| 723 | 723 | break; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - $sep = isset($atts['sep']) ? $atts['sep'] : ', '; |
|
| 726 | + $sep = isset( $atts['sep'] ) ? $atts['sep'] : ', '; |
|
| 727 | 727 | |
| 728 | 728 | $replace_with = FrmEntryMeta::get_meta_value( $entry, $field->id ); |
| 729 | 729 | |
| 730 | 730 | $atts['entry_id'] = $entry->id; |
| 731 | 731 | $atts['entry_key'] = $entry->item_key; |
| 732 | 732 | |
| 733 | - if ( isset($atts['show']) && $atts['show'] == 'field_label' ) { |
|
| 733 | + if ( isset( $atts['show'] ) && $atts['show'] == 'field_label' ) { |
|
| 734 | 734 | $replace_with = $field->name; |
| 735 | - } else if ( isset($atts['show']) && $atts['show'] == 'description' ) { |
|
| 735 | + } else if ( isset( $atts['show'] ) && $atts['show'] == 'description' ) { |
|
| 736 | 736 | $replace_with = $field->description; |
| 737 | 737 | } else { |
| 738 | 738 | $string_value = $replace_with; |
@@ -747,15 +747,15 @@ discard block |
||
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - unset($field); |
|
| 750 | + unset( $field ); |
|
| 751 | 751 | break; |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if ( isset($replace_with) ) { |
|
| 755 | - $content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content ); |
|
| 754 | + if ( isset( $replace_with ) ) { |
|
| 755 | + $content = str_replace( $shortcodes[0][$short_key], $replace_with, $content ); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - unset($atts, $conditional, $replace_with); |
|
| 758 | + unset( $atts, $conditional, $replace_with ); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | return $content; |
@@ -771,7 +771,7 @@ discard block |
||
| 771 | 771 | $new_value = ''; |
| 772 | 772 | switch ( $tag ) { |
| 773 | 773 | case 'admin_email': |
| 774 | - $new_value = get_option('admin_email'); |
|
| 774 | + $new_value = get_option( 'admin_email' ); |
|
| 775 | 775 | break; |
| 776 | 776 | case 'siteurl': |
| 777 | 777 | $new_value = FrmAppHelper::site_url(); |
@@ -797,28 +797,28 @@ discard block |
||
| 797 | 797 | * @return string|array |
| 798 | 798 | */ |
| 799 | 799 | public static function process_get_shortcode( $atts, $return_array = false ) { |
| 800 | - if ( ! isset($atts['param']) ) { |
|
| 800 | + if ( ! isset( $atts['param'] ) ) { |
|
| 801 | 801 | return ''; |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - if ( strpos($atts['param'], '[') ) { |
|
| 805 | - $atts['param'] = str_replace('[', '[', $atts['param']); |
|
| 806 | - $atts['param'] = str_replace(']', ']', $atts['param']); |
|
| 804 | + if ( strpos( $atts['param'], '[' ) ) { |
|
| 805 | + $atts['param'] = str_replace( '[', '[', $atts['param'] ); |
|
| 806 | + $atts['param'] = str_replace( ']', ']', $atts['param'] ); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - $new_value = FrmAppHelper::get_param($atts['param'], ''); |
|
| 809 | + $new_value = FrmAppHelper::get_param( $atts['param'], '' ); |
|
| 810 | 810 | $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] ); |
| 811 | 811 | |
| 812 | 812 | if ( $new_value == '' ) { |
| 813 | - if ( ! isset($atts['prev_val']) ) { |
|
| 813 | + if ( ! isset( $atts['prev_val'] ) ) { |
|
| 814 | 814 | $atts['prev_val'] = ''; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $new_value = isset($atts['default']) ? $atts['default'] : $atts['prev_val']; |
|
| 817 | + $new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val']; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - if ( is_array($new_value) && ! $return_array ) { |
|
| 821 | - $new_value = implode(', ', $new_value); |
|
| 820 | + if ( is_array( $new_value ) && ! $return_array ) { |
|
| 821 | + $new_value = implode( ', ', $new_value ); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | return $new_value; |
@@ -831,12 +831,12 @@ discard block |
||
| 831 | 831 | $replace_with = apply_filters( 'frm_get_display_value', $replace_with, $field, $atts ); |
| 832 | 832 | |
| 833 | 833 | if ( $field->type == 'textarea' || $field->type == 'rte' ) { |
| 834 | - $autop = isset($atts['wpautop']) ? $atts['wpautop'] : true; |
|
| 835 | - if ( apply_filters('frm_use_wpautop', $autop) ) { |
|
| 836 | - if ( is_array($replace_with) ) { |
|
| 837 | - $replace_with = implode("\n", $replace_with); |
|
| 834 | + $autop = isset( $atts['wpautop'] ) ? $atts['wpautop'] : true; |
|
| 835 | + if ( apply_filters( 'frm_use_wpautop', $autop ) ) { |
|
| 836 | + if ( is_array( $replace_with ) ) { |
|
| 837 | + $replace_with = implode( "\n", $replace_with ); |
|
| 838 | 838 | } |
| 839 | - $replace_with = wpautop($replace_with); |
|
| 839 | + $replace_with = wpautop( $replace_with ); |
|
| 840 | 840 | } |
| 841 | 841 | unset( $autop ); |
| 842 | 842 | } else if ( is_array( $replace_with ) ) { |
@@ -858,14 +858,14 @@ discard block |
||
| 858 | 858 | $field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() ); |
| 859 | 859 | |
| 860 | 860 | $field_types = array(); |
| 861 | - if ( in_array($type, $single_input) ) { |
|
| 861 | + if ( in_array( $type, $single_input ) ) { |
|
| 862 | 862 | self::field_types_for_input( $single_input, $field_selection, $field_types ); |
| 863 | - } else if ( in_array($type, $multiple_input) ) { |
|
| 863 | + } else if ( in_array( $type, $multiple_input ) ) { |
|
| 864 | 864 | self::field_types_for_input( $multiple_input, $field_selection, $field_types ); |
| 865 | - } else if ( in_array($type, $other_type) ) { |
|
| 865 | + } else if ( in_array( $type, $other_type ) ) { |
|
| 866 | 866 | self::field_types_for_input( $other_type, $field_selection, $field_types ); |
| 867 | - } else if ( isset( $field_selection[ $type ] ) ) { |
|
| 868 | - $field_types[ $type ] = $field_selection[ $type ]; |
|
| 867 | + } else if ( isset( $field_selection[$type] ) ) { |
|
| 868 | + $field_types[$type] = $field_selection[$type]; |
|
| 869 | 869 | } |
| 870 | 870 | |
| 871 | 871 | $field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) ); |
@@ -874,8 +874,8 @@ discard block |
||
| 874 | 874 | |
| 875 | 875 | private static function field_types_for_input( $inputs, $fields, &$field_types ) { |
| 876 | 876 | foreach ( $inputs as $input ) { |
| 877 | - $field_types[ $input ] = $fields[ $input ]; |
|
| 878 | - unset($input); |
|
| 877 | + $field_types[$input] = $fields[$input]; |
|
| 878 | + unset( $input ); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | |
@@ -920,21 +920,21 @@ discard block |
||
| 920 | 920 | // Check posted vals before checking saved values |
| 921 | 921 | |
| 922 | 922 | // For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero |
| 923 | - if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) { |
|
| 923 | + if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) { |
|
| 924 | 924 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 925 | - $other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 925 | + $other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : ''; |
|
| 926 | 926 | } else { |
| 927 | - $other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ); |
|
| 927 | + $other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ); |
|
| 928 | 928 | } |
| 929 | 929 | return $other_val; |
| 930 | 930 | |
| 931 | - } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) { |
|
| 931 | + } else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) { |
|
| 932 | 932 | // For normal fields |
| 933 | 933 | |
| 934 | 934 | if ( FrmField::is_field_with_multiple_values( $field ) ) { |
| 935 | - $other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : ''; |
|
| 935 | + $other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : ''; |
|
| 936 | 936 | } else { |
| 937 | - $other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] ); |
|
| 937 | + $other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] ); |
|
| 938 | 938 | } |
| 939 | 939 | return $other_val; |
| 940 | 940 | } |
@@ -943,8 +943,8 @@ discard block |
||
| 943 | 943 | if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) { |
| 944 | 944 | // Check if there is an "other" val in saved value and make sure the |
| 945 | 945 | // "other" val is not equal to the Other checkbox option |
| 946 | - if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) { |
|
| 947 | - $other_val = $field['value'][ $opt_key ]; |
|
| 946 | + if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) { |
|
| 947 | + $other_val = $field['value'][$opt_key]; |
|
| 948 | 948 | } |
| 949 | 949 | } else { |
| 950 | 950 | /** |
@@ -956,8 +956,8 @@ discard block |
||
| 956 | 956 | // Multi-select dropdowns - key is not preserved |
| 957 | 957 | if ( is_array( $field['value'] ) ) { |
| 958 | 958 | $o_key = array_search( $temp_val, $field['value'] ); |
| 959 | - if ( isset( $field['value'][ $o_key ] ) ) { |
|
| 960 | - unset( $field['value'][ $o_key ], $o_key ); |
|
| 959 | + if ( isset( $field['value'][$o_key] ) ) { |
|
| 960 | + unset( $field['value'][$o_key], $o_key ); |
|
| 961 | 961 | } |
| 962 | 962 | } else if ( $temp_val == $field['value'] ) { |
| 963 | 963 | // For radio and regular dropdowns |
@@ -1014,7 +1014,7 @@ discard block |
||
| 1014 | 1014 | private static function set_other_name( $args, &$other_args ) { |
| 1015 | 1015 | //Set up name for other field |
| 1016 | 1016 | $other_args['name'] = str_replace( '[]', '', $args['field_name'] ); |
| 1017 | - $other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']); |
|
| 1017 | + $other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] ); |
|
| 1018 | 1018 | $other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']'; |
| 1019 | 1019 | |
| 1020 | 1020 | //Converts item_meta[field_id] => item_meta[other][field_id] and |
@@ -1041,7 +1041,7 @@ discard block |
||
| 1041 | 1041 | // Count should only be greater than 3 if inside of a repeating section |
| 1042 | 1042 | if ( count( $temp_array ) > 3 ) { |
| 1043 | 1043 | $parent = str_replace( ']', '', $temp_array[1] ); |
| 1044 | - $pointer = str_replace( ']', '', $temp_array[2]); |
|
| 1044 | + $pointer = str_replace( ']', '', $temp_array[2] ); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | // Get text for "other" text field |
@@ -1160,15 +1160,15 @@ discard block |
||
| 1160 | 1160 | $replace_with[] = '[' . $new . ']'; |
| 1161 | 1161 | $replace[] = '[' . $old . ' '; |
| 1162 | 1162 | $replace_with[] = '[' . $new . ' '; |
| 1163 | - unset($old, $new); |
|
| 1163 | + unset( $old, $new ); |
|
| 1164 | 1164 | } |
| 1165 | 1165 | if ( is_array( $val ) ) { |
| 1166 | 1166 | foreach ( $val as $k => $v ) { |
| 1167 | - $val[ $k ] = str_replace( $replace, $replace_with, $v ); |
|
| 1168 | - unset($k, $v); |
|
| 1167 | + $val[$k] = str_replace( $replace, $replace_with, $v ); |
|
| 1168 | + unset( $k, $v ); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | } else { |
| 1171 | - $val = str_replace($replace, $replace_with, $val); |
|
| 1171 | + $val = str_replace( $replace, $replace_with, $val ); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | return $val; |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | 'DC' => 'District of Columbia', |
| 1182 | 1182 | 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', |
| 1183 | 1183 | 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', |
| 1184 | - 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine','MD' => 'Maryland', |
|
| 1184 | + 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', |
|
| 1185 | 1185 | 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', |
| 1186 | 1186 | 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', |
| 1187 | 1187 | 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', |
@@ -1272,35 +1272,35 @@ discard block |
||
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | public static function get_bulk_prefilled_opts( array &$prepop ) { |
| 1275 | - $prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries(); |
|
| 1275 | + $prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries(); |
|
| 1276 | 1276 | |
| 1277 | 1277 | $states = FrmFieldsHelper::get_us_states(); |
| 1278 | - $state_abv = array_keys($states); |
|
| 1279 | - sort($state_abv); |
|
| 1280 | - $prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv; |
|
| 1278 | + $state_abv = array_keys( $states ); |
|
| 1279 | + sort( $state_abv ); |
|
| 1280 | + $prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv; |
|
| 1281 | 1281 | |
| 1282 | - $states = array_values($states); |
|
| 1283 | - sort($states); |
|
| 1284 | - $prepop[ __( 'U.S. States', 'formidable' ) ] = $states; |
|
| 1285 | - unset($state_abv, $states); |
|
| 1282 | + $states = array_values( $states ); |
|
| 1283 | + sort( $states ); |
|
| 1284 | + $prepop[__( 'U.S. States', 'formidable' )] = $states; |
|
| 1285 | + unset( $state_abv, $states ); |
|
| 1286 | 1286 | |
| 1287 | - $prepop[ __( 'Age', 'formidable' ) ] = array( |
|
| 1287 | + $prepop[__( 'Age', 'formidable' )] = array( |
|
| 1288 | 1288 | __( 'Under 18', 'formidable' ), __( '18-24', 'formidable' ), __( '25-34', 'formidable' ), |
| 1289 | 1289 | __( '35-44', 'formidable' ), __( '45-54', 'formidable' ), __( '55-64', 'formidable' ), |
| 1290 | 1290 | __( '65 or Above', 'formidable' ), __( 'Prefer Not to Answer', 'formidable' ), |
| 1291 | 1291 | ); |
| 1292 | 1292 | |
| 1293 | - $prepop[ __( 'Satisfaction', 'formidable' ) ] = array( |
|
| 1293 | + $prepop[__( 'Satisfaction', 'formidable' )] = array( |
|
| 1294 | 1294 | __( 'Very Satisfied', 'formidable' ), __( 'Satisfied', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1295 | 1295 | __( 'Unsatisfied', 'formidable' ), __( 'Very Unsatisfied', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1296 | 1296 | ); |
| 1297 | 1297 | |
| 1298 | - $prepop[ __( 'Importance', 'formidable' ) ] = array( |
|
| 1298 | + $prepop[__( 'Importance', 'formidable' )] = array( |
|
| 1299 | 1299 | __( 'Very Important', 'formidable' ), __( 'Important', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1300 | 1300 | __( 'Somewhat Important', 'formidable' ), __( 'Not at all Important', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1301 | 1301 | ); |
| 1302 | 1302 | |
| 1303 | - $prepop[ __( 'Agreement', 'formidable' ) ] = array( |
|
| 1303 | + $prepop[__( 'Agreement', 'formidable' )] = array( |
|
| 1304 | 1304 | __( 'Strongly Agree', 'formidable' ), __( 'Agree', 'formidable' ), __( 'Neutral', 'formidable' ), |
| 1305 | 1305 | __( 'Disagree', 'formidable' ), __( 'Strongly Disagree', 'formidable' ), __( 'N/A', 'formidable' ), |
| 1306 | 1306 | ); |