Completed
Push — master ( f45963...ffd8a9 )
by Dwain
05:01
created
includes/class-sensei-question.php 1 patch
Indentation   +567 added lines, -567 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @since  1.0.0
22 22
 	 */
23 23
 	public function __construct () {
24
-        $this->token = 'question';
24
+		$this->token = 'question';
25 25
 		$this->question_types = $this->question_types();
26 26
 		$this->meta_fields = array( 'question_right_answer', 'question_wrong_answers' );
27 27
 		if ( is_admin() ) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 			if( isset( $post->ID ) ) {
120 120
 
121
-                $question_type = Sensei()->question->get_question_type( $post->ID );
121
+				$question_type = Sensei()->question->get_question_type( $post->ID );
122 122
 
123 123
 				if( $question_type ) {
124 124
 					$type = $this->question_types[ $question_type ];
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 	public function save_question( $post_id = 0 ) {
239 239
 
240 240
 		if( ! isset( $_POST['post_type']
241
-            ) || 'question' != $_POST['post_type'] ) {
242
-            return;
243
-        }
241
+			) || 'question' != $_POST['post_type'] ) {
242
+			return;
243
+		}
244 244
 
245 245
 
246 246
 
247
-        //setup the data for saving
247
+		//setup the data for saving
248 248
 		$data = $_POST ;
249
-        $data['quiz_id'] = 0;
249
+		$data['quiz_id'] = 0;
250 250
 		$data['question_id'] = $post_id;
251 251
 
252 252
 		if ( ! wp_is_post_revision( $post_id ) ){
@@ -340,34 +340,34 @@  discard block
 block discarded – undo
340 340
 		return $request;
341 341
 	}
342 342
 
343
-    /**
344
-     * Get the type of question by id
345
-     *
346
-     * This function uses the post terms to determine which question type
347
-     * the passed question id belongs to.
348
-     *
349
-     * @since 1.7.4
350
-     *
351
-     * @param int $question_id
352
-     *
353
-     * @return string $question_type | bool
354
-     */
355
-    public function get_question_type( $question_id ){
356
-
357
-        if( empty( $question_id ) || ! intval( $question_id ) > 0
358
-            || 'question' != get_post_type( $question_id )   ){
359
-            return false;
360
-        }
361
-
362
-        $question_type = 'multiple-choice';
363
-        $question_types = wp_get_post_terms( $question_id, 'question-type' );
364
-        foreach( $question_types as $type ) {
365
-            $question_type = $type->slug;
366
-        }
367
-
368
-        return $question_type;
369
-
370
-    }// end get_question_type
343
+	/**
344
+	 * Get the type of question by id
345
+	 *
346
+	 * This function uses the post terms to determine which question type
347
+	 * the passed question id belongs to.
348
+	 *
349
+	 * @since 1.7.4
350
+	 *
351
+	 * @param int $question_id
352
+	 *
353
+	 * @return string $question_type | bool
354
+	 */
355
+	public function get_question_type( $question_id ){
356
+
357
+		if( empty( $question_id ) || ! intval( $question_id ) > 0
358
+			|| 'question' != get_post_type( $question_id )   ){
359
+			return false;
360
+		}
361
+
362
+		$question_type = 'multiple-choice';
363
+		$question_types = wp_get_post_terms( $question_id, 'question-type' );
364
+		foreach( $question_types as $type ) {
365
+			$question_type = $type->slug;
366
+		}
367
+
368
+		return $question_type;
369
+
370
+	}// end get_question_type
371 371
 
372 372
 	/**
373 373
 	 * Given a question ID, return the grade that can be achieved.
@@ -399,317 +399,317 @@  discard block
 block discarded – undo
399 399
 	} // end get_question_grade
400 400
 
401 401
 
402
-    /**
403
-     * This function simply loads the question type template
404
-     *
405
-     * @since 1.9.0
406
-     * @param $question_type
407
-     */
408
-    public static function load_question_template( $question_type ){
409
-
410
-        Sensei_Templates::get_template  ( 'single-quiz/question_type-' . $question_type . '.php' );
411
-    }
412
-
413
-    /**
414
-     * Echo the sensei question title.
415
-     *
416
-     * @uses WooThemes_Sensei_Question::get_the_question_title
417
-     *
418
-     * @since 1.9.0
419
-     * @param $question_id
420
-     */
421
-    public static function the_question_title( $question_id ){
422
-
423
-        echo self::get_the_question_title( $question_id );
424
-
425
-    }// end the_question_title
426
-
427
-    /**
428
-     * Generate the question title with it's grade.
429
-     *
430
-     * @since 1.9.0
431
-     *
432
-     * @param $question_id
433
-     * @return string
434
-     */
435
-    public static function get_the_question_title( $question_id ){
436
-
437
-        /**
438
-         * Filter the sensei question title
439
-         *
440
-         * @since 1.3.0
441
-         * @param $question_title
442
-         */
443
-        $title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) );
444
-
445
-        /**
446
-         * hook document in class-woothemes-sensei-message.php the_title()
447
-         */
448
-        $title = apply_filters( 'sensei_single_title', $title, 'question');
449
-
450
-        $title_html  = '<span class="question question-title">';
451
-        $title_html .= $title;
452
-        $title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>';
453
-        $title_html .='</span>';
454
-
455
-        return $title_html;
456
-    }
457
-
458
-    /**
459
-     * Tech the question description
460
-     *
461
-     * @param $question_id
462
-     * @return string
463
-     */
464
-    public static function get_the_question_description( $question_id ){
465
-
466
-        $question = get_post( $question_id );
467
-
468
-        /**
469
-         * Already documented within WordPress Core
470
-         */
471
-        return apply_filters( 'the_content', $question->post_content );
472
-
473
-    }
474
-
475
-    /**
476
-     * Output the question description
477
-     *
478
-     * @since 1.9.0
479
-     * @param $question_id
480
-     */
481
-    public static function the_question_description( $question_id  ){
482
-
483
-        echo self::get_the_question_description( $question_id );
484
-
485
-    }
486
-
487
-    /**
488
-     * Get the questions media markup
489
-     *
490
-     * @since 1.9.0
491
-     * @param $question_id
492
-     * @return string
493
-     */
494
-    public static function get_the_question_media( $question_id ){
495
-
496
-        $question_media = get_post_meta( $question_id, '_question_media', true );
497
-        $question_media_link = '';
498
-        if( 0 < intval( $question_media ) ) {
499
-            $mimetype = get_post_mime_type( $question_media );
500
-            if( $mimetype ) {
501
-                $mimetype_array = explode( '/', $mimetype);
502
-                if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
503
-                    $question_media_type = $mimetype_array[0];
504
-                    $question_media_url = wp_get_attachment_url( $question_media );
505
-                    $attachment = get_post( $question_media );
506
-                    $question_media_title = $attachment->post_title;
507
-                    $question_media_description = $attachment->post_content;
508
-                    switch( $question_media_type ) {
509
-                        case 'image':
510
-                            $image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id );
511
-                            $attachment_src = wp_get_attachment_image_src( $question_media, $image_size );
512
-                            $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>';
513
-                            break;
514
-
515
-                        case 'audio':
516
-                            $question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) );
517
-                            break;
518
-
519
-                        case 'video':
520
-                            $question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) );
521
-                            break;
522
-
523
-                        default:
524
-                            $question_media_filename = basename( $question_media_url );
525
-                            $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>';
526
-                            break;
527
-                    }
528
-                }
529
-            }
530
-        }
531
-
532
-        $output = '';
533
-        if( $question_media_link ) {
534
-
535
-                $output .= '<div class="question_media_display">';
536
-                $output .=      $question_media_link;
537
-                $output .= '<dl>';
538
-
539
-                if( $question_media_title ) {
540
-
541
-                   $output .= '<dt>'. $question_media_title. '</dt>';
542
-
543
-                 }
544
-
545
-                if( $question_media_description ) {
546
-
547
-                    $output .= '<dd>' . $question_media_description . '</dd>';
548
-
549
-                }
550
-
551
-                $output .= '</dl>';
552
-                $output .= '</div>';
402
+	/**
403
+	 * This function simply loads the question type template
404
+	 *
405
+	 * @since 1.9.0
406
+	 * @param $question_type
407
+	 */
408
+	public static function load_question_template( $question_type ){
409
+
410
+		Sensei_Templates::get_template  ( 'single-quiz/question_type-' . $question_type . '.php' );
411
+	}
412
+
413
+	/**
414
+	 * Echo the sensei question title.
415
+	 *
416
+	 * @uses WooThemes_Sensei_Question::get_the_question_title
417
+	 *
418
+	 * @since 1.9.0
419
+	 * @param $question_id
420
+	 */
421
+	public static function the_question_title( $question_id ){
422
+
423
+		echo self::get_the_question_title( $question_id );
424
+
425
+	}// end the_question_title
426
+
427
+	/**
428
+	 * Generate the question title with it's grade.
429
+	 *
430
+	 * @since 1.9.0
431
+	 *
432
+	 * @param $question_id
433
+	 * @return string
434
+	 */
435
+	public static function get_the_question_title( $question_id ){
436
+
437
+		/**
438
+		 * Filter the sensei question title
439
+		 *
440
+		 * @since 1.3.0
441
+		 * @param $question_title
442
+		 */
443
+		$title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) );
444
+
445
+		/**
446
+		 * hook document in class-woothemes-sensei-message.php the_title()
447
+		 */
448
+		$title = apply_filters( 'sensei_single_title', $title, 'question');
449
+
450
+		$title_html  = '<span class="question question-title">';
451
+		$title_html .= $title;
452
+		$title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>';
453
+		$title_html .='</span>';
454
+
455
+		return $title_html;
456
+	}
457
+
458
+	/**
459
+	 * Tech the question description
460
+	 *
461
+	 * @param $question_id
462
+	 * @return string
463
+	 */
464
+	public static function get_the_question_description( $question_id ){
465
+
466
+		$question = get_post( $question_id );
467
+
468
+		/**
469
+		 * Already documented within WordPress Core
470
+		 */
471
+		return apply_filters( 'the_content', $question->post_content );
472
+
473
+	}
474
+
475
+	/**
476
+	 * Output the question description
477
+	 *
478
+	 * @since 1.9.0
479
+	 * @param $question_id
480
+	 */
481
+	public static function the_question_description( $question_id  ){
482
+
483
+		echo self::get_the_question_description( $question_id );
484
+
485
+	}
486
+
487
+	/**
488
+	 * Get the questions media markup
489
+	 *
490
+	 * @since 1.9.0
491
+	 * @param $question_id
492
+	 * @return string
493
+	 */
494
+	public static function get_the_question_media( $question_id ){
495
+
496
+		$question_media = get_post_meta( $question_id, '_question_media', true );
497
+		$question_media_link = '';
498
+		if( 0 < intval( $question_media ) ) {
499
+			$mimetype = get_post_mime_type( $question_media );
500
+			if( $mimetype ) {
501
+				$mimetype_array = explode( '/', $mimetype);
502
+				if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
503
+					$question_media_type = $mimetype_array[0];
504
+					$question_media_url = wp_get_attachment_url( $question_media );
505
+					$attachment = get_post( $question_media );
506
+					$question_media_title = $attachment->post_title;
507
+					$question_media_description = $attachment->post_content;
508
+					switch( $question_media_type ) {
509
+						case 'image':
510
+							$image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id );
511
+							$attachment_src = wp_get_attachment_image_src( $question_media, $image_size );
512
+							$question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>';
513
+							break;
514
+
515
+						case 'audio':
516
+							$question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) );
517
+							break;
518
+
519
+						case 'video':
520
+							$question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) );
521
+							break;
522
+
523
+						default:
524
+							$question_media_filename = basename( $question_media_url );
525
+							$question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>';
526
+							break;
527
+					}
528
+				}
529
+			}
530
+		}
531
+
532
+		$output = '';
533
+		if( $question_media_link ) {
553 534
 
535
+				$output .= '<div class="question_media_display">';
536
+				$output .=      $question_media_link;
537
+				$output .= '<dl>';
554 538
 
555
-         }
556
-
557
-        return $output;
558
-
559
-    } // end get_the_question_media
560
-
539
+				if( $question_media_title ) {
561 540
 
562
-    /**
563
-     * Output the question media
564
-     *
565
-     * @since 1.9.0
566
-     * @param string $question_id
567
-     */
568
-    public static function the_question_media( $question_id ){
541
+				   $output .= '<dt>'. $question_media_title. '</dt>';
569 542
 
570
-        echo self::get_the_question_media( $question_id );
543
+				 }
571 544
 
572
-    }
545
+				if( $question_media_description ) {
573 546
 
574
-    /**
575
-     * Output a special field for the question needed for question submission.
576
-     *
577
-     * @since 1.9.0
578
-     *
579
-     * @param $question_id
580
-     */
581
-    public static function the_question_hidden_fields( $question_id ){
582
-        ?>
547
+					$output .= '<dd>' . $question_media_description . '</dd>';
548
+
549
+				}
550
+
551
+				$output .= '</dl>';
552
+				$output .= '</div>';
553
+
554
+
555
+		 }
556
+
557
+		return $output;
558
+
559
+	} // end get_the_question_media
560
+
561
+
562
+	/**
563
+	 * Output the question media
564
+	 *
565
+	 * @since 1.9.0
566
+	 * @param string $question_id
567
+	 */
568
+	public static function the_question_media( $question_id ){
569
+
570
+		echo self::get_the_question_media( $question_id );
571
+
572
+	}
573
+
574
+	/**
575
+	 * Output a special field for the question needed for question submission.
576
+	 *
577
+	 * @since 1.9.0
578
+	 *
579
+	 * @param $question_id
580
+	 */
581
+	public static function the_question_hidden_fields( $question_id ){
582
+		?>
583 583
 
584 584
             <input type="hidden" name="question_id_<?php $question_id;?>" value="<?php $question_id;?>" />
585 585
             <input type="hidden" name="questions_asked[]" value="<?php esc_attr_e( $question_id ); ?>" />
586 586
 
587 587
         <?php
588
-    }
588
+	}
589 589
 
