| @@ 72-126 (lines=55) @@ | ||
| 69 | return $params; |
|
| 70 | } |
|
| 71 | /*-----------------------------------*/ |
|
| 72 | function shortcodely_do_widget_area($atts) |
|
| 73 | { |
|
| 74 | global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars; |
|
| 75 | ||
| 76 | extract( |
|
| 77 | shortcode_atts( |
|
| 78 | array( |
|
| 79 | 'widget_area' => 'widgets_for_shortcodes', |
|
| 80 | 'class' => 'shortcodely-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 */ |
|
| 81 | 'widget_area_class' => '', /* option to disassociate from themes widget styling use =none*/ |
|
| 82 | 'widget_classes' => '', /* option to disassociate from themes widget styling */ |
|
| 83 | ||
| 84 | ), $atts |
|
| 85 | ) |
|
| 86 | ); |
|
| 87 | ||
| 88 | if (! empty($atts)) { |
|
| 89 | if (('widgets_for_shortcodes' == $widget_area) and ! empty($atts[0])) { |
|
| 90 | $widget_area = $atts[0]; |
|
| 91 | } |
|
| 92 | } |
|
| 93 | ||
| 94 | if (empty($wp_registered_sidebars[$widget_area])) { |
|
| 95 | echo '<br/>Widget area "' . $widget_area . '" not found. Registered widget areas (sidebars) are: <br/>'; |
|
| 96 | foreach ($wp_registered_sidebars as $area => $sidebar) { |
|
| 97 | echo $area . '<br />'; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | //if (isset($_REQUEST['do_widget_debug']) and current_user_can('administrator')) var_dump( $wp_registered_sidebars); /**/ |
|
| 101 | ||
| 102 | if ('none' == $widget_area_class) { |
|
| 103 | $class = ''; |
|
| 104 | } else { |
|
| 105 | if (! empty($widget_area_class)) { //2014 08 |
|
| 106 | $class .= 'class="' . $class . ' ' . $widget_area_class . '"'; |
|
| 107 | } else { |
|
| 108 | $class = 'class="' . $class . '"'; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||
| 112 | if (! empty($widget_classes) and ('none' == $widget_classes)) { |
|
| 113 | add_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class'); |
|
| 114 | } |
|
| 115 | ||
| 116 | ob_start(); /* catch the echo output, so we can control where it appears in the text */ |
|
| 117 | dynamic_sidebar($widget_area); |
|
| 118 | $output = ob_get_clean(); |
|
| 119 | remove_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class'); |
|
| 120 | ||
| 121 | $output = PHP_EOL . '<div id="' . $widget_area . '" ' . $class . '>' |
|
| 122 | . $output |
|
| 123 | . '</div>' . PHP_EOL; |
|
| 124 | ||
| 125 | return $output; |
|
| 126 | } |
|
| 127 | /*-----------------------------------*/ |
|
| 128 | function shortcodely_do_widget($atts) |
|
| 129 | { |
|
| @@ 72-126 (lines=55) @@ | ||
| 69 | return $params; |
|
| 70 | } |
|
| 71 | /*-----------------------------------*/ |
|
| 72 | function shortcodely_do_widget_area($atts) |
|
| 73 | { |
|
| 74 | global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars; |
|
| 75 | ||
| 76 | extract( |
|
| 77 | shortcode_atts( |
|
| 78 | array( |
|
| 79 | 'widget_area' => 'widgets_for_shortcodes', |
|
| 80 | 'class' => 'shortcodely-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 */ |
|
| 81 | 'widget_area_class' => '', /* option to disassociate from themes widget styling use =none*/ |
|
| 82 | 'widget_classes' => '', /* option to disassociate from themes widget styling */ |
|
| 83 | ||
| 84 | ), $atts |
|
| 85 | ) |
|
| 86 | ); |
|
| 87 | ||
| 88 | if (! empty($atts)) { |
|
| 89 | if (('widgets_for_shortcodes' == $widget_area) and ! empty($atts[0])) { |
|
| 90 | $widget_area = $atts[0]; |
|
| 91 | } |
|
| 92 | } |
|
| 93 | ||
| 94 | if (empty($wp_registered_sidebars[$widget_area])) { |
|
| 95 | echo '<br/>Widget area "' . $widget_area . '" not found. Registered widget areas (sidebars) are: <br/>'; |
|
| 96 | foreach ($wp_registered_sidebars as $area => $sidebar) { |
|
| 97 | echo $area . '<br />'; |
|
| 98 | } |
|
| 99 | } |
|
| 100 | //if (isset($_REQUEST['do_widget_debug']) and current_user_can('administrator')) var_dump( $wp_registered_sidebars); /**/ |
|
| 101 | ||
| 102 | if ('none' == $widget_area_class) { |
|
| 103 | $class = ''; |
|
| 104 | } else { |
|
| 105 | if (! empty($widget_area_class)) { //2014 08 |
|
| 106 | $class .= 'class="' . $class . ' ' . $widget_area_class . '"'; |
|
| 107 | } else { |
|
| 108 | $class = 'class="' . $class . '"'; |
|
| 109 | } |
|
| 110 | } |
|
| 111 | ||
| 112 | if (! empty($widget_classes) and ('none' == $widget_classes)) { |
|
| 113 | add_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class'); |
|
| 114 | } |
|
| 115 | ||
| 116 | ob_start(); /* catch the echo output, so we can control where it appears in the text */ |
|
| 117 | dynamic_sidebar($widget_area); |
|
| 118 | $output = ob_get_clean(); |
|
| 119 | remove_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class'); |
|
| 120 | ||
| 121 | $output = PHP_EOL . '<div id="' . $widget_area . '" ' . $class . '>' |
|
| 122 | . $output |
|
| 123 | . '</div>' . PHP_EOL; |
|
| 124 | ||
| 125 | return $output; |
|
| 126 | } |
|
| 127 | /*-----------------------------------*/ |
|
| 128 | function shortcodely_do_widget($atts) |
|
| 129 | { |
|