@@ -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 | } |
@@ -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,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 | |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 56 | 56 | |
| 57 | 57 | if ( $new_values['item_key'] == $new_values['name'] ) { |
| 58 | - unset($check_val['name']); |
|
| 58 | + unset( $check_val['name'] ); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | global $wpdb; |
| 62 | 62 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
| 63 | 63 | |
| 64 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
| 64 | + if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | $is_duplicate = true; |
| 71 | 71 | |
| 72 | 72 | //add more checks here to make sure it's a duplicate |
| 73 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
| 73 | + $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
|
| 74 | 74 | $field_metas = array(); |
| 75 | 75 | foreach ( $metas as $meta ) { |
| 76 | - $field_metas[ $meta->field_id ] = $meta->meta_value; |
|
| 76 | + $field_metas[$meta->field_id] = $meta->meta_value; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | // If prev entry is empty and current entry is not, they are not duplicates |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | return false; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
| 85 | + $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) ); |
|
| 86 | 86 | foreach ( $diff as $field_id => $meta_value ) { |
| 87 | - if ( ! empty($meta_value) ) { |
|
| 87 | + if ( ! empty( $meta_value ) ) { |
|
| 88 | 88 | $is_duplicate = false; |
| 89 | 89 | continue; |
| 90 | 90 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // If CSV is importing, don't check for duplicates |
| 116 | - if ( defined('WP_IMPORTING') && WP_IMPORTING ) { |
|
| 116 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
| 117 | 117 | return false; |
| 118 | 118 | } |
| 119 | 119 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $new_values['is_draft'] = $values->is_draft; |
| 137 | 137 | $new_values['user_id'] = (int) $values->user_id; |
| 138 | 138 | $new_values['updated_by'] = (int) $values->user_id; |
| 139 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 139 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
| 140 | 140 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
| 141 | 141 | $new_values['updated_at'] = $new_values['created_at']; |
| 142 | 142 | |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | $entry_id = $wpdb->insert_id; |
| 149 | 149 | |
| 150 | 150 | global $frm_vars; |
| 151 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 151 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 152 | 152 | $frm_vars['saved_entries'] = array(); |
| 153 | 153 | } |
| 154 | 154 | $frm_vars['saved_entries'][] = (int) $entry_id; |
| 155 | 155 | |
| 156 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
| 156 | + FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
|
| 157 | 157 | self::clear_cache(); |
| 158 | 158 | |
| 159 | 159 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $new_values = self::package_entry_to_update( $id, $values ); |
| 194 | 194 | |
| 195 | - $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact('id') ); |
|
| 195 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); |
|
| 196 | 196 | |
| 197 | 197 | self::after_update_entry( $query_results, $id, $values, $new_values ); |
| 198 | 198 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | return $result; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
| 212 | + do_action( 'frm_before_destroy_entry', $id, $entry ); |
|
| 213 | 213 | |
| 214 | 214 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
| 215 | 215 | $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | |
| 222 | 222 | public static function update_form( $id, $value, $form_id ) { |
| 223 | 223 | global $wpdb; |
| 224 | - $form_id = isset($value) ? $form_id : null; |
|
| 224 | + $form_id = isset( $value ) ? $form_id : null; |
|
| 225 | 225 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 226 | 226 | if ( $result ) { |
| 227 | 227 | self::clear_cache(); |
@@ -268,24 +268,24 @@ discard block |
||
| 268 | 268 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
| 269 | 269 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 270 | 270 | |
| 271 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 271 | + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 272 | 272 | $query_args = array( $id ); |
| 273 | 273 | $query = $wpdb->prepare( $query, $query_args ); |
| 274 | 274 | |
| 275 | 275 | if ( ! $meta ) { |
| 276 | 276 | $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
| 277 | - return stripslashes_deep($entry); |
|
| 277 | + return stripslashes_deep( $entry ); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
| 281 | 281 | if ( $entry !== false ) { |
| 282 | - return stripslashes_deep($entry); |
|
| 282 | + return stripslashes_deep( $entry ); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | $entry = $wpdb->get_row( $query ); |
| 286 | - $entry = self::get_meta($entry); |
|
| 286 | + $entry = self::get_meta( $entry ); |
|
| 287 | 287 | |
| 288 | - return stripslashes_deep($entry); |
|
| 288 | + return stripslashes_deep( $entry ); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | public static function get_meta( $entry ) { |
@@ -301,23 +301,23 @@ discard block |
||
| 301 | 301 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
| 302 | 302 | foreach ( $metas as $meta_val ) { |
| 303 | 303 | if ( $meta_val->item_id == $entry->id ) { |
| 304 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 304 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 305 | 305 | if ( $include_key ) { |
| 306 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
| 306 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
| 307 | 307 | } |
| 308 | 308 | continue; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // include sub entries in an array |
| 312 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
| 313 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
| 312 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
| 313 | + $entry->metas[$meta_val->field_id] = array(); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 316 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 317 | 317 | |
| 318 | - unset($meta_val); |
|
| 318 | + unset( $meta_val ); |
|
| 319 | 319 | } |
| 320 | - unset($metas); |
|
| 320 | + unset( $metas ); |
|
| 321 | 321 | |
| 322 | 322 | FrmAppHelper::set_cache( $entry->id, $entry, 'frm_entry' ); |
| 323 | 323 | |
@@ -335,24 +335,24 @@ discard block |
||
| 335 | 335 | return $exists; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if ( is_numeric($id) ) { |
|
| 338 | + if ( is_numeric( $id ) ) { |
|
| 339 | 339 | $where = array( 'id' => $id ); |
| 340 | 340 | } else { |
| 341 | 341 | $where = array( 'item_key' => $id ); |
| 342 | 342 | } |
| 343 | 343 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 344 | 344 | |
| 345 | - $exists = ($id && $id > 0) ? true : false; |
|
| 345 | + $exists = ( $id && $id > 0 ) ? true : false; |
|
| 346 | 346 | return $exists; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
| 350 | 350 | global $wpdb; |
| 351 | 351 | |
| 352 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 352 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
| 353 | 353 | |
| 354 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
| 355 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
| 354 | + $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
|
| 355 | + $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
|
| 356 | 356 | |
| 357 | 357 | if ( false === $entries ) { |
| 358 | 358 | $fields = 'it.id, it.item_key, it.name, it.ip, it.form_id, it.post_id, it.user_id, it.parent_item_id, it.updated_by, it.created_at, it.updated_at, it.is_draft'; |
@@ -371,25 +371,25 @@ discard block |
||
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | // prepare the query |
| 374 | - $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 374 | + $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 375 | 375 | |
| 376 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
| 377 | - unset($query); |
|
| 376 | + $entries = $wpdb->get_results( $query, OBJECT_K ); |
|
| 377 | + unset( $query ); |
|
| 378 | 378 | |
| 379 | 379 | FrmAppHelper::set_cache( $cache_key, $entries, 'frm_entry' ); |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if ( ! $meta || ! $entries ) { |
| 383 | - return stripslashes_deep($entries); |
|
| 383 | + return stripslashes_deep( $entries ); |
|
| 384 | 384 | } |
| 385 | - unset($meta); |
|
| 385 | + unset( $meta ); |
|
| 386 | 386 | |
| 387 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 387 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
| 388 | 388 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | $meta_where = array( 'field_id !' => 0 ); |
| 392 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 392 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
| 393 | 393 | $meta_where['fi.form_id'] = $where['it.form_id']; |
| 394 | 394 | } else { |
| 395 | 395 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -400,21 +400,21 @@ discard block |
||
| 400 | 400 | unset( $meta_where ); |
| 401 | 401 | |
| 402 | 402 | if ( ! $metas ) { |
| 403 | - return stripslashes_deep($entries); |
|
| 403 | + return stripslashes_deep( $entries ); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | foreach ( $metas as $m_key => $meta_val ) { |
| 407 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 407 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 408 | 408 | continue; |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 412 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 411 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 412 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 415 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 416 | 416 | |
| 417 | - unset($m_key, $meta_val); |
|
| 417 | + unset( $m_key, $meta_val ); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return stripslashes_deep($entries); |
|
| 427 | + return stripslashes_deep( $entries ); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Pagination Methods |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | global $wpdb; |
| 433 | 433 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
| 434 | 434 | |
| 435 | - if ( is_numeric($where) ) { |
|
| 435 | + if ( is_numeric( $where ) ) { |
|
| 436 | 436 | $table_join = 'frm_items'; |
| 437 | 437 | $where = array( 'form_id' => $where ); |
| 438 | 438 | } |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | self::sanitize_entry_post( $values ); |
| 475 | 475 | |
| 476 | 476 | if ( $type != 'xml' ) { |
| 477 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
| 477 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $new_values = self::package_entry_data( $values ); |
@@ -554,11 +554,11 @@ discard block |
||
| 554 | 554 | 'user_id' => self::get_entry_user_id( $values ), |
| 555 | 555 | ); |
| 556 | 556 | |
| 557 | - if ( is_array($new_values['name']) ) { |
|
| 558 | - $new_values['name'] = reset($new_values['name']); |
|
| 557 | + if ( is_array( $new_values['name'] ) ) { |
|
| 558 | + $new_values['name'] = reset( $new_values['name'] ); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
| 561 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
| 562 | 562 | |
| 563 | 563 | return $new_values; |
| 564 | 564 | } |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @return int |
| 594 | 594 | */ |
| 595 | 595 | private static function get_post_id( $values ) { |
| 596 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
| 596 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | /** |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @return int |
| 605 | 605 | */ |
| 606 | 606 | private static function get_parent_item_id( $values ) { |
| 607 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
| 607 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | /** |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | * @return string |
| 616 | 616 | */ |
| 617 | 617 | private static function get_created_at( $values ) { |
| 618 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
| 618 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | /** |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 704 | 704 | global $frm_vars; |
| 705 | 705 | |
| 706 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 706 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 707 | 707 | $frm_vars['saved_entries'] = array(); |
| 708 | 708 | } |
| 709 | 709 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param int $entry_id |
| 719 | 719 | */ |
| 720 | 720 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 721 | - if ( isset($values['item_meta']) ) { |
|
| 721 | + if ( isset( $values['item_meta'] ) ) { |
|
| 722 | 722 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
| 736 | 736 | |
| 737 | 737 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
| 738 | - do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
| 738 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | if ( $update && $update_type != 'xml' ) { |
| 779 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
| 779 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | return $update; |
@@ -797,27 +797,27 @@ discard block |
||
| 797 | 797 | 'name' => self::get_new_entry_name( $values ), |
| 798 | 798 | 'form_id' => self::get_form_id( $values ), |
| 799 | 799 | 'is_draft' => self::get_is_draft_value( $values ), |
| 800 | - 'updated_at' => current_time('mysql', 1), |
|
| 801 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
| 800 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
| 801 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
| 802 | 802 | ); |
| 803 | 803 | |
| 804 | - if ( isset($values['post_id']) ) { |
|
| 804 | + if ( isset( $values['post_id'] ) ) { |
|
| 805 | 805 | $new_values['post_id'] = (int) $values['post_id']; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( isset($values['item_key']) ) { |
|
| 808 | + if ( isset( $values['item_key'] ) ) { |
|
| 809 | 809 | $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | - if ( isset($values['parent_item_id']) ) { |
|
| 812 | + if ( isset( $values['parent_item_id'] ) ) { |
|
| 813 | 813 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
| 816 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
| 817 | 817 | $new_values['user_id'] = $values['frm_user_id']; |
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
| 820 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
| 821 | 821 | |
| 822 | 822 | return $new_values; |
| 823 | 823 | } |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | var $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $frm_db_version = FrmAppHelper::$db_version; |
| 27 | 27 | $old_db_version = (float) $old_db_version; |
| 28 | 28 | if ( ! $old_db_version ) { |
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 29 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( $frm_db_version != $old_db_version ) { |
@@ -36,16 +36,16 @@ discard block |
||
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | 38 | $this->create_tables(); |
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 39 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
| 40 | 40 | |
| 41 | 41 | /***** SAVE DB VERSION *****/ |
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 42 | + update_option( 'frm_db_version', $frm_db_version ); |
|
| 43 | 43 | |
| 44 | 44 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
| 45 | 45 | FrmXMLController::add_default_templates(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - do_action('frm_after_install'); |
|
| 48 | + do_action( 'frm_after_install' ); |
|
| 49 | 49 | |
| 50 | 50 | /**** update the styling settings ****/ |
| 51 | 51 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | global $wpdb; |
| 156 | 156 | $wpdb->query( $q . $charset_collate ); |
| 157 | 157 | } |
| 158 | - unset($q); |
|
| 158 | + unset( $q ); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $starts_with |
| 181 | 181 | */ |
| 182 | 182 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
| 183 | - if ( empty($args) ) { |
|
| 183 | + if ( empty( $args ) ) { |
|
| 184 | 184 | // add an arg to prevent prepare from failing |
| 185 | 185 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 186 | 186 | return; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | $key = trim( $key ); |
| 242 | 242 | |
| 243 | 243 | if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
| 244 | - $k = explode(' ', $key); |
|
| 244 | + $k = explode( ' ', $key ); |
|
| 245 | 245 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
| 246 | 246 | $values[] = '%Y-%m-%d %H:%i:%s'; |
| 247 | 247 | } else { |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | if ( is_array( $value ) ) { |
| 255 | 255 | // translate array of values to "in" |
| 256 | 256 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 257 | - $where = preg_replace('/' . $key . '$/', '', $where); |
|
| 257 | + $where = preg_replace( '/' . $key . '$/', '', $where ); |
|
| 258 | 258 | $where .= '('; |
| 259 | 259 | $start = true; |
| 260 | 260 | foreach ( $value as $v ) { |
@@ -415,8 +415,8 @@ discard block |
||
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | 417 | $where_is = strtolower( $where_is ); |
| 418 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
| 419 | - return ' ' . $switch_to[ $where_is ]; |
|
| 418 | + if ( isset( $switch_to[$where_is] ) ) { |
|
| 419 | + return ' ' . $switch_to[$where_is]; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -438,8 +438,8 @@ discard block |
||
| 438 | 438 | private static function get_group_and_table_name( &$table, &$group ) { |
| 439 | 439 | global $wpdb, $wpmuBaseTablePrefix; |
| 440 | 440 | |
| 441 | - $table_parts = explode(' ', $table); |
|
| 442 | - $group = reset($table_parts); |
|
| 441 | + $table_parts = explode( ' ', $table ); |
|
| 442 | + $group = reset( $table_parts ); |
|
| 443 | 443 | $group = str_replace( $wpdb->prefix, '', $group ); |
| 444 | 444 | |
| 445 | 445 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
| 457 | - if ( ! is_array($args) ) { |
|
| 457 | + if ( ! is_array( $args ) ) { |
|
| 458 | 458 | $args = array( 'order_by' => $args ); |
| 459 | 459 | } |
| 460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
| 469 | 469 | $temp_args = $args; |
| 470 | 470 | foreach ( $temp_args as $k => $v ) { |
| 471 | 471 | if ( $v == '' ) { |
| 472 | - unset( $args[ $k ] ); |
|
| 472 | + unset( $args[$k] ); |
|
| 473 | 473 | continue; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | if ( $k == 'limit' ) { |
| 477 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
| 477 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
| 478 | 478 | } |
| 479 | 479 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
| 480 | 480 | if ( strpos( $v, $db_name ) === false ) { |
| 481 | - $args[ $k ] = $db_name . ' ' . $v; |
|
| 481 | + $args[$k] = $db_name . ' ' . $v; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | $query = self::generate_query_string_from_pieces( $columns, $table, $where ); |
| 507 | 507 | |
| 508 | - $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) ); |
|
| 508 | + $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) ); |
|
| 509 | 509 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' ); |
| 510 | 510 | |
| 511 | 511 | return $results; |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | public function uninstall() { |
| 545 | 545 | if ( ! current_user_can( 'administrator' ) ) { |
| 546 | 546 | $frm_settings = FrmAppHelper::get_settings(); |
| 547 | - wp_die($frm_settings->admin_permission); |
|
| 547 | + wp_die( $frm_settings->admin_permission ); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | global $wpdb, $wp_roles; |
@@ -554,8 +554,8 @@ discard block |
||
| 554 | 554 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 555 | 555 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 556 | 556 | |
| 557 | - delete_option('frm_options'); |
|
| 558 | - delete_option('frm_db_version'); |
|
| 557 | + delete_option( 'frm_options' ); |
|
| 558 | + delete_option( 'frm_db_version' ); |
|
| 559 | 559 | |
| 560 | 560 | //delete roles |
| 561 | 561 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -563,11 +563,11 @@ discard block |
||
| 563 | 563 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 564 | 564 | foreach ( $roles as $role => $details ) { |
| 565 | 565 | $wp_roles->remove_cap( $role, $frm_role ); |
| 566 | - unset($role, $details); |
|
| 566 | + unset( $role, $details ); |
|
| 567 | 567 | } |
| 568 | - unset($frm_role, $frm_role_description); |
|
| 568 | + unset( $frm_role, $frm_role_description ); |
|
| 569 | 569 | } |
| 570 | - unset($roles, $frm_roles); |
|
| 570 | + unset( $roles, $frm_roles ); |
|
| 571 | 571 | |
| 572 | 572 | // delete actions, views, and styles |
| 573 | 573 | |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | |
| 590 | 590 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 591 | 591 | |
| 592 | - do_action('frm_after_uninstall'); |
|
| 592 | + do_action( 'frm_after_uninstall' ); |
|
| 593 | 593 | return true; |
| 594 | 594 | } |
| 595 | 595 | |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | $updated = 0; |
| 648 | 648 | foreach ( $fields as $f ) { |
| 649 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 650 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 649 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 650 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 651 | 651 | continue; |
| 652 | 652 | } |
| 653 | 653 | |
@@ -655,27 +655,27 @@ discard block |
||
| 655 | 655 | $f->field_options['size'] .= 'px'; |
| 656 | 656 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 657 | 657 | if ( $u ) { |
| 658 | - $updated++; |
|
| 658 | + $updated ++; |
|
| 659 | 659 | } |
| 660 | - unset($f); |
|
| 660 | + unset( $f ); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | // Change the characters in widgets to pixels |
| 664 | - $widgets = get_option('widget_frm_show_form'); |
|
| 665 | - if ( empty($widgets) ) { |
|
| 664 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 665 | + if ( empty( $widgets ) ) { |
|
| 666 | 666 | return; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - $widgets = maybe_unserialize($widgets); |
|
| 669 | + $widgets = maybe_unserialize( $widgets ); |
|
| 670 | 670 | foreach ( $widgets as $k => $widget ) { |
| 671 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 671 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 672 | 672 | continue; |
| 673 | 673 | } |
| 674 | 674 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 675 | 675 | $size .= 'px'; |
| 676 | - $widgets[ $k ]['size'] = $size; |
|
| 676 | + $widgets[$k]['size'] = $size; |
|
| 677 | 677 | } |
| 678 | - update_option('widget_frm_show_form', $widgets); |
|
| 678 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | // Format form options |
| 727 | - $form_options = maybe_unserialize($form->options); |
|
| 727 | + $form_options = maybe_unserialize( $form->options ); |
|
| 728 | 728 | |
| 729 | 729 | // Migrate settings to actions |
| 730 | 730 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | private function migrate_to_11() { |
| 735 | 735 | global $wpdb; |
| 736 | 736 | |
| 737 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 737 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 738 | 738 | |
| 739 | 739 | $sending = __( 'Sending', 'formidable' ); |
| 740 | 740 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -745,13 +745,13 @@ discard block |
||
| 745 | 745 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 746 | 746 | </div> |
| 747 | 747 | DEFAULT_HTML; |
| 748 | - unset($sending, $img); |
|
| 748 | + unset( $sending, $img ); |
|
| 749 | 749 | |
| 750 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 750 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 751 | 751 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 752 | 752 | foreach ( $forms as $form ) { |
| 753 | - $form->options = maybe_unserialize($form->options); |
|
| 754 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 753 | + $form->options = maybe_unserialize( $form->options ); |
|
| 754 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 755 | 755 | continue; |
| 756 | 756 | } |
| 757 | 757 | |
@@ -762,9 +762,9 @@ discard block |
||
| 762 | 762 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 763 | 763 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 764 | 764 | } |
| 765 | - unset($form); |
|
| 765 | + unset( $form ); |
|
| 766 | 766 | } |
| 767 | - unset($forms); |
|
| 767 | + unset( $forms ); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | private function migrate_to_6() { |
@@ -793,16 +793,16 @@ discard block |
||
| 793 | 793 | </div> |
| 794 | 794 | DEFAULT_HTML; |
| 795 | 795 | |
| 796 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 796 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 797 | 797 | foreach ( $fields as $field ) { |
| 798 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 798 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 799 | 799 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 800 | 800 | $field->field_options['custom_html'] = $new_default_html; |
| 801 | 801 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 802 | 802 | } |
| 803 | - unset($field); |
|
| 803 | + unset( $field ); |
|
| 804 | 804 | } |
| 805 | - unset($default_html, $old_default_html, $fields); |
|
| 805 | + unset( $default_html, $old_default_html, $fields ); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | private function migrate_to_4() { |
@@ -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 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | 'meta_value' => is_array( $meta_value ) ? serialize( array_filter( $meta_value, 'FrmAppHelper::is_not_empty_value' ) ) : trim( $meta_value ), |
| 21 | 21 | 'item_id' => $entry_id, |
| 22 | 22 | 'field_id' => $field_id, |
| 23 | - 'created_at' => current_time('mysql', 1), |
|
| 23 | + 'created_at' => current_time( 'mysql', 1 ), |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | - $new_values = apply_filters('frm_add_entry_meta', $new_values); |
|
| 26 | + $new_values = apply_filters( 'frm_add_entry_meta', $new_values ); |
|
| 27 | 27 | |
| 28 | 28 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_item_metas', $new_values ); |
| 29 | 29 | |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | $values = array( 'item_id' => $entry_id, 'field_id' => $field_id ); |
| 51 | 51 | $where_values = $values; |
| 52 | 52 | $values['meta_value'] = $meta_value; |
| 53 | - $values = apply_filters('frm_update_entry_meta', $values); |
|
| 54 | - if ( is_array($values['meta_value']) ) { |
|
| 53 | + $values = apply_filters( 'frm_update_entry_meta', $values ); |
|
| 54 | + if ( is_array( $values['meta_value'] ) ) { |
|
| 55 | 55 | $values['meta_value'] = array_filter( $values['meta_value'], 'FrmAppHelper::is_not_empty_value' ); |
| 56 | 56 | } |
| 57 | - $meta_value = maybe_serialize($values['meta_value']); |
|
| 57 | + $meta_value = maybe_serialize( $values['meta_value'] ); |
|
| 58 | 58 | |
| 59 | - wp_cache_delete( $entry_id, 'frm_entry'); |
|
| 59 | + wp_cache_delete( $entry_id, 'frm_entry' ); |
|
| 60 | 60 | self::clear_cache(); |
| 61 | 61 | |
| 62 | 62 | return $wpdb->update( $wpdb->prefix . 'frm_item_metas', array( 'meta_value' => $meta_value ), $where_values ); |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | // set the value for the file upload field and add new tags (in Pro version) |
| 77 | 77 | $meta_value = apply_filters( 'frm_prepare_data_before_db', $meta_value, $field_id, $entry_id, compact( 'field' ) ); |
| 78 | 78 | |
| 79 | - if ( $prev_values && in_array($field_id, $prev_values) ) { |
|
| 79 | + if ( $prev_values && in_array( $field_id, $prev_values ) ) { |
|
| 80 | 80 | |
| 81 | 81 | if ( ( is_array( $meta_value ) && empty( $meta_value ) ) || ( ! is_array( $meta_value ) && trim( $meta_value ) == '' ) ) { |
| 82 | 82 | // remove blank fields |
| 83 | - unset( $values[ $field_id ] ); |
|
| 83 | + unset( $values[$field_id] ); |
|
| 84 | 84 | } else { |
| 85 | 85 | // if value exists, then update it |
| 86 | 86 | self::update_entry_meta( $entry_id, $field_id, '', $meta_value ); |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( empty($prev_values) ) { |
|
| 94 | + if ( empty( $prev_values ) ) { |
|
| 95 | 95 | return; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $prev_values = array_diff($prev_values, array_keys($values)); |
|
| 98 | + $prev_values = array_diff( $prev_values, array_keys( $values ) ); |
|
| 99 | 99 | |
| 100 | - if ( empty($prev_values) ) { |
|
| 100 | + if ( empty( $prev_values ) ) { |
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public static function duplicate_entry_metas( $old_id, $new_id ) { |
| 114 | - $metas = self::get_entry_meta_info($old_id); |
|
| 114 | + $metas = self::get_entry_meta_info( $old_id ); |
|
| 115 | 115 | foreach ( $metas as $meta ) { |
| 116 | - self::add_entry_meta($new_id, $meta->field_id, null, $meta->meta_value); |
|
| 117 | - unset($meta); |
|
| 116 | + self::add_entry_meta( $new_id, $meta->field_id, null, $meta->meta_value ); |
|
| 117 | + unset( $meta ); |
|
| 118 | 118 | } |
| 119 | 119 | self::clear_cache(); |
| 120 | 120 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | public static function delete_entry_meta( $entry_id, $field_id ) { |
| 123 | 123 | global $wpdb; |
| 124 | 124 | self::clear_cache(); |
| 125 | - return $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id)); |
|
| 125 | + return $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}frm_item_metas WHERE field_id=%d AND item_id=%d", $field_id, $entry_id ) ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public static function get_meta_value( $entry, $field_id ) { |
| 143 | 143 | if ( isset( $entry->metas ) ) { |
| 144 | - return isset( $entry->metas[ $field_id ] ) ? $entry->metas[ $field_id ] : false; |
|
| 144 | + return isset( $entry->metas[$field_id] ) ? $entry->metas[$field_id] : false; |
|
| 145 | 145 | } else { |
| 146 | 146 | return self::get_entry_meta_by_field( $entry->id, $field_id ); |
| 147 | 147 | } |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | $cached = FrmAppHelper::check_cache( $entry_id, 'frm_entry' ); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( $cached && isset( $cached->metas ) && isset( $cached->metas[ $field_id ] ) ) { |
|
| 163 | - $result = $cached->metas[ $field_id ]; |
|
| 164 | - return stripslashes_deep($result); |
|
| 162 | + if ( $cached && isset( $cached->metas ) && isset( $cached->metas[$field_id] ) ) { |
|
| 163 | + $result = $cached->metas[$field_id]; |
|
| 164 | + return stripslashes_deep( $result ); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $get_table = $wpdb->prefix . 'frm_item_metas'; |
| 168 | 168 | $query = array( 'item_id' => $entry_id ); |
| 169 | - if ( is_numeric($field_id) ) { |
|
| 169 | + if ( is_numeric( $field_id ) ) { |
|
| 170 | 170 | $query['field_id'] = $field_id; |
| 171 | 171 | } else { |
| 172 | 172 | $get_table .= ' it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $result = FrmDb::get_var( $get_table, $query, 'meta_value' ); |
| 177 | - $result = maybe_unserialize($result); |
|
| 178 | - $result = stripslashes_deep($result); |
|
| 177 | + $result = maybe_unserialize( $result ); |
|
| 178 | + $result = stripslashes_deep( $result ); |
|
| 179 | 179 | |
| 180 | 180 | return $result; |
| 181 | 181 | } |
@@ -185,22 +185,22 @@ discard block |
||
| 185 | 185 | $args = wp_parse_args( $args, $defaults ); |
| 186 | 186 | |
| 187 | 187 | $query = array(); |
| 188 | - self::meta_field_query($field_id, $order, $limit, $args, $query); |
|
| 189 | - $query = implode(' ', $query); |
|
| 188 | + self::meta_field_query( $field_id, $order, $limit, $args, $query ); |
|
| 189 | + $query = implode( ' ', $query ); |
|
| 190 | 190 | |
| 191 | 191 | $cache_key = 'entry_metas_for_field_' . $field_id . $order . $limit . maybe_serialize( $args ); |
| 192 | - $values = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_col'); |
|
| 192 | + $values = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_col' ); |
|
| 193 | 193 | |
| 194 | 194 | if ( ! $args['stripslashes'] ) { |
| 195 | 195 | return $values; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | foreach ( $values as $k => $v ) { |
| 199 | - $values[ $k ] = maybe_unserialize( $v ); |
|
| 200 | - unset($k, $v); |
|
| 199 | + $values[$k] = maybe_unserialize( $v ); |
|
| 200 | + unset( $k, $v ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - return stripslashes_deep($values); |
|
| 203 | + return stripslashes_deep( $values ); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=em.item_id)'; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( is_numeric($field_id) ) { |
|
| 221 | - $query[] = $wpdb->prepare('WHERE em.field_id=%d', $field_id); |
|
| 220 | + if ( is_numeric( $field_id ) ) { |
|
| 221 | + $query[] = $wpdb->prepare( 'WHERE em.field_id=%d', $field_id ); |
|
| 222 | 222 | } else { |
| 223 | 223 | $query[] = $wpdb->prepare( 'LEFT JOIN ' . $wpdb->prefix . 'frm_fields fi ON (em.field_id = fi.id) WHERE fi.field_key=%s', $field_id ); |
| 224 | 224 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | if ( $args['value'] ) { |
| 231 | - $query[] = $wpdb->prepare(' AND meta_value=%s', $args['value']); |
|
| 231 | + $query[] = $wpdb->prepare( ' AND meta_value=%s', $args['value'] ); |
|
| 232 | 232 | } |
| 233 | 233 | $query[] = $order . $limit; |
| 234 | 234 | } |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | $query = 'SELECT it.*, fi.type as field_type, fi.field_key as field_key, |
| 243 | 243 | fi.required as required, fi.form_id as field_form_id, fi.name as field_name, fi.options as fi_options |
| 244 | 244 | FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id' . |
| 245 | - FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 245 | + FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 246 | 246 | |
| 247 | 247 | $cache_key = 'all_' . maybe_serialize( $where ) . $order_by . $limit; |
| 248 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_row' : 'get_results')); |
|
| 248 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_row' : 'get_results' ) ); |
|
| 249 | 249 | |
| 250 | 250 | if ( ! $results || ! $stripslashes ) { |
| 251 | 251 | return $results; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | foreach ( $results as $k => $result ) { |
| 255 | - $results[ $k ]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
| 256 | - unset($k, $result); |
|
| 255 | + $results[$k]->meta_value = stripslashes_deep( maybe_unserialize( $result->meta_value ) ); |
|
| 256 | + unset( $k, $result ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | return $results; |
@@ -265,14 +265,14 @@ discard block |
||
| 265 | 265 | 'user_id' => '', |
| 266 | 266 | 'group_by' => '', |
| 267 | 267 | ); |
| 268 | - $args = wp_parse_args($args, $defaults); |
|
| 268 | + $args = wp_parse_args( $args, $defaults ); |
|
| 269 | 269 | |
| 270 | 270 | $query = array(); |
| 271 | - self::get_ids_query($where, $order_by, $limit, $unique, $args, $query ); |
|
| 272 | - $query = implode(' ', $query); |
|
| 271 | + self::get_ids_query( $where, $order_by, $limit, $unique, $args, $query ); |
|
| 272 | + $query = implode( ' ', $query ); |
|
| 273 | 273 | |
| 274 | 274 | $cache_key = 'ids_' . maybe_serialize( $where ) . $order_by . 'l' . $limit . 'u' . $unique . maybe_serialize( $args ); |
| 275 | - $results = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, ($limit == ' LIMIT 1' ? 'get_var' : 'get_col')); |
|
| 275 | + $results = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, ( $limit == ' LIMIT 1' ? 'get_var' : 'get_col' ) ); |
|
| 276 | 276 | |
| 277 | 277 | return $results; |
| 278 | 278 | } |
@@ -298,17 +298,17 @@ discard block |
||
| 298 | 298 | $query[] = 'FROM ' . $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON it.field_id=fi.id'; |
| 299 | 299 | |
| 300 | 300 | $query[] = 'INNER JOIN ' . $wpdb->prefix . 'frm_items e ON (e.id=it.item_id)'; |
| 301 | - if ( is_array($where) ) { |
|
| 301 | + if ( is_array( $where ) ) { |
|
| 302 | 302 | if ( ! $args['is_draft'] ) { |
| 303 | 303 | $where['e.is_draft'] = 0; |
| 304 | 304 | } else if ( $args['is_draft'] == 1 ) { |
| 305 | 305 | $where['e.is_draft'] = 1; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if ( ! empty($args['user_id']) ) { |
|
| 308 | + if ( ! empty( $args['user_id'] ) ) { |
|
| 309 | 309 | $where['e.user_id'] = $args['user_id']; |
| 310 | 310 | } |
| 311 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 311 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 312 | 312 | |
| 313 | 313 | if ( $args['group_by'] ) { |
| 314 | 314 | $query[] = ' GROUP BY ' . sanitize_text_field( $args['group_by'] ); |
@@ -324,13 +324,13 @@ discard block |
||
| 324 | 324 | $draft_where = $wpdb->prepare( ' AND e.is_draft=%d', 1 ); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if ( ! empty($args['user_id']) ) { |
|
| 328 | - $user_where = $wpdb->prepare(' AND e.user_id=%d', $args['user_id']); |
|
| 327 | + if ( ! empty( $args['user_id'] ) ) { |
|
| 328 | + $user_where = $wpdb->prepare( ' AND e.user_id=%d', $args['user_id'] ); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( strpos($where, ' GROUP BY ') ) { |
|
| 331 | + if ( strpos( $where, ' GROUP BY ' ) ) { |
|
| 332 | 332 | // don't inject WHERE filtering after GROUP BY |
| 333 | - $parts = explode(' GROUP BY ', $where); |
|
| 333 | + $parts = explode( ' GROUP BY ', $where ); |
|
| 334 | 334 | $where = $parts[0]; |
| 335 | 335 | $where .= $draft_where . $user_where; |
| 336 | 336 | $where .= ' GROUP BY ' . $parts[1]; |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // The query has already been prepared |
| 342 | - $query[] = FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 342 | + $query[] = FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | public static function search_entry_metas( $search, $field_id = '', $operator ) { |
| 346 | 346 | $cache_key = 'search_' . maybe_serialize( $search ) . $field_id . $operator; |
| 347 | - $results = wp_cache_get($cache_key, 'frm_entry'); |
|
| 347 | + $results = wp_cache_get( $cache_key, 'frm_entry' ); |
|
| 348 | 348 | if ( false !== $results ) { |
| 349 | 349 | return $results; |
| 350 | 350 | } |
@@ -367,18 +367,18 @@ discard block |
||
| 367 | 367 | case 'day': |
| 368 | 368 | $value = '%' . $value . '%'; |
| 369 | 369 | } |
| 370 | - $where .= $wpdb->prepare(' meta_value ' . $operator . ' %s and', $value ); |
|
| 370 | + $where .= $wpdb->prepare( ' meta_value ' . $operator . ' %s and', $value ); |
|
| 371 | 371 | } |
| 372 | - $where .= $wpdb->prepare(' field_id=%d', $field_id); |
|
| 372 | + $where .= $wpdb->prepare( ' field_id=%d', $field_id ); |
|
| 373 | 373 | $query = 'SELECT DISTINCT item_id FROM ' . $wpdb->prefix . 'frm_item_metas' . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
| 374 | 374 | } else { |
| 375 | 375 | if ( $operator == 'LIKE' ) { |
| 376 | 376 | $search = '%' . $search . '%'; |
| 377 | 377 | } |
| 378 | - $query = $wpdb->prepare("SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id); |
|
| 378 | + $query = $wpdb->prepare( "SELECT DISTINCT item_id FROM {$wpdb->prefix}frm_item_metas WHERE meta_value {$operator} %s and field_id = %d", $search, $field_id ); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $results = $wpdb->get_col($query, 0); |
|
| 381 | + $results = $wpdb->get_col( $query, 0 ); |
|
| 382 | 382 | FrmAppHelper::set_cache( $cache_key, $results, 'frm_entry' ); |
| 383 | 383 | |
| 384 | 384 | return $results; |