-
Notifications
You must be signed in to change notification settings - Fork 38
/
wp-weixin.php
87 lines (73 loc) · 3.19 KB
/
wp-weixin.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
Plugin Name: WP Weixin
Plugin URI: https://github.com/froger-me/wp-weixin
Description: WordPress WeChat integration
Version: 1.3.16
Author: Alexandre Froger
Author URI: https://froger.me
Text Domain: wp-weixin
Domain Path: /languages
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! defined( 'WP_WEIXIN_PLUGIN_FILE' ) ) {
define( 'WP_WEIXIN_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'WP_WEIXIN_PLUGIN_PATH' ) ) {
define( 'WP_WEIXIN_PLUGIN_PATH', plugin_dir_path( WP_WEIXIN_PLUGIN_FILE ) );
}
if ( ! defined( 'WP_WEIXIN_PLUGIN_URL' ) ) {
define( 'WP_WEIXIN_PLUGIN_URL', plugin_dir_url( WP_WEIXIN_PLUGIN_FILE ) );
}
if ( ! defined( 'WP_WEIXIN_API_DISABLED' ) ) {
define( 'WP_WEIXIN_API_DISABLED', false );
}
if ( ! defined( 'WP_WEIXIN_ALLOW_DESKTOP' ) ) {
define( 'WP_WEIXIN_ALLOW_DESKTOP', false );
}
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin.php';
register_activation_hook( WP_WEIXIN_PLUGIN_FILE, array( 'WP_Weixin', 'activate' ) );
register_deactivation_hook( WP_WEIXIN_PLUGIN_FILE, array( 'WP_Weixin', 'deactivate' ) );
register_uninstall_hook( WP_WEIXIN_PLUGIN_FILE, array( 'WP_Weixin', 'uninstall' ) );
function wp_weixin_run() {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-settings.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-wechat.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-wechat-singleton.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'lib/wechat-sdk/wechat-sdk.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'functions.php';
if ( ! class_exists( 'QRcode' ) ) {
require_once WP_WEIXIN_PLUGIN_PATH . '/lib/phpqrcode/phpqrcode.php';
}
$wp_weixin_settings = new WP_Weixin_Settings( true );
if ( WP_Weixin_Settings::get_option( 'enabled' ) ) {
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-walker-nav-menu-wechat-edit.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-menu.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-responder.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-auth.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-bind.php';
require_once WP_WEIXIN_PLUGIN_PATH . 'inc/class-wp-weixin-metabox.php';
$wechat = WP_Weixin_Wechat_Singleton::get_wechat();
$use_responder = WP_Weixin_Settings::get_option( 'responder' );
$use_ecommerce = WP_Weixin_Settings::get_option( 'ecommerce' );
$use_auth = WP_Weixin_Settings::get_option( 'enable_auth' );
$wp_weixin_auth = new WP_Weixin_Auth( $wechat, true );
$wp_weixin_responder = ( $use_responder ) ? new WP_Weixin_Responder( $wechat, true ) : false;
$wp_weixin_menu = ( $use_responder ) ? new WP_Weixin_Menu( $wechat, true ) : false;
$wp_weixin_metabox = new WP_Weixin_Metabox( $wechat, true );
$wp_weixin_bind = ( $use_auth ) ? new WP_Weixin_Bind( $wechat, $wp_weixin_auth, true ) : false;
$wp_weixin = new WP_Weixin( $wechat, true );
do_action(
'wp_weixin_extensions',
$wechat,
$wp_weixin_settings,
$wp_weixin,
$wp_weixin_auth,
$wp_weixin_responder,
$wp_weixin_menu
);
}
}
add_action( 'plugins_loaded', 'wp_weixin_run', 6, 0 );