WC_Product_Variable_Data_Store_CPT::validate_children_dataprotectedWC 1.0

Validate the children data by checking the structure and type of the data.

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

Хуков нет.

Возвращает

true|false. True if valid, false otherwise.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_children_data( $children, $deprecated );
$children(массив) (обязательный)
The children data.
$deprecated(строка) (обязательный)
Was the current transient version, unused since 10.3.0.

Код WC_Product_Variable_Data_Store_CPT::validate_children_data() WC 10.5.2

protected function validate_children_data( $children, $deprecated ) {
	if ( ! is_array( $children ) ) {
		return false;
	}

	// Basic structure checks.
	if ( empty( $children['all'] ) || ! isset( $children['visible'] ) ) {
		return false;
	}

	if ( ! is_array( $children['all'] ) || ! is_array( $children['visible'] ) ) {
		return false;
	}

	foreach ( $children['all'] as $id ) {
		if ( ! is_numeric( $id ) ) {
			return false;
		}
	}

	foreach ( $children['visible'] as $id ) {
		if ( ! is_numeric( $id ) ) {
			return false;
		}
	}

	return true;
}