Yoast\WP\SEO\Introductions\Infrastructure

Wistia_Embed_Permission_Repository::get_value_for_user()publicYoast 1.0

Retrieves the current value for a user.

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

Хуков нет.

Возвращает

true|false. The current value.

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

$Wistia_Embed_Permission_Repository = new Wistia_Embed_Permission_Repository();
$Wistia_Embed_Permission_Repository->get_value_for_user( $user_id );
$user_id(int) (обязательный)
User ID.

Код Wistia_Embed_Permission_Repository::get_value_for_user() Yoast 24.4

public function get_value_for_user( $user_id ) {
	$value = $this->user_helper->get_meta( $user_id, self::USER_META_KEY, true );
	if ( $value === false ) {
		throw new Exception( 'Invalid User ID' );
	}

	if ( $value === '0' || $value === '1' ) {
		// The value is stored as a string because otherwise we can not see the difference between false and an invalid user ID.
		return $value === '1';
	}

	/**
	 * Why could $value be invalid?
	 * - When the database row does not exist yet, $value can be an empty string.
	 * - Faulty data was stored?
	 */
	return self::DEFAULT_VALUE;
}