590
-    /**
591
-     * This function can only be run withing the single quiz question loop
592
-     *
593
-     * @since 1.9.0
594
-     * @param $question_id
595
-     */
596
-    public static function answer_feedback_notes( $question_id ){
590
+	/**
591
+	 * This function can only be run withing the single quiz question loop
592
+	 *
593
+	 * @since 1.9.0
594
+	 * @param $question_id
595
+	 */
596
+	public static function answer_feedback_notes( $question_id ){
597 597
 
598
-        //IDS
599
-        $quiz_id = get_the_ID();
600
-        $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
598
+		//IDS
599
+		$quiz_id = get_the_ID();
600
+		$lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
601 601
 
602
-        // Data to check before showing feedback
603
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() );
604
-        $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
605
-        $not_empty_user_quiz_grade = !empty( $user_quiz_grade );
606
-        $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id );
607
-        $lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id );
608
-        $quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true );
602
+		// Data to check before showing feedback
603
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() );
604
+		$user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
605
+		$not_empty_user_quiz_grade = !empty( $user_quiz_grade );
606
+		$reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id );
607
+		$lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id );
608
+		$quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true );
609 609
 
610
-        if( ( $lesson_completed  && $not_empty_user_quiz_grade  )
611
-            ||  ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type )
612
-            || ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) {
610
+		if( ( $lesson_completed  && $not_empty_user_quiz_grade  )
611
+			||  ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type )
612
+			|| ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) {
613 613
 
614
-            $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() );
614
+			$answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() );
615 615
 
616
-            if( $answer_notes ) { ?>
616
+			if( $answer_notes ) { ?>
617 617
 
618 618
                 <div class="sensei-message info info-special answer-feedback">
619 619
 
620 620
                     <?php
621 621
 
622
-                        /**
623
-                         * Filter the answer feedback
624
-                         * Since 1.9.0
625
-                         *
626
-                         * @param string $answer_notes
627
-                         * @param string $question_id
628
-                         * @param string $lesson_id
629
-                         */
630
-                        echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id );
622
+						/**
623
+						 * Filter the answer feedback
624
+						 * Since 1.9.0
625
+						 *
626
+						 * @param string $answer_notes
627
+						 * @param string $question_id
628
+						 * @param string $lesson_id
629
+						 */
630
+						echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id );
631 631
 
632
-                    ?>
632
+					?>
633 633
 
634 634
                 </div>
635 635
 
636 636
             <?php }
637 637
 
638
-        }// end if we can show answer feedback
638
+		}// end if we can show answer feedback
639 639
 
640
-    }// end answer_feedback_notes
640
+	}// end answer_feedback_notes
641 641
 
642
-    /**
643
-     * This function has to be run inside the quiz question loop on the single quiz page.
644
-     *
645
-     *
646
-     * @since 1.9.0
647
-     * @param string $question_id
648
-     */
649
-    public static function the_answer_result_indication( $question_id ){
642
+	/**
643
+	 * This function has to be run inside the quiz question loop on the single quiz page.
644
+	 *
645
+	 *
646
+	 * @since 1.9.0
647
+	 * @param string $question_id
648
+	 */
649
+	public static function the_answer_result_indication( $question_id ){
650 650
 
651
-        global $post,  $current_user, $sensei_question_loop;
651
+		global $post,  $current_user, $sensei_question_loop;
652 652
 
653
-        // Post Data
654
-        $quiz_id = $sensei_question_loop['quiz_id'];
655
-        $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
656
-        $question_item = $sensei_question_loop['current_question'];
653
+		// Post Data
654
+		$quiz_id = $sensei_question_loop['quiz_id'];
655
+		$lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
656
+		$question_item = $sensei_question_loop['current_question'];
657 657
 
658
-        // Setup variable needed to determine if the message should show and what it should show
659
-        $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
660
-        $lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() );
661
-        $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id );
662
-        $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
658
+		// Setup variable needed to determine if the message should show and what it should show
659
+		$user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
660
+		$lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() );
661
+		$reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id );
662
+		$quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
663 663
 
664
-        // retrieve the question total grade
665
-        $question_grade = Sensei()->question->get_question_grade( $question_id );
664
+		// retrieve the question total grade
665
+		$question_grade = Sensei()->question->get_question_grade( $question_id );
666 666
 
667
-        // retrieve grade the user achieved
668
-        $user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() );
667
+		// retrieve grade the user achieved
668
+		$user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() );
669 669
 
670
-        // Question ID
671
-        $question_id = $question_item->ID;
670
+		// Question ID
671
+		$question_id = $question_item->ID;
672 672
 
673
-        // conditions to check
674
-        $completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ;
675
-        $completed_with_valid_grade_and_reset_not_allowed = $lesson_complete &&  $user_quiz_grade != '' && ! $reset_quiz_allowed ;
676
-        $grade_type_auto_a_valid_grade_and_reset_not_allowed =  'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ;
673
+		// conditions to check
674
+		$completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ;
675
+		$completed_with_valid_grade_and_reset_not_allowed = $lesson_complete &&  $user_quiz_grade != '' && ! $reset_quiz_allowed ;
676
+		$grade_type_auto_a_valid_grade_and_reset_not_allowed =  'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ;
677 677
 
678
-        if (  $completed_with_valid_grade
679
-            || $completed_with_valid_grade_and_reset_not_allowed
680
-            || $grade_type_auto_a_valid_grade_and_reset_not_allowed  ) {
678
+		if (  $completed_with_valid_grade
679
+			|| $completed_with_valid_grade_and_reset_not_allowed
680
+			|| $grade_type_auto_a_valid_grade_and_reset_not_allowed  ) {
681 681
 
682
-            $user_correct = false;
683
-            $answer_message = __( 'Incorrect', 'woothemes-sensei' );
684
-            $answer_message_class = 'user_wrong';
685
-            // For zero grade mark as 'correct' but add no classes
686
-            if ( 0 == $question_grade ) {
682
+			$user_correct = false;
683
+			$answer_message = __( 'Incorrect', 'woothemes-sensei' );
684
+			$answer_message_class = 'user_wrong';
685
+			// For zero grade mark as 'correct' but add no classes
686
+			if ( 0 == $question_grade ) {
687 687
 
688
-                $user_correct = true;
689
-                $answer_message = '';
690
-                $answer_message_class = '';
688
+				$user_correct = true;
689
+				$answer_message = '';
690
+				$answer_message_class = '';
691 691
 
692
-            } else if( $user_question_grade > 0 ) {
692
+			} else if( $user_question_grade > 0 ) {
693 693
 
694
-                $user_correct = true;
695
-                $answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade );
696
-                $answer_message_class = 'user_right';
694
+				$user_correct = true;
695
+				$answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade );
696
+				$answer_message_class = 'user_right';
697 697
 
698
-            }
698
+			}
699 699
 
700
-            // attach the correct answer if the question is auto gradable and user got it wrong
701
-            if( !$reset_quiz_allowed && !$user_correct ){
700
+			// attach the correct answer if the question is auto gradable and user got it wrong
701
+			if( !$reset_quiz_allowed && !$user_correct ){
702 702
 
703
-                $answer_message .=  ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID );
703
+				$answer_message .=  ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID );
704 704
 
705
-            }
705
+			}
706 706
 
707
-            // answer feedback
708
-            $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID );
709
-            if( $answer_notes ) {
710
-                $answer_message_class .= ' has_notes';
711
-            }
712
-            ?>
707
+			// answer feedback
708
+			$answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID );
709
+			if( $answer_notes ) {
710
+				$answer_message_class .= ' has_notes';
711
+			}
712
+			?>
713 713
 
