Skip to content

Commit

Permalink
Merge pull request #1 from brainstormforce/final-changes-before-release
Browse files Browse the repository at this point in the history
- Hide Learndassh button when a custom template is used.
- Hide course materials when a custom template is used.
  • Loading branch information
Nikschavan authored Mar 5, 2018
2 parents 016f1b4 + 2c47fed commit 043c63f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 208 deletions.
17 changes: 4 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Requires at least:** 4.4
**Requires PHP:** 5.3
**Tested up to:** 4.9.4
**Stable tag:** 1.0.1
**Stable tag:** 1.0.0
**License:** GPLv2 or later
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,23 +24,14 @@ Convert the default LearnDash course template that appears for non enrolled stud

## Here is how this plugin works: ##
1. Install & Active the Plugin
2. Add a new Custom Template from the menu that would appear under LearnDash Courses Menu
3. Added Custom Templates will appear in the admin area of all individual courses
4. Select the template for individual course
2. Add a new Custom Template from the menu that would appear under LearnDash LMS Menu.
3. The new Custom Templates will appear in the admin area of all individual courses under option "Select Custom Template for this Course".
4. Select the template for individual course.
5. The default LearnDash template for that individual course will be replaced with the custom template selected in previous step

This plugin currently works best with the <a href="https://wpastra.com/?utm_source=wp-org&utm_medium=readme&utm_campaign=custom-templates-learndash">Astra Theme</a>.

## Changelog ##

### 1.0.2 ###
# Updated plugin name.
# New: Support added for Membership.
# New: Help meta box added in Custom template post.

### 1.0.1 ###
* Support for the Thrive Architect for building the custom course templates.
* Improvement: Load WP Bakery Page Builder's custom CSS along with Astra Theme's CSS instead of Astra Pro's CSS to have wider support.

### 1.0.0 ###
* Initial Release
43 changes: 42 additions & 1 deletion classes/class-ctlearndash.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,41 @@ public static function get_instance() {
* Constructor
*/
private function __construct() {

add_action( 'wp', array( $this, 'override_template_include' ), 999 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 999 );
add_filter( 'astra_page_layout', array( $this, 'astra_page_layout' ), 999 );
add_filter( 'astra_get_content_layout', array( $this, 'content_layout' ), 999 );
add_filter( 'astra_the_title_enabled', array( $this, 'page_title' ), 999 );
add_filter( 'astra_featured_image_enabled', array( $this, 'featured_image' ), 999 );
add_filter( 'body_class', array( $this, 'body_class' ) );
}

/**
* Add class to the body tag if custom template is use for a course.
*
* @param Array $classes class names for the body tag.
* @return Array class names for the body tag.
*/
public function body_class( $classes ) {
// Don't run any code in admin area.
if ( is_admin() ) {
return $classes;
}

// Don't override the template if the post type is not `course`.
if ( ! is_singular( 'sfwd-courses' ) ) {
return $classes;
}

$course_id = learndash_get_course_id();
$user_id = get_current_user_id();
if ( is_user_logged_in() && sfwd_lms_has_access( $course_id, $user_id ) ) {
return $classes;
}

$classes[] = 'custom-template-lifterlms';

return $classes;
}

/**
Expand Down Expand Up @@ -203,6 +231,19 @@ public function enqueue_scripts() {
if ( ! empty( $wpb_custom_css ) ) {
wp_add_inline_style( 'astra-theme-css', $wpb_custom_css );
}

// Custom CSS to hide elements from LearnDash when a custom template is used.
$css = '
.custom-template-lifterlms .btn-join {
display: none;
}
.custom-template-lifterlms #learndash_course_materials {
display: none;
}
';

wp_add_inline_style( 'learndash_style', $css );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion languages/custom-template-learndash.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: Custom Template for LearnDash 1.0.0\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/custom-template-learndash\n"
"POT-Creation-Date: 2018-02-28 09:05:25+00:00\n"
"POT-Creation-Date: 2018-03-05 10:11:41+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down
180 changes: 0 additions & 180 deletions languages/custom-template-lifterlms.pot

This file was deleted.

17 changes: 4 additions & 13 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: liftlms, course, page-buider, beaver builder, elementor, visual composer
Requires at least: 4.4
Requires PHP: 5.3
Tested up to: 4.9.4
Stable tag: 1.0.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -24,23 +24,14 @@ Convert the default LearnDash course template that appears for non enrolled stud

== Here is how this plugin works: ==
1. Install & Active the Plugin
2. Add a new Custom Template from the menu that would appear under LearnDash Courses Menu
3. Added Custom Templates will appear in the admin area of all individual courses
4. Select the template for individual course
2. Add a new Custom Template from the menu that would appear under LearnDash LMS Menu.
3. The new Custom Templates will appear in the admin area of all individual courses under option "Select Custom Template for this Course".
4. Select the template for individual course.
5. The default LearnDash template for that individual course will be replaced with the custom template selected in previous step

This plugin currently works best with the <a href="https://wpastra.com/?utm_source=wp-org&utm_medium=readme&utm_campaign=custom-templates-learndash">Astra Theme</a>.

== Changelog ==

= 1.0.2 =
# Updated plugin name.
# New: Support added for Membership.
# New: Help meta box added in Custom template post.

= 1.0.1 =
* Support for the Thrive Architect for building the custom course templates.
* Improvement: Load WP Bakery Page Builder's custom CSS along with Astra Theme's CSS instead of Astra Pro's CSS to have wider support.

= 1.0.0 =
* Initial Release

0 comments on commit 043c63f

Please sign in to comment.