Carousel Slider - Version 1.6.3

Version Description

Download this release

Release Info

Developer sayful
Plugin Icon Carousel Slider
Version 1.6.3
Comparing to
See all releases

Code changes from version 1.6.2 to 1.6.3

assets/css/admin.css CHANGED
@@ -43,6 +43,8 @@ div[id*="_carousel_slider"] .widget-top:hover { background: #ffdddd !important;
43
  .carousel_slider_gallery_list li { float: left; margin: 0; padding: 0; }
44
  .carousel_slider_gallery_list li > img { margin-right: 10px; margin-bottom: 10px; display: block; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); }
45
 
 
 
46
  /* jQuery UI Datepicker */
47
  .ui-datepicker { background-color: #ffffff; border: 1px solid #cccccc; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); padding: 8px; display: none; }
48
 
43
  .carousel_slider_gallery_list li { float: left; margin: 0; padding: 0; }
44
  .carousel_slider_gallery_list li > img { margin-right: 10px; margin-bottom: 10px; display: block; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); }
45
 
46
+ #field-_post_date_after, #field-_post_date_before, #field-_post_categories, #field-_post_tags, #field-_post_in { display: none; }
47
+
48
  /* jQuery UI Datepicker */
49
  .ui-datepicker { background-color: #ffffff; border: 1px solid #cccccc; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); padding: 8px; display: none; }
50
 
assets/js/admin.js CHANGED
@@ -1,36 +1,77 @@
1
  (function( $ ) {
2
  "use strict";
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  $('#_carousel_slider_slide_type').on('change', function() {
 
 
 
 
 
 
 
 
5
  if (this.value == 'image-carousel') {
6
- $('#section_post_query').slideUp();
7
- $('#section_video_settings').slideUp();
8
- $('#section_url_images_settings').slideUp();
9
  $('#section_images_settings').slideDown();
 
10
  }
11
  if (this.value == 'image-carousel-url') {
12
- $('#section_post_query').slideUp();
13
- $('#section_video_settings').slideUp();
14
- $('#section_images_settings').slideUp();
15
  $('#section_url_images_settings').slideDown();
 
16
  }
17
  if (this.value == 'post-carousel') {
18
- $('#section_images_settings').slideUp();
19
- $('#section_video_settings').slideUp();
20
- $('#section_url_images_settings').slideUp();
21
  $('#section_post_query').slideDown();
22
  }
23
  if (this.value == 'video-carousel') {
24
- $('#section_images_settings').slideUp();
25
- $('#section_post_query').slideUp();
26
- $('#section_url_images_settings').slideUp();
27
  $('#section_video_settings').slideDown();
28
  }
29
  });
30
 
31
  // Select2
32
  $("select.select2").each( function () {
33
-
34
  $(this).select2();
35
  });
36
 
@@ -251,55 +292,4 @@
251
  }
252
  return false;
253
  }
254
-
255
-
256
- $('#carousel_slider_video_btn').on('click', function(e) {
257
- e.preventDefault();
258
-
259
- var options = {
260
- // state: 'insert',
261
- className: 'media-frame carousel-slider-media-frame',
262
- frame: 'select',
263
- multiple: isMultiple,
264
- title: CarouselSlider.video_frame_title,
265
- library: {
266
- type: 'video'
267
- },
268
- button: {
269
- text: CarouselSlider.insert_btn_text
270
- }
271
- };
272
-
273
- frame = wp.media(options).open();
274
-
275
- frame.menu.get('view').unset('gallery');
276
- frame.menu.get('view').unset('featured-image');
277
-
278
- frame.toolbar.get('view').set({
279
- insert: {
280
- style: 'primary',
281
- text: CarouselSlider.insert_btn_text,
282
-
283
- click: function() {
284
- var models = frame.state().get('selection'),
285
- attachment_id = models.first().attributes.id,
286
- files = [];
287
-
288
- if( isMultiple ) {
289
- models.map (function( attachment ) {
290
- attachment = attachment.toJSON();
291
- // console.log(attachment);
292
- files.push(attachment.url);
293
- attachment_id = files;
294
- });
295
- }
296
-
297
- $('#_video_url').val( attachment_id );
298
-
299
- frame.close();
300
- }
301
- }
302
- });
303
- });
304
-
305
  })(jQuery);
1
  (function( $ ) {
2
  "use strict";
3
 
4
+ if ( $('#_carousel_slider_slide_type').val() == 'post-carousel' ) {
5
+ var _postQueryType = $('#_post_query_type').val();
6
+ if ( _postQueryType == 'latest_posts' ) {}
7
+ if ( _postQueryType == 'date_range' ) {
8
+ $('#field-_post_date_after').show();
9
+ $('#field-_post_date_before').show();
10
+ }
11
+ if ( _postQueryType == 'post_categories' ) {
12
+ $('#field-_post_categories').show();
13
+ }
14
+ if ( _postQueryType == 'post_tags' ) {
15
+ $('#field-_post_tags').show();
16
+ }
17
+ if ( _postQueryType == 'specific_posts' ) {
18
+ $('#field-_post_in').show();
19
+ $('#field-_posts_per_page').hide();
20
+ }
21
+ }
22
+
23
+ $('#_post_query_type').on('change', function(){
24
+
25
+ $('#field-_post_date_after').hide('fast');
26
+ $('#field-_post_date_before').hide('fast');
27
+ $('#field-_post_categories').hide('fast');
28
+ $('#field-_post_tags').hide('fast');
29
+ $('#field-_post_in').hide('fast');
30
+ $('#field-_posts_per_page').show('fast');
31
+
32
+ if ( this.value == 'date_range' ) {
33
+ $('#field-_post_date_after').slideDown();
34
+ $('#field-_post_date_before').slideDown();
35
+ }
36
+ if ( this.value == 'post_categories' ) {
37
+ $('#field-_post_categories').slideDown();
38
+ }
39
+ if ( this.value == 'post_tags' ) {
40
+ $('#field-_post_tags').slideDown();
41
+ }
42
+ if ( this.value == 'specific_posts' ) {
43
+ $('#field-_post_in').slideDown();
44
+ $('#field-_posts_per_page').hide('fast');
45
+ }
46
+ });
47
+
48
  $('#_carousel_slider_slide_type').on('change', function() {
49
+
50
+ $('#section_images_settings').hide('fast');
51
+ $('#section_url_images_settings').hide('fast');
52
+ $('#section_images_general_settings').hide('fast');
53
+ $('#section_post_query').hide('fast');
54
+ $('#section_video_settings').hide('fast');
55
+ $('#section_product_query').hide('fast');
56
+
57
  if (this.value == 'image-carousel') {
 
 
 
58
  $('#section_images_settings').slideDown();
59
+ $('#section_images_general_settings').slideDown();
60
  }
61
  if (this.value == 'image-carousel-url') {
 
 
 
62
  $('#section_url_images_settings').slideDown();
63
+ $('#section_images_general_settings').slideDown();
64
  }
65
  if (this.value == 'post-carousel') {
 
 
 
66
  $('#section_post_query').slideDown();
67
  }
68
  if (this.value == 'video-carousel') {
 
 
 
69
  $('#section_video_settings').slideDown();
70
  }
71
  });
72
 
73
  // Select2
74
  $("select.select2").each( function () {
 
75
  $(this).select2();
76
  });
77
 
292
  }
293
  return false;
294
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  })(jQuery);
assets/sass/admin/_meta-box.scss CHANGED
@@ -147,3 +147,14 @@
147
  }
148
  }
149
  }
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
  }
149
  }
150
+
151
+
152
+ // Hide Post carousel fields
153
+ // Related fields will be open by jQuery
154
+ #field-_post_date_after,
155
+ #field-_post_date_before,
156
+ #field-_post_categories,
157
+ #field-_post_tags,
158
+ #field-_post_in {
159
+ display: none;
160
+ }
carousel-slider.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Carousel Slider
4
  Plugin URI: http://wordpress.org/plugins/carousel-slider
5
  Description: Touch enabled WordPress plugin that lets you create beautiful responsive carousel slider.
6
- Version: 1.6.2
7
  Author: Sayful Islam
8
  Author URI: http://sayfulit.com
9
  Text Domain: carousel-slider