714 714
             <div class="answer_message <?php esc_attr_e( $answer_message_class ); ?>">
715 715
 
@@ -719,387 +719,387 @@  discard block
 block discarded – undo
719 719
 
720 720
             <?php
721 721
 
722
-        } // end if user can see all the goodies
723
-
724
-    }// end the_answer_result_indication
725
-
726
-    /**
727
-     * Generate the question template data and return it as an array.
728
-     *
729
-     * @since 1.9.0
730
-     *
731
-     * @param string $question_id
732
-     * @param $quiz_id
733
-     * @return array $question_data
734
-     */
735
-    public static function get_template_data( $question_id, $quiz_id ){
736
-
737
-        $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id  );
738
-
739
-        $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
740
-        //backwards compatibility
741
-        if( 'on' == $reset_allowed ) {
742
-            $reset_allowed = 1;
743
-        }
744
-
745
-        // Check again that the lesson is complete
746
-        $user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() );
747
-        $user_lesson_complete = false;
748
-        if ( $user_lesson_end ) {
749
-            $user_lesson_complete = true;
750
-        }
751
-
752
-        //setup the question data
753
-        $data[ 'ID' ]                     = $question_id;
754
-        $data[ 'title' ]                  = get_the_title( $question_id );
755
-        $data[ 'content' ]                = get_post( $question_id )->post_content;
756
-        $data[ 'quiz_id' ]                = $quiz_id;
757
-        $data[ 'lesson_id' ]              = Sensei()->quiz->get_lesson_id( $quiz_id );
758
-        $data[ 'type' ]                   = Sensei()->question->get_question_type( $question_id );
759
-        $data[ 'question_grade' ]         = Sensei()->question->get_question_grade(  $question_id  );
760
-        $data[ 'user_question_grade' ]    = Sensei()->quiz->get_user_question_grade( $lesson_id,  $question_id , get_current_user_id());
761
-        $data[ 'question_right_answer' ]  = get_post_meta( $question_id , '_question_right_answer', true );
762
-        $data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true );
763
-        $data[ 'user_answer_entry' ]      = Sensei()->quiz->get_user_question_answer( $lesson_id,  $question_id , get_current_user_id() );
764
-        $data[ 'lesson_completed' ]       = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) );
765
-        $data[ 'quiz_grade_type' ]        = get_post_meta( $quiz_id , '_quiz_grade_type', true );
766
-        $data[ 'reset_quiz_allowed' ]     = $reset_allowed;
767
-        $data[ 'lesson_complete' ]        = $user_lesson_complete;
768
-
769
-        /**
770
-         * Filter the question template data. This filter fires  in
771
-         * the get_template_data function
772
-         *
773
-         * @hooked self::boolean_load_question_data
774
-         *
775
-         * @since 1.9.0
776
-         *
777
-         * @param array $data
778
-         * @param string $question_id
779
-         * @param string $quiz_id
780
-         */
781
-        return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id );
722
+		} // end if user can see all the goodies
782 723
 
783
-    }
724
+	}// end the_answer_result_indication
784 725
 
785
-    /**
786
-     * Load multiple choice question data on the sensei_get_question_template_data
787
-     * filter.
788
-     *
789
-     * @since 1.9.0
790
-     *
791
-     * @param $question_data
792
-     * @param $question_id
793
-     * @param $quiz_id
794
-     *
795
-     * @return array()
796
-     */
797
-    public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){
726
+	/**
727
+	 * Generate the question template data and return it as an array.
728
+	 *
729
+	 * @since 1.9.0
730
+	 *
731
+	 * @param string $question_id
732
+	 * @param $quiz_id
733
+	 * @return array $question_data
734
+	 */
735
+	public static function get_template_data( $question_id, $quiz_id ){
798 736
 
737
+		$lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id  );
799 738
 
800
-        if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) {
739
+		$reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
740
+		//backwards compatibility
741
+		if( 'on' == $reset_allowed ) {
742
+			$reset_allowed = 1;
743
+		}
801 744
 
802
-            // Get uploaded file
803
-            $attachment_id = $question_data[ 'user_answer_entry' ];
804
-            $answer_media_url = $answer_media_filename = '';
745
+		// Check again that the lesson is complete
746
+		$user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() );
747
+		$user_lesson_complete = false;
748
+		if ( $user_lesson_end ) {
749
+			$user_lesson_complete = true;
750
+		}
805 751
 
752
+		//setup the question data
753
+		$data[ 'ID' ]                     = $question_id;
754
+		$data[ 'title' ]                  = get_the_title( $question_id );
755
+		$data[ 'content' ]                = get_post( $question_id )->post_content;
756
+		$data[ 'quiz_id' ]                = $quiz_id;
757
+		$data[ 'lesson_id' ]              = Sensei()->quiz->get_lesson_id( $quiz_id );
758
+		$data[ 'type' ]                   = Sensei()->question->get_question_type( $question_id );
759
+		$data[ 'question_grade' ]         = Sensei()->question->get_question_grade(  $question_id  );
760
+		$data[ 'user_question_grade' ]    = Sensei()->quiz->get_user_question_grade( $lesson_id,  $question_id , get_current_user_id());
761
+		$data[ 'question_right_answer' ]  = get_post_meta( $question_id , '_question_right_answer', true );
762
+		$data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true );
763
+		$data[ 'user_answer_entry' ]      = Sensei()->quiz->get_user_question_answer( $lesson_id,  $question_id , get_current_user_id() );
764
+		$data[ 'lesson_completed' ]       = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) );
765
+		$data[ 'quiz_grade_type' ]        = get_post_meta( $quiz_id , '_quiz_grade_type', true );
766
+		$data[ 'reset_quiz_allowed' ]     = $reset_allowed;
767
+		$data[ 'lesson_complete' ]        = $user_lesson_complete;
768
+
769
+		/**
770
+		 * Filter the question template data. This filter fires  in
771
+		 * the get_template_data function
772
+		 *
773
+		 * @hooked self::boolean_load_question_data
774
+		 *
775
+		 * @since 1.9.0
776
+		 *
777
+		 * @param array $data
778
+		 * @param string $question_id
779
+		 * @param string $quiz_id
780
+		 */
781
+		return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id );
806 782
 
807
-            $question_helptext = '';
808
-            if( isset( $question_data['question_wrong_answers'][0] ) ) {
783
+	}
809 784
 
810
-                $question_helptext =  $question_data['question_wrong_answers'][0];
785
+	/**
786
+	 * Load multiple choice question data on the sensei_get_question_template_data
787
+	 * filter.
788
+	 *
789
+	 * @since 1.9.0
790
+	 *
791
+	 * @param $question_data
792
+	 * @param $question_id
793
+	 * @param $quiz_id
794
+	 *
795
+	 * @return array()
796
+	 */
797
+	public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){
811 798
 
812
-            }
813 799
 
800
+		if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) {
814 801
 
815
-            if( 0 < intval( $attachment_id ) ) {
802
+			// Get uploaded file
803
+			$attachment_id = $question_data[ 'user_answer_entry' ];
804
+			$answer_media_url = $answer_media_filename = '';
816 805
 
817
-                $answer_media_url = wp_get_attachment_url( $attachment_id );
818
-                $answer_media_filename = basename( $answer_media_url );
819 806
 
820
-            }
807
+			$question_helptext = '';
808
+			if( isset( $question_data['question_wrong_answers'][0] ) ) {
821 809
 
810
+				$question_helptext =  $question_data['question_wrong_answers'][0];
822 811
 
823
-            // Get max upload file size, formatted for display
824
-            // Code copied from wp-admin/includes/media.php:1515
825
-            $upload_size_unit = $max_upload_size = wp_max_upload_size();
826
-            $sizes = array( 'KB', 'MB', 'GB' );
827
-            for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
828
-                $upload_size_unit /= 1024;
829
-            }
830
-            if ( $u < 0 ) {
812
+			}
831 813
 
832
-                $upload_size_unit = 0;
833
-                $u = 0;
834 814
 
835
-            } else {
815
+			if( 0 < intval( $attachment_id ) ) {
836 816
 
837
-                $upload_size_unit = (int) $upload_size_unit;
817
+				$answer_media_url = wp_get_attachment_url( $attachment_id );
818
+				$answer_media_filename = basename( $answer_media_url );
838 819
 
839
-            }
840
-            $max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) );
820
+			}
841 821
 
842
-            // Assemble all the data needed by the file upload template
843
-            $question_data[ 'answer_media_url' ]      = $answer_media_url;
844
-            $question_data[ 'answer_media_filename' ] = $answer_media_filename;
845
-            $question_data[ 'max_upload_size' ]       = $max_upload_size;
846 822
 
847
-            $question_data[ 'question_helptext' ]     = $question_helptext;
823
+			// Get max upload file size, formatted for display
824
+			// Code copied from wp-admin/includes/media.php:1515
825
+			$upload_size_unit = $max_upload_size = wp_max_upload_size();
826
+			$sizes = array( 'KB', 'MB', 'GB' );
827
+			for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
828
+				$upload_size_unit /= 1024;
829
+			}
830
+			if ( $u < 0 ) {
848 831
 
849
-        }// end if is file upload type
832
+				$upload_size_unit = 0;
833
+				$u = 0;
850 834
 
851
-        return $question_data;
835
+			} else {
852 836
 
853
-    }// end file_upload_load_question_data
837
+				$upload_size_unit = (int) $upload_size_unit;
854 838
 
855
-    /**
856
-     * Load multiple choice question data on the sensei_get_question_template_data
857
-     * filter.
858
-     *
859
-     * @since 1.9.0
860
-     *
861
-     * @param $question_data
862
-     * @param $question_id
863
-     * @param $quiz_id
864
-     *
865
-     * @return array()
866
-     */
867
-    public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){
839
+			}
840
+			$max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) );
868 841
 
869
-        if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) {
842
+			// Assemble all the data needed by the file upload template
843
+			$question_data[ 'answer_media_url' ]      = $answer_media_url;
844
+			$question_data[ 'answer_media_filename' ] = $answer_media_filename;
845
+			$question_data[ 'max_upload_size' ]       = $max_upload_size;
870 846
 
847
+			$question_data[ 'question_helptext' ]     = $question_helptext;
871 848
 
872
-            $answer_type = 'radio';
873
-            if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) {
849
+		}// end if is file upload type
874 850
 
875
-                $answer_type = 'checkbox';
851
+		return $question_data;
876 852
 
877
-            }
853
+	}// end file_upload_load_question_data
878 854
 
