Automattic\WooCommerce\Admin\Features\Settings
Transformer::handle_group_end
Handle the end of a group.
Метод класса: Transformer{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->handle_group_end( $setting, $transformed_settings ): void;
- $setting(массив) (обязательный)
- Setting to add.
- $transformed_settings(массив) (обязательный)
- Transformed settings array.
Код Transformer::handle_group_end() Transformer::handle group end WC 10.7.0
private function handle_group_end( array $setting, array &$transformed_settings ): void {
$ids_match = $this->current_group &&
isset( $this->current_group[0]['id'] ) &&
isset( $setting['id'] ) &&
$this->current_group[0]['id'] === $setting['id'];
$ids_match_undefined = $this->current_group &&
! isset( $this->current_group[0]['id'] ) &&
! isset( $setting['id'] );
// If IDs match, add the group and close it.
if ( $ids_match || $ids_match_undefined ) {
// Compose the group setting.
$title_setting = array_shift( $this->current_group );
$title_setting['id'] = $title_setting['id'] ?? wp_unique_prefixed_id( 'setting_group' );
$transformed_settings[] = array_merge(
$title_setting,
array(
'type' => 'group',
'settings' => $this->current_group,
)
);
$this->current_group = null;
return;
}
// If IDs don't match, we don't need to transform anything so flush the current group.
$this->flush_current_group( $transformed_settings );
$this->add_setting( $setting, $transformed_settings );
}