本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 7 g. O% A' n9 }, o1 v9 J) d
! X; H/ r _! ~5 _1 K$ o- @; H換其它WP的版本也還是這樣,8 w! N2 [- o/ ~- n, Y* o$ X
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。
. |0 c& s( t( @5 Q, h3 d& q看代碼似乎都沒什麼問題,- r6 K7 V/ K: A& X7 ]6 E2 \
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
0 I, e8 C5 q) _% j% B* F - $anchor_level = 0;
: m8 c. K/ p% T1 ~; t# a - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {# W& F1 }6 l) W) q, o- J
- $i = 0;
, s( H8 o1 |% o$ I5 e - foreach ($tokens as $token) {
2 j2 O# m' P+ |3 ^; y' A - if (++$i % 2 && $token != '') { // this token is (non-markup) text# Y, X/ P4 K3 N- d$ r+ I
- if ($anchor_level == 0) { // linkify if not inside anchor tags* d8 V$ B" J5 Z6 p# k: w& n
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4& E8 J! u+ R7 G) d
- $j++;
4 y5 Z$ N( Y0 U2 L, w) O, a - 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 !
+ T4 p5 N7 [, _9 b - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments* O: M7 {4 L: ^0 K& h
- }
U# j& |& p) _ - $must_tokenize = true; // re-tokenize next time around* T6 m5 f# e/ P" ]5 Q5 j+ W
- }
# w! z% o1 y o* ?' H - }* ~+ }+ f& D" x5 g
- } else { // this token is markup. o0 z; K1 Y- \4 p; o# S2 H. L$ C) i
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
w, `$ ~/ K! Z, C4 W - $anchor_level++; X! P5 w. b" H6 ]- X( G5 r6 k
- } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
, V u' {% ^* A9 r. Y) d! v: Q3 H - $anchor_level--;
, d6 k( ?2 O( r8 g6 N' s- m - }
) y U2 v: @; ?5 Y3 G$ ^/ r - }
. z$ T/ F& y( F- ?+ P - $filtered .= $token; // this token has now been filtered
* ^" b8 }2 ^9 E" q5 }. n5 O - }. \- m- d1 Q2 J; N
- $content = $filtered; // filtering completed for this link7 ] |9 S3 T, y( D5 V
- }
複製代碼
7 z# |0 k1 u% c/ x0 D
# D7 C1 I2 o' ^! U6 k. w
v `" H0 u) ]3 r% j
|