• pogle

    (@pogle)


    So when I have the ‘show preloader immediately’ box checked with ‘show preloader on all pages’ set, when I click on a specific link, it indeed loads instantly which is what I want. However I only really need this preloader set for one specific page, when I enter the page id in the custom field, and then I click on the link, it waits a few seconds (~5-7) before the preloader starts. I see your note that says the ‘show preloader immediatly’ only works when it’s set to all pages. But I wonder why this is the case or if it’s possible in any way to make it work for just a specific link or button to show the preloader immediately? It’s difficult for me to share the specific link because its set for registered specific user roles.

    Specifically i’d like this to work instantly when I click on a button or link directly in the user account section, and a link to the same page on the top dropdown menu. It works on all pages, but I only really need it for specific pages.

    Any suggestions?

    • This topic was modified 2 years ago by pogle.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Thien Nguyen

    (@tatthiennguyen)

    Hi @pogle

    Technically, I use regex to detects which links should be applied to “show preloader immediately”.

    I think I should place a filter hook in order to allow developers to add their custom regex.

    Plugin Author Thien Nguyen

    (@tatthiennguyen)

    Hi @pogle

    I’ve just released v1.16.0 which has some custom filter hooks. I hope it works in your case.

    1. Set option “Show preloader immediately” is always true, no matter what is the value of the option “Show preloader on

    add_filter('flat_preloader_show_preloader_instantly', function() {
      return true;
    });

    2. Add the links that you don’t want to apply instantly loading.

    For instance: I don’t want to show preloader instantly when clicking on the page /sample-page

    add_filter('flat_preloader_ignore_links', function($links) {
      array_push($links, '^' . preg_quote( site_url(), '/' ) . '\\/sample-page');
      return $links;
    });
    Thread Starter pogle

    (@pogle)

    Hi Thien,

    I updated the plugin to 1.16 but didn’t see an option to add the pages I want to ignore? https://snipboard.io/tPCIhy.jpg am I missing something?

    Plugin Author Thien Nguyen

    (@tatthiennguyen)

    Hi @pogle

    For some reason, WordPress is moderating my comment, that’s why you cannot see it I think.

    The latest version allows you to modify the behavior through custom code.

    Here is the code in the screenshot below:

    add_filter('flat_preloader_show_preloader_instantly', function() {
      return true;
    });
    
    add_filter('flat_preloader_ignore_links', function($links) {
      array_push($links, '^' . preg_quote( site_url(), '/' ) . '\\/sample-page');
      return $links;
    });
    Thread Starter pogle

    (@pogle)

    ah ok, well I’m not as familiar with coding, I can probably do it, but can you say where I should add this code?

    Plugin Author Thien Nguyen

    (@tatthiennguyen)

    Hi @pogle

    This tutorial from wpbeginner is really good to start adding custom code to your WordPress site.

    https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/

    Let me know if you need further help.

    Thread Starter pogle

    (@pogle)

    ok i’ll try adding via the plugin in the link that you provided, is this .php code?

    Thread Starter pogle

    (@pogle)

    also could you put some sample code of what excluding multiple links including the home page might look like? would it be like ‘\\/pageA’,\\/pageB’,\\/pageC’ ? and if my homepage is just http://www.website.com, how would that look in your exmaple? would it just be / ?

    and I don’t need to add my actual website url to ‘site_url() do I?

    add_filter(‘flat_preloader_ignore_links’, function($links) { array_push($links, ‘^’ . preg_quote( site_url(), ‘/’ ) . ‘\\/sample-page‘); return $links; });

    sorry for the questions!

    • This reply was modified 2 years ago by pogle.
    Plugin Author Thien Nguyen

    (@tatthiennguyen)

    Hi @pogle

    Here is the regex that matches the url: https://www.website.com and https://website.com (Check the result here: https://regex101.com/r/SctrEo/1)

    ^https:\/\/(?:www)?(?:.?)website.com$

    The filter will look like:

    add_filter('flat_preloader_ignore_links', function($links) {
      array_push($links, '^https:\\/\\/(?:www)(?:.?)website.com$');
      return $links;
    });
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Preloader icon takes a handful of seconds to start’ is closed to new replies.