Skip to content

Commit

Permalink
fix issues with empty access plans
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasplevy committed Feb 28, 2019
1 parent 2586f19 commit 8e29aae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
LifterLMS Changelog
===================

v3.29.1 - 2019-02-27
--------------------

+ Automatically reorder access plans when a plan is deleted.
+ Skip (don't create) empty plans passed to the access plan save method as a result of deleted access plans.


v3.29.0 - 2019-02-27
--------------------

Expand Down
11 changes: 8 additions & 3 deletions assets/js/llms-metabox-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Product Options MetaBox
* Displays on Course & Membership Post Types
* @since 3.0.0
* @version 3.29.0
* @version 3.29.1
*/
( function( $ ) {

Expand Down Expand Up @@ -308,7 +308,7 @@
* @param obj $btn jQuery selector of the "X" button clicked to initiate deletion
* @return void
* @since 3.0.0
* @version 3.29.0
* @version 3.29.1
*/
this.delete_plan = function( $btn ) {

Expand All @@ -332,10 +332,15 @@
plan_id: plan_id,
},
success: function( r ) {
LLMS.Spinner.stop( $plan );
setTimeout( function() {
LLMS.Spinner.stop( $plan );
}, 550 );
if ( r.success ) {
self.remove_plan_el( $plan );
self.trigger_update_hook();
setTimeout( function() {
self.update_plan_orders();
}, 500 );
} else if ( r.message ) {
alert( r.message );
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/llms-metabox-product.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion includes/class.llms.ajax.handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ public static function llms_builder( $request ) {
* @param array $request $_POST data.
* @return array
* @since 3.29.0
* @version 3.29.0
* @version 3.29.1
*/
public static function llms_update_access_plans( $request ) {

Expand All @@ -1084,6 +1084,10 @@ public static function llms_update_access_plans( $request ) {

foreach ( $request['plans'] as $raw_plan_data ) {

if ( empty( $raw_plan_data ) ) {
continue;
}

$raw_plan_data['product_id'] = $post_id;

// retained filter for backwards compat.
Expand Down

0 comments on commit 8e29aae

Please sign in to comment.