Popups, Welcome Bar, Optins and Lead Generation Plugin – Icegram - Version 1.10.36

Version Description

Added Christmas Gallery Items

Download this release

Release Info

Developer Icegram
Plugin Icon 128x128 Popups, Welcome Bar, Optins and Lead Generation Plugin – Icegram
Version 1.10.36
Comparing to
See all releases

Code changes from version 1.10.35 to 1.10.36

assets/images/icon-64.png ADDED
Binary file
classes/class-icegram-message-admin.php CHANGED
@@ -258,7 +258,7 @@ if ( !class_exists( 'Icegram_Message_Admin' ) ) {
258
  <input type="text" class="message_field color-field" data-color-label="'.__( 'Background Color', 'icegram' ).'" name="message_data['.$message_id.'][form_bg_color]" id="message_form_bg_color" value="'. $form_bg_color .'" />
259
  <input type="text" class="message_field color-field" data-color-label="'.__( 'Text Color', 'icegram' ).'" name="message_data['.$message_id.'][form_text_color]" id="message_form_text_color" value="'.$form_text_color.'" style="margin-left:5em !important" />
260
  </p>';
261
- echo esc_html( $color_field_html );
262
  $active_plugins = get_option( 'active_plugins', array() );
263
  if (is_multisite()) {
264
  $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
@@ -626,7 +626,7 @@ if ( !class_exists( 'Icegram_Message_Admin' ) ) {
626
 
627
  case 'message_thumbnail':
628
  // echo "<img src='$bg_img' style='max-width: 200px; max-height: 100px;'>";
629
- echo "<img src='$bg_img' style='max-width: 100%; max-height: 100px;'>";
630
  break;
631
 
632
  default:
258
  <input type="text" class="message_field color-field" data-color-label="'.__( 'Background Color', 'icegram' ).'" name="message_data['.$message_id.'][form_bg_color]" id="message_form_bg_color" value="'. $form_bg_color .'" />
259
  <input type="text" class="message_field color-field" data-color-label="'.__( 'Text Color', 'icegram' ).'" name="message_data['.$message_id.'][form_text_color]" id="message_form_text_color" value="'.$form_text_color.'" style="margin-left:5em !important" />
260
  </p>';
261
+ echo $color_field_html ;
262
  $active_plugins = get_option( 'active_plugins', array() );
263
  if (is_multisite()) {
264
  $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
626
 
627
  case 'message_thumbnail':
628
  // echo "<img src='$bg_img' style='max-width: 200px; max-height: 100px;'>";
629
+ echo "<img src='".esc_attr($bg_img)."' style='max-width: 100%; max-height: 100px;'>";
630
  break;
631
 
632
  default:
classes/feedback.php CHANGED
@@ -30,6 +30,7 @@ if ( ! function_exists( 'ig_get_additional_info' ) ) {
30
  // IG Specific information
31
  $additional_info['plugin_meta_info'] = Icegram::get_ig_meta_info();
32
  }
 
33
  return $additional_info;
34
 
35
  }
@@ -37,3 +38,63 @@ if ( ! function_exists( 'ig_get_additional_info' ) ) {
37
  }
38
 
39
  add_filter( 'ig_additional_feedback_meta_info', 'ig_get_additional_info', 10, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  // IG Specific information
31
  $additional_info['plugin_meta_info'] = Icegram::get_ig_meta_info();
32
  }
33
+
34
  return $additional_info;
35
 
36
  }
38
  }
39
 
40
  add_filter( 'ig_additional_feedback_meta_info', 'ig_get_additional_info', 10, 2 );
41
+
42
+ if ( ! function_exists( 'ig_review_message_data' ) ) {
43
+ /**
44
+ * Filter 5 star review data
45
+ *
46
+ * @param $review_data
47
+ *
48
+ * @return mixed
49
+ *
50
+ * @since 1.10.36
51
+ */
52
+ function ig_review_message_data( $review_data ) {
53
+
54
+ $review_url = 'https://wordpress.org/support/plugin/icegram/reviews/';
55
+ $icon_url = IG_PLUGIN_URL . 'assets/images/icon-64.png';
56
+
57
+ $review_data['review_url'] = $review_url;
58
+ $review_data['icon_url'] = $icon_url;
59
+
60
+ return $review_data;
61
+ }
62
+ }
63
+
64
+ add_filter( 'ig_review_message_data', 'ig_review_message_data', 10 );
65
+
66
+ if ( ! function_exists( 'ig_can_ask_user_for_review' ) ) {
67
+ /**
68
+ * Can we ask user for 5 star review?
69
+ *
70
+ * @return bool
71
+ *
72
+ * @since 1.10.36
73
+ */
74
+ function ig_can_ask_user_for_review( $enable, $review_data ) {
75
+
76
+ if ( $enable ) {
77
+
78
+ $screen = get_current_screen();
79
+ if ( ! in_array( $screen->id, array( 'ig_campaign', 'ig_message', 'edit-ig_message', 'edit-ig_campaign' ), true ) ) {
80
+ return false;
81
+ }
82
+
83
+ if ( ! current_user_can( 'manage_options' ) ) {
84
+ return false;
85
+ }
86
+
87
+ $total_campaigns = wp_count_posts( 'ig_campaign' );
88
+ $total_campaigns_publish = $total_campaigns->publish;
89
+ $total_campaigns_draft = $total_campaigns->draft;
90
+
91
+ if ( $total_campaigns_draft == 0 && $total_campaigns_publish == 0 ) {
92
+ return false;
93
+ }
94
+ }
95
+
96
+ return $enable;
97
+ }
98
+ }
99
+
100
+ add_filter( 'ig_can_ask_user_for_review', 'ig_can_ask_user_for_review', 50, 2 );
classes/feedback/class-ig-feedback.php CHANGED
@@ -4,22 +4,30 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
- if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
8
  /**
9
  * IG Feedback
10
  *
11
  * The IG Feedback class adds functionality to get quick interactive feedback from users.
12
  * There are different types of feedabck widget like Stars, Emoji, Thubms Up/ Down, Number etc.
13
  *
14
- * @class IG_Feedback_V_1_0_11
15
- * @package feedback
16
  * @copyright Copyright (c) 2019, Icegram
17
  * @license https://opensource.org/licenses/gpl-license GNU Public License
18
  * @author Icegram
19
- * @since 1.0.0
20
  */
21
- class IG_Feedback_V_1_0_11 {
22
 
 
 
 
 
 
 
 
 
23
  /**
24
  * The API URL where we will send feedback data.
25
  *
@@ -104,8 +112,229 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
104
 
105
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
106
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
 
 
 
 
 
 
109
  public function render_deactivate_feedback() {
110
  add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
111
  add_action( 'admin_print_scripts', array( $this, 'css' ) );
@@ -127,19 +356,19 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
127
  * @since 1.0.1
128
  */
129
  public function enqueue_styles() {
130
- wp_register_style( 'sweetalert', plugin_dir_url( __FILE__ ) . 'assets/css/sweetalert2.min.css' );
131
  wp_enqueue_style( 'sweetalert' );
132
 
133
- wp_register_style( 'animate', plugin_dir_url( __FILE__ ) . 'assets/css/animate.min.css' );
134
  wp_enqueue_style( 'animate' );
135
 
136
- wp_register_style( 'ig-feedback-star-rating', plugin_dir_url( __FILE__ ) . 'assets/css/star-rating.min.css' );
137
  wp_enqueue_style( 'ig-feedback-star-rating' );
138
 
139
- wp_register_style( 'ig-feedback-emoji', plugin_dir_url( __FILE__ ) . 'assets/css/emoji.min.css' );
140
  wp_enqueue_style( 'ig-feedback-emoji' );
141
 
142
- wp_register_style( 'ig-feedback', plugin_dir_url( __FILE__ ) . 'assets/css/feedback.min.css' );
143
  wp_enqueue_style( 'ig-feedback' );
144
  }
145
 
@@ -152,7 +381,6 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
152
  *
153
  * @since 1.0.3
154
  */
155
-
156
  public function prepare_widget_params( $params = array() ) {
157
 
158
  $default_params = array(
@@ -176,6 +404,13 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
176
  return $params;
177
  }
178
 
 
 
 
 
 
 
 
179
  public function render_widget( $params = array() ) {
180
 
181
  $params = $this->prepare_widget_params( $params );
@@ -729,7 +964,7 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
729
  event.preventDefault();
730
  loader(true);
731
  if (!$form.find('input[type=radio]:checked').val()) {
732
- $form.find('.ig-deactivate-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', 'email-subscribers' ) ); ?></span>');
733
  return;
734
  }
735
 
@@ -924,34 +1159,34 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
924
 
925
  $options = array(
926
  1 => array(
927
- 'title' => esc_html__( 'I no longer need the plugin', 'email-subscribers' ),
928
  'slug' => 'i-no-longer-need-the-plugin'
929
  ),
930
  2 => array(
931
- 'title' => esc_html__( 'I\'m switching to a different plugin', 'email-subscribers' ),
932
  'slug' => 'i-am-switching-to-a-different-plugin',
933
- 'details' => esc_html__( 'Please share which plugin', 'email-subscribers' ),
934
  ),
935
  3 => array(
936
- 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'email-subscribers' ),
937
  'slug' => 'i-could-not-get-the-plugin-to-work'
938
  ),
939
  4 => array(
940
- 'title' => esc_html__( 'It\'s a temporary deactivation', 'email-subscribers' ),
941
  'slug' => 'it-is-a-temporary-deactivation'
942
  ),
943
  5 => array(
944
- 'title' => esc_html__( 'Other', 'email-subscribers' ),
945
  'slug' => 'other',
946
- 'details' => esc_html__( 'Please share the reason', 'email-subscribers' ),
947
  ),
948
  );
949
  ?>
950
  <div class="ig-deactivate-survey-modal" id="ig-deactivate-survey-<?php echo $this->plugin; ?>">
951
  <div class="ig-deactivate-survey-wrap">
952
  <form class="ig-deactivate-survey" method="post">
953
- <span class="ig-deactivate-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'email-subscribers' ); ?></span>
954
- <span class="ig-deactivate-survey-desc"><?php echo sprintf( esc_html__( 'If you have a moment, please share why you are deactivating %s:', 'email-subscribers' ), $this->name ); ?></span>
955
  <div class="ig-deactivate-survey-options">
956
  <?php foreach ( $options as $id => $option ) : ?>
957
  <div class="ig-deactivate-survey-option">
@@ -974,9 +1209,9 @@ if ( ! class_exists( 'IG_Feedback_V_1_0_11' ) ) {
974
  <input type="text" class="ig-deactivate-survey-info-email-address" id="ig-deactivate-survey-info-email-address" name="ig-deactivate-survey-info-email-address" value="<?php echo $email; ?>"/>
975
  </div>
976
  <div class="ig-deactivate-survey-footer">
977
- <button type="submit" class="ig-deactivate-survey-submit button button-primary button-large"><?php echo sprintf( esc_html__( 'Submit %s Deactivate', 'email-subscribers' ), '&amp;' ); ?></button>
978
  <img class="ig-deactivate-survey-loader" id="ig-deactivate-survey-loader" src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/images/loading.gif"/>
979
- <a href="#" class="ig-deactivate-survey-deactivate"><?php echo sprintf( esc_html__( 'Skip %s Deactivate', 'email-subscribers' ), '&amp;' ); ?></a>
980
  </div>
981
  </form>
982
  </div>
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
+ if ( ! class_exists( 'IG_Feedback_V_1_0_15' ) ) {
8
  /**
9
  * IG Feedback
10
  *
11
  * The IG Feedback class adds functionality to get quick interactive feedback from users.
12
  * There are different types of feedabck widget like Stars, Emoji, Thubms Up/ Down, Number etc.
13
  *
14
+ * @class IG_Feedback_V_1_0_15
15
+ * @since 1.0.0
16
  * @copyright Copyright (c) 2019, Icegram
17
  * @license https://opensource.org/licenses/gpl-license GNU Public License
18
  * @author Icegram
19
+ * @package feedback
20
  */
21
+ class IG_Feedback_V_1_0_15 {
22
 
23
+ /**
24
+ * Version of Feedback Library
25
+ *
26
+ * @since 1.0.13
27
+ * @var string
28
+ *
29
+ */
30
+ public $version = '1.0.15';
31
  /**
32
  * The API URL where we will send feedback data.
33
  *
112
 
113
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
114
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
115
+
116
+ /**
117
+ * Show 5 star review notice to user
118
+ *
119
+ * @since 1.0.12
120
+ */
121
+ add_action( 'admin_notices', array( &$this, 'show_review_notice' ) );
122
+ }
123
+
124
+ /**
125
+ * Ask for user review
126
+ *
127
+ * @since 1.0.12
128
+ */
129
+ public function show_review_notice() {
130
+
131
+ if ( ! defined( 'DOING_AJAX' ) && is_admin() ) {
132
+
133
+ $enable_review_notice = apply_filters( $this->plugin_abbr . '_enable_review_notice', true );
134
+
135
+ $can_ask_user_for_review = true;
136
+
137
+ if ( $enable_review_notice ) {
138
+
139
+ $current_user_id = get_current_user_id();
140
+
141
+ $review_done_option = $this->plugin_abbr . '_feedback_review_done';
142
+ $no_bug_option = $this->plugin_abbr . '_feedback_do_not_ask_again';
143
+ $already_did_option = $this->plugin_abbr . '_feedback_already_did';
144
+ $maybe_later_option = $this->plugin_abbr . '_feedback_maybe_later';
145
+ $review_done_time_option = $review_done_option . '_time';
146
+ $no_bug_time_option = $no_bug_option . '_time';
147
+ $already_did_time_option = $already_did_option . '_time';
148
+ $maybe_later_time_option = $maybe_later_option . '_time';
149
+
150
+ $no_bug_days_before = 1;
151
+ $no_bug_value = get_user_meta( $current_user_id, $no_bug_option, true );
152
+ $no_bug_time_value = get_user_meta( $current_user_id, $no_bug_time_option, true );
153
+
154
+ $review_done_value = get_user_meta( $current_user_id, $review_done_option, true );
155
+ $review_done_time_value = get_user_meta( $current_user_id, $review_done_time_option, true );
156
+
157
+ if ( ! empty( $no_bug_time_value ) && 0 !== $no_bug_time_value ) {
158
+ $no_bug_time_diff = time() - $no_bug_time_value;
159
+ $no_bug_days_before = floor( $no_bug_time_diff / 86400 ); // 86400 seconds == 1 day
160
+ }
161
+
162
+ $already_did_value = get_user_meta( $current_user_id, $already_did_option, true );
163
+ $already_did_time_value = get_user_meta( $current_user_id, $already_did_time_option, true );
164
+
165
+ $maybe_later_days_before = 1;
166
+ $maybe_later_value = get_user_meta( $current_user_id, $maybe_later_option, true );
167
+ $maybe_later_time_value = get_user_meta( $current_user_id, $maybe_later_time_option, true );
168
+
169
+ if ( $maybe_later_value && ! empty( $maybe_later_time_value ) && 0 !== $maybe_later_time_value ) {
170
+ $maybe_later_time_diff = time() - $maybe_later_time_value;
171
+ $maybe_later_days_before = floor( $maybe_later_time_diff / 86400 ); // 86400 seconds == 1 day
172
+ }
173
+
174
+ // Is user fall in love with our plugin in 15 days after when they said may be later?
175
+ // But, make sure we are asking user only after 15 days.
176
+ // We are good people. Respect the user decision.
177
+ if ( $review_done_value || $no_bug_value || $already_did_value || ( $maybe_later_value && $maybe_later_days_before < 15 ) || $already_did_value ) {
178
+ $can_ask_user_for_review = false;
179
+ }
180
+
181
+ $review_data = array(
182
+ 'review_done_value' => $review_done_value,
183
+ 'review_done_time_value' => $review_done_time_value,
184
+ 'no_bug_value' => $no_bug_value,
185
+ 'no_bug_time_value' => $no_bug_time_value,
186
+ 'maybe_later_value' => $maybe_later_value,
187
+ 'maybe_later_time_value' => $maybe_later_time_value,
188
+ 'already_did_value' => $already_did_value,
189
+ 'already_did_time_value' => $already_did_time_value,
190
+ );
191
+
192
+ $can_ask_user_for_review = apply_filters( $this->plugin_abbr . '_can_ask_user_for_review', $can_ask_user_for_review, $review_data );
193
+
194
+ if ( $can_ask_user_for_review ) {
195
+
196
+ $current_page_url = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
197
+
198
+ $got_feedback = false;
199
+ /************** Update Review Status ********************/
200
+ $nonce = ! empty( $_GET['ig_feedback_nonce'] ) ? esc_attr( wp_unslash( $_GET['ig_feedback_nonce'] ) ) : '';
201
+ $nonce_verified = wp_verify_nonce( $nonce, 'review' );
202
+
203
+ $action = '';
204
+ if ( $nonce_verified ) {
205
+ $action = ! empty( $_GET['ig_feedback_action'] ) ? esc_attr( wp_unslash( $_GET['ig_feedback_action'] ) ) : '';
206
+
207
+ if ( ! empty( $action ) && $this->is_valid_action( $action ) ) {
208
+ update_user_meta( $current_user_id, $action, 1 );
209
+ update_user_meta( $current_user_id, $action . "_time", time() );
210
+
211
+ // Got the review request?
212
+ // Redirect them to review page
213
+ if ( $action === $review_done_option ) {
214
+
215
+ $url = ! empty( $_GET['review_url'] ) ? $_GET['review_url'] : '';
216
+
217
+ if ( ! empty( $url ) ) {
218
+ ?>
219
+
220
+ <meta http-equiv="refresh" content="0; url=<?php echo $url; ?>"/>
221
+
222
+ <?php
223
+ }
224
+ }
225
+ }
226
+
227
+ $got_feedback = true;
228
+ }
229
+ /************** Update Review Status (End) ********************/
230
+
231
+ if ( ! $got_feedback ) {
232
+
233
+ $review_url = "https://wordpress.org/support/plugin/{$this->plugin}/reviews/";
234
+ $icon_url = plugin_dir_url( __FILE__ ) . 'assets/images/icon-64.png';
235
+ $message = __( sprintf( "<span><p>We hope you're enjoying <b>%s</b> plugin! Could you please do us a BIG favor and give us a 5-star rating on WordPress to help us spread the word and boost our motivation?</p>", $this->name ), $this->plugin );
236
+
237
+ $message_data = array(
238
+ 'review_url' => $review_url,
239
+ 'icon_url' => $icon_url,
240
+ 'message' => $message
241
+ );
242
+
243
+ $message_data = apply_filters( $this->plugin_abbr . '_review_message_data', $message_data );
244
+
245
+ $message = ! empty( $message_data['message'] ) ? $message_data['message'] : '';
246
+ $review_url = ! empty( $message_data['review_url'] ) ? $message_data['review_url'] : '';
247
+ $icon_url = ! empty( $message_data['icon_url'] ) ? $message_data['icon_url'] : '';
248
+
249
+ $nonce = wp_create_nonce( 'review' );
250
+
251
+ $review_url = add_query_arg( 'review_url', $review_url, add_query_arg( 'ig_feedback_nonce', $nonce, add_query_arg( 'ig_feedback_action', $review_done_option, $current_page_url ) ) );
252
+ $maybe_later_url = add_query_arg( 'ig_feedback_nonce', $nonce, add_query_arg( 'ig_feedback_action', $maybe_later_option, $current_page_url ) );
253
+ $already_did_url = add_query_arg( 'ig_feedback_nonce', $nonce, add_query_arg( 'ig_feedback_action', $already_did_option, $current_page_url ) );
254
+ $no_bug_url = add_query_arg( 'ig_feedback_nonce', $nonce, add_query_arg( 'ig_feedback_action', $no_bug_option, $current_page_url ) );
255
+
256
+ ?>
257
+
258
+ <style type="text/css">
259
+
260
+ .ig-feedback-notice-links li {
261
+ display: inline-block;
262
+ margin-right: 15px;
263
+ }
264
+
265
+ .ig-feedback-notice-links li a {
266
+ display: inline-block;
267
+ color: #10738b;
268
+ text-decoration: none;
269
+ padding-left: 26px;
270
+ position: relative;
271
+ }
272
+
273
+ .ig-feedback-notice {
274
+ display: flex;
275
+ align-items: center;
276
+ }
277
+
278
+ .ig-feedback-plugin-icon {
279
+ style =
280
+ float: left;
281
+ margin-right: 0.5em;
282
+ }
283
+
284
+ </style>
285
+
286
+ <?php
287
+
288
+ echo '<div class="notice notice-success ig-feedback-notice">';
289
+ echo '<span class="ig-feedback-plugin-icon"> <img src="' . $icon_url . '" alt="Logo"/></span>';
290
+ echo $message;
291
+ echo "<ul class='ig-feedback-notice-links'>";
292
+ echo sprintf( '<li><a href="%s" class="button-primary" target="_blank" data-rated="' . esc_attr__( "Thank You :) ",
293
+ $this->plugin ) . '"><span class="dashicons dashicons-external"></span>&nbsp;&nbsp;Ok, you deserve it</a></li> <li><a href="%s"><span class="dashicons dashicons-calendar-alt"></span>&nbsp;&nbsp;Maybe later</a></li><li><a href="%s"><span class="dashicons dashicons-smiley"></span>&nbsp;&nbsp;I already did!</a></li><li><a href="%s"><span class="dashicons dashicons-no"></span>&nbsp;&nbsp;Don\'t ask me again</a></li>',
294
+ esc_url( $review_url ), esc_url( $maybe_later_url ), esc_url( $already_did_url ), esc_url( $no_bug_url ) );
295
+ echo "</ul></span>";
296
+ echo '</div>';
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Is valid action?
305
+ *
306
+ * @param string $action
307
+ *
308
+ * @return bool
309
+ *
310
+ * @since 1.0.14
311
+ */
312
+ public function is_valid_action( $action = '' ) {
313
+ if ( empty( $action ) ) {
314
+ return false;
315
+ }
316
+
317
+ $available_actions = array(
318
+ '_feedback_review_done',
319
+ '_feedback_already_did',
320
+ '_feedback_maybe_later',
321
+ '_feedback_do_not_ask_again',
322
+ );
323
+
324
+ foreach ( $available_actions as $available_action ) {
325
+ if ( strpos( $action, $available_action ) !== false ) {
326
+ return true;
327
+ }
328
+ }
329
+
330
+ return false;
331
  }
332
 
333
+ /**
334
+ * Render Deactivation Feedback
335
+ *
336
+ * @since 1.0.0
337
+ */
338
  public function render_deactivate_feedback() {
339
  add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
340
  add_action( 'admin_print_scripts', array( $this, 'css' ) );
356
  * @since 1.0.1
357
  */
358
  public function enqueue_styles() {
359
+ wp_register_style( 'sweetalert', plugin_dir_url( __FILE__ ) . 'assets/css/sweetalert2.min.css', array(), $this->version );
360
  wp_enqueue_style( 'sweetalert' );
361
 
362
+ wp_register_style( 'animate', plugin_dir_url( __FILE__ ) . 'assets/css/animate.min.css', array(), $this->version );
363
  wp_enqueue_style( 'animate' );
364
 
365
+ wp_register_style( 'ig-feedback-star-rating', plugin_dir_url( __FILE__ ) . 'assets/css/star-rating.min.css', array(), $this->version );
366
  wp_enqueue_style( 'ig-feedback-star-rating' );
367
 
368
+ wp_register_style( 'ig-feedback-emoji', plugin_dir_url( __FILE__ ) . 'assets/css/emoji.min.css', array(), $this->version );
369
  wp_enqueue_style( 'ig-feedback-emoji' );
370
 
371
+ wp_register_style( 'ig-feedback', plugin_dir_url( __FILE__ ) . 'assets/css/feedback.min.css', array(), $this->version );
372
  wp_enqueue_style( 'ig-feedback' );
373
  }
374
 
381
  *
382
  * @since 1.0.3
383
  */
 
384
  public function prepare_widget_params( $params = array() ) {
385
 
386
  $default_params = array(
404
  return $params;
405
  }
406
 
407
+ /**
408
+ * Render Widget
409
+ *
410
+ * @param array $params
411
+ *
412
+ * @since 1.0.0
413
+ */
414
  public function render_widget( $params = array() ) {
415
 
416
  $params = $this->prepare_widget_params( $params );
964
  event.preventDefault();
965
  loader(true);
966
  if (!$form.find('input[type=radio]:checked').val()) {
967
+ $form.find('.ig-deactivate-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', $this->plugin ) ); ?></span>');
968
  return;
969
  }
970
 
1159
 
1160
  $options = array(
1161
  1 => array(
1162
+ 'title' => esc_html__( 'I no longer need the plugin', $this->plugin ),
1163
  'slug' => 'i-no-longer-need-the-plugin'
1164
  ),
1165
  2 => array(
1166
+ 'title' => esc_html__( 'I\'m switching to a different plugin', $this->plugin ),
1167
  'slug' => 'i-am-switching-to-a-different-plugin',
1168
+ 'details' => esc_html__( 'Please share which plugin', $this->plugin ),
1169
  ),
1170
  3 => array(
1171
+ 'title' => esc_html__( 'I couldn\'t get the plugin to work', $this->plugin ),
1172
  'slug' => 'i-could-not-get-the-plugin-to-work'
1173
  ),
1174
  4 => array(
1175
+ 'title' => esc_html__( 'It\'s a temporary deactivation', $this->plugin ),
1176
  'slug' => 'it-is-a-temporary-deactivation'
1177
  ),
1178
  5 => array(
1179
+ 'title' => esc_html__( 'Other', $this->plugin ),
1180
  'slug' => 'other',
1181
+ 'details' => esc_html__( 'Please share the reason', $this->plugin ),
1182
  ),
1183
  );
1184
  ?>
1185
  <div class="ig-deactivate-survey-modal" id="ig-deactivate-survey-<?php echo $this->plugin; ?>">
1186
  <div class="ig-deactivate-survey-wrap">
1187
  <form class="ig-deactivate-survey" method="post">
1188
+ <span class="ig-deactivate-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . esc_html__( 'Quick Feedback', $this->plugin ); ?></span>
1189
+ <span class="ig-deactivate-survey-desc"><?php echo sprintf( esc_html__( 'If you have a moment, please share why you are deactivating %s:', $this->plugin ), $this->name ); ?></span>
1190
  <div class="ig-deactivate-survey-options">
1191
  <?php foreach ( $options as $id => $option ) : ?>
1192
  <div class="ig-deactivate-survey-option">
1209
  <input type="text" class="ig-deactivate-survey-info-email-address" id="ig-deactivate-survey-info-email-address" name="ig-deactivate-survey-info-email-address" value="<?php echo $email; ?>"/>
1210
  </div>
1211
  <div class="ig-deactivate-survey-footer">
1212
+ <button type="submit" class="ig-deactivate-survey-submit button button-primary button-large"><?php echo sprintf( esc_html__( 'Submit %s Deactivate', $this->plugin ), '&amp;' ); ?></button>
1213
  <img class="ig-deactivate-survey-loader" id="ig-deactivate-survey-loader" src="<?php echo plugin_dir_url( __FILE__ ); ?>/assets/images/loading.gif"/>
1214
+ <a href="#" class="ig-deactivate-survey-deactivate"><?php echo sprintf( esc_html__( 'Skip %s Deactivate', $this->plugin ), '&amp;' ); ?></a>
1215
  </div>
1216
  </form>
1217
  </div>
classes/feedback/class-ig-tracker.php CHANGED
@@ -4,15 +4,15 @@ if ( ! defined( 'ABSPATH' ) ) {
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
- if ( ! class_exists( 'IG_Tracker_V_1_0_11' ) ) {
8
 
9
  /**
10
- * Class IG_Tracker_V_1_0_11
11
  *
12
  * Icegram tracker handler class is responsible for sending anonymous plugin
13
  * data to Icegram servers for users that actively allowed data tracking.
14
  *
15
- * @class IG_Tracker_V_1_0_11
16
  * @since 1.0.0
17
  *
18
  * @copyright Copyright (c) 2019, Icegram
@@ -20,7 +20,7 @@ if ( ! class_exists( 'IG_Tracker_V_1_0_11' ) ) {
20
  * @author Icegram
21
  * @package feedback
22
  */
23
- class IG_Tracker_V_1_0_11 {
24
 
25
  /**
26
  * Get Active, Inactive or all plugins info
4
  exit; // Exit if accessed directly.
5
  }
6
 
7
+ if ( ! class_exists( 'IG_Tracker_V_1_0_15' ) ) {
8
 
9
  /**
10
+ * Class IG_Tracker_V_1_0_15
11
  *
12
  * Icegram tracker handler class is responsible for sending anonymous plugin
13
  * data to Icegram servers for users that actively allowed data tracking.
14
  *
15
+ * @class IG_Tracker_V_1_0_15
16
  * @since 1.0.0
17
  *
18
  * @copyright Copyright (c) 2019, Icegram
20
  * @author Icegram
21
  * @package feedback
22
  */
23
+ class IG_Tracker_V_1_0_15 {
24
 
25
  /**
26
  * Get Active, Inactive or all plugins info
icegram.php CHANGED
@@ -3,7 +3,7 @@
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: 1.10.35
7
  * Author: icegram
8
  * Author URI: https://www.icegram.com/
9
  * Copyright (c) 2014-19 Icegram
@@ -15,215 +15,215 @@
15
  */
16
 
17
  /**
18
- * Main class Icegram
19
- */
20
  class Icegram {
21
 
22
- var $plugin_url;
23
- var $plugin_path;
24
- var $version;
25
- var $_wpautop_tags;
26
- var $message_types;
27
- var $message_type_objs;
28
- var $shortcode_instances;
29
- var $available_headlines;
30
- var $mode;
31
- var $cache_compatibility;
32
-
33
- public static $current_page_id;
34
-
35
- function __construct() {
36
- global $ig_feedback, $ig_tracker;
37
-
38
- $feedback_version = '1.0.11';
39
- $ig_tracker = 'IG_Tracker_V_' . str_replace('.', '_', $feedback_version);
40
-
41
- $this->version = "1.10.35";
42
- $this->shortcode_instances = array();
43
- $this->mode = 'local';
44
- $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
45
- $this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
46
- $this->include_classes( $feedback_version );
47
- $this->cache_compatibility = get_option('icegram_cache_compatibility', 'no');
48
-
49
- if( is_admin() ){
50
- $ig_feedback_class = 'IG_Feedback_V_' . str_replace('.', '_', $feedback_version);
51
- $ig_feedback = new $ig_feedback_class( 'Icegram', 'icegram', 'ig', 'igfree.', false );
52
- $ig_feedback->render_deactivate_feedback();
53
- }
54
-
55
- if( is_admin() && current_user_can( 'edit_posts' ) ) {
56
- $ig_campaign_admin = Icegram_Campaign_Admin::getInstance();
57
- $ig_message_admin = Icegram_Message_Admin::getInstance();
58
- add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_styles_and_scripts' ) );
59
- add_action( 'admin_print_styles', array( &$this, 'remove_preview_button' ) );
60
- add_filter( 'post_row_actions', array( &$this , 'remove_row_actions' ), 10, 2 );
61
-
62
- add_action( 'admin_menu', array( &$this, 'admin_menus') );
63
- add_action( 'admin_init', array( &$this, 'welcome' ) );
64
- add_action( 'admin_init', array( &$this, 'dismiss_admin_notice' ) );
65
-
66
- add_action( 'admin_init', array( &$this, 'import_gallery_item' ) );
67
-
68
- add_action( 'icegram_settings_after', array( &$this, 'klawoo_subscribe_form' ) );
69
- add_action( 'icegram_about_changelog', array( &$this, 'klawoo_subscribe_form' ) );
70
- add_action( 'icegram_settings_after', array( &$this, 'icegram_houskeeping' ) );
71
- add_action( 'admin_notices', array( &$this,'add_admin_notices'));
72
- add_filter( 'plugin_action_links', array($this, 'ig_plugin_settings_link'), 10, 2);
73
- } else {
74
- add_action( 'wp_footer', array( &$this, 'icegram_load_data' ));
75
- }
76
- if($this->cache_compatibility === 'no'){
77
- add_action( 'wp_footer', array( &$this, 'display_messages' ) );
78
- }
79
- add_shortcode( 'icegram', array( &$this, 'execute_shortcode' ) );
80
- add_shortcode( 'ig_form', array( &$this, 'execute_form_shortcode' ) );
81
- // WPML compatibility
82
- add_filter( 'icegram_identify_current_page', array( &$this, 'wpml_get_parent_id' ), 10 );
83
-
84
- add_filter( 'icegram_branding_data', array( &$this , 'branding_data_remove' ), 10 );
85
- add_action( 'wp_enqueue_scripts', array( &$this, 'identify_current_page' ) );
86
- add_filter( 'icegram_get_valid_campaigns_sql', array( &$this , 'append_to_valid_campaigns_sql' ), 10, 2 );
87
- add_action( 'icegram_print_js_css_data', array( &$this, 'print_js_css_data' ), 10, 1);
88
- // common
89
- add_action( 'init', array( &$this, 'register_campaign_post_type' ) );
90
- add_action( 'init', array( &$this, 'register_message_post_type' ) );
91
-
92
- add_action( 'icegram_loaded', array( &$this, 'load_compat_classes') );
93
-
94
- // execute shortcode in sidebar
95
- add_filter( 'widget_text', array(&$this, 'ig_widget_text_filter') );
96
-
97
- add_filter( 'rainmaker_validate_request', array(&$this,'form_submission_validate_request'), 10, 2);
98
- add_filter( 'icegram_data', array( $this, 'two_step_mobile_popup' ), 100, 1);
99
-
100
-
101
- if ( defined( 'DOING_AJAX' ) ) {
102
- if($this->cache_compatibility === 'yes'){
103
- add_action( 'wp_ajax_display_messages', array( &$this, 'display_messages' ) );
104
- add_action( 'wp_ajax_nopriv_display_messages', array( &$this, 'display_messages' ) );
105
- }
106
- add_action( 'wp_ajax_icegram_event_track', array( &$this, 'icegram_event_track' ) );
107
- add_action( 'wp_ajax_nopriv_icegram_event_track', array( &$this, 'icegram_event_track' ) );
108
- add_action( 'wp_ajax_klawoo_subscribe', array( &$this, 'klawoo_subscribe' ) );
109
- add_action( 'wp_ajax_icegram_run_housekeeping', array( &$this, 'run_housekeeping' ) );
110
- add_action( 'wp_ajax_save_gallery_data', array( &$this, 'save_gallery_data' ) );
111
-
112
- }
113
-
114
- }
115
- function ig_plugin_settings_link($links, $file){
116
- if ($file == plugin_basename(__FILE__)){
117
- $settings_link = '<a href="edit.php?post_type=ig_campaign&page=icegram-settings">'.__('Settings', 'icegram').'</a>';
118
- $support_link = '<a href="edit.php?post_type=ig_campaign&page=icegram-support">'.__('Support', 'icegram').'</a>';
119
- array_unshift($links, $support_link);
120
- array_unshift($links, $settings_link);
121
- }
122
- return $links;
123
-
124
- }
125
-
126
- public function load_compat_classes() {
127
-
128
- $compat_classes = (array) glob( $this->plugin_path . '/classes/compat/class-icegram-compat-*.php' );
129
- if (empty($compat_classes)) {
130
- return;
131
- }
132
-
133
- $active_plugins = (array) get_option('active_plugins', array());
134
- if (is_multisite()) {
135
- $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
136
- }
137
- $active_plugins = array_unique( array_merge( array_values($active_plugins), array_keys($active_plugins)) );
138
- $active_plugins_with_slugs = array();
139
- foreach ($active_plugins as $key => $value) {
140
- $slug = dirname( $value );
141
- if ($slug == '.') {
142
- unset($active_plugins[$key]);
143
- } else {
144
- $active_plugins[ $key ] = $slug;
145
- }
146
- }
147
-
148
- foreach ($compat_classes as $file) {
149
- if (is_file ( $file )) {
150
- $slug = str_replace('class-icegram-compat-', '', str_replace(".php", "", basename( $file )) );
151
- if ( in_array($slug, $active_plugins)) {
152
- include_once( $file );
153
- $class_name = 'Icegram_Compat_'. str_replace('-', '_', $slug);
154
- if ( class_exists( $class_name ) ) {
155
- new $class_name();
156
- }
157
- }
158
- }
159
- }
160
- }
161
- public function add_admin_notices(){
162
- $screen = get_current_screen();
163
- if ( !in_array( $screen->id, array( 'ig_campaign', 'ig_message','edit-ig_message','edit-ig_campaign' ), true ) ) return;
164
- //star review start
165
- $total_campaigns = wp_count_posts('ig_campaign');
166
- $total_campaigns_publish = $total_campaigns->publish;
167
- $total_campaigns_draft = $total_campaigns->draft;
168
- $ig_star_review = get_option('ig_star_review_icegram');
169
- $ig_rating_text = array();
170
- $ig_rating_text['star_review'] = __( 'If you like <strong>Icegram</strong>, please consider leaving us a <a target="_blank" href="https://wordpress.org/support/plugin/icegram/reviews/?filter=5#new-post">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating. A huge thank you from the team in advance!', 'icegram' );
171
- $ig_rating_text['help_review'] = __( 'If you like <strong>Icegram</strong>, tell us more about your experience and leave us <a target="_blank" href="https://wordpress.org/support/plugin/icegram/reviews/?filter=5#new-post">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating. A huge thank you from the team in advance!', 'icegram' );
172
-
173
- if (($total_campaigns_draft > 1 || $total_campaigns_publish >= 1) && $ig_star_review !== 'no' ) {
174
- $key = array_rand($ig_rating_text);
175
- $ig_rating_text = $ig_rating_text[$key];
176
- echo '<div class="notice notice-warning" style="background-color: #FFF;"><p style="letter-spacing: 0.6px;">' . $ig_rating_text . ' <a style="float:right" class="ig-admin-btn ig-admin-btn-secondary" href="?ig_dismiss_admin_notice=1&option_name=ig_star_review">' . __( 'No, I don\'t like it', 'icegram' ) . '</a></p></div>';
177
- }
178
- //star review end
179
- //bfcm 2019 :start
180
- $timezone_format = _x('Y-m-d', 'timezone date format');
181
- $ig_current_date = strtotime(date_i18n($timezone_format));
182
- $ig_offer_start = strtotime("2019-11-22");
183
- $ig_offer_end = strtotime("2019-12-03");
184
- if(($ig_current_date >= $ig_offer_start) && ($ig_current_date <= $ig_offer_end)) {
185
- include_once('ig-offer.php');
186
- }
187
- //bfcm 2019 :end
188
-
189
- }
190
- public function dismiss_admin_notice(){
191
- if(isset($_GET['ig_dismiss_admin_notice']) && $_GET['ig_dismiss_admin_notice'] == '1' && isset($_GET['ig_option_name'])){
192
- $option_name = sanitize_text_field( $_GET['ig_option_name'] );
193
- update_option($option_name.'_icegram', true);
194
- if($option_name === 'ig_offer_bfcm_done_2019' || $option_name === 'ig_offer_last_day_bfcm_done_2019' ){
195
- header("Location: https://www.icegram.com/?utm_source=in_app&utm_medium=ig_banner&utm_campaign=ig-bfcm-2019");
196
- exit();
197
- }else{
198
- $referer = wp_get_referer();
199
- wp_safe_redirect( $referer );
200
- exit();
201
- }
202
- }
203
- }
204
-
205
- public function klawoo_subscribe_form() {
206
- ?>
207
  <div class="wrap">
208
- <?php
209
- if ( stripos(get_current_screen()->base, 'settings') !== false ) {
210
- echo "<h2>".__( 'Free Add-ons, Proven Marketing Tricks and Updates', 'icegram' )."</h2>";
211
- }
212
- $current_user = wp_get_current_user();
213
- $customer_email = $current_user->user_email;
214
- ?>
215
  <table class="form-table">
216
- <tr>
217
  <th scope="row"><?php _e( 'Get add-ons and tips...', 'icegram' ) ?></th>
218
  <td>
219
  <form name="klawoo_subscribe" action="#" method="POST" accept-charset="utf-8">
220
- <input class="ltr" type="text" name="name" id="name" placeholder="Name" />
221
- <input class="regular-text ltr" type="text" name="email" id="email" placeholder="Email" value="<?php echo $customer_email?>" />
222
  <input type="hidden" name="list" value="7I763v6Ldrs3YhJeee5EOgFA"/>
223
  <input type="submit" name="submit" id="submit" class="button button-primary" value="Subscribe">
224
  <br><br>
225
- <input type="checkbox" name="es-gdpr-agree" id ="es-gdpr-agree" value="1" required="required">
226
- <label for="es-gdpr-agree"><?php echo sprintf(__( 'I have read and agreed to our %s.', 'icegram' ), '<a href="https://www.icegram.com/privacy-policy/" target="_blank">' . __( 'Privacy Policy', 'icegram' ) . '</a>' ); ?></label>
227
  <br>
228
  </form>
229
  <div id="klawoo_response"></div>
@@ -232,1365 +232,1384 @@ class Icegram {
232
  </table>
233
  </div>
234
  <script type="text/javascript">
235
- jQuery(function () {
236
- jQuery("form[name=klawoo_subscribe]").submit(function (e) {
237
- e.preventDefault();
238
-
239
- jQuery('#klawoo_response').html('');
240
- params = jQuery("form[name=klawoo_subscribe]").serializeArray();
241
- params.push( {name: 'action', value: 'klawoo_subscribe' });
242
-
243
- jQuery.ajax({
244
- method: 'POST',
245
- type: 'text',
246
- url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
247
- data: params,
248
- success: function(response) {
249
- if (response != '') {
250
- jQuery('#klawoo_response').html(response);
251
- } else {
252
- jQuery('#klawoo_response').html('error!');
253
- }
254
- }
255
- });
256
- });
257
- });
258
  </script>
259
- <?php
260
- }
261
-
262
-
263
- public function klawoo_subscribe() {
264
- $url = 'http://app.klawoo.com/subscribe';
265
-
266
- if( !empty( $_POST ) ) {
267
- $params = $_POST;
268
- } else {
269
- exit();
270
- }
271
- $method = 'POST';
272
- $qs = http_build_query( $params );
273
-
274
- $options = array(
275
- 'timeout' => 15,
276
- 'method' => $method
277
- );
278
-
279
- if ( $method == 'POST' ) {
280
- $options['body'] = $qs;
281
- } else {
282
- if ( strpos( $url, '?' ) !== false ) {
283
- $url .= '&'.$qs;
284
- } else {
285
- $url .= '?'.$qs;
286
- }
287
- }
288
-
289
- $response = wp_remote_request( $url, $options );
290
- if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
291
- $data = $response['body'];
292
- if ( $data != 'error' ) {
293
-
294
- $message_start = substr( $data, strpos( $data,'<body>' ) + 6 );
295
- $remove = substr( $message_start, strpos( $message_start,'</body>' ) );
296
- $message = trim( str_replace( $remove, '', $message_start ) );
297
- echo ( $message );
298
- exit();
299
- }
300
- }
301
- exit();
302
- }
303
-
304
- public function icegram_houskeeping(){
305
- ?>
306
  <div class="wrap">
307
- <?php
308
- if ( stripos(get_current_screen()->base, 'settings') !== false ) {
309
- ?>
310
- <form name="icegram_housekeeping" action="#" method="POST" accept-charset="utf-8">
311
- <h2><?php _e( 'Housekeeping', 'icegram' ) ?></h2>
312
- <p class="ig_housekeeping">
313
- <label for="icegram_remove_shortcodes">
314
- <input type="checkbox" name="icegram_remove_shortcodes" value="yes" />
315
- <?php _e( 'Remove all Icegram shortcodes', 'icegram' ); ?>
316
- </label>
317
- <br/><br/>
318
- <label for="icegram_remove_all_data">
319
- <input type="checkbox" name="icegram_remove_all_data" value="yes" />
320
- <?php _e( 'Remove all Icegram campaigns and messages', 'icegram' ); ?>
321
- </label>
322
- <br/><br/>
323
- <img alt="" src="<?php echo admin_url( 'images/wpspin_light.gif' ) ?>" class="ig_loader" style="vertical-align:middle;display:none" />
324
- <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Clean Up', 'icegram' ); ?>">
325
- <div id="icegram_housekeeping_response"></div>
326
- </p>
327
- </form>
328
-
329
  </div>
330
  <script type="text/javascript">
331
- jQuery(function () {
332
- jQuery("form[name=icegram_housekeeping]").submit(function (e) {
333
- if(confirm("<?php _e( 'You won\'t be able to recover this data once you proceed. Do you really want to perform this action?', 'icegram' ); ?>") == true){
334
- e.preventDefault();
335
- jQuery('.ig_loader').show();
336
- jQuery('#icegram_housekeeping_response').text("");
337
- params = jQuery("form[name=icegram_housekeeping]").serializeArray();
338
- params.push( {name: 'action', value: 'icegram_run_housekeeping' });
339
- params.push( {name: 'security', value: '<?php echo wp_create_nonce('ig_run_housekeeping'); ?> '});
340
-
341
- jQuery.ajax({
342
- method: 'POST',
343
- type: 'text',
344
- url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
345
- data: params,
346
- success: function(response) {
347
- jQuery('.ig_loader').hide();
348
- jQuery('#icegram_housekeeping_response').text("<?php _e('Done!', 'icegram'); ?>");
349
- }
350
- });
351
- }
352
- });
353
- });
354
  </script>
355
- <?php
356
- }
357
- }
358
- public function run_housekeeping() {
359
- check_ajax_referer('ig_run_housekeeping', 'security');
360
- global $wpdb, $current_user;
361
- $params = $_POST;
362
- $_POST = array();
363
- if(current_user_can( 'manage_options' ) && !empty($params['icegram_remove_shortcodes']) && $params['icegram_remove_shortcodes'] == 'yes') {
364
- // first get all posts with [icegram] shortcode in them
365
- $sql = "SELECT * FROM `$wpdb->posts` WHERE `post_content` LIKE '%[icegram %]%' and `post_type` != 'revision' ";
366
- $posts = $wpdb->get_results($sql, OBJECT);
367
- if ( !empty($posts) && is_array($posts) ) {
368
- foreach ($posts as $post) {
369
- $post_content = $post->post_content;
370
- // remove shortcode with regexp now
371
- $re = "/\\[icegram(.)*\\]/i";
372
- $post_content = preg_replace($re, '', $post_content);
373
- // save post content back
374
- if ($post_content && $post_content != $post->post_content) {
375
- wp_update_post( array ( 'ID' => $post->ID,
376
- 'post_content' => $post_content
377
- ) );
378
- }
379
- }
380
- }
381
- }
382
-
383
- if(!empty($params['icegram_remove_all_data']) && $params['icegram_remove_all_data'] == 'yes') {
384
- $posts = get_posts( array( 'post_type' => array( 'ig_campaign', 'ig_message' ) ) );
385
- if ( !empty($posts) && is_array($posts) ) {
386
- foreach ($posts as $post) {
387
- wp_delete_post( $post->ID, true);
388
- }
389
- }
390
- do_action('icegram_remove_all_data');
391
- }
392
- $_POST = $params;
393
- }
394
-
395
- public function icegram_event_track() {
396
- if( !empty($_POST['ig_local_url_cs']) && isset($_SERVER['HTTP_ORIGIN']) ){
397
- $parts = parse_url($_POST['ig_local_url_cs']);
398
- $base_url = $parts["scheme"] . "://" . $parts["host"];
399
- header('Access-Control-Allow-Origin: '.$base_url);
400
- header('Access-Control-Allow-Credentials: true');
401
- }
402
-
403
- if( !empty( $_POST['event_data'] ) ) {
404
- foreach ( $_POST['event_data'] as $event ) {
405
- switch ($event['type']) {
406
- case 'shown':
407
- if (is_array($event['params']) && !empty($event['params']['message_id'])) {
408
- $messages_shown[] = $event['params']['message_id'];
409
- if(!empty($event['params']['expiry_time'])){
410
- if($event['params']['expiry_time'] =='today'){
411
- $event['params']['expiry_time'] = strtotime('+1 day', mktime(0, 0, 0));
412
- }else if($event['params']['expiry_time'] == 'current_session'){
413
- $event['params']['expiry_time'] = 0;
414
- }else{
415
- $event['params']['expiry_time'] = strtotime($event['params']['expiry_time']);
416
- }
417
-
418
- $event['default'] = true;
419
- $event = apply_filters('icegram_check_event_track', $event);
420
- if($event['default']){
421
- setcookie('icegram_campaign_shown_'.floor($event['params']['campaign_id']),true , $event['params']['expiry_time'] , '/');
422
- }
423
- }
424
- }
425
- break;
426
- case 'clicked':
427
- if (is_array($event['params']) && !empty($event['params']['message_id'])) {
428
- $messages_clicked[] = $event['params']['message_id'];
429
- if(!empty($event['params']['expiry_time_clicked'])){
430
- if($event['params']['expiry_time_clicked'] =='today'){
431
- $event['params']['expiry_time_clicked'] = strtotime('+1 day', mktime(0, 0, 0));
432
- }else if($event['params']['expiry_time_clicked'] == 'current_session'){
433
- $event['params']['expiry_time_clicked'] = 0;
434
- }else{
435
- $event['params']['expiry_time_clicked'] = strtotime($event['params']['expiry_time_clicked']);
436
- }
437
- //setcookie('icegram_messages_clicked_'.$event['params']['message_id'],true , $event['params']['expiry_time_clicked'] , '/' );
438
- setcookie('icegram_campaign_clicked_'.floor($event['params']['campaign_id']),true , $event['params']['expiry_time_clicked'] , '/' );
439
- }
440
- }
441
- break;
442
-
443
- default:
444
- break;
445
- }
446
-
447
- // Emit event for other plugins to handle it
448
- do_action('icegram_event_track', $event);
449
- do_action('icegram_event_track_'.$event['type'], $event['params']);
450
- }
451
- }
452
- exit();
453
- }
454
-
455
- static function install() {
456
- // Redirect to welcome screen
457
- delete_option( '_icegram_activation_redirect' );
458
- add_option( '_icegram_activation_redirect', 'pending' );
459
- }
460
-
461
- public function welcome() {
462
-
463
- $this->db_update();
464
- // Bail if no activation redirect transient is set
465
- if ( false === get_option( '_icegram_activation_redirect' ) )
466
- return;
467
-
468
- // Delete the redirect transient
469
- delete_option( '_icegram_activation_redirect' );
470
-
471
- wp_redirect( admin_url( 'edit.php?post_type=ig_campaign&page=icegram-support' ) );
472
- exit;
473
- }
474
-
475
- function db_update() {
476
- $current_db_version = get_option( 'icegram_db_version' );
477
- if ( !$current_db_version || version_compare( $current_db_version, '1.2', '<' ) ) {
478
- include( 'updates/icegram-update-1.2.php' );
479
- }
480
- }
481
-
482
- public function admin_menus() {
483
-
484
- $welcome_page_title = __( 'Welcome to Icegram', 'icegram' );
485
- $gallery_page_title = '<span style="color:#f18500;font-weight:bolder;">' . __( 'Gallery', 'icegram' ).'<span>';
486
- $gallery = add_submenu_page( 'edit.php?post_type=ig_campaign', $gallery_page_title, $gallery_page_title, 'manage_options', 'icegram-gallery', array( $this, 'gallery_screen' ) );
487
- $settings_page_title = __( 'Settings', 'icegram' );
488
- $upgrade_page_title = '<span style="color:#f18500;font-weight:bolder;">'.__( 'Upgrade', 'icegram' ) .'</span>';
489
-
490
- $menu_title = __( 'Docs & Support', 'icegram' );
491
- $about = add_submenu_page( 'edit.php?post_type=ig_campaign', $welcome_page_title, $menu_title, 'manage_options', 'icegram-support', array( $this, 'about_screen' ) );
492
- $settings = add_submenu_page( 'edit.php?post_type=ig_campaign', $settings_page_title, $settings_page_title, 'manage_options', 'icegram-settings', array( $this, 'settings_screen' ) );
493
- $upgrade = add_submenu_page( 'edit.php?post_type=ig_campaign', $upgrade_page_title, $upgrade_page_title, 'manage_options', 'icegram-upgrade', array( $this, 'upgrade_screen' ) );
494
-
495
-
496
- add_action( 'admin_print_styles-'. $about, array( $this, 'admin_css' ) );
497
- add_action( 'admin_print_styles-'. $settings, array( $this, 'admin_css' ) );
498
- add_action( 'admin_print_styles-'. $upgrade, array( $this, 'admin_css' ) );
499
-
500
- }
501
-
502
- public function admin_css() {
503
- wp_enqueue_style( 'icegram-activation', $this->plugin_url . '/assets/css/admin.min.css' );
504
- }
505
-
506
- public function about_screen() {
507
-
508
- // Import data if not done already
509
- if( false === get_option( 'icegram_sample_data_imported' ) ) {
510
- $this->import_sample_data( $this->get_sample_data() );
511
- }
512
-
513
- include ( 'about-icegram.php' );
514
- }
515
-
516
- public function settings_screen() {
517
- include ( 'settings.php' );
518
- }
519
-
520
- public function upgrade_screen() {
521
- // include ( 'addons.php' );
522
- }
523
-
524
- public function check_for_gallery_items( $force_update = false ) {
525
- global $icegram;
526
- if ( $force_update === true || false === ( $ig_last_gallery_item_update = get_transient( 'ig_last_gallery_item_update' ) ) ) {
527
- // $url_for_gallery_item = 'https://www.icegram.com/gallery/wp-json/wp/v2/galleryitem?per_page=200&page=1';
528
- $url_for_gallery_item = 'https://www.icegram.com/gallery/wp-json/wp/v2/galleryitem?filter[posts_per_page]=200';
529
- $ig_gallery_json = wp_remote_get( $url_for_gallery_item );
530
- if ( ! is_wp_error( $ig_gallery_json ) ) {
531
- $ig_gallery_json = ( wp_remote_retrieve_body( $ig_gallery_json ) );
532
- if ( !empty($ig_gallery_json) ) {
533
- update_option( 'ig_last_gallery_items', $ig_gallery_json );
534
- }
535
- }else{
536
- update_option( 'requested_gallery_item_with_ajax', 'yes');
537
- ?>
 
 
 
538
  <script type="text/javascript">
539
- jQuery(document).ready(function(){
540
- jQuery.ajax({
541
- url: '<?php echo esc_url( $url_for_gallery_item ); ?>',
542
- method: 'GET',
543
- dataType: 'json',
544
- success: function( response ) {
545
- if ( response != undefined && response != '' ) {
546
- //ajax to save data
547
- jQuery.ajax({
548
- url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
549
- method: 'POST',
550
- dataType: 'json',
551
- data: {
552
- action: 'save_gallery_data',
553
- galleryitems: JSON.stringify(response),
554
- security: '<?php echo wp_create_nonce( 'gallery-save-data' ); // WPCS: XSS ok. ?>'
555
- },
556
- success: function( res ) {
557
- if ( res != undefined && res != '' && res.success != undefined && res.success == 'yes' ) {
558
- // All done.
559
- }
560
- }
561
- });
562
- }
563
- },
564
- error : function (response){
565
- console.log(response, 'res');
566
-
567
- }
568
- });
569
- });
570
  </script>
571
- <?php }
572
- $url_for_categories = 'https://www.icegram.com/gallery/wp-json/wp/v2/custom_cat?filter[orderby]=parent&order=desc';
573
- $options = array(
574
- 'timeout' => 15,
575
- 'method' => 'GET',
576
- 'body' => ''
577
- );
578
- $response = wp_remote_request( $url_for_categories, $options );
579
- $response_code = wp_remote_retrieve_response_code( $response );
580
- // $body = json_decode($response['body'] ,true);
581
- if ( $response_code == 200 ) {
582
- $categories = json_decode($response['body'] ,true);
583
- $cat_list = array();
584
- foreach ($categories as $category) {
585
- if($category['parent'] == 0 ){
586
- $cat_list[$category['term_id']]['name'] = $category['name'] ;
587
- $cat_list[$category['term_id']]['slug'] = $category['slug'] ;
588
- $cat_list[$category['term_id']]['term_id'] = $category['term_id'] ;
589
- }else{
590
- $cat_list[$category['parent']]['list'][] = $category;
591
- }
592
- }
593
- $featured_cat = $cat_list[53];
594
- unset( $cat_list[53]);
595
- array_unshift($cat_list, $featured_cat);
596
- update_option( 'ig_cat_list', $cat_list );
597
- }else{
598
- ?>
599
- <script type="text/javascript">
600
- jQuery(document).ready(function(){
601
- jQuery.ajax({
602
- url: '<?php echo esc_url( $url_for_categories ); ?>',
603
- method: 'GET',
604
- dataType: 'json',
605
- success: function( response ) {
606
-
607
- if ( response != undefined && response != '' ) {
608
- //ajax to save data
609
- jQuery.ajax({
610
- url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
611
- method: 'POST',
612
- dataType: 'json',
613
- data: {
614
- action: 'save_gallery_data',
615
- categories: response,
616
- security: '<?php echo wp_create_nonce( 'gallery-save-data' ); // WPCS: XSS ok. ?>'
617
- },
618
- success: function( res ) {
619
- if ( res != undefined && res != '' && res.success != undefined && res.success == 'yes' ) {
620
- // All done.
621
- }
622
- }
623
- });
624
- }
625
- },
626
- error : function (response){
627
- console.log(response, 'res');
628
-
629
- }
630
- });
631
- });
632
  </script>
633
- <?php
634
- }
635
- set_transient( 'ig_last_gallery_item_update', current_time( 'timestamp') , 24 * HOUR_IN_SECONDS ); // 1 day
636
- }
637
- }
638
-
639
- public function save_gallery_data(){
640
- check_ajax_referer( 'gallery-save-data', 'security' );
641
- if ( current_user_can( 'manage_options' ) ) {
642
- if(!empty($_REQUEST) && !empty($_REQUEST['galleryitems'])){
643
- $ig_gallery_json = stripslashes($_REQUEST['galleryitems']);
644
- update_option( 'ig_last_gallery_items', $ig_gallery_json );
645
- }
646
- if(!empty($_REQUEST) && !empty($_REQUEST['categories'])){
647
- $categories = $_REQUEST['categories'];
648
- $cat_list = array();
649
- foreach ($categories as $category) {
650
- if($category['parent'] == 0 ){
651
- $cat_list[$category['term_id']]['name'] = $category['name'] ;
652
- $cat_list[$category['term_id']]['slug'] = $category['slug'] ;
653
- }else{
654
- $cat_list[$category['parent']]['list'][] = $category;
655
- }
656
- }
657
- update_option( 'ig_cat_list', $cat_list );
658
- }
659
- }
660
-
661
- }
662
-
663
- public static function gallery_screen() {
664
- global $icegram;
665
- //check for new gallery item
666
- $ig_last_gallery_item_update = get_transient('ig_last_gallery_item_update' );
667
-
668
- if(empty($ig_last_gallery_item_update)){
669
- $icegram->check_for_gallery_items(true);
670
- }
671
- $ig_gallery_items = get_option('ig_last_gallery_items',true);
672
- $cat_list = get_option('ig_cat_list',true);
673
- include ( 'gallery.php' );
674
- wp_register_script('ig_gallery_js', $icegram->plugin_url . '/assets/js/gallery.min.js', array ( 'jquery', 'backbone', 'wp-backbone', 'wp-a11y', 'wp-util' ), $icegram->version, true);
675
- if( !wp_script_is( 'ig_gallery_js' ) ) {
676
- wp_enqueue_script( 'ig_gallery_js' );
677
- $imported_gallery_items = get_option('ig_imported_gallery_items',true);
678
- $ig_plan = get_option('ig_engage_plan');
679
- $ig_plan = (!empty($ig_plan)) ? (($ig_plan == 'plus') ? 1 :(($ig_plan == 'pro') ? 2 : (($ig_plan == 'max') ? 3 : 0))) : 0;
680
- $ig_gallery_json =
681
- wp_localize_script( 'ig_gallery_js', '_wpThemeSettings', array(
682
- 'themes' => json_decode($ig_gallery_items, true),
683
- 'settings' => array(
684
- 'canInstall' => ( ! is_multisite() && ( 'install_themes' ) ),
685
- 'isInstall' => true,
686
- 'installURI' => ( ! is_multisite() && ( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
687
- 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'icegram' ),
688
- 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ),
689
- 'ig_plan' => $ig_plan,
690
- 'cat_list' => $cat_list
691
- ),
692
- 'l10n' => array(
693
- 'addNew' => __( 'Add New Gallery Templates', 'icegram'),
694
- 'search' => __( 'Search Gallery Templates', 'icegram'),
695
- 'searchPlaceholder' => __( 'Search Design Templates', 'icegram'), // placeholder (no ellipsis)
696
- 'themesFound' => __( 'Number of Gallery Templates found: %d', 'icegram'),
697
- 'noThemesFound' => __( 'No Gallery Templates found. Try a different search.', 'icegram'),
698
- ),
699
- 'installedThemes' => $imported_gallery_items
700
- ) );
701
- }
702
- }
703
-
704
- public function branding_data_remove( $icegram_branding_data ) {
705
- if( !empty( $icegram_branding_data ) && 'yes' != get_option('icegram_share_love', 'no') ) {
706
- $icegram_branding_data['powered_by_logo'] = '';
707
- $icegram_branding_data['powered_by_text'] = '';
708
- }
709
- return $icegram_branding_data;
710
- }
711
-
712
- //Execute Form shortcode
713
- function execute_form_shortcode( $atts = array() ) {
714
- return '<div class="ig_form_container layout_inline"></div>';
715
- }
716
-
717
- function execute_shortcode( $atts = array() , $content = null ) {
718
- // When shortcode is called, it will only prepare an array with conditions
719
- // And add a placeholder div
720
- // Display will happen in footer via display_messages()
721
- $i = count($this->shortcode_instances);
722
- $this->shortcode_instances[ $i ] = shortcode_atts( array(
723
- 'campaigns' => '',
724
- 'messages' => '',
725
- 'skip_others' => 'no'
726
- ), $atts );
727
-
728
- $class[] = "ig_shortcode_container";
729
- $html[] = "<div id='icegram_shortcode_{$i}'";
730
- if(!empty($atts['campaigns']) && !empty($content)){
731
- $this->shortcode_instances[ $i ]['with_content'] = true;
732
- $class[] = "trigger_onclick";
733
- }
734
- foreach ($atts as $key => $value) {
735
- $value = str_replace(",", " ", $value);
736
- $html[] = " data-{$key}=\"".htmlentities($value)."\" ";
737
- }
738
- $class = implode(" ", $class);
739
- $html[] = "class='".$class."' >".$content."</div>";
740
- return implode(" ", $html);
741
- }
742
-
743
- // Do not index Icegram campaigns / messages...
744
- // Not using currently - made custom post types non public...
745
- function icegram_load_data() {
746
- global $post;
747
- $icegram_pre_data['ajax_url'] = admin_url( 'admin-ajax.php' );
748
- $icegram_pre_data['post_obj'] = $_GET;
749
- $icegram_pre_data['post_obj']['is_home'] = (is_home() || is_front_page()) ? true : false;
750
- $icegram_pre_data['post_obj']['page_id'] = is_object($post) && isset($post->ID) ? $post->ID : 0;
751
- $icegram_pre_data['post_obj']['action'] = 'display_messages';
752
- $icegram_pre_data['post_obj']['shortcodes'] = $this->shortcode_instances;
753
- $icegram_pre_data['post_obj']['cache_compatibility'] = $this->cache_compatibility;
754
- $icegram_pre_data['post_obj']['device'] = $this->get_platform();
755
- wp_register_script('icegram_main_js', $this->plugin_url . '/assets/js/main.min.js', array ( 'jquery' ), $this->version, true);
756
- if( !wp_script_is( 'icegram_main_js' ) ) {
757
- wp_enqueue_script( 'icegram_main_js' );
758
- wp_localize_script( 'icegram_main_js', 'icegram_pre_data', $icegram_pre_data);
759
- }
760
- }
761
-
762
- function display_messages() {
763
-
764
- $skip_others = $preview_mode = false;
765
- $campaign_ids = $message_ids = array();
766
- $this->shortcode_instances = ($this->cache_compatibility == 'yes' && !empty($_REQUEST['shortcodes'])) ? $_REQUEST['shortcodes'] : $this->shortcode_instances;
767
- // Pull in message and campaign IDs from shortcodes - if set
768
- if( !empty( $this->shortcode_instances ) ) {
769
- foreach ($this->shortcode_instances as $i => $value) {
770
- $cids = array_map( 'trim', (array) explode( ',', intval($value['campaigns']) ) );
771
- $mids = array_map( 'trim', (array) explode( ',', intval($value['messages']) ) );
772
- if (!empty($value['skip_others']) && $value['skip_others'] == 'yes' && (!empty($cids) || !empty($mids))) {
773
- $skip_others = true;
774
- }
775
- $campaign_ids = array_merge($campaign_ids, $cids);
776
- $message_ids = array_merge($message_ids, $mids);
777
- }
778
- }
779
- if( !empty( $_REQUEST['campaign_preview_id'] ) && intval($_REQUEST['campaign_preview_id']) && ( 'edit_posts' ) ) {
780
- $campaign_ids = array( intval($_REQUEST['campaign_preview_id']) );
781
- $preview_mode = true;
782
- }
783
-
784
-
785
- $messages = $this->get_valid_messages( $message_ids, $campaign_ids, $preview_mode, $skip_others );
786
-
787
- if( empty( $messages ) ) {
788
- //wp_die(0);
789
- return;
790
- }
791
-
792
- $messages_to_show_ids = array();
793
- foreach ( $messages as $key => $message_data ) {
794
-
795
- if( !is_array( $message_data ) || empty( $message_data ) ) {
796
- continue;
797
- }
798
-
799
- // Don't show a seen message again - if needed
800
- // change to campaign targetting in v1.9.1
801
- if( !empty( $message_data['id'] ) &&
802
- empty( $_GET['campaign_preview_id'] ) &&
803
- !empty( $message_data['retargeting'] ) &&
804
- $message_data['retargeting'] == 'yes'
805
- ) {
806
- if(!empty($_COOKIE['icegram_messages_shown_'.$message_data['id']]) || !empty($_COOKIE['icegram_campaign_shown_'.floor($message_data['campaign_id'])])){
807
- unset( $messages[$key] );
808
- continue;
809
- }
810
- }
811
- if( !empty( $message_data['id'] ) &&
812
- empty( $_GET['campaign_preview_id'] ) &&
813
- !empty( $message_data['retargeting_clicked'] ) &&
814
- $message_data['retargeting_clicked'] == 'yes'
815
- ) {
816
- if(!empty($_COOKIE['icegram_messages_clicked_'.$message_data['id']]) || !empty($_COOKIE['icegram_campaign_clicked_'.floor($message_data['campaign_id'])])){
817
- unset( $messages[$key] );
818
- continue;
819
- }
820
- }
821
-
822
- // Avoid showing the same message twice
823
- if (in_array($message_data['id'], $messages_to_show_ids)) {
824
- unset ( $messages[$key] );
825
- continue;
826
- } else {
827
- $messages_to_show_ids[] = $message_data['id'];
828
- }
829
-
830
- $this->process_message_body($messages[$key]);
831
- }
832
- if( empty( $messages ) )
833
- return;
834
- $icegram_default = apply_filters( 'icegram_branding_data',
835
- array ( 'icon' => $this->plugin_url . '/assets/images/icegram-logo-branding-64-grey.png',
836
- 'powered_by_logo' => $this->plugin_url . '/assets/images/icegram-logo-branding-64-grey.png',
837
- 'powered_by_text' => __( 'Powered by Icegram', 'icegram' )
838
- ) );
839
- $messages = apply_filters( 'icegram_messages_to_show', $messages );
840
- $icegram_data = apply_filters( 'icegram_data', array ( 'messages' => array_values( $messages ),
841
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
842
- 'preview_id' => !empty( $_GET['campaign_preview_id'] ) ? $_GET['campaign_preview_id'] : '',
843
- 'defaults' => $icegram_default
844
- ));
845
- if (empty($icegram_data['preview_id'])) {
846
- unset($icegram_data['preview_id']);
847
- }
848
-
849
- do_action('icegram_print_js_css_data', $icegram_data);
850
-
851
- do_action('icegram_data_printed');
852
- }
853
-
854
- function two_step_mobile_popup( $icegram_data ) {
855
-
856
- $temp = array();
857
- foreach ($icegram_data['messages'] as $message_id => $message) {
858
-
859
- if(!empty($message['ig_mobile_popup']) && $message['ig_mobile_popup'] == true){
860
- $action_bar = $message;
861
- $action_bar['type'] = 'action-bar';
862
- $action_bar['theme'] = 'hello';
863
- $action_bar['position'] = '21';
864
- $action_bar['message'] = '';
865
- $action_bar['label'] = __('Show More', 'icegram');
866
- $action_bar['id'] = $action_bar['id'].'_00';
867
- $action_bar['use_custom_code'] = 'yes';
868
- $action_bar['form_html'] = '';
869
- $action_bar['form_html_original'] = '';
870
- $action_bar['rainmaker_form_code'] = '';
871
- $action_bar['link'] = '';
872
- $action_bar['redirect_to_link'] = '';
873
- $action_bar['cta'] = '';
874
- $action_bar['alt_cta'] = '';
875
- $action_bar['add_alt_cta'] = '';
876
- $action_bar['custom_css'] = '#ig_this_message .ig_close{display:none;}';
877
- $action_bar['custom_js'] = "<script type='text/javascript'>jQuery('#icegram_message_".$action_bar['id']."').on('click', '.ig_button', function(){icegram.get_message_by_id('".$action_bar['id']."').hide(); icegram.get_message_by_id('".$message['id']."').show(); });</script>";
878
- unset($action_bar['ig_mobile_popup']);
879
- $temp[] = $action_bar;
880
- }
881
- }
882
- $icegram_data['messages'] = array_merge($icegram_data['messages'], $temp);
883
- unset($temp);
884
-
885
- return $icegram_data;
886
- }
887
-
888
-
889
- function print_js_css_data( $icegram_data ) {
890
-
891
- $this->collect_js_and_css($icegram_data);
892
- if($this->cache_compatibility === 'yes'){
893
- echo json_encode($icegram_data);
894
- wp_die();
895
- }else{
896
- wp_localize_script('icegram_main_js', 'icegram_data', $icegram_data);
897
- }
898
- }
899
-
900
- function collect_js_and_css(&$icegram_data){
901
-
902
- $types_shown = array();
903
- $scripts = array();
904
- $css = array();
905
- foreach ($icegram_data['messages'] as $key => $message_data) {
906
- $types_shown[] = $message_data['type'];
907
- }
908
-
909
- $types_shown = array_unique($types_shown);
910
- $ver_prefix = '?var=' .$this->version;
911
-
912
- $scripts[] = $this->plugin_url ."/assets/js/icegram.min.js". $ver_prefix;
913
- $css[] = $this->plugin_url ."/assets/css/frontend.min.css". $ver_prefix;
914
- //minify and combine only for default msg type
915
- $ig_core_message_types = array('popup', 'action-bar', 'toast', 'messenger');
916
- // Load JS and default CSS
917
- foreach ($types_shown as $message_type) {
918
- if(!in_array($message_type, $ig_core_message_types)){
919
- $scripts[] = $this->message_types[$message_type]['baseurl'] ."main.js". $ver_prefix;
920
- $css[] = $this->message_types[$message_type]['baseurl'] . "default.css". $ver_prefix;
921
- }else{
922
- $css[] = $this->message_types[$message_type]['baseurl'].'themes/'. $message_type. ".min.css". $ver_prefix;
923
- }
924
- }
925
-
926
- //TODO :: add theme pack theme css files too.
927
- // Load theme CSS
928
- foreach ($icegram_data['messages'] as $key => $message) {
929
- if ( !empty( $this->message_types[ $message['type'] ]['themes'][ $message['theme'] ]) ) {
930
- $theme = $this->message_types[ $message['type'] ]['themes'][ $message['theme'] ]['baseurl'] . $message['theme'].'.css'. $ver_prefix;
931
- }else{
932
- $theme_default = $this->message_types[ $message['type']] ['settings']['theme']['default'];
933
- $theme = $this->message_types[ $message['type'] ]['themes'][ $theme_default]['baseurl'] . $theme_default.'.css'. $ver_prefix;
934
- $icegram_data['messages'][$key]['theme'] = $theme_default;
935
- }
936
- if(!preg_match('/icegram\/message-types/i', $theme)){
937
- $css [] = $theme;
938
- }
939
- }
940
- $css = array_unique($css);
941
- $icegram_data['scripts'] = apply_filters('add_icegram_script' , $scripts);
942
- $icegram_data['css'] = apply_filters('add_icegram_css' , $css);
943
- return $icegram_data;
944
- }
945
-
946
- // Process
947
- function process_message_body(&$message_data){
948
- global $wp_scripts;
949
- global $wp_styles;
950
-
951
- if($this->cache_compatibility == 'yes'){
952
- $q_script = !empty($wp_scripts->queue) ? $wp_scripts->queue : array();
953
- $q_style = !empty($wp_styles->queue) ? $wp_styles->queue : array();
954
- }
955
- $content = $message_data['message'];
956
- $content = convert_chars(convert_smilies( wptexturize( $content )));
957
- if(isset($GLOBALS['wp_embed'])) {
958
- $content = $GLOBALS['wp_embed']->autoembed($content);
959
- }
960
- $content = $this->after_wpautop( wpautop( $this->before_wpautop( $content ) ) );
961
- $content = do_shortcode( shortcode_unautop( $content ) );
962
- $message_data['message'] = $content;
963
-
964
- //do_shortcode in headline
965
- $message_data['headline'] = do_shortcode( shortcode_unautop( $message_data['headline'] ) );
966
- //shortcode support for Third party forms and Rainmaker
967
- $form_html_original = !empty($message_data["rainmaker_form_code"])
968
- ? ('[rainmaker_form id="'. $message_data["rainmaker_form_code"] .'"]')
969
- :(!empty($message_data['form_html_original']) ? $message_data['form_html_original'] : '');
970
- $form_html_original = !empty($message_data["es_form_code"])
971
- ? ('[email-subscribers-form id="'. $message_data["es_form_code"] .'"]')
972
- :$form_html_original;
973
-
974
- if(!empty($form_html_original)){
975
- $message_data['form_html'] = do_shortcode( shortcode_unautop( $form_html_original) );
976
- }
977
- //TODO :: Handle case for inline style and script
978
- if($this->cache_compatibility == 'yes'){
979
- $handles = !empty($wp_scripts->queue) ? array_diff($wp_scripts->queue, $q_script) : array();
980
- unset($q_script);
981
- if(!empty($handles)){
982
- if(empty($message_data['assets']))
983
- $message_data['assets'] = array();
984
-
985
- ob_start();
986
- $wp_scripts->do_items($handles);
987
- $message_data['assets']['scripts'] = array_filter(explode('<script', ob_get_clean()));
988
- }
989
-
990
- //TODO :: do_items if required
991
- $handles = !empty($wp_styles->queue) ? array_diff($wp_styles->queue, $q_style) : array();
992
- unset($q_style);
993
- if(!empty($handles)){
994
- if(empty($message_data['assets']))
995
- $message_data['assets'] = array();
996
-
997
- foreach ($handles as $handle) {
998
- ob_start();
999
- $wp_styles->do_item($handle);
1000
- $message_data['assets']['styles'][$handle] = ob_get_clean();
1001
- }
1002
- }
1003
- }
1004
- }
1005
-
1006
- function enqueue_admin_styles_and_scripts() {
1007
-
1008
- $screen = get_current_screen();
1009
- if ( !in_array( $screen->id, array( 'ig_campaign', 'ig_message', 'edit-ig_campaign' ), true ) ) return;
1010
-
1011
- // Register scripts
1012
- wp_register_script( 'icegram_writepanel', $this->plugin_url . '/assets/js/admin.min.js', array ( 'jquery', 'wp-color-picker' ), $this->version );
1013
-
1014
- wp_enqueue_script( 'icegram_writepanel' );
1015
-
1016
- $icegram_writepanel_params = array ( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'search_message_nonce' => wp_create_nonce( "search-messages" ), 'home_url' => home_url( '/' ) );
1017
- $this->available_headlines = apply_filters( 'icegram_available_headlines', array() );
1018
- $icegram_writepanel_params = array_merge( $icegram_writepanel_params, array( 'available_headlines' => $this->available_headlines ) );
1019
-
1020
- wp_localize_script( 'icegram_writepanel', 'icegram_writepanel_params', $icegram_writepanel_params );
1021
-
1022
- wp_enqueue_style( 'dashicons' );
1023
- wp_enqueue_style( 'wp-color-picker' );
1024
- wp_enqueue_style( 'icegram_admin_styles', $this->plugin_url . '/assets/css/admin.min.css', array(), $this->version );
1025
-
1026
- if ( !wp_script_is( 'jquery-ui-datepicker' ) ) {
1027
- wp_enqueue_script( 'jquery-ui-datepicker' );
1028
- }
1029
-
1030
- }
1031
-
1032
- //execute shortcode in text widget
1033
- function ig_widget_text_filter($content){
1034
- if ( ! preg_match( '/\[[\r\n\t ]*icegram?[\r\n\t ].*?\]/', $content ) )
1035
- return $content;
1036
-
1037
- $content = do_shortcode( $content );
1038
-
1039
- return $content;
1040
- }
1041
-
1042
- public static function get_platform() {
1043
- $mobile_detect = new Ig_Mobile_Detect();
1044
- $mobile_detect->setUserAgent();
1045
- if($mobile_detect->isMobile()){
1046
- return ($mobile_detect->isTablet()) ? 'tablet' : 'mobile';
1047
- }else if($mobile_detect->isTablet()){
1048
- return 'tablet';
1049
- }
1050
- return 'laptop';
1051
- }
1052
-
1053
- function get_message_data( $message_ids = array(), $preview = false ) {
1054
- global $wpdb;
1055
- $message_data = array();
1056
- $original_message_id_map = array();
1057
- $meta_key = $preview ? 'icegram_message_preview_data' : 'icegram_message_data';
1058
- $message_data_query = "SELECT post_id, meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE '$meta_key'";
1059
- if ( !empty( $message_ids ) && is_array( $message_ids ) ) {
1060
- // For WPML compatibility
1061
- if ( function_exists('icl_object_id') ) {
1062
- $wpml_settings = get_option('icl_sitepress_settings');
1063
- $original_if_missing = (is_array($wpml_settings) && array_key_exists('show_untranslated_blog_posts', $wpml_settings) && !empty($wpml_settings['show_untranslated_blog_posts']) ) ? true : false;
1064
-
1065
- foreach ($message_ids as $i=>$id ) {
1066
- $translated = icl_object_id( $id, 'ig_message', $original_if_missing );
1067
- $message_ids[ $i ] = $translated;
1068
- $original_message_id_map[ $translated ] = $id;
1069
- }
1070
- }
1071
- $message_ids = array_filter(array_unique($message_ids));
1072
- if ( !empty( $message_ids ) ) {
1073
- $message_data_query .= " AND post_id IN ( " . implode( ',', $message_ids ) . " )";
1074
- $message_data_results = $wpdb->get_results( $message_data_query, 'ARRAY_A' );
1075
- foreach ( $message_data_results as $message_data_result ) {
1076
- $data = maybe_unserialize( $message_data_result['meta_value'] );
1077
- if (!empty($data)) {
1078
- $message_data[$message_data_result['post_id']] = $data;
1079
- // For WPML compatibility
1080
- if (!empty( $original_message_id_map[ $message_data_result['post_id'] ])) {
1081
- $message_data[$message_data_result['post_id']]['original_message_id'] = $original_message_id_map[ $message_data_result['post_id'] ];
1082
- }
1083
- }
1084
- }
1085
- }
1086
- }
1087
-
1088
- return $message_data;
1089
- }
1090
-
1091
- function get_valid_messages( $message_ids = array(), $campaign_ids = array(), $preview_mode = false, $skip_others = false) {
1092
- list($message_ids, $campaign_ids, $preview_mode, $skip_others) = apply_filters('icegram_get_valid_messages_params', array( $message_ids, $campaign_ids, $preview_mode, $skip_others));
1093
-
1094
- $valid_messages = $valid_campaigns = $message_campaign_map = array();
1095
-
1096
- $campaign_ids = array_filter(array_unique( (array) $campaign_ids));
1097
- $message_ids = array_filter(array_unique( (array) $message_ids));
1098
- if ( !empty( $campaign_ids ) ) {
1099
- $valid_campaigns = $this->get_valid_campaigns( $campaign_ids, true ,$preview_mode);
1100
- }
1101
-
1102
- // When skip_others is true, we won't load campaigns / messages from db
1103
- if (!$skip_others && !$preview_mode) {
1104
- $campaigns = $this->get_valid_campaigns();
1105
- if (!empty($campaigns)) {
1106
- foreach ($campaigns as $id => $campaign) {
1107
- if (!array_key_exists($id, $valid_campaigns)) {
1108
- $valid_campaigns[ $id ] = $campaign;
1109
- }
1110
- }
1111
- }
1112
- }
1113
-
1114
- // Create a map to look up campaign id for a given message
1115
- if( !empty( $valid_campaigns ) ) {
1116
- foreach ($valid_campaigns as $id => $campaign) {
1117
- if ($preview_mode) {
1118
- $campaign->messages = get_post_meta( $id, 'campaign_preview', true );
1119
- }
1120
- if( !empty( $campaign->messages ) ) {
1121
- foreach( $campaign->messages as $msg) {
1122
- $message_ids[] = $msg['id'];
1123
- if (!array_key_exists( $msg['id'], $message_campaign_map)) {
1124
- $message_campaign_map[ $msg['id'] ] = $id;
1125
- }
1126
- }
1127
- }
1128
- }
1129
- }
1130
-
1131
- // We don't display same message twice...
1132
- $message_ids = array_unique($message_ids);
1133
-
1134
- if( empty( $message_ids ) ) {
1135
- return array();
1136
- }
1137
- $valid_messages = $this->get_message_data( $message_ids, $preview_mode );
1138
-
1139
- foreach ($valid_messages as $id => $message_data) {
1140
- // Remove message if required fields are missing
1141
- if (empty($message_data) || empty($message_data['type'])) {
1142
- unset( $valid_messages[$id] );
1143
- continue;
1144
- }
1145
- // Remove message if message type is uninstalled
1146
- $class_name = 'Icegram_Message_Type_' . str_replace(' ', '_', ucwords(str_replace('-', ' ', $message_data['type'])));
1147
- if( !class_exists( $class_name ) ) {
1148
- unset( $valid_messages[$id] );
1149
- continue;
1150
- }
1151
- $message_data['delay_time'] = 0;
1152
- $message_data['retargeting'] = '';
1153
- $message_data['campaign_id'] = ($preview_mode) ? $_REQUEST['campaign_preview_id'] : '';
1154
-
1155
- // Pull display time and retargeting rule from campaign if possible
1156
- $message_id = (!empty($message_data['original_message_id'])) ? $message_data['original_message_id'] : $id;
1157
- if (!empty($message_campaign_map[ $message_id ])) {
1158
- //modify campaign id
1159
- $message_data['campaign_id'] = apply_filters('modify_campaing_id' , $message_campaign_map[ $message_id ] , $message_id) ;
1160
- $campaign = $valid_campaigns[ floor($message_data['campaign_id']) ];
1161
- if (!empty($campaign) && $campaign instanceof Icegram_Campaign) {
1162
- $message_meta_from_campaign = $campaign->get_message_meta_by_id( $message_id );
1163
- if (!empty($message_meta_from_campaign['time'])) {
1164
- $message_data['delay_time'] = $message_meta_from_campaign['time'];
1165
- }
1166
-
1167
- //check if campaign is targeted to mobile at zero
1168
- $device_rule = $campaign->get_rule_value('device');
1169
- if($this->get_platform() !== 'laptop' && !empty($device_rule['mobile']) && $device_rule['mobile'] == 'yes'&& $message_data['delay_time'] == 0 && $message_data['type'] == 'popup'){
1170
- $message_data['ig_mobile_popup'] = true;
1171
- if(!empty($message_data['triggers']) && !empty($message_data['triggers']['when_to_show'])){
1172
- $message_data['ig_mobile_popup'] = ($message_data['triggers']['when_to_show'] == 'duration_on_page' && $message_data['triggers']['duration_on_page'] == 0 ) ? true : false;
1173
- }
1174
- }
1175
- //set delay time -1 if shortcode with content
1176
- foreach ($this->shortcode_instances as $i => $value) {
1177
- $campaign_ids = explode( ',', $value['campaigns']);
1178
- if(!empty($value['with_content']) && in_array($message_data['campaign_id'], $campaign_ids)){
1179
- $message_data['delay_time'] = -1;
1180
- }
1181
- }
1182
- $rule_value = $campaign->get_rule_value('retargeting');
1183
- $message_data['retargeting'] = !empty( $rule_value['retargeting'] ) ? $rule_value['retargeting'] : '';
1184
- $message_data['expiry_time'] = !empty( $rule_value['retargeting'] ) ? $rule_value['expiry_time'] : '';
1185
- $rule_value_retargeting_clicked = $campaign->get_rule_value('retargeting_clicked');
1186
- $message_data['retargeting_clicked'] = !empty( $rule_value_retargeting_clicked['retargeting_clicked'] ) ? $rule_value_retargeting_clicked['retargeting_clicked'] : '';
1187
- $message_data['expiry_time_clicked'] = !empty( $rule_value_retargeting_clicked['retargeting_clicked'] ) ? $rule_value_retargeting_clicked['expiry_time_clicked'] : '';
1188
-
1189
- }
1190
- }
1191
- $valid_messages[$id] = $message_data;
1192
- }
1193
- $valid_messages = apply_filters( 'icegram_valid_messages', $valid_messages );
1194
-
1195
- return $valid_messages;
1196
- }
1197
-
1198
- function get_valid_campaigns( $campaign_ids = array(), $skip_page_check = false ,$preview_mode = false) {
1199
- global $wpdb;
1200
- if ( empty( $campaign_ids ) ) {
1201
- $sql = "SELECT pm.post_id
 
 
 
 
 
 
 
 
 
 
 
 
1202
  FROM {$wpdb->prefix}posts AS p
1203
  LEFT JOIN {$wpdb->prefix}postmeta AS pm ON ( pm.post_id = p.ID )
1204
  WHERE p.post_status = 'publish' ";
1205
- // Filter handler within this file (and possibly others) will append to this SQL
1206
- // and provide arguments for wpdb->prepare if needed.
1207
- // First element in the array is SQL, remaining are values for placeholders in SQL
1208
- $sql_params = apply_filters( 'icegram_get_valid_campaigns_sql', array($sql), array() );
1209
- $campaign_ids = $wpdb->get_col( $wpdb->prepare( array_shift($sql_params), $sql_params ) );
1210
- }
1211
- $valid_campaigns = array();
1212
- foreach ( (array) $campaign_ids as $campaign_id ) {
1213
- $campaign = new Icegram_Campaign( $campaign_id );
1214
- if ( $preview_mode || $campaign->is_valid( array('skip_page_check' => $skip_page_check) ) ) {
1215
- $valid_campaigns[$campaign_id] = $campaign;
1216
- } else {
1217
- // Campgain is invalid!
1218
- }
1219
-
1220
- }
1221
- $valid_campaigns = apply_filters('icegram_valid_campaigns', $valid_campaigns);
1222
- return $valid_campaigns;
1223
- }
1224
-
1225
- function append_to_valid_campaigns_sql( $sql_params = array(), $options = array() ) {
1226
- // Page check conditions
1227
- //$pid = $_GET['page_id'];
1228
- $pid = Icegram::get_current_page_id();
1229
- $sql = " AND (
 
1230
  pm.meta_key = 'icegram_campaign_target_rules' AND (
1231
  ( pm.meta_value LIKE '%%%s%%' )
1232
  OR ( pm.meta_value LIKE '%%%s%%' AND pm.meta_value LIKE '%%%s%%' AND pm.meta_value LIKE '%%%s%%' )
1233
  ";
1234
- $sql_params[] = 's:8:"sitewide";s:3:"yes";';
1235
- $sql_params[] = 's:10:"other_page";s:3:"yes";';
1236
- $sql_params[] = 's:7:"page_id";a:';
1237
- $sql_params[] = serialize( (string) $pid );
1238
- //local url
1239
- $sql .= " OR ( pm.meta_value LIKE '%%%s%%' )";
1240
- $sql_params[] = 's:9:"local_url";s:3:"yes";';
1241
- if(!empty($_REQUEST['cache_compatibility']) && $_REQUEST['cache_compatibility'] == 'yes'){
1242
- $is_home = (!empty($_REQUEST['is_home']) && $_REQUEST['is_home'] === 'true') ? true : false ;
1243
- }else{
1244
- $is_home = (is_home() || is_front_page()) ? true : false;
1245
- }
1246
- if ($is_home === true ) {
1247
- $sql .= " OR ( pm.meta_value LIKE '%%%s%%' )";
1248
- $sql_params[] = 's:8:"homepage";s:3:"yes";';
1249
- }
1250
- $sql .=" ) )";
1251
-
1252
- $sql_params[0] .= $sql;
1253
- //s:9:"logged_in";s:3:"all";
1254
-
1255
- return $sql_params;
1256
- }
1257
-
1258
- // Include all classes required for Icegram plugin
1259
- function include_classes( $feedback_version ) {
1260
- global $ig_tracker;
1261
- $feedback_version_for_file = str_replace('.', '-', $feedback_version);
1262
- $t = 'classes/feedback/class-ig-tracker.php';
1263
- $f = 'classes/feedback/class-ig-feedback.php';
1264
- require_once($t);
1265
- require_once($f);
1266
- require_once('classes/feedback.php');
1267
-
1268
- // $ig_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', $feedback_version );
1269
- $ig_feedback_class = 'IG_Feedback_V_' . str_replace( '.', '_', $feedback_version );
1270
- $ig_feedback = new $ig_feedback_class( 'Icegram', 'icegram', 'ig', 'igfree.', false );
1271
-
1272
- $classes = glob( $this->plugin_path . '/classes/*.php' );
1273
- foreach ( $classes as $file ) {
1274
- // Files with 'admin' in their name are included only for admin section
1275
- if ( is_file( $file ) && ( (strpos($file, '-admin') >= 0 && is_admin()) ) ){
1276
- $all_active_plugins = $ig_tracker::get_plugins();
1277
- if( (strpos($file, 'ig-upsale-admin.php') !== false ) && in_array('icegram-engage/icegram-engage.php', $all_active_plugins)){
1278
- continue;
1279
- }
1280
- include_once $file;
1281
- } else if( !is_admin()){
1282
- include_once $file;
1283
- }
1284
- }
1285
-
1286
- // Load built in message types
1287
- $icegram_message_type_basedirs = glob( $this->plugin_path . '/message-types/*' );
1288
- // Allow other plugins to add new message types
1289
- $icegram_message_type_basedirs = apply_filters( 'icegram_message_type_basedirs', $icegram_message_type_basedirs );
1290
- // Set up different message type classes
1291
- foreach ( $icegram_message_type_basedirs as $dir ) {
1292
- $type = basename ( $dir );
1293
- $class_file = $dir . "/main.php";
1294
- if( is_file( $class_file ) ) {
1295
- include_once( $class_file );
1296
- }
1297
- $class_name = 'Icegram_Message_Type_' . str_replace(' ', '_', ucwords(str_replace('-', ' ', $type)));
1298
- if (class_exists($class_name)) {
1299
- $this->message_type_objs[ $type ] = new $class_name();
1300
- }
1301
- }
1302
- do_action('ig_file_include');
1303
- $this->message_types = apply_filters( 'icegram_message_types', array() );
1304
-
1305
- }
1306
-
1307
- // Register Campaign post type
1308
- function register_campaign_post_type() {
1309
- $labels = array(
1310
- 'name' => __( 'Campaigns', 'icegram' ),
1311
- 'singular_name' => __( 'Campaign', 'icegram' ),
1312
- 'add_new' => __( 'Add New Campaign', 'icegram' ),
1313
- 'add_new_item' => __( 'Add New Campaign', 'icegram' ),
1314
- 'edit_item' => __( 'Edit Campaign', 'icegram' ),
1315
- 'new_item' => __( 'New Campaign', 'icegram' ),
1316
- 'all_items' => __( 'Campaigns', 'icegram' ),
1317
- 'view_item' => __( 'View Campaign', 'icegram' ),
1318
- 'search_items' => __( 'Search Campaigns', 'icegram' ),
1319
- 'not_found' => __( 'No campaigns found', 'icegram' ),
1320
- 'not_found_in_trash' => __( 'No campaigns found in Trash', 'icegram' ),
1321
- 'parent_item_colon' => __( '', 'icegram' ),
1322
- 'menu_name' => __( 'Icegram', 'icegram' )
1323
- );
1324
-
1325
- $args = array(
1326
- 'labels' => $labels,
1327
- // 'menu_icon' => 'dashicons-info',
1328
- 'public' => false,
1329
- 'publicly_queryable' => false,
1330
- 'show_ui' => true,
1331
- 'show_in_menu' => true,
1332
- 'query_var' => true,
1333
- 'rewrite' => array( 'slug' => 'ig_campaign' ),
1334
- 'capability_type' => 'post',
1335
- 'has_archive' => false,
1336
- 'hierarchical' => false,
1337
- 'menu_position' => null,
1338
- 'menu_icon' => $this->plugin_url . '/assets/images/icegram-logo-branding-18-white.png' ,
1339
- 'supports' => array( 'title', 'editor' )
1340
- );
1341
-
1342
- register_post_type( 'ig_campaign', $args );
1343
- }
1344
-
1345
- // Register Message post type
1346
- function register_message_post_type() {
1347
- $labels = array(
1348
- 'name' => __( 'Messages', 'icegram' ),
1349
- 'singular_name' => __( 'Message', 'icegram' ),
1350
- 'add_new' => __( 'Create New', 'icegram' ),
1351
- 'add_new_item' => __( 'Create New Message', 'icegram' ),
1352
- 'edit_item' => __( 'Edit Message', 'icegram' ),
1353
- 'new_item' => __( 'New Message', 'icegram' ),
1354
- 'all_items' => __( 'Messages', 'icegram' ),
1355
- 'view_item' => __( 'View Message', 'icegram' ),
1356
- 'search_items' => __( 'Search Messages', 'icegram' ),
1357
- 'not_found' => __( 'No messages found', 'icegram' ),
1358
- 'not_found_in_trash' => __( 'No messages found in Trash', 'icegram' ),
1359
- 'parent_item_colon' => __( '', 'icegram' ),
1360
- 'menu_name' => __( 'Messages', 'icegram' )
1361
- );
1362
-
1363
- $args = array(
1364
- 'labels' => $labels,
1365
- 'public' => false,
1366
- 'publicly_queryable' => false,
1367
- 'show_ui' => true,
1368
- 'show_in_menu' => 'edit.php?post_type=ig_campaign',
1369
- 'query_var' => true,
1370
- 'rewrite' => array( 'slug' => 'ig_message' ),
1371
- 'capability_type' => 'post',
1372
- 'has_archive' => false,
1373
- 'hierarchical' => false,
1374
- 'menu_position' => null,
1375
- 'supports' => array( 'title' )
1376
- );
1377
-
1378
- register_post_type( 'ig_message', $args );
1379
- }
1380
-
1381
-
1382
- function import( $data = array() ) {
1383
- if ( empty( $data['campaigns'] ) && empty( $data['messages'] ) ) return;
1384
-
1385
- $default_theme = $default_type = '';
1386
- $first_message_type = current( $this->message_types );
1387
-
1388
- if( is_array( $first_message_type ) ) {
1389
- $default_type = $first_message_type['type'];
1390
- if( !empty( $first_message_type['themes'] ) ) {
1391
- $default_theme = key( $first_message_type['themes'] );
1392
- }
1393
- }
1394
-
1395
- $new_campaign_ids = array();
1396
- foreach ( (array) $data['campaigns'] as $campaign ) {
1397
-
1398
- $args = array(
1399
- 'post_content' => ( !empty( $campaign['post_content'] ) ) ? esc_attr( $campaign['post_content'] ) : '',
1400
- 'post_name' => ( !empty( $campaign['post_title'] ) ) ? sanitize_title( $campaign['post_title'] ) : '',
1401
- 'post_title' => ( !empty( $campaign['post_title'] ) ) ? $campaign['post_title'] : '',
1402
- // 'post_status' => ( !empty( $campaign['post_status'] ) ) ? $campaign['post_status'] : 'draft',
1403
- 'post_status' => 'draft',
1404
- 'post_type' => 'ig_campaign'
1405
- );
1406
-
1407
- $new_campaign_id = wp_insert_post( $args );
1408
- $new_campaign_ids[] = $new_campaign_id;
1409
-
1410
- if ( !empty( $campaign['target_rules'] ) ) {
1411
-
1412
- $defaults = array (
1413
- 'homepage' => 'yes',
1414
- 'when' => 'always',
1415
- 'from' => '',
1416
- 'to' => '',
1417
- 'mobile' => 'yes',
1418
- 'tablet' => 'yes',
1419
- 'laptop' => 'yes',
1420
- 'logged_in' => 'all'
1421
- );
1422
-
1423
- $target_rules = wp_parse_args( $campaign['target_rules'], $defaults );
1424
- update_post_meta( $new_campaign_id, 'icegram_campaign_target_rules', $target_rules );
1425
- }
1426
-
1427
- if ( !empty( $campaign['messages'] ) ) {
1428
-
1429
- $messages = array();
1430
-
1431
- foreach ( $campaign['messages'] as $message ) {
1432
-
1433
- if ( !is_array( $message ) ) continue;
1434
-
1435
- $args = array(
1436
- 'post_content' => ( !empty( $message['message'] ) ) ? esc_attr( $message['message'] ) : '',
1437
- 'post_name' => ( !empty( $message['post_title'] ) ) ? sanitize_title( $message['post_title'] ) : '',
1438
- 'post_title' => ( !empty( $message['post_title'] ) ) ? $message['post_title'] : '',
1439
- 'post_status' => ( !empty( $message['post_status'] ) ) ? $message['post_status'] : 'publish',
1440
- 'post_type' => 'ig_message'
1441
- );
1442
-
1443
- $new_message_id = wp_insert_post( $args );
1444
- $new_message = array(
1445
- 'id' => $new_message_id,
1446
- 'time' => ( !empty( $message['time'] ) ) ? $message['time'] : 0
1447
- );
1448
- //for gallery + CTA another message
1449
- if(!empty($message['cta']) && $message['cta'] == 'cta_another_message' && !empty($message['cta_linked_message_id']) && $message['cta_linked_message_id'] == 'auto'){
1450
- $prev_message = end($messages);
1451
- $message['cta_linked_message_id'] = $prev_message['id'];
1452
- array_pop($messages);
1453
- }
1454
- $messages[] = $new_message;
1455
-
1456
- unset( $message['post_content'] );
1457
- unset( $message['time'] );
1458
-
1459
- $message['id'] = $new_message_id;
1460
-
1461
- $defaults = array (
1462
- 'post_title' => '',
1463
- 'type' => $default_type,
1464
- 'theme' => $default_theme,
1465
- 'animation' => '',
1466
- 'headline' => '',
1467
- 'label' => '',
1468
- 'link' => '',
1469
- 'icon' => '',
1470
- 'message' => '',
1471
- 'position' => '',
1472
- 'text_color' => '#000000',
1473
- 'bg_color' => '#ffffff',
1474
- 'custom_code' => '',
1475
- 'id' => ''
1476
- );
1477
- $icegram_message_data = wp_parse_args( $message, $defaults );
1478
- if ( !empty( $icegram_message_data ) ) {
1479
- update_post_meta( $new_message_id, 'icegram_message_data', $icegram_message_data );
1480
- update_post_meta( $new_message_id, 'icegram_message_preview_data', $icegram_message_data );
1481
- }
1482
- }//foreach
1483
-
1484
- if ( !empty( $campaign['messages'] ) ) {
1485
- update_post_meta( $new_campaign_id, 'messages', $messages );
1486
- update_post_meta( $new_campaign_id, 'campaign_preview', $messages );
1487
- }
1488
- }//if
1489
- }
1490
- return $new_campaign_ids;
1491
-
1492
- }
1493
-
1494
- function import_gallery_item(){
1495
- if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'fetch_messages' && !empty($_REQUEST['campaign_id']) && !empty($_REQUEST['gallery_item'])){
1496
- $url = 'https://www.icegram.com/gallery/wp-admin/admin-ajax.php?utm_source=ig_inapp&utm_campaign=ig_gallery&utm_medium='.$_REQUEST['campaign_id'];
1497
- $params = $_REQUEST;
1498
- $imported_gallery_items = array();
1499
- $options = array(
1500
- 'timeout' => 15,
1501
- 'method' => 'POST',
1502
- 'body' => http_build_query( $params )
1503
- );
1504
- $response = wp_remote_request( $url, $options );
1505
- $response_code = wp_remote_retrieve_response_code( $response );
1506
- if ( $response_code == 200 ) {
1507
- $new_campaign_ids = $this->import(json_decode($response['body'] ,true));
1508
- if(!empty($new_campaign_ids)){
1509
- $imported_gallery_items = get_option('ig_imported_gallery_items');
1510
- $imported_gallery_items[] = $_REQUEST['campaign_id'];
1511
- update_option( 'ig_imported_gallery_items', $imported_gallery_items);
1512
- $location = admin_url( 'post.php?post='.$new_campaign_ids[0].'&action=edit');
1513
- header('Location:'.$location);
1514
- exit;
1515
- }else{
1516
- wp_safe_redirect($_SERVER['HTTP_REFERER']);
1517
- }
1518
- }
1519
- }
1520
- }
1521
-
1522
- function import_sample_data ($data = array() ){
1523
- $new_campaign_ids = $this->import($data);
1524
- if( !empty( $new_campaign_ids ) ) {
1525
- update_option( 'icegram_sample_data_imported', $new_campaign_ids );
1526
- }
1527
- }
1528
-
1529
-
1530
-
1531
-
1532
- function get_sample_data() {
1533
-
1534
- return array(
1535
- 'campaigns' => array(
1536
- array(
1537
- 'post_name' => '',
1538
- 'post_title' => 'My First Icegram Campaign',
1539
- 'target_rules' => array (
1540
- 'homepage' => 'yes',
1541
- 'when' => 'always',
1542
- 'from' => '',
1543
- 'to' => '',
1544
- 'mobile' => 'yes',
1545
- 'tablet' => 'yes',
1546
- 'laptop' => 'yes',
1547
- 'logged_in' => 'all'
1548
- ),
1549
- 'messages' => array(
1550
- array (
1551
- 'post_title' => 'Get 2x more Contacts with Your Website',
1552
- 'post_status' => 'publish',
1553
- 'time' => '0',
1554
- 'type' => 'action-bar',
1555
- 'theme' => 'hello',
1556
- 'headline' => 'Get 2x more Contacts with Your Website',
1557
- 'label' => 'Show Me How',
1558
- 'link' => '',
1559
- 'icon' => '',
1560
- 'message' => 'Instant Results Guaranteed',
1561
- 'position' => '01',
1562
- 'text_color' => '#000000',
1563
- 'bg_color' => '#eb593c'
1564
- ),
1565
- array (
1566
- 'post_title' => '20% Off Coupon',
1567
- 'post_status' => 'publish',
1568
- 'time' => '4',
1569
- 'type' => 'messenger',
1570
- 'theme' => 'social',
1571
- 'animation' => 'slide',
1572
- 'headline' => '20% Off - for you',
1573
- 'label' => '',
1574
- 'link' => '',
1575
- 'icon' => '',
1576
- 'message' => "Hey there! We are running a <strong>special 20% off this week</strong> for registered users - like you.
 
 
 
1577
 
1578
  Use coupon <code>LOYALTY20</code> during checkout.",
1579
- 'position' => '22',
1580
- 'text_color' => '#000000',
1581
- 'bg_color' => '#ffffff'
1582
- ),
1583
- array (
1584
- 'post_title' => 'How this blog makes over $34,800 / month for FREE.',
1585
- 'post_status' => 'publish',
1586
- 'time' => '10',
1587
- 'type' => 'popup',
1588
- 'theme' => 'air-mail',
1589
- 'headline' => 'How this blog makes over $34,800 / month for FREE.',
1590
- 'label' => 'FREE INSTANT ACCESS',
1591
- 'link' => '',
1592
- 'icon' => '',
1593
- 'message' => "This website earns over $30,000 every month, every single month, almost on autopilot. I have 4 other sites with similar results. All I do is publish new regular content every week.
1594
 
1595
  <strong>Download my free kit to learn how I do this.</strong>
1596
 
@@ -1601,306 +1620,324 @@ class Icegram {
1601
  <li>Resources and tips to get started quickly</li>
1602
  <li>Private members club to connect with fellow owners</li>
1603
  </ul>",
1604
- 'text_color' => '#000000',
1605
- 'bg_color' => '#ffffff'
1606
-
1607
- ),
1608
- array (
1609
- 'post_title' => 'Exclusive Marketing Report',
1610
- 'post_status' => 'publish',
1611
- 'time' => '6',
1612
- 'type' => 'toast',
1613
- 'theme' => 'stand-out',
1614
- 'animation' => 'pop',
1615
- 'headline' => 'Exclusive Marketing Report',
1616
- 'label' => '',
1617
- 'link' => '',
1618
- 'icon' => '',
1619
- 'message' => 'FREE for every subscriber. Click here to download it.',
1620
- 'position' => '02',
1621
- 'text_color' => '#000000',
1622
- 'bg_color' => '#ffffff'
1623
- )
1624
-
1625
- )
1626
- )
1627
- )
1628
- );
1629
- }
1630
-
1631
- function remove_preview_button() {
1632
- global $post_type;
1633
- if( $post_type == 'ig_message' || $post_type == 'ig_campaign' ) {
1634
- ?>
1635
- <style type="text/css">
1636
- #message.updated.below-h2{ display: none; }
1637
- #preview-action { display:none; }
1638
- /*Remove add new campaign and message*/
1639
- .page-title-action{
1640
- display:none;
1641
- }
1642
- </style>
1643
- <?php
1644
- }
1645
- }
1646
-
1647
-
1648
- function remove_row_actions( $actions, $post ) {
1649
-
1650
- if ( empty( $post->post_type ) || ( $post->post_type != 'ig_campaign' && $post->post_type != 'ig_message' ) ) return $actions;
1651
-
1652
- unset( $actions['inline hide-if-no-js'] );
1653
- unset( $actions['view'] );
1654
-
1655
- return $actions;
1656
-
1657
- }
1658
-
1659
- function identify_current_page() {
1660
- global $post, $wpdb;
1661
-
1662
- $obj = get_queried_object();
1663
- $id = 0;
1664
- if( !empty( $obj->has_archive ) ) {
1665
- $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s ", array( $obj->has_archive, 'page') );
1666
- $id = $wpdb->get_var( $sql );
1667
- } elseif( is_object( $post ) && isset( $post->ID ) ) {
1668
- $id = $post->ID;
1669
- }
1670
- $id = apply_filters('icegram_identify_current_page', $id );
1671
- self::$current_page_id = $id;
1672
- }
1673
-
1674
- static function get_current_page_id() {
1675
- global $post;
1676
- if (!empty($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) {
1677
- $post = get_post($_REQUEST['page_id']);
1678
- setup_postdata( $post );
1679
- // WPML check
1680
- $id = apply_filters('icegram_identify_current_page', $post->ID );
1681
- self::$current_page_id = $id;
1682
- }
1683
- return self::$current_page_id;
1684
- }
1685
-
1686
- static function get_current_page_url() {
1687
- if(!empty($_REQUEST['cache_compatibility']) && $_REQUEST['cache_compatibility'] == 'yes'){
1688
- $pageURL = (!empty($_REQUEST['referral_url'])) ? $_REQUEST['referral_url'] : '';
1689
- }else{
1690
- $pageURL = 'http';
1691
- if( isset($_SERVER["HTTPS"]) ) {
1692
- if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
1693
- }
1694
- $pageURL .= "://";
1695
- if ($_SERVER["SERVER_PORT"] != "80") {
1696
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
1697
- } else {
1698
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
1699
- }
1700
- }
1701
- return $pageURL;
1702
- }
1703
-
1704
- function wpml_get_parent_id( $id ) {
1705
- global $post;
1706
- if (function_exists('icl_object_id') && function_exists('icl_get_default_language') ) {
1707
- $id = icl_object_id($id, $post->post_type, true, icl_get_default_language() );
1708
- }
1709
- return $id;
1710
- }
1711
-
1712
-
1713
- /**
1714
- * Our implementation of wpautop to preserve script and style tags
1715
- */
1716
- function before_wpautop($pee) {
1717
- if ( trim($pee) === '' ) {
1718
- $this->_wpautop_tags = array();
1719
- return '';
1720
- }
1721
-
1722
- $tags = array();
1723
- // Pull out tags and add placeholders
1724
- list( $pee, $tags['pre'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'pre' );
1725
- list( $pee, $tags['script'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'script' );
1726
- list( $pee, $tags['style'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'style' );
1727
- $this->_wpautop_tags = $tags;
1728
-
1729
- if( !empty( $pre_tags ) )
1730
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $pre_tags );
1731
- if( !empty( $script_tags ) )
1732
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $script_tags );
1733
- if( !empty( $style_tags ) )
1734
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $style_tags );
1735
-
1736
- return $pee;
1737
- }
1738
-
1739
- function after_wpautop($pee) {
1740
- if ( trim($pee) === '' || empty($this->_wpautop_tags) )
1741
- return '';
1742
-
1743
- // Replace placeholders with original content
1744
- if (!empty($this->_wpautop_tags['pre'])) {
1745
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['pre'] );
1746
- }
1747
- if (!empty($this->_wpautop_tags['script'])) {
1748
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['script'] );
1749
- }
1750
- if (!empty($this->_wpautop_tags['style'])) {
1751
- $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['style'] );
1752
- }
1753
-
1754
- $this->_wpautop_tags = array();
1755
-
1756
- return $pee;
1757
- }
1758
-
1759
- function _wpautop_add_tag_placeholders( $pee, $tag ) {
1760
- $tags = array();
1761
-
1762
- if ( false !== strpos( $pee, "<{$tag}" ) ) {
1763
- $pee_parts = explode( "</{$tag}>", $pee );
1764
- $last_pee = array_pop( $pee_parts );
1765
- $pee = '';
1766
- $i = 0;
1767
-
1768
- foreach ( $pee_parts as $pee_part ) {
1769
- $start = strpos( $pee_part, "<{$tag}" );
1770
-
1771
- // Malformed html?
1772
- if ( false === $start ) {
1773
- $pee .= $pee_part;
1774
- continue;
1775
- }
1776
-
1777
- $name = "<{$tag} wp-{$tag}-tag-$i></{$tag}>";
1778
- $tags[ $name ] = substr( $pee_part, $start ) . "</{$tag}>";
1779
-
1780
- $pee .= substr( $pee_part, 0, $start ) . $name;
1781
- $i++;
1782
- }
1783
-
1784
- $pee .= $last_pee;
1785
- }
1786
-
1787
- return array( $pee, $tags );
1788
- }
1789
-
1790
- function _wpautop_replace_tag_placeholders( $pee, $tags ) {
1791
- if ( ! empty( $tags ) ) {
1792
- $pee = str_replace( array_keys( $tags ), array_values( $tags ), $pee );
1793
- }
1794
-
1795
- return $pee;
1796
- }
1797
-
1798
- static function duplicate_in_db( $original_id){
1799
- // Get access to the database
1800
- global $wpdb;
1801
- // Get the post as an array
1802
- $duplicate = get_post( $original_id, 'ARRAY_A' );
1803
- // Modify some of the elements
1804
- $duplicate['post_title'] = $duplicate['post_title'].' '.__('Copy', 'icegram');
1805
- $duplicate['post_status'] = 'draft';
1806
- // Set the post date
1807
- $timestamp = current_time('timestamp', 0);
1808
-
1809
- $duplicate['post_date'] = date('Y-m-d H:i:s', $timestamp);
1810
-
1811
- // Remove some of the keys
1812
- unset( $duplicate['ID'] );
1813
- unset( $duplicate['guid'] );
1814
- unset( $duplicate['comment_count'] );
1815
-
1816
- // Insert the post into the database
1817
- $duplicate_id = wp_insert_post( $duplicate );
1818
-
1819
- // Duplicate all taxonomies/terms
1820
- $taxonomies = get_object_taxonomies( $duplicate['post_type'] );
1821
-
1822
- foreach( $taxonomies as $taxonomy ) {
1823
- $terms = wp_get_post_terms( $original_id, $taxonomy, array('fields' => 'names') );
1824
- wp_set_object_terms( $duplicate_id, $terms, $taxonomy );
1825
- }
1826
-
1827
- // Duplicate all custom fields
1828
- $custom_fields = get_post_custom( $original_id );
1829
- foreach ( $custom_fields as $key => $value ) {
1830
- if($key === 'messages'){
1831
- $messages = unserialize($value[0]);
1832
- foreach ($messages as &$message) {
1833
- $clone_msg_id = Icegram::duplicate_in_db($message['id']);
1834
- $message['id'] = $clone_msg_id;
1835
  }
1836
- $value[0] = serialize($messages);
1837
- }
1838
- add_post_meta( $duplicate_id, $key, maybe_unserialize($value[0]) );
1839
- }
1840
- return $duplicate_id;
1841
- }
1842
-
1843
- static function duplicate( $original_id){
1844
- $duplicate_id = Icegram::duplicate_in_db($original_id);
1845
- $location = admin_url( 'post.php?post='.$duplicate_id.'&action=edit');
1846
- header('Location:'.$location);
1847
- exit;
1848
- }
1849
-
1850
- public static function form_submission_validate_request($request_data){
1851
- if(!empty($request_data)){
1852
- // Check for Remote Rainmaker form submission request
1853
- $request_data['ig_is_remote'] = false;
1854
- $request_data['is_remote'] = false;
1855
- if(!empty($request_data['ig_mode']) && $request_data['ig_mode'] === 'remote'){
1856
- $ig_remote_url = $request_data['ig_remote_url'];
1857
- if(!empty($request_data['ig_campaign_id'])){
1858
- $rules = get_post_meta( $request_data['ig_campaign_id'], 'icegram_campaign_target_rules', true );
1859
- if( !empty($rules['remote_urls']) && is_array($rules['remote_urls']) ){
1860
- foreach ($rules['remote_urls'] as $remote_url_pattern) {
1861
- $valid = Icegram_Campaign::is_valid_url($remote_url_pattern , $ig_remote_url);
1862
- if( $valid ){
1863
- $request_data['ig_is_remote'] = true;
1864
- $request_data['is_remote'] = true;
1865
- break;
1866
- }
1867
- }
1868
- //TODO :: discard the the remote request and data
1869
- // if($request_data['ig_is_remote'] == false){
1870
- // return array();
1871
- // }
1872
- }
1873
 
 
 
1874
  }
1875
- }
1876
- }
1877
- return $request_data;
1878
- }
1879
-
1880
- public static function get_ig_meta_info(){
1881
- $total_campaigns = wp_count_posts('ig_campaign');
1882
- $total_campaigns_publish = $total_campaigns->publish;
1883
- $total_campaigns_draft = $total_campaigns->draft;
1884
-
1885
- $meta_info = array(
1886
- 'total_campaigns_publish' => $total_campaigns_publish,
1887
- 'total_campaigns_draft' => $total_campaigns_draft,
1888
- );
1889
-
1890
- return $meta_info;
1891
- }
1892
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1893
  }
1894
 
1895
-
1896
  function initialize_icegram() {
1897
- global $icegram;
 
 
1898
 
1899
- // i18n / l10n - load translations
1900
- load_plugin_textdomain( 'icegram', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
1901
 
1902
- $icegram = new Icegram();
1903
- do_action('icegram_loaded');
1904
  }
1905
 
1906
  add_action( 'plugins_loaded', 'initialize_icegram' );
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: 1.10.36
7
  * Author: icegram
8
  * Author URI: https://www.icegram.com/
9
  * Copyright (c) 2014-19 Icegram
15
  */
16
 
17
  /**
18
+ * Main class Icegram
19
+ */
20
  class Icegram {
21
 
22
+ var $plugin_url;
23
+ var $plugin_path;
24
+ var $version;
25
+ var $_wpautop_tags;
26
+ var $message_types;
27
+ var $message_type_objs;
28
+ var $shortcode_instances;
29
+ var $available_headlines;
30
+ var $mode;
31
+ var $cache_compatibility;
32
+
33
+ public static $current_page_id;
34
+
35
+ function __construct() {
36
+ global $ig_feedback, $ig_tracker;
37
+
38
+ $feedback_version = '1.0.15';
39
+ $ig_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', $feedback_version );
40
+
41
+ $this->version = "1.10.36";
42
+ $this->shortcode_instances = array();
43
+ $this->mode = 'local';
44
+ $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
45
+ $this->plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) );
46
+ $this->define_constants();
47
+ $this->include_classes( $feedback_version );
48
+ $this->cache_compatibility = get_option( 'icegram_cache_compatibility', 'no' );
49
+
50
+ if ( is_admin() ) {
51
+ $ig_feedback->render_deactivate_feedback();
52
+ }
53
+
54
+ if ( is_admin() && current_user_can( 'edit_posts' ) ) {
55
+ $ig_campaign_admin = Icegram_Campaign_Admin::getInstance();
56
+ $ig_message_admin = Icegram_Message_Admin::getInstance();
57
+ add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_styles_and_scripts' ) );
58
+ add_action( 'admin_print_styles', array( &$this, 'remove_preview_button' ) );
59
+ add_filter( 'post_row_actions', array( &$this, 'remove_row_actions' ), 10, 2 );
60
+
61
+ add_action( 'admin_menu', array( &$this, 'admin_menus' ) );
62
+ add_action( 'admin_init', array( &$this, 'welcome' ) );
63
+ add_action( 'admin_init', array( &$this, 'dismiss_admin_notice' ) );
64
+
65
+ add_action( 'admin_init', array( &$this, 'import_gallery_item' ) );
66
+
67
+ add_action( 'icegram_settings_after', array( &$this, 'klawoo_subscribe_form' ) );
68
+ add_action( 'icegram_about_changelog', array( &$this, 'klawoo_subscribe_form' ) );
69
+ add_action( 'icegram_settings_after', array( &$this, 'icegram_houskeeping' ) );
70
+ add_action( 'admin_notices', array( &$this, 'add_admin_notices' ) );
71
+ add_filter( 'plugin_action_links', array( $this, 'ig_plugin_settings_link' ), 10, 2 );
72
+ } else {
73
+ add_action( 'wp_footer', array( &$this, 'icegram_load_data' ) );
74
+ }
75
+ if ( $this->cache_compatibility === 'no' ) {
76
+ add_action( 'wp_footer', array( &$this, 'display_messages' ) );
77
+ }
78
+ add_shortcode( 'icegram', array( &$this, 'execute_shortcode' ) );
79
+ add_shortcode( 'ig_form', array( &$this, 'execute_form_shortcode' ) );
80
+ // WPML compatibility
81
+ add_filter( 'icegram_identify_current_page', array( &$this, 'wpml_get_parent_id' ), 10 );
82
+
83
+ add_filter( 'icegram_branding_data', array( &$this, 'branding_data_remove' ), 10 );
84
+ add_action( 'wp_enqueue_scripts', array( &$this, 'identify_current_page' ) );
85
+ add_filter( 'icegram_get_valid_campaigns_sql', array( &$this, 'append_to_valid_campaigns_sql' ), 10, 2 );
86
+ add_action( 'icegram_print_js_css_data', array( &$this, 'print_js_css_data' ), 10, 1 );
87
+ // common
88
+ add_action( 'init', array( &$this, 'register_campaign_post_type' ) );
89
+ add_action( 'init', array( &$this, 'register_message_post_type' ) );
90
+
91
+ add_action( 'icegram_loaded', array( &$this, 'load_compat_classes' ) );
92
+
93
+ // execute shortcode in sidebar
94
+ add_filter( 'widget_text', array( &$this, 'ig_widget_text_filter' ) );
95
+
96
+ add_filter( 'rainmaker_validate_request', array( &$this, 'form_submission_validate_request' ), 10, 2 );
97
+ add_filter( 'icegram_data', array( $this, 'two_step_mobile_popup' ), 100, 1 );
98
+
99
+
100
+ if ( defined( 'DOING_AJAX' ) ) {
101
+ if ( $this->cache_compatibility === 'yes' ) {
102
+ add_action( 'wp_ajax_display_messages', array( &$this, 'display_messages' ) );
103
+ add_action( 'wp_ajax_nopriv_display_messages', array( &$this, 'display_messages' ) );
104
+ }
105
+ add_action( 'wp_ajax_icegram_event_track', array( &$this, 'icegram_event_track' ) );
106
+ add_action( 'wp_ajax_nopriv_icegram_event_track', array( &$this, 'icegram_event_track' ) );
107
+ add_action( 'wp_ajax_klawoo_subscribe', array( &$this, 'klawoo_subscribe' ) );
108
+ add_action( 'wp_ajax_icegram_run_housekeeping', array( &$this, 'run_housekeeping' ) );
109
+ add_action( 'wp_ajax_save_gallery_data', array( &$this, 'save_gallery_data' ) );
110
+
111
+ }
112
+
113
+ }
114
+
115
+ function ig_plugin_settings_link( $links, $file ) {
116
+ if ( $file == plugin_basename( __FILE__ ) ) {
117
+ $settings_link = '<a href="edit.php?post_type=ig_campaign&page=icegram-settings">' . __( 'Settings', 'icegram' ) . '</a>';
118
+ $support_link = '<a href="edit.php?post_type=ig_campaign&page=icegram-support">' . __( 'Support', 'icegram' ) . '</a>';
119
+ array_unshift( $links, $support_link );
120
+ array_unshift( $links, $settings_link );
121
+ }
122
+
123
+ return $links;
124
+
125
+ }
126
+
127
+ public function define_constants() {
128
+ if ( ! defined( 'IG_PLUGIN_URL' ) ) {
129
+ define( 'IG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
130
+ }
131
+ }
132
+
133
+ public function load_compat_classes() {
134
+
135
+ $compat_classes = (array) glob( $this->plugin_path . '/classes/compat/class-icegram-compat-*.php' );
136
+ if ( empty( $compat_classes ) ) {
137
+ return;
138
+ }
139
+
140
+ $active_plugins = (array) get_option( 'active_plugins', array() );
141
+ if ( is_multisite() ) {
142
+ $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
143
+ }
144
+ $active_plugins = array_unique( array_merge( array_values( $active_plugins ), array_keys( $active_plugins ) ) );
145
+ $active_plugins_with_slugs = array();
146
+ foreach ( $active_plugins as $key => $value ) {
147
+ $slug = dirname( $value );
148
+ if ( $slug == '.' ) {
149
+ unset( $active_plugins[ $key ] );
150
+ } else {
151
+ $active_plugins[ $key ] = $slug;
152
+ }
153
+ }
154
+
155
+ foreach ( $compat_classes as $file ) {
156
+ if ( is_file( $file ) ) {
157
+ $slug = str_replace( 'class-icegram-compat-', '', str_replace( ".php", "", basename( $file ) ) );
158
+ if ( in_array( $slug, $active_plugins ) ) {
159
+ include_once( $file );
160
+ $class_name = 'Icegram_Compat_' . str_replace( '-', '_', $slug );
161
+ if ( class_exists( $class_name ) ) {
162
+ new $class_name();
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ public function add_admin_notices() {
170
+
171
+ global $ig_feedback;
172
+
173
+ $screen = get_current_screen();
174
+ if ( ! in_array( $screen->id, array( 'ig_campaign', 'ig_message', 'edit-ig_message', 'edit-ig_campaign' ), true ) ) {
175
+ return;
176
+ }
177
+
178
+ //bfcm 2019 :start
179
+ $timezone_format = _x( 'Y-m-d', 'timezone date format' );
180
+ $ig_current_date = strtotime( date_i18n( $timezone_format ) );
181
+ $ig_offer_start = strtotime( "2019-11-22" );
182
+ $ig_offer_end = strtotime( "2019-12-03" );
183
+ if ( ( $ig_current_date >= $ig_offer_start ) && ( $ig_current_date <= $ig_offer_end ) ) {
184
+ include_once( 'ig-offer.php' );
185
+ }
186
+ //bfcm 2019 :end
187
+
188
+ }
189
+
190
+ public function dismiss_admin_notice() {
191
+ if ( isset( $_GET['ig_dismiss_admin_notice'] ) && $_GET['ig_dismiss_admin_notice'] == '1' && isset( $_GET['ig_option_name'] ) ) {
192
+ $option_name = sanitize_text_field( $_GET['ig_option_name'] );
193
+ update_option( $option_name . '_icegram', true );
194
+ if ( $option_name === 'ig_offer_bfcm_done_2019' || $option_name === 'ig_offer_last_day_bfcm_done_2019' ) {
195
+ header( "Location: https://www.icegram.com/?utm_source=in_app&utm_medium=ig_banner&utm_campaign=ig-bfcm-2019" );
196
+ exit();
197
+ } else {
198
+ $referer = wp_get_referer();
199
+ wp_safe_redirect( $referer );
200
+ exit();
201
+ }
202
+ }
203
+ }
204
+
205
+ public function klawoo_subscribe_form() {
206
+ ?>
207
  <div class="wrap">
208
+ <?php
209
+ if ( stripos( get_current_screen()->base, 'settings' ) !== false ) {
210
+ echo "<h2>" . __( 'Free Add-ons, Proven Marketing Tricks and Updates', 'icegram' ) . "</h2>";
211
+ }
212
+ $current_user = wp_get_current_user();
213
+ $customer_email = $current_user->user_email;
214
+ ?>
215
  <table class="form-table">
216
+ <tr>
217
  <th scope="row"><?php _e( 'Get add-ons and tips...', 'icegram' ) ?></th>
218
  <td>
219
  <form name="klawoo_subscribe" action="#" method="POST" accept-charset="utf-8">
220
+ <input class="ltr" type="text" name="name" id="name" placeholder="Name"/>
221
+ <input class="regular-text ltr" type="text" name="email" id="email" placeholder="Email" value="<?php echo $customer_email ?>"/>
222
  <input type="hidden" name="list" value="7I763v6Ldrs3YhJeee5EOgFA"/>
223
  <input type="submit" name="submit" id="submit" class="button button-primary" value="Subscribe">
224
  <br><br>
225
+ <input type="checkbox" name="es-gdpr-agree" id="es-gdpr-agree" value="1" required="required">
226
+ <label for="es-gdpr-agree"><?php echo sprintf( __( 'I have read and agreed to our %s.', 'icegram' ), '<a href="https://www.icegram.com/privacy-policy/" target="_blank">' . __( 'Privacy Policy', 'icegram' ) . '</a>' ); ?></label>
227
  <br>
228
  </form>
229
  <div id="klawoo_response"></div>
232
  </table>
233
  </div>
234
  <script type="text/javascript">
235
+ jQuery(function () {
236
+ jQuery("form[name=klawoo_subscribe]").submit(function (e) {
237
+ e.preventDefault();
238
+
239
+ jQuery('#klawoo_response').html('');
240
+ params = jQuery("form[name=klawoo_subscribe]").serializeArray();
241
+ params.push({name: 'action', value: 'klawoo_subscribe'});
242
+
243
+ jQuery.ajax({
244
+ method: 'POST',
245
+ type: 'text',
246
+ url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
247
+ data: params,
248
+ success: function (response) {
249
+ if (response != '') {
250
+ jQuery('#klawoo_response').html(response);
251
+ } else {
252
+ jQuery('#klawoo_response').html('error!');
253
+ }
254
+ }
255
+ });
256
+ });
257
+ });
258
  </script>
259
+ <?php
260
+ }
261
+
262
+
263
+ public function klawoo_subscribe() {
264
+ $url = 'http://app.klawoo.com/subscribe';
265
+
266
+ if ( ! empty( $_POST ) ) {
267
+ $params = $_POST;
268
+ } else {
269
+ exit();
270
+ }
271
+ $method = 'POST';
272
+ $qs = http_build_query( $params );
273
+
274
+ $options = array(
275
+ 'timeout' => 15,
276
+ 'method' => $method
277
+ );
278
+
279
+ if ( $method == 'POST' ) {
280
+ $options['body'] = $qs;
281
+ } else {
282
+ if ( strpos( $url, '?' ) !== false ) {
283
+ $url .= '&' . $qs;
284
+ } else {
285
+ $url .= '?' . $qs;
286
+ }
287
+ }
288
+
289
+ $response = wp_remote_request( $url, $options );
290
+ if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
291
+ $data = $response['body'];
292
+ if ( $data != 'error' ) {
293
+
294
+ $message_start = substr( $data, strpos( $data, '<body>' ) + 6 );
295
+ $remove = substr( $message_start, strpos( $message_start, '</body>' ) );
296
+ $message = trim( str_replace( $remove, '', $message_start ) );
297
+ echo( $message );
298
+ exit();
299
+ }
300
+ }
301
+ exit();
302
+ }
303
+
304
+ public function icegram_houskeeping() {
305
+ ?>
306
  <div class="wrap">
307
+ <?php
308
+ if ( stripos( get_current_screen()->base, 'settings' ) !== false ) {
309
+ ?>
310
+ <form name="icegram_housekeeping" action="#" method="POST" accept-charset="utf-8">
311
+ <h2><?php _e( 'Housekeeping', 'icegram' ) ?></h2>
312
+ <p class="ig_housekeeping">
313
+ <label for="icegram_remove_shortcodes">
314
+ <input type="checkbox" name="icegram_remove_shortcodes" value="yes"/>
315
+ <?php _e( 'Remove all Icegram shortcodes', 'icegram' ); ?>
316
+ </label>
317
+ <br/><br/>
318
+ <label for="icegram_remove_all_data">
319
+ <input type="checkbox" name="icegram_remove_all_data" value="yes"/>
320
+ <?php _e( 'Remove all Icegram campaigns and messages', 'icegram' ); ?>
321
+ </label>
322
+ <br/><br/>
323
+ <img alt="" src="<?php echo admin_url( 'images/wpspin_light.gif' ) ?>" class="ig_loader" style="vertical-align:middle;display:none"/>
324
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Clean Up', 'icegram' ); ?>">
325
+ <div id="icegram_housekeeping_response"></div>
326
+ </p>
327
+ </form>
328
+
329
  </div>
330
  <script type="text/javascript">
331
+ jQuery(function () {
332
+ jQuery("form[name=icegram_housekeeping]").submit(function (e) {
333
+ if (confirm("<?php _e( 'You won\'t be able to recover this data once you proceed. Do you really want to perform this action?', 'icegram' ); ?>") == true) {
334
+ e.preventDefault();
335
+ jQuery('.ig_loader').show();
336
+ jQuery('#icegram_housekeeping_response').text("");
337
+ params = jQuery("form[name=icegram_housekeeping]").serializeArray();
338
+ params.push({name: 'action', value: 'icegram_run_housekeeping'});
339
+ params.push({name: 'security', value: '<?php echo wp_create_nonce( 'ig_run_housekeeping' ); ?> '});
340
+
341
+ jQuery.ajax({
342
+ method: 'POST',
343
+ type: 'text',
344
+ url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
345
+ data: params,
346
+ success: function (response) {
347
+ jQuery('.ig_loader').hide();
348
+ jQuery('#icegram_housekeeping_response').text("<?php _e( 'Done!', 'icegram' ); ?>");
349
+ }
350
+ });
351
+ }
352
+ });
353
+ });
354
  </script>
355
+ <?php
356
+ }
357
+ }
358
+
359
+ public function run_housekeeping() {
360
+ check_ajax_referer( 'ig_run_housekeeping', 'security' );
361
+ global $wpdb, $current_user;
362
+ $params = $_POST;
363
+ $_POST = array();
364
+ if ( current_user_can( 'manage_options' ) && ! empty( $params['icegram_remove_shortcodes'] ) && $params['icegram_remove_shortcodes'] == 'yes' ) {
365
+ // first get all posts with [icegram] shortcode in them
366
+ $sql = "SELECT * FROM `$wpdb->posts` WHERE `post_content` LIKE '%[icegram %]%' and `post_type` != 'revision' ";
367
+ $posts = $wpdb->get_results( $sql, OBJECT );
368
+ if ( ! empty( $posts ) && is_array( $posts ) ) {
369
+ foreach ( $posts as $post ) {
370
+ $post_content = $post->post_content;
371
+ // remove shortcode with regexp now
372
+ $re = "/\\[icegram(.)*\\]/i";
373
+ $post_content = preg_replace( $re, '', $post_content );
374
+ // save post content back
375
+ if ( $post_content && $post_content != $post->post_content ) {
376
+ wp_update_post( array(
377
+ 'ID' => $post->ID,
378
+ 'post_content' => $post_content
379
+ ) );
380
+ }
381
+ }
382
+ }
383
+ }
384
+
385
+ if ( ! empty( $params['icegram_remove_all_data'] ) && $params['icegram_remove_all_data'] == 'yes' ) {
386
+ $posts = get_posts( array( 'post_type' => array( 'ig_campaign', 'ig_message' ) ) );
387
+ if ( ! empty( $posts ) && is_array( $posts ) ) {
388
+ foreach ( $posts as $post ) {
389
+ wp_delete_post( $post->ID, true );
390
+ }
391
+ }
392
+ do_action( 'icegram_remove_all_data' );
393
+ }
394
+ $_POST = $params;
395
+ }
396
+
397
+ public function icegram_event_track() {
398
+ if ( ! empty( $_POST['ig_local_url_cs'] ) && isset( $_SERVER['HTTP_ORIGIN'] ) ) {
399
+ $parts = parse_url( $_POST['ig_local_url_cs'] );
400
+ $base_url = $parts["scheme"] . "://" . $parts["host"];
401
+ header( 'Access-Control-Allow-Origin: ' . $base_url );
402
+ header( 'Access-Control-Allow-Credentials: true' );
403
+ }
404
+
405
+ if ( ! empty( $_POST['event_data'] ) ) {
406
+ foreach ( $_POST['event_data'] as $event ) {
407
+ switch ( $event['type'] ) {
408
+ case 'shown':
409
+ if ( is_array( $event['params'] ) && ! empty( $event['params']['message_id'] ) ) {
410
+ $messages_shown[] = $event['params']['message_id'];
411
+ if ( ! empty( $event['params']['expiry_time'] ) ) {
412
+ if ( $event['params']['expiry_time'] == 'today' ) {
413
+ $event['params']['expiry_time'] = strtotime( '+1 day', mktime( 0, 0, 0 ) );
414
+ } elseif ( $event['params']['expiry_time'] == 'current_session' ) {
415
+ $event['params']['expiry_time'] = 0;
416
+ } else {
417
+ $event['params']['expiry_time'] = strtotime( $event['params']['expiry_time'] );
418
+ }
419
+
420
+ $event['default'] = true;
421
+ $event = apply_filters( 'icegram_check_event_track', $event );
422
+ if ( $event['default'] ) {
423
+ setcookie( 'icegram_campaign_shown_' . floor( $event['params']['campaign_id'] ), true, $event['params']['expiry_time'], '/' );
424
+ }
425
+ }
426
+ }
427
+ break;
428
+ case 'clicked':
429
+ if ( is_array( $event['params'] ) && ! empty( $event['params']['message_id'] ) ) {
430
+ $messages_clicked[] = $event['params']['message_id'];
431
+ if ( ! empty( $event['params']['expiry_time_clicked'] ) ) {
432
+ if ( $event['params']['expiry_time_clicked'] == 'today' ) {
433
+ $event['params']['expiry_time_clicked'] = strtotime( '+1 day', mktime( 0, 0, 0 ) );
434
+ } elseif ( $event['params']['expiry_time_clicked'] == 'current_session' ) {
435
+ $event['params']['expiry_time_clicked'] = 0;
436
+ } else {
437
+ $event['params']['expiry_time_clicked'] = strtotime( $event['params']['expiry_time_clicked'] );
438
+ }
439
+ //setcookie('icegram_messages_clicked_'.$event['params']['message_id'],true , $event['params']['expiry_time_clicked'] , '/' );
440
+ setcookie( 'icegram_campaign_clicked_' . floor( $event['params']['campaign_id'] ), true, $event['params']['expiry_time_clicked'], '/' );
441
+ }
442
+ }
443
+ break;
444
+
445
+ default:
446
+ break;
447
+ }
448
+
449
+ // Emit event for other plugins to handle it
450
+ do_action( 'icegram_event_track', $event );
451
+ do_action( 'icegram_event_track_' . $event['type'], $event['params'] );
452
+ }
453
+ }
454
+ exit();
455
+ }
456
+
457
+ static function install() {
458
+ // Redirect to welcome screen
459
+ delete_option( '_icegram_activation_redirect' );
460
+ add_option( '_icegram_activation_redirect', 'pending' );
461
+ }
462
+
463
+ public function welcome() {
464
+
465
+ $this->db_update();
466
+ // Bail if no activation redirect transient is set
467
+ if ( false === get_option( '_icegram_activation_redirect' ) ) {
468
+ return;
469
+ }
470
+
471
+ // Delete the redirect transient
472
+ delete_option( '_icegram_activation_redirect' );
473
+
474
+ wp_redirect( admin_url( 'edit.php?post_type=ig_campaign&page=icegram-support' ) );
475
+ exit;
476
+ }
477
+
478
+ function db_update() {
479
+ $current_db_version = get_option( 'icegram_db_version' );
480
+ if ( ! $current_db_version || version_compare( $current_db_version, '1.2', '<' ) ) {
481
+ include( 'updates/icegram-update-1.2.php' );
482
+ }
483
+ }
484
+
485
+ public function admin_menus() {
486
+
487
+ $welcome_page_title = __( 'Welcome to Icegram', 'icegram' );
488
+ $gallery_page_title = '<span style="color:#f18500;font-weight:bolder;">' . __( 'Gallery', 'icegram' ) . '<span>';
489
+ $gallery = add_submenu_page( 'edit.php?post_type=ig_campaign', $gallery_page_title, $gallery_page_title, 'manage_options', 'icegram-gallery', array( $this, 'gallery_screen' ) );
490
+ $settings_page_title = __( 'Settings', 'icegram' );
491
+ $upgrade_page_title = '<span style="color:#f18500;font-weight:bolder;">' . __( 'Upgrade', 'icegram' ) . '</span>';
492
+
493
+ $menu_title = __( 'Docs & Support', 'icegram' );
494
+ $about = add_submenu_page( 'edit.php?post_type=ig_campaign', $welcome_page_title, $menu_title, 'manage_options', 'icegram-support', array( $this, 'about_screen' ) );
495
+ $settings = add_submenu_page( 'edit.php?post_type=ig_campaign', $settings_page_title, $settings_page_title, 'manage_options', 'icegram-settings', array( $this, 'settings_screen' ) );
496
+ $upgrade = add_submenu_page( 'edit.php?post_type=ig_campaign', $upgrade_page_title, $upgrade_page_title, 'manage_options', 'icegram-upgrade', array( $this, 'upgrade_screen' ) );
497
+
498
+
499
+ add_action( 'admin_print_styles-' . $about, array( $this, 'admin_css' ) );
500
+ add_action( 'admin_print_styles-' . $settings, array( $this, 'admin_css' ) );
501
+ add_action( 'admin_print_styles-' . $upgrade, array( $this, 'admin_css' ) );
502
+
503
+ }
504
+
505
+ public function admin_css() {
506
+ wp_enqueue_style( 'icegram-activation', $this->plugin_url . '/assets/css/admin.min.css' );
507
+ }
508
+
509
+ public function about_screen() {
510
+
511
+ // Import data if not done already
512
+ if ( false === get_option( 'icegram_sample_data_imported' ) ) {
513
+ $this->import_sample_data( $this->get_sample_data() );
514
+ }
515
+
516
+ include( 'about-icegram.php' );
517
+ }
518
+
519
+ public function settings_screen() {
520
+ include( 'settings.php' );
521
+ }
522
+
523
+ public function upgrade_screen() {
524
+ // include ( 'addons.php' );
525
+ }
526
+
527
+ public function check_for_gallery_items( $force_update = false ) {
528
+ global $icegram;
529
+ if ( $force_update === true || false === ( $ig_last_gallery_item_update = get_transient( 'ig_last_gallery_item_update' ) ) ) {
530
+ // $url_for_gallery_item = 'https://www.icegram.com/gallery/wp-json/wp/v2/galleryitem?per_page=200&page=1';
531
+ $url_for_gallery_item = 'https://www.icegram.com/gallery/wp-json/wp/v2/galleryitem?filter[posts_per_page]=200';
532
+ $ig_gallery_json = wp_remote_get( $url_for_gallery_item );
533
+ if ( ! is_wp_error( $ig_gallery_json ) ) {
534
+ $ig_gallery_json = ( wp_remote_retrieve_body( $ig_gallery_json ) );
535
+ if ( ! empty( $ig_gallery_json ) ) {
536
+ update_option( 'ig_last_gallery_items', $ig_gallery_json );
537
+ }
538
+ } else {
539
+ update_option( 'requested_gallery_item_with_ajax', 'yes' );
540
+ ?>
541
  <script type="text/javascript">
542
+ jQuery(document).ready(function () {
543
+ jQuery.ajax({
544
+ url: '<?php echo esc_url( $url_for_gallery_item ); ?>',
545
+ method: 'GET',
546
+ dataType: 'json',
547
+ success: function (response) {
548
+ if (response != undefined && response != '') {
549
+ //ajax to save data
550
+ jQuery.ajax({
551
+ url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
552
+ method: 'POST',
553
+ dataType: 'json',
554
+ data: {
555
+ action: 'save_gallery_data',
556
+ galleryitems: JSON.stringify(response),
557
+ security: '<?php echo wp_create_nonce( 'gallery-save-data' ); // WPCS: XSS ok. ?>'
558
+ },
559
+ success: function (res) {
560
+ if (res != undefined && res != '' && res.success != undefined && res.success == 'yes') {
561
+ // All done.
562
+ }
563
+ }
564
+ });
565
+ }
566
+ },
567
+ error: function (response) {
568
+ console.log(response, 'res');
569
+
570
+ }
571
+ });
572
+ });
573
  </script>
574
+ <?php }
575
+ $url_for_categories = 'https://www.icegram.com/gallery/wp-json/wp/v2/custom_cat?filter[orderby]=parent&order=desc';
576
+ $options = array(
577
+ 'timeout' => 15,
578
+ 'method' => 'GET',
579
+ 'body' => ''
580
+ );
581
+ $response = wp_remote_request( $url_for_categories, $options );
582
+ $response_code = wp_remote_retrieve_response_code( $response );
583
+ // $body = json_decode($response['body'] ,true);
584
+ if ( $response_code == 200 ) {
585
+ $categories = json_decode( $response['body'], true );
586
+ $cat_list = array();
587
+ foreach ( $categories as $category ) {
588
+ if ( $category['parent'] == 0 ) {
589
+ $cat_list[ $category['term_id'] ]['name'] = $category['name'];
590
+ $cat_list[ $category['term_id'] ]['slug'] = $category['slug'];
591
+ $cat_list[ $category['term_id'] ]['term_id'] = $category['term_id'];
592
+ } else {
593
+ $cat_list[ $category['parent'] ]['list'][] = $category;
594
+ }
595
+ }
596
+ $featured_cat = $cat_list[53];
597
+ unset( $cat_list[53] );
598
+ array_unshift( $cat_list, $featured_cat );
599
+ update_option( 'ig_cat_list', $cat_list );
600
+ } else {
601
+ ?>
602
+ <script type="text/javascript">
603
+ jQuery(document).ready(function () {
604
+ jQuery.ajax({
605
+ url: '<?php echo esc_url( $url_for_categories ); ?>',
606
+ method: 'GET',
607
+ dataType: 'json',
608
+ success: function (response) {
609
+
610
+ if (response != undefined && response != '') {
611
+ //ajax to save data
612
+ jQuery.ajax({
613
+ url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
614
+ method: 'POST',
615
+ dataType: 'json',
616
+ data: {
617
+ action: 'save_gallery_data',
618
+ categories: response,
619
+ security: '<?php echo wp_create_nonce( 'gallery-save-data' ); // WPCS: XSS ok. ?>'
620
+ },
621
+ success: function (res) {
622
+ if (res != undefined && res != '' && res.success != undefined && res.success == 'yes') {
623
+ // All done.
624
+ }
625
+ }
626
+ });
627
+ }
628
+ },
629
+ error: function (response) {
630
+ console.log(response, 'res');
631
+
632
+ }
633
+ });
634
+ });
635
  </script>
636
+ <?php
637
+ }
638
+ set_transient( 'ig_last_gallery_item_update', current_time( 'timestamp' ), 24 * HOUR_IN_SECONDS ); // 1 day
639
+ }
640
+ }
641
+
642
+ public function save_gallery_data() {
643
+ check_ajax_referer( 'gallery-save-data', 'security' );
644
+ if ( current_user_can( 'manage_options' ) ) {
645
+ if ( ! empty( $_REQUEST ) && ! empty( $_REQUEST['galleryitems'] ) ) {
646
+ $ig_gallery_json = stripslashes( $_REQUEST['galleryitems'] );
647
+ update_option( 'ig_last_gallery_items', $ig_gallery_json );
648
+ }
649
+ if ( ! empty( $_REQUEST ) && ! empty( $_REQUEST['categories'] ) ) {
650
+ $categories = $_REQUEST['categories'];
651
+ $cat_list = array();
652
+ foreach ( $categories as $category ) {
653
+ if ( $category['parent'] == 0 ) {
654
+ $cat_list[ $category['term_id'] ]['name'] = $category['name'];
655
+ $cat_list[ $category['term_id'] ]['slug'] = $category['slug'];
656
+ } else {
657
+ $cat_list[ $category['parent'] ]['list'][] = $category;
658
+ }
659
+ }
660
+ update_option( 'ig_cat_list', $cat_list );
661
+ }
662
+ }
663
+
664
+ }
665
+
666
+ public static function gallery_screen() {
667
+ global $icegram;
668
+ //check for new gallery item
669
+ $ig_last_gallery_item_update = get_transient( 'ig_last_gallery_item_update' );
670
+
671
+ if ( empty( $ig_last_gallery_item_update ) ) {
672
+ $icegram->check_for_gallery_items( true );
673
+ }
674
+ $ig_gallery_items = get_option( 'ig_last_gallery_items', true );
675
+ $cat_list = get_option( 'ig_cat_list', true );
676
+ include( 'gallery.php' );
677
+ wp_register_script( 'ig_gallery_js', $icegram->plugin_url . '/assets/js/gallery.min.js', array( 'jquery', 'backbone', 'wp-backbone', 'wp-a11y', 'wp-util' ), $icegram->version, true );
678
+ if ( ! wp_script_is( 'ig_gallery_js' ) ) {
679
+ wp_enqueue_script( 'ig_gallery_js' );
680
+ $imported_gallery_items = get_option( 'ig_imported_gallery_items', true );
681
+ $ig_plan = get_option( 'ig_engage_plan' );
682
+ $ig_plan = ( ! empty( $ig_plan ) ) ? ( ( $ig_plan == 'plus' ) ? 1 : ( ( $ig_plan == 'pro' ) ? 2 : ( ( $ig_plan == 'max' ) ? 3 : 0 ) ) ) : 0;
683
+ $ig_gallery_json =
684
+ wp_localize_script( 'ig_gallery_js', '_wpThemeSettings', array(
685
+ 'themes' => json_decode( $ig_gallery_items, true ),
686
+ 'settings' => array(
687
+ 'canInstall' => ( ! is_multisite() && ( 'install_themes' ) ),
688
+ 'isInstall' => true,
689
+ 'installURI' => ( ! is_multisite() && ( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
690
+ 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete.", 'icegram' ),
691
+ 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ),
692
+ 'ig_plan' => $ig_plan,
693
+ 'cat_list' => $cat_list
694
+ ),
695
+ 'l10n' => array(
696
+ 'addNew' => __( 'Add New Gallery Templates', 'icegram' ),
697
+ 'search' => __( 'Search Gallery Templates', 'icegram' ),
698
+ 'searchPlaceholder' => __( 'Search Design Templates', 'icegram' ), // placeholder (no ellipsis)
699
+ 'themesFound' => __( 'Number of Gallery Templates found: %d', 'icegram' ),
700
+ 'noThemesFound' => __( 'No Gallery Templates found. Try a different search.', 'icegram' ),
701
+ ),
702
+ 'installedThemes' => $imported_gallery_items
703
+ ) );
704
+ }
705
+ }
706
+
707
+ public function branding_data_remove( $icegram_branding_data ) {
708
+ if ( ! empty( $icegram_branding_data ) && 'yes' != get_option( 'icegram_share_love', 'no' ) ) {
709
+ $icegram_branding_data['powered_by_logo'] = '';
710
+ $icegram_branding_data['powered_by_text'] = '';
711
+ }
712
+
713
+ return $icegram_branding_data;
714
+ }
715
+
716
+ //Execute Form shortcode
717
+ function execute_form_shortcode( $atts = array() ) {
718
+ return '<div class="ig_form_container layout_inline"></div>';
719
+ }
720
+
721
+ function execute_shortcode( $atts = array(), $content = null ) {
722
+ // When shortcode is called, it will only prepare an array with conditions
723
+ // And add a placeholder div
724
+ // Display will happen in footer via display_messages()
725
+ $i = count( $this->shortcode_instances );
726
+ $this->shortcode_instances[ $i ] = shortcode_atts( array(
727
+ 'campaigns' => '',
728
+ 'messages' => '',
729
+ 'skip_others' => 'no'
730
+ ), $atts );
731
+
732
+ $class[] = "ig_shortcode_container";
733
+ $html[] = "<div id='icegram_shortcode_{$i}'";
734
+ if ( ! empty( $atts['campaigns'] ) && ! empty( $content ) ) {
735
+ $this->shortcode_instances[ $i ]['with_content'] = true;
736
+ $class[] = "trigger_onclick";
737
+ }
738
+ foreach ( $atts as $key => $value ) {
739
+ $value = str_replace( ",", " ", $value );
740
+ $html[] = " data-{$key}=\"" . htmlentities( $value ) . "\" ";
741
+ }
742
+ $class = implode( " ", $class );
743
+ $html[] = "class='" . $class . "' >" . $content . "</div>";
744
+
745
+ return implode( " ", $html );
746
+ }
747
+
748
+ // Do not index Icegram campaigns / messages...
749
+ // Not using currently - made custom post types non public...
750
+ function icegram_load_data() {
751
+ global $post;
752
+ $icegram_pre_data['ajax_url'] = admin_url( 'admin-ajax.php' );
753
+ $icegram_pre_data['post_obj'] = $_GET;
754
+ $icegram_pre_data['post_obj']['is_home'] = ( is_home() || is_front_page() ) ? true : false;
755
+ $icegram_pre_data['post_obj']['page_id'] = is_object( $post ) && isset( $post->ID ) ? $post->ID : 0;
756
+ $icegram_pre_data['post_obj']['action'] = 'display_messages';
757
+ $icegram_pre_data['post_obj']['shortcodes'] = $this->shortcode_instances;
758
+ $icegram_pre_data['post_obj']['cache_compatibility'] = $this->cache_compatibility;
759
+ $icegram_pre_data['post_obj']['device'] = $this->get_platform();
760
+ wp_register_script( 'icegram_main_js', $this->plugin_url . '/assets/js/main.min.js', array( 'jquery' ), $this->version, true );
761
+ if ( ! wp_script_is( 'icegram_main_js' ) ) {
762
+ wp_enqueue_script( 'icegram_main_js' );
763
+ wp_localize_script( 'icegram_main_js', 'icegram_pre_data', $icegram_pre_data );
764
+ }
765
+ }
766
+
767
+ function display_messages() {
768
+
769
+ $skip_others = $preview_mode = false;
770
+ $campaign_ids = $message_ids = array();
771
+ $this->shortcode_instances = ( $this->cache_compatibility == 'yes' && ! empty( $_REQUEST['shortcodes'] ) ) ? $_REQUEST['shortcodes'] : $this->shortcode_instances;
772
+ // Pull in message and campaign IDs from shortcodes - if set
773
+ if ( ! empty( $this->shortcode_instances ) ) {
774
+ foreach ( $this->shortcode_instances as $i => $value ) {
775
+ $cids = array_map( 'trim', (array) explode( ',', intval( $value['campaigns'] ) ) );
776
+ $mids = array_map( 'trim', (array) explode( ',', intval( $value['messages'] ) ) );
777
+ if ( ! empty( $value['skip_others'] ) && $value['skip_others'] == 'yes' && ( ! empty( $cids ) || ! empty( $mids ) ) ) {
778
+ $skip_others = true;
779
+ }
780
+ $campaign_ids = array_merge( $campaign_ids, $cids );
781
+ $message_ids = array_merge( $message_ids, $mids );
782
+ }
783
+ }
784
+ if ( ! empty( $_REQUEST['campaign_preview_id'] ) && intval( $_REQUEST['campaign_preview_id'] ) && ( 'edit_posts' ) ) {
785
+ $campaign_ids = array( intval( $_REQUEST['campaign_preview_id'] ) );
786
+ $preview_mode = true;
787
+ }
788
+
789
+
790
+ $messages = $this->get_valid_messages( $message_ids, $campaign_ids, $preview_mode, $skip_others );
791
+
792
+ if ( empty( $messages ) ) {
793
+ //wp_die(0);
794
+ return;
795
+ }
796
+
797
+ $messages_to_show_ids = array();
798
+ foreach ( $messages as $key => $message_data ) {
799
+
800
+ if ( ! is_array( $message_data ) || empty( $message_data ) ) {
801
+ continue;
802
+ }
803
+
804
+ // Don't show a seen message again - if needed
805
+ // change to campaign targetting in v1.9.1
806
+ if ( ! empty( $message_data['id'] ) &&
807
+ empty( $_GET['campaign_preview_id'] ) &&
808
+ ! empty( $message_data['retargeting'] ) &&
809
+ $message_data['retargeting'] == 'yes'
810
+ ) {
811
+ if ( ! empty( $_COOKIE[ 'icegram_messages_shown_' . $message_data['id'] ] ) || ! empty( $_COOKIE[ 'icegram_campaign_shown_' . floor( $message_data['campaign_id'] ) ] ) ) {
812
+ unset( $messages[ $key ] );
813
+ continue;
814
+ }
815
+ }
816
+ if ( ! empty( $message_data['id'] ) &&
817
+ empty( $_GET['campaign_preview_id'] ) &&
818
+ ! empty( $message_data['retargeting_clicked'] ) &&
819
+ $message_data['retargeting_clicked'] == 'yes'
820
+ ) {
821
+ if ( ! empty( $_COOKIE[ 'icegram_messages_clicked_' . $message_data['id'] ] ) || ! empty( $_COOKIE[ 'icegram_campaign_clicked_' . floor( $message_data['campaign_id'] ) ] ) ) {
822
+ unset( $messages[ $key ] );
823
+ continue;
824
+ }
825
+ }
826
+
827
+ // Avoid showing the same message twice
828
+ if ( in_array( $message_data['id'], $messages_to_show_ids ) ) {
829
+ unset ( $messages[ $key ] );
830
+ continue;
831
+ } else {
832
+ $messages_to_show_ids[] = $message_data['id'];
833
+ }
834
+
835
+ $this->process_message_body( $messages[ $key ] );
836
+ }
837
+ if ( empty( $messages ) ) {
838
+ return;
839
+ }
840
+ $icegram_default = apply_filters( 'icegram_branding_data',
841
+ array(
842
+ 'icon' => $this->plugin_url . '/assets/images/icegram-logo-branding-64-grey.png',
843
+ 'powered_by_logo' => $this->plugin_url . '/assets/images/icegram-logo-branding-64-grey.png',
844
+ 'powered_by_text' => __( 'Powered by Icegram', 'icegram' )
845
+ ) );
846
+ $messages = apply_filters( 'icegram_messages_to_show', $messages );
847
+ $icegram_data = apply_filters( 'icegram_data', array(
848
+ 'messages' => array_values( $messages ),
849
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
850
+ 'preview_id' => ! empty( $_GET['campaign_preview_id'] ) ? $_GET['campaign_preview_id'] : '',
851
+ 'defaults' => $icegram_default
852
+ ) );
853
+ if ( empty( $icegram_data['preview_id'] ) ) {
854
+ unset( $icegram_data['preview_id'] );
855
+ }
856
+
857
+ do_action( 'icegram_print_js_css_data', $icegram_data );
858
+
859
+ do_action( 'icegram_data_printed' );
860
+ }
861
+
862
+ function two_step_mobile_popup( $icegram_data ) {
863
+
864
+ $temp = array();
865
+ foreach ( $icegram_data['messages'] as $message_id => $message ) {
866
+
867
+ if ( ! empty( $message['ig_mobile_popup'] ) && $message['ig_mobile_popup'] == true ) {
868
+ $action_bar = $message;
869
+ $action_bar['type'] = 'action-bar';
870
+ $action_bar['theme'] = 'hello';
871
+ $action_bar['position'] = '21';
872
+ $action_bar['message'] = '';
873
+ $action_bar['label'] = __( 'Show More', 'icegram' );
874
+ $action_bar['id'] = $action_bar['id'] . '_00';
875
+ $action_bar['use_custom_code'] = 'yes';
876
+ $action_bar['form_html'] = '';
877
+ $action_bar['form_html_original'] = '';
878
+ $action_bar['rainmaker_form_code'] = '';
879
+ $action_bar['link'] = '';
880
+ $action_bar['redirect_to_link'] = '';
881
+ $action_bar['cta'] = '';
882
+ $action_bar['alt_cta'] = '';
883
+ $action_bar['add_alt_cta'] = '';
884
+ $action_bar['custom_css'] = '#ig_this_message .ig_close{display:none;}';
885
+ $action_bar['custom_js'] = "<script type='text/javascript'>jQuery('#icegram_message_" . $action_bar['id'] . "').on('click', '.ig_button', function(){icegram.get_message_by_id('" . $action_bar['id'] . "').hide(); icegram.get_message_by_id('" . $message['id'] . "').show(); });</script>";
886
+ unset( $action_bar['ig_mobile_popup'] );
887
+ $temp[] = $action_bar;
888
+ }
889
+ }
890
+ $icegram_data['messages'] = array_merge( $icegram_data['messages'], $temp );
891
+ unset( $temp );
892
+
893
+ return $icegram_data;
894
+ }
895
+
896
+
897
+ function print_js_css_data( $icegram_data ) {
898
+
899
+ $this->collect_js_and_css( $icegram_data );
900
+ if ( $this->cache_compatibility === 'yes' ) {
901
+ echo json_encode( $icegram_data );
902
+ wp_die();
903
+ } else {
904
+ wp_localize_script( 'icegram_main_js', 'icegram_data', $icegram_data );
905
+ }
906
+ }
907
+
908
+ function collect_js_and_css( &$icegram_data ) {
909
+
910
+ $types_shown = array();
911
+ $scripts = array();
912
+ $css = array();
913
+ foreach ( $icegram_data['messages'] as $key => $message_data ) {
914
+ $types_shown[] = $message_data['type'];
915
+ }
916
+
917
+ $types_shown = array_unique( $types_shown );
918
+ $ver_prefix = '?var=' . $this->version;
919
+
920
+ $scripts[] = $this->plugin_url . "/assets/js/icegram.min.js" . $ver_prefix;
921
+ $css[] = $this->plugin_url . "/assets/css/frontend.min.css" . $ver_prefix;
922
+ //minify and combine only for default msg type
923
+ $ig_core_message_types = array( 'popup', 'action-bar', 'toast', 'messenger' );
924
+ // Load JS and default CSS
925
+ foreach ( $types_shown as $message_type ) {
926
+ if ( ! in_array( $message_type, $ig_core_message_types ) ) {
927
+ $scripts[] = $this->message_types[ $message_type ]['baseurl'] . "main.js" . $ver_prefix;
928
+ $css[] = $this->message_types[ $message_type ]['baseurl'] . "default.css" . $ver_prefix;
929
+ } else {
930
+ $css[] = $this->message_types[ $message_type ]['baseurl'] . 'themes/' . $message_type . ".min.css" . $ver_prefix;
931
+ }
932
+ }
933
+
934
+ //TODO :: add theme pack theme css files too.
935
+ // Load theme CSS
936
+ foreach ( $icegram_data['messages'] as $key => $message ) {
937
+ if ( ! empty( $this->message_types[ $message['type'] ]['themes'][ $message['theme'] ] ) ) {
938
+ $theme = $this->message_types[ $message['type'] ]['themes'][ $message['theme'] ]['baseurl'] . $message['theme'] . '.css' . $ver_prefix;
939
+ } else {
940
+ $theme_default = $this->message_types[ $message['type'] ] ['settings']['theme']['default'];
941
+ $theme = $this->message_types[ $message['type'] ]['themes'][ $theme_default ]['baseurl'] . $theme_default . '.css' . $ver_prefix;
942
+ $icegram_data['messages'][ $key ]['theme'] = $theme_default;
943
+ }
944
+ if ( ! preg_match( '/icegram\/message-types/i', $theme ) ) {
945
+ $css [] = $theme;
946
+ }
947
+ }
948
+ $css = array_unique( $css );
949
+ $icegram_data['scripts'] = apply_filters( 'add_icegram_script', $scripts );
950
+ $icegram_data['css'] = apply_filters( 'add_icegram_css', $css );
951
+
952
+ return $icegram_data;
953
+ }
954
+
955
+ // Process
956
+ function process_message_body( &$message_data ) {
957
+ global $wp_scripts;
958
+ global $wp_styles;
959
+
960
+ if ( $this->cache_compatibility == 'yes' ) {
961
+ $q_script = ! empty( $wp_scripts->queue ) ? $wp_scripts->queue : array();
962
+ $q_style = ! empty( $wp_styles->queue ) ? $wp_styles->queue : array();
963
+ }
964
+ $content = $message_data['message'];
965
+ $content = convert_chars( convert_smilies( wptexturize( $content ) ) );
966
+ if ( isset( $GLOBALS['wp_embed'] ) ) {
967
+ $content = $GLOBALS['wp_embed']->autoembed( $content );
968
+ }
969
+ $content = $this->after_wpautop( wpautop( $this->before_wpautop( $content ) ) );
970
+ $content = do_shortcode( shortcode_unautop( $content ) );
971
+ $message_data['message'] = $content;
972
+
973
+ //do_shortcode in headline
974
+ $message_data['headline'] = do_shortcode( shortcode_unautop( $message_data['headline'] ) );
975
+ //shortcode support for Third party forms and Rainmaker
976
+ $form_html_original = ! empty( $message_data["rainmaker_form_code"] )
977
+ ? ( '[rainmaker_form id="' . $message_data["rainmaker_form_code"] . '"]' )
978
+ : ( ! empty( $message_data['form_html_original'] ) ? $message_data['form_html_original'] : '' );
979
+ $form_html_original = ! empty( $message_data["es_form_code"] )
980
+ ? ( '[email-subscribers-form id="' . $message_data["es_form_code"] . '"]' )
981
+ : $form_html_original;
982
+
983
+ if ( ! empty( $form_html_original ) ) {
984
+ $message_data['form_html'] = do_shortcode( shortcode_unautop( $form_html_original ) );
985
+ }
986
+ //TODO :: Handle case for inline style and script
987
+ if ( $this->cache_compatibility == 'yes' ) {
988
+ $handles = ! empty( $wp_scripts->queue ) ? array_diff( $wp_scripts->queue, $q_script ) : array();
989
+ unset( $q_script );
990
+ if ( ! empty( $handles ) ) {
991
+ if ( empty( $message_data['assets'] ) ) {
992
+ $message_data['assets'] = array();
993
+ }
994
+
995
+ ob_start();
996
+ $wp_scripts->do_items( $handles );
997
+ $message_data['assets']['scripts'] = array_filter( explode( '<script', ob_get_clean() ) );
998
+ }
999
+
1000
+ //TODO :: do_items if required
1001
+ $handles = ! empty( $wp_styles->queue ) ? array_diff( $wp_styles->queue, $q_style ) : array();
1002
+ unset( $q_style );
1003
+ if ( ! empty( $handles ) ) {
1004
+ if ( empty( $message_data['assets'] ) ) {
1005
+ $message_data['assets'] = array();
1006
+ }
1007
+
1008
+ foreach ( $handles as $handle ) {
1009
+ ob_start();
1010
+ $wp_styles->do_item( $handle );
1011
+ $message_data['assets']['styles'][ $handle ] = ob_get_clean();
1012
+ }
1013
+ }
1014
+ }
1015
+ }
1016
+
1017
+ function enqueue_admin_styles_and_scripts() {
1018
+
1019
+ $screen = get_current_screen();
1020
+ if ( ! in_array( $screen->id, array( 'ig_campaign', 'ig_message', 'edit-ig_campaign' ), true ) ) {
1021
+ return;
1022
+ }
1023
+
1024
+ // Register scripts
1025
+ wp_register_script( 'icegram_writepanel', $this->plugin_url . '/assets/js/admin.min.js', array( 'jquery', 'wp-color-picker' ), $this->version );
1026
+
1027
+ wp_enqueue_script( 'icegram_writepanel' );
1028
+
1029
+ $icegram_writepanel_params = array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'search_message_nonce' => wp_create_nonce( "search-messages" ), 'home_url' => home_url( '/' ) );
1030
+ $this->available_headlines = apply_filters( 'icegram_available_headlines', array() );
1031
+ $icegram_writepanel_params = array_merge( $icegram_writepanel_params, array( 'available_headlines' => $this->available_headlines ) );
1032
+
1033
+ wp_localize_script( 'icegram_writepanel', 'icegram_writepanel_params', $icegram_writepanel_params );
1034
+
1035
+ wp_enqueue_style( 'dashicons' );
1036
+ wp_enqueue_style( 'wp-color-picker' );
1037
+ wp_enqueue_style( 'icegram_admin_styles', $this->plugin_url . '/assets/css/admin.min.css', array(), $this->version );
1038
+
1039
+ if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
1040
+ wp_enqueue_script( 'jquery-ui-datepicker' );
1041
+ }
1042
+
1043
+ }
1044
+
1045
+ //execute shortcode in text widget
1046
+ function ig_widget_text_filter( $content ) {
1047
+ if ( ! preg_match( '/\[[\r\n\t ]*icegram?[\r\n\t ].*?\]/', $content ) ) {
1048
+ return $content;
1049
+ }
1050
+
1051
+ $content = do_shortcode( $content );
1052
+
1053
+ return $content;
1054
+ }
1055
+
1056
+ public static function get_platform() {
1057
+ $mobile_detect = new Ig_Mobile_Detect();
1058
+ $mobile_detect->setUserAgent();
1059
+ if ( $mobile_detect->isMobile() ) {
1060
+ return ( $mobile_detect->isTablet() ) ? 'tablet' : 'mobile';
1061
+ } elseif ( $mobile_detect->isTablet() ) {
1062
+ return 'tablet';
1063
+ }
1064
+
1065
+ return 'laptop';
1066
+ }
1067
+
1068
+ function get_message_data( $message_ids = array(), $preview = false ) {
1069
+ global $wpdb;
1070
+ $message_data = array();
1071
+ $original_message_id_map = array();
1072
+ $meta_key = $preview ? 'icegram_message_preview_data' : 'icegram_message_data';
1073
+ $message_data_query = "SELECT post_id, meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE '$meta_key'";
1074
+ if ( ! empty( $message_ids ) && is_array( $message_ids ) ) {
1075
+ // For WPML compatibility
1076
+ if ( function_exists( 'icl_object_id' ) ) {
1077
+ $wpml_settings = get_option( 'icl_sitepress_settings' );
1078
+ $original_if_missing = ( is_array( $wpml_settings ) && array_key_exists( 'show_untranslated_blog_posts', $wpml_settings ) && ! empty( $wpml_settings['show_untranslated_blog_posts'] ) ) ? true : false;
1079
+
1080
+ foreach ( $message_ids as $i => $id ) {
1081
+ $translated = icl_object_id( $id, 'ig_message', $original_if_missing );
1082
+ $message_ids[ $i ] = $translated;
1083
+ $original_message_id_map[ $translated ] = $id;
1084
+ }
1085
+ }
1086
+ $message_ids = array_filter( array_unique( $message_ids ) );
1087
+ if ( ! empty( $message_ids ) ) {
1088
+ $message_data_query .= " AND post_id IN ( " . implode( ',', $message_ids ) . " )";
1089
+ $message_data_results = $wpdb->get_results( $message_data_query, 'ARRAY_A' );
1090
+ foreach ( $message_data_results as $message_data_result ) {
1091
+ $data = maybe_unserialize( $message_data_result['meta_value'] );
1092
+ if ( ! empty( $data ) ) {
1093
+ $message_data[ $message_data_result['post_id'] ] = $data;
1094
+ // For WPML compatibility
1095
+ if ( ! empty( $original_message_id_map[ $message_data_result['post_id'] ] ) ) {
1096
+ $message_data[ $message_data_result['post_id'] ]['original_message_id'] = $original_message_id_map[ $message_data_result['post_id'] ];
1097
+ }
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+
1103
+ return $message_data;
1104
+ }
1105
+
1106
+ function get_valid_messages( $message_ids = array(), $campaign_ids = array(), $preview_mode = false, $skip_others = false ) {
1107
+ list( $message_ids, $campaign_ids, $preview_mode, $skip_others ) = apply_filters( 'icegram_get_valid_messages_params', array( $message_ids, $campaign_ids, $preview_mode, $skip_others ) );
1108
+
1109
+ $valid_messages = $valid_campaigns = $message_campaign_map = array();
1110
+
1111
+ $campaign_ids = array_filter( array_unique( (array) $campaign_ids ) );
1112
+ $message_ids = array_filter( array_unique( (array) $message_ids ) );
1113
+ if ( ! empty( $campaign_ids ) ) {
1114
+ $valid_campaigns = $this->get_valid_campaigns( $campaign_ids, true, $preview_mode );
1115
+ }
1116
+
1117
+ // When skip_others is true, we won't load campaigns / messages from db
1118
+ if ( ! $skip_others && ! $preview_mode ) {
1119
+ $campaigns = $this->get_valid_campaigns();
1120
+ if ( ! empty( $campaigns ) ) {
1121
+ foreach ( $campaigns as $id => $campaign ) {
1122
+ if ( ! array_key_exists( $id, $valid_campaigns ) ) {
1123
+ $valid_campaigns[ $id ] = $campaign;
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+
1129
+ // Create a map to look up campaign id for a given message
1130
+ if ( ! empty( $valid_campaigns ) ) {
1131
+ foreach ( $valid_campaigns as $id => $campaign ) {
1132
+ if ( $preview_mode ) {
1133
+ $campaign->messages = get_post_meta( $id, 'campaign_preview', true );
1134
+ }
1135
+ if ( ! empty( $campaign->messages ) ) {
1136
+ foreach ( $campaign->messages as $msg ) {
1137
+ $message_ids[] = $msg['id'];
1138
+ if ( ! array_key_exists( $msg['id'], $message_campaign_map ) ) {
1139
+ $message_campaign_map[ $msg['id'] ] = $id;
1140
+ }
1141
+ }
1142
+ }
1143
+ }
1144
+ }
1145
+
1146
+ // We don't display same message twice...
1147
+ $message_ids = array_unique( $message_ids );
1148
+
1149
+ if ( empty( $message_ids ) ) {
1150
+ return array();
1151
+ }
1152
+ $valid_messages = $this->get_message_data( $message_ids, $preview_mode );
1153
+
1154
+ foreach ( $valid_messages as $id => $message_data ) {
1155
+ // Remove message if required fields are missing
1156
+ if ( empty( $message_data ) || empty( $message_data['type'] ) ) {
1157
+ unset( $valid_messages[ $id ] );
1158
+ continue;
1159
+ }
1160
+ // Remove message if message type is uninstalled
1161
+ $class_name = 'Icegram_Message_Type_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $message_data['type'] ) ) );
1162
+ if ( ! class_exists( $class_name ) ) {
1163
+ unset( $valid_messages[ $id ] );
1164
+ continue;
1165
+ }
1166
+ $message_data['delay_time'] = 0;
1167
+ $message_data['retargeting'] = '';
1168
+ $message_data['campaign_id'] = ( $preview_mode ) ? $_REQUEST['campaign_preview_id'] : '';
1169
+
1170
+ // Pull display time and retargeting rule from campaign if possible
1171
+ $message_id = ( ! empty( $message_data['original_message_id'] ) ) ? $message_data['original_message_id'] : $id;
1172
+ if ( ! empty( $message_campaign_map[ $message_id ] ) ) {
1173
+ //modify campaign id
1174
+ $message_data['campaign_id'] = apply_filters( 'modify_campaing_id', $message_campaign_map[ $message_id ], $message_id );
1175
+ $campaign = $valid_campaigns[ floor( $message_data['campaign_id'] ) ];
1176
+ if ( ! empty( $campaign ) && $campaign instanceof Icegram_Campaign ) {
1177
+ $message_meta_from_campaign = $campaign->get_message_meta_by_id( $message_id );
1178
+ if ( ! empty( $message_meta_from_campaign['time'] ) ) {
1179
+ $message_data['delay_time'] = $message_meta_from_campaign['time'];
1180
+ }
1181
+
1182
+ //check if campaign is targeted to mobile at zero
1183
+ $device_rule = $campaign->get_rule_value( 'device' );
1184
+ if ( $this->get_platform() !== 'laptop' && ! empty( $device_rule['mobile'] ) && $device_rule['mobile'] == 'yes' && $message_data['delay_time'] == 0 && $message_data['type'] == 'popup' ) {
1185
+ $message_data['ig_mobile_popup'] = true;
1186
+ if ( ! empty( $message_data['triggers'] ) && ! empty( $message_data['triggers']['when_to_show'] ) ) {
1187
+ $message_data['ig_mobile_popup'] = ( $message_data['triggers']['when_to_show'] == 'duration_on_page' && $message_data['triggers']['duration_on_page'] == 0 ) ? true : false;
1188
+ }
1189
+ }
1190
+ //set delay time -1 if shortcode with content
1191
+ foreach ( $this->shortcode_instances as $i => $value ) {
1192
+ $campaign_ids = explode( ',', $value['campaigns'] );
1193
+ if ( ! empty( $value['with_content'] ) && in_array( $message_data['campaign_id'], $campaign_ids ) ) {
1194
+ $message_data['delay_time'] = - 1;
1195
+ }
1196
+ }
1197
+ $rule_value = $campaign->get_rule_value( 'retargeting' );
1198
+ $message_data['retargeting'] = ! empty( $rule_value['retargeting'] ) ? $rule_value['retargeting'] : '';
1199
+ $message_data['expiry_time'] = ! empty( $rule_value['retargeting'] ) ? $rule_value['expiry_time'] : '';
1200
+ $rule_value_retargeting_clicked = $campaign->get_rule_value( 'retargeting_clicked' );
1201
+ $message_data['retargeting_clicked'] = ! empty( $rule_value_retargeting_clicked['retargeting_clicked'] ) ? $rule_value_retargeting_clicked['retargeting_clicked'] : '';
1202
+ $message_data['expiry_time_clicked'] = ! empty( $rule_value_retargeting_clicked['retargeting_clicked'] ) ? $rule_value_retargeting_clicked['expiry_time_clicked'] : '';
1203
+
1204
+ }
1205
+ }
1206
+ $valid_messages[ $id ] = $message_data;
1207
+ }
1208
+ $valid_messages = apply_filters( 'icegram_valid_messages', $valid_messages );
1209
+
1210
+ return $valid_messages;
1211
+ }
1212
+
1213
+ function get_valid_campaigns( $campaign_ids = array(), $skip_page_check = false, $preview_mode = false ) {
1214
+ global $wpdb;
1215
+ if ( empty( $campaign_ids ) ) {
1216
+ $sql = "SELECT pm.post_id
1217
  FROM {$wpdb->prefix}posts AS p
1218
  LEFT JOIN {$wpdb->prefix}postmeta AS pm ON ( pm.post_id = p.ID )
1219
  WHERE p.post_status = 'publish' ";
1220
+ // Filter handler within this file (and possibly others) will append to this SQL
1221
+ // and provide arguments for wpdb->prepare if needed.
1222
+ // First element in the array is SQL, remaining are values for placeholders in SQL
1223
+ $sql_params = apply_filters( 'icegram_get_valid_campaigns_sql', array( $sql ), array() );
1224
+ $campaign_ids = $wpdb->get_col( $wpdb->prepare( array_shift( $sql_params ), $sql_params ) );
1225
+ }
1226
+ $valid_campaigns = array();
1227
+ foreach ( (array) $campaign_ids as $campaign_id ) {
1228
+ $campaign = new Icegram_Campaign( $campaign_id );
1229
+ if ( $preview_mode || $campaign->is_valid( array( 'skip_page_check' => $skip_page_check ) ) ) {
1230
+ $valid_campaigns[ $campaign_id ] = $campaign;
1231
+ } else {
1232
+ // Campgain is invalid!
1233
+ }
1234
+
1235
+ }
1236
+ $valid_campaigns = apply_filters( 'icegram_valid_campaigns', $valid_campaigns );
1237
+
1238
+ return $valid_campaigns;
1239
+ }
1240
+
1241
+ function append_to_valid_campaigns_sql( $sql_params = array(), $options = array() ) {
1242
+ // Page check conditions
1243
+ //$pid = $_GET['page_id'];
1244
+ $pid = Icegram::get_current_page_id();
1245
+ $sql = " AND (
1246
  pm.meta_key = 'icegram_campaign_target_rules' AND (
1247
  ( pm.meta_value LIKE '%%%s%%' )
1248
  OR ( pm.meta_value LIKE '%%%s%%' AND pm.meta_value LIKE '%%%s%%' AND pm.meta_value LIKE '%%%s%%' )
1249
  ";
1250
+ $sql_params[] = 's:8:"sitewide";s:3:"yes";';
1251
+ $sql_params[] = 's:10:"other_page";s:3:"yes";';
1252
+ $sql_params[] = 's:7:"page_id";a:';
1253
+ $sql_params[] = serialize( (string) $pid );
1254
+ //local url
1255
+ $sql .= " OR ( pm.meta_value LIKE '%%%s%%' )";
1256
+ $sql_params[] = 's:9:"local_url";s:3:"yes";';
1257
+ if ( ! empty( $_REQUEST['cache_compatibility'] ) && $_REQUEST['cache_compatibility'] == 'yes' ) {
1258
+ $is_home = ( ! empty( $_REQUEST['is_home'] ) && $_REQUEST['is_home'] === 'true' ) ? true : false;
1259
+ } else {
1260
+ $is_home = ( is_home() || is_front_page() ) ? true : false;
1261
+ }
1262
+ if ( $is_home === true ) {
1263
+ $sql .= " OR ( pm.meta_value LIKE '%%%s%%' )";
1264
+ $sql_params[] = 's:8:"homepage";s:3:"yes";';
1265
+ }
1266
+ $sql .= " ) )";
1267
+
1268
+ $sql_params[0] .= $sql;
1269
+
1270
+ //s:9:"logged_in";s:3:"all";
1271
+
1272
+ return $sql_params;
1273
+ }
1274
+
1275
+ // Include all classes required for Icegram plugin
1276
+ function include_classes( $feedback_version ) {
1277
+ global $ig_tracker, $ig_feedback;
1278
+ $feedback_version_for_file = str_replace( '.', '-', $feedback_version );
1279
+ $t = 'classes/feedback/class-ig-tracker.php';
1280
+ $f = 'classes/feedback/class-ig-feedback.php';
1281
+ require_once( $t );
1282
+ require_once( $f );
1283
+ require_once( 'classes/feedback.php' );
1284
+
1285
+ $ig_feedback_class = 'IG_Feedback_V_' . str_replace( '.', '_', $feedback_version );
1286
+ $ig_feedback = new $ig_feedback_class( 'Icegram', 'icegram', 'ig', 'igfree.', false );
1287
+
1288
+ $classes = glob( $this->plugin_path . '/classes/*.php' );
1289
+ foreach ( $classes as $file ) {
1290
+ // Files with 'admin' in their name are included only for admin section
1291
+ if ( is_file( $file ) && ( ( strpos( $file, '-admin' ) >= 0 && is_admin() ) ) ) {
1292
+ $all_active_plugins = $ig_tracker::get_plugins();
1293
+ if ( ( strpos( $file, 'ig-upsale-admin.php' ) !== false ) && in_array( 'icegram-engage/icegram-engage.php', $all_active_plugins ) ) {
1294
+ continue;
1295
+ }
1296
+ include_once $file;
1297
+ } elseif ( ! is_admin() ) {
1298
+ include_once $file;
1299
+ }
1300
+ }
1301
+
1302
+ // Load built in message types
1303
+ $icegram_message_type_basedirs = glob( $this->plugin_path . '/message-types/*' );
1304
+ // Allow other plugins to add new message types
1305
+ $icegram_message_type_basedirs = apply_filters( 'icegram_message_type_basedirs', $icegram_message_type_basedirs );
1306
+ // Set up different message type classes
1307
+ foreach ( $icegram_message_type_basedirs as $dir ) {
1308
+ $type = basename( $dir );
1309
+ $class_file = $dir . "/main.php";
1310
+ if ( is_file( $class_file ) ) {
1311
+ include_once( $class_file );
1312
+ }
1313
+ $class_name = 'Icegram_Message_Type_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $type ) ) );
1314
+ if ( class_exists( $class_name ) ) {
1315
+ $this->message_type_objs[ $type ] = new $class_name();
1316
+ }
1317
+ }
1318
+ do_action( 'ig_file_include' );
1319
+ $this->message_types = apply_filters( 'icegram_message_types', array() );
1320
+
1321
+ }
1322
+
1323
+ // Register Campaign post type
1324
+ function register_campaign_post_type() {
1325
+ $labels = array(
1326
+ 'name' => __( 'Campaigns', 'icegram' ),
1327
+ 'singular_name' => __( 'Campaign', 'icegram' ),
1328
+ 'add_new' => __( 'Add New Campaign', 'icegram' ),
1329
+ 'add_new_item' => __( 'Add New Campaign', 'icegram' ),
1330
+ 'edit_item' => __( 'Edit Campaign', 'icegram' ),
1331
+ 'new_item' => __( 'New Campaign', 'icegram' ),
1332
+ 'all_items' => __( 'Campaigns', 'icegram' ),
1333
+ 'view_item' => __( 'View Campaign', 'icegram' ),
1334
+ 'search_items' => __( 'Search Campaigns', 'icegram' ),
1335
+ 'not_found' => __( 'No campaigns found', 'icegram' ),
1336
+ 'not_found_in_trash' => __( 'No campaigns found in Trash', 'icegram' ),
1337
+ 'parent_item_colon' => __( '', 'icegram' ),
1338
+ 'menu_name' => __( 'Icegram', 'icegram' )
1339
+ );
1340
+
1341
+ $args = array(
1342
+ 'labels' => $labels,
1343
+ // 'menu_icon' => 'dashicons-info',
1344
+ 'public' => false,
1345
+ 'publicly_queryable' => false,
1346
+ 'show_ui' => true,
1347
+ 'show_in_menu' => true,
1348
+ 'query_var' => true,
1349
+ 'rewrite' => array( 'slug' => 'ig_campaign' ),
1350
+ 'capability_type' => 'post',
1351
+ 'has_archive' => false,
1352
+ 'hierarchical' => false,
1353
+ 'menu_position' => null,
1354
+ 'menu_icon' => $this->plugin_url . '/assets/images/icegram-logo-branding-18-white.png',
1355
+ 'supports' => array( 'title', 'editor' )
1356
+ );
1357
+
1358
+ register_post_type( 'ig_campaign', $args );
1359
+ }
1360
+
1361
+ // Register Message post type
1362
+ function register_message_post_type() {
1363
+ $labels = array(
1364
+ 'name' => __( 'Messages', 'icegram' ),
1365
+ 'singular_name' => __( 'Message', 'icegram' ),
1366
+ 'add_new' => __( 'Create New', 'icegram' ),
1367
+ 'add_new_item' => __( 'Create New Message', 'icegram' ),
1368
+ 'edit_item' => __( 'Edit Message', 'icegram' ),
1369
+ 'new_item' => __( 'New Message', 'icegram' ),
1370
+ 'all_items' => __( 'Messages', 'icegram' ),
1371
+ 'view_item' => __( 'View Message', 'icegram' ),
1372
+ 'search_items' => __( 'Search Messages', 'icegram' ),
1373
+ 'not_found' => __( 'No messages found', 'icegram' ),
1374
+ 'not_found_in_trash' => __( 'No messages found in Trash', 'icegram' ),
1375
+ 'parent_item_colon' => __( '', 'icegram' ),
1376
+ 'menu_name' => __( 'Messages', 'icegram' )
1377
+ );
1378
+
1379
+ $args = array(
1380
+ 'labels' => $labels,
1381
+ 'public' => false,
1382
+ 'publicly_queryable' => false,
1383
+ 'show_ui' => true,
1384
+ 'show_in_menu' => 'edit.php?post_type=ig_campaign',
1385
+ 'query_var' => true,
1386
+ 'rewrite' => array( 'slug' => 'ig_message' ),
1387
+ 'capability_type' => 'post',
1388
+ 'has_archive' => false,
1389
+ 'hierarchical' => false,
1390
+ 'menu_position' => null,
1391
+ 'supports' => array( 'title' )
1392
+ );
1393
+
1394
+ register_post_type( 'ig_message', $args );
1395
+ }
1396
+
1397
+
1398
+ function import( $data = array() ) {
1399
+ if ( empty( $data['campaigns'] ) && empty( $data['messages'] ) ) {
1400
+ return;
1401
+ }
1402
+
1403
+ $default_theme = $default_type = '';
1404
+ $first_message_type = current( $this->message_types );
1405
+
1406
+ if ( is_array( $first_message_type ) ) {
1407
+ $default_type = $first_message_type['type'];
1408
+ if ( ! empty( $first_message_type['themes'] ) ) {
1409
+ $default_theme = key( $first_message_type['themes'] );
1410
+ }
1411
+ }
1412
+
1413
+ $new_campaign_ids = array();
1414
+ foreach ( (array) $data['campaigns'] as $campaign ) {
1415
+
1416
+ $args = array(
1417
+ 'post_content' => ( ! empty( $campaign['post_content'] ) ) ? esc_attr( $campaign['post_content'] ) : '',
1418
+ 'post_name' => ( ! empty( $campaign['post_title'] ) ) ? sanitize_title( $campaign['post_title'] ) : '',
1419
+ 'post_title' => ( ! empty( $campaign['post_title'] ) ) ? $campaign['post_title'] : '',
1420
+ // 'post_status' => ( !empty( $campaign['post_status'] ) ) ? $campaign['post_status'] : 'draft',
1421
+ 'post_status' => 'draft',
1422
+ 'post_type' => 'ig_campaign'
1423
+ );
1424
+
1425
+ $new_campaign_id = wp_insert_post( $args );
1426
+ $new_campaign_ids[] = $new_campaign_id;
1427
+
1428
+ if ( ! empty( $campaign['target_rules'] ) ) {
1429
+
1430
+ $defaults = array(
1431
+ 'homepage' => 'yes',
1432
+ 'when' => 'always',
1433
+ 'from' => '',
1434
+ 'to' => '',
1435
+ 'mobile' => 'yes',
1436
+ 'tablet' => 'yes',
1437
+ 'laptop' => 'yes',
1438
+ 'logged_in' => 'all'
1439
+ );
1440
+
1441
+ $target_rules = wp_parse_args( $campaign['target_rules'], $defaults );
1442
+ update_post_meta( $new_campaign_id, 'icegram_campaign_target_rules', $target_rules );
1443
+ }
1444
+
1445
+ if ( ! empty( $campaign['messages'] ) ) {
1446
+
1447
+ $messages = array();
1448
+
1449
+ foreach ( $campaign['messages'] as $message ) {
1450
+
1451
+ if ( ! is_array( $message ) ) {
1452
+ continue;
1453
+ }
1454
+
1455
+ $args = array(
1456
+ 'post_content' => ( ! empty( $message['message'] ) ) ? esc_attr( $message['message'] ) : '',
1457
+ 'post_name' => ( ! empty( $message['post_title'] ) ) ? sanitize_title( $message['post_title'] ) : '',
1458
+ 'post_title' => ( ! empty( $message['post_title'] ) ) ? $message['post_title'] : '',
1459
+ 'post_status' => ( ! empty( $message['post_status'] ) ) ? $message['post_status'] : 'publish',
1460
+ 'post_type' => 'ig_message'
1461
+ );
1462
+
1463
+ $new_message_id = wp_insert_post( $args );
1464
+ $new_message = array(
1465
+ 'id' => $new_message_id,
1466
+ 'time' => ( ! empty( $message['time'] ) ) ? $message['time'] : 0
1467
+ );
1468
+ //for gallery + CTA another message
1469
+ if ( ! empty( $message['cta'] ) && $message['cta'] == 'cta_another_message' && ! empty( $message['cta_linked_message_id'] ) && $message['cta_linked_message_id'] == 'auto' ) {
1470
+ $prev_message = end( $messages );
1471
+ $message['cta_linked_message_id'] = $prev_message['id'];
1472
+ array_pop( $messages );
1473
+ }
1474
+ $messages[] = $new_message;
1475
+
1476
+ unset( $message['post_content'] );
1477
+ unset( $message['time'] );
1478
+
1479
+ $message['id'] = $new_message_id;
1480
+
1481
+ $defaults = array(
1482
+ 'post_title' => '',
1483
+ 'type' => $default_type,
1484
+ 'theme' => $default_theme,
1485
+ 'animation' => '',
1486
+ 'headline' => '',
1487
+ 'label' => '',
1488
+ 'link' => '',
1489
+ 'icon' => '',
1490
+ 'message' => '',
1491
+ 'position' => '',
1492
+ 'text_color' => '#000000',
1493
+ 'bg_color' => '#ffffff',
1494
+ 'custom_code' => '',
1495
+ 'id' => ''
1496
+ );
1497
+ $icegram_message_data = wp_parse_args( $message, $defaults );
1498
+ if ( ! empty( $icegram_message_data ) ) {
1499
+ update_post_meta( $new_message_id, 'icegram_message_data', $icegram_message_data );
1500
+ update_post_meta( $new_message_id, 'icegram_message_preview_data', $icegram_message_data );
1501
+ }
1502
+ }//foreach
1503
+
1504
+ if ( ! empty( $campaign['messages'] ) ) {
1505
+ update_post_meta( $new_campaign_id, 'messages', $messages );
1506
+ update_post_meta( $new_campaign_id, 'campaign_preview', $messages );
1507
+ }
1508
+ }//if
1509
+ }
1510
+
1511
+ return $new_campaign_ids;
1512
+
1513
+ }
1514
+
1515
+ function import_gallery_item() {
1516
+ if ( ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'fetch_messages' && ! empty( $_REQUEST['campaign_id'] ) && ! empty( $_REQUEST['gallery_item'] ) ) {
1517
+ $url = 'https://www.icegram.com/gallery/wp-admin/admin-ajax.php?utm_source=ig_inapp&utm_campaign=ig_gallery&utm_medium=' . $_REQUEST['campaign_id'];
1518
+ $params = $_REQUEST;
1519
+ $imported_gallery_items = array();
1520
+ $options = array(
1521
+ 'timeout' => 15,
1522
+ 'method' => 'POST',
1523
+ 'body' => http_build_query( $params )
1524
+ );
1525
+ $response = wp_remote_request( $url, $options );
1526
+ $response_code = wp_remote_retrieve_response_code( $response );
1527
+ if ( $response_code == 200 ) {
1528
+ $new_campaign_ids = $this->import( json_decode( $response['body'], true ) );
1529
+ if ( ! empty( $new_campaign_ids ) ) {
1530
+ $imported_gallery_items = get_option( 'ig_imported_gallery_items' );
1531
+ $imported_gallery_items[] = $_REQUEST['campaign_id'];
1532
+ update_option( 'ig_imported_gallery_items', $imported_gallery_items );
1533
+ $location = admin_url( 'post.php?post=' . $new_campaign_ids[0] . '&action=edit' );
1534
+ header( 'Location:' . $location );
1535
+ exit;
1536
+ } else {
1537
+ wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
1538
+ }
1539
+ }
1540
+ }
1541
+ }
1542
+
1543
+ function import_sample_data( $data = array() ) {
1544
+ $new_campaign_ids = $this->import( $data );
1545
+ if ( ! empty( $new_campaign_ids ) ) {
1546
+ update_option( 'icegram_sample_data_imported', $new_campaign_ids );
1547
+ }
1548
+ }
1549
+
1550
+
1551
+ function get_sample_data() {
1552
+
1553
+ return array(
1554
+ 'campaigns' => array(
1555
+ array(
1556
+ 'post_name' => '',
1557
+ 'post_title' => 'My First Icegram Campaign',
1558
+ 'target_rules' => array(
1559
+ 'homepage' => 'yes',
1560
+ 'when' => 'always',
1561
+ 'from' => '',
1562
+ 'to' => '',
1563
+ 'mobile' => 'yes',
1564
+ 'tablet' => 'yes',
1565
+ 'laptop' => 'yes',
1566
+ 'logged_in' => 'all'
1567
+ ),
1568
+ 'messages' => array(
1569
+ array(
1570
+ 'post_title' => 'Get 2x more Contacts with Your Website',
1571
+ 'post_status' => 'publish',
1572
+ 'time' => '0',
1573
+ 'type' => 'action-bar',
1574
+ 'theme' => 'hello',
1575
+ 'headline' => 'Get 2x more Contacts with Your Website',
1576
+ 'label' => 'Show Me How',
1577
+ 'link' => '',
1578
+ 'icon' => '',
1579
+ 'message' => 'Instant Results Guaranteed',
1580
+ 'position' => '01',
1581
+ 'text_color' => '#000000',
1582
+ 'bg_color' => '#eb593c'
1583
+ ),
1584
+ array(
1585
+ 'post_title' => '20% Off Coupon',
1586
+ 'post_status' => 'publish',
1587
+ 'time' => '4',
1588
+ 'type' => 'messenger',
1589
+ 'theme' => 'social',
1590
+ 'animation' => 'slide',
1591
+ 'headline' => '20% Off - for you',
1592
+ 'label' => '',
1593
+ 'link' => '',
1594
+ 'icon' => '',
1595
+ 'message' => "Hey there! We are running a <strong>special 20% off this week</strong> for registered users - like you.
1596
 
1597
  Use coupon <code>LOYALTY20</code> during checkout.",
1598
+ 'position' => '22',
1599
+ 'text_color' => '#000000',
1600
+ 'bg_color' => '#ffffff'
1601
+ ),
1602
+ array(
1603
+ 'post_title' => 'How this blog makes over $34,800 / month for FREE.',
1604
+ 'post_status' => 'publish',
1605
+ 'time' => '10',
1606
+ 'type' => 'popup',
1607
+ 'theme' => 'air-mail',
1608
+ 'headline' => 'How this blog makes over $34,800 / month for FREE.',
1609
+ 'label' => 'FREE INSTANT ACCESS',
1610
+ 'link' => '',
1611
+ 'icon' => '',
1612
+ 'message' => "This website earns over $30,000 every month, every single month, almost on autopilot. I have 4 other sites with similar results. All I do is publish new regular content every week.
1613
 
1614
  <strong>Download my free kit to learn how I do this.</strong>
1615
 
1620
  <li>Resources and tips to get started quickly</li>
1621
  <li>Private members club to connect with fellow owners</li>
1622
  </ul>",
1623
+ 'text_color' => '#000000',
1624
+ 'bg_color' => '#ffffff'
1625
+
1626
+ ),
1627
+ array(
1628
+ 'post_title' => 'Exclusive Marketing Report',
1629
+ 'post_status' => 'publish',
1630
+ 'time' => '6',
1631
+ 'type' => 'toast',
1632
+ 'theme' => 'stand-out',
1633
+ 'animation' => 'pop',
1634
+ 'headline' => 'Exclusive Marketing Report',
1635
+ 'label' => '',
1636
+ 'link' => '',
1637
+ 'icon' => '',
1638
+ 'message' => 'FREE for every subscriber. Click here to download it.',
1639
+ 'position' => '02',
1640
+ 'text_color' => '#000000',
1641
+ 'bg_color' => '#ffffff'
1642
+ )
1643
+
1644
+ )
1645
+ )
1646
+ )
1647
+ );
1648
+ }
1649
+
1650
+ function remove_preview_button() {
1651
+ global $post_type;
1652
+ if ( $post_type == 'ig_message' || $post_type == 'ig_campaign' ) {
1653
+ ?>
1654
+ <style type="text/css">
1655
+ #message.updated.below-h2 {
1656
+ display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1657
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1658
 
1659
+ #preview-action {
1660
+ display: none;
1661
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1662
 
1663
+ /*Remove add new campaign and message*/
1664
+ .page-title-action {
1665
+ display: none;
1666
+ }
1667
+ </style>
1668
+ <?php
1669
+ }
1670
+ }
1671
+
1672
+
1673
+ function remove_row_actions( $actions, $post ) {
1674
+
1675
+ if ( empty( $post->post_type ) || ( $post->post_type != 'ig_campaign' && $post->post_type != 'ig_message' ) ) {
1676
+ return $actions;
1677
+ }
1678
+
1679
+ unset( $actions['inline hide-if-no-js'] );
1680
+ unset( $actions['view'] );
1681
+
1682
+ return $actions;
1683
+
1684
+ }
1685
+
1686
+ function identify_current_page() {
1687
+ global $post, $wpdb;
1688
+
1689
+ $obj = get_queried_object();
1690
+ $id = 0;
1691
+ if ( ! empty( $obj->has_archive ) ) {
1692
+ $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type= %s ", array( $obj->has_archive, 'page' ) );
1693
+ $id = $wpdb->get_var( $sql );
1694
+ } elseif ( is_object( $post ) && isset( $post->ID ) ) {
1695
+ $id = $post->ID;
1696
+ }
1697
+ $id = apply_filters( 'icegram_identify_current_page', $id );
1698
+ self::$current_page_id = $id;
1699
+ }
1700
+
1701
+ static function get_current_page_id() {
1702
+ global $post;
1703
+ if ( ! empty( $_REQUEST['page_id'] ) && is_numeric( $_REQUEST['page_id'] ) ) {
1704
+ $post = get_post( $_REQUEST['page_id'] );
1705
+ setup_postdata( $post );
1706
+ // WPML check
1707
+ $id = apply_filters( 'icegram_identify_current_page', $post->ID );
1708
+ self::$current_page_id = $id;
1709
+ }
1710
+
1711
+ return self::$current_page_id;
1712
+ }
1713
+
1714
+ static function get_current_page_url() {
1715
+ if ( ! empty( $_REQUEST['cache_compatibility'] ) && $_REQUEST['cache_compatibility'] == 'yes' ) {
1716
+ $pageURL = ( ! empty( $_REQUEST['referral_url'] ) ) ? $_REQUEST['referral_url'] : '';
1717
+ } else {
1718
+ $pageURL = 'http';
1719
+ if ( isset( $_SERVER["HTTPS"] ) ) {
1720
+ if ( $_SERVER["HTTPS"] == "on" ) {
1721
+ $pageURL .= "s";
1722
+ }
1723
+ }
1724
+ $pageURL .= "://";
1725
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
1726
+ $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
1727
+ } else {
1728
+ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
1729
+ }
1730
+ }
1731
+
1732
+ return $pageURL;
1733
+ }
1734
+
1735
+ function wpml_get_parent_id( $id ) {
1736
+ global $post;
1737
+ if ( function_exists( 'icl_object_id' ) && function_exists( 'icl_get_default_language' ) ) {
1738
+ $id = icl_object_id( $id, $post->post_type, true, icl_get_default_language() );
1739
+ }
1740
+
1741
+ return $id;
1742
+ }
1743
+
1744
+
1745
+ /**
1746
+ * Our implementation of wpautop to preserve script and style tags
1747
+ */
1748
+ function before_wpautop( $pee ) {
1749
+ if ( trim( $pee ) === '' ) {
1750
+ $this->_wpautop_tags = array();
1751
+
1752
+ return '';
1753
+ }
1754
+
1755
+ $tags = array();
1756
+ // Pull out tags and add placeholders
1757
+ list( $pee, $tags['pre'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'pre' );
1758
+ list( $pee, $tags['script'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'script' );
1759
+ list( $pee, $tags['style'] ) = $this->_wpautop_add_tag_placeholders( $pee, 'style' );
1760
+ $this->_wpautop_tags = $tags;
1761
+
1762
+ if ( ! empty( $pre_tags ) ) {
1763
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $pre_tags );
1764
+ }
1765
+ if ( ! empty( $script_tags ) ) {
1766
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $script_tags );
1767
+ }
1768
+ if ( ! empty( $style_tags ) ) {
1769
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $style_tags );
1770
+ }
1771
+
1772
+ return $pee;
1773
+ }
1774
+
1775
+ function after_wpautop( $pee ) {
1776
+ if ( trim( $pee ) === '' || empty( $this->_wpautop_tags ) ) {
1777
+ return '';
1778
+ }
1779
+
1780
+ // Replace placeholders with original content
1781
+ if ( ! empty( $this->_wpautop_tags['pre'] ) ) {
1782
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['pre'] );
1783
+ }
1784
+ if ( ! empty( $this->_wpautop_tags['script'] ) ) {
1785
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['script'] );
1786
+ }
1787
+ if ( ! empty( $this->_wpautop_tags['style'] ) ) {
1788
+ $pee = $this->_wpautop_replace_tag_placeholders( $pee, $this->_wpautop_tags['style'] );
1789
+ }
1790
+
1791
+ $this->_wpautop_tags = array();
1792
+
1793
+ return $pee;
1794
+ }
1795
+
1796
+ function _wpautop_add_tag_placeholders( $pee, $tag ) {
1797
+ $tags = array();
1798
+
1799
+ if ( false !== strpos( $pee, "<{$tag}" ) ) {
1800
+ $pee_parts = explode( "</{$tag}>", $pee );
1801
+ $last_pee = array_pop( $pee_parts );
1802
+ $pee = '';
1803
+ $i = 0;
1804
+
1805
+ foreach ( $pee_parts as $pee_part ) {
1806
+ $start = strpos( $pee_part, "<{$tag}" );
1807
+
1808
+ // Malformed html?
1809
+ if ( false === $start ) {
1810
+ $pee .= $pee_part;
1811
+ continue;
1812
+ }
1813
+
1814
+ $name = "<{$tag} wp-{$tag}-tag-$i></{$tag}>";
1815
+ $tags[ $name ] = substr( $pee_part, $start ) . "</{$tag}>";
1816
+
1817
+ $pee .= substr( $pee_part, 0, $start ) . $name;
1818
+ $i ++;
1819
+ }
1820
+
1821
+ $pee .= $last_pee;
1822
+ }
1823
+
1824
+ return array( $pee, $tags );
1825
+ }
1826
+
1827
+ function _wpautop_replace_tag_placeholders( $pee, $tags ) {
1828
+ if ( ! empty( $tags ) ) {
1829
+ $pee = str_replace( array_keys( $tags ), array_values( $tags ), $pee );
1830
+ }
1831
+
1832
+ return $pee;
1833
+ }
1834
+
1835
+ static function duplicate_in_db( $original_id ) {
1836
+ // Get access to the database
1837
+ global $wpdb;
1838
+ // Get the post as an array
1839
+ $duplicate = get_post( $original_id, 'ARRAY_A' );
1840
+ // Modify some of the elements
1841
+ $duplicate['post_title'] = $duplicate['post_title'] . ' ' . __( 'Copy', 'icegram' );
1842
+ $duplicate['post_status'] = 'draft';
1843
+ // Set the post date
1844
+ $timestamp = current_time( 'timestamp', 0 );
1845
+
1846
+ $duplicate['post_date'] = date( 'Y-m-d H:i:s', $timestamp );
1847
+
1848
+ // Remove some of the keys
1849
+ unset( $duplicate['ID'] );
1850
+ unset( $duplicate['guid'] );
1851
+ unset( $duplicate['comment_count'] );
1852
+
1853
+ // Insert the post into the database
1854
+ $duplicate_id = wp_insert_post( $duplicate );
1855
+
1856
+ // Duplicate all taxonomies/terms
1857
+ $taxonomies = get_object_taxonomies( $duplicate['post_type'] );
1858
+
1859
+ foreach ( $taxonomies as $taxonomy ) {
1860
+ $terms = wp_get_post_terms( $original_id, $taxonomy, array( 'fields' => 'names' ) );
1861
+ wp_set_object_terms( $duplicate_id, $terms, $taxonomy );
1862
+ }
1863
+
1864
+ // Duplicate all custom fields
1865
+ $custom_fields = get_post_custom( $original_id );
1866
+ foreach ( $custom_fields as $key => $value ) {
1867
+ if ( $key === 'messages' ) {
1868
+ $messages = unserialize( $value[0] );
1869
+ foreach ( $messages as &$message ) {
1870
+ $clone_msg_id = Icegram::duplicate_in_db( $message['id'] );
1871
+ $message['id'] = $clone_msg_id;
1872
+ }
1873
+ $value[0] = serialize( $messages );
1874
+ }
1875
+ add_post_meta( $duplicate_id, $key, maybe_unserialize( $value[0] ) );
1876
+ }
1877
+
1878
+ return $duplicate_id;
1879
+ }
1880
+
1881
+ static function duplicate( $original_id ) {
1882
+ $duplicate_id = Icegram::duplicate_in_db( $original_id );
1883
+ $location = admin_url( 'post.php?post=' . $duplicate_id . '&action=edit' );
1884
+ header( 'Location:' . $location );
1885
+ exit;
1886
+ }
1887
+
1888
+ public static function form_submission_validate_request( $request_data ) {
1889
+ if ( ! empty( $request_data ) ) {
1890
+ // Check for Remote Rainmaker form submission request
1891
+ $request_data['ig_is_remote'] = false;
1892
+ $request_data['is_remote'] = false;
1893
+ if ( ! empty( $request_data['ig_mode'] ) && $request_data['ig_mode'] === 'remote' ) {
1894
+ $ig_remote_url = $request_data['ig_remote_url'];
1895
+ if ( ! empty( $request_data['ig_campaign_id'] ) ) {
1896
+ $rules = get_post_meta( $request_data['ig_campaign_id'], 'icegram_campaign_target_rules', true );
1897
+ if ( ! empty( $rules['remote_urls'] ) && is_array( $rules['remote_urls'] ) ) {
1898
+ foreach ( $rules['remote_urls'] as $remote_url_pattern ) {
1899
+ $valid = Icegram_Campaign::is_valid_url( $remote_url_pattern, $ig_remote_url );
1900
+ if ( $valid ) {
1901
+ $request_data['ig_is_remote'] = true;
1902
+ $request_data['is_remote'] = true;
1903
+ break;
1904
+ }
1905
+ }
1906
+ //TODO :: discard the the remote request and data
1907
+ // if($request_data['ig_is_remote'] == false){
1908
+ // return array();
1909
+ // }
1910
+ }
1911
+
1912
+ }
1913
+ }
1914
+ }
1915
+
1916
+ return $request_data;
1917
+ }
1918
+
1919
+ public static function get_ig_meta_info() {
1920
+ $total_campaigns = wp_count_posts( 'ig_campaign' );
1921
+ $total_campaigns_publish = $total_campaigns->publish;
1922
+ $total_campaigns_draft = $total_campaigns->draft;
1923
+
1924
+ $meta_info = array(
1925
+ 'total_campaigns_publish' => $total_campaigns_publish,
1926
+ 'total_campaigns_draft' => $total_campaigns_draft,
1927
+ );
1928
+
1929
+ return $meta_info;
1930
+ }
1931
  }
1932
 
 
1933
  function initialize_icegram() {
1934
+ global $icegram;
1935
+ // i18n / l10n - load translations
1936
+ load_plugin_textdomain( 'icegram', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
1937
 
1938
+ $icegram = new Icegram();
 
1939
 
1940
+ do_action( 'icegram_loaded' );
 
1941
  }
1942
 
1943
  add_action( 'plugins_loaded', 'initialize_icegram' );
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Popups, Welcome Bar, Optins and Lead Generation Plugin - Icegram ===
2
- Contributors: icegram, storeapps, niravmehta, sandhyam, putler
3
  Donate link: https://www.icegram.com/
4
  Tags: popup, wordpress popups,Exit-popup, optin-popup, popups, hellobar, optin, lead capture, form, marketing, notification, messenger, targeting, monster, ninja ,wordpress lead generation, wordpress lightbox optin, wordpress lightbox optin form, wordpress lightbox optins, wordpress mobile optin forms, wordpress mobile popup, wordpress mobile popups, wordpress optin form, wordpress overlay popup, wordpress popup, wordpress popup form, wordpress popup plugin, wordpress popup solution, wordpress popups , popups, subscribe, wp popups, optin bars, action grabber, promotion, popup message, leads, lists, builder, action bar, floating bar, footer bar, hellobar alternative, pop over, Popup plugin, aweber, campaign monitor, constant contact, email list, exit-intent, onclick popup, analytics, Hubspot, popup ads, pop-up, Mailing list pop-up, re-targeting, Animation,Popups with Animation ,Responsive Popup, split testing, AB testing
5
  Requires at least: 3.9
6
  Tested up to: 5.3
7
- Stable tag: 1.10.35
8
  License: GPLv3
9
 
10
  The best WP popup plugin that let's you create a popup within seconds. Customize popup, target popups to show offers, email signups, social buttons etc and instantly increase conversions on your website.
@@ -217,6 +217,9 @@ Contact Us, provide as much detail of the problem as you can. We will try to sol
217
  5. Target your Icegram message using these display rules
218
 
219
  == Upgrade Notice ==
 
 
 
220
  = 1.10.35 =
221
  Security Fixes
222
 
@@ -483,14 +486,18 @@ Initial Release
483
 
484
 
485
  == Changelog ==
 
 
 
 
486
  = 1.10.35 =
487
  * Fix: Security issues
488
 
489
  = 1.10.34 =
490
- Added Black Friday Cyber Monday Gallery Items
491
 
492
  = 1.10.33 =
493
- * Enhancement: Revised Gallery Templates for halloween
494
 
495
  = 1.10.32 =
496
  * New: Added featured gallery items
1
  === Popups, Welcome Bar, Optins and Lead Generation Plugin - Icegram ===
2
+ Contributors: icegram, storeapps, niravmehta, sandhyam, malayladu, putler
3
  Donate link: https://www.icegram.com/
4
  Tags: popup, wordpress popups,Exit-popup, optin-popup, popups, hellobar, optin, lead capture, form, marketing, notification, messenger, targeting, monster, ninja ,wordpress lead generation, wordpress lightbox optin, wordpress lightbox optin form, wordpress lightbox optins, wordpress mobile optin forms, wordpress mobile popup, wordpress mobile popups, wordpress optin form, wordpress overlay popup, wordpress popup, wordpress popup form, wordpress popup plugin, wordpress popup solution, wordpress popups , popups, subscribe, wp popups, optin bars, action grabber, promotion, popup message, leads, lists, builder, action bar, floating bar, footer bar, hellobar alternative, pop over, Popup plugin, aweber, campaign monitor, constant contact, email list, exit-intent, onclick popup, analytics, Hubspot, popup ads, pop-up, Mailing list pop-up, re-targeting, Animation,Popups with Animation ,Responsive Popup, split testing, AB testing
5
  Requires at least: 3.9
6
  Tested up to: 5.3
7
+ Stable tag: 1.10.36
8
  License: GPLv3
9
 
10
  The best WP popup plugin that let's you create a popup within seconds. Customize popup, target popups to show offers, email signups, social buttons etc and instantly increase conversions on your website.
217
  5. Target your Icegram message using these display rules
218
 
219
  == Upgrade Notice ==
220
+ = 1.10.36 =
221
+ Added Christmas Gallery Items
222
+
223
  = 1.10.35 =
224
  Security Fixes
225
 
486
 
487
 
488
  == Changelog ==
489
+ = 1.10.36 =
490
+ * Fix: Form color field was not rendering properly
491
+ * Enhancement: Added Christmas Gallery Items
492
+
493
  = 1.10.35 =
494
  * Fix: Security issues
495
 
496
  = 1.10.34 =
497
+ * Added Black Friday Cyber Monday Gallery Items
498
 
499
  = 1.10.33 =
500
+ * Enhancement: Revised Gallery Templates for Halloween
501
 
502
  = 1.10.32 =
503
  * New: Added featured gallery items