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

Version Description

1.10.40

  • Update: Improve performance by loading JS/ CSS whenever required
  • Fix: Rainmaker Shortcode issue

1.10.39

  • Fix: Campaigns were not showing if display rules are set to role specific
  • Update: WordPress 5.4 compatibility test

1.10.38

  • UI enhancements

1.10.37

  • Bugfix release

1.10.36

  • Added Christmas Gallery Items

1.10.35

  • Security Fixes

1.10.34

  • Added Black Friday Cyber Monday Gallery Items

1.10.33

  • Revised Gallery Templates for Halloween

1.10.32

  • Added new featured gallery items

1.10.31

  • Revised Gallery Templates

10.30.1

  • Bug Fix release

1.10.28.2

  • Bug Fix release

1.10.28.1

  • Bug Fix release

1.10.28

  • Revised Gallery Templates

1.10.27

  • Bug Fix release

1.10.26

  • Bug Fix release

1.10.25

  • Revised Gallery Templates for Black Friday and Cyber Monday

1.10.24

  • Revised Gallery Templates for Halloween

1.10.23

  • Revised Gallery Templates

1.10.22

  • Fixed popup blocker issue while previewing campaign

1.10.21

  • Compatibility with latest Email Subscribers

1.10.20

  • Compatibility with latest GDPR

1.10.19

  • Compatibility with Rainmaker

1.10.18

  • Improved the UI/UX of the Icegram Gallery

1.10.17

  • Revised Gallery Templates

1.10.16

  • Fixed "The plugin does not have a valid header" issue

1.10.15

  • Added Christmas Gallery templates

1.10.14

  • Compatibility with WordPress 4.9

1.10.13

  • Added Black Friday and Cyber Monday Gallery templates

1.10.12

  • Compatibility with MailPoet 3

1.10.11

  • Added Halloween Gallery templates

1.10.10

  • Revised Gallery Templates

1.10.9.1

  • Bug Fix release

1.10.9

  • Revised Gallery Templates

1.10.8

  • compatibility with Contact Form 7(v4.8)

1.10.7

  • Added more templates in Gallery

1.10.6

  • Search bar, filters added to Icegram's Gallery

1.10.5

  • Improvements in Call To Actions

1.10.4

  • Directly choose Gallery Template while creating a New Campaign

1.10.3

  • Email Subscribers compatibility

1.10.2

  • Update mobile Detect library

1.10.1

  • Bug Fix release

1.10

  • Merge all addons in one

1.9.24

  • Small improvements in responsiveness of Popups and Action bars

1.9.23

  • Bug Fix release

1.9.22

  • No Google penalty for mobile popups, an automatic solution

1.9.21

  • Revamp admin UI

1.9.20.1

  • Bug Fix release

1.9.20

  • Rainmaker compatibility

1.9.19

  • Secured Icegram from XSS vulnerability

1.9.18

  • Compatibility with Icegram's CTA add-on and Rainmaker

1.9.17

  • Performance enhancements

1.9.16

  • Custom forms imported in Rainmaker

1.9.15

  • Added the Gallery of ready to use Icegram Campaigns

1.9.14

  • Added quick action for campaign preview.

1.9.13

  • revamp of popup themes - Airmail, Convert, Inspire, Persuade.

1.9.12

  • Add new custom CSS and JS code block.

1.9.11.1

  • Remove warning in the admin panel.

1.9.11

  • Compatibility with Gravity Forms.

1.9.10

  • Fix for schedule campaign option

1.9.9

  • Compatibility with Contact Form 7.

1.9.8.1

  • Added sprite image for close buttons and other fixes.

1.9.8

  • Enhanced the top Action bar position

1.9.7.1

  • Incorrect plugin name

1.9.7

  • Messengers are now responsive. Many small improvements.

1.9.6

  • Many small changes and other fixes.

1.9.5

  • Added animations for few more message types. Action bars are now responsive.

1.9.4

  • Bugfix release for forms.

1.9.3

  • Bugfix release for "Target link" not working.

1.9.2

  • Shortcode problems solved. New anti-spam mechanism for forms.

1.9.1

  • Few improvements in form functionality.

1.9

  • Form embed functionality improvements, Added forms styles.

1.8.10

  • Fixes for minified js and CSS. Changes for WP themes compatibility.

1.8.9

  • Many small changes. Plus major changes for caching compatibility.

1.8.8

  • Improved shortcode handling, WishList member compatibility, and other fixes.

1.8.7

  • Popups now support custom background and text colors. And a handful of fixes!

1.8.6

  • Fix for "white screen" errors, updated device detection, more readable call to action button colors

1.8.5

  • Bugfix release for device targeting, preview before publishing not working.

1.8.4

  • Popups are now responsive! Plus Visual Composer compatibility and other fixes.

1.8.3

  • Campaign and message duplicate feature added. Plus some other improvements.

1.8.2

  • Bugfix release for preview not working.

1.8.1

  • Recommended upgrade. Many improvements.

1.8

  • Target campaigns to any page with wildcard URL support in "Where" conditions and CTA Click based retargeting.

1.7.1

  • Dismiss admin notice provision, retargeting compatibility with caches and bug fixes.

1.7

  • Improvements in styling, form embeds and retargeting.

1.6

  • Improvements in optin form embedding, bug fixes and more. Required update.

1.5

  • Easy opt-in / subscription form parser and many other enhancements. Required update.

1.4

  • Many small improvements. Support for analytics added. WordPress 4.0 compatible.

1.3

  • 7 premium addons available now. Plus a lot of improvements. Recommended upgrade.

1.2

  • Lots of enhancements... WPML support, pluggable architecture, many internal changes. Do upgrade.

1.1.1

  • Compatibility with W3TC and Localization

1.1

  • First release on WordPress.org

1.0

  • Initial Release
Download this release

Release Info

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

Code changes from version 1.10.39 to 1.10.40

classes/class-icegram-campaign-admin.php CHANGED
@@ -11,42 +11,42 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
11
  function __construct() {
12
 
13
  // add_action( 'add_meta_boxes', array( &$this, 'add_campaigns_metaboxes' ), 0 );
14
- add_action( 'edit_form_advanced', array( &$this, 'add_campaigns_tabs' ) );
15
 
16
  add_action( 'save_post', array( &$this, 'save_campaign_settings' ), 10, 2 );
17
  add_action( 'wp_ajax_icegram_json_search_messages', array( &$this, 'icegram_json_search_messages' ) );
18
  add_action( 'wp_ajax_get_message_action_row', array( &$this, 'get_message_action_row' ) );
19
  // add_filter( 'wp_default_editor', create_function('', 'return "html";') );
20
- add_action( 'wp_ajax_save_campaign_preview', array( &$this, 'save_campaign_preview' ) );
21
- add_action( 'icegram_campaign_target_rules', array( &$this, 'icegram_add_campaign_target_rules' ), 10, 2 );
22
- add_filter('icegram_campaign_messages' ,array( &$this, 'get_icegram_campaign_messages' ) ,10,2 );
23
  //duplicate campaign
24
- add_filter( 'post_row_actions', array(&$this , 'add_campaign_action'), 10, 2 );
25
- add_action('admin_init', array(&$this ,'duplicate_campaign') ,10, 1);
26
 
27
  // Adding tabs here
28
- add_filter( 'icegram_campaign_tabs', array( &$this, 'campaign_data_tab_content' ), 0, 1 );
29
- add_filter( 'icegram_campaign_tabs', array( &$this, 'campaign_target_rules_tab_content' ), 100, 1 );
30
 
31
- $this->site_url = home_url().'/';
32
 
33
  $this->default_target_rules = apply_filters( 'icegram_campaign_default_rules',
34
- array ( 'homepage' => 'yes',
35
- 'when' => 'always',
36
- 'mobile' => 'yes',
37
- 'tablet' => 'yes',
38
- 'laptop' => 'yes',
39
- 'logged_in' => 'all'
40
- )
41
- );
42
 
43
  }
44
  public static function getInstance(){
45
- static $ig_campaign_admin = null;
46
- if (null === $ig_campaign_admin) {
47
- $ig_campaign_admin = new Icegram_Campaign_Admin();
48
- }
49
- return $ig_campaign_admin;
50
  }
51
 
52
  // Initialize campaign Tabs
@@ -63,8 +63,8 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
63
  $tabs_content = !empty($tabs['tabs']) ? implode('', $tabs['tabs']) : '';
64
 
65
  $preview_button = '<div id="" class="ig_preview_button">
66
- <div class="button button-primary campaign_preview">' . __( 'Preview Campaign', 'icegram' ) .'</div>
67
- <div class="clear"></div></div>';
68
 
69
  // $preview_button = '<div class="button button-primary campaign_preview">' . __( 'Preview', 'icegram' ) . '</div>';
70
  echo $preview_button .'<div id="ig-admin-tabs"><ul class="ig-admin-tabs-nav">'. $tabs_nav .'</ul>'. $tabs_content .'</div>';
@@ -73,41 +73,41 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
73
  if ( $pagenow == 'post-new.php' ) {
74
  echo "<style>
75
  #poststuff{
76
- position:relative;
77
- }
78
  #poststuff #post-body.columns-2{
79
- margin-right: 0;
80
- }
81
- .wrap h1.wp-heading-inline,
82
  #post-body-content,
83
- .postbox-container + *:not(:last-child),
84
- .postbox-container > *:not(.ig-gallery-wrap){
85
- display:none;
86
- }
87
- .wrap h1.wp-heading-inline.gallery-heading{
88
- display:inline-block;
89
- }
90
- .ig-gallery-position{
91
- position: absolute;
92
- width: 100%;
93
- left: 0;
94
- top: 50px;
95
- }
96
  #postbox-container-1 #side-sortables.gal-toggled{
97
- display:block;
98
- }
99
- </style>";
100
  // echo '<h1 class="wp-heading-inline gallery-heading">'. __('Import from beautiful design templates', 'icegram'). '<a href="#" class="page-title-action" id="ig-add-new-campaign">'. __('Add New Campaign', 'icegram'). '</a></h1>';
101
  // echo '<h1 class="wp-heading-inline gallery-heading">'. __('Import from beautiful design templates', 'icegram').'</h1>';
102
- Icegram::gallery_screen();
103
- }
104
-
105
- }
106
 
107
  // Display list of messages of campaign tab
108
- function campaign_data_tab_content($tabs) {
109
 
110
- $tab_id = 'main';
111
  $tab_class = 'campaign_data'; // space seprated classes
112
 
113
  $tabs['nav'][$tab_id] = '<li class="ig-admin-nav-'. $tab_id . '"><a href="#ig-admin-tab-'. $tab_id .'">'. __( 'Messages', 'icegram' ) .'</a></li>';
@@ -156,7 +156,7 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
156
  <? do_action('main_tab_prepand_content')?>
157
  <div class="campaign_box"><?php echo $title; ?> &mdash; <?php echo $campaign_box; ?></div>
158
  <div style="margin: 8px -12px 12px -12px">
159
- <hr/>
160
  </div>
161
  <div class="campaign_target_rules_panel">
162
  <div class="options_group">
@@ -167,45 +167,45 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
167
  ?>
168
  <tbody>
169
  <?php
170
- $messages = array();
171
- $messages = apply_filters('icegram_campaign_messages', $messages, $post->ID);
172
- $icegram_message_meta_key = apply_filters('icegram_message_meta_key', 'messages');
173
- if ( !empty( $messages ) ) {
174
- foreach ( $messages as $row => $message ) {
175
- $message_title = get_the_title( $message['id'] );
176
- $message_data = get_post_meta( $message['id'], 'icegram_message_data', true );
177
- $message_type = ( !empty( $message_data['type'] ) ) ? $message_data['type'] : '';
178
- $class = ( !empty( $icegram->message_types[ $message_type ] ) ) ? $message_type : 'unknown';
179
  //if ( empty( $icegram->message_types[ $message_type ] ) ) continue;
180
- ?>
181
- <tr class="form-field message-row" value="<?php echo $message['id']; ?>">
182
- <td class="message_header">
183
- <label class="message_header_label <?php echo "ig_".$message_data['type'] ." " .$class; ?>"><?php echo esc_attr($class); ?></label>
184
- </td>
185
- <td class="message_title">
186
- <div class="message-title-text"><?php echo $message_title; ?></div>
187
- <input type="text" class="message-title-input" name="message_data[<?php echo $message['id']; ?>][post_title]" value="<?php echo esc_attr($message_title); ?>" placeholder="<?php echo __( 'Give this message a name for your own reference', 'icegram' ); ?>" style="display: none;">
188
- </td>
189
- <td class="message_seconds">
190
- <input type="hidden" name="<?php echo $icegram_message_meta_key .'['.$row; ?>][id]" value="<?php echo $message['id']; ?>" />
191
- <input type="number" class="seconds-text" name="<?php echo $icegram_message_meta_key .'['.$row; ?>][time]" min="-1" value="<?php echo ( !empty( $message['time'] ) ) ? $message['time'] : 0; ?>" size="3" />
192
- <?php _e( ' sec', 'icegram' )?>
193
- </td>
194
- <td class="action_links">
195
- <span class="actions message_edit" title="<?php _e( 'Edit Message', 'icegram' ); ?>" ></span>
196
- <span class="actions message_delete" title="<?php _e( 'Remove from Campaign', 'icegram' ); ?>" ></span>
197
- </td>
198
- </tr>
199
- <tr id="message_row_<?php echo $message['id']; ?>" class="message-edit-row" style="display: none;">
200
- <td colspan="4">
201
  <?php
202
- $ig_message_admin->message_form_fields( '', array( 'message_id' => $message['id'] ) );
203
  ?>
204
- </td>
205
- </tr>
206
- <?php
207
- }
208
  }
 
209
  ?>
210
  </tbody>
211
  </table>
@@ -259,15 +259,15 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
259
  <p class="form-field" <?php echo ( !empty( $campaign_target_rules['sitewide'] ) && $campaign_target_rules['sitewide'] == 'yes' ) ? '' : 'style="display: none;"'; ?>>
260
  <label class="options_header"></label>
261
  <?php
262
- echo '<select name="exclude_page_id[]" id="exclude_page_id" data-placeholder="' . __( 'Select pages to exclude&hellip;', 'icegram' ) . '" style="min-width:300px;" class="icegram_chosen_page" multiple>';
263
- foreach ( get_pages() as $page ) {
264
- echo '<option value="' . $page->ID . '"';
265
- if( !empty( $campaign_target_rules['exclude_page_id'] ) ) {
266
- echo selected( in_array( $page->ID, $campaign_target_rules['exclude_page_id'] ) );
267
- }
268
- echo '>' . $page->post_title . '</option>';
269
  }
270
- echo '</select>';
 
 
271
  ?>
272
  </p>
273
  <p class="form-field">
@@ -287,15 +287,15 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
287
  <p class="form-field" <?php echo ( !empty( $campaign_target_rules['other_page'] ) && $campaign_target_rules['other_page'] == 'yes' ) ? '' : 'style="display: none;"'; ?>>
288
  <label class="options_header">&nbsp;</label>
289
  <?php
290
- echo '<select name="page_id[]" id="where_page_id" data-placeholder="' . __( 'Select a page&hellip;', 'icegram' ) . '" style="min-width:300px;" class="icegram_chosen_page" multiple>';
291
- foreach ( get_pages() as $page ) {
292
- echo '<option value="' . $page->ID . '"';
293
- if( !empty( $campaign_target_rules['page_id'] ) ) {
294
- echo selected( in_array( $page->ID, $campaign_target_rules['page_id'] ) );
295
- }
296
- echo '>' . $page->post_title . '</option>';
297
  }
298
- echo '</select>';
 
 
299
  ?>
300
  </p>
301
  <p class="form-field">
@@ -311,7 +311,7 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
311
  foreach ($campaign_target_rules['local_urls'] as $url) {?>
312
  <span><label class="options_header"><span id="valid-field"> </span></label>
313
  <input type="text" data-option="local_url" class="url_input_field" name="campaign_target_rules[local_urls][]" value="<?php echo $this->site_url.$url ;?>"/><span class="delete-url"></span></span>
314
- <?php
315
  }
316
  }else{ ?>
317
  <span><label class="options_header"><span id="valid-field"> </span></label>
@@ -322,7 +322,7 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
322
  </p>
323
 
324
  <?php
325
- do_action( 'icegram_after_campaign_where_rule', $campaign_id, $campaign_target_rules );
326
  ?>
327
  <p class="form-field">
328
  <label class="options_header">&nbsp;</label>
@@ -356,7 +356,7 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
356
  </label>
357
  </p>
358
  <?php
359
- do_action( 'icegram_after_campaign_when_rule', $campaign_id, $campaign_target_rules );
360
  ?>
361
  </div>
362
  <div class="options_group" id="campaign_target_rules_device">
@@ -394,15 +394,15 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
394
 
395
  <div class="user_roles">
396
  <?php
397
- if ( !empty( $campaign_target_rules['logged_in'] ) && ($campaign_target_rules['logged_in'] == 'all' || $campaign_target_rules['logged_in'] == 'not_logged_in') ) {
398
- $campaign_logged_in_user_style = 'style="display: none;"';
399
- } else {
400
- $campaign_logged_in_user_style = 'style="display: block;"';
401
- }
402
  ?>
403
  <p class="form-field" <?php echo $campaign_logged_in_user_style; ?>>
404
  <label class="options_header">&nbsp;</label>
405
- <?php
406
  if ( isset( $wp_roles ) ) {
407
  $wp_roles = new WP_Roles();
408
  $roles = $wp_roles->get_names();
@@ -417,357 +417,364 @@ if ( !class_exists( 'Icegram_Campaign_Admin' ) ) {
417
  }
418
  echo '</select>';
419
  }
420
- ?>
 
 
 
 
 
 
 
 
421
  </div>
422
- <p class="form-field">
423
- <label class="options_header">&nbsp;</label>
424
- <label for="users_not_logged_in">
425
- <input type="radio" name="campaign_target_rules[logged_in]" id="users_not_logged_in" value="not_logged_in" <?php ( !empty( $campaign_target_rules['logged_in'] ) ) ? checked( $campaign_target_rules['logged_in'], 'not_logged_in' ) : ''; ?> />
426
- <?php _e( 'Not Logged in users', 'icegram' ); ?>
427
- </label>
428
- </p>
429
- </div>
430
- <?php $expiry_options_for_shown = array( 'current_session' => __('Current Session' ,'icegram'),
431
- '+50 years' => __('Never' ,'icegram'),
432
- 'today' => __('Today' ,'icegram'),
433
- '+1 week' => __('One week' ,'icegram') ,
434
- '+2 week' => __('Two weeks' ,'icegram'),
435
- '+1 month' => __('One Month ' ,'icegram'),
436
- '+3 months' => __('Three Months ' ,'icegram') ,
437
- '+1 year' => __('One year' ,'icegram') ,
438
- '+2 years' => __('Two Years' ,'icegram'));
439
- $expiry_options_for_clicked = array( '+50 years' => __('Never' ,'icegram'),
440
- 'current_session' => __('Current Session' ,'icegram'),
441
- 'today' => __('Today' ,'icegram'),
442
- '+1 week' => __('One week' ,'icegram') ,
443
- '+2 week' => __('Two weeks' ,'icegram'),
444
- '+1 month' => __('One Month ' ,'icegram'),
445
- '+3 months' => __('Three Months ' ,'icegram') ,
446
- '+1 year' => __('One year' ,'icegram') ,
447
- '+2 years' => __('Two Years' ,'icegram'));
448
-
449
- ?>
450
- <div class="options_group" id="campaign_target_rules_retargeting">
451
- <?php
452
- $html_content = '<p class="form-field">
453
- <label class="options_header">'.__( 'Retargeting', 'icegram' ).'</label>
454
- <label for="retargeting">
455
- <input type="checkbox" name="campaign_target_rules[retargeting]" id="retargeting" value="yes"'.(( !empty( $campaign_target_rules['retargeting'] ) ) ? checked( $campaign_target_rules['retargeting'], 'yes', false ) : '').'/>';
456
- $html_content .= __(' Once shown, do NOT show this campaign again for ', 'icegram' );
457
- $html_content .= '<select name="campaign_target_rules[expiry_time]">';
458
- foreach($expiry_options_for_shown as $key => $option){
459
  ?>
460
- <?php $html_content .= '<option value="'.$key.'"'.((!empty($campaign_target_rules['expiry_time'])) ? selected( $campaign_target_rules['expiry_time'], $key, false ) : "").'>'.$option.'</option>';
 
 
 
 
 
 
 
 
 
 
461
  }
462
- $html_content .= '</select>';
463
- $html_content .= '</label>';
464
- $campaign_target_rules_retargeting = apply_filters('icegram_campaign_target_rules_retargeting' , array( 'html' => $html_content, 'campaign_target_rules' => $campaign_target_rules, 'expiry_options_for_shown' => $expiry_options_for_shown));
465
- echo $campaign_target_rules_retargeting['html'];
466
- ?>
467
- </p>
468
- <p class="form-field">
469
- <label class="options_header">&nbsp;</label>
470
- <label for="retargeting_clicked">
471
- <input type="checkbox" name="campaign_target_rules[retargeting_clicked]" id="retargeting_clicked" value="yes" <?php ( !empty( $campaign_target_rules['retargeting_clicked'] ) ) ? checked( $campaign_target_rules['retargeting_clicked'], 'yes' ) : ''; ?> />
472
- <?php _e( 'Once CTA is clicked, do NOT show this campaign again for', 'icegram' ); ?>
473
- <select name="campaign_target_rules[expiry_time_clicked]">
474
- <?php foreach($expiry_options_for_clicked as $key => $option){
475
  ?>
476
  <option value="<?php echo $key; ?>" <?php (!empty($campaign_target_rules['expiry_time_clicked'])) ? selected( $campaign_target_rules['expiry_time_clicked'], $key ) : ''; ?>><?php echo $option; ?></option>
477
- <?php
478
- }
479
- ?>
480
- </select>
481
- </label>
482
- </p>
483
- </div>
484
- <?php
485
- }
486
 
