diff options
| author | 阔落 <45323514+BigCoke233@users.noreply.github.com> | 2019-03-31 15:01:19 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-31 15:01:19 +0800 |
| commit | 58dd89e1d3c3d254f5ede64b182fc780dabe9a9f (patch) | |
| tree | 8b6258c6fbb907cf97db5375072795ee3ce0b271 /includes | |
| parent | b638fc995937c127750e65e52431c415cc91b964 (diff) | |
更加实用更加稳定的短代码
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/post-content.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/includes/post-content.php b/includes/post-content.php index 21a45ce..0619795 100644 --- a/includes/post-content.php +++ b/includes/post-content.php @@ -1,5 +1,4 @@ <?php
-
$content = $this->content;
$content = preg_replace('/<table(.*?)>/s','<table class="table table-striped table-hover">',$content);
@@ -46,6 +45,31 @@ $reg = '/\[stext\](.*?)\[\/stext\]/s';
$rp = '<div class="post-stext">${1}</div>';
$content = preg_replace($reg,$rp,$content);
+
+ //解析按钮
+ $reg = '/\[btn url="(.*?)" type="(.*?)" ico="(.*?)"\](.*?)\[\/btn\]/s';
+ $rp = '<a href="${1}" class="btn btn-${2}" target="_blank"><i class="${3}"></i> ${4}</a>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析嵌入块
+ $reg = '/\[well\](.*?)\[\/well\]/s';
+ $rp = '<div class="well">${1}</div>';
+ $content = preg_replace($reg,$rp,$content);
+ //解析面板
+ //无参数面板
+ $reg = '/\[panel\](.*?)\[\/panel\]/s';
+ $rp = '<div class="panel panel-default"><Div class="panel-body">${1}</div></div>';
+ $content = preg_replace($reg,$rp,$content);
+ //有标题的面板
+ $reg = '/\[panel title="(.*?)"\](.*?)\[\/panel\]/s';
+ $rp = '<div class="panel panel-default"><div class="panel-heading">${1}</div><Div class="panel-body">${2}</div></div>';
+ $content = preg_replace($reg,$rp,$content);
+
+ //解析列表组
+ $reg = '/\[lg\](.*?)\[\/lg\]/s';
+ $rp = '<ul class="list-group">${1}</ul>';
+ $content = preg_replace($reg,$rp,$content);
+
echo $content;
?>
\ No newline at end of file |
