<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * CMB taxonomy_multicheck_hierarchical field type
 *
 * @since  2.2.5
 *
 * @category  WordPress_Plugin
 * @package   Storyposts_CMB2
 * @author    Storyposts_CMB2 team
 * @license   GPL-2.0+
 * @link      https://cmb2.io
 *
 * Modified by storyposts on 03-May-2026 using {@see https://github.com/BrianHenryIE/strauss}.
 */
class Storyposts_CMB2_Type_Taxonomy_Multicheck_Hierarchical extends Storyposts_CMB2_Type_Taxonomy_Multicheck {

	/**
	 * Parent term ID when looping hierarchical terms.
	 *
	 * @var integer
	 */
	protected $parent = 0;

	public function render() {
		return $this->rendered(
			$this->types->radio( array(
				'class'   => $this->get_wrapper_classes(),
				'options' => $this->get_term_options(),
			), 'taxonomy_multicheck_hierarchical' )
		);
	}

	protected function list_term_input( $term, $saved_terms ) {
		$options = parent::list_term_input( $term, $saved_terms );
		$children = $this->build_children( $term, $saved_terms );

		if ( ! empty( $children ) ) {
			$options .= $children;
		}

		return $options;
	}

}
