PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / Gutenberg / Blocks / Legacy / SingleCourseBlockLegacy.php

SingleCourseBlockLegacy.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at inc/Gutenberg/Blocks/Legacy/SingleCourseBlockLegacy.php

66 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace LearnPress\Gutenberg\Blocks\Legacy;
4
5 use LearnPress\Gutenberg\Blocks\AbstractBlockType;
6 use LearnPress\Helpers\Template;
7 use LearnPress\Models\CourseModel;
8 use LP_Settings;
9
10 /**
11 * Class SingleCourseBlockLegacy
12 *
13 * Handle register, render block template
14 */
15 class SingleCourseBlockLegacy extends AbstractBlockType {
16 public $block_name = 'single-course-legacy';
17
18 /**
19 * Render content of block tag
20 *
21 * @param array $attributes | Attributes of block tag.
22 *
23 * @return false|string
24 */
25 public function render_content_block_template( array $attributes, $content, $block ): string {
26 wp_enqueue_style( 'learnpress' );
27 $html = '';
28 global $wp;
29 $object = get_queried_object();
30 $vars = $wp->query_vars;
31 // Todo: For item course current display on post_type course
32 // After when handle display item course on correct post_type item, remove this code.
33 $page_template = '';
34 if ( ! empty( $vars['course-item'] ) ) {
35 global $post;
36 setup_postdata( $post );
37 $page_template = 'content-single-item.php';
38 } elseif ( $object ) {
39 $course = CourseModel::find( $object->ID, true );
40
41 $page_template = 'single-course-layout.php';
42
43 // Check condition to load single course layout classic or modern.
44 $is_override_single_course = Template::check_template_is_override( 'single-course.php' );
45 $option_single_course_layout = LP_Settings::get_option( 'layout_single_course', '' );
46
47 // Old single course layout.
48 //$page_template = 'single-course.php';
49
50 if ( $course && $course->is_offline() ) {
51 $page_template = 'single-course-offline.php';
52 }
53 }
54
55 if ( $page_template === '' ) {
56 return '';
57 }
58
59 ob_start();
60 Template::instance()->get_frontend_template( $page_template, compact( 'attributes' ) );
61 $html = ob_get_clean();
62
63 return $html;
64 }
65 }
66