-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextendedmeta.php
80 lines (68 loc) · 1.95 KB
/
extendedmeta.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* @package Joomla.Plugin
* @subpackage System.ExtendedMeta
*
* @copyright Copyright (C) 2005-2016 JoomPlace, www.joomplace.com. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Plugin to enables ability for full SEO control
*
* @since 3.6
*/
class PlgSystemExtendedMeta extends JPlugin
{
protected $title;
/**
* Load the language file on instantiation. Note this is only available in Joomla 3.1 and higher.
* If you want to support 3.0 series you must override the constructor
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
public function onContentPrepare($context, &$article, &$params, $page = 0){
// Don't run this plugin when the content is being indexed
if ($context != 'com_content.article')
{
return true;
}
$active_menu = JFactory::getApplication()->getMenu()->getActive();
if ($_SERVER['REMOTE_ADDR'] == '37.44.125.238')
{
/**
* if current menu item is menu item for current article and it has page_title set
* then it's configurations should be in priority
*/
if($active_menu->query['option']=='com_content' && $active_menu->query['view']=='article' && $active_menu->query['id']==$article->id && $active_menu->params->get('page_title','')){
return true;
}
$title = $article->metadata->get('title','');
if($title){
$this->title = $title;
}
}
}
public function onContentPrepareForm($form, $data)
{
// Check we are manipulating a valid form.
$name = $form->getName();
$app = JFactory::getApplication();
$option = $app->input->get('option');
switch ($option)
{
case 'com_content' :
JForm::addFormPath(__DIR__ . '/forms');
$form->loadFile('extratags_content', false);
return true;
}
}
public function onBeforeCompileHead(){
$doc = JFactory::getDocument();
if(isset($this->title)){
$doc->setTitle($this->title);
}
}
}