File "Settings_Section.php"

Full Path: /home/romayxjt/public_html/wp-content/plugins/the-events-calendar/common/src/Common/Admin/Settings_Section.php
File size: 1.32 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * Settings_Section.
 *
 * @since 6.1.0
 */

declare( strict_types=1 );

namespace TEC\Common\Admin;

use TEC\Common\Admin\Entities\Element;

/**
 * Class Settings_Section
 *
 * @since 6.1.0
 */
class Settings_Section extends Section {

	/**
	 * Elements for the section.
	 *
	 * @var Element[]
	 */
	protected array $elements = [];

	/**
	 * Add an element to the section.
	 *
	 * @since 6.1.0
	 *
	 * @param Element $element The element to add.
	 *
	 * @return static
	 */
	public function add_element( Element $element ) {
		$this->elements[] = $element;

		return $this;
	}

	/**
	 * Add multiple elements to the section.
	 *
	 * @since 6.1.0
	 *
	 * @param Element[] $elements The elements to add.
	 *
	 * @return static
	 */
	public function add_elements( array $elements ) {
		foreach ( $elements as $element ) {
			$this->add_element( $element );
		}

		return $this;
	}

	/**
	 * Render the section content.
	 *
	 * @since 6.1.0
	 *
	 * @return void
	 */
	public function render() {
		?>
		<div class="tribe-settings-section">
			<?php $this->render_title(); ?>
			<?php $this->render_elements(); ?>
		</div>
		<?php
	}

	/**
	 * Render the elements for the section.
	 *
	 * @since 6.1.0
	 *
	 * @return void
	 */
	protected function render_elements() {
		foreach ( $this->elements as $element ) {
			$element->render();
		}
	}
}