Cyclone Slider - Version 2.9.0

Version Description

  • 2014-12-09 =
  • Change. Major code refactoring for future features to be easily added
Download this release

Release Info

Developer kosinix
Plugin Icon 128x128 Cyclone Slider
Version 2.9.0
Comparing to
See all releases

Code changes from version 2.8.4 to 2.9.0

Files changed (48) hide show
  1. README.txt +8 -2
  2. classes/class-cyclone-slider-admin.php +0 -723
  3. classes/class-cyclone-slider-data.php +0 -611
  4. classes/class-cyclone-slider-export-page.php +0 -106
  5. classes/class-cyclone-slider-exporter.php +0 -269
  6. classes/class-cyclone-slider-image-editor.php +0 -287
  7. classes/class-cyclone-slider-image-resizer.php +0 -108
  8. classes/class-cyclone-slider-import-page.php +0 -93
  9. classes/class-cyclone-slider-importer.php +0 -401
  10. classes/class-cyclone-slider-scripts.php +0 -183
  11. classes/class-cyclone-slider-settings-page.php +0 -95
  12. classes/class-cyclone-slider-vimeo.php +0 -52
  13. classes/class-cyclone-slider-widget.php +0 -114
  14. classes/class-cyclone-slider-youtube.php +0 -97
  15. classes/class-cyclone-slider.php +0 -272
  16. classes/class-cyclone-templates-manager.php +0 -89
  17. classes/class-image-resizer.php +0 -227
  18. classes/class-nextgen-integration.php +0 -184
  19. classes/codefleet/class-codefleet-admin-page.php +0 -144
  20. classes/codefleet/class-codefleet-admin-sub-page.php +0 -68
  21. classes/codefleet/class-codefleet-plugin-updater.php +0 -149
  22. classes/codefleet/class-codefleet-settings-page.php +0 -228
  23. classes/codefleet/class-codefleet-settings-sub-page.php +0 -84
  24. classes/codefleet/class-codefleet-view.php +0 -76
  25. classes/codefleet/info.txt +0 -1
  26. css/admin.css +7 -1
  27. cyclone-slider.php +61 -106
  28. lang/cycloneslider-es_ES.po +1055 -1055
  29. src/CycloneSlider/Admin.php +705 -0
  30. src/CycloneSlider/AssetLoader.php +181 -0
  31. src/CycloneSlider/Base.php +8 -0
  32. src/CycloneSlider/Data.php +611 -0
  33. src/CycloneSlider/ExportPage.php +116 -0
  34. src/CycloneSlider/Exporter.php +267 -0
  35. src/CycloneSlider/Frontend.php +272 -0
  36. src/CycloneSlider/ImageEditor.php +283 -0
  37. src/CycloneSlider/ImageResizer.php +104 -0
  38. src/CycloneSlider/ImportPage.php +102 -0
  39. src/CycloneSlider/Importer.php +400 -0
  40. src/CycloneSlider/Main.php +64 -0
  41. src/CycloneSlider/NextgenIntegration.php +179 -0
  42. src/CycloneSlider/SettingsPage.php +214 -0
  43. src/CycloneSlider/TemplatesManager.php +116 -0
  44. src/CycloneSlider/Updater.php +202 -0
  45. src/CycloneSlider/View.php +73 -0
  46. src/CycloneSlider/Vimeo.php +48 -0
  47. src/CycloneSlider/Youtube.php +86 -0
  48. {inc → src}/functions.php +1 -1
README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: kosinix
3
  Donate link: http://www.codefleet.net/donate/
4
  Tags: slider, slideshow, drag-and-drop, wordpress-slider, wordpress-slideshow, cycle 2, jquery, responsive, translation-ready, custom-post, cyclone-slider
5
  Requires at least: 3.5
6
- Tested up to: 4.0
7
- Stable tag: 2.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,9 @@ Inside `wp-content` create a folder named "cycloneslider". Add your templates in
103
 
104
  == Changelog ==
105
 
 
 
 
106
  = 2.8.4 - 2014-09-04 =
107
  * Updated spanish language files
108
  * Added compatibility with WP 4.0
@@ -321,6 +324,9 @@ Inside `wp-content` create a folder named "cycloneslider". Add your templates in
321
 
322
  == Upgrade Notice ==
323
 
 
 
 
324
  = 2.8.4 - 2014-09-04 =
325
  * Updated spanish language files
326
  * Added compatibility with WP 4.0
3
  Donate link: http://www.codefleet.net/donate/
4
  Tags: slider, slideshow, drag-and-drop, wordpress-slider, wordpress-slideshow, cycle 2, jquery, responsive, translation-ready, custom-post, cyclone-slider
5
  Requires at least: 3.5
6
+ Tested up to: 4.0.1
7
+ Stable tag: 2.9.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 2.9.0 - 2014-12-09 =
107
+ * Change. Major code refactoring for future features to be easily added
108
+
109
  = 2.8.4 - 2014-09-04 =
110
  * Updated spanish language files
111
  * Added compatibility with WP 4.0
324
 
325
  == Upgrade Notice ==
326
 
327
+ = 2.9.0 - 2014-12-09 =
328
+ * Change. Major code refactoring for future features to be easily added
329
+
330
  = 2.8.4 - 2014-09-04 =
331
  * Updated spanish language files
332
  * Added compatibility with WP 4.0
classes/class-cyclone-slider-admin.php DELETED
@@ -1,723 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Admin')):
3
-
4
- /**
5
- * Class for displaying cyclone admin screen
6
- */
7
- class Cyclone_Slider_Admin {
8
-
9
- protected $view; // Holds the instance of Cyclone_Slider_View
10
- public $slider_count;
11
- protected $message_id;
12
- protected $cyclone_slider_scripts; // Holds frontend scripts object
13
- protected $templates_manager; // Holds template manager object
14
- protected $cyclone_slider_data; // Holds cyclone slider data object
15
- protected $cyclone_settings_data; // Holds cyclone settings array
16
-
17
- /**
18
- * Initializes the plugin by setting localization, filters, and administration functions.
19
- */
20
- public function __construct( $view, $cyclone_slider_scripts, $cyclone_slider_templates_manager, $cyclone_slider_data, $cyclone_settings_data ) {
21
-
22
- $this->view = $view;
23
- $this->cyclone_slider_scripts = $cyclone_slider_scripts;
24
- $this->cyclone_slider_data = $cyclone_slider_data;
25
- $this->templates_manager = $cyclone_slider_templates_manager;
26
- $this->cyclone_settings_data = $cyclone_settings_data;
27
-
28
- // Set defaults
29
- $this->slider_count = 0;
30
-
31
- // Register admin styles and scripts
32
- add_action( 'admin_enqueue_scripts', array( $this->cyclone_slider_scripts, 'register_admin_scripts' ), 10);
33
-
34
- // Register frontend styles and scripts
35
- add_action( 'admin_enqueue_scripts', array( $this->cyclone_slider_scripts, 'register_frontend_scripts_in_admin' ), 100 );
36
-
37
- // Add admin menus
38
- add_action( 'init', array( $this, 'create_post_types' ) );
39
-
40
- // Change admin menu icon
41
- add_action( 'admin_init', array( $this, 'change_admin_menu_icon' ) );
42
-
43
- // Update the messages for our custom post make it appropriate for slideshow
44
- add_filter('post_updated_messages', array( $this, 'post_updated_messages' ) );
45
-
46
- // Remove metaboxes
47
- add_action( 'admin_menu', array( $this, 'remove_meta_boxes' ) );
48
-
49
- // Add slider metaboxes
50
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
51
-
52
- // Hacky way to change text in thickbox
53
- add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 10, 3 );
54
-
55
- // Modify html of image
56
- add_filter( 'image_send_to_editor', array( $this, 'image_send_to_editor'), 1, 8 );
57
-
58
- // Custom columns
59
- add_action( 'manage_cycloneslider_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
60
- add_filter( 'manage_edit-cycloneslider_columns', array( $this, 'slideshow_columns') );
61
-
62
- // Add hook for admin footer
63
- add_action('admin_footer', array( $this, 'admin_footer') );
64
-
65
- // Add body css for custom styling when on our page
66
- add_filter('admin_body_class', array( $this, 'body_class' ) );
67
-
68
-
69
- // Add hook for ajax operations if logged in
70
- add_action( 'wp_ajax_cycloneslider_get_video', array( $this, 'cycloneslider_get_video' ) );
71
-
72
-
73
- $version = get_option('cycloneslider_version');
74
-
75
- } // end constructor
76
-
77
- /**
78
- * Add js and css for WP media manager.
79
- */
80
- function body_class( $classes ) {
81
- if('cycloneslider' == get_post_type()){
82
- $classes .= 'cycloneslider';
83
- }
84
- return $classes;
85
- }
86
-
87
- /**
88
- * Create Post Types
89
- *
90
- * Create custom post for slideshows
91
- */
92
- public function create_post_types() {
93
- register_post_type( 'cycloneslider',
94
- array(
95
- 'labels' => array(
96
- 'name' => __('Cyclone Slider', 'cycloneslider'),
97
- 'singular_name' => __('Slideshow', 'cycloneslider'),
98
- 'add_new' => __('Add Slideshow', 'cycloneslider'),
99
- 'add_new_item' => __('Add New Slideshow', 'cycloneslider'),
100
- 'edit_item' => __('Edit Slideshow', 'cycloneslider'),
101
- 'new_item' => __('New Slideshow', 'cycloneslider'),
102
- 'view_item' => __('View Slideshow', 'cycloneslider'),
103
- 'search_items' => __('Search Slideshows', 'cycloneslider'),
104
- 'not_found' => __('No slideshows found', 'cycloneslider'),
105
- 'not_found_in_trash' => __('No slideshows found in Trash', 'cycloneslider')
106
- ),
107
- 'supports' => array('title'),
108
- 'public' => false,
109
- 'exclude_from_search' => true,
110
- 'show_ui' => true,
111
- 'menu_position' => 100,
112
- 'can_export' => false // Exclude from export
113
- )
114
- );
115
- }
116
-
117
- /**
118
- * Change Icon
119
- */
120
- public function change_admin_menu_icon() {
121
-
122
- global $menu, $wp_version;
123
-
124
- if(!isset($menu) and !is_array($menu)) {
125
- return false; // Abort
126
- }
127
-
128
- foreach( $menu as $key => $value ) {
129
- if( 'edit.php?post_type=cycloneslider' == $value[2] ) {
130
- if ( version_compare( $wp_version, '3.9', '<' ) ) { // WP 3.8 and below
131
- $menu[$key][4] = str_replace('menu-icon-post', 'menu-icon-media', $menu[$key][4]);
132
- } else { // WP 3.9+
133
- $menu[$key][6] = 'dashicons-format-gallery';
134
- }
135
-
136
- }
137
- }
138
- }
139
-
140
- /**
141
- * Add custom messages
142
- *
143
- * @return array Messages for cyclone
144
- */
145
- public function post_updated_messages($messages){
146
- global $post, $post_ID;
147
- $messages['cycloneslider'] = array(
148
- 0 => '',
149
- 1 => __( 'Slideshow updated.', 'cycloneslider' ),
150
- 2 => __( 'Custom field updated.', 'cycloneslider' ),
151
- 3 => __( 'Custom field deleted.', 'cycloneslider' ),
152
- 4 => __( 'Slideshow updated.', 'cycloneslider' ),
153
- 5 => __( 'Slideshow updated.', 'cycloneslider' ),
154
- 6 => __( 'Slideshow published.', 'cycloneslider' ),
155
- 7 => __( 'Slideshow saved.', 'cycloneslider' ),
156
- 8 => __( 'Slideshow updated.', 'cycloneslider' ),
157
- 9 => __( 'Slideshow updated.', 'cycloneslider' ),
158
- 10 => __( 'Slideshow updated.', 'cycloneslider' ),
159
- 101 => sprintf( __( 'Templates CSS could not be saved. Make sure %stemplates.css is writable.', 'cycloneslider' ), CYCLONE_PATH.'css'.DIRECTORY_SEPARATOR),
160
- 102 => sprintf( __( 'Templates JS could not be saved. Make sure %stemplates.js is writable.', 'cycloneslider' ), CYCLONE_PATH.'js'.DIRECTORY_SEPARATOR)
161
- );
162
- return $messages;
163
- }
164
-
165
- /**
166
- * Show custom messages
167
- *
168
- * @return array The array of locations containing path and url
169
- */
170
- public function throw_message($location) {
171
- $location = add_query_arg( 'message', $this->message_id, $location );
172
- $this->message_id = 0;
173
- return $location;
174
- }
175
-
176
- /**
177
- * Remove Meta Boxes
178
- *
179
- * Remove built-in metaboxes from our custom post type
180
- */
181
- public function remove_meta_boxes(){
182
- remove_meta_box('slugdiv', 'cycloneslider', 'normal');
183
- }
184
-
185
- /**
186
- * Add Meta Boxes
187
- *
188
- * Add custom metaboxes to our custom post type
189
- */
190
- public function add_meta_boxes(){
191
-
192
- add_meta_box(
193
- 'cyclone-slides-metabox',
194
- __('Slides', 'cycloneslider'),
195
- array( $this, 'render_slides_meta_box' ),
196
- 'cycloneslider' ,
197
- 'normal',
198
- 'high'
199
- );
200
-
201
- add_meta_box(
202
- 'cyclone-slider-preview-metabox',
203
- __('Slider Preview', 'cycloneslider'),
204
- array( $this, 'render_slider_preview_meta_box' ),
205
- 'cycloneslider' ,
206
- 'side',
207
- 'high'
208
- );
209
-
210
- add_meta_box(
211
- 'cyclone-slider-codes',
212
- __('Get Slider Codes', 'cycloneslider'),
213
- array( $this, 'render_slider_codes' ),
214
- 'cycloneslider' ,
215
- 'side',
216
- 'low'
217
- );
218
-
219
- add_meta_box(
220
- 'cyclone-slider-properties-metabox',
221
- __('Basic Settings', 'cycloneslider'),
222
- array( $this, 'render_slider_properties_meta_box' ),
223
- 'cycloneslider' ,
224
- 'side',
225
- 'low'
226
- );
227
-
228
- add_meta_box(
229
- 'cyclone-slider-advanced-settings-metabox',
230
- __('Advanced Settings', 'cycloneslider'),
231
- array( $this, 'render_slider_advanced_settings_meta_box' ),
232
- 'cycloneslider' ,
233
- 'side',
234
- 'low'
235
- );
236
-
237
- add_meta_box(
238
- 'cyclone-slider-templates-metabox',
239
- __('Templates', 'cycloneslider'),
240
- array( $this, 'render_slider_templates_meta_box' ),
241
- 'cycloneslider' ,
242
- 'normal',
243
- 'low'
244
- );
245
-
246
- add_meta_box(
247
- 'cyclone-slider-id',
248
- __('Slideshow ID', 'cycloneslider'),
249
- array( $this, 'render_slider_id' ),
250
- 'cycloneslider' ,
251
- 'normal',
252
- 'low'
253
- );
254
- }
255
-
256
-
257
-
258
- /**
259
- * Metabox for slides
260
- */
261
- public function render_slides_meta_box($post){
262
-
263
- $slides_html = '';
264
-
265
- $slider_settings = $this->cyclone_slider_data->get_slider_settings( $post->ID );
266
- $slides = $this->cyclone_slider_data->get_slider_slides( $post->ID );
267
-
268
- if(is_array($slides) and count($slides)>0):
269
-
270
- $this->view->set_view_file( CYCLONE_PATH . 'views/slide-edit.php' );
271
-
272
- foreach($slides as $i=>$slide):
273
-
274
- $image_url = $this->get_slide_img_thumb($slide['id']);
275
- $image_url = apply_filters('cycloneslider_preview_url', $image_url, $slide);
276
- $box_title = __('Slide', 'cycloneslider').' '.($i+1);
277
- if( '' != trim($slide['title']) and 'image' == $slide['type'] ){
278
- $box_title = $box_title. ' - '.$slide['title'];
279
- }
280
- $box_title = apply_filters('cycloneslider_box_title', $box_title);
281
-
282
- $vars = array();
283
- $vars['i'] = $i;
284
- $vars['slider_settings'] = $slider_settings;
285
- $vars['slide'] = $slide;
286
- $vars['image_url'] = $image_url;
287
- $vars['box_title'] = $box_title;
288
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug($slide) : '';
289
- $vars['effects'] = $this->cyclone_slider_data->get_slide_effects();
290
-
291
- $this->view->set_vars( $vars );
292
-
293
- $slides_html .= $this->view->get_render();
294
-
295
- endforeach;
296
- endif;
297
-
298
- $this->view->set_view_file( CYCLONE_PATH . 'views/slides.php' );
299
-
300
- $vars = array();
301
- $vars['slides'] = $slides_html;
302
- $vars['post_id'] = $post->ID;
303
- $vars['nonce_name'] = $this->cyclone_slider_data->nonce_name;
304
- $vars['nonce'] = wp_create_nonce( $this->cyclone_slider_data->nonce_action );
305
-
306
- $this->view->set_vars( $vars );
307
- $this->view->render();
308
- }
309
-
310
- /**
311
- * Metabox for slider codes
312
- */
313
- public function render_slider_codes( $post ){
314
-
315
- $this->view->set_view_file( CYCLONE_PATH . 'views/slider-codes.php' );
316
-
317
- $vars = array();
318
- $vars['post'] = $post;
319
- if(empty($post->post_name)){
320
- $vars['shortcode'] = '';
321
- $vars['template_code'] = '';
322
- } else {
323
- $vars['shortcode'] = '[cycloneslider id="'.$post->post_name.'"]';
324
- $vars['template_code'] = '<?php if( function_exists(\'cyclone_slider\') ) cyclone_slider(\''.$post->post_name.'\'); ?>';
325
- }
326
- $this->view->set_vars( $vars );
327
- $this->view->render();
328
-
329
- }
330
-
331
- /**
332
- * Metabox for basic settings
333
- */
334
- public function render_slider_properties_meta_box( $post ){
335
- $slider_settings = $this->cyclone_slider_data->get_slider_settings( $post->ID );
336
-
337
- $this->view->set_view_file( CYCLONE_PATH . 'views/slider-properties.php' );
338
-
339
- $vars = array();
340
- $vars['slider_settings'] = $slider_settings;
341
- $vars['effects'] = $this->cyclone_slider_data->get_slide_effects();
342
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug($slider_settings) : '';
343
-
344
- $this->view->set_vars( $vars );
345
- $this->view->render();
346
-
347
- }
348
-
349
- /**
350
- * Metabox for advanced settings
351
- */
352
- public function render_slider_advanced_settings_meta_box( $post ){
353
- $slider_settings = $this->cyclone_slider_data->get_slider_settings( $post->ID );
354
-
355
- $this->view->set_view_file( CYCLONE_PATH . 'views/slider-advanced-settings.php' );
356
-
357
- $vars = array();
358
- $vars['slider_settings'] = $slider_settings;
359
- $vars['easing_options'] = $this->cyclone_slider_data->get_jquery_easing_options();
360
- $vars['resize_options'] = $this->cyclone_slider_data->get_resize_options();
361
-
362
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug($slider_settings) : '';
363
-
364
- $this->view->set_vars( $vars );
365
- $this->view->render();
366
-
367
- }
368
-
369
-
370
- /**
371
- * Metabox for preview
372
- */
373
- public function render_slider_preview_meta_box($post){
374
-
375
- $this->view->set_view_file( CYCLONE_PATH . 'views/slider-preview.php' );
376
-
377
- $vars = array();
378
- $vars['post'] = $post;
379
- if(empty($post->post_name)){
380
- $vars['shortcode'] = '';
381
- $vars['template_code'] = '';
382
- } else {
383
- $vars['shortcode'] = '[cycloneslider id="'.$post->post_name.'"]';
384
- $vars['template_code'] = '<?php if( function_exists(\'cyclone_slider\') ) cyclone_slider(\''.$post->post_name.'\'); ?>';
385
- }
386
- $this->view->set_vars( $vars );
387
-
388
- $this->view->render();
389
- }
390
-
391
- /**
392
- * Metabox for templates
393
- */
394
- public function render_slider_templates_meta_box($post){
395
-
396
- $slider_settings = $this->cyclone_slider_data->get_slider_settings($post->ID);
397
- $templates = $this->templates_manager->get_all_templates();
398
- $active_templates = $this->templates_manager->get_active_templates( $this->cyclone_settings_data );
399
- ksort ( $templates ); // Sort assoc array alphabetically
400
- foreach($templates as $name=>$template){
401
- if( $name == $slider_settings['template'] ){
402
- $templates[$name]['selected'] = true;
403
- } else {
404
- $templates[$name]['selected'] = false;
405
- }
406
-
407
- if( file_exists($template['path'].'/screenshot.jpg') ) {
408
- $templates[$name]['screenshot'] = $template['url'].'/screenshot.jpg';
409
- } else {
410
- $templates[$name]['screenshot'] = CYCLONE_URL.'images/screenshot.png';
411
- }
412
-
413
- $templates[$name]['warning'] = '';
414
-
415
- if( $template['location_name'] == 'core' ){
416
- $templates[$name]['location_name'] = __('Core', 'cycloneslider');
417
- $templates[$name]['location_details'] = sprintf( __("Located inside the Cyclone Slider's templates directory:<br> <strong>%s</strong>", 'cycloneslider' ), $template['path']);
418
- }
419
- if( $template['location_name'] == 'active-theme' ){
420
- $templates[$name]['location_name'] = 'Active Theme';
421
- $templates[$name]['location_details'] = sprintf( __("Located inside your currently active theme:<br> <strong>%s</strong>", 'cycloneslider' ), $template['path']);
422
- $templates[$name]['warning'] = sprintf( __('Your template is in danger of being overwritten when you upgrade your theme. Please move it inside %s.', 'cycloneslider' ), 'wp-content/cycloneslider' );
423
- }
424
- if( $template['location_name'] == 'wp-content' ){
425
- $templates[$name]['location_name'] = 'WP Content';
426
- $templates[$name]['location_details'] = sprintf( __("Located inside wp-content directory:<br> <strong>%s</strong>", 'cycloneslider'), $template['path'] );
427
- }
428
-
429
- // Remove inactive templates
430
- if($active_templates[$name]==0){
431
- unset($templates[$name]);
432
- }
433
- }
434
-
435
- $this->view->set_view_file( CYCLONE_PATH . 'views/template-selection.php' );
436
-
437
- $vars = array();
438
- $vars['slider_settings'] = $slider_settings;
439
- $vars['templates'] = $templates;
440
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug($templates) : '';
441
-
442
- $this->view->set_vars( $vars );
443
- $this->view->render();
444
- }
445
-
446
- /**
447
- * Metabox for slider ID
448
- */
449
- public function render_slider_id( $post ){
450
-
451
- $this->view->set_view_file( CYCLONE_PATH . 'views/slider-id.php' );
452
-
453
- $vars = array();
454
- $vars['post_name'] = $post->post_name;
455
-
456
- $this->view->set_vars( $vars );
457
- $this->view->render();
458
-
459
- }
460
-
461
- /**
462
- * Hook to admin footer
463
- */
464
- public function admin_footer() {
465
- // JS skeleton for adding a slide
466
- if(get_post_type()=='cycloneslider'){
467
- // Empty Slide
468
- $this->view->set_view_file( CYCLONE_PATH . 'views/slide-edit.php' );
469
-
470
- $vars = array();
471
- $vars['box_title'] = __('Slide *', 'cycloneslider');
472
- $vars['image_url'] = '';
473
- $vars['i'] = '{id}';
474
- $vars['slide'] = $this->cyclone_slider_data->get_slide_defaults();
475
- foreach($vars['slide'] as $key=>$value){
476
- $vars['slide'][$key] = '';
477
- }
478
- $vars['slide']['type'] = 'image';
479
- $vars['effects'] = $this->cyclone_slider_data->get_slide_effects();
480
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug($vars['slide']) : '';
481
- $this->view->set_vars( $vars );
482
- $empty_slide = $this->view->get_render();
483
-
484
- // Main skeleton container
485
- $this->view->set_view_file( CYCLONE_PATH . 'views/slides-skeleton.php' );
486
-
487
- $vars = array();
488
- $vars['empty_slide'] = $empty_slide;
489
-
490
- $this->view->set_vars( $vars );
491
- $this->view->render();
492
- }
493
- }
494
-
495
-
496
- /**
497
- * Get slide image thumb from id. False on fail
498
- */
499
- private function get_slide_img_thumb($attachment_id){
500
- $attachment_id = (int) $attachment_id;
501
- if($attachment_id > 0){
502
- $image_url = wp_get_attachment_image_src( $attachment_id, 'medium', true );
503
- $image_url = (is_array($image_url)) ? $image_url[0] : '';
504
- return $image_url;
505
- }
506
- return false;
507
- }
508
-
509
- /**
510
- * Replace text in media button for WP < 3.5
511
- */
512
- public function replace_text_in_thickbox($translation, $text, $domain ) {
513
- $http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
514
- $req_referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
515
- if(strpos($http_referrer, 'cycloneslider')!==false or $req_referrer=='cycloneslider') {
516
- if ( 'default' == $domain and 'Insert into Post' == $text )
517
- {
518
- return 'Add to Slide';
519
- }
520
- }
521
- return $translation;
522
- }
523
-
524
- // Add attachment ID as html5 data attr in thickbox
525
- public function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ){
526
- if(strpos($html, '<img data-id="')===false){
527
- $html = str_replace('<img', '<img data-id="'.$id.'" ', $html);
528
- }
529
- return $html;
530
- }
531
-
532
- // Modify columns
533
- public function slideshow_columns($columns) {
534
- $columns = array();
535
- $columns['title']= __('Slideshow Name', 'cycloneslider');
536
- $columns['template']= __('Template', 'cycloneslider');
537
- $columns['images']= __('No. of Slides', 'cycloneslider');
538
- $columns['id']= __('Slideshow ID', 'cycloneslider');
539
- $columns['shortcode']= __('Shortcode', 'cycloneslider');
540
- return $columns;
541
- }
542
-
543
- // Add content to custom columns
544
- public function custom_column( $column_name, $post_id ){
545
- if ($column_name == 'template') {
546
- $settings = $this->cyclone_slider_data->get_slider_settings($post_id);
547
- echo ucwords($settings['template']);
548
- }
549
- if ($column_name == 'images') {
550
- echo '<div style="text-align:center; max-width:40px;">' . $this->cyclone_slider_data->get_slide_count( $post_id ) . '</div>';
551
- }
552
- if ($column_name == 'id') {
553
- $post = get_post($post_id);
554
- echo $post->post_name;
555
- }
556
- if ($column_name == 'shortcode') {
557
- $post = get_post($post_id);
558
- echo '[cycloneslider id="'.$post->post_name.'"]';
559
- }
560
- }
561
-
562
-
563
-
564
- // Compare the value from admin and shortcode. If shortcode value is present and not empty, use it, otherwise return admin value
565
- public function get_comp_slider_setting($admin_val, $shortcode_val){
566
- if($shortcode_val!==null){//make sure its really null and not just int zero 0
567
- return $shortcode_val;
568
- }
569
- return $admin_val;
570
- }
571
-
572
- // Return array of slide urls from meta
573
- public function get_slides_from_meta($slider_metas){
574
- $slides = array();
575
- if(is_array($slider_metas)){
576
- foreach($slider_metas as $slider_meta){
577
- $attachment_id = (int) $slider_meta['id'];
578
- $image_url = wp_get_attachment_url($attachment_id);
579
- $image_url = ($image_url===false) ? '' : $image_url;
580
- $slides[] = $image_url;
581
- }
582
- }
583
- return $slides;
584
- }
585
-
586
-
587
- /**
588
- * YOUTUBE & VIMEO
589
- */
590
-
591
- /**
592
- * Ajax for getting videos
593
- */
594
- public function cycloneslider_get_video(){
595
- $url = $_POST['url'];
596
-
597
- $retval = array(
598
- 'success' => false
599
- );
600
-
601
- if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
602
-
603
- if( $video_id = $this->get_youtube_id($url) ){ //If youtube url
604
- if( $embed = wp_oembed_get($url) ){ //Get embed, false on fail
605
- $retval = array(
606
- 'success' => true,
607
- 'url' => $this->get_youtube_thumb($video_id),
608
- 'embed' => $embed
609
- );
610
- }
611
-
612
- } else if( $video_id = $this->get_vimeo_id($url) ){ //If vimeo url
613
- if( $embed = wp_oembed_get($url) ){ //Get embed, false on fail
614
- $retval = array(
615
- 'success' => true,
616
- 'url' => $this->get_vimeo_thumb($video_id),
617
- 'embed' => $embed
618
- );
619
- }
620
- }
621
- }
622
-
623
- echo json_encode($retval);
624
- die();
625
- }
626
-
627
- /**
628
- * Get video thumb url
629
- *
630
- * @param string $url A valid youtube or vimeo url
631
- */
632
- public function get_video_thumb_from_url($url){
633
- $url = esc_url_raw($url);
634
-
635
- if ( $video_id = $this->get_youtube_id($url) ) { // A youtube url
636
-
637
- return $this->get_youtube_thumb($video_id);
638
-
639
- } else if( $video_id = $this->get_vimeo_id($url) ){ // A vimeo url
640
-
641
- return $this->get_vimeo_thumb($video_id);
642
- }
643
-
644
- return false;
645
- }
646
-
647
- /**
648
- * Return vimeo video id
649
- */
650
- public function get_vimeo_id($url){
651
-
652
- $parsed_url = parse_url($url);
653
- if ($parsed_url['host'] == 'vimeo.com'){
654
- $vimeo_id = ltrim( $parsed_url['path'], '/');
655
- if (is_numeric($vimeo_id)) {
656
- return $vimeo_id;
657
- }
658
- }
659
- return false;
660
- }
661
-
662
- /**
663
- * Get vimeo video thumbnail image
664
- *
665
- * @param int Vimeo ID.
666
- * @param string Size can be: thumbnail_small, thumbnail_medium, thumbnail_large.
667
- *
668
- * @return string URL of thumbnail image.
669
- */
670
- public function get_vimeo_thumb($video_id, $size = 'thumbnail_large'){
671
- $vimeo = unserialize( file_get_contents('http://vimeo.com/api/v2/video/'.$video_id.'.php') );
672
- if( isset($vimeo[0][$size]) ){
673
- return $vimeo[0][$size];
674
- }
675
- return '';
676
- }
677
-
678
- /**
679
- * Get youtube video thumbnail image
680
- *
681
- * @param int Youtube ID.
682
- *
683
- * @return string URL of thumbnail image.
684
- */
685
- public function get_youtube_thumb($video_id){
686
- return 'http://img.youtube.com/vi/'.$video_id.'/0.jpg';
687
- }
688
-
689
- /**
690
- * Get youtube ID from different url formats
691
- *
692
- * @param string $url Youtube url
693
- * @return string Youtube URL or boolean false on fail
694
- */
695
- public function get_youtube_id($url){
696
- if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
697
- return false;
698
- }
699
- $parsed_url = parse_url($url);
700
-
701
- if(strpos($parsed_url['host'], 'youtube.com')!==false){
702
- if(strpos($parsed_url['path'], '/watch')!==false){ // Regular url Eg. http://www.youtube.com/watch?v=9bZkp7q19f0
703
- parse_str($parsed_url['query'], $parsed_str);
704
- if(isset($parsed_str['v']) and !empty($parsed_str['v'])){
705
- return $parsed_str['v'];
706
- }
707
- } else if(strpos($parsed_url['path'], '/v/')!==false){ // "v" URL http://www.youtube.com/v/9bZkp7q19f0?version=3&autohide=1
708
- $id = str_replace('/v/','',$parsed_url['path']);
709
- if( !empty($id) ){
710
- return $id;
711
- }
712
- } else if(strpos($parsed_url['path'], '/embed/')!==false){ // Embed URL: http://www.youtube.com/embed/9bZkp7q19f0
713
- return str_replace('/embed/','',$parsed_url['path']);
714
- }
715
- } else if(strpos($parsed_url['host'], 'youtu.be')!==false){ // Shortened URL: http://youtu.be/9bZkp7q19f0
716
- return str_replace('/','',$parsed_url['path']);
717
- }
718
-
719
- return false;
720
- }
721
- } // end class
722
-
723
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-data.php DELETED
@@ -1,611 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Data')):
3
-
4
- /**
5
- * Class for saving and getting slider data
6
- */
7
- class Cyclone_Slider_Data {
8
-
9
- public $nonce_name;
10
- public $nonce_action;
11
- private $cyclone_slider_image_resizer;
12
-
13
- /**
14
- * Initializes the class
15
- */
16
- public function __construct( $cyclone_slider_image_resizer ){
17
- $this->nonce_name = 'cyclone_slider_builder_nonce'; // Must match with the one in class-cyclone-slider-admin.php
18
- $this->nonce_action = 'cyclone-slider-save'; // Must match with the one in class-cyclone-slider-admin.php
19
-
20
- $this->cyclone_slider_image_resizer = $cyclone_slider_image_resizer;
21
-
22
- // Save slides
23
- add_action( 'save_post', array( $this, 'save_slider_post' ) );
24
- }
25
-
26
- /**
27
- * Save post hook
28
- */
29
- public function save_slider_post( $post_id ){
30
- global $cyclone_slider_saved_done;
31
-
32
- // Stop! We have already saved..
33
- if($cyclone_slider_saved_done){
34
- return $post_id;
35
- }
36
-
37
- // Verify nonce
38
- $nonce_name = $this->nonce_name;
39
- if (!empty($_POST[$nonce_name])) {
40
- if (!wp_verify_nonce($_POST[$nonce_name], $this->nonce_action)) {
41
- return $post_id;
42
- }
43
- } else {
44
- return $post_id; // Make sure we cancel on missing nonce!
45
- }
46
-
47
- // Check autosave
48
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
49
- return $post_id;
50
- }
51
-
52
- // Resize images if needed
53
- if($_POST['cycloneslider_settings']['resize'] == 1){
54
- $this->cyclone_slider_image_resizer->resize_images( $_POST['cycloneslider_settings'], $_POST['cycloneslider_metas'] );
55
-
56
- }
57
-
58
- // Save slides
59
- $this->add_slider_slides( $post_id, $_POST['cycloneslider_metas'] );
60
-
61
- // Save slider settings
62
- $this->add_slider_settings( $post_id, $_POST['cycloneslider_settings']);
63
-
64
- // Marked as done
65
- $cyclone_slider_saved_done = true;
66
- }
67
-
68
- /**
69
- * API to add slider
70
- */
71
- public function add_slider( $post_title, $slider_settings, $slides ){
72
- global $cyclone_slider_saved_done;
73
-
74
- $cyclone_slider_saved_done= true; // Prevent double whammy!
75
-
76
- $post_data = array(
77
- 'post_type' => 'cycloneslider',
78
- 'post_title' => $post_title,
79
- 'post_content' => '',
80
- 'post_status' => 'publish'
81
- );
82
-
83
- if( $slider_id = wp_insert_post( $post_data ) ){
84
-
85
- // Resize images if needed
86
- if( $slider_settings['resize'] == 1){
87
- $this->cyclone_slider_image_resizer->resize_images( $slider_settings, $slides );
88
- }
89
-
90
- // Save slides
91
- $this->add_slider_slides( $slider_id, $slides );
92
-
93
- // Save slider settings
94
- $this->add_slider_settings( $slider_id, $slider_settings );
95
- }
96
- }
97
-
98
- /**
99
- * Add Slide Settings
100
- *
101
- * API to add slider settings to slider post meta
102
- *
103
- * @param int $slider_id Slider post ID
104
- * @param array $settings Slider settings array
105
- * @return void
106
- */
107
- public function add_slider_settings( $slider_id, $settings ){
108
- $settings = wp_parse_args(
109
- $settings,
110
- $this->get_slider_defaults()
111
- );
112
-
113
- $settings_to_save['template'] = sanitize_text_field( $settings['template'] );
114
- $settings_to_save['fx'] = sanitize_text_field( $settings['fx'] );
115
- $settings_to_save['timeout'] = (int) ( $settings['timeout'] );
116
- $settings_to_save['speed'] = (int) ( $settings['speed'] );
117
- $settings_to_save['width'] = (int) ( $settings['width'] );
118
- $settings_to_save['height'] = (int) ( $settings['height'] );
119
- $settings_to_save['hover_pause'] = sanitize_text_field( $settings['hover_pause'] );
120
- $settings_to_save['show_prev_next'] = (int) ( $settings['show_prev_next'] );
121
- $settings_to_save['show_nav'] = (int) ( $settings['show_nav'] );
122
- $settings_to_save['tile_count'] = (int) ( $settings['tile_count'] );
123
- $settings_to_save['tile_delay'] = (int) ( $settings['tile_delay'] );
124
- $settings_to_save['tile_vertical'] = sanitize_text_field( $settings['tile_vertical'] );
125
- $settings_to_save['random'] = (int) ( $settings['random'] );
126
- $settings_to_save['resize'] = (int) ( $settings['resize'] );
127
- $settings_to_save['width_management'] = sanitize_text_field( $settings['width_management'] );
128
-
129
- $settings_to_save = apply_filters('cycloneslider_settings', $settings_to_save, $slider_id); // Apply filters before saving
130
-
131
- delete_post_meta($slider_id, '_cycloneslider_settings');
132
- update_post_meta($slider_id, '_cycloneslider_settings', $settings_to_save);
133
- }
134
-
135
- /**
136
- * Add Slider Slides
137
- *
138
- * API to add slides
139
- *
140
- * @param int $slider_id Slider post ID
141
- * @param array $slides Slides array
142
- * @return void
143
- */
144
- public function add_slider_slides( $slider_id, $slides ){
145
-
146
- $slides_to_save = array();
147
-
148
- if( is_array($slides) ){
149
-
150
- $i=0;//always start from 0
151
- foreach($slides as $slide){
152
- $slide = wp_parse_args(
153
- $slide,
154
- $this->get_slide_defaults()
155
- );
156
- $slides_to_save[$i]['id'] = (int) ($slide['id']);
157
- $slides_to_save[$i]['type'] = sanitize_text_field($slide['type']);
158
-
159
- $slides_to_save[$i]['link'] = esc_url_raw($slide['link']);
160
- $slides_to_save[$i]['title'] = wp_kses_post($slide['title']);
161
- $slides_to_save[$i]['description'] = wp_kses_post($slide['description']);
162
- $slides_to_save[$i]['link_target'] = sanitize_text_field($slide['link_target']);
163
-
164
- $slides_to_save[$i]['img_alt'] = sanitize_text_field($slide['img_alt']);
165
- $slides_to_save[$i]['img_title'] = sanitize_text_field($slide['img_title']);
166
-
167
- $slides_to_save[$i]['enable_slide_effects'] = (int) ($slide['enable_slide_effects']);
168
- $slides_to_save[$i]['fx'] = sanitize_text_field($slide['fx']);
169
- $slides_to_save[$i]['speed'] = sanitize_text_field($slide['speed']);
170
- $slides_to_save[$i]['timeout'] = sanitize_text_field($slide['timeout']);
171
- $slides_to_save[$i]['tile_count'] = sanitize_text_field($slide['tile_count']);
172
- $slides_to_save[$i]['tile_delay'] = sanitize_text_field($slide['tile_delay']);
173
- $slides_to_save[$i]['tile_vertical'] = sanitize_text_field($slide['tile_vertical']);
174
-
175
- $slides_to_save[$i]['video_thumb'] = esc_url_raw($slide['video_thumb']);
176
- $slides_to_save[$i]['video_url'] = esc_url_raw($slide['video_url']);
177
- $slides_to_save[$i]['video'] = $slide['video'];
178
-
179
- $slides_to_save[$i]['custom'] = $slide['custom'];
180
-
181
- $slides_to_save[$i]['youtube_url'] = esc_url_raw($slide['youtube_url']);
182
- $slides_to_save[$i]['youtube_related'] = sanitize_text_field($slide['youtube_related']);
183
-
184
- $slides_to_save[$i]['vimeo_url'] = esc_url_raw($slide['vimeo_url']);
185
-
186
- $slides_to_save[$i]['testimonial'] = wp_kses_post($slide['testimonial']);
187
- $slides_to_save[$i]['testimonial_author'] = sanitize_text_field($slide['testimonial_author']);
188
- $slides_to_save[$i]['testimonial_link'] = esc_url_raw($slide['testimonial_link']);
189
- $slides_to_save[$i]['testimonial_link_target'] = sanitize_text_field($slide['testimonial_link_target']);
190
-
191
- $i++;
192
- }
193
-
194
- }
195
- $slides_to_save = apply_filters('cycloneslider_slides', $slides_to_save); //do filter before saving
196
-
197
- delete_post_meta($slider_id, '_cycloneslider_metas');
198
- update_post_meta($slider_id, '_cycloneslider_metas', $slides_to_save);
199
- }
200
-
201
-
202
-
203
- public function get_thumb_name( $image_file, $width, $height ){
204
-
205
- // Get image path info and create file name
206
- $info = pathinfo( $image_file ); // Eg: d:/uploads/image-1.jpg
207
- if( !isset($info['extension']) or !isset($info['filename'])){
208
- return false;
209
- }
210
-
211
- $ext = $info['extension']; // File extension Eg. "jpg"
212
- $filename = $info['filename']; // Filename Eg. "image-1"
213
- return "{$filename}-{$width}x{$height}.{$ext}"; // Thumbname. Eg. "image-1-600x300.jpg"
214
-
215
- }
216
-
217
- /**
218
- * Get Sliders
219
- *
220
- * Get all sliders and their accompanying meta data
221
- *
222
- * @return array|false The array of sliders post and their meta data or false on fail
223
- */
224
- public function get_sliders( $args=array() ){
225
- $defaults = array(
226
- 'post_type' => 'cycloneslider',
227
- 'numberposts' => -1 // Get all
228
- );
229
- $args = wp_parse_args($args, $defaults);
230
-
231
- $slider_posts = get_posts( $args ); // Use get_posts to avoid filters
232
- $sliders = array(); // Store it here
233
- if( !empty($slider_posts) and is_array($slider_posts) ){
234
- foreach($slider_posts as $index=>$slider_post){
235
- $sliders[$index] = (array) $slider_post;
236
- $sliders[$index]['slider_settings'] = $this->get_slider_settings( $slider_post->ID );
237
- $sliders[$index]['slides'] = $this->get_slider_slides( $slider_post->ID );
238
- }
239
- return $sliders;
240
- } else {
241
- return false;
242
- }
243
- }
244
-
245
- /**
246
- * Get Slider Settings
247
- *
248
- * Get slider settings by $slider_id
249
- *
250
- * @paramt int $slider_id ID of slider post
251
- * @return array The array of slider settings
252
- */
253
- public function get_slider_settings( $slider_id ) {
254
- $meta = get_post_custom( $slider_id );
255
- $slider_settings = array();
256
- if(isset($meta['_cycloneslider_settings'][0]) and !empty($meta['_cycloneslider_settings'][0])){
257
- $slider_settings = maybe_unserialize($meta['_cycloneslider_settings'][0]);
258
- }
259
- $slider_settings = wp_parse_args($slider_settings, $this->get_slider_defaults() );
260
- return apply_filters('cycloneslider_get_slider_settings', $slider_settings);
261
- }
262
-
263
- /**
264
- * Get Slider Slides
265
- *
266
- * @param int $slider_id Post ID of the slider custom post.
267
- * @return array The array of slides settings
268
- */
269
- public function get_slider_slides( $slider_id ){
270
- $meta = get_post_custom( $slider_id );
271
-
272
- if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){
273
- $slides = maybe_unserialize($meta['_cycloneslider_metas'][0]);
274
- $defaults = $this->get_slide_defaults();
275
-
276
- foreach($slides as $i=>$slide){
277
- $slides[$i] = wp_parse_args($slide, $defaults);
278
- }
279
-
280
- return apply_filters('cycloneslider_get_slider_slides', $slides);
281
- }
282
- return false;
283
- }
284
-
285
- /**
286
- * Get Slider by Slug
287
- *
288
- * @param string $slug Post slug of the slider custom post.
289
- * @return array|false The array of slider post and associated meta or false if none found
290
- */
291
- public function get_slider_by_slug( $slug ) {
292
- // Get slider by id
293
- $args = array(
294
- 'post_type' => 'cycloneslider',
295
- 'numberposts' => 1,
296
- 'name'=> $slug
297
- );
298
-
299
- $slider_posts = get_posts( $args ); // Use get_posts to avoid filters
300
-
301
- $sliders = array(); // Store it here
302
- if( !empty($slider_posts) and is_array($slider_posts) ){
303
- foreach($slider_posts as $index=>$slider_post){
304
- $sliders[$index] = (array) $slider_post;
305
- $sliders[$index]['slider_settings'] = $this->get_slider_settings( $slider_post->ID );
306
- $sliders[$index]['slides'] = $this->get_slider_slides( $slider_post->ID );
307
- }
308
- return $sliders[0];
309
- }
310
-
311
- return false;
312
- }
313
-
314
- /**
315
- * Gets the number of slides of slideshow
316
- *
317
- * @param int $slider_id Post ID of slider custom post
318
- * @return int|0 Total images or zero
319
- */
320
- public function get_slide_count( $slider_id ){
321
- $meta = get_post_custom( $slider_id );
322
-
323
- if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){
324
- $slides = maybe_unserialize($meta['_cycloneslider_metas'][0]);
325
-
326
- return count($slides);
327
- }
328
- return 0;
329
- }
330
-
331
- /**
332
- * Get Slide Image URL
333
- */
334
- public function get_slide_image_url( $slide_image_id, $slider_settings ){
335
- $width = $slider_settings['width'];
336
- $height = $slider_settings['height'];
337
-
338
- // Get url to full image, its width and height
339
- $image_dimensions = wp_get_attachment_image_src($slide_image_id, 'full');
340
- if(!$image_dimensions){
341
- return false;
342
- }
343
-
344
- // Assign variables
345
- list($image_url, $orig_width, $orig_height) = $image_dimensions;
346
-
347
- // If orig image width and height is the same as slideshow width and height, do not resize and return url
348
- if($orig_width == $width and $orig_height == $height){
349
- return $image_url;
350
- }
351
-
352
- //If resize is no, return url
353
- if( isset( $slider_settings['resize'] ) and $slider_settings['resize'] == 0 ){
354
- return $image_url;
355
- }
356
-
357
- // Get full path to the slide image
358
- $image_file = get_attached_file($slide_image_id);
359
- if(empty($image_file)){
360
- return false;
361
- }
362
-
363
- $thumb_name = $this->get_thumb_name( $image_file, $width, $height );
364
- $thumb_url = dirname($image_url).'/'.$thumb_name; // URL to thumbnail
365
-
366
- return $thumb_url;
367
- }
368
-
369
- /**
370
- * Gets the slider default settings.
371
- *
372
- * @return array The array of slider defaults
373
- */
374
- public function get_slider_defaults(){
375
- return array(
376
- 'template' => 'standard',
377
- 'fx' => 'fade',
378
- 'timeout' => '4000',
379
- 'speed' => '1000',
380
- 'width' => '960',
381
- 'height' => '600',
382
- 'hover_pause' => 'true',
383
- 'show_prev_next' => '1',
384
- 'show_nav' => '1',
385
- 'tile_count' => '7',
386
- 'tile_delay' => '100',
387
- 'tile_vertical' => 'true',
388
- 'random' => 0,
389
- 'resize' => 1,
390
- 'width_management' => 'responsive',
391
- 'resize_option' => 'auto',
392
- 'easing' => '',
393
- 'allow_wrap' => 'true',
394
- 'dynamic_height' => 'off',
395
- 'delay' => 0,
396
- 'swipe' => 'false'
397
- );
398
- }
399
-
400
- /**
401
- * Gets the slide default settings.
402
- *
403
- * @return array The array of slide defaults
404
- */
405
- public function get_slide_defaults(){
406
- return array(
407
- 'enable_slide_effects'=>0,
408
- 'type' => 'image',
409
- 'id' => '',
410
- 'link' => '',
411
- 'title' => '',
412
- 'description' => '',
413
- 'link_target' => '_self',
414
- 'fx' => 'default',
415
- 'speed' => '',
416
- 'timeout' => '',
417
- 'tile_count' => '7',
418
- 'tile_delay' => '100',
419
- 'tile_vertical' => 'true',
420
- 'img_alt' => '',
421
- 'img_title' => '',
422
-
423
- 'video_thumb' => '',
424
- 'video_url' => '',
425
- 'video' => '',
426
-
427
- 'custom' => '',
428
-
429
- 'youtube_url' => '',
430
- 'youtube_related' => 'false',
431
-
432
- 'vimeo_url' => '',
433
-
434
- 'testimonial' => '',
435
- 'testimonial_author' => '',
436
- 'testimonial_link' => '',
437
- 'testimonial_link_target' => '_self'
438
- );
439
- }
440
-
441
- /**
442
- * Get Resize Options
443
- *
444
- * @return array The array of resize options in a key-value pair
445
- */
446
- public function get_resize_options(){
447
- return array(
448
- 'auto' => 'Auto',
449
- 'crop' => 'Crop',
450
- 'exact' => 'Exact',
451
- 'landscape' => 'Landscape',
452
- 'portrait' => 'Portrait'
453
- );
454
- }
455
-
456
- /**
457
- * Gets the slide effects.
458
- *
459
- * @return array The array of supported slide effects
460
- */
461
- public function get_slide_effects(){
462
- return array(
463
- 'fade'=>'Fade',
464
- 'fadeout'=>'Fade Out',
465
- 'none'=>'None',
466
- 'scrollHorz'=>'Scroll Horizontally',
467
- 'tileBlind'=>'Tile Blind',
468
- 'tileSlide'=>'Tile Slide'
469
- );
470
- }
471
-
472
- /**
473
- * Get array of jquery easing options
474
- *
475
- * @return array Easing options
476
- */
477
- public function get_jquery_easing_options(){
478
- return array(
479
- array(
480
- 'text' => 'Default',
481
- 'value' => ''
482
- ),
483
- array(
484
- 'text' => 'Swing',
485
- 'value' => 'swing'
486
- ),
487
- array(
488
- 'text' => 'Ease-In Quad',
489
- 'value' => 'easeInQuad'
490
- ),
491
- array(
492
- 'text' => 'Ease-Out Quad',
493
- 'value' => 'easeOutQuad'
494
- ),
495
- array(
496
- 'text' => 'Ease-In OutQuad',
497
- 'value' => 'easeInOutQuad'
498
- ),
499
- array(
500
- 'text' => 'Ease-In Cubic',
501
- 'value' => 'easeInCubic'
502
- ),
503
- array(
504
- 'text' => 'Ease-Out Cubic',
505
- 'value' => 'easeOutCubic'
506
- ),
507
- array(
508
- 'text' => 'Ease-In OutCubic',
509
- 'value' => 'easeInOutCubic'
510
- ),
511
- array(
512
- 'text' => 'Ease-In Quart',
513
- 'value' => 'easeInQuart'
514
- ),
515
- array(
516
- 'text' => 'Ease-Out Quart',
517
- 'value' => 'easeOutQuart'
518
- ),
519
- array(
520
- 'text' => 'Ease-In OutQuart',
521
- 'value' => 'easeInOutQuart'
522
- ),
523
- array(
524
- 'text' => 'Ease-In Quint',
525
- 'value' => 'easeInQuint'
526
- ),
527
- array(
528
- 'text' => 'Ease-Out Quint',
529
- 'value' => 'easeOutQuint'
530
- ),
531
- array(
532
- 'text' => 'Ease-In OutQuint',
533
- 'value' => 'easeInOutQuint'
534
- ),
535
- array(
536
- 'text' => 'Ease-In Sine',
537
- 'value' => 'easeInSine'
538
- ),
539
- array(
540
- 'text' => 'Ease-Out Sine',
541
- 'value' => 'easeOutSine'
542
- ),
543
- array(
544
- 'text' => 'Ease-In OutSine',
545
- 'value' => 'easeInOutSine'
546
- ),
547
- array(
548
- 'text' => 'Ease-In Expo',
549
- 'value' => 'easeInExpo'
550
- ),
551
- array(
552
- 'text' => 'Ease-Out Expo',
553
- 'value' => 'easeOutExpo'
554
- ),
555
- array(
556
- 'text' => 'Ease-In OutExpo',
557
- 'value' => 'easeInOutExpo'
558
- ),
559
- array(
560
- 'text' => 'Ease-In Circ',
561
- 'value' => 'easeInCirc'
562
- ),
563
- array(
564
- 'text' => 'Ease-Out Circ',
565
- 'value' => 'easeOutCirc'
566
- ),
567
- array(
568
- 'text' => 'Ease-In OutCirc',
569
- 'value' => 'easeInOutCirc'
570
- ),
571
- array(
572
- 'text' => 'Ease-In Elastic',
573
- 'value' => 'easeInElastic'
574
- ),
575
- array(
576
- 'text' => 'Ease-Out Elastic',
577
- 'value' => 'easeOutElastic'
578
- ),
579
- array(
580
- 'text' => 'Ease-In OutElastic',
581
- 'value' => 'easeInOutElastic'
582
- ),
583
- array(
584
- 'text' => 'Ease-In Back',
585
- 'value' => 'easeInBack'
586
- ),
587
- array(
588
- 'text' => 'Ease-Out Back',
589
- 'value' => 'easeOutBack'
590
- ),
591
- array(
592
- 'text' => 'Ease-In OutBack',
593
- 'value' => 'easeInOutBack'
594
- ),
595
- array(
596
- 'text' => 'Ease-In Bounce',
597
- 'value' => 'easeInBounce'
598
- ),
599
- array(
600
- 'text' => 'Ease-Out Bounce',
601
- 'value' => 'easeOutBounce'
602
- ),
603
- array(
604
- 'text' => 'Ease-In OutBounce',
605
- 'value' => 'easeInOutBounce'
606
- )
607
- );
608
- }
609
- }
610
-
611
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-export-page.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Export_Page') and class_exists('Codefleet_Admin_Sub_Page')):
3
-
4
- /**
5
- * Class for wrapping WP add_submenu_page.
6
- */
7
- class Cyclone_Slider_Export_Page extends Codefleet_Admin_Sub_Page {
8
- protected $view;
9
- protected $exporter;
10
- protected $cyclone_slider_data; // Holds cyclone slider data object
11
-
12
- public function __construct( $view, $exporter, $cyclone_slider_data ) {
13
- parent::__construct();
14
- $this->view = $view;
15
- $this->exporter = $exporter;
16
- $this->cyclone_slider_data = $cyclone_slider_data;
17
-
18
- add_action('init', array( $this, 'catch_posts') );
19
- }
20
-
21
- public function catch_posts(){
22
- // Verify nonce
23
- if( isset($_POST[$this->cyclone_slider_data->nonce_name]) ){
24
- $nonce = $_POST[$this->cyclone_slider_data->nonce_name];
25
- if ( wp_verify_nonce( $nonce, $this->cyclone_slider_data->nonce_action) ) {
26
-
27
- if( isset($_POST['cycloneslider_export_step']) ){
28
- if( $_POST['cycloneslider_export_step'] == 1 ){
29
- $cyclone_export = array();
30
- if( isset($_POST['cycloneslider_export']) ){
31
- if(!empty($_POST['cycloneslider_export'])){
32
- $cyclone_export = $_POST['cycloneslider_export'];
33
- update_option('cycloneslider_export', $cyclone_export);
34
- wp_redirect( get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export&step=2') );
35
- exit;
36
- }
37
- }
38
- update_option('cycloneslider_export', $cyclone_export);
39
- }
40
- }
41
- }
42
- }
43
- }
44
-
45
- /**
46
- * Render page. This function should output the HTML of the page.
47
- */
48
- public function render_page( $post ){
49
- $current_step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
50
- if($current_step == 2){
51
- $this->step_2();
52
- } else {
53
- $this->step_1();
54
- }
55
- }
56
-
57
- public function step_1(){
58
- $cycloneslider_export = get_option('cycloneslider_export');
59
- $defaults = array(
60
- 'all' => 0,
61
- 'sliders' => array()
62
- );
63
- $cycloneslider_export = wp_parse_args($cycloneslider_export, $defaults);
64
-
65
- $this->view->set_view_file( CYCLONE_PATH . 'views/export-step-1.php' );
66
- $vars = array();
67
- $vars['sliders'] = $this->cyclone_slider_data->get_sliders();
68
- $vars['nonce_name'] = $this->cyclone_slider_data->nonce_name;
69
- $vars['nonce'] = wp_create_nonce( $this->cyclone_slider_data->nonce_action );
70
- $vars['cycloneslider_export'] = $cycloneslider_export;
71
- $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
72
- $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
73
- $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
74
- $this->view->set_vars( $vars );
75
- $this->view->render();
76
-
77
- }
78
-
79
- public function step_2(){
80
- $cycloneslider_export = get_option('cycloneslider_export');
81
- $defaults = array(
82
- 'all' => 0,
83
- 'sliders' => array()
84
- );
85
- $cycloneslider_export = wp_parse_args($cycloneslider_export, $defaults);
86
-
87
- $uploads = wp_upload_dir();
88
- $zip_file = $uploads['basedir'].'/cyclone-slider.zip';
89
-
90
- $this->exporter->export( $zip_file, $cycloneslider_export['sliders'] );
91
-
92
- $this->view->set_view_file( CYCLONE_PATH . 'views/export-step-2.php' );
93
- $vars = array();
94
- $vars['nonce_name'] = $this->cyclone_slider_data->nonce_name;
95
- $vars['nonce'] = wp_create_nonce( $this->cyclone_slider_data->nonce_action );
96
- $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export&step=3' );
97
- $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
98
- $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
99
- $vars['zip_url'] = $uploads['baseurl'].'/cyclone-slider.zip';
100
- $vars['log_results'] = $this->exporter->get_results();
101
- $this->view->set_vars( $vars );
102
- $this->view->render();
103
- }
104
- } // end class
105
-
106
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-exporter.php DELETED
@@ -1,269 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Exporter')):
3
-
4
- /**
5
- * Class for exporting cyclone-slider.zip
6
- */
7
- class Cyclone_Slider_Exporter {
8
- protected $log_results; // Hold results of import operations
9
- protected $log_count;
10
- protected $cyclone_slider_data;
11
-
12
- public function __construct( $cyclone_slider_data ) {
13
- $this->log_results = array(
14
- 'oks'=>array(),
15
- 'errors'=>array()
16
- );
17
- $this->log_count = 0;
18
- $this->cyclone_slider_data = $cyclone_slider_data;
19
- }
20
-
21
- /**
22
- * Get log results
23
- *
24
- */
25
- public function get_results(){
26
- return $this->log_results;
27
- }
28
-
29
- /**
30
- * Export
31
- *
32
- * Export main operation
33
- *
34
- * @param string $zip_file Full path and filename to zip file
35
- * @param array $sliders_slugs_array Array of slider slugs to export
36
- * @return void|false Do export or abort and return false on fail
37
- */
38
- public function export( $zip_file, array $sliders_slugs_array ) {
39
-
40
- // Check selected sliders
41
- if( empty($sliders_slugs_array) ){
42
- $this->add_error( 'Error no sliders selected' );
43
- return false;
44
- }
45
-
46
- // Generate sliders export data
47
- if( ($sliders_export_data = $this->generate_sliders_export_data( $sliders_slugs_array )) === false ){
48
- $this->add_error( 'Error generating sliders export data' );
49
- return false;
50
- }
51
-
52
- // Generate images lists
53
- if( ($images_list = $this->generate_images_list( $sliders_slugs_array )) === false ){
54
- $this->add_error( 'Error generating images list' );
55
- return false;
56
- }
57
-
58
- // Generate images export data
59
- if( ($images_export_data = $this->generate_images_export_data( $sliders_slugs_array )) === false ){
60
- $this->add_error( 'Error generating images export data' );
61
- return false;
62
- }
63
-
64
- // Combine
65
- $export_data = array(
66
- 'sliders' => $sliders_export_data,
67
- 'images' => $images_export_data
68
- );
69
- $this->add_ok( 'Success generating export data' );
70
-
71
- // Generate JSON
72
- if( ($export_json = $this->generate_json_data( $export_data )) === false ){
73
- $this->add_error( 'Error generating JSON data' );
74
- return false;
75
- }
76
- $this->add_ok( 'Success converting export data to JSON' );
77
-
78
- // Generate Zip
79
- if( $this->generate_export_zip( $zip_file, $images_list, $export_json ) === false ){
80
- $this->add_error( 'Error generating zip file' );
81
- return false;
82
- }
83
- $this->add_ok( 'Success generating zip file' );
84
-
85
- return true;
86
- }
87
-
88
- /**
89
- * Generate Sliders Export Data
90
- *
91
- * Generate export data array for selected sliders. Include slider settings and slides
92
- *
93
- * @param array $sliders_slugs_array Array of slider slugs to export
94
- * @return array|false Export data array or false on fail
95
- */
96
- private function generate_sliders_export_data( array $sliders_slugs_array ) {
97
-
98
- if( !empty( $sliders_slugs_array ) ){
99
- $sliders_export_data = array();
100
- foreach( $sliders_slugs_array as $i=>$slider_slug){
101
-
102
- $slider = $this->cyclone_slider_data->get_slider_by_slug( $slider_slug );
103
-
104
- if($slider){
105
- $sliders_export_data[$i] = array(
106
- 'title' => $slider['post_title'],
107
- 'name' => $slider['post_name'],
108
- 'slider_settings' => $slider['slider_settings'],
109
- 'slides' => $slider['slides']
110
- );
111
- $this->add_ok( sprintf('Exporting data for slider "%s"', $slider_slug) );
112
- } else {
113
- $this->add_error( sprintf('Slider "%s" not found', $slider_slug) );
114
- }
115
-
116
- }
117
- return $sliders_export_data;
118
- }
119
-
120
- return false;
121
- }
122
-
123
- /**
124
- * Generate Images List
125
- *
126
- * Generate image array for slider images
127
- *
128
- * @param array $sliders_slugs_array Array of slider slugs to export
129
- * @return array|false Export data array or false on fail
130
- */
131
- private function generate_images_list( array $sliders_slugs_array ) {
132
-
133
- if( !empty( $sliders_slugs_array ) ){
134
-
135
- $images_list = array();
136
-
137
- foreach( $sliders_slugs_array as $slider_slug){
138
- $slider = $this->cyclone_slider_data->get_slider_by_slug( $slider_slug );
139
- if($slider){
140
- if(isset($slider['slides'])){
141
- foreach($slider['slides'] as $i=>$slide){
142
- $images_list[$slider['post_name']][$i] = get_attached_file( $slide['id'] ); // Filename of image
143
- }
144
- }
145
- }
146
- }
147
-
148
- return $images_list;
149
- }
150
-
151
- return false;
152
- }
153
-
154
- /**
155
- * Generate Images Export Data
156
- *
157
- * Generate export data array for slider images
158
- *
159
- * @param array $sliders_slugs_array Array of slider slugs to export
160
- * @return array|false Export data array or false on fail
161
- */
162
- private function generate_images_export_data( array $sliders_slugs_array ) {
163
-
164
- if( !empty( $sliders_slugs_array ) ){
165
- $images_export_data = array();
166
- foreach( $sliders_slugs_array as $slider_slug){
167
-
168
- $slider = $this->cyclone_slider_data->get_slider_by_slug( $slider_slug );
169
-
170
- if($slider){
171
- if(isset($slider['slides'])){
172
- foreach($slider['slides'] as $i=>$slide){
173
- $images_export_data[$slider['post_name']][$i] = sanitize_file_name( wp_basename( get_attached_file( $slide['id'] ) ) ); // Filename of image
174
- }
175
- }
176
- }
177
- }
178
- return $images_export_data;
179
- }
180
-
181
- return false;
182
- }
183
-
184
- /**
185
- * Generate JSON Data
186
- *
187
- * Generate json data
188
- *
189
- * @param array $export_data Array of export data
190
- * @return string|false JSON data or false on fail
191
- */
192
- private function generate_json_data( array $export_data ) {
193
-
194
- if($export_data){
195
- // JSON encode
196
- if( $export_json = json_encode($export_data) ){
197
- return $export_json;
198
- }
199
- }
200
-
201
- return false;
202
- }
203
-
204
- /**
205
- * Generate Export Zip
206
- *
207
- * Generate export zip. Add images and export.json
208
- *
209
- * @param string $zip_file Zip file to save
210
- * @param array $images_list Array of image file paths to include in the zip
211
- * @param string $export_json JSON string to save
212
- * @return string|false JSON data or false on fail
213
- */
214
- private function generate_export_zip( $zip_file, array $images_list, $export_json ) {
215
-
216
- if( !class_exists('ZipArchive') ) {
217
- $this->add_error( 'ZipArchive not supported' );
218
- return false;
219
- }
220
- $zip = new ZipArchive();
221
-
222
- if ($zip->open($zip_file, ZIPARCHIVE::OVERWRITE)!==TRUE) {
223
- $this->add_error( 'Error opening zip file' );
224
- return false;
225
- }
226
-
227
- // Add slide images
228
- foreach($images_list as $a=>$sliders) {
229
- foreach($sliders as $b=>$image_file){
230
- if(!empty($image_file)){ // Non image slides
231
- $filename = sanitize_file_name( wp_basename( $image_file ) );
232
- if( $zip->addFile( $image_file, $filename ) === false ){
233
- $this->add_error( sprintf( 'Error adding file %s to zip', $filename ) );
234
- }
235
- }
236
- }
237
- }
238
-
239
- // Add json file
240
- $zip->addFromString("export.json", $export_json );
241
-
242
- $zip->close();
243
- return $zip_file;
244
- }
245
-
246
-
247
-
248
- /**
249
- * Add Ok
250
- *
251
- * @param string $message Message to add
252
- * @return void
253
- */
254
- private function add_ok( $message ){
255
- $this->log_results['oks'][$this->log_count++] = $message;
256
- }
257
-
258
- /**
259
- * Add Error
260
- *
261
- * @param string $message Message to add
262
- * @return void
263
- */
264
- private function add_error( $message ){
265
- $this->log_results['errors'][$this->log_count++] = $message;
266
- }
267
- }
268
-
269
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-image-editor.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Image_Editor')):
3
-
4
- /**
5
- * Class for editing images. Each instance handles a single file.
6
- */
7
- class Cyclone_Slider_Image_Editor {
8
- protected $file = ''; // Image file
9
- protected $quality = 90; // JPEG quality
10
- protected $image = false; // GD resource of image
11
- protected $width; // Image width
12
- protected $height; // Image height
13
- protected $size; // Array holding width and height of image
14
-
15
- // Resize constants
16
- const RESIZE_EXACT = 'exact';
17
- const RESIZE_PORTRAIT = 'portrait';
18
- const RESIZE_LANDSCAPE = 'landscape';
19
- const RESIZE_CROP = 'crop';
20
-
21
- /**
22
- * Assign file
23
- */
24
- public function __construct( $file ) {
25
-
26
- $this->file = $file;
27
-
28
- }
29
-
30
- public function __destruct() {
31
- if ( $this->image ) {
32
- // Free memory
33
- imagedestroy( $this->image );
34
- }
35
- }
36
-
37
- private function _get_file_ext( $file ){
38
- // Get extension
39
- $path_parts = pathinfo( $file );
40
-
41
- if( ! isset( $path_parts['extension'] ) )
42
- return false;
43
-
44
- if( $path_parts['extension'] == '' )
45
- return false;
46
-
47
- return strtolower( $path_parts['extension'] );
48
- }
49
-
50
- /**
51
- * Loads image resource from file
52
- *
53
- * @return resource|boolean GD resource on success; False on fail
54
- */
55
- public function load(){
56
-
57
- if ( ! is_file( $this->file ) )
58
- return false;
59
-
60
- // Get extension
61
- $extension = $this->_get_file_ext( $this->file );
62
-
63
- if( ! $extension )
64
- return false;
65
-
66
- if( $extension == 'jpg' or $extension == 'jpeg' ){
67
- $this->image = @imagecreatefromjpeg( $this->file );
68
-
69
- } else if( $extension == 'gif' ){
70
- $this->image = @imagecreatefromgif( $this->file );
71
-
72
- } else if( $extension == 'png' ){
73
- $this->image = @imagecreatefrompng( $this->file );
74
-
75
- }
76
-
77
- if ( ! is_resource( $this->image ) )
78
- return false;
79
-
80
- $this->update_size();
81
-
82
- return true;
83
- }
84
-
85
- /**
86
- * Sets or updates current image size.
87
- *
88
- * @param int $width
89
- * @param int $height
90
- */
91
- protected function update_size( $width = false, $height = false ) {
92
- if ( ! $width )
93
- $width = imagesx( $this->image );
94
-
95
- if ( ! $height )
96
- $height = imagesy( $this->image );
97
-
98
- $this->size = array(
99
- 'width' => (int) $width,
100
- 'height' => (int) $height
101
- );
102
- return true;
103
- }
104
-
105
- /**
106
- * Resize
107
- *
108
- * @param int $new_width
109
- * @param int $new_height
110
- * @param string $resize_option
111
- * @return void
112
- */
113
- public function resize( $new_width, $new_height, $resize_option="auto") {
114
- // Get current width and height
115
- list($orig_width, $orig_height) = array_values($this->size);
116
-
117
- // Get optimal width and height - based on $resize_option
118
- list($optimal_width, $optimal_height) = $this->get_optimal_dimension( $orig_width, $orig_height, $new_width, $new_height, $resize_option );
119
-
120
- // Resample - create image canvas of x, y size
121
- $image_resized = imagecreatetruecolor($optimal_width, $optimal_height);
122
- // Preserve PNG transparency start
123
- imagealphablending($image_resized, false);
124
- imagesavealpha($image_resized, true);
125
- $transparent = imagecolorallocatealpha($image_resized, 255, 255, 255, 127);
126
- imagefilledrectangle($image_resized, 0, 0, $optimal_width, $optimal_height, $transparent);
127
- // Preserve PNG transparency end
128
- imagecopyresampled($image_resized, $this->image, 0, 0, 0, 0, $optimal_width, $optimal_height, $orig_width, $orig_height);
129
-
130
- // Free memory
131
- imagedestroy( $this->image );
132
-
133
- // Assign
134
- $this->image = $image_resized;
135
- $this->update_size();
136
-
137
- // If option is 'crop', then crop too
138
- if ($resize_option == self::RESIZE_CROP) {
139
- $this->crop($optimal_width, $optimal_height, $new_width, $new_height);
140
- }
141
- }
142
-
143
- /**
144
- * Crop
145
- *
146
- * @param int $optimal_width
147
- * @param int $optimal_height
148
- * @param int $new_width
149
- * @param int $new_height
150
- * @param string $resize_option
151
- * @return void
152
- */
153
- public function crop($optimal_width, $optimal_height, $new_width, $new_height) {
154
- // Find center - this will be used for the crop
155
- $crop_start_x = ( $optimal_width / 2) - ( $new_width /2 );
156
- $crop_start_y = ( $optimal_height/ 2) - ( $new_height/2 );
157
-
158
- // Now crop from center to exact requested size
159
- $image_resized = imagecreatetruecolor($new_width , $new_height);
160
- imagecopyresampled($image_resized, $this->image , 0, 0, $crop_start_x, $crop_start_y, $new_width, $new_height , $new_width, $new_height);
161
-
162
- // Free memory
163
- imagedestroy( $this->image );
164
-
165
- // Assign
166
- $this->image = $image_resized;
167
- $this->update_size();
168
- }
169
-
170
- /**
171
- * Save
172
- */
173
- public function save($filename, $image_quality="100") {
174
- // Get extension
175
- $extension = $this->_get_file_ext( $filename );
176
-
177
- switch($extension) {
178
- case 'jpg':
179
- case 'jpeg':
180
- if (imagetypes() & IMG_JPG) {
181
- imagejpeg($this->image, $filename, $image_quality);
182
- }
183
- break;
184
-
185
- case 'gif':
186
- if (imagetypes() & IMG_GIF) {
187
- imagegif($this->image, $filename);
188
- }
189
- break;
190
-
191
- case 'png':
192
- // Scale quality from 0-100 to 0-9
193
- $scale_quality = round(($image_quality/100) * 9);
194
-
195
- // Invert quality setting as 0 is best, not 9
196
- $invert_scale_quality = 9 - $scale_quality;
197
-
198
- if (imagetypes() & IMG_PNG) {
199
- imagepng($this->image, $filename, $invert_scale_quality);
200
- }
201
- break;
202
-
203
- default:
204
- // No extension - No save.
205
- break;
206
- }
207
- }
208
-
209
- /**
210
- * Get Optimal Dimension
211
- *
212
- * Computes the best possible width and height when resizing an image
213
- *
214
- * @param int $orig_width
215
- * @param int $orig_height
216
- * @param int $new_width
217
- * @param int $new_height
218
- * @param string $resize_option
219
- *
220
- * @return array Array containing width and height
221
- */
222
- public function get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, $resize_option='auto') {
223
-
224
- if($resize_option == self::RESIZE_EXACT){
225
-
226
- $optimal_width = $new_width;
227
- $optimal_height = $new_height;
228
-
229
- } else if($resize_option== self::RESIZE_PORTRAIT ){ // Prefer height, compute width
230
-
231
- $ratio = $orig_width / $orig_height;
232
-
233
- $optimal_width = $new_height * $ratio;
234
- $optimal_height= $new_height;
235
-
236
- } else if($resize_option== self::RESIZE_LANDSCAPE){ // Prefer width
237
-
238
- $ratio = $orig_height / $orig_width;
239
-
240
- $optimal_width = $new_width;
241
- $optimal_height = $new_width * $ratio;
242
-
243
- } else if($resize_option== self::RESIZE_CROP){ // Crop
244
-
245
- $height_ratio = $orig_height / $new_height;
246
- $width_ratio = $orig_width / $new_width;
247
-
248
- if ($height_ratio < $width_ratio) {
249
- $optimal_ratio = $height_ratio;
250
- } else {
251
- $optimal_ratio = $width_ratio;
252
- }
253
-
254
- $optimal_width = $orig_width / $optimal_ratio;
255
- $optimal_height = $orig_height / $optimal_ratio;
256
-
257
-
258
- } else { // Auto
259
- if ($orig_height < $orig_width) { // Image to be resized is wider (landscape)
260
-
261
- list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'landscape');
262
-
263
- } elseif ($orig_height > $orig_width) { // Image to be resized is taller (portrait)
264
-
265
- list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'portrait');
266
-
267
- } else { // Image to be resized as a square
268
- if ($new_height < $new_width) { // Image to be resized is wider (landscape)
269
-
270
- list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'landscape');
271
-
272
- } else if ($new_height > $new_width) {
273
-
274
- list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'portrait');
275
-
276
- } else { // Square being resized to a square
277
- $optimal_width = $new_width;
278
- $optimal_height= $new_height;
279
- }
280
- }
281
- }
282
-
283
- return array( $optimal_width, $optimal_height );
284
- }
285
- }
286
-
287
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-image-resizer.php DELETED
@@ -1,108 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Image_Resizer')):
3
-
4
- /**
5
- * Class for copying WP images for import/export purposes and resizing slide images
6
- */
7
- class Cyclone_Slider_Image_Resizer {
8
-
9
- /**
10
- * Resize Images
11
- *
12
- * API to resize slide images
13
- *
14
- * @param int $slider_id Slider post ID
15
- * @param array $slides Slides array
16
- * @return void
17
- */
18
- public function resize_images( $slider_settings, $slides ){
19
-
20
- // Prevent fatal error on users without GD installed
21
- if(!function_exists('gd_info')){
22
- return false;
23
- }
24
-
25
- $slider_settings['resize_quality'] = 90;
26
- $width = $slider_settings['width'];
27
- $height = $slider_settings['height'];
28
-
29
- if( is_array($slides) ){
30
-
31
- foreach($slides as $slide){
32
- // Get full path to the slide image
33
- $image_file = get_attached_file( $slide['id'] );
34
-
35
- // Extract image path info
36
- $info = pathinfo($image_file);
37
- $dirname = isset($info['dirname']) ? $info['dirname'] : ''; // Path to directory
38
-
39
- // Create thumb filename-{width}x{height}.jpg
40
- $thumb_name = $this->generate_thumb_name( $image_file, $width, $height );
41
-
42
- // Save image to this file
43
- $image_file_dest = "{$dirname}/{$thumb_name}";
44
-
45
- if( ! is_file( $image_file_dest ) ) { // Destination file does not exist
46
- //echo "fresh {$image_file_dest} <br>";
47
- $this->resize( $image_file, $image_file_dest, $width, $height, $slider_settings );
48
-
49
- } else if( is_file( $image_file_dest ) and $slider_settings['force_resize'] ) { // Exist but force resize so we resave it
50
- //echo "REfreshed {$image_file_dest} <br>";
51
- $this->resize( $image_file, $image_file_dest, $width, $height, $slider_settings );
52
-
53
- }
54
- }
55
- //exit;
56
- }
57
- }
58
-
59
- /**
60
- * Resize Image
61
- *
62
- * @param string $image_file
63
- * @param string $image_file_dest
64
- * @param int $width
65
- * @param int $height
66
- * @param array $slider_settings
67
- * @return boolean True or false
68
- */
69
- private function resize($image_file, $image_file_dest, $width, $height, $slider_settings){
70
- // Create
71
- $image = new Cyclone_Slider_Image_Editor( $image_file );
72
-
73
- // Load
74
- if( $image->load() ){
75
-
76
- // Do resize
77
- $image->resize( $width, $height, $slider_settings['resize_option'] );
78
- $image->save( $image_file_dest, $slider_settings['resize_quality']);
79
-
80
- return true;
81
- }
82
- return false;
83
- }
84
-
85
- /**
86
- * Generate Thumb Name
87
- *
88
- * @param string $image_file
89
- * @param int $width
90
- * @param int $height
91
- * @return string
92
- */
93
- public function generate_thumb_name( $image_file, $width, $height ){
94
-
95
- // Get image path info and create file name
96
- $info = pathinfo( $image_file ); // Eg: d:/uploads/image-1.jpg
97
- if( !isset($info['extension']) or !isset($info['filename'])){
98
- return false;
99
- }
100
-
101
- $ext = $info['extension']; // File extension Eg. "jpg"
102
- $filename = $info['filename']; // Filename Eg. "image-1"
103
- return "{$filename}-{$width}x{$height}.{$ext}"; // Thumbname. Eg. "image-1-600x300.jpg"
104
-
105
- }
106
- }
107
-
108
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-import-page.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Import_Page') and class_exists('Codefleet_Admin_Sub_Page')):
3
-
4
- /**
5
- * Class for wrapping WP add_submenu_page.
6
- */
7
- class Cyclone_Slider_Import_Page extends Codefleet_Admin_Sub_Page {
8
- protected $view;
9
- protected $importer;
10
- protected $cyclone_slider_data; // Holds cyclone slider data object
11
-
12
- public function __construct( $view, $importer, $cyclone_slider_data ) {
13
- parent::__construct();
14
- $this->view = $view;
15
- $this->importer = $importer;
16
- $this->cyclone_slider_data = $cyclone_slider_data;
17
-
18
- add_action('init', array( $this, 'catch_posts') );
19
- }
20
-
21
- public function catch_posts(){
22
- // Verify nonce
23
- if( isset($_POST[$this->cyclone_slider_data->nonce_name]) ){
24
- $nonce = $_POST[$this->cyclone_slider_data->nonce_name];
25
- if ( wp_verify_nonce( $nonce, $this->cyclone_slider_data->nonce_action) ) {
26
- $uploads = wp_upload_dir(); // Get dir
27
- if( isset($_POST['cycloneslider_import_step']) ){
28
- if( $_POST['cycloneslider_import_step'] == 1 ){
29
- $cyclone_import = array();
30
-
31
- // Success
32
- if( $this->importer->import( $_FILES['cycloneslider_import']['tmp_name'], $uploads['basedir'].'/cyclone-slider' ) ){
33
- $cyclone_import = $this->importer->get_results();
34
- update_option('cycloneslider_import', $cyclone_import);
35
- wp_redirect( get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import&step=2') );
36
- exit;
37
- } else { // Fail
38
-
39
- }
40
- }
41
- }
42
- }
43
- }
44
- }
45
-
46
- /**
47
- * Render page. This function should output the HTML of the page.
48
- */
49
- public function render_page( $post ){
50
- $current_step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
51
- if($current_step == 2){
52
- $this->step_2();
53
- } else {
54
- $this->step_1();
55
- }
56
-
57
- }
58
-
59
- public function step_1(){
60
- $this->view->set_view_file( CYCLONE_PATH . 'views/import-step-1.php' );
61
- $vars = array();
62
- $vars['nonce_name'] = $this->cyclone_slider_data->nonce_name;
63
- $vars['nonce'] = wp_create_nonce( $this->cyclone_slider_data->nonce_action );
64
- $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
65
- $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
66
- $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
67
- $this->view->set_vars( $vars );
68
- $this->view->render();
69
-
70
- }
71
- public function step_2(){
72
- $log_results = get_option('cycloneslider_import');
73
- $defaults = array(
74
- 'oks'=>array(),
75
- 'errors'=>array()
76
- );
77
- $log_results = wp_parse_args($log_results, $defaults);
78
- delete_option('cycloneslider_import');
79
-
80
- $this->view->set_view_file( CYCLONE_PATH . 'views/import-step-2.php' );
81
- $vars = array();
82
- $vars['log_results'] = $log_results;
83
- $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
84
- $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
85
- $this->view->set_vars( $vars );
86
- $this->view->render();
87
-
88
- }
89
-
90
- } // end class
91
-
92
-
93
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-importer.php DELETED
@@ -1,401 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Importer')):
3
-
4
- /**
5
- * Class for importing cyclone-slider.zip
6
- */
7
- class Cyclone_Slider_Importer {
8
- protected $log_results; // Hold results of import operations
9
- protected $log_count;
10
- protected $cyclone_slider_data;
11
-
12
- public function __construct( $cyclone_slider_data ) {
13
- $this->log_results = array(
14
- 'oks'=>array(),
15
- 'errors'=>array()
16
- );
17
- $this->log_count = 0;
18
- $this->cyclone_slider_data = $cyclone_slider_data;
19
- }
20
-
21
- /**
22
- * Get log results
23
- *
24
- */
25
- public function get_results(){
26
- return $this->log_results;
27
- }
28
-
29
- /**
30
- * Import zip file
31
- *
32
- * @param filename $zip_file. Full path and filename to zip file
33
- * @param string $dir. Path to folder to extract the zip
34
- */
35
- public function import( $zip_file, $target_dir ) {
36
- // Check zip existence
37
- if( !file_exists($zip_file) ){
38
- $this->add_error('Zip file not found.');
39
- return false;
40
- }
41
-
42
- // Check zip support
43
- if( !class_exists('ZipArchive') ){
44
- $this->add_error('ZipArchive not supported.');
45
- return false;
46
- }
47
-
48
- // Check zip
49
- if( !$this->check_integrity( $zip_file ) ){
50
- return false;
51
- }
52
-
53
- // Remove old tmp folder if present
54
- if ( file_exists($target_dir) and is_dir($target_dir)) {
55
- if( $this->rmdir_recursive($target_dir)=== false ){
56
- $this->add_error('Failed to remove the temporary extract folder.');
57
- return false;
58
- } else {
59
- $this->add_ok('Removed the temporary extract folder.');
60
- }
61
- }
62
-
63
- // Create tmp folder to hold extracted files
64
- if(mkdir($target_dir)===false){
65
- $this->add_error('Failed to create the temporary extract folder.');
66
- return false;
67
- } else {
68
- $this->add_ok('Created the temporary extract folder.');
69
- }
70
-
71
- // Extract zip
72
- $zip = new ZipArchive;
73
- $zip->open($zip_file);
74
- if( $zip->extractTo($target_dir) === false ){
75
- $this->add_error('Failed to extract zip contents.');
76
- return false;
77
- } else {
78
- $this->add_ok('Extracted zip contents.');
79
- }
80
- $zip->close();
81
-
82
- // Read export JSON
83
- if( ($export_string = file_get_contents($target_dir.'/export.json')) === false ){
84
- $this->add_error('Failed to read export JSON.');
85
- return false;
86
- } else {
87
- $this->add_ok('Success reading export file.');
88
- }
89
-
90
- // Decode JSON
91
- if( ($export_data = json_decode($export_string, true)) == false ) {
92
- $this->add_error('Failed to decode JSON');
93
- return false;
94
- }
95
- $this->add_ok('Success decoding JSON');
96
-
97
- // Add images
98
- if( ($images_list = $this->add_images( $export_data['images'] )) === false){
99
- $this->add_error('Failed to add images');
100
- return false;
101
- }
102
- $this->add_ok('Success importing images');
103
-
104
- // Add sliders
105
- if( ($sliders_list = $this->add_sliders( $export_data['sliders'], $images_list ) ) === false){
106
- $this->add_error('Failed to add sliders');
107
- return false;
108
- }
109
- $this->add_ok('Success importing sliders');
110
-
111
- return true;
112
- }
113
-
114
- private function add_sliders( array $sliders, array $images_list ){
115
-
116
- foreach($sliders as $slider_index=>$slider){
117
- $slider = (array) $slider;
118
- foreach($slider['slides'] as $slide_index=>$slide){
119
- $sliders[$slider_index]['slides'][$slide_index]['id'] = $images_list[$slider['name']][$slide_index];// Update image ID
120
- }
121
- $this->cyclone_slider_data->add_slider($slider['title'], $slider['slider_settings'], $sliders[$slider_index]['slides'] );
122
- }
123
- return $sliders;
124
- }
125
-
126
- /**
127
- * Check zip file for consistency
128
- *
129
- * @param ZipArchive $zip. Instance
130
- */
131
- public function check_integrity( $zip_file ){
132
- $zip = new ZipArchive();
133
-
134
- // ZipArchive::CHECKCONS will enforce additional consistency checks
135
- $res = $zip->open($zip_file, ZipArchive::CHECKCONS);
136
-
137
- if ( $res === true){ // OK
138
- return true;
139
- }
140
-
141
- $this->add_error($this->get_zip_error($res));
142
- return false;
143
-
144
- }
145
-
146
- /**
147
- * @param
148
- */
149
- private function add_images( array $sliders ){
150
- $dir = wp_upload_dir();
151
- $target_folder = $dir['path'].'/';
152
- $src_folder = $dir['basedir'].'/cyclone-slider/';
153
-
154
- $images_list = array();
155
- foreach($sliders as $slider_name=>$slider){
156
-
157
- foreach($slider as $i=>$image){
158
- $image_id = 0;
159
- if(!empty($image)){ // Check for slides without images ie. custom or youtube slide
160
- $image_id = $this->copy_image( $src_folder.$image, $target_folder);
161
- }
162
- $images_list[$slider_name][] = $image_id;
163
- }
164
- //$this->cyclone_slider_data->add_slider($slider->title, $slider_settings, $slides );
165
- }
166
- return $images_list;
167
- }
168
-
169
- /**
170
- * Copy image to WP upload directory, create attachment and return attachment ID.
171
- *
172
- * @param string $image_file
173
- * @param string $target_folder
174
- * @return int|false Attachment ID on success false on fail
175
- */
176
- public function copy_image( $image_file, $target_folder ){
177
- if( !file_exists($image_file) ){
178
- return false;
179
- }
180
- $info = pathinfo($image_file);
181
-
182
- if( !isset($info['dirname']) and !isset($info['filename']) and !isset($info['extension']) ){
183
- return false;
184
- }
185
- $dirname = $info['dirname']; // Path to directory
186
- $filename = $info['filename']; // Filename without extension Eg. "image-1"
187
- $ext = $info['extension']; // File extension Eg. "jpg"
188
-
189
- $target_folder_files = scandir($target_folder);
190
- if($target_folder_files===false){
191
- return false;
192
- }
193
-
194
- $new_name = $this->increment_name( wp_basename( $image_file ), $target_folder_files); // Append numbers if file exist
195
- if(copy($image_file, $target_folder.$new_name)===false){
196
- return false;
197
- }
198
-
199
- return $this->add_media_image( $target_folder.$new_name ); // Add image as media attachment
200
- }
201
-
202
- /**
203
- * Add image as media attachment
204
- *
205
- * @param array $properties Media properties see $defaults for example
206
- * @param string $file Full path to file to add
207
- * @return int|false Attachment ID on success false on fail
208
- */
209
- private function add_media_image( $file, array $properties = array() ){
210
- $wp_upload_dir = wp_upload_dir();
211
-
212
- $filename = wp_basename( $file ); // Filename with extension. Example: image.jpg
213
- $wp_filetype = wp_check_filetype( $filename ); // Get mime type and extension
214
- $file_ext = $wp_filetype['ext']; // Extension without ".". Example: jpg
215
-
216
- $defaults = array(
217
- 'post_mime_type' => $wp_filetype['type'],
218
- 'post_title' => $this->slug_to_title( wp_basename( $file, ".$file_ext" ) ),
219
- 'post_content' => '',
220
- 'post_status' => 'inherit'
221
- );
222
-
223
- $properties = wp_parse_args( $properties, $defaults ); // Apply defaults
224
-
225
- $attach_id = wp_insert_attachment( $properties, $file ); // Location of the file on the server. The file MUST be on the WP uploads directory
226
-
227
- if(!function_exists('wp_generate_attachment_metadata')) require_once( ABSPATH . 'wp-admin/includes/image.php' );// Required for wp_generate_attachment_metadata
228
-
229
- $attachment_metadata = wp_generate_attachment_metadata( $attach_id, $file ); // Generate different thumbnails
230
- wp_update_attachment_metadata( $attach_id, $attachment_metadata );
231
- return $attach_id;
232
- }
233
-
234
- /**
235
- * Replace - and _ with spaces and capitalize, for a readable post title
236
- *
237
- * @param string $string To manipulate
238
- */
239
- private function slug_to_title( $string ){
240
- $string = sanitize_title( $string );
241
- $patterns = array();
242
- $patterns[0] = '/-/';
243
- $patterns[1] = '/_/';
244
- $replacements = array();
245
- $replacements[0] = ' ';
246
- $replacements[1] = ' ';
247
- return ucwords(preg_replace($patterns, $replacements, $string));
248
- }
249
-
250
- /**
251
- * Remove directory and its contents
252
- *
253
- * @param string $dir Directory to delete
254
- * @return true|false True on success false on fail
255
- */
256
- public function rmdir_recursive( $dir ) {
257
- foreach(scandir($dir) as $file) {
258
- if ('.' === $file || '..' === $file) continue;
259
- if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
260
- else unlink("$dir/$file");
261
- }
262
- return rmdir($dir);
263
- }
264
-
265
- /**
266
- * Append "-{n}" to name if filename already exist. Eg.: image.jpg becomes image-1.jpg
267
- *
268
- * @param string $file File to rename
269
- * @param array $other_filenames Filenames (not full path, only names) to look for. Similar to array returned by scandir.
270
- */
271
- private function increment_name( $file, array $other_filenames ){
272
- $pathinfo = pathinfo( $file );
273
-
274
- $dirname = $pathinfo['dirname'];
275
- $basename = $pathinfo['basename'];
276
- $extension = isset($pathinfo['extension']) ? ".".$pathinfo['extension'] : '';
277
- $filename = $pathinfo['filename'];
278
-
279
- $counter = 0;
280
- $new_name = $basename;
281
-
282
- while( $this->in_array_str_i( $new_name, $other_filenames ) ){
283
- $new_name = $filename.'-'.++$counter.$extension;
284
- }
285
-
286
- return $new_name;
287
- }
288
-
289
- /**
290
- * Case insensitive string lookup in an array. Similar usage to in_array
291
- */
292
- private function in_array_str_i($key, array $array){
293
- foreach($array as $element){
294
- if(strcasecmp($key, $element)==0){ // Found it
295
- return true;
296
- }
297
- }
298
- return false;
299
- }
300
-
301
- /**
302
- * Add Ok
303
- *
304
- * @param string $message Message to add
305
- * @return void
306
- */
307
- private function add_ok( $message ){
308
- $this->log_results['oks'][$this->log_count++] = $message;
309
- }
310
-
311
- /**
312
- * Add Error
313
- *
314
- * @param string $message Message to add
315
- * @return void
316
- */
317
- private function add_error( $message ){
318
- $this->log_results['errors'][$this->log_count++] = $message;
319
- }
320
-
321
- /**
322
- * Get zip error description from code
323
- *
324
- * @param int $error_code. ZipArchive error code
325
- */
326
- public function get_zip_error( $error_code ){
327
- if($error_code == ZIPARCHIVE::ER_MULTIDISK){
328
- return 'Multi-disk zip archives not supported.';
329
-
330
- } else if($error_code == ZIPARCHIVE::ER_RENAME){
331
- return 'Renaming temporary file failed.';
332
-
333
- } else if($error_code == ZIPARCHIVE::ER_CLOSE){
334
- return 'Closing zip archive failed.';
335
-
336
- } else if($error_code == ZIPARCHIVE::ER_SEEK){
337
- return 'Seek error.';
338
-
339
- } else if($error_code == ZIPARCHIVE::ER_READ){
340
- return 'Read error.';
341
-
342
- } else if($error_code == ZIPARCHIVE::ER_WRITE){
343
- return 'Write error.';
344
-
345
- } else if($error_code == ZIPARCHIVE::ER_CRC){
346
- return 'CRC error.';
347
-
348
- } else if($error_code == ZIPARCHIVE::ER_ZIPCLOSED){
349
- return 'Containing zip archive was closed.';
350
-
351
- } else if($error_code == ZIPARCHIVE::ER_NOENT){
352
- return 'No such file.';
353
-
354
- } else if($error_code == ZIPARCHIVE::ER_EXISTS){
355
- return 'File already exists.';
356
-
357
- } else if($error_code == ZIPARCHIVE::ER_OPEN){
358
- return 'Cannot open file.';
359
-
360
- } else if($error_code == ZIPARCHIVE::ER_TMPOPEN){
361
- return 'Failure to create temporary file.';
362
-
363
- } else if($error_code == ZIPARCHIVE::ER_ZLIB){
364
- return 'Zlib error.';
365
-
366
- } else if($error_code == ZIPARCHIVE::ER_MEMORY){
367
- return 'Memory allocation failure.';
368
-
369
- } else if($error_code == ZIPARCHIVE::ER_CHANGED){
370
- return 'Entry has been changed.';
371
-
372
- } else if($error_code == ZIPARCHIVE::ER_COMPNOTSUPP){
373
- return 'Compression method not supported.';
374
-
375
- } else if($error_code == ZIPARCHIVE::ER_EOF){
376
- return 'Premature EOF.';
377
-
378
- } else if($error_code == ZIPARCHIVE::ER_INVAL){
379
- return 'Invalid argument.';
380
-
381
- } else if($error_code == ZIPARCHIVE::ER_NOZIP){
382
- return 'Not a zip archive.';
383
-
384
- } else if($error_code == ZIPARCHIVE::ER_INTERNAL){
385
- return 'Internal error.';
386
-
387
- } else if($error_code == ZIPARCHIVE::ER_INCONS){
388
- return 'Zip archive inconsistent.';
389
-
390
- } else if($error_code == ZIPARCHIVE::ER_REMOVE){
391
- return 'Cannot remove file.';
392
-
393
- } else if($error_code == ZIPARCHIVE::ER_DELETED){
394
- return 'Entry has been deleted.';
395
-
396
- }
397
- return 'Unknown error.';
398
- }
399
- }
400
-
401
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-scripts.php DELETED
@@ -1,183 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Scripts')):
3
-
4
- /**
5
- * Class for handling styles and scripts
6
- */
7
- class Cyclone_Slider_Scripts {
8
-
9
- private $templates_manager; // Holds templates manager object
10
- private $cyclone_settings_data; // Holds cyclone settings array
11
-
12
- /**
13
- * Initialize
14
- */
15
- public function __construct( $templates_manager, $cyclone_settings_data ) {
16
-
17
- // Inject dependencies
18
- $this->templates_manager = $templates_manager;
19
- $this->cyclone_settings_data = $cyclone_settings_data;
20
-
21
- } // end constructor
22
-
23
- /**
24
- * Scripts and styles for slider admin area
25
- */
26
- public function register_admin_scripts( $hook ) {
27
-
28
- if( 'cycloneslider' == get_post_type() || $hook == 'cycloneslider_page_cycloneslider-settings' || $hook == 'cycloneslider_page_cycloneslider-export' ||$hook == 'cycloneslider_page_cycloneslider-import' ){ // Limit loading to certain admin pages
29
-
30
- // Required media files for new media manager. Since WP 3.5+
31
- wp_enqueue_media();
32
-
33
- // Fontawesome style
34
- wp_enqueue_style( 'font-awesome', CYCLONE_URL.'libs/font-awesome/css/font-awesome.min.css', array(), CYCLONE_VERSION );
35
-
36
- // Main style
37
- wp_enqueue_style( 'cycloneslider-admin-styles', CYCLONE_URL.'css/admin.css', array(), CYCLONE_VERSION );
38
-
39
- // Disable autosave
40
- wp_dequeue_script( 'autosave' );
41
-
42
- // For sortable elements
43
- wp_enqueue_script('jquery-ui-sortable');
44
-
45
- // For localstorage
46
- wp_enqueue_script( 'store', CYCLONE_URL.'js/store-json2.min.js', array('jquery'), CYCLONE_VERSION );
47
-
48
- // Allow translation to script texts
49
- wp_register_script( 'cycloneslider-admin-script', CYCLONE_URL.'js/admin.js', array('jquery'), CYCLONE_VERSION );
50
- wp_localize_script( 'cycloneslider-admin-script', 'cycloneslider_admin_vars',
51
- array(
52
- 'title' => __( 'Select an image', 'cycloneslider' ), // This will be used as the default title
53
- 'title2' => __( 'Select Images - Use Ctrl + Click or Shift + Click', 'cycloneslider' ),
54
- 'button' => __( 'Add to Slide', 'cycloneslider' ), // This will be used as the default button text
55
- 'button2' => __( 'Add Images as Slides', 'cycloneslider' ),
56
- 'youtube_url_error' => __( 'Error. Make sure its a valid YouTube URL.', 'cycloneslider' )
57
- )
58
- );
59
- wp_enqueue_script( 'cycloneslider-admin-script');
60
-
61
- }
62
- }
63
-
64
- /**
65
- * Scripts and styles for slider to run in admin preview. Must be hook to either admin_enqueue_scripts or wp_enqueue_scripts
66
- *
67
- * @param string $hook Hook name passed by WP
68
- * @return void
69
- */
70
- public function register_frontend_scripts_in_admin( $hook ) {
71
- if( get_post_type() == 'cycloneslider' || 'cycloneslider_page_cycloneslider-settings' == $hook || 'cycloneslider_page_cycloneslider-export' == $hook || 'cycloneslider_page_cycloneslider-import' == $hook ){ // Limit loading to certain admin pages
72
- $this->register_frontend_scripts( $hook );
73
- }
74
- }
75
-
76
- /**
77
- * Scripts and styles for slider to run. Must be hook to either admin_enqueue_scripts or wp_enqueue_scripts
78
- *
79
- * @param string $hook Hook name passed by WP
80
- * @return void
81
- */
82
- public function register_frontend_scripts( $hook ) {
83
-
84
- $in_footer = true;
85
- if($this->cyclone_settings_data['load_scripts_in'] == 'header'){
86
- $in_footer = false;
87
- }
88
-
89
- /*** Magnific Popup Style ***/
90
- if($this->cyclone_settings_data['load_magnific'] == 1){
91
- wp_enqueue_style( 'jquery-magnific-popup', CYCLONE_URL.'libs/magnific-popup/magnific-popup.css', array(), CYCLONE_VERSION );
92
- }
93
-
94
- /*** Templates Styles ***/
95
- $this->enqueue_templates_css();
96
-
97
- /*****************************/
98
-
99
- /*** Core Cycle2 Scripts ***/
100
- if($this->cyclone_settings_data['load_cycle2'] == 1){
101
- wp_enqueue_script( 'jquery-cycle2', CYCLONE_URL.'libs/cycle2/jquery.cycle2.min.js', array('jquery'), CYCLONE_VERSION, $in_footer );
102
- }
103
- if($this->cyclone_settings_data['load_cycle2_carousel'] == 1){
104
- wp_enqueue_script( 'jquery-cycle2-carousel', CYCLONE_URL.'libs/cycle2/jquery.cycle2.carousel.min.js', array('jquery', 'jquery-cycle2'), CYCLONE_VERSION, $in_footer );
105
- }
106
- if($this->cyclone_settings_data['load_cycle2_swipe'] == 1){
107
- wp_enqueue_script( 'jquery-cycle2-swipe', CYCLONE_URL.'libs/cycle2/jquery.cycle2.swipe.min.js', array('jquery', 'jquery-cycle2'), CYCLONE_VERSION, $in_footer );
108
- }
109
- if($this->cyclone_settings_data['load_cycle2_tile'] == 1){
110
- wp_enqueue_script( 'jquery-cycle2-tile', CYCLONE_URL.'libs/cycle2/jquery.cycle2.tile.min.js', array('jquery', 'jquery-cycle2'), CYCLONE_VERSION, $in_footer );
111
- }
112
- if($this->cyclone_settings_data['load_cycle2_video'] == 1){
113
- wp_enqueue_script( 'jquery-cycle2-video', CYCLONE_URL.'libs/cycle2/jquery.cycle2.video.min.js', array('jquery', 'jquery-cycle2'), CYCLONE_VERSION, $in_footer );
114
- }
115
-
116
- /*** Easing Script***/
117
- if($this->cyclone_settings_data['load_easing'] == 1){
118
- wp_enqueue_script( 'jquery-easing', CYCLONE_URL.'libs/jquery-easing/jquery.easing.1.3.1.min.js', array('jquery'), CYCLONE_VERSION, $in_footer );
119
- }
120
-
121
- /*** Magnific Popup Scripts ***/
122
- if($this->cyclone_settings_data['load_magnific'] == 1){
123
- wp_enqueue_script( 'jquery-magnific-popup', CYCLONE_URL.'libs/magnific-popup/jquery.magnific-popup.min.js', array('jquery'), CYCLONE_VERSION, $in_footer );
124
- }
125
-
126
- /*** Templates Scripts ***/
127
- $this->enqueue_templates_scripts();
128
-
129
- /*** Client Script ***/
130
- wp_enqueue_script( 'cyclone-client', CYCLONE_URL.'js/client.js', array('jquery'), CYCLONE_VERSION, $in_footer );
131
-
132
- }
133
-
134
- /**
135
- * Enqueues templates styles.
136
- */
137
- private function enqueue_templates_css(){
138
- $ds = DIRECTORY_SEPARATOR;
139
-
140
- $template_folders = $this->templates_manager->get_all_templates();
141
- $active_templates = $this->templates_manager->get_active_templates( $this->cyclone_settings_data );
142
-
143
- foreach($template_folders as $name=>$folder){
144
-
145
- if( 1 == $active_templates[$name] ){
146
- $file = $folder['path']."/style.css"; // Path to file
147
-
148
- if( file_exists( $file ) ){ // Check existence
149
- wp_enqueue_style( 'cyclone-template-style-'.sanitize_title($name), $folder['url'].'/style.css', array(), CYCLONE_VERSION );
150
- }
151
- }
152
- }
153
- }
154
-
155
- /**
156
- * Enqueues templates scripts.
157
- */
158
- private function enqueue_templates_scripts(){
159
- $ds = DIRECTORY_SEPARATOR;
160
-
161
- $in_footer = true;
162
- if($this->cyclone_settings_data['load_scripts_in'] == 'header'){
163
- $in_footer = false;
164
- }
165
-
166
- $template_folders = $this->templates_manager->get_all_templates();
167
- $active_templates = $this->templates_manager->get_active_templates( $this->cyclone_settings_data );
168
-
169
- foreach($template_folders as $name=>$folder){
170
-
171
- if( 1 == $active_templates[$name] ){
172
- $file = $folder['path']."/script.js"; // Path to file
173
-
174
- if( file_exists( $file ) ){ // Check existence
175
- wp_enqueue_script( 'cyclone-template-script-'.sanitize_title($name), $folder['url'].'/script.js', array(), CYCLONE_VERSION, $in_footer );
176
- }
177
- }
178
- }
179
- }
180
-
181
- }
182
-
183
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-settings-page.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Settings_Page') and class_exists('Codefleet_Settings_Sub_Page')):
3
- /**
4
- * Class for plugin settings
5
- */
6
- class Cyclone_Slider_Settings_Page extends Codefleet_Settings_Sub_Page {
7
-
8
- protected $view; // Holds the instance of Cyclone_Slider_View
9
- protected $templates_manager; // Holds template manager object
10
-
11
- /**
12
- * Initialize
13
- */
14
- public function __construct( $view, $templates_manager ) {
15
- parent::__construct();
16
- // Dependency injections
17
- $this->view = $view;
18
- $this->templates_manager = $templates_manager;
19
- }
20
-
21
- /**
22
- * Render settings page. This function should echo the HTML form of the settings page.
23
- */
24
- public function render_settings_page($post){
25
- $this->view->set_view_file( CYCLONE_PATH . 'views/settings-page.php' );
26
-
27
- $settings_data = $this->get_settings_data();
28
- $templates = $this->templates_manager->get_all_templates();
29
-
30
- $settings_data['load_templates'] = $this->templates_manager->get_active_templates( $settings_data );// Filter load templates
31
-
32
-
33
- $vars = array();
34
- $vars['page_title'] = $this->page_title;
35
- $vars['screen_icon'] = get_screen_icon('options-general'); ;
36
-
37
-
38
- $vars['settings_fields'] = $this->settings_fields( $this->option_group );
39
- $vars['option_name'] = $this->option_name;
40
-
41
-
42
- $vars['templates'] = $templates;
43
- $vars['settings_data'] = $settings_data;
44
-
45
- $vars['debug'] = (CYCLONE_DEBUG) ? cyclone_slider_debug( $vars['settings_data'] ) : '';
46
-
47
- $this->view->set_vars( $vars );
48
- $this->view->render();
49
- }
50
-
51
- /**
52
- * Validate data from HTML form
53
- */
54
- public function validate_options( $input ) {
55
- $input = wp_parse_args($input, $this->get_settings_data());
56
-
57
- $input['load_magnific'] = 0;
58
- $input['load_easing']= 0;
59
-
60
- if( isset($_POST['reset']) ){
61
- $input = $this->get_default_settings_data();
62
- add_settings_error( $this->menu_slug, 'restore_defaults', __( 'Default options restored.', 'cycloneslider'), 'updated fade' );
63
- } else {
64
-
65
- }
66
- return $input;
67
- }
68
-
69
- /**
70
- * Apply default values
71
- */
72
- public function get_default_settings_data() {
73
- $defaults = array();
74
- $defaults['load_scripts_in'] = 'footer';
75
-
76
- $defaults['load_cycle2'] = 1;
77
- $defaults['load_cycle2_carousel'] = 1;
78
- $defaults['load_cycle2_swipe'] = 1;
79
- $defaults['load_cycle2_tile'] = 1;
80
- $defaults['load_cycle2_video'] = 1;
81
-
82
- $defaults['load_easing'] = 0;
83
-
84
- $defaults['load_magnific'] = 0;
85
-
86
- $defaults['load_templates'] = array();
87
-
88
- $defaults['script_priority'] = 100;
89
- return $defaults;
90
- }
91
-
92
-
93
- } // end class
94
-
95
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-vimeo.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Vimeo')):
3
-
4
- /**
5
- * Class for handling Vimeo slides
6
- */
7
- class Cyclone_Slider_Vimeo {
8
-
9
- /**
10
- * Get Vimeo ID
11
- *
12
- * Return vimeo video id
13
- *
14
- * @param string $url URL of to parse
15
- *
16
- * @return int|false Vimeo ID on success and false on fail
17
- */
18
- public function get_vimeo_id($url){
19
-
20
- $parsed_url = parse_url($url);
21
- if ($parsed_url['host'] == 'vimeo.com'){
22
- $vimeo_id = ltrim( $parsed_url['path'], '/');
23
- if (is_numeric($vimeo_id)) {
24
- return $vimeo_id;
25
- }
26
- }
27
- return false;
28
- }
29
-
30
- /**
31
- * Get vimeo video thumbnail image
32
- *
33
- * @param int Vimeo ID.
34
- * @param string Size can be: thumbnail_small, thumbnail_medium, thumbnail_large.
35
- *
36
- * @return string URL of thumbnail image.
37
- */
38
- public function get_vimeo_thumb($video_id, $size = 'small'){
39
- if(!empty($video_id)){
40
- $data = @file_get_contents('http://vimeo.com/api/v2/video/'.$video_id.'.php');
41
- if( $data ) {
42
- $vimeo = unserialize( $data );
43
- if( isset($vimeo[0]['thumbnail_'.$size]) ){
44
- return $vimeo[0]['thumbnail_'.$size];
45
- }
46
- }
47
- }
48
- return '';
49
- }
50
- } // end class
51
-
52
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-widget.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Widget')):
3
-
4
- /**
5
- * Class for Cyclone Slider widget
6
- */
7
- class Cyclone_Slider_Widget extends WP_Widget {
8
-
9
- /**
10
- * Constructor
11
- */
12
- public function __construct() {
13
- parent::__construct(
14
- 'cyclone-slider-widget', // Base ID
15
- __( 'Cyclone Slider Widget', 'cycloneslider' ), // Name
16
- array( 'description' => __( 'Widget for displaying sliders.', 'cycloneslider' ), ) // Args
17
- );
18
- }
19
-
20
- /**
21
- * Widget output
22
- */
23
- function widget( $args, $instance ) {
24
- extract($args, EXTR_SKIP);
25
-
26
- echo $before_widget;
27
-
28
- if ( !empty($instance['title']) ) {
29
- $title = apply_filters('widget_title', $instance['title']);
30
- echo $before_title . $title . $after_title;
31
- }
32
- $slideshow = '';
33
- if ( !empty($instance['slideshow']) ) {
34
- $slideshow = $instance['slideshow'];
35
- if( function_exists('cyclone_slider') ) cyclone_slider($slideshow);
36
- }
37
- echo $after_widget;
38
- }
39
-
40
- /**
41
- * Widget on save
42
- */
43
- function update( $new_instance, $old_instance ) {
44
- $instance = $old_instance;
45
-
46
- $instance['title'] = strip_tags($new_instance['title']);
47
- $instance['slideshow'] = strip_tags($new_instance['slideshow']);
48
-
49
- return $instance;
50
-
51
- }
52
-
53
- /**
54
- * Admin form
55
- */
56
- function form( $instance ) {
57
- $defaults = array(
58
- 'title' => '',
59
- 'slideshow'=>''
60
- );
61
- $instance = wp_parse_args( (array) $instance, $defaults );
62
-
63
- $slideshow = $instance['slideshow'];
64
-
65
- ?>
66
- <p>
67
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'cycloneslider'); ?></label>
68
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php esc_attr_e($instance['title']); ?>" />
69
- </p>
70
- <p>
71
- <?php
72
- $my_query = new WP_Query(
73
- array(
74
- 'post_type' => 'cycloneslider',
75
- 'order'=>'ASC',
76
- 'posts_per_page' => -1,
77
- )
78
- );
79
- if($my_query->have_posts()):
80
- ?>
81
- <label for="<?php echo $this->get_field_id('slideshow'); ?>"><?php _e('Select a Slider:', 'cycloneslider'); ?></label>
82
- <select class="widefat" id="<?php echo $this->get_field_id('slideshow'); ?>" name="<?php echo $this->get_field_name('slideshow'); ?>">
83
- <option value=""></option>
84
- <?php
85
- global $post;
86
- $old_post = $post;
87
- while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
88
- <option value="<?php echo $post->post_name; ?>" <?php echo $slideshow==$post->post_name ? 'selected="selected"': ''; ?>><?php the_title(); ?></option>
89
- <?php
90
- endwhile;
91
- wp_reset_postdata();
92
- $post = $old_post;
93
- ?>
94
- </select>
95
- <?php else: ?>
96
- <?php _e('No sliders found.', 'cycloneslider'); ?>
97
- <?php endif; ?>
98
- </p>
99
- <?php
100
-
101
- }
102
-
103
- }
104
-
105
-
106
- /**
107
- * Register it
108
- */
109
- function cycloneslider_widgets(){
110
- register_widget('Cyclone_Slider_Widget');
111
- }
112
- add_action('widgets_init', 'cycloneslider_widgets');
113
-
114
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider-youtube.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider_Youtube')):
3
-
4
- /**
5
- * Class for handling youtube slides
6
- */
7
- class Cyclone_Slider_Youtube {
8
-
9
- /**
10
- * Initialize
11
- */
12
- public function __construct() {
13
-
14
-
15
- // Add hook for ajax operations if logged in
16
- //add_action( 'wp_ajax_cycloneslider_check_youtube_url', array( $this, 'cycloneslider_check_youtube_url' ) );
17
-
18
-
19
- } // end constructor
20
-
21
- /**
22
- * Ajax for checking youtube url
23
- *
24
- * @return void Prints json data
25
- */
26
- public function cycloneslider_check_youtube_url(){
27
- $url = $_POST['url'];
28
-
29
- $retval = array(
30
- 'success' => false
31
- );
32
-
33
- if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
34
- if( $id = $this->get_youtube_id($url) ){
35
- $retval['success'] = true;
36
- $retval['id'] = $id;
37
- $retval['v_url'] = "http://www.youtube.com/v/{$id}";
38
- }
39
- }
40
-
41
- echo json_encode($retval);
42
- die();
43
- }
44
-
45
- /**
46
- * Get youtube ID from different url formats
47
- *
48
- * @param string $url Youtube url
49
- * @return string|boolean Youtube URL on success or boolean false on fail
50
- */
51
- public function get_youtube_id($url){
52
- if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
53
- return false;
54
- }
55
- $parsed_url = parse_url($url);
56
-
57
- if(strpos($parsed_url['host'], 'youtube.com')!==false){
58
- if(strpos($parsed_url['path'], '/watch')!==false){ // Regular url Eg. http://www.youtube.com/watch?v=9bZkp7q19f0
59
- parse_str($parsed_url['query'], $parsed_str);
60
- if(isset($parsed_str['v']) and !empty($parsed_str['v'])){
61
- return $parsed_str['v'];
62
- }
63
- } else if(strpos($parsed_url['path'], '/v/')!==false){ // "v" URL http://www.youtube.com/v/9bZkp7q19f0?version=3&autohide=1
64
- $id = str_replace('/v/','',$parsed_url['path']);
65
- if( !empty($id) ){
66
- return $id;
67
- }
68
- } else if(strpos($parsed_url['path'], '/embed/')!==false){ // Embed URL: http://www.youtube.com/embed/9bZkp7q19f0
69
- return str_replace('/embed/','',$parsed_url['path']);
70
- }
71
- } else if(strpos($parsed_url['host'], 'youtu.be')!==false){ // Shortened URL: http://youtu.be/9bZkp7q19f0
72
- return str_replace('/','',$parsed_url['path']);
73
- }
74
-
75
- return false;
76
- }
77
-
78
-
79
- /**
80
- * Get youtube video thumbnail image
81
- *
82
- * @param int string $video_id YouTube ID
83
- * @param string $size Can be: small, medium, large
84
- *
85
- * @return string URL of thumbnail image.
86
- */
87
- public function get_youtube_thumb( $video_id, $size = 'small' ){
88
- if( 'large' == $size ){
89
- return 'http://img.youtube.com/vi/'.$video_id.'/hqdefault.jpg';
90
- } else if( 'medium' == $size ){
91
- return 'http://img.youtube.com/vi/'.$video_id.'/mqdefault.jpg';
92
- }
93
- return 'http://img.youtube.com/vi/'.$video_id.'/default.jpg';
94
- }
95
- } // end class
96
-
97
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-slider.php DELETED
@@ -1,272 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Slider')):
3
-
4
- class Cyclone_Slider {
5
- public $slider_count;
6
- private $cyclone_slider_templates; // Holds templates manager object
7
- private $cyclone_slider_scripts; // Holds slider scripts object
8
- private $cyclone_slider_data; // Holds cyclone slider data object
9
- private $cyclone_slider_youtube; // Holds youtube class
10
- private $cyclone_slider_vimeo; // Holds vimeo class
11
- private $view; // Holds cyclone slider view object
12
-
13
- /**
14
- * Initializes the plugin by setting localization, filters, and administration functions.
15
- */
16
- public function __construct( $cyclone_slider_scripts, $cyclone_slider_data, $view, $cyclone_slider_templates, $cyclone_slider_youtube, $cyclone_slider_vimeo ) {
17
-
18
- // Inject dependencies
19
- $this->cyclone_slider_scripts = $cyclone_slider_scripts;
20
- $this->cyclone_slider_data = $cyclone_slider_data;
21
- $this->cyclone_slider_templates = $cyclone_slider_templates;
22
- $this->cyclone_slider_youtube = $cyclone_slider_youtube;
23
- $this->cyclone_slider_vimeo = $cyclone_slider_vimeo;
24
- $this->view = $view;
25
-
26
- // Set defaults
27
- $this->slider_count = 0;
28
-
29
- // Register frontend styles and scripts
30
- add_action( 'wp_enqueue_scripts', array( $this->cyclone_slider_scripts, 'register_frontend_scripts' ), 100 );
31
-
32
- // Our shortcode
33
- add_shortcode('cycloneslider', array( $this, 'cycloneslider_shortcode') );
34
-
35
- } // end constructor
36
-
37
- /**
38
- * Cycloneslider Shortcode
39
- *
40
- * Displays shortcode on pages
41
- *
42
- * @param array $shortcode_settings Array of shortcode parameters
43
- * @return string Slider HTML
44
- */
45
- public function cycloneslider_shortcode( $shortcode_settings ) {
46
-
47
- $shortcode_settings = shortcode_atts(
48
- array(
49
- 'id' => 0,
50
- 'easing' => null,
51
- 'fx' => null,
52
- 'timeout' => null,
53
- 'speed' => null,
54
- 'width' => null,
55
- 'height' => null,
56
- 'hover_pause' => null,
57
- 'show_prev_next' => null,
58
- 'show_nav' => null,
59
- 'tile_count' => null,
60
- 'tile_delay' => null,
61
- 'tile_vertical' => null,
62
- 'random' => null,
63
- 'resize' => null,
64
- 'width_management' => null
65
- ),
66
- $shortcode_settings,
67
- 'cycloneslider'
68
- );
69
-
70
- $slider_slug = $shortcode_settings['id']; // Slideshow slug passed from shortcode
71
-
72
- $slider_count = ++$this->slider_count; // Make each call to shortcode unique
73
-
74
- $slider_html_id = 'cycloneslider-'.$slider_slug.'-'.$slider_count; // UID
75
-
76
- $slider = $this->cyclone_slider_data->get_slider_by_slug( $slider_slug ); // Get slider by slug
77
-
78
- // Abort if slider not found!
79
- if( $slider === false ){
80
- return sprintf(__('[Slideshow "%s" not found]', 'cycloneslider'), $slider_slug);
81
- }
82
-
83
- // Assign important variables
84
- $slider_settings = $slider['slider_settings']; // Assign slider settings
85
- $slides = $slider['slides']; // Assign slides
86
-
87
- $template_name = $slider_settings['template'];
88
- $view_file = $this->get_view_file( $template_name );
89
-
90
- // Abort if template not found!
91
- if( $view_file === false ){
92
- return sprintf(__('[Template "%s" not found]', 'cycloneslider'), $template_name);
93
- }
94
-
95
- // Use shortcode settings if present and override admin settings
96
- if( null !== $shortcode_settings['fx'] ){
97
- $slider_settings['fx'] = $shortcode_settings['fx'];
98
- }
99
- if( null !== $shortcode_settings['timeout'] ){
100
- $slider_settings['timeout'] = $shortcode_settings['timeout'];
101
- }
102
- if( null !== $shortcode_settings['speed'] ){
103
- $slider_settings['speed'] = $shortcode_settings['speed'];
104
- }
105
- if( null !== $shortcode_settings['width'] ){
106
- $slider_settings['width'] = $shortcode_settings['width'];
107
- }
108
- if( null !== $shortcode_settings['height'] ){
109
- $slider_settings['height'] = $shortcode_settings['height'];
110
- }
111
- if( null !== $shortcode_settings['hover_pause'] ){
112
- $slider_settings['hover_pause'] = $shortcode_settings['hover_pause'];
113
- }
114
- if( null !== $shortcode_settings['show_prev_next'] ){
115
- $slider_settings['show_prev_next'] = $shortcode_settings['show_prev_next'];
116
- }
117
- if( null !== $shortcode_settings['show_nav'] ){
118
- $slider_settings['show_nav'] = $shortcode_settings['show_nav'];
119
- }
120
- if( null !== $shortcode_settings['tile_count'] ){
121
- $slider_settings['tile_count'] = $shortcode_settings['tile_count'];
122
- }
123
- if( null !== $shortcode_settings['tile_delay'] ){
124
- $slider_settings['tile_delay'] = $shortcode_settings['tile_delay'];
125
- }
126
- if( null !== $shortcode_settings['tile_vertical'] ){
127
- $slider_settings['tile_vertical'] = $shortcode_settings['tile_vertical'];
128
- }
129
- if( null !== $shortcode_settings['random'] ){
130
- $slider_settings['random'] = $shortcode_settings['random'];
131
- }
132
- if( null !== $shortcode_settings['resize'] ){
133
- $slider_settings['resize'] = $shortcode_settings['resize'];
134
- }
135
- if( null !== $shortcode_settings['width_management'] ){
136
- $slider_settings['width_management'] = $shortcode_settings['width_management'];
137
- }
138
-
139
- $image_count = 0; // Number of image slides
140
- $video_count = 0; // Number of video slides
141
- $custom_count = 0; // Number of custom slides
142
- $youtube_count = 0; // Number of youtube slides
143
- $vimeo_count = 0; // Number of Vimeo slides
144
-
145
- // Do some last minute logic
146
- // Translations and counters
147
- foreach($slides as $i=>$slide){
148
- $slides[$i]['title'] = __($slide['title']);
149
- $slides[$i]['description'] = __($slide['description']);
150
- if($slides[$i]['type']=='image'){
151
-
152
- list($full_image_url, $orig_width, $orig_height) = wp_get_attachment_image_src($slide['id'], 'full');
153
-
154
- $slides[$i]['full_image_url'] = $full_image_url;
155
- $slides[$i]['image_url'] = $this->cyclone_slider_data->get_slide_image_url( $slide['id'], $slider_settings );
156
-
157
- $image_count++;
158
- } else if($slides[$i]['type']=='video'){
159
- $video_count++;
160
- } else if($slides[$i]['type']=='custom'){
161
- $custom_count++;
162
- } else if($slides[$i]['type']=='youtube'){
163
- $youtube_count++;
164
- $youtube_id = $this->cyclone_slider_youtube->get_youtube_id($slides[$i]['youtube_url']);
165
-
166
- $youtube_related = '';
167
- if( 'true' == $slides[$i]['youtube_related'] ) {
168
- $youtube_related = '&rel=0';
169
- }
170
-
171
- $slides[$i]['youtube_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="//www.youtube.com/embed/'.$youtube_id.'?wmode=transparent'.$youtube_related.'" frameborder="0" allowfullscreen></iframe>';
172
- $slides[$i]['youtube_id'] = $youtube_id;
173
- $slides[$i]['thumbnail_small'] = $this->cyclone_slider_youtube->get_youtube_thumb($youtube_id);
174
-
175
- } else if($slides[$i]['type']=='vimeo'){
176
- $vimeo_count++;
177
- $vimeo_id = $this->cyclone_slider_vimeo->get_vimeo_id($slides[$i]['vimeo_url']);
178
-
179
- $slides[$i]['vimeo_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="http://player.vimeo.com/video/'.$vimeo_id.'?api=1&wmode=transparent" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
180
- $slides[$i]['vimeo_id'] = $vimeo_id;
181
- $slides[$i]['thumbnail_small'] = $this->cyclone_slider_vimeo->get_vimeo_thumb($vimeo_id);
182
- }
183
- }
184
-
185
- // Randomize slides
186
- if($slider_settings['random']){
187
- shuffle($slides);
188
- }
189
-
190
- // Assign view file
191
- $this->view->set_view_file( $view_file );
192
-
193
- // Hardcoded for now
194
- $slider_settings['hide_non_active'] = "true";
195
- $slider_settings['auto_height'] = "{$slider_settings['width']}:{$slider_settings['height']}"; // Use ratio for backward compat
196
- if( 'on' == $slider_settings['dynamic_height'] ) {
197
- $slider_settings['auto_height'] = 0; // Disable autoheight when dynamic height is on. To prevent slider returning to wrong (ratio height) height when browser is resized.
198
- }
199
- if( ($youtube_count+$vimeo_count) > 0 or 'on' == $slider_settings['dynamic_height'] ){
200
- $slider_settings['hide_non_active'] = "false"; // Do not hide non active slides to prevent reloading of videos and for getBoundingClientRect() to not return 0.
201
- }
202
- $slider_settings['auto_height_speed'] = 250; // Will be editable in admin in the future
203
- $slider_settings['auto_height_easing'] = "null"; // Will be editable in admin in the future
204
-
205
- // Pass this vars to template
206
- $vars = array();
207
- $vars['slider_html_id'] = $slider_html_id; // The unique HTML ID for slider
208
- $vars['slider_count'] = $slider_count;
209
- $vars['slides'] = $slides;
210
- $vars['image_count'] = $image_count;
211
- $vars['video_count'] = $video_count;
212
- $vars['custom_count'] = $custom_count;
213
- $vars['youtube_count'] = $youtube_count;
214
- $vars['slider_id'] = $slider_slug; // (Deprecated since 2.6.0, use $slider_html_id instead) Unique string to identify the slideshow.
215
- $vars['slider_metas'] = $slides; // (Deprecated since 2.5.5, use $slides instead) An array containing slides properties.
216
- $vars['slider_settings'] = $slider_settings;
217
-
218
- $this->view->set_vars( $vars );
219
- $slider_html = $this->view->get_render();
220
-
221
- // Remove whitespace to prevent WP from adding rogue paragraphs
222
- $slider_html = $this->trim_white_spaces( $slider_html );
223
-
224
- // Return HTML
225
- return $slider_html;
226
- }
227
-
228
- /**
229
- * Trim White Spaces
230
- *
231
- */
232
- public function trim_white_spaces($buffer, $off=false){
233
- if($off){
234
- return $buffer;
235
- }
236
- $search = array(
237
- '/\>[^\S ]+/s', //strip whitespaces after tags, except space
238
- '/[^\S ]+\</s', //strip whitespaces before tags, except space
239
- '/(\s)+/s' // shorten multiple whitespace sequences
240
- );
241
- $replace = array(
242
- '>',
243
- '<',
244
- '\\1'
245
- );
246
- return preg_replace($search, $replace, $buffer);
247
- }
248
-
249
- /**
250
- * Get View File
251
- *
252
- * Get slider view file from theme or plugin location
253
- *
254
- * @param string $template_name Name of slider template
255
- * @return string|false Slider view filepath or false
256
- */
257
- public function get_view_file( $template_name ){
258
-
259
- $template_locations = $this->cyclone_slider_templates->get_template_locations();
260
- $template_locations = array_reverse($template_locations); // Last added template locations are checked first
261
- foreach($template_locations as $template_location){
262
- $view_file = $template_location['path']."{$template_name}/slider.php";
263
- if(@is_file($view_file)){
264
- return $view_file;
265
- }
266
- }
267
-
268
- return false;
269
- }
270
- } // end class
271
-
272
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-cyclone-templates-manager.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- if(!class_exists('Cyclone_Templates_Manager')):
3
-
4
- /**
5
- * In charge in getting templates from various template locations.
6
- */
7
- class Cyclone_Templates_Manager {
8
-
9
- protected $template_locations;
10
-
11
- /**
12
- * Initializes class
13
- */
14
- public function __construct() {
15
- $this->template_locations = array();
16
- }
17
-
18
- /**
19
- * Add a directory to read templates from
20
- *
21
- * @param string $location - The full path to a directory
22
- */
23
- public function add_template_location( $location ){
24
- $this->template_locations[] = $location;
25
- }
26
-
27
- /**
28
- * Get all templates in array format
29
- */
30
- public function get_all_templates(){
31
- if(is_array($this->template_locations) and !empty($this->template_locations)){
32
- $template_folders = array();
33
- foreach($this->template_locations as $location){
34
- if($files = @scandir($location['path'])){
35
- $c = 0;
36
- foreach($files as $name){
37
- if($name!='.' and $name!='..' and is_dir($location['path'].$name) and @file_exists($location['path'].$name.DIRECTORY_SEPARATOR.'slider.php') ){ // Check if its a directory
38
- $ini_array['slide_type'] = array('image');// Default
39
- if(@file_exists($location['path'].$name.DIRECTORY_SEPARATOR.'config.txt')){
40
- $ini_array = parse_ini_file($location['path'].$name.DIRECTORY_SEPARATOR.'config.txt'); //Parse ini to get slide types supported
41
- }
42
-
43
- $name = sanitize_title($name);// Change space to dash and all lowercase
44
- $template_folders[$name] = array( // Here we override template of the same names. If there is a template with the same name in plugin and theme directory, the one in theme will take over
45
- 'path'=>$location['path'].$name,
46
- 'url'=>$location['url'].$name,
47
- 'supports' => $ini_array['slide_type'],
48
- 'location_name' => $location['location_name']
49
- );
50
- }
51
- }
52
- }
53
- }
54
- return $template_folders;
55
- }
56
-
57
- }
58
-
59
- /**
60
- * Get Active Templates
61
- *
62
- * Get templates that are enabled in settings page
63
- *
64
- * @return array Template locations
65
- */
66
- public function get_active_templates( $settings_data ){
67
-
68
- $templates = $this->get_all_templates();
69
-
70
- foreach($templates as $name=>$template){
71
-
72
- if( !isset($settings_data['load_templates'][$name]) ){
73
- $settings_data['load_templates'][$name] = 1;
74
- }
75
- }
76
- return $settings_data['load_templates'];
77
- }
78
-
79
- /**
80
- * Get Template Locations
81
- *
82
- * @return array Template locations
83
- */
84
- public function get_template_locations(){
85
- return $this->template_locations;
86
- }
87
- }
88
-
89
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-image-resizer.php DELETED
@@ -1,227 +0,0 @@
1
- <?php
2
- if(!class_exists('Image_Resizer')):
3
-
4
- class Image_Resizer {
5
-
6
- // *** Class variables
7
- private $image;
8
- private $width;
9
- private $height;
10
- private $imageResized;
11
-
12
- function __construct($fileName)
13
- {
14
- // *** Open up the file
15
- $this->image = $this->openImage($fileName);
16
-
17
- // *** Get width and height
18
- $this->width = imagesx($this->image);
19
- $this->height = imagesy($this->image);
20
- }
21
-
22
- private function openImage($file)
23
- {
24
- // *** Get extension
25
- $extension = strtolower(strrchr($file, '.'));
26
-
27
- switch($extension)
28
- {
29
- case '.jpg':
30
- case '.jpeg':
31
- $img = @imagecreatefromjpeg($file);
32
- break;
33
- case '.gif':
34
- $img = @imagecreatefromgif($file);
35
- break;
36
- case '.png':
37
- $img = @imagecreatefrompng($file);
38
- break;
39
- default:
40
- $img = false;
41
- break;
42
- }
43
- return $img;
44
- }
45
-
46
- public function resizeImage($newWidth, $newHeight, $option="auto")
47
- {
48
- // *** Get optimal width and height - based on $option
49
- $optionArray = $this->getDimensions($newWidth, $newHeight, $option);
50
-
51
- $optimalWidth = $optionArray['optimalWidth'];
52
- $optimalHeight = $optionArray['optimalHeight'];
53
-
54
-
55
- // *** Resample - create image canvas of x, y size
56
- $this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
57
- /*** Preserve PNG transparency start ***/
58
- imagealphablending($this->imageResized, false);
59
- imagesavealpha($this->imageResized, true);
60
- $transparent = imagecolorallocatealpha($this->imageResized, 255, 255, 255, 127);
61
- imagefilledrectangle($this->imageResized, 0, 0, $optimalWidth, $optimalHeight, $transparent);
62
- /*** Preserve PNG transparency end ***/
63
- imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
64
-
65
-
66
- // *** if option is 'crop', then crop too
67
- if ($option == 'crop') {
68
- $this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight);
69
- }
70
- }
71
-
72
- public function getDimensions($newWidth, $newHeight, $option)
73
- {
74
-
75
- switch ($option)
76
- {
77
- case 'exact':
78
- $optimalWidth = $newWidth;
79
- $optimalHeight= $newHeight;
80
- break;
81
- case 'portrait':
82
- $optimalWidth = $this->getSizeByFixedHeight($newHeight);
83
- $optimalHeight= $newHeight;
84
- break;
85
- case 'landscape':
86
- $optimalWidth = $newWidth;
87
- $optimalHeight= $this->getSizeByFixedWidth($newWidth);
88
- break;
89
- case 'auto':
90
- $optionArray = $this->getSizeByAuto($newWidth, $newHeight);
91
- $optimalWidth = $optionArray['optimalWidth'];
92
- $optimalHeight = $optionArray['optimalHeight'];
93
- break;
94
- case 'crop':
95
- $optionArray = $this->getOptimalCrop($newWidth, $newHeight);
96
- $optimalWidth = $optionArray['optimalWidth'];
97
- $optimalHeight = $optionArray['optimalHeight'];
98
- break;
99
- }
100
- return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
101
- }
102
-
103
- private function getSizeByFixedHeight($newHeight)
104
- {
105
- $ratio = $this->width / $this->height;
106
- $newWidth = $newHeight * $ratio;
107
- return $newWidth;
108
- }
109
-
110
- private function getSizeByFixedWidth($newWidth)
111
- {
112
- $ratio = $this->height / $this->width;
113
- $newHeight = $newWidth * $ratio;
114
- return $newHeight;
115
- }
116
-
117
- private function getSizeByAuto($newWidth, $newHeight)
118
- {
119
- if ($this->height < $this->width)
120
- // *** Image to be resized is wider (landscape)
121
- {
122
- $optimalWidth = $newWidth;
123
- $optimalHeight= $this->getSizeByFixedWidth($newWidth);
124
- }
125
- elseif ($this->height > $this->width)
126
- // *** Image to be resized is taller (portrait)
127
- {
128
- $optimalWidth = $this->getSizeByFixedHeight($newHeight);
129
- $optimalHeight= $newHeight;
130
- }
131
- else
132
- // *** Image to be resizerd is a square
133
- {
134
- if ($newHeight < $newWidth) {
135
- $optimalWidth = $newWidth;
136
- $optimalHeight= $this->getSizeByFixedWidth($newWidth);
137
- } else if ($newHeight > $newWidth) {
138
- $optimalWidth = $this->getSizeByFixedHeight($newHeight);
139
- $optimalHeight= $newHeight;
140
- } else {
141
- // *** Square being resized to a square
142
- $optimalWidth = $newWidth;
143
- $optimalHeight= $newHeight;
144
- }
145
- }
146
-
147
- return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
148
- }
149
-
150
- private function getOptimalCrop($newWidth, $newHeight)
151
- {
152
-
153
- $heightRatio = $this->height / $newHeight;
154
- $widthRatio = $this->width / $newWidth;
155
-
156
- if ($heightRatio < $widthRatio) {
157
- $optimalRatio = $heightRatio;
158
- } else {
159
- $optimalRatio = $widthRatio;
160
- }
161
-
162
- $optimalHeight = $this->height / $optimalRatio;
163
- $optimalWidth = $this->width / $optimalRatio;
164
-
165
- return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
166
- }
167
-
168
- private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight)
169
- {
170
- // *** Find center - this will be used for the crop
171
- $cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
172
- $cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
173
-
174
- $crop = $this->imageResized;
175
- //imagedestroy($this->imageResized);
176
-
177
- // *** Now crop from center to exact requested size
178
- $this->imageResized = imagecreatetruecolor($newWidth , $newHeight);
179
- imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight);
180
- }
181
-
182
- public function saveImage($savePath, $imageQuality="100")
183
- {
184
- // *** Get extension
185
- $extension = strrchr($savePath, '.');
186
- $extension = strtolower($extension);
187
-
188
- switch($extension)
189
- {
190
- case '.jpg':
191
- case '.jpeg':
192
- if (imagetypes() & IMG_JPG) {
193
- imagejpeg($this->imageResized, $savePath, $imageQuality);
194
- }
195
- break;
196
-
197
- case '.gif':
198
- if (imagetypes() & IMG_GIF) {
199
- imagegif($this->imageResized, $savePath);
200
- }
201
- break;
202
-
203
- case '.png':
204
- // *** Scale quality from 0-100 to 0-9
205
- $scaleQuality = round(($imageQuality/100) * 9);
206
-
207
- // *** Invert quality setting as 0 is best, not 9
208
- $invertScaleQuality = 9 - $scaleQuality;
209
-
210
- if (imagetypes() & IMG_PNG) {
211
- imagepng($this->imageResized, $savePath, $invertScaleQuality);
212
- }
213
- break;
214
-
215
- // ... etc
216
-
217
- default:
218
- // *** No extension - No save.
219
- break;
220
- }
221
-
222
- imagedestroy($this->imageResized);
223
- }
224
-
225
- }
226
-
227
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/class-nextgen-integration.php DELETED
@@ -1,184 +0,0 @@
1
- <?php
2
- if(!class_exists('Nextgen_Integration')):
3
-
4
- /**
5
- * Class for NextGEN integration. Allows import of images from a gallery as new slides.
6
- */
7
- class Nextgen_Integration {
8
-
9
- private $cyclone_slider_data; // Holds cyclone slider data object
10
-
11
- /**
12
- * Initialize
13
- */
14
- function __construct( $cyclone_slider_data ) {
15
-
16
- $this->cyclone_slider_data = $cyclone_slider_data;
17
-
18
- // Add metaboxes
19
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 100 );
20
-
21
- // Append nextgen slides
22
- add_filter('cycloneslider_slides', array($this, 'nextgen_slides'));
23
-
24
- }
25
-
26
- /**
27
- * Add metabox
28
- */
29
- function add_meta_boxes(){
30
- global $nggdb;
31
- if(!isset($nggdb)){//Show only if nextgen plugin is available
32
- return false;
33
- }
34
-
35
- add_meta_box(
36
- 'cyclone-nextgen-metabox',
37
- __('NextGEN Integration', 'cycloneslider'),
38
- array( $this, 'render_nextgen_meta_box' ),
39
- 'cycloneslider' ,
40
- 'normal',
41
- 'low'
42
- );
43
- }
44
-
45
- /**
46
- * Render metabox
47
- */
48
- function render_nextgen_meta_box($post){
49
- global $nggdb;
50
-
51
- ?>
52
- <div class="cycloneslider-field last">
53
- <label for="cycloneslider_nextgen_gallery"><?php _e('Choose a NextGEN Gallery', 'cycloneslider'); ?></label>
54
- <?php
55
- $galleries = $nggdb->find_all_galleries();
56
- ?>
57
- <select id="cycloneslider_nextgen_gallery" name="cycloneslider_settings[nextgen_gallery]">
58
- <option selected="selected" value="0"></option>
59
- <?php foreach($galleries as $gallery): ?>
60
- <option value="<?php echo $gallery->gid; ?>"><?php echo $gallery->title; ?></option>
61
- <?php endforeach; ?>
62
- </select>
63
- <input type="submit" name="cycloneslider_settings[nextgen]" value="<?php _e('Import', 'cycloneslider'); ?>" class="button-secondary" />
64
- <br />
65
- <span class="note"><?php _e('Select a gallery to import images from. Images will be added as new slides.', 'cycloneslider'); ?></span>
66
- <div class="clear"></div>
67
- </div>
68
- <?php
69
- }
70
-
71
- /**
72
- * Append 1-x to name if filename already exist
73
- */
74
- function increment_name($filename, $extension, $folder_files){
75
- $name = $filename.'.'.$extension;
76
- if($this->in_array_str_i($name, $folder_files)){
77
- $existing = true;
78
- $counter = 0;
79
- while($existing){
80
- $counter++;
81
- $name = $filename.$counter.'.'.$extension;
82
- if(!$this->in_array_str_i($name, $folder_files)){
83
- return $name;
84
- }
85
- }
86
- }
87
- return $name;
88
- }
89
-
90
- /**
91
- * Case insensitive string lookup in an array
92
- */
93
- function in_array_str_i($key, $array){
94
- foreach($array as $element){
95
- if(strcasecmp($key, $element)==0){
96
- return true;
97
- }
98
- }
99
- return false;
100
- }
101
-
102
- /**
103
- * Replace certain characters with spaces in order to be a readable post title
104
- */
105
- function slug_to_title($string){
106
- $patterns = array();
107
- $patterns[0] = '/-/';
108
- $patterns[1] = '/_/';
109
- $replacements = array();
110
- $replacements[0] = ' ';
111
- $replacements[1] = ' ';
112
- return ucwords(preg_replace($patterns, $replacements, $string));
113
- }
114
-
115
- /**
116
- * Copy image to WP upload directory, create attachment and return attachment ID.
117
- */
118
- function copy_image($image_file){
119
- $dir = wp_upload_dir();
120
- $target_folder = $dir['path'].'/';
121
-
122
- $info = pathinfo($image_file);
123
- $dirname = isset($info['dirname']) ? $info['dirname'] : ''; // Path to directory
124
- $filename = isset($info['filename']) ? $info['filename'] : ''; // Filename without extension Eg. "image-1"
125
- $ext = isset($info['extension']) ? $info['extension'] : ''; // File extension Eg. "jpg"
126
-
127
- if($target_folder_files = scandir($target_folder)){
128
- if(is_array($target_folder_files)){
129
- $new_name = $this->increment_name($filename, $ext, $target_folder_files); //Append numbers if file exist
130
- if(copy($image_file, $target_folder.$new_name)){
131
-
132
- $size = getimagesize($target_folder.$new_name);// Get mime type
133
- // Build attachment details
134
- $attachment = array(
135
- 'post_mime_type' => $size['mime'],
136
- 'post_title' => $this->slug_to_title(basename($new_name, '.'.$ext)),
137
- 'post_content' => '',
138
- 'post_status' => 'inherit'
139
- );
140
-
141
- $attach_id = wp_insert_attachment( $attachment, $target_folder.$new_name );
142
-
143
- if(!function_exists('wp_generate_attachment_metadata')) include( ABSPATH . 'wp-admin/includes/image.php' );// Required for wp_generate_attachment_metadata
144
-
145
- $attach_data = wp_generate_attachment_metadata( $attach_id, $target_folder.$new_name ); // Generate different thumbnails
146
- wp_update_attachment_metadata( $attach_id, $attach_data );
147
- return $attach_id;
148
- }
149
- }
150
- }
151
- return false;
152
- }
153
-
154
-
155
-
156
- /**
157
- * Add images from nextgen as new slides. Images are copied from nextgen folders into WP uploads dir and added as attachments.
158
- */
159
- function nextgen_slides($slides){
160
- global $nggdb;
161
- if(!isset($nggdb)){
162
- return $slides;
163
- }
164
-
165
- if(isset($_POST['cycloneslider_settings']['nextgen']) and isset($_POST['cycloneslider_settings']['nextgen_gallery']) ){
166
-
167
- $nextgen_gallery = $nggdb->get_gallery((int) $_POST['cycloneslider_settings']['nextgen_gallery']);
168
-
169
- if(!empty($nextgen_gallery) and is_array($nextgen_gallery)){
170
-
171
- foreach($nextgen_gallery as $image){
172
- if($attach_id = $this->copy_image($image->imagePath)){ //Copy success!
173
- $slides[] = wp_parse_args(array('id' => $attach_id), $this->cyclone_slider_data->get_slide_defaults() ); //Add the slide ID and fill in default values
174
- }
175
- }
176
- }
177
- }
178
-
179
- return $slides;
180
- }
181
-
182
- } // end class
183
-
184
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-admin-page.php DELETED
@@ -1,144 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_Admin_Page')):
3
-
4
- /**
5
- * Class for wrapping WP add_menu_page.
6
- */
7
- class Codefleet_Admin_Page {
8
-
9
- /**
10
- * Class variables relating to WP add_menu_page
11
- */
12
- protected $page_title;
13
- protected $menu_title;
14
- protected $capability;
15
- protected $menu_slug;
16
- protected $icon_url;
17
- protected $position;
18
-
19
- /**
20
- * Initialize
21
- */
22
- public function __construct() {
23
- $this->page_title = 'Custom Settings';
24
- $this->menu_title = 'Custom Settings';
25
- $this->capability = 'manage_options';
26
- $this->menu_slug = 'custom-settings-page';
27
- $this->icon_url = null;
28
- $this->position = null;
29
- }
30
-
31
- /**
32
- * Show settings page by hooking 'em up with WP.
33
- */
34
- public function show(){
35
-
36
- // Add page
37
- add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
38
- }
39
-
40
- /**
41
- * Menu page action hook
42
- */
43
- public function add_menu_and_page(){
44
- // Use built-in WP function
45
- add_menu_page(
46
- $this->page_title,
47
- $this->menu_title,
48
- $this->capability,
49
- $this->menu_slug,
50
- array( $this, 'render_page'),
51
- $this->icon_url,
52
- $this->position
53
- );
54
- }
55
-
56
- /**
57
- * Render page. This function should output the HTML of the page.
58
- */
59
- public function render_page($post){
60
- ?>
61
- <div class="wrap">
62
- <?php echo get_screen_icon('options-general'); ?>
63
- <h2><?php echo $this->page_title; ?></h2>
64
- <div class="intro">
65
- <p>This is the intro text</p>
66
- </div>
67
-
68
- <form method="post" action="">
69
-
70
- <table class="form-table">
71
- <tr>
72
- <th><label for="<?php echo esc_attr( 'sample_text' ); ?>"><?php echo esc_attr( 'Sample Text' ); ?></label></th>
73
- <td>
74
- <input type="text" id="sample_text" name="sample_text" value="" />
75
- </td>
76
- </tr>
77
- </table>
78
- <?php submit_button( 'Save Options', 'primary', 'submit', false) ?>
79
- <?php submit_button( 'Restore Defaults', 'secondary', 'reset', false) ?>
80
- </form>
81
-
82
- </div><?php
83
- }
84
-
85
-
86
-
87
-
88
- /**
89
- * SETTER FUNCTIONS
90
- */
91
- public function set_page_title( $value ){
92
- $this->page_title = $value;
93
- }
94
-
95
- public function set_menu_title( $value ){
96
- $this->menu_title = $value;
97
- }
98
-
99
- public function set_capability( $value ){
100
- $this->capability = $value;
101
- }
102
-
103
- public function set_menu_slug( $value ){
104
- $this->menu_slug = $value;
105
- }
106
-
107
- public function set_icon_url( $value ){
108
- $this->icon_url = $value;
109
- }
110
-
111
- public function set_position( $value ){
112
- $this->position = $value;
113
- }
114
-
115
- /**
116
- * GETTER FUNCTIONS
117
- */
118
- public function get_page_title(){
119
- return $this->page_title;
120
- }
121
-
122
- public function get_menu_title(){
123
- return $this->menu_title;
124
- }
125
-
126
- public function get_capability(){
127
- return $this->capability;
128
- }
129
-
130
- public function get_menu_slug(){
131
- return $this->menu_slug;
132
- }
133
-
134
- public function get_icon_url(){
135
- return $this->icon_url;
136
- }
137
-
138
- public function get_position(){
139
- return $this->position;
140
- }
141
-
142
- } // end class
143
-
144
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-admin-sub-page.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_Admin_Sub_Page') and class_exists('Codefleet_Admin_Page')):
3
-
4
- /**
5
- * Class for wrapping WP add_submenu_page.
6
- */
7
- class Codefleet_Admin_Sub_Page extends Codefleet_Admin_Page {
8
-
9
- /**
10
- * Class variables relating to WP add_submenu_page
11
- */
12
- protected $parent_slug;
13
-
14
- /**
15
- * Initialize
16
- */
17
- public function __construct() {
18
- $this->page_title = 'Settings Sub Page';
19
- $this->menu_title = 'Settings Sub Page';
20
- $this->capability = 'manage_options';
21
- $this->menu_slug = 'custom-settings-sub-page';
22
- $this->icon_url = null;
23
- $this->position = null;
24
- $this->parent_slug = 'options-general.php';
25
- }
26
-
27
-
28
- /**
29
- * Show settings page by hooking 'em up with WP.
30
- */
31
- public function show(){
32
-
33
- // Add settings page
34
- add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
35
- }
36
-
37
- /**
38
- * Menu page action hook
39
- */
40
- public function add_menu_and_page(){
41
- // Use built-in WP function
42
- add_submenu_page(
43
- $this->parent_slug,
44
- $this->page_title,
45
- $this->menu_title,
46
- $this->capability,
47
- $this->menu_slug,
48
- array( $this, 'render_page')
49
- );
50
- }
51
-
52
- /**
53
- * SETTER FUNCTIONS
54
- */
55
- public function set_parent_slug( $value ){
56
- $this->parent_slug = $value;
57
- }
58
-
59
- /**
60
- * GETTER FUNCTIONS
61
- */
62
- public function get_parent_slug(){
63
- return $this->parent_slug;
64
- }
65
-
66
- } // end class
67
-
68
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-plugin-updater.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_Plugin_Updater')):
3
-
4
- /**
5
- * Manage updates for self hosted plugins
6
- */
7
- class Codefleet_Plugin_Updater {
8
-
9
- // Array containing list of plugins to manage
10
- protected $plugins;
11
-
12
- /**
13
- * Initialize properties
14
- */
15
- public function __construct() {
16
- $this->plugins = array();
17
- }
18
-
19
- /**
20
- * Add plugin to list
21
- *
22
- * @param string $slug - Format"plugin-folder/plugin-filename.php"
23
- * @param string $remote_url - URL for the remote file that returns our plugin info
24
- * @param string $current_version - Current version of installed plugin
25
- */
26
- public function add_plugin($slug, $remote_url, $current_version){
27
- $obj = new stdClass();
28
- $obj->slug = $slug;
29
- $obj->remote_url = $remote_url;
30
- $obj->current_version = $current_version;
31
-
32
- $this->plugins[$slug] = $obj;
33
- }
34
-
35
- /**
36
- * Filter WP data and insert custom data
37
- */
38
- public function check_updates(){
39
- // Insert custom plugins info to 'update_plugins" site transient
40
- add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
41
-
42
- // Define the alternative response for information checking
43
- add_filter('plugins_api', array($this, 'check_info'), 10, 3);
44
- }
45
-
46
- /**
47
- * Check update for each plugin in the list
48
- *
49
- * @param object $transient - The site transient containing plugin info
50
- */
51
- public function check_update($transient) {
52
-
53
- // Return we already checked
54
- if (empty($transient->checked)) {
55
- return $transient;
56
- }
57
-
58
- if(!empty($this->plugins)){
59
-
60
- foreach($this->plugins as $plugin_slug=>$plugin){
61
-
62
- // Get the remote version
63
- if( $remote_info = $this->get_remote_plugin_info($plugin->remote_url, $plugin_slug) ) {
64
-
65
- // If a newer version is available, add the update info
66
- if ( version_compare($plugin->current_version, $remote_info['version'], '<') ) {
67
-
68
- // Prepare needed info for transient using objects
69
- $obj = new stdClass();
70
-
71
- $obj->slug = $plugin_slug;
72
- $obj->new_version = $remote_info['version'];
73
- $obj->url = $remote_info['url'];
74
- $obj->package = $remote_info['package'];
75
-
76
- $transient->response[$plugin_slug] = $obj;
77
-
78
- }
79
-
80
- }
81
- }
82
- }
83
-
84
- return $transient;
85
- }
86
-
87
-
88
-
89
- /**
90
- * Add our self-hosted description to the filter
91
- */
92
- public function check_info($false, $action, $arg)
93
- {
94
- if(!empty($this->plugins)){
95
-
96
- foreach($this->plugins as $plugin_slug=>$plugin){
97
- if ( isset($arg->slug) and $plugin_slug === $arg->slug) {
98
-
99
- // Get the remote version
100
- $remote_info = $this->get_remote_plugin_info($plugin->remote_url, $plugin_slug);
101
-
102
- // Build needed info
103
- $information = new stdClass();
104
- $information->slug = $plugin_slug;
105
- $information->version = $remote_info['version'];
106
- $information->author = $remote_info['author'];
107
- $information->homepage = $remote_info['homepage'];
108
- $information->requires = $remote_info['requires'];
109
- $information->tested = $remote_info['tested'];
110
- $information->downloaded = $remote_info['downloaded'];
111
- $information->last_updated = $remote_info['last_updated'];
112
- $information->sections = $remote_info['sections'];
113
- $information->download_link = $remote_info['package'];
114
-
115
- return $information;
116
- }
117
- }
118
-
119
- }
120
- return $false;
121
- }
122
-
123
- /**
124
- * Fetch plugin info from remote url
125
- *
126
- * @param url $remote_url - URL to webpage that returns serialize data of plugin info
127
- * @param string $plugin - Plugin slug in this format: "[plugin-folder/plugin-name.php]"
128
- */
129
- public function get_remote_plugin_info($remote_url, $plugin) {
130
- $raw_response = wp_remote_post(
131
- $remote_url,
132
- array(
133
- 'body' => array(
134
- 'plugin' => $plugin
135
- )
136
- )
137
- );
138
-
139
- if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
140
- return false;
141
-
142
- $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
143
-
144
- return $response;
145
- }
146
-
147
- }
148
-
149
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-settings-page.php DELETED
@@ -1,228 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_Settings_Page')):
3
-
4
- /**
5
- * Class for settings page creation.
6
- */
7
- class Codefleet_Settings_Page {
8
-
9
- /**
10
- * Class variables relating to WP settings API
11
- */
12
- protected $option_group;
13
- protected $option_name;
14
- protected $page_title;
15
- protected $menu_title;
16
- protected $capability;
17
- protected $menu_slug;
18
- protected $icon_url;
19
- protected $position;
20
-
21
- /**
22
- * Initialize
23
- */
24
- public function __construct() {
25
- $this->option_group = 'mytheme_option_group';
26
- $this->option_name = 'mytheme_option_name';
27
- $this->page_title = 'Custom Settings';
28
- $this->menu_title = 'Custom Settings';
29
- $this->capability = 'manage_options';
30
- $this->menu_slug = 'custom-settings-page';
31
- $this->icon_url = null;
32
- $this->position = null;
33
- }
34
-
35
- /**
36
- * Show settings page by hooking 'em up with WP.
37
- */
38
- public function show(){
39
-
40
- // Add settings
41
- add_action( 'admin_init', array( $this, 'register_settings') );
42
-
43
- // Add settings page
44
- add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
45
- }
46
-
47
- /**
48
- * Prepare option data
49
- */
50
- public function register_settings() {
51
- // Use built-in WP function
52
- register_setting(
53
- $this->option_group,
54
- $this->option_name,
55
- array( $this, 'validate_options')
56
- );
57
- }
58
-
59
- /**
60
- * Menu page action hook
61
- */
62
- public function add_menu_and_page(){
63
- // Use built-in WP function
64
- add_menu_page(
65
- $this->page_title,
66
- $this->menu_title,
67
- $this->capability,
68
- $this->menu_slug,
69
- array( $this, 'render_settings_page'),
70
- $this->icon_url,
71
- $this->position
72
- );
73
- }
74
-
75
- /**
76
- * Render settings page. This function should echo the HTML form of the settings page.
77
- */
78
- public function render_settings_page($post){
79
- ?>
80
- <div class="wrap">
81
- <?php echo get_screen_icon('options-general'); ?>
82
- <h2><?php echo $this->page_title; ?></h2>
83
- <div class="intro">
84
- <p>This is the intro text</p>
85
- </div>
86
- <?php settings_errors(); print_r($this->get_settings_data()); ?>
87
-
88
- <form method="post" action="options.php">
89
- <?php
90
- echo $this->settings_fields( $this->option_group );
91
- ?>
92
- <table class="form-table">
93
- <tr>
94
- <th><label for="<?php echo esc_attr( 'footer' ); ?>"><?php echo esc_attr( 'Footer Text' ); ?></label></th>
95
- <td>
96
- <input type="text" id="<?php echo esc_attr( 'footer' ); ?>" name="<?php echo esc_attr( $this->option_name."[footer]" ); ?>" value="<?php echo esc_attr( $this->get_data('footer') ); ?>" />
97
- </td>
98
- </tr>
99
- </table>
100
- <?php submit_button( 'Save Options', 'primary', 'submit', false) ?>
101
- <?php submit_button( 'Restore Defaults', 'secondary', 'reset', false) ?>
102
- </form>
103
-
104
- </div><?php
105
- }
106
-
107
- /**
108
- * Validate data from form
109
- */
110
- public function validate_options( $input ) {
111
- $input = wp_parse_args($input, $this->get_settings_data());
112
- if( isset($_POST['reset']) ){
113
- $input = $this->get_default_settings_data();
114
- add_settings_error( $this->menu_slug, 'restore_defaults', __( 'Default options restored.'), 'updated fade' );
115
- }
116
- return $input;
117
- }
118
-
119
- /**
120
- * Output needed fields for security
121
- */
122
- function settings_fields( $option_group ) {
123
- $fields = "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";
124
- $fields .= '<input type="hidden" name="action" value="update" />';
125
- $fields .= wp_nonce_field("$option_group-options", '_wpnonce', true, false);
126
- return $fields;
127
- }
128
-
129
- /**
130
- * Get settings data. If there is no data from database, use default values
131
- */
132
- public function get_settings_data(){
133
- return get_option( $this->option_name, $this->get_default_settings_data() );
134
- }
135
-
136
- /**
137
- * Get settings data by uid
138
- */
139
- public function get_data($uid){
140
- $settings_data = $this->get_settings_data();
141
- if(isset($settings_data[$uid])){
142
- return $settings_data[$uid];
143
- }
144
- return false;
145
- }
146
-
147
- /**
148
- * Apply default values
149
- */
150
- public function get_default_settings_data() {
151
- $defaults = array();
152
-
153
- return $defaults;
154
- }
155
-
156
- /**
157
- * SETTER FUNCTIONS
158
- */
159
- public function set_option_group( $value ){
160
- $this->option_group = $value;
161
- }
162
-
163
- public function set_option_name( $value ){
164
- $this->option_name = $value;
165
- }
166
-
167
- public function set_page_title( $value ){
168
- $this->page_title = $value;
169
- }
170
-
171
- public function set_menu_title( $value ){
172
- $this->menu_title = $value;
173
- }
174
-
175
- public function set_capability( $value ){
176
- $this->capability = $value;
177
- }
178
-
179
- public function set_menu_slug( $value ){
180
- $this->menu_slug = $value;
181
- }
182
-
183
- public function set_icon_url( $value ){
184
- $this->icon_url = $value;
185
- }
186
-
187
- public function set_position( $value ){
188
- $this->position = $value;
189
- }
190
-
191
- /**
192
- * GETTER FUNCTIONS
193
- */
194
- public function get_option_group(){
195
- return $this->option_group;
196
- }
197
-
198
- public function get_option_name(){
199
- return $this->option_name;
200
- }
201
-
202
- public function get_page_title(){
203
- return $this->page_title;
204
- }
205
-
206
- public function get_menu_title(){
207
- return $this->menu_title;
208
- }
209
-
210
- public function get_capability(){
211
- return $this->capability;
212
- }
213
-
214
- public function get_menu_slug(){
215
- return $this->menu_slug;
216
- }
217
-
218
- public function get_icon_url(){
219
- return $this->icon_url;
220
- }
221
-
222
- public function get_position(){
223
- return $this->position;
224
- }
225
-
226
- } // end class
227
-
228
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-settings-sub-page.php DELETED
@@ -1,84 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_Settings_Sub_Page') and class_exists('Codefleet_Settings_Page')):
3
-
4
- /**
5
- * Class for settings for sub page creation.
6
- */
7
- class Codefleet_Settings_Sub_Page extends Codefleet_Settings_Page {
8
-
9
- /**
10
- * Class variables relating to WP settings API
11
- */
12
- protected $parent_slug;
13
-
14
- /**
15
- * Initialize
16
- */
17
- public function __construct() {
18
- $this->option_group = 'mytheme_option_group';
19
- $this->option_name = 'mytheme_option_name';
20
- $this->page_title = 'Settings Sub Page';
21
- $this->menu_title = 'Settings Sub Page';
22
- $this->capability = 'manage_options';
23
- $this->menu_slug = 'custom-settings-sub-page';
24
- $this->icon_url = null;
25
- $this->position = null;
26
- $this->parent_slug = 'options-general.php';
27
- }
28
-
29
-
30
- /**
31
- * Show settings page by hooking 'em up with WP.
32
- */
33
- public function show(){
34
-
35
- // Add settings
36
- add_action( 'admin_init', array( $this, 'register_settings') );
37
-
38
- // Add settings page
39
- add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
40
- }
41
-
42
- /**
43
- * Prepare option data
44
- */
45
- public function register_settings() {
46
- register_setting(
47
- $this->option_group,
48
- $this->option_name,
49
- array( $this, 'validate_options')
50
- );
51
- }
52
-
53
- /**
54
- * Menu page action hook
55
- */
56
- public function add_menu_and_page(){
57
- // Use built-in WP function
58
- add_submenu_page(
59
- $this->parent_slug,
60
- $this->page_title,
61
- $this->menu_title,
62
- $this->capability,
63
- $this->menu_slug,
64
- array( $this, 'render_settings_page')
65
- );
66
- }
67
-
68
- /**
69
- * SETTER FUNCTIONS
70
- */
71
- public function set_parent_slug( $value ){
72
- $this->parent_slug = $value;
73
- }
74
-
75
- /**
76
- * GETTER FUNCTIONS
77
- */
78
- public function get_parent_slug(){
79
- return $this->parent_slug;
80
- }
81
-
82
- } // end class
83
-
84
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/class-codefleet-view.php DELETED
@@ -1,76 +0,0 @@
1
- <?php
2
- if(!class_exists('Codefleet_View')):
3
-
4
- /**
5
- * Class for conveniently fetching template files and attaching template variables
6
- */
7
- class Codefleet_View {
8
-
9
- protected $view_file;
10
- protected $vars = array();
11
-
12
- /**
13
- * Constructor
14
- */
15
- public function __construct( $view_file='' ){
16
- $this->view_file = $view_file;
17
- }
18
-
19
- /**
20
- * Magic functions
21
- */
22
- public function __get( $key ) {
23
- return $this->vars[$key];
24
- }
25
-
26
- public function __set( $key, $value ) {
27
- $this->vars[$key] = $value;
28
- }
29
-
30
- /**
31
- * Setters
32
- */
33
- public function set_view_file( $value ){
34
- $this->view_file = $value;
35
- }
36
-
37
- public function set_vars( $value ){
38
- $this->vars = $value;
39
- }
40
-
41
- /**
42
- * Getters
43
- */
44
- public function get_view_file(){
45
- return $this->view_file;
46
- }
47
-
48
- public function get_vars(){
49
- return $this->vars;
50
- }
51
-
52
- /**
53
- * Include the view file and extract the passed variables
54
- */
55
- public function render(){
56
-
57
- if(@file_exists($this->view_file)){
58
- extract($this->vars, EXTR_SKIP); // Extract variables
59
-
60
- include($this->view_file); //Include the view file
61
- } else {
62
- echo '<p>Not found '.$this->view_file.'</p>';
63
- }
64
- }
65
-
66
- /**
67
- * Get and return view_file contents as string
68
- */
69
- public function get_render(){
70
- ob_start();
71
- $this->render();
72
- return ob_get_clean();
73
- }
74
- }
75
-
76
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/codefleet/info.txt DELETED
@@ -1 +0,0 @@
1
- Contains common classes for codefleet.net plugins
 
css/admin.css CHANGED
@@ -689,4 +689,10 @@ label[for="force_resize"]{
689
  }
690
  .cs2-disabled{
691
  color: #999;
692
- }
 
 
 
 
 
 
689
  }
690
  .cs2-disabled{
691
  color: #999;
692
+ }
693
+
694
+ /* Override Admin CSS to prevent covering the lightbox prev button during preview */
695
+ .sticky-menu #adminmenuwrap {
696
+ z-index: 999;
697
+ }
698
+
cyclone-slider.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cyclone Slider 2
4
  Plugin URI: http://www.codefleet.net/cyclone-slider-2/
5
  Description: Create and manage sliders with ease. Built for both casual users and developers.
6
- Version: 2.8.4
7
  Author: Nico Amarilla
8
  Author URI: http://www.codefleet.net/
9
  License:
@@ -24,116 +24,71 @@ License:
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
 
26
  */
27
- if(!defined('CYCLONE_VERSION')){
28
- define('CYCLONE_VERSION', '2.8.4' );
29
- }
30
- if(!defined('CYCLONE_PATH')){
31
- define('CYCLONE_PATH', realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR );
32
- }
33
- if(!defined('CYCLONE_URL')){
34
- define('CYCLONE_URL', plugin_dir_url(__FILE__) );
35
- }
36
- if(!defined('CYCLONE_DEBUG')){
37
- define('CYCLONE_DEBUG', false );
38
- }
39
-
40
- // Include common classes
41
- require_once(CYCLONE_PATH.'classes/codefleet/class-codefleet-view.php');
42
- require_once(CYCLONE_PATH.'classes/codefleet/class-codefleet-admin-page.php');
43
- require_once(CYCLONE_PATH.'classes/codefleet/class-codefleet-admin-sub-page.php');
44
- require_once(CYCLONE_PATH.'classes/codefleet/class-codefleet-settings-page.php');
45
- require_once(CYCLONE_PATH.'classes/codefleet/class-codefleet-settings-sub-page.php');
46
-
47
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-exporter.php');
48
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-importer.php');
49
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-settings-page.php');
50
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-export-page.php');
51
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-import-page.php');
52
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-data.php');
53
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-youtube.php');
54
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-vimeo.php');
55
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-admin.php');
56
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider.php');
57
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-widget.php');
58
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-scripts.php');
59
- require_once(CYCLONE_PATH.'classes/class-cyclone-templates-manager.php');
60
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-image-editor.php');
61
- require_once(CYCLONE_PATH.'classes/class-cyclone-slider-image-resizer.php');
62
- require_once(CYCLONE_PATH.'classes/class-image-resizer.php');
63
- require_once(CYCLONE_PATH.'classes/class-nextgen-integration.php');
64
- require_once(CYCLONE_PATH.'inc/functions.php');
65
-
66
- $cyclone_slider_saved_done = false; //Global variable to limit save_post execution to only once
67
-
68
- // Store the plugin instance to a global object so that other plugins can use remove_action and remove_filter
69
- // Inject dependencies here
70
- $codefleet_view = new Codefleet_View();
71
-
72
- $cyclone_slider_image_resizer = new Cyclone_Slider_Image_Resizer();
73
-
74
- $cyclone_slider_data = new Cyclone_Slider_Data( $cyclone_slider_image_resizer );
75
-
76
- $cyclone_slider_nextgen_integration = new Nextgen_Integration( $cyclone_slider_data );
77
-
78
- $cyclone_slider_exporter = new Cyclone_Slider_Exporter( $cyclone_slider_data );
79
-
80
- $cyclone_slider_importer = new Cyclone_Slider_Importer( $cyclone_slider_data );
81
-
82
- $cyclone_slider_templates_manager = new Cyclone_Templates_Manager();
83
-
84
- // Add directories to get templates
85
- $cyclone_slider_templates_manager->add_template_location(
86
- array(
87
- 'path' => CYCLONE_PATH.'templates'.DIRECTORY_SEPARATOR, // This resides in the plugin
88
- 'url' => CYCLONE_URL.'templates/',
89
- 'location_name' => 'core'
90
- )
91
- );
92
- $cyclone_slider_templates_manager->add_template_location(
93
- array(
94
- 'path' => realpath(get_stylesheet_directory()).DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR,// This resides in the current theme or child theme
95
- 'url' => get_stylesheet_directory_uri()."/cycloneslider/",
96
- 'location_name' => 'active-theme'
97
- )
98
- );
99
-
100
- $cyclone_upload_dir = wp_upload_dir();
101
- $cyclone_template_folder = realpath( dirname( $cyclone_upload_dir['basedir'] ) );
102
-
103
- $cyclone_slider_templates_manager->add_template_location(
104
- array(
105
- 'path' => $cyclone_template_folder.DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR,// This resides in the wp-content folder to prevent deleting when upgrading themes
106
- 'url' => content_url()."/cycloneslider/",
107
- 'location_name' => 'wp-content'
108
- )
109
- );
110
-
111
-
112
- $cyclone_slider_settings_page = new Cyclone_Slider_Settings_Page( $codefleet_view, $cyclone_slider_templates_manager );
113
- $cyclone_slider_settings_page->set_option_group('cyclone_option_group');
114
- $cyclone_slider_settings_page->set_option_name('cyclone_option_name');
115
- $cyclone_slider_settings_page->set_parent_slug('edit.php?post_type=cycloneslider');
116
- $cyclone_slider_settings_page->set_menu_slug('cycloneslider-settings');
117
 
118
- $cyclone_slider_youtube = new Cyclone_Slider_Youtube();
119
- $cyclone_slider_vimeo = new Cyclone_Slider_Vimeo();
120
-
121
- $cyclone_slider_scripts = new Cyclone_Slider_Scripts( $cyclone_slider_templates_manager, $cyclone_slider_settings_page->get_settings_data() );
 
 
 
 
 
122
 
123
- $cyclone_slider_admin = new Cyclone_Slider_Admin( $codefleet_view, $cyclone_slider_scripts, $cyclone_slider_templates_manager, $cyclone_slider_data, $cyclone_slider_settings_page->get_settings_data() );
124
 
125
- $cyclone_slider_plugin_instance = new Cyclone_Slider( $cyclone_slider_scripts, $cyclone_slider_data, $codefleet_view, $cyclone_slider_templates_manager, $cyclone_slider_youtube, $cyclone_slider_vimeo );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
- // Load domain in this hook to work with WPML
128
- add_action('plugins_loaded', 'cycloneslider_plugin_init');
129
- function cycloneslider_plugin_init() {
130
- global $cyclone_slider_settings_page;
131
 
132
- load_plugin_textdomain( 'cycloneslider', false, basename(CYCLONE_PATH).'/lang' );
 
 
 
 
 
 
133
 
134
- // These strings should be here for translation to work
135
- $cyclone_slider_settings_page->set_page_title( __('Cyclone Slider Settings', 'cycloneslider') );
136
- $cyclone_slider_settings_page->set_menu_title( __('Settings', 'cycloneslider') );
137
- $cyclone_slider_settings_page->show();
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
 
3
  Plugin Name: Cyclone Slider 2
4
  Plugin URI: http://www.codefleet.net/cyclone-slider-2/
5
  Description: Create and manage sliders with ease. Built for both casual users and developers.
6
+ Version: 2.9.0
7
  Author: Nico Amarilla
8
  Author URI: http://www.codefleet.net/
9
  License:
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
 
26
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ function cslider_autoloader($classname) {
29
+ if(false !== strpos($classname, 'CycloneSlider')){
30
+ $plugin_dir = realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR;
31
+ $classname = str_replace('_', DIRECTORY_SEPARATOR, $classname);
32
+ $file = $plugin_dir .'src'.DIRECTORY_SEPARATOR. $classname . '.php';
33
+ require_once $file;
34
+ }
35
+ }
36
+ spl_autoload_register('cslider_autoloader');
37
 
38
+ $cyclone_slider_plugin_instance = null;
39
 
40
+ // Hook the plugin
41
+ add_action('plugins_loaded', 'cslider_init', 10);
42
+ function cslider_init() {
43
+ global $cyclone_slider_plugin_instance;
44
+
45
+ $plugin = new CycloneSlider_Main();
46
+
47
+ $plugin['path'] = realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR;
48
+ $plugin['url'] = plugin_dir_url(__FILE__);
49
+
50
+ $plugin['debug'] = false;
51
+ $plugin['version'] = '2.9.0';
52
+ $plugin['textdomain'] = 'cycloneslider';
53
+ $plugin['slug'] = 'cyclone-slider-2/cyclone-slider.php';
54
+ $plugin['nonce_name'] = 'cyclone_slider_builder_nonce';
55
+ $plugin['nonce_action'] = 'cyclone-slider-save';
56
+
57
+ require_once($plugin['path'].'src/functions.php');
58
+
59
+ $plugin['view'] = new CycloneSlider_View();
60
+
61
+ $plugin['image_resizer'] = new CycloneSlider_ImageResizer();
62
+
63
+ $plugin['data'] = new CycloneSlider_Data();
64
 
65
+ $plugin['nextgen_integration'] = new CycloneSlider_NextgenIntegration();
66
+
67
+ $plugin['templates_manager'] = new CycloneSlider_TemplatesManager();
 
68
 
69
+ $plugin['settings_page'] = new CycloneSlider_SettingsPage();
70
+ $plugin['settings_page.page_title'] = __('Cyclone Slider Settings', $plugin['textdomain']);
71
+ $plugin['settings_page.menu_title'] = __('Settings', $plugin['textdomain']);
72
+ $plugin['settings_page.option_group'] = 'cyclone_option_group';
73
+ $plugin['settings_page.option_name'] = 'cyclone_option_name';
74
+ $plugin['settings_page.parent_slug'] = 'edit.php?post_type=cycloneslider';
75
+ $plugin['settings_page.menu_slug'] = 'cycloneslider-settings';
76
 
 
 
 
 
77
 
78
+ $plugin['youtube'] = new CycloneSlider_Youtube();
79
+
80
+ $plugin['vimeo'] = new CycloneSlider_Vimeo();
81
+
82
+ $plugin['asset_loader'] = new CycloneSlider_AssetLoader();
83
+
84
+ $plugin['admin'] = new CycloneSlider_Admin();
85
+
86
+ $plugin['frontend'] = new CycloneSlider_Frontend();
87
+
88
+
89
+
90
+ $plugin->run();
91
+
92
+ $cyclone_slider_plugin_instance = $plugin;
93
  }
94
+
lang/cycloneslider-es_ES.po CHANGED
@@ -1,1055 +1,1055 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Cyclone Slider 2 v2.8.3\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-12-29 18:36+0800\n"
6
- "PO-Revision-Date: 2014-08-29 17:45+0100\n"
7
- "Last-Translator: \n"
8
- "Language-Team: Digital03 <info@digital03.net>\n"
9
- "Language: es_ES\n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
- "X-Generator: Poedit 1.6.8\n"
15
- "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
- "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
18
- "X-Poedit-Basepath: .\n"
19
- "X-Textdomain-Support: yes\n"
20
- "X-Poedit-SearchPath-0: .\n"
21
-
22
- # @ cycloneslider
23
- #: ../cyclone-slider.php:135
24
- msgid "Cyclone Slider Settings"
25
- msgstr "Ajustes de Cyclone Slider"
26
-
27
- # @ cycloneslider
28
- #: ../cyclone-slider.php:136
29
- msgid "Settings"
30
- msgstr "Ajustes"
31
-
32
- # @ cycloneslider
33
- #: ../classes/class-cyclone-slider-admin.php:96
34
- msgid "Cyclone Slider"
35
- msgstr "Cyclone Slider"
36
-
37
- # @ cycloneslider
38
- #: ../classes/class-cyclone-slider-admin.php:97
39
- msgid "Slideshow"
40
- msgstr "Slideshow"
41
-
42
- # @ cycloneslider
43
- #: ../classes/class-cyclone-slider-admin.php:98
44
- msgid "Add Slideshow"
45
- msgstr "Añadir slideshow"
46
-
47
- # @ cycloneslider
48
- #: ../classes/class-cyclone-slider-admin.php:99
49
- msgid "Add New Slideshow"
50
- msgstr "Añadir nuevo slideshow"
51
-
52
- # @ cycloneslider
53
- #: ../classes/class-cyclone-slider-admin.php:100
54
- msgid "Edit Slideshow"
55
- msgstr "Editar slideshow"
56
-
57
- # @ cycloneslider
58
- #: ../classes/class-cyclone-slider-admin.php:101
59
- msgid "New Slideshow"
60
- msgstr "Nuevo slideshow"
61
-
62
- # @ cycloneslider
63
- #: ../classes/class-cyclone-slider-admin.php:102
64
- msgid "View Slideshow"
65
- msgstr "Ver slideshow"
66
-
67
- # @ cycloneslider
68
- #: ../classes/class-cyclone-slider-admin.php:103
69
- msgid "Search Slideshows"
70
- msgstr "Buscar slideshows"
71
-
72
- # @ cycloneslider
73
- #: ../classes/class-cyclone-slider-admin.php:104
74
- msgid "No slideshows found"
75
- msgstr "No se han encontrado slideshows"
76
-
77
- # @ cycloneslider
78
- #: ../classes/class-cyclone-slider-admin.php:105
79
- msgid "No slideshows found in Trash"
80
- msgstr "No hay slideshows en la papelera"
81
-
82
- # @ cycloneslider
83
- #: ../classes/class-cyclone-slider-admin.php:141
84
- #: ../classes/class-cyclone-slider-admin.php:144
85
- #: ../classes/class-cyclone-slider-admin.php:145
86
- #: ../classes/class-cyclone-slider-admin.php:148
87
- #: ../classes/class-cyclone-slider-admin.php:149
88
- #: ../classes/class-cyclone-slider-admin.php:150
89
- msgid "Slideshow updated."
90
- msgstr "Slideshow actualizado."
91
-
92
- # @ cycloneslider
93
- #: ../classes/class-cyclone-slider-admin.php:142
94
- msgid "Custom field updated."
95
- msgstr "Campos personalizados actualizados"
96
-
97
- # @ cycloneslider
98
- #: ../classes/class-cyclone-slider-admin.php:143
99
- msgid "Custom field deleted."
100
- msgstr "Campo personalizado eliminado."
101
-
102
- # @ cycloneslider
103
- #: ../classes/class-cyclone-slider-admin.php:146
104
- msgid "Slideshow published."
105
- msgstr "Slideshow publicado."
106
-
107
- # @ cycloneslider
108
- #: ../classes/class-cyclone-slider-admin.php:147
109
- msgid "Slideshow saved."
110
- msgstr "Slideshow guardado."
111
-
112
- # @ cycloneslider
113
- #: ../classes/class-cyclone-slider-admin.php:151
114
- #, php-format
115
- msgid ""
116
- "Templates CSS could not be saved. Make sure %stemplates.css is writable."
117
- msgstr ""
118
- "La plantilla CSS no ha podido ser guardada. Asegurate que %stemplates.css "
119
- "tiene permiso de escritura."
120
-
121
- # @ cycloneslider
122
- #: ../classes/class-cyclone-slider-admin.php:152
123
- #, php-format
124
- msgid "Templates JS could not be saved. Make sure %stemplates.js is writable."
125
- msgstr ""
126
- "La plantilla JS no ha podido ser guardada. Asegurate que %stemplates.js "
127
- "tiene permisos de escritura."
128
-
129
- # @ cycloneslider
130
- #: ../classes/class-cyclone-slider-admin.php:186
131
- msgid "Slides"
132
- msgstr "Diapositivas"
133
-
134
- # @ cycloneslider
135
- #: ../classes/class-cyclone-slider-admin.php:195
136
- msgid "Slider Preview"
137
- msgstr "Vista previa"
138
-
139
- # @ cycloneslider
140
- #: ../classes/class-cyclone-slider-admin.php:204
141
- msgid "Get Slider Codes"
142
- msgstr "Ver el código del slider"
143
-
144
- # @ cycloneslider
145
- #: ../classes/class-cyclone-slider-admin.php:213
146
- msgid "Basic Settings"
147
- msgstr "Ajustes básicos"
148
-
149
- # @ cycloneslider
150
- #: ../classes/class-cyclone-slider-admin.php:222
151
- msgid "Advanced Settings"
152
- msgstr "Ajustes avanzados"
153
-
154
- # @ cycloneslider
155
- #: ../classes/class-cyclone-slider-admin.php:231
156
- msgid "Templates"
157
- msgstr "Plantillas"
158
-
159
- # @ cycloneslider
160
- #: ../classes/class-cyclone-slider-admin.php:240
161
- #: ../classes/class-cyclone-slider-admin.php:524
162
- msgid "Slideshow ID"
163
- msgstr "ID del slideshow"
164
-
165
- # @ cycloneslider
166
- #: ../classes/class-cyclone-slider-admin.php:268
167
- msgid "Slide"
168
- msgstr "Diapositiva"
169
-
170
- # @ cycloneslider
171
- #: ../classes/class-cyclone-slider-admin.php:406
172
- msgid "Core"
173
- msgstr "Núcleo"
174
-
175
- # @ cycloneslider
176
- #: ../classes/class-cyclone-slider-admin.php:407
177
- #, php-format
178
- msgid ""
179
- "Located inside the Cyclone Slider's templates directory:<br> <strong>%s</"
180
- "strong>"
181
- msgstr ""
182
- "Localizado dentro del directorio de plantillas de Cyclone Slider:<br> "
183
- "<strong>%s</strong>"
184
-
185
- # @ cycloneslider
186
- #: ../classes/class-cyclone-slider-admin.php:411
187
- #, php-format
188
- msgid "Located inside your currently active theme:<br> <strong>%s</strong>"
189
- msgstr "Localizado dentro de tu tema actual:<br> <strong>%s</strong>"
190
-
191
- # @ cycloneslider
192
- #: ../classes/class-cyclone-slider-admin.php:412
193
- #, php-format
194
- msgid ""
195
- "Your template is in danger of being overwritten when you upgrade your theme. "
196
- "Please move it inside %s."
197
- msgstr ""
198
- "Tu plantilla está en peligro de ser sobre-escrita cuando actualices tu tema. "
199
- "Por favor, muevela dentro de %s."
200
-
201
- # @ cycloneslider
202
- #: ../classes/class-cyclone-slider-admin.php:416
203
- #, php-format
204
- msgid "Located inside wp-content directory:<br> <strong>%s</strong>"
205
- msgstr "Localizado dentro de la carpeta wp-content:<br> <strong>%s</strong>"
206
-
207
- # @ cycloneslider
208
- #: ../classes/class-cyclone-slider-admin.php:457
209
- msgid "Slide *"
210
- msgstr "Diapositiva *"
211
-
212
- # @ cycloneslider
213
- #: ../classes/class-cyclone-slider-admin.php:521
214
- msgid "Slideshow Name"
215
- msgstr "Nombre del slideshow"
216
-
217
- # @ cycloneslider
218
- #: ../classes/class-cyclone-slider-admin.php:522
219
- msgid "Template"
220
- msgstr "Plantilla"
221
-
222
- # @ cycloneslider
223
- #: ../classes/class-cyclone-slider-admin.php:523
224
- msgid "No. of Slides"
225
- msgstr "No. de diapositivas"
226
-
227
- # @ cycloneslider
228
- #: ../classes/class-cyclone-slider-admin.php:525
229
- msgid "Shortcode"
230
- msgstr "Shortcode"
231
-
232
- # @ cycloneslider
233
- #: ../classes/class-cyclone-slider-scripts.php:52
234
- msgid "Select an image"
235
- msgstr "Seleciona una imagen"
236
-
237
- # @ cycloneslider
238
- #: ../classes/class-cyclone-slider-scripts.php:53
239
- msgid "Select Images - Use Ctrl + Click or Shift + Click"
240
- msgstr "Selecionar varias imágenes - Usar Ctrl + Click o Shift + Click"
241
-
242
- # @ cycloneslider
243
- #: ../classes/class-cyclone-slider-scripts.php:54
244
- msgid "Add to Slide"
245
- msgstr "Añadir a la diapositiva"
246
-
247
- # @ cycloneslider
248
- #: ../classes/class-cyclone-slider-scripts.php:55 ../views/slides.php:9
249
- msgid "Add Images as Slides"
250
- msgstr "Añadir imágenes como diapositivas"
251
-
252
- # @ cycloneslider
253
- #: ../classes/class-cyclone-slider-scripts.php:56
254
- msgid "Error. Make sure its a valid YouTube URL."
255
- msgstr "Error. Asegúrate de que es una dirección de YouTube válida."
256
-
257
- # @ cycloneslider
258
- # @ default
259
- #: ../classes/class-cyclone-slider-settings-page.php:62
260
- #: ../classes/codefleet/class-codefleet-settings-page.php:114
261
- msgid "Default options restored."
262
- msgstr "Ajustes por defecto restaurados."
263
-
264
- # @ cycloneslider
265
- #: ../classes/class-cyclone-slider-widget.php:15
266
- msgid "Cyclone Slider Widget"
267
- msgstr "Cyclone Slider Widget"
268
-
269
- # @ cycloneslider
270
- #: ../classes/class-cyclone-slider-widget.php:16
271
- msgid "Widget for displaying sliders."
272
- msgstr "Widget para mostrar diapositivas."
273
-
274
- # @ cycloneslider
275
- #: ../classes/class-cyclone-slider-widget.php:67 ../views/slide-edit.php:49
276
- msgid "Title:"
277
- msgstr "Título:"
278
-
279
- # @ cycloneslider
280
- #: ../classes/class-cyclone-slider-widget.php:81
281
- msgid "Select a Slider:"
282
- msgstr "Selectionar un Slider"
283
-
284
- # @ cycloneslider
285
- #: ../classes/class-cyclone-slider-widget.php:96
286
- msgid "No sliders found."
287
- msgstr "No se han encontrado Sliders."
288
-
289
- # @ cycloneslider
290
- #: ../classes/class-cyclone-slider.php:80
291
- #, php-format
292
- msgid "[Slideshow \"%s\" not found]"
293
- msgstr "[Slideshow \"%s\" no encontrado]"
294
-
295
- # @ cycloneslider
296
- #: ../classes/class-cyclone-slider.php:92
297
- #, php-format
298
- msgid "[Template \"%s\" not found]"
299
- msgstr "[Plantilla \"%s\" no encontrada]"
300
-
301
- # @ cycloneslider
302
- #: ../classes/class-nextgen-integration.php:37
303
- msgid "NextGEN Integration"
304
- msgstr "Integración con NextGEN"
305
-
306
- # @ cycloneslider
307
- #: ../classes/class-nextgen-integration.php:53
308
- msgid "Choose a NextGEN Gallery"
309
- msgstr "Escoge una galería NextGEN"
310
-
311
- # @ cycloneslider
312
- #: ../classes/class-nextgen-integration.php:63 ../views/export-step-1.php:7
313
- #: ../views/export-step-2.php:7 ../views/import-step-1.php:7
314
- #: ../views/import-step-2.php:7
315
- msgid "Import"
316
- msgstr "Importar"
317
-
318
- # @ cycloneslider
319
- #: ../classes/class-nextgen-integration.php:65
320
- msgid ""
321
- "Select a gallery to import images from. Images will be added as new slides."
322
- msgstr ""
323
- "Selecciona una galería para importar las imágenes. Las imagenes serán "
324
- "añadidas como nuevas diapositivas."
325
-
326
- # @ cycloneslider
327
- #: ../templates/dark/slider.php:43
328
- msgid "View Larger Image"
329
- msgstr "Ver imagen grande"
330
-
331
- # @ cycloneslider
332
- #: ../templates/dark/slider.php:46 ../templates/dark/slider.php:48
333
- msgid "Learn More"
334
- msgstr "Saber más"
335
-
336
- # @ cycloneslider
337
- #: ../templates/dark/slider.php:64 ../templates/default/slider.php:62
338
- #: ../templates/default/slider.php:66 ../templates/default/slider.php:70
339
- #: ../templates/standard/slider.php:70 ../templates/thumbnails/slider.php:70
340
- msgid "Slide type not supported."
341
- msgstr "Tipo de diapositiva no soportado."
342
-
343
- # @ cycloneslider
344
- #: ../views/export-step-1.php:6 ../views/export-step-2.php:6
345
- #: ../views/import-step-1.php:6 ../views/import-step-2.php:6
346
- msgid "Export"
347
- msgstr "Exportar"
348
-
349
- # @ cycloneslider
350
- #: ../views/export-step-1.php:9 ../views/export-step-2.php:9
351
- msgid "Cyclone Slider Export"
352
- msgstr "Exportar Cyclone Slider"
353
-
354
- # @ cycloneslider
355
- #: ../views/export-step-1.php:18
356
- msgid "Select sliders:"
357
- msgstr "Seleccionar sliders:"
358
-
359
- # @ cycloneslider
360
- #: ../views/export-step-1.php:24
361
- msgid "Select All"
362
- msgstr "Seleccionar todo"
363
-
364
- # @ cycloneslider
365
- #: ../views/export-step-1.php:37
366
- msgid "No slider to export."
367
- msgstr "No hay sliders para exportar."
368
-
369
- # @ cycloneslider
370
- #: ../views/export-step-1.php:40 ../views/import-step-1.php:25
371
- msgid "Next"
372
- msgstr "Siguiente"
373
-
374
- # @ cycloneslider
375
- #: ../views/export-step-2.php:16
376
- msgid "Your export file is ready. Click Download."
377
- msgstr "El archivo de exportación ha sido realizado. Pulsa para descargar."
378
-
379
- # @ cycloneslider
380
- #: ../views/export-step-2.php:18 ../views/export-step-2.php:27
381
- #: ../views/import-step-2.php:18 ../views/import-step-2.php:26
382
- msgid "Back"
383
- msgstr "Volver"
384
-
385
- # @ cycloneslider
386
- #: ../views/export-step-2.php:19
387
- msgid "Download"
388
- msgstr "Descargar"
389
-
390
- # @ cycloneslider
391
- #: ../views/import-step-1.php:9 ../views/import-step-2.php:9
392
- msgid "Cyclone Slider Import"
393
- msgstr "Importar Cyclone Slider"
394
-
395
- # @ cycloneslider
396
- #: ../views/import-step-1.php:18
397
- msgid "Import Zip File:"
398
- msgstr "Importar archivo Zip:"
399
-
400
- # @ cycloneslider
401
- #: ../views/import-step-2.php:16
402
- msgid "Import operation success!"
403
- msgstr "La importación se ha realizado correctamente!"
404
-
405
- # @ cycloneslider
406
- #: ../views/settings-page.php:7
407
- msgid ""
408
- "Play with these settings if Cyclone Slider 2 is not working or if you want "
409
- "to optimize it."
410
- msgstr ""
411
- "Cambia estas opciones si Cyclone Slider 2 no funciona bien o si quieres "
412
- "optimizarlo."
413
-
414
- # @ cycloneslider
415
- #: ../views/settings-page.php:17
416
- msgid "Load scripts in:"
417
- msgstr "Cargar scripts en:"
418
-
419
- # @ cycloneslider
420
- #: ../views/settings-page.php:20
421
- msgid "Header"
422
- msgstr "Cabecera"
423
-
424
- # @ cycloneslider
425
- #: ../views/settings-page.php:21
426
- msgid "Footer"
427
- msgstr "Pie de página"
428
-
429
- # @ cycloneslider
430
- #: ../views/settings-page.php:26
431
- msgid "Load these scripts:"
432
- msgstr "Cargar estos scripts"
433
-
434
- # @ cycloneslider
435
- #: ../views/settings-page.php:31
436
- msgid "Cycle 2. This is the core script needed by the plugin."
437
- msgstr "Cycle 2. Este es el script necesario para que el plugin funcione."
438
-
439
- # @ cycloneslider
440
- #: ../views/settings-page.php:36
441
- msgid "Cycle 2 - Carousel. Used by these templates: Galleria, Lea, Dos."
442
- msgstr "Cycle 2 - Carousel. Usado por estas plantillas: Galería, Lea, Dos."
443
-
444
- # @ cycloneslider
445
- #: ../views/settings-page.php:41
446
- msgid "Cycle 2 - Swipe. For touch swipe events."
447
- msgstr "Cycle 2. Swipe. Para eventos táctiles."
448
-
449
- # @ cycloneslider
450
- #: ../views/settings-page.php:46
451
- msgid "Cycle 2 - Tile. Used for tile transition effects."
452
- msgstr "Cycle 2. Tile. Usado para los efectos de las transiciones."
453
-
454
- # @ cycloneslider
455
- #: ../views/settings-page.php:51
456
- msgid "Cycle 2 - Video. Used by YouTube template."
457
- msgstr "Cycle 2 - Vídeo. Usado por la plantilla Youtube."
458
-
459
- # @ cycloneslider
460
- #: ../views/settings-page.php:56
461
- msgid "Magnific Popup - Enable lightbox option."
462
- msgstr "Magnific Popup. Activa la opción lightbox."
463
-
464
- # @ cycloneslider
465
- #: ../views/settings-page.php:56 ../views/settings-page.php:61
466
- #: ../views/slider-advanced-settings.php:2
467
- msgid "Available in pro version."
468
- msgstr "Disponible en la versión pro."
469
-
470
- # @ cycloneslider
471
- #: ../views/settings-page.php:61
472
- msgid "Easing - Enable easing options."
473
- msgstr "Easing. Activa las opciones de fundido."
474
-
475
- # @ cycloneslider
476
- #: ../views/settings-page.php:66
477
- msgid "Scripts loading priority:"
478
- msgstr "Prioridad de carga de scripts:"
479
-
480
- # @ cycloneslider
481
- #: ../views/settings-page.php:69
482
- msgid "Make this value bigger to load scripts last."
483
- msgstr "Introduce un valor más grande para cargar los scripts los últimos."
484
-
485
- # @ cycloneslider
486
- #: ../views/settings-page.php:73
487
- msgid "Load these templates:"
488
- msgstr "Usar estas plantillas:"
489
-
490
- # @ cycloneslider
491
- #: ../views/settings-page.php:86
492
- msgid "Save Options"
493
- msgstr "Guardar opciones"
494
-
495
- # @ cycloneslider
496
- #: ../views/settings-page.php:87
497
- msgid "Restore Defaults"
498
- msgstr "Restaurar por defecto"
499
-
500
- # @ cycloneslider
501
- #: ../views/slide-edit.php:16
502
- msgid "Delete"
503
- msgstr "Eliminar"
504
-
505
- # @ cycloneslider
506
- #: ../views/slide-edit.php:25
507
- msgid "Image"
508
- msgstr "Imagen"
509
-
510
- # @ cycloneslider
511
- #: ../views/slide-edit.php:26
512
- msgid "YouTube"
513
- msgstr "YouTube. "
514
-
515
- # @ cycloneslider
516
- #: ../views/slide-edit.php:27
517
- msgid "Vimeo"
518
- msgstr "Vimeo"
519
-
520
- # @ cycloneslider
521
- #: ../views/slide-edit.php:28 ../views/slide-edit.php:168
522
- msgid "Custom HTML"
523
- msgstr "HTML personalizado"
524
-
525
- #: ../views/slide-edit.php:29
526
- msgid "Video (Old Version)"
527
- msgstr "Video (Versión antigua)"
528
-
529
- # @ cycloneslider
530
- #: ../views/slide-edit.php:41
531
- msgid "Get Image"
532
- msgstr "Elegir imagen"
533
-
534
- # @ cycloneslider
535
- #: ../views/slide-edit.php:44
536
- msgid "Slide Properties:"
537
- msgstr "Propiedades de la plantilla"
538
-
539
- # @ cycloneslider
540
- #: ../views/slide-edit.php:46
541
- msgid "Caption"
542
- msgstr "Leyenda"
543
-
544
- # @ cycloneslider
545
- #: ../views/slide-edit.php:53
546
- msgid "Description:"
547
- msgstr "Decripción:"
548
-
549
- # @ cycloneslider
550
- #: ../views/slide-edit.php:59
551
- msgid "Link"
552
- msgstr "Enlace"
553
-
554
- # @ cycloneslider
555
- #: ../views/slide-edit.php:62
556
- msgid "Link URL:"
557
- msgstr "URL del enlace"
558
-
559
- # @ cycloneslider
560
- #: ../views/slide-edit.php:66
561
- msgid "Open Link in:"
562
- msgstr "Abrir enlace en:"
563
-
564
- # @ cycloneslider
565
- #: ../views/slide-edit.php:68
566
- msgid "Same Window"
567
- msgstr "Misma ventana"
568
-
569
- # @ cycloneslider
570
- #: ../views/slide-edit.php:69
571
- msgid "New Tab or Window"
572
- msgstr "Abrir enlace en una nueva ventana/pestaña"
573
-
574
- # @ cycloneslider
575
- #: ../views/slide-edit.php:75
576
- msgid "Image Attributes"
577
- msgstr "Atributos de imagen"
578
-
579
- # @ cycloneslider
580
- #: ../views/slide-edit.php:78
581
- msgid "Alternate Text:"
582
- msgstr "Texto alternativo:"
583
-
584
- # @ cycloneslider
585
- #: ../views/slide-edit.php:82
586
- msgid "Title Text:"
587
- msgstr "Texto del título:"
588
-
589
- # @ cycloneslider
590
- #: ../views/slide-edit.php:88
591
- msgid "Slide Transition Effects"
592
- msgstr "Efectos de transición de diapositivas"
593
-
594
- # @ cycloneslider
595
- #: ../views/slide-edit.php:92
596
- msgid "Disable"
597
- msgstr "Desactivar"
598
-
599
- # @ cycloneslider
600
- #: ../views/slide-edit.php:93
601
- msgid "Enable Slide Effects"
602
- msgstr "Activar efectos de diapositiva"
603
-
604
- # @ cycloneslider
605
- #: ../views/slide-edit.php:99
606
- msgid "Transition Effects:"
607
- msgstr "Efectos de transición:"
608
-
609
- # @ cycloneslider
610
- #: ../views/slide-edit.php:110 ../views/slider-properties.php:32
611
- msgid "Transition Effects Speed:"
612
- msgstr "Velocidad del efecto de transición:"
613
-
614
- # @ cycloneslider
615
- #: ../views/slide-edit.php:112 ../views/slide-edit.php:119
616
- #: ../views/slider-properties.php:34
617
- msgid "Milliseconds"
618
- msgstr "Milisegundos"
619
-
620
- # @ cycloneslider
621
- #: ../views/slide-edit.php:117 ../views/slider-properties.php:26
622
- msgid "Next Slide Delay:"
623
- msgstr "Retraso siguiente diapositiva:"
624
-
625
- # @ cycloneslider
626
- #: ../views/slide-edit.php:127 ../views/slider-properties.php:13
627
- msgid "Tile Count:"
628
- msgstr "Número de diapositivas:"
629
-
630
- # @ cycloneslider
631
- #: ../views/slide-edit.php:129 ../views/slider-properties.php:15
632
- msgid "The number of tiles to use in the transition."
633
- msgstr "Número de diapositivas para usar esta transición."
634
-
635
- # @ cycloneslider
636
- #: ../views/slide-edit.php:133
637
- msgid "Tile Delay:"
638
- msgstr "Retraso:"
639
-
640
- # @ cycloneslider
641
- #: ../views/slide-edit.php:135
642
- msgid "Milliseconds to delay each individual tile transition."
643
- msgstr "Milisegundos para retrasar cada transición individual."
644
-
645
- # @ cycloneslider
646
- #: ../views/slide-edit.php:139 ../views/slider-properties.php:18
647
- msgid "Tile Position:"
648
- msgstr "Posición de la capa:"
649
-
650
- # @ cycloneslider
651
- #: ../views/slide-edit.php:141 ../views/slider-properties.php:20
652
- msgid "Vertical"
653
- msgstr "Vertical"
654
-
655
- # @ cycloneslider
656
- #: ../views/slide-edit.php:142 ../views/slider-properties.php:21
657
- msgid "Horizontal"
658
- msgstr "Horizontal"
659
-
660
- # @ cycloneslider
661
- #: ../views/slide-edit.php:154
662
- msgid "YouTube URL:"
663
- msgstr "URL Youtube:"
664
-
665
- # @ cycloneslider
666
- #: ../views/slide-edit.php:156
667
- msgid "Copy and paste a valid YouTube URL here."
668
- msgstr "Copia y pega un enlace válido de Youtube aquí."
669
-
670
- # @ cycloneslider
671
- #: ../views/slide-edit.php:161
672
- msgid "Vimeo URL:"
673
- msgstr "URL Vimeo:"
674
-
675
- # @ cycloneslider
676
- #: ../views/slide-edit.php:163
677
- msgid "Copy and paste a valid Vimeo URL here."
678
- msgstr "Copia y pega un enlace válido a Vimeo aquí."
679
-
680
- #: ../views/slide-edit.php:175
681
- msgid ""
682
- "This video slide is problematic. Please consider using YouTube, Vimeo or "
683
- "Custom slide type for videos. This slide will be removed in the future and "
684
- "will be replaced with a better one."
685
- msgstr ""
686
- "Estea diapositva de video es problemática. Por favor, considera usar "
687
- "YouTube, Vimeo o una diapositiva personalizada para vídeos. Esta diapositiva "
688
- "será borrada en el futuro y reemplazada por una mejor."
689
-
690
- # @ cycloneslider
691
- #: ../views/slide-edit.php:186
692
- msgid "Video URL:"
693
- msgstr "URL Vídeo"
694
-
695
- # @ cycloneslider
696
- #: ../views/slide-edit.php:188
697
- msgid "Copy and paste a Youtube or Vimeo URL and hit the Get Video button."
698
- msgstr ""
699
- "Copia y pega un enlace válido a Youtube o Vimeo y pulsa el botón Añadir video"
700
-
701
- # @ cycloneslider
702
- #: ../views/slide-edit.php:192
703
- msgid "Get Video"
704
- msgstr "Añadir Vídeo"
705
-
706
- #: ../views/slide-edit.php:197
707
- msgid "Embed Code"
708
- msgstr "Código de incrustación"
709
-
710
- #: ../views/slide-edit.php:199
711
- msgid ""
712
- "You can place your embed code directly here. Or you can use the Get Video "
713
- "button to generate the embed code."
714
- msgstr ""
715
- "Puedes colocar tu código de incrustación directamente aquí. O puedes usar el "
716
- "botón Poner video para generar el código de incrustación."
717
-
718
- #: ../views/slide-edit.php:201
719
- msgid ""
720
- "<strong>Note:</strong> The Slide Properties and Tile effects are not "
721
- "supported for videos."
722
- msgstr ""
723
- "<strong>Nota:</strong> Las propiedades del slide y los efectos de capa no "
724
- "están soportados para vídeos."
725
-
726
- #: ../views/slide-edit.php:203
727
- msgid ""
728
- "<strong>Note:</strong> Append &wmode=transparent to the embed code src "
729
- "attribute to make HTML elements appear on top of Flash."
730
- msgstr ""
731
- "<strong>Nota:</strong>Añade &wmode=transparent al código fuente para hacer "
732
- "los elementos HTML aparecer encima del Flash."
733
-
734
- # @ cycloneslider
735
- #: ../views/slider-advanced-settings.php:4
736
- msgid "Allow Wrap?"
737
- msgstr "Permitir volver al inicio?"
738
-
739
- # @ cycloneslider
740
- #: ../views/slider-advanced-settings.php:6
741
- #: ../views/slider-advanced-settings.php:44 ../views/slider-properties.php:66
742
- #: ../views/slider-properties.php:74 ../views/slider-properties.php:82
743
- #: ../views/slider-properties.php:92 ../views/slider-properties.php:101
744
- msgid "Yes"
745
- msgstr "Si"
746
-
747
- # @ cycloneslider
748
- #: ../views/slider-advanced-settings.php:7
749
- #: ../views/slider-advanced-settings.php:45 ../views/slider-properties.php:67
750
- #: ../views/slider-properties.php:75 ../views/slider-properties.php:83
751
- #: ../views/slider-properties.php:91 ../views/slider-properties.php:100
752
- msgid "No"
753
- msgstr "No"
754
-
755
- # @ cycloneslider
756
- #: ../views/slider-advanced-settings.php:10
757
- msgid ""
758
- "Determines if slider wraps to beginning slide if it reaches the end slide."
759
- msgstr ""
760
- "Determina si el slider vuelve al principio tras mostrar la última "
761
- "diapositiva."
762
-
763
- # @ cycloneslider
764
- #: ../views/slider-advanced-settings.php:15
765
- msgid "Dynamic Height:"
766
- msgstr "Altura dinámica:"
767
-
768
- # @ cycloneslider
769
- #: ../views/slider-advanced-settings.php:17
770
- msgid "Off"
771
- msgstr "Apagado"
772
-
773
- # @ cycloneslider
774
- #: ../views/slider-advanced-settings.php:18
775
- msgid "On"
776
- msgstr "Encendido"
777
-
778
- # @ cycloneslider
779
- #: ../views/slider-advanced-settings.php:21
780
- msgid "Adjust slider height depending on current slide."
781
- msgstr "Ajustar el alto del slider dependiendo de la diapositiva actual."
782
-
783
- # @ cycloneslider
784
- #: ../views/slider-advanced-settings.php:26
785
- msgid "Delay:"
786
- msgstr "Retardo:"
787
-
788
- # @ cycloneslider
789
- #: ../views/slider-advanced-settings.php:28
790
- msgid ""
791
- "Milliseconds to add or substract from the time before the first transition "
792
- "occurs."
793
- msgstr "Milisegundos a añadir o quitar del tiempo de transición general."
794
-
795
- # @ cycloneslider
796
- #: ../views/slider-advanced-settings.php:32
797
- msgid "Easing:"
798
- msgstr "Easing:"
799
-
800
- # @ cycloneslider
801
- #: ../views/slider-advanced-settings.php:38
802
- msgid "Easing for transition animations."
803
- msgstr "Transición Easing (moderada) para las animaciones"
804
-
805
- # @ cycloneslider
806
- #: ../views/slider-advanced-settings.php:42
807
- msgid "Swipe:"
808
- msgstr "Swipe:"
809
-
810
- # @ cycloneslider
811
- #: ../views/slider-advanced-settings.php:48
812
- msgid "Enable swipe gesture support for touch devices."
813
- msgstr "Activar gestos swipe para dispositivos touch."
814
-
815
- # @ cycloneslider
816
- #: ../views/slider-advanced-settings.php:53
817
- msgid "Resize Options:"
818
- msgstr "Opciones de redimensión:"
819
-
820
- # @ cycloneslider
821
- #: ../views/slider-advanced-settings.php:61
822
- msgid "Force Resize"
823
- msgstr "Forzar redimensión"
824
-
825
- # @ cycloneslider
826
- #: ../views/slider-advanced-settings.php:63
827
- msgid "Auto - Cyclone Slider decides the resize option."
828
- msgstr "Auto - Cyclone Slider decide el redimensionado"
829
-
830
- # @ cycloneslider
831
- #: ../views/slider-advanced-settings.php:64
832
- msgid "Crop - Resize and remove excess parts."
833
- msgstr "Recortar. Redimensionar y eliminar los excesos."
834
-
835
- # @ cycloneslider
836
- #: ../views/slider-advanced-settings.php:65
837
- msgid "Exact - Resize to exact dimensions."
838
- msgstr "Exacto. Redimensionar al tamaño exacto."
839
-
840
- # @ cycloneslider
841
- #: ../views/slider-advanced-settings.php:66
842
- msgid "Landscape - Resize to exact width."
843
- msgstr "Panorámico. Redimensionar al ancho exacto."
844
-
845
- # @ cycloneslider
846
- #: ../views/slider-advanced-settings.php:67
847
- msgid "Portrait - Resize to exact height."
848
- msgstr "Retrato. Redimensionar al alto exacto."
849
-
850
- # @ cycloneslider
851
- #: ../views/slider-codes.php:4
852
- msgid "Your Shortcode:"
853
- msgstr "Shortcode:"
854
-
855
- # @ cycloneslider
856
- #: ../views/slider-codes.php:6
857
- msgid ""
858
- "Copy and paste this shortcode into your Post, Page or Custom Post editor."
859
- msgstr ""
860
- "Copia y pega este shortcode en tu Entrada, Página o Editor de Entrada "
861
- "Personalizado."
862
-
863
- # @ cycloneslider
864
- #: ../views/slider-codes.php:10
865
- msgid "Your PHP Code:"
866
- msgstr "Código PHP:"
867
-
868
- # @ Cyclone Slider 2
869
- # @
870
- # @ Traducido al español por Digital03
871
- # @ http://digital03.net
872
- #: ../views/slider-codes.php:12
873
- msgid ""
874
- "Copy and paste this code when you need to display the slider in template "
875
- "files (header.php, front-page.php, etc.)."
876
- msgstr ""
877
- "Copia y pega este shortcode cuando necesites mostrar este slider en un "
878
- "archivo de plantilla (header.php, front-page.php, etc)."
879
-
880
- # @ cycloneslider
881
- #: ../views/slider-id.php:5
882
- msgid "Change the Slideshow ID here."
883
- msgstr "Cambia el ID del Slideshow aquí."
884
-
885
- # @ cycloneslider
886
- #: ../views/slider-preview.php:9
887
- msgid "Your preview will appear here."
888
- msgstr "Tu nombre de usuario aparecerá aquí."
889
-
890
- # @ cycloneslider
891
- #: ../views/slider-properties.php:4
892
- msgid "Transition Effects to Use:"
893
- msgstr "Efecto de transición a usar:"
894
-
895
- # @ cycloneslider
896
- #: ../views/slider-properties.php:28
897
- msgid "Milliseconds. 0 to disable auto advance."
898
- msgstr "Milisegundos. 0 para desactivar el avance automático."
899
-
900
- # @ cycloneslider
901
- #: ../views/slider-properties.php:38
902
- msgid "Width:"
903
- msgstr "Ancho:"
904
-
905
- # @ cycloneslider
906
- #: ../views/slider-properties.php:40 ../views/slider-properties.php:46
907
- msgid "pixels."
908
- msgstr "píxeles."
909
-
910
- # @ cycloneslider
911
- #: ../views/slider-properties.php:44
912
- msgid "Height:"
913
- msgstr "Alto:"
914
-
915
- # @ cycloneslider
916
- #: ../views/slider-properties.php:50
917
- msgid "Width Management:"
918
- msgstr "Gestión del ancho:"
919
-
920
- # @ cycloneslider
921
- #: ../views/slider-properties.php:52
922
- msgid "Responsive"
923
- msgstr "Adaptable"
924
-
925
- # @ cycloneslider
926
- #: ../views/slider-properties.php:53
927
- msgid "Full"
928
- msgstr "Completo"
929
-
930
- # @ cycloneslider
931
- #: ../views/slider-properties.php:54
932
- msgid "Fixed"
933
- msgstr "Fijo"
934
-
935
- # @ cycloneslider
936
- #: ../views/slider-properties.php:57
937
- msgid ""
938
- "Responsive - resizes to smaller size but maximum width will be equal to the "
939
- "provided width."
940
- msgstr ""
941
- "Adaptable. Redimensiona al tamaño más pequeño pero el ancho máximo será "
942
- "igual que el indicado."
943
-
944
- # @ cycloneslider
945
- #: ../views/slider-properties.php:58
946
- msgid ""
947
- "Full - the same as responsive but maximum width will be equal to its "
948
- "container ignoring the provided width."
949
- msgstr ""
950
- "Completo - lo mismo que adaptable, pero la ancura máxima será igual al "
951
- "contenedor ignorando la anchura máxima indicada del slider."
952
-
953
- # @ cycloneslider
954
- #: ../views/slider-properties.php:59
955
- msgid "Fixed - width and height are not resized."
956
- msgstr "Fijo. Ancho y alto no serán modificados."
957
-
958
- # @ cycloneslider
959
- #: ../views/slider-properties.php:64
960
- msgid "Pause on Hover?"
961
- msgstr "Parar con el ratón encima?"
962
-
963
- # @ cycloneslider
964
- #: ../views/slider-properties.php:72
965
- msgid "Show Prev/Next Buttons?"
966
- msgstr "Mostrar botones Anterior/Siguiente?"
967
-
968
- # @ cycloneslider
969
- #: ../views/slider-properties.php:80
970
- msgid "Show Navigation?"
971
- msgstr "Mostrar navegación?"
972
-
973
- # @ cycloneslider
974
- #: ../views/slider-properties.php:85
975
- msgid "The thumbnails or dots depending on template."
976
- msgstr "Miniaturas o puntos dependiendo de la plantilla."
977
-
978
- # @ cycloneslider
979
- #: ../views/slider-properties.php:89
980
- msgid "Resize Images?"
981
- msgstr "Redimensionar imagenes?"
982
-
983
- # @ cycloneslider
984
- #: ../views/slider-properties.php:94
985
- msgid ""
986
- "Yes - resize images to slideshow dimension. <br>No - use the original "
987
- "uploaded image."
988
- msgstr ""
989
- "Si - redimensiona las imagenes al tamaño del slider<br>No - usa el tamaño "
990
- "original de la imagen subida"
991
-
992
- # @ cycloneslider
993
- #: ../views/slider-properties.php:98
994
- msgid "Random Slide Order?"
995
- msgstr "Orden de diapositivas aleatorio?"
996
-
997
- # @ cycloneslider
998
- #: ../views/slider-properties.php:103
999
- msgid "Randomize order of slides on every page visit."
1000
- msgstr "Cambia aleatoriamente el orden de las diapositivas en cada visita"
1001
-
1002
- # @ cycloneslider
1003
- #: ../views/slides.php:8
1004
- msgid "Add Slide"
1005
- msgstr "Añadir diapositiva"
1006
-
1007
- # @ cycloneslider
1008
- #: ../views/template-selection.php:4
1009
- msgid "Name"
1010
- msgstr "Nombre"
1011
-
1012
- # @ cycloneslider
1013
- #: ../views/template-selection.php:5
1014
- msgid "Supported Slides"
1015
- msgstr "Diapositivas soportadas"
1016
-
1017
- # @ cycloneslider
1018
- #: ../views/template-selection.php:6
1019
- msgid "Location"
1020
- msgstr "Localización"
1021
-
1022
- # @ cycloneslider
1023
- #: ../views/template-selection.php:7
1024
- msgid "Selected"
1025
- msgstr "Seleccionado"
1026
-
1027
- # @ cycloneslider
1028
- #~ msgid "Testimonial"
1029
- #~ msgstr "Recomendación"
1030
-
1031
- # @ cycloneslider
1032
- #~ msgid "Do not show suggested videos when the video finishes."
1033
- #~ msgstr ""
1034
- #~ "No sugerir otros videos relacionados cuando el vídeo seleccionado termine."
1035
-
1036
- # @ cycloneslider
1037
- #~ msgid "Quote"
1038
- #~ msgstr "Cita"
1039
-
1040
- # @ cycloneslider
1041
- #~ msgid "Author"
1042
- #~ msgstr "Autor"
1043
-
1044
- # @ cycloneslider
1045
- #, fuzzy
1046
- #~ msgid "Name:"
1047
- #~ msgstr "Nombre:"
1048
-
1049
- # @ default
1050
- #~ msgid "title"
1051
- #~ msgstr "título"
1052
-
1053
- # @ default
1054
- #~ msgid "description"
1055
- #~ msgstr "descripción"
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Cyclone Slider 2 v2.8.3\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-12-29 18:36+0800\n"
6
+ "PO-Revision-Date: 2014-08-29 17:45+0100\n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: Digital03 <info@digital03.net>\n"
9
+ "Language: es_ES\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
+ "X-Generator: Poedit 1.6.8\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
18
+ "X-Poedit-Basepath: .\n"
19
+ "X-Textdomain-Support: yes\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+
22
+ # @ cycloneslider
23
+ #: ../cyclone-slider.php:135
24
+ msgid "Cyclone Slider Settings"
25
+ msgstr "Ajustes de Cyclone Slider"
26
+
27
+ # @ cycloneslider
28
+ #: ../cyclone-slider.php:136
29
+ msgid "Settings"
30
+ msgstr "Ajustes"
31
+
32
+ # @ cycloneslider
33
+ #: ../classes/class-cyclone-slider-admin.php:96
34
+ msgid "Cyclone Slider"
35
+ msgstr "Cyclone Slider"
36
+
37
+ # @ cycloneslider
38
+ #: ../classes/class-cyclone-slider-admin.php:97
39
+ msgid "Slideshow"
40
+ msgstr "Slideshow"
41
+
42
+ # @ cycloneslider
43
+ #: ../classes/class-cyclone-slider-admin.php:98
44
+ msgid "Add Slideshow"
45
+ msgstr "Añadir slideshow"
46
+
47
+ # @ cycloneslider
48
+ #: ../classes/class-cyclone-slider-admin.php:99
49
+ msgid "Add New Slideshow"
50
+ msgstr "Añadir nuevo slideshow"
51
+
52
+ # @ cycloneslider
53
+ #: ../classes/class-cyclone-slider-admin.php:100
54
+ msgid "Edit Slideshow"
55
+ msgstr "Editar slideshow"
56
+
57
+ # @ cycloneslider
58
+ #: ../classes/class-cyclone-slider-admin.php:101
59
+ msgid "New Slideshow"
60
+ msgstr "Nuevo slideshow"
61
+
62
+ # @ cycloneslider
63
+ #: ../classes/class-cyclone-slider-admin.php:102
64
+ msgid "View Slideshow"
65
+ msgstr "Ver slideshow"
66
+
67
+ # @ cycloneslider
68
+ #: ../classes/class-cyclone-slider-admin.php:103
69
+ msgid "Search Slideshows"
70
+ msgstr "Buscar slideshows"
71
+
72
+ # @ cycloneslider
73
+ #: ../classes/class-cyclone-slider-admin.php:104
74
+ msgid "No slideshows found"
75
+ msgstr "No se han encontrado slideshows"
76
+
77
+ # @ cycloneslider
78
+ #: ../classes/class-cyclone-slider-admin.php:105
79
+ msgid "No slideshows found in Trash"
80
+ msgstr "No hay slideshows en la papelera"
81
+
82
+ # @ cycloneslider
83
+ #: ../classes/class-cyclone-slider-admin.php:141
84
+ #: ../classes/class-cyclone-slider-admin.php:144
85
+ #: ../classes/class-cyclone-slider-admin.php:145
86
+ #: ../classes/class-cyclone-slider-admin.php:148
87
+ #: ../classes/class-cyclone-slider-admin.php:149
88
+ #: ../classes/class-cyclone-slider-admin.php:150
89
+ msgid "Slideshow updated."
90
+ msgstr "Slideshow actualizado."
91
+
92
+ # @ cycloneslider
93
+ #: ../classes/class-cyclone-slider-admin.php:142
94
+ msgid "Custom field updated."
95
+ msgstr "Campos personalizados actualizados"
96
+
97
+ # @ cycloneslider
98
+ #: ../classes/class-cyclone-slider-admin.php:143
99
+ msgid "Custom field deleted."
100
+ msgstr "Campo personalizado eliminado."
101
+
102
+ # @ cycloneslider
103
+ #: ../classes/class-cyclone-slider-admin.php:146
104
+ msgid "Slideshow published."
105
+ msgstr "Slideshow publicado."
106
+
107
+ # @ cycloneslider
108
+ #: ../classes/class-cyclone-slider-admin.php:147
109
+ msgid "Slideshow saved."
110
+ msgstr "Slideshow guardado."
111
+
112
+ # @ cycloneslider
113
+ #: ../classes/class-cyclone-slider-admin.php:151
114
+ #, php-format
115
+ msgid ""
116
+ "Templates CSS could not be saved. Make sure %stemplates.css is writable."
117
+ msgstr ""
118
+ "La plantilla CSS no ha podido ser guardada. Asegurate que %stemplates.css "
119
+ "tiene permiso de escritura."
120
+
121
+ # @ cycloneslider
122
+ #: ../classes/class-cyclone-slider-admin.php:152
123
+ #, php-format
124
+ msgid "Templates JS could not be saved. Make sure %stemplates.js is writable."
125
+ msgstr ""
126
+ "La plantilla JS no ha podido ser guardada. Asegurate que %stemplates.js "
127
+ "tiene permisos de escritura."
128
+
129
+ # @ cycloneslider
130
+ #: ../classes/class-cyclone-slider-admin.php:186
131
+ msgid "Slides"
132
+ msgstr "Diapositivas"
133
+
134
+ # @ cycloneslider
135
+ #: ../classes/class-cyclone-slider-admin.php:195
136
+ msgid "Slider Preview"
137
+ msgstr "Vista previa"
138
+
139
+ # @ cycloneslider
140
+ #: ../classes/class-cyclone-slider-admin.php:204
141
+ msgid "Get Slider Codes"
142
+ msgstr "Ver el código del slider"
143
+
144
+ # @ cycloneslider
145
+ #: ../classes/class-cyclone-slider-admin.php:213
146
+ msgid "Basic Settings"
147
+ msgstr "Ajustes básicos"
148
+
149
+ # @ cycloneslider
150
+ #: ../classes/class-cyclone-slider-admin.php:222
151
+ msgid "Advanced Settings"
152
+ msgstr "Ajustes avanzados"
153
+
154
+ # @ cycloneslider
155
+ #: ../classes/class-cyclone-slider-admin.php:231
156
+ msgid "Templates"
157
+ msgstr "Plantillas"
158
+
159
+ # @ cycloneslider
160
+ #: ../classes/class-cyclone-slider-admin.php:240
161
+ #: ../classes/class-cyclone-slider-admin.php:524
162
+ msgid "Slideshow ID"
163
+ msgstr "ID del slideshow"
164
+
165
+ # @ cycloneslider
166
+ #: ../classes/class-cyclone-slider-admin.php:268
167
+ msgid "Slide"
168
+ msgstr "Diapositiva"
169
+
170
+ # @ cycloneslider
171
+ #: ../classes/class-cyclone-slider-admin.php:406
172
+ msgid "Core"
173
+ msgstr "Núcleo"
174
+
175
+ # @ cycloneslider
176
+ #: ../classes/class-cyclone-slider-admin.php:407
177
+ #, php-format
178
+ msgid ""
179
+ "Located inside the Cyclone Slider's templates directory:<br> <strong>%s</"
180
+ "strong>"
181
+ msgstr ""
182
+ "Localizado dentro del directorio de plantillas de Cyclone Slider:<br> "
183
+ "<strong>%s</strong>"
184
+
185
+ # @ cycloneslider
186
+ #: ../classes/class-cyclone-slider-admin.php:411
187
+ #, php-format
188
+ msgid "Located inside your currently active theme:<br> <strong>%s</strong>"
189
+ msgstr "Localizado dentro de tu tema actual:<br> <strong>%s</strong>"
190
+
191
+ # @ cycloneslider
192
+ #: ../classes/class-cyclone-slider-admin.php:412
193
+ #, php-format
194
+ msgid ""
195
+ "Your template is in danger of being overwritten when you upgrade your theme. "
196
+ "Please move it inside %s."
197
+ msgstr ""
198
+ "Tu plantilla está en peligro de ser sobre-escrita cuando actualices tu tema. "
199
+ "Por favor, muevela dentro de %s."
200
+
201
+ # @ cycloneslider
202
+ #: ../classes/class-cyclone-slider-admin.php:416
203
+ #, php-format
204
+ msgid "Located inside wp-content directory:<br> <strong>%s</strong>"
205
+ msgstr "Localizado dentro de la carpeta wp-content:<br> <strong>%s</strong>"
206
+
207
+ # @ cycloneslider
208
+ #: ../classes/class-cyclone-slider-admin.php:457
209
+ msgid "Slide *"
210
+ msgstr "Diapositiva *"
211
+
212
+ # @ cycloneslider
213
+ #: ../classes/class-cyclone-slider-admin.php:521
214
+ msgid "Slideshow Name"
215
+ msgstr "Nombre del slideshow"
216
+
217
+ # @ cycloneslider
218
+ #: ../classes/class-cyclone-slider-admin.php:522
219
+ msgid "Template"
220
+ msgstr "Plantilla"
221
+
222
+ # @ cycloneslider
223
+ #: ../classes/class-cyclone-slider-admin.php:523
224
+ msgid "No. of Slides"
225
+ msgstr "No. de diapositivas"
226
+
227
+ # @ cycloneslider
228
+ #: ../classes/class-cyclone-slider-admin.php:525
229
+ msgid "Shortcode"
230
+ msgstr "Shortcode"
231
+
232
+ # @ cycloneslider
233
+ #: ../classes/class-cyclone-slider-scripts.php:52
234
+ msgid "Select an image"
235
+ msgstr "Seleciona una imagen"
236
+
237
+ # @ cycloneslider
238
+ #: ../classes/class-cyclone-slider-scripts.php:53
239
+ msgid "Select Images - Use Ctrl + Click or Shift + Click"
240
+ msgstr "Selecionar varias imágenes - Usar Ctrl + Click o Shift + Click"
241
+
242
+ # @ cycloneslider
243
+ #: ../classes/class-cyclone-slider-scripts.php:54
244
+ msgid "Add to Slide"
245
+ msgstr "Añadir a la diapositiva"
246
+
247
+ # @ cycloneslider
248
+ #: ../classes/class-cyclone-slider-scripts.php:55 ../views/slides.php:9
249
+ msgid "Add Images as Slides"
250
+ msgstr "Añadir imágenes como diapositivas"
251
+
252
+ # @ cycloneslider
253
+ #: ../classes/class-cyclone-slider-scripts.php:56
254
+ msgid "Error. Make sure its a valid YouTube URL."
255
+ msgstr "Error. Asegúrate de que es una dirección de YouTube válida."
256
+
257
+ # @ cycloneslider
258
+ # @ default
259
+ #: ../classes/class-cyclone-slider-settings-page.php:62
260
+ #: ../classes/codefleet/class-codefleet-settings-page.php:114
261
+ msgid "Default options restored."
262
+ msgstr "Ajustes por defecto restaurados."
263
+
264
+ # @ cycloneslider
265
+ #: ../classes/class-cyclone-slider-widget.php:15
266
+ msgid "Cyclone Slider Widget"
267
+ msgstr "Cyclone Slider Widget"
268
+
269
+ # @ cycloneslider
270
+ #: ../classes/class-cyclone-slider-widget.php:16
271
+ msgid "Widget for displaying sliders."
272
+ msgstr "Widget para mostrar diapositivas."
273
+
274
+ # @ cycloneslider
275
+ #: ../classes/class-cyclone-slider-widget.php:67 ../views/slide-edit.php:49
276
+ msgid "Title:"
277
+ msgstr "Título:"
278
+
279
+ # @ cycloneslider
280
+ #: ../classes/class-cyclone-slider-widget.php:81
281
+ msgid "Select a Slider:"
282
+ msgstr "Selectionar un Slider"
283
+
284
+ # @ cycloneslider
285
+ #: ../classes/class-cyclone-slider-widget.php:96
286
+ msgid "No sliders found."
287
+ msgstr "No se han encontrado Sliders."
288
+
289
+ # @ cycloneslider
290
+ #: ../classes/class-cyclone-slider.php:80
291
+ #, php-format
292
+ msgid "[Slideshow \"%s\" not found]"
293
+ msgstr "[Slideshow \"%s\" no encontrado]"
294
+
295
+ # @ cycloneslider
296
+ #: ../classes/class-cyclone-slider.php:92
297
+ #, php-format
298
+ msgid "[Template \"%s\" not found]"
299
+ msgstr "[Plantilla \"%s\" no encontrada]"
300
+
301
+ # @ cycloneslider
302
+ #: ../classes/class-nextgen-integration.php:37
303
+ msgid "NextGEN Integration"
304
+ msgstr "Integración con NextGEN"
305
+
306
+ # @ cycloneslider
307
+ #: ../classes/class-nextgen-integration.php:53
308
+ msgid "Choose a NextGEN Gallery"
309
+ msgstr "Escoge una galería NextGEN"
310
+
311
+ # @ cycloneslider
312
+ #: ../classes/class-nextgen-integration.php:63 ../views/export-step-1.php:7
313
+ #: ../views/export-step-2.php:7 ../views/import-step-1.php:7
314
+ #: ../views/import-step-2.php:7
315
+ msgid "Import"
316
+ msgstr "Importar"
317
+
318
+ # @ cycloneslider
319
+ #: ../classes/class-nextgen-integration.php:65
320
+ msgid ""
321
+ "Select a gallery to import images from. Images will be added as new slides."
322
+ msgstr ""
323
+ "Selecciona una galería para importar las imágenes. Las imagenes serán "
324
+ "añadidas como nuevas diapositivas."
325
+
326
+ # @ cycloneslider
327
+ #: ../templates/dark/slider.php:43
328
+ msgid "View Larger Image"
329
+ msgstr "Ver imagen grande"
330
+
331
+ # @ cycloneslider
332
+ #: ../templates/dark/slider.php:46 ../templates/dark/slider.php:48
333
+ msgid "Learn More"
334
+ msgstr "Saber más"
335
+
336
+ # @ cycloneslider
337
+ #: ../templates/dark/slider.php:64 ../templates/default/slider.php:62
338
+ #: ../templates/default/slider.php:66 ../templates/default/slider.php:70
339
+ #: ../templates/standard/slider.php:70 ../templates/thumbnails/slider.php:70
340
+ msgid "Slide type not supported."
341
+ msgstr "Tipo de diapositiva no soportado."
342
+
343
+ # @ cycloneslider
344
+ #: ../views/export-step-1.php:6 ../views/export-step-2.php:6
345
+ #: ../views/import-step-1.php:6 ../views/import-step-2.php:6
346
+ msgid "Export"
347
+ msgstr "Exportar"
348
+
349
+ # @ cycloneslider
350
+ #: ../views/export-step-1.php:9 ../views/export-step-2.php:9
351
+ msgid "Cyclone Slider Export"
352
+ msgstr "Exportar Cyclone Slider"
353
+
354
+ # @ cycloneslider
355
+ #: ../views/export-step-1.php:18
356
+ msgid "Select sliders:"
357
+ msgstr "Seleccionar sliders:"
358
+
359
+ # @ cycloneslider
360
+ #: ../views/export-step-1.php:24
361
+ msgid "Select All"
362
+ msgstr "Seleccionar todo"
363
+
364
+ # @ cycloneslider
365
+ #: ../views/export-step-1.php:37
366
+ msgid "No slider to export."
367
+ msgstr "No hay sliders para exportar."
368
+
369
+ # @ cycloneslider
370
+ #: ../views/export-step-1.php:40 ../views/import-step-1.php:25
371
+ msgid "Next"
372
+ msgstr "Siguiente"
373
+
374
+ # @ cycloneslider
375
+ #: ../views/export-step-2.php:16
376
+ msgid "Your export file is ready. Click Download."
377
+ msgstr "El archivo de exportación ha sido realizado. Pulsa para descargar."
378
+
379
+ # @ cycloneslider
380
+ #: ../views/export-step-2.php:18 ../views/export-step-2.php:27
381
+ #: ../views/import-step-2.php:18 ../views/import-step-2.php:26
382
+ msgid "Back"
383
+ msgstr "Volver"
384
+
385
+ # @ cycloneslider
386
+ #: ../views/export-step-2.php:19
387
+ msgid "Download"
388
+ msgstr "Descargar"
389
+
390
+ # @ cycloneslider
391
+ #: ../views/import-step-1.php:9 ../views/import-step-2.php:9
392
+ msgid "Cyclone Slider Import"
393
+ msgstr "Importar Cyclone Slider"
394
+
395
+ # @ cycloneslider
396
+ #: ../views/import-step-1.php:18
397
+ msgid "Import Zip File:"
398
+ msgstr "Importar archivo Zip:"
399
+
400
+ # @ cycloneslider
401
+ #: ../views/import-step-2.php:16
402
+ msgid "Import operation success!"
403
+ msgstr "La importación se ha realizado correctamente!"
404
+
405
+ # @ cycloneslider
406
+ #: ../views/settings-page.php:7
407
+ msgid ""
408
+ "Play with these settings if Cyclone Slider 2 is not working or if you want "
409
+ "to optimize it."
410
+ msgstr ""
411
+ "Cambia estas opciones si Cyclone Slider 2 no funciona bien o si quieres "
412
+ "optimizarlo."
413
+
414
+ # @ cycloneslider
415
+ #: ../views/settings-page.php:17
416
+ msgid "Load scripts in:"
417
+ msgstr "Cargar scripts en:"
418
+
419
+ # @ cycloneslider
420
+ #: ../views/settings-page.php:20
421
+ msgid "Header"
422
+ msgstr "Cabecera"
423
+
424
+ # @ cycloneslider
425
+ #: ../views/settings-page.php:21
426
+ msgid "Footer"
427
+ msgstr "Pie de página"
428
+
429
+ # @ cycloneslider
430
+ #: ../views/settings-page.php:26
431
+ msgid "Load these scripts:"
432
+ msgstr "Cargar estos scripts"
433
+
434
+ # @ cycloneslider
435
+ #: ../views/settings-page.php:31
436
+ msgid "Cycle 2. This is the core script needed by the plugin."
437
+ msgstr "Cycle 2. Este es el script necesario para que el plugin funcione."
438
+
439
+ # @ cycloneslider
440
+ #: ../views/settings-page.php:36
441
+ msgid "Cycle 2 - Carousel. Used by these templates: Galleria, Lea, Dos."
442
+ msgstr "Cycle 2 - Carousel. Usado por estas plantillas: Galería, Lea, Dos."
443
+
444
+ # @ cycloneslider
445
+ #: ../views/settings-page.php:41
446
+ msgid "Cycle 2 - Swipe. For touch swipe events."
447
+ msgstr "Cycle 2. Swipe. Para eventos táctiles."
448
+
449
+ # @ cycloneslider
450
+ #: ../views/settings-page.php:46
451
+ msgid "Cycle 2 - Tile. Used for tile transition effects."
452
+ msgstr "Cycle 2. Tile. Usado para los efectos de las transiciones."
453
+
454
+ # @ cycloneslider
455
+ #: ../views/settings-page.php:51
456
+ msgid "Cycle 2 - Video. Used by YouTube template."
457
+ msgstr "Cycle 2 - Vídeo. Usado por la plantilla Youtube."
458
+
459
+ # @ cycloneslider
460
+ #: ../views/settings-page.php:56
461
+ msgid "Magnific Popup - Enable lightbox option."
462
+ msgstr "Magnific Popup. Activa la opción lightbox."
463
+
464
+ # @ cycloneslider
465
+ #: ../views/settings-page.php:56 ../views/settings-page.php:61
466
+ #: ../views/slider-advanced-settings.php:2
467
+ msgid "Available in pro version."
468
+ msgstr "Disponible en la versión pro."
469
+
470
+ # @ cycloneslider
471
+ #: ../views/settings-page.php:61
472
+ msgid "Easing - Enable easing options."
473
+ msgstr "Easing. Activa las opciones de fundido."
474
+
475
+ # @ cycloneslider
476
+ #: ../views/settings-page.php:66
477
+ msgid "Scripts loading priority:"
478
+ msgstr "Prioridad de carga de scripts:"
479
+
480
+ # @ cycloneslider
481
+ #: ../views/settings-page.php:69
482
+ msgid "Make this value bigger to load scripts last."
483
+ msgstr "Introduce un valor más grande para cargar los scripts los últimos."
484
+
485
+ # @ cycloneslider
486
+ #: ../views/settings-page.php:73
487
+ msgid "Load these templates:"
488
+ msgstr "Usar estas plantillas:"
489
+
490
+ # @ cycloneslider
491
+ #: ../views/settings-page.php:86
492
+ msgid "Save Options"
493
+ msgstr "Guardar opciones"
494
+
495
+ # @ cycloneslider
496
+ #: ../views/settings-page.php:87
497
+ msgid "Restore Defaults"
498
+ msgstr "Restaurar por defecto"
499
+
500
+ # @ cycloneslider
501
+ #: ../views/slide-edit.php:16
502
+ msgid "Delete"
503
+ msgstr "Eliminar"
504
+
505
+ # @ cycloneslider
506
+ #: ../views/slide-edit.php:25
507
+ msgid "Image"
508
+ msgstr "Imagen"
509
+
510
+ # @ cycloneslider
511
+ #: ../views/slide-edit.php:26
512
+ msgid "YouTube"
513
+ msgstr "YouTube. "
514
+
515
+ # @ cycloneslider
516
+ #: ../views/slide-edit.php:27
517
+ msgid "Vimeo"
518
+ msgstr "Vimeo"
519
+
520
+ # @ cycloneslider
521
+ #: ../views/slide-edit.php:28 ../views/slide-edit.php:168
522
+ msgid "Custom HTML"
523
+ msgstr "HTML personalizado"
524
+
525
+ #: ../views/slide-edit.php:29
526
+ msgid "Video (Old Version)"
527
+ msgstr "Video (Versión antigua)"
528
+
529
+ # @ cycloneslider
530
+ #: ../views/slide-edit.php:41
531
+ msgid "Get Image"
532
+ msgstr "Elegir imagen"
533
+
534
+ # @ cycloneslider
535
+ #: ../views/slide-edit.php:44
536
+ msgid "Slide Properties:"
537
+ msgstr "Propiedades de la plantilla"
538
+
539
+ # @ cycloneslider
540
+ #: ../views/slide-edit.php:46
541
+ msgid "Caption"
542
+ msgstr "Leyenda"
543
+
544
+ # @ cycloneslider
545
+ #: ../views/slide-edit.php:53
546
+ msgid "Description:"
547
+ msgstr "Decripción:"
548
+
549
+ # @ cycloneslider
550
+ #: ../views/slide-edit.php:59
551
+ msgid "Link"
552
+ msgstr "Enlace"
553
+
554
+ # @ cycloneslider
555
+ #: ../views/slide-edit.php:62
556
+ msgid "Link URL:"
557
+ msgstr "URL del enlace"
558
+
559
+ # @ cycloneslider
560
+ #: ../views/slide-edit.php:66
561
+ msgid "Open Link in:"
562
+ msgstr "Abrir enlace en:"
563
+
564
+ # @ cycloneslider
565
+ #: ../views/slide-edit.php:68
566
+ msgid "Same Window"
567
+ msgstr "Misma ventana"
568
+
569
+ # @ cycloneslider
570
+ #: ../views/slide-edit.php:69
571
+ msgid "New Tab or Window"
572
+ msgstr "Abrir enlace en una nueva ventana/pestaña"
573
+
574
+ # @ cycloneslider
575
+ #: ../views/slide-edit.php:75
576
+ msgid "Image Attributes"
577
+ msgstr "Atributos de imagen"
578
+
579
+ # @ cycloneslider
580
+ #: ../views/slide-edit.php:78
581
+ msgid "Alternate Text:"
582
+ msgstr "Texto alternativo:"
583
+
584
+ # @ cycloneslider
585
+ #: ../views/slide-edit.php:82
586
+ msgid "Title Text:"
587
+ msgstr "Texto del título:"
588
+
589
+ # @ cycloneslider
590
+ #: ../views/slide-edit.php:88
591
+ msgid "Slide Transition Effects"
592
+ msgstr "Efectos de transición de diapositivas"
593
+
594
+ # @ cycloneslider
595
+ #: ../views/slide-edit.php:92
596
+ msgid "Disable"
597
+ msgstr "Desactivar"
598
+
599
+ # @ cycloneslider
600
+ #: ../views/slide-edit.php:93
601
+ msgid "Enable Slide Effects"
602
+ msgstr "Activar efectos de diapositiva"
603
+
604
+ # @ cycloneslider
605
+ #: ../views/slide-edit.php:99
606
+ msgid "Transition Effects:"
607
+ msgstr "Efectos de transición:"
608
+
609
+ # @ cycloneslider
610
+ #: ../views/slide-edit.php:110 ../views/slider-properties.php:32
611
+ msgid "Transition Effects Speed:"
612
+ msgstr "Velocidad del efecto de transición:"
613
+
614
+ # @ cycloneslider
615
+ #: ../views/slide-edit.php:112 ../views/slide-edit.php:119
616
+ #: ../views/slider-properties.php:34
617
+ msgid "Milliseconds"
618
+ msgstr "Milisegundos"
619
+
620
+ # @ cycloneslider
621
+ #: ../views/slide-edit.php:117 ../views/slider-properties.php:26
622
+ msgid "Next Slide Delay:"
623
+ msgstr "Retraso siguiente diapositiva:"
624
+
625
+ # @ cycloneslider
626
+ #: ../views/slide-edit.php:127 ../views/slider-properties.php:13
627
+ msgid "Tile Count:"
628
+ msgstr "Número de diapositivas:"
629
+
630
+ # @ cycloneslider
631
+ #: ../views/slide-edit.php:129 ../views/slider-properties.php:15
632
+ msgid "The number of tiles to use in the transition."
633
+ msgstr "Número de diapositivas para usar esta transición."
634
+
635
+ # @ cycloneslider
636
+ #: ../views/slide-edit.php:133
637
+ msgid "Tile Delay:"
638
+ msgstr "Retraso:"
639
+
640
+ # @ cycloneslider
641
+ #: ../views/slide-edit.php:135
642
+ msgid "Milliseconds to delay each individual tile transition."
643
+ msgstr "Milisegundos para retrasar cada transición individual."
644
+
645
+ # @ cycloneslider
646
+ #: ../views/slide-edit.php:139 ../views/slider-properties.php:18
647
+ msgid "Tile Position:"
648
+ msgstr "Posición de la capa:"
649
+
650
+ # @ cycloneslider
651
+ #: ../views/slide-edit.php:141 ../views/slider-properties.php:20
652
+ msgid "Vertical"
653
+ msgstr "Vertical"
654
+
655
+ # @ cycloneslider
656
+ #: ../views/slide-edit.php:142 ../views/slider-properties.php:21
657
+ msgid "Horizontal"
658
+ msgstr "Horizontal"
659
+
660
+ # @ cycloneslider
661
+ #: ../views/slide-edit.php:154
662
+ msgid "YouTube URL:"
663
+ msgstr "URL Youtube:"
664
+
665
+ # @ cycloneslider
666
+ #: ../views/slide-edit.php:156
667
+ msgid "Copy and paste a valid YouTube URL here."
668
+ msgstr "Copia y pega un enlace válido de Youtube aquí."
669
+
670
+ # @ cycloneslider
671
+ #: ../views/slide-edit.php:161
672
+ msgid "Vimeo URL:"
673
+ msgstr "URL Vimeo:"
674
+
675
+ # @ cycloneslider
676
+ #: ../views/slide-edit.php:163
677
+ msgid "Copy and paste a valid Vimeo URL here."
678
+ msgstr "Copia y pega un enlace válido a Vimeo aquí."
679
+
680
+ #: ../views/slide-edit.php:175
681
+ msgid ""
682
+ "This video slide is problematic. Please consider using YouTube, Vimeo or "
683
+ "Custom slide type for videos. This slide will be removed in the future and "
684
+ "will be replaced with a better one."
685
+ msgstr ""
686
+ "Estea diapositva de video es problemática. Por favor, considera usar "
687
+ "YouTube, Vimeo o una diapositiva personalizada para vídeos. Esta diapositiva "
688
+ "será borrada en el futuro y reemplazada por una mejor."
689
+
690
+ # @ cycloneslider
691
+ #: ../views/slide-edit.php:186
692
+ msgid "Video URL:"
693
+ msgstr "URL Vídeo"
694
+
695
+ # @ cycloneslider
696
+ #: ../views/slide-edit.php:188
697
+ msgid "Copy and paste a Youtube or Vimeo URL and hit the Get Video button."
698
+ msgstr ""
699
+ "Copia y pega un enlace válido a Youtube o Vimeo y pulsa el botón Añadir video"
700
+
701
+ # @ cycloneslider
702
+ #: ../views/slide-edit.php:192
703
+ msgid "Get Video"
704
+ msgstr "Añadir Vídeo"
705
+
706
+ #: ../views/slide-edit.php:197
707
+ msgid "Embed Code"
708
+ msgstr "Código de incrustación"
709
+
710
+ #: ../views/slide-edit.php:199
711
+ msgid ""
712
+ "You can place your embed code directly here. Or you can use the Get Video "
713
+ "button to generate the embed code."
714
+ msgstr ""
715
+ "Puedes colocar tu código de incrustación directamente aquí. O puedes usar el "
716
+ "botón Poner video para generar el código de incrustación."
717
+
718
+ #: ../views/slide-edit.php:201
719
+ msgid ""
720
+ "<strong>Note:</strong> The Slide Properties and Tile effects are not "
721
+ "supported for videos."
722
+ msgstr ""
723
+ "<strong>Nota:</strong> Las propiedades del slide y los efectos de capa no "
724
+ "están soportados para vídeos."
725
+
726
+ #: ../views/slide-edit.php:203
727
+ msgid ""
728
+ "<strong>Note:</strong> Append &wmode=transparent to the embed code src "
729
+ "attribute to make HTML elements appear on top of Flash."
730
+ msgstr ""
731
+ "<strong>Nota:</strong>Añade &wmode=transparent al código fuente para hacer "
732
+ "los elementos HTML aparecer encima del Flash."
733
+
734
+ # @ cycloneslider
735
+ #: ../views/slider-advanced-settings.php:4
736
+ msgid "Allow Wrap?"
737
+ msgstr "Permitir volver al inicio?"
738
+
739
+ # @ cycloneslider
740
+ #: ../views/slider-advanced-settings.php:6
741
+ #: ../views/slider-advanced-settings.php:44 ../views/slider-properties.php:66
742
+ #: ../views/slider-properties.php:74 ../views/slider-properties.php:82
743
+ #: ../views/slider-properties.php:92 ../views/slider-properties.php:101
744
+ msgid "Yes"
745
+ msgstr "Si"
746
+
747
+ # @ cycloneslider
748
+ #: ../views/slider-advanced-settings.php:7
749
+ #: ../views/slider-advanced-settings.php:45 ../views/slider-properties.php:67
750
+ #: ../views/slider-properties.php:75 ../views/slider-properties.php:83
751
+ #: ../views/slider-properties.php:91 ../views/slider-properties.php:100
752
+ msgid "No"
753
+ msgstr "No"
754
+
755
+ # @ cycloneslider
756
+ #: ../views/slider-advanced-settings.php:10
757
+ msgid ""
758
+ "Determines if slider wraps to beginning slide if it reaches the end slide."
759
+ msgstr ""
760
+ "Determina si el slider vuelve al principio tras mostrar la última "
761
+ "diapositiva."
762
+
763
+ # @ cycloneslider
764
+ #: ../views/slider-advanced-settings.php:15
765
+ msgid "Dynamic Height:"
766
+ msgstr "Altura dinámica:"
767
+
768
+ # @ cycloneslider
769
+ #: ../views/slider-advanced-settings.php:17
770
+ msgid "Off"
771
+ msgstr "Apagado"
772
+
773
+ # @ cycloneslider
774
+ #: ../views/slider-advanced-settings.php:18
775
+ msgid "On"
776
+ msgstr "Encendido"
777
+
778
+ # @ cycloneslider
779
+ #: ../views/slider-advanced-settings.php:21
780
+ msgid "Adjust slider height depending on current slide."
781
+ msgstr "Ajustar el alto del slider dependiendo de la diapositiva actual."
782
+
783
+ # @ cycloneslider
784
+ #: ../views/slider-advanced-settings.php:26
785
+ msgid "Delay:"
786
+ msgstr "Retardo:"
787
+
788
+ # @ cycloneslider
789
+ #: ../views/slider-advanced-settings.php:28
790
+ msgid ""
791
+ "Milliseconds to add or substract from the time before the first transition "
792
+ "occurs."
793
+ msgstr "Milisegundos a añadir o quitar del tiempo de transición general."
794
+
795
+ # @ cycloneslider
796
+ #: ../views/slider-advanced-settings.php:32
797
+ msgid "Easing:"
798
+ msgstr "Easing:"
799
+
800
+ # @ cycloneslider
801
+ #: ../views/slider-advanced-settings.php:38
802
+ msgid "Easing for transition animations."
803
+ msgstr "Transición Easing (moderada) para las animaciones"
804
+
805
+ # @ cycloneslider
806
+ #: ../views/slider-advanced-settings.php:42
807
+ msgid "Swipe:"
808
+ msgstr "Swipe:"
809
+
810
+ # @ cycloneslider
811
+ #: ../views/slider-advanced-settings.php:48
812
+ msgid "Enable swipe gesture support for touch devices."
813
+ msgstr "Activar gestos swipe para dispositivos touch."
814
+
815
+ # @ cycloneslider
816
+ #: ../views/slider-advanced-settings.php:53
817
+ msgid "Resize Options:"
818
+ msgstr "Opciones de redimensión:"
819
+
820
+ # @ cycloneslider
821
+ #: ../views/slider-advanced-settings.php:61
822
+ msgid "Force Resize"
823
+ msgstr "Forzar redimensión"
824
+
825
+ # @ cycloneslider
826
+ #: ../views/slider-advanced-settings.php:63
827
+ msgid "Auto - Cyclone Slider decides the resize option."
828
+ msgstr "Auto - Cyclone Slider decide el redimensionado"
829
+
830
+ # @ cycloneslider
831
+ #: ../views/slider-advanced-settings.php:64
832
+ msgid "Crop - Resize and remove excess parts."
833
+ msgstr "Recortar. Redimensionar y eliminar los excesos."
834
+
835
+ # @ cycloneslider
836
+ #: ../views/slider-advanced-settings.php:65
837
+ msgid "Exact - Resize to exact dimensions."
838
+ msgstr "Exacto. Redimensionar al tamaño exacto."
839
+
840
+ # @ cycloneslider
841
+ #: ../views/slider-advanced-settings.php:66
842
+ msgid "Landscape - Resize to exact width."
843
+ msgstr "Panorámico. Redimensionar al ancho exacto."
844
+
845
+ # @ cycloneslider
846
+ #: ../views/slider-advanced-settings.php:67
847
+ msgid "Portrait - Resize to exact height."
848
+ msgstr "Retrato. Redimensionar al alto exacto."
849
+
850
+ # @ cycloneslider
851
+ #: ../views/slider-codes.php:4
852
+ msgid "Your Shortcode:"
853
+ msgstr "Shortcode:"
854
+
855
+ # @ cycloneslider
856
+ #: ../views/slider-codes.php:6
857
+ msgid ""
858
+ "Copy and paste this shortcode into your Post, Page or Custom Post editor."
859
+ msgstr ""
860
+ "Copia y pega este shortcode en tu Entrada, Página o Editor de Entrada "
861
+ "Personalizado."
862
+
863
+ # @ cycloneslider
864
+ #: ../views/slider-codes.php:10
865
+ msgid "Your PHP Code:"
866
+ msgstr "Código PHP:"
867
+
868
+ # @ Cyclone Slider 2
869
+ # @
870
+ # @ Traducido al español por Digital03
871
+ # @ http://digital03.net
872
+ #: ../views/slider-codes.php:12
873
+ msgid ""
874
+ "Copy and paste this code when you need to display the slider in template "
875
+ "files (header.php, front-page.php, etc.)."
876
+ msgstr ""
877
+ "Copia y pega este shortcode cuando necesites mostrar este slider en un "
878
+ "archivo de plantilla (header.php, front-page.php, etc)."
879
+
880
+ # @ cycloneslider
881
+ #: ../views/slider-id.php:5
882
+ msgid "Change the Slideshow ID here."
883
+ msgstr "Cambia el ID del Slideshow aquí."
884
+
885
+ # @ cycloneslider
886
+ #: ../views/slider-preview.php:9
887
+ msgid "Your preview will appear here."
888
+ msgstr "Tu nombre de usuario aparecerá aquí."
889
+
890
+ # @ cycloneslider
891
+ #: ../views/slider-properties.php:4
892
+ msgid "Transition Effects to Use:"
893
+ msgstr "Efecto de transición a usar:"
894
+
895
+ # @ cycloneslider
896
+ #: ../views/slider-properties.php:28
897
+ msgid "Milliseconds. 0 to disable auto advance."
898
+ msgstr "Milisegundos. 0 para desactivar el avance automático."
899
+
900
+ # @ cycloneslider
901
+ #: ../views/slider-properties.php:38
902
+ msgid "Width:"
903
+ msgstr "Ancho:"
904
+
905
+ # @ cycloneslider
906
+ #: ../views/slider-properties.php:40 ../views/slider-properties.php:46
907
+ msgid "pixels."
908
+ msgstr "píxeles."
909
+
910
+ # @ cycloneslider
911
+ #: ../views/slider-properties.php:44
912
+ msgid "Height:"
913
+ msgstr "Alto:"
914
+
915
+ # @ cycloneslider
916
+ #: ../views/slider-properties.php:50
917
+ msgid "Width Management:"
918
+ msgstr "Gestión del ancho:"
919
+
920
+ # @ cycloneslider
921
+ #: ../views/slider-properties.php:52
922
+ msgid "Responsive"
923
+ msgstr "Adaptable"
924
+
925
+ # @ cycloneslider
926
+ #: ../views/slider-properties.php:53
927
+ msgid "Full"
928
+ msgstr "Completo"
929
+
930
+ # @ cycloneslider
931
+ #: ../views/slider-properties.php:54
932
+ msgid "Fixed"
933
+ msgstr "Fijo"
934
+
935
+ # @ cycloneslider
936
+ #: ../views/slider-properties.php:57
937
+ msgid ""
938
+ "Responsive - resizes to smaller size but maximum width will be equal to the "
939
+ "provided width."
940
+ msgstr ""
941
+ "Adaptable. Redimensiona al tamaño más pequeño pero el ancho máximo será "
942
+ "igual que el indicado."
943
+
944
+ # @ cycloneslider
945
+ #: ../views/slider-properties.php:58
946
+ msgid ""
947
+ "Full - the same as responsive but maximum width will be equal to its "
948
+ "container ignoring the provided width."
949
+ msgstr ""
950
+ "Completo - lo mismo que adaptable, pero la ancura máxima será igual al "
951
+ "contenedor ignorando la anchura máxima indicada del slider."
952
+
953
+ # @ cycloneslider
954
+ #: ../views/slider-properties.php:59
955
+ msgid "Fixed - width and height are not resized."
956
+ msgstr "Fijo. Ancho y alto no serán modificados."
957
+
958
+ # @ cycloneslider
959
+ #: ../views/slider-properties.php:64
960
+ msgid "Pause on Hover?"
961
+ msgstr "Parar con el ratón encima?"
962
+
963
+ # @ cycloneslider
964
+ #: ../views/slider-properties.php:72
965
+ msgid "Show Prev/Next Buttons?"
966
+ msgstr "Mostrar botones Anterior/Siguiente?"
967
+
968
+ # @ cycloneslider
969
+ #: ../views/slider-properties.php:80
970
+ msgid "Show Navigation?"
971
+ msgstr "Mostrar navegación?"
972
+
973
+ # @ cycloneslider
974
+ #: ../views/slider-properties.php:85
975
+ msgid "The thumbnails or dots depending on template."
976
+ msgstr "Miniaturas o puntos dependiendo de la plantilla."
977
+
978
+ # @ cycloneslider
979
+ #: ../views/slider-properties.php:89
980
+ msgid "Resize Images?"
981
+ msgstr "Redimensionar imagenes?"
982
+
983
+ # @ cycloneslider
984
+ #: ../views/slider-properties.php:94
985
+ msgid ""
986
+ "Yes - resize images to slideshow dimension. <br>No - use the original "
987
+ "uploaded image."
988
+ msgstr ""
989
+ "Si - redimensiona las imagenes al tamaño del slider<br>No - usa el tamaño "
990
+ "original de la imagen subida"
991
+
992
+ # @ cycloneslider
993
+ #: ../views/slider-properties.php:98
994
+ msgid "Random Slide Order?"
995
+ msgstr "Orden de diapositivas aleatorio?"
996
+
997
+ # @ cycloneslider
998
+ #: ../views/slider-properties.php:103
999
+ msgid "Randomize order of slides on every page visit."
1000
+ msgstr "Cambia aleatoriamente el orden de las diapositivas en cada visita"
1001
+
1002
+ # @ cycloneslider
1003
+ #: ../views/slides.php:8
1004
+ msgid "Add Slide"
1005
+ msgstr "Añadir diapositiva"
1006
+
1007
+ # @ cycloneslider
1008
+ #: ../views/template-selection.php:4
1009
+ msgid "Name"
1010
+ msgstr "Nombre"
1011
+
1012
+ # @ cycloneslider
1013
+ #: ../views/template-selection.php:5
1014
+ msgid "Supported Slides"
1015
+ msgstr "Diapositivas soportadas"
1016
+
1017
+ # @ cycloneslider
1018
+ #: ../views/template-selection.php:6
1019
+ msgid "Location"
1020
+ msgstr "Localización"
1021
+
1022
+ # @ cycloneslider
1023
+ #: ../views/template-selection.php:7
1024
+ msgid "Selected"
1025
+ msgstr "Seleccionado"
1026
+
1027
+ # @ cycloneslider
1028
+ #~ msgid "Testimonial"
1029
+ #~ msgstr "Recomendación"
1030
+
1031
+ # @ cycloneslider
1032
+ #~ msgid "Do not show suggested videos when the video finishes."
1033
+ #~ msgstr ""
1034
+ #~ "No sugerir otros videos relacionados cuando el vídeo seleccionado termine."
1035
+
1036
+ # @ cycloneslider
1037
+ #~ msgid "Quote"
1038
+ #~ msgstr "Cita"
1039
+
1040
+ # @ cycloneslider
1041
+ #~ msgid "Author"
1042
+ #~ msgstr "Autor"
1043
+
1044
+ # @ cycloneslider
1045
+ #, fuzzy
1046
+ #~ msgid "Name:"
1047
+ #~ msgstr "Nombre:"
1048
+
1049
+ # @ default
1050
+ #~ msgid "title"
1051
+ #~ msgstr "título"
1052
+
1053
+ # @ default
1054
+ #~ msgid "description"
1055
+ #~ msgstr "descripción"
src/CycloneSlider/Admin.php ADDED
@@ -0,0 +1,705 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for displaying cyclone admin screen
4
+ */
5
+ class CycloneSlider_Admin extends CycloneSlider_Base {
6
+
7
+ public $slider_count;
8
+ protected $message_id;
9
+
10
+
11
+ public function bootstrap() {
12
+
13
+
14
+ // Set defaults
15
+ $this->slider_count = 0;
16
+
17
+ // Register admin styles and scripts
18
+ add_action( 'admin_enqueue_scripts', array( $this->plugin['asset_loader'], 'register_admin_scripts' ), 10);
19
+
20
+ // Register frontend styles and scripts
21
+ add_action( 'admin_enqueue_scripts', array( $this->plugin['asset_loader'], 'register_frontend_scripts_in_admin' ), 100 );
22
+
23
+ // Add admin menus
24
+ add_action( 'init', array( $this, 'create_post_types' ) );
25
+
26
+ // Change admin menu icon
27
+ add_action( 'admin_init', array( $this, 'change_admin_menu_icon' ) );
28
+
29
+ // Update the messages for our custom post make it appropriate for slideshow
30
+ add_filter('post_updated_messages', array( $this, 'post_updated_messages' ) );
31
+
32
+ // Remove metaboxes
33
+ add_action( 'admin_menu', array( $this, 'remove_meta_boxes' ) );
34
+
35
+ // Add slider metaboxes
36
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
37
+
38
+ // Hacky way to change text in thickbox
39
+ add_filter( 'gettext', array( $this, 'replace_text_in_thickbox' ), 10, 3 );
40
+
41
+ // Modify html of image
42
+ add_filter( 'image_send_to_editor', array( $this, 'image_send_to_editor'), 1, 8 );
43
+
44
+ // Custom columns
45
+ add_action( 'manage_cycloneslider_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
46
+ add_filter( 'manage_edit-cycloneslider_columns', array( $this, 'slideshow_columns') );
47
+
48
+ // Add hook for admin footer
49
+ add_action('admin_footer', array( $this, 'admin_footer') );
50
+
51
+ // Add body css for custom styling when on our page
52
+ add_filter('admin_body_class', array( $this, 'body_class' ) );
53
+
54
+
55
+ // Add hook for ajax operations if logged in
56
+ add_action( 'wp_ajax_cycloneslider_get_video', array( $this, 'cycloneslider_get_video' ) );
57
+
58
+
59
+ } // end constructor
60
+
61
+ /**
62
+ * Add js and css for WP media manager.
63
+ */
64
+ function body_class( $classes ) {
65
+ if('cycloneslider' == get_post_type()){
66
+ $classes .= 'cycloneslider';
67
+ }
68
+ return $classes;
69
+ }
70
+
71
+ /**
72
+ * Create Post Types
73
+ *
74
+ * Create custom post for slideshows
75
+ */
76
+ public function create_post_types() {
77
+ register_post_type( 'cycloneslider',
78
+ array(
79
+ 'labels' => array(
80
+ 'name' => __('Cyclone Slider', $this->plugin['textdomain']),
81
+ 'singular_name' => __('Slideshow', $this->plugin['textdomain']),
82
+ 'add_new' => __('Add Slideshow', $this->plugin['textdomain']),
83
+ 'add_new_item' => __('Add New Slideshow', $this->plugin['textdomain']),
84
+ 'edit_item' => __('Edit Slideshow', $this->plugin['textdomain']),
85
+ 'new_item' => __('New Slideshow', $this->plugin['textdomain']),
86
+ 'view_item' => __('View Slideshow', $this->plugin['textdomain']),
87
+ 'search_items' => __('Search Slideshows', $this->plugin['textdomain']),
88
+ 'not_found' => __('No slideshows found', $this->plugin['textdomain']),
89
+ 'not_found_in_trash' => __('No slideshows found in Trash', $this->plugin['textdomain'])
90
+ ),
91
+ 'supports' => array('title'),
92
+ 'public' => false,
93
+ 'exclude_from_search' => true,
94
+ 'show_ui' => true,
95
+ 'menu_position' => 100,
96
+ 'can_export' => false // Exclude from export
97
+ )
98
+ );
99
+ }
100
+
101
+ /**
102
+ * Change Icon
103
+ */
104
+ public function change_admin_menu_icon() {
105
+
106
+ global $menu, $wp_version;
107
+
108
+ if(!isset($menu) and !is_array($menu)) {
109
+ return false; // Abort
110
+ }
111
+
112
+ foreach( $menu as $key => $value ) {
113
+ if( 'edit.php?post_type=cycloneslider' == $value[2] ) {
114
+ if ( version_compare( $wp_version, '3.9', '<' ) ) { // WP 3.8 and below
115
+ $menu[$key][4] = str_replace('menu-icon-post', 'menu-icon-media', $menu[$key][4]);
116
+ } else { // WP 3.9+
117
+ $menu[$key][6] = 'dashicons-format-gallery';
118
+ }
119
+
120
+ }
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Add custom messages
126
+ *
127
+ * @return array Messages for cyclone
128
+ */
129
+ public function post_updated_messages($messages){
130
+ global $post, $post_ID;
131
+ $messages['cycloneslider'] = array(
132
+ 0 => '',
133
+ 1 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
134
+ 2 => __( 'Custom field updated.', $this->plugin['textdomain'] ),
135
+ 3 => __( 'Custom field deleted.', $this->plugin['textdomain'] ),
136
+ 4 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
137
+ 5 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
138
+ 6 => __( 'Slideshow published.', $this->plugin['textdomain'] ),
139
+ 7 => __( 'Slideshow saved.', $this->plugin['textdomain'] ),
140
+ 8 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
141
+ 9 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
142
+ 10 => __( 'Slideshow updated.', $this->plugin['textdomain'] ),
143
+ 101 => sprintf( __( 'Templates CSS could not be saved. Make sure %stemplates.css is writable.', $this->plugin['textdomain'] ), $this->plugin['path'].'css'.DIRECTORY_SEPARATOR),
144
+ 102 => sprintf( __( 'Templates JS could not be saved. Make sure %stemplates.js is writable.', $this->plugin['textdomain'] ), $this->plugin['path'].'js'.DIRECTORY_SEPARATOR)
145
+ );
146
+ return $messages;
147
+ }
148
+
149
+ /**
150
+ * Show custom messages
151
+ *
152
+ * @return array The array of locations containing path and url
153
+ */
154
+ public function throw_message($location) {
155
+ $location = add_query_arg( 'message', $this->message_id, $location );
156
+ $this->message_id = 0;
157
+ return $location;
158
+ }
159
+
160
+ /**
161
+ * Remove Meta Boxes
162
+ *
163
+ * Remove built-in metaboxes from our custom post type
164
+ */
165
+ public function remove_meta_boxes(){
166
+ remove_meta_box('slugdiv', 'cycloneslider', 'normal');
167
+ }
168
+
169
+ /**
170
+ * Add Meta Boxes
171
+ *
172
+ * Add custom metaboxes to our custom post type
173
+ */
174
+ public function add_meta_boxes(){
175
+
176
+ add_meta_box(
177
+ 'cyclone-slides-metabox',
178
+ __('Slides', $this->plugin['textdomain']),
179
+ array( $this, 'render_slides_meta_box' ),
180
+ 'cycloneslider' ,
181
+ 'normal',
182
+ 'high'
183
+ );
184
+
185
+ add_meta_box(
186
+ 'cyclone-slider-preview-metabox',
187
+ __('Slider Preview', $this->plugin['textdomain']),
188
+ array( $this, 'render_slider_preview_meta_box' ),
189
+ 'cycloneslider' ,
190
+ 'side',
191
+ 'high'
192
+ );
193
+
194
+ add_meta_box(
195
+ 'cyclone-slider-codes',
196
+ __('Get Slider Codes', $this->plugin['textdomain']),
197
+ array( $this, 'render_slider_codes' ),
198
+ 'cycloneslider' ,
199
+ 'side',
200
+ 'low'
201
+ );
202
+
203
+ add_meta_box(
204
+ 'cyclone-slider-properties-metabox',
205
+ __('Basic Settings', $this->plugin['textdomain']),
206
+ array( $this, 'render_slider_properties_meta_box' ),
207
+ 'cycloneslider' ,
208
+ 'side',
209
+ 'low'
210
+ );
211
+
212
+ add_meta_box(
213
+ 'cyclone-slider-advanced-settings-metabox',
214
+ __('Advanced Settings', $this->plugin['textdomain']),
215
+ array( $this, 'render_slider_advanced_settings_meta_box' ),
216
+ 'cycloneslider' ,
217
+ 'side',
218
+ 'low'
219
+ );
220
+
221
+ add_meta_box(
222
+ 'cyclone-slider-templates-metabox',
223
+ __('Templates', $this->plugin['textdomain']),
224
+ array( $this, 'render_slider_templates_meta_box' ),
225
+ 'cycloneslider' ,
226
+ 'normal',
227
+ 'low'
228
+ );
229
+
230
+ add_meta_box(
231
+ 'cyclone-slider-id',
232
+ __('Slideshow ID', $this->plugin['textdomain']),
233
+ array( $this, 'render_slider_id' ),
234
+ 'cycloneslider' ,
235
+ 'normal',
236
+ 'low'
237
+ );
238
+ }
239
+
240
+
241
+
242
+ /**
243
+ * Metabox for slides
244
+ */
245
+ public function render_slides_meta_box($post){
246
+
247
+ $slides_html = '';
248
+
249
+ $slider_settings = $this->plugin['data']->get_slider_settings( $post->ID );
250
+ $slides = $this->plugin['data']->get_slider_slides( $post->ID );
251
+
252
+ if(is_array($slides) and count($slides)>0):
253
+
254
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slide-edit.php' );
255
+
256
+ foreach($slides as $i=>$slide):
257
+
258
+ $image_url = $this->get_slide_img_thumb($slide['id']);
259
+ $image_url = apply_filters('cycloneslider_preview_url', $image_url, $slide);
260
+ $box_title = __('Slide', $this->plugin['textdomain']).' '.($i+1);
261
+ if( '' != trim($slide['title']) and 'image' == $slide['type'] ){
262
+ $box_title = $box_title. ' - '.$slide['title'];
263
+ }
264
+ $box_title = apply_filters('cycloneslider_box_title', $box_title);
265
+
266
+ $vars = array();
267
+ $vars['i'] = $i;
268
+ $vars['slider_settings'] = $slider_settings;
269
+ $vars['slide'] = $slide;
270
+ $vars['image_url'] = $image_url;
271
+ $vars['box_title'] = $box_title;
272
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug($slide) : '';
273
+ $vars['effects'] = $this->plugin['data']->get_slide_effects();
274
+
275
+ $this->plugin['view']->set_vars( $vars );
276
+
277
+ $slides_html .= $this->plugin['view']->get_render();
278
+
279
+ endforeach;
280
+ endif;
281
+
282
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slides.php' );
283
+
284
+ $vars = array();
285
+ $vars['slides'] = $slides_html;
286
+ $vars['post_id'] = $post->ID;
287
+ $vars['nonce_name'] = $this->plugin['nonce_name'];
288
+ $vars['nonce'] = wp_create_nonce( $this->plugin['nonce_action'] );
289
+
290
+ $this->plugin['view']->set_vars( $vars );
291
+ $this->plugin['view']->render();
292
+ }
293
+
294
+ /**
295
+ * Metabox for slider codes
296
+ */
297
+ public function render_slider_codes( $post ){
298
+
299
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slider-codes.php' );
300
+
301
+ $vars = array();
302
+ $vars['post'] = $post;
303
+ if(empty($post->post_name)){
304
+ $vars['shortcode'] = '';
305
+ $vars['template_code'] = '';
306
+ } else {
307
+ $vars['shortcode'] = '[cycloneslider id="'.$post->post_name.'"]';
308
+ $vars['template_code'] = '<?php if( function_exists(\'cyclone_slider\') ) cyclone_slider(\''.$post->post_name.'\'); ?>';
309
+ }
310
+ $this->plugin['view']->set_vars( $vars );
311
+ $this->plugin['view']->render();
312
+
313
+ }
314
+
315
+ /**
316
+ * Metabox for basic settings
317
+ */
318
+ public function render_slider_properties_meta_box( $post ){
319
+ $slider_settings = $this->plugin['data']->get_slider_settings( $post->ID );
320
+
321
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slider-properties.php' );
322
+
323
+ $vars = array();
324
+ $vars['slider_settings'] = $slider_settings;
325
+ $vars['effects'] = $this->plugin['data']->get_slide_effects();
326
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug($slider_settings) : '';
327
+
328
+ $this->plugin['view']->set_vars( $vars );
329
+ $this->plugin['view']->render();
330
+
331
+ }
332
+
333
+ /**
334
+ * Metabox for advanced settings
335
+ */
336
+ public function render_slider_advanced_settings_meta_box( $post ){
337
+ $slider_settings = $this->plugin['data']->get_slider_settings( $post->ID );
338
+
339
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slider-advanced-settings.php' );
340
+
341
+ $vars = array();
342
+ $vars['slider_settings'] = $slider_settings;
343
+ $vars['easing_options'] = $this->plugin['data']->get_jquery_easing_options();
344
+ $vars['resize_options'] = $this->plugin['data']->get_resize_options();
345
+
346
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug($slider_settings) : '';
347
+
348
+ $this->plugin['view']->set_vars( $vars );
349
+ $this->plugin['view']->render();
350
+
351
+ }
352
+
353
+
354
+ /**
355
+ * Metabox for preview
356
+ */
357
+ public function render_slider_preview_meta_box($post){
358
+
359
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slider-preview.php' );
360
+
361
+ $vars = array();
362
+ $vars['post'] = $post;
363
+ if(empty($post->post_name)){
364
+ $vars['shortcode'] = '';
365
+ $vars['template_code'] = '';
366
+ } else {
367
+ $vars['shortcode'] = '[cycloneslider id="'.$post->post_name.'"]';
368
+ $vars['template_code'] = '<?php if( function_exists(\'cyclone_slider\') ) cyclone_slider(\''.$post->post_name.'\'); ?>';
369
+ }
370
+ $this->plugin['view']->set_vars( $vars );
371
+
372
+ $this->plugin['view']->render();
373
+ }
374
+
375
+ /**
376
+ * Metabox for templates
377
+ */
378
+ public function render_slider_templates_meta_box($post){
379
+
380
+ $slider_settings = $this->plugin['data']->get_slider_settings($post->ID);
381
+ $templates = $this->plugin['templates_manager']->get_all_templates();
382
+ $active_templates = $this->plugin['templates_manager']->get_active_templates();
383
+ ksort ( $templates ); // Sort assoc array alphabetically
384
+ foreach($templates as $name=>$template){
385
+ if( $name == $slider_settings['template'] ){
386
+ $templates[$name]['selected'] = true;
387
+ } else {
388
+ $templates[$name]['selected'] = false;
389
+ }
390
+
391
+ if( file_exists($template['path'].'/screenshot.jpg') ) {
392
+ $templates[$name]['screenshot'] = $template['url'].'/screenshot.jpg';
393
+ } else {
394
+ $templates[$name]['screenshot'] = $this->plugin['url'].'images/screenshot.png';
395
+ }
396
+
397
+ $templates[$name]['warning'] = '';
398
+
399
+ if( $template['location_name'] == 'core' ){
400
+ $templates[$name]['location_name'] = __('Core', $this->plugin['textdomain']);
401
+ $templates[$name]['location_details'] = sprintf( __("Located inside the Cyclone Slider's templates directory:<br> <strong>%s</strong>", $this->plugin['textdomain'] ), $template['path']);
402
+ }
403
+ if( $template['location_name'] == 'active-theme' ){
404
+ $templates[$name]['location_name'] = 'Active Theme';
405
+ $templates[$name]['location_details'] = sprintf( __("Located inside your currently active theme:<br> <strong>%s</strong>", $this->plugin['textdomain'] ), $template['path']);
406
+ $templates[$name]['warning'] = sprintf( __('Your template is in danger of being overwritten when you upgrade your theme. Please move it inside %s.', $this->plugin['textdomain'] ), 'wp-content/cycloneslider' );
407
+ }
408
+ if( $template['location_name'] == 'wp-content' ){
409
+ $templates[$name]['location_name'] = 'WP Content';
410
+ $templates[$name]['location_details'] = sprintf( __("Located inside wp-content directory:<br> <strong>%s</strong>", $this->plugin['textdomain']), $template['path'] );
411
+ }
412
+
413
+ // Remove inactive templates
414
+ if($active_templates[$name]==0){
415
+ unset($templates[$name]);
416
+ }
417
+ }
418
+
419
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/template-selection.php' );
420
+
421
+ $vars = array();
422
+ $vars['slider_settings'] = $slider_settings;
423
+ $vars['templates'] = $templates;
424
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug($templates) : '';
425
+
426
+ $this->plugin['view']->set_vars( $vars );
427
+ $this->plugin['view']->render();
428
+ }
429
+
430
+ /**
431
+ * Metabox for slider ID
432
+ */
433
+ public function render_slider_id( $post ){
434
+
435
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slider-id.php' );
436
+
437
+ $vars = array();
438
+ $vars['post_name'] = $post->post_name;
439
+
440
+ $this->plugin['view']->set_vars( $vars );
441
+ $this->plugin['view']->render();
442
+
443
+ }
444
+
445
+ /**
446
+ * Hook to admin footer
447
+ */
448
+ public function admin_footer() {
449
+ // JS skeleton for adding a slide
450
+ if(get_post_type()=='cycloneslider'){
451
+ // Empty Slide
452
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slide-edit.php' );
453
+
454
+ $vars = array();
455
+ $vars['box_title'] = __('Slide *', $this->plugin['textdomain']);
456
+ $vars['image_url'] = '';
457
+ $vars['i'] = '{id}';
458
+ $vars['slide'] = $this->plugin['data']->get_slide_defaults();
459
+ foreach($vars['slide'] as $key=>$value){
460
+ $vars['slide'][$key] = '';
461
+ }
462
+ $vars['slide']['type'] = 'image';
463
+ $vars['effects'] = $this->plugin['data']->get_slide_effects();
464
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug($vars['slide']) : '';
465
+ $this->plugin['view']->set_vars( $vars );
466
+ $empty_slide = $this->plugin['view']->get_render();
467
+
468
+ // Main skeleton container
469
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/slides-skeleton.php' );
470
+
471
+ $vars = array();
472
+ $vars['empty_slide'] = $empty_slide;
473
+
474
+ $this->plugin['view']->set_vars( $vars );
475
+ $this->plugin['view']->render();
476
+ }
477
+ }
478
+
479
+
480
+ /**
481
+ * Get slide image thumb from id. False on fail
482
+ */
483
+ private function get_slide_img_thumb($attachment_id){
484
+ $attachment_id = (int) $attachment_id;
485
+ if($attachment_id > 0){
486
+ $image_url = wp_get_attachment_image_src( $attachment_id, 'medium', true );
487
+ $image_url = (is_array($image_url)) ? $image_url[0] : '';
488
+ return $image_url;
489
+ }
490
+ return false;
491
+ }
492
+
493
+ /**
494
+ * Replace text in media button for WP < 3.5
495
+ */
496
+ public function replace_text_in_thickbox($translation, $text, $domain ) {
497
+ $http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
498
+ $req_referrer = isset($_REQUEST['referer']) ? $_REQUEST['referer'] : '';
499
+ if(strpos($http_referrer, 'cycloneslider')!==false or $req_referrer=='cycloneslider') {
500
+ if ( 'default' == $domain and 'Insert into Post' == $text )
501
+ {
502
+ return 'Add to Slide';
503
+ }
504
+ }
505
+ return $translation;
506
+ }
507
+
508
+ // Add attachment ID as html5 data attr in thickbox
509
+ public function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ){
510
+ if(strpos($html, '<img data-id="')===false){
511
+ $html = str_replace('<img', '<img data-id="'.$id.'" ', $html);
512
+ }
513
+ return $html;
514
+ }
515
+
516
+ // Modify columns
517
+ public function slideshow_columns($columns) {
518
+ $columns = array();
519
+ $columns['title']= __('Slideshow Name', $this->plugin['textdomain']);
520
+ $columns['template']= __('Template', $this->plugin['textdomain']);
521
+ $columns['images']= __('No. of Slides', $this->plugin['textdomain']);
522
+ $columns['id']= __('Slideshow ID', $this->plugin['textdomain']);
523
+ $columns['shortcode']= __('Shortcode', $this->plugin['textdomain']);
524
+ return $columns;
525
+ }
526
+
527
+ // Add content to custom columns
528
+ public function custom_column( $column_name, $post_id ){
529
+ if ($column_name == 'template') {
530
+ $settings = $this->plugin['data']->get_slider_settings($post_id);
531
+ echo ucwords($settings['template']);
532
+ }
533
+ if ($column_name == 'images') {
534
+ echo '<div style="text-align:center; max-width:40px;">' . $this->plugin['data']->get_slide_count( $post_id ) . '</div>';
535
+ }
536
+ if ($column_name == 'id') {
537
+ $post = get_post($post_id);
538
+ echo $post->post_name;
539
+ }
540
+ if ($column_name == 'shortcode') {
541
+ $post = get_post($post_id);
542
+ echo '[cycloneslider id="'.$post->post_name.'"]';
543
+ }
544
+ }
545
+
546
+
547
+
548
+ // Compare the value from admin and shortcode. If shortcode value is present and not empty, use it, otherwise return admin value
549
+ public function get_comp_slider_setting($admin_val, $shortcode_val){
550
+ if($shortcode_val!==null){//make sure its really null and not just int zero 0
551
+ return $shortcode_val;
552
+ }
553
+ return $admin_val;
554
+ }
555
+
556
+ // Return array of slide urls from meta
557
+ public function get_slides_from_meta($slider_metas){
558
+ $slides = array();
559
+ if(is_array($slider_metas)){
560
+ foreach($slider_metas as $slider_meta){
561
+ $attachment_id = (int) $slider_meta['id'];
562
+ $image_url = wp_get_attachment_url($attachment_id);
563
+ $image_url = ($image_url===false) ? '' : $image_url;
564
+ $slides[] = $image_url;
565
+ }
566
+ }
567
+ return $slides;
568
+ }
569
+
570
+
571
+ /**
572
+ * YOUTUBE & VIMEO
573
+ */
574
+
575
+ /**
576
+ * Ajax for getting videos
577
+ */
578
+ public function cycloneslider_get_video(){
579
+ $url = $_POST['url'];
580
+
581
+ $retval = array(
582
+ 'success' => false
583
+ );
584
+
585
+ if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
586
+
587
+ if( $video_id = $this->get_youtube_id($url) ){ //If youtube url
588
+ if( $embed = wp_oembed_get($url) ){ //Get embed, false on fail
589
+ $retval = array(
590
+ 'success' => true,
591
+ 'url' => $this->get_youtube_thumb($video_id),
592
+ 'embed' => $embed
593
+ );
594
+ }
595
+
596
+ } else if( $video_id = $this->get_vimeo_id($url) ){ //If vimeo url
597
+ if( $embed = wp_oembed_get($url) ){ //Get embed, false on fail
598
+ $retval = array(
599
+ 'success' => true,
600
+ 'url' => $this->get_vimeo_thumb($video_id),
601
+ 'embed' => $embed
602
+ );
603
+ }
604
+ }
605
+ }
606
+
607
+ echo json_encode($retval);
608
+ die();
609
+ }
610
+
611
+ /**
612
+ * Get video thumb url
613
+ *
614
+ * @param string $url A valid youtube or vimeo url
615
+ */
616
+ public function get_video_thumb_from_url($url){
617
+ $url = esc_url_raw($url);
618
+
619
+ if ( $video_id = $this->get_youtube_id($url) ) { // A youtube url
620
+
621
+ return $this->get_youtube_thumb($video_id);
622
+
623
+ } else if( $video_id = $this->get_vimeo_id($url) ){ // A vimeo url
624
+
625
+ return $this->get_vimeo_thumb($video_id);
626
+ }
627
+
628
+ return false;
629
+ }
630
+
631
+ /**
632
+ * Return vimeo video id
633
+ */
634
+ public function get_vimeo_id($url){
635
+
636
+ $parsed_url = parse_url($url);
637
+ if ($parsed_url['host'] == 'vimeo.com'){
638
+ $vimeo_id = ltrim( $parsed_url['path'], '/');
639
+ if (is_numeric($vimeo_id)) {
640
+ return $vimeo_id;
641
+ }
642
+ }
643
+ return false;
644
+ }
645
+
646
+ /**
647
+ * Get vimeo video thumbnail image
648
+ *
649
+ * @param int Vimeo ID.
650
+ * @param string Size can be: thumbnail_small, thumbnail_medium, thumbnail_large.
651
+ *
652
+ * @return string URL of thumbnail image.
653
+ */
654
+ public function get_vimeo_thumb($video_id, $size = 'thumbnail_large'){
655
+ $vimeo = unserialize( file_get_contents('http://vimeo.com/api/v2/video/'.$video_id.'.php') );
656
+ if( isset($vimeo[0][$size]) ){
657
+ return $vimeo[0][$size];
658
+ }
659
+ return '';
660
+ }
661
+
662
+ /**
663
+ * Get youtube video thumbnail image
664
+ *
665
+ * @param int Youtube ID.
666
+ *
667
+ * @return string URL of thumbnail image.
668
+ */
669
+ public function get_youtube_thumb($video_id){
670
+ return 'http://img.youtube.com/vi/'.$video_id.'/0.jpg';
671
+ }
672
+
673
+ /**
674
+ * Get youtube ID from different url formats
675
+ *
676
+ * @param string $url Youtube url
677
+ * @return string Youtube URL or boolean false on fail
678
+ */
679
+ public function get_youtube_id($url){
680
+ if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
681
+ return false;
682
+ }
683
+ $parsed_url = parse_url($url);
684
+
685
+ if(strpos($parsed_url['host'], 'youtube.com')!==false){
686
+ if(strpos($parsed_url['path'], '/watch')!==false){ // Regular url Eg. http://www.youtube.com/watch?v=9bZkp7q19f0
687
+ parse_str($parsed_url['query'], $parsed_str);
688
+ if(isset($parsed_str['v']) and !empty($parsed_str['v'])){
689
+ return $parsed_str['v'];
690
+ }
691
+ } else if(strpos($parsed_url['path'], '/v/')!==false){ // "v" URL http://www.youtube.com/v/9bZkp7q19f0?version=3&autohide=1
692
+ $id = str_replace('/v/','',$parsed_url['path']);
693
+ if( !empty($id) ){
694
+ return $id;
695
+ }
696
+ } else if(strpos($parsed_url['path'], '/embed/')!==false){ // Embed URL: http://www.youtube.com/embed/9bZkp7q19f0
697
+ return str_replace('/embed/','',$parsed_url['path']);
698
+ }
699
+ } else if(strpos($parsed_url['host'], 'youtu.be')!==false){ // Shortened URL: http://youtu.be/9bZkp7q19f0
700
+ return str_replace('/','',$parsed_url['path']);
701
+ }
702
+
703
+ return false;
704
+ }
705
+ } // end class
src/CycloneSlider/AssetLoader.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for handling styles and scripts
4
+ */
5
+ class CycloneSlider_AssetLoader {
6
+
7
+ protected $plugin;
8
+ protected $cyclone_settings_data;
9
+
10
+ public function run( $plugin ) {
11
+ $this->plugin = $plugin;
12
+
13
+ $this->cyclone_settings_data = $this->plugin['settings_page']->get_settings_data();
14
+
15
+ // Register frontend styles and scripts
16
+ add_action( 'wp_enqueue_scripts', array( $this, 'register_frontend_scripts' ), 100 );
17
+
18
+ // Add scripts
19
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_admin_scripts' ), 10);
20
+
21
+ add_action( 'admin_enqueue_scripts', array( $this, 'register_frontend_scripts_in_admin' ), 10);
22
+ }
23
+
24
+ /**
25
+ * Scripts and styles for slider admin area
26
+ */
27
+ public function register_admin_scripts( $hook ) {
28
+
29
+ if( 'cycloneslider' == get_post_type() || $hook == 'cycloneslider_page_cycloneslider-settings' || $hook == 'cycloneslider_page_cycloneslider-export' ||$hook == 'cycloneslider_page_cycloneslider-import' ){ // Limit loading to certain admin pages
30
+
31
+ // Required media files for new media manager. Since WP 3.5+
32
+ wp_enqueue_media();
33
+
34
+ // Fontawesome style
35
+ wp_enqueue_style( 'font-awesome', $this->plugin['url'].'libs/font-awesome/css/font-awesome.min.css', array(), $this->plugin['version'] );
36
+
37
+ // Main style
38
+ wp_enqueue_style( 'cycloneslider-admin-styles', $this->plugin['url'].'css/admin.css', array(), $this->plugin['version'] );
39
+
40
+ // Disable autosave
41
+ wp_dequeue_script( 'autosave' );
42
+
43
+ // For sortable elements
44
+ wp_enqueue_script('jquery-ui-sortable');
45
+
46
+ // For localstorage
47
+ wp_enqueue_script( 'store', $this->plugin['url'].'js/store-json2.min.js', array('jquery'), $this->plugin['version'] );
48
+
49
+ // Allow translation to script texts
50
+ wp_register_script( 'cycloneslider-admin-script', $this->plugin['url'].'js/admin.js', array('jquery'), $this->plugin['version'] );
51
+ wp_localize_script( 'cycloneslider-admin-script', 'cycloneslider_admin_vars',
52
+ array(
53
+ 'title' => __( 'Select an image', 'cycloneslider' ), // This will be used as the default title
54
+ 'title2' => __( 'Select Images - Use Ctrl + Click or Shift + Click', 'cycloneslider' ),
55
+ 'button' => __( 'Add to Slide', 'cycloneslider' ), // This will be used as the default button text
56
+ 'button2' => __( 'Add Images as Slides', 'cycloneslider' ),
57
+ 'youtube_url_error' => __( 'Error. Make sure its a valid YouTube URL.', 'cycloneslider' )
58
+ )
59
+ );
60
+ wp_enqueue_script( 'cycloneslider-admin-script');
61
+
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Scripts and styles for slider to run in admin preview. Must be hook to either admin_enqueue_scripts or wp_enqueue_scripts
67
+ *
68
+ * @param string $hook Hook name passed by WP
69
+ * @return void
70
+ */
71
+ public function register_frontend_scripts_in_admin( $hook ) {
72
+ if( get_post_type() == 'cycloneslider' || 'cycloneslider_page_cycloneslider-settings' == $hook || 'cycloneslider_page_cycloneslider-export' == $hook || 'cycloneslider_page_cycloneslider-import' == $hook ){ // Limit loading to certain admin pages
73
+ $this->register_frontend_scripts( $hook );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Scripts and styles for slider to run. Must be hook to either admin_enqueue_scripts or wp_enqueue_scripts
79
+ *
80
+ * @param string $hook Hook name passed by WP
81
+ * @return void
82
+ */
83
+ public function register_frontend_scripts( $hook ) {
84
+
85
+ $in_footer = true;
86
+ if($this->cyclone_settings_data['load_scripts_in'] == 'header'){
87
+ $in_footer = false;
88
+ }
89
+
90
+ /*** Magnific Popup Style ***/
91
+ if($this->cyclone_settings_data['load_magnific'] == 1){
92
+ wp_enqueue_style( 'jquery-magnific-popup', $this->plugin['url'].'libs/magnific-popup/magnific-popup.css', array(), $this->plugin['version'] );
93
+ }
94
+
95
+ /*** Templates Styles ***/
96
+ $this->enqueue_templates_css();
97
+
98
+ /*****************************/
99
+
100
+ /*** Core Cycle2 Scripts ***/
101
+ if($this->cyclone_settings_data['load_cycle2'] == 1){
102
+ wp_enqueue_script( 'jquery-cycle2', $this->plugin['url'].'libs/cycle2/jquery.cycle2.min.js', array('jquery'), $this->plugin['version'], $in_footer );
103
+ }
104
+ if($this->cyclone_settings_data['load_cycle2_carousel'] == 1){
105
+ wp_enqueue_script( 'jquery-cycle2-carousel', $this->plugin['url'].'libs/cycle2/jquery.cycle2.carousel.min.js', array('jquery', 'jquery-cycle2'), $this->plugin['version'], $in_footer );
106
+ }
107
+ if($this->cyclone_settings_data['load_cycle2_swipe'] == 1){
108
+ wp_enqueue_script( 'jquery-cycle2-swipe', $this->plugin['url'].'libs/cycle2/jquery.cycle2.swipe.min.js', array('jquery', 'jquery-cycle2'), $this->plugin['version'], $in_footer );
109
+ }
110
+ if($this->cyclone_settings_data['load_cycle2_tile'] == 1){
111
+ wp_enqueue_script( 'jquery-cycle2-tile', $this->plugin['url'].'libs/cycle2/jquery.cycle2.tile.min.js', array('jquery', 'jquery-cycle2'), $this->plugin['version'], $in_footer );
112
+ }
113
+ if($this->cyclone_settings_data['load_cycle2_video'] == 1){
114
+ wp_enqueue_script( 'jquery-cycle2-video', $this->plugin['url'].'libs/cycle2/jquery.cycle2.video.min.js', array('jquery', 'jquery-cycle2'), $this->plugin['version'], $in_footer );
115
+ }
116
+
117
+ /*** Easing Script***/
118
+ if($this->cyclone_settings_data['load_easing'] == 1){
119
+ wp_enqueue_script( 'jquery-easing', $this->plugin['url'].'libs/jquery-easing/jquery.easing.1.3.1.min.js', array('jquery'), $this->plugin['version'], $in_footer );
120
+ }
121
+
122
+ /*** Magnific Popup Scripts ***/
123
+ if($this->cyclone_settings_data['load_magnific'] == 1){
124
+ wp_enqueue_script( 'jquery-magnific-popup', $this->plugin['url'].'libs/magnific-popup/jquery.magnific-popup.min.js', array('jquery'), $this->plugin['version'], $in_footer );
125
+ }
126
+
127
+ /*** Templates Scripts ***/
128
+ $this->enqueue_templates_scripts();
129
+
130
+ /*** Client Script ***/
131
+ wp_enqueue_script( 'cyclone-client', $this->plugin['url'].'js/client.js', array('jquery'), $this->plugin['version'], $in_footer );
132
+
133
+ }
134
+
135
+ /**
136
+ * Enqueues templates styles.
137
+ */
138
+ private function enqueue_templates_css(){
139
+ $ds = DIRECTORY_SEPARATOR;
140
+
141
+ $template_folders = $this->plugin['templates_manager']->get_all_templates();
142
+ $active_templates = $this->plugin['templates_manager']->get_active_templates( $this->cyclone_settings_data );
143
+
144
+ foreach($template_folders as $name=>$folder){
145
+
146
+ if( 1 == $active_templates[$name] ){
147
+ $file = $folder['path']."/style.css"; // Path to file
148
+
149
+ if( file_exists( $file ) ){ // Check existence
150
+ wp_enqueue_style( 'cyclone-template-style-'.sanitize_title($name), $folder['url'].'/style.css', array(), $this->plugin['version'] );
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ /**
157
+ * Enqueues templates scripts.
158
+ */
159
+ private function enqueue_templates_scripts(){
160
+ $ds = DIRECTORY_SEPARATOR;
161
+
162
+ $in_footer = true;
163
+ if($this->cyclone_settings_data['load_scripts_in'] == 'header'){
164
+ $in_footer = false;
165
+ }
166
+
167
+ $template_folders = $this->plugin['templates_manager']->get_all_templates();
168
+ $active_templates = $this->plugin['templates_manager']->get_active_templates( $this->cyclone_settings_data );
169
+
170
+ foreach($template_folders as $name=>$folder){
171
+
172
+ if( 1 == $active_templates[$name] ){
173
+ $file = $folder['path']."/script.js"; // Path to file
174
+
175
+ if( file_exists( $file ) ){ // Check existence
176
+ wp_enqueue_script( 'cyclone-template-script-'.sanitize_title($name), $folder['url'].'/script.js', array(), $this->plugin['version'], $in_footer );
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
src/CycloneSlider/Base.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class CycloneSlider_Base {
3
+ protected $plugin;
4
+
5
+ public function run( $plugin ) {
6
+ $this->plugin = $plugin;
7
+ }
8
+ }
src/CycloneSlider/Data.php ADDED
@@ -0,0 +1,611 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for saving and getting slider data
4
+ */
5
+ class CycloneSlider_Data {
6
+
7
+ protected $plugin;
8
+
9
+ /**
10
+ * Initializes the class
11
+ */
12
+ public function __construct(){}
13
+
14
+ public function run( $plugin ){
15
+ $this->plugin = $plugin;
16
+
17
+ // Save slides
18
+ add_action( 'save_post', array( $this, 'save_slider_post' ) );
19
+ }
20
+
21
+ /**
22
+ * Save post hook
23
+ */
24
+ public function save_slider_post( $post_id ){
25
+ global $cyclone_slider_saved_done;
26
+
27
+ // Stop! We have already saved..
28
+ if($cyclone_slider_saved_done){
29
+ return $post_id;
30
+ }
31
+
32
+ // Verify nonce
33
+ $nonce_name = $this->plugin['nonce_name'];
34
+ if (!empty($_POST[$nonce_name])) {
35
+ if (!wp_verify_nonce($_POST[$nonce_name], $this->plugin['nonce_action'])) {
36
+ return $post_id;
37
+ }
38
+ } else {
39
+ return $post_id; // Make sure we cancel on missing nonce!
40
+ }
41
+
42
+ // Check autosave
43
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
44
+ return $post_id;
45
+ }
46
+
47
+ // Resize images if needed
48
+ if($_POST['cycloneslider_settings']['resize'] == 1){
49
+ $this->plugin['image_resizer']->resize_images( $_POST['cycloneslider_settings'], $_POST['cycloneslider_metas'] );
50
+
51
+ }
52
+
53
+ // Save slides
54
+ $this->add_slider_slides( $post_id, $_POST['cycloneslider_metas'] );
55
+
56
+ // Save slider settings
57
+ $this->add_slider_settings( $post_id, $_POST['cycloneslider_settings']);
58
+
59
+ // Marked as done
60
+ $cyclone_slider_saved_done = true;
61
+ }
62
+
63
+ /**
64
+ * API to add slider
65
+ */
66
+ public function add_slider( $post_title, $slider_settings, $slides ){
67
+ global $cyclone_slider_saved_done;
68
+
69
+ $cyclone_slider_saved_done= true; // Prevent double whammy!
70
+
71
+ $post_data = array(
72
+ 'post_type' => 'cycloneslider',
73
+ 'post_title' => $post_title,
74
+ 'post_content' => '',
75
+ 'post_status' => 'publish'
76
+ );
77
+
78
+ if( $slider_id = wp_insert_post( $post_data ) ){
79
+
80
+ // Resize images if needed
81
+ if( $slider_settings['resize'] == 1){
82
+ $this->plugin['image_resizer']->resize_images( $slider_settings, $slides );
83
+ }
84
+
85
+ // Save slides
86
+ $this->add_slider_slides( $slider_id, $slides );
87
+
88
+ // Save slider settings
89
+ $this->add_slider_settings( $slider_id, $slider_settings );
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Add Slide Settings
95
+ *
96
+ * API to add slider settings to slider post meta
97
+ *
98
+ * @param int $slider_id Slider post ID
99
+ * @param array $settings Slider settings array
100
+ * @return void
101
+ */
102
+ public function add_slider_settings( $slider_id, $settings ){
103
+ $settings = wp_parse_args(
104
+ $settings,
105
+ $this->get_slider_defaults()
106
+ );
107
+
108
+ $settings_to_save['template'] = sanitize_text_field( $settings['template'] );
109
+ $settings_to_save['fx'] = sanitize_text_field( $settings['fx'] );
110
+ $settings_to_save['timeout'] = (int) ( $settings['timeout'] );
111
+ $settings_to_save['speed'] = (int) ( $settings['speed'] );
112
+ $settings_to_save['width'] = (int) ( $settings['width'] );
113
+ $settings_to_save['height'] = (int) ( $settings['height'] );
114
+ $settings_to_save['hover_pause'] = sanitize_text_field( $settings['hover_pause'] );
115
+ $settings_to_save['show_prev_next'] = (int) ( $settings['show_prev_next'] );
116
+ $settings_to_save['show_nav'] = (int) ( $settings['show_nav'] );
117
+ $settings_to_save['tile_count'] = (int) ( $settings['tile_count'] );
118
+ $settings_to_save['tile_delay'] = (int) ( $settings['tile_delay'] );
119
+ $settings_to_save['tile_vertical'] = sanitize_text_field( $settings['tile_vertical'] );
120
+ $settings_to_save['random'] = (int) ( $settings['random'] );
121
+ $settings_to_save['resize'] = (int) ( $settings['resize'] );
122
+ $settings_to_save['width_management'] = sanitize_text_field( $settings['width_management'] );
123
+ $settings_to_save['easing'] = sanitize_text_field( $settings['easing'] );
124
+ $settings_to_save['resize_option'] = sanitize_text_field( $settings['resize_option'] );
125
+ $settings_to_save['allow_wrap'] = sanitize_text_field( $settings['allow_wrap'] );
126
+ $settings_to_save['dynamic_height'] = sanitize_text_field( $settings['dynamic_height'] );
127
+ $settings_to_save['delay'] = (int) ( $settings['delay'] );
128
+ $settings_to_save['swipe'] = sanitize_text_field( $settings['swipe'] );
129
+
130
+ $settings_to_save = apply_filters('cycloneslider_settings', $settings_to_save, $slider_id); // Apply filters before saving
131
+
132
+ delete_post_meta($slider_id, '_cycloneslider_settings');
133
+ update_post_meta($slider_id, '_cycloneslider_settings', $settings_to_save);
134
+ }
135
+
136
+ /**
137
+ * Add Slider Slides
138
+ *
139
+ * API to add slides
140
+ *
141
+ * @param int $slider_id Slider post ID
142
+ * @param array $slides Slides array
143
+ * @return void
144
+ */
145
+ public function add_slider_slides( $slider_id, $slides ){
146
+
147
+ $slides_to_save = array();
148
+
149
+ if( is_array($slides) ){
150
+
151
+ $i=0;//always start from 0
152
+ foreach($slides as $slide){
153
+ $slide = wp_parse_args(
154
+ $slide,
155
+ $this->get_slide_defaults()
156
+ );
157
+ $slides_to_save[$i]['id'] = (int) ($slide['id']);
158
+ $slides_to_save[$i]['type'] = sanitize_text_field($slide['type']);
159
+
160
+ $slides_to_save[$i]['link'] = esc_url_raw($slide['link']);
161
+ $slides_to_save[$i]['title'] = wp_kses_post($slide['title']);
162
+ $slides_to_save[$i]['description'] = wp_kses_post($slide['description']);
163
+ $slides_to_save[$i]['link_target'] = sanitize_text_field($slide['link_target']);
164
+
165
+ $slides_to_save[$i]['img_alt'] = sanitize_text_field($slide['img_alt']);
166
+ $slides_to_save[$i]['img_title'] = sanitize_text_field($slide['img_title']);
167
+
168
+ $slides_to_save[$i]['enable_slide_effects'] = (int) ($slide['enable_slide_effects']);
169
+ $slides_to_save[$i]['fx'] = sanitize_text_field($slide['fx']);
170
+ $slides_to_save[$i]['speed'] = sanitize_text_field($slide['speed']);
171
+ $slides_to_save[$i]['timeout'] = sanitize_text_field($slide['timeout']);
172
+ $slides_to_save[$i]['tile_count'] = sanitize_text_field($slide['tile_count']);
173
+ $slides_to_save[$i]['tile_delay'] = sanitize_text_field($slide['tile_delay']);
174
+ $slides_to_save[$i]['tile_vertical'] = sanitize_text_field($slide['tile_vertical']);
175
+
176
+ $slides_to_save[$i]['video_thumb'] = esc_url_raw($slide['video_thumb']);
177
+ $slides_to_save[$i]['video_url'] = esc_url_raw($slide['video_url']);
178
+ $slides_to_save[$i]['video'] = $slide['video'];
179
+
180
+ $slides_to_save[$i]['custom'] = $slide['custom'];
181
+
182
+ $slides_to_save[$i]['youtube_url'] = esc_url_raw($slide['youtube_url']);
183
+ $slides_to_save[$i]['youtube_related'] = sanitize_text_field($slide['youtube_related']);
184
+
185
+ $slides_to_save[$i]['vimeo_url'] = esc_url_raw($slide['vimeo_url']);
186
+
187
+ $slides_to_save[$i]['testimonial'] = wp_kses_post($slide['testimonial']);
188
+ $slides_to_save[$i]['testimonial_author'] = sanitize_text_field($slide['testimonial_author']);
189
+ $slides_to_save[$i]['testimonial_link'] = esc_url_raw($slide['testimonial_link']);
190
+ $slides_to_save[$i]['testimonial_link_target'] = sanitize_text_field($slide['testimonial_link_target']);
191
+
192
+ $i++;
193
+ }
194
+
195
+ }
196
+ $slides_to_save = apply_filters('cycloneslider_slides', $slides_to_save); //do filter before saving
197
+
198
+ delete_post_meta($slider_id, '_cycloneslider_metas');
199
+ update_post_meta($slider_id, '_cycloneslider_metas', $slides_to_save);
200
+ }
201
+
202
+
203
+
204
+ public function get_thumb_name( $image_file, $width, $height ){
205
+
206
+ // Get image path info and create file name
207
+ $info = pathinfo( $image_file ); // Eg: d:/uploads/image-1.jpg
208
+ if( !isset($info['extension']) or !isset($info['filename'])){
209
+ return false;
210
+ }
211
+
212
+ $ext = $info['extension']; // File extension Eg. "jpg"
213
+ $filename = $info['filename']; // Filename Eg. "image-1"
214
+ return "{$filename}-{$width}x{$height}.{$ext}"; // Thumbname. Eg. "image-1-600x300.jpg"
215
+
216
+ }
217
+
218
+ /**
219
+ * Get Sliders
220
+ *
221
+ * Get all sliders and their accompanying meta data
222
+ *
223
+ * @return array|false The array of sliders post and their meta data or false on fail
224
+ */
225
+ public function get_sliders( $args=array() ){
226
+ $defaults = array(
227
+ 'post_type' => 'cycloneslider',
228
+ 'numberposts' => -1 // Get all
229
+ );
230
+ $args = wp_parse_args($args, $defaults);
231
+
232
+ $slider_posts = get_posts( $args ); // Use get_posts to avoid filters
233
+ $sliders = array(); // Store it here
234
+ if( !empty($slider_posts) and is_array($slider_posts) ){
235
+ foreach($slider_posts as $index=>$slider_post){
236
+ $sliders[$index] = (array) $slider_post;
237
+ $sliders[$index]['slider_settings'] = $this->get_slider_settings( $slider_post->ID );
238
+ $sliders[$index]['slides'] = $this->get_slider_slides( $slider_post->ID );
239
+ }
240
+ return $sliders;
241
+ } else {
242
+ return false;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Get Slider Settings
248
+ *
249
+ * Get slider settings by $slider_id
250
+ *
251
+ * @paramt int $slider_id ID of slider post
252
+ * @return array The array of slider settings
253
+ */
254
+ public function get_slider_settings( $slider_id ) {
255
+ $meta = get_post_custom( $slider_id );
256
+ $slider_settings = array();
257
+ if(isset($meta['_cycloneslider_settings'][0]) and !empty($meta['_cycloneslider_settings'][0])){
258
+ $slider_settings = maybe_unserialize($meta['_cycloneslider_settings'][0]);
259
+ }
260
+ $slider_settings = wp_parse_args($slider_settings, $this->get_slider_defaults() );
261
+ return apply_filters('cycloneslider_get_slider_settings', $slider_settings);
262
+ }
263
+
264
+ /**
265
+ * Get Slider Slides
266
+ *
267
+ * @param int $slider_id Post ID of the slider custom post.
268
+ * @return array The array of slides settings
269
+ */
270
+ public function get_slider_slides( $slider_id ){
271
+ $meta = get_post_custom( $slider_id );
272
+
273
+ if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){
274
+ $slides = maybe_unserialize($meta['_cycloneslider_metas'][0]);
275
+ $defaults = $this->get_slide_defaults();
276
+
277
+ foreach($slides as $i=>$slide){
278
+ $slides[$i] = wp_parse_args($slide, $defaults);
279
+ }
280
+
281
+ return apply_filters('cycloneslider_get_slider_slides', $slides);
282
+ }
283
+ return false;
284
+ }
285
+
286
+ /**
287
+ * Get Slider by Slug
288
+ *
289
+ * @param string $slug Post slug of the slider custom post.
290
+ * @return array|false The array of slider post and associated meta or false if none found
291
+ */
292
+ public function get_slider_by_slug( $slug ) {
293
+ // Get slider by id
294
+ $args = array(
295
+ 'post_type' => 'cycloneslider',
296
+ 'numberposts' => 1,
297
+ 'name'=> $slug
298
+ );
299
+
300
+ $slider_posts = get_posts( $args ); // Use get_posts to avoid filters
301
+
302
+ $sliders = array(); // Store it here
303
+ if( !empty($slider_posts) and is_array($slider_posts) ){
304
+ foreach($slider_posts as $index=>$slider_post){
305
+ $sliders[$index] = (array) $slider_post;
306
+ $sliders[$index]['slider_settings'] = $this->get_slider_settings( $slider_post->ID );
307
+ $sliders[$index]['slides'] = $this->get_slider_slides( $slider_post->ID );
308
+ }
309
+ return $sliders[0];
310
+ }
311
+
312
+ return false;
313
+ }
314
+
315
+ /**
316
+ * Gets the number of slides of slideshow
317
+ *
318
+ * @param int $slider_id Post ID of slider custom post
319
+ * @return int|0 Total images or zero
320
+ */
321
+ public function get_slide_count( $slider_id ){
322
+ $meta = get_post_custom( $slider_id );
323
+
324
+ if(isset($meta['_cycloneslider_metas'][0]) and !empty($meta['_cycloneslider_metas'][0])){
325
+ $slides = maybe_unserialize($meta['_cycloneslider_metas'][0]);
326
+
327
+ return count($slides);
328
+ }
329
+ return 0;
330
+ }
331
+
332
+ /**
333
+ * Get Slide Image URL
334
+ */
335
+ public function get_slide_image_url( $slide_image_id, $slider_settings ){
336
+ $width = $slider_settings['width'];
337
+ $height = $slider_settings['height'];
338
+
339
+ // Get url to full image, its width and height
340
+ $image_dimensions = wp_get_attachment_image_src($slide_image_id, 'full');
341
+ if(!$image_dimensions){
342
+ return false;
343
+ }
344
+
345
+ // Assign variables
346
+ list($image_url, $orig_width, $orig_height) = $image_dimensions;
347
+
348
+ // If orig image width and height is the same as slideshow width and height, do not resize and return url
349
+ if($orig_width == $width and $orig_height == $height){
350
+ return $image_url;
351
+ }
352
+
353
+ //If resize is no, return url
354
+ if( isset( $slider_settings['resize'] ) and $slider_settings['resize'] == 0 ){
355
+ return $image_url;
356
+ }
357
+
358
+ // Get full path to the slide image
359
+ $image_file = get_attached_file($slide_image_id);
360
+ if(empty($image_file)){
361
+ return false;
362
+ }
363
+
364
+ $thumb_name = $this->get_thumb_name( $image_file, $width, $height );
365
+ $thumb_url = dirname($image_url).'/'.$thumb_name; // URL to thumbnail
366
+
367
+ return $thumb_url;
368
+ }
369
+
370
+ /**
371
+ * Gets the slider default settings.
372
+ *
373
+ * @return array The array of slider defaults
374
+ */
375
+ public function get_slider_defaults(){
376
+ return array(
377
+ 'template' => 'standard',
378
+ 'fx' => 'fade',
379
+ 'timeout' => '4000',
380
+ 'speed' => '1000',
381
+ 'width' => '960',
382
+ 'height' => '600',
383
+ 'hover_pause' => 'true',
384
+ 'show_prev_next' => '1',
385
+ 'show_nav' => '1',
386
+ 'tile_count' => '7',
387
+ 'tile_delay' => '100',
388
+ 'tile_vertical' => 'true',
389
+ 'random' => 0,
390
+ 'resize' => 1,
391
+ 'width_management' => 'responsive',
392
+ 'resize_option' => 'auto',
393
+ 'easing' => '',
394
+ 'allow_wrap' => 'true',
395
+ 'dynamic_height' => 'off',
396
+ 'delay' => 0,
397
+ 'swipe' => 'false'
398
+ );
399
+ }
400
+
401
+ /**
402
+ * Gets the slide default settings.
403
+ *
404
+ * @return array The array of slide defaults
405
+ */
406
+ public function get_slide_defaults(){
407
+ return array(
408
+ 'enable_slide_effects'=>0,
409
+ 'type' => 'image',
410
+ 'id' => '',
411
+ 'link' => '',
412
+ 'title' => '',
413
+ 'description' => '',
414
+ 'link_target' => '_self',
415
+ 'fx' => 'default',
416
+ 'speed' => '',
417
+ 'timeout' => '',
418
+ 'tile_count' => '7',
419
+ 'tile_delay' => '100',
420
+ 'tile_vertical' => 'true',
421
+ 'img_alt' => '',
422
+ 'img_title' => '',
423
+
424
+ 'video_thumb' => '',
425
+ 'video_url' => '',
426
+ 'video' => '',
427
+
428
+ 'custom' => '',
429
+
430
+ 'youtube_url' => '',
431
+ 'youtube_related' => 'false',
432
+
433
+ 'vimeo_url' => '',
434
+
435
+ 'testimonial' => '',
436
+ 'testimonial_author' => '',
437
+ 'testimonial_link' => '',
438
+ 'testimonial_link_target' => '_self'
439
+ );
440
+ }
441
+
442
+ /**
443
+ * Get Resize Options
444
+ *
445
+ * @return array The array of resize options in a key-value pair
446
+ */
447
+ public function get_resize_options(){
448
+ return array(
449
+ 'auto' => 'Auto',
450
+ 'crop' => 'Crop',
451
+ 'exact' => 'Exact',
452
+ 'landscape' => 'Landscape',
453
+ 'portrait' => 'Portrait'
454
+ );
455
+ }
456
+
457
+ /**
458
+ * Gets the slide effects.
459
+ *
460
+ * @return array The array of supported slide effects
461
+ */
462
+ public function get_slide_effects(){
463
+ return array(
464
+ 'fade'=>'Fade',
465
+ 'fadeout'=>'Fade Out',
466
+ 'none'=>'None',
467
+ 'scrollHorz'=>'Scroll Horizontally',
468
+ 'tileBlind'=>'Tile Blind',
469
+ 'tileSlide'=>'Tile Slide'
470
+ );
471
+ }
472
+
473
+ /**
474
+ * Get array of jquery easing options
475
+ *
476
+ * @return array Easing options
477
+ */
478
+ public function get_jquery_easing_options(){
479
+ return array(
480
+ array(
481
+ 'text' => 'Default',
482
+ 'value' => ''
483
+ ),
484
+ array(
485
+ 'text' => 'Swing',
486
+ 'value' => 'swing'
487
+ ),
488
+ array(
489
+ 'text' => 'Ease-In Quad',
490
+ 'value' => 'easeInQuad'
491
+ ),
492
+ array(
493
+ 'text' => 'Ease-Out Quad',
494
+ 'value' => 'easeOutQuad'
495
+ ),
496
+ array(
497
+ 'text' => 'Ease-In OutQuad',
498
+ 'value' => 'easeInOutQuad'
499
+ ),
500
+ array(
501
+ 'text' => 'Ease-In Cubic',
502
+ 'value' => 'easeInCubic'
503
+ ),
504
+ array(
505
+ 'text' => 'Ease-Out Cubic',
506
+ 'value' => 'easeOutCubic'
507
+ ),
508
+ array(
509
+ 'text' => 'Ease-In OutCubic',
510
+ 'value' => 'easeInOutCubic'
511
+ ),
512
+ array(
513
+ 'text' => 'Ease-In Quart',
514
+ 'value' => 'easeInQuart'
515
+ ),
516
+ array(
517
+ 'text' => 'Ease-Out Quart',
518
+ 'value' => 'easeOutQuart'
519
+ ),
520
+ array(
521
+ 'text' => 'Ease-In OutQuart',
522
+ 'value' => 'easeInOutQuart'
523
+ ),
524
+ array(
525
+ 'text' => 'Ease-In Quint',
526
+ 'value' => 'easeInQuint'
527
+ ),
528
+ array(
529
+ 'text' => 'Ease-Out Quint',
530
+ 'value' => 'easeOutQuint'
531
+ ),
532
+ array(
533
+ 'text' => 'Ease-In OutQuint',
534
+ 'value' => 'easeInOutQuint'
535
+ ),
536
+ array(
537
+ 'text' => 'Ease-In Sine',
538
+ 'value' => 'easeInSine'
539
+ ),
540
+ array(
541
+ 'text' => 'Ease-Out Sine',
542
+ 'value' => 'easeOutSine'
543
+ ),
544
+ array(
545
+ 'text' => 'Ease-In OutSine',
546
+ 'value' => 'easeInOutSine'
547
+ ),
548
+ array(
549
+ 'text' => 'Ease-In Expo',
550
+ 'value' => 'easeInExpo'
551
+ ),
552
+ array(
553
+ 'text' => 'Ease-Out Expo',
554
+ 'value' => 'easeOutExpo'
555
+ ),
556
+ array(
557
+ 'text' => 'Ease-In OutExpo',
558
+ 'value' => 'easeInOutExpo'
559
+ ),
560
+ array(
561
+ 'text' => 'Ease-In Circ',
562
+ 'value' => 'easeInCirc'
563
+ ),
564
+ array(
565
+ 'text' => 'Ease-Out Circ',
566
+ 'value' => 'easeOutCirc'
567
+ ),
568
+ array(
569
+ 'text' => 'Ease-In OutCirc',
570
+ 'value' => 'easeInOutCirc'
571
+ ),
572
+ array(
573
+ 'text' => 'Ease-In Elastic',
574
+ 'value' => 'easeInElastic'
575
+ ),
576
+ array(
577
+ 'text' => 'Ease-Out Elastic',
578
+ 'value' => 'easeOutElastic'
579
+ ),
580
+ array(
581
+ 'text' => 'Ease-In OutElastic',
582
+ 'value' => 'easeInOutElastic'
583
+ ),
584
+ array(
585
+ 'text' => 'Ease-In Back',
586
+ 'value' => 'easeInBack'
587
+ ),
588
+ array(
589
+ 'text' => 'Ease-Out Back',
590
+ 'value' => 'easeOutBack'
591
+ ),
592
+ array(
593
+ 'text' => 'Ease-In OutBack',
594
+ 'value' => 'easeInOutBack'
595
+ ),
596
+ array(
597
+ 'text' => 'Ease-In Bounce',
598
+ 'value' => 'easeInBounce'
599
+ ),
600
+ array(
601
+ 'text' => 'Ease-Out Bounce',
602
+ 'value' => 'easeOutBounce'
603
+ ),
604
+ array(
605
+ 'text' => 'Ease-In OutBounce',
606
+ 'value' => 'easeInOutBounce'
607
+ )
608
+ );
609
+ }
610
+ }
611
+
src/CycloneSlider/ExportPage.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for export page
4
+ */
5
+ class CycloneSlider_ExportPage {
6
+ protected $plugin;
7
+
8
+ public function run( $plugin ) {
9
+ $this->plugin = $plugin;
10
+
11
+ // Add page
12
+ add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
13
+
14
+ // Post
15
+ add_action('init', array( $this, 'catch_posts') );
16
+ }
17
+
18
+ /**
19
+ * Menu page action hook
20
+ */
21
+ public function add_menu_and_page(){
22
+ // Use built-in WP function
23
+ add_submenu_page(
24
+ $this->plugin['export_page.parent_slug'],
25
+ $this->plugin['export_page.page_title'],
26
+ $this->plugin['export_page.menu_title'],
27
+ $this->plugin['export_page.capability'],
28
+ $this->plugin['export_page.menu_slug'],
29
+ array( $this, 'render_page')
30
+ );
31
+ }
32
+
33
+ public function catch_posts(){
34
+ // Verify nonce
35
+ if( isset($_POST[ $this->plugin['nonce_name'] ]) ){
36
+ $nonce = $_POST[ $this->plugin['nonce_name'] ];
37
+ if ( wp_verify_nonce( $nonce, $this->plugin['nonce_action'] ) ) {
38
+
39
+ if( isset($_POST['cycloneslider_export_step']) ){
40
+ if( $_POST['cycloneslider_export_step'] == 1 ){
41
+ $cyclone_export = array();
42
+ if( isset($_POST['cycloneslider_export']) ){
43
+ if(!empty($_POST['cycloneslider_export'])){
44
+ $cyclone_export = $_POST['cycloneslider_export'];
45
+ update_option('cycloneslider_export', $cyclone_export);
46
+ wp_redirect( get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export&step=2') );
47
+ exit;
48
+ }
49
+ }
50
+ update_option('cycloneslider_export', $cyclone_export);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Render page. This function should output the HTML of the page.
59
+ */
60
+ public function render_page( $post ){
61
+ $current_step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
62
+ if($current_step == 2){
63
+ $this->step_2();
64
+ } else {
65
+ $this->step_1();
66
+ }
67
+ }
68
+
69
+ public function step_1(){
70
+ $cycloneslider_export = get_option('cycloneslider_export');
71
+ $defaults = array(
72
+ 'all' => 0,
73
+ 'sliders' => array()
74
+ );
75
+ $cycloneslider_export = wp_parse_args($cycloneslider_export, $defaults);
76
+
77
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/export-step-1.php' );
78
+ $vars = array();
79
+ $vars['sliders'] = $this->plugin['data']->get_sliders();
80
+ $vars['nonce_name'] = $this->plugin['nonce_name'];
81
+ $vars['nonce'] = wp_create_nonce( $this->plugin['nonce_action'] );
82
+ $vars['cycloneslider_export'] = $cycloneslider_export;
83
+ $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
84
+ $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
85
+ $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
86
+ $this->plugin['view']->set_vars( $vars );
87
+ $this->plugin['view']->render();
88
+
89
+ }
90
+
91
+ public function step_2(){
92
+ $cycloneslider_export = get_option('cycloneslider_export');
93
+ $defaults = array(
94
+ 'all' => 0,
95
+ 'sliders' => array()
96
+ );
97
+ $cycloneslider_export = wp_parse_args($cycloneslider_export, $defaults);
98
+
99
+ $uploads = wp_upload_dir();
100
+ $zip_file = $uploads['basedir'].'/cyclone-slider.zip';
101
+
102
+ $this->plugin['exporter']->export( $zip_file, $cycloneslider_export['sliders'] );
103
+
104
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/export-step-2.php' );
105
+ $vars = array();
106
+ $vars['nonce_name'] = $this->plugin['nonce_name'];
107
+ $vars['nonce'] = wp_create_nonce( $this->plugin['nonce_action'] );
108
+ $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export&step=3' );
109
+ $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
110
+ $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
111
+ $vars['zip_url'] = $uploads['baseurl'].'/cyclone-slider.zip';
112
+ $vars['log_results'] = $this->plugin['exporter']->get_results();
113
+ $this->plugin['view']->set_vars( $vars );
114
+ $this->plugin['view']->render();
115
+ }
116
+ } // end class
src/CycloneSlider/Exporter.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for exporting cyclone-slider.zip
4
+ */
5
+ class CycloneSlider_Exporter {
6
+ protected $log_results; // Hold results of import operations
7
+ protected $log_count;
8
+ protected $plugin;
9
+
10
+ public function run( $plugin ) {
11
+ $this->plugin = $plugin;
12
+
13
+ $this->log_results = array(
14
+ 'oks'=>array(),
15
+ 'errors'=>array()
16
+ );
17
+ $this->log_count = 0;
18
+
19
+ }
20
+
21
+ /**
22
+ * Get log results
23
+ *
24
+ */
25
+ public function get_results(){
26
+ return $this->log_results;
27
+ }
28
+
29
+ /**
30
+ * Export
31
+ *
32
+ * Export main operation
33
+ *
34
+ * @param string $zip_file Full path and filename to zip file
35
+ * @param array $sliders_slugs_array Array of slider slugs to export
36
+ * @return void|false Do export or abort and return false on fail
37
+ */
38
+ public function export( $zip_file, array $sliders_slugs_array ) {
39
+
40
+ // Check selected sliders
41
+ if( empty($sliders_slugs_array) ){
42
+ $this->add_error( 'Error no sliders selected' );
43
+ return false;
44
+ }
45
+
46
+ // Generate sliders export data
47
+ if( ($sliders_export_data = $this->generate_sliders_export_data( $sliders_slugs_array )) === false ){
48
+ $this->add_error( 'Error generating sliders export data' );
49
+ return false;
50
+ }
51
+
52
+ // Generate images lists
53
+ if( ($images_list = $this->generate_images_list( $sliders_slugs_array )) === false ){
54
+ $this->add_error( 'Error generating images list' );
55
+ return false;
56
+ }
57
+
58
+ // Generate images export data
59
+ if( ($images_export_data = $this->generate_images_export_data( $sliders_slugs_array )) === false ){
60
+ $this->add_error( 'Error generating images export data' );
61
+ return false;
62
+ }
63
+
64
+ // Combine
65
+ $export_data = array(
66
+ 'sliders' => $sliders_export_data,
67
+ 'images' => $images_export_data
68
+ );
69
+ $this->add_ok( 'Success generating export data' );
70
+
71
+ // Generate JSON
72
+ if( ($export_json = $this->generate_json_data( $export_data )) === false ){
73
+ $this->add_error( 'Error generating JSON data' );
74
+ return false;
75
+ }
76
+ $this->add_ok( 'Success converting export data to JSON' );
77
+
78
+ // Generate Zip
79
+ if( $this->generate_export_zip( $zip_file, $images_list, $export_json ) === false ){
80
+ $this->add_error( 'Error generating zip file' );
81
+ return false;
82
+ }
83
+ $this->add_ok( 'Success generating zip file' );
84
+
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Generate Sliders Export Data
90
+ *
91
+ * Generate export data array for selected sliders. Include slider settings and slides
92
+ *
93
+ * @param array $sliders_slugs_array Array of slider slugs to export
94
+ * @return array|false Export data array or false on fail
95
+ */
96
+ private function generate_sliders_export_data( array $sliders_slugs_array ) {
97
+
98
+ if( !empty( $sliders_slugs_array ) ){
99
+ $sliders_export_data = array();
100
+ foreach( $sliders_slugs_array as $i=>$slider_slug){
101
+
102
+ $slider = $this->plugin['data']->get_slider_by_slug( $slider_slug );
103
+
104
+ if($slider){
105
+ $sliders_export_data[$i] = array(
106
+ 'title' => $slider['post_title'],
107
+ 'name' => $slider['post_name'],
108
+ 'slider_settings' => $slider['slider_settings'],
109
+ 'slides' => $slider['slides']
110
+ );
111
+ $this->add_ok( sprintf('Exporting data for slider "%s"', $slider_slug) );
112
+ } else {
113
+ $this->add_error( sprintf('Slider "%s" not found', $slider_slug) );
114
+ }
115
+
116
+ }
117
+ return $sliders_export_data;
118
+ }
119
+
120
+ return false;
121
+ }
122
+
123
+ /**
124
+ * Generate Images List
125
+ *
126
+ * Generate image array for slider images
127
+ *
128
+ * @param array $sliders_slugs_array Array of slider slugs to export
129
+ * @return array|false Export data array or false on fail
130
+ */
131
+ private function generate_images_list( array $sliders_slugs_array ) {
132
+
133
+ if( !empty( $sliders_slugs_array ) ){
134
+
135
+ $images_list = array();
136
+
137
+ foreach( $sliders_slugs_array as $slider_slug){
138
+ $slider = $this->plugin['data']->get_slider_by_slug( $slider_slug );
139
+ if($slider){
140
+ if(isset($slider['slides'])){
141
+ foreach($slider['slides'] as $i=>$slide){
142
+ $images_list[$slider['post_name']][$i] = get_attached_file( $slide['id'] ); // Filename of image
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ return $images_list;
149
+ }
150
+
151
+ return false;
152
+ }
153
+
154
+ /**
155
+ * Generate Images Export Data
156
+ *
157
+ * Generate export data array for slider images
158
+ *
159
+ * @param array $sliders_slugs_array Array of slider slugs to export
160
+ * @return array|false Export data array or false on fail
161
+ */
162
+ private function generate_images_export_data( array $sliders_slugs_array ) {
163
+
164
+ if( !empty( $sliders_slugs_array ) ){
165
+ $images_export_data = array();
166
+ foreach( $sliders_slugs_array as $slider_slug){
167
+
168
+ $slider = $this->plugin['data']->get_slider_by_slug( $slider_slug );
169
+
170
+ if($slider){
171
+ if(isset($slider['slides'])){
172
+ foreach($slider['slides'] as $i=>$slide){
173
+ $images_export_data[$slider['post_name']][$i] = sanitize_file_name( wp_basename( get_attached_file( $slide['id'] ) ) ); // Filename of image
174
+ }
175
+ }
176
+ }
177
+ }
178
+ return $images_export_data;
179
+ }
180
+
181
+ return false;
182
+ }
183
+
184
+ /**
185
+ * Generate JSON Data
186
+ *
187
+ * Generate json data
188
+ *
189
+ * @param array $export_data Array of export data
190
+ * @return string|false JSON data or false on fail
191
+ */
192
+ private function generate_json_data( array $export_data ) {
193
+
194
+ if($export_data){
195
+ // JSON encode
196
+ if( $export_json = json_encode($export_data) ){
197
+ return $export_json;
198
+ }
199
+ }
200
+
201
+ return false;
202
+ }
203
+
204
+ /**
205
+ * Generate Export Zip
206
+ *
207
+ * Generate export zip. Add images and export.json
208
+ *
209
+ * @param string $zip_file Zip file to save
210
+ * @param array $images_list Array of image file paths to include in the zip
211
+ * @param string $export_json JSON string to save
212
+ * @return string|false JSON data or false on fail
213
+ */
214
+ private function generate_export_zip( $zip_file, array $images_list, $export_json ) {
215
+
216
+ if( !class_exists('ZipArchive') ) {
217
+ $this->add_error( 'ZipArchive not supported' );
218
+ return false;
219
+ }
220
+ $zip = new ZipArchive();
221
+
222
+ if ($zip->open($zip_file, ZIPARCHIVE::OVERWRITE)!==TRUE) {
223
+ $this->add_error( 'Error opening zip file' );
224
+ return false;
225
+ }
226
+
227
+ // Add slide images
228
+ foreach($images_list as $a=>$sliders) {
229
+ foreach($sliders as $b=>$image_file){
230
+ if(!empty($image_file)){ // Non image slides
231
+ $filename = sanitize_file_name( wp_basename( $image_file ) );
232
+ if( $zip->addFile( $image_file, $filename ) === false ){
233
+ $this->add_error( sprintf( 'Error adding file %s to zip', $filename ) );
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ // Add json file
240
+ $zip->addFromString("export.json", $export_json );
241
+
242
+ $zip->close();
243
+ return $zip_file;
244
+ }
245
+
246
+
247
+
248
+ /**
249
+ * Add Ok
250
+ *
251
+ * @param string $message Message to add
252
+ * @return void
253
+ */
254
+ private function add_ok( $message ){
255
+ $this->log_results['oks'][$this->log_count++] = $message;
256
+ }
257
+
258
+ /**
259
+ * Add Error
260
+ *
261
+ * @param string $message Message to add
262
+ * @return void
263
+ */
264
+ private function add_error( $message ){
265
+ $this->log_results['errors'][$this->log_count++] = $message;
266
+ }
267
+ }
src/CycloneSlider/Frontend.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CycloneSlider_Frontend extends CycloneSlider_Base {
3
+ public $slider_count;
4
+
5
+ public function bootstrap() {
6
+
7
+ // Set defaults
8
+ $this->slider_count = 0;
9
+
10
+ // Our shortcode
11
+ add_shortcode('cycloneslider', array( $this, 'cycloneslider_shortcode') );
12
+
13
+ }
14
+
15
+ /**
16
+ * Cycloneslider Shortcode
17
+ *
18
+ * Displays shortcode on pages
19
+ *
20
+ * @param array $shortcode_settings Array of shortcode parameters
21
+ * @return string Slider HTML
22
+ */
23
+ public function cycloneslider_shortcode( $shortcode_settings ) {
24
+
25
+ $shortcode_settings = shortcode_atts(
26
+ array(
27
+ 'id' => 0,
28
+ 'easing' => null,
29
+ 'fx' => null,
30
+ 'timeout' => null,
31
+ 'speed' => null,
32
+ 'width' => null,
33
+ 'height' => null,
34
+ 'hover_pause' => null,
35
+ 'show_prev_next' => null,
36
+ 'show_nav' => null,
37
+ 'tile_count' => null,
38
+ 'tile_delay' => null,
39
+ 'tile_vertical' => null,
40
+ 'random' => null,
41
+ 'resize' => null,
42
+ 'resize_option' => null,
43
+ 'easing' => null,
44
+ 'allow_wrap' => null,
45
+ 'dynamic_height' => null,
46
+ 'delay' => null,
47
+ 'swipe' => null,
48
+ 'width_management' => null
49
+ ),
50
+ $shortcode_settings,
51
+ 'cycloneslider'
52
+ );
53
+
54
+ $slider_slug = $shortcode_settings['id']; // Slideshow slug passed from shortcode
55
+
56
+ $slider_count = ++$this->slider_count; // Make each call to shortcode unique
57
+
58
+ $slider_html_id = 'cycloneslider-'.$slider_slug.'-'.$slider_count; // UID
59
+
60
+ $slider = $this->plugin['data']->get_slider_by_slug( $slider_slug ); // Get slider by slug
61
+
62
+ // Abort if slider not found!
63
+ if( $slider === false ){
64
+ return sprintf(__('[Slideshow "%s" not found]', 'cycloneslider'), $slider_slug);
65
+ }
66
+
67
+ // Assign important variables
68
+ $slider_settings = $slider['slider_settings']; // Assign slider settings
69
+ $slides = $slider['slides']; // Assign slides
70
+
71
+ $template_name = $slider_settings['template'];
72
+ $view_file = $this->get_view_file( $template_name );
73
+
74
+ // Abort if template not found!
75
+ if( $view_file === false ){
76
+ return sprintf(__('[Template "%s" not found]', 'cycloneslider'), $template_name);
77
+ }
78
+
79
+ // Use shortcode settings if present and override admin settings
80
+ if( null !== $shortcode_settings['fx'] ){
81
+ $slider_settings['fx'] = $shortcode_settings['fx'];
82
+ }
83
+ if( null !== $shortcode_settings['timeout'] ){
84
+ $slider_settings['timeout'] = $shortcode_settings['timeout'];
85
+ }
86
+ if( null !== $shortcode_settings['speed'] ){
87
+ $slider_settings['speed'] = $shortcode_settings['speed'];
88
+ }
89
+ if( null !== $shortcode_settings['width'] ){
90
+ $slider_settings['width'] = $shortcode_settings['width'];
91
+ }
92
+ if( null !== $shortcode_settings['height'] ){
93
+ $slider_settings['height'] = $shortcode_settings['height'];
94
+ }
95
+ if( null !== $shortcode_settings['hover_pause'] ){
96
+ $slider_settings['hover_pause'] = $shortcode_settings['hover_pause'];
97
+ }
98
+ if( null !== $shortcode_settings['show_prev_next'] ){
99
+ $slider_settings['show_prev_next'] = $shortcode_settings['show_prev_next'];
100
+ }
101
+ if( null !== $shortcode_settings['show_nav'] ){
102
+ $slider_settings['show_nav'] = $shortcode_settings['show_nav'];
103
+ }
104
+ if( null !== $shortcode_settings['tile_count'] ){
105
+ $slider_settings['tile_count'] = $shortcode_settings['tile_count'];
106
+ }
107
+ if( null !== $shortcode_settings['tile_delay'] ){
108
+ $slider_settings['tile_delay'] = $shortcode_settings['tile_delay'];
109
+ }
110
+ if( null !== $shortcode_settings['tile_vertical'] ){
111
+ $slider_settings['tile_vertical'] = $shortcode_settings['tile_vertical'];
112
+ }
113
+ if( null !== $shortcode_settings['random'] ){
114
+ $slider_settings['random'] = $shortcode_settings['random'];
115
+ }
116
+ if( null !== $shortcode_settings['resize'] ){
117
+ $slider_settings['resize'] = $shortcode_settings['resize'];
118
+ }
119
+ if( null !== $shortcode_settings['resize_option'] ){
120
+ $slider_settings['resize_option'] = $shortcode_settings['resize_option'];
121
+ }
122
+ if( null !== $shortcode_settings['easing'] ){
123
+ $slider_settings['easing'] = $shortcode_settings['easing'];
124
+ }
125
+ if( null !== $shortcode_settings['allow_wrap'] ){
126
+ $slider_settings['allow_wrap'] = $shortcode_settings['allow_wrap'];
127
+ }
128
+ if( null !== $shortcode_settings['dynamic_height'] ){
129
+ $slider_settings['dynamic_height'] = $shortcode_settings['dynamic_height'];
130
+ }
131
+ if( null !== $shortcode_settings['delay'] ){
132
+ $slider_settings['delay'] = $shortcode_settings['delay'];
133
+ }
134
+ if( null !== $shortcode_settings['swipe'] ){
135
+ $slider_settings['swipe'] = $shortcode_settings['swipe'];
136
+ }
137
+ if( null !== $shortcode_settings['width_management'] ){
138
+ $slider_settings['width_management'] = $shortcode_settings['width_management'];
139
+ }
140
+
141
+ $image_count = 0; // Number of image slides
142
+ $video_count = 0; // Number of video slides
143
+ $custom_count = 0; // Number of custom slides
144
+ $youtube_count = 0; // Number of youtube slides
145
+ $vimeo_count = 0; // Number of Vimeo slides
146
+
147
+ // Do some last minute logic
148
+ // Translations and counters
149
+ foreach($slides as $i=>$slide){
150
+ $slides[$i]['title'] = __($slide['title']);
151
+ $slides[$i]['description'] = __($slide['description']);
152
+ if($slides[$i]['type']=='image'){
153
+
154
+ list($full_image_url, $orig_width, $orig_height) = wp_get_attachment_image_src($slide['id'], 'full');
155
+
156
+ $slides[$i]['full_image_url'] = $full_image_url;
157
+ $slides[$i]['image_url'] = $this->plugin['data']->get_slide_image_url( $slide['id'], $slider_settings );
158
+
159
+ $image_count++;
160
+ } else if($slides[$i]['type']=='video'){
161
+ $video_count++;
162
+ } else if($slides[$i]['type']=='custom'){
163
+ $custom_count++;
164
+ } else if($slides[$i]['type']=='youtube'){
165
+ $youtube_count++;
166
+ $youtube_id = $this->plugin['youtube']->get_youtube_id($slides[$i]['youtube_url']);
167
+
168
+ $youtube_related = '';
169
+ if( 'true' == $slides[$i]['youtube_related'] ) {
170
+ $youtube_related = '&rel=0';
171
+ }
172
+
173
+ $slides[$i]['youtube_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="//www.youtube.com/embed/'.$youtube_id.'?wmode=transparent'.$youtube_related.'" frameborder="0" allowfullscreen></iframe>';
174
+ $slides[$i]['youtube_id'] = $youtube_id;
175
+ $slides[$i]['thumbnail_small'] = $this->plugin['youtube']->get_youtube_thumb($youtube_id);
176
+
177
+ } else if($slides[$i]['type']=='vimeo'){
178
+ $vimeo_count++;
179
+ $vimeo_id = $this->plugin['vimeo']->get_vimeo_id($slides[$i]['vimeo_url']);
180
+
181
+ $slides[$i]['vimeo_embed_code'] = '<iframe id="'.$slider_html_id.'-iframe-'.$i.'" width="'.$slider_settings['width'].'" height="'.$slider_settings['height'].'" src="http://player.vimeo.com/video/'.$vimeo_id.'?api=1&wmode=transparent" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
182
+ $slides[$i]['vimeo_id'] = $vimeo_id;
183
+ $slides[$i]['thumbnail_small'] = $this->plugin['vimeo']->get_vimeo_thumb($vimeo_id);
184
+ }
185
+ }
186
+
187
+ // Randomize slides
188
+ if($slider_settings['random']){
189
+ shuffle($slides);
190
+ }
191
+
192
+ // Assign view file
193
+ $this->plugin['view']->set_view_file( $view_file );
194
+
195
+ // Hardcoded for now
196
+ $slider_settings['hide_non_active'] = "true";
197
+ $slider_settings['auto_height'] = "{$slider_settings['width']}:{$slider_settings['height']}"; // Use ratio for backward compat
198
+ if( 'on' == $slider_settings['dynamic_height'] ) {
199
+ $slider_settings['auto_height'] = 0; // Disable autoheight when dynamic height is on. To prevent slider returning to wrong (ratio height) height when browser is resized.
200
+ }
201
+ if( ($youtube_count+$vimeo_count) > 0 or 'on' == $slider_settings['dynamic_height'] ){
202
+ $slider_settings['hide_non_active'] = "false"; // Do not hide non active slides to prevent reloading of videos and for getBoundingClientRect() to not return 0.
203
+ }
204
+ $slider_settings['auto_height_speed'] = 250; // Will be editable in admin in the future
205
+ $slider_settings['auto_height_easing'] = "null"; // Will be editable in admin in the future
206
+
207
+ // Pass this vars to template
208
+ $vars = array();
209
+ $vars['slider_html_id'] = $slider_html_id; // The unique HTML ID for slider
210
+ $vars['slider_count'] = $slider_count;
211
+ $vars['slides'] = $slides;
212
+ $vars['image_count'] = $image_count;
213
+ $vars['video_count'] = $video_count;
214
+ $vars['custom_count'] = $custom_count;
215
+ $vars['youtube_count'] = $youtube_count;
216
+ $vars['slider_id'] = $slider_slug; // (Deprecated since 2.6.0, use $slider_html_id instead) Unique string to identify the slideshow.
217
+ $vars['slider_metas'] = $slides; // (Deprecated since 2.5.5, use $slides instead) An array containing slides properties.
218
+ $vars['slider_settings'] = $slider_settings;
219
+
220
+ $this->plugin['view']->set_vars( $vars );
221
+ $slider_html = $this->plugin['view']->get_render();
222
+
223
+ // Remove whitespace to prevent WP from adding rogue paragraphs
224
+ $slider_html = $this->trim_white_spaces( $slider_html );
225
+
226
+ // Return HTML
227
+ return $slider_html;
228
+ }
229
+
230
+ /**
231
+ * Trim White Spaces
232
+ *
233
+ */
234
+ public function trim_white_spaces($buffer, $off=false){
235
+ if($off){
236
+ return $buffer;
237
+ }
238
+ $search = array(
239
+ '/\>[^\S ]+/s', //strip whitespaces after tags, except space
240
+ '/[^\S ]+\</s', //strip whitespaces before tags, except space
241
+ '/(\s)+/s' // shorten multiple whitespace sequences
242
+ );
243
+ $replace = array(
244
+ '>',
245
+ '<',
246
+ '\\1'
247
+ );
248
+ return preg_replace($search, $replace, $buffer);
249
+ }
250
+
251
+ /**
252
+ * Get View File
253
+ *
254
+ * Get slider view file from theme or plugin location
255
+ *
256
+ * @param string $template_name Name of slider template
257
+ * @return string|false Slider view filepath or false
258
+ */
259
+ public function get_view_file( $template_name ){
260
+
261
+ $template_locations = $this->plugin['templates_manager']->get_template_locations();
262
+ $template_locations = array_reverse($template_locations); // Last added template locations are checked first
263
+ foreach($template_locations as $template_location){
264
+ $view_file = $template_location['path']."{$template_name}/slider.php";
265
+ if(@is_file($view_file)){
266
+ return $view_file;
267
+ }
268
+ }
269
+
270
+ return false;
271
+ }
272
+ } // end class
src/CycloneSlider/ImageEditor.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for editing images. Each instance handles a single file.
4
+ */
5
+ class CycloneSlider_ImageEditor {
6
+ protected $file = ''; // Image file
7
+ protected $quality = 90; // JPEG quality
8
+ protected $image = false; // GD resource of image
9
+ protected $width; // Image width
10
+ protected $height; // Image height
11
+ protected $size; // Array holding width and height of image
12
+
13
+ // Resize constants
14
+ const RESIZE_EXACT = 'exact';
15
+ const RESIZE_PORTRAIT = 'portrait';
16
+ const RESIZE_LANDSCAPE = 'landscape';
17
+ const RESIZE_CROP = 'crop';
18
+
19
+ /**
20
+ * Assign file
21
+ */
22
+ public function __construct( $file ) {
23
+
24
+ $this->file = $file;
25
+
26
+ }
27
+
28
+ public function __destruct() {
29
+ if ( $this->image ) {
30
+ // Free memory
31
+ imagedestroy( $this->image );
32
+ }
33
+ }
34
+
35
+ private function _get_file_ext( $file ){
36
+ // Get extension
37
+ $path_parts = pathinfo( $file );
38
+
39
+ if( ! isset( $path_parts['extension'] ) )
40
+ return false;
41
+
42
+ if( $path_parts['extension'] == '' )
43
+ return false;
44
+
45
+ return strtolower( $path_parts['extension'] );
46
+ }
47
+
48
+ /**
49
+ * Loads image resource from file
50
+ *
51
+ * @return resource|boolean GD resource on success; False on fail
52
+ */
53
+ public function load(){
54
+
55
+ if ( ! is_file( $this->file ) )
56
+ return false;
57
+
58
+ // Get extension
59
+ $extension = $this->_get_file_ext( $this->file );
60
+
61
+ if( ! $extension )
62
+ return false;
63
+
64
+ if( $extension == 'jpg' or $extension == 'jpeg' ){
65
+ $this->image = @imagecreatefromjpeg( $this->file );
66
+
67
+ } else if( $extension == 'gif' ){
68
+ $this->image = @imagecreatefromgif( $this->file );
69
+
70
+ } else if( $extension == 'png' ){
71
+ $this->image = @imagecreatefrompng( $this->file );
72
+
73
+ }
74
+
75
+ if ( ! is_resource( $this->image ) )
76
+ return false;
77
+
78
+ $this->update_size();
79
+
80
+ return true;
81
+ }
82
+
83
+ /**
84
+ * Sets or updates current image size.
85
+ *
86
+ * @param int $width
87
+ * @param int $height
88
+ */
89
+ protected function update_size( $width = false, $height = false ) {
90
+ if ( ! $width )
91
+ $width = imagesx( $this->image );
92
+
93
+ if ( ! $height )
94
+ $height = imagesy( $this->image );
95
+
96
+ $this->size = array(
97
+ 'width' => (int) $width,
98
+ 'height' => (int) $height
99
+ );
100
+ return true;
101
+ }
102
+
103
+ /**
104
+ * Resize
105
+ *
106
+ * @param int $new_width
107
+ * @param int $new_height
108
+ * @param string $resize_option
109
+ * @return void
110
+ */
111
+ public function resize( $new_width, $new_height, $resize_option="auto") {
112
+ // Get current width and height
113
+ list($orig_width, $orig_height) = array_values($this->size);
114
+
115
+ // Get optimal width and height - based on $resize_option
116
+ list($optimal_width, $optimal_height) = $this->get_optimal_dimension( $orig_width, $orig_height, $new_width, $new_height, $resize_option );
117
+
118
+ // Resample - create image canvas of x, y size
119
+ $image_resized = imagecreatetruecolor($optimal_width, $optimal_height);
120
+ // Preserve PNG transparency start
121
+ imagealphablending($image_resized, false);
122
+ imagesavealpha($image_resized, true);
123
+ $transparent = imagecolorallocatealpha($image_resized, 255, 255, 255, 127);
124
+ imagefilledrectangle($image_resized, 0, 0, $optimal_width, $optimal_height, $transparent);
125
+ // Preserve PNG transparency end
126
+ imagecopyresampled($image_resized, $this->image, 0, 0, 0, 0, $optimal_width, $optimal_height, $orig_width, $orig_height);
127
+
128
+ // Free memory
129
+ imagedestroy( $this->image );
130
+
131
+ // Assign
132
+ $this->image = $image_resized;
133
+ $this->update_size();
134
+
135
+ // If option is 'crop', then crop too
136
+ if ($resize_option == self::RESIZE_CROP) {
137
+ $this->crop($optimal_width, $optimal_height, $new_width, $new_height);
138
+ }
139
+ }
140
+
141
+ /**
142
+ * Crop
143
+ *
144
+ * @param int $optimal_width
145
+ * @param int $optimal_height
146
+ * @param int $new_width
147
+ * @param int $new_height
148
+ * @param string $resize_option
149
+ * @return void
150
+ */
151
+ public function crop($optimal_width, $optimal_height, $new_width, $new_height) {
152
+ // Find center - this will be used for the crop
153
+ $crop_start_x = ( $optimal_width / 2) - ( $new_width /2 );
154
+ $crop_start_y = ( $optimal_height/ 2) - ( $new_height/2 );
155
+
156
+ // Now crop from center to exact requested size
157
+ $image_resized = imagecreatetruecolor($new_width , $new_height);
158
+ imagecopyresampled($image_resized, $this->image , 0, 0, $crop_start_x, $crop_start_y, $new_width, $new_height , $new_width, $new_height);
159
+
160
+ // Free memory
161
+ imagedestroy( $this->image );
162
+
163
+ // Assign
164
+ $this->image = $image_resized;
165
+ $this->update_size();
166
+ }
167
+
168
+ /**
169
+ * Save
170
+ */
171
+ public function save($filename, $image_quality="100") {
172
+ // Get extension
173
+ $extension = $this->_get_file_ext( $filename );
174
+
175
+ switch($extension) {
176
+ case 'jpg':
177
+ case 'jpeg':
178
+ if (imagetypes() & IMG_JPG) {
179
+ imagejpeg($this->image, $filename, $image_quality);
180
+ }
181
+ break;
182
+
183
+ case 'gif':
184
+ if (imagetypes() & IMG_GIF) {
185
+ imagegif($this->image, $filename);
186
+ }
187
+ break;
188
+
189
+ case 'png':
190
+ // Scale quality from 0-100 to 0-9
191
+ $scale_quality = round(($image_quality/100) * 9);
192
+
193
+ // Invert quality setting as 0 is best, not 9
194
+ $invert_scale_quality = 9 - $scale_quality;
195
+
196
+ if (imagetypes() & IMG_PNG) {
197
+ imagepng($this->image, $filename, $invert_scale_quality);
198
+ }
199
+ break;
200
+
201
+ default:
202
+ // No extension - No save.
203
+ break;
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Get Optimal Dimension
209
+ *
210
+ * Computes the best possible width and height when resizing an image
211
+ *
212
+ * @param int $orig_width
213
+ * @param int $orig_height
214
+ * @param int $new_width
215
+ * @param int $new_height
216
+ * @param string $resize_option
217
+ *
218
+ * @return array Array containing width and height
219
+ */
220
+ public function get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, $resize_option='auto') {
221
+
222
+ if($resize_option == self::RESIZE_EXACT){
223
+
224
+ $optimal_width = $new_width;
225
+ $optimal_height = $new_height;
226
+
227
+ } else if($resize_option== self::RESIZE_PORTRAIT ){ // Prefer height, compute width
228
+
229
+ $ratio = $orig_width / $orig_height;
230
+
231
+ $optimal_width = $new_height * $ratio;
232
+ $optimal_height= $new_height;
233
+
234
+ } else if($resize_option== self::RESIZE_LANDSCAPE){ // Prefer width
235
+
236
+ $ratio = $orig_height / $orig_width;
237
+
238
+ $optimal_width = $new_width;
239
+ $optimal_height = $new_width * $ratio;
240
+
241
+ } else if($resize_option== self::RESIZE_CROP){ // Crop
242
+
243
+ $height_ratio = $orig_height / $new_height;
244
+ $width_ratio = $orig_width / $new_width;
245
+
246
+ if ($height_ratio < $width_ratio) {
247
+ $optimal_ratio = $height_ratio;
248
+ } else {
249
+ $optimal_ratio = $width_ratio;
250
+ }
251
+
252
+ $optimal_width = $orig_width / $optimal_ratio;
253
+ $optimal_height = $orig_height / $optimal_ratio;
254
+
255
+
256
+ } else { // Auto
257
+ if ($orig_height < $orig_width) { // Image to be resized is wider (landscape)
258
+
259
+ list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'landscape');
260
+
261
+ } elseif ($orig_height > $orig_width) { // Image to be resized is taller (portrait)
262
+
263
+ list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'portrait');
264
+
265
+ } else { // Image to be resized as a square
266
+ if ($new_height < $new_width) { // Image to be resized is wider (landscape)
267
+
268
+ list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'landscape');
269
+
270
+ } else if ($new_height > $new_width) {
271
+
272
+ list($optimal_width, $optimal_height) = $this->get_optimal_dimension($orig_width, $orig_height, $new_width, $new_height, 'portrait');
273
+
274
+ } else { // Square being resized to a square
275
+ $optimal_width = $new_width;
276
+ $optimal_height= $new_height;
277
+ }
278
+ }
279
+ }
280
+
281
+ return array( $optimal_width, $optimal_height );
282
+ }
283
+ }
src/CycloneSlider/ImageResizer.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for copying WP images for import/export purposes and resizing slide images
4
+ */
5
+ class CycloneSlider_ImageResizer {
6
+
7
+ /**
8
+ * Resize Images
9
+ *
10
+ * API to resize slide images
11
+ *
12
+ * @param int $slider_id Slider post ID
13
+ * @param array $slides Slides array
14
+ * @return void
15
+ */
16
+ public function resize_images( $slider_settings, $slides ){
17
+
18
+ // Prevent fatal error on users without GD installed
19
+ if(!function_exists('gd_info')){
20
+ return false;
21
+ }
22
+
23
+ $slider_settings['resize_quality'] = 90;
24
+ $width = $slider_settings['width'];
25
+ $height = $slider_settings['height'];
26
+
27
+ if( is_array($slides) ){
28
+
29
+ foreach($slides as $slide){
30
+ // Get full path to the slide image
31
+ $image_file = get_attached_file( $slide['id'] );
32
+
33
+ // Extract image path info
34
+ $info = pathinfo($image_file);
35
+ $dirname = isset($info['dirname']) ? $info['dirname'] : ''; // Path to directory
36
+
37
+ // Create thumb filename-{width}x{height}.jpg
38
+ $thumb_name = $this->generate_thumb_name( $image_file, $width, $height );
39
+
40
+ // Save image to this file
41
+ $image_file_dest = "{$dirname}/{$thumb_name}";
42
+
43
+ if( ! is_file( $image_file_dest ) ) { // Destination file does not exist
44
+ //echo "fresh {$image_file_dest} <br>";
45
+ $this->resize( $image_file, $image_file_dest, $width, $height, $slider_settings );
46
+
47
+ } else if( is_file( $image_file_dest ) and $slider_settings['force_resize'] ) { // Exist but force resize so we resave it
48
+ //echo "REfreshed {$image_file_dest} <br>";
49
+ $this->resize( $image_file, $image_file_dest, $width, $height, $slider_settings );
50
+
51
+ }
52
+ }
53
+ //exit;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Resize Image
59
+ *
60
+ * @param string $image_file
61
+ * @param string $image_file_dest
62
+ * @param int $width
63
+ * @param int $height
64
+ * @param array $slider_settings
65
+ * @return boolean True or false
66
+ */
67
+ private function resize($image_file, $image_file_dest, $width, $height, $slider_settings){
68
+ // Create
69
+ $image = new CycloneSlider_ImageEditor( $image_file );
70
+
71
+ // Load
72
+ if( $image->load() ){
73
+
74
+ // Do resize
75
+ $image->resize( $width, $height, $slider_settings['resize_option'] );
76
+ $image->save( $image_file_dest, $slider_settings['resize_quality']);
77
+
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+
83
+ /**
84
+ * Generate Thumb Name
85
+ *
86
+ * @param string $image_file
87
+ * @param int $width
88
+ * @param int $height
89
+ * @return string
90
+ */
91
+ public function generate_thumb_name( $image_file, $width, $height ){
92
+
93
+ // Get image path info and create file name
94
+ $info = pathinfo( $image_file ); // Eg: d:/uploads/image-1.jpg
95
+ if( !isset($info['extension']) or !isset($info['filename'])){
96
+ return false;
97
+ }
98
+
99
+ $ext = $info['extension']; // File extension Eg. "jpg"
100
+ $filename = $info['filename']; // Filename Eg. "image-1"
101
+ return "{$filename}-{$width}x{$height}.{$ext}"; // Thumbname. Eg. "image-1-600x300.jpg"
102
+
103
+ }
104
+ }
src/CycloneSlider/ImportPage.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for import page
4
+ */
5
+ class CycloneSlider_ImportPage {
6
+ protected $plugin;
7
+
8
+ public function run( $plugin ) {
9
+ $this->plugin = $plugin;
10
+
11
+ // Add page
12
+ add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
13
+
14
+ // Post
15
+ add_action('init', array( $this, 'catch_posts') );
16
+ }
17
+
18
+ /**
19
+ * Menu page action hook
20
+ */
21
+ public function add_menu_and_page(){
22
+ // Use built-in WP function
23
+ add_submenu_page(
24
+ $this->plugin['import_page.parent_slug'],
25
+ $this->plugin['import_page.page_title'],
26
+ $this->plugin['import_page.menu_title'],
27
+ $this->plugin['import_page.capability'],
28
+ $this->plugin['import_page.menu_slug'],
29
+ array( $this, 'render_page')
30
+ );
31
+ }
32
+
33
+ public function catch_posts(){
34
+ // Verify nonce
35
+ if( isset($_POST[ $this->plugin['nonce_name'] ]) ){
36
+ $nonce = $_POST[ $this->plugin['nonce_name'] ];
37
+ if ( wp_verify_nonce( $nonce, $this->plugin['nonce_action']) ) {
38
+ $uploads = wp_upload_dir(); // Get dir
39
+ if( isset($_POST['cycloneslider_import_step']) ){
40
+ if( $_POST['cycloneslider_import_step'] == 1 ){
41
+ $cyclone_import = array();
42
+
43
+ // Success
44
+ if( $this->plugin['importer']->import( $_FILES['cycloneslider_import']['tmp_name'], $uploads['basedir'].'/cyclone-slider' ) ){
45
+ $cyclone_import = $this->plugin['importer']->get_results();
46
+ update_option('cycloneslider_import', $cyclone_import);
47
+ wp_redirect( get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import&step=2') );
48
+ exit;
49
+ } else { // Fail
50
+
51
+ }
52
+ }
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Render page. This function should output the HTML of the page.
60
+ */
61
+ public function render_page( $post ){
62
+ $current_step = isset($_GET['step']) ? (int) $_GET['step'] : 1;
63
+ if($current_step == 2){
64
+ $this->step_2();
65
+ } else {
66
+ $this->step_1();
67
+ }
68
+
69
+ }
70
+
71
+ public function step_1(){
72
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/import-step-1.php' );
73
+ $vars = array();
74
+ $vars['nonce_name'] = $this->plugin['nonce_name'];
75
+ $vars['nonce'] = wp_create_nonce( $this->plugin['nonce_action'] );
76
+ $vars['form_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
77
+ $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
78
+ $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
79
+ $this->plugin['view']->set_vars( $vars );
80
+ $this->plugin['view']->render();
81
+
82
+ }
83
+ public function step_2(){
84
+ $log_results = get_option('cycloneslider_import');
85
+ $defaults = array(
86
+ 'oks'=>array(),
87
+ 'errors'=>array()
88
+ );
89
+ $log_results = wp_parse_args($log_results, $defaults);
90
+ delete_option('cycloneslider_import');
91
+
92
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/import-step-2.php' );
93
+ $vars = array();
94
+ $vars['log_results'] = $log_results;
95
+ $vars['export_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-export' );
96
+ $vars['import_page_url'] = get_admin_url( get_current_blog_id(), 'edit.php?post_type=cycloneslider&page=cycloneslider-import' );
97
+ $this->plugin['view']->set_vars( $vars );
98
+ $this->plugin['view']->render();
99
+
100
+ }
101
+
102
+ } // end class
src/CycloneSlider/Importer.php ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class for importing cyclone-slider.zip
5
+ */
6
+ class CycloneSlider_Importer {
7
+ protected $log_results; // Hold results of import operations
8
+ protected $log_count;
9
+ protected $plugin;
10
+
11
+ public function run( $plugin ) {
12
+ $this->plugin = $plugin;
13
+
14
+ $this->log_results = array(
15
+ 'oks'=>array(),
16
+ 'errors'=>array()
17
+ );
18
+ $this->log_count = 0;
19
+
20
+ }
21
+
22
+ /**
23
+ * Get log results
24
+ *
25
+ */
26
+ public function get_results(){
27
+ return $this->log_results;
28
+ }
29
+
30
+ /**
31
+ * Import zip file
32
+ *
33
+ * @param filename $zip_file. Full path and filename to zip file
34
+ * @param string $dir. Path to folder to extract the zip
35
+ */
36
+ public function import( $zip_file, $target_dir ) {
37
+ // Check zip existence
38
+ if( !file_exists($zip_file) ){
39
+ $this->add_error('Zip file not found.');
40
+ return false;
41
+ }
42
+
43
+ // Check zip support
44
+ if( !class_exists('ZipArchive') ){
45
+ $this->add_error('ZipArchive not supported.');
46
+ return false;
47
+ }
48
+
49
+ // Check zip
50
+ if( !$this->check_integrity( $zip_file ) ){
51
+ return false;
52
+ }
53
+
54
+ // Remove old tmp folder if present
55
+ if ( file_exists($target_dir) and is_dir($target_dir)) {
56
+ if( $this->rmdir_recursive($target_dir)=== false ){
57
+ $this->add_error('Failed to remove the temporary extract folder.');
58
+ return false;
59
+ } else {
60
+ $this->add_ok('Removed the temporary extract folder.');
61
+ }
62
+ }
63
+
64
+ // Create tmp folder to hold extracted files
65
+ if(mkdir($target_dir)===false){
66
+ $this->add_error('Failed to create the temporary extract folder.');
67
+ return false;
68
+ } else {
69
+ $this->add_ok('Created the temporary extract folder.');
70
+ }
71
+
72
+ // Extract zip
73
+ $zip = new ZipArchive;
74
+ $zip->open($zip_file);
75
+ if( $zip->extractTo($target_dir) === false ){
76
+ $this->add_error('Failed to extract zip contents.');
77
+ return false;
78
+ } else {
79
+ $this->add_ok('Extracted zip contents.');
80
+ }
81
+ $zip->close();
82
+
83
+ // Read export JSON
84
+ if( ($export_string = file_get_contents($target_dir.'/export.json')) === false ){
85
+ $this->add_error('Failed to read export JSON.');
86
+ return false;
87
+ } else {
88
+ $this->add_ok('Success reading export file.');
89
+ }
90
+
91
+ // Decode JSON
92
+ if( ($export_data = json_decode($export_string, true)) == false ) {
93
+ $this->add_error('Failed to decode JSON');
94
+ return false;
95
+ }
96
+ $this->add_ok('Success decoding JSON');
97
+
98
+ // Add images
99
+ if( ($images_list = $this->add_images( $export_data['images'] )) === false){
100
+ $this->add_error('Failed to add images');
101
+ return false;
102
+ }
103
+ $this->add_ok('Success importing images');
104
+
105
+ // Add sliders
106
+ if( ($sliders_list = $this->add_sliders( $export_data['sliders'], $images_list ) ) === false){
107
+ $this->add_error('Failed to add sliders');
108
+ return false;
109
+ }
110
+ $this->add_ok('Success importing sliders');
111
+
112
+ return true;
113
+ }
114
+
115
+ private function add_sliders( array $sliders, array $images_list ){
116
+
117
+ foreach($sliders as $slider_index=>$slider){
118
+ $slider = (array) $slider;
119
+ foreach($slider['slides'] as $slide_index=>$slide){
120
+ $sliders[$slider_index]['slides'][$slide_index]['id'] = $images_list[$slider['name']][$slide_index];// Update image ID
121
+ }
122
+ $this->plugin['data']->add_slider($slider['title'], $slider['slider_settings'], $sliders[$slider_index]['slides'] );
123
+ }
124
+ return $sliders;
125
+ }
126
+
127
+ /**
128
+ * Check zip file for consistency
129
+ *
130
+ * @param ZipArchive $zip. Instance
131
+ */
132
+ public function check_integrity( $zip_file ){
133
+ $zip = new ZipArchive();
134
+
135
+ // ZipArchive::CHECKCONS will enforce additional consistency checks
136
+ $res = $zip->open($zip_file, ZipArchive::CHECKCONS);
137
+
138
+ if ( $res === true){ // OK
139
+ return true;
140
+ }
141
+
142
+ $this->add_error($this->get_zip_error($res));
143
+ return false;
144
+
145
+ }
146
+
147
+ /**
148
+ * @param
149
+ */
150
+ private function add_images( array $sliders ){
151
+ $dir = wp_upload_dir();
152
+ $target_folder = $dir['path'].'/';
153
+ $src_folder = $dir['basedir'].'/cyclone-slider/';
154
+
155
+ $images_list = array();
156
+ foreach($sliders as $slider_name=>$slider){
157
+
158
+ foreach($slider as $i=>$image){
159
+ $image_id = 0;
160
+ if(!empty($image)){ // Check for slides without images ie. custom or youtube slide
161
+ $image_id = $this->copy_image( $src_folder.$image, $target_folder);
162
+ }
163
+ $images_list[$slider_name][] = $image_id;
164
+ }
165
+ //$this->plugin['data']->add_slider($slider->title, $slider_settings, $slides );
166
+ }
167
+ return $images_list;
168
+ }
169
+
170
+ /**
171
+ * Copy image to WP upload directory, create attachment and return attachment ID.
172
+ *
173
+ * @param string $image_file
174
+ * @param string $target_folder
175
+ * @return int|false Attachment ID on success false on fail
176
+ */
177
+ public function copy_image( $image_file, $target_folder ){
178
+ if( !file_exists($image_file) ){
179
+ return false;
180
+ }
181
+ $info = pathinfo($image_file);
182
+
183
+ if( !isset($info['dirname']) and !isset($info['filename']) and !isset($info['extension']) ){
184
+ return false;
185
+ }
186
+ $dirname = $info['dirname']; // Path to directory
187
+ $filename = $info['filename']; // Filename without extension Eg. "image-1"
188
+ $ext = $info['extension']; // File extension Eg. "jpg"
189
+
190
+ $target_folder_files = scandir($target_folder);
191
+ if($target_folder_files===false){
192
+ return false;
193
+ }
194
+
195
+ $new_name = $this->increment_name( wp_basename( $image_file ), $target_folder_files); // Append numbers if file exist
196
+ if(copy($image_file, $target_folder.$new_name)===false){
197
+ return false;
198
+ }
199
+
200
+ return $this->add_media_image( $target_folder.$new_name ); // Add image as media attachment
201
+ }
202
+
203
+ /**
204
+ * Add image as media attachment
205
+ *
206
+ * @param array $properties Media properties see $defaults for example
207
+ * @param string $file Full path to file to add
208
+ * @return int|false Attachment ID on success false on fail
209
+ */
210
+ private function add_media_image( $file, array $properties = array() ){
211
+ $wp_upload_dir = wp_upload_dir();
212
+
213
+ $filename = wp_basename( $file ); // Filename with extension. Example: image.jpg
214
+ $wp_filetype = wp_check_filetype( $filename ); // Get mime type and extension
215
+ $file_ext = $wp_filetype['ext']; // Extension without ".". Example: jpg
216
+
217
+ $defaults = array(
218
+ 'post_mime_type' => $wp_filetype['type'],
219
+ 'post_title' => $this->slug_to_title( wp_basename( $file, ".$file_ext" ) ),
220
+ 'post_content' => '',
221
+ 'post_status' => 'inherit'
222
+ );
223
+
224
+ $properties = wp_parse_args( $properties, $defaults ); // Apply defaults
225
+
226
+ $attach_id = wp_insert_attachment( $properties, $file ); // Location of the file on the server. The file MUST be on the WP uploads directory
227
+
228
+ if(!function_exists('wp_generate_attachment_metadata')) require_once( ABSPATH . 'wp-admin/includes/image.php' );// Required for wp_generate_attachment_metadata
229
+
230
+ $attachment_metadata = wp_generate_attachment_metadata( $attach_id, $file ); // Generate different thumbnails
231
+ wp_update_attachment_metadata( $attach_id, $attachment_metadata );
232
+ return $attach_id;
233
+ }
234
+
235
+ /**
236
+ * Replace - and _ with spaces and capitalize, for a readable post title
237
+ *
238
+ * @param string $string To manipulate
239
+ */
240
+ private function slug_to_title( $string ){
241
+ $string = sanitize_title( $string );
242
+ $patterns = array();
243
+ $patterns[0] = '/-/';
244
+ $patterns[1] = '/_/';
245
+ $replacements = array();
246
+ $replacements[0] = ' ';
247
+ $replacements[1] = ' ';
248
+ return ucwords(preg_replace($patterns, $replacements, $string));
249
+ }
250
+
251
+ /**
252
+ * Remove directory and its contents
253
+ *
254
+ * @param string $dir Directory to delete
255
+ * @return true|false True on success false on fail
256
+ */
257
+ public function rmdir_recursive( $dir ) {
258
+ foreach(scandir($dir) as $file) {
259
+ if ('.' === $file || '..' === $file) continue;
260
+ if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
261
+ else unlink("$dir/$file");
262
+ }
263
+ return rmdir($dir);
264
+ }
265
+
266
+ /**
267
+ * Append "-{n}" to name if filename already exist. Eg.: image.jpg becomes image-1.jpg
268
+ *
269
+ * @param string $file File to rename
270
+ * @param array $other_filenames Filenames (not full path, only names) to look for. Similar to array returned by scandir.
271
+ */
272
+ private function increment_name( $file, array $other_filenames ){
273
+ $pathinfo = pathinfo( $file );
274
+
275
+ $dirname = $pathinfo['dirname'];
276
+ $basename = $pathinfo['basename'];
277
+ $extension = isset($pathinfo['extension']) ? ".".$pathinfo['extension'] : '';
278
+ $filename = $pathinfo['filename'];
279
+
280
+ $counter = 0;
281
+ $new_name = $basename;
282
+
283
+ while( $this->in_array_str_i( $new_name, $other_filenames ) ){
284
+ $new_name = $filename.'-'.++$counter.$extension;
285
+ }
286
+
287
+ return $new_name;
288
+ }
289
+
290
+ /**
291
+ * Case insensitive string lookup in an array. Similar usage to in_array
292
+ */
293
+ private function in_array_str_i($key, array $array){
294
+ foreach($array as $element){
295
+ if(strcasecmp($key, $element)==0){ // Found it
296
+ return true;
297
+ }
298
+ }
299
+ return false;
300
+ }
301
+
302
+ /**
303
+ * Add Ok
304
+ *
305
+ * @param string $message Message to add
306
+ * @return void
307
+ */
308
+ private function add_ok( $message ){
309
+ $this->log_results['oks'][$this->log_count++] = $message;
310
+ }
311
+
312
+ /**
313
+ * Add Error
314
+ *
315
+ * @param string $message Message to add
316
+ * @return void
317
+ */
318
+ private function add_error( $message ){
319
+ $this->log_results['errors'][$this->log_count++] = $message;
320
+ }
321
+
322
+ /**
323
+ * Get zip error description from code
324
+ *
325
+ * @param int $error_code. ZipArchive error code
326
+ */
327
+ public function get_zip_error( $error_code ){
328
+ if($error_code == ZIPARCHIVE::ER_MULTIDISK){
329
+ return 'Multi-disk zip archives not supported.';
330
+
331
+ } else if($error_code == ZIPARCHIVE::ER_RENAME){
332
+ return 'Renaming temporary file failed.';
333
+
334
+ } else if($error_code == ZIPARCHIVE::ER_CLOSE){
335
+ return 'Closing zip archive failed.';
336
+
337
+ } else if($error_code == ZIPARCHIVE::ER_SEEK){
338
+ return 'Seek error.';
339
+
340
+ } else if($error_code == ZIPARCHIVE::ER_READ){
341
+ return 'Read error.';
342
+
343
+ } else if($error_code == ZIPARCHIVE::ER_WRITE){
344
+ return 'Write error.';
345
+
346
+ } else if($error_code == ZIPARCHIVE::ER_CRC){
347
+ return 'CRC error.';
348
+
349
+ } else if($error_code == ZIPARCHIVE::ER_ZIPCLOSED){
350
+ return 'Containing zip archive was closed.';
351
+
352
+ } else if($error_code == ZIPARCHIVE::ER_NOENT){
353
+ return 'No such file.';
354
+
355
+ } else if($error_code == ZIPARCHIVE::ER_EXISTS){
356
+ return 'File already exists.';
357
+
358
+ } else if($error_code == ZIPARCHIVE::ER_OPEN){
359
+ return 'Cannot open file.';
360
+
361
+ } else if($error_code == ZIPARCHIVE::ER_TMPOPEN){
362
+ return 'Failure to create temporary file.';
363
+
364
+ } else if($error_code == ZIPARCHIVE::ER_ZLIB){
365
+ return 'Zlib error.';
366
+
367
+ } else if($error_code == ZIPARCHIVE::ER_MEMORY){
368
+ return 'Memory allocation failure.';
369
+
370
+ } else if($error_code == ZIPARCHIVE::ER_CHANGED){
371
+ return 'Entry has been changed.';
372
+
373
+ } else if($error_code == ZIPARCHIVE::ER_COMPNOTSUPP){
374
+ return 'Compression method not supported.';
375
+
376
+ } else if($error_code == ZIPARCHIVE::ER_EOF){
377
+ return 'Premature EOF.';
378
+
379
+ } else if($error_code == ZIPARCHIVE::ER_INVAL){
380
+ return 'Invalid argument.';
381
+
382
+ } else if($error_code == ZIPARCHIVE::ER_NOZIP){
383
+ return 'Not a zip archive.';
384
+
385
+ } else if($error_code == ZIPARCHIVE::ER_INTERNAL){
386
+ return 'Internal error.';
387
+
388
+ } else if($error_code == ZIPARCHIVE::ER_INCONS){
389
+ return 'Zip archive inconsistent.';
390
+
391
+ } else if($error_code == ZIPARCHIVE::ER_REMOVE){
392
+ return 'Cannot remove file.';
393
+
394
+ } else if($error_code == ZIPARCHIVE::ER_DELETED){
395
+ return 'Entry has been deleted.';
396
+
397
+ }
398
+ return 'Unknown error.';
399
+ }
400
+ }
src/CycloneSlider/Main.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class CycloneSlider_Main implements ArrayAccess, Iterator {
3
+ protected $container;
4
+ protected $position;
5
+
6
+ public function __construct() {
7
+ $this->container = array();
8
+ $this->position = 0;
9
+ }
10
+
11
+ public function run(){
12
+ // Loop on contents
13
+ foreach($this as $key=>$content){
14
+ if( is_object($content) ){
15
+ $reflection = new ReflectionClass(get_class($content));
16
+ if($reflection->hasMethod('run')){
17
+ $content->run( $this ); // Call run method if it is an object with a run method()
18
+ if($reflection->hasMethod('bootstrap')){
19
+ $content->bootstrap(); // Call run method if it is an object with a bootstrap method()
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+
26
+ // Array Access
27
+ public function offsetSet($offset, $value) {
28
+ $this->container[$offset] = $value;
29
+ }
30
+
31
+ public function offsetExists($offset) {
32
+ return isset($this->container[$offset]);
33
+ }
34
+
35
+ public function offsetUnset($offset) {
36
+ unset($this->container[$offset]);
37
+ }
38
+
39
+ public function offsetGet($offset) {
40
+ return isset($this->container[$offset]) ? $this->container[$offset] : null;
41
+ }
42
+
43
+ // Iterator
44
+ public function rewind() {
45
+ reset($this->container);
46
+ }
47
+
48
+ public function current() {
49
+ return current($this->container);
50
+ }
51
+
52
+ public function key() {
53
+ return key($this->container);
54
+ }
55
+
56
+ public function next() {
57
+ return next($this->container);
58
+ }
59
+
60
+ public function valid() {
61
+ return key($this->container) !== null;
62
+ }
63
+
64
+ }
src/CycloneSlider/NextgenIntegration.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for NextGEN integration. Allows import of images from a gallery as new slides.
4
+ */
5
+ class CycloneSlider_NextgenIntegration {
6
+
7
+ protected $plugin;
8
+
9
+ /**
10
+ * Run
11
+ */
12
+ function run( $plugin ) {
13
+ $this->plugin = $plugin;
14
+
15
+ // Add metaboxes
16
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 100 );
17
+
18
+ // Append nextgen slides
19
+ add_filter('cycloneslider_slides', array($this, 'nextgen_slides'));
20
+
21
+ }
22
+
23
+ /**
24
+ * Add metabox
25
+ */
26
+ function add_meta_boxes(){
27
+ global $nggdb;
28
+ if(!isset($nggdb)){//Show only if nextgen plugin is available
29
+ return false;
30
+ }
31
+
32
+ add_meta_box(
33
+ 'cyclone-nextgen-metabox',
34
+ __('NextGEN Integration', 'cycloneslider'),
35
+ array( $this, 'render_nextgen_meta_box' ),
36
+ 'cycloneslider' ,
37
+ 'normal',
38
+ 'low'
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Render metabox
44
+ */
45
+ function render_nextgen_meta_box($post){
46
+ global $nggdb;
47
+
48
+ ?>
49
+ <div class="cycloneslider-field last">
50
+ <label for="cycloneslider_nextgen_gallery"><?php _e('Choose a NextGEN Gallery', 'cycloneslider'); ?></label>
51
+ <?php
52
+ $galleries = $nggdb->find_all_galleries();
53
+ ?>
54
+ <select id="cycloneslider_nextgen_gallery" name="cycloneslider_settings[nextgen_gallery]">
55
+ <option selected="selected" value="0"></option>
56
+ <?php foreach($galleries as $gallery): ?>
57
+ <option value="<?php echo $gallery->gid; ?>"><?php echo $gallery->title; ?></option>
58
+ <?php endforeach; ?>
59
+ </select>
60
+ <input type="submit" name="cycloneslider_settings[nextgen]" value="<?php _e('Import', 'cycloneslider'); ?>" class="button-secondary" />
61
+ <br />
62
+ <span class="note"><?php _e('Select a gallery to import images from. Images will be added as new slides.', 'cycloneslider'); ?></span>
63
+ <div class="clear"></div>
64
+ </div>
65
+ <?php
66
+ }
67
+
68
+ /**
69
+ * Append 1-x to name if filename already exist
70
+ */
71
+ function increment_name($filename, $extension, $folder_files){
72
+ $name = $filename.'.'.$extension;
73
+ if($this->in_array_str_i($name, $folder_files)){
74
+ $existing = true;
75
+ $counter = 0;
76
+ while($existing){
77
+ $counter++;
78
+ $name = $filename.$counter.'.'.$extension;
79
+ if(!$this->in_array_str_i($name, $folder_files)){
80
+ return $name;
81
+ }
82
+ }
83
+ }
84
+ return $name;
85
+ }
86
+
87
+ /**
88
+ * Case insensitive string lookup in an array
89
+ */
90
+ function in_array_str_i($key, $array){
91
+ foreach($array as $element){
92
+ if(strcasecmp($key, $element)==0){
93
+ return true;
94
+ }
95
+ }
96
+ return false;
97
+ }
98
+
99
+ /**
100
+ * Replace certain characters with spaces in order to be a readable post title
101
+ */
102
+ function slug_to_title($string){
103
+ $patterns = array();
104
+ $patterns[0] = '/-/';
105
+ $patterns[1] = '/_/';
106
+ $replacements = array();
107
+ $replacements[0] = ' ';
108
+ $replacements[1] = ' ';
109
+ return ucwords(preg_replace($patterns, $replacements, $string));
110
+ }
111
+
112
+ /**
113
+ * Copy image to WP upload directory, create attachment and return attachment ID.
114
+ */
115
+ function copy_image($image_file){
116
+ $dir = wp_upload_dir();
117
+ $target_folder = $dir['path'].'/';
118
+
119
+ $info = pathinfo($image_file);
120
+ $dirname = isset($info['dirname']) ? $info['dirname'] : ''; // Path to directory
121
+ $filename = isset($info['filename']) ? $info['filename'] : ''; // Filename without extension Eg. "image-1"
122
+ $ext = isset($info['extension']) ? $info['extension'] : ''; // File extension Eg. "jpg"
123
+
124
+ if($target_folder_files = scandir($target_folder)){
125
+ if(is_array($target_folder_files)){
126
+ $new_name = $this->increment_name($filename, $ext, $target_folder_files); //Append numbers if file exist
127
+ if(copy($image_file, $target_folder.$new_name)){
128
+
129
+ $size = getimagesize($target_folder.$new_name);// Get mime type
130
+ // Build attachment details
131
+ $attachment = array(
132
+ 'post_mime_type' => $size['mime'],
133
+ 'post_title' => $this->slug_to_title(basename($new_name, '.'.$ext)),
134
+ 'post_content' => '',
135
+ 'post_status' => 'inherit'
136
+ );
137
+
138
+ $attach_id = wp_insert_attachment( $attachment, $target_folder.$new_name );
139
+
140
+ if(!function_exists('wp_generate_attachment_metadata')) include( ABSPATH . 'wp-admin/includes/image.php' );// Required for wp_generate_attachment_metadata
141
+
142
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $target_folder.$new_name ); // Generate different thumbnails
143
+ wp_update_attachment_metadata( $attach_id, $attach_data );
144
+ return $attach_id;
145
+ }
146
+ }
147
+ }
148
+ return false;
149
+ }
150
+
151
+
152
+
153
+ /**
154
+ * Add images from nextgen as new slides. Images are copied from nextgen folders into WP uploads dir and added as attachments.
155
+ */
156
+ function nextgen_slides($slides){
157
+ global $nggdb;
158
+ if(!isset($nggdb)){
159
+ return $slides;
160
+ }
161
+
162
+ if(isset($_POST['cycloneslider_settings']['nextgen']) and isset($_POST['cycloneslider_settings']['nextgen_gallery']) ){
163
+
164
+ $nextgen_gallery = $nggdb->get_gallery((int) $_POST['cycloneslider_settings']['nextgen_gallery']);
165
+
166
+ if(!empty($nextgen_gallery) and is_array($nextgen_gallery)){
167
+
168
+ foreach($nextgen_gallery as $image){
169
+ if($attach_id = $this->copy_image($image->imagePath)){ //Copy success!
170
+ $slides[] = wp_parse_args(array('id' => $attach_id), $plugin['data']->get_slide_defaults() ); //Add the slide ID and fill in default values
171
+ }
172
+ }
173
+ }
174
+ }
175
+
176
+ return $slides;
177
+ }
178
+
179
+ } // end class
src/CycloneSlider/SettingsPage.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for settings page
4
+ */
5
+ class CycloneSlider_SettingsPage extends CycloneSlider_Base {
6
+
7
+
8
+ public function bootstrap() {
9
+
10
+ // Add settings
11
+ add_action( 'admin_init', array( $this, 'register_settings') );
12
+
13
+ // Add settings page
14
+ add_action( 'admin_menu', array( $this, 'add_menu_and_page'));
15
+ }
16
+
17
+ public function add_menu_and_page(){
18
+ // Use built-in WP function
19
+ add_submenu_page(
20
+ $this->plugin['settings_page.parent_slug'],
21
+ $this->plugin['settings_page.page_title'],
22
+ $this->plugin['settings_page.menu_title'],
23
+ 'manage_options',
24
+ $this->plugin['settings_page.menu_slug'],
25
+ array( $this, 'render_settings_page')
26
+ );
27
+ }
28
+
29
+ /**
30
+ * Render settings page. This function should echo the HTML form of the settings page.
31
+ */
32
+ public function render_settings_page($post){
33
+ $this->plugin['view']->set_view_file( $this->plugin['path'] . 'views/settings-page.php' );
34
+
35
+ $settings_data = $this->get_settings_data();
36
+ $templates = $this->plugin['templates_manager']->get_all_templates();
37
+
38
+ $settings_data['load_templates'] = $this->plugin['templates_manager']->get_active_templates( $settings_data );// Filter load templates
39
+
40
+
41
+ $vars = array();
42
+ $vars['page_title'] = $this->plugin['settings_page.page_title'];
43
+ $vars['screen_icon'] = get_screen_icon('options-general'); ;
44
+
45
+
46
+ $vars['settings_fields'] = $this->settings_fields( $this->plugin['settings_page.option_group'] );
47
+ $vars['option_name'] = $this->plugin['settings_page.option_name'];
48
+
49
+
50
+ $vars['templates'] = $templates;
51
+ $vars['settings_data'] = $settings_data;
52
+
53
+ $vars['debug'] = ($this->plugin['debug']) ? cyclone_slider_debug( $vars['settings_data'] ) : '';
54
+
55
+ $this->plugin['view']->set_vars( $vars );
56
+ $this->plugin['view']->render();
57
+ }
58
+
59
+ /**
60
+ * Prepare option data
61
+ */
62
+ public function register_settings() {
63
+ register_setting(
64
+ $this->plugin['settings_page.option_group'],
65
+ $this->plugin['settings_page.option_name'],
66
+ array( $this, 'validate_options')
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Validate data from HTML form
72
+ */
73
+ public function validate_options( $input ) {
74
+ $input = wp_parse_args($input, $this->get_settings_data());
75
+
76
+ delete_site_transient('update_plugins'); // Force check. Regenerate package url for updater
77
+
78
+ if( isset($_POST['reset']) ){
79
+ $input = $this->get_default_settings_data();
80
+ add_settings_error( $this->menu_slug, 'restore_defaults', __( 'Default options restored.', 'cycloneslider'), 'updated fade' );
81
+ }
82
+ return $input;
83
+ }
84
+
85
+ /**
86
+ * Get settings data. If there is no data from database, use default values
87
+ */
88
+ public function get_settings_data(){
89
+ return get_option( $this->plugin['settings_page.option_name'], $this->get_default_settings_data() );
90
+ }
91
+
92
+ /**
93
+ * Apply default values
94
+ */
95
+ public function get_default_settings_data() {
96
+ $defaults = array();
97
+ $defaults['load_scripts_in'] = 'footer';
98
+
99
+ $defaults['load_cycle2'] = 1;
100
+ $defaults['load_cycle2_carousel'] = 1;
101
+ $defaults['load_cycle2_swipe'] = 1;
102
+ $defaults['load_cycle2_tile'] = 1;
103
+ $defaults['load_cycle2_video'] = 1;
104
+
105
+ $defaults['load_easing'] = 1;
106
+
107
+ $defaults['load_magnific'] = 1;
108
+
109
+ $defaults['load_templates'] = array();
110
+
111
+ $defaults['script_priority'] = 100;
112
+
113
+ $defaults['license_id'] = '';
114
+ $defaults['license_key'] = '';
115
+
116
+ return $defaults;
117
+ }
118
+
119
+ /**
120
+ * Output needed fields for security
121
+ */
122
+ function settings_fields( $option_group ) {
123
+ $fields = "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";
124
+ $fields .= '<input type="hidden" name="action" value="update" />';
125
+ $fields .= wp_nonce_field("$option_group-options", '_wpnonce', true, false);
126
+ return $fields;
127
+ }
128
+
129
+
130
+
131
+ /**
132
+ * Get settings data by uid
133
+ */
134
+ public function get_data($uid){
135
+ $settings_data = $this->get_settings_data();
136
+ if(isset($settings_data[$uid])){
137
+ return $settings_data[$uid];
138
+ }
139
+ return false;
140
+ }
141
+
142
+
143
+
144
+ /**
145
+ * SETTER FUNCTIONS
146
+ */
147
+ public function set_option_group( $value ){
148
+ $this->option_group = $value;
149
+ }
150
+
151
+ public function set_option_name( $value ){
152
+ $this->option_name = $value;
153
+ }
154
+
155
+ public function set_page_title( $value ){
156
+ $this->page_title = $value;
157
+ }
158
+
159
+ public function set_menu_title( $value ){
160
+ $this->menu_title = $value;
161
+ }
162
+
163
+ public function set_capability( $value ){
164
+ $this->capability = $value;
165
+ }
166
+
167
+ public function set_menu_slug( $value ){
168
+ $this->menu_slug = $value;
169
+ }
170
+
171
+ public function set_icon_url( $value ){
172
+ $this->icon_url = $value;
173
+ }
174
+
175
+ public function set_position( $value ){
176
+ $this->position = $value;
177
+ }
178
+
179
+ /**
180
+ * GETTER FUNCTIONS
181
+ */
182
+ public function get_option_group(){
183
+ return $this->option_group;
184
+ }
185
+
186
+ public function get_option_name(){
187
+ return $this->option_name;
188
+ }
189
+
190
+ public function get_page_title(){
191
+ return $this->page_title;
192
+ }
193
+
194
+ public function get_menu_title(){
195
+ return $this->menu_title;
196
+ }
197
+
198
+ public function get_capability(){
199
+ return $this->capability;
200
+ }
201
+
202
+ public function get_menu_slug(){
203
+ return $this->menu_slug;
204
+ }
205
+
206
+ public function get_icon_url(){
207
+ return $this->icon_url;
208
+ }
209
+
210
+ public function get_position(){
211
+ return $this->position;
212
+ }
213
+
214
+ } // end class
src/CycloneSlider/TemplatesManager.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * In charge in getting templates from various template locations.
4
+ */
5
+ class CycloneSlider_TemplatesManager extends CycloneSlider_Base {
6
+
7
+ protected $template_locations;
8
+
9
+ /**
10
+ * Initializes class
11
+ */
12
+ public function __construct() {
13
+ $this->template_locations = array();
14
+ }
15
+
16
+
17
+ public function bootstrap(){
18
+
19
+ // Add directories to get templates
20
+ $this->add_template_location(
21
+ array(
22
+ 'path' => $this->plugin['path'].'templates'.DIRECTORY_SEPARATOR, // This resides in the plugin
23
+ 'url' => $this->plugin['url'].'templates/',
24
+ 'location_name' => 'core'
25
+ )
26
+ );
27
+ $this->add_template_location(
28
+ array(
29
+ 'path' => realpath(get_stylesheet_directory()).DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR,// This resides in the current theme or child theme
30
+ 'url' => get_stylesheet_directory_uri()."/cycloneslider/",
31
+ 'location_name' => 'active-theme'
32
+ )
33
+ );
34
+ $cyclone_upload_dir = wp_upload_dir();
35
+ $cyclone_template_folder = realpath( dirname( $cyclone_upload_dir['basedir'] ) );
36
+
37
+ $this->add_template_location(
38
+ array(
39
+ 'path' => $cyclone_template_folder.DIRECTORY_SEPARATOR.'cycloneslider'.DIRECTORY_SEPARATOR,// This resides in the wp-content folder to prevent deleting when upgrading themes
40
+ 'url' => content_url()."/cycloneslider/",
41
+ 'location_name' => 'wp-content'
42
+ )
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Add a directory to read templates from
48
+ *
49
+ * @param string $location - The full path to a directory
50
+ */
51
+ public function add_template_location( $location ){
52
+ $this->template_locations[] = $location;
53
+ }
54
+
55
+ /**
56
+ * Get all templates in array format
57
+ */
58
+ public function get_all_templates(){
59
+ if(is_array($this->template_locations) and !empty($this->template_locations)){
60
+ $template_folders = array();
61
+ foreach($this->template_locations as $location){
62
+ if($files = @scandir($location['path'])){
63
+ $c = 0;
64
+ foreach($files as $name){
65
+ if($name!='.' and $name!='..' and is_dir($location['path'].$name) and @file_exists($location['path'].$name.DIRECTORY_SEPARATOR.'slider.php') ){ // Check if its a directory
66
+ $ini_array['slide_type'] = array('image');// Default
67
+ if(@file_exists($location['path'].$name.DIRECTORY_SEPARATOR.'config.txt')){
68
+ $ini_array = parse_ini_file($location['path'].$name.DIRECTORY_SEPARATOR.'config.txt'); //Parse ini to get slide types supported
69
+ }
70
+
71
+ $name = sanitize_title($name);// Change space to dash and all lowercase
72
+ $template_folders[$name] = array( // Here we override template of the same names. If there is a template with the same name in plugin and theme directory, the one in theme will take over
73
+ 'path'=>$location['path'].$name,
74
+ 'url'=>$location['url'].$name,
75
+ 'supports' => $ini_array['slide_type'],
76
+ 'location_name' => $location['location_name']
77
+ );
78
+ }
79
+ }
80
+ }
81
+ }
82
+ return $template_folders;
83
+ }
84
+
85
+ }
86
+
87
+ /**
88
+ * Get Active Templates
89
+ *
90
+ * Get templates that are enabled in settings page
91
+ *
92
+ * @return array Template locations
93
+ */
94
+ public function get_active_templates(){
95
+
96
+ $settings_data = $this->plugin['settings_page']->get_settings_data();
97
+ $templates = $this->get_all_templates();
98
+
99
+ foreach($templates as $name=>$template){
100
+
101
+ if( !isset($settings_data['load_templates'][$name]) ){
102
+ $settings_data['load_templates'][$name] = 1;
103
+ }
104
+ }
105
+ return $settings_data['load_templates'];
106
+ }
107
+
108
+ /**
109
+ * Get Template Locations
110
+ *
111
+ * @return array Template locations
112
+ */
113
+ public function get_template_locations(){
114
+ return $this->template_locations;
115
+ }
116
+ }
src/CycloneSlider/Updater.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for updating plugin
4
+ */
5
+ class CycloneSlider_Updater extends CycloneSlider_Base {
6
+
7
+ private $settings_data; // To access the license id and key
8
+ private $plugin_slug; // Slug of the plugin
9
+ private $current_version; // Current plugin version to check against
10
+ private $info_url; // URL to API endpoint that returns latest plugin version + plugin info
11
+
12
+ public function bootstrap(){
13
+ $this->settings_data = $this->plugin['settings_page']->get_settings_data();
14
+
15
+ $this->plugin_slug = $this->plugin['slug'];
16
+ $this->current_version = $this->plugin['version'];
17
+ $this->info_url = $this->plugin['updater.info_url'];
18
+
19
+ $this->check_updates();
20
+ //print_r( get_site_transient( 'update_plugins') );
21
+
22
+ }
23
+
24
+ /*
25
+ public function update_package_url(){
26
+ $api_url = $this->plugin['updater.download_url'];
27
+ $client_time = time();
28
+ $license_id = $this->settings_data['license_id'];
29
+ $license_key = $this->settings_data['license_key'];
30
+
31
+
32
+ $new_option = get_site_transient( 'update_plugins' );
33
+ if(isset($new_option['response']['cyclone-slider-pro/cyclone-slider.php']['package'])){
34
+ $new_option['response']['cyclone-slider-pro/cyclone-slider.php']['package'] = $this->generate_package_url($api_url, $client_time, $license_id, $license_key);
35
+ set_site_transient( 'update_plugins', $new_option );
36
+ }
37
+
38
+ }
39
+ //*/
40
+
41
+
42
+
43
+ /**
44
+ * Check updates
45
+ */
46
+ public function check_updates($force_check=false){
47
+
48
+ if($force_check){
49
+ delete_site_transient('update_plugins'); // Force check
50
+ }
51
+
52
+ // Insert custom plugins info to 'update_plugins" site transient
53
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_plugin'));
54
+
55
+ // Define the alternative response for information checking
56
+ add_filter('plugins_api', array($this, 'check_info'), 10, 3);
57
+ }
58
+
59
+ /**
60
+ * Check update for each plugin in the list
61
+ *
62
+ * @param object $transient - The site transient containing plugin info
63
+ */
64
+ public function check_plugin($transient) {
65
+
66
+ // Return we already checked
67
+ if (empty($transient->checked)) {
68
+ return $transient;
69
+ }
70
+
71
+ // Get the remote plugin info
72
+ $latest_plugin = $this->get_latest_plugin_info($this->info_url);
73
+
74
+ if( $latest_plugin ) {
75
+
76
+ // If a newer version is available, add the update info
77
+ if ( version_compare($this->current_version, $latest_plugin->version, '<') ) {
78
+
79
+ // Prepare needed info for transient using objects
80
+ $obj = new stdClass();
81
+
82
+ $obj->slug = $latest_plugin->slug;
83
+ $obj->new_version = $latest_plugin->version;
84
+ $obj->url = $latest_plugin->url;
85
+
86
+
87
+ $api_url = $this->plugin['updater.download_url'];
88
+ $client_time = time();
89
+ $license_id = $this->settings_data['license_id'];
90
+ $license_key = $this->settings_data['license_key'];
91
+
92
+ $obj->package = $this->generate_package_url($api_url, $client_time, $license_id, $license_key);
93
+
94
+ $transient->response[ $obj->slug ] = $obj;
95
+ }
96
+
97
+ }
98
+
99
+ return $transient;
100
+ }
101
+
102
+ /**
103
+ * Add our self-hosted description to the filter
104
+ */
105
+ public function check_info($false, $action, $arg) {
106
+
107
+ if ( isset($arg->slug) and $arg->slug === $this->plugin_slug ) { // Plugin slug format: {folder-name}/{main-file.php}
108
+
109
+ // Get the remote version
110
+ if( $latest_plugin = $this->get_latest_plugin_info( $this->info_url ) ) {
111
+
112
+ // Build needed info
113
+ $information = new stdClass();
114
+ $information->name = 'Cyclone Slider Pro';
115
+ $information->slug = $this->plugin_slug;
116
+ $information->version = $latest_plugin->version;
117
+ $information->author = $latest_plugin->author;
118
+ $information->homepage = $latest_plugin->homepage;
119
+ $information->requires = $latest_plugin->requires;
120
+ $information->tested = $latest_plugin->tested;
121
+ $information->downloaded = $latest_plugin->downloaded;
122
+ $information->last_updated = $latest_plugin->last_updated;
123
+ $information->sections = $this->format_sections((array) $latest_plugin->sections);
124
+
125
+ $api_url = $this->plugin['updater.download_url'];
126
+ $client_time = time();
127
+ $license_id = $this->settings_data['license_id'];
128
+ $license_key = $this->settings_data['license_key'];
129
+
130
+ $information->download_link = $this->generate_package_url($api_url, $client_time, $license_id, $license_key);
131
+
132
+ return $information;
133
+ }
134
+ }
135
+
136
+ return $false;
137
+ }
138
+
139
+
140
+
141
+ /**
142
+ * Fetch plugin info from remote url
143
+ *
144
+ * @param string $info_url - URL to API endpoint that returns latest plugin version + plugin info
145
+ * @return object $response
146
+ */
147
+ public function get_latest_plugin_info( $info_url ) {
148
+
149
+ $raw_response = wp_remote_get( $info_url );
150
+ //echo cyclone_slider_debug( $raw_response );
151
+ //var_dump( $raw_response );
152
+ if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
153
+ return false;
154
+
155
+ $response = json_decode( wp_remote_retrieve_body( $raw_response ) );
156
+
157
+ //echo cyclone_slider_debug( $response );
158
+ if(!isset($response->data)){
159
+ return false;
160
+ }
161
+ return $response->data;
162
+ }
163
+
164
+
165
+ protected function format_sections( $sections ) {
166
+ return array(
167
+ 'description' => $sections['description'],
168
+ 'installation' => $sections['installation'],
169
+ 'changelog' => $this->format_changelog( $sections['changelog'] )
170
+ );
171
+ }
172
+
173
+ protected function format_changelog( $changelog ) {
174
+ $html = '<ul>';
175
+ foreach($changelog as $log){
176
+ $html .= '<li>'.$log.'</li>';
177
+ }
178
+ $html .= '</ul>';
179
+ return $html;
180
+ }
181
+
182
+ protected function generate_package_url($api_url, $client_time, $license_id, $license_key){
183
+
184
+ $query_string = http_build_query(array(
185
+ 't' => $client_time,//uses time(),
186
+ 'lid' => $license_id
187
+ ));
188
+
189
+ $digest = $api_url.' '.$query_string.' '.$license_key;
190
+
191
+ $signature = hash( 'sha256', $digest );
192
+
193
+ $query_array = array(
194
+ 't' => $client_time,
195
+ 'lid' => $license_id,
196
+ 'signature' => $signature
197
+ );
198
+ $query_string = http_build_query($query_array);
199
+ return $this->plugin['updater.download_url'].'?'.$query_string;
200
+
201
+ }
202
+ } // end class
src/CycloneSlider/View.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class for conveniently fetching template files and attaching template variables
5
+ */
6
+ class CycloneSlider_View {
7
+
8
+ protected $view_file;
9
+ protected $vars = array();
10
+
11
+ /**
12
+ * Constructor
13
+ */
14
+ public function __construct( $view_file='' ){
15
+ $this->view_file = $view_file;
16
+ }
17
+
18
+ /**
19
+ * Magic functions
20
+ */
21
+ public function __get( $key ) {
22
+ return $this->vars[$key];
23
+ }
24
+
25
+ public function __set( $key, $value ) {
26
+ $this->vars[$key] = $value;
27
+ }
28
+
29
+ /**
30
+ * Setters
31
+ */
32
+ public function set_view_file( $value ){
33
+ $this->view_file = $value;
34
+ }
35
+
36
+ public function set_vars( $value ){
37
+ $this->vars = $value;
38
+ }
39
+
40
+ /**
41
+ * Getters
42
+ */
43
+ public function get_view_file(){
44
+ return $this->view_file;
45
+ }
46
+
47
+ public function get_vars(){
48
+ return $this->vars;
49
+ }
50
+
51
+ /**
52
+ * Include the view file and extract the passed variables
53
+ */
54
+ public function render(){
55
+
56
+ if(@file_exists($this->view_file)){
57
+ extract($this->vars, EXTR_SKIP); // Extract variables
58
+
59
+ include($this->view_file); //Include the view file
60
+ } else {
61
+ echo '<p>Not found '.$this->view_file.'</p>';
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Get and return view_file contents as string
67
+ */
68
+ public function get_render(){
69
+ ob_start();
70
+ $this->render();
71
+ return ob_get_clean();
72
+ }
73
+ }
src/CycloneSlider/Vimeo.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for handling Vimeo slides
4
+ */
5
+ class CycloneSlider_Vimeo {
6
+
7
+ /**
8
+ * Get Vimeo ID
9
+ *
10
+ * Return vimeo video id
11
+ *
12
+ * @param string $url URL of to parse
13
+ *
14
+ * @return int|false Vimeo ID on success and false on fail
15
+ */
16
+ public function get_vimeo_id($url){
17
+
18
+ $parsed_url = parse_url($url);
19
+ if ($parsed_url['host'] == 'vimeo.com'){
20
+ $vimeo_id = ltrim( $parsed_url['path'], '/');
21
+ if (is_numeric($vimeo_id)) {
22
+ return $vimeo_id;
23
+ }
24
+ }
25
+ return false;
26
+ }
27
+
28
+ /**
29
+ * Get vimeo video thumbnail image
30
+ *
31
+ * @param int Vimeo ID.
32
+ * @param string Size can be: thumbnail_small, thumbnail_medium, thumbnail_large.
33
+ *
34
+ * @return string URL of thumbnail image.
35
+ */
36
+ public function get_vimeo_thumb($video_id, $size = 'small'){
37
+ if(!empty($video_id)){
38
+ $data = @file_get_contents('http://vimeo.com/api/v2/video/'.$video_id.'.php');
39
+ if( $data ) {
40
+ $vimeo = unserialize( $data );
41
+ if( isset($vimeo[0]['thumbnail_'.$size]) ){
42
+ return $vimeo[0]['thumbnail_'.$size];
43
+ }
44
+ }
45
+ }
46
+ return '';
47
+ }
48
+ } // end class
src/CycloneSlider/Youtube.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class for handling youtube slides
4
+ */
5
+ class CycloneSlider_Youtube {
6
+
7
+ /**
8
+ * Initialize
9
+ */
10
+ public function __construct() {} // end constructor
11
+
12
+ /**
13
+ * Ajax for checking youtube url
14
+ *
15
+ * @return void Prints json data
16
+ */
17
+ public function cycloneslider_check_youtube_url(){
18
+ $url = $_POST['url'];
19
+
20
+ $retval = array(
21
+ 'success' => false
22
+ );
23
+
24
+ if (filter_var($url, FILTER_VALIDATE_URL) !== FALSE) {
25
+ if( $id = $this->get_youtube_id($url) ){
26
+ $retval['success'] = true;
27
+ $retval['id'] = $id;
28
+ $retval['v_url'] = "http://www.youtube.com/v/{$id}";
29
+ }
30
+ }
31
+
32
+ echo json_encode($retval);
33
+ die();
34
+ }
35
+
36
+ /**
37
+ * Get youtube ID from different url formats
38
+ *
39
+ * @param string $url Youtube url
40
+ * @return string|boolean Youtube URL on success or boolean false on fail
41
+ */
42
+ public function get_youtube_id($url){
43
+ if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
44
+ return false;
45
+ }
46
+ $parsed_url = parse_url($url);
47
+
48
+ if(strpos($parsed_url['host'], 'youtube.com')!==false){
49
+ if(strpos($parsed_url['path'], '/watch')!==false){ // Regular url Eg. http://www.youtube.com/watch?v=9bZkp7q19f0
50
+ parse_str($parsed_url['query'], $parsed_str);
51
+ if(isset($parsed_str['v']) and !empty($parsed_str['v'])){
52
+ return $parsed_str['v'];
53
+ }
54
+ } else if(strpos($parsed_url['path'], '/v/')!==false){ // "v" URL http://www.youtube.com/v/9bZkp7q19f0?version=3&autohide=1
55
+ $id = str_replace('/v/','',$parsed_url['path']);
56
+ if( !empty($id) ){
57
+ return $id;
58
+ }
59
+ } else if(strpos($parsed_url['path'], '/embed/')!==false){ // Embed URL: http://www.youtube.com/embed/9bZkp7q19f0
60
+ return str_replace('/embed/','',$parsed_url['path']);
61
+ }
62
+ } else if(strpos($parsed_url['host'], 'youtu.be')!==false){ // Shortened URL: http://youtu.be/9bZkp7q19f0
63
+ return str_replace('/','',$parsed_url['path']);
64
+ }
65
+
66
+ return false;
67
+ }
68
+
69
+
70
+ /**
71
+ * Get youtube video thumbnail image
72
+ *
73
+ * @param int string $video_id YouTube ID
74
+ * @param string $size Can be: small, medium, large
75
+ *
76
+ * @return string URL of thumbnail image.
77
+ */
78
+ public function get_youtube_thumb( $video_id, $size = 'small' ){
79
+ if( 'large' == $size ){
80
+ return 'http://img.youtube.com/vi/'.$video_id.'/hqdefault.jpg';
81
+ } else if( 'medium' == $size ){
82
+ return 'http://img.youtube.com/vi/'.$video_id.'/mqdefault.jpg';
83
+ }
84
+ return 'http://img.youtube.com/vi/'.$video_id.'/default.jpg';
85
+ }
86
+ } // end class
{inc → src}/functions.php RENAMED
@@ -9,7 +9,7 @@
9
  function cyclone_slider( $slider_slug ){
10
  global $cyclone_slider_plugin_instance;
11
  if(isset($cyclone_slider_plugin_instance)){
12
- echo $cyclone_slider_plugin_instance->cycloneslider_shortcode( array('id'=>$slider_slug) );
13
  }
14
  }
15
 
9
  function cyclone_slider( $slider_slug ){
10
  global $cyclone_slider_plugin_instance;
11
  if(isset($cyclone_slider_plugin_instance)){
12
+ echo $cyclone_slider_plugin_instance['frontend']->cycloneslider_shortcode( array('id'=>$slider_slug) );
13
  }
14
  }
15