admin_url( 'admin-ajax.php' ) ) ); wp_enqueue_script( 'post-feedback' ); } function post_user_feedback() { if ( ! check_ajax_referer() ) { die( 'security error' ); } $payload = array( 'reason' => sanitize_text_field( $_POST['reason'] ), 'other_input' => isset( $_POST['other_input'] ) ? sanitize_text_field( $_POST['other_input'] ) : '', ); if ( isset( $_POST['support'] ) ) { $payload['support']['email'] = sanitize_email( $_POST['support']['email'] ); $payload['support']['title'] = sanitize_text_field( $_POST['support']['title'] ); $payload['support']['text'] = sanitize_textarea_field( $_POST['support']['text'] ); } $args = array( 'body' => $payload, 'timeout' => 20, ); $result = wp_remote_post( 'https://postmansmtp.com/feedback', $args ); die( 'success' ); } function admin_head() { ?>