Marketing inbox note (https://github.com/woocommerce/woocommerce-admin/pull/4030)
* Add Marketing Note Provider Class * Add marketing note intro to events * Include Market Notes with feature plugin * Change marketing into note title * Remove facebook extension inbox note * Remove onboarding completed (market my store) inbox note * Add inline comment back in * Remove constructor Install method doesn’t exist * Remove unnecessary use of WC_Admin_Notes_Marketing * Change marketing hub note to use speaker gridicon * Remove facebook note on update to 1.1.0
This commit is contained in:
parent
cd9ee95c32
commit
05cf7b010e
|
@ -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' );
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Admin Facebook Extension Note Provider.
|
||||
*
|
||||
* Adds a note to the merchant's inbox showing the benefits of the Facebook extension.
|
||||
*
|
||||
* @package WooCommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Notes;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Notes_Facebook_Extension
|
||||
*/
|
||||
class WC_Admin_Notes_Facebook_Extension {
|
||||
/**
|
||||
* Note traits.
|
||||
*/
|
||||
use NoteTraits;
|
||||
|
||||
/**
|
||||
* Name of the note for use in the database.
|
||||
*/
|
||||
const NOTE_NAME = 'wc-admin-facebook-extension';
|
||||
|
||||
/**
|
||||
* Attach hooks.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'woocommerce_note_action_install-now', array( $this, 'install_facebook_extension' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Possibly add Facebook extension note.
|
||||
*/
|
||||
public static function possibly_add_facebook_note() {
|
||||
// Only show the Facebook note to stores with products.
|
||||
$products = wp_count_posts( 'product' );
|
||||
if ( (int) $products->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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Admin Marketing Note Provider.
|
||||
*
|
||||
* Adds notes to the merchant's inbox concerning the marketing dashboard.
|
||||
*
|
||||
* @package WooCommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Notes;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Notes_Marketing
|
||||
*/
|
||||
class WC_Admin_Notes_Marketing {
|
||||
|
||||
/**
|
||||
* Note traits.
|
||||
*/
|
||||
use NoteTraits;
|
||||
|
||||
/**
|
||||
* Name of the note for use in the database.
|
||||
*/
|
||||
const NOTE_NAME_INTRO = 'wc-admin-marketing-intro';
|
||||
|
||||
/**
|
||||
* Maybe add a note introducing the marketing hub.
|
||||
*/
|
||||
public static function possibly_add_note_intro() {
|
||||
|
||||
$data_store = \WC_Data_Store::load( 'admin-note' );
|
||||
|
||||
// See if we've already created this kind of note so we don't do it again.
|
||||
$note_ids = $data_store->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();
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Admin: Store ready note
|
||||
*
|
||||
* Adds notes for store onboarding and setup.
|
||||
*
|
||||
* @package WooCommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Notes;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Notes_Onboarding.
|
||||
*/
|
||||
class WC_Admin_Notes_Onboarding {
|
||||
const NOTE_NAME = 'wc-admin-task-list-complete';
|
||||
|
||||
/**
|
||||
* Creates a note for task list completion.
|
||||
*/
|
||||
public static function add_task_list_complete_note() {
|
||||
$is_task_list_complete = get_option( 'woocommerce_task_list_complete', false );
|
||||
if ( ! $is_task_list_complete ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if we've already created this kind of note so we don't do it again.
|
||||
$data_store = \WC_Data_Store::load( 'admin-note' );
|
||||
$note_ids = $data_store->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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue