Automattic\WooCommerce\Api\Infrastructure

Main::filter_methods_against_settingspublic staticWC 1.0

Apply the GraphQL-scoped site settings to a caller-declared list of HTTP methods.

Centralises the "what verbs does the admin actually allow on a GraphQL endpoint" rule so both WooCommerce core's own endpoint and every sibling plugin endpoint applied through {@see self::register_graphql_endpoint()} honour the same settings.

Currently the only rule is: if the GET endpoint has been disabled in the GraphQL settings section, strip GET from the list.

Метод класса: Main{}

Хуков нет.

Возвращает

Строку[]. Possibly narrowed list — may be empty, in which case the caller should skip the route registration entirely.

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

$result = Main::filter_methods_against_settings( $methods ): array;
$methods(string[]) (обязательный)
HTTP methods the caller declared.

Код Main::filter_methods_against_settings() WC 11.0.1

public static function filter_methods_against_settings( array $methods ): array {
	if ( ! self::is_get_endpoint_enabled() ) {
		$methods = array_values( array_diff( $methods, array( 'GET' ) ) );
	}
	return $methods;
}