@@ -19,267 +19,269 @@ if ( ! defined( 'WPINC' ) ) {
19
 
20
  // Define Carousel Slider Version
21
  if ( ! defined( 'CAROUSEL_SLIDER_VERSION' ) ) {
22
- define( 'CAROUSEL_SLIDER_VERSION', '1.6.2' );
23
  }
24
 
25
- if( ! class_exists('Carousel_Slider') ):
26
-
27
- class Carousel_Slider
28
- {
29
- private $plugin_name;
30
- private $plugin_version;
31
- private $plugin_url;
32
- private $plugin_path;
33
-
34
- protected static $instance = null;
35
-
36
- /**
37
- * Main Carousel_Slider Instance
38
- *
39
- * Ensures only one instance of Carousel_Slider is loaded or can be loaded.
40
- *
41
- * @since 1.6.0
42
- * @static
43
- * @see Carousel_Slider()
44
- * @return Carousel_Slider - Main instance
45
- */
46
- public static function instance() {
47
- if ( is_null( self::$instance ) ) {
48
- self::$instance = new self();
 
 
49
  }
50
- return self::$instance;
51
- }
52
-
53
- public function __construct()
54
- {
55
- $this->plugin_name = 'carousel-slider';
56
- $this->plugin_version = CAROUSEL_SLIDER_VERSION;
57
-
58
- add_action('wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 15 );
59
- add_action('admin_enqueue_scripts', array( $this, 'admin_scripts' ), 10 );
60
- add_action('wp_footer', array( $this, 'inline_script'), 30);
61
- add_action('init', array( $this, 'load_textdomain' ) );
62
- add_filter('widget_text', 'do_shortcode');
63
- $this->includes();
64
- }
65
 
66
- public function load_textdomain()
67
- {
68
- // Set filter for plugin's languages directory
69
- $shaplatools_lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
70
-
71
- // Traditional WordPress plugin locale filter
72
- $locale = apply_filters( 'plugin_locale', get_locale(), 'carousel-slider' );
73
- $mofile = sprintf( '%1$s-%2$s.mo', 'carousel-slider', $locale );
74
-
75
- // Setup paths to current locale file
76
- $mofile_local = $shaplatools_lang_dir . $mofile;
77
- $mofile_global = WP_LANG_DIR . '/carousel-slider/' . $mofile;
78
-
79
- if ( file_exists( $mofile_global ) ) {
80
- // Look in global /wp-content/languages/carousel-slider folder
81
- load_textdomain( $this->plugin_name, $mofile_global );
82
- } elseif ( file_exists( $mofile_local ) ) {
83
- // Look in local /wp-content/plugins/carousel-slider/languages/ folder
84
- load_textdomain( $this->plugin_name, $mofile_local );
85
- } else {
86
- // Load the default language files
87
- load_plugin_textdomain( $this->plugin_name, false, $shaplatools_lang_dir );
88
  }
89
- }
90
 
91
- public function includes()
92
- {
93
- if ( is_admin() ) {
94
- $this->admin_includes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
- if ( ! is_admin() ) {
97
- $this->frontend_includes();
98
- }
99
-
100
- require_once $this->plugin_path() . '/widgets/widget-carousel_slider.php';
101
- }
102
-
103
- public function admin_includes()
104
- {
105
- require_once $this->plugin_path() . '/includes/class-carousel-slider-vc-element.php';
106
- require_once $this->plugin_path() . '/includes/class-carousel-slider-documentation.php';
107
- require_once $this->plugin_path() . '/includes/class-carousel-slider-form.php';
108
- require_once $this->plugin_path() . '/includes/class-carousel-slider-admin.php';
109
-
110
- new Carousel_Slider_Admin( $this->plugin_path(), $this->plugin_url() );
111
- }
112
-
113
- public function frontend_includes()
114
- {
115
- require_once $this->plugin_path() . '/shortcodes/class-carousel-slider-shortcode.php';
116
- require_once $this->plugin_path() . '/shortcodes/class-carousel-slider-deprecated-shortcode.php';
117
 
118
- new Carousel_Slider_Shortcode( $this->plugin_path(), $this->plugin_url() );
119
- new Carousel_Slider_Deprecated_Shortcode( $this->plugin_path() );
120
- }
 
 
 
 
 
121
 
122
- public function frontend_scripts()
123
- {
124
- wp_register_style( $this->plugin_name, $this->plugin_url() . '/assets/css/style.css', array(), $this->plugin_version, 'all' );
125
- wp_register_script( 'owl-carousel', $this->plugin_url() . '/assets/js/owl.carousel.min.js', array( 'jquery' ), '2.2.0', true );
 
 
 
126
 
127
- if( $this->has_shortcode('carousel_slide') || $this->has_shortcode( 'carousel') )
128
- {
129
- wp_enqueue_style( $this->plugin_name );
130
- wp_enqueue_script( 'owl-carousel' );
 
 
 
 
 
 
 
 
131
  }
132
- }
133
 
134
- public function admin_scripts( $hook )
135
- {
136
- global $post;
137
-
138
- if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
139
-
140
- if( is_a( $post, 'WP_Post' ) && 'carousels' == $post->post_type ) {
141
-
142
- wp_enqueue_style(
143
- $this->plugin_name . '-admin',
144
- $this->plugin_url() . '/assets/css/admin.css',
145
- array(),
146
- $this->plugin_version,
147
- 'all'
148
- );
149
-
150
- wp_enqueue_media();
151
- wp_enqueue_style( 'wp-color-picker' );
152
-
153
- wp_enqueue_script(
154
- 'select2',
155
- $this->plugin_url() . '/assets/js/select2.min.js',
156
- array( 'jquery' ),
157
- '4.0.3',
158
- true
159
- );
160
-
161
- wp_enqueue_script(
162
- 'livequery',
163
- $this->plugin_url() . '/assets/js/jquery.livequery.js',
164
- array( 'jquery' ),
165
- '1.3.6',
166
- true
167
- );
168
-
169
- wp_enqueue_script(
170
- $this->plugin_name . '-admin',
171
- $this->plugin_url() . '/assets/js/admin.js',
172
- array(
173
- 'jquery',
174
- 'wp-color-picker',
175
- 'jquery-ui-accordion',
176
- 'jquery-ui-datepicker',
177
- 'jquery-ui-sortable',
178
- 'select2',
179
- 'livequery'
180
- ),
181
- $this->plugin_version,
182
- true
183
- );
184
-
185
- wp_localize_script( $this->plugin_name . '-admin', 'CarouselSlider', array(
186
- 'post_id' => $post->ID,
187
- 'image_ids' => get_post_meta( $post->ID, '_wpdh_image_ids', true ),
188
- 'nonce' => wp_create_nonce( 'carousel_slider_ajax' ),
189
- 'create_btn_text' => __('Create Gallery', 'carousel-slider'),
190
- 'edit_btn_text' => __('Edit Gallery', 'carousel-slider'),
191
- 'save_btn_text' => __('Save Gallery', 'carousel-slider'),
192
- 'progress_btn_text' => __('Saving...', 'carousel-slider'),
193
- 'insert_btn_text' => __('Insert', 'carousel-slider'),
194
- 'video_frame_title' => __('Choose Video', 'carousel-slider'),
195
- ));
196
- }
197
- }
198
- }
199
 
200
- public function inline_script()
201
- {
202
- if( $this->has_shortcode('carousel_slide') || $this->has_shortcode( 'carousel') ):
203
- ?><script type="text/javascript">
204
- jQuery( document ).ready(function( $ ){
205
- $( 'body' ).find('.carousel-slider').each(function(){
206
- var _this = $(this);
207
- var isVideo = _this.data('slide-type') == 'video-carousel' ? true : false;
208
- var videoWidth = isVideo ? _this.data('video-width') : false;
209
- var videoHeight = isVideo ? _this.data('video-height') : false;
210
- var autoWidth = isVideo ? true : false;
211
- _this.owlCarousel({
212
- nav: _this.data('nav'),
213
- dots: _this.data('dots'),
214
- margin: _this.data('margin'),
215
- loop: _this.data('loop'),
216
- autoplay: _this.data('autoplay'),
217
- autoplayTimeout: _this.data('autoplay-timeout'),
218
- autoplaySpeed: _this.data('autoplay-speed'),
219
- autoplayHoverPause: _this.data('autoplay-hover-pause'),
220
- slideBy: _this.data('slide-by'),
221
- lazyLoad: _this.data('lazy-load'),
222
- video:isVideo,
223
- videoWidth: videoWidth,
224
- videoHeight: videoHeight,
225
- autoWidth: autoWidth,
226
- navText: [ _this.data('nav-previous-icon'), _this.data('nav-next-icon') ],
227
- responsive: {
228
- 320:{ items: _this.data('colums-mobile') },
229
- 600:{ items: _this.data('colums-small-tablet') },
230
- 768:{ items: _this.data('colums-tablet') },
231
- 993:{ items: _this.data('colums-small-desktop') },
232
- 1200:{items: _this.data('colums-desktop') },
233
- 1921:{items: _this.data('colums') }
234
- }
235
- });
236
- });
237
- });
238
- </script><?php
239
- endif;
240
- }
241
 
242
- private function has_shortcode( $shortcode )
243
- {
 
 
 
 
244
 
245
- if ( is_active_widget( false, false, 'widget_carousel_slider', true ) ) {
246
- return true;
247
  }
248
 
249
- global $post;
250
-
251
- if ( ! is_a( $post, 'WP_Post' ) ) {
252
- return false;
 
 
 
 
 
 
 
253
  }
254
 
255
- if ( ! has_shortcode( $post->post_content, $shortcode) ) {
256
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
 
259
- return true;
260
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
- /**
263
- * Plugin path.
264
- *
265
- * @return string Plugin path
266
- */
267
- private function plugin_path() {
268
- if ( $this->plugin_path ) return $this->plugin_path;
 
 
 
 
 
 
269
 
270
- return $this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
271
- }
 
 
 
 
 
 
 
 
 
 
272
 
273
- /**
274
- * Plugin url.
275
- *
276
- * @return string Plugin url
277
- */
278
- private function plugin_url() {
279
- if ( $this->plugin_url ) return $this->plugin_url;
280
- return $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
 
 
 
 
281
  }
282
- }
283
 
284
  endif;
285
 
@@ -290,22 +292,19 @@ endif;
290
  * then kicking off the plugin from this point in the file does
291
  * not affect the page life cycle.
292
  */
293
- Carousel_Slider::instance();
294
-
295
- /**
296
- * The code that runs during plugin deactivation.
297
- */
298
- function carousel_slider_deactivation() {
299
- flush_rewrite_rules();
300
- }
301
- register_deactivation_hook( __FILE__, 'carousel_slider_deactivation' );
302
-
303
- /**
304
- * The code that runs during plugin activation.
305
- */
306
- function carousel_slider_activation()
307
- {
308
- require_once plugin_dir_path( __FILE__ ) . 'includes/class-carousel-slider-activation.php';
309
- Carousel_Slider_Activation::activate();
310
  }
311
- register_activation_hook( __FILE__, 'carousel_slider_activation' );
3
  Plugin Name: Carousel Slider
4
  Plugin URI: http://wordpress.org/plugins/carousel-slider
5
  Description: Touch enabled WordPress plugin that lets you create beautiful responsive carousel slider.
6
+ Version: 1.6.3
7
  Author: Sayful Islam
8
  Author URI: http://sayfulit.com
9
  Text Domain: carousel-slider
19
 
20
  // Define Carousel Slider Version
21
  if ( ! defined( 'CAROUSEL_SLIDER_VERSION' ) ) {
22
+ define( 'CAROUSEL_SLIDER_VERSION', '1.6.3' );
23
  }
24
 
25
+ if ( ! class_exists( 'Carousel_Slider' ) ):
26
+
27
+ class Carousel_Slider {
28
+ private $plugin_name;
29
+ private $plugin_version;
30
+ private $plugin_url;
31
+ private $plugin_path;
32
+
33
+ protected static $instance = null;
34
+
35
+ /**
36
+ * Main Carousel_Slider Instance
37
+ *
38
+ * Ensures only one instance of Carousel_Slider is loaded or can be loaded.
39
+ *
40
+ * @since 1.6.0
41
+ * @static
42
+ * @see Carousel_Slider()
43
+ * @return Carousel_Slider - Main instance
44
+ */
45
+ public static function instance() {
46
+ if ( is_null( self::$instance ) ) {
47
+ self::$instance = new self();
48
+ }
49
+
50
+ return self::$instance;
51
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ /**
54
+ * Carousel_Slider constructor.
55
+ */
56
+ public function __construct() {
57
+ $this->plugin_name = 'carousel-slider';
58
+ $this->plugin_version = CAROUSEL_SLIDER_VERSION;
59
+
60
+ register_activation_hook( __FILE__, array( $this, 'activation' ) );
61
+ register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
62
+
63
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_scripts' ), 15 );
64
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 10 );
65
+ add_action( 'wp_footer', array( $this, 'inline_script' ), 30 );
66
+ add_action( 'init', array( $this, 'load_textdomain' ) );
67
+ add_filter( 'widget_text', 'do_shortcode' );
68
+ $this->includes();
 
 
 
 
 
 
69
  }
 
70
 
71
+ /**
72
+ * Load plugin textdomain
73
+ */
74
+ public function load_textdomain() {
75
+ // Set filter for plugin's languages directory
76
+ $shaplatools_lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
77
+
78
+ // Traditional WordPress plugin locale filter
79
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'carousel-slider' );
80
+ $mofile = sprintf( '%1$s-%2$s.mo', 'carousel-slider', $locale );
81
+
82
+ // Setup paths to current locale file
83
+ $mofile_local = $shaplatools_lang_dir . $mofile;
84
+ $mofile_global = WP_LANG_DIR . '/carousel-slider/' . $mofile;
85
+
86
+ if ( file_exists( $mofile_global ) ) {
87
+ // Look in global /wp-content/languages/carousel-slider folder
88
+ load_textdomain( $this->plugin_name, $mofile_global );
89
+ } elseif ( file_exists( $mofile_local ) ) {
90
+ // Look in local /wp-content/plugins/carousel-slider/languages/ folder
91
+ load_textdomain( $this->plugin_name, $mofile_local );
92
+ } else {
93
+ // Load the default language files
94
+ load_plugin_textdomain( $this->plugin_name, false, $shaplatools_lang_dir );
95
+ }
96
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
+ /**
99
+ * To be run when the plugin is activated
100
+ * @return void
101
+ */
102
+ public function activation() {
103
+ require_once $this->plugin_path() . '/includes/class-carousel-slider-activation.php';
104
+ Carousel_Slider_Activation::activate();
105
+ }
106
 
107
+ /**
108
+ * To be run when the plugin is deactivated
109
+ * @return void
110
+ */
111
+ public function deactivation() {
112
+ flush_rewrite_rules();
113
+ }
114
 
115
+ /**
116
+ * Include admin and front facing files
117
+ */
118
+ public function includes() {
119
+ if ( is_admin() ) {
120
+ $this->admin_includes();
121
+ }
122
+ if ( ! is_admin() ) {
123
+ $this->frontend_includes();
124
+ }
125
+
126
+ require_once $this->plugin_path() . '/widgets/widget-carousel_slider.php';
127
  }
 
128
 
129
+ /**
130
+ * Include admin files
131
+ */
132
+ public function admin_includes() {
133
+ require_once $this->plugin_path() . '/includes/class-carousel-slider-vc-element.php';
134
+ require_once $this->plugin_path() . '/includes/class-carousel-slider-documentation.php';
135
+ require_once $this->plugin_path() . '/includes/class-carousel-slider-form.php';
136
+ require_once $this->plugin_path() . '/includes/class-carousel-slider-admin.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
+ new Carousel_Slider_Admin( $this->plugin_path(), $this->plugin_url() );
139
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
+ /**
142
+ * Load front facing files
143
+ */
144
+ public function frontend_includes() {
145
+ require_once $this->plugin_path() . '/shortcodes/class-carousel-slider-shortcode.php';
146
+ require_once $this->plugin_path() . '/shortcodes/class-carousel-slider-deprecated-shortcode.php';
147
 
148
+ new Carousel_Slider_Shortcode( $this->plugin_path(), $this->plugin_url() );
149
+ new Carousel_Slider_Deprecated_Shortcode( $this->plugin_path() );
150
  }
151
 
152
+ /**
153
+ * Load frontend scripts
154
+ */
155
+ public function frontend_scripts() {
156
+ wp_register_style( $this->plugin_name, $this->plugin_url() . '/assets/css/style.css', array(), $this->plugin_version, 'all' );
157
+ wp_register_script( 'owl-carousel', $this->plugin_url() . '/assets/js/owl.carousel.min.js', array( 'jquery' ), '2.2.0', true );
158
+
159
+ if ( $this->should_load_scripts() ) {
160
+ wp_enqueue_style( $this->plugin_name );
161
+ wp_enqueue_script( 'owl-carousel' );
162
+ }
163
  }
164
 
165
+ /**
166
+ * Load admin scripts
167
+ * @param $hook
168
+ */
169
+ public function admin_scripts( $hook ) {
170
+ global $post;
171
+
172
+ if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
173
+
174
+ if ( is_a( $post, 'WP_Post' ) && 'carousels' == $post->post_type ) {
175
+
176
+ wp_enqueue_media();
177
+ wp_enqueue_style( 'wp-color-picker' );
178
+ wp_enqueue_style( $this->plugin_name . '-admin', $this->plugin_url() . '/assets/css/admin.css', array(), $this->plugin_version, 'all' );
179
+ wp_enqueue_script( 'select2', $this->plugin_url() . '/assets/js/select2.min.js', array( 'jquery' ), '4.0.3', true );
180
+ wp_enqueue_script( 'livequery', $this->plugin_url() . '/assets/js/jquery.livequery.js', array( 'jquery' ), '1.3.6', true );
181
+ wp_enqueue_script( $this->plugin_name . '-admin', $this->plugin_url() . '/assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-accordion', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'select2', 'livequery' ), $this->plugin_version, true );
182
+
183
+ wp_localize_script( $this->plugin_name . '-admin', 'CarouselSlider', array(
184
+ 'post_id' => $post->ID,
185
+ 'image_ids' => get_post_meta( $post->ID, '_wpdh_image_ids', true ),
186
+ 'nonce' => wp_create_nonce( 'carousel_slider_ajax' ),
187
+ 'create_btn_text' => __( 'Create Gallery', 'carousel-slider' ),
188
+ 'edit_btn_text' => __( 'Edit Gallery', 'carousel-slider' ),
189
+ 'save_btn_text' => __( 'Save Gallery', 'carousel-slider' ),
190
+ 'progress_btn_text' => __( 'Saving...', 'carousel-slider' ),
191
+ 'insert_btn_text' => __( 'Insert', 'carousel-slider' ),
192
+ 'video_frame_title' => __( 'Choose Video', 'carousel-slider' ),
193
+ ) );
194
+ }
195
+ }
196
  }
197
 
198
+ /**
199
+ * Load front end inline script
200
+ */
201
+ public function inline_script() {
202
+ if ( $this->should_load_scripts() ):
203
+ ?>
204
+ <script type="text/javascript">
205
+ jQuery(document).ready(function ($) {
206
+ if (jQuery().owlCarousel) {
207
+ $('body').find('.carousel-slider').each(function () {
208
+ var _this = $(this);
209
+ var isVideo = _this.data('slide-type') == 'video-carousel' ? true : false;
210
+ var videoWidth = isVideo ? _this.data('video-width') : false;
211
+ var videoHeight = isVideo ? _this.data('video-height') : false;
212
+ var autoWidth = isVideo ? true : false;
213
+ _this.owlCarousel({
214
+ nav: _this.data('nav'),
215
+ dots: _this.data('dots'),
216
+ margin: _this.data('margin'),
217
+ loop: _this.data('loop'),
218
+ autoplay: _this.data('autoplay'),
219
+ autoplayTimeout: _this.data('autoplay-timeout'),
220
+ autoplaySpeed: _this.data('autoplay-speed'),
221
+ autoplayHoverPause: _this.data('autoplay-hover-pause'),
222
+ slideBy: _this.data('slide-by'),
223
+ lazyLoad: _this.data('lazy-load'),
224
+ video: isVideo,
225
+ videoWidth: videoWidth,
226
+ videoHeight: videoHeight,
227
+ autoWidth: autoWidth,
228
+ navText: [_this.data('nav-previous-icon'), _this.data('nav-next-icon')],
229
+ responsive: {
230
+ 320: {items: _this.data('colums-mobile')},
231
+ 600: {items: _this.data('colums-small-tablet')},
232
+ 768: {items: _this.data('colums-tablet')},
233
+ 993: {items: _this.data('colums-small-desktop')},
234
+ 1200: {items: _this.data('colums-desktop')},
235
+ 1921: {items: _this.data('colums')}
236
+ }
237
+ });
238
+ });
239
+ }
240
+ });
241
+ </script><?php
242
+ endif;
243
+ }
244
 
245
+ /**
246
+ * Check if it should load frontend scripts
247
+ *
248
+ * @return mixed|void
249
+ */
250
+ private function should_load_scripts() {
251
+ global $post;
252
+ $load_scripts = is_active_widget( false, false, 'widget_carousel_slider', true ) ||
253
+ ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'carousel_slide' ) ) ||
254
+ ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'carousel' ) );
255
+
256
+ return apply_filters( 'carousel_slider_load_scripts', $load_scripts );
257
+ }
258
 
