* Restore FB extension to installation whitelist.

Errantly removed in fe585aa2.

* Fix FB extension installation from inbox.

APIs have diverged.
This commit is contained in:
Jeff Stieler 2019-10-08 12:32:44 -07:00 committed by GitHub
parent 431e465893
commit ba28e41ee5
2 changed files with 8 additions and 4 deletions

View File

@ -383,6 +383,7 @@ class Onboarding {
return apply_filters(
'woocommerce_onboarding_plugins_whitelist',
array(
'facebook-for-woocommerce' => 'facebook-for-woocommerce/facebook-for-woocommerce.php',
'jetpack' => 'jetpack/jetpack.php',
'woocommerce-services' => 'woocommerce-services/woocommerce-services.php',
'woocommerce-gateway-stripe' => 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php',

View File

@ -81,19 +81,22 @@ class WC_Admin_Notes_Facebook_Extension {
/**
* Install Facebook extension when note is actioned.
*
* @param WC_Admin_Note $note Note being acted upon.
*/
public function install_facebook_extension( $note ) {
if ( self::NOTE_NAME === $note->get_name() ) {
$plugin = array( 'plugin' => 'facebook-for-woocommerce' );
$install_request = array( 'plugin' => 'facebook-for-woocommerce' );
$installer = new \Automattic\WooCommerce\Admin\API\OnboardingPlugins();
$result = $installer->install_plugin( $plugin );
$result = $installer->install_plugin( $install_request );
if ( is_wp_error( $result ) ) {
// @todo Reset note actioned status?
return;
}
$installer->activate_plugin( $plugin );
$activate_request = array( 'plugins' => 'facebook-for-woocommerce' );
$installer->activate_plugins( $activate_request );
}
}
}