-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog.php
183 lines (165 loc) · 8.43 KB
/
blog.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
if (! class_exists ('PH_Blog')) {
class PH_Blog {
private static $instance = false;
public static function get_instance() {
if ( !self::$instance )
self::$instance = new self;
return self::$instance;
}
public function __construct(){
// add custom post type
add_action( 'init', array( $this, 'ph_news' ) );
add_action( 'init', array( $this, 'ph_dumpster_blog' ) );
add_action( 'init', array( $this, 'ph_porta_potty_blog' ) );
add_action( 'template_include', array( $this, 'news_page_template' ) );
add_action( 'template_include', array( $this, 'dumpster_blog_page_template' ) );
add_action( 'template_include', array( $this, 'porta_potty_blog_page_template' ) );
}
public function ph_news() {
// create Dumpster custom post type
register_post_type( 'news',
array(
'labels' => array(
'name' => __( 'News' ),
'singular_name' => __( 'News' ),
'add_new' => __( 'Add News' ),
'add_new_item' => __( 'Add News' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit News' ),
'new_item' => __( 'New News' ),
'view' => __( 'View News' ),
'view_item' => __( 'View News' ),
'search_items' => __( 'Search News' ),
'not_found' => __( 'No News found' ),
'not_found_in_trash' => __( 'No News found in Trash' ),
'parent' => __( 'Parent News' ),
),
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'news'),
'supports' => array( 'title', 'editor', 'thumbnail','page-attributes'),
'show_in_rest' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-text-page',
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'rest_base' => 'news',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
}
public function news_page_template($template) {
if (is_singular('news')) {
$template_path = plugin_dir_path(__FILE__) . 'templates/news.php';
if (file_exists($template_path)) {
return $template_path;
}
}
return $template;
}
public function ph_dumpster_blog() {
// create Dumpster custom post type
register_post_type( 'dumpster_blog',
array(
'labels' => array(
'name' => __( 'Dumpster Blog' ),
'singular_name' => __( 'Dumpster Post' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Dumpster Post' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Dumpster Post' ),
'new_item' => __( 'New Dumpster Post' ),
'view' => __( 'View Dumpster Post' ),
'view_item' => __( 'View Dumpster Post' ),
'search_items' => __( 'Search Dumpster Post' ),
'not_found' => __( 'No Dumpster Post found' ),
'not_found_in_trash' => __( 'No Dumpster Post found in Trash' ),
'parent' => __( 'Parent Dumpster Post' ),
),
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'dumpsters'),
'supports' => array( 'title', 'editor', 'thumbnail','page-attributes'),
'show_in_rest' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-text-page',
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'rest_base' => 'dumpster-blog',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
}
public function dumpster_blog_page_template($template) {
if (is_singular('dumpster_blog')) {
$template_path = plugin_dir_path(__FILE__) . 'templates/dumpster-blog.php';
if (file_exists($template_path)) {
return $template_path;
}
}
return $template;
}
public function ph_porta_potty_blog() {
// create Porta Potty custom post type
register_post_type( 'porta_potty_blog',
array(
'labels' => array(
'name' => __( 'Porta Potty Blog' ),
'singular_name' => __( 'Porta Potty Post' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Porta Potty Post' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Porta Potty Post' ),
'new_item' => __( 'New Porta Potty Post' ),
'view' => __( 'View Porta Potty Post' ),
'view_item' => __( 'View Porta Potty Post' ),
'search_items' => __( 'Search Porta Potty Post' ),
'not_found' => __( 'No Porta Potty Post found' ),
'not_found_in_trash' => __( 'No Porta Potty Post found in Trash' ),
'parent' => __( 'Parent Porta Potty Post' ),
),
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'porta-potties'),
'supports' => array( 'title', 'editor', 'thumbnail','page-attributes'),
'show_in_rest' => true,
'menu_position' => 7,
'menu_icon' => 'dashicons-text-page',
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'rest_base' => 'Porta-Potty-blog',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
}
public function porta_potty_blog_page_template($template) {
if (is_singular('porta_potty_blog')) {
$template_path = plugin_dir_path(__FILE__) . 'templates/porta-potty-blog.php';
if (file_exists($template_path)) {
return $template_path;
}
}
return $template;
}
}
PH_Blog::get_instance();
}