source: extensions/add_head_element/main.inc.php

Last change on this file was 32645, checked in by ddtddt, 2 years ago

[add_head_element] check for piwigo 12

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