@@ -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 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | * @param int $duplicate_entry_time |
| 108 | 108 | * @return bool |
| 109 | 109 | */ |
| 110 | - private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ){ |
|
| 110 | + private static function is_duplicate_check_needed( $new_values, $values, &$duplicate_entry_time ) { |
|
| 111 | 111 | // If CSV is importing, don't check for duplicates |
| 112 | - if ( defined('WP_IMPORTING') && WP_IMPORTING ) { |
|
| 112 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
@@ -133,14 +133,14 @@ discard block |
||
| 133 | 133 | $values = self::getOne( $id ); |
| 134 | 134 | |
| 135 | 135 | $new_values = array(); |
| 136 | - $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 136 | + $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
|
| 137 | 137 | $new_values['name'] = $values->name; |
| 138 | 138 | $new_values['is_draft'] = $values->is_draft; |
| 139 | 139 | $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
| 140 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 141 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
| 140 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
| 141 | + $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 ); |
|
| 142 | 142 | |
| 143 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values ); |
|
| 143 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
|
| 144 | 144 | if ( ! $query_results ) { |
| 145 | 145 | return false; |
| 146 | 146 | } |
@@ -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,10 +209,10 @@ 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 | - $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) ); |
|
| 215 | - $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) ); |
|
| 214 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
|
| 215 | + $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
|
| 216 | 216 | |
| 217 | 217 | self::clear_cache(); |
| 218 | 218 | |
@@ -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 | - $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' ); |
|
| 277 | - return stripslashes_deep($entry); |
|
| 276 | + $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
|
| 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,25 +301,25 @@ discard block |
||
| 301 | 301 | $include_key = apply_filters( 'frm_include_meta_keys', false ); |
| 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 | - wp_cache_set( $entry->id, $entry, 'frm_entry'); |
|
| 322 | + wp_cache_set( $entry->id, $entry, 'frm_entry' ); |
|
| 323 | 323 | |
| 324 | 324 | return $entry; |
| 325 | 325 | } |
@@ -335,28 +335,28 @@ 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 | - $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where ); |
|
| 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'; |
| 359 | - $table = $wpdb->prefix .'frm_items it '; |
|
| 359 | + $table = $wpdb->prefix . 'frm_items it '; |
|
| 360 | 360 | |
| 361 | 361 | if ( $inc_form ) { |
| 362 | 362 | $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
@@ -366,15 +366,15 @@ discard block |
||
| 366 | 366 | if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
| 367 | 367 | // sort by a requested field |
| 368 | 368 | $field_id = (int) $order_matches[1]; |
| 369 | - $fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id; |
|
| 369 | + $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
|
| 370 | 370 | unset( $order_matches, $field_id ); |
| 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 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 380 | 380 | wp_cache_set( $cache_key, $entries, 'frm_entry', 300 ); |
@@ -382,16 +382,16 @@ discard block |
||
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | if ( ! $meta || ! $entries ) { |
| 385 | - return stripslashes_deep($entries); |
|
| 385 | + return stripslashes_deep( $entries ); |
|
| 386 | 386 | } |
| 387 | - unset($meta); |
|
| 387 | + unset( $meta ); |
|
| 388 | 388 | |
| 389 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 389 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
| 390 | 390 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $meta_where = array( 'field_id !' => 0 ); |
| 394 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 394 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
| 395 | 395 | $meta_where['fi.form_id'] = $where['it.form_id']; |
| 396 | 396 | } else { |
| 397 | 397 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -402,21 +402,21 @@ discard block |
||
| 402 | 402 | unset( $meta_where ); |
| 403 | 403 | |
| 404 | 404 | if ( ! $metas ) { |
| 405 | - return stripslashes_deep($entries); |
|
| 405 | + return stripslashes_deep( $entries ); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | foreach ( $metas as $m_key => $meta_val ) { |
| 409 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 409 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 410 | 410 | continue; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 414 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 413 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 414 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 417 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 418 | 418 | |
| 419 | - unset($m_key, $meta_val); |
|
| 419 | + unset( $m_key, $meta_val ); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -426,15 +426,15 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - return stripslashes_deep($entries); |
|
| 429 | + return stripslashes_deep( $entries ); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // Pagination Methods |
| 433 | 433 | public static function getRecordCount( $where = '' ) { |
| 434 | 434 | global $wpdb; |
| 435 | - $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id'; |
|
| 435 | + $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
|
| 436 | 436 | |
| 437 | - if ( is_numeric($where) ) { |
|
| 437 | + if ( is_numeric( $where ) ) { |
|
| 438 | 438 | $table_join = 'frm_items'; |
| 439 | 439 | $where = array( 'form_id' => $where ); |
| 440 | 440 | } |
@@ -442,19 +442,19 @@ discard block |
||
| 442 | 442 | if ( is_array( $where ) ) { |
| 443 | 443 | $count = FrmDb::get_count( $table_join, $where ); |
| 444 | 444 | } else { |
| 445 | - $cache_key = 'count_'. maybe_serialize($where); |
|
| 446 | - $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
| 447 | - $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var'); |
|
| 445 | + $cache_key = 'count_' . maybe_serialize( $where ); |
|
| 446 | + $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
|
| 447 | + $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | return $count; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | public static function getPageCount( $p_size, $where = '' ) { |
| 454 | - if ( is_numeric($where) ) { |
|
| 454 | + if ( is_numeric( $where ) ) { |
|
| 455 | 455 | return ceil( (int) $where / (int) $p_size ); |
| 456 | 456 | } else { |
| 457 | - return ceil( (int) self::getRecordCount($where) / (int) $p_size ); |
|
| 457 | + return ceil( (int) self::getRecordCount( $where ) / (int) $p_size ); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | self::sanitize_entry_post( $values ); |
| 472 | 472 | |
| 473 | 473 | if ( $type != 'xml' ) { |
| 474 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
| 474 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | $new_values = self::package_entry_data( $values ); |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | $item_name = self::get_new_entry_name( $values, $values['item_key'] ); |
| 540 | 540 | $new_values = array( |
| 541 | - 'item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'), |
|
| 541 | + 'item_key' => FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key' ), |
|
| 542 | 542 | 'name' => FrmAppHelper::truncate( $item_name, 255, 1, '' ), |
| 543 | 543 | 'ip' => FrmAppHelper::get_ip_address(), |
| 544 | 544 | 'is_draft' => self::get_is_draft_value( $values ), |
@@ -551,11 +551,11 @@ discard block |
||
| 551 | 551 | 'user_id' => self::get_entry_user_id( $values ), |
| 552 | 552 | ); |
| 553 | 553 | |
| 554 | - if ( is_array($new_values['name']) ) { |
|
| 555 | - $new_values['name'] = reset($new_values['name']); |
|
| 554 | + if ( is_array( $new_values['name'] ) ) { |
|
| 555 | + $new_values['name'] = reset( $new_values['name'] ); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
| 558 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
| 559 | 559 | |
| 560 | 560 | return $new_values; |
| 561 | 561 | } |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return int |
| 569 | 569 | */ |
| 570 | 570 | private static function get_is_draft_value( $values ) { |
| 571 | - return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 571 | + return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @return int |
| 591 | 591 | */ |
| 592 | 592 | private static function get_post_id( $values ) { |
| 593 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
| 593 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | * @return int |
| 602 | 602 | */ |
| 603 | 603 | private static function get_parent_item_id( $values ) { |
| 604 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
| 604 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | * @return string |
| 613 | 613 | */ |
| 614 | 614 | private static function get_created_at( $values ) { |
| 615 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
| 615 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | private static function insert_entry_into_database( $new_values ) { |
| 681 | 681 | global $wpdb; |
| 682 | 682 | |
| 683 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values ); |
|
| 683 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
|
| 684 | 684 | |
| 685 | 685 | if ( ! $query_results ) { |
| 686 | 686 | $entry_id = false; |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 701 | 701 | global $frm_vars; |
| 702 | 702 | |
| 703 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 703 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 704 | 704 | $frm_vars['saved_entries'] = array(); |
| 705 | 705 | } |
| 706 | 706 | |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | * @param int $entry_id |
| 716 | 716 | */ |
| 717 | 717 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 718 | - if ( isset($values['item_meta']) ) { |
|
| 718 | + if ( isset( $values['item_meta'] ) ) { |
|
| 719 | 719 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
| 720 | 720 | } |
| 721 | 721 | } |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
| 733 | 733 | |
| 734 | 734 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
| 735 | - do_action( 'frm_after_create_entry_'. $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
| 735 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | if ( $update && $update_type != 'xml' ) { |
| 776 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
| 776 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | return $update; |
@@ -794,27 +794,27 @@ discard block |
||
| 794 | 794 | 'name' => self::get_new_entry_name( $values ), |
| 795 | 795 | 'form_id' => self::get_form_id( $values ), |
| 796 | 796 | 'is_draft' => self::get_is_draft_value( $values ), |
| 797 | - 'updated_at' => current_time('mysql', 1), |
|
| 798 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
| 797 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
| 798 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
| 799 | 799 | ); |
| 800 | 800 | |
| 801 | - if ( isset($values['post_id']) ) { |
|
| 801 | + if ( isset( $values['post_id'] ) ) { |
|
| 802 | 802 | $new_values['post_id'] = (int) $values['post_id']; |
| 803 | 803 | } |
| 804 | 804 | |
| 805 | - if ( isset($values['item_key']) ) { |
|
| 806 | - $new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key', $id); |
|
| 805 | + if ( isset( $values['item_key'] ) ) { |
|
| 806 | + $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - if ( isset($values['parent_item_id']) ) { |
|
| 809 | + if ( isset( $values['parent_item_id'] ) ) { |
|
| 810 | 810 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
| 813 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
| 814 | 814 | $new_values['user_id'] = $values['frm_user_id']; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
| 817 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
| 818 | 818 | |
| 819 | 819 | return $new_values; |
| 820 | 820 | } |
@@ -844,8 +844,8 @@ discard block |
||
| 844 | 844 | FrmEntryMeta::update_entry_metas( $id, $values['item_meta'] ); |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - do_action('frm_after_update_entry', $id, $new_values['form_id'] ); |
|
| 848 | - do_action('frm_after_update_entry_'. $new_values['form_id'], $id ); |
|
| 847 | + do_action( 'frm_after_update_entry', $id, $new_values['form_id'] ); |
|
| 848 | + do_action( 'frm_after_update_entry_' . $new_values['form_id'], $id ); |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | /** |