PluginProbe
Icegram Collect – Easy Form, Lead Collection and Subscription plugin / 1.3.4
Icegram Collect – Easy Form, Lead Collection and Subscription plugin v1.3.4
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 1.3.4, at icegram-rainmaker.php

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