<?php
/**
 * UX Builder element shortcode: numbes_value
 *
 * Renders the stats block HTML (Zion-style classes) based on element options.
 */

if ( ! function_exists( 'flatsome_child_numbes_value_shortcode' ) ) {
	function flatsome_child_numbes_value_shortcode( $atts = array() ) {
		$atts = shortcode_atts(
			array(
				'class'   => '',

				'number1' => '100.000.000',
				'text1'   => 'mét vải đã sản xuất',

				'number2' => '20.000+',
				'text2'   => 'đối tác, khách hàng',

				'number3' => '200',
				'text3'   => 'nhân sự',

				'number4' => '10+',
				'text4'   => 'năm kinh nghiệm',
			),
			$atts,
			'numbes_value'
		);

		$uid = function_exists( 'uniqid' ) ? uniqid( 'uid' . wp_rand( 10, 999 ) . '_' ) : 'uid' . wp_rand( 10, 999999 );

		$wrapper_id = $uid . '_wrap';
		$id1         = $uid . '_1';
		$id2         = $uid . '_2';
		$id3         = $uid . '_3';
		$id4         = $uid . '_4';

		$classes = array( 'zb-element', 'zb-el-container' );
		if ( ! empty( $atts['class'] ) ) {
			$classes[] = $atts['class'];
		}

		return
			'<div id="' . esc_attr( $wrapper_id ) . '" class="' . esc_attr( implode( ' ', $classes ) ) . '">' .
				'<div id="' . esc_attr( $uid . '_col3' ) . '" class="zb-column--3 zb-column zb-element zb-el-zionColumn"></div>' .
				'<div id="' . esc_attr( $uid . '_col9' ) . '" class="zb-column--9 zb-column zb-element zb-el-zionColumn">' .
					'<div id="' . esc_attr( $id1 ) . '" class="zb-element zb-el-container ajs__element fadeInUp animated" data-ajs-animation="fadeInUp">' .
						'<p id="' . esc_attr( $uid . '_n1' ) . '" class="linear_gradient zb-element zb-el-zionHeading">' . esc_html( $atts['number1'] ) . '</p>' .
						'<div id="' . esc_attr( $uid . '_t1' ) . '" class="sub-linear_gradient zb-element zb-el-zionText"><h3>' . esc_html( $atts['text1'] ) . '</h3></div>' .
					'</div>' .
					'<div id="' . esc_attr( $uid . '_mid' ) . '" class="zb-element zb-el-container">' .
						'<div id="' . esc_attr( $id2 ) . '" class="zb-element zb-el-container ajs__element fadeInUp animated" data-ajs-animation="fadeInUp">' .
							'<p id="' . esc_attr( $uid . '_n2' ) . '" class="linear_gradient zb-element zb-el-zionHeading">' . esc_html( $atts['number2'] ) . '</p>' .
							'<div id="' . esc_attr( $uid . '_t2' ) . '" class="sub-linear_gradient zb-element zb-el-zionText"><h3>' . esc_html( $atts['text2'] ) . '</h3></div>' .
						'</div>' .
						'<div id="' . esc_attr( $id3 ) . '" class="zb-element zb-el-container ajs__element fadeInUp animated" data-ajs-animation="fadeInUp">' .
							'<p id="' . esc_attr( $uid . '_n3' ) . '" class="linear_gradient zb-element zb-el-zionHeading">' . esc_html( $atts['number3'] ) . '</p>' .
							'<div id="' . esc_attr( $uid . '_t3' ) . '" class="sub-linear_gradient zb-element zb-el-zionText"><h3>' . esc_html( $atts['text3'] ) . '</h3></div>' .
						'</div>' .
					'</div>' .
					'<div id="' . esc_attr( $id4 ) . '" class="zb-element zb-el-container">' .
						'<p id="' . esc_attr( $uid . '_n4' ) . '" class="linear_gradient filter zb-element zb-el-zionHeading">' . esc_html( $atts['number4'] ) . '</p>' .
						'<div id="' . esc_attr( $uid . '_t4' ) . '" class="sub-linear_gradient zb-element zb-el-zionText"><h3>' . esc_html( $atts['text4'] ) . '</h3></div>' .
					'</div>' .
				'</div>' .
			'</div>';
	}

	add_shortcode( 'numbes_value', 'flatsome_child_numbes_value_shortcode' );
}

