Popup Builder – Responsive WordPress Pop up - Version 3.83

Version Description

Download this release

Release Info

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

Code changes from version 3.82 to 3.83

com/classes/Filters.php CHANGED
@@ -1,865 +1,870 @@
1
- <?php
2
- namespace sgpb;
3
- use \WP_Query;
4
- use \SgpbPopupConfig;
5
- use sgpb\PopupBuilderActivePackage;
6
- use sgpb\SGPopup;
7
-
8
- class Filters
9
- {
10
- private $activePopupsQueryString = '';
11
-
12
- public function setQueryString($activePopupsQueryString)
13
- {
14
- $this->activePopupsQueryString = $activePopupsQueryString;
15
- }
16
-
17
- public function getQueryString()
18
- {
19
- return $this->activePopupsQueryString;
20
- }
21
-
22
- public function __construct()
23
- {
24
- $this->init();
25
- }
26
-
27
- public function init()
28
- {
29
- add_filter('admin_url', array($this, 'addNewPostUrl'), 10, 2);
30
- add_filter('wpseo_sitemap_exclude_post_type', array($this, 'excludeSitemapsYoast'), 10, 2);
31
- add_filter('admin_menu', array($this, 'removeAddNewSubmenu'), 10, 2);
32
- add_filter('manage_'.SG_POPUP_POST_TYPE.'_posts_columns', array($this, 'popupsTableColumns'));
33
- add_filter('post_row_actions', array($this, 'quickRowLinksManager'), 10, 2);
34
- add_filter('sgpbAdminJs', array($this, 'adminJsFilter'), 1, 1);
35
- add_filter('sgpbAdminCssFiles', array($this, 'sgpbAdminCssFiles'), 1, 1);
36
- add_filter('sgpbPopupContentLoadToPage', array($this, 'filterPopupContent'), 10, 2);
37
- add_filter('the_content', array($this, 'clearContentPreviewMode'), 10, 1);
38
- // The priority of this action should be higher than the extensions' init priority.
39
- add_action('init', array($this, 'excludePostToShowPrepare'), 99999999);
40
- add_filter('preview_post_link', array($this, 'editPopupPreviewLink'), 10, 2);
41
- add_filter('upgrader_pre_download', array($this, 'maybeShortenEddFilename'), 10, 4);
42
- add_filter('sgpbSavedPostData', array($this, 'savedPostData'), 10, 1);
43
- add_filter('sgpbPopupEvents', array($this, 'popupEvents'), 10, 1);
44
- add_filter('sgpbAdditionalMetaboxes', array($this, 'metaboxes'), 10, 1);
45
- add_filter('sgpbOptionAvailable', array($this, 'filterOption'), 10, 1);
46
- add_filter('export_wp_filename', array($this, 'exportFileName'), 10, 1);
47
- add_filter('sgpbAdvancedOptionsDefaultValues', array($this, 'defaultAdvancedOptionsValues'), 10, 1);
48
- add_filter('sgpbPopupContentLoadToPage', array($this, 'popupContentLoadToPage'), 10, 2);
49
- add_filter('sgpbExtraNotifications', array($this, 'sgpbExtraNotifications'), 10, 1);
50
- add_filter('sgpbSystemInformation', array($this, 'systemInformation'), 10, 1);
51
- add_filter('plugin_action_links', array($this, 'pluginActionLinks'), 10, 4);
52
- add_filter('plugin_row_meta', array( $this, 'pluginRowMetas'), 10, 4);
53
- add_filter('rank_math/sitemap/exclude_post_type', array($this, 'excludeRankMath'), 10, 2);
54
- add_filter('sgpbUserSelectionQuery', array($this, 'userSelectionQueryAddExtraAttributes'), 100, 1);
55
- add_filter('sgpbFilterOptionsBeforeSaving', array($this, 'filterOptionsBeforeSaving'), 100, 1);
56
- add_filter('sgpbPopupExtraData', array($this, 'popupExtraDataRender'), 100, 2);
57
- add_filter('wpml_link_to_translation', array($this, 'linkToTranslationWpml'), 30, 4);
58
- add_filter('pll_get_post_types', array($this, 'enablePBpostTypeForTranslating'), 10, 2);
59
- }
60
-
61
- public function enablePBpostTypeForTranslating($postTypes, $isSettings)
62
- {
63
- $postTypes[SG_POPUP_POST_TYPE] = SG_POPUP_POST_TYPE;
64
-
65
- return $postTypes;
66
- }
67
-
68
- public function linkToTranslationWpml($link, $postId, $lang, $trid)
69
- {
70
- if (strpos($link, SG_POPUP_POST_TYPE) && strpos($link, 'source_lang') && isset($trid)) {
71
-
72
- $popupType = 'html';
73
- $popup = SGPopup::find($postId);
74
- if (!empty($popup) || !is_object($popup)) {
75
- $popupType = $popup->getType();
76
- }
77
- $link .= '&sgpb_type='.$popupType;
78
- }
79
-
80
- return $link;
81
- }
82
-
83
- public function popupExtraDataRender($popupId = 0, $popupOptions = array())
84
- {
85
- $floatingButton = '';
86
- if (empty($popupOptions['sgpb-enable-floating-button'])) {
87
- return $floatingButton;
88
- }
89
- $buttonStyles = '';
90
- $buttonClass = 'sgpb-'.$popupOptions['sgpb-floating-button-style'].'-'.$popupOptions['sgpb-floating-button-position'];
91
-
92
- if (isset($popupOptions['sgpb-floating-button-style']) && $popupOptions['sgpb-floating-button-style'] == 'basic' && strstr($popupOptions['sgpb-floating-button-position'], 'center')) {
93
- if (strstr($popupOptions['sgpb-floating-button-position'], 'top') || strstr($popupOptions['sgpb-floating-button-position'], 'bottom')) {
94
- $buttonStyles .= 'right: '.$popupOptions['sgpb-floating-button-position-right'].'%;';
95
- }
96
- else if (strstr($popupOptions['sgpb-floating-button-position'], 'left') || strstr($popupOptions['sgpb-floating-button-position'], 'right')) {
97
- $buttonStyles .= 'top: '.$popupOptions['sgpb-floating-button-position-top'].'%;';
98
- }
99
- }
100
-
101
- if (isset($popupOptions['sgpb-floating-button-font-size'])) {
102
- $buttonStyles .= 'font-size: '.$popupOptions['sgpb-floating-button-font-size'].'px;';
103
- }
104
- if (isset($popupOptions['sgpb-floating-button-border-size'])) {
105
- $buttonStyles .= 'border-width: '.$popupOptions['sgpb-floating-button-border-size'].'px;';
106
- $buttonStyles .= 'border-style: solid;';
107
- }
108
- if (isset($popupOptions['sgpb-floating-button-border-radius'])) {
109
- $buttonStyles .= 'border-radius: '.$popupOptions['sgpb-floating-button-border-radius'].'px;';
110
- }
111
- if (isset($popupOptions['sgpb-floating-button-border-color'])) {
112
- $buttonStyles .= 'border-color: '.$popupOptions['sgpb-floating-button-border-color'].';';
113
- }
114
- if (isset($popupOptions['sgpb-floating-button-bg-color'])) {
115
- $buttonStyles .= 'background-color: '.$popupOptions['sgpb-floating-button-bg-color'].';';
116
- }
117
- if (isset($popupOptions['sgpb-floating-button-text-color'])) {
118
- $buttonStyles .= 'color: '.$popupOptions['sgpb-floating-button-text-color'].';';
119
- }
120
-
121
- /*
122
- * We first hide to make all CSS load then we will show once document is ready
123
- * SgpbEventListener.eventsListenerAfterDocumentReady -> showFloatingButton
124
- */
125
- $buttonStyles .= 'display: none;';
126
-
127
- $floatingButton = '<div class="'.$buttonClass.' sgpb-floating-button sg-popup-id-'.$popupId.'" style="'.$buttonStyles.'"><span class="sgpb-'.$popupOptions['sgpb-floating-button-style'].'-floating-button-text">'.$popupOptions['sgpb-floating-button-text'].'</span></div>';
128
-
129
- echo $floatingButton;
130
- }
131
-
132
- public function filterOptionsBeforeSaving($unfilteredData = array())
133
- {
134
- $externalOptions = array(
135
- 'icl_post_language' => 'sgpb-icl_post_language'
136
- );
137
-
138
- foreach ($externalOptions as $optionKey => $value) {
139
- if (isset($unfilteredData[$optionKey])) {
140
- $unfilteredData[$value] = $unfilteredData[$optionKey];
141
- // there is no need to unset the old index value, because in the next step we'll take only the values from indexes started with "sgpb"
142
- }
143
- }
144
-
145
- return $unfilteredData;
146
- }
147
-
148
- public function userSelectionQueryAddExtraAttributes($query)
149
- {
150
- $query .= ' status = 0 and unsubscribed = 0';
151
-
152
- return $query;
153
- }
154
-
155
- public function excludeRankMath($exclude, $type)
156
- {
157
- if ($type == SG_POPUP_POST_TYPE) {
158
- $exclude = true;
159
- }
160
-
161
- return $exclude;
162
- }
163
-
164
- public function pluginRowMetas($pluginMeta, $pluginFile, $pluginData, $status)
165
- {
166
- if (empty($pluginFile)) {
167
- return $pluginMeta;
168
- }
169
-
170
- $allExtensions = \SgpbDataConfig::allExtensionsKeys();
171
- $allExtensions = wp_list_pluck($allExtensions, 'pluginKey');
172
- $allExtensions[] = SG_POPUP_FILE_NAME;
173
-
174
- $rowMeta = array(
175
- 'rateus' => '<a href="'.SG_POPUP_RATE_US_URL.'" target="_blank">'.esc_html__('Rate us', SG_POPUP_TEXT_DOMAIN).'</a>',
176
- 'support' => '<a href="'.SG_POPUP_SUPPORT_URL.'" target="_blank">'.esc_html__('Support', SG_POPUP_TEXT_DOMAIN).'</a>'
177
- );
178
-
179
- if (in_array($pluginFile, $allExtensions)) {
180
- $pluginMeta = array_merge($pluginMeta, $rowMeta);
181
- }
182
-
183
- return $pluginMeta;
184
- }
185
-
186
- public function pluginActionLinks($actions, $pluginFile, $pluginData, $context)
187
- {
188
- if (empty($pluginFile)) {
189
- return $actions;
190
- }
191
-
192
- $allExtensions = \SgpbDataConfig::allExtensionsKeys();
193
- $allExtensions = wp_list_pluck($allExtensions, 'pluginKey');
194
- $allExtensions[] = SG_POPUP_FILE_NAME;
195
-
196
- $settingPageUrl = admin_url().'edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_SETTINGS_PAGE;
197
-
198
- $links = array(
199
- 'settings' => '<a href="'.$settingPageUrl.'" target="_blank">'.esc_html__('Settings', SG_POPUP_TEXT_DOMAIN).'</a>',
200
- 'docs' => '<a href="'.SG_POPUP_TICKET_URL.'" target="_blank">'.esc_html__('Docs', SG_POPUP_TEXT_DOMAIN).'</a>'
201
- );
202
-
203
- if (in_array($pluginFile, $allExtensions)) {
204
- if ($pluginFile == SG_POPUP_FILE_NAME) {
205
- $getActiveExtensions = AdminHelper::getAllExtensions();
206
- if (empty($getActiveExtensions['active'])) {
207
- $links['upgrade'] = '<a style="color: #4364eb;" href="'.SG_POPUP_BUNDLE_URL.'" target="_blank">'.esc_html__('Upgrade', SG_POPUP_TEXT_DOMAIN).'</a>';
208
- }
209
- }
210
- $actions = array_merge($links, $actions);
211
- }
212
-
213
- return $actions;
214
- }
215
-
216
- public function systemInformation($infoContent)
217
- {
218
-
219
- $infoContent .= 'Platform: '.@$platform . "\n";
220
- $infoContent .= 'Browser Name: '.@$bname . "\n";
221
- $infoContent .= 'Browser Version: '.@$version . "\n";
222
- $infoContent .= 'User Agent: '.@$uAgent . "\n";
223
-
224
- return $infoContent;
225
- }
226
-
227
- public function popupContentLoadToPage($content, $popupId)
228
- {
229
- $customScripts = AdminHelper::renderCustomScripts($popupId);
230
- $content .= $customScripts;
231
-
232
- return $content;
233
- }
234
-
235
- public function sgpbExtraNotifications($notifications = array())
236
- {
237
- $license = self::licenseNotification();
238
- if (!empty($license)) {
239
- $notifications[] = $license;
240
- }
241
-
242
- $promotional = self::promotionalNotifications();
243
- if (!empty($promotional)) {
244
- $notifications[] = $promotional;
245
- }
246
-
247
- $supportBanner = self::supportBannerNotifcations();
248
- if (!empty($supportBanner)) {
249
- $notifications[] = $supportBanner;
250
- }
251
-
252
- return $notifications;
253
- }
254
-
255
- public static function supportBannerNotifcations()
256
- {
257
- $hideSupportBanner = get_option('sgpb-hide-support-banner');
258
- if (!empty($hideSupportBanner)) {
259
- return array();
260
- }
261
- $message = AdminHelper::supportBannerNotification();
262
- $notification['id'] = SGPB_SUPPORT_BANNER_NOTIFICATION_ID;
263
- $notification['priority'] = 1;
264
- $notification['type'] = 1;
265
- $notification['message'] = $message;
266
-
267
- return $notification;
268
- }
269
-
270
- public static function promotionalNotifications()
271
- {
272
- $alreadyDone = get_option('SGPBCloseReviewPopup-notification');
273
- if (!empty($alreadyDone)) {
274
- return array();
275
- }
276
- $id = SGPB_RATE_US_NOTIFICATION_ID;
277
- $type = 1;
278
- $priority = 1;
279
-
280
- $maxOpenPopupStatus = AdminHelper::shouldOpenForMaxOpenPopupMessage();
281
- // popup opening count notification
282
- if ($maxOpenPopupStatus) {
283
- $message = AdminHelper::getMaxOpenPopupsMessage();
284
- }
285
-
286
- $shouldOpenForDays = AdminHelper::shouldOpenReviewPopupForDays();
287
- if ($shouldOpenForDays && !$maxOpenPopupStatus) {
288
- $message = AdminHelper::getMaxOpenDaysMessage();
289
- }
290
- if (empty($message)) {
291
- return array();
292
- }
293
-
294
- $alternateNotification['priority'] = $priority;
295
- $alternateNotification['type'] = $type;
296
- $alternateNotification['id'] = $id;
297
- $alternateNotification['message'] = $message;
298
-
299
- return $alternateNotification;
300
- }
301
-
302
- public function licenseNotification()
303
- {
304
- $inactiveExtensionNotice = array();
305
- $dontShowLicenseBanner = get_option('sgpb-hide-license-notice-banner');
306
- if ($dontShowLicenseBanner) {
307
- return $notifications;
308
- }
309
-
310
- $inactive = AdminHelper::getOption('SGPB_INACTIVE_EXTENSIONS');
311
- $hasInactiveExtensions = AdminHelper::hasInactiveExtensions();
312
-
313
- if (!$inactive) {
314
- AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 1);
315
- if ($hasInactiveExtensions) {
316
- AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 'inactive');
317
- $inactive = 'inactive';
318
- }
319
-
320
- }
321
-
322
- if ($hasInactiveExtensions && $inactive == 'inactive') {
323
- $licenseSectionUrl = menu_page_url(SGPB_POPUP_LICENSE, false);
324
- $partOfContent = '<br><br>'.__('<a href="'.$licenseSectionUrl.'">Follow the link</a> to finalize the activation.', SG_POPUP_TEXT_DOMAIN);
325
- $message = '<b>'.__('Thank you for choosing our plugin!', SG_POPUP_TEXT_DOMAIN).'</b>';
326
- $message .= '<br>';
327
- $message .= '<br>';
328
- $message .= '<b>'.__('You have activated Popup Builder extension(s). Please, don\'t forget to activate the license key(s) as well.', SG_POPUP_TEXT_DOMAIN).'</b>';
329
- $message .= '<b>'.$partOfContent.'</b>';
330
-
331
- $inactiveExtensionNotice['priority'] = 1;
332
- $inactiveExtensionNotice['type'] = 2;
333
- $inactiveExtensionNotice['id'] = 'sgpbMainActiveInactiveLicense';
334
- $inactiveExtensionNotice['message'] = $message;
335
- }
336
-
337
- return $inactiveExtensionNotice;
338
- }
339
-
340
- public function excludeSitemapsYoast($exclude = false, $postType)
341
- {
342
- $postTypeObject = get_post_type_object($postType);
343
- if (!is_object($postTypeObject)) {
344
- return $exclude;
345
- }
346
-
347
- if ($postTypeObject->public === false || $postType == SG_POPUP_POST_TYPE) {
348
- return true;
349
- }
350
-
351
- return $exclude;
352
- }
353
-
354
- public function defaultAdvancedOptionsValues($options = array())
355
- {
356
- $enablePopupOverlay = PopupBuilderActivePackage::canUseOption('sgpb-enable-popup-overlay');
357
- if (!$enablePopupOverlay) {
358
- $options['sgpb-enable-popup-overlay'] = 'on';
359
- }
360
-
361
- return $options;
362
- }
363
-
364
- public function excludePostToShowPrepare()
365
- {
366
- SgpbPopupConfig::popupTypesInit();
367
- $queryString = SGPopup::getActivePopupsQueryString();
368
- $this->setQueryString($queryString);
369
- add_filter('posts_where' , array($this, 'excludePostsToShow'), 10, 1);
370
- }
371
-
372
- public function exportFileName($fileName)
373
- {
374
- if (!empty($_GET['sgpbExportAction'])) {
375
- return SGPB_POPUP_EXPORT_FILE_NAME;
376
- }
377
-
378
- return $fileName;
379
- }
380
-
381
- public function filterOption($filterOption)
382
- {
383
- $extensionOptionsData = AdminHelper::getExtensionAvaliabilityOptions();
384
-
385
- if (empty($extensionOptionsData)) {
386
- return $filterOption;
387
- }
388
-
389
- foreach ($extensionOptionsData as $extensionKey => $extensionOptions) {
390
- $isAdvancedClosingActive = is_plugin_active($extensionKey);
391
- if (isset($filterOption['name']) && !$isAdvancedClosingActive) {
392
- $name = $filterOption['name'];
393
-
394
- if (in_array($name, $extensionOptions)) {
395
- $filterOption['status'] = false;
396
- }
397
- }
398
- }
399
-
400
- return $filterOption;
401
- }
402
-
403
- public function metaboxes($metaboxes)
404
- {
405
- $otherConditionsProLabel = '';
406
- $otherConditionsCanBeUsed = PopupBuilderActivePackage::canUseSection('popupOtherConditionsSection');
407
- if (!$otherConditionsCanBeUsed) {
408
- $otherConditionsProLabel .= '<a href="'.SG_POPUP_SCHEDULING_URL.'" target="_blank" class="sgpb-pro-label-metabox">';
409
- $otherConditionsProLabel .= __('UNLOCK OPTION', SG_POPUP_TEXT_DOMAIN).'</a>';
410
- }
411
- $metaboxes['targetMetaboxView'] = array(
412
- 'key' => 'targetMetaboxView',
413
- 'displayName' => 'Popup Display Rules',
414
- 'filePath' => SG_POPUP_VIEWS_PATH.'targetView.php',
415
- 'priority' => 'high'
416
- );
417
-
418
- $metaboxes['eventsMetaboxView'] = array(
419
- 'key' => 'eventsMetaboxView',
420
- 'displayName' => 'Popup Events',
421
- 'filePath' => SG_POPUP_VIEWS_PATH.'eventsView.php',
422
- 'priority' => 'high'
423
- );
424
-
425
- $metaboxes['conditionsMetaboxView'] = array(
426
- 'key' => 'conditionsMetaboxView',
427
- 'displayName' => 'Popup Conditions',
428
- 'filePath' => SG_POPUP_VIEWS_PATH.'conditionsView.php',
429
- 'priority' => 'high'
430
- );
431
-
432
- $metaboxes['behaviorAfterSpecialEventsMetaboxView'] = array(
433
- 'key' => 'behaviorAfterSpecialEventsMetaboxView',
434
- 'displayName' => 'Behavior After Special Events',
435
- 'filePath' => SG_POPUP_VIEWS_PATH.'behaviorAfterSpecialEventsView.php',
436
- 'priority' => 'high'
437
- );
438
-
439
- $metaboxes['popupDesignMetaBoxView'] = array(
440
- 'key' => 'popupDesignMetaBoxView',
441
- 'displayName' => 'Design',
442
- 'filePath' => SG_POPUP_VIEWS_PATH.'popupDesignView.php',
443
- 'priority' => 'high'
444
- );
445
-
446
- $metaboxes['closeSettings'] = array(
447
- 'key' => 'closeSettings',
448
- 'displayName' => 'Close Settings',
449
- 'filePath' => SG_POPUP_VIEWS_PATH.'closeSettingsView.php',
450
- 'priority' => 'high'
451
- );
452
-
453
- $metaboxes['spgdimension'] = array(
454
- 'key' => 'spgdimension',
455
- 'displayName' => 'Dimensions',
456
- 'filePath' => SG_POPUP_VIEWS_PATH.'dimensionsView.php',
457
- 'priority' => 'high'
458
- );
459
-
460
- $metaboxes['optionsMetaboxView'] = array(
461
- 'key' => 'optionsMetaboxView',
462
- 'displayName' => 'Popup Options',
463
- 'filePath' => SG_POPUP_VIEWS_PATH.'optionsView.php',
464
- 'priority' => 'high'
465
- );
466
-
467
- $metaboxes['otherConditionsMetaBoxView'] = array(
468
- 'key' => 'otherConditionsMetaBoxView',
469
- 'displayName' => 'Popup Additional Conditions'.$otherConditionsProLabel,
470
- 'filePath' => SG_POPUP_VIEWS_PATH.'otherConditionsView.php',
471
- 'priority' => 'high'
472
- );
473
-
474
- $metaboxes['customCssJs'] = array(
475
- 'key' => 'customCssJs',
476
- 'displayName' => 'Custom JS or CSS',
477
- 'filePath' => SG_POPUP_VIEWS_PATH.'customEditor.php',
478
- 'priority' => 'low'
479
- );
480
-
481
- $metaboxes['floatingButton'] = array(
482
- 'key' => 'floatingButton',
483
- 'displayName' => 'Floating Button',
484
- 'filePath' => SG_POPUP_VIEWS_PATH.'floatingButton.php',
485
- 'context' => 'side',
486
- 'priority' => 'high'
487
- );
488
-
489
- $metaboxes['popupOpeningCounter'] = array(
490
- 'key' => 'popupOpeningCounter',
491
- 'displayName' => 'Popup statistics',
492
- 'filePath' => SG_POPUP_VIEWS_PATH.'popupOpeningCounter.php',
493
- 'context' => 'side',
494
- 'priority' => 'low'
495
- );
496
-
497
- return $metaboxes;
498
- }
499
-
500
- public function popupEvents($events)
501
- {
502
- foreach ($events as $eventKey => $eventData) {
503
- if (isset($eventData['param'])) {
504
- if ($eventData['param'] == SGPB_CSS_CLASS_ACTIONS_KEY) {
505
- unset($events[$eventKey]);
506
- $events[] = array('param' => 'click');
507
- $events[] = array('param' => 'hover');
508
- $events[] = array('param' => 'confirm');
509
- }
510
- else if ($eventData['param'] == SGPB_CLICK_ACTION_KEY) {
511
- $events[$eventKey]['param'] = 'click';
512
- }
513
- else if ($eventData['param'] == SGPB_HOVER_ACTION_KEY) {
514
- $events[$eventKey]['param'] = 'hover';
515
- }
516
- }
517
- }
518
-
519
- return $events;
520
- }
521
-
522
- public function savedPostData($postData)
523
- {
524
- // for old popups here we change already saved old popup id
525
- if (isset($postData['sgpb-mailchimp-success-popup'])) {
526
- // sgpGetCorrectPopupId it's a temporary function and it will be removed in future
527
- if (function_exists(__NAMESPACE__.'\sgpGetCorrectPopupId')) {
528
- $postData['sgpb-mailchimp-success-popup'] = sgpGetCorrectPopupId($postData['sgpb-mailchimp-success-popup']);
529
- }
530
- }
531
- // for old popups here we change already saved old popup id
532
- if (isset($postData['sgpb-aweber-success-popup'])) {
533
- if (function_exists(__NAMESPACE__.'\sgpGetCorrectPopupId')) {
534
- $postData['sgpb-aweber-success-popup'] = sgpGetCorrectPopupId($postData['sgpb-aweber-success-popup']);
535
- }
536
- }
537
-
538
- return $postData;
539
- }
540
-
541
- public function removeAddNewSubmenu()
542
- {
543
- //we don't need the default add new, since we are using our custom page for it
544
- $page = remove_submenu_page(
545
- 'edit.php?post_type='.SG_POPUP_POST_TYPE,
546
- 'post-new.php?post_type='.SG_POPUP_POST_TYPE
547
- );
548
- }
549
-
550
- public function maybeShortenEddFilename($return, $package)
551
- {
552
- if (strpos($package, SG_POPUP_STORE_URL) !== false) {
553
- add_filter('wp_unique_filename', array($this, 'shortenEddFilename'), 100, 2);
554
- }
555
- return $return;
556
- }
557
-
558
- public function shortenEddFilename($filename, $ext)
559
- {
560
- $filename = substr($filename, 0, 20).$ext;
561
- remove_filter('wp_unique_filename', array($this, 'shortenEddFilename'), 10);
562
- return $filename;
563
- }
564
-
565
- public function editPopupPreviewLink($previewLink = '', $post = array())
566
- {
567
- if (!empty($post) && $post->post_type == SG_POPUP_POST_TYPE) {
568
- $popupId = $post->ID;
569
- $targets = get_post_meta($popupId, 'sg_popup_target_preview', true);
570
- if (empty($targets['sgpb-target'][0])) {
571
- return $previewLink .= '/?sg_popup_preview_id='.$popupId;
572
- }
573
- $targetParams = @$targets['sgpb-target'][0][0]['param'];
574
- if ((!empty($targetParams) && $targetParams == 'not_rule') || empty($targetParams)) {
575
- $previewLink = home_url();
576
- $previewLink .= '/?sg_popup_preview_id='.$popupId;
577
-
578
- return $previewLink;
579
- }
580
- foreach ($targets['sgpb-target'][0] as $targetKey => $targetValue) {
581
- if (!isset($targetValue['operator']) || $targetValue['operator'] == '!=') {
582
- continue;
583
- }
584
- $previewLink = self::getPopupPreviewLink($targetValue, $popupId);
585
- $previewLink .= '/?sg_popup_preview_id='.$popupId;
586
- }
587
- }
588
-
589
- return $previewLink;
590
- }
591
-
592
- public static function getPopupPreviewLink($targetData, $popupId)
593
- {
594
- $previewLink = home_url();
595
-
596
- if (empty($targetData['param'])) {
597
- return $previewLink;
598
- }
599
- $targetParam = $targetData['param'];
600
-
601
- if ($targetParam == 'everywhere') {
602
- return $previewLink;
603
- }
604
-
605
- $args = array(
606
- 'orderby' => 'rand'
607
- );
608
-
609
- // posts
610
- if (strpos($targetData['param'], '_all')) {
611
- if ($targetData['param'] == 'post_all') {
612
- $args['post_type'] = 'post';
613
- }
614
- if ($targetData['param'] == 'page_all') {
615
- $args['post_type'] = 'page';
616
- }
617
- }
618
- if ($targetData['param'] == 'post_type' && !empty($targetData['value'])) {
619
- $args['post_type'] = $targetData['value'];
620
- }
621
- if ($targetData['param'] == 'page_type' && !empty($targetData['value'])) {
622
- $pageTypes = $targetData['value'];
623
- foreach ($pageTypes as $pageType) {
624
-
625
- if ($pageType == 'is_home_page') {
626
- if (is_front_page() && is_home()) {
627
- // default homepage
628
- return get_home_url();
629
- }
630
- else if (is_front_page()) {
631
- // static homepage
632
- return get_home_url();
633
- }
634
- }
635
- else if (function_exists($pageType)) {
636
- if ($pageType == 'is_home') {
637
- return get_home_url();
638
- }
639
- else if ($pageType == 'is_search') {
640
- return get_search_link();
641
- }
642
- else if ($pageType == 'is_shop') {
643
- return get_home_url().'/shop/';
644
- }
645
- }
646
- }
647
- }
648
- if (isset($args['post_type'])) {
649
- $the_query = new WP_Query($args);
650
- foreach ($the_query->posts as $post) {
651
- $postId = $post->ID;
652
- if (get_permalink($postId)) {
653
- return get_permalink($postId);
654
- }
655
- }
656
- }
657
- // selected post/page/custom_post_types...
658
- if (strpos($targetData['param'], '_selected') && !empty($targetData['value'])) {
659
- $value = array_keys($targetData['value']);
660
- if (!empty($value[0])) {
661
- if (get_permalink($value[0])) {
662
- return get_permalink($value[0]);
663
- }
664
- }
665
- }
666
- if (strpos($targetData['param'], '_archive') && !empty($targetData['value'])) {
667
- $value = array_keys($targetData['value']);
668
- if (!empty($value[0])) {
669
- if (get_permalink($value[0])) {
670
- return get_permalink($value[0]);
671
- }
672
- }
673
- }
674
-
675
- return $previewLink;
676
- }
677
-
678
- public function excludePostsToShow($where)
679
- {
680
- if (function_exists('is_admin') && is_admin()) {
681
- if (!function_exists('get_current_screen')) {
682
- return $where;
683
- }
684
-
685
- $screen = get_current_screen();
686
- if (empty($screen)) {
687
- return $where;
688
- }
689
-
690
- $postType = $screen->post_type;
691
- if ($postType == SG_POPUP_POST_TYPE &&
692
- $screen instanceof \WP_Screen &&
693
- $screen->id === 'edit-popupbuilder') {
694
- if (class_exists('sgpb\SGPopup')) {
695
- $activePopupsQuery = $this->getQueryString();
696
- if ($activePopupsQuery && $activePopupsQuery != '') {
697
- $where .= $activePopupsQuery;
698
- }
699
- }
700
- }
701
- }
702
-
703
- return $where;
704
- }
705
-
706
- public function clearContentPreviewMode($content)
707
- {
708
- global $post_type;
709
-
710
- if (is_preview() && $post_type == SG_POPUP_POST_TYPE) {
711
- $content = '';
712
- }
713
-
714
- return $content;
715
- }
716
-
717
- public function filterPopupContent($content, $popupId)
718
- {
719
- preg_match_all('/<iframe.*?src="(.*?)".*?<\/iframe>/', $content, $matches);
720
- /*$finalContent = '';*/
721
- // $matches[0] array contain iframes stings
722
- // $matches[1] array contain iframes URLs
723
- if (empty($matches) && empty($matches[0]) && empty($matches[1])) {
724
- return $content;
725
- }
726
- $urls = $matches[1];
727
-
728
- foreach ($matches[0] as $key => $iframe) {
729
- if (empty($urls[$key])) {
730
- continue;
731
- }
732
-
733
- $pos = strpos($iframe, $urls[$key]);
734
-
735
- if ($pos === false) {
736
- continue;
737
- }
738
-
739
- $content = str_replace(' src="'.$urls[$key].'"', ' src="" data-attr-src="'.esc_attr($urls[$key]).'"', $content);
740
- }
741
- if (function_exists('do_blocks')) {
742
- $content = do_blocks($content);
743
- }
744
-
745
- return do_shortcode($content);
746
- }
747
-
748
- public function addNewPostUrl($url, $path)
749
- {
750
- if ($path == 'post-new.php?post_type='.SG_POPUP_POST_TYPE) {
751
- $url = str_replace('post-new.php?post_type='.SG_POPUP_POST_TYPE, 'edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_POST_TYPE, $url);
752
- }
753
-
754
- return $url;
755
- }
756
-
757
- public function popupsTableColumns($columns)
758
- {
759
- unset($columns['date']);
760
-
761
- $additionalItems = array();
762
- $additionalItems['counter'] = __('Views', SG_POPUP_TEXT_DOMAIN);
763
- $additionalItems['onOff'] = __('Enabled (show popup)', SG_POPUP_TEXT_DOMAIN);
764
- $additionalItems['type'] = __('Type', SG_POPUP_TEXT_DOMAIN);
765
- $additionalItems['shortcode'] = __('Shortcode', SG_POPUP_TEXT_DOMAIN);
766
- $additionalItems['className'] = __('Class', SG_POPUP_TEXT_DOMAIN);
767
-
768
- return $columns + $additionalItems;
769
- }
770
-
771
- /**
772
- * Function to add/hide links from popups dataTable row
773
- */
774
- public function quickRowLinksManager($actions, $post)
775
- {
776
- global $post_type;
777
-
778
- if ($post_type != SG_POPUP_POST_TYPE) {
779
- return $actions;
780
- }
781
- // remove quick edit link
782
- unset($actions['inline hide-if-no-js']);
783
- // remove view link
784
- unset($actions['view']);
785
-
786
- $actions['clone'] = '<a href="'.$this->popupGetClonePostLink($post->ID , 'display', false).'" title="';
787
- $actions['clone'] .= esc_attr__("Clone this item", SG_POPUP_TEXT_DOMAIN);
788
- $actions['clone'] .= '">'. esc_html__('Clone', SG_POPUP_TEXT_DOMAIN).'</a>';
789
-
790
- return $actions;
791
- }
792
-
793
- /**
794
- * Retrieve duplicate post link for post.
795
- *
796
- * @param int $id Optional. Post ID.
797
- * @param string $context Optional, default to display. How to write the '&', defaults to '&amp;'.
798
- * @return string
799
- */
800
- public function popupGetClonePostLink($id = 0, $context = 'display')
801
- {
802
- if (!$post = get_post($id)) {
803
- return;
804
- }
805
- $actionName = "popupSaveAsNew";
806
-
807
- if ('display' == $context) {
808
- $action = '?action='.$actionName.'&amp;post='.$post->ID;
809
- } else {
810
- $action = '?action='.$actionName.'&post='.$post->ID;
811
- }
812
-
813
- $postTypeObject = get_post_type_object($post->post_type);
814
-
815
- if (!$postTypeObject) {
816
- return;
817
- }
818
-
819
- return wp_nonce_url(apply_filters('popupGetClonePostLink', admin_url("admin.php".$action), $post->ID, $context), 'duplicate-post_' . $post->ID);
820
- }
821
-
822
- /* media button scripts */
823
- public function adminJsFilter($jsFiles)
824
- {
825
- $allowToShow = MediaButton::allowToShow();
826
- if ($allowToShow) {
827
- $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'select2.min.js');
828
- $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'sgpbSelect2.js');
829
- $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'Popup.js');
830
- $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'PopupConfig.js');
831
- $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'MediaButton.js');
832
-
833
- $jsFiles['localizeData'][] = array(
834
- 'handle' => 'Popup.js',
835
- 'name' => 'sgpbPublicUrl',
836
- 'data' => SG_POPUP_PUBLIC_URL
837
- );
838
-
839
- $jsFiles['localizeData'][] = array(
840
- 'handle' => 'MediaButton.js',
841
- 'name' => 'mediaButtonParams',
842
- 'data' => array(
843
- 'currentPostType' => get_post_type(),
844
- 'popupBuilderPostType' => SG_POPUP_POST_TYPE,
845
- 'ajaxUrl' => admin_url('admin-ajax.php'),
846
- 'nonce' => wp_create_nonce(SG_AJAX_NONCE)
847
- )
848
- );
849
- }
850
-
851
- return $jsFiles;
852
- }
853
-
854
- /* media button styles */
855
- public function sgpbAdminCssFiles($cssFiles)
856
- {
857
- $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'sgbp-bootstrap.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
858
- $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'select2.min.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
859
- $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'popupAdminStyles.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
860
-
861
- return $cssFiles;
862
- }
863
- }
864
-
865
-
 
 
 
 
 
