1<?php 2/** 3 * DokuWiki plugin for Hubspot 4 * 5 * Hook into application -> executed after header metadata was rendered 6 * 7 * @license GPLv3 (http://www.gnu.org/licenses/gpl.html) 8 * @author Pieter van Os (info@pkservices.nl) 9 */ 10 11if (!defined('DOKU_INC')) { 12 die(); 13} 14if (!defined('DOKU_PLUGIN')) { 15 define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); 16} 17require_once DOKU_PLUGIN . 'action.php'; 18require_once DOKU_PLUGIN . 'hubspot/code.php'; 19 20class action_plugin_hubspot extends DokuWiki_Action_Plugin 21{ 22 function register(Doku_Event_Handler $controller) 23 { 24 // TPL_METAHEADER_OUTPUT AFTER to place it before the </head> 25 $controller->register_hook( 26 'TPL_METAHEADER_OUTPUT', 'AFTER', $this, '_hook_header' 27 ); 28 } 29 30 function _hook_header(Doku_Event $event, $param) 31 { 32 $data = hubspot_tracking(); 33 $event->data['script'][] = array( 34 'type' => 'text/javascript', 35 'charset' => 'utf-8', 36 '_data' => $data, 37 ); 38 } 39} 40