Nov 05

剛剛把這邊升級成 WordPress 2.3.1 。

因為 WordPress 2.3 開始支援 tag ,所以之前使用的 Ultimate Tag Warrior 被我拔掉了。
(其實是... 要先拔掉才能升級... 不然會有 function redeclare 的 error 。 XD

在拔掉 Ultimate Tag Warrior 之前,我在網路上嘗試尋找把原本的 tag 轉移到 WordPress 2.3 內建的 tag 功能的作法。

我找到了 這篇,不過升級後我就發現管理平台的 Manage -> Import 中就有搬移的功能! :cool:

接著要修改 theme ,增加 tag 與 tag cloud 顯示的語法。
很快地,我發現在我用的 theme 裡面增加的 the_tags() 只能在多篇文章顯示時運作正常,瀏覽單篇文章時都看不到。
如果有人也有遇到相同問題的話,請修改 wp-includes/category-template.php ,把 function get_the_tags( $id = 0 ) 中的這段:

        $id = (int) $id;

        if ( ! $id && ! in_the_loop() )
                return false; // in-the-loop function

        if ( !$id )
                $id = (int) $post->ID;

改成

        $id = (int) $id;
/*
        if ( ! $id && ! in_the_loop() )
                return false; // in-the-loop function
*/
        if ( !$id )
                $id = (int) $post->ID;

應該就能解決了。

升級完 WordPress 2.3.1 的話可以檢查目錄下的檔案,以下這些是不需要的,可以砍掉。

  • wp-admin/admin-db.php
  • wp-admin/cat.js
  • wp-admin/categories.js
  • wp-admin/custom-fields.js
  • wp-admin/dbx-admin-key.js
  • wp-admin/edit-comments.js
  • wp-admin/install-rtl.css
  • wp-admin/install.css
  • wp-admin/upgrade-schema.php
  • wp-admin/upload-functions.php
  • wp-admin/upload-rtl.css
  • wp-admin/upload.css
  • wp-admin/upload.js
  • wp-admin/users.js
  • wp-admin/widgets-rtl.css
  • wp-admin/widgets.css
  • wp-admin/xfn.js
  • wp-includes/js/tinymce/license.html

另外,新版的 WordPress 後台會顯示 plugin 有沒有新的版本啦! :eek:

Technorati Tags: ,

Tags: ,
(Visited 1292 times)
Jan 25

我應該算是比較懶惰的人吧,因為我用覆蓋法。 :oops:

因為有 ssh login 的權限,所以我這邊步驟是這樣( 舊版的放置目錄是 ~/blog ):

  1. 官方網站的下載頁面 抓新版檔案,放在家目錄( ~/latest.tar.gz )。
  2. 新版(2.1)解壓縮( cd ~ && tar xvfz latest.tar.gz )。
  3. 看看有啥檔案是新版拿掉的( diff -rc ~/blog ~/wordpress | grep "Only in blog" )。
  4. 除了自己放的檔案、theme、plugin、設定檔以外的檔案都砍了。
  5. 砍掉 ~/wordpress ( rm -rf ~/wordpress )。
  6. 用新版蓋掉舊版 ( cd ~ && mv blog wordpress && tar xvfz latest.tar.gz && mv wordpress blog )。
  7. 用瀏覽器開 wp-admin/upgrade.php 。

改過 wp-includes/wp-db.php 就收工了。 XD

原本我這邊跑的是 2.0.6 ,在 2.1 裡面應該殺掉的檔案有這些:

  • wp-admin/edit-form-ajax-cat.php
  • wp-admin/execute-pings.php
  • wp-admin/inline-uploading.php
  • wp-admin/link-categories.php
  • wp-admin/list-manipulation.js
  • wp-admin/list-manipulation.php
  • wp-includes/comment-functions.php
  • wp-includes/feed-functions.php
  • wp-includes/functions-compat.php
  • wp-includes/functions-formatting.php
  • wp-includes/functions-post.php
  • wp-includes/js/dbx-key.js
  • wp-includes/js/tinymce/plugins/autosave/langs/cs.js
  • wp-includes/js/tinymce/plugins/autosave/langs/sv.js
  • wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js
  • wp-includes/js/tinymce/plugins/inlinepopups/readme.txt
  • wp-includes/js/tinymce/themes/advanced/editor_template_src.js
  • wp-includes/links.php
  • wp-includes/pluggable-functions.php
  • wp-includes/template-functions-author.php
  • wp-includes/template-functions-category.php
  • wp-includes/template-functions-general.php
  • wp-includes/template-functions-links.php
  • wp-includes/template-functions-post.php
  • wp-includes/wp-l10n.php

給大家參考看看。:cool:

另外,之前 的 Twilight AutoSave 可以關掉並刪除了。 ;-)

