@@ -6,11 +6,11 @@ discard block |
||
| 6 | 6 | class FrmEntry { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * Create a new entry |
|
| 10 | - * |
|
| 11 | - * @param array $values |
|
| 12 | - * @return int | boolean $entry_id |
|
| 13 | - */ |
|
| 9 | + * Create a new entry |
|
| 10 | + * |
|
| 11 | + * @param array $values |
|
| 12 | + * @return int | boolean $entry_id |
|
| 13 | + */ |
|
| 14 | 14 | public static function create( $values ) { |
| 15 | 15 | $entry_id = self::create_entry( $values, 'standard' ); |
| 16 | 16 | |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * Create a new entry with some differences depending on type |
|
| 22 | - * |
|
| 23 | - * @param array $values |
|
| 24 | - * @param string $type |
|
| 25 | - * @return int | boolean $entry_id |
|
| 26 | - */ |
|
| 21 | + * Create a new entry with some differences depending on type |
|
| 22 | + * |
|
| 23 | + * @param array $values |
|
| 24 | + * @param string $type |
|
| 25 | + * @return int | boolean $entry_id |
|
| 26 | + */ |
|
| 27 | 27 | private static function create_entry( $values, $type ) { |
| 28 | 28 | $new_values = self::before_insert_entry_in_database( $values, $type ); |
| 29 | 29 | |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | return $entry_id; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * check for duplicate entries created in the last minute |
|
| 42 | - * @return boolean |
|
| 43 | - */ |
|
| 40 | + /** |
|
| 41 | + * check for duplicate entries created in the last minute |
|
| 42 | + * @return boolean |
|
| 43 | + */ |
|
| 44 | 44 | public static function is_duplicate( $new_values, $values ) { |
| 45 | 45 | $duplicate_entry_time = apply_filters( 'frm_time_to_check_duplicates', 60, $new_values ); |
| 46 | 46 | |
@@ -48,40 +48,40 @@ discard block |
||
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - $check_val = $new_values; |
|
| 51 | + $check_val = $new_values; |
|
| 52 | 52 | $check_val['created_at >'] = date( 'Y-m-d H:i:s', ( strtotime( $new_values['created_at'] ) - absint( $duplicate_entry_time ) ) ); |
| 53 | 53 | |
| 54 | 54 | unset( $check_val['created_at'], $check_val['updated_at'] ); |
| 55 | 55 | unset( $check_val['is_draft'], $check_val['id'], $check_val['item_key'] ); |
| 56 | 56 | |
| 57 | - if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 57 | + if ( $new_values['item_key'] == $new_values['name'] ) { |
|
| 58 | 58 | unset( $check_val['name'] ); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - global $wpdb; |
|
| 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 | 64 | if ( ! $entry_exists || empty( $entry_exists ) || ! isset( $values['item_meta'] ) ) { |
| 65 | - return false; |
|
| 66 | - } |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $is_duplicate = false; |
|
| 69 | - foreach ( $entry_exists as $entry_exist ) { |
|
| 70 | - $is_duplicate = true; |
|
| 68 | + $is_duplicate = false; |
|
| 69 | + foreach ( $entry_exists as $entry_exist ) { |
|
| 70 | + $is_duplicate = true; |
|
| 71 | 71 | |
| 72 | 72 | // make sure it's a duplicate |
| 73 | 73 | $metas = FrmEntryMeta::get_entry_meta_info( $entry_exist ); |
| 74 | - $field_metas = array(); |
|
| 75 | - foreach ( $metas as $meta ) { |
|
| 74 | + $field_metas = array(); |
|
| 75 | + foreach ( $metas as $meta ) { |
|
| 76 | 76 | $field_metas[ $meta->field_id ] = $meta->meta_value; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - // If prev entry is empty and current entry is not, they are not duplicates |
|
| 80 | - $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 79 | + // If prev entry is empty and current entry is not, they are not duplicates |
|
| 80 | + $filtered_vals = array_filter( $values['item_meta'] ); |
|
| 81 | 81 | $field_metas = array_filter( $field_metas ); |
| 82 | - if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 83 | - return false; |
|
| 84 | - } |
|
| 82 | + if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
|
| 83 | + return false; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | // compare serialized values and not arrays |
| 87 | 87 | $new_meta = array_map( 'maybe_serialize', $filtered_vals ); |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $diff = array_diff_assoc( $field_metas, $new_meta ); |
| 101 | - foreach ( $diff as $field_id => $meta_value ) { |
|
| 101 | + foreach ( $diff as $field_id => $meta_value ) { |
|
| 102 | 102 | if ( ! empty( $meta_value ) ) { |
| 103 | - $is_duplicate = false; |
|
| 104 | - continue; |
|
| 105 | - } |
|
| 106 | - } |
|
| 103 | + $is_duplicate = false; |
|
| 104 | + continue; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - if ( $is_duplicate ) { |
|
| 108 | + if ( $is_duplicate ) { |
|
| 109 | 109 | break; |
| 110 | - } |
|
| 111 | - } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - return $is_duplicate; |
|
| 114 | - } |
|
| 113 | + return $is_duplicate; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * Determine if an entry needs to be checked as a possible duplicate |
@@ -156,32 +156,32 @@ discard block |
||
| 156 | 156 | $new_values['updated_at'] = $new_values['created_at']; |
| 157 | 157 | |
| 158 | 158 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_items', $new_values ); |
| 159 | - if ( ! $query_results ) { |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 159 | + if ( ! $query_results ) { |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - $entry_id = $wpdb->insert_id; |
|
| 163 | + $entry_id = $wpdb->insert_id; |
|
| 164 | 164 | |
| 165 | - global $frm_vars; |
|
| 165 | + global $frm_vars; |
|
| 166 | 166 | if ( ! isset( $frm_vars['saved_entries'] ) ) { |
| 167 | - $frm_vars['saved_entries'] = array(); |
|
| 168 | - } |
|
| 169 | - $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 167 | + $frm_vars['saved_entries'] = array(); |
|
| 168 | + } |
|
| 169 | + $frm_vars['saved_entries'][] = (int) $entry_id; |
|
| 170 | 170 | |
| 171 | 171 | FrmEntryMeta::duplicate_entry_metas( $id, $entry_id ); |
| 172 | 172 | self::clear_cache(); |
| 173 | 173 | |
| 174 | 174 | do_action( 'frm_after_duplicate_entry', $entry_id, $new_values['form_id'], array( 'old_id' => $id ) ); |
| 175 | - return $entry_id; |
|
| 176 | - } |
|
| 175 | + return $entry_id; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | - * Update an entry (not via XML) |
|
| 180 | - * |
|
| 181 | - * @param int $id |
|
| 182 | - * @param array $values |
|
| 183 | - * @return boolean|int $update_results |
|
| 184 | - */ |
|
| 179 | + * Update an entry (not via XML) |
|
| 180 | + * |
|
| 181 | + * @param int $id |
|
| 182 | + * @param array $values |
|
| 183 | + * @return boolean|int $update_results |
|
| 184 | + */ |
|
| 185 | 185 | public static function update( $id, $values ) { |
| 186 | 186 | $update_results = self::update_entry( $id, $values, 'standard' ); |
| 187 | 187 | |
@@ -189,14 +189,14 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | - * Update an entry with some differences depending on the update type |
|
| 193 | - * |
|
| 194 | - * @since 2.0.16 |
|
| 195 | - * |
|
| 196 | - * @param int $id |
|
| 197 | - * @param array $values |
|
| 198 | - * @return boolean|int $query_results |
|
| 199 | - */ |
|
| 192 | + * Update an entry with some differences depending on the update type |
|
| 193 | + * |
|
| 194 | + * @since 2.0.16 |
|
| 195 | + * |
|
| 196 | + * @param int $id |
|
| 197 | + * @param array $values |
|
| 198 | + * @return boolean|int $query_results |
|
| 199 | + */ |
|
| 200 | 200 | private static function update_entry( $id, $values, $update_type ) { |
| 201 | 201 | global $wpdb; |
| 202 | 202 | |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public static function destroy( $id ) { |
| 218 | - global $wpdb; |
|
| 219 | - $id = (int) $id; |
|
| 218 | + global $wpdb; |
|
| 219 | + $id = (int) $id; |
|
| 220 | 220 | |
| 221 | 221 | $entry = self::getOne( $id ); |
| 222 | - if ( ! $entry ) { |
|
| 223 | - $result = false; |
|
| 224 | - return $result; |
|
| 225 | - } |
|
| 222 | + if ( ! $entry ) { |
|
| 223 | + $result = false; |
|
| 224 | + return $result; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | do_action( 'frm_before_destroy_entry', $id, $entry ); |
| 228 | 228 | |
@@ -231,18 +231,18 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | self::clear_cache(); |
| 233 | 233 | |
| 234 | - return $result; |
|
| 235 | - } |
|
| 234 | + return $result; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | public static function update_form( $id, $value, $form_id ) { |
| 238 | - global $wpdb; |
|
| 238 | + global $wpdb; |
|
| 239 | 239 | $form_id = isset( $value ) ? $form_id : null; |
| 240 | 240 | $result = $wpdb->update( $wpdb->prefix . 'frm_items', array( 'form_id' => $form_id ), array( 'id' => $id ) ); |
| 241 | 241 | if ( $result ) { |
| 242 | 242 | self::clear_cache(); |
| 243 | 243 | } |
| 244 | - return $result; |
|
| 245 | - } |
|
| 244 | + return $result; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | 247 | /** |
| 248 | 248 | * Clear entry caching |
@@ -284,19 +284,19 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | public static function getOne( $id, $meta = false ) { |
| 287 | - global $wpdb; |
|
| 287 | + global $wpdb; |
|
| 288 | 288 | |
| 289 | - $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 289 | + $query = "SELECT it.*, fr.name as form_name, fr.form_key as form_key FROM {$wpdb->prefix}frm_items it |
|
| 290 | 290 | LEFT OUTER JOIN {$wpdb->prefix}frm_forms fr ON it.form_id=fr.id WHERE "; |
| 291 | 291 | |
| 292 | 292 | $query .= is_numeric( $id ) ? 'it.id=%d' : 'it.item_key=%s'; |
| 293 | - $query_args = array( $id ); |
|
| 294 | - $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok. |
|
| 293 | + $query_args = array( $id ); |
|
| 294 | + $query = $wpdb->prepare( $query, $query_args ); // WPCS: unprepared SQL ok. |
|
| 295 | 295 | |
| 296 | - if ( ! $meta ) { |
|
| 296 | + if ( ! $meta ) { |
|
| 297 | 297 | $entry = FrmDb::check_cache( $id . '_nometa', 'frm_entry', $query, 'get_row' ); |
| 298 | 298 | return stripslashes_deep( $entry ); |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | 301 | $entry = FrmDb::check_cache( $id, 'frm_entry' ); |
| 302 | 302 | if ( $entry !== false ) { |
@@ -307,14 +307,14 @@ discard block |
||
| 307 | 307 | $entry = self::get_meta( $entry ); |
| 308 | 308 | |
| 309 | 309 | return stripslashes_deep( $entry ); |
| 310 | - } |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | 312 | public static function get_meta( $entry ) { |
| 313 | - if ( ! $entry ) { |
|
| 314 | - return $entry; |
|
| 315 | - } |
|
| 313 | + if ( ! $entry ) { |
|
| 314 | + return $entry; |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - global $wpdb; |
|
| 317 | + global $wpdb; |
|
| 318 | 318 | $metas = FrmDb::get_results( |
| 319 | 319 | $wpdb->prefix . 'frm_item_metas m LEFT JOIN ' . $wpdb->prefix . 'frm_fields f ON m.field_id=f.id', |
| 320 | 320 | array( |
@@ -324,56 +324,56 @@ discard block |
||
| 324 | 324 | 'field_id, meta_value, field_key, item_id' |
| 325 | 325 | ); |
| 326 | 326 | |
| 327 | - $entry->metas = array(); |
|
| 327 | + $entry->metas = array(); |
|
| 328 | 328 | |
| 329 | 329 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
| 330 | - foreach ( $metas as $meta_val ) { |
|
| 331 | - if ( $meta_val->item_id == $entry->id ) { |
|
| 330 | + foreach ( $metas as $meta_val ) { |
|
| 331 | + if ( $meta_val->item_id == $entry->id ) { |
|
| 332 | 332 | $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 333 | 333 | if ( $include_key ) { |
| 334 | 334 | $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
| 335 | 335 | } |
| 336 | - continue; |
|
| 337 | - } |
|
| 336 | + continue; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - // include sub entries in an array |
|
| 339 | + // include sub entries in an array |
|
| 340 | 340 | if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
| 341 | 341 | $entry->metas[ $meta_val->field_id ] = array(); |
| 342 | - } |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | 344 | $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
| 345 | 345 | |
| 346 | 346 | unset( $meta_val ); |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | unset( $metas ); |
| 349 | 349 | |
| 350 | 350 | FrmDb::set_cache( $entry->id, $entry, 'frm_entry' ); |
| 351 | 351 | |
| 352 | - return $entry; |
|
| 353 | - } |
|
| 352 | + return $entry; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - /** |
|
| 356 | - * @param string $id |
|
| 357 | - */ |
|
| 355 | + /** |
|
| 356 | + * @param string $id |
|
| 357 | + */ |
|
| 358 | 358 | public static function exists( $id ) { |
| 359 | - global $wpdb; |
|
| 359 | + global $wpdb; |
|
| 360 | 360 | |
| 361 | - if ( FrmDb::check_cache( $id, 'frm_entry' ) ) { |
|
| 362 | - $exists = true; |
|
| 363 | - return $exists; |
|
| 364 | - } |
|
| 361 | + if ( FrmDb::check_cache( $id, 'frm_entry' ) ) { |
|
| 362 | + $exists = true; |
|
| 363 | + return $exists; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | if ( is_numeric( $id ) ) { |
| 367 | - $where = array( 'id' => $id ); |
|
| 368 | - } else { |
|
| 369 | - $where = array( 'item_key' => $id ); |
|
| 370 | - } |
|
| 367 | + $where = array( 'id' => $id ); |
|
| 368 | + } else { |
|
| 369 | + $where = array( 'item_key' => $id ); |
|
| 370 | + } |
|
| 371 | 371 | $id = FrmDb::get_var( $wpdb->prefix . 'frm_items', $where ); |
| 372 | 372 | |
| 373 | 373 | return ( $id && $id > 0 ); |
| 374 | - } |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 376 | + public static function getAll( $where, $order_by = '', $limit = '', $meta = false, $inc_form = true ) { |
|
| 377 | 377 | global $wpdb; |
| 378 | 378 | |
| 379 | 379 | $limit = FrmDb::esc_limit( $limit ); |
@@ -381,21 +381,21 @@ discard block |
||
| 381 | 381 | $cache_key = maybe_serialize( $where ) . $order_by . $limit . $inc_form; |
| 382 | 382 | $entries = wp_cache_get( $cache_key, 'frm_entry' ); |
| 383 | 383 | |
| 384 | - if ( false === $entries ) { |
|
| 385 | - $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'; |
|
| 384 | + if ( false === $entries ) { |
|
| 385 | + $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'; |
|
| 386 | 386 | $table = $wpdb->prefix . 'frm_items it '; |
| 387 | 387 | |
| 388 | - if ( $inc_form ) { |
|
| 389 | - $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 390 | - $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 391 | - } |
|
| 388 | + if ( $inc_form ) { |
|
| 389 | + $fields = 'it.*, fr.name as form_name,fr.form_key as form_key'; |
|
| 390 | + $table .= 'LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id '; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 394 | - // sort by a requested field |
|
| 395 | - $field_id = (int) $order_matches[1]; |
|
| 393 | + if ( preg_match( '/ meta_([0-9]+)/', $order_by, $order_matches ) ) { |
|
| 394 | + // sort by a requested field |
|
| 395 | + $field_id = (int) $order_matches[1]; |
|
| 396 | 396 | $fields .= ', (SELECT meta_value FROM ' . $wpdb->prefix . 'frm_item_metas WHERE field_id = ' . $field_id . ' AND item_id = it.id) as meta_' . $field_id; |
| 397 | 397 | unset( $order_matches, $field_id ); |
| 398 | - } |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | // prepare the query |
| 401 | 401 | $query = 'SELECT ' . $fields . ' FROM ' . $table . FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit; |
@@ -404,45 +404,45 @@ discard block |
||
| 404 | 404 | unset( $query ); |
| 405 | 405 | |
| 406 | 406 | FrmDb::set_cache( $cache_key, $entries, 'frm_entry' ); |
| 407 | - } |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - if ( ! $meta || ! $entries ) { |
|
| 409 | + if ( ! $meta || ! $entries ) { |
|
| 410 | 410 | return stripslashes_deep( $entries ); |
| 411 | - } |
|
| 411 | + } |
|
| 412 | 412 | unset( $meta ); |
| 413 | 413 | |
| 414 | 414 | if ( ! is_array( $where ) && preg_match( '/^it\.form_id=\d+$/', $where ) ) { |
| 415 | 415 | $where = array( 'it.form_id' => substr( $where, 11 ) ); |
| 416 | - } |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - $meta_where = array( 'field_id !' => 0 ); |
|
| 418 | + $meta_where = array( 'field_id !' => 0 ); |
|
| 419 | 419 | if ( $limit == '' && is_array( $where ) && count( $where ) == 1 && isset( $where['it.form_id'] ) ) { |
| 420 | - $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 421 | - } else { |
|
| 422 | - $meta_where['item_id'] = array_keys( $entries ); |
|
| 423 | - } |
|
| 420 | + $meta_where['fi.form_id'] = $where['it.form_id']; |
|
| 421 | + } else { |
|
| 422 | + $meta_where['item_id'] = array_keys( $entries ); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 425 | + $metas = FrmDb::get_results( $wpdb->prefix . 'frm_item_metas it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_fields fi ON (it.field_id = fi.id)', $meta_where, 'item_id, meta_value, field_id, field_key, form_id' ); |
|
| 426 | 426 | |
| 427 | - unset( $meta_where ); |
|
| 427 | + unset( $meta_where ); |
|
| 428 | 428 | |
| 429 | - if ( ! $metas ) { |
|
| 429 | + if ( ! $metas ) { |
|
| 430 | 430 | return stripslashes_deep( $entries ); |
| 431 | - } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - foreach ( $metas as $m_key => $meta_val ) { |
|
| 434 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 435 | - continue; |
|
| 436 | - } |
|
| 433 | + foreach ( $metas as $m_key => $meta_val ) { |
|
| 434 | + if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 435 | + continue; |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 438 | + if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 439 | 439 | $entries[ $meta_val->item_id ]->metas = array(); |
| 440 | - } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
| 443 | 443 | |
| 444 | 444 | unset( $m_key, $meta_val ); |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | |
| 447 | 447 | if ( ! FrmAppHelper::prevent_caching() ) { |
| 448 | 448 | foreach ( $entries as $entry ) { |
@@ -452,30 +452,30 @@ discard block |
||
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | return stripslashes_deep( $entries ); |
| 455 | - } |
|
| 455 | + } |
|
| 456 | 456 | |
| 457 | - // Pagination Methods |
|
| 458 | - public static function getRecordCount( $where = '' ) { |
|
| 459 | - global $wpdb; |
|
| 457 | + // Pagination Methods |
|
| 458 | + public static function getRecordCount( $where = '' ) { |
|
| 459 | + global $wpdb; |
|
| 460 | 460 | $table_join = $wpdb->prefix . 'frm_items it LEFT OUTER JOIN ' . $wpdb->prefix . 'frm_forms fr ON it.form_id=fr.id'; |
| 461 | 461 | |
| 462 | 462 | if ( is_numeric( $where ) ) { |
| 463 | - $table_join = 'frm_items'; |
|
| 464 | - $where = array( 'form_id' => $where ); |
|
| 465 | - } |
|
| 463 | + $table_join = 'frm_items'; |
|
| 464 | + $where = array( 'form_id' => $where ); |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - if ( is_array( $where ) ) { |
|
| 468 | - $count = FrmDb::get_count( $table_join, $where ); |
|
| 469 | - } else { |
|
| 467 | + if ( is_array( $where ) ) { |
|
| 468 | + $count = FrmDb::get_count( $table_join, $where ); |
|
| 469 | + } else { |
|
| 470 | 470 | $cache_key = 'count_' . maybe_serialize( $where ); |
| 471 | 471 | $query = 'SELECT COUNT(*) FROM ' . $table_join . FrmDb::prepend_and_or_where( ' WHERE ', $where ); |
| 472 | 472 | $count = FrmDb::check_cache( $cache_key, 'frm_entry', $query, 'get_var' ); |
| 473 | - } |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - return $count; |
|
| 476 | - } |
|
| 475 | + return $count; |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - public static function getPageCount( $p_size, $where = '' ) { |
|
| 478 | + public static function getPageCount( $p_size, $where = '' ) { |
|
| 479 | 479 | $p_size = (int) $p_size; |
| 480 | 480 | $count = 1; |
| 481 | 481 | if ( $p_size ) { |
@@ -486,16 +486,16 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | return $count; |
| 489 | - } |
|
| 489 | + } |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | - * Prepare the data before inserting it into the database |
|
| 493 | - * |
|
| 494 | - * @since 2.0.16 |
|
| 495 | - * @param array $values |
|
| 496 | - * @param string $type |
|
| 497 | - * @return array $new_values |
|
| 498 | - */ |
|
| 492 | + * Prepare the data before inserting it into the database |
|
| 493 | + * |
|
| 494 | + * @since 2.0.16 |
|
| 495 | + * @param array $values |
|
| 496 | + * @param string $type |
|
| 497 | + * @return array $new_values |
|
| 498 | + */ |
|
| 499 | 499 | private static function before_insert_entry_in_database( &$values, $type ) { |
| 500 | 500 | |
| 501 | 501 | self::sanitize_entry_post( $values ); |
@@ -510,13 +510,13 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | /** |
| 513 | - * Create an entry and perform after create actions |
|
| 514 | - * |
|
| 515 | - * @since 2.0.16 |
|
| 516 | - * @param array $values |
|
| 517 | - * @param array $new_values |
|
| 518 | - * @return boolean|int $entry_id |
|
| 519 | - */ |
|
| 513 | + * Create an entry and perform after create actions |
|
| 514 | + * |
|
| 515 | + * @since 2.0.16 |
|
| 516 | + * @param array $values |
|
| 517 | + * @param array $new_values |
|
| 518 | + * @return boolean|int $entry_id |
|
| 519 | + */ |
|
| 520 | 520 | private static function continue_to_create_entry( $values, $new_values ) { |
| 521 | 521 | $entry_id = self::insert_entry_into_database( $new_values ); |
| 522 | 522 | if ( ! $entry_id ) { |
@@ -528,37 +528,37 @@ discard block |
||
| 528 | 528 | return $entry_id; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Sanitize the POST values before we use them |
|
| 533 | - * |
|
| 534 | - * @since 2.0 |
|
| 535 | - * @param array $values The POST values by reference |
|
| 536 | - */ |
|
| 537 | - public static function sanitize_entry_post( &$values ) { |
|
| 538 | - $sanitize_method = array( |
|
| 539 | - 'form_id' => 'absint', |
|
| 540 | - 'frm_action' => 'sanitize_title', |
|
| 541 | - 'form_key' => 'sanitize_title', |
|
| 542 | - 'item_key' => 'sanitize_title', |
|
| 543 | - 'item_name' => 'sanitize_text_field', |
|
| 544 | - 'frm_saving_draft' => 'absint', |
|
| 545 | - 'is_draft' => 'absint', |
|
| 546 | - 'post_id' => 'absint', |
|
| 547 | - 'parent_item_id' => 'absint', |
|
| 548 | - 'created_at' => 'sanitize_text_field', |
|
| 549 | - 'updated_at' => 'sanitize_text_field', |
|
| 550 | - ); |
|
| 551 | - |
|
| 552 | - FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 553 | - } |
|
| 531 | + /** |
|
| 532 | + * Sanitize the POST values before we use them |
|
| 533 | + * |
|
| 534 | + * @since 2.0 |
|
| 535 | + * @param array $values The POST values by reference |
|
| 536 | + */ |
|
| 537 | + public static function sanitize_entry_post( &$values ) { |
|
| 538 | + $sanitize_method = array( |
|
| 539 | + 'form_id' => 'absint', |
|
| 540 | + 'frm_action' => 'sanitize_title', |
|
| 541 | + 'form_key' => 'sanitize_title', |
|
| 542 | + 'item_key' => 'sanitize_title', |
|
| 543 | + 'item_name' => 'sanitize_text_field', |
|
| 544 | + 'frm_saving_draft' => 'absint', |
|
| 545 | + 'is_draft' => 'absint', |
|
| 546 | + 'post_id' => 'absint', |
|
| 547 | + 'parent_item_id' => 'absint', |
|
| 548 | + 'created_at' => 'sanitize_text_field', |
|
| 549 | + 'updated_at' => 'sanitize_text_field', |
|
| 550 | + ); |
|
| 551 | + |
|
| 552 | + FrmAppHelper::sanitize_request( $sanitize_method, $values ); |
|
| 553 | + } |
|
| 554 | 554 | |
| 555 | 555 | /** |
| 556 | - * Prepare the new values for inserting into the database |
|
| 557 | - * |
|
| 558 | - * @since 2.0.16 |
|
| 559 | - * @param array $values |
|
| 560 | - * @return array $new_values |
|
| 561 | - */ |
|
| 556 | + * Prepare the new values for inserting into the database |
|
| 557 | + * |
|
| 558 | + * @since 2.0.16 |
|
| 559 | + * @param array $values |
|
| 560 | + * @return array $new_values |
|
| 561 | + */ |
|
| 562 | 562 | private static function package_entry_data( &$values ) { |
| 563 | 563 | global $wpdb; |
| 564 | 564 | |
@@ -611,34 +611,34 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
| 614 | - * Get the is_draft value for a new entry |
|
| 615 | - * |
|
| 616 | - * @since 2.0.16 |
|
| 617 | - * @param array $values |
|
| 618 | - * @return int |
|
| 619 | - */ |
|
| 614 | + * Get the is_draft value for a new entry |
|
| 615 | + * |
|
| 616 | + * @since 2.0.16 |
|
| 617 | + * @param array $values |
|
| 618 | + * @return int |
|
| 619 | + */ |
|
| 620 | 620 | private static function get_is_draft_value( $values ) { |
| 621 | 621 | return ( ( isset( $values['frm_saving_draft'] ) && $values['frm_saving_draft'] == 1 ) || ( isset( $values['is_draft'] ) && $values['is_draft'] == 1 ) ) ? 1 : 0; |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | - * Get the created_at value for a new entry |
|
| 626 | - * |
|
| 627 | - * @since 2.0.16 |
|
| 628 | - * @param array $values |
|
| 629 | - * @return string |
|
| 630 | - */ |
|
| 625 | + * Get the created_at value for a new entry |
|
| 626 | + * |
|
| 627 | + * @since 2.0.16 |
|
| 628 | + * @param array $values |
|
| 629 | + * @return string |
|
| 630 | + */ |
|
| 631 | 631 | private static function get_created_at( $values ) { |
| 632 | 632 | return self::get_entry_value( $values, 'created_at', current_time( 'mysql', 1 ) ); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | /** |
| 636 | - * Get the updated_at value for a new entry |
|
| 637 | - * |
|
| 638 | - * @since 2.0.16 |
|
| 639 | - * @param array $values |
|
| 640 | - * @return string |
|
| 641 | - */ |
|
| 636 | + * Get the updated_at value for a new entry |
|
| 637 | + * |
|
| 638 | + * @since 2.0.16 |
|
| 639 | + * @param array $values |
|
| 640 | + * @return string |
|
| 641 | + */ |
|
| 642 | 642 | private static function get_updated_at( $values ) { |
| 643 | 643 | if ( isset( $values['updated_at'] ) ) { |
| 644 | 644 | $updated_at = $values['updated_at']; |
@@ -650,12 +650,12 @@ discard block |
||
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | /** |
| 653 | - * Get the description value for a new entry |
|
| 654 | - * |
|
| 655 | - * @since 2.0.16 |
|
| 656 | - * @param array $values |
|
| 657 | - * @return string |
|
| 658 | - */ |
|
| 653 | + * Get the description value for a new entry |
|
| 654 | + * |
|
| 655 | + * @since 2.0.16 |
|
| 656 | + * @param array $values |
|
| 657 | + * @return string |
|
| 658 | + */ |
|
| 659 | 659 | private static function get_entry_description( $values ) { |
| 660 | 660 | if ( isset( $values['description'] ) && ! empty( $values['description'] ) ) { |
| 661 | 661 | $description = maybe_serialize( $values['description'] ); |
@@ -672,12 +672,12 @@ discard block |
||
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | - * Get the user_id value for a new entry |
|
| 676 | - * |
|
| 677 | - * @since 2.0.16 |
|
| 678 | - * @param array $values |
|
| 679 | - * @return int |
|
| 680 | - */ |
|
| 675 | + * Get the user_id value for a new entry |
|
| 676 | + * |
|
| 677 | + * @since 2.0.16 |
|
| 678 | + * @param array $values |
|
| 679 | + * @return int |
|
| 680 | + */ |
|
| 681 | 681 | private static function get_entry_user_id( $values ) { |
| 682 | 682 | if ( isset( $values['frm_user_id'] ) && ( is_numeric( $values['frm_user_id'] ) || FrmAppHelper::is_admin() ) ) { |
| 683 | 683 | $user_id = $values['frm_user_id']; |
@@ -690,12 +690,12 @@ discard block |
||
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /** |
| 693 | - * Insert new entry into the database |
|
| 694 | - * |
|
| 695 | - * @since 2.0.16 |
|
| 696 | - * @param array $new_values |
|
| 697 | - * @return int | boolean $entry_id |
|
| 698 | - */ |
|
| 693 | + * Insert new entry into the database |
|
| 694 | + * |
|
| 695 | + * @since 2.0.16 |
|
| 696 | + * @param array $new_values |
|
| 697 | + * @return int | boolean $entry_id |
|
| 698 | + */ |
|
| 699 | 699 | private static function insert_entry_into_database( $new_values ) { |
| 700 | 700 | global $wpdb; |
| 701 | 701 | |
@@ -711,11 +711,11 @@ discard block |
||
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | /** |
| 714 | - * Add the new entry to global $frm_vars |
|
| 715 | - * |
|
| 716 | - * @since 2.0.16 |
|
| 717 | - * @param int $entry_id |
|
| 718 | - */ |
|
| 714 | + * Add the new entry to global $frm_vars |
|
| 715 | + * |
|
| 716 | + * @since 2.0.16 |
|
| 717 | + * @param int $entry_id |
|
| 718 | + */ |
|
| 719 | 719 | private static function add_new_entry_to_frm_vars( $entry_id ) { |
| 720 | 720 | global $frm_vars; |
| 721 | 721 | |
@@ -727,12 +727,12 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
| 730 | - * Add entry metas, if there are any |
|
| 731 | - * |
|
| 732 | - * @since 2.0.16 |
|
| 733 | - * @param array $values |
|
| 734 | - * @param int $entry_id |
|
| 735 | - */ |
|
| 730 | + * Add entry metas, if there are any |
|
| 731 | + * |
|
| 732 | + * @since 2.0.16 |
|
| 733 | + * @param array $values |
|
| 734 | + * @param int $entry_id |
|
| 735 | + */ |
|
| 736 | 736 | private static function maybe_add_entry_metas( $values, $entry_id ) { |
| 737 | 737 | if ( isset( $values['item_meta'] ) ) { |
| 738 | 738 | FrmEntryMeta::update_entry_metas( $entry_id, $values['item_meta'] ); |
@@ -740,12 +740,12 @@ discard block |
||
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | /** |
| 743 | - * Trigger frm_after_create_entry hooks |
|
| 744 | - * |
|
| 745 | - * @since 2.0.16 |
|
| 746 | - * @param int $entry_id |
|
| 747 | - * @param array $new_values |
|
| 748 | - */ |
|
| 743 | + * Trigger frm_after_create_entry hooks |
|
| 744 | + * |
|
| 745 | + * @since 2.0.16 |
|
| 746 | + * @param int $entry_id |
|
| 747 | + * @param array $new_values |
|
| 748 | + */ |
|
| 749 | 749 | private static function after_entry_created_actions( $entry_id, $values, $new_values ) { |
| 750 | 750 | // this is a child entry |
| 751 | 751 | $is_child = isset( $values['parent_form_id'] ) && isset( $values['parent_nonce'] ) && ! empty( $values['parent_form_id'] ) && wp_verify_nonce( $values['parent_nonce'], 'parent' ); |
@@ -755,13 +755,13 @@ discard block |
||
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | - * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 759 | - * |
|
| 760 | - * @since 2.0.16 |
|
| 761 | - * @param array $values |
|
| 762 | - * @param array $new_values |
|
| 763 | - * @param int $entry_id |
|
| 764 | - */ |
|
| 758 | + * Actions to perform immediately after an entry is inserted in the frm_items database |
|
| 759 | + * |
|
| 760 | + * @since 2.0.16 |
|
| 761 | + * @param array $values |
|
| 762 | + * @param array $new_values |
|
| 763 | + * @param int $entry_id |
|
| 764 | + */ |
|
| 765 | 765 | private static function after_insert_entry_in_database( $values, $new_values, $entry_id ) { |
| 766 | 766 | |
| 767 | 767 | self::add_new_entry_to_frm_vars( $entry_id ); |
@@ -774,14 +774,14 @@ discard block |
||
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | /** |
| 777 | - * Perform some actions right before updating an entry |
|
| 778 | - * |
|
| 779 | - * @since 2.0.16 |
|
| 780 | - * @param int $id |
|
| 781 | - * @param array $values |
|
| 782 | - * @param string $update_type |
|
| 783 | - * @return boolean $update |
|
| 784 | - */ |
|
| 777 | + * Perform some actions right before updating an entry |
|
| 778 | + * |
|
| 779 | + * @since 2.0.16 |
|
| 780 | + * @param int $id |
|
| 781 | + * @param array $values |
|
| 782 | + * @param string $update_type |
|
| 783 | + * @return boolean $update |
|
| 784 | + */ |
|
| 785 | 785 | private static function before_update_entry( $id, &$values, $update_type ) { |
| 786 | 786 | $update = true; |
| 787 | 787 | |
@@ -799,13 +799,13 @@ discard block |
||
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
| 802 | - * Package the entry data for updating |
|
| 803 | - * |
|
| 804 | - * @since 2.0.16 |
|
| 805 | - * @param int $id |
|
| 806 | - * @param array $values |
|
| 807 | - * @return array $new_values |
|
| 808 | - */ |
|
| 802 | + * Package the entry data for updating |
|
| 803 | + * |
|
| 804 | + * @since 2.0.16 |
|
| 805 | + * @param int $id |
|
| 806 | + * @param array $values |
|
| 807 | + * @return array $new_values |
|
| 808 | + */ |
|
| 809 | 809 | private static function package_entry_to_update( $id, $values ) { |
| 810 | 810 | global $wpdb; |
| 811 | 811 | |
@@ -839,14 +839,14 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
| 842 | - * Perform some actions right after updating an entry |
|
| 843 | - * |
|
| 844 | - * @since 2.0.16 |
|
| 845 | - * @param boolean|int $query_results |
|
| 846 | - * @param int $id |
|
| 847 | - * @param array $values |
|
| 848 | - * @param array $new_values |
|
| 849 | - */ |
|
| 842 | + * Perform some actions right after updating an entry |
|
| 843 | + * |
|
| 844 | + * @since 2.0.16 |
|
| 845 | + * @param boolean|int $query_results |
|
| 846 | + * @param int $id |
|
| 847 | + * @param array $values |
|
| 848 | + * @param array $new_values |
|
| 849 | + */ |
|
| 850 | 850 | private static function after_update_entry( $query_results, $id, $values, $new_values ) { |
| 851 | 851 | if ( $query_results ) { |
| 852 | 852 | self::clear_cache(); |
@@ -868,13 +868,13 @@ discard block |
||
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | - * Create entry from an XML import |
|
| 872 | - * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 873 | - * |
|
| 874 | - * @since 2.0.16 |
|
| 875 | - * @param array $values |
|
| 876 | - * @return int | boolean $entry_id |
|
| 877 | - */ |
|
| 871 | + * Create entry from an XML import |
|
| 872 | + * Certain actions aren't necessary when importing (like saving sub entries, checking for duplicates, etc.) |
|
| 873 | + * |
|
| 874 | + * @since 2.0.16 |
|
| 875 | + * @param array $values |
|
| 876 | + * @return int | boolean $entry_id |
|
| 877 | + */ |
|
| 878 | 878 | public static function create_entry_from_xml( $values ) { |
| 879 | 879 | $entry_id = self::create_entry( $values, 'xml' ); |
| 880 | 880 | |
@@ -882,26 +882,26 @@ discard block |
||
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | /** |
| 885 | - * Update entry from an XML import |
|
| 886 | - * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 887 | - * |
|
| 888 | - * @since 2.0.16 |
|
| 889 | - * @param int $id |
|
| 890 | - * @param array $values |
|
| 891 | - * @return int | boolean $updated |
|
| 892 | - */ |
|
| 885 | + * Update entry from an XML import |
|
| 886 | + * Certain actions aren't necessary when importing (like saving sub entries and modifying other vals) |
|
| 887 | + * |
|
| 888 | + * @since 2.0.16 |
|
| 889 | + * @param int $id |
|
| 890 | + * @param array $values |
|
| 891 | + * @return int | boolean $updated |
|
| 892 | + */ |
|
| 893 | 893 | public static function update_entry_from_xml( $id, $values ) { |
| 894 | 894 | $updated = self::update_entry( $id, $values, 'xml' ); |
| 895 | 895 | |
| 896 | 896 | return $updated; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - /** |
|
| 900 | - * @param string $key |
|
| 901 | - * @return int entry_id |
|
| 902 | - */ |
|
| 899 | + /** |
|
| 900 | + * @param string $key |
|
| 901 | + * @return int entry_id |
|
| 902 | + */ |
|
| 903 | 903 | public static function get_id_by_key( $key ) { |
| 904 | - $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 905 | - return $entry_id; |
|
| 906 | - } |
|
| 904 | + $entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) ); |
|
| 905 | + return $entry_id; |
|
| 906 | + } |
|
| 907 | 907 | } |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 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 |
| 80 | 80 | $filtered_vals = array_filter( $values['item_meta'] ); |
| 81 | - $field_metas = array_filter( $field_metas ); |
|
| 81 | + $field_metas = array_filter( $field_metas ); |
|
| 82 | 82 | if ( empty( $field_metas ) && ! empty( $filtered_vals ) ) { |
| 83 | 83 | return false; |
| 84 | 84 | } |
@@ -329,19 +329,19 @@ discard block |
||
| 329 | 329 | $include_key = apply_filters( 'frm_include_meta_keys', false, array( 'form_id' => $entry->form_id ) ); |
| 330 | 330 | foreach ( $metas as $meta_val ) { |
| 331 | 331 | if ( $meta_val->item_id == $entry->id ) { |
| 332 | - $entry->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 332 | + $entry->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 333 | 333 | if ( $include_key ) { |
| 334 | - $entry->metas[ $meta_val->field_key ] = $entry->metas[ $meta_val->field_id ]; |
|
| 334 | + $entry->metas[$meta_val->field_key] = $entry->metas[$meta_val->field_id]; |
|
| 335 | 335 | } |
| 336 | 336 | continue; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // include sub entries in an array |
| 340 | - if ( ! isset( $entry_metas[ $meta_val->field_id ] ) ) { |
|
| 341 | - $entry->metas[ $meta_val->field_id ] = array(); |
|
| 340 | + if ( ! isset( $entry_metas[$meta_val->field_id] ) ) { |
|
| 341 | + $entry->metas[$meta_val->field_id] = array(); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $entry->metas[ $meta_val->field_id ][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 344 | + $entry->metas[$meta_val->field_id][] = maybe_unserialize( $meta_val->meta_value ); |
|
| 345 | 345 | |
| 346 | 346 | unset( $meta_val ); |
| 347 | 347 | } |
@@ -431,15 +431,15 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | foreach ( $metas as $m_key => $meta_val ) { |
| 434 | - if ( ! isset( $entries[ $meta_val->item_id ] ) ) { |
|
| 434 | + if ( ! isset( $entries[$meta_val->item_id] ) ) { |
|
| 435 | 435 | continue; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( ! isset( $entries[ $meta_val->item_id ]->metas ) ) { |
|
| 439 | - $entries[ $meta_val->item_id ]->metas = array(); |
|
| 438 | + if ( ! isset( $entries[$meta_val->item_id]->metas ) ) { |
|
| 439 | + $entries[$meta_val->item_id]->metas = array(); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - $entries[ $meta_val->item_id ]->metas[ $meta_val->field_id ] = maybe_unserialize( $meta_val->meta_value ); |
|
| 442 | + $entries[$meta_val->item_id]->metas[$meta_val->field_id] = maybe_unserialize( $meta_val->meta_value ); |
|
| 443 | 443 | |
| 444 | 444 | unset( $m_key, $meta_val ); |
| 445 | 445 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | private static function get_entry_value( $values, $name, $default ) { |
| 590 | - return isset( $values[ $name ] ) ? $values[ $name ] : $default; |
|
| 590 | + return isset( $values[$name] ) ? $values[$name] : $default; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |