1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: if( !class_exists('WxRobot_Admin') ):
18:
19: 20: 21:
22: class WxRobot_Admin{
23:
24: 25: 26:
27: public static $_instance = null;
28:
29:
30: 31: 32: 33: 34:
35: public static function instance(){
36: if( is_null (self::$_instance)){
37: self::$_instance = new self();
38: }
39: return self::$_instance;
40: }
41:
42: 43: 44: 45: 46:
47: public function __construct(){
48:
49: include_once('class-wx-menu-functions.php');
50:
51: add_filter( 'plugin_action_links', array($this, 'weixin_robot_action_links'), 10, 2);
52: add_filter( 'plugin_row_meta', array($this, 'weixin_robot_row_meta'), 10, 2 );
53: add_action( "current_screen", array( $this, 'add_tabs' ), 50 );
54:
55: add_action( 'admin_menu', array($this, 'weixin_robot_menu'), 1);
56: add_action( 'admin_footer', array(&$this, 'weixin_robot_footer'));
57:
58: add_filter( 'manage_posts_columns', array($this, 'posts_columns_id'), 1);
59: add_action( 'manage_posts_custom_column', array($this, 'posts_custom_id_columns'), 1, 2);
60: add_filter( 'manage_pages_columns', array($this, 'posts_columns_id'), 1);
61: add_action( 'manage_pages_custom_column', array($this,'posts_custom_id_columns'), 1, 2);
62:
63:
64:
65: add_action( 'weixin_midoks_push', array($this, 'weixin_midoks_push'));
66:
67: $this->weixin_menu_cache('init');
68:
69: add_action( 'admin_menu', array($this, 'wx_extends_admin'), 3);
70:
71: }
72:
73: 74: 75: 76: 77:
78: public function wx_extends_admin(){
79: $list = WxRobot_Table_Extends::instance()->select_extends();
80: if(!empty($list)){
81: foreach($list as $k=>$v){
82: WxRobot_Extends::instance()->admin($v['ext_cn']);
83: }
84: }
85: }
86:
87: 88: 89:
90: public function weixin_robot_row_meta($input, $file){
91: $file_arr = explode('/', $file);
92: if('wp-weixin-robot' == $file_arr[0]){
93: array_push($input, '<a href="'.WEIXIN_ROBOT_DOCUMENT.'" target="_blank">API文档</a>');
94: array_push($input, '<a href="https://wordpress.org/plugins/wp-weixin-robot/developers/" target="_blank">代码版本</a>');
95: }
96: return $input;
97: }
98:
99: 100: 101:
102: public function weixin_robot_action_links($links, $file){
103: if ( basename($file) != basename(plugin_basename(WEIXIN_ROBOT_POS))){
104: return $links;
105: }
106: $settings_link = '<a href="admin.php?page=weixin-robot-setting">设置</a>';
107: array_unshift($links, $settings_link);
108: return $links;
109: }
110:
111:
112: 113: 114:
115: public function add_tabs(){
116: $screen = get_current_screen();
117: $screen->add_help_tab( array(
118: 'id' => 'wxrobot_support_tab',
119: 'title' => 'API支持',
120: 'content' =>
121: '<h2>感谢</h2>' .
122: '<p>非常感谢你使用WP微信机器人,这次更新,主要是进行了代码处理。让代码更加易读</p>' .
123: '<p>文档地址:<a href="'.WEIXIN_ROBOT_DOCUMENT.'" target="_blank">'.WEIXIN_ROBOT_DOCUMENT.'</a></p>'
124: ) );
125: }
126:
127: 128: 129: 130: 131: 132: 133: 134:
135: private function weixin_class_cache($file, $className, $method = ''){
136: static $_instance = array();
137: $md5_name = md5($file);
138: if(!isset($_instance[$md5_name])){
139: include_once($file);
140: $_instance[$md5_name] = new $className();
141: }
142:
143: if( !empty($method) && method_exists($_instance[$md5_name], $method)){
144: $_instance[$md5_name]->$method();
145: }
146: }
147:
148: 149: 150: 151: 152: 153:
154: private function weixin_menu_cache($method = ''){
155:
156: $options = get_option(WEIXIN_ROBOT_OPTIONS);
157:
158: $this->weixin_class_cache('class-wx-menu-instro.php', 'WxRobot_Admin_Menu_Instro', $method);
159: $this->weixin_class_cache('class-wx-menu-setting.php', 'WxRobot_Admin_Menu_Setting', $method);
160: $this->weixin_class_cache('class-wx-menu-records.php', 'WxRobot_Admin_Menu_Records', $method);
161: $this->weixin_class_cache('class-wx-menu-reply.php', 'WxRobot_Admin_Menu_Reply', $method);
162: $this->weixin_class_cache('class-wx-menu-statistics.php', 'WxRobot_Admin_Menu_Statistics', $method);
163:
164: if(!empty($options['ai']) && !empty($options['as'])){
165: $this->weixin_class_cache('class-wx-menu-menu.php', 'WxRobot_Admin_Menu_Menu', $method);
166: }
167: $this->weixin_class_cache('class-wx-menu-extends.php', 'WxRobot_Admin_Menu_Extends', $method);
168: }
169:
170: 171: 172:
173: public function weixin_robot_menu(){
174: $this->weixin_menu_cache('menu');
175: }
176:
177: 178: 179:
180: public function posts_columns_id($defaults){
181: $defaults['wps_post_id'] = __('ID');
182: return $defaults;
183: }
184:
185: 186: 187:
188: public function posts_custom_id_columns($column_name, $id){
189: if($column_name === 'wps_post_id'){
190: echo $id;
191: }
192: }
193:
194: 195: 196:
197: public function pull_update_pubish_post($id){
198: }
199:
200: 201: 202:
203: public function pull_new_pubish_post($id){
204: $t['time'] = time();
205: $t['id'] = $id;
206: $this->options['weixin_robot_push_today'] = json_encode($t);
207: update_option('weixin_robot_options', $this->options);
208: }
209:
210: 211: 212:
213: public function weixin_midoks_push(){
214: ?>
215: <hr />
216: <p>请关注我的博客:<a href="http://midoks.cachecha.com/" target="_blank">midoks.cachecha.com</a></p>
217: <p><img src="<?php echo WEIXIN_ROBOT_URL; ?>/assets/img/mini_alipay.png" title="支付宝扫描,即可为我捐助。" alt="支付宝扫描,即可为我捐助。"></p>
218: <p>能为你服务,我感到无限的兴奋</p><?php
219: }
220:
221: 222: 223:
224: public function weixin_robot_footer(){
225: echo '<script language="javascript" type="text/javascript" src="http://js.users.51.la/16589822.js"></script>';
226: $t = <<<EOT
227: var h51Time=window.setInterval(hidden51la,100);function hidden51la(){var t={a:'ajiang',a2:'51.la'};for(i=0;i<document.getElementsByTagName("a").length;i++){var temObj=document.getElementsByTagName("a")[i];if(temObj.href.indexOf(t.a)>=0){temObj.style.display="none"}if(temObj.href.indexOf(t.a2)>=0){temObj.style.display="none";clearInterval(h51Time)}}}
228: EOT;
229: echo '<script> '.$t.' </script>';
230: }
231:
232: }
233:
234: endif;
235:
236: return WxRobot_Admin::instance();
237:
238:
239:
240: ?>
241: