Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom templates created using Divi Builder #7

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions classes/class-ctlearndash.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static function get_template() {
return false;
}

$template = get_course_meta_setting( get_the_id(), 'learndash_course_template' );
$template = learndash_get_course_meta_setting( get_the_id(), 'learndash_course_template' );
if ( '' === $template ) {
return false;
}
Expand All @@ -199,7 +199,7 @@ public function enqueue_scripts() {
return false;
}

$template = get_course_meta_setting( get_the_id(), 'learndash_course_template' );
$template = learndash_get_course_meta_setting( get_the_id(), 'learndash_course_template' );
if ( 'none' !== $template && $template ) {

if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
Expand Down Expand Up @@ -286,7 +286,7 @@ public function override_template_include() {
*/
public function render( $content ) {

$template = get_course_meta_setting( get_the_id(), 'learndash_course_template' );
$template = learndash_get_course_meta_setting( get_the_id(), 'learndash_course_template' );
if ( 'none' !== $template && $template ) {
$content = '<div class="custom-template-learndash-content">';
$content .= $this->get_action_content( $template );
Expand Down Expand Up @@ -355,6 +355,13 @@ public function get_action_content( $post_id ) {
return ob_get_clean();
}

if ( self::is_divi_activated( $post_id ) ) {
ob_start();
echo '<div id="et-boc" class="et-boc">' . apply_filters( 'the_content', $post->post_content ) . '</div>'; // WPCS: XSS OK.
wp_reset_postdata();
return ob_get_clean();
}

ob_start();
echo do_shortcode( $post->post_content );
wp_reset_postdata();
Expand Down Expand Up @@ -422,6 +429,20 @@ public static function is_tve_activated( $id ) {
}
}

/**
* Check if Divi is activated n the layout.
*
* @param int $id Post id.
* @return boolean
*/
public static function is_divi_activated( $id ) {
if ( function_exists( 'et_pb_is_pagebuilder_used' ) && et_pb_is_pagebuilder_used( $id ) ) {
return true;
}

return false;
}

}
}

Expand Down
Loading