| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @deprecated since 4.2.9 |
| 5 |
*/ |
| 6 |
class LP_Meta_Box_Question extends LP_Meta_Box { |
| 7 |
|
| 8 |
private static $_instance = null; |
| 9 |
|
| 10 |
public $post_type = LP_QUESTION_CPT; |
| 11 |
|
| 12 |
public function add_meta_box() { |
| 13 |
add_meta_box( 'question_settings', esc_html__( 'Question Settings', 'learnpress' ), array( $this, 'output' ), $this->post_type, 'normal', 'high' ); |
| 14 |
} |
| 15 |
|
| 16 |
public function metabox( $post_id ) { |
| 17 |
return apply_filters( |
| 18 |
'lp/metabox/question/lists', |
| 19 |
array( |
| 20 |
'_lp_mark' => new LP_Meta_Box_Text_Field( |
| 21 |
esc_html__( 'Points', 'learnpress' ), |
| 22 |
esc_html__( 'Points for choosing the correct answer.', 'learnpress' ), |
| 23 |
'1', |
| 24 |
array( |
| 25 |
'type_input' => 'number', |
| 26 |
'custom_attributes' => array( |
| 27 |
'min' => '1', |
| 28 |
'step' => '1', |
| 29 |
), |
| 30 |
'style' => 'width: 60px;', |
| 31 |
) |
| 32 |
), |
| 33 |
'_lp_hint' => new LP_Meta_Box_Textarea_Field( |
| 34 |
esc_html__( 'Hint', 'learnpress' ), |
| 35 |
esc_html__( 'The instructions for the user to select the right answer. The text will be shown when users click the \'Hint\' button.', 'learnpress' ), |
| 36 |
'' |
| 37 |
), |
| 38 |
'_lp_explanation' => new LP_Meta_Box_Textarea_Field( |
| 39 |
esc_html__( 'Explanation', 'learnpress' ), |
| 40 |
esc_html__( 'The explanation will be displayed when students click the "Check Answer" button.', 'learnpress' ), |
| 41 |
'' |
| 42 |
), |
| 43 |
) |
| 44 |
); |
| 45 |
} |
| 46 |
|
| 47 |
public function output( $post ) { |
| 48 |
parent::output( $post ); |
| 49 |
?> |
| 50 |
|
| 51 |
<div class="lp-meta-box lp-meta-box--question"> |
| 52 |
<div class="lp-meta-box__inner"> |
| 53 |
<?php |
| 54 |
do_action( 'learnpress/question-settings/before' ); |
| 55 |
// Check if add_filter to old version. |
| 56 |
$is_old = false; |
| 57 |
|
| 58 |
foreach ( $this->metabox( $post->ID ) as $key => $object ) { |
| 59 |
if ( is_a( $object, 'LP_Meta_Box_Field' ) ) { |
| 60 |
$object->id = $key; |
| 61 |
$output = $object->output( $post->ID ); |
| 62 |
if ( ! empty( $output ) ) { |
| 63 |
echo wp_kses_post( $object->output( $post->ID ) ); |
| 64 |
} |
| 65 |
} elseif ( is_array( $object ) ) { |
| 66 |
$is_old = true; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
if ( $is_old ) { |
| 71 |
lp_meta_box_output( $this->metabox( $post->ID ) ); |
| 72 |
} |
| 73 |
|
| 74 |
do_action( 'learnpress/question-settings/after' ); |
| 75 |
?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
|
| 79 |
<?php |
| 80 |
} |
| 81 |
|
| 82 |
public static function instance() { |
| 83 |
if ( is_null( self::$_instance ) ) { |
| 84 |
self::$_instance = new self(); |
| 85 |
} |
| 86 |
|
| 87 |
return self::$_instance; |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
LP_Meta_Box_Question::instance(); |
| 92 |
|