Automattic\WooCommerce\Admin\RemoteInboxNotifications

RemoteInboxNotificationsEngine::get_note_from_db()public staticWC 1.0

Get the note. This is used to display localized note.

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

Хуков нет.

Возвращает

Note. The note.

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

$result = RemoteInboxNotificationsEngine::get_note_from_db( $note_from_db );
$note_from_db(Note) (обязательный)
The note object created from db.

Код RemoteInboxNotificationsEngine::get_note_from_db() WC 8.7.0

public static function get_note_from_db( $note_from_db ) {
	if ( ! $note_from_db instanceof Note || get_user_locale() === $note_from_db->get_locale() ) {
		return $note_from_db;
	}
	$specs = DataSourcePoller::get_instance()->get_specs_from_data_sources();
	foreach ( $specs as $spec ) {
		if ( $spec->slug !== $note_from_db->get_name() ) {
			continue;
		}
		$locale = SpecRunner::get_locale( $spec->locales, true );
		if ( $locale === null ) {
			// No locale found, so don't update the note.
			break;
		}

		$localized_actions = SpecRunner::get_actions( $spec );

		// Manually copy the action id from the db to the localized action, since they were not being provided.
		foreach ( $localized_actions as $localized_action ) {
			$action = $note_from_db->get_action( $localized_action->name );
			if ( $action ) {
				$localized_action->id = $action->id;
			}
		}

		$note_from_db->set_title( $locale->title );
		$note_from_db->set_content( $locale->content );
		$note_from_db->set_actions( $localized_actions );
	}

	return $note_from_db;
}