__( 'Name', 'dealroot' ), 'email' => __( 'Email', 'dealroot' ), 'phone' => __( 'Phone', 'dealroot' ), 'subject' => __( 'Subject', 'dealroot' ), 'message' => __( 'Message', 'dealroot' ), ); $fields = array(); foreach ( $labels as $key => $label ) { if ( isset( $_POST[ $key ] ) ) { $fields[] = array( 'label' => $label, 'name' => $key, 'type' => 'email' === $key ? 'email' : ( 'phone' === $key ? 'tel' : ( 'message' === $key ? 'textarea' : 'text' ) ), 'value' => sanitize_textarea_field( wp_unslash( $_POST[ $key ] ) ), ); } } $node_id = isset( $_POST['node_id'] ) ? sanitize_key( wp_unslash( $_POST['node_id'] ) ) : ''; $post_id = isset( $_POST['post_id'] ) ? absint( wp_unslash( $_POST['post_id'] ) ) : 0; // phpcs:enable Capture::submission( self::key(), $node_id, $post_id ? (string) get_the_title( $post_id ) : __( 'Contact form', 'dealroot' ), $fields ); } }