class-ld-rest-exams-controller.php
1.74 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
<?php
/**
* LearnDash REST API V2 Exams Post Controller.
*
* This Controller class is used to GET/UPDATE/DELETE the LearnDash
* custom post type exams (ld-exam).
*
* This class extends the LD_REST_Posts_Controller_V2 class.
*
* @since 4.0.0
* @package LearnDash\REST\V2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ( ! class_exists( 'LD_REST_Exams_Controller_V2' ) ) && ( class_exists( 'LD_REST_Posts_Controller_V2' ) ) ) {
/**
* Class LearnDash REST API V2 Exams Post Controller.
*
* @since 4.0.0
* @uses LD_REST_Posts_Controller_V2
*/
class LD_REST_Exams_Controller_V2 extends LD_REST_Posts_Controller_V2 /* phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound */ {
/**
* Public constructor for class
*
* @since 4.0.0
*
* @param string $post_type Post type.
*/
public function __construct( $post_type = '' ) {
if ( empty( $post_type ) ) {
$post_type = learndash_get_post_type_slug( 'exam' );
}
$this->post_type = $post_type;
$this->metaboxes = array();
parent::__construct( $this->post_type );
/**
* Set the rest_base after the parent __constructor
* as it will set these var with WP specific details.
*/
$this->rest_base = $this->get_rest_base( 'exams' );
}
/**
* Prepare the LearnDash Post Type Settings.
*
* @since 4.0.0
*/
protected function register_fields() {
$this->register_fields_metabox();
do_action( 'learndash_rest_register_fields', $this->post_type, $this );
}
/**
* Gets public schema.
*
* @since 4.0.0
*
* @return array
*/
public function get_public_item_schema() {
$schema = parent::get_public_item_schema();
$schema['title'] = 'exam';
return $schema;
}
// End of functions.
}
}