$current_niche, ), array( 'data-loop-product-layout' => ProductCatalogService::get_product_layout(), ) ) ); } } if ( ! function_exists( 'brandy_get_editable_class' ) ) { /** * Returns class for wrapper when in customize mode */ function brandy_get_editable_class( $edit_type = 'section' ) { if ( is_customize_preview() ) { return 'row' === $edit_type ? 'editable-part editable-row-part' : 'editable-part editable-element-part'; } return ''; } } if ( ! function_exists( 'brandy_get_editable_attributes' ) ) { /** * Returns attrubutes for wrapper when in customize mode * * @param string $section_id Section id. */ function brandy_get_editable_attributes( string $section_id ) { return true ? "data-section-id=$section_id" : ''; } } if ( ! function_exists( 'brandy_print_dom_attributes' ) ) { /** * Print DOM element attributes from given array * * @param array $attributes * * @return void */ function brandy_print_dom_attributes( $attributes ) { foreach ( $attributes as $attr_name => $attr_value ) { echo esc_attr( $attr_name ); if ( ! empty( $attr_value ) ) { echo '="' . esc_attr( $attr_value ) . '"'; } } } } if ( ! function_exists( 'brandy_get_devices' ) ) { /** * Returns all device of theme * * @return array */ function brandy_get_devices() { return array( 'desktop', 'tablet', 'mobile' ); } } if ( ! function_exists( 'brandy_enabled_devices_classes' ) ) { /** * Return classes which indicate which device is hidden * * @param array $enabled_devices List enabled devices. * * @return string */ function brandy_enabled_devices_classes( $enabled_devices ) { if ( ! is_array( $enabled_devices ) ) { return ''; } $hidden_devices = array_diff( array( 'desktop', 'mobile' ), $enabled_devices ); $classes = implode( ' ', array_map( function( $device ) { if ( 'mobile' === $device ) { return 'hide-mobile hide-tablet'; } return 'hide-' . $device; }, $hidden_devices ) ); return $classes; } } if ( ! function_exists( 'brandy_render_badge' ) ) { /** * Render Brandy badge * * @param string $number * @param string $attrs * @param string $class * * @return void */ function brandy_render_badge( $number, $attrs = '', $class = '' ) { get_template_part( 'template-parts/common/badge', '', array( 'number' => $number, 'attrs' => $attrs, 'class' => $class, ) ); } } if ( ! function_exists( 'brandy_render_icon' ) ) { /** * Render Brandy icon * * @param string $icon Icon source * @param string $class * @param string $attrs * * @return void */ function brandy_render_icon( $icon, $attrs = array() ) { get_template_part( 'template-parts/common/icon', '', array( 'icon' => $icon, 'attrs' => $attrs, ) ); } } if ( ! class_exists( 'Brandy_Walker_Menu' ) ) { class Brandy_Walker_Menu extends Walker_Nav_Menu { public $menu_settings = null; public $layout = 'horizontal'; public $level_output = array( 'parent' => 'menu_item_parent', 'id' => 'db_id', ); public $max_depth = PHP_INT_MAX; public $sub_menus = array(); public function __construct( $settings, $layout = 'horizontal', $max_depth = PHP_INT_MAX ) { $this->menu_settings = $settings; $this->layout = $layout; $this->max_depth = $max_depth; add_filter( 'wp_nav_menu', array( $this, 'push_submenus' ), 100, 2 ); add_filter( 'wp_page_menu', array( $this, 'push_submenus' ), 100, 2 ); } public function push_submenus( $menu, $args ) { if ( 'vertical' === $this->layout ) { foreach ( array_reverse( $this->sub_menus ) as $sub_menu ) { $menu .= $sub_menu; } } remove_filter( 'wp_nav_menu', array( $this, 'push_submenus' ), 100 ); remove_filter( 'wp_page_menu', array( $this, 'push_submenus' ), 100 ); return $menu; } public function start_lvl( &$output, $depth = 1, $args = null, $element = null ) { if ( 'horizontal' === $this->layout ) { $output .= "\n