-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
51 lines (40 loc) · 1.21 KB
/
functions.php
File metadata and controls
51 lines (40 loc) · 1.21 KB
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
<?php
register_nav_menu( 'nav-menu', 'head_menu');
function load_post() {
// 如果 action ID 是 load_post, 并且传入的必须参数存在, 则执行响应方法
if($_GET['action'] == 'load_post' && $_GET['id'] != '') {
$id = $_GET["id"];
$output = '';
// 获取文章对象
global $wpdb, $post;
$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id));
// 如果指定 ID 的文章存在, 则对他进行格式化
if($post) {
$content = $post->post_content;
$output = balanceTags($content);
$output = wpautop($output);
}
// 打印文章内容并中断后面的处理
echo $output;
die();
}
}
// 将接口加到 init 中
add_action('init', 'load_post');
///////////////////////短代码支持
//代码
function codeebox($atts, $content=null, $code="") {
$return = "<pre class='prettyprint'>";
$return .= do_shortcode($content);
$return .= "</pre>";
return $return;
}
add_shortcode('codee' , 'codeebox' );
//下载
function downloadbox($atts, $content=null, $code="") {
$return = "<i class='cloud download icon'></i>";
$return .= do_shortcode($content);
$return .= "";
return $return;
}
add_shortcode('down1' , 'downloadbox' );