Skip to content

Commit

Permalink
Add new head html hook
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalkerl committed Feb 20, 2024
1 parent 3a88df0 commit dae755a
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
39 changes: 39 additions & 0 deletions classes/local/hooks/output/standard_head_html_prepend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_webanalytics\local\hooks\output;

use tool_webanalytics\injector;

/**
* Allows plugins to add any elements to the page <head> html tag
*
* @package tool_webanalytics
* @author Benjamin Walker ([email protected])
* @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());
}
}
34 changes: 34 additions & 0 deletions db/hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Hook callbacks for Webanalytics
*
* @package tool_webanalytics
* @author Benjamin Walker ([email protected])
* @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,
],
];
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2021122300; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024022000; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2021122300; // Same as version.
$plugin->requires = 2022112800; // Requires Moodle 4.1 or later.
$plugin->component = "tool_webanalytics";
Expand Down

0 comments on commit dae755a

Please sign in to comment.