487
  // Return json encoded messages for searched term
488
- function icegram_json_search_messages( $x = '' ) {
489
- global $icegram;
490
- check_ajax_referer( 'search-messages', 'security' );
491
 
492
- header( 'Content-Type: application/json; charset=utf-8' );
493
 
494
- $term = ( string ) urldecode( stripslashes( strip_tags( $_GET['term'] ) ) );
495
- $post_types = array('ig_message');
496
 
497
- if ( empty( $term ) ) die();
498
 
499
- if ( is_numeric( $term ) ) {
500
 
501
- $args = array(
502
- 'post_type' => $post_types,
503
- 'post_status' => 'publish',
504
- 'posts_per_page' => -1,
505
- 'post__in' => array( 0, $term ),
506
- 'fields' => 'ids'
507
- );
508
 
509
- $posts = get_posts( $args );
510
 
511
- } else {
512
 
513
- $args = array(
514
- 'post_type' => $post_types,
515
- 'post_status' => 'publish',
516
- 'posts_per_page' => -1,
517
- 's' => $term,
518
- 'fields' => 'ids'
519
- );
520
 
521
- $posts = get_posts( $args );
522
 
523
- }
524
 
525
- $found_messages = array();
526
- if ( $posts ) {
527
 
528
- foreach ( $posts as $post ) {
529
 
530
- $message_title = get_the_title( $post );
531
- $message_data = get_post_meta( $post, 'icegram_message_data', true );
532
- $message_type = ( !empty( $icegram->message_types[ $message_data['type'] ]['type'] ) ) ? $icegram->message_types[ $message_data['type'] ]['type'] : '';
533
- $found_messages[ $post ] = $message_type . ' &mdash; ' . $message_title;
534
 
535
- }
536
  // $found_messages[''] = __( '- - - - - - - - - - - - - - - - - - - - - - - - - -', 'icegram' );
537
- }
538
 
539
  // foreach ( $icegram->message_types as $message ) {
540
  // $found_messages[ $message['type'] ] = __( 'Create new', 'icegram' ) . ' ' . $message['name'] . ' ...';
541
  // }
542
- ob_clean();
543
- $found_messages = apply_filters( 'icegram_searched_messages', $found_messages, $term );
544
- echo json_encode( $found_messages );
545
- die();
546
- }
547
 
548
  // Constant table header for campaign
549
- function message_list_table_header() {
550
- ?>
551
- <thead>
552
- <tr class="form-field message-row-header">
553
- <th class="message_header"><?php _e( 'Type', 'icegram' ); ?></th>
554
- <th class="message_title"><?php _e( 'Name', 'icegram' ); ?></th>
555
- <th class="message_seconds"><?php _e( 'Show after', 'icegram' ); ?></th>
556
- <th class="action_links"><?php _e( 'Actions', 'icegram' ); ?></th>
557
- </tr>
558
- </thead>
559
- <?php
560
- }
561
 
562
  // Return html for message row in json encoded format
563
- function get_message_action_row() {
564
 
565
- $ig_message_admin = Icegram_Message_Admin::getInstance();
566
- $ig_message_admin->is_icegram_editor = true;
567
 
568
- if ( empty( $_POST['message_id'] ) || !is_numeric( $_POST['message_id'] ) ) {
569
 
570
- $my_post = array(
571
- 'post_status' => 'auto-draft',
572
- 'post_type' => 'ig_message'
573
- );
574
- $message_id = wp_insert_post( $my_post );
575
- $message_title = '';
576
- $message_type = $_POST['message_id'];
577
 
578
- } else {
579
-
580
- $message_id = $_POST['message_id'];
581
- $message_title = get_the_title( $message_id );
582
- $message_data = get_post_meta( $message_id, 'icegram_message_data', true );
583
- $message_type = $message_data['type'];
584
 
585
- }
586
-
587
- ob_start();
588
- $icegram_message_meta_key = apply_filters('icegram_message_meta_key' , 'messages');
589
- ?>
590
- <tr class="form-field message-row" value="<?php echo $message_id; ?>">
591
- <td class="message_header">
592
- <label class="message_header_label <?php echo "ig_".$message_type; ?>"><?php echo ucwords( str_replace( "-", ' ', $message_type ) ); ?></label>
593
- </td>
594
- <td class="message_title">
595
- <div class="message-title-text" style="display:none;"><?php echo $message_title; ?></div>
596
- <input type="text" class="message-title-input" name="message_data[<?php echo $message_id; ?>][post_title]" value="<?php echo $message_title; ?>" placeholder="<?php echo __( 'Give this message a name for your own reference', 'icegram' ); ?>">
597
- </td>
598
- <td class="message_seconds">
599
- <input type="hidden" name="<?php echo $icegram_message_meta_key .'['.$_POST['row']; ?>][id]" value="<?php echo $message_id; ?>" />
600
- <input type="number" class="seconds-text" name="<?php echo $icegram_message_meta_key .'['.$_POST['row']; ?>][time]" min="-1" value="0" size="3" /><?php _e( ' sec', 'icegram' )?>
601
- </td>
602
- <td class="action_links">
603
- <span class="actions message_edit" title="<?php _e( 'Edit Message', 'icegram' ); ?>" ></span>
604
- <span class="actions message_delete" title="<?php _e( 'Remove from Campaign', 'icegram' ); ?>" ></span>
605
- </td>
606
- </tr>
607
- <tr id="message_row_<?php echo $message_id; ?>" class="message-edit-row">
608
- <td colspan="4">
609
- <?php
610
- $ig_message_admin->message_form_fields( '', array( 'message_type' => $message_type, 'message_id' => $message_id, 'new_message_row' => true ) );
611
  ?>
612
- </td>
613
- </tr>
614
- <?php
615
-
616
- echo json_encode( array( 'id' => $message_id, 'main' => ob_get_clean() ) );
617
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
618
 
619
- }
 
620
 
621
- // Save all list of messages and targeting rules
622
- function save_campaign_settings( $post_id, $post ) {
623
-
624
- if (empty( $post_id ) || empty( $post ) || empty( $_POST )) return;
625
- if (defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE) return;
626
- if (is_int( wp_is_post_revision( $post ) )) return;
627
- if (is_int( wp_is_post_autosave( $post ) )) return;
628
- if ( empty( $_POST['icegram_campaign_meta_nonce'] ) || ! wp_verify_nonce( $_POST['icegram_campaign_meta_nonce'], 'icegram_campaign_save_data' ) ) return;
629
- if (! current_user_can( 'edit_post', $post_id )) return;
630
- if ($post->post_type != 'ig_campaign') return;
631
-
632
- $campaign_target_rules = apply_filters( 'icegram_update_campaign_rules', $_POST['campaign_target_rules'], $post_id );
633
-
634
- if(!empty($campaign_target_rules) && !empty($campaign_target_rules['local_urls'])){
635
- foreach ($campaign_target_rules['local_urls'] as $key => $url) {
636
- if( !empty( $url ) ){
637
- if( $url == '*'){
638
- $campaign_target_rules['local_urls'][$key] = $url;
639
- }else{
640
- $url = str_replace($this->site_url, '', $url);
641
- $campaign_target_rules['local_urls'][$key] = $url;
642
- }
643
- } else {
644
- unset($campaign_target_rules['local_urls'][$key]);
645
- }
646
- }
647
-
648
- }
649
-
650
- if ( isset( $_POST['page_id'] ) ) {
651
- $campaign_target_rules['page_id'] = $_POST['page_id'];
652
- update_post_meta( $post_id, 'icegram_campaign_target_pages', $_POST['page_id'] );
653
- }
654
- if ( isset( $_POST['exclude_page_id'] ) ) {
655
- $campaign_target_rules['exclude_page_id'] = $_POST['exclude_page_id'];
656
- update_post_meta( $post_id, 'icegram_campaign_target_pages', $_POST['exclude_page_id'] );
657
  }
658
 
659
- if ( count( $campaign_target_rules ) > 0 ) {
660
- update_post_meta( $post_id, 'icegram_campaign_target_rules', $campaign_target_rules );
661
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
 
663
- if ( empty( $_POST['messages'] ) ) {
664
- update_post_meta( $post_id, 'messages', array() );
665
- } else {
666
 
667
- update_post_meta( $post_id, 'messages', array_values( $_POST['messages'] ) );
668
- update_post_meta( $post_id, 'campaign_preview', array_values( $_POST['messages'] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
 
670
  // Saving $_POST to temp var before updating messages
671
  // to avoid problems with action handlers that rely on
672
  // $_POST vars - e.g. WPML!!
673
- $old_post = $_POST;
674
- $_POST = array();
675
- foreach ( $old_post['message_data'] as $message_id => $message_data ) {
676
 
677
- $type = $message_data['type'];
678
- if( isset( $message_data['theme'][$type] ) ) {
679
- $message_data['theme'] = $message_data['theme'][$type];
680
- } else {
681
- unset( $message_data['theme'] );
682
- }
683
- if( isset( $message_data['animation'][$type] ) ) {
684
- $message_data['animation'] = $message_data['animation'][$type];
685
- } else {
686
- unset( $message_data['animation'] );
687
- }
688
- if( isset( $message_data['position'][$type] ) ) {
689
- $message_data['position'] = $message_data['position'][$type];
690
- } elseif( isset( $message_data['position']['ig_default'] ) ) {
691
- $message_data['position'] = $message_data['position']['ig_default'];
692
- }
 
 
 
 
 
 
 
 
693
  //save message data when campaign is save
694
- $message_data = apply_filters( 'icegram_update_message_data', $message_data, $message_id );
695
- update_post_meta( $message_id, 'icegram_message_data', $message_data );
696
- update_post_meta( $message_id, 'icegram_message_preview_data', $message_data );
697
- wp_update_post( array ( 'ID' => $message_id,
698
- 'post_content' => $message_data['message'],
699
- 'post_status' => 'publish',
700
- 'post_title' => empty( $message_data['post_title'] ) ? $message_data['headline']: $message_data['post_title']
701
- ) );
 
 
702
  }
703
- $_POST = $old_post;
704
  }
705
- }
706
 
707
  // On preview button click save campaign messages list
708
- function save_campaign_preview() {
709
 
710
- if ( empty($_POST['post_ID']) ) die();
711
- if ( !current_user_can( 'edit_post', $_POST['post_ID'] ) ) die();
712
 
713
- $messages = apply_filters('campaign_preview_messages', $_POST['messages'], $_POST);
714
- if( !empty( $messages ) ) {
715
- update_post_meta( $_POST['post_ID'], 'campaign_preview', $messages ) ;
716
 
717
- foreach ( (array) $_POST['message_data'] as $message_id => $message_data ) {
718
- $type = $message_data['type'];
719
- if( isset( $message_data['theme'][$type] ) ) {
720
- $message_data['theme'] = $message_data['theme'][$type];
721
- } else {
722
- unset( $message_data['theme'] );
723
- }
724
- if( isset( $message_data['animation'][$type] ) ) {
725
- $message_data['animation'] = $message_data['animation'][$type];
726
- } else {
727
- unset( $message_data['animation'] );
728
- }
729
- if( isset( $message_data['position'][$type] ) ) {
730
- $message_data['position'] = $message_data['position'][$type];
731
- } elseif( isset( $message_data['position']['ig_default'] ) ) {
732
- $message_data['position'] = $message_data['position']['ig_default'];
 
 
 
733
  }
734
- $message_data = apply_filters( 'icegram_update_message_preview_data', $message_data, $message_id );
735
- update_post_meta( $message_id, 'icegram_message_preview_data', $message_data );
736
- }
737
  // Determine page url to preview on...
738
- $page_url = '';
739
 
740
- if ( !empty($_POST['campaign_target_rules']) && !empty($_POST['campaign_target_rules']['other_page']) && !empty($_POST['page_id']) && is_array($_POST['page_id'])) {
741
- $page_url = get_permalink( $_POST['page_id'][0] );
742
- }
743
- if ($page_url == '') {
744
- if(!empty($_POST['campaign_target_rules']['local_url']) && is_array($_POST['campaign_target_rules']['local_urls'])){
745
- $page_url = (strpos($_POST['campaign_target_rules']['local_urls'][0], '*') === false) ? $_POST['campaign_target_rules']['local_urls'][0] : home_url();
746
- }else{
747
- $page_url = home_url();
748
  }
 
 
 
 
 
 
 
 
 
749
  }
750
- ob_clean();
751
- echo esc_url(add_query_arg( 'campaign_preview_id', $_POST['post_ID'], $page_url ));
752
  }
753
- die();
754
 
755
- }
 
756
 
757
- function add_campaign_action( $actions, $post ){
758
- if ($post->post_type != 'ig_campaign') return $actions;
759
-
760
  // Create a nonce & add an action
761
- $actions['duplicate_campaign'] = '<a class="ig-duplicate-campaign" href="post.php?campaign_id='.$post->ID.'&action=duplicate-campaign" >'.__('Duplicate' ,'icegram').'</a>';
762
- $actions['preview_campaign'] = '<a class="ig-preview-campaign" target="_blank" href="'.home_url().'?campaign_preview_id='.$post->ID.'" >'.__('Preview' ,'icegram').'</a>';
763
- return $actions;
764
- }
765
 
766
- function duplicate_campaign(){
767
- if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate-campaign' && !empty($_REQUEST['campaign_id'])){
768
- Icegram::duplicate( $_REQUEST['campaign_id']);
 
769
  }
 
770
  }
771
-
772
- }
773
- }
11
  function __construct() {
12
 
13
  // add_action( 'add_meta_boxes', array( &$this, 'add_campaigns_metaboxes' ), 0 );
14
+ add_action( 'edit_form_advanced', array( &$this, 'add_campaigns_tabs' ) );
15
 
16
  add_action( 'save_post', array( &$this, 'save_campaign_settings' ), 10, 2 );
17
  add_action( 'wp_ajax_icegram_json_search_messages', array( &$this, 'icegram_json_search_messages' ) );
18
  add_action( 'wp_ajax_get_message_action_row', array( &$this, 'get_message_action_row' ) );
19
  // add_filter( 'wp_default_editor', create_function('', 'return "html";') );
20
+ add_action( 'wp_ajax_save_campaign_preview', array( &$this, 'save_campaign_preview' ) );
21
+ add_action( 'icegram_campaign_target_rules', array( &$this, 'icegram_add_campaign_target_rules' ), 10, 2 );
22
+ add_filter('icegram_campaign_messages' ,array( &$this, 'get_icegram_campaign_messages' ) ,10,2 );
23
  //duplicate campaign
24
+ add_filter( 'post_row_actions', array(&$this , 'add_campaign_action'), 10, 2 );
25
+ add_action('admin_init', array(&$this ,'duplicate_campaign') ,10, 1);
26
 
27
  // Adding tabs here
28
+ add_filter( 'icegram_campaign_tabs', array( &$this, 'campaign_data_tab_content' ), 0, 1 );
29
+ add_filter( 'icegram_campaign_tabs', array( &$this, 'campaign_target_rules_tab_content' ), 100, 1 );
30
 
31
+ $this->site_url = home_url().'/';
32
 
33
  $this->default_target_rules = apply_filters( 'icegram_campaign_default_rules',
34
+ array ( 'homepage' => 'yes',
35
+ 'when' => 'always',
36
+ 'mobile' => 'yes',
37
+ 'tablet' => 'yes',
38
+ 'laptop' => 'yes',
39
+ 'logged_in' => 'all'
40
+ )
41
+ );
42
 
43
  }
44
  public static function getInstance(){
45
+ static $ig_campaign_admin = null;
46
+ if (null === $ig_campaign_admin) {
47
+ $ig_campaign_admin = new Icegram_Campaign_Admin();
48
+ }
49
+ return $ig_campaign_admin;
50
  }
51
 
52
  // Initialize campaign Tabs
63
  $tabs_content = !empty($tabs['tabs']) ? implode('', $tabs['tabs']) : '';
64
 
65
  $preview_button = '<div id="" class="ig_preview_button">
66
+ <div class="button button-primary campaign_preview">' . __( 'Preview Campaign', 'icegram' ) .'</div>
67
+ <div class="clear"></div></div>';
68
 
69
  // $preview_button = '<div class="button button-primary campaign_preview">' . __( 'Preview', 'icegram' ) . '</div>';
70
  echo $preview_button .'<div id="ig-admin-tabs"><ul class="ig-admin-tabs-nav">'. $tabs_nav .'</ul>'. $tabs_content .'</div>';
73
  if ( $pagenow == 'post-new.php' ) {
74
  echo "<style>
75
  #poststuff{
76
+ position:relative;
77
+ }
78
  #poststuff #post-body.columns-2{
79
+ margin-right: 0;
80
+ }
81
+ .wrap h1.wp-heading-inline,
82
  #post-body-content,
83
+ .postbox-container + *:not(:last-child),
84
+ .postbox-container > *:not(.ig-gallery-wrap){
85
+ display:none;
86
+ }
87
+ .wrap h1.wp-heading-inline.gallery-heading{
88
+ display:inline-block;
89
+ }
90
+ .ig-gallery-position{
91
+ position: absolute;
92
+ width: 100%;
93
+ left: 0;
94
+ top: 50px;
95
+ }
96
  #postbox-container-1 #side-sortables.gal-toggled{
97
+ display:block;
98
+ }
99
+ </style>";
100
  // echo '<h1 class="wp-heading-inline gallery-heading">'. __('Import from beautiful design templates', 'icegram'). '<a href="#" class="page-title-action" id="ig-add-new-campaign">'. __('Add New Campaign', 'icegram'). '</a></h1>';
101
  // echo '<h1 class="wp-heading-inline gallery-heading">'. __('Import from beautiful design templates', 'icegram').'</h1>';
102
+ Icegram::gallery_screen();
103
+ }
104
+
105
+ }
106
 
107
  // Display list of messages of campaign tab