879
-            // Merge right and wrong answers
880
-            if ( is_array( $question_data[ 'question_right_answer' ] ) ) {
855
+	/**
856
+	 * Load multiple choice question data on the sensei_get_question_template_data
857
+	 * filter.
858
+	 *
859
+	 * @since 1.9.0
860
+	 *
861
+	 * @param $question_data
862
+	 * @param $question_id
863
+	 * @param $quiz_id
864
+	 *
865
+	 * @return array()
866
+	 */
867
+	public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){
881 868
 
882
-                $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] );
869
+		if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) {
883 870
 
884
-            }  else {
885 871
 
886
-                array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] );
887
-                $merged_options = $question_data[ 'question_wrong_answers' ];
872
+			$answer_type = 'radio';
873
+			if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) {
888 874
 
889
-            }
875
+				$answer_type = 'checkbox';
890 876
 
891
-            // Setup answer options array.
892
-            $question_answers_options = array();
893
-            $count = 0;
877
+			}
894 878
 
895
-            foreach( $merged_options as $answer ) {
879
+			// Merge right and wrong answers
880
+			if ( is_array( $question_data[ 'question_right_answer' ] ) ) {
896 881
 
897
-                $count++;
898
-                $question_option = array();
882
+				$merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] );
899 883
 
900
-                if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' )
901
-                    || ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' )
902
-                    || ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ]  && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) {
884
+			}  else {
903 885
 
904
-                    $user_correct = false;
886
+				array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] );
887
+				$merged_options = $question_data[ 'question_wrong_answers' ];
905 888
 
889
+			}
906 890
 
907
-                    // For zero grade mark as 'correct' but add no classes
908
-                    if ( 0 == $question_data[ 'question_grade' ] ) {
891
+			// Setup answer options array.
892
+			$question_answers_options = array();
893
+			$count = 0;
909 894
 
910
-                        $user_correct = true;
895
+			foreach( $merged_options as $answer ) {
911 896
 
912
-                    }  else if( $question_data[ 'user_question_grade' ] > 0 ) {
897
+				$count++;
898
+				$question_option = array();
913 899
 
914
-                        $user_correct = true;
900
+				if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' )
901
+					|| ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' )
902
+					|| ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ]  && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) {
915 903
 
916
-                    }
904
+					$user_correct = false;
917 905
 
918
-                }
919 906
 
920
-                // setup the option specific classes
921
-                $answer_class = '';
922
-                if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) {
923
-                    if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) {
907
+					// For zero grade mark as 'correct' but add no classes
908
+					if ( 0 == $question_data[ 'question_grade' ] ) {
924 909
 
925
-                        $answer_class .= ' right_answer';
910
+						$user_correct = true;
926 911
 
927
-                    }  elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) {
912
+					}  else if( $question_data[ 'user_question_grade' ] > 0 ) {
928 913
 
929
-                        $answer_class .= ' right_answer';
914
+						$user_correct = true;
930 915
 
931
-                    } elseif( ( is_array( $question_data['user_answer_entry']  ) && in_array($answer, $question_data['user_answer_entry'] ) )
932
-                        ||  ( !  $question_data['user_answer_entry'] &&  $question_data['user_answer_entry'] == $answer ) ) {
916
+					}
933 917
 
934
-                        $answer_class = 'user_wrong';
935
-                        if( $user_correct ) {
918
+				}
936 919
 
937
-                            $answer_class = 'user_right';
920
+				// setup the option specific classes
921
+				$answer_class = '';
922
+				if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) {
923
+					if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) {
938 924
 
939
-                        }
925
+						$answer_class .= ' right_answer';
940 926
 
941
-                    }
927
+					}  elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) {
942 928
 
943
-                }
929
+						$answer_class .= ' right_answer';
944 930
 
945
-                // determine if the current option must be checked
946
-                $checked = '';
947
-                if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) {
948
-                    if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) {
931
+					} elseif( ( is_array( $question_data['user_answer_entry']  ) && in_array($answer, $question_data['user_answer_entry'] ) )
932
+						||  ( !  $question_data['user_answer_entry'] &&  $question_data['user_answer_entry'] == $answer ) ) {
949 933
 
950
-                        $checked = 'checked="checked"';
934
+						$answer_class = 'user_wrong';
935
+						if( $user_correct ) {
951 936
 
952
-                    } elseif ( !is_array( $question_data['user_answer_entry'] ) ) {
937
+							$answer_class = 'user_right';
953 938
 
954
-                        $checked = checked( $answer, $question_data['user_answer_entry'] , false );
939
+						}
955 940
 
956
-                    }
941
+					}
957 942
 
958
-                } // End If Statement
943
+				}
959 944
 
960
-                //Load the answer option data
961
-                $question_option[ 'ID' ]          = Sensei()->lesson->get_answer_id( $answer );
962
-                $question_option[ 'answer' ]      = $answer;
963
-                $question_option[ 'option_class'] = $answer_class;
964
-                $question_option[ 'checked']      = $checked;
965
-                $question_option[ 'count' ]       = $count;
966
-                $question_option[ 'type' ] = $answer_type;
945
+				// determine if the current option must be checked
946
+				$checked = '';
947
+				if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) {
948
+					if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) {
967 949
 
968
-                // add the speci  fic option to the list of options for this question
969
-                $question_answers_options[] = $question_option;
950
+						$checked = 'checked="checked"';
970 951
 
971
-            } // end for each option
952
+					} elseif ( !is_array( $question_data['user_answer_entry'] ) ) {
972 953
 
954
+						$checked = checked( $answer, $question_data['user_answer_entry'] , false );
973 955
 
974
-            // Shuffle the array depending on the settings
975
-            $answer_options_sorted = array();
976
-            $random_order = get_post_meta( $question_data['ID'], '_random_order', true );
977
-            if(  $random_order && $random_order == 'yes' ) {
956
+					}
978 957
 
979
-                $answer_options_sorted = $question_answers_options;
980
-                shuffle( $answer_options_sorted );
958
+				} // End If Statement
981 959
 
982
-            } else {
960
+				//Load the answer option data
961
+				$question_option[ 'ID' ]          = Sensei()->lesson->get_answer_id( $answer );
962
+				$question_option[ 'answer' ]      = $answer;
963
+				$question_option[ 'option_class'] = $answer_class;
964
+				$question_option[ 'checked']      = $checked;
965
+				$question_option[ 'count' ]       = $count;
966
+				$question_option[ 'type' ] = $answer_type;
983 967
 
984
-                $answer_order = array();
985
-                $answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true );
986
-                if( $answer_order_string ) {
968
+				// add the speci  fic option to the list of options for this question
969
+				$question_answers_options[] = $question_option;
987 970
 
988
-                    $answer_order = array_filter( explode( ',', $answer_order_string ) );
989
-                    if( count( $answer_order ) > 0 ) {
971
+			} // end for each option
990 972
 
991
-                        foreach( $answer_order as $answer_id ) {
992 973
 
993
-                            if( isset( $question_answers_options[ $answer_id ] ) ) {
974
+			// Shuffle the array depending on the settings
975
+			$answer_options_sorted = array();
976
+			$random_order = get_post_meta( $question_data['ID'], '_random_order', true );
977
+			if(  $random_order && $random_order == 'yes' ) {
994 978
 
995
-                                $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ];
996
-                                unset( $question_answers_options[ $answer_id ] );
979
+				$answer_options_sorted = $question_answers_options;
980
+				shuffle( $answer_options_sorted );
997 981
 
998
-                            }
982
+			} else {
999 983
 
1000
-                        }
984
+				$answer_order = array();
985
+				$answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true );
986
+				if( $answer_order_string ) {
1001 987
 
1002
-                        if( count( $question_answers_options ) > 0 ) {
1003
-                            foreach( $question_answers_options as $id => $answer ) {
988
+					$answer_order = array_filter( explode( ',', $answer_order_string ) );
989
+					if( count( $answer_order ) > 0 ) {
1004 990
 
1005
-                                $answer_options_sorted[ $id ] = $answer;
991
+						foreach( $answer_order as $answer_id ) {
1006 992
 
1007
-                            }
1008
-                        }
993
+							if( isset( $question_answers_options[ $answer_id ] ) ) {
1009 994
 
1010
-                    }else{
995
+								$answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ];
996
+								unset( $question_answers_options[ $answer_id ] );
1011 997
 
1012
-                        $answer_options_sorted = $question_answers_options;
998
+							}
1013 999
 
1014
-                    }
1000
+						}
1015 1001
 
1016
-                }else{
1002
+						if( count( $question_answers_options ) > 0 ) {
1003
+							foreach( $question_answers_options as $id => $answer ) {
1017 1004
 
1018
-                    $answer_options_sorted = $question_answers_options;
1005
+								$answer_options_sorted[ $id ] = $answer;
1019 1006
 
1020
-                } // end if $answer_order_string
1007
+							}
1008
+						}
1021 1009
 
1022
-            } // end if random order
1010
+					}else{
1023 1011
 
1012
+						$answer_options_sorted = $question_answers_options;
1024 1013
 
1025
-            // assemble and setup the data for the templates data array
1026
-            $question_data[ 'answer_options' ]    =  $answer_options_sorted;
1014
+					}
1027 1015
 
1028
-        }
1016
+				}else{
1029 1017
 
1030
-        return $question_data;
1018
+					$answer_options_sorted = $question_answers_options;
1031 1019
 
1032
-    }//  end multiple_choice_load_question_data
1020
+				} // end if $answer_order_string
1033 1021
 
1034
-    /**
1035
-     * Load the gap fill question data on the sensei_get_question_template_data
1036
-     * filter.
1037
-     *
1038
-     * @since 1.9.0
1039
-     *
1040
-     * @param $question_data
1041
-     * @param $question_id
1042
-     * @param $quiz_id
1043
-     *
1044
-     * @return array()
1045
-     */
1046
-    public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){
1022
+			} // end if random order
1047 1023
 
1048
-        if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) {
1049 1024
 
1050
-            $gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] );
1051
-            $question_data[ 'gapfill_pre' ]  = isset( $gapfill_array[0] ) ? $gapfill_array[0] : '';
1052
-            $question_data[ 'gapfill_gap' ]  = isset( $gapfill_array[1] ) ? $gapfill_array[1] : '';
1053
-            $question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : '';
1025
+			// assemble and setup the data for the templates data array
1026
+			$question_data[ 'answer_options' ]    =  $answer_options_sorted;
1054 1027
 
1055
-        }
1028
+		}
1056 1029
 
1057
-        return $question_data;
1030
+		return $question_data;
1058 1031
 
