本帖最後由 jeffseo 於 2013-12-6 19:33 編輯
4 h) U/ s. ?# N) o! \! p6 O0 @; H: N3 e
換其它WP的版本也還是這樣,3 C3 a3 O7 J s# y
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。! l$ g- z$ _) V- h
看代碼似乎都沒什麼問題, K% _4 `5 Z" J5 W
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case1 @5 M4 R# t# }, Z
- $anchor_level = 0;( A% b5 b6 @/ \$ l( b
- if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {7 }0 v6 @4 S. ^. \1 Q
- $i = 0;
5 F: K; Y3 O# R! L9 {8 b. p - foreach ($tokens as $token) {
# o9 y$ [- d! F# E* z% |, L _4 n - if (++$i % 2 && $token != '') { // this token is (non-markup) text
; i; D5 ]' ]0 P& V" v% \: s - if ($anchor_level == 0) { // linkify if not inside anchor tags5 x* o' H5 m& I. Y
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4# Z% M4 O. h) R) X3 z. W
- $j++;7 U% N/ @! e# Q" Y: V& n; s
- if ($j <= SimpleTags_Plugin::get_option_value('auto_link_max_by_tag') || SimpleTags_Plugin::get_option_value('auto_link_max_by_tag') == 0) {// Limit replacement at 1 by default, or options value !+ R. `" P( p5 L
- $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
5 N- E; [+ H8 z0 ~9 X" |2 E! j/ k1 l - }
" Z, f( X0 i8 `9 B( t1 W2 A* }2 S - $must_tokenize = true; // re-tokenize next time around1 O3 T1 z& j5 s- Q1 U* n# k1 D
- }( V. h! I/ j6 c0 l$ v1 I
- }
" A( ?, W5 ?( Q2 d* N$ n; M/ J4 Y - } else { // this token is markup% Q/ n M. u- m" W$ Z5 S
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>$ y5 N& m3 r W# m7 J( p
- $anchor_level++;+ U1 L7 B% [8 I( l8 q7 I
- } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
4 h0 w/ u% C/ ]8 v- i, i - $anchor_level--;4 ^ t' K8 s1 L
- }8 [, B8 m' Y0 u& Z& `/ \
- }* j! \% t p3 h
- $filtered .= $token; // this token has now been filtered9 v5 B" L3 U/ L/ R" w
- }5 n; C4 P3 w3 @% L5 M5 x
- $content = $filtered; // filtering completed for this link" J, c2 _. ~! @1 n4 {$ n
- }
複製代碼
$ k; d- }' f& B! Y9 |/ d. h
& B8 W r1 U* I) T) @8 _1 _4 S# ]$ o. H
|