WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Admin\RemoteInboxNotifications

DataSourcePoller::validate_spec() private WC 1.0

Validate the spec.

{} Это метод класса: DataSourcePoller{}

Хуков нет.

Возвращает

true/false. The result of the validation.

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

$result = DataSourcePoller::validate_spec( $spec, $url );
$spec(объект) (обязательный)
The spec to validate.
$url(строка) (обязательный)
The url of the feed that provided the spec.

Код DataSourcePoller::validate_spec() WC 4.7.1

<?php
private static function validate_spec( $spec, $url ) {
	$logger         = self::get_logger();
	$logger_context = array( 'source' => $url );

	if ( ! isset( $spec->slug ) ) {
		$logger->error(
			'Spec is invalid because the slug is missing in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	if ( ! isset( $spec->status ) ) {
		$logger->error(
			'Spec is invalid because the status is missing in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	if ( ! isset( $spec->locales ) || ! is_array( $spec->locales ) ) {
		$logger->error(
			'Spec is invalid because the status is missing or empty in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	if ( null === SpecRunner::get_locale( $spec->locales ) ) {
		$logger->error(
			'Spec is invalid because the locale could not be retrieved in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	if ( ! isset( $spec->type ) ) {
		$logger->error(
			'Spec is invalid because the type is missing in feed',
			$logger_context
		);
		// phpcs:ignore
		$logger->error( print_r( $spec, true ), $logger_context );

		return false;
	}

	if ( isset( $spec->actions ) && is_array( $spec->actions ) ) {
		foreach ( $spec->actions as $action ) {
			if ( ! self::validate_action( $action, $url ) ) {
				$logger->error(
					'Spec is invalid because an action is invalid in feed',
					$logger_context
				);
				// phpcs:ignore
				$logger->error( print_r( $spec, true ), $logger_context );

				return false;
			}
		}
	}

	if ( isset( $spec->rules ) && is_array( $spec->rules ) ) {
		foreach ( $spec->rules as $rule ) {
			if ( ! isset( $rule->type ) ) {
				$logger->error(
					'Spec is invalid because a rule type is empty in feed',
					$logger_context
				);
				// phpcs:ignore
				$logger->error( print_r( $rule, true ), $logger_context );
				// phpcs:ignore
				$logger->error( print_r( $spec, true ), $logger_context );

				return false;
			}

			$processor = GetRuleProcessor::get_processor( $rule->type );

			if ( ! $processor->validate( $rule ) ) {
				$logger->error(
					'Spec is invalid because a rule is invalid in feed',
					$logger_context
				);
				// phpcs:ignore
				$logger->error( print_r( $rule, true ), $logger_context );
				// phpcs:ignore
				$logger->error( print_r( $spec, true ), $logger_context );

				return false;
			}
		}
	}

	return true;
}