HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/shoetique/wp-content/plugins/facebook-for-woocommerce/facebook-commerce-admin-banner.php
<?php
/**
 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
 *
 * This source code is licensed under the license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @package FacebookCommerce
 */

/**
 * Outputs WhatApp utility messaging recruitment admin banner
 *
 * @since x.x.x
 */

/**
 * WhatsApp Admin Banner class for Facebook for WooCommerce.
 */
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
		);
	}

	/**
	 * 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  = '<div class="fb-wa-banner" data-nonce="' .
			esc_attr( wp_create_nonce( self::BANNER_ID ) ) .
			'" data-banner-id="' .
			esc_attr( self::BANNER_ID ) .
			'">';
		$banner_html .= '<img src="' .
			esc_url(
				plugins_url(
					'assets/images/ico-whatsapp.png',
					__FILE__
				)
			) .
			'" width="36" height="36" alt="WhatsApp Logo" />';
		$banner_html .= '<h2>Sign up to test WhatsApp’s new integration with '
			. 'WooCommerce</h2>';
		$banner_html .= '<p>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.</p>';
		$banner_html .= '<a class="wa-cta-button" '
			. 'href="https://facebookpso.qualtrics.com/jfe/form/SV_0SVseus9UADOhhQ"'
			. '>Sign Up</a>';
		$banner_html .= '<a class="wa-close-button" title="Close banner" '
			. 'href="#"><img src="' .
			esc_url(
				plugins_url(
					'assets/images/ico-close.svg',
					__FILE__
				)
			) .
			'" width="16" height="16" alt="Close button" /></a>';
		$banner_html .= '</div>';

		echo wp_kses_post( $banner_html );
	}
}