1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Plugin add < head > element |
---|
4 | Version: auto |
---|
5 | Description: Add element to tag < head > |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=582 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://piwigo.org/ |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | global $prefixeTable; |
---|
14 | |
---|
15 | define('AHE_DIR' , basename(dirname(__FILE__))); |
---|
16 | define('AHE_PATH' , PHPWG_PLUGINS_PATH . AHE_DIR . '/'); |
---|
17 | |
---|
18 | add_event_handler('get_admin_plugin_menu_links', 'AHE_admin_menu'); |
---|
19 | function AHE_admin_menu($menu) |
---|
20 | { |
---|
21 | array_push( |
---|
22 | $menu, |
---|
23 | array( |
---|
24 | 'NAME' => 'Add < head > element', |
---|
25 | 'URL' => get_root_url().'admin.php?page=plugin-add_head_element' |
---|
26 | ) |
---|
27 | ); |
---|
28 | |
---|
29 | return $menu; |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | //add in <head> |
---|
34 | add_event_handler('loc_begin_page_header', 'AHE1',20 ); |
---|
35 | |
---|
36 | function AHE1() |
---|
37 | { |
---|
38 | global $template,$conf; |
---|
39 | |
---|
40 | if (isset($conf['add_head_element_apply_on'])) |
---|
41 | { |
---|
42 | if (!is_array($conf['add_head_element_apply_on'])) |
---|
43 | { |
---|
44 | $conf['add_head_element_apply_on'] = explode(',', $conf['add_head_element_apply_on']); |
---|
45 | } |
---|
46 | |
---|
47 | if (defined('IN_ADMIN') and IN_ADMIN) |
---|
48 | { |
---|
49 | // we are in the administration |
---|
50 | if (!in_array('admin', $conf['add_head_element_apply_on'])) |
---|
51 | { |
---|
52 | return; |
---|
53 | } |
---|
54 | } |
---|
55 | else |
---|
56 | { |
---|
57 | // we are in the gallery |
---|
58 | if (!in_array('gallery', $conf['add_head_element_apply_on'])) |
---|
59 | { |
---|
60 | return; |
---|
61 | } |
---|
62 | } |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | if (!empty($conf['add_head_element'])) |
---|
67 | { |
---|
68 | $template->append('head_elements', $conf['add_head_element']); |
---|
69 | } |
---|
70 | } |
---|
71 | ?> |
---|