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

Last change on this file since 32332 was 32332, checked in by ddtddt, 3 years ago

[add_head_element] menu only for webmaster

File size: 3.1 KB
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 by TEMMII                      |
13// +-----------------------------------------------------------------------+
14// | Copyright(C) 2011 - 2020 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 . '/');
37define('AHE_ADMIN' , get_root_url().'admin.php?page=plugin-'.AHE_DIR);
38
39add_event_handler('loading_lang', 'Add_head_element_loading_lang');       
40function Add_head_element_loading_lang(){
41  load_language('plugin.lang', AHE_PATH);
42}
43
44add_event_handler('get_admin_plugin_menu_links', 'AHE_admin_menu');
45function AHE_admin_menu($menu){
46  if (is_webmaster()){
47        load_language('plugin.lang', AHE_PATH);
48        $menu[] = array(
49          'NAME' => l10n('Add < head > element'),
50          'URL' => AHE_ADMIN,
51    );
52  }
53  return $menu;
54}
55
56
57//add in <head>
58add_event_handler('loc_begin_page_header', 'AHE1',20 );
59function AHE1(){
60  global $template,$conf;
61  if (isset($conf['add_head_element_apply_on']))
62  {
63    if (!is_array($conf['add_head_element_apply_on']))
64    {
65      $conf['add_head_element_apply_on'] = explode(',', $conf['add_head_element_apply_on']);
66    }
67
68    if (defined('IN_ADMIN') and IN_ADMIN)
69    {
70      // we are in the administration
71      if (!in_array('admin', $conf['add_head_element_apply_on']))
72      {
73        return;
74      }
75    }
76    else
77    {
78      // we are in the gallery
79      if (!in_array('gallery', $conf['add_head_element_apply_on']))
80      {
81        return;
82      }
83    }
84   
85  }
86 
87        if (!empty($conf['add_head_element']))
88        {
89    $template->append('head_elements', $conf['add_head_element']);
90        }
91}
92?>
Note: See TracBrowser for help on using the repository browser.