@@ -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 ) ); |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public static function after_duplicate( $form_id, $values ) { |
| 106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
| 106 | + $new_opts = $values['options'] = maybe_unserialize( $values['options'] ); |
|
| 107 | 107 | |
| 108 | - if ( isset($new_opts['success_msg']) ) { |
|
| 109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
| 108 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
| 109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
| 112 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
| 113 | 113 | |
| 114 | 114 | if ( $new_opts != $values['options'] ) { |
| 115 | 115 | global $wpdb; |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | $values['status'] = 'published'; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( isset($values['form_key']) ) { |
|
| 130 | + if ( isset( $values['form_key'] ) ) { |
|
| 131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
| 135 | 135 | |
| 136 | - $new_values = self::set_update_options( array(), $values); |
|
| 136 | + $new_values = self::set_update_options( array(), $values ); |
|
| 137 | 137 | |
| 138 | 138 | foreach ( $values as $value_key => $value ) { |
| 139 | 139 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
| 140 | - $new_values[ $value_key ] = $value; |
|
| 140 | + $new_values[$value_key] = $value; |
|
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | 143 | |
@@ -153,9 +153,9 @@ discard block |
||
| 153 | 153 | } else { |
| 154 | 154 | $query_results = true; |
| 155 | 155 | } |
| 156 | - unset($new_values); |
|
| 156 | + unset( $new_values ); |
|
| 157 | 157 | |
| 158 | - $values = self::update_fields($id, $values); |
|
| 158 | + $values = self::update_fields( $id, $values ); |
|
| 159 | 159 | |
| 160 | 160 | do_action( 'frm_update_form', $id, $values ); |
| 161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -167,20 +167,20 @@ discard block |
||
| 167 | 167 | * @return array |
| 168 | 168 | */ |
| 169 | 169 | public static function set_update_options( $new_values, $values ) { |
| 170 | - if ( ! isset($values['options']) ) { |
|
| 170 | + if ( ! isset( $values['options'] ) ) { |
|
| 171 | 171 | return $new_values; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
| 175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
| 176 | 176 | |
| 177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
| 178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
| 179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
| 180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
| 177 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
| 178 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
| 179 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
| 180 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
| 181 | 181 | |
| 182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
| 183 | - $new_values['options'] = serialize($options); |
|
| 182 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
| 183 | + $new_values['options'] = serialize( $options ); |
|
| 184 | 184 | |
| 185 | 185 | return $new_values; |
| 186 | 186 | } |
@@ -191,54 +191,54 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | public static function update_fields( $id, $values ) { |
| 193 | 193 | |
| 194 | - if ( ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
| 194 | + if ( ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
| 195 | 195 | return $values; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $all_fields = FrmField::get_all_for_form($id); |
|
| 199 | - if ( empty($all_fields) ) { |
|
| 198 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
| 199 | + if ( empty( $all_fields ) ) { |
|
| 200 | 200 | return $values; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - if ( ! isset($values['item_meta']) ) { |
|
| 203 | + if ( ! isset( $values['item_meta'] ) ) { |
|
| 204 | 204 | $values['item_meta'] = array(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $field_array = array(); |
| 208 | - $existing_keys = array_keys($values['item_meta']); |
|
| 208 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
| 209 | 209 | foreach ( $all_fields as $fid ) { |
| 210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
| 211 | - $values['item_meta'][ $fid->id ] = ''; |
|
| 210 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
| 211 | + $values['item_meta'][$fid->id] = ''; |
|
| 212 | 212 | } |
| 213 | - $field_array[ $fid->id ] = $fid; |
|
| 213 | + $field_array[$fid->id] = $fid; |
|
| 214 | 214 | } |
| 215 | - unset($all_fields); |
|
| 215 | + unset( $all_fields ); |
|
| 216 | 216 | |
| 217 | 217 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
| 218 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
| 219 | - $field = $field_array[ $field_id ]; |
|
| 218 | + if ( isset( $field_array[$field_id] ) ) { |
|
| 219 | + $field = $field_array[$field_id]; |
|
| 220 | 220 | } else { |
| 221 | - $field = FrmField::getOne($field_id); |
|
| 221 | + $field = FrmField::getOne( $field_id ); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ( ! $field ) { |
| 225 | 225 | continue; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
| 228 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
| 229 | 229 | if ( $is_settings_page ) { |
| 230 | 230 | //updating the settings page |
| 231 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
| 232 | - $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 ) ); |
|
| 233 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 231 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
| 232 | + $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 ) ); |
|
| 233 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 234 | 234 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 235 | 235 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
| 236 | 236 | $prev_opts = $field->field_options; |
| 237 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
| 237 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
| 238 | 238 | if ( $prev_opts != $field->field_options ) { |
| 239 | 239 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
| 240 | 240 | } |
| 241 | - unset($prev_opts); |
|
| 241 | + unset( $prev_opts ); |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -252,23 +252,23 @@ discard block |
||
| 252 | 252 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
| 253 | 253 | |
| 254 | 254 | foreach ( $update_options as $opt => $default ) { |
| 255 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
| 255 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
| 259 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
| 260 | - $field_key = isset( $values['field_options'][ 'field_key_' . $field_id ] ) ? $values['field_options'][ 'field_key_' . $field_id ] : $field->field_key; |
|
| 261 | - $required = isset( $values['field_options'][ 'required_' . $field_id ] ) ? $values['field_options'][ 'required_' . $field_id ] : false; |
|
| 262 | - $field_type = isset( $values['field_options'][ 'type_' . $field_id ] ) ? $values['field_options'][ 'type_' . $field_id ] : $field->type; |
|
| 263 | - $field_description = isset( $values['field_options'][ 'description_' . $field_id ] ) ? $values['field_options'][ 'description_' . $field_id ] : $field->description; |
|
| 258 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
| 259 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
| 260 | + $field_key = isset( $values['field_options']['field_key_' . $field_id] ) ? $values['field_options']['field_key_' . $field_id] : $field->field_key; |
|
| 261 | + $required = isset( $values['field_options']['required_' . $field_id] ) ? $values['field_options']['required_' . $field_id] : false; |
|
| 262 | + $field_type = isset( $values['field_options']['type_' . $field_id] ) ? $values['field_options']['type_' . $field_id] : $field->type; |
|
| 263 | + $field_description = isset( $values['field_options']['description_' . $field_id] ) ? $values['field_options']['description_' . $field_id] : $field->description; |
|
| 264 | 264 | |
| 265 | - FrmField::update($field_id, array( |
|
| 265 | + FrmField::update( $field_id, array( |
|
| 266 | 266 | 'field_key' => $field_key, 'type' => $field_type, |
| 267 | 267 | 'default_value' => $default_value, 'field_options' => $field->field_options, |
| 268 | 268 | 'description' => $field_description, 'required' => $required, |
| 269 | 269 | ) ); |
| 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 | |
@@ -281,17 +281,17 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public static function set_status( $id, $status ) { |
| 283 | 283 | if ( 'trash' == $status ) { |
| 284 | - return self::trash($id); |
|
| 284 | + return self::trash( $id ); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
| 287 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
| 288 | 288 | if ( ! in_array( $status, $statuses ) ) { |
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | global $wpdb; |
| 293 | 293 | |
| 294 | - if ( is_array($id) ) { |
|
| 294 | + if ( is_array( $id ) ) { |
|
| 295 | 295 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
| 296 | 296 | FrmDb::get_where_clause_and_values( $where ); |
| 297 | 297 | array_unshift( $where['values'], $status ); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | return self::destroy( $id ); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - $form = self::getOne($id); |
|
| 320 | + $form = self::getOne( $id ); |
|
| 321 | 321 | if ( ! $form ) { |
| 322 | 322 | return false; |
| 323 | 323 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | public static function destroy( $id ) { |
| 352 | 352 | global $wpdb; |
| 353 | 353 | |
| 354 | - $form = self::getOne($id); |
|
| 354 | + $form = self::getOne( $id ); |
|
| 355 | 355 | if ( ! $form ) { |
| 356 | 356 | return false; |
| 357 | 357 | } |
@@ -360,8 +360,8 @@ discard block |
||
| 360 | 360 | // Disconnect the entries from this form |
| 361 | 361 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
| 362 | 362 | foreach ( $entries as $entry_id ) { |
| 363 | - FrmEntry::destroy($entry_id); |
|
| 364 | - unset($entry_id); |
|
| 363 | + FrmEntry::destroy( $entry_id ); |
|
| 364 | + unset( $entry_id ); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | // Disconnect the fields from this form |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if ( $query_results ) { |
| 372 | 372 | // Delete all form actions linked to this form |
| 373 | 373 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
| 374 | - $action_control->destroy($id, 'all'); |
|
| 374 | + $action_control->destroy( $id, 'all' ); |
|
| 375 | 375 | |
| 376 | 376 | // Clear form caching |
| 377 | 377 | self::clear_form_cache(); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $form->options = maybe_unserialize( $form->options ); |
| 406 | 406 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
| 407 | 407 | self::destroy( $form->id ); |
| 408 | - $count++; |
|
| 408 | + $count ++; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | unset( $form ); |
@@ -419,15 +419,15 @@ discard block |
||
| 419 | 419 | public static function &getName( $id ) { |
| 420 | 420 | global $wpdb; |
| 421 | 421 | |
| 422 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 422 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 423 | 423 | if ( $form ) { |
| 424 | - $r = stripslashes($form->name); |
|
| 424 | + $r = stripslashes( $form->name ); |
|
| 425 | 425 | return $r; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
| 429 | 429 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
| 430 | - $r = stripslashes($r); |
|
| 430 | + $r = stripslashes( $r ); |
|
| 431 | 431 | |
| 432 | 432 | return $r; |
| 433 | 433 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | */ |
| 448 | 448 | public static function &getKeyById( $id ) { |
| 449 | 449 | $id = (int) $id; |
| 450 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
| 450 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
| 451 | 451 | if ( $cache ) { |
| 452 | 452 | return $cache->form_key; |
| 453 | 453 | } |
@@ -481,17 +481,17 @@ discard block |
||
| 481 | 481 | $table_name = $prefix . 'frm_forms'; |
| 482 | 482 | } else { |
| 483 | 483 | $table_name = $wpdb->prefix . 'frm_forms'; |
| 484 | - $cache = wp_cache_get($id, 'frm_form'); |
|
| 484 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
| 485 | 485 | if ( $cache ) { |
| 486 | - if ( isset($cache->options) ) { |
|
| 487 | - $cache->options = maybe_unserialize($cache->options); |
|
| 486 | + if ( isset( $cache->options ) ) { |
|
| 487 | + $cache->options = maybe_unserialize( $cache->options ); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - return stripslashes_deep($cache); |
|
| 490 | + return stripslashes_deep( $cache ); |
|
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( is_numeric($id) ) { |
|
| 494 | + if ( is_numeric( $id ) ) { |
|
| 495 | 495 | $where = array( 'id' => $id ); |
| 496 | 496 | } else { |
| 497 | 497 | $where = array( 'form_key' => $id ); |
@@ -499,11 +499,11 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | $results = FrmDb::get_row( $table_name, $where ); |
| 501 | 501 | |
| 502 | - if ( isset($results->options) ) { |
|
| 502 | + if ( isset( $results->options ) ) { |
|
| 503 | 503 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
| 504 | - $results->options = maybe_unserialize($results->options); |
|
| 504 | + $results->options = maybe_unserialize( $results->options ); |
|
| 505 | 505 | } |
| 506 | - return stripslashes_deep($results); |
|
| 506 | + return stripslashes_deep( $results ); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | $results = reset( $results ); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - return stripslashes_deep($results); |
|
| 535 | + return stripslashes_deep( $results ); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
@@ -572,19 +572,19 @@ discard block |
||
| 572 | 572 | foreach ( $results as $row ) { |
| 573 | 573 | if ( 'trash' != $row->status ) { |
| 574 | 574 | if ( $row->is_template ) { |
| 575 | - $counts['template']++; |
|
| 575 | + $counts['template'] ++; |
|
| 576 | 576 | } else { |
| 577 | - $counts['published']++; |
|
| 577 | + $counts['published'] ++; |
|
| 578 | 578 | } |
| 579 | 579 | } else { |
| 580 | - $counts['trash']++; |
|
| 580 | + $counts['trash'] ++; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | if ( 'draft' == $row->status ) { |
| 584 | - $counts['draft']++; |
|
| 584 | + $counts['draft'] ++; |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | - unset($row); |
|
| 587 | + unset( $row ); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | $counts = (object) $counts; |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | public static function validate( $values ) { |
| 611 | 611 | $errors = array(); |
| 612 | 612 | |
| 613 | - return apply_filters('frm_validate_form', $errors, $values); |
|
| 613 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | public static function get_params( $form = null ) { |
@@ -622,11 +622,11 @@ discard block |
||
| 622 | 622 | self::maybe_get_form( $form ); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
| 626 | - return $frm_vars['form_params'][ $form->id ]; |
|
| 625 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
| 626 | + return $frm_vars['form_params'][$form->id]; |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
| 629 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 630 | 630 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
| 631 | 631 | |
| 632 | 632 | $default_values = array( |
@@ -644,15 +644,15 @@ discard block |
||
| 644 | 644 | //if there are two forms on the same page, make sure not to submit both |
| 645 | 645 | foreach ( $default_values as $var => $default ) { |
| 646 | 646 | if ( $var == 'action' ) { |
| 647 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 647 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
| 648 | 648 | } else { |
| 649 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 649 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 650 | 650 | } |
| 651 | 651 | unset( $var, $default ); |
| 652 | 652 | } |
| 653 | 653 | } else { |
| 654 | 654 | foreach ( $default_values as $var => $default ) { |
| 655 | - $values[ $var ] = $default; |
|
| 655 | + $values[$var] = $default; |
|
| 656 | 656 | unset( $var, $default ); |
| 657 | 657 | } |
| 658 | 658 | } |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | public static function list_page_params() { |
| 668 | 668 | $values = array(); |
| 669 | 669 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
| 670 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 670 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | return $values; |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
| 688 | 688 | 'keep_post' => '', |
| 689 | 689 | ) as $var => $default ) { |
| 690 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
| 690 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | return $values; |
@@ -729,16 +729,16 @@ discard block |
||
| 729 | 729 | $small_form = new stdClass(); |
| 730 | 730 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
| 731 | 731 | $small_form->{$var} = $form->{$var}; |
| 732 | - unset($var); |
|
| 732 | + unset( $var ); |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | $frm_vars['forms_loaded'][] = $small_form; |
| 736 | 736 | |
| 737 | - if ( $this_load && empty($global_load) ) { |
|
| 737 | + if ( $this_load && empty( $global_load ) ) { |
|
| 738 | 738 | $global_load = $frm_vars['load_css'] = true; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 741 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | public static function show_submit( $form ) { |