acf_admin_field_group::ajax_render_field_settings()publicACF 5.0.0

This function will return HTML containing the field's settings based on it's new type

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

Возвращает

null. Ничего (null).

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

$acf_admin_field_group = new acf_admin_field_group();
$acf_admin_field_group->ajax_render_field_settings();

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

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

Код acf_admin_field_group::ajax_render_field_settings() ACF 6.0.4

public function ajax_render_field_settings() {
	// Verify the current request.
	if ( ! acf_verify_ajax() || ! acf_current_user_can_admin() ) {
		wp_send_json_error();
	}

	// Make sure we have a field.
	$field = acf_maybe_get_POST( 'field' );
	if ( ! $field ) {
		wp_send_json_error();
	}

	$field['prefix'] = acf_maybe_get_POST( 'prefix' );
	$field           = acf_get_valid_field( $field );

	$tabs = array(
		'general'           => '',
		'validation'        => '',
		'presentation'      => '',
		'conditional_logic' => '',
	);

	foreach ( $tabs as $tab => $content ) {
		ob_start();

		if ( 'general' === $tab ) {
			// Back-compat for fields not using tab-specific hooks.
			do_action( "acf/render_field_settings/type={$field['type']}", $field );
		}

		do_action( "acf/render_field_{$tab}_settings/type={$field['type']}", $field );

		$sections[ $tab ] = ob_get_clean();
	}

	wp_send_json_success( $sections );
}