108
+ function campaign_data_tab_content($tabs) {
109
 
110
+ $tab_id = 'main';
111
  $tab_class = 'campaign_data'; // space seprated classes
112
 
113
  $tabs['nav'][$tab_id] = '<li class="ig-admin-nav-'. $tab_id . '"><a href="#ig-admin-tab-'. $tab_id .'">'. __( 'Messages', 'icegram' ) .'</a></li>';
156
  <? do_action('main_tab_prepand_content')?>
157
  <div class="campaign_box"><?php echo $title; ?> &mdash; <?php echo $campaign_box; ?></div>
158
  <div style="margin: 8px -12px 12px -12px">
159
+ <hr/>
160
  </div>
161
  <div class="campaign_target_rules_panel">
162
  <div class="options_group">
167
  ?>
168
  <tbody>
169
  <?php
170
+ $messages = array();
171
+ $messages = apply_filters('icegram_campaign_messages', $messages, $post->ID);
172
+ $icegram_message_meta_key = apply_filters('icegram_message_meta_key', 'messages');
173
+ if ( !empty( $messages ) ) {
174
+ foreach ( $messages as $row => $message ) {
175
+ $message_title = get_the_title( $message['id'] );
176
+ $message_data = get_post_meta( $message['id'], 'icegram_message_data', true );
177
+ $message_type = ( !empty( $message_data['type'] ) ) ? $message_data['type'] : '';
178
+ $class = ( !empty( $icegram->message_types[ $message_type ] ) ) ? $message_type : 'unknown';
179
  //if ( empty( $icegram->message_types[ $message_type ] ) ) continue;
180
+ ?>
181
+ <tr class="form-field message-row" value="<?php echo $message['id']; ?>">
182
+ <td class="message_header">
183
+ <label class="message_header_label <?php echo "ig_".$message_data['type'] ." " .$class; ?>"><?php echo esc_attr($class); ?></label>
184
+ </td>
185
+ <td class="message_title">
186
+ <div class="message-title-text"><?php echo $message_title; ?></div>
187
+ <input type="text" class="message-title-input" name="message_data[<?php echo $message['id']; ?>][post_title]" value="<?php echo esc_attr($message_title); ?>" placeholder="<?php echo __( 'Give this message a name for your own reference', 'icegram' ); ?>" style="display: none;">
188
+ </td>
189
+ <td class="message_seconds">
190
+ <input type="hidden" name="<?php echo $icegram_message_meta_key .'['.$row; ?>][id]" value="<?php echo $message['id']; ?>" />
191
+ <input type="number" class="seconds-text" name="<?php echo $icegram_message_meta_key .'['.$row; ?>][time]" min="-1" value="<?php echo ( !empty( $message['time'] ) ) ? $message['time'] : 0; ?>" size="3" />
192
+ <?php _e( ' sec', 'icegram' )?>
193
+ </td>
194
+ <td class="action_links">
195
+ <span class="actions message_edit" title="<?php _e( 'Edit Message', 'icegram' ); ?>" ></span>
196
+ <span class="actions message_delete" title="<?php _e( 'Remove from Campaign', 'icegram' ); ?>" ></span>
197
+ </td>
198
+ </tr>
199
+ <tr id="message_row_<?php echo $message['id']; ?>" class="message-edit-row" style="display: none;">
200
+ <td colspan="4">
201
  <?php
202
+ $ig_message_admin->message_form_fields( '', array( 'message_id' => $message['id'] ) );
203
  ?>
204
+ </td>
205
+ </tr>
206
+ <?php
 
207
  }
208
+ }
209
  ?>
210
  </tbody>
211
  </table>
259
  <p class="form-field" <?php echo ( !empty( $campaign_target_rules['sitewide'] ) && $campaign_target_rules['sitewide'] == 'yes' ) ? '' : 'style="display: none;"'; ?>>
260
  <label class="options_header"></label>
261
  <?php
262
+ echo '<select name="exclude_page_id[]" id="exclude_page_id" data-placeholder="' . __( 'Select pages to exclude&hellip;', 'icegram' ) . '" style="min-width:300px;" class="icegram_chosen_page" multiple>';
263
+ foreach ( get_pages() as $page ) {
264
+ echo '<option value="' . $page->ID . '"';
265
+ if( !empty( $campaign_target_rules['exclude_page_id'] ) ) {
266
+ echo selected( in_array( $page->ID, $campaign_target_rules['exclude_page_id'] ) );
 
 
267
  }
268
+ echo '>' . $page->post_title . '</option>';
269
+ }
270
+ echo '</select>';
271
  ?>
272
  </p>
273
  <p class="form-field">
287
  <p class="form-field" <?php echo ( !empty( $campaign_target_rules['other_page'] ) && $campaign_target_rules['other_page'] == 'yes' ) ? '' : 'style="display: none;"'; ?>>
288
  <label class="options_header">&nbsp;</label>
289
  <?php
290
+ echo '<select name="page_id[]" id="where_page_id" data-placeholder="' . __( 'Select a page&hellip;', 'icegram' ) . '" style="min-width:300px;" class="icegram_chosen_page" multiple>';
291
+ foreach ( get_pages() as $page ) {
292
+ echo '<option value="' . $page->ID . '"';
293
+ if( !empty( $campaign_target_rules['page_id'] ) ) {
294
+ echo selected( in_array( $page->ID, $campaign_target_rules['page_id'] ) );
 
 
295
  }
296
+ echo '>' . $page->post_title . '</option>';
297
+ }
298
+ echo '</select>';
299
  ?>
300
  </p>
301
  <p class="form-field">
311
  foreach ($campaign_target_rules['local_urls'] as $url) {?>
312
  <span><label class="options_header"><span id="valid-field"> </span></label>
313
  <input type="text" data-option="local_url" class="url_input_field" name="campaign_target_rules[local_urls][]" value="<?php echo $this->site_url.$url ;?>"/><span class="delete-url"></span></span>
314
+ <?php
315
  }
316
  }else{ ?>
317
  <span><label class="options_header"><span id="valid-field"> </span></label>
322
  </p>
323
 
324
  <?php
325
+ do_action( 'icegram_after_campaign_where_rule', $campaign_id, $campaign_target_rules );
326
  ?>
327
  <p class="form-field">
328
  <label class="options_header">&nbsp;</label>
356
  </label>
357
  </p>
358
  <?php
359
+ do_action( 'icegram_after_campaign_when_rule', $campaign_id, $campaign_target_rules );
360
  ?>
361
  </div>
362
  <div class="options_group" id="campaign_target_rules_device">
394
 
395
  <div class="user_roles">
396
  <?php
397
+ if ( !empty( $campaign_target_rules['logged_in'] ) && ($campaign_target_rules['logged_in'] == 'all' || $campaign_target_rules['logged_in'] == 'not_logged_in') ) {
398
+ $campaign_logged_in_user_style = 'style="display: none;"';
399
+ } else {
400
+ $campaign_logged_in_user_style = 'style="display: block;"';
401
+ }
402
  ?>
403
  <p class="form-field" <?php echo $campaign_logged_in_user_style; ?>>
404
  <label class="options_header">&nbsp;</label>
405
+ <?php
406
  if ( isset( $wp_roles ) ) {
407
  $wp_roles = new WP_Roles();
408
  $roles = $wp_roles->get_names();
417
  }
418
  echo '</select>';
419
  }
420
+ ?>
421
+ </div>
422
+ <p class="form-field">
423
+ <label class="options_header">&nbsp;</label>
424
+ <label for="users_not_logged_in">
425
+ <input type="radio" name="campaign_target_rules[logged_in]" id="users_not_logged_in" value="not_logged_in" <?php ( !empty( $campaign_target_rules['logged_in'] ) ) ? checked( $campaign_target_rules['logged_in'], 'not_logged_in' ) : ''; ?> />
426
+ <?php _e( 'Not Logged in users', 'icegram' ); ?>
427
+ </label>
428
+ </p>
429
  </div>
430
+ <?php $expiry_options_for_shown = array( 'current_session' => __('Current Session' ,'icegram'),
431
+ '+50 years' => __('Never' ,'icegram'),
432
+ 'today' => __('Today' ,'icegram'),
433
+ '+1 week' => __('One week' ,'icegram') ,
434
+ '+2 week' => __('Two weeks' ,'icegram'),
435
+ '+1 month' => __('One Month ' ,'icegram'),
436
+ '+3 months' => __('Three Months ' ,'icegram') ,
437
+ '+1 year' => __('One year' ,'icegram') ,
438
+ '+2 years' => __('Two Years' ,'icegram'));
439
+ $expiry_options_for_clicked = array( '+50 years' => __('Never' ,'icegram'),
440
+ 'current_session' => __('Current Session' ,'icegram'),
441
+ 'today' => __('Today' ,'icegram'),
442
+ '+1 week' => __('One week' ,'icegram') ,
443
+ '+2 week' => __('Two weeks' ,'icegram'),
444
+ '+1 month' => __('One Month ' ,'icegram'),
445
+ '+3 months' => __('Three Months ' ,'icegram') ,
446
+ '+1 year' => __('One year' ,'icegram') ,
447
+ '+2 years' => __('Two Years' ,'icegram'));
448
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  ?>
450
+ <div class="options_group" id="campaign_target_rules_retargeting">
451
+ <?php
452
+ $html_content = '<p class="form-field">
453
+ <label class="options_header">'.__( 'Retargeting', 'icegram' ).'</label>
454
+ <label for="retargeting">
455
+ <input type="checkbox" name="campaign_target_rules[retargeting]" id="retargeting" value="yes"'.(( !empty( $campaign_target_rules['retargeting'] ) ) ? checked( $campaign_target_rules['retargeting'], 'yes', false ) : '').'/>';
456
+ $html_content .= __(' Once shown, do NOT show this campaign again for ', 'icegram' );
457
+ $html_content .= '<select name="campaign_target_rules[expiry_time]">';
458
+ foreach($expiry_options_for_shown as $key => $option){
459
+ ?>
460
+ <?php $html_content .= '<option value="'.$key.'"'.((!empty($campaign_target_rules['expiry_time'])) ? selected( $campaign_target_rules['expiry_time'], $key, false ) : "").'>'.$option.'</option>';
461
  }
462
+ $html_content .= '</select>';
463
+ $html_content .= '</label>';
464
+ $campaign_target_rules_retargeting = apply_filters('icegram_campaign_target_rules_retargeting' , array( 'html' => $html_content, 'campaign_target_rules' => $campaign_target_rules, 'expiry_options_for_shown' => $expiry_options_for_shown));
465
+ echo $campaign_target_rules_retargeting['html'];
466
+ ?>
467
+ </p>
468
+ <p class="form-field">
469
+ <label class="options_header">&nbsp;</label>
470
+ <label for="retargeting_clicked">
471
+ <input type="checkbox" name="campaign_target_rules[retargeting_clicked]" id="retargeting_clicked" value="yes" <?php ( !empty( $campaign_target_rules['retargeting_clicked'] ) ) ? checked( $campaign_target_rules['retargeting_clicked'], 'yes' ) : ''; ?> />
472
+ <?php _e( 'Once CTA is clicked, do NOT show this campaign again for', 'icegram' ); ?>
473
+ <select name="campaign_target_rules[expiry_time_clicked]">
474
+ <?php foreach($expiry_options_for_clicked as $key => $option){
475
  ?>
476
  <option value="<?php echo $key; ?>" <?php (!empty($campaign_target_rules['expiry_time_clicked'])) ? selected( $campaign_target_rules['expiry_time_clicked'], $key ) : ''; ?>><?php echo $option; ?></option>
477
+ <?php
478
+ }
479
+ ?>
480
+ </select>
481
+ </label>
482
+ </p>
483
+ </div>
484
+ <?php
485
+ }
486
 
487
  // Return json encoded messages for searched term
488
+ function icegram_json_search_messages( $x = '' ) {
489
+ global $icegram;
490
+ check_ajax_referer( 'search-messages', 'security' );
491
 
492
+ header( 'Content-Type: application/json; charset=utf-8' );
493
 
494
+ $term = ( string ) urldecode( stripslashes( strip_tags( $_GET['term'] ) ) );
495
+ $post_types = array('ig_message');
496
 
497
+ if ( empty( $term ) ) die();
498
 
499
+ if ( is_numeric( $term ) ) {
500
 
501
+ $args = array(
502
+ 'post_type' => $post_types,
503
+ 'post_status' => 'publish',
504
+ 'posts_per_page' => -1,
505
+ 'post__in' => array( 0, $term ),
506
+ 'fields' => 'ids'
507
+ );
508
 
509
+ $posts = get_posts( $args );
510
 
511
+ } else {
512
 
513
+ $args = array(
514
+ 'post_type' => $post_types,
515
+ 'post_status' => 'publish',
516
+ 'posts_per_page' => -1,
517
+ 's' => $term,
518
+ 'fields' => 'ids'
519
+ );
520
 
521
+ $posts = get_posts( $args );
522
 
523
+ }
524
 
525
+ $found_messages = array();
526
+ if ( $posts ) {
527
 
528
+ foreach ( $posts as $post ) {
529
 
530
+ $message_title = get_the_title( $post );
531
+ $message_data = get_post_meta( $post, 'icegram_message_data', true );
532
+ $message_type = ( !empty( $icegram->message_types[ $message_data['type'] ]['type'] ) ) ? $icegram->message_types[ $message_data['type'] ]['type'] : '';
533
+ $found_messages[ $post ] = $message_type . ' &mdash; ' . $message_title;
534
 
535
+ }
536
  // $found_messages[''] = __( '- - - - - - - - - - - - - - - - - - - - - - - - - -', 'icegram' );
537
+ }
538
 
539
  // foreach ( $icegram->message_types as $message ) {
540
  // $found_messages[ $message['type'] ] = __( 'Create new', 'icegram' ) . ' ' . $message['name'] . ' ...';
541
  // }
542
+ ob_clean();
543
+ $found_messages = apply_filters( 'icegram_searched_messages', $found_messages, $term );
544
+ echo json_encode( $found_messages );
545
+ die();
546
+ }
547
 
548
  // Constant table header for campaign
549
+ function message_list_table_header() {
550
+ ?>
551
+ <thead>
552
+ <tr class="form-field message-row-header">
553
+ <th class="message_header"><?php _e( 'Type', 'icegram' ); ?></th>
554
+ <th class="message_title"><?php _e( 'Name', 'icegram' ); ?></th>
555
+ <th class="message_seconds"><?php _e( 'Show after', 'icegram' ); ?></th>
556
+ <th class="action_links"><?php _e( 'Actions', 'icegram' ); ?></th>
557
+ </tr>
558
+ </thead>
559
+ <?php
560
+ }
561
 
562
  // Return html for message row in json encoded format
563
+ function get_message_action_row() {
564
 
565
+ $ig_message_admin = Icegram_Message_Admin::getInstance();
566
+ $ig_message_admin->is_icegram_editor = true;
567
 
568
+ if ( empty( $_POST['message_id'] ) || !is_numeric( $_POST['message_id'] ) ) {
569
 
570
+ $my_post = array(
571
+ 'post_status' => 'auto-draft',
572
+ 'post_type' => 'ig_message'
573
+ );
574
+ $message_id = wp_insert_post( $my_post );
575
+ $message_title = '';
576
+ $message_type = $_POST['message_id'];
577
 
578
+ } else {
 
 
 
 
 
579
 
580
+ $message_id = $_POST['message_id'];
581
+ $message_title = get_the_title( $message_id );
582
+ $message_data = get_post_meta( $message_id, 'icegram_message_data', true );
583
+ $message_type = $message_data['type'];
584
+
585
+ }
586
+
587
+ ob_start();
588
+ $icegram_message_meta_key = apply_filters('icegram_message_meta_key' , 'messages');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
  ?>
590
+ <tr class="form-field message-row" value="<?php echo $message_id; ?>">
591
+ <td class="message_header">
592
+ <label class="message_header_label <?php echo "ig_".$message_type; ?>"><?php echo ucwords( str_replace( "-", ' ', $message_type ) ); ?></label>
593
+ </td>
594
+ <td class="message_title">
595
+ <div class="message-title-text" style="display:none;"><?php echo $message_title; ?></div>
596
+ <input type="text" class="message-title-input" name="message_data[<?php echo $message_id; ?>][post_title]" value="<?php echo $message_title; ?>" placeholder="<?php echo __( 'Give this message a name for your own reference', 'icegram' ); ?>">
597
+ </td>
598
+ <td class="message_seconds">
599
+ <input type="hidden" name="<?php echo $icegram_message_meta_key .'['.$_POST['row']; ?>][id]" value="<?php echo $message_id; ?>" />
600
+ <input type="number" class="seconds-text" name="<?php echo $icegram_message_meta_key .'['.$_POST['row']; ?>][time]" min="-1" value="0" size="3" /><?php _e( ' sec', 'icegram' )?>
601
+ </td>
602
+ <td class="action_links">
603
+ <span class="actions message_edit" title="<?php _e( 'Edit Message', 'icegram' ); ?>" ></span>
604
+ <span class="actions message_delete" title="<?php _e( 'Remove from Campaign', 'icegram' ); ?>" ></span>
605
+ </td>
606
+ </tr>
607
+ <tr id="message_row_<?php echo $message_id; ?>" class="message-edit-row">
608
+ <td colspan="4">
609
+ <?php
610
+ $ig_message_admin->message_form_fields( '', array( 'message_type' => $message_type, 'message_id' => $message_id, 'new_message_row' => true ) );
611
+ ?>
612
+ </td>
613
+ </tr>
614
+ <?php
615
 
616
+ echo json_encode( array( 'id' => $message_id, 'main' => ob_get_clean() ) );
617
+ die();
618
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
619
  }
620
 
621
+ // Save all list of messages and targeting rules
622
+ function save_campaign_settings( $post_id, $post ) {
623
+
624
+ if (empty( $post_id ) || empty( $post ) || empty( $_POST )) return;
625
+ if (defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE) return;
626
+ if (is_int( wp_is_post_revision( $post ) )) return;
627
+ if (is_int( wp_is_post_autosave( $post ) )) return;
628
+ if ( empty( $_POST['icegram_campaign_meta_nonce'] ) || ! wp_verify_nonce( $_POST['icegram_campaign_meta_nonce'], 'icegram_campaign_save_data' ) ) return;
629
+ if (! current_user_can( 'edit_post', $post_id )) return;
630
+ if ($post->post_type != 'ig_campaign') return;
631
+
632
+ $campaign_target_rules = apply_filters( 'icegram_update_campaign_rules', $_POST['campaign_target_rules'], $post_id );
633
+
634
+ if(!empty($campaign_target_rules) && !empty($campaign_target_rules['local_urls'])){
635
+ foreach ($campaign_target_rules['local_urls'] as $key => $url) {
636
+ if( !empty( $url ) ){
637
+ if( $url == '*'){
638
+ $campaign_target_rules['local_urls'][$key] = $url;
639
+ }else{
640
+ $url = str_replace($this->site_url, '', $url);
641
+ $campaign_target_rules['local_urls'][$key] = $url;
642
+ }
643
+ } else {
644
+ unset($campaign_target_rules['local_urls'][$key]);
645
+ }
646
+ }
647
 
648
+ }
 
 
649
 
650
+ if ( isset( $_POST['page_id'] ) ) {
651
+ $campaign_target_rules['page_id'] = $_POST['page_id'];
652
+ update_post_meta( $post_id, 'icegram_campaign_target_pages', $_POST['page_id'] );
653
+ }
654
+ if ( isset( $_POST['exclude_page_id'] ) ) {
655
+ $campaign_target_rules['exclude_page_id'] = $_POST['exclude_page_id'];
656
+ update_post_meta( $post_id, 'icegram_campaign_target_pages', $_POST['exclude_page_id'] );
657
+ }
658
+
659
+ if ( count( $campaign_target_rules ) > 0 ) {
660
+ update_post_meta( $post_id, 'icegram_campaign_target_rules', $campaign_target_rules );
661
+ }
662
+
663
+ if ( empty( $_POST['messages'] ) ) {
664
+ update_post_meta( $post_id, 'messages', array() );
665
+ } else {
666
+
667
+ update_post_meta( $post_id, 'messages', array_values( $_POST['messages'] ) );
668
+ update_post_meta( $post_id, 'campaign_preview', array_values( $_POST['messages'] ) );
669
 
670
  // Saving $_POST to temp var before updating messages
671
  // to avoid problems with action handlers that rely on
672
  // $_POST vars - e.g. WPML!!
673
+ $old_post = $_POST;
674
+ $_POST = array();
 
675
 
676
+ foreach ( $old_post['message_data'] as $message_id => $message_data ) {
677
+
678
+ $type = $message_data['type'];
679
+ if( isset( $message_data['theme'][$type] ) ) {
680
+ $message_data['theme'] = $message_data['theme'][$type];
681
+ } else {
682
+ unset( $message_data['theme'] );
683
+ }
684
+ if( isset( $message_data['animation'][$type] ) ) {
685
+ $message_data['animation'] = $message_data['animation'][$type];
686
+ } else {
687
+ unset( $message_data['animation'] );
688
+ }
689
+ if( isset( $message_data['position'][$type] ) ) {
690
+ $message_data['position'] = $message_data['position'][$type];
691
+ } elseif( isset( $message_data['position']['ig_default'] ) ) {
692
+ $message_data['position'] = $message_data['position']['ig_default'];
693
+ }
694
+
695
+ if( empty( $message_data['rainmaker_form_code'] ) && ! empty( $message_data['form_html_original'] ) && strpos( $message_data['form_html_original'], 'rainmaker_form') ) {
696
+ $rm_shortcode_pos = strpos($message_data['form_html_original'], '"')+1;
697
+ $rm_shortcode = substr($message_data['form_html_original'], $rm_shortcode_pos , strripos($message_data['form_html_original'], "\\") - $rm_shortcode_pos);
698
+ $message_data['rainmaker_form_code'] = $rm_shortcode ;
699
+ }
700
  //save message data when campaign is save
701
+ $message_data = apply_filters( 'icegram_update_message_data', $message_data, $message_id );
702
+ update_post_meta( $message_id, 'icegram_message_data', $message_data );
703
+ update_post_meta( $message_id, 'icegram_message_preview_data', $message_data );
704
+ wp_update_post( array ( 'ID' => $message_id,
705
+ 'post_content' => $message_data['message'],
706
+ 'post_status' => 'publish',
707
+ 'post_title' => empty( $message_data['post_title'] ) ? $message_data['headline']: $message_data['post_title']
708
+ ) );
709
+ }
710
+ $_POST = $old_post;
711
  }
 
712
  }
 
713
 
714
  // On preview button click save campaign messages list
715
+ function save_campaign_preview() {
716
 
717
+ if ( empty($_POST['post_ID']) ) die();
718
+ if ( !current_user_can( 'edit_post', $_POST['post_ID'] ) ) die();
719
 
720
+ $messages = apply_filters('campaign_preview_messages', $_POST['messages'], $_POST);
721
+ if( !empty( $messages ) ) {
722
+ update_post_meta( $_POST['post_ID'], 'campaign_preview', $messages ) ;
723
 
724
+ foreach ( (array) $_POST['message_data'] as $message_id => $message_data ) {
725
+ $type = $message_data['type'];
726
+ if( isset( $message_data['theme'][$type] ) ) {
727
+ $message_data['theme'] = $message_data['theme'][$type];
728
+ } else {
729
+ unset( $message_data['theme'] );
730
+ }
731
+ if( isset( $message_data['animation'][$type] ) ) {
732
+ $message_data['animation'] = $message_data['animation'][$type];
733
+ } else {
734
+ unset( $message_data['animation'] );
735
+ }
736
+ if( isset( $message_data['position'][$type] ) ) {
737
+ $message_data['position'] = $message_data['position'][$type];
738
+ } elseif( isset( $message_data['position']['ig_default'] ) ) {
739
+ $message_data['position'] = $message_data['position']['ig_default'];
740
+ }
741
+ $message_data = apply_filters( 'icegram_update_message_preview_data', $message_data, $message_id );
742
+ update_post_meta( $message_id, 'icegram_message_preview_data', $message_data );
743
  }
 
 
 
744
  // Determine page url to preview on...
745
+ $page_url = '';
746
 
747
+ if ( !empty($_POST['campaign_target_rules']) && !empty($_POST['campaign_target_rules']['other_page']) && !empty($_POST['page_id']) && is_array($_POST['page_id'])) {
748
+ $page_url = get_permalink( $_POST['page_id'][0] );
 
 
 
 
 
 
749
  }
750
+ if ($page_url == '') {
751
+ if(!empty($_POST['campaign_target_rules']['local_url']) && is_array($_POST['campaign_target_rules']['local_urls'])){
752
+ $page_url = (strpos($_POST['campaign_target_rules']['local_urls'][0], '*') === false) ? $_POST['campaign_target_rules']['local_urls'][0] : home_url();
753
+ }else{
754
+ $page_url = home_url();
755
+ }
756
+ }
757
+ ob_clean();
758
+ echo esc_url(add_query_arg( 'campaign_preview_id', $_POST['post_ID'], $page_url ));
759
  }
760
+ die();
761
+
762
  }
 
