get_results( "SELECT id, title, icon, congratulations_message as congrats, restriction_message, required_achievement_id, required_level_id, 'level' as type, priority, unlock_with_points_enabled, point_type_id, min_points FROM {$wpdb->prefix}gameengine_levels ORDER BY priority ASC", ARRAY_A ); // Fetch all Achievements. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $achievements = $wpdb->get_results( "SELECT id, title, badge_image as icon, congratulations_message as congrats, restriction_message, required_achievement_id, required_level_id, 'achievement' as type, created_at, unlock_with_points_enabled, required_point_type_id as point_type_id, required_points_amount as min_points FROM {$wpdb->prefix}gameengine_achievements ORDER BY created_at ASC", ARRAY_A ); // Fetch user earned levels. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $user_levels = $wpdb->get_col( $wpdb->prepare( "SELECT level_id FROM {$wpdb->prefix}gameengine_user_levels WHERE user_id = %d", $user_id ) ); // Fetch user earned achievements. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $user_achievements = $wpdb->get_col( $wpdb->prepare( "SELECT achievement_id FROM {$wpdb->prefix}gameengine_user_achievements WHERE user_id = %d", $user_id ) ); // Merge and process status. $journey = array_merge($levels ? $levels : array(), $achievements ? $achievements : array()); $unlocked = array(); $locked = array(); if (! empty($journey)) { foreach ($journey as $item) { $is_completed = ('level' === $item['type']) ? in_array($item['id'], (array)$user_levels) : in_array($item['id'], (array)$user_achievements); $item['status'] = $is_completed ? 'completed' : 'locked'; if ($is_completed) { $unlocked[] = $item; } else { $locked[] = $item; } } } return array_merge($unlocked, $locked); } /** * Renders the Roadmap HTML. * * Reached steps come first, then the locked ones in order. The next few * locked steps stay in view and the rest fold into a
, so a long * journey doesn't push the rest of the page down. * * @param int $user_id The User ID. * @return string HTML output. */ public static function render_html($user_id) { $gameengine_journey = self::get_combined_journey($user_id); ob_start(); if (empty($gameengine_journey)) { ?>

'completed'))); $gameengine_percent = (int) round(($gameengine_reached / $gameengine_total) * 100); /** * Filters how many locked steps show before the rest fold away. * * @param int $count Locked steps to show. Default 3. */ $gameengine_visible = $gameengine_reached + max(0, (int) apply_filters('gameengine_progress_map_visible_locked', 3)); // Folding away one or two steps saves nothing, so show them. if ($gameengine_total - $gameengine_visible <= 2) { $gameengine_visible = $gameengine_total; } $gameengine_shown = array_slice($gameengine_journey, 0, $gameengine_visible); $gameengine_folded = array_slice($gameengine_journey, $gameengine_visible); ?>

' . esc_html(number_format_i18n($gameengine_reached)) . '', esc_html(number_format_i18n($gameengine_total)) ); ?>

$gameengine_node) : $gameengine_is_completed = ('completed' === $gameengine_node['status']); $gameengine_is_level = ('level' === $gameengine_node['type']); $gameengine_node_icon = (string) ($gameengine_node['icon'] ?? ''); ?>
  • 0) { return sprintf( /* translators: 1: points needed, 2: what the points are called, e.g. "Community Points" */ __('Collect %1$s %2$s to unlock.', 'gameengine'), number_format_i18n($points), \GameEngine\Classes\PointsManager::get_point_type_label((int) ($node['point_type_id'] ?? 0)) ); } return __('Complete pre-requisites to unlock.', 'gameengine'); } }