Beispiel #1
0
 function wm_sidebar_setup($return = false, $atts = array())
 {
     //Helper variables
     $output = apply_filters('wmhook_wm_sidebar_setup_output_defaults', array('class_main' => ' twelve pane', 'class_sidebar' => '', 'output' => '', 'position' => 'none'));
     //Requirements check
     if (!function_exists('wma_sidebar')) {
         if (!$return) {
             return $output;
         } else {
             if (isset($output[$return])) {
                 return $output[$return];
             } else {
                 return;
             }
         }
     }
     $defaults = array('page_id' => null, 'position' => wm_option('skin-sidebar-position') ? wm_option('skin-sidebar-position') : WM_DEFAULT_SIDEBAR_POSITION);
     $sidebar_none_posts = apply_filters('wmhook_sidebar_none_posts', array('wm_projects', 'page'));
     if (is_archive() && apply_filters('wmhook_archive_disable_sidebar', false) || is_singular($sidebar_none_posts) && !is_page_template('home.php')) {
         $defaults['position'] = 'none';
     }
     $defaults = apply_filters('wmhook_wm_sidebar_setup_defaults', $defaults);
     $atts = wp_parse_args($atts, $defaults);
     if ((is_home() || is_singular() || class_exists('WooCommerce') && is_shop()) && function_exists('wma_meta_option') && wma_meta_option('sidebar', $atts['page_id'])) {
         $atts['position'] = wma_meta_option('sidebar', $atts['page_id']);
     }
     if (is_singular() && 'sections' == wma_meta_option('sidebar', $atts['page_id'])) {
         $defaults['position'] = 'none';
     }
     $atts = apply_filters('wmhook_wm_sidebar_setup_atts', $atts);
     //Preparing output
     if ('none' !== $atts['position']) {
         $classes = wm_option('skin-sidebar-width') ? wm_option('skin-sidebar-width') : WM_DEFAULT_SIDEBAR_WIDTH;
         //First array value is for sidebar width, the second for content width
         $classes = explode(';', $classes);
         if (isset($classes[0])) {
             $output['class_sidebar'] = $classes[0];
         }
         if (isset($classes[1])) {
             if ('left' === $atts['position']) {
                 $classes[1] .= ' sidebar-left';
             }
             $output['class_main'] = $classes[1];
         }
     }
     $output['position'] = $atts['position'];
     //Actuall sidebar HTML output
     if ('none' !== $output['position']) {
         $output['output'] = wma_sidebar(apply_filters('wmhook_wm_sidebar_setup_sidebar_atts', array('attributes' => ' role="complementary"', 'class' => 'sidebar widget-area clearfix sidebar-' . esc_attr($output['position'] . $output['class_sidebar']), 'sidebar' => 'general'), $atts));
     }
     //If no sidebar to output, set fullwidth layout
     if (!$output['output']) {
         $output = array('class_main' => ' twelve pane', 'class_sidebar' => '', 'output' => '', 'position' => 'none');
     }
     //Output
     $output = apply_filters('wmhook_wm_sidebar_setup_output', $output, $atts);
     if (!$return) {
         return $output;
     } else {
         if (isset($output[$return])) {
             return $output[$return];
         } else {
             return;
         }
     }
 }
Beispiel #2
0
<?php

/**
 * Widget area
 *
 * This file is being included into "../class-shortcodes.php" file's shortcode_render() method.
 *
 * @since    1.0
 * @version  1.1.6
 *
 * @param  string area
 * @param  string class
 * @param  integer max_widgets_count
 */
//Shortcode attributes
$defaults = apply_filters('wmhook_shortcode_' . '_defaults', array('area' => '', 'class' => '', 'max_widgets_count' => 0), $shortcode);
$atts = apply_filters('wmhook_shortcode_' . '_attributes', $atts, $shortcode);
$atts = shortcode_atts($defaults, $atts, $prefix_shortcode . $shortcode);
//Validation
//class
$atts['class'] = trim('clearfix ' . $atts['class']);
$atts['class'] = apply_filters('wmhook_shortcode_' . $shortcode . '_classes', $atts['class'], $atts);
//Output
if (function_exists('wma_sidebar')) {
    $output = wma_sidebar(array('class' => esc_attr($atts['class']), 'max_widgets_count' => absint($atts['max_widgets_count']), 'sidebar' => trim($atts['area'])));
}
Beispiel #3
0
 function wm_wc_floating_cart($return = false)
 {
     //Requirements check
     if (apply_filters('wmhook_wm_wc_floating_cart_disable', false)) {
         return;
     }
     //Helper variables
     $output = $widget_area = array();
     $widget_area_atts = apply_filters('wmhook_wm_wc_floating_cart_widget_area_atts', array('max_widgets_count' => 2, 'sidebar' => 'floating-cart'));
     if (function_exists('wma_sidebar')) {
         $widget_area = wma_sidebar($widget_area_atts);
     }
     if (empty($widget_area)) {
         return;
     }
     //Preparing output
     $output[10] = "\r\n\r\n" . '<div id="floating-cart" class="floating-cart">';
     $output[20] = '<a href="' . get_permalink(wc_get_page_id('cart')) . '" id="floating-cart-switch" class="floating-cart-switch"><span class="screen-reader-text">' . __('Show cart', 'mustang') . '</span></a>';
     $output[30] = '<div id="floating-cart-content" class="floating-cart-content woocommerce-page">';
     //.woocommerce-page is here to inherit WC styles when not on WC page
     $output[40] = $widget_area;
     $output[50] = '</div>';
     $output[60] = "\r\n" . '</div>' . "\r\n";
     //Output
     $output = apply_filters('wmhook_wm_wc_floating_cart_output', $output);
     if (!$return) {
         echo implode('', $output);
     } else {
         return implode('', $output);
     }
 }