| @@ -17,13 +17,16 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | public function __construct() { |
| 19 | 19 | $this->includes(); |
| 20 | 20 | |
| 21 | + // @since 4.0.0 | |
| 21 | 22 | add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); |
| 23 | + // @since 4.2.7 | |
| 24 | + add_action( 'add_meta_boxes', array( $this, '_do_add_meta_boxes' ), 10, 2 ); | |
| 22 | 25 | add_action( 'save_post', array( $this, 'save_meta_boxes' ), 100, 2 ); |
| 23 | 26 | add_action( 'learnpress_save_' . $this->post_type . '_metabox', array( $this, 'save' ) ); |
| 24 | 27 | |
| 25 | - add_action( 'learnpress_save_lp_course_metabox', 'LP_Meta_Box_Course::save_eduma_child_metabox_v3', 10 ); | |
| 28 | + //add_action( 'learnpress_save_lp_course_metabox', 'LP_Meta_Box_Course::save_eduma_child_metabox_v3', 10 ); | |
| 26 | 29 | } |
| 27 | 30 | |
| 28 | 31 | // Include fields. |
| 29 | 32 | public function includes() { |
| @@ -40,13 +43,46 @@ | ||
| 40 | 43 | include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/fields/date.php'; |
| 41 | 44 | include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/fields/wysiwyg.php'; |
| 42 | 45 | include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/fields/repeater.php'; |
| 43 | 46 | include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/fields/autocomplete.php'; |
| 47 | + include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/fields/materials.php'; | |
| 44 | 48 | include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/lp-meta-box-functions.php'; |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | - public function add_meta_box() {} | |
| 51 | + public function add_meta_box() { | |
| 52 | + // Implement from child | |
| 53 | + } | |
| 48 | 54 | |
| 55 | + /** | |
| 56 | + * Handle call method add meta boxes | |
| 57 | + * | |
| 58 | + * @param $post_type | |
| 59 | + * @param $post | |
| 60 | + * | |
| 61 | + * @return void | |
| 62 | + * @since 4.2.7 | |
| 63 | + */ | |
| 64 | + final public function _do_add_meta_boxes( $post_type, $post ) { | |
| 65 | + if ( $post_type !== $this->post_type ) { | |
| 66 | + return; | |
| 67 | + } | |
| 68 | + | |
| 69 | + $this->add_meta_boxes( $post ); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Method for add meta boxes | |
| 74 | + * | |
| 75 | + * @param $post | |
| 76 | + * | |
| 77 | + * @return void | |
| 78 | + * @since 4.2.7 | |
| 79 | + */ | |
| 80 | + public function add_meta_boxes( $post ) { | |
| 81 | + // Implement from child | |
| 82 | + } | |
| 83 | + | |
| 84 | + | |
| 49 | 85 | public function metabox( $post_id ) { |
| 50 | 86 | return array(); |
| 51 | 87 | } |
| 52 | 88 | |
| @@ -89,7 +125,12 @@ | ||
| 89 | 125 | } |
| 90 | 126 | |
| 91 | 127 | self::$saved_meta_boxes = true; |
| 92 | 128 | |
| 129 | + //TODO: Not apply for course, | |
| 130 | + // but on theme custom fields course is using this hook. Need change how to hook on theme. | |
| 131 | + /*if ( $post->post_type === LP_COURSE_CPT ) { | |
| 132 | + return; | |
| 133 | + }*/ | |
| 93 | 134 | do_action( 'learnpress_save_' . $post->post_type . '_metabox', $post_id, $post ); |
| 94 | 135 | } |
| 95 | 136 | } |