WC_REST_System_Status_V2_Controller::check_if_field_item_exists()privateWC 3.9.0

Check if field item exists.

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

Хуков нет.

Возвращает

true|false.

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

// private - только в коде основоного (родительского) класса
$result = $this->check_if_field_item_exists( $section, $items, $fields );
$section(строка) (обязательный)
Fields section.
$items(массив) (обязательный)
List of items to check for.
$fields(массив) (обязательный)
List of fields to be included on the response.

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

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

Код WC_REST_System_Status_V2_Controller::check_if_field_item_exists() WC 8.7.0

private function check_if_field_item_exists( $section, $items, $fields ) {
	if ( ! in_array( $section, $fields, true ) ) {
		return false;
	}

	$exclude = array();
	foreach ( $fields as $field ) {
		$values = explode( '.', $field );

		if ( $section !== $values[0] || empty( $values[1] ) ) {
			continue;
		}

		$exclude[] = $values[1];
	}

	return 0 <= count( array_intersect( $items, $exclude ) );
}