Skip to content

Commit 146107c

Browse files
committed
update the text link in Faq Short Description
1 parent d6c4059 commit 146107c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Helper/Config.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @Author Ngo Quang Cuong <bestearnmoney87@gmail.com>
66
* @Date 2016-12-23 23:54:46
77
* @Last modified by: nquangcuong
8-
* @Last Modified time: 2017-01-05 09:03:57
8+
* @Last Modified time: 2017-07-14 23:37:23
99
*/
1010

1111
namespace PHPCuong\Faq\Helper;
@@ -87,8 +87,26 @@ public function getFaqShortDescription($content, $identifier)
8787
if (!empty($arg)) {
8888
$arg = $arg.'... <a href="'.$this->getFaqFullPath($identifier).'">'.__('Read more').'</a>';
8989
}
90+
$arg = $this->findUrlsInText($arg);
9091
return $arg;
9192
}
93+
$content = $this->findUrlsInText($content);
94+
return $content;
95+
}
96+
97+
/**
98+
* Find and Replace the text is a Url
99+
*
100+
* @param $content
101+
* @return string
102+
*/
103+
public function findUrlsInText($content)
104+
{
105+
$pattern = '~[a-z]+://\S+~';
106+
preg_match_all($pattern, $content, $urls);
107+
foreach ($urls[0] as $url) {
108+
$content = str_replace($url, "<a href=".$url." target='_blank'>".$url."</a> ", $content);
109+
}
92110
return $content;
93111
}
94112

0 commit comments

Comments
 (0)