Version Description
Download this release
Release Info
Developer | anmari |
Plugin | amr shortcode any widget |
Version | 2.2 |
Comparing to | |
See all releases |
Code changes from version 2.1 to 2.2
- amr-admin-form-html.php +17 -3
- amr-shortcode-any-widget.php +58 -14
- index.php +3 -0
- readme.txt +81 -26
- screenshot-1.jpg +0 -0
- screenshot-1.png +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-4.jpg → screenshot-7.jpg +0 -0
- screenshot-7.png +0 -0
- screenshot-8.jpg +0 -0
- screenshot-9.jpg +0 -0
amr-admin-form-html.php
CHANGED
@@ -57,6 +57,7 @@ if (!class_exists('amr_saw_plugin_admin')) {
|
|
57 |
}
|
58 |
function config_page() {
|
59 |
$this->admin_heading($this->longname);
|
|
|
60 |
echo '<ul>';
|
61 |
echo '<li>';
|
62 |
_e('Drag the widgets you want to use to the shortcodes sidebar.');
|
@@ -85,8 +86,15 @@ if (!class_exists('amr_saw_plugin_admin')) {
|
|
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:');
|
@@ -95,14 +103,13 @@ if (!class_exists('amr_saw_plugin_admin')) {
|
|
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.
|
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>';
|
@@ -114,6 +121,13 @@ if (!class_exists('amr_saw_plugin_admin')) {
|
|
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');
|
57 |
}
|
58 |
function config_page() {
|
59 |
$this->admin_heading($this->longname);
|
60 |
+
echo '<h3><a href="http://wordpress.org/plugins/amr-shortcode-any-widget/">More detailed instructions at the wordpress plugin page.</a></h3>';
|
61 |
echo '<ul>';
|
62 |
echo '<li>';
|
63 |
_e('Drag the widgets you want to use to the shortcodes sidebar.');
|
86 |
echo '<a title="Create a page" href="'
|
87 |
.add_query_arg('content','[do_widget_area]', get_admin_url('','post-new.php?post_type=page'))
|
88 |
.'"> ';
|
89 |
+
_e('Create a page with do_widget_area shortcode without the widget_area class');
|
90 |
+
echo '</a> Hoping to avoid theme styling.';
|
91 |
+
echo '</li>';
|
92 |
+
echo '<li>';
|
93 |
+
echo '<a title="Create a page" href="'
|
94 |
+
.add_query_arg('content','[do_widget_area widget_area_class=none]', get_admin_url('','post-new.php?post_type=page'))
|
95 |
+
.'"> ';
|
96 |
_e('Create a page with do_widget_area shortcode');
|
97 |
+
echo '</a> Hoping to use theme styling.';
|
98 |
echo '</li>';
|
99 |
echo '<li>';
|
100 |
_e('Examples:');
|
103 |
_e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]');
|
104 |
echo '</li>';
|
105 |
echo '<li>';
|
106 |
+
_e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background. Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.');
|
107 |
echo '</li>';
|
108 |
echo '</ul>';
|
109 |
echo '<br />';
|
110 |
|
111 |
echo '<h2>';
|
112 |
_e('To add a single widget to a page');
|
|
|
113 |
echo '</h2>';
|
114 |
echo '<ul>';
|
115 |
echo '<li>';
|
121 |
echo '</li>';
|
122 |
echo '<li>';
|
123 |
echo '<a title="Create a page" href="'
|
124 |
+
.add_query_arg('content','[do_widget Archives widget_classes=none]', get_admin_url('','post-new.php?post_type=page'))
|
125 |
+
.'"> ';
|
126 |
+
_e('Create a page with do_widget shortcode and remove widget_classes');
|
127 |
+
echo '</a>';
|
128 |
+
echo '</li>';
|
129 |
+
echo '<li>';
|
130 |
+
echo '<a title="Create a page" href="'
|
131 |
.add_query_arg('content','[do_widget Archives]', get_admin_url('','post-new.php?post_type=page'))
|
132 |
.'"> ';
|
133 |
_e('Create a page with do_widget shortcode');
|
amr-shortcode-any-widget.php
CHANGED
@@ -4,24 +4,50 @@ 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.
|
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 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
@@ -49,7 +75,8 @@ if it is in, then get the instance data and use that */
|
|
49 |
'name' => '', /* MKM added explicit 'name' attribute. For existing users we still need to allow prev method, else too many support queries will happen */
|
50 |
'title' => '', /* do the default title unless they ask us not to - use string here not boolean */
|
51 |
'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 */
|
52 |
-
'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 */
|
|
|
53 |
), $atts));
|
54 |
|
55 |
|
@@ -140,7 +167,7 @@ if it is in, then get the instance data and use that */
|
|
140 |
$output = '';
|
141 |
foreach ($wid as $i=>$widget_instance) {
|
142 |
ob_start(); /* catch the echo output, so we can control where it appears in the text */
|
143 |
-
shortcode_sidebar($widget_instance, $sidebar, $title, $class, $wrap);
|
144 |
$output .= ob_get_clean();
|
145 |
}
|
146 |
}
|
@@ -148,7 +175,7 @@ if it is in, then get the instance data and use that */
|
|
148 |
return ($output);
|
149 |
}
|
150 |
/* -------------------------------------------------------------------------*/
|
151 |
-
function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=true, $class='', $wrap='') { /* This is basically the wordpress code, slightly modified */
|
152 |
global $wp_registered_sidebars, $wp_registered_widgets;
|
153 |
|
154 |
$debug = amr_check_if_widget_debug();
|
@@ -167,8 +194,10 @@ function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=tr
|
|
167 |
|
168 |
$params = array_merge(
|
169 |
array(
|
170 |
-
array_merge( $sidebar,
|
171 |
-
(
|
|
|
|
|
172 |
);
|
173 |
|
174 |
$validtitletags = array ('h1','h2','h3','h4','h5','header','strong','em');
|
@@ -182,7 +211,7 @@ function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=tr
|
|
182 |
}
|
183 |
|
184 |
if (!empty ($wrap)) {
|
185 |
-
$params[0]['before_widget'] = '<'.$wrap.' id="%1$s" class="%2$s
|
186 |
$params[0]['after_widget'] = '</'.$wrap.'>';
|
187 |
}
|
188 |
|
@@ -200,17 +229,25 @@ function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=tr
|
|
200 |
// add MKM and others requested class in to the wp classname string
|
201 |
// if no class specfied, then class will = amrwidget. These classes are so can reverse out unwanted widget styling.
|
202 |
|
203 |
-
$classname_ .= ' widget '
|
|
|
|
|
|
|
204 |
|
|
|
|
|
|
|
205 |
// Substitute HTML id and class attributes into before_widget
|
206 |
if (!empty($params[0]['before_widget']))
|
207 |
$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
|
208 |
else
|
209 |
$params[0]['before_widget'] = '';
|
210 |
|
211 |
-
if (empty($params[0]['before_widget']))
|
|
|
212 |
|
213 |
-
|
|
|
214 |
|
215 |
if (!empty($title)) {
|
216 |
if ($title=='false') { /* amr switch off the title html, still need to get rid of title separately */
|
@@ -219,11 +256,18 @@ function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=tr
|
|
219 |
}
|
220 |
else {
|
221 |
if (in_array( $title, $validtitletags)) {
|
222 |
-
$
|
|
|
|
|
223 |
$params[0]['after_title'] = '</'.$title.'>';
|
224 |
}
|
225 |
}
|
226 |
}
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
$callback = $wp_registered_widgets[$widget_id]['callback'];
|
229 |
if ( is_callable($callback) ) {
|
@@ -245,7 +289,7 @@ if ( function_exists('register_sidebar') ) { // maybe later, get the first mai
|
|
245 |
'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.',
|
246 |
'before_widget' => '<aside'.' id="%1$s" class="%2$s ">', // 201402 to match twentyfourteen theme
|
247 |
'after_widget' => '</aside>',
|
248 |
-
'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?
|
249 |
'after_title' => '</h1>' );
|
250 |
|
251 |
|
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.2
|
8 |
Author URI: http://webdesign.anmari.com
|
9 |
|
10 |
*/
|
11 |
+
function amr_remove_widget_class($params) { // remove the widget classes
|
12 |
+
if (!empty($params[0]['before_widget'])) {
|
13 |
+
$params[0]['before_widget'] =
|
14 |
+
str_replace ('"widget ','"',$params[0]['before_widget']);
|
15 |
+
}
|
16 |
+
|
17 |
+
if (!empty($params[0]['before_title'])) {
|
18 |
+
|
19 |
+
$params[0]['before_title'] =
|
20 |
+
$params[0]['before_title'] = str_replace ('widget-title','',$params[0]['before_title']);
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
return ($params);
|
25 |
+
}
|
26 |
/*-----------------------------------*/
|
27 |
function do_widget_area($atts) {
|
28 |
|
29 |
global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
|
30 |
|
31 |
extract(shortcode_atts(array(
|
32 |
+
'widget_area' => 'widgets_for_shortcodes',
|
33 |
+
'class' => 'amr_widget_area', /* 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 */
|
34 |
+
'widget_area_class' => '', /* option to disassociate from themes widget styling use =none*/
|
35 |
+
'widget_classes' => '' /* option to disassociate from themes widget styling */
|
36 |
+
|
37 |
), $atts));
|
38 |
|
39 |
+
$class = 'class="amr-widget-area ';
|
40 |
+
if (empty($widget_area_class) or !($widget_area_class=='none'))
|
41 |
+
$class .= ' widget-area"';
|
42 |
+
$output = PHP_EOL.'<div id="'.$widget_area.'" '.$class. '>';
|
43 |
+
|
44 |
+
if (!empty($widget_classes) and ($widget_classes=='none'))
|
45 |
+
add_filter('dynamic_sidebar_params','amr_remove_widget_class');
|
46 |
|
47 |
ob_start(); /* catch the echo output, so we can control where it appears in the text */
|
48 |
dynamic_sidebar($widget_area);
|
49 |
$output .= ob_get_clean();
|
50 |
+
remove_filter('dynamic_sidebar_params','amr_remove_widget_class');
|
51 |
|
52 |
$output .= '</div>'.PHP_EOL;
|
53 |
|
75 |
'name' => '', /* MKM added explicit 'name' attribute. For existing users we still need to allow prev method, else too many support queries will happen */
|
76 |
'title' => '', /* do the default title unless they ask us not to - use string here not boolean */
|
77 |
'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 */
|
78 |
+
'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 */
|
79 |
+
'widget_classes' => '' /* option to disassociate from themes widget styling */
|
80 |
), $atts));
|
81 |
|
82 |
|
167 |
$output = '';
|
168 |
foreach ($wid as $i=>$widget_instance) {
|
169 |
ob_start(); /* catch the echo output, so we can control where it appears in the text */
|
170 |
+
shortcode_sidebar($widget_instance, $sidebar, $title, $class, $wrap, $widget_classes);
|
171 |
$output .= ob_get_clean();
|
172 |
}
|
173 |
}
|
175 |
return ($output);
|
176 |
}
|
177 |
/* -------------------------------------------------------------------------*/
|
178 |
+
function shortcode_sidebar( $widget_id, $name="widgets_for_shortcode", $title=true, $class='', $wrap='', $widget_classes='') { /* This is basically the wordpress code, slightly modified */
|
179 |
global $wp_registered_sidebars, $wp_registered_widgets;
|
180 |
|
181 |
$debug = amr_check_if_widget_debug();
|
194 |
|
195 |
$params = array_merge(
|
196 |
array(
|
197 |
+
array_merge( $sidebar,
|
198 |
+
array('widget_id' => $widget_id,
|
199 |
+
'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
|
200 |
+
(array) $wp_registered_widgets[$widget_id]['params']
|
201 |
);
|
202 |
|
203 |
$validtitletags = array ('h1','h2','h3','h4','h5','header','strong','em');
|
211 |
}
|
212 |
|
213 |
if (!empty ($wrap)) {
|
214 |
+
$params[0]['before_widget'] = '<'.$wrap.' id="%1$s" class="%2$s">';
|
215 |
$params[0]['after_widget'] = '</'.$wrap.'>';
|
216 |
}
|
217 |
|
229 |
// add MKM and others requested class in to the wp classname string
|
230 |
// if no class specfied, then class will = amrwidget. These classes are so can reverse out unwanted widget styling.
|
231 |
|
232 |
+
// $classname_ .= ' widget '; // wordpress seems to almost always adds the widget class
|
233 |
+
|
234 |
+
|
235 |
+
$classname_ .= ' '.$class;
|
236 |
|
237 |
+
// we are picking up the defaults from the thems sidebar ad they have registered heir sidebar to issue widget classes?
|
238 |
+
|
239 |
+
|
240 |
// Substitute HTML id and class attributes into before_widget
|
241 |
if (!empty($params[0]['before_widget']))
|
242 |
$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
|
243 |
else
|
244 |
$params[0]['before_widget'] = '';
|
245 |
|
246 |
+
if (empty($params[0]['before_widget']))
|
247 |
+
$params[0]['after_widget'] = '';
|
248 |
|
249 |
+
$params = apply_filters( 'dynamic_sidebar_params', $params );
|
250 |
+
// allow, any pne usingmust ensure they apply to the correct sidebars
|
251 |
|
252 |
if (!empty($title)) {
|
253 |
if ($title=='false') { /* amr switch off the title html, still need to get rid of title separately */
|
256 |
}
|
257 |
else {
|
258 |
if (in_array( $title, $validtitletags)) {
|
259 |
+
$class = ' class="widget-title" ';
|
260 |
+
|
261 |
+
$params[0]['before_title'] = '<'.$title.' '.$class.' >';
|
262 |
$params[0]['after_title'] = '</'.$title.'>';
|
263 |
}
|
264 |
}
|
265 |
}
|
266 |
+
|
267 |
+
if (!empty($widget_classes) and ($widget_classes == 'none') ) {
|
268 |
+
$params = amr_remove_widget_class($params); // also called in widget area shortcode
|
269 |
+
}
|
270 |
+
|
271 |
|
272 |
$callback = $wp_registered_widgets[$widget_id]['callback'];
|
273 |
if ( is_callable($callback) ) {
|
289 |
'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.',
|
290 |
'before_widget' => '<aside'.' id="%1$s" class="%2$s ">', // 201402 to match twentyfourteen theme
|
291 |
'after_widget' => '</aside>',
|
292 |
+
'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 the widget styling. ?
|
293 |
'after_title' => '</h1>' );
|
294 |
|
295 |
|
index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
?>
|
readme.txt
CHANGED
@@ -1,14 +1,26 @@
|
|
1 |
=== amr shortcode any widget ===
|
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 |
-
Insert widgets or a widget area into a page
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
1. Test your chosen widget works in a normal sidebar or widget area first.
|
14 |
2. Then Activate this plugin
|
@@ -16,19 +28,41 @@ For more details see [anmari.com](http://webdesign.anmari.com/category/plugins/s
|
|
16 |
4. Drag your chosen widgets from to the shortcodes sidebar. Save.
|
17 |
5. Go the shortcode any widget settings. Click on one of the create page links to help you setup the shortcode.
|
18 |
6. OR go to an existing page and enter a shortcode:
|
|
|
19 |
[do_widget widgetname] eg: [do_widget calendar]
|
20 |
[do_widget "widget name"]. eg: [do_widget "tag cloud"]
|
|
|
|
|
21 |
[do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
|
22 |
-
[do_widget_area sidebarname] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply.
|
23 |
-
|
|
|
|
|
24 |
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.
|
25 |
-
Click on the link 'Try debug'.
|
26 |
-
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
To 'remove debug mode'
|
31 |
-
remove ?do_widget_debug=1 from the url you are looking at (only debugs if you are logged in and an administrator)
|
32 |
|
33 |
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.
|
34 |
|
@@ -41,6 +75,11 @@ If you liked this plugin, you might also like my other plugins:
|
|
41 |
|
42 |
|
43 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
44 |
= Version 2.1 =
|
45 |
* 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.
|
46 |
|
@@ -74,7 +113,7 @@ If you liked this plugin, you might also like my other plugins:
|
|
74 |
= Version 1.3 =
|
75 |
* Added debug link and retested. Added readme.
|
76 |
|
77 |
-
= 1.12=
|
78 |
* 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.
|
79 |
* 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.
|
80 |
|
@@ -99,27 +138,43 @@ Or can use [do_widget widgetname] within the text in the page and save. If the
|
|
99 |
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]
|
100 |
|
101 |
do_widget parameters:
|
102 |
-
title=false to hide a title
|
103 |
-
title= one of h1,h2,h3,h4,h5,strong,em
|
104 |
-
class=yourclassname
|
105 |
-
wrap=one of div, section, p, aside
|
106 |
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
|
113 |
|
114 |
== Screenshots ==
|
115 |
|
116 |
-
1. setting up widgets in
|
117 |
-
2. widgets in a page
|
118 |
-
3.
|
119 |
-
4.
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
125 |
|
1 |
=== amr shortcode any widget ===
|
2 |
Contributors: anmari
|
3 |
+
Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
|
4 |
Tested up to: 3.8.1
|
5 |
+
Version: 2.2
|
6 |
Stable tag: trunk
|
7 |
|
8 |
== Description ==
|
9 |
+
Insert separate widgets or a entire widget area (sidebar) into a page using a shortcode.
|
10 |
+
|
11 |
+
The Widgets settings are specified in a specially created "widgets for shortcode" sidebar, just like you normally setuop a widget.
|
12 |
+
|
13 |
+
The Plugin will call that widget instance from the do_widget shortcode, or the chosen sidebar from the do_widget_area shortcode.
|
14 |
+
|
15 |
+
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/)
|
16 |
+
|
17 |
+
The plugins default action is that it will magically find the settings for your themes first sidebar and use them to control the widget's output. In most cases this would mean that the widget will be styled as per the rest of your theme.
|
18 |
+
|
19 |
+
If that does not look good, parameters exist to override this behaviour.
|
20 |
+
|
21 |
+
Change your theme? 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. Check this still looks nice please! in some themes you may ned up with white text on a white background and will then have to override or change css.
|
22 |
+
|
23 |
+
**Instructions:**
|
24 |
|
25 |
1. Test your chosen widget works in a normal sidebar or widget area first.
|
26 |
2. Then Activate this plugin
|
28 |
4. Drag your chosen widgets from to the shortcodes sidebar. Save.
|
29 |
5. Go the shortcode any widget settings. Click on one of the create page links to help you setup the shortcode.
|
30 |
6. OR go to an existing page and enter a shortcode:
|
31 |
+
|
32 |
[do_widget widgetname] eg: [do_widget calendar]
|
33 |
[do_widget "widget name"]. eg: [do_widget "tag cloud"]
|
34 |
+
[do_widget id=widgetid]
|
35 |
+
|
36 |
[do_widget_area] (will use the "widgets in shortcodes" widget area / sidebar
|
37 |
+
[do_widget_area sidebarname] for another sidebar or widget area - eg: to maximise likelihood of getting your theme's widget css to apply.
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
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.
|
42 |
+
Click on the link 'Try debug'. 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 using 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.
|
43 |
+
|
44 |
+
**[do_widget ...] Parameters:**
|
45 |
|
46 |
+
* *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 bethe first parameter then.
|
47 |
+
* id=*wordpress assigned id of widget*
|
48 |
+
* 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. If not entered plugin will use the same title html that your themes first sidebar uses - yes even if you change themes, it will switch to the new themes html.
|
49 |
+
* wrap=*htmltag* where *htmltag* is one of div,p,main,aside,section. This will override your themes first sidebar html settings for widget wrapping html.
|
50 |
+
* 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 styling from your theme.
|
51 |
+
* class=*yourclassname* By default the plugin will add a class of amr-widget tto 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.
|
52 |
+
* sidebar="*sidebarname*" will default to widgets_for_shortcode sidebar. Only use if you want to re-use a widget already beingused in another sidebar. THis is theme dependent and WILL break if you change themes.
|
53 |
+
|
54 |
+
**[do_widget_area ...] Parameters:**
|
55 |
+
|
56 |
+
* widget_area=*yourwidgetarea* defaults to 'widgets_for_shortcodes' if nothing entered
|
57 |
+
* widget_area_class=none /* option to remove theme styling by removing the widget_area class from the sidebar html */
|
58 |
+
* widget_classes=none /* option to remove the widget class from the widget wrappinghtml
|
59 |
+
* class=*yourclassname* default is amr_widget_area'
|
60 |
+
|
61 |
+
|
62 |
+
See the settings page for links to help your create the shortcodes in a page.
|
63 |
|
64 |
To 'remove debug mode'
|
65 |
+
remove ?do_widget_debug=1 from the url you are looking at (NOTE it only debugs if you are logged in and an administrator, so this is really NOT a problem.)
|
66 |
|
67 |
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.
|
68 |
|
75 |
|
76 |
|
77 |
== Changelog ==
|
78 |
+
= Version 2.2 =
|
79 |
+
* Attempt to add more styling control.
|
80 |
+
* Add widget_classes=none to reverse out widget type class. NOte to totally override wordpress widget
|
81 |
+
* Add widget_area_class=none
|
82 |
+
|
83 |
= Version 2.1 =
|
84 |
* 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.
|
85 |
|
113 |
= Version 1.3 =
|
114 |
* Added debug link and retested. Added readme.
|
115 |
|
116 |
+
= 1.12 =
|
117 |
* 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.
|
118 |
* 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.
|
119 |
|
138 |
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]
|
139 |
|
140 |
do_widget parameters:
|
|
|
|
|
|
|
|
|
141 |
|
142 |
+
* title=false to hide a title
|
143 |
+
* title= one of h1,h2,h3,h4,h5,strong,em
|
144 |
+
* class=yourclassname (else it will add amr_widget)
|
145 |
+
* wrap=one of div, section, p, aside
|
146 |
+
* widget_classes=none (will take the widget class out and the widget-title class out)
|
147 |
+
|
148 |
+
do_widget_area parameters:
|
149 |
+
|
150 |
+
* widget_classes=none (will take the 'widget' class out and the widget-title class out)
|
151 |
+
* widget_area_class=none (will take out the 'widget_area' class )
|
152 |
+
|
153 |
+
**Styling**
|
154 |
+
|
155 |
+
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. It may work beautifully and have the content looking like it belongs with your theme.
|
156 |
You may have undesired effects applying that do not work in the main content area.
|
157 |
You may have desired effects not applying because the css is specific to a themes sidebar.
|
158 |
|
159 |
+
Via the plugin you can do the following to affect styling:
|
160 |
+
* 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]
|
161 |
+
* Hardcode away from your themes html for widgets and widget title. EG: if your theme uses aside and h2, you could specify: [do_widget *widgetname* widget_classes=none wrap=div title=h3]. By default the plugin will use whatever your first sidebar uses. This will change if you change themes, but only if you have NOT overridden the html with wrap and title.
|
162 |
+
* Apply an existing class in your theme. Use [do_widget *widgetname* class=*yourclass*].
|
163 |
+
* Use the addition class 'amr-widget' provided to specify alternate css in your themes stylesheet or with something like wordpress custom css.
|
164 |
+
|
165 |
|
166 |
|
167 |
|
168 |
== Screenshots ==
|
169 |
|
170 |
+
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.
|
171 |
+
2. add shortcode for widgets in a page (must be in the widgets for shortcode sidebar)
|
172 |
+
3. widgets in a page
|
173 |
+
4. with the default widget class and with widget_classes=none
|
174 |
+
two rss feed widgets in shortcode sidebar - both will show if just name used
|
175 |
+
5. Debug messages - scroll down till you see the shortcodes sidebar - the widgets and their ids will be listed. Use the id of the widget you want.
|
176 |
+
6. Examples of a page with several do_widgets: query_posts and tag cloud
|
177 |
+
7. Example of rss widgets in a custom theme
|
178 |
+
|
179 |
+
|
180 |
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.jpg
CHANGED
Binary file
|
screenshot-3.jpg
CHANGED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|
screenshot-6.png
CHANGED
Binary file
|
screenshot-4.jpg → screenshot-7.jpg
RENAMED
File without changes
|
screenshot-7.png
DELETED
Binary file
|
screenshot-8.jpg
DELETED
Binary file
|
screenshot-9.jpg
DELETED
Binary file
|