| @@ -473,10 +473,8 @@ | ||
| 473 | 473 | public function required_mark( $field ) { |
| 474 | 474 | if ( $this->is_required( $field ) ) { |
| 475 | 475 | return ' <span class="required">*</span>'; |
| 476 | 476 | } |
| 477 | - | |
| 478 | - return ''; | |
| 479 | 477 | } |
| 480 | 478 | |
| 481 | 479 | /** |
| 482 | 480 | * Prints help text for a field |
| @@ -530,34 +528,23 @@ | ||
| 530 | 528 | * |
| 531 | 529 | * @return mixed |
| 532 | 530 | */ |
| 533 | 531 | 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'] : ''; | |
| 532 | + if( empty( $_POST['_wpnonce'] ) ) { | |
| 533 | + wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); | |
| 538 | 534 | } |
| 539 | 535 | |
| 540 | - if ( empty( $nonce ) ) { | |
| 536 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) { | |
| 541 | 537 | wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); |
| 542 | 538 | } |
| 543 | 539 | |
| 544 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $nonce ) ), 'wpuf_form_add' ) ) { | |
| 545 | - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) ); | |
| 546 | - } | |
| 540 | + $args = ! empty( $args ) ? $args : weforms_clean( $_POST ); | |
| 541 | + $value = !empty( $args[$field['name']] ) ? $args[$field['name']] : ''; | |
| 547 | 542 | |
| 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 | 543 | if ( is_array( $value ) ) { |
| 557 | - $entry_value = implode( WeForms::$field_separator, $value ); | |
| 544 | + $entry_value = implode( WeForms::$field_separator, $args[$field['name']] ); | |
| 558 | 545 | } else { |
| 559 | - $entry_value = sanitize_textarea_field( trim( $value ) ); | |
| 546 | + $entry_value = trim( $value ); | |
| 560 | 547 | } |
| 561 | 548 | |
| 562 | 549 | return $entry_value; |
| 563 | 550 | } |