本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 # w! \9 _% A* S7 [" z6 H
; A, [# u M: i+ L換其它WP的版本也還是這樣," m( [* v# l; |# e
另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。
8 V3 C8 g' {* V, m6 S8 g0 h看代碼似乎都沒什麼問題,0 \: c+ q9 z8 Z/ b
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case8 z# u; @) ~4 L" j/ [
- $anchor_level = 0;! I' _9 T. e p/ q% x" E+ o
- if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {
7 e3 `5 W4 J8 ~' L0 [4 a( A - $i = 0;
- l$ {. z# |% C2 I; C - foreach ($tokens as $token) {
9 G/ f) t0 T5 A$ h0 o - if (++$i % 2 && $token != '') { // this token is (non-markup) text4 U4 d' D# z/ h" J, [
- if ($anchor_level == 0) { // linkify if not inside anchor tags
6 ^6 a3 U# _& ` - if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4. u' u* F ~8 o" M2 r. K# _
- $j++;$ l$ w& `$ p8 b2 h+ ?% O
- 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 !
6 G3 z9 w+ @: v- O1 m - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
1 W8 n4 |4 y2 \4 W2 w8 U - }
: c k2 ^+ l$ ]0 ~& k+ o" @ - $must_tokenize = true; // re-tokenize next time around
6 i8 Y/ \( Z9 B& ?6 w: p- G. r' R8 k - }
( n# q1 A* ~2 T - }
2 I3 i M, [* Y( z) F - } else { // this token is markup
$ T8 p; G j1 i7 `, k! X+ A+ T - if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
; k- y7 L( |1 C. X/ J9 A - $anchor_level++;" Q, X1 u- y( \
- } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>8 R0 I9 o" a& k2 q, [6 n: n6 Z
- $anchor_level--;$ ?' B/ a0 s/ i* k5 k. h' ]' |+ t
- }) E. t! A. l/ k/ _- l$ B
- }2 f# a! x) X: E5 L: ]6 v! n" w
- $filtered .= $token; // this token has now been filtered
& T2 W; k$ N9 o$ L% T - }
" i& D7 D: H/ X5 Q5 L; ?3 T4 G - $content = $filtered; // filtering completed for this link
* b+ d; S6 B* l" W8 Q# S - }
複製代碼
8 Y) R% q0 A- t2 L
/ {1 C4 L# ?$ \, y0 S, A9 f
: k, ^! e1 v6 h6 K* r: \5 z |