Popups – WordPress Popup - Version 1.2.3

Version Description

  • Added Ajax mode in settings page to make popups compatible with cache plugins
  • Added a close button shortcode
  • Fixed bug with settings page
  • Fixed bug detecting triggered clicks on iphone 6
  • Some other minor bugfixes
Download this release

Release Info

Developer timersys
Plugin Icon 128x128 Popups – WordPress Popup
Version 1.2.3
Comparing to
See all releases

Code changes from version 1.2.2.1 to 1.2.3

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: timersys
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K4T6L69EV9G2Q
4
  Tags: twitter,google+, facebook,Popups, twitter follow, facebook like, google plus,social boost, social splash, popup, facebook popup, scroll popups, popups, wordpress popup, wp popups
5
  Requires at least: 3.6
6
- Tested up to: 4.0.1
7
- Stable tag: 1.2.2.1
8
  Text Domain: spucpt
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -13,10 +13,6 @@ Increase your followers ratio 40% with the new Popups - Multiple popup options,
13
 
14
  == Description ==
15
 
16
- > <strong>Black Friday Plus!</strong><br>
17
- >
18
- > Check our ([Black Friday Offer](https://wp.timersys.com/black-friday-plus/))
19
- >
20
 
21
  The new Popups plugin can display multiple popups. Is the perfect solution to increase your social followers, your mailing lists by adding a form like mailchimp or to display any important message in a simple popup.
22
 
@@ -41,6 +37,8 @@ There are multiple display filters that can be combined:
41
  * Change font color, background, borders, etc
42
  * You can also configure background opacity.
43
  * Days until popup shows again
 
 
44
 
45
  > <strong>Premium Version</strong><br>
46
  >
@@ -102,6 +100,18 @@ Yes if you need to debug you can use uncompressed javascript by addings ([this c
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  = 1.2.2.1 =
106
 
107
  * Fixed bug when images where used on popup
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K4T6L69EV9G2Q
4
  Tags: twitter,google+, facebook,Popups, twitter follow, facebook like, google plus,social boost, social splash, popup, facebook popup, scroll popups, popups, wordpress popup, wp popups
5
  Requires at least: 3.6
6
+ Tested up to: 4.1
7
+ Stable tag: 1.2.3
8
  Text Domain: spucpt
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
  == Description ==
15
 
 
 
 
 
16
 
17
  The new Popups plugin can display multiple popups. Is the perfect solution to increase your social followers, your mailing lists by adding a form like mailchimp or to display any important message in a simple popup.
18
 
37
  * Change font color, background, borders, etc
38
  * You can also configure background opacity.
39
  * Days until popup shows again
40
+ * Ajax mode to make popups cache compatible
41
+ * Shortcodes for social networks available
42
 
43
  > <strong>Premium Version</strong><br>
44
  >
100
 
101
  == Changelog ==
102
 
103
+ = 1.2.3 =
104
+
105
+ * Added Ajax mode in settings page to make popups compatible with cache plugins
106
+ * Added a close button shortcode
107
+ * Fixed bug with settings page
108
+ * Fixed bug detecting triggered clicks on iphone 6
109
+ * Some other minor bugfixes
110
+
111
+ = 1.2.2.2 =
112
+
113
+ * Improved and fixed generic form compatiblity and m4wp
114
+
115
  = 1.2.2.1 =
116
 
117
  * Fixed bug when images where used on popup
admin/class-social-popup-admin.php CHANGED
@@ -98,8 +98,9 @@ class SocialPopup_Admin {
98
 
99
  //Add our metaboxes
100
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
 
101
  //Save metaboxes
102
- add_action( 'save_post', array( $this, 'save_meta_options' ), 20 );
103
 
104
  // Load admin style sheet and JavaScript.
105
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
@@ -216,7 +217,17 @@ class SocialPopup_Admin {
216
  update_option( 'spu_settings' , esc_sql( @$_POST['spu_settings'] ) );
217
 
218
  }
219
- $opts = apply_filters('spu/settings_page/opts', get_option( 'spu_settings' ) );
 
 
 
 
 
 
 
 
 
 
220
 
221
  include 'views/settings-page.php';
222
 
@@ -376,9 +387,13 @@ class SocialPopup_Admin {
376
  }
377
 
378
  /**
379
- * Saves popup options and rules
380
- */
381
- public function save_meta_options( $post_id ) {
 
 
 
 
382
  // Verify that the nonce is set and valid.
383
  if ( !isset( $_POST['spu_options_nonce'] ) || ! wp_verify_nonce( $_POST['spu_options_nonce'], 'spu_options' ) ) {
384
  return $post_id;
@@ -406,10 +421,11 @@ class SocialPopup_Admin {
406
  return $post_id;
407
  }
408
 
409
- $post = get_post( $post_id );
410
  $opts = $_POST['spu'];
411
  unset( $_POST['spu'] );
412
 
 
 
413
  // sanitize settings
414
  $opts['css']['width'] = sanitize_text_field( $opts['css']['width'] );
415
  $opts['css']['bgopacity'] = sanitize_text_field( $opts['css']['bgopacity'] );
@@ -417,6 +433,40 @@ class SocialPopup_Admin {
417
  $opts['cookie'] = absint( sanitize_text_field( $opts['cookie'] ) );
418
  $opts['trigger_number'] = absint( sanitize_text_field( $opts['trigger_number'] ) );
419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
 
421
  // save box settings
422
  update_post_meta( $post_id, 'spu_options', apply_filters( 'spu/metaboxes/sanitized_options', $opts ) );
@@ -424,8 +474,6 @@ class SocialPopup_Admin {
424
  // Start with rules
425
  if( isset($_POST['spu_rules']) && is_array($_POST['spu_rules']) )
426
  {
427
-
428
-
429
  // clean array keys
430
  $groups = array_values( $_POST['spu_rules'] );
431
  foreach($groups as $group_id => $group )
@@ -434,7 +482,7 @@ class SocialPopup_Admin {
434
  {
435
  // clean array keys
436
  $groups_a[] = array_values( $group );
437
-
438
  }
439
  }
440
 
@@ -442,7 +490,6 @@ class SocialPopup_Admin {
442
  unset( $_POST['spu_rules'] );
443
  }
444
 
445
- #$this->flush_rules();
446
  }
447
  /**
448
  * Register and enqueue admin-specific style sheet.
98
 
99
  //Add our metaboxes
100
  add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
101
+
102
  //Save metaboxes
103
+ add_action( 'save_post_spucpt', array( $this, 'save_meta_options' ), 20 );
104
 
105
  // Load admin style sheet and JavaScript.
106
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
217
  update_option( 'spu_settings' , esc_sql( @$_POST['spu_settings'] ) );
218
 
219
  }
220
+
221
+ $defaults = array(
222
+ 'debug' => '',
223
+ 'safe' => '',
224
+ 'shortcodes_style' => '',
225
+ 'facebook' => '',
226
+ 'google' => '',
227
+ 'twitter' => '',
228
+ );
229
+
230
+ $opts = apply_filters('spu/settings_page/opts', get_option( 'spu_settings', $defaults ) );
231
 
232
  include 'views/settings-page.php';
233
 
387
  }
388
 
389
  /**
390
+ * Saves popup options and rules
391
+ *
392
+ * @param $post_id
393
+ * @param $post
394
+ * @param $update
395
+ */
396
+ public function save_meta_options( $post_id ) {
397
  // Verify that the nonce is set and valid.
398
  if ( !isset( $_POST['spu_options_nonce'] ) || ! wp_verify_nonce( $_POST['spu_options_nonce'], 'spu_options' ) ) {
399
  return $post_id;
421
  return $post_id;
422
  }
423
 
 
424
  $opts = $_POST['spu'];
425
  unset( $_POST['spu'] );
426
 
427
+ $post = get_post($post_id);
428
+
429
  // sanitize settings
430
  $opts['css']['width'] = sanitize_text_field( $opts['css']['width'] );
431
  $opts['css']['bgopacity'] = sanitize_text_field( $opts['css']['bgopacity'] );
433
  $opts['cookie'] = absint( sanitize_text_field( $opts['cookie'] ) );
434
  $opts['trigger_number'] = absint( sanitize_text_field( $opts['trigger_number'] ) );
435
 
436
+ // Check for social shortcodes and update post meta ( we check later if we need to enqueue any social js)
437
+ $total_shortcodes =0;
438
+ if( has_shortcode( $post->post_content, 'spu-facebook' ) ){
439
+ $total_shortcodes++;
440
+ update_post_meta( $post_id, 'spu_fb', true );
441
+ } else {
442
+ delete_post_meta( $post_id, 'spu_fb');
443
+ }
444
+ if( has_shortcode( $post->post_content, 'spu-twitter' ) ){
445
+ $total_shortcodes++;
446
+ update_post_meta( $post_id, 'spu_tw', true );
447
+ } else {
448
+ delete_post_meta( $post_id, 'spu_tw');
449
+ }
450
+ if( has_shortcode( $post->post_content, 'spu-google' ) ){
451
+ $total_shortcodes++;
452
+ $opts['google'] = true;
453
+ update_post_meta( $post_id, 'spu_google', true );
454
+ } else {
455
+ delete_post_meta( $post_id, 'spu_google');
456
+ }
457
+ // save total shortcodes (for auto styling)
458
+ if( $total_shortcodes ){
459
+ update_post_meta( $post_id, 'spu_social', $total_shortcodes );
460
+ } else {
461
+ delete_post_meta( $post_id, 'spu_social' );
462
+ }
463
+ if( has_shortcode( $post->post_content, 'gravityform' ) ) {
464
+ preg_match('/\[gravityform id="([0-9]+)".*\]/i', $post->post_content, $matches);
465
+ if( !empty( $matches[1] ) )
466
+ update_post_meta( $post_id, 'spu_gravity', $matches[1]);
467
+ } else {
468
+ delete_post_meta( $post_id, 'spu_gravity' );
469
+ }
470
 
471
  // save box settings
472
  update_post_meta( $post_id, 'spu_options', apply_filters( 'spu/metaboxes/sanitized_options', $opts ) );
474
  // Start with rules
475
  if( isset($_POST['spu_rules']) && is_array($_POST['spu_rules']) )
476
  {
 
 
477
  // clean array keys
478
  $groups = array_values( $_POST['spu_rules'] );
479
  foreach($groups as $group_id => $group )
482
  {
483
  // clean array keys
484
  $groups_a[] = array_values( $group );
485
+
486
  }
487
  }
488
 
490
  unset( $_POST['spu_rules'] );
491
  }
492
 
 
493
  }
494
  /**
495
  * Register and enqueue admin-specific style sheet.
admin/views/metabox-help.php CHANGED
@@ -3,7 +3,8 @@
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
  ?>
5
 
6
- <p><?php _e( 'You have three social shortcodes to use that will print a Facebook like, a Google+ Follow and a Twitter follow. Check the available options and default values:', $this->plugin_slug );?></p>
 
7
  <p><strong>Facebook:</strong></p>
8
  <p>
9
  [spu-facebook href="" layout="" show_faces="" share="" action="" width=""]
@@ -24,7 +25,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
24
  <a href="go-opts" onclick="jQuery('#go-opts').slideToggle();return false;"><?php _e( 'View Google+ Options', $this->plugin_slug );?></a>
25
  <ul id="go-opts" style="display:none;">
26
  <li><b>url:</b> <?php _e( 'Your Google+ url', $this->plugin_slug );?></li>
27
- <li><b>size:</b> <?php _e( 'small, standard, tall Default value: medium', $this->plugin_slug );?></li>
28
  <li><b>annotation:</b> <?php _e( 'inline, none <b>Default value:</b> bubble', $this->plugin_slug );?></li>
29
  </ul>
30
  <p><strong>Twitter:</strong></p>
@@ -34,7 +35,18 @@ if ( !defined( 'ABSPATH' ) ) exit;
34
  <a href="tw-opts" onclick="jQuery('#tw-opts').slideToggle();return false;"><?php _e( 'View Twitter Options', $this->plugin_slug );?></a>
35
  <ul id="tw-opts" style="display:none;">
36
  <li><b>user:</b> <?php _e( 'Your Twitter user <b>Default chifli</b>iiii', $this->plugin_slug );?></li>
37
- <li><b>show_count:</b> <?php _e( 'false Default value: true', $this->plugin_slug );?></li>
38
  <li><b>size:</b> <?php _e( 'large <b>Default value:</b> ""', $this->plugin_slug );?></li>
39
  <li><b>lang:</b> </li>
40
  </ul>
 
 
 
 
 
 
 
 
 
 
 
3
  if ( !defined( 'ABSPATH' ) ) exit;
4
  ?>
5
 
6
+ <p><?php _e( 'You have three social shortcodes to use that will print a Facebook like, a Google+ Follow and a Twitter follow. Check the available options and <strong>configure them with your social accounts</strong>:', $this->plugin_slug );?></p>
7
+
8
  <p><strong>Facebook:</strong></p>
9
  <p>
10
  [spu-facebook href="" layout="" show_faces="" share="" action="" width=""]
25
  <a href="go-opts" onclick="jQuery('#go-opts').slideToggle();return false;"><?php _e( 'View Google+ Options', $this->plugin_slug );?></a>
26
  <ul id="go-opts" style="display:none;">
27
  <li><b>url:</b> <?php _e( 'Your Google+ url', $this->plugin_slug );?></li>
28
+ <li><b>size:</b> <?php _e( 'small, standard, tall <b>Default value:</b> medium', $this->plugin_slug );?></li>
29
  <li><b>annotation:</b> <?php _e( 'inline, none <b>Default value:</b> bubble', $this->plugin_slug );?></li>
30
  </ul>
31
  <p><strong>Twitter:</strong></p>
35
  <a href="tw-opts" onclick="jQuery('#tw-opts').slideToggle();return false;"><?php _e( 'View Twitter Options', $this->plugin_slug );?></a>
36
  <ul id="tw-opts" style="display:none;">
37
  <li><b>user:</b> <?php _e( 'Your Twitter user <b>Default chifli</b>iiii', $this->plugin_slug );?></li>
38
+ <li><b>show_count:</b> <?php _e( 'false <b>Default value:</b> true', $this->plugin_slug );?></li>
39
  <li><b>size:</b> <?php _e( 'large <b>Default value:</b> ""', $this->plugin_slug );?></li>
40
  <li><b>lang:</b> </li>
41
  </ul>
42
+ <h3 style="padding-left:0;margin: 20px 0;"><strong><?php _e('Other available Shortcodes:', $this->plugin_slug );?><strong></h3>
43
+ <p><strong>Close Button:</strong></p>
44
+ <p>
45
+ [spu-close class="" text="" align=""]
46
+ </p>
47
+ <a href="close-opts" onclick="jQuery('#close-opts').slideToggle();return false;"><?php _e( 'View Close shortcode Options', $this->plugin_slug );?></a>
48
+ <ul id="close-opts" style="display:none;">
49
+ <li><b>class:</b> <?php _e( 'Pass a custom class to style your button', $this->plugin_slug );?></li>
50
+ <li><b>text:</b> <?php _e( 'Button label - <b>Default value:</b> Close', $this->plugin_slug );?></li>
51
+ <li><b>align:</b> <?php _e( 'left, right, center, none - <b>Default value:</b> center', $this->plugin_slug );?></li>
52
+ </ul>
admin/views/settings-page.php CHANGED
@@ -9,13 +9,23 @@
9
  <form name="spu-settings" method="post">
10
  <table class="form-table">
11
  <?php do_action( 'spu/settings_page/before' ); ?>
 
 
 
 
 
 
 
 
 
 
12
  <tr valign="top" class="">
13
  <th><label for="debug"><?php _e( 'Enable Debug mode?', $this->plugin_slug ); ?></label></th>
14
  <td colspan="3">
15
- <label><input type="checkbox" id="debug" name="spu_settings[debug]" value="1" <?php checked(@$opts['debug'], 1); ?> />
16
  <p class="help"><?php _e( 'Will use uncompressed js', $this->plugin_slug ); ?></p>
17
  </td>
18
-
19
  </tr>
20
  <tr valign="top" class="">
21
  <th><label for="safe"><?php _e( 'Enable safe mode?', $this->plugin_slug ); ?></label></th>
9
  <form name="spu-settings" method="post">
10
  <table class="form-table">
11
  <?php do_action( 'spu/settings_page/before' ); ?>
12
+
13
+ <tr valign="top" class="">
14
+ <th><label for="ajax_mode"><?php _e( 'Ajax mode?', $this->plugin_slug ); ?></label></th>
15
+ <td colspan="3">
16
+ <label><input type="checkbox" id="ajax_mode" name="spu_settings[ajax_mode]" value="1" <?php checked(@$opts['ajax_mode'], 1); ?> />
17
+ <p class="help"><?php _e( 'Load popups using ajax. Compatible with cache plugins, but might not work with all plugins', $this->plugin_slug ); ?></p>
18
+ </td>
19
+
20
+ </tr>
21
+
22
  <tr valign="top" class="">
23
  <th><label for="debug"><?php _e( 'Enable Debug mode?', $this->plugin_slug ); ?></label></th>
24
  <td colspan="3">
25
+ <label><input type="checkbox" id="debug" name="spu_settings[debug]" value="1" <?php checked(@$opts['debug'], 1); ?> />
26
  <p class="help"><?php _e( 'Will use uncompressed js', $this->plugin_slug ); ?></p>
27
  </td>
28
+
29
  </tr>
30
  <tr valign="top" class="">
31
  <th><label for="safe"><?php _e( 'Enable safe mode?', $this->plugin_slug ); ?></label></th>
includes/class-spu-helper.php CHANGED
@@ -35,12 +35,12 @@ class Spu_Helper {
35
  );
36
 
37
  $is_ajax = false;
 
38
  if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'spu_nonce') )
39
  {
40
  $is_ajax = true;
41
  }
42
 
43
-
44
  // Is AJAX call?
45
  if( $is_ajax )
46
  {
35
  );
36
 
37
  $is_ajax = false;
38
+
39
  if( isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'spu_nonce') )
40
  {
41
  $is_ajax = true;
42
  }
43
 
 
44
  // Is AJAX call?
45
  if( $is_ajax )
46
  {
popups.php CHANGED
@@ -11,7 +11,7 @@
11
  * @socialpopup
12
  * Plugin Name: Popups - WordPress Popup
13
  * Plugin URI: http://www.timersys.com/free-plugins/social-popup/
14
- * Version: 1.2.2.1
15
  * Description: This plugin will display a popup or splash screen when a new user visit your site showing a Google+, twitter and facebook follow links. This will increase you followers ratio in a 40%. Popup will be close depending on your settings. Check readme.txt for full details.
16
  * Author: Damian Logghe
17
  * Author URI: http://wp.timersys.com
11
  * @socialpopup
12
  * Plugin Name: Popups - WordPress Popup
13
  * Plugin URI: http://www.timersys.com/free-plugins/social-popup/
14
+ * Version: 1.2.3
15
  * Description: This plugin will display a popup or splash screen when a new user visit your site showing a Google+, twitter and facebook follow links. This will increase you followers ratio in a 40%. Popup will be close depending on your settings. Check readme.txt for full details.
16
  * Author: Damian Logghe
17
  * Author URI: http://wp.timersys.com
public/assets/css/public.css CHANGED
@@ -4,6 +4,9 @@ body {
4
  min-height: 100% !important;
5
  height: auto !important;
6
  }
 
 
 
7
  .spu-bg{
8
  position: fixed;
9
  width: 100%;
@@ -25,6 +28,7 @@ body {
25
  -moz-border-radius: 8px;
26
  -webkit-border-radius: 8px;
27
  border-radius: 8px;
 
28
  }
29
  .spu-box.spu-centered{
30
  margin: 0;
@@ -105,6 +109,15 @@ body {
105
  .spu-shortcode iframe{
106
  max-width: 1200px;
107
  }
 
 
 
 
 
 
 
 
 
108
  @media only screen and (max-width: 620px) {
109
  .spu-box {
110
  left: 0 !important;
4
  min-height: 100% !important;
5
  height: auto !important;
6
  }
7
+ .spu-box, .spu-box *{
8
+ box-sizing: border-box;
9
+ }
10
  .spu-bg{
11
  position: fixed;
12
  width: 100%;
28
  -moz-border-radius: 8px;
29
  -webkit-border-radius: 8px;
30
  border-radius: 8px;
31
+ max-width: 100%;
32
  }
33
  .spu-box.spu-centered{
34
  margin: 0;
109
  .spu-shortcode iframe{
110
  max-width: 1200px;
111
  }
112
+ .spu_shortcodes{
113
+ zoom: 1;
114
+ }
115
+
116
+ .spu_shortcodes:before,
117
+ .spu_shortcodes:after { content: ""; display: table; }
118
+ .spu_shortcodes:after { clear: both; }
119
+
120
+
121
  @media only screen and (max-width: 620px) {
122
  .spu-box {
123
  left: 0 !important;
public/assets/js/min/public-min.js CHANGED
@@ -1 +1 @@
1
- function spuCreateCookie(t,i,e){if(e){var n=new Date;n.setTime(n.getTime()+24*e*60*60*1e3);var o="; expires="+n.toGMTString()}else var o="";document.cookie=t+"="+i+o+"; path=/"}function spuReadCookie(t){for(var i=t+"=",e=document.cookie.split(";"),n=0;n<e.length;n++){for(var o=e[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(i))return o.substring(i.length,o.length)}return null}function googleCB(t){if("on"==t.state){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}function closeGoogle(t){if("confirm"==t.type){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}jQuery(window).load(function(){window.SPU=function($){function t(t){var i=r[t],e=$(window).width(),n=$(window).height(),o=i.height(),a=i.width();i.css({position:"fixed",top:n/2-o/2,left:e/2-a/2})}function i(t){var i=$(t).find(".spu-facebook");if(i.length){var e=i.find(".fb-like > span").width();if(0==e){var n=i.find(".fb-like").data("layout");i.append("box_count"==n?'<style type="text/css"> #'+$(t).attr("id")+" .fb-like iframe, #"+$(t).attr("id")+" .fb_iframe_widget span, #"+$(t).attr("id")+" .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>":'<style type="text/css"> #'+$(t).attr("id")+" .fb-like iframe, #"+$(t).attr("id")+" .fb_iframe_widget span, #"+$(t).attr("id")+" .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>")}}}function e(i,e){var n=r[i],o=$("#spu-bg-"+i),a=n.data("bgopa");if(n.is(":animated"))return!1;if(e===!0&&n.is(":visible")||e===!1&&n.is(":hidden"))return!1;if(e===!1){var s=parseInt(n.data("cookie"));s>0&&spuCreateCookie("spu_box_"+i,!0,s)}else n.hasClass("spu-centered")&&t(i);var d=n.data("spuanimation");return"fade"===d?n.fadeToggle("slow"):n.slideToggle("slow"),e===!0&&a>0?o.fadeIn():o.fadeOut(),e}function n(t,i,e,n){var o={url:spuvar.ajax_url,data:t,cache:!1,type:"POST",dataType:"json",timeout:3e4},e=e||!1,n=n||!1;i&&(o.url=i),e&&(o.success=e),n&&(o.error=n),$.ajax(o)}var o=$(window).height(),a=spuvar.is_admin,r=[];return $(".spu-content").children().first().css({"margin-top":0,"padding-top":0}).end().last().css({"margin-bottom":0,"padding-bottom":0}),$(".spu-box").each(function(){spuvar.safe_mode&&$(this).prependTo("body");var t=$(this),s=t.data("trigger"),d=0,u=1===parseInt(t.data("test-mode")),c=t.data("box-id"),f=1===parseInt(t.data("auto-hide")),p=parseInt(t.data("seconds-close")),l=parseInt(t.data("trigger-number"),10),h="percentage"==s?parseInt(t.data("trigger-number"),10)/100:.8,w=h*$(document).height();i(t),$(".spu-google").width($(".spu-google").width()-20),$(".spu-twitter").width($(".spu-twitter").width()-12);var g=0,m=0,b=t.width(),v=t.find(".spu-content").width(),y=t.data("total");y&&!spuvar.disable_style&&($(this).find(".spu-shortcode").each(function(){g+=$(this).width()}),m=v-g),m>0&&($(this).find(".spu-shortcode").each(function(){3==y?$(this).css("margin-left",m/(y-1)):$(this).css("margin-left",m/2)}),2==y?$(this).find(".spu-shortcode").last().css("margin-left",0):3==y&&$(this).find(".spu-shortcode").first().css("margin-left",0)),b>$(window).width()&&t.css("cssText","max-width:"+t.css("width")+";width:auto !important;"),$(document).keyup(function(t){27==t.keyCode&&e(c,!1)});var x=navigator.userAgent,_=x.match(/iPad/i)||x.match(/iPhone/i)?"touchstart":"click";$("body").on(_,function(t){t.which&&e(c,!1)}),$("body").on(_,".spu-box",function(t){t.stopPropagation()}),t.hide().css("left",""),r[c]=t;var k=function(){d&&clearTimeout(d),d=window.setTimeout(function(){var t=$(window).scrollTop(),i=t+o>=w;i?(f||$(window).unbind("scroll",k),e(c,!0)):e(c,!1)},100)},T=function(){d&&clearTimeout(d),d=window.setTimeout(function(){e(c,!0)},1e3*l)},C=spuReadCookie("spu_box_"+c);if((void 0==C||a&&u)&&("seconds"==s?T():($(window).bind("scroll",k),k()),window.location.hash&&window.location.hash.length>0)){var P=window.location.hash,I;P.substring(1)===t.attr("id")&&setTimeout(function(){e(c,!0)},100)}t.find(".spu-close").click(function(){e(c,!1),"percentage"==s&&$(window).unbind("scroll",k)}),$('a[href="#'+t.attr("id")+'"]').click(function(){return e(c,!0),!1}),t.find(".gform_wrapper form").addClass("gravity-form"),t.find('form:not(".wpcf7-form, .gravity-form")').submit(function(t){t.preventDefault();var i=!0,o=$(this),a=o.serialize(),r=o.attr("action"),s=function(t){var i=$(t).filter("#spu-"+c).html();$("#spu-"+c).html(i),setTimeout(function(){e(c,!1)},spuvar.seconds_confirmation_close)};return n(a,r,s,"","html"),i}),$("body").on("mailsent.wpcf7",function(){e(c,!1)}),$(document).on("gform_confirmation_loaded",function(){e(c,!1)})}),{show:function(t){return e(t,!0)},hide:function(t){return e(t,!1)},request:function(t,i,e,o){return n(t,i,e,o)}}}(window.jQuery)}),jQuery(function($){function t(){FB.Event.subscribe("edge.create",function(t,i){var e=$(i).parents(".spu-box").data("box-id");e&&(SPU.hide(e),SPU.track(e,!0))}),e=!0,clearInterval(n)}function i(t){var i=$(t.target).parents(".spu-box").data("box-id");i&&SPU.hide(i)}var e=!1,n=setInterval(function(){"undefined"==typeof FB||e||t()},1e3);"undefined"!=typeof twttr&&twttr.ready(function(t){t.events.bind("tweet",i),t.events.bind("follow",i)})});
1
+ !function($){"use strict";function t(t,i,e,n,o){var a={url:spuvar.ajax_url,data:t,cache:!1,type:"POST",dataType:"json",timeout:3e4},o=o||!1,e=e||!1,n=n||!1;i&&(a.url=i),e&&(a.success=e),n&&(a.error=n),o&&(a.dataType=o),$.ajax(a)}function i(t,i,e){if(e){var n=new Date;n.setTime(n.getTime()+24*e*60*60*1e3);var o="; expires="+n.toGMTString()}else var o="";document.cookie=t+"="+i+o+"; path=/"}function e(t){for(var i=t+"=",e=document.cookie.split(";"),n=0;n<e.length;n++){for(var o=e[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(i))return o.substring(i.length,o.length)}return null}function n(){FB.Event.subscribe("edge.create",function(t,i){var e=$(i).parents(".spu-box").data("box-id");e&&(SPU.hide(e),SPU.track(e,!0))}),d=!0,clearInterval(u)}function o(t){var i=$(t.target).parents(".spu-box").data("box-id");i&&SPU.hide(i)}function a(t){if("on"==t.state){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}function r(t){if("confirm"==t.type){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}if(spuvar.ajax_mode){var s={pid:spuvar.pid,referrer:document.referrer};t(s,!1,success_cb,!1,"html")}jQuery(window).load(function(){window.SPU=function($){function n(t){var i=d[t],e=$(window).width(),n=$(window).height(),o=i.height(),a=i.width();i.css({position:"fixed",top:n/2-o/2,left:e/2-a/2})}function o(t){var i=$(t).find(".spu-facebook");if(i.length){var e=i.find(".fb-like > span").width();if(0==e){var n=i.find(".fb-like").data("layout");i.append("box_count"==n?'<style type="text/css"> #'+$(t).attr("id")+" .fb-like iframe, #"+$(t).attr("id")+" .fb_iframe_widget span, #"+$(t).attr("id")+" .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>":'<style type="text/css"> #'+$(t).attr("id")+" .fb-like iframe, #"+$(t).attr("id")+" .fb_iframe_widget span, #"+$(t).attr("id")+" .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>")}}}function a(t,e){var o=d[t],a=$("#spu-bg-"+t),r=o.data("bgopa");if(o.is(":animated"))return!1;if(e===!0&&o.is(":visible")||e===!1&&o.is(":hidden"))return!1;if(e===!1){var s=parseInt(o.data("cookie"));s>0&&i("spu_box_"+t,!0,s)}else o.hasClass("spu-centered")&&($(window).resize(function(){n(t)}),n(t));var u=o.data("spuanimation");return"fade"===u?o.fadeToggle("slow"):o.slideToggle("slow"),e===!0&&r>0?a.fadeIn():a.fadeOut(),e}var r=$(window).height(),s=spuvar.is_admin,d=[];return $(".spu-content").children().first().css({"margin-top":0,"padding-top":0}).end().last().css({"margin-bottom":0,"padding-bottom":0}),$(".spu-box").each(function(){spuvar.safe_mode&&$(this).prependTo("body");var i=$(this),n=i.data("trigger"),u=0,c=1===parseInt(i.data("test-mode")),f=i.data("box-id"),p=1===parseInt(i.data("auto-hide")),l=parseInt(i.data("seconds-close")),h=parseInt(i.data("trigger-number"),10),w="percentage"==n?parseInt(i.data("trigger-number"),10)/100:.8,m=w*$(document).height();o(i),$(".spu-google").width($(".spu-google").width()-20),$(".spu-twitter").width($(".spu-twitter").width()-12);var g=0,v=0,b=i.width(),y=i.find(".spu-content").width(),x=i.data("total");x&&!spuvar.disable_style&&($(this).find(".spu-shortcode").each(function(){g+=$(this).width()}),v=y-g),v>0&&($(this).find(".spu-shortcode").each(function(){3==x?$(this).css("margin-left",v/(x-1)):$(this).css("margin-left",v/2)}),2==x?$(this).find(".spu-shortcode").last().css("margin-left",0):3==x&&$(this).find(".spu-shortcode").first().css("margin-left",0)),b>$(window).width()&&i.css("cssText","max-width:"+i.css("width")+";width:auto !important;"),$(document).keyup(function(t){27==t.keyCode&&a(f,!1)});var _=navigator.userAgent,T=_.match(/iPad/i)||_.match(/iPhone/i)?"touchstart":"click";$("body").on(T,function(t){t.which&&a(f,!1)}),$("body").on(T,".spu-box",function(t){t.stopPropagation()}),i.hide().css("left",""),d[f]=i;var k=function(){u&&clearTimeout(u),u=window.setTimeout(function(){var t=$(window).scrollTop(),i=t+r>=m;i?(p||$(window).unbind("scroll",k),a(f,!0)):a(f,!1)},100)},P=function(){u&&clearTimeout(u),u=window.setTimeout(function(){a(f,!0)},1e3*h)},j=e("spu_box_"+f);if((void 0==j||s&&c)&&("seconds"==n?P():($(window).bind("scroll",k),k()),window.location.hash&&window.location.hash.length>0)){var I=window.location.hash,S;I.substring(1)===i.attr("id")&&setTimeout(function(){a(f,!0)},100)}i.find(".spu-close-popup").click(function(){a(f,!1),"percentage"==n&&$(window).unbind("scroll",k)}),$('a[href="#'+i.attr("id")+'"]').click(function(){return a(f,!0),!1}),i.find(".gform_wrapper form").addClass("gravity-form"),i.on("submit",'form:not(".wpcf7-form, .gravity-form")',function(i){i.preventDefault(),track(f,!0);var e=!0,n=$(this),o=n.serialize(),r=n.attr("action"),s=function(t,i,e){console.log("Spu Form error: "+i+" - "+e)},d=function(t){var i=$(t).filter("#spu-"+f).html();$("#spu-"+f).html(i),$("#spu-"+f).find(".mc4wp-form-error").length||setTimeout(function(){a(f,!1)},1e3*spuvar.seconds_confirmation_close)};return t(o,r,d,s,"html"),e}),$("body").on("mailsent.wpcf7",function(){a(f,!1)}),$(document).on("gform_confirmation_loaded",function(){a(f,!1)})}),{show:function(t){return a(t,!0)},hide:function(t){return a(t,!1)},request:function(i,e,n,o){return t(i,e,n,o)}}}(window.jQuery)});var d=!1,u=setInterval(function(){"undefined"==typeof FB||d||n()},1e3);"undefined"!=typeof twttr&&twttr.ready(function(t){t.events.bind("tweet",o),t.events.bind("follow",o)})}(jQuery);
public/assets/js/public.js CHANGED
@@ -1,386 +1,447 @@
1
- jQuery(window).load(function() {
 
2
 
3
- window.SPU = (function($) {
4
 
5
- var windowHeight = $(window).height();
6
- var isAdmin = spuvar.is_admin;
7
- var $boxes = [];
8
 
9
 
10
- //remove paddings and margins from first and last items inside box
11
- $(".spu-content").children().first().css({
12
- "margin-top": 0,
13
- "padding-top": 0
14
- }).end().last().css({
15
- 'margin-bottom': 0,
16
- 'padding-bottom': 0
17
- });
18
 
19
- // loop through boxes
20
- $(".spu-box").each(function() {
21
 
22
- // move to parent in safe mode
23
- if( spuvar.safe_mode ){
24
 
25
- $(this).prependTo('body');
26
-
27
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- // vars
30
- var $box = $(this);
31
- var triggerMethod = $box.data('trigger');
32
- var timer = 0;
33
- var testMode = (parseInt($box.data('test-mode')) === 1);
34
- var id = $box.data('box-id');
35
- var autoHide = (parseInt($box.data('auto-hide')) === 1);
36
- var secondsClose = parseInt($box.data('seconds-close'));
37
- var triggerSeconds = parseInt( $box.data('trigger-number'), 10 );
38
- var triggerPercentage = ( triggerMethod == 'percentage' ) ? ( parseInt( $box.data('trigger-number'), 10 ) / 100 ) : 0.8;
39
- var triggerHeight = ( triggerPercentage * $(document).height() );
 
 
 
 
 
 
 
 
40
 
41
- facebookFix( $box );
42
- //correct widths of sharing icons
43
- $('.spu-google').width($('.spu-google').width()-20);
44
- $('.spu-twitter').width($('.spu-twitter').width()-12);
45
 
46
- //center spu-shortcodes
47
- var swidth = 0;
48
- var free_width = 0;
49
- var boxwidth = $box.width();
50
- var cwidth = $box.find(".spu-content").width();
51
- var total = $box.data('total'); //total of shortcodes used
52
- if( total && ! spuvar.disable_style ){
53
 
54
- //calculate total width of shortcodes all togheter
55
- $(this).find(".spu-shortcode").each(function(){
56
- swidth = swidth + $(this).width();
57
- });
58
- //available space to split margins
59
- free_width = cwidth - swidth;
60
-
61
  }
62
- if( free_width > 0 ) {
63
- //leave some margin
64
- $(this).find(".spu-shortcode").each(function(){
65
- if( total == 3) {
66
 
67
- $(this).css('margin-left',(free_width / (total-1)));
68
-
69
- } else {
70
-
71
- $(this).css('margin-left',(free_width / 2 ));
72
-
73
- }
74
 
75
- });
76
- //remove margin when neccesary
77
- if( total == 2) {
78
 
79
- $(this).find(".spu-shortcode").last().css('margin-left',0);
80
 
81
- } else if( total == 3) {
 
 
 
82
 
83
- $(this).find(".spu-shortcode").first().css('margin-left',0);
84
-
85
- }
86
- }
 
 
 
 
 
 
 
 
 
 
87
 
88
- // Check if box width is less that window
89
- if( boxwidth > $(window).width() ){
90
- $box.css('cssText', 'max-width:'+$box.css('width')+';width:auto !important;');
91
- }
92
 
93
- //close with esc
94
- $(document).keyup(function(e) {
95
- if (e.keyCode == 27) {
96
- toggleBox( id, false );
97
- }
98
- });
99
- //close on ipads // iphones
100
- var ua = navigator.userAgent,
101
- event = (ua.match(/iPad/i) || ua.match(/iPhone/i)) ? "touchstart" : "click";
102
-
103
- $('body').on(event, function (ev) {
104
- // test that event is user triggered and not programatically
105
- if( ev.which ) {
106
 
107
- toggleBox( id, false );
108
-
109
- }
110
- });
111
- //not on the box
112
- $('body' ).on(event,'.spu-box', function(event) {
113
- event.stopPropagation();
114
- });
115
 
116
- //hide boxes and remove left-99999px we cannot since beggining of facebook won't display
117
- $box.hide().css('left','');
118
 
119
- // add box to global boxes array
120
- $boxes[id] = $box;
 
 
 
 
121
 
122
- // functions that check % of height
123
- var triggerHeightCheck = function()
124
- {
125
- if(timer) {
126
- clearTimeout(timer);
127
- }
128
 
129
- timer = window.setTimeout(function() {
130
- var scrollY = $(window).scrollTop();
131
- var triggered = ((scrollY + windowHeight) >= triggerHeight);
132
 
133
- // show box when criteria for this box is matched
134
- if( triggered ) {
 
 
135
 
136
- // remove listen event if box shouldn't be hidden again
137
- if( ! autoHide ) {
138
- $(window).unbind('scroll', triggerHeightCheck);
139
- }
140
 
141
- toggleBox( id, true );
142
- } else {
143
- toggleBox( id, false );
144
- }
 
 
 
 
145
 
146
- }, 100);
147
- }
148
- // function that show popup after X secs
149
- var triggerSecondsCheck = function()
150
- {
151
- if(timer) {
152
- clearTimeout(timer);
153
- }
154
 
155
- timer = window.setTimeout(function() {
156
 
157
- toggleBox( id, true );
 
158
 
159
- }, triggerSeconds * 1000);
160
- }
161
 
162
- // show box if cookie not set or if in test mode
163
- var cookieValue = spuReadCookie( 'spu_box_' + id );
 
 
 
 
 
 
 
164
 
165
- if( cookieValue == undefined || ( isAdmin && testMode ) ) {
166
-
167
- if(triggerMethod == 'seconds') {
168
- triggerSecondsCheck();
169
- } else {
170
- $(window).bind( 'scroll', triggerHeightCheck );
171
- // init, check box criteria once
172
- triggerHeightCheck();
173
- }
174
-
175
- // shows the box when hash refers to a box
176
- if(window.location.hash && window.location.hash.length > 0) {
177
-
178
- var hash = window.location.hash;
179
- var $element;
180
-
181
- if( hash.substring(1) === $box.attr( 'id' ) ) {
182
- setTimeout(function() {
183
- toggleBox( id, true );
184
- }, 100);
185
- }
186
- }
187
- } /* end check cookie */
188
 
189
- $box.find(".spu-close").click(function() {
 
190
 
191
- // hide box
192
- toggleBox( id, false );
 
 
 
 
 
193
 
194
- if(triggerMethod == 'percentage') {
195
- // unbind
196
- $(window).unbind( 'scroll', triggerHeightCheck );
197
- }
198
-
199
- });
200
-
201
- // add link listener for this box
202
- $('a[href="#' + $box.attr('id') +'"]').click(function() {
203
-
204
- toggleBox(id, true);
205
- return false;
206
- });
207
 
208
- // add class to the gravity form if they exist within the box
209
- $box.find('.gform_wrapper form').addClass('gravity-form');
210
-
211
- // Add generic form tracking
212
- $box.find('form:not(".wpcf7-form, .gravity-form")').submit( function(e){
213
- e.preventDefault();
214
-
215
- var submit = true,
216
- form = $(this),
217
- data = form.serialize(),
218
- url = form.attr('action'),
219
- success_cb = function (data){
220
- var response = $(data).filter('#spu-'+ id ).html();
221
- $('#spu-' + id ).html(response);
222
- // give 2 seconds for response
223
- setTimeout( function(){
224
-
225
- toggleBox(id, false );
226
-
227
- }, spuvar.seconds_confirmation_close);
228
- }
229
- // Send form by ajax and replace popup with response
230
- request(data, url, success_cb, '', 'html');
231
-
232
- return submit;
233
- });
234
-
235
- // CF7 support
236
- $('body').on('mailsent.wpcf7', function(){
237
-
238
- toggleBox(id, false );
239
- });
240
-
241
- // Gravity forms support (only AJAX mode)
242
- $(document).on('gform_confirmation_loaded', function(){
243
-
244
- toggleBox(id, false );
245
- });
246
 
247
- });
 
 
 
 
 
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
- //function that center popup on screen
251
- function centerBox( id ) {
252
- var $box = $boxes[id];
253
- var windowWidth = $(window).width();
254
- var windowHeight = $(window).height();
255
- var popupHeight = $box.height();
256
- var popupWidth = $box.width();
257
- $box.css({
258
- "position": "fixed",
259
- "top": windowHeight / 2 - popupHeight / 2,
260
- "left": windowWidth / 2 - popupWidth / 2
261
- });
262
- }
263
 
264
- //facebookBugFix
265
- function facebookFix( box ) {
 
 
 
 
 
 
 
 
 
 
 
266
 
267
- // Facebook bug that fails to resize
268
- var $fbbox = $(box).find('.spu-facebook');
269
- if( $fbbox.length ){
270
- //if exist and width is 0
271
- var $fbwidth = $fbbox.find('.fb-like > span').width();
272
- if ( $fbwidth == 0 ) {
273
- var $fblayout = $fbbox.find('.fb-like').data('layout');
274
- if( $fblayout == 'box_count' ) {
275
 
276
- $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>');
 
 
 
 
 
 
 
277
 
278
- } else {
279
-
280
- $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>');
281
 
282
- }
283
- }
284
- }
285
- }
286
-
287
- //function that show/hide box
288
- function toggleBox( id, show ) {
289
- var $box = $boxes[id];
290
- var $bg = $('#spu-bg-'+id);
291
- var $bgopa = $box.data('bgopa');
292
-
293
- // don't do anything if box is undergoing an animation
294
- if( $box.is( ":animated" ) ) {
295
- return false;
296
- }
297
 
298
- // is box already at desired visibility?
299
- if( ( show === true && $box.is( ":visible" ) ) || ( show === false && $box.is( ":hidden" ) ) ) {
300
- return false;
301
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
302
 
303
- //if we are closing , set cookie
304
- if( show === false) {
305
- // set cookie
306
- var days = parseInt( $box.data('cookie') );
307
- if( days > 0 ) {
308
- spuCreateCookie( 'spu_box_' + id, true, days );
309
- }
310
- } else {
311
 
312
- //if is a centered popup, center it
313
- if( $box.hasClass('spu-centered') ) {
 
 
 
 
 
 
314
 
315
- centerBox( id );
 
 
 
316
 
317
- }
318
-
319
- }
320
-
321
- // show box
322
- var animation = $box.data('spuanimation');
323
 
324
- if( animation === 'fade' ) {
325
- $box.fadeToggle( 'slow' );
326
- } else {
327
- $box.slideToggle( 'slow' );
328
- }
329
 
330
- //background
331
- if( show === true && $bgopa > 0 ){
332
- $bg.fadeIn();
333
- } else {
334
- $bg.fadeOut();
335
  }
336
- return show;
337
  }
338
- // AJAX REQUESTS
339
- function request(data, url, success_cb, error_cb){
340
- // Prepare variables.
341
- var ajax = {
342
- url: spuvar.ajax_url,
343
- data: data,
344
- cache: false,
345
- type: 'POST',
346
- dataType: 'json',
347
- timeout: 30000
348
- },
349
- success_cb = success_cb || false,
350
- error_cb = error_cb || false;
351
-
352
- // Set ajax url is supplied
353
- if ( url ) {
354
- ajax.url = url;
355
- }
356
- // Set success callback if supplied.
357
- if ( success_cb ) {
358
- ajax.success = success_cb;
359
- }
360
 
361
- // Set error callback if supplied.
362
- if ( error_cb ) {
363
- ajax.error = error_cb;
364
- }
 
 
 
 
 
 
 
 
 
 
365
 
366
- // Make the ajax request.
367
- $.ajax(ajax);
368
- }
369
- return {
370
- show: function( box_id ) {
371
- return toggleBox( box_id, true );
372
- },
373
- hide: function( box_id ) {
374
- return toggleBox( box_id, false );
375
- },
376
- request: function( data, url, success_cb, error_cb ) {
377
- return request( data, url, success_cb, error_cb );
378
- }
379
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
 
381
- })(window.jQuery);
382
- });
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  /**
385
  * Cookie functions
386
  */
@@ -408,7 +469,7 @@ function spuReadCookie(name) {
408
  * Social Callbacks
409
  */
410
 
411
- jQuery(function($) {
412
  var SPUfb = false;
413
 
414
  var FbTimer = setInterval(function(){
@@ -446,24 +507,45 @@ jQuery(function($) {
446
  SPU.hide(box_id);
447
  }
448
  }
449
- });
450
- function googleCB(a) {
451
 
452
- if( "on" == a.state ) {
453
 
454
- var box_id = jQuery('.spu-gogl').data('box-id');
455
- if( box_id) {
456
- SPU.hide(box_id);
 
 
 
457
  }
458
  }
459
- }
460
- function closeGoogle(a){
461
- if( "confirm" == a.type )
462
- {
463
- var box_id = jQuery('.spu-gogl').data('box-id');
464
- if( box_id) {
465
- SPU.hide(box_id);
466
-
 
 
 
 
 
 
 
 
 
467
  }
 
 
 
 
 
 
 
 
 
 
 
468
  }
469
- }
1
+ (function($){
2
+ "use strict";
3
 
4
+ var SPU = function() {
5
 
6
+ var windowHeight = $(window).height();
7
+ var isAdmin = spuvar.is_admin;
8
+ var $boxes = [];
9
 
10
 
11
+ //remove paddings and margins from first and last items inside box
12
+ $(".spu-content").children().first().css({
13
+ "margin-top": 0,
14
+ "padding-top": 0
15
+ }).end().last().css({
16
+ 'margin-bottom': 0,
17
+ 'padding-bottom': 0
18
+ });
19
 
20
+ // loop through boxes
21
+ $(".spu-box").each(function() {
22
 
23
+ // move to parent in safe mode
24
+ if( spuvar.safe_mode ){
25
 
26
+ $(this).prependTo('body');
27
+
28
+ }
29
+
30
+ // vars
31
+ var $box = $(this);
32
+ var triggerMethod = $box.data('trigger');
33
+ var timer = 0;
34
+ var testMode = (parseInt($box.data('test-mode')) === 1);
35
+ var id = $box.data('box-id');
36
+ var autoHide = (parseInt($box.data('auto-hide')) === 1);
37
+ var secondsClose = parseInt($box.data('seconds-close'));
38
+ var triggerSeconds = parseInt( $box.data('trigger-number'), 10 );
39
+ var triggerPercentage = ( triggerMethod == 'percentage' ) ? ( parseInt( $box.data('trigger-number'), 10 ) / 100 ) : 0.8;
40
+ var triggerHeight = ( triggerPercentage * $(document).height() );
41
+
42
+ facebookFix( $box );
43
+ //correct widths of sharing icons
44
+ $('.spu-google').width($('.spu-google').width()-20);
45
+ $('.spu-twitter').width($('.spu-twitter').width()-12);
46
+
47
+ //center spu-shortcodes
48
+ var swidth = 0;
49
+ var free_width = 0;
50
+ var boxwidth = $box.width();
51
+ var cwidth = $box.find(".spu-content").width();
52
+ var total = $box.data('total'); //total of shortcodes used
53
 
54
+
55
+ //wrap them all
56
+ $(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>');
57
+ if( total && ! spuvar.disable_style && $(window).width() > boxwidth ){
58
+
59
+ //calculate total width of shortcodes all togheter
60
+ $(this).find(".spu-shortcode").each(function(){
61
+ swidth = swidth + $(this).width();
62
+ });
63
+ //available space to split margins
64
+ free_width = cwidth - swidth - total;
65
+
66
+ }
67
+ if( free_width > 0 ) {
68
+ //leave some margin
69
+ $(this).find(".spu-shortcode").each(function(){
70
+ if( total == 3) {
71
+
72
+ $(this).css('margin-left',(free_width / (total-1)));
73
 
74
+ } else {
 
 
 
75
 
76
+ $(this).css('margin-left',(free_width / 2 ));
 
 
 
 
 
 
77
 
 
 
 
 
 
 
 
78
  }
 
 
 
 
79
 
80
+ });
81
+ //remove margin when neccesary
82
+ if( total == 2) {
 
 
 
 
83
 
84
+ $(this).find(".spu-shortcode").last().css('margin-left',0);
 
 
85
 
86
+ } else if( total == 3) {
87
 
88
+ $(this).find(".spu-shortcode").first().css('margin-left',0);
89
+
90
+ }
91
+ }
92
 
93
+
94
+ //close with esc
95
+ $(document).keyup(function(e) {
96
+ if (e.keyCode == 27) {
97
+ toggleBox( id, false );
98
+ }
99
+ });
100
+ //close on ipads // iphones
101
+ var ua = navigator.userAgent,
102
+ event = (ua.match(/iPad/i) || ua.match(/iPhone/i)) ? "touchstart" : "click";
103
+
104
+ $('body').on(event, function (ev) {
105
+ // test that event is user triggered and not programatically
106
+ if( ev.originalEvent !== undefined ) {
107
 
108
+ toggleBox( id, false );
 
 
 
109
 
110
+ }
111
+ });
112
+ //not on the box
113
+ $('body' ).on(event,'.spu-box', function(event) {
114
+ event.stopPropagation();
115
+ });
 
 
 
 
 
 
 
116
 
117
+ //hide boxes and remove left-99999px we cannot since beggining of facebook won't display
118
+ $box.hide().css('left','');
 
 
 
 
 
 
119
 
120
+ // add box to global boxes array
121
+ $boxes[id] = $box;
122
 
123
+ // functions that check % of height
124
+ var triggerHeightCheck = function()
125
+ {
126
+ if(timer) {
127
+ clearTimeout(timer);
128
+ }
129
 
130
+ timer = window.setTimeout(function() {
131
+ var scrollY = $(window).scrollTop();
132
+ var triggered = ((scrollY + windowHeight) >= triggerHeight);
 
 
 
133
 
134
+ // show box when criteria for this box is matched
135
+ if( triggered ) {
 
136
 
137
+ // remove listen event if box shouldn't be hidden again
138
+ if( ! autoHide ) {
139
+ $(window).unbind('scroll', triggerHeightCheck);
140
+ }
141
 
142
+ toggleBox( id, true );
143
+ } else {
144
+ toggleBox( id, false );
145
+ }
146
 
147
+ }, 100);
148
+ }
149
+ // function that show popup after X secs
150
+ var triggerSecondsCheck = function()
151
+ {
152
+ if(timer) {
153
+ clearTimeout(timer);
154
+ }
155
 
156
+ timer = window.setTimeout(function() {
 
 
 
 
 
 
 
157
 
158
+ toggleBox( id, true );
159
 
160
+ }, triggerSeconds * 1000);
161
+ }
162
 
163
+ // show box if cookie not set or if in test mode
164
+ var cookieValue = spuReadCookie( 'spu_box_' + id );
165
 
166
+ if( ( cookieValue == undefined || cookieValue == '' ) || ( isAdmin && $box.testMode ) ) {
167
+
168
+ if(triggerMethod == 'seconds') {
169
+ triggerSecondsCheck();
170
+ } else {
171
+ $(window).bind( 'scroll', triggerHeightCheck );
172
+ // init, check box criteria once
173
+ triggerHeightCheck();
174
+ }
175
 
176
+ // shows the box when hash refers to a box
177
+ if(window.location.hash && window.location.hash.length > 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
+ var hash = window.location.hash;
180
+ var $element;
181
 
182
+ if( hash.substring(1) === $box.attr( 'id' ) ) {
183
+ setTimeout(function() {
184
+ toggleBox( id, true );
185
+ }, 100);
186
+ }
187
+ }
188
+ } /* end check cookie */
189
 
190
+ $box.find(".spu-close-popup").click(function() {
 
 
 
 
 
 
 
 
 
 
 
 
191
 
192
+ // hide box
193
+ toggleBox( id, false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
+ if(triggerMethod == 'percentage') {
196
+ // unbind
197
+ $(window).unbind( 'scroll', triggerHeightCheck );
198
+ }
199
+
200
+ });
201
 
202
+ // add link listener for this box
203
+ $('a[href="#' + $box.attr('id') +'"]').click(function() {
204
+
205
+ toggleBox(id, true);
206
+ return false;
207
+ });
208
+
209
+ // add class to the gravity form if they exist within the box
210
+ $box.find('.gform_wrapper form').addClass('gravity-form');
211
+
212
+ // Add generic form tracking
213
+ $box.on('submit','form:not(".wpcf7-form, .gravity-form")', function(e){
214
+ e.preventDefault();
215
+ // track event
216
+ track( id, true );
217
+
218
+ var submit = true,
219
+ form = $(this),
220
+ data = form.serialize(),
221
+ url = form.attr('action'),
222
+ error_cb = function (data, error, errorThrown){
223
+ console.log('Spu Form error: ' + error + ' - ' + errorThrown);
224
+ },
225
+ success_cb = function (data){
226
+
227
+ var response = $(data).filter('#spu-'+ id ).html();
228
+ $('#spu-' + id ).html(response);
229
+
230
+ // check if an error was returned for m4wp
231
+ if( ! $('#spu-' + id ).find('.mc4wp-form-error').length ) {
232
+
233
+ // give 2 seconds for response
234
+ setTimeout( function(){
235
+
236
+ toggleBox(id, false );
237
+
238
+ }, spuvar.seconds_confirmation_close * 1000);
239
+
240
+ }
241
+ };
242
+ // Send form by ajax and replace popup with response
243
+ request(data, url, success_cb, error_cb, 'html');
244
+
245
+ return submit;
246
+ });
247
+
248
+ // CF7 support
249
+ $('body').on('mailsent.wpcf7', function(){
250
+
251
+ toggleBox(id, false );
252
+ });
253
+
254
+ // Gravity forms support (only AJAX mode)
255
+ $(document).on('gform_confirmation_loaded', function(){
256
+
257
+ toggleBox(id, false );
258
+ });
259
+
260
+ });
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
+ //function that center popup on screen
264
+ function centerBox( id ) {
265
+ var $box = $boxes[id];
266
+ var windowWidth = $(window).width();
267
+ var windowHeight = $(window).height();
268
+ var popupHeight = $box.height();
269
+ var popupWidth = $box.width();
270
+ $box.css({
271
+ "position": "fixed",
272
+ "top": windowHeight / 2 - popupHeight / 2,
273
+ "left": windowWidth / 2 - popupWidth / 2
274
+ });
275
+ }
276
 
277
+ //facebookBugFix
278
+ function facebookFix( box ) {
 
 
 
 
 
 
279
 
280
+ // Facebook bug that fails to resize
281
+ var $fbbox = $(box).find('.spu-facebook');
282
+ if( $fbbox.length ){
283
+ //if exist and width is 0
284
+ var $fbwidth = $fbbox.find('.fb-like > span').width();
285
+ if ( $fbwidth == 0 ) {
286
+ var $fblayout = $fbbox.find('.fb-like').data('layout');
287
+ if( $fblayout == 'box_count' ) {
288
 
289
+ $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 63px !important;width: 80px !important;}</style>');
 
 
290
 
291
+ } else {
292
+
293
+ $fbbox.append('<style type="text/css"> #'+$(box).attr('id')+' .fb-like iframe, #'+$(box).attr('id')+' .fb_iframe_widget span, #'+$(box).attr('id')+' .fb_iframe_widget{ height: 20px !important;width: 80px !important;}</style>');
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
+ }
 
 
296
  }
297
+ }
298
+ }
299
+
300
+ //function that show/hide box
301
+ function toggleBox( id, show ) {
302
+ var $box = $boxes[id];
303
+ var $bg = $('#spu-bg-'+id);
304
+ var $bgopa = $box.data('bgopa');
305
+
306
+ // don't do anything if box is undergoing an animation
307
+ if( $box.is( ":animated" ) ) {
308
+ return false;
309
+ }
310
 
311
+ // is box already at desired visibility?
312
+ if( ( show === true && $box.is( ":visible" ) ) || ( show === false && $box.is( ":hidden" ) ) ) {
313
+ return false;
314
+ }
 
 
 
 
315
 
316
+ //if we are closing , set cookie
317
+ if( show === false) {
318
+ // set cookie
319
+ var days = parseInt( $box.data('cookie') );
320
+ if( days > 0 ) {
321
+ spuCreateCookie( 'spu_box_' + id, true, days );
322
+ }
323
+ } else {
324
 
325
+ //if is a centered popup, center it
326
+ if( $box.hasClass('spu-centered') ) {
327
+ //bind for resize
328
+ $(window).resize(function(){
329
 
330
+ centerBox( id );
 
 
 
 
 
331
 
332
+ });
333
+ centerBox( id );
 
 
 
334
 
 
 
 
 
 
335
  }
336
+
337
  }
338
+
339
+ // show box
340
+ var animation = $box.data('spuanimation');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
 
342
+ if( animation === 'fade' ) {
343
+ $box.fadeToggle( 'slow' );
344
+ } else {
345
+ $box.slideToggle( 'slow' );
346
+ }
347
+
348
+ //background
349
+ if( show === true && $bgopa > 0 ){
350
+ $bg.fadeIn();
351
+ } else {
352
+ $bg.fadeOut();
353
+ }
354
+ return show;
355
+ }
356
 
357
+ return {
358
+ show: function( box_id ) {
359
+ return toggleBox( box_id, true );
360
+ },
361
+ hide: function( box_id ) {
362
+ return toggleBox( box_id, false );
363
+ },
364
+ request: function( data, url, success_cb, error_cb ) {
365
+ return request( data, url, success_cb, error_cb );
 
 
 
 
366
  }
367
+ }
368
+
369
+ }
370
+ if( spuvar.ajax_mode ) {
371
+
372
+ var data = {
373
+ pid : spuvar.pid,
374
+ referrer : document.referrer,
375
+ action : 'spu_load',
376
+ }
377
+ var success_cb = function(response) {
378
+
379
+ $('body').append(response);
380
+
381
+ reload_socials();
382
+
383
+ SPU();
384
+
385
+ },
386
+ error_cb = function (data, error, errorThrown){
387
+ console.log('Problem loading popups - error: ' + error + ' - ' + errorThrown);
388
+ }
389
+ request(data, spuvar.site_url , success_cb, error_cb, 'html');
390
+ } else {
391
 
392
+ jQuery(window).load(function() {
 
393
 
394
+ SPU();
395
+
396
+ });
397
+ }
398
+
399
+
400
+
401
+ /**
402
+ * Ajax requests
403
+ * @param data
404
+ * @param url
405
+ * @param success_cb
406
+ * @param error_cb
407
+ * @param dataType
408
+ */
409
+ function request(data, url, success_cb, error_cb, dataType){
410
+ // Prepare variables.
411
+ var ajax = {
412
+ url: spuvar.ajax_url,
413
+ data: data,
414
+ cache: false,
415
+ type: 'POST',
416
+ dataType: 'json',
417
+ timeout: 30000
418
+ },
419
+ dataType = dataType || false,
420
+ success_cb = success_cb || false,
421
+ error_cb = error_cb || false;
422
+
423
+ // Set ajax url is supplied
424
+ if ( url ) {
425
+ ajax.url = url;
426
+ }
427
+ // Set success callback if supplied.
428
+ if ( success_cb ) {
429
+ ajax.success = success_cb;
430
+ }
431
+
432
+ // Set error callback if supplied.
433
+ if ( error_cb ) {
434
+ ajax.error = error_cb;
435
+ }
436
+
437
+ // Change dataType if supplied.
438
+ if ( dataType ) {
439
+ ajax.dataType = dataType;
440
+ }
441
+ // Make the ajax request.
442
+ $.ajax(ajax);
443
+
444
+ }
445
  /**
446
  * Cookie functions
447
  */
469
  * Social Callbacks
470
  */
471
 
472
+
473
  var SPUfb = false;
474
 
475
  var FbTimer = setInterval(function(){
507
  SPU.hide(box_id);
508
  }
509
  }
 
 
510
 
511
+ function googleCB(a) {
512
 
513
+ if( "on" == a.state ) {
514
+
515
+ var box_id = jQuery('.spu-gogl').data('box-id');
516
+ if( box_id) {
517
+ SPU.hide(box_id);
518
+ }
519
  }
520
  }
521
+ function closeGoogle(a){
522
+ if( "confirm" == a.type )
523
+ {
524
+ var box_id = jQuery('.spu-gogl').data('box-id');
525
+ if( box_id) {
526
+ SPU.hide(box_id);
527
+
528
+ }
529
+ }
530
+ }
531
+ function reload_socials(){
532
+ if( spuvar_social.facebook ) {
533
+
534
+ // reload fb
535
+ try{
536
+ FB.XFBML.parse();
537
+ }catch(ex){}
538
  }
539
+ if( spuvar_social.google ){
540
+
541
+ // reload google
542
+ gapi.plusone.go();
543
+
544
+ }
545
+ if( spuvar_social.twitter ){
546
+
547
+ //reload twitter
548
+ twttr.widgets.load();
549
+ }
550
  }
551
+ })(jQuery);
public/class-social-popup.php CHANGED
@@ -23,7 +23,7 @@ class SocialPopup {
23
  *
24
  * @var string
25
  */
26
- const VERSION = '1.2.2.1';
27
 
28
  /**
29
  * Popups to use acrros files
@@ -67,7 +67,7 @@ class SocialPopup {
67
  *
68
  * @since 1.0.0
69
  */
70
- var $info;
71
 
72
  /**
73
  * Initialize the plugin by setting localization and loading public scripts
@@ -86,6 +86,8 @@ class SocialPopup {
86
  'upgrade_version' => '1.6.4.3',
87
  );
88
 
 
 
89
  $this->spu_settings = apply_filters('spu/settings_page/opts', get_option( 'spu_settings' ) );
90
 
91
  // Load plugin text domain
@@ -96,12 +98,13 @@ class SocialPopup {
96
 
97
  // Register public-facing style sheet and JavaScript.
98
  add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ), 1 );
 
99
 
100
- //check for matches
101
- add_action( 'wp_enqueue_scripts', array( $this, 'check_for_matches' ), 3 );
102
-
103
- //print boxes
104
- add_action( 'wp_footer', array( $this, 'print_boxes' ) );
105
 
106
  //FILTERS
107
  add_filter('spu/get_info', array($this, 'get_info'), 1, 1);
@@ -118,6 +121,7 @@ class SocialPopup {
118
  add_shortcode( 'spu-facebook', array( $this, 'facebook_shortcode' ) );
119
  add_shortcode( 'spu-twitter', array( $this, 'twitter_shortcode' ) );
120
  add_shortcode( 'spu-google', array( $this, 'google_shortcode' ) );
 
121
  }
122
 
123
  /**
@@ -332,26 +336,16 @@ class SocialPopup {
332
  $js_url = plugins_url( 'assets/js/public.js', __FILE__ );
333
  }
334
 
335
-
336
  wp_register_style( 'spu-public-css', plugins_url( 'assets/css/public.css', __FILE__ ), array(), self::VERSION );
337
 
338
  wp_register_script( 'spu-public', $js_url, array( 'jquery' ), self::VERSION, true );
339
 
340
- if( !defined( 'SPU_UNLOAD_FB_JS') && empty( $opts['facebook'] ) ) {
341
 
342
- wp_register_script( 'spu-facebook', 'http://connect.facebook.net/'.get_locale().'/all.js#xfbml=1', array('jquery'), self::VERSION, FALSE);
343
-
344
- }
345
- if( ! defined( 'SPU_UNLOAD_TW_JS') && empty( $opts['twitter'] ) ) {
346
 
347
- wp_register_script( 'spu-twitter', 'http://platform.twitter.com/widgets.js', array('jquery'), self::VERSION, FALSE);
348
-
349
- }
350
- if( ! defined( 'SPU_UNLOAD_GO_JS') && empty( $opts['google'] ) ) {
351
-
352
- wp_register_script( 'spu-google', 'https://apis.google.com/js/plusone.js', array('jquery'), self::VERSION, FALSE);
353
 
354
- }
355
  }
356
 
357
  /**
@@ -362,14 +356,10 @@ class SocialPopup {
362
  public function check_for_matches() {
363
 
364
  global $wpdb;
365
- global $spu_matches;
366
- global $total_shortcodes;
367
 
368
- include_once( SPU_PLUGIN_DIR . 'public/includes/class-spu-rules.php' );
369
-
370
- $spu_rules = new Spu_Rules();
371
 
372
- $matches = $facebook = $twitter = $google = false;
373
 
374
  //Grab all popups ids
375
  $spu_ids = $wpdb->get_results( "SELECT ID, post_content FROM $wpdb->posts WHERE post_type='spucpt' AND post_status='publish'");
@@ -379,64 +369,96 @@ class SocialPopup {
379
 
380
  $match = $spu_rules->check_rules( $rules );
381
  if( $match ) {
382
- $matches = true;
383
  $spu_matches[] = $spu->ID;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
 
385
- $total_shortcodes[$spu->ID] = array();
386
- $total_shortcodes[$spu->ID][0] = 0;
387
-
388
- //if we have matches we check for shortcodes to add scripts later
389
- if( has_shortcode( $spu->post_content, 'spu-facebook' ) ){
390
- $facebook = true;
391
- $total_shortcodes[$spu->ID][0]++;
392
- }
393
- if( has_shortcode( $spu->post_content, 'spu-twitter' ) ){
394
- $twitter = true;
395
- $total_shortcodes[$spu->ID][0]++;
396
- }
397
- if( has_shortcode( $spu->post_content, 'spu-google' ) ){
398
- $google = true;
399
- $total_shortcodes[$spu->ID][0]++;
400
- $total_shortcodes[$spu->ID]['google'] = true;
401
- }
402
  }
 
403
  }
 
404
 
405
- if( $matches ) {
406
 
407
-
408
- wp_enqueue_script('spu-public');
409
- wp_enqueue_style('spu-public-css');
410
- wp_localize_script( 'spu-public', 'spuvar',
411
- array(
412
- 'is_admin' => current_user_can( 'administrator' ),
413
- 'disable_style' => @$this->spu_settings['shortcodes_style'],
414
- 'safe_mode' => @$this->spu_settings['safe'],
415
- 'seconds_confirmation_close' => apply_filters( 'spu/spuvar/seconds_confirmation_close', 5 ),
416
- )
417
- );
418
 
419
- if( $facebook ){
420
- wp_enqueue_script( 'spu-facebook' );
421
  }
422
- if( $twitter ){
423
- wp_enqueue_script( 'spu-twitter' );
424
- }
425
 
426
- if( $google ){
427
- wp_enqueue_script( 'spu-google' );
428
- }
429
  }
430
-
431
-
432
- }
 
 
 
 
 
 
 
433
 
 
 
 
 
 
 
 
434
 
435
  /**
436
  * [facebook_shortcode description]
437
- * @param {[type]} $content [description]
438
- * @param {[type]} $atts [description]
439
- * @return {[type]} [description]
 
 
 
 
440
  */
441
  function facebook_shortcode( $atts, $content ) {
442
 
@@ -466,9 +488,9 @@ class SocialPopup {
466
 
467
  /**
468
  * [twitter_shortcode description]
469
- * @param [type] $content [description]
470
- * @param [type] $atts [description]
471
- * @return [type] [description]
472
  */
473
  function twitter_shortcode( $atts, $content ) {
474
 
@@ -487,7 +509,7 @@ class SocialPopup {
487
  * [google_shortcode description]
488
  * @param [type] $atts [description]
489
  * @param [type] $content [description]
490
- * @return [type] [description]
491
  */
492
  function google_shortcode( $atts, $content ) {
493
  extract( shortcode_atts( array(
@@ -510,6 +532,15 @@ class SocialPopup {
510
  return '<div class="spu-google spu-shortcode"><div class="g-plusone" data-callback="googleCB" data-onendinteraction="closeGoogle" data-recommendations="false" data-annotation="'.$annotation.'" data-size="'.$size.'" data-href="'.$url.'"></div></div>';
511
 
512
  }
 
 
 
 
 
 
 
 
 
513
 
514
  /**
515
  * Returns plugin info
@@ -542,27 +573,27 @@ class SocialPopup {
542
 
543
  /**
544
  * Print the actual popup
545
- * @param int $spu_id post id of the popup
546
- * @return echo the popup
547
  */
548
  function print_boxes( ) {
549
 
550
- global $spu_matches;
551
- global $total_shortcodes;
552
-
553
- //if we dont' have matches stop here
554
- if( empty( $spu_matches) )
555
- return;
556
- // Include Helper class
557
- include_once( SPU_PLUGIN_DIR . 'includes/class-spu-helper.php' );
558
-
559
- foreach ($spu_matches as $spu_id ) {
560
 
561
- include( 'views/popup.php');
 
 
 
562
 
563
- } //endforeach
564
- echo '<div id="fb-root" class=" fb_reset"></div>';
565
 
 
 
 
 
 
 
 
 
566
  }
567
 
568
  /**
@@ -576,4 +607,37 @@ class SocialPopup {
576
 
577
  }
578
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
579
  }
23
  *
24
  * @var string
25
  */
26
+ const VERSION = '1.2.3';
27
 
28
  /**
29
  * Popups to use acrros files
67
  *
68
  * @since 1.0.0
69
  */
70
+ public $info;
71
 
72
  /**
73
  * Initialize the plugin by setting localization and loading public scripts
86
  'upgrade_version' => '1.6.4.3',
87
  );
88
 
89
+ $this->load_dependencies();
90
+
91
  $this->spu_settings = apply_filters('spu/settings_page/opts', get_option( 'spu_settings' ) );
92
 
93
  // Load plugin text domain
98
 
99
  // Register public-facing style sheet and JavaScript.
100
  add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ), 1 );
101
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ));
102
 
103
+ if( !isset($this->spu_settings['ajax_mode'] ) ) {
104
+ //print boxes
105
+ add_action( 'wp_footer', array( $this, 'print_boxes' ) );
106
+ }
107
+ add_action( 'init', array( $this, 'register_spu_ajax' ), 10 );
108
 
109
  //FILTERS
110
  add_filter('spu/get_info', array($this, 'get_info'), 1, 1);
121
  add_shortcode( 'spu-facebook', array( $this, 'facebook_shortcode' ) );
122
  add_shortcode( 'spu-twitter', array( $this, 'twitter_shortcode' ) );
123
  add_shortcode( 'spu-google', array( $this, 'google_shortcode' ) );
124
+ add_shortcode( 'spu-close', array( $this, 'close_shortcode' ) );
125
  }
126
 
127
  /**
336
  $js_url = plugins_url( 'assets/js/public.js', __FILE__ );
337
  }
338
 
 
339
  wp_register_style( 'spu-public-css', plugins_url( 'assets/css/public.css', __FILE__ ), array(), self::VERSION );
340
 
341
  wp_register_script( 'spu-public', $js_url, array( 'jquery' ), self::VERSION, true );
342
 
343
+ wp_register_script( 'spu-facebook', 'http://connect.facebook.net/'.get_locale().'/all.js#xfbml=1', array('jquery'), self::VERSION, FALSE);
344
 
345
+ wp_register_script( 'spu-twitter', 'http://platform.twitter.com/widgets.js', array('jquery'), self::VERSION, FALSE);
 
 
 
346
 
347
+ wp_register_script( 'spu-google', 'https://apis.google.com/js/plusone.js', array('jquery'), self::VERSION, FALSE);
 
 
 
 
 
348
 
 
349
  }
350
 
351
  /**
356
  public function check_for_matches() {
357
 
358
  global $wpdb;
 
 
359
 
360
+ $spu_matches = false;
 
 
361
 
362
+ $spu_rules = new Spu_Rules();
363
 
364
  //Grab all popups ids
365
  $spu_ids = $wpdb->get_results( "SELECT ID, post_content FROM $wpdb->posts WHERE post_type='spucpt' AND post_status='publish'");
369
 
370
  $match = $spu_rules->check_rules( $rules );
371
  if( $match ) {
 
372
  $spu_matches[] = $spu->ID;
373
+ }
374
+ }
375
+
376
+ return $spu_matches;
377
+ }
378
+
379
+ /**
380
+ * Function that enqueue all needed scritps and styles
381
+ * @since 1.3
382
+ */
383
+ public function enqueue_scripts() {
384
+
385
+ wp_enqueue_script('spu-public');
386
+ wp_enqueue_style('spu-public-css');
387
+ wp_localize_script( 'spu-public', 'spuvar',
388
+ array(
389
+ 'is_admin' => current_user_can( 'administrator' ),
390
+ 'disable_style' => @$this->spu_settings['shortcodes_style'],
391
+ 'safe_mode' => @$this->spu_settings['safe'],
392
+ 'ajax_mode' => @$this->spu_settings['ajax_mode'],
393
+ 'ajax_url' => admin_url('admin-ajax.php'),
394
+ 'site_url' => site_url(),
395
+ 'pid' => get_queried_object_id(),
396
+ 'is_front_page' => is_front_page(),
397
+ 'seconds_confirmation_close' => apply_filters( 'spu/spuvar/seconds_confirmation_close', 5 ),
398
+ )
399
+ );
400
+ $this->enqueue_social_shortcodes();
401
+ }
402
+
403
+ /**
404
+ * Function that runs the different checks to see if social is enqueue or not
405
+ * @since 1.3
406
+ */
407
+ private function enqueue_social_shortcodes(){
408
+ global $wpdb;
409
+
410
+ $spuvar_social = '';
411
+
412
+ // Check if defined or remove js in options
413
+ if( !defined( 'SPU_UNLOAD_FB_JS') && empty( $opts['facebook'] ) ) {
414
+
415
+ // Check if any popup have facebook, then enqueue js
416
+ if( $fb = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = 'spu_fb' " ) ) {
417
 
418
+ wp_enqueue_script( 'spu-facebook');
419
+ $spuvar_social['facebook'] = true;
420
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
+
423
  }
424
+ if( ! defined( 'SPU_UNLOAD_TW_JS') && empty( $opts['twitter'] ) ) {
425
 
426
+ if( $fb = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key ='spu_tw' " ) ) {
427
 
428
+ wp_enqueue_script( 'spu-twitter');
429
+ $spuvar_social['twitter'] = true;
 
 
 
 
 
 
 
 
 
430
 
 
 
431
  }
 
 
 
432
 
 
 
 
433
  }
434
+ if( ! defined( 'SPU_UNLOAD_GO_JS') && empty( $opts['google'] ) ) {
435
+
436
+ if( $fb = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key ='spu_google' " ) ) {
437
+
438
+ wp_enqueue_script( 'spu-google');
439
+ $spuvar_social['google'] = true;
440
+ }
441
+
442
+ }
443
+ wp_localize_script( 'jquery', 'spuvar_social', $spuvar_social);
444
 
445
+ //also include gravity forms if needed
446
+ if( $gf = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key ='spu_gravity' " ) ) {
447
+
448
+ gravity_form_enqueue_scripts($gf, true);
449
+
450
+ }
451
+ }
452
 
453
  /**
454
  * [facebook_shortcode description]
455
+ *
456
+ * @param $atts
457
+ * @param $content
458
+ *
459
+ * @internal param $ $content [description] $content [description]
460
+ * @internal param $atts [description] $atts [description]
461
+ * @return string [description]
462
  */
463
  function facebook_shortcode( $atts, $content ) {
464
 
488
 
489
  /**
490
  * [twitter_shortcode description]
491
+ * @param string $content [description]
492
+ * @param array $atts [description]
493
+ * @return string [description]
494
  */
495
  function twitter_shortcode( $atts, $content ) {
496
 
509
  * [google_shortcode description]
510
  * @param [type] $atts [description]
511
  * @param [type] $content [description]
512
+ * @return string [description]
513
  */
514
  function google_shortcode( $atts, $content ) {
515
  extract( shortcode_atts( array(
532
  return '<div class="spu-google spu-shortcode"><div class="g-plusone" data-callback="googleCB" data-onendinteraction="closeGoogle" data-recommendations="false" data-annotation="'.$annotation.'" data-size="'.$size.'" data-href="'.$url.'"></div></div>';
533
 
534
  }
535
+
536
+ function close_shortcode( $atts, $content ) {
537
+ extract( shortcode_atts( array(
538
+ 'class' => 'button-primary',
539
+ 'text' => 'Close',
540
+ ), $atts ) );
541
+
542
+ return '<button class="spu-close-popup '.$class.'">'.$text.'</button>';
543
+ }
544
 
545
  /**
546
  * Returns plugin info
573
 
574
  /**
575
  * Print the actual popup
576
+ * @return mixed echo popup html
 
577
  */
578
  function print_boxes( ) {
579
 
580
+ $spu_matches = $this->check_for_matches();
 
 
 
 
 
 
 
 
 
581
 
582
+ //if we have matches continue
583
+ if( ! empty( $spu_matches) ) {
584
+
585
+ foreach ($spu_matches as $spu_id ) {
586
 
587
+ include( 'views/popup.php');
 
588
 
589
+ } //endforeach
590
+ echo '<div id="fb-root" class=" fb_reset"></div>';
591
+
592
+ }
593
+
594
+ if( defined( 'DOING_AJAX' ) ) {
595
+ die(); //we are in ajax mode
596
+ }
597
  }
598
 
599
  /**
607
 
608
  }
609
 
610
+ /**
611
+ * Load necessary files
612
+ * @since 1.2.3
613
+ */
614
+ private function load_dependencies(){
615
+ // Include Helper class
616
+ require_once( SPU_PLUGIN_DIR . 'includes/class-spu-helper.php' );
617
+ // Include Rules Class
618
+ require_once( SPU_PLUGIN_DIR . 'public/includes/class-spu-rules.php' );
619
+ }
620
+
621
+ /**
622
+ * Custom ajax hook. Wp_ajax won't let us do_shortcode for example
623
+ * @return mixed Prints all spus
624
+ */
625
+ function register_spu_ajax() {
626
+
627
+ if( is_admin() )
628
+ return;
629
+
630
+ if ( empty( $_POST['spu_action'] ) || $_POST['spu_action'] != 'spu_load' ) {
631
+
632
+ return;
633
+
634
+ }
635
+
636
+ define( 'DOING_AJAX', TRUE );
637
+
638
+ $this->print_boxes();
639
+
640
+ die();
641
+ }
642
+
643
  }
public/includes/class-spu-rules.php CHANGED
@@ -8,7 +8,18 @@
8
 
9
  class Spu_Rules
10
  {
11
-
 
 
 
 
 
 
 
 
 
 
 
12
  /*
13
  * __construct
14
  * Add all the filters to use later
@@ -16,7 +27,7 @@ class Spu_Rules
16
 
17
  function __construct()
18
  {
19
-
20
 
21
  // User
22
  add_filter('spu/rules/rule_match/user_type', array($this, 'rule_match_user_type'), 10, 2);
@@ -43,6 +54,18 @@ class Spu_Rules
43
  add_filter('spu/rules/rule_match/mobiles', array($this, 'rule_match_mobiles'), 10, 2);
44
  add_filter('spu/rules/rule_match/tablets', array($this, 'rule_match_tablets'), 10, 2);
45
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  }
48
 
@@ -56,13 +79,6 @@ class Spu_Rules
56
  function check_rules( $rules = '' )
57
  {
58
 
59
- // Parse values
60
- #$options = apply_filters( 'spu/parse_types' );
61
-
62
-
63
- // find all acf objects
64
- #$acfs = apply_filters('spu/get_field_groups', array());
65
-
66
  //if no rules, add the box
67
  $add_box = true;
68
 
@@ -200,7 +216,7 @@ class Spu_Rules
200
  */
201
  function rule_match_search_engine( $match, $rule ) {
202
 
203
- $ref = isset($_SERVER['HTTP_REFERRER']) ? $_SERVER['HTTP_REFERRER'] : '';
204
 
205
  $SE = apply_filters( 'spu/rules/search_engines', array('/search?', '.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.', '.bing.' ) );
206
 
@@ -224,7 +240,7 @@ class Spu_Rules
224
  function rule_match_same_site( $match, $rule ) {
225
 
226
 
227
- $ref = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
228
 
229
  $internal = str_replace( array( 'http://','https://' ), '', site_url() );
230
 
@@ -277,8 +293,8 @@ class Spu_Rules
277
 
278
  function rule_match_post( $match, $rule )
279
  {
280
- global $post;
281
- $post_id = isset( $post->ID ) ? $post->ID : '';
282
 
283
  if($rule['operator'] == "==")
284
  {
@@ -302,19 +318,20 @@ class Spu_Rules
302
 
303
  function rule_match_page_type( $match, $rule )
304
  {
305
- global $post;
306
 
307
- $post_id = isset( $post->ID ) ? $post->ID : '';
308
 
309
  $post = get_post( $post_id );
310
 
311
  $post_parent = isset( $post->post_parent ) ? $post->post_parent : '';
 
312
  $post_type = $this->get_post_type();
313
 
314
  if( $rule['value'] == 'front_page') {
315
 
316
  $front_page = (int) get_option('page_on_front');
317
-
318
  if( $front_page !== 0 ) {
319
 
320
  if($rule['operator'] == "==") {
@@ -327,16 +344,34 @@ class Spu_Rules
327
 
328
  }
329
  } else {
330
-
331
- if($rule['operator'] == "==") {
332
-
333
- $match = is_home();
334
-
335
- } elseif($rule['operator'] == "!=") {
336
-
337
- $match = !is_home();
338
-
339
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
  }
342
 
@@ -371,7 +406,8 @@ class Spu_Rules
371
 
372
  }
373
  elseif( $rule['value'] == 'top_level') {
374
- $post_parent = $post_parent;
 
375
  if( $options['page_parent'] )
376
  {
377
  $post_parent = $options['page_parent'];
@@ -442,16 +478,16 @@ class Spu_Rules
442
 
443
  function rule_match_page_parent( $match, $rule )
444
  {
445
- global $post;
446
  // validation
447
- if( !$post->ID )
448
  {
449
  return false;
450
  }
451
 
452
 
453
  // vars
454
- $post = get_post( $post->ID );
455
 
456
  $post_parent = $post->post_parent;
457
  if( $options['page_parent'] )
@@ -483,14 +519,14 @@ class Spu_Rules
483
 
484
  function rule_match_page_template( $match, $rule )
485
  {
486
- global $post;
487
 
488
- $page_template = get_post_meta( $post->ID, '_wp_page_template', true );
489
 
490
 
491
  if( ! $page_template ) {
492
 
493
- if( 'page' == get_post_type( $post->ID ) ) {
494
 
495
  $page_template = "default";
496
 
@@ -520,10 +556,10 @@ class Spu_Rules
520
 
521
  function rule_match_post_category( $match, $rule )
522
  {
523
- global $post;
524
 
525
  // validate
526
- if( !$post->ID )
527
  {
528
  return false;
529
  }
@@ -535,7 +571,7 @@ class Spu_Rules
535
  // vars
536
  $taxonomies = get_object_taxonomies( $post_type );
537
 
538
- $all_terms = get_the_terms( $post->ID, 'category' );
539
  if($all_terms)
540
  {
541
  foreach($all_terms as $all_term)
@@ -559,7 +595,7 @@ class Spu_Rules
559
  {
560
  $match = false;
561
 
562
- if($terms)
563
  {
564
  if( in_array($rule['value'], $terms) )
565
  {
@@ -637,10 +673,10 @@ class Spu_Rules
637
 
638
  function rule_match_post_format( $match, $rule )
639
  {
640
- global $post;
641
 
642
  // validate
643
- if( !$post->ID )
644
  {
645
  return false;
646
  }
@@ -651,7 +687,7 @@ class Spu_Rules
651
  // does post_type support 'post-format'
652
  if( post_type_supports( $post_type, 'post-formats' ) )
653
  {
654
- $post_format = get_post_format( $post->ID );
655
 
656
  if( $post_format === false )
657
  {
@@ -686,17 +722,17 @@ class Spu_Rules
686
 
687
  function rule_match_post_status( $match, $rule )
688
  {
689
- global $post;
690
 
691
  // validate
692
- if( !$post->ID )
693
  {
694
  return false;
695
  }
696
 
697
 
698
  // vars
699
- $post_status = get_post_status( $post->ID );
700
 
701
 
702
  // auto-draft = draft
@@ -732,9 +768,9 @@ class Spu_Rules
732
 
733
  function rule_match_taxonomy( $match, $rule )
734
  {
735
- global $post;
736
  // validate
737
- if( !$post->ID )
738
  {
739
  return false;
740
  }
@@ -750,7 +786,7 @@ class Spu_Rules
750
  {
751
  foreach( $taxonomies as $tax )
752
  {
753
- $all_terms = get_the_terms( $post->ID, $tax );
754
  if($all_terms)
755
  {
756
  foreach($all_terms as $all_term)
@@ -814,9 +850,9 @@ class Spu_Rules
814
  function get_post_type(){
815
  global $wp_query;
816
 
817
- $post_type = $wp_query->query_vars['post_type'] ;
818
 
819
- $post_type = empty( $post_type ) ? get_post_type() : $post_type;
820
 
821
  return $post_type;
822
  }
8
 
9
  class Spu_Rules
10
  {
11
+ /**
12
+ * post id used to check rules
13
+ * @var int
14
+ */
15
+ protected $post_id;
16
+
17
+ /**
18
+ * referred using in ajax calls
19
+ * @var string
20
+ */
21
+ protected $referrer;
22
+
23
  /*
24
  * __construct
25
  * Add all the filters to use later
27
 
28
  function __construct()
29
  {
30
+ global $post;
31
 
32
  // User
33
  add_filter('spu/rules/rule_match/user_type', array($this, 'rule_match_user_type'), 10, 2);
54
  add_filter('spu/rules/rule_match/mobiles', array($this, 'rule_match_mobiles'), 10, 2);
55
  add_filter('spu/rules/rule_match/tablets', array($this, 'rule_match_tablets'), 10, 2);
56
 
57
+ $this->post_id = isset( $post->ID ) ? $post->ID : '';
58
+ $this->referrer = isset($_SERVER['HTTP_REFERRER']) ? $_SERVER['HTTP_REFERRER'] : '';
59
+
60
+ if( defined('DOING_AJAX') ) {
61
+
62
+ if( isset( $_REQUEST['pid'] ) ) {
63
+ $this->post_id = $_REQUEST['pid'];
64
+ }
65
+ if( isset( $_REQUEST['referrer'] ) ) {
66
+ $this->referrer = $_REQUEST['referrer'];
67
+ }
68
+ }
69
 
70
  }
71
 
79
  function check_rules( $rules = '' )
80
  {
81
 
 
 
 
 
 
 
 
82
  //if no rules, add the box
83
  $add_box = true;
84
 
216
  */
217
  function rule_match_search_engine( $match, $rule ) {
218
 
219
+ $ref = $this->referrer;
220
 
221
  $SE = apply_filters( 'spu/rules/search_engines', array('/search?', '.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.', '.bing.' ) );
222
 
240
  function rule_match_same_site( $match, $rule ) {
241
 
242
 
243
+ $ref = $this->referrer;
244
 
245
  $internal = str_replace( array( 'http://','https://' ), '', site_url() );
246
 
293
 
294
  function rule_match_post( $match, $rule )
295
  {
296
+
297
+ $post_id = $this->post_id;
298
 
299
  if($rule['operator'] == "==")
300
  {
318
 
319
  function rule_match_page_type( $match, $rule )
320
  {
321
+
322
 
323
+ $post_id = $this->post_id;
324
 
325
  $post = get_post( $post_id );
326
 
327
  $post_parent = isset( $post->post_parent ) ? $post->post_parent : '';
328
+
329
  $post_type = $this->get_post_type();
330
 
331
  if( $rule['value'] == 'front_page') {
332
 
333
  $front_page = (int) get_option('page_on_front');
334
+
335
  if( $front_page !== 0 ) {
336
 
337
  if($rule['operator'] == "==") {
344
 
345
  }
346
  } else {
347
+ // if doing ajax is_home won't work so we do a workaround
348
+ if( defined( 'DOING_AJAX') ) {
349
+
350
+ $front_page = get_option( 'show_on_front' );
351
+
352
+ if($rule['operator'] == "==") {
353
+
354
+ $match = ( 'posts' == $front_page && $post_id == 0 );
355
+
356
+ } elseif($rule['operator'] == "!=") {
357
+
358
+ $match = !( 'posts' == $front_page && $post_id == 0 );
359
+
360
+ }
361
+
362
+
363
+ } else {
364
+
365
+ if($rule['operator'] == "==") {
366
+
367
+ $match = is_home();
368
+
369
+ } elseif($rule['operator'] == "!=") {
370
+
371
+ $match = !is_home();
372
+
373
+ }
374
+ }
375
 
376
  }
377
 
406
 
407
  }
408
  elseif( $rule['value'] == 'top_level') {
409
+
410
+
411
  if( $options['page_parent'] )
412
  {
413
  $post_parent = $options['page_parent'];
478
 
479
  function rule_match_page_parent( $match, $rule )
480
  {
481
+
482
  // validation
483
+ if( !$this->post_id )
484
  {
485
  return false;
486
  }
487
 
488
 
489
  // vars
490
+ $post = get_post( $this->post_id );
491
 
492
  $post_parent = $post->post_parent;
493
  if( $options['page_parent'] )
519
 
520
  function rule_match_page_template( $match, $rule )
521
  {
522
+
523
 
524
+ $page_template = get_post_meta( $this->post_id, '_wp_page_template', true );
525
 
526
 
527
  if( ! $page_template ) {
528
 
529
+ if( 'page' == get_post_type( $this->post_id ) ) {
530
 
531
  $page_template = "default";
532
 
556
 
557
  function rule_match_post_category( $match, $rule )
558
  {
559
+
560
 
561
  // validate
562
+ if( !$this->post_id )
563
  {
564
  return false;
565
  }
571
  // vars
572
  $taxonomies = get_object_taxonomies( $post_type );
573
 
574
+ $all_terms = get_the_terms( $this->post_id, 'category' );
575
  if($all_terms)
576
  {
577
  foreach($all_terms as $all_term)
595
  {
596
  $match = false;
597
 
598
+ if(!empty($terms))
599
  {
600
  if( in_array($rule['value'], $terms) )
601
  {
673
 
674
  function rule_match_post_format( $match, $rule )
675
  {
676
+
677
 
678
  // validate
679
+ if( !$this->post_id )
680
  {
681
  return false;
682
  }
687
  // does post_type support 'post-format'
688
  if( post_type_supports( $post_type, 'post-formats' ) )
689
  {
690
+ $post_format = get_post_format( $this->post_id );
691
 
692
  if( $post_format === false )
693
  {
722
 
723
  function rule_match_post_status( $match, $rule )
724
  {
725
+
726
 
727
  // validate
728
+ if( !$this->post_id )
729
  {
730
  return false;
731
  }
732
 
733
 
734
  // vars
735
+ $post_status = get_post_status( $this->post_id );
736
 
737
 
738
  // auto-draft = draft
768
 
769
  function rule_match_taxonomy( $match, $rule )
770
  {
771
+
772
  // validate
773
+ if( !$this->post_id )
774
  {
775
  return false;
776
  }
786
  {
787
  foreach( $taxonomies as $tax )
788
  {
789
+ $all_terms = get_the_terms( $this->post_id, $tax );
790
  if($all_terms)
791
  {
792
  foreach($all_terms as $all_term)
850
  function get_post_type(){
851
  global $wp_query;
852
 
853
+ $post_type = isset( $wp_query->query_vars['post_type'] ) ? $wp_query->query_vars['post_type'] : '';
854
 
855
+ $post_type = empty( $post_type ) ? get_post_type() : '';
856
 
857
  return $post_type;
858
  }
public/views/popup.php CHANGED
@@ -47,14 +47,14 @@ do_action( 'spu/popup/before_popup', $box, $opts, $css);
47
  }
48
  </style>
49
  <div class="spu-bg" id="spu-bg-<?php echo $box->ID; ?>"></div>
50
- <div class="spu-box spu-<?php echo esc_attr( $opts['css']['position'] ); ?> spu-total-<?php echo $total_shortcodes[$box->ID][0];?> <?php echo isset( $total_shortcodes[$box->ID]['google'] ) ? 'spu-gogl' : '';?>" id="spu-<?php echo $box->ID; ?>"
51
  data-box-id="<?php echo $box->ID ; ?>" data-trigger="<?php echo esc_attr( $opts['trigger'] ); ?>"
52
  data-trigger-number="<?php echo esc_attr( absint( $opts['trigger_number'] ) ); ?>"
53
  data-spuanimation="<?php echo esc_attr($opts['animation']); ?>" data-cookie="<?php echo esc_attr( absint ( $opts['cookie'] ) ); ?>" data-test-mode="<?php echo esc_attr($opts['test_mode']); ?>"
54
- data-auto-hide="<?php echo esc_attr($opts['auto_hide']); ?>" data-bgopa="<?php echo esc_attr($css['bgopacity']);?>" data-total="<?php echo $total_shortcodes[$box->ID][0];?>"
55
  style="left:-99999px" <?php echo apply_filters( 'spu/popup/data_attrs', $data_attrs, $opts);?>>
56
  <div class="spu-content"><?php echo $content; ?></div>
57
- <span class="spu-close">&times;</span>
58
  <span class="spu-timer"></span>
59
  </div>
60
  <!-- / Popups Box -->
47
  }
48
  </style>
49
  <div class="spu-bg" id="spu-bg-<?php echo $box->ID; ?>"></div>
50
+ <div class="spu-box spu-<?php echo esc_attr( $opts['css']['position'] ); ?> spu-total-<?php echo get_post_meta($box->ID, 'spu_social',true);?> <?php echo get_post_meta($box->ID, 'spu_google',true) ? 'spu-gogl' : '';?>" id="spu-<?php echo $box->ID; ?>"
51
  data-box-id="<?php echo $box->ID ; ?>" data-trigger="<?php echo esc_attr( $opts['trigger'] ); ?>"
52
  data-trigger-number="<?php echo esc_attr( absint( $opts['trigger_number'] ) ); ?>"
53
  data-spuanimation="<?php echo esc_attr($opts['animation']); ?>" data-cookie="<?php echo esc_attr( absint ( $opts['cookie'] ) ); ?>" data-test-mode="<?php echo esc_attr($opts['test_mode']); ?>"
54
+ data-auto-hide="<?php echo esc_attr($opts['auto_hide']); ?>" data-bgopa="<?php echo esc_attr($css['bgopacity']);?>" data-total="<?php echo get_post_meta($box->ID, 'spu_social',true);?>"
55
  style="left:-99999px" <?php echo apply_filters( 'spu/popup/data_attrs', $data_attrs, $opts);?>>
56
  <div class="spu-content"><?php echo $content; ?></div>
57
+ <span class="spu-close spu-close-popup">&times;</span>
58
  <span class="spu-timer"></span>
59
  </div>
60
  <!-- / Popups Box -->