本帖最後由 jeffseo 於 2013-12-6 19:33 編輯 : ~$ w) d! L" z# e/ O% h
- h, B, T; A b& I0 j) p# d" Q# R換其它WP的版本也還是這樣,
- V6 N: B0 r: P+ ?3 ^另外Maximum number of links per article:這個值也沒讀成功,設置10個TAG,文章中仍然會把所有TAG都鏈接上。, ]9 Z7 q: ~0 q1 \& o8 h4 J! ^8 K
看代碼似乎都沒什麼問題,
$ d$ V1 Q2 r; m1 d其它用simple tags的哥們也是這樣的嗎- // there should always be at least one token, but check just in case
+ N y# ~2 i% y3 _( n - $anchor_level = 0;
7 d# D; e1 ]8 K - if (isset($tokens) && is_array($tokens) && count($tokens) > 0) {
$ l5 _4 p: V. d5 {2 X2 v- E0 E {, G - $i = 0;
4 p& F1 ~0 P6 T. ^) g) o - foreach ($tokens as $token) {8 l; A C; V& \0 u( V
- if (++$i % 2 && $token != '') { // this token is (non-markup) text
5 J, ^; `1 u- _6 F+ M" C0 B) i5 f - if ($anchor_level == 0) { // linkify if not inside anchor tags5 N3 I+ z. S$ h0 ?' V
- if (preg_match($match, $token)) { // use preg_match for compatibility with PHP 4 \ H) G; u I
- $j++;
, R+ o- \: [6 A$ p' V+ C e( ?$ a - 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 !0 }1 v$ f$ M6 L2 b
- $token = preg_replace($match, $substitute, $token); // only PHP 5 supports calling preg_replace with 5 arguments
2 ]8 ^( N/ d' t+ a$ x - }8 M. @ a% o! x
- $must_tokenize = true; // re-tokenize next time around
0 T% X5 F1 o: D" K - }: {! E7 b" \3 s, B
- }
2 q" t1 d% c8 i4 |3 m - } else { // this token is markup0 F" h. s* d7 V8 `
- if (preg_match("#<\s*a\s+[^>]*>#i", $token)) { // found <a ...>
6 R7 \8 J1 V! c; O" L& { - $anchor_level++;
$ L) j0 ?: S$ o/ ]2 C; ^9 E; c. m - } elseif (preg_match("#<\s*/\s*a\s*>#i", $token)) { // found </a>4 Y7 k# p( |4 D' k1 h
- $anchor_level--;# s% Z* j' m/ l1 `7 Z8 \- Y
- }# @2 o0 q% s6 h8 v3 Z( ~
- }
/ @8 k& v$ V; f, W+ t2 l - $filtered .= $token; // this token has now been filtered! e* g0 b N) X1 x
- }
* Z0 A8 f& r# D6 _* g - $content = $filtered; // filtering completed for this link
% S) y$ m5 l4 ?9 a: n1 M - }
複製代碼
/ u( \6 q/ n% q: m
. f* h: Z' |2 E& d7 X; h+ l9 E* F( Y5 A, ^" }- n
|