diff --git a/admin/tool/usertours/classes/helper.php b/admin/tool/usertours/classes/helper.php index ee0eb52d766..da8a9410dfb 100644 --- a/admin/tool/usertours/classes/helper.php +++ b/admin/tool/usertours/classes/helper.php @@ -44,6 +44,11 @@ class helper { */ const MOVE_DOWN = 1; + /** + * @var boolean Has it been bootstrapped? + */ + private static $bootstrapped = false; + /** * Get the link to edit the step. * @@ -488,6 +493,11 @@ class helper { public static function bootstrap() { global $PAGE; + if (self::$bootstrapped) { + return; + } + self::$bootstrapped = true; + if ($tour = manager::get_current_tour()) { $PAGE->requires->js_call_amd('tool_usertours/usertours', 'init', [ $tour->get_id(), diff --git a/admin/tool/usertours/lib.php b/admin/tool/usertours/lib.php index 476dd093847..086fdb41619 100644 --- a/admin/tool/usertours/lib.php +++ b/admin/tool/usertours/lib.php @@ -67,3 +67,11 @@ function tool_usertours_inplace_editable($itemtype, $itemid, $newvalue) { function tool_usertours_extend_navigation_user() { \tool_usertours\helper::bootstrap(); } + +/** + * Add JS to bootstrap tours. Only in Moodle 3.3+ + */ +function tool_usertours_before_footer() { + \tool_usertours\helper::bootstrap(); +} +