-
Notifications
You must be signed in to change notification settings - Fork 1
/
import-meetup-events.php
309 lines (277 loc) · 11.7 KB
/
import-meetup-events.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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php
/**
* Plugin Name: Import Meetup Events
* Plugin URI: https://xylusthemes.com/plugins/import-meetup-events/
* Description: Import Meetup Events allows you to import Meetup (meetup.com) events into your WordPress site effortlessly.
* Version: 1.6.3
* Author: xylus
* Author URI: http://xylusthemes.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: import-meetup-events
* Domain Path: /languages
*
* @link http://xylusthemes.com/
* @since 1.0.0
* @package Import_Meetup_Events
*/
// If this file is called directly, abort.
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('Import_Meetup_Events')):
/**
* Main Import Meetup Events class
*/
class Import_Meetup_Events {
/** Singleton *************************************************************/
/**
* Import_Meetup_Events The one true Import_Meetup_Events.
*/
private static $instance;
public $common, $cpt, $meetup, $admin, $manage_import, $ime, $tec, $em, $eventon, $event_organizer, $aioec, $my_calendar, $cron, $common_pro, $authorize;
/**
* Main Import Meetup Events Instance.
*
* Insure that only one instance of Import_Meetup_Events exists in memory at any one time.
* Also prevents needing to define globals all over the place.
*
* @since 1.0.0
* @static object $instance
* @uses Import_Meetup_Events::setup_constants() Setup the constants needed.
* @uses Import_Meetup_Events::includes() Include the required files.
* @uses Import_Meetup_Events::laod_textdomain() load the language files.
* @see run_Import_Meetup_Events()
* @return object| Import Meetup Events the one true Import Meetup Events.
*/
public static function instance() {
if (!isset(self::$instance) && !(self::$instance instanceof Import_Meetup_Events)) {
self::$instance = new Import_Meetup_Events;
self::$instance->setup_constants();
add_action('plugins_loaded', array(self::$instance, 'load_textdomain'));
add_action( 'plugins_loaded', array( self::$instance, 'load_authorize_class' ), 20 );
add_action('wp_enqueue_scripts', array(self::$instance, 'ime_enqueue_style'));
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( self::$instance, 'ime_setting_doc_links' ) );
self::$instance->includes();
self::$instance->common = new Import_Meetup_Events_Common();
self::$instance->cpt = new Import_Meetup_Events_Cpt();
self::$instance->meetup = new Import_Meetup_Events_Meetup();
self::$instance->admin = new Import_Meetup_Events_Admin();
if (ime_is_pro()) {
self::$instance->manage_import = new Import_Meetup_Events_Pro_Manage_Import();
} else {
self::$instance->manage_import = new Import_Meetup_Events_Manage_Import();
}
self::$instance->ime = new Import_Meetup_Events_IME();
self::$instance->tec = new Import_Meetup_Events_TEC();
self::$instance->em = new Import_Meetup_Events_EM();
self::$instance->eventon = new Import_Meetup_Events_EventON();
self::$instance->event_organizer = new Import_Meetup_Events_Event_Organizer();
self::$instance->aioec = new Import_Meetup_Events_Aioec();
self::$instance->my_calendar = new Import_Meetup_Events_My_Calendar();
}
return self::$instance;
}
/** Magic Methods *********************************************************/
/**
* A dummy constructor to prevent Import_Meetup_Events from being loaded more than once.
*
* @since 1.0.0
* @see Import_Meetup_Events::instance()
* @see run_Import_Meetup_Events()
*/
private function __construct() {
/* Do nothing here */
}
/**
* A dummy magic method to prevent Import_Meetup_Events from being cloned.
*
* @since 1.0.0
*/
public function __clone() {
_doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'import-meetup-events'), '1.6.3');
}
/**
* A dummy magic method to prevent Import_Meetup_Events from being unserialized.
*
* @since 1.0.0
*/
public function __wakeup() {
_doing_it_wrong(__FUNCTION__, esc_html__('Cheatin’ huh?', 'import-meetup-events'), '1.6.3');
}
/**
* Setup plugins constants.
*
* @access private
* @since 1.0.0
* @return void
*/
private function setup_constants() {
// Plugin version.
if (!defined('IME_VERSION')) {
define('IME_VERSION', '1.6.3');
}
// Minimum Pro plugin version.
if( ! defined( 'IME_MIN_PRO_VERSION' ) ){
define( 'IME_MIN_PRO_VERSION', '1.6.1' );
}
// Plugin folder Path.
if (!defined('IME_PLUGIN_DIR')) {
define('IME_PLUGIN_DIR', plugin_dir_path(__FILE__));
}
// Plugin folder URL.
if (!defined('IME_PLUGIN_URL')) {
define('IME_PLUGIN_URL', plugin_dir_url(__FILE__));
}
// Plugin root file.
if (!defined('IME_PLUGIN_FILE')) {
define('IME_PLUGIN_FILE', __FILE__);
}
// Options
if (!defined('IME_OPTIONS')) {
define('IME_OPTIONS', 'xtmi_meetup_options');
}
// Pro plugin Buy now Link.
if (!defined('IME_PLUGIN_BUY_NOW_URL')) {
define('IME_PLUGIN_BUY_NOW_URL', 'http://xylusthemes.com/plugins/import-meetup-events/?utm_source=insideplugin&utm_medium=web&utm_content=sidebar&utm_campaign=freeplugin');
}
}
/**
* Include required files.
*
* @access private
* @since 1.0.0
* @return void
*/
private function includes() {
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-common.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-list-table.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-admin.php';
if (ime_is_pro()) {
require_once IMEPRO_PLUGIN_DIR . 'includes/class-import-meetup-events-manage-import.php';
} else {
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-manage-import.php';
}
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-cpt.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-meetup.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-ime.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-tec.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-em.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-eventon.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-event_organizer.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-aioec.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-my-calendar.php';
require_once IME_PLUGIN_DIR . 'includes/class-ime-plugin-deactivation.php';
require_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-api.php';
require_once IME_PLUGIN_DIR . 'includes/libs/IMEParsedown.php';
// Gutenberg Block
require_once IME_PLUGIN_DIR . 'blocks/meetup-events/index.php';
}
/**
* Loads the plugin language files.
*
* @access public
* @since 1.0.0
* @return void
*/
public function load_textdomain() {
load_plugin_textdomain(
'import-meetup-events',
false,
basename(dirname(__FILE__)) . '/languages'
);
}
/**
* IME setting And docs link add in plugin page.
*
* @since 1.0
* @return void
*/
public function ime_setting_doc_links( $links ) {
$ime_setting_doc_link = array(
'ime-event-setting' => sprintf(
'<a href="%s">%s</a>',
esc_url( admin_url( 'admin.php?page=meetup_import&tab=settings' ) ),
esc_html__( 'Setting', 'import-meetup-events' )
),
'ime-event-docs' => sprintf(
'<a target="_blank" href="%s">%s</a>',
esc_url( 'https://docs.xylusthemes.com/docs/import-meetup-events/' ),
esc_html__( 'Docs', 'import-meetup-events' )
),
);
return array_merge( $links, $ime_setting_doc_link );
}
/**
* Loads the Meetup authorize class
*
* @access public
* @since 1.5
* @return void
*/
public function load_authorize_class(){
if( !class_exists( 'Import_Meetup_Events_Authorize', false ) ){
include_once IME_PLUGIN_DIR . 'includes/class-import-meetup-events-authorize.php';
global $ime_events;
if( class_exists('Import_Meetup_Events_Authorize', false ) && !empty( $ime_events ) ){
$ime_events->authorize = new Import_Meetup_Events_Authorize();
}
}
}
/**
* enqueue style front-end
*
* @access public
* @since 1.0.0
* @return void
*/
public function ime_enqueue_style() {
$css_dir = IME_PLUGIN_URL . 'assets/css/';
wp_enqueue_style('font-awesome', $css_dir . 'font-awesome.min.css', false, "");
wp_enqueue_style('import-meetup-events-front', $css_dir . 'import-meetup-events.css', false, "");
wp_enqueue_style('import-meetup-events-front-style2', $css_dir . 'grid-style2.css', false, '' );
}
}
endif; // End If class exists check.
/**
* The main function for that returns Import_Meetup_Events
*
* The main function responsible for returning the one true Import_Meetup_Events
* Instance to functions everywhere.
*
* Use this function like you would a global variable, except without needing
* to declare the global.
*
* Example: <?php $ime_events = run_import_meetup_events(); ?>
*
* @since 1.0.0
* @return object|Import_Meetup_Events The one true Import_Meetup_Events Instance.
*/
function run_import_meetup_events() {
return Import_Meetup_Events::instance();
}
/**
* Get Import events setting options
*
* @since 1.0
* @return void
*/
function ime_get_import_options($type = '') {
$ime_options = get_option(IME_OPTIONS);
return $ime_options;
}
// Get Import_Meetup_Events Running.
global $ime_events, $ime_errors, $ime_success_msg, $ime_warnings, $ime_info_msg;
$ime_events = run_import_meetup_events();
$ime_errors = $ime_warnings = $ime_success_msg = $ime_info_msg = array();
/**
* The code that runs during plugin activation.
*
* @since 1.1.1
*/
function ime_activate_import_meetup_events() {
global $ime_events;
$ime_events->cpt->register_event_post_type();
flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'ime_activate_import_meetup_events');