← All changes
|
inc/Shortcodes/class-lp-shortcode-course-curriculum.php
+59
-59
4.3.9
→
4.4.8
View file →
| @@ -1,59 +1,59 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Register Form Shortcode. | |
| 4 | - * | |
| 5 | - * @author ThimPress | |
| 6 | - * @category Shortcodes | |
| 7 | - * @package Learnpress/Shortcodes | |
| 8 | - * @version 3.0.0 | |
| 9 | - * @extends LP_Abstract_Shortcode | |
| 10 | - */ | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Prevent loading this file directly | |
| 14 | - */ | |
| 15 | -defined( 'ABSPATH' ) || exit(); | |
| 16 | - | |
| 17 | -if ( ! class_exists( 'LP_Shortcode_Course_Curriculum' ) ) { | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * Class LP_Shortcode_Course_Curriculum | |
| 21 | - */ | |
| 22 | - class LP_Shortcode_Course_Curriculum extends LP_Abstract_Shortcode { | |
| 23 | - /** | |
| 24 | - * LP_Shortcode_Course_Curriculum constructor. | |
| 25 | - * | |
| 26 | - * @param mixed $atts | |
| 27 | - */ | |
| 28 | - public function __construct( $atts = '' ) { | |
| 29 | - parent::__construct( $atts ); | |
| 30 | - } | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * Shortcode content. | |
| 34 | - * | |
| 35 | - * @return string | |
| 36 | - */ | |
| 37 | - public function output() { | |
| 38 | - wp_enqueue_style( 'learnpress' ); | |
| 39 | - ob_start(); | |
| 40 | - global $post; | |
| 41 | - $post = get_post( $this->_atts['id'] ); | |
| 42 | - | |
| 43 | - require_once realpath( LP_PLUGIN_PATH . '/inc/course/class-model-user-can-view-course-item.php' ); | |
| 44 | - | |
| 45 | - if ( ! $post || ( LP_COURSE_CPT !== get_post_type( $post->ID ) ) ) { | |
| 46 | - learn_press_display_message( __( 'Invalid course.', 'learnpress' ), 'error' ); | |
| 47 | - } else { | |
| 48 | - setup_postdata( $post ); | |
| 49 | - learn_press_get_template( 'single-course/tabs/curriculum.php' ); | |
| 50 | - wp_reset_postdata(); | |
| 51 | - } | |
| 52 | - | |
| 53 | - $output = ob_get_clean(); | |
| 54 | - | |
| 55 | - return $output; | |
| 56 | - } | |
| 57 | - | |
| 58 | - } | |
| 59 | -} | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Register Form Shortcode. | |
| 4 | + * | |
| 5 | + * @author ThimPress | |
| 6 | + * @category Shortcodes | |
| 7 | + * @package Learnpress/Shortcodes | |
| 8 | + * @version 3.0.0 | |
| 9 | + * @extends LP_Abstract_Shortcode | |
| 10 | + */ | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Prevent loading this file directly | |
| 14 | + */ | |
| 15 | +defined( 'ABSPATH' ) || exit(); | |
| 16 | + | |
| 17 | +if ( ! class_exists( 'LP_Shortcode_Course_Curriculum' ) ) { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Class LP_Shortcode_Course_Curriculum | |
| 21 | + */ | |
| 22 | + class LP_Shortcode_Course_Curriculum extends LP_Abstract_Shortcode { | |
| 23 | + /** | |
| 24 | + * LP_Shortcode_Course_Curriculum constructor. | |
| 25 | + * | |
| 26 | + * @param mixed $atts | |
| 27 | + */ | |
| 28 | + public function __construct( $atts = '' ) { | |
| 29 | + parent::__construct( $atts ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Shortcode content. | |
| 34 | + * | |
| 35 | + * @return string | |
| 36 | + */ | |
| 37 | + public function output() { | |
| 38 | + wp_enqueue_style( 'learnpress' ); | |
| 39 | + ob_start(); | |
| 40 | + global $post; | |
| 41 | + $post = get_post( $this->_atts['id'] ); | |
| 42 | + | |
| 43 | + require_once realpath( LP_PLUGIN_PATH . '/inc/course/class-model-user-can-view-course-item.php' ); | |
| 44 | + | |
| 45 | + if ( ! $post || ( LP_COURSE_CPT !== get_post_type( $post->ID ) ) ) { | |
| 46 | + learn_press_display_message( __( 'Invalid course.', 'learnpress' ), 'error' ); | |
| 47 | + } else { | |
| 48 | + setup_postdata( $post ); | |
| 49 | + learn_press_get_template( 'single-course/tabs/curriculum.php' ); | |
| 50 | + wp_reset_postdata(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + $output = ob_get_clean(); | |
| 54 | + | |
| 55 | + return $output; | |
| 56 | + } | |
| 57 | + | |
| 58 | + } | |
| 59 | +} | |