diff --git a/assets/js/admin/whatsapp-admin-notice.js b/assets/js/admin/whatsapp-admin-notice.js new file mode 100644 index 000000000..2cb5057be --- /dev/null +++ b/assets/js/admin/whatsapp-admin-notice.js @@ -0,0 +1,9 @@ +jQuery(function ($) { + $(document).on('click', '.wc-facebook-global-notice.is-dismissible .notice-dismiss', function () { + $.post(WCFBAdminNotice.ajax_url, { + action: 'wc_facebook_dismiss_notice', + nonce: WCFBAdminNotice.nonce, + notice_id: WCFBAdminNotice.notice_id + }); + }); +}); diff --git a/facebook-commerce-admin-notice.php b/facebook-commerce-admin-notice.php new file mode 100644 index 000000000..25a589b3f --- /dev/null +++ b/facebook-commerce-admin-notice.php @@ -0,0 +1,106 @@ + admin_url( 'admin-ajax.php' ), + 'nonce' => wp_create_nonce( self::NOTICE_ID ), + 'notice_id' => self::NOTICE_ID, + ) + ); + } + + /** + * Handles the AJAX request to dismiss the notice. + */ + public function ajax_dismiss_notice() { + check_ajax_referer( self::NOTICE_ID, 'nonce' ); + update_user_meta( get_current_user_id(), self::NOTICE_ID, 1 ); + wp_send_json_success(); + } + + /** + * Displays the admin notice if not dismissed. + */ + public function show_notice() { + if ( strtotime( 'now' ) > strtotime( '2025-06-16 23:59:59' ) ) { + return; + } + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return; + } + + if ( get_user_meta( get_current_user_id(), self::NOTICE_ID, true ) ) { + return; + } + + $dismiss_url = add_query_arg( + array( + self::NOTICE_ID => '1', + '_wpnonce' => wp_create_nonce( self::NOTICE_ID ), + ) + ); + + ?> + +
+ Sign up for our testing program and get early access now!", + 'facebook-for-woocommerce' + ), + array( + 'a' => array( + 'href' => array(), + ), + ) + ), + 'https://facebookpso.qualtrics.com/jfe/form/SV_0SVseus9UADOhhQ' + ); + ?> +
+