CPT Bootstrap Carousel - Version 1.10

Version Description

Download this release

Release Info

Developer tallphil
Plugin Icon 128x128 CPT Bootstrap Carousel
Version 1.10
Comparing to
See all releases

Code changes from version 1.9.1 to 1.10

cpt-bootstrap-carousel.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: CPT Bootstrap Carousel
4
  Plugin URI: http://www.tallphil.co.uk/bootstrap-carousel/
5
  Description: A custom post type for choosing images and content which outputs <a href="http://getbootstrap.com/javascript/#carousel" target="_blank">Bootstrap Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.
6
- Version: 1.9.1
7
  Author: Phil Ewels
8
  Author URI: http://phil.ewels.co.uk
9
  Text Domain: cpt-bootstrap-carousel
@@ -41,22 +41,22 @@ function cptbc_post_type() {
41
  'public' => true,
42
  'exclude_from_search' => true,
43
  'publicly_queryable' => false,
44
- 'show_ui' => true,
45
- 'show_in_menu' => true,
46
  'query_var' => true,
47
  'rewrite' => true,
48
  'capability_type' => 'page',
49
- 'has_archive' => true,
50
  'hierarchical' => false,
51
  'menu_position' => 21,
52
  'menu_icon' => 'dashicons-images-alt',
53
  'supports' => array('title','excerpt','thumbnail', 'page-attributes')
54
- );
55
  register_post_type('cptbc', $args);
56
  }
57
  // Create a taxonomy for the carousel post type
58
  function cptbc_taxonomies () {
59
- $args = array('hierarchical' => true);
60
  register_taxonomy( 'carousel_category', 'cptbc', $args );
61
  }
62
  add_action( 'init', 'cptbc_taxonomies', 0 );
@@ -67,7 +67,7 @@ add_action( 'init', 'cptbc_taxonomies', 0 );
67
  function cptbc_addFeaturedImageSupport() {
68
  $supportedTypes = get_theme_support( 'post-thumbnails' );
69
  if( $supportedTypes === false ) {
70
- add_theme_support( 'post-thumbnails', array( 'cptbc' ) );
71
  add_image_size('featured_preview', 100, 55, true);
72
  } elseif( is_array( $supportedTypes ) ) {
73
  $supportedTypes[0][] = 'cptbc';
@@ -81,4 +81,3 @@ add_action( 'after_setup_theme', 'cptbc_addFeaturedImageSupport');
81
  require_once('cptbc-admin.php');
82
  require_once('cptbc-settings.php');
83
  require_once('cptbc-frontend.php');
84
-
3
  Plugin Name: CPT Bootstrap Carousel
4
  Plugin URI: http://www.tallphil.co.uk/bootstrap-carousel/
5
  Description: A custom post type for choosing images and content which outputs <a href="http://getbootstrap.com/javascript/#carousel" target="_blank">Bootstrap Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.
6
+ Version: 1.10
7
  Author: Phil Ewels
8
  Author URI: http://phil.ewels.co.uk
9
  Text Domain: cpt-bootstrap-carousel
41
  'public' => true,
42
  'exclude_from_search' => true,
43
  'publicly_queryable' => false,
44
+ 'show_ui' => true,
45
+ 'show_in_menu' => true,
46
  'query_var' => true,
47
  'rewrite' => true,
48
  'capability_type' => 'page',
49
+ 'has_archive' => true,
50
  'hierarchical' => false,
51
  'menu_position' => 21,
52
  'menu_icon' => 'dashicons-images-alt',
53
  'supports' => array('title','excerpt','thumbnail', 'page-attributes')
54
+ );
55
  register_post_type('cptbc', $args);
56
  }
57
  // Create a taxonomy for the carousel post type
58
  function cptbc_taxonomies () {
59
+ $args = array('hierarchical' => true, 'label' => 'Carousel Categories');
60
  register_taxonomy( 'carousel_category', 'cptbc', $args );
61
  }
62
  add_action( 'init', 'cptbc_taxonomies', 0 );
