Example #1
0
 function wma_sidebar($atts = array())
 {
     //Set default setting attributes
     $atts = wp_parse_args($atts, array('attributes' => '', 'class' => 'widget-area', 'max_widgets_count' => 0, 'sidebar' => 'sidebar-1', 'tag' => 'div', 'wrapper' => array('open' => '', 'close' => '')));
     //Helper variables
     $output = '';
     //Validation
     //class
     $atts['class'] = trim('wm-sidebar ' . trim($atts['class']));
     //max_widgets_count
     $atts['max_widgets_count'] = absint($atts['max_widgets_count']);
     //sidebar
     $atts['sidebar'] = trim($atts['sidebar']);
     if (!$atts['sidebar']) {
         $atts['sidebar'] = 'sidebar-1';
     }
     //widgets setup
     $atts['widgets'] = wp_get_sidebars_widgets();
     if (!is_array($atts['widgets'])) {
         $atts['widgets'] = array();
     }
     if (isset($atts['widgets'][$atts['sidebar']])) {
         $atts['widgets'] = $atts['widgets'][$atts['sidebar']];
         $atts['class'] .= ' widgets-count-' . count($atts['widgets']);
     } else {
         $atts['widgets'] = array();
     }
     //wrapper
     if (!is_array($atts['wrapper']) && !isset($atts['wrapper']['open']) && !isset($atts['wrapper']['close'])) {
         $atts['wrapper'] = array('open' => '', 'close' => '');
     }
     //class
     $atts['class'] = apply_filters('wmhook_wmamp_' . 'sidebar_classes', $atts['class']);
     $atts['class'] = apply_filters('wmhook_wmamp_' . 'sidebar_classes_' . $atts['sidebar'], $atts['class']);
     //tag
     if (in_array('sidebar', explode(' ', $atts['class']))) {
         $atts['tag'] = 'aside';
     }
     //Allow filtering the attributes
     $atts = apply_filters('wmhook_wmamp_' . 'sidebar_atts', $atts);
     $atts = apply_filters('wmhook_wmamp_' . 'sidebar_atts_' . $atts['sidebar'], $atts);
     //Preparing output
     if (is_active_sidebar($atts['sidebar']) && (0 === $atts['max_widgets_count'] || $atts['max_widgets_count'] >= count($atts['widgets']))) {
         $output .= $atts['wrapper']['open'];
         if (function_exists('wmhook_sidebars_before')) {
             $output .= wmhook_sidebars_before();
         }
         $output .= "\r\n\r\n" . '<' . tag_escape($atts['tag']) . ' class="' . $atts['class'] . '" data-id="' . $atts['sidebar'] . '" data-widgets-count="' . count($atts['widgets']) . '"' . $atts['attributes'] . '>' . "\r\n";
         //data-id is to prevent double ID attributes on the website
         $output .= apply_filters('wmhook_wmamp_' . 'sidebar_widgets_pre', '', $atts);
         if (function_exists('wmhook_sidebar_top')) {
             $output .= wmhook_sidebar_top();
         }
         if (function_exists('ob_start') && function_exists('ob_get_clean')) {
             ob_start();
             dynamic_sidebar($atts['sidebar']);
             $output .= ob_get_clean();
         }
         if (function_exists('wmhook_sidebar_bottom')) {
             $output .= wmhook_sidebar_bottom();
         }
         $output .= apply_filters('wmhook_wmamp_' . 'sidebar_widgets_post', '', $atts);
         $output .= "\r\n" . '</' . tag_escape($atts['tag']) . '>' . "\r\n\r\n";
         if (function_exists('wmhook_sidebars_after')) {
             $output .= wmhook_sidebars_after();
         }
         $output .= $atts['wrapper']['close'];
     }
     //Output
     $output = apply_filters('wmhook_wmamp_' . 'sidebar', $output, $atts);
     $output = apply_filters('wmhook_wmamp_' . 'sidebar_' . $atts['sidebar'], $output, $atts);
     return apply_filters('wmhook_wmamp_' . 'wma_sidebar' . '_output', $output, $atts);
 }
if (is_active_sidebar($sidebar_id)) {
    dynamic_sidebar($sidebar_id);
} else {
    echo '
							<div class="widget width-1-2" style="width: 48%;">
								<h3 class="widget-heading">About Mustang Lite</h3>
								<div class="widget-content">
									<strong>Mustang Lite</strong> WordPress Theme lets you create beautiful, professional business websites. By default you get the basic blog design which can be extended to full power of the theme with additional <a href="http://wordpress.org/plugins/webman-amplifier/" target="_blank"><strong>WebMan Amplifier</strong> plugin installation</a> (see the <a href="http://themedemos.webmandesign.eu/mustang/">full theme demo website</a>). This theme is a free, lite version of premium <a href="https://creativemarket.com/webmandesign/45467-Mustang-Multipurpose-WordPress-Theme?ref=mustang-lite" target="_blank"><strong>Mustang Multipurpose WordPress Theme</strong> by WebMan</a>. The lite version <strong>does not</strong> support WooCommerce eshop plugin, bbPress forums plugin and also does not contain the premium page builder and sliders plugins included in the paid version. Check out themes by WebMan at <a href="http://www.webmandesign.eu">www.webmandesign.eu</a>. Thank you for using Mustang Lite!<br /><br />
									Theme user manual with demo data can be found at <a href="http://www.webmandesign.eu/manual/mustang/">www.webmandesign.eu/manual/mustang/</a>.
								</div>
							</div>

							<div class="widget">
								<h3 class="widget-heading">Footer Widgets</h3>
								<div class="widget-content">
									To add custom widgets into footer, nagigate to <strong>Appearance &raquo; Widgets</strong> and add widgets into "Footer Widgets" area. <strong>Mustang Lite</strong> supports 4 widgets in the footer by default. <strong>After you install and activate the WebMan Amplifier plugin</strong>, you will get all the power of the theme: masonry footer layout, footer columns setup, "Credits" widget area.
								</div>
							</div>

							<div class="widget">
								<h3 class="widget-heading">WebMan Amplifier Plugin</h3>
								<div class="widget-content">
									The <a href="http://wordpress.org/plugins/webman-amplifier/" target="_blank"><strong>WebMan Amplifier</strong> plugin</a> was built specifically for themes created by WebMan (<a href="http://www.webmandesign.eu">www.webmandesign.eu</a>). This is a premium plugin offered for free via WordPress plugin repository. It extends the power of your theme beyond imagination! <a href="' . admin_url('themes.php?page=' . WM_THEME_SHORTNAME . '-about') . '"><strong>Install the plugin to use full potential of Mustang Lite theme!</strong></a>
								</div>
							</div>
						';
}
echo wmhook_sidebar_bottom();
echo "\r\n" . '</div>' . "\r\n\r\n";
echo wmhook_sidebars_after();
echo '</div></div></div>';