forked from BadFishy/G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcode.php
66 lines (57 loc) · 1.82 KB
/
shortcode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
*
* 感谢Maicong大佬的短代码解析QwQ
* 注册短代码
*
* @author MaiCong <[email protected]>
* @link https://github.com/maicong/stay
* @since 1.5.4
*
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
require_once __DIR__ . '/shortcode.main.php';
// // 项目面板
// function shortcode_panel_task( $atts, $content = '' ) {
// return '<div class="tip mc-panel p-task clearfix">' . $content . '</div>';
// }
// add_shortcode( 'task' , 'shortcode_panel_task' );
//文章跳转
function shortcode_jump_button( $atts, $content= ''){
$db = Typecho_Db::get();
$result = $db->fetchAll($db->select()->from('table.contents')
->where('status = ?','publish')
->where('type = ?', 'post')
->where('cid = ?',$content)
);
if($result){
$i=1;
foreach($result as $val){
$val = Typecho_Widget::widget('Widget_Abstract_Contents')->push($val);
$post_title = htmlspecialchars($val['title']);
$post_permalink = $val['permalink'];
$post_date = $val['created'];
$post_cid = $val['cid'];
$post_date = date('Y-m-d',$post_date);
return '
<div class="ArtinArt">
<h4><a href="'.$post_permalink.'">'.$post_title.'</a></h4>
<p class="clear"><span style="float:left">ID:'.$post_cid.'</span><span style="float:right">'.$post_date.'</span></p>
</div>
';
}
}
else{
return '<span>id无效QAQ</span>';
}
}
add_shortcode('art','shortcode_jump_button');
// 下载
function shortcode_button_dl( $atts, $content = '' ) {
$args = shortcode_atts( array(
'href' => 'https://',
'target' => '_blank'
), $atts );
return '<div class="post-download"><a href="//' . $args['href'] . '" target="' . $args['target'] . '"><span>' . $content . '</span></a></div>';
}
add_shortcode( 'dl' , 'shortcode_button_dl' );