. * * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ */ 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 * * @return array */ public function add( $type, $email, $message, $terms ) { $errors = array(); // Submit feedback to ServMask if ( empty( $type ) ) { $errors[] = __( 'Feedback type is invalid.', AI1WM_PLUGIN_NAME ); } elseif ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) { $errors[] = __( 'Your email is not valid.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $message ) ) { $errors[] = __( 'Please enter comments in the text area.', AI1WM_PLUGIN_NAME ); } elseif ( empty( $terms ) ) { $errors[] = __( 'Please accept feedback term conditions.', AI1WM_PLUGIN_NAME ); } else { $response = wp_remote_post( AI1WM_FEEDBACK_URL, array( 'timeout' => 15, 'body' => array( 'type' => $type, 'email' => $email, 'message' => $message, ), ) ); if ( is_wp_error( $response ) ) { $errors[] = sprintf( __( 'Something went wrong: %s', AI1WM_PLUGIN_NAME ), $response->get_error_message() ); } } return $errors; } }