amr shortcode any widget - Version 3.7

Version Description

Download this release

Release Info

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

Code changes from version 3.6 to 3.7

Files changed (2) hide show
  1. amr-shortcode-any-widget.php +23 -10
  2. readme.txt +8 -2
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 see <a href="https://wordpress.org/plugins/amr-shortcode-any-widget/faq/">FAQ</a>.
6
  Author: anmari
7
- Version: 3.6
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
@@ -92,7 +92,6 @@ global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
92
  if it is in, then get the instance data and use that */
93
 
94
  if (is_admin()) {return '';} // eg in case someone decides to apply content filters when apost is saved, and not all widget stuff is there.
95
-
96
  extract(shortcode_atts(array(
97
  'sidebar' => 'Widgets for Shortcodes', //default
98
  'id' => '',
@@ -113,8 +112,7 @@ if it is in, then get the instance data and use that */
113
 
114
  /* compatibility check - if the name is not entered, then the first parameter is the name */
115
  if (empty($name) and !empty($atts[0]))
116
- $name = $atts[0];
117
-
118
  /* the widget need not be specified, [do_widget widgetname] is adequate */
119
  if (!empty($name)) { // we have a name
120
  $widget = $name;
@@ -211,9 +209,11 @@ if it is in, then get the instance data and use that */
211
  }
212
  }
213
 
214
- return ($output);
215
- }
216
- /* -------------------------------------------------------------------------*/
 
 
217
  function amr_shortcode_sidebar( $widget_id,
218
  $name="widgets_for_shortcode",
219
  $title=true,
@@ -226,7 +226,7 @@ function amr_shortcode_sidebar( $widget_id,
226
 
227
  $sidebarid = amr_get_sidebar_id ($name);
228
 
229
- $sidebars_widgets = wp_get_sidebars_widgets();
230
 
231
  $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
232
 
@@ -322,9 +322,21 @@ function amr_shortcode_sidebar( $widget_id,
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;
328
 
329
  if ( function_exists('register_sidebar') ) { // maybe later, get the first main sidebar and copy it's before/after etc
330
  $args = array(
@@ -347,6 +359,7 @@ if ( function_exists('register_sidebar') ) { // maybe later, get the first mai
347
  }
348
 
349
  register_sidebar($args);
 
350
  }
351
 
352
  //else { echo '<h1>CANNOT REGISTER widgets_for_shortcodes SIDEBAR</h1>';}
@@ -358,6 +371,7 @@ include ('amr-utilities.php');
358
  if (is_admin() ) $amr_saw_plugin_admin = new amr_saw_plugin_admin();
359
 
360
  add_action('widgets_init', 'amr_reg_sidebar',98); // register late so it appears last
 
361
 
362
  add_action('switch_theme', 'amr_save_shortcodes_sidebar');
363
  add_action('after_switch_theme', 'amr_restore_shortcodes_sidebar');
@@ -384,4 +398,3 @@ function amr_add_action_links ( $links ) {
384
  '<a title="Click for a page of tips" href="' . admin_url( 'options-general.php?page=amr_saw' ) . '">HELP</a>';
385
  return array_merge( $links, $mylinks );
386
  }
387
- ?>
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.7
8
  Author URI: http://webdesign.anmari.com
9
 
10
  */
92
  if it is in, then get the instance data and use that */
93
 
94
  if (is_admin()) {return '';} // eg in case someone decides to apply content filters when apost is saved, and not all widget stuff is there.
 
95
  extract(shortcode_atts(array(
96
  'sidebar' => 'Widgets for Shortcodes', //default
97
  'id' => '',
112
 
113
  /* compatibility check - if the name is not entered, then the first parameter is the name */
114
  if (empty($name) and !empty($atts[0]))
115
+ $name = $atts[0];
 
116
  /* the widget need not be specified, [do_widget widgetname] is adequate */
117
  if (!empty($name)) { // we have a name
118
  $widget = $name;
209
  }
210
  }
211
 
212
+ return ($output);
213
+ }
214
+
215
+
216
+
217
  function amr_shortcode_sidebar( $widget_id,
218
  $name="widgets_for_shortcode",
219
  $title=true,
226
 
227
  $sidebarid = amr_get_sidebar_id ($name);
228
 
229
+ $amr_sidebars_widgets = wp_get_sidebars_widgets(); //201711 do we need?
230
 
231
  $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
232
 
322
  return $did_one;
323
  }
324
 
325
+
326
+ function amr_saw_setup_sidebar ($sidebars_widgets) {
327
+ global $sidebars_widgets; //need?
328
+ // now theme mods has record of widgets and sidebar, but not for our new one.
329
+ if ( is_array( $sidebars_widgets ) ) {
330
+ if (empty($sidebars_widgets['widgets_for_shortcodes'])) {
331
+ $sidebars_widgets['widgets_for_shortcodes'] = array();
332
+ }
333
+ }
334
+ return $sidebars_widgets;
335
+ }
336
+
337
  function amr_reg_sidebar() { // this is fired late, so hopefully any theme sidebars will have been registered already.
338
 
339
+ global $wp_registered_widgets, $_wp_sidebars_widgets, $sidebars_widgets, $wp_registered_sidebars;
340
 
341
  if ( function_exists('register_sidebar') ) { // maybe later, get the first main sidebar and copy it's before/after etc
342
  $args = array(
359
  }
360
 
361
  register_sidebar($args);
362
+
363
  }
364
 
365
  //else { echo '<h1>CANNOT REGISTER widgets_for_shortcodes SIDEBAR</h1>';}
371
  if (is_admin() ) $amr_saw_plugin_admin = new amr_saw_plugin_admin();
372
 
373
  add_action('widgets_init', 'amr_reg_sidebar',98); // register late so it appears last
374
+ add_filter( 'theme_mod_sidebars_widgets', 'amr_saw_setup_sidebar' ); //20171126
375
 
376
  add_action('switch_theme', 'amr_save_shortcodes_sidebar');
377
  add_action('after_switch_theme', 'amr_restore_shortcodes_sidebar');
398
  '<a title="Click for a page of tips" href="' . admin_url( 'options-general.php?page=amr_saw' ) . '">HELP</a>';
399
  return array_merge( $links, $mylinks );
400
  }
 
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === amr shortcode any widget ===
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
- Tested up to: 5.0 alpha
5
- Version: 3.6
6
  Stable tag: trunk
7
 
8
  == Description ==
@@ -13,6 +13,8 @@ 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?
@@ -160,6 +162,10 @@ If you only using widget, maybe inserting the whole sidebar or widgertarea would
160
  [do_widget_area]
161
 
162
  == Changelog ==
 
 
 
 
163
  = Version 3.6 =
164
  * Basically forcing an update in the hope that the third party php7compatibility checker sort itself out. It's complaining about mixed line endings, but they're not.
165
  * Added indonesian translation provided by Jordan Silaen.
1
  === amr shortcode any widget ===
2
  Contributors: anmari
3
  Tags: shortcode, widget, page, templates, page template, widget_area, sidebar
4
+ Tested up to: 5.0.3
5
+ Version: 3.7
6
  Stable tag: trunk
7
 
8
  == Description ==
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
+ To use in the block editor, add a shortcode block, then type in (including the square brackets [do_widget widgetname] or copy the do_widget tip from the widget in the 'Widgets for Shortcodes' sidebar.
17
+
18
  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.)
19
 
20
  Using a widget more than once?
162
  [do_widget_area]
163
 
164
  == Changelog ==
165
+ = Version 3.6 =
166
+ * Found a mixed line ending. Updated.
167
+ * Tested on 5.0.3 and 5.1beta, with php 7.3.1
168
+
169
  = Version 3.6 =
170
  * Basically forcing an update in the hope that the third party php7compatibility checker sort itself out. It's complaining about mixed line endings, but they're not.
171
  * Added indonesian translation provided by Jordan Silaen.