1059
-    }//  end gap_fill_load_question_data
1032
+	}//  end multiple_choice_load_question_data
1033
+
1034
+	/**
1035
+	 * Load the gap fill question data on the sensei_get_question_template_data
1036
+	 * filter.
1037
+	 *
1038
+	 * @since 1.9.0
1039
+	 *
1040
+	 * @param $question_data
1041
+	 * @param $question_id
1042
+	 * @param $quiz_id
1043
+	 *
1044
+	 * @return array()
1045
+	 */
1046
+	public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){
1047
+
1048
+		if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) {
1049
+
1050
+			$gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] );
1051
+			$question_data[ 'gapfill_pre' ]  = isset( $gapfill_array[0] ) ? $gapfill_array[0] : '';
1052
+			$question_data[ 'gapfill_gap' ]  = isset( $gapfill_array[1] ) ? $gapfill_array[1] : '';
1053
+			$question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : '';
1054
+
1055
+		}
1056
+
1057
+		return $question_data;
1058
+
1059
+	}//  end gap_fill_load_question_data
1060 1060
 
1061 1061
 
1062
-    /**
1063
-     * Get the correct answer for a question
1064
-     *
1065
-     * @param $question_id
1066
-     * @return string $correct_answer or empty
1067
-     */
1068
-    public static function get_correct_answer( $question_id ){
1062
+	/**
1063
+	 * Get the correct answer for a question
1064
+	 *
1065
+	 * @param $question_id
1066
+	 * @return string $correct_answer or empty
1067
+	 */
1068
+	public static function get_correct_answer( $question_id ){
1069 1069
 
1070
-        $right_answer = get_post_meta( $question_id, '_question_right_answer', true );
1071
-        $type = Sensei()->question->get_question_type( $question_id );
1072
-        $type_name = __( 'Multiple Choice', 'woothemes-sensei' );
1073
-        $grade_type = 'manual-grade';
1070
+		$right_answer = get_post_meta( $question_id, '_question_right_answer', true );
1071
+		$type = Sensei()->question->get_question_type( $question_id );
1072
+		$type_name = __( 'Multiple Choice', 'woothemes-sensei' );
1073
+		$grade_type = 'manual-grade';
1074 1074
 
1075
-        if ('boolean'== $type ) {
1075
+		if ('boolean'== $type ) {
1076 1076
 
1077
-            $right_answer = ucfirst($right_answer);
1077
+			$right_answer = ucfirst($right_answer);
1078 1078
 
1079
-        }elseif( 'multiple-choice' == $type ) {
1079
+		}elseif( 'multiple-choice' == $type ) {
1080 1080
 
1081
-            $right_answer = (array) $right_answer;
1082
-            $right_answer = implode( ', ', $right_answer );
1081
+			$right_answer = (array) $right_answer;
1082
+			$right_answer = implode( ', ', $right_answer );
1083 1083
 
1084
-        }elseif( 'gap-fill' == $type ) {
1084
+		}elseif( 'gap-fill' == $type ) {
1085 1085
 
1086
-            $right_answer_array = explode( '||', $right_answer );
1087
-            if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; }
1088
-            if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; }
1089
-            if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; }
1086
+			$right_answer_array = explode( '||', $right_answer );
1087
+			if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; }
1088
+			if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; }
1089
+			if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; }
1090 1090
 
1091
-            $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post;
1091
+			$right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post;
1092 1092
 
1093
-        }else{
1093
+		}else{
1094 1094
 
1095
-            // for non auto gradable question types no answer should be returned.
1096
-            $right_answer = '';
1095
+			// for non auto gradable question types no answer should be returned.
1096
+			$right_answer = '';
1097 1097
 
1098
-        }
1098
+		}
1099 1099
 
1100
-        return $right_answer;
1100
+		return $right_answer;
1101 1101
 
1102
-    } // get_correct_answer
1102
+	} // get_correct_answer
1103 1103
 
1104 1104
 } // End Class
1105 1105
 
Please login to merge, or discard this patch.
includes/class-sensei-settings.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,43 +21,43 @@  discard block
 block discarded – undo
21 21
 	 * @return void
22 22
 	 */
23 23
 	public function __construct () {
24
-	    parent::__construct(); // Required in extended classes.
24
+		parent::__construct(); // Required in extended classes.
25 25
 
26
-        $this->token = 'woothemes-sensei-settings';
27
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
26
+		$this->token = 'woothemes-sensei-settings';
27
+		add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
28 28
 
29
-        // Setup Admin Settings data
30
-        if ( is_admin() ) {
29
+		// Setup Admin Settings data
30
+		if ( is_admin() ) {
31 31
 
32
-            $this->has_tabs 	= true;
33
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
35
-            $this->page_slug	= 'woothemes-sensei-settings';
32
+			$this->has_tabs 	= true;
33
+			$this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
+			$this->menu_label	= __( 'Settings', 'woothemes-sensei' );
35
+			$this->page_slug	= 'woothemes-sensei-settings';
36 36
 
37
-        } // End If Statement
37
+		} // End If Statement
38 38
 
39
-        $this->register_hook_listener();
40
-        $this->get_settings();
39
+		$this->register_hook_listener();
40
+		$this->get_settings();
41 41
 
42 42
 	} // End __construct()
43 43
 
44
-    /**
45
-     * Get settings value
46
-     *
47
-     * @since 1.9.0
48
-     * @param string $setting_name
49
-     * @return mixed
50
-     */
51
-    public function get( $setting_name ){
44
+	/**
45
+	 * Get settings value
46
+	 *
47
+	 * @since 1.9.0
48
+	 * @param string $setting_name
49
+	 * @return mixed
50
+	 */
51
+	public function get( $setting_name ){
52 52
 
53
-        if( isset( $this->settings[ $setting_name ] ) ){
53
+		if( isset( $this->settings[ $setting_name ] ) ){
54 54
 
55
-            return $this->settings[ $setting_name ];
55
+			return $this->settings[ $setting_name ];
56 56
 
57
-        }
57
+		}
58 58
 
59
-        return false;
60
-    }
59
+		return false;
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * Register the settings screen within the WordPress admin.
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
146 146
 		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
147 147
 
148
-	    $fields = array();
148
+		$fields = array();
149 149
 
150 150
 		$fields['access_permission'] = array(
151 151
 								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 								'section' => 'default-settings'
208 208
 								);
209 209
 
210
-    	// Course Settings
210
+		// Course Settings
211 211
 
212
-    	$fields['course_completion'] = array(
212
+		$fields['course_completion'] = array(
213 213
 								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
214 214
 								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
215 215
 								'type' => 'select',
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 								'options' => $complete_settings
220 220
 								);
221 221
 
222
-    	$fields['course_author'] = array(
222
+		$fields['course_author'] = array(
223 223
 								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
224 224
 								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
225 225
 								'type' => 'checkbox',
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
 		);
448 448
 
449 449
 		$teacher_email_options = array(
450
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
450
+			'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
+			'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
+			'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
+			'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
454 454
 			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
455 455
 		);
456 456
 
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 
560 560
 		if ( Sensei_WC::is_woocommerce_active() ) {
561 561
 			// WooCommerce Settings
562
-    		$fields['woocommerce_enabled'] = array(
562
+			$fields['woocommerce_enabled'] = array(
563 563
 									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
564 564
 									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
565 565
 									'type' => 'checkbox',
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
648 648
 
649 649
 		foreach ( $pages_split as $k => $v ) {
650
-		    $id = '';
651
-		    // Get the ID value.
652
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
653
-
654
-		    if ( isset( $matches[1] ) ) {
655
-		        $id = $matches[1];
656
-		        $page_items[$id] = trim( strip_tags( $v ) );
657
-		    } // End If Statement
650
+			$id = '';
651
+			// Get the ID value.
652
+			preg_match( '/value="(.*?)"/i', $v, $matches );
653
+
654
+			if ( isset( $matches[1] ) ) {
655
+				$id = $matches[1];
656
+				$page_items[$id] = trim( strip_tags( $v ) );
657
+			} // End If Statement
658 658
 		} // End For Loop
659 659
 
660 660
 		$pages_array = $page_items;
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
 		Sensei_Language_Pack_Manager::messages();
672 672
 	}
673 673
 
674
-    /**
675
-     * Flush the rewrite rules after the settings have been updated.
676
-     * This is to ensure that the
677
-     *
678
-     * @since 1.9.0
679
-     */
680
-    public static function flush_rewrite_rules(){
674
+	/**
675
+	 * Flush the rewrite rules after the settings have been updated.
676
+	 * This is to ensure that the
677
+	 *
678
+	 * @since 1.9.0
679
+	 */
680
+	public static function flush_rewrite_rules(){
681 681
 
682
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
682
+		if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
+			&& isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
684 684
 
685
-            Sensei()->initiate_rewrite_rules_flush();
685
+			Sensei()->initiate_rewrite_rules_flush();
686 686
 
687
-        }
687
+		}
688 688
 
689
-    }//end  flush_cache
689
+	}//end  flush_cache
690 690
 } // End Class
691 691
 
692 692
 /**
Please login to merge, or discard this patch.
includes/class-sensei-admin.php 1 patch
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	public function __construct () {
22 22
 
23
-        //register admin styles
23
+		//register admin styles
24 24
 		add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) );
25 25
 
26
-        //register admin scripts
27
-        add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
26
+		//register admin scripts
27
+		add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
28 28
 
29 29
 		add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) );
30 30
 		add_action( 'settings_before_form', array( $this, 'install_pages_output' ) );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
34 34
 		add_action( 'admin_init', array( $this, 'page_redirect' ) );
35 35
 		add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
36
-        add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
36
+		add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
37 37
 
38 38
 		// Duplicate lesson & courses
39 39
 		add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 );
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 		if( $menu_cap ) {
86 86
 			$menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' );
87
-            add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
87
+			add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
88 88
 		}
89 89
 
90 90
 		add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) );
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 			$submenu_file = 'edit-tags.php?taxonomy=course-category&amp;post_type=course';
142 142
 			$parent_file  = 'edit.php?post_type=course';
143 143
 
144
-        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
144
+		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
145 145
 
146
-            $submenu_file = 'edit-tags.php?taxonomy=module';
147
-            $parent_file  = 'edit.php?post_type=course';
146
+			$submenu_file = 'edit-tags.php?taxonomy=module';
147
+			$parent_file  = 'edit.php?post_type=course';
148 148
 
149 149
 		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) {
150 150
 
151
-            $submenu_file = 'edit.php?post_type=sensei_message';
151
+			$submenu_file = 'edit.php?post_type=sensei_message';
152 152
 			$parent_file  = 'sensei';
153 153
 
154 154
 		}
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	function install_pages_output() {
178 178
 
179
-        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
179
+		if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
180 180
 
181
-            ?>
181
+			?>
182 182
             <div id="message" class="updated sensei-message sensei-connect">
183 183
                 <p><?php _e( '<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p>
184 184
                 <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a>
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             </div>
187 187
             <?php
188 188
 
189
-        }
189
+		}
190 190
 
191 191
 	} // End install_pages_output()
192 192
 
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
 		endif;
219 219
 
220 220
 		$page_data = array(
221
-	        'post_status' 		=> 'publish',
222
-	        'post_type' 		=> 'page',
223
-	        'post_author' 		=> 1,
224
-	        'post_name' 		=> $slug,
225
-	        'post_title' 		=> $page_title,
226
-	        'post_content' 		=> $page_content,
227
-	        'post_parent' 		=> $post_parent,
228
-	        'comment_status' 	=> 'closed'
229
-	    );
230
-	    $page_id = wp_insert_post( $page_data );
231
-
232
-	    update_option( $option, $page_id );
221
+			'post_status' 		=> 'publish',
222
+			'post_type' 		=> 'page',
223
+			'post_author' 		=> 1,
224
+			'post_name' 		=> $slug,
225
+			'post_title' 		=> $page_title,
226
+			'post_content' 		=> $page_content,
227
+			'post_parent' 		=> $post_parent,
228
+			'comment_status' 	=> 'closed'
229
+		);
230
+		$page_id = wp_insert_post( $page_data );
231
+
232
+		update_option( $option, $page_id );
233 233
 	} // End create_page()
234 234
 
235 235
 
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	function create_pages() {
243 243
 
244 244
 		// Courses page
245
-	    $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
245
+		$this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
246 246
 
247 247
 		// User Dashboard page
248
-	    $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
248
+		$this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
249 249
 
250 250
 	} // End create_pages()
251 251
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 		wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' );
267 267
 		wp_enqueue_style( 'woothemes-sensei-global' );
268 268
 
269
-        // Select 2 styles
270
-        wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
269
+		// Select 2 styles
270
+		wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
271 271
 
272 272
 		// Test for Write Panel Pages
273 273
 		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
@@ -280,32 +280,32 @@  discard block
 block discarded – undo
280 280
 	} // End admin_styles_global()
281 281
 
282 282
 
283
-    /**
284
-     * Globally register all scripts needed in admin.
285
-     *
286
-     * The script users should enqueue the script when needed.
287
-     *
288
-     * @since 1.8.2
289
-     * @access public
290
-     */
291
-    public function register_scripts( $hook ){
283
+	/**
284
+	 * Globally register all scripts needed in admin.
285
+	 *
286
+	 * The script users should enqueue the script when needed.
287
+	 *
288
+	 * @since 1.8.2
289
+	 * @access public
290
+	 */
291
+	public function register_scripts( $hook ){
292 292
 
293
-        $screen = get_current_screen();
293
+		$screen = get_current_screen();
294 294
 
295
-        // Allow developers to load non-minified versions of scripts
296
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
295
+		// Allow developers to load non-minified versions of scripts
296
+		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
297 297
 
298
-        // Select2 script used to enhance all select boxes
299
-        wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
298
+		// Select2 script used to enhance all select boxes
299
+		wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
300 300
 
301
-        // load edit module scripts
302
-        if( 'edit-module' ==  $screen->id ){
301
+		// load edit module scripts
302
+		if( 'edit-module' ==  $screen->id ){
303 303
 
304
-            wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
304
+			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
305 305
 
306
-        }
306
+		}
307 307
 
308
-    }
308
+	}
309 309
 
310 310
 
311 311
 	/**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @return void
316 316
 	 */
317 317
 	function admin_install_notice() {
318
-	    ?>
318
+		?>
319 319
 	    <div id="message" class="updated sensei-message sensei-connect">
320 320
 
321 321
             <p>
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * @return void
351 351
 	 */
352 352
 	function admin_installed_notice() {
353
-	    ?>
353
+		?>
354 354
 	    <div id="message" class="updated sensei-message sensei-connect">
355 355
 
356 356
 	    	<p>
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	    </div>
379 379
 	    <?php
380 380
 
381
-	    // Set installed option
382
-	    update_option('sensei_installed', 0);
381
+		// Set installed option
382
+		update_option('sensei_installed', 0);
383 383
 	} // End admin_installed_notice()
384 384
 
385 385
 
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
 	function admin_notices_styles() {
412 412
 
413 413
 		// Installed notices
414
-	    if ( 1 == get_option( 'sensei_installed' ) ) {
414
+		if ( 1 == get_option( 'sensei_installed' ) ) {
415 415
 
416
-	    	wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
416
+			wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
417 417
 
418
-	    	if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
419
-	    		add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
420
-	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
421
-	    		add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
422
-	    	} // End If Statement
418
+			if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
419
+				add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
420
+			} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
421
+				add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
422
+			} // End If Statement
423 423
 
424
-	    } // End If Statement
424
+		} // End If Statement
425 425
 
426
-	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
427
-	    	add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
428
-	    }
426
+		if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
427
+			add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
428
+		}
429 429
 
