_atts = shortcode_atts( array( 'id' => 0, 'text' => '', ), $this->_atts ); } /** * Output form. * * @return string */ public function output() { ob_start(); $atts = $this->_atts; if ( 'current' === $atts['id'] ) { $course_id = learn_press_is_course() ? get_the_ID() : 0; } else { $course_id = $atts['id']; } $course = learn_press_get_course( $course_id ); if ( $course_id && $course ) { LP_Global::set_course( $course ); global $post; $post = get_post( $course_id ); setup_postdata( $post ); add_filter( 'learn-press/enroll-course-button-text', array( $this, 'button_text' ) ); learn_press_get_template( 'single-course/buttons/enroll.php', array( 'course' => $course ) ); remove_filter( 'learn-press/enroll-course-button-text', array( $this, 'button_text' ) ); wp_reset_postdata(); LP_Global::reset(); } else { } return ob_get_clean(); } /** * @param string $text * * @return string */ public function button_text( $text ) { if ( $this->_atts['text'] ) { $text = $this->_atts['text']; } return $text; } } }