Yoast\WP\SEO

Loader::conditionals_are_met()protectedYoast 1.0

Checks if all conditionals of a given loadable are met.

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

Хуков нет.

Возвращает

true|false. Whether all conditionals of the loadable are met.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->conditionals_are_met( $loadable_class );
$loadable_class(строка) (обязательный)
The class name of the loadable.

Код Loader::conditionals_are_met() Yoast 22.4

protected function conditionals_are_met( $loadable_class ) {
	// In production environments do not fatal if the class does not exist but log and fail gracefully.
	if ( \YOAST_ENVIRONMENT === 'production' && ! \class_exists( $loadable_class ) ) {
		if ( \defined( 'WP_DEBUG' ) && \WP_DEBUG ) {
			// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
			\error_log(
				\sprintf(
					/* translators: %1$s expands to Yoast SEO, %2$s expands to the name of the class that could not be found. */
					\__( '%1$s attempted to load the class %2$s but it could not be found.', 'wordpress-seo' ),
					'Yoast SEO',
					$loadable_class
				)
			);
		}
		return false;
	}

	$conditionals = $loadable_class::get_conditionals();
	foreach ( $conditionals as $class ) {
		$conditional = $this->get_class( $class );
		if ( $conditional === null || ! $conditional->is_met() ) {
			return false;
		}
	}

	return true;
}