Yoast\WP\SEO\Dashboard\Infrastructure\Configuration

Site_Kit_Consent_Repository{}Yoast 1.0

Stores and retrieves the Site Kit consent status.

Хуков нет.

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

$Site_Kit_Consent_Repository = new Site_Kit_Consent_Repository();
// use class methods

Методы

  1. public __construct( Options_Helper $options_helper )
  2. public is_consent_granted()
  3. public set_site_kit_consent( bool $consent )

Код Site_Kit_Consent_Repository{} Yoast 25.1

class Site_Kit_Consent_Repository implements Site_Kit_Consent_Repository_Interface {

	/**
	 * Holds the Options_Helper instance.
	 *
	 * @var Options_Helper
	 */
	private $options_helper;

	/**
	 * Constructs the class.
	 *
	 * @param Options_Helper $options_helper The options helper.
	 */
	public function __construct( Options_Helper $options_helper ) {
		$this->options_helper = $options_helper;
	}

	/**
	 * Sets the Site Kit consent value.
	 *
	 * @param bool $consent The consent status.
	 *
	 * @return bool False when the update failed, true when the update succeeded.
	 */
	public function set_site_kit_consent( bool $consent ): bool {
		return $this->options_helper->set( 'site_kit_connected', $consent );
	}

	/**
	 * Checks if consent has ben given for Site Kit.
	 * *
	 *
	 * @return bool True when consent has been given, false when it is not.
	 */
	public function is_consent_granted(): bool {
		return $this->options_helper->get( 'site_kit_connected', false );
	}
}