1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: 18: 19:
20: class WxRobot_Admin_Menu_Extends{
21: 22: 23: 24: 25:
26: public function init(){
27: }
28:
29: 30: 31: 32: 33:
34: public function menu(){
35: add_submenu_page('weixin-robot',
36: 'weixin-robot',
37: '微信机器人扩展',
38: 'manage_options',
39: 'weixin-robot-extends',
40: array($this, 'weixin_robot_extends'));
41: }
42:
43: 44: 45: 46: 47:
48: public function extends_post(){
49:
50: if(isset($_GET['file']) && isset($_GET['type'])){
51: $ext_file = trim($_GET['file']);
52: $ext_type = trim($_GET['type']);
53: if('del'==$ext_type){
54: WxRobot_Table_Extends::instance()->uninstall($ext_file);
55: WxRobot_Table_Extends::instance()->delete_extends_name($ext_file);
56: wx_notice_msg('卸载成功!!!');
57: }else if(in_array($ext_type, array('all', 'subscribe', 'text', 'location', 'image', 'link', 'video','voice', 'menu'))){
58:
59: if(!WxRobot_Table_Extends::instance()->select_extends_name($ext_file)){
60: WxRobot_Table_Extends::instance()->install($ext_file);
61: WxRobot_Table_Extends::instance()->insert_extends($ext_file , $ext_type, '1');
62: wx_notice_msg('安装成功!!!');
63: }else{
64: wx_notice_msg('已经安装成功!!!');
65: }
66: }
67: }
68: }
69:
70: 71: 72: 73: 74:
75: public function weixin_robot_extends(){
76:
77: $this->extends_post();
78:
79: $list = WxRobot_Table_Extends::instance()->get_all_plugins();
80: echo '<div class="wrap"><h2>微信机器人扩展</h2>';
81:
82: $url = $_SERVER['REQUEST_URI'];
83: $r_url = str_replace(strstr($url, '&'), '', $url);
84: $thisPageUrl = 'http://'.$_SERVER['HTTP_HOST'].$r_url;
85:
86: echo '<table class="wp-list-table widefat plugins" cellspacing="0">';
87:
88: echo '<tr>';
89: echo '<th scope="col" id="name" class="manage-column column-name" style="">插件</th>';
90: echo '<th scope="col" id="description" class="manage-column column-description" style="">图像描述</th>';
91: echo '</tr>';
92:
93: if(isset($list['abspath']) && !empty($list['abspath'])){
94: foreach($list['abspath'] as $k=>$v){
95: $pinfo = $list['info'][$k];
96:
97: if(WxRobot_Table_Extends::instance()->select_extends_name($list['path'][$k])){
98: echo "<tr><td class=\"plugin-title\"><strong>{$pinfo['extend_name']}</strong>",
99: '<div class="row-actions-visible"><span class="0"><a href="',$thisPageUrl.'&file='.$list['path'][$k].'&type=del',
100: '">已启用</a></span></div></td>';
101: }else{
102: echo "<tr><td class=\"plugin-title\"><strong>{$pinfo['extend_name']}</strong>",
103: '<div class="row-actions-visible"><span class="0"><a href="',$thisPageUrl.'&file='.$list['path'][$k].'&type='.$list['type'][$k],
104: '">未启用</a></span></div></td>';
105: }
106:
107: echo '<td class="column-description desc"><div class="plugin-description"><p>',
108: $pinfo['description'],'</p></div><div class="active second plugin-version-author-uri">',
109: $pinfo['version'],'版本 | 作者为 ',
110: $pinfo['author'],' | ','事件类型:', $list['type'][$k],' | ','<a href="#" title="',
111: $list['path'][$k],'" style="color:#000;">插件地址</a> | ',
112: '联系邮箱:',$pinfo['email'],' | ',
113: '<a href="',$pinfo['extend_url'],'" title="访问插件主页" target="_blank">访问插件主页</a></div></td>';
114: echo '</tr>';
115: }
116: }
117: echo '</table></div>';
118: do_action('weixin_midoks_push');
119: }
120:
121: }
122:
123: ?>
124: