WC_Brands::output_product_brand()
Displays product brand.
Метод класса: WC_Brands{}
Хуков нет.
Возвращает
Строку
. The generated output.
Использование
$WC_Brands = new WC_Brands(); $WC_Brands->output_product_brand( $atts );
- $atts(массив) (обязательный)
- Attributes from the shortcode.
Код WC_Brands::output_product_brand() WC Brands::output product brand WC 9.4.2
public function output_product_brand( $atts ) { global $post; $args = shortcode_atts( array( 'width' => '', 'height' => '', 'class' => 'aligncenter', 'post_id' => '', ), $atts ); if ( ! $args['post_id'] && ! $post ) { return ''; } if ( ! $args['post_id'] ) { $args['post_id'] = $post->ID; } $brands = wp_get_post_terms( $args['post_id'], 'product_brand', array( 'fields' => 'ids' ) ); // Bail early if we don't have any brands registered. if ( 0 === count( $brands ) ) { return ''; } ob_start(); foreach ( $brands as $brand ) { $thumbnail = wc_get_brand_thumbnail_url( $brand ); if ( empty( $thumbnail ) ) { continue; } $args['thumbnail'] = $thumbnail; $args['term'] = get_term_by( 'id', $brand, 'product_brand' ); if ( $args['width'] || $args['height'] ) { $args['width'] = ! empty( $args['width'] ) ? $args['width'] : 'auto'; $args['height'] = ! empty( $args['height'] ) ? $args['height'] : 'auto'; } wc_get_template( 'shortcodes/single-brand.php', $args, 'woocommerce', WC()->plugin_path() . '/templates/brands/' ); } return ob_get_clean(); }