本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 $ y3 p5 w5 j! s# X; H- Z
# q( W. g4 {6 d# w# S+ @; O
換其它WP的版本也還是這樣,
( r3 m( Z1 ^9 G( }+ K另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。3 B* s9 N9 l, D; X! K3 q
看代碼似乎都沒什麼問題,# E) N( o& e- j9 J- Q/ ` X2 c
其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case* r) U+ j) s* n% u; N: g t6 M
- $anchor_level = 0;2 Q$ K: o- B2 g3 x( e; M
- if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {& M' z% q9 b* I' z# i* ?
- $i = 0;
- l: w' l2 B1 S' ~0 z0 k' n - foreach ($tokens as $token) {
! O; Z& E- e! ^8 s0 l4 F" I - if (++$i % 2 && $token != '') { // this token is (non-markup) text' ?$ g9 A5 r! f) n9 o% B1 U& E2 q
- if ($anchor_level == 0) { // linkify if not inside anchor tags" G1 l1 i2 y6 s, D k2 F$ v8 x
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4
5 P# P: p p5 f n+ p% b - $j++;3 @! {9 E( W* V) g% Z* 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 !
4 o; |6 c6 s, V9 w# e# d0 }$ G - $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
! i. I. ?% g9 ~ B; q - }
* O0 I% u# X# j8 u9 J - $must_tokenize = true; // re-tokenize next time around
' }/ x0 R- {# N! {" {$ O - }5 e" T2 U: j9 y, i2 F' \
- }, _: P+ E0 @9 Y& X
- } else { // this token is markup
4 \7 \+ q) ?. s' `4 ~ - if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
7 q; J/ j t+ @ - $anchor_level++;
* B! C1 Y3 G" H - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>
' ^* ~" f0 }" x, m- @5 `6 t - $anchor_level--;
& T* H+ Y" A6 ~9 Z, D' [7 ~ - }
" A3 g) K8 A% s - }
! K, F# c" E5 a8 C$ X - $filtered .= $token; // this token has now been filtered
/ c2 l2 S; k [5 y - }
! n5 E. ], g4 C: J" g) f7 [9 ~ - $content = $filtered; // filtering completed for this link
8 c' [' n) T: o; D/ O( ~2 w% X2 @7 F - }
複製代碼
: m- q0 R+ [4 M
/ `5 u/ H: Q3 p5 G% q1 S
1 T! |& O, x8 d |