PluginProbe
Icegram Engage – Popups, Optins, CTAs & Lead Generation / 2.0.1
Icegram Engage – Popups, Optins, CTAs & Lead Generation v2.0.1
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 2.0.1, at icegram.php

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