@@ -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 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @return boolean |
| 43 | 43 | */ |
| 44 | 44 | public static function is_duplicate( $new_values, $values ) { |
| 45 | - if ( defined('WP_IMPORTING') && WP_IMPORTING ) { |
|
| 45 | + if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 59 | 59 | |
| 60 | 60 | if ( $new_values['item_key'] == $new_values['name'] ) { |
| 61 | - unset($check_val['name']); |
|
| 61 | + unset( $check_val['name'] ); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | global $wpdb; |
| 65 | 65 | $entry_exists = FrmDb::get_col( $wpdb->prefix . 'frm_items', $check_val, 'id', array( 'order_by' => 'created_at DESC' ) ); |
| 66 | 66 | |
| 67 | - if ( ! $entry_exists || empty($entry_exists) || ! isset($values['item_meta']) ) { |
|
| 67 | + if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | $is_duplicate = true; |
| 74 | 74 | |
| 75 | 75 | //add more checks here to make sure it's a duplicate |
| 76 | - $metas = FrmEntryMeta::get_entry_meta_info($entry_exist); |
|
| 76 | + $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
|
| 77 | 77 | $field_metas = array(); |
| 78 | 78 | foreach ( $metas as $meta ) { |
| 79 | - $field_metas[ $meta->field_id ] = $meta->meta_value; |
|
| 79 | + $field_metas[$meta->field_id] = $meta->meta_value; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // If prev entry is empty and current entry is not, they are not duplicates |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | return false; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $diff = array_diff_assoc($field_metas, array_map('maybe_serialize', $values['item_meta'])); |
|
| 88 | + $diff = array_diff_assoc( $field_metas, array_map( 'maybe_serialize', $values['item_meta'] ) ); |
|
| 89 | 89 | foreach ( $diff as $field_id => $meta_value ) { |
| 90 | - if ( ! empty($meta_value) ) { |
|
| 90 | + if ( ! empty( $meta_value ) ) { |
|
| 91 | 91 | $is_duplicate = false; |
| 92 | 92 | continue; |
| 93 | 93 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | $values = self::getOne( $id ); |
| 108 | 108 | |
| 109 | 109 | $new_values = array(); |
| 110 | - $new_values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix .'frm_items', 'item_key'); |
|
| 110 | + $new_values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
|
| 111 | 111 | $new_values['name'] = $values->name; |
| 112 | 112 | $new_values['is_draft'] = $values->is_draft; |
| 113 | 113 | $new_values['user_id'] = $new_values['updated_by'] = (int) $values->user_id; |
| 114 | - $new_values['form_id'] = $values->form_id ? (int) $values->form_id: null; |
|
| 115 | - $new_values['created_at'] = $new_values['updated_at'] = current_time('mysql', 1); |
|
| 114 | + $new_values['form_id'] = $values->form_id ? (int) $values->form_id : null; |
|
| 115 | + $new_values['created_at'] = $new_values['updated_at'] = current_time( 'mysql', 1 ); |
|
| 116 | 116 | |
| 117 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values ); |
|
| 117 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
|
| 118 | 118 | if ( ! $query_results ) { |
| 119 | 119 | return false; |
| 120 | 120 | } |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | $entry_id = $wpdb->insert_id; |
| 123 | 123 | |
| 124 | 124 | global $frm_vars; |
| 125 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 125 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 126 | 126 | $frm_vars['saved_entries'] = array(); |
| 127 | 127 | } |
| 128 | 128 | $frm_vars['saved_entries'][] = (int) $entry_id; |
| 129 | 129 | |
| 130 | - FrmEntryMeta::duplicate_entry_metas($id, $entry_id); |
|
| 130 | + FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
|
| 131 | 131 | self::clear_cache(); |
| 132 | 132 | |
| 133 | 133 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | $new_values = self::package_entry_to_update( $id, $values ); |
| 168 | 168 | |
| 169 | - $query_results = $wpdb->update( $wpdb->prefix .'frm_items', $new_values, compact('id') ); |
|
| 169 | + $query_results = $wpdb->update( $wpdb->prefix . 'frm_items', $new_values, compact( 'id' ) ); |
|
| 170 | 170 | |
| 171 | 171 | self::after_update_entry( $query_results, $id, $values, $new_values ); |
| 172 | 172 | |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | return $result; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - do_action('frm_before_destroy_entry', $id, $entry); |
|
| 186 | + do_action( 'frm_before_destroy_entry', $id, $entry ); |
|
| 187 | 187 | |
| 188 | - $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_item_metas WHERE item_id=%d', $id) ); |
|
| 189 | - $result = $wpdb->query( $wpdb->prepare('DELETE FROM ' . $wpdb->prefix .'frm_items WHERE id=%d', $id) ); |
|
| 188 | + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_item_metas WHERE item_id=%d', $id ) ); |
|
| 189 | + $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_items WHERE id=%d', $id ) ); |
|
| 190 | 190 | |
| 191 | 191 | self::clear_cache(); |
| 192 | 192 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public static function &update_form( $id, $value, $form_id ) { |
| 197 | 197 | global $wpdb; |
| 198 | - $form_id = isset($value) ? $form_id : null; |
|
| 198 | + $form_id = isset( $value ) ? $form_id : null; |
|
| 199 | 199 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 200 | 200 | if ( $result ) { |
| 201 | 201 | self::clear_cache(); |
@@ -242,24 +242,24 @@ discard block |
||
| 242 | 242 | $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
| 243 | 243 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 244 | 244 | |
| 245 | - $query .= is_numeric($id) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 245 | + $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
|
| 246 | 246 | $query_args = array( $id ); |
| 247 | 247 | $query = $wpdb->prepare( $query, $query_args ); |
| 248 | 248 | |
| 249 | 249 | if ( ! $meta ) { |
| 250 | - $entry = FrmAppHelper::check_cache( $id .'_nometa', 'frm_entry', $query, 'get_row' ); |
|
| 251 | - return stripslashes_deep($entry); |
|
| 250 | + $entry = FrmAppHelper::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
|
| 251 | + return stripslashes_deep( $entry ); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $entry = FrmAppHelper::check_cache( $id, 'frm_entry' ); |
| 255 | 255 | if ( $entry !== false ) { |
| 256 | - return stripslashes_deep($entry); |
|
| 256 | + return stripslashes_deep( $entry ); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | $entry = $wpdb->get_row( $query ); |
| 260 | - $entry = self::get_meta($entry); |
|
| 260 | + $entry = self::get_meta( $entry ); |
|
| 261 | 261 | |
| 262 | - return stripslashes_deep($entry); |
|
| 262 | + return stripslashes_deep( $entry ); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | public static function get_meta( $entry ) { |
@@ -275,25 +275,25 @@ discard block |
||
| 275 | 275 | $include_key = apply_filters( 'frm_include_meta_keys', false ); |
| 276 | 276 | foreach ( $metas as $meta_val ) { |
| 277 | 277 | if ( $meta_val->item_id == $entry->id ) { |
| 278 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 278 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 279 | 279 | if ( $include_key ) { |
| 280 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
| 280 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
| 281 | 281 | } |
| 282 | 282 | continue; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // include sub entries in an array |
| 286 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
| 287 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
| 286 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
| 287 | + $entry->metas[$meta_val->field_id] = array(); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 290 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 291 | 291 | |
| 292 | - unset($meta_val); |
|
| 292 | + unset( $meta_val ); |
|
| 293 | 293 | } |
| 294 | - unset($metas); |
|
| 294 | + unset( $metas ); |
|
| 295 | 295 | |
| 296 | - wp_cache_set( $entry->id, $entry, 'frm_entry'); |
|
| 296 | + wp_cache_set( $entry->id, $entry, 'frm_entry' ); |
|
| 297 | 297 | |
| 298 | 298 | return $entry; |
| 299 | 299 | } |
@@ -309,28 +309,28 @@ discard block |
||
| 309 | 309 | return $exists; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( is_numeric($id) ) { |
|
| 312 | + if ( is_numeric( $id ) ) { |
|
| 313 | 313 | $where = array( 'id' => $id ); |
| 314 | 314 | } else { |
| 315 | 315 | $where = array( 'item_key' => $id ); |
| 316 | 316 | } |
| 317 | - $id = FrmDb::get_var( $wpdb->prefix .'frm_items', $where ); |
|
| 317 | + $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
|
| 318 | 318 | |
| 319 | - $exists = ($id && $id > 0) ? true : false; |
|
| 319 | + $exists = ( $id && $id > 0 ) ? true : false; |
|
| 320 | 320 | return $exists; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
| 324 | 324 | global $wpdb; |
| 325 | 325 | |
| 326 | - $limit = FrmAppHelper::esc_limit($limit); |
|
| 326 | + $limit = FrmAppHelper::esc_limit( $limit ); |
|
| 327 | 327 | |
| 328 | - $cache_key = maybe_serialize($where) . $order_by . $limit . $inc_form; |
|
| 329 | - $entries = wp_cache_get($cache_key, 'frm_entry'); |
|
| 328 | + $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
|
| 329 | + $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
|
| 330 | 330 | |
| 331 | 331 | if ( false === $entries ) { |
| 332 | 332 | $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'; |
| 333 | - $table = $wpdb->prefix .'frm_items it '; |
|
| 333 | + $table = $wpdb->prefix . 'frm_items it '; |
|
| 334 | 334 | |
| 335 | 335 | if ( $inc_form ) { |
| 336 | 336 | $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
| 341 | 341 | // sort by a requested field |
| 342 | 342 | $field_id = (int) $order_matches[1]; |
| 343 | - $fields .= ', (SELECT meta_value FROM '. $wpdb->prefix .'frm_item_metas WHERE field_id = '. $field_id .' AND item_id = it.id) as meta_'. $field_id; |
|
| 343 | + $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
|
| 344 | 344 | unset( $order_matches, $field_id ); |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // prepare the query |
| 348 | - $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where(' WHERE ', $where) . $order_by . $limit; |
|
| 348 | + $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
|
| 349 | 349 | |
| 350 | - $entries = $wpdb->get_results($query, OBJECT_K); |
|
| 351 | - unset($query); |
|
| 350 | + $entries = $wpdb->get_results( $query, OBJECT_K ); |
|
| 351 | + unset( $query ); |
|
| 352 | 352 | |
| 353 | 353 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 354 | 354 | wp_cache_set( $cache_key, $entries, 'frm_entry', 300 ); |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | if ( ! $meta || ! $entries ) { |
| 359 | - return stripslashes_deep($entries); |
|
| 359 | + return stripslashes_deep( $entries ); |
|
| 360 | 360 | } |
| 361 | - unset($meta); |
|
| 361 | + unset( $meta ); |
|
| 362 | 362 | |
| 363 | - if ( ! is_array( $where ) && preg_match('/^it\.form_id=\d+$/', $where) ) { |
|
| 363 | + if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
|
| 364 | 364 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | $meta_where = array( 'field_id !' => 0 ); |
| 368 | - if ( $limit == '' && is_array($where) && count($where) == 1 && isset($where['it.form_id']) ) { |
|
| 368 | + if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
|
| 369 | 369 | $meta_where['fi.form_id'] = $where['it.form_id']; |
| 370 | 370 | } else { |
| 371 | 371 | $meta_where['item_id'] = array_keys( $entries ); |
@@ -376,21 +376,21 @@ discard block |
||
| 376 | 376 | unset( $meta_where ); |
| 377 | 377 | |
| 378 | 378 | if ( ! $metas ) { |
| 379 | - return stripslashes_deep($entries); |
|
| 379 | + return stripslashes_deep( $entries ); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | foreach ( $metas as $m_key => $meta_val ) { |
| 383 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 383 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 384 | 384 | continue; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 388 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 387 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 388 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 391 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 392 | 392 | |
| 393 | - unset($m_key, $meta_val); |
|
| 393 | + unset( $m_key, $meta_val ); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | if ( ! FrmAppHelper::prevent_caching() ) { |
@@ -400,15 +400,15 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - return stripslashes_deep($entries); |
|
| 403 | + return stripslashes_deep( $entries ); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // Pagination Methods |
| 407 | 407 | public static function getRecordCount( $where = '' ) { |
| 408 | 408 | global $wpdb; |
| 409 | - $table_join = $wpdb->prefix .'frm_items it LEFT OUTER JOIN '. $wpdb->prefix .'frm_forms fr ON it.form_id=fr.id'; |
|
| 409 | + $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
|
| 410 | 410 | |
| 411 | - if ( is_numeric($where) ) { |
|
| 411 | + if ( is_numeric( $where ) ) { |
|
| 412 | 412 | $table_join = 'frm_items'; |
| 413 | 413 | $where = array( 'form_id' => $where ); |
| 414 | 414 | } |
@@ -417,19 +417,19 @@ discard block |
||
| 417 | 417 | $count = FrmDb::get_count( $table_join, $where ); |
| 418 | 418 | } else { |
| 419 | 419 | global $wpdb; |
| 420 | - $cache_key = 'count_'. maybe_serialize($where); |
|
| 421 | - $query = 'SELECT COUNT(*) FROM '. $table_join . FrmAppHelper::prepend_and_or_where(' WHERE ', $where); |
|
| 422 | - $count = FrmAppHelper::check_cache($cache_key, 'frm_entry', $query, 'get_var'); |
|
| 420 | + $cache_key = 'count_' . maybe_serialize( $where ); |
|
| 421 | + $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmAppHelper::prepend_and_or_where( ' WHERE ', $where ); |
|
| 422 | + $count = FrmAppHelper::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | return $count; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | public static function getPageCount( $p_size, $where = '' ) { |
| 429 | - if ( is_numeric($where) ) { |
|
| 429 | + if ( is_numeric( $where ) ) { |
|
| 430 | 430 | return ceil( (int) $where / (int) $p_size ); |
| 431 | 431 | } else { |
| 432 | - return ceil( (int) self::getRecordCount($where) / (int) $p_size ); |
|
| 432 | + return ceil( (int) self::getRecordCount( $where ) / (int) $p_size ); |
|
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | self::sanitize_entry_post( $values ); |
| 447 | 447 | |
| 448 | 448 | if ( $type != 'xml' ) { |
| 449 | - $values = apply_filters('frm_pre_create_entry', $values); |
|
| 449 | + $values = apply_filters( 'frm_pre_create_entry', $values ); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | $new_values = self::package_entry_data( $values ); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | $item_name = self::get_new_entry_name( $values, $values['item_key'] ); |
| 515 | 515 | $new_values = array( |
| 516 | - 'item_key' => FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key'), |
|
| 516 | + 'item_key' => FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key' ), |
|
| 517 | 517 | 'name' => FrmAppHelper::truncate( $item_name, 255, 1, '' ), |
| 518 | 518 | 'ip' => FrmAppHelper::get_ip_address(), |
| 519 | 519 | 'is_draft' => self::get_is_draft_value( $values ), |
@@ -526,11 +526,11 @@ discard block |
||
| 526 | 526 | 'user_id' => self::get_entry_user_id( $values ), |
| 527 | 527 | ); |
| 528 | 528 | |
| 529 | - if ( is_array($new_values['name']) ) { |
|
| 530 | - $new_values['name'] = reset($new_values['name']); |
|
| 529 | + if ( is_array( $new_values['name'] ) ) { |
|
| 530 | + $new_values['name'] = reset( $new_values['name'] ); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $new_values['updated_by'] = isset($values['updated_by']) ? $values['updated_by'] : $new_values['user_id']; |
|
| 533 | + $new_values['updated_by'] = isset( $values['updated_by'] ) ? $values['updated_by'] : $new_values['user_id']; |
|
| 534 | 534 | |
| 535 | 535 | return $new_values; |
| 536 | 536 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * @return int |
| 544 | 544 | */ |
| 545 | 545 | private static function get_is_draft_value( $values ) { |
| 546 | - return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 546 | + return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * @return int |
| 566 | 566 | */ |
| 567 | 567 | private static function get_post_id( $values ) { |
| 568 | - return isset( $values['post_id'] ) ? (int) $values['post_id']: 0; |
|
| 568 | + return isset( $values['post_id'] ) ? (int) $values['post_id'] : 0; |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @return int |
| 577 | 577 | */ |
| 578 | 578 | private static function get_parent_item_id( $values ) { |
| 579 | - return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id']: 0; |
|
| 579 | + return isset( $values['parent_item_id'] ) ? (int) $values['parent_item_id'] : 0; |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | * @return string |
| 588 | 588 | */ |
| 589 | 589 | private static function get_created_at( $values ) { |
| 590 | - return isset( $values['created_at'] ) ? $values['created_at']: current_time('mysql', 1); |
|
| 590 | + return isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | private static function insert_entry_into_database( $new_values ) { |
| 656 | 656 | global $wpdb; |
| 657 | 657 | |
| 658 | - $query_results = $wpdb->insert( $wpdb->prefix .'frm_items', $new_values ); |
|
| 658 | + $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
|
| 659 | 659 | |
| 660 | 660 | if ( ! $query_results ) { |
| 661 | 661 | $entry_id = false; |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 676 | 676 | global $frm_vars; |
| 677 | 677 | |
| 678 | - if ( ! isset($frm_vars['saved_entries']) ) { |
|
| 678 | + if ( ! isset( $frm_vars['saved_entries'] ) ) { |
|
| 679 | 679 | $frm_vars['saved_entries'] = array(); |
| 680 | 680 | } |
| 681 | 681 | |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * @param int $entry_id |
| 691 | 691 | */ |
| 692 | 692 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 693 | - if ( isset($values['item_meta']) ) { |
|
| 693 | + if ( isset( $values['item_meta'] ) ) { |
|
| 694 | 694 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
| 695 | 695 | } |
| 696 | 696 | } |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
| 708 | 708 | |
| 709 | 709 | do_action( 'frm_after_create_entry', $entry_id, $new_values['form_id'], compact( 'is_child' ) ); |
| 710 | - do_action( 'frm_after_create_entry_'. $new_values['form_id'], $entry_id , compact( 'is_child' ) ); |
|
| 710 | + do_action( 'frm_after_create_entry_' . $new_values['form_id'], $entry_id, compact( 'is_child' ) ); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | if ( $update && $update_type != 'xml' ) { |
| 751 | - $values = apply_filters('frm_pre_update_entry', $values, $id); |
|
| 751 | + $values = apply_filters( 'frm_pre_update_entry', $values, $id ); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | return $update; |
@@ -769,27 +769,27 @@ discard block |
||
| 769 | 769 | 'name' => self::get_new_entry_name( $values ), |
| 770 | 770 | 'form_id' => self::get_form_id( $values ), |
| 771 | 771 | 'is_draft' => self::get_is_draft_value( $values ), |
| 772 | - 'updated_at' => current_time('mysql', 1), |
|
| 773 | - 'updated_by' => isset($values['updated_by']) ? $values['updated_by'] : get_current_user_id(), |
|
| 772 | + 'updated_at' => current_time( 'mysql', 1 ), |
|
| 773 | + 'updated_by' => isset( $values['updated_by'] ) ? $values['updated_by'] : get_current_user_id(), |
|
| 774 | 774 | ); |
| 775 | 775 | |
| 776 | - if ( isset($values['post_id']) ) { |
|
| 776 | + if ( isset( $values['post_id'] ) ) { |
|
| 777 | 777 | $new_values['post_id'] = (int) $values['post_id']; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - if ( isset($values['item_key']) ) { |
|
| 781 | - $new_values['item_key'] = FrmAppHelper::get_unique_key($values['item_key'], $wpdb->prefix .'frm_items', 'item_key', $id); |
|
| 780 | + if ( isset( $values['item_key'] ) ) { |
|
| 781 | + $new_values['item_key'] = FrmAppHelper::get_unique_key( $values['item_key'], $wpdb->prefix . 'frm_items', 'item_key', $id ); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - if ( isset($values['parent_item_id']) ) { |
|
| 784 | + if ( isset( $values['parent_item_id'] ) ) { |
|
| 785 | 785 | $new_values['parent_item_id'] = (int) $values['parent_item_id']; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - if ( isset($values['frm_user_id']) && is_numeric($values['frm_user_id']) ) { |
|
| 788 | + if ( isset( $values['frm_user_id'] ) && is_numeric( $values['frm_user_id'] ) ) { |
|
| 789 | 789 | $new_values['user_id'] = $values['frm_user_id']; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - $new_values = apply_filters('frm_update_entry', $new_values, $id); |
|
| 792 | + $new_values = apply_filters( 'frm_update_entry', $new_values, $id ); |
|
| 793 | 793 | |
| 794 | 794 | return $new_values; |
| 795 | 795 | } |
@@ -819,8 +819,8 @@ discard block |
||
| 819 | 819 | FrmEntryMeta::update_entry_metas( $id, $values['item_meta'] ); |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - do_action('frm_after_update_entry', $id, $new_values['form_id'] ); |
|
| 823 | - do_action('frm_after_update_entry_'. $new_values['form_id'], $id ); |
|
| 822 | + do_action( 'frm_after_update_entry', $id, $new_values['form_id'] ); |
|
| 823 | + do_action( 'frm_after_update_entry_' . $new_values['form_id'], $id ); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | /** |