Version Description
- Added option to scroll page to title when it's clicked open
- Added detection for SCRIPT_DEBUG to load minified JavaScript conditionally
Download this release
Release Info
Developer | philbuchanan |
Plugin | Accordion Shortcodes |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- accordion-shortcodes.php +7 -4
- accordion.js +10 -2
- accordion.min.js +1 -1
- readme.txt +19 -9
accordion-shortcodes.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Accordion Shortcodes
|
4 |
* Description: Adds a few shortcodes to allow for accordion dropdowns.
|
5 |
-
* Version: 1.2.
|
6 |
* Author: Phil Buchanan
|
7 |
* Author URI: http://philbuchanan.com
|
8 |
*/
|
@@ -46,7 +46,8 @@ class Accordion_Shortcodes {
|
|
46 |
# Registers the minified accordion JavaScript file
|
47 |
static function register_script() {
|
48 |
|
49 |
-
|
|
|
50 |
|
51 |
}
|
52 |
|
@@ -70,7 +71,8 @@ class Accordion_Shortcodes {
|
|
70 |
'autoclose' => true,
|
71 |
'openfirst' => false,
|
72 |
'openall' => false,
|
73 |
-
'clicktoclose' => false
|
|
|
74 |
), $atts));
|
75 |
|
76 |
# Set settings object (for use in JavaScript)
|
@@ -78,7 +80,8 @@ class Accordion_Shortcodes {
|
|
78 |
'autoClose' => self::parse_boolean($autoclose),
|
79 |
'openFirst' => self::parse_boolean($openfirst),
|
80 |
'openAll' => self::parse_boolean($openall),
|
81 |
-
'clickToClose' => self::parse_boolean($clicktoclose)
|
|
|
82 |
);
|
83 |
wp_localize_script('accordion-shortcodes-script', 'accordionSettings', $script_data);
|
84 |
|
2 |
/**
|
3 |
* Plugin Name: Accordion Shortcodes
|
4 |
* Description: Adds a few shortcodes to allow for accordion dropdowns.
|
5 |
+
* Version: 1.2.2
|
6 |
* Author: Phil Buchanan
|
7 |
* Author URI: http://philbuchanan.com
|
8 |
*/
|
46 |
# Registers the minified accordion JavaScript file
|
47 |
static function register_script() {
|
48 |
|
49 |
+
$min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
|
50 |
+
wp_register_script('accordion-shortcodes-script', plugins_url('accordion' . $min . '.js', __FILE__), array('jquery'), '1.2.2', true);
|
51 |
|
52 |
}
|
53 |
|
71 |
'autoclose' => true,
|
72 |
'openfirst' => false,
|
73 |
'openall' => false,
|
74 |
+
'clicktoclose' => false,
|
75 |
+
'scroll' => false
|
76 |
), $atts));
|
77 |
|
78 |
# Set settings object (for use in JavaScript)
|
80 |
'autoClose' => self::parse_boolean($autoclose),
|
81 |
'openFirst' => self::parse_boolean($openfirst),
|
82 |
'openAll' => self::parse_boolean($openall),
|
83 |
+
'clickToClose' => self::parse_boolean($clicktoclose),
|
84 |
+
'scroll' => self::parse_boolean($scroll)
|
85 |
);
|
86 |
wp_localize_script('accordion-shortcodes-script', 'accordionSettings', $script_data);
|
87 |
|
accordion.js
CHANGED
@@ -10,7 +10,8 @@
|
|
10 |
autoClose: true,
|
11 |
openFirst: false,
|
12 |
openAll: false,
|
13 |
-
clickToClose: false
|
|
|
14 |
};
|
15 |
|
16 |
// Check for accordion settings variable passed from WordPress
|
@@ -41,7 +42,14 @@
|
|
41 |
}
|
42 |
|
43 |
// Open clicked item
|
44 |
-
$(this).next().slideDown(duration)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
$(this).addClass('open');
|
46 |
|
47 |
}
|
10 |
autoClose: true,
|
11 |
openFirst: false,
|
12 |
openAll: false,
|
13 |
+
clickToClose: false,
|
14 |
+
scroll: false
|
15 |
};
|
16 |
|
17 |
// Check for accordion settings variable passed from WordPress
|
42 |
}
|
43 |
|
44 |
// Open clicked item
|
45 |
+
$(this).next().slideDown(duration, function() {
|
46 |
+
// Scroll page to the title
|
47 |
+
if (settings.scroll) {
|
48 |
+
$('html, body').animate({
|
49 |
+
scrollTop: $(this).prev().offset().top
|
50 |
+
}, duration);
|
51 |
+
}
|
52 |
+
});
|
53 |
$(this).addClass('open');
|
54 |
|
55 |
}
|
accordion.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
(function(e){"use strict";var t=e(".accordion-title"),n=e(".accordion-content").hide(),r=e(".accordion-content:first-of-type"),i=250,s={autoClose:true,openFirst:false,openAll:false,clickToClose:false};if(typeof accordionSettings!=="undefined"){s=accordionSettings}if(s.openAll){n.show();t.addClass("open")}else if(s.openFirst){r.prev().addClass("open");r.slideDown(i)}t.click(function(){if(!e(this).hasClass("open")){if(s.autoClose){n.slideUp(i);t.removeClass("open")}e(this).next().slideDown(i);e(this).addClass("open")}else if(s.clickToClose){e(this).next().slideUp(i);e(this).removeClass("open")}return false})})(jQuery)
|
1 |
+
(function(e){"use strict";var t=e(".accordion-title"),n=e(".accordion-content").hide(),r=e(".accordion-content:first-of-type"),i=250,s={autoClose:true,openFirst:false,openAll:false,clickToClose:false,scroll:false};if(typeof accordionSettings!=="undefined"){s=accordionSettings}if(s.openAll){n.show();t.addClass("open")}else if(s.openFirst){r.prev().addClass("open");r.slideDown(i)}t.click(function(){if(!e(this).hasClass("open")){if(s.autoClose){n.slideUp(i);t.removeClass("open")}e(this).next().slideDown(i,function(){if(s.scroll){e("html, body").animate({scrollTop:e(this).prev().offset().top},i)}});e(this).addClass("open")}else if(s.clickToClose){e(this).next().slideUp(i);e(this).removeClass("open")}return false})})(jQuery)
|
readme.txt
CHANGED
@@ -5,14 +5,14 @@ Donate Link: http://philbuchanan.com/
|
|
5 |
Tags: accordion, accordions, shortcodes
|
6 |
Requires at least: 3.3
|
7 |
Tested up to: 3.8
|
8 |
-
Stable tag: 1.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
-
Adds a few shortcodes to allow for accordion
|
13 |
|
14 |
== Description ==
|
15 |
-
Adds a few shortcodes to allow for accordion
|
16 |
|
17 |
**NOTE:** If you are not comfortable with WordPress shortcodes, this plugin may not be for you.
|
18 |
|
@@ -24,8 +24,9 @@ Adds a few shortcodes to allow for accordion dropdowns.
|
|
24 |
* Set the HTML tag for the title element of each item (optional)
|
25 |
* Open the first accordion item by default (optional)
|
26 |
* Open all accordion items by default (optional)
|
27 |
-
* Disable auto closing of accordion items (
|
28 |
* Manually close items by clicking the title again (optional)
|
|
|
29 |
|
30 |
= The Shortcodes =
|
31 |
|
@@ -40,8 +41,8 @@ and
|
|
40 |
= Basic Usage Example =
|
41 |
|
42 |
[accordion]
|
43 |
-
[accordion-item title="Title of accordion item"]
|
44 |
-
[accordion-item title="Second accordion item"]
|
45 |
[/accordion]
|
46 |
|
47 |
This will output the following HTML:
|
@@ -49,11 +50,11 @@ This will output the following HTML:
|
|
49 |
<div class="accordion">
|
50 |
<h3 class="accordion-title">Title of accordion item</h3>
|
51 |
<div class="accordion-content">
|
52 |
-
|
53 |
</div>
|
54 |
<h3 class="accordion-title">Second accordion item</h3>
|
55 |
<div class="accordion-content">
|
56 |
-
|
57 |
</div>
|
58 |
</div>
|
59 |
|
@@ -77,7 +78,7 @@ This is most likely caused by a poorly coded theme. The plugin makes use of the
|
|
77 |
|
78 |
No CSS is added by default to the accordion.
|
79 |
|
80 |
-
Changing the look and feel of the plugin requires you to be comfortable with editing your themes stylesheet. If you are
|
81 |
|
82 |
== Other Notes ==
|
83 |
|
@@ -115,6 +116,8 @@ There are a few advanced settings you can add to the opening accordion shortcode
|
|
115 |
|
116 |
**clicktoclose**: Sets whether clicking an open title closes it. Set `clicktoclose="true/false"` on the opening accordion tag like this: `[accordion clicktoclose="true"]`. Default is `false`.
|
117 |
|
|
|
|
|
118 |
You can also set the HTML tag for the titles of each item by added `tag="tagname"` to each `[accordion-item]` shortcode. Make sure to **not** include the angle brackets around the tag name. Example: to use `<h2>` instead of the default `<h3>` tag: `[accordion-item title="Item title" tag="h2"]Item content[/accordion-item]`
|
119 |
|
120 |
= Issues/Suggestions =
|
@@ -122,6 +125,10 @@ You can also set the HTML tag for the titles of each item by added `tag="tagname
|
|
122 |
For bug reports or feature requests or if you'd like to contribute to the plugin you can check everything out on [Github](https://github.com/philbuchanan/Accordion-Shortcodes/).
|
123 |
|
124 |
== Changelog ==
|
|
|
|
|
|
|
|
|
125 |
= 1.2.1 =
|
126 |
* Added option to open all items by default
|
127 |
|
@@ -162,6 +169,9 @@ For bug reports or feature requests or if you'd like to contribute to the plugin
|
|
162 |
* Initial release
|
163 |
|
164 |
== Upgrade Notice ==
|
|
|
|
|
|
|
165 |
= 1.2.1 =
|
166 |
Added option to open all items by default.
|
167 |
|
5 |
Tags: accordion, accordions, shortcodes
|
6 |
Requires at least: 3.3
|
7 |
Tested up to: 3.8
|
8 |
+
Stable tag: 1.2.2
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
+
Adds a few shortcodes to allow for accordion drop-downs.
|
13 |
|
14 |
== Description ==
|
15 |
+
Adds a few shortcodes to allow for accordion drop-downs.
|
16 |
|
17 |
**NOTE:** If you are not comfortable with WordPress shortcodes, this plugin may not be for you.
|
18 |
|
24 |
* Set the HTML tag for the title element of each item (optional)
|
25 |
* Open the first accordion item by default (optional)
|
26 |
* Open all accordion items by default (optional)
|
27 |
+
* Disable auto closing of accordion items (optional)
|
28 |
* Manually close items by clicking the title again (optional)
|
29 |
+
* Scroll page to title when it's clicked open (optional)
|
30 |
|
31 |
= The Shortcodes =
|
32 |
|
41 |
= Basic Usage Example =
|
42 |
|
43 |
[accordion]
|
44 |
+
[accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
|
45 |
+
[accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
|
46 |
[/accordion]
|
47 |
|
48 |
This will output the following HTML:
|
50 |
<div class="accordion">
|
51 |
<h3 class="accordion-title">Title of accordion item</h3>
|
52 |
<div class="accordion-content">
|
53 |
+
Drop-down content goes here.
|
54 |
</div>
|
55 |
<h3 class="accordion-title">Second accordion item</h3>
|
56 |
<div class="accordion-content">
|
57 |
+
Drop-down content goes here.
|
58 |
</div>
|
59 |
</div>
|
60 |
|
78 |
|
79 |
No CSS is added by default to the accordion.
|
80 |
|
81 |
+
Changing the look and feel of the plugin requires you to be comfortable with editing your themes stylesheet. If you are familiar with that process, you can add some [CSS](http://wordpress.org/plugins/accordion-shortcodes/other_notes/#Other-Notes) to make the accordion look the way you want.
|
82 |
|
83 |
== Other Notes ==
|
84 |
|
116 |
|
117 |
**clicktoclose**: Sets whether clicking an open title closes it. Set `clicktoclose="true/false"` on the opening accordion tag like this: `[accordion clicktoclose="true"]`. Default is `false`.
|
118 |
|
119 |
+
**scroll**: Sets whether to scroll to the title when it's clicked open. This is useful if you have a lot of content within your accordion items. Set `scroll="true/false"` on the opening accordion tag like this: `[accordion scroll="true"]`. Default is `false`.
|
120 |
+
|
121 |
You can also set the HTML tag for the titles of each item by added `tag="tagname"` to each `[accordion-item]` shortcode. Make sure to **not** include the angle brackets around the tag name. Example: to use `<h2>` instead of the default `<h3>` tag: `[accordion-item title="Item title" tag="h2"]Item content[/accordion-item]`
|
122 |
|
123 |
= Issues/Suggestions =
|
125 |
For bug reports or feature requests or if you'd like to contribute to the plugin you can check everything out on [Github](https://github.com/philbuchanan/Accordion-Shortcodes/).
|
126 |
|
127 |
== Changelog ==
|
128 |
+
= 1.2.2 =
|
129 |
+
* Added option to scroll page to title when it's clicked open
|
130 |
+
* Added detection for SCRIPT_DEBUG to load minified JavaScript conditionally
|
131 |
+
|
132 |
= 1.2.1 =
|
133 |
* Added option to open all items by default
|
134 |
|
169 |
* Initial release
|
170 |
|
171 |
== Upgrade Notice ==
|
172 |
+
= 1.2.2 =
|
173 |
+
Added option to scroll page to title when it's clicked open (useful if your accordion items contain a lot of content).
|
174 |
+
|
175 |
= 1.2.1 =
|
176 |
Added option to open all items by default.
|
177 |
|