forked from nystudio107/seomatic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeomaticPlugin.php
More file actions
executable file
·133 lines (108 loc) · 4.64 KB
/
SeomaticPlugin.php
File metadata and controls
executable file
·133 lines (108 loc) · 4.64 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
namespace Craft;
class SeomaticPlugin extends BasePlugin
{
public function getName()
{
return Craft::t('SEOmatic');
}
public function getDescription()
{
return 'A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, and flexible.';
}
public function getDocumentationUrl()
{
return 'https://github.com/khalwat/seomatic/blob/master/README.md';
}
public function getReleaseFeedUrl()
{
return 'https://raw.githubusercontent.com/khalwat/seomatic/master/releases.json';
}
public function getVersion()
{
return '1.1.9';
}
public function getSchemaVersion()
{
return '1.1.5';
}
public function getDeveloper()
{
return 'nystudio107';
}
public function getDeveloperUrl()
{
return 'http://nystudio107.com';
}
public function hasCpSection()
{
return true;
}
public function init()
{
require_once __DIR__ . '/vendor/autoload.php';
craft()->templates->hook('seomaticRender', function(&$context)
{
if ((craft()->request->isSiteRequest()) && (isset($context['seomaticMeta'])))
{
$locale = craft()->language;
$seomaticMeta = $context['seomaticMeta'];
$seomaticSiteMeta = $context['seomaticSiteMeta'];
$seomaticIdentity = $context['seomaticIdentity'];
$seomaticSocial = $context['seomaticSocial'];
$seomaticCreator = $context['seomaticCreator'];
$seomaticHelper = $context['seomaticHelper'];
/* -- We want to pass an up-to-date variable context to the template, so pass everything on in */
$result="";
$metaVars = array(
'seomaticMeta' => $seomaticMeta,
'seomaticSiteMeta' => $seomaticSiteMeta,
'seomaticIdentity' => $seomaticIdentity,
'seomaticSocial' => $seomaticSocial,
'seomaticCreator' => $seomaticCreator,
'seomaticHelper' => $seomaticHelper,
);
/* -- Render the seomaticMeta, this is where the magic happens */
$seomaticTemplatePath = '';
if (isset($context['seomaticTemplatePath']))
$seomaticTemplatePath = $context['seomaticTemplatePath'];
$result = craft()->seomatic->renderSiteMeta($seomaticTemplatePath, $metaVars, $locale);
return $result;
}
});
}
public function addTwigExtension()
{
Craft::import('plugins.seomatic.twigextensions.SeomaticTwigExtension');
return new SeomaticTwigExtension();
}
public function registerSiteRoutes()
{
return array(
'humans.txt' => array('action' => 'seomatic/renderHumans'),
'robots.txt' => array('action' => 'seomatic/renderRobots'),
);
}
public function registerCpRoutes()
{
return array(
'seomatic/site' => array('action' => 'seomatic/editSiteMeta'),
'seomatic/site/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editSiteMeta'),
'seomatic/identity' => array('action' => 'seomatic/editIdentity'),
'seomatic/identity/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editIdentity'),
'seomatic/social' => array('action' => 'seomatic/editSocial'),
'seomatic/social/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editSocial'),
'seomatic/creator' => array('action' => 'seomatic/editCreator'),
'seomatic/creator/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editCreator'),
'seomatic/meta/new' => array('action' => 'seomatic/editMeta'),
'seomatic/meta/new/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editMeta'),
'seomatic/meta/(?P<metaId>\d+)' => array('action' => 'seomatic/editMeta'),
'seomatic/meta/(?P<metaId>\d+)/(?P<locale>[-\w\.*]+)' => array('action' => 'seomatic/editMeta'),
);
}
public function onAfterInstall()
{
/* -- Show our "Welcome to SEOmatic" message */
craft()->request->redirect(UrlHelper::getCpUrl('seomatic/welcome'));
}
} /* -- class SeomaticPlugin */