: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$firstHeader = sprintf('<h1 class="sgpb-review-h1"><strong class="sgrb-review-strong">%1$s</strong> %2$s %3$d %4$s</h1>',
__('This is great!','popup-builder'),
__('We have noticed that you are using Popup Builder plugin on your site for','popup-builder'),
esc_html( $getUsageDays ),
__('days, we are thankful for that.','popup-builder')
$popupContent = self::getMaxOpenPopupContent($firstHeader, 'days');
public static function getPopupUsageDays()
$installDate = get_option('SGPBInstallDate');
$timeDate = new \DateTime('now');
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
$diff = $timeNow-$installDate;
$days = floor($diff/(60*60*24));
public static function getMaxOpenPopupContent($firstHeader, $type)
.sgpb-buttons-wrapper .press{
transition:background 0.15s linear
.sgpb-buttons-wrapper .press-grey {
background-color:#9E9E9E;
border:2px solid #9E9E9E;
.sgpb-buttons-wrapper .press-lightblue {
background-color:#03A9F4;
border:2px solid #03A9F4;
--main-bg-color: #1ac6ff;
color: var(--main-bg-color);
<div class="sgpb-review-wrapper">
<div class="sgpb-review-description">
<?php echo wp_kses($firstHeader, 'post'); ?>
<h2 class="sgrb-review-h2"><?php esc_html_e('This is really great for your website score.', 'popup-builder'); ?></h2>
<p class="sgrb-review-mt20"><?php esc_html_e('Have your input in the development of our plugin, and we’ll provide better conversions for your site!<br /> Leave your 5-star positive review and help us go further to the perfection!', 'popup-builder'); ?></p>
<div class="sgpb-buttons-wrapper">
<button class="press press-grey sgpb-button-1 sgpb-close-promo-notification" data-action="sg-already-did-review"><?php esc_html_e('I already did', 'popup-builder'); ?></button>
<button class="press press-lightblue sgpb-button-3 sgpb-close-promo-notification" data-action="sg-you-worth-it"><?php esc_html_e('You worth it!', 'popup-builder'); ?></button>
<button class="press press-grey sgpb-button-2 sgpb-close-promo-notification" data-action="sg-show-popup-period" data-message-type="<?php echo esc_attr($type); ?>"><?php esc_html_e('Maybe later', 'popup-builder'); ?></button></div>
$popupContent = ob_get_clean();
public static function shouldOpenReviewPopupForDays()
$dontShowAgain = get_option('SGPBCloseReviewPopup-notification');
$periodNextTime = get_option('SGPBOpenNextTime');
// When period next time does not exits it means the user is old
$usageDays = self::getPopupMainTableCreationDate();
update_option('SGPBUsageDays', $usageDays);
if (!defined('SGPB_REVIEW_POPUP_PERIOD')) {
define('SGPB_REVIEW_POPUP_PERIOD', '500');
if (defined('SGPB_REVIEW_POPUP_PERIOD') && $usageDays > SGPB_REVIEW_POPUP_PERIOD && !$dontShowAgain) {
$remainingDays = SGPB_REVIEW_POPUP_PERIOD - $usageDays;
$popupTimeZone = \SGPBConfigDataHelper::getDefaultTimezone();
$timeDate = new DateTime('now', new DateTimeZone($popupTimeZone));
$timeDate->modify('+'.$remainingDays.' day');
$timeNow = strtotime($timeDate->format('Y-m-d H:i:s'));
update_option('SGPBOpenNextTime', $timeNow);
$currentData = new \DateTime('now');
$timeNow = $currentData->format('Y-m-d H:i:s');
$timeNow = strtotime($timeNow);
if ($periodNextTime > $timeNow) {
public static function getPopupMainTableCreationDate()
$results = $wpdb->get_results( $wpdb->prepare('SELECT table_name, create_time FROM information_schema.tables WHERE table_schema=%s AND table_name=%s', DB_NAME, $wpdb->prefix.'sgpb_subscribers'), ARRAY_A);
$createTime = $results[0]['create_time'];
$createTime = strtotime($createTime);
update_option('SGPBInstallDate', $createTime);
$diff = time() - $createTime;
$days = floor($diff/(60*60*24));
public static function shouldOpenForMaxOpenPopupMessage()
$counterMaxPopup = self::getMaxOpenPopupId();
if (empty($counterMaxPopup)) {
$dontShowAgain = get_option('SGPBCloseReviewPopup-notification');
$maxCountDefine = get_option('SGPBMaxOpenCount');
$maxCountDefine = SGPB_ASK_REVIEW_POPUP_COUNT;
return $counterMaxPopup['maxCount'] >= $maxCountDefine && !$dontShowAgain;
public static function getMaxOpenPopupId()
$popupsCounterData = get_option('SgpbCounter');
if (!$popupsCounterData) {
$counters = array_values($popupsCounterData);
$maxCount = max($counters);
$popupId = array_search($maxCount, $popupsCounterData);
public static function getMaxOpenPopupsMessage()
$counterMaxPopup = self::getMaxOpenPopupId();
$maxCountDefine = get_option('SGPBMaxOpenCount');
$popupTitle = get_the_title($counterMaxPopup['popupId']);
if (!empty($counterMaxPopup['maxCount'])) {
$maxCountDefine = $counterMaxPopup['maxCount'];
/* translators: popup Title, max Count Define */
$firstHeader = sprintf('<h1 class="sgpb-review-h1"><strong class="sgrb-review-strong">%1$s</strong> <b>%2$s</b> %3$s <strong class="sgrb-review-strong">%4$s </strong>%5$s <strong class="sgrb-review-strong">%6$d %7$s</strong></h1>',
__('Awesome news!','popup-builder'),
__('Popup Builder','popup-builder'),
__('plugin helped you to share your message via','popup-builder'),
__('popup with your visitors for','popup-builder'),
esc_html( $maxCountDefine ),
__('times!','popup-builder')
$popupContent = self::getMaxOpenPopupContent($firstHeader, 'count');
* @param email $fromEmail
* @return string $headers
public static function getEmailHeader($fromEmail, $args = array())
$contentType = 'text/html';
$blogInfo = wp_specialchars_decode( get_bloginfo() );
if (!empty($args['contentType'])) {
$contentType = $args['contentType'];
if (!empty($args['charset'])) {
$charset = $args['charset'];
$headers = 'MIME-Version: 1.0'."\r\n";
$headers .= 'From: "'.$blogInfo.'" <'.$fromEmail.'>'."\r\n";
$headers .= 'Content-type: '.$contentType.'; charset='.$charset.''."\r\n"; //set UTF-8
* Get file content from URL
public static function getFileFromURL($url)
$remoteData = wp_safe_remote_get( $url );
if ( is_wp_error( $remoteData ) ) {
$data = wp_remote_retrieve_body( $remoteData );
public static function getRightMetaboxBannerText()
$bannerText = get_option('sgpb-metabox-banner-remote-get');
public static function getGutenbergPopupsIdAndTitle($excludesPopups = array())
$allPopups = SGPopup::getAllPopups();
$popupIdTitles = array();
$excludesPopups = apply_filters('sgpb_exclude_from_popups_list', $excludesPopups);
foreach ($allPopups as $popup) {
$title = $popup->getTitle();
$type = $popup->getType();
if (!empty($excludesPopups)) {
foreach ($excludesPopups as $excludesPopupId) {
if ($excludesPopupId != $id) {
$array['title'] = $title.' - '.$type;
$popupIdTitles[] = $array;
$array['title'] = $title.' - '.$type;
$popupIdTitles[] = $array;
public static function getGutenbergPopupsEvents()
array('value' => '', 'title' => __('Select Event', 'popup-builder')),
array('value' => 'inherit', 'title' => __('Inherit', 'popup-builder')),
array('value' => 'onLoad', 'title' => __('On load', 'popup-builder')),
array('value' => 'click', 'title' => __('On click', 'popup-builder')),
array('value' => 'hover', 'title' => __('On hover', 'popup-builder'))
public static function checkEditorByPopupId($popupId)
if (class_exists('\Elementor\Plugin')) {
$elementorContent = get_post_meta($popupId, '_elementor_edit_mode', true);
if (!empty($elementorContent) && $elementorContent == 'builder') {
$popupContent = Elementor\Plugin::instance()->frontend->get_builder_content_for_display($popupId);
else if (class_exists('Vc_Manager')) {
$stylesAndScripts = self::renderWPBakeryScriptsAndStyles($popupId);
$popupContent .= '<style>'.$stylesAndScripts.'</style>';
public static function renderWPBakeryScriptsAndStyles($popupId = 0)
return get_post_meta($popupId, '_wpb_shortcodes_custom_css', true);
* countdown popup, convert date to seconds
* @return false|int|string
public static function dateToSeconds($dueDate, $timezone)
$dateObj = self::getDateObjFromDate('now', $timezone);
$timeNow = gettype($dateObj) == 'string' ? strtotime($dateObj) : 0;
$dueDateTime = gettype($dueDate) == 'string' ? strtotime($dueDate) : 0;
$seconds = $dueDateTime-$timeNow;
* @return string $protocol
public static function getSiteProtocol()
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') {
public static function findSubscribersByEmail($subscriberEmail = '', $list = 0)
$subscribersTableName = $wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME;
$subscriber = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $subscribersTableName WHERE email = %s AND subscriptionType = %d ", $subscriberEmail, $list), ARRAY_A);
$subscriber = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $subscribersTableName WHERE email = %s ", $subscriberEmail), ARRAY_A);
public static function updateOption($optionKey, $optionValue)
update_option($optionKey, $optionValue);
public static function getOption($optionKey, $default = false)
return get_option($optionKey, $default);
public static function deleteOption($optionKey)
delete_option($optionKey);
* It's change popup registered plugins static paths to dynamic
* @return bool where true mean modified false mean there is not need modification
public static function makeRegisteredPluginsStaticPathsToDynamic()
// remove old outdated option sgpbModifiedRegisteredPluginsPaths
delete_option('sgpbModifiedRegisteredPluginsPaths');
delete_option('SG_POPUP_BUILDER_REGISTERED_PLUGINS');
$hasModifiedPaths = AdminHelper::getOption(SGPB_REGISTERED_PLUGINS_PATHS_MODIFIED);
Installer::registerPlugin();
AdminHelper::updateOption(SGPB_REGISTERED_PLUGINS_PATHS_MODIFIED, 1);
$registeredPlugins = AdminHelper::getOption(SGPB_POPUP_BUILDER_REGISTERED_PLUGINS);
if (empty($registeredPlugins)) {
$registeredPlugins = json_decode($registeredPlugins, true);
if (empty($registeredPlugins)) {
foreach ($registeredPlugins as $key => $registeredPlugin) {
if (empty($registeredPlugin['classPath'])) {
$registeredPlugins[$key]['classPath'] = str_replace(WP_PLUGIN_DIR, '', $registeredPlugin['classPath']);
if (!empty($registeredPlugin['options']['licence']['file'])) {
$registeredPlugins[$key]['options']['licence']['file'] = $registeredPlugin['options']['licence']['file'];
$registeredPlugins = wp_json_encode($registeredPlugins);
AdminHelper::updateOption(SGPB_POPUP_BUILDER_REGISTERED_PLUGINS, $registeredPlugins);
public static function hasInactiveExtensions()
$hasInactiveExtensions = false;
$allRegiseredPBPlugins = AdminHelper::getOption(SGPB_POPUP_BUILDER_REGISTERED_PLUGINS);
$allRegiseredPBPlugins = !empty($allRegiseredPBPlugins) ? json_decode($allRegiseredPBPlugins, true) : array();
if (empty($allRegiseredPBPlugins)) {
return $hasInactiveExtensions;
foreach ($allRegiseredPBPlugins as $pluginPath => $registeredPlugin) {
if (!isset($registeredPlugin['options']['licence']['key'])) {
if (!isset($registeredPlugin['options']['licence']['file'])) {
$extensionKey = $registeredPlugin['options']['licence']['file'];
$isPluginActive = is_plugin_active($extensionKey);
$pluginKey = $registeredPlugin['options']['licence']['key'];
$isValidLicense = get_option('sgpb-license-status-'.$pluginKey);
// if we even have at least one inactive extension, we don't need to check remaining extensions
if ($isValidLicense != 'valid' && $isPluginActive) {
$hasInactiveExtensions = true;