amr shortcode any widget - Version 2.0

Version Description

Download this release

Release Info

Developer anmari
Plugin Icon wp plugin amr shortcode any widget
Version 2.0
Comparing to
See all releases

Code changes from version 1.8 to 2.0

Files changed (4) hide show
  1. amr-admin-form-html.php +56 -95
  2. amr-shortcode-any-widget.php +132 -165
  3. amr-utilities.php +141 -0
  4. readme.txt +40 -11
amr-admin-form-html.php CHANGED
@@ -9,7 +9,7 @@ if (!class_exists('amr_saw_plugin_admin')) {
9
  class amr_saw_plugin_admin {
10
  var $hook = 'amr_saw';
11
  var $filename = 'amr_shortcode_any_widget/amr_shortcode_any_widget.php';
12
- var $longname = 'Shortcode any widget';
13
  var $shortname = 'Shortcode any widget';
14
  var $optionname = '';
15
  var $homepage = '';
@@ -66,7 +66,7 @@ if (!class_exists('amr_saw_plugin_admin')) {
66
  _e('Set the widgets parameters if there are any.');
67
  echo '</li>';
68
  echo '<li>';
69
- _e('You could test them out in a displayable sidebar, then drag them to the shortcodes sidebar.');
70
 
71
  echo '</li>';
72
  echo '<li>';
@@ -74,124 +74,85 @@ if (!class_exists('amr_saw_plugin_admin')) {
74
  _e('Go to widgets');
75
  echo '</a>';
76
  echo '</li>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  echo '<li>';
78
- _e('Then add the shortcode [do_widget widgetname] to a page.');
 
79
  echo '</li>';
80
  echo '<li>';
81
- _e('Examples:[do_widget "tag cloud"] or [do_widget id=widgetid]');
82
  echo '</li>';
83
  echo '<li>';
84
  echo '<a title="Create a page" href="'
85
  .add_query_arg('content','[do_widget Archives]', get_admin_url('','post-new.php?post_type=page'))
86
  .'"> ';
87
- _e('Create the page');
88
  echo '</a>';
89
  echo '</li>';
90
  echo '<li>';
91
- echo 'You can add as many of these on one page as you like. Use title=false to switch off the title.';
 
 
92
  echo '</li>';
93
  echo '<li>';
94
- echo '[do_widget pages title=false]';
95
  echo '</li>';
96
  echo '<li>';
97
- echo '[do_widget categories]';
98
  echo '</li>';
99
  echo '<li>';
100
- echo '[do_widget "tag cloud"]';
101
  echo '</li>';
102
  echo '<li>';
103
- echo '[do_widget "recent posts"]';
104
  echo '</li>';
105
  echo '<li>';
106
- echo '<li>';
107
- echo 'If the plugin cannot work out what you want, it will show a debug prompt
108
- , click on the debug prompt and look for the name or id of your widget in the shortcodes sidebar (you may have to scroll through a lot of debug info). If the name does not work, try with the id. Sometimes the widget name that wordpress calls it internally is not the same as what you see on the screen and you will need the debug to find the id.';
109
  echo '</li>';
110
- echo '<li>';
111
  echo '</ul>';
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
-
115
-
116
- /**
117
- * Create a Checkbox input field
118
- */
119
- function radiobutton($id, $label, $value, $selected) {
120
- $sel = checked($value,$selected, false);
121
- return "<input type='radio' id='".$id."' name='".$id."' value='".$value."'"
122
- . $sel."/>&nbsp;".$label."<br />";
123
- }
124
- /**
125
- * Create a Checkbox input field
126
- */
127
- function checkbox($id, $label, $value) {
128
- return '<input type="checkbox" id="'.$id.'" name="'.$id.'"'. checked($value,true,false).'/>&nbsp;<label for="'.$id.'">'.$label.'</label><br/>';
129
- }
130
- /**
131
- * Create a Dropdown input field
132
- */
133
- function dropdown($id, $label, $options, $selected) {
134
- //
135
- $html = '<label for="'.$id.'">'.$label.':</label><br/>'
136
- .'<select id=\''.$id.'\' name=\''.$id.'\'>';
137
- foreach ($options as $i => $option) {
138
- //
139
- $sel = selected($i, $selected, false); //wordpress function returns with single quotes, not double
140
- $html .= '<OPTION '.$sel.' label=\''.$option.'\' value=\''.$i.'\'>'.$option.'</OPTION>';
141
- }
142
- $html .= '</select>';
143
- return ($html);
144
- }
145
- /**
146
- * Create a Text input field
147
- */
148
- function textinput($id, $label, $value, $length='45') {
149
- return '<label for="'.$id.'">'.$label.':</label><br/><input size="'
150
- .$length.'" type="text" id="'.$id.'" name="'.$id.'" value="'.$value.'"/><br/><br/>';
151
- }
152
- /**
153
- * Create a Text area field
154
- */
155
- function textarea($id, $label, $value, $cols='45', $rows='10') {
156
- return '<label for="'.$id.'">'.$label.':</label><br/>'
157
- .'<textarea rows="'.$rows.'" cols="'.$cols
158
- .'" id="'.$id.'" name="'.$id.'"/>'.$value.'</TEXTAREA><br/><br/>';
159
- }
160
- /**
161
- * Create a postbox widget
162
- */
163
- function postbox($id, $title, $content) {
164
- ?>
165
- <div id="<?php echo $id; ?>" class="postbox">
166
- <div class="handlediv" title="Click to toggle"><br /></div>
167
- <h3 class="hndle"><span><?php echo $title; ?></span></h3>
168
- <div class="inside">
169
- <?php echo $content; ?>
170
- </div>
171
- </div>
172
- <?php
173
- }
174
- /**
175
- * Create a form table from an array of rows
176
- */
177
- function form_table($rows) { // array of rows () id, label, desc, content
178
- $content = '<table class="form-table">';
179
- foreach ($rows as $row) {
180
- $content .= '<tr><th valign="top" scrope="row">';
181
- if (isset($row['id']) && $row['id'] != '')
182
- $content .= '<label for="'.$row['id'].'">'.$row['label'].':</label>';
183
- else
184
- $content .= $row['label'];
185
- if (isset($row['desc']) && $row['desc'] != '')
186
- $content .= '<br/><small>'.$row['desc'].'</small>';
187
- $content .= '</th><td valign="top">';
188
- $content .= $row['content'];
189
- $content .= '</td></tr>';
190
- }
191
- $content .= '</table>';
192
- return $content;
193
- }
194
-
195
  /**
196
  * Info box with link to the support forums.
197
  */
9
  class amr_saw_plugin_admin {
10
  var $hook = 'amr_saw';
11
  var $filename = 'amr_shortcode_any_widget/amr_shortcode_any_widget.php';
12
+ var $longname = 'Shortcode any widget - insert widgets or widget areas into a page.';
13
  var $shortname = 'Shortcode any widget';
14
  var $optionname = '';
15
  var $homepage = '';
66
  _e('Set the widgets parameters if there are any.');
67
  echo '</li>';
68
  echo '<li>';
69
+ _e('You could test the widgets out in a displayable widget area (sidebar/footer), then drag them to the widgets_for_shortcodes sidebar.');
70
 
71
  echo '</li>';
72
  echo '<li>';
74
  _e('Go to widgets');
75
  echo '</a>';
76
  echo '</li>';
77
+ echo '</ul>';
78
+
79
+ echo '<h2>';
80
+ _e('To add a widget area - all widgets in the widget area:');
81
+
82
+ echo '</h2>';
83
+ echo '<ul>';
84
+ echo '<li>';
85
+ echo '<a title="Create a page" href="'
86
+ .add_query_arg('content','[do_widget_area]', get_admin_url('','post-new.php?post_type=page'))
87
+ .'"> ';
88
+ _e('Create a page with do_widget_area shortcode');
89
+ echo '</a>';
90
+ echo '</li>';
91
+ echo '<li>';
92
+ _e('Examples:');
93
+ echo '</li>';
94
+ echo '<li>';
95
+ _e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]');
96
+ echo '</li>';
97
+ echo '<li>';
98
+ _e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Be prepared to adjust your css!');
99
+ echo '</li>';
100
+ echo '</ul>';
101
+ echo '<br />';
102
+
103
+ echo '<h2>';
104
+ _e('To add a single widget to a page');
105
+
106
+ echo '</h2>';
107
+ echo '<ul>';
108
  echo '<li>';
109
+ _e('Add the shortcode [do_widget widgetname] to a page.');
110
+ _e('Examples:');
111
  echo '</li>';
112
  echo '<li>';
113
+ _e('[do_widget "tag cloud"] or [do_widget id=widgetid]');
114
  echo '</li>';
115
  echo '<li>';
116
  echo '<a title="Create a page" href="'
117
  .add_query_arg('content','[do_widget Archives]', get_admin_url('','post-new.php?post_type=page'))
118
  .'"> ';
119
+ _e('Create a page with do_widget shortcode');
120
  echo '</a>';
121
  echo '</li>';
122
  echo '<li>';
123
+ echo 'Use title=false to hide a widget title. ';
124
+ echo 'Use title=somehtmltag and wrap=somehtmltag to change the html used.';
125
+ echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling?';
126
  echo '</li>';
127
  echo '<li>';
128
+ echo '[do_widget pages title=false] will hide the widget title';
129
  echo '</li>';
130
  echo '<li>';
131
+ echo '[do_widget pages title=h3] give the title a heading 3 html tag.';
132
  echo '</li>';
133
  echo '<li>';
134
+ echo '[do_widget categories] or [do_widget name=categories] will do the same thing: display the categories widget.';
135
  echo '</li>';
136
  echo '<li>';
137
+ echo '[do_widget "tag cloud" wrap=aside] will wrap the widget in an "aside" html tag.';
138
  echo '</li>';
139
  echo '<li>';
140
+ echo '[do_widget "recent posts"]';
 
 
141
  echo '</li>';
 
142
  echo '</ul>';
143
+
144
+ echo '<p>';
145
+ echo 'If the plugin cannot work out what you want, it will show a debug prompt
146
+ , click on the debug prompt and look for the name or id of your widget in the shortcodes sidebar (you may have to scroll through a lot of debug info). If the name does not work, try with the id. Sometimes the widget name that wordpress calls it internally is not the same as what you see on the screen and you will need the debug to find the id.';
147
+ echo '</p><p><b>';
148
+ echo "Valid title html tags are : h1, h2, h3, h4, h5, header, strong, em ";
149
+ echo '</b></p><p><b>';
150
+ echo "Valid html wrap tags are : div, p, aside , section";
151
+ echo '</b></p>';
152
+
153
  }
154
 
155
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  /**
157
  * Info box with link to the support forums.
158
  */
amr-shortcode-any-widget.php CHANGED
@@ -2,13 +2,31 @@
2
  /*
3
  Plugin Name: amr shortcode any widget
4
  Plugin URI: http://webdesign.anmari.com/shortcode-any-widget/
5
- Description: Include any widget in a page for any theme. [do_widget widgetname ] or [do_widget "widget name" ]. If upgrading see changelog. Can be very powerful eg: with queryposts widget it can become a templater.
6
  Author: anmari
7
- Version: 1.8
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
 
 
 
 
 
 
 
 
11
 
 
 
 
 
 
 
 
 
 
 
12
  /*-----------------------------------*/
13
  function do_widget($atts) {
14
 
@@ -26,22 +44,29 @@ if it is in, then get the instance data and use that */
26
  }
27
 
28
  extract(shortcode_atts(array(
29
- 'sidebar' => 'Shortcodes',
 
30
  'id' => '',
31
- 'title' => 'true' /* do the default title unless they ask us not to - use string here not boolean */
 
 
 
32
  ), $atts));
33
 
34
-
 
 
 
 
35
 
36
  /* the widget need not be specified, [do_widget widgetname] is adequate */
37
- if (!empty($atts[0])) { // we have a name
38
- $widget = $atts[0];
39
 
40
  foreach ($wp_registered_widgets as $i => $w) { /* get the official internal name or id that the widget was registered with */
41
  if (strtolower($w['name']) === strtolower($widget)) $widget_ids[] = $i;
42
  //if ($debug) {echo '<br /> Check: '.$w['name'];}
43
- }
44
-
45
  }
46
  else { /* check for id if we do not have a name */
47
  if (!empty($id)) { /* if a specific id has been specified */
@@ -58,31 +83,24 @@ if it is in, then get the instance data and use that */
58
  }
59
 
60
  if (empty ($widget_ids)) {
61
- echo '<p><b>Requested widget not found in widget list.';
62
  amr_show_widget_debug('empty', $atts);
63
  return (false) ;
64
- }
65
-
66
- if ($title == 'false')
67
- $title = false; /* If ask not to display title, then do not */
68
- else
69
- $title = true;
70
 
71
  if (!($sidebarid = get_sidebar_id ($sidebar)))
72
- $sidebarid=$sidebar; /* get the official sidebar id - will take the first one */
73
 
74
  if (empty($widget))
75
  $widget = '';
76
- /* if ($debug) {
77
- echo '<hr>Looking for widget with name:'.$widget.' or id='.$id.' Found instances:'.' <br />';
78
- if (!empty($widget_ids)) foreach ($widget_ids as $i=> $w) {
79
- echo $w.'<br />';
80
- };
81
- }
82
- */
83
  $content = '';
84
  /* if the widget is in our chosen sidebar, then use the options stored for that */
85
 
 
 
 
 
86
  if ((isset ($_wp_sidebars_widgets[$sidebarid])) and (!empty ($_wp_sidebars_widgets[$sidebarid]))) {
87
  /* if ($debug) {
88
  echo '<br />Widget ids in sidebar: "'.$sidebar.'" with id: '.$sidebarid .'<br />';
@@ -104,14 +122,15 @@ if it is in, then get the instance data and use that */
104
  }
105
  else { /* the sidebar is not defined */
106
  //if ($debug) {
107
- echo '<br />Sidebar '.$sidebar.'with sidebarid '.$sidebarid.' is empty or not defined.';
108
  //}
109
  }
110
 
111
  $output = '';
112
  if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
113
  //if ($debug) {
114
- echo '<h2>Widget '.$widget.' not in sidebar with id '.$sidebarid.' and with name '.$sidebar.'</h2>';
 
115
  //}
116
  unset($sidebar);
117
  unset($sidebarid);
@@ -122,111 +141,92 @@ if it is in, then get the instance data and use that */
122
  $output = '';
123
  foreach ($wid as $i=>$widget_instance) {
124
  ob_start(); /* catch the echo output, so we can control where it appears in the text */
125
- shortcode_sidebar($widget_instance, $sidebar, $title);
126
  $output .= ob_get_clean();
127
  }
128
-
129
  }
130
 
131
  return ($output);
132
  }
133
- /*-----------------------------------*/
134
- function amr_get_sidebar_name ($id) { /* dont need anymore ? or at least temporarily */
135
- /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */
136
- global $wp_registered_sidebars;
137
- foreach ($wp_registered_sidebars as $i => $a) {
138
- if ((isset ($a['id'])) and ( $a['id'] === $id)) {
139
- if (isset($a['name'])) return ($a['name']);
140
- else return ($id);
141
- }
142
- }
143
- return (false);
144
- }
145
- /*-----------------------------------*/
146
- function get_sidebar_id ($name) { /* dont need anymore ? or at least temporarily */
147
- /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */
148
- global $wp_registered_sidebars;
149
- foreach ($wp_registered_sidebars as $i => $a) {
150
- if ((isset ($a['name'])) and ( $a['name'] === $name)) return ($i);
151
- }
152
- return (false);
153
- }
154
  /* -------------------------------------------------------------------------*/
155
- function shortcode_sidebar( $id, $index=1, $title=true) { /* This is basically the wordpress code, slightly modified */
156
  global $wp_registered_sidebars, $wp_registered_widgets;
157
 
158
  $debug = amr_check_if_widget_debug();
159
 
160
- if ( is_int($index) ) {
161
- $index = "sidebar-$index";
162
- } else {
163
- $index = sanitize_title($index);
164
- foreach ( (array) $wp_registered_sidebars as $key => $value ) {
165
- if ( sanitize_title($value['name']) == $index ) {
166
- $index = $key;
167
- break;
168
- }
169
- }
170
- }
171
 
172
  $sidebars_widgets = wp_get_sidebars_widgets();
173
-
174
- /* if ($debug) {
175
- echo '<h3> result of wp_get_sidebars_widgets()</h3>';
176
- foreach ($sidebars_widgets as $i=>$w) {
177
- echo '<br />'.$w['name'].' '.$w['id'];
178
- };
179
- }
180
- */
181
-
182
- /* DONT NEED TO BE ACTIVE ? if there are no active widgets */
183
- // if ( empty($wp_registered_sidebars[$index]) ||
184
- // !array_key_exists($index, $sidebars_widgets) ||
185
- // !is_array($sidebars_widgets[$index])
186
- // || empty($sidebars_widgets[$index]) ) {
187
- // echo '<br />'.'No active widgets for '.$index;
188
- // return false;
189
- // }
190
 
191
- // $sidebar = $wp_registered_sidebars[$index];
192
- $sidebar = array('wp_inactive_widgets');
193
  $did_one = false;
194
 
195
- // foreach ( (array) $sidebars_widgets[$index] as $id ) { /* lifted from wordpress code, keep as similar as possible for now */
196
 
197
- if ( !isset($wp_registered_widgets[$id]) ) continue;
198
 
199
  $params = array_merge(
200
- array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),
201
- (array) $wp_registered_widgets[$id]['params']
202
- );
 
 
 
 
 
 
 
 
 
 
 
203
 
204
- // Substitute HTML id and class attributes into before_widget
 
 
 
 
 
205
  $classname_ = '';
206
- foreach ( (array) $wp_registered_widgets[$id]['classname'] as $cn ) {
 
207
  if ( is_string($cn) )
208
  $classname_ .= '_' . $cn;
209
  elseif ( is_object($cn) )
210
  $classname_ .= '_' . get_class($cn);
211
- }
212
  $classname_ = ltrim($classname_, '_');
 
 
 
 
 
 
 
213
  if (!empty($params[0]['before_widget']))
214
- $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
215
- else $params[0]['before_widget'] = '';
216
- if (empty($params[0]['after_widget'])) $params[0]['after_widget'] = '';
 
 
217
 
218
- $params = apply_filters( 'dynamic_sidebar_params', $params );
219
 
220
- if (!$title) { /* amr switch off the title html, still need to get rid of title separately */
221
- $params[0]['before_title'] = '<span style="display: none">';
222
- $params[0]['after_title'] = '</span>';
223
- }
224
- else {
225
- $params[0]['before_title'] = '<h2>';
226
- $params[0]['after_title'] = '</h2>';
 
 
 
 
227
  }
228
 
229
- $callback = $wp_registered_widgets[$id]['callback'];
230
  if ( is_callable($callback) ) {
231
  call_user_func_array($callback, $params);
232
  $did_one = true;
@@ -235,82 +235,49 @@ function shortcode_sidebar( $id, $index=1, $title=true) { /* This is basically t
235
  return $did_one;
236
  }
237
  /* -------------------------------------------------------------------------------------------------------------*/
238
- function amr_reg_sidebar() {
239
- if ( function_exists('register_sidebar') )
240
- register_sidebar(array('name'=>'Shortcodes',
241
- 'id' => 'Shortcodes',
242
- 'before_widget' => '<div id="%1$s" class="widget %2$s clearfix">',
243
- 'after_widget' => '</div>',
244
- 'before_title' => '<h2 class="widgettitle">',
245
- 'after_title' => '</h2>' ));
246
- }
247
- /*-----------------------------------*/
248
- function amr_check_if_widget_debug() {
249
- // only do these debug if we are logged in and are the administrator
250
 
251
- if ((!is_user_logged_in()) or (!current_user_can('administrator')))
252
- return false;
253
-
254
- if (isset($_REQUEST['do_widget_debug'])) {
255
- echo '<br/>Note: Debugs only shown to a Logged in Administrator.<br />';
256
- return true;
257
- }
258
- else
259
- return false;
260
- }
261
- /*-----------------------------------*/
262
- function amr_show_widget_debug($type='', $atts=array()) {
263
- global $wp_registered_sidebars, $wp_registered_widgets,$_wp_sidebars_widgets;
264
- // only do these debug if we are logged in and are the administrator
265
 
266
- $debug = amr_check_if_widget_debug();
 
 
 
 
 
 
 
 
267
 
268
- if ($type=='empty') {
269
- if (current_user_can('administrator')) echo '<br />You are admin: <a href="'.add_query_arg('do_widget_debug','1').'">Try debug</a></b></p>';
270
 
271
- if ($debug) {
272
-
273
- echo '<h2>As a last resort, dump the wp variables </h2>';
274
- $sidebars_widgets = wp_get_sidebars_widgets();
275
- echo '<h3> result of wp_get_sidebars_widgets()</h3>';
276
- foreach ($sidebars_widgets as $i=>$w) {
277
- echo '<br/>'.$i; var_dump($w);
278
- };
279
-
280
- echo '<h3>$_wp_sidebars_widgets:</h3>';
281
- var_dump($_wp_sidebars_widgets);
282
- echo '<br /><h3>$wp_registered_widgets:</h3>';
283
- var_dump($wp_registered_widgets);
284
- }
285
  }
286
 
287
- if (($type=='which one') and ($debug)) {
288
- echo '<h3>DEBUG on: Please scroll down till you find the shortcodes sidebar.</h3>';
289
- echo '<br />Attributes entered:<br />';
290
- var_dump($atts);
291
- echo '<br />Shortcode sidebar and widgets<br />';
292
- foreach ($_wp_sidebars_widgets as $i=> $w) {
293
- if (($i == "Shortcodes")) {
294
- echo 'Sidebar:&nbsp;<b>'.$i.': '.amr_get_sidebar_name($i).'</b><br />';
295
- if (is_array($w)) {
296
- sort ($w);
297
- foreach ($w as $i2=> $w2) {
298
- echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$w2.' <br />';
299
- };
300
- }
301
- echo '<br />';
302
- }
303
- };
304
- }
305
  }
306
  /*-----------------------------------*/
307
  include ('amr-admin-form-html.php');
308
- if (is_admin() ) $amr_saw_plugin_admin = new amr_saw_plugin_admin();
309
- add_action('admin_init', 'amr_reg_sidebar');
 
310
 
311
- add_shortcode('do_widget', 'do_widget');
 
 
 
312
 
 
 
313
 
314
- require_once(ABSPATH . 'wp-includes/widgets.php');
315
 
316
  ?>
2
  /*
3
  Plugin Name: amr shortcode any widget
4
  Plugin URI: http://webdesign.anmari.com/shortcode-any-widget/
5
+ Description: Include any widget in a page for any theme. [do_widget widgetname ] or [do_widget "widget name" ] or include a whole widget area [do_widget_area]. If upgrading see changelog. Can be very powerful eg: with queryposts widget it can become a templater.
6
  Author: anmari
7
+ Version: 2.0
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
11
+ /*-----------------------------------*/
12
+ function do_widget_area($atts) {
13
+
14
+ global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
15
+
16
+ extract(shortcode_atts(array(
17
+ 'widget_area' => 'widgets_for_shortcodes'
18
+ ), $atts));
19
 
20
+ $output = PHP_EOL.'<div id="'.$widget_area.'" class="amr-widget-area widget-area">';
21
+
22
+ ob_start(); /* catch the echo output, so we can control where it appears in the text */
23
+ dynamic_sidebar($widget_area);
24
+ $output .= ob_get_clean();
25
+
26
+ $output .= '</div>'.PHP_EOL;
27
+
28
+ return ($output);
29
+ }
30
  /*-----------------------------------*/
31
  function do_widget($atts) {
32
 
44
  }
45
 
46
  extract(shortcode_atts(array(
47
+ // 'sidebar' => 'Shortcodes',
48
+ 'sidebar' => 'Widgets for Shortcodes',
49
  'id' => '',
50
+ 'name' => '', /* MKM added explicit 'name' attribute. For existing users we still need to allow prev method, else too many support queries will happen */
51
+ 'title' => '', /* do the default title unless they ask us not to - use string here not boolean */
52
+ 'class' => 'amr_widget', /* the widget class is picked up automatically. If we want to add an additional class at the wrap level to try to match a theme, use this */
53
+ 'wrap' => '' /* wrap the whole thing - title plus widget in a div - maybe the themes use a div, maybe not, maybe we want that styling, maybe not */
54
  ), $atts));
55
 
56
+
57
+
58
+ /* compatibility check - if the name is not entered, then the first parameter is the name */
59
+ if (empty($name) and !empty($atts[0]))
60
+ $name = $atts[0];
61
 
62
  /* the widget need not be specified, [do_widget widgetname] is adequate */
63
+ if (!empty($name)) { // we have a name
64
+ $widget = $name;
65
 
66
  foreach ($wp_registered_widgets as $i => $w) { /* get the official internal name or id that the widget was registered with */
67
  if (strtolower($w['name']) === strtolower($widget)) $widget_ids[] = $i;
68
  //if ($debug) {echo '<br /> Check: '.$w['name'];}
69
+ }
 
70
  }
71
  else { /* check for id if we do not have a name */
72
  if (!empty($id)) { /* if a specific id has been specified */
83
  }
84
 
85
  if (empty ($widget_ids)) {
86
+ echo '<br /><a href="" title="Error: Your Requested widget '.$widget.' '.$id.' is not in the widget list. Typo maybe?">!</a><br />';
87
  amr_show_widget_debug('empty', $atts);
88
  return (false) ;
89
+ }
 
 
 
 
 
90
 
91
  if (!($sidebarid = get_sidebar_id ($sidebar)))
92
+ $sidebarid=$sidebar; /* get the official sidebar id for this widget area - will take the first one */
93
 
94
  if (empty($widget))
95
  $widget = '';
96
+
 
 
 
 
 
 
97
  $content = '';
98
  /* if the widget is in our chosen sidebar, then use the options stored for that */
99
 
100
+ if ((!isset ($_wp_sidebars_widgets[$sidebarid])) or (empty ($_wp_sidebars_widgets[$sidebarid]))) { // try upgrade
101
+ amr_upgrade_sidebar();
102
+ }
103
+
104
  if ((isset ($_wp_sidebars_widgets[$sidebarid])) and (!empty ($_wp_sidebars_widgets[$sidebarid]))) {
105
  /* if ($debug) {
106
  echo '<br />Widget ids in sidebar: "'.$sidebar.'" with id: '.$sidebarid .'<br />';
122
  }
123
  else { /* the sidebar is not defined */
124
  //if ($debug) {
125
+ echo '<br /><a href="" title="Error: Sidebar '.$sidebar.' with sidebarid '.$sidebarid.' is empty (no widgets) or is not defined.">!</a><br />';
126
  //}
127
  }
128
 
129
  $output = '';
130
  if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
131
  //if ($debug) {
132
+ echo '<br /><a href="" title="Error: Your requested Widget '.$widget.' is not in the '.$sidebar.' sidebar ">!</a><br />';
133
+ amr_show_widget_debug('empty', $atts);
134
  //}
135
  unset($sidebar);
136
  unset($sidebarid);
141
  $output = '';
142
  foreach ($wid as $i=>$widget_instance) {
143
  ob_start(); /* catch the echo output, so we can control where it appears in the text */
144
+ shortcode_sidebar($widget_instance, $sidebar, $title, $class, $wrap);
145
  $output .= ob_get_clean();
146
  }
 
147
  }
148
 
149
  return ($output);
150
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  /* -------------------------------------------------------------------------*/
152
+ function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=true, $class='', $wrap='') { /* This is basically the wordpress code, slightly modified */
153
  global $wp_registered_sidebars, $wp_registered_widgets;
154
 
155
  $debug = amr_check_if_widget_debug();
156
 
157
+ $sidebarid = get_sidebar_id ($name);
 
 
 
 
 
 
 
 
 
 
158
 
159
  $sidebars_widgets = wp_get_sidebars_widgets();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
 
161
+ $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
162
+
163
  $did_one = false;
164
 
165
+ /* lifted from wordpress code, keep as similar as possible for now */
166
 
167
+ if ( !isset($wp_registered_widgets[$widget_id]) ) continue;
168
 
169
  $params = array_merge(
170
+ array(
171
+ array_merge( $sidebar, array('widget_id' => $widget_id, 'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
172
+ (array) $wp_registered_widgets[$widget_id]['params']
173
+ );
174
+
175
+ $validtitletags = array ('h1','h2','h3','h4','h5','header','strong','em');
176
+ $validwraptags = array ('div','p','main','aside','section');
177
+
178
+ if (!empty($wrap)) { /* then folks want to 'wrap' with their own html tag, or wrap = yes */
179
+ if ((!in_array( $wrap, $validwraptags)))
180
+ $wrap = '';
181
+ /* To match a variety of themes, allow for a variety of html tags. */
182
+ /* May not need if our sidebar match attempt has worked */
183
+ }
184
 
185
+ if (!empty ($wrap)) {
186
+ $params[0]['before_widget'] = '<'.$wrap.' id="%1$s" class="%2$s ">';
187
+ $params[0]['after_widget'] = '</'.$wrap.'>';
188
+ }
189
+
190
+ // wp code to get classname
191
  $classname_ = '';
192
+ //foreach ( (array) $wp_registered_widgets[$widget_id]['classname'] as $cn ) {
193
+ $cn = $wp_registered_widgets[$widget_id]['classname'];
194
  if ( is_string($cn) )
195
  $classname_ .= '_' . $cn;
196
  elseif ( is_object($cn) )
197
  $classname_ .= '_' . get_class($cn);
198
+ //}
199
  $classname_ = ltrim($classname_, '_');
200
+
201
+ // add MKM and others requested class in to the wp classname string
202
+ // if no class specfied, then class will = amrwidget. These classes are so can reverse out unwanted widget styling.
203
+
204
+ $classname_ .= ' widget '.$class;
205
+
206
+ // Substitute HTML id and class attributes into before_widget
207
  if (!empty($params[0]['before_widget']))
208
+ $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
209
+ else
210
+ $params[0]['before_widget'] = '';
211
+
212
+ if (empty($params[0]['before_widget'])) $params[0]['after_widget'] = '';
213
 
214
+ //$params = apply_filters( 'dynamic_sidebar_params', $params ); // should we do this? - intended for sidebar but we not in sidebar
215
 
216
+ if (!empty($title)) {
217
+ if ($title=='false') { /* amr switch off the title html, still need to get rid of title separately */
218
+ $params[0]['before_title'] = '<span style="display: none">';
219
+ $params[0]['after_title'] = '</span>';
220
+ }
221
+ else {
222
+ if (in_array( $title, $validtitletags)) {
223
+ $params[0]['before_title'] = '<'.$title.' class="widget-title">';
224
+ $params[0]['after_title'] = '</'.$title.'>';
225
+ }
226
+ }
227
  }
228
 
229
+ $callback = $wp_registered_widgets[$widget_id]['callback'];
230
  if ( is_callable($callback) ) {
231
  call_user_func_array($callback, $params);
232
  $did_one = true;
235
  return $did_one;
236
  }
237
  /* -------------------------------------------------------------------------------------------------------------*/
238
+ function amr_reg_sidebar() { // this is fired late, so hopefully any theme sidebars will have been registered already.
 
 
 
 
 
 
 
 
 
 
 
239
 
240
+ global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
 
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
+ if ( function_exists('register_sidebar') ) { // maybe later, get the first main sidebar and copy it's before/after etc
243
+ $args = array(
244
+ 'name' =>'Widgets for Shortcodes',
245
+ 'id' => 'widgets_for_shortcodes', // hope to avoid losing widgets
246
+ 'description' => 'Sidebar to hold widgets and their settings. These widgets will be used in a shortcode. This sidebars widgets should be saved with your theme settings now.',
247
+ 'before_widget' => '<aside'.' id="%1$s" class="%2$s ">', // 201402 to match twentyfourteen theme
248
+ 'after_widget' => '</aside>',
249
+ 'before_title' => '<h1 class="widget-title" >', // 201402 maybe dont use widget class - we are in content here not in a widget area but others want?
250
+ 'after_title' => '</h1>' );
251
 
 
 
252
 
253
+
254
+ if (!empty($wp_registered_sidebars)) { // we got some sidebars already.
255
+ $main_sidebar = array_pop($wp_registered_sidebars); // Grab the first sidebar and use that as defaults for the widgets
256
+ $args['before_widget'] = $main_sidebar['before_widget'];
257
+ $args['after_widget'] = $main_sidebar['after_widget'];
258
+ $args['before_title'] = $main_sidebar['before_title'];
259
+ $args['after_title'] = $main_sidebar['after_title'];
 
 
 
 
 
 
 
260
  }
261
 
262
+ register_sidebar($args);
263
+ }
264
+
265
+ //else { echo '<h1>CANNOT REGISTER widgets_for_shortcodes SIDEBAR</h1>';}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
  /*-----------------------------------*/
268
  include ('amr-admin-form-html.php');
269
+ include ('amr-utilities.php');
270
+
271
+ if (is_admin() ) $amr_saw_plugin_admin = new amr_saw_plugin_admin();
272
 
273
+ add_action('widgets_init', 'amr_reg_sidebar',98); // register late so it appears last
274
+ add_action('widgets_init', 'amr_upgrade_sidebar',99); // copy old shortcodes sidebar to new one if necessary
275
+ add_action('switch_theme', 'amr_save_shortcodes_sidebar');
276
+ add_action('after_switch_theme','amr_restore_shortcodes_sidebar');
277
 
278
+ add_shortcode('do_widget', 'do_widget');
279
+ add_shortcode('do_widget_area', 'do_widget_area'); // just dump the whole widget area - to get same styling
280
 
281
+ //require_once(ABSPATH . 'wp-includes/widgets.php'); // *** do we really need this here?
282
 
283
  ?>
amr-utilities.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*-----------------------------------*/
3
+ function get_sidebar_id ($name) {
4
+ /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
5
+ take the first one that matches */
6
+ global $wp_registered_sidebars;
7
+
8
+ foreach ($wp_registered_sidebars as $i => $a) {
9
+ if ((isset ($a['name'])) and ( $a['name'] === $name))
10
+ return ($i);
11
+ }
12
+ return (false);
13
+ }
14
+ /*-----------------------------------*/
15
+ function amr_get_sidebar_name ($id) { /* dont need anymore ? or at least temporarily */
16
+ /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */
17
+ global $wp_registered_sidebars;
18
+ foreach ($wp_registered_sidebars as $i => $a) {
19
+ if ((isset ($a['id'])) and ( $a['id'] === $id)) {
20
+ if (isset($a['name'])) return ($a['name']);
21
+ else return ($id);
22
+ }
23
+ }
24
+ return (false);
25
+ }
26
+ /*-----------------------------------*/
27
+ function amr_check_if_widget_debug() {
28
+ // only do these debug if we are logged in and are the administrator
29
+
30
+ if ((!is_user_logged_in()) or (!current_user_can('administrator')))
31
+ return false;
32
+
33
+ if (isset($_REQUEST['do_widget_debug'])) {
34
+ $url_without_debug_query = remove_query_arg( 'do_widget_debug');
35
+ $eek = '<a href="'.$url_without_debug_query.'">Remove debug</a>';
36
+ echo '<br/>Note: Debugs only shown to a Logged in Administrator.'
37
+ .'<br />'
38
+ .$eek
39
+ .'<br />';
40
+ return true;
41
+ }
42
+ else
43
+ return false;
44
+ }
45
+ /*-----------------------------------*/
46
+ function amr_show_widget_debug($type='', $atts=array()) {
47
+ global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets;
48
+ // only do these debug if we are logged in and are the administrator
49
+
50
+ $debug = amr_check_if_widget_debug();
51
+
52
+ if ($type=='empty') {
53
+ if (current_user_can('administrator'))
54
+ echo '<br /> You are admin: <a href="'.add_query_arg('do_widget_debug','1').'">Try debug </a></b>'
55
+ .'See a exclamation point ! above ?. Hover over to see error message.'
56
+ .'</p>';
57
+
58
+ if ($debug) {
59
+
60
+ echo '<p>As a last resort, we may dump the wp variables to do with sidebars and widgets. Maybe that will help you:</p>';
61
+ $sidebars_widgets = wp_get_sidebars_widgets();
62
+ echo '<h3> result of wp_get_sidebars_widgets():</h3>';
63
+ foreach ($sidebars_widgets as $i=>$w) {
64
+ echo '<br/>'.$i; var_dump($w);
65
+ };
66
+
67
+ echo '<h3>$_wp_sidebars_widgets:</h3>';
68
+ var_dump($_wp_sidebars_widgets);
69
+ //echo '<br /><h3>$wp_registered_widgets:</h3>';
70
+ //var_dump($wp_registered_widgets);
71
+ echo '<br /><h3>$wp_registered_sidebars:</h3>';
72
+ var_dump($wp_registered_sidebars);
73
+ }
74
+ }
75
+
76
+ if (($type=='which one') and ($debug)) {
77
+ echo '<h3>DEBUG on: Is your widget in the widgets_for_shortcodes sidebar?</h3>';
78
+ //echo '<br />The shortcode attributes you entered are:<br />';
79
+ //var_dump($atts);
80
+ echo '<br /><h2>widgets_for_shortcodes sidebar and widgets</h2>';
81
+ $found = false;
82
+ foreach ($_wp_sidebars_widgets as $i=> $w) {
83
+ if (($i == "widgets_for_shortcodes")) {
84
+ echo 'Sidebar:&nbsp;<b>'.$i.': '.amr_get_sidebar_name($i).'</b> has widgets: <br />';
85
+ $found = true;
86
+ if (is_array($w)) {
87
+ sort ($w);
88
+ foreach ($w as $i2=> $w2) {
89
+ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$w2.' <br />';
90
+ };
91
+ }
92
+ echo '<br />';
93
+ }
94
+ //else {echo ' '.$i;}
95
+ };
96
+ if (!$found) echo '<h2>widgets_for_shortcodes sidebar empty or not defined.</h2>';
97
+ }
98
+ }
99
+ /*-----------------------------------*/
100
+ function amr_save_shortcodes_sidebar() { // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten
101
+ $sidebars_widgets = wp_get_sidebars_widgets();
102
+ if (!empty($sidebars_widgets['widgets_for_shortcodes']))
103
+ update_option('sidebars_widgets_for_shortcodes_saved',$sidebars_widgets['widgets_for_shortcodes']);
104
+ else { // our shortcodes sidebar is empty but when to fix ?
105
+
106
+ }
107
+ }
108
+ /*-----------------------------------*/
109
+ function amr_restore_shortcodes_sidebar() { // when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten
110
+ global $_wp_sidebars_widgets;
111
+
112
+ $sidebars_widgets = wp_get_sidebars_widgets();
113
+ if (empty($sidebars_widgets['widgets_for_shortcodes'])) {
114
+ $sidebars_widgets['widgets_for_shortcodes'] = get_option('sidebars_widgets_for_shortcodes_saved');
115
+ update_option('sidebars_widgets',$sidebars_widgets);
116
+
117
+ }
118
+
119
+ }
120
+ /*-----------------------------------*/
121
+ function amr_upgrade_sidebar() { // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.?
122
+ $sidebars_widgets = wp_get_sidebars_widgets();
123
+ if (!empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes'])) { // we need to upgrade
124
+ $sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes'];
125
+ unset ($sidebars_widgets['Shortcodes']);
126
+ update_option('sidebars_widgets',$sidebars_widgets );
127
+ add_action( 'admin_notices', 'widgets_shortcode_admin_notice' );
128
+ }
129
+ }
130
+
131
+ /*-----------------------------------*/
132
+ function widgets_shortcode_admin_notice() {
133
+ ?>
134
+ <div class="updated">
135
+ <p>Please go to widgets page and check your "widgets for shortcodes" sidebar. It will hopefully have been corrected upgraded with your widgets and all should be fine.</p>
136
+ </div>
137
+ <?php
138
+ }
139
+ /*-----------------------------------*/
140
+
141
+ ?>
readme.txt CHANGED
@@ -2,26 +2,33 @@
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template
4
  Tested up to: 3.8.1
5
- Version: 1.8
6
  Stable tag: trunk
7
 
8
  == Description ==
9
  This simple 'utility' plugin allows one to have any widget used in a page shortcode in any theme - no need to use the hybrid theme or create a special template. You could use the query posts widget in the page to create a archive within a page, or the rss widget to list feed content from other sites. For more details see [anmari.com](http://webdesign.anmari.com/category/plugins/shortcode-any-widget/)
10
 
11
- 1. Test chosen widget works in normal sidebar first.
12
- 2. Activate this plugin
13
- 3. Go to Appearance > widgets and find "shortcode" sidebar
14
- 4. Drag chosen widgets from configured sidebar to shortcodes sidebar. Save.
15
- 5. Go to page where you want configured widget to appear
16
- 6. enter one of:
17
  [do_widget widgetname] eg: [do_widget calendar]
18
  [do_widget "widget name"]. eg: [do_widget "tag cloud"]
 
 
19
  [do_widget id=widgetid] in a page or post
20
- 7. If the plugin cannot work out what you want and you are logged in as an adminsitrator, it will show a debug prompt to you only.
21
  Click on the link 'Try debug'.
22
  It will produce a bunch of info. Look for the id of your widget in the shortcodes sidebar (you may have to scroll through a lot of debug info). Try wusing the widget id. Sometimes the widget name that wordpress calls it internally is not the same as what you see on the screen and you will need the 'debug' to find the id.
23
 
24
- Plugin has been tested with most standard widgets (rss feeds, tag cloud, pages, meta, search, and of course my own plugins widgets - upcoming events list, calendar and user lists.
 
 
 
 
 
25
 
26
  If you use a widget more than once for different reasons, you may need to use the widget id to isolate which widget instance and it's settings to use. ie: [do_widget id=categories-6] . If you just use the name, it will display all widgets in the shortcode sidebar with that name (all instances).
27
 
@@ -30,7 +37,17 @@ If you liked this plugin, you might also like my other plugins:
30
  [wpusersplugin.com](http://wpusersplugin.com) - a suite of plugins to help with membership sites. Major plugin is [amr users](http://wordpress.org/extend/plugins/amr-users/)
31
 
32
 
 
33
  == Changelog ==
 
 
 
 
 
 
 
 
 
34
  = Version 1.8 =
35
  * Whoops - had renamed the main file and forgot to delete it from the svn. Forcing a version number change to ensure files get cleaned up for everyone
36
 
@@ -68,13 +85,25 @@ If you liked this plugin, you might also like my other plugins:
68
  0. Activate plugin
69
  1. Goto Appearance > widgets and find "shortcode" sidebar
70
  1. Drag chosen widgets to shortcodes sidebar. Save. (note the names)
71
- 2. Add [do_widget id=widgetid] in a page or post
72
  3. If it fails, click on the debug prompt and look for the id of your widget, use that.
73
 
74
  Or can use [do_widget widgetname] within the text in the page and save. If the widget name has a space in it, use [do_widget "widget name"].
75
 
76
  If you use a widget more than once for different shortcodes, you can use the widget id to isolate which widget instance (and of course associated settings to use). ie: [do_widget id=categories-6]
77
-
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  == Screenshots ==
80
 
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template
4
  Tested up to: 3.8.1
5
+ Version: 2
6
  Stable tag: trunk
7
 
8
  == Description ==
9
  This simple 'utility' plugin allows one to have any widget used in a page shortcode in any theme - no need to use the hybrid theme or create a special template. You could use the query posts widget in the page to create a archive within a page, or the rss widget to list feed content from other sites. For more details see [anmari.com](http://webdesign.anmari.com/category/plugins/shortcode-any-widget/)
10
 
11
+ 1. Test your chosen widget works in a normal sidebar or widget area first.
12
+ 2. Then Activate this plugin
13
+ 3. Go to Appearance > widgets and find the " widgets for shortcode" sidebar or widget area
14
+ 4. Drag your chosen widgets from to the shortcodes sidebar. Save.
15
+ 5. Go the shortcode any widget settings. Click on one of the create page links to help you setup the shortcode.
16
+ 6. OR go to an existing page and enter a shortcode:
17
  [do_widget widgetname] eg: [do_widget calendar]
18
  [do_widget "widget name"]. eg: [do_widget "tag cloud"]
19
+ [do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
20
+ [do_widget_area sidebarname] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply. Beware of white text on white background issues (TwentyFourteen theme is a good example of this.)
21
  [do_widget id=widgetid] in a page or post
22
+ 7. If the plugin cannot work out what you want and you are logged in as an administrator, it will show a debug prompt to you, the logged in admin only.
23
  Click on the link 'Try debug'.
24
  It will produce a bunch of info. Look for the id of your widget in the shortcodes sidebar (you may have to scroll through a lot of debug info). Try wusing the widget id. Sometimes the widget name that wordpress calls it internally is not the same as what you see on the screen and you will need the 'debug' to find the id.
25
 
26
+ See the settings page for more examples.
27
+
28
+ To 'remove debug mode'
29
+ remove ?do_widget_debug=1 from the url you are looking at (only debugs if you are logged in and an administrator)
30
+
31
+ The plugin has been tested with most standard widgets (rss feeds, tag cloud, pages, meta, search, and of course my own plugins widgets - upcoming events list, calendar and user lists.
32
 
33
  If you use a widget more than once for different reasons, you may need to use the widget id to isolate which widget instance and it's settings to use. ie: [do_widget id=categories-6] . If you just use the name, it will display all widgets in the shortcode sidebar with that name (all instances).
34
 
37
  [wpusersplugin.com](http://wpusersplugin.com) - a suite of plugins to help with membership sites. Major plugin is [amr users](http://wordpress.org/extend/plugins/amr-users/)
38
 
39
 
40
+
41
  == Changelog ==
42
+ = Version 2 =
43
+ * Shortcode widget id changed so that wordpress will save the shortcode settings per theme.
44
+ * Added Code to auto upgrade, but just in case please check your widgets page. Look at the inactive widgets if the widgets are not in your widgets for shortcodes sidebar.
45
+ * Logic added on theme switching to save shortcode widget settings and restore them after the theme switch, so you can play with themes and not have to set up your widgets again. WP kept putting them into an 'inactive sidebar'.
46
+ * Added, as requested by a few of you, the ability to add a class and control the html around the widget without having to enter html around the shortcode has been added. See the settings page for instructions.
47
+ * Added the ability to specify what html should be used for the title and the widget wrap, so that you can more easily either match your theme or get away from your thesmes widget styling.
48
+ * Added ability to insert a whole widget area into the page. The default will be the "widgets for shortcode" sidebar/widget area. You can specify others. Note Specifying other widget areas may be theme dependent, ie: switch and you'll lose that page.
49
+ * Added classes amr-widget and amr-widget-area so one can target the widgets in the page to adjust css.
50
+
51
  = Version 1.8 =
52
  * Whoops - had renamed the main file and forgot to delete it from the svn. Forcing a version number change to ensure files get cleaned up for everyone
53
 
85
  0. Activate plugin
86
  1. Goto Appearance > widgets and find "shortcode" sidebar
87
  1. Drag chosen widgets to shortcodes sidebar. Save. (note the names)
88
+ 2. Add [do_widget widgetname] in a page or post or [do_widget_area]
89
  3. If it fails, click on the debug prompt and look for the id of your widget, use that.
90
 
91
  Or can use [do_widget widgetname] within the text in the page and save. If the widget name has a space in it, use [do_widget "widget name"].
92
 
93
  If you use a widget more than once for different shortcodes, you can use the widget id to isolate which widget instance (and of course associated settings to use). ie: [do_widget id=categories-6]
94
+
95
+ do_widget parameters:
96
+ title=false to hide a title
97
+ title= one of h1,h2,h3,h4,h5,strong,em
98
+ class=yourclassname
99
+ wrap=one of div, section, p, aside
100
+
101
+ Check your styling. The effects are very dependent on how your theme has specified the css that may apply to widgets and sidebars/widget areas.
102
+ You may have undesired effects applying that do not work in the main content area.
103
+ You may have desired effects not applying because the css is specific to a themes sidebar.
104
+
105
+
106
+
107
 
108
  == Screenshots ==
109