first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,257 @@
<?php
defined( 'ABSPATH' ) || exit;
/**
* ES_Admin_Notices Class.
*/
class ES_Admin_Notices {
/**
* Stores notices.
*
* @var array
*/
private static $notices = array();
/**
* Array of notices - name => callback.
*
* @var array
*/
private static $core_notices = array(
'update' => 'update_notice',
);
/**
* Constructor.
*/
public static function init() {
self::$notices = get_option( 'ig_es_admin_notices', array() );
add_action( 'wp_loaded', array( __CLASS__, 'es_dismiss_admin_notice' ) );
add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
}
/**
* Store notices to DB
*/
public static function store_notices() {
update_option( 'ig_es_admin_notices', self::get_notices() );
}
/**
* Get notices
*
* @return array
*/
public static function get_notices() {
return ! empty( self::$notices ) ? self::$notices : array();
}
/**
* Remove all notices.
*/
public static function remove_all_notices() {
self::$notices = array();
}
/**
* Show a notice.
*
* @param string $name Notice name.
*/
public static function add_notice( $name ) {
self::$notices = array_unique( array_merge( self::get_notices(), array( $name ) ) );
}
/**
* Remove a notice from being displayed.
*
* @param string $name Notice name.
*/
public static function remove_notice( $name ) {
self::$notices = array_diff( self::get_notices(), array( $name ) );
delete_option( 'ig_es_admin_notice_' . $name );
}
/**
* See if a notice is being shown.
*
* @param string $name Notice name.
*
* @return boolean
*/
public static function has_notice( $name ) {
return in_array( $name, self::get_notices(), true );
}
/**
* Hide a notice if the GET variable is set.
*/
public static function hide_notices() {
$hide_notice = ig_es_get_request_data( 'ig-es-hide-notice' );
$ig_es_hide_notice_nonce = ig_es_get_request_data( '_ig_es_notice_nonce' );
if ( isset( $_GET['ig-es-hide-notice'] ) && isset( $_GET['_ig_es_notice_nonce'] ) ) { // WPCS: input var ok, CSRF ok.
if ( ! wp_verify_nonce( sanitize_key( $ig_es_hide_notice_nonce ), 'ig_es_hide_notices_nonce' ) ) { // WPCS: input var ok, CSRF ok.
wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'email-subscribers' ) );
}
self::remove_notice( $hide_notice );
update_user_meta( get_current_user_id(), 'dismissed_' . $hide_notice . '_notice', true );
do_action( 'ig_es_hide_' . $hide_notice . '_notice' );
}
}
public static function add_notices() {
$notices = self::get_notices();
if ( empty( $notices ) ) {
return;
}
if ( ! ES()->is_es_admin_screen() ) {
return;
}
foreach ( $notices as $notice ) {
if ( ! empty( self::$core_notices[ $notice ] ) ) {
add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) );
} else {
add_action( 'admin_notices', array( __CLASS__, 'output_custom_notices' ) );
}
}
}
/**
* Add a custom notice.
*
* @param string $name Notice name.
* @param string $notice_html Notice HTML.
*/
public static function add_custom_notice( $name, $args ) {
self::add_notice( $name );
update_option( 'ig_es_custom_admin_notice_' . $name, $args );
}
/**
* Output any stored custom notices.
*/
public static function output_custom_notices() {
$notices = self::get_notices();
if ( ! empty( $notices ) ) {
foreach ( $notices as $notice ) {
if ( empty( self::$core_notices[ $notice ] ) ) {
$notice_args = get_option( 'ig_es_custom_admin_notice_' . $notice );
$timezone_format = _x( 'Y-m-d', 'timezone date format' );
$ig_current_date = strtotime( date_i18n( $timezone_format ) );
if ( ! empty( $notice_args['include'] ) && file_exists( $notice_args['include'] ) ) {
include_once $notice_args['include'];
}
if ( ! empty( $notice_args['html'] ) ) {
echo wp_kses_post( $notice_args['html'] );
}
// if ( $notice_html ) {
// include dirname( __FILE__ ) . '/views/html-notice-custom.php';
// }
}
}
}
}
/**
* If we need to update, include a message with the update button.
*/
public static function update_notice() {
$latest_version_to_update = ES_Install::get_latest_db_version_to_update();
if ( version_compare( get_ig_es_db_version(), $latest_version_to_update, '<' ) ) {
// Database is updating now.
include dirname( __FILE__ ) . '/views/html-notice-updating.php';
// Show button to to "Run the updater"
// include dirname( __FILE__ ) . '/views/html-notice-update.php';
} else {
include dirname( __FILE__ ) . '/views/html-notice-updated.php';
}
}
/**
* If we need to update, include a message with the update button.
*/
public static function es_dismiss_admin_notice() {
$es_dismiss_admin_notice = ig_es_get_request_data( 'es_dismiss_admin_notice' );
$option_name = ig_es_get_request_data( 'option_name' );
if ( '1' === $es_dismiss_admin_notice && ! empty( $option_name ) ) {
if ( current_user_can( 'manage_options' ) && check_admin_referer( 'es_dismiss_admin_notice' ) ) {
update_option( 'ig_es_' . $option_name, 'yes', false );
if ( in_array( $option_name, array( 'redirect_upsale_notice', 'dismiss_upsale_notice', 'dismiss_star_notice', 'star_notice_done', 'trial_to_premium_notice' ), true ) ) {
update_option( 'ig_es_' . $option_name . '_date', ig_get_current_date_time(), false );
}
if ( 'star_notice_done' === $option_name ) {
header( 'Location: https://wordpress.org/support/plugin/email-subscribers/reviews/' );
exit();
}
if ( 'redirect_upsale_notice' === $option_name ) {
header( 'Location: https://www.icegram.com/email-subscribers-starter-plan-pricing/?utm_source=es&utm_medium=es_upsale_banner&utm_campaign=es_upsell' );
exit();
}
if ( 'trial_to_premium_notice' === $option_name ) {
self::remove_notice( 'trial_to_premium' );
$action = ig_es_get_request_data( 'action' );
if ( 'ig_es_trial_to_premium_redirect' === $action ) {
header( 'Location: https://www.icegram.com/email-subscribers-starter-plan-pricing/?utm_source=in_app&utm_medium=es_trial_to_premium_notice&utm_campaign=es_trial_to_premium_notice' );
exit();
}
}
// Halloween 2022 offer
if ( 'offer_bfcm_2023' === $option_name ) {
$redirect_url = 'https://www.icegram.com/express/pricing/?utm_source=in_app&utm_medium=es_banner&utm_campaign=offer_bfcm_2023';
if ( ES()->is_pro() ) {
$redirect_url = 'https://www.icegram.com/?utm_source=in_app&utm_medium=es_banner&utm_campaign=offer_bfcm_2023';
}
header( "Location: {$redirect_url}" );
exit();
} else {
// Remove wp cron notice if user have acknowledged it.
if ( 'wp_cron_notice' === $option_name ) {
self::remove_notice( 'show_wp_cron' );
} elseif ( 'trial_consent' === $option_name ) {
self::remove_notice( $option_name );
}
$referer = wp_get_referer();
wp_safe_redirect( $referer );
}
exit();
}
}
}
}
ES_Admin_Notices::init();

