-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwp-discord-post.php
158 lines (135 loc) · 3.89 KB
/
wp-discord-post.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
/**
* WP Discord Post
*
* @author Nicola Mustone
* @license GPL-2.0+
*
* Plugin Name: WP Discord Post
* Plugin URI: https://wordpress.org/plugins/wp-discord-post/
* Description: A Discord integration that sends a message on your desired Discord server and channel for every new post published.
* Version: 2.1.0
* Author: Nicola Mustone
* Author URI: https://nicola.blog/
* Text Domain: wp-discord-post
*
* WC tested up to: 3.4.4
*
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Main class of the plugin WP Discord Post. Handles the bot and the admin settings.
*/
class WP_Discord_Post {
/**
* The single instance of the class.
*
* @var WP_Discord_Post
*/
protected static $_instance = null;
/**
* The instance of WP_Discord_Post_Post.
*
* @var WP_Discord_Post_Post
*/
public $post = null;
/**
* The instance of WP_Discord_Post_CF7.
*
* @var WP_Discord_Post_CF7
*/
public $cf7 = null;
/**
* The instance of WP_Discord_Post_GF.
*
* @var WP_Discord_Post_GF
*/
public $gf = null;
/**
* The instance of WP_Discord_Post_Jetpack_CF.
*
* @var WP_Discord_Post_Jetpack_CF
*/
public $jetpack_cf = null;
/**
* The instance of WP_Discord_Post_WooCommerce.
*
* @var WP_Discord_Post_WooCommerce
*/
public $woocommerce = null;
/**
* The instance of WP_Discord_Post_ACF.
*
* @var WP_Discord_Post_ACF
*/
public $acf = null;
/**
* Main WP_Discord_Post Instance.
*
* Ensures only one instance of WP_Discord_Post is loaded or can be loaded.
*
* @static
* @return WP_Discord_Post - Main instance.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Cloning is forbidden.
*/
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wp-discord-post' ), '1.0.9' );
}
/**
* Unserializing instances of this class is forbidden.
*/
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wp-discord-post' ), '1.0.9' );
}
/**
* Adds the required hooks.
*/
public function __construct() {
require_once( 'includes/functions-general.php' );
require_once( 'includes/class-wp-discord-post-admin.php' );
require_once( 'includes/class-wp-discord-post-http.php' );
require_once( 'includes/class-wp-discord-post-formatting.php' );
if ( is_admin() ) {
require_once( 'includes/class-wp-discord-post-dank-meme.php' );
}
$this->post = require_once( 'includes/class-wp-discord-post-post.php' );
if ( 'yes' === get_option( 'wp_discord_enabled_for_cf7' ) && class_exists( 'WPCF7' ) ) {
$this->cf7 = include_once( 'includes/class-wp-discord-post-cf7.php' );
}
if ( 'yes' === get_option( 'wp_discord_enabled_for_jetpack_cf' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'contact-form' ) ) {
$this->jetpack_cf = include_once( 'includes/class-wp-discord-post-jetpack-cf.php' );
}
if ( 'yes' === get_option( 'wp_discord_enabled_for_gf' ) && class_exists( 'GFForms' ) ) {
$this->gf = include_once( 'includes/class-wp-discord-post-gf.php' );
}
if ( class_exists( 'WooCommerce' ) ) {
$this->woocommerce = include_once( 'includes/class-wp-discord-post-woocommerce.php' );
}
if ( class_exists( 'acf' ) ) {
$this->acf = include_once( 'includes/class-wp-discord-post-acf.php' );
}
$this->load_textdomain();
do_action( 'wp_discord_post_init' );
}
/**
* Loads the plugin localization files.
*/
public function load_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'wp-discord-post' );
load_textdomain( 'wp-discord-post', WP_LANG_DIR . '/wp-discord-post/discord-post-' . $locale . '.mo' );
load_plugin_textdomain( 'wp-discord-post', false, plugin_basename( __DIR__ ) . '/languages' );
}
}
WP_Discord_Post::instance();