CPT Bootstrap Carousel - Version 1.11

Version Description

  • Added support for crossfading images instead of sliding
Download this release

Release Info

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

Code changes from version 1.10 to 1.11

LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
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.10
7
  Author: Phil Ewels
8
  Author URI: http://phil.ewels.co.uk
9
  Text Domain: cpt-bootstrap-carousel
@@ -12,72 +12,14 @@ License: GPLv2
12
 
13
  // Initialise - load in translations
14
  function cptbc_loadtranslations () {
15
- $plugin_dir = basename(dirname(__FILE__)).'/languages';
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,
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 );
63
-
64
-
65
- // Add theme support for featured images if not already present
66
- // http://wordpress.stackexchange.com/questions/23839/using-add-theme-support-inside-a-plugin
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';
74
- add_theme_support( 'post-thumbnails', $supportedTypes[0] );
75
- add_image_size('featured_preview', 100, 55, true);
76
- }
77
- }
78
- add_action( 'after_setup_theme', 'cptbc_addFeaturedImageSupport');
79
 
80
  // Load in the pages doing everything else!
81
- require_once('cptbc-admin.php');
82
- require_once('cptbc-settings.php');
83
- require_once('cptbc-frontend.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://getbootstrap.com/javascript/#carousel" target="_blank">Bootstrap Carousel</a> from a shortcode. Requires Bootstrap javascript and CSS to be loaded separately.
6
+ Version: 1.11
7
  Author: Phil Ewels
8
  Author URI: http://phil.ewels.co.uk
9
  Text Domain: cpt-bootstrap-carousel
12
 
13
  // Initialise - load in translations
14
  function cptbc_loadtranslations () {
15
+ $plugin_dir = basename(dirname(__FILE__)).'/languages';
16
+ load_plugin_textdomain( 'cpt-bootstrap-carousel', false, $plugin_dir );
17
  }
18
  add_action('plugins_loaded', 'cptbc_loadtranslations');
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  // Load in the pages doing everything else!
22
+ require_once('src/cptbc-init.php');
23
+ require_once('src/cptbc-admin.php');
24
+ require_once('src/cptbc-settings.php');
25
+ require_once('src/cptbc-frontend.php');
cptbc-admin.php DELETED
@@ -1,187 +0,0 @@
1
- <?php
2
- /*****************************************************
3
- * CPT Bootstrap Carousel
4
- * http://www.tallphil.co.uk/bootstrap-carousel/
5
- * ----------------------------------------------------
6
- * cptbc-admin.php
7
- * Code to customise the WordPress admin pages
8
- ******************************************************/
9
-
10
- ///////////////////
11
- // ADMIN PAGES
12
- ///////////////////
13
-
14
- // Add column in admin list view to show featured image
15
- // http://wp.tutsplus.com/tutorials/creative-coding/add-a-custom-column-in-posts-and-custom-post-types-admin-screen/
16
- function cptbc_get_featured_image($post_ID) {
17
- $post_thumbnail_id = get_post_thumbnail_id($post_ID);
18
- if ($post_thumbnail_id) {
19
- $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
20
- return $post_thumbnail_img[0];
21
- }
22
- }
23
- function cptbc_columns_head($defaults) {
24
- $defaults['featured_image'] = __('Featured Image', 'cpt-bootstrap-carousel');
25
- $defaults['category'] = __('Category', 'cpt-bootstrap-carousel');
26
- return $defaults;
27
- }
28
- function cptbc_columns_content($column_name, $post_ID) {
29
- if ($column_name == 'featured_image') {
30
- $post_featured_image = cptbc_get_featured_image($post_ID);
31
- if ($post_featured_image) {
32
- echo '<a href="'.get_edit_post_link($post_ID).'"><img src="' . $post_featured_image . '" alt="" style="max-width:100%;" /></a>';
33
- }
34
- }
35
- if ($column_name == 'category') {
36
- $post_categories = get_the_terms($post_ID, 'carousel_category');
37
- if ($post_categories) {
38
- $output = '';
39
- foreach($post_categories as $cat){
40
- $output .= $cat->name.', ';
41
- }
42
- echo trim($output, ', ');
43
- } else {
44
- echo 'No categories';
45
- }
46
- }
47
- }
48
- add_filter('manage_cptbc_posts_columns', 'cptbc_columns_head');
49
- add_action('manage_cptbc_posts_custom_column', 'cptbc_columns_content', 10, 2);
50
-
51
- // Extra admin field for image URL
52
- function cptbc_image_url(){
53
- global $post;
54
- $custom = get_post_custom($post->ID);
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(){
103
- global $post;
104
- if (isset($_POST["cptbc_image_url"])) {
105
- $openblank = 0;
106
- if(isset($_POST["cptbc_image_url_openblank"]) && $_POST["cptbc_image_url_openblank"] == '1'){
107
- $openblank = 1;
108
- }
109
- update_post_meta($post->ID, "cptbc_image_url", esc_url($_POST["cptbc_image_url"]));
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
-
120
-
121
- ///////////////////
122
- // CONTEXTUAL HELP
123
- ///////////////////
124
- function cptbc_contextual_help_tab() {
125
- $screen = get_current_screen();
126
- if( $screen->post_type === 'cptbc'){
127
- $help = '<p>You can add a <strong>CPT Bootstrap Carousel</strong> image carousel using the shortcode <code>[image-carousel]</code>.</p>
128
- <p>You can read the full plugin documentation on the <a href="http://wordpress.org/plugins/cpt-bootstrap-carousel/" target="_blank">WordPress plugins page</a></p>
129
- <p>Most settings can be changed in the <a href="">settings page</a> but you can also specify options for individual carousels
130
- using the following settings:</p>
131
-
132
- <ul>
133
- <li><code>interval</code> <em>(default 5000)</em>
134
- <ul>
135
- <li>Length of time for the caption to pause on each image. Time in milliseconds.</li>
136
- </ul></li>
137
-
138
- <li><code>showcaption</code> <em>(default true)</em>
139
- <ul>
140
- <li>Whether to display the text caption on each image or not. true or false.</li>
141
- </ul></li>
142
-
143
- <li><code>showcontrols</code> <em>(default true)</em>
144
- <ul>
145
- <li>Whether to display the control arrows or not. true or false.</li>
146
- </ul></li>
147
-
148
- <li><code>orderby</code> and <code>order</code> <em>(default menu_order ASC)</em>
149
- <ul>
150
- <li>What order to display the posts in. Uses WP_Query terms.</li>
151
- </ul></li>
152
-
153
- <li><code>category</code> <em>(default all)</em>
154
- <ul>
155
- <li>Filter carousel items by a comma separated list of carousel category slugs.</li>
156
- </ul></li>
157
-
158
- <li><code>image_size</code> <em>(default full)</em>
159
- <ul>
160
- <li>WordPress image size to use, useful for small carousels</li>
161
- </ul></li>
162
-
163
- <li><code>id</code> <em>(default all)</em>
164
- <ul>
165
- <li>Specify the ID of a specific carousel post to display only one image.</li>';
166
- if(isset($_GET['post'])){
167
- $help .= '<li>The ID of the post you\'re currently editing is <strong>'.$_GET['post'].'</strong></li>';
168
- }
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
- ';
178
- $screen->add_help_tab( array(
179
- 'id' => 'cptbc_contextual_help',
180
- 'title' => __('Carousel'),
181
- 'content' => __($help)
182
- ) );
183
- }
184
- } // if( $screen->post_type === 'cptbc'){
185
- add_action('load-post.php', 'cptbc_contextual_help_tab');
186
- add_action('load-post-new.php', 'cptbc_contextual_help_tab');
187
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cptbc-frontend.php DELETED
@@ -1,303 +0,0 @@
1
- <?php
2
- /*****************************************************
3
- * CPT Bootstrap Carousel
4
- * http://www.tallphil.co.uk/bootstrap-carousel/
5
- * ----------------------------------------------------
6
- * cptbc-frontend.php
7
- * Code to handle front-end rendering of the carousel
8
- ******************************************************/
9
-
10
- ///////////////////
11
- // FRONT END
12
- ///////////////////
13
-
14
- // Shortcode
15
- function cptbc_shortcode($atts, $content = null) {
16
- // Set default shortcode attributes
17
- $options = get_option( 'cptbc_settings' );
18
- if(!$options){
19
- cptbc_set_options ();
20
- $options = get_option( 'cptbc_settings' );
21
- }
22
- $options['id'] = '';
23
-
24
- // Parse incomming $atts into an array and merge it with $defaults
25
- $atts = shortcode_atts($options, $atts);
26
-
27
- return cptbc_frontend($atts);
28
- }
29
- add_shortcode('image-carousel', 'cptbc_shortcode');
30
-
31
- // Display carousel
32
- function cptbc_frontend($atts){
33
-
34
- // Build the attributes
35
- $id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page
36
- $args = array(
37
- 'post_type' => 'cptbc',
38
- 'posts_per_page' => '-1',
39
- 'orderby' => $atts['orderby'],
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>';
52
- if(!isset($atts['before_caption'])) $atts['before_caption'] = '<p>';
53
- if(!isset($atts['after_caption'])) $atts['after_caption'] = '</p>';
54
- if(!isset($atts['image_size'])) $atts['image_size'] = 'full';
55
- if(!isset($atts['use_background_images'])) $atts['use_background_images'] = '0';
56
- if(!isset($atts['use_javascript_animation'])) $atts['use_javascript_animation'] = '1';
57
- if(!isset($atts['select_background_images_style_size'])) $atts['select_background_images_style_size'] = 'cover';
58
- if($atts['id'] != ''){
59
- $args['p'] = $atts['id'];
60
- }
61
-
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();
70
- if ( '' != get_the_post_thumbnail(get_the_ID(), $atts['image_size']) ) {
71
- $post_id = get_the_ID();
72
- $title = get_the_title();
73
- $content = get_the_excerpt();
74
- $image = get_the_post_thumbnail( get_the_ID(), $atts['image_size'] );
75
- $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), $atts['image_size']);
76
- $image_src = $image_src[0];
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
-
86
- // Check we actually have something to show
87
- if(count($images) > 0){
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 = '';
117
- if($image['url'] && $atts['link_button'] == 0) {
118
- $linkstart = '<a href="'.$image['url'].'"';
119
- if($image['url_openblank']) {
120
- $linkstart .= ' target="_blank"';
121
- }
122
- $linkstart .= '>';
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']) {
179
- $target = ' target="_blank"';
180
- }
181
- echo '<a href="'.$image['url'].'" '.$target.' class="'.$atts['link_button_class'].'">';
182
- if(isset($image['link_text']) && strlen($image['link_text']) > 0) {
183
- echo $image['link_text'];
184
- } else {
185
- echo $atts['link_button_text'];
186
- }
187
- echo '</a>';
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
-
219
- </div>
220
-
221
- <?php // Javascript animation fallback
222
- if($atts['use_javascript_animation'] == '1'){ ?>
223
- <script type="text/javascript">
224
- jQuery(document).ready(function() {
225
- jQuery('#cptbc_<?php echo $id; ?>').carousel({
226
- interval: <?php echo $atts['interval']; ?>
227
- });
228
- });
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 DELETED
@@ -1,647 +0,0 @@
1
- <?php
2
- /*****************************************************
3
- * CPT Bootstrap Carousel
4
- * http://www.tallphil.co.uk/bootstrap-carousel/
5
- * ----------------------------------------------------
6
- * cptbc-settings.php
7
- * Code to handle the Settings page
8
- ******************************************************/
9
-
10
- ///////////////////
11
- // SETTINGS PAGE
12
- ///////////////////
13
-
14
- // Set up settings defaults
15
- register_activation_hook(__FILE__, 'cptbc_set_options');
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>',
33
- 'after_caption' => '</p>',
34
- 'image_size' => 'full',
35
- 'link_button' => '1',
36
- 'link_button_text' => 'Read more',
37
- 'link_button_class' => 'btn btn-default pull-right',
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
- }
49
- // Clean up on uninstall
50
- register_activation_hook(__FILE__, 'cptbc_deactivate');
51
- function cptbc_deactivate(){
52
- delete_option('cptbc_settings');
53
- }
54
-
55
-
56
- // Render the settings page
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
75
- $this->options = get_option( 'cptbc_settings' );
76
- if(!$this->options){
77
- cptbc_set_options ();
78
- $this->options = get_option( 'cptbc_settings' );
79
- }
80
- ?>
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
107
- __('Carousel Behaviour', 'cpt-bootstrap-carousel'), // Title
108
- array( $this, 'cptbc_settings_behaviour_header' ), // Callback
109
- 'cpt-bootstrap-carousel' // Page
110
- );
111
- add_settings_section(
112
- 'cptbc_settings_setup', // ID
113
- __('Carousel Setup', 'cpt-bootstrap-carousel'), // Title
114
- array( $this, 'cptbc_settings_setup' ), // Callback
115
- 'cpt-bootstrap-carousel' // Page
116
- );
117
- add_settings_section(
118
- 'cptbc_settings_link_buttons', // ID
119
- __('Link Buttons', 'cpt-bootstrap-carousel'), // Title
120
- array( $this, 'cptbc_settings_link_buttons_header' ), // Callback
121
- 'cpt-bootstrap-carousel' // Page
122
- );
123
- add_settings_section(
124
- 'cptbc_settings_markup', // ID
125
- __('Custom Markup', 'cpt-bootstrap-carousel'), // Title
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
133
- __('Slide Interval (milliseconds)', 'cpt-bootstrap-carousel'), // Title
134
- array( $this, 'interval_callback' ), // Callback
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
213
- __('Height if using bkgrnd images (px)', 'cpt-bootstrap-carousel'), // Title
214
- array( $this, 'background_images_height_callback' ), // Callback
215
- 'cpt-bootstrap-carousel', // Page
216
- 'cptbc_settings_setup' // Section
217
- );
218
- add_settings_field(
219
- 'background_images_style_size', // ID
220
- __('Background images size style', 'cpt-bootstrap-carousel'), // Title
221
- array( $this, 'background_images_style_size_callback' ), // Callback
222
- 'cpt-bootstrap-carousel', // Page
223
- 'cptbc_settings_setup' // Section
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
234
- add_settings_field(
235
- 'link_button', // ID
236
- __('Show links as button in caption', 'cpt-bootstrap-carousel'), // Title
237
- array( $this, 'link_button_callback' ), // Callback
238
- 'cpt-bootstrap-carousel', // Page
239
- 'cptbc_settings_link_buttons' // Section
240
- );
241
- add_settings_field(
242
- 'link_button_text', // ID
243
- __('Default text for link buttons', 'cpt-bootstrap-carousel'), // Title
244
- array( $this, 'link_button_text_callback' ), // Callback
245
- 'cpt-bootstrap-carousel', // Page
246
- 'cptbc_settings_link_buttons' // Section
247
- );
248
- add_settings_field(
249
- 'link_button_class', // ID
250
- __('Class for link buttons', 'cpt-bootstrap-carousel'), // Title
251
- array( $this, 'link_button_class_callback' ), // Callback
252
- 'cpt-bootstrap-carousel', // Page
253
- 'cptbc_settings_link_buttons' // Section
254
- );
255
- add_settings_field(
256
- 'link_button_before', // ID
257
- __('HTML before link buttons', 'cpt-bootstrap-carousel'), // Title
258
- array( $this, 'link_button_before_callback' ), // Callback
259
- 'cpt-bootstrap-carousel', // Page
260
- 'cptbc_settings_link_buttons' // Section
261
- );
262
- add_settings_field(
263
- 'link_button_after', // ID
264
- __('HTML after link buttons', 'cpt-bootstrap-carousel'), // Title
265
- array( $this, 'link_button_after_callback' ), // Callback
266
- 'cpt-bootstrap-carousel', // Page
267
- 'cptbc_settings_link_buttons' // Section
268
- );
269
-
270
- // Markup Section
271
- add_settings_field(
272
- 'customprev', // ID
273
- __('Custom prev button class', 'cpt-bootstrap-carousel'), // Title
274
- array( $this, 'customprev_callback' ), // Callback
275
- 'cpt-bootstrap-carousel', // Page
276
- 'cptbc_settings_markup' // Section
277
- );
278
- add_settings_field(
279
- 'customnext', // ID
280
- __('Custom next button class', 'cpt-bootstrap-carousel'), // Title
281
- array( $this, 'customnext_callback' ), // Callback
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
302
- array( $this, 'before_title_callback' ), // Callback
303
- 'cpt-bootstrap-carousel', // Page
304
- 'cptbc_settings_markup' // Section
305
- );
306
- add_settings_field(
307
- 'after_title', // ID
308
- __('HTML after title', 'cpt-bootstrap-carousel'), // Title
309
- array( $this, 'after_title_callback' ), // Callback
310
- 'cpt-bootstrap-carousel', // Page
311
- 'cptbc_settings_markup' // Section
312
- );
313
- add_settings_field(
314
- 'before_caption', // ID
315
- __('HTML before caption text', 'cpt-bootstrap-carousel'), // Title
316
- array( $this, 'before_caption_callback' ), // Callback
317
- 'cpt-bootstrap-carousel', // Page
318
- 'cptbc_settings_markup' // Section
319
- );
320
- add_settings_field(
321
- 'after_caption', // ID
322
- __('HTML after caption text', 'cpt-bootstrap-carousel'), // Title
323
- array( $this, 'after_caption_callback' ), // Callback
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>';
348
- }
349
- public function cptbc_settings_setup() {
350
- echo '<p>'.__('Change the setup of the carousel - how it functions.', 'cpt-bootstrap-carousel').'</p>';
351
- }
352
- public function cptbc_settings_link_buttons_header() {
353
- echo '<p>'.__('Options for using a link button instead of linking the image directly.', 'cpt-bootstrap-carousel').'</p>';
354
- }
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 = '';
382
- $cptbc_showcaption_f = ' selected="selected"';
383
- } else {
384
- $cptbc_showcaption_t = ' selected="selected"';
385
- $cptbc_showcaption_f = '';
386
- }
387
- print '<select id="showcaption" name="cptbc_settings[showcaption]">
388
- <option value="true"'.$cptbc_showcaption_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
389
- <option value="false"'.$cptbc_showcaption_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
390
- </select>';
391
- }
392
- public function showcontrols_callback() {
393
- if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'false'){
394
- $cptbc_showcontrols_t = '';
395
- $cptbc_showcontrols_f = ' selected="selected"';
396
- $cptbc_showcontrols_c = '';
397
- } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'true'){
398
- $cptbc_showcontrols_t = ' selected="selected"';
399
- $cptbc_showcontrols_f = '';
400
- $cptbc_showcontrols_c = '';
401
- } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'custom'){
402
- $cptbc_showcontrols_t = '';
403
- $cptbc_showcontrols_f = '';
404
- $cptbc_showcontrols_c = ' selected="selected"';
405
- }
406
- print '<select id="showcontrols" name="cptbc_settings[showcontrols]">
407
- <option value="true"'.$cptbc_showcontrols_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
408
- <option value="false"'.$cptbc_showcontrols_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
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){
434
- print '<option value="'.$val.'"';
435
- if(isset( $this->options['orderby'] ) && $this->options['orderby'] == $val){
436
- print ' selected="selected"';
437
- }
438
- print ">$option</option>";
439
- }
440
- print '</select>';
441
- }
442
- public function order_callback() {
443
- if(isset( $this->options['order'] ) && $this->options['order'] == 'DESC'){
444
- $cptbc_showcontrols_a = '';
445
- $cptbc_showcontrols_d = ' selected="selected"';
446
- } else {
447
- $cptbc_showcontrols_a = ' selected="selected"';
448
- $cptbc_showcontrols_d = '';
449
- }
450
- print '<select id="order" name="cptbc_settings[order]">
451
- <option value="ASC"'.$cptbc_showcontrols_a.'>'.__('Ascending', 'cpt-bootstrap-carousel').'</option>
452
- <option value="DESC"'.$cptbc_showcontrols_d.'>'.__('Decending', 'cpt-bootstrap-carousel').'</option>
453
- </select>';
454
- }
455
- public function category_callback() {
456
- $cats = get_terms('carousel_category');
457
- print '<select id="orderby" name="cptbc_settings[category]">
458
- <option value="">'.__('All Categories', 'cpt-bootstrap-carousel').'</option>';
459
- foreach($cats as $cat){
460
- print '<option value="'.$cat->name.'"';
461
- if(isset( $this->options['category'] ) && $this->options['category'] == $cat->name){
462
- print ' selected="selected"';
463
- }
464
- print ">".$cat->name."</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
- }
491
- public function image_size_callback() {
492
- $image_sizes = get_intermediate_image_sizes();
493
- print '<select id="image_size" name="cptbc_settings[image_size]">
494
- <option value="full"';
495
- if(isset( $this->options['image_size'] ) && $this->options['image_size'] == 'full'){
496
- print ' selected="selected"';
497
- }
498
- echo '>Full (default)</option>';
499
- foreach($image_sizes as $size){
500
- print '<option value="'.$size.'"';
501
- if(isset( $this->options['image_size'] ) && $this->options['image_size'] == $size){
502
- print ' selected="selected"';
503
- }
504
- print ">".ucfirst($size)."</option>";
505
- }
506
- print '</select>';
507
- echo '<p class="description">'.__("If your carousels are small, you can a smaller image size to increase page load times.", 'cpt-bootstrap-carousel').'</p>';
508
- }
509
- public function use_background_images_callback() {
510
- print '<select id="use_background_images" name="cptbc_settings[use_background_images]">';
511
- print '<option value="0"';
512
- if(isset( $this->options['use_background_images'] ) && $this->options['use_background_images'] == 0){
513
- print ' selected="selected"';
514
- }
515
- echo '>No (default)</option>';
516
- print '<option value="1"';
517
- if(isset( $this->options['use_background_images'] ) && $this->options['use_background_images'] == 1){
518
- print ' selected="selected"';
519
- }
520
- echo '>Yes</option>';
521
- print '</select>';
522
- echo '<p class="description">'.__("Experimental feature - Use CSS background images so that pictures auto-fill the space available.", 'cpt-bootstrap-carousel').'</p>';
523
- }
524
- public function background_images_height_callback() {
525
- printf('<input type="text" id="background_images_height" name="cptbc_settings[background_images_height]" value="%s" size="15" />',
526
- isset( $this->options['background_images_height'] ) ? esc_attr( $this->options['background_images_height']) : '500px');
527
- echo '<p class="description">'.__("If using background images above, how tall do you want the carousel to be?", 'cpt-bootstrap-carousel').'</p>';
528
- }
529
-
530
- public function use_javascript_animation_callback() {
531
- print '<select id="use_javascript_animation" name="cptbc_settings[use_javascript_animation]">';
532
- print '<option value="1"';
533
- if(isset( $this->options['use_javascript_animation'] ) && $this->options['use_javascript_animation'] == 1){
534
- print ' selected="selected"';
535
- }
536
- echo '>Yes (default)</option>';
537
- print '<option value="0"';
538
- if(isset( $this->options['use_javascript_animation'] ) && $this->options['use_javascript_animation'] == 0){
539
- print ' selected="selected"';
540
- }
541
- echo '>No</option>';
542
- print '</select>';
543
- echo '<p class="description">'.__("The Bootstrap Carousel is designed to work usign data-attributes. Sometimes the animation doesn't work correctly with this, so the default is to include a small portion of Javascript to fire the carousel. You can choose not to include this here.", 'cpt-bootstrap-carousel').'</p>';
544
- }
545
- public function background_images_style_size_callback() {
546
- print '<select id="select_background_images_style_size" name="cptbc_settings[select_background_images_style_size]">';
547
- print '<option value="cover"';
548
- if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'cover'){
549
- print ' selected="selected"';
550
- }
551
- echo '>Cover (default)</option>';
552
- print '<option value="contain"';
553
- if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'contain'){
554
- print ' selected="selected"';
555
- }
556
- echo '>Contain</option>';
557
- print '<option value="auto"';
558
- if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'auto'){
559
- print ' selected="selected"';
560
- }
561
- echo '>Auto</option>';
562
- print '</select>';
563
- echo '<p class="description">'.__('If you find that your images are not scaling correctly when using background images try switching the style to \'contain\' or \'auto\'', 'cpt-bootstrap-carousel').'</p>';
564
- }
565
-
566
- // Link buttons section
567
- public function link_button_callback(){
568
- print '<select id="link_button" name="cptbc_settings[link_button]">';
569
- print '<option value="1"';
570
- if(isset( $this->options['link_button'] ) && $this->options['link_button'] == 1){
571
- print ' selected="selected"';
572
- }
573
- echo '>Yes</option>';
574
- print '<option value="0"';
575
- if(!isset( $this->options['link_button'] ) || $this->options['link_button'] == 0){
576
- print ' selected="selected"';
577
- }
578
- echo '>No (Default)</option>';
579
- print '</select>';
580
- echo '<p class="description">'.__("If a URL is set for a carousel image, this option will create a button in the caption instead of linking the image itself.", 'cpt-bootstrap-carousel').'</p>';
581
- }
582
- public function link_button_text_callback() {
583
- printf('<input type="text" id="link_button_text" name="cptbc_settings[link_button_text]" value="%s" size="20" />',
584
- isset( $this->options['link_button_text'] ) ? esc_attr( $this->options['link_button_text']) : 'Read more');
585
- }
586
- public function link_button_class_callback() {
587
- printf('<input type="text" id="link_button_class" name="cptbc_settings[link_button_class]" value="%s" size="20" />',
588
- isset( $this->options['link_button_class'] ) ? esc_attr( $this->options['link_button_class']) : 'btn btn-default pull-right');
589
- echo '<p class="description">'.__("Bootstrap style buttons must have the class <code>btn</code> and then one of the following: <code>btn-default</code>, <code>btn-primary</code>, <code>btn-success</code>, <code>btn-warning</code>, <code>btn-danger</code> or <code>btn-info</code>. No <code>.</code> prefixes. <code>pull-right</code> to float the button on the right. See the ", 'cpt-bootstrap-carousel').' <a href="http://getbootstrap.com/css/#buttons-options" target="_blank">Bootstrap documentation</a>.</p>';
590
- }
591
- public function link_button_before_callback() {
592
- printf('<input type="text" id="link_button_before" name="cptbc_settings[link_button_before]" value="%s" size="20" />',
593
- isset( $this->options['link_button_before'] ) ? esc_attr( $this->options['link_button_before']) : '');
594
- }
595
- public function link_button_after_callback() {
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" />',
603
- isset( $this->options['before_title'] ) ? esc_attr( $this->options['before_title']) : '<h4>');
604
- }
605
- public function customnext_callback() {
606
- printf('<input type="text" id="customnext" name="cptbc_settings[customnext]" value="%s" size="15" />',
607
- isset( $this->options['customnext'] ) ? esc_attr( $this->options['customnext']) : '');
608
- }
609
- public function customprev_callback() {
610
- printf('<input type="text" id="customprev" name="cptbc_settings[customprev]" value="%s" size="15" />',
611
- isset( $this->options['customprev'] ) ? esc_attr( $this->options['customprev']) : '');
612
- }
613
- public function after_title_callback() {
614
- printf('<input type="text" id="after_title" name="cptbc_settings[after_title]" value="%s" size="15" />',
615
- isset( $this->options['after_title'] ) ? esc_attr( $this->options['after_title']) : '</h4>');
616
- }
617
- public function before_caption_callback() {
618
- printf('<input type="text" id="before_caption" name="cptbc_settings[before_caption]" value="%s" size="15" />',
619
- isset( $this->options['before_caption'] ) ? esc_attr( $this->options['before_caption']) : '<p>');
620
- }
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() ){
637
- $cptbc_settings_page = new cptbc_settings_page();
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' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,9 @@ 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: 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
 
@@ -17,83 +18,76 @@ A custom post type for choosing images and content which outputs a [carousel](ht
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
- 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.
31
- `[image-carousel interval="12000"]`
32
-
33
 
34
  * `showcaption` _(default true)_
35
- * Whether to display the text caption on each image or not. `true` or `false`.
36
- `[image-carousel showcaption="false"]`
37
-
38
 
39
  * `showcontrols` _(default true)_
40
- * Whether to display the control arrows or not. `true` or `false`.
41
- `[image-carousel showcontrols="false"]`
42
-
43
 
44
  * `orderby` and `order` _(default `menu_order` `ASC`)_
45
- * What order to display the posts in. Uses [WP_Query terms](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
46
- `[image-carousel orderby="rand"]
47
- [image-carousel orderby="date" orderby="DESC"]`
48
-
49
 
50
  * `category` _(default all)_
51
- * Filter carousel items by a comma separated list of carousel category slugs.
52
- `[image-carousel category="homepage,highlights"]`
53
-
54
 
55
  * `id` _(default all)_
56
- * Specify the ID of a specific carousel post to display only one image.
57
- * Find the image ID by looking at the edit post link, eg. post 109 would be `/wp-admin/post.php?post=109&action=edit`
58
- `[image-carousel id="109"]`
59
-
60
 
61
  * `twbs` _(default 2)_
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) @reddo, @joshgerdes, @atnon, @grahamharper, @rchq, @oheijo, @smtk, @cla63, @cookierebes and @sipman.
68
 
69
- The Serbo-Croation translation was kindly provided by Borisa Djuraskovic from http://www.webhostinghub.com
70
 
71
  = Contributing =
72
 
73
- If you would like to contribute to this plugin, please go to the [GitHub repository](https://github.com/ewels/cpt-bootstrap-carousel) and make a personal fork of the development version. You can then make your changes and submit a pull request. I will happily review the code and then merge when we're both happy. You can read more details [here](https://github.com/ewels/cpt-bootstrap-carousel/blob/master/CONTRIBUTING.md).
74
 
75
  == Installation ==
76
 
77
- = The easy way: =
78
 
79
  1. Go to the Plugins Menu in WordPress
80
- 1. Search for "CPT Bootstrap Carousel"
81
- 1. Click 'Install'
82
- 1. Activate the plugin
83
 
84
  = Manual Installation =
85
 
86
  1. Download the plugin file from this page and unzip the contents
87
- 1. Upload the `cpt-bootstrap-carousel` folder to the `/wp-content/plugins/` directory
88
- 1. Activate the `cpt-bootstrap-carousel` plugin through the 'Plugins' menu in WordPress
89
 
90
  = Once Activated =
91
 
92
  1. Make sure that your theme is loading the [Twitter Bootstrap](http://www.getbootstrap.com) CSS and Carousel javascript
93
- 1. Place the `[image-carousel]` shortcode in a Page or Post
94
- 1. Create new items in the `Carousel` post type, uploading a Featured Image for each.
95
- 1. *Optional:* You can hyperlink each image by entering the desired url `Image Link URL` admin metabox when adding a new carousel image.
96
-
97
 
98
  == Frequently Asked Questions ==
99
 
@@ -103,7 +97,7 @@ This can be caused by having your jQuery and Bootstrap javascript files included
103
 
104
  * Make sure that jQuery is only being included once
105
  * Make sure that the Bootstrap javascript file is being included after jQuery
106
- * NB: This often means putting it after `wp_head()` in your theme's `header.php` file
107
  * Make sure that both jQuery and Bootstrap are being included in the theme header, not footer
108
  * Make sure that the Bootstrap javascript file is referenced _after_ the jQuery file.
109
 
@@ -114,7 +108,10 @@ First of all, install and activate the plugin. Go to 'Carousel' in the WordPress
114
  = Can I insert the carousel into a WordPress template instead of a page? =
115
 
116
  Absolutely - you just need to use the [do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) WordPress function. For example:
117
- `<?php echo do_shortcode('[image-carousel]'); ?>`
 
 
 
118
 
119
  = I get grey bars at the side of my images / The image isn't aligned (or doesn't reach the far side of the carousel) =
120
 
@@ -130,13 +127,13 @@ Yes - create a few categories and add your specific images to a specific categor
130
 
131
  = Can I customise the way it looks / works? =
132
 
133
- The carousel shortcode has a number of attributes that you can use to customise the output. These are described on the main plugin [Description](http://wordpress.org/plugins/cpt-bootstrap-carousel/) page.
134
 
135
  = Help! Nothing is showing up at all =
136
 
137
  1. Is the plugin installed and activated?
138
- 1. Have you added any items in the `Carousel` post type?
139
- 1. Have you placed the `[image-carousel]` shortcode in your page?
140
 
141
  Try writing the shortcode using the 'Text' editor instead of the 'Visual' editor, as the visual editor can sometimes add extra unwanted markup.
142
 
@@ -156,16 +153,22 @@ You need to make sure that each image is the same height. You can do this by set
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
171
  * New German translation courtesy of @stefan-meier
@@ -176,34 +179,39 @@ You need to make sure that each image is the same height. You can do this by set
176
  * Localization file path issue fixed (thanks @stefan-meier)
177
 
178
  = 1.9 =
 
179
  * Prevented the help tab from displaying on pages other than Carousel Items
180
  * Made the output buffer cleaning only happen if we have images (thanks @ChrisLomax)
181
  * Tidied up some warnings generated when WP_DEBUG was true
182
  * New settings option to rely on data-attributes only, without any Javascript chunks
183
  * Split the plugin into multiple files to make code easier to maintain
184
- * Re-wrote the settings page to make things clearer
185
  * Added new feature to have a link button instead of clickable slider image
186
  * Bugfix: Carousel items with links using background images now work.
187
 
188
  = 1.8.1 =
 
189
  * Bugfix. Apologies to anyone who ran into it and thanks to kylewhenderson for the spot.
190
 
191
  = 1.8 =
192
- * Bumped "tested with" up to WP 4.0
 
193
  * Added new plugin icon and updated the banner + screenshots
194
  * Carousel controls now hidden if there is only one image - thanks to @rchq
195
  * Option to use a different WordPress image size, suggested by oheijo
196
  * Added option to specify HTML tags for caption and title. Suggested by smtk
197
  * New option to use background images instead of `<img>` tags. Good for resizing. Suggested by @cla63 and @cookierebes
198
- * New Serbo-Croatian translation! Thanks to borisa from http://www.webhostinghub.com
199
 
200
  = 1.7 =
 
201
  * Added custom classes for next/prev buttons - written by @reddo
202
  * Added admin column for categories
203
  * Made the category dropdown in the settings work (bugfix)
204
  * Addeed contextual help on post and page editing screens
205
 
206
  = 1.6 =
 
207
  * Made the title and caption linked if we have a URL
208
  * Stopped the caption div from displaying if there is not caption
209
  * Added a unique CSS id attribute to each item, based on the wordpress post ID
@@ -212,43 +220,52 @@ You need to make sure that each image is the same height. You can do this by set
212
  * Changed the default version of bootstrap to v3 for new installs. This can be customised in the settings.
213
 
214
  = 1.5 =
 
215
  * Added new Settings page. Means less shortcode attributes, more user friendly
216
  * Added i18n functions so that the plugin can be translated
217
  * Fix: Bug where featured images were shown on all post types. Noticed by @grahamharper
218
 
219
  = 1.4 =
 
220
  * Fix: Bug limited carousel to only 10 images. Now displays all images.
221
  * Fix: Specifying interval didn't always worked. Re-written javascript to make it more reliable
222
  * Added `id` shortcode attribute to specify a single image for the carousel
223
  * Restructured the readme file to make usage clearer
224
 
225
  = 1.3 =
 
226
  * Added support for carousel categories, using filtering with the `category` shortcode
227
  * Added `orderby` shortcode attribute to specify ordering of images
228
- * This means that images can now be in a random order
229
  * Added `twbs` shortcode attribute to allow the output of Twitter Bootstrap v3 markup
230
  * Added WordPress directory screenshots
231
  * Admin thumbnail images now link to the edit page
232
 
233
  = 1.2 =
 
234
  * Featured images are now shown in the admin list view
235
  * Added new admin metabox for image url (written by @tallphil, based on code contributed by @atnon)
236
 
237
  = 1.1 =
 
238
  * Added shortcode attributes (code contributed by @joshgerdes)
239
 
240
  = 1.0 =
 
241
  * Initial release
242
 
243
- == Upgrade Notice ==
244
 
245
  = 1.3 =
 
246
  * A bunch of requested features have been added - mainly random ordering and categories. See the changelog for more details.
247
 
248
  = 1.2 =
 
249
  * Featured images are now shown in the admin list view.
250
- ** 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.
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.
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.4
7
+ Requires PHP: 5.2.4
8
+ Stable tag: 1.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
18
  The plugin assumes that you're already using Bootstrap, so you need to load the Bootstrap javascript and CSS separately.
19
 
20
  * [Download Twitter Bootstrap](http://getbootstrap.com/)
 
21
  * [Bootstrap CDN](http://www.bootstrapcdn.com/) _(hotlink CSS and javascript files)_
22
+ * [Bootstrap Carousel in action](https://getbootstrap.com/docs/4.4/components/carousel/)
23
 
24
+ This plugin is available from the WordPress Plugins Directory: [https://wordpress.org/plugins/cpt-bootstrap-carousel/](https://wordpress.org/plugins/cpt-bootstrap-carousel/).
25
+ The source code is maintained on GitHub: [https://github.com/ewels/cpt-bootstrap-carousel](https://github.com/ewels/cpt-bootstrap-carousel).
26
 
27
  = Shortcode Options =
28
  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...
29
 
30
  * `interval` _(default 5000)_
31
+ * Length of time for the caption to pause on each image. Time in milliseconds.
32
+ * `[image-carousel interval="12000"]`
 
33
 
34
  * `showcaption` _(default true)_
35
+ * Whether to display the text caption on each image or not. `true` or `false`.
36
+ * `[image-carousel showcaption="false"]`
 
37
 
38
  * `showcontrols` _(default true)_
39
+ * Whether to display the control arrows or not. `true` or `false`.
40
+ * `[image-carousel showcontrols="false"]`
 
41
 
42
  * `orderby` and `order` _(default `menu_order` `ASC`)_
43
+ * What order to display the posts in. Uses [WP_Query terms](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
44
+ * `[image-carousel orderby="rand"]`
45
+ * `[image-carousel orderby="date" orderby="DESC"]`
 
46
 
47
  * `category` _(default all)_
48
+ * Filter carousel items by a comma separated list of carousel category slugs.
49
+ * `[image-carousel category="homepage,highlights"]`
 
50
 
51
  * `id` _(default all)_
52
+ * Specify the ID of a specific carousel post to display only one image.
53
+ * Find the image ID by looking at the edit post link, eg. post 109 would be `/wp-admin/post.php?post=109&action=edit`
54
+ * `[image-carousel id="109"]`
 
55
 
56
  * `twbs` _(default 2)_
57
+ * Output markup for Twitter Bootstrap Version 2 or 3.
58
+ * `[image-carousel twbs="3"]`
59
 
60
  = Credits =
61
 
62
  This plugin was written by @tallphil with help and suggestions from several others including (but not limited to) @reddo, @joshgerdes, @atnon, @grahamharper, @rchq, @oheijo, @smtk, @cla63, @cookierebes and @sipman.
63
 
64
+ The Serbo-Croation translation was kindly provided by Borisa Djuraskovic from [http://www.webhostinghub.com](http://www.webhostinghub.com)
65
 
66
  = Contributing =
67
 
68
+ If you would like to contribute to this plugin, please make a personal fork of the GitHub repository and then submit a pull request. For more details please see the [contributing guide](https://github.com/ewels/CPT-Bootstrap-Carousel/CONTRIBUTING.md).
69
 
70
  == Installation ==
71
 
72
+ = The easy way =
73
 
74
  1. Go to the Plugins Menu in WordPress
75
+ 2. Search for "CPT Bootstrap Carousel"
76
+ 3. Click 'Install'
77
+ 4. Activate the plugin
78
 
79
  = Manual Installation =
80
 
81
  1. Download the plugin file from this page and unzip the contents
82
+ 2. Upload the `cpt-bootstrap-carousel` folder to the `/wp-content/plugins/` directory
83
+ 3. Activate the `cpt-bootstrap-carousel` plugin through the 'Plugins' menu in WordPress
84
 
85
  = Once Activated =
86
 
87
  1. Make sure that your theme is loading the [Twitter Bootstrap](http://www.getbootstrap.com) CSS and Carousel javascript
88
+ 2. Place the `[image-carousel]` shortcode in a Page or Post
89
+ 3. Create new items in the `Carousel` post type, uploading a Featured Image for each.
90
+ * (Optional) You can hyperlink each image by entering the desired url `Image Link URL` admin metabox when adding a new carousel image.
 
91
 
92
  == Frequently Asked Questions ==
93
 
97
 
98
  * Make sure that jQuery is only being included once
99
  * Make sure that the Bootstrap javascript file is being included after jQuery
100
+ * NB: This often means putting it after `wp_head()` in your theme's `header.php` file
101
  * Make sure that both jQuery and Bootstrap are being included in the theme header, not footer
102
  * Make sure that the Bootstrap javascript file is referenced _after_ the jQuery file.
103
 
108
  = Can I insert the carousel into a WordPress template instead of a page? =
109
 
110
  Absolutely - you just need to use the [do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) WordPress function. For example:
111
+
112
+ `
113
+ echo do_shortcode('[image-carousel]');
114
+ `
115
 
116
  = I get grey bars at the side of my images / The image isn't aligned (or doesn't reach the far side of the carousel) =
117
 
127
 
128
  = Can I customise the way it looks / works? =
129
 
130
+ The carousel shortcode has a number of attributes that you can use to customise the output. These are described on the main plugin [Description](http://wordpress.org/plugins/cpt-bootstrap-carousel/installation/) page.
131
 
132
  = Help! Nothing is showing up at all =
133
 
134
  1. Is the plugin installed and activated?
135
+ 2. Have you added any items in the `Carousel` post type?
136
+ 3. Have you placed the `[image-carousel]` shortcode in your page?
137
 
138
  Try writing the shortcode using the 'Text' editor instead of the 'Visual' editor, as the visual editor can sometimes add extra unwanted markup.
139
 
153
 
154
  == Changelog ==
155
 
156
+ = 1.11 =
157
+
158
+ * Added support for crossfading images instead of sliding
159
+
160
+ = 1.10 =
161
+
162
  * Added support for Bootstrap 4
163
  * Added support for video backgrounds, youtube or vimeo
164
  * Tested with WordPress 5.1.1
165
  * Separated settings option for _Show Caption / Titles?_ into two, one for each.
166
  * Fixed minor front end bug when using background images. Thanks to @thendigital
167
+ * New Indonesian translation by Jordan Silaen from [http://chameleonjohn.com/](http://chameleonjohn.com/)
168
  * Many other tweaks and improvements
169
 
170
  = 1.9.1 =
171
+
172
  * Titles and captions now show if present, independently of each other (previously both needed to be filled in)
173
  * You can hide them by leaving blank, or setting _Show Slide Titles / Captions?_ to False in the settings
174
  * New German translation courtesy of @stefan-meier
179
  * Localization file path issue fixed (thanks @stefan-meier)
180
 
181
  = 1.9 =
182
+
183
  * Prevented the help tab from displaying on pages other than Carousel Items
184
  * Made the output buffer cleaning only happen if we have images (thanks @ChrisLomax)
185
  * Tidied up some warnings generated when WP_DEBUG was true
186
  * New settings option to rely on data-attributes only, without any Javascript chunks
187
  * Split the plugin into multiple files to make code easier to maintain
188
+ * Rewrote the settings page to be clearer
189
  * Added new feature to have a link button instead of clickable slider image
190
  * Bugfix: Carousel items with links using background images now work.
191
 
192
  = 1.8.1 =
193
+
194
  * Bugfix. Apologies to anyone who ran into it and thanks to kylewhenderson for the spot.
195
 
196
  = 1.8 =
197
+
198
+ * Bumped "tested with" up to `WP 4.0`
199
  * Added new plugin icon and updated the banner + screenshots
200
  * Carousel controls now hidden if there is only one image - thanks to @rchq
201
  * Option to use a different WordPress image size, suggested by oheijo
202
  * Added option to specify HTML tags for caption and title. Suggested by smtk
203
  * New option to use background images instead of `<img>` tags. Good for resizing. Suggested by @cla63 and @cookierebes
204
+ * New Serbo-Croatian translation! Thanks to borisa from [http://www.webhostinghub.com](http://www.webhostinghub.com)
205
 
206
  = 1.7 =
207
+
208
  * Added custom classes for next/prev buttons - written by @reddo
209
  * Added admin column for categories
210
  * Made the category dropdown in the settings work (bugfix)
211
  * Addeed contextual help on post and page editing screens
212
 
213
  = 1.6 =
214
+
215
  * Made the title and caption linked if we have a URL
216
  * Stopped the caption div from displaying if there is not caption
217
  * Added a unique CSS id attribute to each item, based on the wordpress post ID
220
  * Changed the default version of bootstrap to v3 for new installs. This can be customised in the settings.
221
 
222
  = 1.5 =
223
+
224
  * Added new Settings page. Means less shortcode attributes, more user friendly
225
  * Added i18n functions so that the plugin can be translated
226
  * Fix: Bug where featured images were shown on all post types. Noticed by @grahamharper
227
 
228
  = 1.4 =
229
+
230
  * Fix: Bug limited carousel to only 10 images. Now displays all images.
231
  * Fix: Specifying interval didn't always worked. Re-written javascript to make it more reliable
232
  * Added `id` shortcode attribute to specify a single image for the carousel
233
  * Restructured the readme file to make usage clearer
234
 
235
  = 1.3 =
236
+
237
  * Added support for carousel categories, using filtering with the `category` shortcode
238
  * Added `orderby` shortcode attribute to specify ordering of images
239
+ * This means that images can now be in a random order
240
  * Added `twbs` shortcode attribute to allow the output of Twitter Bootstrap v3 markup
241
  * Added WordPress directory screenshots
242
  * Admin thumbnail images now link to the edit page
243
 
244
  = 1.2 =
245
+
246
  * Featured images are now shown in the admin list view
247
  * Added new admin metabox for image url (written by @tallphil, based on code contributed by @atnon)
248
 
249
  = 1.1 =
250
+
251
  * Added shortcode attributes (code contributed by @joshgerdes)
252
 
253
  = 1.0 =
254
+
255
  * Initial release
256
 
257
+ == Upgrade Notice ==
258
 
259
  = 1.3 =
260
+
261
  * A bunch of requested features have been added - mainly random ordering and categories. See the changelog for more details.
262
 
263
  = 1.2 =
264
+
265
  * Featured images are now shown in the admin list view.
266
+ * 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.
267
  * Added a new admin metabox to give each image a link (optional).
268
 
269
  = 1.1 =
270
+
271
  * Added shortcode attribute functionality for tweaking of carousel options.
src/cptbc-admin.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*****************************************************
3
+ * CPT Bootstrap Carousel
4
+ * http://www.tallphil.co.uk/bootstrap-carousel/
5
+ * ----------------------------------------------------
6
+ * cptbc-admin.php
7
+ * Code to customise the WordPress admin pages
8
+ ******************************************************/
9
+
10
+ ///////////////////
11
+ // ADMIN PAGES
12
+ ///////////////////
13
+
14
+ // Add column in admin list view to show featured image
15
+ // http://wp.tutsplus.com/tutorials/creative-coding/add-a-custom-column-in-posts-and-custom-post-types-admin-screen/
16
+ function cptbc_get_featured_image($post_ID) {
17
+ $post_thumbnail_id = get_post_thumbnail_id($post_ID);
18
+ if ($post_thumbnail_id) {
19
+ $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
20
+ return $post_thumbnail_img[0];
21
+ }
22
+ }
23
+ function cptbc_columns_head($defaults) {
24
+ $defaults['featured_image'] = __('Featured Image', 'cpt-bootstrap-carousel');
25
+ $defaults['category'] = __('Category', 'cpt-bootstrap-carousel');
26
+ return $defaults;
27
+ }
28
+ function cptbc_columns_content($column_name, $post_ID) {
29
+ if ($column_name == 'featured_image') {
30
+ $post_featured_image = cptbc_get_featured_image($post_ID);
31
+ if ($post_featured_image) {
32
+ echo '<a href="'.get_edit_post_link($post_ID).'"><img src="' . $post_featured_image . '" alt="" style="max-width:100%;" /></a>';
33
+ }
34
+ }
35
+ if ($column_name == 'category') {
36
+ $post_categories = get_the_terms($post_ID, 'carousel_category');
37
+ if ($post_categories) {
38
+ $output = '';
39
+ foreach($post_categories as $cat){
40
+ $output .= $cat->name.', ';
41
+ }
42
+ echo trim($output, ', ');
43
+ } else {
44
+ echo 'No categories';
45
+ }
46
+ }
47
+ }
48
+ add_filter('manage_cptbc_posts_columns', 'cptbc_columns_head');
49
+ add_action('manage_cptbc_posts_custom_column', 'cptbc_columns_content', 10, 2);
50
+
51
+ // Extra admin field for image URL
52
+ function cptbc_image_url(){
53
+ global $post;
54
+ $custom = get_post_custom($post->ID);
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(){
103
+ global $post;
104
+ if (isset($_POST["cptbc_image_url"])) {
105
+ $openblank = 0;
106
+ if(isset($_POST["cptbc_image_url_openblank"]) && $_POST["cptbc_image_url_openblank"] == '1'){
107
+ $openblank = 1;
108
+ }
109
+ update_post_meta($post->ID, "cptbc_image_url", esc_url($_POST["cptbc_image_url"]));
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
+
120
+
121
+ ///////////////////
122
+ // CONTEXTUAL HELP
123
+ ///////////////////
124
+ function cptbc_contextual_help_tab() {
125
+ $screen = get_current_screen();
126
+ if( $screen->post_type === 'cptbc'){
127
+ $help = '<p>You can add a <strong>CPT Bootstrap Carousel</strong> image carousel using the shortcode <code>[image-carousel]</code>.</p>
128
+ <p>You can read the full plugin documentation on the <a href="http://wordpress.org/plugins/cpt-bootstrap-carousel/" target="_blank">WordPress plugins page</a></p>
129
+ <p>Most settings can be changed in the <a href="">settings page</a> but you can also specify options for individual carousels
130
+ using the following settings:</p>
131
+
132
+ <ul>
133
+ <li><code>interval</code> <em>(default 5000)</em>
134
+ <ul>
135
+ <li>Length of time for the caption to pause on each image. Time in milliseconds.</li>
136
+ </ul></li>
137
+
138
+ <li><code>showcaption</code> <em>(default true)</em>
139
+ <ul>
140
+ <li>Whether to display the text caption on each image or not. true or false.</li>
141
+ </ul></li>
142
+
143
+ <li><code>showcontrols</code> <em>(default true)</em>
144
+ <ul>
145
+ <li>Whether to display the control arrows or not. true or false.</li>
146
+ </ul></li>
147
+
148
+ <li><code>orderby</code> and <code>order</code> <em>(default menu_order ASC)</em>
149
+ <ul>
150
+ <li>What order to display the posts in. Uses WP_Query terms.</li>
151
+ </ul></li>
152
+
153
+ <li><code>category</code> <em>(default all)</em>
154
+ <ul>
155
+ <li>Filter carousel items by a comma separated list of carousel category slugs.</li>
156
+ </ul></li>
157
+
158
+ <li><code>image_size</code> <em>(default full)</em>
159
+ <ul>
160
+ <li>WordPress image size to use, useful for small carousels</li>
161
+ </ul></li>
162
+
163
+ <li><code>id</code> <em>(default all)</em>
164
+ <ul>
165
+ <li>Specify the ID of a specific carousel post to display only one image.</li>';
166
+ if(isset($_GET['post'])){
167
+ $help .= '<li>The ID of the post you\'re currently editing is <strong>'.$_GET['post'].'</strong></li>';
168
+ }
169
+ $help .= '
170
+ </ul></li>
171
+
172
+ <li><code>twbs</code> <em>(default 4)</em>
173
+ <ul>
174
+ <li>Output markup for Twitter Bootstrap Version 2, 3 or 4.</li>
175
+ </ul></li>
176
+ </ul>
177
+ ';
178
+ $screen->add_help_tab( array(
179
+ 'id' => 'cptbc_contextual_help',
180
+ 'title' => __('Carousel'),
181
+ 'content' => __($help)
182
+ ) );
183
+ }
184
+ } // if( $screen->post_type === 'cptbc'){
185
+ add_action('load-post.php', 'cptbc_contextual_help_tab');
186
+ add_action('load-post-new.php', 'cptbc_contextual_help_tab');
src/cptbc-frontend.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*****************************************************
3
+ * CPT Bootstrap Carousel
4
+ * http://www.tallphil.co.uk/bootstrap-carousel/
5
+ * ----------------------------------------------------
6
+ * cptbc-frontend.php
7
+ * Code to handle front-end rendering of the carousel
8
+ ******************************************************/
9
+
10
+ ///////////////////
11
+ // FRONT END
12
+ ///////////////////
13
+
14
+ // Shortcode
15
+ function cptbc_shortcode($atts, $content = null) {
16
+ // Set default shortcode attributes
17
+ $options = get_option( 'cptbc_settings' );
18
+ if(!$options){
19
+ cptbc_set_options ();
20
+ $options = get_option( 'cptbc_settings' );
21
+ }
22
+ $options['id'] = '';
23
+
24
+ // Parse incomming $atts into an array and merge it with $defaults
25
+ $atts = shortcode_atts($options, $atts);
26
+
27
+ return cptbc_frontend($atts);
28
+ }
29
+ add_shortcode('image-carousel', 'cptbc_shortcode');
30
+
31
+ // Display carousel
32
+ function cptbc_frontend($atts){
33
+
34
+ // Build the attributes
35
+ $id = rand(0, 999); // use a random ID so that the CSS IDs work with multiple on one page
36
+ $args = array(
37
+ 'post_type' => 'cptbc',
38
+ 'posts_per_page' => '-1',
39
+ 'orderby' => $atts['orderby'],
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>';
52
+ if(!isset($atts['before_caption'])) $atts['before_caption'] = '<p>';
53
+ if(!isset($atts['after_caption'])) $atts['after_caption'] = '</p>';
54
+ if(!isset($atts['image_size'])) $atts['image_size'] = 'full';
55
+ if(!isset($atts['use_background_images'])) $atts['use_background_images'] = '0';
56
+ if(!isset($atts['use_javascript_animation'])) $atts['use_javascript_animation'] = '1';
57
+ if(!isset($atts['select_background_images_style_size'])) $atts['select_background_images_style_size'] = 'cover';
58
+ if($atts['id'] != ''){
59
+ $args['p'] = $atts['id'];
60
+ }
61
+
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();
70
+ if ( '' != get_the_post_thumbnail(get_the_ID(), $atts['image_size']) ) {
71
+ $post_id = get_the_ID();
72
+ $title = get_the_title();
73
+ $content = get_the_excerpt();
74
+ $image = get_the_post_thumbnail( get_the_ID(), $atts['image_size'] );
75
+ $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), $atts['image_size']);
76
+ $image_src = $image_src[0];
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(
83
+ 'post_id' => $post_id,
84
+ 'title' => $title,
85
+ 'content' => $content,
86
+ 'image' => $image,
87
+ 'img_src' => $image_src,
88
+ 'url' => esc_url($url),
89
+ 'video_url' => esc_url($video_url),
90
+ 'video_aspect' => $video_aspect,
91
+ 'url_openblank' => $url_openblank == "1" ? true : false,
92
+ 'link_text' => $link_text
93
+ );
94
+ }
95
+ }
96
+
97
+ // Check we actually have something to show
98
+ if(count($images) > 0){
99
+ ob_start();
100
+ ?>
101
+ <div id="cptbc_<?php echo $id; ?>" class="carousel slide<?php if($atts['use_carousel_fade'] == '1'){ echo ' carousel-fade'; } ?>" <?php if($atts['use_javascript_animation'] == '0'){ echo ' data-ride="carousel"'; } ?> data-interval="<?php echo $atts['interval']; ?>">
102
+
103
+ <?php
104
+ if( $atts['showindicators'] === 'true' ) {
105
+ // First content - the carousel indicators
106
+ if( count( $images ) > 1 ){ ?>
107
+ <ol class="carousel-indicators">
108
+ <?php foreach ($images as $key => $image) { ?>
109
+ <li data-target="#cptbc_<?php echo $id; ?>" data-slide-to="<?php echo $key; ?>" <?php echo $key == 0 ? 'class="active"' : ''; ?>></li>
110
+ <?php } ?>
111
+ </ol>
112
+ <?php
113
+ }
114
+ } ?>
115
+
116
+ <div class="carousel-inner">
117
+ <?php
118
+ // Carousel Content
119
+ foreach ($images as $key => $image) {
120
+
121
+ if( !isset($atts['link_button']) ) {
122
+ $atts['link_button'] = 0;
123
+ }
124
+
125
+ // Build anchor link so it can be reused
126
+ $linkstart = '';
127
+ $linkend = '';
128
+ if($image['url'] && $atts['link_button'] == 0) {
129
+ $linkstart = '<a href="'.$image['url'].'"';
130
+ if($image['url_openblank']) {
131
+ $linkstart .= ' target="_blank"';
132
+ }
133
+ $linkstart .= '>';
134
+ $linkend = '</a>';
135
+ } ?>
136
+
137
+ <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'] . ';"'; } ?>>
138
+ <?php
139
+ // Regular behaviour - display image with link around it
140
+ if ($image['video_url']) { ?>
141
+ <div class="embed-responsive <?php echo $image['video_aspect']; ?>">
142
+ <?php
143
+ $provider;
144
+ // Check which video provider and set the JS API param
145
+ if (strpos($image['video_url'], 'youtube')) {
146
+ $provider = 'youtube';
147
+ $image['video_url'] .= (strpos($image['video_url'], '?')) ? '&enablejsapi=1' : '?enablejsapi=1';
148
+ } else if (strpos($image['video_url'], 'vimeo')) {
149
+ $provider = 'vimeo';
150
+ $image['video_url'] .= (strpos($image['video_url'], '?')) ? '&api=1' : '?api=1';
151
+ }
152
+
153
+ // if not in list add it
154
+ //if ($video_providers)
155
+ if (!in_array( $provider, $video_providers)) {
156
+ $video_providers[] = $provider;
157
+ }
158
+ ?>
159
+ <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>
160
+ </div>
161
+ <?php
162
+ } else {
163
+ if($atts['use_background_images'] == 0){
164
+ echo $linkstart.$image['image'].$linkend;
165
+ // Background images mode - need block level link inside carousel link if we have a linl
166
+ } else if($image['url'] && $atts['link_button'] == 0) {
167
+ echo '<a href="'.$image['url'].'"';
168
+ if($image['url_openblank']) {
169
+ echo ' target="_blank"';
170
+ }
171
+ echo ' style="display:block; width:100%; height:100%;">&nbsp;</a>';
172
+ }
173
+ // The Caption div
174
+ if(($atts['showtitle'] === 'true' && strlen($image['title']) > 0) || ($atts['showcaption'] === 'true' && strlen($image['content']) > 0) || ($image['url'] && $atts['link_button'] == 1)) {
175
+ if(isset($atts['before_caption_div'])) echo $atts['before_caption_div'];
176
+ echo '<div class="carousel-caption">';
177
+ // Title
178
+ if($atts['showtitle'] === 'true' && strlen($image['title']) > 0){
179
+ echo $atts['before_title'].$linkstart.$image['title'].$linkend.$atts['after_title'];
180
+ }
181
+ // Caption
182
+ if($atts['showcaption'] === 'true' && strlen($image['content']) > 0){
183
+ echo $atts['before_caption'].$linkstart.$image['content'].$linkend.$atts['after_caption'];
184
+ }
185
+ // Link Button
186
+ if($image['url'] && $atts['link_button'] == 1){
187
+ if(isset($atts['link_button_before'])) echo $atts['link_button_before'];
188
+ $target = '';
189
+ if($image['url_openblank']) {
190
+ $target = ' target="_blank"';
191
+ }
192
+ echo '<a href="'.$image['url'].'" '.$target.' class="'.$atts['link_button_class'].'">';
193
+ if(isset($image['link_text']) && strlen($image['link_text']) > 0) {
194
+ echo $image['link_text'];
195
+ } else {
196
+ echo $atts['link_button_text'];
197
+ }
198
+ echo '</a>';
199
+ if(isset($atts['link_button_after'])) echo $atts['link_button_after'];
200
+ }
201
+ echo '</div>';
202
+ if(isset($atts['after_caption_div'])) echo $atts['after_caption_div'];
203
+
204
+ }
205
+ } // End video if ?>
206
+ </div>
207
+ <?php } ?>
208
+ </div>
209
+
210
+ <?php // Previous / Next controls
211
+ if( count( $images ) > 1 ){
212
+ if( $atts['showcontrols'] === 'true' && $atts['twbs' ] == '3') { ?>
213
+ <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
214
+ <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
215
+ <?php } elseif ( $atts['showcontrols'] === 'true' && $atts['twbs'] == '4' ) { ?>
216
+ <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>
217
+ <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>
218
+ <?php } elseif ( $atts['showcontrols'] === 'true' ) { ?>
219
+ <a class="left carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="prev">‹</a>
220
+ <a class="right carousel-control" href="#cptbc_<?php echo $id; ?>" data-slide="next">›</a>
221
+ <?php } elseif ( $atts['showcontrols'] === 'custom' && $atts['twbs'] == '3' && $atts['customprev'] != '' && $atts['customnext'] != '' ) { ?>
222
+ <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>
223
+ <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>
224
+ <? } elseif ( $atts['showcontrols'] === 'custom' && $atts['twbs'] == '4' && $atts['customprev'] != '' && $atts['customnext'] != '' ) { ?>
225
+ <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>
226
+ <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>
227
+ <?php }
228
+ } ?>
229
+
230
+ </div>
231
+
232
+ <?php // Javascript animation fallback
233
+ if($atts['use_javascript_animation'] == '1'){ ?>
234
+ <script type="text/javascript">
235
+ jQuery(document).ready(function() {
236
+ jQuery('#cptbc_<?php echo $id; ?>').carousel({
237
+ interval: <?php echo $atts['interval']; ?>
238
+ });
239
+ });
240
+ </script>
241
+ <?php }
242
+
243
+ // Check & load video auto pause requirements
244
+ if (count($video_providers) > 0) { ?>
245
+ <script>
246
+ var $myCarousel = jQuery('#cptbc_<?php echo $id; ?>');
247
+
248
+ <?php foreach ($video_providers as $provider):
249
+ if ($provider == 'youtube') { ?>
250
+ // See http://jsfiddle.net/8R5y6/
251
+ function callYoutubePlayer(frame_id, func, args) {
252
+ if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id;
253
+ var iframe = document.getElementById(frame_id);
254
+ if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') {
255
+ iframe = iframe.getElementsByTagName('iframe')[0];
256
+ }
257
+ if (iframe) {
258
+ // Frame exists,
259
+ iframe.contentWindow.postMessage(JSON.stringify({
260
+ "event": "command",
261
+ "func": func,
262
+ "args": args || [],
263
+ "id": frame_id
264
+ }), "*");
265
+ }
266
+ }
267
+
268
+ $myCarousel.on("slide.bs.carousel", function (event) {
269
+ var $currentSlide = $myCarousel.find(".active iframe.provider-youtube");
270
+ if (!$currentSlide.length) { return; }
271
+ callYoutubePlayer($currentSlide, 'pauseVideo')
272
+ });
273
+
274
+ <?php }
275
+ if ($provider == 'vimeo') { ?>
276
+ // Youtube version hacked into vimeo version
277
+ function callVimeoPlayer(frame_id, action, args) {
278
+ if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id;
279
+ var iframe = document.getElementById(frame_id);
280
+ if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') {
281
+ iframe = iframe.getElementsByTagName('iframe')[0];
282
+ }
283
+ if (iframe) {
284
+ var data = { method: action };
285
+ if (args) {
286
+ data.value = args;
287
+ }
288
+ url = iframe.src.split('?')[0];
289
+ iframe.contentWindow.postMessage(JSON.stringify(data), url);
290
+ }
291
+ }
292
+
293
+ $myCarousel.on("slide.bs.carousel", function (event) {
294
+ var $currentSlide = $myCarousel.find(".active iframe.provider-vimeo");
295
+ if (!$currentSlide.length) { return; }
296
+ callVimeoPlayer($currentSlide, 'pause')
297
+ });
298
+ <?php }
299
+ endforeach; ?>
300
+ </script>
301
+ <?php }
302
+
303
+ // Collect the output
304
+ $output = ob_get_contents();
305
+ ob_end_clean();
306
+ } else {
307
+ $output = '<!-- CPT Bootstrap Carousel - no images found for #cptbc_'.$id.' -->';
308
+ }
309
+
310
+ // Restore original Post Data
311
+ wp_reset_postdata();
312
+
313
+ return $output;
314
+ }
src/cptbc-init.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ ////////////////////////////
4
+ // Custom Post Type Setup
5
+ ////////////////////////////
6
+ add_action( 'init', 'cptbc_post_type' );
7
+ function cptbc_post_type() {
8
+ $labels = array(
9
+ 'name' => __('Carousel Images', 'cpt-bootstrap-carousel'),
10
+ 'singular_name' => __('Carousel Image', 'cpt-bootstrap-carousel'),
11
+ 'add_new' => __('Add New', 'cpt-bootstrap-carousel'),
12
+ 'add_new_item' => __('Add New Carousel Image', 'cpt-bootstrap-carousel'),
13
+ 'edit_item' => __('Edit Carousel Image', 'cpt-bootstrap-carousel'),
14
+ 'new_item' => __('New Carousel Image', 'cpt-bootstrap-carousel'),
15
+ 'view_item' => __('View Carousel Image', 'cpt-bootstrap-carousel'),
16
+ 'search_items' => __('Search Carousel Images', 'cpt-bootstrap-carousel'),
17
+ 'not_found' => __('No Carousel Image', 'cpt-bootstrap-carousel'),
18
+ 'not_found_in_trash' => __('No Carousel Images found in Trash', 'cpt-bootstrap-carousel'),
19
+ 'parent_item_colon' => '',
20
+ 'menu_name' => __('Carousel', 'cpt-bootstrap-carousel')
21
+ );
22
+ $args = array(
23
+ 'labels' => $labels,
24
+ 'public' => true,
25
+ 'exclude_from_search' => true,
26
+ 'publicly_queryable' => false,
27
+ 'show_ui' => true,
28
+ 'show_in_menu' => true,
29
+ 'query_var' => true,
30
+ 'rewrite' => true,
31
+ 'capability_type' => 'page',
32
+ 'has_archive' => true,
33
+ 'hierarchical' => false,
34
+ 'menu_position' => 21,
35
+ 'menu_icon' => 'dashicons-images-alt',
36
+ 'supports' => array('title','excerpt','thumbnail', 'page-attributes')
37
+ );
38
+ register_post_type('cptbc', $args);
39
+ }
40
+ // Create a taxonomy for the carousel post type
41
+ function cptbc_taxonomies () {
42
+ $args = array('hierarchical' => true, 'label' => 'Carousel Categories');
43
+ register_taxonomy( 'carousel_category', 'cptbc', $args );
44
+ }
45
+ add_action( 'init', 'cptbc_taxonomies', 0 );
46
+
47
+
48
+ // Add theme support for featured images if not already present
49
+ // http://wordpress.stackexchange.com/questions/23839/using-add-theme-support-inside-a-plugin
50
+ function cptbc_addFeaturedImageSupport() {
51
+ $supportedTypes = get_theme_support( 'post-thumbnails' );
52
+ if( $supportedTypes === false ) {
53
+ add_theme_support( 'post-thumbnails', array( 'cptbc' ) );
54
+ add_image_size('featured_preview', 100, 55, true);
55
+ } elseif( is_array( $supportedTypes ) ) {
56
+ $supportedTypes[0][] = 'cptbc';
57
+ add_theme_support( 'post-thumbnails', $supportedTypes[0] );
58
+ add_image_size('featured_preview', 100, 55, true);
59
+ }
60
+ }
61
+ add_action( 'after_setup_theme', 'cptbc_addFeaturedImageSupport');
src/cptbc-settings.php ADDED
@@ -0,0 +1,670 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*****************************************************
3
+ * CPT Bootstrap Carousel
4
+ * http://www.tallphil.co.uk/bootstrap-carousel/
5
+ * ----------------------------------------------------
6
+ * cptbc-settings.php
7
+ * Code to handle the Settings page
8
+ ******************************************************/
9
+
10
+ ///////////////////
11
+ // SETTINGS PAGE
12
+ ///////////////////
13
+
14
+ // Set up settings defaults
15
+ register_activation_hook(__FILE__, 'cptbc_set_options');
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>',
33
+ 'after_caption' => '</p>',
34
+ 'image_size' => 'full',
35
+ 'link_button' => '1',
36
+ 'link_button_text' => 'Read more',
37
+ 'link_button_class' => 'btn btn-default pull-right',
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
+ 'use_carousel_fade' => '0',
47
+ );
48
+ add_option('cptbc_settings', $defaults);
49
+ }
50
+ // Clean up on uninstall
51
+ register_activation_hook(__FILE__, 'cptbc_deactivate');
52
+ function cptbc_deactivate(){
53
+ delete_option('cptbc_settings');
54
+ }
55
+
56
+
57
+ // Render the settings page
58
+ class cptbc_settings_page {
59
+ // Holds the values to be used in the fields callbacks
60
+ private $options;
61
+
62
+ // Start up
63
+ public function __construct() {
64
+ add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
65
+ add_action( 'admin_init', array( $this, 'page_init' ) );
66
+ }
67
+
68
+ // Add settings page
69
+ public function add_plugin_page() {
70
+ 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'));
71
+ }
72
+
73
+ // Options page callback
74
+ public function create_admin_page() {
75
+ // Set class property
76
+ $this->options = get_option( 'cptbc_settings' );
77
+ if(!$this->options){
78
+ cptbc_set_options ();
79
+ $this->options = get_option( 'cptbc_settings' );
80
+ }
81
+ ?>
82
+ <div class="wrap">
83
+ <h2>CPT Bootstrap Carousel <?php _e('Settings', 'cpt-bootstrap-carousel'); ?></h2>
84
+ <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>
85
+
86
+ <form method="post" action="options.php">
87
+ <?php
88
+ settings_fields( 'cptbc_settings' );
89
+ do_settings_sections( 'cpt-bootstrap-carousel' );
90
+ submit_button();
91
+ ?>
92
+ </form>
93
+ </div>
94
+ <?php
95
+ }
96
+
97
+ // Register and add settings
98
+ public function page_init() {
99
+ register_setting(
100
+ 'cptbc_settings', // Option group
101
+ 'cptbc_settings', // Option name
102
+ array( $this, 'sanitize' ) // Sanitize
103
+ );
104
+
105
+ // Sections
106
+ add_settings_section(
107
+ 'cptbc_settings_behaviour', // ID
108
+ __('Carousel Behaviour', 'cpt-bootstrap-carousel'), // Title
109
+ array( $this, 'cptbc_settings_behaviour_header' ), // Callback
110
+ 'cpt-bootstrap-carousel' // Page
111
+ );
112
+ add_settings_section(
113
+ 'cptbc_settings_setup', // ID
114
+ __('Carousel Setup', 'cpt-bootstrap-carousel'), // Title
115
+ array( $this, 'cptbc_settings_setup' ), // Callback
116
+ 'cpt-bootstrap-carousel' // Page
117
+ );
118
+ add_settings_section(
119
+ 'cptbc_settings_link_buttons', // ID
120
+ __('Link Buttons', 'cpt-bootstrap-carousel'), // Title
121
+ array( $this, 'cptbc_settings_link_buttons_header' ), // Callback
122
+ 'cpt-bootstrap-carousel' // Page
123
+ );
124
+ add_settings_section(
125
+ 'cptbc_settings_markup', // ID
126
+ __('Custom Markup', 'cpt-bootstrap-carousel'), // Title
127
+ array( $this, 'cptbc_settings_markup_header' ), // Callback
128
+ 'cpt-bootstrap-carousel' // Page
129
+ );
130
+
131
+ // Behaviour Fields
132
+ add_settings_field(
133
+ 'interval', // ID
134
+ __('Slide Interval (milliseconds)', 'cpt-bootstrap-carousel'), // Title
135
+ array( $this, 'interval_callback' ), // Callback
136
+ 'cpt-bootstrap-carousel', // Page
137
+ 'cptbc_settings_behaviour' // Section
138
+ );
139
+ add_settings_field(
140
+ 'showtitle', // ID
141
+ __('Show Slide Titles?', 'cpt-bootstrap-carousel'), // Title
142
+ array( $this, 'showtitle_callback' ), // Callback
143
+ 'cpt-bootstrap-carousel', // Page
144
+ 'cptbc_settings_behaviour' // Section
145
+ );
146
+ add_settings_field(
147
+ 'showcaption', // ID
148
+ __('Show Slide Captions?', 'cpt-bootstrap-carousel'), // Title
149
+ array( $this, 'showcaption_callback' ), // Callback
150
+ 'cpt-bootstrap-carousel', // Page
151
+ 'cptbc_settings_behaviour' // Section
152
+ );
153
+ add_settings_field(
154
+ 'showcontrols', // ID
155
+ __('Show Slide Controls?', 'cpt-bootstrap-carousel'), // Title
156
+ array( $this, 'showcontrols_callback' ), // Callback
157
+ 'cpt-bootstrap-carousel', // Page
158
+ 'cptbc_settings_behaviour' // Section
159
+ );
160
+ add_settings_field(
161
+ 'showindicators', // ID
162
+ __('Show Slide Indicators?', 'cpt-bootstrap-carousel'), // Title
163
+ array( $this, 'showindicators_callback' ), // Callback
164
+ 'cpt-bootstrap-carousel', // Page
165
+ 'cptbc_settings_behaviour' // Section
166
+ );
167
+ add_settings_field(
168
+ 'orderby', // ID
169
+ __('Order Slides By', 'cpt-bootstrap-carousel'), // Title
170
+ array( $this, 'orderby_callback' ), // Callback
171
+ 'cpt-bootstrap-carousel', // Page
172
+ 'cptbc_settings_behaviour' // Section
173
+ );
174
+ add_settings_field(
175
+ 'order', // ID
176
+ __('Ordering Direction', 'cpt-bootstrap-carousel'), // Title
177
+ array( $this, 'order_callback' ), // Callback
178
+ 'cpt-bootstrap-carousel', // Page
179
+ 'cptbc_settings_behaviour' // Section
180
+ );
181
+ add_settings_field(
182
+ 'category', // ID
183
+ __('Restrict to Category', 'cpt-bootstrap-carousel'), // Title
184
+ array( $this, 'category_callback' ), // Callback
185
+ 'cpt-bootstrap-carousel', // Page
186
+ 'cptbc_settings_behaviour' // Section
187
+ );
188
+
189
+ // Carousel Setup Section
190
+ add_settings_field(
191
+ 'twbs', // ID
192
+ __('Twitter Bootstrap Version', 'cpt-bootstrap-carousel'), // Title
193
+ array( $this, 'twbs_callback' ), // Callback
194
+ 'cpt-bootstrap-carousel', // Page
195
+ 'cptbc_settings_setup' // Section
196
+ );
197
+ add_settings_field(
198
+ 'image_size', // ID
199
+ __('Image Size', 'cpt-bootstrap-carousel'), // Title
200
+ array( $this, 'image_size_callback' ), // Callback
201
+ 'cpt-bootstrap-carousel', // Page
202
+ 'cptbc_settings_setup' // Section
203
+ );
204
+
205
+ add_settings_field(
206
+ 'use_background_images', // ID
207
+ __('Use background images?', 'cpt-bootstrap-carousel'), // Title
208
+ array( $this, 'use_background_images_callback' ), // Callback
209
+ 'cpt-bootstrap-carousel', // Page
210
+ 'cptbc_settings_setup' // Section
211
+ );
212
+ add_settings_field(
213
+ 'background_images_height', // ID
214
+ __('Height if using bkgrnd images (px)', 'cpt-bootstrap-carousel'), // Title
215
+ array( $this, 'background_images_height_callback' ), // Callback
216
+ 'cpt-bootstrap-carousel', // Page
217
+ 'cptbc_settings_setup' // Section
218
+ );
219
+ add_settings_field(
220
+ 'background_images_style_size', // ID
221
+ __('Background images size style', 'cpt-bootstrap-carousel'), // Title
222
+ array( $this, 'background_images_style_size_callback' ), // Callback
223
+ 'cpt-bootstrap-carousel', // Page
224
+ 'cptbc_settings_setup' // Section
225
+ );
226
+ add_settings_field(
227
+ 'use_javascript_animation', // ID
228
+ __('Use Javascript to animate carousel?', 'cpt-bootstrap-carousel'), // Title
229
+ array( $this, 'use_javascript_animation_callback' ), // Callback
230
+ 'cpt-bootstrap-carousel', // Page
231
+ 'cptbc_settings_setup' // Section
232
+ );
233
+ add_settings_field(
234
+ 'use_carousel_fade', // ID
235
+ __('Crossfade images instead of slide animation?', 'cpt-bootstrap-carousel'), // Title
236
+ array( $this, 'use_carousel_fade_callback' ), // Callback
237
+ 'cpt-bootstrap-carousel', // Page
238
+ 'cptbc_settings_setup' // Section
239
+ );
240
+
241
+ // Link buttons
242
+ add_settings_field(
243
+ 'link_button', // ID
244
+ __('Show links as button in caption', 'cpt-bootstrap-carousel'), // Title
245
+ array( $this, 'link_button_callback' ), // Callback
246
+ 'cpt-bootstrap-carousel', // Page
247
+ 'cptbc_settings_link_buttons' // Section
248
+ );
249
+ add_settings_field(
250
+ 'link_button_text', // ID
251
+ __('Default text for link buttons', 'cpt-bootstrap-carousel'), // Title
252
+ array( $this, 'link_button_text_callback' ), // Callback
253
+ 'cpt-bootstrap-carousel', // Page
254
+ 'cptbc_settings_link_buttons' // Section
255
+ );
256
+ add_settings_field(
257
+ 'link_button_class', // ID
258
+ __('Class for link buttons', 'cpt-bootstrap-carousel'), // Title
259
+ array( $this, 'link_button_class_callback' ), // Callback
260
+ 'cpt-bootstrap-carousel', // Page
261
+ 'cptbc_settings_link_buttons' // Section
262
+ );
263
+ add_settings_field(
264
+ 'link_button_before', // ID
265
+ __('HTML before link buttons', 'cpt-bootstrap-carousel'), // Title
266
+ array( $this, 'link_button_before_callback' ), // Callback
267
+ 'cpt-bootstrap-carousel', // Page
268
+ 'cptbc_settings_link_buttons' // Section
269
+ );
270
+ add_settings_field(
271
+ 'link_button_after', // ID
272
+ __('HTML after link buttons', 'cpt-bootstrap-carousel'), // Title
273
+ array( $this, 'link_button_after_callback' ), // Callback
274
+ 'cpt-bootstrap-carousel', // Page
275
+ 'cptbc_settings_link_buttons' // Section
276
+ );
277
+
278
+ // Markup Section
279
+ add_settings_field(
280
+ 'customprev', // ID
281
+ __('Custom prev button class', 'cpt-bootstrap-carousel'), // Title
282
+ array( $this, 'customprev_callback' ), // Callback
283
+ 'cpt-bootstrap-carousel', // Page
284
+ 'cptbc_settings_markup' // Section
285
+ );
286
+ add_settings_field(
287
+ 'customnext', // ID
288
+ __('Custom next button class', 'cpt-bootstrap-carousel'), // Title
289
+ array( $this, 'customnext_callback' ), // Callback
290
+ 'cpt-bootstrap-carousel', // Page
291
+ 'cptbc_settings_markup' // Section
292
+ );
293
+ add_settings_field(
294
+ 'before_caption_div', // ID
295
+ __('HTML before caption div', 'cpt-bootstrap-carousel'), // Title
296
+ array( $this, 'before_caption_div_callback' ), // Callback
297
+ 'cpt-bootstrap-carousel', // Page
298
+ 'cptbc_settings_markup' // Section
299
+ );
300
+ add_settings_field(
301
+ 'after_caption_div', // ID
302
+ __('HTML after caption div', 'cpt-bootstrap-carousel'), // Title
303
+ array( $this, 'after_caption_div_callback' ), // Callback
304
+ 'cpt-bootstrap-carousel', // Page
305
+ 'cptbc_settings_markup' // Section
306
+ );
307
+ add_settings_field(
308
+ 'before_title', // ID
309
+ __('HTML before title', 'cpt-bootstrap-carousel'), // Title
310
+ array( $this, 'before_title_callback' ), // Callback
311
+ 'cpt-bootstrap-carousel', // Page
312
+ 'cptbc_settings_markup' // Section
313
+ );
314
+ add_settings_field(
315
+ 'after_title', // ID
316
+ __('HTML after title', 'cpt-bootstrap-carousel'), // Title
317
+ array( $this, 'after_title_callback' ), // Callback
318
+ 'cpt-bootstrap-carousel', // Page
319
+ 'cptbc_settings_markup' // Section
320
+ );
321
+ add_settings_field(
322
+ 'before_caption', // ID
323
+ __('HTML before caption text', 'cpt-bootstrap-carousel'), // Title
324
+ array( $this, 'before_caption_callback' ), // Callback
325
+ 'cpt-bootstrap-carousel', // Page
326
+ 'cptbc_settings_markup' // Section
327
+ );
328
+ add_settings_field(
329
+ 'after_caption', // ID
330
+ __('HTML after caption text', 'cpt-bootstrap-carousel'), // Title
331
+ array( $this, 'after_caption_callback' ), // Callback
332
+ 'cpt-bootstrap-carousel', // Page
333
+ 'cptbc_settings_markup' // Section
334
+ );
335
+
336
+ }
337
+
338
+ // Sanitize each setting field as needed - @param array $input Contains all settings fields as array keys
339
+ public function sanitize( $input ) {
340
+ $new_input = array();
341
+ foreach($input as $key => $var){
342
+ if($key == 'twbs' || $key == 'interval' || $key == 'background_images_height'){
343
+ $new_input[$key] = absint( $input[$key] );
344
+ } 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'){
345
+ $new_input[$key] = $input[$key]; // Don't sanitise these, meant to be html!
346
+ } else {
347
+ $new_input[$key] = sanitize_text_field( $input[$key] );
348
+ }
349
+ }
350
+ return $new_input;
351
+ }
352
+
353
+ // Print the Section text
354
+ public function cptbc_settings_behaviour_header() {
355
+ echo '<p>'.__('Basic setup of how each Carousel will function, what controls will show and which images will be displayed.', 'cpt-bootstrap-carousel').'</p>';
356
+ }
357
+ public function cptbc_settings_setup() {
358
+ echo '<p>'.__('Change the setup of the carousel - how it functions.', 'cpt-bootstrap-carousel').'</p>';
359
+ }
360
+ public function cptbc_settings_link_buttons_header() {
361
+ echo '<p>'.__('Options for using a link button instead of linking the image directly.', 'cpt-bootstrap-carousel').'</p>';
362
+ }
363
+ public function cptbc_settings_markup_header() {
364
+ echo '<p>'.__('Customise which CSS classes and HTML tags the Carousel uses.', 'cpt-bootstrap-carousel').'</p>';
365
+ }
366
+
367
+ // Callback functions - print the form inputs
368
+ // Carousel behaviour
369
+ public function interval_callback() {
370
+ printf('<input type="text" id="interval" name="cptbc_settings[interval]" value="%s" size="15" />',
371
+ isset( $this->options['interval'] ) ? esc_attr( $this->options['interval']) : '');
372
+ echo '<p class="description">'.__('How long each image shows for before it slides. Set to 0 to disable animation.', 'cpt-bootstrap-carousel').'</p>';
373
+ }
374
+ public function showtitle_callback() {
375
+ if(isset( $this->options['showtitle'] ) && $this->options['showtitle'] == 'false'){
376
+ $cptbc_showtitle_t = '';
377
+ $cptbc_showtitle_f = ' selected="selected"';
378
+ } else {
379
+ $cptbc_showtitle_t = ' selected="selected"';
380
+ $cptbc_showtitle_f = '';
381
+ }
382
+ print '<select id="showtitle" name="cptbc_settings[showtitle]">
383
+ <option value="true"'.$cptbc_showtitle_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
384
+ <option value="false"'.$cptbc_showtitle_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
385
+ </select>';
386
+ }
387
+ public function showcaption_callback() {
388
+ if(isset( $this->options['showcaption'] ) && $this->options['showcaption'] == 'false'){
389
+ $cptbc_showcaption_t = '';
390
+ $cptbc_showcaption_f = ' selected="selected"';
391
+ } else {
392
+ $cptbc_showcaption_t = ' selected="selected"';
393
+ $cptbc_showcaption_f = '';
394
+ }
395
+ print '<select id="showcaption" name="cptbc_settings[showcaption]">
396
+ <option value="true"'.$cptbc_showcaption_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
397
+ <option value="false"'.$cptbc_showcaption_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
398
+ </select>';
399
+ }
400
+ public function showcontrols_callback() {
401
+ if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'false'){
402
+ $cptbc_showcontrols_t = '';
403
+ $cptbc_showcontrols_f = ' selected="selected"';
404
+ $cptbc_showcontrols_c = '';
405
+ } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'true'){
406
+ $cptbc_showcontrols_t = ' selected="selected"';
407
+ $cptbc_showcontrols_f = '';
408
+ $cptbc_showcontrols_c = '';
409
+ } else if(isset( $this->options['showcontrols'] ) && $this->options['showcontrols'] == 'custom'){
410
+ $cptbc_showcontrols_t = '';
411
+ $cptbc_showcontrols_f = '';
412
+ $cptbc_showcontrols_c = ' selected="selected"';
413
+ }
414
+ print '<select id="showcontrols" name="cptbc_settings[showcontrols]">
415
+ <option value="true"'.$cptbc_showcontrols_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
416
+ <option value="false"'.$cptbc_showcontrols_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
417
+ <option value="custom"'.$cptbc_showcontrols_c.'>'.__('Custom', 'cpt-bootstrap-carousel').'</option>
418
+ </select>';
419
+ }
420
+ public function showindicators_callback() {
421
+ if(isset( $this->options['showindicators'] ) && $this->options['showindicators'] == 'false'){
422
+ $cptbc_showindicators_t = '';
423
+ $cptbc_showindicators_f = ' selected="selected"';
424
+ } else if(isset( $this->options['showindicators'] ) && $this->options['showindicators'] == 'true'){
425
+ $cptbc_showindicators_t = ' selected="selected"';
426
+ $cptbc_showindicators_f = '';
427
+ }
428
+ print '<select id="showindicators" name="cptbc_settings[showindicators]">
429
+ <option value="true"'.$cptbc_showindicators_t.'>'.__('Show', 'cpt-bootstrap-carousel').'</option>
430
+ <option value="false"'.$cptbc_showindicators_f.'>'.__('Hide', 'cpt-bootstrap-carousel').'</option>
431
+ </select>';
432
+ }
433
+ public function orderby_callback() {
434
+ $orderby_options = array (
435
+ 'menu_order' => __('Menu order, as set in Carousel overview page', 'cpt-bootstrap-carousel'),
436
+ 'date' => __('Date slide was published', 'cpt-bootstrap-carousel'),
437
+ 'rand' => __('Random ordering', 'cpt-bootstrap-carousel'),
438
+ 'title' => __('Slide title', 'cpt-bootstrap-carousel')
439
+ );
440
+ print '<select id="orderby" name="cptbc_settings[orderby]">';
441
+ foreach($orderby_options as $val => $option){
442
+ print '<option value="'.$val.'"';
443
+ if(isset( $this->options['orderby'] ) && $this->options['orderby'] == $val){
444
+ print ' selected="selected"';
445
+ }
446
+ print ">$option</option>";
447
+ }
448
+ print '</select>';
449
+ }
450
+ public function order_callback() {
451
+ if(isset( $this->options['order'] ) && $this->options['order'] == 'DESC'){
452
+ $cptbc_showcontrols_a = '';
453
+ $cptbc_showcontrols_d = ' selected="selected"';
454
+ } else {
455
+ $cptbc_showcontrols_a = ' selected="selected"';
456
+ $cptbc_showcontrols_d = '';
457
+ }
458
+ print '<select id="order" name="cptbc_settings[order]">
459
+ <option value="ASC"'.$cptbc_showcontrols_a.'>'.__('Ascending', 'cpt-bootstrap-carousel').'</option>
460
+ <option value="DESC"'.$cptbc_showcontrols_d.'>'.__('Decending', 'cpt-bootstrap-carousel').'</option>
461
+ </select>';
462
+ }
463
+ public function category_callback() {
464
+ $cats = get_terms('carousel_category');
465
+ print '<select id="orderby" name="cptbc_settings[category]">
466
+ <option value="">'.__('All Categories', 'cpt-bootstrap-carousel').'</option>';
467
+ foreach($cats as $cat){
468
+ print '<option value="'.$cat->name.'"';
469
+ if(isset( $this->options['category'] ) && $this->options['category'] == $cat->name){
470
+ print ' selected="selected"';
471
+ }
472
+ print ">".$cat->name."</option>";
473
+ }
474
+ print '</select>';
475
+ }
476
+
477
+ // Setup Section
478
+ public function twbs_callback() {
479
+ if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '2'){
480
+ $cptbc_twbs4 = '';
481
+ $cptbc_twbs3 = '';
482
+ $cptbc_twbs2 = ' selected="selected"';
483
+ } else if(isset( $this->options['twbs'] ) && $this->options['twbs'] == '3'){
484
+ $cptbc_twbs4 = '';
485
+ $cptbc_twbs3 = ' selected="selected"';
486
+ $cptbc_twbs2 = '';
487
+ } else {
488
+ $cptbc_twbs4 = ' selected="selected"';
489
+ $cptbc_twbs3 = '';
490
+ $cptbc_twbs2 = '';
491
+ }
492
+ print '<select id="twbs" name="cptbc_settings[twbs]">
493
+ <option value="2"'.$cptbc_twbs2.'>2.x</option>
494
+ <option value="3"'.$cptbc_twbs3.'>3.x</option>
495
+ <option value="4"'.$cptbc_twbs4.'>4.x (Default)</option>
496
+ </select>';
497
+ echo '<p class="description">'.__("Set according to which version of Bootstrap you're using.", 'cpt-bootstrap-carousel').'</p>';
498
+ }
499
+ public function image_size_callback() {
500
+ $image_sizes = get_intermediate_image_sizes();
501
+ print '<select id="image_size" name="cptbc_settings[image_size]">
502
+ <option value="full"';
503
+ if(isset( $this->options['image_size'] ) && $this->options['image_size'] == 'full'){
504
+ print ' selected="selected"';
505
+ }
506
+ echo '>Full (default)</option>';
507
+ foreach($image_sizes as $size){
508
+ print '<option value="'.$size.'"';
509
+ if(isset( $this->options['image_size'] ) && $this->options['image_size'] == $size){
510
+ print ' selected="selected"';
511
+ }
512
+ print ">".ucfirst($size)."</option>";
513
+ }
514
+ print '</select>';
515
+ echo '<p class="description">'.__("If your carousels are small, you can a smaller image size to increase page load times.", 'cpt-bootstrap-carousel').'</p>';
516
+ }
517
+ public function use_background_images_callback() {
518
+ print '<select id="use_background_images" name="cptbc_settings[use_background_images]">';
519
+ print '<option value="0"';
520
+ if(isset( $this->options['use_background_images'] ) && $this->options['use_background_images'] == 0){
521
+ print ' selected="selected"';
522
+ }
523
+ echo '>No (default)</option>';
524
+ print '<option value="1"';
525
+ if(isset( $this->options['use_background_images'] ) && $this->options['use_background_images'] == 1){
526
+ print ' selected="selected"';
527
+ }
528
+ echo '>Yes</option>';
529
+ print '</select>';
530
+ echo '<p class="description">'.__("Experimental feature - Use CSS background images so that pictures auto-fill the space available.", 'cpt-bootstrap-carousel').'</p>';
531
+ }
532
+ public function background_images_height_callback() {
533
+ printf('<input type="text" id="background_images_height" name="cptbc_settings[background_images_height]" value="%s" size="15" />',
534
+ isset( $this->options['background_images_height'] ) ? esc_attr( $this->options['background_images_height']) : '500px');
535
+ echo '<p class="description">'.__("If using background images above, how tall do you want the carousel to be?", 'cpt-bootstrap-carousel').'</p>';
536
+ }
537
+
538
+ public function use_javascript_animation_callback() {
539
+ print '<select id="use_javascript_animation" name="cptbc_settings[use_javascript_animation]">';
540
+ print '<option value="1"';
541
+ if(isset( $this->options['use_javascript_animation'] ) && $this->options['use_javascript_animation'] == 1){
542
+ print ' selected="selected"';
543
+ }
544
+ echo '>Yes (default)</option>';
545
+ print '<option value="0"';
546
+ if(isset( $this->options['use_javascript_animation'] ) && $this->options['use_javascript_animation'] == 0){
547
+ print ' selected="selected"';
548
+ }
549
+ echo '>No</option>';
550
+ print '</select>';
551
+ echo '<p class="description">'.__("The Bootstrap Carousel is designed to work usign data-attributes. Sometimes the animation doesn't work correctly with this, so the default is to include a small portion of Javascript to fire the carousel. You can choose not to include this here.", 'cpt-bootstrap-carousel').'</p>';
552
+ }
553
+ public function use_carousel_fade_callback() {
554
+ print '<select id="use_carousel_fade" name="cptbc_settings[use_carousel_fade]">';
555
+ print '<option value="0"';
556
+ if(isset( $this->options['use_carousel_fade'] ) && $this->options['use_carousel_fade'] == 0){
557
+ print ' selected="selected"';
558
+ }
559
+ echo '>No (Default)</option>';
560
+ print '<option value="1"';
561
+ if(isset( $this->options['use_carousel_fade'] ) && $this->options['use_carousel_fade'] == 1){
562
+ print ' selected="selected"';
563
+ }
564
+ echo '>Yes</option>';
565
+ print '</select>';
566
+ echo '<p class="description">'.__("If selected, images will cross-fade instead of sliding. BS4 only.", 'cpt-bootstrap-carousel').'</p>';
567
+ }
568
+ public function background_images_style_size_callback() {
569
+ print '<select id="select_background_images_style_size" name="cptbc_settings[select_background_images_style_size]">';
570
+ print '<option value="cover"';
571
+ if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'cover'){
572
+ print ' selected="selected"';
573
+ }
574
+ echo '>Cover (default)</option>';
575
+ print '<option value="contain"';
576
+ if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'contain'){
577
+ print ' selected="selected"';
578
+ }
579
+ echo '>Contain</option>';
580
+ print '<option value="auto"';
581
+ if(isset( $this->options['select_background_images_style_size'] ) && $this->options['select_background_images_style_size'] === 'auto'){
582
+ print ' selected="selected"';
583
+ }
584
+ echo '>Auto</option>';
585
+ print '</select>';
586
+ echo '<p class="description">'.__('If you find that your images are not scaling correctly when using background images try switching the style to \'contain\' or \'auto\'', 'cpt-bootstrap-carousel').'</p>';
587
+ }
588
+
589
+ // Link buttons section
590
+ public function link_button_callback(){
591
+ print '<select id="link_button" name="cptbc_settings[link_button]">';
592
+ print '<option value="1"';
593
+ if(isset( $this->options['link_button'] ) && $this->options['link_button'] == 1){
594
+ print ' selected="selected"';
595
+ }
596
+ echo '>Yes</option>';
597
+ print '<option value="0"';
598
+ if(!isset( $this->options['link_button'] ) || $this->options['link_button'] == 0){
599
+ print ' selected="selected"';
600
+ }
601
+ echo '>No (Default)</option>';
602
+ print '</select>';
603
+ echo '<p class="description">'.__("If a URL is set for a carousel image, this option will create a button in the caption instead of linking the image itself.", 'cpt-bootstrap-carousel').'</p>';
604
+ }
605
+ public function link_button_text_callback() {
606
+ printf('<input type="text" id="link_button_text" name="cptbc_settings[link_button_text]" value="%s" size="20" />',
607
+ isset( $this->options['link_button_text'] ) ? esc_attr( $this->options['link_button_text']) : 'Read more');
608
+ }
609
+ public function link_button_class_callback() {
610
+ printf('<input type="text" id="link_button_class" name="cptbc_settings[link_button_class]" value="%s" size="20" />',
611
+ isset( $this->options['link_button_class'] ) ? esc_attr( $this->options['link_button_class']) : 'btn btn-default pull-right');
612
+ echo '<p class="description">'.__("Bootstrap style buttons must have the class <code>btn</code> and then one of the following: <code>btn-default</code>, <code>btn-primary</code>, <code>btn-success</code>, <code>btn-warning</code>, <code>btn-danger</code> or <code>btn-info</code>. No <code>.</code> prefixes. <code>pull-right</code> to float the button on the right. See the ", 'cpt-bootstrap-carousel').' <a href="http://getbootstrap.com/css/#buttons-options" target="_blank">Bootstrap documentation</a>.</p>';
613
+ }
614
+ public function link_button_before_callback() {
615
+ printf('<input type="text" id="link_button_before" name="cptbc_settings[link_button_before]" value="%s" size="20" />',
616
+ isset( $this->options['link_button_before'] ) ? esc_attr( $this->options['link_button_before']) : '');
617
+ }
618
+ public function link_button_after_callback() {
619
+ printf('<input type="text" id="link_button_after" name="cptbc_settings[link_button_after]" value="%s" size="20" />',
620
+ isset( $this->options['link_button_after'] ) ? esc_attr( $this->options['link_button_after']) : '');
621
+ }
622
+
623
+ // Markup section
624
+ public function before_title_callback() {
625
+ printf('<input type="text" id="before_title" name="cptbc_settings[before_title]" value="%s" size="15" />',
626
+ isset( $this->options['before_title'] ) ? esc_attr( $this->options['before_title']) : '<h4>');
627
+ }
628
+ public function customnext_callback() {
629
+ printf('<input type="text" id="customnext" name="cptbc_settings[customnext]" value="%s" size="15" />',
630
+ isset( $this->options['customnext'] ) ? esc_attr( $this->options['customnext']) : '');
631
+ }
632
+ public function customprev_callback() {
633
+ printf('<input type="text" id="customprev" name="cptbc_settings[customprev]" value="%s" size="15" />',
634
+ isset( $this->options['customprev'] ) ? esc_attr( $this->options['customprev']) : '');
635
+ }
636
+ public function after_title_callback() {
637
+ printf('<input type="text" id="after_title" name="cptbc_settings[after_title]" value="%s" size="15" />',
638
+ isset( $this->options['after_title'] ) ? esc_attr( $this->options['after_title']) : '</h4>');
639
+ }
640
+ public function before_caption_callback() {
641
+ printf('<input type="text" id="before_caption" name="cptbc_settings[before_caption]" value="%s" size="15" />',
642
+ isset( $this->options['before_caption'] ) ? esc_attr( $this->options['before_caption']) : '<p>');
643
+ }
644
+ public function after_caption_callback() {
645
+ printf('<input type="text" id="after_caption" name="cptbc_settings[after_caption]" value="%s" size="15" />',
646
+ isset( $this->options['after_caption'] ) ? esc_attr( $this->options['after_caption']) : '</p>');
647
+ }
648
+ public function before_caption_div_callback() {
649
+ printf('<input type="text" id="before_caption_div" name="cptbc_settings[before_caption_div]" value="%s" size="15" />',
650
+ isset( $this->options['before_caption_div'] ) ? esc_attr( $this->options['before_caption_div']) : '');
651
+ }
652
+ public function after_caption_div_callback() {
653
+ printf('<input type="text" id="after_caption_div" name="cptbc_settings[after_caption_div]" value="%s" size="15" />',
654
+ isset( $this->options['after_caption_div'] ) ? esc_attr( $this->options['after_caption_div']) : '');
655
+ }
656
+
657
+ }
658
+
659
+ if( is_admin() ){
660
+ $cptbc_settings_page = new cptbc_settings_page();
661
+ }
662
+
663
+ // Add settings link on plugin page
664
+ function cptbc_settings_link ($links) {
665
+ $settings_link = '<a href="edit.php?post_type=cptbc&page=cpt-bootstrap-carousel">'.__('Settings', 'cpt-bootstrap-carousel').'</a>';
666
+ array_unshift($links, $settings_link);
667
+ return $links;
668
+ }
669
+ $cptbc_plugin = plugin_basename(__FILE__);
670
+ add_filter("plugin_action_links_$cptbc_plugin", 'cptbc_settings_link' );