Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders
PaymentGateway::get_plugin_slug()
Get the source plugin slug of a payment gateway instance.
Метод класса: PaymentGateway{}
Хуков нет.
Возвращает
Строку
. The plugin slug of the payment gateway.
Использование
$PaymentGateway = new PaymentGateway(); $PaymentGateway->get_plugin_slug( $payment_gateway ): string;
- $payment_gateway(WC_Payment_Gateway) (обязательный)
- The payment gateway object.
Код PaymentGateway::get_plugin_slug() PaymentGateway::get plugin slug WC 9.6.0
public function get_plugin_slug( WC_Payment_Gateway $payment_gateway ): string { // If the payment gateway object has a `plugin_slug` property, use it. // This is useful for testing. if ( isset( $payment_gateway->plugin_slug ) ) { return $payment_gateway->plugin_slug; } try { $reflector = new \ReflectionClass( get_class( $payment_gateway ) ); } catch ( \ReflectionException $e ) { // Bail if we can't get the class details. return ''; } $gateway_class_filename = $reflector->getFileName(); // Determine the gateway's plugin directory from the class path. $gateway_class_path = trim( dirname( plugin_basename( $gateway_class_filename ) ), DIRECTORY_SEPARATOR ); if ( false === strpos( $gateway_class_path, DIRECTORY_SEPARATOR ) ) { // The gateway class file is in the root of the plugin's directory. $plugin_slug = $gateway_class_path; } else { $plugin_slug = explode( DIRECTORY_SEPARATOR, $gateway_class_path )[0]; } return $plugin_slug; }