diff --git a/plugins/woocommerce-admin/includes/wc-admin-update-functions.php b/plugins/woocommerce-admin/includes/wc-admin-update-functions.php index 9726c65cbe4..022a310f142 100644 --- a/plugins/woocommerce-admin/includes/wc-admin-update-functions.php +++ b/plugins/woocommerce-admin/includes/wc-admin-update-functions.php @@ -77,3 +77,10 @@ function wc_admin_update_0251_remove_unsnooze_action() { function wc_admin_update_0251_db_version() { Installer::update_db_version( '0.25.1' ); } + +/** + * Remove Facebook Extension note. + */ +function wc_admin_update_110_remove_facebook_note() { + WC_Admin_Notes::delete_notes_with_name( 'wc-admin-facebook-extension' ); +} diff --git a/plugins/woocommerce-admin/src/Events.php b/plugins/woocommerce-admin/src/Events.php index dd945fce697..6774e046f78 100644 --- a/plugins/woocommerce-admin/src/Events.php +++ b/plugins/woocommerce-admin/src/Events.php @@ -10,7 +10,6 @@ namespace Automattic\WooCommerce\Admin; defined( 'ABSPATH' ) || exit; -use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Facebook_Extension; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Giving_Feedback_Notes; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Mobile_App; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_New_Sales_Record; @@ -18,6 +17,7 @@ use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Tracking_Opt_In; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Onboarding_Email_Marketing; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Personalize_Store; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_WooCommerce_Payments; +use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Marketing; /** * WC_Admin_Events Class. @@ -65,10 +65,10 @@ class Events { WC_Admin_Notes_New_Sales_Record::possibly_add_sales_record_note(); WC_Admin_Notes_Giving_Feedback_Notes::add_notes_for_admin_giving_feedback(); WC_Admin_Notes_Mobile_App::possibly_add_mobile_app_note(); - WC_Admin_Notes_Facebook_Extension::possibly_add_facebook_note(); WC_Admin_Notes_Tracking_Opt_In::possibly_add_tracking_opt_in_note(); WC_Admin_Notes_Onboarding_Email_Marketing::possibly_add_onboarding_email_marketing_note(); WC_Admin_Notes_Personalize_Store::possibly_add_personalize_store_note(); WC_Admin_Notes_WooCommerce_Payments::possibly_add_note(); + WC_Admin_Notes_Marketing::possibly_add_note_intro(); } } diff --git a/plugins/woocommerce-admin/src/FeaturePlugin.php b/plugins/woocommerce-admin/src/FeaturePlugin.php index d9e7f371801..56cda82cdbb 100644 --- a/plugins/woocommerce-admin/src/FeaturePlugin.php +++ b/plugins/woocommerce-admin/src/FeaturePlugin.php @@ -10,7 +10,6 @@ namespace Automattic\WooCommerce\Admin; defined( 'ABSPATH' ) || exit; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes; -use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Facebook_Extension; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Historical_Data; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Order_Milestones; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Welcome_Message; @@ -185,7 +184,6 @@ class FeaturePlugin { new WC_Admin_Notes_Historical_Data(); new WC_Admin_Notes_Order_Milestones(); new WC_Admin_Notes_Welcome_Message(); - new WC_Admin_Notes_Facebook_Extension(); new WC_Admin_Notes_Tracking_Opt_In(); new WC_Admin_Notes_WooCommerce_Payments(); } diff --git a/plugins/woocommerce-admin/src/Features/OnboardingTasks.php b/plugins/woocommerce-admin/src/Features/OnboardingTasks.php index b4732eea99a..4c0e65deb5b 100644 --- a/plugins/woocommerce-admin/src/Features/OnboardingTasks.php +++ b/plugins/woocommerce-admin/src/Features/OnboardingTasks.php @@ -10,7 +10,6 @@ namespace Automattic\WooCommerce\Admin\Features; use \Automattic\WooCommerce\Admin\Loader; use Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore; -use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Onboarding; /** * Contains the logic for completing onboarding tasks. @@ -45,7 +44,6 @@ class OnboardingTasks { */ public function __construct() { // This hook needs to run when options are updated via REST. - add_action( 'add_option_woocommerce_task_list_complete', array( $this, 'add_completion_note' ), 10, 2 ); add_action( 'add_option_woocommerce_task_list_complete', array( $this, 'track_completion' ), 10, 2 ); add_action( 'add_option_woocommerce_task_list_tracked_completed_tasks', array( $this, 'track_task_completion' ), 10, 2 ); add_action( 'update_option_woocommerce_task_list_tracked_completed_tasks', array( $this, 'track_task_completion' ), 10, 2 ); @@ -282,18 +280,6 @@ class OnboardingTasks { return $tax_supported_countries; } - /** - * Add the task list completion note after completing all tasks. - * - * @param mixed $old_value Old value. - * @param mixed $new_value New value. - */ - public static function add_completion_note( $old_value, $new_value ) { - if ( $new_value ) { - WC_Admin_Notes_Onboarding::add_task_list_complete_note(); - } - } - /** * Records an event when all tasks are completed in the task list. * diff --git a/plugins/woocommerce-admin/src/Install.php b/plugins/woocommerce-admin/src/Install.php index bf641676e02..17c36a11537 100644 --- a/plugins/woocommerce-admin/src/Install.php +++ b/plugins/woocommerce-admin/src/Install.php @@ -40,6 +40,9 @@ class Install { 'wc_admin_update_0251_remove_unsnooze_action', 'wc_admin_update_0251_db_version', ), + '1.1.0' => array( + 'wc_admin_update_110_remove_facebook_note', + ), ); /** diff --git a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Extension.php b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Extension.php deleted file mode 100644 index ba6e27dff51..00000000000 --- a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Extension.php +++ /dev/null @@ -1,121 +0,0 @@ -publish < 1 ) { - return; - } - - // We want to show the Facebook note after day 3. - $three_days_in_seconds = 3 * DAY_IN_SECONDS; - if ( ! self::wc_admin_active_for( $three_days_in_seconds ) ) { - return; - } - - $data_store = \WC_Data_Store::load( 'admin-note' ); - - // We already have this note? Then exit, we're done. - $note_ids = $data_store->get_notes_with_name( self::NOTE_NAME ); - if ( ! empty( $note_ids ) ) { - return; - } - - include_once ABSPATH . '/wp-admin/includes/plugin.php'; - - $content = __( 'Grow your business by targeting the right people and driving sales with Facebook. You can install this free extension now.', 'woocommerce-admin' ); - - $note = new WC_Admin_Note(); - $note->set_title( __( 'Market on Facebook', 'woocommerce-admin' ) ); - $note->set_content( $content ); - $note->set_content_data( (object) array() ); - $note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); - $note->set_icon( 'thumbs-up' ); - $note->set_name( self::NOTE_NAME ); - $note->set_source( 'woocommerce-admin' ); - $note->add_action( 'learn-more', __( 'Learn more', 'woocommerce-admin' ), 'https://woocommerce.com/products/facebook/', WC_Admin_Note::E_WC_ADMIN_NOTE_UNACTIONED ); - $note->add_action( 'install-now', __( 'Install now', 'woocommerce-admin' ), false, WC_Admin_Note::E_WC_ADMIN_NOTE_UNACTIONED, true ); - - // Create the note as "actioned" if the Facebook extension is already installed. - if ( 0 === validate_plugin( 'facebook-for-woocommerce/facebook-for-woocommerce.php' ) ) { - $note->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED ); - } - - $note->save(); - } - - /** - * 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() ) { - $install_request = array( 'plugin' => 'facebook-for-woocommerce' ); - $installer = new \Automattic\WooCommerce\Admin\API\OnboardingPlugins(); - $result = $installer->install_plugin( $install_request ); - - if ( is_wp_error( $result ) ) { - // @todo Reset note actioned status? - return; - } - - $activate_request = array( 'plugins' => 'facebook-for-woocommerce' ); - $installer->activate_plugins( $activate_request ); - - $content = __( 'You\'re almost ready to start driving sales with Facebook. Complete the setup steps to control how WooCommerce integrates with your Facebook store.', 'woocommerce-admin' ); - $note->set_title( __( 'Market on Facebook — Installed', 'woocommerce-admin' ) ); - $note->set_content( $content ); - $note->set_icon( 'checkmark-circle' ); - $note->clear_actions(); - $note->add_action( - 'configure-facebook', - __( 'Setup', 'woocommerce-admin' ), - add_query_arg( - array( - 'page' => 'wc-settings', - 'tab' => 'integration', - 'section' => 'facebookcommerce', - ), - admin_url( 'admin.php' ) - ), - WC_Admin_Note::E_WC_ADMIN_NOTE_UNACTIONED - ); - } - } -} diff --git a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Marketing.php b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Marketing.php new file mode 100644 index 00000000000..59f80ae885c --- /dev/null +++ b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Marketing.php @@ -0,0 +1,60 @@ +get_notes_with_name( self::NOTE_NAME_INTRO ); + + if ( ! empty( $note_ids ) ) { + return; + } + + $note = new WC_Admin_Note(); + $note->set_title( __( 'Connect with your audience', 'woocommerce-admin' ) ); + $note->set_content( __( 'Grow your customer base and increase your sales with marketing tools built for WooCommerce.', 'woocommerce-admin' ) ); + $note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); + $note->set_icon( 'speaker' ); + $note->set_name( self::NOTE_NAME_INTRO ); + $note->set_content_data( (object) array() ); + $note->set_source( 'woocommerce-admin' ); + $note->add_action( + 'open-marketing-hub', + __( 'Open marketing hub', 'woocommerce-admin' ), + admin_url( 'admin.php?page=wc-admin&path=/marketing' ), + WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED + ); + + $note->save(); + } +} diff --git a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php deleted file mode 100644 index d3c6f6f4253..00000000000 --- a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php +++ /dev/null @@ -1,52 +0,0 @@ -get_notes_with_name( self::NOTE_NAME ); - if ( ! empty( $note_ids ) ) { - return; - } - - $note = new WC_Admin_Note(); - $note->set_title( __( 'Congratulations - your store is ready for launch!', 'woocommerce-admin' ) ); - $note->set_content( __( 'You’re ready to take your first order - may the sales roll in!', 'woocommerce-admin' ) ); - $note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); - $note->set_icon( 'notice' ); - $note->set_name( self::NOTE_NAME ); - $note->set_content_data( (object) array() ); - $note->set_source( 'woocommerce-admin' ); - $note->add_action( - 'market-store', - __( 'Market my store', 'woocommerce-admin' ), - 'https://woocommerce.com/product-category/woocommerce-extensions/marketing-extensions/' - ); - - $note->save(); - } -}