Skip to content

Commit

Permalink
fix the course order logic within PHP in case JS fails the course ord…
Browse files Browse the repository at this point in the history
…er always shows as the user has selected it. #944
  • Loading branch information
dwainm committed Jul 15, 2015
1 parent 6f2d39f commit 566bc54
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions classes/class-woothemes-sensei-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -978,14 +978,29 @@ public function course_order_screen() {
}

$courses = Sensei()->course->get_all_courses();

if( 0 < count( $courses ) ) {

$order_string = $this->get_course_order();
// order the courses as set by the users
$all_course_ids = array();
foreach( $courses as $course ){

$all_course_ids[] = (string)$course->ID;

}
$order_string = $this->get_course_order();

if( !empty( $order_string ) ){
$ordered_course_ids = explode(',' , $order_string );
$all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
}


$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
$html .= '<ul class="sortable-course-list">' . "\n";
$count = 0;
foreach ( $courses as $course ) {
foreach ( $all_course_ids as $course_id ) {
$course = get_post( $course_id );
$count++;
$class = 'course';
if ( $count == 1 ) { $class .= ' first'; }
Expand Down

0 comments on commit 566bc54

Please sign in to comment.