本帖最後由 jeffseo 於 2013-12-6 19:33 編輯
7 @) w& \6 T8 x: w* T1 _5 \
) a4 U! ], \% g) y: P; H* `換其它WP的版本也還是這樣,2 Q+ V& c# `$ X" q2 q9 o6 C
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。 x b% [! s& p H0 T) I
看代碼似乎都沒什麼問題,
; r% U, J. S c" t+ J其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case* P% j5 x$ k/ U
- $anchor_level = 0;
/ N/ r3 W. k- @; P9 o2 F D; O9 T - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {% i- m8 \0 G1 R/ x% I6 {, c+ Q, q4 t v5 ]
- $i = 0;3 V( y3 q6 u( p' Z0 Y% f
- foreach ($tokens as $token) {
! m. `; `5 N# f" m - if (++$i % 2 && $token != '') { // this token is (non-markup) text$ v2 [# S8 J/ M Q5 h" b) ~
- if ($anchor_level == 0) { // linkify if not inside anchor tags$ y) r9 o. }1 u8 l4 Q8 {3 h
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4% p1 b2 q5 D3 E7 q
- $j++;
5 l2 a; f( h$ V5 J7 k$ w3 z! w - 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 !
1 [- p$ M9 K0 N$ x - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
# J- |. \$ e+ v7 y, x( b' N - }
1 b! O8 O' @, _1 f3 f6 X - $must_tokenize = true; // re-tokenize next time around
% @+ V* }$ P0 k- Y: z( A, C. E, C4 I - }
) w! j4 ?& d5 v6 n3 S5 j - }
$ o+ a' K& K E" w - } else { // this token is markup* A: L7 l5 @7 p( _1 s
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>; _$ C" f# p* c. t: L
- $anchor_level++;
& Z v. Z: Z; [) i. s - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
0 t* I; m$ X* p( x - $anchor_level--;
& x. @7 X' Z% j8 K7 _" ^ - }& [ `8 R5 ]4 S
- }* M( z7 E2 o; u8 n
- $filtered .= $token; // this token has now been filtered
5 F1 }- J5 X; ?7 y6 a - }& h" m: b: q6 T* k0 L1 |% i
- $content = $filtered; // filtering completed for this link4 ~; j6 N4 h0 n8 S: \" p3 B
- }
複製代碼
1 o7 y! a: u5 j8 n
" e. q, I5 h9 b$ p& ]$ h) E5 J
& A$ H7 @6 X6 q% N& H* S: e9 K, S |