-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-mjj-faq-cpt.php
62 lines (51 loc) · 1.55 KB
/
class-mjj-faq-cpt.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
<?php
class MJJ_FAQ_CPT{
protected static $instance = null;
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
} // end if
return self::$instance;
} // end get_instance
private function __construct(){
add_action( 'init', array( 'MJJ_FAQ_CPT', 'create_post_types' ) );
add_filter( 'the_content', array( 'MJJ_FAQ_CPT', 'add_div' ) );
}
public static function create_post_types(){
register_post_type( 'mjj_faq',
array(
'labels' => array(
'name' => __( 'MJJ FAQs' ),
'singular_name' => __( 'FAQ' ),
'add_new' => 'Add New',
'add_new_item' => 'Add New FAQ',
'edit_item' => 'Edit FAQ',
'new_item' => 'New FAQ',
'all_items' => 'All FAQs',
'view_item' => 'View FAQs',
'search_items' => 'Search FAQ',
'not_found' => 'No FAQs found',
'not_found_in_trash' => 'No FAQs found in Trash',
'parent_item_colon' => '',
'menu_name' => 'FAQs'
),
'supports' => array('title', 'editor', 'thumbnail' ),
'public' => true,
'hierarchical' => false,
'has_archive' => true,
'rewrite' => array('slug' => 'frequently-asked-questions'),
'menu_position' => 5,
'show_in_rest' => true,
'rest_base' => 'mjj-faq-api',
'rest_controller_class' => 'WP_REST_Posts_Controller',
)
);
}
public static function add_div( $content ){
if( is_singular( 'mjj_faq' ) ){
$content .= '<div id="mjj-faq"></div>';
}
return $content;
}
}