: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
private $hideMediaButton = true;
public function __toString()
public function __construct($hideMediaButton = true)
$this->hideMediaButton = $hideMediaButton;
public static function allowToShow()
global $pagenow, $typenow;
// for show in plugins page when package is pro
if (SGPB_POPUP_PKG !== SGPB_POPUP_PKG_FREE) {
array_push($pages, 'post.php');
return ($pages && $typenow != 'download');
private function allowToShowJsVariable()
return get_post_type() == SG_POPUP_POST_TYPE;
if (!$this->hideMediaButton && $this->allowToShowJsVariable()) {
$output = $this->mediaButton();
$output .= $this->insertJsVariable();
private function insertJsVariable()
if (!$this->allowToShowJsVariable()){
$buttonTitle = __('Insert custom JS variable', 'popup-builder');
@include(SG_POPUP_VIEWS_PATH.'jsVariableView.php');
$jsVariableContent = ob_get_contents();
$img = '<span class="dashicons dashicons-welcome-widgets-menus" style="padding: 3px 2px 0px 0px"></span>';
$output = '<a data-id="sgpb-js-variable-wrapper" href="javascript:void(0);" class="button sgpb-insert-js-variable" title="'.$buttonTitle.'" style="padding-left: .4em;">'. $img.$buttonTitle.'</a>';
if (!$this->hideMediaButton) {
return $output.$jsVariableContent;
private function mediaButton()
$allowToShow = MediaButton::allowToShow();
$currentPostType = AdminHelper::getCurrentPostType();
$mediaButtonContent = '';
if (!empty($currentPostType) && $currentPostType == SG_POPUP_POST_TYPE) {
$elementorContent = get_post_meta($post->ID, '_elementor_edit_mode', true);
if (!empty($elementorContent) && $elementorContent == 'builder'){
@include(SG_POPUP_VIEWS_PATH.'htmlCustomButtonElement.php');
$mediaButtonContent = ob_get_contents();
add_action('admin_footer', function() {
require_once(SG_POPUP_VIEWS_PATH.'htmlCustomButtonElement.php');
@include(SG_POPUP_VIEWS_PATH.'mediaButton.php');
$mediaButtonContent .= ob_get_contents();
$showCurrentUser = AdminHelper::showMenuForCurrentUser();
$screen = get_current_screen();
$hideInNewsletter = isset($screen) ? $screen->id === 'popupbuilder_page_sgpbNewsletter' : false;
if (!$showCurrentUser || $hideInNewsletter) {
$buttonTitle = __('Insert popup', 'popup-builder');
$img = '<span class="dashicons dashicons-welcome-widgets-menus" style="padding: 3px 2px 0px 0px"></span>';
$output = '<a data-id="sgpb-hidden-media-popup" href="javascript:void(0);" class="button sgpb-insert-media-button-js" title="'.$buttonTitle.'" style="padding-left: .4em;">'. $img.$buttonTitle.'</a>';
if (!$this->hideMediaButton) {
return $output.$mediaButtonContent;