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.

Метод класса: 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.

Code of Init::set_gateway_top_of_list() WC 7.1.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;
}