259
+ /**
260
+ * Plugin path.
261
+ *
262
+ * @return string Plugin path
263
+ */
264
+ private function plugin_path() {
265
+ if ( $this->plugin_path ) {
266
+ return $this->plugin_path;
267
+ }
268
+
269
+ return $this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
270
+ }
271
 
272
+ /**
273
+ * Plugin url.
274
+ *
275
+ * @return string Plugin url
276
+ */
277
+ private function plugin_url() {
278
+ if ( $this->plugin_url ) {
279
+ return $this->plugin_url;
280
+ }
281
+
282
+ return $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
283
+ }
284
  }
 
285
 
286
  endif;
287
 
292
  * then kicking off the plugin from this point in the file does
293
  * not affect the page life cycle.
294
  */
295
+ if ( defined( 'CAROUSEL_SLIDER_PRO_VERSION' ) ) {
296
+
297
+ add_action( 'admin_init', function(){
298
+ deactivate_plugins( plugin_basename( __FILE__ ) );
299
+ });
300
+
301
+ add_action( 'admin_notices', function () {
302
+ ?>
303
+ <div class="notice notice-error">
304
+ <p><?php _e( 'You can\'t activate the free version of Carousel Slider while you are using the premium one.', 'carousel-slider' ); ?></p>
305
+ </div>
306
+ <?php
307
+ } );
308
+ } else {
309
+ Carousel_Slider::instance();
 
 
310
  }
 
