Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • WxRobot_Admin
  • WxRobot_Admin_Menu_Extends
  • WxRobot_Admin_Menu_Instro
  • WxRobot_Admin_Menu_Menu
  • WxRobot_Admin_Menu_Records
  • WxRobot_Admin_Menu_Reply
  • WxRobot_Admin_Menu_Setting
  • WxRobot_Admin_Menu_Statistics
  • WxRobot_Cmd
  • WxRobot_Cmd_Event
  • WxRobot_Cmd_Event_User
  • WxRobot_Cmd_Text
  • WxRobot_Extends
  • WxRobot_Install
  • WxRobot_Robot
  • WxRobot_SDK
  • WxRobot_Table_Extends
  • WxRobot_Table_Menu
  • WxRobot_Table_Records
  • WxRobot_Table_Reply
  • WxRobot_Uninstall
  • WxRobot_Wp
  • XMLParse

Functions

  • wx_admin_log
  • wx_is_xml
  • wx_notice_msg
  • wx_parse_xml
  • wx_random_big_pic
  • wx_random_small_pic
  • wx_request_array
  • wx_request_decode
  • wx_request_is_encode
  • wx_request_xml
  • wx_send_encode
  • Overview
  • Package
  • Class
  1: <?php
  2: /**
  3:  * WxRobot Admin
  4:  * 
  5:  * WP微信机器人后台
  6:  *
  7:  * @author      midoks
  8:  * @category    Admin
  9:  * @package     WxRobot/Admin
 10:  * @since       5.3.0
 11:  */
 12: 
 13: if ( ! defined( 'ABSPATH' ) ) {
 14:     exit;
 15: }
 16: 
 17: if( !class_exists('WxRobot_Admin') ):
 18: 
 19: /**
 20:  * WxRobot_Admin 后台控制类
 21:  */
 22: class WxRobot_Admin{
 23: 
 24:     /**
 25:      * WxRobot Admin Instance
 26:      */
 27:     public static $_instance = null;
 28:     
 29: 
 30:     /**
 31:      * WxRobot 后台类实例化
 32:      * 
 33:      * @return WxRobot Admin instance
 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:      * @return void
 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:         //add_action( 'publish_post', array($this, 'pull_new_pubish_post'));
 64:         //add_action( 'pre_post_update', array($this, 'pull_new_pubish_post'));
 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:      * @return void
 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:      * @param   string $file        加载类文件
131:      * @param   string $className 类名
132:      * @param   string $method  调用的方法
133:      * @return  void
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:      * @param   string $method  调用方法
152:      * @void
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:      * 显示文章ID选项
179:      */
180:     public function posts_columns_id($defaults){
181:         $defaults['wps_post_id'] = __('ID');
182:             return $defaults;
183:     }
184: 
185:     /**
186:      * 显示文章ID值
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: 
API documentation generated by ApiGen