Version Description
Download this release
Release Info
Developer | anmari |
Plugin | amr shortcode any widget |
Version | 2.8 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.8
- amr-shortcode-any-widget.php +14 -6
- amr-utilities.php +39 -18
- readme.txt +10 -5
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: 2.
|
8 |
Author URI: http://webdesign.anmari.com
|
9 |
|
10 |
*/
|
@@ -147,6 +147,7 @@ if it is in, then get the instance data and use that */
|
|
147 |
if ((!isset ($_wp_sidebars_widgets[$sidebarid])) or (empty ($_wp_sidebars_widgets[$sidebarid]))) { // try upgrade
|
148 |
amr_upgrade_sidebar();
|
149 |
}
|
|
|
150 |
|
151 |
if ((isset ($_wp_sidebars_widgets[$sidebarid])) and (!empty ($_wp_sidebars_widgets[$sidebarid]))) {
|
152 |
/* if ($debug) {
|
@@ -168,17 +169,23 @@ if it is in, then get the instance data and use that */
|
|
168 |
*/
|
169 |
}
|
170 |
else { /* the sidebar is not defined */
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
$output = '';
|
177 |
if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
|
178 |
-
|
179 |
echo '<br /><a href="" title="Error: Your requested Widget '.$widget.' is not in the '.$sidebar.' sidebar ">!</a><br />';
|
180 |
amr_show_widget_debug('empty', $atts);
|
181 |
-
|
182 |
unset($sidebar);
|
183 |
unset($sidebarid);
|
184 |
|
@@ -360,4 +367,5 @@ function add_action_links ( $links ) {
|
|
360 |
);
|
361 |
return array_merge( $links, $mylinks );
|
362 |
}
|
|
|
363 |
?>
|
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: 2.8
|
8 |
Author URI: http://webdesign.anmari.com
|
9 |
|
10 |
*/
|
147 |
if ((!isset ($_wp_sidebars_widgets[$sidebarid])) or (empty ($_wp_sidebars_widgets[$sidebarid]))) { // try upgrade
|
148 |
amr_upgrade_sidebar();
|
149 |
}
|
150 |
+
|
151 |
|
152 |
if ((isset ($_wp_sidebars_widgets[$sidebarid])) and (!empty ($_wp_sidebars_widgets[$sidebarid]))) {
|
153 |
/* if ($debug) {
|
169 |
*/
|
170 |
}
|
171 |
else { /* the sidebar is not defined */
|
172 |
+
|
173 |
+
if (isset($debug)) { // only do this in debug mode
|
174 |
+
if (!isset($_wp_sidebars_widgets[$sidebarid]))
|
175 |
+
echo '<br /><a href="" title="Error: Sidebar '.$sidebar.' with sidebarid '.$sidebarid.' is not defined.">!</a><br />';
|
176 |
+
// shouldnt happen - maybe someone running content filters on save
|
177 |
+
else
|
178 |
+
echo '<br /><a href="" title="Error: Sidebar '.$sidebar.' with sidebarid '.$sidebarid.' is empty (no widgets)">!</a><br />';
|
179 |
+
}
|
180 |
+
|
181 |
}
|
182 |
|
183 |
$output = '';
|
184 |
if (empty ($wid) or (!is_array($wid)) or (count($wid) < 1)) {
|
185 |
+
|
186 |
echo '<br /><a href="" title="Error: Your requested Widget '.$widget.' is not in the '.$sidebar.' sidebar ">!</a><br />';
|
187 |
amr_show_widget_debug('empty', $atts);
|
188 |
+
|
189 |
unset($sidebar);
|
190 |
unset($sidebarid);
|
191 |
|
367 |
);
|
368 |
return array_merge( $links, $mylinks );
|
369 |
}
|
370 |
+
|
371 |
?>
|
amr-utilities.php
CHANGED
@@ -25,16 +25,25 @@ global $wp_registered_sidebars;
|
|
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 = esc_url(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;
|
@@ -44,52 +53,64 @@ function amr_check_if_widget_debug() {
|
|
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 |
-
|
55 |
-
|
|
|
|
|
56 |
.'</p>';
|
57 |
|
58 |
if ($debug) {
|
59 |
|
60 |
-
echo '<p>As a last resort, we
|
61 |
$sidebars_widgets = wp_get_sidebars_widgets();
|
62 |
-
|
63 |
foreach ($sidebars_widgets as $i=>$w) {
|
64 |
-
echo '<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 '
|
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 '
|
|
|
85 |
$found = true;
|
86 |
if (is_array($w)) {
|
87 |
sort ($w);
|
88 |
foreach ($w as $i2=> $w2) {
|
89 |
-
echo '
|
90 |
};
|
91 |
}
|
92 |
-
echo '
|
93 |
}
|
94 |
//else {echo ' '.$i;}
|
95 |
};
|
25 |
}
|
26 |
/*-----------------------------------*/
|
27 |
function amr_check_if_widget_debug() {
|
28 |
+
global $said;
|
29 |
// only do these debug if we are logged in and are the administrator
|
30 |
|
31 |
if ((!is_user_logged_in()) or (!current_user_can('administrator')))
|
32 |
return false;
|
33 |
+
|
34 |
+
|
35 |
|
36 |
if (isset($_REQUEST['do_widget_debug'])) {
|
37 |
+
if (empty($said)) {
|
38 |
+
$said = true;
|
39 |
+
}
|
40 |
+
else return true;
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
$url_without_debug_query = esc_url(remove_query_arg( 'do_widget_debug'));
|
45 |
$eek = '<a href="'.$url_without_debug_query.'">Remove debug</a>';
|
46 |
echo '<br/>Note: Debugs only shown to a Logged in Administrator.'
|
|
|
47 |
.$eek
|
48 |
.'<br />';
|
49 |
return true;
|
53 |
}
|
54 |
/*-----------------------------------*/
|
55 |
function amr_show_widget_debug($type='', $atts=array()) {
|
56 |
+
global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
|
57 |
// only do these debug if we are logged in and are the administrator
|
58 |
|
59 |
+
|
60 |
$debug = amr_check_if_widget_debug();
|
61 |
|
62 |
if ($type=='empty') {
|
63 |
+
if (!$debug and current_user_can('administrator'))
|
64 |
+
|
65 |
+
echo '<br/>Problem? Have you read <a title="Detailed help on how to use this plugin" ref="https://wordpress.org/plugins/amr-shortcode-any-widget/installation/">this</a> carefully?<br />';
|
66 |
+
echo '<br /> You are admin: <a href="'.esc_url(add_query_arg('do_widget_debug','1')).'">Click here to try debug </a></b>'
|
67 |
+
.'(or eee a exclamation point ! above ?. Hover over to see error message.)'
|
68 |
.'</p>';
|
69 |
|
70 |
if ($debug) {
|
71 |
|
72 |
+
echo '<p>As a last resort, we will list all sidebars and their widgets, maybe that will help?</p>';
|
73 |
$sidebars_widgets = wp_get_sidebars_widgets();
|
74 |
+
ksort ($sidebars_widgets); // push inactive down the bottom of the list
|
75 |
foreach ($sidebars_widgets as $i=>$w) {
|
76 |
+
echo '<h3>do_widget sidebar='.$i.' ....</h3><table>';
|
77 |
+
echo '<tr><th>Widget name</th><th>Widget id</th>';
|
78 |
+
foreach ($w as $j=>$id) {
|
79 |
+
echo '<tr><td>';
|
80 |
+
if (isset($wp_registered_widgets[$id])) echo $wp_registered_widgets[$id]['name'];
|
81 |
+
|
82 |
+
echo '</td><td> id='.$id.'</td></tr>';
|
83 |
+
}
|
84 |
+
echo '</table>';
|
85 |
+
//var_dump($w);
|
86 |
};
|
87 |
|
88 |
+
//echo '<h3>$_wp_sidebars_widgets:</h3>';
|
89 |
+
//var_dump($_wp_sidebars_widgets);
|
90 |
//echo '<br /><h3>$wp_registered_widgets:</h3>';
|
91 |
//var_dump($wp_registered_widgets);
|
92 |
+
//echo '<br /><h3>$wp_registered_sidebars:</h3>';
|
93 |
+
//var_dump($wp_registered_sidebars);
|
94 |
}
|
95 |
}
|
96 |
|
97 |
if (($type=='which one') and ($debug)) {
|
98 |
+
echo 'DEBUG on: Is your widget in the widgets_for_shortcodes sidebar?<br />';
|
99 |
//echo '<br />The shortcode attributes you entered are:<br />';
|
100 |
//var_dump($atts);
|
|
|
101 |
$found = false;
|
102 |
foreach ($_wp_sidebars_widgets as $i=> $w) {
|
103 |
+
if (($i == "widgets_for_shortcodes") and !empty($w)) {
|
104 |
+
echo 'To access the widgets in '.$i.': <b>'.amr_get_sidebar_name($i).'</b> by id, use these shortcodes:';
|
105 |
+
echo '<div style="border: solid medium green; padding: 40px;" />';
|
106 |
$found = true;
|
107 |
if (is_array($w)) {
|
108 |
sort ($w);
|
109 |
foreach ($w as $i2=> $w2) {
|
110 |
+
echo '<p>[do_widget id='.$w2.'] </p>';
|
111 |
};
|
112 |
}
|
113 |
+
echo '</div>';
|
114 |
}
|
115 |
//else {echo ' '.$i;}
|
116 |
};
|
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.3
|
5 |
-
Version: 2.
|
6 |
Stable tag: trunk
|
7 |
|
8 |
== Description ==
|
@@ -10,6 +10,8 @@ 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. THEN Drag your chosen widgets to the sidebar called "widgets for shortcode".
|
12 |
|
|
|
|
|
13 |
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]
|
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/)
|
@@ -18,7 +20,7 @@ The plugins default action is that it will magically find the settings for your
|
|
18 |
|
19 |
Change your theme and woried 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. 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.
|
20 |
|
21 |
-
|
22 |
|
23 |
== Installation ==
|
24 |
|
@@ -80,6 +82,8 @@ See also [home page](http://wordpress.org/plugins/amr-shortcode-any-widget/)
|
|
80 |
|
81 |
== Frequently Asked Questions ==
|
82 |
|
|
|
|
|
83 |
**Widget help, the widget is doing this, when it should do that**
|
84 |
|
85 |
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. There are 1000's and 1000's of widgets. I cannot help you with all ofthese. Please see
|
@@ -190,9 +194,10 @@ More info on background: http://wordpress.org/support/topic/your-theme-your-side
|
|
190 |
|
191 |
|
192 |
== Changelog ==
|
193 |
-
= Version 2.
|
194 |
-
* Tested on 4.3
|
195 |
-
*
|
|
|
196 |
|
197 |
|
198 |
= Version 2.6 =
|
2 |
Contributors: anmari
|
3 |
Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
|
4 |
Tested up to: 4.3
|
5 |
+
Version: 2.8
|
6 |
Stable tag: trunk
|
7 |
|
8 |
== Description ==
|
10 |
|
11 |
Set up your widget first in a normal sidebar. Check it works. THEN Drag your chosen widgets to the sidebar called "widgets for shortcode".
|
12 |
|
13 |
+
PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and PLEASE read https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ before asking any questions.
|
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/)
|
20 |
|
21 |
Change your theme and woried 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. 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 |
+
|
24 |
|
25 |
== Installation ==
|
26 |
|
82 |
|
83 |
== Frequently Asked Questions ==
|
84 |
|
85 |
+
PLEASE get your widgets working in a sidebar BEFORE activating this plugin, and PLEASE read https://wordpress.org/plugins/amr-shortcode-any-widget/installation/ before asking any questions.
|
86 |
+
|
87 |
**Widget help, the widget is doing this, when it should do that**
|
88 |
|
89 |
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. There are 1000's and 1000's of widgets. I cannot help you with all ofthese. Please see
|
194 |
|
195 |
|
196 |
== Changelog ==
|
197 |
+
= Version 2.8 =
|
198 |
+
* Tested on 4.3.1
|
199 |
+
* No real functional change.
|
200 |
+
* 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.
|
201 |
|
202 |
|
203 |
= Version 2.6 =
|