. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ if ( ! defined( 'ABSPATH' ) ) { die( 'Kangaroos cannot jump here' ); } class Ai1wm_Feedback { /** * Submit customer feedback to servmask.com * * @param string $type Feedback type * @param string $email User e-mail * @param string $message User message * @param integer $terms User accept terms * @param string $purchases Purchases IDs * * @return array */ public static function add( $type, $email, $message, $terms, $purchases ) { // Validate email if ( filter_var( $email, FILTER_VALIDATE_EMAIL ) === false ) { throw new Ai1wm_Feedback_Exception( __( 'Your email is not valid.', AI1WM_PLUGIN_NAME ) ); } // Validate type if ( empty( $type ) ) { throw new Ai1wm_Feedback_Exception( __( 'Feedback type is not valid.', AI1WM_PLUGIN_NAME ) ); } // Validate message if ( empty( $message ) ) { throw new Ai1wm_Feedback_Exception( __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME ) ); } // Validate terms if ( empty( $terms ) ) { throw new Ai1wm_Feedback_Exception( __( 'Please accept feedback term conditions.', AI1WM_PLUGIN_NAME ) ); } $response = wp_remote_post( AI1WM_FEEDBACK_URL, array( 'timeout' => 15, 'body' => array( 'type' => $type, 'email' => $email, 'message' => $message, 'purchases' => $purchases, ), ) ); if ( is_wp_error( $response ) ) { throw new Ai1wm_Feedback_Exception( sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() ) ); } return $response; } }