Popup Builder – Responsive WordPress Pop up - Version 3.77

Version Description

Current Version of Popup Builder is 3.77

Download this release

Release Info

Developer Sygnoos
Plugin Icon 128x128 Popup Builder – Responsive WordPress Pop up
Version 3.77
Comparing to
See all releases

Code changes from version 3.76 to 3.77

PopupBuilderInit.php CHANGED
@@ -70,6 +70,7 @@ class PopupBuilderInit
70
  require_once(SG_POPUP_CLASSES_PATH.'NotificationCenter.php');
71
  require_once(SG_POPUP_CLASSES_PATH.'Notification.php');
72
  require_once(SG_POPUP_CLASSES_PATH.'Feedback.php');
 
73
  }
74
 
75
  public function actions()
70
  require_once(SG_POPUP_CLASSES_PATH.'NotificationCenter.php');
71
  require_once(SG_POPUP_CLASSES_PATH.'Notification.php');
72
  require_once(SG_POPUP_CLASSES_PATH.'Feedback.php');
73
+ require_once(SG_POPUP_COMPONENTS_PATH.'Menu.php');
74
  }
75
 
76
  public function actions()
com/classes/Actions.php CHANGED
@@ -58,8 +58,10 @@ class Actions
58
  add_action('template_redirect', array($this, 'redirectFromPopupPage'));
59
  add_filter('views_edit-popupbuilder', array($this, 'mainActionButtons'), 10, 1);
60
  add_action('wpml_loaded', array($this, 'wpmlRelatedActions'));
 
61
  new SGPBFeedback();
62
  new SGPBReports();
 
63
  new Ajax();
64
  }
65
 
58
  add_action('template_redirect', array($this, 'redirectFromPopupPage'));
59
  add_filter('views_edit-popupbuilder', array($this, 'mainActionButtons'), 10, 1);
60
  add_action('wpml_loaded', array($this, 'wpmlRelatedActions'));
61
+
62
  new SGPBFeedback();
63
  new SGPBReports();
64
+ new SGPBMenu();
65
  new Ajax();
66
  }
67
 
com/classes/PopupLoader.php CHANGED
@@ -131,9 +131,10 @@ class PopupLoader
131
  $popupBuilderPosts = new WP_Query(
132
  array(
133
  'post_type' => SG_POPUP_POST_TYPE,
134
- 'posts_per_page' => 100
135
  )
136
  );
 
137
  // We check all the popups one by one to realize whether they might be loaded or not.
138
  while ($popupBuilderPosts->have_posts()) {
139
  $popupBuilderPosts->next_post();
@@ -147,7 +148,6 @@ class PopupLoader
147
  }
148
  }
149
 
150
-
151
  $this->doGroupFiltersPopups();
152
  $popups = $this->getLoadablePopups();
153
 
131
  $popupBuilderPosts = new WP_Query(
132
  array(
133
  'post_type' => SG_POPUP_POST_TYPE,
134
+ 'posts_per_page' => -1
135
  )
136
  );
137
+
138
  // We check all the popups one by one to realize whether they might be loaded or not.
139
  while ($popupBuilderPosts->have_posts()) {
140
  $popupBuilderPosts->next_post();
148
  }
149
  }
150
 
 
151
  $this->doGroupFiltersPopups();
152
  $popups = $this->getLoadablePopups();
153
 
com/classes/ScriptsLoader.php CHANGED
@@ -58,10 +58,8 @@ class ScriptsLoader
58
  // load popup scripts and styles and add popup data to the footer
59
  public function loadToFooter()
