本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 . y/ {5 x& r0 S* y7 L# ~
! D$ P2 W, R4 f7 R. P9 I
換其它WP的版本也還是這樣,9 K% Y+ | D' p/ a- m
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。
$ @. z9 y/ Q( _9 R, L% V3 @* G. H' t看代碼似乎都沒什麼問題,
% E" d% v* N# Z其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
4 s' ?. W/ P' N: `$ `7 G7 m - $anchor_level = 0;
8 ?& W1 {% e' T7 G( @- G - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {* U: K2 `: }" q( s1 A! s: `
- $i = 0;
& {& ^) ~3 h5 d, h1 m$ I5 D) g/ n) b - foreach ($tokens as $token) {3 u7 w, W" G+ c/ D$ ?
- if (++$i % 2 && $token != '') { // this token is (non-markup) text
6 S7 t% @6 M) k" ]# l: L( n$ W - if ($anchor_level == 0) { // linkify if not inside anchor tags
; U( t9 \6 D7 `) h0 T4 N, G/ S. n - if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4
( x r1 \" {% u* z5 b - $j++;( w# j5 M) G, A5 w8 o
- 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 !
( k" E$ T- L: ]) n( L - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments7 Q9 L( o; H: b {/ Z+ e2 K
- }' B, N: S. ], R) `! i" @9 e
- $must_tokenize = true; // re-tokenize next time around
1 i, I" c6 D- J v# W, l - }
4 c( B' j: j% S/ p - }
1 q: z) T% G$ ]) S - } else { // this token is markup
' A& z& ^" C- g2 W# ?* r8 @2 s - if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>9 n* \) [! k9 h7 i
- $anchor_level++;" r$ @: x9 l: ]
- } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
& ?% D6 y: Q, ] - $anchor_level--;0 q7 N5 M2 \& a8 R( F1 k9 ^
- }9 k. ~ v: K; f' ~3 \/ i
- }
; {$ D$ t* m% J, J) R0 t - $filtered .= $token; // this token has now been filtered- _5 D# L# \) t* {4 J1 d" P
- }. ~: ?4 u9 }) o; H6 B
- $content = $filtered; // filtering completed for this link
- n i% O' |: i" k0 h, I - }
複製代碼
; ]0 _7 A9 x1 ?8 c& M" T% _4 H$ X
; A8 w n. Q* n4 V
. `5 V( ~- D" |3 b9 ^ X# @2 x |