Version Description
- Added new Settings page. Means less shortcode attributes, more user friendly
- Added i18n functions so that the plugin can be translated
- Fix: Bug where featured images were shown on all post types. Noticed by @grahamharper
Download this release
Release Info
Developer | tallphil |
Plugin | CPT Bootstrap Carousel |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4 to 1.5
- cpt-bootstrap-carousel.php +304 -26
- readme.txt +14 -5
cpt-bootstrap-carousel.php
CHANGED
@@ -3,28 +3,38 @@
|
|
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
|
10 |
*/
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
// Custom Post Type Setup
|
|
|
13 |
add_action( 'init', 'cptbc_post_type' );
|
14 |
function cptbc_post_type() {
|
15 |
$labels = array(
|
16 |
-
'name' => 'Carousel Images',
|
17 |
-
'singular_name' => 'Carousel Image',
|
18 |
-
'add_new' => 'Add New',
|
19 |
-
'add_new_item' => 'Add New Carousel Image',
|
20 |
-
'edit_item' => 'Edit Carousel Image',
|
21 |
-
'new_item' => 'New Carousel Image',
|
22 |
-
'view_item' => 'View Carousel Image',
|
23 |
-
'search_items' => 'Search Carousel Images',
|
24 |
-
'not_found' =>
|
25 |
-
'not_found_in_trash' => 'No Carousel Images found in Trash',
|
26 |
'parent_item_colon' => '',
|
27 |
-
'menu_name' => 'Carousel'
|
28 |
);
|
29 |
$args = array(
|
30 |
'labels' => $labels,
|
@@ -76,7 +86,7 @@ function cptbc_get_featured_image($post_ID) {
|
|
76 |
}
|
77 |
}
|
78 |
function cptbc_columns_head($defaults) {
|
79 |
-
$defaults['featured_image'] = 'Featured Image';
|
80 |
return $defaults;
|
81 |
}
|
82 |
function cptbc_columns_content($column_name, $post_ID) {
|
@@ -87,8 +97,8 @@ function cptbc_columns_content($column_name, $post_ID) {
|
|
87 |
}
|
88 |
}
|
89 |
}
|
90 |
-
add_filter('
|
91 |
-
add_action('
|
92 |
|
93 |
// Extra admin field for image URL
|
94 |
function cptbc_image_url(){
|
@@ -97,10 +107,10 @@ function cptbc_image_url(){
|
|
97 |
$cptbc_image_url = isset($custom['cptbc_image_url']) ? $custom['cptbc_image_url'][0] : '';
|
98 |
$cptbc_image_url_openblank = isset($custom['cptbc_image_url_openblank']) ? $custom['cptbc_image_url_openblank'][0] : '0';
|
99 |
?>
|
100 |
-
<label
|
101 |
<input name="cptbc_image_url" value="<?php echo $cptbc_image_url; ?>" /> <br />
|
102 |
-
<small><em
|
103 |
-
<label><input type="checkbox" name="cptbc_image_url_openblank" <?php if($cptbc_image_url_openblank == 1){ echo ' checked="checked"'; } ?> value="1" /> Open link in new window
|
104 |
<?php
|
105 |
}
|
106 |
function cptbc_admin_init_custpost(){
|
@@ -116,13 +126,9 @@ function cptbc_mb_save_details(){
|
|
116 |
}
|
117 |
add_action('save_post', 'cptbc_mb_save_details');
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
// Shortcode
|
124 |
-
function cptbc_shortcode($atts, $content = null) {
|
125 |
-
// Set default shortcode attributes
|
126 |
$defaults = array(
|
127 |
'interval' => '5000',
|
128 |
'showcaption' => 'true',
|
@@ -133,9 +139,281 @@ function cptbc_shortcode($atts, $content = null) {
|
|
133 |
'id' => '',
|
134 |
'twbs' => '2'
|
135 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
// Parse incomming $atts into an array and merge it with $defaults
|
138 |
-
$atts = shortcode_atts($
|
139 |
|
140 |
return cptbc_frontend($atts);
|
141 |
}
|
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.5
|
7 |
Author: Phil Ewels
|
8 |
Author URI: http://phil.ewels.co.uk
|
9 |
+
Text Domain: cpt-bootstrap-carousel
|
10 |
License: GPLv2
|
11 |
*/
|
12 |
|
13 |
+
// Initialise - load in translations
|
14 |
+
function cptbc_loadtranslations () {
|
15 |
+
$plugin_dir = basename(dirname(__FILE__));
|
16 |
+
load_plugin_textdomain( 'cpt-bootstrap-carousel', false, $plugin_dir );
|
17 |
+
}
|
18 |
+
add_action('plugins_loaded', 'cptbc_loadtranslations');
|
19 |
+
|
20 |
+
////////////////////////////
|
21 |
// Custom Post Type Setup
|
22 |
+
////////////////////////////
|
23 |
add_action( 'init', 'cptbc_post_type' );
|
24 |
function cptbc_post_type() {
|
25 |
$labels = array(
|
26 |
+
'name' => __('Carousel Images', 'cpt-bootstrap-carousel'),
|
27 |
+
'singular_name' => __('Carousel Image', 'cpt-bootstrap-carousel'),
|
28 |
+
'add_new' => __('Add New', 'cpt-bootstrap-carousel'),
|
29 |
+
'add_new_item' => __('Add New Carousel Image', 'cpt-bootstrap-carousel'),
|
30 |
+
'edit_item' => __('Edit Carousel Image', 'cpt-bootstrap-carousel'),
|
31 |
+
'new_item' => __('New Carousel Image', 'cpt-bootstrap-carousel'),
|
32 |
+
'view_item' => __('View Carousel Image', 'cpt-bootstrap-carousel'),
|
33 |
+
'search_items' => __('Search Carousel Images', 'cpt-bootstrap-carousel'),
|
34 |
+
'not_found' => __('No Carousel Image', 'cpt-bootstrap-carousel'),
|
35 |
+
'not_found_in_trash' => __('No Carousel Images found in Trash', 'cpt-bootstrap-carousel'),
|
36 |
'parent_item_colon' => '',
|
37 |
+
'menu_name' => __('Carousel', 'cpt-bootstrap-carousel')
|
38 |
);
|
39 |
$args = array(
|
40 |
'labels' => $labels,
|
86 |
}
|
87 |
}
|
88 |
function cptbc_columns_head($defaults) {
|
89 |
+
$defaults['featured_image'] = __('Featured Image', 'cpt-bootstrap-carousel');
|
90 |
return $defaults;
|
91 |
}
|
92 |
function cptbc_columns_content($column_name, $post_ID) {
|
97 |
}
|
98 |
}
|
99 |
}
|
100 |
+
add_filter('manage_cptbc_posts_columns', 'cptbc_columns_head');
|
101 |
+
add_action('manage_cptbc_posts_custom_column', 'cptbc_columns_content', 10, 2);
|
102 |
|
103 |
// Extra admin field for image URL
|
104 |
function cptbc_image_url(){
|
107 |
$cptbc_image_url = isset($custom['cptbc_image_url']) ? $custom['cptbc_image_url'][0] : '';
|
108 |
$cptbc_image_url_openblank = isset($custom['cptbc_image_url_openblank']) ? $custom['cptbc_image_url_openblank'][0] : '0';
|
109 |
?>
|
110 |
+
<label><?php _e('Image URL', 'cpt-bootstrap-carousel'); ?>:</label>
|
111 |
<input name="cptbc_image_url" value="<?php echo $cptbc_image_url; ?>" /> <br />
|
112 |
+
<small><em><?php _e('(optional - leave blank for no link)', 'cpt-bootstrap-carousel'); ?></em></small><br /><br />
|
113 |
+
<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>
|
114 |
<?php
|
115 |
}
|
116 |
function cptbc_admin_init_custpost(){
|
126 |
}
|
127 |
add_action('save_post', 'cptbc_mb_save_details');
|
128 |
|
129 |
+
// Set up settings defaults
|
130 |
+
register_activation_hook(__FILE__, 'cptbc_set_options');
|
131 |
+
function cptbc_set_options (){
|
|
|
|
|
|
|
|
|
132 |
$defaults = array(
|
133 |
'interval' => '5000',
|
134 |
'showcaption' => 'true',
|
139 |
'id' => '',
|
140 |
'twbs' => '2'
|
141 |
);
|
142 |
+
add_option('cptbc_settings', $defaults);
|
143 |
+
}
|
144 |
+
// Clean up on uninstall
|
145 |
+
register_activation_hook(__FILE__, 'cptbc_deactivate');
|
146 |
+
function cptbc_deactivate(){
|
147 |
+
delete_option('cptbc_settings');
|
148 |
+
}
|
149 |
+
|
150 |
+
|
151 |
+
///////////////////
|
152 |
+
// SETTINGS PAGE
|
153 |
+
///////////////////
|
154 |
+
class cptbc_settings_page {
|
155 |
+
// Holds the values to be used in the fields callbacks
|
156 |
+
private $options;
|
157 |
+
|
158 |
+
// Start up
|
159 |
+
public function __construct() {
|
160 |
+
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
|
161 |
+
add_action( 'admin_init', array( $this, 'page_init' ) );
|
162 |
+
}
|
163 |
+
|
164 |
+
// Add settings page
|
165 |
+
public function add_plugin_page() {
|
166 |
+
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'));
|
167 |
+
}
|
168 |
+
|
169 |
+
// Options page callback
|
170 |
+
public function create_admin_page() {
|
171 |
+
// Set class property
|
172 |
+
$this->options = get_option( 'cptbc_settings' );
|
173 |
+
if(!$this->options){
|
174 |
+
cptbc_set_options ();
|
175 |
+
$this->options = get_option( 'cptbc_settings' );
|
176 |
+
}
|
177 |
+
?>
|
178 |
+
<div class="wrap">
|
179 |
+
<?php screen_icon('edit');?> <h2>CPT Bootstrap Carousel <?php _e('Settings', 'cpt-bootstrap-carousel'); ?></h2>
|
180 |
+
<p><?php printf(__('You can set the default behaviour of your carousels here. All 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>
|
181 |
+
|
182 |
+
<form method="post" action="options.php">
|
183 |
+
<?php
|
184 |
+
settings_fields( 'cptbc_settings' );
|
185 |
+
do_settings_sections( 'cpt-bootstrap-carousel' );
|
186 |
+
submit_button();
|
187 |
+
?>
|
188 |
+
</form>
|
189 |
+
</div>
|
190 |
+
<?php
|
191 |
+
}
|
192 |
+
|
193 |
+
// Register and add settings
|
194 |
+
public function page_init() {
|
195 |
+
register_setting(
|
196 |
+
'cptbc_settings', // Option group
|
197 |
+
'cptbc_settings', // Option name
|
198 |
+
array( $this, 'sanitize' ) // Sanitize
|
199 |
+
);
|
200 |
+
|
201 |
+
add_settings_section(
|
202 |
+
'cptbc_settings_options', // ID
|
203 |
+
'', // Title - nothing to say here.
|
204 |
+
array( $this, 'cptbc_settings_options_header' ), // Callback
|
205 |
+
'cpt-bootstrap-carousel' // Page
|
206 |
+
);
|
207 |
+
|
208 |
+
add_settings_field(
|
209 |
+
'twbs', // ID
|
210 |
+
__('Twitter Bootstrap Version', 'cpt-bootstrap-carousel'), // Title
|
211 |
+
array( $this, 'twbs_callback' ), // Callback
|
212 |
+
'cpt-bootstrap-carousel', // Page
|
213 |
+
'cptbc_settings_options' // Section
|
214 |
+
);
|
215 |
+
|
216 |
+
add_settings_field(
|
217 |
+
'interval', // ID
|
218 |
+
__('Slide Interval (milliseconds)', 'cpt-bootstrap-carousel'), // Title
|
219 |
+
array( $this, 'interval_callback' ), // Callback
|
220 |
+
'cpt-bootstrap-carousel', // Page
|
221 |
+
'cptbc_settings_options' // Section
|
222 |
+
);
|
223 |
+
|
224 |
+
add_settings_field(
|
225 |
+
'showcaption', // ID
|
226 |
+
__('Show Slide Captions?', 'cpt-bootstrap-carousel'), // Title
|
227 |
+
array( $this, 'showcaption_callback' ), // Callback
|
228 |
+
'cpt-bootstrap-carousel', // Page
|
229 |
+
'cptbc_settings_options' // Section
|
230 |
+
);
|
231 |
+
|
232 |
+
add_settings_field(
|
233 |
+
'showcontrols', // ID
|
234 |
+
__('Show Slide Controls?', 'cpt-bootstrap-carousel'), // Title
|
235 |
+
array( $this, 'showcontrols_callback' ), // Callback
|
236 |
+
'cpt-bootstrap-carousel', // Page
|
237 |
+
'cptbc_settings_options' // Section
|
238 |
+
);
|
239 |
+
|
240 |
+
add_settings_field(
|
241 |
+
'orderby', // ID
|
242 |
+
__('Order Slides By', 'cpt-bootstrap-carousel'), // Title
|
243 |
+
array( $this, 'orderby_callback' ), // Callback
|
244 |
+
'cpt-bootstrap-carousel', // Page
|
245 |
+
'cptbc_settings_options' // Section
|
246 |
+
);
|
247 |
+
|
248 |
+
add_settings_field(
|
249 |
+
'order', // ID
|
250 |
+
__('Ordering Direction', 'cpt-bootstrap-carousel'), // Title
|
251 |
+
array( $this, 'order_callback' ), // Callback
|
252 |
+
'cpt-bootstrap-carousel', // Page
|
253 |
+
'cptbc_settings_options' // Section
|
254 |
+
);
|
255 |
+
|
256 |
+
add_settings_field(
|
257 |
+
'category', // ID
|
258 |
+
__('Restrict to Category', 'cpt-bootstrap-carousel'), // Title
|
259 |
+
array( $this, 'category_callback' ), // Callback
|
260 |
+
'cpt-bootstrap-carousel', // Page
|
261 |
+
'cptbc_settings_options' // Section
|
262 |
+
);
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
// Sanitize each setting field as needed - @param array $input Contains all settings fields as array keys
|
267 |
+
public function sanitize( $input ) {
|
268 |
+
$new_input = array();
|
269 |
+
foreach($input as $key => $var){
|
270 |
+
if($key == 'twbs' || $key == 'interval'){
|
271 |
+
$new_input[$key] = absint( $input[$key] );
|
272 |
+
if($key == 'interval' && $new_input[$key] == 0){
|
273 |
+
$new_input[$key] = 5000;
|
274 |
+
}
|
275 |
+
} else {
|
276 |
+
$new_input[$key] = sanitize_text_field( $input[$key] );
|
277 |
+
}
|
278 |
+
}
|
279 |
+
return $new_input;
|
280 |
+
}
|
281 |
+
|
282 |
+
// Print the Section text
|
283 |
+
public function cptbc_settings_options_header() {
|
284 |
+
// nothing to say here.
|
285 |
+
}
|
286 |
+
|
287 |
+
public function twbs_callback() {
|
288 |
+
if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '3'){
|
289 |
+
$cptbc_twbs3 = ' selected="selected"';
|
290 |
+
$cptbc_twbs2 = '';
|
291 |
+
} else {
|
292 |
+
$cptbc_twbs3 = '';
|
293 |
+
$cptbc_twbs2 = ' selected="selected"';
|
294 |
+
}
|
295 |
+
print '<select id="twbs" name="cptbc_settings[twbs]">
|
296 |
+
<option value="2"'.$cptbc_twbs2.'>2.x</option>
|
297 |
+
<option value="3"'.$cptbc_twbs3.'>3.x</option>
|
298 |
+
</select>';
|
299 |
+
}
|
300 |
+
|
301 |
+
public function interval_callback() {
|
302 |
+
printf('<input type="text" id="interval" name="cptbc_settings[interval]" value="%s" size="6" />',
|
303 |
+
isset( $this->options['interval'] ) ? esc_attr( $this->options['interval']) : '');
|
304 |
+
}
|
305 |
+
|
306 |
+
public function showcaption_callback() {
|
307 |
+
if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){
|
308 |
+
$cptbc_showcaption_t = '';
|
309 |
+
$cptbc_showcaption_f = ' selected="selected"';
|
310 |
+
} else {
|
311 |
+
$cptbc_showcaption_t = ' selected="selected"';
|
312 |
+
$cptbc_showcaption_f = '';
|
313 |
+
}
|
314 |
+
print '<select id="showcaption" name="cptbc_settings[showcaption]">
|
315 |
+
<option value="true"'.$cptbc_showcaption_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
|
316 |
+
<option value="false"'.$cptbc_showcaption_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
|
317 |
+
</select>';
|
318 |
+
}
|
319 |
+
|
320 |
+
public function showcontrols_callback() {
|
321 |
+
if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'false'){
|
322 |
+
$cptbc_showcontrols_t = '';
|
323 |
+
$cptbc_showcontrols_f = ' selected="selected"';
|
324 |
+
} else {
|
325 |
+
$cptbc_showcontrols_t = ' selected="selected"';
|
326 |
+
$cptbc_showcontrols_f = '';
|
327 |
+
}
|
328 |
+
print '<select id="showcontrols" name="cptbc_settings[showcontrols]">
|
329 |
+
<option value="true"'.$cptbc_showcontrols_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
|
330 |
+
<option value="false"'.$cptbc_showcontrols_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
|
331 |
+
</select>';
|
332 |
+
}
|
333 |
+
|
334 |
+
public function orderby_callback() {
|
335 |
+
$orderby_options = array (
|
336 |
+
'menu_order' => __('Menu order, as set in Carousel overview page', 'cpt-bootstrap-carousel'),
|
337 |
+
'date' => __('Date slide was published', 'cpt-bootstrap-carousel'),
|
338 |
+
'rand' => __('Random ordering', 'cpt-bootstrap-carousel'),
|
339 |
+
'title' => __('Slide title', 'cpt-bootstrap-carousel')
|
340 |
+
);
|
341 |
+
print '<select id="orderby" name="cptbc_settings[orderby]">';
|
342 |
+
foreach($orderby_options as $val => $option){
|
343 |
+
print '<option value="'.$val.'"';
|
344 |
+
if(isset( $this->options['orderby'] ) && $this->options['orderby'] == $val){
|
345 |
+
print ' selected="selected"';
|
346 |
+
}
|
347 |
+
print ">$option</option>";
|
348 |
+
}
|
349 |
+
print '</select>';
|
350 |
+
}
|
351 |
+
|
352 |
+
public function order_callback() {
|
353 |
+
if(isset( $this->options['order'] ) && $this->options['order'] == 'DESC'){
|
354 |
+
$cptbc_showcontrols_a = '';
|
355 |
+
$cptbc_showcontrols_d = ' selected="selected"';
|
356 |
+
} else {
|
357 |
+
$cptbc_showcontrols_a = ' selected="selected"';
|
358 |
+
$cptbc_showcontrols_d = '';
|
359 |
+
}
|
360 |
+
print '<select id="order" name="cptbc_settings[order]">
|
361 |
+
<option value="ASC"'.$cptbc_showcontrols_a.'>'.__('Ascending', 'cpt-bootstrap-carousel').'</option>
|
362 |
+
<option value="DESC"'.$cptbc_showcontrols_d.'>'.__('Decending', 'cpt-bootstrap-carousel').'</option>
|
363 |
+
</select>';
|
364 |
+
}
|
365 |
+
|
366 |
+
public function category_callback() {
|
367 |
+
$cats = get_terms('carousel_category');
|
368 |
+
print '<select id="orderby" name="cptbc_settings[category]">
|
369 |
+
<option value="">'.__('All Categories', 'cpt-bootstrap-carousel').'</option>';
|
370 |
+
foreach($cats as $cat){
|
371 |
+
print '<option value="'.$cat->term_id.'"';
|
372 |
+
if(isset( $this->options['category'] ) && $this->options['category'] == $cat->term_id){
|
373 |
+
print ' selected="selected"';
|
374 |
+
}
|
375 |
+
print ">".$cat->name."</option>";
|
376 |
+
}
|
377 |
+
print '</select>';
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
}
|
382 |
+
|
383 |
+
if( is_admin() ){
|
384 |
+
$cptbc_settings_page = new cptbc_settings_page();
|
385 |
+
}
|
386 |
+
|
387 |
+
// Add settings link on plugin page
|
388 |
+
function cptbc_settings_link ($links) {
|
389 |
+
$settings_link = '<a href="edit.php?post_type=cptbc&page=cpt-bootstrap-carousel">'.__('Settings', 'cpt-bootstrap-carousel').'</a>';
|
390 |
+
array_unshift($links, $settings_link);
|
391 |
+
return $links;
|
392 |
+
}
|
393 |
+
$cptbc_plugin = plugin_basename(__FILE__);
|
394 |
+
add_filter("plugin_action_links_$cptbc_plugin", 'cptbc_settings_link' );
|
395 |
+
|
396 |
+
|
397 |
+
|
398 |
+
|
399 |
+
|
400 |
+
|
401 |
+
///////////////////
|
402 |
+
// FRONT END
|
403 |
+
///////////////////
|
404 |
+
|
405 |
+
// Shortcode
|
406 |
+
function cptbc_shortcode($atts, $content = null) {
|
407 |
+
// Set default shortcode attributes
|
408 |
+
$options = get_option( 'cptbc_settings' );
|
409 |
+
if(!$options){
|
410 |
+
cptbc_set_options ();
|
411 |
+
$options = get_option( 'cptbc_settings' );
|
412 |
+
}
|
413 |
+
$options['id'] = '';
|
414 |
|
415 |
// Parse incomming $atts into an array and merge it with $defaults
|
416 |
+
$atts = shortcode_atts($options, $atts);
|
417 |
|
418 |
return cptbc_frontend($atts);
|
419 |
}
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== CPT Bootstrap Carousel ===
|
2 |
-
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: 3.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -24,7 +24,7 @@ The plugin assumes that you're already using Bootstrap, so you need to load the
|
|
24 |
If you'd like to contribute to this plugin, you can find it [hosted on GitHub](https://github.com/tallphil/cpt-bootstrap-carousel).
|
25 |
|
26 |
= Shortcode Options =
|
27 |
-
|
28 |
|
29 |
* `interval` _(default 5000)_
|
30 |
* Length of time for the caption to pause on each image. Time in milliseconds.
|
@@ -62,6 +62,10 @@ You can specify how long the carousel pauses for, and whether to display caption
|
|
62 |
* Output markup for Twitter Bootstrap Version 2 or 3.
|
63 |
`[image-carousel twbs="3"]`
|
64 |
|
|
|
|
|
|
|
|
|
65 |
|
66 |
== Installation ==
|
67 |
|
@@ -108,7 +112,7 @@ Absolutely - you just need to use the [do_shortcode](http://codex.wordpress.org/
|
|
108 |
|
109 |
= Can I change the order that the images display in? =
|
110 |
|
111 |
-
You can specify the order that the carousel displays images by using the `orderby` and `order` shortcode attributes.
|
112 |
|
113 |
= Can I have different carousels with different images on the same site? =
|
114 |
|
@@ -142,6 +146,11 @@ You need to make sure that each image is the same height. You can do this by set
|
|
142 |
|
143 |
== Changelog ==
|
144 |
|
|
|
|
|
|
|
|
|
|
|
145 |
= 1.4 =
|
146 |
* Fix: Bug limited carousel to only 10 images. Now displays all images.
|
147 |
* Fix: Specifying interval didn't always worked. Re-written javascript to make it more reliable
|
1 |
=== CPT Bootstrap Carousel ===
|
2 |
+
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: 3.8
|
7 |
+
Stable tag: 1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
24 |
If you'd like to contribute to this plugin, you can find it [hosted on GitHub](https://github.com/tallphil/cpt-bootstrap-carousel).
|
25 |
|
26 |
= Shortcode Options =
|
27 |
+
As of version 1.5, nearly all of these options can be set in the CPT Bootstrap Carousel Settings page. However, if you'd like different settings for different carousels, you can override these by using shortcode options...
|
28 |
|
29 |
* `interval` _(default 5000)_
|
30 |
* Length of time for the caption to pause on each image. Time in milliseconds.
|
62 |
* Output markup for Twitter Bootstrap Version 2 or 3.
|
63 |
`[image-carousel twbs="3"]`
|
64 |
|
65 |
+
= Credits =
|
66 |
+
|
67 |
+
This plugin was written by @tallphil with help and suggestions from several others including (but not limited to) @joshgerdes, @atnon and @grahamharper.
|
68 |
+
|
69 |
|
70 |
== Installation ==
|
71 |
|
112 |
|
113 |
= Can I change the order that the images display in? =
|
114 |
|
115 |
+
You can specify the order that the carousel displays images by changing the setting in the Settings page, or by using the `orderby` and `order` shortcode attributes. The settings page has common settings, or you can use any terms described for the [WP_Query orderby terms](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters) for the shortcode.
|
116 |
|
117 |
= Can I have different carousels with different images on the same site? =
|
118 |
|
146 |
|
147 |
== Changelog ==
|
148 |
|
149 |
+
= 1.5 =
|
150 |
+
* Added new Settings page. Means less shortcode attributes, more user friendly
|
151 |
+
* Added i18n functions so that the plugin can be translated
|
152 |
+
* Fix: Bug where featured images were shown on all post types. Noticed by @grahamharper
|
153 |
+
|
154 |
= 1.4 =
|
155 |
* Fix: Bug limited carousel to only 10 images. Now displays all images.
|
156 |
* Fix: Specifying interval didn't always worked. Re-written javascript to make it more reliable
|