: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @copyright Copyright (c) 2023, Code Atlantic LLC
if ( ! defined( 'ABSPATH' ) ) {
* Hook the initialize method to the WP init action.
public static function init() {
/** Regitster Metaboxes */
add_action( 'add_meta_boxes', [ __CLASS__, 'meta_box' ] );
/** Process meta saving. */
add_action( 'save_post', [ __CLASS__, 'save' ], 10, 2 );
* Registers popup metaboxes.
public static function meta_box() {
add_meta_box( 'pum_theme_settings', __( 'Theme Settings', 'popup-maker' ), [ __CLASS__, 'render_settings_meta_box' ], 'popup_theme', 'normal', 'high' );
add_meta_box( 'pum_theme_preview', __( 'Theme Preview', 'popup-maker' ), [ __CLASS__, 'render_preview_meta_box' ], 'popup_theme', 'side', 'high' );
* Ensures integrity of values.
public static function parse_values( $values = [] ) {
$defaults = self::defaults();
if ( empty( $values ) ) {
$values = self::fill_missing_defaults( $values );
* Fills default settings only when missing.
* Excludes checkbox type fields where a false value is represented by the field being unset.
public static function fill_missing_defaults( $settings = [] ) {
$excluded_field_types = [ 'checkbox', 'multicheck' ];
$defaults = self::defaults();
foreach ( $defaults as $field_id => $default_value ) {
$field = PUM_Utils_Fields::get_field( self::fields(), $field_id );
if ( isset( $settings[ $field_id ] ) || in_array( $field['type'], $excluded_field_types ) ) {
$settings[ $field_id ] = $default_value;
* Parse & prepare values for form rendering.
* Add additional data for license_key fields, split the measure fields etc.
public static function render_form_values( $settings ) {
foreach ( $settings as $key => $value ) {
$field = PUM_Utils_Fields::get_field( self::fields(), $key );
switch ( $field['type'] ) {
* Render the settings meta box wrapper and JS vars.
public static function render_settings_meta_box() {
$theme = pum_get_theme( $post->ID );
// Get the meta directly rather than from cached object.
$settings = self::parse_values( $theme->get_settings() );
wp_nonce_field( basename( __FILE__ ), 'pum_theme_settings_nonce' );
wp_enqueue_script( 'popup-maker-admin' );
<script type="text/javascript">
window.pum_theme_settings_editor =
echo PUM_Utils_Array::safe_json_encode(
'pum_theme_settings_editor_var',
'id' => 'pum-theme-settings',
'sections' => self::sections(),
'fields' => self::fields(),
'current_values' => self::render_form_values( $settings ),
<div id="pum-theme-settings-container" class="pum-theme-settings-container">
<div class="pum-no-js" style="padding: 0 12px;">
<p><?php printf( __( 'If you are seeing this, the page is still loading or there are Javascript errors on this page. %1$sView troubleshooting guide%2$s', 'popup-maker' ), '<a href="https://docs.wppopupmaker.com/article/373-checking-for-javascript-errors" target="_blank">', '</a>' ); ?></p>
public static function render_preview_meta_box() {
$theme = pum_get_theme( $post->ID );
$deprecated_atb_enabled = class_exists( 'PUM_ATB' ) && ! pum_extension_enabled( 'advanced-theme-builder' );
// Remove this div after PUM ATC updated properly
if ( $deprecated_atb_enabled ) {
echo '<div id="PopMake-Preview">';
<div class="pum-theme-preview">
<div class="pum-popup-overlay <?php echo $deprecated_atb_enabled ? 'example-popup-overlay' : ''; ?>"></div>
<div class="pum-popup-container <?php echo $deprecated_atb_enabled ? 'example-popup' : ''; ?>">
<div class="pum-popup-title"><?php _e( 'Title Text', 'popup-maker' ); ?></div>
<div class="pum-popup-content">
<?php echo apply_filters( 'pum_example_popup_content', '<p>Suspendisse ipsum eros, tincidunt sed commodo ut, viverra vitae ipsum. Etiam non porta neque. Pellentesque nulla elit, aliquam in ullamcorper at, bibendum sed eros. Morbi non sapien tellus, ac vestibulum eros. In hac habitasse platea dictumst. Nulla vestibulum, diam vel porttitor placerat, eros tortor ultrices lectus, eget faucibus arcu justo eget massa. Maecenas id tellus vitae justo posuere hendrerit aliquet ut dolor.</p>' ); ?>
<button type="button" class="pum-popup-close <?php echo $deprecated_atb_enabled ? 'close-popup' : ''; ?>" aria-label="<?php _e( 'Close', 'popup-maker' ); ?>">
<?php echo $theme->get_setting( 'close_text', '×' ); ?>
__( 'If you move this theme preview to the bottom of your sidebar here it will follow you down the page?', 'popup-maker' ),
__( 'Clicking on an element in this theme preview will take you to its relevant settings in the editor?', 'popup-maker' ),
$key = array_rand( $tips, 1 );
<i class="dashicons dashicons-info"></i> <?php echo '<strong>' . __( 'Did you know:', 'popup-maker' ) . '</strong> ' . $tips[ $key ]; ?>
// Remove this div after PUM ATC updated properly
if ( $deprecated_atb_enabled ) {
* Used to get deprecated fields for metabox saving of old extensions.
public static function deprecated_meta_fields() {
foreach ( self::deprecated_meta_field_groups() as $group ) {
foreach ( apply_filters( 'popmake_popup_theme_meta_field_group_' . $group, [] ) as $field ) {
$fields[] = 'popup_theme_' . $group . '_' . $field;
return apply_filters( 'popmake_popup_theme_meta_fields', $fields );
* Used to get field groups from extensions.
public static function deprecated_meta_field_groups() {
return apply_filters( 'popmake_popup_theme_meta_field_groups', [ 'display', 'close' ] );
public static function can_save( $post_id, $post ) {
if ( isset( $post->post_type ) && 'popup_theme' !== $post->post_type ) {
if ( ! isset( $_POST['pum_theme_settings_nonce'] ) || ! wp_verify_nonce( $_POST['pum_theme_settings_nonce'], basename( __FILE__ ) ) ) {
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
if ( isset( $post->post_type ) && 'revision' === $post->post_type ) {
if ( ! current_user_can( 'edit_post', $post_id ) ) {
public static function save( $post_id, $post ) {
if ( ! self::can_save( $post_id, $post ) ) {
$theme = pum_get_theme( $post_id );
$settings = ! empty( $_POST['theme_settings'] ) ? $_POST['theme_settings'] : [];
$settings = wp_parse_args( $settings, self::defaults() );
$settings = apply_filters( 'pum_theme_setting_pre_save', $settings, $post->ID );
$settings = PUM_Utils_Fields::sanitize_fields( $settings, self::fields() );
// Ensure data integrity.
$settings = self::parse_values( $settings );
// $theme->update_meta( 'popup_theme_settings', $settings );
$theme->update_settings( $settings );
// If this is a built in theme and the user has modified it set a key so that we know not to make automatic upgrades to it in the future.
if ( get_post_meta( $post_id, '_pum_built_in', true ) !== false ) {
update_post_meta( $post_id, '_pum_user_modified', true );
self::process_deprecated_saves( $post_id, $post );
do_action( 'pum_save_theme', $post_id, $post );
public static function process_deprecated_saves( $post_id, $post ) {
$field_prefix = 'popup_theme_';
$old_fields = (array) apply_filters(
'popmake_popup_theme_fields',
foreach ( $old_fields as $section => $fields ) {
$section_prefix = "{$field_prefix}{$section}";
foreach ( $fields as $field => $args ) {
$field_name = "{$section_prefix}_{$field}";
if ( isset( $_POST[ $field_name ] ) ) {
$meta_values[ $field ] = apply_filters( 'popmake_metabox_save_' . $field_name, $_POST[ $field_name ] );
update_post_meta( $post_id, "popup_theme_{$section}", $meta_values );
// TODO Remove this and all other code here. This should be clean and all code more compartmentalized.
foreach ( self::deprecated_meta_fields() as $field ) {
if ( isset( $_POST[ $field ] ) ) {
$new = apply_filters( 'popmake_metabox_save_' . $field, $_POST[ $field ] );
update_post_meta( $post_id, $field, $new );
delete_post_meta( $post_id, $field );
* List of tabs & labels for the settings panel.
public static function tabs() {
'pum_theme_settings_tabs',
'general' => __( 'General', 'popup-maker' ),
'overlay' => __( 'Overlay', 'popup-maker' ),
'container' => __( 'Container', 'popup-maker' ),
'title' => __( 'Title', 'popup-maker' ),
'content' => __( 'Content', 'popup-maker' ),
'close' => __( 'Close', 'popup-maker' ),
'advanced' => __( 'Advanced', 'popup-maker' ),
* List of tabs & labels for the settings panel.
public static function sections() {
'pum_theme_settings_sections',
'main' => __( 'General', 'popup-maker' ),
'background' => __( 'Background', 'popup-maker' ),
'main' => __( 'Container', 'popup-maker' ),
'background' => __( 'Background', 'popup-maker' ),
'border' => __( 'Border', 'popup-maker' ),
'boxshadow' => __( 'Drop Shadow', 'popup-maker' ),
'typography' => __( 'Font', 'popup-maker' ),
'textshadow' => __( 'Text Shadow', 'popup-maker' ),
'typography' => __( 'Text', 'popup-maker' ),
'main' => __( 'General', 'popup-maker' ),
'size' => __( 'Size', 'popup-maker' ),
'position' => __( 'Position', 'popup-maker' ),
'background' => __( 'Background', 'popup-maker' ),
'border' => __( 'Border', 'popup-maker' ),
'boxshadow' => __( 'Drop Shadow', 'popup-maker' ),
'typography' => __( 'Font', 'popup-maker' ),
'textshadow' => __( 'Text Shadow', 'popup-maker' ),
'main' => __( 'Advanced', 'popup-maker' ),
public static function border_style_options() {
'pum_theme_border_style_options',
'none' => __( 'None', 'popup-maker' ),
'solid' => __( 'Solid', 'popup-maker' ),
'dotted' => __( 'Dotted', 'popup-maker' ),
'dashed' => __( 'Dashed', 'popup-maker' ),
'double' => __( 'Double', 'popup-maker' ),
'groove' => __( 'Groove', 'popup-maker' ),
'inset' => __( 'Inset (inner shadow)', 'popup-maker' ),
'outset' => __( 'Outset', 'popup-maker' ),
'ridge' => __( 'Ridge', 'popup-maker' ),
public static function size_unit_options() {
'pum_theme_size_unit_options',
public static function font_family_options() {
'inherit' => __( 'Use Your Themes', 'popup-maker' ),
__( 'System Fonts', 'popup-maker' ) => [
'Sans-Serif' => 'Sans-Serif',
'Comic Sans MS' => 'Comic Sans MS',
'Lucida Grande' => 'Lucida Grande',
'Times New Roman' => 'Times New Roman',
/** @deprecated 1.8.0 This filter is no longer in use */
$old_fonts = apply_filters( 'popmake_font_family_options', [] );
$fonts = array_merge( $fonts, array_flip( $old_fonts ) );
return apply_filters( 'pum_theme_font_family_options', $fonts );
public static function font_weight_options() {
'pum_theme_font_weight_options',
400 => __( 'Normal', 'popup-maker' ) . ' (400)',
700 => __( 'Bold', 'popup-maker' ) . ' (700)',
* Returns array of popup settings fields.
public static function fields() {
if ( ! isset( $fields ) ) {
$size_unit_options = self::size_unit_options();
$border_style_options = self::border_style_options();
$font_family_options = self::font_family_options();
$font_weight_options = self::font_weight_options();
'pum_theme_settings_fields',