Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders
PaymentGateway::get_plugin_file()
Get the plugin file of payment gateway, without the .php extension.
This is useful for the WP API, which expects the plugin file without the .php extension.
Метод класса: PaymentGateway{}
Хуков нет.
Возвращает
Строку
. The plugin file corresponding to the payment gateway plugin. Does not include the .php extension.
Использование
$PaymentGateway = new PaymentGateway(); $PaymentGateway->get_plugin_file( $payment_gateway, $plugin_slug ): string;
- $payment_gateway(WC_Payment_Gateway) (обязательный)
- The payment gateway object.
- $plugin_slug(строка)
- The payment gateway plugin slug to use directly.
По умолчанию: ''
Код PaymentGateway::get_plugin_file() PaymentGateway::get plugin file WC 9.6.1
public function get_plugin_file( WC_Payment_Gateway $payment_gateway, string $plugin_slug = '' ): string { // If the payment gateway object has a `plugin_file` property, use it. // This is useful for testing. if ( isset( $payment_gateway->plugin_file ) ) { $plugin_file = $payment_gateway->plugin_file; // Remove the .php extension from the file path. The WP API expects it without it. if ( ! empty( $plugin_file ) && str_ends_with( $plugin_file, '.php' ) ) { $plugin_file = substr( $plugin_file, 0, - 4 ); } return $plugin_file; } if ( empty( $plugin_slug ) ) { $plugin_slug = $this->get_plugin_slug( $payment_gateway ); } // Bail if we couldn't determine the plugin slug. if ( empty( $plugin_slug ) ) { return ''; } $plugin_file = PluginsHelper::get_plugin_path_from_slug( $plugin_slug ); // Remove the .php extension from the file path. The WP API expects it without it. if ( ! empty( $plugin_file ) && str_ends_with( $plugin_file, '.php' ) ) { $plugin_file = substr( $plugin_file, 0, - 4 ); } return $plugin_file; }