Completed
Push — master ( c847f3...1a4e84 )
by Dwain
05:11
created
includes/emails/class-woothemes-sensei-email-teacher-completed-course.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Completed_Course' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Completed_Course')) :
6 6
 
7 7
 /**
8 8
  * Teacher Completed Course
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function __construct() {
33 33
 		$this->template = 'teacher-completed-course';
34
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has completed a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
35
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has completed a course', 'woothemes-sensei' ), $this->template );
34
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has completed a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
35
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has completed a course', 'woothemes-sensei'), $this->template);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
 	 * @access public
42 42
 	 * @return void
43 43
 	 */
44
-	function trigger( $learner_id = 0, $course_id = 0 ) {
44
+	function trigger($learner_id = 0, $course_id = 0) {
45 45
 		global  $sensei_email_data;
46 46
 
47 47
 		// Get learner user object
48
-		$this->learner = new WP_User( $learner_id );
48
+		$this->learner = new WP_User($learner_id);
49 49
 
50 50
 		// Get teacher ID and user object
51
-		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
52
-		$this->teacher = new WP_User( $teacher_id );
51
+		$teacher_id = get_post_field('post_author', $course_id, 'raw');
52
+		$this->teacher = new WP_User($teacher_id);
53 53
 
54 54
 		// Get passed status
55
-		$passed = __( 'passed', 'woothemes-sensei' );
56
-		if( ! Sensei_Utils::sensei_user_passed_course( $course_id, $learner_id ) ) {
57
-			$passed = __( 'failed', 'woothemes-sensei' );
55
+		$passed = __('passed', 'woothemes-sensei');
56
+		if ( ! Sensei_Utils::sensei_user_passed_course($course_id, $learner_id)) {
57
+			$passed = __('failed', 'woothemes-sensei');
58 58
 		}
59 59
 
60 60
 		// Construct data array
61
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
61
+		$sensei_email_data = apply_filters('sensei_email_data', array(
62 62
 			'template'			=> $this->template,
63 63
 			'heading'			=> $this->heading,
64 64
 			'teacher_id'		=> $teacher_id,
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 			'learner_name'		=> $this->learner->display_name,
67 67
 			'course_id'			=> $course_id,
68 68
 			'passed'			=> $passed,
69
-		), $this->template );
69
+		), $this->template);
70 70
 
71 71
 		// Set recipient (learner)
72
-		$this->recipient = stripslashes( $this->teacher->user_email );
72
+		$this->recipient = stripslashes($this->teacher->user_email);
73 73
 
74 74
 		// Send mail
75
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
75
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
76 76
 	}
77 77
 }
78 78
 
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * trigger function.
39 39
 	 *
40
-     * @param int $learner_id
41
-     * @param int $course_id
42
-     *
40
+	 * @param int $learner_id
41
+	 * @param int $course_id
42
+	 *
43 43
 	 * @return void
44 44
 	 */
45 45
 	function trigger( $learner_id = 0, $course_id = 0 ) {
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-new-message-reply.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class WooThemes_Sensei_Email_New_Message_Reply {
18 18
 
19
-    /**
20
-     * @var string
21
-     */
22
-    var $template;
23
-
24
-    /**
25
-     * @var string
26
-     */
19
+	/**
20
+	 * @var string
21
+	 */
22
+	var $template;
23
+
24
+	/**
25
+	 * @var string
26
+	 */
27 27
 	var $subject;
28 28
 
29
-    /**
30
-     * @var string
31
-     */
32
-    var $heading;
29
+	/**
30
+	 * @var string
31
+	 */
32
+	var $heading;
33 33
 
34
-    /**
35
-     * @var string
36
-     */
34
+	/**
35
+	 * @var string
36
+	 */
37 37
 	var $recipient;
38 38
 
39 39
 	var $original_sender;
40 40
 	var $original_receiver;
41 41
 	var $commenter;
42 42
 
43
-    /**
44
-     * @var WP_Post
45
-     */
43
+	/**
44
+	 * @var WP_Post
45
+	 */
46 46
 	var $message;
47 47
 
48
-    /**
49
-     * @var WP_Comment
50
-     */
48
+	/**
49
+	 * @var WP_Comment
50
+	 */
51 51
 	var $comment;
52 52
 
53 53
 	/**
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * trigger function.
66 66
 	 *
67
-     * @param WP_Comment $comment
68
-     * @param string $message
69
-     *
67
+	 * @param WP_Comment $comment
68
+	 * @param string $message
69
+	 *
70 70
 	 * @return void
71 71
 	 */
72 72
 	function trigger ( $comment, $message ) {
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 
91 91
 		$comment_link = get_comment_link( $comment );
92 92
 
93
-        // setup the post type parameter
94
-        $content_type = get_post_type( $content_id );
95
-        if( !$content_type ){
96
-            $content_type ='';
97
-        }
93
+		// setup the post type parameter
94
+		$content_type = get_post_type( $content_id );
95
+		if( !$content_type ){
96
+			$content_type ='';
97
+		}
98 98
 
99
-        // Construct data array
100
-        $sensei_email_data = apply_filters( 'sensei_email_data', array(
101
-            'template'			=> $this->template,
102
-            $content_type.'_id' => $content_id,
99
+		// Construct data array
100
+		$sensei_email_data = apply_filters( 'sensei_email_data', array(
101
+			'template'			=> $this->template,
102
+			$content_type.'_id' => $content_id,
103 103
 			'heading'			=> $this->heading,
104 104
 			'commenter_name'	=> $this->commenter->display_name,
105 105
 			'message'			=> $this->comment->comment_content,
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_New_Message_Reply' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_New_Message_Reply')) :
6 6
 
7 7
 /**
8 8
  * Teacher New Message
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	function __construct() {
59 59
 		$this->template = 'new-message-reply';
60
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have a new message', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
61
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'You have received a reply to your private message', 'woothemes-sensei' ), $this->template );
60
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have a new message', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
61
+		$this->heading = apply_filters('sensei_email_heading', __('You have received a reply to your private message', 'woothemes-sensei'), $this->template);
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,35 +69,35 @@  discard block
 block discarded – undo
69 69
      *
70 70
 	 * @return void
71 71
 	 */
72
-	function trigger ( $comment, $message ) {
72
+	function trigger($comment, $message) {
73 73
 
74 74
 		global  $sensei_email_data;
75 75
 
76 76
 		$this->comment = $comment;
77 77
 		$this->message = $message;
78 78
 
79
-		$this->commenter = get_userdata( $comment->user_id );
79
+		$this->commenter = get_userdata($comment->user_id);
80 80
 
81
-		$original_sender = get_post_meta( $this->message->ID, '_sender', true );
82
-		$this->original_sender = get_user_by( 'login', $original_sender );
81
+		$original_sender = get_post_meta($this->message->ID, '_sender', true);
82
+		$this->original_sender = get_user_by('login', $original_sender);
83 83
 
84
-		$original_receiver = get_post_meta( $this->message->ID, '_receiver', true );
85
-		$this->original_receiver = get_user_by( 'login', $original_receiver );
84
+		$original_receiver = get_post_meta($this->message->ID, '_receiver', true);
85
+		$this->original_receiver = get_user_by('login', $original_receiver);
86 86
 
87
-		$content_type = get_post_meta( $this->message->ID, '_posttype', true );
88
-		$content_id = get_post_meta( $this->message->ID, '_post', true );
89
-		$content_title = get_the_title( $content_id );
87
+		$content_type = get_post_meta($this->message->ID, '_posttype', true);
88
+		$content_id = get_post_meta($this->message->ID, '_post', true);
89
+		$content_title = get_the_title($content_id);
90 90
 
91
-		$comment_link = get_comment_link( $comment );
91
+		$comment_link = get_comment_link($comment);
92 92
 
93 93
         // setup the post type parameter
94
-        $content_type = get_post_type( $content_id );
95
-        if( !$content_type ){
96
-            $content_type ='';
94
+        $content_type = get_post_type($content_id);
95
+        if ( ! $content_type) {
96
+            $content_type = '';
97 97
         }
98 98
 
99 99
         // Construct data array
100
-        $sensei_email_data = apply_filters( 'sensei_email_data', array(
100
+        $sensei_email_data = apply_filters('sensei_email_data', array(
101 101
             'template'			=> $this->template,
102 102
             $content_type.'_id' => $content_id,
103 103
 			'heading'			=> $this->heading,
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
 			'comment_link'		=> $comment_link,
107 107
 			'content_title'		=> $content_title,
108 108
 			'content_type'		=> $content_type,
109
-		), $this->template );
109
+		), $this->template);
110 110
 
111 111
 		// Set recipient
112
-		if( $this->commenter->user_login == $original_sender ) {
113
-			$this->recipient = stripslashes( $this->original_receiver->user_email );
112
+		if ($this->commenter->user_login == $original_sender) {
113
+			$this->recipient = stripslashes($this->original_receiver->user_email);
114 114
 		} else {
115
-			$this->recipient = stripslashes( $this->original_sender->user_email );
115
+			$this->recipient = stripslashes($this->original_sender->user_email);
116 116
 		}
117 117
 
118 118
 		// Send mail
119
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
119
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
120 120
 	}
121 121
 }
122 122
 
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-learner-graded-quiz.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,11 +36,11 @@
 block discarded – undo
36 36
 	/**
37 37
 	 * trigger function.
38 38
 	 *
39
-     * @param int $user_id
40
-     * @param int $quiz_id
41
-     * @param int $grade
42
-     * @param int $passmark
43
-     *
39
+	 * @param int $user_id
40
+	 * @param int $quiz_id
41
+	 * @param int $grade
42
+	 * @param int $passmark
43
+	 *
44 44
 	 * @return void
45 45
 	 */
46 46
 	function trigger ( $user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0 ) {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Graded_Quiz' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Learner_Graded_Quiz')) :
6 6
 
7 7
 /**
8 8
  * Learner Graded Quiz
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	function __construct() {
31 31
 		$this->template = 'learner-graded-quiz';
32
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your quiz has been graded', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
33
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your quiz has been graded', 'woothemes-sensei' ), $this->template );
32
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your quiz has been graded', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
33
+		$this->heading = apply_filters('sensei_email_heading', __('Your quiz has been graded', 'woothemes-sensei'), $this->template);
34 34
 	}
35 35
 
36 36
 	/**
@@ -43,48 +43,48 @@  discard block
 block discarded – undo
43 43
      *
44 44
 	 * @return void
45 45
 	 */
46
-	function trigger ( $user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0 ) {
46
+	function trigger($user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0) {
47 47
 
48 48
 		global  $sensei_email_data;
49 49
 
50 50
 		// Get learner user object
51
-		$this->user = new WP_User( $user_id );
51
+		$this->user = new WP_User($user_id);
52 52
 
53 53
 		// Get passed flag
54
-		$passed = __( 'failed', 'woothemes-sensei' );
55
-		if( $grade >= $passmark ) {
56
-			$passed = __( 'passed', 'woothemes-sensei' );
54
+		$passed = __('failed', 'woothemes-sensei');
55
+		if ($grade >= $passmark) {
56
+			$passed = __('passed', 'woothemes-sensei');
57 57
 		}
58 58
 
59 59
 		// Get grade tye (auto/manual)
60
-		$grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
60
+		$grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true);
61 61
 
62
-		if( 'auto' == $grade_type ) {
63
-			$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have completed a quiz', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
64
-			$this->heading = apply_filters( 'sensei_email_heading', __( 'You have completed a quiz', 'woothemes-sensei' ), $this->template );
62
+		if ('auto' == $grade_type) {
63
+			$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have completed a quiz', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
64
+			$this->heading = apply_filters('sensei_email_heading', __('You have completed a quiz', 'woothemes-sensei'), $this->template);
65 65
 		}
66 66
 
67
-		$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
67
+		$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
68 68
 
69 69
 		// Construct data array
70
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
70
+		$sensei_email_data = apply_filters('sensei_email_data', array(
71 71
 			'template'			=> $this->template,
72 72
 			'heading'			=> $this->heading,
73 73
 			'user_id'			=> $user_id,
74
-			'user_name'         => stripslashes( $this->user->display_name ),
74
+			'user_name'         => stripslashes($this->user->display_name),
75 75
 			'lesson_id'			=> $lesson_id,
76 76
 			'quiz_id'			=> $quiz_id,
77 77
 			'grade'				=> $grade,
78 78
 			'passmark'			=> $passmark,
79 79
 			'passed'			=> $passed,
80 80
 			'grade_type'		=> $grade_type,
81
-		), $this->template );
81
+		), $this->template);
82 82
 
83 83
 		// Set recipient (learner)
84
-		$this->recipient = stripslashes( $this->user->user_email );
84
+		$this->recipient = stripslashes($this->user->user_email);
85 85
 
86 86
 		// Send mail
87
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
87
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
88 88
 	}
89 89
 }
90 90
 
Please login to merge, or discard this patch.
includes/class-sensei-utils.php 4 patches
Braces   +41 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Utilities Class
@@ -181,8 +184,7 @@  discard block
 block discarded – undo
181 184
 				// ...use a filter to switch the encoding back
182 185
 				add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
183 186
 			}
184
-		}
185
-		else {
187
+		} else {
186 188
 			$args['status'] = 'any'; // 'log' == 'sensei_user_answer'
187 189
 		}
188 190
 
@@ -307,8 +309,12 @@  discard block
 block discarded – undo
307 309
 				}
308 310
 
309 311
 				foreach( $activities as $activity ) {
310
-					if( '' == $activity->comment_type ) continue;
311
-					if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
312
+					if( '' == $activity->comment_type ) {
313
+						continue;
314
+					}
315
+					if( strpos( 'sensei_', $activity->comment_type ) != 0 ) {
316
+						continue;
317
+					}
312 318
 					$dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true );
313 319
 					wp_cache_flush();
314 320
 				}
@@ -360,11 +366,13 @@  discard block
 block discarded – undo
360 366
             $emails[] = $user->user_email;
361 367
         }
362 368
 
363
-        if ( is_email( $customer_email ) )
364
-            $emails[] = $customer_email;
369
+        if ( is_email( $customer_email ) ) {
370
+                    $emails[] = $customer_email;
371
+        }
365 372
 
366
-        if ( sizeof( $emails ) == 0 )
367
-            return false;
373
+        if ( sizeof( $emails ) == 0 ) {
374
+                    return false;
375
+        }
368 376
 
369 377
         return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
370 378
 
@@ -379,7 +387,9 @@  discard block
 block discarded – undo
379 387
 	 */
380 388
 	public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) {
381 389
 
382
-		if( ! $input_name ) $input_name = $editor_id;
390
+		if( ! $input_name ) {
391
+			$input_name = $editor_id;
392
+		}
383 393
 
384 394
 		$buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext';
385 395
 
@@ -689,8 +699,7 @@  discard block
 block discarded – undo
689 699
 				if ( $has_questions ) {
690 700
 					$status = 'passed'; // Force a pass
691 701
 					$metadata['grade'] = 0;
692
-				}
693
-				else {
702
+				} else {
694 703
 					$status = 'complete';
695 704
 				}
696 705
 			}
@@ -738,7 +747,9 @@  discard block
 block discarded – undo
738 747
 	public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) {
739 748
 
740 749
 
741
-		if( ! $lesson_id ) return false;
750
+		if( ! $lesson_id ) {
751
+			return false;
752
+		}
742 753
 
743 754
 		if( intval( $user_id ) == 0 ) {
744 755
 			$user_id = get_current_user_id();
@@ -776,7 +787,9 @@  discard block
 block discarded – undo
776 787
 	public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) {
777 788
 
778 789
 
779
-		if( ! $course_id ) return false;
790
+		if( ! $course_id ) {
791
+			return false;
792
+		}
780 793
 
781 794
 		if( intval( $user_id ) == 0 ) {
782 795
 			$user_id = get_current_user_id();
@@ -844,8 +857,7 @@  discard block
 block discarded – undo
844 857
 		if( $question ) {
845 858
 			if ( is_object( $question ) ) {
846 859
 				$user_answer_id = $question->comment_ID;
847
-			}
848
-			else {
860
+			} else {
849 861
 				if( intval( $user_id ) == 0 ) {
850 862
 					$user_id = get_current_user_id();
851 863
 				}
@@ -872,8 +884,7 @@  discard block
 block discarded – undo
872 884
 		if( $question ) {
873 885
 			if ( is_object( $question ) ) {
874 886
 				$user_answer_id = $question->comment_ID;
875
-			}
876
-			else {
887
+			} else {
877 888
 				if( intval( $user_id ) == 0 ) {
878 889
 					$user_id = get_current_user_id();
879 890
 				}
@@ -938,8 +949,7 @@  discard block
 block discarded – undo
938 949
 			if ( !empty($notes) ) {
939 950
 				$user_lesson_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
940 951
 				$activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes );
941
-			}
942
-			else {
952
+			} else {
943 953
 				$activity_logged = true;
944 954
 			}
945 955
 		}
@@ -1451,8 +1461,7 @@  discard block
 block discarded – undo
1451 1461
 							$lessons_completed++;
1452 1462
 							break;
1453 1463
 					}
1454
-				}
1455
-				else {
1464
+				} else {
1456 1465
 					switch ( $lesson_status->comment_approved ) {
1457 1466
 						case 'complete': // Lesson has no quiz/questions
1458 1467
 						case 'graded': // Lesson has quiz, but it's not important what the grade was
@@ -1500,11 +1509,9 @@  discard block
 block discarded – undo
1500 1509
 		if( $course ) {
1501 1510
 			if ( is_object( $course ) && is_a( $course,'WP_Comment') ) {
1502 1511
 				$user_course_status = $course->comment_approved;
1503
-			}
1504
-			elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) {
1512
+			} elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) {
1505 1513
 				$user_course_status = $course;
1506
-			}
1507
-			else {
1514
+			} else {
1508 1515
 				if( ! $user_id ) {
1509 1516
 					$user_id = get_current_user_id();
1510 1517
 				}
@@ -1564,11 +1571,9 @@  discard block
 block discarded – undo
1564 1571
 			if ( is_object( $lesson ) ) {
1565 1572
 				$user_lesson_status = $lesson->comment_approved;
1566 1573
 				$lesson_id = $lesson->comment_post_ID;
1567
-			}
1568
-			elseif ( ! is_numeric( $lesson ) ) {
1574
+			} elseif ( ! is_numeric( $lesson ) ) {
1569 1575
 				$user_lesson_status = $lesson;
1570
-			}
1571
-			else {
1576
+			} else {
1572 1577
 				if( ! $user_id ) {
1573 1578
 					$user_id = get_current_user_id();
1574 1579
 				}
@@ -1581,8 +1586,7 @@  discard block
 block discarded – undo
1581 1586
 
1582 1587
 				if ( $_user_lesson_status ) {
1583 1588
 					$user_lesson_status = $_user_lesson_status->comment_approved;
1584
-				}
1585
-				else {
1589
+				} else {
1586 1590
 					return false; // No status means not complete
1587 1591
 				}
1588 1592
 				$lesson_id = $lesson;
@@ -1683,7 +1687,9 @@  discard block
 block discarded – undo
1683 1687
 
1684 1688
 	public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) {
1685 1689
 
1686
-		if( ! $quiz_id  ) return false;
1690
+		if( ! $quiz_id  ) {
1691
+			return false;
1692
+		}
1687 1693
 
1688 1694
 		if( ! $user_id ) {
1689 1695
 			$user_id = get_current_user_id();
@@ -1921,7 +1927,7 @@  discard block
 block discarded – undo
1921 1927
             $start_function = 'user_start_'.$post_type;
1922 1928
             $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1923 1929
 
1924
-        }else{
1930
+        } else{
1925 1931
 
1926 1932
             $sensei_user_activity_id = $sensei_user_status->comment_ID;
1927 1933
 
@@ -2138,7 +2144,7 @@  discard block
 block discarded – undo
2138 2144
 
2139 2145
             return round( $val, $precision, $mode );
2140 2146
 
2141
-        }else{
2147
+        } else{
2142 2148
 
2143 2149
             return round( $val, $precision );
2144 2150
 
Please login to merge, or discard this patch.
Indentation   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
 	/**
27 27
 	 * Check if WooCommerce is present.
28
-     *
29
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
28
+	 *
29
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
30 30
 	 * @access public
31 31
 	 * @since  1.0.2
32 32
 	 * @static
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public static function sensei_is_woocommerce_present () {
36 36
 
37
-        return Sensei_WC::is_woocommerce_present();
37
+		return Sensei_WC::is_woocommerce_present();
38 38
 
39 39
 	} // End sensei_is_woocommerce_present()
40 40
 
41 41
 	/**
42 42
 	 * Check if WooCommerce is active.
43
-     *
44
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
43
+	 *
44
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
45 45
 	 * @access public
46 46
 	 * @since  1.0.2
47 47
 	 * @static
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 			add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
187 187
 		}
188 188
 
189
-        //Get the comments
190
-        /**
191
-         * This filter runs inside Sensei_Utils::sensei_check_for_activity
192
-         *
193
-         * It runs while getting the comments for the given request.
194
-         *
195
-         * @param int|array $comments
196
-         */
197
-        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
189
+		//Get the comments
190
+		/**
191
+		 * This filter runs inside Sensei_Utils::sensei_check_for_activity
192
+		 *
193
+		 * It runs while getting the comments for the given request.
194
+		 *
195
+		 * @param int|array $comments
196
+		 */
197
+		$comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
198 198
 
199 199
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
200 200
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
 		return $dataset_changes;
280 280
 	} // End sensei_delete_activities()
281 281
 
282
-    /**
283
-     * Delete all activity for specified user
284
-     * @access public
282
+	/**
283
+	 * Delete all activity for specified user
284
+	 * @access public
285 285
 	 * @since  1.5.0
286
-     * @param  integer $user_id User ID
287
-     * @return boolean
288
-     */
289
-    public static function delete_all_user_activity( $user_id = 0 ) {
286
+	 * @param  integer $user_id User ID
287
+	 * @return boolean
288
+	 */
289
+	public static function delete_all_user_activity( $user_id = 0 ) {
290 290
 
291
-    	$dataset_changes = false;
291
+		$dataset_changes = false;
292 292
 
293
-    	if( $user_id ) {
293
+		if( $user_id ) {
294 294
 
295 295
 			$activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true );
296 296
 
@@ -335,35 +335,35 @@  discard block
 block discarded – undo
335 335
 		return $activity_value;
336 336
 	} // End sensei_get_activity_value()
337 337
 
338
-    /**
339
-     * Checks if a user (by email) has bought an item.
340
-     *
341
-     * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
342
-     * @access public
343
-     * @since  1.0.0
344
-     * @param  string $customer_email
345
-     * @param  int $user_id
346
-     * @param  int $product_id
347
-     * @return bool
348
-     */
349
-    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
338
+	/**
339
+	 * Checks if a user (by email) has bought an item.
340
+	 *
341
+	 * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
342
+	 * @access public
343
+	 * @since  1.0.0
344
+	 * @param  string $customer_email
345
+	 * @param  int $user_id
346
+	 * @param  int $product_id
347
+	 * @return bool
348
+	 */
349
+	public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
350 350
 
351
-        $emails = array();
351
+		$emails = array();
352 352
 
353
-        if ( $user_id ) {
354
-            $user = get_user_by( 'id', intval( $user_id ) );
355
-            $emails[] = $user->user_email;
356
-        }
353
+		if ( $user_id ) {
354
+			$user = get_user_by( 'id', intval( $user_id ) );
355
+			$emails[] = $user->user_email;
356
+		}
357 357
 
358
-        if ( is_email( $customer_email ) )
359
-            $emails[] = $customer_email;
358
+		if ( is_email( $customer_email ) )
359
+			$emails[] = $customer_email;
360 360
 
361
-        if ( sizeof( $emails ) == 0 )
362
-            return false;
361
+		if ( sizeof( $emails ) == 0 )
362
+			return false;
363 363
 
364
-        return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
364
+		return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
365 365
 
366
-    } // End sensei_customer_bought_product()
366
+	} // End sensei_customer_bought_product()
367 367
 
368 368
 	/**
369 369
 	 * Load the WordPress rich text editor
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	/**
400 400
 	 * Save quiz answers submitted by users
401 401
 	 * @param  array $submitted User's quiz answers
402
-     * @param int $user_id
402
+	 * @param int $user_id
403 403
 	 * @return boolean            Whether the answers were saved or not
404 404
 	 */
405 405
 	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) {
@@ -468,72 +468,72 @@  discard block
 block discarded – undo
468 468
 
469 469
 		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
470 470
 
471
-        /**
472
-         * Filter the data array for the Sensei wp_handle_upload function call
473
-         *
474
-         * This filter was mainly added for Unit Testing purposes.
475
-         *
476
-         * @since 1.7.4
477
-         *
478
-         * @param array  $file_upload_args {
479
-         *      array of current values
480
-         *
481
-         *     @type string test_form set to false by default
482
-         * }
483
-         */
484
-        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
485
-
486
-        $file_return = wp_handle_upload( $file, $file_upload_args );
487
-
488
-        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
489
-            return false;
490
-        } else {
471
+		/**
472
+		 * Filter the data array for the Sensei wp_handle_upload function call
473
+		 *
474
+		 * This filter was mainly added for Unit Testing purposes.
475
+		 *
476
+		 * @since 1.7.4
477
+		 *
478
+		 * @param array  $file_upload_args {
479
+		 *      array of current values
480
+		 *
481
+		 *     @type string test_form set to false by default
482
+		 * }
483
+		 */
484
+		$file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
485
+
486
+		$file_return = wp_handle_upload( $file, $file_upload_args );
487
+
488
+		if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
489
+			return false;
490
+		} else {
491 491
 
492
-            $filename = $file_return['file'];
492
+			$filename = $file_return['file'];
493 493
 
494
-            $attachment = array(
495
-                'post_mime_type' => $file_return['type'],
496
-                'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
497
-                'post_content' => '',
498
-                'post_status' => 'inherit',
499
-                'guid' => $file_return['url']
500
-            );
494
+			$attachment = array(
495
+				'post_mime_type' => $file_return['type'],
496
+				'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
497
+				'post_content' => '',
498
+				'post_status' => 'inherit',
499
+				'guid' => $file_return['url']
500
+			);
501 501
 
502
-            $attachment_id = wp_insert_attachment( $attachment, $filename );
502
+			$attachment_id = wp_insert_attachment( $attachment, $filename );
503 503
 
504
-            require_once(ABSPATH . 'wp-admin/includes/image.php');
505
-            $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
506
-            wp_update_attachment_metadata( $attachment_id, $attachment_data );
504
+			require_once(ABSPATH . 'wp-admin/includes/image.php');
505
+			$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
506
+			wp_update_attachment_metadata( $attachment_id, $attachment_data );
507 507
 
508
-            if( 0 < intval( $attachment_id ) ) {
509
-            	return $attachment_id;
510
-            }
511
-        }
508
+			if( 0 < intval( $attachment_id ) ) {
509
+				return $attachment_id;
510
+			}
511
+		}
512 512
 
513
-        return false;
513
+		return false;
514 514
 	}
515 515
 
516 516
 	/**
517 517
 	 * Grade quiz automatically
518
-     *
519
-     * This function grades each question automatically if the are auto gradable.
520
-     * It store all question grades.
521
-     *
522
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
523
-     *
518
+	 *
519
+	 * This function grades each question automatically if the are auto gradable.
520
+	 * It store all question grades.
521
+	 *
522
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
523
+	 *
524 524
 	 * @param  integer $quiz_id         ID of quiz
525 525
 	 * @param  array $submitted questions id ans answers {
526
-     *          @type int $question_id
527
-     *          @type mixed $answer
528
-     * }
526
+	 *          @type int $question_id
527
+	 *          @type mixed $answer
528
+	 * }
529 529
 	 * @param  integer $total_questions Total questions in quiz (not used)
530
-     * @param string $quiz_grade_type Optional defaults to auto
531
-     *
530
+	 * @param string $quiz_grade_type Optional defaults to auto
531
+	 *
532 532
 	 * @return int $quiz_grade total sum of all question grades
533 533
 	 */
534 534
 	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
535 535
 
536
-        return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
536
+		return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
537 537
 
538 538
 	} // End sensei_grade_quiz_auto()
539 539
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 * @param  integer $quiz_id ID of quiz
543 543
 	 * @param  integer $grade   Grade received
544 544
 	 * @param  integer $user_id ID of user being graded
545
-     * @param  string $quiz_grade_type default 'auto'
545
+	 * @param  string $quiz_grade_type default 'auto'
546 546
 	 * @return boolean
547 547
 	 */
548 548
 	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) {
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 
567 567
 	/**
568 568
 	 * Grade question automatically
569
-     *
570
-     * This function checks the question typ and then grades it accordingly.
571
-     *
572
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
573
-     *
569
+	 *
570
+	 * This function checks the question typ and then grades it accordingly.
571
+	 *
572
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
573
+	 *
574 574
 	 * @param integer $question_id
575
-     * @param string $question_type of the standard Sensei question types
575
+	 * @param string $question_type of the standard Sensei question types
576 576
 	 * @param string $answer
577
-     * @param int $user_id
578
-     *
577
+	 * @param int $user_id
578
+	 *
579 579
 	 * @return int $question_grade
580 580
 	 */
581 581
 	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
582 582
 
583
-       return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
583
+	   return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
584 584
 
585 585
 	} // end sensei_grade_question_auto
586 586
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 	 * Grade question
589 589
 	 * @param  integer $question_id ID of question
590 590
 	 * @param  integer $grade       Grade received
591
-     * @param int $user_id
591
+	 * @param int $user_id
592 592
 	 * @return boolean
593 593
 	 */
594 594
 	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) {
@@ -627,35 +627,35 @@  discard block
 block discarded – undo
627 627
 	}
628 628
 
629 629
 
630
-    /**
631
-     * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
632
-     *
633
-     * @since 1.7.4
634
-     *
635
-     * @param integer $user_id
636
-     * @param integer $lesson_id
637
-     * @param bool $complete
638
-     *
639
-     * @return mixed boolean or comment_ID
640
-     */
641
-    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
630
+	/**
631
+	 * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
632
+	 *
633
+	 * @since 1.7.4
634
+	 *
635
+	 * @param integer $user_id
636
+	 * @param integer $lesson_id
637
+	 * @param bool $complete
638
+	 *
639
+	 * @return mixed boolean or comment_ID
640
+	 */
641
+	public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
642 642
 
643
-        return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
643
+		return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
644 644
 
645
-    }// end user_start_lesson()
645
+	}// end user_start_lesson()
646 646
 
647 647
 	/**
648 648
 	 * Mark a lesson as started for user
649
-     *
650
-     * Will also start the lesson course for the user if the user hans't started taking it already.
651
-     *
652
-     * @since 1.6.0
653
-     *
649
+	 *
650
+	 * Will also start the lesson course for the user if the user hans't started taking it already.
651
+	 *
652
+	 * @since 1.6.0
653
+	 *
654 654
 	 * @param  integer $lesson_id ID of lesson
655 655
 	 * @param int| string $user_id default 0
656
-     * @param bool $complete default false
657
-     *
658
-     * @return mixed boolean or comment_ID
656
+	 * @param bool $complete default false
657
+	 *
658
+	 * @return mixed boolean or comment_ID
659 659
 	 */
660 660
 	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
661 661
 
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
 				$metadata['start'] = current_time('mysql');
702 702
 				$activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata );
703 703
 
704
-            } else {
704
+			} else {
705 705
 
706
-                // if users is already taking the lesson  and the status changes to complete update it
707
-                $current_user_activity = get_comment($activity_logged);
708
-                if( $status=='complete' &&
709
-                    $status != $current_user_activity->comment_approved  ){
706
+				// if users is already taking the lesson  and the status changes to complete update it
707
+				$current_user_activity = get_comment($activity_logged);
708
+				if( $status=='complete' &&
709
+					$status != $current_user_activity->comment_approved  ){
710 710
 
711
-                    $comment = array();
712
-                    $comment['comment_ID'] = $activity_logged;
713
-                    $comment['comment_approved'] = $status;
714
-                    wp_update_comment( $comment );
711
+					$comment = array();
712
+					$comment['comment_ID'] = $activity_logged;
713
+					$comment['comment_approved'] = $status;
714
+					wp_update_comment( $comment );
715 715
 
716
-                }
716
+				}
717 717
 
718
-            }
718
+			}
719 719
 
720 720
 			if ( $complete ) {
721 721
 				// Run this *after* the lesson status has been created/updated
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	/**
862 862
 	 * Returns the answer_notes for a specific question and user, or sensei_user_answer entry
863 863
 	 *
864
-     * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
864
+	 * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
865 865
 	 * @param mixed $question
866 866
 	 * @param int $user_id
867 867
 	 * @return string
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 * Add answer notes to question
922 922
 	 * @param  integer $question_id ID of question
923 923
 	 * @param  integer $user_id     ID of user
924
-     * @param string $notes
924
+	 * @param string $notes
925 925
 	 * @return boolean
926 926
 	 */
927 927
 	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) {
@@ -979,17 +979,17 @@  discard block
 block discarded – undo
979 979
 	 * @return void
980 980
 	 */
981 981
 	public static function sort_array_by_key( $array, $key ) {
982
-	    $sorter = array();
983
-	    $ret = array();
984
-	    reset( $array );
985
-	    foreach ( $array as $ii => $va ) {
986
-	        $sorter[$ii] = $va[$key];
987
-	    } // End For Loop
988
-	    asort( $sorter );
989
-	    foreach ( $sorter as $ii => $va ) {
990
-	        $ret[$ii] = $array[$ii];
991
-	    } // End For Loop
992
-	    $array = $ret;
982
+		$sorter = array();
983
+		$ret = array();
984
+		reset( $array );
985
+		foreach ( $array as $ii => $va ) {
986
+			$sorter[$ii] = $va[$key];
987
+		} // End For Loop
988
+		asort( $sorter );
989
+		foreach ( $sorter as $ii => $va ) {
990
+			$ret[$ii] = $array[$ii];
991
+		} // End For Loop
992
+		$array = $ret;
993 993
 	} // End sort_array_by_key()
994 994
 
995 995
 	/**
@@ -1002,21 +1002,21 @@  discard block
 block discarded – undo
1002 1002
 		$questions_array = array();
1003 1003
 		if ( 0 < $quiz_id ) {
1004 1004
 			$question_args = array( 'post_type'         => 'question',
1005
-                                    'posts_per_page'       => -1,
1006
-                                    'orderby'           => 'ID',
1007
-                                    'order'             => 'ASC',
1008
-                                    'meta_query'		=> array(
1005
+									'posts_per_page'       => -1,
1006
+									'orderby'           => 'ID',
1007
+									'order'             => 'ASC',
1008
+									'meta_query'		=> array(
1009 1009
 										array(
1010 1010
 											'key'       => '_quiz_id',
1011 1011
 											'value'     => $quiz_id,
1012 1012
 										)
1013 1013
 									),
1014
-                                    'post_status'       => 'any',
1015
-                                    'suppress_filters'  => 0
1016
-                                );
1017
-            $questions_array = get_posts( $question_args );
1018
-        } // End If Statement
1019
-        return $questions_array;
1014
+									'post_status'       => 'any',
1015
+									'suppress_filters'  => 0
1016
+								);
1017
+			$questions_array = get_posts( $question_args );
1018
+		} // End If Statement
1019
+		return $questions_array;
1020 1020
 	} // End lesson_quiz_questions()
1021 1021
 
1022 1022
 	/**
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 	 * Set the status message displayed to the user for a quiz
1175 1175
 	 * @param  integer $lesson_id ID of quiz lesson
1176 1176
 	 * @param  integer $user_id   ID of user
1177
-     * @param  bool $is_lesson
1177
+	 * @param  bool $is_lesson
1178 1178
 	 * @return array              Status code and message
1179 1179
 	 */
1180 1180
 	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) {
@@ -1257,20 +1257,20 @@  discard block
 block discarded – undo
1257 1257
 					}
1258 1258
 				}
1259 1259
 
1260
-                // add next lesson button
1261
-                $nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1262
-                $next_lesson_id = absint( $nav_id_array['next_lesson'] );
1260
+				// add next lesson button
1261
+				$nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1262
+				$next_lesson_id = absint( $nav_id_array['next_lesson'] );
1263 1263
 
1264
-                // Output HTML
1265
-                if ( ( 0 < $next_lesson_id ) ) {
1266
-                    $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1267
-                                . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1268
-                                .'</a>';
1264
+				// Output HTML
1265
+				if ( ( 0 < $next_lesson_id ) ) {
1266
+					$message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1267
+								. '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1268
+								.'</a>';
1269 1269
 
1270
-                }
1270
+				}
1271 1271
 
1272 1272
 			}
1273
-            // Lesson/Quiz not complete
1273
+			// Lesson/Quiz not complete
1274 1274
 			else {
1275 1275
 				// Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
1276 1276
 				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) {
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		$message = apply_filters( 'sensei_user_quiz_status_' . $status, $message );
1311 1311
 
1312 1312
 		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) {
1313
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1313
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1314 1314
 			$extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' .  __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' .  __( 'View the lesson quiz', 'woothemes-sensei' )  . '</a></p>';
1315 1315
 		}
1316 1316
 
@@ -1368,9 +1368,9 @@  discard block
 block discarded – undo
1368 1368
 				$user_id = get_current_user_id();
1369 1369
 			}
1370 1370
 
1371
-            if( ! $user_id > 0 ){
1372
-                return false;
1373
-            }
1371
+			if( ! $user_id > 0 ){
1372
+				return false;
1373
+			}
1374 1374
 
1375 1375
 			$user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) );
1376 1376
 			if( $user_course_status_id ) {
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 	 * Check if a user has completed a course or not
1495 1495
 	 *
1496 1496
 	 * @param int | WP_Post | WP_Comment $course course_id or sensei_course_status entry
1497
-     *
1497
+	 *
1498 1498
 	 * @param int $user_id
1499 1499
 	 * @return boolean
1500 1500
 	 */
@@ -1512,14 +1512,14 @@  discard block
 block discarded – undo
1512 1512
 					$user_id = get_current_user_id();
1513 1513
 				}
1514 1514
 
1515
-                if( is_a( $course, 'WP_Post' ) ){
1516
-                    $course =   $course->ID;
1517
-                }
1515
+				if( is_a( $course, 'WP_Post' ) ){
1516
+					$course =   $course->ID;
1517
+				}
1518 1518
 
1519 1519
 				$user_course_status = Sensei_Utils::user_course_status( $course , $user_id );
1520 1520
 				if( isset( $user_course_status->comment_approved ) ){
1521
-                    $user_course_status = $user_course_status->comment_approved;
1522
-                }
1521
+					$user_course_status = $user_course_status->comment_approved;
1522
+				}
1523 1523
 
1524 1524
 			}
1525 1525
 			if( $user_course_status && 'complete' == $user_course_status ) {
@@ -1544,11 +1544,11 @@  discard block
 block discarded – undo
1544 1544
 				$user_id = get_current_user_id();
1545 1545
 			}
1546 1546
 
1547
-            $activity_args = array(
1548
-                'post_id' => $lesson_id,
1549
-                'user_id' => $user_id,
1550
-                'type' => 'sensei_lesson_status',
1551
-                'field' => 'comment_ID' );
1547
+			$activity_args = array(
1548
+				'post_id' => $lesson_id,
1549
+				'user_id' => $user_id,
1550
+				'type' => 'sensei_lesson_status',
1551
+				'field' => 'comment_ID' );
1552 1552
 
1553 1553
 			$user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args );
1554 1554
 			if( $user_lesson_status_id ) {
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 	/**
1562 1562
 	 * Check if a user has completed a lesson or not
1563 1563
 	 *
1564
-     * @uses  Sensei()
1564
+	 * @uses  Sensei()
1565 1565
 	 * @param mixed $lesson lesson_id or sensei_lesson_status entry
1566 1566
 	 * @param int $user_id
1567 1567
 	 * @return boolean
@@ -1582,10 +1582,10 @@  discard block
 block discarded – undo
1582 1582
 					$user_id = get_current_user_id();
1583 1583
 				}
1584 1584
 
1585
-                // the user is not logged in
1586
-                if( ! $user_id > 0 ){
1587
-                    return false;
1588
-                }
1585
+				// the user is not logged in
1586
+				if( ! $user_id > 0 ){
1587
+					return false;
1588
+				}
1589 1589
 				$_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id );
1590 1590
 
1591 1591
 				if ( $_user_lesson_status ) {
@@ -1664,9 +1664,9 @@  discard block
 block discarded – undo
1664 1664
 	 */
1665 1665
 	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1666 1666
 
1667
-        if( ! $user_id ) {
1668
-            $user_id = get_current_user_id();
1669
-        }
1667
+		if( ! $user_id ) {
1668
+			$user_id = get_current_user_id();
1669
+		}
1670 1670
 
1671 1671
 		if( $lesson_id > 0 && $user_id > 0 ) {
1672 1672
 
@@ -1717,12 +1717,12 @@  discard block
 block discarded – undo
1717 1717
 	 * Sets the status for the lesson
1718 1718
 	 *
1719 1719
 	 * @since  1.7.0
1720
-     *
1720
+	 *
1721 1721
 	 * @param int|string $user_id
1722 1722
 	 * @param int|string $lesson_id
1723 1723
 	 * @param string $status
1724 1724
 	 * @param array $metadata
1725
-     *
1725
+	 *
1726 1726
 	 * @return mixed false or comment_ID
1727 1727
 	 */
1728 1728
 	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 	/**
1839 1839
 	 * Adjust the comment query to be faster on the database, used by Analysis admin
1840 1840
 	 * @since  1.7.0
1841
-     * @param array $pieces
1841
+	 * @param array $pieces
1842 1842
 	 * @return array $pieces
1843 1843
 	 */
1844 1844
 	public static function comment_total_sum_meta_value_filter( $pieces ) {
@@ -1873,360 +1873,360 @@  discard block
 block discarded – undo
1873 1873
 		return $pieces;
1874 1874
 	}
1875 1875
 
1876
-    /**
1877
-     *
1878
-     * Alias to Woothemes_Sensei_Utils::update_user_data
1879
-     * @since 1.7.4
1880
-     *
1881
-     * @param string $data_key maximum 39 characters allowed
1882
-     * @param int $post_id
1883
-     * @param mixed $value
1884
-     * @param int $user_id
1885
-     *
1886
-     * @return bool $success
1887
-     */
1888
-    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1889
-
1890
-        return self::update_user_data( $data_key, $post_id, $value , $user_id );
1891
-
1892
-    }// end add_user_data
1893
-
1894
-    /**
1895
-     * add user specific data to the passed in sensei post type id
1896
-     *
1897
-     * This function saves comment meta on the users current status. If no status is available
1898
-     * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1899
-     *
1900
-     * @since 1.7.4
1901
-     *
1902
-     * @param string $data_key maximum 39 characters allowed
1903
-     * @param int $post_id
1904
-     * @param mixed $value
1905
-     * @param int $user_id
1906
-     *
1907
-     * @return bool $success
1908
-     */
1909
-    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1910
-
1911
-        if( ! ( $user_id > 0 ) ){
1912
-            $user_id = get_current_user_id();
1913
-        }
1914
-
1915
-        $supported_post_types = array( 'course', 'lesson' );
1916
-        $post_type = get_post_type( $post_id );
1917
-        if( empty( $post_id ) || empty( $data_key )
1918
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1919
-            || !get_userdata( $user_id )
1920
-            || ! in_array( $post_type, $supported_post_types )  ){
1921
-
1922
-            return false;
1923
-        }
1924
-
1925
-        // check if there and existing Sensei status on this post type if not create it
1926
-        // and get the  activity ID
1927
-        $status_function = 'user_'.$post_type.'_status';
1928
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1929
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1930
-
1931
-            $start_function = 'user_start_'.$post_type;
1932
-            $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1933
-
1934
-        }else{
1935
-
1936
-            $sensei_user_activity_id = $sensei_user_status->comment_ID;
1937
-
1938
-        }
1939
-
1940
-        // store the data
1941
-        $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1942
-
1943
-       return $success;
1944
-
1945
-    }//update_user_data
1946
-
1947
-    /**
1948
-     * Get the user data stored on the passed in post type
1949
-     *
1950
-     * This function gets the comment meta on the lesson or course status
1951
-     *
1952
-     * @since 1.7.4
1953
-     *
1954
-     * @param $data_key
1955
-     * @param $post_id
1956
-     * @param int $user_id
1957
-     *
1958
-     * @return mixed $user_data_value
1959
-     */
1960
-    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1961
-
1962
-        $user_data_value = true;
1963
-
1964
-        if( ! ( $user_id > 0 ) ){
1965
-            $user_id = get_current_user_id();
1966
-        }
1967
-
1968
-        $supported_post_types = array( 'course', 'lesson' );
1969
-        $post_type = get_post_type( $post_id );
1970
-        if( empty( $post_id ) || empty( $data_key )
1971
-            || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1972
-            || ! get_userdata( $user_id )
1973
-            || !in_array( $post_type, $supported_post_types )  ){
1974
-
1975
-            return false;
1976
-        }
1977
-
1978
-        // check if there and existing Sensei status on this post type if not create it
1979
-        // and get the  activity ID
1980
-        $status_function = 'user_'.$post_type.'_status';
1981
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1982
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1983
-            return false;
1984
-        }
1985
-
1986
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
1987
-        $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1988
-
1989
-        return $user_data_value;
1990
-
1991
-    }// end get_user_data
1992
-
1993
-    /**
1994
-     * Delete the Sensei user data for the given key, Sensei post type and user combination.
1995
-     *
1996
-     * @param int $data_key
1997
-     * @param int $post_id
1998
-     * @param int $user_id
1999
-     *
2000
-     * @return bool $deleted
2001
-     */
2002
-    public static function delete_user_data( $data_key, $post_id , $user_id ){
2003
-        $deleted = true;
1876
+	/**
1877
+	 *
1878
+	 * Alias to Woothemes_Sensei_Utils::update_user_data
1879
+	 * @since 1.7.4
1880
+	 *
1881
+	 * @param string $data_key maximum 39 characters allowed
1882
+	 * @param int $post_id
1883
+	 * @param mixed $value
1884
+	 * @param int $user_id
1885
+	 *
1886
+	 * @return bool $success
1887
+	 */
1888
+	public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1889
+
1890
+		return self::update_user_data( $data_key, $post_id, $value , $user_id );
1891
+
1892
+	}// end add_user_data
1893
+
1894
+	/**
1895
+	 * add user specific data to the passed in sensei post type id
1896
+	 *
1897
+	 * This function saves comment meta on the users current status. If no status is available
1898
+	 * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1899
+	 *
1900
+	 * @since 1.7.4
1901
+	 *
1902
+	 * @param string $data_key maximum 39 characters allowed
1903
+	 * @param int $post_id
1904
+	 * @param mixed $value
1905
+	 * @param int $user_id
1906
+	 *
1907
+	 * @return bool $success
1908
+	 */
1909
+	public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1910
+
1911
+		if( ! ( $user_id > 0 ) ){
1912
+			$user_id = get_current_user_id();
1913
+		}
1914
+
1915
+		$supported_post_types = array( 'course', 'lesson' );
1916
+		$post_type = get_post_type( $post_id );
1917
+		if( empty( $post_id ) || empty( $data_key )
1918
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1919
+			|| !get_userdata( $user_id )
1920
+			|| ! in_array( $post_type, $supported_post_types )  ){
1921
+
1922
+			return false;
1923
+		}
1924
+
1925
+		// check if there and existing Sensei status on this post type if not create it
1926
+		// and get the  activity ID
1927
+		$status_function = 'user_'.$post_type.'_status';
1928
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
1929
+		if( ! isset( $sensei_user_status->comment_ID ) ){
1930
+
1931
+			$start_function = 'user_start_'.$post_type;
1932
+			$sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1933
+
1934
+		}else{
1935
+
1936
+			$sensei_user_activity_id = $sensei_user_status->comment_ID;
1937
+
1938
+		}
1939
+
1940
+		// store the data
1941
+		$success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1942
+
1943
+	   return $success;
1944
+
1945
+	}//update_user_data
1946
+
1947
+	/**
1948
+	 * Get the user data stored on the passed in post type
1949
+	 *
1950
+	 * This function gets the comment meta on the lesson or course status
1951
+	 *
1952
+	 * @since 1.7.4
1953
+	 *
1954
+	 * @param $data_key
1955
+	 * @param $post_id
1956
+	 * @param int $user_id
1957
+	 *
1958
+	 * @return mixed $user_data_value
1959
+	 */
1960
+	public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1961
+
1962
+		$user_data_value = true;
1963
+
1964
+		if( ! ( $user_id > 0 ) ){
1965
+			$user_id = get_current_user_id();
1966
+		}
1967
+
1968
+		$supported_post_types = array( 'course', 'lesson' );
1969
+		$post_type = get_post_type( $post_id );
1970
+		if( empty( $post_id ) || empty( $data_key )
1971
+			|| ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1972
+			|| ! get_userdata( $user_id )
1973
+			|| !in_array( $post_type, $supported_post_types )  ){
2004 1974
 
2005
-        if( ! ( $user_id > 0 ) ){
2006
-            $user_id = get_current_user_id();
2007
-        }
1975
+			return false;
1976
+		}
2008 1977
 
2009
-        $supported_post_types = array( 'course', 'lesson' );
2010
-        $post_type = get_post_type( $post_id );
2011
-        if( empty( $post_id ) || empty( $data_key )
2012
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2013
-            || ! get_userdata( $user_id )
2014
-            || !in_array( $post_type, $supported_post_types )  ){
1978
+		// check if there and existing Sensei status on this post type if not create it
1979
+		// and get the  activity ID
1980
+		$status_function = 'user_'.$post_type.'_status';
1981
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
1982
+		if( ! isset( $sensei_user_status->comment_ID ) ){
1983
+			return false;
1984
+		}
2015 1985
 
2016
-            return false;
2017
-        }
1986
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
1987
+		$user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1988
+
1989
+		return $user_data_value;
1990
+
1991
+	}// end get_user_data
1992
+
1993
+	/**
1994
+	 * Delete the Sensei user data for the given key, Sensei post type and user combination.
1995
+	 *
1996
+	 * @param int $data_key
1997
+	 * @param int $post_id
1998
+	 * @param int $user_id
1999
+	 *
2000
+	 * @return bool $deleted
2001
+	 */
2002
+	public static function delete_user_data( $data_key, $post_id , $user_id ){
2003
+		$deleted = true;
2004
+
2005
+		if( ! ( $user_id > 0 ) ){
2006
+			$user_id = get_current_user_id();
2007
+		}
2008
+
2009
+		$supported_post_types = array( 'course', 'lesson' );
2010
+		$post_type = get_post_type( $post_id );
2011
+		if( empty( $post_id ) || empty( $data_key )
2012
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2013
+			|| ! get_userdata( $user_id )
2014
+			|| !in_array( $post_type, $supported_post_types )  ){
2015
+
2016
+			return false;
2017
+		}
2018 2018
 
2019
-        // check if there and existing Sensei status on this post type if not create it
2020
-        // and get the  activity ID
2021
-        $status_function = 'user_'.$post_type.'_status';
2022
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2023
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2024
-            return false;
2025
-        }
2019
+		// check if there and existing Sensei status on this post type if not create it
2020
+		// and get the  activity ID
2021
+		$status_function = 'user_'.$post_type.'_status';
2022
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
2023
+		if( ! isset( $sensei_user_status->comment_ID ) ){
2024
+			return false;
2025
+		}
2026 2026
 
2027
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
2028
-        $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2027
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
2028
+		$deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2029 2029
 
2030
-        return $deleted;
2030
+		return $deleted;
2031 2031
 
2032
-    }// end delete_user_data
2032
+	}// end delete_user_data
2033 2033
 
2034 2034
 
2035
-    /**
2036
-     * The function creates a drop down. Never write up a Sensei select statement again.
2037
-     *
2038
-     * @since 1.8.0
2039
-     *
2040
-     * @param string $selected_value
2041
-     * @param $options{
2042
-     *    @type string $value the value saved in the database
2043
-     *    @type string $option what the user will see in the list of items
2044
-     * }
2045
-     * @param array $attributes{
2046
-     *   @type string $attribute  type such name or id etc.
2047
-     *  @type string $value
2048
-     * }
2049
-     * @param bool $enable_none_option
2050
-     *
2051
-     * @return string $drop_down_element
2052
-     */
2053
-    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2035
+	/**
2036
+	 * The function creates a drop down. Never write up a Sensei select statement again.
2037
+	 *
2038
+	 * @since 1.8.0
2039
+	 *
2040
+	 * @param string $selected_value
2041
+	 * @param $options{
2042
+	 *    @type string $value the value saved in the database
2043
+	 *    @type string $option what the user will see in the list of items
2044
+	 * }
2045
+	 * @param array $attributes{
2046
+	 *   @type string $attribute  type such name or id etc.
2047
+	 *  @type string $value
2048
+	 * }
2049
+	 * @param bool $enable_none_option
2050
+	 *
2051
+	 * @return string $drop_down_element
2052
+	 */
2053
+	public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2054 2054
 
2055
-        $drop_down_element = '';
2055
+		$drop_down_element = '';
2056 2056
 
2057
-        // setup the basic attributes
2058
-        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2057
+		// setup the basic attributes
2058
+		if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2059 2059
 
2060
-            $attributes['name'] = 'sensei-options';
2060
+			$attributes['name'] = 'sensei-options';
2061 2061
 
2062
-        }
2062
+		}
2063 2063
 
2064
-        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2064
+		if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2065 2065
 
2066
-            $attributes['id'] = 'sensei-options';
2066
+			$attributes['id'] = 'sensei-options';
2067 2067
 
2068
-        }
2068
+		}
2069 2069
 
2070
-        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2070
+		if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2071 2071
 
2072
-            $attributes['class'] ='chosen_select widefat';
2072
+			$attributes['class'] ='chosen_select widefat';
2073 2073
 
2074
-        }
2074
+		}
2075 2075
 
2076
-        // create element attributes
2077
-        $combined_attributes = '';
2078
-        foreach( $attributes as $attribute => $value ){
2076
+		// create element attributes
2077
+		$combined_attributes = '';
2078
+		foreach( $attributes as $attribute => $value ){
2079 2079
 
2080
-            $combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2080
+			$combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2081 2081
 
2082
-        }// end for each
2082
+		}// end for each
2083 2083
 
2084 2084
 
2085
-        // create the select element
2086
-        $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2085
+		// create the select element
2086
+		$drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2087 2087
 
2088
-        // show the none option if the client requested
2089
-        if( $enable_none_option ) {
2090
-            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2091
-        }
2088
+		// show the none option if the client requested
2089
+		if( $enable_none_option ) {
2090
+			$drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2091
+		}
2092 2092
 
2093
-        if ( count( $options ) > 0 ) {
2093
+		if ( count( $options ) > 0 ) {
2094 2094
 
2095
-            foreach ($options as $value => $option ){
2095
+			foreach ($options as $value => $option ){
2096 2096
 
2097
-                $element = '';
2098
-                $element.= '<option value="' . esc_attr( $value ) . '"';
2099
-                $element .= selected( $value, $selected_value, false ) . '>';
2100
-                $element .= esc_html(  $option ) . '</option>' . "\n";
2097
+				$element = '';
2098
+				$element.= '<option value="' . esc_attr( $value ) . '"';
2099
+				$element .= selected( $value, $selected_value, false ) . '>';
2100
+				$element .= esc_html(  $option ) . '</option>' . "\n";
2101 2101
 
2102
-                // add the element to the select html
2103
-                $drop_down_element.= $element;
2104
-            } // End For Loop
2102
+				// add the element to the select html
2103
+				$drop_down_element.= $element;
2104
+			} // End For Loop
2105 2105
 
2106
-        } // End If Statement
2106
+		} // End If Statement
2107 2107
 
2108
-        $drop_down_element .= '</select>' . "\n";
2108
+		$drop_down_element .= '</select>' . "\n";
2109 2109
 
2110
-        return $drop_down_element;
2110
+		return $drop_down_element;
2111 2111
 
2112
-    }// generate_drop_down
2112
+	}// generate_drop_down
2113 2113
 
2114
-    /**
2115
-     * Wrapper for the default php round() function.
2116
-     * This allows us to give more control to a user on how they can round Sensei
2117
-     * decimals passed through this function.
2118
-     *
2119
-     * @since 1.8.5
2120
-     *
2121
-     * @param double $val
2122
-     * @param int $precision
2123
-     * @param $mode
2124
-     * @param string $context
2125
-     *
2126
-     * @return double $val
2127
-     */
2128
-    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2114
+	/**
2115
+	 * Wrapper for the default php round() function.
2116
+	 * This allows us to give more control to a user on how they can round Sensei
2117
+	 * decimals passed through this function.
2118
+	 *
2119
+	 * @since 1.8.5
2120
+	 *
2121
+	 * @param double $val
2122
+	 * @param int $precision
2123
+	 * @param $mode
2124
+	 * @param string $context
2125
+	 *
2126
+	 * @return double $val
2127
+	 */
2128
+	public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2129 2129
 
2130
-        /**å
2130
+		/**å
2131 2131
          * Change the precision for the Sensei_Utils::round function.
2132 2132
          * the precision given will be passed into the php round function
2133 2133
          * @since 1.8.5
2134 2134
          */
2135
-        $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2136
-
2137
-        /**
2138
-         * Change the mode for the Sensei_Utils::round function.
2139
-         * the mode given will be passed into the php round function
2140
-         *
2141
-         * This applies only to PHP version 5.3.0 and greater
2142
-         *
2143
-         * @since 1.8.5
2144
-         */
2145
-        $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2135
+		$precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2136
+
2137
+		/**
2138
+		 * Change the mode for the Sensei_Utils::round function.
2139
+		 * the mode given will be passed into the php round function
2140
+		 *
2141
+		 * This applies only to PHP version 5.3.0 and greater
2142
+		 *
2143
+		 * @since 1.8.5
2144
+		 */
2145
+		$mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2146 2146
 
2147
-        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2147
+		if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2148 2148
 
2149
-            return round( $val, $precision, $mode );
2149
+			return round( $val, $precision, $mode );
2150 2150
 
2151
-        }else{
2151
+		}else{
2152 2152
 
2153
-            return round( $val, $precision );
2153
+			return round( $val, $precision );
2154 2154
 
2155
-        }
2155
+		}
2156 2156
 
2157
-    }
2157
+	}
2158 2158
 
2159
-    /**
2160
-     * Returns the current url with all the query vars
2161
-     *
2162
-     * @since 1.9.0
2163
-     * @return string $url
2164
-     */
2165
-    public static function get_current_url(){
2159
+	/**
2160
+	 * Returns the current url with all the query vars
2161
+	 *
2162
+	 * @since 1.9.0
2163
+	 * @return string $url
2164
+	 */
2165
+	public static function get_current_url(){
2166 2166
 
2167
-        global $wp;
2168
-        $current_url = trailingslashit( home_url( $wp->request ) );
2169
-        if ( isset( $_GET ) ) {
2167
+		global $wp;
2168
+		$current_url = trailingslashit( home_url( $wp->request ) );
2169
+		if ( isset( $_GET ) ) {
2170 2170
 
2171
-            foreach ($_GET as $param => $val ) {
2171
+			foreach ($_GET as $param => $val ) {
2172 2172
 
2173
-                $current_url = add_query_arg( $param, $val , $current_url );
2173
+				$current_url = add_query_arg( $param, $val , $current_url );
2174 2174
 
2175
-            }
2176
-        }
2175
+			}
2176
+		}
2177 2177
 
2178
-        return $current_url;
2179
-    }
2178
+		return $current_url;
2179
+	}
2180 2180
 
2181
-    /**
2182
-     * Restore the global WP_Query
2183
-     *
2184
-     * @since 1.9.0
2185
-     */
2186
-    public static function restore_wp_query() {
2181
+	/**
2182
+	 * Restore the global WP_Query
2183
+	 *
2184
+	 * @since 1.9.0
2185
+	 */
2186
+	public static function restore_wp_query() {
2187 2187
 
2188
-        wp_reset_query();
2188
+		wp_reset_query();
2189 2189
 
2190
-    }
2190
+	}
2191 2191
 
2192
-    /**
2193
-     * Merge two arrays in a zip like fashion.
2194
-     * If one array is longer than the other the elements will be apended
2195
-     * to the end of the resulting array.
2196
-     *
2197
-     * @since 1.9.0
2198
-     *
2199
-     * @param array $array_a
2200
-     * @param array $array_b
2201
-     * @return array $merged_array
2202
-     */
2203
-    public static function array_zip_merge( $array_a, $array_b ){
2192
+	/**
2193
+	 * Merge two arrays in a zip like fashion.
2194
+	 * If one array is longer than the other the elements will be apended
2195
+	 * to the end of the resulting array.
2196
+	 *
2197
+	 * @since 1.9.0
2198
+	 *
2199
+	 * @param array $array_a
2200
+	 * @param array $array_b
2201
+	 * @return array $merged_array
2202
+	 */
2203
+	public static function array_zip_merge( $array_a, $array_b ){
2204 2204
 
2205
-        if( ! is_array( $array_a ) || ! is_array( $array_b )  ){
2206
-            trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2207
-        }
2205
+		if( ! is_array( $array_a ) || ! is_array( $array_b )  ){
2206
+			trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2207
+		}
2208 2208
 
2209
-        $merged_array = array();
2210
-        $total_elements = count( $array_a )  + count( $array_b );
2209
+		$merged_array = array();
2210
+		$total_elements = count( $array_a )  + count( $array_b );
2211 2211
 
2212
-        // Zip arrays
2213
-        for ( $i = 0; $i < $total_elements; $i++) {
2212
+		// Zip arrays
2213
+		for ( $i = 0; $i < $total_elements; $i++) {
2214 2214
 
2215
-            // if has an element at current index push a on top
2216
-            if( isset( $array_a[ $i ] ) ){
2217
-                $merged_array[] = $array_a[ $i ]  ;
2218
-            }
2215
+			// if has an element at current index push a on top
2216
+			if( isset( $array_a[ $i ] ) ){
2217
+				$merged_array[] = $array_a[ $i ]  ;
2218
+			}
2219 2219
 
2220
-            // next if $array_b has an element at current index push a on top of the element
2221
-            // from a if there was one, if not the element before that.
2222
-            if( isset( $array_b[ $i ] ) ){
2223
-                $merged_array[] = $array_b[ $i ]  ;
2224
-            }
2220
+			// next if $array_b has an element at current index push a on top of the element
2221
+			// from a if there was one, if not the element before that.
2222
+			if( isset( $array_b[ $i ] ) ){
2223
+				$merged_array[] = $array_b[ $i ]  ;
2224
+			}
2225 2225
 
2226
-        }
2226
+		}
2227 2227
 
2228
-        return $merged_array;
2229
-    }
2228
+		return $merged_array;
2229
+	}
2230 2230
 
2231 2231
 } // End Class
2232 2232
 
Please login to merge, or discard this patch.
Spacing   +531 added lines, -531 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Utilities Class
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 	 * @since   1.0.0
19 19
 	 * @return  string The URL to the placeholder thumbnail image.
20 20
 	 */
21
-	public static function get_placeholder_image () {
21
+	public static function get_placeholder_image() {
22 22
 
23
-		return esc_url( apply_filters( 'sensei_placeholder_thumbnail', Sensei()->plugin_url . 'assets/images/placeholder.png' ) );
23
+		return esc_url(apply_filters('sensei_placeholder_thumbnail', Sensei()->plugin_url.'assets/images/placeholder.png'));
24 24
 	} // End get_placeholder_image()
25 25
 
26 26
 	/**
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @static
33 33
 	 * @return bool
34 34
 	 */
35
-	public static function sensei_is_woocommerce_present () {
35
+	public static function sensei_is_woocommerce_present() {
36 36
 
37 37
         return Sensei_WC::is_woocommerce_present();
38 38
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @static
48 48
 	 * @return boolean
49 49
 	 */
50
-	public static function sensei_is_woocommerce_activated () {
50
+	public static function sensei_is_woocommerce_activated() {
51 51
 
52 52
 		return  Sensei_WC::is_woocommerce_active();
53 53
 
@@ -60,70 +60,70 @@  discard block
 block discarded – undo
60 60
 	 * @param  array $args (default: array())
61 61
 	 * @return bool | int
62 62
 	 */
63
-	public static function sensei_log_activity ( $args = array() ) {
63
+	public static function sensei_log_activity($args = array()) {
64 64
 		global $wpdb;
65 65
 
66 66
 		// Args, minimum data required for WP
67 67
 		$data = array(
68
-					'comment_post_ID' => intval( $args['post_id'] ),
68
+					'comment_post_ID' => intval($args['post_id']),
69 69
 					'comment_author' => '', // Not needed
70 70
 					'comment_author_email' => '', // Not needed
71 71
 					'comment_author_url' => '', // Not needed
72
-					'comment_content' => !empty($args['data']) ? esc_html( $args['data'] ) : '',
73
-					'comment_type' => esc_attr( $args['type'] ),
74
-					'user_id' => intval( $args['user_id'] ),
75
-					'comment_approved' => !empty($args['status']) ? esc_html( $args['status'] ) : 'log', // 'log' == 'sensei_user_answer'
72
+					'comment_content' => ! empty($args['data']) ? esc_html($args['data']) : '',
73
+					'comment_type' => esc_attr($args['type']),
74
+					'user_id' => intval($args['user_id']),
75
+					'comment_approved' => ! empty($args['status']) ? esc_html($args['status']) : 'log', // 'log' == 'sensei_user_answer'
76 76
 				);
77 77
 		// Allow extra data
78
-		if ( !empty($args['username']) ) {
79
-			$data['comment_author'] = sanitize_user( $args['username'] );
78
+		if ( ! empty($args['username'])) {
79
+			$data['comment_author'] = sanitize_user($args['username']);
80 80
 		}
81
-		if ( !empty($args['user_email']) ) {
82
-			$data['comment_author_email'] = sanitize_email( $args['user_email'] );
81
+		if ( ! empty($args['user_email'])) {
82
+			$data['comment_author_email'] = sanitize_email($args['user_email']);
83 83
 		}
84
-		if ( !empty($args['user_url']) ) {
85
-			$data['comment_author_url'] = esc_url( $args['user_url'] );
84
+		if ( ! empty($args['user_url'])) {
85
+			$data['comment_author_url'] = esc_url($args['user_url']);
86 86
 		}
87
-		if ( !empty($args['parent']) ) {
87
+		if ( ! empty($args['parent'])) {
88 88
 			$data['comment_parent'] = $args['parent'];
89 89
 		}
90 90
 		// Sanity check
91
-		if ( empty($args['user_id']) ) {
92
-			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') );
91
+		if (empty($args['user_id'])) {
92
+			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei'));
93 93
 			return false;
94 94
 		}
95 95
 
96
-		do_action( 'sensei_log_activity_before', $args, $data );
96
+		do_action('sensei_log_activity_before', $args, $data);
97 97
 
98 98
 		$flush_cache = false;
99 99
 
100 100
 		// Custom Logic
101 101
 		// Check if comment exists first
102
-		$comment_id = $wpdb->get_var( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'] ) );
103
-		if ( ! $comment_id ) {
102
+		$comment_id = $wpdb->get_var($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type']));
103
+		if ( ! $comment_id) {
104 104
 			// Add the comment
105
-			$comment_id = wp_insert_comment( $data );
105
+			$comment_id = wp_insert_comment($data);
106 106
 
107 107
 			$flush_cache = true;
108
-		} elseif ( isset( $args['action'] ) && 'update' == $args['action'] ) {
108
+		} elseif (isset($args['action']) && 'update' == $args['action']) {
109 109
 			// Update the comment if an update was requested
110 110
 			$data['comment_ID'] = $comment_id;
111 111
 			// By default update the timestamp of the comment
112
-			if ( empty($args['keep_time']) ) {
112
+			if (empty($args['keep_time'])) {
113 113
 				$data['comment_date'] = current_time('mysql');
114 114
 			}
115
-			wp_update_comment( $data );
115
+			wp_update_comment($data);
116 116
 			$flush_cache = true;
117 117
 		} // End If Statement
118 118
 
119 119
 		// Manually Flush the Cache
120
-		if ( $flush_cache ) {
120
+		if ($flush_cache) {
121 121
 			wp_cache_flush();
122 122
 		}
123 123
 
124
-		do_action( 'sensei_log_activity_after', $args, $data,  $comment_id );
124
+		do_action('sensei_log_activity_after', $args, $data, $comment_id);
125 125
 
126
-		if ( 0 < $comment_id ) {
126
+		if (0 < $comment_id) {
127 127
 			// Return the ID so that it can be used for meta data storage
128 128
 			return $comment_id;
129 129
 		} else {
@@ -140,41 +140,41 @@  discard block
 block discarded – undo
140 140
 	 * @param  bool $return_comments (default: false)
141 141
 	 * @return mixed | int
142 142
 	 */
143
-	public static function sensei_check_for_activity ( $args = array(), $return_comments = false ) {
143
+	public static function sensei_check_for_activity($args = array(), $return_comments = false) {
144 144
 
145 145
 		global  $wp_version;
146
-		if ( !$return_comments ) {
146
+		if ( ! $return_comments) {
147 147
 			$args['count'] = true;
148 148
 		}
149 149
 
150 150
 		// Are we only retrieving a single entry, or not care about the order...
151
-		if ( isset( $args['count'] ) || isset( $args['post_id'] ) ){
151
+		if (isset($args['count']) || isset($args['post_id'])) {
152 152
 
153 153
 			// ...then we don't need to ask the db to order the results, this overrides WP default behaviour
154
-			if ( version_compare( $wp_version, '4.1', '>=' ) ) {
154
+			if (version_compare($wp_version, '4.1', '>=')) {
155 155
 				$args['order'] = false;
156 156
 				$args['orderby'] = false;
157 157
 			}
158 158
 		}
159 159
 
160 160
 		// A user ID of 0 is in valid, so shortcut this
161
-		if ( isset( $args['user_id'] ) && 0 == intval ( $args['user_id'] ) ) {
162
-			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') );
161
+		if (isset($args['user_id']) && 0 == intval($args['user_id'])) {
162
+			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei'));
163 163
 			return false;
164 164
 		}
165 165
 		// Check for legacy code
166
-		if ( isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes') ) ) {
167
-			_deprecated_argument( __FUNCTION__, '1.7', sprintf( __('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'] ) );
166
+		if (isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes'))) {
167
+			_deprecated_argument(__FUNCTION__, '1.7', sprintf(__('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type']));
168 168
 			return false;
169 169
 		}
170 170
 		// Are we checking for specific comment_approved statuses?
171
-		if ( isset($args['status']) ) {
171
+		if (isset($args['status'])) {
172 172
 			// Temporarily store as a custom status if requesting an array...
173
-			if ( is_array( $args['status'] ) && version_compare($wp_version, '4.1', '<') ) {
173
+			if (is_array($args['status']) && version_compare($wp_version, '4.1', '<')) {
174 174
 				// Encode now, decode later
175
-				$args['status'] = implode( ",", $args['status'] );
175
+				$args['status'] = implode(",", $args['status']);
176 176
 				// ...use a filter to switch the encoding back
177
-				add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
177
+				add_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter'));
178 178
 			}
179 179
 		}
180 180
 		else {
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 
184 184
 		// Take into account WP < 4.1 will automatically add ' comment_approved = 1 OR comment_approved = 0 '
185
-		if ( ( is_array( $args['status'] ) || 'any' == $args['status'] ) && version_compare($wp_version, '4.1', '<') ) {
186
-			add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
185
+		if ((is_array($args['status']) || 'any' == $args['status']) && version_compare($wp_version, '4.1', '<')) {
186
+			add_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter'));
187 187
 		}
188 188
 
189 189
         //Get the comments
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
          *
195 195
          * @param int|array $comments
196 196
          */
197
-        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
197
+        $comments = apply_filters('sensei_check_for_activity', get_comments($args));
198 198
 
199
-		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
200
-		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
199
+		remove_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter'));
200
+		remove_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter'));
201 201
 		// Return comments
202
-		if ( $return_comments ) {
202
+		if ($return_comments) {
203 203
 			// Could check for array of 1 and just return the 1 item?
204
-			if ( is_array($comments) && 1 == count($comments) ) {
204
+			if (is_array($comments) && 1 == count($comments)) {
205 205
 				$comments = array_shift($comments);
206 206
 			}
207 207
 
@@ -219,31 +219,31 @@  discard block
 block discarded – undo
219 219
 	 * @param  array $args (default: array())
220 220
 	 * @return array
221 221
 	 */
222
-	public static function sensei_activity_ids ( $args = array() ) {
222
+	public static function sensei_activity_ids($args = array()) {
223 223
 
224 224
 
225
-		$comments = Sensei_Utils::sensei_check_for_activity( $args, true );
225
+		$comments = Sensei_Utils::sensei_check_for_activity($args, true);
226 226
 		// Need to always use an array, even with only 1 item
227
-		if ( !is_array($comments) ) {
228
-			$comments = array( $comments );
227
+		if ( ! is_array($comments)) {
228
+			$comments = array($comments);
229 229
 		}
230 230
 
231 231
 		$post_ids = array();
232 232
 		// Count comments
233
-		if ( is_array( $comments ) && ( 0 < intval( count( $comments ) ) ) ) {
234
-			foreach ( $comments as $key => $value  ) {
233
+		if (is_array($comments) && (0 < intval(count($comments)))) {
234
+			foreach ($comments as $key => $value) {
235 235
 				// Add matches to id array
236
-				if ( isset( $args['field'] ) && 'comment' == $args['field'] ) {
237
-					array_push( $post_ids, $value->comment_ID );
238
-				} elseif( isset( $args['field'] ) && 'user_id' == $args['field'] ) {
239
-					array_push( $post_ids, $value->user_id );
236
+				if (isset($args['field']) && 'comment' == $args['field']) {
237
+					array_push($post_ids, $value->comment_ID);
238
+				} elseif (isset($args['field']) && 'user_id' == $args['field']) {
239
+					array_push($post_ids, $value->user_id);
240 240
 				} else {
241
-					array_push( $post_ids, $value->comment_post_ID );
241
+					array_push($post_ids, $value->comment_post_ID);
242 242
 				} // End If Statement
243 243
 			} // End For Loop
244 244
 			// Reset array indexes
245
-			$post_ids = array_unique( $post_ids );
246
-			$post_ids = array_values( $post_ids );
245
+			$post_ids = array_unique($post_ids);
246
+			$post_ids = array_values($post_ids);
247 247
 		} // End If Statement
248 248
 
249 249
 		return $post_ids;
@@ -257,20 +257,20 @@  discard block
 block discarded – undo
257 257
 	 * @param  array $args (default: array())
258 258
 	 * @return boolean
259 259
 	 */
260
-	public static function sensei_delete_activities ( $args = array() ) {
260
+	public static function sensei_delete_activities($args = array()) {
261 261
 
262 262
 		$dataset_changes = false;
263 263
 
264 264
 		// If activity exists remove activity from log
265
-		$comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => intval( $args['post_id'] ), 'user_id' => intval( $args['user_id'] ), 'type' => esc_attr( $args['type'] ) ), true );
266
-		if( $comments ) {
265
+		$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => intval($args['post_id']), 'user_id' => intval($args['user_id']), 'type' => esc_attr($args['type'])), true);
266
+		if ($comments) {
267 267
 			// Need to always return an array, even with only 1 item
268
-			if ( !is_array( $comments ) ) {
269
-				$comments = array( $comments );
268
+			if ( ! is_array($comments)) {
269
+				$comments = array($comments);
270 270
 			}
271
-			foreach ( $comments as $key => $value  ) {
272
-				if ( isset( $value->comment_ID ) && 0 < $value->comment_ID ) {
273
-					$dataset_changes = wp_delete_comment( intval( $value->comment_ID ), true );
271
+			foreach ($comments as $key => $value) {
272
+				if (isset($value->comment_ID) && 0 < $value->comment_ID) {
273
+					$dataset_changes = wp_delete_comment(intval($value->comment_ID), true);
274 274
 				} // End If Statement
275 275
 			} // End For Loop
276 276
 			// Manually flush the cache
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
      * @param  integer $user_id User ID
287 287
      * @return boolean
288 288
      */
289
-    public static function delete_all_user_activity( $user_id = 0 ) {
289
+    public static function delete_all_user_activity($user_id = 0) {
290 290
 
291 291
     	$dataset_changes = false;
292 292
 
293
-    	if( $user_id ) {
293
+    	if ($user_id) {
294 294
 
295
-			$activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true );
295
+			$activities = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user_id), true);
296 296
 
297
-			if( $activities ) {
297
+			if ($activities) {
298 298
 
299 299
 				// Need to always return an array, even with only 1 item
300
-				if ( ! is_array( $activities ) ) {
301
-					$activities = array( $activities );
300
+				if ( ! is_array($activities)) {
301
+					$activities = array($activities);
302 302
 				}
303 303
 
304
-				foreach( $activities as $activity ) {
305
-					if( '' == $activity->comment_type ) continue;
306
-					if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
307
-					$dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true );
304
+				foreach ($activities as $activity) {
305
+					if ('' == $activity->comment_type) continue;
306
+					if (strpos('sensei_', $activity->comment_type) != 0) continue;
307
+					$dataset_changes = wp_delete_comment(intval($activity->comment_ID), true);
308 308
 					wp_cache_flush();
309 309
 				}
310 310
 			}
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 	 * @param  array $args (default: array())
322 322
 	 * @return string
323 323
 	 */
324
-	public static function sensei_get_activity_value ( $args = array() ) {
324
+	public static function sensei_get_activity_value($args = array()) {
325 325
 
326 326
 
327 327
 		$activity_value = false;
328
-		if ( !empty($args['field']) ) {
329
-			$comment = Sensei_Utils::sensei_check_for_activity( $args, true );
328
+		if ( ! empty($args['field'])) {
329
+			$comment = Sensei_Utils::sensei_check_for_activity($args, true);
330 330
 
331
-			if ( isset( $comment->{$args['field']} ) && '' != $comment->{$args['field']} ) {
331
+			if (isset($comment->{$args['field']} ) && '' != $comment->{$args['field']} ) {
332 332
 				$activity_value = $comment->{$args['field']};
333 333
 			} // End If Statement
334 334
 		}
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
      * @param  int $product_id
347 347
      * @return bool
348 348
      */
349
-    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
349
+    public static function sensei_customer_bought_product($customer_email, $user_id, $product_id) {
350 350
 
351 351
         $emails = array();
352 352
 
353
-        if ( $user_id ) {
354
-            $user = get_user_by( 'id', intval( $user_id ) );
353
+        if ($user_id) {
354
+            $user = get_user_by('id', intval($user_id));
355 355
             $emails[] = $user->user_email;
356 356
         }
357 357
 
358
-        if ( is_email( $customer_email ) )
358
+        if (is_email($customer_email))
359 359
             $emails[] = $customer_email;
360 360
 
361
-        if ( sizeof( $emails ) == 0 )
361
+        if (sizeof($emails) == 0)
362 362
             return false;
363 363
 
364
-        return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
364
+        return Sensei_WC::has_customer_bought_product($user_id, $product_id);
365 365
 
366 366
     } // End sensei_customer_bought_product()
367 367
 
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 	 * @param  string $input_name Name for text area form element
373 373
 	 * @return void
374 374
 	 */
375
-	public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) {
375
+	public static function sensei_text_editor($content = '', $editor_id = 'senseitexteditor', $input_name = '') {
376 376
 
377
-		if( ! $input_name ) $input_name = $editor_id;
377
+		if ( ! $input_name) $input_name = $editor_id;
378 378
 
379 379
 		$buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext';
380 380
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 			'quicktags' => false
393 393
 		);
394 394
 
395
-		wp_editor( $content, $editor_id, $settings );
395
+		wp_editor($content, $editor_id, $settings);
396 396
 
397 397
 	} // End sensei_text_editor()
398 398
 
@@ -402,57 +402,57 @@  discard block
 block discarded – undo
402 402
      * @param int $user_id
403 403
 	 * @return boolean            Whether the answers were saved or not
404 404
 	 */
405
-	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) {
405
+	public static function sensei_save_quiz_answers($submitted = array(), $user_id = 0) {
406 406
 
407
-		if( intval( $user_id ) == 0 ) {
407
+		if (intval($user_id) == 0) {
408 408
 			$user_id = get_current_user_id();
409 409
 		}
410 410
 
411 411
 		$answers_saved = false;
412 412
 
413
-		if( $submitted && intval( $user_id ) > 0 ) {
413
+		if ($submitted && intval($user_id) > 0) {
414 414
 
415
-			foreach( $submitted as $question_id => $answer ) {
415
+			foreach ($submitted as $question_id => $answer) {
416 416
 
417 417
 				// Get question type
418
-				$question_type = Sensei()->question->get_question_type( $question_id );
418
+				$question_type = Sensei()->question->get_question_type($question_id);
419 419
 
420 420
 				// Sanitise answer
421
-				if( 0 == get_magic_quotes_gpc() ) {
422
-					$answer = wp_unslash( $answer );
421
+				if (0 == get_magic_quotes_gpc()) {
422
+					$answer = wp_unslash($answer);
423 423
 				}
424
-				switch( $question_type ) {
425
-					case 'multi-line': $answer = nl2br( $answer ); break;
424
+				switch ($question_type) {
425
+					case 'multi-line': $answer = nl2br($answer); break;
426 426
 					case 'single-line': break;
427 427
 					case 'gap-fill': break;
428
-					default: $answer = maybe_serialize( $answer ); break;
428
+					default: $answer = maybe_serialize($answer); break;
429 429
 				}
430 430
 				$args = array(
431 431
 							'post_id' => $question_id,
432
-							'data' => base64_encode( $answer ),
432
+							'data' => base64_encode($answer),
433 433
 							'type' => 'sensei_user_answer', /* FIELD SIZE 20 */
434 434
 							'user_id' => $user_id,
435 435
 							'action' => 'update'
436 436
 						);
437
-				$answers_saved = Sensei_Utils::sensei_log_activity( $args );
437
+				$answers_saved = Sensei_Utils::sensei_log_activity($args);
438 438
 			}
439 439
 
440 440
 			// Handle file upload questions
441
-			if( isset( $_FILES ) ) {
442
-				foreach( $_FILES as $field => $file ) {
443
-					if( strpos( $field, 'file_upload_' ) !== false ) {
444
-						$question_id = str_replace( 'file_upload_', '', $field );
445
-						if( $file && $question_id ) {
446
-							$attachment_id = self::upload_file( $file );
447
-							if( $attachment_id ) {
441
+			if (isset($_FILES)) {
442
+				foreach ($_FILES as $field => $file) {
443
+					if (strpos($field, 'file_upload_') !== false) {
444
+						$question_id = str_replace('file_upload_', '', $field);
445
+						if ($file && $question_id) {
446
+							$attachment_id = self::upload_file($file);
447
+							if ($attachment_id) {
448 448
 								$args = array(
449 449
 									'post_id' => $question_id,
450
-									'data' => base64_encode( $attachment_id ),
450
+									'data' => base64_encode($attachment_id),
451 451
 									'type' => 'sensei_user_answer', /* FIELD SIZE 20 */
452 452
 									'user_id' => $user_id,
453 453
 									'action' => 'update'
454 454
 								);
455
-								$answers_saved = Sensei_Utils::sensei_log_activity( $args );
455
+								$answers_saved = Sensei_Utils::sensei_log_activity($args);
456 456
 							}
457 457
 						}
458 458
 					}
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 
465 465
 	} // End sensei_save_quiz_answers()
466 466
 
467
-	public static function upload_file( $file = array() ) {
467
+	public static function upload_file($file = array()) {
468 468
 
469
-		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
469
+		require_once(ABSPATH.'wp-admin/includes/admin.php');
470 470
 
471 471
         /**
472 472
          * Filter the data array for the Sensei wp_handle_upload function call
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
          *     @type string test_form set to false by default
482 482
          * }
483 483
          */
484
-        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
484
+        $file_upload_args = apply_filters('sensei_file_upload_args', array('test_form' => false));
485 485
 
486
-        $file_return = wp_handle_upload( $file, $file_upload_args );
486
+        $file_return = wp_handle_upload($file, $file_upload_args);
487 487
 
488
-        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
488
+        if (isset($file_return['error']) || isset($file_return['upload_error_handler'])) {
489 489
             return false;
490 490
         } else {
491 491
 
@@ -493,19 +493,19 @@  discard block
 block discarded – undo
493 493
 
494 494
             $attachment = array(
495 495
                 'post_mime_type' => $file_return['type'],
496
-                'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
496
+                'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
497 497
                 'post_content' => '',
498 498
                 'post_status' => 'inherit',
499 499
                 'guid' => $file_return['url']
500 500
             );
501 501
 
502
-            $attachment_id = wp_insert_attachment( $attachment, $filename );
502
+            $attachment_id = wp_insert_attachment($attachment, $filename);
503 503
 
504
-            require_once(ABSPATH . 'wp-admin/includes/image.php');
505
-            $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
506
-            wp_update_attachment_metadata( $attachment_id, $attachment_data );
504
+            require_once(ABSPATH.'wp-admin/includes/image.php');
505
+            $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
506
+            wp_update_attachment_metadata($attachment_id, $attachment_data);
507 507
 
508
-            if( 0 < intval( $attachment_id ) ) {
508
+            if (0 < intval($attachment_id)) {
509 509
             	return $attachment_id;
510 510
             }
511 511
         }
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
      *
532 532
 	 * @return int $quiz_grade total sum of all question grades
533 533
 	 */
534
-	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
534
+	public static function sensei_grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') {
535 535
 
536
-        return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
536
+        return Sensei_Grading::grade_quiz_auto($quiz_id, $submitted, $total_questions, $quiz_grade_type);
537 537
 
538 538
 	} // End sensei_grade_quiz_auto()
539 539
 
@@ -545,20 +545,20 @@  discard block
 block discarded – undo
545 545
      * @param  string $quiz_grade_type default 'auto'
546 546
 	 * @return boolean
547 547
 	 */
548
-	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) {
549
-		if( intval( $user_id ) == 0 ) {
548
+	public static function sensei_grade_quiz($quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto') {
549
+		if (intval($user_id) == 0) {
550 550
 			$user_id = get_current_user_id();
551 551
 		}
552 552
 
553 553
 		$activity_logged = false;
554
-		if( intval( $quiz_id ) > 0 && intval( $user_id ) > 0 ) {
555
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
556
-			$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
557
-			$activity_logged = update_comment_meta( $user_lesson_status->comment_ID, 'grade', $grade );
554
+		if (intval($quiz_id) > 0 && intval($user_id) > 0) {
555
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
556
+			$user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
557
+			$activity_logged = update_comment_meta($user_lesson_status->comment_ID, 'grade', $grade);
558 558
 
559
-			$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
559
+			$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
560 560
 
561
-			do_action( 'sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type );
561
+			do_action('sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type);
562 562
 		}
563 563
 
564 564
 		return $activity_logged;
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
      *
579 579
 	 * @return int $question_grade
580 580
 	 */
581
-	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
581
+	public static function sensei_grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) {
582 582
 
583
-       return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
583
+       return  WooThemes_Sensei_Grading::grade_question_auto($question_id, $question_type, $answer, $user_id);
584 584
 
585 585
 	} // end sensei_grade_question_auto
586 586
 
@@ -591,20 +591,20 @@  discard block
 block discarded – undo
591 591
      * @param int $user_id
592 592
 	 * @return boolean
593 593
 	 */
594
-	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) {
595
-		if( intval( $user_id ) == 0 ) {
594
+	public static function sensei_grade_question($question_id = 0, $grade = 0, $user_id = 0) {
595
+		if (intval($user_id) == 0) {
596 596
 			$user_id = get_current_user_id();
597 597
 		}
598 598
 
599 599
 		$activity_logged = false;
600
-		if( intval( $question_id ) > 0 && intval( $user_id ) > 0 ) {
600
+		if (intval($question_id) > 0 && intval($user_id) > 0) {
601 601
 
602
-			$user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
603
-			$activity_logged = update_comment_meta( $user_answer_id, 'user_grade', $grade );
602
+			$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
603
+			$activity_logged = update_comment_meta($user_answer_id, 'user_grade', $grade);
604 604
 
605
-			$answer_notes = get_post_meta( $question_id, '_answer_feedback', true );
606
-			if ( !empty($answer_notes) ) {
607
-				update_comment_meta( $user_answer_id, 'answer_note', base64_encode( $answer_notes ) );
605
+			$answer_notes = get_post_meta($question_id, '_answer_feedback', true);
606
+			if ( ! empty($answer_notes)) {
607
+				update_comment_meta($user_answer_id, 'answer_note', base64_encode($answer_notes));
608 608
 			}
609 609
 
610 610
 		}
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
 		return $activity_logged;
613 613
 	}
614 614
 
615
-	public static function sensei_delete_question_grade( $question_id = 0, $user_id = 0 ) {
616
-		if( intval( $user_id ) == 0 ) {
615
+	public static function sensei_delete_question_grade($question_id = 0, $user_id = 0) {
616
+		if (intval($user_id) == 0) {
617 617
 			$user_id = get_current_user_id();
618 618
 		}
619 619
 
620 620
 		$activity_logged = false;
621
-		if( intval( $question_id ) > 0 ) {
622
-			$user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
623
-			$activity_logged = delete_comment_meta( $user_answer_id, 'user_grade' );
621
+		if (intval($question_id) > 0) {
622
+			$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
623
+			$activity_logged = delete_comment_meta($user_answer_id, 'user_grade');
624 624
 		}
625 625
 
626 626
 		return $activity_logged;
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
      *
639 639
      * @return mixed boolean or comment_ID
640 640
      */
641
-    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
641
+    public static function user_start_lesson($user_id = 0, $lesson_id = 0, $complete = false) {
642 642
 
643
-        return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
643
+        return self::sensei_start_lesson($lesson_id, $user_id, $complete);
644 644
 
645 645
     }// end user_start_lesson()
646 646
 
@@ -657,22 +657,22 @@  discard block
 block discarded – undo
657 657
      *
658 658
      * @return mixed boolean or comment_ID
659 659
 	 */
660
-	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
660
+	public static function sensei_start_lesson($lesson_id = 0, $user_id = 0, $complete = false) {
661 661
 
662 662
 
663
-		if( intval( $user_id ) == 0 ) {
663
+		if (intval($user_id) == 0) {
664 664
 			$user_id = get_current_user_id();
665 665
 		}
666 666
 
667 667
 		$activity_logged = false;
668 668
 
669
-		if( intval( $lesson_id ) > 0 ) {
669
+		if (intval($lesson_id) > 0) {
670 670
 
671
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
672
-			if( $course_id ) {
673
-				$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, $user_id );
674
-				if( ! $is_user_taking_course ) {
675
-					Sensei_Utils::user_start_course( $user_id, $course_id );
671
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
672
+			if ($course_id) {
673
+				$is_user_taking_course = Sensei_Utils::user_started_course($course_id, $user_id);
674
+				if ( ! $is_user_taking_course) {
675
+					Sensei_Utils::user_start_course($user_id, $course_id);
676 676
 				}
677 677
 			}
678 678
 
@@ -680,12 +680,12 @@  discard block
 block discarded – undo
680 680
 			$status = 'in-progress';
681 681
 
682 682
 			// Note: When this action runs the lesson status may not yet exist
683
-			do_action( 'sensei_user_lesson_start', $user_id, $lesson_id );
683
+			do_action('sensei_user_lesson_start', $user_id, $lesson_id);
684 684
 
685
-			if( $complete ) {
685
+			if ($complete) {
686 686
 
687
-				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
688
-				if ( $has_questions ) {
687
+				$has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
688
+				if ($has_questions) {
689 689
 					$status = 'passed'; // Force a pass
690 690
 					$metadata['grade'] = 0;
691 691
 				}
@@ -695,31 +695,31 @@  discard block
 block discarded – undo
695 695
 			}
696 696
 
697 697
 			// Check if user is already taking the lesson
698
-			$activity_logged = Sensei_Utils::user_started_lesson( $lesson_id, $user_id );
699
-			if( ! $activity_logged ) {
698
+			$activity_logged = Sensei_Utils::user_started_lesson($lesson_id, $user_id);
699
+			if ( ! $activity_logged) {
700 700
 
701 701
 				$metadata['start'] = current_time('mysql');
702
-				$activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata );
702
+				$activity_logged = Sensei_Utils::update_lesson_status($user_id, $lesson_id, $status, $metadata);
703 703
 
704 704
             } else {
705 705
 
706 706
                 // if users is already taking the lesson  and the status changes to complete update it
707 707
                 $current_user_activity = get_comment($activity_logged);
708
-                if( $status=='complete' &&
709
-                    $status != $current_user_activity->comment_approved  ){
708
+                if ($status == 'complete' &&
709
+                    $status != $current_user_activity->comment_approved) {
710 710
 
711 711
                     $comment = array();
712 712
                     $comment['comment_ID'] = $activity_logged;
713 713
                     $comment['comment_approved'] = $status;
714
-                    wp_update_comment( $comment );
714
+                    wp_update_comment($comment);
715 715
 
716 716
                 }
717 717
 
718 718
             }
719 719
 
720
-			if ( $complete ) {
720
+			if ($complete) {
721 721
 				// Run this *after* the lesson status has been created/updated
722
-				do_action( 'sensei_user_lesson_end', $user_id, $lesson_id );
722
+				do_action('sensei_user_lesson_end', $user_id, $lesson_id);
723 723
 			}
724 724
 
725 725
 		}
@@ -734,20 +734,20 @@  discard block
 block discarded – undo
734 734
 	 * @param int $user_id
735 735
 	 * @return boolean
736 736
 	 */
737
-	public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) {
737
+	public static function sensei_remove_user_from_lesson($lesson_id = 0, $user_id = 0, $from_course = false) {
738 738
 
739 739
 
740
-		if( ! $lesson_id ) return false;
740
+		if ( ! $lesson_id) return false;
741 741
 
742
-		if( intval( $user_id ) == 0 ) {
742
+		if (intval($user_id) == 0) {
743 743
 			$user_id = get_current_user_id();
744 744
 		}
745 745
 
746 746
 		// Process quiz
747
-		$lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
747
+		$lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
748 748
 
749 749
 		// Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade
750
-		Sensei_Utils::sensei_delete_quiz_answers( $lesson_quiz_id, $user_id );
750
+		Sensei_Utils::sensei_delete_quiz_answers($lesson_quiz_id, $user_id);
751 751
 
752 752
 		// Delete lesson status
753 753
 		$args = array(
@@ -756,10 +756,10 @@  discard block
 block discarded – undo
756 756
 			'user_id' => $user_id,
757 757
 		);
758 758
 		// This auto deletes the corresponding meta data, such as the quiz grade, and questions asked
759
-		Sensei_Utils::sensei_delete_activities( $args );
759
+		Sensei_Utils::sensei_delete_activities($args);
760 760
 
761
-		if( ! $from_course ) {
762
-			do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id );
761
+		if ( ! $from_course) {
762
+			do_action('sensei_user_lesson_reset', $user_id, $lesson_id);
763 763
 		}
764 764
 
765 765
 		return true;
@@ -772,19 +772,19 @@  discard block
 block discarded – undo
772 772
 	 * @param int $user_id
773 773
 	 * @return boolean
774 774
 	 */
775
-	public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) {
775
+	public static function sensei_remove_user_from_course($course_id = 0, $user_id = 0) {
776 776
 
777 777
 
778
-		if( ! $course_id ) return false;
778
+		if ( ! $course_id) return false;
779 779
 
780
-		if( intval( $user_id ) == 0 ) {
780
+		if (intval($user_id) == 0) {
781 781
 			$user_id = get_current_user_id();
782 782
 		}
783 783
 
784
-		$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
784
+		$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
785 785
 
786
-		foreach( $lesson_ids as $lesson_id ) {
787
-			Sensei_Utils::sensei_remove_user_from_lesson( $lesson_id, $user_id, true );
786
+		foreach ($lesson_ids as $lesson_id) {
787
+			Sensei_Utils::sensei_remove_user_from_lesson($lesson_id, $user_id, true);
788 788
 		}
789 789
 
790 790
 		// Delete course status
@@ -794,36 +794,36 @@  discard block
 block discarded – undo
794 794
 			'user_id' => $user_id,
795 795
 		);
796 796
 
797
-		Sensei_Utils::sensei_delete_activities( $args );
797
+		Sensei_Utils::sensei_delete_activities($args);
798 798
 
799
-		do_action( 'sensei_user_course_reset', $user_id, $course_id );
799
+		do_action('sensei_user_course_reset', $user_id, $course_id);
800 800
 
801 801
 		return true;
802 802
 	}
803 803
 
804
-	public static function sensei_get_quiz_questions( $quiz_id = 0 ) {
804
+	public static function sensei_get_quiz_questions($quiz_id = 0) {
805 805
 
806 806
 
807 807
 		$questions = array();
808 808
 
809
-		if( intval( $quiz_id ) > 0 ) {
810
-			$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
811
-			$questions = Sensei_Utils::array_sort_reorder( $questions );
809
+		if (intval($quiz_id) > 0) {
810
+			$questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
811
+			$questions = Sensei_Utils::array_sort_reorder($questions);
812 812
 		}
813 813
 
814 814
 		return $questions;
815 815
 	}
816 816
 
817
-	public static function sensei_get_quiz_total( $quiz_id = 0 ) {
817
+	public static function sensei_get_quiz_total($quiz_id = 0) {
818 818
 
819 819
 
820 820
 		$quiz_total = 0;
821 821
 
822
-		if( $quiz_id > 0 ) {
823
-			$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
822
+		if ($quiz_id > 0) {
823
+			$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
824 824
 			$question_grade = 0;
825
-			foreach( $questions as $question ) {
826
-				$question_grade = Sensei()->question->get_question_grade( $question->ID );
825
+			foreach ($questions as $question) {
826
+				$question_grade = Sensei()->question->get_question_grade($question->ID);
827 827
 				$quiz_total += $question_grade;
828 828
 			}
829 829
 		}
@@ -838,20 +838,20 @@  discard block
 block discarded – undo
838 838
 	 * @param int $user_id
839 839
 	 * @return string
840 840
 	 */
841
-	public static function sensei_get_user_question_grade( $question = 0, $user_id = 0 ) {
841
+	public static function sensei_get_user_question_grade($question = 0, $user_id = 0) {
842 842
 		$question_grade = false;
843
-		if( $question ) {
844
-			if ( is_object( $question ) ) {
843
+		if ($question) {
844
+			if (is_object($question)) {
845 845
 				$user_answer_id = $question->comment_ID;
846 846
 			}
847 847
 			else {
848
-				if( intval( $user_id ) == 0 ) {
848
+				if (intval($user_id) == 0) {
849 849
 					$user_id = get_current_user_id();
850 850
 				}
851
-				$user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
851
+				$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
852 852
 			}
853
-			if ( $user_answer_id ) {
854
-				$question_grade = get_comment_meta( $user_answer_id, 'user_grade', true );
853
+			if ($user_answer_id) {
854
+				$question_grade = get_comment_meta($user_answer_id, 'user_grade', true);
855 855
 			}
856 856
 		}
857 857
 
@@ -866,52 +866,52 @@  discard block
 block discarded – undo
866 866
 	 * @param int $user_id
867 867
 	 * @return string
868 868
 	 */
869
-	public static function sensei_get_user_question_answer_notes( $question = 0, $user_id = 0 ) {
869
+	public static function sensei_get_user_question_answer_notes($question = 0, $user_id = 0) {
870 870
 		$answer_notes = false;
871
-		if( $question ) {
872
-			if ( is_object( $question ) ) {
871
+		if ($question) {
872
+			if (is_object($question)) {
873 873
 				$user_answer_id = $question->comment_ID;
874 874
 			}
875 875
 			else {
876
-				if( intval( $user_id ) == 0 ) {
876
+				if (intval($user_id) == 0) {
877 877
 					$user_id = get_current_user_id();
878 878
 				}
879
-				$user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
879
+				$user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
880 880
 			}
881
-			if ( $user_answer_id ) {
882
-				$answer_notes = base64_decode( get_comment_meta( $user_answer_id, 'answer_note', true ) );
881
+			if ($user_answer_id) {
882
+				$answer_notes = base64_decode(get_comment_meta($user_answer_id, 'answer_note', true));
883 883
 			}
884 884
 		}
885 885
 
886 886
 		return $answer_notes;
887 887
 	}
888 888
 
889
-	public static function sensei_delete_quiz_answers( $quiz_id = 0, $user_id = 0 ) {
890
-		if( intval( $user_id ) == 0 ) {
889
+	public static function sensei_delete_quiz_answers($quiz_id = 0, $user_id = 0) {
890
+		if (intval($user_id) == 0) {
891 891
 			$user_id = get_current_user_id();
892 892
 		}
893 893
 
894 894
 		$delete_answers = false;
895
-		if( intval( $quiz_id ) > 0 ) {
896
-			$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
897
-			foreach( $questions as $question ) {
898
-				$delete_answers = Sensei_Utils::sensei_delete_activities( array( 'post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ) );
895
+		if (intval($quiz_id) > 0) {
896
+			$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
897
+			foreach ($questions as $question) {
898
+				$delete_answers = Sensei_Utils::sensei_delete_activities(array('post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer'));
899 899
 			}
900 900
 		}
901 901
 
902 902
 		return $delete_answers;
903 903
 	}
904 904
 
905
-	public static function sensei_delete_quiz_grade( $quiz_id = 0, $user_id = 0 ) {
906
-		if( intval( $user_id ) == 0 ) {
905
+	public static function sensei_delete_quiz_grade($quiz_id = 0, $user_id = 0) {
906
+		if (intval($user_id) == 0) {
907 907
 			$user_id = get_current_user_id();
908 908
 		}
909 909
 
910 910
 		$delete_grade = false;
911
-		if( intval( $quiz_id ) > 0 ) {
912
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
913
-			$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
914
-			$delete_grade = delete_comment_meta( $user_lesson_status->comment_ID, 'grade' );
911
+		if (intval($quiz_id) > 0) {
912
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
913
+			$user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
914
+			$delete_grade = delete_comment_meta($user_lesson_status->comment_ID, 'grade');
915 915
 		}
916 916
 
917 917
 		return $delete_grade;
@@ -924,20 +924,20 @@  discard block
 block discarded – undo
924 924
      * @param string $notes
925 925
 	 * @return boolean
926 926
 	 */
927
-	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) {
928
-		if( intval( $user_id ) == 0 ) {
927
+	public static function sensei_add_answer_notes($question_id = 0, $user_id = 0, $notes = '') {
928
+		if (intval($user_id) == 0) {
929 929
 			$user_id = get_current_user_id();
930 930
 		}
931 931
 
932 932
 		$activity_logged = false;
933 933
 
934
-		if( intval( $question_id ) > 0 ) {
935
-			$notes = base64_encode( $notes );
934
+		if (intval($question_id) > 0) {
935
+			$notes = base64_encode($notes);
936 936
 
937 937
 			// Don't store empty values, no point
938
-			if ( !empty($notes) ) {
939
-				$user_lesson_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
940
-				$activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes );
938
+			if ( ! empty($notes)) {
939
+				$user_lesson_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
940
+				$activity_logged = update_comment_meta($user_lesson_id, 'answer_note', $notes);
941 941
 			}
942 942
 			else {
943 943
 				$activity_logged = true;
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 	 * @param  array $return_array data to be ordered
954 954
 	 * @return array $return_array ordered data
955 955
 	 */
956
-	public static function array_sort_reorder( $return_array ) {
957
-		if ( isset( $_GET['orderby'] ) && '' != esc_html( $_GET['orderby'] ) ) {
956
+	public static function array_sort_reorder($return_array) {
957
+		if (isset($_GET['orderby']) && '' != esc_html($_GET['orderby'])) {
958 958
 			$sort_key = '';
959 959
 			// if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->sortable_columns ) ) {
960 960
 			// 	$sort_key = esc_html( $_GET['orderby'] );
961 961
 			// } // End If Statement
962
-			if ( '' != $sort_key ) {
963
-					Sensei_Utils::sort_array_by_key($return_array,$sort_key);
964
-				if ( isset( $_GET['order'] ) && 'desc' == esc_html( $_GET['order'] ) ) {
965
-					$return_array = array_reverse( $return_array, true );
962
+			if ('' != $sort_key) {
963
+					Sensei_Utils::sort_array_by_key($return_array, $sort_key);
964
+				if (isset($_GET['order']) && 'desc' == esc_html($_GET['order'])) {
965
+					$return_array = array_reverse($return_array, true);
966 966
 				} // End If Statement
967 967
 			} // End If Statement
968 968
 			return $return_array;
@@ -978,15 +978,15 @@  discard block
 block discarded – undo
978 978
 	 * @param  $key string column name in array
979 979
 	 * @return void
980 980
 	 */
981
-	public static function sort_array_by_key( $array, $key ) {
981
+	public static function sort_array_by_key($array, $key) {
982 982
 	    $sorter = array();
983 983
 	    $ret = array();
984
-	    reset( $array );
985
-	    foreach ( $array as $ii => $va ) {
984
+	    reset($array);
985
+	    foreach ($array as $ii => $va) {
986 986
 	        $sorter[$ii] = $va[$key];
987 987
 	    } // End For Loop
988
-	    asort( $sorter );
989
-	    foreach ( $sorter as $ii => $va ) {
988
+	    asort($sorter);
989
+	    foreach ($sorter as $ii => $va) {
990 990
 	        $ret[$ii] = $array[$ii];
991 991
 	    } // End For Loop
992 992
 	    $array = $ret;
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 	 * @param  integer $quiz_id
999 999
 	 * @return array of quiz questions
1000 1000
 	 */
1001
-	public static function lesson_quiz_questions( $quiz_id = 0 ) {
1001
+	public static function lesson_quiz_questions($quiz_id = 0) {
1002 1002
 		$questions_array = array();
1003
-		if ( 0 < $quiz_id ) {
1004
-			$question_args = array( 'post_type'         => 'question',
1003
+		if (0 < $quiz_id) {
1004
+			$question_args = array('post_type'         => 'question',
1005 1005
                                     'posts_per_page'       => -1,
1006 1006
                                     'orderby'           => 'ID',
1007 1007
                                     'order'             => 'ASC',
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
                                     'post_status'       => 'any',
1015 1015
                                     'suppress_filters'  => 0
1016 1016
                                 );
1017
-            $questions_array = get_posts( $question_args );
1017
+            $questions_array = get_posts($question_args);
1018 1018
         } // End If Statement
1019 1019
         return $questions_array;
1020 1020
 	} // End lesson_quiz_questions()
@@ -1024,25 +1024,25 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  integer $course_id ID of course
1025 1025
 	 * @return integer            Pass mark for course
1026 1026
 	 */
1027
-	public static function sensei_course_pass_grade( $course_id = 0 ) {
1027
+	public static function sensei_course_pass_grade($course_id = 0) {
1028 1028
 
1029 1029
 
1030 1030
 		$course_passmark = 0;
1031 1031
 
1032
-		if( $course_id > 0 ) {
1033
-			$lessons = Sensei()->course->course_lessons( $course_id );
1032
+		if ($course_id > 0) {
1033
+			$lessons = Sensei()->course->course_lessons($course_id);
1034 1034
 			$lesson_count = 0;
1035 1035
 			$total_passmark = 0;
1036
-			foreach( $lessons as $lesson ) {
1036
+			foreach ($lessons as $lesson) {
1037 1037
 
1038 1038
 				// Get Quiz ID
1039
-				$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID );
1039
+				$quiz_id = Sensei()->lesson->lesson_quizzes($lesson->ID);
1040 1040
 
1041 1041
 				// Check for a pass being required
1042
-				$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1043
-				if ( $pass_required ) {
1042
+				$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1043
+				if ($pass_required) {
1044 1044
 					// Get quiz passmark
1045
-					$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
1045
+					$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
1046 1046
 
1047 1047
 					// Add up total passmark
1048 1048
 					$total_passmark += $quiz_passmark;
@@ -1051,12 +1051,12 @@  discard block
 block discarded – undo
1051 1051
 				}
1052 1052
 			}
1053 1053
 			// Might be a case of no required lessons
1054
-			if ( $lesson_count ) {
1055
-				$course_passmark = ( $total_passmark / $lesson_count );
1054
+			if ($lesson_count) {
1055
+				$course_passmark = ($total_passmark / $lesson_count);
1056 1056
 			}
1057 1057
 		}
1058 1058
 
1059
-		return Sensei_Utils::round( $course_passmark );
1059
+		return Sensei_Utils::round($course_passmark);
1060 1060
 	}
1061 1061
 
1062 1062
 	/**
@@ -1065,27 +1065,27 @@  discard block
 block discarded – undo
1065 1065
 	 * @param  integer $user_id   ID of user
1066 1066
 	 * @return integer            User's total grade
1067 1067
 	 */
1068
-	public static function sensei_course_user_grade( $course_id = 0, $user_id = 0 ) {
1068
+	public static function sensei_course_user_grade($course_id = 0, $user_id = 0) {
1069 1069
 
1070 1070
 
1071
-		if( intval( $user_id ) == 0 ) {
1071
+		if (intval($user_id) == 0) {
1072 1072
 			$user_id = get_current_user_id();
1073 1073
 		}
1074 1074
 
1075 1075
 		$total_grade = 0;
1076 1076
 
1077
-		if( $course_id > 0 && $user_id > 0 ) {
1078
-			$lessons = Sensei()->course->course_lessons( $course_id );
1077
+		if ($course_id > 0 && $user_id > 0) {
1078
+			$lessons = Sensei()->course->course_lessons($course_id);
1079 1079
 			$lesson_count = 0;
1080 1080
 			$total_grade = 0;
1081
-			foreach( $lessons as $lesson ) {
1081
+			foreach ($lessons as $lesson) {
1082 1082
 
1083 1083
 				// Check for lesson having questions, thus a quiz, thus having a grade
1084
-				$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
1085
-				if ( $has_questions ) {
1086
-					$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, $user_id );
1084
+				$has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
1085
+				if ($has_questions) {
1086
+					$user_lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, $user_id);
1087 1087
 					// Get user quiz grade
1088
-					$quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1088
+					$quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1089 1089
 
1090 1090
 					// Add up total grade
1091 1091
 					$total_grade += $quiz_grade;
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
 			}
1096 1096
 
1097 1097
 			// Might be a case of no lessons with quizzes
1098
-			if ( $lesson_count ) {
1099
-				$total_grade = ( $total_grade / $lesson_count );
1098
+			if ($lesson_count) {
1099
+				$total_grade = ($total_grade / $lesson_count);
1100 1100
 			}
1101 1101
 
1102 1102
 		}
1103 1103
 
1104
-		return Sensei_Utils::round( $total_grade );
1104
+		return Sensei_Utils::round($total_grade);
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1110,18 +1110,18 @@  discard block
 block discarded – undo
1110 1110
 	 * @param  integer $user_id   ID of user
1111 1111
 	 * @return boolean
1112 1112
 	 */
1113
-	public static function sensei_user_passed_course( $course_id = 0, $user_id = 0 ) {
1114
-		if( intval( $user_id ) == 0 ) {
1113
+	public static function sensei_user_passed_course($course_id = 0, $user_id = 0) {
1114
+		if (intval($user_id) == 0) {
1115 1115
 			$user_id = get_current_user_id();
1116 1116
 		}
1117 1117
 
1118 1118
 		$pass = false;
1119 1119
 
1120
-		if( $course_id > 0 && $user_id > 0 ) {
1121
-			$passmark = Sensei_Utils::sensei_course_pass_grade( $course_id );
1122
-			$user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id );
1120
+		if ($course_id > 0 && $user_id > 0) {
1121
+			$passmark = Sensei_Utils::sensei_course_pass_grade($course_id);
1122
+			$user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id);
1123 1123
 
1124
-			if( $user_grade >= $passmark ) {
1124
+			if ($user_grade >= $passmark) {
1125 1125
 				$pass = true;
1126 1126
 			}
1127 1127
 		}
@@ -1136,38 +1136,38 @@  discard block
 block discarded – undo
1136 1136
 	 * @param  integer $user_id   ID of user
1137 1137
 	 * @return array              Status code and message
1138 1138
 	 */
1139
-	public static function sensei_user_course_status_message( $course_id = 0, $user_id = 0 ) {
1140
-		if( intval( $user_id ) == 0 ) {
1139
+	public static function sensei_user_course_status_message($course_id = 0, $user_id = 0) {
1140
+		if (intval($user_id) == 0) {
1141 1141
 			$user_id = get_current_user_id();
1142 1142
 		}
1143 1143
 
1144 1144
 		$status = 'not_started';
1145 1145
 		$box_class = 'info';
1146
-		$message = __( 'You have not started this course yet.', 'woothemes-sensei' );
1146
+		$message = __('You have not started this course yet.', 'woothemes-sensei');
1147 1147
 
1148
-		if( $course_id > 0 && $user_id > 0 ) {
1148
+		if ($course_id > 0 && $user_id > 0) {
1149 1149
 
1150
-			$started_course = Sensei_Utils::user_started_course( $course_id, $user_id );
1150
+			$started_course = Sensei_Utils::user_started_course($course_id, $user_id);
1151 1151
 
1152
-			if( $started_course ) {
1153
-				$passmark = Sensei_Utils::sensei_course_pass_grade( $course_id ); // This happens inside sensei_user_passed_course()!
1154
-				$user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); // This happens inside sensei_user_passed_course()!
1155
-				if( $user_grade >= $passmark ) {
1152
+			if ($started_course) {
1153
+				$passmark = Sensei_Utils::sensei_course_pass_grade($course_id); // This happens inside sensei_user_passed_course()!
1154
+				$user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id); // This happens inside sensei_user_passed_course()!
1155
+				if ($user_grade >= $passmark) {
1156 1156
 					$status = 'passed';
1157 1157
 					$box_class = 'tick';
1158
-					$message = sprintf( __( 'You have passed this course with a grade of %1$d%%.', 'woothemes-sensei' ), $user_grade );
1158
+					$message = sprintf(__('You have passed this course with a grade of %1$d%%.', 'woothemes-sensei'), $user_grade);
1159 1159
 				} else {
1160 1160
 					$status = 'failed';
1161 1161
 					$box_class = 'alert';
1162
-					$message = sprintf( __( 'You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei' ), $passmark, $user_grade );
1162
+					$message = sprintf(__('You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei'), $passmark, $user_grade);
1163 1163
 				}
1164 1164
 			}
1165 1165
 
1166 1166
 		}
1167 1167
 
1168
-		$message = apply_filters( 'sensei_user_course_status_' . $status, $message );
1168
+		$message = apply_filters('sensei_user_course_status_'.$status, $message);
1169 1169
 
1170
-		return array( 'status' => $status, 'box_class' => $box_class, 'message' => $message );
1170
+		return array('status' => $status, 'box_class' => $box_class, 'message' => $message);
1171 1171
 	}
1172 1172
 
1173 1173
 	/**
@@ -1177,94 +1177,94 @@  discard block
 block discarded – undo
1177 1177
      * @param  bool $is_lesson
1178 1178
 	 * @return array              Status code and message
1179 1179
 	 */
1180
-	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) {
1180
+	public static function sensei_user_quiz_status_message($lesson_id = 0, $user_id = 0, $is_lesson = false) {
1181 1181
 		global  $current_user;
1182
-		if( intval( $user_id ) == 0 ) {
1182
+		if (intval($user_id) == 0) {
1183 1183
 			$user_id = $current_user->ID;
1184 1184
 		}
1185 1185
 
1186 1186
 		$status = 'not_started';
1187 1187
 		$box_class = 'info';
1188
-		$message = __( "You have not taken this lesson's quiz yet", 'woothemes-sensei' );
1188
+		$message = __("You have not taken this lesson's quiz yet", 'woothemes-sensei');
1189 1189
 		$extra = '';
1190 1190
 
1191
-		if( $lesson_id > 0 && $user_id > 0 ) {
1191
+		if ($lesson_id > 0 && $user_id > 0) {
1192 1192
 
1193 1193
 			// Prerequisite lesson
1194
-			$prerequisite = get_post_meta( $lesson_id, '_lesson_prerequisite', true );
1194
+			$prerequisite = get_post_meta($lesson_id, '_lesson_prerequisite', true);
1195 1195
 
1196 1196
 			// Course ID
1197
-			$course_id = absint( get_post_meta( $lesson_id, '_lesson_course', true ) );
1197
+			$course_id = absint(get_post_meta($lesson_id, '_lesson_course', true));
1198 1198
 
1199 1199
 			// Has user started course
1200
-			$started_course = Sensei_Utils::user_started_course( $course_id, $user_id );
1200
+			$started_course = Sensei_Utils::user_started_course($course_id, $user_id);
1201 1201
 
1202 1202
 			// Has user completed lesson
1203
-			$user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1204
-			$lesson_complete = Sensei_Utils::user_completed_lesson( $user_lesson_status );
1203
+			$user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1204
+			$lesson_complete = Sensei_Utils::user_completed_lesson($user_lesson_status);
1205 1205
 
1206 1206
 			// Quiz ID
1207
-			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1207
+			$quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1208 1208
 
1209 1209
 			// Quiz grade
1210 1210
 			$quiz_grade = 0;
1211
-			if ( $user_lesson_status ) {
1212
-				$quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1211
+			if ($user_lesson_status) {
1212
+				$quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1213 1213
 			}
1214 1214
 
1215 1215
 			// Quiz passmark
1216
-			$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
1216
+			$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
1217 1217
 			$quiz_passmark_float = (float) $quiz_passmark;
1218 1218
 
1219 1219
 			// Pass required
1220
-			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1220
+			$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1221 1221
 
1222 1222
 			// Quiz questions
1223
-			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
1223
+			$has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
1224 1224
 
1225
-			if ( ! $started_course ) {
1225
+			if ( ! $started_course) {
1226 1226
 
1227 1227
 				$status = 'not_started_course';
1228 1228
 				$box_class = 'info';
1229
-				$message = sprintf( __( 'Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . esc_attr( __( 'Sign Up', 'woothemes-sensei' ) ) . '">', '</a>' );
1229
+				$message = sprintf(__('Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.esc_attr(__('Sign Up', 'woothemes-sensei')).'">', '</a>');
1230 1230
 
1231
-			} elseif ( ! is_user_logged_in() ) {
1231
+			} elseif ( ! is_user_logged_in()) {
1232 1232
 
1233 1233
 				$status = 'login_required';
1234 1234
 				$box_class = 'info';
1235
-				$message = __( 'You must be logged in to take this quiz', 'woothemes-sensei' );
1235
+				$message = __('You must be logged in to take this quiz', 'woothemes-sensei');
1236 1236
 
1237 1237
 			}
1238 1238
 			// Lesson/Quiz is marked as complete thus passing any quiz restrictions
1239
-			elseif ( $lesson_complete ) {
1239
+			elseif ($lesson_complete) {
1240 1240
 
1241 1241
 				$status = 'passed';
1242 1242
 				$box_class = 'tick';
1243 1243
 				// Lesson status will be "complete" (has no Quiz)
1244
-				if ( ! $has_quiz_questions ) {
1245
-					$message = sprintf( __( 'Congratulations! You have passed this lesson.', 'woothemes-sensei' ) );
1244
+				if ( ! $has_quiz_questions) {
1245
+					$message = sprintf(__('Congratulations! You have passed this lesson.', 'woothemes-sensei'));
1246 1246
 				}
1247 1247
 				// Lesson status will be "graded" (no passmark required so might have failed all the questions)
1248
-				elseif ( empty( $quiz_grade ) ) {
1249
-					$message = sprintf( __( 'Congratulations! You have completed this lesson.', 'woothemes-sensei' ) );
1248
+				elseif (empty($quiz_grade)) {
1249
+					$message = sprintf(__('Congratulations! You have completed this lesson.', 'woothemes-sensei'));
1250 1250
 				}
1251 1251
 				// Lesson status will be "passed" (passmark reached)
1252
-				elseif ( ! empty( $quiz_grade ) && abs( $quiz_grade ) >= 0 ) {
1253
-					if( $is_lesson ) {
1254
-						$message = sprintf( __( 'Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_grade ) );
1252
+				elseif ( ! empty($quiz_grade) && abs($quiz_grade) >= 0) {
1253
+					if ($is_lesson) {
1254
+						$message = sprintf(__('Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade));
1255 1255
 					} else {
1256
-						$message = sprintf( __( 'Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_grade ) );
1256
+						$message = sprintf(__('Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade));
1257 1257
 					}
1258 1258
 				}
1259 1259
 
1260 1260
                 // add next lesson button
1261
-                $nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1262
-                $next_lesson_id = absint( $nav_id_array['next_lesson'] );
1261
+                $nav_id_array = sensei_get_prev_next_lessons($lesson_id);
1262
+                $next_lesson_id = absint($nav_id_array['next_lesson']);
1263 1263
 
1264 1264
                 // Output HTML
1265
-                if ( ( 0 < $next_lesson_id ) ) {
1266
-                    $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1267
-                                . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1265
+                if ((0 < $next_lesson_id)) {
1266
+                    $message .= ' '.'<a class="next-lesson" href="'.esc_url(get_permalink($next_lesson_id))
1267
+                                . '" rel="next"><span class="meta-nav"></span>'.__('Next Lesson', 'woothemes-sensei')
1268 1268
                                 .'</a>';
1269 1269
 
1270 1270
                 }
@@ -1273,33 +1273,33 @@  discard block
 block discarded – undo
1273 1273
             // Lesson/Quiz not complete
1274 1274
 			else {
1275 1275
 				// Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
1276
-				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) {
1276
+				if (isset($user_lesson_status->comment_approved) && 'ungraded' == $user_lesson_status->comment_approved) {
1277 1277
 					$status = 'complete';
1278 1278
 					$box_class = 'info';
1279
-					if( $is_lesson ) {
1280
-						$message = sprintf( __( 'You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . esc_attr( get_the_title( $quiz_id ) ) . '">', '</a>' );
1279
+					if ($is_lesson) {
1280
+						$message = sprintf(__('You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($quiz_id)).'" title="'.esc_attr(get_the_title($quiz_id)).'">', '</a>');
1281 1281
 					} else {
1282
-						$message = sprintf( __( 'You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_passmark ) );
1282
+						$message = sprintf(__('You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark));
1283 1283
 					}
1284 1284
 				}
1285 1285
 				// Lesson status must be "failed"
1286
-				elseif ( isset( $user_lesson_status->comment_approved ) && 'failed' == $user_lesson_status->comment_approved ) {
1286
+				elseif (isset($user_lesson_status->comment_approved) && 'failed' == $user_lesson_status->comment_approved) {
1287 1287
 					$status = 'failed';
1288 1288
 					$box_class = 'alert';
1289
-					if( $is_lesson ) {
1290
-						$message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_passmark ),  Sensei_Utils::round( $quiz_grade ) );
1289
+					if ($is_lesson) {
1290
+						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade));
1291 1291
 					} else {
1292
-						$message = sprintf( __( 'You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_passmark ),  Sensei_Utils::round( $quiz_grade ) );
1292
+						$message = sprintf(__('You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade));
1293 1293
 					}
1294 1294
 				}
1295 1295
 				// Lesson/Quiz requires a pass
1296
-				elseif( $pass_required ) {
1296
+				elseif ($pass_required) {
1297 1297
 					$status = 'not_started';
1298 1298
 					$box_class = 'info';
1299
-					if( $is_lesson ) {
1300
-						$message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_passmark ) );
1299
+					if ($is_lesson) {
1300
+						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark));
1301 1301
 					} else {
1302
-						$message = sprintf( __( 'You require %1$d%% to pass this quiz.', 'woothemes-sensei' ),  Sensei_Utils::round( $quiz_passmark ) );
1302
+						$message = sprintf(__('You require %1$d%% to pass this quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark));
1303 1303
 					}
1304 1304
 				}
1305 1305
 			}
@@ -1307,15 +1307,15 @@  discard block
 block discarded – undo
1307 1307
 		}
1308 1308
 
1309 1309
 		// Legacy filter
1310
-		$message = apply_filters( 'sensei_user_quiz_status_' . $status, $message );
1310
+		$message = apply_filters('sensei_user_quiz_status_'.$status, $message);
1311 1311
 
1312
-		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) {
1313
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1314
-			$extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' .  __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' .  __( 'View the lesson quiz', 'woothemes-sensei' )  . '</a></p>';
1312
+		if ($is_lesson && ! in_array($status, array('login_required', 'not_started_course'))) {
1313
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1314
+			$extra = '<p><a class="button" href="'.esc_url(get_permalink($quiz_id)).'" title="'.__('View the lesson quiz', 'woothemes-sensei').'">'.__('View the lesson quiz', 'woothemes-sensei').'</a></p>';
1315 1315
 		}
1316 1316
 
1317 1317
 		// Filter of all messages
1318
-		return apply_filters( 'sensei_user_quiz_status', array( 'status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra ), $lesson_id, $user_id, $is_lesson );
1318
+		return apply_filters('sensei_user_quiz_status', array('status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra), $lesson_id, $user_id, $is_lesson);
1319 1319
 	}
1320 1320
 
1321 1321
 	/**
@@ -1325,14 +1325,14 @@  discard block
 block discarded – undo
1325 1325
 	 * @param  integer $course_id Course ID
1326 1326
 	 * @return mixed boolean or comment_ID
1327 1327
 	 */
1328
-	public static function user_start_course( $user_id = 0, $course_id = 0 ) {
1328
+	public static function user_start_course($user_id = 0, $course_id = 0) {
1329 1329
 
1330 1330
 		$activity_logged = false;
1331 1331
 
1332
-		if( $user_id && $course_id ) {
1332
+		if ($user_id && $course_id) {
1333 1333
 			// Check if user is already on the Course
1334
-			$activity_logged = Sensei_Utils::user_started_course( $course_id, $user_id );
1335
-			if ( ! $activity_logged ) {
1334
+			$activity_logged = Sensei_Utils::user_started_course($course_id, $user_id);
1335
+			if ( ! $activity_logged) {
1336 1336
 
1337 1337
 				// Add user to course
1338 1338
 				$course_metadata = array(
@@ -1341,11 +1341,11 @@  discard block
 block discarded – undo
1341 1341
 					'complete' => 0,
1342 1342
 				);
1343 1343
 
1344
-				$activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status = 'in-progress', $course_metadata );
1344
+				$activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status = 'in-progress', $course_metadata);
1345 1345
 
1346 1346
 				// Allow further actions
1347
-				if ( $activity_logged ) {
1348
-					do_action( 'sensei_user_course_start', $user_id, $course_id );
1347
+				if ($activity_logged) {
1348
+					do_action('sensei_user_course_start', $user_id, $course_id);
1349 1349
 				}
1350 1350
 			}
1351 1351
 		}
@@ -1361,19 +1361,19 @@  discard block
 block discarded – undo
1361 1361
 	 * @param int $user_id
1362 1362
 	 * @return mixed false or comment_ID
1363 1363
 	 */
1364
-	public static function user_started_course( $course_id = 0, $user_id = 0 ) {
1364
+	public static function user_started_course($course_id = 0, $user_id = 0) {
1365 1365
 
1366
-		if( $course_id ) {
1367
-			if( ! $user_id ) {
1366
+		if ($course_id) {
1367
+			if ( ! $user_id) {
1368 1368
 				$user_id = get_current_user_id();
1369 1369
 			}
1370 1370
 
1371
-            if( ! $user_id > 0 ){
1371
+            if ( ! $user_id > 0) {
1372 1372
                 return false;
1373 1373
             }
1374 1374
 
1375
-			$user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) );
1376
-			if( $user_course_status_id ) {
1375
+			$user_course_status_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID'));
1376
+			if ($user_course_status_id) {
1377 1377
 				return $user_course_status_id;
1378 1378
 			}
1379 1379
 		}
@@ -1388,17 +1388,17 @@  discard block
 block discarded – undo
1388 1388
 	 * @param  integer $user_id   User ID
1389 1389
 	 * @return int
1390 1390
 	 */
1391
-	public static function user_complete_course( $course_id = 0, $user_id = 0 ) {
1391
+	public static function user_complete_course($course_id = 0, $user_id = 0) {
1392 1392
 		global  $wp_version;
1393 1393
 
1394
-		if( $course_id ) {
1395
-			if( ! $user_id ) {
1394
+		if ($course_id) {
1395
+			if ( ! $user_id) {
1396 1396
 				$user_id = get_current_user_id();
1397 1397
 			}
1398 1398
 
1399 1399
 			$course_status = 'in-progress';
1400 1400
 			$course_metadata = array();
1401
-			$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1401
+			$course_completion = Sensei()->settings->settings['course_completion'];
1402 1402
 			$lessons_completed = $total_lessons = 0;
1403 1403
 			$lesson_status_args = array(
1404 1404
 					'user_id' => $user_id,
@@ -1407,8 +1407,8 @@  discard block
 block discarded – undo
1407 1407
 				);
1408 1408
 
1409 1409
 			// Grab all of this Courses' lessons, looping through each...
1410
-			$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
1411
-			$total_lessons = count( $lesson_ids );
1410
+			$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
1411
+			$total_lessons = count($lesson_ids);
1412 1412
 				// ...if course completion not set to 'passed', and all lessons are complete or graded,
1413 1413
 				// ......then all lessons are 'passed'
1414 1414
 				// ...else if course completion is set to 'passed', check if each lesson has questions...
@@ -1421,29 +1421,29 @@  discard block
 block discarded – undo
1421 1421
 			// The below checks if a lesson is fully completed, though maybe should be Utils::user_completed_lesson()
1422 1422
 			$all_lesson_statuses = array();
1423 1423
 			// In WordPress 4.1 get_comments() allows a single query to cover multiple comment_post_IDs
1424
-			if ( version_compare($wp_version, '4.1', '>=') ) {
1424
+			if (version_compare($wp_version, '4.1', '>=')) {
1425 1425
 				$lesson_status_args['post__in'] = $lesson_ids;
1426
-				$all_lesson_statuses = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true );
1426
+				$all_lesson_statuses = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true);
1427 1427
 				// Need to always return an array, even with only 1 item
1428
-				if ( !is_array($all_lesson_statuses) ) {
1429
-					$all_lesson_statuses = array( $all_lesson_statuses );
1428
+				if ( ! is_array($all_lesson_statuses)) {
1429
+					$all_lesson_statuses = array($all_lesson_statuses);
1430 1430
 				}
1431 1431
 			}
1432 1432
 			// ...otherwise check each one
1433 1433
 			else {
1434
-				foreach( $lesson_ids as $lesson_id ) {
1434
+				foreach ($lesson_ids as $lesson_id) {
1435 1435
 					$lesson_status_args['post_id'] = $lesson_id;
1436
-					$each_lesson_status = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true );
1436
+					$each_lesson_status = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true);
1437 1437
 					// Check for valid return before using
1438
-					if ( !empty($each_lesson_status->comment_approved) ) {
1438
+					if ( ! empty($each_lesson_status->comment_approved)) {
1439 1439
 						$all_lesson_statuses[] = $each_lesson_status;
1440 1440
 					}
1441 1441
 				}
1442 1442
 			}
1443
-			foreach( $all_lesson_statuses as $lesson_status ) {
1443
+			foreach ($all_lesson_statuses as $lesson_status) {
1444 1444
 				// If lessons are complete without needing quizzes to be passed
1445
-				if ( 'passed' != $course_completion ) {
1446
-					switch ( $lesson_status->comment_approved ) {
1445
+				if ('passed' != $course_completion) {
1446
+					switch ($lesson_status->comment_approved) {
1447 1447
 						// A user cannot 'complete' a course if a lesson...
1448 1448
 						case 'in-progress': // ...is still in progress
1449 1449
 						case 'ungraded': // ...hasn't yet been graded
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 					}
1456 1456
 				}
1457 1457
 				else {
1458
-					switch ( $lesson_status->comment_approved ) {
1458
+					switch ($lesson_status->comment_approved) {
1459 1459
 						case 'complete': // Lesson has no quiz/questions
1460 1460
 						case 'graded': // Lesson has quiz, but it's not important what the grade was
1461 1461
 						case 'passed': // Lesson has quiz and the user passed
@@ -1469,20 +1469,20 @@  discard block
 block discarded – undo
1469 1469
 					}
1470 1470
 				}
1471 1471
 			} // Each lesson
1472
-			if ( $lessons_completed == $total_lessons ) {
1472
+			if ($lessons_completed == $total_lessons) {
1473 1473
 				$course_status = 'complete';
1474 1474
 			}
1475 1475
 
1476 1476
 			// Update meta data on how many lessons have been completed
1477 1477
 			$course_metadata['complete'] = $lessons_completed;
1478 1478
 			// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1479
-			$course_metadata['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1479
+			$course_metadata['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1480 1480
 
1481
-			$activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status, $course_metadata );
1481
+			$activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status, $course_metadata);
1482 1482
 
1483 1483
 			// Allow further actions
1484
-			if ( 'complete' == $course_status ) {
1485
-				do_action( 'sensei_user_course_end', $user_id, $course_id );
1484
+			if ('complete' == $course_status) {
1485
+				do_action('sensei_user_course_end', $user_id, $course_id);
1486 1486
 			}
1487 1487
 			return $activity_logged;
1488 1488
 		}
@@ -1498,31 +1498,31 @@  discard block
 block discarded – undo
1498 1498
 	 * @param int $user_id
1499 1499
 	 * @return boolean
1500 1500
 	 */
1501
-	public static function user_completed_course( $course , $user_id = 0 ) {
1501
+	public static function user_completed_course($course, $user_id = 0) {
1502 1502
 
1503
-		if( $course ) {
1504
-			if ( is_object( $course ) && is_a( $course,'WP_Comment') ) {
1503
+		if ($course) {
1504
+			if (is_object($course) && is_a($course, 'WP_Comment')) {
1505 1505
 				$user_course_status = $course->comment_approved;
1506 1506
 			}
1507
-			elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) {
1507
+			elseif ( ! is_numeric($course) && ! is_a($course, 'WP_Post')) {
1508 1508
 				$user_course_status = $course;
1509 1509
 			}
1510 1510
 			else {
1511
-				if( ! $user_id ) {
1511
+				if ( ! $user_id) {
1512 1512
 					$user_id = get_current_user_id();
1513 1513
 				}
1514 1514
 
1515
-                if( is_a( $course, 'WP_Post' ) ){
1516
-                    $course =   $course->ID;
1515
+                if (is_a($course, 'WP_Post')) {
1516
+                    $course = $course->ID;
1517 1517
                 }
1518 1518
 
1519
-				$user_course_status = Sensei_Utils::user_course_status( $course , $user_id );
1520
-				if( isset( $user_course_status->comment_approved ) ){
1519
+				$user_course_status = Sensei_Utils::user_course_status($course, $user_id);
1520
+				if (isset($user_course_status->comment_approved)) {
1521 1521
                     $user_course_status = $user_course_status->comment_approved;
1522 1522
                 }
1523 1523
 
1524 1524
 			}
1525
-			if( $user_course_status && 'complete' == $user_course_status ) {
1525
+			if ($user_course_status && 'complete' == $user_course_status) {
1526 1526
 				return true;
1527 1527
 			}
1528 1528
 		}
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 	 * @param int $user_id
1538 1538
 	 * @return mixed false or comment_ID
1539 1539
 	 */
1540
-	public static function user_started_lesson( $lesson_id = 0, $user_id = 0 ) {
1540
+	public static function user_started_lesson($lesson_id = 0, $user_id = 0) {
1541 1541
 
1542
-		if( $lesson_id ) {
1543
-			if( ! $user_id ) {
1542
+		if ($lesson_id) {
1543
+			if ( ! $user_id) {
1544 1544
 				$user_id = get_current_user_id();
1545 1545
 			}
1546 1546
 
@@ -1550,8 +1550,8 @@  discard block
 block discarded – undo
1550 1550
                 'type' => 'sensei_lesson_status',
1551 1551
                 'field' => 'comment_ID' );
1552 1552
 
1553
-			$user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args );
1554
-			if( $user_lesson_status_id ) {
1553
+			$user_lesson_status_id = Sensei_Utils::sensei_get_activity_value($activity_args);
1554
+			if ($user_lesson_status_id) {
1555 1555
 				return $user_lesson_status_id;
1556 1556
 			}
1557 1557
 		}
@@ -1566,29 +1566,29 @@  discard block
 block discarded – undo
1566 1566
 	 * @param int $user_id
1567 1567
 	 * @return boolean
1568 1568
 	 */
1569
-	public static function user_completed_lesson( $lesson = 0, $user_id = 0 ) {
1569
+	public static function user_completed_lesson($lesson = 0, $user_id = 0) {
1570 1570
 
1571
-		if( $lesson ) {
1571
+		if ($lesson) {
1572 1572
 			$lesson_id = 0;
1573
-			if ( is_object( $lesson ) ) {
1573
+			if (is_object($lesson)) {
1574 1574
 				$user_lesson_status = $lesson->comment_approved;
1575 1575
 				$lesson_id = $lesson->comment_post_ID;
1576 1576
 			}
1577
-			elseif ( ! is_numeric( $lesson ) ) {
1577
+			elseif ( ! is_numeric($lesson)) {
1578 1578
 				$user_lesson_status = $lesson;
1579 1579
 			}
1580 1580
 			else {
1581
-				if( ! $user_id ) {
1581
+				if ( ! $user_id) {
1582 1582
 					$user_id = get_current_user_id();
1583 1583
 				}
1584 1584
 
1585 1585
                 // the user is not logged in
1586
-                if( ! $user_id > 0 ){
1586
+                if ( ! $user_id > 0) {
1587 1587
                     return false;
1588 1588
                 }
1589
-				$_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id );
1589
+				$_user_lesson_status = Sensei_Utils::user_lesson_status($lesson, $user_id);
1590 1590
 
1591
-				if ( $_user_lesson_status ) {
1591
+				if ($_user_lesson_status) {
1592 1592
 					$user_lesson_status = $_user_lesson_status->comment_approved;
1593 1593
 				}
1594 1594
 				else {
@@ -1596,12 +1596,12 @@  discard block
 block discarded – undo
1596 1596
 				}
1597 1597
 				$lesson_id = $lesson;
1598 1598
 			}
1599
-			if ( 'in-progress' != $user_lesson_status ) {
1599
+			if ('in-progress' != $user_lesson_status) {
1600 1600
 				// Check for Passed or Completed Setting
1601 1601
 				// Should we be checking for the Course completion setting? Surely that should only affect the Course completion, not bypass each Lesson setting
1602 1602
 //				$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1603 1603
 //				if ( 'passed' == $course_completion ) {
1604
-					switch( $user_lesson_status ) {
1604
+					switch ($user_lesson_status) {
1605 1605
 						case 'complete':
1606 1606
 						case 'graded':
1607 1607
 						case 'passed':
@@ -1610,13 +1610,13 @@  discard block
 block discarded – undo
1610 1610
 
1611 1611
 						case 'failed':
1612 1612
 							// This may be 'completed' depending on...
1613
-							if ( $lesson_id ) {
1613
+							if ($lesson_id) {
1614 1614
 								// Get Quiz ID, this won't be needed once all Quiz meta fields are stored on the Lesson
1615
-								$lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1616
-								if ( $lesson_quiz_id ) {
1615
+								$lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1616
+								if ($lesson_quiz_id) {
1617 1617
 									// ...the quiz pass setting
1618
-									$pass_required = get_post_meta( $lesson_quiz_id, '_pass_required', true );
1619
-									if ( empty($pass_required) ) {
1618
+									$pass_required = get_post_meta($lesson_quiz_id, '_pass_required', true);
1619
+									if (empty($pass_required)) {
1620 1620
 										// We just require the user to have done the quiz, not to have passed
1621 1621
 										return true;
1622 1622
 									}
@@ -1639,15 +1639,15 @@  discard block
 block discarded – undo
1639 1639
 	 * @param int $user_id
1640 1640
 	 * @return object
1641 1641
 	 */
1642
-	public static function user_course_status( $course_id = 0, $user_id = 0 ) {
1642
+	public static function user_course_status($course_id = 0, $user_id = 0) {
1643 1643
 
1644 1644
 
1645
-		if( $course_id ) {
1646
-			if( ! $user_id ) {
1645
+		if ($course_id) {
1646
+			if ( ! $user_id) {
1647 1647
 				$user_id = get_current_user_id();
1648 1648
 			}
1649 1649
 
1650
-			$user_course_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status' ), true );
1650
+			$user_course_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status'), true);
1651 1651
 			return $user_course_status;
1652 1652
 		}
1653 1653
 
@@ -1662,27 +1662,27 @@  discard block
 block discarded – undo
1662 1662
 	 * @param int $user_id
1663 1663
 	 * @return object | bool
1664 1664
 	 */
1665
-	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1665
+	public static function user_lesson_status($lesson_id = 0, $user_id = 0) {
1666 1666
 
1667
-        if( ! $user_id ) {
1667
+        if ( ! $user_id) {
1668 1668
             $user_id = get_current_user_id();
1669 1669
         }
1670 1670
 
1671
-		if( $lesson_id > 0 && $user_id > 0 ) {
1671
+		if ($lesson_id > 0 && $user_id > 0) {
1672 1672
 
1673
-			$user_lesson_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status' ), true );
1673
+			$user_lesson_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status'), true);
1674 1674
 			return $user_lesson_status;
1675 1675
 		}
1676 1676
 
1677 1677
 		return false;
1678 1678
 	}
1679 1679
 
1680
-	public static function is_preview_lesson( $lesson_id ) {
1680
+	public static function is_preview_lesson($lesson_id) {
1681 1681
 		$is_preview = false;
1682 1682
 
1683
-		if( 'lesson' == get_post_type( $lesson_id ) ) {
1684
-			$lesson_preview = get_post_meta( $lesson_id, '_lesson_preview', true );
1685
-			if ( isset( $lesson_preview ) && '' != $lesson_preview ) {
1683
+		if ('lesson' == get_post_type($lesson_id)) {
1684
+			$lesson_preview = get_post_meta($lesson_id, '_lesson_preview', true);
1685
+			if (isset($lesson_preview) && '' != $lesson_preview) {
1686 1686
 				$is_preview = true;
1687 1687
 			}
1688 1688
 		}
@@ -1690,22 +1690,22 @@  discard block
 block discarded – undo
1690 1690
 		return $is_preview;
1691 1691
 	}
1692 1692
 
1693
-	public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) {
1693
+	public static function user_passed_quiz($quiz_id = 0, $user_id = 0) {
1694 1694
 
1695
-		if( ! $quiz_id  ) return false;
1695
+		if ( ! $quiz_id) return false;
1696 1696
 
1697
-		if( ! $user_id ) {
1697
+		if ( ! $user_id) {
1698 1698
 			$user_id = get_current_user_id();
1699 1699
 		}
1700
-		$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1700
+		$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1701 1701
 
1702 1702
 		// Quiz Grade
1703
-		$lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1704
-		$quiz_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
1703
+		$lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1704
+		$quiz_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
1705 1705
 
1706 1706
 		// Check if Grade is greater than or equal to pass percentage
1707
-		$quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
1708
-		if ( $quiz_passmark <= intval( $quiz_grade ) ) {
1707
+		$quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
1708
+		if ($quiz_passmark <= intval($quiz_grade)) {
1709 1709
 			return true;
1710 1710
 		}
1711 1711
 
@@ -1725,9 +1725,9 @@  discard block
 block discarded – undo
1725 1725
      *
1726 1726
 	 * @return mixed false or comment_ID
1727 1727
 	 */
1728
-	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
1728
+	public static function update_lesson_status($user_id, $lesson_id, $status = 'in-progress', $metadata = array()) {
1729 1729
 		$comment_id = false;
1730
-		if ( !empty($status) ) {
1730
+		if ( ! empty($status)) {
1731 1731
 			$args = array(
1732 1732
 					'user_id'   => $user_id,
1733 1733
 					'post_id'   => $lesson_id,
@@ -1736,18 +1736,18 @@  discard block
 block discarded – undo
1736 1736
 					'action'    => 'update', // Update the existing status...
1737 1737
 					'keep_time' => true, // ...but don't change the existing timestamp
1738 1738
 				);
1739
-			if( 'in-progress' == $status ) {
1740
-				unset( $args['keep_time'] ); // Keep updating what's happened
1739
+			if ('in-progress' == $status) {
1740
+				unset($args['keep_time']); // Keep updating what's happened
1741 1741
 			}
1742 1742
 
1743
-			$comment_id = Sensei_Utils::sensei_log_activity( $args );
1744
-			if ( $comment_id && !empty($metadata) ) {
1745
-				foreach( $metadata as $key => $value ) {
1746
-					update_comment_meta( $comment_id, $key, $value );
1743
+			$comment_id = Sensei_Utils::sensei_log_activity($args);
1744
+			if ($comment_id && ! empty($metadata)) {
1745
+				foreach ($metadata as $key => $value) {
1746
+					update_comment_meta($comment_id, $key, $value);
1747 1747
 				}
1748 1748
 			}
1749 1749
 
1750
-			do_action( 'sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id );
1750
+			do_action('sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id);
1751 1751
 		}
1752 1752
 		return $comment_id;
1753 1753
 	}
@@ -1763,9 +1763,9 @@  discard block
 block discarded – undo
1763 1763
 	 * @param array $metadata
1764 1764
 	 * @return mixed false or comment_ID
1765 1765
 	 */
1766
-	public static function update_course_status( $user_id, $course_id, $status = 'in-progress', $metadata = array() ) {
1766
+	public static function update_course_status($user_id, $course_id, $status = 'in-progress', $metadata = array()) {
1767 1767
 		$comment_id = false;
1768
-		if ( !empty($status) ) {
1768
+		if ( ! empty($status)) {
1769 1769
 			$args = array(
1770 1770
 					'user_id'   => $user_id,
1771 1771
 					'post_id'   => $course_id,
@@ -1774,17 +1774,17 @@  discard block
 block discarded – undo
1774 1774
 					'action'    => 'update', // Update the existing status...
1775 1775
 					'keep_time' => true, // ...but don't change the existing timestamp
1776 1776
 				);
1777
-			if( 'in-progress' == $status ) {
1778
-				unset( $args['keep_time'] ); // Keep updating what's happened
1777
+			if ('in-progress' == $status) {
1778
+				unset($args['keep_time']); // Keep updating what's happened
1779 1779
 			}
1780 1780
 
1781
-			$comment_id = Sensei_Utils::sensei_log_activity( $args );
1782
-			if ( $comment_id && !empty($metadata) ) {
1783
-				foreach( $metadata as $key => $value ) {
1784
-					update_comment_meta( $comment_id, $key, $value );
1781
+			$comment_id = Sensei_Utils::sensei_log_activity($args);
1782
+			if ($comment_id && ! empty($metadata)) {
1783
+				foreach ($metadata as $key => $value) {
1784
+					update_comment_meta($comment_id, $key, $value);
1785 1785
 				}
1786 1786
 			}
1787
-			do_action( 'sensei_course_status_updated', $status, $user_id, $course_id, $comment_id );
1787
+			do_action('sensei_course_status_updated', $status, $user_id, $course_id, $comment_id);
1788 1788
 		}
1789 1789
 		return $comment_id;
1790 1790
 	}
@@ -1796,9 +1796,9 @@  discard block
 block discarded – undo
1796 1796
 	 * @param  array $pieces (default: array())
1797 1797
 	 * @return array
1798 1798
 	 */
1799
-	public static function single_comment_filter( $pieces ) {
1800
-		unset( $pieces['orderby'] );
1801
-		unset( $pieces['order'] );
1799
+	public static function single_comment_filter($pieces) {
1800
+		unset($pieces['orderby']);
1801
+		unset($pieces['order']);
1802 1802
 
1803 1803
 		return $pieces;
1804 1804
 	}
@@ -1810,9 +1810,9 @@  discard block
 block discarded – undo
1810 1810
 	 * @param  array $pieces (default: array())
1811 1811
 	 * @return array
1812 1812
 	 */
1813
-	public static function comment_any_status_filter( $pieces ) {
1813
+	public static function comment_any_status_filter($pieces) {
1814 1814
 
1815
-		$pieces['where'] = str_replace( array( "( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND" ), '', $pieces['where'] );
1815
+		$pieces['where'] = str_replace(array("( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND"), '', $pieces['where']);
1816 1816
 
1817 1817
 		return $pieces;
1818 1818
 	}
@@ -1824,12 +1824,12 @@  discard block
 block discarded – undo
1824 1824
 	 * @param  array $pieces (default: array())
1825 1825
 	 * @return array
1826 1826
 	 */
1827
-	public static function comment_multiple_status_filter( $pieces ) {
1827
+	public static function comment_multiple_status_filter($pieces) {
1828 1828
 
1829
-		preg_match( "/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder );
1830
-		if ( !empty($placeholder[1]) ) {
1831
-			$statuses = explode( ',', $placeholder[1] );
1832
-			$pieces['where'] = str_replace( "comment_approved = '" . $placeholder[1] . "'", "comment_approved IN ('". implode( "', '", $statuses ) . "')", $pieces['where'] );
1829
+		preg_match("/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder);
1830
+		if ( ! empty($placeholder[1])) {
1831
+			$statuses = explode(',', $placeholder[1]);
1832
+			$pieces['where'] = str_replace("comment_approved = '".$placeholder[1]."'", "comment_approved IN ('".implode("', '", $statuses)."')", $pieces['where']);
1833 1833
 		}
1834 1834
 
1835 1835
 		return $pieces;
@@ -1841,12 +1841,12 @@  discard block
 block discarded – undo
1841 1841
      * @param array $pieces
1842 1842
 	 * @return array $pieces
1843 1843
 	 */
1844
-	public static function comment_total_sum_meta_value_filter( $pieces ) {
1844
+	public static function comment_total_sum_meta_value_filter($pieces) {
1845 1845
 		global $wpdb, $wp_version;
1846 1846
 
1847 1847
 		$pieces['fields'] = " COUNT(*) AS total, SUM($wpdb->commentmeta.meta_value) AS meta_sum ";
1848
-		unset( $pieces['groupby'] );
1849
-		if ( version_compare($wp_version, '4.1', '>=') ) {
1848
+		unset($pieces['groupby']);
1849
+		if (version_compare($wp_version, '4.1', '>=')) {
1850 1850
 			$args['order'] = false;
1851 1851
 			$args['orderby'] = false;
1852 1852
 		}
@@ -1861,12 +1861,12 @@  discard block
 block discarded – undo
1861 1861
 	 * @param  array $pieces (default: array())
1862 1862
 	 * @return array
1863 1863
 	 */
1864
-	public static function get_posts_count_only_filter( $pieces ) {
1864
+	public static function get_posts_count_only_filter($pieces) {
1865 1865
 		global $wp_version;
1866 1866
 
1867 1867
 		$pieces['fields'] = " COUNT(*) AS total ";
1868
-		unset( $pieces['groupby'] );
1869
-		if ( version_compare($wp_version, '4.1', '>=') ) {
1868
+		unset($pieces['groupby']);
1869
+		if (version_compare($wp_version, '4.1', '>=')) {
1870 1870
 			$args['order'] = false;
1871 1871
 			$args['orderby'] = false;
1872 1872
 		}
@@ -1885,9 +1885,9 @@  discard block
 block discarded – undo
1885 1885
      *
1886 1886
      * @return bool $success
1887 1887
      */
1888
-    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1888
+    public static function add_user_data($data_key, $post_id, $value = '', $user_id = 0) {
1889 1889
 
1890
-        return self::update_user_data( $data_key, $post_id, $value , $user_id );
1890
+        return self::update_user_data($data_key, $post_id, $value, $user_id);
1891 1891
 
1892 1892
     }// end add_user_data
1893 1893
 
@@ -1906,18 +1906,18 @@  discard block
 block discarded – undo
1906 1906
      *
1907 1907
      * @return bool $success
1908 1908
      */
1909
-    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1909
+    public static function update_user_data($data_key, $post_id, $value = '', $user_id = 0) {
1910 1910
 
1911
-        if( ! ( $user_id > 0 ) ){
1911
+        if ( ! ($user_id > 0)) {
1912 1912
             $user_id = get_current_user_id();
1913 1913
         }
1914 1914
 
1915
-        $supported_post_types = array( 'course', 'lesson' );
1916
-        $post_type = get_post_type( $post_id );
1917
-        if( empty( $post_id ) || empty( $data_key )
1918
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1919
-            || !get_userdata( $user_id )
1920
-            || ! in_array( $post_type, $supported_post_types )  ){
1915
+        $supported_post_types = array('course', 'lesson');
1916
+        $post_type = get_post_type($post_id);
1917
+        if (empty($post_id) || empty($data_key)
1918
+            || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
1919
+            || ! get_userdata($user_id)
1920
+            || ! in_array($post_type, $supported_post_types)) {
1921 1921
 
1922 1922
             return false;
1923 1923
         }
@@ -1925,20 +1925,20 @@  discard block
 block discarded – undo
1925 1925
         // check if there and existing Sensei status on this post type if not create it
1926 1926
         // and get the  activity ID
1927 1927
         $status_function = 'user_'.$post_type.'_status';
1928
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1929
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1928
+        $sensei_user_status = self::$status_function($post_id, $user_id);
1929
+        if ( ! isset($sensei_user_status->comment_ID)) {
1930 1930
 
1931 1931
             $start_function = 'user_start_'.$post_type;
1932
-            $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1932
+            $sensei_user_activity_id = self::$start_function($user_id, $post_id);
1933 1933
 
1934
-        }else{
1934
+        } else {
1935 1935
 
1936 1936
             $sensei_user_activity_id = $sensei_user_status->comment_ID;
1937 1937
 
1938 1938
         }
1939 1939
 
1940 1940
         // store the data
1941
-        $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1941
+        $success = update_comment_meta($sensei_user_activity_id, $data_key, $value);
1942 1942
 
1943 1943
        return $success;
1944 1944
 
@@ -1957,20 +1957,20 @@  discard block
 block discarded – undo
1957 1957
      *
1958 1958
      * @return mixed $user_data_value
1959 1959
      */
1960
-    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1960
+    public static function get_user_data($data_key, $post_id, $user_id = 0) {
1961 1961
 
1962 1962
         $user_data_value = true;
1963 1963
 
1964
-        if( ! ( $user_id > 0 ) ){
1964
+        if ( ! ($user_id > 0)) {
1965 1965
             $user_id = get_current_user_id();
1966 1966
         }
1967 1967
 
1968
-        $supported_post_types = array( 'course', 'lesson' );
1969
-        $post_type = get_post_type( $post_id );
1970
-        if( empty( $post_id ) || empty( $data_key )
1971
-            || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1972
-            || ! get_userdata( $user_id )
1973
-            || !in_array( $post_type, $supported_post_types )  ){
1968
+        $supported_post_types = array('course', 'lesson');
1969
+        $post_type = get_post_type($post_id);
1970
+        if (empty($post_id) || empty($data_key)
1971
+            || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
1972
+            || ! get_userdata($user_id)
1973
+            || ! in_array($post_type, $supported_post_types)) {
1974 1974
 
1975 1975
             return false;
1976 1976
         }
@@ -1978,13 +1978,13 @@  discard block
 block discarded – undo
1978 1978
         // check if there and existing Sensei status on this post type if not create it
1979 1979
         // and get the  activity ID
1980 1980
         $status_function = 'user_'.$post_type.'_status';
1981
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1982
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1981
+        $sensei_user_status = self::$status_function($post_id, $user_id);
1982
+        if ( ! isset($sensei_user_status->comment_ID)) {
1983 1983
             return false;
1984 1984
         }
1985 1985
 
1986 1986
         $sensei_user_activity_id = $sensei_user_status->comment_ID;
1987
-        $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1987
+        $user_data_value = get_comment_meta($sensei_user_activity_id, $data_key, true);
1988 1988
 
1989 1989
         return $user_data_value;
1990 1990
 
@@ -1999,19 +1999,19 @@  discard block
 block discarded – undo
1999 1999
      *
2000 2000
      * @return bool $deleted
2001 2001
      */
2002
-    public static function delete_user_data( $data_key, $post_id , $user_id ){
2002
+    public static function delete_user_data($data_key, $post_id, $user_id) {
2003 2003
         $deleted = true;
2004 2004
 
2005
-        if( ! ( $user_id > 0 ) ){
2005
+        if ( ! ($user_id > 0)) {
2006 2006
             $user_id = get_current_user_id();
2007 2007
         }
2008 2008
 
2009
-        $supported_post_types = array( 'course', 'lesson' );
2010
-        $post_type = get_post_type( $post_id );
2011
-        if( empty( $post_id ) || empty( $data_key )
2012
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2013
-            || ! get_userdata( $user_id )
2014
-            || !in_array( $post_type, $supported_post_types )  ){
2009
+        $supported_post_types = array('course', 'lesson');
2010
+        $post_type = get_post_type($post_id);
2011
+        if (empty($post_id) || empty($data_key)
2012
+            || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
2013
+            || ! get_userdata($user_id)
2014
+            || ! in_array($post_type, $supported_post_types)) {
2015 2015
 
2016 2016
             return false;
2017 2017
         }
@@ -2019,13 +2019,13 @@  discard block
 block discarded – undo
2019 2019
         // check if there and existing Sensei status on this post type if not create it
2020 2020
         // and get the  activity ID
2021 2021
         $status_function = 'user_'.$post_type.'_status';
2022
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2023
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2022
+        $sensei_user_status = self::$status_function($post_id, $user_id);
2023
+        if ( ! isset($sensei_user_status->comment_ID)) {
2024 2024
             return false;
2025 2025
         }
2026 2026
 
2027 2027
         $sensei_user_activity_id = $sensei_user_status->comment_ID;
2028
-        $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2028
+        $deleted = delete_comment_meta($sensei_user_activity_id, $data_key);
2029 2029
 
2030 2030
         return $deleted;
2031 2031
 
@@ -2050,62 +2050,62 @@  discard block
 block discarded – undo
2050 2050
      *
2051 2051
      * @return string $drop_down_element
2052 2052
      */
2053
-    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2053
+    public static function generate_drop_down($selected_value, $options = array(), $attributes = array(), $enable_none_option = true) {
2054 2054
 
2055 2055
         $drop_down_element = '';
2056 2056
 
2057 2057
         // setup the basic attributes
2058
-        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2058
+        if ( ! isset($attributes['name']) || empty($attributes['name'])) {
2059 2059
 
2060 2060
             $attributes['name'] = 'sensei-options';
2061 2061
 
2062 2062
         }
2063 2063
 
2064
-        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2064
+        if ( ! isset($attributes['id']) || empty($attributes['id'])) {
2065 2065
 
2066 2066
             $attributes['id'] = 'sensei-options';
2067 2067
 
2068 2068
         }
2069 2069
 
2070
-        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2070
+        if ( ! isset($attributes['class']) || empty($attributes['class'])) {
2071 2071
 
2072
-            $attributes['class'] ='chosen_select widefat';
2072
+            $attributes['class'] = 'chosen_select widefat';
2073 2073
 
2074 2074
         }
2075 2075
 
2076 2076
         // create element attributes
2077 2077
         $combined_attributes = '';
2078
-        foreach( $attributes as $attribute => $value ){
2078
+        foreach ($attributes as $attribute => $value) {
2079 2079
 
2080
-            $combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2080
+            $combined_attributes .= $attribute.'="'.$value.'"'.' ';
2081 2081
 
2082 2082
         }// end for each
2083 2083
 
2084 2084
 
2085 2085
         // create the select element
2086
-        $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2086
+        $drop_down_element .= '<select '.$combined_attributes.' >'."\n";
2087 2087
 
2088 2088
         // show the none option if the client requested
2089
-        if( $enable_none_option ) {
2090
-            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2089
+        if ($enable_none_option) {
2090
+            $drop_down_element .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
2091 2091
         }
2092 2092
 
2093
-        if ( count( $options ) > 0 ) {
2093
+        if (count($options) > 0) {
2094 2094
 
2095
-            foreach ($options as $value => $option ){
2095
+            foreach ($options as $value => $option) {
2096 2096
 
2097 2097
                 $element = '';
2098
-                $element.= '<option value="' . esc_attr( $value ) . '"';
2099
-                $element .= selected( $value, $selected_value, false ) . '>';
2100
-                $element .= esc_html(  $option ) . '</option>' . "\n";
2098
+                $element .= '<option value="'.esc_attr($value).'"';
2099
+                $element .= selected($value, $selected_value, false).'>';
2100
+                $element .= esc_html($option).'</option>'."\n";
2101 2101
 
2102 2102
                 // add the element to the select html
2103
-                $drop_down_element.= $element;
2103
+                $drop_down_element .= $element;
2104 2104
             } // End For Loop
2105 2105
 
2106 2106
         } // End If Statement
2107 2107
 
2108
-        $drop_down_element .= '</select>' . "\n";
2108
+        $drop_down_element .= '</select>'."\n";
2109 2109
 
2110 2110
         return $drop_down_element;
2111 2111
 
@@ -2125,14 +2125,14 @@  discard block
 block discarded – undo
2125 2125
      *
2126 2126
      * @return double $val
2127 2127
      */
2128
-    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2128
+    public static function round($val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '') {
2129 2129
 
2130 2130
         /**å
2131 2131
          * Change the precision for the Sensei_Utils::round function.
2132 2132
          * the precision given will be passed into the php round function
2133 2133
          * @since 1.8.5
2134 2134
          */
2135
-        $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2135
+        $precision = apply_filters('sensei_round_precision', $precision, $val, $context, $mode);
2136 2136
 
2137 2137
         /**
2138 2138
          * Change the mode for the Sensei_Utils::round function.
@@ -2142,15 +2142,15 @@  discard block
 block discarded – undo
2142 2142
          *
2143 2143
          * @since 1.8.5
2144 2144
          */
2145
-        $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2145
+        $mode = apply_filters('sensei_round_mode', $mode, $val, $context, $precision);
2146 2146
 
2147
-        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2147
+        if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
2148 2148
 
2149
-            return round( $val, $precision, $mode );
2149
+            return round($val, $precision, $mode);
2150 2150
 
2151
-        }else{
2151
+        } else {
2152 2152
 
2153
-            return round( $val, $precision );
2153
+            return round($val, $precision);
2154 2154
 
2155 2155
         }
2156 2156
 
@@ -2162,15 +2162,15 @@  discard block
 block discarded – undo
2162 2162
      * @since 1.9.0
2163 2163
      * @return string $url
2164 2164
      */
2165
-    public static function get_current_url(){
2165
+    public static function get_current_url() {
2166 2166
 
2167 2167
         global $wp;
2168
-        $current_url = trailingslashit( home_url( $wp->request ) );
2169
-        if ( isset( $_GET ) ) {
2168
+        $current_url = trailingslashit(home_url($wp->request));
2169
+        if (isset($_GET)) {
2170 2170
 
2171
-            foreach ($_GET as $param => $val ) {
2171
+            foreach ($_GET as $param => $val) {
2172 2172
 
2173
-                $current_url = add_query_arg( $param, $val , $current_url );
2173
+                $current_url = add_query_arg($param, $val, $current_url);
2174 2174
 
2175 2175
             }
2176 2176
         }
@@ -2200,27 +2200,27 @@  discard block
 block discarded – undo
2200 2200
      * @param array $array_b
2201 2201
      * @return array $merged_array
2202 2202
      */
2203
-    public static function array_zip_merge( $array_a, $array_b ){
2203
+    public static function array_zip_merge($array_a, $array_b) {
2204 2204
 
2205
-        if( ! is_array( $array_a ) || ! is_array( $array_b )  ){
2205
+        if ( ! is_array($array_a) || ! is_array($array_b)) {
2206 2206
             trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2207 2207
         }
2208 2208
 
2209 2209
         $merged_array = array();
2210
-        $total_elements = count( $array_a )  + count( $array_b );
2210
+        $total_elements = count($array_a) + count($array_b);
2211 2211
 
2212 2212
         // Zip arrays
2213
-        for ( $i = 0; $i < $total_elements; $i++) {
2213
+        for ($i = 0; $i < $total_elements; $i++) {
2214 2214
 
2215 2215
             // if has an element at current index push a on top
2216
-            if( isset( $array_a[ $i ] ) ){
2217
-                $merged_array[] = $array_a[ $i ]  ;
2216
+            if (isset($array_a[$i])) {
2217
+                $merged_array[] = $array_a[$i];
2218 2218
             }
2219 2219
 
2220 2220
             // next if $array_b has an element at current index push a on top of the element
2221 2221
             // from a if there was one, if not the element before that.
2222
-            if( isset( $array_b[ $i ] ) ){
2223
-                $merged_array[] = $array_b[ $i ]  ;
2222
+            if (isset($array_b[$i])) {
2223
+                $merged_array[] = $array_b[$i];
2224 2224
             }
2225 2225
 
2226 2226
         }
@@ -2235,4 +2235,4 @@  discard block
 block discarded – undo
2235 2235
  * @ignore only for backward compatibility
2236 2236
  * @since 1.9.0
2237 2237
  */
2238
-class WooThemes_Sensei_Utils extends Sensei_Utils{}
2239 2238
\ No newline at end of file
2239
+class WooThemes_Sensei_Utils extends Sensei_Utils {}
2240 2240
\ No newline at end of file
Please login to merge, or discard this patch.
Doc Comments   +20 added lines, -17 removed lines patch added patch discarded remove patch
@@ -463,6 +463,9 @@  discard block
 block discarded – undo
463 463
 
464 464
 	} // End sensei_save_quiz_answers()
465 465
 
466
+	/**
467
+	 * @return string
468
+	 */
466 469
 	public static function upload_file( $file = array() ) {
467 470
 
468 471
 		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
@@ -635,7 +638,7 @@  discard block
 block discarded – undo
635 638
      * @param integer $lesson_id
636 639
      * @param bool $complete
637 640
      *
638
-     * @return mixed boolean or comment_ID
641
+     * @return boolean|string boolean or comment_ID
639 642
      */
640 643
     public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
641 644
 
@@ -654,7 +657,7 @@  discard block
 block discarded – undo
654 657
 	 * @param int| string $user_id default 0
655 658
      * @param bool $complete default false
656 659
      *
657
-     * @return mixed boolean or comment_ID
660
+     * @return boolean|string boolean or comment_ID
658 661
 	 */
659 662
 	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
660 663
 
@@ -833,7 +836,7 @@  discard block
 block discarded – undo
833 836
 	/**
834 837
 	 * Returns the user_grade for a specific question and user, or sensei_user_answer entry
835 838
 	 *
836
-	 * @param mixed $question
839
+	 * @param integer $question
837 840
 	 * @param int $user_id
838 841
 	 * @return string
839 842
 	 */
@@ -861,7 +864,7 @@  discard block
 block discarded – undo
861 864
 	 * Returns the answer_notes for a specific question and user, or sensei_user_answer entry
862 865
 	 *
863 866
      * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
864
-	 * @param mixed $question
867
+	 * @param integer $question
865 868
 	 * @param int $user_id
866 869
 	 * @return string
867 870
 	 */
@@ -974,7 +977,7 @@  discard block
 block discarded – undo
974 977
 	 * sort_array_by_key sorts array by key
975 978
 	 * @since  1.3.0
976 979
 	 * @param  array $array by ref
977
-	 * @param  $key string column name in array
980
+	 * @param  string $key string column name in array
978 981
 	 * @return void
979 982
 	 */
980 983
 	public static function sort_array_by_key( $array, $key ) {
@@ -1021,7 +1024,7 @@  discard block
 block discarded – undo
1021 1024
 	/**
1022 1025
 	 * Get pass mark for course
1023 1026
 	 * @param  integer $course_id ID of course
1024
-	 * @return integer            Pass mark for course
1027
+	 * @return double            Pass mark for course
1025 1028
 	 */
1026 1029
 	public static function sensei_course_pass_grade( $course_id = 0 ) {
1027 1030
 
@@ -1062,7 +1065,7 @@  discard block
 block discarded – undo
1062 1065
 	 * Get user total grade for course
1063 1066
 	 * @param  integer $course_id ID of course
1064 1067
 	 * @param  integer $user_id   ID of user
1065
-	 * @return integer            User's total grade
1068
+	 * @return double            User's total grade
1066 1069
 	 */
1067 1070
 	public static function sensei_course_user_grade( $course_id = 0, $user_id = 0 ) {
1068 1071
 
@@ -1322,7 +1325,7 @@  discard block
 block discarded – undo
1322 1325
 	 * @since  1.4.8
1323 1326
 	 * @param  integer $user_id   User ID
1324 1327
 	 * @param  integer $course_id Course ID
1325
-	 * @return mixed boolean or comment_ID
1328
+	 * @return string|boolean boolean or comment_ID
1326 1329
 	 */
1327 1330
 	public static function user_start_course( $user_id = 0, $course_id = 0 ) {
1328 1331
 
@@ -1358,7 +1361,7 @@  discard block
 block discarded – undo
1358 1361
 	 * @since  1.7.0
1359 1362
 	 * @param int $course_id
1360 1363
 	 * @param int $user_id
1361
-	 * @return mixed false or comment_ID
1364
+	 * @return false|string false or comment_ID
1362 1365
 	 */
1363 1366
 	public static function user_started_course( $course_id = 0, $user_id = 0 ) {
1364 1367
 
@@ -1385,7 +1388,7 @@  discard block
 block discarded – undo
1385 1388
 	 * @since  1.7.0
1386 1389
 	 * @param  integer $course_id Course ID
1387 1390
 	 * @param  integer $user_id   User ID
1388
-	 * @return int
1391
+	 * @return boolean
1389 1392
 	 */
1390 1393
 	public static function user_complete_course( $course_id = 0, $user_id = 0 ) {
1391 1394
 		global  $wp_version;
@@ -1534,7 +1537,7 @@  discard block
 block discarded – undo
1534 1537
 	 * @since  1.7.0
1535 1538
 	 * @param int $lesson_id
1536 1539
 	 * @param int $user_id
1537
-	 * @return mixed false or comment_ID
1540
+	 * @return string|false false or comment_ID
1538 1541
 	 */
1539 1542
 	public static function user_started_lesson( $lesson_id = 0, $user_id = 0 ) {
1540 1543
 
@@ -1561,7 +1564,7 @@  discard block
 block discarded – undo
1561 1564
 	 * Check if a user has completed a lesson or not
1562 1565
 	 *
1563 1566
      * @uses  Sensei()
1564
-	 * @param mixed $lesson lesson_id or sensei_lesson_status entry
1567
+	 * @param integer $lesson lesson_id or sensei_lesson_status entry
1565 1568
 	 * @param int $user_id
1566 1569
 	 * @return boolean
1567 1570
 	 */
@@ -1659,7 +1662,7 @@  discard block
 block discarded – undo
1659 1662
 	 * @since 1.7.0
1660 1663
 	 * @param int $lesson_id
1661 1664
 	 * @param int $user_id
1662
-	 * @return object | bool
1665
+	 * @return integer | bool
1663 1666
 	 */
1664 1667
 	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1665 1668
 
@@ -1718,11 +1721,11 @@  discard block
 block discarded – undo
1718 1721
 	 * @since  1.7.0
1719 1722
      *
1720 1723
 	 * @param int|string $user_id
1721
-	 * @param int|string $lesson_id
1724
+	 * @param integer $lesson_id
1722 1725
 	 * @param string $status
1723 1726
 	 * @param array $metadata
1724 1727
      *
1725
-	 * @return mixed false or comment_ID
1728
+	 * @return boolean false or comment_ID
1726 1729
 	 */
1727 1730
 	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
1728 1731
 		$comment_id = false;
@@ -1760,7 +1763,7 @@  discard block
 block discarded – undo
1760 1763
 	 * @param int $course_id
1761 1764
 	 * @param string $status
1762 1765
 	 * @param array $metadata
1763
-	 * @return mixed false or comment_ID
1766
+	 * @return boolean false or comment_ID
1764 1767
 	 */
1765 1768
 	public static function update_course_status( $user_id, $course_id, $status = 'in-progress', $metadata = array() ) {
1766 1769
 		$comment_id = false;
@@ -1950,7 +1953,7 @@  discard block
 block discarded – undo
1950 1953
      *
1951 1954
      * @since 1.7.4
1952 1955
      *
1953
-     * @param $data_key
1956
+     * @param string $data_key
1954 1957
      * @param $post_id
1955 1958
      * @param int $user_id
1956 1959
      *
Please login to merge, or discard this patch.
includes/template-functions.php 4 patches
Braces   +13 added lines, -8 removed lines patch added patch discarded remove patch
@@ -181,7 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @return void
182 182
 	 */
183 183
 	function sensei_recent_comments_widget_filter( $widget_args = array() ) {
184
-		if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' );
184
+		if ( ! isset( $widget_args['post_type'] ) ) {
185
+			$widget_args['post_type'] = array( 'post', 'page' );
186
+		}
185 187
 		return $widget_args;
186 188
 	} // End sensei_recent_comments_widget_filter()
187 189
 	add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 );
@@ -196,8 +198,9 @@  discard block
 block discarded – undo
196 198
 	function sensei_course_archive_filter( $query ) {
197 199
 
198 200
 
199
-		if ( ! $query->is_main_query() )
200
-        	return;
201
+		if ( ! $query->is_main_query() ) {
202
+		        	return;
203
+		}
201 204
 
202 205
 		// Apply Filter only if on frontend and when course archive is running
203 206
 		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
@@ -412,7 +415,7 @@  discard block
 block discarded – undo
412 415
 
413 416
 		return false;
414 417
 
415
-	}else{
418
+	} else{
416 419
 
417 420
 		return true;
418 421
 
@@ -446,7 +449,7 @@  discard block
 block discarded – undo
446 449
 
447 450
 			$wp_query = $modules_query;
448 451
 
449
-		}else{
452
+		} else{
450 453
 
451 454
 			wp_reset_query();
452 455
 
@@ -478,7 +481,7 @@  discard block
 block discarded – undo
478 481
 
479 482
 		return have_posts();
480 483
 
481
-	}else{
484
+	} else{
482 485
 
483 486
         // if the loop has not been initiated check the first module has lessons
484 487
         if( -1 == $sensei_modules_loop[ 'current' ]  ){
@@ -622,7 +625,7 @@  discard block
 block discarded – undo
622 625
 
623 626
         return true;
624 627
 
625
-    }else{
628
+    } else{
626 629
 
627 630
         return false;
628 631
 
@@ -865,7 +868,9 @@  discard block
 block discarded – undo
865 868
  */
866 869
 function get_sensei_header(){
867 870
 
868
-    if ( ! defined( 'ABSPATH' ) ) exit;
871
+    if ( ! defined( 'ABSPATH' ) ) {
872
+    	exit;
873
+    }
869 874
 
870 875
     get_header();
871 876
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 * sensei_check_if_product_is_in_cart function.
144 144
 	 *
145 145
 	 * @deprecated since 1.9.0
146
-	 * @param int $wc_post_id (default: 0)
146
+	 * @param int $wc_product_id (default: 0)
147 147
 	 * @return bool
148 148
 	 */
149 149
 	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) {
Please login to merge, or discard this patch.
Indentation   +320 added lines, -321 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 	 * 	Output tags.
6 6
 	 ***************************************************************************************************/
7 7
 
8
-    /**
9
-     * sensei_course_archive_next_link function.
10
-     *
11
-     * @access public
12
-     * @param string $type (default: 'newcourses')
13
-     * @return void
14
-     */
15
-    function sensei_course_archive_next_link( $type = 'newcourses' ) {
8
+	/**
9
+	 * sensei_course_archive_next_link function.
10
+	 *
11
+	 * @access public
12
+	 * @param string $type (default: 'newcourses')
13
+	 * @return void
14
+	 */
15
+	function sensei_course_archive_next_link( $type = 'newcourses' ) {
16 16
 
17
-        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
17
+		_deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
18 18
 
19
-    } // End sensei_course_archive_next_link()
19
+	} // End sensei_course_archive_next_link()
20 20
 
21 21
 	 /**
22 22
 	  * course_single_lessons function.
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 	  */
27 27
 	 function course_single_lessons() {
28 28
 
29
-         // load backwards compatible template name if it exists in the users theme
30
-         $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
-         if( $located_template ){
29
+		 // load backwards compatible template name if it exists in the users theme
30
+		 $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
+		 if( $located_template ){
32 32
 
33
-             Sensei_Templates::get_template( 'single-course/course-lessons.php' );
34
-             return;
33
+			 Sensei_Templates::get_template( 'single-course/course-lessons.php' );
34
+			 return;
35 35
 
36
-        }
36
+		}
37 37
 
38 38
 		Sensei_Templates::get_template( 'single-course/lessons.php' );
39 39
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	  */
49 49
 	 function lesson_single_meta() {
50 50
 
51
-         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
52
-         sensei_the_single_lesson_meta();
51
+		 _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
52
+		 sensei_the_single_lesson_meta();
53 53
 
54 54
 	 } // End lesson_single_meta()
55 55
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	  * @access public
61 61
 	  * @param bool $return (default: false)
62 62
 	  * @return void
63
-      * @deprecated since 1.9.0
63
+	  * @deprecated since 1.9.0
64 64
 	  */
65 65
 	 function quiz_questions( $return = false ) {
66 66
 
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 	  * @access public
75 75
 	  * @since  1.3.0
76 76
 	  * @return void
77
-      * @deprecated
77
+	  * @deprecated
78 78
 	  */
79 79
 	 function quiz_question_type( $question_type = 'multiple-choice' ) {
80 80
 
81
-         Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
81
+		 Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
82 82
 
83 83
 	 } // End lesson_single_meta()
84 84
 
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * sensei_check_prerequisite_course function.
91 91
 	 *
92
-     * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id );
92
+	 * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id );
93 93
 	 * @access public
94 94
 	 * @param mixed $course_id
95 95
 	 * @return bool
96 96
 	 */
97 97
 	function sensei_check_prerequisite_course( $course_id ) {
98 98
 
99
-        return Sensei_Course::is_prerequisite_complete( $course_id );
99
+		return Sensei_Course::is_prerequisite_complete( $course_id );
100 100
 
101 101
 	} // End sensei_check_prerequisite_course()
102 102
 
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
     			<span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span>
121 121
 
122 122
     		</form><?php
123
-    	} // End If Statement
123
+		} // End If Statement
124 124
 	} // End sensei_start_course_form()
125 125
 
126 126
 
127 127
 	/**
128 128
 	 * sensei_wc_add_to_cart function.
129 129
 	 *
130
-     * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id );
130
+	 * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id );
131 131
 	 * @access public
132 132
 	 * @param mixed $course_id
133 133
 	 * @return void
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return bool
148 148
 	 */
149 149
 	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) {
150
-        return Sensei_WC::is_product_in_cart( $wc_product_id );
150
+		return Sensei_WC::is_product_in_cart( $wc_product_id );
151 151
 	} // End sensei_check_if_product_is_in_cart()
152 152
 
153 153
 	/**
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	function sensei_simple_course_price( $post_id ) {
161 161
 
162 162
 		//WooCommerce Pricing
163
-        if ( Sensei_WC::is_woocommerce_active() ) {
164
-    	    $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
-    	    if ( 0 < $wc_post_id ) {
166
-    	    	// Get the product
167
-    	    	$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
163
+		if ( Sensei_WC::is_woocommerce_active() ) {
164
+			$wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
+			if ( 0 < $wc_post_id ) {
166
+				// Get the product
167
+				$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
168 168
 
169
-    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
169
+				if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
170 170
     	    		<span class="course-price"><?php echo $product->get_price_html(); ?></span>
171 171
     	    	<?php } // End If Statement
172
-    	    } // End If Statement
173
-    	} // End If Statement
172
+			} // End If Statement
173
+		} // End If Statement
174 174
 	} // End sensei_simple_course_price()
175 175
 
176 176
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 		if ( ! $query->is_main_query() )
200
-        	return;
200
+			return;
201 201
 
202 202
 		// Apply Filter only if on frontend and when course archive is running
203 203
 		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) {
206 206
 			// Check for pagination settings
207 207
    			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
208
-    			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
209
-    		} else {
210
-    			$amount = $query->get( 'posts_per_page' );
211
-    		} // End If Statement
212
-    		$query->set( 'posts_per_page', $amount );
208
+				$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
209
+			} else {
210
+				$amount = $query->get( 'posts_per_page' );
211
+			} // End If Statement
212
+			$query->set( 'posts_per_page', $amount );
213 213
 		} // End If Statement
214 214
 	} // End sensei_course_archive_filter()
215 215
 	add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
@@ -248,70 +248,70 @@  discard block
 block discarded – undo
248 248
 			$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
249 249
 			$all_lessons = array();
250 250
 
251
-            $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
252
-
253
-            if( !empty( $modules )  ){
254
-                foreach( (array) $modules as $module ) {
255
-
256
-                    $args = array(
257
-                        'post_type' => 'lesson',
258
-                        'post_status' => 'publish',
259
-                        'posts_per_page' => -1,
260
-                        'meta_query' => array(
261
-                            array(
262
-                                'key' => '_lesson_course',
263
-                                'value' => intval( $lesson_course_id ),
264
-                                'compare' => '='
265
-                            )
266
-                        ),
267
-                        'tax_query' => array(
268
-                            array(
269
-                                'taxonomy' => Sensei()->modules->taxonomy,
270
-                                'field' => 'id',
271
-                                'terms' => intval( $module->term_id )
272
-                            )
273
-                        ),
274
-                        'meta_key' => '_order_module_' . $module->term_id,
275
-                        'orderby' => 'meta_value_num date',
276
-                        'order' => 'ASC',
277
-                        'suppress_filters' => 0
278
-                    );
279
-
280
-                    $lessons = get_posts( $args );
281
-                    if ( 0 < count( $lessons ) ) {
282
-                        foreach ($lessons as $lesson_item){
283
-                            $all_lessons[] = $lesson_item->ID;
284
-                        } // End For Loop
285
-                    } // End If Statement
286
-
287
-                }//end for each
288
-
289
-            }// end if empty modules
290
-
291
-            $args = array(
292
-                'post_type' => 'lesson',
293
-                'posts_per_page' => -1,
294
-                'suppress_filters' => 0,
295
-                'meta_key' => '_order_' . $lesson_course_id,
296
-                'orderby' => 'meta_value_num date',
297
-                'order' => 'ASC',
298
-                'meta_query' => array(
299
-                    array(
300
-                        'key' => '_lesson_course',
301
-                        'value' => intval( $lesson_course_id ),
302
-                    ),
303
-                ),
304
-                'post__not_in' => $all_lessons,
305
-            );
306
-
307
-            $other_lessons = get_posts( $args );
308
-            if ( 0 < count( $other_lessons ) ) {
251
+			$modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
252
+
253
+			if( !empty( $modules )  ){
254
+				foreach( (array) $modules as $module ) {
255
+
256
+					$args = array(
257
+						'post_type' => 'lesson',
258
+						'post_status' => 'publish',
259
+						'posts_per_page' => -1,
260
+						'meta_query' => array(
261
+							array(
262
+								'key' => '_lesson_course',
263
+								'value' => intval( $lesson_course_id ),
264
+								'compare' => '='
265
+							)
266
+						),
267
+						'tax_query' => array(
268
+							array(
269
+								'taxonomy' => Sensei()->modules->taxonomy,
270
+								'field' => 'id',
271
+								'terms' => intval( $module->term_id )
272
+							)
273
+						),
274
+						'meta_key' => '_order_module_' . $module->term_id,
275
+						'orderby' => 'meta_value_num date',
276
+						'order' => 'ASC',
277
+						'suppress_filters' => 0
278
+					);
279
+
280
+					$lessons = get_posts( $args );
281
+					if ( 0 < count( $lessons ) ) {
282
+						foreach ($lessons as $lesson_item){
283
+							$all_lessons[] = $lesson_item->ID;
284
+						} // End For Loop
285
+					} // End If Statement
286
+
287
+				}//end for each
288
+
289
+			}// end if empty modules
290
+
291
+			$args = array(
292
+				'post_type' => 'lesson',
293
+				'posts_per_page' => -1,
294
+				'suppress_filters' => 0,
295
+				'meta_key' => '_order_' . $lesson_course_id,
296
+				'orderby' => 'meta_value_num date',
297
+				'order' => 'ASC',
298
+				'meta_query' => array(
299
+					array(
300
+						'key' => '_lesson_course',
301
+						'value' => intval( $lesson_course_id ),
302
+					),
303
+				),
304
+				'post__not_in' => $all_lessons,
305
+			);
306
+
307
+			$other_lessons = get_posts( $args );
308
+			if ( 0 < count( $other_lessons ) ) {
309 309
 				foreach ($other_lessons as $lesson_item){
310 310
 					$all_lessons[] = $lesson_item->ID;
311 311
 				} // End For Loop
312 312
 			} // End If Statement
313 313
 
314
-            if ( 0 < count( $all_lessons ) ) {
314
+			if ( 0 < count( $all_lessons ) ) {
315 315
 				$found_index = false;
316 316
 				foreach ( $all_lessons as $lesson ){
317 317
 					if ( $found_index && $return_values['next_lesson'] == 0 ) {
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
    */
343 343
   function sensei_get_excerpt( $post_id = '' ) {
344 344
 
345
-      global $post;
346
-      _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
347
-      return get_the_excerpt();
345
+	  global $post;
346
+	  _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
347
+	  return get_the_excerpt();
348 348
 
349 349
   }
350 350
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 */
370 370
 function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) {
371 371
 
372
-    return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
372
+	return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
373 373
 
374 374
 } // End sensei_has_user_completed_prerequisite_lesson()
375 375
 
@@ -484,27 +484,27 @@  discard block
 block discarded – undo
484 484
 
485 485
 	}else{
486 486
 
487
-        // if the loop has not been initiated check the first module has lessons
488
-        if( -1 == $sensei_modules_loop[ 'current' ]  ){
487
+		// if the loop has not been initiated check the first module has lessons
488
+		if( -1 == $sensei_modules_loop[ 'current' ]  ){
489 489
 
490
-            $index = 0;
490
+			$index = 0;
491 491
 
492
-            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
493
-                // setup the query for the module lessons
494
-                $course_id = $sensei_modules_loop['course_id'];
492
+			if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
493
+				// setup the query for the module lessons
494
+				$course_id = $sensei_modules_loop['course_id'];
495 495
 
496
-                $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
497
-                $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
496
+				$module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
497
+				$modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
498 498
 
499
-                // setup the global wp-query only if the lessons
500
-                if( $modules_query->have_posts() ){
499
+				// setup the global wp-query only if the lessons
500
+				if( $modules_query->have_posts() ){
501 501
 
502
-                    return true;
502
+					return true;
503 503
 
504
-                }
505
-            }
506
-        }
507
-        // default to false if the first module doesn't have posts
504
+				}
505
+			}
506
+		}
507
+		// default to false if the first module doesn't have posts
508 508
 		return false;
509 509
 
510 510
 	}
@@ -612,46 +612,46 @@  discard block
 block discarded – undo
612 612
 		return '';
613 613
 	}
614 614
 
615
-    global $sensei_modules_loop;
616
-    $module_title = $sensei_modules_loop['current_module']->name;
617
-    $module_term_id = $sensei_modules_loop['current_module']->term_id;
618
-    $course_id = $sensei_modules_loop['course_id'];
619
-    $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() );
615
+	global $sensei_modules_loop;
616
+	$module_title = $sensei_modules_loop['current_module']->name;
617
+	$module_term_id = $sensei_modules_loop['current_module']->term_id;
618
+	$course_id = $sensei_modules_loop['course_id'];
619
+	$module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() );
620 620
 
621
-    $module_status =  '';
622
-    if ( $module_progress && $module_progress > 0) {
621
+	$module_status =  '';
622
+	if ( $module_progress && $module_progress > 0) {
623 623
 
624
-        $module_status = __('Completed', 'woothemes-sensei');
624
+		$module_status = __('Completed', 'woothemes-sensei');
625 625
 
626
-        if ($module_progress < 100) {
626
+		if ($module_progress < 100) {
627 627
 
628
-            $module_status = __('In progress', 'woothemes-sensei');
628
+			$module_status = __('In progress', 'woothemes-sensei');
629 629
 
630
-        }
630
+		}
631 631
 
632
-    }
632
+	}
633 633
 
634 634
 	if ( empty( $module_status ) ){
635 635
 		return '';
636 636
 	}
637 637
 
638 638
 	$status_class = strtolower( str_replace( ' ', '-', $module_status  ) );
639
-    $module_status_html = '<p class="status module-status ' . $status_class . '">'
640
-                            . $module_status
641
-                            . '</p>';
642
-
643
-    /**
644
-     * Filter the module status.
645
-     *
646
-     * This fires within the sensei_get_the_module_status function.
647
-     *
648
-     * @since 1.9.0
649
-     *
650
-     * @param $module_status_html
651
-     * @param $module_term_id
652
-     * @param $course_id
653
-     */
654
-    return apply_filters( 'sensei_the_module_status_html',  $module_status_html , $module_term_id, $course_id );
639
+	$module_status_html = '<p class="status module-status ' . $status_class . '">'
640
+							. $module_status
641
+							. '</p>';
642
+
643
+	/**
644
+	 * Filter the module status.
645
+	 *
646
+	 * This fires within the sensei_get_the_module_status function.
647
+	 *
648
+	 * @since 1.9.0
649
+	 *
650
+	 * @param $module_status_html
651
+	 * @param $module_term_id
652
+	 * @param $course_id
653
+	 */
654
+	return apply_filters( 'sensei_the_module_status_html',  $module_status_html , $module_term_id, $course_id );
655 655
 
656 656
 }
657 657
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
  */
662 662
 function sensei_the_module_status(){
663 663
 
664
-    echo sensei_get_the_module_status();
664
+	echo sensei_get_the_module_status();
665 665
 
666 666
 }
667 667
 
@@ -682,21 +682,21 @@  discard block
 block discarded – undo
682 682
  */
683 683
 function sensei_quiz_has_questions(){
684 684
 
685
-    global $sensei_question_loop;
685
+	global $sensei_question_loop;
686 686
 
687
-    if( !isset( $sensei_question_loop['total'] ) ){
688
-        return false;
689
-    }
687
+	if( !isset( $sensei_question_loop['total'] ) ){
688
+		return false;
689
+	}
690 690
 
691
-    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
691
+	if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
692 692
 
693
-        return true;
693
+		return true;
694 694
 
695
-    }else{
695
+	}else{
696 696
 
697
-        return false;
697
+		return false;
698 698
 
699
-    }
699
+	}
700 700
 
701 701
 }// end sensei_quiz_has_questions
702 702
 
@@ -707,15 +707,14 @@  discard block
 block discarded – undo
707 707
  * execution.
708 708
  *
709 709
  * @since 1.9.0
710
-
711 710
  */
712 711
 function sensei_setup_the_question(){
713 712
 
714
-    global $sensei_question_loop;
713
+	global $sensei_question_loop;
715 714
 
716
-    $sensei_question_loop['current']++;
717
-    $index = $sensei_question_loop['current'];
718
-    $sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
715
+	$sensei_question_loop['current']++;
716
+	$index = $sensei_question_loop['current'];
717
+	$sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
719 718
 
720 719
 
721 720
 }// end sensei_setup_the_question
@@ -728,12 +727,12 @@  discard block
 block discarded – undo
728 727
  */
729 728
 function sensei_the_question_content(){
730 729
 
731
-    global $sensei_question_loop;
730
+	global $sensei_question_loop;
732 731
 
733
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
732
+	$question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
734 733
 
735
-    // load the template that displays the question information.
736
-    WooThemes_Sensei_Question::load_question_template( $question_type );
734
+	// load the template that displays the question information.
735
+	WooThemes_Sensei_Question::load_question_template( $question_type );
737 736
 
738 737
 }// end sensei_the_question_content
739 738
 
@@ -744,26 +743,26 @@  discard block
 block discarded – undo
744 743
  */
745 744
 function sensei_the_question_class(){
746 745
 
747
-    global $sensei_question_loop;
746
+	global $sensei_question_loop;
748 747
 
749
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
748
+	$question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
750 749
 
751
-    /**
752
-     * filter the sensei question class within
753
-     * the quiz question loop.
754
-     *
755
-     * @since 1.9.0
756
-     */
757
-     $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
750
+	/**
751
+	 * filter the sensei question class within
752
+	 * the quiz question loop.
753
+	 *
754
+	 * @since 1.9.0
755
+	 */
756
+	 $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
758 757
 
759
-    $html_classes = '';
760
-    foreach( $classes as $class ){
758
+	$html_classes = '';
759
+	foreach( $classes as $class ){
761 760
 
762
-        $html_classes .= $class . ' ';
761
+		$html_classes .= $class . ' ';
763 762
 
764
-    }// end foreach
763
+	}// end foreach
765 764
 
766
-    esc_attr_e( trim( $html_classes ) );
765
+	esc_attr_e( trim( $html_classes ) );
767 766
 
768 767
 }
769 768
 
@@ -774,12 +773,12 @@  discard block
 block discarded – undo
774 773
  */
775 774
 function sensei_get_the_question_id( ){
776 775
 
777
-    global $sensei_question_loop;
778
-    if( isset( $sensei_question_loop['current_question']->ID ) ){
776
+	global $sensei_question_loop;
777
+	if( isset( $sensei_question_loop['current_question']->ID ) ){
779 778
 
780
-        return $sensei_question_loop['current_question']->ID;
779
+		return $sensei_question_loop['current_question']->ID;
781 780
 
782
-    }
781
+	}
783 782
 
784 783
 }// end sensei_the_question_id
785 784
 
@@ -806,63 +805,63 @@  discard block
 block discarded – undo
806 805
  */
807 806
 function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){
808 807
 
809
-    if( empty( $lesson_id ) ){
808
+	if( empty( $lesson_id ) ){
810 809
 
811
-        $lesson_id = get_the_ID();
810
+		$lesson_id = get_the_ID();
812 811
 
813
-    }
812
+	}
814 813
 
815
-    if( empty( $user_id ) ){
814
+	if( empty( $user_id ) ){
816 815
 
817
-        $user_id = get_current_user_id();
816
+		$user_id = get_current_user_id();
818 817
 
819
-    }
818
+	}
820 819
 
821
-    // Check for prerequisite lesson completions
822
-    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
823
-    $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
824
-    $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
820
+	// Check for prerequisite lesson completions
821
+	$pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
822
+	$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
823
+	$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
825 824
 
826
-    $is_preview = false;
827
-    if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
825
+	$is_preview = false;
826
+	if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
828 827
 
829
-        $is_preview = true;
830
-        $pre_requisite_complete = true;
828
+		$is_preview = true;
829
+		$pre_requisite_complete = true;
831 830
 
832
-    };
831
+	};
833 832
 
834 833
 
835
-    $user_can_access_lesson =  false;
834
+	$user_can_access_lesson =  false;
836 835
 
837
-    if( is_user_logged_in() && $user_taking_course ){
836
+	if( is_user_logged_in() && $user_taking_course ){
838 837
 
839
-        $user_can_access_lesson =  true;
838
+		$user_can_access_lesson =  true;
840 839
 
841
-    }
840
+	}
842 841
 
843 842
 
844
-    $access_permission = false;
843
+	$access_permission = false;
845 844
 
846
-    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
845
+	if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
847 846
 
848
-        $access_permission = true;
847
+		$access_permission = true;
849 848
 
850
-    }
849
+	}
851 850
 
852
-    $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
851
+	$can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
853 852
 
854
-    /**
855
-     * Filter the can user view lesson function
856
-     *
857
-     * @since 1.9.0
858
-     *
859
-     * @hooked Sensei_WC::alter_can_user_view_lesson
860
-     *
861
-     * @param bool $can_user_view_lesson
862
-     * @param string $lesson_id
863
-     * @param string $user_id
864
-     */
865
-    return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
853
+	/**
854
+	 * Filter the can user view lesson function
855
+	 *
856
+	 * @since 1.9.0
857
+	 *
858
+	 * @hooked Sensei_WC::alter_can_user_view_lesson
859
+	 *
860
+	 * @param bool $can_user_view_lesson
861
+	 * @param string $lesson_id
862
+	 * @param string $user_id
863
+	 */
864
+	return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
866 865
 
867 866
 } // end sensei_can_current_user_view_lesson
868 867
 
@@ -874,49 +873,49 @@  discard block
 block discarded – undo
874 873
  */
875 874
 function sensei_the_single_lesson_meta(){
876 875
 
877
-    // if the lesson meta is included within theme load that instead of the function content
878
-    $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
879
-    if( ! empty( $template ) ){
876
+	// if the lesson meta is included within theme load that instead of the function content
877
+	$template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
878
+	if( ! empty( $template ) ){
880 879
 
881
-        Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
882
-        return;
880
+		Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
881
+		return;
883 882
 
884
-    }
885
-
886
-    // Get the meta info
887
-    $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
888
-    $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() );
883
+	}
889 884
 
890
-    // Complete Lesson Logic
891
-    do_action( 'sensei_complete_lesson' );
892
-    // Check that the course has been started
893
-    if ( Sensei()->access_settings()
894
-        || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
895
-        || $is_preview ) {
896
-        ?>
885
+	// Get the meta info
886
+	$lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
887
+	$is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() );
888
+
889
+	// Complete Lesson Logic
890
+	do_action( 'sensei_complete_lesson' );
891
+	// Check that the course has been started
892
+	if ( Sensei()->access_settings()
893
+		|| Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
894
+		|| $is_preview ) {
895
+		?>
897 896
         <section class="lesson-meta">
898 897
             <?php
899
-            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
898
+			if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
900 899
 
901
-                do_action( 'sensei_lesson_video', get_the_ID() );
900
+				do_action( 'sensei_lesson_video', get_the_ID() );
902 901
 
903
-            }
904
-            ?>
902
+			}
903
+			?>
905 904
             <?php do_action( 'sensei_frontend_messages' ); ?>
906 905
 
907 906
             <?php if ( ! $is_preview
908
-                || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
907
+				|| Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
909 908
 
910
-                sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
909
+				sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
911 910
 
912
-            } ?>
911
+			} ?>
913 912
         </section>
914 913
 
915 914
         <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?>
916 915
 
917 916
     <?php }
918 917
 
919
-    do_action( 'sensei_lesson_meta_extra', get_the_ID() );
918
+	do_action( 'sensei_lesson_meta_extra', get_the_ID() );
920 919
 
921 920
 } // end the_single_lesson_meta
922 921
 
@@ -932,16 +931,16 @@  discard block
 block discarded – undo
932 931
  */
933 932
 function get_sensei_header(){
934 933
 
935
-    if ( ! defined( 'ABSPATH' ) ) exit;
934
+	if ( ! defined( 'ABSPATH' ) ) exit;
936 935
 
937
-    get_header();
936
+	get_header();
938 937
 
939
-    /**
940
-     * sensei_before_main_content hook
941
-     *
942
-     * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
943
-     */
944
-    do_action( 'sensei_before_main_content' );
938
+	/**
939
+	 * sensei_before_main_content hook
940
+	 *
941
+	 * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
942
+	 */
943
+	do_action( 'sensei_before_main_content' );
945 944
 
946 945
 }// end get_sensei_header
947 946
 
@@ -957,28 +956,28 @@  discard block
 block discarded – undo
957 956
  */
958 957
 function get_sensei_footer(){
959 958
 
960
-    /**
961
-     * sensei_pagination hook
962
-     *
963
-     * @hooked sensei_pagination - 10 (outputs pagination)
964
-     */
965
-    do_action( 'sensei_pagination' );
966
-
967
-    /**
968
-     * sensei_after_main_content hook
969
-     *
970
-     * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
971
-     */
972
-    do_action( 'sensei_after_main_content' );
973
-
974
-    /**
975
-     * sensei_sidebar hook
976
-     *
977
-     * @hooked sensei_get_sidebar - 10
978
-     */
979
-    do_action( 'sensei_sidebar' );
980
-
981
-    get_footer();
959
+	/**
960
+	 * sensei_pagination hook
961
+	 *
962
+	 * @hooked sensei_pagination - 10 (outputs pagination)
963
+	 */
964
+	do_action( 'sensei_pagination' );
965
+
966
+	/**
967
+	 * sensei_after_main_content hook
968
+	 *
969
+	 * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
970
+	 */
971
+	do_action( 'sensei_after_main_content' );
972
+
973
+	/**
974
+	 * sensei_sidebar hook
975
+	 *
976
+	 * @hooked sensei_get_sidebar - 10
977
+	 */
978
+	do_action( 'sensei_sidebar' );
979
+
980
+	get_footer();
982 981
 
983 982
 }// end get_sensei_header
984 983
 
@@ -990,14 +989,14 @@  discard block
 block discarded – undo
990 989
  */
991 990
 function the_no_permissions_title(){
992 991
 
993
-    /**
994
-     * Filter the no permissions title just before it is echo'd on the
995
-     * no-permissions.php file.
996
-     *
997
-     * @since 1.9.0
998
-     * @param $no_permissions_title
999
-     */
1000
-    echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
992
+	/**
993
+	 * Filter the no permissions title just before it is echo'd on the
994
+	 * no-permissions.php file.
995
+	 *
996
+	 * @since 1.9.0
997
+	 * @param $no_permissions_title
998
+	 */
999
+	echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
1001 1000
 
1002 1001
 }
1003 1002
 
@@ -1008,14 +1007,14 @@  discard block
 block discarded – undo
1008 1007
  */
1009 1008
 function the_no_permissions_message( $post_id ){
1010 1009
 
1011
-    /**
1012
-     * Filter the no permissions message just before it is echo'd on the
1013
-     * no-permissions.php file.
1014
-     *
1015
-     * @since 1.9.0
1016
-     * @param $no_permissions_message
1017
-     */
1018
-    echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
1010
+	/**
1011
+	 * Filter the no permissions message just before it is echo'd on the
1012
+	 * no-permissions.php file.
1013
+	 *
1014
+	 * @since 1.9.0
1015
+	 * @param $no_permissions_message
1016
+	 */
1017
+	echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
1019 1018
 
1020 1019
 }
1021 1020
 
@@ -1026,8 +1025,8 @@  discard block
 block discarded – undo
1026 1025
  */
1027 1026
 function sensei_the_excerpt( $post_id ){
1028 1027
 
1029
-    global $post;
1030
-    the_excerpt( $post );
1028
+	global $post;
1029
+	the_excerpt( $post );
1031 1030
 
1032 1031
 }
1033 1032
 
@@ -1041,9 +1040,9 @@  discard block
 block discarded – undo
1041 1040
  */
1042 1041
  function sensei_get_current_page_url(){
1043 1042
 
1044
-     global $wp;
1045
-     $current_page_url =  home_url( $wp->request );
1046
-     return $current_page_url;
1043
+	 global $wp;
1044
+	 $current_page_url =  home_url( $wp->request );
1045
+	 return $current_page_url;
1047 1046
 
1048 1047
  }
1049 1048
 
@@ -1055,7 +1054,7 @@  discard block
 block discarded – undo
1055 1054
  */
1056 1055
 function sensei_the_my_courses_content(){
1057 1056
 
1058
-    echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
1057
+	echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
1059 1058
 
1060 1059
 } // sensei_the_my_courses_content
1061 1060
 
@@ -1070,7 +1069,7 @@  discard block
 block discarded – undo
1070 1069
  */
1071 1070
 function sensei_load_template( $template_name ){
1072 1071
 
1073
-    Sensei_Templates::get_template( $template_name );
1072
+	Sensei_Templates::get_template( $template_name );
1074 1073
 
1075 1074
 }
1076 1075
 
@@ -1084,7 +1083,7 @@  discard block
 block discarded – undo
1084 1083
  */
1085 1084
 function sensei_load_template_part( $slug, $name ){
1086 1085
 
1087
-    Sensei_Templates::get_part( $slug, $name );
1086
+	Sensei_Templates::get_part( $slug, $name );
1088 1087
 
1089 1088
 }
1090 1089
 
@@ -1103,17 +1102,17 @@  discard block
 block discarded – undo
1103 1102
  */
1104 1103
 function sensei_the_lesson_excerpt( $lesson_id = '' ) {
1105 1104
 
1106
-    if( empty( $lesson_id )){
1105
+	if( empty( $lesson_id )){
1107 1106
 
1108
-        $lesson_id = get_the_ID();
1107
+		$lesson_id = get_the_ID();
1109 1108
 
1110
-    }
1109
+	}
1111 1110
 
1112
-    if( 'lesson' != get_post_type( $lesson_id ) ){
1113
-        return;
1114
-    }
1111
+	if( 'lesson' != get_post_type( $lesson_id ) ){
1112
+		return;
1113
+	}
1115 1114
 
1116
-    echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1115
+	echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1117 1116
 
1118 1117
 }// End lesson_excerpt()
1119 1118
 
@@ -1123,16 +1122,16 @@  discard block
 block discarded – undo
1123 1122
  * @since 1.9.0
1124 1123
  */
1125 1124
 function sensei_the_course_results_lessons(){
1126
-    // load backwards compatible template name if it exists in the users theme
1127
-    $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1128
-    if( $located_template ){
1125
+	// load backwards compatible template name if it exists in the users theme
1126
+	$located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1127
+	if( $located_template ){
1129 1128
 
1130
-        Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1131
-        return;
1129
+		Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1130
+		return;
1132 1131
 
1133
-    }
1132
+	}
1134 1133
 
1135
-    Sensei_Templates::get_template( 'course-results/lessons.php' );
1134
+	Sensei_Templates::get_template( 'course-results/lessons.php' );
1136 1135
 }
1137 1136
 
1138 1137
 /**
@@ -1144,7 +1143,7 @@  discard block
 block discarded – undo
1144 1143
  */
1145 1144
 function sensei_courses_per_row(){
1146 1145
 
1147
-    echo Sensei_Course::get_loop_number_of_columns();
1146
+	echo Sensei_Course::get_loop_number_of_columns();
1148 1147
 
1149 1148
 }
1150 1149
 
@@ -1158,7 +1157,7 @@  discard block
 block discarded – undo
1158 1157
  */
1159 1158
 function sensei_get_template( $template_name, $args, $path ){
1160 1159
 
1161
-    Sensei_Templates::get_template( $template_name, $args, $path );
1160
+	Sensei_Templates::get_template( $template_name, $args, $path );
1162 1161
 
1163 1162
 }
1164 1163
 
@@ -1172,14 +1171,14 @@  discard block
 block discarded – undo
1172 1171
  */
1173 1172
 function get_the_lesson_status_class(){
1174 1173
 
1175
-    $status_class = '';
1176
-    $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
1174
+	$status_class = '';
1175
+	$lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
1177 1176
 
1178
-    if ( $lesson_completed ) {
1179
-        $status_class = 'completed';
1180
-    }
1177
+	if ( $lesson_completed ) {
1178
+		$status_class = 'completed';
1179
+	}
1181 1180
 
1182
-    return  $status_class;
1181
+	return  $status_class;
1183 1182
 
1184 1183
 }// end get_the_lesson_status_class
1185 1184
 /**
@@ -1191,5 +1190,5 @@  discard block
 block discarded – undo
1191 1190
  */
1192 1191
 function sensei_the_lesson_status_class(){
1193 1192
 
1194
-    echo get_the_lesson_status_class();
1193
+	echo get_the_lesson_status_class();
1195 1194
 }
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ){ exit; } // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) { exit; } // Exit if accessed directly
3 3
 
4 4
 	/***************************************************************************************************
5 5
 	 * 	Output tags.
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
      * @param string $type (default: 'newcourses')
13 13
      * @return void
14 14
      */
15
-    function sensei_course_archive_next_link( $type = 'newcourses' ) {
15
+    function sensei_course_archive_next_link($type = 'newcourses') {
16 16
 
17
-        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
17
+        _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.');
18 18
 
19 19
     } // End sensei_course_archive_next_link()
20 20
 
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 function course_single_lessons() {
28 28
 
29 29
          // load backwards compatible template name if it exists in the users theme
30
-         $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
-         if( $located_template ){
30
+         $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php');
31
+         if ($located_template) {
32 32
 
33
-             Sensei_Templates::get_template( 'single-course/course-lessons.php' );
33
+             Sensei_Templates::get_template('single-course/course-lessons.php');
34 34
              return;
35 35
 
36 36
         }
37 37
 
38
-		Sensei_Templates::get_template( 'single-course/lessons.php' );
38
+		Sensei_Templates::get_template('single-course/lessons.php');
39 39
 
40 40
 	 } // End course_single_lessons()
41 41
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	  */
49 49
 	 function lesson_single_meta() {
50 50
 
51
-         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
51
+         _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta');
52 52
          sensei_the_single_lesson_meta();
53 53
 
54 54
 	 } // End lesson_single_meta()
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	  * @return void
63 63
       * @deprecated since 1.9.0
64 64
 	  */
65
-	 function quiz_questions( $return = false ) {
65
+	 function quiz_questions($return = false) {
66 66
 
67
-	 	Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' );
67
+	 	Sensei_Templates::get_template('single-quiz/quiz-questions.php');
68 68
 
69 69
 	 } // End quiz_questions()
70 70
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	  * @return void
77 77
       * @deprecated
78 78
 	  */
79
-	 function quiz_question_type( $question_type = 'multiple-choice' ) {
79
+	 function quiz_question_type($question_type = 'multiple-choice') {
80 80
 
81
-         Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
81
+         Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php');
82 82
 
83 83
 	 } // End lesson_single_meta()
84 84
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param mixed $course_id
95 95
 	 * @return bool
96 96
 	 */
97
-	function sensei_check_prerequisite_course( $course_id ) {
97
+	function sensei_check_prerequisite_course($course_id) {
98 98
 
99
-        return Sensei_Course::is_prerequisite_complete( $course_id );
99
+        return Sensei_Course::is_prerequisite_complete($course_id);
100 100
 
101 101
 	} // End sensei_check_prerequisite_course()
102 102
 
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
 	 * @param mixed $course_id
109 109
 	 * @return void
110 110
 	 */
111
-	function sensei_start_course_form( $course_id ) {
111
+	function sensei_start_course_form($course_id) {
112 112
 
113
-		$prerequisite_complete = sensei_check_prerequisite_course( $course_id );
113
+		$prerequisite_complete = sensei_check_prerequisite_course($course_id);
114 114
 
115
-		if ( $prerequisite_complete ) {
116
-		?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
115
+		if ($prerequisite_complete) {
116
+		?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>">
117 117
 
118
-    			<input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" />
118
+    			<input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" />
119 119
 
120
-    			<span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span>
120
+    			<span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span>
121 121
 
122 122
     		</form><?php
123 123
     	} // End If Statement
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 	 * @param mixed $course_id
133 133
 	 * @return void
134 134
 	 */
135
-	function sensei_wc_add_to_cart( $course_id ) {
135
+	function sensei_wc_add_to_cart($course_id) {
136 136
 
137
-		Sensei_WC::the_add_to_cart_button_html( $course_id );
137
+		Sensei_WC::the_add_to_cart_button_html($course_id);
138 138
 
139 139
 	} // End sensei_wc_add_to_cart()
140 140
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @param int $wc_post_id (default: 0)
147 147
 	 * @return bool
148 148
 	 */
149
-	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) {
150
-        return Sensei_WC::is_product_in_cart( $wc_product_id );
149
+	function sensei_check_if_product_is_in_cart($wc_product_id = 0) {
150
+        return Sensei_WC::is_product_in_cart($wc_product_id);
151 151
 	} // End sensei_check_if_product_is_in_cart()
152 152
 
153 153
 	/**
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	 * @param mixed $post_id
158 158
 	 * @return void
159 159
 	 */
160
-	function sensei_simple_course_price( $post_id ) {
160
+	function sensei_simple_course_price($post_id) {
161 161
 
162 162
 		//WooCommerce Pricing
163
-        if ( Sensei_WC::is_woocommerce_active() ) {
164
-    	    $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
-    	    if ( 0 < $wc_post_id ) {
163
+        if (Sensei_WC::is_woocommerce_active()) {
164
+    	    $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true);
165
+    	    if (0 < $wc_post_id) {
166 166
     	    	// Get the product
167
-    	    	$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
167
+    	    	$product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
168 168
 
169
-    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
169
+    	    	if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?>
170 170
     	    		<span class="course-price"><?php echo $product->get_price_html(); ?></span>
171 171
     	    	<?php } // End If Statement
172 172
     	    } // End If Statement
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 * @param array $widget_args (default: array())
181 181
 	 * @return array
182 182
 	 */
183
-	function sensei_recent_comments_widget_filter( $widget_args = array() ) {
184
-		if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' );
183
+	function sensei_recent_comments_widget_filter($widget_args = array()) {
184
+		if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page');
185 185
 		return $widget_args;
186 186
 	} // End sensei_recent_comments_widget_filter()
187
-	add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 );
187
+	add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1);
188 188
 
189 189
 	/**
190 190
 	 * sensei_course_archive_filter function.
@@ -193,26 +193,26 @@  discard block
 block discarded – undo
193 193
 	 * @param WP_Query $query ( default: array ( ) )
194 194
 	 * @return void
195 195
 	 */
196
-	function sensei_course_archive_filter( $query ) {
196
+	function sensei_course_archive_filter($query) {
197 197
 
198 198
 
199
-		if ( ! $query->is_main_query() )
199
+		if ( ! $query->is_main_query())
200 200
         	return;
201 201
 
202 202
 		// Apply Filter only if on frontend and when course archive is running
203
-		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
203
+		$course_page_id = intval(Sensei()->settings->settings['course_page']);
204 204
 
205
-		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) {
205
+		if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) {
206 206
 			// Check for pagination settings
207
-   			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
208
-    			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
207
+   			if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
208
+    			$amount = absint(Sensei()->settings->settings['course_archive_amount']);
209 209
     		} else {
210
-    			$amount = $query->get( 'posts_per_page' );
210
+    			$amount = $query->get('posts_per_page');
211 211
     		} // End If Statement
212
-    		$query->set( 'posts_per_page', $amount );
212
+    		$query->set('posts_per_page', $amount);
213 213
 		} // End If Statement
214 214
 	} // End sensei_course_archive_filter()
215
-	add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
215
+	add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
216 216
 
217 217
 	/**
218 218
 	 * sensei_complete_lesson_button description
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return html
221 221
 	 */
222 222
 	function sensei_complete_lesson_button() {
223
-		do_action( 'sensei_complete_lesson_button' );
223
+		do_action('sensei_complete_lesson_button');
224 224
 	} // End sensei_complete_lesson_button()
225 225
 
226 226
 	/**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return html
230 230
 	 */
231 231
 	function sensei_reset_lesson_button() {
232
-		do_action( 'sensei_reset_lesson_button' );
232
+		do_action('sensei_reset_lesson_button');
233 233
 	} // End sensei_reset_lesson_button()
234 234
 
235 235
 	/**
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 	 * @param  integer $lesson_id
239 239
 	 * @return array $return_values
240 240
 	 */
241
-	function sensei_get_prev_next_lessons( $lesson_id = 0 ) {
241
+	function sensei_get_prev_next_lessons($lesson_id = 0) {
242 242
 
243 243
 		$return_values = array();
244 244
 		$return_values['prev_lesson'] = 0;
245 245
 		$return_values['next_lesson'] = 0;
246
-		if ( 0 < $lesson_id ) {
246
+		if (0 < $lesson_id) {
247 247
 			// Get the List of Lessons in the Course
248
-			$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
248
+			$lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
249 249
 			$all_lessons = array();
250 250
 
251
-            $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
251
+            $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id));
252 252
 
253
-            if( !empty( $modules )  ){
254
-                foreach( (array) $modules as $module ) {
253
+            if ( ! empty($modules)) {
254
+                foreach ((array) $modules as $module) {
255 255
 
256 256
                     $args = array(
257 257
                         'post_type' => 'lesson',
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                         'meta_query' => array(
261 261
                             array(
262 262
                                 'key' => '_lesson_course',
263
-                                'value' => intval( $lesson_course_id ),
263
+                                'value' => intval($lesson_course_id),
264 264
                                 'compare' => '='
265 265
                             )
266 266
                         ),
@@ -268,18 +268,18 @@  discard block
 block discarded – undo
268 268
                             array(
269 269
                                 'taxonomy' => Sensei()->modules->taxonomy,
270 270
                                 'field' => 'id',
271
-                                'terms' => intval( $module->term_id )
271
+                                'terms' => intval($module->term_id)
272 272
                             )
273 273
                         ),
274
-                        'meta_key' => '_order_module_' . $module->term_id,
274
+                        'meta_key' => '_order_module_'.$module->term_id,
275 275
                         'orderby' => 'meta_value_num date',
276 276
                         'order' => 'ASC',
277 277
                         'suppress_filters' => 0
278 278
                     );
279 279
 
280
-                    $lessons = get_posts( $args );
281
-                    if ( 0 < count( $lessons ) ) {
282
-                        foreach ($lessons as $lesson_item){
280
+                    $lessons = get_posts($args);
281
+                    if (0 < count($lessons)) {
282
+                        foreach ($lessons as $lesson_item) {
283 283
                             $all_lessons[] = $lesson_item->ID;
284 284
                         } // End For Loop
285 285
                     } // End If Statement
@@ -292,36 +292,36 @@  discard block
 block discarded – undo
292 292
                 'post_type' => 'lesson',
293 293
                 'posts_per_page' => -1,
294 294
                 'suppress_filters' => 0,
295
-                'meta_key' => '_order_' . $lesson_course_id,
295
+                'meta_key' => '_order_'.$lesson_course_id,
296 296
                 'orderby' => 'meta_value_num date',
297 297
                 'order' => 'ASC',
298 298
                 'meta_query' => array(
299 299
                     array(
300 300
                         'key' => '_lesson_course',
301
-                        'value' => intval( $lesson_course_id ),
301
+                        'value' => intval($lesson_course_id),
302 302
                     ),
303 303
                 ),
304 304
                 'post__not_in' => $all_lessons,
305 305
             );
306 306
 
307
-            $other_lessons = get_posts( $args );
308
-            if ( 0 < count( $other_lessons ) ) {
309
-				foreach ($other_lessons as $lesson_item){
307
+            $other_lessons = get_posts($args);
308
+            if (0 < count($other_lessons)) {
309
+				foreach ($other_lessons as $lesson_item) {
310 310
 					$all_lessons[] = $lesson_item->ID;
311 311
 				} // End For Loop
312 312
 			} // End If Statement
313 313
 
314
-            if ( 0 < count( $all_lessons ) ) {
314
+            if (0 < count($all_lessons)) {
315 315
 				$found_index = false;
316
-				foreach ( $all_lessons as $lesson ){
317
-					if ( $found_index && $return_values['next_lesson'] == 0 ) {
316
+				foreach ($all_lessons as $lesson) {
317
+					if ($found_index && $return_values['next_lesson'] == 0) {
318 318
 						$return_values['next_lesson'] = $lesson;
319 319
 					} // End If Statement
320
-					if ( $lesson == $lesson_id ) {
320
+					if ($lesson == $lesson_id) {
321 321
 						// Is the current post
322 322
 						$found_index = true;
323 323
 					} // End If Statement
324
-					if ( !$found_index ) {
324
+					if ( ! $found_index) {
325 325
 						$return_values['prev_lesson'] = $lesson;
326 326
 					} // End If Statement
327 327
 				} // End For Loop
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
    * @param  int|WP_Post $post_id Optional. Defaults to current post
341 341
    * @return string $excerpt
342 342
    */
343
-  function sensei_get_excerpt( $post_id = '' ) {
343
+  function sensei_get_excerpt($post_id = '') {
344 344
 
345 345
       global $post;
346 346
       _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
   }
350 350
 
351
-	function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) {
352
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" );
353
-		return Sensei_Utils::user_started_course( $post_id, $user_id );
351
+	function sensei_has_user_started_course($post_id = 0, $user_id = 0) {
352
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()");
353
+		return Sensei_Utils::user_started_course($post_id, $user_id);
354 354
 	} // End sensei_has_user_started_course()
355 355
 
356
-	function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) {
357
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" );
358
-		return Sensei_Utils::user_completed_lesson( $post_id, $user_id );
356
+	function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) {
357
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()");
358
+		return Sensei_Utils::user_completed_lesson($post_id, $user_id);
359 359
 	} // End sensei_has_user_completed_lesson()
360 360
 
361 361
 /**
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
  * @param int $user_id
368 368
  * @return bool
369 369
 */
370
-function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) {
370
+function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) {
371 371
 
372
-    return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
372
+    return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id);
373 373
 
374 374
 } // End sensei_has_user_completed_prerequisite_lesson()
375 375
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
  * @return bool
393 393
  *
394 394
  */
395
-function sensei_have_modules( $course_post_id = '' ){
395
+function sensei_have_modules($course_post_id = '') {
396 396
 
397 397
 	global $post, $wp_query, $sensei_modules_loop;
398 398
 
@@ -400,23 +400,23 @@  discard block
 block discarded – undo
400 400
 	wp_reset_query();
401 401
 	$post = $wp_query->post;
402 402
 
403
-	if( empty( $course_post_id ) ){
403
+	if (empty($course_post_id)) {
404 404
 
405 405
 		$course_id = $post->ID;
406 406
 
407 407
 	}
408 408
 
409 409
 	// doesn't apply to none course post types
410
-	if( ! sensei_is_a_course( $course_id )  ){
410
+	if ( ! sensei_is_a_course($course_id)) {
411 411
 		return false;
412 412
 	}
413 413
 
414 414
 	// check the current item compared to the total number of modules
415
-	if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ]  ){
415
+	if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) {
416 416
 
417 417
 		return false;
418 418
 
419
-	}else{
419
+	} else {
420 420
 
421 421
 		return true;
422 422
 
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
  *
431 431
  * @since 1.9.0
432 432
  */
433
-function sensei_setup_module(){
433
+function sensei_setup_module() {
434 434
 
435 435
 	global  $sensei_modules_loop, $wp_query;
436 436
 
437 437
 	// increment the index
438
-	$sensei_modules_loop[ 'current' ]++;
439
-	$index = $sensei_modules_loop[ 'current' ];
440
-	if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
438
+	$sensei_modules_loop['current']++;
439
+	$index = $sensei_modules_loop['current'];
440
+	if (isset($sensei_modules_loop['modules'][$index])) {
441 441
 
442 442
 		$sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index];
443 443
 		// setup the query for the module lessons
444 444
 		$course_id = $sensei_modules_loop['course_id'];
445 445
 		$module_term_id = $sensei_modules_loop['current_module']->term_id;
446
-		$modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
446
+		$modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id);
447 447
 
448 448
 		// setup the global wp-query only if the lessons
449
-		if( $modules_query->have_posts() ){
449
+		if ($modules_query->have_posts()) {
450 450
 
451 451
 			$wp_query = $modules_query;
452 452
 
453
-		}else{
453
+		} else {
454 454
 
455 455
 			wp_reset_query();
456 456
 
@@ -474,30 +474,30 @@  discard block
 block discarded – undo
474 474
  *
475 475
  * @return bool
476 476
  */
477
-function sensei_module_has_lessons(){
477
+function sensei_module_has_lessons() {
478 478
 
479 479
 	global $wp_query, $sensei_modules_loop;
480 480
 
481
-	if( 'lesson' == $wp_query->get('post_type') ){
481
+	if ('lesson' == $wp_query->get('post_type')) {
482 482
 
483 483
 		return have_posts();
484 484
 
485
-	}else{
485
+	} else {
486 486
 
487 487
         // if the loop has not been initiated check the first module has lessons
488
-        if( -1 == $sensei_modules_loop[ 'current' ]  ){
488
+        if ( -1 == $sensei_modules_loop['current']  ) {
489 489
 
490 490
             $index = 0;
491 491
 
492
-            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
492
+            if (isset($sensei_modules_loop['modules'][$index])) {
493 493
                 // setup the query for the module lessons
494 494
                 $course_id = $sensei_modules_loop['course_id'];
495 495
 
496
-                $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
497
-                $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
496
+                $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id;
497
+                $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id);
498 498
 
499 499
                 // setup the global wp-query only if the lessons
500
-                if( $modules_query->have_posts() ){
500
+                if ($modules_query->have_posts()) {
501 501
 
502 502
                     return true;
503 503
 
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
  * @uses sensei_the_module_title
522 522
  * @return string
523 523
  */
524
-function sensei_the_module_title_attribute(){
524
+function sensei_the_module_title_attribute() {
525 525
 
526
-	esc_attr_e( sensei_get_the_module_title() );
526
+	esc_attr_e(sensei_get_the_module_title());
527 527
 
528 528
 }
529 529
 
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
  *
535 535
  * @return string
536 536
  */
537
-function sensei_the_module_permalink(){
537
+function sensei_the_module_permalink() {
538 538
 
539 539
 	global $sensei_modules_loop;
540 540
 	$course_id = $sensei_modules_loop['course_id'];
541
-	$module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) );
541
+	$module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module'));
542 542
 	$module_term_id = $sensei_modules_loop['current_module']->term_id;
543 543
 
544 544
 	/**
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	 * @param int $module_term_id
551 551
 	 * @param string $course_id
552 552
 	 */
553
-	 echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id  ,$course_id ) );
553
+	 echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id));
554 554
 
555 555
 }// end sensei_the_module_permalink
556 556
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
  *
563 563
  * @return string
564 564
  */
565
-function sensei_get_the_module_title(){
565
+function sensei_get_the_module_title() {
566 566
 
567 567
 	global $sensei_modules_loop;
568 568
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 * @param $module_term_id
582 582
 	 * @param $course_id
583 583
 	 */
584
-	return apply_filters( 'sensei_the_module_title',  $module_title , $module_term_id, $course_id );
584
+	return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id);
585 585
 
586 586
 }
587 587
 
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
  * @uses sensei_get_the_module_title
594 594
  * @return string
595 595
  */
596
-function sensei_the_module_title(){
596
+function sensei_the_module_title() {
597 597
 
598 598
 	echo sensei_get_the_module_title();
599 599
 
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
  * @since 1.9.0
607 607
  * @return string
608 608
  */
609
-function sensei_get_the_module_status(){
609
+function sensei_get_the_module_status() {
610 610
 
611
-	if( ! is_user_logged_in() ){
611
+	if ( ! is_user_logged_in()) {
612 612
 		return '';
613 613
 	}
614 614
 
@@ -616,10 +616,10 @@  discard block
 block discarded – undo
616 616
     $module_title = $sensei_modules_loop['current_module']->name;
617 617
     $module_term_id = $sensei_modules_loop['current_module']->term_id;
618 618
     $course_id = $sensei_modules_loop['course_id'];
619
-    $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() );
619
+    $module_progress = Sensei()->modules->get_user_module_progress($module_term_id, $course_id, get_current_user_id());
620 620
 
621
-    $module_status =  '';
622
-    if ( $module_progress && $module_progress > 0) {
621
+    $module_status = '';
622
+    if ($module_progress && $module_progress > 0) {
623 623
 
624 624
         $module_status = __('Completed', 'woothemes-sensei');
625 625
 
@@ -631,12 +631,12 @@  discard block
 block discarded – undo
631 631
 
632 632
     }
633 633
 
634
-	if ( empty( $module_status ) ){
634
+	if (empty($module_status)) {
635 635
 		return '';
636 636
 	}
637 637
 
638
-	$status_class = strtolower( str_replace( ' ', '-', $module_status  ) );
639
-    $module_status_html = '<p class="status module-status ' . $status_class . '">'
638
+	$status_class = strtolower(str_replace(' ', '-', $module_status));
639
+    $module_status_html = '<p class="status module-status '.$status_class.'">'
640 640
                             . $module_status
641 641
                             . '</p>';
642 642
 
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      * @param $module_term_id
652 652
      * @param $course_id
653 653
      */
654
-    return apply_filters( 'sensei_the_module_status_html',  $module_status_html , $module_term_id, $course_id );
654
+    return apply_filters('sensei_the_module_status_html', $module_status_html, $module_term_id, $course_id);
655 655
 
656 656
 }
657 657
 
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
  * Print out the current module status
660 660
  * @since 1.9.0
661 661
  */
662
-function sensei_the_module_status(){
662
+function sensei_the_module_status() {
663 663
 
664 664
     echo sensei_get_the_module_status();
665 665
 
@@ -680,19 +680,19 @@  discard block
 block discarded – undo
680 680
  *
681 681
  * @return bool
682 682
  */
683
-function sensei_quiz_has_questions(){
683
+function sensei_quiz_has_questions() {
684 684
 
685 685
     global $sensei_question_loop;
686 686
 
687
-    if( !isset( $sensei_question_loop['total'] ) ){
687
+    if ( ! isset($sensei_question_loop['total'])) {
688 688
         return false;
689 689
     }
690 690
 
691
-    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
691
+    if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) {
692 692
 
693 693
         return true;
694 694
 
695
-    }else{
695
+    } else {
696 696
 
697 697
         return false;
698 698
 
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
  * @since 1.9.0
710 710
 
711 711
  */
712
-function sensei_setup_the_question(){
712
+function sensei_setup_the_question() {
713 713
 
714 714
     global $sensei_question_loop;
715 715
 
716 716
     $sensei_question_loop['current']++;
717 717
     $index = $sensei_question_loop['current'];
718
-    $sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
718
+    $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index];
719 719
 
720 720
 
721 721
 }// end sensei_setup_the_question
@@ -726,14 +726,14 @@  discard block
 block discarded – undo
726 726
  * This function gets the type and loads the template that will handle it.
727 727
  *
728 728
  */
729
-function sensei_the_question_content(){
729
+function sensei_the_question_content() {
730 730
 
731 731
     global $sensei_question_loop;
732 732
 
733
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
733
+    $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
734 734
 
735 735
     // load the template that displays the question information.
736
-    WooThemes_Sensei_Question::load_question_template( $question_type );
736
+    WooThemes_Sensei_Question::load_question_template($question_type);
737 737
 
738 738
 }// end sensei_the_question_content
739 739
 
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @since 1.9.0
744 744
  */
745
-function sensei_the_question_class(){
745
+function sensei_the_question_class() {
746 746
 
747 747
     global $sensei_question_loop;
748 748
 
749
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
749
+    $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
750 750
 
751 751
     /**
752 752
      * filter the sensei question class within
@@ -754,16 +754,16 @@  discard block
 block discarded – undo
754 754
      *
755 755
      * @since 1.9.0
756 756
      */
757
-     $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
757
+     $classes = apply_filters('sensei_question_classes', array($question_type));
758 758
 
759 759
     $html_classes = '';
760
-    foreach( $classes as $class ){
760
+    foreach ($classes as $class) {
761 761
 
762
-        $html_classes .= $class . ' ';
762
+        $html_classes .= $class.' ';
763 763
 
764 764
     }// end foreach
765 765
 
766
-    esc_attr_e( trim( $html_classes ) );
766
+    esc_attr_e(trim($html_classes));
767 767
 
768 768
 }
769 769
 
@@ -772,10 +772,10 @@  discard block
 block discarded – undo
772 772
  *
773 773
  * @since 1.9.0
774 774
  */
775
-function sensei_get_the_question_id( ){
775
+function sensei_get_the_question_id( ) {
776 776
 
777 777
     global $sensei_question_loop;
778
-    if( isset( $sensei_question_loop['current_question']->ID ) ){
778
+    if (isset($sensei_question_loop['current_question']->ID)) {
779 779
 
780 780
         return $sensei_question_loop['current_question']->ID;
781 781
 
@@ -804,27 +804,27 @@  discard block
 block discarded – undo
804 804
  * @param string $lesson_id
805 805
  * @return bool
806 806
  */
807
-function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){
807
+function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') {
808 808
 
809
-    if( empty( $lesson_id ) ){
809
+    if (empty($lesson_id)) {
810 810
 
811 811
         $lesson_id = get_the_ID();
812 812
 
813 813
     }
814 814
 
815
-    if( empty( $user_id ) ){
815
+    if (empty($user_id)) {
816 816
 
817 817
         $user_id = get_current_user_id();
818 818
 
819 819
     }
820 820
 
821 821
     // Check for prerequisite lesson completions
822
-    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
823
-    $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
824
-    $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
822
+    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id);
823
+    $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
824
+    $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, $user_id);
825 825
 
826 826
     $is_preview = false;
827
-    if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
827
+    if (Sensei_Utils::is_preview_lesson($lesson_id)) {
828 828
 
829 829
         $is_preview = true;
830 830
         $pre_requisite_complete = true;
@@ -832,24 +832,24 @@  discard block
 block discarded – undo
832 832
     };
833 833
 
834 834
 
835
-    $user_can_access_lesson =  false;
835
+    $user_can_access_lesson = false;
836 836
 
837
-    if( is_user_logged_in() && $user_taking_course ){
837
+    if (is_user_logged_in() && $user_taking_course) {
838 838
 
839
-        $user_can_access_lesson =  true;
839
+        $user_can_access_lesson = true;
840 840
 
841 841
     }
842 842
 
843 843
 
844 844
     $access_permission = false;
845 845
 
846
-    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
846
+    if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) {
847 847
 
848 848
         $access_permission = true;
849 849
 
850 850
     }
851 851
 
852
-    $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
852
+    $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview;
853 853
 
854 854
     /**
855 855
      * Filter the can user view lesson function
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
      * @param string $lesson_id
863 863
      * @param string $user_id
864 864
      */
865
-    return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
865
+    return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id);
866 866
 
867 867
 } // end sensei_can_current_user_view_lesson
868 868
 
@@ -872,51 +872,51 @@  discard block
 block discarded – undo
872 872
  * The function should only be called on the single lesson
873 873
  *
874 874
  */
875
-function sensei_the_single_lesson_meta(){
875
+function sensei_the_single_lesson_meta() {
876 876
 
877 877
     // if the lesson meta is included within theme load that instead of the function content
878
-    $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
879
-    if( ! empty( $template ) ){
878
+    $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php');
879
+    if ( ! empty($template)) {
880 880
 
881
-        Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
881
+        Sensei_Templates::get_template('single-lesson/lesson-meta.php');
882 882
         return;
883 883
 
884 884
     }
885 885
 
886 886
     // Get the meta info
887
-    $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
888
-    $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() );
887
+    $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true));
888
+    $is_preview = Sensei_Utils::is_preview_lesson(get_the_ID());
889 889
 
890 890
     // Complete Lesson Logic
891
-    do_action( 'sensei_complete_lesson' );
891
+    do_action('sensei_complete_lesson');
892 892
     // Check that the course has been started
893
-    if ( Sensei()->access_settings()
894
-        || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
895
-        || $is_preview ) {
893
+    if (Sensei()->access_settings()
894
+        || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())
895
+        || $is_preview) {
896 896
         ?>
897 897
         <section class="lesson-meta">
898 898
             <?php
899
-            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
899
+            if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') {
900 900
 
901
-                do_action( 'sensei_lesson_video', get_the_ID() );
901
+                do_action('sensei_lesson_video', get_the_ID());
902 902
 
903 903
             }
904 904
             ?>
905
-            <?php do_action( 'sensei_frontend_messages' ); ?>
905
+            <?php do_action('sensei_frontend_messages'); ?>
906 906
 
907 907
             <?php if ( ! $is_preview
908
-                || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
908
+                || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) {
909 909
 
910
-                sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
910
+                sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id()));
911 911
 
912 912
             } ?>
913 913
         </section>
914 914
 
915
-        <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?>
915
+        <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?>
916 916
 
917 917
     <?php }
918 918
 
919
-    do_action( 'sensei_lesson_meta_extra', get_the_ID() );
919
+    do_action('sensei_lesson_meta_extra', get_the_ID());
920 920
 
921 921
 } // end the_single_lesson_meta
922 922
 
@@ -930,9 +930,9 @@  discard block
 block discarded – undo
930 930
  *
931 931
  * @since 1.9.0
932 932
  */
933
-function get_sensei_header(){
933
+function get_sensei_header() {
934 934
 
935
-    if ( ! defined( 'ABSPATH' ) ) exit;
935
+    if ( ! defined('ABSPATH')) exit;
936 936
 
937 937
     get_header();
938 938
 
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
      *
942 942
      * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
943 943
      */
944
-    do_action( 'sensei_before_main_content' );
944
+    do_action('sensei_before_main_content');
945 945
 
946 946
 }// end get_sensei_header
947 947
 
@@ -955,28 +955,28 @@  discard block
 block discarded – undo
955 955
  *
956 956
  * @since 1.9.0
957 957
  */
958
-function get_sensei_footer(){
958
+function get_sensei_footer() {
959 959
 
960 960
     /**
961 961
      * sensei_pagination hook
962 962
      *
963 963
      * @hooked sensei_pagination - 10 (outputs pagination)
964 964
      */
965
-    do_action( 'sensei_pagination' );
965
+    do_action('sensei_pagination');
966 966
 
967 967
     /**
968 968
      * sensei_after_main_content hook
969 969
      *
970 970
      * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
971 971
      */
972
-    do_action( 'sensei_after_main_content' );
972
+    do_action('sensei_after_main_content');
973 973
 
974 974
     /**
975 975
      * sensei_sidebar hook
976 976
      *
977 977
      * @hooked sensei_get_sidebar - 10
978 978
      */
979
-    do_action( 'sensei_sidebar' );
979
+    do_action('sensei_sidebar');
980 980
 
981 981
     get_footer();
982 982
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  *
989 989
  * @since 1.9.0
990 990
  */
991
-function the_no_permissions_title(){
991
+function the_no_permissions_title() {
992 992
 
993 993
     /**
994 994
      * Filter the no permissions title just before it is echo'd on the
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
      * @since 1.9.0
998 998
      * @param $no_permissions_title
999 999
      */
1000
-    echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
1000
+    echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']);
1001 1001
 
1002 1002
 }
1003 1003
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
  *
1007 1007
  * @since 1.9.0
1008 1008
  */
1009
-function the_no_permissions_message( $post_id ){
1009
+function the_no_permissions_message($post_id) {
1010 1010
 
1011 1011
     /**
1012 1012
      * Filter the no permissions message just before it is echo'd on the
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
      * @since 1.9.0
1016 1016
      * @param $no_permissions_message
1017 1017
      */
1018
-    echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
1018
+    echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id);
1019 1019
 
1020 1020
 }
1021 1021
 
@@ -1024,10 +1024,10 @@  discard block
 block discarded – undo
1024 1024
  *
1025 1025
  * @since 1.9.0
1026 1026
  */
1027
-function sensei_the_excerpt( $post_id ){
1027
+function sensei_the_excerpt($post_id) {
1028 1028
 
1029 1029
     global $post;
1030
-    the_excerpt( $post );
1030
+    the_excerpt($post);
1031 1031
 
1032 1032
 }
1033 1033
 
@@ -1039,10 +1039,10 @@  discard block
 block discarded – undo
1039 1039
  * @global WP $wp
1040 1040
  * @return string $current_page_url
1041 1041
  */
1042
- function sensei_get_current_page_url(){
1042
+ function sensei_get_current_page_url() {
1043 1043
 
1044 1044
      global $wp;
1045
-     $current_page_url =  home_url( $wp->request );
1045
+     $current_page_url = home_url($wp->request);
1046 1046
      return $current_page_url;
1047 1047
 
1048 1048
  }
@@ -1053,9 +1053,9 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @since 1.9.0
1055 1055
  */
1056
-function sensei_the_my_courses_content(){
1056
+function sensei_the_my_courses_content() {
1057 1057
 
1058
-    echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
1058
+    echo Sensei()->course->load_user_courses_content(wp_get_current_user());
1059 1059
 
1060 1060
 } // sensei_the_my_courses_content
1061 1061
 
@@ -1068,9 +1068,9 @@  discard block
 block discarded – undo
1068 1068
  *
1069 1069
  * @since 1.9.0
1070 1070
  */
1071
-function sensei_load_template( $template_name ){
1071
+function sensei_load_template($template_name) {
1072 1072
 
1073
-    Sensei_Templates::get_template( $template_name );
1073
+    Sensei_Templates::get_template($template_name);
1074 1074
 
1075 1075
 }
1076 1076
 
@@ -1082,9 +1082,9 @@  discard block
 block discarded – undo
1082 1082
  * @param string $name the name of the template.
1083 1083
  * @since 1.9.0
1084 1084
  */
1085
-function sensei_load_template_part( $slug, $name ){
1085
+function sensei_load_template_part($slug, $name) {
1086 1086
 
1087
-    Sensei_Templates::get_part( $slug, $name );
1087
+    Sensei_Templates::get_part($slug, $name);
1088 1088
 
1089 1089
 }
1090 1090
 
@@ -1101,19 +1101,19 @@  discard block
 block discarded – undo
1101 1101
  * @access public
1102 1102
  * @param string $lesson_id
1103 1103
  */
1104
-function sensei_the_lesson_excerpt( $lesson_id = '' ) {
1104
+function sensei_the_lesson_excerpt($lesson_id = '') {
1105 1105
 
1106
-    if( empty( $lesson_id )){
1106
+    if (empty($lesson_id)) {
1107 1107
 
1108 1108
         $lesson_id = get_the_ID();
1109 1109
 
1110 1110
     }
1111 1111
 
1112
-    if( 'lesson' != get_post_type( $lesson_id ) ){
1112
+    if ('lesson' != get_post_type($lesson_id)) {
1113 1113
         return;
1114 1114
     }
1115 1115
 
1116
-    echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1116
+    echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false);
1117 1117
 
1118 1118
 }// End lesson_excerpt()
1119 1119
 
@@ -1122,17 +1122,17 @@  discard block
 block discarded – undo
1122 1122
  *
1123 1123
  * @since 1.9.0
1124 1124
  */
1125
-function sensei_the_course_results_lessons(){
1125
+function sensei_the_course_results_lessons() {
1126 1126
     // load backwards compatible template name if it exists in the users theme
1127
-    $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1128
-    if( $located_template ){
1127
+    $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php');
1128
+    if ($located_template) {
1129 1129
 
1130
-        Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1130
+        Sensei_Templates::get_template('course-results/course-lessons.php');
1131 1131
         return;
1132 1132
 
1133 1133
     }
1134 1134
 
1135
-    Sensei_Templates::get_template( 'course-results/lessons.php' );
1135
+    Sensei_Templates::get_template('course-results/lessons.php');
1136 1136
 }
1137 1137
 
1138 1138
 /**
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
  * @uses Sensei_Course::get_loop_number_of_columns
1143 1143
  * @since 1.9.0
1144 1144
  */
1145
-function sensei_courses_per_row(){
1145
+function sensei_courses_per_row() {
1146 1146
 
1147 1147
     echo Sensei_Course::get_loop_number_of_columns();
1148 1148
 
@@ -1156,9 +1156,9 @@  discard block
 block discarded – undo
1156 1156
  * @param $args
1157 1157
  * @param $path
1158 1158
  */
1159
-function sensei_get_template( $template_name, $args, $path ){
1159
+function sensei_get_template($template_name, $args, $path) {
1160 1160
 
1161
-    Sensei_Templates::get_template( $template_name, $args, $path );
1161
+    Sensei_Templates::get_template($template_name, $args, $path);
1162 1162
 
1163 1163
 }
1164 1164
 
@@ -1170,12 +1170,12 @@  discard block
 block discarded – undo
1170 1170
  *
1171 1171
  * @return string $status_class
1172 1172
  */
1173
-function get_the_lesson_status_class(){
1173
+function get_the_lesson_status_class() {
1174 1174
 
1175 1175
     $status_class = '';
1176
-    $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
1176
+    $lesson_completed = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
1177 1177
 
1178
-    if ( $lesson_completed ) {
1178
+    if ($lesson_completed) {
1179 1179
         $status_class = 'completed';
1180 1180
     }
1181 1181
 
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
  *
1190 1190
  * @since 1.9.0
1191 1191
  */
1192
-function sensei_the_lesson_status_class(){
1192
+function sensei_the_lesson_status_class() {
1193 1193
 
1194 1194
     echo get_the_lesson_status_class();
1195 1195
 }
Please login to merge, or discard this patch.
templates/no-permissions.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Template for displaying all access restriction error messages.
4
- *
5
- * Override this template by copying it to yourtheme/sensei/no-permissions.php
6
- *
7
- * @author 		Automattic
8
- * @package 	Sensei
9
- * @category    Templates
10
- * @version     1.9.0
11
- */
3
+	 * The Template for displaying all access restriction error messages.
4
+	 *
5
+	 * Override this template by copying it to yourtheme/sensei/no-permissions.php
6
+	 *
7
+	 * @author 		Automattic
8
+	 * @package 	Sensei
9
+	 * @category    Templates
10
+	 * @version     1.9.0
11
+	 */
12 12
 ?>
13 13
 
14 14
 <?php  get_sensei_header();  ?>
15 15
 
16 16
 <?php
17 17
 /**
18
- * This action fires inside the no-permissions.php file. It
19
- * is place above before all the content.
20
- *
21
- * @since 1.9.0
22
- * @param $post_id
23
- */
18
+	 * This action fires inside the no-permissions.php file. It
19
+	 * is place above before all the content.
20
+	 *
21
+	 * @since 1.9.0
22
+	 * @param $post_id
23
+	 */
24 24
 do_action('sensei_no_permissions_before_content', get_the_ID() );
25 25
 ?>
26 26
 
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
     </header>
34 34
 
35 35
     <?php
36
-    /**
37
-     * This action fires inside the no-permissions.php file. It
38
-     * is place just before the content.
39
-     *
40
-     * @since 1.9.0
41
-     * @param $post_id
42
-     */
43
-    do_action('sensei_no_permissions_inside_before_content', get_the_ID() );
44
-    ?>
36
+	/**
37
+	 * This action fires inside the no-permissions.php file. It
38
+	 * is place just before the content.
39
+	 *
40
+	 * @since 1.9.0
41
+	 * @param $post_id
42
+	 */
43
+	do_action('sensei_no_permissions_inside_before_content', get_the_ID() );
44
+	?>
45 45
 
46 46
     <section class="entry fix">
47 47
 
@@ -60,26 +60,26 @@  discard block
 block discarded – undo
60 60
     </section>
61 61
 
62 62
     <?php
63
-    /**
64
-     * This action fires inside the no-permissions.php file. It
65
-     * is place just after the content.
66
-     *
67
-     * @since 1.9.0
68
-     * @param $post_id
69
-     */
70
-    do_action('sensei_no_permissions_inside_after_content', get_the_ID() );
71
-    ?>
63
+	/**
64
+	 * This action fires inside the no-permissions.php file. It
65
+	 * is place just after the content.
66
+	 *
67
+	 * @since 1.9.0
68
+	 * @param $post_id
69
+	 */
70
+	do_action('sensei_no_permissions_inside_after_content', get_the_ID() );
71
+	?>
72 72
 
73 73
 </article><!-- .no-permissions -->
74 74
 
75 75
 <?php
76 76
 /**
77
- * This action fires inside the no-permissions.php file. It
78
- * is placed outside after the content.
79
- *
80
- * @since 1.9.0
81
- * @param $post_id
82
- */
77
+	 * This action fires inside the no-permissions.php file. It
78
+	 * is placed outside after the content.
79
+	 *
80
+	 * @since 1.9.0
81
+	 * @param $post_id
82
+	 */
83 83
 do_action('sensei_no_permissions_after_content', get_the_ID() );
84 84
 ?>
85 85
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 ?>
13 13
 
14
-<?php  get_sensei_header();  ?>
14
+<?php  get_sensei_header(); ?>
15 15
 
16 16
 <?php
17 17
 /**
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  * @since 1.9.0
22 22
  * @param $post_id
23 23
  */
24
-do_action('sensei_no_permissions_before_content', get_the_ID() );
24
+do_action('sensei_no_permissions_before_content', get_the_ID());
25 25
 ?>
26 26
 
27
-<article <?php post_class( 'no-permission' ) ?> >
27
+<article <?php post_class('no-permission') ?> >
28 28
 
29 29
     <header>
30 30
 
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
      * @since 1.9.0
41 41
      * @param $post_id
42 42
      */
43
-    do_action('sensei_no_permissions_inside_before_content', get_the_ID() );
43
+    do_action('sensei_no_permissions_inside_before_content', get_the_ID());
44 44
     ?>
45 45
 
46 46
     <section class="entry fix">
47 47
 
48 48
         <div class="sensei-message alert">
49 49
 
50
-            <?php the_no_permissions_message( get_the_ID() ); ?>
50
+            <?php the_no_permissions_message(get_the_ID()); ?>
51 51
 
52 52
         </div>
53 53
 
54 54
         <p class="excerpt">
55 55
 
56
-            <?php sensei_the_excerpt( get_the_ID() ); ?>
56
+            <?php sensei_the_excerpt(get_the_ID()); ?>
57 57
 
58 58
         </p>
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @since 1.9.0
68 68
      * @param $post_id
69 69
      */
70
-    do_action('sensei_no_permissions_inside_after_content', get_the_ID() );
70
+    do_action('sensei_no_permissions_inside_after_content', get_the_ID());
71 71
     ?>
72 72
 
73 73
 </article><!-- .no-permissions -->
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @since 1.9.0
81 81
  * @param $post_id
82 82
  */
83
-do_action('sensei_no_permissions_after_content', get_the_ID() );
83
+do_action('sensei_no_permissions_after_content', get_the_ID());
84 84
 ?>
85 85
 
86 86
 <?php get_sensei_footer(); ?>
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-sensei-frontend.php 3 patches
Braces   +30 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Frontend Class
@@ -668,7 +671,9 @@  discard block
 block discarded – undo
668 671
 	public function sensei_breadcrumb( $id = 0 ) {
669 672
 
670 673
 		// Only output on lesson, quiz and taxonomy (module) pages
671
-		if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return;
674
+		if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) {
675
+			return;
676
+		}
672 677
 
673 678
 		if( empty( $id )  ){
674 679
 
@@ -1094,17 +1099,26 @@  discard block
 block discarded – undo
1094 1099
 
1095 1100
 						<p class="form-row form-row-wide">
1096 1101
 							<label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1097
-							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" />
1102
+							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) {
1103
+	esc_attr_e( $_POST['sensei_reg_username'] );
1104
+}
1105
+?>" />
1098 1106
 						</p>
1099 1107
 
1100 1108
 						<p class="form-row form-row-wide">
1101 1109
 							<label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1102
-							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" />
1110
+							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) {
1111
+	esc_attr_e( $_POST['sensei_reg_email'] );
1112
+}
1113
+?>" />
1103 1114
 						</p>
1104 1115
 
1105 1116
 						<p class="form-row form-row-wide">
1106 1117
 							<label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1107
-							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" />
1118
+							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) {
1119
+	esc_attr_e( $_POST['sensei_reg_password'] );
1120
+}
1121
+?>" />
1108 1122
 						</p>
1109 1123
 
1110 1124
 						<!-- Spam Trap -->
@@ -1437,8 +1451,12 @@  discard block
 block discarded – undo
1437 1451
 
1438 1452
 		if( Sensei_WC::is_woocommerce_active() ) {
1439 1453
 
1440
-			if( ! is_user_logged_in() ) return;
1441
-			if( ! isset( $post->ID ) ) return;
1454
+			if( ! is_user_logged_in() ) {
1455
+				return;
1456
+			}
1457
+			if( ! isset( $post->ID ) ) {
1458
+				return;
1459
+			}
1442 1460
 
1443 1461
 			$user_id = $current_user->ID;
1444 1462
 			$course_id = $post->ID;
@@ -1599,7 +1617,7 @@  discard block
 block discarded – undo
1599 1617
 		    		//assigne the username to the creds array for further processing
1600 1618
 		    		$creds['user_login'] =  $user->user_login ;
1601 1619
 
1602
-		    	}else{
1620
+		    	} else{
1603 1621
 
1604 1622
 		    		// process this as a default username login
1605 1623
 		    		$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
@@ -1616,7 +1634,7 @@  discard block
 block discarded – undo
1616 1634
 				if ( is_wp_error($user) ){ // on login failure
1617 1635
                     wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1618 1636
                     exit;
1619
-				}else{ // on login success
1637
+				} else{ // on login success
1620 1638
 
1621 1639
 					/**
1622 1640
 					* change the redirect url programatically
@@ -1633,14 +1651,14 @@  discard block
 block discarded – undo
1633 1651
 
1634 1652
 				}	// end is_wp_error($user)
1635 1653
 
1636
-		    }else{ // if username or password is empty
1654
+		    } else{ // if username or password is empty
1637 1655
 
1638 1656
                 wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1639 1657
 		        exit;
1640 1658
 
1641 1659
 		    } // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1642 1660
 
1643
-	    }elseif( ( isset( $_GET['login'] ) ) ) {
1661
+	    } elseif( ( isset( $_GET['login'] ) ) ) {
1644 1662
 	    	// else if this request is a redircect from a previously faile login request
1645 1663
 	    	$this->login_message_process();
1646 1664
 
@@ -1762,7 +1780,7 @@  discard block
 block discarded – undo
1762 1780
 
1763 1781
 				$message = __('Incorrect login details', 'woothemes-sensei' );
1764 1782
 
1765
-			}elseif( $_GET['login'] == 'emptyfields'  ){
1783
+			} elseif( $_GET['login'] == 'emptyfields'  ){
1766 1784
 
1767 1785
 				$message= __('Please enter your username and password', 'woothemes-sensei' );
1768 1786
 			}
Please login to merge, or discard this patch.
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		// Only show course & lesson excerpts in search results
70 70
 		add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) );
71 71
 
72
-        //Use WooCommerce filter to show admin bar to Teachers.
73
-        add_action( 'init', array( $this, 'sensei_show_admin_bar') );
72
+		//Use WooCommerce filter to show admin bar to Teachers.
73
+		add_action( 'init', array( $this, 'sensei_show_admin_bar') );
74 74
 
75
-        // Remove course from active courses if an order is cancelled or refunded
75
+		// Remove course from active courses if an order is cancelled or refunded
76 76
 		add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
77 77
 		add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
78 78
 		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 			wp_enqueue_script( Sensei()->token . '-user-dashboard' );
134 134
 
135 135
 
136
-            // Course Archive javascript
137
-            if( is_post_type_archive( 'course' ) ){
136
+			// Course Archive javascript
137
+			if( is_post_type_archive( 'course' ) ){
138 138
 
139
-                wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true );
140
-                wp_enqueue_script( 'sensei-course-archive-js' );
139
+				wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true );
140
+				wp_enqueue_script( 'sensei-course-archive-js' );
141 141
 
142
-            }
142
+			}
143 143
 
144 144
 
145 145
 			// Allow additional scripts to be loaded
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	/**
181 181
 	 * sensei_get_template_part function.
182 182
 	 *
183
-     * @deprecated sine 1.9.0
183
+	 * @deprecated sine 1.9.0
184 184
 	 * @access public
185 185
 	 * @param mixed $slug
186 186
 	 * @param string $name (default: '')
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	function sensei_get_template_part( $slug, $name = '' ) {
190 190
 
191
-        _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' );
192
-        Sensei_Templates::get_part( $slug, $name );
191
+		_deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' );
192
+		Sensei_Templates::get_part( $slug, $name );
193 193
 
194 194
 	} // End sensei_get_template_part()
195 195
 
196 196
 	/**
197 197
 	 * sensei_get_template function.
198 198
 	 *
199
-     * @deprecated since 1.9.0
199
+	 * @deprecated since 1.9.0
200 200
 	 * @access public
201 201
 	 * @param mixed $template_name
202 202
 	 * @param array $args (default: array())
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
208 208
 
209
-        _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' );
210
-        Sensei_Templates::get_template($template_name, $args, $template_path, $default_path  );
209
+		_deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' );
210
+		Sensei_Templates::get_template($template_name, $args, $template_path, $default_path  );
211 211
 
212 212
 	} // End sensei_get_template()
213 213
 
@@ -223,33 +223,33 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) {
225 225
 
226
-        _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' );
227
-        Sensei_Templates::locate_template( $template_name, $template_path, $default_path );
226
+		_deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' );
227
+		Sensei_Templates::locate_template( $template_name, $template_path, $default_path );
228 228
 
229 229
 	} // End sensei_locate_template()
230 230
 
231 231
 
232 232
 	/**
233 233
 	 * sensei_output_content_wrapper function.
234
-     *
234
+	 *
235 235
 	 * @access public
236 236
 	 * @return void
237 237
 	 */
238 238
 	function sensei_output_content_wrapper() {
239 239
 
240
-	    // backwards compatibility check for old location under the wrappers directory of the active theme
241
-        $backwards_compatible_wrapper_location =   array(
242
-            Sensei()->template_url . 'wrappers/wrapper-start.php',
243
-            'wrappers/wrapper-start.php'
244
-        );
240
+		// backwards compatibility check for old location under the wrappers directory of the active theme
241
+		$backwards_compatible_wrapper_location =   array(
242
+			Sensei()->template_url . 'wrappers/wrapper-start.php',
243
+			'wrappers/wrapper-start.php'
244
+		);
245 245
 
246
-        $template = locate_template( $backwards_compatible_wrapper_location );
247
-        if( !empty( $template ) ){
246
+		$template = locate_template( $backwards_compatible_wrapper_location );
247
+		if( !empty( $template ) ){
248 248
 
249
-            Sensei_Templates::get_template( 'wrappers/wrapper-start.php' );
250
-            return;
249
+			Sensei_Templates::get_template( 'wrappers/wrapper-start.php' );
250
+			return;
251 251
 
252
-        }
252
+		}
253 253
 
254 254
 		Sensei_Templates::get_template( 'globals/wrapper-start.php' );
255 255
 
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
 
259 259
 	/**
260 260
 	 * sensei_output_content_wrapper_end function.
261
-     *
261
+	 *
262 262
 	 * @access public
263 263
 	 * @return void
264 264
 	 */
265 265
 	function sensei_output_content_wrapper_end() {
266 266
 
267
-	    // backwards compatibility check for old location under the wrappers directory of the active theme
268
-        $backwards_compatible_wrapper_location =   array(
269
-            Sensei()->template_url . 'wrappers/wrapper-end.php',
270
-            'wrappers/wrapper-end.php'
271
-        );
267
+		// backwards compatibility check for old location under the wrappers directory of the active theme
268
+		$backwards_compatible_wrapper_location =   array(
269
+			Sensei()->template_url . 'wrappers/wrapper-end.php',
270
+			'wrappers/wrapper-end.php'
271
+		);
272 272
 
273
-        $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location );
274
-        if( !empty( $backwards_compatible_template ) ){
273
+		$backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location );
274
+		if( !empty( $backwards_compatible_template ) ){
275 275
 
276
-            Sensei_Templates::get_template( 'wrappers/wrapper-end.php' );
277
-            return;
276
+			Sensei_Templates::get_template( 'wrappers/wrapper-end.php' );
277
+			return;
278 278
 
279
-        }
279
+		}
280 280
 
281 281
 
282 282
 		Sensei_Templates::get_template( 'globals/wrapper-end.php' );
@@ -292,55 +292,55 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public static function load_content_pagination() {
294 294
 
295
-        if( is_singular('course') ) {
295
+		if( is_singular('course') ) {
296 296
 
297
-            // backwards compatibility check for old location under the wrappers directory of the active theme
298
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) );
299
-            if( !empty( $template ) ){
297
+			// backwards compatibility check for old location under the wrappers directory of the active theme
298
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) );
299
+			if( !empty( $template ) ){
300 300
 
301
-                Sensei_Templates::get_template( 'wrappers/pagination-posts.php' );
302
-                return;
301
+				Sensei_Templates::get_template( 'wrappers/pagination-posts.php' );
302
+				return;
303 303
 
304
-            }
304
+			}
305 305
 
306 306
 			Sensei_Templates::get_template( 'globals/pagination-posts.php' );
307 307
 
308 308
 		} elseif( is_singular('lesson') ) {
309 309
 
310
-		    // backwards compatibility check for old location under the wrappers directory of the active theme
311
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) );
312
-            if( !empty( $template ) ){
310
+			// backwards compatibility check for old location under the wrappers directory of the active theme
311
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) );
312
+			if( !empty( $template ) ){
313 313
 
314
-                Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' );
315
-                return;
314
+				Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' );
315
+				return;
316 316
 
317
-            }
317
+			}
318 318
 
319 319
 			Sensei_Templates::get_template( 'globals/pagination-lesson.php' );
320 320
 
321 321
 		} elseif( is_singular('quiz') ) {
322 322
 
323
-		    // backwards compatibility check for old location under the wrappers directory of the active theme
324
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) );
325
-            if( !empty( $template ) ){
323
+			// backwards compatibility check for old location under the wrappers directory of the active theme
324
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) );
325
+			if( !empty( $template ) ){
326 326
 
327
-                Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' );
328
-                return;
327
+				Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' );
328
+				return;
329 329
 
330
-            }
330
+			}
331 331
 
332 332
 			Sensei_Templates::get_template( 'globals/pagination-quiz.php' );
333 333
 
334 334
 		} else {
335 335
 
336
-            // backwards compatibility check for old location under the wrappers directory of the active theme
337
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) );
338
-            if( !empty( $template ) ){
336
+			// backwards compatibility check for old location under the wrappers directory of the active theme
337
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) );
338
+			if( !empty( $template ) ){
339 339
 
340
-                Sensei_Templates::get_template( 'wrappers/pagination.php' );
341
-                return;
340
+				Sensei_Templates::get_template( 'wrappers/pagination.php' );
341
+				return;
342 342
 
343
-            }
343
+			}
344 344
 
345 345
 			Sensei_Templates::get_template( 'globals/pagination.php' );
346 346
 
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 
398 398
 				case '#senseimymessages':
399 399
 					$item->url = $my_messages_url;
400
-                    // if no archive link exist for sensei_message
401
-                    // set it back to the place holder
402
-                    if( ! $item->url ){
400
+					// if no archive link exist for sensei_message
401
+					// set it back to the place holder
402
+					if( ! $item->url ){
403 403
 
404
-                        $item->url = '#senseimymessages';
404
+						$item->url = '#senseimymessages';
405 405
 
406
-                    }
406
+					}
407 407
 					break;
408 408
 
409 409
 				case '#senseilearnerprofile':
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 			// Remove the My Messages link for logged out users or if Private Messages are disabled
471 471
 			if( ! get_post_type_archive_link( 'sensei_message' )
472
-                && '#senseimymessages' == $item->url ) {
472
+				&& '#senseimymessages' == $item->url ) {
473 473
 
474 474
 				if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) {
475 475
 
@@ -492,42 +492,42 @@  discard block
 block discarded – undo
492 492
 
493 493
 	// add category nicenames in body and post class
494 494
 	function sensei_search_results_classes($classes) {
495
-	    global $post;
496
-	    // Handle Search Classes for Courses, Lessons, and WC Products
497
-	    if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) {
498
-	    	$classes[] = 'post';
495
+		global $post;
496
+		// Handle Search Classes for Courses, Lessons, and WC Products
497
+		if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) {
498
+			$classes[] = 'post';
499 499
 		} // End If Statement
500
-	    return $classes;
500
+		return $classes;
501 501
 	} // End sensei_search_results_classes()
502 502
 
503
-    /**
504
-     * sensei_single_title output for single page title
505
-     * @since  1.1.0
506
-     * @return void
507
-     * @deprecated
508
-     */
509
-    function the_single_title() {
503
+	/**
504
+	 * sensei_single_title output for single page title
505
+	 * @since  1.1.0
506
+	 * @return void
507
+	 * @deprecated
508
+	 */
509
+	function the_single_title() {
510 510
 
511
-        _deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0');
511
+		_deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0');
512 512
 
513
-    } // End sensei_single_title()
513
+	} // End sensei_single_title()
514 514
 
515 515
 	/**
516 516
 	 * sensei_course_image output for course image Please use Sensei()->course->course_image instead.
517
-     *
518
-     * @deprecated since 1.9.0
519
-     * @param $course_id
520
-     * @param string $width
521
-     * @param string $height
522
-     * @param bool|false $return
523
-     * @return string|void
517
+	 *
518
+	 * @deprecated since 1.9.0
519
+	 * @param $course_id
520
+	 * @param string $width
521
+	 * @param string $height
522
+	 * @param bool|false $return
523
+	 * @return string|void
524 524
 	 */
525 525
 	function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) {
526 526
 
527
-    	if ( ! $return ) {
527
+		if ( ! $return ) {
528 528
 
529 529
 			echo Sensei()->course->course_image( $course_id, $width, $height );
530
-            return '';
530
+			return '';
531 531
 
532 532
 		} // End If Statement
533 533
 
@@ -538,31 +538,31 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * sensei_lesson_image output for lesson image
540 540
 	 * @since  1.2.0
541
-     * @deprecated since 1.9.0
542
-     * @param $lesson_id
543
-     * @param string $width
544
-     * @param string $height
545
-     * @param bool|false $return
546
-     * @param bool|false $widget
547
-     * @return string
541
+	 * @deprecated since 1.9.0
542
+	 * @param $lesson_id
543
+	 * @param string $width
544
+	 * @param string $height
545
+	 * @param bool|false $return
546
+	 * @param bool|false $widget
547
+	 * @return string
548 548
 	 */
549 549
 	function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) {
550 550
 
551
-        if( ! $return ){
551
+		if( ! $return ){
552 552
 
553
-            echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
554
-            return '';
555
-        }
553
+			echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
554
+			return '';
555
+		}
556 556
 
557
-        return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
557
+		return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
558 558
 
559 559
 	} // End sensei_lesson_image()
560 560
 
561
-    /**
562
-     * @since 1.0.0
563
-     * @param WP_Query $query
564
-     */
565
-    function sensei_course_archive_pagination( $query ) {
561
+	/**
562
+	 * @since 1.0.0
563
+	 * @param WP_Query $query
564
+	 */
565
+	function sensei_course_archive_pagination( $query ) {
566 566
 
567 567
 		if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) {
568 568
 
@@ -585,50 +585,50 @@  discard block
 block discarded – undo
585 585
 	 *
586 586
 	 * @access public
587 587
 	 * @since  1.2.0
588
-     * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header
588
+	 * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header
589 589
 	 * @return void
590 590
 	 */
591 591
 	function sensei_course_archive_header(  ) {
592 592
 
593
-        trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header ');
594
-        WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' );
593
+		trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header ');
594
+		WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' );
595 595
 
596 596
 	} // sensei_course_archive_header()
597 597
 
598 598
 	/**
599 599
 	 * sensei_lesson_archive_header function.
600 600
 	 *
601
-     * @deprecated since 1.9.0
601
+	 * @deprecated since 1.9.0
602 602
 	 * @access public
603 603
 	 * @since  1.2.1
604 604
 	 * @return void
605 605
 	 */
606 606
 	public function sensei_lesson_archive_header( ) {
607
-        _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' );
608
-        Sensei()->lesson->the_archive_header();
607
+		_deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' );
608
+		Sensei()->lesson->the_archive_header();
609 609
 	} // sensei_course_archive_header()
610 610
 
611
-    /**
612
-     * @deprecated since 1.9.0
613
-     */
611
+	/**
612
+	 * @deprecated since 1.9.0
613
+	 */
614 614
 	public function sensei_message_archive_header( ){
615
-        _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
616
-        Sensei_Messages::the_archive_header();
615
+		_deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
616
+		Sensei_Messages::the_archive_header();
617 617
 	} // sensei_message_archive_header()
618 618
 
619 619
 	/**
620 620
 	 * sensei_course_archive_course_title output for course archive page individual course title
621 621
 	 * @since  1.2.0
622
-     * @param WP_Post $post_item
622
+	 * @param WP_Post $post_item
623 623
 	 * @return void
624 624
 	 */
625 625
 	function sensei_course_archive_course_title( $post_item ) {
626 626
 		if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) {
627 627
 			$post_id = absint( $post_item->ID );
628
-    		$post_title = $post_item->post_title;
628
+			$post_title = $post_item->post_title;
629 629
 		} else {
630 630
 			$post_id = get_the_ID();
631
-    		$post_title = get_the_title();
631
+			$post_title = get_the_title();
632 632
 		} // End If Statement
633 633
 		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
634 634
 	} // End sensei_course_archive_course_title()
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 */
641 641
 	public function sensei_lesson_archive_lesson_title() {
642 642
 		$post_id = get_the_ID();
643
-    	$post_title = get_the_title();
643
+		$post_title = get_the_title();
644 644
 		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
645 645
 	} // End sensei_lesson_archive_lesson_title()
646 646
 
@@ -657,9 +657,9 @@  discard block
 block discarded – undo
657 657
 
658 658
 		if( empty( $id )  ){
659 659
 
660
-            $id = get_the_ID();
660
+			$id = get_the_ID();
661 661
 
662
-        }
662
+		}
663 663
 
664 664
 		$sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' );
665 665
 		$separator = apply_filters( 'sensei_breadcrumb_separator', '&gt;' );
@@ -672,31 +672,31 @@  discard block
 block discarded – undo
672 672
 				return;
673 673
 			}
674 674
 			$html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>';
675
-    	} // End If Statement
676
-    	// Quiz
675
+		} // End If Statement
676
+		// Quiz
677 677
 		if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) {
678 678
 			$lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) );
679 679
 			if( ! $lesson_id ) {
680 680
 				return;
681 681
 			}
682 682
 			 $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' .  __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>';
683
-    	} // End If Statement
683
+		} // End If Statement
684 684
 
685
-    	// Allow other plugins to filter html
686
-    	$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
687
-    	$html .= '</section>';
685
+		// Allow other plugins to filter html
686
+		$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
687
+		$html .= '</section>';
688 688
 
689
-    	echo $html;
689
+		echo $html;
690 690
 	} // End sensei_breadcrumb()
691 691
 
692 692
 
693
-    /**
694
-     * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead
695
-     */
693
+	/**
694
+	 * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead
695
+	 */
696 696
 	public function sensei_lesson_course_signup_link( ) {
697 697
 
698
-        _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' );
699
-        WooThemes_Sensei_Lesson::course_signup_link();
698
+		_deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' );
699
+		WooThemes_Sensei_Lesson::course_signup_link();
700 700
 	}
701 701
 
702 702
 	public function lesson_tags_display( $lesson_id = 0 ) {
@@ -715,27 +715,27 @@  discard block
 block discarded – undo
715 715
 					?><section class="lesson-tags">
716 716
 		    			<?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?>
717 717
 		    		</section><?php
718
-		    	}
719
-	    	}
718
+				}
719
+			}
720 720
 		}
721 721
 	}
722 722
 
723
-    /**
724
-     * @param WP_Query $query
725
-     */
723
+	/**
724
+	 * @param WP_Query $query
725
+	 */
726 726
 	public function lesson_tag_archive_filter( $query ) {
727
-    	if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
728
-    		// Limit to lessons only
729
-    		$query->set( 'post_type', 'lesson' );
727
+		if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
728
+			// Limit to lessons only
729
+			$query->set( 'post_type', 'lesson' );
730 730
 
731
-    		// Set order of lessons
732
-    		$query->set( 'orderby', 'menu_order' );
733
-    		$query->set( 'order', 'ASC' );
731
+			// Set order of lessons
732
+			$query->set( 'orderby', 'menu_order' );
733
+			$query->set( 'order', 'ASC' );
734 734
 
735
-    	}
736
-    }
735
+		}
736
+	}
737 737
 
738
-    public function lesson_tag_archive_header( $title ) {
738
+	public function lesson_tag_archive_header( $title ) {
739 739
 		if( is_tax( 'lesson-tag' ) ) {
740 740
 			$title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) );
741 741
 		}
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 			$sanitized_submit = esc_html( $_POST['quiz_action'] );
758 758
 
759 759
 			switch ($sanitized_submit) {
760
-                case 'lesson-complete':
760
+				case 'lesson-complete':
761 761
 
762 762
 					Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true );
763 763
 
764 764
 					break;
765 765
 
766
-                case 'lesson-reset':
766
+				case 'lesson-reset':
767 767
 
768 768
 					Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID );
769 769
 
@@ -875,13 +875,13 @@  discard block
 block discarded – undo
875 875
 		if ( 0 < intval( $post_id ) ) {
876 876
 			$lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true );
877 877
 			if ( 'http' == substr( $lesson_video_embed, 0, 4) ) {
878
-        		// V2 - make width and height a setting for video embed
879
-        		$lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ );
880
-        	} // End If Statement
881
-        	if ( '' != $lesson_video_embed ) {
882
-        	?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883
-        	} // End If Statement
884
-        } // End If Statement
878
+				// V2 - make width and height a setting for video embed
879
+				$lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ );
880
+			} // End If Statement
881
+			if ( '' != $lesson_video_embed ) {
882
+			?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883
+			} // End If Statement
884
+		} // End If Statement
885 885
 	} // End sensei_lesson_video()
886 886
 
887 887
 	public function sensei_complete_lesson_button() {
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 		$pass_required = true;
895 895
 		if( $quiz_id ) {
896 896
 			// Get quiz pass setting
897
-	    	$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
898
-	    }
897
+			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
898
+		}
899 899
 		if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) {
900 900
 			?>
901 901
 			<form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
@@ -948,12 +948,12 @@  discard block
 block discarded – undo
948 948
 		} // End If Statement
949 949
 	} // End sensei_reset_lesson_button()
950 950
 
951
-    /**
952
-     * @deprecated since 1.9.0
953
-     */
954
-    public function sensei_lesson_quiz_meta( ) {
951
+	/**
952
+	 * @deprecated since 1.9.0
953
+	 */
954
+	public function sensei_lesson_quiz_meta( ) {
955 955
 
956
-        Sensei_Lesson::footer_quiz_call_to_action();
956
+		Sensei_Lesson::footer_quiz_call_to_action();
957 957
 
958 958
 	} // End sensei_lesson_quiz_meta()
959 959
 
@@ -979,38 +979,38 @@  discard block
 block discarded – undo
979 979
         	</p>
980 980
         	<p class="course-excerpt"><?php the_excerpt(); ?></p>
981 981
         	<?php if ( 0 < $free_lesson_count ) {
982
-                $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
982
+				$free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
983 983
                 <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p>
984 984
             <?php } ?>
985 985
 		</section><?php
986 986
 	} // End sensei_course_archive_meta()
987 987
 
988
-    /**
989
-     * @deprecated since 1.9.0
990
-     */
988
+	/**
989
+	 * @deprecated since 1.9.0
990
+	 */
991 991
 	public function sensei_single_main_content() {
992
-	    _deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0');
992
+		_deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0');
993 993
 	} // End sensei_single_main_content()
994 994
 
995
-    /**
996
-    * @deprecated since 1.9.0
997
-    */
995
+	/**
996
+	 * @deprecated since 1.9.0
997
+	 */
998 998
 	public function sensei_lesson_archive_main_content() {
999
-        _deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly');
999
+		_deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly');
1000 1000
 	} // End sensei_lesson_archive_main_content()
1001 1001
 
1002
-    /**
1003
-    * @deprecated since 1.9.0
1004
-    */
1002
+	/**
1003
+	 * @deprecated since 1.9.0
1004
+	 */
1005 1005
 	public function sensei_message_archive_main_content() {
1006 1006
 		_deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' );
1007 1007
 	} // End sensei_lesson_archive_main_content()
1008 1008
 
1009
-    /**
1010
-    * @deprecated since 1.9.0
1011
-    */
1009
+	/**
1010
+	 * @deprecated since 1.9.0
1011
+	 */
1012 1012
 	public function sensei_no_permissions_main_content() {
1013
-        _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' );
1013
+		_deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' );
1014 1014
 	} // End sensei_no_permissions_main_content()
1015 1015
 
1016 1016
 	public function sensei_course_category_main_content() {
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 				<div class="col-1">
1059 1059
 					<?php
1060 1060
 					// output the actual form markup
1061
-                    Sensei_Templates::get_template( 'user/login-form.php');
1061
+					Sensei_Templates::get_template( 'user/login-form.php');
1062 1062
 					?>
1063 1063
 				</div>
1064 1064
 
@@ -1139,12 +1139,12 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		//if this is a paid course
1141 1141
 		if ( Sensei_WC::is_woocommerce_active() ) {
1142
-    	    $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
1143
-    	    if ( 0 < $wc_post_id ) {
1144
-    	    	$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
1145
-    	    } // End If Statement
1146
-    	}
1147
-    	return $preview_text;
1142
+			$wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
1143
+			if ( 0 < $wc_post_id ) {
1144
+				$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
1145
+			} // End If Statement
1146
+		}
1147
+		return $preview_text;
1148 1148
 	}
1149 1149
 
1150 1150
 	public function sensei_lesson_preview_title( $title = '', $id = 0 ) {
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 		$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
1177 1177
 		// Handle user starting the course
1178 1178
 		if ( isset( $_POST['course_start'] )
1179
-		    && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' )
1180
-		    && !$is_user_taking_course ) {
1179
+			&& wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' )
1180
+			&& !$is_user_taking_course ) {
1181 1181
 
1182 1182
 			// Start the course
1183 1183
 			$activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID );
@@ -1196,35 +1196,35 @@  discard block
 block discarded – undo
1196 1196
 		} // End If Statement
1197 1197
 	} // End sensei_course_start()
1198 1198
 
1199
-    /**
1200
-     * @deprecated since 1.9.0
1201
-     */
1199
+	/**
1200
+	 * @deprecated since 1.9.0
1201
+	 */
1202 1202
 	public function sensei_course_meta() {
1203
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' );
1204
-        Sensei()->course->the_course_meta( get_post() );
1203
+		_deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' );
1204
+		Sensei()->course->the_course_meta( get_post() );
1205 1205
 	} // End sensei_course_meta()
1206 1206
 
1207
-    /**
1208
-     * @deprecated since 1.9.0
1209
-     */
1207
+	/**
1208
+	 * @deprecated since 1.9.0
1209
+	 */
1210 1210
 	public function sensei_course_meta_video() {
1211
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' );
1212
-        Sensei_Course::the_course_video();
1211
+		_deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' );
1212
+		Sensei_Course::the_course_video();
1213 1213
 	} // End sensei_course_meta_video()
1214 1214
 
1215
-    /**
1216
-     * This function shows the WooCommerce cart notice if the user has
1217
-     * added the current course to cart. It does not show if the user is already taking
1218
-     * the course.
1219
-     *
1220
-     * @since 1.0.2
1221
-     * @return void;
1222
-     */
1223
-    public function sensei_woocommerce_in_cart_message() {
1215
+	/**
1216
+	 * This function shows the WooCommerce cart notice if the user has
1217
+	 * added the current course to cart. It does not show if the user is already taking
1218
+	 * the course.
1219
+	 *
1220
+	 * @since 1.0.2
1221
+	 * @return void;
1222
+	 */
1223
+	public function sensei_woocommerce_in_cart_message() {
1224 1224
 		global $post, $woocommerce;
1225 1225
 
1226 1226
 		$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
1227
-        $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() );
1227
+		$user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() );
1228 1228
 		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
1229 1229
 
1230 1230
 			if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) {
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 				$item_id = $item['product_id'];
1273 1273
 			} 
1274 1274
 
1275
-            if ( $item_id > 0 ) {
1275
+			if ( $item_id > 0 ) {
1276 1276
 
1277 1277
 				$user_id = get_post_meta( $order_id, '_customer_user', true );
1278 1278
 
@@ -1352,15 +1352,15 @@  discard block
 block discarded – undo
1352 1352
 
1353 1353
 					$items = $order->get_items();
1354 1354
 					foreach( $items as $item ) {
1355
-                                            if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356
-                                                $item_id = $item['variation_id'];
1357
-                                                $product_type = 'variation';
1358
-                                            } else {
1359
-                                                $item_id = $item['product_id'];
1360
-                                            }
1355
+											if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356
+												$item_id = $item['variation_id'];
1357
+												$product_type = 'variation';
1358
+											} else {
1359
+												$item_id = $item['product_id'];
1360
+											}
1361 1361
 
1362
-                                            $product_ids[] = $item_id;
1363
-                                            }
1362
+											$product_ids[] = $item_id;
1363
+											}
1364 1364
 
1365 1365
 					$order_ids[] = $post_id;
1366 1366
 				}
@@ -1468,32 +1468,32 @@  discard block
 block discarded – undo
1468 1468
 				$items = $order->get_items();
1469 1469
 				foreach( $items as $item ) {
1470 1470
 
1471
-                    $product = wc_get_product( $item['product_id'] );
1471
+					$product = wc_get_product( $item['product_id'] );
1472 1472
 
1473
-                    // handle product bundles
1474
-                    if( is_object( $product ) &&  $product->is_type('bundle') ){
1473
+					// handle product bundles
1474
+					if( is_object( $product ) &&  $product->is_type('bundle') ){
1475 1475
 
1476
-                        $bundled_product = new WC_Product_Bundle( $product->id );
1477
-                        $bundled_items = $bundled_product->get_bundled_items();
1476
+						$bundled_product = new WC_Product_Bundle( $product->id );
1477
+						$bundled_items = $bundled_product->get_bundled_items();
1478 1478
 
1479
-                        foreach( $bundled_items as $bundled_item ){
1479
+						foreach( $bundled_items as $bundled_item ){
1480 1480
 
1481
-                            if( $bundled_item->product_id == $course_product_id ) {
1482
-                                Sensei_Utils::user_start_course( $user_id, $course_id );
1483
-                                return;
1484
-                            }
1481
+							if( $bundled_item->product_id == $course_product_id ) {
1482
+								Sensei_Utils::user_start_course( $user_id, $course_id );
1483
+								return;
1484
+							}
1485 1485
 
1486
-                        }
1486
+						}
1487 1487
 
1488
-                    } else {
1488
+					} else {
1489 1489
 
1490
-                    // handle regular products
1491
-                        if( $item['product_id'] == $course_product_id ) {
1492
-                            Sensei_Utils::user_start_course( $user_id, $course_id );
1493
-                            return;
1494
-                        }
1490
+					// handle regular products
1491
+						if( $item['product_id'] == $course_product_id ) {
1492
+							Sensei_Utils::user_start_course( $user_id, $course_id );
1493
+							return;
1494
+						}
1495 1495
 
1496
-                    }
1496
+					}
1497 1497
 				}
1498 1498
 			}
1499 1499
 
@@ -1524,21 +1524,21 @@  discard block
 block discarded – undo
1524 1524
 
1525 1525
 		//if not posted from the sensei login form let
1526 1526
 		// WordPress or any other party handle the failed request
1527
-	    if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form']  ){
1527
+		if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form']  ){
1528 1528
 
1529
-	    	return ;
1529
+			return ;
1530 1530
 
1531
-	    }
1531
+		}
1532 1532
 
1533
-    	// Get the reffering page, where did the post submission come from?
1534
-    	$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);
1533
+		// Get the reffering page, where did the post submission come from?
1534
+		$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);
1535 1535
 
1536 1536
    		 // if there's a valid referrer, and it's not the default log-in screen
1537
-	    if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
1538
-	        // let's append some information (login=failed) to the URL for the theme to use
1539
-	        wp_redirect( esc_url_raw( add_query_arg('login', 'failed',  $referrer) ) );
1540
-	    	exit;
1541
-    	}
1537
+		if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
1538
+			// let's append some information (login=failed) to the URL for the theme to use
1539
+			wp_redirect( esc_url_raw( add_query_arg('login', 'failed',  $referrer) ) );
1540
+			exit;
1541
+		}
1542 1542
 	}// End sensei_login_fail_redirect_to_front_end_login
1543 1543
 
1544 1544
 	/**
@@ -1549,92 +1549,92 @@  discard block
 block discarded – undo
1549 1549
 	function sensei_handle_login_request( ) {
1550 1550
 
1551 1551
 		// Check that it is a sensei login request and if it has a valid nonce
1552
-	    if(  isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) {
1552
+		if(  isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) {
1553 1553
 
1554
-	    	// Validate the login request nonce
1555
-		    if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1556
-		    	return;
1557
-		    }
1554
+			// Validate the login request nonce
1555
+			if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1556
+				return;
1557
+			}
1558 1558
 
1559
-		    //get the page where the sensei log form is located
1560
-		    $referrer = $_REQUEST['_wp_http_referer'];
1561
-		    //$redirect = $_REQUEST['_sensei_redirect'];
1559
+			//get the page where the sensei log form is located
1560
+			$referrer = $_REQUEST['_wp_http_referer'];
1561
+			//$redirect = $_REQUEST['_sensei_redirect'];
1562 1562
 
1563
-		    if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
1564
-		    	 && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){
1563
+			if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
1564
+				 && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){
1565 1565
 
1566
-		    	// when the user has entered a password or username do the sensei login
1567
-		    	$creds = array();
1566
+				// when the user has entered a password or username do the sensei login
1567
+				$creds = array();
1568 1568
 
1569
-		    	// check if the requests login is an email address
1570
-		    	if( is_email(  trim( $_REQUEST['log'] ) )  ){
1571
-		    		// query wordpress for the users details
1572
-		    		$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1569
+				// check if the requests login is an email address
1570
+				if( is_email(  trim( $_REQUEST['log'] ) )  ){
1571
+					// query wordpress for the users details
1572
+					$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1573 1573
 
1574
-		    		// validate the user object
1575
-		    		if( !$user ){
1574
+					// validate the user object
1575
+					if( !$user ){
1576 1576
 
1577
-		    			// the email doesnt exist
1578
-                        wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1579
-		        		exit;
1577
+						// the email doesnt exist
1578
+						wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1579
+						exit;
1580 1580
 
1581
-		    		}
1581
+					}
1582 1582
 
1583
-		    		//assigne the username to the creds array for further processing
1584
-		    		$creds['user_login'] =  $user->user_login ;
1583
+					//assigne the username to the creds array for further processing
1584
+					$creds['user_login'] =  $user->user_login ;
1585 1585
 
1586
-		    	}else{
1586
+				}else{
1587 1587
 
1588
-		    		// process this as a default username login
1589
-		    		$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
1588
+					// process this as a default username login
1589
+					$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
1590 1590
 
1591
-		    	}
1591
+				}
1592 1592
 
1593 1593
 				// get setup the rest of the creds array
1594 1594
 				$creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] );
1595 1595
 				$creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ;
1596 1596
 
1597 1597
 				//attempt logging in with the given details
1598
-			    $secure_cookie = is_ssl() ? true : false;
1599
-			    $user = wp_signon( $creds, $secure_cookie );
1598
+				$secure_cookie = is_ssl() ? true : false;
1599
+				$user = wp_signon( $creds, $secure_cookie );
1600 1600
 
1601 1601
 				if ( is_wp_error($user) ){ // on login failure
1602
-                    wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1603
-                    exit;
1602
+					wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1603
+					exit;
1604 1604
 				}else{ // on login success
1605 1605
 
1606 1606
 					/**
1607
-					* change the redirect url programatically
1608
-					*
1609
-					* @since 1.6.1
1610
-					*
1611
-					* @param string $referrer the page where the current url wheresensei login form was posted from
1612
-					*/
1607
+					 * change the redirect url programatically
1608
+					 *
1609
+					 * @since 1.6.1
1610
+					 *
1611
+					 * @param string $referrer the page where the current url wheresensei login form was posted from
1612
+					 */
1613 1613
 
1614 1614
 					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) );
1615 1615
 
1616 1616
 					wp_redirect( esc_url_raw( $success_redirect_url ) );
1617
-		        	exit;
1617
+					exit;
1618 1618
 
1619 1619
 				}	// end is_wp_error($user)
1620 1620
 
1621
-		    }else{ // if username or password is empty
1621
+			}else{ // if username or password is empty
1622 1622
 
1623
-                wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1624
-		        exit;
1623
+				wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1624
+				exit;
1625 1625
 
1626
-		    } // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1626
+			} // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1627 1627
 
1628
-	    }elseif( ( isset( $_GET['login'] ) ) ) {
1629
-	    	// else if this request is a redircect from a previously faile login request
1630
-	    	$this->login_message_process();
1628
+		}elseif( ( isset( $_GET['login'] ) ) ) {
1629
+			// else if this request is a redircect from a previously faile login request
1630
+			$this->login_message_process();
1631 1631
 
1632 1632
 			//exit the handle login request function
1633 1633
 			return;
1634
-	    }
1634
+		}
1635 1635
 
1636
-	    // if none of the above
1637
-	    return;
1636
+		// if none of the above
1637
+		return;
1638 1638
 
1639 1639
 	} // End  sensei_login_fail_redirect_to_front_end_login
1640 1640
 
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 	 */
1738 1738
 	public function login_message_process(){
1739 1739
 
1740
-            // setup the message variables
1740
+			// setup the message variables
1741 1741
 			$message = '';
1742 1742
 
1743 1743
 			//only output message if the url contains login=failed and login=emptyfields
@@ -1756,22 +1756,22 @@  discard block
 block discarded – undo
1756 1756
 	}// end login_message_process
1757 1757
 
1758 1758
 
1759
-    /**
1760
-     * sensei_show_admin_bar(). Use WooCommerce filter
1761
-     * to show admin bar to Teachers as well.
1762
-     *
1763
-     * @return void redirect
1764
-     *
1765
-     */
1766
-    public function sensei_show_admin_bar () {
1759
+	/**
1760
+	 * sensei_show_admin_bar(). Use WooCommerce filter
1761
+	 * to show admin bar to Teachers as well.
1762
+	 *
1763
+	 * @return void redirect
1764
+	 *
1765
+	 */
1766
+	public function sensei_show_admin_bar () {
1767 1767
 
1768
-        if (current_user_can('edit_courses')) {
1768
+		if (current_user_can('edit_courses')) {
1769 1769
 
1770
-            add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1);
1770
+			add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1);
1771 1771
 
1772
-        }
1772
+		}
1773 1773
 
1774
-    }
1774
+	}
1775 1775
 
1776 1776
 } // End Class
1777 1777
 
Please login to merge, or discard this patch.
Spacing   +450 added lines, -450 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Frontend Class
@@ -20,78 +20,78 @@  discard block
 block discarded – undo
20 20
 	 * Constructor.
21 21
 	 * @since  1.0.0
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 
25 25
 		// Template output actions
26
-		add_action( 'sensei_before_main_content', array( $this, 'sensei_output_content_wrapper' ), 10 );
27
-		add_action( 'sensei_after_main_content', array( $this, 'sensei_output_content_wrapper_end' ), 10 );
28
-		add_action( 'sensei_lesson_archive_lesson_title', array( $this, 'sensei_lesson_archive_lesson_title' ), 10 );
26
+		add_action('sensei_before_main_content', array($this, 'sensei_output_content_wrapper'), 10);
27
+		add_action('sensei_after_main_content', array($this, 'sensei_output_content_wrapper_end'), 10);
28
+		add_action('sensei_lesson_archive_lesson_title', array($this, 'sensei_lesson_archive_lesson_title'), 10);
29 29
 
30 30
 		// 1.2.1
31
-		add_action( 'wp_head', array( $this, 'sensei_complete_lesson' ), 10 );
32
-		add_action( 'wp_head', array( $this, 'sensei_complete_course' ), 10 );
33
-		add_action( 'sensei_frontend_messages', array( $this, 'sensei_frontend_messages' ) );
34
-		add_action( 'sensei_lesson_video', array( $this, 'sensei_lesson_video' ), 10, 1 );
35
-		add_action( 'sensei_complete_lesson_button', array( $this, 'sensei_complete_lesson_button' ) );
36
-		add_action( 'sensei_reset_lesson_button', array( $this, 'sensei_reset_lesson_button' ) );
31
+		add_action('wp_head', array($this, 'sensei_complete_lesson'), 10);
32
+		add_action('wp_head', array($this, 'sensei_complete_course'), 10);
33
+		add_action('sensei_frontend_messages', array($this, 'sensei_frontend_messages'));
34
+		add_action('sensei_lesson_video', array($this, 'sensei_lesson_video'), 10, 1);
35
+		add_action('sensei_complete_lesson_button', array($this, 'sensei_complete_lesson_button'));
36
+		add_action('sensei_reset_lesson_button', array($this, 'sensei_reset_lesson_button'));
37 37
 
38
-		add_action( 'sensei_course_archive_meta', array( $this, 'sensei_course_archive_meta' ) );
38
+		add_action('sensei_course_archive_meta', array($this, 'sensei_course_archive_meta'));
39 39
 
40
-		add_action( 'sensei_lesson_tag_main_content', array( $this, 'sensei_lesson_archive_main_content' ), 10 );
41
-		add_action( 'sensei_no_permissions_main_content', array( $this, 'sensei_no_permissions_main_content' ), 10 );
40
+		add_action('sensei_lesson_tag_main_content', array($this, 'sensei_lesson_archive_main_content'), 10);
41
+		add_action('sensei_no_permissions_main_content', array($this, 'sensei_no_permissions_main_content'), 10);
42 42
 
43
-		add_action( 'sensei_lesson_meta', array( $this, 'sensei_lesson_meta' ), 10 );
44
-		add_action( 'sensei_single_course_content_inside_before', array( $this, 'sensei_course_start' ), 10 );
43
+		add_action('sensei_lesson_meta', array($this, 'sensei_lesson_meta'), 10);
44
+		add_action('sensei_single_course_content_inside_before', array($this, 'sensei_course_start'), 10);
45 45
 
46 46
 		// add_filter( 'get_comments_number', array( $this, 'sensei_lesson_comment_count' ), 1 );
47
-		add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 );
47
+		add_filter('the_title', array($this, 'sensei_lesson_preview_title'), 10, 2);
48 48
 
49 49
 		//1.6.2
50
-		add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 );
51
-		add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 );
50
+		add_filter('wp_login_failed', array($this, 'sensei_login_fail_redirect'), 10);
51
+		add_filter('init', array($this, 'sensei_handle_login_request'), 10);
52 52
 		//1.6.3
53
-		add_action( 'init', array( $this, 'sensei_process_registration' ), 2 );
53
+		add_action('init', array($this, 'sensei_process_registration'), 2);
54 54
 		//1.7.0
55
-		add_action( 'sensei_pagination', array( $this, 'sensei_breadcrumb' ), 80, 1 );
55
+		add_action('sensei_pagination', array($this, 'sensei_breadcrumb'), 80, 1);
56 56
 
57 57
 		// Fix pagination for course archive pages when filtering by course type
58
-		add_filter( 'pre_get_posts', array( $this, 'sensei_course_archive_pagination' ) );
58
+		add_filter('pre_get_posts', array($this, 'sensei_course_archive_pagination'));
59 59
 
60 60
 		// Scripts and Styles
61
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
62
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
61
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
62
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
63 63
 
64 64
 		// Custom Menu Item filters
65
-		add_filter( 'wp_setup_nav_menu_item', array( $this, 'sensei_setup_nav_menu_item' ) );
66
-		add_filter( 'wp_nav_menu_objects', array( $this, 'sensei_wp_nav_menu_objects' ) );
65
+		add_filter('wp_setup_nav_menu_item', array($this, 'sensei_setup_nav_menu_item'));
66
+		add_filter('wp_nav_menu_objects', array($this, 'sensei_wp_nav_menu_objects'));
67 67
 		// Search Results filters
68
-		add_filter( 'post_class', array( $this, 'sensei_search_results_classes' ), 10 );
68
+		add_filter('post_class', array($this, 'sensei_search_results_classes'), 10);
69 69
 		// Only show course & lesson excerpts in search results
70
-		add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) );
70
+		add_filter('the_content', array($this, 'sensei_search_results_excerpt'));
71 71
 
72 72
         //Use WooCommerce filter to show admin bar to Teachers.
73
-        add_action( 'init', array( $this, 'sensei_show_admin_bar') );
73
+        add_action('init', array($this, 'sensei_show_admin_bar'));
74 74
 
75 75
         // Remove course from active courses if an order is cancelled or refunded
76
-		add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
77
-		add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
78
-		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
79
-		add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
80
-		add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
81
-		add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
76
+		add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'remove_active_course'), 10, 1);
77
+		add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'remove_active_course'), 10, 1);
78
+		add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'remove_active_course'), 10, 1);
79
+		add_action('woocommerce_order_status_processing_to_refunded', array($this, 'remove_active_course'), 10, 1);
80
+		add_action('woocommerce_order_status_completed_to_refunded', array($this, 'remove_active_course'), 10, 1);
81
+		add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'remove_active_course'), 10, 1);
82 82
 
83 83
 		// Make sure correct courses are marked as active for users
84
-		add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 );
85
-		add_action( 'sensei_single_course_content_inside_before', array( $this, 'activate_purchased_single_course' ), 10 );
84
+		add_action('sensei_before_my_courses', array($this, 'activate_purchased_courses'), 10, 1);
85
+		add_action('sensei_single_course_content_inside_before', array($this, 'activate_purchased_single_course'), 10);
86 86
 
87 87
 		// Lesson tags
88
-		add_action( 'sensei_lesson_meta_extra', array( $this, 'lesson_tags_display' ), 10, 1 );
89
-		add_action( 'pre_get_posts', array( $this, 'lesson_tag_archive_filter' ), 10, 1 );
90
-		add_filter( 'sensei_lessons_archive_text', array( $this, 'lesson_tag_archive_header' ) );
91
-		add_action( 'sensei_loop_lesson_inside_before', array( $this, 'lesson_tag_archive_description' ), 11 );
88
+		add_action('sensei_lesson_meta_extra', array($this, 'lesson_tags_display'), 10, 1);
89
+		add_action('pre_get_posts', array($this, 'lesson_tag_archive_filter'), 10, 1);
90
+		add_filter('sensei_lessons_archive_text', array($this, 'lesson_tag_archive_header'));
91
+		add_action('sensei_loop_lesson_inside_before', array($this, 'lesson_tag_archive_description'), 11);
92 92
 
93 93
 		// Hide Sensei activity comments from lesson and course pages
94
-		add_filter( 'wp_list_comments_args', array( $this, 'hide_sensei_activity' ) );
94
+		add_filter('wp_list_comments_args', array($this, 'hide_sensei_activity'));
95 95
 	} // End __construct()
96 96
 
97 97
 	/**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @since  1.7.3
102 102
 	 * @return array|mixed
103 103
 	 */
104
-	public function __get( $key ) {
104
+	public function __get($key) {
105 105
 
106
-		if ( 'lesson' == $key || 'course' == $key ) {
107
-			if ( WP_DEBUG ) {
108
-				trigger_error( sprintf( 'Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3' ) );
106
+		if ('lesson' == $key || 'course' == $key) {
107
+			if (WP_DEBUG) {
108
+				trigger_error(sprintf('Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3'));
109 109
 			}
110 110
 			return Sensei()->$key;
111 111
 		}
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
 	 * @since  1.0.0
119 119
 	 * @return void
120 120
 	 */
121
-	public function enqueue_scripts () {
121
+	public function enqueue_scripts() {
122 122
 
123 123
 		$disable_js = false;
124
-		if ( isset( Sensei()->settings->settings[ 'js_disable' ] ) ) {
125
-			$disable_js = Sensei()->settings->settings[ 'js_disable' ];
124
+		if (isset(Sensei()->settings->settings['js_disable'])) {
125
+			$disable_js = Sensei()->settings->settings['js_disable'];
126 126
 		} // End If Statement
127
-		if ( ! $disable_js ) {
127
+		if ( ! $disable_js) {
128 128
 
129
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
129
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
130 130
 
131 131
 			// My Courses tabs script
132
-			wp_register_script( Sensei()->token . '-user-dashboard', esc_url( Sensei()->plugin_url . 'assets/js/user-dashboard' . $suffix . '.js' ), array( 'jquery-ui-tabs' ), Sensei()->version, true );
133
-			wp_enqueue_script( Sensei()->token . '-user-dashboard' );
132
+			wp_register_script(Sensei()->token.'-user-dashboard', esc_url(Sensei()->plugin_url.'assets/js/user-dashboard'.$suffix.'.js'), array('jquery-ui-tabs'), Sensei()->version, true);
133
+			wp_enqueue_script(Sensei()->token.'-user-dashboard');
134 134
 
135 135
 
136 136
             // Course Archive javascript
137
-            if( is_post_type_archive( 'course' ) ){
137
+            if (is_post_type_archive('course')) {
138 138
 
139
-                wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true );
140
-                wp_enqueue_script( 'sensei-course-archive-js' );
139
+                wp_register_script('sensei-course-archive-js', esc_url(Sensei()->plugin_url.'assets/js/frontend/course-archive'.$suffix.'.js'), array('jquery'), '1', true);
140
+                wp_enqueue_script('sensei-course-archive-js');
141 141
 
142 142
             }
143 143
 
144 144
 
145 145
 			// Allow additional scripts to be loaded
146
-			do_action( 'sensei_additional_scripts' );
146
+			do_action('sensei_additional_scripts');
147 147
 
148 148
 		} // End If Statement
149 149
 
@@ -154,23 +154,23 @@  discard block
 block discarded – undo
154 154
 	 * @since  1.0.0
155 155
 	 * @return void
156 156
 	 */
157
-	public function enqueue_styles () {
157
+	public function enqueue_styles() {
158 158
 
159 159
 		$disable_styles = false;
160
-		if ( isset( Sensei()->settings->settings[ 'styles_disable' ] ) ) {
161
-			$disable_styles = Sensei()->settings->settings[ 'styles_disable' ];
160
+		if (isset(Sensei()->settings->settings['styles_disable'])) {
161
+			$disable_styles = Sensei()->settings->settings['styles_disable'];
162 162
 		} // End If Statement
163 163
 
164 164
 		// Add filter for theme overrides
165
-		$disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles );
165
+		$disable_styles = apply_filters('sensei_disable_styles', $disable_styles);
166 166
 
167
-		if ( ! $disable_styles ) {
167
+		if ( ! $disable_styles) {
168 168
 
169
-			wp_register_style( Sensei()->token . '-frontend', Sensei()->plugin_url . 'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen' );
170
-			wp_enqueue_style( Sensei()->token . '-frontend' );
169
+			wp_register_style(Sensei()->token.'-frontend', Sensei()->plugin_url.'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen');
170
+			wp_enqueue_style(Sensei()->token.'-frontend');
171 171
 
172 172
 			// Allow additional stylesheets to be loaded
173
-			do_action( 'sensei_additional_styles' );
173
+			do_action('sensei_additional_styles');
174 174
 
175 175
 		} // End If Statement
176 176
 
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	 * @param string $name (default: '')
187 187
 	 * @return void
188 188
 	 */
189
-	function sensei_get_template_part( $slug, $name = '' ) {
189
+	function sensei_get_template_part($slug, $name = '') {
190 190
 
191
-        _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' );
192
-        Sensei_Templates::get_part( $slug, $name );
191
+        _deprecated_function('class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part');
192
+        Sensei_Templates::get_part($slug, $name);
193 193
 
194 194
 	} // End sensei_get_template_part()
195 195
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	 * @param string $default_path (default: '')
205 205
 	 * @return void
206 206
 	 */
207
-	function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
207
+	function sensei_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
208 208
 
209
-        _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' );
210
-        Sensei_Templates::get_template($template_name, $args, $template_path, $default_path  );
209
+        _deprecated_function('sensei_get_template', '1.9.0', 'Sensei_Templates::get_template');
210
+        Sensei_Templates::get_template($template_name, $args, $template_path, $default_path);
211 211
 
212 212
 	} // End sensei_get_template()
213 213
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 * @param string $default_path (default: '')
222 222
 	 * @return void
223 223
 	 */
224
-	function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) {
224
+	function sensei_locate_template($template_name, $template_path = '', $default_path = '') {
225 225
 
226
-        _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' );
227
-        Sensei_Templates::locate_template( $template_name, $template_path, $default_path );
226
+        _deprecated_function('sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template');
227
+        Sensei_Templates::locate_template($template_name, $template_path, $default_path);
228 228
 
229 229
 	} // End sensei_locate_template()
230 230
 
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 	function sensei_output_content_wrapper() {
239 239
 
240 240
 	    // backwards compatibility check for old location under the wrappers directory of the active theme
241
-        $backwards_compatible_wrapper_location =   array(
242
-            Sensei()->template_url . 'wrappers/wrapper-start.php',
241
+        $backwards_compatible_wrapper_location = array(
242
+            Sensei()->template_url.'wrappers/wrapper-start.php',
243 243
             'wrappers/wrapper-start.php'
244 244
         );
245 245
 
246
-        $template = locate_template( $backwards_compatible_wrapper_location );
247
-        if( !empty( $template ) ){
246
+        $template = locate_template($backwards_compatible_wrapper_location);
247
+        if ( ! empty($template)) {
248 248
 
249
-            Sensei_Templates::get_template( 'wrappers/wrapper-start.php' );
249
+            Sensei_Templates::get_template('wrappers/wrapper-start.php');
250 250
             return;
251 251
 
252 252
         }
253 253
 
254
-		Sensei_Templates::get_template( 'globals/wrapper-start.php' );
254
+		Sensei_Templates::get_template('globals/wrapper-start.php');
255 255
 
256 256
 	} // End sensei_output_content_wrapper()
257 257
 
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	function sensei_output_content_wrapper_end() {
266 266
 
267 267
 	    // backwards compatibility check for old location under the wrappers directory of the active theme
268
-        $backwards_compatible_wrapper_location =   array(
269
-            Sensei()->template_url . 'wrappers/wrapper-end.php',
268
+        $backwards_compatible_wrapper_location = array(
269
+            Sensei()->template_url.'wrappers/wrapper-end.php',
270 270
             'wrappers/wrapper-end.php'
271 271
         );
272 272
 
273
-        $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location );
274
-        if( !empty( $backwards_compatible_template ) ){
273
+        $backwards_compatible_template = locate_template($backwards_compatible_wrapper_location);
274
+        if ( ! empty($backwards_compatible_template)) {
275 275
 
276
-            Sensei_Templates::get_template( 'wrappers/wrapper-end.php' );
276
+            Sensei_Templates::get_template('wrappers/wrapper-end.php');
277 277
             return;
278 278
 
279 279
         }
280 280
 
281 281
 
282
-		Sensei_Templates::get_template( 'globals/wrapper-end.php' );
282
+		Sensei_Templates::get_template('globals/wrapper-end.php');
283 283
 
284 284
 	} // End sensei_output_content_wrapper_end()
285 285
 
@@ -292,57 +292,57 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public static function load_content_pagination() {
294 294
 
295
-        if( is_singular('course') ) {
295
+        if (is_singular('course')) {
296 296
 
297 297
             // backwards compatibility check for old location under the wrappers directory of the active theme
298
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) );
299
-            if( !empty( $template ) ){
298
+            $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-posts.php'));
299
+            if ( ! empty($template)) {
300 300
 
301
-                Sensei_Templates::get_template( 'wrappers/pagination-posts.php' );
301
+                Sensei_Templates::get_template('wrappers/pagination-posts.php');
302 302
                 return;
303 303
 
304 304
             }
305 305
 
306
-			Sensei_Templates::get_template( 'globals/pagination-posts.php' );
306
+			Sensei_Templates::get_template('globals/pagination-posts.php');
307 307
 
308
-		} elseif( is_singular('lesson') ) {
308
+		} elseif (is_singular('lesson')) {
309 309
 
310 310
 		    // backwards compatibility check for old location under the wrappers directory of the active theme
311
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) );
312
-            if( !empty( $template ) ){
311
+		    $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-lesson.php'));
312
+            if ( ! empty($template)) {
313 313
 
314
-                Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' );
314
+                Sensei_Templates::get_template('wrappers/pagination-lesson.php');
315 315
                 return;
316 316
 
317 317
             }
318 318
 
319
-			Sensei_Templates::get_template( 'globals/pagination-lesson.php' );
319
+			Sensei_Templates::get_template('globals/pagination-lesson.php');
320 320
 
321
-		} elseif( is_singular('quiz') ) {
321
+		} elseif (is_singular('quiz')) {
322 322
 
323 323
 		    // backwards compatibility check for old location under the wrappers directory of the active theme
324
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) );
325
-            if( !empty( $template ) ){
324
+		    $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-quiz.php'));
325
+            if ( ! empty($template)) {
326 326
 
327
-                Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' );
327
+                Sensei_Templates::get_template('wrappers/pagination-quiz.php');
328 328
                 return;
329 329
 
330 330
             }
331 331
 
332
-			Sensei_Templates::get_template( 'globals/pagination-quiz.php' );
332
+			Sensei_Templates::get_template('globals/pagination-quiz.php');
333 333
 
334 334
 		} else {
335 335
 
336 336
             // backwards compatibility check for old location under the wrappers directory of the active theme
337
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) );
338
-            if( !empty( $template ) ){
337
+            $template = locate_template(array(Sensei()->template_url.'wrappers/pagination.php'));
338
+            if ( ! empty($template)) {
339 339
 
340
-                Sensei_Templates::get_template( 'wrappers/pagination.php' );
340
+                Sensei_Templates::get_template('wrappers/pagination.php');
341 341
                 return;
342 342
 
343 343
             }
344 344
 
345
-			Sensei_Templates::get_template( 'globals/pagination.php' );
345
+			Sensei_Templates::get_template('globals/pagination.php');
346 346
 
347 347
 		} // End If Statement
348 348
 
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 	 * @param object $item
369 369
 	 * @return object $item
370 370
 	 */
371
-	public function sensei_setup_nav_menu_item( $item ) {
371
+	public function sensei_setup_nav_menu_item($item) {
372 372
 		global $pagenow, $wp_rewrite;
373 373
 
374
-		if( 'nav-menus.php' != $pagenow && !defined('DOING_AJAX') && isset( $item->url ) && 'custom' == $item->type ) {
374
+		if ('nav-menus.php' != $pagenow && ! defined('DOING_AJAX') && isset($item->url) && 'custom' == $item->type) {
375 375
 
376 376
 			// Set up Sensei menu links
377
-			$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
378
-			$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
377
+			$course_page_id = intval(Sensei()->settings->settings['course_page']);
378
+			$my_account_page_id = intval(Sensei()->settings->settings['my_course_page']);
379 379
 
380 380
 			$course_page_url = Sensei_Course::get_courses_page_url();
381
-			$lesson_archive_url = get_post_type_archive_link( 'lesson' );
382
-			$my_courses_url = get_permalink( $my_account_page_id );
383
-			$my_messages_url = get_post_type_archive_link( 'sensei_message' );
381
+			$lesson_archive_url = get_post_type_archive_link('lesson');
382
+			$my_courses_url = get_permalink($my_account_page_id);
383
+			$my_messages_url = get_post_type_archive_link('sensei_message');
384 384
 
385
-			switch ( $item->url ) {
385
+			switch ($item->url) {
386 386
 				case '#senseicourses':
387 387
 					$item->url = $course_page_url;
388 388
 					break;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 					$item->url = $my_messages_url;
400 400
                     // if no archive link exist for sensei_message
401 401
                     // set it back to the place holder
402
-                    if( ! $item->url ){
402
+                    if ( ! $item->url) {
403 403
 
404 404
                         $item->url = '#senseimymessages';
405 405
 
@@ -407,21 +407,21 @@  discard block
 block discarded – undo
407 407
 					break;
408 408
 
409 409
 				case '#senseilearnerprofile':
410
-					$item->url = esc_url( Sensei()->learner_profiles->get_permalink() );
410
+					$item->url = esc_url(Sensei()->learner_profiles->get_permalink());
411 411
 					break;
412 412
 
413 413
 				case '#senseiloginlogout':
414
-						$logout_url = wp_logout_url( home_url() );
414
+						$logout_url = wp_logout_url(home_url());
415 415
 						// Login link links to the My Courses page, to avoid the WP dashboard.
416 416
 						$login_url = $my_courses_url;
417 417
 
418
-						$item->url = ( is_user_logged_in() ? $logout_url : $login_url );
418
+						$item->url = (is_user_logged_in() ? $logout_url : $login_url);
419 419
 
420 420
 						// determine the menu title login or logout
421
-						if ( is_user_logged_in() ) {
422
-							$menu_title =  __( 'Logout'  ,'woothemes-sensei');
421
+						if (is_user_logged_in()) {
422
+							$menu_title = __('Logout', 'woothemes-sensei');
423 423
 						} else {
424
-							$menu_title =  __( 'Login'  ,'woothemes-sensei');
424
+							$menu_title = __('Login', 'woothemes-sensei');
425 425
 						}
426 426
 
427 427
 						/**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 						 *
432 432
 						 * @param $menu_title
433 433
 						 */
434
-						$item->title = apply_filters( 'sensei_login_logout_menu_title', $menu_title );
434
+						$item->title = apply_filters('sensei_login_logout_menu_title', $menu_title);
435 435
 
436 436
 					break;
437 437
 
@@ -439,12 +439,12 @@  discard block
 block discarded – undo
439 439
 					break;
440 440
 			}
441 441
 
442
-			$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
443
-			$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
444
-			$item_url = untrailingslashit( $item->url );
445
-			$_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
442
+			$_root_relative_current = untrailingslashit($_SERVER['REQUEST_URI']);
443
+			$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_root_relative_current);
444
+			$item_url = untrailingslashit($item->url);
445
+			$_indexless_current = untrailingslashit(preg_replace('/'.preg_quote($wp_rewrite->index, '/').'$/', '', $current_url));
446 446
 			// Highlight current menu item
447
-			if ( $item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
447
+			if ($item_url && in_array($item_url, array($current_url, $_indexless_current, $_root_relative_current))) {
448 448
 				$item->classes[] = 'current-menu-item current_page_item';
449 449
 			}
450 450
 
@@ -463,26 +463,26 @@  discard block
 block discarded – undo
463 463
 	 * @param object $sorted_menu_items
464 464
 	 * @return object $sorted_menu_items
465 465
 	 */
466
-	public function sensei_wp_nav_menu_objects( $sorted_menu_items ) {
466
+	public function sensei_wp_nav_menu_objects($sorted_menu_items) {
467 467
 
468
-		foreach( $sorted_menu_items as $k=>$item ) {
468
+		foreach ($sorted_menu_items as $k=>$item) {
469 469
 
470 470
 			// Remove the My Messages link for logged out users or if Private Messages are disabled
471
-			if( ! get_post_type_archive_link( 'sensei_message' )
472
-                && '#senseimymessages' == $item->url ) {
471
+			if ( ! get_post_type_archive_link('sensei_message')
472
+                && '#senseimymessages' == $item->url) {
473 473
 
474
-				if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) {
474
+				if ( ! is_user_logged_in() || (isset(Sensei()->settings->settings['messages_disable']) && Sensei()->settings->settings['messages_disable'])) {
475 475
 
476
-					unset( $sorted_menu_items[$k] );
476
+					unset($sorted_menu_items[$k]);
477 477
 
478 478
 				}
479 479
 			}
480 480
 			// Remove the My Profile link for logged out users.
481
-			if( Sensei()->learner_profiles->get_permalink() == $item->url ) {
481
+			if (Sensei()->learner_profiles->get_permalink() == $item->url) {
482 482
 
483
-				if ( !is_user_logged_in() || ! ( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) ) {
483
+				if ( ! is_user_logged_in() || ! (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable'])) {
484 484
 
485
-					unset( $sorted_menu_items[$k] );
485
+					unset($sorted_menu_items[$k]);
486 486
 
487 487
 				}
488 488
 			}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	function sensei_search_results_classes($classes) {
495 495
 	    global $post;
496 496
 	    // Handle Search Classes for Courses, Lessons, and WC Products
497
-	    if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) {
497
+	    if (isset($post->post_type) && (('course' == $post->post_type) || ('lesson' == $post->post_type) || ('product' == $post->post_type))) {
498 498
 	    	$classes[] = 'post';
499 499
 		} // End If Statement
500 500
 	    return $classes;
@@ -522,16 +522,16 @@  discard block
 block discarded – undo
522 522
      * @param bool|false $return
523 523
      * @return string|void
524 524
 	 */
525
-	function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) {
525
+	function sensei_course_image($course_id, $width = '100', $height = '100', $return = false) {
526 526
 
527
-    	if ( ! $return ) {
527
+    	if ( ! $return) {
528 528
 
529
-			echo Sensei()->course->course_image( $course_id, $width, $height );
529
+			echo Sensei()->course->course_image($course_id, $width, $height);
530 530
             return '';
531 531
 
532 532
 		} // End If Statement
533 533
 
534
-		return Sensei()->course->course_image( $course_id, $width, $height );
534
+		return Sensei()->course->course_image($course_id, $width, $height);
535 535
 
536 536
 	} // End sensei_course_image()
537 537
 
@@ -546,15 +546,15 @@  discard block
 block discarded – undo
546 546
      * @param bool|false $widget
547 547
      * @return string
548 548
 	 */
549
-	function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) {
549
+	function sensei_lesson_image($lesson_id, $width = '100', $height = '100', $return = false, $widget = false) {
550 550
 
551
-        if( ! $return ){
551
+        if ( ! $return) {
552 552
 
553
-            echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
553
+            echo Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget);
554 554
             return '';
555 555
         }
556 556
 
557
-        return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
557
+        return Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget);
558 558
 
559 559
 	} // End sensei_lesson_image()
560 560
 
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
      * @since 1.0.0
563 563
      * @param WP_Query $query
564 564
      */
565
-    function sensei_course_archive_pagination( $query ) {
565
+    function sensei_course_archive_pagination($query) {
566 566
 
567
-		if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) {
567
+		if ( ! is_admin() && $query->is_main_query() && isset($_GET['action']) && in_array($_GET['action'], array('newcourses', 'featuredcourses', 'freecourses', 'paidcourses'))) {
568 568
 
569 569
 			$amount = 0;
570
-			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
571
-				$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
570
+			if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
571
+				$amount = absint(Sensei()->settings->settings['course_archive_amount']);
572 572
 			}
573 573
 
574
-			if( $amount ) {
575
-				$query->set( 'posts_per_page', $amount );
574
+			if ($amount) {
575
+				$query->set('posts_per_page', $amount);
576 576
 			}
577 577
 
578
-			$query->set( 'orderby', 'menu_order date' );
578
+			$query->set('orderby', 'menu_order date');
579 579
 
580 580
 		}
581 581
 	}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	function sensei_course_archive_header(  ) {
592 592
 
593 593
         trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header ');
594
-        WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' );
594
+        WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>');
595 595
 
596 596
 	} // sensei_course_archive_header()
597 597
 
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
604 604
 	 * @return void
605 605
 	 */
606 606
 	public function sensei_lesson_archive_header( ) {
607
-        _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' );
607
+        _deprecated_function('WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header');
608 608
         Sensei()->lesson->the_archive_header();
609 609
 	} // sensei_course_archive_header()
610 610
 
611 611
     /**
612 612
      * @deprecated since 1.9.0
613 613
      */
614
-	public function sensei_message_archive_header( ){
615
-        _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
614
+	public function sensei_message_archive_header( ) {
615
+        _deprecated_function('Sensei_Frontend::sensei_message_archive_header', 'Please use: Sense');
616 616
         Sensei_Messages::the_archive_header();
617 617
 	} // sensei_message_archive_header()
618 618
 
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
      * @param WP_Post $post_item
623 623
 	 * @return void
624 624
 	 */
625
-	function sensei_course_archive_course_title( $post_item ) {
626
-		if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) {
627
-			$post_id = absint( $post_item->ID );
625
+	function sensei_course_archive_course_title($post_item) {
626
+		if (isset($post_item->ID) && (0 < $post_item->ID)) {
627
+			$post_id = absint($post_item->ID);
628 628
     		$post_title = $post_item->post_title;
629 629
 		} else {
630 630
 			$post_id = get_the_ID();
631 631
     		$post_title = get_the_title();
632 632
 		} // End If Statement
633
-		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
633
+		?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php
634 634
 	} // End sensei_course_archive_course_title()
635 635
 
636 636
 	/**
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	public function sensei_lesson_archive_lesson_title() {
642 642
 		$post_id = get_the_ID();
643 643
     	$post_title = get_the_title();
644
-		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
644
+		?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php
645 645
 	} // End sensei_lesson_archive_lesson_title()
646 646
 
647 647
 	/**
@@ -650,40 +650,40 @@  discard block
 block discarded – undo
650 650
 	 * @param  integer $id course, lesson or quiz id
651 651
 	 * @return void
652 652
 	 */
653
-	public function sensei_breadcrumb( $id = 0 ) {
653
+	public function sensei_breadcrumb($id = 0) {
654 654
 
655 655
 		// Only output on lesson, quiz and taxonomy (module) pages
656
-		if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return;
656
+		if ( ! (is_tax('module') || is_singular('lesson') || is_singular('quiz'))) return;
657 657
 
658
-		if( empty( $id )  ){
658
+		if (empty($id)) {
659 659
 
660 660
             $id = get_the_ID();
661 661
 
662 662
         }
663 663
 
664
-		$sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' );
665
-		$separator = apply_filters( 'sensei_breadcrumb_separator', '&gt;' );
664
+		$sensei_breadcrumb_prefix = __('Back to: ', 'woothemes-sensei');
665
+		$separator = apply_filters('sensei_breadcrumb_separator', '&gt;');
666 666
 
667
-		$html = '<section class="sensei-breadcrumb">' . $sensei_breadcrumb_prefix;
667
+		$html = '<section class="sensei-breadcrumb">'.$sensei_breadcrumb_prefix;
668 668
 		// Lesson
669
-		if ( is_singular( 'lesson' ) && 0 < intval( $id ) ) {
670
-			$course_id = intval( get_post_meta( $id, '_lesson_course', true ) );
671
-			if( ! $course_id ) {
669
+		if (is_singular('lesson') && 0 < intval($id)) {
670
+			$course_id = intval(get_post_meta($id, '_lesson_course', true));
671
+			if ( ! $course_id) {
672 672
 				return;
673 673
 			}
674
-			$html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>';
674
+			$html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>';
675 675
     	} // End If Statement
676 676
     	// Quiz
677
-		if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) {
678
-			$lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) );
679
-			if( ! $lesson_id ) {
677
+		if (is_singular('quiz') && 0 < intval($id)) {
678
+			$lesson_id = intval(get_post_meta($id, '_quiz_lesson', true));
679
+			if ( ! $lesson_id) {
680 680
 				return;
681 681
 			}
682
-			 $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' .  __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>';
682
+			 $html .= '<a href="'.esc_url(get_permalink($lesson_id)).'" title="'.__('Back to the lesson', 'woothemes-sensei').'">'.get_the_title($lesson_id).'</a>';
683 683
     	} // End If Statement
684 684
 
685 685
     	// Allow other plugins to filter html
686
-    	$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
686
+    	$html = apply_filters('sensei_breadcrumb_output', $html, $separator);
687 687
     	$html .= '</section>';
688 688
 
689 689
     	echo $html;
@@ -695,25 +695,25 @@  discard block
 block discarded – undo
695 695
      */
696 696
 	public function sensei_lesson_course_signup_link( ) {
697 697
 
698
-        _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' );
698
+        _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link');
699 699
         WooThemes_Sensei_Lesson::course_signup_link();
700 700
 	}
701 701
 
702
-	public function lesson_tags_display( $lesson_id = 0 ) {
703
-		if( $lesson_id ) {
704
-			$tags = wp_get_post_terms( $lesson_id, 'lesson-tag' );
705
-			if( $tags && count( $tags ) > 0 ) {
702
+	public function lesson_tags_display($lesson_id = 0) {
703
+		if ($lesson_id) {
704
+			$tags = wp_get_post_terms($lesson_id, 'lesson-tag');
705
+			if ($tags && count($tags) > 0) {
706 706
 				$tag_list = '';
707
-				foreach( $tags as $tag ) {
708
-					$tag_link = get_term_link( $tag, 'lesson-tag' );
709
-					if( ! is_wp_error( $tag_link ) ) {
710
-						if( $tag_list ) { $tag_list .= ', '; }
711
-						$tag_list .= '<a href="' . $tag_link . '">' . $tag->name . '</a>';
707
+				foreach ($tags as $tag) {
708
+					$tag_link = get_term_link($tag, 'lesson-tag');
709
+					if ( ! is_wp_error($tag_link)) {
710
+						if ($tag_list) { $tag_list .= ', '; }
711
+						$tag_list .= '<a href="'.$tag_link.'">'.$tag->name.'</a>';
712 712
 					}
713 713
 				}
714
-				if( $tag_list ) {
714
+				if ($tag_list) {
715 715
 					?><section class="lesson-tags">
716
-		    			<?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?>
716
+		    			<?php printf(__('Lesson tags: %1$s', 'woothemes-sensei'), $tag_list); ?>
717 717
 		    		</section><?php
718 718
 		    	}
719 719
 	    	}
@@ -723,51 +723,51 @@  discard block
 block discarded – undo
723 723
     /**
724 724
      * @param WP_Query $query
725 725
      */
726
-	public function lesson_tag_archive_filter( $query ) {
727
-    	if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
726
+	public function lesson_tag_archive_filter($query) {
727
+    	if (is_tax('lesson-tag') && $query->is_main_query()) {
728 728
     		// Limit to lessons only
729
-    		$query->set( 'post_type', 'lesson' );
729
+    		$query->set('post_type', 'lesson');
730 730
 
731 731
     		// Set order of lessons
732
-    		$query->set( 'orderby', 'menu_order' );
733
-    		$query->set( 'order', 'ASC' );
732
+    		$query->set('orderby', 'menu_order');
733
+    		$query->set('order', 'ASC');
734 734
 
735 735
     	}
736 736
     }
737 737
 
738
-    public function lesson_tag_archive_header( $title ) {
739
-		if( is_tax( 'lesson-tag' ) ) {
740
-			$title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) );
738
+    public function lesson_tag_archive_header($title) {
739
+		if (is_tax('lesson-tag')) {
740
+			$title = sprintf(__('Lesson tag: %1$s', 'woothemes-sensei'), apply_filters('sensei_lesson_tag_archive_title', get_queried_object()->name));
741 741
 		}
742 742
 		return $title;
743 743
 	}
744 744
 
745 745
 	public function lesson_tag_archive_description() {
746
-		if( is_tax( 'lesson-tag' ) ) {
746
+		if (is_tax('lesson-tag')) {
747 747
 			$tag = get_queried_object();
748
-			echo '<p class="archive-description lesson-description">' . apply_filters( 'sensei_lesson_tag_archive_description', nl2br( $tag->description ), $tag->term_id ) . '</p>';
748
+			echo '<p class="archive-description lesson-description">'.apply_filters('sensei_lesson_tag_archive_description', nl2br($tag->description), $tag->term_id).'</p>';
749 749
 		}
750 750
 	}
751 751
 
752 752
 	public function sensei_complete_lesson() {
753
-		global $post,  $current_user;
753
+		global $post, $current_user;
754 754
 		// Handle Quiz Completion
755
-		if ( isset( $_POST['quiz_action'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_lesson_noonce' ], 'woothemes_sensei_complete_lesson_noonce' ) ) {
755
+		if (isset($_POST['quiz_action']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) {
756 756
 
757
-			$sanitized_submit = esc_html( $_POST['quiz_action'] );
757
+			$sanitized_submit = esc_html($_POST['quiz_action']);
758 758
 
759 759
 			switch ($sanitized_submit) {
760 760
                 case 'lesson-complete':
761 761
 
762
-					Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true );
762
+					Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true);
763 763
 
764 764
 					break;
765 765
 
766 766
                 case 'lesson-reset':
767 767
 
768
-					Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID );
768
+					Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID);
769 769
 
770
-					$this->messages = '<div class="sensei-message note">' .  __( 'Lesson Reset Successfully.', 'woothemes-sensei' ) . '</div>';
770
+					$this->messages = '<div class="sensei-message note">'.__('Lesson Reset Successfully.', 'woothemes-sensei').'</div>';
771 771
 					break;
772 772
 
773 773
 				default:
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	} // End sensei_complete_lesson()
782 782
 
783 783
 	public function sensei_complete_course() {
784
-		global $post,  $current_user, $wp_query;
785
-		if ( isset( $_POST['course_complete'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_course_noonce' ], 'woothemes_sensei_complete_course_noonce' ) ) {
784
+		global $post, $current_user, $wp_query;
785
+		if (isset($_POST['course_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_course_noonce'], 'woothemes_sensei_complete_course_noonce')) {
786 786
 
787
-			$sanitized_submit = esc_html( $_POST['course_complete'] );
788
-			$sanitized_course_id = absint( esc_html( $_POST['course_complete_id'] ) );
787
+			$sanitized_submit = esc_html($_POST['course_complete']);
788
+			$sanitized_course_id = absint(esc_html($_POST['course_complete_id']));
789 789
 			// Handle submit data
790 790
 			switch ($sanitized_submit) {
791
-				case __( 'Mark as Complete', 'woothemes-sensei' ):
791
+				case __('Mark as Complete', 'woothemes-sensei'):
792 792
 
793 793
 					// Add user to course
794 794
 					$course_metadata = array(
@@ -796,15 +796,15 @@  discard block
 block discarded – undo
796 796
 						'percent' => 0, // No completed lessons yet
797 797
 						'complete' => 0,
798 798
 					);
799
-					$activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata );
799
+					$activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata);
800 800
 
801
-					if ( $activity_logged ) {
801
+					if ($activity_logged) {
802 802
 						// Get all course lessons
803
-						$course_lesson_ids = Sensei()->course->course_lessons( $sanitized_course_id, 'any', 'ids' );
803
+						$course_lesson_ids = Sensei()->course->course_lessons($sanitized_course_id, 'any', 'ids');
804 804
 						// Mark all quiz user meta lessons as complete
805
-						foreach ( $course_lesson_ids as $lesson_item_id ){
805
+						foreach ($course_lesson_ids as $lesson_item_id) {
806 806
 							// Mark lesson as complete
807
-							$activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_item_id, $current_user->ID, $complete = true );
807
+							$activity_logged = Sensei_Utils::sensei_start_lesson($lesson_item_id, $current_user->ID, $complete = true);
808 808
 						} // End For Loop
809 809
 
810 810
 						// Update with final stats
@@ -812,22 +812,22 @@  discard block
 block discarded – undo
812 812
 							'percent' => 100,
813 813
 							'complete' => count($course_lesson_ids),
814 814
 						);
815
-						$activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'complete', $course_metadata );
815
+						$activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'complete', $course_metadata);
816 816
 
817
-						do_action( 'sensei_user_course_end', $current_user->ID, $sanitized_course_id );
817
+						do_action('sensei_user_course_end', $current_user->ID, $sanitized_course_id);
818 818
 
819 819
 						// Success message
820
-						$this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s marked as complete.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>';
820
+						$this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s marked as complete.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>';
821 821
 					} // End If Statement
822 822
 
823 823
 					break;
824 824
 
825
-				case __( 'Delete Course', 'woothemes-sensei' ):
825
+				case __('Delete Course', 'woothemes-sensei'):
826 826
 
827
-					Sensei_Utils::sensei_remove_user_from_course( $sanitized_course_id, $current_user->ID );
827
+					Sensei_Utils::sensei_remove_user_from_course($sanitized_course_id, $current_user->ID);
828 828
 
829 829
 					// Success message
830
-					$this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s deleted.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>';
830
+					$this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s deleted.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>';
831 831
 					break;
832 832
 
833 833
 				default:
@@ -843,25 +843,25 @@  discard block
 block discarded – undo
843 843
 	 * @param int $lesson_id
844 844
 	 * @return array
845 845
 	 */
846
-	public function sensei_get_user_quiz_answers( $lesson_id = 0 ) {
846
+	public function sensei_get_user_quiz_answers($lesson_id = 0) {
847 847
 		global $current_user;
848 848
 
849 849
 		$user_answers = array();
850 850
 
851
-		if ( 0 < intval( $lesson_id ) ) {
852
-			$lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $lesson_id );
853
-			foreach( $lesson_quiz_questions as $question ) {
854
-				$answer = maybe_unserialize( base64_decode( Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content' ) ) ) );
855
-				$user_answers[ $question->ID ] = $answer;
851
+		if (0 < intval($lesson_id)) {
852
+			$lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($lesson_id);
853
+			foreach ($lesson_quiz_questions as $question) {
854
+				$answer = maybe_unserialize(base64_decode(Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content'))));
855
+				$user_answers[$question->ID] = $answer;
856 856
 			}
857 857
 		}
858 858
 
859 859
 		return $user_answers;
860 860
 	} // End sensei_get_user_quiz_answers()
861 861
 
862
-	public function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) {
863
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" );
864
-		return Sensei_Utils::user_completed_lesson( $post_id, $user_id );
862
+	public function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) {
863
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()");
864
+		return Sensei_Utils::user_completed_lesson($post_id, $user_id);
865 865
 	} // End sensei_has_user_completed_lesson()
866 866
 
867 867
 /**
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
 		Sensei()->notices->print_notices();
872 872
 	} // End sensei_frontend_messages()
873 873
 
874
-	public function sensei_lesson_video( $post_id = 0 ) {
875
-		if ( 0 < intval( $post_id ) ) {
876
-			$lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true );
877
-			if ( 'http' == substr( $lesson_video_embed, 0, 4) ) {
874
+	public function sensei_lesson_video($post_id = 0) {
875
+		if (0 < intval($post_id)) {
876
+			$lesson_video_embed = get_post_meta($post_id, '_lesson_video_embed', true);
877
+			if ('http' == substr($lesson_video_embed, 0, 4)) {
878 878
         		// V2 - make width and height a setting for video embed
879
-        		$lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ );
879
+        		$lesson_video_embed = wp_oembed_get(esc_url($lesson_video_embed)/*, array( 'width' => 100 , 'height' => 100)*/);
880 880
         	} // End If Statement
881
-        	if ( '' != $lesson_video_embed ) {
881
+        	if ('' != $lesson_video_embed) {
882 882
         	?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883 883
         	} // End If Statement
884 884
         } // End If Statement
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
 		$quiz_id = 0;
891 891
 
892 892
 		// Lesson quizzes
893
-		$quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID );
893
+		$quiz_id = Sensei()->lesson->lesson_quizzes($post->ID);
894 894
 		$pass_required = true;
895
-		if( $quiz_id ) {
895
+		if ($quiz_id) {
896 896
 			// Get quiz pass setting
897
-	    	$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
897
+	    	$pass_required = get_post_meta($quiz_id, '_pass_required', true);
898 898
 	    }
899
-		if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) {
899
+		if ( ! $quiz_id || ($quiz_id && ! $pass_required)) {
900 900
 			?>
901
-			<form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
901
+			<form class="lesson_button_form" method="POST" action="<?php echo esc_url(get_permalink()); ?>">
902 902
 	            <input type="hidden"
903 903
                        name="woothemes_sensei_complete_lesson_noonce"
904 904
                        id="woothemes_sensei_complete_lesson_noonce"
905
-                       value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>"
905
+                       value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>"
906 906
                 />
907 907
 
908 908
 	            <input type="hidden" name="quiz_action" value="lesson-complete" />
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                 <input type="submit"
911 911
                        name="quiz_complete"
912 912
                        class="quiz-submit complete"
913
-                       value="<?php _e( 'Complete Lesson', 'woothemes-sensei' ); ?>"/>
913
+                       value="<?php _e('Complete Lesson', 'woothemes-sensei'); ?>"/>
914 914
 
915 915
 	        </form>
916 916
 			<?php
@@ -923,25 +923,25 @@  discard block
 block discarded – undo
923 923
 		$quiz_id = 0;
924 924
 
925 925
 		// Lesson quizzes
926
-		$quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID );
926
+		$quiz_id = Sensei()->lesson->lesson_quizzes($post->ID);
927 927
 		$reset_allowed = true;
928
-		if( $quiz_id ) {
928
+		if ($quiz_id) {
929 929
 			// Get quiz pass setting
930
-			$reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
930
+			$reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true);
931 931
 		}
932
-		if ( ! $quiz_id || !empty($reset_allowed) ) {
932
+		if ( ! $quiz_id || ! empty($reset_allowed)) {
933 933
 		?>
934
-		<form method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
934
+		<form method="POST" action="<?php echo esc_url(get_permalink()); ?>">
935 935
 
936 936
             <input
937 937
             type="hidden"
938
-            name="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>"
939
-            id="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>"
940
-            value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" />
938
+            name="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>"
939
+            id="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>"
940
+            value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" />
941 941
 
942 942
             <input type="hidden" name="quiz_action" value="lesson-reset" />
943 943
 
944
-            <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e( 'Reset Lesson', 'woothemes-sensei' ); ?>"/>
944
+            <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e('Reset Lesson', 'woothemes-sensei'); ?>"/>
945 945
 
946 946
         </form>
947 947
 		<?php
@@ -964,23 +964,23 @@  discard block
 block discarded – undo
964 964
 		$post_title = get_the_title();
965 965
 		$author_display_name = get_the_author();
966 966
 		$author_id = get_the_author_meta('ID');
967
-		$category_output = get_the_term_list( $post_id, 'course-category', '', ', ', '' );
968
-		$free_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $post_id ) );
967
+		$category_output = get_the_term_list($post_id, 'course-category', '', ', ', '');
968
+		$free_lesson_count = intval(Sensei()->course->course_lesson_preview_count($post_id));
969 969
 		?><section class="entry">
970 970
         	<p class="sensei-course-meta">
971
-           	<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
972
-		   	<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span>
971
+           	<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
972
+		   	<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span>
973 973
 		   	<?php } // End If Statement ?>
974
-		   	<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' . __( 'Lessons', 'woothemes-sensei' ); ?></span>
975
-		   	<?php if ( '' != $category_output ) { ?>
976
-		   	<span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
974
+		   	<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
975
+		   	<?php if ('' != $category_output) { ?>
976
+		   	<span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
977 977
 		   	<?php } // End If Statement ?>
978
-		   	<?php sensei_simple_course_price( $post_id ); ?>
978
+		   	<?php sensei_simple_course_price($post_id); ?>
979 979
         	</p>
980 980
         	<p class="course-excerpt"><?php the_excerpt(); ?></p>
981
-        	<?php if ( 0 < $free_lesson_count ) {
982
-                $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
983
-                <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p>
981
+        	<?php if (0 < $free_lesson_count) {
982
+                $free_lessons = sprintf(__('You can access %d of this course\'s lessons for free', 'woothemes-sensei'), $free_lesson_count); ?>
983
+                <p class="sensei-free-lessons"><a href="<?php echo get_permalink($post_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?></a> - <?php echo $free_lessons; ?></p>
984 984
             <?php } ?>
985 985
 		</section><?php
986 986
 	} // End sensei_course_archive_meta()
@@ -1003,33 +1003,33 @@  discard block
 block discarded – undo
1003 1003
     * @deprecated since 1.9.0
1004 1004
     */
1005 1005
 	public function sensei_message_archive_main_content() {
1006
-		_deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' );
1006
+		_deprecated_function('Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed');
1007 1007
 	} // End sensei_lesson_archive_main_content()
1008 1008
 
1009 1009
     /**
1010 1010
     * @deprecated since 1.9.0
1011 1011
     */
1012 1012
 	public function sensei_no_permissions_main_content() {
1013
-        _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' );
1013
+        _deprecated_function('Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed');
1014 1014
 	} // End sensei_no_permissions_main_content()
1015 1015
 
1016 1016
 	public function sensei_course_category_main_content() {
1017 1017
 		global $post;
1018
-		if ( have_posts() ) { ?>
1018
+		if (have_posts()) { ?>
1019 1019
 
1020 1020
 			<section id="main-course" class="course-container">
1021 1021
 
1022
-                <?php do_action( 'sensei_course_archive_header' ); ?>
1022
+                <?php do_action('sensei_course_archive_header'); ?>
1023 1023
 
1024
-                <?php while ( have_posts() ) { the_post(); ?>
1024
+                <?php while (have_posts()) { the_post(); ?>
1025 1025
 
1026
-                    <article class="<?php echo join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ); ?>">
1026
+                    <article class="<?php echo join(' ', get_post_class(array('course', 'post'), get_the_ID())); ?>">
1027 1027
 
1028
-	    			    <?php sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', get_the_ID() ); ?>
1028
+	    			    <?php sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', get_the_ID()); ?>
1029 1029
 
1030
-	    			    <?php sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before', $post ); ?>
1030
+	    			    <?php sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before', $post); ?>
1031 1031
 
1032
-	    			    <?php do_action( 'sensei_course_archive_meta' ); ?>
1032
+	    			    <?php do_action('sensei_course_archive_meta'); ?>
1033 1033
 
1034 1034
 	    		    </article>
1035 1035
 
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 
1042 1042
 			<p>
1043 1043
 
1044
-                <?php _e( 'No courses found that match your selection.', 'woothemes-sensei' ); ?>
1044
+                <?php _e('No courses found that match your selection.', 'woothemes-sensei'); ?>
1045 1045
 
1046 1046
             </p>
1047 1047
 
@@ -1058,12 +1058,12 @@  discard block
 block discarded – undo
1058 1058
 				<div class="col-1">
1059 1059
 					<?php
1060 1060
 					// output the actual form markup
1061
-                    Sensei_Templates::get_template( 'user/login-form.php');
1061
+                    Sensei_Templates::get_template('user/login-form.php');
1062 1062
 					?>
1063 1063
 				</div>
1064 1064
 
1065 1065
 			<?php
1066
-			if ( get_option('users_can_register') ) {
1066
+			if (get_option('users_can_register')) {
1067 1067
 
1068 1068
 				// get current url
1069 1069
 				$action_url = get_permalink();
@@ -1071,38 +1071,38 @@  discard block
 block discarded – undo
1071 1071
 				?>
1072 1072
 
1073 1073
 				<div class="col-2">
1074
-					<h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2>
1074
+					<h2><?php _e('Register', 'woothemes-sensei'); ?></h2>
1075 1075
 
1076
-					<form method="post" class="register"  action="<?php echo esc_url( $action_url ); ?>" >
1076
+					<form method="post" class="register"  action="<?php echo esc_url($action_url); ?>" >
1077 1077
 
1078
-						<?php do_action( 'sensei_register_form_start' ); ?>
1078
+						<?php do_action('sensei_register_form_start'); ?>
1079 1079
 
1080 1080
 						<p class="form-row form-row-wide">
1081
-							<label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1082
-							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" />
1081
+							<label for="sensei_reg_username"><?php _e('Username', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1082
+							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty($_POST['sensei_reg_username'])) esc_attr_e($_POST['sensei_reg_username']); ?>" />
1083 1083
 						</p>
1084 1084
 
1085 1085
 						<p class="form-row form-row-wide">
1086
-							<label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1087
-							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" />
1086
+							<label for="sensei_reg_email"><?php _e('Email address', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1087
+							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty($_POST['sensei_reg_email'])) esc_attr_e($_POST['sensei_reg_email']); ?>" />
1088 1088
 						</p>
1089 1089
 
1090 1090
 						<p class="form-row form-row-wide">
1091
-							<label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1092
-							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" />
1091
+							<label for="sensei_reg_password"><?php _e('Password', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1092
+							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty($_POST['sensei_reg_password'])) esc_attr_e($_POST['sensei_reg_password']); ?>" />
1093 1093
 						</p>
1094 1094
 
1095 1095
 						<!-- Spam Trap -->
1096
-						<div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woothemes-sensei' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
1096
+						<div style="left:-999em; position:absolute;"><label for="trap"><?php _e('Anti-spam', 'woothemes-sensei'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
1097 1097
 
1098
-						<?php do_action( 'sensei_register_form_fields' ); ?>
1099
-						<?php do_action( 'register_form' ); ?>
1098
+						<?php do_action('sensei_register_form_fields'); ?>
1099
+						<?php do_action('register_form'); ?>
1100 1100
 
1101 1101
 						<p class="form-row">
1102
-							<input type="submit" class="button" name="register" value="<?php _e( 'Register', 'woothemes-sensei' ); ?>" />
1102
+							<input type="submit" class="button" name="register" value="<?php _e('Register', 'woothemes-sensei'); ?>" />
1103 1103
 						</p>
1104 1104
 
1105
-						<?php do_action( 'sensei_register_form_end' ); ?>
1105
+						<?php do_action('sensei_register_form_end'); ?>
1106 1106
 
1107 1107
 					</form>
1108 1108
 				</div>
@@ -1115,17 +1115,17 @@  discard block
 block discarded – undo
1115 1115
 		<?php
1116 1116
 	} // End sensei_login_form()
1117 1117
 
1118
-	public function sensei_lesson_meta( $post_id = 0 ) {
1118
+	public function sensei_lesson_meta($post_id = 0) {
1119 1119
 		global $post;
1120
-		if ( 0 < intval( $post_id ) ) {
1121
-		$lesson_course_id = absint( get_post_meta( $post_id, '_lesson_course', true ) );
1120
+		if (0 < intval($post_id)) {
1121
+		$lesson_course_id = absint(get_post_meta($post_id, '_lesson_course', true));
1122 1122
 		?><section class="entry">
1123 1123
             <p class="sensei-course-meta">
1124
-			    <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?>
1125
-			    <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span>
1124
+			    <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?>
1125
+			    <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span>
1126 1126
 			    <?php } ?>
1127
-                <?php if ( 0 < intval( $lesson_course_id ) ) { ?>
1128
-                <span class="lesson-course"><?php echo '&nbsp;' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . __( 'View course', 'woothemes-sensei' ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span>
1127
+                <?php if (0 < intval($lesson_course_id)) { ?>
1128
+                <span class="lesson-course"><?php echo '&nbsp;'.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.__('View course', 'woothemes-sensei').'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span>
1129 1129
                 <?php } ?>
1130 1130
             </p>
1131 1131
             <p class="lesson-excerpt"><?php the_excerpt( ); ?></p>
@@ -1133,36 +1133,36 @@  discard block
 block discarded – undo
1133 1133
 		} // End If Statement
1134 1134
 	} // sensei_lesson_meta()
1135 1135
 
1136
-	public function sensei_lesson_preview_title_text( $course_id ) {
1136
+	public function sensei_lesson_preview_title_text($course_id) {
1137 1137
 
1138
-		$preview_text = __( ' (Preview)', 'woothemes-sensei' );
1138
+		$preview_text = __(' (Preview)', 'woothemes-sensei');
1139 1139
 
1140 1140
 		//if this is a paid course
1141
-		if ( Sensei_WC::is_woocommerce_active() ) {
1142
-    	    $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
1143
-    	    if ( 0 < $wc_post_id ) {
1144
-    	    	$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
1141
+		if (Sensei_WC::is_woocommerce_active()) {
1142
+    	    $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true);
1143
+    	    if (0 < $wc_post_id) {
1144
+    	    	$preview_text = __(' (Free Preview)', 'woothemes-sensei');
1145 1145
     	    } // End If Statement
1146 1146
     	}
1147 1147
     	return $preview_text;
1148 1148
 	}
1149 1149
 
1150
-	public function sensei_lesson_preview_title( $title = '', $id = 0 ) {
1150
+	public function sensei_lesson_preview_title($title = '', $id = 0) {
1151 1151
 		global $post, $current_user;
1152 1152
 
1153 1153
 		// Limit to lessons and check if lesson ID matches filtered post ID
1154 1154
 		// @see https://github.com/woothemes/sensei/issues/574
1155
-		if( isset( $post->ID ) && $id == $post->ID && 'lesson' == get_post_type( $post ) ) {
1155
+		if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) {
1156 1156
 
1157 1157
 			// Limit to main query only
1158
-			if( is_main_query() ) {
1158
+			if (is_main_query()) {
1159 1159
 
1160 1160
 				// Get the course ID
1161
-				$course_id = get_post_meta( $post->ID, '_lesson_course', true );
1161
+				$course_id = get_post_meta($post->ID, '_lesson_course', true);
1162 1162
 
1163 1163
 				// Check if the user is taking the course
1164
-				if( is_singular( 'lesson' ) && Sensei_Utils::is_preview_lesson( $post->ID ) && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID ) && $post->ID == $id ) {
1165
-					$title .= ' ' . $this->sensei_lesson_preview_title_text( $course_id );
1164
+				if (is_singular('lesson') && Sensei_Utils::is_preview_lesson($post->ID) && ! Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) {
1165
+					$title .= ' '.$this->sensei_lesson_preview_title_text($course_id);
1166 1166
 				}
1167 1167
 			}
1168 1168
 		}
@@ -1173,23 +1173,23 @@  discard block
 block discarded – undo
1173 1173
 		global $post, $current_user;
1174 1174
 
1175 1175
 		// Check if the user is taking the course
1176
-		$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
1176
+		$is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID);
1177 1177
 		// Handle user starting the course
1178
-		if ( isset( $_POST['course_start'] )
1179
-		    && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' )
1180
-		    && !$is_user_taking_course ) {
1178
+		if (isset($_POST['course_start'])
1179
+		    && wp_verify_nonce($_POST['woothemes_sensei_start_course_noonce'], 'woothemes_sensei_start_course_noonce')
1180
+		    && ! $is_user_taking_course) {
1181 1181
 
1182 1182
 			// Start the course
1183
-			$activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID );
1183
+			$activity_logged = Sensei_Utils::user_start_course($current_user->ID, $post->ID);
1184 1184
 			$this->data = new stdClass();
1185 1185
 			$this->data->is_user_taking_course = false;
1186
-			if ( $activity_logged ) {
1186
+			if ($activity_logged) {
1187 1187
 				$this->data->is_user_taking_course = true;
1188 1188
 
1189 1189
 				// Refresh page to avoid re-posting
1190 1190
 				?>
1191 1191
 
1192
-			    <script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script>
1192
+			    <script type="text/javascript"> window.location = '<?php echo get_permalink($post->ID); ?>'; </script>
1193 1193
 
1194 1194
 			    <?php
1195 1195
 			} // End If Statement
@@ -1200,15 +1200,15 @@  discard block
 block discarded – undo
1200 1200
      * @deprecated since 1.9.0
1201 1201
      */
1202 1202
 	public function sensei_course_meta() {
1203
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' );
1204
-        Sensei()->course->the_course_meta( get_post() );
1203
+        _deprecated_function('Sensei_Frontend::sensei_course_meta', '1.9.0', 'Sensei_Course::the_course_meta()');
1204
+        Sensei()->course->the_course_meta(get_post());
1205 1205
 	} // End sensei_course_meta()
1206 1206
 
1207 1207
     /**
1208 1208
      * @deprecated since 1.9.0
1209 1209
      */
1210 1210
 	public function sensei_course_meta_video() {
1211
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' );
1211
+        _deprecated_function('Sensei_Frontend::sensei_course_meta_video', '1.9.0', 'Sensei_Course::the_course_video()');
1212 1212
         Sensei_Course::the_course_video();
1213 1213
 	} // End sensei_course_meta_video()
1214 1214
 
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
     public function sensei_woocommerce_in_cart_message() {
1224 1224
 		global $post, $woocommerce;
1225 1225
 
1226
-		$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
1227
-        $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() );
1228
-		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
1226
+		$wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
1227
+        $user_course_status_id = Sensei_Utils::user_started_course($post->ID, get_current_user_id());
1228
+		if (0 < intval($wc_post_id) && ! $user_course_status_id) {
1229 1229
 
1230
-			if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) {
1231
-				echo '<div class="sensei-message info">' . sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' );
1230
+			if (Sensei_WC::is_product_in_cart($wc_post_id)) {
1231
+				echo '<div class="sensei-message info">'.sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei').'</div>', '<a class="cart-complete" href="'.$woocommerce->cart->get_checkout_url().'" title="'.__('complete the purchase', 'woothemes-sensei').'">'.__('complete the purchase', 'woothemes-sensei').'</a>');
1232 1232
 			} // End If Statement
1233 1233
 
1234 1234
 		} // End If Statement
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 	} // End sensei_woocommerce_in_cart_message()
1237 1237
 
1238 1238
 	// Deprecated
1239
-	public function sensei_lesson_comment_count( $count ) {
1239
+	public function sensei_lesson_comment_count($count) {
1240 1240
 		return $count;
1241 1241
 	} // End sensei_lesson_comment_count()
1242 1242
 
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $content Original content
1246 1246
 	 * @return string          Modified content
1247 1247
 	 */
1248
-	public function sensei_search_results_excerpt( $content ) {
1248
+	public function sensei_search_results_excerpt($content) {
1249 1249
 		global $post;
1250 1250
 
1251
-		if( is_search() && in_array( $post->post_type, array( 'course', 'lesson' ) ) ) {
1252
-			$content = '<p class="course-excerpt">' . the_excerpt( ) . '</p>';
1251
+		if (is_search() && in_array($post->post_type, array('course', 'lesson'))) {
1252
+			$content = '<p class="course-excerpt">'.the_excerpt( ).'</p>';
1253 1253
 		}
1254 1254
 
1255 1255
 		return $content;
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
 	 * @param  integer $order_id ID of order
1261 1261
 	 * @return void
1262 1262
 	 */
1263
-	public function remove_active_course( $order_id ) {
1264
-		$order = new WC_Order( $order_id );
1263
+	public function remove_active_course($order_id) {
1264
+		$order = new WC_Order($order_id);
1265 1265
 
1266
-		foreach ( $order->get_items() as $item ) {
1267
-			if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
1266
+		foreach ($order->get_items() as $item) {
1267
+			if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
1268 1268
 				// If item has variation_id then its a variation of the product
1269 1269
 				$item_id = $item['variation_id'];
1270 1270
 			} else {
@@ -1272,11 +1272,11 @@  discard block
 block discarded – undo
1272 1272
 				$item_id = $item['product_id'];
1273 1273
 			} 
1274 1274
 
1275
-            if ( $item_id > 0 ) {
1275
+            if ($item_id > 0) {
1276 1276
 
1277
-				$user_id = get_post_meta( $order_id, '_customer_user', true );
1277
+				$user_id = get_post_meta($order_id, '_customer_user', true);
1278 1278
 
1279
-				if( $user_id ) {
1279
+				if ($user_id) {
1280 1280
 
1281 1281
 					// Get all courses for product
1282 1282
 					$args = array(
@@ -1292,13 +1292,13 @@  discard block
 block discarded – undo
1292 1292
 						'order' => 'ASC',
1293 1293
 						'fields' => 'ids',
1294 1294
 					);
1295
-					$course_ids = get_posts( $args );
1295
+					$course_ids = get_posts($args);
1296 1296
 
1297
-					if( $course_ids && count( $course_ids ) > 0 ) {
1298
-						foreach( $course_ids as $course_id ) {
1297
+					if ($course_ids && count($course_ids) > 0) {
1298
+						foreach ($course_ids as $course_id) {
1299 1299
 
1300 1300
 							// Remove all course user meta
1301
-							Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id );
1301
+							Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id);
1302 1302
 
1303 1303
 						} // End For Loop
1304 1304
 					} // End If Statement
@@ -1314,16 +1314,16 @@  discard block
 block discarded – undo
1314 1314
 	 * @param  integer $user_id User ID
1315 1315
 	 * @return void
1316 1316
 	 */
1317
-	public function activate_purchased_courses( $user_id = 0 ) {
1317
+	public function activate_purchased_courses($user_id = 0) {
1318 1318
 
1319
-		if( $user_id ) {
1319
+		if ($user_id) {
1320 1320
 
1321
-			if( Sensei_WC::is_woocommerce_active() ) {
1321
+			if (Sensei_WC::is_woocommerce_active()) {
1322 1322
 
1323 1323
 				// Get all user's orders
1324 1324
 				$order_args = array(
1325 1325
 					'post_type' => 'shop_order',
1326
-					'post_status' =>  array( 'wc-processing', 'wc-completed' ),
1326
+					'post_status' =>  array('wc-processing', 'wc-completed'),
1327 1327
 					'posts_per_page' => -1,
1328 1328
 					'meta_query' => array(
1329 1329
 						array(
@@ -1333,25 +1333,25 @@  discard block
 block discarded – undo
1333 1333
 					),
1334 1334
 				);
1335 1335
 
1336
-				$orders = get_posts( $order_args );
1336
+				$orders = get_posts($order_args);
1337 1337
 
1338 1338
 				$product_ids = array();
1339 1339
 				$order_ids = array();
1340 1340
 
1341
-				foreach( $orders as $post_id ) {
1341
+				foreach ($orders as $post_id) {
1342 1342
 
1343 1343
 					// Only process each order once
1344
-					$processed = get_post_meta( $post_id, 'sensei_products_processed', true );
1344
+					$processed = get_post_meta($post_id, 'sensei_products_processed', true);
1345 1345
 
1346
-					if( $processed && $processed == 'processed' ) {
1346
+					if ($processed && $processed == 'processed') {
1347 1347
 						continue;
1348 1348
 					}
1349 1349
 
1350 1350
 					// Get course product IDs from order
1351
-					$order = new WC_Order( $post_id );
1351
+					$order = new WC_Order($post_id);
1352 1352
 
1353 1353
 					$items = $order->get_items();
1354
-					foreach( $items as $item ) {
1354
+					foreach ($items as $item) {
1355 1355
                                             if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356 1356
                                                 $item_id = $item['variation_id'];
1357 1357
                                                 $product_type = 'variation';
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 					$order_ids[] = $post_id;
1366 1366
 				}
1367 1367
 
1368
-				if( count( $product_ids ) > 0 ) {
1368
+				if (count($product_ids) > 0) {
1369 1369
 
1370 1370
 					// Get all courses from user's orders
1371 1371
 					$course_args = array(
@@ -1382,31 +1382,31 @@  discard block
 block discarded – undo
1382 1382
 						'order' => 'ASC',
1383 1383
 						'fields' => 'ids',
1384 1384
 					);
1385
-					$course_ids = get_posts( $course_args );
1385
+					$course_ids = get_posts($course_args);
1386 1386
 
1387
-					foreach( $course_ids as $course_id ) {
1387
+					foreach ($course_ids as $course_id) {
1388 1388
 
1389
-						$user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id );
1389
+						$user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id);
1390 1390
 
1391 1391
 						// Ignore course if already completed
1392
-						if( Sensei_Utils::user_completed_course( $user_course_status ) ) {
1392
+						if (Sensei_Utils::user_completed_course($user_course_status)) {
1393 1393
 							continue;
1394 1394
 						}
1395 1395
 
1396 1396
 						// Ignore course if already started
1397
-						if( $user_course_status ) {
1397
+						if ($user_course_status) {
1398 1398
 							continue;
1399 1399
 						}
1400 1400
 
1401 1401
 						// Mark course as started by user
1402
-						Sensei_Utils::user_start_course( $user_id, $course_id );
1402
+						Sensei_Utils::user_start_course($user_id, $course_id);
1403 1403
 					}
1404 1404
 				}
1405 1405
 
1406
-				if( count( $order_ids ) > 0 ) {
1407
-					foreach( $order_ids as $order_id ) {
1406
+				if (count($order_ids) > 0) {
1407
+					foreach ($order_ids as $order_id) {
1408 1408
 						// Mark order as processed
1409
-						update_post_meta( $order_id, 'sensei_products_processed', 'processed' );
1409
+						update_post_meta($order_id, 'sensei_products_processed', 'processed');
1410 1410
 					}
1411 1411
 				}
1412 1412
 			}
@@ -1420,28 +1420,28 @@  discard block
 block discarded – undo
1420 1420
 	public function activate_purchased_single_course() {
1421 1421
 		global $post, $current_user;
1422 1422
 
1423
-		if( Sensei_WC::is_woocommerce_active() ) {
1423
+		if (Sensei_WC::is_woocommerce_active()) {
1424 1424
 
1425
-			if( ! is_user_logged_in() ) return;
1426
-			if( ! isset( $post->ID ) ) return;
1425
+			if ( ! is_user_logged_in()) return;
1426
+			if ( ! isset($post->ID)) return;
1427 1427
 
1428 1428
 			$user_id = $current_user->ID;
1429 1429
 			$course_id = $post->ID;
1430
-			$course_product_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
1431
-			if( ! $course_product_id ) {
1430
+			$course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
1431
+			if ( ! $course_product_id) {
1432 1432
 				return;
1433 1433
 			}
1434 1434
 
1435
-			$user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id );
1435
+			$user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id);
1436 1436
 
1437 1437
 			// Ignore course if already completed
1438
-			if( Sensei_Utils::user_completed_course( $user_course_status ) ) {
1438
+			if (Sensei_Utils::user_completed_course($user_course_status)) {
1439 1439
 
1440 1440
 				return;
1441 1441
 			}
1442 1442
 
1443 1443
 			// Ignore course if already started
1444
-			if( $user_course_status ) {
1444
+			if ($user_course_status) {
1445 1445
 				return;
1446 1446
 			}
1447 1447
 
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 			$order_args = array(
1450 1450
 				'post_type' => 'shop_order',
1451 1451
 				'posts_per_page' => -1,
1452
-				'post_status' => array( 'wc-processing', 'wc-completed' ),
1452
+				'post_status' => array('wc-processing', 'wc-completed'),
1453 1453
 				'meta_query' => array(
1454 1454
 					array(
1455 1455
 						'key' => '_customer_user',
@@ -1458,28 +1458,28 @@  discard block
 block discarded – undo
1458 1458
 				),
1459 1459
 				'fields' => 'ids',
1460 1460
 			);
1461
-			$orders = get_posts( $order_args );
1461
+			$orders = get_posts($order_args);
1462 1462
 
1463
-			foreach( $orders as $order_post_id ) {
1463
+			foreach ($orders as $order_post_id) {
1464 1464
 
1465 1465
 				// Get course product IDs from order
1466
-				$order = new WC_Order( $order_post_id );
1466
+				$order = new WC_Order($order_post_id);
1467 1467
 
1468 1468
 				$items = $order->get_items();
1469
-				foreach( $items as $item ) {
1469
+				foreach ($items as $item) {
1470 1470
 
1471
-                    $product = wc_get_product( $item['product_id'] );
1471
+                    $product = wc_get_product($item['product_id']);
1472 1472
 
1473 1473
                     // handle product bundles
1474
-                    if( is_object( $product ) &&  $product->is_type('bundle') ){
1474
+                    if (is_object($product) && $product->is_type('bundle')) {
1475 1475
 
1476
-                        $bundled_product = new WC_Product_Bundle( $product->id );
1476
+                        $bundled_product = new WC_Product_Bundle($product->id);
1477 1477
                         $bundled_items = $bundled_product->get_bundled_items();
1478 1478
 
1479
-                        foreach( $bundled_items as $bundled_item ){
1479
+                        foreach ($bundled_items as $bundled_item) {
1480 1480
 
1481
-                            if( $bundled_item->product_id == $course_product_id ) {
1482
-                                Sensei_Utils::user_start_course( $user_id, $course_id );
1481
+                            if ($bundled_item->product_id == $course_product_id) {
1482
+                                Sensei_Utils::user_start_course($user_id, $course_id);
1483 1483
                                 return;
1484 1484
                             }
1485 1485
 
@@ -1488,8 +1488,8 @@  discard block
 block discarded – undo
1488 1488
                     } else {
1489 1489
 
1490 1490
                     // handle regular products
1491
-                        if( $item['product_id'] == $course_product_id ) {
1492
-                            Sensei_Utils::user_start_course( $user_id, $course_id );
1491
+                        if ($item['product_id'] == $course_product_id) {
1492
+                            Sensei_Utils::user_start_course($user_id, $course_id);
1493 1493
                             return;
1494 1494
                         }
1495 1495
 
@@ -1505,9 +1505,9 @@  discard block
 block discarded – undo
1505 1505
 	 * @param  array  $args Default arguments
1506 1506
 	 * @return array        Modified arguments
1507 1507
 	 */
1508
-	public function hide_sensei_activity( $args = array() ) {
1508
+	public function hide_sensei_activity($args = array()) {
1509 1509
 
1510
-		if( is_singular( 'lesson' ) || is_singular( 'course' ) ) {
1510
+		if (is_singular('lesson') || is_singular('course')) {
1511 1511
 			$args['type'] = 'comment';
1512 1512
 		}
1513 1513
 
@@ -1524,9 +1524,9 @@  discard block
 block discarded – undo
1524 1524
 
1525 1525
 		//if not posted from the sensei login form let
1526 1526
 		// WordPress or any other party handle the failed request
1527
-	    if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form']  ){
1527
+	    if ( ! isset($_REQUEST['form']) || 'sensei-login' != $_REQUEST['form']) {
1528 1528
 
1529
-	    	return ;
1529
+	    	return;
1530 1530
 
1531 1531
 	    }
1532 1532
 
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 1534
     	$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);
1535 1535
 
1536 1536
    		 // if there's a valid referrer, and it's not the default log-in screen
1537
-	    if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
1537
+	    if ( ! empty($referrer) && ! strstr($referrer, 'wp-login') && ! strstr($referrer, 'wp-admin')) {
1538 1538
 	        // let's append some information (login=failed) to the URL for the theme to use
1539
-	        wp_redirect( esc_url_raw( add_query_arg('login', 'failed',  $referrer) ) );
1539
+	        wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1540 1540
 	    	exit;
1541 1541
     	}
1542 1542
 	}// End sensei_login_fail_redirect_to_front_end_login
@@ -1549,10 +1549,10 @@  discard block
 block discarded – undo
1549 1549
 	function sensei_handle_login_request( ) {
1550 1550
 
1551 1551
 		// Check that it is a sensei login request and if it has a valid nonce
1552
-	    if(  isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) {
1552
+	    if (isset($_REQUEST['form']) && 'sensei-login' == $_REQUEST['form']) {
1553 1553
 
1554 1554
 	    	// Validate the login request nonce
1555
-		    if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1555
+		    if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'sensei-login')) {
1556 1556
 		    	return;
1557 1557
 		    }
1558 1558
 
@@ -1560,48 +1560,48 @@  discard block
 block discarded – undo
1560 1560
 		    $referrer = $_REQUEST['_wp_http_referer'];
1561 1561
 		    //$redirect = $_REQUEST['_sensei_redirect'];
1562 1562
 
1563
-		    if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
1564
-		    	 && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){
1563
+		    if ((isset($_REQUEST['log']) && ! empty($_REQUEST['log']))
1564
+		    	 && (isset($_REQUEST['pwd']) && ! empty($_REQUEST['pwd']))) {
1565 1565
 
1566 1566
 		    	// when the user has entered a password or username do the sensei login
1567 1567
 		    	$creds = array();
1568 1568
 
1569 1569
 		    	// check if the requests login is an email address
1570
-		    	if( is_email(  trim( $_REQUEST['log'] ) )  ){
1570
+		    	if (is_email(trim($_REQUEST['log']))) {
1571 1571
 		    		// query wordpress for the users details
1572
-		    		$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1572
+		    		$user = get_user_by('email', sanitize_email($_REQUEST['log']));
1573 1573
 
1574 1574
 		    		// validate the user object
1575
-		    		if( !$user ){
1575
+		    		if ( ! $user) {
1576 1576
 
1577 1577
 		    			// the email doesnt exist
1578
-                        wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1578
+                        wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1579 1579
 		        		exit;
1580 1580
 
1581 1581
 		    		}
1582 1582
 
1583 1583
 		    		//assigne the username to the creds array for further processing
1584
-		    		$creds['user_login'] =  $user->user_login ;
1584
+		    		$creds['user_login'] = $user->user_login;
1585 1585
 
1586
-		    	}else{
1586
+		    	} else {
1587 1587
 
1588 1588
 		    		// process this as a default username login
1589
-		    		$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
1589
+		    		$creds['user_login'] = sanitize_text_field($_REQUEST['log']);
1590 1590
 
1591 1591
 		    	}
1592 1592
 
1593 1593
 				// get setup the rest of the creds array
1594
-				$creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] );
1595
-				$creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ;
1594
+				$creds['user_password'] = sanitize_text_field($_REQUEST['pwd']);
1595
+				$creds['remember'] = isset($_REQUEST['rememberme']) ? true : false;
1596 1596
 
1597 1597
 				//attempt logging in with the given details
1598 1598
 			    $secure_cookie = is_ssl() ? true : false;
1599
-			    $user = wp_signon( $creds, $secure_cookie );
1599
+			    $user = wp_signon($creds, $secure_cookie);
1600 1600
 
1601
-				if ( is_wp_error($user) ){ // on login failure
1602
-                    wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1601
+				if (is_wp_error($user)) { // on login failure
1602
+                    wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1603 1603
                     exit;
1604
-				}else{ // on login success
1604
+				} else { // on login success
1605 1605
 
1606 1606
 					/**
1607 1607
 					* change the redirect url programatically
@@ -1611,21 +1611,21 @@  discard block
 block discarded – undo
1611 1611
 					* @param string $referrer the page where the current url wheresensei login form was posted from
1612 1612
 					*/
1613 1613
 
1614
-					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) );
1614
+					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg('login', $referrer));
1615 1615
 
1616
-					wp_redirect( esc_url_raw( $success_redirect_url ) );
1616
+					wp_redirect(esc_url_raw($success_redirect_url));
1617 1617
 		        	exit;
1618 1618
 
1619 1619
 				}	// end is_wp_error($user)
1620 1620
 
1621
-		    }else{ // if username or password is empty
1621
+		    } else { // if username or password is empty
1622 1622
 
1623
-                wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1623
+                wp_redirect(esc_url_raw(add_query_arg('login', 'emptyfields', $referrer)));
1624 1624
 		        exit;
1625 1625
 
1626 1626
 		    } // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1627 1627
 
1628
-	    }elseif( ( isset( $_GET['login'] ) ) ) {
1628
+	    }elseif ((isset($_GET['login']))) {
1629 1629
 	    	// else if this request is a redircect from a previously faile login request
1630 1630
 	    	$this->login_message_process();
1631 1631
 
@@ -1644,87 +1644,87 @@  discard block
 block discarded – undo
1644 1644
 	 * @return void redirect
1645 1645
 	 *
1646 1646
 	 */
1647
-	public function sensei_process_registration(){
1647
+	public function sensei_process_registration() {
1648 1648
 		global 	 $current_user;
1649 1649
 		// check the for the sensei specific registration requests
1650
-		if( !isset( $_POST['sensei_reg_username'] ) && ! isset( $_POST['sensei_reg_email'] ) && !isset( $_POST['sensei_reg_password'] )){
1650
+		if ( ! isset($_POST['sensei_reg_username']) && ! isset($_POST['sensei_reg_email']) && ! isset($_POST['sensei_reg_password'])) {
1651 1651
 			// exit if this is not a sensei registration request
1652
-			return ;
1652
+			return;
1653 1653
 		}
1654 1654
 		// check for spam throw cheating huh
1655
-		if( isset( $_POST['email_2'] ) &&  '' !== $_POST['email_2']   ){
1655
+		if (isset($_POST['email_2']) && '' !== $_POST['email_2']) {
1656 1656
 			$message = 'Error:  The spam field should be empty';
1657
-			Sensei()->notices->add_notice( $message, 'alert');
1657
+			Sensei()->notices->add_notice($message, 'alert');
1658 1658
 			return;
1659 1659
 		}
1660 1660
 
1661 1661
 		// retreive form variables
1662
-		$new_user_name		= sanitize_user( $_POST['sensei_reg_username'] );
1663
-		$new_user_email		= $_POST['sensei_reg_email'];
1664
-		$new_user_password	= $_POST['sensei_reg_password'];
1662
+		$new_user_name = sanitize_user($_POST['sensei_reg_username']);
1663
+		$new_user_email = $_POST['sensei_reg_email'];
1664
+		$new_user_password = $_POST['sensei_reg_password'];
1665 1665
 
1666 1666
 		// Check the username
1667 1667
 		$username_error_notice = '';
1668
-		if ( $new_user_name == '' ) {
1669
-			$username_error_notice =  __( '<strong>ERROR</strong>: Please enter a username.' );
1670
-		} elseif ( ! validate_username( $new_user_name ) ) {
1671
-			$username_error_notice =  __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' );
1672
-		} elseif ( username_exists( $new_user_name ) ) {
1673
-			$username_error_notice =  __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' );
1668
+		if ($new_user_name == '') {
1669
+			$username_error_notice = __('<strong>ERROR</strong>: Please enter a username.');
1670
+		} elseif ( ! validate_username($new_user_name)) {
1671
+			$username_error_notice = __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.');
1672
+		} elseif (username_exists($new_user_name)) {
1673
+			$username_error_notice = __('<strong>ERROR</strong>: This username is already registered. Please choose another one.');
1674 1674
 		}
1675 1675
 
1676 1676
 		// exit on username error
1677
-		if( '' !== $username_error_notice ){
1678
-			Sensei()->notices->add_notice( $username_error_notice , 'alert');
1677
+		if ('' !== $username_error_notice) {
1678
+			Sensei()->notices->add_notice($username_error_notice, 'alert');
1679 1679
 			return;
1680 1680
 		}
1681 1681
 
1682 1682
 		// Check the e-mail address
1683 1683
 		$email_error_notice = '';
1684
-		if ( $new_user_email == '' ) {
1685
-			$email_error_notice = __( '<strong>ERROR</strong>: Please type your e-mail address.' );
1686
-		} elseif ( ! is_email( $new_user_email ) ) {
1687
-			$email_error_notice = __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' );
1688
-		} elseif ( email_exists( $new_user_email ) ) {
1689
-			$email_error_notice = __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' );
1684
+		if ($new_user_email == '') {
1685
+			$email_error_notice = __('<strong>ERROR</strong>: Please type your e-mail address.');
1686
+		} elseif ( ! is_email($new_user_email)) {
1687
+			$email_error_notice = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
1688
+		} elseif (email_exists($new_user_email)) {
1689
+			$email_error_notice = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');
1690 1690
 		}
1691 1691
 
1692 1692
 		// exit on email address error
1693
-		if( '' !== $email_error_notice ){
1694
-			Sensei()->notices->add_notice( $email_error_notice , 'alert');
1693
+		if ('' !== $email_error_notice) {
1694
+			Sensei()->notices->add_notice($email_error_notice, 'alert');
1695 1695
 			return;
1696 1696
 		}
1697 1697
 
1698 1698
 		//check user password
1699 1699
 
1700 1700
 		// exit on email address error
1701
-		if( empty( $new_user_password ) ){
1702
-			Sensei()->notices->add_notice(  __( '<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.' )  , 'alert');
1701
+		if (empty($new_user_password)) {
1702
+			Sensei()->notices->add_notice(__('<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.'), 'alert');
1703 1703
 			return;
1704 1704
 		}
1705 1705
 
1706 1706
 		// register user
1707
-		$user_id = wp_create_user( $new_user_name, $new_user_password, $new_user_email );
1708
-		if ( ! $user_id || is_wp_error( $user_id ) ) {
1709
-			Sensei()->notices->add_notice( sprintf( __( '<strong>ERROR</strong>: Couldn\'t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ), 'alert');
1707
+		$user_id = wp_create_user($new_user_name, $new_user_password, $new_user_email);
1708
+		if ( ! $user_id || is_wp_error($user_id)) {
1709
+			Sensei()->notices->add_notice(sprintf(__('<strong>ERROR</strong>: Couldn\'t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')), 'alert');
1710 1710
 		}
1711 1711
 
1712 1712
 		// notify the user
1713
-		wp_new_user_notification( $user_id, $new_user_password );
1713
+		wp_new_user_notification($user_id, $new_user_password);
1714 1714
 
1715 1715
 		// set global current user aka log the user in
1716
-		$current_user = get_user_by( 'id', $user_id );
1717
-		wp_set_auth_cookie( $user_id, true );
1716
+		$current_user = get_user_by('id', $user_id);
1717
+		wp_set_auth_cookie($user_id, true);
1718 1718
 
1719 1719
 		// Redirect
1720 1720
 		global $wp;
1721
-		if ( wp_get_referer() ) {
1722
-			$redirect = esc_url( wp_get_referer() );
1721
+		if (wp_get_referer()) {
1722
+			$redirect = esc_url(wp_get_referer());
1723 1723
 		} else {
1724
-			$redirect = esc_url( home_url( $wp->request ) );
1724
+			$redirect = esc_url(home_url($wp->request));
1725 1725
 		}
1726 1726
 
1727
-		wp_redirect( apply_filters( 'sensei_registration_redirect', $redirect ) );
1727
+		wp_redirect(apply_filters('sensei_registration_redirect', $redirect));
1728 1728
 		exit;
1729 1729
 
1730 1730
 	} // end  sensei_process_registration)()
@@ -1735,23 +1735,23 @@  discard block
 block discarded – undo
1735 1735
 	 * @return void redirect
1736 1736
 	 * @since 1.7.0
1737 1737
 	 */
1738
-	public function login_message_process(){
1738
+	public function login_message_process() {
1739 1739
 
1740 1740
             // setup the message variables
1741 1741
 			$message = '';
1742 1742
 
1743 1743
 			//only output message if the url contains login=failed and login=emptyfields
1744 1744
 
1745
-			if( $_GET['login'] == 'failed' ){
1745
+			if ($_GET['login'] == 'failed') {
1746 1746
 
1747
-				$message = __('Incorrect login details', 'woothemes-sensei' );
1747
+				$message = __('Incorrect login details', 'woothemes-sensei');
1748 1748
 
1749
-			}elseif( $_GET['login'] == 'emptyfields'  ){
1749
+			}elseif ($_GET['login'] == 'emptyfields') {
1750 1750
 
1751
-				$message= __('Please enter your username and password', 'woothemes-sensei' );
1751
+				$message = __('Please enter your username and password', 'woothemes-sensei');
1752 1752
 			}
1753 1753
 
1754
-			Sensei()->notices->add_notice( $message, 'alert');
1754
+			Sensei()->notices->add_notice($message, 'alert');
1755 1755
 
1756 1756
 	}// end login_message_process
1757 1757
 
@@ -1763,11 +1763,11 @@  discard block
 block discarded – undo
1763 1763
      * @return void redirect
1764 1764
      *
1765 1765
      */
1766
-    public function sensei_show_admin_bar () {
1766
+    public function sensei_show_admin_bar() {
1767 1767
 
1768 1768
         if (current_user_can('edit_courses')) {
1769 1769
 
1770
-            add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1);
1770
+            add_filter('woocommerce_disable_admin_bar', '__return_false', 10, 1);
1771 1771
 
1772 1772
         }
1773 1773
 
@@ -1780,4 +1780,4 @@  discard block
 block discarded – undo
1780 1780
  * @ignore only for backward compatibility
1781 1781
  * @since 1.9.0
1782 1782
  */
1783
-class WooThemes_Sensei_Frontend extends Sensei_Frontend{}
1783
+class WooThemes_Sensei_Frontend extends Sensei_Frontend {}
Please login to merge, or discard this patch.
includes/admin/class-sensei-learner-management.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -21,6 +21,7 @@
 block discarded – undo
21 21
 	/**
22 22
 	 * Constructor
23 23
 	 * @since  1.6.0
24
+	 * @param string $file
24 25
 	 * @return  void
25 26
 	 */
26 27
 	public function __construct ( $file ) {
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Learners Class
@@ -342,7 +345,7 @@  discard block
 block discarded – undo
342 345
 
343 346
                     $name = $full_name;
344 347
 
345
-                }else{
348
+                } else{
346 349
 
347 350
                     $name = $full_name . ' ['. $user->display_name .']';
348 351
 
@@ -359,11 +362,17 @@  discard block
 block discarded – undo
359 362
 
360 363
 		$result = false;
361 364
 
362
-		if( ! isset( $_POST['add_learner_submit'] ) ) return $result;
365
+		if( ! isset( $_POST['add_learner_submit'] ) ) {
366
+			return $result;
367
+		}
363 368
 
364
-		if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) return $result;
369
+		if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) {
370
+			return $result;
371
+		}
365 372
 
366
-		if( ( ! isset( $_POST['add_user_id'] ) || '' ==  $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) return $result;
373
+		if( ( ! isset( $_POST['add_user_id'] ) || '' ==  $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) {
374
+			return $result;
375
+		}
367 376
 
368 377
 		$post_type = $_POST['add_post_type'];
369 378
 		$user_id = absint( $_POST['add_user_id'] );
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 
79 79
 		// Load Learners JS
80 80
 		wp_enqueue_script( 'sensei-learners-general',
81
-            Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js',
82
-                            array('jquery','sensei-core-select2','sensei-chosen-ajax' ), Sensei()->version, true );
81
+			Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js',
82
+							array('jquery','sensei-core-select2','sensei-chosen-ajax' ), Sensei()->version, true );
83 83
 
84 84
 		$data = array(
85 85
 			'remove_generic_confirm' => __( 'Are you sure you want to remove this user?', 'woothemes-sensei' ),
86 86
 			'remove_from_lesson_confirm' => __( 'Are you sure you want to remove the user from this lesson?', 'woothemes-sensei' ),
87 87
 			'remove_from_course_confirm' => __( 'Are you sure you want to remove the user from this course?', 'woothemes-sensei' ),
88 88
 			'remove_user_from_post_nonce' => wp_create_nonce( 'remove_user_from_post_nonce' ),
89
-            'search_users_nonce' => wp_create_nonce( 'search-users' ),
90
-            'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' )
89
+			'search_users_nonce' => wp_create_nonce( 'search-users' ),
90
+			'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' )
91 91
 		);
92 92
 
93 93
 		wp_localize_script( 'sensei-learners-general', 'woo_learners_general_data', $data );
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	/**
187 187
 	 * learners_headers outputs Learners general headers
188 188
 	 * @since  1.6.0
189
-     * @param array $args
189
+	 * @param array $args
190 190
 	 * @return void
191 191
 	 */
192 192
 	public function learners_headers( $args = array( 'nav' => 'default' ) ) {
@@ -252,38 +252,38 @@  discard block
 block discarded – undo
252 252
 
253 253
 	public function remove_user_from_post() {
254 254
 
255
-        // Parse POST data
256
-        $data = sanitize_text_field( $_POST['data'] );
257
-        $action_data = array();
258
-        parse_str( $data, $action_data );
255
+		// Parse POST data
256
+		$data = sanitize_text_field( $_POST['data'] );
257
+		$action_data = array();
258
+		parse_str( $data, $action_data );
259 259
 
260 260
 		// Security checks
261
-        // ensure the current user may remove users from post
262
-        // only teacher or admin can remove users
261
+		// ensure the current user may remove users from post
262
+		// only teacher or admin can remove users
263 263
 
264
-        // check the nonce, valid post
264
+		// check the nonce, valid post
265 265
 		$nonce = '';
266 266
 		if ( isset($_POST['remove_user_from_post_nonce']) ) {
267 267
 			$nonce = esc_html( $_POST['remove_user_from_post_nonce'] );
268 268
 		}
269
-        $post =  get_post( intval( $action_data[ 'post_id' ] ) );
269
+		$post =  get_post( intval( $action_data[ 'post_id' ] ) );
270 270
 
271
-        // validate the user
272
-        $may_remove_user = false;
273
-        if( current_user_can('manage_sensei')
274
-            ||  $post->post_author == get_current_user_id() ){
271
+		// validate the user
272
+		$may_remove_user = false;
273
+		if( current_user_can('manage_sensei')
274
+			||  $post->post_author == get_current_user_id() ){
275 275
 
276
-            $may_remove_user = true;
276
+			$may_remove_user = true;
277 277
 
278
-        }
278
+		}
279 279
 
280
-        if( ! wp_verify_nonce( $nonce, 'remove_user_from_post_nonce' )
281
-            || ! is_a( $post ,'WP_Post' )
282
-            || ! $may_remove_user ){
280
+		if( ! wp_verify_nonce( $nonce, 'remove_user_from_post_nonce' )
281
+			|| ! is_a( $post ,'WP_Post' )
282
+			|| ! $may_remove_user ){
283 283
 
284
-            die('');
284
+			die('');
285 285
 
286
-        }
286
+		}
287 287
 
288 288
 		if( $action_data['user_id'] && $action_data['post_id'] && $action_data['post_type'] ) {
289 289
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
 				case 'course':
299 299
 
300
-                    $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id );
300
+					$removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id );
301 301
 
302 302
 				break;
303 303
 
@@ -344,19 +344,19 @@  discard block
 block discarded – undo
344 344
 
345 345
 		if ( $users ) {
346 346
 			foreach ( $users as $user ) {
347
-                $full_name = Sensei_Learner::get_full_name( $user->ID );
347
+				$full_name = Sensei_Learner::get_full_name( $user->ID );
348 348
 
349
-                if( trim($user->display_name ) == trim( $full_name ) ){
349
+				if( trim($user->display_name ) == trim( $full_name ) ){
350 350
 
351
-                    $name = $full_name;
351
+					$name = $full_name;
352 352
 
353
-                }else{
353
+				}else{
354 354
 
355
-                    $name = $full_name . ' ['. $user->display_name .']';
355
+					$name = $full_name . ' ['. $user->display_name .']';
356 356
 
357
-                }
357
+				}
358 358
 
359
-                $found_users[ $user->ID ] = $name  . ' (#' . $user->ID . ' &ndash; ' . sanitize_email( $user->user_email ) . ')';
359
+				$found_users[ $user->ID ] = $name  . ' (#' . $user->ID . ' &ndash; ' . sanitize_email( $user->user_email ) . ')';
360 360
 			}
361 361
 		}
362 362
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			break;
401 401
 
402 402
 			case 'lesson':
403
-                $lesson_id = absint( $_POST['add_lesson_id'] );
403
+				$lesson_id = absint( $_POST['add_lesson_id'] );
404 404
 				$complete = false;
405 405
 				if( isset( $_POST['add_complete_lesson'] ) && 'yes' == $_POST['add_complete_lesson'] ) {
406 406
 					$complete = true;
@@ -460,23 +460,23 @@  discard block
 block discarded – undo
460 460
 		}
461 461
 	}
462 462
 
463
-    /**
464
-     * Return the full name and surname or the display name of the user.
465
-     *
466
-     * The user must have both name and surname otherwise display name will be returned.
467
-     *
468
-     * @deprecated since 1.9.0 use Se
469
-     * @since 1.8.0
470
-     *
471
-     * @param int $user_id | bool false for an invalid $user_id
472
-     *
473
-     * @return string $full_name
474
-     */
475
-    public function get_learner_full_name( $user_id ){
476
-
477
-        return Sensei_Learner::get_full_name( $user_id );
478
-
479
-    } // end get_learner_full_name
463
+	/**
464
+	 * Return the full name and surname or the display name of the user.
465
+	 *
466
+	 * The user must have both name and surname otherwise display name will be returned.
467
+	 *
468
+	 * @deprecated since 1.9.0 use Se
469
+	 * @since 1.8.0
470
+	 *
471
+	 * @param int $user_id | bool false for an invalid $user_id
472
+	 *
473
+	 * @return string $full_name
474
+	 */
475
+	public function get_learner_full_name( $user_id ){
476
+
477
+		return Sensei_Learner::get_full_name( $user_id );
478
+
479
+	} // end get_learner_full_name
480 480
 
481 481
 } // End Class
482 482
 
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Learners Class
@@ -22,30 +22,30 @@  discard block
 block discarded – undo
22 22
 	 * @since  1.6.0
23 23
 	 * @return  void
24 24
 	 */
25
-	public function __construct ( $file ) {
26
-		$this->name = __( 'Learner Management', 'woothemes-sensei' );;
25
+	public function __construct($file) {
26
+		$this->name = __('Learner Management', 'woothemes-sensei'); ;
27 27
 		$this->file = $file;
28 28
 		$this->page_slug = 'sensei_learners';
29 29
 
30 30
 		// Admin functions
31
-		if ( is_admin() ) {
32
-			add_action( 'admin_menu', array( $this, 'learners_admin_menu' ), 30);
33
-			add_action( 'learners_wrapper_container', array( $this, 'wrapper_container'  ) );
34
-			if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
35
-				add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
36
-				add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
31
+		if (is_admin()) {
32
+			add_action('admin_menu', array($this, 'learners_admin_menu'), 30);
33
+			add_action('learners_wrapper_container', array($this, 'wrapper_container'));
34
+			if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
35
+				add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
36
+				add_action('admin_print_styles', array($this, 'enqueue_styles'));
37 37
 			}
38 38
 
39
-			add_action( 'admin_init', array( $this, 'add_new_learners' ) );
39
+			add_action('admin_init', array($this, 'add_new_learners'));
40 40
 
41
-			add_action( 'admin_notices', array( $this, 'add_learner_notices' ) );
41
+			add_action('admin_notices', array($this, 'add_learner_notices'));
42 42
 		} // End If Statement
43 43
 
44 44
 		// Ajax functions
45
-		if ( is_admin() ) {
46
-			add_action( 'wp_ajax_get_redirect_url_learners', array( $this, 'get_redirect_url' ) );
47
-			add_action( 'wp_ajax_remove_user_from_post', array( $this, 'remove_user_from_post' ) );
48
-			add_action( 'wp_ajax_sensei_json_search_users', array( $this, 'json_search_users' ) );
45
+		if (is_admin()) {
46
+			add_action('wp_ajax_get_redirect_url_learners', array($this, 'get_redirect_url'));
47
+			add_action('wp_ajax_remove_user_from_post', array($this, 'remove_user_from_post'));
48
+			add_action('wp_ajax_sensei_json_search_users', array($this, 'json_search_users'));
49 49
 		}
50 50
 	} // End __construct()
51 51
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	public function learners_admin_menu() {
59 59
 		global $menu;
60 60
 
61
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
62
-			$learners_page = add_submenu_page( 'sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array( $this, 'learners_page' ) );
61
+		if (current_user_can('manage_sensei_grades')) {
62
+			$learners_page = add_submenu_page('sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array($this, 'learners_page'));
63 63
 		}
64 64
 
65 65
 	} // End learners_admin_menu()
@@ -72,25 +72,25 @@  discard block
 block discarded – undo
72 72
 	 * @since 1.6.0
73 73
 	 * @return void
74 74
 	 */
75
-	public function enqueue_scripts () {
75
+	public function enqueue_scripts() {
76 76
 
77
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
77
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
78 78
 
79 79
 		// Load Learners JS
80
-		wp_enqueue_script( 'sensei-learners-general',
81
-            Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js',
82
-                            array('jquery','sensei-core-select2','sensei-chosen-ajax' ), Sensei()->version, true );
80
+		wp_enqueue_script('sensei-learners-general',
81
+            Sensei()->plugin_url.'assets/js/learners-general'.$suffix.'.js',
82
+                            array('jquery', 'sensei-core-select2', 'sensei-chosen-ajax'), Sensei()->version, true);
83 83
 
84 84
 		$data = array(
85
-			'remove_generic_confirm' => __( 'Are you sure you want to remove this user?', 'woothemes-sensei' ),
86
-			'remove_from_lesson_confirm' => __( 'Are you sure you want to remove the user from this lesson?', 'woothemes-sensei' ),
87
-			'remove_from_course_confirm' => __( 'Are you sure you want to remove the user from this course?', 'woothemes-sensei' ),
88
-			'remove_user_from_post_nonce' => wp_create_nonce( 'remove_user_from_post_nonce' ),
89
-            'search_users_nonce' => wp_create_nonce( 'search-users' ),
90
-            'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' )
85
+			'remove_generic_confirm' => __('Are you sure you want to remove this user?', 'woothemes-sensei'),
86
+			'remove_from_lesson_confirm' => __('Are you sure you want to remove the user from this lesson?', 'woothemes-sensei'),
87
+			'remove_from_course_confirm' => __('Are you sure you want to remove the user from this course?', 'woothemes-sensei'),
88
+			'remove_user_from_post_nonce' => wp_create_nonce('remove_user_from_post_nonce'),
89
+            'search_users_nonce' => wp_create_nonce('search-users'),
90
+            'selectplaceholder'=> __('Select Learner', 'woothemes-sensei')
91 91
 		);
92 92
 
93
-		wp_localize_script( 'sensei-learners-general', 'woo_learners_general_data', $data );
93
+		wp_localize_script('sensei-learners-general', 'woo_learners_general_data', $data);
94 94
 
95 95
 	} // End enqueue_scripts()
96 96
 
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	 * @since 1.6.0
103 103
 	 * @return void
104 104
 	 */
105
-	public function enqueue_styles () {
105
+	public function enqueue_styles() {
106 106
 
107
-		wp_enqueue_style( 'woothemes-sensei-admin' );
107
+		wp_enqueue_style('woothemes-sensei-admin');
108 108
 
109 109
 	} // End enqueue_styles()
110 110
 
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	public function load_data_table_files() {
117 117
 
118 118
 		// Load Learners Classes
119
-		$classes_to_load = array(	'list-table',
119
+		$classes_to_load = array('list-table',
120 120
 									'learners-main',
121 121
 									);
122
-		foreach ( $classes_to_load as $class_file ) {
123
-			Sensei()->load_class( $class_file );
122
+		foreach ($classes_to_load as $class_file) {
123
+			Sensei()->load_class($class_file);
124 124
 		} // End For Loop
125 125
 
126 126
 	} // End load_data_table_files()
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 	 * @param  undefined  $optional_data optional constructor arguments
134 134
 	 * @return object                 class instance object
135 135
 	 */
136
-	public function load_data_object( $name = '', $data = 0, $optional_data = null ) {
136
+	public function load_data_object($name = '', $data = 0, $optional_data = null) {
137 137
 		// Load Analysis data
138
-		$object_name = 'WooThemes_Sensei_Learners_' . $name;
139
-		if ( is_null($optional_data) ) {
140
-			$sensei_learners_object = new $object_name( $data );
138
+		$object_name = 'WooThemes_Sensei_Learners_'.$name;
139
+		if (is_null($optional_data)) {
140
+			$sensei_learners_object = new $object_name($data);
141 141
 		} else {
142
-			$sensei_learners_object = new $object_name( $data, $optional_data );
142
+			$sensei_learners_object = new $object_name($data, $optional_data);
143 143
 		} // End If Statement
144
-		if ( 'Main' == $name ) {
144
+		if ('Main' == $name) {
145 145
 			$sensei_learners_object->prepare_items();
146 146
 		} // End If Statement
147 147
 		return $sensei_learners_object;
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 		// Load Learners data
159 159
 		$course_id = 0;
160 160
 		$lesson_id = 0;
161
-		if( isset( $_GET['course_id'] ) ) {
162
-			$course_id = intval( $_GET['course_id'] );
161
+		if (isset($_GET['course_id'])) {
162
+			$course_id = intval($_GET['course_id']);
163 163
 		}
164
-		if( isset( $_GET['lesson_id'] ) ) {
165
-			$lesson_id = intval( $_GET['lesson_id'] );
164
+		if (isset($_GET['lesson_id'])) {
165
+			$lesson_id = intval($_GET['lesson_id']);
166 166
 		}
167
-		$sensei_learners_main = $this->load_data_object( 'Main', $course_id, $lesson_id );
167
+		$sensei_learners_main = $this->load_data_object('Main', $course_id, $lesson_id);
168 168
 		// Wrappers
169
-		do_action( 'learners_before_container' );
170
-		do_action( 'learners_wrapper_container', 'top' );
169
+		do_action('learners_before_container');
170
+		do_action('learners_wrapper_container', 'top');
171 171
 		$this->learners_headers();
172 172
 		?>
173 173
 		<div id="poststuff" class="sensei-learners-wrap">
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
 				<?php $sensei_learners_main->display(); ?>
176 176
 			</div>
177 177
 			<div class="sensei-learners-extra">
178
-				<?php do_action( 'sensei_learners_extra' ); ?>
178
+				<?php do_action('sensei_learners_extra'); ?>
179 179
 			</div>
180 180
 		</div>
181 181
 		<?php
182
-		do_action( 'learners_wrapper_container', 'bottom' );
183
-		do_action( 'learners_after_container' );
182
+		do_action('learners_wrapper_container', 'bottom');
183
+		do_action('learners_after_container');
184 184
 	} // End learners_default_view()
185 185
 
186 186
 	/**
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
      * @param array $args
190 190
 	 * @return void
191 191
 	 */
192
-	public function learners_headers( $args = array( 'nav' => 'default' ) ) {
192
+	public function learners_headers($args = array('nav' => 'default')) {
193 193
 
194
-		$function = 'learners_' . $args['nav'] . '_nav';
194
+		$function = 'learners_'.$args['nav'].'_nav';
195 195
 		$this->$function();
196 196
 		?>
197
-			<p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
197
+			<p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
198 198
 		<?php
199
-		do_action( 'sensei_learners_after_headers' );
199
+		do_action('sensei_learners_after_headers');
200 200
 
201 201
 	} // End learners_headers()
202 202
 
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * @param $which string
207 207
 	 * @return void
208 208
 	 */
209
-	public function wrapper_container( $which ) {
210
-		if ( 'top' == $which ) {
209
+	public function wrapper_container($which) {
210
+		if ('top' == $which) {
211 211
 			?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php
212
-		} elseif ( 'bottom' == $which ) {
212
+		} elseif ('bottom' == $which) {
213 213
 			?></div><!--/#woothemes-sensei--><?php
214 214
 		} // End If Statement
215 215
 	} // End wrapper_container()
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 	 * @return void
221 221
 	 */
222 222
 	public function learners_default_nav() {
223
-		$title = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ) ), esc_html( $this->name ) );
224
-		if ( isset( $_GET['course_id'] ) ) { 
225
-			$course_id = intval( $_GET['course_id'] );
226
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) );
227
-			$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) );
223
+		$title = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('page' => $this->page_slug), admin_url('admin.php'))), esc_html($this->name));
224
+		if (isset($_GET['course_id'])) { 
225
+			$course_id = intval($_GET['course_id']);
226
+			$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners'), admin_url('admin.php'));
227
+			$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id));
228 228
 		}
229
-		if ( isset( $_GET['lesson_id'] ) ) { 
230
-			$lesson_id = intval( $_GET['lesson_id'] );
231
-			$title .= '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;' . get_the_title( intval( $lesson_id ) ) . '</span>'; 
229
+		if (isset($_GET['lesson_id'])) { 
230
+			$lesson_id = intval($_GET['lesson_id']);
231
+			$title .= '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;'.get_the_title(intval($lesson_id)).'</span>'; 
232 232
 		}
233 233
 		?>
234
-			<h2><?php echo apply_filters( 'sensei_learners_nav_title', $title ); ?></h2>
234
+			<h2><?php echo apply_filters('sensei_learners_nav_title', $title); ?></h2>
235 235
 		<?php
236 236
 	} // End learners_default_nav()
237 237
 
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
 		// Parse POST data
241 241
 		$data = $_POST['data'];
242 242
 		$course_data = array();
243
-		parse_str( $data, $course_data );
243
+		parse_str($data, $course_data);
244 244
 
245
-		$course_cat = intval( $course_data['course_cat'] );
245
+		$course_cat = intval($course_data['course_cat']);
246 246
 
247
-		$redirect_url = apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'course_cat' => $course_cat ), admin_url( 'admin.php' ) ) );
247
+		$redirect_url = apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'course_cat' => $course_cat), admin_url('admin.php')));
248 248
 
249
-		echo esc_url_raw( $redirect_url );
249
+		echo esc_url_raw($redirect_url);
250 250
 		die();
251 251
 	}
252 252
 
253 253
 	public function remove_user_from_post() {
254 254
 
255 255
         // Parse POST data
256
-        $data = sanitize_text_field( $_POST['data'] );
256
+        $data = sanitize_text_field($_POST['data']);
257 257
         $action_data = array();
258
-        parse_str( $data, $action_data );
258
+        parse_str($data, $action_data);
259 259
 
260 260
 		// Security checks
261 261
         // ensure the current user may remove users from post
@@ -263,54 +263,54 @@  discard block
 block discarded – undo
263 263
 
264 264
         // check the nonce, valid post
265 265
 		$nonce = '';
266
-		if ( isset($_POST['remove_user_from_post_nonce']) ) {
267
-			$nonce = esc_html( $_POST['remove_user_from_post_nonce'] );
266
+		if (isset($_POST['remove_user_from_post_nonce'])) {
267
+			$nonce = esc_html($_POST['remove_user_from_post_nonce']);
268 268
 		}
269
-        $post =  get_post( intval( $action_data[ 'post_id' ] ) );
269
+        $post = get_post(intval($action_data['post_id']));
270 270
 
271 271
         // validate the user
272 272
         $may_remove_user = false;
273
-        if( current_user_can('manage_sensei')
274
-            ||  $post->post_author == get_current_user_id() ){
273
+        if (current_user_can('manage_sensei')
274
+            ||  $post->post_author == get_current_user_id()) {
275 275
 
276 276
             $may_remove_user = true;
277 277
 
278 278
         }
279 279
 
280
-        if( ! wp_verify_nonce( $nonce, 'remove_user_from_post_nonce' )
281
-            || ! is_a( $post ,'WP_Post' )
282
-            || ! $may_remove_user ){
280
+        if ( ! wp_verify_nonce($nonce, 'remove_user_from_post_nonce')
281
+            || ! is_a($post, 'WP_Post')
282
+            || ! $may_remove_user) {
283 283
 
284 284
             die('');
285 285
 
286 286
         }
287 287
 
288
-		if( $action_data['user_id'] && $action_data['post_id'] && $action_data['post_type'] ) {
288
+		if ($action_data['user_id'] && $action_data['post_id'] && $action_data['post_type']) {
289 289
 
290
-			$user_id = intval( $action_data['user_id'] );
291
-			$post_id = intval( $action_data['post_id'] );
292
-			$post_type = sanitize_text_field( $action_data['post_type'] );
290
+			$user_id = intval($action_data['user_id']);
291
+			$post_id = intval($action_data['post_id']);
292
+			$post_type = sanitize_text_field($action_data['post_type']);
293 293
 
294
-			$user = get_userdata( $user_id );
294
+			$user = get_userdata($user_id);
295 295
 
296
-			switch( $post_type ) {
296
+			switch ($post_type) {
297 297
 
298 298
 				case 'course':
299 299
 
300
-                    $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id );
300
+                    $removed = Sensei_Utils::sensei_remove_user_from_course($post_id, $user_id);
301 301
 
302 302
 				break;
303 303
 
304 304
 				case 'lesson':
305 305
 
306
-					$removed = Sensei_Utils::sensei_remove_user_from_lesson( $post_id, $user_id );
306
+					$removed = Sensei_Utils::sensei_remove_user_from_lesson($post_id, $user_id);
307 307
 
308 308
 				break;
309 309
 
310 310
 			}
311 311
 
312
-			if( $removed ) {
313
-				die( 'removed' );
312
+			if ($removed) {
313
+				die('removed');
314 314
 			}
315 315
 
316 316
 		}
@@ -321,109 +321,109 @@  discard block
 block discarded – undo
321 321
 	public function json_search_users() {
322 322
 
323 323
 
324
-		check_ajax_referer( 'search-users', 'security' );
324
+		check_ajax_referer('search-users', 'security');
325 325
 
326
-		$term = sanitize_text_field( stripslashes( $_GET['term'] ) );
326
+		$term = sanitize_text_field(stripslashes($_GET['term']));
327 327
 
328
-		if ( empty( $term ) ) {
328
+		if (empty($term)) {
329 329
 			die();
330 330
 		}
331 331
 
332
-		$default = isset( $_GET['default'] ) ? $_GET['default'] : __( 'None', 'woocommerce' );
332
+		$default = isset($_GET['default']) ? $_GET['default'] : __('None', 'woocommerce');
333 333
 
334
-		$found_users = array( '' => $default );
334
+		$found_users = array('' => $default);
335 335
 
336
-		$users_query = new WP_User_Query( apply_filters( 'sensei_json_search_users_query', array(
336
+		$users_query = new WP_User_Query(apply_filters('sensei_json_search_users_query', array(
337 337
 			'fields'         => 'all',
338 338
 			'orderby'        => 'display_name',
339
-			'search'         => '*' . $term . '*',
340
-			'search_columns' => array( 'ID', 'user_login', 'user_email', 'user_nicename','user_firstname','user_lastname' )
341
-		), $term ) );
339
+			'search'         => '*'.$term.'*',
340
+			'search_columns' => array('ID', 'user_login', 'user_email', 'user_nicename', 'user_firstname', 'user_lastname')
341
+		), $term));
342 342
 
343 343
 		$users = $users_query->get_results();
344 344
 
345
-		if ( $users ) {
346
-			foreach ( $users as $user ) {
347
-                $full_name = Sensei_Learner::get_full_name( $user->ID );
345
+		if ($users) {
346
+			foreach ($users as $user) {
347
+                $full_name = Sensei_Learner::get_full_name($user->ID);
348 348
 
349
-                if( trim($user->display_name ) == trim( $full_name ) ){
349
+                if (trim($user->display_name) == trim($full_name)) {
350 350
 
351 351
                     $name = $full_name;
352 352
 
353
-                }else{
353
+                } else {
354 354
 
355
-                    $name = $full_name . ' ['. $user->display_name .']';
355
+                    $name = $full_name.' ['.$user->display_name.']';
356 356
 
357 357
                 }
358 358
 
359
-                $found_users[ $user->ID ] = $name  . ' (#' . $user->ID . ' &ndash; ' . sanitize_email( $user->user_email ) . ')';
359
+                $found_users[$user->ID] = $name.' (#'.$user->ID.' &ndash; '.sanitize_email($user->user_email).')';
360 360
 			}
361 361
 		}
362 362
 
363
-		wp_send_json( $found_users );
363
+		wp_send_json($found_users);
364 364
 	}
365 365
 
366 366
 	public function add_new_learners() {
367 367
 
368 368
 		$result = false;
369 369
 
370
-		if( ! isset( $_POST['add_learner_submit'] ) ) return $result;
370
+		if ( ! isset($_POST['add_learner_submit'])) return $result;
371 371
 
372
-		if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) return $result;
372
+		if ( ! isset($_POST['add_learner_nonce']) || ! wp_verify_nonce($_POST['add_learner_nonce'], 'add_learner_to_sensei')) return $result;
373 373
 
374
-		if( ( ! isset( $_POST['add_user_id'] ) || '' ==  $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) return $result;
374
+		if (( ! isset($_POST['add_user_id']) || '' == $_POST['add_user_id']) || ! isset($_POST['add_post_type']) || ! isset($_POST['add_course_id']) || ! isset($_POST['add_lesson_id'])) return $result;
375 375
 
376 376
 		$post_type = $_POST['add_post_type'];
377
-		$user_id = absint( $_POST['add_user_id'] );
378
-		$course_id = absint( $_POST['add_course_id'] );
377
+		$user_id = absint($_POST['add_user_id']);
378
+		$course_id = absint($_POST['add_course_id']);
379 379
 
380
-		switch( $post_type ) {
380
+		switch ($post_type) {
381 381
 			case 'course':
382 382
 
383
-				$result = Sensei_Utils::user_start_course( $user_id, $course_id );
383
+				$result = Sensei_Utils::user_start_course($user_id, $course_id);
384 384
 
385 385
 				// Complete each lesson if course is set to be completed
386
-				if( isset( $_POST['add_complete_course'] ) && 'yes' == $_POST['add_complete_course'] ) {
386
+				if (isset($_POST['add_complete_course']) && 'yes' == $_POST['add_complete_course']) {
387 387
 
388
-					$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
388
+					$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
389 389
 
390
-					foreach( $lesson_ids as $id ) {
391
-						Sensei_Utils::sensei_start_lesson( $id, $user_id, true );
390
+					foreach ($lesson_ids as $id) {
391
+						Sensei_Utils::sensei_start_lesson($id, $user_id, true);
392 392
 					}
393 393
 
394 394
 					// Updates the Course status and it's meta data
395
-					Sensei_Utils::user_complete_course( $course_id, $user_id );
395
+					Sensei_Utils::user_complete_course($course_id, $user_id);
396 396
 
397
-					do_action( 'sensei_user_course_end', $user_id, $course_id );
397
+					do_action('sensei_user_course_end', $user_id, $course_id);
398 398
 				}
399 399
 
400 400
 			break;
401 401
 
402 402
 			case 'lesson':
403
-                $lesson_id = absint( $_POST['add_lesson_id'] );
403
+                $lesson_id = absint($_POST['add_lesson_id']);
404 404
 				$complete = false;
405
-				if( isset( $_POST['add_complete_lesson'] ) && 'yes' == $_POST['add_complete_lesson'] ) {
405
+				if (isset($_POST['add_complete_lesson']) && 'yes' == $_POST['add_complete_lesson']) {
406 406
 					$complete = true;
407 407
 				}
408 408
 
409
-				$result = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id, $complete );
409
+				$result = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, $complete);
410 410
 
411 411
 				// Updates the Course status and it's meta data
412
-				Sensei_Utils::user_complete_course( $course_id, $user_id );
412
+				Sensei_Utils::user_complete_course($course_id, $user_id);
413 413
 
414 414
 			break;
415 415
 		}
416 416
 
417 417
 		// Set redirect URL after adding user to course/lesson
418
-		$query_args = array( 'page' => $this->page_slug, 'view' => 'learners' );
418
+		$query_args = array('page' => $this->page_slug, 'view' => 'learners');
419 419
 
420
-		if( $result ) {
420
+		if ($result) {
421 421
 
422
-			if( $course_id ) {
422
+			if ($course_id) {
423 423
 				$query_args['course_id'] = $course_id;
424 424
 			}
425 425
 
426
-			if( $lesson_id ) {
426
+			if ($lesson_id) {
427 427
 				$query_args['lesson_id'] = $lesson_id;
428 428
 			}
429 429
 
@@ -433,23 +433,23 @@  discard block
 block discarded – undo
433 433
 			$query_args['message'] = 'error';
434 434
 		}
435 435
 
436
-		$redirect_url = apply_filters( 'sensei_learners_add_learner_redirect_url', add_query_arg( $query_args, admin_url( 'admin.php' ) ) );
436
+		$redirect_url = apply_filters('sensei_learners_add_learner_redirect_url', add_query_arg($query_args, admin_url('admin.php')));
437 437
 
438
-		wp_safe_redirect( esc_url_raw( $redirect_url ) );
438
+		wp_safe_redirect(esc_url_raw($redirect_url));
439 439
 		exit;
440 440
 	}
441 441
 
442 442
 	public function add_learner_notices() {
443
-		if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) {
444
-			if( 'success' == $_GET['message'] ) {
443
+		if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) {
444
+			if ('success' == $_GET['message']) {
445 445
 				$msg = array(
446 446
 					'updated',
447
-					__( 'Learner added successfully!', 'woothemes-sensei' ),
447
+					__('Learner added successfully!', 'woothemes-sensei'),
448 448
 				);
449 449
 			} else {
450 450
 				$msg = array(
451 451
 					'error',
452
-					__( 'Error adding learner.', 'woothemes-sensei' ),
452
+					__('Error adding learner.', 'woothemes-sensei'),
453 453
 				);
454 454
 			}
455 455
 			?>
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
      *
473 473
      * @return string $full_name
474 474
      */
475
-    public function get_learner_full_name( $user_id ){
475
+    public function get_learner_full_name($user_id) {
476 476
 
477
-        return Sensei_Learner::get_full_name( $user_id );
477
+        return Sensei_Learner::get_full_name($user_id);
478 478
 
479 479
     } // end get_learner_full_name
480 480
 
@@ -485,4 +485,4 @@  discard block
 block discarded – undo
485 485
  * @ignore only for backward compatibility
486 486
  * @since 1.9.0
487 487
  */
488
-class WooThemes_Sensei_Learners extends Sensei_Learner_Management{}
488
+class WooThemes_Sensei_Learners extends Sensei_Learner_Management {}
Please login to merge, or discard this patch.
includes/theme-integrations/theme-integration-loader.php 2 patches
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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @since 1.9.0
37 37
      */
38
-    private function setup_themes(){
38
+    private function setup_themes() {
39 39
 
40 40
         $this->themes = array(
41 41
             'twentyeleven',
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @since 1.9.0
56 56
      */
57
-    private function setup_currently_active_theme(){
57
+    private function setup_currently_active_theme() {
58 58
 
59 59
         $this->active_theme = get_option('template');
60 60
 
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @since 1.9.0
69 69
      */
70
-    private function possibly_load_supported_theme_wrappers(){
70
+    private function possibly_load_supported_theme_wrappers() {
71 71
 
72
-        if ( in_array( $this->active_theme, $this->themes ) ){
72
+        if (in_array($this->active_theme, $this->themes)) {
73 73
 
74 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  );
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 77
 
78 78
             // load the file or exit if there is no file for this theme
79
-            if( ! file_exists( $supported_theme_class_file ) ){
79
+            if ( ! file_exists($supported_theme_class_file)) {
80 80
                 return;
81 81
             }
82
-            include_once( $supported_theme_class_file );
83
-            include_once( 'twentytwelve.php' );
82
+            include_once($supported_theme_class_file);
83
+            include_once('twentytwelve.php');
84 84
             //initialize the class or exit if there is no class for this theme
85
-            if( ! class_exists( $supported_theme_class_name ) ){
85
+            if ( ! class_exists($supported_theme_class_name)) {
86 86
                 return;
87 87
             }
88 88
             $supported_theme = new $supported_theme_class_name;
89 89
 
90 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 );
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 93
 
94 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 );
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 97
         }
98 98
     }
99 99
 
Please login to merge, or discard this patch.