430 430
 	} // End admin_notices_styles()
431 431
 
@@ -541,30 +541,30 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) {
543 543
 
544
-        $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
545
-        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
544
+		$old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
545
+		$old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
546 546
 
547
-        // duplicate the generic wp post information
547
+		// duplicate the generic wp post information
548 548
 		$new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' );
549 549
 
550 550
 		//update the new lesson data
551
-        add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
551
+		add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
552 552
 
553 553
 		//update the new quiz data
554
-        add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
555
-        wp_update_post(
556
-            array(
557
-                'ID' => $new_quiz->ID,
558
-                'post_parent' => $new_lesson_id
559
-            )
560
-        );
554
+		add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
555
+		wp_update_post(
556
+			array(
557
+				'ID' => $new_quiz->ID,
558
+				'post_parent' => $new_lesson_id
559
+			)
560
+		);
561 561
 
562 562
 		foreach( $old_quiz_questions as $question ) {
563 563
 
564 564
 			// copy the question order over to the new quiz
565 565
 			$old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true );
566
-            $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
567
-            add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
566
+			$new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
567
+			add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
568 568
 
569 569
 			// Add question to quiz
570 570
 			add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false );
@@ -886,21 +886,21 @@  discard block
 block discarded – undo
886 886
 								break;
887 887
 
888 888
 								case 'checkbox':
889
-                                    //backwards compatibility
890
-                                    if( empty( $data ) || 'on' == $data ){
891
-                                        $checked_value = 'on';
892
-                                    }elseif( 'yes' == $data  ) {
889
+									//backwards compatibility
890
+									if( empty( $data ) || 'on' == $data ){
891
+										$checked_value = 'on';
892
+									}elseif( 'yes' == $data  ) {
893 893
 
894
-                                        $checked_value = 'yes';
894
+										$checked_value = 'yes';
895 895
 
896
-                                    }elseif( 'auto' == $data  ) {
896
+									}elseif( 'auto' == $data  ) {
897 897
 
898
-                                        $checked_value = 'auto';
898
+										$checked_value = 'auto';
899 899
 
900
-                                    } else {
901
-                                        $checked_value = 1;
902
-                                        $data = intval( $data );
903
-                                    }
900
+									} else {
901
+										$checked_value = 1;
902
+										$data = intval( $data );
903
+									}
904 904
 									$checked = checked( $checked_value, $data, false );
905 905
 									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n";
906 906
 								break;