1
+ <?php
2
+ namespace sgpb;
3
+ use \WP_Query;
4
+ use \SgpbPopupConfig;
5
+ use sgpb\PopupBuilderActivePackage;
6
+ use sgpb\SGPopup;
7
+
8
+ class Filters
9
+ {
10
+ private $activePopupsQueryString = '';
11
+
12
+ public function setQueryString($activePopupsQueryString)
13
+ {
14
+ $this->activePopupsQueryString = $activePopupsQueryString;
15
+ }
16
+
17
+ public function getQueryString()
18
+ {
19
+ return $this->activePopupsQueryString;
20
+ }
21
+
22
+ public function __construct()
23
+ {
24
+ $this->init();
25
+ }
26
+
27
+ public function init()
28
+ {
29
+ add_filter('admin_url', array($this, 'addNewPostUrl'), 10, 2);
30
+ add_filter('wpseo_sitemap_exclude_post_type', array($this, 'excludeSitemapsYoast'), 10, 2);
31
+ add_filter('admin_menu', array($this, 'removeAddNewSubmenu'), 10, 2);
32
+ add_filter('manage_'.SG_POPUP_POST_TYPE.'_posts_columns', array($this, 'popupsTableColumns'));
33
+ add_filter('post_row_actions', array($this, 'quickRowLinksManager'), 10, 2);
34
+ add_filter('sgpbAdminJs', array($this, 'adminJsFilter'), 1, 1);
35
+ add_filter('sgpbAdminCssFiles', array($this, 'sgpbAdminCssFiles'), 1, 1);
36
+ add_filter('sgpbPopupContentLoadToPage', array($this, 'filterPopupContent'), 10, 2);
37
+ add_filter('the_content', array($this, 'clearContentPreviewMode'), 10, 1);
38
+ // The priority of this action should be higher than the extensions' init priority.
39
+ add_action('init', array($this, 'excludePostToShowPrepare'), 99999999);
40
+ add_filter('preview_post_link', array($this, 'editPopupPreviewLink'), 10, 2);
41
+ add_filter('upgrader_pre_download', array($this, 'maybeShortenEddFilename'), 10, 4);
42
+ add_filter('sgpbSavedPostData', array($this, 'savedPostData'), 10, 1);
43
+ add_filter('sgpbPopupEvents', array($this, 'popupEvents'), 10, 1);
44
+ add_filter('sgpbAdditionalMetaboxes', array($this, 'metaboxes'), 10, 1);
45
+ add_filter('sgpbOptionAvailable', array($this, 'filterOption'), 10, 1);
46
+ add_filter('export_wp_filename', array($this, 'exportFileName'), 10, 1);
47
+ add_filter('sgpbAdvancedOptionsDefaultValues', array($this, 'defaultAdvancedOptionsValues'), 10, 1);
48
+ add_filter('sgpbPopupContentLoadToPage', array($this, 'popupContentLoadToPage'), 10, 2);
49
+ add_filter('sgpbExtraNotifications', array($this, 'sgpbExtraNotifications'), 10, 1);
50
+ add_filter('sgpbSystemInformation', array($this, 'systemInformation'), 10, 1);
51
+ add_filter('plugin_action_links', array($this, 'pluginActionLinks'), 10, 4);
52
+ add_filter('plugin_row_meta', array( $this, 'pluginRowMetas'), 10, 4);
53
+ add_filter('rank_math/sitemap/exclude_post_type', array($this, 'excludeRankMath'), 10, 2);
54
+ add_filter('sgpbUserSelectionQuery', array($this, 'userSelectionQueryAddExtraAttributes'), 100, 1);
55
+ add_filter('sgpbFilterOptionsBeforeSaving', array($this, 'filterOptionsBeforeSaving'), 100, 1);
56
+ add_filter('sgpbPopupExtraData', array($this, 'popupExtraDataRender'), 100, 2);
57
+ add_filter('wpml_link_to_translation', array($this, 'linkToTranslationWpml'), 30, 4);
58
+ add_filter('pll_get_post_types', array($this, 'enablePBpostTypeForTranslating'), 10, 2);
59
+ }
60
+
61
+ public function enablePBpostTypeForTranslating($postTypes, $isSettings)
62
+ {
63
+ $postTypes[SG_POPUP_POST_TYPE] = SG_POPUP_POST_TYPE;
64
+
65
+ return $postTypes;
66
+ }
67
+
68
+ public function linkToTranslationWpml($link, $postId, $lang, $trid)
69
+ {
70
+ if (strpos($link, SG_POPUP_POST_TYPE) && strpos($link, 'source_lang') && isset($trid)) {
71
+
72
+ $popupType = 'html';
73
+ $popup = SGPopup::find($postId);
74
+ if (!empty($popup) || !is_object($popup)) {
75
+ $popupType = $popup->getType();
76
+ }
77
+ $link .= '&sgpb_type='.$popupType;
78
+ }
79
+
80
+ return $link;
81
+ }
82
+
83
+ public function popupExtraDataRender($popupId = 0, $popupOptions = array())
84
+ {
85
+ $floatingButton = '';
86
+ if (empty($popupOptions['sgpb-enable-floating-button'])) {
87
+ return $floatingButton;
88
+ }
89
+ $buttonStyles = 'z-index:99999999999;';
90
+ $buttonClass = 'sgpb-'.$popupOptions['sgpb-floating-button-style'].'-'.$popupOptions['sgpb-floating-button-position'];
91
+
92
+ if (isset($popupOptions['sgpb-floating-button-style']) && $popupOptions['sgpb-floating-button-style'] == 'basic' && strstr($popupOptions['sgpb-floating-button-position'], 'center')) {
93
+ if (strstr($popupOptions['sgpb-floating-button-position'], 'top')) {
94
+ $buttonStyles .= 'top: 0%;';
95
+ $buttonStyles .= 'right: '.$popupOptions['sgpb-floating-button-position-right'].'%;';
96
+ }
97
+ else if (strstr($popupOptions['sgpb-floating-button-position'], 'bottom')) {
98
+ $buttonStyles .= 'bottom: 0%;';
99
+ $buttonStyles .= 'right: '.$popupOptions['sgpb-floating-button-position-right'].'%;';
100
+ }
101
+ else if (strstr($popupOptions['sgpb-floating-button-position'], 'left') || strstr($popupOptions['sgpb-floating-button-position'], 'right')) {
102
+ $buttonStyles .= 'top: '.$popupOptions['sgpb-floating-button-position-top'].'%;';
103
+ }
104
+ }
105
+
106
+ if (isset($popupOptions['sgpb-floating-button-font-size'])) {
107
+ $buttonStyles .= 'font-size: '.$popupOptions['sgpb-floating-button-font-size'].'px;';
108
+ }
109
+ if (isset($popupOptions['sgpb-floating-button-border-size'])) {
110
+ $buttonStyles .= 'border-width: '.$popupOptions['sgpb-floating-button-border-size'].'px;';
111
+ $buttonStyles .= 'border-style: solid;';
112
+ }
113
+ if (isset($popupOptions['sgpb-floating-button-border-radius'])) {
114
+ $buttonStyles .= 'border-radius: '.$popupOptions['sgpb-floating-button-border-radius'].'px;';
115
+ }
116
+ if (isset($popupOptions['sgpb-floating-button-border-color'])) {
117
+ $buttonStyles .= 'border-color: '.$popupOptions['sgpb-floating-button-border-color'].';';
118
+ }
119
+ if (isset($popupOptions['sgpb-floating-button-bg-color'])) {
120
+ $buttonStyles .= 'background-color: '.$popupOptions['sgpb-floating-button-bg-color'].';';
121
+ }
122
+ if (isset($popupOptions['sgpb-floating-button-text-color'])) {
123
+ $buttonStyles .= 'color: '.$popupOptions['sgpb-floating-button-text-color'].';';
124
+ }
125
+
126
+ /*
127
+ * We first hide to make all CSS load then we will show once document is ready
128
+ * SgpbEventListener.eventsListenerAfterDocumentReady -> showFloatingButton
129
+ */
130
+ $buttonStyles .= 'display: none;';
131
+
132
+ $floatingButton = '<div class="'.$buttonClass.' sgpb-floating-button sg-popup-id-'.$popupId.'" style="'.$buttonStyles.'"><span class="sgpb-'.$popupOptions['sgpb-floating-button-style'].'-floating-button-text">'.$popupOptions['sgpb-floating-button-text'].'</span></div>';
133
+
134
+ return $floatingButton;
135
+ }
136
+
137
+ public function filterOptionsBeforeSaving($unfilteredData = array())
138
+ {
139
+ $externalOptions = array(
140
+ 'icl_post_language' => 'sgpb-icl_post_language'
141
+ );
142
+
143
+ foreach ($externalOptions as $optionKey => $value) {
144
+ if (isset($unfilteredData[$optionKey])) {
145
+ $unfilteredData[$value] = $unfilteredData[$optionKey];
146
+ // there is no need to unset the old index value, because in the next step we'll take only the values from indexes started with "sgpb"
147
+ }
148
+ }
149
+
150
+ return $unfilteredData;
151
+ }
152
+
153
+ public function userSelectionQueryAddExtraAttributes($query)
154
+ {
155
+ $query .= ' status = 0 and unsubscribed = 0';
156
+
157
+ return $query;
158
+ }
159
+
160
+ public function excludeRankMath($exclude, $type)
161
+ {
162
+ if ($type == SG_POPUP_POST_TYPE) {
163
+ $exclude = true;
164
+ }
165
+
166
+ return $exclude;
167
+ }
168
+
169
+ public function pluginRowMetas($pluginMeta, $pluginFile, $pluginData, $status)
170
+ {
171
+ if (empty($pluginFile)) {
172
+ return $pluginMeta;
173
+ }
174
+
175
+ $allExtensions = \SgpbDataConfig::allExtensionsKeys();
176
+ $allExtensions = wp_list_pluck($allExtensions, 'pluginKey');
177
+ $allExtensions[] = SG_POPUP_FILE_NAME;
178
+
179
+ $rowMeta = array(
180
+ 'rateus' => '<a href="'.SG_POPUP_RATE_US_URL.'" target="_blank">'.esc_html__('Rate us', SG_POPUP_TEXT_DOMAIN).'</a>',
181
+ 'support' => '<a href="'.SG_POPUP_SUPPORT_URL.'" target="_blank">'.esc_html__('Support', SG_POPUP_TEXT_DOMAIN).'</a>'
182
+ );
183
+
184
+ if (in_array($pluginFile, $allExtensions)) {
185
+ $pluginMeta = array_merge($pluginMeta, $rowMeta);
186
+ }
187
+
188
+ return $pluginMeta;
189
+ }
190
+
191
+ public function pluginActionLinks($actions, $pluginFile, $pluginData, $context)
192
+ {
193
+ if (empty($pluginFile)) {
194
+ return $actions;
195
+ }
196
+
197
+ $allExtensions = \SgpbDataConfig::allExtensionsKeys();
198
+ $allExtensions = wp_list_pluck($allExtensions, 'pluginKey');
199
+ $allExtensions[] = SG_POPUP_FILE_NAME;
200
+
201
+ $settingPageUrl = admin_url().'edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_SETTINGS_PAGE;
202
+
203
+ $links = array(
204
+ 'settings' => '<a href="'.$settingPageUrl.'" target="_blank">'.esc_html__('Settings', SG_POPUP_TEXT_DOMAIN).'</a>',
205
+ 'docs' => '<a href="'.SG_POPUP_TICKET_URL.'" target="_blank">'.esc_html__('Docs', SG_POPUP_TEXT_DOMAIN).'</a>'
206
+ );
207
+
208
+ if (in_array($pluginFile, $allExtensions)) {
209
+ if ($pluginFile == SG_POPUP_FILE_NAME) {
210
+ $getActiveExtensions = AdminHelper::getAllExtensions();
211
+ if (empty($getActiveExtensions['active'])) {
212
+ $links['upgrade'] = '<a style="color: #4364eb;" href="'.SG_POPUP_BUNDLE_URL.'" target="_blank">'.esc_html__('Upgrade', SG_POPUP_TEXT_DOMAIN).'</a>';
213
+ }
214
+ }
215
+ $actions = array_merge($links, $actions);
216
+ }
217
+
218
+ return $actions;
219
+ }
220
+
221
+ public function systemInformation($infoContent)
222
+ {
223
+
224
+ $infoContent .= 'Platform: '.@$platform . "\n";
225
+ $infoContent .= 'Browser Name: '.@$bname . "\n";
226
+ $infoContent .= 'Browser Version: '.@$version . "\n";
227
+ $infoContent .= 'User Agent: '.@$uAgent . "\n";
228
+
229
+ return $infoContent;
230
+ }
231
+
232
+ public function popupContentLoadToPage($content, $popupId)
233
+ {
234
+ $customScripts = AdminHelper::renderCustomScripts($popupId);
235
+ $content .= $customScripts;
236
+
237
+ return $content;
238
+ }
239
+
240
+ public function sgpbExtraNotifications($notifications = array())
241
+ {
242
+ $license = self::licenseNotification();
243
+ if (!empty($license)) {
244
+ $notifications[] = $license;
245
+ }
246
+
247
+ $promotional = self::promotionalNotifications();
248
+ if (!empty($promotional)) {
249
+ $notifications[] = $promotional;
250
+ }
251
+
252
+ $supportBanner = self::supportBannerNotifcations();
253
+ if (!empty($supportBanner)) {
254
+ $notifications[] = $supportBanner;
255
+ }
256
+
257
+ return $notifications;
258
+ }
259
+
260
+ public static function supportBannerNotifcations()
261
+ {
262
+ $hideSupportBanner = get_option('sgpb-hide-support-banner');
263
+ if (!empty($hideSupportBanner)) {
264
+ return array();
265
+ }
266
+ $message = AdminHelper::supportBannerNotification();
267
+ $notification['id'] = SGPB_SUPPORT_BANNER_NOTIFICATION_ID;
268
+ $notification['priority'] = 1;
269
+ $notification['type'] = 1;
270
+ $notification['message'] = $message;
271
+
272
+ return $notification;
273
+ }
274
+
275
+ public static function promotionalNotifications()
276
+ {
277
+ $alreadyDone = get_option('SGPBCloseReviewPopup-notification');
278
+ if (!empty($alreadyDone)) {
279
+ return array();
280
+ }
281
+ $id = SGPB_RATE_US_NOTIFICATION_ID;
282
+ $type = 1;
283
+ $priority = 1;
284
+
285
+ $maxOpenPopupStatus = AdminHelper::shouldOpenForMaxOpenPopupMessage();
286
+ // popup opening count notification
287
+ if ($maxOpenPopupStatus) {
288
+ $message = AdminHelper::getMaxOpenPopupsMessage();
289
+ }
290
+
291
+ $shouldOpenForDays = AdminHelper::shouldOpenReviewPopupForDays();
292
+ if ($shouldOpenForDays && !$maxOpenPopupStatus) {
293
+ $message = AdminHelper::getMaxOpenDaysMessage();
294
+ }
295
+ if (empty($message)) {
296
+ return array();
297
+ }
298
+
299
+ $alternateNotification['priority'] = $priority;
300
+ $alternateNotification['type'] = $type;
301
+ $alternateNotification['id'] = $id;
302
+ $alternateNotification['message'] = $message;
303
+
304
+ return $alternateNotification;
305
+ }
306
+
307
+ public function licenseNotification()
308
+ {
309
+ $inactiveExtensionNotice = array();
310
+ $dontShowLicenseBanner = get_option('sgpb-hide-license-notice-banner');
311
+ if ($dontShowLicenseBanner) {
312
+ return $notifications;
313
+ }
314
+
315
+ $inactive = AdminHelper::getOption('SGPB_INACTIVE_EXTENSIONS');
316
+ $hasInactiveExtensions = AdminHelper::hasInactiveExtensions();
317
+
318
+ if (!$inactive) {
319
+ AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 1);
320
+ if ($hasInactiveExtensions) {
321
+ AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 'inactive');
322
+ $inactive = 'inactive';
323
+ }
324
+
325
+ }
326
+
327
+ if ($hasInactiveExtensions && $inactive == 'inactive') {
328
+ $licenseSectionUrl = menu_page_url(SGPB_POPUP_LICENSE, false);
329
+ $partOfContent = '<br><br>'.__('<a href="'.$licenseSectionUrl.'">Follow the link</a> to finalize the activation.', SG_POPUP_TEXT_DOMAIN);
330
+ $message = '<b>'.__('Thank you for choosing our plugin!', SG_POPUP_TEXT_DOMAIN).'</b>';
331
+ $message .= '<br>';
332
+ $message .= '<br>';
333
+ $message .= '<b>'.__('You have activated Popup Builder extension(s). Please, don\'t forget to activate the license key(s) as well.', SG_POPUP_TEXT_DOMAIN).'</b>';
334
+ $message .= '<b>'.$partOfContent.'</b>';
335
+
336
+ $inactiveExtensionNotice['priority'] = 1;
337
+ $inactiveExtensionNotice['type'] = 2;
338
+ $inactiveExtensionNotice['id'] = 'sgpbMainActiveInactiveLicense';
339
+ $inactiveExtensionNotice['message'] = $message;
340
+ }
341
+
342
+ return $inactiveExtensionNotice;
343
+ }
344
+
345
+ public function excludeSitemapsYoast($exclude = false, $postType)
346
+ {
347
+ $postTypeObject = get_post_type_object($postType);
348
+ if (!is_object($postTypeObject)) {
349
+ return $exclude;
350
+ }
351
+
352
+ if ($postTypeObject->public === false || $postType == SG_POPUP_POST_TYPE) {
353
+ return true;
354
+ }
355
+
356
+ return $exclude;
357
+ }
358
+
359
+ public function defaultAdvancedOptionsValues($options = array())
360
+ {
361
+ $enablePopupOverlay = PopupBuilderActivePackage::canUseOption('sgpb-enable-popup-overlay');
362
+ if (!$enablePopupOverlay) {
363
+ $options['sgpb-enable-popup-overlay'] = 'on';
364
+ }
365
+
366
+ return $options;
367
+ }
368
+
369
+ public function excludePostToShowPrepare()
370
+ {
371
+ SgpbPopupConfig::popupTypesInit();
372
+ $queryString = SGPopup::getActivePopupsQueryString();
373
+ $this->setQueryString($queryString);
374
+ add_filter('posts_where' , array($this, 'excludePostsToShow'), 10, 1);
375
+ }
376
+
377
+ public function exportFileName($fileName)
378
+ {
379
+ if (!empty($_GET['sgpbExportAction'])) {
380
+ return SGPB_POPUP_EXPORT_FILE_NAME;
381
+ }
382
+
383
+ return $fileName;
384
+ }
385
+
386
+ public function filterOption($filterOption)
387
+ {
388
+ $extensionOptionsData = AdminHelper::getExtensionAvaliabilityOptions();
389
+
390
+ if (empty($extensionOptionsData)) {
391
+ return $filterOption;
392
+ }
393
+
394
+ foreach ($extensionOptionsData as $extensionKey => $extensionOptions) {
395
+ $isAdvancedClosingActive = is_plugin_active($extensionKey);
396
+ if (isset($filterOption['name']) && !$isAdvancedClosingActive) {
397
+ $name = $filterOption['name'];
398
+
399
+ if (in_array($name, $extensionOptions)) {
400
+ $filterOption['status'] = false;
401
+ }
402
+ }
403
+ }
404
+
405
+ return $filterOption;
406
+ }
407
+
408
+ public function metaboxes($metaboxes)
409
+ {
410
+ $otherConditionsProLabel = '';
411
+ $otherConditionsCanBeUsed = PopupBuilderActivePackage::canUseSection('popupOtherConditionsSection');
412
+ if (!$otherConditionsCanBeUsed) {
413
+ $otherConditionsProLabel .= '<a href="'.SG_POPUP_SCHEDULING_URL.'" target="_blank" class="sgpb-pro-label-metabox">';
414
+ $otherConditionsProLabel .= __('UNLOCK OPTION', SG_POPUP_TEXT_DOMAIN).'</a>';
415
+ }
416
+ $metaboxes['targetMetaboxView'] = array(
417
+ 'key' => 'targetMetaboxView',
418
+ 'displayName' => 'Popup Display Rules',
419
+ 'filePath' => SG_POPUP_VIEWS_PATH.'targetView.php',
420
+ 'priority' => 'high'
421
+ );
422
+
423
+ $metaboxes['eventsMetaboxView'] = array(
424
+ 'key' => 'eventsMetaboxView',
425
+ 'displayName' => 'Popup Events',
426
+ 'filePath' => SG_POPUP_VIEWS_PATH.'eventsView.php',
427
+ 'priority' => 'high'
428
+ );
429
+
430
+ $metaboxes['conditionsMetaboxView'] = array(
431
+ 'key' => 'conditionsMetaboxView',
432
+ 'displayName' => 'Popup Conditions',
433
+ 'filePath' => SG_POPUP_VIEWS_PATH.'conditionsView.php',
434
+ 'priority' => 'high'
435
+ );
436
+
437
+ $metaboxes['behaviorAfterSpecialEventsMetaboxView'] = array(
438
+ 'key' => 'behaviorAfterSpecialEventsMetaboxView',
439
+ 'displayName' => 'Behavior After Special Events',
440
+ 'filePath' => SG_POPUP_VIEWS_PATH.'behaviorAfterSpecialEventsView.php',
441
+ 'priority' => 'high'
442
+ );
443
+
444
+ $metaboxes['popupDesignMetaBoxView'] = array(
445
+ 'key' => 'popupDesignMetaBoxView',
446
+ 'displayName' => 'Design',
447
+ 'filePath' => SG_POPUP_VIEWS_PATH.'popupDesignView.php',
448
+ 'priority' => 'high'
449
+ );
450
+
451
+ $metaboxes['closeSettings'] = array(
452
+ 'key' => 'closeSettings',
453
+ 'displayName' => 'Close Settings',
454
+ 'filePath' => SG_POPUP_VIEWS_PATH.'closeSettingsView.php',
455
+ 'priority' => 'high'
456
+ );
457
+
458
+ $metaboxes['spgdimension'] = array(
459
+ 'key' => 'spgdimension',
460
+ 'displayName' => 'Dimensions',
461
+ 'filePath' => SG_POPUP_VIEWS_PATH.'dimensionsView.php',
462
+ 'priority' => 'high'
463
+ );
464
+
465
+ $metaboxes['optionsMetaboxView'] = array(
466
+ 'key' => 'optionsMetaboxView',
467
+ 'displayName' => 'Popup Options',
468
+ 'filePath' => SG_POPUP_VIEWS_PATH.'optionsView.php',
469
+ 'priority' => 'high'
470
+ );
471
+
472
+ $metaboxes['otherConditionsMetaBoxView'] = array(
473
+ 'key' => 'otherConditionsMetaBoxView',
474
+ 'displayName' => 'Popup Additional Conditions'.$otherConditionsProLabel,
475
+ 'filePath' => SG_POPUP_VIEWS_PATH.'otherConditionsView.php',
476
+ 'priority' => 'high'
477
+ );
478
+
479
+ $metaboxes['customCssJs'] = array(
480
+ 'key' => 'customCssJs',
481
+ 'displayName' => 'Custom JS or CSS',
482
+ 'filePath' => SG_POPUP_VIEWS_PATH.'customEditor.php',
483
+ 'priority' => 'low'
484
+ );
485
+
486
+ $metaboxes['floatingButton'] = array(
487
+ 'key' => 'floatingButton',
488
+ 'displayName' => 'Floating Button',
489
+ 'filePath' => SG_POPUP_VIEWS_PATH.'floatingButton.php',
490
+ 'context' => 'side',
491
+ 'priority' => 'high'
492
+ );
493
+
494
+ $metaboxes['popupOpeningCounter'] = array(
495
+ 'key' => 'popupOpeningCounter',
496
+ 'displayName' => 'Popup statistics',
497
+ 'filePath' => SG_POPUP_VIEWS_PATH.'popupOpeningCounter.php',
498
+ 'context' => 'side',
499
+ 'priority' => 'low'
500
+ );
501
+
502
+ return $metaboxes;
503
+ }
504
+
505
+ public function popupEvents($events)
506
+ {
507
+ foreach ($events as $eventKey => $eventData) {
508
+ if (isset($eventData['param'])) {
509
+ if ($eventData['param'] == SGPB_CSS_CLASS_ACTIONS_KEY) {
510
+ unset($events[$eventKey]);
511
+ $events[] = array('param' => 'click');
512
+ $events[] = array('param' => 'hover');
513
+ $events[] = array('param' => 'confirm');
514
+ }
515
+ else if ($eventData['param'] == SGPB_CLICK_ACTION_KEY) {
516
+ $events[$eventKey]['param'] = 'click';
517
+ }
518
+ else if ($eventData['param'] == SGPB_HOVER_ACTION_KEY) {
519
+ $events[$eventKey]['param'] = 'hover';
520
+ }
521
+ }
522
+ }
523
+
524
+ return $events;
525
+ }
526
+
527
+ public function savedPostData($postData)
528
+ {
529
+ // for old popups here we change already saved old popup id
530
+ if (isset($postData['sgpb-mailchimp-success-popup'])) {
531
+ // sgpGetCorrectPopupId it's a temporary function and it will be removed in future
532
+ if (function_exists(__NAMESPACE__.'\sgpGetCorrectPopupId')) {
533
+ $postData['sgpb-mailchimp-success-popup'] = sgpGetCorrectPopupId($postData['sgpb-mailchimp-success-popup']);
534
+ }
535
+ }
536
+ // for old popups here we change already saved old popup id
537
+ if (isset($postData['sgpb-aweber-success-popup'])) {
538
+ if (function_exists(__NAMESPACE__.'\sgpGetCorrectPopupId')) {
539
+ $postData['sgpb-aweber-success-popup'] = sgpGetCorrectPopupId($postData['sgpb-aweber-success-popup']);
540
+ }
541
+ }
542
+
543
+ return $postData;
544
+ }
545
+
546
+ public function removeAddNewSubmenu()
547
+ {
548
+ //we don't need the default add new, since we are using our custom page for it
549
+ $page = remove_submenu_page(
550
+ 'edit.php?post_type='.SG_POPUP_POST_TYPE,
551
+ 'post-new.php?post_type='.SG_POPUP_POST_TYPE
552
+ );
553
+ }
554
+
555
+ public function maybeShortenEddFilename($return, $package)
556
+ {
557
+ if (strpos($package, SG_POPUP_STORE_URL) !== false) {
558
+ add_filter('wp_unique_filename', array($this, 'shortenEddFilename'), 100, 2);
559
+ }
560
+ return $return;
561
+ }
562
+
563
+ public function shortenEddFilename($filename, $ext)
564
+ {
565
+ $filename = substr($filename, 0, 20).$ext;
566
+ remove_filter('wp_unique_filename', array($this, 'shortenEddFilename'), 10);
567
+ return $filename;
568
+ }
569
+
570
+ public function editPopupPreviewLink($previewLink = '', $post = array())
571
+ {
572
+ if (!empty($post) && $post->post_type == SG_POPUP_POST_TYPE) {
573
+ $popupId = $post->ID;
574
+ $targets = get_post_meta($popupId, 'sg_popup_target_preview', true);
575
+ if (empty($targets['sgpb-target'][0])) {
576
+ return $previewLink .= '/?sg_popup_preview_id='.$popupId;
577
+ }
578
+ $targetParams = @$targets['sgpb-target'][0][0]['param'];
579
+ if ((!empty($targetParams) && $targetParams == 'not_rule') || empty($targetParams)) {
580
+ $previewLink = home_url();
581
+ $previewLink .= '/?sg_popup_preview_id='.$popupId;
582
+
583
+ return $previewLink;
584
+ }
585
+ foreach ($targets['sgpb-target'][0] as $targetKey => $targetValue) {
586
+ if (!isset($targetValue['operator']) || $targetValue['operator'] == '!=') {
587
+ continue;
588
+ }
589
+ $previewLink = self::getPopupPreviewLink($targetValue, $popupId);
590
+ $previewLink .= '/?sg_popup_preview_id='.$popupId;
591
+ }
592
+ }
593
+
594
+ return $previewLink;
595
+ }
596
+
597
+ public static function getPopupPreviewLink($targetData, $popupId)
598
+ {
599
+ $previewLink = home_url();
600
+
601
+ if (empty($targetData['param'])) {
602
+ return $previewLink;
603
+ }
604
+ $targetParam = $targetData['param'];
605
+
606
+ if ($targetParam == 'everywhere') {
607
+ return $previewLink;
608
+ }
609
+
610
+ $args = array(
611
+ 'orderby' => 'rand'
612
+ );
613
+
614
+ // posts
615
+ if (strpos($targetData['param'], '_all')) {
616
+ if ($targetData['param'] == 'post_all') {
617
+ $args['post_type'] = 'post';
618
+ }
619
+ if ($targetData['param'] == 'page_all') {
620
+ $args['post_type'] = 'page';
621
+ }
622
+ }
623
+ if ($targetData['param'] == 'post_type' && !empty($targetData['value'])) {
624
+ $args['post_type'] = $targetData['value'];
625
+ }
626
+ if ($targetData['param'] == 'page_type' && !empty($targetData['value'])) {
627
+ $pageTypes = $targetData['value'];
628
+ foreach ($pageTypes as $pageType) {
629
+
630
+ if ($pageType == 'is_home_page') {
631
+ if (is_front_page() && is_home()) {
632
+ // default homepage
633
+ return get_home_url();
634
+ }
635
+ else if (is_front_page()) {
636
+ // static homepage
637
+ return get_home_url();
638
+ }
639
+ }
640
+ else if (function_exists($pageType)) {
641
+ if ($pageType == 'is_home') {
642
+ return get_home_url();
643
+ }
644
+ else if ($pageType == 'is_search') {
645
+ return get_search_link();
646
+ }
647
+ else if ($pageType == 'is_shop') {
648
+ return get_home_url().'/shop/';
649
+ }
650
+ }
651
+ }
652
+ }
653
+ if (isset($args['post_type'])) {
654
+ $the_query = new WP_Query($args);
655
+ foreach ($the_query->posts as $post) {
656
+ $postId = $post->ID;
657
+ if (get_permalink($postId)) {
658
+ return get_permalink($postId);
659
+ }
660
+ }
661
+ }
662
+ // selected post/page/custom_post_types...
663
+ if (strpos($targetData['param'], '_selected') && !empty($targetData['value'])) {
664
+ $value = array_keys($targetData['value']);
665
+ if (!empty($value[0])) {
666
+ if (get_permalink($value[0])) {
667
+ return get_permalink($value[0]);
668
+ }
669
+ }
670
+ }
671
+ if (strpos($targetData['param'], '_archive') && !empty($targetData['value'])) {
672
+ $value = array_keys($targetData['value']);
673
+ if (!empty($value[0])) {
674
+ if (get_permalink($value[0])) {
675
+ return get_permalink($value[0]);
676
+ }
677
+ }
678
+ }
679
+
680
+ return $previewLink;
681
+ }
682
+
683
+ public function excludePostsToShow($where)
684
+ {
685
+ if (function_exists('is_admin') && is_admin()) {
686
+ if (!function_exists('get_current_screen')) {
687
+ return $where;
688
+ }
689
+
690
+ $screen = get_current_screen();
691
+ if (empty($screen)) {
692
+ return $where;
693
+ }
694
+
695
+ $postType = $screen->post_type;
696
+ if ($postType == SG_POPUP_POST_TYPE &&
697
+ $screen instanceof \WP_Screen &&
698
+ $screen->id === 'edit-popupbuilder') {
699
+ if (class_exists('sgpb\SGPopup')) {
700
+ $activePopupsQuery = $this->getQueryString();
701
+ if ($activePopupsQuery && $activePopupsQuery != '') {
702
+ $where .= $activePopupsQuery;
703
+ }
704
+ }
705
+ }
706
+ }
707
+
708
+ return $where;
709
+ }
710
+
711
+ public function clearContentPreviewMode($content)
712
+ {
713
+ global $post_type;
714
+
715
+ if (is_preview() && $post_type == SG_POPUP_POST_TYPE) {
716
+ $content = '';
717
+ }
718
+
719
+ return $content;
720
+ }
721
+
722
+ public function filterPopupContent($content, $popupId)
723
+ {
724
+ preg_match_all('/<iframe.*?src="(.*?)".*?<\/iframe>/', $content, $matches);
725
+ /*$finalContent = '';*/
726
+ // $matches[0] array contain iframes stings
727
+ // $matches[1] array contain iframes URLs
728
+ if (empty($matches) && empty($matches[0]) && empty($matches[1])) {
729
+ return $content;
730
+ }
731
+ $urls = $matches[1];
732
+
733
+ foreach ($matches[0] as $key => $iframe) {
734
+ if (empty($urls[$key])) {
735
+ continue;
736
+ }
737
+
738
+ $pos = strpos($iframe, $urls[$key]);
739
+
740
+ if ($pos === false) {
741
+ continue;
742
+ }
743
+
744
+ $content = str_replace(' src="'.$urls[$key].'"', ' src="" data-attr-src="'.esc_attr($urls[$key]).'"', $content);
745
+ }
746
+ if (function_exists('do_blocks')) {
747
+ $content = do_blocks($content);
748
+ }
749
+
750
+ return do_shortcode($content);
751
+ }
752
+
753
+ public function addNewPostUrl($url, $path)
754
+ {
755
+ if ($path == 'post-new.php?post_type='.SG_POPUP_POST_TYPE) {
756
+ $url = str_replace('post-new.php?post_type='.SG_POPUP_POST_TYPE, 'edit.php?post_type='.SG_POPUP_POST_TYPE.'&page='.SG_POPUP_POST_TYPE, $url);
757
+ }
758
+
759
+ return $url;
760
+ }
761
+
762
+ public function popupsTableColumns($columns)
763
+ {
764
+ unset($columns['date']);
765
+
766
+ $additionalItems = array();
767
+ $additionalItems['counter'] = __('Views', SG_POPUP_TEXT_DOMAIN);
768
+ $additionalItems['onOff'] = __('Enabled (show popup)', SG_POPUP_TEXT_DOMAIN);
769
+ $additionalItems['type'] = __('Type', SG_POPUP_TEXT_DOMAIN);
770
+ $additionalItems['shortcode'] = __('Shortcode', SG_POPUP_TEXT_DOMAIN);
771
+ $additionalItems['className'] = __('Class', SG_POPUP_TEXT_DOMAIN);
772
+
773
+ return $columns + $additionalItems;
774
+ }
775
+
776
+ /**
777
+ * Function to add/hide links from popups dataTable row
778
+ */
779
+ public function quickRowLinksManager($actions, $post)
780
+ {
781
+ global $post_type;
782
+
783
+ if ($post_type != SG_POPUP_POST_TYPE) {
784
+ return $actions;
785
+ }
786
+ // remove quick edit link
787
+ unset($actions['inline hide-if-no-js']);
788
+ // remove view link
789
+ unset($actions['view']);
790
+
791
+ $actions['clone'] = '<a href="'.$this->popupGetClonePostLink($post->ID , 'display', false).'" title="';
792
+ $actions['clone'] .= esc_attr__("Clone this item", SG_POPUP_TEXT_DOMAIN);
793
+ $actions['clone'] .= '">'. esc_html__('Clone', SG_POPUP_TEXT_DOMAIN).'</a>';
794
+
795
+ return $actions;
796
+ }
797
+
798
+ /**
799
+ * Retrieve duplicate post link for post.
800
+ *
801
+ * @param int $id Optional. Post ID.
802
+ * @param string $context Optional, default to display. How to write the '&', defaults to '&amp;'.
803
+ * @return string
804
+ */
805
+ public function popupGetClonePostLink($id = 0, $context = 'display')
806
+ {
807
+ if (!$post = get_post($id)) {
808
+ return;
809
+ }
810
+ $actionName = "popupSaveAsNew";
811
+
812
+ if ('display' == $context) {
813
+ $action = '?action='.$actionName.'&amp;post='.$post->ID;
814
+ } else {
815
+ $action = '?action='.$actionName.'&post='.$post->ID;
816
+ }
817
+
818
+ $postTypeObject = get_post_type_object($post->post_type);
819
+
820
+ if (!$postTypeObject) {
821
+ return;
822
+ }
823
+
824
+ return wp_nonce_url(apply_filters('popupGetClonePostLink', admin_url("admin.php".$action), $post->ID, $context), 'duplicate-post_' . $post->ID);
825
+ }
826
+
827
+ /* media button scripts */
828
+ public function adminJsFilter($jsFiles)
829
+ {
830
+ $allowToShow = MediaButton::allowToShow();
831
+ if ($allowToShow) {
832
+ $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'select2.min.js');
833
+ $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'sgpbSelect2.js');
834
+ $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'Popup.js');
835
+ $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'PopupConfig.js');
836
+ $jsFiles['jsFiles'][] = array('folderUrl' => SG_POPUP_JS_URL, 'filename' => 'MediaButton.js');
837
+
838
+ $jsFiles['localizeData'][] = array(
839
+ 'handle' => 'Popup.js',
840
+ 'name' => 'sgpbPublicUrl',
841
+ 'data' => SG_POPUP_PUBLIC_URL
842
+ );
843
+
844
+ $jsFiles['localizeData'][] = array(
845
+ 'handle' => 'MediaButton.js',
846
+ 'name' => 'mediaButtonParams',
847
+ 'data' => array(
848
+ 'currentPostType' => get_post_type(),
849
+ 'popupBuilderPostType' => SG_POPUP_POST_TYPE,
850
+ 'ajaxUrl' => admin_url('admin-ajax.php'),
851
+ 'nonce' => wp_create_nonce(SG_AJAX_NONCE)
852
+ )
853
+ );
854
+ }
855
+
856
+ return $jsFiles;
857
+ }
858
+
859
+ /* media button styles */
860
+ public function sgpbAdminCssFiles($cssFiles)
861
+ {
862
+ $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'sgbp-bootstrap.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
863
+ $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'select2.min.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
864
+ $cssFiles[] = array('folderUrl' => SG_POPUP_CSS_URL, 'filename' => 'popupAdminStyles.css', 'dep' => array(), 'ver' => SG_POPUP_VERSION, 'inFooter' => false);
865
+
866
+ return $cssFiles;
867
+ }
868
+ }
869
+
870
+
com/classes/Javascript.php CHANGED
@@ -115,7 +115,7 @@ class Javascript
115
 
