-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions-ece-spaces.php
70 lines (59 loc) · 1.91 KB
/
functions-ece-spaces.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
67
68
69
70
<?php
/*********************ECE SPACES**************************/
add_action( 'init', 'create_ece_space_post_type' );
function create_ece_space_post_type() {
register_post_type( 'ececlub_space',
array(
'labels' => array(
'name' => __( 'ECE Spaces', 'ececlub'),
'singular_name' => __( 'ECE Space', 'ececlub')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'spaces'),
'supports' => array('title', 'editor', 'custom-fields', 'revisions')
)
);
}
add_action("admin_init", "ececlub_space_admin_init");
function ececlub_space_admin_init(){
add_meta_box("space-meta", __("Location", 'ececlub'), "ececlub_space_meta", "ececlub_space", "side", "low");
}
function ececlub_space_meta(){
global $post;
$custom = get_post_custom($post->ID);
$location = $custom["location"][0];
?>
<label>Location:</label>
<input name="location" value="<?php echo $location; ?>" />
<?php
}
add_action('save_post', 'save_ececlub_space');
function save_ececlub_space(){
global $post;
update_post_meta($post->ID, "location", $_POST["location"]);
}
add_action("manage_posts_custom_column", "ececlub_space_custom_columns");
add_filter("manage_edit-ececlub_space_columns", "ececlub_space_edit_columns");
function ececlub_space_edit_columns($columns){
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => __("Title", 'ececlub'),
"description" => __("Description", 'ececlub'),
"location" => __("Location", 'ececlub'),
);
return $columns;
}
function ececlub_space_custom_columns($column){
global $post;
switch ($column) {
case "description":
the_excerpt();
break;
case "location":
$custom = get_post_custom();
echo $custom["location"][0];
break;
}
}
?>