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{}

Хуков нет.

Возвращает

Массив. Modified ordering.

Использование

$result = Init::set_gateway_top_of_list( $ordering );
$ordering(массив) (обязательный)
Existing ordering of the payment gateways.

Код Init::set_gateway_top_of_list() 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;
}