Version Description
- Added support for carousel categories, using filtering with the
category
shortcode - Added
orderby
shortcode attribute to specify ordering of images- This means that images can now be in a random order
- Added
twbs
shortcode attribute to allow the output of Twitter Bootstrap v3 markup - Added WordPress directory screenshots
- Admin thumbnail images now link to the edit page
Download this release
Release Info
Developer | tallphil |
Plugin | CPT Bootstrap Carousel |
Version | 1.3 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3
- cpt-bootstrap-carousel.php +21 -5
- readme.txt +62 -9
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://twitter.github.io/bootstrap/javascript.html#carousel" target="_blank">Bootstrap Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.
|
6 |
-
Version: 1.
|
7 |
Author: Phil Ewels
|
8 |
Author URI: http://phil.ewels.co.uk
|
9 |
License: GPLv2
|
@@ -43,6 +43,12 @@ function cptbc_post_type() {
|
|
43 |
);
|
44 |
register_post_type('cptbc', $args);
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
|
48 |
// Add theme support for featured images if not already present
|
@@ -77,7 +83,7 @@ function cptbc_columns_content($column_name, $post_ID) {
|
|
77 |
if ($column_name == 'featured_image') {
|
78 |
$post_featured_image = cptbc_get_featured_image($post_ID);
|
79 |
if ($post_featured_image) {
|
80 |
-
echo '<img src="' . $post_featured_image . '"
|
81 |
}
|
82 |
}
|
83 |
}
|
@@ -120,7 +126,11 @@ function cptbc_shortcode($atts, $content = null) {
|
|
120 |
$defaults = array(
|
121 |
'interval' => '5000',
|
122 |
'showcaption' => 'true',
|
123 |
-
'showcontrols' => 'true'
|
|
|
|
|
|
|
|
|
124 |
);
|
125 |
|
126 |
// Parse incomming $atts into an array and merge it with $defaults
|
@@ -133,7 +143,10 @@ add_shortcode('image-carousel', 'cptbc_shortcode');
|
|
133 |
// Display carousel
|
134 |
function cptbc_frontend($atts){
|
135 |
$id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page
|
136 |
-
$args = array( 'post_type' => 'cptbc', 'orderby' => '
|
|
|
|
|
|
|
137 |
$loop = new WP_Query( $args );
|
138 |
$images = array();
|
139 |
while ( $loop->have_posts() ) {
|
@@ -177,7 +190,10 @@ function cptbc_frontend($atts){
|
|
177 |
</div>
|
178 |
<?php } ?>
|
179 |
</div>
|
180 |
-
<?php if($atts['showcontrols'] === 'true') { ?>
|
|
|
|
|
|
|
181 |
<a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹</a>
|
182 |
<a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›</a>
|
183 |
<?php } ?>
|
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://twitter.github.io/bootstrap/javascript.html#carousel" target="_blank">Bootstrap Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.
|
6 |
+
Version: 1.3
|
7 |
Author: Phil Ewels
|
8 |
Author URI: http://phil.ewels.co.uk
|
9 |
License: GPLv2
|
43 |
);
|
44 |
register_post_type('cptbc', $args);
|
45 |
}
|
46 |
+
// Create a taxonomy for the carousel post type
|
47 |
+
function cptbc_taxonomies () {
|
48 |
+
$args = array('hierarchical' => true);
|
49 |
+
register_taxonomy( 'carousel_category', 'cptbc', $args );
|
50 |
+
}
|
51 |
+
add_action( 'init', 'cptbc_taxonomies', 0 );
|
52 |
|
53 |
|
54 |
// Add theme support for featured images if not already present
|
83 |
if ($column_name == 'featured_image') {
|
84 |
$post_featured_image = cptbc_get_featured_image($post_ID);
|
85 |
if ($post_featured_image) {
|
86 |
+
echo '<a href="'.get_edit_post_link($post_ID).'"><img src="' . $post_featured_image . '" /></a>';
|
87 |
}
|
88 |
}
|
89 |
}
|
126 |
$defaults = array(
|
127 |
'interval' => '5000',
|
128 |
'showcaption' => 'true',
|
129 |
+
'showcontrols' => 'true',
|
130 |
+
'orderby' => 'menu_order',
|
131 |
+
'order' => 'ASC',
|
132 |
+
'category' => '',
|
133 |
+
'twbs' => '2'
|
134 |
);
|
135 |
|
136 |
// Parse incomming $atts into an array and merge it with $defaults
|
143 |
// Display carousel
|
144 |
function cptbc_frontend($atts){
|
145 |
$id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page
|
146 |
+
$args = array( 'post_type' => 'cptbc', 'orderby' => $atts['orderby'], 'order' => $atts['order']);
|
147 |
+
if($atts['category'] != ''){
|
148 |
+
$args['carousel_category'] = $atts['category'];
|
149 |
+
}
|
150 |
$loop = new WP_Query( $args );
|
151 |
$images = array();
|
152 |
while ( $loop->have_posts() ) {
|
190 |
</div>
|
191 |
<?php } ?>
|
192 |
</div>
|
193 |
+
<?php if($atts['showcontrols'] === 'true' && $atts['twbs'] == '3') { ?>
|
194 |
+
<a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="icon-prev"></span></a>
|
195 |
+
<a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="icon-next"></span></a>
|
196 |
+
<?php } else if($atts['showcontrols'] === 'true'){ ?>
|
197 |
<a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹</a>
|
198 |
<a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›</a>
|
199 |
<?php } ?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: tallphil, joshgerdes, atnon
|
|
3 |
Donate Link: http://phil.ewels.co.uk
|
4 |
Tags: carousel, slider, image, bootstrap
|
5 |
Requires at least: 3.0.1
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -12,14 +12,14 @@ 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://
|
16 |
|
17 |
The plugin assumes that you're already using Bootstrap, so you need to load the Bootstrap javascript and CSS separately.
|
18 |
|
19 |
-
* [Download Twitter Bootstrap](http://
|
20 |
* [Bootstrap WordPress Theme](http://320press.com/wpbs/)
|
21 |
* [Bootstrap CDN](http://www.bootstrapcdn.com/) _(hotlink CSS and javascript files)_
|
22 |
-
* [Bootstrap Carousel in action](http://
|
23 |
|
24 |
The carousel can be tweaked using shortcode attributes, eg: `[image-carousel interval="8000" showcaption="false" showcontrols="false"]`
|
25 |
|
@@ -46,19 +46,55 @@ shortcode attributes:
|
|
46 |
* Whether to display the text caption on each image or not. `true` or `false`.
|
47 |
1. `showcontrols` _(default true)_
|
48 |
* Whether to display the control arrows or not. `true` or `false`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
For example, to display the carousel with no captions, no controls and pausing for eight seconds, use the following:
|
51 |
-
`[image-carousel interval="8000" showcaption="false" showcontrols="false"]`
|
52 |
|
53 |
== Frequently Asked Questions ==
|
54 |
|
55 |
-
=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
1. Is the plugin installed and activated?
|
58 |
1. Have you added any items in the `Carousel` post type?
|
59 |
1. Have you placed the `[image-carousel]` shortcode in your page?
|
60 |
|
61 |
-
|
|
|
|
|
62 |
|
63 |
1. Is your theme loading the Bootstrap CSS and Javascript? _(look for `bootstrap.css` in the source HTML)_
|
64 |
|
@@ -66,8 +102,22 @@ For example, to display the carousel with no captions, no controls and pausing f
|
|
66 |
|
67 |
1. You need to make sure that each image is the same height. You can do this by setting an `Aspect ratio` in the `Edit Image` section of the WordPress Media Library and cropping your images.
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
= 1.2 =
|
72 |
* Featured images are now shown in the admin list view
|
73 |
* Added new admin metabox for image url (written by @tallphil, based on code contributed by @atnon)
|
@@ -80,6 +130,9 @@ For example, to display the carousel with no captions, no controls and pausing f
|
|
80 |
|
81 |
== Upgrade Notice ==
|
82 |
|
|
|
|
|
|
|
83 |
= 1.2 =
|
84 |
* Featured images are now shown in the admin list view.
|
85 |
** Note: This update creates a new thumbnail size. I recommend using the [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) WordPress plugin to regenerate all of your image thumbnails.
|
3 |
Donate Link: http://phil.ewels.co.uk
|
4 |
Tags: carousel, slider, image, bootstrap
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 3.6
|
7 |
+
Stable tag: 1.3
|
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 |
|
19 |
+
* [Download Twitter Bootstrap](http://getbootstrap.com/)
|
20 |
* [Bootstrap WordPress Theme](http://320press.com/wpbs/)
|
21 |
* [Bootstrap CDN](http://www.bootstrapcdn.com/) _(hotlink CSS and javascript files)_
|
22 |
+
* [Bootstrap Carousel in action](http://getbootstrap.com/javascript/#carousel)
|
23 |
|
24 |
The carousel can be tweaked using shortcode attributes, eg: `[image-carousel interval="8000" showcaption="false" showcontrols="false"]`
|
25 |
|
46 |
* Whether to display the text caption on each image or not. `true` or `false`.
|
47 |
1. `showcontrols` _(default true)_
|
48 |
* Whether to display the control arrows or not. `true` or `false`.
|
49 |
+
1. `orderby` and `order` _(default `menu_order` `ASC`)_
|
50 |
+
* What order to display the posts in. Uses [WP_Query terms](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
|
51 |
+
1. `category` _(default all)_
|
52 |
+
* Filter carousel items by a comma separated list of carousel category slugs.
|
53 |
+
1. `twbs` _(default 2)_
|
54 |
+
* Output markup for Twitter Bootstrap Version 2 or 3.
|
55 |
+
|
56 |
+
For example, to display a carousel with no captions or controls, use the following:
|
57 |
+
`[image-carousel showcaption="false" showcontrols="false"]`
|
58 |
+
|
59 |
+
To display a carousel which pauses for 8 seconds and shows images in a random order:
|
60 |
+
`[image-carousel interval="8000" orderby="rand"]`
|
61 |
+
|
62 |
+
To display a carousel with images from the `global` and `home` categories, with markup for Twitter Bootstrap v3.x:
|
63 |
+
`[image-carousel category="global,home" twbs="3"]`
|
64 |
|
|
|
|
|
65 |
|
66 |
== Frequently Asked Questions ==
|
67 |
|
68 |
+
= How do I insert the carousel? =
|
69 |
+
|
70 |
+
First of all, install and activate the plugin. Go to 'Carousel' in the WordPress admin pages and add some images. Then, insert the carousel using the `[image-carousel]` into the body of any page.
|
71 |
+
|
72 |
+
= Can I customise the way it looks? =
|
73 |
+
|
74 |
+
The carousel shortcode has a number of attributes that you can use to customise the output. These are described on the [Installation](http://wordpress.org/plugins/cpt-bootstrap-carousel/installation/) page.
|
75 |
+
|
76 |
+
= Can I insert the carousel into a WordPress template instead of a page? =
|
77 |
+
|
78 |
+
Absolutely - you just need to use the [do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) WordPress function. For example:
|
79 |
+
`<?php echo do_shortcode('[image-carousel]'); ?>`
|
80 |
+
|
81 |
+
= Can I change the order that the images display in? =
|
82 |
+
|
83 |
+
You can specify the order that the carousel displays images by using the `orderby` and `order` shortcode attributes. You can use any terms described for the [WP_Query orderby terms](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters), such as random, by date, by title and by menu order.
|
84 |
+
|
85 |
+
= Can I have different carousels with different images on the same site? =
|
86 |
+
|
87 |
+
Yes - create a few categories and add your specific images to a specific category. Then, when inserting the shortcode into the page, specify which category you want it to display images from using the `category` shortcode attribute.
|
88 |
+
|
89 |
+
= Help! Nothing is showing up at all =
|
90 |
|
91 |
1. Is the plugin installed and activated?
|
92 |
1. Have you added any items in the `Carousel` post type?
|
93 |
1. Have you placed the `[image-carousel]` shortcode in your page?
|
94 |
|
95 |
+
Try writing the shortcode using the 'Text' editor instead of the 'Visual' editor, as the visual editor can sometimes add extra unwanted markup.
|
96 |
+
|
97 |
+
= My images are showing but they're all over the place =
|
98 |
|
99 |
1. Is your theme loading the Bootstrap CSS and Javascript? _(look for `bootstrap.css` in the source HTML)_
|
100 |
|
102 |
|
103 |
1. You need to make sure that each image is the same height. You can do this by setting an `Aspect ratio` in the `Edit Image` section of the WordPress Media Library and cropping your images.
|
104 |
|
105 |
+
== Screenshots ==
|
106 |
+
|
107 |
+
1. Admin list interface showing Carousel images and titles.
|
108 |
+
2. Admin image interface showing optional title and caption (Excerpt) fields, along with Category, order, image and URL
|
109 |
+
3. Example output. Requires Bootstrap CSS and Javascript to be loaded (see documentation).
|
110 |
+
|
111 |
== Changelog ==
|
112 |
|
113 |
+
= 1.3 =
|
114 |
+
* Added support for carousel categories, using filtering with the `category` shortcode
|
115 |
+
* Added `orderby` shortcode attribute to specify ordering of images
|
116 |
+
* This means that images can now be in a random order
|
117 |
+
* Added `twbs` shortcode attribute to allow the output of Twitter Bootstrap v3 markup
|
118 |
+
* Added WordPress directory screenshots
|
119 |
+
* Admin thumbnail images now link to the edit page
|
120 |
+
|
121 |
= 1.2 =
|
122 |
* Featured images are now shown in the admin list view
|
123 |
* Added new admin metabox for image url (written by @tallphil, based on code contributed by @atnon)
|
130 |
|
131 |
== Upgrade Notice ==
|
132 |
|
133 |
+
= 1.3 =
|
134 |
+
* A bunch of requested features have been added - mainly random ordering and categories. See the changelog for more details.
|
135 |
+
|
136 |
= 1.2 =
|
137 |
* Featured images are now shown in the admin list view.
|
138 |
** Note: This update creates a new thumbnail size. I recommend using the [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) WordPress plugin to regenerate all of your image thumbnails.
|