• Hi @hyenokian,

    My site crashed, and WordPress reported fatal errors. Upon inspecting, it appears that AYS Popup Box is not PHP 8.2+ compatible (and is certainly [unfortunately] the culprit). I reverted my site to PHP 7.4, the errors went away, and the site functions fine. Would you update this plugin to be compatible with PHP 8.2+?

    Here’s the part that’s causing the error:

    Fatal error: Uncaught TypeError: str_replace():
    Argument #2 ($replace) must be of type string when argument #1 ($search) is a string

    .../plugins/ays-popup-box/includes/class-ays-pb-data.php:74

    str_replace('%%post_author_r...', Array, 'You can give in...')

    Thank you for your help!

    • This topic was modified 4 days, 4 hours ago by Adam.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Jasmine

    (@hyenokian)

    Dear @panhead,

    Thank you for your topic.

    Could you please let us know which versions of WordPress and Popup Box you are currently using so that our team can check the issue?

    Looking forward to your reply.

    Thank you!

    Thread Starter Adam

    (@panhead)

    Thank you for your reply, @hyenokian!

    I am using the latest WordPress 7.0.1, and the latest Popup Box 6.3.4. When I upgrade my site’s PHP from 7.4 to 8.2, the site goes offline. If I revert back to 7.4, the site comes back up, and everything works as intended.

    Thread Starter Adam

    (@panhead)

    Copilot says that this will help narrow down the issue:

    Fatal error:
    str_replace(): Argument #2 ($replace)
    must be of type string

    class-ays-pb-data.php:74

    and this…

    str_replace('%%post_author_r...', Array, ...)
    Thread Starter Adam

    (@panhead)

    Further, Copilot had me replace this function: replace_message_variables with this:

    public static function replace_message_variables($content, $data){
    foreach($data as $variable => $value){

    if (is_array($value)) {
    $value = implode(', ', $value);
    } elseif (is_object($value)) {
    $value = '';
    }

    $content = str_replace(
    "%%".$variable."%%",
    (string) $value,
    $content
    );
    }

    return $content;
    }

    And my site came back online!

    Plugin Support Jasmine

    (@hyenokian)

    Dear @panhead,

    Thank you for your reply.

    We followed the steps you described, but we were unable to reproduce the issue on our end.

    Please contact us through this form so that we can investigate why this is happening on your website. If the issue is still present, our team will check it directly on your site and fix it.

    Looking forward to hearing from you.

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.