: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$popup = pum_get_popup( $popup->ID );
if ( ! pum_is_popup( $popup ) ) {
if ( $popup->get_setting( 'zindex', false ) ) {
$zindex = esc_attr( $popup->get_setting( 'zindex' ) );
echo sprintf( "#pum-%d {z-index: %d}\r\n", esc_attr( $popup->ID ), esc_attr( $zindex ) );
// Allow per popup CSS additions.
do_action( 'pum_generate_popup_css', $popup->ID );
$popup_css .= ob_get_clean();
// Clear the global $current.
pum()->current_popup = null;
* Used when asset cache is not enabled.
public static function inline_css() {
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo self::generate_font_imports();
echo self::generate_popup_theme_styles();
echo self::generate_popup_styles();
// Render any extra styles globally added.
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
* Generate Popup Theme Styles
public static function custom_css() {
// Render any extra styles globally added.
if ( ! empty( $GLOBALS['pum_extra_styles'] ) ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $GLOBALS['pum_extra_styles'];
// Allows rendering extra css via action.
do_action( 'pum_styles' );
* Generate Popup Theme Styles
public static function generate_font_imports() {
foreach ( pum_get_all_themes() as $theme ) {
$google_fonts = array_merge( $google_fonts, pum_get_theme( $theme->ID )->get_google_fonts_used() );
if ( ! empty( $google_fonts ) && ! pum_get_option( 'disable_google_font_loading', false ) ) {
$link = '//fonts.googleapis.com/css?family=';
foreach ( $google_fonts as $font_family => $variants ) {
if ( '//fonts.googleapis.com/css?family=' !== $link ) {
if ( is_array( $variants ) ) {
if ( implode( ',', $variants ) !== '' ) {
$link .= trim( implode( ',', $variants ), ':' );
$imports = "/* Popup Google Fonts */\r\n@import url('$link');\r\n\r\n" . $imports;
$imports = apply_filters( 'pum_generate_font_imports', $imports );
* Generate Popup Theme Styles
public static function generate_popup_theme_styles() {
$themes = pum_get_all_themes();
foreach ( $themes as $theme ) {
$theme_styles = pum_get_rendered_theme_styles( $theme->ID );
if ( '' !== $theme_styles ) {
$styles .= '/* Popup Theme ' . $theme->ID . ': ' . $theme->post_title . " */\r\n";
$styles .= $theme_styles . "\r\n";
$styles = apply_filters( 'popmake_theme_styles', $styles );
$styles = apply_filters( 'pum_generate_popup_theme_styles', $styles );
* Reset the cache to force regeneration.
public static function reset_cache() {
update_option( 'pum-has-cached-css', false );
update_option( 'pum-has-cached-js', false );
* Adds admin notice if the files are not writeable.
* @param array $alerts The alerts currently in the alert system.
* @return array Alerts for the alert system.
public static function cache_alert( $alerts ) {
if ( self::should_not_show_alert() ) {
$nonce = wp_create_nonce( 'pum-write-notice-action' );
$undo_url = add_query_arg( [
'pum_writeable_notice_check' => 'undo',
$dismiss_url = add_query_arg([
'pum_writeable_notice_check' => 'dismiss',
<li><a href="<?php echo esc_attr( $undo_url ); ?>"><strong><?php esc_html_e( 'Try to create cache again', 'popup-maker' ); ?></strong></a></li>
<li><a href="<?php echo esc_attr( $dismiss_url ); ?>" class="pum-dismiss"><?php esc_html_e( 'Keep current method', 'popup-maker' ); ?></a></li>
<li><a href="https://docs.wppopupmaker.com/article/521-debugging-filesystem-errors?utm_source=filesystem-error-alert&utm_medium=inline-doclink&utm_campaign=filesystem-error" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'Learn more', 'popup-maker' ); ?></a></li>
'code' => 'pum_writeable_notice',
'message' => esc_html__( "Popup Maker detected an issue with your file system's ability and is unable to create & save cached assets for your popup styling and settings. This may lead to suboptimal performance. Please check your filesystem and contact your hosting provide to ensure Popup Maker can create and write to cache files.", 'popup-maker' ),
'dismissible' => '2 weeks',
* Checks if any options have been clicked from admin notices.
public static function admin_notice_check() {
if ( isset( $_GET['pum_writeable_notice_check'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
check_admin_referer( 'pum-write-notice-action' );
// If either dismiss or try again button is clicked, hide the admin notice.
update_option( '_pum_writeable_notice_dismissed', true );
if ( 'undo' === $_GET['pum_writeable_notice_check'] ) {
// If try again is clicked, remove flag.
update_option( 'pum_files_writeable', true );
pum_update_option( 'disable_asset_caching', true );
* Whether or not we should show admin notice
* @return bool True if notice should not be shown
public static function should_not_show_alert() {
return true === (bool) get_option( 'pum_files_writeable', true ) || true === (bool) get_option( '_pum_writeable_notice_dismissed', true );
* Tests whether the file is accessible and returns 200 status code
* @param string $filename Filename of cache file to test.
* @return bool True if file exists and is accessible
private static function is_file_accessible( $filename ) {
if ( ! $filename || empty( $filename ) || ! is_string( $filename ) ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
pum_log_message( 'Cannot check if file is accessible. Filename passed: ' . print_r( $filename, true ) );
$cache_url = PUM_Helpers::get_cache_dir_url();
if ( false === $cache_url ) {
pum_log_message( 'Cannot access cache file when tested. Cache URL returned false.' );
$protocol = is_ssl() ? 'https:' : 'http:';
$file = $protocol . $cache_url . '/' . $filename;
$results = wp_remote_request(
// If it returned a WP_Error, let's log its error message.
if ( is_wp_error( $results ) ) {
$error = $results->get_error_message();
pum_log_message( sprintf( 'Cannot access cache file when tested. Tested file: %s Error given: %s', esc_html( $file ), esc_html( $error ) ) );
// If it returned valid array...
if ( is_array( $results ) && isset( $results['response'] ) ) {
$status_code = $results['response']['code'];
// ... then, check if it's a valid status code. Only if it is a valid 2XX code, will this method return true.
if ( false !== $status_code && ( 200 <= $status_code && 300 > $status_code ) ) {
pum_log_message( sprintf( 'Cannot access cache file when tested. Status code received was: %s', esc_html( $status_code ) ) );
* Process a change to options conditionally if the user came from a bugged version.
* @param string $upgraded_from The version the user upgraded from.
public static function maybe_reset_asset_cache_notices( $upgraded_from ) {
// If version compoare upgraded from was v1.18.0 exactly delete the notice.
if ( '1.18.0' === $upgraded_from ) {
update_option( 'pum_files_writeable', true );
update_option( '_pum_writeable_notice_dismissed', true );
pum_update_option( 'disable_asset_caching', false );