'; echo ''; } } /** * pc_default_subcategory_thumbnail * * Render subcategory thumbnail. * * @param string $category * @since 1.0 */ if ( ! function_exists( 'alpus_pc_default_subcategory_thumbnail' ) ) { function alpus_pc_default_subcategory_thumbnail( $category ) { if ( alpus_wc_get_loop_prop( 'show_icon', false ) ) { $icon_class = get_term_meta( $category->term_id, 'product_cat_icon', true ); $icon_class = $icon_class ? $icon_class : 'far fa-heart'; echo ''; } else { $html = ''; $thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' ); $thumbnail_id = get_term_meta( $category->term_id, 'thumbnail_id', true ); $dimensions = false; if ( ! in_array( str_replace( 'woocommerce_', '', $thumbnail_size ), array( 'shop_single', 'single', 'shop_catalog', 'thumbnail', 'shop_thumbnail', 'gallery_thumbnail' ) ) ) { if ( 'full' == $thumbnail_size ) { $dimensions = wp_get_attachment_metadata( $thumbnail_id ); } else { $dimensions = image_get_intermediate_size( $thumbnail_id, $thumbnail_size ); } } if ( ! $dimensions ) { $dimensions = wc_get_image_size( $thumbnail_size ); } if ( $thumbnail_id ) { if ( isset( $dimensions['url'] ) && $dimensions['url'] ) { $image = $dimensions['url']; } else { $image = isset( wp_get_attachment_image_src( $thumbnail_id, $thumbnail_size )[0] ) ? wp_get_attachment_image_src( $thumbnail_id, $thumbnail_size )[0] : ''; } $image_srcset = wp_get_attachment_image_srcset( $thumbnail_id, $thumbnail_size ); $image_meta = wp_get_attachment_metadata( $thumbnail_id ); $image_sizes = wp_get_attachment_image_sizes( $thumbnail_id, $thumbnail_size, $image_meta ); if ( 0 == $dimensions['height'] ) { $full_image_size = wp_get_attachment_image_src( $thumbnail_id, 'full' ); if ( isset( $full_image_size[1] ) && $full_image_size[1] ) { $dimensions['height'] = intval( $dimensions['width'] / absint( $full_image_size[1] ) * absint( $full_image_size[2] ) ); } } // If image's width is smaller than thumbnail size, use real image's size. if ( is_array( $dimensions ) && is_array( $image_meta ) && $dimensions['width'] > $image_meta['width'] ) { $dimensions['width'] = $image_meta['width']; $dimensions['height'] = $image_meta['height']; } } else { $image = wc_placeholder_img_src(); $image_srcset = false; $image_sizes = false; } if ( $image ) { // Prevent esc_url from breaking spaces in urls for image embeds. // Ref: https://core.trac.wordpress.org/ticket/23605. $image = str_replace( ' ', '%20', $image ); // Add responsive image markup if available. if ( $image_srcset && $image_sizes ) { $html = '' . esc_attr( $category->name ) . ''; } else { $html = '' . esc_attr( $category->name ) . ''; } } /** * Filters the html of subcategory thumbnail. * * @since 1.0 */ echo apply_filters( 'alpus_wc_subcategory_thumbnail_html', $html ); } } } /** * pc_default_after_subcategory_thumbnail * * Render html after subcategory thumbnail. * * @param string $category * @since 1.0 */ if ( ! function_exists( 'alpus_pc_default_after_subcategory_thumbnail' ) ) { function alpus_pc_default_after_subcategory_thumbnail( $category ) { $content_origin = alpus_wc_get_loop_prop( 'content_origin' ); echo ''; echo ''; if ( $content_origin ) { echo '
'; } else { echo '
'; } } } /** * pc_default_template_loop_category_title * * Render product category title. * * @param array $category * @since 1.0 */ if ( ! function_exists( 'alpus_pc_default_template_loop_category_title' ) ) { function alpus_pc_default_template_loop_category_title( $category ) { // Title echo '

'; echo ''; echo esc_html( $category->name ); echo ''; echo '

'; // Count if ( alpus_wc_get_loop_prop( 'show_count', true ) ) { echo apply_filters( 'woocommerce_subcategory_count_html', '' . esc_html( $category->count ) . ' ' . esc_html__( 'Products', 'alpus' ) . '', $category ); } // Link if ( alpus_wc_get_loop_prop( 'show_link', true ) ) { $link_text = alpus_wc_get_loop_prop( 'link_text' ); $link_class = 'btn btn-underline btn-link'; echo '' . ( $link_text ? esc_html( $link_text ) : esc_html__( 'Shop Now', 'alpus' ) ) . ''; } } } /** * pc_default_after_subcategory_title * * Render html after subcategory title. * * @since 1.0 */ if ( ! function_exists( 'alpus_pc_default_after_subcategory_title' ) ) { function alpus_pc_default_after_subcategory_title() { echo '
'; } }