HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/link-control.php
<?php

namespace Elementor\Modules\AtomicWidgets\Controls\Types;

use Elementor\Modules\AtomicWidgets\Base\Atomic_Control_Base;
use Elementor\Modules\WpRest\Classes\WP_Post;

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

class Link_Control extends Atomic_Control_Base {
	private bool $allow_custom_values = true;
	private int $minimum_input_length = 2;
	private ?string $placeholder = null;
	private array $query_options = [
		'endpoint' => '',
		'requestParams' => [],
	];

	public static function bind_to( string $prop_name ) {
		$instance = parent::bind_to( $prop_name );
		$instance->set_placeholder( __( 'Paste URL or type', 'elementor' ) );
		$instance->set_endpoint( WP_Post::ENDPOINT );
		$instance->set_request_params( WP_Post::build_query_params( [
			WP_Post::KEYS_FORMAT_MAP_KEY => [
				'ID' => 'id',
				'post_title' => 'label',
				'post_type' => 'groupLabel',
			],
		] ) );

		return $instance;
	}

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

	public function set_placeholder( string $placeholder ): self {
		$this->placeholder = $placeholder;

		return $this;
	}

	public function get_props(): array {
		return [
			'placeholder' => $this->placeholder,
			'allowCustomValues' => $this->allow_custom_values,
			'queryOptions' => $this->query_options,
			'minInputLength' => $this->minimum_input_length,
		];
	}

	public function set_allow_custom_values( bool $allow_custom_values ): self {
		$this->allow_custom_values = $allow_custom_values;

		return $this;
	}

	public function set_endpoint( string $url ): self {
		$this->query_options['endpoint'] = $url;

		return $this;
	}

	public function set_request_params( array $params ): self {
		$this->query_options['requestParams'] = $params;

		return $this;
	}

	public function set_minimum_input_length( int $input_length ): self {
		$this->minimum_input_length = $input_length;

		return $this;
	}
}