-
Notifications
You must be signed in to change notification settings - Fork 1
/
ritterml-sermons.php
151 lines (126 loc) · 4.16 KB
/
ritterml-sermons.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
/*
Plugin Name: sermons plugin by mike ritter
Description: create sermon custom post types for church website
Plugin URI: https://github.com/mikeritter/wordpress_plugins/mikeritter-sermons
Version: 0.0.4
Author: Mike Ritter
*/
/*
* Outline:
* * custom post type
* * custom taxonomies
* * custom meta boxes
*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/*
* Create sermon post type
*/
add_action('init','create_post_type');
function create_post_type(){
register_post_type(
'ritterml_sermon',
array(
'labels' => array(
'name' => 'Sermons',
'singular_name' => 'Sermon'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'sermons'),
'menu_position' => 5,
'supports' => array('title','editor')
)
);
}
add_action( 'init', 'be_register_taxonomies' );
/**
* Register Multiple Taxonomies
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/register-multiple-taxonomies/
*/
function be_register_taxonomies() {
$taxonomies = array(
array(
'slug' => 'sermon-date',
'single_name' => 'Date',
'plural_name' => 'Dates',
'post_type' => 'sermon',
'rewrite' => array( 'slug' => 'date' ),
),
array(
'slug' => 'sermon-description',
'single_name' => 'Description',
'plural_name' => 'Descriptions',
'post_type' => 'sermon',
),
array(
'slug' => 'sermon-service',
'single_name' => 'Service',
'plural_name' => 'Services',
'post_type' => 'sermon',
'rewrite' => array('slug' => 'service')
),
array(
'slug' => 'sermon-image',
'single_name' => 'Image',
'plural_name' => 'Images',
'post_type' => 'sermon',
'rewrite' => array('slug' => 'image')
),
array(
'slug' => 'sermon-embed',
'single_name' => 'Embed',
'plural_name' => 'Embeds',
'post_type' => 'sermon',
'rewrite' => array('slug' => 'embeds')
)
);
foreach( $taxonomies as $taxonomy ) {
$labels = array(
'name' => $taxonomy['plural_name'],
'singular_name' => $taxonomy['single_name'],
'search_items' => 'Search ' . $taxonomy['plural_name'],
'all_items' => 'All ' . $taxonomy['plural_name'],
'parent_item' => 'Parent ' . $taxonomy['single_name'],
'parent_item_colon' => 'Parent ' . $taxonomy['single_name'] . ':',
'edit_item' => 'Edit ' . $taxonomy['single_name'],
'update_item' => 'Update ' . $taxonomy['single_name'],
'add_new_item' => 'Add New ' . $taxonomy['single_name'],
'new_item_name' => 'New ' . $taxonomy['single_name'] . ' Name',
'menu_name' => $taxonomy['plural_name']
);
$rewrite = isset( $taxonomy['rewrite'] ) ? $taxonomy['rewrite'] : array( 'slug' => $taxonomy['slug'] );
$hierarchical = isset( $taxonomy['hierarchical'] ) ? $taxonomy['hierarchical'] : true;
register_taxonomy( $taxonomy['slug'], $taxonomy['post_type'], array(
'hierarchical' => $hierarchical,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => $rewrite,
));
}
}
/*
* Adding my meta boxes
*/
add_action('add_meta_boxes','ritterml_sermon_date_meta');
function ritterml_sermon_date_meta(){
add_meta_box(
'sermon_date',
__('Sermon Date','ritterml_sermon'),
'sermon_date_meta_box',
'normal',
'default'
);
}
function sermon_date_meta_box($object,$box){
?>
<div>
<label>Sermon Date:</label><input type="date" />
</div>
<?php
}
/* Stop Adding Functions Below this Line */
?>