Automattic\WooCommerce\Internal\Admin\WCPayPromotion

Init::set_gateway_top_of_listpublic staticWC 1.0

By default, new payment gateways are put at the bottom of the list on the admin "Payments" settings screen. For visibility, we want WooPayments to be at the top of the list.

Method of the class: Init{}

No Hooks.

Returns

Array. Modified ordering.

Usage

$result = Init::set_gateway_top_of_list( $ordering );
$ordering(array) (required)
Existing ordering of the payment gateways.

Init::set_gateway_top_of_list() code WC 10.3.6

public static function set_gateway_top_of_list( $ordering ) {
	$ordering = (array) $ordering;
	$id       = WCPaymentGatewayPreInstallWCPayPromotion::GATEWAY_ID;
	// Only tweak the ordering if the list hasn't been reordered with WooPayments in it already.
	if ( ! isset( $ordering[ $id ] ) || ! is_numeric( $ordering[ $id ] ) ) {
		$is_empty        = empty( $ordering ) || ( count( $ordering ) === 1 && in_array( $ordering[0], array( false, '' ) ) );
		$ordering[ $id ] = $is_empty ? 0 : ( min( array_map( 'intval', $ordering ) ) - 1 );
	}

	return $ordering;
}