# easy-elements/1.5.3/includes/Utils/SearchSelect2.php

Easy Elements for Elementor – Addons &amp; Website Templates, version 1.5.3. 111 lines.

- Page: https://pluginprobe.com/plugins/easy-elements/1.5.3/code/includes/Utils/SearchSelect2.php
- Raw: https://pluginprobe.com/plugins/easy-elements/1.5.3/raw/includes/Utils/SearchSelect2.php
- Modified: 2026-07-20T06:16:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-elements/1.5.3/code/includes/Utils/SearchSelect2.php#L10-L20`.

```php
<?php
namespace Easyel\EasyElements\Utils;
/**
 * Elementor autocomplete controls
 */
use Elementor\Base_Data_Control;
use Elementor\Plugin;

if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * Elementor easyel_autocomplete control.
 *
 * @since 1.0.0
 */
class SearchSelect2 extends Base_Data_Control {
	/**
	 * Get easyel_autocomplete control type.
	 *
	 * Retrieve the control type, in this case `easyel_autocomplete`.
	 *
	 * @since  1.0.0
	 * @access public
	 *
	 * @return string Control type.
	 */
	public function get_type() {
		return 'easyel_autocomplete';
	}

	/**
	 * Get easyel_autocomplete control default settings.
	 *
	 * Retrieve the default settings of the easyel_autocomplete control. Used to return the
	 * default settings while initializing the easyel_autocomplete control.
	 *
	 * @since  1.0.0
	 * @access protected
	 *
	 * @return array Control default settings.
	 */
	protected function get_default_settings() {
		return [
			'label_block' => true,
			'multiple'    => false,
			'taxonomy'    => false,
			'post_type'   => false,
			'security'    => wp_create_nonce( 'easyel_autocomplete_nonce' ),
			'options'     => [],
			'callback'    => '',
		];
	}

	/**
	 * Enqueue control scripts and styles.
	 *
	 * @since  1.0.0
	 * @access public
	 */
	public function enqueue() {
		wp_enqueue_script( 'easyel-autocomplete-control', EASYELEMENTS_ASSETS_URL . 'js/easyel-autocomplete.js', [ 'jquery' ], EASYELEMENTS_VER, false );

		wp_localize_script(
            'easyel-autocomplete-control',
            'easyel_custom_select_obj',
            [
                'security' => wp_create_nonce('easyel_autocomplete_nonce'),
                'ajax_url' => admin_url('admin-ajax.php'),
            ]
        );
	}

	/**
	 * Render easyel_autocomplete control output in the editor.
	 *
	 * Used to generate the control HTML in the editor using Underscore JS
	 * template. The variables for the class are available using `data` JS
	 * object.
	 *
	 * @since  1.0.0
	 * @access public
	 */
	public function content_template() {
		$control_uid = $this->get_control_uid();
		?>
		<div class="elementor-control-field">
			<label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{ data.label
				}}}</label>
			<div class="elementor-control-input-wrapper">
				<# var multiple = ( data.multiple ) ? 'multiple' : ''; #>
				<select id="<?php echo esc_attr( $control_uid ); ?>" class="elementor-select2" type="select2" {{ multiple }} data-setting="{{ data.name }}" data-post-type="{{ data.post_type }}" data-taxonomy="{{ data.taxonomy }}" data-placeholder="<?php echo esc_attr__( 'Search', 'easy-elements' ); ?>">
					<# _.each( data.options, function( option_title, option_value ) {
					var value = data.controlValue;
					if ( typeof value == 'string' ) {
						var selected = ( option_value === value ) ? 'selected' : '';
					} else if ( null !== value ) {
						var value = _.values( value );
						var selected = ( -1 !== value.indexOf( option_value ) ) ? 'selected' : '';
					}
					#>
					<option {{ selected }} value="{{ option_value }}">{{{ option_title }}}</option>
					<# } ); #>
				</select>
			</div>
		</div>
		<# if ( data.description ) { #>
		<div class="elementor-control-field-description">{{{ data.description }}}</div>
		<# } #>
		<?php
	}
}
```
