PluginProbe
Icegram Collect – Easy Form, Lead Collection and Subscription plugin / trunk
Icegram Collect – Easy Form, Lead Collection and Subscription plugin vtrunk
trunk 0.10 0.11 0.12 0.13 0.14 0.14.1 0.14.2 0.15 0.16 0.16.1 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 All 74 releases
icegram-rainmaker / icegram-rainmaker.php

icegram-rainmaker.php in Icegram Collect – Easy Form, Lead Collection and Subscription plugin trunk, at icegram-rainmaker.php

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