本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 8 d! d6 t: G+ b5 W" Y# T3 d/ x
4 }' W( e5 |( I* M6 P* Z換其它WP的版本也還是這樣,
9 E! ]5 ] R- k; { T另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。) r, Q4 u! w6 e' `
看代碼似乎都沒什麼問題,
/ Q7 [9 n# H% d* G3 s( P) T# Y其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case, B3 \5 r4 H* r" m- {% z$ F6 O
- $anchor_level = 0;
4 L" x* `; Q% J2 ]& t - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {
7 W; Z+ w; C0 D+ U' b$ b! V - $i = 0;
# M! a6 u; D4 T& M4 K - foreach ($tokens as $token) {) \8 i" C* X- Y
- if (++$i % 2 && $token != '') { // this token is (non-markup) text; @6 v# ]4 R% [6 L5 d0 L+ c- z! H
- if ($anchor_level == 0) { // linkify if not inside anchor tags
, P4 `0 B8 a* n f! h6 i - if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4 r+ z8 f/ B0 m" g6 C9 f
- $j++;
' \3 q' X. [- k2 r4 s/ B) 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 !: d; U9 K7 d# Y5 x4 K
- $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments1 V6 A* |5 z5 V
- }# g! q4 t% J1 E8 T% P
- $must_tokenize = true; // re-tokenize next time around
! H+ Z, ~0 C+ _4 v - }& u5 R3 d9 C3 R' J5 k! X
- }, v! o: O; j+ y! B/ i: D
- } else { // this token is markup- u0 m/ N% n) Y
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>3 a: N- y* G: F6 o: _' b) D% ]
- $anchor_level++;
* j% R6 j) E7 g: w6 Y$ k1 q - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
$ c/ \# |3 U$ [" N1 [, F* q - $anchor_level--;
& T3 _$ G% z. i% [ - }
4 ]( K- O0 w7 h1 Z, t7 a) Z% @3 v3 V9 \ - }
1 Y7 U! ^% \0 [. i" Y0 u* E$ X5 z - $filtered .= $token; // this token has now been filtered0 F7 ] C1 r- o# D2 u/ _
- }! ~/ \9 X6 Y' D8 w" t" d
- $content = $filtered; // filtering completed for this link H2 X- J! r" h2 [! N, H
- }
複製代碼
E7 r8 t/ X3 A, g% A
0 Z4 f _ m4 ]$ r0 T' C
* @2 \4 O7 P4 f8 h; _
|