amr shortcode any widget - Version 3.4

Version Description

Download this release

Release Info

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

Code changes from version 3.3 to 3.4

Files changed (3) hide show
  1. amr-shortcode-any-widget.php +6 -6
  2. amr-utilities.php +8 -9
  3. readme.txt +268 -272
amr-shortcode-any-widget.php CHANGED
@@ -2,9 +2,9 @@
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" ] [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.3
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
@@ -35,7 +35,7 @@ function amr_remove_widget_class($params) { // remove the widget classes
35
 
36
  return ($params);
37
  }
38
- /*-----------------------------------*/
39
  function amr_do_widget_area($atts) {
40
 
41
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
@@ -83,7 +83,7 @@ global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
83
 
84
  return ($output);
85
  }
86
- /*-----------------------------------*/
87
  function amr_do_widget($atts) {
88
 
89
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
@@ -321,7 +321,7 @@ function amr_shortcode_sidebar( $widget_id,
321
  // }
322
  return $did_one;
323
  }
324
- /* ---------------------------------------------------------------------------*/
325
  function amr_reg_sidebar() { // this is fired late, so hopefully any theme sidebars will have been registered already.
326
 
327
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
@@ -351,7 +351,7 @@ if ( function_exists('register_sidebar') ) { // maybe later, get the first mai
351
 
352
  //else { echo '<h1>CANNOT REGISTER widgets_for_shortcodes SIDEBAR</h1>';}
353
  }
354
- /*-----------------------------------*/
355
  include ('amr-admin-form-html.php');
356
  include ('amr-utilities.php');
357
 
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" ] [do_widget id=widgetnamedashed-n ]or include a whole widget area [do_widget_area]. Please see <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/faq/">FAQ</a>.
6
  Author: anmari
7
+ Version: 3.4
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
35
 
36
  return ($params);
37
  }
38
+
39
  function amr_do_widget_area($atts) {
40
 
41
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
83
 
84
  return ($output);
85
  }
86
+
87
  function amr_do_widget($atts) {
88
 
89
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
321
  // }
322
  return $did_one;
323
  }
324
+
325
  function amr_reg_sidebar() { // this is fired late, so hopefully any theme sidebars will have been registered already.
326
 
327
  global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
351
 
352
  //else { echo '<h1>CANNOT REGISTER widgets_for_shortcodes SIDEBAR</h1>';}
353
  }
354
+
355
  include ('amr-admin-form-html.php');
356
  include ('amr-utilities.php');
357
 
amr-utilities.php CHANGED
@@ -24,7 +24,6 @@ global $_wp_sidebars_widgets;
24
  return ($text);
25
  }
26
 
27
- /*-----------------------------------*/
28
  function amr_get_widgets_sidebar($wid) {
29
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
30
  take the first one that matches */
@@ -42,7 +41,7 @@ global $_wp_sidebars_widgets;
42
  }
43
  return (false); // widget id not in any sidebar
44
  }
45
- /*-----------------------------------*/
46
  function amr_get_sidebar_id ($name) {
47
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
48
  take the first one that matches */
@@ -54,7 +53,7 @@ global $wp_registered_sidebars;
54
  }
55
  return (false);
56
  }
57
- /*-----------------------------------*/
58
  function amr_get_sidebar_name ($id) { /* dont need anymore ? or at least temporarily */
59
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */
60
  global $wp_registered_sidebars;
@@ -66,7 +65,7 @@ global $wp_registered_sidebars;
66
  }
67
  return (false);
68
  }
69
- /*-----------------------------------*/
70
  function amr_check_if_widget_debug() {
71
  global $said;
72
  // only do these debug if we are logged in and are the administrator
@@ -94,7 +93,7 @@ global $said;
94
  else
95
  return false;
96
  }
97
- /*-----------------------------------*/
98
  function amr_show_widget_debug($type='', $name, $id, $sidebar) {
99
  global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
100
  // only do these debug if we are logged in and are the administrator
@@ -113,7 +112,7 @@ global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $
113
 
114
  return ($text);
115
  }
116
- /*-----------------------------------*/
117
  function amr_save_shortcodes_sidebar() { // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten
118
  $sidebars_widgets = wp_get_sidebars_widgets();
119
  if (!empty($sidebars_widgets['widgets_for_shortcodes']))
@@ -122,7 +121,7 @@ function amr_save_shortcodes_sidebar() { // when switching a theme, save the wi
122
 
123
  }
124
  }
125
- /*-----------------------------------*/
126
  function amr_restore_shortcodes_sidebar() { // when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten
127
  global $_wp_sidebars_widgets;
128
 
@@ -134,7 +133,7 @@ global $_wp_sidebars_widgets;
134
  }
