Subscribe via RSS

Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction - Albert Einstein

Make WP-PostViews Work with WP-Super-Cache

User ImageThaya Kareeson
Popularity: 27%
Updated: Apr 20, 2008

In response to JTPratt’s comment on my post, “Make Popularity Contest Work with WP-Super-Cache,” I am releasing a modification of Lester Chan’s WP-PostViews plugin to support counting using Javascript. Please try it out to see if this works for you.

A side note to Lester Chan and Richer Yang (WP-PostViews and WP-PostViews Plus authors repectively). Please feel free to contact me about incorporating these changes into WP-PostViews and/or WP-PostViews Plus so that it can be officially committed to the wp-plugins.org repository. I would create my own version of WP-PostViews in the repository, but do not want to steal your thunder :).

Download:
WP-PostViews JS Mod for WordPress 2.5

Note:
Modded Plugin only tested to work with WordPress 2.5 and is probably not backwards compatible with WordPress 2.3.3 or earlier versions.

Special Installation Instructions:
Intallation works the same way as the original WP-PostViews except that you will need to do ONE OF THE FOLLOWING:

  1. Place a symbolic link from wp-content/wp-postviews-js.php -> plugins/wp-postviews/wp-postviews-js.php
  2. Move wp-postviews-js.php directly under your wp-content/ directory

That should be all. I would really appreciate it if you can provide any feedback (security issues, better implementations, or other important thing that I’m totally not aware of). Also please feel free to email me with questions and keep me posted on how things are going with the plugin.

Rate this:
3.5

20 Responses to “Make WP-PostViews Work with WP-Super-Cache”

  1. no imageRosyidi (Check me out!) (3 comments)

    Thanks a lot.

    Rate this:
    3.2
  2. no imageThaya Kareeson (Check me out!) (45 comments)

    @Rosyidi
    You’re welcome! Please feel free to send me any questions or comments about this modification. And if you really like it, please write about it :-).
    Rate this:
    3.5
  3. no imageRosyidi (Check me out!) (3 comments)

    I stil don’t understand abut “Place a symbolic link”. What is symbolic means?
    Maybe I’ll repost this plugin on May 3.

    Rate this:
    3.2
  4. no imageThaya Kareeson (Check me out!) (45 comments)

    @Rosyidi

    You can find information about what symbolic links are at Wikipedia. Symbolic links are only available on a Unix/Linux environment. If you are hosting from a Windows machine, you can just move wp-postviews-js.php directly under your wp-content/ directory to achieve the same effect. Hope this helps.

    Rate this:
    3.5
  5. no imageJTPratt's Blogging Mistakes (Check me out!) (4 comments)

    I thank you for this fix - it worked GREAT on one of my sites! It didn’t (and may never) on my main site though, since I use 4 dozen odd plugins. I wonder, sezwho was one problem I had, as well as wp-postratings by lester chan.

    What happens with the WP-Stats plugin (wordpress.com official stats) when wp-super-cache is enabled? Are views of cached pages counted in your stats, or not?

  6. justfrank (1 comments)

    It works. And it works GREAT!
    Moving wp-postviews-js.php into wp-content was enough, no need to mess with symbolic links, for who doesn’t know how to do this ;)

  7. no imageThaya Kareeson (Check me out!) (45 comments)

    @JTPratt

    What is your main site? I’m not sure why it’s not working on your main site, but I believe the reason could be that the Javascript in this mod clashes with one of your other plugins’ Javascript. The mod I did here is supposed to work with any other cache plugin, but WP-Super-Cache is supposed to have a hook called “add_cacheaction” that can be used to add a count action. I’ll look into it to see if this method would work (and probably write a post about it if it does).

    @justfrank

    Thank you for visiting! I’m glad that the mod worked out for you.

  8. no imageThaya Kareeson (Check me out!) (45 comments)

    @JTPratt

    I forgot to answer the second part of your question. I’m pretty sure the WP-Stats plugin will not record hits if WP-Super-Cache is enabled. That said, I think it can also benefit from the method of using WP-Super-Cache’s add_cacheaction hook. I’ll explore this further and keep you posted on my findings.

  9. no imageJTPratt's Blogging Mistakes (Check me out!) (4 comments)

    My main site is http://www.jtpratt. Now, after 24 hours - my other site I thought everything was working on isn’t registering and counts on postviews at all. On the other hand, WP-Stats seems to be working fine ( so far )…

  10. no imageThaya Kareeson (Check me out!) (45 comments)

    @JTPratt

    Interesting, I will have to look into WP-Stats to see how it works. Thank you.

  11. no imagesylv3rblade (Check me out!) (3 comments)

    I can’t seem to make it work. Postviews doesn’t count even when Super Cache is off. Do you have a list of compatible plugins or at least those that have conflicts with this?

    Rate this:
    3.1
  12. no imageThaya Kareeson (Check me out!) (45 comments)

    @sylv3rblade

    Sorry I do not have a list of compatible/conflicting plugins. Please stay tuned, I will be releasing a non-javascript version soon (within the next day or two). Sorry for the delay!

    Rate this:
    3.5
  13. no imagesylv3rblade (Check me out!) (3 comments)

    Err no wait.. Scratch that. I forgot about the symbolic link. Umm… does shared hosting even support that? Can I use .htaccess?

    Rate this:
    3.1
  14. no imageThaya Kareeson (Check me out!) (45 comments)

    @sylv3rblade

    It depends on your shared host. I recommend just moving wp-postviews-js.php directly under your wp-content/ directory if your hosting does not support symbolic links.

    Rate this:
    3.5
  15. no imagesylv3rblade (Check me out!) (3 comments)

    Thanks. I got it working now. I think I screwed up the first time because I had a copy of wp-postviews-js.php on both the wp-content directory and the wp-postviews directory

    Thanks again.

    Rate this:
    3.1
  16. no imagehendra (Check me out!) (1 comments)

    Thanks a lot. Just advice to the others, if you activate this plugin, its better to you to delete the cache of wp-super-cache, after activating this plugin.

    Rate this:
    2.5
  17. no imageThaya Kareeson (Check me out!) (45 comments)

    @sylv3rblade

    I’m glad it works out for you.

    @hendra

    I’m glad it works out for you too, and thank you for your advice.

    Rate this:
    3.5
  18. no imageRosyidi (Check me out!) (3 comments)

    I will be releasing a non-javascript version soon

    @ Thaya : Than, it still work on wp super cache?

    Rate this:
    3.2
  19. no imageThaya Kareeson (Check me out!) (45 comments)

    @Rosyidi

    Yes, I will make use of WP-Super-Cache’s add_cacheaction hook to get WP-PostViews to count without Javascript while WP-Super-Cache is enabled. After evaluating the code, there is more work involved than I first thought, but it should be more efficient than the Javascript version when finished.

    Rate this:
    3.5
  20. no imageThaya Kareeson (Check me out!) (45 comments)

    @All

    Unfortunately, it turns out that I misunderstood the add_cacheaction hook. Previously, I thought that add_cacheaction hook gets called every time before a cached page is delivered. I was wrong and there currently is no such hook available in WP-Super-Cache right now. I will definitely make a request to Donncha to add this to WP-Super-Cache. So as it stands, you are stuck with the JS Mod version of WP-PostViews.

    I have to appologize for getting your hopes up. The WP-Super-Cache code is quite complex (if Donncha doesn’t walk you through it :)), so it took me a while to figure this out.

    Rate this:
    3.5

Leave a Reply