includes/class-carousel-slider-activation.php CHANGED
@@ -4,6 +4,9 @@ if ( ! class_exists('Carousel_Slider_Activation') ):
4
 
5
  class Carousel_Slider_Activation
6
  {
 
 
 
7
  public static function activate()
8
  {
9
  $version = get_option( 'carousel_slider_version' );
@@ -19,6 +22,9 @@ class Carousel_Slider_Activation
19
  flush_rewrite_rules();
20
  }
21
 
 
 
 
22
  public static function update_meta_160()
23
  {
24
  $carousels = get_posts( array(
4
 
5
  class Carousel_Slider_Activation
6
  {
7
+ /**
8
+ * Script that should load upon plugin activation
9
+ */
10
  public static function activate()
11
  {
12
  $version = get_option( 'carousel_slider_version' );
22
  flush_rewrite_rules();
23
  }
24
 
25
+ /**
26
+ * Update meta for prior to version 1.6.0
27
+ */
28
  public static function update_meta_160()
29
  {
30
  $carousels = get_posts( array(
includes/class-carousel-slider-admin.php CHANGED
@@ -8,12 +8,16 @@ if( ! class_exists('Carousel_Slider_Admin') ):
8
 
9
  class Carousel_Slider_Admin
10
  {
11
- // use Carousel_Slider_Form;
12
-
13
  private $plugin_path;
14
  private $plugin_url;
15
  private $form;
16
 
 
 
 
 
 
 
17
  public function __construct( $plugin_path, $plugin_url )
18
  {
19
  $this->plugin_path = $plugin_path;
@@ -36,6 +40,9 @@ class Carousel_Slider_Admin
36
  add_filter("attachment_fields_to_save", array( $this, "attachment_fields_to_save" ), null, 2);
37
  }
38
 
 
 
 
39
  public function carousel_post_type() {
40
  $labels = array(
41
  'name' => _x( 'Slides', 'Post Type General Name', 'carousel-slider' ),
@@ -75,6 +82,14 @@ class Carousel_Slider_Admin
75
  register_post_type( 'carousels', $args );
76
  }
77
 
 
 
 
 
 
 
 
 
78
  public function post_row_actions( $actions, $post )
79
  {
80
  global $current_screen;
@@ -87,6 +102,11 @@ class Carousel_Slider_Admin
87
  return $actions;
88
  }
89
 
 
 
 
 
 
90
  public function columns_head(){
91
 
92
  $columns = array(
@@ -100,6 +120,12 @@ class Carousel_Slider_Admin
100
 
101
  }
102
 
 
 
 
 
 
 
103
  public function columns_content($column, $post_id) {
104
  switch ($column) {
105
 
@@ -127,6 +153,9 @@ class Carousel_Slider_Admin
127
  }
128
  }
129
 
 
 
 
130
  public function add_meta_boxes()
131
  {
132
  add_meta_box(
@@ -139,6 +168,9 @@ class Carousel_Slider_Admin
139
  );
140
  }
141
 
 
 
 
142
  public function carousel_slider_meta_boxes()
143
  {
144
  wp_nonce_field( 'carousel_slider_nonce', '_carousel_slider_nonce' );
@@ -148,16 +180,20 @@ class Carousel_Slider_Admin
148
  $slide_type = in_array($slide_type, array('image-carousel', 'post-carousel', 'image-carousel-url', 'video-carousel')) ? $slide_type : 'image-carousel';
149
 
150
  require_once $this->plugin_path . '/templates/admin/types.php';
151
- require_once $this->plugin_path . '/templates/admin/images.php';
152
- require_once $this->plugin_path . '/templates/admin/images-carousel-url.php';
153
  require_once $this->plugin_path . '/templates/admin/post-carousel.php';
154
  require_once $this->plugin_path . '/templates/admin/video-carousel.php';
 
155
  require_once $this->plugin_path . '/templates/admin/general.php';
156
  require_once $this->plugin_path . '/templates/admin/navigation.php';
157
  require_once $this->plugin_path . '/templates/admin/autoplay.php';
158
  require_once $this->plugin_path . '/templates/admin/responsive.php';
159
  }
160
 
 
 
 
161
  public function shortcode_usage_info()
162
  {
163
  add_meta_box(
@@ -170,6 +206,9 @@ class Carousel_Slider_Admin
170
  );
171
  }
172
 
 
 
 
173
  public function render_meta_box_shortcode_info()
174
  {
175
  ob_start(); ?>
8
 
9
  class Carousel_Slider_Admin
10
  {
 
 
11
  private $plugin_path;
12
  private $plugin_url;
13
  private $form;
14
 
15
+ /**
16
+ * Carousel_Slider_Admin constructor.
17
+ *
18
+ * @param $plugin_path
19
+ * @param $plugin_url
20
+ */
21
  public function __construct( $plugin_path, $plugin_url )
22
  {
23
  $this->plugin_path = $plugin_path;
40
  add_filter("attachment_fields_to_save", array( $this, "attachment_fields_to_save" ), null, 2);
41
  }
42
 
43
+ /**
44
+ * Carousel slider post type
45
+ */
46
  public function carousel_post_type() {
47
  $labels = array(
48
  'name' => _x( 'Slides', 'Post Type General Name', 'carousel-slider' ),
82
  register_post_type( 'carousels', $args );
83
  }
84
 
85
+ /**
86
+ * Hide view and quick edit from carousel slider admin
87
+ *
88
+ * @param $actions
89
+ * @param $post
90
+ *
91
+ * @return mixed
92
+ */
93
  public function post_row_actions( $actions, $post )
94
  {
95
  global $current_screen;
102
  return $actions;
103
  }
104
 
105
+ /**
106
+ * Customize Carousel slider list table head
107
+ *
108
+ * @return array
109
+ */
110
  public function columns_head(){
111
 
112
  $columns = array(
120
 
121
  }
122
 
123
+ /**
124
+ * Generate carousel slider list table content
125
+ *
126
+ * @param $column
127
+ * @param $post_id
128
+ */
129
  public function columns_content($column, $post_id) {
130
  switch ($column) {
131
 
153
  }
154
  }
155
 
156
+ /**
157
+ * Add carousel slider meta box
158
+ */
159
  public function add_meta_boxes()
160
  {
161
  add_meta_box(
168
  );
169
  }
170
 
171
+ /**
172
+ * Load metabox content
173
+ */
174
  public function carousel_slider_meta_boxes()
175
  {
176
  wp_nonce_field( 'carousel_slider_nonce', '_carousel_slider_nonce' );
180
  $slide_type = in_array($slide_type, array('image-carousel', 'post-carousel', 'image-carousel-url', 'video-carousel')) ? $slide_type : 'image-carousel';
181
 
182
  require_once $this->plugin_path . '/templates/admin/types.php';
183
+ require_once $this->plugin_path . '/templates/admin/images-media.php';
184
+ require_once $this->plugin_path . '/templates/admin/images-url.php';
185
  require_once $this->plugin_path . '/templates/admin/post-carousel.php';
186
  require_once $this->plugin_path . '/templates/admin/video-carousel.php';
187
+ require_once $this->plugin_path . '/templates/admin/images-settings.php';
188
  require_once $this->plugin_path . '/templates/admin/general.php';
189
  require_once $this->plugin_path . '/templates/admin/navigation.php';
190
  require_once $this->plugin_path . '/templates/admin/autoplay.php';
191
  require_once $this->plugin_path . '/templates/admin/responsive.php';
192
  }
193
 
194
+ /**
195
+ * Metabox for shortcode information
196
+ */
197
  public function shortcode_usage_info()
198
  {
199
  add_meta_box(
206
  );
207
  }
208
 
209
+ /**
210
+ * Render shortcode metabox content
211
+ */
212
  public function render_meta_box_shortcode_info()
213
  {
214
  ob_start(); ?>
includes/class-carousel-slider-form.php CHANGED
@@ -8,6 +8,11 @@ if( ! class_exists('Carousel_Slider_Form') ):
8
 
9
  class Carousel_Slider_Form
10
  {
 
 
 
 
 
11
  public function text( array $args )
12
  {
13
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -18,6 +23,12 @@ class Carousel_Slider_Form
18
  echo sprintf( '<input type="text" class="sp-input-text" value="%1$s" id="%2$s" name="%3$s">', $value, $args['id'], $name);
19
  echo $this->field_after();
20
  }
 
 
 
 
 
 
21
  public function textarea( array $args )
22
  {
23
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -31,6 +42,11 @@ class Carousel_Slider_Form
31
  echo $this->field_after();
32
  }
33
 
 
 
 
 
 
34
  public function color( array $args )
35
  {
36
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -43,6 +59,11 @@ class Carousel_Slider_Form
43
  echo $this->field_after();
44
  }
45
 
 
 
 
 
 
46
  public function date( array $args )
47
  {
48
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -55,6 +76,10 @@ class Carousel_Slider_Form
55
  echo $this->field_after();
56
  }
57
 
 
 
 
 
58
  public function number( array $args )
59
  {
60
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -68,6 +93,11 @@ class Carousel_Slider_Form
68
  echo $this->field_after();
69
  }
70
 
 
 
 
 
 
71
  public function checkbox( array $args )
72
  {
73
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -82,6 +112,11 @@ class Carousel_Slider_Form
82
  echo $this->field_after();
83
  }
84
 
 
 
 
 
 
85
  public function select( $args )
86
  {
87
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -100,6 +135,11 @@ class Carousel_Slider_Form
100
  echo $this->field_after();
101
  }
102
 
 
 
 
 
 
103
  public function posts_list( $args )
104
  {
105
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -120,6 +160,11 @@ class Carousel_Slider_Form
120
  echo $this->field_after();
121
  }
122
 
 
 
 
 
 
123
  public function images_gallery( $args )
124
  {
125
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -146,6 +191,11 @@ class Carousel_Slider_Form
146
  echo $html;
147
  }
148
 
 
 
 
 
 
149
  public function images_url( array $args )
150
  {
151
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -158,7 +208,9 @@ class Carousel_Slider_Form
158
  $html .= '<ul class="carousel_slider_url_images_list">';
159
  if ( is_array($value) && count($value) > 0){
160
  foreach ($value as $image ) {
161
- $html .= sprintf('<li><img src="%s" alt="%s" width="75" height="75"></li>', $image['url'], $image['alt']);
 
 
162
  }
163
  }
164
  $html .= '</ul>';
@@ -166,6 +218,10 @@ class Carousel_Slider_Form
166
  echo $html;
167
  }
168
 
 
 
 
 
169
  public function file( array $args )
170
  {
171
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -178,6 +234,11 @@ class Carousel_Slider_Form
178
  echo $this->field_after();
179
  }
180
 
 
 
 
 
 
181
  public function image_sizes( array $args )
182
  {
183
  if( ! isset( $args['id'], $args['name'] ) ) return;
@@ -220,6 +281,11 @@ class Carousel_Slider_Form
220
  echo $this->field_after();
221
  }
222
 
 
 
 
 
 
223
  public function post_terms( array $args )
224
  {
225
  global $wp_version;
@@ -253,6 +319,13 @@ class Carousel_Slider_Form
253
  echo $this->field_after();
254
  }
255
 
 
 
 
 
 
 
 
256
  private function field_common( $args )
257
  {
258
  global $post;
@@ -273,6 +346,13 @@ class Carousel_Slider_Form
273
  return array( $name, $value );
274
  }
275
 
 
 
 
 
 
 
 
276
  private function field_before( $args )
277
  {
278
  $table = sprintf( '<div class="sp-input-group" id="field-%s">', $args['id'] );
@@ -286,6 +366,11 @@ class Carousel_Slider_Form
286
  return $table;
287
  }
288
 
 
 
 
 
 
289
  private function field_after()
290
  {
291
  return '</div></div>';
8
 
9
  class Carousel_Slider_Form
10
  {
11
+ /**
12
+ * Generate text input field
13
+ *
14
+ * @param array $args
15
+ */
16
  public function text( array $args )
17
  {
18
  if( ! isset( $args['id'], $args['name'] ) ) return;
23
  echo sprintf( '<input type="text" class="sp-input-text" value="%1$s" id="%2$s" name="%3$s">', $value, $args['id'], $name);
24
  echo $this->field_after();
25
  }
26
+
27
+ /**
28
+ * Generate textarea input field
29
+ *
30
+ * @param array $args
31
+ */
32
  public function textarea( array $args )
33
  {
34
  if( ! isset( $args['id'], $args['name'] ) ) return;
42
  echo $this->field_after();
43
  }
44
 
45
+ /**
46
+ * Generate color input field
47
+ *
48
+ * @param array $args
49
+ */
50
  public function color( array $args )
51
  {
52
  if( ! isset( $args['id'], $args['name'] ) ) return;
59
  echo $this->field_after();
60
  }
61
 
62
+ /**
63
+ * Generate date input field
64
+ *
65
+ * @param array $args
66
+ */
67
  public function date( array $args )
68
  {
69
  if( ! isset( $args['id'], $args['name'] ) ) return;
76
  echo $this->field_after();
77
  }
78
 
79
+ /**
80
+ * Generate number input field
81
+ * @param array $args
82
+ */
83
  public function number( array $args )
84
  {
85
  if( ! isset( $args['id'], $args['name'] ) ) return;
93
  echo $this->field_after();
94
  }
95
 
96
+ /**
97
+ * Generate checkbox input field
98
+ *
99
+ * @param array $args
100
+ */
101
  public function checkbox( array $args )
102
  {
103
  if( ! isset( $args['id'], $args['name'] ) ) return;
112
  echo $this->field_after();
113
  }
114
 
115
+ /**
116
+ * Generate select input field
117
+ *
118
+ * @param $args
119
+ */
120
  public function select( $args )
121
  {
122
  if( ! isset( $args['id'], $args['name'] ) ) return;
135
  echo $this->field_after();
136
  }
137
 
138
+ /**
139
+ * Generate select field for post list
140
+ *
141
+ * @param $args
142
+ */
143
  public function posts_list( $args )
144
  {
145
  if( ! isset( $args['id'], $args['name'] ) ) return;
160
  echo $this->field_after();
161
  }
162
 
163
+ /**
164
+ * Generate field for image galleries
165
+ *
166
+ * @param $args
167
+ */
168
  public function images_gallery( $args )
169
  {
170
  if( ! isset( $args['id'], $args['name'] ) ) return;
191
  echo $html;
192
  }
193
 
194
+ /**
195
+ * Generate gallery from images url
196
+ *
197
+ * @param array $args
198
+ */
199
  public function images_url( array $args )
200
  {
201
  if( ! isset( $args['id'], $args['name'] ) ) return;
208
  $html .= '<ul class="carousel_slider_url_images_list">';
209
  if ( is_array($value) && count($value) > 0){
210
  foreach ($value as $image ) {
211
+ if (filter_var($image['url'], FILTER_VALIDATE_URL)) {
212
+ $html .= sprintf('<li><img src="%s" alt="%s" width="75" height="75"></li>', esc_url($image['url']), $image['alt']);
213
+ }
214
  }
215
  }
216
  $html .= '</ul>';
218
  echo $html;
219
  }
220
 
221
+ /**
222
+ * Generate field for file
223
+ * @param array $args
224
+ */
225
  public function file( array $args )
226
  {
227
  if( ! isset( $args['id'], $args['name'] ) ) return;
234
  echo $this->field_after();
235
  }
236
 
237
+ /**
238
+ * Generate select field for available image sizes
239
+ *
240
+ * @param array $args
241
+ */
242
  public function image_sizes( array $args )
243
  {
244
  if( ! isset( $args['id'], $args['name'] ) ) return;
281
  echo $this->field_after();
282
  }
283
 
284
+ /**
285
+ * Generate field for post terms
286
+ *
287
+ * @param array $args
288
+ */
289
  public function post_terms( array $args )
290
  {
291
  global $wp_version;
319
  echo $this->field_after();
320
  }
321
 
322
+ /**
323
+ * Generate name for value for input fields
324
+ *
325
+ * @param $args
326
+ *
327
+ * @return array
328
+ */
329
  private function field_common( $args )
330
  {
331
  global $post;
346
  return array( $name, $value );
347
  }
348
 
349
+ /**
350
+ * Generate field before content
351
+ *
352
+ * @param $args
353
+ *
354
+ * @return string
355
+ */
356
  private function field_before( $args )
357
  {
358
  $table = sprintf( '<div class="sp-input-group" id="field-%s">', $args['id'] );
366
  return $table;
367
  }
368
 
369
+ /**
370
+ * Generate field after content
371
+ *
372
+ * @return string
373
+ */
374
  private function field_after()
375
  {
376
  return '</div></div>';
includes/class-carousel-slider-vc-element.php CHANGED
@@ -8,12 +8,18 @@ if( ! class_exists('Carousel_Slider_VC_Element') ):
8
 
9
  class Carousel_Slider_VC_Element
10
  {
11
- public function __construct() {
 
 
 
12
  // We safely integrate with VC with this hook
13
- add_action( 'init', array( $this, 'integrateWithVC' ) );
14
  }
15
-
16
- public function integrateWithVC() {
 
 
 
17
  // Check if Visual Composer is installed
18
  if ( ! defined( 'WPB_VC_VERSION' ) ) {
19
  return;
@@ -39,7 +45,12 @@ class Carousel_Slider_VC_Element
39
  ));
40
  }
41
 
42
- private function carousels_list()
 
 
 
 
 
43
  {
44
  $carousels = get_posts( array(
45
  'post_type' => 'carousels',
8
 
9
  class Carousel_Slider_VC_Element
10
  {
11
+ /**
12
+ * Carousel_Slider_VC_Element constructor.
13
+ */
14
+ public function __construct() {
15
  // We safely integrate with VC with this hook
16
+ add_action( 'init', array( $this, 'integrate_with_vc' ) );
17
  }
18
+
19
+ /**
20
+ * Integrate with visual composer
21
+ */
22
+ public function integrate_with_vc() {
23
  // Check if Visual Composer is installed
24
  if ( ! defined( 'WPB_VC_VERSION' ) ) {
25
  return;
45
  ));
46
  }
47
 
48
+ /**
49
+ * Generate array for carousel slider
50
+ *
51
+ * @return array
52
+ */
53
+ private function carousels_list()
54
  {
55
  $carousels = get_posts( array(
56
  'post_type' => 'carousels',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: widget, shortcode, images, carousel, carousel slider, image carousel, slid
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3LZWQTHEVYWCY
5
  Requires at least: 3.5
6
  Tested up to: 4.8
7
- Stable tag: 1.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -74,6 +74,12 @@ Do you have questions or issues with Carousel Slider? [Ask for support here](htt
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
77
  = version 1.6.2 - 2017-01-27 =
78
  * Fixed - Removed PHP trait to add support to PHP 5.3 as some users still use PHP 5.3
79
  * Fixed - Fixed issue to make all carousel slider type to **Image Carousel** on activation.
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3LZWQTHEVYWCY
5
  Requires at least: 3.5
6
  Tested up to: 4.8
7
+ Stable tag: 1.6.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
74
 
75
  == Changelog ==
76
 
77
+ = version 1.6.3 - 2017-01-31 =
78
+ * Added - Added title option for carousel slider widget.
79
+ * Tweak - Tweak at post carousel admin interface.
80
+ * Tweak - Added new carousel_slider_load_scripts filter hook for modifying scripts load conditions.
81
+ * And some other tweak for coding improvement.
82
+
83
  = version 1.6.2 - 2017-01-27 =
84
  * Fixed - Removed PHP trait to add support to PHP 5.3 as some users still use PHP 5.3
85
  * Fixed - Fixed issue to make all carousel slider type to **Image Carousel** on activation.
shortcodes/class-carousel-slider-deprecated-shortcode.php CHANGED
@@ -10,6 +10,11 @@ class Carousel_Slider_Deprecated_Shortcode
10
  {
11
  private $plugin_path;
12
 
 
 
 
 
 
13
  public function __construct( $plugin_path )
14
  {
15
  $this->plugin_path = $plugin_path;
10
  {
11
  private $plugin_path;
12
 
13
+ /**
14
+ * Carousel_Slider_Deprecated_Shortcode constructor.
15
+ *
16
+ * @param $plugin_path
17
+ */
18
  public function __construct( $plugin_path )
19
  {
20
  $this->plugin_path = $plugin_path;
shortcodes/class-carousel-slider-shortcode.php CHANGED
@@ -11,6 +11,12 @@ class Carousel_Slider_Shortcode
11
  private $plugin_path;
12
  private $plugin_url;
13
 
 
 
 
 
 
 
14
  public function __construct( $plugin_path, $plugin_url )
15
  {
16
  $this->plugin_path = $plugin_path;
@@ -75,6 +81,13 @@ class Carousel_Slider_Shortcode
75
  return;
76
  }
77
 
 
 
 
 
 
 
 
78
  private function carousel_options( $id )
79
  {
80
  $_nav_color = get_post_meta( $id, '_nav_color', true );
@@ -114,6 +127,15 @@ class Carousel_Slider_Shortcode
114
  return $this->array_to_data( $options_array );
115
  }
116
 
 
 
 
 
 
 
 
 
 
117
  public function get_meta( $id, $key, $default = null )
118
  {
119
  $meta = get_post_meta( $id, $key, true );
@@ -130,6 +152,13 @@ class Carousel_Slider_Shortcode
130
  return esc_attr( $meta );
131
  }
132
 
 
 
 
 
 
 
 
133
  public function array_to_data( $array )
134
  {
135
 
@@ -175,6 +204,13 @@ class Carousel_Slider_Shortcode
175
  return false;
176
  }
177
 
 
 
 
 
 
 
 
178
  public function video_url( $url ) {
179
  if( ! $this->is_valid_url( $url )){
180
  return;
@@ -193,16 +229,33 @@ class Carousel_Slider_Shortcode
193
  return;
194
  }
195
 
 
 
 
 
 
196
  public function nav_previous_icon()
197
  {
198
  return '<svg class="carousel-slider-nav-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="48" viewBox="0 0 11 28"><path d="M9.8 8.5c0 0.1-0.1 0.3-0.2 0.4l-6.1 6.1 6.1 6.1c0.1 0.1 0.2 0.2 0.2 0.4s-0.1 0.3-0.2 0.4l-0.8 0.8c-0.1 0.1-0.2 0.2-0.4 0.2s-0.3-0.1-0.4-0.2l-7.3-7.3c-0.1-0.1-0.2-0.2-0.2-0.4s0.1-0.3 0.2-0.4l7.3-7.3c0.1-0.1 0.2-0.2 0.4-0.2s0.3 0.1 0.4 0.2l0.8 0.8c0.1 0.1 0.2 0.2 0.2 0.4z"/></svg>';
199
  }
200
 
 
 
 
 
 
201
  public function nav_next_icon()
202
  {
203
  return '<svg class="carousel-slider-nav-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="48" viewBox="0 0 9 28"><path d="M9.3 15c0 0.1-0.1 0.3-0.2 0.4l-7.3 7.3c-0.1 0.1-0.2 0.2-0.4 0.2s-0.3-0.1-0.4-0.2l-0.8-0.8c-0.1-0.1-0.2-0.2-0.2-0.4 0-0.1 0.1-0.3 0.2-0.4l6.1-6.1-6.1-6.1c-0.1-0.1-0.2-0.2-0.2-0.4s0.1-0.3 0.2-0.4l0.8-0.8c0.1-0.1 0.2-0.2 0.4-0.2s0.3 0.1 0.4 0.2l7.3 7.3c0.1 0.1 0.2 0.2 0.2 0.4z"/></svg>';
204
  }
205
 
 
 
 
 
 
 
 
206
  public function filter_posts( $posts )
207
  {
208
  if ( ! is_array( $posts ) ) {
11
  private $plugin_path;
12
  private $plugin_url;
13
 
14
+ /**
15
+ * Carousel_Slider_Shortcode constructor.
16
+ *
17
+ * @param $plugin_path
18
+ * @param $plugin_url
19
+ */
20
  public function __construct( $plugin_path, $plugin_url )
21
  {
22
  $this->plugin_path = $plugin_path;
81
  return;
82
  }
83
 
84
+ /**
85
+ * Generate carousel options for slider
86
+ *
87
+ * @param $id
88
+ *
89
+ * @return array
90
+ */
91
  private function carousel_options( $id )
92
  {
93
  $_nav_color = get_post_meta( $id, '_nav_color', true );
127
  return $this->array_to_data( $options_array );
128
  }
129
 
130
+ /**
131
+ * Get post meta by id and key
132
+ *
133
+ * @param $id
134
+ * @param $key
135
+ * @param null $default
136
+ *
137
+ * @return string|void
138
+ */
139
  public function get_meta( $id, $key, $default = null )
140
  {
141
  $meta = get_post_meta( $id, $key, true );
152
  return esc_attr( $meta );
153
  }
154
 
155
+ /**
156
+ * Convert array to html data attribute
157
+ *
158
+ * @param $array
159
+ *
160
+ * @return array
161
+ */
162
  public function array_to_data( $array )
163
  {
164
 
204
  return false;
205
  }
206
 
207
+ /**
208
+ * Convert url to youtube and vimeo video link
209
+ *
210
+ * @param $url
211
+ *
212
+ * @return string|void
213
+ */
214
  public function video_url( $url ) {
215
  if( ! $this->is_valid_url( $url )){
216
  return;
229
  return;
230
  }
231
 
232
+ /**
233
+ * Previous navigation icon
234
+ *
235
+ * @return string
236
+ */
237
  public function nav_previous_icon()
238
  {
239
  return '<svg class="carousel-slider-nav-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="48" viewBox="0 0 11 28"><path d="M9.8 8.5c0 0.1-0.1 0.3-0.2 0.4l-6.1 6.1 6.1 6.1c0.1 0.1 0.2 0.2 0.2 0.4s-0.1 0.3-0.2 0.4l-0.8 0.8c-0.1 0.1-0.2 0.2-0.4 0.2s-0.3-0.1-0.4-0.2l-7.3-7.3c-0.1-0.1-0.2-0.2-0.2-0.4s0.1-0.3 0.2-0.4l7.3-7.3c0.1-0.1 0.2-0.2 0.4-0.2s0.3 0.1 0.4 0.2l0.8 0.8c0.1 0.1 0.2 0.2 0.2 0.4z"/></svg>';
240
  }
241
 
242
+ /**
243
+ * Next navigation icon
244
+ *
245
+ * @return string
246
+ */
247
  public function nav_next_icon()
248
  {
249
  return '<svg class="carousel-slider-nav-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="48" viewBox="0 0 9 28"><path d="M9.3 15c0 0.1-0.1 0.3-0.2 0.4l-7.3 7.3c-0.1 0.1-0.2 0.2-0.4 0.2s-0.3-0.1-0.4-0.2l-0.8-0.8c-0.1-0.1-0.2-0.2-0.2-0.4 0-0.1 0.1-0.3 0.2-0.4l6.1-6.1-6.1-6.1c-0.1-0.1-0.2-0.2-0.2-0.4s0.1-0.3 0.2-0.4l0.8-0.8c0.1-0.1 0.2-0.2 0.4-0.2s0.3 0.1 0.4 0.2l7.3 7.3c0.1 0.1 0.2 0.2 0.2 0.4z"/></svg>';
250
  }
251
 
252
+ /**
253
+ * Filter posts data
254
+ *
255
+ * @param $posts
256
+ *
257
+ * @return array|void
258
+ */
259
  public function filter_posts( $posts )
260
  {
261
  if ( ! is_array( $posts ) ) {
templates/admin/general.php CHANGED
@@ -5,6 +5,18 @@
5
  <div class="shapla-toggle-inner">
6
  <div class="shapla-toggle-content">
7
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
8
  $this->form->text( array(
9
  'id' => '_slide_by',
10
  'name' => __('Slide By', 'carousel-slider'),
@@ -24,42 +36,6 @@
24
  'desc' => __('Check to show inifnity loop. Duplicate last and first items to get loop illusion', 'carousel-slider'),
25
  'std' => 'on'
26
  ));
27
- $this->form->checkbox(array(
28
- 'id' => '_lazy_load_image',
29
- 'name' => __('Lazy load image', 'carousel-slider'),
30
- 'label' => __('Lazy load image.', 'carousel-slider'),
31
- 'desc' => __('Check to enable image lazy load.', 'carousel-slider'),
32
- 'std' => 'off'
33
- ));
34
- $this->form->checkbox(array(
35
- 'id' => '_show_attachment_title',
36
- 'name' => __('Show Image Title', 'carousel-slider'),
37
- 'label' => __('Show Image Title', 'carousel-slider'),
38
- 'desc' => __('Check to show title below image. Only works with image carousel.', 'carousel-slider'),
39
- 'std' => 'off'
40
- ));
41
- $this->form->checkbox(array(
42
- 'id' => '_show_attachment_caption',
43
- 'name' => __('Show Image Caption', 'carousel-slider'),
44
- 'label' => __('Show Image Caption', 'carousel-slider'),
45
- 'desc' => __('Check to show caption below image. Only works with image carousel.', 'carousel-slider'),
46
- 'std' => 'off'
47
- ));
48
- $this->form->image_sizes(array(
49
- 'id' => __('_image_size', 'carousel-slider'),
50
- 'name' => __('Carousel Image size', 'carousel-slider'),
51
- 'desc' => sprintf(__( 'Select "original uploaded image" for full size image or your desired image size for carousel image. You can change the default size for thumbnail, medium and large from %1$s Settings >> Media %2$s.', 'carousel-slider' ),'<a target="_blank" href="'.get_admin_url().'options-media.php">','</a>'),
52
- ));
53
- $this->form->select(array(
54
- 'id' => '_image_target',
55
- 'name' => __('Image Target', 'carousel-slider'),
56
- 'desc' => __('Choose where to open the linked image. (For Image Carousel)', 'carousel-slider'),
57
- 'std' => '_self',
58
- 'options' => array(
59
- '_self' => __('Open in the same frame as it was clicked', 'carousel-slider'),
60
- '_blank' => __('Open in a new window or tab', 'carousel-slider'),
61
- ),
62
- ));
63
  ?>
64
  </div>
65
  </div>
5
  <div class="shapla-toggle-inner">
6
  <div class="shapla-toggle-content">
7
  <?php
8
+ $this->form->image_sizes(array(
9
+ 'id' => __('_image_size', 'carousel-slider'),
10
+ 'name' => __('Carousel Image size', 'carousel-slider'),
11
+ 'desc' => sprintf(__( 'Select "original uploaded image" for full size image or your desired image size for carousel image. You can change the default size for thumbnail, medium and large from %1$s Settings >> Media %2$s.', 'carousel-slider' ),'<a target="_blank" href="'.get_admin_url().'options-media.php">','</a>'),
12
+ ));
13
+ $this->form->checkbox(array(
14
+ 'id' => '_lazy_load_image',
15
+ 'name' => __('Lazy load image', 'carousel-slider'),
16
+ 'label' => __('Lazy load image.', 'carousel-slider'),
17
+ 'desc' => __('Check to enable image lazy load.', 'carousel-slider'),
18
+ 'std' => 'off'
19
+ ));
20
  $this->form->text( array(
21
  'id' => '_slide_by',
22
  'name' => __('Slide By', 'carousel-slider'),
36
  'desc' => __('Check to show inifnity loop. Duplicate last and first items to get loop illusion', 'carousel-slider'),
37
  'std' => 'on'
38
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ?>
40
  </div>
41
  </div>
templates/admin/{images.php → images-media.php} RENAMED
@@ -1,6 +1,6 @@
1
  <div data-id="open" id="section_images_settings" class="shapla-toggle shapla-toggle--stroke" style="display: <?php echo $slide_type != 'image-carousel' ? 'none' : 'block'; ?>">
2
  <span class="shapla-toggle-title">
3
- <?php _e('Media Images Settings', 'carousel-slider'); ?>
4
  </span>
5
  <div class="shapla-toggle-inner">
6
  <div class="shapla-toggle-content">
1
  <div data-id="open" id="section_images_settings" class="shapla-toggle shapla-toggle--stroke" style="display: <?php echo $slide_type != 'image-carousel' ? 'none' : 'block'; ?>">
2
  <span class="shapla-toggle-title">
3
+ <?php _e('Media Images', 'carousel-slider'); ?>
4
  </span>
5
  <div class="shapla-toggle-inner">
6
  <div class="shapla-toggle-content">
templates/admin/images-settings.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $img_settings = ($slide_type == 'image-carousel') || ($slide_type == 'image-carousel-url') ? true : false;?>
2
+ <div data-id="open" id="section_images_general_settings" class="shapla-toggle shapla-toggle--stroke" style="display: <?php echo !$img_settings ? 'none' : 'block'; ?>">
3
+ <span class="shapla-toggle-title">
4
+ <?php _e('Image Carousel Settings', 'carousel-slider'); ?>
5
+ </span>
6
+ <div class="shapla-toggle-inner">
7
+ <div class="shapla-toggle-content">
8
+ <?php
9
+ $this->form->checkbox(array(
10
+ 'id' => '_show_attachment_title',
11
+ 'name' => __('Show Image Title', 'carousel-slider'),
12
+ 'label' => __('Show Image Title', 'carousel-slider'),
13
+ 'desc' => __('Check to show title below image. Only works with image carousel.', 'carousel-slider'),
14
+ 'std' => 'off'
15
+ ));
16
+ $this->form->checkbox(array(
17
+ 'id' => '_show_attachment_caption',
18
+ 'name' => __('Show Image Caption', 'carousel-slider'),
19
+ 'label' => __('Show Image Caption', 'carousel-slider'),
20
+ 'desc' => __('Check to show caption below image. Only works with image carousel.', 'carousel-slider'),
21
+ 'std' => 'off'
22
+ ));
23
+ $this->form->select(array(
24
+ 'id' => '_image_target',
25
+ 'name' => __('Image Target', 'carousel-slider'),
26
+ 'desc' => __('Choose where to open the linked image.', 'carousel-slider'),
27
+ 'std' => '_self',
28
+ 'options' => array(
29
+ '_self' => __('Open in the same frame as it was clicked', 'carousel-slider'),
30
+ '_blank' => __('Open in a new window or tab', 'carousel-slider'),
31
+ ),
32
+ ));
33
+ ?>
34
+ </div>
35
+ </div>
36
+ </div>
templates/admin/{images-carousel-url.php → images-url.php} RENAMED
@@ -4,7 +4,7 @@ $btn_text = $_images_urls ? 'Edit URLs' : 'Add URLs';
4
  ?>
5
  <div data-id="open" id="section_url_images_settings" class="shapla-toggle shapla-toggle--stroke" style="display: <?php echo $slide_type != 'image-carousel-url' ? 'none' : 'block'; ?>">
6
  <span class="shapla-toggle-title">
7
- <?php _e('URL Images Settings', 'carousel-slider'); ?>
8
  </span>
9
  <div class="shapla-toggle-inner">
10
  <div class="shapla-toggle-content">
4
  ?>
5
  <div data-id="open" id="section_url_images_settings" class="shapla-toggle shapla-toggle--stroke" style="display: <?php echo $slide_type != 'image-carousel-url' ? 'none' : 'block'; ?>">
6
  <span class="shapla-toggle-title">
7
+ <?php _e('URL Images', 'carousel-slider'); ?>
8
  </span>
9
  <div class="shapla-toggle-inner">
10
  <div class="shapla-toggle-content">
templates/admin/post-carousel.php CHANGED
@@ -51,7 +51,7 @@
51
  'id' => '_posts_per_page',
52
  'name' => __('Posts per page', 'carousel-slider'),
53
  'std' => 12,
54
- 'desc' => __('How many post you want to show on carousel slide (Disabled for Specific posts)', 'carousel-slider'),
55
  ));
56
  $this->form->select(array(
57
  'id' => '_post_order',
51
  'id' => '_posts_per_page',
52
  'name' => __('Posts per page', 'carousel-slider'),
53
  'std' => 12,
54
+ 'desc' => __('How many post you want to show on carousel slide.', 'carousel-slider'),
55
  ));
56
  $this->form->select(array(
57
  'id' => '_post_order',
widgets/widget-carousel_slider.php CHANGED
@@ -26,16 +26,19 @@ class Carousel_Slider_Widget extends WP_Widget {
26
  public function widget( $args, $instance ) {
27
  extract($args);
28
 
29
- wp_enqueue_style( 'carousel-slider' );
30
- wp_enqueue_script( 'owl-carousel' );
31
-
32
- $carousel_id = isset($instance['carousel_id']) ? $instance['carousel_id'] : 0;
33
 
34
  if ( ! $carousel_id) {
35
  return;
36
  }
37
 
38
  echo $args['before_widget'];
 
 
 
 
 
39
  echo do_shortcode('[carousel_slide id='. $carousel_id .']');
40
  echo $args['after_widget'];
41
  }
@@ -47,11 +50,15 @@ class Carousel_Slider_Widget extends WP_Widget {
47
  */
48
  public function form( $instance )
49
  {
50
- $carousels = $this->carousels_list();
51
- $carousel_id = ! empty( $instance['carousel_id'] ) ? $instance['carousel_id'] : null;
 
52
 
53
  if ( count( $carousels ) > 0 ) {
54
 
 
 
 
55
  echo sprintf('<p><label>%s</label>', __('Choose Slide', 'carousel-slider'));
56
  echo sprintf('<select class="widefat" name="%s">', $this->get_field_name( 'carousel_id' ));
57
  foreach ($carousels as $carousel ) {
@@ -82,7 +89,8 @@ class Carousel_Slider_Widget extends WP_Widget {
82
  */
83
  public function update( $new_instance, $old_instance ) {
84
  $instance = array();
85
- $instance['carousel_id'] = ( ! empty( $new_instance['carousel_id'] ) ) ? strip_tags( $new_instance['carousel_id'] ) : '';
 
86
 
87
  return $instance;
88
  }
@@ -100,7 +108,7 @@ class Carousel_Slider_Widget extends WP_Widget {
100
 
101
  return array_map(function($carousel){
102
  return (object) array(
103
- 'id' => $carousel->ID,
104
  'title' => esc_html($carousel->post_title),
105
  );
106
  }, $carousels);
26
  public function widget( $args, $instance ) {
27
  extract($args);
28
 
29
+ $title = apply_filters( 'widget_title', esc_attr( $instance['title'] ) );
30
+ $carousel_id = isset($instance['carousel_id']) ? absint( $instance['carousel_id'] ) : 0;
 
 
31
 
32
  if ( ! $carousel_id) {
33
  return;
34
  }
35
 
36
  echo $args['before_widget'];
37
+
38
+ if ( ! empty( $title ) ) {
39
+ echo $args['before_title'] . $title . $args['after_title'];
40
+ }
41
+
42
  echo do_shortcode('[carousel_slide id='. $carousel_id .']');
43
  echo $args['after_widget'];
44
  }
50
  */
51
  public function form( $instance )
52
  {
53
+ $carousels = $this->carousels_list();
54
+ $carousel_id = ! empty( $instance['carousel_id'] ) ? absint($instance['carousel_id']) : null;
55
+ $title = ! empty( $instance['title'] ) ? esc_attr($instance['title']) : '';
56
 
57
  if ( count( $carousels ) > 0 ) {
58
 
59
+ echo sprintf('<p><label for="%1$s">%2$s</label>', $this->get_field_id( 'title' ), __('Title (optional):', 'carousel-slider'));
60
+ echo sprintf('<input type="text" class="widefat" id="%1$s" name="%2$s" value="%3$s" /></p>', $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), $title);
61
+
62
  echo sprintf('<p><label>%s</label>', __('Choose Slide', 'carousel-slider'));
63
  echo sprintf('<select class="widefat" name="%s">', $this->get_field_name( 'carousel_id' ));
64
  foreach ($carousels as $carousel ) {
89
  */
90
  public function update( $new_instance, $old_instance ) {
91
  $instance = array();
92
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );
93
+ $instance['carousel_id'] = absint( $new_instance['carousel_id'] );
94
 
95
  return $instance;
96
  }
108
 
109
  return array_map(function($carousel){
110
  return (object) array(
111
+ 'id' => absint($carousel->ID),
112
  'title' => esc_html($carousel->post_title),
113
  );
114
  }, $carousels);