763
 
764
+ function add_campaign_action( $actions, $post ){
765
+ if ($post->post_type != 'ig_campaign') return $actions;
766
 
 
 
 
767
  // Create a nonce & add an action
768
+ $actions['duplicate_campaign'] = '<a class="ig-duplicate-campaign" href="post.php?campaign_id='.$post->ID.'&action=duplicate-campaign" >'.__('Duplicate' ,'icegram').'</a>';
769
+ $actions['preview_campaign'] = '<a class="ig-preview-campaign" target="_blank" href="'.home_url().'?campaign_preview_id='.$post->ID.'" >'.__('Preview' ,'icegram').'</a>';
770
+ return $actions;
771
+ }
772
 
773
+ function duplicate_campaign(){
774
+ if(!empty($_REQUEST['action']) && $_REQUEST['action'] == 'duplicate-campaign' && !empty($_REQUEST['campaign_id'])){
775
+ Icegram::duplicate( $_REQUEST['campaign_id']);
776
+ }
777
  }
778
+
779
  }
780
+ }
 
 
classes/class-icegram-compat.php CHANGED
@@ -12,12 +12,12 @@ if ( !class_exists( 'Icegram_Compat_Base' ) ) {
12
  if($icegram->cache_compatibility === 'yes'){
13
  add_action( 'wp_footer', array( &$this, 'render_js' ) );
14
  } else {
15
- add_action( 'icegram_data_printed', array( &$this, 'render_js' ) );
16
  }
17
  }
18
 
19
  // This will be overridden in child classes
20
- function render_js() {
21
 
22
  }
23
  }
12
  if($icegram->cache_compatibility === 'yes'){
13
  add_action( 'wp_footer', array( &$this, 'render_js' ) );
14
  } else {
15
+ add_action( 'icegram_data_printed', array( &$this, 'render_js' ), 10, 1 );
16
  }
17
  }
18
 
19
  // This will be overridden in child classes
20
+ function render_js( $type ) {
21
 
22
  }
23
  }
classes/class-icegram-message-admin.php CHANGED
@@ -54,35 +54,35 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
54
  }
55
  ?>
56
 
57
- <style type="text/css">
58
- <?php
59
- foreach ( $icegram->message_types as $message_type => $message ) {
60
- if( !empty( $message['admin_style'] ) ) {
61
- $message_type = 'ig_'.$message_type;
62
- $label_bg_color = $message['admin_style']['label_bg_color'];
63
- $theme_header_height = (int)$message['admin_style']['theme_header_height'];
64
- $theme_header_bg_size = ( $theme_header_height + 3 )."em";
65
- $thumbnail_width = $message['admin_style']['thumbnail_width'];
66
- $thumbnail_height = $message['admin_style']['thumbnail_height'];
67
- echo " .message_header .$message_type {
68
- background-color: {$label_bg_color};
69
- }
70
- .message_theme_{$message_type} + .chosen-container-single .chosen-single {
71
- height: {$theme_header_height} !important;
72
- }
73
- .message_theme_{$message_type} + .chosen-container-single .chosen-single span {
74
- background-size: {$theme_header_bg_size} !important;
75
- line-height: {$theme_header_height} !important;
76
- }
77
- .message_theme_{$message_type} + .chosen-container .chosen-results li {
78
- width: {$thumbnail_width} !important;
79
- height: {$thumbnail_height} !important;
80
- }";
81
  }
82
-
 
 
 
 
 
 
 
83
  }
 
 
84
  ?>
85
- </style>
86
  <?php
87
  $message_id = ! empty( $action['message_id'] ) ? $action['message_id'] : $post->ID;
88
  $message_data = get_post_meta( $message_id, 'icegram_message_data', true );
@@ -109,42 +109,42 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
109
  wp_nonce_field( 'icegram_message_save_data', 'icegram_message_meta_nonce' );
110
  if ( ! empty( $action['message_id'] ) ) {
111
  ?>
112
- <div class="thickbox_edit_message" id="<?php echo $action['message_id']; ?>">
113
- <?php
114
- }
115
- ?>
116
- <div class="wp_attachment_details edit-form-section message-setting-fields">
117
- <input id="message_type" class="message_type" name="message_data[<?php echo $message_id; ?>][type]" type="hidden" value="<?php echo esc_attr( $message_data['type'] ) ?>"></input>
118
- <input id="message_theme_ig_<?php echo esc_attr( $message_data['type'] ) ?>" name="message_data[<?php echo $message_id; ?>][theme][<?php echo esc_attr( $message_data['type'] ) ?>]" type="hidden" value="<?php echo esc_attr( $message_data['theme'] ) ?>"></input>
119
  <?php // action add for interstitial message setting
120
  do_action( 'icegram_after_message_theme_settings', $message_id, $message_data );
121
  ?>
122
 
123
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['headline'] ) ?>">
124
- <label for="message_headline" class="message_label">
125
- <strong><?php _e( 'Headline', 'icegram' ); ?></strong>
126
- <span class="help_tip admin_field_icon" data-tip="<?php _e( 'Shown with highest prominence. Click on idea button on right to get a new headline.', 'icegram' ); ?>"></span>
127
- </label>
128
  <?php
129
  $message_headline = ( isset( $message_data['headline'] ) ) ? $message_data['headline'] : $default_message_title;
130
  ?>
131
- <input type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][headline]" id="message_title" value="<?php echo esc_attr( $message_headline ); ?>" data-headline="<?php echo $message_title_key; ?>"/>
132
- <a class="button message_headline_button tips" data-tip="<?php _e( 'Give Me Another Headline', 'icegram' ); ?>">
133
- <span class="headline-buttons-icon admin_field_icon"></span>
134
- </a>
135
- </p>
136
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['icon'] ) ?>">
137
- <label for="upload_image" class="message_label">
138
- <strong><?php _e( 'Icon / Avatar Image', 'icegram' ); ?></strong>
139
- <span class="help_tip admin_field_icon" data-tip="<?php _e( 'This image will appear in message content.', 'icegram' ); ?>"></span>
140
- </label>
141
- <input id="upload_image" type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][icon]" value="<?php if ( isset( $message_data['icon'] ) ) {
142
  echo esc_attr( $message_data['icon'] );
143
  } ?>"/>
144
- <a class="button message_image_button tips" data-tip="<?php _e( 'Upload / Select an image', 'icegram' ); ?>" onclick="tb_show('<?php _e( 'Upload / Select Image' ); ?>', 'media-upload.php?type=image&TB_iframe=true', false);">
145
- <span class="image-buttons-icon admin_field_icon"></span>
146
- </a>
147
- </p>
148
 
149
  <?php
150
  $editor_args = array(
@@ -155,11 +155,11 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
155
  'tinymce' => true
156
  );
157
  ?>
158
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['message'] ) ?>">
159
- <style type="text/css">.wp-editor-tools:after {
160
- display: inline-block !important;
161
- }</style>
162
- <label for="message_body" class="message_body message_label"><strong><?php _e( 'Message Body', 'icegram' ); ?></strong></label>
163
  <?php
164
  $message = ( ! empty( $message_data['message'] ) ) ? $message_data['message'] : '';
165
  //TODO :: check need of exit-redirect Type
@@ -169,26 +169,26 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
169
  ?>
170
 
171
  <?php wp_editor( $message, 'edit' . $message_id, $editor_args ); ?>
172
- </p>
173
  <?php foreach ( $icegram->message_types as $message ) {
174
  if ( empty( $message['settings']['animation']['values'] ) ) {
175
  continue;
176
  }
177
  $animations = $message['settings']['animation']['values']
178
  ?>
179
- <p class="message_row <?php echo "ig_" . $message['type']; ?>">
180
- <label for="message_animation_<?php echo $message['type'] ?>" class="message_label"><strong><?php _e( 'Animation', 'icegram' ); ?></strong></label>
181
- <select id="message_animation_<?php echo $message['type'] ?>" name="message_data[<?php echo $message_id; ?>][animation][<?php echo $message['type'] ?>]" class="icegram_chosen_page message_animation message_animation_<?php echo $message['type']; ?>">
182
  <?php asort( $animations );
183
  $animations = array( 'no-anim' => 'No Animation' ) + $animations;
184
  foreach ( $animations as $value => $label ) { ?>
185
- <option value="<?php echo esc_attr( $value ) ?>" <?php echo ( ! empty( $message_data['animation'] ) && esc_attr( $value ) == $message_data['animation'] ) ? 'selected' : ''; ?>><?php echo esc_html( $label ) ?></option>
186
  <?php } ?>
187
- </select>
188
- </p>
189
  <?php } ?>
190
 
191
- <!-- Embed Form options -->
192
 
193
  <?php
194
 
@@ -202,175 +202,175 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
202
  $form_layouts = $this->message_form_layouts_to_show();
203
  $default_form_layout = ! empty( $icegram->message_types[ $message_data['type'] ]['settings']['form_layout']['default'] ) ? $icegram->message_types[ $message_data['type'] ]['settings']['form_layout']['default'] : '';
204
  $use_form_check = ( ! empty( $message_data['use_form'] ) )
205
- ? checked( $message_data['use_form'], 'yes', 0 )
206
- : '';
207
  $show_form_options = empty( $use_form_check ) ? 'style="display:none;"' : '';
208
  ?>
209
- <p class="message_row message_form_options_check <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>" message_id="<?php echo $message_id; ?>">
210
- <label for="message_use_form" class="message_label"><strong><?php _e( 'Form', 'icegram' ); ?></strong></label> <label>
211
- <input class="show_form_options" type="checkbox" name="message_data[<?php echo $message_id; ?>][use_form]" id="message_use_form" value="yes" <?php echo $use_form_check ?>/> <?php _e( 'Use Opt-in / Subscription / Lead capture form', 'icegram' ); ?></label>
212
- </p>
213
-
214
- <div class="message_form_options" <?php echo $show_form_options; ?> message_id="<?php echo $message_id; ?>">
215
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
216
- <label for="message_form_style" class="message_label">&nbsp;</label>
217
- <select id="message_form_style" name="message_data[<?php echo $message_id; ?>][form_style]" class="icegram_chosen_page message_form_style ">
218
- <?php
219
- $available_form_styles = $this->available_form_styles();
220
- foreach ( $available_form_styles as $style ) {
221
- $bg_img = "background-image: url(" . $icegram->plugin_url . '/assets/images/' . strtolower( str_replace( ' ', '_', $style['name'] ) ) . ".png)";
222
- ?>
223
- <option style="<?php echo $bg_img; ?>" <?php echo ( ! empty( $message_data['form_style'] ) && strtolower( str_replace( ' ', '_', $style['name'] ) ) == $message_data['form_style'] ) ? 'selected' : ''; ?> value="<?php echo esc_attr( strtolower( str_replace( ' ', '_', $style['name'] ) ) ) ?>"
224
- class="<?php echo strtolower( str_replace( ' ', '_', $style['name'] ) ) ?>" <?php echo ( ! empty( $message_data['form_style'] ) && esc_attr( strtolower( $style['name'] ) ) == $message_data['form_style'] ) ? 'selected' : ''; ?>><?php echo esc_html( $style['name'] ) ?></option>
225
- <?php } ?>
226
- </select>
227
- </p>
228
-
229
- <p class="form_layouts message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
230
- <label for="message_form_layouts" class="message_label">&nbsp;</label>
231
- <div class="form_radio_group">
232
- <span class="location <?php if ( ! empty( $form_layouts['left'] ) ) {
233
- echo "ig_" . implode( ' ig_', $form_layouts['left'] );
234
- } ?>">
235
- <label style="background-position:0px 23px;" for="form_layout_left_<?php echo $message_id; ?>" title="<?php _e( 'Left', 'icegram' ); ?>">
236
- <input class="message_form_layout" type="radio" id="form_layout_left_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
237
- value="left" <?php echo ( ! empty( $message_data['form_layout'] ) && "left" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "left" == $default_form_layout ? 'checked' : '' ); ?> />
238
- <?php _e( 'Left', 'icegram' ); ?>
239
- </label>
240
- </span>
241
-
242
- <span class="location <?php if ( ! empty( $form_layouts['right'] ) ) {
243
- echo "ig_" . implode( ' ig_', $form_layouts['right'] );
244
- } ?>">
245
  <label style="background-position:-100px 23px;" for="form_layout_right_<?php echo $message_id; ?>" title="<?php _e( 'Right', 'icegram' ); ?>">
246
- <input class="message_form_layout" type="radio" id="form_layout_right_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
247
- value="right" <?php echo ( ! empty( $message_data['form_layout'] ) && "right" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "right" == $default_form_layout ? 'checked' : '' ); ?> />
248
- <?php _e( 'Right', 'icegram' ); ?>
249
  </label>
250
  </span>
251
 
252
- <span class="location <?php if ( ! empty( $form_layouts['bottom'] ) ) {
253
- echo "ig_" . implode( ' ig_', $form_layouts['bottom'] );
254
- } ?>">
255
- <label style="background-position:-200px 23px;" for="form_layout_bottom_<?php echo $message_id; ?>" title="<?php _e( 'Bottom', 'icegram' ); ?>">
256
  <input class="message_form_layout" type="radio" id="form_layout_bottom_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
257
- value="bottom" <?php echo ( ! empty( $message_data['form_layout'] ) && "bottom" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "bottom" == $default_form_layout ? 'checked' : '' ); ?> />
258
  <?php _e( 'Bottom', 'icegram' ); ?>
259
- </label>
260
- </span>
261
 
262
  <?php
263
  $inline_position_checked = ( ! empty( $message_data['form_layout'] ) && "inline" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "inline" == $default_form_layout ? 'checked' : '' );
264
  $show_color_options = ! empty( $inline_position_checked ) ? 'style="display:none;"' : '';
265
  ?>
266
- <span class="location <?php if ( ! empty( $form_layouts['inline'] ) ) {
267
  echo "ig_" . implode( ' ig_', $form_layouts['inline'] );
268
  } ?>">
269
- <label style="background-position:-300px 23px;" for="form_layout_inline_<?php echo $message_id; ?>" title="<?php _e( 'Inline', 'icegram' ); ?>">
270
- <input class="message_form_layout" type="radio" id="form_layout_inline_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]" value="inline" <?php echo $inline_position_checked; ?> />
271
- <?php _e( 'Inline', 'icegram' ); ?>
272
- </label>
273
- </span>
274
- </div>
275
 
276
- </p>
277
- <?php
278
 
279
- $color_field_html = '<p class="message_form_color message_row ig_"' . implode( ' ig_', $settings['embed_form'] ) . '" ' . $show_color_options . '>
280
- <label for="message_form_bg_color" class="message_label">&nbsp;</label>
281
- <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 . '" />
282
- <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" />
283
- </p>';
284
- echo $color_field_html;
285
- $active_plugins = get_option( 'active_plugins', array() );
286
- if ( is_multisite() ) {
287
- $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
288
- }
289
 
290
- ?>
291
 
292
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
293
- <label class="message_label">&nbsp;</label>
294
- <textarea class="message_field message_form_header" rows="2" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_header]" id="" value="" placeholder="<?php _e( 'Text / HTML to show before the form', 'icegram' ); ?>"><?php echo esc_attr( $form_header ); ?></textarea>
295
- </p>
296
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
297
- <label class="message_label">&nbsp;</label>
298
- <?php
299
- $form_embed_html = '';
300
- $force_use_rm = false;
301
- $es_current_version = '3.5.18';
302
- $is_es_active = false;
303
-
304
- if ( in_array( 'email-subscribers/email-subscribers.php', $active_plugins ) ) {
305
- $es_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers/email-subscribers.php' );
306
- $es_current_version = ! empty( $es_plugin_meta_data['Version'] ) ? $es_plugin_meta_data['Version'] : '';
307
- $is_es_active = true;
308
- }
309
 
310
- if ( in_array( 'email-subscribers-premium/email-subscribers-premium.php', $active_plugins ) ) {
311
- $es_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers-premium/email-subscribers-premium.php' );
312
- $es_current_version = ! empty( $es_plugin_meta_data['Version'] ) ? $es_plugin_meta_data['Version'] : '';
313
- $is_es_active = true;
314
- }
315
 
316
- $force_use_rm = ( version_compare( $es_current_version, '4.0', '<' ) ) ? true : false;
317
 
318
  //Add Rainmaker form
319
- $rm_html = __( "Add form embed code" ) . '<strong>' . __( " or easily embed using ", "icegram" ) . '<a style="font-style:normal;" href="' . admin_url( "plugin-install.php?tab=search&type=term&s=icegram-rainmaker" ) . '" target="_blank" alt="Rainmaker - Forms, Leads and CRM">Icegram\'s Rainmaker' . '</a> plugin </strong>';
320
- $rm_html = ( true === $force_use_rm ) ? $rm_html : '';
321
- $hide_embed = '';
322
- if ( in_array( 'icegram-rainmaker/icegram-rainmaker.php', $active_plugins ) && ( ! empty( $message_data["rainmaker_form_code"] ) || $force_use_rm ) ) {
323
- $rainmaker_form_list = Rainmaker::get_rm_form_id_name_map();
324
- $rm_html = __( "Use Rainmaker form ", "icegram" );
325
- $rm_html .= '<select class="rainmaker_form_list" style="max-width:30%" name="message_data[' . $message_id . '][rainmaker_form_code]">
326
- <option value="" selected>' . __( "Select form ", "icegram" ) . '</option>';
327
- foreach ( $rainmaker_form_list as $id => $name ) {
328
- $rm_html .= '<option ' . ( ( ! empty( $message_data["rainmaker_form_code"] ) && $id == $message_data["rainmaker_form_code"] ) ? 'selected' : '' ) . ' value="' . $id . '">' . $name . '</option>';
329
- }
330
- $rm_html .= '</select><span style="font-style:italic">' . __( ' or add ', 'icegram' ) . '<a class="embed_form_code_toggle" style="cursor: pointer;">' . __( 'form embed code', 'icegram' ) . '</a></span>';
331
- $hide_embed = ( empty( $message_data["rainmaker_form_code"] ) && ! empty( $form_html_original ) ) ? '' : 'style="display:none"';
332
- $form_embed_html = $rm_html;
333
- }
334
 
335
  //Add Email Subscribers form
336
- $es_html = __( "Add form embed code" ) . '<strong>' . __( " or easily embed using ", "icegram" ) . '<a style="font-style:normal;" href="' . admin_url( "plugin-install.php?tab=search&type=term&s=email-subscribers" ) . '" target="_blank" alt="Email Subscribers & Newsletters">Email Subscribers & Newsletters' . '</a> plugin </strong>';
337
- if ( $is_es_active && ! $force_use_rm ) {
338
- $forms_db = new ES_DB_Forms();
339
- $es_form_list = call_user_func( array( $forms_db, 'get_forms_id_name_map' ) );
340
- $es_html = __( "Use Email Subscribers form ", "icegram" );
341
- $es_html .= '<select class="es_form_list" style="max-width:30%" name="message_data[' . $message_id . '][es_form_code]">
342
- <option value="" selected>' . __( "Select form ", "icegram" ) . '</option>';
343
- foreach ( $es_form_list as $id => $name ) {
344
- $es_html .= '<option ' . ( ( ! empty( $message_data["es_form_code"] ) && $id == $message_data["es_form_code"] ) ? 'selected' : '' ) . ' value="' . $id . '">' . $name . '</option>';
345
- }
346
- $es_html .= '</select><span style="font-style:italic">' . __( ' or add ', 'icegram' ) . '<a class="embed_form_code_toggle" style="cursor: pointer;">' . __( 'form embed code', 'icegram' ) . '</a></span>';
347
- $hide_embed = ( empty( $message_data["es_form_code"] ) && ! empty( $form_html_original ) ) ? '' : 'style="display:none"';
348
- }
349
- $form_embed_html = ! empty( $rm_html ) ? $rm_html : $es_html;
350
- ?>
351
- <label class="message_label">&nbsp;</label>
352
- <span class="message_label" style="padding-bottom:.3em"> <?php echo $form_embed_html; ?></span>
353
- <label class="message_label">&nbsp;</label>
354
- <textarea class="message_field message_form_html_original" <?php echo $hide_embed ?> rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_html_original]" id="message_form_html_original_<?php echo $message_id; ?>" value=""
355
- placeholder="<?php _e( 'Paste HTML / shortcode of your form here...', 'icegram' ); ?>"><?php if ( isset( $form_html_original ) ) {
356
- echo esc_attr( $form_html_original );
357
- } ?></textarea>
358
- <br>
359
- <label class="message_label">&nbsp;</label>
360
- <label style="font-size:.9em;"><input class="message_form_has_label" type="checkbox" name="message_data[<?php echo $message_id; ?>][form_has_label]" value="yes" <?php echo $form_has_label ?> />
361
- <?php _e( 'Show labels above fields', 'icegram' ); ?></label>
362
- </p>
363
-
364
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
365
- <label class="message_label">&nbsp;</label>
366
- <textarea class="message_field message_form_footer" rows="2" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_footer]" id="" value="" placeholder="<?php _e( 'Text / HTML to show after the form', 'icegram' ); ?>"><?php echo esc_attr( $form_footer ); ?></textarea>
367
- </p>
368
- <div class="form_inline_shortcode campaign_shortcode light message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>" style="font-size:.9em;display:inline;">
369
  <?php echo __( 'Insert <code>[ig_form]</code> where you want to show this form in message body.', 'icegram' ); ?>
