validate() ) { wp_send_json_error( __( 'Missing required parameters.', 'gravitysmtp' ), 400 ); } $license_key = filter_input( INPUT_POST, self::PARAM_LICENSE_KEY ); $license_key = htmlspecialchars( $license_key ); $container = Gravity_SMTP::container(); $key_is_empty = empty( $license_key ); $is_valid = false; if ( ! $key_is_empty ) { $license_info = $container->get( Updates_Service_Provider::LICENSE_API_CONNECTOR )->check_license( $license_key ); $is_valid = License_Statuses::VALID_KEY === $license_info->get_status(); } if ( ! $is_valid ) { wp_send_json_error( __( 'Invalid license key.', 'gravitysmtp' ), 400 ); } wp_send_json_success( array( 'license_key' => $license_key ) ); } protected function validate() { if ( ! parent::validate() ) { return false; } if ( empty( $_REQUEST[ self::PARAM_LICENSE_KEY ] ) ) { return false; } return true; } }