Home > archives > コメント/トラックバック本文をインデントするHook

コメント/トラックバック本文をインデントするHook

エントリー本文をインデントするHookを応用して(まるっとコピペして)できあがりー。

/**
 * コメント本文にインデントを付加します。
 */
function indent_comment_body($content) {
    // インデント数 (dl.log dd p から見て)
    $indent = '7';

    if ($indent != '') {
        $indent = (int) $indent;

        for ($i = 0; $i < $indent; $i ++)
            $indentText .= "\\t";
    } else {
        $indentText = "\\t\\t\\t\\t\\t";
    }

    $pre_flag = false;
    $arr_content = split("\\n", $content);

    foreach ($arr_content as $line) {
        if(!$pre_flag) {
            if (strpos($line, "<pre") !== false)
                $pre_flag = true;

            $mes .= $indentText . $line . "\\n";
        }
        else {
            if (strpos($line, "</pre>") !== false)
                $pre_flag = false;

            $mes .= $line . "\\n";
        }
    }

    return rtrim($mes) . "\\n";
}

add_filter('comment_text', indent_comment_body, 100);

上記コードを、functions.phpのどこかにコピペすればOK!!

Comments:0

Comment Form
Remember personal info

Trackbacks:0

Trackback URL for this entry
http://miniturbo.org/2007/04/03/140157/trackback/
Listed below are links to weblogs that reference
コメント/トラックバック本文をインデントするHook from miniturbo.org

Home > archives > コメント/トラックバック本文をインデントするHook

Search

Return to page top