370
- </div>
371
- </div>
372
 
373
- <!-- Embed Form options : End -->
374
 
375
  <?php
376
 
@@ -378,24 +378,24 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
378
  $show_only_link = array_diff( $settings['link'], $settings['label'] );
379
 
380
  ?>
381
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $show_cta_actions ) ?>">
382
- <label for="message_label" class="message_label">
383
- <strong>
384
- <span class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"> <?php _e( 'Call To Action', 'icegram' ); ?> </span>
385
- <span class="message_row <?php echo "ig_" . implode( ' ig_', $show_only_link ) ?>"> <?php _e( 'Call To Action', 'icegram' ); ?> </span>
386
- </strong>
387
- </label>
388
- <span class="message_row option_title <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"><?php _e( "Main Call To Action Button", "icegram" ); ?></span>
389
- </p>
390
-
391
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>">
392
- <label for="message_label" class="message_label"> &nbsp;
393
- <span class="help_tip admin_field_icon" data-tip="<?php _e( 'Your call to action text. Something unusual will increase conversions.', 'icegram' ); ?>"></span>
394
- </label><span class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"><span class="message_label sub_option_label"><?php _e( "Label", "icegram" ); ?></span>
395
  <input type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][label]" id="message_label" value="<?php if ( isset( $message_data['label'] ) ) {
396
  echo esc_attr( $message_data['label'] );
397
  } ?>"/> </span>
398
- </p>
399
 
400
  <?php
401
  do_action( 'icegram_after_button_label', $message_id, $message_data );
@@ -403,33 +403,33 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
403
  <?php
404
 
405
  $target_link_field = '<p class="message_row ig_' . implode( ' ig_', $settings['link'] ) . '">
406
- <span class="message_row ig_' . implode( ' ig_', $settings['label'] ) . '">
407
- <label for="message_link" class="message_label">&nbsp;
408
- <span class="help_tip admin_field_icon" data-tip="' . __( 'Enter destination URL here. Clicking will redirect to this link.', 'icegram' ) . '"></span>
409
- </label>
410
- </span>
411
- <span class="message_row ig_' . implode( ' ig_', $show_only_link ) . '">
412
- <span style="float:left" class="help_tip admin_field_icon" data-tip="' . __( 'Enter destination URL here. Clicking will redirect to this link.', 'icegram' ) . '"></span>
413
- </span>
414
- <span class="message_label sub_option_label">' . __( "Target Link", "icegram" ) . '</span>
415
- <input type="text" class="message_field message_link" name="message_data[' . $message_id . '][link]"
416
- id="message_link" value="' . esc_attr( ( isset( $message_data['link'] ) ? $message_data['link'] : '' ) ) . '" />
417
- </p>';
418
 
419
  $target_link_field .= '<p class="message_row ig_' . implode( ' ig_', $settings["link"] ) . '">
420
- <label for="message" class="message_label">&nbsp;</label>
421
- <label style="color:#BBB;">&nbsp;<input type="checkbox" disabled checked="checked"/>' . __( "Open in new tab ", "icegram" ) . '</label>
422
- <span>
423
- <a href="https://www.icegram.com/documentation/how-to-open-cta-link-in-a-new-tab-using-icegram/?utm_source=ig_field&utm_medium=ig_inapp_promo&utm_campaign=ig_inapp_promo" target="_blank">' . __( "How to do this?", "icegram" ) . '</a>
424
- </span>
425
- </p>';
426
  $icegram_message_target_link = apply_filters( 'icegram_message_field_link', array( 'html' => $target_link_field, 'message_id' => $message_id, 'message_data' => $message_data, 'settings' => $settings ) );
427
  echo $icegram_message_target_link['html'];
428
  ?>
429
- <p class="message_row <?php echo "ig_" . implode( ' ig_', $show_cta_actions ) ?>">
430
- <label for="message_label" class="message_label"> &nbsp;</label>
431
- <span class="ig_admin_hr">&nbsp;</span>
432
- </p>
433
 
434
  <?php
435
  $text_color = ( ! empty( $message_data['text_color'] ) ) ? $message_data['text_color'] : '';
@@ -437,36 +437,36 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
437
  $cta_bg_color = ( ! empty( $message_data['cta_bg_color'] ) ) ? $message_data['cta_bg_color'] : '';
438
  $cta_text_color = ( ! empty( $message_data['cta_text_color'] ) ) ? $message_data['cta_text_color'] : '';
439
  $colors_options_check = ( ! empty( $message_data['use_theme_defaults'] ) )
440
- ? checked( $message_data['use_theme_defaults'], 'yes', 0 )
441
- : ( ( ! empty( $bg_color ) || ! empty( $text_color ) || ! empty( $cta_bg_color ) || ! empty( $cta_text_color ) ) ? '' : 'checked="checked"' );
442
 
443
  $show_color_options = ( ! empty( $colors_options_check ) ) ? 'style="display: none;"' : '';
444
  $color_field_html = '<p class="message_row ig_' . implode( ' ig_', $settings['bg_color'] ) . '">
445
- <label for="message_bg_color" class="message_label">&nbsp;</label>
446
- <span class="message_label sub_option_label" > ' . __( 'Body', 'icegram' ) . '</span>
447
- <input type="text" class="message_field color-field" data-color-label="' . __( 'Background', 'icegram' ) . '" name="message_data[' . $message_id . '][bg_color]" id="message_bg_color" value="' . $bg_color . '" />
448
- <input type="text" class="message_field color-field" data-color-label="' . __( 'Text', 'icegram' ) . '" name="message_data[' . $message_id . '][text_color]" id="message_text_color" value="' . $text_color . '" />
449
- </p>
450
- <p class="message_row ig_' . implode( ' ig_', $settings['label'] ) . '">
451
- <label for="message_cta_bg_color" class="message_label">&nbsp;</label>
452
- <span class="message_label sub_option_label" >' . __( 'Button', 'icegram' ) . '</span>
453
- <input type="text" class="message_field color-field" data-color-label="' . __( 'Background', 'icegram' ) . '" name="message_data[' . $message_id . '][cta_bg_color]" id="message_cta_bg_color" value="' . $cta_bg_color . '" />
454
- <input type="text" class="message_field color-field" data-color-label="' . __( 'Text', 'icegram' ) . '" name="message_data[' . $message_id . '][cta_text_color]" id="message_cta_text_color" value="' . $cta_text_color . '" />
455
- </p>';
456
  // </div>';
457
  $color_field = apply_filters( 'icegram_color_fields', array( 'html' => $color_field_html, 'message_id' => $message_id, 'message_data' => $message_data, 'settings' => $settings ) );
458
  $color_field_html = '<div class="message_colors_options_container" ' . $show_color_options . '>' . $color_field['html'] . '</div>';
459
 
460
  $colors_options_html = '<p class="message_row ig_' . implode( ' ig_', $settings['bg_color'] ) . '">
461
- <label for="message_use_theme_defaults" class="message_label"><strong>' . __( 'Colors', 'icegram' ) . '</strong></label> <label >
462
- <input class="show_color_options" type="checkbox" name="message_data[' . $message_id . '][use_theme_defaults]" id="message_use_theme_defaults" value="yes" ' . $colors_options_check . '/> ' . __( 'Use theme\'s default colors', 'icegram' ) . '</label> ' . $color_field_html . '
463
- </p>';
464
  echo $colors_options_html;
465
 
466
  ?>
467
- <p class="message_row position <?php echo "ig_" . implode( ' ig_', $settings['position'] ) ?>">
468
- <label for="message_position" class="message_label"><strong><?php _e( 'Position', 'icegram' ); ?></strong></label>
469
- <span class="message_field location-selector message_label">
470
  <input type="radio" id="radio01_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][position][ig_default]" value="00" <?php echo ( ! empty( $message_data['position'] ) && "00" == $message_data['position'] ) ? 'checked' : ''; ?> />
471
  <label for="radio01_<?php echo $message_id; ?>" title="Top Left">
472
  <span class="location <?php if ( ! empty( $positions['00'] ) ) {
@@ -522,366 +522,371 @@ if ( ! class_exists( 'Icegram_Message_Admin' ) ) {
522
  } ?> bottom right" data-position="bottom right"></span>
523
  </label>
524
  </span>
525
- </p>
526
  <?php
527
  do_action( 'icegram_after_message_settings', $message_id, $message_data );
528
  ?>
529
- <!-- Custom code -->
530
  <?php
531
- $dummy_css = '#ig_this_message .ig_headline{ /* font-size: 3em !important; */ }';
532
- $dummy_js = '<script type="text/javascript"> /* add your js code here */ </script>';
533
- $message_custom_css = ( ! empty( $message_data['custom_css'] ) ) ? $message_data['custom_css'] : $dummy_css;
534
- $message_custom_js = ( ! empty( $message_data['custom_js'] ) ) ? $message_data['custom_js'] : $dummy_js;
535
- $use_custom_code_check = ( ! empty( $message_data['use_custom_code'] ) )
536
- ? checked( $message_data['use_custom_code'], 'yes', 0 )
537
- : '';
538
- $show_custom_code_options = empty( $use_custom_code_check ) ? 'style="display:none;"' : '';
539
 
540
- ?>
541
- <p class="message_row message_custom_code_options_check <?php echo "ig_" . implode( ' ig_', $settings['custom_code'] ) ?>" message_id="<?php echo $message_id; ?>">
542
- <label for="message_custom_code" class="message_label"><strong><?php _e( 'Custom Code', 'icegram' ); ?></strong></label>
543
- <label><input class="show_custom_code_options" type="checkbox" name="message_data[<?php echo $message_id; ?>][use_custom_code]" id="message_use_custom_code" value="yes" <?php echo $use_custom_code_check ?>/> <?php _e( 'Add custom code for this message', 'icegram' ); ?></label>
544
- </p>
545
- <div class="message_custom_code_options" <?php echo $show_custom_code_options; ?> message_id="<?php echo $message_id; ?>">
546
- <label class="message_label">&nbsp;</label>
547
- <span class="message_label"> <?php _e( 'CSS', 'icegram' ); ?></span>
548
- <br>
549
- <label class="message_label">&nbsp;</label>
550
- <textarea class="message_field message_custom_css" rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][custom_css]" id="message_message_custom_css_<?php echo $message_id; ?>" value=""
551
- placeholder="<?php //_e('Add Custom CSS for this message here...', 'icegram' ); ?>"><?php if ( isset( $message_custom_css ) ) {
552
- echo esc_attr( $message_custom_css );
553
- } ?></textarea>
554
- <br>
555
- <label class="message_label">&nbsp;</label>
556
- <span class="message_label"> <?php _e( 'JS', 'icegram' ); ?></span>
557
- <br>
558
- <label class="message_label">&nbsp;</label>
559
- <textarea class="message_field message_custom_js" rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][custom_js]" id="message_message_custom_js_<?php echo $message_id; ?>" value=""
560
- placeholder="<?php _e( 'Add Custom javaScript for this message here...', 'icegram' ); ?>"><?php if ( isset( $message_custom_js ) ) {
561
  echo esc_attr( $message_custom_js );
562
  } ?></textarea>
563
- </div>
564
-
565
- <!-- Custom code : End -->
566
- </div>
567
- <input type="hidden" name="message_data[<?php echo $message_id; ?>][id]" value="<?php echo $message_id; ?>">
568
- <input type="hidden" class="message_id" name="message_id" value="<?php echo $message_id; ?>">
569
- <?php
570
 
571
- if ( ! empty( $action['message_id'] ) ) {
572
- ?></div>
 
 
573
  <?php
574
- } else {
575
 
576
- ?>
577
- <p class="message_row">
578
- <label class="message_label">&nbsp;</label>
579
- <span>
580
- <span class="shortcode_description admin_field_icon"></span>
581
- <?php
582
- echo sprintf( __( 'You may add <code>[%s]</code> where you want to show this message.', 'icegram' ), 'icegram messages="' . $post->ID . '"' );
583
- ?>
584
- </span></p>
585
- <?php
586
- }
587
 
588
- }
 
 
 
 
 
 
 
 
 
 
 
 
589
 
590
  // Used to save the settings which are being made in the message form and added to message page appropriately
591
- function update_message_settings( $post_id, $post ) {
592
 
593
- if ( empty( $post_id ) || empty( $post ) || empty( $_POST['message_data'] ) || empty( $_POST['message_data'][ $post_id ] ) ) {
594
- return;
595
- }
596
- if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
597
- return;
598
- }
599
- if ( is_int( wp_is_post_revision( $post ) ) ) {
600
- return;
601
- }
602
- if ( is_int( wp_is_post_autosave( $post ) ) ) {
603
- return;
604
- }
605
- if ( empty( $_POST['icegram_message_meta_nonce'] ) || ! wp_verify_nonce( $_POST['icegram_message_meta_nonce'], 'icegram_message_save_data' ) ) {
606
- return;
607
- }
608
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
609
- return;
610
- }
611
- if ( $post->post_type != 'ig_message' ) {
612
- return;
613
- }
614
 
615
- $message_data = $_POST['message_data'][ $post_id ];
616
- $type = $message_data['type'];
617
 
618
- if ( isset( $message_data['theme'][ $type ] ) ) {
619
- $message_data['theme'] = $message_data['theme'][ $type ];
620
- } else {
621
- unset( $message_data['theme'] );
622
- }
623
- if ( isset( $message_data['animation'][ $type ] ) ) {
624
- $message_data['animation'] = $message_data['animation'][ $type ];
625
- } else {
626
- unset( $message_data['animation'] );
627
- }
628
- if ( isset( $message_data['position'][ $type ] ) ) {
629
- $message_data['position'] = $message_data['position'][ $type ];
630
- } elseif ( isset( $message_data['position']['ig_default'] ) ) {
631
- $message_data['position'] = $message_data['position']['ig_default'];
632
- }
 
 
 
 
 
633
 
634
- $message_data = apply_filters( 'icegram_update_message_data', $message_data, $post_id );
635
- update_post_meta( $post_id, 'icegram_message_data', $message_data );
636
- update_post_meta( $post_id, 'icegram_message_preview_data', $message_data );
637
 
638
- }
639
 
640
  // Additionally save message body content in post_content of post table
641
- function save_message_in_post_content( $post_data ) {
642
 
643
- if ( ! empty( $_POST['post_type'] ) && $_POST['post_type'] == 'ig_message' && ! empty( $_POST['message_data'] ) ) {
644
- $message_id = $_POST['ID'];
645
- $post_data['post_content'] = $_POST['message_data'][ $message_id ]['message'];
646
 
647
- if ( isset( $_POST['message_data'][ $message_id ]['post_title'] ) ) {
648
 
649
- if ( ! empty( $_POST['message_data'][ $message_id ]['post_title'] ) ) {
650
- $post_data['post_title'] = $_POST['message_data'][ $message_id ]['post_title'];
651
- } else {
652
- $post_data['post_title'] = $_POST['message_data'][ $message_id ]['headline'];
 
 
 
653
  }
654
 
 
655
  }
656
- }
657
-
658
- return $post_data;
659
- }
660
 
661
  // Add message columns to message dashboard
662
- function edit_columns( $existing_columns ) {
663
 
664
- $date = $existing_columns['date'];
665
- unset( $existing_columns['date'] );
666
 
667
- $existing_columns['message_type'] = __( 'Type', 'icegram' );
668
- $existing_columns['message_theme'] = __( 'Theme', 'icegram' );
669
- $existing_columns['message_thumbnail'] = __( 'Thumbnail', 'icegram' );
670
- $existing_columns['date'] = $date;
671
 
672
- return apply_filters( 'icegram_manage_message_columns', $existing_columns );
673
 
674
- }
675
 
676
  // Add message columns data to message dashboard
677
- function custom_columns( $column ) {
678
- global $post, $icegram;
679
 
680
- if ( ( is_object( $post ) && $post->post_type != 'ig_message' ) ) {
681
- return;
682
- }
683
 
684
- $message_data = get_post_meta( $post->ID, 'icegram_message_data', true );
685
- if ( empty( $message_data['type'] ) ) {
686
- return;
687
- }
688
- $class_name = 'Icegram_Message_Type_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $message_data['type'] ) ) );
689
- if ( ! class_exists( $class_name ) ) {
690
- return;
691
- }
692
- $type = ucwords( str_replace( "-", ' ', $message_data['type'] ) );
693
- $theme = ucwords( str_replace( "-", ' ', $message_data['theme'] ) );
694
 
695
- $bg_img = $icegram->message_types[ $message_data['type'] ]['themes'][ $message_data['theme'] ]['baseurl'] . $message_data['theme'] . ".png";
696
 
697
- switch ( $column ) {
698
- case 'message_type':
699
- echo esc_attr( $type );
700
- break;
701
 
702
- case 'message_theme':
703
- echo esc_attr( $theme );
704
- break;
705
 
706
- case 'message_thumbnail':
707
  // echo "<img src='$bg_img' style='max-width: 200px; max-height: 100px;'>";
708
- echo "<img src='" . esc_attr( $bg_img ) . "' style='max-width: 100%; max-height: 100px;'>";
709
- break;
710
 
711
- default:
712
- do_action( 'icegram_manage_message_custom_column', $column, $message_data );
713
- break;
714
 
715
- }
716
 
717
- }
718
 
719
  // Create array for settings based on message types
720
- function message_settings_to_show() {
721
 
722
- global $icegram;
723
- $settings = array();
724
- foreach ( $icegram->message_types as $type => $value ) {
725
- foreach ( $value['settings'] as $setting => $property ) {
726
- $settings[ $setting ][] = $type;
727
- }
728
- }
729
 
730
- return apply_filters( 'icegram_message_settings_to_show', $settings );
731
 
732
- }
733
 
734
  // Create array for positions available for all message types
735
- function message_form_layouts_to_show() {
736
 
737
- global $icegram;
738
- $form_layouts = array();
739
- foreach ( $icegram->message_types as $type => $value ) {
740
- if ( empty( $value['settings']['form_layout'] ) ) {
741
- continue;
742
- }
743
 
744
- if ( ! empty( $value['settings']['form_layout']['values'] ) ) {
745
- foreach ( $value['settings']['form_layout']['values'] as $form_layout ) {
746
- $form_layouts[ $form_layout ][] = $type;
 
 
747
  }
748
- }
749
- }
750
 
751
  // return apply_filters( 'icegram_message_form_layouts_to_show', $form_layouts );
752
- return $form_layouts;
753
 
754
- }
755
 
756
 
757
  // Create array for positions available for all message types
758
- function message_positions_to_show() {
759
 
760
- global $icegram;
761
- $positions = array();
762
- foreach ( $icegram->message_types as $type => $value ) {
763
- if ( empty( $value['settings']['position'] ) ) {
764
- continue;
765
- }
766
 
767
- if ( ! empty( $value['settings']['position']['values'] ) ) {
768
- foreach ( $value['settings']['position']['values'] as $position ) {
769
- $positions[ $position ][] = $type;
 
 
770
  }
771
- }
772
- }
773
 
774
- return apply_filters( 'icegram_message_positions_to_show', $positions );
775
 
776
- }
777
 
778
  // Default message data for newly created message