@@ -1004,26 +1004,26 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
 		if( 0 < count( $courses ) ) {
1006 1006
 
1007
-            // order the courses as set by the users
1008
-            $all_course_ids = array();
1009
-            foreach( $courses as $course ){
1007
+			// order the courses as set by the users
1008
+			$all_course_ids = array();
1009
+			foreach( $courses as $course ){
1010 1010
 
1011
-                $all_course_ids[] = (string)$course->ID;
1011
+				$all_course_ids[] = (string)$course->ID;
1012 1012
 
1013
-            }
1014
-            $order_string = $this->get_course_order();
1013
+			}
1014
+			$order_string = $this->get_course_order();
1015 1015
 
1016
-            if( !empty( $order_string ) ){
1017
-                $ordered_course_ids = explode(',' , $order_string );
1018
-                $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1019
-            }
1016
+			if( !empty( $order_string ) ){
1017
+				$ordered_course_ids = explode(',' , $order_string );
1018
+				$all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1019
+			}
1020 1020
 
1021 1021
 
1022 1022
 			$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1023 1023
 			$html .= '<ul class="sortable-course-list">' . "\n";
1024 1024
 			$count = 0;
1025 1025
 			foreach ( $all_course_ids as $course_id ) {
1026
-                $course = get_post( $course_id );
1026
+				$course = get_post( $course_id );
1027 1027
 				$count++;
1028 1028
 				$class = 'course';
1029 1029
 				if ( $count == 1 ) { $class .= ' first'; }
@@ -1138,73 +1138,73 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
 				$displayed_lessons = array();
1140 1140
 
1141
-                $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1142
-
1143
-                foreach( $modules as $module ) {
1144
-
1145
-                    $args = array(
1146
-                        'post_type' => 'lesson',
1147
-                        'post_status' => 'publish',
1148
-                        'posts_per_page' => -1,
1149
-                        'meta_query' => array(
1150
-                            array(
1151
-                                'key' => '_lesson_course',
1152
-                                'value' => intval( $course_id ),
1153
-                                'compare' => '='
1154
-                            )
1155
-                        ),
1156
-                        'tax_query' => array(
1157
-                            array(
1158
-                                'taxonomy' => Sensei()->modules->taxonomy,
1159
-                                'field' => 'id',
1160
-                                'terms' => intval( $module->term_id )
1161
-                            )
1162
-                        ),
1163
-                        'meta_key' => '_order_module_' . $module->term_id,
1164
-                        'orderby' => 'meta_value_num date',
1165
-                        'order' => 'ASC',
1166
-                        'suppress_filters' => 0
1167
-                    );
1168
-
1169
-                    $lessons = get_posts( $args );
1170
-
1171
-                    if( count( $lessons ) > 0 ) {
1172
-                        $html .= '<h3>' . $module->name . '</h3>' . "\n";
1173
-                        $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1174
-
1175
-                        $count = 0;
1176
-                        foreach( $lessons as $lesson ) {
1177
-                            $count++;
1178
-                            $class = 'lesson';
1179
-                            if ( $count == 1 ) { $class .= ' first'; }
1180
-                            if ( $count == count( $lesson ) ) { $class .= ' last'; }
1181
-                            if ( $count % 2 != 0 ) {
1182
-                                $class .= ' alternate';
1183
-                            }
1184
-
1185
-                            $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1186
-
1187
-                            $displayed_lessons[] = $lesson->ID;
1188
-                        }
1189
-
1190
-                        $html .= '</ul>' . "\n";
1191
-
1192
-                        $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1193
-                    }
1194
-                }
1195
-
1196
-
1197
-                $lessons = Sensei()->course->course_lessons( $course_id );
1141
+				$modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1142
+
1143
+				foreach( $modules as $module ) {
1144
+
1145
+					$args = array(
1146
+						'post_type' => 'lesson',
1147
+						'post_status' => 'publish',
1148
+						'posts_per_page' => -1,
1149
+						'meta_query' => array(
1150
+							array(
1151
+								'key' => '_lesson_course',
1152
+								'value' => intval( $course_id ),
1153
+								'compare' => '='
1154
+							)
1155
+						),
1156
+						'tax_query' => array(
1157
+							array(
1158
+								'taxonomy' => Sensei()->modules->taxonomy,
1159
+								'field' => 'id',
1160
+								'terms' => intval( $module->term_id )
1161
+							)
1162
+						),
1163
+						'meta_key' => '_order_module_' . $module->term_id,
1164
+						'orderby' => 'meta_value_num date',
1165
+						'order' => 'ASC',
1166
+						'suppress_filters' => 0
1167
+					);
1168
+
1169
+					$lessons = get_posts( $args );
1170
+
1171
+					if( count( $lessons ) > 0 ) {
1172
+						$html .= '<h3>' . $module->name . '</h3>' . "\n";
1173
+						$html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1174
+
1175
+						$count = 0;
1176
+						foreach( $lessons as $lesson ) {
1177
+							$count++;
1178
+							$class = 'lesson';
1179
+							if ( $count == 1 ) { $class .= ' first'; }
1180
+							if ( $count == count( $lesson ) ) { $class .= ' last'; }
1181
+							if ( $count % 2 != 0 ) {
1182
+								$class .= ' alternate';
1183
+							}
1184
+
1185
+							$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1186
+
1187
+							$displayed_lessons[] = $lesson->ID;
1188
+						}
1189
+
1190
+						$html .= '</ul>' . "\n";
1191
+
1192
+						$html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1193
+					}
1194
+				}
1195
+
1196
+
1197
+				$lessons = Sensei()->course->course_lessons( $course_id );
1198 1198
 
1199 1199
 				if( 0 < count( $lessons ) ) {
1200 1200
 
1201
-                    //get module term ids, will be used to exclude lessons
1202
-                    $module_items_ids = array();
1203
-                    if( ! empty( $modules ) ) {
1204
-                        foreach ($modules as $module) {
1205
-                            $module_items_ids[] = $module->term_id;
1206
-                        }
1207
-                    }
1201
+					//get module term ids, will be used to exclude lessons
1202
+					$module_items_ids = array();
1203
+					if( ! empty( $modules ) ) {
1204
+						foreach ($modules as $module) {
1205
+							$module_items_ids[] = $module->term_id;
1206
+						}
1207
+					}
1208 1208
 
1209 1209
 					if( 0 < count( $displayed_lessons ) ) {
1210 1210
 						$html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n";
@@ -1214,13 +1214,13 @@  discard block
 block discarded – undo
1214 1214
 					$count = 0;
1215 1215
 					foreach ( $lessons as $lesson ) {
1216 1216
 
1217
-                        // if lesson belongs to one fo the course modules then exclude it here
1218
-                        // as it is listed above
1219
-                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1217
+						// if lesson belongs to one fo the course modules then exclude it here
1218
+						// as it is listed above
1219
+						if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1220 1220
 
1221
-                            continue;
1221
+							continue;
1222 1222
 
1223
-                        }
1223
+						}
1224 1224
 
1225 1225
 						$count++;
1226 1226
 						$class = 'lesson';
@@ -1264,23 +1264,23 @@  discard block
 block discarded – undo
1264 1264
 
1265 1265
 		if( $course_id ) {
1266 1266
 
1267
-            $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1267
+			$modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1268 1268
 
1269
-            foreach( $modules as $module ) {
1269
+			foreach( $modules as $module ) {
1270 1270
 
1271
-                $module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ];
1271
+				$module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ];
1272 1272
 
1273
-                if( $module_order_string ) {
1274
-                    $order = explode( ',', $module_order_string );
1275
-                    $i = 1;
1276
-                    foreach( $order as $lesson_id ) {
1277
-                        if( $lesson_id ) {
1278
-                            update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1279
-                            ++$i;
1280
-                        }
1281
-                    }
1282
-                }
1283
-            }
1273
+				if( $module_order_string ) {
1274
+					$order = explode( ',', $module_order_string );
1275
+					$i = 1;
1276
+					foreach( $order as $lesson_id ) {
1277
+						if( $lesson_id ) {
1278
+							update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1279
+							++$i;
1280
+						}
1281
+					}
1282
+				}
1283
+			}
1284 1284
 
1285 1285
 
1286 1286
 			if( $order_string ) {
@@ -1363,47 +1363,47 @@  discard block
 block discarded – undo
1363 1363
 
1364 1364
 	/**
1365 1365
 	 * Adding admin notice if the current
1366
-     * installed theme is not compatible
1367
-     *
1366
+	 * installed theme is not compatible
1367
+	 *
1368 1368
 	 * @return void
1369 1369
 	 */
1370 1370
 	public function theme_compatibility_notices() {
1371 1371
 
1372
-        if( isset( $_GET['sensei_hide_notice'] ) ) {
1373
-        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1372
+		if( isset( $_GET['sensei_hide_notice'] ) ) {
1373
+			switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1374 1374
 				case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break;
1375 1375
 				case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break;
1376 1376
 			}
1377
-        }
1377
+		}
1378 1378
 
1379
-        // white list templates that are already support by default and do not show notice for them
1380
-        $template = get_option( 'template' );
1379
+		// white list templates that are already support by default and do not show notice for them
1380
+		$template = get_option( 'template' );
1381 1381
 
1382
-        $white_list = array(    'twentyeleven',
1383
-                                'twentytwelve',
1384
-                                'twentyfourteen',
1385
-                                'twentyfifteen',
1386
-                                'twentysixteen',
1387
-                                'storefront',
1388
-                                                );
1382
+		$white_list = array(    'twentyeleven',
1383
+								'twentytwelve',
1384
+								'twentyfourteen',
1385
+								'twentyfifteen',
1386
+								'twentysixteen',
1387
+								'storefront',
1388
+												);
1389 1389
 
1390
-        if ( in_array( $template, $white_list ) ) {
1390
+		if ( in_array( $template, $white_list ) ) {
1391 1391
 
1392
-            return;
1392
+			return;
1393 1393
 
1394
-        }
1394
+		}
1395 1395
 
1396
-        // don't show the notice if the user chose to hide it
1397
-        $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1398
-        if(  $hide_theme_check_notice ) {
1396
+		// don't show the notice if the user chose to hide it
1397
+		$hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1398
+		if(  $hide_theme_check_notice ) {
1399 1399
 
1400
-            return;
1400
+			return;
1401 1401
 
1402
-        }
1402
+		}
1403 1403
 
1404
-        // show the notice for themes not supporting sensei
1405
-	    if ( ! current_theme_supports( 'sensei' ) ) {
1406
-            ?>
1404
+		// show the notice for themes not supporting sensei
1405
+		if ( ! current_theme_supports( 'sensei' ) ) {
1406
+			?>
1407 1407
 
1408 1408
             <div id="message" class="error sensei-message sensei-connect">
1409 1409
                     <p>
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 	public function reset_theme_check_notices() {
1440 1440
 		global $current_user;
1441 1441
 		wp_get_current_user();
1442
-        $user_id = $current_user->ID;
1442
+		$user_id = $current_user->ID;
1443 1443
 
1444 1444
 		delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' );
1445 1445
 	}
@@ -1459,60 +1459,60 @@  discard block
 block discarded – undo
1459 1459
 		return $prevent_access;
1460 1460
 	}
1461 1461
 
1462
-    /**
1463
-     * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args
1464
-     * on the sensei settings page.
1465
-     *
1466
-     * The function
1467
-     *
1468
-     * @since 1.8.7
1469
-     */
1470
-    public  static function install_pages(){
1462
+	/**
1463
+	 * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args
1464
+	 * on the sensei settings page.
1465
+	 *
1466
+	 * The function
1467
+	 *
1468
+	 * @since 1.8.7
1469
+	 */
1470
+	public  static function install_pages(){
1471 1471
 
1472
-        // only fire on the settings page
1473
-        if( ! isset( $_GET['page'] )
1474
-            || 'woothemes-sensei-settings' != $_GET['page']
1475
-            || 1 == get_option('skip_install_sensei_pages') ){
1472
+		// only fire on the settings page
1473
+		if( ! isset( $_GET['page'] )
1474
+			|| 'woothemes-sensei-settings' != $_GET['page']
1475
+			|| 1 == get_option('skip_install_sensei_pages') ){
1476 1476
 
1477
-            return;
1477
+			return;
1478 1478
 
1479
-        }
1479
+		}
1480 1480
 
1481
-        // Install/page installer
1482
-        $install_complete = false;
1481
+		// Install/page installer
1482
+		$install_complete = false;
1483 1483
 
1484
-        // Add pages button
1485
-        $settings_url = '';
1486
-        if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) {
1484
+		// Add pages button
1485
+		$settings_url = '';
1486
+		if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) {
1487 1487
 
1488
-            Sensei()->admin->create_pages();
1489
-            update_option('skip_install_sensei_pages', 1);
1490
-            $install_complete = true;
1491
-            $settings_url = remove_query_arg('install_sensei_pages');
1488
+			Sensei()->admin->create_pages();
1489
+			update_option('skip_install_sensei_pages', 1);
1490
+			$install_complete = true;
1491
+			$settings_url = remove_query_arg('install_sensei_pages');
1492 1492
 
1493
-            // Skip button
1494
-        } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) {
1493
+			// Skip button
1494
+		} elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) {
1495 1495
 
1496
-            update_option('skip_install_sensei_pages', 1);
1497
-            $install_complete = true;
1498
-            $settings_url = remove_query_arg('skip_install_sensei_pages');
1496
+			update_option('skip_install_sensei_pages', 1);
1497
+			$install_complete = true;
1498
+			$settings_url = remove_query_arg('skip_install_sensei_pages');
1499 1499
 
1500
-        }
1500
+		}
1501 1501
 
1502
-        if ($install_complete) {
1502
+		if ($install_complete) {
1503 1503
 
1504
-            // Flush rules after install
1505
-            flush_rewrite_rules( true );
1504
+			// Flush rules after install
1505
+			flush_rewrite_rules( true );
1506 1506
 
1507
-            // Set installed option
1508
-            update_option('sensei_installed', 0);
1507
+			// Set installed option
1508
+			update_option('sensei_installed', 0);
1509 1509
 
1510
-            $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1511
-            wp_redirect( $complete_url );
1510
+			$complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1511
+			wp_redirect( $complete_url );
1512 1512
 
1513
-        }
1513
+		}
1514 1514
 
1515
-    }// end install_pages
1515
+	}// end install_pages
1516 1516
 
1517 1517
 } // End Class
1518 1518
 
Please login to merge, or discard this patch.
includes/theme-integrations/theme-integration-loader.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -10,91 +10,91 @@
 block discarded – undo
10 10
  */
