Accordion Shortcodes - Version 1.1.1

Version Description

Added a link to plugin documentation from the plugins page for easy access.

Download this release

Release Info

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

Code changes from version trunk to 1.1.1

accordion-shortcodes.php CHANGED
@@ -1,328 +1,114 @@
1
  <?php
2
  /**
3
  * Plugin Name: Accordion Shortcodes
4
- * Description: Shortcodes for creating responsive accordion drop-downs.
5
- * Version: 2.3.3
6
  * Author: Phil Buchanan
7
  * Author URI: http://philbuchanan.com
8
  */
9
 
10
- require_once('tinymce/tinymce.php');
11
-
12
- // Make sure to not redeclare the class
13
  if (!class_exists('Accordion_Shortcodes')) :
14
 
15
  class Accordion_Shortcodes {
16
 
17
- /**
18
- * Current plugin version number
19
- */
20
- private $plugin_version = '2.3.3';
21
-
22
-
23
-
24
- /**
25
- * Should the accordion JavaScript file be loaded the on the current page
26
- * False by default
27
- */
28
- private $load_script = false;
29
-
30
-
31
-
32
- /**
33
- * Holds all the accordion shortcodes group settings
34
- */
35
- private $script_data = array();
36
-
37
-
38
-
39
- /**
40
- * Count of each accordion group on a page
41
- */
42
- private $group_count = 0;
43
-
44
-
45
-
46
- /**
47
- * Count for each accordion item within an accordion group
48
- */
49
- private $item_count = 0;
50
-
51
-
52
-
53
- /**
54
- * Holds the accordion group container HTML tag
55
- */
56
- private $wrapper_tag = 'div';
57
-
58
-
59
-
60
- /**
61
- * Holds the accordion item title HTML tag
62
- */
63
- private $title_tag = 'h3';
64
-
65
-
66
-
67
- /**
68
- * Holds the accordion item content container HTML tag
69
- */
70
- private $content_tag = 'div';
71
-
72
-
73
-
74
- /**
75
- * Class constructor
76
- * Sets up the plugin, including: textdomain, adding shortcodes, registering
77
- * scripts and adding buttons.
78
- */
79
  function __construct() {
 
80
  $basename = plugin_basename(__FILE__);
81
-
82
- // Load text domain
83
  load_plugin_textdomain('accordion_shortcodes', false, dirname($basename) . '/languages/');
84
-
85
- // Register JavaScript
86
- add_action('wp_enqueue_scripts', array($this, 'register_script'));
87
-
88
- // Add shortcodes
89
- $prefix = $this->get_compatibility_prefix();
90
-
91
- add_shortcode($prefix . 'accordion', array($this, 'accordion_shortcode'));
92
- add_shortcode($prefix . 'accordion-item', array($this, 'accordion_item_shortcode'));
93
-
94
- // Print script in wp_footer
95
- add_action('wp_footer', array($this, 'print_script'));
96
-
97
- if (is_admin()) {
98
- // Add link to documentation on plugin page
99
- add_filter("plugin_action_links_$basename", array($this, 'add_documentation_link'));
100
-
101
- // Add buttons to MCE editor
102
- if (!defined('AS_TINYMCE') || AS_TINYMCE != false) {
103
- $Accordion_Shortcode_Tinymce_Extensions = new Accordion_Shortcode_Tinymce_Extensions;
104
- }
105
- }
106
  }
107
-
108
-
109
-
110
- /**
111
- * Get the compatibility mode prefix
112
- *
113
- * return string The compatibility mode prefix
114
- */
115
- private function get_compatibility_prefix() {
116
- return defined('AS_COMPATIBILITY') && AS_COMPATIBILITY ? 'as-' : '';
117
- }
118
-
119
-
120
-
121
- /**
122
- * Registers the JavaScript file
123
- * If SCRIPT_DEBUG is set to true in the config file, the un-minified
124
- * version of the JavaScript file will be used.
125
- */
126
- public function register_script() {
127
- $min = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
128
- wp_register_script('accordion-shortcodes-script', plugins_url('accordion' . $min . '.js', __FILE__), array('jquery'), $this->plugin_version, true);
129
- }
130
-
131
-
132
-
133
- /**
134
- * Prints the accordion JavaScript in the footer
135
- * This inlcludes both the accordion jQuery plugin file registered by
136
- * 'register_script()' and the accordion settings JavaScript variable.
137
- */
138
- public function print_script() {
139
- // Check to see if shortcodes are used on page
140
- if (!$this->load_script) return;
141
-
142
- wp_enqueue_script('accordion-shortcodes-script');
143
-
144
- // Output accordions settings JavaScript variable
145
- wp_localize_script('accordion-shortcodes-script', 'accordionShortcodesSettings', $this->script_data);
146
- }
147
-
148
-
149
-
150
- /**
151
- * Checks if a value is boolean
152
- *
153
- * @param string $value The value to test
154
- * return bool
155
- */
156
- private function is_boolean($value) {
157
  return filter_var($value, FILTER_VALIDATE_BOOLEAN);
 
158
  }
159
-
160
-
161
-
162
- /**
163
- * Check for valid HTML tag
164
- * Checks the supplied HTML tag against a list of approved tags.
165
- *
166
- * @param string $tag The HTML tag to test
167
- * return string A valid HTML tag
168
- */
169
- private function check_html_tag($tag) {
170
- $tag = preg_replace('/\s/', '', $tag);
171
- $tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'div');
172
-
173
- if (in_array($tag, $tags)) return $tag;
174
- else return $this->title_tag;
175
  }
176
-
177
-
178
-
179
- /**
180
- * Check for valid scroll value
181
- * Scroll value must be either an int or bool
182
- *
183
- * @param int/bool $scroll The scroll offset integer or true/false
184
- * return int/bool The scroll offset integer else true/false
185
- */
186
- private function check_scroll_value($scroll) {
187
- $int = intval($scroll);
188
-
189
- if (is_int($int) && $int != 0) {
190
- return $int;
191
- }
192
- else {
193
- return $this->is_boolean($scroll);
194
- }
195
- }
196
-
197
-
198
-
199
- /**
200
- * Get's the ID for an accordion item
201
- *
202
- * @param string $id If the user set an ID
203
- * return array The IDs for the accordion title and item
204
- */
205
- private function get_accordion_id($id) {
206
- $title_id = $id ? $id : "accordion-$this->group_count-t$this->item_count";
207
- $content_id = $id ? "content-$id" : "accordion-$this->group_count-c$this->item_count";
208
-
209
- return array(
210
- 'title' => $title_id,
211
- 'content' => $content_id
212
- );
213
  }
214
-
215
-
216
-
217
- /**
218
- * Accordion group shortcode
219
- */
220
- public function accordion_shortcode($atts, $content = null) {
221
- // The shortcode is used on the page, so load the JavaScript
222
- $this->load_script = true;
223
-
224
- // Set accordion counters
225
- $this->group_count++;
226
- $this->item_count = 0;
227
-
228
  extract(shortcode_atts(array(
229
- 'tag' => '',
230
  'autoclose' => true,
231
  'openfirst' => false,
232
- 'openall' => false,
233
- 'clicktoclose' => false,
234
- 'scroll' => false,
235
- 'semantics' => '',
236
- 'class' => ''
237
- ), $atts, 'accordion'));
238
-
239
- // Set global HTML tag names
240
- // Set title HTML tag
241
- if ($tag) $this->title_tag = $this->check_html_tag($tag);
242
- else $this->title_tag = 'h3';
243
-
244
- // Set wrapper HTML tags
245
- if ($semantics == 'dl') {
246
- $this->wrapper_tag = 'dl';
247
- $this->title_tag = 'dt';
248
- $this->content_tag = 'dd';
249
- }
250
- else {
251
- $this->wrapper_tag = 'div';
252
- $this->content_tag = 'div';
253
- }
254
-
255
- // Set settings object (for use in JavaScript)
256
  $script_data = array(
257
- 'id' => "accordion-$this->group_count",
258
- 'autoClose' => $this->is_boolean($autoclose),
259
- 'openFirst' => $this->is_boolean($openfirst),
260
- 'openAll' => $this->is_boolean($openall),
261
- 'clickToClose' => $this->is_boolean($clicktoclose),
262
- 'scroll' => $this->check_scroll_value($scroll)
263
- );
264
-
265
- // Add this shortcodes settings instance to the global script data array
266
- $this->script_data[] = $script_data;
267
-
268
- return sprintf('<%2$s id="%3$s" class="accordion no-js%4$s" role="tablist" aria-multiselectable="true">%1$s</%2$s>',
269
- do_shortcode($content),
270
- $this->wrapper_tag,
271
- "accordion-$this->group_count",
272
- $class ? " $class" : ''
273
  );
 
 
 
 
274
  }
