-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsof-organisations.php
252 lines (204 loc) · 4.72 KB
/
sof-organisations.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/**
* SOF Organisations
*
* Plugin Name: SOF Organisations
* Description: Provides Organisation Custom Post Types for The Ball website.
* Plugin URI: https://github.com/spiritoffootball/sof-organisations
* GitHub Plugin URI: https://github.com/spiritoffootball/sof-organisations
* Version: 1.0.1a
* Author: Christian Wach
* Author URI: https://haystack.co.uk
* Text Domain: sof-organisations
* Domain Path: /languages
*
* @package SOF_Organisations
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Set our version here.
define( 'SOF_ORGANISATIONS_VERSION', '1.0.1a' );
// Store reference to this file.
if ( ! defined( 'SOF_ORGANISATIONS_FILE' ) ) {
define( 'SOF_ORGANISATIONS_FILE', __FILE__ );
}
// Store URL to this plugin's directory.
if ( ! defined( 'SOF_ORGANISATIONS_URL' ) ) {
define( 'SOF_ORGANISATIONS_URL', plugin_dir_url( SOF_ORGANISATIONS_FILE ) );
}
// Store PATH to this plugin's directory.
if ( ! defined( 'SOF_ORGANISATIONS_PATH' ) ) {
define( 'SOF_ORGANISATIONS_PATH', plugin_dir_path( SOF_ORGANISATIONS_FILE ) );
}
/**
* Main Plugin Class.
*
* A class that encapsulates plugin functionality.
*
* @since 1.0
*/
class SOF_Organisations {
/**
* Admin object.
*
* @since 1.0
* @access public
* @var SOF_Organisations_Admin
*/
public $admin;
/**
* CiviCRM object.
*
* @since 1.0
* @access public
* @var SOF_Organisations_CiviCRM
*/
public $civicrm;
/**
* Custom Post Type loader object.
*
* @since 1.0
* @access public
* @var SOF_Organisations_CPT
*/
public $cpt;
/**
* ACF loader object.
*
* @since 1.0
* @access public
* @var SOF_Organisations_ACF
*/
public $acf;
/**
* Constructor.
*
* @since 1.0
*/
public function __construct() {
// Initialise on "plugins_loaded".
add_action( 'plugins_loaded', [ $this, 'initialise' ] );
}
/**
* Do stuff on plugin init.
*
* @since 1.0
*/
public function initialise() {
// Only do this once.
static $done;
if ( isset( $done ) && true === $done ) {
return;
}
// Load translation.
$this->translation();
// Include files.
$this->include_files();
// Set up objects and references.
$this->setup_objects();
/**
* Broadcast that this plugin is now loaded.
*
* @since 1.0
*/
do_action( 'sof_orgs/loaded' );
// We're done.
$done = true;
}
/**
* Enable translation.
*
* @since 1.0
*/
public function translation() {
// Load translations.
// phpcs:ignore WordPress.WP.DeprecatedParameters.Load_plugin_textdomainParam2Found
load_plugin_textdomain(
'sof-organisations', // Unique name.
false, // Deprecated argument.
dirname( plugin_basename( SOF_ORGANISATIONS_FILE ) ) . '/languages/' // Relative path to files.
);
}
/**
* Include files.
*
* @since 1.0
*/
public function include_files() {
// Include class files.
include SOF_ORGANISATIONS_PATH . 'includes/class-admin.php';
include SOF_ORGANISATIONS_PATH . 'includes/class-civicrm.php';
include SOF_ORGANISATIONS_PATH . 'includes/class-cpt.php';
include SOF_ORGANISATIONS_PATH . 'includes/class-acf.php';
}
/**
* Set up this plugin's objects.
*
* @since 1.0
*/
public function setup_objects() {
// Init objects.
$this->admin = new SOF_Organisations_Admin( $this );
$this->civicrm = new SOF_Organisations_CiviCRM( $this );
$this->cpt = new SOF_Organisations_CPT( $this );
$this->acf = new SOF_Organisations_ACF( $this );
}
/**
* Perform plugin activation tasks.
*
* @since 1.0
*/
public function activate() {
// Maybe init.
$this->initialise();
/**
* Broadcast plugin activation.
*
* @since 1.0
*/
do_action( 'sof_orgs/activate' );
}
/**
* Perform plugin deactivation tasks.
*
* @since 1.0
*/
public function deactivate() {
// Maybe init.
$this->initialise();
/**
* Broadcast plugin deactivation.
*
* @since 1.0
*/
do_action( 'sof_orgs/deactivate' );
}
}
/**
* Utility to get a reference to this plugin.
*
* @since 1.0
*
* @return SOF_Organisations $sof_organisations The plugin reference.
*/
function sof_organisations() {
// Store instance in static variable.
static $sof_organisations = false;
// Maybe return instance.
if ( false === $sof_organisations ) {
$sof_organisations = new SOF_Organisations();
}
// --<
return $sof_organisations;
}
// Initialise plugin now.
sof_organisations();
// Activation.
register_activation_hook( __FILE__, [ sof_organisations(), 'activate' ] );
// Deactivation.
register_deactivation_hook( __FILE__, [ sof_organisations(), 'deactivate' ] );
/*
* Uninstall uses the 'uninstall.php' method.
*
* @see https://codex.wordpress.org/Function_Reference/register_uninstall_hook
*/