本帖最後由 jeffseo 於 2013-12-6 19:33 編輯
9 ~2 e, i+ |9 X9 ?, R% s* _' f0 q2 u8 ~ C& }- C
換其它WP的版本也還是這樣,2 z2 O' v/ Q% _2 o [. r
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。( m1 [6 t+ A6 ^) X
看代碼似乎都沒什麼問題,/ ?& H: k+ G4 V! b6 s2 j/ C
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
! ~; M4 m% L$ }/ _ - $anchor_level = 0;( t: H0 h8 F( }* [* I7 C
- if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {1 U) ]$ F: ?- h& A/ r
- $i = 0;0 V( W2 {; `- K* ^+ x
- foreach ($tokens as $token) {7 J! z3 ^- g7 ?9 U# @
- if (++$i % 2 && $token != '') { // this token is (non-markup) text( ]3 ]1 \) i; U, }# O1 _" H9 R
- if ($anchor_level == 0) { // linkify if not inside anchor tags; t, z9 |/ w" K5 K: m
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4* U: `! [+ {5 f, h9 J- z
- $j++;
0 L+ E H% \. m* B, ~ - 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 E/ Q# i3 \ - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments$ _3 h- z; Y9 A
- }. X8 A+ c/ v5 ?& }( l" |
- $must_tokenize = true; // re-tokenize next time around- G" F7 u# i% ^: p4 B5 z5 k, t
- }# w0 F6 K7 H1 o' a6 k
- }
: L! S D' ?% \ w `. U5 S - } else { // this token is markup
% u0 b* c3 P' s7 g. K* P - if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
: F0 a: w8 Z& j/ u; W% `. M% b) ~ - $anchor_level++;2 y2 z- ]; b' h( o
- } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>( Z* b4 H- J4 ]% Y c% f9 ^! Z
- $anchor_level--;2 z- [1 X0 u; K8 n7 q. u
- }
2 |! Y' C/ I. l! U* e/ t8 y - }/ e9 h W ?6 E& ^( V& K2 m
- $filtered .= $token; // this token has now been filtered
" Z2 k' I) j6 f - }$ ]% m4 Q# h% I5 k8 M4 v
- $content = $filtered; // filtering completed for this link; v9 `% Q# v C V1 V' N$ g
- }
複製代碼
1 w9 _2 [6 A: L
. I7 l6 k2 B4 `7 w$ P0 x
, C- @* p% G$ j# v5 i |