: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class SGPBConfigDataHelper
public static $customPostType;
public static $allCustomPosts = array();
public static function getPostTypeData($args = array())
$query = self::getQueryDataByArgs($args);
foreach ($query->posts as $post) {
$posts[$post->ID] = $post->post_title;
public static function getQueryDataByArgs($args = array())
'post_status' => 'publish',
'suppress_filters' => false,
$args = wp_parse_args($args, $defaultArgs);
$query = new WP_Query($args);
* this method is used for to get all other post types
* that may created by another plugins or theme or website owner!
* example: download from EDD, product from Woocommerce!
public static function getAllCustomPosts()
$allCustomPosts = get_post_types($args);
if (isset($allCustomPosts[SG_POPUP_POST_TYPE])) {
unset($allCustomPosts[SG_POPUP_POST_TYPE]);
self::$allCustomPosts = $allCustomPosts;
return $allCustomPosts; // TODO check for usages and remove this line
public static function addFilters()
self::addPostTypeToFilters();
private static function addPostTypeToFilters()
self::getAllCustomPosts();
add_filter('sgPopupTargetParams', array(__CLASS__, 'addPopupTargetParams'), 1, 1);
add_filter('sgPopupTargetData', array(__CLASS__, 'addPopupTargetData'), 1, 1);
add_filter('sgPopupTargetTypes', array(__CLASS__, 'addPopupTargetTypes'), 1, 1);
add_filter('sgPopupTargetAttrs', array(__CLASS__, 'addPopupTargetAttrs'), 1, 1);
add_filter('sgPopupPageTemplates', array(__CLASS__, 'addPopupPageTemplates'), 1, 1);
add_filter('sgPopupTargetPostType', array(__CLASS__, 'getAllCustomPostTypes'), 1, 1);
add_filter('sgPopupTargetPageType', array(__CLASS__, 'getPageTypes'), 1, 1);
public static function addPopupTargetParams($targetParams)
$allCustomPostTypes = self::$allCustomPosts;
// for conditions, to exclude other post types, tags etc.
if (isset($targetParams['select_role'])) {
foreach ($allCustomPostTypes as $customPostType) {
$targetParams[$customPostType] = array(
$customPostType.'_all' => 'All '.ucfirst($customPostType).'s',
$customPostType.'_archive' => 'Archives '.ucfirst($customPostType).'s',
$customPostType.'_selected' => 'Select '.ucfirst($customPostType).'s',
$customPostType.'_categories' => 'Select '.ucfirst($customPostType).' categories'
public static function addPopupTargetData($targetData)
$allCustomPostTypes = self::$allCustomPosts;
foreach ($allCustomPostTypes as $customPostType) {
$targetData[$customPostType.'_all'] = null;
$targetData[$customPostType.'_selected'] = '';
$targetData[$customPostType.'_categories'] = self::getCustomPostCategories($customPostType);
public static function getCustomPostCategories($postTypeName)
$taxonomyObjects = get_object_taxonomies($postTypeName);
if ($postTypeName == 'product') {
$taxonomyObjects = array('product_cat');
$categories = self::getPostsAllCategories($postTypeName, $taxonomyObjects);
public static function addPopupTargetTypes($targetTypes)
$allCustomPostTypes = self::$allCustomPosts;
foreach ($allCustomPostTypes as $customPostType) {
$targetTypes[$customPostType.'_selected'] = 'select';
$targetTypes[$customPostType.'_categories'] = 'select';
public static function addPopupTargetAttrs($targetAttrs)
$allCustomPostTypes = self::$allCustomPosts;
foreach ($allCustomPostTypes as $customPostType) {
$targetAttrs[$customPostType.'_selected']['htmlAttrs'] = array('class' => 'js-sg-select2 js-select-ajax', 'data-select-class' => 'js-select-ajax', 'data-select-type' => 'ajax', 'data-value-param' => $customPostType, 'multiple' => 'multiple');
$targetAttrs[$customPostType.'_selected']['infoAttrs'] = array('label' => __('Select ', 'popup-builder').$customPostType);
$targetAttrs[$customPostType.'_categories']['htmlAttrs'] = array('class' => 'js-sg-select2 js-select-ajax', 'data-select-class' => 'js-select-ajax', 'isNotPostType' => true, 'data-value-param' => $customPostType, 'multiple' => 'multiple');
$targetAttrs[$customPostType.'_categories']['infoAttrs'] = array('label' => __('Select ', 'popup-builder').$customPostType.' categories');
public static function addPopupPageTemplates($templates)
$pageTemplates = self::getPageTemplates();
$pageTemplates += $templates;
public static function getAllCustomPostTypes()
$allCustomPosts = get_post_types($args);
if (!empty($allCustomPosts[SG_POPUP_POST_TYPE])) {
unset($allCustomPosts[SG_POPUP_POST_TYPE]);
public static function getPostsAllCategories($postType = 'post', $taxonomies = array(), $search_text = '')
'taxonomy' => $taxonomies,
'name__like' => $search_text
$supportedTaxonomies = array('category');
if (!empty($taxonomies)) {
$supportedTaxonomies = $taxonomies;
foreach ($cats as $cat) {
if (isset($cat->taxonomy)) {
if (!in_array($cat->taxonomy, $supportedTaxonomies)) {
$catsParams[$id] = $name;
public static function getPageTypes()
$postTypes['is_home_page'] = __('Home Page', 'popup-builder');
$postTypes['is_home'] = __('Posts Page', 'popup-builder');
$postTypes['is_search'] = __('Search Pages', 'popup-builder');
$postTypes['is_404'] = __('404 Pages', 'popup-builder');
if (function_exists('is_shop')) {
$postTypes['is_shop'] = __('Shop Page', 'popup-builder');
if (function_exists('is_archive')) {
$postTypes['is_archive'] = __('Archive Page', 'popup-builder');
public static function getPageTemplates()
'page.php' => __('Default Template', 'popup-builder')
$templates = wp_get_theme()->get_page_templates();
foreach ($templates as $key => $value) {
$pageTemplates[$key] = $value;
public static function getAllTags($search_text = '')
'name__like' => $search_text
foreach ($tags as $tag) {
$allTags[$tag->slug] = $tag->name;
public static function getTagsByIds($ids = [])
foreach ($tags as $tag) {
$allTags[$tag->slug] = $tag->name;
public static function getTagsBySlug($ids = [])
foreach ($tags as $tag) {
$allTags[$tag->slug] = $tag->name;
public static function getTermsByIds($ids = array())
$terms = get_terms(array(
foreach ($terms as $term) {
$allTags[$term->term_id] = $term->name;
public static function defaultData()
$data['contentClickOptions'] = array(
'fieldWrapperAttr' => array(
'class' => 'col-md-7 sgpb-choice-option-wrapper'
'class' => 'formItem__title'
'groupWrapperAttr' => array(
'class' => 'subFormItem sgpb-choice-wrapper formItem'
'buttonPosition' => 'right',
'name' => 'sgpb-content-click-behavior',
'name' => __('Close Popup', 'popup-builder').':'
'name' => 'sgpb-content-click-behavior',
'data-attr-href' => 'content-click-redirect',
'name' => __('Redirect', 'popup-builder').':'
'name' => 'sgpb-content-click-behavior',
'data-attr-href' => 'content-copy-to-clipboard',
'name' => __('Copy to clipboard', 'popup-builder').':'
$data['customEditorContent'] = array(
'ShouldOpen' => '<b>Opening events:</b><br><br><b>#1</b> Add the code you want to run <b>before</b> the popup opening. This will be a condition for opening the popup, that is processed and defined before the popup opening. If the return value is <b>"true"</b> then the popup will open, if the value is <b>"false"</b> the popup won\'t open.',
'WillOpen' => '<b>#2</b> Add the code you want to run <b>before</b> the popup opens. This will be the code that will work in the process of opening the popup. <b>true/false</b> conditions will not work in this phase.',
'DidOpen' => '<b>#3</b> Add the code you want to run <b>after</b> the popup opens. This code will work when the popup is already open on the page.',
'ShouldClose' => '<b>Closing events:</b><br><br><b>#1</b> Add the code that will be fired <b>before</b> the popup closes. This will be a condition for the popup closing. If the return value is <b>"true"</b> then the popup will close, if the value is <b>"false"</b> the popup won\'t close.',
'WillClose' => '<b>#2</b> Add the code you want to run <b>before</b> the popup closes. This will be the code that will work in the process of closing the popup. <b>true/false</b> conditions will not work in this phase.',
'DidClose' => '<b>#3</b> Add the code you want to run <b>after</b> the popup closes. This code will work when the popup is already closed on the page.'
'<span class="formItem__text">
'.__('If you need the popup id number in the custom code, you may use the following variable to get the ID:', 'popup-builder').'
// we need this oldDefaultValue for the backward compatibility
'oldDefaultValue' => array(
'/*popup content wrapper*/'."\n".
'.sgpb-content-popupId {'."\n\n".'}'."\n\n".
'.sgpb-popup-overlay-popupId {'."\n\n".'}'."\n\n".
'/*popup wrapper*/'."\n".
'.sgpb-popup-builder-content-popupId {'."\n\n".'}'."\n\n"
'<br>/*popup content wrapper*/',
'.sgpb-popup-overlay-popupId',
'.sgpb-popup-builder-content-popupId'
'<span class="formItem__text">
'.__('If you need the popup id number in the custom code, you may use the following variable to get the ID:', 'popup-builder').'
$data['htmlCustomButtonArgs'] = array(
'fieldWrapperAttr' => array(
'class' => 'col-md-6 sgpb-choice-option-wrapper'
'class' => 'col-md-6 sgpb-choice-option-wrapper sgpb-sub-option-label'
'groupWrapperAttr' => array(
'class' => 'row form-group sgpb-choice-wrapper'
'buttonPosition' => 'right',
'name' => 'sgpb-custom-button',
'class' => 'custom-button-copy-to-clipboard',
'data-attr-href' => 'sgpb-custom-button-copy',
'value' => 'copyToClipBoard'
'name' => __('Copy to clipboard', 'popup-builder').':'
'name' => 'sgpb-custom-button',
'class' => 'custom-button-copy-to-clipboard',
'data-attr-href' => 'sgpb-custom-button-redirect-to-URL',
'value' => 'redirectToURL'
'name' => __('Redirect to URL', 'popup-builder').':'
'name' => 'sgpb-custom-button',
'class' => 'subs-success-open-popup',
'data-attr-href' => 'sgpb-custom-button-open-popup',
'name' => __('Open popup', 'popup-builder').':'
'name' => 'sgpb-custom-button',
'class' => 'sgpb-custom-button-hide-popup',
'name' => __('Hide popup', 'popup-builder').':'
$data['popupDimensions'] = array(
'fieldWrapperAttr' => array(
'class' => 'col-md-7 sgpb-choice-option-wrapper'
'class' => 'formItem__title'
'groupWrapperAttr' => array(
'class' => 'subFormItem sgpb-choice-wrapper sgpb-display-flex sgpb-align-item-center formItem'
'buttonPosition' => 'right',
'name' => 'sgpb-popup-dimension-mode',
'data-attr-href' => 'responsive-dimension-wrapper',
'value' => 'responsiveMode'
'name' => __('Responsive mode', 'popup-builder').':',
'info' => __('The sizes of the popup will be counted automatically, according to the content size of the popup. You can select the size in percentages, with this mode, to specify the size on the screen', 'popup-builder').'.'
'name' => 'sgpb-popup-dimension-mode',
'data-attr-href' => 'custom-dimension-wrapper',
'name' => __('Custom mode', 'popup-builder').':',
'info' => __('Add your own custom dimensions for the popup to get the exact sizing for your popup', 'popup-builder').'.'