WPSEO_MyYoast_Api_Request::validate_responseprivateYoast 1.0

Validates that all the needed fields are in de decoded response.

Метод класса: WPSEO_MyYoast_Api_Request{}

Хуков нет.

Возвращает

stdClass. The json decoded response.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->validate_response( $response );
$response(stdClass) (обязательный)
The response to validate.

Код WPSEO_MyYoast_Api_Request::validate_response() Yoast 27.9

private function validate_response( $response ) {
	if ( isset( $response->url, $response->subscriptions ) && is_array( $response->subscriptions ) ) {
		return $response;
	}

	throw new WPSEO_MyYoast_Invalid_JSON_Exception(
		esc_html__( 'Not all needed fields are present.', 'wordpress-seo' ),
	);
}