HEX
Server: LiteSpeed
System: Linux pulsar191.sitesanctuary.org 5.14.0-284.30.1.el9.tuxcare.els9.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jan 10 17:34:05 UTC 2025 x86_64
User: lgooir (1604)
PHP: 8.1.32
Disabled: exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/lgooir/.trash/elementor/modules/atomic-widgets/controls/types/toggle-control.php
<?php
namespace Elementor\Modules\AtomicWidgets\Controls\Types;

use Elementor\Modules\AtomicWidgets\Base\Atomic_Control_Base;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

class Toggle_Control extends Atomic_Control_Base {
	private array $options = [];
	private bool $full_width = false;
	private string $size = 'tiny';
	private bool $exclusive = true;
	private bool $convert_options = false;

	public function get_type(): string {
		return 'toggle';
	}

	public function add_options( array $control_options ): self {
		$this->options = [];

		foreach ( $control_options as $value => $config ) {
			$this->options[] = [
				'value' => $value,
				'label' => $config['title'] ?? $value,
				'icon' => $config['atomic-icon'] ?? null,
				'showTooltip' => true,
				'exclusive' => false,
			];
		}

		return $this;
	}

	public function set_size( string $size ): self {
		$allowed_sizes = [ 'tiny', 'small', 'medium', 'large' ];

		if ( in_array( $size, $allowed_sizes, true ) ) {
			$this->size = $size;
		}

		return $this;
	}

	public function set_exclusive( bool $exclusive ): self {
		$this->exclusive = $exclusive;

		return $this;
	}

	/**
	 * Whether to convert the v3 options to v4 compatible
	 *
	 * @param bool $convert_options
	 * @return $this
	 */
	public function set_convert_options( bool $convert_options ): self {
		$this->convert_options = $convert_options;

		return $this;
	}

	public function get_props(): array {
		return [
			'options' => $this->options,
			'fullWidth' => $this->full_width,
			'size' => $this->size,
			'exclusive' => $this->exclusive,
			'convertOptions' => $this->convert_options,
		];
	}
}