class-learndash-admin-coupon-edit.php
1.91 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
<?php
/**
* LearnDash Admin Coupon Edit.
*
* @since 4.1.0
* @package LearnDash\Coupon\Edit
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if (
class_exists( 'Learndash_Admin_Post_Edit' ) &&
! class_exists( 'Learndash_Admin_Coupon_Edit' )
) {
/**
* Class LearnDash Admin Coupon Edit.
*
* @since 4.1.0
* @uses Learndash_Admin_Post_Edit
*/
class Learndash_Admin_Coupon_Edit extends Learndash_Admin_Post_Edit {
/**
* Public constructor for class.
*
* @since 4.1.0
*/
public function __construct() {
$this->post_type = learndash_get_post_type_slug(
LDLMS_Post_Types::COUPON
);
parent::__construct();
}
/**
* On Load handler function for this post type edit.
* This function is called by a WP action when the admin
* page 'post.php' or 'post-new.php' are loaded.
*
* @since 4.1.0
*/
public function on_load() {
if ( $this->post_type_check() ) {
require_once LEARNDASH_LMS_PLUGIN_DIR . 'includes/settings/settings-metaboxes/class-ld-settings-metabox-coupon-settings.php';
parent::on_load();
}
}
/**
* Save metabox handler function.
*
* @since 4.1.0
*
* @param integer $post_id Post ID Question being edited.
* @param WP_Post $post WP_Post Question being edited.
* @param boolean $update If update true, else false.
*
* @return bool
*/
public function save_post( $post_id = 0, $post = null, $update = false ): bool {
if ( ! $this->post_type_check( $post ) ) {
return false;
}
if ( ! parent::save_post( $post_id, $post, $update ) ) {
return false;
}
if ( empty( $this->_metaboxes ) ) {
return true;
}
foreach ( $this->_metaboxes as $metabox ) {
$settings_fields = $metabox->get_post_settings_field_updates(
$post_id,
$post,
$update
);
$metabox->save_post_meta_box( $post_id, $post, $update, $settings_fields );
}
return true;
}
}
}
new Learndash_Admin_Coupon_Edit();