| @@ -530,34 +530,23 @@ | ||
| 530 | 530 | * |
| 531 | 531 | * @return mixed |
| 532 | 532 | */ |
| 533 | 533 | public function prepare_entry( $field, $args = [] ) { |
| 534 | - if ( $args instanceof WP_REST_Request ) { | |
| 535 | - $nonce = $args->get_param( '_wpnonce' ); | |
| 536 | - } else { | |
| 537 | - $nonce = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : ''; | |
| 534 | + if( empty( $_POST['_wpnonce'] ) ) { | |
| 535 | + wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); | |
| 538 | 536 | } |
| 539 | 537 | |
| 540 | - if ( empty( $nonce ) ) { | |
| 538 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) { | |
| 541 | 539 | wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); |
| 542 | 540 | } |
| 543 | 541 | |
| 544 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $nonce ) ), 'wpuf_form_add' ) ) { | |
| 545 | - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); | |
| 546 | - } | |
| 542 | + $args = ! empty( $args ) ? $args : weforms_clean( $_POST ); | |
| 543 | + $value = !empty( $args[$field['name']] ) ? $args[$field['name']] : ''; | |
| 547 | 544 | |
| 548 | - if ( $args instanceof WP_REST_Request ) { | |
| 549 | - $args = weforms_clean( $args->get_params() ); | |
| 550 | - } elseif ( empty( $args ) ) { | |
| 551 | - $args = weforms_clean( $_POST ); | |
| 552 | - } | |
| 553 | - | |
| 554 | - $value = ! empty( $args[ $field['name'] ] ) ? $args[ $field['name'] ] : ''; | |
| 555 | - | |
| 556 | 545 | if ( is_array( $value ) ) { |
| 557 | - $entry_value = implode( WeForms::$field_separator, $value ); | |
| 546 | + $entry_value = implode( WeForms::$field_separator, $args[$field['name']] ); | |
| 558 | 547 | } else { |
| 559 | - $entry_value = sanitize_textarea_field( trim( $value ) ); | |
| 548 | + $entry_value = trim( $value ); | |
| 560 | 549 | } |
| 561 | 550 | |
| 562 | 551 | return $entry_value; |
| 563 | 552 | } |