From 9fc6f82cb4daf756d579d20cc0c28f3633d7f419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovana=20Ran=C4=91elovi=C4=87?= Date: Wed, 14 May 2025 15:11:09 +0200 Subject: [PATCH 1/7] Add WAUM recruitment banner class --- facebook-commerce-admin-banner.php | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 facebook-commerce-admin-banner.php diff --git a/facebook-commerce-admin-banner.php b/facebook-commerce-admin-banner.php new file mode 100644 index 000000000..1b98ebf30 --- /dev/null +++ b/facebook-commerce-admin-banner.php @@ -0,0 +1,38 @@ +'; + $banner_html .= 'WhatsApp Logo'; + $banner_html .= '

Sign up to test WhatsApp’s new integration with WooCommerce

'; + $banner_html .= '

We’re launching a brand new WhatsApp integration for WooCommerce allowing businesses to send order tracking notifications on WhatsApp. Sign up for a chance to join our testing program and get early access to this new feature. As a thank you, participants who complete testing will receive a $500 ad credit.

'; + $banner_html .= 'Sign Up'; + $banner_html .= 'Close button'; + $banner_html .= ''; + + echo wp_kses_post( $banner_html ); + } +} From 06d602390a78690f361ecbff5acc01506f34d849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovana=20Ran=C4=91elovi=C4=87?= Date: Wed, 14 May 2025 15:42:50 +0200 Subject: [PATCH 2/7] Check if banner should be shown --- facebook-commerce-admin-banner.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/facebook-commerce-admin-banner.php b/facebook-commerce-admin-banner.php index 1b98ebf30..8ee34ecf4 100644 --- a/facebook-commerce-admin-banner.php +++ b/facebook-commerce-admin-banner.php @@ -24,6 +24,18 @@ class WC_Facebookcommerce_Admin_Banner { * Output the banner HTML if it should be shown. */ public function render_banner() { + // Check if the WhatsApp admin banner should be shown. + if ( strtotime( 'now' ) > strtotime( '2025-06-15 23:59:59' ) ) { + return; + } + + if ( ! current_user_can( 'manage_woocommerce' ) ) { + return; + } + + if ( get_user_meta( get_current_user_id(), self::BANNER_ID, true ) ) { + return; + } $banner_html = '
'; $banner_html .= 'WhatsApp Logo'; From ad10d3cd9d01be71eb016ffdf69ced82474e6de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovana=20Ran=C4=91elovi=C4=87?= Date: Thu, 15 May 2025 09:24:07 +0200 Subject: [PATCH 3/7] Add WAUM banner images --- assets/images/ico-close.svg | 1 + assets/images/ico-whatsapp.png | Bin 0 -> 1889 bytes 2 files changed, 1 insertion(+) create mode 100644 assets/images/ico-close.svg create mode 100644 assets/images/ico-whatsapp.png diff --git a/assets/images/ico-close.svg b/assets/images/ico-close.svg new file mode 100644 index 000000000..4929537ca --- /dev/null +++ b/assets/images/ico-close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/images/ico-whatsapp.png b/assets/images/ico-whatsapp.png new file mode 100644 index 0000000000000000000000000000000000000000..9bf4754366acf1f2822febf1748c36d2e9e40d95 GIT binary patch literal 1889 zcmV-n2cGzeP)tkT8`r+iwryi{vbHkj+TIB!f4b{+I(=RzJtyxxt8>0n z=&Js!kst8?)^vXOPhI@4=U-WfUf_KZqd?6Qagu*#F$NG9&0aM=JO5Y9KDD&%K-(Jo zM{TQYA91a=eS|RG@#3vFt`t_T`R4H5Q-?D^wCEP z%6?qby4OP+my*l-=*y4a!8MML*rxsP`SlE7&7`i_-&>5S_vq2VFFks<{rP*Zb7bxSl_{k-&!y0oPMJ`4e~&vE^J*mHFTRXxn%~0TJUoI0%yt(g``3G@6}p8X zbD8ZSpY;{AZ>6KZUbw*)J2ZW7yWLZ$0l>F2kZ>+bHL?6?mjCsvE<2aoPKe&51FS*@J{Cg)CfVs zaJPvUmf?(xYn0f(j)Gg;FlFV)$;!4#MM#=3xz{4=&8I*qaSZ?vr3T;a8e6sW_@uMTkaKQ1di3R(cDxWfiH1(i z#n6xtia)zkje}1uPo%%sxNLCU zaR-p1&luEuY@nUuQ2X67{eYho{9@?wML6u}LIsa+mIjZ z=HX(DDj$LCEN>$c7T@Xkmc3Ha|;hK|#GX4qQF_;u0KuWWMCE zkK}_zmygAJ_Qz;MJTDDf^KK#kmcIMH<)}i;d8N`X#=ls6tM2@+X zK=WLTEgy%2%=7T@t@B7VMB=3AuxhB;3BOlOIQk-HR~P%_=Tw!@!50_aVDLK)!zdTV zx1azf%}@5GNceg_ZKeg-4|FdEaV@L8y8?kWg%uVd}I}u(x;GGnTLJKr($BoOx9o2 zB|p8g(3N$#_`JAgi1MxtYC%SZspq>R-$^$YU|K~!rj<*WEoG&*KabHhPR&pKeV!}# z>LLn5c@fc!K)GH13xbrYyw>DD%)*rN*_ixCE(OdkciXe1|Bqh&Kgt}@FXeA%y0ULB z!nnb4Jw-9W%Ib6}$iM>zKxlen87BT=hQdt6{ww=`Kb5%sr2UDLy697&wk7NI$f*@ zs7c&w#1o$Xj0hNI1Vd7Yjy&l+acB97?CT57rDB`xq9CdignnON6R(z7 Date: Thu, 15 May 2025 12:47:36 +0200 Subject: [PATCH 4/7] Add WAUM banner styles --- ...cebook-for-woocommerce-whatsapp-banner.css | 64 +++++++++++++++++++ includes/Admin/Settings_Screens/Advertise.php | 1 + 2 files changed, 65 insertions(+) create mode 100644 assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css diff --git a/assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css b/assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css new file mode 100644 index 000000000..29aac8249 --- /dev/null +++ b/assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css @@ -0,0 +1,64 @@ +.fb-wa-banner { + display: block; + position: relative; + box-sizing: border-box; + width: 1000px; + margin-bottom: 20px; + padding: 16px; + color: #050505; + background: #fff; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.2); +} + +.fb-wa-banner p, +.fb-wa-banner h2 { + font-family: Helvetica, Arial, sans-serif; + font-size: 20px; + line-height: 24px; + color:#606770; +} + +.fb-wa-banner h2 { + font-weight: 600; + color: #1c1e21; +} + +.fb-wa-banner .wa-cta-button { + display: inline-block; + cursor: pointer; + border: 1px solid; + width: 151px; + border-radius: 6px; + text-decoration: none; + box-sizing: content-box; + font-size: 16px; + line-height: 34px; + -webkit-font-smoothing: antialiased; + font-weight: bold; + justify-content: center; + padding: 0 8px; + position: relative; + text-align: center; + text-shadow: none; + vertical-align: middle; + transition: 200ms cubic-bezier(.08, .52, .52, 1) background-color, 200ms cubic-bezier(.08, .52, .52, 1) box-shadow, 200ms cubic-bezier(.08, .52, .52, 1) transform; + padding: 0 16px; + color: #fff; + background-color: #1877f2; + border-color: #1877f2; +} + +.fb-wa-banner .wa-cta-button:hover { + background-color: #1763cf; + border-color: #1763cf; +} + +.fb-wa-banner .wa-close-button { + position: absolute; + display: block; + width: 16px; + height: 16px; + padding: 5px; + right: 16px; + top: 16px; +} diff --git a/includes/Admin/Settings_Screens/Advertise.php b/includes/Admin/Settings_Screens/Advertise.php index 90b4d7396..92c339fcd 100644 --- a/includes/Admin/Settings_Screens/Advertise.php +++ b/includes/Admin/Settings_Screens/Advertise.php @@ -70,6 +70,7 @@ public function enqueue_assets() { return; } wp_enqueue_style( 'wc-facebook-admin-advertise-settings', facebook_for_woocommerce()->get_plugin_url() . '/assets/css/admin/facebook-for-woocommerce-advertise.css', array(), \WC_Facebookcommerce::VERSION ); + wp_enqueue_style( 'wc-facebook-admin-whatsapp-banner', facebook_for_woocommerce()->get_plugin_url() . '/assets/css/admin/facebook-for-woocommerce-whatsapp-banner.css', array(), \WC_Facebookcommerce::VERSION ); } From 7ad6a02e57c984c5251cfa4a25abba3fbdbe3e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovana=20Ran=C4=91elovi=C4=87?= Date: Thu, 15 May 2025 13:20:52 +0200 Subject: [PATCH 5/7] Instantiate WAUM recruitment banner class --- includes/Admin/Settings_Screens/Advertise.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/Admin/Settings_Screens/Advertise.php b/includes/Admin/Settings_Screens/Advertise.php index 92c339fcd..c94568f6b 100644 --- a/includes/Admin/Settings_Screens/Advertise.php +++ b/includes/Admin/Settings_Screens/Advertise.php @@ -210,6 +210,9 @@ public function render() { $fbe_extras = wp_json_encode( $this->get_lwi_ads_configuration_data() ); + require_once __DIR__ . '/../../../facebook-commerce-admin-banner.php'; + $banner = new \WC_Facebookcommerce_Admin_Banner(); + $banner->render_banner(); ?>
Date: Mon, 19 May 2025 14:51:34 +0200 Subject: [PATCH 6/7] Remove console log calls --- assets/js/admin/whatsapp-admin-banner.js | 13 +++++++ facebook-commerce-admin-banner.php | 38 ++++++++++++++++++- includes/Admin/Settings_Screens/Advertise.php | 2 + 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 assets/js/admin/whatsapp-admin-banner.js diff --git a/assets/js/admin/whatsapp-admin-banner.js b/assets/js/admin/whatsapp-admin-banner.js new file mode 100644 index 000000000..fedaaaf27 --- /dev/null +++ b/assets/js/admin/whatsapp-admin-banner.js @@ -0,0 +1,13 @@ +jQuery(function ($) { + $(document).on('click', '.fb-wa-banner .wa-close-button', function (e) { + e.preventDefault(); + $('.fb-wa-banner').remove(); + + $.post(WCFBAdminBanner.ajax_url, { + action: 'wc_facebook_dismiss_banner', + nonce: WCFBAdminBanner.nonce, + banner_id: WCFBAdminBanner.banner_id + }).done(function (response) { + }); + }); +}); diff --git a/facebook-commerce-admin-banner.php b/facebook-commerce-admin-banner.php index 8ee34ecf4..ba6818e70 100644 --- a/facebook-commerce-admin-banner.php +++ b/facebook-commerce-admin-banner.php @@ -20,6 +20,42 @@ class WC_Facebookcommerce_Admin_Banner { const BANNER_ID = 'wc_facebook_admin_banner'; + public function __construct() { + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_banner_script' ) ); + add_action( 'wp_ajax_wc_facebook_dismiss_banner', array( $this, 'ajax_dismiss_banner' ) ); + } + + /** + * Enqueue the admin banner script and localize data. + */ + public function enqueue_banner_script() { + wp_enqueue_script( + 'whatsapp-admin-banner', + plugins_url( 'assets/js/admin/whatsapp-admin-banner.js', __FILE__ ), + array( 'jquery' ), + '1.0', + true + ); + wp_localize_script( + 'whatsapp-admin-banner', + 'WCFBAdminBanner', + array( + 'ajax_url' => admin_url( 'admin-ajax.php' ), + 'nonce' => wp_create_nonce( self::BANNER_ID ), + 'banner_id' => self::BANNER_ID, + ) + ); + } + + /** + * AJAX handler to dismiss the banner. + */ + public function ajax_dismiss_banner() { + check_ajax_referer( self::BANNER_ID, 'nonce' ); + update_user_meta( get_current_user_id(), self::BANNER_ID, 1 ); + wp_send_json_success(); + } + /** * Output the banner HTML if it should be shown. */ @@ -37,7 +73,7 @@ public function render_banner() { return; } - $banner_html = '
'; + $banner_html = '
'; $banner_html .= 'WhatsApp Logo'; $banner_html .= '

Sign up to test WhatsApp’s new integration with WooCommerce

'; $banner_html .= '

We’re launching a brand new WhatsApp integration for WooCommerce allowing businesses to send order tracking notifications on WhatsApp. Sign up for a chance to join our testing program and get early access to this new feature. As a thank you, participants who complete testing will receive a $500 ad credit.

'; diff --git a/includes/Admin/Settings_Screens/Advertise.php b/includes/Admin/Settings_Screens/Advertise.php index c94568f6b..1be27e32b 100644 --- a/includes/Admin/Settings_Screens/Advertise.php +++ b/includes/Admin/Settings_Screens/Advertise.php @@ -213,7 +213,9 @@ public function render() { require_once __DIR__ . '/../../../facebook-commerce-admin-banner.php'; $banner = new \WC_Facebookcommerce_Admin_Banner(); $banner->render_banner(); + $banner->enqueue_banner_script(); ?> +
Date: Mon, 19 May 2025 17:11:22 +0200 Subject: [PATCH 7/7] Update code style and banner class init --- assets/js/admin/whatsapp-admin-banner.js | 2 +- facebook-commerce-admin-banner.php | 66 +++++++++++++++---- facebook-for-woocommerce.php | 14 ++++ includes/Admin/Settings_Screens/Advertise.php | 7 +- 4 files changed, 72 insertions(+), 17 deletions(-) diff --git a/assets/js/admin/whatsapp-admin-banner.js b/assets/js/admin/whatsapp-admin-banner.js index fedaaaf27..f11bb94a3 100644 --- a/assets/js/admin/whatsapp-admin-banner.js +++ b/assets/js/admin/whatsapp-admin-banner.js @@ -1,13 +1,13 @@ jQuery(function ($) { $(document).on('click', '.fb-wa-banner .wa-close-button', function (e) { e.preventDefault(); - $('.fb-wa-banner').remove(); $.post(WCFBAdminBanner.ajax_url, { action: 'wc_facebook_dismiss_banner', nonce: WCFBAdminBanner.nonce, banner_id: WCFBAdminBanner.banner_id }).done(function (response) { + $('.fb-wa-banner').remove(); }); }); }); diff --git a/facebook-commerce-admin-banner.php b/facebook-commerce-admin-banner.php index ba6818e70..d134cf561 100644 --- a/facebook-commerce-admin-banner.php +++ b/facebook-commerce-admin-banner.php @@ -21,8 +21,14 @@ class WC_Facebookcommerce_Admin_Banner { const BANNER_ID = 'wc_facebook_admin_banner'; public function __construct() { - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_banner_script' ) ); - add_action( 'wp_ajax_wc_facebook_dismiss_banner', array( $this, 'ajax_dismiss_banner' ) ); + add_action( + 'admin_enqueue_scripts', + array( $this, 'enqueue_banner_script' ) + ); + add_action( + 'wp_ajax_wc_facebook_dismiss_banner', + array( $this, 'ajax_dismiss_banner' ) + ); } /** @@ -31,7 +37,10 @@ public function __construct() { public function enqueue_banner_script() { wp_enqueue_script( 'whatsapp-admin-banner', - plugins_url( 'assets/js/admin/whatsapp-admin-banner.js', __FILE__ ), + plugins_url( + 'assets/js/admin/whatsapp-admin-banner.js', + __FILE__ + ), array( 'jquery' ), '1.0', true @@ -52,8 +61,11 @@ public function enqueue_banner_script() { */ public function ajax_dismiss_banner() { check_ajax_referer( self::BANNER_ID, 'nonce' ); - update_user_meta( get_current_user_id(), self::BANNER_ID, 1 ); - wp_send_json_success(); + update_user_meta( + get_current_user_id(), + self::BANNER_ID, + 1 + ); } /** @@ -69,16 +81,46 @@ public function render_banner() { return; } - if ( get_user_meta( get_current_user_id(), self::BANNER_ID, true ) ) { + if ( get_user_meta( + get_current_user_id(), + self::BANNER_ID, + true + ) ) { return; } - $banner_html = '
'; - $banner_html .= 'WhatsApp Logo'; - $banner_html .= '

Sign up to test WhatsApp’s new integration with WooCommerce

'; - $banner_html .= '

We’re launching a brand new WhatsApp integration for WooCommerce allowing businesses to send order tracking notifications on WhatsApp. Sign up for a chance to join our testing program and get early access to this new feature. As a thank you, participants who complete testing will receive a $500 ad credit.

'; - $banner_html .= ''; - $banner_html .= ''; + $banner_html = '
'; + $banner_html .= 'WhatsApp Logo'; + $banner_html .= '

Sign up to test WhatsApp’s new integration with ' + . 'WooCommerce

'; + $banner_html .= '

We’re launching a brand new WhatsApp integration for ' + . 'WooCommerce allowing businesses to send order tracking notifications ' + . 'on WhatsApp. Sign up for a chance to join our testing program and get ' + . 'early access to this new feature. As a thank you, participants who ' + . 'complete testing will receive a $500 ad credit.

'; + $banner_html .= ''; + $banner_html .= ''; $banner_html .= '
'; echo wp_kses_post( $banner_html ); diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index 36015a048..39a7ce137 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -38,6 +38,20 @@ function () { } } ); + +if ( is_admin() ) { + add_action( + 'admin_init', + function () { + if ( ! class_exists( 'WC_Facebookcommerce_Admin_Banner' ) ) { + require_once plugin_dir_path( __FILE__ ) . + 'facebook-commerce-admin-banner.php'; + } + new WC_Facebookcommerce_Admin_Banner(); + } + ); +} + /** * The plugin loader class. * diff --git a/includes/Admin/Settings_Screens/Advertise.php b/includes/Admin/Settings_Screens/Advertise.php index 1be27e32b..670a67d5c 100644 --- a/includes/Admin/Settings_Screens/Advertise.php +++ b/includes/Admin/Settings_Screens/Advertise.php @@ -210,10 +210,9 @@ public function render() { $fbe_extras = wp_json_encode( $this->get_lwi_ads_configuration_data() ); - require_once __DIR__ . '/../../../facebook-commerce-admin-banner.php'; - $banner = new \WC_Facebookcommerce_Admin_Banner(); - $banner->render_banner(); - $banner->enqueue_banner_script(); + $wa_banner = new \WC_Facebookcommerce_Admin_Banner(); + $wa_banner->render_banner(); + $wa_banner->enqueue_banner_script(); ?>