Changeset 391
- Timestamp:
- 07/31/08 10:57:55 (5 months ago)
- Files:
-
- 1 modified
-
euckr-trackback/trunk/euckr-trackback.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
euckr-trackback/trunk/euckr-trackback.php
r390 r391 7 7 Description: EUC-KR로 운영되는 블로그와의 트랙백 송수신 문제를 해결합니다. 8 8 9 Version: 0.3 9 Version: 0.31 10 10 11 11 Author: Choen, Youngmin … … 32 32 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 33 */ 34 if ( !function_exists('mb_convert_encoding') && !function_exists('iconv') ) { 35 function korean_trackback_admin_notice() { 36 echo '<div class="error fade"><p>EUC-KR Trackback 플러그인을 사용할 수 없습니다. 현재 서버에 필요한 모듈(mbstring 또는 iconv)이 설치되지 않았습니다. 서버관리지에게 해당모듈(mbstring 권장)의 지원을 요청해 보시기 바랍니다.</p></div>'; 37 } 38 add_action('admin_notices', 'korean_trackback_admin_notice'); 39 return;// 더이상 플러그인 내용을 읽어들이지 않고 마칩니다. 40 } 34 41 35 42 // 바람님의 트랙백 패치(http://www.windlike.net/blog/279/)를 응용해서 만들었습니다. … … 157 164 // 기왕이면 if (function_exists('trackback_kr')) 을 사용해주는게 좋습니다. 158 165 function trackback_kr($url, $title, $excerpt, $id) { 159 // 블로그에서 EUC-KR을 사용중이라면 그냥 워드프레스 함수를 사용해도 됨.160 166 if ('EUC-KR' == strtoupper(get_option('blog_charset'))) 161 167 return trackback($url, $title, $excerpt, $id); … … 177 183 } else { 178 184 foreach ($euckr_blogs as $blog) { 179 if ( strpos($url, $blog) !== false) {185 if (!empty($blog) && strpos($url, $blog) !== false) { 180 186 $tokr = true; 181 187 break; … … 196 202 } 197 203 endif; 204 205 // iconv 만 설치된 서버를 위해 워드프레스 2.6에 포함된 함수들을 빌려왔습니다. 206 if ( ! function_exists('wp_html_excerpt') ): 207 208 function wp_html_excerpt( $str, $count ) { 209 $str = strip_tags( $str ); 210 $str = mb_strcut( $str, 0, $count ); 211 // remove part of an entity at the end 212 $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str ); 213 return $str; 214 } 215 216 if ( ! function_exists('mb_strcut') ): 217 function mb_strcut( $str, $start, $length=null, $encoding=null ) { 218 return _mb_strcut($str, $start, $length, $encoding); 219 } 220 endif; 221 222 if ( ! function_exists('_mb_strcut') ): 223 function _mb_strcut( $str, $start, $length=null, $encoding=null ) { 224 // the solution below, works only for utf-8, so in case of a different 225 // charset, just use built-in substr 226 $charset = get_option( 'blog_charset' ); 227 if ( !in_array( $charset, array('utf8', 'utf-8', 'UTF8', 'UTF-8') ) ) { 228 return is_null( $length )? substr( $str, $start ) : substr( $str, $start, $length); 229 } 230 // use the regex unicode support to separate the UTF-8 characters into an array 231 preg_match_all( '/./us', $str, $match ); 232 $chars = is_null( $length )? array_slice( $match[0], $start ) : array_slice( $match[0], $start, $length ); 233 return implode( '', $chars ); 234 } 235 endif; 236 237 endif; 198 238 ?>
