| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Icegram Express - Email Subscribers, Newsletters and Marketing Automation Plugin |
| 4 |
* Plugin URI: https://www.icegram.com/ |
| 5 |
* Description: Add subscription forms on website, send HTML newsletters & automatically notify subscribers about new blog posts once it is published. |
| 6 |
* Version: 5.9.34 |
| 7 |
* Author: Icegram |
| 8 |
* Author URI: https://www.icegram.com/ |
| 9 |
* Requires at least: 3.9 |
| 10 |
* Tested up to: 7.0 |
| 11 |
* WC requires at least: 3.6.0 |
| 12 |
* WC tested up to: 8.0.2 |
| 13 |
* ES Woo: 7120515:9f4c7f8bb491260ef19edf9699db73e6 |
| 14 |
* Requires PHP: 7.0 |
| 15 |
* Text Domain: email-subscribers |
| 16 |
* Domain Path: /lite/languages/ |
| 17 |
* License: GPLv3 |
| 18 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 19 |
* Copyright (c) 2016-2022 Icegram |
| 20 |
*/ |
| 21 |
|
| 22 |
// If this file is called directly, abort. |
| 23 |
if ( ! defined( 'WPINC' ) ) { |
| 24 |
die; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Minimum PHP version required for Icegram Express |
| 29 |
* |
| 30 |
* @since 4.4.1 |
| 31 |
* |
| 32 |
* @since 4.4.3 Added if not already defined() check. |
| 33 |
*/ |
| 34 |
if ( ! defined( 'IG_ES_MIN_PHP_VER' ) ) { |
| 35 |
define( 'IG_ES_MIN_PHP_VER', '7.0' ); |
| 36 |
} |
| 37 |
|
| 38 |
if ( ! function_exists( 'ig_es_fail_php_version_notice' ) ) { |
| 39 |
|
| 40 |
/** |
| 41 |
* Icegram Express admin notice for minimum PHP version. |
| 42 |
* |
| 43 |
* Warning when the site doesn't have the minimum required PHP version. |
| 44 |
* |
| 45 |
* @return void |
| 46 |
* @since 4.4.1 |
| 47 |
*/ |
| 48 |
function ig_es_fail_php_version_notice() { |
| 49 |
/* translators: %s: PHP version */ |
| 50 |
$message = sprintf( esc_html__( 'Icegram Express requires PHP version %s+, plugin is currently NOT RUNNING.', 'email-subscribers' ), IG_ES_MIN_PHP_VER ); |
| 51 |
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) ); |
| 52 |
echo wp_kses_post( $html_message ); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
if ( ! version_compare( PHP_VERSION, IG_ES_MIN_PHP_VER, '>=' ) ) { |
| 57 |
add_action( 'admin_notices', 'ig_es_fail_php_version_notice' ); |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Earlier we were using IG_ES_FEEDBACK_VERSION constant |
| 63 |
* We have made some changes into 1.0.11 which we want to use. |
| 64 |
* So, avoid conflicts, we have define new constant |
| 65 |
* Now onward, we will use this constant |
| 66 |
* |
| 67 |
* @since 4.3.0 |
| 68 |
*/ |
| 69 |
if ( ! defined( 'IG_ES_FEEDBACK_TRACKER_VERSION' ) ) { |
| 70 |
define( 'IG_ES_FEEDBACK_TRACKER_VERSION', '1.2.12' ); |
| 71 |
} |
| 72 |
|
| 73 |
if ( ! defined( 'IG_ES_TRACKER_VERSION' ) ) { |
| 74 |
define( 'IG_ES_TRACKER_VERSION', '1.2.6' ); |
| 75 |
} |
| 76 |
|
| 77 |
if ( ! defined( 'IG_ES_PLUGIN_USAGE_TRACKER_VERSION' ) ) { |
| 78 |
define( 'IG_ES_PLUGIN_USAGE_TRACKER_VERSION', '1.0.0' ); |
| 79 |
} |
| 80 |
|
| 81 |
global $ig_es_tracker; |
| 82 |
|
| 83 |
/** |
| 84 |
* WordPress version |
| 85 |
* |
| 86 |
* @since 4.4.2 |
| 87 |
*/ |
| 88 |
global $wp_version; |
| 89 |
|
| 90 |
|
| 91 |
/* ***************************** Initial Compatibility Work (Start) ******************* */ |
| 92 |
|
| 93 |
/* =========== Do not edit this code unless you know what you are doing ========= */ |
| 94 |
|
| 95 |
/* |
| 96 |
* Note: We are not using ES_PLUGIN_DIR constant at this moment because there are chances |
| 97 |
* It might be defined from older version of ES |
| 98 |
*/ |
| 99 |
require plugin_dir_path( __FILE__ ) . 'lite/includes/feedback/class-ig-tracker.php'; |
| 100 |
$ig_es_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', IG_ES_TRACKER_VERSION ); |
| 101 |
|
| 102 |
if ( ! function_exists( 'ig_es_show_upgrade_pro_notice' ) ) { |
| 103 |
/** |
| 104 |
* Show ES Premium Upgrade Notice |
| 105 |
* |
| 106 |
* @since 4.3.0 |
| 107 |
*/ |
| 108 |
function ig_es_show_upgrade_pro_notice() { |
| 109 |
$url = admin_url( 'plugins.php?plugin_status=upgrade' ); |
| 110 |
?> |
| 111 |
<div class="notice notice-error"> |
| 112 |
<p> |
| 113 |
<?php |
| 114 |
echo wp_kses_post( |
| 115 |
sprintf( |
| 116 |
/* translators: %s: Link to Icegram Express Premium upgrade */ |
| 117 |
__( 'You are using older version of <strong>Icegram Express Premium</strong> plugin. It won\'t work because it needs plugin to be updated. Please update %s plugin.', 'email-subscribers' ), |
| 118 |
'<a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Icegram Express Premium', 'email-subscribers' ) . '</a>' |
| 119 |
) |
| 120 |
); |
| 121 |
?> |
| 122 |
</p> |
| 123 |
</div> |
| 124 |
<?php |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
if ( ! function_exists( 'deactivate_plugins' ) ) { |
| 129 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 130 |
} |
| 131 |
|
| 132 |
$ig_es_plan = 'lite'; |
| 133 |
if ( 'email-subscribers-premium.php' === basename( __FILE__ ) ) { |
| 134 |
$ig_es_plan = 'premium'; |
| 135 |
} elseif ( 'icegram-marketing-automation.php' === basename( __FILE__ ) ) { |
| 136 |
$ig_es_plan = 'woo'; |
| 137 |
} |
| 138 |
|
| 139 |
$current_active_plugins = $ig_es_tracker::get_active_plugins(); |
| 140 |
|
| 141 |
if ( 'premium' === $ig_es_plan ) { |
| 142 |
// We don't need ES Lite version As we are already running ES Premium 4.3.0+ |
| 143 |
// which includes ES Lite code. |
| 144 |
// So, deactivate it |
| 145 |
deactivate_plugins( 'email-subscribers/email-subscribers.php', true ); |
| 146 |
} elseif ( 'woo' === $ig_es_plan ) { |
| 147 |
$plugins_to_deactivate = array( |
| 148 |
'email-subscribers/email-subscribers.php', |
| 149 |
'email-subscribers-premium/email-subscribers-premium.php', |
| 150 |
); |
| 151 |
foreach ( $plugins_to_deactivate as $plugin_slug ) { |
| 152 |
if ( in_array( $plugin_slug, $current_active_plugins, true ) ) { |
| 153 |
deactivate_plugins( $plugin_slug, true ); |
| 154 |
} |
| 155 |
} |
| 156 |
} else { |
| 157 |
/** |
| 158 |
* Steps: |
| 159 |
* - Check Whether ES Premium Installed |
| 160 |
* - If It's installed & It's < 4.3.0 => Show Upgrade Notice |
| 161 |
* - If It's installed & It's >= 4.3.0 => return |
| 162 |
*/ |
| 163 |
|
| 164 |
// - If It's installed & It's < 4.3.0 => Show Upgrade Notice |
| 165 |
$all_plugins = $ig_es_tracker::get_plugins( 'all', true ); |
| 166 |
|
| 167 |
$es_pro_plugin = 'email-subscribers-premium/email-subscribers-premium.php'; |
| 168 |
$es_pro_plugin_version = ! empty( $all_plugins[ $es_pro_plugin ] ) ? $all_plugins[ $es_pro_plugin ]['version'] : ''; |
| 169 |
|
| 170 |
if ( ! empty( $es_pro_plugin_version ) ) { |
| 171 |
|
| 172 |
// Is Pro active? |
| 173 |
$is_pro_active = $all_plugins[ $es_pro_plugin ]['is_active']; |
| 174 |
|
| 175 |
// Free >= 4.3.0 && Pro < 4.3.0 |
| 176 |
if ( version_compare( $es_pro_plugin_version, 4.3, '<' ) ) { |
| 177 |
|
| 178 |
// Show Upgrade Notice if It's Admin Screen. |
| 179 |
if ( is_admin() ) { |
| 180 |
add_action( 'admin_head', 'ig_es_show_upgrade_pro_notice', PHP_INT_MAX ); |
| 181 |
} |
| 182 |
} elseif ( $is_pro_active && version_compare( $es_pro_plugin_version, 4.3, '>=' ) ) { |
| 183 |
return; |
| 184 |
} |
| 185 |
} |
| 186 |
} |
| 187 |
/* ***************************** Initial Compatibility Work (End) ******************* */ |
| 188 |
|
| 189 |
if ( ! defined( 'ES_PLUGIN_VERSION' ) ) { |
| 190 |
define( 'ES_PLUGIN_VERSION', '5.9.34' ); |
| 191 |
} |
| 192 |
|
| 193 |
// Plugin Folder Path. |
| 194 |
if ( ! defined( 'ES_PLUGIN_DIR' ) ) { |
| 195 |
define( 'ES_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 196 |
} |
| 197 |
|
| 198 |
if ( ! defined( 'ES_PLUGIN_BASE_NAME' ) ) { |
| 199 |
define( 'ES_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) ); |
| 200 |
} |
| 201 |
|
| 202 |
if ( ! defined( 'ES_PLUGIN_FILE' ) ) { |
| 203 |
define( 'ES_PLUGIN_FILE', __FILE__ ); |
| 204 |
} |
| 205 |
|
| 206 |
if ( ! defined( 'ES_PLUGIN_URL' ) ) { |
| 207 |
define( 'ES_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 208 |
} |
| 209 |
|
| 210 |
if ( ! defined( 'ES_IMG_URL' ) ) { |
| 211 |
define( 'ES_IMG_URL', ES_PLUGIN_URL . 'lite/admin/images/' ); |
| 212 |
} |
| 213 |
|
| 214 |
// Start-IG-Code. |
| 215 |
if ( ! defined( 'IG_ES_PLUGIN_PLAN' ) ) { |
| 216 |
define( 'IG_ES_PLUGIN_PLAN', 'lite' ); |
| 217 |
} |
| 218 |
// End-IG-Code. |
| 219 |
// Start-Woo-Code. |
| 220 |
if ( ! defined( 'IG_ES_PLUGIN_PLAN' ) ) { |
| 221 |
define( 'IG_ES_PLUGIN_PLAN', 'woo' ); |
| 222 |
} |
| 223 |
|
| 224 |
add_action( 'before_woocommerce_init', function() { |
| 225 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 226 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 227 |
} |
| 228 |
} ); |
| 229 |
|
| 230 |
if ( ! function_exists( 'ig_es_woocommerce_inactive_notice' ) ) { |
| 231 |
|
| 232 |
/** |
| 233 |
* Icegram Express admin notice when WooCommerce is in inactive. |
| 234 |
* |
| 235 |
* @return void |
| 236 |
* @since 4.6.1 |
| 237 |
*/ |
| 238 |
function ig_es_woocommerce_inactive_notice() { |
| 239 |
$message = esc_html__( 'Icegram Express requires WooCommerce to be installed and active, plugin is currently NOT RUNNING.', 'email-subscribers' ); |
| 240 |
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) ); |
| 241 |
echo wp_kses_post( $html_message ); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
/* |
| 246 |
* Check if WooCommerce is active. Show notice if not active. |
| 247 |
*/ |
| 248 |
|
| 249 |
if ( 'woo' === IG_ES_PLUGIN_PLAN && ! in_array( 'woocommerce/woocommerce.php', $current_active_plugins, true ) ) { |
| 250 |
add_action( 'admin_notices', 'ig_es_woocommerce_inactive_notice' ); |
| 251 |
// Disable all other functionality. |
| 252 |
return; |
| 253 |
} |
| 254 |
// End-Woo-Code. |
| 255 |
if ( ! function_exists( 'activate_email_subscribers' ) ) { |
| 256 |
/** |
| 257 |
* The code that runs during plugin activation. |
| 258 |
* This action is documented in includes/class-email-subscribers-activator.php |
| 259 |
* |
| 260 |
* @param bool $network_wide Is plugin being activated on a network. |
| 261 |
*/ |
| 262 |
function activate_email_subscribers( $network_wide ) { |
| 263 |
|
| 264 |
global $wpdb; |
| 265 |
|
| 266 |
require_once ES_PLUGIN_DIR . 'lite/includes/class-email-subscribers-activator.php'; |
| 267 |
|
| 268 |
if ( is_multisite() && $network_wide ) { |
| 269 |
|
| 270 |
// Get all active blogs in the network and activate plugin on each one |
| 271 |
// phpcs:disable |
| 272 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) ); |
| 273 |
// phpcs:enable |
| 274 |
foreach ( $blog_ids as $blog_id ) { |
| 275 |
ig_es_activate_on_blog( $blog_id ); |
| 276 |
} |
| 277 |
} else { |
| 278 |
Email_Subscribers_Activator::activate(); |
| 279 |
add_option( 'email_subscribers_do_activation_redirect', true ); |
| 280 |
} |
| 281 |
} |
| 282 |
} |
| 283 |
|
| 284 |
if ( ! function_exists( 'deactivate_email_subscribers' ) ) { |
| 285 |
/** |
| 286 |
* The code that runs during plugin deactivation. |
| 287 |
* This action is documented in includes/class-email-subscribers-deactivator.php |
| 288 |
* |
| 289 |
* @param bool $network_wide Is plugin being activated on a network. |
| 290 |
*/ |
| 291 |
function deactivate_email_subscribers( $network_wide ) { |
| 292 |
|
| 293 |
require_once ES_PLUGIN_DIR . 'lite/includes/class-email-subscribers-deactivator.php'; |
| 294 |
|
| 295 |
if ( is_multisite() && $network_wide ) { |
| 296 |
|
| 297 |
global $wpdb; |
| 298 |
|
| 299 |
// Get all active blogs in the network. |
| 300 |
// phpcs:disable |
| 301 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) ); |
| 302 |
// phpcs:enable |
| 303 |
foreach ( $blog_ids as $blog_id ) { |
| 304 |
// Run deactivation code on each one |
| 305 |
ig_es_trigger_deactivation_in_multisite( $blog_id ); |
| 306 |
} |
| 307 |
} else { |
| 308 |
Email_Subscribers_Deactivator::deactivate(); |
| 309 |
} |
| 310 |
} |
| 311 |
} |
| 312 |
|
| 313 |
register_activation_hook( __FILE__, 'activate_email_subscribers' ); |
| 314 |
register_deactivation_hook( __FILE__, 'deactivate_email_subscribers' ); |
| 315 |
|
| 316 |
if ( ! function_exists( 'ig_es_may_activate_on_blog' ) ) { |
| 317 |
|
| 318 |
/** |
| 319 |
* Function to handle new blog(site) creation/activation in WP Multisite |
| 320 |
* |
| 321 |
* @param int $blog_id Blog ID of new site. |
| 322 |
* |
| 323 |
* @since 4.4.2 |
| 324 |
*/ |
| 325 |
function ig_es_may_activate_on_blog( $blog_id ) { |
| 326 |
|
| 327 |
// In WP > WP 5.1.0 WP_Site object is passed instead of blog_id. |
| 328 |
if ( $blog_id instanceof WP_Site ) { |
| 329 |
$blog_id = (int) $blog_id->blog_id; |
| 330 |
} |
| 331 |
|
| 332 |
if ( empty( $blog_id ) || ! is_numeric( $blog_id ) ) { |
| 333 |
return; |
| 334 |
} |
| 335 |
|
| 336 |
if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
| 337 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 338 |
} |
| 339 |
|
| 340 |
if ( is_plugin_active_for_network( 'email-subscribers/email-subscribers.php' ) ) { |
| 341 |
ig_es_activate_on_blog( $blog_id ); |
| 342 |
} |
| 343 |
} |
| 344 |
} |
| 345 |
|
| 346 |
if ( ! function_exists( 'ig_es_activate_on_blog' ) ) { |
| 347 |
|
| 348 |
/** |
| 349 |
* Function to trigger Icegram Express' activation code for individual site/blog in a network. |
| 350 |
* |
| 351 |
* @param int $blog_id Blog ID of newly created site/blog. |
| 352 |
* |
| 353 |
* @since 4.4.2 |
| 354 |
*/ |
| 355 |
function ig_es_activate_on_blog( $blog_id ) { |
| 356 |
switch_to_blog( $blog_id ); |
| 357 |
Email_Subscribers_Activator::activate(); |
| 358 |
add_option( 'email_subscribers_do_activation_redirect', true ); |
| 359 |
restore_current_blog(); |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
if ( ! function_exists( 'ig_es_trigger_deactivation_in_multisite' ) ) { |
| 364 |
|
| 365 |
/** |
| 366 |
* Function to trigger Icegram Express' deactivation code for individual site in a network. |
| 367 |
* |
| 368 |
* @param int $blog_id Blog ID of newly created site/blog. |
| 369 |
* |
| 370 |
* @since 4.4.2 |
| 371 |
*/ |
| 372 |
function ig_es_trigger_deactivation_in_multisite( $blog_id ) { |
| 373 |
switch_to_blog( $blog_id ); |
| 374 |
Email_Subscribers_Deactivator::deactivate(); |
| 375 |
restore_current_blog(); |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
if ( version_compare( $wp_version, '5.1.0', '>' ) ) { |
| 380 |
/** |
| 381 |
* New action when a new site/blog created in WP Multisite > 5.1.0. Priority is lower to allow other options of site to be set before we initiate our activation process. |
| 382 |
*/ |
| 383 |
add_action( 'wp_initialize_site', 'ig_es_may_activate_on_blog', 99 ); |
| 384 |
} else { |
| 385 |
/** |
| 386 |
* Deprecated action when a new site/blog created in WP Multisite <= 5.1.0 |
| 387 |
*/ |
| 388 |
add_action( 'wpmu_new_blog', 'ig_es_may_activate_on_blog' ); |
| 389 |
} |
| 390 |
|
| 391 |
// This action gets triggered when super admin activates a single site/blog. |
| 392 |
add_action( 'activate_blog', 'ig_es_may_activate_on_blog' ); |
| 393 |
|
| 394 |
add_action( 'admin_init', 'email_subscribers_redirect' ); |
| 395 |
|
| 396 |
if ( ! function_exists( 'email_subscribers_redirect' ) ) { |
| 397 |
function email_subscribers_redirect() { |
| 398 |
|
| 399 |
// Check if it is multisite and the current user is in the network administrative interface. e.g. `/wp-admin/network/` |
| 400 |
if ( is_multisite() && is_network_admin() ) { |
| 401 |
return; |
| 402 |
} |
| 403 |
|
| 404 |
if ( get_option( 'email_subscribers_do_activation_redirect', false ) ) { |
| 405 |
delete_option( 'email_subscribers_do_activation_redirect' ); |
| 406 |
wp_redirect( 'admin.php?page=es_dashboard' ); |
| 407 |
} |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
if ( ! function_exists( 'es_subbox' ) ) { |
| 412 |
/** |
| 413 |
* Show subscription form |
| 414 |
* |
| 415 |
* @param null $namefield |
| 416 |
* @param null $desc |
| 417 |
* @param null $group |
| 418 |
*/ |
| 419 |
function es_subbox( $namefield = null, $desc = null, $group = null ) { |
| 420 |
|
| 421 |
$allowedtags = ig_es_allowed_html_tags_in_esc(); |
| 422 |
$atts = array( |
| 423 |
'namefield' => $namefield, |
| 424 |
'desc' => $desc, |
| 425 |
'group' => $group, |
| 426 |
); |
| 427 |
$subscription_shortcode = ES_Shortcode::render_es_subscription_shortcode( $atts ); |
| 428 |
add_filter( 'safe_style_css', 'ig_es_allowed_css_style' ); |
| 429 |
echo wp_kses( $subscription_shortcode, $allowedtags ); |
| 430 |
} |
| 431 |
} |
| 432 |
|
| 433 |
/** |
| 434 |
* The core plugin class that is used to define internationalization, |
| 435 |
* admin-specific hooks, and public-facing site hooks. |
| 436 |
*/ |
| 437 |
require ES_PLUGIN_DIR . 'lite/includes/class-email-subscribers.php'; |
| 438 |
|
| 439 |
if ( ! function_exists( 'ES' ) ) { |
| 440 |
|
| 441 |
/** |
| 442 |
* Icegram Express instance |
| 443 |
* |
| 444 |
* @return Email_Subscribers |
| 445 |
* |
| 446 |
* @since 4.2.1 |
| 447 |
*/ |
| 448 |
function ES() { |
| 449 |
return Email_Subscribers::instance(); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
// Start ES |
| 454 |
ES()->run(); |
| 455 |
|