Skip to content

Commit

Permalink
Merge pull request #4 from brainstormforce/improvement-and-fixes
Browse files Browse the repository at this point in the history
- Fixed: PHP Notice when the Custom Template is selected to None from the courses.
  • Loading branch information
Nikschavan authored Apr 5, 2018
2 parents 404086c + 0ed7247 commit a49eeac
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 71 deletions.
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
**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
**Tested up to:** 4.9.5
**Stable tag:** 1.0.2
**License:** GPLv2 or later
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

The selected custom template will replace default LearnDash course template for non-enrolled students.

## Description ##

This plugin will help you replace default LearnDash course template for non-enrolled students with a custom template. You can design the custom template with any page builder of your choice.
To convert more visitors into students, you need a real sales page for your LearnDash courses. However, most sites just use the default LeanDash page that is not very friendly for conversions. That is because, making a custom sales page is difficult and requires a ton of custom development. But not anymore!

Convert the default LearnDash course template that appears for non enrolled students into a custom designed, sales or landing page.
Now with this plugin, you will be able to design your own conversion friendly, custom sales page for your courses with any page builder. The page will be displayed to only non enrolled students, who have not bought the course.

In nutshell, transform the default LearnDash course template that appears for non enrolled students into a custom designed, sales or landing page and convert more visitors into students!

## Installation ##

Expand All @@ -31,8 +33,29 @@ Convert the default LearnDash course template that appears for non enrolled stud

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>.

## Screenshots ##

