From 4dddb62195d6739258625a74e09c75def7b73851 Mon Sep 17 00:00:00 2001 From: Ajay Ghaghretiya <32254909+Mr-AjayM@users.noreply.github.com> Date: Tue, 16 Apr 2019 13:41:34 +0530 Subject: [PATCH] Fix-woocommerce/woocommerce-admin#1982 (https://github.com/woocommerce/woocommerce-admin/pull/2019) * Fix-woocommerce/woocommerce-admin#1982 * Fix-woocommerce/woocommerce-admin#1982 #Tabs replaced with spaces * woocommerce/woocommerce-admin#1982 * Fix-woocommerce/woocommerce-admin#1982 Resolved Inline comments must end in full-stops, exclamation marks, or question marks. * update with tabs fixes formatting * update woocommerce-admin.php tab formatting fixes. * Update woocommerce-admin.php Update Co-Authored-By: Mr-AjayM <32254909+Mr-AjayM@users.noreply.github.com> * Update woocommerce-admin.php remove leading / Co-Authored-By: Mr-AjayM <32254909+Mr-AjayM@users.noreply.github.com> --- ...s-wc-admin-notes-giving-feedback-notes.php | 68 +++++++++++++++++++ .../woocommerce-admin/woocommerce-admin.php | 3 + 2 files changed, 71 insertions(+) create mode 100644 plugins/woocommerce-admin/includes/notes/class-wc-admin-notes-giving-feedback-notes.php diff --git a/plugins/woocommerce-admin/includes/notes/class-wc-admin-notes-giving-feedback-notes.php b/plugins/woocommerce-admin/includes/notes/class-wc-admin-notes-giving-feedback-notes.php new file mode 100644 index 00000000000..dc34f2755f6 --- /dev/null +++ b/plugins/woocommerce-admin/includes/notes/class-wc-admin-notes-giving-feedback-notes.php @@ -0,0 +1,68 @@ +get_notes_with_name( $name ); + if ( ! empty( $note_ids ) ) { + return; + } + + // Getting install timestamp reference class-wc-admin-install.php. + $wc_admin_installed = get_option( 'wc_admin_install_timestamp', false ); + if ( false === $wc_admin_installed ) { + $wc_admin_installed = time(); + update_option( 'wc_admin_install_timestamp', $wc_admin_installed ); + } + + $current_time = time(); + $three_days_in_seconds = 259200; + + // We need to show Admin Giving feeback notification after 3 days of install. + if ( $current_time - $wc_admin_installed < $three_days_in_seconds ) { + return; + } + + // Otherwise, create our new note. + $note = new WC_Admin_Note(); + $note->set_title( __( 'Giving feedback', 'woocommerce-admin' ) ); + $note->set_content( __( 'Are you enjoying the new WooCommerce experience? We\'d love to get your feedback.', '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://github.com/woocommerce/woocommerce-admin/issues/new/choose' + ); + $note->save(); + } +} diff --git a/plugins/woocommerce-admin/woocommerce-admin.php b/plugins/woocommerce-admin/woocommerce-admin.php index 030a624a2b1..0021586dd7c 100755 --- a/plugins/woocommerce-admin/woocommerce-admin.php +++ b/plugins/woocommerce-admin/woocommerce-admin.php @@ -153,6 +153,7 @@ add_action( 'admin_menu', 'wc_admin_devdocs' ); */ function wc_admin_do_wc_admin_daily() { 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(); } add_action( 'wc_admin_daily', 'wc_admin_do_wc_admin_daily' ); @@ -207,9 +208,11 @@ function wc_admin_plugins_loaded() { require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-install.php'; require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-api-init.php'; + // Admin note providers. // @todo These should be bundled in the features/ folder, but loading them from there currently has a load order issue. require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-new-sales-record.php'; require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-settings-notes.php'; + require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-giving-feedback-notes.php'; require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-woo-subscriptions-notes.php'; require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-historical-data.php'; require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-order-milestones.php';