Carousel Slider - Version 1.9.3

Version Description

Download this release

Release Info

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

Code changes from version 1.9.2 to 1.9.3

carousel-slider.php CHANGED
@@ -3,14 +3,14 @@
3
  * Plugin Name: Carousel Slider
4
  * Plugin URI: http://wordpress.org/plugins/carousel-slider
5
  * Description: <strong>Carousel Slider</strong> allows you to create beautiful, touch enabled, responsive carousels and sliders. It let you create SEO friendly Image carousel from Media Library or from custom URL, Video carousel using Youtube and Vimeo video, Post carousel, Hero banner slider and various types of WooCommerce products carousels.
6
- * Version: 1.9.2
7
  * Author: Sayful Islam
8
  * Author URI: https://sayfulislam.com
9
- * Requires at least: 4.4
10
- * Tested up to: 5.2
11
  *
12
- * WC requires at least: 2.5
13
- * WC tested up to: 3.6
14
  *
15
  * Text Domain: carousel-slider
16
  *
@@ -68,8 +68,8 @@ if ( ! class_exists( 'Carousel_Slider' ) ) {
68
  * Main Carousel_Slider Instance
69
  * Ensures only one instance of the class is loaded or can be loaded.
70
  *
71
- * @since 1.6.0
72
  * @return Carousel_Slider - Main instance
 
73
  */
74
  public static function instance() {
75
  if ( is_null( self::$instance ) ) {
@@ -114,8 +114,8 @@ if ( ! class_exists( 'Carousel_Slider' ) ) {
114
  /**
115
  * Define constant if not already set.
116
  *
117
- * @param string $name
118
- * @param string|bool $value
119
  */
120
  private function define( $name, $value ) {
121
  if ( ! defined( $name ) ) {
@@ -136,6 +136,8 @@ if ( ! class_exists( 'Carousel_Slider' ) ) {
136
  require_once CAROUSEL_SLIDER_WIDGETS . '/widget-carousel_slider.php';
137
 
138
  if ( $this->is_request( 'admin' ) ) {
 
 
139
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-credit.php';
140
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-documentation.php';
141
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-vc-element.php';
@@ -220,7 +222,7 @@ if ( ! class_exists( 'Carousel_Slider' ) ) {
220
  /**
221
  * What type of request is this?
222
  *
223
- * @param string $type admin, ajax, cron or frontend.
224
  *
225
  * @return bool
226
  */
3
  * Plugin Name: Carousel Slider
4
  * Plugin URI: http://wordpress.org/plugins/carousel-slider
5
  * Description: <strong>Carousel Slider</strong> allows you to create beautiful, touch enabled, responsive carousels and sliders. It let you create SEO friendly Image carousel from Media Library or from custom URL, Video carousel using Youtube and Vimeo video, Post carousel, Hero banner slider and various types of WooCommerce products carousels.
6
+ * Version: 1.9.3
7
  * Author: Sayful Islam
8
  * Author URI: https://sayfulislam.com
9
+ * Requires at least: 4.8
10
+ * Tested up to: 5.4
11
  *
12
+ * WC requires at least: 3.0
13
+ * WC tested up to: 4.0
14
  *
15
  * Text Domain: carousel-slider
16
  *
68
  * Main Carousel_Slider Instance
69
  * Ensures only one instance of the class is loaded or can be loaded.
70
  *
 
71
  * @return Carousel_Slider - Main instance
72
+ * @since 1.6.0
73
  */
74
  public static function instance() {
75
  if ( is_null( self::$instance ) ) {
114
  /**
115
  * Define constant if not already set.
116
  *
117
+ * @param string $name
118
+ * @param string|bool $value
119
  */
120
  private function define( $name, $value ) {
121
  if ( ! defined( $name ) ) {
136
  require_once CAROUSEL_SLIDER_WIDGETS . '/widget-carousel_slider.php';
137
 
138
  if ( $this->is_request( 'admin' ) ) {
139
+ require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-setting-api.php';
140
+ require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-setting.php';
141
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-credit.php';
142
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-documentation.php';
143
  require_once CAROUSEL_SLIDER_INCLUDES . '/class-carousel-slider-vc-element.php';
222
  /**
223
  * What type of request is this?
224
  *
225
+ * @param string $type admin, ajax, cron or frontend.
226
  *
227
  * @return bool
228
  */
includes/class-carousel-slider-script.php CHANGED
@@ -207,6 +207,12 @@ if ( ! class_exists( 'Carousel_Slider_Script' ) ) {
207
  * @return boolean
208
  */
209
  private function should_load_scripts() {
 
 
 
 
 
 
210
  global $post;
211
  $load_scripts = is_active_widget( false, false, 'widget_carousel_slider', true ) ||
212
  ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'carousel_slide' ) ) ||
207
  * @return boolean
208
  */
209
  private function should_load_scripts() {
210
+ $settings = get_option( 'carousel_slider_settings' );
211
+ $settings = is_array( $settings ) ? $settings : [];
212
+ if ( isset( $settings['load_scripts'] ) && 'always' == $settings['load_scripts'] ) {
213
+ return true;
214
+ }
215
+
216
  global $post;
217
  $load_scripts = is_active_widget( false, false, 'widget_carousel_slider', true ) ||
218
  ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'carousel_slide' ) ) ||
includes/class-carousel-slider-setting-api.php ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // If this file is called directly, abort.
4
+ defined( 'ABSPATH' ) || die;
5
+
6
+ /**
7
+ * Very simple WordPress Settings API wrapper class
8
+ *
9
+ * WordPress Option Page Wrapper class that implements WordPress Settings API and
10
+ * give you easy way to create multi tabs admin menu and
11
+ * add setting fields with build in validation.
12
+ *
13
+ * @version 1.0.0 (Oct 28, 2016)
14
+ *
15
+ * @author Sayful Islam <sayful.islam001@gmail.com>
16
+ * @link www.sayfulislam.com
17
+ */
18
+ if ( ! class_exists( 'Carousel_Slider_Setting_API' ) ) {
19
+
20
+
21
+ class Carousel_Slider_Setting_API {
22
+
23
+ /**
24
+ * Setting page options
25
+ *
26
+ * @var array
27
+ */
28
+ private $options = array();
29
+
30
+ /**
31
+ * Setting page menu fields
32
+ *
33
+ * @var array
34
+ */
35
+ private $menu_fields = array();
36
+
37
+ /**
38
+ * Fields list
39
+ *
40
+ * @var array
41
+ */
42
+ private $fields = array();
43
+
44
+ /**
45
+ * Setting page tabs settings
46
+ *
47
+ * @var array
48
+ */
49
+ private $tabs = array();
50
+
51
+ /**
52
+ * Setting page form action attribute value
53
+ *
54
+ * @var string
55
+ */
56
+ private $action = 'options.php';
57
+
58
+
59
+ /**
60
+ * Filterable_Portfolio_Setting_API constructor.
61
+ */
62
+ public function __construct() {
63
+ if ( is_admin() ) {
64
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
65
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Add new admin menu
71
+ *
72
+ * This method is accessible outside the class for creating menu
73
+ *
74
+ * @param array $menu_fields
75
+ *
76
+ * @throws Exception
77
+ */
78
+ public function add_menu( array $menu_fields ) {
79
+ if ( ! isset( $menu_fields['page_title'], $menu_fields['menu_title'], $menu_fields['menu_slug'] ) ) {
80
+ throw new Exception( 'Required key is not set properly for creating menu.' );
81
+ }
82
+
83
+ $this->menu_fields = $menu_fields;
84
+ }
85
+
86
+ /**
87
+ * Add new settings field
88
+ *
89
+ * This method is accessible outside the class for creating settings field
90
+ *
91
+ * @param array $field
92
+ *
93
+ * @throws Exception
94
+ */
95
+ public function add_field( array $field ) {
96
+ if ( ! isset( $field['id'], $field['name'] ) ) {
97
+ throw new Exception( 'Required key is not set properly for creating tab.' );
98
+ }
99
+
100
+ $this->fields[] = $field;
101
+ }
102
+
103
+ /**
104
+ * Add setting page tab
105
+ *
106
+ * This method is accessible outside the class for creating page tab
107
+ *
108
+ * @param array $tab
109
+ *
110
+ * @throws Exception
111
+ */
112
+ public function add_tab( array $tab ) {
113
+ if ( ! isset( $tab['id'], $tab['title'] ) ) {
114
+ throw new Exception( 'Required key is not set properly for creating tab.' );
115
+ }
116
+
117
+ $this->tabs[] = $tab;
118
+ }
119
+
120
+ /**
121
+ * Register setting and its sanitize callback.
122
+ */
123
+ public function admin_init() {
124
+ register_setting(
125
+ $this->menu_fields['option_name'],
126
+ $this->menu_fields['option_name'],
127
+ array( $this, 'sanitize_callback' )
128
+ );
129
+ }
130
+
131
+ /**
132
+ * Create admin menu
133
+ */
134
+ public function admin_menu() {
135
+ $page_title = $this->menu_fields['page_title'];
136
+ $menu_title = $this->menu_fields['menu_title'];
137
+ $menu_slug = $this->menu_fields['menu_slug'];
138
+ $capability = isset( $this->menu_fields['capability'] ) ? $this->menu_fields['capability'] : 'manage_options';
139
+ $parent_slug = isset( $this->menu_fields['parent_slug'] ) ? $this->menu_fields['parent_slug'] : null;
140
+
141
+ if ( $parent_slug ) {
142
+ add_submenu_page(
143
+ $parent_slug,
144
+ $page_title,
145
+ $menu_title,
146
+ $capability,
147
+ $menu_slug,
148
+ array( $this, 'page_content' )
149
+ );
150
+ } else {
151
+ add_menu_page(
152
+ $page_title,
153
+ $menu_title,
154
+ $capability,
155
+ $menu_slug,
156
+ array( $this, 'page_content' )
157
+ );
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Load page content
163
+ */
164
+ public function page_content() {
165
+ ob_start(); ?>
166
+ <div class="wrap about-wrap">
167
+ <h1><?php echo $this->menu_fields['page_title']; ?></h1>
168
+ <div class="about-text"><?php echo $this->menu_fields['about_text']; ?></div>
169
+ <?php $this->option_page_tabs(); ?>
170
+ <form autocomplete="off" method="POST" action="<?php echo $this->action; ?>">
171
+ <?php
172
+ $this->get_options();
173
+ settings_fields( $this->menu_fields['option_name'] );
174
+ $this->setting_fields( $this->filter_fields_by_tab() );
175
+ submit_button();
176
+ ?>
177
+ </form>
178
+ </div>
179
+ <?php
180
+ echo ob_get_clean();
181
+ }
182
+
183
+ /**
184
+ * Generate Option Page Tabs
185
+ * @return void
186
+ */
187
+ private function option_page_tabs() {
188
+ if ( count( $this->tabs ) < 1 ) {
189
+ return;
190
+ }
191
+
192
+ $current_tab = isset ( $_GET['tab'] ) ? $_GET['tab'] : $this->tabs[0]['id'];
193
+ $page = $this->menu_fields['menu_slug'];
194
+
195
+ echo '<h2 class="nav-tab-wrapper wp-clearfix">';
196
+ foreach ( $this->tabs as $tab ) {
197
+ $class = ( $tab['id'] === $current_tab ) ? ' nav-tab-active' : '';
198
+ $page_url = esc_url( add_query_arg( array(
199
+ 'page' => $page,
200
+ 'tab' => $tab['id']
201
+ ), admin_url( $this->menu_fields['parent_slug'] ) ) );
202
+ echo '<a class="nav-tab' . $class . '" href="' . $page_url . '">' . $tab['title'] . '</a>';
203
+ }
204
+ echo '</h2>';
205
+ }
206
+
207
+ /**
208
+ * Filter settings fields by page tab
209
+ *
210
+ * @param string $current_tab
211
+ *
212
+ * @return array
213
+ */
214
+ public function filter_fields_by_tab( $current_tab = null ) {
215
+
216
+ if ( count( $this->tabs ) < 1 ) {
217
+ return $this->fields;
218
+ }
219
+
220
+ if ( ! $current_tab ) {
221
+ $current_tab = isset ( $_GET['tab'] ) ? $_GET['tab'] : $this->tabs[0]['id'];
222
+ }
223
+
224
+ $new_array = array();
225
+ if ( is_array( $this->fields ) && count( $this->fields ) > 0 ) {
226
+ foreach ( array_keys( $this->fields ) as $key ) {
227
+ if ( isset( $this->fields[ $key ]['tab'] ) ) {
228
+ $temp[ $key ] = $this->fields[ $key ]['tab'];
229
+ if ( $temp[ $key ] == $current_tab ) {
230
+ $new_array[ $key ] = $this->fields[ $key ];
231
+ }
232
+ } else {
233
+ if ( $current_tab == $this->tabs[0]['id'] ) {
234
+ $new_array[ $key ] = $this->fields[ $key ];
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ return $new_array;
241
+ }
242
+
243
+ /**
244
+ * Sanitize each setting field as needed
245
+ *
246
+ * @param array $input Contains all settings fields as array keys
247
+ *
248
+ * @return array
249
+ */
250
+ public function sanitize_callback( array $input ) {
251
+ $output_array = array();
252
+ $fields = $this->fields;
253
+ $options = (array) get_option( $this->menu_fields['option_name'] );
254
+ $options = array_filter( $options );
255
+
256
+ if ( empty( $options ) ) {
257
+ $options = (array) $this->get_options();
258
+ }
259
+
260
+ if ( count( $this->tabs ) > 0 ) {
261
+ parse_str( $_POST['_wp_http_referer'], $referrer );
262
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : $this->tabs[0]['id'];
263
+ $fields = $this->filter_fields_by_tab( $tab );
264
+ }
265
+
266
+ // Loop through each setting being saved and
267
+ // pass it through a sanitize filter
268
+ foreach ( $input as $key => $value ) {
269
+ foreach ( $fields as $field ) {
270
+ if ( $field['id'] == $key ) {
271
+ $rule = empty( $field['validate'] ) ? $field['type'] : $field['validate'];
272
+ $output_array[ $key ] = $this->validate( $value, $rule );
273
+ }
274
+ }
275
+ }
276
+
277
+ return array_merge( $options, $output_array );
278
+ }
279
+
280
+ /**
281
+ * Get options parsed with default value
282
+ * @return array
283
+ */
284
+ public function get_options() {
285
+ $options_array = array();
286
+
287
+ foreach ( $this->fields as $value ) {
288
+ $std_value = ( isset( $value['std'] ) ) ? $value['std'] : '';
289
+ $options_array[ $value['id'] ] = $std_value;
290
+ }
291
+
292
+ $options = wp_parse_args(
293
+ get_option( $this->menu_fields['option_name'] ),
294
+ $options_array
295
+ );
296
+
297
+ return $this->options = $options;
298
+ }
299
+
300
+ /**
301
+ * Validate the option's value
302
+ *
303
+ * @param mixed $input
304
+ * @param string $validation_rule
305
+ *
306
+ * @return mixed
307
+ */
308
+ private function validate( $input, $validation_rule = 'text' ) {
309
+ switch ( $validation_rule ) {
310
+ case 'text':
311
+ return sanitize_text_field( $input );
312
+ break;
313
+
314
+ case 'number':
315
+ return is_int( $input ) ? trim( $input ) : intval( $input );
316
+ break;
317
+
318
+ case 'url':
319
+ return esc_url_raw( trim( $input ) );
320
+ break;
321
+
322
+ case 'email':
323
+ return sanitize_email( $input );
324
+ break;
325
+
326
+ case 'checkbox':
327
+ return ( $input == 1 ) ? 1 : 0;
328
+ break;
329
+
330
+ case 'multi_checkbox':
331
+ return $input;
332
+ break;
333
+
334
+ case 'radio':
335
+ return sanitize_text_field( $input );
336
+ break;
337
+
338
+ case 'select':
339
+ return sanitize_text_field( $input );
340
+ break;
341
+
342
+ case 'date':
343
+ return date( 'F d, Y', strtotime( $input ) );
344
+ break;
345
+
346
+ case 'textarea':
347
+ return wp_filter_nohtml_kses( $input );
348
+ break;
349
+
350
+ case 'inlinehtml':
351
+ return wp_filter_kses( force_balance_tags( $input ) );
352
+ break;
353
+
354
+ case 'linebreaks':
355
+ return wp_strip_all_tags( $input );
356
+ break;
357
+
358
+ case 'wp_editor':
359
+ return wp_kses_post( $input );
360
+ break;
361
+
362
+ default:
363
+ return sanitize_text_field( $input );
364
+ break;
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Settings fields
370
+ *
371
+ * @param array $fields
372
+ *
373
+ * @return void
374
+ */
375
+ private function setting_fields( $fields = null ) {
376
+ $fields = is_array( $fields ) ? $fields : $this->fields;
377
+
378
+ $table = "";
379
+ $table .= "<table class='form-table'>";
380
+
381
+ foreach ( $fields as $field ) {
382
+ $name = sprintf( '%s[%s]', $this->menu_fields['option_name'], $field['id'] );
383
+ $type = isset( $field['type'] ) ? $field['type'] : 'text';
384
+ $value = isset( $this->options[ $field['id'] ] ) ? $this->options[ $field['id'] ] : '';
385
+
386
+ $table .= "<tr>";
387
+ $table .= sprintf( '<th scope="row"><label for="%1$s">%2$s</label></th>', $field['id'],
388
+ $field['name'] );
389
+ $table .= "<td>";
390
+
391
+ if ( method_exists( $this, $type ) ) {
392
+ $table .= $this->$type( $field, $name, $value );
393
+ } else {
394
+ $table .= $this->text( $field, $name, $value );
395
+ }
396
+
397
+ if ( ! empty( $field['desc'] ) ) {
398
+ $table .= sprintf( '<p class="description">%s</p>', $field['desc'] );
399
+ }
400
+ $table .= "</td>";
401
+ $table .= "</tr>";
402
+ }
403
+
404
+ $table .= "</table>";
405
+ echo $table;
406
+ }
407
+
408
+ /**
409
+ * text input field
410
+ *
411
+ * @param array $field
412
+ * @param string $name
413
+ * @param string $value
414
+ *
415
+ * @return string
416
+ */
417
+ public function text( $field, $name, $value ) {
418
+ return sprintf( '<input type="text" class="regular-text" value="%1$s" id="%2$s" name="%3$s">', $value,
419
+ $field['id'], $name );
420
+ }
421
+
422
+ /**
423
+ * email input field
424
+ *
425
+ * @param array $field
426
+ * @param string $name
427
+ * @param string $value
428
+ *
429
+ * @return string
430
+ */
431
+ public function email( $field, $name, $value ) {
432
+ return sprintf( '<input type="email" class="regular-text" value="%1$s" id="%2$s" name="%3$s">', $value,
433
+ $field['id'], $name );
434
+ }
435
+
436
+ /**
437
+ * password input field
438
+ *
439
+ * @param array $field
440
+ * @param string $name
441
+ * @param string $value
442
+ *
443
+ * @return string
444
+ */
445
+ public function password( $field, $name, $value ) {
446
+ return sprintf( '<input type="password" class="regular-text" value="" id="%2$s" name="%3$s">', $value,
447
+ $field['id'], $name );
448
+ }
449
+
450
+ /**
451
+ * number input field
452
+ *
453
+ * @param array $field
454
+ * @param string $name
455
+ * @param string $value
456
+ *
457
+ * @return string
458
+ */
459
+ public function number( $field, $name, $value ) {
460
+ return sprintf( '<input type="number" class="regular-text" value="%1$s" id="%2$s" name="%3$s">', $value,
461
+ $field['id'], $name );
462
+ }
463
+
464
+ /**
465
+ * url input field
466
+ *
467
+ * @param array $field
468
+ * @param string $name
469
+ * @param string $value
470
+ *
471
+ * @return string
472
+ */
473
+ public function url( $field, $name, $value ) {
474
+ return sprintf( '<input type="url" class="regular-text" value="%1$s" id="%2$s" name="%3$s">', $value,
475
+ $field['id'], $name );
476
+ }
477
+
478
+ /**
479
+ * color input field
480
+ *
481
+ * @param array $field
482
+ * @param string $name
483
+ * @param string $value
484
+ *
485
+ * @return string
486
+ */
487
+ public function color( $field, $name, $value ) {
488
+ $default_color = ( isset( $field['std'] ) ) ? $field['std'] : "";
489
+
490
+ return sprintf( '<input type="text" class="color-picker" value="%1$s" id="%2$s" name="%3$s" data-alpha="true" data-default-color="%4$s">',
491
+ $value, $field['id'], $name, $default_color );
492
+ }
493
+
494
+ /**
495
+ * date input field
496
+ *
497
+ * @param array $field
498
+ * @param string $name
499
+ * @param string $value
500
+ *
501
+ * @return string
502
+ */
503
+ public function date( $field, $name, $value ) {
504
+ $value = date( "F d, Y", strtotime( $value ) );
505
+
506
+ return sprintf( '<input type="text" class="regular-text datepicker" value="%1$s" id="%2$s" name="%3$s">',
507
+ $value, $field['id'], $name );
508
+ }
509
+
510
+ /**
511
+ * textarea input field
512
+ *
513
+ * @param array $field
514
+ * @param string $name
515
+ * @param string $value
516
+ *
517
+ * @return string
518
+ */
519
+ public function textarea( $field, $name, $value ) {
520
+ $rows = ( isset( $field['rows'] ) ) ? $field['rows'] : 5;
521
+ $cols = ( isset( $field['cols'] ) ) ? $field['cols'] : 40;
522
+ $placeholder = ( isset( $field['placeholder'] ) ) ? sprintf( 'placeholder="%s"',
523
+ esc_attr( $field['placeholder'] ) ) : '';
524
+
525
+ return '<textarea id="' . $field['id'] . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '" ' . $placeholder . '>' . $value . '</textarea>';
526
+ }
527
+
528
+ /**
529
+ * checkbox input field
530
+ *
531
+ * @param array $field
532
+ * @param string $name
533
+ * @param string $value
534
+ *
535
+ * @return string
536
+ */
537
+ public function checkbox( $field, $name, $value ) {
538
+ $checked = ( 1 == $value ) ? 'checked' : '';
539
+ $table = '<input type="hidden" name="' . $name . '" value="0">';
540
+ $table .= '<fieldset><legend class="screen-reader-text"><span>' . $field['name'] . '</span></legend>';
541
+ $table .= '<label for="' . $field['id'] . '">';
542
+ $table .= '<input type="checkbox" value="1" id="' . $field['id'] . '" name="' . $name . '" ' . $checked . '>';
543
+ $table .= $field['name'] . '</label></fieldset>';
544
+
545
+ return $table;
546
+ }
547
+
548
+ /**
549
+ * multi checkbox input field
550
+ *
551
+ * @param array $field
552
+ * @param string $name
553
+ * @param array $value
554
+ *
555
+ * @return string
556
+ */
557
+ public function multi_checkbox( $field, $name, $value ) {
558
+ $table = "<fieldset>";
559
+ $name = $name . "[]";
560
+
561
+ $table .= sprintf( '<input type="hidden" name="%1$s" value="0">', $name );
562
+ foreach ( $field['options'] as $key => $label ) {
563
+ $checked = ( in_array( $key, $value ) ) ? 'checked="checked"' : '';
564
+ $table .= '<label for="' . $key . '"><input type="checkbox" value="' . $key . '" id="' . $key . '" name="' . $name . '" ' . $checked . '>' . $label . '</label><br>';
565
+ }
566
+ $table .= "</fieldset>";
567
+
568
+ return $table;
569
+ }
570
+
571
+ /**
572
+ * radio input field
573
+ *
574
+ * @param array $field
575
+ * @param string $name
576
+ * @param string $value
577
+ *
578
+ * @return string
579
+ */
580
+ public function radio( $field, $name, $value ) {
581
+ $table = '<fieldset><legend class="screen-reader-text"><span>' . $field['name'] . '</span></legend><p>';
582
+
583
+ foreach ( $field['options'] as $key => $label ) {
584
+
585
+ $checked = ( $value == $key ) ? 'checked="checked"' : '';
586
+ $table .= '<label><input type="radio" ' . $checked . ' value="' . $key . '" name="' . $name . '">' . $label . '</label><br>';
587
+ }
588
+ $table .= "</p></fieldset>";
589
+
590
+ return $table;
591
+ }
592
+
593
+ /**
594
+ * select input field
595
+ *
596
+ * @param array $field
597
+ * @param string $name
598
+ * @param string $value
599
+ *
600
+ * @return string
601
+ */
602
+ public function select( $field, $name, $value ) {
603
+ $table = sprintf( '<select id="%1$s" name="%2$s" class="regular-text">', $field['id'], $name );
604
+ foreach ( $field['options'] as $key => $label ) {
605
+ $selected = ( $value == $key ) ? 'selected="selected"' : '';
606
+ $table .= '<option value="' . $key . '" ' . $selected . '>' . $label . '</option>';
607
+ }
608
+ $table .= "</select>";
609
+
610
+ return $table;
611
+ }
612
+
613
+ /**
614
+ * Get available image sizes
615
+ *
616
+ * @param $field
617
+ * @param $name
618
+ * @param $value
619
+ *
620
+ * @return string
621
+ */
622
+ public function image_sizes( $field, $name, $value ) {
623
+
624
+ global $_wp_additional_image_sizes;
625
+
626
+ $sizes = array();
627
+
628
+ foreach ( get_intermediate_image_sizes() as $_size ) {
629
+ if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
630
+
631
+ $width = get_option( "{$_size}_size_w" );
632
+ $height = get_option( "{$_size}_size_h" );
633
+ $crop = (bool) get_option( "{$_size}_crop" ) ? 'hard' : 'soft';
634
+
635
+ $sizes[ $_size ] = "{$_size} - {$width}x{$height} ($crop crop)";
636
+
637
+ } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
638
+
639
+ $width = $_wp_additional_image_sizes[ $_size ]['width'];
640
+ $height = $_wp_additional_image_sizes[ $_size ]['height'];
641
+ $crop = $_wp_additional_image_sizes[ $_size ]['crop'] ? 'hard' : 'soft';
642
+
643
+ $sizes[ $_size ] = "{$_size} - {$width}x{$height} ($crop crop)";
644
+ }
645
+ }
646
+
647
+ $sizes = array_merge( $sizes, array( 'full' => 'original uploaded image' ) );
648
+
649
+ $table = '<select name="' . $name . '" id="' . $field['id'] . '" class="regular-text select2">';
650
+ foreach ( $sizes as $key => $option ) {
651
+ $selected = ( $value == $key ) ? ' selected="selected"' : '';
652
+ $table .= '<option value="' . $key . '" ' . $selected . '>' . $option . '</option>';
653
+ }
654
+ $table .= '</select>';
655
+
656
+ return $table;
657
+ }
658
+
659
+ /**
660
+ * wp_editor input field
661
+ *
662
+ * @param array $field
663
+ * @param string $name
664
+ * @param string $value
665
+ *
666
+ * @return string
667
+ */
668
+ public function wp_editor( $field, $name, $value ) {
669
+ ob_start();
670
+ echo "<div class='sp-wp-editor-container'>";
671
+ wp_editor( $value, $field['id'], array(
672
+ 'textarea_name' => $name,
673
+ 'tinymce' => false,
674
+ 'media_buttons' => false,
675
+ 'textarea_rows' => isset( $field['rows'] ) ? $field['rows'] : 6,
676
+ 'quicktags' => array( "buttons" => "strong,em,link,img,ul,li,ol" ),
677
+ ) );
678
+ echo "</div>";
679
+
680
+ return ob_get_clean();
681
+ }
682
+ }
683
+ }
includes/class-carousel-slider-setting.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // If this file is called directly, abort.
4
+ defined( 'ABSPATH' ) || die;
5
+
6
+ if ( ! class_exists( 'Carousel_Slider_Setting' ) ) {
7
+ class Carousel_Slider_Setting {
8
+
9
+ /**
10
+ * Instance of current class
11
+ *
12
+ * @var self
13
+ */
14
+ private static $instance;
15
+
16
+ /**
17
+ * @return Carousel_Slider_Setting
18
+ */
19
+ public static function init() {
20
+ if ( is_null( self::$instance ) ) {
21
+ self::$instance = new self();
22
+
23
+ add_action( 'init', array( self::$instance, 'settings' ) );
24
+ }
25
+
26
+ return self::$instance;
27
+ }
28
+
29
+ /**
30
+ * Plugin setting fields
31
+ *
32
+ * @throws Exception
33
+ */
34
+ public function settings() {
35
+ $settings = new Carousel_Slider_Setting_API();
36
+ $settings->add_menu( array(
37
+ 'page_title' => __( 'Carousel Slider Settings', 'carousel-slider' ),
38
+ 'menu_title' => __( 'Settings', 'carousel-slider' ),
39
+ 'about_text' => __( 'Thank you for choosing Carousel Slider. We hope you enjoy it!', 'carousel-slider' ),
40
+ 'menu_slug' => 'settings',
41
+ 'parent_slug' => 'edit.php?post_type=carousels',
42
+ 'option_name' => 'carousel_slider_settings',
43
+ ) );
44
+
45
+ // Add settings page tab
46
+ $settings->add_tab( array(
47
+ 'id' => 'general',
48
+ 'title' => __( 'General', 'carousel-slider' ),
49
+ ) );
50
+
51
+ $settings->add_field( array(
52
+ 'id' => 'load_scripts',
53
+ 'type' => 'radio',
54
+ 'std' => 'optimized',
55
+ 'name' => __( 'Style & Scrips', 'carousel-slider' ),
56
+ 'desc' => __( 'If you choose Optimized, then scrips and styles will be loaded only on page where you are using shortcode. If Optimized is not working for you then choose Always.', 'carousel-slider' ),
57
+ 'options' => array(
58
+ 'always' => __( 'Always', 'carousel-slider' ),
59
+ 'optimized' => __( 'Optimized (recommended)', 'carousel-slider' ),
60
+ ),
61
+ 'tab' => 'general',
62
+ ) );
63
+ }
64
+ }
65
+ }
66
+
67
+ Carousel_Slider_Setting::init();
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Carousel Slider ===
2
  Contributors: sayful, stackonet, majeedraza
3
  Tags: woocommerce, shortcode, images, carousel, carousel slider, image carousel, product carousel, slider, owl carousel
4
- Requires at least: 4.5
5
- Tested up to: 5.2
6
- Requires PHP: 5.3
7
- Stable tag: 1.9.2
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10
 
@@ -15,7 +15,7 @@ Create SEO friendly Image, Logo, Video, Post, WooCommerce Product Carousel and S
15
  **Create SEO friendly Image, Logo, Video, Post, WooCommerce Product Carousel and Slider.**
16
  Carousel Slider is a touch enabled WordPress plugin that lets you create highly customizable, stylish responsive carousel slider. With Carousel Slider, you can create image carousel using media gallery or custom url, post carousel, video carousel. We have integrated [Owl Carousel 2](http://www.owlcarousel.owlgraphic.com/) into our plugin for the ultimate device support.
17
 
18
- > Looking for a free minimal WordPress theme. Try [Shapla](https://wordpress.org/themes/shapla/)
19
 
20
 
21
  **If you like this plugin, please give us [5 star](https://wordpress.org/support/plugin/carousel-slider/reviews/?rate=5#new-post) to encourage for future improvement.**
@@ -57,7 +57,7 @@ https://www.youtube.com/watch?v=yiAkvXyfakg
57
  = With Page Builder by SiteOrigin =
58
  https://www.youtube.com/watch?v=-OaYQZfr1RM
59
 
60
- = With WPBakery Visual Composer =
61
  https://www.youtube.com/watch?v=4LhDXH81whk
62
 
63
  = Using as a Widget =
@@ -74,33 +74,6 @@ https://www.youtube.com/watch?v=kYgp6wp27lM
74
 
75
  If you still need help. visit [WordPress codex](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
76
 
77
- == Frequently Asked Questions ==
78
-
79
- = How to use shortcode/slider in theme template file? =
80
- By default, Carousel slider only load scripts when you use shortcode in TinyMCE editor or use Carousel Slider Widget. This helps to reduce two unnecessary HTTP request for Style and Script when you are not using the slider.
81
- If you want to use shortcode in your theme directly, you need to tell the plugin to load scripts for your perticular page or template in your (theme/child theme) functions.php file. To load scripts, you can use the following filter hook.
82
- For example, if you want to use shortcode only for your front page, add the following filter hook in your theme functions.php file.
83
-
84
- `add_filter('carousel_slider_load_scripts', 'carousel_slider_load_scripts');
85
- function carousel_slider_load_scripts( $load_scripts ) {
86
- // To use only for front page
87
- if ( is_front_page() ) {
88
- return true;
89
- }
90
- return $load_scripts;
91
- }`
92
-
93
- or write the following code to always load the slider scripts and style.
94
-
95
- `add_filter('carousel_slider_load_scripts', 'carousel_slider_load_scripts');
96
- function carousel_slider_load_scripts( $load_scripts ) {
97
- return true;
98
- }`
99
-
100
- Now you can use the following function at your theme template file replacing `YOUR_SLIDER_ID` with actual carousel slider id.
101
-
102
- `echo do_shortcode('[carousel_slide id='YOUR_SLIDER_ID']");`
103
-
104
  == Screenshots ==
105
 
106
  1. Carousel slider admin page
@@ -113,6 +86,12 @@ Now you can use the following function at your theme template file replacing `YO
113
 
114
  == Changelog ==
115
 
 
 
 
 
 
 
116
  = version 1.9.2 - 2019-05-26 =
117
  * Fix - Fix Carousel slider showing hidden products
118
  * Tweak - Checked version compatibility with WooCommerce 3.6.*
@@ -262,7 +241,7 @@ Now you can use the following function at your theme template file replacing `YO
262
  * Added - Lazy Load of images.
263
  * Added - Support multiple carousel slide at same page.
264
  * Added - New Carousel Slider Widget to add carousel at widget. Especially helpful for page builder that use widget like "SiteOrigin Page Builder".
265
- * Added - New Element added for WPBakery Visual Composer page builder. If you are using WPBakery Visual Composer page.
266
  * Merged - All CSS styles in on file.
267
 
268
  = version 1.5.1 - 2016-08-11 =
1
  === Carousel Slider ===
2
  Contributors: sayful, stackonet, majeedraza
3
  Tags: woocommerce, shortcode, images, carousel, carousel slider, image carousel, product carousel, slider, owl carousel
4
+ Requires at least: 4.8
5
+ Tested up to: 5.4
6
+ Requires PHP: 5.6
7
+ Stable tag: 1.9.3
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10
 
15
  **Create SEO friendly Image, Logo, Video, Post, WooCommerce Product Carousel and Slider.**
16
  Carousel Slider is a touch enabled WordPress plugin that lets you create highly customizable, stylish responsive carousel slider. With Carousel Slider, you can create image carousel using media gallery or custom url, post carousel, video carousel. We have integrated [Owl Carousel 2](http://www.owlcarousel.owlgraphic.com/) into our plugin for the ultimate device support.
17
 
18
+ > Looking for a free minimal WordPress theme. Try [Shapla](https://wordpress.org/themes/shapla)
19
 
20
 
21
  **If you like this plugin, please give us [5 star](https://wordpress.org/support/plugin/carousel-slider/reviews/?rate=5#new-post) to encourage for future improvement.**
57
  = With Page Builder by SiteOrigin =
58
  https://www.youtube.com/watch?v=-OaYQZfr1RM
59
 
60
+ = With Visual Composer Website Builder =
61
  https://www.youtube.com/watch?v=4LhDXH81whk
62
 
63
  = Using as a Widget =
74
 
75
  If you still need help. visit [WordPress codex](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins)
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  == Screenshots ==
78
 
79
  1. Carousel slider admin page
86
 
87
  == Changelog ==
88
 
89
+ = version 1.9.3 - 2019-11-17 =
90
+ * Tweak - Checked version compatibility with WooCommerce 3.8.*
91
+ * Tweak - Checked version compatibility with WordPress 5.3.*
92
+ * Add - Add settings to enable/disable loading scrips and styles to all pages.
93
+ * Tweak - Rename "WPBakery Visual Composer" to "Visual Composer Website Builder"
94
+
95
  = version 1.9.2 - 2019-05-26 =
96
  * Fix - Fix Carousel slider showing hidden products
97
  * Tweak - Checked version compatibility with WooCommerce 3.6.*
241
  * Added - Lazy Load of images.
242
  * Added - Support multiple carousel slide at same page.
243
  * Added - New Carousel Slider Widget to add carousel at widget. Especially helpful for page builder that use widget like "SiteOrigin Page Builder".
244
+ * Added - New Element added for Visual Composer Website Builder. If you are using Visual Composer Website Builder.
245
  * Merged - All CSS styles in on file.
246
 
247
  = version 1.5.1 - 2016-08-11 =
templates/admin/documentation.php CHANGED
@@ -77,7 +77,7 @@ if ( ! defined( 'WPINC' ) ) {
77
  src="https://www.youtube.com/embed/4LhDXH81whk" frameborder="0"
78
  allowfullscreen></iframe>
79
  </div>
80
- <label><?php esc_html_e( 'With WPBakery Visual Composer', 'carousel-slider' ); ?></label>
81
  </div>
82
  </div>
83
  </div>
77
  src="https://www.youtube.com/embed/4LhDXH81whk" frameborder="0"
78
  allowfullscreen></iframe>
79
  </div>
80
+ <label><?php esc_html_e( 'With Visual Composer Website Builder', 'carousel-slider' ); ?></label>
81
  </div>
82
  </div>
83
  </div>