779
- function default_message_data( $message_type = '' ) {
780
 
781
- global $icegram;
782
- $default_themes = array();
783
- foreach ( $icegram->message_types as $type => $value ) {
784
- if ( isset( $value['settings']['theme']['default'] ) ) {
785
- $default_themes[ $type ] = $value['settings']['theme']['default'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
786
  }
787
- }
788
- if ( ! empty( $message_type ) ) {
789
- $default_message = $icegram->message_types[ $message_type ];
790
- } else {
791
- $default_message = reset( $icegram->message_types );
792
- }
793
- $default_message_data = array(
794
- 'type' => $default_message['type'],
795
- 'position' => ( ! empty( $default_message['settings']['position']['values'][0] ) ) ? $default_message['settings']['position']['values'][0] : '',
796
- 'text_color' => ( ! empty( $default_message['settings']['text_color']['default'] ) ) ? $default_message['settings']['text_color']['default'] : '',
797
- 'bg_color' => ( ! empty( $default_message['settings']['bg_color']['default'] ) ) ? $default_message['settings']['bg_color']['default'] : '',
798
- 'theme' => $default_themes
799
- );
800
-
801
- return apply_filters( 'icegram_default_message_data', $default_message_data );
802
- }
803
 
804
  // Form styles for the form
805
  //TODO :: check this and do changes if required
806
- function available_form_styles() {
807
- $available_form_styles = array(
808
- array( 'name' => 'Style 0' ),
809
- array( 'name' => 'Style 1' ),
810
- array( 'name' => 'Style 2' ),
811
- array( 'name' => 'Style 3' ),
812
- array( 'name' => 'Style 4' )
813
- );
814
-
815
- return $available_form_styles;
816
- }
817
 
818
  // All headline to generate randomly for messages
819
- function available_headlines( $available_headlines = array() ) {
820
- $available_headlines = array_merge( $available_headlines, array(
821
- __( 'Here Is A Method That Is Helping ____ To ____', 'icegram' ),
822
- __( '__ Little Known Ways To ____', 'icegram' ),
823
- __( 'Get Rid Of ____ Once And For All', 'icegram' ),
824
- __( 'How To ____ So You Can ____', 'icegram' ),
825
- __( 'They Didn\'t Think I Could ____, But I Did', 'icegram' ),
826
- __( 'How ____ Made Me ____', 'icegram' ),
827
- __( 'Are You ____ ?', 'icegram' ),
828
- __( 'Warning: ____ !', 'icegram' ),
829
- __( 'Do You Make These Mistakes With ____ ?', 'icegram' ),
830
- __( '7 Ways To ____', 'icegram' ),
831
- __( 'If You\'re ____, You Can ____', 'icegram' ),
832
- __( 'Turn your ____ into a ____', 'icegram' ),
833
- __( 'Want To Be A ____?', 'icegram' ),
834
- __( 'The Ugly Truth About Your Beautiful ____', 'icegram' ),
835
- __( 'The Secret to ____ Is Simply ____!', 'icegram' ),
836
- __( 'The Quickest Way I Know To ____', 'icegram' ),
837
- __( 'The Lazy Man\'s Way To ____', 'icegram' ),
838
- __( 'The Amazing Story Of ____ That Requires So Little Of ____ You Could ____', 'icegram' ),
839
- __( 'The Amazing Secret Of The ____ Genius Who Is Afraid Of ____', 'icegram' ),
840
- __( 'The 10 Wackiest Ideas That ____... And How You Can Too!', 'icegram' ),
841
- __( 'The Inside Secrets To ____ With Crazy, Outlandish And Outrageous ____', 'icegram' ),
842
- __( '____ Like A ____', 'icegram' ),
843
- __( 'Remember When You Could Have ____, And You Didn\'t?', 'icegram' ),
844
- __( 'Is The ____ Worth $x To You?', 'icegram' ),
845
- __( 'Increase your ____, reduce ____, maintain ____ and ____ with ____', 'icegram' ),
846
- __( 'If You Can ____ You Can ____', 'icegram' ),
847
- __( 'I Discovered How To ____... Now I\'m Revealing My Secret', 'icegram' ),
848
- __( 'How To Turn Your ____ Into The Most ____', 'icegram' ),
849
- __( 'How To Take The Headache Out Of ____', 'icegram' ),
850
- __( 'How To ____ ... Legally', 'icegram' ),
851
- __( 'How To ____ That ____', 'icegram' ),
852
- __( 'How To Discover The ____ That Lies Hidden In Your ____', 'icegram' ),
853
- __( 'How To ____ Even When Your Not ____', 'icegram' ),
854
- __( '____ With No ____!', 'icegram' ),
855
- __( 'Greatest Goldmine of ____ Ever Jammed Into One Big ____', 'icegram' ),
856
- __( 'Free ____ Tells How To Get Better ____', 'icegram' ),
857
- __( 'FREE ____ Worth $____ for the first 100 People to take Advantage of this Offer', 'icegram' ),
858
- __( 'Don\'t Try This With Any Other ____', 'icegram' ),
859
- __( 'Do You Honestly Want To ____?', 'icegram' ),
860
- __( 'Discover The Magic ____ That Will Bring You ____ & ____!', 'icegram' ),
861
- __( '____ Man Reveals A Short-Cut To ____', 'icegram' ),
862
- __( 'Confessions Of A ____', 'icegram' ),
863
- __( 'Are You Ready To ____?', 'icegram' ),
864
- __( 'An Open Letter To Everyone Who ____ More Than ____ Per ____', 'icegram' ),
865
- __( 'An Amazing ____ You Can Carry In Your ____', 'icegram' ),
866
- __( '21 Secret ____ that will ____... NOW!', 'icegram' )
867
- ) );
868
-
869
- return $available_headlines;
870
- }
871
 
872
- function add_message_action( $actions, $post ) {
873
- if ( $post->post_type != 'ig_message' ) {
874
- return $actions;
875
- }
876
- $actions['duplicate_message'] = '<a class="ig-duplicate-message" href="post.php?message_id=' . $post->ID . '&action=duplicate-message" >' . __( 'Duplicate', 'icegram' ) . '</a>';
877
 
878
- return $actions;
879
- }
880
 
881
- function duplicate_message() {
882
- if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'duplicate-message' && ! empty( $_REQUEST['message_id'] ) ) {
883
- Icegram::duplicate( $_REQUEST['message_id'] );
 
 
884
  }
885
- }
886
- }
887
- }
54
  }
55
  ?>
56
 
57
+ <style type="text/css">
58
+ <?php
59
+ foreach ( $icegram->message_types as $message_type => $message ) {
60
+ if( !empty( $message['admin_style'] ) ) {
61
+ $message_type = 'ig_'.$message_type;
62
+ $label_bg_color = $message['admin_style']['label_bg_color'];
63
+ $theme_header_height = (int)$message['admin_style']['theme_header_height'];
64
+ $theme_header_bg_size = ( $theme_header_height + 3 )."em";
65
+ $thumbnail_width = $message['admin_style']['thumbnail_width'];
66
+ $thumbnail_height = $message['admin_style']['thumbnail_height'];
67
+ echo " .message_header .$message_type {
68
+ background-color: {$label_bg_color};
69
+ }
70
+ .message_theme_{$message_type} + .chosen-container-single .chosen-single {
71
+ height: {$theme_header_height} !important;
 
 
 
 
 
 
 
 
 
72
  }
73
+ .message_theme_{$message_type} + .chosen-container-single .chosen-single span {
74
+ background-size: {$theme_header_bg_size} !important;
75
+ line-height: {$theme_header_height} !important;
76
+ }
77
+ .message_theme_{$message_type} + .chosen-container .chosen-results li {
78
+ width: {$thumbnail_width} !important;
79
+ height: {$thumbnail_height} !important;
80
+ }";
81
  }
82
+
83
+ }
84
  ?>
85
+ </style>
86
  <?php
87
  $message_id = ! empty( $action['message_id'] ) ? $action['message_id'] : $post->ID;
88
  $message_data = get_post_meta( $message_id, 'icegram_message_data', true );
109
  wp_nonce_field( 'icegram_message_save_data', 'icegram_message_meta_nonce' );
110
  if ( ! empty( $action['message_id'] ) ) {
111
  ?>
112
+ <div class="thickbox_edit_message" id="<?php echo $action['message_id']; ?>">
113
+ <?php
114
+ }
115
+ ?>
116
+ <div class="wp_attachment_details edit-form-section message-setting-fields">
117
+ <input id="message_type" class="message_type" name="message_data[<?php echo $message_id; ?>][type]" type="hidden" value="<?php echo esc_attr( $message_data['type'] ) ?>"></input>
118
+ <input id="message_theme_ig_<?php echo esc_attr( $message_data['type'] ) ?>" name="message_data[<?php echo $message_id; ?>][theme][<?php echo esc_attr( $message_data['type'] ) ?>]" type="hidden" value="<?php echo esc_attr( $message_data['theme'] ) ?>"></input>
119
  <?php // action add for interstitial message setting
120
  do_action( 'icegram_after_message_theme_settings', $message_id, $message_data );
121
  ?>
122
 
123
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['headline'] ) ?>">
124
+ <label for="message_headline" class="message_label">
125
+ <strong><?php _e( 'Headline', 'icegram' ); ?></strong>
126
+ <span class="help_tip admin_field_icon" data-tip="<?php _e( 'Shown with highest prominence. Click on idea button on right to get a new headline.', 'icegram' ); ?>"></span>
127
+ </label>
128
  <?php
129
  $message_headline = ( isset( $message_data['headline'] ) ) ? $message_data['headline'] : $default_message_title;
130
  ?>
131
+ <input type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][headline]" id="message_title" value="<?php echo esc_attr( $message_headline ); ?>" data-headline="<?php echo $message_title_key; ?>"/>
132
+ <a class="button message_headline_button tips" data-tip="<?php _e( 'Give Me Another Headline', 'icegram' ); ?>">
133
+ <span class="headline-buttons-icon admin_field_icon"></span>
134
+ </a>
135
+ </p>
136
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['icon'] ) ?>">
137
+ <label for="upload_image" class="message_label">
138
+ <strong><?php _e( 'Icon / Avatar Image', 'icegram' ); ?></strong>
139
+ <span class="help_tip admin_field_icon" data-tip="<?php _e( 'This image will appear in message content.', 'icegram' ); ?>"></span>
140
+ </label>
141
+ <input id="upload_image" type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][icon]" value="<?php if ( isset( $message_data['icon'] ) ) {
142
  echo esc_attr( $message_data['icon'] );
143
  } ?>"/>
144
+ <a class="button message_image_button tips" data-tip="<?php _e( 'Upload / Select an image', 'icegram' ); ?>" onclick="tb_show('<?php _e( 'Upload / Select Image' ); ?>', 'media-upload.php?type=image&TB_iframe=true', false);">
145
+ <span class="image-buttons-icon admin_field_icon"></span>
146
+ </a>
147
+ </p>
148
 
149
  <?php
150
  $editor_args = array(
155
  'tinymce' => true
156
  );
157
  ?>
158
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['message'] ) ?>">
159
+ <style type="text/css">.wp-editor-tools:after {
160
+ display: inline-block !important;
161
+ }</style>
162
+ <label for="message_body" class="message_body message_label"><strong><?php _e( 'Message Body', 'icegram' ); ?></strong></label>
163
  <?php
164
  $message = ( ! empty( $message_data['message'] ) ) ? $message_data['message'] : '';
165
  //TODO :: check need of exit-redirect Type
169
  ?>
170
 
171
  <?php wp_editor( $message, 'edit' . $message_id, $editor_args ); ?>
172
+ </p>
173
  <?php foreach ( $icegram->message_types as $message ) {
174
  if ( empty( $message['settings']['animation']['values'] ) ) {
175
  continue;
176
  }
177
  $animations = $message['settings']['animation']['values']
178
  ?>
179
+ <p class="message_row <?php echo "ig_" . $message['type']; ?>">
180
+ <label for="message_animation_<?php echo $message['type'] ?>" class="message_label"><strong><?php _e( 'Animation', 'icegram' ); ?></strong></label>
181
+ <select id="message_animation_<?php echo $message['type'] ?>" name="message_data[<?php echo $message_id; ?>][animation][<?php echo $message['type'] ?>]" class="icegram_chosen_page message_animation message_animation_<?php echo $message['type']; ?>">
182
  <?php asort( $animations );
183
  $animations = array( 'no-anim' => 'No Animation' ) + $animations;
184
  foreach ( $animations as $value => $label ) { ?>
185
+ <option value="<?php echo esc_attr( $value ) ?>" <?php echo ( ! empty( $message_data['animation'] ) && esc_attr( $value ) == $message_data['animation'] ) ? 'selected' : ''; ?>><?php echo esc_html( $label ) ?></option>
186
  <?php } ?>
187
+ </select>
188
+ </p>
189
  <?php } ?>
190
 
191
+ <!-- Embed Form options -->
192
 
193
  <?php
194
 
202
  $form_layouts = $this->message_form_layouts_to_show();
203
  $default_form_layout = ! empty( $icegram->message_types[ $message_data['type'] ]['settings']['form_layout']['default'] ) ? $icegram->message_types[ $message_data['type'] ]['settings']['form_layout']['default'] : '';
204
  $use_form_check = ( ! empty( $message_data['use_form'] ) )
205
+ ? checked( $message_data['use_form'], 'yes', 0 )
206
+ : '';
207
  $show_form_options = empty( $use_form_check ) ? 'style="display:none;"' : '';
208
  ?>
209
+ <p class="message_row message_form_options_check <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>" message_id="<?php echo $message_id; ?>">
210
+ <label for="message_use_form" class="message_label"><strong><?php _e( 'Form', 'icegram' ); ?></strong></label> <label>
211
+ <input class="show_form_options" type="checkbox" name="message_data[<?php echo $message_id; ?>][use_form]" id="message_use_form" value="yes" <?php echo $use_form_check ?>/> <?php _e( 'Use Opt-in / Subscription / Lead capture form', 'icegram' ); ?></label>
212
+ </p>
213
+
214
+ <div class="message_form_options" <?php echo $show_form_options; ?> message_id="<?php echo $message_id; ?>">
215
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
216
+ <label for="message_form_style" class="message_label">&nbsp;</label>
217
+ <select id="message_form_style" name="message_data[<?php echo $message_id; ?>][form_style]" class="icegram_chosen_page message_form_style ">
218
+ <?php
219
+ $available_form_styles = $this->available_form_styles();
220
+ foreach ( $available_form_styles as $style ) {
221
+ $bg_img = "background-image: url(" . $icegram->plugin_url . '/assets/images/' . strtolower( str_replace( ' ', '_', $style['name'] ) ) . ".png)";
222
+ ?>
223
+ <option style="<?php echo $bg_img; ?>" <?php echo ( ! empty( $message_data['form_style'] ) && strtolower( str_replace( ' ', '_', $style['name'] ) ) == $message_data['form_style'] ) ? 'selected' : ''; ?> value="<?php echo esc_attr( strtolower( str_replace( ' ', '_', $style['name'] ) ) ) ?>"
224
+ class="<?php echo strtolower( str_replace( ' ', '_', $style['name'] ) ) ?>" <?php echo ( ! empty( $message_data['form_style'] ) && esc_attr( strtolower( $style['name'] ) ) == $message_data['form_style'] ) ? 'selected' : ''; ?>><?php echo esc_html( $style['name'] ) ?></option>
225
+ <?php } ?>
226
+ </select>
227
+ </p>
228
+
229
+ <p class="form_layouts message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
230
+ <label for="message_form_layouts" class="message_label">&nbsp;</label>
231
+ <div class="form_radio_group">
232
+ <span class="location <?php if ( ! empty( $form_layouts['left'] ) ) {
233
+ echo "ig_" . implode( ' ig_', $form_layouts['left'] );
234
+ } ?>">
235
+ <label style="background-position:0px 23px;" for="form_layout_left_<?php echo $message_id; ?>" title="<?php _e( 'Left', 'icegram' ); ?>">
236
+ <input class="message_form_layout" type="radio" id="form_layout_left_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
237
+ value="left" <?php echo ( ! empty( $message_data['form_layout'] ) && "left" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "left" == $default_form_layout ? 'checked' : '' ); ?> />
238
+ <?php _e( 'Left', 'icegram' ); ?>
239
+ </label>
240
+ </span>
241
+
242
+ <span class="location <?php if ( ! empty( $form_layouts['right'] ) ) {
243
+ echo "ig_" . implode( ' ig_', $form_layouts['right'] );
244
+ } ?>">
245
  <label style="background-position:-100px 23px;" for="form_layout_right_<?php echo $message_id; ?>" title="<?php _e( 'Right', 'icegram' ); ?>">
246
+ <input class="message_form_layout" type="radio" id="form_layout_right_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
247
+ value="right" <?php echo ( ! empty( $message_data['form_layout'] ) && "right" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "right" == $default_form_layout ? 'checked' : '' ); ?> />
248
+ <?php _e( 'Right', 'icegram' ); ?>
249
  </label>
250
  </span>
251
 
252
+ <span class="location <?php if ( ! empty( $form_layouts['bottom'] ) ) {
253
+ echo "ig_" . implode( ' ig_', $form_layouts['bottom'] );
254
+ } ?>">
255
+ <label style="background-position:-200px 23px;" for="form_layout_bottom_<?php echo $message_id; ?>" title="<?php _e( 'Bottom', 'icegram' ); ?>">
256
  <input class="message_form_layout" type="radio" id="form_layout_bottom_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]"
257
+ value="bottom" <?php echo ( ! empty( $message_data['form_layout'] ) && "bottom" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "bottom" == $default_form_layout ? 'checked' : '' ); ?> />
258
  <?php _e( 'Bottom', 'icegram' ); ?>
259
+ </label>
260
+ </span>
261
 
262
  <?php
263
  $inline_position_checked = ( ! empty( $message_data['form_layout'] ) && "inline" == $message_data['form_layout'] ) ? 'checked' : ( empty( $message_data['form_layout'] ) && "inline" == $default_form_layout ? 'checked' : '' );
264
  $show_color_options = ! empty( $inline_position_checked ) ? 'style="display:none;"' : '';
265
  ?>
266
+ <span class="location <?php if ( ! empty( $form_layouts['inline'] ) ) {
267
  echo "ig_" . implode( ' ig_', $form_layouts['inline'] );
268
  } ?>">
269
+ <label style="background-position:-300px 23px;" for="form_layout_inline_<?php echo $message_id; ?>" title="<?php _e( 'Inline', 'icegram' ); ?>">
270
+ <input class="message_form_layout" type="radio" id="form_layout_inline_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][form_layout]" value="inline" <?php echo $inline_position_checked; ?> />
271
+ <?php _e( 'Inline', 'icegram' ); ?>
272
+ </label>
273
+ </span>
274
+ </div>
275
 
276
+ </p>
277
+ <?php
278
 
279
+ $color_field_html = '<p class="message_form_color message_row ig_"' . implode( ' ig_', $settings['embed_form'] ) . '" ' . $show_color_options . '>
280
+ <label for="message_form_bg_color" class="message_label">&nbsp;</label>
281
+ <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 . '" />
282
+ <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" />
283
+ </p>';
284
+ echo $color_field_html;
285
+ $active_plugins = get_option( 'active_plugins', array() );
286
+ if ( is_multisite() ) {
287
+ $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
288
+ }
289
 
290
+ ?>
291
 
292
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
293
+ <label class="message_label">&nbsp;</label>
294
+ <textarea class="message_field message_form_header" rows="2" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_header]" id="" value="" placeholder="<?php _e( 'Text / HTML to show before the form', 'icegram' ); ?>"><?php echo esc_attr( $form_header ); ?></textarea>
295
+ </p>
296
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
297
+ <label class="message_label">&nbsp;</label>
298
+ <?php
299
+ $form_embed_html = '';
300
+ $force_use_rm = false;
301
+ $es_current_version = '3.5.18';
302
+ $is_es_active = false;
303
+
304
+ if ( in_array( 'email-subscribers/email-subscribers.php', $active_plugins ) ) {
305
+ $es_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers/email-subscribers.php' );
306
+ $es_current_version = ! empty( $es_plugin_meta_data['Version'] ) ? $es_plugin_meta_data['Version'] : '';
307
+ $is_es_active = true;
308
+ }
309
 
310
+ if ( in_array( 'email-subscribers-premium/email-subscribers-premium.php', $active_plugins ) ) {
311
+ $es_plugin_meta_data = get_plugin_data( WP_PLUGIN_DIR . '/email-subscribers-premium/email-subscribers-premium.php' );
312
+ $es_current_version = ! empty( $es_plugin_meta_data['Version'] ) ? $es_plugin_meta_data['Version'] : '';
313
+ $is_es_active = true;
314
+ }
315
 
316
+ $force_use_rm = ( version_compare( $es_current_version, '4.0', '<' ) ) ? true : false;
317
 
318
  //Add Rainmaker form
319
+ $rm_html = __( "Add form embed code" ) . '<strong>' . __( " or easily embed using ", "icegram" ) . '<a style="font-style:normal;" href="' . admin_url( "plugin-install.php?tab=search&type=term&s=icegram-rainmaker" ) . '" target="_blank" alt="Rainmaker - Forms, Leads and CRM">Icegram\'s Rainmaker' . '</a> plugin </strong>';
320
+ $rm_html = ( true === $force_use_rm ) ? $rm_html : '';
321
+ $hide_embed = '';
322
+ if ( in_array( 'icegram-rainmaker/icegram-rainmaker.php', $active_plugins ) && ( ! empty( $message_data["rainmaker_form_code"] ) || $force_use_rm ) ) {
323
+ $rainmaker_form_list = Rainmaker::get_rm_form_id_name_map();
324
+ $rm_html = __( "Use Rainmaker form ", "icegram" );
325
+ $rm_html .= '<select class="rainmaker_form_list" style="max-width:30%" name="message_data[' . $message_id . '][rainmaker_form_code]">
326
+ <option value="" selected>' . __( "Select form ", "icegram" ) . '</option>';
327
+ foreach ( $rainmaker_form_list as $id => $name ) {
328
+ $rm_html .= '<option ' . ( ( ! empty( $message_data["rainmaker_form_code"] ) && $id == $message_data["rainmaker_form_code"] ) ? 'selected' : '' ) . ' value="' . $id . '">' . $name . '</option>';
329
+ }
330
+ $rm_html .= '</select><span style="font-style:italic">' . __( ' or add ', 'icegram' ) . '<a class="embed_form_code_toggle" style="cursor: pointer;">' . __( 'form embed code', 'icegram' ) . '</a></span>';
331
+ $hide_embed = ( empty( $message_data["rainmaker_form_code"] ) && ! empty( $form_html_original ) ) ? '' : 'style="display:none"';
332
+ $form_embed_html = $rm_html;
333
+ }
334
 
335
  //Add Email Subscribers form