275
-
276
-
277
-
278
- /**
279
- * Accordion item shortcode
280
- */
281
- public function accordion_item_shortcode($atts, $content = null) {
282
  extract(shortcode_atts(array(
283
  'title' => '',
284
- 'id' => '',
285
- 'tag' => '',
286
- 'class' => '',
287
- 'state' => ''
288
- ), $atts, 'accordion-item'));
289
-
290
- // Increment accordion item count
291
- $this->item_count++;
292
-
293
- $ids = $this->get_accordion_id($id);
294
-
295
- $accordion_title = sprintf('<%1$s id="%3$s" class="accordion-title%5$s" role="tab" aria-controls="%4$s" aria-selected="false" aria-expanded="false" tabindex="0" %6$s>%2$s</%1$s>',
296
- $tag ? $this->check_html_tag($tag) : $this->title_tag,
297
- $title ? $title : '<span style="color:red;">' . __('Please enter a title attribute', 'accordion_shortcodes') . '</span>',
298
- $ids['title'],
299
- $ids['content'],
300
- $class ? " $class" : '',
301
- $state ? ' data-initialstate="' . $state . '"' : ''
302
- );
303
-
304
- $accordion_content = sprintf('<%1$s id="%3$s" class="accordion-content" role="tabpanel" aria-labelledby="%4$s" aria-hidden="true">%2$s</%1$s>',
305
- $this->content_tag,
306
  do_shortcode($content),
307
- $ids['content'],
308
- $ids['title']
309
  );
310
-
311
- return $accordion_title . $accordion_content;
312
  }
313
-
314
-
315
-
316
- /**
317
- * Add documentation link on plugin page
318
- */
319
- public function add_documentation_link($links) {
320
- array_push($links, sprintf('<a href="%s">%s</a>',
321
- 'http://wordpress.org/plugins/accordion-shortcodes/',
322
- _x('Documentation', 'link to documentation on wordpress.org site', 'accordion_shortcodes')
323
- ));
324
-
325
  return $links;
 
326
  }
327
 
328
  }