135
 
136
  }
137
- /*-----------------------------------*/
138
  function amr_upgrade_sidebar() { // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.?
139
  $sidebars_widgets = wp_get_sidebars_widgets();
140
  if (!empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes'])) { // we need to upgrade
@@ -152,6 +151,6 @@ function widgets_shortcode_admin_notice() {
152
  </div>
153
  <?php
154
  }
155
- /*-----------------------------------*/
156
 
157
  ?>
24
  return ($text);
25
  }
26
 
 
27
  function amr_get_widgets_sidebar($wid) {
28
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
29
  take the first one that matches */
41
  }
42
  return (false); // widget id not in any sidebar
43
  }
44
+
45
  function amr_get_sidebar_id ($name) {
46
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
47
  take the first one that matches */
53
  }
54
  return (false);
55
  }
56
+
57
  function amr_get_sidebar_name ($id) { /* dont need anymore ? or at least temporarily */
58
  /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer. take the first one */
59
  global $wp_registered_sidebars;
65
  }
66
  return (false);
67
  }
68
+
69
  function amr_check_if_widget_debug() {
70
  global $said;
71
  // only do these debug if we are logged in and are the administrator
93
  else
94
  return false;
95
  }
96
+
97
  function amr_show_widget_debug($type='', $name, $id, $sidebar) {
98
  global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
99
  // only do these debug if we are logged in and are the administrator
112
 
113
  return ($text);
114
  }
115
+
116
  function amr_save_shortcodes_sidebar() { // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten
117
  $sidebars_widgets = wp_get_sidebars_widgets();
118
  if (!empty($sidebars_widgets['widgets_for_shortcodes']))
121
 
122
  }
123
  }
124
+
125
  function amr_restore_shortcodes_sidebar() { // when switching a theme, restore the widgets we use for the shortcodes as they are getting overwritten
126
  global $_wp_sidebars_widgets;
127
 
133
  }
134
 
135
  }
