| @@ -1,92 +1,92 @@ | ||
| 1 | -<?php | |
| 2 | -class LP_Meta_Box_Lesson extends LP_Meta_Box { | |
| 3 | - | |
| 4 | - private static $_instance = null; | |
| 5 | - | |
| 6 | - public $post_type = LP_LESSON_CPT; | |
| 7 | - | |
| 8 | - public function add_meta_box() { | |
| 9 | - add_meta_box( 'lesson_settings', esc_html__( 'Lesson Settings', 'learnpress' ), array( $this, 'output' ), $this->post_type, 'normal', 'high' ); | |
| 10 | - } | |
| 11 | - | |
| 12 | - public function metabox( $post_id = 0 ) { | |
| 13 | - return apply_filters( | |
| 14 | - 'lp/metabox/lesson/lists', | |
| 15 | - array( | |
| 16 | - '_lp_duration' => new LP_Meta_Box_Duration_Field( | |
| 17 | - esc_html__( 'Duration', 'learnpress' ), | |
| 18 | - '', | |
| 19 | - '0', | |
| 20 | - array( | |
| 21 | - 'default_time' => 'minute', | |
| 22 | - 'custom_attributes' => array( | |
| 23 | - 'min' => '0', | |
| 24 | - 'step' => '1', | |
| 25 | - ), | |
| 26 | - ) | |
| 27 | - ), | |
| 28 | - '_lp_preview' => new LP_Meta_Box_Checkbox_Field( | |
| 29 | - esc_html__( 'Preview', 'learnpress' ), | |
| 30 | - esc_html__( 'Students can view this lesson content without taking the course.', 'learnpress' ), | |
| 31 | - 'no' | |
| 32 | - ), | |
| 33 | - ) | |
| 34 | - ); | |
| 35 | - } | |
| 36 | - | |
| 37 | - public function output( $post ) { | |
| 38 | - parent::output( $post ); | |
| 39 | - ?> | |
| 40 | - | |
| 41 | - <div class="lp-meta-box lp-meta-box--lesson"> | |
| 42 | - <div class="lp-meta-box__inner"> | |
| 43 | - <?php | |
| 44 | - do_action( 'learnpress/lesson-settings/before' ); | |
| 45 | - // Check if add_filter to old version. | |
| 46 | - $is_old = false; | |
| 47 | - | |
| 48 | - foreach ( $this->metabox( $post->ID ) as $key => $object ) { | |
| 49 | - if ( is_a( $object, 'LP_Meta_Box_Field' ) ) { | |
| 50 | - $object->id = $key; | |
| 51 | - $output = $object->output( $post->ID ); | |
| 52 | - if ( ! empty( $output ) ) { | |
| 53 | - learn_press_echo_vuejs_write_on_php( $object->output( $post->ID ) ); | |
| 54 | - } | |
| 55 | - } elseif ( is_array( $object ) ) { | |
| 56 | - $is_old = true; | |
| 57 | - } | |
| 58 | - } | |
| 59 | - ?> | |
| 60 | - <style type="text/css"> .lesson-materials{display: flex; flex-direction: row; flex-wrap: nowrap; } .field-material__label{width: 180px; max-width: 180px; min-width: 180px; } .field-material__label label{color: #23282d; font-size: 14px; font-weight: 600; flex: 0 0 auto; } </style> | |
| 61 | - <div class="lesson-materials"> | |
| 62 | - <div class="field-material__label"> | |
| 63 | - <label><?php echo __( 'Materials', 'learnpress' ); ?></label> | |
| 64 | - </div> | |
| 65 | - <?php | |
| 66 | - $material = new LP_Meta_Box_Material_Fields(); | |
| 67 | - $material->output( $post->ID ); | |
| 68 | - ?> | |
| 69 | - </div> | |
| 70 | - <?php | |
| 71 | - if ( $is_old ) { | |
| 72 | - lp_meta_box_output( $this->metabox( $post->ID ) ); | |
| 73 | - } | |
| 74 | - | |
| 75 | - do_action( 'learnpress/lesson-settings/after' ); | |
| 76 | - ?> | |
| 77 | - </div> | |
| 78 | - </div> | |
| 79 | - | |
| 80 | - <?php | |
| 81 | - } | |
| 82 | - | |
| 83 | - public static function instance() { | |
| 84 | - if ( is_null( self::$_instance ) ) { | |
| 85 | - self::$_instance = new self(); | |
| 86 | - } | |
| 87 | - | |
| 88 | - return self::$_instance; | |
| 89 | - } | |
| 90 | -} | |
| 91 | - | |
| 92 | -LP_Meta_Box_Lesson::instance(); | |
| 1 | +<?php | |
| 2 | +class LP_Meta_Box_Lesson extends LP_Meta_Box { | |
| 3 | + | |
| 4 | + private static $_instance = null; | |
| 5 | + | |
| 6 | + public $post_type = LP_LESSON_CPT; | |
| 7 | + | |
| 8 | + public function add_meta_box() { | |
| 9 | + add_meta_box( 'lesson_settings', esc_html__( 'Lesson Settings', 'learnpress' ), array( $this, 'output' ), $this->post_type, 'normal', 'high' ); | |
| 10 | + } | |
| 11 | + | |
| 12 | + public function metabox( $post_id = 0 ) { | |
| 13 | + return apply_filters( | |
| 14 | + 'lp/metabox/lesson/lists', | |
| 15 | + array( | |
| 16 | + '_lp_duration' => new LP_Meta_Box_Duration_Field( | |
| 17 | + esc_html__( 'Duration', 'learnpress' ), | |
| 18 | + '', | |
| 19 | + '0', | |
| 20 | + array( | |
| 21 | + 'default_time' => 'minute', | |
| 22 | + 'custom_attributes' => array( | |
| 23 | + 'min' => '0', | |
| 24 | + 'step' => '1', | |
| 25 | + ), | |
| 26 | + ) | |
| 27 | + ), | |
| 28 | + '_lp_preview' => new LP_Meta_Box_Checkbox_Field( | |
| 29 | + esc_html__( 'Preview', 'learnpress' ), | |
| 30 | + esc_html__( 'Students can view this lesson content without taking the course.', 'learnpress' ), | |
| 31 | + 'no' | |
| 32 | + ), | |
| 33 | + ) | |
| 34 | + ); | |
| 35 | + } | |
| 36 | + | |
| 37 | + public function output( $post ) { | |
| 38 | + parent::output( $post ); | |
| 39 | + ?> | |
| 40 | + | |
| 41 | + <div class="lp-meta-box lp-meta-box--lesson"> | |
| 42 | + <div class="lp-meta-box__inner"> | |
| 43 | + <?php | |
| 44 | + do_action( 'learnpress/lesson-settings/before', $post ); | |
| 45 | + // Check if add_filter to old version. | |
| 46 | + $is_old = false; | |
| 47 | + | |
| 48 | + foreach ( $this->metabox( $post->ID ) as $key => $object ) { | |
| 49 | + if ( is_a( $object, 'LP_Meta_Box_Field' ) ) { | |
| 50 | + $object->id = $key; | |
| 51 | + $output = $object->output( $post->ID ); | |
| 52 | + if ( ! empty( $output ) ) { | |
| 53 | + learn_press_echo_vuejs_write_on_php( $object->output( $post->ID ) ); | |
| 54 | + } | |
| 55 | + } elseif ( is_array( $object ) ) { | |
| 56 | + $is_old = true; | |
| 57 | + } | |
| 58 | + } | |
| 59 | + ?> | |
| 60 | + <style type="text/css"> .lesson-materials{display: flex; flex-direction: row; flex-wrap: nowrap; } .field-material__label{width: 180px; max-width: 180px; min-width: 180px; } .field-material__label label{color: #23282d; font-size: 14px; font-weight: 600; flex: 0 0 auto; } </style> | |
| 61 | + <div class="lesson-materials"> | |
| 62 | + <div class="field-material__label"> | |
| 63 | + <label><?php echo __( 'Materials', 'learnpress' ); ?></label> | |
| 64 | + </div> | |
| 65 | + <?php | |
| 66 | + $material = new LP_Meta_Box_Material_Fields(); | |
| 67 | + $material->output( $post->ID ); | |
| 68 | + ?> | |
| 69 | + </div> | |
| 70 | + <?php | |
| 71 | + if ( $is_old ) { | |
| 72 | + lp_meta_box_output( $this->metabox( $post->ID ) ); | |
| 73 | + } | |
| 74 | + | |
| 75 | + do_action( 'learnpress/lesson-settings/after', $post ); | |
| 76 | + ?> | |
| 77 | + </div> | |
| 78 | + </div> | |
| 79 | + | |
| 80 | + <?php | |
| 81 | + } | |
| 82 | + | |
| 83 | + public static function instance() { | |
| 84 | + if ( is_null( self::$_instance ) ) { | |
| 85 | + self::$_instance = new self(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + return self::$_instance; | |
| 89 | + } | |
| 90 | +} | |
| 91 | + | |
| 92 | +LP_Meta_Box_Lesson::instance(); | |