access->isAdmin() ) { return; } /** * Allows the "what's new" modal to be turned off. * * @since 5.0.0 * * @param bool $show Whether to show the modal. */ if ( ! apply_filters( 'aioseo_show_whats_new_modal', true ) ) { return; } $userId = get_current_user_id(); $current = aioseo()->version; $seen = (string) get_user_meta( $userId, self::SEEN_META, true ); // First sight of this user: record where they are and show nothing, so a fresh // install isn't shown a backlog it was never missing. if ( '' === $seen ) { update_user_meta( $userId, self::SEEN_META, $current ); return; } if ( version_compare( $seen, $current, '>=' ) ) { return; } $items = aioseo()->newsroom->getItemsBetweenVersions( $seen, $current ); // Nothing published for the skipped versions, so there's nothing worth // interrupting for — which is how a patch release stays silent with no flag. if ( empty( $items ) ) { update_user_meta( $userId, self::SEEN_META, $current ); return; } // Recorded before rendering, so this shows once per version even if the page is // closed without dismissing. update_user_meta( $userId, self::SEEN_META, $current ); $this->render( $items, $seen, $current ); } /** * Output the modal. * * @since 5.0.0 * * @param array $items The items to show. * @param string $from The version the user was last shown. * @param string $to The version now running. * @return void */ private function render( $items, $from, $to ) { // Grouped by version so a release reads as one thing with several changes. $groups = []; foreach ( $items as $item ) { $groups[ $item['version'] ][] = $item; } $archiveUrl = aioseo()->newsroom->getArchiveUrl( 'newsroom-update-modal' ); $releases = count( $groups ); // Coming from a much older version can span dozens of releases, which turns the // modal into a scroll. Show the most recent and point at the newsroom for the rest. $hidden = 0; if ( self::MAX_RELEASES < $releases ) { $hidden = $releases - self::MAX_RELEASES; $groups = array_slice( $groups, 0, self::MAX_RELEASES, true ); } ?>