@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | * @param array $message |
| 76 | 76 | */ |
| 77 | 77 | public function add_message( $message ) { |
| 78 | - if ( isset( $this->messages[ $message['key'] ] ) && ! isset( $message['force'] ) ) { |
|
| 78 | + if ( isset( $this->messages[$message['key']] ) && ! isset( $message['force'] ) ) { |
|
| 79 | 79 | // Don't replace messages unless required. |
| 80 | 80 | return; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( isset( $this->messages[ $message['key'] ] ) ) { |
|
| 83 | + if ( isset( $this->messages[$message['key']] ) ) { |
|
| 84 | 84 | // Move up and mark as new. |
| 85 | - unset( $this->messages[ $message['key'] ] ); |
|
| 85 | + unset( $this->messages[$message['key']] ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $this->fill_message( $message ); |
| 89 | - $this->messages[ $message['key'] ] = $message; |
|
| 89 | + $this->messages[$message['key']] = $message; |
|
| 90 | 90 | |
| 91 | 91 | $this->update_list(); |
| 92 | 92 | |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | private function clean_messages() { |
| 115 | 115 | $removed = false; |
| 116 | 116 | foreach ( $this->messages as $t => $message ) { |
| 117 | - $read = isset( $message['read'] ) && ! empty( $message['read'] ) && isset( $message['read'][ get_current_user_id() ] ) && $message['read'][ get_current_user_id() ] < strtotime( '-1 month' ); |
|
| 118 | - $dismissed = isset( $message['dismissed'] ) && ! empty( $message['dismissed'] ) && isset( $message['dismissed'][ get_current_user_id() ] ) && $message['dismissed'][ get_current_user_id() ] < strtotime( '-1 week' ); |
|
| 117 | + $read = isset( $message['read'] ) && ! empty( $message['read'] ) && isset( $message['read'][get_current_user_id()] ) && $message['read'][get_current_user_id()] < strtotime( '-1 month' ); |
|
| 118 | + $dismissed = isset( $message['dismissed'] ) && ! empty( $message['dismissed'] ) && isset( $message['dismissed'][get_current_user_id()] ) && $message['dismissed'][get_current_user_id()] < strtotime( '-1 week' ); |
|
| 119 | 119 | $expired = $this->is_expired( $message ); |
| 120 | 120 | if ( $read || $expired || $dismissed ) { |
| 121 | - unset( $this->messages[ $t ] ); |
|
| 121 | + unset( $this->messages[$t] ); |
|
| 122 | 122 | $removed = true; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -131,11 +131,11 @@ discard block |
||
| 131 | 131 | private function filter_messages( &$messages ) { |
| 132 | 132 | $user_id = get_current_user_id(); |
| 133 | 133 | foreach ( $messages as $k => $message ) { |
| 134 | - $dismissed = isset( $message['dismissed'] ) && isset( $message['dismissed'][ $user_id ] ); |
|
| 134 | + $dismissed = isset( $message['dismissed'] ) && isset( $message['dismissed'][$user_id] ); |
|
| 135 | 135 | if ( $this->is_expired( $message ) || $dismissed ) { |
| 136 | - unset( $messages[ $k ] ); |
|
| 136 | + unset( $messages[$k] ); |
|
| 137 | 137 | } elseif ( ! $this->is_for_user( $message ) ) { |
| 138 | - unset( $messages[ $k ] ); |
|
| 138 | + unset( $messages[$k] ); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | $messages = apply_filters( 'frm_filter_inbox', $messages ); |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | * @param string $key |
| 169 | 169 | */ |
| 170 | 170 | public function mark_read( $key ) { |
| 171 | - if ( ! isset( $this->messages[ $key ] ) ) { |
|
| 171 | + if ( ! isset( $this->messages[$key] ) ) { |
|
| 172 | 172 | return; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( ! isset( $this->messages[ $key ]['read'] ) ) { |
|
| 176 | - $this->messages[ $key ]['read'] = array(); |
|
| 175 | + if ( ! isset( $this->messages[$key]['read'] ) ) { |
|
| 176 | + $this->messages[$key]['read'] = array(); |
|
| 177 | 177 | } |
| 178 | - $this->messages[ $key ]['read'][ get_current_user_id() ] = time(); |
|
| 178 | + $this->messages[$key]['read'][get_current_user_id()] = time(); |
|
| 179 | 179 | |
| 180 | 180 | $this->update_list(); |
| 181 | 181 | } |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | * @since 4.05.02 |
| 187 | 187 | */ |
| 188 | 188 | public function mark_unread( $key ) { |
| 189 | - $is_read = isset( $this->messages[ $key ] ) && isset( $this->messages[ $key ]['read'] ) && isset( $this->messages[ $key ]['read'][ get_current_user_id() ] ); |
|
| 189 | + $is_read = isset( $this->messages[$key] ) && isset( $this->messages[$key]['read'] ) && isset( $this->messages[$key]['read'][get_current_user_id()] ); |
|
| 190 | 190 | if ( $is_read ) { |
| 191 | - unset( $this->messages[ $key ]['read'][ get_current_user_id() ] ); |
|
| 191 | + unset( $this->messages[$key]['read'][get_current_user_id()] ); |
|
| 192 | 192 | $this->update_list(); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if ( ! isset( $this->messages[ $key ] ) ) { |
|
| 205 | + if ( ! isset( $this->messages[$key] ) ) { |
|
| 206 | 206 | return; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( ! isset( $this->messages[ $key ]['dismissed'] ) ) { |
|
| 210 | - $this->messages[ $key ]['dismissed'] = array(); |
|
| 209 | + if ( ! isset( $this->messages[$key]['dismissed'] ) ) { |
|
| 210 | + $this->messages[$key]['dismissed'] = array(); |
|
| 211 | 211 | } |
| 212 | - $this->messages[ $key ]['dismissed'][ get_current_user_id() ] = time(); |
|
| 212 | + $this->messages[$key]['dismissed'][get_current_user_id()] = time(); |
|
| 213 | 213 | |
| 214 | 214 | $this->update_list(); |
| 215 | 215 | } |
@@ -221,11 +221,11 @@ discard block |
||
| 221 | 221 | $user_id = get_current_user_id(); |
| 222 | 222 | foreach ( $this->messages as $key => $message ) { |
| 223 | 223 | if ( ! isset( $message['dismissed'] ) ) { |
| 224 | - $this->messages[ $key ]['dismissed'] = array(); |
|
| 224 | + $this->messages[$key]['dismissed'] = array(); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ! isset( $message['dismissed'][ $user_id ] ) ) { |
|
| 228 | - $this->messages[ $key ]['dismissed'][ $user_id ] = time(); |
|
| 227 | + if ( ! isset( $message['dismissed'][$user_id] ) ) { |
|
| 228 | + $this->messages[$key]['dismissed'][$user_id] = time(); |
|
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | $this->update_list(); |
@@ -235,8 +235,8 @@ discard block |
||
| 235 | 235 | $messages = $this->get_messages( 'filter' ); |
| 236 | 236 | $user_id = get_current_user_id(); |
| 237 | 237 | foreach ( $messages as $t => $message ) { |
| 238 | - if ( isset( $message['read'] ) && isset( $message['read'][ $user_id ] ) ) { |
|
| 239 | - unset( $messages[ $t ] ); |
|
| 238 | + if ( isset( $message['read'] ) && isset( $message['read'][$user_id] ) ) { |
|
| 239 | + unset( $messages[$t] ); |
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | return $messages; |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | * @since 4.05.02 |
| 261 | 261 | */ |
| 262 | 262 | public function remove( $key ) { |
| 263 | - if ( isset( $this->messages[ $key ] ) ) { |
|
| 264 | - unset( $this->messages[ $key ] ); |
|
| 263 | + if ( isset( $this->messages[$key] ) ) { |
|
| 264 | + unset( $this->messages[$key] ); |
|
| 265 | 265 | $this->update_list(); |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | if ( $_POST ) { |
| 118 | 118 | $repeating = isset( $args['repeating'] ) && $args['repeating']; |
| 119 | 119 | if ( $repeating ) { |
| 120 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { |
|
| 120 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) { |
|
| 121 | 121 | $value_is_posted = true; |
| 122 | 122 | } |
| 123 | - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { |
|
| 123 | + } elseif ( isset( $_POST['item_meta'][$field->id] ) ) { |
|
| 124 | 124 | $value_is_posted = true; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER ); |
| 151 | 151 | |
| 152 | 152 | foreach ( $shortcodes[0] as $short_key => $tag ) { |
| 153 | - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] ); |
|
| 153 | + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] ); |
|
| 154 | 154 | if ( ! empty( $add_atts ) ) { |
| 155 | 155 | $this_atts = array_merge( $atts, $add_atts ); |
| 156 | 156 | } else { |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $default = FrmEntriesController::show_entry_shortcode( $this_atts ); |
| 161 | 161 | |
| 162 | 162 | // Add the default message. |
| 163 | - $message = str_replace( $shortcodes[0][ $short_key ], $default, $message ); |
|
| 163 | + $message = str_replace( $shortcodes[0][$short_key], $default, $message ); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | return $message; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | public static function prepare_display_value( $entry, $field, $atts ) { |
| 170 | - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false; |
|
| 170 | + $field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false; |
|
| 171 | 171 | |
| 172 | 172 | if ( FrmAppHelper::pro_is_installed() ) { |
| 173 | 173 | $empty = empty( $field_value ); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) ); |
| 191 | 191 | } else { |
| 192 | 192 | // Get all values for this field. |
| 193 | - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false; |
|
| 193 | + $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false; |
|
| 194 | 194 | |
| 195 | 195 | if ( $child_values ) { |
| 196 | 196 | $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) ); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $value = $args['temp_value']; |
| 309 | 309 | } |
| 310 | 310 | if ( empty( $args['parent_field_id'] ) ) { |
| 311 | - $_POST['item_meta'][ $field->id ] = $value; |
|
| 311 | + $_POST['item_meta'][$field->id] = $value; |
|
| 312 | 312 | } else { |
| 313 | 313 | self::set_parent_field_posted_value( $field, $value, $args ); |
| 314 | 314 | } |
@@ -320,20 +320,20 @@ discard block |
||
| 320 | 320 | * @since 4.01 |
| 321 | 321 | */ |
| 322 | 322 | private static function set_parent_field_posted_value( $field, $value, $args ) { |
| 323 | - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && |
|
| 324 | - is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { |
|
| 323 | + if ( isset( $_POST['item_meta'][$args['parent_field_id']] ) && |
|
| 324 | + is_array( $_POST['item_meta'][$args['parent_field_id']] ) ) { |
|
| 325 | 325 | |
| 326 | - if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || |
|
| 327 | - ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { |
|
| 328 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); |
|
| 326 | + if ( ! isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) || |
|
| 327 | + ! is_array( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] ) ) { |
|
| 328 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array(); |
|
| 329 | 329 | } |
| 330 | 330 | } else { |
| 331 | 331 | // All of the section was probably removed. |
| 332 | - $_POST['item_meta'][ $args['parent_field_id'] ] = array(); |
|
| 333 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); |
|
| 332 | + $_POST['item_meta'][$args['parent_field_id']] = array(); |
|
| 333 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']] = array(); |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; |
|
| 336 | + $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | public static function get_posted_value( $field, &$value, $args ) { |
@@ -364,10 +364,10 @@ discard block |
||
| 364 | 364 | if ( empty( $args['parent_field_id'] ) ) { |
| 365 | 365 | // Sanitizing is done next. |
| 366 | 366 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 367 | - $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; |
|
| 367 | + $value = isset( $_POST['item_meta'][$field_id] ) ? wp_unslash( $_POST['item_meta'][$field_id] ) : ''; |
|
| 368 | 368 | } else { |
| 369 | 369 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 370 | - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; |
|
| 370 | + $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) : ''; |
|
| 371 | 371 | } |
| 372 | 372 | return $value; |
| 373 | 373 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | self::set_other_repeating_vals( $field, $value, $args ); |
| 399 | 399 | |
| 400 | 400 | // Check if there are any posted "Other" values. |
| 401 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { |
|
| 401 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) { |
|
| 402 | 402 | |
| 403 | 403 | // Save original value. |
| 404 | 404 | $args['temp_value'] = $value; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | // Sanitizing is done next. |
| 408 | 408 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 409 | - $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); |
|
| 409 | + $other_vals = wp_unslash( $_POST['item_meta']['other'][$field->id] ); |
|
| 410 | 410 | FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); |
| 411 | 411 | |
| 412 | 412 | // Set the validation value now |
@@ -429,13 +429,13 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | // Check if there are any other posted "other" values for this field. |
| 432 | - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { |
|
| 432 | + if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) { |
|
| 433 | 433 | // Save original value |
| 434 | 434 | $args['temp_value'] = $value; |
| 435 | 435 | $args['other'] = true; |
| 436 | 436 | |
| 437 | 437 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 438 | - $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); |
|
| 438 | + $other_vals = wp_unslash( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ); |
|
| 439 | 439 | FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals ); |
| 440 | 440 | |
| 441 | 441 | // Set the validation value now. |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | if ( is_array( $value ) && $field->type === 'checkbox' ) { |
| 463 | 463 | // Combine "Other" values with checked values. "Other" values will override checked box values. |
| 464 | 464 | foreach ( $other_vals as $k => $v ) { |
| 465 | - if ( isset( $value[ $k ] ) && trim( $v ) === '' ) { |
|
| 465 | + if ( isset( $value[$k] ) && trim( $v ) === '' ) { |
|
| 466 | 466 | // If the other box is checked, but doesn't have a value. |
| 467 | 467 | $value = ''; |
| 468 | 468 | break; |
@@ -479,25 +479,25 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | // Multi-select dropdown. |
| 481 | 481 | if ( is_array( $value ) ) { |
| 482 | - $o_key = array_search( $field->options[ $other_key ], $value ); |
|
| 482 | + $o_key = array_search( $field->options[$other_key], $value ); |
|
| 483 | 483 | |
| 484 | 484 | if ( $o_key !== false ) { |
| 485 | 485 | // Modify the original value so other key will be preserved. |
| 486 | - $value[ $other_key ] = $value[ $o_key ]; |
|
| 486 | + $value[$other_key] = $value[$o_key]; |
|
| 487 | 487 | |
| 488 | 488 | // By default, the array keys will be numeric for multi-select dropdowns. |
| 489 | 489 | // If going backwards and forwards between pages, the array key will match the other key. |
| 490 | 490 | if ( $o_key !== $other_key ) { |
| 491 | - unset( $value[ $o_key ] ); |
|
| 491 | + unset( $value[$o_key] ); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $args['temp_value'] = $value; |
| 495 | - $value[ $other_key ] = reset( $other_vals ); |
|
| 496 | - if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) { |
|
| 497 | - unset( $value[ $other_key ] ); |
|
| 495 | + $value[$other_key] = reset( $other_vals ); |
|
| 496 | + if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) { |
|
| 497 | + unset( $value[$other_key] ); |
|
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | - } elseif ( $field->options[ $other_key ] == $value ) { |
|
| 500 | + } elseif ( $field->options[$other_key] == $value ) { |
|
| 501 | 501 | $value = $other_vals; |
| 502 | 502 | } |
| 503 | 503 | } |