source: extensions/add_head_element/main.inc.php @ 25535

Last change on this file since 25535 was 23583, checked in by plg, 11 years ago

ability to say if elements must be added on gallery, or admin, or both

File size: 1.5 KB
Line 
1<?php
2/*
3Plugin Name: Plugin add < head > element
4Version: auto
5Description: Add element to tag < head >
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=582
7Author: ddtddt
8Author URI: http://piwigo.org/
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13global $prefixeTable;
14
15define('AHE_DIR' , basename(dirname(__FILE__)));
16define('AHE_PATH' , PHPWG_PLUGINS_PATH . AHE_DIR . '/');
17
18add_event_handler('get_admin_plugin_menu_links', 'AHE_admin_menu');
19function 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>
34add_event_handler('loc_begin_page_header', 'AHE1',20 );
35
36function 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?>
Note: See TracBrowser for help on using the repository browser.