本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 I1 R/ G& g. \9 R. w8 K8 L" y& I
8 O8 s' t: }. O/ _換其它WP的版本也還是這樣,! x7 P: I( O5 K; H
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。; M6 V T \" ~
看代碼似乎都沒什麼問題,- i8 W1 a& h- G% f" z
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
# \5 J: i+ \$ Y$ U3 |! V( L8 L - $anchor_level = 0;
, ^2 V$ v$ X) C, s4 B# b - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {# r8 Z( R4 m1 E1 B W
- $i = 0;
- S: F9 }& Q! {6 w _. @ - foreach ($tokens as $token) {" b' ]8 i2 d, W$ H
- if (++$i % 2 && $token != '') { // this token is (non-markup) text6 w2 ^ J+ [0 H# r) E& L. X1 G
- if ($anchor_level == 0) { // linkify if not inside anchor tags9 \; N$ @% \1 B) s/ a+ j% Y
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4/ K9 [* B+ m8 Q1 @4 d' c
- $j++;
; s% W; R; R# M, i- g - 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 !! A$ Z9 y) r ~# t v' Z
- $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
# m) m( V$ M7 G: J* T2 c$ C1 S0 l - }
9 R# T- N$ Q7 E. R - $must_tokenize = true; // re-tokenize next time around
) `& s/ ~: E3 M+ x, x - }
/ E$ W: R6 o) C# Z* Q. e( a3 L - }! D7 W; o# Z* i. e8 {) ]. O
- } else { // this token is markup
& I4 I0 ]) h; j6 H% e9 h$ Q- m% T/ `+ m - if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
& s0 _2 q2 |1 `. o/ T4 r - $anchor_level++;
) ^( ?: x( D$ Z0 @" @ - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
! I7 Q: ^: q% o - $anchor_level--;* A, Q- {. M- S N( x/ L i
- }
6 x# E+ E! a8 A1 J - }
( t: k, D5 }2 T. Y - $filtered .= $token; // this token has now been filtered! m- h, X( ~/ I) D& q8 R! E
- }' s! N. G6 ? y2 f6 I: J
- $content = $filtered; // filtering completed for this link, S# y# t$ a3 {- Y$ s: `
- }
複製代碼
# E2 N( G: g2 F8 ~- f# t& t$ x" S4 w+ n9 e. H$ A
1 ~/ m% x5 q/ B
|