• Hi there,
    Thanks for a festive plugin! ??

    I’ve just come across a bug. I note that it was raised some time ago too, but not detailed enough to be resolved there.

    If you set your homepage as a static page (that is, it doesn’t contain your blog posts) then the plugin doesn’t honour the “Show on … Home Page” option.

    The issue is with line 108 in class-wp.snow-effect-public.php, which is supposed to check the homepage option. It’s checking by using the is_home() function, which is historically badly named, as it only fires on the blog list page, irrespective of whether the blog list is on the “home” page or not. So when the blog posts are on the homepage, the plugin fires, but when the blog posts are on a separate page, it doesn’t.

    More properly, line 108 should check for is_front_page(), which fires on static home pages. However, if line 108 is thus changed, other changes are also necessary, because:

    1) is_page() (on line 109) also fires on a static home page, so if you’ve set the plugin to show on your home page, but not on other pages, then line 109 will conflict with line 108 and switch the plugin off; and

    2) (as now) there is no way to specify whether the plugin fires on a blog page that is not the home page.

    If lines 108 – 111 are changed as follows, it resolves: the bug; problem 1; and a partial fix for problem 2:

    $show = true;
    if (wp_is_mobile() && $this->settings['settings_show_on_mobile'] != 'mobile') $show = false;
    if (is_front_page() && $this->settings['settings_show_on_home'] != 'home') $show = false;
    if (is_page() && (!is_front_page()) && $this->settings['settings_show_on_pages'] != 'pages') $show = false;
    if (is_single() && $this->settings['settings_show_on_posts'] != 'posts') $show = false;
    if (is_home() && (!is_front_page()) && $this->settings['settings_show_on_posts'] != 'posts') $show = false;
    if (is_archive() && $this->settings['settings_show_on_archives'] != 'archives') $show = false;

    Notes on the “partial fix for problem 2”: There is an additional line for the non-homepage blog list setting (checking with is_home() && (!is_front_page()) ). I have assumed that if someone wants to show the plugin on the individual blog posts, then they will be fine with it showing on their non-homepage blog list page. This seems to be a reasonable assumption.

    Ideally another setting could be included for this on the plugin’s settings, but I’ve opted here for a minimalist approach — fixing the bug, without getting into a whole new load of work changing the customizer and settings.

    Hope this gives you enough info to fix the bug for the next festive season ??

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug: Home page option doesn’t work on Static Home Page’ is closed to new replies.