Automattic\WooCommerce\Internal\Admin\Settings
Utils::order_map_apply_mappings()
Apply order mappings to a base order map.
Метод класса: Utils{}
Хуков нет.
Возвращает
Массив
. The updated base order map, normalized.
Использование
$result = Utils::order_map_apply_mappings( $base_map, $new_mappings ): array;
- $base_map(массив) (обязательный)
- The base order map.
- $new_mappings(массив) (обязательный)
- The order mappings to apply. This can be a full or partial list of the base one, but it can also contain (only) new IDs and their orders.
Код Utils::order_map_apply_mappings() Utils::order map apply mappings WC 9.6.1
public static function order_map_apply_mappings( array $base_map, array $new_mappings ): array { // Make sure the base map is sorted ascending by their order values. // We don't normalize first because the order values have meaning. asort( $base_map ); $updated_map = $base_map; // Apply the new mappings in the order they were given. foreach ( $new_mappings as $id => $order ) { // If the ID is not in the base map, we ADD it at the desired order. Otherwise, we MOVE it. if ( ! isset( $base_map[ $id ] ) ) { $updated_map = self::order_map_add_at_order( $updated_map, $id, $order ); continue; } $updated_map = self::order_map_move_at_order( $updated_map, $id, $order ); } return self::order_map_normalize( $updated_map ); }