| 35 | | // 바람님(http://windlike.net)과 태영님(http://mytears.org)이 작성하신 내용. |
| 36 | | // is_utf8 대신에 워드프레스에 포함된 seems_utf8 함수를 이용했습니다. |
| 37 | | function korean_trackback_post( $insert_id ) { |
| 38 | | global $_POST; |
| 39 | | |
| 40 | | // 블로그에서 EUC-KR을 사용중이라면 그냥 워드프레스 함수를 사용해도 됨. |
| 41 | | if ('EUC-KR' == strtoupper(get_option('blog_charset'))) |
| | 35 | // 바람님의 트랙백 패치(http://www.windlike.net/blog/279/)를 응용해서 만들었습니다. |
| | 36 | function korean_trackback_pre() { |
| | 37 | if ( 'EUC-KR' == strtoupper(get_option('blog_charset')) ) |
| | 38 | return; |
| | 39 | if ( is_robots() || is_feed() || !is_trackback() ) |
| 49 | | // $tb_url = remove_accents($tb_url); |
| 50 | | if (seems_utf8($tb_url)) {// fix url from tistory |
| 51 | | if (function_exists('mb_strtolower')) { |
| 52 | | $tb_url = mb_strtolower($tb_url, 'UTF-8'); |
| 53 | | } |
| 54 | | $tb_url = utf8_uri_encode($tb_url); |
| | 49 | if ( !$_POST['charset'] ) |
| | 50 | $_POST['charset'] = 'ASCII, UTF-8, EUC-KR, ISO-8859-1, JIS, EUC-JP, SJIS'; |
| | 51 | |
| | 52 | // mbstring 을 지원하지 않고 iconv 만 지원하는 서버를 위한 내용 |
| | 53 | if ( !function_exists('mb_convert_encoding') && function_exists('iconv') ) { |
| | 54 | // These three are stripslashed here so that they can be properly escaped after iconv() |
| | 55 | $_POST['title'] = stripslashes($_POST['title']); |
| | 56 | $_POST['excerpt'] = stripslashes($_POST['excerpt']); |
| | 57 | $_POST['blog_name'] = stripslashes($_POST['blog_name']); |
| | 58 | $charset = 'EUC-KR'; |
| | 59 | if ( !seems_utf8($_POST['title']) ) |
| | 60 | $_POST['title'] = iconv($charset, 'UTF-8', $_POST['title']); |
| | 61 | if ( !seems_utf8($_POST['excerpt']) ) |
| | 62 | $_POST['excerpt'] = iconv($charset, 'UTF-8', $_POST['excerpt']); |
| | 63 | if ( !seems_utf8($_POST['blog_name']) ) |
| | 64 | $_POST['blog_name'] = iconv($charset, 'UTF-8', $_POST['blog_name']); |
| | 65 | // addslashes again. |
| | 66 | $_POST['title'] = addslashes($_POST['title']); |
| | 67 | $_POST['excerpt'] = addslashes($_POST['excerpt']); |
| | 68 | $_POST['blog_name'] = addslashes($_POST['blog_name']); |
| 56 | | |
| 57 | | if ($_POST['charset']) |
| 58 | | $charset = strtoupper( trim($_POST['charset']) ); |
| 59 | | else |
| 60 | | $charset = 'UTF-8, EUC-KR, ISO-8859-1, JIS, EUC-JP, SJIS';// just added EUC-KR right after UTF-8 |
| 61 | | |
| 62 | | // For international trackbacks |
| 63 | | if ( function_exists('mb_convert_encoding') ) {// recommended |
| 64 | | $title = mb_convert_encoding($title, get_option('blog_charset'), $charset); |
| 65 | | $excerpt = mb_convert_encoding($excerpt, get_option('blog_charset'), $charset); |
| 66 | | $blog_name = mb_convert_encoding($blog_name, get_option('blog_charset'), $charset); |
| 67 | | } else if ( function_exists('iconv') ) { |
| 68 | | $charset = 'EUC-KR'; |
| 69 | | |
| 70 | | if ( !seems_utf8($title) ) |
| 71 | | $title = iconv($charset, 'UTF-8', $title); |
| 72 | | if ( !seems_utf8($excerpt) ) |
| 73 | | $excerpt = iconv($charset, 'UTF-8', $excerpt); |
| 74 | | if ( !seems_utf8($blog_name) ) |
| 75 | | $blog_name = iconv($charset, 'UTF-8', $blog_name); |
| 76 | | } else |
| 77 | | return; |
| 78 | | |
| 79 | | $comment_ID = $insert_id; |
| 80 | | $comment_author = $blog_name; |
| 81 | | $comment_content = "<strong>$title</strong>\n\n$excerpt..."; |
| 82 | | $comment_author_url = $tb_url; |
| 83 | | |
| 84 | | $commentdata = compact('comment_ID', 'comment_author', 'comment_content', 'comment_author_url' ); |
| 85 | | |
| 86 | | wp_update_comment($commentdata); |