-
Notifications
You must be signed in to change notification settings - Fork 16
/
bp-reshare.php
executable file
·207 lines (182 loc) · 4.75 KB
/
bp-reshare.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/**
* BuddyPress Reshare plugin header
*
* @package BP Reshare
* @author imath https://imathi.eu
* @license GPL-2.0+
* @link https://imathi.eu/tag/reshare/
*
* @wordpress-plugin
* Plugin Name: BP Reshare
* Plugin URI: https://imathi.eu/tag/reshare/
* Description: Allows members to reshare activities in a BuddyPress powered community
* Version: 2.0.1
* Author: imath
* Author URI: https://imathi.eu
* Text Domain: bp-reshare
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages/
* GitHub Plugin URI: https://github.com/imath/bp-reshare
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'BuddyReshare' ) ) :
/**
* Main BP Reshare Class
*
* @since BP Reshare (1.0)
*/
class BuddyReshare {
/**
* Instance of this class.
*
* @since 1.0
*
* @var object
*/
protected static $instance = null;
/**
* Initialize the plugin
*
* @since 1.0
*/
private function __construct() {
$this->setup_globals();
$this->includes();
}
/**
* Return an instance of this class.
*
* @since 1.0
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Sets some globals for the plugin
*
* @since 1.0
*/
private function setup_globals() {
/** BP Reshare globals ********************************************/
$this->version = '2.0.1';
$this->db_version = bp_get_option( 'bp-reshare-version', 0 );
$this->domain = 'bp-reshare';
$this->file = __FILE__;
$this->basename = plugin_basename( $this->file );
$this->plugin_dir = plugin_dir_path( $this->file );
$this->plugin_url = plugin_dir_url( $this->file );
$this->lang_dir = trailingslashit( $this->plugin_dir . 'languages' );
$this->includes_dir = trailingslashit( $this->plugin_dir . 'includes' );
$this->js_url = trailingslashit( $this->plugin_url . 'js' );
$this->css_url = trailingslashit( $this->plugin_url . 'css' );
/** Component specific globals ********************************************/
$this->component_id = 'bp_reshare';
$this->component_slug = 'reshare';
$this->component_name = 'Reshares';
// Rest namespace and version.
$this->rest = (object) array(
'namespace' => 'bp-reshare',
'version' => 'v1',
);
// Set Cache Global groups.
wp_cache_add_global_groups( array(
'user_reshares',
'user_reshared',
'user_favorites',
'reshares_count',
'reshared_notifications',
) );
}
/**
* Includes the needed files
*
* @since 1.0
*/
private function includes() {
require( $this->includes_dir . 'functions.php' );
if ( 2.0 <= (float) $this->db_version ) {
if ( bp_is_active( 'activity' ) ) {
require( $this->includes_dir . 'rest.php' );
require( $this->includes_dir . 'users.php' );
require( $this->includes_dir . 'activity.php' );
if ( buddyreshare_are_emails_active() ) {
require( $this->includes_dir . 'emails.php' );
}
if ( bp_is_active( 'notifications' ) ) {
require( $this->includes_dir . 'notifications.php' );
}
if ( bp_is_active( 'blogs' ) ) {
require( $this->includes_dir . 'posts.php' );
}
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
require( $this->includes_dir . 'deprecated.php' );
}
if ( is_admin() ) {
require( $this->includes_dir . 'settings.php' );
}
}
}
require( $this->includes_dir . 'upgrade.php' );
}
/**
* Sets the key hooks to add an action or a filter to
*
* @since 1.0
* @deprecated 2.0.0
*/
private function setup_hooks() {
_deprecated_function( __FUNCTION__, '2.0.0' );
}
/**
* Loads the component
*
* @since 1.0
* @deprecated 2.0.0
*/
public function load_component() {
_deprecated_function( __FUNCTION__, '2.0.0' );
}
/**
* Enqueues the js and css files only if BP Reshare needs it
*
* @since 1.0
* @deprecated 2.0.0
*/
public function cssjs() {
_deprecated_function( __FUNCTION__, '2.0.0' );
}
/**
* The theme can override plugin's css
*
* @since 1.0
* @deprecated 2.0.0
*/
public function css_datas() {
_deprecated_function( __FUNCTION__, '2.0.0' );
}
/**
* Loads the translation files
*
* @since 1.0
* @deprecated 2.0.0
*/
public function load_textdomain() {
_deprecated_function( __FUNCTION__, '2.0.0' );
}
}
endif;
// Let's start !
function buddyreshare() {
return BuddyReshare::get_instance();
}
// Not too early and not too late ! 9 seems ok ;)
add_action( 'bp_include', 'buddyreshare', 9 );