PluginProbe
Icegram Engage – Popups, Optins, CTAs & Lead Generation / 3.1.27
Icegram Engage – Popups, Optins, CTAs & Lead Generation v3.1.27
3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 trunk 1.1 1.1.1 1.1.2 1.10 1.10.1 1.10.10 1.10.11 1.10.12 All 180 releases
icegram / icegram.php

icegram.php in Icegram Engage – Popups, Optins, CTAs & Lead Generation 3.1.27, at icegram.php

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