File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 5
5
* @Author Ngo Quang Cuong <bestearnmoney87@gmail.com>
6
6
* @Date 2016-12-23 23:54:46
7
7
* @Last modified by: nquangcuong
8
- * @Last Modified time: 2017-01-05 09:03:57
8
+ * @Last Modified time: 2017-07-14 23:37:23
9
9
*/
10
10
11
11
namespace PHPCuong \Faq \Helper ;
@@ -87,8 +87,26 @@ public function getFaqShortDescription($content, $identifier)
87
87
if (!empty ($ arg )) {
88
88
$ arg = $ arg .'... <a href=" ' .$ this ->getFaqFullPath ($ identifier ).'"> ' .__ ('Read more ' ).'</a> ' ;
89
89
}
90
+ $ arg = $ this ->findUrlsInText ($ arg );
90
91
return $ arg ;
91
92
}
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
+ }
92
110
return $ content ;
93
111
}
94
112
You can’t perform that action at this time.
0 commit comments