WC_Auth::make_validation()
Make validation.
Description Description
Source Source
File: includes/class-wc-auth.php
protected function make_validation() {
$data = array();
$params = array(
'app_name',
'user_id',
'return_url',
'callback_url',
'scope',
);
foreach ( $params as $param ) {
if ( empty( $_REQUEST[ $param ] ) ) { // WPCS: input var ok, CSRF ok.
/* translators: %s: parameter */
throw new Exception( sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param ) );
}
$data[ $param ] = wp_unslash( $_REQUEST[ $param ] ); // WPCS: input var ok, CSRF ok, sanitization ok.
}
if ( ! in_array( $data['scope'], array( 'read', 'write', 'read_write' ), true ) ) {
/* translators: %s: scope */
throw new Exception( sprintf( __( 'Invalid scope %s', 'woocommerce' ), wc_clean( $data['scope'] ) ) );
}
foreach ( array( 'return_url', 'callback_url' ) as $param ) {
$param = $this->get_formatted_url( $data[ $param ] );
if ( false === filter_var( $param, FILTER_VALIDATE_URL ) ) {
/* translators: %s: url */
throw new Exception( sprintf( __( 'The %s is not a valid URL', 'woocommerce' ), $param ) );
}
}
$callback_url = $this->get_formatted_url( $data['callback_url'] );
if ( 0 !== stripos( $callback_url, 'https://' ) ) {
throw new Exception( __( 'The callback_url needs to be over SSL', 'woocommerce' ) );
}
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.4.0 | Introduced. |