Automattic\WooCommerce\Internal\Admin\Notes
WooCommercePayments::install_and_activate_wcpay()
Install and activate WooCommerce Payments.
Method of the class: WooCommercePayments{}
No Hooks.
Return
true|false
. Whether the plugin was successfully activated.
Usage
// private - for code of main (parent) class only $result = $this->install_and_activate_wcpay();
WooCommercePayments::install_and_activate_wcpay() WooCommercePayments::install and activate wcpay code WC 9.5.1
private 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 ) ) { return false; } wc_admin_record_tracks_event( 'woocommerce_payments_install', array( 'context' => 'inbox' ) ); $activate_request = array( 'plugins' => self::PLUGIN_SLUG ); $result = $installer->activate_plugins( $activate_request ); if ( is_wp_error( $result ) ) { return false; } return true; }