WordPress at Your Fingertips
function is not described

WC_Settings_API::get_field_value() public WC 1.0

Get a field's posted and validated value.

{} It's a method of the class: WC_Settings_API{}

No Hooks.

Return

String.

Usage

$WC_Settings_API = new WC_Settings_API();
$WC_Settings_API->get_field_value( $key, $field, $post_data );
$key(string) (required)
Field key.
$field(array) (required)
Field array.
$post_data(array)
Posted data.

Code of WC_Settings_API::get_field_value() WC 5.5.2

<?php
public function get_field_value( $key, $field, $post_data = array() ) {
	$type      = $this->get_field_type( $field );
	$field_key = $this->get_field_key( $key );
	$post_data = empty( $post_data ) ? $_POST : $post_data; // WPCS: CSRF ok, input var ok.
	$value     = isset( $post_data[ $field_key ] ) ? $post_data[ $field_key ] : null;

	if ( isset( $field['sanitize_callback'] ) && is_callable( $field['sanitize_callback'] ) ) {
		return call_user_func( $field['sanitize_callback'], $value );
	}

	// Look for a validate_FIELDID_field method for special handling.
	if ( is_callable( array( $this, 'validate_' . $key . '_field' ) ) ) {
		return $this->{'validate_' . $key . '_field'}( $key, $value );
	}

	// Look for a validate_FIELDTYPE_field method.
	if ( is_callable( array( $this, 'validate_' . $type . '_field' ) ) ) {
		return $this->{'validate_' . $type . '_field'}( $key, $value );
	}

	// Fallback to text.
	return $this->validate_text_field( $key, $value );
}