helper()->acadlix_get_option('acadlix_dashboard_page_id'); if (!$dashboard_page_id) { return; } // get_page_uri securely handles both top-level pages and child pages (e.g., parent/dashboard) $dashboard_slug = get_page_uri($dashboard_page_id); if (empty($dashboard_slug)) { return; } $new_rules = [ '^' . $dashboard_slug . '/reset-password/?$' => 'index.php?pagename=' . $dashboard_slug . '&is_lms_reset_password=1', ]; // Prepend the new rules to the top of the existing rules array $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } public function is_dashboard_page() { $dashboard_page_id = acadlix()->helper()->acadlix_get_option('acadlix_dashboard_page_id'); return $dashboard_page_id && is_page($dashboard_page_id); } public function template_loader($template) { if ($this->is_dashboard_page()) { // !defined('DONOTCACHEPAGE') && define('DONOTCACHEPAGE', true); // phpcs:ignore // Prevent caching for the dashboard page // ALLOW caching for the iframe so React can load it quickly from disk cache if remounted if (!empty($_GET['acadlix_iframe'])) { // Cache privately for the logged-in user for 1 hour (3600 seconds) // header('Cache-Control: private, max-age=3600'); return acadlix()->view()->dashboardIframe()->render(); } header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); header('Pragma: no-cache'); header('Expires: 0'); $dashboard_template = ACADLIX_INCLUDES_PATH . 'Common/View/DashboardView.php'; if ($dashboard_template) { return $dashboard_template; } } return $template; } public function disable_admin_bar_on_dashboard($show_admin_bar) { if ($this->is_dashboard_page()) { return false; } return $show_admin_bar; } public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; } } }