67
  function cptbc_addFeaturedImageSupport() {
68
  $supportedTypes = get_theme_support( 'post-thumbnails' );
69
  if( $supportedTypes === false ) {
70
+ add_theme_support( 'post-thumbnails', array( 'cptbc' ) );
71
  add_image_size('featured_preview', 100, 55, true);
72
  } elseif( is_array( $supportedTypes ) ) {
73
  $supportedTypes[0][] = 'cptbc';
81
  require_once('cptbc-admin.php');
82
  require_once('cptbc-settings.php');
83
  require_once('cptbc-frontend.php');
 
cptbc-admin.php CHANGED
@@ -55,20 +55,48 @@ function cptbc_image_url(){
55
  $cptbc_image_url = isset($custom['cptbc_image_url']) ? $custom['cptbc_image_url'][0] : '';
56
  $cptbc_image_url_openblank = isset($custom['cptbc_image_url_openblank']) ? $custom['cptbc_image_url_openblank'][0] : '0';
57
  $cptbc_image_link_text = isset($custom['cptbc_image_link_text']) ? $custom['cptbc_image_link_text'][0] : '';
 
 
58
  ?>
59
- <label><?php _e('Image URL', 'cpt-bootstrap-carousel'); ?>:</label>
60
- <input name="cptbc_image_url" value="<?php echo $cptbc_image_url; ?>" /> <br />
61
- <small><em><?php _e('(optional - leave blank for no link)', 'cpt-bootstrap-carousel'); ?></em></small><br /><br />
 
 
62
 
63
- <label><input type="checkbox" name="cptbc_image_url_openblank" <?php if($cptbc_image_url_openblank == 1){ echo ' checked="checked"'; } ?> value="1" /> <?php _e('Open link in new window?', 'cpt-bootstrap-carousel'); ?></label><br /><br />
 
 
 
 
64
 
65
- <label><?php _e('Button Text', 'cpt-bootstrap-carousel'); ?>:</label>
66
- <input name="cptbc_image_link_text" value="<?php echo $cptbc_image_link_text; ?>" /> <br />
67
- <small><em><?php _e('(optional - leave blank for default, only shown if using link buttons)', 'cpt-bootstrap-carousel'); ?></em></small>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  <?php
69
  }
70
  function cptbc_admin_init_custpost(){
71
- add_meta_box("cptbc_image_url", "Image Link URL", "cptbc_image_url", "cptbc", "side", "low");
72
  }
73
  add_action("add_meta_boxes", "cptbc_admin_init_custpost");
74
  function cptbc_mb_save_details(){
@@ -82,6 +110,10 @@ function cptbc_mb_save_details(){
82
  update_post_meta($post->ID, "cptbc_image_url_openblank", $openblank);
83
  update_post_meta($post->ID, "cptbc_image_link_text", sanitize_text_field($_POST["cptbc_image_link_text"]));
84
  }
 
 
 
 
85
  }
86
  add_action('save_post', 'cptbc_mb_save_details');
87
 
@@ -137,9 +169,9 @@ function cptbc_contextual_help_tab() {
137
  $help .= '
138
  </ul></li>
139
 
140
- <li><code>twbs</code> <em>(default 2)</em>
141
  <ul>
142
- <li>Output markup for Twitter Bootstrap Version 2 or 3.</li>
143
  </ul></li>
144
  </ul>
145
  ';
55
  $cptbc_image_url = isset($custom['cptbc_image_url']) ? $custom['cptbc_image_url'][0] : '';
56
  $cptbc_image_url_openblank = isset($custom['cptbc_image_url_openblank']) ? $custom['cptbc_image_url_openblank'][0] : '0';
57
  $cptbc_image_link_text = isset($custom['cptbc_image_link_text']) ? $custom['cptbc_image_link_text'][0] : '';
58
+ $cptbc_video_url = isset($custom['cptbc_video_url']) ? $custom['cptbc_video_url'][0] : '';
59
+ $cptbc_video_aspect = isset($custom['cptbc_video_aspect']) ? $custom['cptbc_video_aspect'][0] : '';
60
  ?>
61
+ <p>
62
+ <label><?php _e('Image URL', 'cpt-bootstrap-carousel'); ?>:</label>
63
+ <input type="url" name="cptbc_image_url" value="<?php echo $cptbc_image_url; ?>" style="width: 100%"/> <br />
64
+ <small><em><?php _e('(optional - leave blank for no link)', 'cpt-bootstrap-carousel'); ?></em></small>
65
+ </p>
66
 
67
+ <p>
68
+ <label>
69
+ <input type="checkbox" name="cptbc_image_url_openblank" <?php if($cptbc_image_url_openblank == 1){ echo ' checked="checked"'; } ?> value="1" /> <?php _e('Open link in new window?', 'cpt-bootstrap-carousel'); ?>
70
+ </label>
71
+ </p>
72
 
73
+ <p>
74
+ <label><?php _e('Button Text', 'cpt-bootstrap-carousel'); ?>:</label>
75
+ <input type="text" name="cptbc_image_link_text" value="<?php echo $cptbc_image_link_text; ?>" style="width: 100%"/> <br />
76
+ <small><em><?php _e('(optional - leave blank for default, only shown if using link buttons)', 'cpt-bootstrap-carousel'); ?></em></small>
77
+ </p>
78
+
79
+ <hr />
80
+
81
+ <p><strong>Note: Using a video replaces the slide text &amp; button (if shown), Youtube &amp; Vimeo are supported</strong></p>
82
+
83
+ <p>
84
+ <label><?php _e('Video URL', 'cpt-bootstrap-carousel'); ?>:</label>
85
+ <input type="text" name="cptbc_video_url" value="<?php echo $cptbc_video_url; ?>" style="width: 100%"/> <br />
86
+ <small><em><?php _e('(use only the url, not the full embed code)', 'cpt-bootstrap-carousel'); ?></em></small>
87
+ </p>
88
+
89
+ <p>
90
+ <label><?php _e('Video Aspect Ratio', 'cpt-bootstrap-carousel'); ?>:</label>
91
+ <select name="cptbc_video_aspect">
92
+ <option value="embed-responsive-16by9" <?php if ($cptbc_video_aspect == "embed-responsive-16by9") echo 'selected'; ?>>16:9</option>
93
+ <option value="embed-responsive-4by3" <?php if ($cptbc_video_aspect == "embed-responsive-4by3") echo 'selected'; ?>>4:3</option>
94
+ </select> <br />
95
+ </p>
96
  <?php
97
  }
98
  function cptbc_admin_init_custpost(){
99
+ add_meta_box("cptbc_image_url", "Slide Options", "cptbc_image_url", "cptbc", "side", "low");
100
  }
101
  add_action("add_meta_boxes", "cptbc_admin_init_custpost");
102
  function cptbc_mb_save_details(){
110
  update_post_meta($post->ID, "cptbc_image_url_openblank", $openblank);
111
  update_post_meta($post->ID, "cptbc_image_link_text", sanitize_text_field($_POST["cptbc_image_link_text"]));
112
  }
113
+ if (isset($_POST["cptbc_video_url"])) {
114
+ update_post_meta($post->ID, "cptbc_video_url", esc_url($_POST["cptbc_video_url"]));
115
+ update_post_meta($post->ID, "cptbc_video_aspect", sanitize_text_field($_POST["cptbc_video_aspect"]));
116
+ }
117
  }
118
  add_action('save_post', 'cptbc_mb_save_details');
119
 
169
  $help .= '
170
  </ul></li>
171
 
172
+ <li><code>twbs</code> <em>(default 3)</em>
173
  <ul>
174
+ <li>Output markup for Twitter Bootstrap Version 2, 3 or 4.</li>
175
  </ul></li>
176
  </ul>
177
  ';
cptbc-frontend.php CHANGED
@@ -40,7 +40,12 @@ function cptbc_frontend($atts){
40
  'order' => $atts['order']
41
  );
42
  if($atts['category'] != ''){
43
- $args['carousel_category'] = $atts['category'];
 
 
 
 
 
44
  }
45
  if(!isset($atts['before_title'])) $atts['before_title'] = '<h4>';
46
  if(!isset($atts['after_title'])) $atts['after_title'] = '</h4>';
@@ -57,6 +62,8 @@ function cptbc_frontend($atts){
57
  // Collect the carousel content. Needs printing in two loops later (bullets and content)
58
  $loop = new WP_Query( $args );
59
  $images = array();
 
 
60
  $output = '';
61
  while ( $loop->have_posts() ) {
62
  $loop->the_post();
@@ -70,7 +77,9 @@ function cptbc_frontend($atts){
70
  $url = get_post_meta(get_the_ID(), 'cptbc_image_url', true);
71
  $url_openblank = get_post_meta(get_the_ID(), 'cptbc_image_url_openblank', true);
72
  $link_text = get_post_meta(get_the_ID(), 'cptbc_image_link_text', true);
73
- $images[] = array('post_id' => $post_id, 'title' => $title, 'content' => $content, 'image' => $image, 'img_src' => $image_src, 'url' => esc_url($url), 'url_openblank' => $url_openblank == "1" ? true : false, 'link_text' => $link_text);
 
 
74
  }
75
  }
76
 
@@ -79,25 +88,29 @@ function cptbc_frontend($atts){
79
  ob_start();
80
  ?>
81
  <div id="cptbc_<?php echo $id; ?>" class="carousel slide" <?php if($atts['use_javascript_animation'] == '0'){ echo ' data-ride="carousel"'; } ?> data-interval="<?php echo $atts['interval']; ?>">
82
-
83
- <?php // First content - the carousel indicators
84
- if( count( $images ) > 1 ){ ?>
85
- <ol class="carousel-indicators">
86
- <?php foreach ($images as $key => $image) { ?>
87
- <li data-target="#cptbc_<?php echo $id; ?>" data-slide-to="<?php echo $key; ?>" <?php echo $key == 0 ? 'class="active"' : ''; ?>></li>
88
- <?php } ?>
89
- </ol>
90
- <?php } ?>
 
 
 
 
91
 
92
  <div class="carousel-inner">
93
  <?php
94
  // Carousel Content
95
  foreach ($images as $key => $image) {
96
-
97
  if( !isset($atts['link_button']) ) {
98
  $atts['link_button'] = 0;
99
  }
100
-
101
  // Build anchor link so it can be reused
102
  $linkstart = '';
103
  $linkend = '';
@@ -110,32 +123,56 @@ function cptbc_frontend($atts){
110
  $linkend = '</a>';
111
  } ?>
112
 
113
- <div class="item <?php echo $key == 0 ? 'active' : ''; ?>" id="cptbc-item-<?php echo $image['post_id']; ?>" <?php if($atts['use_background_images'] == 1){ echo ' style="height: '.$atts['background_images_height'].'px; background: url(\''.$image['img_src'].'\') no-repeat center center ; -webkit-background-size: ' . $atts['select_background_images_style_size'] . '; -moz-background-size: ' . $atts['select_background_images_style_size'] . '; -o-background-size: ' . $atts['select_background_images_style_size'] . '; background-size: ' . $atts['select_background_images_style_size'] . ';"'; } ?>>
114
  <?php
115
  // Regular behaviour - display image with link around it
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  if($atts['use_background_images'] == 0){
117
  echo $linkstart.$image['image'].$linkend;
118
- // Backgorund images mode - need block level link inside carousel link if we have a linl
119
  } else if($image['url'] && $atts['link_button'] == 0) {
120
  echo '<a href="'.$image['url'].'"';
121
  if($image['url_openblank']) {
122
- $linkstart .= ' target="_blank"';
123
  }
124
  echo ' style="display:block; width:100%; height:100%;">&nbsp;</a>';
125
- }
126
  // The Caption div
127
- if(($atts['showcaption'] === 'true' && (strlen($image['title']) > 0 || strlen($image['content']) > 0)) || ($image['url'] && $atts['link_button'] == 1)) {
 
128
  echo '<div class="carousel-caption">';
129
  // Title
130
- if(strlen($image['title']) > 0){
131
  echo $atts['before_title'].$linkstart.$image['title'].$linkend.$atts['after_title'];
132
  }
133
  // Caption
134
- if(strlen($image['content']) > 0){
135
  echo $atts['before_caption'].$linkstart.$image['content'].$linkend.$atts['after_caption'];
136
  }
137
  // Link Button
138
- if($image['url'] && $atts['link_button'] == 1){
139
  if(isset($atts['link_button_before'])) echo $atts['link_button_before'];
140
  $target = '';
141
  if($image['url_openblank']) {
@@ -151,22 +188,31 @@ function cptbc_frontend($atts){
151
  if(isset($atts['link_button_after'])) echo $atts['link_button_after'];
152
  }
153
  echo '</div>';
154
- } ?>
 
 
 
155
  </div>
156
  <?php } ?>
157
  </div>
158
 
159
  <?php // Previous / Next controls
160
  if( count( $images ) > 1 ){
161
- if($atts['showcontrols'] === 'true' && $atts['twbs'] == '3') { ?>
162
  <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
163
  <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
164
- <?php } else if($atts['showcontrols'] === 'true'){ ?>
 
 
 
165
  <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹</a>
166
  <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›</a>
167
- <?php } else if($atts['showcontrols'] === 'custom' && $atts['twbs'] == '3' && $atts['customprev'] != '' && $atts['customnext'] != ''){ ?>
168
- <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="<?php echo $atts['customprev'] ?> icon-prev"></span></a>
169
- <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="<?php echo $atts['customnext'] ?> icon-next"></span></a>
 
 
 
170
  <?php }
171
  } ?>
172
 
@@ -183,14 +229,75 @@ function cptbc_frontend($atts){
183
  </script>
184
  <?php }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  // Collect the output
187
  $output = ob_get_contents();
188
  ob_end_clean();
 
 
189
  }
190
-
191
  // Restore original Post Data
192
- wp_reset_postdata();
193
-
194
  return $output;
195
  }
196
-
40
  'order' => $atts['order']
41
  );
42
  if($atts['category'] != ''){
43
+ $args['tax_query'][] = array(
44
+ 'taxonomy' => 'carousel_category',
45
+ 'field' => 'slug',
46
+ 'terms' => $atts['category'],
47
+ 'operator' => 'IN'
48
+ );
49
  }
50
  if(!isset($atts['before_title'])) $atts['before_title'] = '<h4>';
51
  if(!isset($atts['after_title'])) $atts['after_title'] = '</h4>';
62
  // Collect the carousel content. Needs printing in two loops later (bullets and content)
63
  $loop = new WP_Query( $args );
64
  $images = array();
65
+ $video_providers = array();
66
+
67
  $output = '';
68
  while ( $loop->have_posts() ) {
69
  $loop->the_post();
77
  $url = get_post_meta(get_the_ID(), 'cptbc_image_url', true);
78
  $url_openblank = get_post_meta(get_the_ID(), 'cptbc_image_url_openblank', true);
79
  $link_text = get_post_meta(get_the_ID(), 'cptbc_image_link_text', true);
80
+ $video_url = get_post_meta(get_the_ID(), 'cptbc_video_url', true);
81
+ $video_aspect = get_post_meta(get_the_ID(), 'cptbc_video_aspect', true);
82
+ $images[] = array('post_id' => $post_id, 'title' => $title, 'content' => $content, 'image' => $image, 'img_src' => $image_src, 'url' => esc_url($url), 'video_url' => esc_url($video_url), 'video_aspect' => $video_aspect, 'url_openblank' => $url_openblank == "1" ? true : false, 'link_text' => $link_text);
83
  }
84
  }
85
 
88
  ob_start();
89
  ?>
90
  <div id="cptbc_<?php echo $id; ?>" class="carousel slide" <?php if($atts['use_javascript_animation'] == '0'){ echo ' data-ride="carousel"'; } ?> data-interval="<?php echo $atts['interval']; ?>">
91
+
92
+ <?php
93
+ if( $atts['showindicators'] === 'true' ) {
94
+ // First content - the carousel indicators
95
+ if( count( $images ) > 1 ){ ?>
96
+ <ol class="carousel-indicators">
97
+ <?php foreach ($images as $key => $image) { ?>
98
+ <li data-target="#cptbc_<?php echo $id; ?>" data-slide-to="<?php echo $key; ?>" <?php echo $key == 0 ? 'class="active"' : ''; ?>></li>
99
+ <?php } ?>
100
+ </ol>
101
+ <?php
102
+ }
103
+ } ?>
104
 
105
  <div class="carousel-inner">
106
  <?php
107
  // Carousel Content
108
  foreach ($images as $key => $image) {
109
+
110
  if( !isset($atts['link_button']) ) {
111
  $atts['link_button'] = 0;
112
  }
113
+
114
  // Build anchor link so it can be reused
115
  $linkstart = '';
116
  $linkend = '';
123
  $linkend = '</a>';
124
  } ?>
125
 
126
+ <div class="<?php echo $atts['twbs'] == '4' ? 'carousel-' : ''; ?>item <?php echo $key == 0 ? 'active' : ''; ?>" id="cptbc-item-<?php echo $image['post_id']; ?>" <?php if($atts['use_background_images'] == 1){ echo ' style="' .(($atts['background_images_height'] != 0) ? 'height: ' . $atts['background_images_height'] . 'px; ' : "") . ' background: url(\''.$image['img_src'].'\') no-repeat center center ; -webkit-background-size: ' . $atts['select_background_images_style_size'] . '; -moz-background-size: ' . $atts['select_background_images_style_size'] . '; -o-background-size: ' . $atts['select_background_images_style_size'] . '; background-size: ' . $atts['select_background_images_style_size'] . ';"'; } ?>>
127
  <?php
128
  // Regular behaviour - display image with link around it
129
+ if ($image['video_url']) { ?>
130
+ <div class="embed-responsive <?php echo $image['video_aspect']; ?>">
131
+ <?php
132
+ $provider;
133
+ // Check which video provider and set the JS API param
134
+ if (strpos($image['video_url'], 'youtube')) {
135
+ $provider = 'youtube';
136
+ $image['video_url'] .= (strpos($image['video_url'], '?')) ? '&enablejsapi=1' : '?enablejsapi=1';
137
+ } else if (strpos($image['video_url'], 'vimeo')) {
138
+ $provider = 'vimeo';
139
+ $image['video_url'] .= (strpos($image['video_url'], '?')) ? '&api=1' : '?api=1';
140
+ }
141
+
142
+ // if not in list add it
143
+ //if ($video_providers)
144
+ if (!in_array( $provider, $video_providers)) {
145
+ $video_providers[] = $provider;
146
+ }
147
+ ?>
148
+ <iframe id="<?php echo 'video-' . $key; ?>" width="100%" class="embed-responsive-item provider-<?php echo $provider; ?>" height="100%" src="<?php echo $image['video_url']; ?>" frameborder="0" allowfullscreen=""></iframe>
149
+ </div>
150
+ <?php
151
+ } else {
152
  if($atts['use_background_images'] == 0){
153
  echo $linkstart.$image['image'].$linkend;
154
+ // Background images mode - need block level link inside carousel link if we have a linl
155
  } else if($image['url'] && $atts['link_button'] == 0) {
156
  echo '<a href="'.$image['url'].'"';
157
  if($image['url_openblank']) {
158
+ echo ' target="_blank"';
159
  }
160
  echo ' style="display:block; width:100%; height:100%;">&nbsp;</a>';
161
+ }
162
  // The Caption div
163
+ if(($atts['showtitle'] === 'true' && strlen($image['title']) > 0) || ($atts['showcaption'] === 'true' && strlen($image['content']) > 0) || ($image['url'] && $atts['link_button'] == 1)) {
164
+ if(isset($atts['before_caption_div'])) echo $atts['before_caption_div'];
165
  echo '<div class="carousel-caption">';
166
  // Title
167
+ if($atts['showtitle'] === 'true' && strlen($image['title']) > 0){
168
  echo $atts['before_title'].$linkstart.$image['title'].$linkend.$atts['after_title'];
169
  }
170
  // Caption
171
+ if($atts['showcaption'] === 'true' && strlen($image['content']) > 0){
172
  echo $atts['before_caption'].$linkstart.$image['content'].$linkend.$atts['after_caption'];
173
  }
174
  // Link Button
175
+ if($image['url'] && $atts['link_button'] == 1){
176
  if(isset($atts['link_button_before'])) echo $atts['link_button_before'];
177
  $target = '';
178
  if($image['url_openblank']) {
188
  if(isset($atts['link_button_after'])) echo $atts['link_button_after'];
189
  }
190
  echo '</div>';
191
+ if(isset($atts['after_caption_div'])) echo $atts['after_caption_div'];
192
+
193
+ }
194
+ } // End video if ?>
195
  </div>
196
  <?php } ?>
197
  </div>
198
 
199
  <?php // Previous / Next controls
200
  if( count( $images ) > 1 ){
201
+ if( $atts['showcontrols'] === 'true' && $atts['twbs' ] == '3') { ?>
202
  <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
203
  <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
204
+ <?php } elseif ( $atts['showcontrols'] === 'true' && $atts['twbs'] == '4' ) { ?>
205
+ <a class="carousel-control-prev" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="carousel-control-prev-icon icon-prev"></span></a>
206
+ <a class="carousel-control-next" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="carousel-control-next-icon icon-next"></span></a>
207
+ <?php } elseif ( $atts['showcontrols'] === 'true' ) { ?>
208
  <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹</a>
209
  <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›</a>
210
+ <?php } elseif ( $atts['showcontrols'] === 'custom' && $atts['twbs'] == '3' && $atts['customprev'] != '' && $atts['customnext'] != '' ) { ?>
211
+ <a class="left carousel-control" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="<?php echo $atts['customprev'] ?> icon-prev"></span></a>
212
+ <a class="right carousel-control" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="<?php echo $atts['customnext'] ?> icon-next"></span></a>
213
+ <? } elseif ( $atts['showcontrols'] === 'custom' && $atts['twbs'] == '4' && $atts['customprev'] != '' && $atts['customnext'] != '' ) { ?>
214
+ <a class="carousel-control-prev" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="<?php echo $atts['customprev'] ?> icon-prev"></span></a>
215
+ <a class="carousel-control-next" role="button" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="<?php echo $atts['customnext'] ?> icon-next"></span></a>
216
  <?php }
217
  } ?>
218
 
229
  </script>
230
  <?php }