View File

@@ -0,0 +1,31 @@
<?php
/**
* Admin View: Notice - Update
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$update_url = wp_nonce_url(
add_query_arg( 'do_update_ig_es', 'true', admin_url( 'admin.php?page=es_dashboard' ) ),
'ig_es_db_update',
'ig_es_db_update_nonce'
);
?>
<div id="message" class="updated">
<p>
<strong><?php esc_html_e( 'Icegram Express data update', 'email-subscribers' ); ?></strong> &#8211; <?php esc_html_e( 'We need to update your data store to the latest version.', 'email-subscribers' ); ?>
</p>
<p class="submit">
<a href="<?php echo esc_url( $update_url ); ?>" class="es-update-now button-primary">
<?php esc_html_e( 'Run the updater', 'email-subscribers' ); ?>
</a>
</p>
</div>
<script type="text/javascript">
jQuery( '.es-update-now' ).click( 'click', function() {
return window.confirm( '<?php echo esc_js( __( 'Are you sure you wish to run the updater now?', 'email-subscribers' ) ); ?>' ); // jshint ignore:line
});
</script>

View File

@@ -0,0 +1,15 @@
<?php
/**
* Admin View: Notice - Updated
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<div id="message" class="updated es-message es-connect es-message--success">
<a class="es-message-close notice-dismiss" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'update', remove_query_arg( 'do_update_ig_es' ) ), 'ig_es_hide_notices_nonce', '_ig_es_notice_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'email-subscribers' ); ?></a>
<p><?php esc_html_e( 'Icegram Express data update complete. Thank you for updating to the latest version!', 'email-subscribers' ); ?></p>
</div>

View File

@@ -0,0 +1,26 @@
<?php
/**
* Admin View: Notice - Updating
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$force_update_url = wp_nonce_url(
add_query_arg( 'force_update_ig_es', 'true', admin_url( 'admin.php?page=es_settings' ) ),
'ig_es_force_db_update',
'ig_es_force_db_update_nonce'
);
?>
<div id="message" class="updated es-message es-connect">
<p>
<strong><?php esc_html_e( 'Icegram Express data update', 'email-subscribers' ); ?></strong> &#8211; <?php esc_html_e( 'Your database is being updated in the background. Please be patient.', 'email-subscribers' ); ?>
<!--
<a href="<?php echo esc_url( $force_update_url ); ?>">
<?php esc_html_e( 'Taking a while? Click here to run it now.', 'email-subscribers' ); ?>
</a>
-->
</p>
</div>

View File

@@ -0,0 +1,35 @@
<style type="text/css">
.ig_es_offer {
width:70%;
margin: 0 auto;
text-align: center;
padding-top: 0.8em;
}
</style>
<?php
$plan = ES()->get_plan();
$offer_name = 'offer_bfcm_2023';
$img_url = esc_url( ES_PLUGIN_URL ) . 'lite/admin/images/bfcm-pro-banner-2023.png';
if ( ES()->is_pro() ) {
$img_url = esc_url( ES_PLUGIN_URL ) . 'lite/admin/images/bfcm-common-banner-2023.png';
}
if ( ( get_option( 'ig_es_offer_bfcm_2023' ) !== 'yes' ) && ES()->is_offer_period( 'bfcm' ) ) {
$notice_dismiss_url = wp_nonce_url(
add_query_arg(
array(
'es_dismiss_admin_notice' => 1,
'option_name' => $offer_name,
)
),
'es_dismiss_admin_notice'
);
?>
<div class="wrap">
<div class="ig_es_offer">
<a target="_blank" href="<?php echo esc_url( $notice_dismiss_url ); ?>"><img style="margin:0 auto" src="<?php echo esc_url( $img_url ); ?>"/></a>
</div>
</div>
<?php } ?>

View File

@@ -0,0 +1,27 @@
<style type="text/css">
.ig_es_offer {
width:55%;
margin: 0 auto;
text-align: center;
padding-top: 1.2em;
}
</style>
<?php
if ( ( get_option( 'ig_es_offer_halloween_2022' ) !== 'yes' ) && ES()->is_offer_period( 'halloween' ) ) {
$notice_dismiss_url = wp_nonce_url(
add_query_arg(
array(
'es_dismiss_admin_notice' => 1,
'option_name' => 'offer_halloween_2022',
)
),
'es_dismiss_admin_notice'
);
?>
<div class="ig_es_offer">
<a target="_blank" href="<?php echo esc_url( $notice_dismiss_url ); ?>"><img src="<?php echo esc_url ( ES_PLUGIN_URL ); ?>/lite/admin/images/halloween-2022.png"/></a>
</div>
<?php } ?>

View File

@@ -0,0 +1,27 @@
<style type="text/css">
.ig_es_offer {
width: 60%;
margin: 0 auto;
text-align: center;
padding-top: 1.2em;
}
</style>
<?php
if ( ( get_option( 'ig_es_offer_covid_19' ) !== 'yes' ) && ( $ig_current_date >= strtotime( '2020-04-08' ) ) && ( $ig_current_date <= strtotime( '2020-04-30' ) ) ) {
$notice_dismiss_url = wp_nonce_url(
add_query_arg(
array(
'es_dismiss_admin_notice' => 1,
'option_name' => 'offer_covid_19',
)
),
'es_dismiss_admin_notice'
);
?>
<div class="ig_es_offer">
<a target="_blank" href="<?php echo esc_url( $notice_dismiss_url ); ?>"><img src="<?php echo esc_url( ES_PLUGIN_URL ); ?>/lite/admin/images/covid-19.png"/></a>
</div>
<?php } ?>

View File

@@ -0,0 +1,39 @@
<?php
/**
* Admin View: Notice - Trial Optin
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$referer = wp_get_referer();
$optin_url = wp_nonce_url(
add_query_arg( 'ig_es_trial_consent', 'yes', $referer ),
'ig_es_trial_consent'
);
$optout_url = wp_nonce_url(
add_query_arg( 'ig_es_trial_consent', 'no', $referer ),
'ig_es_trial_consent'
);
?>
<div class="notice notice-success">
<p>
<?php
/* translators: %s: Trial period in days */
echo esc_html__( sprintf( 'Start your %s days free trial of Icegram Express premium services like email delivery check, spam protection, cron handling & lot more..', ES()->trial->get_trial_period( 'in_days' ) ), 'email-subscribers' );
?>
<br/>
<a href="<?php echo esc_url( $optin_url ); ?>" class="ig-es-primary-button px-3 py-1 mt-2 align-middle">
<?php
echo esc_html__( 'Yes, start my free trial!', 'email-subscribers' );
?>
</a>
<a href="<?php echo esc_url( $optout_url ); ?>" class="ig-es-title-button px-3 py-1 mt-2 ml-2 align-middle">
<?php
echo esc_html__( 'No, its ok!', 'email-subscribers' );
?>
</a>
</p>
</div>