136
+
137
  function amr_upgrade_sidebar() { // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.?
138
  $sidebars_widgets = wp_get_sidebars_widgets();
139
  if (!empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes'])) { // we need to upgrade
151
  </div>
152
  <?php
153
  }
154
+
155
 
156
  ?>
readme.txt CHANGED
@@ -1,276 +1,272 @@
1
- === amr shortcode any widget ===
2
- Contributors: anmari
3
- Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
- Tested up to: 4.7 alpha
5
- Version: 3.3
6
- Stable tag: trunk
7
-
8
- == Description ==
9
- Insert a widget or multiple widgets or a entire widget area (sidebar) into a page using a shortcode.
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 (or the do_widget_area)
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
-
32
- PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and please read https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ and https://wordpress.org/plugins/amr-shortcode-any-widget/faq/ and/or see the settings page. To see a list of your widgets in their sidebars, add ?do_widget_debug to the page with the do_widget shortcode.
33
-
34
- == Installation ==
35
-
36
- 1. Test your chosen widget in a normal sidebar or widget area first.
37
- 2. Then activate this plugin
38
- 3. Go to Appearance > widgets and find the " widgets for shortcode" sidebar or widget area
39
- 4. Drag your chosen widget from your normal sidebar to the shortcodes sidebar. Save.
40
- 5. Now go to a page and enter a do_widget shortcode The shortcode any widget settings page has some helpful (hopefully) examples and links.
41
-
42
- * [do_widget widgetname] eg: [do_widget calendar]
43
- * [do_widget "widget name"]. eg: [do_widget "tag cloud"]
44
- * [do_widget id=widgetid] . eg: [do_widget id=tag-cloud-3]
45
-
46
- * [do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
47
- * [do_widget_area sidebarname] or [do_widget_area widget_area=sidebarname] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply.
48
-
49
- **[do_widget ...] Parameters:**
50
-
51
- * *nameofwidget* or name="*nameofwidget*" This is NOT the title of the widget. THis is the name that you see in the widgets menu page even when unassigned to a sidebar. For existing users , you can also use just the name of the widget without name=. It must be the first parameter then. You can only do this with the name, not the id.
52
- * id=*wordpress assigned id of widget*. Examples: id=meta-3, id=tag-cloud-9 etc
53
- * title=false to hide the widgets title OR to override your themes first sidebar html settings for widget titles, use title=*htmltag* where *htmltag* is one of h1,h2,h3,h4,h5,header,strong,em.
54
- * wrap=*htmltag* where *htmltag* is one of div,p,main,aside,section. This will override your themes first sidebar widget wrapping html.
55
- * widget_classes=none This will remove the class "widget" from the wrapping html and the class "widget_title" from the title html. This may be enough to remove any unwanted css caused by your theme.
56
- * class=*yourclassname* By default the plugin will add a class of amr-widget to the wrapping html. You can use this to add any special css. Add css either by editing your themes stylesheet if it is a custom theme, or using something like the wordpress custom css plugin.
57
- * sidebar="*sidebarname*" will default to widgets_for_shortcode sidebar. Only use if you want to re-use a widget already being used in another sidebar. THis is theme dependent and WILL break if you change themes. Safer to use the widget_id.
58
-
59
- **[do_widget_area ...] Parameters:**
60
-
61
- * widget_area=*yourwidgetarea* defaults to 'widgets_for_shortcodes' if nothing entered
62
- * widget_area_class=none /* option to remove theme styling by removing the widget_area class from the sidebar html */
63
- * widget_classes=none /* option to remove the widget class from the widget wrappinghtml
64
- * class=*yourclassname* default is amr_widget_area. This will affect the widget area NOT the individual widgets. At the moment can only remove the widget classes, not replace them when using do_widget_area.
65
-
66
- Advanced users WARNING: using do_widget_area with a widget area other than the shortcode one means that if you changes themes and the new theme has different sidebars, then this shortcode with a named widget area will not work.
67
-
68
- See the settings page for links to help your create the shortcodes in a page.
69
-
70
- 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.
71
-
72
- 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).
73
-
74
-
75
- **If you liked this plugin, you might also like my other plugins:**
76
-
77
- * [icalevents.com](http://icalevents.com) - a ics compliant events plugin fully integrated with wordpress, so it will work with many other plugins (seo, maps, social)
78
- * [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/)
79
-
80
- == Frequently Asked Questions ==
81
-
82
- PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and PLEASE read https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ and the settings page before asking any questions.
83
-
84
- **Widget help, the widget is doing this, when it should do that**
85
-
86
- Please get the widget working first in a normal sidebar without this plugin and ask for support on the widgets forum it is does not work in a normal sidebar.
87
-
88
- **How to identify widget**
89
-
90
- To identify your widget in the shortcode, use the NAME or the ID.
91
-
92
- The name is the generic NAME like "tag cloud".
93
-
94
- The id is how wordpress identifies the instance of the widget. The id is visible at the bottom of the widget settings box.
95
-
96
- **Styling, your theme, css, overriding**
97
-
98
- Yes anything could happen wrt the appearance.(There are tens of 1000s of themes and widgets. Multiply out the possible combinations. Add in css specifity, inheritance and cascading rules. Consider you are moving the widget out of the sidebar where the the theme and widget plugin expect it to be. ) The effects are very dependent on how your theme has specified the css that may apply to widgets and sidebars/widget areas.
99
-
100
- It may work beautifully and have the content looking like it belongs with your theme.
101
-
102
- This plugin tries to help encourage that 'belonging' look. If it fails then it offers ways to switch the html and/or the classes being generated.
103
-
104
-
105
- Examples:
106
- * you may have undesired effects applying that do not work in the main content area
107
- * You may have desired effects not applying because the css is specific to a themes sidebar and does not apply to the html in a page.
108
-
109
- The plugin can help a bit - Via the plugin you can do the following to affect styling:
110
-
111
- * Remove the general wordpress 'widget' class from the widgets wrapping html and the 'widget_title' from the title html. ([do_widget *widgetname* widget_classes=none]
112
-
113
- * Change the 'wrap' html and the title html with parameters wrap=div title=h3. See the settings page.
114
-
115
- * Apply an existing class in your theme. Use [do_widget *widgetname* class=*yourclass*].
116
-
117
- * Use the additional class 'amr-widget' provided to specify alternate css in your themes stylesheet or with something like wordpress custom css.
118
-
119
- One of the new features is as a default setting is that the plugin will try have your current themes first sidebar styling apply to the widgets inserted into a page via the shortcode.
120
-
121
- Many folks requested this, insisting that absolutely this is what should be happening and why didn't it? Well..This could be great - Imagine: a plugin that can pick up the theme styling and change it as your theme changes.
122
-
123
- The success of this depends very much on how your theme specifies it's css. Does it always use classes ? - more css will apply. Does it lock the css down by sidebar-id: that css will not apply.
124
-
125
- It also depends on what the original widget plugin does with css and js. It may have done something thinking that the widget will always be inside a sidebar and not anticipated being in a page. This the shortcde-any-widget plugin has no control over.
126
-
127
- For example: An unwanted effect could be white text on a white background as in the twenty fourteen theme.
128
-
129
- **If you have an undesired styling effect with the default settings:**
130
-
131
- You need to learn the joys of the 'inspect element' tools in various browsers or browser web developer, firebug add-ons, so you can see what css is applying to what html. Then you can either change some of the html or override or change the css.
132
-
133
- Options if you don't like the default result:
134
-
135
- Use the 'amr-widget' class that has been added to the widget wrapping html to override any css.
136
-
137
- eg:
138
- .amr-widget [
139
- color: #000000;
140
- }
141
-
142
- Tap into a class you already have in your theme:
143
-
144
- [do_widget class=yourclass]
145
-
146
- Change the html that the shortcode-any-widget plugin will use.
147
-
148
- eg: don't like the h3.widget-title styling ? change the title html to h2 in the shotcode parameters
149
-
150
- [do_widget title=h2]
151
-
152
- eg: don't like the 'aside' wrapping html styling? change the wrapping html:
153
-
154
- [do_widget wrap=div]
155
-
156
- If you only using widget, maybe inserting the whole sidebar or widgertarea would give an interesting effect. Sidebar background css may apply.
157
-
158
- [do_widget_area]
159
-
160
-
161
-
162
- == Changelog ==
163
- = Version 3.3 =
164
- * Retested on wordpres 4.5 and 4.5.1-alpha
165
- * Re-instated the saving of widgets in the shortcode sidebar on theme switch and the reloading of these saved widgets when theme is reactivated (Was commented out for awhile back in 2014, but appears to be working well and very useful when you changing a theme but maybe forgotten about this page that has widget on it - yeah that could be bad !
166
-
167
-
168
- = Version 3.2 =
169
- * tweaked some error messages and handle situation better where there are no widgets or possibly empty sidebars.
170
-
171
-
172
- = Version 3.1 =
173
- * added code for the widget-id to appear in the widget settings window.
174
- * removed lots of the 'debug' as it will hopefully no longer be needed.
175
- * most error messages will now be returned in the shortcode, not echoed at top of page.
176
- * the do_widget_debug lists less, but hopefully more usefully a list of the do_widget and do_widget_area options based on your sidebars and the widgets in them.
177
-
178
- = Version 3 =
179
- * added code to not output anything if in admin (eg: in edit/save mode) in case something has forced application of content filters when saving (and not all widget stuff is active, so errors are output.
180
- * prefixed unprefixed function names to avoid conflicts
181
-
182
- = Version 2.9 =
183
- * in debug help, the link to the installation page help was not properly setup. Fixed.
184
-
185
- = Version 2.8 =
186
- * Tested on 4.3.1
187
- * No real functional change.
188
- * Tweaked debug info to look a little prettier. Also some error messages will not show unless you haev requested debug (?do_widiet_debug) to try to avoid the message that some genesis theme users are experiencing. I have not been able to recreate this with the genesis theme myself - it might be a plugin that they are using.
189
-
190
-
191
- = Version 2.6 =
192
- * Tested on 4.2
193
- * Removed from admin settings area the use of add_query_arg (unnecessary)
194
- * Added esc_url to widget id 'debug' oage just in case (it is only accessed by logged in admin, but lets be safe and keep everyone happy if the see the add_query_arg and remove_query_arg
195
-
196
- = Version 2.5 =
197
- * Tested on 4.1.1, Linked to the settings help page from the plugin action menu.
198
- * Changed the readme a bit to try further aid understanding and reduce support issues
199
- * Updated some screenshots.
200
-
201
- = Version 2.4 =
202
- * Tested on 4.1, Cleaned up the readme, Lang file for info page - most texts.
203
-
204
- = Version 2.3 =
205
- * Fixed some widget area class options that were not working.
206
- * Added a widget area debug option to make it easier to find how your theme has stored it's widget area / sidebar ids. They are not always easy to find.
207
- * Tested on 3.9.1
208
- * Updated readme
209
-
210
- = Version 2.2 =
211
- * Attempt to add more styling control.
212
- * Add widget_classes=none to reverse out widget type class. NOte to totally override wordpress widget
213
- * Add widget_area_class=none
214
-
215
- = Version 2.1 =
216
- * Bug Fix - last sidebar registered by theme was being overwritten by the attempt to copy the themes sidebar arguments so that cleverly (hopefully) the shortcode widgets would pick up the same styling. Fixed now. Now it really does pickup the first sidebars styling - with devasting consquence in twenty-fourteen theme - yes white text on white background is not fun to read. But on other themes it works a treat.
217
-
218
-
219
- = Version 2 =
220
- * Shortcode widget id changed so that wordpress will save the shortcode settings per theme.
221
- * 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.
222
- * 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'.
223
- * 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.
224
- * 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.
225
- * 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.
226
- * Added classes amr-widget and amr-widget-area so one can target the widgets in the page to adjust css.
227
-
228
- = Version 1.8 =
229
- * 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
230
-
231
- = Version 1.7 =
232
- * Change: Changed so that debugs and debug prompt will only show to a logged in administrator.
233
-
234
- = Version 1.6 =
235
- * Add: added a settings page to help people out (not really settings)
236
- * Fix: changed a clashing function name
237
-
238
- = Version 1.5 =
239
- * Fixed: a small bug which caused a warning if you had not saved the widgets in your shortcode sidebar
240
-
241
- = Version 1.4 =
242
- * Updated readme - made very detailed steps and added some screen shots.
243
- * Tested on wp 3.3.1 and fixed some notices when bad parameters entered.
244
-
245
- = Version 1.3 =
246
- * Added debug link and retested. Added readme.
247
-
 
248
  = 1.12 =
249
- * Changed dummy shortcode sidebar so it appears after the theme sidebars to avoid taking over their widgets (this happened in numbered sidebars) PLEASE note if you have upgraded, you may appear to have "lost" your widgets due to this sidebar change. You have not - they will be in your "inactive widgets" - please drag them to the new sidebar. You may also find that you have 2 versions of the plugin, with slightly different folder names. This will allow you to go back to the previous one to check what you had there if you need to. Deactivate the old one and activate the new one. Move your widgets back in. Test then Delete the old one. In one theme it also appeared that somehow due to this change, one of the sidebar widgets "moved" down to another sidebar. I think that this may have had something to do with the fact that sidebars can be numbered or named, so please check all your sidebars before continuing. As always make sure thath you know how to restore from a backup before doing any upgrades of any kind.
250
- * Tested in 2.9.2, can still use either the widget name "Categories" or id=categories-6. Note widget must have been created in the dummy shortcode sidebar.
251
-
252
  = 1.1 =
253
-
254
- * Allow for lowercase use of widget names for the those challenged by attention to detail!
255
- * Cleaned up debug mode to make it easier for people to identify which instance of a widget they are using. Add &do_widget_debug to url string.
256
-
257
  = 1.0 =
258
- * Launch of the plugin
259
-
260
-
261
-
262
-
263
- == Screenshots ==
264
-
265
- 1. setting up widgets in the widgets for shortcode sidebar. The widget's user interface (UI) is used to provide a UI for the do_widget shortcode.
266
- 2. add shortcode for widgets in a page (must be in the widgets for shortcode sidebar)
267
- 3. widgets in a page
268
- 4. with the default widget class and with widget_classes=none
269
- two rss feed widgets in shortcode sidebar - both will show if just name used
270
- 5. The widget id is now visible in the widget window
271
- 6. After clicking on debug message - scroll down till you see the shortcodes sidebar - the widgets and their ids will be listed. Find the id of the widget you want.
272
- 7. Shortcode parameters to remove widget-classes in theme like the twenty-fourteen theme (avoid white text on white background)
273
- 8. Example of multiple rss widgets in twenty-fourteen theme
274
-
275
-
276
 
1
+ === amr shortcode any widget ===
2
+ Contributors: anmari
3
+ Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
+ Tested up to: 4.8 alpha
5
+ Version: 3.4
6
+ Stable tag: trunk
7
+
8
+ == Description ==
9
+ Insert a widget or multiple widgets or a entire widget area (sidebar) into a page using a shortcode.
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 (or the do_widget_area)
15
+
16
+ Please see detailed info on shortcodes and parameters under the installation tab (depending what the plugin directory developers have most recently done, this may be under the FAQ, or at the very least under the readme.)
17
+
18
+ Using a widget more than once?
19
+
20
+ 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]
21
+
22
+ 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/)
23
+
24
+ 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.
25
+
26
+ 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]
27
+
28
+ Changed your theme and worried about losing the sidebar settings ?
29
+
30
+ 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.
31
+
32
+ **Note:**
33
+
34
+ PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and please read https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ and https://wordpress.org/plugins/amr-shortcode-any-widget/faq/ and/or see the settings page. To see a list of your widgets in their sidebars, add ?do_widget_debug to the page with the do_widget shortcode.
35
+
36
+ == Installation ==
37
+
38
+ 1. Test your chosen widget in a normal sidebar or widget area first.
39
+ 2. Then activate this plugin
40
+ 3. Go to Appearance > widgets and find the " widgets for shortcode" sidebar or widget area
41
+ 4. Drag your chosen widget from your normal sidebar to the shortcodes sidebar. Save.
42
+ 5. Now go to a page and enter a do_widget shortcode The shortcode any widget settings page has some helpful (hopefully) examples and links.
43
+
44
+ * [do_widget widgetname] eg: [do_widget calendar]
45
+ * [do_widget "widget name"]. eg: [do_widget "tag cloud"]
46
+ * [do_widget id=widgetid] . eg: [do_widget id=tag-cloud-3]
47
+
48
+ * [do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
49
+ * [do_widget_area sidebarid] or [do_widget_area widget_area=sidebarid] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply.
50
+
51
+ **[do_widget ...] Parameters:**
52
+
53
+ * *nameofwidget* or name="*nameofwidget*" This is NOT the title of the widget. THis is the name that you see in the widgets menu page even when unassigned to a sidebar. For existing users , you can also use just the name of the widget without name=. It must be the first parameter then. You can only do this with the name, not the id.
54
+ * id=*wordpress assigned id of widget*. Examples: id=meta-3, id=tag-cloud-9 etc
55
+ * title=false to hide the widgets title OR to override your themes first sidebar html settings for widget titles, use title=*htmltag* where *htmltag* is one of h1,h2,h3,h4,h5,header,strong,em.
56
+ * wrap=*htmltag* where *htmltag* is one of div,p,main,aside,section. This will override your themes first sidebar widget wrapping html.
57
+ * widget_classes=none This will remove the class "widget" from the wrapping html and the class "widget_title" from the title html. This may be enough to remove any unwanted css caused by your theme.
58
+ * class=*yourclassname* By default the plugin will add a class of amr-widget to the wrapping html. You can use this to add any special css. Add css either by editing your themes stylesheet if it is a custom theme, or using something like the wordpress custom css plugin.
59
+ * sidebar="*sidebarname*" will default to widgets_for_shortcode sidebar. Only use if you want to re-use a widget already being used in another sidebar. THis is theme dependent and WILL break if you change themes. Safer to use the widget_id.
60
+
61
+ **[do_widget_area ...] Parameters:**
62
+
63
+ * widget_area=*yourwidgetarea* defaults to 'widgets_for_shortcodes' if nothing entered
64
+ * widget_area_class=none /* option to remove theme styling by removing the widget_area class from the sidebar html */
65
+ * widget_classes=none /* option to remove the widget class from the widget wrappinghtml
66
+ * class=*yourclassname* default is amr_widget_area. This will affect the widget area NOT the individual widgets. At the moment can only remove the widget classes, not replace them when using do_widget_area.
67
+
68
+ Advanced users WARNING: using do_widget_area with a widget area other than the shortcode one means that if you changes themes and the new theme has different sidebars, then this shortcode with a named widget area will not work.
69
+
70
+ See the settings page for links to help your create the shortcodes in a page.
71
+
72
+ 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.
73
+
74
+ 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).
75
+
76
+
77
+ **If you liked this plugin, you might also like my other plugins:**
78
+
79
+ * [icalevents.com](http://icalevents.com) - a ics compliant events plugin fully integrated with wordpress, so it will work with many other plugins (seo, maps, social)
80
+ * [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/)
81
+
82
+ == Frequently Asked Questions ==
83
+
84
+ PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and PLEASE read the installation instructions (?is the plugin directory showing them!?) and the settings page before asking any questions.
85
+
86
+ **Widget help, the widget is doing this, when it should do that**
87
+
88
+ Please get the widget working first in a normal sidebar without this plugin and ask for support on the widgets forum it is does not work in a normal sidebar.
89
+
90
+ **How to identify widget**
91
+
92
+ To identify your widget in the shortcode, use the NAME or the ID.
93
+
94
+ The name is the generic NAME like "tag cloud".
95
+
96
+ The id is how wordpress identifies the instance of the widget. The id is visible at the bottom of the widget settings box.
97
+
98
+ **Styling, your theme, css, overriding**
99
+
100
+ Yes anything could happen wrt the appearance.(There are tens of 1000s of themes and widgets. Multiply out the possible combinations. Add in css specifity, inheritance and cascading rules. Consider you are moving the widget out of the sidebar where the the theme and widget plugin expect it to be. ) The effects are very dependent on how your theme has specified the css that may apply to widgets and sidebars/widget areas.
101
+
102
+ It may work beautifully and have the content looking like it belongs with your theme.
103
+
104
+ This plugin tries to help encourage that 'belonging' look. If it fails then it offers ways to switch the html and/or the classes being generated.
105
+
106
+
107
+ Examples:
108
+ * you may have undesired effects applying that do not work in the main content area
109
+ * You may have desired effects not applying because the css is specific to a themes sidebar and does not apply to the html in a page.
110
+
111
+ The plugin can help a bit - Via the plugin you can do the following to affect styling:
112
+
113
+ * Remove the general wordpress 'widget' class from the widgets wrapping html and the 'widget_title' from the title html. ([do_widget *widgetname* widget_classes=none]
114
+
115
+ * Change the 'wrap' html and the title html with parameters wrap=div title=h3. See the settings page.
116
+
117
+ * Apply an existing class in your theme. Use [do_widget *widgetname* class=*yourclass*].
118
+
119
+ * Use the additional class 'amr-widget' provided to specify alternate css in your themes stylesheet or with something like wordpress custom css.
120
+
121
+ One of the new features is as a default setting is that the plugin will try have your current themes first sidebar styling apply to the widgets inserted into a page via the shortcode.
122
+
123
+ Many folks requested this, insisting that absolutely this is what should be happening and why didn't it? Well..This could be great - Imagine: a plugin that can pick up the theme styling and change it as your theme changes.
124
+
125
+ The success of this depends very much on how your theme specifies it's css. Does it always use classes ? - more css will apply. Does it lock the css down by sidebar-id: that css will not apply.
126
+
127
+ It also depends on what the original widget plugin does with css and js. It may have done something thinking that the widget will always be inside a sidebar and not anticipated being in a page. This the shortcde-any-widget plugin has no control over.
128
+
129
+ For example: An unwanted effect could be white text on a white background as in the twenty fourteen theme.
130
+
131
+ **If you have an undesired styling effect with the default settings:**
132
+
133
+ You need to learn the joys of the 'inspect element' tools in various browsers or browser web developer, firebug add-ons, so you can see what css is applying to what html. Then you can either change some of the html or override or change the css.
134
+
135
+ Options if you don't like the default result:
136
+
137
+ Use the 'amr-widget' class that has been added to the widget wrapping html to override any css.
138
+
139
+ eg:
140
+ .amr-widget [
141
+ color: #000000;
142
+ }
143
+
144
+ Tap into a class you already have in your theme:
145
+
146
+ [do_widget class=yourclass]
147
+
148
+ Change the html that the shortcode-any-widget plugin will use.
149
+
150
+ eg: don't like the h3.widget-title styling ? change the title html to h2 in the shotcode parameters
151
+
152
+ [do_widget title=h2]
153
+
154
+ eg: don't like the 'aside' wrapping html styling? change the wrapping html:
155
+
156
+ [do_widget wrap=div]
157
+
158
+ If you only using widget, maybe inserting the whole sidebar or widgertarea would give an interesting effect. Sidebar background css may apply.
159
+
160
+ [do_widget_area]
161
+
162
+ == Changelog ==
163
+ = Version 3.4 =
164
+ * Retested on wordpres 4.7 and 4.8 alpha and forcing update because of plugin directory needs trigger temporarily to show the installation instructions
165
+
166
+ = Version 3.3 =
167
+ * Retested on wordpres 4.5 and 4.5.1-alpha
168
+ * Re-instated the saving of widgets in the shortcode sidebar on theme switch and the reloading of these saved widgets when theme is reactivated (Was commented out for awhile back in 2014, but appears to be working well and very useful when you changing a theme but maybe forgotten about this page that has widget on it - yeah that could be bad !
169
+
170
+ = Version 3.2 =
171
+ * tweaked some error messages and handle situation better where there are no widgets or possibly empty sidebars.
172
+
173
+ = Version 3.1 =
174
+ * added code for the widget-id to appear in the widget settings window.
175
+ * removed lots of the 'debug' as it will hopefully no longer be needed.
176
+ * most error messages will now be returned in the shortcode, not echoed at top of page.
177
+ * the do_widget_debug lists less, but hopefully more usefully a list of the do_widget and do_widget_area options based on your sidebars and the widgets in them.
178
+
179
+ = Version 3 =
180
+ * added code to not output anything if in admin (eg: in edit/save mode) in case something has forced application of content filters when saving (and not all widget stuff is active, so errors are output.
181
+ * prefixed unprefixed function names to avoid conflicts
182
+
183
+ = Version 2.9 =
184
+ * in debug help, the link to the installation page help was not properly setup. Fixed.
185
+
186
+ = Version 2.8 =
187
+ * Tested on 4.3.1
188
+ * No real functional change.
189
+ * Tweaked debug info to look a little prettier. Also some error messages will not show unless you haev requested debug (?do_widiet_debug) to try to avoid the message that some genesis theme users are experiencing. I have not been able to recreate this with the genesis theme myself - it might be a plugin that they are using.
190
+
191
+
192
+ = Version 2.6 =
193
+ * Tested on 4.2
194
+ * Removed from admin settings area the use of add_query_arg (unnecessary)
195
+ * Added esc_url to widget id 'debug' oage just in case (it is only accessed by logged in admin, but lets be safe and keep everyone happy if the see the add_query_arg and remove_query_arg
196
+
197
+ = Version 2.5 =
198
+ * Tested on 4.1.1, Linked to the settings help page from the plugin action menu.
199
+ * Changed the readme a bit to try further aid understanding and reduce support issues
200
+ * Updated some screenshots.
201
+
202
+ = Version 2.4 =
203
+ * Tested on 4.1, Cleaned up the readme, Lang file for info page - most texts.
204
+
205
+ = Version 2.3 =
206
+ * Fixed some widget area class options that were not working.
207
+ * Added a widget area debug option to make it easier to find how your theme has stored it's widget area / sidebar ids. They are not always easy to find.
208
+ * Tested on 3.9.1
209
+ * Updated readme
210
+
211
+ = Version 2.2 =
212
+ * Attempt to add more styling control.
213
+ * Add widget_classes=none to reverse out widget type class. NOte to totally override wordpress widget
214
+ * Add widget_area_class=none
215
+
216
+ = Version 2.1 =
217
+ * Bug Fix - last sidebar registered by theme was being overwritten by the attempt to copy the themes sidebar arguments so that cleverly (hopefully) the shortcode widgets would pick up the same styling. Fixed now. Now it really does pickup the first sidebars styling - with devasting consquence in twenty-fourteen theme - yes white text on white background is not fun to read. But on other themes it works a treat.
218
+
219
+
220
+ = Version 2 =
221
+ * Shortcode widget id changed so that wordpress will save the shortcode settings per theme.
222
+ * 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.
223
+ * 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'.
224
+ * 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.
225
+ * 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.
226
+ * 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.
227
+ * Added classes amr-widget and amr-widget-area so one can target the widgets in the page to adjust css.
228
+
229
+ = Version 1.8 =
230
+ * 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
231
+
232
+ = Version 1.7 =
233
+ * Change: Changed so that debugs and debug prompt will only show to a logged in administrator.
234
+
235
+ = Version 1.6 =
236
+ * Add: added a settings page to help people out (not really settings)
237
+ * Fix: changed a clashing function name
238
+
239
+ = Version 1.5 =
240
+ * Fixed: a small bug which caused a warning if you had not saved the widgets in your shortcode sidebar
241
+
242
+ = Version 1.4 =
243
+ * Updated readme - made very detailed steps and added some screen shots.
244
+ * Tested on wp 3.3.1 and fixed some notices when bad parameters entered.
245
+
246
+ = Version 1.3 =
247
+ * Added debug link and retested. Added readme.
248
+
249
  = 1.12 =
250
+ * Changed dummy shortcode sidebar so it appears after the theme sidebars to avoid taking over their widgets (this happened in numbered sidebars) PLEASE note if you have upgraded, you may appear to have "lost" your widgets due to this sidebar change. You have not - they will be in your "inactive widgets" - please drag them to the new sidebar. You may also find that you have 2 versions of the plugin, with slightly different folder names. This will allow you to go back to the previous one to check what you had there if you need to. Deactivate the old one and activate the new one. Move your widgets back in. Test then Delete the old one. In one theme it also appeared that somehow due to this change, one of the sidebar widgets "moved" down to another sidebar. I think that this may have had something to do with the fact that sidebars can be numbered or named, so please check all your sidebars before continuing. As always make sure thath you know how to restore from a backup before doing any upgrades of any kind.
251
+ * Tested in 2.9.2, can still use either the widget name "Categories" or id=categories-6. Note widget must have been created in the dummy shortcode sidebar.
252
+
253
  = 1.1 =
254
+
255
+ * Allow for lowercase use of widget names for the those challenged by attention to detail!
256
+ * Cleaned up debug mode to make it easier for people to identify which instance of a widget they are using. Add &do_widget_debug to url string.
257
+
258
  = 1.0 =
259
+ * Launch of the plugin
260
+
261
+ == Screenshots ==
262
+
263
+ 1. setting up widgets in the widgets for shortcode sidebar. The widget's user interface (UI) is used to provide a UI for the do_widget shortcode.
264
+ 2. add shortcode for widgets in a page (must be in the widgets for shortcode sidebar)
265
+ 3. widgets in a page
266
+ 4. with the default widget class and with widget_classes=none
267
+ two rss feed widgets in shortcode sidebar - both will show if just name used
268
+ 5. The widget id is now visible in the widget window
269
+ 6. After clicking on debug message - scroll down till you see the shortcodes sidebar - the widgets and their ids will be listed. Find the id of the widget you want.
270
+ 7. Shortcode parameters to remove widget-classes in theme like the twenty-fourteen theme (avoid white text on white background)
271
+ 8. Example of multiple rss widgets in twenty-fourteen theme
 
 
 
 
 
272