116
  $localizeDatas = $script['localizeData'];
117
 
118
- foreach($localizeDatas as $localizeData) {
119
  if (!is_array($localizeData['data'])) {
120
  $localizeData['data'] = (array)$localizeData['data'];
121
  }
115
 
116
  $localizeDatas = $script['localizeData'];
117
 
118
+ foreach($localizeDatas as $localizeData) {
119
  if (!is_array($localizeData['data'])) {
120
  $localizeData['data'] = (array)$localizeData['data'];
121
  }
com/classes/ScriptsLoader.php CHANGED
@@ -124,8 +124,7 @@ class ScriptsLoader
124
  <div class="sgpb-popup-builder-content-'.esc_attr($popupId).' sgpb-popup-builder-content-html">'.$popupContent.'</div>
125
  </div>
126
  </div>';
127
- $footerPopupContent .= $extraContent;
128
- echo $footerPopupContent;
129
  });
130
  }
131
 
@@ -252,7 +251,10 @@ class ScriptsLoader
252
  foreach ($localizeData as $valueData) {
253
  if (empty($valueData)) {
254
  continue;
 
255
 
 
 
256
  }
257
 
258
  ScriptsIncluder::localizeScript($valueData['handle'], $valueData['name'], $valueData['data']);
124
  <div class="sgpb-popup-builder-content-'.esc_attr($popupId).' sgpb-popup-builder-content-html">'.$popupContent.'</div>
125
  </div>
126
  </div>';
127
+ echo $extraContent.$footerPopupContent;
 
128
  });
