Automattic\WooCommerce\Internal\Admin\WCPayPromotion

Init::set_gateway_top_of_list()public 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 WooCommerce Payments to be at the top of the list.

Method of the class: Init{}

No Hooks.

Return

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 8.7.0

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 WooCommerce Payments in it already.
	if ( ! isset( $ordering[ $id ] ) || ! is_numeric( $ordering[ $id ] ) ) {
		$is_empty        = empty( $ordering ) || ( count( $ordering ) === 1 && $ordering[0] === false );
		$ordering[ $id ] = $is_empty ? 0 : ( min( $ordering ) - 1 );
	}
	return $ordering;
}