本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 4 R1 r8 Q+ C% V6 H
0 G; d9 }0 x2 w/ |
換其它WP的版本也還是這樣,
5 I. T" y7 r" J3 k) _) Z( ^8 [另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。4 E6 p3 F$ V% Y" Z: \. G" H
看代碼似乎都沒什麼問題,; D; N! W( I4 b' D
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
+ b0 ^! z8 y1 p( U - $anchor_level = 0;; l; e8 Y, V; w. e! P0 B
- if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {
4 S4 B- I2 j. W( s# H; J5 I5 K - $i = 0;' `+ T; f% D( [" N# ?
- foreach ($tokens as $token) {
+ ?% e; S% ^) D9 m# D - if (++$i % 2 && $token != '') { // this token is (non-markup) text
+ m9 Q* H$ z& n t6 Y - if ($anchor_level == 0) { // linkify if not inside anchor tags" [, o, E: T/ ~2 y4 ^
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4
6 I$ s* |: c+ K1 D8 X - $j++;/ `9 d* N# R3 M0 ]. v
- 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 !
5 Q4 \( W, E8 f+ b5 Z( p9 l. E - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
0 [4 } v( n6 b; k9 r - }8 U4 n! a0 e( q5 T- O5 |# _
- $must_tokenize = true; // re-tokenize next time around
/ m) K& v$ {" y% M - }
+ Z9 ^" s4 c( ]) h - }/ ~% Y/ [1 N% f/ A
- } else { // this token is markup! _, @+ d& @. @6 o8 Y. V* g
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...># S' y8 w- d7 a! s
- $anchor_level++;
: Z2 k" n6 Y5 t; e2 O4 G: W - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
3 z9 O4 g/ b* L3 ]7 }6 } - $anchor_level--;
# J8 e; z+ t; H9 O' H" k. x* ^ - }! _/ y; B' R- E) P5 R! S
- }
" K: M0 t6 @( N" ?8 W s - $filtered .= $token; // this token has now been filtered
, s( {+ l0 h9 g9 t( Q3 | - }
/ A( b/ d) v2 R) p - $content = $filtered; // filtering completed for this link
: E" o0 j N3 G8 F) T4 N' v - }
複製代碼
# f- l3 t% O7 d% I9 {: W
9 h A% ]9 k: T
' ?( b: o. z$ m$ n |