: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public $customPostTypeObj;
public $insideShortcodes;
public $mediaButton = false;
public function __construct()
add_action('init', array($this, 'wpInit'), 100);
add_action('init', array($this, 'callUnsubcribeUserByEmail'), 9999);
add_action('admin_init', array($this, 'postTypeInit'), 9999);
if (method_exists('sgpb\AdminHelper', 'updatesInit') && !has_action('admin_init', array( 'sgpb\AdminHelper', 'updatesInit'))){
add_action('admin_init', array( 'sgpb\AdminHelper', 'updatesInit'), 9999);
add_action('admin_menu', array($this, 'addSubMenu'));
add_action('admin_menu', array($this, 'supportLinks'), 999);
add_action('admin_head', array($this, 'showPreviewButtonAfterPopupPublish'));
add_action('admin_head', array($this, 'custom_admin_js'));
add_action('admin_enqueue_scripts', array($this, 'adminLoadPopups'));
add_action('admin_action_popupSaveAsNew', array($this, 'popupSaveAsNew'));
add_action('admin_post_csv_file', array($this, 'getSubscribersCsvFile'));
add_action('admin_post_sgpb_system_info', array($this, 'getSystemInfoFile'));
add_action('admin_post_sgpbSaveSettings', array($this, 'saveSettings'), 10, 1);
add_action('admin_init', array($this, 'userRolesCaps'));
add_action('admin_notices', array($this, 'pluginNotices'));
add_action('admin_init', array($this, 'pluginLoaded'));
add_action('transition_post_status', array($this, 'deletePopup'), 100, 3);
add_action('wp_before_admin_bar_render', array($this, 'pluginActivated'), 10, 2);
add_action('admin_head', array($this, 'hidePageBuilderEditButtons'));
add_action('admin_head', array($this, 'hidePublishingActions'));
add_action('add_meta_boxes', array($this, 'popupMetaboxes'), 100);
add_filter('post_updated_messages', array($this, 'popupPublishedMessage'), 1, 1);
add_action('before_delete_post', array($this, 'deleteSubscribersWithPopup'), 1, 1);
add_action('sgpb_duplicate_post', array($this, 'popupCopyPostMetaInfo'), 10, 2);
add_filter('get_sample_permalink_html', array($this, 'removePostPermalink'), 1, 1);
add_action('manage_'.SG_POPUP_POST_TYPE.'_posts_custom_column' , array($this, 'popupsTableColumnsValues'), 10, 2);
add_action('media_buttons', array($this, 'popupMediaButton'));
add_filter('mce_external_plugins', array($this, 'editorButton'), 1, 1);
add_action('admin_enqueue_scripts', array('sgpb\Style', 'enqueueStyles'));
add_action('admin_enqueue_scripts', array('sgpb\Javascript', 'enqueueScripts'));
// this action for popup options saving and popup builder classes save ex from post and page
add_action('save_post', array($this, 'savePost'), 100, 3);
add_action('wp_enqueue_scripts', array($this, 'enqueuePopupBuilderScripts'));
add_filter('sgpbOtherConditions', array($this ,'conditionsSatisfy'), 11, 1);
add_shortcode('sg_popup', array($this, 'sgpbPopupShortcode'));
add_filter('cron_schedules', array($this, 'cronAddMinutes'), 10, 1);
add_action('sgpb_send_newsletter', array($this, 'newsletterSendEmail'), 10, 1);
// add_action('sgpbGetBannerContentOnce', array($this, 'getBannerContent'), 10, 1);
add_action('plugins_loaded', array($this, 'loadTextDomain'));
// for change admin popup list order
add_action('pre_get_posts', array($this, 'preGetPosts'));
add_action('template_redirect', array($this, 'redirectFromPopupPage'));
add_filter('views_edit-popupbuilder', array($this, 'mainActionButtons'), 10, 1);
add_action('wpml_loaded', array($this, 'wpmlRelatedActions'));
add_action('the_post', array($this, 'postExcludeFromPopupsList'));
add_filter('get_user_option_screen_layout_'.SG_POPUP_POST_TYPE, array($this, 'screenLayoutSetOneColumn'));
add_filter( 'upload_mimes', array($this, 'popupbuilder_allow_csv_mime_types') );
add_action( 'plugins_loaded' , array($this, 'popupbuilder_contrucst') );
public function popupbuilder_contrucst()
public function popupbuilder_allow_csv_mime_types( $mimes ) {
$mimes['csv'] = 'text/csv';
public function custom_admin_js()
$currentPostType = AdminHelper::getCurrentPostType();
if(!empty($currentPostType) && ($currentPostType == SG_POPUP_POST_TYPE || $currentPostType == SG_POPUP_AUTORESPONDER_POST_TYPE || $currentPostType == SG_POPUP_TEMPLATE_POST_TYPE)) {
wp_register_script( 'sgpb-actions-js-footer', '', array("jquery"), SGPB_POPUP_VERSION, true );
wp_enqueue_script( 'sgpb-actions-js-footer' );
wp_add_inline_script( 'sgpb-actions-js-footer', "jQuery(document).ready(function ($) {
const myForm = $('.post-type-popupbuilder #posts-filter, .post-type-sgpbtemplate #posts-filter, .post-type-sgpbtemplate #posts-filter');
myForm.addClass('sgpb-table');
const searchValue = $('.post-type-popupbuilder #post-search-input, .post-type-sgpbtemplate #posts-filter, .post-type-sgpbautoresponder #posts-filter').val();
$('.post-type-popupbuilder #posts-filter .tablenav.top .tablenav-pages, .post-type-sgpbtemplate #posts-filter .tablenav.top .tablenav-pages, .post-type-sgpbautoresponder #posts-filter .tablenav.top .tablenav-pages').append($('.subsubsub').addClass('show'));
myForm.append($('.post-type-popupbuilder #posts-filter .tablenav.bottom .tablenav-pages:not(.no-pages, .one-page) .pagination-links, .post-type-sgpbtemplate #posts-filter .tablenav.bottom .tablenav-pages:not(.no-pages, .one-page) .pagination-links, .post-type-sgpbautoresponder #posts-filter .tablenav.bottom .tablenav-pages:not(.no-pages, .one-page) .pagination-links'));
$('#sgpbSearchInPosts').val(searchValue);
$('#sgpbSearchInPosts').keyup('enter', function (e) {
$('.post-type-popupbuilder #post-search-input, .post-type-sgpbtemplate #post-search-input, .post-type-sgpbautoresponder #post-search-input').val(this.value);
$('#sgpbSearchInPostsSubmit').on('click', function () {
$('.post-type-popupbuilder #post-search-input, .post-type-sgpbtemplate #post-search-input, .post-type-sgpbautoresponder #post-search-input').val($('#sgpbSearchInPosts').val());
public function screenLayoutSetOneColumn()
public function wpmlRelatedActions()
// The actions below will be executed right after WPML is fully configured and loaded.
add_action('admin_head', array($this, 'removeUnneededMetaboxesFromPopups'), 10);
public function removeUnneededMetaboxesFromPopups()
if (isset($_GET['post_type']) && sanitize_text_field($_GET['post_type']) == SG_POPUP_POST_TYPE) {
$exlcudeTrPopupTypes = array(
$exlcudeTrPopupTypes = apply_filters('sgpbNoMcePopupTypes', $exlcudeTrPopupTypes);
if (isset($_GET['sgpb_type']) && in_array(sanitize_text_field($_GET['sgpb_type']), $exlcudeTrPopupTypes)) {
remove_meta_box('icl_div', SG_POPUP_POST_TYPE, 'side');
public function deletePopup($newStatus, $oldStatus, $post)
$currentPostType = AdminHelper::getCurrentPostType();
if (!empty($currentPostType) && $currentPostType == SG_POPUP_POST_TYPE) {
Functions::clearAllTransients();
public function showPreviewButtonAfterPopupPublish()
$currentPostType = AdminHelper::getCurrentPostType();
if (!empty($currentPostType) && ($currentPostType == SG_POPUP_POST_TYPE || $currentPostType == SG_POPUP_AUTORESPONDER_POST_TYPE || $currentPostType == SG_POPUP_TEMPLATE_POST_TYPE)) {
.post-type-popupbuilder #save-post,
.post-type-sgpbtemplate #save-post,
.post-type-sgpbautoresponder #save-post
.post-type-popupbuilder .subsubsub,
.post-type-sgpbtemplate .subsubsub,
.post-type-sgpbautoresponder .subsubsub
.post-type-popupbuilder .subsubsub.show,
.post-type-sgpbtemplate .subsubsub.show,
.post-type-sgpbautoresponder .subsubsub.show
display:block !important;
.post-type-popupbuilder .search-box,
.post-type-sgpbtemplate .search-box,
.post-type-sgpbautoresponder .search-box
.post-type-popupbuilder .search-box.show,
.post-type-sgpbtemplate .search-box.show,
.post-type-sgpbautoresponder .search-box.show
display:block !important;
.post-type-popupbuilder .tablenav-pages.no-pages,
.post-type-sgpbtemplate .tablenav-pages.no-pages,
.post-type-sgpbautoresponder .tablenav-pages.no-pages
.post-type-popupbuilder .tablenav-pages *:not(.subsubsub, .subsubsub *),
.post-type-sgpbtemplate .tablenav-pages *:not(.subsubsub, .subsubsub *),
.post-type-sgpbautoresponder .tablenav-pages *:not(.subsubsub, .subsubsub *),
.post-type-popupbuilder .tablenav-pages.no-pages *:not(.subsubsub, .subsubsub *),
.post-type-sgpbtemplate .tablenav-pages.no-pages *:not(.subsubsub, .subsubsub *),
.post-type-sgpbautoresponder .tablenav-pages.no-pages *:not(.subsubsub, .subsubsub *),
.post-type-popupbuilder .tablenav-pages.one-page *:not(.subsubsub, .subsubsub *),
.post-type-sgpbtemplate .tablenav-pages.one-page *:not(.subsubsub, .subsubsub *),
.post-type-sgpbautoresponder .tablenav-pages.one-page *:not(.subsubsub, .subsubsub *)
echo wp_kses($styles, AdminHelper::allowed_html_tags());
public function inactiveExtensionNotice()
$dontShowLicenseBanner = get_option('sgpb-hide-license-notice-banner');
if ($dontShowLicenseBanner) {
$inactive = AdminHelper::getOption('SGPB_INACTIVE_EXTENSIONS');
$hasInactiveExtensions = AdminHelper::hasInactiveExtensions();
AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 1);
if ($hasInactiveExtensions) {
AdminHelper::updateOption('SGPB_INACTIVE_EXTENSIONS', 'inactive');
$licenseSectionUrl = menu_page_url(SGPB_POPUP_LICENSE, false);
$partOfContent = '<br><br><a href="'.esc_url($licenseSectionUrl).'">'.__('Follow the link', 'popup-builder').'</a> '.__('to finalize the activation.', 'popup-builder');
if (function_exists('get_current_screen')) {
$screen = get_current_screen();
if ($screenId == SGPB_POPUP_LICENSE_SCREEN) {
if ($hasInactiveExtensions && $inactive == 'inactive') {
<div id="welcome-panel" class="update-nag sgpb-extensions-notices sgpb-license-notice">
<div class="welcome-panel-content">
<b><?php esc_html_e('Thank you for choosing our plugin!', 'popup-builder') ?></b>
<b><?php esc_html_e('You have activated Popup Builder extension(s). Please, don\'t forget to activate the license key(s) as well.', 'popup-builder') ?></b>
<b><?php echo wp_kses($partOfContent, AdminHelper::allowed_html_tags()); ?></b>
<button type="button" class="notice-dismiss" onclick="jQuery('.sgpb-license-notice').remove();"><span class="screen-reader-text"><?php esc_html_e('Dismiss this notice.', 'popup-builder') ?></span></button>
<span class="sgpb-dont-show-again-license-notice"><?php esc_html_e('Don\'t show again.', 'popup-builder'); ?></span>
$content = ob_get_clean();
echo wp_kses($content, AdminHelper::allowed_html_tags());
public function hidePublishingActions() {
$currentPostType = AdminHelper::getCurrentPostType();
if (empty($currentPostType) || $currentPostType != SG_POPUP_POST_TYPE) {
#misc-publishing-actions .edit-post-status,
#misc-publishing-actions .edit-timestamp,
#misc-publishing-actions .edit-visibility {
echo wp_kses($styles, AdminHelper::allowed_html_tags());
public function hidePageBuilderEditButtons($postId = 0, $post = array())
$currentPostType = AdminHelper::getCurrentPostType();
if (empty($currentPostType) || $currentPostType != SG_POPUP_POST_TYPE) {
$excludedPopupTypesFromPageBuildersFunctionality = array(
$excludedPopupTypesFromPageBuildersFunctionality = apply_filters('sgpbHidePageBuilderEditButtons', $excludedPopupTypesFromPageBuildersFunctionality);
$popupType = AdminHelper::getCurrentPopupType();
if (in_array($popupType, $excludedPopupTypesFromPageBuildersFunctionality)) {
#elementor-switch-mode, #elementor-editor {
echo wp_kses($style, AdminHelper::allowed_html_tags());
public function getBannerContent()
// right metabox banner content
$metaboxBannerContent = AdminHelper::getFileFromURL(SGPB_METABOX_BANNER_CRON_TEXT_URL);
update_option('sgpb-metabox-banner-remote-get', $metaboxBannerContent);
if (isset($_GET['sgpb_type'])) {
$_GET['sgpb_type'] = sanitize_text_field($_GET['sgpb_type']);
if (!in_array($_GET['sgpb_type'], $fields)){
wp_redirect(get_home_url());
public function mainActionButtons($views)
require_once(SG_POPUP_VIEWS_PATH.'mainActionButtons.php');
* Loads the plugin language files
public function loadTextDomain()
$popupBuilderLangDir = SG_POPUP_BUILDER_PATH.'/languages/';
$popupBuilderLangDir = apply_filters('popupBuilderLanguagesDirectory', $popupBuilderLangDir);
$locale = apply_filters('sgpbPluginLocale', get_locale(), SG_POPUP_TEXT_DOMAIN);
$mofile = sprintf('%1$s-%2$s.mo', 'popup-builder', $locale);
$mofileLocal = $popupBuilderLangDir.$mofile;
if (file_exists($mofileLocal)) {
// Look in local /wp-content/plugins/popup-builder/languages/ folder
load_textdomain(SG_POPUP_TEXT_DOMAIN, $mofileLocal);
// Load the default language files
load_plugin_textdomain(SG_POPUP_TEXT_DOMAIN, false, $popupBuilderLangDir);
public function redirectFromPopupPage()
$currentPostType = @$post->post_type;
// in some themes global $post returns null
if (empty($currentPostType)) {
$currentPostType = $post_type;
// for editing popup content via page builders on backend
if (!isset($_GET) || empty($_GET)) {
if (!is_admin() && SG_POPUP_POST_TYPE == $currentPostType && !is_preview()) {
// it's for seo optimization
public function preGetPosts($query)
if (!is_admin() || !isset($_GET['post_type']) || sanitize_text_field($_GET['post_type']) != SG_POPUP_POST_TYPE) {
// change default order by id and desc
if (!isset($_GET['orderby'])) {
$query->set('orderby', 'ID');
$query->set('order', 'desc');
$query = apply_filters('sgpbPreGetPosts', $query);
public function pluginNotices()
if (function_exists('get_current_screen')) {
$screen = get_current_screen();
if ($screenId == 'edit-popupbuilder') {
$notificationsObj = new SGPBNotificationCenter();
echo wp_kses($notificationsObj->displayNotifications(), AdminHelper::allowed_html_tags());
$extensions = AdminHelper::getAllActiveExtensions();
$updated = get_option('sgpb_extensions_updated');
$scan_spam_code = AdminHelper::sgpbScanCustomJsProblem();
if( $scan_spam_code !== false )
$content.= AdminHelper::renderAlertCustomJsProblem( $scan_spam_code['marked_code'] );
if (get_option('sgpb-disable-custom-js')) {
$content.= AdminHelper::renderAlertEnableCustomJS();
// if popup builder has the old version
if (!get_option('SGPB_POPUP_VERSION')) {
echo wp_kses( $content, AdminHelper::allowed_html_tags() );
$alertProblem = get_option('sgpb_alert_problems');
// for old users show alert about problems
echo wp_kses(AdminHelper::renderAlertProblem(), AdminHelper::allowed_html_tags());
// Don't show the banner if there's not any extension of Popup Builder or if the user has clicked "don't show"
if (empty($extensions) || $updated) {
<div id="welcome-panel" class="update-nag sgpb-extensions-notices">
<div class="welcome-panel-content">
<?php echo wp_kses(AdminHelper::renderExtensionsContent(), AdminHelper::allowed_html_tags()); ?>
$content .= ob_get_clean();
echo wp_kses($content, AdminHelper::allowed_html_tags());
private function registerImporter()
require_once SG_POPUP_LIBS_PATH.'Importer.php';
$importer = new WP_Import();
register_importer(SG_POPUP_POST_TYPE, SG_POPUP_POST_TYPE, __('Importer', 'popup-builder'), array($importer, 'dispatch'));
public function pluginLoaded()
$this->registerImporter();
$versionPopup = get_option('SGPB_POPUP_VERSION');
$convert = get_option('sgpbConvertToNewVersion');
$unsubscribeColumnFixed = get_option('sgpbUnsubscribeColumnFixed');
AdminHelper::makeRegisteredPluginsStaticPathsToDynamic();
if (!$unsubscribeColumnFixed) {
AdminHelper::addUnsubscribeColumn();
update_option('sgpbUnsubscribeColumnFixed', 1);
delete_option('sgpbUnsubscribeColumn');
if ($versionPopup && !$convert) {
update_option('sgpbConvertToNewVersion', 1);
ConvertToNewVersion::convert();
Installer::registerPlugin();