Yoast\WP\SEO\Conditionals

Gradual_Rollout_Conditional::is_in_rollout_cohort │ private │ Yoast 1.0

Determines whether this site falls within the current rollout share.

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

Хуков нет.

Возвращает

bool. Whether this site is in the rollout cohort.

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

// private - только в коде основоного (родительского) класса
$result = $this->is_in_rollout_cohort(): bool;

Код Gradual_Rollout_Conditional::is_in_rollout_cohort() Yoast 28.7

private function is_in_rollout_cohort(): bool {
	$share = \max( 0, \min( self::BUCKET_COUNT, $this->get_rollout_share() ) );

	if ( $share <= 0 ) {
		return false;
	}

	if ( $share >= self::BUCKET_COUNT ) {
		return true;
	}

	// Hash the feature name together with the site URL so cohorts differ per feature
	// (no permanently lucky sites). sprintf( '%u' ) reads crc32's result as unsigned,
	// which keeps the modulo correct on 32-bit platforms where crc32 can be negative.
	$bucket = ( (int) \sprintf( '%u', \crc32( $this->get_feature_name() . \site_url() ) ) % self::BUCKET_COUNT );

	return ( $bucket < $share );
}