Yoast\WP\SEO\Abilities\Application

Site_Representation_Updater::save_logo │ private │ Yoast 1.0

Saves a logo ID along with its URL, like the media library does in the settings and the first-time configuration.

The schema reads the logo by its ID, while the settings and the first-time configuration show it by its URL.

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

Хуков нет.

Возвращает

bool. Whether the logo ID was saved.

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

// private - только в коде основоного (родительского) класса
$result = $this->save_logo( $field_name, $attachment_id ): bool;
$field_name(строка) (обязательный)
The option name of the logo ID.
$attachment_id(int) (обязательный)
The attachment ID of the logo, 0 to clear it.

Код Site_Representation_Updater::save_logo() Yoast 28.8

private function save_logo( string $field_name, int $attachment_id ): bool {
	if ( $this->options_helper->set( $field_name, $attachment_id ) !== true ) {
		return false;
	}

	$logo = self::LOGOS[ $field_name ];
	$url  = ( $attachment_id === 0 ) ? '' : $this->image_helper->get_attachment_image_url( $attachment_id, 'full' );

	$this->options_helper->set( $logo, $url );
	// Much like saving the logo from the settings/FTC, let's also clear its meta information so that it can lazily be generated when needed.
	$this->options_helper->set( $logo . '_meta', false );

	return true;
}