View File

@@ -0,0 +1,108 @@
<?php
/**
* Admin View: Notice - Trial To Premium Offer
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$referer = wp_get_referer();
$notice_optin_action = 'ig_es_trial_to_premium_redirect';
$optin_url = wp_nonce_url(
add_query_arg(
array(
'es_dismiss_admin_notice' => 1,
'option_name' => 'trial_to_premium_notice',
'action' => $notice_optin_action,
),
$referer
),
'es_dismiss_admin_notice'
);
$notice_optout_action = 'ig_es_trial_to_premium_dismiss';
$optout_url = wp_nonce_url(
add_query_arg(
array(
'es_dismiss_admin_notice' => 1,
'option_name' => 'trial_to_premium_notice',
'action' => $notice_optout_action,
),
$referer
),
'es_dismiss_admin_notice'
);
$remaining_trial_days = ES()->trial->get_remaining_trial_days();
$day_or_days = _n( 'day', 'days', $remaining_trial_days, 'email-subscribers' );
$discount_messages = array(
'bfcm' => array(
'message' => __( 'Get flat <strong>50%</strong> discount on annual plan if you upgrade now!<br/><strong>No coupon code</strong> required. Discount will be applied automatically.', 'email-subscribers' ),
),
);
$offer_type_to_show = 'trial';
$offers_date_ranges = array(
'bfcm' => array(
'start_date' => '2022-11-23 7:00:00',
'end_date' => '2022-11-30 7:00:00',
),
);
foreach ( $offers_date_ranges as $offer_type => $offer_dates ) {
$offer_start_date = $offer_dates['start_date'];
$offer_end_date = $offer_dates['end_date'];
if ( ( $ig_current_date >= strtotime( $offer_start_date ) ) && ( $ig_current_date <= strtotime( $offer_end_date ) ) ) {
$offer_type_to_show = $offer_type;
break;
}
}
$trial_expiration_message = '';
if ( $remaining_trial_days > 1 ) {
/* translators: 1. Remaining trial days. 2. day or days text based on number of remaining trial days. */
$trial_expiration_message = sprintf( __( 'Your free trial is going to <strong>expire in %1$s %2$s</strong>.', 'email-subscribers' ), $remaining_trial_days, $day_or_days );
} else {
$trial_expiration_message = __( 'Today is the <strong>last day</strong> of your free trial.', 'email-subscribers' );
}
// Add default value to message.
/* translators: 1. Discount % 2. Premium coupon code */
$discount_message = sprintf( __( 'Get flat %1$s discount if you upgrade now!<br/>Use coupon code %2$s during checkout.', 'email-subscribers' ), '<strong>10%</strong>', '<span class="ml-2 px-1.5 py-1 font-medium bg-yellow-100 rounded-md border-2 border-dotted border-indigo-300 select-all">PREMIUM10</span>' );
$offer_cta_optin_text = __( 'Upgrade now', 'email-subscribers' );
$offer_cta_optout_text = __( 'No, it\'s ok', 'email-subscribers' );
// Override offer message with current active offer message.
if ( ! empty( $discount_messages[ $offer_type_to_show ] ) ) {
$discount_message = ! empty( $discount_messages[ $offer_type_to_show ]['message'] ) ? $discount_messages[ $offer_type_to_show ]['message'] : $discount_message;
}
/* translators: 1. Trial expiration message. 2. Discount message. */
$offer_message = sprintf( __( 'Hi there,<br/>Hope you are enjoying <strong>Icegram Express MAX trial</strong>.<br/>%1$s<br/>Upgrade now to continue uninterrupted use of premium features like <strong>block fake signups, prevent bot attacks, broadcast scheduling, automatic email sending, detailed campaign report, prevent emails from going to spam</strong> & lot more....<br/>%2$s', 'email-subscribers' ), $trial_expiration_message, $discount_message );
?>
<div id="ig-es-trial-to-premium-notice" class="notice notice-success">
<p>
<?php
echo wp_kses_post( $offer_message );
?>
<br/>
<a href="<?php echo esc_url( $optin_url ); ?>" target="_blank" id="ig-es-optin-trial-to-premium-offer" class="ig-es-primary-button px-3 py-1 mt-2 align-middle">
<?php
echo esc_html( $offer_cta_optin_text );
?>
</a>
<a href="<?php echo esc_url( $optout_url ); ?>" class="ig-es-title-button px-3 py-1 mt-2 ml-2 align-middle">
<?php
echo esc_html( $offer_cta_optout_text );
?>
</a>
</p>
</div>