| @@ -30,5 +30,25 @@ | ||
| 30 | 30 | public function isIntegration(): bool { |
| 31 | 31 | return false; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** | |
| 35 | + * "Unread" indicator on this section's navigation link. Return a version string to enable it; | |
| 36 | + * bump the version to show the badge again after it was seen. Store-wide: the first visit | |
| 37 | + * clears it for every user. | |
| 38 | + */ | |
| 39 | + public function getBadgeVersion(): ?string { | |
| 40 | + return null; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public function isBadgeUnseen(): bool { | |
| 44 | + $version = $this->getBadgeVersion(); | |
| 45 | + | |
| 46 | + return $version && get_option( 'tpt_section_badge_seen_' . $this->getSlug() ) !== $version; | |
| 47 | + } | |
| 48 | + | |
| 49 | + public function markBadgeSeen() { | |
| 50 | + if ( $this->getBadgeVersion() ) { | |
| 51 | + update_option( 'tpt_section_badge_seen_' . $this->getSlug(), $this->getBadgeVersion(), false ); | |
| 52 | + } | |
| 53 | + } | |
| 34 | 54 | } |