本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 & L; W- f- ]4 I- ~( G' ]
; v, ~/ `% u, C( ~換其它WP的版本也還是這樣,, R4 T- L- K: ?" R8 h& D
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。0 X7 q* B$ F% l2 [) k0 k2 k
看代碼似乎都沒什麼問題,
1 ^, E+ M ~! `% n5 m2 }# X其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
% B1 C7 x" O# }5 ] i, T$ z q - $anchor_level = 0;
% u% R1 v3 b5 a6 O& y1 n - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {
) X" g2 y. U; P" y" q - $i = 0;
1 B' Q- t9 Q6 u$ r, Z2 w- x - foreach ($tokens as $token) {# W" X1 ~& a6 a- ]( R3 U
- if (++$i % 2 && $token != '') { // this token is (non-markup) text2 {; u, I- \+ s0 F3 F. o) L2 ?
- if ($anchor_level == 0) { // linkify if not inside anchor tags
2 u# k/ K$ v0 T( ~ - if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4
* n" p; G U* o) l6 \ - $j++;1 k0 }; J" n. N @ 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 !
/ O, B4 M3 Y8 W$ m+ c; k" u% a - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments- `% R* V* U) ?0 q' i4 W, ~4 }
- }
# p) I2 v% @/ V: ?1 Y3 y - $must_tokenize = true; // re-tokenize next time around& X" L! B# @( ~5 J v
- }; ~6 J8 }, g+ f9 s4 Z
- }
6 V5 |$ ]: |+ r1 [4 l - } else { // this token is markup8 d; @8 s* c/ h0 d* I8 R$ S
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>- R V4 P) E" ?/ e L
- $anchor_level++;
. o+ B; e* r( P$ z ~0 [( @- |7 Y5 d0 S - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
+ I6 D3 Z# U( j. q% E( e! m - $anchor_level--;, N, c R1 [* @, m; V* B! e
- }1 F. k5 e* g8 ^ P) r/ f9 u5 B$ ~
- }5 e- w p, @9 t" K* \2 g
- $filtered .= $token; // this token has now been filtered7 w1 l- [% D; u% F' K8 q9 Y, n
- }
2 L7 m# a1 B/ A- X: |3 ]0 J - $content = $filtered; // filtering completed for this link$ C* M" f! T, S
- }
複製代碼
' W: H" Y' @# Z4 h7 D
1 Y9 B7 v" n( u" u' t
" L/ C* z+ q4 }: k+ \9 B |