Support » Plugin: Simple Banner » Bug: Banner not showing on pages where get_the_ID not available

  • Resolved mrmadhat

    (@mrmadhat)


    Hi,

    In simple-banner.php line 56 there is the following code:

    
    $banner_is_disabled = in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))) || get_option('hide_simple_banner') == "yes";
    
    if ($banner_is_disabled){
        echo '<style type="text/css" media="screen">.simple-banner{display:none;}</style>';
    }
    

    On pages where get_the_ID() is not available, such as custom taxonomy archives, $banner_is_disabled is true when get_option('disabled_pages_array') is an empty string.

    a short term fix is:

    
    $disabled_pages = get_option('disabled_pages_array');
    $disabled_on_current_page = ! empty($disabled_pages) && in_array(get_the_ID(), explode(',', $disabled_pages));
    
    $banner_is_disabled = $disabled_on_current_page || get_option('hide_simple_banner') == "yes";
    

    but I think a better solution would be one that checks what page the user is on and handles it.

    For anyone experiencing this issue who needs a fix immediately you can add the following to the functions.php of your child theme:

    
    add_action('wp_head', 'force_simple_banner_display');
    
    function force_simple_banner_display() {
        echo '<style>.simple-banner { display: block !important; }</style>';
    }
    
    • This topic was modified 3 months, 3 weeks ago by mrmadhat.
    • This topic was modified 3 months, 3 weeks ago by mrmadhat.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.