Popups – WordPress Popup - Version 1.2.3.4

Version Description

  • Added referrer display rule
  • Fixed spuvar_social undefined when not using wordpress jquery
  • Fixed wpml support in ajax mode
  • Added trigger events in javascript so devs can hook in
  • Added geotargeting support in popups using Geotargeting plugin
  • Fixed undefined variable in admin
Download this release

Release Info

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

Code changes from version 1.2.3.3 to 1.2.3.4

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.1
7
- Stable tag: 1.2.3.3
8
  Text Domain: spucpt
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -24,10 +24,12 @@ There are multiple display filters that can be combined:
24
  * Filter users that never commented
25
  * Filter users that arrived via another page on your site
26
  * Filter users via roles
 
27
  * Show popup to logged / non logged users
28
  * Show or not to mobile and tablet users
29
  * Show depending on post type, post template, post name, post format, post status and post taxonomy
30
  * Show depending on page template, if page is parent, page name, page type
 
31
 
32
  = Available Settings =
33
 
@@ -104,6 +106,15 @@ Yes if you need to debug you can use uncompressed javascript by addings ([this c
104
 
105
  == Changelog ==
106
 
 
 
 
 
 
 
 
 
 
107
  = 1.2.3.3 =
108
 
109
  * Added Serbo-Croatian language
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.1
7
+ Stable tag: 1.2.3.4
8
  Text Domain: spucpt
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
24
  * Filter users that never commented
25
  * Filter users that arrived via another page on your site
26
  * Filter users via roles
27
+ * Show popup depending on referrer
28
  * Show popup to logged / non logged users
29
  * Show or not to mobile and tablet users
30
  * Show depending on post type, post template, post name, post format, post status and post taxonomy
31
  * Show depending on page template, if page is parent, page name, page type
32
+ * Geotarget popups using the [Geotargeting plugin](http://wp.timersys.com/geotargeting/)
33
 
34
  = Available Settings =
35
 
106
 
107
  == Changelog ==
108
 
109
+ = 1.2.3.4 =
110
+
111
+ * Added referrer display rule
112
+ * Fixed spuvar_social undefined when not using wordpress jquery
113
+ * Fixed wpml support in ajax mode
114
+ * Added trigger events in javascript so devs can hook in
115
+ * Added geotargeting support in popups using [Geotargeting plugin](http://wp.timersys.com/geotargeting/)
116
+ * Fixed undefined variable in admin
117
+
118
  = 1.2.3.3 =
119
 
120
  * Added Serbo-Croatian language
admin/views/metabox-rules.php CHANGED
@@ -64,6 +64,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
64
  'page_template' => __("Page Template", $this->plugin_slug ),
65
  ),
66
  __("Other", $this->plugin_slug ) => array(
 
67
  'mobiles' => __("Mobile Phone", $this->plugin_slug ),
68
  'tablets' => __("Tablet", $this->plugin_slug ),
69
  )
@@ -113,7 +114,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
113
  $args = array(
114
  'group_id' => $group_id,
115
  'rule_id' => $rule_id,
116
- 'value' => $rule['value'],
117
  'name' => 'spu_rules[' . $group_id . '][' . $rule_id . '][value]',
118
  'param' => $rule['param']
119
  );
64
  'page_template' => __("Page Template", $this->plugin_slug ),
65
  ),
66
  __("Other", $this->plugin_slug ) => array(
67
+ 'referrer' => __("Referrer", $this->plugin_slug ),
68
  'mobiles' => __("Mobile Phone", $this->plugin_slug ),
69
  'tablets' => __("Tablet", $this->plugin_slug ),
70
  )
114
  $args = array(
115
  'group_id' => $group_id,
116
  'rule_id' => $rule_id,
117
+ 'value' => !empty($rule['value']) ? $rule['value'] : '',
118
  'name' => 'spu_rules[' . $group_id . '][' . $rule_id . '][value]',
119
  'param' => $rule['param']
120
  );
includes/class-spu-helper.php CHANGED
@@ -266,9 +266,14 @@ class Spu_Helper {
266
  // allow custom rules rules
267
  $choices = apply_filters( 'spu/rules/rule_values/' . $options['param'], $choices );
268
 
269
- self::print_select( $choices, $options );
270
-
271
-
 
 
 
 
 
272
  // ajax?
273
  if( $is_ajax )
274
  {
@@ -323,7 +328,7 @@ class Spu_Helper {
323
  {
324
  foreach( $choices as $key => $value )
325
  {
326
- if( $optgroup )
327
  {
328
  // this select is grouped with optgroup
329
  if($key != '') echo '<optgroup label="'.$key.'">';
@@ -354,6 +359,14 @@ class Spu_Helper {
354
 
355
  }
356
 
 
 
 
 
 
 
 
 
357
  /**
358
  * Return the box options
359
  * @param int $id spucpt id
266
  // allow custom rules rules
267
  $choices = apply_filters( 'spu/rules/rule_values/' . $options['param'], $choices );
268
 
269
+ if( $options['param'] == 'referrer' ) {
270
+ self::print_textfield( $options );
271
+ } else {
272
+ self::print_select( $choices, $options );
273
+ }
274
+
275
+
276
+
277
  // ajax?
278
  if( $is_ajax )
279
  {
328
  {
329
  foreach( $choices as $key => $value )
330
  {
331
+ if( isset($optgroup) )
332
  {
333
  // this select is grouped with optgroup
334
  if($key != '') echo '<optgroup label="'.$key.'">';
359
 
360
  }
361
 
362
+ /**
363
+ * Prints a text field rule
364
+ * @param $options
365
+ */
366
+ static function print_textfield( $options ) {
367
+ echo '<input type="text" name="'.$options['name'].'" value="'.$options['value'].'" id="spu_rule_'.$options['group_id'].'_rule_'.$options['rule_id'].'" />';
368
+ }
369
+
370
  /**
371
  * Return the box options
372
  * @param int $id spucpt id
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.3.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
11
  * @socialpopup
12
  * Plugin Name: Popups - WordPress Popup
13
  * Plugin URI: http://www.timersys.com/free-plugins/social-popup/
14
+ * Version: 1.2.3.4
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/js/min/public-min.js CHANGED
@@ -1 +1 @@
1
- !function($){"use strict";function t(t,i,e,o,n){var a={url:spuvar.ajax_url,data:t,cache:!1,type:"POST",dataType:"json",timeout:3e4},n=n||!1,e=e||!1,o=o||!1;i&&(a.url=i),e&&(a.success=e),o&&(a.error=o),n&&(a.dataType=n),$.ajax(a)}function i(t,i,e){if(e){var o=new Date;o.setTime(o.getTime()+24*e*60*60*1e3);var n="; expires="+o.toGMTString()}else var n="";document.cookie=t+"="+i+n+"; path=/"}function e(t){for(var i=t+"=",e=document.cookie.split(";"),o=0;o<e.length;o++){for(var n=e[o];" "==n.charAt(0);)n=n.substring(1,n.length);if(0==n.indexOf(i))return n.substring(i.length,n.length)}return null}function o(){FB.Event.subscribe("edge.create",function(t,i){var e=$(i).parents(".spu-box").data("box-id");e&&SPU.hide(e)}),l=!0,clearInterval(h)}function n(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)}}function s(){if(spuvar_social.facebook)try{FB.XFBML.parse()}catch(t){}spuvar_social.google&&gapi.plusone.go(),spuvar_social.twitter&&twttr.widgets.load()}function d(){$(".spu-box form").each(function(){var t=$(this).attr("action");$(this).attr("action",t.replace("?spu_action=spu_load",""))})}var u=function(){function o(t){var i=u[t],e=$(window).width(),o=$(window).height(),n=i.outerHeight(),a=i.outerWidth(),r=i.data("width"),s=0,d=o/2-n/2,c="fixed",f=$(document).scrollTop();i.hasClass("spu-centered")&&(e>r&&(s=e/2-a/2),i.css({left:s,position:c,top:d})),n+50>o&&(c="absolute",d=f,i.css({position:c,top:d,bottom:"auto"}))}function n(t){var i=$(t).find(".spu-facebook");if(i.length){var e=i.find(".fb-like > span").width();if(0==e){var o=i.find(".fb-like").data("layout");i.append("box_count"==o?'<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 n=u[t],a=$("#spu-bg-"+t),r=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&&i("spu_box_"+t,!0,s)}else $(window).resize(function(){o(t)}),o(t);var d=n.data("spuanimation");return"fade"===d?n.fadeToggle("slow"):n.slideToggle("slow"),e===!0&&r>0?a.fadeIn():a.fadeOut(),e}var r=$(window).height(),d=spuvar.is_admin,u=[];return s(),$(".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),o=i.data("trigger"),s=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),g="percentage"==o?parseInt(i.data("trigger-number"),10)/100:.8,w=g*$(document).height();n(i),$(".spu-google").width($(".spu-google").width()-20),$(".spu-twitter").width($(".spu-twitter ").width()-50);var m=0,v=0,b=i.outerWidth(),_=i.find(".spu-content").width(),y=i.data("total");$(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>'),y&&!spuvar.disable_style&&$(window).width()>b&&($(this).find(".spu-shortcode").each(function(){m+=$(this).width()}),v=_-m-y),v>0&&($(this).find(".spu-shortcode").each(function(){$(this).css("margin-left",v/2)}),2==y?$(this).find(".spu-shortcode").last().css("margin-left",0):3==y&&$(this).find(".spu-shortcode").first().css("margin-left",0)),$(document).keyup(function(t){27==t.keyCode&&a(f,!1)});var x=navigator.userAgent,T=x.match(/iPad/i)||x.match(/iPhone/i)?"touchstart":"click";$("body").on(T,function(t){void 0!==t.originalEvent&&a(f,!1)}),$("body").on(T,".spu-box",function(t){t.stopPropagation()}),i.hide().css("left",""),u[f]=i;var k=function(){s&&clearTimeout(s),s=window.setTimeout(function(){var t=$(window).scrollTop(),i=t+r>=w;i?(p||$(window).unbind("scroll",k),a(f,!0)):a(f,!1)},100)},P=function(){s&&clearTimeout(s),s=window.setTimeout(function(){a(f,!0)},1e3*h)},j=e("spu_box_"+f);if((void 0==j||""==j||d&&c)&&("seconds"==o?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"==o&&$(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();var e=!0,o=$(this),n=o.serialize(),r=o.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(n,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,o,n){return t(i,e,o,n)}}};if(spuvar.ajax_mode){var c={pid:spuvar.pid,referrer:document.referrer},f=function(t){$("body").append(t),window.SPU=u(),d()},p=function(t,i,e){console.log("Problem loading popups - error: "+i+" - "+e)};t(c,spuvar.ajax_mode_url,f,p,"html")}else jQuery(window).load(function(){window.SPU=u()});var l=!1,h=setInterval(function(){"undefined"==typeof FB||l||o()},1e3);"undefined"!=typeof twttr&&twttr.ready(function(t){t.events.bind("tweet",n),t.events.bind("follow",n)})}(jQuery);
1
+ !function($){"use strict";function t(t,i,e,o,n){var r={url:spuvar.ajax_url,data:t,cache:!1,type:"POST",dataType:"json",timeout:3e4},n=n||!1,e=e||!1,o=o||!1;i&&(r.url=i),e&&(r.success=e),o&&(r.error=o),n&&(r.dataType=n),$.ajax(r)}function i(t,i,e){if(e){var o=new Date;o.setTime(o.getTime()+24*e*60*60*1e3);var n="; expires="+o.toGMTString()}else var n="";document.cookie=t+"="+i+n+"; path=/"}function e(t){for(var i=t+"=",e=document.cookie.split(";"),o=0;o<e.length;o++){for(var n=e[o];" "==n.charAt(0);)n=n.substring(1,n.length);if(0==n.indexOf(i))return n.substring(i.length,n.length)}return null}function o(){FB.Event.subscribe("edge.create",function(t,i){var e=$(i).parents(".spu-box").data("box-id");e&&SPU.hide(e)}),l=!0,clearInterval(g)}function n(t){var i=$(t.target).parents(".spu-box").data("box-id");i&&SPU.hide(i)}function r(t){if("on"==t.state){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}function a(t){if("confirm"==t.type){var i=jQuery(".spu-gogl").data("box-id");i&&SPU.hide(i)}}function s(){if(spuvar_social.facebook)try{FB.XFBML.parse()}catch(t){}spuvar_social.google&&gapi.plusone.go(),spuvar_social.twitter&&twttr.widgets.load()}function d(){$(".spu-box form").each(function(){var t=$(this).attr("action");$(this).attr("action",t.replace("?spu_action=spu_load",""))}),$.fn.wpcf7InitForm&&$(".spu-box div.wpcf7 > form").wpcf7InitForm()}var u=function(){function o(t){var i=u[t],e=$(window).width(),o=$(window).height(),n=i.outerHeight(),r=i.outerWidth(),a=i.data("width"),s=0,d=o/2-n/2,c="fixed",f=$(document).scrollTop();i.hasClass("spu-centered")&&(e>a&&(s=e/2-r/2),i.css({left:s,position:c,top:d})),n+50>o&&(c="absolute",d=f,i.css({position:c,top:d,bottom:"auto"}))}function n(t){var i=$(t).find(".spu-facebook");if(i.length){var e=i.find(".fb-like > span").width();if(0==e){var o=i.find(".fb-like").data("layout");i.append("box_count"==o?'<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 r(t,e){var n=u[t],r=$("#spu-bg-"+t),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&&i("spu_box_"+t,!0,s),n.trigger("spu.box_close",[t])}else n.trigger("spu.box_open",[t]),$(window).resize(function(){o(t)}),o(t);var d=n.data("spuanimation");return"fade"===d?n.fadeToggle("slow"):n.slideToggle("slow"),e===!0&&a>0?r.fadeIn():r.fadeOut(),e}var a=$(window).height(),d=spuvar.is_admin,u=[];return s(),$(".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),o=i.data("trigger"),s=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")),g=parseInt(i.data("trigger-number"),10),h="percentage"==o?parseInt(i.data("trigger-number"),10)/100:.8,m=h*$(document).height();n(i),$(".spu-google").width($(".spu-google").width()-20),$(".spu-twitter").width($(".spu-twitter ").width()-50);var w=0,b=0,v=i.outerWidth(),_=i.find(".spu-content").width(),x=i.data("total");i.find(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>'),x&&!spuvar.disable_style&&$(window).width()>v&&(i.find(".spu-shortcode").each(function(){w+=$(this).width()}),b=_-w-x),b>0&&(i.find(".spu-shortcode").each(function(){$(this).css("margin-left",b/2)}),2==x?i.find(".spu-shortcode").last().css("margin-left",0):3==x&&i.find(".spu-shortcode").first().css("margin-left",0)),$(document).keyup(function(t){27==t.keyCode&&r(f,!1)});var y=navigator.userAgent,T=y.match(/iPad/i)||y.match(/iPhone/i)?"touchstart":"click";$("body").on(T,function(t){void 0!==t.originalEvent&&r(f,!1)}),$("body").on(T,".spu-box",function(t){t.stopPropagation()}),i.hide().css("left",""),u[f]=i;var k=function(){s&&clearTimeout(s),s=window.setTimeout(function(){var t=$(window).scrollTop(),i=t+a>=m;i?(p||$(window).unbind("scroll",k),r(f,!0)):r(f,!1)},100)},I=function(){s&&clearTimeout(s),s=window.setTimeout(function(){r(f,!0)},1e3*g)},P=e("spu_box_"+f);if((void 0==P||""==P||d&&c)&&("seconds"==o?I():($(window).bind("scroll",k),k()),window.location.hash&&window.location.hash.length>0)){var j=window.location.hash,S;j.substring(1)===i.attr("id")&&setTimeout(function(){r(f,!0)},100)}i.find(".spu-close-popup").click(function(){r(f,!1),"percentage"==o&&$(window).unbind("scroll",k)}),$('a[href="#'+i.attr("id")+'"]').click(function(){return r(f,!0),!1}),i.find(".gform_wrapper form").addClass("gravity-form"),i.on("submit",'form:not(".wpcf7-form, .gravity-form")',function(e){e.preventDefault();var o=!0,n=$(this),a=n.serialize(),s=n.attr("action"),d=function(t,i,e){console.log("Spu Form error: "+i+" - "+e)},u=function(t){var i=$(t).filter("#spu-"+f).html();$("#spu-"+f).html(i),$("#spu-"+f).find(".mc4wp-form-error").length||setTimeout(function(){r(f,!1)},1e3*spuvar.seconds_confirmation_close)};return t(a,s,u,d,"html"),i.trigger("spu.form_submitted",[f]),o}),$("body").on("mailsent.wpcf7",function(){i.trigger("spu.form_submitted",[f]),r(f,!1)}),$(document).on("gform_confirmation_loaded",function(){i.trigger("spu.form_submitted",[f]),r(f,!1)})}),{show:function(t){return r(t,!0)},hide:function(t){return r(t,!1)},request:function(i,e,o,n){return t(i,e,o,n)}}};if(spuvar.ajax_mode){var c={pid:spuvar.pid,referrer:document.referrer},f=function(t){$("body").append(t),window.SPU=u(),d()},p=function(t,i,e){console.log("Problem loading popups - error: "+i+" - "+e)};t(c,spuvar.ajax_mode_url,f,p,"html")}else jQuery(window).load(function(){window.SPU=u()});var l=!1,g=setInterval(function(){"undefined"==typeof FB||l||o()},1e3);"undefined"!=typeof twttr&&twttr.ready(function(t){t.events.bind("tweet",n),t.events.bind("follow",n)})}(jQuery);
public/assets/js/public.js CHANGED
@@ -54,11 +54,11 @@ var SPU_master = function() {
54
 
55
 
56
  //wrap them all
57
- $(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>');
58
  if( total && ! spuvar.disable_style && $(window).width() > boxwidth ){
59
 
60
  //calculate total width of shortcodes all togheter
61
- $(this).find(".spu-shortcode").each(function(){
62
  swidth = swidth + $(this).width();
63
  });
64
  //available space to split margins
@@ -67,19 +67,19 @@ var SPU_master = function() {
67
  }
68
  if( free_width > 0 ) {
69
  //leave some margin
70
- $(this).find(".spu-shortcode").each(function(){
71
-
72
- $(this).css('margin-left',(free_width / 2 ));
73
 
74
  });
75
  //remove margin when neccesary
76
  if( total == 2) {
77
 
78
- $(this).find(".spu-shortcode").last().css('margin-left',0);
79
 
80
  } else if( total == 3) {
81
 
82
- $(this).find(".spu-shortcode").first().css('margin-left',0);
83
 
84
  }
85
  }
@@ -235,18 +235,20 @@ var SPU_master = function() {
235
  // Send form by ajax and replace popup with response
236
  request(data, url, success_cb, error_cb, 'html');
237
 
 
 
238
  return submit;
239
  });
240
 
241
  // CF7 support
242
  $('body').on('mailsent.wpcf7', function(){
243
-
244
  toggleBox(id, false );
245
  });
246
 
247
  // Gravity forms support (only AJAX mode)
248
  $(document).on('gform_confirmation_loaded', function(){
249
-
250
  toggleBox(id, false );
251
  });
252
 
@@ -339,9 +341,9 @@ var SPU_master = function() {
339
  if( days > 0 ) {
340
  spuCreateCookie( 'spu_box_' + id, true, days );
341
  }
 
342
  } else {
343
-
344
-
345
  //bind for resize
346
  $(window).resize(function(){
347
 
@@ -395,7 +397,7 @@ if( spuvar.ajax_mode ) {
395
 
396
  $('body').append(response);
397
  window.SPU = SPU_master();
398
- SPU_clean_action_forms(); //remove spu_Action from forms
399
 
400
  },
401
  error_cb = function (data, error, errorThrown){
@@ -411,8 +413,6 @@ if( spuvar.ajax_mode ) {
411
  });
412
  }
413
 
414
-
415
-
416
  /**
417
  * Ajax requests
418
  * @param data
@@ -559,10 +559,14 @@ function SPU_reload_socials(){
559
  twttr.widgets.load();
560
  }
561
  }
562
- function SPU_clean_action_forms(){
 
563
  $('.spu-box form').each( function(){
564
  var action = $(this).attr('action');
565
  $(this).attr('action' , action.replace('?spu_action=spu_load',''));
566
  });
 
 
 
567
  }
568
  })(jQuery);
54
 
55
 
56
  //wrap them all
57
+ $box.find(".spu-shortcode").wrapAll('<div class="spu_shortcodes"/>');
58
  if( total && ! spuvar.disable_style && $(window).width() > boxwidth ){
59
 
60
  //calculate total width of shortcodes all togheter
61
+ $box.find(".spu-shortcode").each(function(){
62
  swidth = swidth + $(this).width();
63
  });
64
  //available space to split margins
67
  }
68
  if( free_width > 0 ) {
69
  //leave some margin
70
+ $box.find(".spu-shortcode").each(function(){
71
+
72
+ $(this).css('margin-left',(free_width / 2 ));
73
 
74
  });
75
  //remove margin when neccesary
76
  if( total == 2) {
77
 
78
+ $box.find(".spu-shortcode").last().css('margin-left',0);
79
 
80
  } else if( total == 3) {
81
 
82
+ $box.find(".spu-shortcode").first().css('margin-left',0);
83
 
84
  }
85
  }
235
  // Send form by ajax and replace popup with response
236
  request(data, url, success_cb, error_cb, 'html');
237
 
238
+ $box.trigger('spu.form_submitted', [id]);
239
+
240
  return submit;
241
  });
242
 
243
  // CF7 support
244
  $('body').on('mailsent.wpcf7', function(){
245
+ $box.trigger('spu.form_submitted', [id]);
246
  toggleBox(id, false );
247
  });
248
 
249
  // Gravity forms support (only AJAX mode)
250
  $(document).on('gform_confirmation_loaded', function(){
251
+ $box.trigger('spu.form_submitted', [id]);
252
  toggleBox(id, false );
253
  });
254
 
341
  if( days > 0 ) {
342
  spuCreateCookie( 'spu_box_' + id, true, days );
343
  }
344
+ $box.trigger('spu.box_close', [id]);
345
  } else {
346
+ $box.trigger('spu.box_open', [id]);
 
347
  //bind for resize
348
  $(window).resize(function(){
349
 
397
 
398
  $('body').append(response);
399
  window.SPU = SPU_master();
400
+ SPU_reload_forms(); //remove spu_Action from forms
401
 
402
  },
403
  error_cb = function (data, error, errorThrown){
413
  });
414
  }
415
 
 
 
416
  /**
417
  * Ajax requests
418
  * @param data
559
  twttr.widgets.load();
560
  }
561
  }
562
+ function SPU_reload_forms(){
563
+ // Clear actions
564
  $('.spu-box form').each( function(){
565
  var action = $(this).attr('action');
566
  $(this).attr('action' , action.replace('?spu_action=spu_load',''));
567
  });
568
+ if ($.fn.wpcf7InitForm) {
569
+ $('.spu-box div.wpcf7 > form').wpcf7InitForm();
570
+ }
571
  }
572
  })(jQuery);
public/class-social-popup.php CHANGED
@@ -23,7 +23,7 @@ class SocialPopup {
23
  *
24
  * @var string
25
  */
26
- const VERSION = '1.2.3.3';
27
 
28
  /**
29
  * Popups to use acrros files
@@ -84,7 +84,8 @@ class SocialPopup {
84
  'hook' => SPU_PLUGIN_HOOK,
85
  'version' => self::VERSION,
86
  'upgrade_version' => '1.6.4.3',
87
- );
 
88
 
89
  $this->load_dependencies();
90
 
@@ -362,33 +363,35 @@ class SocialPopup {
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'");
366
-
367
- foreach( $spu_ids as $spu ) {
368
-
369
- $spu_id = $this->get_real_spu_id($spu->ID);
370
-
371
- $rules = get_post_meta( $spu_id, 'spu_rules' ,true );
372
 
373
- $match = $spu_rules->check_rules( $rules );
374
- if( $match ) {
375
- $spu_matches[] = $spu_id;
 
 
 
 
 
 
376
  }
377
  }
378
-
379
  return $spu_matches;
380
  }
381
 
382
  /**
383
- * Used to get wpml real ids if wpml installed
384
- * @param int $id popup id
385
- * @return int return id
386
  */
387
- function get_real_spu_id($id) {
388
- if( !function_exists('icl_object_id') )
389
- return $id;
390
-
391
- return icl_object_id($id,'spucpt');
 
 
 
 
 
392
  }
393
 
394
  /**
@@ -406,7 +409,7 @@ class SocialPopup {
406
  'safe_mode' => isset( $this->spu_settings['safe'] ) ? $this->spu_settings['safe'] : '',
407
  'ajax_mode' => isset( $this->spu_settings['ajax_mode'] ) ? $this->spu_settings['ajax_mode'] :'',
408
  'ajax_url' => admin_url('admin-ajax.php'),
409
- 'ajax_mode_url' => site_url('/?spu_action=spu_load'),
410
  'pid' => get_queried_object_id(),
411
  'is_front_page' => is_front_page(),
412
  'seconds_confirmation_close' => apply_filters( 'spu/spuvar/seconds_confirmation_close', 5 ),
@@ -420,7 +423,7 @@ class SocialPopup {
420
  * @since 1.3
421
  */
422
  private function enqueue_social_shortcodes(){
423
- global $wpdb;
424
 
425
  $spuvar_social = '';
426
 
@@ -455,7 +458,8 @@ class SocialPopup {
455
  }
456
 
457
  }
458
- wp_localize_script( 'jquery', 'spuvar_social', $spuvar_social);
 
459
 
460
  //also include gravity forms if needed
461
  if( $gf = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key ='spu_gravity' " ) ) {
@@ -635,18 +639,42 @@ class SocialPopup {
635
  * @return mixed Prints all spus
636
  */
637
  function register_spu_ajax() {
638
-
639
- if ( empty( $_REQUEST['spu_action'] ) || $_REQUEST['spu_action'] != 'spu_load' )
640
  return;
641
-
642
-
643
  define( 'DOING_AJAX', TRUE );
644
 
645
-
646
  $this->print_boxes();
647
-
648
 
649
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  }
651
 
652
  }
23
  *
24
  * @var string
25
  */
26
+ const VERSION = '1.2.3.4';
27
 
28
  /**
29
  * Popups to use acrros files
84
  'hook' => SPU_PLUGIN_HOOK,
85
  'version' => self::VERSION,
86
  'upgrade_version' => '1.6.4.3',
87
+ 'wpml_lang' => defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : '',
88
+ );
89
 
90
  $this->load_dependencies();
91
 
363
  $spu_rules = new Spu_Rules();
364
 
365
  //Grab all popups ids
366
+ $spu_ids = $this->get_spu_ids();
 
 
 
 
 
 
367
 
368
+ if( !empty($spu_ids) ) {
369
+ foreach ( $spu_ids as $spu ) {
370
+
371
+ $rules = get_post_meta( $spu->ID, 'spu_rules', true );
372
+
373
+ $match = $spu_rules->check_rules( $rules );
374
+ if ( $match ) {
375
+ $spu_matches[] = $spu->ID;
376
+ }
377
  }
378
  }
 
379
  return $spu_matches;
380
  }
381
 
382
  /**
383
+ * Return array of popups ids
 
 
384
  */
385
+ function get_spu_ids() {
386
+ global $wpdb;
387
+ // IF wpml is active and spucpt is translated get correct ids for language
388
+ if( function_exists('icl_object_id') ) {
389
+ $spu_ids = $this->get_wpml_ids();
390
+ if(!empty($spu_ids)) {
391
+ return $spu_ids;
392
+ }
393
+ }
394
+ return $wpdb->get_results( "SELECT ID, post_content FROM $wpdb->posts WHERE post_type='spucpt' AND post_status='publish'");
395
  }
396
 
397
  /**
409
  'safe_mode' => isset( $this->spu_settings['safe'] ) ? $this->spu_settings['safe'] : '',
410
  'ajax_mode' => isset( $this->spu_settings['ajax_mode'] ) ? $this->spu_settings['ajax_mode'] :'',
411
  'ajax_url' => admin_url('admin-ajax.php'),
412
+ 'ajax_mode_url' => site_url('/?spu_action=spu_load&lang='.$this->info['wpml_lang']),
413
  'pid' => get_queried_object_id(),
414
  'is_front_page' => is_front_page(),
415
  'seconds_confirmation_close' => apply_filters( 'spu/spuvar/seconds_confirmation_close', 5 ),
423
  * @since 1.3
424
  */
425
  private function enqueue_social_shortcodes(){
426
+ global $wpdb,$spuvar_social;
427
 
428
  $spuvar_social = '';
429
 
458
  }
459
 
460
  }
461
+ wp_localize_script( 'spu-public', 'spuvar_social', $spuvar_social);
462
+
463
 
464
  //also include gravity forms if needed
465
  if( $gf = $wpdb->get_var( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key ='spu_gravity' " ) ) {
639
  * @return mixed Prints all spus
640
  */
641
  function register_spu_ajax() {
642
+
643
+ if ( empty( $_REQUEST['spu_action'] ) || $_REQUEST['spu_action'] != 'spu_load' )
644
  return;
645
+
 
646
  define( 'DOING_AJAX', TRUE );
647
 
 
648
  $this->print_boxes();
 
649
 
650
+ die();
651
+ }
652
+
653
+
654
+ /**
655
+ * Return popups for current language
656
+ * @return bool | array of ids
657
+ */
658
+ protected function get_wpml_ids( ) {
659
+ global $wpdb;
660
+ $wpml_settings = get_option( 'icl_sitepress_settings', true);
661
+
662
+ if ( ! empty( $wpml_settings['custom_posts_sync_option']['spucpt'] ) ) {
663
+
664
+ $sql = "select DISTINCT * from $wpdb->posts as a
665
+ LEFT JOIN {$wpdb->prefix}icl_translations as b
666
+ ON a.ID = b.element_id
667
+ WHERE a.post_status = 'publish'
668
+ AND a.post_type = 'spucpt'
669
+ AND b.language_code = '" . esc_sql( ICL_LANGUAGE_CODE ) . "'
670
+ GROUP BY ID";
671
+
672
+ $ids = $wpdb->get_results( $sql );
673
+ if( !empty($ids) )
674
+ return $ids;
675
+ }
676
+
677
+ return false;
678
  }
679
 
680
  }
public/includes/class-spu-rules.php CHANGED
@@ -53,6 +53,7 @@ class Spu_Rules
53
  //Other
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'] : '';
@@ -231,6 +232,24 @@ class Spu_Rules
231
 
232
  }
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  /**
235
  * [rule_match_same_site description]
236
  * @param bool $match false default
53
  //Other
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
+ add_filter('spu/rules/rule_match/referrer', array($this, 'rule_match_referrer'), 10, 2);
57
 
58
  $this->post_id = isset( $post->ID ) ? $post->ID : '';
59
  $this->referrer = isset($_SERVER['HTTP_REFERRER']) ? $_SERVER['HTTP_REFERRER'] : '';
232
 
233
  }
234
 
235
+ /**
236
+ * Check for user referrer
237
+ * @param bool $match false default
238
+ * @param array $rule rule to compare
239
+ * @return boolean true if match
240
+ */
241
+ function rule_match_referrer( $match, $rule ) {
242
+
243
+ $ref = $this->referrer;
244
+
245
+ if ( strpos( $ref,$rule['value'] ) !==false ){
246
+ return $rule['operator'] == "==" ? true : false;
247
+ }
248
+
249
+ return $rule['operator'] == "==" ? false : true;
250
+
251
+ }
252
+
253
  /**
254
  * [rule_match_same_site description]
255
  * @param bool $match false default