| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Icegram Engage - Popups, Optins, CTAs & lot more... |
| 4 |
* Plugin URI: https://www.icegram.com/ |
| 5 |
* Description: All in one solution to inspire, convert and engage your audiences. Action bars, Popup windows, Messengers, Toast notifications and more. Awesome themes and powerful rules. |
| 6 |
* Version: 3.1.10 |
| 7 |
* Tested up to: 6.1.2 |
| 8 |
* Author: icegram |
| 9 |
* Author URI: https://www.icegram.com/ |
| 10 |
* Copyright (c) 2014-22 Icegram |
| 11 |
* License: GPLv3 |
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 13 |
* |
| 14 |
* Text Domain: icegram |
| 15 |
* Domain Path: /lang/ |
| 16 |
*/ |
| 17 |
|
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
if ( ! defined( 'IG_FEEDBACK_TRACKER_VERSION' ) ) { |
| 23 |
define( 'IG_FEEDBACK_TRACKER_VERSION', '1.2.8' ); |
| 24 |
} |
| 25 |
|
| 26 |
/* ***************************** Initial Compatibility Work (Start) ******************* */ |
| 27 |
|
| 28 |
/* =========== Do not edit this code unless you know what you are doing ========= */ |
| 29 |
|
| 30 |
/* |
| 31 |
* Note: We are not using IG_PLUGIN_DIR constant at this moment because there are chances |
| 32 |
* It might be defined from older version of IG |
| 33 |
*/ |
| 34 |
require plugin_dir_path( __FILE__ ) . 'lite/classes/feedback/class-ig-tracker.php'; |
| 35 |
|
| 36 |
global $ig_tracker; |
| 37 |
|
| 38 |
$ig_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', IG_FEEDBACK_TRACKER_VERSION ); |
| 39 |
|
| 40 |
|
| 41 |
if ( ! function_exists( 'ig_show_upgrade_pro_notice' ) ) { |
| 42 |
/** |
| 43 |
* Show IG Premium Upgrade Notice |
| 44 |
* |
| 45 |
* @since 1.11.0 |
| 46 |
*/ |
| 47 |
function ig_show_upgrade_pro_notice() { |
| 48 |
$url = admin_url( 'plugins.php?plugin_status=upgrade' ); |
| 49 |
?> |
| 50 |
<div class="notice notice-error"> |
| 51 |
<p> |
| 52 |
<?php |
| 53 |
/* translators: %s: Link to Icegram Engage upgrade */ |
| 54 |
echo wp_kses_post( sprintf( __( 'You are using older version of <strong>Icegram Engage</strong> plugin. It won\'t work because it needs plugin to be updated. Please update %s plugin.', 'icegram' ), |
| 55 |
'<a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Icegram Engage', 'icegram' ) . '</a>' ) ); |
| 56 |
?> |
| 57 |
</p> |
| 58 |
</div> |
| 59 |
<?php |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
if ( ! function_exists( 'deactivate_plugins' ) ) { |
| 64 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 65 |
} |
| 66 |
|
| 67 |
$ig_plan = 'lite'; |
| 68 |
if ( 'icegram-engage.php' === basename( __FILE__ ) ) { |
| 69 |
$ig_plan = 'premium'; |
| 70 |
} |
| 71 |
$current_active_plugins = $ig_tracker::get_active_plugins(); |
| 72 |
|
| 73 |
if ( 'premium' === $ig_plan ) { |
| 74 |
if ( in_array( 'icegram/icegram.php', $current_active_plugins, true ) ) { |
| 75 |
deactivate_plugins( 'icegram/icegram.php', true ); |
| 76 |
} |
| 77 |
} else { |
| 78 |
/** |
| 79 |
* Steps: |
| 80 |
* - Check Whether Icegram Engage Installed |
| 81 |
* - If It's installed & It's < 2.0.0 => Show Upgrade Notice |
| 82 |
* - If It's installed & It's >= 2.0.0 => return |
| 83 |
*/ |
| 84 |
|
| 85 |
//- If It's installed & It's < 2.0.0 => Show Upgrade Notice |
| 86 |
$all_plugins = $ig_tracker::get_plugins( 'all', true ); |
| 87 |
|
| 88 |
$ig_prem_plugin = 'icegram-engage/icegram-engage.php'; |
| 89 |
$ig_prem_plugin_version = ! empty( $all_plugins[ $ig_prem_plugin ] ) ? $all_plugins[ $ig_prem_plugin ]['version'] : ''; |
| 90 |
|
| 91 |
if ( ! empty( $ig_prem_plugin_version ) ) { |
| 92 |
|
| 93 |
// Is Premium active? |
| 94 |
$is_premium_active = $all_plugins[ $ig_prem_plugin ]['is_active']; |
| 95 |
|
| 96 |
// Free >= 2.0.0 && Premium < 2.0.0 |
| 97 |
if ( version_compare( $ig_prem_plugin_version, '2.0.0', '<' ) ) { |
| 98 |
|
| 99 |
// Show Upgrade Notice if It's Admin Screen. |
| 100 |
if ( is_admin() ) { |
| 101 |
add_action( 'admin_head', 'ig_show_upgrade_pro_notice', PHP_INT_MAX ); |
| 102 |
} |
| 103 |
|
| 104 |
} elseif ( $is_premium_active && version_compare( $ig_prem_plugin_version, '2.0.0', '>=' ) ) { |
| 105 |
return; |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
/* ***************************** Initial Compatibility Work (End) ******************* */ |
| 111 |
|
| 112 |
if ( ! defined( 'IG_PLUGIN_DIR' ) ) { |
| 113 |
define( 'IG_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 114 |
} |
| 115 |
|
| 116 |
if ( ! defined( 'IG_PLUGIN_URL' ) ) { |
| 117 |
define( 'IG_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 118 |
} |
| 119 |
|
| 120 |
if ( ! defined( 'IG_PLUGIN_FILE' ) ) { |
| 121 |
define( 'IG_PLUGIN_FILE', __FILE__ ); |
| 122 |
} |
| 123 |
|
| 124 |
if ( ! defined( 'IG_PLUGIN_VERSION' ) ) { |
| 125 |
define( 'IG_PLUGIN_VERSION', '3.1.10' ); |
| 126 |
} |
| 127 |
|
| 128 |
if ( ! defined( 'IG_PRODUCT_ID' ) ) { |
| 129 |
define( 'IG_PRODUCT_ID', 1000 ); |
| 130 |
} |
| 131 |
|
| 132 |
require plugin_dir_path( __FILE__ ) . 'lite/class-icegram.php'; |
| 133 |
require plugin_dir_path( __FILE__ ) . 'lite/class-icegram-loader.php'; |
| 134 |
|
| 135 |
|
| 136 |
if ( ! function_exists( 'activate_icegram' ) ) { |
| 137 |
/** |
| 138 |
* The code that runs during plugin activation. |
| 139 |
* |
| 140 |
* @param bool $network_wide Is plugin being activated on a network. |
| 141 |
*/ |
| 142 |
function activate_icegram( $network_wide ) { |
| 143 |
|
| 144 |
global $wpdb; |
| 145 |
require_once plugin_dir_path( __FILE__ ) . 'lite/classes/class-icegram-activator.php'; |
| 146 |
|
| 147 |
if ( is_multisite() && $network_wide ) { |
| 148 |
|
| 149 |
// Get all active blogs in the network and activate plugin on each one |
| 150 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) ); |
| 151 |
foreach ( $blog_ids as $blog_id ) { |
| 152 |
ig_activate_on_blog( $blog_id ); |
| 153 |
} |
| 154 |
} else { |
| 155 |
Icegram_Activator::activate(); |
| 156 |
} |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
if ( ! function_exists( 'deactivate_icegram' ) ) { |
| 161 |
/** |
| 162 |
* The code that runs during plugin deactivation. |
| 163 |
* |
| 164 |
* @param bool $network_wide Is plugin being activated on a network. |
| 165 |
* |
| 166 |
*/ |
| 167 |
function deactivate_icegram( $network_wide ) { |
| 168 |
|
| 169 |
require_once plugin_dir_path( __FILE__ ) . 'lite/classes/class-icegram-deactivator.php'; |
| 170 |
|
| 171 |
if ( is_multisite() && $network_wide ) { |
| 172 |
|
| 173 |
global $wpdb; |
| 174 |
|
| 175 |
// Get all active blogs in the network. |
| 176 |
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) ); |
| 177 |
foreach ( $blog_ids as $blog_id ) { |
| 178 |
// Run deactivation code on each one |
| 179 |
ig_trigger_deactivation_in_multisite( $blog_id ); |
| 180 |
} |
| 181 |
} else { |
| 182 |
Icegram_Deactivator::deactivate(); |
| 183 |
} |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
if ( ! function_exists( 'ig_activate_on_blog' ) ) { |
| 188 |
|
| 189 |
/** |
| 190 |
* Function to trigger Icegram's activation code for individual site/blog in a network. |
| 191 |
* |
| 192 |
* @param int $blog_id Blog ID of newly created site/blog. |
| 193 |
* |
| 194 |
* @since 1.11.0 |
| 195 |
*/ |
| 196 |
function ig_activate_on_blog( $blog_id ) { |
| 197 |
switch_to_blog( $blog_id ); |
| 198 |
Icegram_Activator::activate(); |
| 199 |
restore_current_blog(); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
if ( ! function_exists( 'ig_trigger_deactivation_in_multisite' ) ) { |
| 204 |
|
| 205 |
/** |
| 206 |
* Function to trigger Icegram deactivation code for individual site in a network. |
| 207 |
* |
| 208 |
* @param int $blog_id Blog ID of newly created site/blog. |
| 209 |
* |
| 210 |
* @since 1.11.0 |
| 211 |
*/ |
| 212 |
function ig_trigger_deactivation_in_multisite( $blog_id ) { |
| 213 |
switch_to_blog( $blog_id ); |
| 214 |
Icegram_Deactivator::deactivate(); |
| 215 |
restore_current_blog(); |
| 216 |
} |
| 217 |
} |
| 218 |
|
| 219 |
register_activation_hook( __FILE__, 'activate_icegram' ); |
| 220 |
register_deactivation_hook( __FILE__, 'deactivate_icegram' ); |
| 221 |
|
| 222 |
if ( ! function_exists( 'initialize_icegram' ) ) { |
| 223 |
function initialize_icegram() { |
| 224 |
/* @var Icegram Object */ |
| 225 |
global $icegram; |
| 226 |
|
| 227 |
// i18n / l10n - load translations |
| 228 |
load_plugin_textdomain( 'icegram', false, IG_PLUGIN_DIR . 'lite/lang/' ); |
| 229 |
|
| 230 |
$icegram = new Icegram(); |
| 231 |
|
| 232 |
do_action( 'icegram_loaded' ); |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
add_action( 'plugins_loaded', 'initialize_icegram' ); |
| 237 |
|
| 238 |
add_filter( 'ig-engage_is_page_for_notifications', 'ig_show_notification'); |
| 239 |
|
| 240 |
if ( ! function_exists( 'ig_show_notification' ) ) { |
| 241 |
function ig_show_notification(){ |
| 242 |
|
| 243 |
$screen = get_current_screen(); |
| 244 |
|
| 245 |
if( empty( $screen ) ){ |
| 246 |
return false; |
| 247 |
} |
| 248 |
|
| 249 |
if ( in_array( $screen->id, array( 'ig_campaign', 'ig_message', 'edit-ig_campaign', 'edit-ig_message', 'ig_campaign_page_icegram-reports', 'ig_campaign_page_icegram-support', 'ig_campaign_page_icegram-settings', 'ig_campaign_page_icegram-upgrade' ) ) ){ |
| 250 |
return true; |
| 251 |
} |
| 252 |
return false; |
| 253 |
|
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
if ( ! function_exists( 'IG' ) ) { |
| 258 |
|
| 259 |
/** |
| 260 |
* Icegram instance |
| 261 |
* |
| 262 |
* @param string $plugin_path Plugin path from which files to load. |
| 263 |
* |
| 264 |
* @return Icegram |
| 265 |
* |
| 266 |
* @since 1.11.0 |
| 267 |
*/ |
| 268 |
function IG( $plugin_path = '' ) { |
| 269 |
$icegram_loader = Icegram_Loader::instance(); |
| 270 |
// Load files if plugin path given. |
| 271 |
if ( ! empty( $plugin_path ) ) { |
| 272 |
$icegram_loader->load_dependencies( $plugin_path ); |
| 273 |
} |
| 274 |
return $icegram_loader; |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
$current_plugin_path = plugin_dir_path( __FILE__ ); |
| 279 |
|
| 280 |
/** |
| 281 |
* We need to pass the plugin path explicitly using $current_plugin_path variable. |
| 282 |
* We are not using IG_PLUGIN_DIR constant here, since using IG_PLUGIN_DIR constant causes premium version files not getting loaded when lite version is active and user is activating premium versions. |
| 283 |
* In that case, value of IG_PLUGIN_DIR constant is the path of Icegram lite plugin(since it is loaded first before premium version) which does not have premium version's file thus these files are not loaded. |
| 284 |
*/ |
| 285 |
IG( $current_plugin_path ); |