class-ld-settings-section-questions-cpt.php
2.84 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 Settings Section for Question Custom Post Type Metabox.
*
* @since 2.6.0
* @package LearnDash\Settings\Sections
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Questions_CPT' ) ) ) {
/**
* Class LearnDash Settings Section for Question Custom Post Type Metabox.
*
* @since 2.6.0
*/
class LearnDash_Settings_Questions_CPT extends LearnDash_Settings_Section {
/**
* Protected constructor for class
*
* @since 2.6.0
*/
protected function __construct() {
// What screen ID are we showing on.
$this->settings_screen_id = 'sfwd-question_page_questions-options';
// The page ID (different than the screen ID).
$this->settings_page_id = 'questions-options';
// This is the 'option_name' key used in the wp_options table.
$this->setting_option_key = 'learndash_settings_questions_cpt';
// This is the HTML form field prefix used.
$this->setting_field_prefix = 'learndash_settings_questions_cpt';
// Used within the Settings API to uniquely identify this section.
$this->settings_section_key = 'cpt_options';
// Section label/header.
$this->settings_section_label = sprintf(
// translators: placeholder: Quiz.
esc_html_x( '%s Custom Post Type Options', 'placeholder: Question', 'learndash' ),
LearnDash_Custom_Label::get_label( 'question' )
);
// Used to show the section description above the fields. Can be empty.
$this->settings_section_description = sprintf(
// translators: placeholder: Quizzes.
esc_html_x( 'Control the LearnDash %s Custom Post Type Options.', 'placeholder: Questions', 'learndash' ),
LearnDash_Custom_Label::get_label( 'questions' )
);
parent::__construct();
}
/**
* Initialize the metabox settings fields.
*
* @since 2.6.0
*/
public function load_settings_fields() {
$this->setting_option_fields = array(
'exclude_from_search' => array(
'name' => 'exclude_from_search',
'type' => 'checkbox',
'label' => esc_html__( 'Exclude From Search', 'learndash' ),
'help_text' => esc_html__( 'Exclude From Search', 'learndash' ),
'value' => isset( $this->setting_option_values['exclude_from_search'] ) ? $this->setting_option_values['exclude_from_search'] : '',
'options' => array(
'yes' => esc_html__( 'Exclude', 'learndash' ),
),
),
);
/** This filter is documented in includes/settings/settings-metaboxes/class-ld-settings-metabox-course-access-settings.php */
$this->setting_option_fields = apply_filters( 'learndash_settings_fields', $this->setting_option_fields, $this->settings_section_key );
parent::load_settings_fields();
}
}
}
add_action(
'learndash_settings_sections_init',
function() {
LearnDash_Settings_Questions_CPT::add_section_instance();
}
);