-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisqus.php
37 lines (33 loc) · 1.18 KB
/
disqus.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
<?php
function hook_disqus_render_linklist($data, $config)
{
if(isset($config)){
$disqusShortname = $config->get('plugins.DISQUS_SHORTNAME');
} else if(isset($GLOBALS['plugins']['DISQUS_SHORTNAME'])){
$disqusShortname = $GLOBALS['plugins']['DISQUS_SHORTNAME'];
}
if(count($data['links']) === 1 && !isset($_GET['page']) && !empty($disqusShortname)){
foreach ($data['links'] as $key => $link) {
if(isset($_GET[$link['shorturl']])){
// We are on the permalink page.
$data['plugin_end_zone'][] = '
<div id="disqus_thread" style="padding:10px;"></div>
<script>
var disqus_config = function () {
this.page.url = "' . $link['url'] . '";
this.page.identifier = "' . $link['shorturl'] . '";
};
(function() {
var d = document, s = d.createElement("script");
s.src = "//' . $disqusShortname . '.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
';
}
}
}
return $data;
}