[12496] | 1 | <?php |
---|
| 2 | /* |
---|
[31463] | 3 | Plugin Name: Add < head > element |
---|
[12496] | 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 |
---|
[31463] | 8 | Author URI: http://temmii.com/piwigo/ |
---|
[12496] | 9 | */ |
---|
| 10 | |
---|
[31463] | 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 | |
---|
[12496] | 31 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 32 | |
---|
| 33 | global $prefixeTable; |
---|
| 34 | |
---|
| 35 | define('AHE_DIR' , basename(dirname(__FILE__))); |
---|
| 36 | define('AHE_PATH' , PHPWG_PLUGINS_PATH . AHE_DIR . '/'); |
---|
| 37 | |
---|
[31463] | 38 | add_event_handler('loading_lang', 'Add_head_element_loading_lang'); |
---|
| 39 | function Add_head_element_loading_lang(){ |
---|
| 40 | load_language('plugin.lang', AHE_PATH); |
---|
| 41 | } |
---|
| 42 | |
---|
[12496] | 43 | add_event_handler('get_admin_plugin_menu_links', 'AHE_admin_menu'); |
---|
| 44 | function AHE_admin_menu($menu) |
---|
| 45 | { |
---|
[23583] | 46 | array_push( |
---|
| 47 | $menu, |
---|
| 48 | array( |
---|
[31463] | 49 | 'NAME' => l10n('Add < head > element'), |
---|
[23583] | 50 | 'URL' => get_root_url().'admin.php?page=plugin-add_head_element' |
---|
| 51 | ) |
---|
| 52 | ); |
---|
| 53 | |
---|
[12496] | 54 | return $menu; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | //add in <head> |
---|
| 59 | add_event_handler('loc_begin_page_header', 'AHE1',20 ); |
---|
| 60 | |
---|
| 61 | function AHE1() |
---|
| 62 | { |
---|
[23583] | 63 | global $template,$conf; |
---|
[12496] | 64 | |
---|
[23583] | 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 | } |
---|
[12496] | 71 | |
---|
[23583] | 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 | |
---|
[14969] | 91 | if (!empty($conf['add_head_element'])) |
---|
[12496] | 92 | { |
---|
[14969] | 93 | $template->append('head_elements', $conf['add_head_element']); |
---|
[12496] | 94 | } |
---|
[23583] | 95 | } |
---|
[12496] | 96 | ?> |
---|