: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
require_once(SG_POPUP_CLASSES_PATH.'/Ajax.php');
require_once(SG_POPUP_HELPERS_PATH.'AdminHelper.php');
use sgpbDataTable\SGPBTable;
use sgpb\SubscriptionPopup;
class SGPBSubscribers extends SGPBTable
public function __construct()
parent::__construct('sgpbAllSubscribers');
$this->setRowsPerPage(SGPB_APP_POPUP_TABLE_LIMIT);
$this->setTablename($wpdb->prefix.SGPB_SUBSCRIBERS_TABLE_NAME);
$selectAllCheckbox = '<div class="sgpb-wrapper checkbox-wrapper">
<input class="subs-bulk" type="checkbox" id="checkbox-all">
<label class="checkboxLabel" for="checkbox-all"></label>
'bulk' => $selectAllCheckbox,
'firstName' => __('First name', 'popup-builder'),
'lastName' => __('Last name', 'popup-builder'),
'email' => __('Email', 'popup-builder'),
'cDate' => __('Date', 'popup-builder'),
'subscriptionType' => __('Popup', 'popup-builder')
//'options' => __('Actions', 'popup-builder')
$filterColumnsDisplaySettings = array(
'displayColumns' => $displayColumns
$filterColumnsDisplaySettings = apply_filters('sgpbAlterColumnIntoSubscribers', $filterColumnsDisplaySettings);
$this->setColumns((isset($filterColumnsDisplaySettings['columns']) ? $filterColumnsDisplaySettings['columns'] : ''));
$this->setDisplayColumns((isset($filterColumnsDisplaySettings['displayColumns']) ? $filterColumnsDisplaySettings['displayColumns'] : ''));
$this->setSortableColumns(array(
'id' => array('id', false),
'firstName' => array('firstName', true),
'lastName' => array('lastName', true),
'email' => array('email', true),
'cDate' => array('cDate', true),
'subscriptionType' => array('subscriptionType', true),
$this->setInitialSort(array(
public function customizeRow(&$row)
$row = apply_filters('sgpbEditSubscribersTableRowValues', $row, $popupId);
$row[6] = get_the_title($popupId);
// show date more user friendly
$row[5] = gmdate('d F Y', strtotime($row[5]));
$row[0] = '<div class="sgpb-wrapper checkbox-wrapper">
<input class="subs-delete-checkbox" type="checkbox" id="checkbox-'.esc_attr($id).'" data-delete-id="'.esc_attr($id).'">
<label class="checkboxLabel" for="checkbox-'.esc_attr($id).'"></label>
public function customizeQuery(&$query)
$query = AdminHelper::subscribersRelatedQuery($query);
public function getNavPopupsConditions()
$subscriptionPopups = SubscriptionPopup::getAllSubscriptionForms();
if (isset($_GET['sgpb-subscription-popup-id'])) {
$selectedPopup = (int)sanitize_text_field($_GET['sgpb-subscription-popup-id']);
$allowed_html = AdminHelper::allowed_html_tags();
<input type="hidden" class="sgpb-subscription-popup-id" name="sgpb-subscription-popup-id" value="<?php echo esc_attr($selectedPopup);?>">
<input type="hidden" name="page" value="<?php echo esc_attr(SG_POPUP_SUBSCRIBERS_PAGE); ?>" >
<select class="select__select sgpb-margin-right-10" name="sgpb-subscription-popup" id="sgpb-subscription-popup">
$list .= '<option value="all">'.__('All', 'popup-builder').'</option>';
foreach ($subscriptionPopups as $popupId => $popupTitle) {
if ($selectedPopup == $popupId) {
$list .= '<option value="'.esc_attr($popupId).'"'.esc_attr($selected).'>'.esc_html($popupTitle).'</option>';
echo wp_kses($list, $allowed_html);
$content = ob_get_contents();
public function getNavDateConditions() {
$subscribersDates = SubscriptionPopup::getAllSubscribersDate();
foreach ($subscribersDates as $arr) {
$uniqueDates = array_unique($uniqueDates, SORT_REGULAR);
if (isset($_GET['sgpb-subscribers-date'])) {
$selectedDate = sanitize_text_field($_GET['sgpb-subscribers-date']);
$allowed_html = AdminHelper::allowed_html_tags();
<input type="hidden" class="sgpb-subscribers-date" name="sgpb-subscribers-date" value="<?php echo esc_attr($selectedDate);?>">
<select class="select__select sgpb-margin-right-10" name="sgpb-subscribers-dates" id="sgpb-subscribers-dates">
$gotDateList = '<option value="all">'.__('All dates', 'popup-builder').'</option>';
foreach ($uniqueDates as $date) {
if ($selectedDate == $date['date-value']) {
$gotDateList .= '<option value="'.$date['date-value'].'"'.$selected.'>'.$date['date-title'].'</option>';
if (empty($subscribersDates)) {
$dateValue = isset($date) && isset($date['date-value']) ? $date['date-value'] : '';
$gotDateList = '<option value="'.$dateValue.'"'.$selected.'>'.__('Date', 'popup-builder').'</option>';
echo wp_kses($dateList.$gotDateList, $allowed_html);
$content = ob_get_contents();
// parent class method overriding
public function extra_tablenav($which)
$isVisibleExtraNav = $this->getIsVisibleExtraNav();
if (!$isVisibleExtraNav) {
$allowed_html = AdminHelper::allowed_html_tags();
<div class="sgpb-display-flex sgpb-justify-content-between actions">
<label class="screen-reader-text" for="sgpb-subscription-popup"><?php esc_html_e('Filter by popup', 'popup-builder')?></label>
<?php echo wp_kses($this->getNavPopupsConditions(), $allowed_html); ?>
<label class="screen-reader-text" for="sgpb-subscribers-dates"><?php esc_html_e('Filter by date', 'popup-builder')?></label>
<?php echo wp_kses($this->getNavDateConditions(), $allowed_html); ?>
<input name="filter_action" id="post-query-submit" class="buttonGroup__button buttonGroup__button_blueBg buttonGroup__button_unrounded" value="<?php esc_html_e('Filter', 'popup-builder')?>" type="submit">
<button type="button" class="sgpb-btn sgpb-btn-danger sgpb-btn-disabled sgpb-btn--rounded sg-subs-delete-button" data-ajaxNonce="<?php echo esc_attr(SG_AJAX_NONCE);?>">
<?php esc_html_e('Delete subscriber(s)', 'popup-builder')?>