-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatest-tweets.php
51 lines (47 loc) · 1.91 KB
/
latest-tweets.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
<?php
namespace Grav\Plugin;
use Grav\Common\Plugin;
class LatestTweetsPlugin extends Plugin
{
public static function getSubscribedEvents()
{
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onTwigSiteVariables' => ['onTwigSiteVariables', 0],
];
}
public function onPluginsInitialized()
{
require_once __DIR__ . '/tweets.php';
$this->grav['twig']->twig_vars['latesttweets'] = display_latest_tweets(
$this->config->get('plugins.latest-tweets.twitter_id'),
$this->config->get('plugins.latest-tweets.consumerkey'),
$this->config->get('plugins.latest-tweets.consumersecret'),
$this->config->get('plugins.latest-tweets.accesstoken'),
$this->config->get('plugins.latest-tweets.accesstokensecret'),
$this->config->get('plugins.latest-tweets.tweets_to_display'),
$this->config->get('plugins.latest-tweets.ignore_replies'),
$this->config->get('plugins.latest-tweets.include_rts')
);
}
public function onTwigTemplatePaths()
{
$this->grav['twig']->twig_paths[] = __DIR__ . '/templates';
}
public function onTwigSiteVariables()
{
//Pass a reference to plugin config
$this->grav['twig']->twig_vars['ltconfig'] = $this->config->get('plugins.latest-tweets');
if ($this->config->get('plugins.latest-tweets.built_in_css')) {
$this->grav['assets']
->add('plugin://latest-tweets/assets/css/latest-tweets.css');
}
if ($this->config->get('plugins.latest-tweets.fontawesome')) {
$this->grav['assets']
->add('https://use.fontawesome.com/releases/v5.0.13/css/all.css');
}
$this->grav['assets']
->add('https://platform.twitter.com/widgets.js');
}
}