• Resolved DrLightman

    (@drlightman)


    Hello, I’m still using an old modded by me version of this plugin which was the best for pop.posts imho and probably still is.

    One modification I made and maybe you want to consider implementing was to use the SHORTINIT constant in the ajax call made to update the view counter. That constant is used by WordPress to reduce the high load of an ordinary wp-load.

    In a site of mine I was using wp-super-cache to reduce server load but the effort was almost obliterated by the ajax calls that are not cached for obvious reasons.

    Using a separate php file wpp-fast-ajax.php in the plugin directory for the ajax call like:

    ini_set(‘html_errors’, 0);
    define( ‘SHORTINIT’, true );
    require_once dirname( __FILE__ ) . ‘/../../../wp-load.php’;

    function wpp_update( )
    {
    global $wpdb;
    ….
    }
    wpp_update( );

    helped a lot.

    https://www.ads-software.com/plugins/wordpress-popular-posts/

Viewing 1 replies (of 1 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Nice finding! I wasn’t aware of this feature. However, what worries me about it is this:

    @INT mantain SHORTINIT is hard. You have to load all the thing you need, and all the things needed by the things that you need, and so on… Also, you need to check everithing works on every WordPress (major) update, because sometimes functions are moved from file to file (e.g. when deprecated, but not only in that case) and you can get fatal errors when before update everithing was fine. For same reason code may not work with older versions. Be careful with it and, just a tip, avoid to use it in plugin/themes to be shared or sold. Also, be sure to test your code with WP_DEBUG turned on.

    By G. M. at WordPress Development Stack Exchange.

    While I’m sure that it does improves a lot the AJAX response times, maintaining it across multiple WordPress versions -as M. G. says- could turn into a real nightmare for me.

    I’ll investigate more about it. With some luck, I may find a way to make it work without having to resort to ugly hacks.

    Nonetheless, thank you for sharing this. I really appreciate it!

Viewing 1 replies (of 1 total)
  • The topic ‘SHORTINIT for fast ajax’ is closed to new replies.