: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
private function getAddonsEventFromPopup($popup)
$popupId = $popup->getId();
$sg_popup_addons_connectionTableName = $wpdb->prefix.'sg_popup_addons_connection';
$results = $wpdb->get_results($wpdb->prepare( "SELECT options FROM $sg_popup_addons_connectionTableName WHERE popupId = %d and extensionType = 'option'", $popupId) , ARRAY_A);
// it's collect all events saved values ex Exit Intent and AdBlock
foreach ($results as $result) {
$currentOptions = json_decode($result['options'], true);
if (empty($currentOptions)) {
$options = array_merge($options, $currentOptions);
* Filter and change some related values for new version
private function filterOptions($options)
if (isset($options['effect']) && $options['effect'] != 'No effect') {
$options['sgpb-open-animation'] = 'on';
if (isset($options['isActiveStatus']) && $options['isActiveStatus'] == 'off') {
$options['isActiveStatus'] = '';
if (empty($options['sgTheme3BorderColor'])) {
$options['sgTheme3BorderColor'] = '#000000';
if (isset($options['popupContentBackgroundRepeat']) && ($options['popupContentBackgroundRepeat'] != 'no-repeat' && $options['popupContentBackgroundSize'] == 'auto')) {
$options['popupContentBackgroundSize'] = 'repeat';
if (isset($options['theme'])) {
$themeNumber = preg_replace('/[^0-9]/', '', $options['theme']);
if (isset($options['aweber-success-behavior']) && $options['aweber-success-behavior'] == 'redirectToUrl') {
$options['aweber-success-behavior'] = 'redirectToURL';
if (isset($options['disablePopupOverlay'])) {
$options['sgpb-enable-popup-overlay'] = '';
// contact form new options
if (isset($options['contact-success-behavior']) && $options['contact-success-behavior'] == 'redirectToUrl') {
$options['contact-success-behavior'] = 'redirectToURL';
if (isset($options['contact-text-input-bgcolor'])) {
$options['sgpb-contact-message-bg-color'] = $options['contact-text-input-bgcolor'];
if (isset($options['contact-text-bordercolor'])) {
$options['sgpb-contact-message-border-color'] = $options['contact-text-bordercolor'];
if (isset($options['contact-inputs-color'])) {
$options['sgpb-contact-message-text-color'] = $options['contact-inputs-color'];
if (isset($options['contact-placeholder-color'])) {
$options['sgpb-contact-message-placeholder-color'] = $options['contact-placeholder-color'];
if (isset($options['contact-inputs-border-width'])) {
$options['sgpb-contact-message-border-width'] = $options['contact-inputs-border-width'];
if (isset($options['contact-success-popups-list'])) {
$options['contact-success-popups-list'] = sgpGetCorrectPopupId($options['contact-success-popups-list']);
if (isset($options['popup-content-padding'])) {
// add theme default padding to content padding
$options['popup-content-padding'] += 7;
$options['popup-content-padding'] += 12;
$options['popup-content-padding'] += 0;
$options['popup-content-padding'] += 5;
// social popup add to default value
if (empty($options['sgMailLable'])) {
$options['sgMailLable'] = 'E-mail';
if (empty($options['fbShareLabel'])) {
$options['fbShareLabel'] = 'Share';
if (empty($options['lindkinLabel'])) {
$options['lindkinLabel'] = 'Share';
if (empty($options['googLelabel'])) {
$options['googLelabel'] = '+1';
if (empty($options['twitterLabel'])) {
$options['twitterLabel'] = 'Tweet';
if (empty($options['pinterestLabel'])) {
$options['pinterestLabel'] = 'Pin it';
if (isset($options['subs-success-behavior']) && $options['subs-success-behavior'] == 'redirectToUrl') {
$options['subs-success-behavior'] = 'redirectToURL';
$options['sgpb-subs-form-bg-color'] = '#FFFFFF';
$options['sgpb-button-image-width'] = $buttonImageWidth;
$options['sgpb-button-image-height'] = $buttonImageHeight;
// pro options customizations
if (SGPB_POPUP_PKG > SGPB_POPUP_PKG_FREE) {
if (empty($options['sgpb-restriction-yes-btn-radius-type'])) {
$options['sgpb-restriction-yes-btn-radius-type'] = '%';
if (empty($options['sgpb-restriction-no-btn-radius-type'])) {
$options['sgpb-restriction-no-btn-radius-type'] = '%';
if (empty($options['sgpb-restriction-yes-btn-border-color'])) {
// border color should be like background color
$options['sgpb-restriction-yes-btn-border-color'] = $options['yesButtonBackgroundColor'];
if (empty($options['sgpb-restriction-no-btn-border-color'])) {
// border color should be like background color
$options['sgpb-restriction-no-btn-border-color'] = $options['noButtonBackgroundColor'];
public function changeOldValues($optionName, $optionValue)
if ($optionName == 'theme') {
$themeNumber = preg_replace('/[^0-9]/', '', $optionValue);
$optionValue = 'sgpb-theme-'.$themeNumber;
private function popupObjectFromArray($arr)
$options = json_decode($arr['options'], true);
$this->setId($arr['id']);
$this->setTitle($arr['title']);
$sg_image_popup = $wpdb->prefix.'sg_image_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `url` FROM $sg_image_popup WHERE id = %d", $arr['id']) , ARRAY_A);
if (!empty($result['url'])) {
$options['image-url'] = $result['url'];
$sg_html_popup = $wpdb->prefix.'sg_html_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content` FROM $sg_html_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$sg_fblike_popup = $wpdb->prefix.'sg_fblike_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_fblike_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
$this->setCustomOptions($customOptions);
$sg_shortCode_popup = $wpdb->prefix.'sg_shortCode_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `url` FROM $sg_shortCode_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['url'])) {
$this->setContent($result['url']);
$sg_iframe_popup = $wpdb->prefix.'sg_iframe_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `url` FROM $sg_iframe_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['url'])) {
$options['iframe-url'] = $result['url'];
$sg_video_popup = $wpdb->prefix.'sg_video_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `url`, `options` FROM $sg_video_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['url'])) {
$options['video-url'] = $result['url'];
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
if (!empty($customOptions)) {
$this->setCustomOptions($customOptions);
$sg_age_restriction_popup = $wpdb->prefix.'sg_age_restriction_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `yesButton` as `yesButtonLabel`, `noButton` as `noButtonLabel`, `url` as `restrictionUrl` FROM $sg_age_restriction_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
unset($result['content']);
$this->setCustomOptions($result);
$sg_social_popup = $wpdb->prefix.'sg_social_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `socialContent`, `buttons`, `socialOptions` FROM $sg_social_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['socialContent'])) {
$this->setContent($result['socialContent']);
$buttons = json_decode($result['buttons'], true);
$socialOptions = json_decode($result['socialOptions'], true);
$socialAllOptions = array_merge($buttons, $socialOptions);
$this->setCustomOptions($socialAllOptions);
$sg_subscription_popup = $wpdb->prefix.'sg_subscription_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_subscription_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$subsOptions = $result['options'];
$subsOptions = json_decode($subsOptions, true);
if (!empty($subsOptions)) {
$this->setCustomOptions($subsOptions);
$sg_countdown_popup = $wpdb->prefix.'sg_countdown_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_countdown_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
$this->setCustomOptions($customOptions);
$sg_contact_form_popup = $wpdb->prefix.'sg_contact_form_popup';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_contact_form_popup WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
$this->setCustomOptions($customOptions);
$sg_popup_mailchimp = $wpdb->prefix.'sg_popup_mailchimp';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_popup_mailchimp WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
$this->setCustomOptions($customOptions);
$sg_popup_aweber = $wpdb->prefix.'sg_popup_aweber';
$result = $wpdb->get_row( $wpdb->prepare("SELECT `content`, `options` FROM $sg_popup_aweber WHERE id = %d", $arr['id']), ARRAY_A);
if (!empty($result['content'])) {
$this->setContent($result['content']);
$customOptions = $result['options'];
$customOptions = json_decode($customOptions, true);
$this->setCustomOptions($customOptions);
$this->setOptions($options);
public function getNamesMapping()
'delay' => 'sgpb-popup-delay',
'isActiveStatus' => 'sgpb-is-active',
'image-url' => 'sgpb-image-url',
'theme' => 'sgpb-popup-themes',
'effect' => 'sgpb-open-animation-effect',
'duration' => 'sgpb-open-animation-speed',
'popupOpenSound' => 'sgpb-open-sound',
'popupOpenSoundFile' => 'sgpb-sound-url',
'popup-dimension-mode' => 'sgpb-popup-dimension-mode',
'popup-responsive-dimension-measure' => 'sgpb-responsive-dimension-measure',
'height' => 'sgpb-height',
'maxWidth' => 'sgpb-max-width',
'maxHeight' => 'sgpb-max-height',
'escKey' => 'sgpb-esc-key',
'closeButton' => 'sgpb-enable-close-button',
'buttonDelayValue' => 'sgpb-close-button-delay',
'scrolling' => 'sgpb-enable-content-scrolling',
'disable-page-scrolling' => 'sgpb-disable-page-scrolling',
'overlayClose' => 'sgpb-overlay-click',
'contentClick' => 'sgpb-content-click',
'content-click-behavior' => 'sgpb-content-click-behavior',
'click-redirect-to-url' => 'sgpb-click-redirect-to-url',
'redirect-to-new-tab' => 'sgpb-redirect-to-new-tab',
'reopenAfterSubmission' => 'sgpb-reopen-after-form-submission',
'repeatPopup' => 'sgpb-show-popup-same-user',
'popup-appear-number-limit' => 'sgpb-show-popup-same-user-count',
'onceExpiresTime' => 'sgpb-show-popup-same-user-expiry',
'save-cookie-page-level' => 'sgpb-show-popup-same-user-page-level',
'popupContentBgImage' => 'sgpb-show-background',
'popupContentBackgroundSize' => 'sgpb-background-image-mode',
'popupContentBgImageUrl' => 'sgpb-background-image',
'sgOverlayColor' => 'sgpb-overlay-color',
'sg-content-background-color' => 'sgpb-background-color',
'popup-background-opacity' => 'sgpb-content-opacity',
'opacity' => 'sgpb-overlay-opacity',
'sgOverlayCustomClasss' => 'sgpb-overlay-custom-class',
'sgContentCustomClasss' => 'sgpb-content-custom-class',
'popup-z-index' => 'sgpb-popup-z-index',
'popup-content-padding' => 'sgpb-content-padding',
'popupFixed' => 'sgpb-popup-fixed',
'fixedPostion' => 'sgpb-popup-fixed-position',
'sgpb-open-animation' => 'sgpb-open-animation',
'theme-close-text' => 'sgpb-button-text',
'sgTheme3BorderRadius' => 'sgpb-border-radius',
'sgTheme3BorderColor' => 'sgpb-border-color',
'fblike-like-url' => 'sgpb-fblike-like-url',
'fblike-layout' => 'sgpb-fblike-layout',
'fblike-dont-show-share-button' => 'sgpb-fblike-dont-show-share-button',
'sgpb-button-image-width' => 'sgpb-button-image-width',
'sgpb-button-image-height' => 'sgpb-button-image-height'
$names['iframe-url'] = 'sgpb-iframe-url';
$names['video-url'] = 'sgpb-video-url';
$names['video-autoplay'] = 'sgpb-video-autoplay';
$names['yesButtonLabel'] = 'sgpb-restriction-yes-btn';
$names['noButtonLabel'] = 'sgpb-restriction-no-btn';
$names['restrictionUrl'] = 'sgpb-restriction-no-url';
$names['yesButtonBackgroundColor'] = 'sgpb-restriction-yes-btn-bg-color';
$names['yesButtonTextColor'] = 'sgpb-restriction-yes-btn-text-color';
$names['yesButtonRadius'] = 'sgpb-restriction-yes-btn-radius';
$names['sgRestrictionExpirationTime'] = 'sgpb-restriction-yes-expiration-time';
$names['restrictionCookeSavingLevel'] = 'sgpb-restriction-cookie-level';
$names['noButtonBackgroundColor'] = 'sgpb-restriction-no-btn-bg-color';
$names['noButtonTextColor'] = 'sgpb-restriction-no-btn-text-color';
$names['noButtonRadius'] = 'sgpb-restriction-no-btn-radius';
// age restriction new options
$names['sgpb-restriction-yes-btn-radius-type'] = 'sgpb-restriction-yes-btn-radius-type';
$names['sgpb-restriction-no-btn-radius-type'] = 'sgpb-restriction-no-btn-radius-type';
$names['sgpb-restriction-yes-btn-border-color'] = 'sgpb-restriction-yes-btn-border-color';
$names['sgpb-restriction-no-btn-border-color'] = 'sgpb-restriction-no-btn-border-color';
'autoClosePopup' => 'sgpb-auto-close',
'popupClosingTimer' => 'sgpb-auto-close-time',
'disablePopupOverlay' => 'sgpb-enable-popup-overlay',
'disablePopup' => 'sgpb-disable-popup-closing',
'popup-schedule-status' => 'sgpb-schedule-status',
'schedule-start-weeks' => 'sgpb-schedule-weeks',
'schedule-start-time' => 'sgpb-schedule-start-time',
'schedule-end-time' => 'sgpb-schedule-end-time',
'popup-timer-status' => 'sgpb-popup-timer-status',
'popup-start-timer' => 'sgpb-popup-start-timer',
'popup-finish-timer' => 'sgpb-popup-end-timer',
'inActivityStatus' => 'sgpb-inactivity-status',
'inactivity-timout' => 'sgpb-inactivity-timer',
'onScrolling' => 'sgpb-onscroll-status',
'beforeScrolingPrsent' => 'sgpb-onscroll-percentage',
'sg-user-status' => 'sgpb-by-user-status',
'loggedin-user' => 'sgpb-for-logged-in-user',
'forMobile' => 'sgpb-hide-on-mobile',
'openMobile' => 'sgpb-only-on-mobile',
'countryStatus' => 'sgpb-by-country',
'allowCountries' => 'sgpb-allow-countries',
'countryIso' => 'sgpb-countries-iso',
'randomPopup' => 'sgpb-random-popup'
$names = array_merge($names, $proNames);
$names['allPagesStatus'] = 'allPagesStatus';