19 Jan 2006

K2 patch for WP lightbox JS plugin

In the spirit of a better K2 community I bring you K2 WP lightbox JS plugin patch based on K2 revision 163. Known to be working on any version of K2 r163 and below.

Remember this is a hack and not a solution. The code is dirty and need to be clean. Help are welcome. Just like William Hung said, I have no professional training. By applying this patch, I take no responsibility if anything bad happen to your theme. Always remember to backup first!

The K2 WP lightbox JS plugin patch include :

  • Fix conflict between liveSearchInit and HideUtils window.onload event in single entry view. As a result initLightbox kickstart perfectly.
  • Remove unnessary HideUtils event for logged in user. The reason is even the field is visible, the data saved in the commentator field cannot be changed.
  • Relocate HideUtils for authorinfo to header.
  • Remove commentator Name, Email and URL text area if user is logged in.
  • Re-write LiveSearch SCRIPT element.
  • Remove unnessary <?php trackback_rdf(); ?> in HEAD. I kept wondering why it was there in the first place.
  • Add few more additional condition to LiveSearch, LiveComment, hideUtils to avoid calling un-used script.
  • Add additional condition to ajax_comment.js (k2bugs ticket ID#0000193)
  • Increase window.setTimeout for liveSearchDoSearch(). Modified especially for fast typer (Binary Blue theme).
  • Add a headers for cache-control and file type for browser to livesearch.js.php.

How to apply the patch?

  1. First, there are 3 K2 file you need to BACKUP; comments.php, livesearch.js.php and header.php.
  2. Download and save the patch inside your k2 folder.
  3. In your shell, apply the patch using patch -p0 < k2r163_wp-lightboxJS_patch.diff
  4. You can also download the modified K2 r163 with lightbox JS (changes file only) if you are unfimiliar with diff and patch. The files are based on default K2 theme rev163.

So what are you waiting for, go apply the patch and download WP lightbox JS plugin.

UPDATE: Fix some few more glitches.