Add back giving feedback note with some changes (https://github.com/woocommerce/woocommerce-admin/pull/4317)

* Add back giving feedback note with some changes

* Use unique name for new note

Co-authored-by: Rebecca Scott <me@becdetat.com>
This commit is contained in:
Bec Scott 2020-05-11 16:14:37 +10:00 committed by GitHub
parent 563a9deb68
commit 5ae18fea04
2 changed files with 67 additions and 0 deletions

View File

@ -10,6 +10,7 @@ namespace Automattic\WooCommerce\Admin;
defined( 'ABSPATH' ) || exit;
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;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Tracking_Opt_In;
@ -70,5 +71,6 @@ class Events {
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();
WC_Admin_Notes_Giving_Feedback_Notes::add_notes_for_admin_giving_feedback();
}
}

View File

@ -0,0 +1,65 @@
<?php
/**
* WooCommerce Admin (Dashboard) Giving feedback notes provider
*
* Adds notes to the merchant's inbox about giving feedback.
*
* @package WooCommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* WC_Admin_Notes_Giving_Feedback_Notes
*/
class WC_Admin_Notes_Giving_Feedback_Notes {
/**
* Note traits.
*/
use NoteTraits;
/**
* Add notes for admin giving feedback.
*/
public static function add_notes_for_admin_giving_feedback() {
self::possibly_add_admin_giving_feedback_note();
}
/**
* Possibly add a notice setting moved note.
*/
protected static function possibly_add_admin_giving_feedback_note() {
$name = 'wc-admin-store-notice-giving-feedback-2';
$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( $name );
if ( ! empty( $note_ids ) ) {
return;
}
// We need to show Admin Giving feeback notification after 8 days of install.
$eight_days_in_seconds = 8 * DAY_IN_SECONDS;
if ( ! self::wc_admin_active_for( $eight_days_in_seconds ) ) {
return;
}
// Otherwise, create our new note.
$note = new WC_Admin_Note();
$note->set_title( __( 'Give feedback', 'woocommerce-admin' ) );
$note->set_content( __( 'Now that youve chosen us as a partner, our goal is to make sure we\'re providing the right tools to meet your needs. We\'re looking forward to having your feedback on the store setup experience so we can improve it in the future.', 'woocommerce-admin' ) );
$note->set_content_data( (object) array() );
$note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_icon( 'info' );
$note->set_name( $name );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'share-feedback',
__( 'Share feedback', 'woocommerce-admin' ),
'https://automattic.survey.fm/new-onboarding-survey'
);
$note->save();
}
}