amr shortcode any widget - Version 3.2

Version Description

Download this release

Release Info

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

Code changes from version 3.1 to 3.2

Files changed (3) hide show
  1. amr-shortcode-any-widget.php +4 -4
  2. amr-utilities.php +8 -5
  3. readme.txt +13 -3
amr-shortcode-any-widget.php CHANGED
@@ -4,7 +4,7 @@ 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" ] [do_widget id=widgetnamedashed-n ]or include a whole widget area [do_widget_area]. Please read: <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/installation/">Installation</a> and <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/faq/">FAQ</a>.
6
  Author: anmari
7
- Version: 3.1
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
@@ -185,17 +185,17 @@ if it is in, then get the instance data and use that */
185
  else { /* the sidebar is not defined or selected - should not happen */
186
  if (isset($debug)) { // only do this in debug mode
187
  if (!isset($_wp_sidebars_widgets[$sidebarid]))
188
- $output = '<br /><a href="" title="Error: Sidebar '.$sidebar.' with sidebarid '.$sidebarid.' is not defined.">!</a><br />';
189
  // shouldnt happen - maybe someone running content filters on save
190
  else
191
- $output = '<br /><a href="" title="Error: Sidebar '.$sidebar.' with sidebarid '.$sidebarid.' is empty (no widgets)">!</a><br />';
192
  }
193
  }
194
 
195
  $output = '';
196
  if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
197
 
198
- $output = '<p><a href="" title="Error: Your requested Widget '.$widget.' is not in the '.$sidebar.' sidebar ">!</a></p>';
199
  $output .= amr_show_widget_debug('empty', $name, $id, $sidebar);
200
 
201
  unset($sidebar);
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" ] [do_widget id=widgetnamedashed-n ]or include a whole widget area [do_widget_area]. Please read: <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/installation/">Installation</a> and <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/faq/">FAQ</a>.
6
  Author: anmari
7
+ Version: 3.2
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
185
  else { /* the sidebar is not defined or selected - should not happen */
186
  if (isset($debug)) { // only do this in debug mode
187
  if (!isset($_wp_sidebars_widgets[$sidebarid]))
188
+ $output = '<p>Error: Sidebar "'.$sidebar.'" with sidebarid "'.$sidebarid.'" is not defined.</p>';
189
  // shouldnt happen - maybe someone running content filters on save
190
  else
191
+ $output = '<p>Error: Sidebar "'.$sidebar.'" with sidebarid "'.$sidebarid.'" is empty (no widgets)</p>';
192
  }
193
  }
194
 
195
  $output = '';
196
  if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
197
 
198
+ $output = '<p>Error: Your requested Widget "'.$widget.'" is not in the "'.$sidebar.'" sidebar</p>';
199
  $output .= amr_show_widget_debug('empty', $name, $id, $sidebar);
200
 
201
  unset($sidebar);
amr-utilities.php CHANGED
@@ -31,11 +31,14 @@ take the first one that matches */
31
  global $_wp_sidebars_widgets;
32
 
33
  foreach ($_wp_sidebars_widgets as $sidebarid => $sidebar) {
34
- foreach ($sidebar as $i=> $w) {
35
- if ($w == $wid) {
36
- return $sidebarid;
37
- }
38
- };
 
 
 
39
  }
40
  return (false); // widget id not in any sidebar
41
  }
31
  global $_wp_sidebars_widgets;
32
 
33
  foreach ($_wp_sidebars_widgets as $sidebarid => $sidebar) {
34
+
35
+ if (is_array($sidebar) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar
36
+ foreach ($sidebar as $i=> $w) {
37
+ if ($w == $wid) {
38
+ return $sidebarid;
39
+ }
40
+ };
41
+ }
42
  }
43
  return (false); // widget id not in any sidebar
44
  }
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
  Tested up to: 4.4.1
5
- Version: 3.1
6
  Stable tag: trunk
7
 
8
  == Description ==
@@ -10,16 +10,22 @@ Insert a widget or multiple widgets or a entire widget area (sidebar) into a pag
10
 
11
  Set up your widget first in a normal sidebar. Check it works.
12
  THEN Drag your chosen widgets to the sidebar called "widgets for shortcode".
 
13
  Add the do_widget shortcode to the page where you would like the widget to appear.
14
 
15
- Using a widget more than once? Reference a specific widget instance from the do_widget shortcode, or the chosen sidebar from the do_widget_area shortcode. Eg: [do_widget id=widget-n]
 
 
16
 
17
  For example: 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/)
18
 
19
  The plugins default action is that it will magically find the settings for your themes sidebar and use the sidebar html to control the widgets output. In most cases this means the widget will be styled as per the rest of your theme. If that does not look good, parameters exist to try override this behaviour.
 
20
  EG: in twenty-fourteen theme widget text ends up being white on white! widget_classes=none fixes that. Eg: [do_widget widget_classes=none yourwidget]
21
 
22
- Changed your theme and worried about losing the sidebar settings ? No problem, the plugin will save and restore the widgets_for_shortcode settings. On display it will then pick up the new themes sidebar settings.
 
 
23
 
24
  **Note:**
25
 
@@ -155,6 +161,10 @@ If you only using widget, maybe inserting the whole sidebar or widgertarea would
155
 
156
  == Changelog ==
157
 
 
 
 
 
158
  = Version 3.1 =
159
  * added code for the widget-id to appear in the widget settings window.
160
  * removed lots of the 'debug' as it will hopefully no longer be needed.
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
  Tested up to: 4.4.1
5
+ Version: 3.2
6
  Stable tag: trunk
7
 
8
  == Description ==
10
 
11
  Set up your widget first in a normal sidebar. Check it works.
12
  THEN Drag your chosen widgets to the sidebar called "widgets for shortcode".
13
+
14
  Add the do_widget shortcode to the page where you would like the widget to appear.
15
 
16
+ Using a widget more than once?
17
+
18
+ Reference a specific widget instance from the do_widget shortcode, or the chosen sidebar from the do_widget_area shortcode. Eg: [do_widget id=widget-n]
19
 
20
  For example: 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/)
21
 
22
  The plugins default action is that it will magically find the settings for your themes sidebar and use the sidebar html to control the widgets output. In most cases this means the widget will be styled as per the rest of your theme. If that does not look good, parameters exist to try override this behaviour.
23
+
24
  EG: in twenty-fourteen theme widget text ends up being white on white! widget_classes=none fixes that. Eg: [do_widget widget_classes=none yourwidget]
25
 
26
+ Changed your theme and worried about losing the sidebar settings ?
27
+
28
+ No problem, the plugin will save and restore the widgets_for_shortcode settings. On display it will then pick up the new themes sidebar settings.
29
 
30
  **Note:**
31
 
161
 
162
  == Changelog ==
163
 
164
+ = Version 3.2 =
165
+ * tweaked some error messages and handle situation better where there are no widgets or possibly empty sidebars.
166
+
167
+
168
  = Version 3.1 =
169
  * added code for the widget-id to appear in the widget settings window.
170
  * removed lots of the 'debug' as it will hopefully no longer be needed.