336
+ $es_html = __( "Add form embed code" ) . '<strong>' . __( " or easily embed using ", "icegram" ) . '<a style="font-style:normal;" href="' . admin_url( "plugin-install.php?tab=search&type=term&s=email-subscribers" ) . '" target="_blank" alt="Email Subscribers & Newsletters">Email Subscribers & Newsletters' . '</a> plugin </strong>';
337
+ if ( $is_es_active && ! $force_use_rm ) {
338
+ $forms_db = new ES_DB_Forms();
339
+ $es_form_list = call_user_func( array( $forms_db, 'get_forms_id_name_map' ) );
340
+ $es_html = __( "Use Email Subscribers form ", "icegram" );
341
+ $es_html .= '<select class="es_form_list" style="max-width:30%" name="message_data[' . $message_id . '][es_form_code]">
342
+ <option value="" selected>' . __( "Select form ", "icegram" ) . '</option>';
343
+ foreach ( $es_form_list as $id => $name ) {
344
+ $es_html .= '<option ' . ( ( ! empty( $message_data["es_form_code"] ) && $id == $message_data["es_form_code"] ) ? 'selected' : '' ) . ' value="' . $id . '">' . $name . '</option>';
345
+ }
346
+ $es_html .= '</select><span style="font-style:italic">' . __( ' or add ', 'icegram' ) . '<a class="embed_form_code_toggle" style="cursor: pointer;">' . __( 'form embed code', 'icegram' ) . '</a></span>';
347
+ $hide_embed = ( empty( $message_data["es_form_code"] ) && ! empty( $form_html_original ) ) ? '' : 'style="display:none"';
348
+ }
349
+ $form_embed_html = ! empty( $rm_html ) ? $rm_html : $es_html;
350
+ ?>
351
+ <label class="message_label">&nbsp;</label>
352
+ <span class="message_label" style="padding-bottom:.3em"> <?php echo $form_embed_html; ?></span>
353
+ <label class="message_label">&nbsp;</label>
354
+ <textarea class="message_field message_form_html_original" <?php echo $hide_embed ?> rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_html_original]" id="message_form_html_original_<?php echo $message_id; ?>" value=""
355
+ placeholder="<?php _e( 'Paste HTML / shortcode of your form here...', 'icegram' ); ?>"><?php if ( isset( $form_html_original ) ) {
356
+ echo esc_attr( $form_html_original );
357
+ } ?></textarea>
358
+ <br>
359
+ <label class="message_label">&nbsp;</label>
360
+ <label style="font-size:.9em;"><input class="message_form_has_label" type="checkbox" name="message_data[<?php echo $message_id; ?>][form_has_label]" value="yes" <?php echo $form_has_label ?> />
361
+ <?php _e( 'Show labels above fields', 'icegram' ); ?></label>
362
+ </p>
363
+
364
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>">
365
+ <label class="message_label">&nbsp;</label>
366
+ <textarea class="message_field message_form_footer" rows="2" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][form_footer]" id="" value="" placeholder="<?php _e( 'Text / HTML to show after the form', 'icegram' ); ?>"><?php echo esc_attr( $form_footer ); ?></textarea>
367
+ </p>
368
+ <div class="form_inline_shortcode campaign_shortcode light message_row <?php echo "ig_" . implode( ' ig_', $settings['embed_form'] ) ?>" style="font-size:.9em;display:inline;">
369
  <?php echo __( 'Insert <code>[ig_form]</code> where you want to show this form in message body.', 'icegram' ); ?>
370
+ </div>
371
+ </div>
372
 
373
+ <!-- Embed Form options : End -->
374
 
375
  <?php
376
 
378
  $show_only_link = array_diff( $settings['link'], $settings['label'] );
379
 
380
  ?>
381
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $show_cta_actions ) ?>">
382
+ <label for="message_label" class="message_label">
383
+ <strong>
384
+ <span class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"> <?php _e( 'Call To Action', 'icegram' ); ?> </span>
385
+ <span class="message_row <?php echo "ig_" . implode( ' ig_', $show_only_link ) ?>"> <?php _e( 'Call To Action', 'icegram' ); ?> </span>
386
+ </strong>
387
+ </label>
388
+ <span class="message_row option_title <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"><?php _e( "Main Call To Action Button", "icegram" ); ?></span>
389
+ </p>
390
+
391
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>">
392
+ <label for="message_label" class="message_label"> &nbsp;
393
+ <span class="help_tip admin_field_icon" data-tip="<?php _e( 'Your call to action text. Something unusual will increase conversions.', 'icegram' ); ?>"></span>
394
+ </label><span class="message_row <?php echo "ig_" . implode( ' ig_', $settings['label'] ) ?>"><span class="message_label sub_option_label"><?php _e( "Label", "icegram" ); ?></span>
395
  <input type="text" class="message_field" name="message_data[<?php echo $message_id; ?>][label]" id="message_label" value="<?php if ( isset( $message_data['label'] ) ) {
396
  echo esc_attr( $message_data['label'] );
397
  } ?>"/> </span>
398
+ </p>
399
 
400
  <?php
401
  do_action( 'icegram_after_button_label', $message_id, $message_data );
403
  <?php
404
 
405
  $target_link_field = '<p class="message_row ig_' . implode( ' ig_', $settings['link'] ) . '">
406
+ <span class="message_row ig_' . implode( ' ig_', $settings['label'] ) . '">
407
+ <label for="message_link" class="message_label">&nbsp;
408
+ <span class="help_tip admin_field_icon" data-tip="' . __( 'Enter destination URL here. Clicking will redirect to this link.', 'icegram' ) . '"></span>
409
+ </label>
410
+ </span>
411
+ <span class="message_row ig_' . implode( ' ig_', $show_only_link ) . '">
412
+ <span style="float:left" class="help_tip admin_field_icon" data-tip="' . __( 'Enter destination URL here. Clicking will redirect to this link.', 'icegram' ) . '"></span>
413
+ </span>
414
+ <span class="message_label sub_option_label">' . __( "Target Link", "icegram" ) . '</span>
415
+ <input type="text" class="message_field message_link" name="message_data[' . $message_id . '][link]"
416
+ id="message_link" value="' . esc_attr( ( isset( $message_data['link'] ) ? $message_data['link'] : '' ) ) . '" />
417
+ </p>';
418
 
419
  $target_link_field .= '<p class="message_row ig_' . implode( ' ig_', $settings["link"] ) . '">
420
+ <label for="message" class="message_label">&nbsp;</label>
421
+ <label style="color:#BBB;">&nbsp;<input type="checkbox" disabled checked="checked"/>' . __( "Open in new tab ", "icegram" ) . '</label>
422
+ <span>
423
+ <a href="https://www.icegram.com/documentation/how-to-open-cta-link-in-a-new-tab-using-icegram/?utm_source=ig_field&utm_medium=ig_inapp_promo&utm_campaign=ig_inapp_promo" target="_blank">' . __( "How to do this?", "icegram" ) . '</a>
424
+ </span>
425
+ </p>';
426
  $icegram_message_target_link = apply_filters( 'icegram_message_field_link', array( 'html' => $target_link_field, 'message_id' => $message_id, 'message_data' => $message_data, 'settings' => $settings ) );
427
  echo $icegram_message_target_link['html'];
428
  ?>
429
+ <p class="message_row <?php echo "ig_" . implode( ' ig_', $show_cta_actions ) ?>">
430
+ <label for="message_label" class="message_label"> &nbsp;</label>
431
+ <span class="ig_admin_hr">&nbsp;</span>
432
+ </p>
433
 
434
  <?php
435
  $text_color = ( ! empty( $message_data['text_color'] ) ) ? $message_data['text_color'] : '';
437
  $cta_bg_color = ( ! empty( $message_data['cta_bg_color'] ) ) ? $message_data['cta_bg_color'] : '';
438
  $cta_text_color = ( ! empty( $message_data['cta_text_color'] ) ) ? $message_data['cta_text_color'] : '';
439
  $colors_options_check = ( ! empty( $message_data['use_theme_defaults'] ) )
440
+ ? checked( $message_data['use_theme_defaults'], 'yes', 0 )
441
+ : ( ( ! empty( $bg_color ) || ! empty( $text_color ) || ! empty( $cta_bg_color ) || ! empty( $cta_text_color ) ) ? '' : 'checked="checked"' );
442
 
443
  $show_color_options = ( ! empty( $colors_options_check ) ) ? 'style="display: none;"' : '';
444
  $color_field_html = '<p class="message_row ig_' . implode( ' ig_', $settings['bg_color'] ) . '">
445
+ <label for="message_bg_color" class="message_label">&nbsp;</label>
446
+ <span class="message_label sub_option_label" > ' . __( 'Body', 'icegram' ) . '</span>
447
+ <input type="text" class="message_field color-field" data-color-label="' . __( 'Background', 'icegram' ) . '" name="message_data[' . $message_id . '][bg_color]" id="message_bg_color" value="' . $bg_color . '" />
448
+ <input type="text" class="message_field color-field" data-color-label="' . __( 'Text', 'icegram' ) . '" name="message_data[' . $message_id . '][text_color]" id="message_text_color" value="' . $text_color . '" />
449
+ </p>
450
+ <p class="message_row ig_' . implode( ' ig_', $settings['label'] ) . '">
451
+ <label for="message_cta_bg_color" class="message_label">&nbsp;</label>
452
+ <span class="message_label sub_option_label" >' . __( 'Button', 'icegram' ) . '</span>
453
+ <input type="text" class="message_field color-field" data-color-label="' . __( 'Background', 'icegram' ) . '" name="message_data[' . $message_id . '][cta_bg_color]" id="message_cta_bg_color" value="' . $cta_bg_color . '" />
454
+ <input type="text" class="message_field color-field" data-color-label="' . __( 'Text', 'icegram' ) . '" name="message_data[' . $message_id . '][cta_text_color]" id="message_cta_text_color" value="' . $cta_text_color . '" />
455
+ </p>';
456
  // </div>';
457
  $color_field = apply_filters( 'icegram_color_fields', array( 'html' => $color_field_html, 'message_id' => $message_id, 'message_data' => $message_data, 'settings' => $settings ) );
458
  $color_field_html = '<div class="message_colors_options_container" ' . $show_color_options . '>' . $color_field['html'] . '</div>';
459
 
460
  $colors_options_html = '<p class="message_row ig_' . implode( ' ig_', $settings['bg_color'] ) . '">
461
+ <label for="message_use_theme_defaults" class="message_label"><strong>' . __( 'Colors', 'icegram' ) . '</strong></label> <label >
462
+ <input class="show_color_options" type="checkbox" name="message_data[' . $message_id . '][use_theme_defaults]" id="message_use_theme_defaults" value="yes" ' . $colors_options_check . '/> ' . __( 'Use theme\'s default colors', 'icegram' ) . '</label> ' . $color_field_html . '
463
+ </p>';
464
  echo $colors_options_html;
465
 
466
  ?>
467
+ <p class="message_row position <?php echo "ig_" . implode( ' ig_', $settings['position'] ) ?>">
468
+ <label for="message_position" class="message_label"><strong><?php _e( 'Position', 'icegram' ); ?></strong></label>
469
+ <span class="message_field location-selector message_label">
470
  <input type="radio" id="radio01_<?php echo $message_id; ?>" name="message_data[<?php echo $message_id; ?>][position][ig_default]" value="00" <?php echo ( ! empty( $message_data['position'] ) && "00" == $message_data['position'] ) ? 'checked' : ''; ?> />
471
  <label for="radio01_<?php echo $message_id; ?>" title="Top Left">
472
  <span class="location <?php if ( ! empty( $positions['00'] ) ) {
522
  } ?> bottom right" data-position="bottom right"></span>
523
  </label>
524
  </span>
525
+ </p>
526
  <?php
527
  do_action( 'icegram_after_message_settings', $message_id, $message_data );
528
  ?>
529
+ <!-- Custom code -->
530
  <?php
531
+ $dummy_css = '#ig_this_message .ig_headline{ /* font-size: 3em !important; */ }';
532
+ $dummy_js = '<script type="text/javascript"> /* add your js code here */ </script>';
533
+ $message_custom_css = ( ! empty( $message_data['custom_css'] ) ) ? $message_data['custom_css'] : $dummy_css;
534
+ $message_custom_js = ( ! empty( $message_data['custom_js'] ) ) ? $message_data['custom_js'] : $dummy_js;
535
+ $use_custom_code_check = ( ! empty( $message_data['use_custom_code'] ) )
536
+ ? checked( $message_data['use_custom_code'], 'yes', 0 )
537
+ : '';
538
+ $show_custom_code_options = empty( $use_custom_code_check ) ? 'style="display:none;"' : '';
539
 
540
+ ?>
541
+ <p class="message_row message_custom_code_options_check <?php echo "ig_" . implode( ' ig_', $settings['custom_code'] ) ?>" message_id="<?php echo $message_id; ?>">
542
+ <label for="message_custom_code" class="message_label"><strong><?php _e( 'Custom Code', 'icegram' ); ?></strong></label>
543
+ <label><input class="show_custom_code_options" type="checkbox" name="message_data[<?php echo $message_id; ?>][use_custom_code]" id="message_use_custom_code" value="yes" <?php echo $use_custom_code_check ?>/> <?php _e( 'Add custom code for this message', 'icegram' ); ?></label>
544
+ </p>
545
+ <div class="message_custom_code_options" <?php echo $show_custom_code_options; ?> message_id="<?php echo $message_id; ?>">
546
+ <label class="message_label">&nbsp;</label>
547
+ <span class="message_label"> <?php _e( 'CSS', 'icegram' ); ?></span>
548
+ <br>
549
+ <label class="message_label">&nbsp;</label>
550
+ <textarea class="message_field message_custom_css" rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][custom_css]" id="message_message_custom_css_<?php echo $message_id; ?>" value=""
551
+ placeholder="<?php //_e('Add Custom CSS for this message here...', 'icegram' ); ?>"><?php if ( isset( $message_custom_css ) ) {
552
+ echo esc_attr( $message_custom_css );
553
+ } ?></textarea>
554
+ <br>
555
+ <label class="message_label">&nbsp;</label>
556
+ <span class="message_label"> <?php _e( 'JS', 'icegram' ); ?></span>
557
+ <br>
558
+ <label class="message_label">&nbsp;</label>
559
+ <textarea class="message_field message_custom_js" rows="6" autocomplete="off" cols="65" name="message_data[<?php echo $message_id; ?>][custom_js]" id="message_message_custom_js_<?php echo $message_id; ?>" value=""
560
+ placeholder="<?php _e( 'Add Custom javaScript for this message here...', 'icegram' ); ?>"><?php if ( isset( $message_custom_js ) ) {
561
  echo esc_attr( $message_custom_js );
562
  } ?></textarea>
563
+ </div>
 
 
 
 
 
 
564
 
565
+ <!-- Custom code : End -->
566
+ </div>
567
+ <input type="hidden" name="message_data[<?php echo $message_id; ?>][id]" value="<?php echo $message_id; ?>">
568
+ <input type="hidden" class="message_id" name="message_id" value="<?php echo $message_id; ?>">
569
  <?php
 
570
 
571
+ if ( ! empty( $action['message_id'] ) ) {
572
+ ?></div>
573
+ <?php
574
+ } else {
 
 
 
 
 
 
 
575
 
576
+ ?>
577
+ <p class="message_row">
578
+ <label class="message_label">&nbsp;</label>
579
+ <span>
580
+ <span class="shortcode_description admin_field_icon"></span>
581
+ <?php
582
+ echo sprintf( __( 'You may add <code>[%s]</code> where you want to show this message.', 'icegram' ), 'icegram messages="' . $post->ID . '"' );
583
+ ?>
584
+ </span></p>
585
+ <?php
586
+ }
587
+
588
+ }
589
 
590
  // Used to save the settings which are being made in the message form and added to message page appropriately
591
+ function update_message_settings( $post_id, $post ) {
592
 
593
+ if ( empty( $post_id ) || empty( $post ) || empty( $_POST['message_data'] ) || empty( $_POST['message_data'][ $post_id ] ) ) {
594
+ return;
595
+ }
596
+ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
597
+ return;
598
+ }
599
+ if ( is_int( wp_is_post_revision( $post ) ) ) {
600
+ return;
601
+ }
602
+ if ( is_int( wp_is_post_autosave( $post ) ) ) {
603
+ return;
604
+ }
605
+ if ( empty( $_POST['icegram_message_meta_nonce'] ) || ! wp_verify_nonce( $_POST['icegram_message_meta_nonce'], 'icegram_message_save_data' ) ) {
606
+ return;
607
+ }
608
+ if ( ! current_user_can( 'edit_post', $post_id ) ) {
609
+ return;
610
+ }
611
+ if ( $post->post_type != 'ig_message' ) {
612
+ return;
613
+ }
614
 
615
+ $message_data = $_POST['message_data'][ $post_id ];
616
+ $type = $message_data['type'];
617
 
618
+ if ( isset( $message_data['theme'][ $type ] ) ) {
619
+ $message_data['theme'] = $message_data['theme'][ $type ];
620
+ } else {
621
+ unset( $message_data['theme'] );
622
+ }
623
+ if ( isset( $message_data['animation'][ $type ] ) ) {
624
+ $message_data['animation'] = $message_data['animation'][ $type ];
625
+ } else {
626
+ unset( $message_data['animation'] );
627
+ }
628
+ if ( isset( $message_data['position'][ $type ] ) ) {
629
+ $message_data['position'] = $message_data['position'][ $type ];
630
+ } elseif ( isset( $message_data['position']['ig_default'] ) ) {
631
+ $message_data['position'] = $message_data['position']['ig_default'];
632
+ }
633
+ if( empty( $message_data['rainmaker_form_code'] ) && ! empty( $message_data['form_html_original'] ) && strpos( $message_data['form_html_original'], 'rainmaker_form') ) {
634
+ $rm_shortcode_pos = strpos($message_data['form_html_original'], '"')+1;
635
+ $rm_shortcode = substr($message_data['form_html_original'], $rm_shortcode_pos , strripos($message_data['form_html_original'], "\\") - $rm_shortcode_pos);
636
+ $message_data['rainmaker_form_code'] = $rm_shortcode ;
637
+ }
638
 
639
+ $message_data = apply_filters( 'icegram_update_message_data', $message_data, $post_id );
640
+ update_post_meta( $post_id, 'icegram_message_data', $message_data );
641
+ update_post_meta( $post_id, 'icegram_message_preview_data', $message_data );
642
 
643
+ }
644
 
645
  // Additionally save message body content in post_content of post table
646
+ function save_message_in_post_content( $post_data ) {
647
 
648
+ if ( ! empty( $_POST['post_type'] ) && $_POST['post_type'] == 'ig_message' && ! empty( $_POST['message_data'] ) ) {
649
+ $message_id = $_POST['ID'];
650
+ $post_data['post_content'] = $_POST['message_data'][ $message_id ]['message'];
651
 
652
+ if ( isset( $_POST['message_data'][ $message_id ]['post_title'] ) ) {
653
 
654
+ if ( ! empty( $_POST['message_data'][ $message_id ]['post_title'] ) ) {
655
+ $post_data['post_title'] = $_POST['message_data'][ $message_id ]['post_title'];
656
+ } else {
657
+ $post_data['post_title'] = $_POST['message_data'][ $message_id ]['headline'];
658
+ }
659
+
660
+ }
661
  }
662
 
663
+ return $post_data;
664
  }
 
 
 
 
665
 
666
  // Add message columns to message dashboard
667
+ function edit_columns( $existing_columns ) {
668
 
669
+ $date = $existing_columns['date'];
670
+ unset( $existing_columns['date'] );
671
 
672
+ $existing_columns['message_type'] = __( 'Type', 'icegram' );
673
+ $existing_columns['message_theme'] = __( 'Theme', 'icegram' );
674
+ $existing_columns['message_thumbnail'] = __( 'Thumbnail', 'icegram' );
675
+ $existing_columns['date'] = $date;
676
 
677
+ return apply_filters( 'icegram_manage_message_columns', $existing_columns );
678
 
679
+ }
680
 
681
  // Add message columns data to message dashboard
682
+ function custom_columns( $column ) {
683
+ global $post, $icegram;
684
 
685
+ if ( ( is_object( $post ) && $post->post_type != 'ig_message' ) ) {
686
+ return;
687
+ }
688
 
689
+ $message_data = get_post_meta( $post->ID, 'icegram_message_data', true );
690
+ if ( empty( $message_data['type'] ) ) {
691
+ return;
692
+ }
693
+ $class_name = 'Icegram_Message_Type_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $message_data['type'] ) ) );
694
+ if ( ! class_exists( $class_name ) ) {
695
+ return;
696
+ }
697
+ $type = ucwords( str_replace( "-", ' ', $message_data['type'] ) );
698
+ $theme = ucwords( str_replace( "-", ' ', $message_data['theme'] ) );
699
 
700
+ $bg_img = $icegram->message_types[ $message_data['type'] ]['themes'][ $message_data['theme'] ]['baseurl'] . $message_data['theme'] . ".png";
701
 
702
+ switch ( $column ) {
703
+ case 'message_type':
704
+ echo esc_attr( $type );
705
+ break;
706
 
707
+ case 'message_theme':
708
+ echo esc_attr( $theme );
709
+ break;
710
 
711
+ case 'message_thumbnail':
712
  // echo "<img src='$bg_img' style='max-width: 200px; max-height: 100px;'>";
713
+ echo "<img src='" . esc_attr( $bg_img ) . "' style='max-width: 100%; max-height: 100px;'>";
714
+ break;
715
 
716
+ default:
717
+ do_action( 'icegram_manage_message_custom_column', $column, $message_data );
718
+ break;
719
 
720
+ }
721
 
722
+ }
723
 
724
  // Create array for settings based on message types
725
+ function message_settings_to_show() {
726
 
727
+ global $icegram;
728
+ $settings = array();
729
+ foreach ( $icegram->message_types as $type => $value ) {
730
+ foreach ( $value['settings'] as $setting => $property ) {
731
+ $settings[ $setting ][] = $type;
732
+ }
733
+ }
734
 
735
+ return apply_filters( 'icegram_message_settings_to_show', $settings );
736
 
737
+ }
738
 
739
  // Create array for positions available for all message types
