<?php
/**
 * Widget Name: Product Description
 * Description: Outputs the WooCommerce product long description (post content)
 *              for the current product or a chosen product, with an optional
 *              heading, expandable "read more" clamp, drop cap, shortcode
 *              processing, empty-state handling and multiple attractive styles.
 *
 * @package    captain-widgets-kit
 * @subpackage captain-widgets-kit/includes
 * @since      1.4.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;

/**
 * Class Captwiki_Woo_Product_Description
 *
 * @since 1.4.0
 */
class Captwiki_Woo_Product_Description extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * @since 1.4.0
	 * @return string
	 */
	public function get_name(): string {
		return 'captwiki-woo-product-description';
	}

	/**
	 * Get widget title.
	 *
	 * @since 1.4.0
	 * @return string
	 */
	public function get_title(): string {
		return esc_html__( 'Product Description', 'captain-widgets-kit' );
	}

	/**
	 * Get widget icon.
	 *
	 * @since 1.4.0
	 * @return string
	 */
	public function get_icon(): string {
		return 'eicon-product-description captwiki-el-logo';
	}

	/**
	 * Get widget categories.
	 *
	 * @since 1.4.0
	 * @return array
	 */
	public function get_categories(): array {
		return array( 'captwiki-woo-commerce' );
	}

	/**
	 * Get widget keywords.
	 *
	 * @since 1.4.0
	 * @return array
	 */
	public function get_keywords(): array {
		return array( 'woocommerce', 'woo', 'product', 'description', 'content', 'details', 'read more', 'captain-widgets-kit' );
	}

	/**
	 * Disable Elementor's default inner wrapper.
	 *
	 * @since 1.4.0
	 * @return bool
	 */
	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	/**
	 * Available visual styles.
	 *
	 * @since 1.4.0
	 * @return array
	 */
	private function captwiki_style_options(): array {
		return array(
			'style-1' => esc_html__( 'Style 1 – Classic', 'captain-widgets-kit' ),
			'style-2' => esc_html__( 'Style 2 – Boxed Card', 'captain-widgets-kit' ),
			'style-3' => esc_html__( 'Style 3 – Left Accent', 'captain-widgets-kit' ),
			'style-4' => esc_html__( 'Style 4 – Minimal Wide', 'captain-widgets-kit' ),
			'style-5' => esc_html__( 'Style 5 – Soft Gradient', 'captain-widgets-kit' ),
			'style-6' => esc_html__( 'Style 6 – Framed', 'captain-widgets-kit' ),
		);
	}

	/**
	 * Build a list of published products for the source selector.
	 *
	 * @since 1.4.0
	 * @return array
	 */
	private function captwiki_get_products_options(): array {

		$options = array();

		if ( ! function_exists( 'wc_get_products' ) ) {
			return $options;
		}

		$products = wc_get_products(
			array(
				'status'  => 'publish',
				'limit'   => 50,
				'orderby' => 'title',
				'order'   => 'ASC',
				'return'  => 'objects',
			)
		);

		foreach ( $products as $product ) {
			$options[ $product->get_id() ] = $product->get_name();
		}

		return $options;
	}

	/**
	 * Register controls.
	 *
	 * @since 1.4.0
	 */
	protected function register_controls(): void {
		$this->register_content_controls();
		$this->register_title_style_controls();
		$this->register_content_style_controls();
		$this->register_readmore_style_controls();
	}

	/**
	 * Content tab controls.
	 *
	 * @since 1.4.0
	 */
	private function register_content_controls(): void {

		$this->start_controls_section(
			'section_content',
			array(
				'label' => esc_html__( 'Description', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

		$this->add_control(
			'widget_style',
			array(
				'label'   => esc_html__( 'Style', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'style-1',
				'options' => $this->captwiki_style_options(),
			)
		);

		$this->add_control(
			'product_source',
			array(
				'label'   => esc_html__( 'Product', 'captain-widgets-kit' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'current',
				'options' => array(
					'current'  => esc_html__( 'Current Product', 'captain-widgets-kit' ),
					'specific' => esc_html__( 'Select a Product', 'captain-widgets-kit' ),
				),
			)
		);

		$this->add_control(
			'product_id',
			array(
				'label'       => esc_html__( 'Choose Product', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::SELECT2,
				'label_block' => true,
				'options'     => $this->captwiki_get_products_options(),
				'condition'   => array( 'product_source' => 'specific' ),
			)
		);

		$this->add_control(
			'show_title',
			array(
				'label'        => esc_html__( 'Show Heading', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Show', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'Hide', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'no',
			)
		);

		$this->add_control(
			'title_text',
			array(
				'label'       => esc_html__( 'Heading Text', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Description', 'captain-widgets-kit' ),
				'label_block' => true,
				'condition'   => array( 'show_title' => 'yes' ),
			)
		);

		$this->add_control(
			'title_tag',
			array(
				'label'     => esc_html__( 'Heading Tag', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'h3',
				'options'   => array(
					'h2'   => 'H2',
					'h3'   => 'H3',
					'h4'   => 'H4',
					'h5'   => 'H5',
					'div'  => 'div',
					'span' => 'span',
				),
				'condition' => array( 'show_title' => 'yes' ),
			)
		);

		$this->add_control(
			'process_shortcodes',
			array(
				'label'        => esc_html__( 'Render Formatting & Shortcodes', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'Yes', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'No', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'yes',
				'description'  => esc_html__( 'Runs the description through WordPress content filters so blocks, formatting and shortcodes display correctly.', 'captain-widgets-kit' ),
			)
		);

		$this->add_control(
			'drop_cap',
			array(
				'label'        => esc_html__( 'Drop Cap', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'On', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'Off', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
			)
		);

		$this->add_control(
			'enable_readmore',
			array(
				'label'        => esc_html__( 'Expandable (Read More)', 'captain-widgets-kit' ),
				'type'         => Controls_Manager::SWITCHER,
				'label_on'     => esc_html__( 'On', 'captain-widgets-kit' ),
				'label_off'    => esc_html__( 'Off', 'captain-widgets-kit' ),
				'return_value' => 'yes',
				'default'      => 'no',
				'separator'    => 'before',
				'description'  => esc_html__( 'Clamps long descriptions to a fixed height with a toggle button.', 'captain-widgets-kit' ),
			)
		);

		$this->add_responsive_control(
			'collapsed_height',
			array(
				'label'      => esc_html__( 'Collapsed Height', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array( 'px' => array( 'min' => 60, 'max' => 600, 'step' => 10 ) ),
				'default'    => array( 'unit' => 'px', 'size' => 160 ),
				'condition'  => array( 'enable_readmore' => 'yes' ),
			)
		);

		$this->add_control(
			'readmore_text',
			array(
				'label'     => esc_html__( 'Read More Label', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'Read more', 'captain-widgets-kit' ),
				'condition' => array( 'enable_readmore' => 'yes' ),
			)
		);

		$this->add_control(
			'readless_text',
			array(
				'label'     => esc_html__( 'Read Less Label', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::TEXT,
				'default'   => esc_html__( 'Read less', 'captain-widgets-kit' ),
				'condition' => array( 'enable_readmore' => 'yes' ),
			)
		);

		$this->add_control(
			'empty_text',
			array(
				'label'       => esc_html__( 'Empty Fallback', 'captain-widgets-kit' ),
				'type'        => Controls_Manager::TEXTAREA,
				'rows'        => 2,
				'default'     => '',
				'label_block' => true,
				'separator'   => 'before',
				'description' => esc_html__( 'Shown when the product has no description. Leave empty to output nothing on the live site.', 'captain-widgets-kit' ),
			)
		);

		$this->add_responsive_control(
			'text_align',
			array(
				'label'     => esc_html__( 'Alignment', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'left'    => array(
						'title' => esc_html__( 'Left', 'captain-widgets-kit' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'  => array(
						'title' => esc_html__( 'Center', 'captain-widgets-kit' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'   => array(
						'title' => esc_html__( 'Right', 'captain-widgets-kit' ),
						'icon'  => 'eicon-text-align-right',
					),
					'justify' => array(
						'title' => esc_html__( 'Justify', 'captain-widgets-kit' ),
						'icon'  => 'eicon-text-align-justify',
					),
				),
				'default'   => 'left',
				'selectors' => array(
					'{{WRAPPER}} .captwiki-pdesc' => 'text-align: {{VALUE}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Heading style controls.
	 *
	 * @since 1.4.0
	 */
	private function register_title_style_controls(): void {

		$selector = '{{WRAPPER}} .captwiki-pdesc__title';

		$this->start_controls_section(
			'section_title_style',
			array(
				'label'     => esc_html__( 'Heading', 'captain-widgets-kit' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'show_title' => 'yes' ),
			)
		);

		$this->add_control(
			'title_color',
			array(
				'label'     => esc_html__( 'Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$selector => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'title_typography',
				'selector' => $selector,
			)
		);

		$this->add_responsive_control(
			'title_spacing',
			array(
				'label'      => esc_html__( 'Spacing Below', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array( 'px' => array( 'min' => 0, 'max' => 60 ) ),
				'selectors'  => array(
					$selector => 'margin-bottom: {{SIZE}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Content (body) style controls.
	 *
	 * @since 1.4.0
	 */
	private function register_content_style_controls(): void {

		$wrap_selector    = '{{WRAPPER}} .captwiki-pdesc';
		$content_selector = '{{WRAPPER}} .captwiki-pdesc__content';

		$this->start_controls_section(
			'section_content_style',
			array(
				'label' => esc_html__( 'Content', 'captain-widgets-kit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

		$this->add_control(
			'content_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$content_selector                                            => 'color: {{VALUE}};',
					$content_selector . ' p'                                     => 'color: {{VALUE}};',
					$content_selector . ' li'                                    => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'link_color',
			array(
				'label'     => esc_html__( 'Link Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$content_selector . ' a' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'content_typography',
				'selector' => $content_selector . ', ' . $content_selector . ' p, ' . $content_selector . ' li',
			)
		);

		$this->add_control(
			'dropcap_color',
			array(
				'label'     => esc_html__( 'Drop Cap Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'condition' => array( 'drop_cap' => 'yes' ),
				'selectors' => array(
					$content_selector . '.has-dropcap > p:first-of-type::first-letter' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'box_heading',
			array(
				'label'     => esc_html__( 'Box', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_control(
			'box_bg',
			array(
				'label'     => esc_html__( 'Background', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$wrap_selector => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->add_responsive_control(
			'box_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em' ),
				'selectors'  => array(
					$wrap_selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'box_border',
				'selector' => $wrap_selector,
			)
		);

		$this->add_responsive_control(
			'box_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					$wrap_selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'box_shadow',
				'selector' => $wrap_selector,
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Read more button style controls.
	 *
	 * @since 1.4.0
	 */
	private function register_readmore_style_controls(): void {

		$selector = '{{WRAPPER}} .captwiki-pdesc__toggle';

		$this->start_controls_section(
			'section_readmore_style',
			array(
				'label'     => esc_html__( 'Read More Button', 'captain-widgets-kit' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'enable_readmore' => 'yes' ),
			)
		);

		$this->start_controls_tabs( 'readmore_tabs' );

		$this->start_controls_tab(
			'readmore_tab_normal',
			array( 'label' => esc_html__( 'Normal', 'captain-widgets-kit' ) )
		);

		$this->add_control(
			'readmore_color',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$selector => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'readmore_bg',
			array(
				'label'     => esc_html__( 'Background', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$selector => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'readmore_tab_hover',
			array( 'label' => esc_html__( 'Hover', 'captain-widgets-kit' ) )
		);

		$this->add_control(
			'readmore_color_hover',
			array(
				'label'     => esc_html__( 'Text Color', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$selector . ':hover' => 'color: {{VALUE}};',
				),
			)
		);

		$this->add_control(
			'readmore_bg_hover',
			array(
				'label'     => esc_html__( 'Background', 'captain-widgets-kit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					$selector . ':hover' => 'background-color: {{VALUE}};',
				),
			)
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'      => 'readmore_typography',
				'selector'  => $selector,
				'separator' => 'before',
			)
		);

		$this->add_responsive_control(
			'readmore_padding',
			array(
				'label'      => esc_html__( 'Padding', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', 'em' ),
				'selectors'  => array(
					$selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->add_responsive_control(
			'readmore_radius',
			array(
				'label'      => esc_html__( 'Border Radius', 'captain-widgets-kit' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					$selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);

		$this->end_controls_section();
	}

	/**
	 * Resolve the product.
	 *
	 * @since 1.4.0
	 * @param array $settings Widget settings.
	 * @return \WC_Product|false
	 */
	private function captwiki_resolve_product( array $settings ) {

		$source = ! empty( $settings['product_source'] ) ? $settings['product_source'] : 'current';

		if ( 'specific' === $source && ! empty( $settings['product_id'] ) ) {
			return wc_get_product( absint( $settings['product_id'] ) );
		}

		$product = wc_get_product( get_the_ID() );

		if ( $product ) {
			return $product;
		}

		if ( \Elementor\Plugin::$instance->editor->is_edit_mode() || \Elementor\Plugin::$instance->preview->is_preview_mode() ) {
			$latest = wc_get_products(
				array(
					'status' => 'publish',
					'limit'  => 1,
				)
			);

			if ( ! empty( $latest ) ) {
				return $latest[0];
			}
		}

		return false;
	}

	/**
	 * Output an editor-only notice.
	 *
	 * @since 1.4.0
	 * @param string $message Notice text.
	 */
	private function captwiki_render_editor_notice( string $message ): void {

		if ( ! \Elementor\Plugin::$instance->editor->is_edit_mode() ) {
			return;
		}

		echo '<div class="captwiki-pdesc captwiki-pdesc--notice"><p>' . esc_html( $message ) . '</p></div>';
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * @since 1.4.0
	 */
	protected function render(): void {

		if ( ! class_exists( 'WooCommerce' ) || ! function_exists( 'wc_get_product' ) ) {
			$this->captwiki_render_editor_notice( esc_html__( 'WooCommerce is required for the Product Description widget.', 'captain-widgets-kit' ) );
			return;
		}

		$settings = $this->get_settings_for_display();
		$product  = $this->captwiki_resolve_product( $settings );

		if ( ! $product instanceof \WC_Product ) {
			$this->captwiki_render_editor_notice( esc_html__( 'No product found. Place this widget on a product template or select a product.', 'captain-widgets-kit' ) );
			return;
		}

		$raw = $product->get_description();

		if ( '' === trim( (string) $raw ) ) {
			$fallback = isset( $settings['empty_text'] ) ? trim( (string) $settings['empty_text'] ) : '';

			if ( '' === $fallback ) {
				$this->captwiki_render_editor_notice( esc_html__( 'This product has no description (nothing is shown on the live site).', 'captain-widgets-kit' ) );
				return;
			}

			$raw = $fallback;
		}

		$process = ! empty( $settings['process_shortcodes'] ) && 'yes' === $settings['process_shortcodes'];
		$content = $process ? apply_filters( 'the_content', $raw ) : wpautop( wp_kses_post( $raw ) );

		$allowed_styles = array_keys( $this->captwiki_style_options() );
		$style          = ! empty( $settings['widget_style'] ) && in_array( $settings['widget_style'], $allowed_styles, true ) ? $settings['widget_style'] : 'style-1';

		wp_enqueue_style(
			'captwiki-woo-product-description-' . $style,
			CAPTWIKI_URL . 'assets/css/widgets/woo-product-description/captwiki-woo-product-description-' . $style . '.css',
			array( 'captwiki-woo-product-description' ),
			CAPTWIKI_VERSION
		);

		$enable_more = ! empty( $settings['enable_readmore'] ) && 'yes' === $settings['enable_readmore'];
		$drop_cap    = ! empty( $settings['drop_cap'] ) && 'yes' === $settings['drop_cap'];

		if ( $enable_more ) {
			wp_enqueue_script( 'captwiki-woo-product-description' );
		}

		$collapsed = 160;
		if ( ! empty( $settings['collapsed_height']['size'] ) ) {
			$collapsed = absint( $settings['collapsed_height']['size'] );
		}

		$wrapper_classes = array(
			'captwiki-pdesc',
			'captwiki-' . $style,
			'captwiki-widget-' . $this->get_id(),
		);

		if ( $enable_more ) {
			$wrapper_classes[] = 'captwiki-pdesc--expandable';
		}

		$content_classes = array( 'captwiki-pdesc__content' );
		if ( $drop_cap ) {
			$content_classes[] = 'has-dropcap';
		}

		$wrapper_attr = '';
		if ( $enable_more ) {
			$wrapper_attr = ' data-collapsed-height="' . esc_attr( (string) $collapsed ) . '"';
		}

		echo '<div class="' . esc_attr( implode( ' ', $wrapper_classes ) ) . '"' . $wrapper_attr . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

		if ( ! empty( $settings['show_title'] ) && 'yes' === $settings['show_title'] && ! empty( $settings['title_text'] ) ) {
			$tag         = ! empty( $settings['title_tag'] ) ? $settings['title_tag'] : 'h3';
			$allowed_tag = array( 'h2', 'h3', 'h4', 'h5', 'div', 'span' );
			$tag         = in_array( $tag, $allowed_tag, true ) ? $tag : 'h3';

			echo '<' . esc_attr( $tag ) . ' class="captwiki-pdesc__title">' . esc_html( $settings['title_text'] ) . '</' . esc_attr( $tag ) . '>';
		}

		echo '<div class="' . esc_attr( implode( ' ', $content_classes ) ) . '">' . wp_kses_post( $content ) . '</div>';

		if ( $enable_more ) {
			$more = ! empty( $settings['readmore_text'] ) ? $settings['readmore_text'] : esc_html__( 'Read more', 'captain-widgets-kit' );
			$less = ! empty( $settings['readless_text'] ) ? $settings['readless_text'] : esc_html__( 'Read less', 'captain-widgets-kit' );

			echo '<button type="button" class="captwiki-pdesc__toggle" data-more="' . esc_attr( $more ) . '" data-less="' . esc_attr( $less ) . '">' . esc_html( $more ) . '</button>';
		}

		echo '</div>';
	}
}
