0 ) { $final_title = self::truncate_text( $final_title, $title_length_limit ); } /* Toggle animation set */ $toggle_rotate_sets = in_array( $toggle_icons_set['set'] ?? null, array( 1, 4, 5, 6, 9, 10, 12 ), true ); ob_start(); ?>
%s', wp_kses_post( $category_list ) ); } /** * Render_excerpt * * @param mixed $excerpt excerpt. * @param mixed $excerpt_limit excerpt limit. * @param mixed $excerpt_length lenght type. * @return Statement */ public static function render_excerpt( $excerpt, $excerpt_limit, $excerpt_length ) { if ( empty( $excerpt ) ) { return ''; } if ( 'limit' === $excerpt_length && ! empty( $excerpt_limit['value'] ) ) { $limit = (int) $excerpt_limit['value']; if ( 'words' === ( $excerpt_limit['unit'] ?? '' ) ) { $excerpt = wp_trim_words( $excerpt, $limit, '...' ); } else { $excerpt = self::truncate_text( wp_strip_all_tags( $excerpt ), $limit ); } } return sprintf( '
%s
', wp_kses_post( $excerpt ) ); } /** * Render_featured_image * * @param mixed $data image data. * @param mixed $link link. * @param mixed $block_name block name. * @return statement */ public static function render_featured_image( $data, $link = '', $block_name = '' ) { $post_id = absint( $data['post_id'] ?? 0 ); $image_alt = $data['image_alt'] ?? ''; $post_title = $data['postTitle'] ?? ''; $link_mode = $data['generalLinkOpen'] ?? ''; if ( ! $post_id ) { return ''; } $thumb_id = get_post_thumbnail_id( $post_id ); if ( 'product-accordion' === $block_name && ! $thumb_id ) { $thumb_id = get_option( 'woocommerce_placeholder_image', 0 ); } if ( ! $thumb_id ) { return ''; } // Image size (fallback to thumbnail). $image_size = $data['image_size'] ?? 'thumbnail'; // Get image src. $image = wp_get_attachment_image_src( $thumb_id, $image_size ); if ( ! $image ) { return ''; } $image_url = $image[0]; // Srcset & sizes (auto generated). $srcset = wp_get_attachment_image_srcset( $thumb_id, $image_size ); $sizes = wp_get_attachment_image_sizes( $thumb_id, $image_size ); // Alt fallback logic. if ( empty( $image_alt ) ) { $image_alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true ); } $image_alt = $image_alt ?? $post_title; // Link handling. $is_real_link = in_array( $link_mode, array( 'current-tab', 'new-tab' ), true ); $tag = $is_real_link ? 'a' : 'div'; ob_start(); ?> < class="sp-eab-featured-image-wrapper" href="" target="" rel="noopener noreferrer" > <?php echo esc_attr( $image_alt ); ?> srcset="" sizes="" loading="lazy" decoding="async" /> > %s ', esc_url( $link ), $open_new_tab ? '_blank' : '_self', esc_html__( 'Read More', 'easy-accordion-free' ) ); } /** * Eab_render_rating stars * * @param mixed $rating rating. * @return statement */ public static function eab_render_stars( $rating = 0 ) { $rating = floatval( $rating ); $full_stars = floor( $rating ); $has_half = ( $rating - $full_stars ) >= 0.5; $empty_stars = 5 - $full_stars - ( $has_half ? 1 : 0 ); ob_start(); ?>
( )
%2$s', esc_attr( $product['type'] ?? 'simple' ), $product['product_price'] ); } /** * Eab_render_quantity_input * * @param mixed $min min quantity. * @return statement */ public static function eab_render_quantity_input( $min = 1 ) { ob_start(); ?>
%2$s', esc_html( $title_tag ), esc_html( $display_title ) ); } /** * Build_image_data * * @param mixed $data post data. * @param mixed $context attrs. * @return array */ private static function build_image_data( $data, $context ) { return array( 'post_id' => $data['post_id'] ?? 0, 'attachment_metadata' => $data['attachment_metadata'] ?? '', 'image_size' => $data['image_size'] ?? 'large', 'image_alt' => $data['image_alt'] ?? '', 'postTitle' => $data['title'] ?? '', 'badge_text' => $data['sale_badge'] ?? '', 'generalLinkOpen' => $context['generalLinkOpen'], 'template' => $context['template'], 'show_badge' => $context['showBadge'], 'show_image' => $context['showFeaturedImage'], ); } /** * Build_product_header_data * * @param mixed $data post data. * @param mixed $context attrs. * @return array */ private static function build_product_header_data( $data, $context ) { return array_merge( $data, array( 'toggleIconsSet' => $context['toggleIconsSet'], 'enableExpandAndCollapseIcon' => $context['enableExpandAndCollapseIcon'], 'toggleIconPosition' => $context['toggleIconPosition'], 'linkOpenNewTab' => $context['linkOpenNewTab'], 'postTitleLenght' => $context['postTitleLenght'], 'postTitleLenghtNumber' => $context['postTitleLenghtNumber'], 'metaDisplayPosition' => $context['metaDisplayPosition'], 'metaDataOptions' => $context['metaDataOptions'], ) ); } /** * Render_product_body * * @param mixed $data product data. * @param mixed $context attrs. * @param mixed $header_data header data. * @return void */ private static function render_product_body( $data, $context, $header_data ) { if ( $context['showRating'] ) { echo self::eab_render_review_data( $data ); // phpcs:ignore } if ( $context['showProductTitle'] && 'product-accordion-two' === $context['template'] ) { echo self::eab_render_product_name( $header_data ); // phpcs:ignore } if ( $context['showPrice'] ) { echo self::eab_render_price_data( $data ); // phpcs:ignore } if ( $context['showExcerpt'] ) { echo self::render_excerpt($data['excerpt'] ?? '',$context['excerptLimit'],$context['excerptLength']); // phpcs:ignore } if ( $context['showAddToCart'] ) { echo self::render_add_to_cart_from_data($data,$context['addToCartLabel'],$context['template']); // phpcs:ignore } } /** * Post_single_item * * @param mixed $data post data. * @param mixed $attributes post attrs. * @return statement */ public static function post_single_item( $data, $attributes ) { $context = Blocks_Query::prepare_post_item_attributes( $attributes ); $image_data = self::build_image_data( $data, $context ); $header_data = self::build_product_header_data( $data, $context ); $post_id = $data['post_id'] ?? 0; $link = $data['link'] ?? ''; $excerpt = $data['excerpt'] ?? ''; $author_url = $data['author_url'] ?? ''; $author = $data['author'] ?? ''; $post_date = $data['post_date'] ?? ''; $category_list = $data['category_list'] ?? ''; $sku = $data['sku'] ?? ''; ob_start(); ?>
< class="sp-eab-accordion-heading sp-d-flex sp-align-center" role="button" tabindex="0"> >
$author_url, 'author' => $author, 'post_date' => $post_date, 'category_list' => $category_list ?? '', 'metaDataOptions' => $attributes['metaDataOptions'] ?? array(), ) ); echo $meta_data; // phpcs:ignore if ( $context['showExcerpt'] ) { echo self::render_excerpt($excerpt, $context['excerptLimit'],$context['excerptLength']); // phpcs:ignore } endif; if ( 'product-accordion' === $context['blockName'] ) { self::render_product_body( $data, $context, $header_data ); } if ( $context['showReadMore'] && 'post-accordion' === $context['blockName'] ) { echo self::render_read_more_button($link, $context['showReadMoreLinkInNewTab']); // phpcs:ignore } ?>