$current_niche, ), array( 'data-loop-product-layout' => ProductCatalogService::get_product_layout(), 'data-brandy-blocks-installed' => is_brandy_blocks_installed() ? 'true' : 'false', ) ) ); } } 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 ( ! function_exists( 'brandy_wishlist' ) ) { /** * Render wishlist content template */ function brandy_wishlist( $settings ) { get_template_part( 'template-parts/wishlist/wishlist-drawer', '', array( 'settings' => $settings, ) ); } } if ( ! function_exists( 'brandy_get_rating_html' ) ) { /** * Display product ratings * * @param int $rating Rating for this product (overall or single) * @param int $count Total reviews for this product * @param boolean $only_stars Show only stars or not * @param boolean $total_reviews . */ function brandy_get_rating_html( $product, $rating, $rating_count = 0, $show_only_stars = false, $show_overall = false, $review_count = 0 ) { // if ( empty( $product ) ) { // return; // } brandy_get_template_part( 'template-parts/rating', null, array( // 'product' => $product, 'rating' => $rating, 'rating_count' => $rating_count, 'show_only_stars' => $show_only_stars, 'review_count' => $review_count, 'show_overall' => $show_overall, ) ); } } if ( ! function_exists( 'brandy_get_current_page_id' ) ) { /** * Get current page ID */ function brandy_get_current_page_id() { if ( is_front_page() ) { return get_option( 'page_on_front' ); } elseif ( is_home() ) { return get_option( 'page_for_posts' ); } elseif ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) { return wc_get_page_id( 'shop' ); } else { return get_the_ID(); } } } if ( ! function_exists( 'brandy_render_button_link' ) ) { function brandy_render_button_link( $args ) { $default_args = array( 'text' => __( 'Button', 'brandy' ), 'href' => '#', 'class' => '', ); $args = wp_parse_args( $args, $default_args ); ?> __( 'Button', 'brandy' ), 'href' => '#', 'class' => '', ); $args = wp_parse_args( $args, $default_args ); ?> %s', ! empty( $args['class'] ) ? esc_attr( ' ' . $args['class'] ) : '', esc_attr( ! empty( $args['href'] ) ? ( 'href="' . esc_url( $args['href'] ) . '"' ) : '' ), esc_html( $args['text'] ) ) ?> '; if ( 'next' === $type ) { $icon = ' '; } return apply_filters( 'brandy_swiper_navigation_icon', $icon, $type ); } } if ( ! function_exists( 'brandy_breadcrumb' ) ) { function brandy_breadcrumb( $args = array() ) { if ( is_wc_installed() && function_exists( 'woocommerce_breadcrumb' ) ) { \woocommerce_breadcrumb( $args ); return; } $args = wp_parse_args( $args, apply_filters( 'brandy_breadcrumb_defaults', array( 'delimiter' => ' / ', 'wrap_before' => '', 'before' => '', 'after' => '', 'home' => _x( 'Home', 'breadcrumb', 'brandy' ), ) ) ); $breadcrumbs_instance = new \Brandy\Utils\Breadcrumbs(); if ( ! empty( $args['home'] ) ) { $breadcrumbs_instance->add_crumb( $args['home'], home_url() ); } extract( $args ); $breadcrumb = $breadcrumbs_instance->generate(); include BRANDY_TEMPLATE_DIR . '/woocommerce/global/breadcrumb.php'; } }