本帖最後由 jeffseo 於 2013-12-6 19:33 編輯
7 L! d- y9 A9 q& i' |8 S% R- ]$ l1 a0 m& N2 v. n( m
換其它WP的版本也還是這樣,
: x; I- H8 M8 k. B; K# Q另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。
2 q, @% [$ w$ n7 k6 ?( \看代碼似乎都沒什麼問題,8 W) f) \; O. {1 s1 m% w
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case! k/ [) c3 w; N2 O( t, X
- $anchor_level = 0;
0 K, x; _& R) h - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {: b/ ~! }3 X5 k+ c7 X( f
- $i = 0;, y( n- s0 [, ^* }
- foreach ($tokens as $token) {( M/ E* s( o8 _) k2 M
- if (++$i % 2 && $token != '') { // this token is (non-markup) text
- I) |3 m0 s# T- p$ t - if ($anchor_level == 0) { // linkify if not inside anchor tags( L3 @. F8 n7 v1 M
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 47 e2 v7 a0 z3 [4 g! s- D+ o
- $j++;! X( l' y. V- k
- 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 !& G5 E! m, `6 K1 u" F3 s2 S7 Y
- $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments5 I) c! n) T* p+ [1 o& m
- } \% y* k- `& m5 p0 ^3 l. |+ f. q
- $must_tokenize = true; // re-tokenize next time around1 ^/ Z: F3 Q. v0 i7 e/ [1 X
- }5 z/ A9 {' \& H) I
- }( a$ C9 Q5 n( N1 z! E2 } f
- } else { // this token is markup3 P1 Q6 b d/ P' [; }! I
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
3 ~9 x) M$ t3 i. l - $anchor_level++;
( P8 j' g+ u! f/ _/ [# K - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
: A/ B" @. l2 x6 { - $anchor_level--;3 g) G, a: R1 J# J
- }
3 u3 W# S# j; N5 W' I- T - }
) K. W& i) q* D$ @; U - $filtered .= $token; // this token has now been filtered- K! Q: n: D+ c; P" |7 w7 ?/ _' o
- }
* r5 j0 g* N, ^ - $content = $filtered; // filtering completed for this link4 e+ Q; N7 W. _
- }
複製代碼
* R3 _. ^) K k4 k+ e
' ~) t0 b- ?. u- O* t' w1 z- b: i" g: Q& _4 g' d8 u- @5 U
|