acf_field_gallery::ajax_get_attachment()publicACF 5.0.0

ajax_get_attachment

description

Метод класса: acf_field_gallery{}

Хуков нет.

Возвращает

$post_id. (int)

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

$acf_field_gallery = new acf_field_gallery();
$acf_field_gallery->ajax_get_attachment();

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

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

Код acf_field_gallery::ajax_get_attachment() ACF 6.0.4

function ajax_get_attachment() {

	// Validate requrest.
	if ( ! acf_verify_ajax() ) {
		die();
	}

	// Get args.
	$args = acf_request_args(
		array(
			'id'        => 0,
			'field_key' => '',
		)
	);

	// Cast args.
	$args['id'] = (int) $args['id'];

	// Bail early if no id.
	if ( ! $args['id'] ) {
		die();
	}

	// Load field.
	$field = acf_get_field( $args['field_key'] );
	if ( ! $field ) {
		die();
	}

	// Render.
	$this->render_attachment( $args['id'], $field );
	die;
}