PluginProbe
Icegram Engage – Popups, Optins, CTAs & Lead Generation / 3.1.37
Icegram Engage – Popups, Optins, CTAs & Lead Generation v3.1.37
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.37, at icegram.php

295 lines 9.0 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.37
7 * Tested up to: 6.8
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: /lite/lang/
16 */
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 if ( ! defined( 'ICEGRAM_FEEDBACK_TRACKER_VERSION' ) ) {
23 define( 'ICEGRAM_FEEDBACK_TRACKER_VERSION', '1.2.9' );
24 }
25
26 if ( ! defined( 'ICEGRAM_USAGE_TRACKER_VERSION' ) ) {
27 define( 'ICEGRAM_USAGE_TRACKER_VERSION', '1.0.2' );
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 ICEGRAM_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 $icegram_tracker;
41
42 $icegram_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', ICEGRAM_FEEDBACK_TRACKER_VERSION );
43
44 if ( ! function_exists( 'icegram_show_upgrade_pro_notice' ) ) {
45 /**
46 * Show IG Premium Upgrade Notice
47 *
48 * @since 1.11.0
49 */
50 function icegram_show_upgrade_pro_notice() {
51 $url = admin_url( 'plugins.php?plugin_status=upgrade' );
52 ?>
53 <div class="notice notice-error">
54 <p>
55 <?php
56 /* translators: %s: Link to Icegram Engage upgrade */
57 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' ),
58 '<a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Icegram Engage', 'icegram' ) . '</a>' ) );
59 ?>
60 </p>
61 </div>
62 <?php
63 }
64 }
65
66 if ( ! function_exists( 'deactivate_plugins' ) ) {
67 require_once ABSPATH . 'wp-admin/includes/plugin.php';
68 }
69
70 $icegram_plan = 'lite';
71 if ( 'icegram-engage.php' === basename( __FILE__ ) ) {
72 $icegram_plan = 'premium';
73 }
74
75 $icegram_current_active_plugins = $icegram_tracker::get_active_plugins();
76
77 if ( 'premium' === $icegram_plan ) {
78 if ( in_array( 'icegram/icegram.php', $icegram_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 $icegram_all_plugins = $icegram_tracker::get_plugins( 'all', true );
91
92 $icegram_prem_plugin = 'icegram-engage/icegram-engage.php';
93
94 $icegram_prem_plugin_version = ! empty( $icegram_all_plugins[ $icegram_prem_plugin ] ) ? $icegram_all_plugins[ $icegram_prem_plugin ]['version'] : '';
95
96 if ( ! empty( $icegram_prem_plugin_version ) ) {
97
98 // Is Premium active?
99 $icegram_is_premium_active = $icegram_all_plugins[ $icegram_prem_plugin ]['is_active'];
100
101 // Free >= 2.0.0 && Premium < 2.0.0
102 if ( version_compare( $icegram_prem_plugin_version, '2.0.0', '<' ) ) {
103
104 // Show Upgrade Notice if It's Admin Screen.
105 if ( is_admin() ) {
106 add_action( 'admin_head', 'icegram_show_upgrade_pro_notice', PHP_INT_MAX );
107 }
108
109 } elseif ( $icegram_is_premium_active && version_compare( $icegram_prem_plugin_version, '2.0.0', '>=' ) ) {
110 return;
111 }
112 }
113 }
114
115 /* ***************************** Initial Compatibility Work (End) ******************* */
116
117 if ( ! defined( 'ICEGRAM_PLUGIN_DIR' ) ) {
118 define( 'ICEGRAM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
119 }
120
121 if ( ! defined( 'ICEGRAM_PLUGIN_URL' ) ) {
122 define( 'ICEGRAM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
123 }
124
125 if ( ! defined( 'ICEGRAM_PLUGIN_FILE' ) ) {
126 define( 'ICEGRAM_PLUGIN_FILE', __FILE__ );
127 }
128
129 if ( ! defined( 'ICEGRAM_PLUGIN_VERSION' ) ) {
130 define( 'ICEGRAM_PLUGIN_VERSION', '3.1.37' );
131 }
132
133 if ( ! defined( 'ICEGRAM_PRODUCT_ID' ) ) {
134 define( 'ICEGRAM_PRODUCT_ID', 1000 );
135 }
136
137 require plugin_dir_path( __FILE__ ) . 'lite/class-icegram.php';
138 require plugin_dir_path( __FILE__ ) . 'lite/class-icegram-loader.php';
139
140
141 if ( ! function_exists( 'icegram_activate' ) ) {
142 /**
143 * The code that runs during plugin activation.
144 *
145 * @param bool $network_wide Is plugin being activated on a network.
146 */
147 function icegram_activate( $network_wide ) {
148
149 global $wpdb;
150 require_once plugin_dir_path( __FILE__ ) . 'lite/classes/class-icegram-activator.php';
151
152 if ( is_multisite() && $network_wide ) {
153
154 // Get all active blogs in the network and activate plugin on each one
155 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
156 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) );
157 foreach ( $blog_ids as $blog_id ) {
158 icegram_activate_on_blog( $blog_id );
159 }
160 } else {
161 Icegram_Activator::activate();
162 }
163 }
164 }
165
166 if ( ! function_exists( 'icegram_deactivate' ) ) {
167 /**
168 * The code that runs during plugin deactivation.
169 *
170 * @param bool $network_wide Is plugin being activated on a network.
171 *
172 */
173 function icegram_deactivate( $network_wide ) {
174
175 require_once plugin_dir_path( __FILE__ ) . 'lite/classes/class-icegram-deactivator.php';
176
177 if ( is_multisite() && $network_wide ) {
178
179 global $wpdb;
180
181 // Get all active blogs in the network.
182 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
183 $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE deleted = %d", 0 ) );
184 foreach ( $blog_ids as $blog_id ) {
185 // Run deactivation code on each one
186 icegram_trigger_deactivation_in_multisite( $blog_id );
187 }
188 } else {
189 Icegram_Deactivator::deactivate();
190 }
191 }
192 }
193
194 if ( ! function_exists( 'icegram_activate_on_blog' ) ) {
195
196 /**
197 * Function to trigger Icegram's activation code for individual site/blog in a network.
198 *
199 * @param int $blog_id Blog ID of newly created site/blog.
200 *
201 * @since 1.11.0
202 */
203 function icegram_activate_on_blog( $blog_id ) {
204 switch_to_blog( $blog_id );
205 Icegram_Activator::activate();
206 restore_current_blog();
207 }
208 }
209
210 if ( ! function_exists( 'icegram_trigger_deactivation_in_multisite' ) ) {
211
212 /**
213 * Function to trigger Icegram deactivation code for individual site in a network.
214 *
215 * @param int $blog_id Blog ID of newly created site/blog.
216 *
217 * @since 1.11.0
218 */
219 function icegram_trigger_deactivation_in_multisite( $blog_id ) {
220 switch_to_blog( $blog_id );
221 Icegram_Deactivator::deactivate();
222 restore_current_blog();
223 }
224 }
225
226 register_activation_hook( __FILE__, 'icegram_activate' );
227 register_deactivation_hook( __FILE__, 'icegram_deactivate' );
228
229 add_action( 'init', 'icegram_load_translations' );
230 if ( ! function_exists( 'icegram_load_translations' ) ) {
231 function icegram_load_translations() {
232 load_plugin_textdomain( 'icegram', false, ICEGRAM_PLUGIN_DIR . 'lite/lang/' );
233 }
234 }
235
236 add_action( 'plugins_loaded', 'icegram_initialize' );
237 if ( ! function_exists( 'icegram_initialize' ) ) {
238 function icegram_initialize() {
239 /* @var Icegram Object */
240 global $icegram;
241 $icegram = new Icegram();
242 do_action( 'icegram_loaded' );
243 }
244 }
245
246 add_filter( 'icegram-engage_is_page_for_notifications', 'icegram_show_notification');
247
248 if ( ! function_exists( 'icegram_show_notification' ) ) {
249
250 function icegram_show_notification(){
251
252 $screen = get_current_screen();
253
254 if( empty( $screen ) ){
255 return false;
256 }
257
258 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' ) ) ){
259 return true;
260 }
261 return false;
262
263 }
264 }
265
266 if ( ! function_exists( 'Icegram_Instance' ) ) {
267
268 /**
269 * Icegram instance
270 *
271 * @param string $plugin_path Plugin path from which files to load.
272 *
273 * @return Icegram
274 *
275 * @since 1.11.0
276 */
277 function Icegram_Instance( $plugin_path = '' ) {
278 $icegram_loader = Icegram_Loader::instance();
279 // Load files if plugin path given.
280 if ( ! empty( $plugin_path ) ) {
281 $icegram_loader->load_dependencies( $plugin_path );
282 }
283 return $icegram_loader;
284 }
285 }
286
287
288 $icegram_current_plugin_path = plugin_dir_path( __FILE__ );
289
290 /**
291 * We need to pass the plugin path explicitly using $current_plugin_path variable.
292 * We are not using ICEGRAM_PLUGIN_DIR constant here, since using ICEGRAM_PLUGIN_DIR constant causes premium version files not getting loaded when lite version is active and user is activating premium versions.
293 * In that case, value of ICEGRAM_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.
294 */
295 Icegram_Instance( $icegram_current_plugin_path );