Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/ultimate-addons-for-contact-form-7/addons/country-dropdown/country-dropdown.php
+++ b/ultimate-addons-for-contact-form-7/addons/country-dropdown/country-dropdown.php
@@ -102,7 +102,7 @@
ob_start(); ?>
<select <?php echo $atts; ?> id="uacf7_country_api">
- <option value="">Select a Country</option>
+ <option value=""><?php echo esc_html__( 'Select a Country', 'ultimate-addons-cf7' ); ?></option>
</select>
<?php
$api_country = ob_get_clean();
@@ -270,7 +270,7 @@
<textarea class="values" name="" id="tag-generator-panel-product-id" cols="30" rows="10" disabled></textarea>
<br>
- <?php echo _e( ' One ID per line. ', 'ultimate-addons-cf7' ) ?>
+ <?php echo esc_html( __( ' One ID per line. ', 'ultimate-addons-cf7' ) ); ?>
<?php
$default_country = ob_get_clean();
/*
--- a/ultimate-addons-for-contact-form-7/addons/signature/ultimate-signature.php
+++ b/ultimate-addons-for-contact-form-7/addons/signature/ultimate-signature.php
@@ -196,7 +196,7 @@
</div>
<div class="control_div">
<button data-field-name="<?php echo sanitize_html_class( $tag->name ); ?>"
- class="clear-button"><?php _e( 'Clear', 'ultimate-addons-cf7' ); ?></button>
+ class="clear-button"><?php echo esc_html__( 'Clear', 'ultimate-addons-cf7' ); ?></button>
</div>
</span>
--- a/ultimate-addons-for-contact-form-7/admin/tf-options/classes/UACF7_Settings.php
+++ b/ultimate-addons-for-contact-form-7/admin/tf-options/classes/UACF7_Settings.php
@@ -368,6 +368,9 @@
</div>
<div class="uacf7-addons-settings-sidebar">
+ <div class="uacf7-dashboard-promo-banner-header uacf7-sidebar-promo-header">
+ <?php do_action( 'uacf7_dashboard_promo_notice' ); ?>
+ </div>
<?php echo $this->tf_sidebar(); ?>
</div>
</div>
@@ -871,7 +874,9 @@
<div class="tf-setting-dashboard">
<!-- dashboard-header-include -->
<?php echo $this->tf_top_header(); ?>
-
+ <div class="uacf7-dashboard-promo-banner-header">
+ <?php do_action( 'uacf7_dashboard_promo_notice' ); ?>
+ </div>
<div class="tf-option-wrapper tf-setting-wrapper">
<form method="post" action="" class="tf-option-form <?php echo esc_attr( $ajax_save_class ) ?>"
enctype="multipart/form-data">
--- a/ultimate-addons-for-contact-form-7/inc/dashboard-promo-notice.php
+++ b/ultimate-addons-for-contact-form-7/inc/dashboard-promo-notice.php
@@ -0,0 +1,363 @@
+<?php
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+class Uacf7_Dashboard_Promo_Notice {
+
+ const NOTICE_KEY = 'uacf7_pro_promo';
+
+ public function __construct() {
+
+ add_action(
+ 'wp_ajax_uacf7_dismiss_promo_notice',
+ array( $this, 'dismiss_notice' )
+ );
+
+ /**
+ * Custom hook.
+ *
+ * Usage:
+ * do_action( 'uacf7_dashboard_promo_notice' );
+ */
+ add_action(
+ 'uacf7_dashboard_promo_notice',
+ array( $this, 'render' )
+ );
+ }
+
+ // instance method to make it singleton class
+ public static function instance() {
+ static $instance = null;
+
+ if ( is_null( $instance ) ) {
+ $instance = new self();
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Check if Pro plugin active.
+ */
+ private function is_pro_active() {
+
+ if ( defined( 'UACF7_PRO_VERSION' ) || class_exists( 'Ultimate_Addons_CF7_PRO' ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Get dynamic pricing data.
+ *
+ * @return array
+ */
+ private function get_dynamic_pricing() {
+
+ $cache_key = 'uacf7_dynamic_pricing';
+
+ $pricing = get_transient( $cache_key );
+
+ if ( false !== $pricing ) {
+ return $pricing;
+ }
+
+ $response = wp_remote_get(
+ 'http://api.themefic.com/dynamic-pricing/pricing.json',
+ array(
+ 'timeout' => 10,
+ 'redirection' => 3,
+ )
+ );
+
+ if ( is_wp_error( $response ) ) {
+ return array();
+ }
+
+ if ( 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
+ return array();
+ }
+
+ $body = wp_remote_retrieve_body( $response );
+
+ if ( empty( $body ) ) {
+ return array();
+ }
+
+ $data = json_decode( $body, true );
+
+ if (
+ JSON_ERROR_NONE !== json_last_error() ||
+ ! is_array( $data )
+ ) {
+ return array();
+ }
+
+ set_transient(
+ $cache_key,
+ $data,
+ DAY_IN_SECONDS
+ );
+
+ return $data;
+ }
+
+ /**
+ * Get current offer.
+ *
+ * @return array
+ */
+ private function get_current_offer() {
+
+ $base_price = 199;
+
+ $fallback = array(
+ 'offer_name' => 'Special Deal',
+ 'discount' => 75,
+ 'coupon' => '',
+ 'regular_price' => $base_price,
+ 'discount_price' => 49,
+ );
+
+ $pricing = $this->get_dynamic_pricing();
+
+ try {
+
+ $datetime = new DateTime(
+ 'now',
+ new DateTimeZone( 'America/Toronto' )
+ );
+
+ $is_weekend = ( (int) $datetime->format( 'N' ) >= 6 );
+
+ $key = $is_weekend
+ ? 'weekend'
+ : 'weekday';
+
+ if (
+ empty( $pricing[ $key ] ) ||
+ ! is_array( $pricing[ $key ] )
+ ) {
+ return $fallback;
+ }
+
+ $config = $pricing[ $key ];
+
+ $discount = isset( $config['discount'] )
+ ? absint( $config['discount'] )
+ : 0;
+
+ if ( $discount <= 0 || $discount >= 100 ) {
+ return $fallback;
+ }
+
+ $discount_price = (int) floor(
+ $base_price * ( ( 100 - $discount ) / 100 )
+ );
+
+ $coupon = '';
+
+ if ( ! empty( $config['coupons']['uacf7'] ) ) {
+ $coupon = sanitize_text_field(
+ $config['coupons']['uacf7']
+ );
+ }
+
+ if ( ! empty( $config['coupon'] ) ) {
+ $coupon = sanitize_text_field(
+ $config['coupon']
+ );
+ }
+
+ return array(
+ 'offer_name' => ! empty( $config['offer'] )
+ ? sanitize_text_field( $config['offer'] )
+ : 'Special Deal',
+ 'discount' => $discount,
+ 'coupon' => $coupon,
+ 'regular_price' => $base_price,
+ 'discount_price' => $discount_price,
+ );
+
+ } catch ( Exception $e ) {
+ return $fallback;
+ }
+ }
+
+ /**
+ * Should display notice?
+ */
+ public function should_display() {
+
+ if ( $this->is_pro_active() ) {
+ return false;
+ }
+
+ $user_id = get_current_user_id();
+
+ $data = get_user_meta(
+ $user_id,
+ self::NOTICE_KEY,
+ true
+ );
+
+ if ( empty( $data ) ) {
+ return true;
+ }
+
+ if ( ! empty( $data['forever'] ) ) {
+ return false;
+ }
+
+ if (
+ ! empty( $data['hide_until'] ) &&
+ time() < absint( $data['hide_until'] )
+ ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Render banner.
+ */
+ public function render() {
+
+ if ( ! $this->should_display() ) {
+ return;
+ }
+
+ $offer = $this->get_current_offer();
+
+ ?>
+
+ <div class="uacf7-promo-banner">
+
+ <button
+ type="button"
+ class="uacf7-promo-close"
+ aria-label="<?php esc_attr_e( 'Dismiss', 'ultimate-addons-cf7' ); ?>"
+ >
+ <svg width="9" height="9" viewBox="0 0 9 9" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M8 0.5L0.5 8M0.5 0.5L8 8" stroke="#626A6A" stroke-linecap="round" stroke-linejoin="round"/>
+ </svg>
+ </button>
+
+ <div class="uacf7-promo-icon">
+
+ <img style="height:72px; width:60px;" src="<?php echo UACF7_URL; ?>assets/admin/images/icons/shield-icon.gif" alt="shield logo">
+
+ </div>
+
+ <div class="uacf7-promo-content">
+
+ <h3>
+ <?php
+ echo esc_html(
+ sprintf(
+ __( 'Lifetime License only for $%s', 'ultimate-addons-cf7' ),
+ number_format_i18n( $offer['discount_price'] )
+ )
+ );
+ ?>
+ </h3>
+
+ <p>
+ <?php esc_html_e(
+ 'All PRO features included.',
+ 'ultimate-addons-cf7'
+ ); ?>
+ </p>
+
+ </div>
+
+ <div class="uacf7-promo-action">
+ <a
+ href="<?php echo esc_url( uacf7_utm_generator( 'https://cf7addons.com/pricing', array( 'utm_medium' => 'dashboard_promo_notice', 'utm_source' => 'uacf7_in_plugin_addons_button', 'utm_campaign' => 'uacf7_plugin_free' ) ) ); ?>"
+ target="_blank"
+ class="button button-primary"
+ >
+
+ <div class="buy-now-text">
+ <?php esc_html_e( 'Buy Now', 'ultimate-addons-cf7' ); ?>
+ </div>
+ <div class="arrow-icon">
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <path d="M17 17V7H7M17 7L7 17" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+ </svg>
+ </div>
+ </a>
+
+ </div>
+
+ </div>
+
+ <?php
+ }
+
+ /**
+ * Dismiss notice.
+ */
+ public function dismiss_notice() {
+
+ check_ajax_referer(
+ 'uacf7_notice_nonce',
+ 'nonce'
+ );
+
+ if ( ! current_user_can( 'manage_options' ) ) {
+ wp_send_json_error( 'Unauthorized' );
+ }
+
+ $user_id = get_current_user_id();
+
+ $data = get_user_meta(
+ $user_id,
+ self::NOTICE_KEY,
+ true
+ );
+
+ if ( empty( $data ) ) {
+ $data = array(
+ 'dismiss_count' => 1,
+ 'hide_until' => strtotime( '+7 days' ),
+ );
+ } else {
+
+ $count = isset( $data['dismiss_count'] )
+ ? absint( $data['dismiss_count'] )
+ : 0;
+
+ $count++;
+
+ if ( $count >= 2 ) {
+
+ $data = array(
+ 'dismiss_count' => $count,
+ 'forever' => true,
+ );
+
+ } else {
+
+ $data = array(
+ 'dismiss_count' => $count,
+ 'hide_until' => strtotime( '+7 days' ),
+ );
+ }
+ }
+
+ update_user_meta(
+ $user_id,
+ self::NOTICE_KEY,
+ $data
+ );
+
+ wp_send_json_success();
+ }
+
+}
+
+Uacf7_Dashboard_Promo_Notice::instance();
No newline at end of file
--- a/ultimate-addons-for-contact-form-7/inc/functions.php
+++ b/ultimate-addons-for-contact-form-7/inc/functions.php
@@ -17,6 +17,11 @@
require_once ( UACF7_PATH .'inc/class-promo-notice.php');
}
+if ( file_exists( UACF7_PATH . 'inc/dashboard-promo-notice.php' ) ) {
+
+ require_once ( UACF7_PATH .'inc/dashboard-promo-notice.php');
+}
+
//Require Dashboard Notice
if ( file_exists( UACF7_PATH . 'inc/class-dashboard-widget.php' ) ) {
@@ -24,10 +29,10 @@
}
//Require ultimate Promo Notice
-if ( file_exists( UACF7_PATH . 'inc/class-helper-banner.php' ) ) {
+// if ( file_exists( UACF7_PATH . 'inc/class-helper-banner.php' ) ) {
- require_once ( UACF7_PATH .'inc/class-helper-banner.php');
-}
+// require_once ( UACF7_PATH .'inc/class-helper-banner.php');
+// }
if ( file_exists( UACF7_PATH . 'admin/admin-menu.php' ) ) {
require_once UACF7_PATH . 'admin/admin-menu.php';
@@ -35,7 +40,6 @@
-
// Import export
add_filter( 'uacf7_post_meta_options', 'uacf7_post_meta_options_import_export', 100, 2 );
function uacf7_post_meta_options_import_export( $value, $post_id ) {
--- a/ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7.php
+++ b/ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7.php
@@ -3,7 +3,7 @@
* Plugin Name: Ultra Addons for Contact Form 7
* Plugin URI: https://cf7addons.com/
* Description: 50+ Essential Addons for Contact Form 7 - Conditional Fields, Multi Step Forms, Redirection, Form Templates, Columns, WooCommerce, Mailchimp and more, all in one.
- * Version: 3.5.43
+ * Version: 3.5.44
* Author: Themefic
* Author URI: https://themefic.com/
* License: GPL-2.0+
@@ -30,7 +30,7 @@
define( 'UACF7_ADDONS', UACF7_URL . 'addons' );
define( 'UACF7_PATH', plugin_dir_path( __FILE__ ) );
- define( 'UACF7_VERSION', '3.5.43' );
+ define( 'UACF7_VERSION', '3.5.44' );
if ( ! class_exists( 'AppseroClient' ) ) {
require_once( __DIR__ . '/inc/app/src/Client.php' );
@@ -202,6 +202,17 @@
'pro_active' => $pro_active
)
);
+
+ wp_localize_script(
+ 'uacf7-admin-script',
+ 'uacf7Promo',
+ array(
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ 'nonce' => wp_create_nonce(
+ 'uacf7_notice_nonce'
+ ),
+ )
+ );
wp_enqueue_style( 'uacf7-notyf', UACF7_URL . 'assets/app/libs/notyf/notyf.min.css', '', UACF7_VERSION );
wp_enqueue_script( 'uacf7-notyf', UACF7_URL . 'assets/app/libs/notyf/notyf.min.js', array( 'jquery' ), UACF7_VERSION, true );