因應 2.0 , 再修 Twilight AutoSave

2005 December 30

升級 2.0 以後, 我發現 Twilight AutoSave 沒辦法用了.
( ychsiao 前輩也有在 這篇 說他的也不能用. XD )

目前在 plugin 的網頁是貼出了這段:

Please note: I offer no support for this plugin with WP 2.0 as of yet. The software is still beta, and works completely differently. I will see how I can upgrade this to work with 2.0 when I can (if it is possible).

於是我自己 trace 了一下 code , 發現問題出在這幾行 :
add_action("save_post", "twAutoSaveDelete");
add_action(”publish_post”, “twAutoSaveDelete”);

save_post 跟 publish_post 僅存在於 1.5 版的 wp-admin/post.php 中, 2.0 版被拿掉了.
所以必須把上面那兩行改成 :
add_action("simple_edit_form", "twAutoSaveDelete");
add_action(”edit_form_advanced”, “twAutoSaveDelete”);
add_action(”edit_page_form”, “twAutoSaveDelete”);

另外, 我還看到一個小瑕疵, 在 tw-autosave.php 裡面有這段:
if (cookietemp.length > 100){
var endstring = “[…]”;
}

可是 endstring 這個變數也沒有事先被定義, 而且這段 code 並沒有做例外處理, 所以當文章內容小於 100 字時, 我們會在文章回復框看到 undefined 的字串.
解法很簡單, 在 if (cookietemp.length > 100){ 上面加入這行就搞定了 :
var endstring = "";

目前改完以後看來都正常.
晚點把這些回報給作者, 跟他討論看看好了. :cool:

Comments »

The URI to TrackBack this entry is: http://joehorn.blogsome.com/2005/12/30/%e5%9b%a0%e6%87%89-20-%e5%86%8d%e4%bf%ae-twilight-autosave/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>