740
+ function message_form_layouts_to_show() {
741
 
742
+ global $icegram;
743
+ $form_layouts = array();
744
+ foreach ( $icegram->message_types as $type => $value ) {
745
+ if ( empty( $value['settings']['form_layout'] ) ) {
746
+ continue;
747
+ }
748
 
749
+ if ( ! empty( $value['settings']['form_layout']['values'] ) ) {
750
+ foreach ( $value['settings']['form_layout']['values'] as $form_layout ) {
751
+ $form_layouts[ $form_layout ][] = $type;
752
+ }
753
+ }
754
  }
 
 
755
 
756
  // return apply_filters( 'icegram_message_form_layouts_to_show', $form_layouts );
757
+ return $form_layouts;
758
 
759
+ }
760
 
761
 
762
  // Create array for positions available for all message types
763
+ function message_positions_to_show() {
764
 
765
+ global $icegram;
766
+ $positions = array();
767
+ foreach ( $icegram->message_types as $type => $value ) {
768
+ if ( empty( $value['settings']['position'] ) ) {
769
+ continue;
770
+ }
771
 
772
+ if ( ! empty( $value['settings']['position']['values'] ) ) {
773
+ foreach ( $value['settings']['position']['values'] as $position ) {
774
+ $positions[ $position ][] = $type;
775
+ }
776
+ }
777
  }
 
 
778
 
779
+ return apply_filters( 'icegram_message_positions_to_show', $positions );
780
 
781
+ }
782
 
783
  // Default message data for newly created message
784
+ function default_message_data( $message_type = '' ) {
785
 
786
+ global $icegram;
787
+ $default_themes = array();
788
+ foreach ( $icegram->message_types as $type => $value ) {
789
+ if ( isset( $value['settings']['theme']['default'] ) ) {
790
+ $default_themes[ $type ] = $value['settings']['theme']['default'];
791
+ }
792
+ }
793
+ if ( ! empty( $message_type ) ) {
794
+ $default_message = $icegram->message_types[ $message_type ];
795
+ } else {
796
+ $default_message = reset( $icegram->message_types );
797
+ }
798
+ $default_message_data = array(
799
+ 'type' => $default_message['type'],
800
+ 'position' => ( ! empty( $default_message['settings']['position']['values'][0] ) ) ? $default_message['settings']['position']['values'][0] : '',
801
+ 'text_color' => ( ! empty( $default_message['settings']['text_color']['default'] ) ) ? $default_message['settings']['text_color']['default'] : '',
802
+ 'bg_color' => ( ! empty( $default_message['settings']['bg_color']['default'] ) ) ? $default_message['settings']['bg_color']['default'] : '',
803
+ 'theme' => $default_themes
804
+ );
805
+
806
+ return apply_filters( 'icegram_default_message_data', $default_message_data );
807
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808
 
809
  // Form styles for the form
810
  //TODO :: check this and do changes if required
811
+ function available_form_styles() {
812
+ $available_form_styles = array(
813
+ array( 'name' => 'Style 0' ),
814
+ array( 'name' => 'Style 1' ),
815
+ array( 'name' => 'Style 2' ),
816
+ array( 'name' => 'Style 3' ),
817
+ array( 'name' => 'Style 4' )
818
+ );
819
+
820
+ return $available_form_styles;
821
+ }
822
 
823
  // All headline to generate randomly for messages
824
+ function available_headlines( $available_headlines = array() ) {
825
+ $available_headlines = array_merge( $available_headlines, array(
826
+ __( 'Here Is A Method That Is Helping ____ To ____', 'icegram' ),
827
+ __( '__ Little Known Ways To ____', 'icegram' ),
828
+ __( 'Get Rid Of ____ Once And For All', 'icegram' ),
829
+ __( 'How To ____ So You Can ____', 'icegram' ),
830
+ __( 'They Didn\'t Think I Could ____, But I Did', 'icegram' ),
831
+ __( 'How ____ Made Me ____', 'icegram' ),
832
+ __( 'Are You ____ ?', 'icegram' ),
833
+ __( 'Warning: ____ !', 'icegram' ),
834
+ __( 'Do You Make These Mistakes With ____ ?', 'icegram' ),
835
+ __( '7 Ways To ____', 'icegram' ),
836
+ __( 'If You\'re ____, You Can ____', 'icegram' ),
837
+ __( 'Turn your ____ into a ____', 'icegram' ),
838
+ __( 'Want To Be A ____?', 'icegram' ),
839
+ __( 'The Ugly Truth About Your Beautiful ____', 'icegram' ),
840
+ __( 'The Secret to ____ Is Simply ____!', 'icegram' ),
841
+ __( 'The Quickest Way I Know To ____', 'icegram' ),
842
+ __( 'The Lazy Man\'s Way To ____', 'icegram' ),
843
+ __( 'The Amazing Story Of ____ That Requires So Little Of ____ You Could ____', 'icegram' ),
844
+ __( 'The Amazing Secret Of The ____ Genius Who Is Afraid Of ____', 'icegram' ),
845
+ __( 'The 10 Wackiest Ideas That ____... And How You Can Too!', 'icegram' ),
846
+ __( 'The Inside Secrets To ____ With Crazy, Outlandish And Outrageous ____', 'icegram' ),
847
+ __( '____ Like A ____', 'icegram' ),
848
+ __( 'Remember When You Could Have ____, And You Didn\'t?', 'icegram' ),
849
+ __( 'Is The ____ Worth $x To You?', 'icegram' ),
850
+ __( 'Increase your ____, reduce ____, maintain ____ and ____ with ____', 'icegram' ),
851
+ __( 'If You Can ____ You Can ____', 'icegram' ),
852
+ __( 'I Discovered How To ____... Now I\'m Revealing My Secret', 'icegram' ),
853
+ __( 'How To Turn Your ____ Into The Most ____', 'icegram' ),
854
+ __( 'How To Take The Headache Out Of ____', 'icegram' ),
855
+ __( 'How To ____ ... Legally', 'icegram' ),
856
+ __( 'How To ____ That ____', 'icegram' ),
857
+ __( 'How To Discover The ____ That Lies Hidden In Your ____', 'icegram' ),
858
+ __( 'How To ____ Even When Your Not ____', 'icegram' ),
859
+ __( '____ With No ____!', 'icegram' ),
860
+ __( 'Greatest Goldmine of ____ Ever Jammed Into One Big ____', 'icegram' ),
861
+ __( 'Free ____ Tells How To Get Better ____', 'icegram' ),
862
+ __( 'FREE ____ Worth $____ for the first 100 People to take Advantage of this Offer', 'icegram' ),
863
+ __( 'Don\'t Try This With Any Other ____', 'icegram' ),
864
+ __( 'Do You Honestly Want To ____?', 'icegram' ),
865
+ __( 'Discover The Magic ____ That Will Bring You ____ & ____!', 'icegram' ),
866
+ __( '____ Man Reveals A Short-Cut To ____', 'icegram' ),
867
+ __( 'Confessions Of A ____', 'icegram' ),
868
+ __( 'Are You Ready To ____?', 'icegram' ),
869
+ __( 'An Open Letter To Everyone Who ____ More Than ____ Per ____', 'icegram' ),
870
+ __( 'An Amazing ____ You Can Carry In Your ____', 'icegram' ),
871
+ __( '21 Secret ____ that will ____... NOW!', 'icegram' )
872
+ ) );
873
+
874
+ return $available_headlines;
875
+ }
876
 
877
+ function add_message_action( $actions, $post ) {
878
+ if ( $post->post_type != 'ig_message' ) {
879
+ return $actions;
880
+ }
881
+ $actions['duplicate_message'] = '<a class="ig-duplicate-message" href="post.php?message_id=' . $post->ID . '&action=duplicate-message" >' . __( 'Duplicate', 'icegram' ) . '</a>';
882
 
883
+ return $actions;
884
+ }
885
 
886
+ function duplicate_message() {
887
+ if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'duplicate-message' && ! empty( $_REQUEST['message_id'] ) ) {
888
+ Icegram::duplicate( $_REQUEST['message_id'] );
889
+ }
890
+ }
891
  }
892
+ }
 
 
classes/compat/class-icegram-compat-contact-form-7.php CHANGED
@@ -20,7 +20,8 @@ if ( !class_exists( 'Icegram_Compat_contact_form_7' ) ) {
20
  }
21
 
22
 
23
- function render_js() {
 
24
  ?>
25
 
26
  <style type="text/css">
@@ -82,10 +83,10 @@ jQuery(function() {
82
  }
83
 
84
  }); // init.icegram
85
-
86
  // Dismiss response text/div when shown within icegram form container
87
  jQuery('body').on('click', '.ig_form_container .wpcf7-response-output', function(e) {
88
- jQuery(e.target).slideUp();
89
  });
90
  // Handle CTA function(s) after successful submission of form
91
  jQuery( window ).on('wpcf7:mailsent', function(e) {
@@ -103,6 +104,7 @@ jQuery(function() {
103
  </script>
104
 
105
  <?php
 
106
  }
107
  }
108
  }
20
  }
21
 
22
 
23
+ function render_js( $type ) {
24
+ if( 'contact-form-7' === $type ){
25
  ?>
26
 
27
  <style type="text/css">
83
  }
84
 
85
  }); // init.icegram
86
+
87
  // Dismiss response text/div when shown within icegram form container
88
  jQuery('body').on('click', '.ig_form_container .wpcf7-response-output', function(e) {
89
+ jQuery(e.target).slideUp();
90
  });
91
  // Handle CTA function(s) after successful submission of form
92
  jQuery( window ).on('wpcf7:mailsent', function(e) {
104
  </script>
105
 
106
  <?php
107
+ }
108
  }
109
  }
110
  }
classes/compat/class-icegram-compat-gravityforms.php CHANGED
@@ -20,7 +20,8 @@ if ( !class_exists( 'Icegram_Compat_gravityforms' ) ) {
20
  }
21
  }
22
 
23
- function render_js() {
 
24
  ?>
25
 
26
  <style type="text/css">
@@ -43,6 +44,7 @@ jQuery(function() {
43
  </script>
44
 
45
  <?php
 
46
  }
47
  }
48
  }
20
  }
21
  }
22
 
23
+ function render_js( $type ) {
24
+ if( 'gravityform' === $type ){
25
  ?>
26
 
27
  <style type="text/css">
44
  </script>
45
 
46
  <?php
47
+ }
48
  }
49
  }
50
  }
classes/ig-upsale-admin.php CHANGED
@@ -7,6 +7,7 @@ if ( !class_exists( 'Icegram_upsale' ) ) {
7
  class Icegram_upsale {
8
  function __construct() {
9
  add_action( 'add_meta_boxes', array( &$this, 'add_campaigns_analytics_metaboxes' ), 0 );
 
10
  add_filter( 'icegram_campaign_tabs', array( &$this, 'add_upsale_tab' ), 10, 1 );
11
  add_action('icegram_after_message_settings', array($this,'display_bt_upsale'),10,2);
12
  add_filter('icegram_message_field_link' ,array(&$this, 'display_cta_upsale'));
@@ -16,30 +17,52 @@ if ( !class_exists( 'Icegram_upsale' ) ) {
16
  add_meta_box( 'campaign_stats_upsale', __( 'Statistics', 'icegram' ), array( &$this, 'print_campaign_image' ), 'ig_campaign', 'normal', 'high' );
17
  }
18
 
 
19
  function print_campaign_image(){
20
  global $icegram;
21
  ?>
22
- <a href="https://www.icegram.com/analytics/?utm_source=in_app&utm_medium=analytics&utm_campaign=ig_upsale" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/analytics.png"/></a>
23
  <?php
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  function add_upsale_tab( $tabs ){
27
- $tabs['nav']['upsale'] = '<li class="ig-admin-nav-upsale ig-admin-nav-notab"><a href="https://www.icegram.com/split-testing/?utm_source=in_app&utm_medium=split-testing&utm_campaign=ig_upsale" target="blank">Split testing<span style="font-size: 0.8em; margin-left: 0.3em; padding: 2px; background: #e66060; color: #fff; border-radius: 2px; ">Premium</span></a></li>';
28
  return $tabs;
29
  }
30
 
31
  function display_bt_upsale( $message_id, $message_data ){
32
  global $icegram;
33
  ?>
34
- <label class="message_label"><a class="ig_bt_upsale" href="https://www.icegram.com/exit-intent-optins/?utm_source=in_app&utm_medium=exit-intent&utm_campaign=ig_upsale" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/exit-intent-label.png"/></a></label>
35
- <a class="ig_bt_upsale" href="https://www.icegram.com/exit-intent-optins/?utm_source=in_app&utm_medium=exit-intent&utm_campaign=ig_upsale" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/exit-intent-feild.png"/></a>
36
  <?php
37
  }
38
 
39
  function display_cta_upsale( $params ){
40
  global $icegram;
41
  ?>
42
- <a class="ig_cta_upsale" href="https://www.icegram.com/cta-actions/?utm_source=in_app&utm_medium=cta&utm_campaign=ig_upsale" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/cta-new-tab.png"/></a>
43
  <?php
44
  return $params;
45
  }
7
  class Icegram_upsale {
8
  function __construct() {
9
  add_action( 'add_meta_boxes', array( &$this, 'add_campaigns_analytics_metaboxes' ), 0 );
10
+ add_action( 'add_meta_boxes', array( &$this, 'add_upsell_notice' ), 0 );
11
  add_filter( 'icegram_campaign_tabs', array( &$this, 'add_upsale_tab' ), 10, 1 );
12
  add_action('icegram_after_message_settings', array($this,'display_bt_upsale'),10,2);
13
  add_filter('icegram_message_field_link' ,array(&$this, 'display_cta_upsale'));
17
  add_meta_box( 'campaign_stats_upsale', __( 'Statistics', 'icegram' ), array( &$this, 'print_campaign_image' ), 'ig_campaign', 'normal', 'high' );
18
  }
19
 
20
+
21
  function print_campaign_image(){
22
  global $icegram;
23
  ?>
24
+ <a href="https://www.icegram.com/analytics/?utm_source=in_app&utm_medium=analytics&utm_campaign=ig_upsell" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/analytics.png"/></a>
25
  <?php
26
  }
27
 
28
+ /**
29
+ * Add Upsell Notice
30
+ *
31
+ * @since 1.10.40
32
+ */
33
+ function add_upsell_notice(){
34
+ add_meta_box( 'premium_upsale', __( 'Upgrade To Premium', 'icegram' ), array( &$this, 'print_premium_message' ), 'ig_campaign', 'side' );
35
+ }
36
+
37
+ /**
38
+ * Added Premium Notice
39
+ *
40
+ * @since 1.10.40
41
+ */
42
+ function print_premium_message() {
43
+
44
+ $pricing_url = "https://www.icegram.com/pricing/?utm_source=in_app&utm_medium=campaign_upgrade_notice&utm_campaign=ig_upsell";
45
+
46
+ echo "<a href='" . $pricing_url . "' target='_blank' >Upgrade to Icegram Premium now!</a> <br /><br />Use code <b style='color: green'>PREMIUM10</b> to get <b>flat 10% discount</b>";
47
+ }
48
+
49
  function add_upsale_tab( $tabs ){
50
+ $tabs['nav']['upsale'] = '<li class="ig-admin-nav-upsale ig-admin-nav-notab"><a href="https://www.icegram.com/split-testing/?utm_source=in_app&utm_medium=split-testing&utm_campaign=ig_upsell" target="blank">Split testing<span style="font-size: 0.8em; margin-left: 0.3em; padding: 2px; background: #e66060; color: #fff; border-radius: 2px; ">Premium</span></a></li>';
51
  return $tabs;
52
  }
53
 
54
  function display_bt_upsale( $message_id, $message_data ){
55
  global $icegram;
56
  ?>
57
+ <label class="message_label"><a class="ig_bt_upsale" href="https://www.icegram.com/exit-intent-optins/?utm_source=in_app&utm_medium=exit-intent&utm_campaign=ig_upsell" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/exit-intent-label.png"/></a></label>
58
+ <a class="ig_bt_upsale" href="https://www.icegram.com/exit-intent-optins/?utm_source=in_app&utm_medium=exit-intent&utm_campaign=ig_upsell" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/exit-intent-feild.png"/></a>
59
  <?php
60
  }
61
 
62
  function display_cta_upsale( $params ){
63
  global $icegram;
64
  ?>
65
+ <a class="ig_cta_upsale" href="https://www.icegram.com/cta-actions/?utm_source=in_app&utm_medium=cta&utm_campaign=ig_upsell" target="blank"><img src="<?php echo $icegram->plugin_url ?>/assets/images/cta-new-tab.png"/></a>
66
  <?php
67
  return $params;
68
  }
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.39
7
  * Author: icegram
8
  * Author URI: https://www.icegram.com/
9
  * Copyright (c) 2014-19 Icegram
@@ -38,7 +38,7 @@ class Icegram {
38
  $feedback_version = '1.2.2';
39
  $ig_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', $feedback_version );
40
 
41
- $this->version = "1.10.39";
42
  $this->shortcode_instances = array();
43
  $this->mode = 'local';
44
  $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
@@ -756,12 +756,10 @@ class Icegram {
756
  $icegram_pre_data['post_obj']['shortcodes'] = $this->shortcode_instances;
757
  $icegram_pre_data['post_obj']['cache_compatibility'] = $this->cache_compatibility;
758
  $icegram_pre_data['post_obj']['device'] = $this->get_platform();
 
 
 
759
 
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
 
@@ -795,6 +793,10 @@ class Icegram {
795
  return;
796
  }
797
 
 
 
 
 
798
  $messages_to_show_ids = array();
799
  foreach ( $messages as $key => $message_data ) {
800
 
@@ -857,7 +859,17 @@ class Icegram {
857
 
858
  do_action( 'icegram_print_js_css_data', $icegram_data );
859
 
860
- do_action( 'icegram_data_printed' );
 
 
 
 
 
 
 
 
 
 
861
  }
862
 
863
  function two_step_mobile_popup( $icegram_data ) {
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.40
7
  * Author: icegram
8
  * Author URI: https://www.icegram.com/
9
  * Copyright (c) 2014-19 Icegram
38
  $feedback_version = '1.2.2';
39
  $ig_tracker = 'IG_Tracker_V_' . str_replace( '.', '_', $feedback_version );
40
 
41
+ $this->version = "1.10.40";
42
  $this->shortcode_instances = array();
43
  $this->mode = 'local';
44
  $this->plugin_url = untrailingslashit( plugins_url( '/', __FILE__ ) );
756
  $icegram_pre_data['post_obj']['shortcodes'] = $this->shortcode_instances;
757
  $icegram_pre_data['post_obj']['cache_compatibility'] = $this->cache_compatibility;
758
  $icegram_pre_data['post_obj']['device'] = $this->get_platform();
759
+
760
+ wp_register_script( 'icegram_main_js', $this->plugin_url . '/assets/js/main.min.js', array( 'jquery' ), $this->version, true );
761
+ wp_localize_script( 'icegram_main_js', 'icegram_pre_data', $icegram_pre_data );
762
 
 
 
 
 
 
763
 
764
  }
765
 
793
  return;
794
  }
795
 
796
+ if ( ! wp_script_is('icegram_main_js')){
797
+ wp_enqueue_script( 'icegram_main_js');
798
+ }
799
+
800
  $messages_to_show_ids = array();
801
  foreach ( $messages as $key => $message_data ) {
802
 
859
 
860
  do_action( 'icegram_print_js_css_data', $icegram_data );
861
 
862
+
863
+ // Load CF7 & Garvity Forms CSS & JS only if form loaded
864
+ $compat_form_types = array( 'contact-form-7' , 'gravityform' );
865
+
866
+ foreach ( $icegram_data['messages'] as $message_id ) {
867
+ foreach ( $compat_form_types as $type ) {
868
+ if ( strpos( $message_id['form_html_original'] , $type )) {
869
+ do_action( 'icegram_data_printed' , $type );
870
+ }
871
+ }
872
+ }
873
  }
874
 
875
  function two_step_mobile_popup( $icegram_data ) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: icegram, storeapps, niravmehta, sandhyam, malayladu, putler
3
  Donate link: https://www.icegram.com/
4
  Tags: popup, optin, hellobar, 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.4
7
- Stable tag: 1.10.39
8
  License: GPLv3
9
 
10
  The best WP popup plugin that lets 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.
@@ -237,6 +237,11 @@ Contact Us, provide as much detail of the problem as you can. We will try to sol
237
 
238
  == Upgrade Notice ==
239
 
 
 
 
 
 
240
  **1.10.39**
241
 
242
  * Fix: Campaigns were not showing if display rules are set to role specific
@@ -609,6 +614,16 @@ Contact Us, provide as much detail of the problem as you can. We will try to sol
609
 
610
  == Changelog ==
611
 
 
 
 
 
 
 
 
 
 
 
612
  **1.10.38**
613
 
614
  * UI enhancements
3
  Donate link: https://www.icegram.com/
4
  Tags: popup, optin, hellobar, 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.4.1
7
+ Stable tag: 1.10.40
8
  License: GPLv3
9
 
10
  The best WP popup plugin that lets 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.
237
 
238
  == Upgrade Notice ==
239
 
240
+ **1.10.40**
241
+
242
+ * Update: Improve performance by loading JS/ CSS whenever required
243
+ * Fix: Rainmaker Shortcode issue
244
+
245
  **1.10.39**
246
 
247
  * Fix: Campaigns were not showing if display rules are set to role specific
614
 
615
  == Changelog ==
616
 
617
+ **1.10.40**
618
+
619
+ * Update: Improve performance by loading JS/ CSS whenever required
620
+ * Fix: Rainmaker Shortcode issue
621
+
622
+ **1.10.39**
623
+
624
+ * Fix: Campaigns were not showing if display rules are set to role specific
625
+ * Update: WordPress 5.4 compatibility test
626
+
627
  **1.10.38**
628
 
629
  * UI enhancements