• Hello,

    Since updated to PHP 8.0, I am getting a couple of PHP warning messages in my WP error_log related to Cookie Notice. This is using the latest v2.3.0 of the plugin.
    PHP Warning: Undefined array key "refuse_opt" in /home/deleted/public_html/wp-content/plugins/cookie-notice/includes/frontend.php on line 173
    PHP Warning: Undefined array key "refuse_opt" in /home/deleted/public_html/wp-content/plugins/cookie-notice/includes/frontend.php on line 177

    I have set WP_DEBUG = true in my wp-config, but the warning messages do not appear on the frontend of the site.
    These PHP warning messages aren’t written to error_log when visiting the site, clicking on the cookie notice banner, or even saving the Cookie Notice settings.
    So I don’t quite know what action is causing them to initiate, but they seem to occur randomly every few hours.

    Line 173:
    . ( $options['refuse_opt'] === true ? '<a href="#" id="cn-refuse-cookie" data-cookie-set="refuse" class="cn-set-cookie ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['refuse_text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['refuse_text'] ) . '</a>' : '' )
    Line 177:
    ' . ( $options['refuse_opt'] === true && $options['revoke_cookies'] == true ?

    Is there a quick and easy syntax fix to stop these warnings from filling up my log file?

    Thank you

Viewing 1 replies (of 1 total)
  • Thread Starter gatfuts

    (@gatfuts)

    No response yet, so went about fixing it myself. Change line 173 to:
    . ( (isset($options['refuse_opt']) && $options['refuse_opt'] === true) ? '<a href="#" id="cn-refuse-cookie" data-cookie-set="refuse" class="cn-set-cookie ' . $options['button_class'] . ( $options['css_class'] !== '' ? ' cn-button-custom ' . $options['css_class'] : '' ) . '" aria-label="' . esc_attr( $options['refuse_text'] ) . '"' . ( $options['css_class'] == '' ? ' style="background-color: ' . esc_attr( $options['colors']['button'] ) . '"' : '' ) . '>' . esc_html( $options['refuse_text'] ) . '</a>' : '' )

    And line 177 to:
    ' . ( (isset($options['refuse_opt']) && $options['refuse_opt'] === true && $options['revoke_cookies'] == true) ?

Viewing 1 replies (of 1 total)

The topic ‘PHP 8.0 Warning Message’ is closed to new replies.