Technorati Tags:

Tags:
(Visited 2655 times)
May 27

剛剛在網路上亂晃晃到的, 蠻有趣的東西.

sidebar 跟 comment 區塊可以隨心所欲的讓使用者移動還蠻有趣的.
可惜... 這個 plugin 似乎只能搭配 K2 使用. :(

Technorati Tags: , ,

Tags: , ,
(Visited 3922 times)
Jan 01

這兩天在 shakalaca 長輩跟 DK 大長輩的個人板上都看到 K2 這個名詞, 所以很好奇的去看了一下是什麼東西.

原來 K2 是套 WordPress 用的 theme .
如果要我說出改用 K2 的動機的話, 應該是因為這套 theme 用了 AJAX ( Asynchronous JavaScript and XML ) 來做使用者留言功能.
可是我不想在剛換 theme 之後馬上再換一次, 所以找了一下相關資源. :oops:

我發現到, 除了 K2 以外, Squible 這套 theme 也有用 AJAX comment .
而且我在 這篇 看到有人把 AJAX comment 從 K2 抽出來, 用 step-by-step 的方式教大家換.
另外附上一些參考網頁 :

因為步驟不算簡單, 而且照原文的說法看來, 可能會有些風險, 所以我就不用中文解釋了, 有興趣的自己看看吧. :wink:

我這邊在更改時沒有遇到麻煩, 不過我有先把整個目錄先壓縮備份. XD
如果想知道效果如何的話, 可以在這篇隨便留個 comment 就知道了. :cool:

題外話, K2 的網站/網路似乎很詭異, 我有時連的上, 有時連不上. :roll:

Technorati Tags: , ,

Tags: , ,
(Visited 8475 times)
Dec 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:

Technorati Tags: ,

Tags: ,
(Visited 7716 times)
Dec 30

升級 2.0 以後, 我發現 Recent Comments 的選項頁面出不來. :???:

於是, 拜 估狗大神 所賜, 我找到了 這頁 .

我按照文章裡面的說明修改 wp-content/plugins/get-recent-comments.php , 在這行:

// WordPress 1.5 includes this file again on the options page. Avoid duplicate declaration:

下面有段:

if ( function_exists("is_plugin_page") && is_plugin_page() ) {
        kjgrc_options_page();
        return;
}

然後把整段整個換成 :

add_action("options_page_get-recent-comments", "kjgrc_options_page" );

就好了. :cool:

Technorati Tags: ,

Tags: ,
(Visited 7685 times)
Sep 11

剛剛 Solaris 叔叔 跟我說他的 Blog 消失了.

找了一下問題之後發現這串 log :

[Sun Sep 11 19:40:49 2005] [error] [client 59.104.45.15] PHP Fatal error: Only variables can be passed by reference in ###/wp-includes/gettext.php on line 66

我針對這段作了小修改 , 原先的這段 code :

return array_shift(unpack("V", $this->STREAM->read(4)));

改成這樣就恢復正常了 :

$read_int_tmp = unpack("V", $this->STREAM->read(4));
return array_shift($read_int_tmp);

因為昨天晚上我把 PHP 從 5.0.4 升級到 5.0.5 , 所以這應該是 5.0.5 才會遇到的問題吧!? :shock:

更詭異的是, 我這邊跟 R 董那邊 都沒發生這個問題.
( 所以應該說是 Solaris 叔叔 帶賽? :cool: )

Technorati Tags: ,

Tags: ,
(Visited 4775 times)
Jul 04

之前我在 WordPress 外掛 - 酷比搜尋 這篇所發佈的版本為 0.2 版.

因為 酷比搜尋 的 nicole 留的 comment 提到了一個之前我沒加入的功能, 所以剛剛又進行改寫.

不過我沒有特別寫在 Blog 上, 而是另外產生 WordPress Plugin - 酷比搜尋 這個頁面, 以備將來的版本更新 .

anyway, 目前版本是 0.4 , 有興趣的可以看看, 以後該頁有更新我也會丟 Blog 出來.

Technorati Tags: ,

Tags: ,
(Visited 3344 times)
Jun 14

我們常用的傳統搜尋引擎只允許我們輸入字詞, 或是一行句子.
這種以文找文的搜尋系統則可以讓我們輸入一個文章段落, 甚至是一整篇文章的內容.

理論上, 這種系統的搜尋演算法寫的好, 或是訓練樣本數夠多的話.
這種系統產生出來的搜尋結果準確度會比傳統的系統還要高.
這種系統的搜尋準確度會呈現兩極化, 準的話就很準, 不準的話就... orz
而且, 結果也跟使用者所選取的段落內容有關.

之前我先是在 ijliao 長輩那 看到 Y!Q search 這種以文找文的搜尋系統.

接下來, 國外也有人寫出了 WordPress 的 plugin , 叫做 Y!Q Lookup , 於是我也在我這邊加進了這個外掛.

我在試用過後發現, Y!Q search 似乎只接受英文字母, 而其產生的結果幾乎都是國外網頁, 所以我也一直想找看看有沒有國內的搜尋引擎也提供以文找文的搜尋介面.

原本我以為 Yahoo!奇摩 會是第一個提供這種系統的廠商, 但是我猜錯了... XD
我在 無名 的 Blog 系統找到了國內第一個提供以文找文的搜尋系統, 名為 Scupio! ( 中文名稱為酷比 ) .

於是我參考了 Y!Q Lookup , 生出了酷比搜尋這個 WordPress 的 plugin .

這個 plugin 提供了兩種搜尋框.
橫幅搜尋框 - 適用於文章內容

方塊搜尋框 - 適用於 sidebar

如果您有興趣使用的話, 請先下載 這個檔案 .
然後將解壓縮出來的 wp-scupio.php 放進 wp-content/plugins , 並啟動這個外掛.

要顯示出搜尋框的方式很簡單.
橫幅搜尋框的產生用 doScupioBar 這個 function , 方塊搜尋框的產生用 doScupioBox 這個 function .

如果您的 WordPress 有開啟 excerpt , 而且確定該段落支援的話.
您可以用這行語法來產生橫幅搜尋框 :

<?php doScupioBar(1); ?>

或是用這行語法來產生方塊搜尋框 :

<?php doScupioBox(1); ?>

這樣會讓搜尋框裡面輸入文字的地方先產生出文章的標題.

如果沒有的話, 可以直接丟這行來產生橫幅搜尋框 :

<?php doScupioBar(); ?>

或是丟這行語法來產生方塊搜尋框 :

<?php doScupioBox(); ?>

anyway, 有使用上的問題或是任何建議與批評, 麻煩在這篇丟個 comment , 或是直接 mail 給我.
當然, 捶背 ( trackback ) 也行. XD

Technorati Tags: ,

Tags: ,
(Visited 7503 times)
May 31

剛剛我發現我這裡的 calendar 已經跳到 6 月, 像這樣 :
WP Calendar error

於是去看了 , 也都有這個問題.

看過程式之後, 果然是 gmt_offset 所產生的問題.

因為在 wp-includes/functions.php 中的 current_time 這個 function 提供了兩種格式: mysql 跟 timestamp .
而 mysql 的格式用了 gmdate , 所以加上 gmt_offset 之後是沒問題的.
timestamp 卻因為使用了 time , 所以再加上 gmt_offset 之後會出現異常.
因為我發現只有 calendar 出問題, 所以我只改了 wp-includes/template-functions-general.php 這個檔案, 沒有修改 current_time 這個 function .

如果您的站台的 calendar 也有相同問題的話, 請修改 wp-includes/template-functions-general.php , 把原先這兩行註解掉:

$thisyear = gmdate("Y", current_time("timestamp") + get_settings("gmt_offset") * 3600);
$thismonth = gmdate("m", current_time("timestamp") + get_settings("gmt_offset") * 3600);

加進這兩行 :

$thisyear = gmdate("Y", current_time("timestamp"));
$thismonth = gmdate("m", current_time("timestamp"));

也就是變成這樣 :

//        $thisyear = gmdate("Y", current_time("timestamp") + get_settings("gmt_offset") * 3600);
//        $thismonth = gmdate("m", current_time("timestamp") + get_settings("gmt_offset") * 3600);
$thisyear = gmdate("Y", current_time("timestamp"));
$thismonth = gmdate("m", current_time("timestamp"));

如果您有 shell login 權限的話, 可以到您的 WordPress 主目錄, 然後抓取 這個檔案 後用這個指令做修正 :

patch < template-functions-general.diff.txt

Technorati Tags: ,

Tags: ,
(Visited 6345 times)