11 11
 class Sensei_Theme_Integration_Loader {
12 12
 
13
-    /**
14
-     * @var array
15
-     * Holding a reference core supported themes
16
-     */
17
-    protected $themes;
18
-
19
-    /**
20
-     * @var string
21
-     * reference to the theme currently active on this site
22
-     */
23
-    protected $active_theme;
24
-
25
-    public function __construct() {
26
-
27
-        $this->setup_themes();
28
-        $this->setup_currently_active_theme();
29
-        $this->possibly_load_supported_theme_wrappers();
30
-
31
-    }
32
-
33
-    /**
34
-     * Setup the theme slugs supported by Sensei Core
35
-     *
36
-     * @since 1.9.0
37
-     */
38
-    private function setup_themes(){
39
-
40
-        $this->themes = array(
41
-            'twentyeleven',
42
-            'twentytwelve',
43
-            'twentythirteen',
44
-            'twentyfourteen',
45
-            'twentyfifteen',
46
-            'twentysixteen',
47
-            'storefront',
48
-        );
49
-
50
-    }// end setup themes
51
-
52
-    /**
53
-     * Setup the currently active theme
54
-     *
55
-     * @since 1.9.0
56
-     */
57
-    private function setup_currently_active_theme(){
58
-
59
-        $this->active_theme = get_option('template');
60
-
61
-    }
62
-
63
-    /**
64
-     * Remove default Sensei wrappers and load
65
-     * supported wrappers if the current theme is
66
-     * a theme we have an integration for within core.
67
-     *
68
-     * @since 1.9.0
69
-     */
70
-    private function possibly_load_supported_theme_wrappers(){
71
-
72
-        if ( in_array( $this->active_theme, $this->themes ) ){
73
-
74
-            // setup file and class names
75
-            $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
76
-            $supported_theme_class_name  = 'Sensei_'. ucfirst( $this->active_theme  );
77
-
78
-            // load the file or exit if there is no file for this theme
79
-            if( ! file_exists( $supported_theme_class_file ) ){
80
-                return;
81
-            }
82
-            include_once( $supported_theme_class_file );
83
-            include_once( 'twentytwelve.php' );
84
-            //initialize the class or exit if there is no class for this theme
85
-            if( ! class_exists( $supported_theme_class_name ) ){
86
-                return;
87
-            }
88
-            $supported_theme = new $supported_theme_class_name;
89
-
90
-            // remove default wrappers
91
-            remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
92
-            remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
93
-
94
-            // load the supported theme wrappers
95
-            add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
96
-            add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
97
-        }
98
-    }
13
+	/**
14
+	 * @var array
15
+	 * Holding a reference core supported themes
16
+	 */
17
+	protected $themes;
18
+
19
+	/**
20
+	 * @var string
21
+	 * reference to the theme currently active on this site
22
+	 */
23
+	protected $active_theme;
24
+
25
+	public function __construct() {
26
+
27
+		$this->setup_themes();
28
+		$this->setup_currently_active_theme();
29
+		$this->possibly_load_supported_theme_wrappers();
30
+
31
+	}
32
+
33
+	/**
34
+	 * Setup the theme slugs supported by Sensei Core
35
+	 *
36
+	 * @since 1.9.0
37
+	 */
38
+	private function setup_themes(){
39
+
40
+		$this->themes = array(
41
+			'twentyeleven',
42
+			'twentytwelve',
43
+			'twentythirteen',
44
+			'twentyfourteen',
45
+			'twentyfifteen',
46
+			'twentysixteen',
47
+			'storefront',
48
+		);
49
+
50
+	}// end setup themes
51
+
52
+	/**
53
+	 * Setup the currently active theme
54
+	 *
55
+	 * @since 1.9.0
56
+	 */
57
+	private function setup_currently_active_theme(){
58
+
59
+		$this->active_theme = get_option('template');
60
+
61
+	}
62
+
63
+	/**
64
+	 * Remove default Sensei wrappers and load
65
+	 * supported wrappers if the current theme is
66
+	 * a theme we have an integration for within core.
67
+	 *
68
+	 * @since 1.9.0
69
+	 */
70
+	private function possibly_load_supported_theme_wrappers(){
71
+
72
+		if ( in_array( $this->active_theme, $this->themes ) ){
73
+
74
+			// setup file and class names
75
+			$supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
76
+			$supported_theme_class_name  = 'Sensei_'. ucfirst( $this->active_theme  );
77
+
78
+			// load the file or exit if there is no file for this theme
79
+			if( ! file_exists( $supported_theme_class_file ) ){
80
+				return;
81
+			}
82
+			include_once( $supported_theme_class_file );
83
+			include_once( 'twentytwelve.php' );
84
+			//initialize the class or exit if there is no class for this theme
85
+			if( ! class_exists( $supported_theme_class_name ) ){
86
+				return;
87
+			}
88
+			$supported_theme = new $supported_theme_class_name;
89
+
90
+			// remove default wrappers
91
+			remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
92
+			remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
93
+
94
+			// load the supported theme wrappers
95
+			add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
96
+			add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
97
+		}
98
+	}
99 99
 
100 100
 } /// end class
101 101
\ No newline at end of file
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfourteen.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 */
10 10
 Class Sensei_Twentyfourteen {
11 11
 
12
-    /**
13
-     * Output opening wrappers
14
-     * @since 1.9.0
15
-     */
16
-    public function wrapper_start(){
17
-    ?>
12
+	/**
13
+	 * Output opening wrappers
14
+	 * @since 1.9.0
15
+	 */
16
+	public function wrapper_start(){
17
+	?>
18 18
 
19 19
         <div id="main-content" class="main-content">
20 20
             <div id="primary" class="content-area">
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 
24 24
     <?php }
25 25
 
26
-    /**
27
-     * Output closing wrappers
28
-     *
29
-     * @since 1.9.0
30
-     */
31
-    public function wrapper_end(){ ?>
26
+	/**
27
+	 * Output closing wrappers
28
+	 *
29
+	 * @since 1.9.0
30
+	 */
31
+	public function wrapper_end(){ ?>
32 32
 
33 33
 
34 34
                     </div>
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
         </div>
38 38
 
39 39
         <?php
40
-        get_sidebar();
40
+		get_sidebar();
41 41
 	 }
42 42
 
43 43
 }
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfifteen.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,28 +9,28 @@
 block discarded – undo
9 9
 */
10 10
 Class Sensei_Twentyfifteen extends Sensei__S {
11 11
 
12
-    /**
13
-     * Output opening wrappers
14
-     * @since 1.9.0
15
-     */
16
-    public function wrapper_start(){
12
+	/**
13
+	 * Output opening wrappers
14
+	 * @since 1.9.0
15
+	 */
16
+	public function wrapper_start(){
17 17
 
18
-        // output inline styles
19
-        $this->print_styles();
18
+		// output inline styles
19
+		$this->print_styles();
20 20
 
21
-        // call the parent starting wrappers
22
-        parent::wrapper_start();
21
+		// call the parent starting wrappers
22
+		parent::wrapper_start();
23 23
 
24
-    }
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * Output the style for the
29
-     * twenty fifteen theme integration.
30
-     *
31
-     * @since 1.9.0
32
-     */
33
-    private function print_styles(){?>
27
+	/**
28
+	 * Output the style for the
29
+	 * twenty fifteen theme integration.
30
+	 *
31
+	 * @since 1.9.0
32
+	 */
33
+	private function print_styles(){?>
34 34
 
35 35
         <style>
36 36
             @media screen and (min-width: 59.6875em){
Please login to merge, or discard this patch.
includes/theme-integrations/_s.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,29 +9,29 @@
 block discarded – undo
9 9
 */
10 10
 Class Sensei__S {
11 11
 
12
-    /**
13
-     * Output opening wrappers
14
-     * @since 1.9.0
15
-     */
16
-    public function wrapper_start(){ ?>
12
+	/**
13
+	 * Output opening wrappers
14
+	 * @since 1.9.0
15
+	 */
16
+	public function wrapper_start(){ ?>
17 17
         <div id="primary" class="content-area">
18 18
             <main id="main" class="site-main" role="main">
19 19
 
20 20
     <?php }
21 21
 
22
-    /**
23
-     * Output closing wrappers
24
-     *
25
-     * @since 1.9.0
26
-     */
27
-    public function wrapper_end(){ ?>
22
+	/**
23
+	 * Output closing wrappers
24
+	 *
25
+	 * @since 1.9.0
26
+	 */
27
+	public function wrapper_end(){ ?>
28 28
 
29 29
             </main> <!-- main-site -->
30 30
           </div> <!-- content-area -->
31 31
 
32 32
 	    <?php
33 33
 
34
-        get_sidebar();
34
+		get_sidebar();
35 35
 
36
-    }
36
+	}
37 37
 } // end class
Please login to merge, or discard this patch.
includes/theme-integrations/twentythirteen.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,24 +9,24 @@
 block discarded – undo
9 9
 */
10 10
 Class Sensei_Twentythirteen {
11 11
 
12
-    /**
13
-     * Output opening wrappers
14
-     * @since 1.9.0
15
-     */
16
-    public function wrapper_start(){
17
-    ?>
12
+	/**
13
+	 * Output opening wrappers
14
+	 * @since 1.9.0
15
+	 */
16
+	public function wrapper_start(){
17
+	?>
18 18
 
19 19
         <div id="primary" class="site-content">
20 20
             <div id="content" role="main" class="entry-content">
21 21
 
22 22
     <?php }
23 23
 
24
-    /**
25
-     * Output closing wrappers
26
-     *
27
-     * @since 1.9.0
28
-     */
29
-    public function wrapper_end(){ ?>
24
+	/**
25
+	 * Output closing wrappers
26
+	 *
27
+	 * @since 1.9.0
28
+	 */
29
+	public function wrapper_end(){ ?>
30 30
 
31 31
 			</div>
32 32
 		</div>
Please login to merge, or discard this patch.
includes/theme-integrations/twentytwelve.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,24 +9,24 @@
 block discarded – undo
9 9
 */
10 10
 Class Sensei_Twentythirteen {
11 11
 
12
-    /**
13
-     * Output opening wrappers
14
-     * @since 1.9.0
15
-     */
16
-    public function wrapper_start(){
17
-    ?>
12
+	/**
13
+	 * Output opening wrappers
14
+	 * @since 1.9.0
15
+	 */
16
+	public function wrapper_start(){
17
+	?>
18 18
 
19 19
         <div id="primary" class="site-content">
20 20
             <div id="content" role="main" class="entry-content">
21 21
 
22 22
     <?php }
23 23
 
24
-    /**
25
-     * Output closing wrappers
26
-     *
27
-     * @since 1.9.0
28
-     */
29
-    public function wrapper_end(){ ?>
24
+	/**
25
+	 * Output closing wrappers
26
+	 *
27
+	 * @since 1.9.0
28
+	 */
29
+	public function wrapper_end(){ ?>
30 30
 
31 31
 			</div>
32 32
 		</div>
Please login to merge, or discard this patch.