@@ -330,3 +116,5 @@ class Accordion_Shortcodes {
330
  $Accordion_Shortcodes = new Accordion_Shortcodes;
331
 
332
  endif;
 
 
1
  <?php
2
  /**
3
  * Plugin Name: Accordion Shortcodes
4
+ * Description: Adds a few shortcodes to allow for accordion dropdowns.
5
+ * Version: 1.1.1
6
  * Author: Phil Buchanan
7
  * Author URI: http://philbuchanan.com
8
  */
9
 
10
+ # Make sure to not redeclare the class
 
 
11
  if (!class_exists('Accordion_Shortcodes')) :
12
 
13
  class Accordion_Shortcodes {
14
 
15
+ static $add_script;
16
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  function __construct() {
18
+
19
  $basename = plugin_basename(__FILE__);
20
+
21
+ # Load text domain
22
  load_plugin_textdomain('accordion_shortcodes', false, dirname($basename) . '/languages/');
23
+
24
+ # Register JavaScript
25
+ add_action('wp_enqueue_scripts', array(__CLASS__, 'register_script'));
26
+
27
+ # Add shortcodes
28
+ add_shortcode('accordion', array(__CLASS__, 'accordion_shortcode'));
29
+ add_shortcode('accordion-item', array(__CLASS__, 'accordion_item_shortcode'));
30
+
31
+ # Print script in wp_footer
32
+ add_action('wp_footer', array(__CLASS__, 'print_script'));
33
+
34
+ # Add link to documentation
35
+ add_filter("plugin_action_links_$basename", array(__CLASS__, 'add_documentation_link'));
36
+
 
 
 
 
 
 
 
 
37
  }
38
+
39
+ # Checks for boolean value
40
+ static function parse_boolean($value) {
41
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  return filter_var($value, FILTER_VALIDATE_BOOLEAN);
43
+
44
  }
45
+
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.1.1', true);
50
+
 
 
 
 
 
 
 
 
 
 
51
  }
52
+
53
+ # Prints the minified accordion JavaScript file in the footer
54
+ static function print_script() {
55
+
56
+ # Check to see if shortcodes are used on page
57
+ if (!self::$add_script) return;
58
+
59
+ wp_enqueue_script('accordion-shortcodes-script');
60
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
+
63
+ # Accordion wrapper shortcode
64
+ static function accordion_shortcode($atts, $content = null) {
65
+
66
+ # The shortcode is used on the page, so we'll need to load the JavaScript
67
+ self::$add_script = true;
68
+
 
 
 
 
 
 
 
69
  extract(shortcode_atts(array(
 
70
  'autoclose' => true,
71
  'openfirst' => false,
72
+ 'clicktoclose' => false
73
+ ), $atts));
74
+
75
+ # Set settings object (for use in JavaScript)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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);
82
+
83
+ return '<div class="accordion">' . do_shortcode($content) . '</div>';
84
+
85
  }
86
+
87
+ # Accordion item shortcode
88
+ static function accordion_item_shortcode($atts, $content = null) {
89
+
 
 
 
90
  extract(shortcode_atts(array(
91
  'title' => '',
92
+ 'tag' => 'h3'
93
+ ), $atts));
94
+
95
+ return sprintf('<%3$s class="accordion-title">%1$s</%3$s><div class="accordion-content">%2$s</div>',
96
+ $title ? $title : '<span style="color:red;">' . __('Please enter a title attribute: [accordion-item title="Item title"]', 'accordion_shortcodes') . '</span>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  do_shortcode($content),
98
+ $tag
 
99
  );
100
+
 
101
  }
102
+
103
+ # Add documentation link on plugin page
104
+ static function add_documentation_link($links) {
105
+
106
+ $settings_link = '<a href="http://wordpress.org/plugins/accordion-shortcodes/">' . __('Documentation', 'accordion_shortcodes') . '</a>';
107
+
108
+ array_push($links, $settings_link);
109
+
 
 
 
 
110
  return $links;
111
+
112
  }
113
 
114
  }
116
  $Accordion_Shortcodes = new Accordion_Shortcodes;
117
 
118
  endif;
119
+
120
+ ?>
accordion.js CHANGED
@@ -1,201 +1,54 @@
1
  (function($) {
2
  'use strict';
3
-
4
- var i, settings;
5
-
6
-
7
-
8
- /**
9
- * Accordion Shortcodes plugin function
10
- *
11
- * @param object options Plugin settings to override the defaults
12
- */
13
- $.fn.accordionShortcodes = function(options) {
14
-
15
- var allTitles = this.children('.accordion-title'),
16
- allPanels = this.children('.accordion-content').hide(),
17
- firstTitle = allTitles.first(),
18
- firstPanel = allPanels.first(),
19
- selectedId = $(window.location.hash),
20
- duration = 250,
21
- settings = $.extend({
22
- // Set default settings
23
- autoClose: true,
24
- openFirst: false,
25
- openAll: false,
26
- clickToClose: false,
27
- scroll: false
28
- }, options);
29
-
30
-
31
-
32
- /**
33
- * Initial setup
34
- * Remove the 'no-js' class since JavaScript is enabled and set the
35
- * scroll offset.
36
- */
37
- $('.accordion').removeClass('no-js');
38
-
39
- settings.scrollOffset = Math.floor(parseInt(settings.scroll)) | 0;
40
-
41
-
42
-
43
- /**
44
- * Defualt click function
45
- * Called when an accordion title is clicked.
46
- */
47
- function clickHandler() {
48
- // Only open the item if item isn't already open
49
- if (!$(this).hasClass('open')) {
50
- // Close all accordion items
51
- if (settings.autoClose) {
52
- allTitles.each(function() {
53
- closeItem($(this));
54
- });
55
- }
56
-
57
- // Open clicked item
58
- openItem($(this), true);
59
  }
60
- // If item is open, and click to close is set, close it
61
- else if (settings.clickToClose) {
62
- closeItem($(this));
63
- }
64
-
65
- return false;
66
- }
67
-
68
-
69
-
70
- /**
71
- * Opens an accordion item
72
- * Also handles accessibility attribute settings.
73
- *
74
- * @param object ele The accordion item title to open
75
- * @param bool scroll Whether to scroll the page
76
- */
77
- function openItem(ele, scroll) {
78
- // Clear/stop any previous animations before revealing content
79
- ele.next().clearQueue().stop().slideDown(duration, function() {
80
- // Scroll page to the title
81
- if (scroll && settings.scroll) {
82
- $('html, body').animate({
83
- scrollTop: $(this).prev().offset().top - settings.scrollOffset
84
- }, duration);
85
- }
86
- });
87
-
88
- // Mark accordion item as open and read and set aria attributes
89
- ele.addClass('open read')
90
- .attr({
91
- 'aria-selected': 'true',
92
- 'aria-expanded': 'true'
93
- })
94
- .next().attr({
95
- 'aria-hidden': 'false'
96
- });
97
  }
98
-
99
-
100
-
101
- /**
102
- * Closes an accordion item
103
- * Also handles accessibility attribute settings.
104
- *
105
- * @param object ele The accordion item title to open
106
- */
107
- function closeItem(ele) {
108
- ele.next().slideUp(duration);
109
- ele.removeClass('open');
110
-
111
- // Set accessibility attributes
112
- ele.attr({
113
- 'aria-selected': 'false',
114
- 'aria-expanded': 'false'
115
- })
116
- .next().attr({
117
- 'aria-hidden': 'true'
118
- });
119
- }
120
-
121
-
122
-
123
- /**
124
- * Should any accordions be opened or closed on load?
125
- * Open first, open all, open based on URL hash or open/closed based on
126
- * initial state setting.
127
- */
128
- if (selectedId.length && selectedId.hasClass('accordion-title')) {
129
- openItem(selectedId, true);
130
- }
131
- else if (settings.openAll) {
132
- allTitles.each(function() {
133
- openItem($(this), false);
134
- });
135
- }
136
- else if (settings.openFirst) {
137
- openItem(firstTitle, false);
138
- }
139
-
140
- // Open or close items if initial state set to open or close
141
- $('[data-initialstate!=""]').each(function() {
142
- switch ($(this).data('initialstate')) {
143
- case 'open':
144
- openItem($(this), false);
145
- break;
146
- case 'closed':
147
- // Only close it if the hash isn't for this item
148
- if ($(this).attr('id') !== selectedId.attr('id')) {
149
- closeItem($(this));
150
- }
151
- break;
152
- }
153
- });
154
-
155
-
156
-
157
- /**
158
- * Add event listeners
159
- */
160
- allTitles.click(clickHandler);
161
-
162
- allTitles.keydown(function(e) {
163
- var code = e.which;
164
-
165
- // 13 = Return, 32 = Space
166
- if ((code === 13) || (code === 32)) {
167
- // Simulate click on title
168
- $(this).click();
169
- }
170
- });
171
-
172
- // Listen for hash changes (in page jump links for accordions)
173
- $(window).on('hashchange', function() {
174
- selectedId = $(window.location.hash);
175
-
176
- if (selectedId.length && selectedId.hasClass('accordion-title')) {
177
- if (settings.autoClose) {
178
- allTitles.each(function() {
179
- closeItem($(this));
180
- });
181
- }
182
-
183
- openItem(selectedId, true);
184
- }
185
- });
186
-
187
- return this;
188
- };
189
-
190
-
191
-
192
- // Loop through accordion settings objects
193
- // Wait for the entire page to load before loading the accordion
194
- $(window).on('load', function() {
195
- for (var i = 0; i < accordionShortcodesSettings.length; i += 1) {
196
- settings = accordionShortcodesSettings[i];
197
-
198
- $('#' + settings.id).accordionShortcodes(settings);
199
  }
 
 
200
  });
201
- }(jQuery));
 
1
  (function($) {
2
  'use strict';
3
+
4
+ var allTitles = $('.accordion-title'),
5
+ allPanels = $('.accordion-content').hide(),
6
+ firstPanel = $('.accordion-content:first-of-type'),
7
+ duration = 250,
8
+ settings = {
9
+ // Set defaults
10
+ autoClose: true,
11
+ openFirst: false,
12
+ clickToClose: false
13
+ };
14
+
15
+ // Check for accordion settings variable passed from WordPress
16
+ if (typeof accordionSettings !== 'undefined') {
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
+ }
25
+
26
+ // Add event listener
27
+ allTitles.click(function() {
28
+
29
+ // Only open the item if item isn't already open
30
+ if (!$(this).hasClass('open')) {
31
+
32
+ // Close all accordion items
33
+ if (settings.autoClose) {
34
+ allPanels.slideUp(duration);
35
+ allTitles.removeClass('open');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
+
38
+ // Open clicked item
39
+ $(this).next().slideDown(duration);
40
+ $(this).addClass('open');
41
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
+ // If item is open, close it
44
+ else if (settings.clickToClose) {
45
+
46
+ $(this).next().slideUp(duration);
47
+ $(this).removeClass('open');
48
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
+ return false;
51
+
52
  });
53
+
54
+ }(jQuery));
accordion.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){"use strict";var o;t.fn.accordionShortcodes=function(o){function e(){return t(this).hasClass("open")?h.clickToClose&&n(t(this)):(h.autoClose&&a.each(function(){n(t(this))}),i(t(this),!0)),!1}function i(o,e){o.next().clearQueue().stop().slideDown(l,function(){e&&h.scroll&&t("html, body").animate({scrollTop:t(this).prev().offset().top-h.scrollOffset},l)}),o.addClass("open read").attr({"aria-selected":"true","aria-expanded":"true"}).next().attr({"aria-hidden":"false"})}function n(t){t.next().slideUp(l),t.removeClass("open"),t.attr({"aria-selected":"false","aria-expanded":"false"}).next().attr({"aria-hidden":"true"})}var a=this.children(".accordion-title"),s=this.children(".accordion-content").hide(),c=a.first(),r=(s.first(),t(window.location.hash)),l=250,h=t.extend({autoClose:!0,openFirst:!1,openAll:!1,clickToClose:!1,scroll:!1},o);return t(".accordion").removeClass("no-js"),h.scrollOffset=0|Math.floor(parseInt(h.scroll)),r.length&&r.hasClass("accordion-title")?i(r,!0):h.openAll?a.each(function(){i(t(this),!1)}):h.openFirst&&i(c,!1),t('[data-initialstate!=""]').each(function(){switch(t(this).data("initialstate")){case"open":i(t(this),!1);break;case"closed":t(this).attr("id")!==r.attr("id")&&n(t(this))}}),a.click(e),a.keydown(function(o){var e=o.which;(13===e||32===e)&&t(this).click()}),t(window).on("hashchange",function(){r=t(window.location.hash),r.length&&r.hasClass("accordion-title")&&(h.autoClose&&a.each(function(){n(t(this))}),i(r,!0))}),this},t(window).on("load",function(){for(var e=0;e<accordionShortcodesSettings.length;e+=1)o=accordionShortcodesSettings[e],t("#"+o.id).accordionShortcodes(o)})}(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,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)
assets/icon-128x128.png DELETED
Binary file
assets/icon-256x256.png DELETED
Binary file
assets/screenshot-1.jpg ADDED
Binary file
assets/screenshot-1.png DELETED
Binary file
assets/screenshot-2.jpg ADDED
Binary file
assets/screenshot-2.png DELETED
Binary file
assets/screenshot-3.png DELETED
Binary file
languages/default.po CHANGED
@@ -1,25 +1,24 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Accordion Shortcodes\n"
4
- "POT-Creation-Date: 2015-05-09 09:37-0500\n"
5
- "PO-Revision-Date: 2015-05-09 09:37-0500\n"
6
  "Last-Translator: Phil Buchanan <info@philbuchanan.com>\n"
7
  "Language-Team: \n"
8
- "Language: en_CA\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.7.6\n"
13
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
14
  "X-Poedit-Basepath: .\n"
15
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
 
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
- #: ../accordion-shortcodes.php:294
19
- msgid "Please enter a title attribute"
20
  msgstr ""
21
 
22
- #: ../accordion-shortcodes.php:318
23
- msgctxt "link to documentation on wordpress.org site"
24
  msgid "Documentation"
25
  msgstr ""
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Accordion Shortcodes\n"
4
+ "POT-Creation-Date: 2014-01-22 09:48-0500\n"
5
+ "PO-Revision-Date: 2014-01-22 09:51-0500\n"
6
  "Last-Translator: Phil Buchanan <info@philbuchanan.com>\n"
7
  "Language-Team: \n"
 
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.3\n"
12
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
13
  "X-Poedit-Basepath: .\n"
14
  "Plural-Forms: nplurals=2; plural=n != 1;\n"
15
+ "Language: en_CA\n"
16
  "X-Poedit-SearchPath-0: ..\n"
17
 
18
+ #: ../accordion-shortcodes.php:96
19
+ msgid "Please enter a title attribute: [accordion-item title=\"Item title\"]"
20
  msgstr ""
21
 
22
+ #: ../accordion-shortcodes.php:106
 
23
  msgid "Documentation"
24
  msgstr ""
readme.txt CHANGED
@@ -2,57 +2,45 @@
2
  Contributors: philbuchanan
3
  Author URI: http://philbuchanan.com/
4
  Donate Link: http://philbuchanan.com/
5
- Tags: accordion, accordions, shortcodes, responsive accordions, accordions plugin, jquery accordions, accordions short-code, accordions plugin wordpress, accordions plugin jquery
6
  Requires at least: 3.3
7
- Tested up to: 4.8
8
- Stable tag: 2.3.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Shortcodes for creating responsive accordion drop-downs.
13
 
14
  == Description ==
 
15
 
16
- Accordion Shortcodes is a simple plugin that adds a few shortcodes for adding accordion drop-downs to your pages.
17
-
18
- The accordions should blend seamlessly with your theme. However, you may want to edit your theme's main stylesheet in order to add some custom styling (see below for sample CSS).
19
 
20
  = Features =
21
 
22
- * Adds two shortcodes for adding accordions to your site
23
- * Supports multiple accordions with individual settings on a single page
24
- * Two buttons in the TinyMCE editor make it easy to add and configure the accordion shortcodes
25
- * Responsive
26
  * No default CSS added
27
  * Only adds JavaScript on pages that use the shortcodes
28
- * Support for item IDs and direct links
29
- * Accessible (for users requiring tabbed keyboard navigation control)
30
-
31
- = Optional Features =
32
-
33
- * Open the first accordion item by default
34
- * Open all accordion items by default
35
- * Disable auto closing of accordion items
36
- * Manually close items by clicking the title again
37
- * Scroll page to title when it's clicked open
38
- * Set the HTML tag for the title element
39
- * Change the semantic structure of your accordions (advanced)
40
 
41
  = The Shortcodes =
42
 
43
  The two shortcodes that are added are:
44
 
45
- `[accordion]...[/accordion]`
46
 
47
  and
48
 
49
- `[accordion-item title=""]...[/accordion-item]`
50
 
51
  = Basic Usage Example =
52
 
53
  [accordion]
54
- [accordion-item title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
55
- [accordion-item title="Second accordion item"]Drop-down content goes here.[/accordion-item]
56
  [/accordion]
57
 
58
  This will output the following HTML:
@@ -60,87 +48,39 @@ This will output the following HTML:
60
  <div class="accordion">
61
  <h3 class="accordion-title">Title of accordion item</h3>
62
  <div class="accordion-content">
63
- Drop-down content goes here.
64
  </div>
65
  <h3 class="accordion-title">Second accordion item</h3>
66
  <div class="accordion-content">
67
- Drop-down content goes here.
68
  </div>
69
  </div>
70
 
 
 
 
 
71
  == Installation ==
72
  1. Upload the 'accordion-shortcodes' folder to the '/wp-content/plugins/' directory.
73
  2. Activate the plugin through the Plugins menu in WordPress.
74
  3. Add the shortcodes to your content.
 
75
 
76
  == Frequently Asked Questions ==
77
 
78
  = Why isn't the JavaScript file loading on my site? =
79
 
80
- This is most likely caused by a poorly coded theme. This 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 theme's footer.php file.
81
 
82
  = How can I change the look of the accordion? =
 
83
 
84
- No CSS is added by default to the accordion. The accordion should look fine with every theme.
85
-
86
- That said, you can change the looking of the accordion as long as you are comfortable with editing your theme's stylesheet. If you are familiar with that process, you can add some CSS to make the accordion look the way you want.
87
-
88
- = How can I make all accordion content disply when printing the page? =
89
-
90
- Add this CSS to your theme's CSS stylesheet:
91
-
92
- `@media print {
93
- .accordion-content {
94
- display: block !important;
95
- }
96
- }`
97
-
98
- = Can I use other shortcodes inside each accordion item? =
99
-
100
- Absolutely! You can use any of the WordPress format settings and headings as well.
101
-
102
- You cannot, however nest an accordion within another accordion. This is a limitation of how WordPress processes shortcodes.
103
-
104
- = How do I accommodate fixed position headers if I'm using `scroll`? =
105
-
106
- The scroll setting accepts numeric values as well. So, instead of setting `[accordion scroll="true"]`, you can define a pixel offset for the final scroll position like this: `[accordion scroll="50"]`. Set the numeric value to the pixel height of your fixed header.
107
-
108
- = Is it possible to open/close all accordions with a single button click? =
109
 
110
- Yes! Although you will need to know some simple code to get it working.
111
-
112
- In your theme, you'll need to have a Javascript file with the following code:
113
-
114
- `$('.js-open-everything').click(function() {
115
- $.each($('.accordion-title'), function(index, value) {
116
- if (!$(this).hasClass('open')) {
117
- $(this).trigger('click');
118
- }
119
- });
120
- });`
121
-
122
- Then, you can add a button to your page:
123
-
124
- `<button class="js-open-everything">Open Everything</button>`
125
-
126
- = I have a lot of extra space showing around my accordions (and other shortcodes). How can I remove it? =
127
-
128
- WordPress automatically adds paragraphs and line breaks to content formatted in the editor, so if your shortcodes aren't formatted just right, you'll see a lot of extra spacing. Putting this function in your theme's functions.php file should fix it:
129
 
130
- `/**
131
- * Fixes empty <p> and <br> tags showing before and after shortcodes in the
132
- * output content.
133
- */
134
- function pb_the_content_shortcode_fix($content) {
135
- $array = array(
136
- '<p>[' => '[',
137
- ']</p>' => ']',
138
- ']<br />' => ']',
139
- ']<br>' => ']'
140
- );
141
- return strtr($content, $array);
142
- }
143
- add_filter('the_content', 'pb_the_content_shortcode_fix');`
144
 
145
  == Other Notes ==
146
 
@@ -150,8 +90,8 @@ Here is some sample CSS to get you started if you want to customize the look and
150
 
151
  /* Accordion Styles */
152
  .accordion {
153
- border-bottom: 1px solid #dbdbdb;
154
- margin-bottom: 20px;
155
  }
156
  .accordion-title {
157
  border-top: 1px solid #dbdbdb;
@@ -164,182 +104,75 @@ Here is some sample CSS to get you started if you want to customize the look and
164
  .accordion-title.open {cursor: default;}
165
  .accordion-content {padding-bottom: 20px;}
166
 
167
- = Opening an Accordion Via ID =
168
-
169
- You can optionally add a unique ID to each of your accordion items and then use that ID in the URL to open that item by default. For example, say you have the following accordions:
170
-
171
- [accordion]
172
- [accordion-item id="item-1" title="Title of accordion item"]Drop-down content goes here.[/accordion-item]
173
- [accordion-item id="item-2" title="Second accordion item"]Drop-down content goes here.[/accordion-item]
174
- [accordion-item id="item-3" title="A Third accordion"]Drop-down content goes here.[/accordion-item]
175
- [/accordion]
176
-
177
- You could use this URL to open the third item by default:
178
-
179
- http://yourdomain.com/your/path/#item-3
180
-
181
- All you need to do is ensure that the part after the `#` in the URL matches the ID set on the accordion item.
182
-
183
- = Advanced Accordion Settings =
184
 
185
  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:
186
 
187
- [accordion autoclose="true" openfirst="false" openall="false" clicktoclose="false"]
188
-
189
- **autoclose**: Sets whether accordion items close automatically when you open the next item. Set `autoclose="true/false"` on the opening accordion shortcode like this: `[accordion autoclose="false"]`. Default is `true`.
190
-
191
- **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 shortcode like this: `[accordion openfirst="true"]`. Default is `false`.
192
-
193
- **openall**: Sets whether all accordion items are open by default. It is recommended that this setting be used with **clicktoclose**. Set `openall="true/false"` on the opening accordion shortcode like this: `[accordion openall="true"]`. Default is `false`.
194
-
195
- **clicktoclose**: Sets whether clicking an open title closes it. Set `clicktoclose="true/false"` on the opening accordion shortcode like this: `[accordion clicktoclose="true"]`. Default is `false`.
196
-
197
- **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 shortcode like this: `[accordion scroll="true"]`. Default is `false`. You may also specify an integer for a pixel offset if you'd like the page to scroll further (useful when the site uses a fixed position header navigation). NOTE: Only use pixel offset integers of > 0. If you do not want a scroll offset, but still want scrolling, simply use `scroll="true"`.
198
-
199
- **class**: Sets a custom CSS class for the accordion group or individual accordion items. Set `class="your-class-name"` on the opening accordion or accordion-item shortcode like this: `[accordion class="your-class-name"]` or `[accordion-item class="your-class-name"]`. Added a class to the accordion-item will add the class to the title HTML tag.
200
-
201
- **tag**: Set the global HTML tag to use for all accordion titles. Set `tag="h2"` on the opening accordion shortcode like this: `[accordion tag="h2"]`. Default is `h3`.
202
-
203
- **semantics**: You can change the entire semantic structure of the accordions to use a definition list (dl, dt, dd) by setting `semantics="dl"` on the opening accordion shortcode like this: `[accordion semantics="dl"]`. By default the accordion will use `div` tags for the wrapper and content containers. If you set this option to `dl`, it is recommended that you do not also use the `tag` option. This feature is not selectable from the accordion button dialog box and must be added manually.
204
-
205
- = Advanced Accordion Item Settings =
206
-
207
- **state**: Sets the initial state of the accordion item to `open` or `closed`. Set `state=open` or `state=closed` on the opening accordion item shortcode like this: `[accordion-item state=open]`. This setting will override all other accordion settings except when linking to an accordion item via ID.
208
-
209
- **tag**: You can also set the HTML tag for the titles of each accordion item individually by adding `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]`. Using a tag attribute on an individual accordion item will override the global setting. The list of valid tags is: h1, h2, h3, h4, h5, h6, p, div.
210
-
211
- = Filtering Shortcodes =
212
-
213
- You can filter the settings and content of the shortcodes by adding some simply code to the functions.php file of your theme.
214
 
215
- For example, you could set the `openfirst` option for all accordions across the entire site using:
216
 
217
- add_filter('shortcode_atts_accordion', 'set_accordion_shortcode_defaults', 10, 3);
218
- function set_accordion_shortcode_defaults($atts) {
219
- // Override the openfirst setting here
220
- $atts['openfirst'] = true;
221
- return $atts;
222
- }
223
-
224
- = Compatibility Mode =
225
-
226
- If you have a theme that already includes the shortcodes `[accordion]` or `[accordion-item]` you can enable compatibility mode.
227
-
228
- To enable compatibility mode add `define('AS_COMPATIBILITY', true);` to your wp-config.php file. This will add a prefix of 'as-' to the two accordion shortcodes.
229
 
230
- With compatibility mode enabled, make sure your shortcodes start with `as-` like this: `[as-accordion]...[/as-accordion]` and `[as-accordion-item]...[/as-accordion-item]`.
231
 
232
- = Disable TinyMCE Buttons =
233
-
234
- You can optionally disable the TinyMCE extension which will remove the buttons from the editor button bar. To disable the TinyMCE extension add `define('AS_TINYMCE', false);` to your wp-config.php file.
235
 
236
  = Issues/Suggestions =
237
 
238
  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/).
239
 
240
- == Screenshots ==
241
-
242
- 1. The Accordion Group and Accordion Item shortcode buttons in the editor
243
- 2. The Accordion Group shortcode insertion dialog box
244
- 3. The Accordion Item shortcode insertion dialog box
245
-
246
  == Changelog ==
247
- = 2.3.3 =
248
- * Now compatible up to WordPress 4.8
249
- * FIXED: aria-mutliselectable is now on the accordion group instead of each accordion item title
250
-
251
- = 2.3.2 =
252
- * Now compatible up to WordPress 4.7
253
- * FIXED: Accordion titles now truly accessible via keyboard control
254
-
255
- = 2.3.1 =
256
- * Now compatible up to WordPress 4.6
257
- * FIXED: A bug with a deprecated function in jQuery
258
-
259
- = 2.3.0 =
260
- * NEW: Added setting to set initial state (open or closed) of individual accordion items on page load
261
- * NEW: Added wp-config option to disable the TinyMCE extension
262
- * Now compatible up to WordPress 4.5
263
-
264
- = 2.2.6 =
265
- * FIXED: Scroll offset was ignored when an accordion was linked to from another page
266
-
267
- = 2.2.5 =
268
- * Now compatible up to WordPress 4.4
269
-
270
- = 2.2.4 =
271
- * Now compatible up to WordPress 4.3
272
-
273
- = 2.2.3 =
274
- FIXED: A bug where the content editor would break in custom post types
275
-
276
- = 2.2.1 =
277
- FIXED: A bug where setting both scroll and openfirst would scroll the window without user interaction
278
-
279
- = 2.2 =
280
- * NEW: Accessible for users requiring tabbed keyboard navigation control (this took way too long)
281
- * NEW: A classname of 'read' is now added to accordion item titles as they are opened. This allows you to style all read accordion items
282
- * NEW: Compatibility mode adds a prefix to the shortcodes for themes that already include accordion shortcodes with matching names
283
- * FIXED: Animation queue not clearing
284
- * Now compatible up to WordPress 4.2
285
-
286
- = 2.1.1 =
287
- * FIXED: An issue where openfirst would not work if title tag was set to div
288
- * FIXED: An issue where title tag setting was not respected when using multiple accordions on one page
289
-
290
- = 2.1 =
291
- * NEW: Use multiple accordions on a single page! Each shortcode will now respect its own individual settings.
292
- * Now compatible up to WordPress 4.1
293
-
294
- = 2.0.1 =
295
- * NEW: Add a custom CSS classname to your accordion item group or accordion item shortcode
296
- * NEW: Set an integer for scroll property to offset the scrolling by that many pixels
297
- * Now compatible up to WordPress 4.0
298
-
299
- = 2.0 =
300
- * NEW: Buttons in the editor to easily add shortcodes with various settings
301
- * NEW: Support for item IDs on accordion items and direct linking to a specific item
302
- * NEW: Change the entire semantic structure of your accordions by using definition lists
303
- * ENHANCED: Class added if JavaScript is disabled (so you can style your accordions differently if necessary)
304
- * ENHANCED: Each accordion now has its own unique ID (accordion-1, accordion-2...) so you can target each one on a page
305
- * FIXED: A few incredibly small bugs/annoyances
306
 
307
  == Upgrade Notice ==
308
- = 2.3.2 =
309
- You may notice a focus state around your accordion items when clicking them. This is necessary to support accessibility within the plugin. If you really must remove the focus state (though not recommended) you can do so by adding this CSS to your theme's stylesheet: `.accordion-title {outline: none;}`.
310
-
311
- = 2.3.1 =
312
- Fixed a minor bug that could cause warnings in the developer console. Also now compatible up to WordPress 4.6.
313
-
314
- = 2.3.0 =
315
- Added setting to set initial state (open or closed) of individual accordion items on page load. Also now compatible up to WordPress 4.5.
316
-
317
- = 2.2.6 =
318
- Fixes an issues where the scroll offset was ignored when an accordion was linked to from another page.
319
-
320
- = 2.2.5 =
321
- Now compatible up to WordPress 4.4.
322
-
323
- = 2.2.4 =
324
- Now compatible up to WordPress 4.3.
325
-
326
- = 2.2.3 =
327
- Fixes a bug where the content editor would break in custom post types.
328
 
329
- = 2.2.1 =
330
- Fixes a bug introduced in v2.2 when using the scroll and openfirst setting together.
331
 
332
- = 2.2 =
333
- Drastically improved accessibility. New 'read' class added to opened accordion items. Compatibility mode added for theme's with the same accordion shortcode names. WordPress 4.2 compatibility.
334
 
335
- = 2.1.1 =
336
- Fixes a few minor issues accidentally introduced in the 2.1 update.
337
 
338
- = 2.1 =
339
- This update brings the much request support for multiple accordions on a single page! Each shortcode will now respect its own individual settings.
340
 
341
- = 2.0.1 =
342
- WordPress 4.0 compatibility.
343
 
344
- = 2.0 =
345
- Big changes for version 2.0!
2
  Contributors: philbuchanan
3
  Author URI: http://philbuchanan.com/
4
  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.1.1
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 dropdowns.
13
 
14
  == Description ==
15
+ Adds a few shortcodes to allow for accordion dropdowns.
16
 
17
+ **NOTE:** If you are not comfortable with WordPress shortcodes, this plugin may not be for you.
 
 
18
 
19
  = Features =
20
 
21
+ * Adds two shortcodes for adding an accordion to your site
 
 
 
22
  * No default CSS added
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
 
29
  = The Shortcodes =
30
 
31
  The two shortcodes that are added are:
32
 
33
+ `[accordion]`
34
 
35
  and
36
 
37
+ `[accordion-item title="" tag=""]`
38
 
39
  = Basic Usage Example =
40
 
41
  [accordion]
42
+ [accordion-item title="Title of accordion item"]Dropdown content goes here.[/accordion-item]
43
+ [accordion-item title="Second accordion item"]Dropdown content goes here.[/accordion-item]
44
  [/accordion]
45
 
46
  This will output the following HTML:
48
  <div class="accordion">
49
  <h3 class="accordion-title">Title of accordion item</h3>
50
  <div class="accordion-content">
51
+ Dropdown content goes here.
52
  </div>
53
  <h3 class="accordion-title">Second accordion item</h3>
54
  <div class="accordion-content">
55
+ Dropdown content goes here.
56
  </div>
57
  </div>
58
 
59
+ = Advanced Settings =
60
+
61
+ There are a few [advances settings](http://wordpress.org/plugins/accordion-shortcodes/other_notes/) for the plugin.
62
+
63
  == Installation ==
64
  1. Upload the 'accordion-shortcodes' folder to the '/wp-content/plugins/' directory.
65
  2. Activate the plugin through the Plugins menu in WordPress.
66
  3. Add the shortcodes to your content.
67
+ 4. Add some [CSS](http://wordpress.org/plugins/accordion-shortcodes/other_notes/#Other-Notes) to your themes stylesheet to make the accordion look the way you want.
68
 
69
  == Frequently Asked Questions ==
70
 
71
  = Why isn't the JavaScript file loading on my site? =
72
 
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ == Screenshots ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
+ 1. The shortcodes in the editor
83
+ 2. The accordion on the live site (note that CSS has been added to the themes stylesheet)
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  == Other Notes ==
86
 
90
 
91
  /* Accordion Styles */
92
  .accordion {
93
+ border-bottom: 1px solid #dbdbdb;
94
+ margin-bottom: 20px;
95
  }
96
  .accordion-title {
97
  border-top: 1px solid #dbdbdb;
104
  .accordion-title.open {cursor: default;}
105
  .accordion-content {padding-bottom: 20px;}
106
 
107
+ = Advanced Settings =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  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:
110
 
111
+ [accordion autoclose="true" openfirst="false" clicktoclose="false"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ **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`.
114
 
115
+ **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`.
 
 
 
 
 
 
 
 
 
 
 
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
+ 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]`
 
 
120
 
121
  = Issues/Suggestions =
122
 
123
  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/).
124
 
 
 
 
 
 
 
125
  == Changelog ==
126
+ = 1.1.1=
127
+ * Added link to documentation from plugins page
128
+ * Added FAQs to readme
129
+ * Added screenshots
130
+
131
+ = 1.1 =
132
+ * **WARNING**: This update makes HTML structure changes and will require changes to your CSS
133
+ * New HTML structure, based on class names
134
+ * HTML now validates properly
135
+ * Added localization support for error messages
136
+
137
+ = 1.0.4 =
138
+ * Added option to close an open item by clicking the title
139
+
140
+ = 1.0.3 =
141
+ * Added option to open the first item by default
142
+ * Fixed an issue where clicking an already open item will close and reopen it
143
+ * Added better inline documentation
144
+ * Added minified JavaScript file
145
+
146
+ = 1.0.2 =
147
+ * Added setting to disable auto closing of accordion items
148
+ * Better handling of accordion items with no title attribute set
149
+ * Updated minimum WordPress version requirement (should still work down to 2.8, but not supported)
150
+
151
+ = 1.0.1 =
152
+ * Checks if the class exists before trying to create it
153
+ * Updated readme
154
+
155
+ = 1.0 =
156
+ * Initial release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  == Upgrade Notice ==
159
+ = 1.1.1 =
160
+ Added a link to plugin documentation from the plugins page for easy access.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
+ = 1.1 =
163
+ **WARNING**: This update makes HTML structure changes and will require changes to your CSS.
164
 
165
+ = 1.0.4 =
166
+ Added an option to close an item by clicking the title.
167
 
168
+ = 1.0.3 =
169
+ Added an option to open the first item by default. Fixed a bug that caused open items to close and reopen when clicking them.
170
 
171
+ = 1.0.2 =
172
+ Added an option to disable auto closing of accordion items.
173
 
174
+ = 1.0.1 =
175
+ Minor code updates.
176
 
177
+ = 1.0 =
178
+ Initial release.
tinymce/images/accordion-item.gif DELETED
Binary file
tinymce/images/accordion-item.svg DELETED
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
6
- <g>
7
- <g>
8
- <path fill-rule="evenodd" clip-rule="evenodd" fill="#787878" d="M2,3v3h1v11h14V6h1V3H2z M16,16H4V6h12V16z M17,5H3V4h14V5z"/>
9
- </g>
10
- </g>
11
- <rect x="4" y="6" fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" width="12" height="10"/>
12
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
tinymce/images/accordion.gif DELETED
Binary file
tinymce/images/accordion.svg DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
6
- <g>
7
- <g>
8
- <path fill-rule="evenodd" clip-rule="evenodd" fill="#787878" d="M2,2v5h1v8H2v3h16v-3h-1V7h1V2H2z M17,17H3v-1h14V17z M16,15H4V7
9
- h12V15z M17,6H3V5h14V6z M17,4H3V3h14V4z"/>
10
- </g>
11
- </g>
12
- <rect x="4" y="7" fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" width="12" height="8"/>
13
- </svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
tinymce/tinymce-plugin.js DELETED
@@ -1,154 +0,0 @@
1
- (function() {
2
- 'use strict';
3
-
4
- tinymce.create('tinymce.plugins.accordionShortcodesExtensions', {
5
- init: function(editor, url) {
6
- if (accordionShortcodesPrefix == undefined) {
7
- var accordionShortcodesPrefix = '';
8
- }
9
-
10
- // Accordion group
11
- editor.addButton('AccordionShortcode', {
12
- title: 'Add an accordion group',
13
- image: url + '/images/accordion.gif',
14
- onclick: function() {
15
- editor.windowManager.open({
16
- title: 'Insert Accordion Shortcode',
17
- body: [
18
- {
19
- type: 'checkbox',
20
- name: 'autoclose',
21
- label: 'Auto Close Accordions',
22
- checked: true
23
- },
24
- {
25
- type: 'checkbox',
26
- name: 'openfirst',
27
- label: 'Open First Accordion'
28
- },
29
- {
30
- type: 'checkbox',
31
- name: 'openall',
32
- label: 'Open All Accordions'
33
- },
34
- {
35
- type: 'checkbox',
36
- name: 'clicktoclose',
37
- label: 'Click to Close Accordions'
38
- },
39
- {
40
- type: 'checkbox',
41
- name: 'scroll',
42
- label: 'Scroll to Top of Accordion'
43
- },
44
- {
45
- type: 'listbox',
46
- name: 'tag',
47
- label: 'HTML Tag for Title',
48
- minWidth: 75,
49
- values: [
50
- {text: '---', value: null},
51
- {text: 'h1', value: 'h1'},
52
- {text: 'h2', value: 'h2'},
53
- {text: 'h3', value: 'h3'},
54
- {text: 'h4', value: 'h4'},
55
- {text: 'h5', value: 'h5'},
56
- {text: 'h6', value: 'h6'},
57
- {text: 'p', value: 'p'},
58
- {text: 'div', value: 'div'}
59
- ]
60
- }
61
- ],
62
- onsubmit: function(e) {
63
- var shortcode = '[' + accordionShortcodesPrefix + 'accordion';
64
-
65
- if (e.data.autoclose === false) {
66
- shortcode += ' autoclose=' + e.data.autoclose;
67
- }
68
- if (e.data.openfirst) {
69
- shortcode += ' openfirst=' + e.data.openfirst;
70
- }
71
- if (e.data.openall) {
72
- shortcode += ' openall=' + e.data.openall;
73
- }
74
- if (e.data.clicktoclose) {
75
- shortcode += ' clicktoclose=' + e.data.clicktoclose;
76
- }
77
- if (e.data.scroll) {
78
- shortcode += ' scroll=' + e.data.scroll;
79
- }
80
- if (e.data.tag) {
81
- shortcode += ' tag=' + e.data.tag;
82
- }
83
-
84
- shortcode += ']' + editor.selection.getContent() + '[/' + accordionShortcodesPrefix + 'accordion]';
85
-
86
- editor.insertContent(shortcode);
87
- }
88
- });
89
- }
90
- });
91
-
92
- // Accordion item
93
- editor.addButton('AccordionItemShortcode', {
94
- title: 'Add an accordion item',
95
- image: url + '/images/accordion-item.gif',
96
- onclick: function() {
97
- editor.windowManager.open({
98
- title: 'Insert Accordion Item Shortcode',
99
- body: [
100
- {
101
- type: 'textbox',
102
- name: 'title',
103
- label: 'Accordion Item Title',
104
- minWidth: 300
105
- },
106
- {
107
- type: 'listbox',
108
- name: 'initialstate',
109
- label: 'Initial State (optional)',
110
- minWidth: 75,
111
- values: [
112
- {text: '---', value: null},
113
- {text: 'open', value: 'open'},
114
- {text: 'closed', value: 'closed'},
115
- ]
116
- },
117
- {
118
- type: 'textbox',
119
- name: 'id',
120
- label: 'ID (optional)',
121
- minWidth: 300
122
- },
123
- {
124
- type: 'container',
125
- html: 'Each ID on a single page must be unique and cannot contain spaces.'
126
- }
127
- ],
128
- onsubmit: function(e) {
129
- var shortcode = '[' + accordionShortcodesPrefix + 'accordion-item title="';
130
-
131
- if (e.data.title) {
132
- shortcode += e.data.title;
133
- }
134
- shortcode += '"';
135
-
136
- if (e.data.id) {
137
- shortcode += ' id=' + e.data.id.replace(/\s+/g, '-');
138
- }
139
- if (e.data.initialstate) {
140
- shortcode += ' state=' + e.data.initialstate;
141
- }
142
-
143
- shortcode += ']' + editor.selection.getContent() + '[/' + accordionShortcodesPrefix + 'accordion-item]';
144
-
145
- editor.insertContent(shortcode);
146
- }
147
- })
148
- }
149
- });
150
- }
151
- });
152
-
153
- tinymce.PluginManager.add('accordionShortcodesExtensions', tinymce.plugins.accordionShortcodesExtensions);
154
- }());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tinymce/tinymce.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
- // Make sure to not redeclare the class
4
- if (!class_exists('Accordion_Shortcode_Tinymce_Extensions')) :
5
-
6
- class Accordion_Shortcode_Tinymce_Extensions {
7
-
8
- /**
9
- * Class constructor
10
- * Adds the button hooks when the admin panel initializes.
11
- */
12
- function __construct() {
13
- add_action('admin_init', array($this, 'button_hooks'));
14
- add_action('admin_head', array($this, 'admin_head'));
15
- }
16
-
17
-
18
-
19
- /**
20
- * Load the plugin and register the buttons
21
- */
22
- public function button_hooks() {
23
- if ((current_user_can('edit_posts') || current_user_can('edit_pages')) && get_user_option('rich_editing')) {
24
- add_filter('mce_external_plugins', array($this, 'add_tinymce_plugin'));
25
- add_filter('mce_buttons', array($this, 'register_buttons'));
26
- }
27
- }
28
-
29
-
30
-
31
- /**
32
- * Register the accordion shortcodes buttons plugin
33
- */
34
- public function add_tinymce_plugin($plugin_array) {
35
- $plugin_array['accordionShortcodesExtensions'] = plugins_url('accordion-shortcodes/tinymce/tinymce-plugin.js');
36
-
37
- return $plugin_array;
38
- }
39
-
40
-
41
-
42
- /**
43
- * Register the accordion shortcode buttons
44
- */
45
- public function register_buttons($buttons) {
46
- $newButtons = array(
47
- 'AccordionShortcode',
48
- 'AccordionItemShortcode'
49
- );
50
-
51
- // Place the buttons before the "insert more" button
52
- array_splice($buttons, 12, 0, $newButtons);
53
-
54
- return $buttons;
55
- }
56
-
57
-
58
-
59
- /**
60
- * Localize MCE buttons and labels
61
- */
62
- public function admin_head() {
63
- if (defined('AS_COMPATIBILITY') && AS_COMPATIBILITY) {
64
- $prefix = 'as-';
65
- }
66
- else {
67
- $prefix = '';
68
- } ?>
69
-
70
- <script type="text/javascript">
71
- var accordionShortcodesPrefix = '<?php echo $prefix; ?>';
72
- </script>
73
- <?php }
74
-
75
- }
76
-
77
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/accordion-shortcodes.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Accordion Shortcodes
4
+ * Description: Adds a few shortcodes to allow for accordion dropdowns.
5
+ Version: 1.1.1
6
+ * Author: Phil Buchanan
7
+ * Author URI: http://philbuchanan.com
8
+ */
9
+
10
+ # Make sure to not redeclare the class
11
+ if (!class_exists('Accordion_Shortcodes')) :
12
+
13
+ class Accordion_Shortcodes {
14
+
15
+ static $add_script;
16
+
17
+ function __construct() {
18
+
19
+ $basename = plugin_basename(__FILE__);
20
+
21
+ # Load text domain
22
+ load_plugin_textdomain('accordion_shortcodes', false, dirname($basename) . '/languages/');
23
+
24
+ # Register JavaScript
25
+ add_action('wp_enqueue_scripts', array(__CLASS__, 'register_script'));
26
+
27
+ # Add shortcodes
28
+ add_shortcode('accordion', array(__CLASS__, 'accordion_shortcode'));
29
+ add_shortcode('accordion-item', array(__CLASS__, 'accordion_item_shortcode'));
30
+
31
+ # Print script in wp_footer
32
+ add_action('wp_footer', array(__CLASS__, 'print_script'));
33
+
34
+ # Add link to documentation
35
+ add_filter("plugin_action_links_$basename", array(__CLASS__, 'add_documentation_link'));
36
+
37
+ }
38
+
39
+ # Checks for boolean value
40
+ static function parse_boolean($value) {
41
+
42
+ return filter_var($value, FILTER_VALIDATE_BOOLEAN);
43
+
44
+ }
45
+
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.1.1', true);
50
+
51
+ }
52
+
53
+ # Prints the minified accordion JavaScript file in the footer
54
+ static function print_script() {
55
+
56
+ # Check to see if shortcodes are used on page
57
+ if (!self::$add_script) return;
58
+
59
+ wp_enqueue_script('accordion-shortcodes-script');
60
+
61
+ }
62
+
63
+ # Accordion wrapper shortcode
64
+ static function accordion_shortcode($atts, $content = null) {
65
+
66
+ # The shortcode is used on the page, so we'll need to load the JavaScript
67
+ self::$add_script = true;
68
+
69
+ extract(shortcode_atts(array(
70
+ 'autoclose' => true,
71
+ 'openfirst' => false,
72
+ 'clicktoclose' => false
73
+ ), $atts));
74
+
75
+ # Set settings object (for use in JavaScript)
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);
82
+
83
+ return '<div class="accordion">' . do_shortcode($content) . '</div>';
84
+
85
+ }
86
+
87
+ # Accordion item shortcode
88
+ static function accordion_item_shortcode($atts, $content = null) {
89
+
90
+ extract(shortcode_atts(array(
91
+ 'title' => '',
92
+ 'tag' => 'h3'
93
+ ), $atts));
94
+
95
+ return sprintf('<%3$s class="accordion-title">%1$s</%3$s><div class="accordion-content">%2$s</div>',
96
+ $title ? $title : '<span style="color:red;">' . __('Please enter a title attribute: [accordion-item title="Item title"]', 'accordion_shortcodes') . '</span>',
97
+ do_shortcode($content),
98
+ $tag
99
+ );
100
+
101
+ }
102
+
103
+ # Add documentation link on plugin page
104
+ static function add_documentation_link($links) {
105
+
106
+ $settings_link = '<a href="http://wordpress.org/plugins/accordion-shortcodes/">' . __('Documentation', 'accordion_shortcodes') . '</a>';
107
+
108
+ array_push($links, $settings_link);
109
+
110
+ return $links;
111
+
112
+ }
113
+
114
+ }
115
+
116
+ $Accordion_Shortcodes = new Accordion_Shortcodes;
117
+
118
+ endif;
119
+
120
+ ?>
trunk/accordion.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+ 'use strict';
3
+
4
+ var allTitles = $('.accordion-title'),
5
+ allPanels = $('.accordion-content').hide(),
6
+ firstPanel = $('.accordion-content:first-of-type'),
7
+ duration = 250,
8
+ settings = {
9
+ // Set defaults
10
+ autoClose: true,
11
+ openFirst: false,
12
+ clickToClose: false
13
+ };
14
+
15
+ // Check for accordion settings variable passed from WordPress
16
+ if (typeof accordionSettings !== 'undefined') {
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
+ }
25
+
26
+ // Add event listener
27
+ allTitles.click(function() {
28
+
29
+ // Only open the item if item isn't already open
30
+ if (!$(this).hasClass('open')) {
31
+
32
+ // Close all accordion items
33
+ if (settings.autoClose) {
34
+ allPanels.slideUp(duration);
35
+ allTitles.removeClass('open');
36
+ }
37
+
38
+ // Open clicked item
39
+ $(this).next().slideDown(duration);
40
+ $(this).addClass('open');
41
+
42
+ }
43
+ // If item is open, close it
44
+ else if (settings.clickToClose) {
45
+
46
+ $(this).next().slideUp(duration);
47
+ $(this).removeClass('open');
48
+
49
+ }
50
+ return false;
51
+
52
+ });
53
+
54
+ }(jQuery));
trunk/accordion.min.js ADDED
@@ -0,0 +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)
trunk/assets/screenshot-1.jpg ADDED
Binary file
trunk/assets/screenshot-2.jpg ADDED
Binary file
trunk/languages/default.po ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Accordion Shortcodes\n"
4
+ "POT-Creation-Date: 2014-01-22 09:48-0500\n"
5
+ "PO-Revision-Date: 2014-01-22 09:51-0500\n"
6
+ "Last-Translator: Phil Buchanan <info@philbuchanan.com>\n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.6.3\n"
12
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
15
+ "Language: en_CA\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../accordion-shortcodes.php:96
19
+ msgid "Please enter a title attribute: [accordion-item title=\"Item title\"]"
20
+ msgstr ""
21
+
22
+ #: ../accordion-shortcodes.php:106
23
+ msgid "Documentation"
24
+ msgstr ""
trunk/languages/es_ES.mo ADDED
Binary file
trunk/languages/fr_FR.mo ADDED
Binary file
trunk/readme.txt ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Accordion Shortcodes ===
2
+ Contributors: philbuchanan
3
+ Author URI: http://philbuchanan.com/
4
+ 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.1.1
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 dropdowns.
13
+
14
+ == Description ==
15
+ Adds a few shortcodes to allow for accordion dropdowns.
16
+
17
+ **NOTE:** If you are not comfortable with WordPress shortcodes, this plugin may not be for you.
18
+
19
+ = Features =
20
+
21
+ * Adds two shortcodes for adding an accordion to your site
22
+ * No default CSS added
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
+
29
+ = The Shortcodes =
30
+
31
+ The two shortcodes that are added are:
32
+
33
+ `[accordion]`
34
+
35
+ and
36
+
37
+ `[accordion-item title="" tag=""]`
38
+
39
+ = Basic Usage Example =
40
+
41
+ [accordion]
42
+ [accordion-item title="Title of accordion item"]Dropdown content goes here.[/accordion-item]
43
+ [accordion-item title="Second accordion item"]Dropdown content goes here.[/accordion-item]
44
+ [/accordion]
45
+
46
+ This will output the following HTML:
47
+
48
+ <div class="accordion">
49
+ <h3 class="accordion-title">Title of accordion item</h3>
50
+ <div class="accordion-content">
51
+ Dropdown content goes here.
52
+ </div>
53
+ <h3 class="accordion-title">Second accordion item</h3>
54
+ <div class="accordion-content">
55
+ Dropdown content goes here.
56
+ </div>
57
+ </div>
58
+
59
+ = Advanced Settings =
60
+
61
+ There are a few [advances settings](http://wordpress.org/plugins/accordion-shortcodes/other_notes/) for the plugin.
62
+
63
+ == Installation ==
64
+ 1. Upload the 'accordion-shortcodes' folder to the '/wp-content/plugins/' directory.
65
+ 2. Activate the plugin through the Plugins menu in WordPress.
66
+ 3. Add the shortcodes to your content.
67
+ 4. Add some [CSS](http://wordpress.org/plugins/accordion-shortcodes/other_notes/#Other-Notes) to your themes stylesheet to make the accordion look the way you want.
68
+
69
+ == Frequently Asked Questions ==
70
+
71
+ = Why isn't the JavaScript file loading on my site? =
72
+
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.
79
+
80
+ == Screenshots ==
81
+
82
+ 1. The shortcodes in the editor
83
+ 2. The accordion on the live site (note that CSS has been added to the themes stylesheet)
84
+
85
+ == Other Notes ==
86
+
87
+ = Sample CSS =
88
+
89
+ Here is some sample CSS to get you started if you want to customize the look and feel of the accordion.
90
+
91
+ /* Accordion Styles */
92
+ .accordion {
93
+ border-bottom: 1px solid #dbdbdb;
94
+ margin-bottom: 20px;
95
+ }
96
+ .accordion-title {
97
+ border-top: 1px solid #dbdbdb;
98
+ margin: 0;
99
+ padding: 20px 0;
100
+ cursor: pointer;
101
+ }
102
+ .accordion-title:hover {}
103
+ .accordion-title:first-child {border: none;}
104
+ .accordion-title.open {cursor: default;}
105
+ .accordion-content {padding-bottom: 20px;}
106
+
107
+ = Advanced Settings =
108
+
109
+ 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:
110
+
111
+ [accordion autoclose="true" openfirst="false" clicktoclose="false"]
112
+
113
+ **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`.
114
+
115
+ **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`.
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
+ 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]`
120
+
121
+ = Issues/Suggestions =
122
+
123
+ 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/).
124
+
125
+ == Changelog ==
126
+ = 1.1.1=
127
+ * Added link to documentation from plugins page
128
+ * Added FAQs to readme
129
+ * Added screenshots
130
+
131
+ = 1.1 =
132
+ * **WARNING**: This update makes HTML structure changes and will require changes to your CSS
133
+ * New HTML structure, based on class names
134
+ * HTML now validates properly
135
+ * Added localization support for error messages
136
+
137
+ = 1.0.4 =
138
+ * Added option to close an open item by clicking the title
139
+
140
+ = 1.0.3 =
141
+ * Added option to open the first item by default
142
+ * Fixed an issue where clicking an already open item will close and reopen it
143
+ * Added better inline documentation
144
+ * Added minified JavaScript file
145
+
146
+ = 1.0.2 =
147
+ * Added setting to disable auto closing of accordion items
148
+ * Better handling of accordion items with no title attribute set
149
+ * Updated minimum WordPress version requirement (should still work down to 2.8, but not supported)
150
+
151
+ = 1.0.1 =
152
+ * Checks if the class exists before trying to create it
153
+ * Updated readme
154
+
155
+ = 1.0 =
156
+ * Initial release
157
+
158
+ == Upgrade Notice ==
159
+ = 1.1.1 =
160
+ Added a link to plugin documentation from the plugins page for easy access.
161
+
162
+ = 1.1 =
163
+ **WARNING**: This update makes HTML structure changes and will require changes to your CSS.
164
+
165
+ = 1.0.4 =
166
+ Added an option to close an item by clicking the title.
167
+
168
+ = 1.0.3 =
169
+ Added an option to open the first item by default. Fixed a bug that caused open items to close and reopen when clicking them.
170
+
171
+ = 1.0.2 =
172
+ Added an option to disable auto closing of accordion items.
173
+
174
+ = 1.0.1 =
175
+ Minor code updates.
176
+
177
+ = 1.0 =
178
+ Initial release.