-
Notifications
You must be signed in to change notification settings - Fork 591
/
Plugin.php
47 lines (41 loc) · 1.46 KB
/
Plugin.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
<?php
/**
* 畅言评论回调插件,主要用于畅言评论后回推到 Typecho 自有评论系统<br />回推地址:http[s]://YOUR_HOST/changyan-callback
*
* @package ChangyanCallback
* @author mrgeneral
* @version 1.0.0
* @link https://www.chengxiaobai.cn
*/
class ChangyanCallback_Plugin implements Typecho_Plugin_Interface
{
public static function activate()
{
/**
* Initialization column for multilevel comments.
*
* It's wouldn't be deleted when plugin was disabled.
*/
$db = Typecho_Db::get();
$commentsTableName = $db->getPrefix() . 'comments';
$commentsColumns = $db->fetchAll($db->query("show columns from $commentsTableName"));
if (empty(array_filter($commentsColumns, function ($commentsColumn) {
return $commentsColumn['Field'] === 'cmtid';
}))) {
$db->query("ALTER TABLE `$commentsTableName` ADD `cmtid` INT(10) NOT null DEFAULT '0'");
}
Helper::addRoute('ChangyanCallback', '/changyan-callback/', 'ChangyanCallback_Action', 'action');
}
public static function deactivate()
{
Helper::removeRoute('ChangyanCallback');
}
public static function config(Typecho_Widget_Helper_Form $form)
{
// TODO: Implement config() method.
}
public static function personalConfig(Typecho_Widget_Helper_Form $form)
{
// TODO: Implement personalConfig() method.
}
}