231
 
232
+ // Check & load video auto pause requirements
233
+ if (count($video_providers) > 0) { ?>
234
+ <script>
235
+ var $myCarousel = jQuery('#cptbc_<?php echo $id; ?>');
236
+
237
+ <?php foreach ($video_providers as $provider):
238
+ if ($provider == 'youtube') { ?>
239
+ // See http://jsfiddle.net/8R5y6/
240
+ function callYoutubePlayer(frame_id, func, args) {
241
+ if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id;
242
+ var iframe = document.getElementById(frame_id);
243
+ if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') {
244
+ iframe = iframe.getElementsByTagName('iframe')[0];
245
+ }
246
+ if (iframe) {
247
+ // Frame exists,
248
+ iframe.contentWindow.postMessage(JSON.stringify({
249
+ "event": "command",
250
+ "func": func,
251
+ "args": args || [],
252
+ "id": frame_id
253
+ }), "*");
254
+ }
255
+ }
256
+
257
+ $myCarousel.on("slide.bs.carousel", function (event) {
258
+ var $currentSlide = $myCarousel.find(".active iframe.provider-youtube");
259
+ if (!$currentSlide.length) { return; }
260
+ callYoutubePlayer($currentSlide, 'pauseVideo')
261
+ });
262
+
263
+ <?php }
264
+ if ($provider == 'vimeo') { ?>
265
+ // Youtube version hacked into vimeo version
266
+ function callVimeoPlayer(frame_id, action, args) {
267
+ if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id;
268
+ var iframe = document.getElementById(frame_id);
269
+ if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') {
270
+ iframe = iframe.getElementsByTagName('iframe')[0];
271
+ }
272
+ if (iframe) {
273
+ var data = { method: action };
274
+ if (args) {
275
+ data.value = args;
276
+ }
277
+ url = iframe.src.split('?')[0];
278
+ iframe.contentWindow.postMessage(JSON.stringify(data), url);
279
+ }
280
+ }
281
+
282
+ $myCarousel.on("slide.bs.carousel", function (event) {
283
+ var $currentSlide = $myCarousel.find(".active iframe.provider-vimeo");
284
+ if (!$currentSlide.length) { return; }
285
+ callVimeoPlayer($currentSlide, 'pause')
286
+ });
287
+ <?php }
288
+ endforeach; ?>
289
+ </script>
290
+ <?php }
291
+
292
  // Collect the output
