Skip to content

Commit 77f3b7d

Browse files
Merge pull request #356 from lightspeeddevelopment/add/355
Added compatibility for Sensei 3.0 new features.
2 parents 92115e1 + d273a59 commit 77f3b7d

File tree

9 files changed

+62
-16
lines changed

9 files changed

+62
-16
lines changed

assets/css/sensei/maps/sensei.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/sensei/sensei.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/sensei/sensei.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ article.page {
388388
padding-right: 10px;
389389
}
390390
&.currently-in-course {
391-
.course-products {
391+
.course-products,
392+
.single_add_to_cart_button {
392393
display: none;
393394
}
394395
}
@@ -501,6 +502,13 @@ article.page {
501502
order: 3;
502503
.button.view-results {
503504
margin-left: 0;
505+
@include lsx-button-scaffolding();
506+
@include small-button();
507+
@include lsx-button-colour();
508+
margin-left: $lsx-gap;
509+
&:hover {
510+
@extend %button-hover;
511+
}
504512
}
505513
form {
506514
width: 100%;
@@ -588,6 +596,12 @@ article.page {
588596
margin-right: auto;
589597
.course {
590598
margin-bottom: 0;
599+
&.user-status-active,
600+
&.user-status-completed {
601+
.single_add_to_cart_button {
602+
display: none;
603+
}
604+
}
591605
//@include media('<tablet') {
592606
display: flex;
593607
flex-direction: column;

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# LSX Change log
22

3-
# [[2.7.1]] - In Development
3+
# [[2.8.0]] - 2020-05-21
44

55
### Added
66
- One new hooks/actions added in layouts: `lsx_entry_inside_top` to hook into a page content.
77
- WooCommerce 4.1 compatibility.
88
- Adding Yoast 14.0.+ compatibility.
9+
- Added compatibility for LSX Banners for Sensei single lessons.
910

1011
### Changed
1112
- Woocommerce Cart, Checkout, Thank You and Restricted styling improved.
1213
- Layout changed on Cart, Checkout, Thank You and Restricted woocommerce pages.
14+
- Updated Sensei related functions to replace deprecated functions.
1315

1416
### Fixed
1517
- Fixed issue #346 'If LSX banners is not enabled there is a simple banner showing on each page.'.
1618
- Body class `using-gutenberg` affecting other custom post type single pages was removed from any custom post type single page.
19+
- Fixed a few styling issues related to Sensei templates.
20+
21+
### Security
22+
- Testing compatibility with WordPress 5.4.1
1723

1824

1925
## [[2.7.0]](https://github.com/lightspeeddevelopment/lsx/releases/tag/2.7.0) - 2020-03-30

functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
exit;
1212
}
1313

14-
define( 'LSX_VERSION', '2.7' );
14+
define( 'LSX_VERSION', '2.8' );
1515

1616
if ( class_exists( 'WooCommerce' ) ) {
1717
require get_template_directory() . '/includes/woocommerce/woocommerce.php';

includes/layout.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ function lsx_global_header() {
187187
}
188188

189189
if ( is_page() && ( 'page' !== $show_on_front || ! is_front_page() ) ) :
190-
?>
190+
if ( class_exists( 'LSX_Banners' ) && empty( apply_filters( 'lsx_banner_plugin_disable', false ) && ( ! has_post_thumbnail() ) ) ) {
191+
return;
192+
}
193+
?>
191194
<div class="archive-header-wrapper banner-page col-<?php echo esc_attr( $size ); ?>-12">
192195
<?php lsx_global_header_inner_bottom(); ?>
193196
<header class="archive-header">
@@ -196,6 +199,7 @@ function lsx_global_header() {
196199

197200
</div>
198201
<?php
202+
199203
elseif ( is_single() && ! is_singular( 'post' ) ) :
200204
?>
201205
<div class="archive-header-wrapper banner-single col-<?php echo esc_attr( $size ); ?>-12">

includes/sensei/class-lsx-sensei-course.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function get_course_thumbnail() {
9898
*/
9999
public function course_body_div_open() {
100100
global $post, $current_user;
101-
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
101+
$is_user_taking_course = Sensei_Utils::has_started_course( $post->ID, $current_user->ID );
102102
$user_taking_course_class = '';
103103
if ( ! empty( $is_user_taking_course ) ) {
104104
$user_taking_course_class = 'currently-in-course';
@@ -148,16 +148,17 @@ public function course_body_div_results_close() {
148148
*/
149149
public function display_course_amount() {
150150
global $post, $current_user;
151-
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
152-
$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
153-
$course_purchasable = '';
151+
$is_user_taking_course = Sensei_Course::is_user_enrolled( $post->ID, $current_user->ID );
152+
$is_user_starting_course = Sensei_Utils::has_started_course( $post->ID, $current_user->ID );
153+
$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
154+
$course_purchasable = '';
154155
if ( class_exists( 'Sensei_WC' ) ) {
155156
$course_purchasable = Sensei_WC::is_course_purchasable( $post->ID );
156157
$currency = get_woocommerce_currency_symbol();
157158
$product = new WC_Product( $wc_post_id );
158-
if ( ( ! empty( $product->get_price() ) ) && ( ! $is_user_taking_course ) ) {
159+
if ( ( ! empty( $product->get_price() ) ) && ( ( ! $is_user_taking_course ) || ( ! $is_user_starting_course ) ) ) {
159160
echo '<span class="course-product-price price"><span>' . esc_html( $currency ) . ' </span>' . sprintf( '%0.2f', esc_html( $product->get_price() ) ) . '</span>';
160-
} elseif ( ( '' === $product->get_price() || 0 == $product->get_price() ) && $course_purchasable ) {
161+
} elseif ( ( '' === $product->get_price() || 0 == $product->get_price() ) && $course_purchasable && ( ( ! $is_user_taking_course ) || ( ! $is_user_starting_course ) ) ) {
161162
echo '<span class="course-product-price price">' . wp_kses_post( 'Free!', 'lsx' ) . '</span>';
162163
}
163164
}

includes/sensei/class-lsx-sensei.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function __construct() {
6060

6161
add_filter( 'get_the_archive_title', array( $this, 'lsx_sensei_modify_archive_title' ), 99, 1 );
6262

63+
add_filter( 'lsx_banner_allowed_post_types', array( $this, 'lsx_banner_allowed_post_types_sensei' ) );
64+
6365
// LSX.
6466
add_filter( 'lsx_global_header_disable', array( $this, 'lsx_sensei_disable_lsx_banner' ) );
6567
// LSX Banners - Plugin, Placeholders.
@@ -189,13 +191,21 @@ public function lsx_sensei_modify_archive_title( $title ) {
189191
* @subpackage sensei
190192
*/
191193
public function lsx_sensei_disable_lsx_banner( $disabled ) {
192-
if ( is_sensei() ) {
194+
if ( is_sensei() && ( ! is_singular( 'lesson' ) ) ) {
193195
$disabled = true;
194196
}
195197

196198
return $disabled;
197199
}
198200

201+
/**
202+
* Enable project custom post type on LSX Banners.
203+
*/
204+
public function lsx_banner_allowed_post_types_sensei( $post_types ) {
205+
$post_types[] = 'lesson';
206+
return $post_types;
207+
}
208+
199209
/**
200210
* Filters the archive title.
201211
*
@@ -226,7 +236,7 @@ public function lsx_sensei_category_title( $html ) {
226236
*/
227237
public function lsx_sensei_add_buttons( $course_id ) {
228238
global $post, $current_user;
229-
$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
239+
$is_user_taking_course = Sensei_Course::is_user_enrolled( $post->ID, $current_user->ID );
230240
$course_purchasable = '';
231241
if ( class_exists( 'Sensei_WC' ) ) {
232242
$course_purchasable = Sensei_WC::is_course_purchasable( $post->ID );
@@ -250,7 +260,18 @@ public function lsx_sensei_add_buttons( $course_id ) {
250260
* @subpackage sensei
251261
*/
252262
public function lsx_sensei_add_to_cart_text( $text ) {
263+
global $post, $current_user;
264+
$is_user_taking_course = Sensei_Utils::has_started_course( $post->ID, $current_user->ID );
265+
$is_course_on_cart = Sensei_WC::is_course_in_cart( $post->ID, $current_user->ID );
266+
253267
$text = esc_html__( 'Add to cart', 'lsx' );
268+
269+
if ( ( $is_user_taking_course ) ) {
270+
return;
271+
}
272+
if ( ( $is_course_on_cart ) ) {
273+
$text = esc_html__( 'Course added to cart', 'lsx' );
274+
}
254275
return $text;
255276
}
256277

readme.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: feedmymedia
33
Donate link: https://donate.lsdev.biz/
44
Tags: LSX Theme, Gutenberg, Block Based Builder, WordPress Theme
55
Requires at least: 5.1.1
6-
Tested up to: 5.4
6+
Tested up to: 5.4.1
77
Requires PHP: 7.0
8-
Stable tag: 2.7
8+
Stable tag: 2.8
99
License: GPLv3
1010
Licence URI: https://www.gnu.org/licenses/gpl-3.0.en.html
1111

0 commit comments

Comments
 (0)