hook_section(); } /** * Hook section in. */ private function hook_section() { $section_priority = apply_filters( 'hestia_section_priority', 20, 'hestia_shop' ); add_action( 'hestia_sections', array( $this, 'do_section' ), absint( $section_priority ) ); add_action( 'hestia_do_shop_section', array( $this, 'render_section' ) ); } /** * Executes the hook on which the content is rendered. */ public function do_section() { do_action( 'hestia_do_shop_section', false ); } /** * Shop section content. * * @since Hestia 1.0 * @modified 1.1.51 * * @param bool $is_shortcode flag used if section is called via a shortcode. */ public function render_section( $is_shortcode = false ) { /** * Don't show section if Disable section is checked or it doesn't have any content. * Show it if it's called as a shortcode. */ $hide_section = get_theme_mod( 'hestia_shop_hide', false ); $section_style = ''; if ( $is_shortcode === false && (bool) $hide_section === true ) { if ( is_customize_preview() ) { $section_style = 'style="display: none"'; } else { return; } } if ( ! class_exists( 'WooCommerce' ) ) { return; } /** * Gather data to display the section. */ if ( current_user_can( 'edit_theme_options' ) ) { /* translators: 1 - link to customizer setting. 2 - 'customizer' */ $hestia_shop_subtitle = get_theme_mod( 'hestia_shop_subtitle', sprintf( __( 'Change this subtitle in %s.', 'hestia' ), sprintf( '%2$s', esc_url( admin_url( 'customize.php?autofocus[control]=hestia_shop_subtitle' ) ), __( 'customizer', 'hestia' ) ) ) ); } else { $hestia_shop_subtitle = get_theme_mod( 'hestia_shop_subtitle' ); } $hestia_shop_title = get_theme_mod( 'hestia_shop_title', esc_html__( 'Products', 'hestia' ) ); /** * In case this function is called as shortcode, we remove the container and we add 'is-shortcode' class. */ $wrapper_class = $is_shortcode === true ? 'is-shortcode' : 'section-gray'; $container_class = $is_shortcode === true ? '' : 'container'; hestia_before_shop_section_trigger(); ?>
>

shop_content(); hestia_bottom_shop_section_content_trigger(); ?>
'; return; } $hestia_shop_items = get_theme_mod( 'hestia_shop_items', 4 ); $args = array( 'post_type' => 'product', ); $args['posts_per_page'] = ! empty( $hestia_shop_items ) ? absint( $hestia_shop_items ) : 4; /* Exclude hidden products from the loop */ $args['tax_query'] = array( array( 'taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => 'exclude-from-catalog', 'operator' => 'NOT IN', ), ); $hestia_shop_categories = get_theme_mod( 'hestia_shop_categories' ); if ( ! empty( $hestia_shop_categories ) ) { array_push( $args['tax_query'], array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $hestia_shop_categories, ) ); } $hestia_shop_order = get_theme_mod( 'hestia_shop_order', 'DESC' ); if ( ! empty( $hestia_shop_order ) ) { $args['order'] = $hestia_shop_order; } $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { $i = 1; echo '
'; while ( $loop->have_posts() ) { $loop->the_post(); global $product; global $post; ?>
get_categories(); } if ( apply_filters( 'hestia_show_category_on_product_card', true ) && ! empty( $product_categories ) ) { /** * Explode categories in words by ',' separator and show only the first 2. If the value is modified to -1 or lower in * a function hooked at hestia_shop_category_words, then show all categories. */ $categories = explode( ',', $product_categories ); $nb_of_cat = apply_filters( 'hestia_shop_category_words', 2 ); $nb_of_cat = intval( $nb_of_cat ); $cat = $nb_of_cat > -1 ? hestia_limit_content( $categories, $nb_of_cat, ',', false ) : $product_categories; $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); echo '
'; echo wp_kses( $cat, $allowed_html ); echo '
'; } ?>

-1 ? hestia_limit_content( $title_in_words, $title_limit, ' ' ) : $title; ?>

post_excerpt ) { /** * Explode the excerpt in words by ' ' separator and show only the first 60 words. If the value is modified to -1 or lower in * a function hooked at hestia_shop_excerpt_words, then use the normal behavior from woocommece ( show post excerpt ) */ $excerpt_in_words = explode( ' ', $post->post_excerpt ); $excerpt_limit = apply_filters( 'hestia_shop_excerpt_words', 60 ); $excerpt_limit = intval( $excerpt_limit ); $limited_excerpt = $excerpt_limit > -1 ? hestia_limit_content( $excerpt_in_words, $excerpt_limit, ' ' ) : $post->post_excerpt; ?>
'; echo '
'; } $i ++; } wp_reset_postdata(); echo '
'; } ?>