diff --git a/classes/local/hooks/output/standard_head_html_prepend.php b/classes/local/hooks/output/standard_head_html_prepend.php new file mode 100644 index 0000000..35d8df4 --- /dev/null +++ b/classes/local/hooks/output/standard_head_html_prepend.php @@ -0,0 +1,39 @@ +. + +namespace tool_webanalytics\local\hooks\output; + +use tool_webanalytics\injector; + +/** + * Allows plugins to add any elements to the page html tag + * + * @package tool_webanalytics + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class standard_head_html_prepend { + + /** + * Render tracking code. + * + * @param \core\hook\output\standard_head_html_prepend $hook + */ + public static function callback(\core\hook\output\standard_head_html_prepend $hook): void { + $hook->add_html(injector::render_tracking_code()); + } +} diff --git a/db/hooks.php b/db/hooks.php new file mode 100644 index 0000000..9febc41 --- /dev/null +++ b/db/hooks.php @@ -0,0 +1,34 @@ +. + +/** + * Hook callbacks for Webanalytics + * + * @package tool_webanalytics + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$callbacks = [ + [ + 'hook' => core\hook\output\standard_head_html_prepend::class, + 'callback' => 'tool_webanalytics\local\hooks\output\standard_head_html_prepend::callback', + 'priority' => 0, + ], +]; diff --git a/version.php b/version.php index c294ec9..612b410 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2021122300; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2021122300; // Same as version. +$plugin->version = 2024022000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024022000; // Same as version. $plugin->requires = 2022112800; // Requires Moodle 4.1 or later. $plugin->component = "tool_webanalytics"; $plugin->supported = [401, 403]; // Available as of Moodle 4.1.0 or later.