This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcyclone-slider.php
437 lines (353 loc) · 15.6 KB
/
cyclone-slider.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?php
/*
Plugin Name: Cyclone Slider 2
Plugin URI: http://www.codefleet.net/cyclone-slider-2/
Description: Create and manage sliders with ease. Built for both casual users and developers.
Version: 2.10.0
Author: Nico Amarilla
Author URI: http://www.codefleet.net/
License:
Copyright 2015 ([email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Autoloader
function cycloneslider_autoloader( $class_name ) {
if( false !== strpos( $class_name, 'CycloneSlider' ) ){
$classes_dir = realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
$class_file = str_replace( '_', DIRECTORY_SEPARATOR, $class_name ) . '.php';
require_once $classes_dir . $class_file;
}
}
spl_autoload_register('cycloneslider_autoloader');
$cyclone_slider_plugin_instance = null;
$cyclone_slider_saved_done = false;
// Hook the plugin
add_action('plugins_loaded', 'cycloneslider_init');
function cycloneslider_init() {
global $cyclone_slider_plugin_instance;
$plugin = new CycloneSlider_Plugin();
$plugin['path'] = realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR;
$plugin['url'] = plugin_dir_url(__FILE__);
$plugin['version'] = 'cycloneslider_service_plugin_version';
$plugin['debug'] = false;
$plugin['textdomain'] = 'cycloneslider';
$plugin['slug'] = 'cyclone-slider-2/cyclone-slider.php';
$plugin['nonce_name'] = 'cyclone_slider_builder_nonce';
$plugin['nonce_action'] = 'cyclone-slider-save';
$plugin['wp_upload_location'] = 'cycloneslider_wp_upload_location';
$plugin['wp_content_dir'] = 'cycloneslider_service_wp_content_dir';
$plugin['wp_content_url'] = content_url();
$plugin['cyclone_slider_dir'] = 'cycloneslider_service_cyclone_slider_dir'; // Folder where plugin related functions are performed
$plugin['view_folder'] = $plugin['path'].'views';
$plugin['view'] = 'cycloneslider_service_view';
$plugin['image_resizer'] = 'cycloneslider_service_image_resizer';
$plugin['image_editor'] = 'CycloneSlider_ImageEditor';
$plugin['image_sizes'] = array(
'40_40_crop' => array( // Used by thumbnail template
'width' => 40,
'height' => 40,
'resize_option' => 'crop'
),
'60_60_crop' => array( // Used by Galleria template
'width' => 60,
'height' => 60,
'resize_option' => 'crop'
)
);
$plugin['image_sizes'] = apply_filters('cycloneslider_image_sizes', $plugin['image_sizes']);
$plugin['data'] = 'cycloneslider_service_data';
$plugin['nextgen_integration'] = 'cycloneslider_service_nextgen';
$plugin['exporter'] = 'cycloneslider_service_exporter';
$plugin['exports_dir'] = $plugin['cyclone_slider_dir'].'/exports';
$plugin['export_json_file'] = 'export.json';
$plugin['importer'] = 'cycloneslider_service_importer';
$plugin['imports_dir'] = $plugin['cyclone_slider_dir'].'/imports';
$plugin['imports_extracts_dir'] = $plugin['imports_dir'].'/extracts';
$plugin['import_zip_name'] = 'import.zip';
$plugin['zip_archive'] = 'ZipArchive';
// Order is important. core is overridden by active-theme which in turn is overridden by wp-content.
$plugin['template_locations'] = array(
array(
'path' => $plugin['path'].'templates'.DIRECTORY_SEPARATOR, // This resides in the plugin
'url' => $plugin['url'].'templates/',
'location_name' => 'core'
),
array(
'path' => realpath(get_stylesheet_directory()).DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR, // This resides in the current theme or child theme. Gets deleted when theme is deleted.
'url' => get_stylesheet_directory_uri()."/cycloneslider/",
'location_name' => 'active-theme'
),
array(
'path' => $plugin['wp_content_dir'].DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR, // This resides in the wp-content folder to prevent deleting when upgrading themes. Recommended location
'url' => $plugin['wp_content_url']."/cycloneslider/",
'location_name' => 'wp-content'
)
);
$plugin['settings_page'] = 'cycloneslider_service_settings_page';
$plugin['settings_page_properties'] = array(
'parent_slug' => 'edit.php?post_type=cycloneslider',
'page_title' => __('Cyclone Slider Settings', $plugin['textdomain']),
'menu_title' => __('Settings', $plugin['textdomain']),
'capability' => 'manage_options',
'menu_slug' => 'cycloneslider-settings',
'option_group' => 'cyclone_option_group',
'option_name' => 'cyclone_option_name'
);
$plugin['export_page'] = 'cycloneslider_service_export_page';
$plugin['export_page_properties'] = array(
'parent_slug' => 'edit.php?post_type=cycloneslider',
'page_title' => __('Cyclone Slider Export', $plugin['textdomain']),
'menu_title' => __('Export/Import', $plugin['textdomain']),
'capability' => 'manage_options',
'menu_slug' => 'cycloneslider-export',
'transient_name' => 'cycloneslider_export_transient',
'nonce_name' => 'cycloneslider_export_nonce',
'nonce_action' => 'cycloneslider_export',
'url' => get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' )
);
//$plugin['export_page_nextgen'] = 'cycloneslider_service_export_page_nextgen';
$plugin['export_page_nextgen_properties'] = array(
'parent_slug' => '',
'page_title' => __('Cyclone Slider Nextgen Export', $plugin['textdomain']),
'menu_title' => __('Export Nextgen', $plugin['textdomain']),
'capability' => 'manage_options',
'menu_slug' => 'cycloneslider-export-nextgen',
'transient_name' => 'cycloneslider_export_nextgen_transient',
'nonce_name' => 'cycloneslider_export_nextgen_nonce',
'nonce_action' => 'cycloneslider_export_nextgen',
'url' => get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export-nextgen' )
);
$plugin['import_page'] = 'cycloneslider_service_import_page';
$plugin['import_page_properties'] = array(
'parent_slug' => '',
'page_title' => __('Cyclone Slider Import', $plugin['textdomain']),
'menu_title' => __('Import', $plugin['textdomain']),
'capability' => 'manage_options',
'menu_slug' => 'cycloneslider-import',
'nonce_name' => 'cycloneslider_import_nonce',
'nonce_action' => 'cycloneslider_import',
'url' => get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' )
);
$plugin['zip_archive'] = 'cycloneslider_service_zip_archive';
$plugin['youtube'] = new CycloneSlider_Youtube();
$plugin['vimeo'] = new CycloneSlider_Vimeo();
$plugin['asset_loader'] = 'cycloneslider_service_asset_loader';
$plugin['admin'] = 'cycloneslider_service_admin';
$plugin['frontend'] = 'cycloneslider_service_frontend';
$plugin['widgets'] = new CycloneSlider_Widgets();
require_once($plugin['path'].'src/functions.php'); // Function not autoloaded from the old days. Deprecated
$plugin->run();
$cyclone_slider_plugin_instance = $plugin;
}
// Service Definitions
function cycloneslider_service_plugin_version( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$default_headers = array(
'name' => 'Plugin Name',
'plugin_uri' => 'Plugin URI',
'version' => 'Version'
);
$plugin_data = get_file_data( __FILE__, $default_headers, 'plugin' ); // WP Func
$object = $plugin_data['version'];
return $object;
}
function cycloneslider_wp_upload_location( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$wp_locations = wp_upload_dir();
$object = $wp_locations;
return $object;
}
function cycloneslider_service_wp_content_dir( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$wp_upload_dir = $plugin['wp_upload_location'];
$object = dirname( $wp_upload_dir['basedir'] );
return $object;
}
function cycloneslider_service_cyclone_slider_dir( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = $plugin['wp_content_dir'].'/cyclone-slider';
return $object;
}
function cycloneslider_service_image_resizer( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_ImageResizer( $plugin['image_sizes'], $plugin['image_editor'] );
return $object;
}
function cycloneslider_service_data( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_Data( $plugin['nonce_name'], $plugin['nonce_action'], $plugin['image_resizer'], $plugin['template_locations'], $plugin['settings_page_properties'] );
return $object;
}
function cycloneslider_service_nextgen( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_NextgenIntegration( $plugin['data'] );
return $object;
}
function cycloneslider_service_exporter( $plugin ){
static $object;
if (null !== $object) {
return $object;
}
$wp_upload_location = $plugin['wp_upload_location'];
$object = new CycloneSlider_Exporter( $plugin['data'], $plugin['zip_archive'], $plugin['export_json_file'], $plugin['textdomain'] );
return $object;
}
function cycloneslider_service_importer( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$wp_upload_location = $plugin['wp_upload_location'];
$object = new CycloneSlider_Importer( $plugin['data'], $plugin['imports_dir'], $wp_upload_location['path'], $plugin['zip_archive'], $plugin['import_zip_name'], $plugin['imports_extracts_dir'], $plugin['export_json_file'], $plugin['textdomain'] );
return $object;
}
function cycloneslider_service_view( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_View( $plugin['view_folder'] );
return $object;
}
function cycloneslider_service_settings_page( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_SettingsPage( $plugin['settings_page_properties'], $plugin['data'], $plugin['textdomain'], $plugin['debug'], $plugin['view'] );
return $object;
}
function cycloneslider_service_export_page( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_ExportPage(
$plugin['export_page_properties']['parent_slug'],
$plugin['export_page_properties']['page_title'],
$plugin['export_page_properties']['menu_title'],
$plugin['export_page_properties']['capability'],
$plugin['export_page_properties']['menu_slug'],
$plugin['data']->get_sliders(),
$plugin['view'],
$plugin['exporter'],
$plugin['wp_content_dir'],
$plugin['wp_content_url'],
$plugin['textdomain'],
$plugin['export_page_properties']['transient_name'],
$plugin['export_page_properties']['nonce_name'],
$plugin['export_page_properties']['nonce_action'],
$plugin['export_page_properties']['url'],
$plugin['import_page_properties']['url'],
$plugin['export_page_nextgen_properties']['url']
);
return $object;
}
function cycloneslider_service_import_page( $plugin ){
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_ImportPage(
$plugin['import_page_properties']['parent_slug'],
$plugin['import_page_properties']['page_title'],
$plugin['import_page_properties']['menu_title'],
$plugin['import_page_properties']['capability'],
$plugin['import_page_properties']['menu_slug'],
$plugin['data'],
$plugin['view'],
$plugin['import_page_properties']['nonce_name'],
$plugin['import_page_properties']['nonce_action'],
$plugin['importer'],
$plugin['cyclone_slider_dir'],
$plugin['wp_content_dir'],
$plugin['wp_content_url'],
$plugin['textdomain'],
$plugin['export_page_properties']['url'],
$plugin['import_page_properties']['url'],
$plugin['export_page_nextgen_properties']['url']
);
return $object;
}
function cycloneslider_service_export_page_nextgen( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_ExportPageNextgen(
$plugin['export_page_nextgen_properties']['parent_slug'],
$plugin['export_page_nextgen_properties']['page_title'],
$plugin['export_page_nextgen_properties']['menu_title'],
$plugin['export_page_nextgen_properties']['capability'],
$plugin['export_page_nextgen_properties']['menu_slug'],
$plugin['view'],
$plugin['exporter'],
$plugin['wp_content_dir'],
$plugin['wp_content_url'],
$plugin['textdomain'],
$plugin['export_page_nextgen_properties']['transient_name'],
$plugin['export_page_nextgen_properties']['nonce_name'],
$plugin['export_page_nextgen_properties']['nonce_action'],
$plugin['export_page_properties']['url'],
$plugin['import_page_properties']['url'],
$plugin['export_page_nextgen_properties']['url']
);
return $object;
}
function cycloneslider_service_zip_archive( $plugin ){
return new ZipArchive;
}
function cycloneslider_service_asset_loader( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_AssetLoader( $plugin['data']->get_settings_page_data(), $plugin['url'], $plugin['version'], $plugin['data'] );
return $object;
}
function cycloneslider_service_admin( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_Admin($plugin['asset_loader'], $plugin['textdomain'], $plugin['data'], $plugin['debug'], $plugin['view'], $plugin['nonce_name'], $plugin['nonce_action'], $plugin['url'] );
return $object;
}
function cycloneslider_service_frontend( $plugin ) {
static $object;
if (null !== $object) {
return $object;
}
$object = new CycloneSlider_Frontend( $plugin['data'], $plugin['image_sizes'], $plugin['youtube'], $plugin['vimeo'], $plugin['view'] );
return $object;
}