-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexam.php
More file actions
96 lines (88 loc) · 2.45 KB
/
exam.php
File metadata and controls
96 lines (88 loc) · 2.45 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
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
<?php
/**
* Plugin Name: Exam Management
* Plugin URI: https://example.com
* Description: A WordPress plugin for screening senior developer applicants with custom post types for students, exams, results.
* Version: 1.0.0
* Author: Your Name
* Author URI: https://example.com
* License: GPL-2.0+
*/
// Define constants
define( 'EM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'EM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Custom Post Types and Taxonomy
class EM_CPT {
public static function init() {
add_action( 'init', array( __CLASS__, 'register_cpts' ) );
add_action( 'init', array( __CLASS__, 'register_taxonomy' ) );
}
public static function register_cpts() {
// Students CPT
register_post_type( 'em_student', array(
'labels' => array(
'name' => 'Students',
'singular_name' => 'Student',
),
'public' => true,
'capability_type' => 'post',
'supports' => array( 'title', 'editor' ),
'menu_icon' => 'dashicons-groups',
'show_in_rest' => true,
) );
// Subjects CPT
register_post_type( 'em_subject', array(
'labels' => array(
'name' => 'Subjects',
'singular_name' => 'Subject',
),
'public' => true,
'capability_type' => 'post',
'supports' => array( 'title' ),
'menu_icon' => 'dashicons-book-alt',
'show_in_rest' => true,
) );
// Exams CPT
register_post_type( 'em_exam', array(
'labels' => array(
'name' => 'Exams',
'singular_name' => 'Exam',
),
'public' => true,
'capability_type' => 'post',
'supports' => array( 'title', 'editor' ),
'menu_icon' => 'dashicons-book',
'show_in_rest' => true,
) );
// Results CPT
register_post_type( 'em_result', array(
'labels' => array(
'name' => 'Results',
'singular_name' => 'Result',
),
'public' => true,
'capability_type' => 'post',
'supports' => array( 'title' ),
'menu_icon' => 'dashicons-performance',
'show_in_rest' => true,
) );
}
public static function register_taxonomy() {
// Terms Taxonomy
register_taxonomy( 'em_term', array( 'em_exam' ), array(
'labels' => array(
'name' => 'Terms',
'singular_name' => 'Term',
),
'public' => true,
'hierarchical' => false,
'show_ui' => true,
'show_in_rest' => true,
) );
}
}
// Initialize plugin
function em_init() {
EM_CPT::init();
}
add_action( 'plugins_loaded', 'em_init' );