Yoast\WP\SEO\Llms_Txt\Infrastructure\File

WordPress_Llms_Txt_Permission_Gate::is_managed_by_yoast_seo │ public │ Yoast 1.0

Checks if Yoast SEO manages the llms.txt.

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

Хуков нет.

Возвращает

bool. Checks if Yoast SEO manages the llms.txt.

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

$WordPress_Llms_Txt_Permission_Gate = new WordPress_Llms_Txt_Permission_Gate();
$WordPress_Llms_Txt_Permission_Gate->is_managed_by_yoast_seo(): bool;

Код WordPress_Llms_Txt_Permission_Gate::is_managed_by_yoast_seo() Yoast 28.9

public function is_managed_by_yoast_seo(): bool {
	$stored_hash = \get_option( Populate_File_Command_Handler::CONTENT_HASH_OPTION, '' );

	// If the file does not exist yet, we always regenerate/create it.
	if ( ! $this->file_system_adapter->file_exists() ) {
		return true;
	}

	// This means the file is already there (maybe hand made or another plugin created it). And since we don't have a hash it's not ours.
	if ( $stored_hash === '' ) {
		return false;
	}

	$current_content = $this->file_system_adapter->get_file_contents();

	// If you have a hash, we want to make sure it's the same. This check makes sure the file is not edited by the user.
	return \md5( $current_content ) === $stored_hash;
}