129
  }
130
 
251
  foreach ($localizeData as $valueData) {
252
  if (empty($valueData)) {
253
  continue;
254
+ }
255
 
256
+ if (!is_array($valueData['data'])) {
257
+ $valueData['data'] = (array)$valueData['data'];
258
  }
259
 
260
  ScriptsIncluder::localizeScript($valueData['handle'], $valueData['name'], $valueData['data']);
com/config/configPackage.php CHANGED
@@ -3,6 +3,6 @@ if (!defined('ABSPATH')) {
3
  exit();
4
  }
5
 
6
- define('SG_POPUP_VERSION', '3.82');
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.83');
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.82
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.83
7
  * Author: Sygnoos
8
  * Author URI: https://sygnoos.com
9
  * License: GPLv2
readme.txt CHANGED
@@ -8,7 +8,7 @@ Tags: popup, pop up, wordpress popup, popup maker, exit popup, popup builder, wo
8
  Requires at least: 4.2
9
  Tested up to: 5.7
10
  Requires PHP: 5.3.3
11
- Stable tag: 3.82
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
 
@@ -145,6 +145,10 @@ Go to the Popup Builder settings and set your desired options.
145
 
146
  == Changelog ==
147
 
 
 
 
 
148
  = Version 3.82 =
149
  * Bug fixed related to PHP Fatal error.
150
 
@@ -444,4 +448,4 @@ Leave us a good review :)
444
 
445
  == Upgrade Notice ==
446
 
447
- Current Version of Popup Builder is 3.82
8
  Requires at least: 4.2
9
  Tested up to: 5.7
10
  Requires PHP: 5.3.3
11
+ Stable tag: 3.83
12
  License: GPLv2 or later
13
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
 
145
 
146
  == Changelog ==
147
 
148
+ = Version 3.83 =
149
+ * Improvement of Floating button relater to the filter
150
+ * Bug fixed related to the warning in WP_Scripts->localize(), 3rd parameter's string is changed to array
151
+
152
  = Version 3.82 =
153
  * Bug fixed related to PHP Fatal error.
154
 
448
 
449
  == Upgrade Notice ==
450
 
451
+ Current Version of Popup Builder is 3.83