-
Notifications
You must be signed in to change notification settings - Fork 7
/
spotim-comments.php
159 lines (136 loc) · 3.39 KB
/
spotim-comments.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
159
<?php
/**
* Plugin Name: Spot.IM Comments
* Plugin URI: https://wordpress.org/plugins/spotim-comments/
* Description: Real-time comments widget turns your site into its own content-circulating ecosystem.
* Version: 4.3.0
* Author: Spot.IM
* Author URI: https://github.com/SpotIM
* License: GPLv2
* License URI: license.txt
* Text Domain: spotim-comments
* GitHub Plugin URI: [email protected]:SpotIM/wordpress-comments-plugin.git
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WP_SpotIM
*
* A general class for Spot.IM comments for WordPress.
*
* @since 1.0.2
*/
class WP_SpotIM {
/**
* Instance
*
* @since 1.0.2
*
* @access private
* @static
*
* @var WP_SpotIM
*/
private static $instance;
/**
* Constructor
*
* Get things started.
*
* @since 1.0.2
*
* @access protected
*/
protected function __construct() {
// Activation/Deactivation hooks
register_activation_hook( __FILE__, array( $this, 'flush_rewrite_rules' ) );
register_deactivation_hook( __FILE__, array( $this, 'flush_rewrite_rules' ) );
// Load plugin files
$this->load_files();
// Get the Options
$this->options = SpotIM_Options::get_instance();
// Run the plugin
new SpotIM_i18n();
new SpotIM_Cron( $this->options );
new SpotIM_Feed();
if ( is_admin() ) {
// Admin Page
new SpotIM_Admin( $this->options );
} else {
// Frontend code: embed script, comments template, comments count.
new SpotIM_Frontend( $this->options );
}
}
/**
* Get Instance
*
* @since 2.0.0
*
* @access public
* @static
*
* @return WP_SpotIM
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Flush rewrite rules
*
* @since 4.1.0
*
* @access public
*
* @return void
*/
public function flush_rewrite_rules() {
flush_rewrite_rules();
}
/**
* Load plugin files
*
* @since 4.3.0 The functionality moved to a method.
*
* @access public
*
* @return void
*/
public function load_files() {
$files = [
'helpers/class-spotim-form.php',
'helpers/class-spotim-message.php',
'helpers/class-spotim-comment.php',
'helpers/class-spotim-json-feed.php',
'class-spotim-i18n.php',
'class-spotim-import.php',
'class-spotim-options.php',
'class-spotim-settings-fields.php',
'class-spotim-metabox.php',
'class-spotim-admin.php',
'class-spotim-frontend.php',
'class-spotim-feed.php',
'class-spotim-cron.php',
'spotim-shortcodes.php',
'spotim-widgets.php',
];
foreach ( $files as $file ) {
require_once( 'inc/' . $file );
}
}
}
/**
* Spotim Instance
*
* @since 1.0
*
* @return WP_SpotIM
*/
function spotim_instance() {
return WP_SpotIM::get_instance();
}
add_action( 'plugins_loaded', 'spotim_instance', 0 );