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

Revision 31463, 3.0 KB checked in by ddtddt, 4 years ago (diff)

[extensions] - add_head_element - 2.8

Line 
1<?php
2/*
3Plugin Name: 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://temmii.com/piwigo/
9*/
10
11// +-----------------------------------------------------------------------+
12// | Add < head > element plugin for piwigo                            |
13// +-----------------------------------------------------------------------+
14// | Copyright(C) 2011 - 2016 ddtddt             http://temmii.com/piwigo/ |
15// +-----------------------------------------------------------------------+
16// | This program is free software; you can redistribute it and/or modify  |
17// | it under the terms of the GNU General Public License as published by  |
18// | the Free Software Foundation                                          |
19// |                                                                       |
20// | This program is distributed in the hope that it will be useful, but   |
21// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
22// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
23// | General Public License for more details.                              |
24// |                                                                       |
25// | You should have received a copy of the GNU General Public License     |
26// | along with this program; if not, write to the Free Software           |
27// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
28// | USA.                                                                  |
29// +-----------------------------------------------------------------------+
30
31if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
32
33global $prefixeTable;
34
35define('AHE_DIR' , basename(dirname(__FILE__)));
36define('AHE_PATH' , PHPWG_PLUGINS_PATH . AHE_DIR . '/');
37
38add_event_handler('loading_lang', 'Add_head_element_loading_lang');       
39function Add_head_element_loading_lang(){
40  load_language('plugin.lang', AHE_PATH);
41}
42
43add_event_handler('get_admin_plugin_menu_links', 'AHE_admin_menu');
44function AHE_admin_menu($menu)
45{
46  array_push(
47    $menu,
48    array(
49      'NAME' => l10n('Add < head > element'),
50      'URL' => get_root_url().'admin.php?page=plugin-add_head_element'
51      )
52    );
53 
54  return $menu;
55}
56
57
58//add in <head>
59add_event_handler('loc_begin_page_header', 'AHE1',20 );
60
61function AHE1()
62{
63  global $template,$conf;
64
65  if (isset($conf['add_head_element_apply_on']))
66  {
67    if (!is_array($conf['add_head_element_apply_on']))
68    {
69      $conf['add_head_element_apply_on'] = explode(',', $conf['add_head_element_apply_on']);
70    }
71
72    if (defined('IN_ADMIN') and IN_ADMIN)
73    {
74      // we are in the administration
75      if (!in_array('admin', $conf['add_head_element_apply_on']))
76      {
77        return;
78      }
79    }
80    else
81    {
82      // we are in the gallery
83      if (!in_array('gallery', $conf['add_head_element_apply_on']))
84      {
85        return;
86      }
87    }
88   
89  }
90 
91        if (!empty($conf['add_head_element']))
92        {
93    $template->append('head_elements', $conf['add_head_element']);
94        }
95}
96?>
Note: See TracBrowser for help on using the repository browser.