function install_and_activate_wcpay() {$install_request = array('plugins' => self::PLUGIN_SLUG);$installer = new \Automattic\WooCommerce\Admin\API\Plugins();$result = $installer->install_plugins($install_request);If (is_wp_error($result)){返回false;} wc_admin_record_tracks_event('woocommerce_payments_install', array('context' => '));$activate_request = array('plugins' => self::PLUGIN_SLUG);$result = $installer->activate_plugins($activate_request);If (is_wp_error($result)){返回false;}返回true;} /** *安装和激活WooCommerce支付插件,并重定向到安装。 */ public function install_on_action() { // TODO: Need to validate this request more strictly since we're taking install actions directly? /* phpcs:disable WordPress.Security.NonceVerification */ if ( ! isset( $_GET['page'] ) || 'wc-admin' !== $_GET['page'] || ! isset( $_GET['action'] ) || 'setup-woocommerce-payments' !== $_GET['action'] ) { return; } /* phpcs:enable */ if ( ! current_user_can( 'install_plugins' ) ) { return; } $this->install_and_activate_wcpay(); // WooCommerce Payments is installed at this point, so link straight into the onboarding flow. $connect_url = add_query_arg( array( 'wcpay-connect' => '1', '_wpnonce' => wp_create_nonce( 'wcpay-connect' ), ), admin_url() ); wp_safe_redirect( $connect_url ); exit; } }
致命错误:未捕获错误:类的Automattic \ WooCommerce \ Admin \ Notes \ WooCommercePayments”中没有/home/presidiu/public_html / newsite / wp-content /插件/ WooCommerce /包/ woocommerce-admin / src / FeaturePlugin.php: 188堆栈跟踪:# 0 /home/presidiu/public_html / newsite / wp-content /插件/ WooCommerce /包/ woocommerce-admin / src / FeaturePlugin.php (135):Automattic \ WooCommerce \ Admin \ FeaturePlugin - >包括()# 1 /home/presidiu/public_html / newsite wp-content /插件/ WooCommerce /包/ woocommerce-admin / src / FeaturePlugin.php (75):/home/ presidio /public_html/newsite/wp-content/plugins/ WooCommerce /packages/ WooCommerce - Admin /src/Composer/Package.php(77): Automattic\WooCommerce\Admin\FeaturePlugin->init() #3 [internal function]:#4 /home/ presidio /public_html/newsite/wp-content/plugins/ WooCommerce /src/Packages.php(69): call_user_func(Array) #4 /home/ presidio /public_html/newsite/wp-content/plugins/ woocomer .php(69): call_user_func(Array) #5 /home/ presidio /public_html/newsite/wp-content/plugins/ woocomer .php(/home/presidiu/public_html / newsite / wp-content /插件/ woocommerce /包/ woocommerce-admin / src / FeaturePlugin.php在网上188