60
  {
61
- $alreadyLoadedPopups = array();
62
  $popups = $this->getLoadablePopups();
63
  $currentPostType = AdminHelper::getCurrentPostType();
64
- $postId = 0;
65
  global $wp;
66
  $currentUrl = home_url( $wp->request );
67
  $currentUrl = strpos($currentUrl, '/popupbuilder/');
58
  // load popup scripts and styles and add popup data to the footer
59
  public function loadToFooter()
60
  {
 
61
  $popups = $this->getLoadablePopups();
62
  $currentPostType = AdminHelper::getCurrentPostType();
 
63
  global $wp;
64
  $currentUrl = home_url( $wp->request );
65
  $currentUrl = strpos($currentUrl, '/popupbuilder/');
com/classes/components/Menu.php ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace sgpb;
4
+
5
+ /**
6
+ * Class SGPBMenu
7
+ * @package sgpb
8
+ */
9
+ class SGPBMenu
10
+ {
11
+ /**
12
+ * Singleton variable to save menu locations.
13
+ * @var
14
+ */
15
+ public static $navMenuLocations;
16
+
17
+ /**
18
+ * Singleton variable to save menu items on which popup is set.
19
+ * @var
20
+ */
21
+ public static $navMenuItems;
22
+
23
+ /**
24
+ * Menu constructor.
25
+ */
26
+ public function __construct()
27
+ {
28
+ $this->init();
29
+ }
30
+
31
+ /**
32
+ * Initialize actions and filters.
33
+ */
34
+ public function init()
35
+ {
36
+ add_action('wp_nav_menu_item_custom_fields', array($this, 'fields'), 10, 4);
37
+ add_action('wp_update_nav_menu_item', array($this, 'save'), 10, 2);
38
+
39
+ add_filter('nav_menu_css_class', array($this, 'addPopupTriggeringClass'), 10, 2);
40
+ add_filter('wp_setup_nav_menu_item', array($this, 'addCustomNavFields'));
41
+ add_filter('sgpbLoadablePopups', array($this, 'addPopupToLoad'));
42
+ }
43
+
44
+ /**
45
+ * @param $classes
46
+ * @param $menuItem
47
+ * @return mixed
48
+ */
49
+ public function addPopupTriggeringClass($classes, $menuItem)
50
+ {
51
+ $popupId = $menuItem->sgpbPopupId;
52
+ if ($popupId && !in_array('sg-popup-id-'.$popupId, $classes)) {
53
+ array_push($classes, 'sg-popup-id-'.$popupId);
54
+ }
55
+
56
+ return $classes;
57
+ }
58
+
59
+ /**
60
+ * @param $popups
61
+ * @return mixed
62
+ */
63
+ public function addPopupToLoad($popups) {
64
+ $registeredMenus = $this->getNavMenuLocations();
65
+ /* Will only return menu items on which popup is set */
66
+ $menuItems = $this->getNavMenuItemsWithPopup($registeredMenus);
67
+
68
+ foreach ($menuItems as $menuItem) {
69
+ $menuPopupId = (int)$menuItem->sgpbPopupId;
70
+
71
+ /* As $menuItems contains only menu items on which popup is set
72
+ we can check if the popup should load on current page or not */
73
+ $popup = $this->shouldLoadPopupForMenuItem($menuPopupId, $popups);
74
+ if (!$popup) {
75
+ $popup = SGPopup::find($menuPopupId);
76
+ if (!$popup instanceof SGPopup) continue;
77
+ /* We could set param everywhere as popup was not suppose to load on current page.
78
+ We could also load popup to current requested page but to avoid any confusion
79
+ it will be better to use everywhere */
80
+ // $popup->setTarget(array(
81
+ // array('param' => 'everywhere')
82
+ // ));
83
+ $popups[] = $popup;
84
+ }
85
+
86
+ $popupOpeningEvents = $popup->getEvents();
87
+
88
+ /* If the popup is setup inside the menu but there is no onclick event we will add manually */
89
+ if (!$this->inMultiDimArray('click', $popupOpeningEvents)) {
90
+ $popup->setEvents(array('param' => 'click', 'value' => ''));
91
+ }
92
+ /* if the popup is set on menu item we don't need any limitation */
93
+ //$this->disablePopupLimitation($popup);
94
+ }
95
+
96
+ return $popups;
97
+ }
98
+
99
+ /**
100
+ * @param $popup
101
+ */
102
+ private function disablePopupLimitation(&$popup)
103
+ {
104
+ $popupOptions = $popup->getOptions();
105
+ unset($popupOptions['sgpb-show-popup-same-user']);
106
+ $popup->setOptions($popupOptions);
107
+ }
108
+
109
+ /**
110
+ * @param $item
111
+ * @param $array
112
+ * @return false|int
113
+ */
114
+ private function inMultiDimArray($item , $array){
115
+ return preg_match('/"'.preg_quote($item, '/').'"/i' , json_encode($array));
116
+ }
117
+
118
+ /**
119
+ * @param $menuPopupId
120
+ * @param $popups
121
+ * @return false|mixed
122
+ */
123
+ private function shouldLoadPopupForMenuItem($menuPopupId, &$popups) {
124
+ foreach ($popups as $popup) {
125
+ $popupId = $popup->getId();
126
+ /* Menu item contains popup with current id and the popup is loaded */
127
+ if ($menuPopupId == $popupId) {
128
+ return $popup;
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+
134
+ /**
135
+ * @param false $forceUpdate
136
+ * @return array
137
+ */
138
+ public function getNavMenuLocations($forceUpdate = false)
139
+ {
140
+ if (!isset(self::$navMenuLocations) && !$forceUpdate) {
141
+ self::$navMenuLocations = get_nav_menu_locations();
142
+ }
143
+
144
+ return isset(self::$navMenuLocations) ? self::$navMenuLocations : array();
145
+ }
146
+
147
+ /**
148
+ * @param array $navMenuLocations
149
+ * @param false $forceUpdate
150
+ * @return array of menu items where popup is set
151
+ */
152
+ public function getNavMenuItemsWithPopup($navMenuLocations = array(), $forceUpdate = false)
153
+ {
154
+ if (!isset(self::$navMenuItems) && !$forceUpdate) {
155
+ foreach ($navMenuLocations as $menuName => $menuId) {
156
+ $menuItems = wp_get_nav_menu_items($menuId);
157
+ foreach ($menuItems as $menuItem) {
158
+ $popupId = $menuItem->sgpbPopupId;
159
+ if ($popupId > 0) {
160
+ self::$navMenuItems[] = $menuItem;
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ return isset(self::$navMenuItems) ? self::$navMenuItems : array();
167
+ }
168
+
169
+ /**
170
+ * @param $menu_item
171
+ * @return mixed
172
+ */
173
+ public function addCustomNavFields($menuItem)
174
+ {
175
+ $menuItem->sgpbPopupId = get_post_meta($menuItem->ID, '_menu_sgpb_popup_id', true);
176
+ return $menuItem;
177
+ }
178
+
179
+ /**
180
+ * @return array of popup objects
181
+ */
182
+ public static function getPopups()
183
+ {
184
+ return SGPopup::getAllPopups();
185
+ }
186
+
187
+ /**
188
+ * Adds custom fields to the menu item editor.
189
+ *
190
+ * @param $itemId
191
+ * @param $item
192
+ * @param $depth
193
+ * @param $args
194
+ */
195
+ public function fields($itemId, $item, $depth, $args)
196
+ { ?>
197
+ <div class="description description-wide">
198
+ <label for="edit-menu-item-pb-<?php echo $item->ID; ?>">
199
+ <?php _e('Select a Popup', SG_POPUP_TEXT_DOMAIN); ?><br/>
200
+ <select class="widefat" name="menu-item-pb[<?php echo $item->ID; ?>][popup]"
201
+ id="edit-menu-item-pb-<?php echo $item->ID; ?>">
202
+ <option value=""></option>
203
+ <?php foreach (self::getPopups() as $popup) : ?>
204
+ <option value="<?php echo $popup->getId(); ?>" <?php selected($popup->getId(), (int)get_post_meta($itemId, '_menu_sgpb_popup_id', true)); ?>>
205
+ <?php echo esc_html($popup->getTitle()); ?>
206
+ </option>
207
+ <?php endforeach; ?>
208
+ </select>
209
+ <span class="description"><?php _e('Open a popup once this item is clicked.', SG_POPUP_TEXT_DOMAIN); ?></span>
210
+ </label>
211
+ </div>
212
+ <?php
213
+ }
214
+
215
+ /**
216
+ * Processes the saving of menu items.
217
+ *
218
+ * @param $menu_id
219
+ * @param $item_id
220
+ */
221
+ public function save($menu_id, $item_id)
222
+ {
223
+ delete_post_meta($item_id, '_menu_sgpb_popup_id');
224
+ if (isset($_POST['menu-item-pb'][$item_id]['popup'])) {
225
+ $popupId = (int)$_POST['menu-item-pb'][$item_id]['popup'];
226
+ update_post_meta($item_id, '_menu_sgpb_popup_id', $popupId);
227
+ }
228
+ }
229
+ }
com/config/config.php CHANGED
@@ -61,6 +61,7 @@ class SgpbPopupConfig
61
  self::addDefine('SG_POPUP_CONFIG_PATH', SG_POPUP_COM_PATH.'config/');
62
  self::addDefine('SG_POPUP_PUBLIC_PATH', SG_POPUP_BUILDER_PATH.'public/');
63
  self::addDefine('SG_POPUP_CLASSES_PATH', SG_POPUP_COM_PATH.'classes/');
 
64
  self::addDefine('SG_POPUP_DATA_TABLES_PATH', SG_POPUP_CLASSES_PATH.'dataTable/');
65
  self::addDefine('SG_POPUP_CLASSES_POPUPS_PATH', SG_POPUP_CLASSES_PATH.'popups/');
66
  self::addDefine('SG_POPUP_EXTENSION_PATH', SG_POPUP_CLASSES_PATH.'extension/');
61
  self::addDefine('SG_POPUP_CONFIG_PATH', SG_POPUP_COM_PATH.'config/');
62
  self::addDefine('SG_POPUP_PUBLIC_PATH', SG_POPUP_BUILDER_PATH.'public/');
63
  self::addDefine('SG_POPUP_CLASSES_PATH', SG_POPUP_COM_PATH.'classes/');
64
+ self::addDefine('SG_POPUP_COMPONENTS_PATH', SG_POPUP_CLASSES_PATH.'components/');
65
  self::addDefine('SG_POPUP_DATA_TABLES_PATH', SG_POPUP_CLASSES_PATH.'dataTable/');
66
  self::addDefine('SG_POPUP_CLASSES_POPUPS_PATH', SG_POPUP_CLASSES_PATH.'popups/');
67
  self::addDefine('SG_POPUP_EXTENSION_PATH', SG_POPUP_CLASSES_PATH.'extension/');
com/config/configPackage.php CHANGED
@@ -3,6 +3,6 @@ if (!defined('ABSPATH')) {
3
  exit();
4
  }
5
 
6
- define('SG_POPUP_VERSION', '3.76');
7
  define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
8
  define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
3
  exit();
4
  }
5
 
6
+ define('SG_POPUP_VERSION', '3.77');
7
  define('SGPB_POPUP_PKG', SGPB_POPUP_PKG_FREE);
8
  define('POPUP_BUILDER_BASENAME', 'popupbuilder-platinum/popup-builder.php');
popup-builder.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: https://popup-builder.com
5
  * Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
6
- * Version: 3.76
7
  * Author: Sygnoos
8
  * Author URI: https://sygnoos.com
9
  * License: GPLv2
3
  * Plugin Name: Popup Builder
4
  * Plugin URI: https://popup-builder.com
5
  * Description: The most complete popup plugin. Html, image, iframe, shortcode, video and many other popup types. Manage popup dimensions, effects, themes and more.
6
+ * Version: 3.77
7
  * Author: Sygnoos
8
  * Author URI: https://sygnoos.com
9
  * License: GPLv2
public/js/PopupBuilder.js CHANGED
@@ -786,7 +786,7 @@ SGPBPopup.prototype.isSatistfyForShowingLimitation = function(popupData)
786
  }
787
  var cookieData = this.getPopupShowLimitationCookie(popupData);
788
 
789
- /*when there is noot*/
790
  if (!cookieData.cookie) {
791
  return true;
792
  }
@@ -2619,12 +2619,6 @@ SgpbEventListener.prototype.sgpbClick = function(listenerObj, eventData)
2619
  return true;
2620
  }
2621
 
2622
- var attr = currentTarget.parent().attr('data-popup-id');
2623
- var attr2 = currentTarget.attr('data-popup-id');
2624
- if (jQuery(e.originalEvent.target).parents('li').length && typeof jQuery(e.originalEvent.target).parents('li').attr('data-popup-id') == 'undefined') {
2625
- return true;
2626
- }
2627
-
2628
  var allowToOpen = popupObj.forceCheckCurrentPopupType(popupObj);
2629
  if (!allowToOpen) {
2630
  return true;
786
  }
787
  var cookieData = this.getPopupShowLimitationCookie(popupData);
788
 
789
+ /*when there is not*/
790
  if (!cookieData.cookie) {
791
  return true;
792
  }
2619
  return true;
2620
  }
2621
 
 
 
 
 
 
 
2622
  var allowToOpen = popupObj.forceCheckCurrentPopupType(popupObj);
2623
  if (!allowToOpen) {
2624
  return true;
readme.txt CHANGED
@@ -9,7 +9,7 @@ Tags: popup, pop up, wordpress popup, popup maker, exit popup, popup builder, wo
9
  Requires at least: 4.2
10
  Tested up to: 5.6
11
  Requires PHP: 5.3.3
12
- Stable tag: 3.76
13
  License: GPLv2 or later
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
 
@@ -184,7 +184,13 @@ Go to the Popup Builder settings and set your desired options.
184
  12. Countdown popup
185
  13. Facebook popup
186
 
187
- == Changelog ==
 
 
 
 
 
 
188
 
189
  = Version 3.76 =
190
  * Live preview fix of subscription popup.
@@ -1286,7 +1292,7 @@ Leave us a good review :)
1286
 
1287
  == Upgrade Notice ==
1288
 
1289
- Current Version of Popup Builder is 3.76
1290
 
1291
  == Other Notes ==
1292
 
9
  Requires at least: 4.2
10
  Tested up to: 5.6
11
  Requires PHP: 5.3.3
12
+ Stable tag: 3.77
13
  License: GPLv2 or later
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
 
184
  12. Countdown popup
185
  13. Facebook popup
186
 
187
+ == Changelog ==
188
+
189
+ = Version 3.77 =
190
+ * New Feature: Now users can select and set the popup on menu from the Appearance section.
191
+ * Bug fixed related to more than 100 popups on the website, popups are now loaded as needed.
192
+ * Bug fixed related to triggering onclick popup that is wrapped inside the `<ul><li>` tags.
193
+ * Code improvements and minor fixes.
194
 
195
  = Version 3.76 =
196
  * Live preview fix of subscription popup.
1292
 
1293
  == Upgrade Notice ==
1294
 
1295
+ Current Version of Popup Builder is 3.77
1296
 
1297
  == Other Notes ==
1298