293
  $output = ob_get_contents();
294
  ob_end_clean();
295
+ } else {
296
+ $output = '<!-- CPT Bootstrap Carousel - no images found for #cptbc_'.$id.' -->';
297
  }
298
+
299
  // Restore original Post Data
300
+ wp_reset_postdata();
301
+
302
  return $output;
303
  }
 
cptbc-settings.php CHANGED
@@ -16,13 +16,17 @@ register_activation_hook(__FILE__, 'cptbc_set_options');
16
  function cptbc_set_options (){
17
  $defaults = array(
18
  'interval' => '5000',
 
19
  'showcaption' => 'true',
20
  'showcontrols' => 'true',
 
21
  'customprev' => '',
22
  'customnext' => '',
23
  'orderby' => 'menu_order',
24
  'order' => 'ASC',
25
  'category' => '',
 
 
26
  'before_title' => '<h4>',
27
  'after_title' => '</h4>',
28
  'before_caption' => '<p>',
@@ -34,11 +38,11 @@ function cptbc_set_options (){
34
  'link_button_before' => '',
35
  'link_button_after' => '',
36
  'id' => '',
37
- 'twbs' => '3',
38
  'use_background_images' => '0',
39
  'background_images_height' => '500',
40
- 'background_images_style_size' => 'cover',
41
- 'use_javascript_animation' => '1',
42
  );
43
  add_option('cptbc_settings', $defaults);
44
  }
@@ -53,18 +57,18 @@ function cptbc_deactivate(){
53
  class cptbc_settings_page {
54
  // Holds the values to be used in the fields callbacks
55
  private $options;
56
-
57
  // Start up
58
  public function __construct() {
59
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
60
  add_action( 'admin_init', array( $this, 'page_init' ) );
61
  }
62
-
63
  // Add settings page
64
  public function add_plugin_page() {
65
  add_submenu_page('edit.php?post_type=cptbc', __('Settings', 'cpt-bootstrap-carousel'), __('Settings', 'cpt-bootstrap-carousel'), 'manage_options', 'cpt-bootstrap-carousel', array($this,'create_admin_page'));
66
  }
67
-
68
  // Options page callback
69
  public function create_admin_page() {
70
  // Set class property
@@ -77,26 +81,26 @@ class cptbc_settings_page {
77
  <div class="wrap">
78
  <h2>CPT Bootstrap Carousel <?php _e('Settings', 'cpt-bootstrap-carousel'); ?></h2>
79
  <p><?php printf(__('You can set the default behaviour of your carousels here. Most of these settings can be overridden by using %s shortcode attributes %s.', 'cpt-bootstrap-carousel'),'<a href="http://wordpress.org/plugins/cpt-bootstrap-carousel/" target="_blank">', '</a>'); ?></p>
80
-
81
  <form method="post" action="options.php">
82
  <?php
83
- settings_fields( 'cptbc_settings' );
84
  do_settings_sections( 'cpt-bootstrap-carousel' );
85
- submit_button();
86
  ?>
87
  </form>
88
  </div>
89
  <?php
90
  }
91
-
92
  // Register and add settings
93
- public function page_init() {
94
  register_setting(
95
  'cptbc_settings', // Option group
96
  'cptbc_settings', // Option name
97
  array( $this, 'sanitize' ) // Sanitize
98
  );
99
-
100
  // Sections
101
  add_settings_section(
102
  'cptbc_settings_behaviour', // ID
@@ -122,7 +126,7 @@ class cptbc_settings_page {
122
  array( $this, 'cptbc_settings_markup_header' ), // Callback
123
  'cpt-bootstrap-carousel' // Page
124
  );
125
-
126
  // Behaviour Fields
127
  add_settings_field(
128
  'interval', // ID
@@ -131,64 +135,78 @@ class cptbc_settings_page {
131
  'cpt-bootstrap-carousel', // Page
132
  'cptbc_settings_behaviour' // Section
133
  );
 
 
 
 
 
 
 
134
  add_settings_field(
135
  'showcaption', // ID
136
- __('Show Slide Titles / Captions?', 'cpt-bootstrap-carousel'), // Title
137
  array( $this, 'showcaption_callback' ), // Callback
138
  'cpt-bootstrap-carousel', // Page
139
- 'cptbc_settings_behaviour' // Section
140
  );
141
  add_settings_field(
142
  'showcontrols', // ID
143
- __('Show Slide Controls?', 'cpt-bootstrap-carousel'), // Title
144
  array( $this, 'showcontrols_callback' ), // Callback
145
  'cpt-bootstrap-carousel', // Page
146
- 'cptbc_settings_behaviour' // Section
 
 
 
 
 
 
 
147
  );
148
  add_settings_field(
149
  'orderby', // ID
150
- __('Order Slides By', 'cpt-bootstrap-carousel'), // Title
151
  array( $this, 'orderby_callback' ), // Callback
152
  'cpt-bootstrap-carousel', // Page
153
- 'cptbc_settings_behaviour' // Section
154
  );
155
  add_settings_field(
156
  'order', // ID
157
- __('Ordering Direction', 'cpt-bootstrap-carousel'), // Title
158
  array( $this, 'order_callback' ), // Callback
159
  'cpt-bootstrap-carousel', // Page
160
- 'cptbc_settings_behaviour' // Section
161
  );
162
  add_settings_field(
163
  'category', // ID
164
- __('Restrict to Category', 'cpt-bootstrap-carousel'), // Title
165
  array( $this, 'category_callback' ), // Callback
166
  'cpt-bootstrap-carousel', // Page
167
- 'cptbc_settings_behaviour' // Section
168
  );
169
-
170
  // Carousel Setup Section
171
  add_settings_field(
172
  'twbs', // ID
173
- __('Twitter Bootstrap Version', 'cpt-bootstrap-carousel'), // Title
174
  array( $this, 'twbs_callback' ), // Callback
175
  'cpt-bootstrap-carousel', // Page
176
- 'cptbc_settings_setup' // Section
177
  );
178
  add_settings_field(
179
  'image_size', // ID
180
- __('Image Size', 'cpt-bootstrap-carousel'), // Title
181
  array( $this, 'image_size_callback' ), // Callback
182
  'cpt-bootstrap-carousel', // Page
183
- 'cptbc_settings_setup' // Section
184
  );
185
-
186
  add_settings_field(
187
  'use_background_images', // ID
188
- __('Use background images?', 'cpt-bootstrap-carousel'), // Title
189
  array( $this, 'use_background_images_callback' ), // Callback
190
  'cpt-bootstrap-carousel', // Page
191
- 'cptbc_settings_setup' // Section
192
  );
193
  add_settings_field(
194
  'background_images_height', // ID
@@ -206,10 +224,10 @@ class cptbc_settings_page {
206
  );
207
  add_settings_field(
208
  'use_javascript_animation', // ID
209
- __('Use Javascript to animate carousel?', 'cpt-bootstrap-carousel'), // Title
210
  array( $this, 'use_javascript_animation_callback' ), // Callback
211
  'cpt-bootstrap-carousel', // Page
212
- 'cptbc_settings_setup' // Section
213
  );
214
 
215
  // Link buttons
@@ -248,7 +266,7 @@ class cptbc_settings_page {
248
  'cpt-bootstrap-carousel', // Page
249
  'cptbc_settings_link_buttons' // Section
250
  );
251
-
252
  // Markup Section
253
  add_settings_field(
254
  'customprev', // ID
@@ -264,6 +282,20 @@ class cptbc_settings_page {
264
  'cpt-bootstrap-carousel', // Page
265
  'cptbc_settings_markup' // Section
266
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  add_settings_field(
268
  'before_title', // ID
269
  __('HTML before title', 'cpt-bootstrap-carousel'), // Title
@@ -292,24 +324,24 @@ class cptbc_settings_page {
292
  'cpt-bootstrap-carousel', // Page
293
  'cptbc_settings_markup' // Section
294
  );
295
-
296
  }
297
-
298
  // Sanitize each setting field as needed - @param array $input Contains all settings fields as array keys
299
  public function sanitize( $input ) {
300
  $new_input = array();
301
  foreach($input as $key => $var){
302
  if($key == 'twbs' || $key == 'interval' || $key == 'background_images_height'){
303
  $new_input[$key] = absint( $input[$key] );
304
- } else if ($key == 'link_button_before' || $key == 'link_button_after' || $key == 'before_title' || $key == 'after_title' || $key == 'before_caption' || $key == 'after_caption'){
305
  $new_input[$key] = $input[$key]; // Don't sanitise these, meant to be html!
306
- } else {
307
  $new_input[$key] = sanitize_text_field( $input[$key] );
308
  }
309
  }
310
  return $new_input;
311
  }
312
-
313
  // Print the Section text
314
  public function cptbc_settings_behaviour_header() {
315
  echo '<p>'.__('Basic setup of how each Carousel will function, what controls will show and which images will be displayed.', 'cpt-bootstrap-carousel').'</p>';
@@ -323,14 +355,27 @@ class cptbc_settings_page {
323
  public function cptbc_settings_markup_header() {
324
  echo '<p>'.__('Customise which CSS classes and HTML tags the Carousel uses.', 'cpt-bootstrap-carousel').'</p>';
325
  }
326
-
327
  // Callback functions - print the form inputs
328
- // Carousel behaviour
329
  public function interval_callback() {
330
  printf('<input type="text" id="interval" name="cptbc_settings[interval]" value="%s" size="15" />',
331
  isset( $this->options['interval'] ) ? esc_attr( $this->options['interval']) : '');
332
  echo '<p class="description">'.__('How long each image shows for before it slides. Set to 0 to disable animation.', 'cpt-bootstrap-carousel').'</p>';
333
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  public function showcaption_callback() {
335
  if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){
336
  $cptbc_showcaption_t = '';
@@ -364,12 +409,25 @@ class cptbc_settings_page {
364
  <option value="custom"'.$cptbc_showcontrols_c.'>'.__('Custom', 'cpt-bootstrap-carousel').'</option>
365
  </select>';
366
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  public function orderby_callback() {
368
  $orderby_options = array (
369
  'menu_order' => __('Menu order, as set in Carousel overview page', 'cpt-bootstrap-carousel'),
370
  'date' => __('Date slide was published', 'cpt-bootstrap-carousel'),
371
  'rand' => __('Random ordering', 'cpt-bootstrap-carousel'),
372
- 'title' => __('Slide title', 'cpt-bootstrap-carousel')
373
  );
374
  print '<select id="orderby" name="cptbc_settings[orderby]">';
375
  foreach($orderby_options as $val => $option){
@@ -407,19 +465,26 @@ class cptbc_settings_page {
407
  }
408
  print '</select>';
409
  }
410
-
411
  // Setup Section
412
  public function twbs_callback() {
413
- if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '3'){
414
- $cptbc_twbs3 = ' selected="selected"';
415
- $cptbc_twbs2 = '';
416
- } else {
417
  $cptbc_twbs3 = '';
418
  $cptbc_twbs2 = ' selected="selected"';
 
 
 
 
 
 
 
 
419
  }
420
  print '<select id="twbs" name="cptbc_settings[twbs]">
421
  <option value="2"'.$cptbc_twbs2.'>2.x</option>
422
- <option value="3"'.$cptbc_twbs3.'>3.x (Default)</option>
 
423
  </select>';
424
  echo '<p class="description">'.__("Set according to which version of Bootstrap you're using.", 'cpt-bootstrap-carousel').'</p>';
425
  }
@@ -531,7 +596,7 @@ class cptbc_settings_page {
531
  printf('<input type="text" id="link_button_after" name="cptbc_settings[link_button_after]" value="%s" size="20" />',
532
  isset( $this->options['link_button_after'] ) ? esc_attr( $this->options['link_button_after']) : '');
533
  }
534
-
535
  // Markup section
536
  public function before_title_callback() {
537
  printf('<input type="text" id="before_title" name="cptbc_settings[before_title]" value="%s" size="15" />',
@@ -556,8 +621,16 @@ class cptbc_settings_page {
556
  public function after_caption_callback() {
557
  printf('<input type="text" id="after_caption" name="cptbc_settings[after_caption]" value="%s" size="15" />',
558
  isset( $this->options['after_caption'] ) ? esc_attr( $this->options['after_caption']) : '</p>');
559
- }
560
-
 
 
 
 
 
 
 
 
561
  }
562
 
563
  if( is_admin() ){
@@ -565,10 +638,10 @@ if( is_admin() ){
565
  }
566
 
567
  // Add settings link on plugin page
568
- function cptbc_settings_link ($links) {
569
- $settings_link = '<a href="edit.php?post_type=cptbc&page=cpt-bootstrap-carousel">'.__('Settings', 'cpt-bootstrap-carousel').'</a>';
570
- array_unshift($links, $settings_link);
571
- return $links;
572
  }
573
- $cptbc_plugin = plugin_basename(__FILE__);
574
  add_filter("plugin_action_links_$cptbc_plugin", 'cptbc_settings_link' );
16
  function cptbc_set_options (){
17
  $defaults = array(
18
  'interval' => '5000',
19
+ 'showtitle' => 'true',
20
  'showcaption' => 'true',
21
  'showcontrols' => 'true',
22
+ 'showindicators' => 'true',
23
  'customprev' => '',
24
  'customnext' => '',
25
  'orderby' => 'menu_order',
26
  'order' => 'ASC',
27
  'category' => '',
28
+ 'before_caption_div' => '',
29
+ 'after_caption_div' => '',
30
  'before_title' => '<h4>',
31
  'after_title' => '</h4>',
32
  'before_caption' => '<p>',
38
  'link_button_before' => '',
39
  'link_button_after' => '',
40
  'id' => '',
41
+ 'twbs' => '4',
42
  'use_background_images' => '0',
43
  'background_images_height' => '500',
44
+ 'background_images_style_size' => 'cover',
45
+ 'use_javascript_animation' => '1',
46
  );
47
  add_option('cptbc_settings', $defaults);
48
  }
57
  class cptbc_settings_page {
58
  // Holds the values to be used in the fields callbacks
59
  private $options;
60
+
61
  // Start up
62
  public function __construct() {
63
  add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
64
  add_action( 'admin_init', array( $this, 'page_init' ) );
65
  }
66
+
67
  // Add settings page
68
  public function add_plugin_page() {
69
  add_submenu_page('edit.php?post_type=cptbc', __('Settings', 'cpt-bootstrap-carousel'), __('Settings', 'cpt-bootstrap-carousel'), 'manage_options', 'cpt-bootstrap-carousel', array($this,'create_admin_page'));
70
  }
71
+
72
  // Options page callback
73
  public function create_admin_page() {
74
  // Set class property
81
  <div class="wrap">
82
  <h2>CPT Bootstrap Carousel <?php _e('Settings', 'cpt-bootstrap-carousel'); ?></h2>
83
  <p><?php printf(__('You can set the default behaviour of your carousels here. Most of these settings can be overridden by using %s shortcode attributes %s.', 'cpt-bootstrap-carousel'),'<a href="http://wordpress.org/plugins/cpt-bootstrap-carousel/" target="_blank">', '</a>'); ?></p>
84
+
85
  <form method="post" action="options.php">
86
  <?php
87
+ settings_fields( 'cptbc_settings' );
88
  do_settings_sections( 'cpt-bootstrap-carousel' );
89
+ submit_button();
90
  ?>
91
  </form>
92
  </div>
93
  <?php
94
  }
95
+
96
  // Register and add settings
97
+ public function page_init() {
98
  register_setting(
99
  'cptbc_settings', // Option group
100
  'cptbc_settings', // Option name
101
  array( $this, 'sanitize' ) // Sanitize
102
  );
103
+
104
  // Sections
105
  add_settings_section(
106
  'cptbc_settings_behaviour', // ID
126
  array( $this, 'cptbc_settings_markup_header' ), // Callback
127
  'cpt-bootstrap-carousel' // Page
128
  );
129
+
130
  // Behaviour Fields
131
  add_settings_field(
132
  'interval', // ID
135
  'cpt-bootstrap-carousel', // Page
136
  'cptbc_settings_behaviour' // Section
137
  );
138
+ add_settings_field(
139
+ 'showtitle', // ID
140
+ __('Show Slide Titles?', 'cpt-bootstrap-carousel'), // Title
141
+ array( $this, 'showtitle_callback' ), // Callback
142
+ 'cpt-bootstrap-carousel', // Page
143
+ 'cptbc_settings_behaviour' // Section
144
+ );
145
  add_settings_field(
146
  'showcaption', // ID
147
+ __('Show Slide Captions?', 'cpt-bootstrap-carousel'), // Title
148
  array( $this, 'showcaption_callback' ), // Callback
149
  'cpt-bootstrap-carousel', // Page
150
+ 'cptbc_settings_behaviour' // Section
151
  );
152
  add_settings_field(
153
  'showcontrols', // ID
154
+ __('Show Slide Controls?', 'cpt-bootstrap-carousel'), // Title
155
  array( $this, 'showcontrols_callback' ), // Callback
156
  'cpt-bootstrap-carousel', // Page
157
+ 'cptbc_settings_behaviour' // Section
158
+ );
159
+ add_settings_field(
160
+ 'showindicators', // ID
161
+ __('Show Slide Indicators?', 'cpt-bootstrap-carousel'), // Title
162
+ array( $this, 'showindicators_callback' ), // Callback
163
+ 'cpt-bootstrap-carousel', // Page
164
+ 'cptbc_settings_behaviour' // Section
165
  );
166
  add_settings_field(
167
  'orderby', // ID
168
+ __('Order Slides By', 'cpt-bootstrap-carousel'), // Title
169
  array( $this, 'orderby_callback' ), // Callback
170
  'cpt-bootstrap-carousel', // Page
171
+ 'cptbc_settings_behaviour' // Section
172
  );
173
  add_settings_field(
174
  'order', // ID
175
+ __('Ordering Direction', 'cpt-bootstrap-carousel'), // Title
176
  array( $this, 'order_callback' ), // Callback
177
  'cpt-bootstrap-carousel', // Page
178
+ 'cptbc_settings_behaviour' // Section
179
  );
180
  add_settings_field(
181
  'category', // ID
182
+ __('Restrict to Category', 'cpt-bootstrap-carousel'), // Title
183
  array( $this, 'category_callback' ), // Callback
184
  'cpt-bootstrap-carousel', // Page
185
+ 'cptbc_settings_behaviour' // Section
186
  );
187
+
188
  // Carousel Setup Section
189
  add_settings_field(
190
  'twbs', // ID
191
+ __('Twitter Bootstrap Version', 'cpt-bootstrap-carousel'), // Title
192
  array( $this, 'twbs_callback' ), // Callback
193
  'cpt-bootstrap-carousel', // Page
194
+ 'cptbc_settings_setup' // Section
195
  );
196
  add_settings_field(
197
  'image_size', // ID
198
+ __('Image Size', 'cpt-bootstrap-carousel'), // Title
199
  array( $this, 'image_size_callback' ), // Callback
200
  'cpt-bootstrap-carousel', // Page
201
+ 'cptbc_settings_setup' // Section
202
  );
203
+
204
  add_settings_field(
205
  'use_background_images', // ID
206
+ __('Use background images?', 'cpt-bootstrap-carousel'), // Title
207
  array( $this, 'use_background_images_callback' ), // Callback
208
  'cpt-bootstrap-carousel', // Page
209
+ 'cptbc_settings_setup' // Section
210
  );
211
  add_settings_field(
212
  'background_images_height', // ID
224
  );
225
  add_settings_field(
226
  'use_javascript_animation', // ID
227
+ __('Use Javascript to animate carousel?', 'cpt-bootstrap-carousel'), // Title
228
  array( $this, 'use_javascript_animation_callback' ), // Callback
229
  'cpt-bootstrap-carousel', // Page
230
+ 'cptbc_settings_setup' // Section
231
  );
232
 
233
  // Link buttons
266
  'cpt-bootstrap-carousel', // Page
267
  'cptbc_settings_link_buttons' // Section
268
  );
269
+
270
  // Markup Section
271
  add_settings_field(
272
  'customprev', // ID
282
  'cpt-bootstrap-carousel', // Page
283
  'cptbc_settings_markup' // Section
284
  );
285
+ add_settings_field(
286
+ 'before_caption_div', // ID
287
+ __('HTML before caption div', 'cpt-bootstrap-carousel'), // Title
288
+ array( $this, 'before_caption_div_callback' ), // Callback
289
+ 'cpt-bootstrap-carousel', // Page
290
+ 'cptbc_settings_markup' // Section
291
+ );
292
+ add_settings_field(
293
+ 'after_caption_div', // ID
294
+ __('HTML after caption div', 'cpt-bootstrap-carousel'), // Title
295
+ array( $this, 'after_caption_div_callback' ), // Callback
296
+ 'cpt-bootstrap-carousel', // Page
297
+ 'cptbc_settings_markup' // Section
298
+ );
299
  add_settings_field(
300
  'before_title', // ID
301
  __('HTML before title', 'cpt-bootstrap-carousel'), // Title
324
  'cpt-bootstrap-carousel', // Page
325
  'cptbc_settings_markup' // Section
326
  );
327
+
328
  }
329
+
330
  // Sanitize each setting field as needed - @param array $input Contains all settings fields as array keys
331
  public function sanitize( $input ) {
332
  $new_input = array();
333
  foreach($input as $key => $var){
334
  if($key == 'twbs' || $key == 'interval' || $key == 'background_images_height'){
335
  $new_input[$key] = absint( $input[$key] );
336
+ } else if ($key == 'link_button_before' || $key == 'link_button_after' || $key == 'before_title' || $key == 'after_title' || $key == 'before_caption' || $key == 'after_caption' || $key == 'before_caption_div' || $key == 'after_caption_div'){
337
  $new_input[$key] = $input[$key]; // Don't sanitise these, meant to be html!
338
+ } else {
339
  $new_input[$key] = sanitize_text_field( $input[$key] );
340
  }
341
  }
342
  return $new_input;
343
  }
344
+
345
  // Print the Section text
346
  public function cptbc_settings_behaviour_header() {
347
  echo '<p>'.__('Basic setup of how each Carousel will function, what controls will show and which images will be displayed.', 'cpt-bootstrap-carousel').'</p>';
355
  public function cptbc_settings_markup_header() {
356
  echo '<p>'.__('Customise which CSS classes and HTML tags the Carousel uses.', 'cpt-bootstrap-carousel').'</p>';
357
  }
358
+
359
  // Callback functions - print the form inputs
360
+ // Carousel behaviour
361
  public function interval_callback() {
362
  printf('<input type="text" id="interval" name="cptbc_settings[interval]" value="%s" size="15" />',
363
  isset( $this->options['interval'] ) ? esc_attr( $this->options['interval']) : '');
364
  echo '<p class="description">'.__('How long each image shows for before it slides. Set to 0 to disable animation.', 'cpt-bootstrap-carousel').'</p>';
365
  }
366
+ public function showtitle_callback() {
367
+ if(isset( $this->options['showtitle'] ) && $this->options['showtitle'] == 'false'){
368
+ $cptbc_showtitle_t = '';
369
+ $cptbc_showtitle_f = ' selected="selected"';
370
+ } else {
371
+ $cptbc_showtitle_t = ' selected="selected"';
372
+ $cptbc_showtitle_f = '';
373
+ }
374
+ print '<select id="showtitle" name="cptbc_settings[showtitle]">
375
+ <option value="true"'.$cptbc_showtitle_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
376
+ <option value="false"'.$cptbc_showtitle_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
377
+ </select>';
378
+ }
379
  public function showcaption_callback() {
380
  if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){
381
  $cptbc_showcaption_t = '';
409
  <option value="custom"'.$cptbc_showcontrols_c.'>'.__('Custom', 'cpt-bootstrap-carousel').'</option>
410
  </select>';
411
  }
412
+ public function showindicators_callback() {
413
+ if(isset( $this->options['showindicators'] ) && $this->options['showindicators'] == 'false'){
414
+ $cptbc_showindicators_t = '';
415
+ $cptbc_showindicators_f = ' selected="selected"';
416
+ } else if(isset( $this->options['showindicators'] ) && $this->options['showindicators'] == 'true'){
417
+ $cptbc_showindicators_t = ' selected="selected"';
418
+ $cptbc_showindicators_f = '';
419
+ }
420
+ print '<select id="showindicators" name="cptbc_settings[showindicators]">
421
+ <option value="true"'.$cptbc_showindicators_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
422
+ <option value="false"'.$cptbc_showindicators_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
423
+ </select>';
424
+ }
425
  public function orderby_callback() {
426
  $orderby_options = array (
427
  'menu_order' => __('Menu order, as set in Carousel overview page', 'cpt-bootstrap-carousel'),
428
  'date' => __('Date slide was published', 'cpt-bootstrap-carousel'),
429
  'rand' => __('Random ordering', 'cpt-bootstrap-carousel'),
430
+ 'title' => __('Slide title', 'cpt-bootstrap-carousel')
431
  );
432
  print '<select id="orderby" name="cptbc_settings[orderby]">';
433
  foreach($orderby_options as $val => $option){
465
  }
466
  print '</select>';
467
  }
468
+
469
  // Setup Section
470
  public function twbs_callback() {
471
+ if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '2'){
472
+ $cptbc_twbs4 = '';
 
 
473
  $cptbc_twbs3 = '';
474
  $cptbc_twbs2 = ' selected="selected"';
475
+ } else if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '4'){
476
+ $cptbc_twbs4 = ' selected="selected"';
477
+ $cptbc_twbs3 = '';
478
+ $cptbc_twbs2 = '';
479
+ } else {
480
+ $cptbc_twbs4 = '';
481
+ $cptbc_twbs3 = ' selected="selected"';
482
+ $cptbc_twbs2 = '';
483
  }
484
  print '<select id="twbs" name="cptbc_settings[twbs]">
485
  <option value="2"'.$cptbc_twbs2.'>2.x</option>
486
+ <option value="3"'.$cptbc_twbs3.'>3.x</option>
487
+ <option value="4"'.$cptbc_twbs4.'>4.x (Default)</option>
488
  </select>';
489
  echo '<p class="description">'.__("Set according to which version of Bootstrap you're using.", 'cpt-bootstrap-carousel').'</p>';
490
  }
596
  printf('<input type="text" id="link_button_after" name="cptbc_settings[link_button_after]" value="%s" size="20" />',
597
  isset( $this->options['link_button_after'] ) ? esc_attr( $this->options['link_button_after']) : '');
598
  }
599
+
600
  // Markup section
601
  public function before_title_callback() {
602
  printf('<input type="text" id="before_title" name="cptbc_settings[before_title]" value="%s" size="15" />',
621
  public function after_caption_callback() {
622
  printf('<input type="text" id="after_caption" name="cptbc_settings[after_caption]" value="%s" size="15" />',
623
  isset( $this->options['after_caption'] ) ? esc_attr( $this->options['after_caption']) : '</p>');
624
+ }
625
+ public function before_caption_div_callback() {
626
+ printf('<input type="text" id="before_caption_div" name="cptbc_settings[before_caption_div]" value="%s" size="15" />',
627
+ isset( $this->options['before_caption_div'] ) ? esc_attr( $this->options['before_caption_div']) : '');
628
+ }
629
+ public function after_caption_div_callback() {
630
+ printf('<input type="text" id="after_caption_div" name="cptbc_settings[after_caption_div]" value="%s" size="15" />',
631
+ isset( $this->options['after_caption_div'] ) ? esc_attr( $this->options['after_caption_div']) : '');
632
+ }
633
+
634
  }
635
 
636
  if( is_admin() ){
638
  }
639
 
640
  // Add settings link on plugin page
641
+ function cptbc_settings_link ($links) {
642
+ $settings_link = '<a href="edit.php?post_type=cptbc&page=cpt-bootstrap-carousel">'.__('Settings', 'cpt-bootstrap-carousel').'</a>';
643
+ array_unshift($links, $settings_link);
644
+ return $links;
645
  }
646
+ $cptbc_plugin = plugin_basename(__FILE__);
647
  add_filter("plugin_action_links_$cptbc_plugin", 'cptbc_settings_link' );
languages/cpt-bootstrap-carousel-id_ID.po ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2013 CPT Bootstrap Carousel
2
+ # This file is distributed under the same license as the CPT Bootstrap Carousel package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: CPT Bootstrap Carousel 1.9\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/cpt-bootstrap-carousel\n"
7
+ "POT-Creation-Date: 2013-12-15 15:20:37+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2017-04-03 13:23+0100\n"
12
+ "Last-Translator: Jordan Silaen <jordan.silaen@chameleonjohn.com>\n"
13
+ "Language-Team: ChameleonJohn.com <jordan.silaen@chameleonjohn.com>\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Generator: Poedit 1.7.1\n"
16
+ "Language: id_ID\n"
17
+
18
+ #: cpt-bootstrap-carousel.php:26
19
+ msgid "Carousel Images"
20
+ msgstr "Gambar Carousel"
21
+
22
+ #: cpt-bootstrap-carousel.php:27
23
+ msgid "Carousel Image"
24
+ msgstr "Carousel Gambar"
25
+
26
+ #: cpt-bootstrap-carousel.php:28
27
+ msgid "Add New"
28
+ msgstr "Tambah baru"
29
+
30
+ #: cpt-bootstrap-carousel.php:29
31
+ msgid "Add New Carousel Image"
32
+ msgstr "Add New Carousel Gambar"
33
+
34
+ #: cpt-bootstrap-carousel.php:30
35
+ msgid "Edit Carousel Image"
36
+ msgstr "Mengedit Carousel Gambar"
37
+
38
+ #: cpt-bootstrap-carousel.php:31
39
+ msgid "New Carousel Image"
40
+ msgstr "Carousel Gambar baru"
41
+
42
+ #: cpt-bootstrap-carousel.php:32
43
+ msgid "View Carousel Image"
44
+ msgstr "Lihat Carousel Gambar"
45
+
46
+ #: cpt-bootstrap-carousel.php:33
47
+ msgid "Search Carousel Images"
48
+ msgstr "Cari Carousel Images"
49
+
50
+ #: cpt-bootstrap-carousel.php:34
51
+ msgid "No Carousel Image"
52
+ msgstr "Tidak ada Carousel Gambar"
53
+
54
+ #: cpt-bootstrap-carousel.php:35
55
+ msgid "No Carousel Images found in Trash"
56
+ msgstr "Tidak ada Carousel Gambar ditemukan di Sampah"
57
+
58
+ #: cpt-bootstrap-carousel.php:37
59
+ msgid "Carousel"
60
+ msgstr "Korsel"
61
+
62
+ #: cpt-bootstrap-carousel.php:89
63
+ msgid "Featured Image"
64
+ msgstr "Gambar Pilihan"
65
+
66
+ #: cpt-bootstrap-carousel.php:110
67
+ msgid "Image URL"
68
+ msgstr "URL gambar"
69
+
70
+ #: cpt-bootstrap-carousel.php:112
71
+ msgid "(optional - leave blank for no link)"
72
+ msgstr "(Opsional - kosongkan ada link)"
73
+
74
+ #: cpt-bootstrap-carousel.php:113
75
+ msgid "Open link in new window?"
76
+ msgstr "Buka link di jendela baru?"
77
+
78
+ #: cpt-bootstrap-carousel.php:166 cpt-bootstrap-carousel.php:179
79
+ #: cpt-bootstrap-carousel.php:389
80
+ msgid "Settings"
81
+ msgstr "pengaturan"
82
+
83
+ #: cpt-bootstrap-carousel.php:180
84
+ msgid ""
85
+ "You can set the default behaviour of your carousels here. All of these settings can "
86
+ "be overridden by using %s shortcode attributes %s."
87
+ msgstr "Anda dapat mengatur perilaku default komidi putar Anda di sini. Semua pengaturan ini dapat diganti dengan menggunakan %s shortcode atribut %s ."
88
+
89
+ #: cpt-bootstrap-carousel.php:210
90
+ msgid "Twitter Bootstrap Version"
91
+ msgstr "Twitter Bootstrap Versi"
92
+
93
+ #: cpt-bootstrap-carousel.php:218
94
+ msgid "Slide Interval (milliseconds)"
95
+ msgstr "Slide Interval (milidetik)"
96
+
97
+ #: cpt-bootstrap-carousel.php:226
98
+ msgid "Show Slide Captions?"
99
+ msgstr "Pertunjukkan Keterangan?"
100
+
101
+ #: cpt-bootstrap-carousel.php:234
102
+ msgid "Show Slide Controls?"
103
+ msgstr "Tampilkan Kontrol Slide?"
104
+
105
+ #: cpt-bootstrap-carousel.php:242
106
+ msgid "Order Slides By"
107
+ msgstr "Agar Slide Dengan"
108
+
109
+ #: cpt-bootstrap-carousel.php:250
110
+ msgid "Ordering Direction"
111
+ msgstr "pemesanan Arah"
112
+
113
+ #: cpt-bootstrap-carousel.php:258
114
+ msgid "Restrict to Category"
115
+ msgstr "Batasi untuk Kategori"
116
+
117
+ #: cpt-bootstrap-carousel.php:315 cpt-bootstrap-carousel.php:329
118
+ msgid "Show"
119
+ msgstr "Menunjukkan"
120
+
121
+ #: cpt-bootstrap-carousel.php:316 cpt-bootstrap-carousel.php:330
122
+ msgid "Hide"
123
+ msgstr "Menyembunyikan"
124
+
125
+ #: cpt-bootstrap-carousel.php:336
126
+ msgid "Menu order, as set in Carousel overview page"
127
+ msgstr "urutan menu, seperti diatur dalam Carousel halaman ikhtisar"
128
+
129
+ #: cpt-bootstrap-carousel.php:337
130
+ msgid "Date slide was published"
131
+ msgstr "Tanggal geser diterbitkan"
132
+
133
+ #: cpt-bootstrap-carousel.php:338
134
+ msgid "Random ordering"
135
+ msgstr "pemesanan acak"
136
+
137
+ #: cpt-bootstrap-carousel.php:339
138
+ msgid "Slide title"
139
+ msgstr "judul Slide"
140
+
141
+ #: cpt-bootstrap-carousel.php:361
142
+ msgid "Ascending"
143
+ msgstr "Ascending"
144
+
145
+ #: cpt-bootstrap-carousel.php:362
146
+ msgid "Decending"
147
+ msgstr "decending"
148
+
149
+ #: cpt-bootstrap-carousel.php:369
150
+ msgid "All Categories"
151
+ msgstr "semua Kategori"
152
+
153
+ #. Plugin Name of the plugin/theme
154
+ msgid "CPT Bootstrap Carousel"
155
+ msgstr "CPT Bootstrap Carousel"
156
+
157
+ #. Plugin URI of the plugin/theme
158
+ msgid "http://www.tallphil.co.uk/bootstrap-carousel/"
159
+ msgstr "http://www.tallphil.co.uk/bootstrap-carousel/"
160
+
161
+ #. Description of the plugin/theme
162
+ msgid ""
163
+ "A custom post type for choosing images and content which outputs <a href=\"http://"
164
+ "twitter.github.io/bootstrap/javascript.html#carousel\" target=\"_blank\">Bootstrap "
165
+ "Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded "
166
+ "separately."
167
+ msgstr "Sebuah jenis posting kustom untuk memilih gambar dan konten yang output <a href=\"http://twitter.github.io/bootstrap/javascript.html#carousel\" target=\"_blank\"> Bootstrap Carousel </a> dari shortcode. Membutuhkan Bootstrap javascript dan CSS yang akan dimuat secara terpisah."
168
+
169
+ #. Author of the plugin/theme
170
+ msgid "Phil Ewels"
171
+ msgstr "Phil Ewels"
172
+
173
+ #. Author URI of the plugin/theme
174
+ msgid "http://phil.ewels.co.uk"
175
+ msgstr "http://phil.ewels.co.uk"
176
+
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tallphil
3
  Donate Link: http://www.tallphil.co.uk/bootstrap-carousel/
4
  Tags: carousel, slider, image, bootstrap
5
  Requires at least: 3.0.1
6
- Tested up to: 4.3
7
- Stable tag: 1.9.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,7 @@ A custom post type for choosing images and content which outputs Bootstrap Image
12
 
13
  == Description ==
14
 
15
- A custom post type for choosing images and content which outputs a [carousel](http://getbootstrap.com/javascript/#carousel) from [Twitter Bootstrap](http://www.getbootstrap.com) using the shortcode `[image-carousel]`.
16
 
17
  The plugin assumes that you're already using Bootstrap, so you need to load the Bootstrap javascript and CSS separately.
18
 
@@ -156,6 +156,15 @@ You need to make sure that each image is the same height. You can do this by set
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
 
 
159
  = 1.9.1 =
160
  * Titles and captions now show if present, independently of each other (previously both needed to be filled in)
161
  * You can hide them by leaving blank, or setting _Show Slide Titles / Captions?_ to False in the settings
@@ -242,4 +251,4 @@ You need to make sure that each image is the same height. You can do this by set
242
  * Added a new admin metabox to give each image a link (optional).
243
 
244
  = 1.1 =
245
- * Added shortcode attribute functionality for tweaking of carousel options.
3
  Donate Link: http://www.tallphil.co.uk/bootstrap-carousel/
4
  Tags: carousel, slider, image, bootstrap
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.1.1
7
+ Stable tag: 1.10
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ A custom post type for choosing images and content which outputs a [carousel](http://getbootstrap.com/javascript/#carousel) from [Twitter Bootstrap](http://www.getbootstrap.com) using the shortcode `[image-carousel]`.
16
 
17
  The plugin assumes that you're already using Bootstrap, so you need to load the Bootstrap javascript and CSS separately.
18
 
156
 
157
  == Changelog ==
158
 
159
+ = 1.10.1 =
160
+ * Added support for Bootstrap 4
161
+ * Added support for video backgrounds, youtube or vimeo
162
+ * Tested with WordPress 5.1.1
163
+ * Separated settings option for _Show Caption / Titles?_ into two, one for each.
164
+ * Fixed minor front end bug when using background images. Thanks to @thendigital
165
+ * New Indonesian translation by Jordan Silaen from http://chameleonjohn.com/
166
+ * Many other tweaks and improvements
167
+
168
  = 1.9.1 =
169
  * Titles and captions now show if present, independently of each other (previously both needed to be filled in)
170
  * You can hide them by leaving blank, or setting _Show Slide Titles / Captions?_ to False in the settings
251
  * Added a new admin metabox to give each image a link (optional).
252
 
253
  = 1.1 =
254
+ * Added shortcode attribute functionality for tweaking of carousel options.