Accordion Shortcodes - Version 1.2.1

Version Description

  • Added option to open all items by default
Download this release

Release Info

Developer philbuchanan
Plugin Icon 128x128 Accordion Shortcodes
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

Files changed (4) hide show
  1. accordion-shortcodes.php +4 -2
  2. accordion.js +8 -3
  3. accordion.min.js +1 -1
  4. readme.txt +14 -4
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,7 @@ class Accordion_Shortcodes {
46
  # Registers the minified accordion JavaScript file
47
  static function register_script() {
48
 
49
- wp_register_script('accordion-shortcodes-script', plugins_url('accordion.min.js', __FILE__), array('jquery'), '1.2', true);
50
 
51
  }
52
 
@@ -69,6 +69,7 @@ class Accordion_Shortcodes {
69
  extract(shortcode_atts(array(
70
  'autoclose' => true,
71
  'openfirst' => false,
 
72
  'clicktoclose' => false
73
  ), $atts));
74
 
@@ -76,6 +77,7 @@ class Accordion_Shortcodes {
76
  $script_data = array(
77
  'autoClose' => self::parse_boolean($autoclose),
78
  'openFirst' => self::parse_boolean($openfirst),
 
79
  'clickToClose' => self::parse_boolean($clicktoclose)
80
  );
81
  wp_localize_script('accordion-shortcodes-script', 'accordionSettings', $script_data);
2
  /**
3
  * Plugin Name: Accordion Shortcodes
4
  * Description: Adds a few shortcodes to allow for accordion dropdowns.
5
+ * Version: 1.2.1
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
+ wp_register_script('accordion-shortcodes-script', plugins_url('accordion.min.js', __FILE__), array('jquery'), '1.2.1', true);
50
 
51
  }
52
 
69
  extract(shortcode_atts(array(
70
  'autoclose' => true,
71
  'openfirst' => false,
72
+ 'openall' => false,
73
  'clicktoclose' => false
74
  ), $atts));
75
 
77
  $script_data = array(
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);
accordion.js CHANGED
@@ -9,6 +9,7 @@
9
  // Set defaults
10
  autoClose: true,
11
  openFirst: false,
 
12
  clickToClose: false
13
  };
14
 
@@ -17,8 +18,12 @@
17
  settings = accordionSettings;
18
  }
19
 
20
- // Open the first accordion item
21
- if (settings.openFirst) {
 
 
 
 
22
  firstPanel.prev().addClass('open');
23
  firstPanel.slideDown(duration);
24
  }
@@ -40,7 +45,7 @@
40
  $(this).addClass('open');
41
 
42
  }
43
- // If item is open, close it
44
  else if (settings.clickToClose) {
45
 
46
  $(this).next().slideUp(duration);
9
  // Set defaults
10
  autoClose: true,
11
  openFirst: false,
12
+ openAll: false,
13
  clickToClose: false
14
  };
15
 
18
  settings = accordionSettings;
19
  }
20
 
21
+ // Open the first or all accordion items
22
+ if (settings.openAll) {
23
+ allPanels.show();
24
+ allTitles.addClass('open');
25
+ }
26
+ else if (settings.openFirst) {
27
  firstPanel.prev().addClass('open');
28
  firstPanel.slideDown(duration);
29
  }
45
  $(this).addClass('open');
46
 
47
  }
48
+ // If item is open, and click to close is set, close it
49
  else if (settings.clickToClose) {
50
 
51
  $(this).next().slideUp(duration);
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,clickToClose:false};if(typeof accordionSettings!=="undefined"){s=accordionSettings}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};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)
readme.txt CHANGED
@@ -5,7 +5,7 @@ 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
 
@@ -23,6 +23,7 @@ Adds a few shortcodes to allow for accordion dropdowns.
23
  * Only adds JavaScript on pages that use the shortcodes
24
  * Set the HTML tag for the title element of each item (optional)
25
  * Open the first accordion item by default (optional)
 
26
  * Disable auto closing of accordion items (optinoal)
27
  * Manually close items by clicking the title again (optional)
28
 
@@ -34,7 +35,7 @@ The two shortcodes that are added are:
34
 
35
  and
36
 
37
- `[accordion-item title="" tag=""]`
38
 
39
  = Basic Usage Example =
40
 
@@ -73,6 +74,7 @@ There are a few [advances settings](http://wordpress.org/plugins/accordion-short
73
  This is most likely caused by a poorly coded theme. The plugin makes use of the `wp_footer()` function to load the JavaScript file and it's dependancy (jQuery). Check your theme to ensure that the `wp_footer()` function is being called right before the closing `</body>` tag in your themes footer.php file.
74
 
75
  = How can I change the look of the accordion? =
 
76
  No CSS is added by default to the accordion.
77
 
78
  Changing the look and feel of the plugin requires you to be comfortable with editing your themes stylesheet. If you are familier 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.
@@ -103,11 +105,13 @@ Here is some sample CSS to get you started if you want to customize the look and
103
 
104
  There are a few advanced settings you can add to the opening accordion shortcode. The full shortcode, with all the default settings looks like this:
105
 
106
- [accordion autoclose="true" openfirst="false" clicktoclose="false"]
107
 
108
  **autoclose**: Sets whether accordion items close automatically when you open the next item. Set `autoclose="true/false"` on the opening accordion tag like this: `[accordion autoclose="false"]`. Default is `true`.
109
 
110
- **openfirst**: Sets whether the first accordion item is open by default. Set `openfirst="true/false"` on the opening accordion tag like this: `[accordion openfirst="true"]`. Default is `false`.
 
 
111
 
112
  **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`.
113
 
@@ -118,6 +122,9 @@ You can also set the HTML tag for the titles of each item by added `tag="tagname
118
  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/).
119
 
120
  == Changelog ==
 
 
 
121
  = 1.2 =
122
  * Fixed a potential error with headers already being sent
123
  * Fixed an issue with the SVN repo
@@ -155,6 +162,9 @@ For bug reports or feature requests or if you'd like to contribute to the plugin
155
  * Initial release
156
 
157
  == Upgrade Notice ==
 
 
 
158
  = 1.2 =
159
  General code cleanup and bug fixes.
160
 
5
  Tags: accordion, accordions, shortcodes
6
  Requires at least: 3.3
7
  Tested up to: 3.8
8
+ Stable tag: 1.2.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
23
  * Only adds JavaScript on pages that use the shortcodes
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 (optinoal)
28
  * Manually close items by clicking the title again (optional)
29
 
35
 
36
  and
37
 
38
+ `[accordion-item title=""]`
39
 
40
  = Basic Usage Example =
41
 
74
  This is most likely caused by a poorly coded theme. The plugin makes use of the `wp_footer()` function to load the JavaScript file and it's dependancy (jQuery). Check your theme to ensure that the `wp_footer()` function is being called right before the closing `</body>` tag in your themes footer.php file.
75
 
76
  = How can I change the look of the accordion? =
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 familier 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.
105
 
106
  There are a few advanced settings you can add to the opening accordion shortcode. The full shortcode, with all the default settings looks like this:
107
 
108
+ [accordion autoclose="true" openfirst="false" openall="false" clicktoclose="false"]
109
 
110
  **autoclose**: Sets whether accordion items close automatically when you open the next item. Set `autoclose="true/false"` on the opening accordion tag like this: `[accordion autoclose="false"]`. Default is `true`.
111
 
112
+ **openfirst**: Sets whether the first accordion item is open by default. This setting will be overridden if **openall** is set to true. Set `openfirst="true/false"` on the opening accordion tag like this: `[accordion openfirst="true"]`. Default is `false`.
113
+
114
+ **openall**: Sets whether all accordion items are open by default. It is recommened that this setting be used with **clicktoclose**. Set `openall="true/false"` on the opening accordion tag like this: `[accordion openall="true"]`. Default is `false`.
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
 
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
+
128
  = 1.2 =
129
  * Fixed a potential error with headers already being sent
130
  * Fixed an issue with the SVN repo
162
  * Initial release
163
 
164
  == Upgrade Notice ==
165
+ = 1.2.1 =
166
+ Added option to open all items by default.
167
+
168
  = 1.2 =
169
  General code cleanup and bug fixes.
170