acf_field_select::input_admin_enqueue_scripts()publicACF 5.3.2

input_admin_enqueue_scripts

description

@type    function

{} Это метод класса: acf_field_select{}

Хуков нет.

Возвращает

$post_id. (int)

Использование

$acf_field_select = new acf_field_select();
$acf_field_select->input_admin_enqueue_scripts();

Список изменений

С версии 5.3.2 Введена.

Код acf_field_select::input_admin_enqueue_scripts() ACF 5.10.2

function input_admin_enqueue_scripts() {

	// bail ealry if no enqueue
	if ( ! acf_get_setting( 'enqueue_select2' ) ) {
		return;
	}

	// globals
	global $wp_scripts, $wp_styles;

	// vars
	$min     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	$major   = acf_get_setting( 'select2_version' );
	$version = '';
	$script  = '';
	$style   = '';

	// attempt to find 3rd party Select2 version
	// - avoid including v3 CSS when v4 JS is already enququed
	if ( isset( $wp_scripts->registered['select2'] ) ) {

		$major = (int) $wp_scripts->registered['select2']->ver;

	}

	// v4
	if ( $major == 4 ) {

		$version = '4.0';
		$script  = acf_get_url( "assets/inc/select2/4/select2.full{$min}.js" );
		$style   = acf_get_url( "assets/inc/select2/4/select2{$min}.css" );

		// v3
	} else {

		$version = '3.5.2';
		$script  = acf_get_url( "assets/inc/select2/3/select2{$min}.js" );
		$style   = acf_get_url( 'assets/inc/select2/3/select2.css' );

	}

	// enqueue
	wp_enqueue_script( 'select2', $script, array( 'jquery' ), $version );
	wp_enqueue_style( 'select2', $style, '', $version );

	// localize
	acf_localize_data(
		array(
			'select2L10n' => array(
				'matches_1'            => _x( 'One result is available, press enter to select it.', 'Select2 JS matches_1', 'acf' ),
				'matches_n'            => _x( '%d results are available, use up and down arrow keys to navigate.', 'Select2 JS matches_n', 'acf' ),
				'matches_0'            => _x( 'No matches found', 'Select2 JS matches_0', 'acf' ),
				'input_too_short_1'    => _x( 'Please enter 1 or more characters', 'Select2 JS input_too_short_1', 'acf' ),
				'input_too_short_n'    => _x( 'Please enter %d or more characters', 'Select2 JS input_too_short_n', 'acf' ),
				'input_too_long_1'     => _x( 'Please delete 1 character', 'Select2 JS input_too_long_1', 'acf' ),
				'input_too_long_n'     => _x( 'Please delete %d characters', 'Select2 JS input_too_long_n', 'acf' ),
				'selection_too_long_1' => _x( 'You can only select 1 item', 'Select2 JS selection_too_long_1', 'acf' ),
				'selection_too_long_n' => _x( 'You can only select %d items', 'Select2 JS selection_too_long_n', 'acf' ),
				'load_more'            => _x( 'Loading more results…', 'Select2 JS load_more', 'acf' ),
				'searching'            => _x( 'Searching…', 'Select2 JS searching', 'acf' ),
				'load_fail'            => _x( 'Loading failed', 'Select2 JS load_fail', 'acf' ),
			),
		)
	);
}