WC_Auth::make_validation
Make validation.
Метод класса: WC_Auth{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->make_validation();
Список изменений
| С версии 2.4.0 | Введена. |
Код WC_Auth::make_validation() WC Auth::make validation WC 11.2.2
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 ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Values are required for handshake validation; key creation verifies capability and nonce.
/* translators: %s: parameter */
throw new Exception( sprintf( __( 'Missing parameter %s', 'woocommerce' ), $param ) );
}
// Every handshake parameter is a single string; anything else, an array in particular, is rejected here so that it cannot reach the string-only functions used below.
if ( ! is_string( $_REQUEST[ $param ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Values are required for handshake validation; key creation verifies capability and nonce.
/* translators: %s: parameter */
throw new Exception( sprintf( __( 'Invalid parameter %s', 'woocommerce' ), $param ) ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- The caught message is escaped by esc_html() where it is rendered; escaping here would double-encode translated text.
}
$data[ $param ] = wp_unslash( $_REQUEST[ $param ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Raw values are needed to validate the submitted URLs and scope; each value is sanitized or escaped where it is used, and key creation verifies capability and nonce.
}
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' ) );
}
}