Completed
Push — master ( 0751da...d9d684 )
by Mark
02:14
created

action_plugin_webmaster::addVerifyHeaders()   B

Complexity

Conditions 6
Paths 9

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 26
rs 8.439
cc 6
eloc 15
nc 9
nop 2
1
<?php
2
/**
3
 * Webmaster Tools plugin.
4
 *
5
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6
 * @author     Mark C. Prins <[email protected]>
7
 * @author     Marius Rieder <[email protected]>
8
 */
9
10
if (!defined('DOKU_INC')) {
11
    die();
12
}
13
if (!defined('DOKU_PLUGIN')) {
14
    define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
15
}
16
require_once(DOKU_PLUGIN.'action.php');
17
18
class action_plugin_webmaster extends DokuWiki_Action_Plugin {
19
20
    function register(Doku_Event_Handler $controller) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'addVerifyHeaders', array());
22
    }   
23
24
    function addVerifyHeaders(&$event, $param) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
25
        if (empty($event->data)||empty($event->data['meta'])) {
26
            return;
27
        }
28
29
        /* Google */
30
        $g = $this->getConf('webmaster_google');
31
        if (!empty($g)) {
32
            $g = array('name' => 'google-site-verification', 'content' => $g);
33
            $event->data['meta'][] = $g;
34
        }
35
36
        /* bing */
37
        $b = $this->getConf('webmaster_bing');
38
        if (!empty($b)) {
39
            $b = array('name' => 'msvalidate.01', 'content' => $b);
40
            $event->data['meta'][] = $b;
41
        }
42
43
        /* Yandex */
44
        $y = $this->getConf('webmaster_yandexkey');
45
        if (!empty($y)) {
46
            $y = array('name' => 'yandex-verification', 'content' => $y); 
47
            $event->data['meta'][] = $y;
48
        }
49
    }
50
}
51