### 1. Add a new Custom Template. ###
![Add a new Custom Template.](http://ps.w.org/custom-template-for-learndash/assets/screenshot-1.png)

### 2. Create Template with Any Page Builder of your choice! ###
![Create Template with Any Page Builder of your choice!](http://ps.w.org/custom-template-for-learndash/assets/screenshot-2.png)

### 3. Select the Template for courses. ###
![Select the Template for courses.](http://ps.w.org/custom-template-for-learndash/assets/screenshot-3.png)

### 4. Selected Template for non - enrolled students. ###
![Selected Template for non - enrolled students.](http://ps.w.org/custom-template-for-learndash/assets/screenshot-4.png)

### 5. For enrolled students, the normal course page appears. ###
![For enrolled students, the normal course page appears.](http://ps.w.org/custom-template-for-learndash/assets/screenshot-5.png)


## Changelog ##

### 1.0.2 ###
- Fixed: PHP Notice when the Custom Template is selected to None from the course.

### 1.0.1 ###
- Correctly hide the content added by learndash when custom template is used.

Expand Down
19 changes: 9 additions & 10 deletions admin/class-ctlearndash-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public static function get_instance() {
public function __construct() {

// Activation hook.
register_activation_hook( CTLEARNDASH_FILE, array( $this, 'rewrite_rules' ) );
register_deactivation_hook( CTLEARNDASH_FILE, 'flush_rewrite_rules' );
add_action( 'admin_init', array( $this, 'ctlearndash_initialize' ) );

add_action( 'parent_file', array( $this, 'remove_unwanted_tabs' ) );
add_action( 'init', array( $this, 'learndash_course_landing_page_post_type' ) );
Expand Down Expand Up @@ -116,18 +115,18 @@ public function help_meta_box_callback() {
);
}


/**
* Reset write rules.
* Reset write rules when plugin is activated.
*
* @since 1.0.2
* @return void
*/
public function rewrite_rules() {

$this->learndash_course_landing_page_post_type();

// flush rewrite rules.
flush_rewrite_rules();
public function ctlearndash_initialize() {
if ( is_admin() && get_option( 'ctlearndash_activation' ) === 'is-activated' ) {
delete_option( 'ctlearndash_activation' );
flush_rewrite_rules();
}
}

/**
Expand Down Expand Up @@ -321,7 +320,7 @@ public function save_course_landing_page( $post_id ) {
update_post_meta( $post_id, 'course_template', $landing_page_id );
}
}
} // End if().
}

/**
* Kicking this off by calling 'get_instance()' method
Expand Down
1 change: 0 additions & 1 deletion classes/class-ctlearndash-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ private function includes() {
}

add_action( 'plugins_loaded', 'CTLearnDash_Loader::get_instance' );

94 changes: 47 additions & 47 deletions classes/class-ctlearndash.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function astra_page_layout( $sidebar ) {

$template = self::get_template();

if ( $template ) {
if ( 'none' !== $template && $template ) {
$template_sidebar = get_post_meta( $template, 'site-sidebar-layout', true );
if ( ! empty( $template_sidebar ) && 'default' !== $template_sidebar ) {
$sidebar = $template_sidebar;
Expand All @@ -105,7 +105,7 @@ public function astra_page_layout( $sidebar ) {
public function content_layout( $layout ) {

$template = self::get_template();
if ( $template ) {
if ( 'none' !== $template && $template ) {
$template_layout = get_post_meta( $template, 'site-content-layout', true );
if ( ! empty( $template_layout ) && 'default' !== $template_layout ) {
$layout = $template_layout;
Expand All @@ -124,7 +124,7 @@ public function content_layout( $layout ) {
public function page_title( $status ) {

$template = self::get_template();
if ( $template ) {
if ( 'none' !== $template && $template ) {
$template_status = get_post_meta( $template, 'site-post-title', true );
if ( ! empty( $template_status ) ) {
$status = ( 'disabled' === $template_status ) ? false : true;
Expand All @@ -143,7 +143,7 @@ public function page_title( $status ) {
public function featured_image( $status ) {

$template = self::get_template();
if ( $template && is_singular() ) {
if ( 'none' !== $template && $template && is_singular() ) {
$template_status = get_post_meta( $template, 'ast-featured-img', true );
if ( ! empty( $template_status ) ) {
$status = ( 'disabled' === $template_status ) ? false : true;
Expand Down Expand Up @@ -200,54 +200,56 @@ public function enqueue_scripts() {
}

$template = get_course_meta_setting( get_the_id(), 'learndash_course_template' );
if ( class_exists( '\Elementor\Post_CSS_File' ) ) {
if ( 'none' !== $template && $template ) {
if ( class_exists( '\Elementor\Post_CSS_File' ) ) {

if ( self::is_elementor_activated( $template ) ) {
if ( self::is_elementor_activated( $template ) ) {

$css_file = new \Elementor\Post_CSS_File( $template );
$css_file->enqueue();
}
}

// Check if current layout is built using the thrive architect.
if ( self::is_tve_activated( $template ) ) {

if ( tve_get_post_meta( $template, 'thrive_icon_pack' ) && ! wp_style_is( 'thrive_icon_pack', 'enqueued' ) ) {
TCB_Icon_Manager::enqueue_icon_pack();
$css_file = new \Elementor\Post_CSS_File( $template );
$css_file->enqueue();
}
}

tve_enqueue_extra_resources( $template );
tve_enqueue_style_family( $template );
tve_enqueue_custom_fonts( $template, true );
tve_load_custom_css( $template );
// Check if current layout is built using the thrive architect.
if ( self::is_tve_activated( $template ) ) {

add_filter( 'tcb_enqueue_resources', '__return_true' );
tve_frontend_enqueue_scripts();
remove_filter( 'tcb_enqueue_resources', '__return_true' );
}
if ( tve_get_post_meta( $template, 'thrive_icon_pack' ) && ! wp_style_is( 'thrive_icon_pack', 'enqueued' ) ) {
TCB_Icon_Manager::enqueue_icon_pack();
}

// Add VC style if it is activated.
$wpb_custom_css = get_post_meta( $template, '_wpb_shortcodes_custom_css', true );
if ( ! empty( $wpb_custom_css ) ) {
wp_add_inline_style( 'learndash_style', $wpb_custom_css );
}
tve_enqueue_extra_resources( $template );
tve_enqueue_style_family( $template );
tve_enqueue_custom_fonts( $template, true );
tve_load_custom_css( $template );

// Custom CSS to hide elements from LearnDash when a custom template is used.
$css = '
.custom-template-lifterlms .custom-template-learndash-content .btn-join,
.custom-template-lifterlms .custom-template-learndash-content #learndash_course_status,
.custom-template-lifterlms .custom-template-learndash-content #learndash_course_materials {
display: initial;
add_filter( 'tcb_enqueue_resources', '__return_true' );
tve_frontend_enqueue_scripts();
remove_filter( 'tcb_enqueue_resources', '__return_true' );
}

.custom-template-lifterlms .btn-join,
.custom-template-lifterlms #learndash_course_status,
.custom-template-lifterlms #learndash_course_materials {
display: none;
// Add VC style if it is activated.
$wpb_custom_css = get_post_meta( $template, '_wpb_shortcodes_custom_css', true );
if ( ! empty( $wpb_custom_css ) ) {
wp_add_inline_style( 'learndash_style', $wpb_custom_css );
}
';

wp_add_inline_style( 'learndash_style', $css );
// Custom CSS to hide elements from LearnDash when a custom template is used.
$css = '
.custom-template-lifterlms .custom-template-learndash-content .btn-join,
.custom-template-lifterlms .custom-template-learndash-content #learndash_course_status,
.custom-template-lifterlms .custom-template-learndash-content #learndash_course_materials {
display: initial;
}
.custom-template-lifterlms .btn-join,
.custom-template-lifterlms #learndash_course_status,
.custom-template-lifterlms #learndash_course_materials {
display: none;
}
';

wp_add_inline_style( 'learndash_style', $css );
}
}

/**
Expand All @@ -273,7 +275,7 @@ public function override_template_include() {
return false;
}

add_filter( 'the_content', array( $this, 'render' ) );
add_filter( 'the_content', array( $this, 'render' ), 1001 );
}

/**
Expand All @@ -284,15 +286,13 @@ public function override_template_include() {
*/
public function render( $content ) {

$content = '<div class="custom-template-learndash-content">';
$template = get_course_meta_setting( get_the_id(), 'learndash_course_template' );

if ( $template ) {
if ( 'none' !== $template && $template ) {
$content = '<div class="custom-template-learndash-content">';
$content .= $this->get_action_content( $template );
$content .= '</div>';
}

$content .= '</div>';

return $content;
}

Expand Down
18 changes: 16 additions & 2 deletions custom-template-learndash.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@
* Author URI: https://www.brainstormforce.com/
* Text Domain: custom-template-learndash
* Domain Path: /languages
* Version: 1.0.1
* Version: 1.0.2
*
* @package Custom Template for LearnDash
*/

define( 'CTLEARNDASH_VER', '1.0.1' );
// Set Option to flush the rewrite rule after activation of plugin.
register_activation_hook( __FILE__, 'ctlearndash_activation' );

/**
* Set option that states plugin is activated.
*
* @since 1.0.2
* @return void
*/
function ctlearndash_activation() {
add_option( 'ctlearndash_activation', 'is-activated' );
}

define( 'CTLEARNDASH_VER', '1.0.2' );
define( 'CTLEARNDASH_FILE', __FILE__ );
define( 'CTLEARNDASH_DIR', plugin_dir_path( __FILE__ ) );
define( 'CTLEARNDASH_URL', plugins_url( '/', __FILE__ ) );
define( 'CTLEARNDASH_PATH', plugin_basename( __FILE__ ) );

require_once CTLEARNDASH_DIR . 'classes/class-ctlearndash-loader.php';

4 changes: 2 additions & 2 deletions languages/custom-template-learndash.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# This file is distributed under the same license as the Custom Template for LearnDash package.
msgid ""
msgstr ""
"Project-Id-Version: Custom Template for LearnDash 1.0.1\n"
"Project-Id-Version: Custom Template for LearnDash 1.0.2\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/custom-template-learndash\n"
"POT-Creation-Date: 2018-03-06 11:52:21+00:00\n"
"POT-Creation-Date: 2018-04-04 08:24:57+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-template-learndash",
"version": "1.0.1",
"version": "1.0.2",
"main": "Gruntfile.js",
"author": "YOUR NAME HERE",
"devDependencies": {
Expand Down
21 changes: 17 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ Donate link: https://www.paypal.me/BrainstormForce
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
Tested up to: 4.9.5
Stable tag: 1.0.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

The selected custom template will replace default LearnDash course template for non-enrolled students.

== Description ==

This plugin will help you replace default LearnDash course template for non-enrolled students with a custom template. You can design the custom template with any page builder of your choice.
To convert more visitors into students, you need a real sales page for your LearnDash courses. However, most sites just use the default LeanDash page that is not very friendly for conversions. That is because, making a custom sales page is difficult and requires a ton of custom development. But not anymore!

Convert the default LearnDash course template that appears for non enrolled students into a custom designed, sales or landing page.
Now with this plugin, you will be able to design your own conversion friendly, custom sales page for your courses with any page builder. The page will be displayed to only non enrolled students, who have not bought the course.

In nutshell, transform the default LearnDash course template that appears for non enrolled students into a custom designed, sales or landing page and convert more visitors into students!

== Installation ==

Expand All @@ -31,8 +33,19 @@ Convert the default LearnDash course template that appears for non enrolled stud

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>.

== Screenshots ==

1. Add a new Custom Template.
2. Create Template with Any Page Builder of your choice!
3. Select the Template for courses.
4. Selected Template for non - enrolled students.
5. For enrolled students, the normal course page appears.

== Changelog ==

= 1.0.2 =
- Fixed: PHP Notice when the Custom Template is selected to None from the course.

= 1.0.1 =
- Correctly hide the content added by learndash when custom template is used.

Expand Down

0 comments on commit a49eeac

Please sign in to comment.