Completed
Push — master ( 80c0ca...82d23b )
by Dwain
04:32
created
includes/class-sensei-lesson.php 4 patches
Braces   +28 added lines, -16 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 Lessons Class
@@ -378,8 +381,7 @@  discard block
 block discarded – undo
378 381
 		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
379 382
 		if( 0 < count( $quiz_questions ) ) {
380 383
 			update_post_meta( $post_id, '_quiz_has_questions', '1' );
381
-		}
382
-		else {
384
+		} else {
383 385
 			delete_post_meta( $post_id, '_quiz_has_questions' );
384 386
 		}
385 387
 
@@ -390,7 +392,9 @@  discard block
 block discarded – undo
390 392
 
391 393
 	public function get_submitted_setting_value( $field = false ) {
392 394
 
393
-		if( ! $field ) return;
395
+		if( ! $field ) {
396
+			return;
397
+		}
394 398
 
395 399
 		$value = false;
396 400
 
@@ -1507,7 +1511,7 @@  discard block
 block discarded – undo
1507 1511
 
1508 1512
             $field_name = 'answer_feedback_boolean';
1509 1513
 
1510
-        }elseif( 'multiple-choice' == $question_type ){
1514
+        } elseif( 'multiple-choice' == $question_type ){
1511 1515
 
1512 1516
             $field_name = 'answer_feedback_multiple_choice';
1513 1517
 
@@ -1603,7 +1607,9 @@  discard block
 block discarded – undo
1603 1607
 
1604 1608
 		$html = '';
1605 1609
 
1606
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1610
+		if( ! $lesson_id && ! $quiz_id ) {
1611
+			return $html;
1612
+		}
1607 1613
 
1608 1614
 		$settings = $this->get_quiz_settings( $quiz_id );
1609 1615
 
@@ -2258,11 +2264,11 @@  discard block
 block discarded – undo
2258 2264
 
2259 2265
             $answer_feedback = $data[ 'answer_feedback_boolean' ];
2260 2266
 
2261
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2267
+		} elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2262 2268
 
2263 2269
             $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2264 2270
 
2265
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2271
+        } elseif( isset( $data[ 'answer_feedback' ] )  ){
2266 2272
 
2267 2273
             $answer_feedback = $data[ 'answer_feedback' ];
2268 2274
 
@@ -2275,8 +2281,7 @@  discard block
 block discarded – undo
2275 2281
 		// Handle the extended question text
2276 2282
 		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2277 2283
 			$post_content = $data[ 'question_description' ];
2278
-		}
2279
-		else {
2284
+		} else {
2280 2285
 			$post_content = '';
2281 2286
 		}
2282 2287
 		// Question Query Arguments
@@ -2484,8 +2489,7 @@  discard block
 block discarded – undo
2484 2489
 				'key' => '_lesson_course',
2485 2490
 				'value' => $course_id,
2486 2491
 			);
2487
-		}
2488
-		else {
2492
+		} else {
2489 2493
 			// Simple check for connection to a Course
2490 2494
 			$post_args['meta_query'][] = array(
2491 2495
 				'key' => '_lesson_course',
@@ -2613,9 +2617,13 @@  discard block
 block discarded – undo
2613 2617
 				// Fetch each question in the order in which they were asked
2614 2618
 				$questions = array();
2615 2619
 				foreach( $selected_questions as $question_id ) {
2616
-					if( ! $question_id ) continue;
2620
+					if( ! $question_id ) {
2621
+						continue;
2622
+					}
2617 2623
 					$question = get_post( $question_id );
2618
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2624
+					if( ! isset( $question ) || ! isset( $question->ID ) ) {
2625
+						continue;
2626
+					}
2619 2627
 					$questions[] = $question;
2620 2628
 				}
2621 2629
 
@@ -2628,7 +2636,9 @@  discard block
 block discarded – undo
2628 2636
 
2629 2637
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2630 2638
 				foreach( $questions_array as $question ) {
2631
-					if( 'question' != $question->post_type ) continue;
2639
+					if( 'question' != $question->post_type ) {
2640
+						continue;
2641
+					}
2632 2642
 					$existing_questions[] = $question->ID;
2633 2643
 				}
2634 2644
 
@@ -2668,7 +2678,9 @@  discard block
 block discarded – undo
2668 2678
 
2669 2679
 						// Add selected questions to existing questions array to prevent duplicates from being added
2670 2680
 						foreach( $questions_array as $cat_question ) {
2671
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2681
+							if( in_array( $cat_question->ID, $existing_questions ) ) {
2682
+								continue;
2683
+							}
2672 2684
 							$existing_questions[] = $cat_question->ID;
2673 2685
 						}
2674 2686
 					}
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 *
240 240
 	 * @access public
241 241
 	 * @param int $post_id
242
-	 * @return void
242
+	 * @return integer|null
243 243
 	 */
244 244
 	public function meta_box_save ( $post_id ) {
245 245
 
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
 	 *
2419 2419
 	 * @access private
2420 2420
 	 * @param array $data (default: array())
2421
-	 * @return void
2421
+	 * @return boolean
2422 2422
 	 */
2423 2423
 	private function lesson_delete_question( $data = array() ) {
2424 2424
 
@@ -2884,7 +2884,7 @@  discard block
 block discarded – undo
2884 2884
      * @access public
2885 2885
      *
2886 2886
      * @param int $lesson_id
2887
-     * @return int|bool $course_id or bool when nothing is found.
2887
+     * @return integer $course_id or bool when nothing is found.
2888 2888
      */
2889 2889
      public function get_course_id( $lesson_id ){
2890 2890
 
Please login to merge, or discard this patch.
Spacing   +1080 added lines, -1080 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 Lessons Class
@@ -20,80 +20,80 @@  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
 		// Setup meta fields for this post type
25
-		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
25
+		$this->meta_fields = array('lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed');
26 26
 
27 27
         $this->question_order = '';
28 28
 
29 29
 		// Admin actions
30
-		if ( is_admin() ) {
30
+		if (is_admin()) {
31 31
 
32 32
 			// Metabox functions
33
-			add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
34
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
35
-			add_action( 'save_post', array( $this, 'quiz_update' ) );
33
+			add_action('admin_menu', array($this, 'meta_box_setup'), 20);
34
+			add_action('save_post', array($this, 'meta_box_save'));
35
+			add_action('save_post', array($this, 'quiz_update'));
36 36
 
37 37
 			// Custom Write Panel Columns
38
-			add_filter( 'manage_edit-lesson_columns', array( $this, 'add_column_headings' ), 10, 1 );
39
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
38
+			add_filter('manage_edit-lesson_columns', array($this, 'add_column_headings'), 10, 1);
39
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
40 40
 
41 41
 			// Add/Update question
42
-			add_action( 'wp_ajax_lesson_update_question', array( $this, 'lesson_update_question' ) );
43
-			add_action( 'wp_ajax_nopriv_lesson_update_question', array( $this, 'lesson_update_question' ) );
42
+			add_action('wp_ajax_lesson_update_question', array($this, 'lesson_update_question'));
43
+			add_action('wp_ajax_nopriv_lesson_update_question', array($this, 'lesson_update_question'));
44 44
 
45 45
 			// Add course
46
-			add_action( 'wp_ajax_lesson_add_course', array( $this, 'lesson_add_course' ) );
47
-			add_action( 'wp_ajax_nopriv_lesson_add_course', array( $this, 'lesson_add_course' ) );
46
+			add_action('wp_ajax_lesson_add_course', array($this, 'lesson_add_course'));
47
+			add_action('wp_ajax_nopriv_lesson_add_course', array($this, 'lesson_add_course'));
48 48
 
49 49
 			// Update grade type
50
-			add_action( 'wp_ajax_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
51
-			add_action( 'wp_ajax_nopriv_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
50
+			add_action('wp_ajax_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
51
+			add_action('wp_ajax_nopriv_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
52 52
 
53 53
 			// Update question order
54
-			add_action( 'wp_ajax_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
55
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
54
+			add_action('wp_ajax_lesson_update_question_order', array($this, 'lesson_update_question_order'));
55
+			add_action('wp_ajax_nopriv_lesson_update_question_order', array($this, 'lesson_update_question_order'));
56 56
 
57 57
 			//Update question order
58
-			add_action( 'wp_ajax_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
59
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
58
+			add_action('wp_ajax_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
59
+			add_action('wp_ajax_nopriv_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
60 60
 
61 61
 			// Get answer ID
62
-			add_action( 'wp_ajax_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
63
-			add_action( 'wp_ajax_nopriv_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
62
+			add_action('wp_ajax_question_get_answer_id', array($this, 'question_get_answer_id'));
63
+			add_action('wp_ajax_nopriv_question_get_answer_id', array($this, 'question_get_answer_id'));
64 64
 
65 65
 			// Add multiple questions
66
-			add_action( 'wp_ajax_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
67
-			add_action( 'wp_ajax_nopriv_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
66
+			add_action('wp_ajax_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
67
+			add_action('wp_ajax_nopriv_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
68 68
 
69 69
 			// Remove multiple questions
70
-			add_action( 'wp_ajax_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
71
-			add_action( 'wp_ajax_nopriv_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
70
+			add_action('wp_ajax_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
71
+			add_action('wp_ajax_nopriv_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
72 72
 
73 73
 			// Get question category limit
74
-			add_action( 'wp_ajax_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
75
-			add_action( 'wp_ajax_nopriv_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
74
+			add_action('wp_ajax_get_question_category_limit', array($this, 'get_question_category_limit'));
75
+			add_action('wp_ajax_nopriv_get_question_category_limit', array($this, 'get_question_category_limit'));
76 76
 
77 77
 			// Add existing questions
78
-			add_action( 'wp_ajax_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
79
-			add_action( 'wp_ajax_nopriv_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
78
+			add_action('wp_ajax_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
79
+			add_action('wp_ajax_nopriv_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
80 80
 
81 81
 			// Filter existing questions
82
-			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
83
-			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
82
+			add_action('wp_ajax_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
83
+			add_action('wp_ajax_nopriv_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
84 84
 
85 85
             // output bulk edit fields
86
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
87
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
86
+            add_action('bulk_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
87
+            add_action('quick_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
88 88
 
89 89
             // load quick edit default values
90
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
90
+            add_action('manage_lesson_posts_custom_column', array($this, 'set_quick_edit_admin_defaults'), 11, 2);
91 91
 
92 92
             // save bulk edit fields
93
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
93
+            add_action('wp_ajax_save_bulk_edit_book', array($this, 'save_all_lessons_edit_fields'));
94 94
 
95 95
             // flush rewrite rules when saving a lesson
96
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
96
+            add_action('save_post', array(__CLASS__, 'flush_rewrite_rules'));
97 97
 
98 98
 		} else {
99 99
 			// Frontend actions
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	 * @access public
107 107
 	 * @return void
108 108
 	 */
109
-	public function meta_box_setup () {
109
+	public function meta_box_setup() {
110 110
 
111 111
 		// Add Meta Box for Prerequisite Lesson
112
-		add_meta_box( 'lesson-prerequisite', __( 'Lesson Prerequisite', 'woothemes-sensei' ), array( $this, 'lesson_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
112
+		add_meta_box('lesson-prerequisite', __('Lesson Prerequisite', 'woothemes-sensei'), array($this, 'lesson_prerequisite_meta_box_content'), $this->token, 'side', 'default');
113 113
 
114 114
 		// Add Meta Box for Lesson Course
115
-		add_meta_box( 'lesson-course', __( 'Lesson Course', 'woothemes-sensei' ), array( $this, 'lesson_course_meta_box_content' ), $this->token, 'side', 'default' );
115
+		add_meta_box('lesson-course', __('Lesson Course', 'woothemes-sensei'), array($this, 'lesson_course_meta_box_content'), $this->token, 'side', 'default');
116 116
 
117 117
 		// Add Meta Box for Lesson Preview
118
-		add_meta_box( 'lesson-preview', __( 'Lesson Preview', 'woothemes-sensei' ), array( $this, 'lesson_preview_meta_box_content' ), $this->token, 'side', 'default' );
118
+		add_meta_box('lesson-preview', __('Lesson Preview', 'woothemes-sensei'), array($this, 'lesson_preview_meta_box_content'), $this->token, 'side', 'default');
119 119
 
120 120
 		// Add Meta Box for Lesson Information
121
-		add_meta_box( 'lesson-info', __( 'Lesson Information', 'woothemes-sensei' ), array( $this, 'lesson_info_meta_box_content' ), $this->token, 'normal', 'default' );
121
+		add_meta_box('lesson-info', __('Lesson Information', 'woothemes-sensei'), array($this, 'lesson_info_meta_box_content'), $this->token, 'normal', 'default');
122 122
 
123 123
 		// Add Meta Box for Quiz Settings
124
-		add_meta_box( 'lesson-quiz-settings', __( 'Quiz Settings', 'woothemes-sensei' ), array( $this, 'lesson_quiz_settings_meta_box_content' ), $this->token, 'normal', 'default' );
124
+		add_meta_box('lesson-quiz-settings', __('Quiz Settings', 'woothemes-sensei'), array($this, 'lesson_quiz_settings_meta_box_content'), $this->token, 'normal', 'default');
125 125
 
126 126
 		// Add Meta Box for Lesson Quiz Questions
127
-		add_meta_box( 'lesson-quiz', __( 'Quiz Questions', 'woothemes-sensei' ), array( $this, 'lesson_quiz_meta_box_content' ), $this->token, 'normal', 'default' );
127
+		add_meta_box('lesson-quiz', __('Quiz Questions', 'woothemes-sensei'), array($this, 'lesson_quiz_meta_box_content'), $this->token, 'normal', 'default');
128 128
 
129 129
 		// Remove "Custom Settings" meta box.
130
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
130
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
131 131
 
132 132
 		// Add JS scripts
133
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
133
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
134 134
 
135 135
 		// Add CSS
136
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
136
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
137 137
 
138 138
 	} // End meta_box_setup()
139 139
 
@@ -144,30 +144,30 @@  discard block
 block discarded – undo
144 144
 	 * @access public
145 145
 	 * @return void
146 146
 	 */
147
-	public function lesson_info_meta_box_content () {
147
+	public function lesson_info_meta_box_content() {
148 148
 		global $post;
149 149
 
150
-		$lesson_length = get_post_meta( $post->ID, '_lesson_length', true );
151
-		$lesson_complexity = get_post_meta( $post->ID, '_lesson_complexity', true );
150
+		$lesson_length = get_post_meta($post->ID, '_lesson_length', true);
151
+		$lesson_complexity = get_post_meta($post->ID, '_lesson_complexity', true);
152 152
 		$complexity_array = $this->lesson_complexities();
153
-		$lesson_video_embed = get_post_meta( $post->ID, '_lesson_video_embed', true );
153
+		$lesson_video_embed = get_post_meta($post->ID, '_lesson_video_embed', true);
154 154
 
155 155
 		$html = '';
156 156
 		// Lesson Length
157
-		$html .= '<p><label for="lesson_length">' . __( 'Lesson Length in minutes', 'woothemes-sensei' ) . ': </label>';
158
-		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="' . esc_attr( $lesson_length ) . '" /></p>' . "\n";
157
+		$html .= '<p><label for="lesson_length">'.__('Lesson Length in minutes', 'woothemes-sensei').': </label>';
158
+		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="'.esc_attr($lesson_length).'" /></p>'."\n";
159 159
 		// Lesson Complexity
160
-		$html .= '<p><label for="lesson_complexity">' . __( 'Lesson Complexity', 'woothemes-sensei' ) . ': </label>';
160
+		$html .= '<p><label for="lesson_complexity">'.__('Lesson Complexity', 'woothemes-sensei').': </label>';
161 161
 		$html .= '<select id="lesson-complexity-options" name="lesson_complexity" class="chosen_select lesson-complexity-select">';
162
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
163
-			foreach ($complexity_array as $key => $value){
164
-				$html .= '<option value="' . esc_attr( $key ) . '"' . selected( $key, $lesson_complexity, false ) . '>' . esc_html( $value ) . '</option>' . "\n";
162
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
163
+			foreach ($complexity_array as $key => $value) {
164
+				$html .= '<option value="'.esc_attr($key).'"'.selected($key, $lesson_complexity, false).'>'.esc_html($value).'</option>'."\n";
165 165
 			} // End For Loop
166
-		$html .= '</select></p>' . "\n";
166
+		$html .= '</select></p>'."\n";
167 167
 
168
-		$html .= '<p><label for="lesson_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . ':</label><br/>' . "\n";
169
-		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">' . $lesson_video_embed . '</textarea></p>' . "\n";
170
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
168
+		$html .= '<p><label for="lesson_video_embed">'.__('Video Embed Code', 'woothemes-sensei').':</label><br/>'."\n";
169
+		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">'.$lesson_video_embed.'</textarea></p>'."\n";
170
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
171 171
 
172 172
 		echo $html;
173 173
 
@@ -179,31 +179,31 @@  discard block
 block discarded – undo
179 179
 	 * @access public
180 180
 	 * @return void
181 181
 	 */
182
-	public function lesson_prerequisite_meta_box_content () {
182
+	public function lesson_prerequisite_meta_box_content() {
183 183
 		global $post;
184 184
 		// Get existing post meta
185
-		$select_lesson_prerequisite = get_post_meta( $post->ID, '_lesson_prerequisite', true );
185
+		$select_lesson_prerequisite = get_post_meta($post->ID, '_lesson_prerequisite', true);
186 186
 		// Get the Lesson Posts
187
-		$post_args = array(	'post_type' 		=> 'lesson',
187
+		$post_args = array('post_type' 		=> 'lesson',
188 188
 							'posts_per_page' 		=> -1,
189 189
 							'orderby'         	=> 'title',
190 190
     						'order'           	=> 'ASC',
191 191
     						'exclude' 			=> $post->ID,
192 192
 							'suppress_filters' 	=> 0
193 193
 							);
194
-		$posts_array = get_posts( $post_args );
194
+		$posts_array = get_posts($post_args);
195 195
 		// Build the HTML to Output
196 196
 		$html = '';
197
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
198
-		if ( count( $posts_array ) > 0 ) {
199
-			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">' . "\n";
200
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
201
-				foreach ($posts_array as $post_item){
202
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_lesson_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
197
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
198
+		if (count($posts_array) > 0) {
199
+			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">'."\n";
200
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
201
+				foreach ($posts_array as $post_item) {
202
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_lesson_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
203 203
 				} // End For Loop
204
-			$html .= '</select>' . "\n";
204
+			$html .= '</select>'."\n";
205 205
 		} else {
206
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
206
+			$html .= '<p>'.esc_html(__('No lessons exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
207 207
 		} // End If Statement
208 208
 		// Output the HTML
209 209
 		echo $html;
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 	 * @access public
216 216
 	 * @return void
217 217
 	 */
218
-	public function lesson_preview_meta_box_content () {
218
+	public function lesson_preview_meta_box_content() {
219 219
 		global $post;
220 220
 		// Get existing post meta
221
-		$lesson_preview = get_post_meta( $post->ID, '_lesson_preview', true );
221
+		$lesson_preview = get_post_meta($post->ID, '_lesson_preview', true);
222 222
 		$html = '';
223
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
223
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
224 224
 
225 225
 		$checked = '';
226
-		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
227
-	 	    $checked = checked( 'preview', $lesson_preview, false );
226
+		if (isset($lesson_preview) && ('' != $lesson_preview)) {
227
+	 	    $checked = checked('preview', $lesson_preview, false);
228 228
 	 	} // End If Statement
229 229
 
230 230
 	 	$html .= '<label for="lesson_preview">';
231
-	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" ' . $checked . '>&nbsp;' . __( 'Allow this lesson to be viewed without purchase/login', 'woothemes-sensei' ) . '<br>';
231
+	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" '.$checked.'>&nbsp;'.__('Allow this lesson to be viewed without purchase/login', 'woothemes-sensei').'<br>';
232 232
 
233 233
 		// Output the HTML
234 234
 		echo $html;
@@ -241,32 +241,32 @@  discard block
 block discarded – undo
241 241
 	 * @param int $post_id
242 242
 	 * @return void
243 243
 	 */
244
-	public function meta_box_save ( $post_id ) {
244
+	public function meta_box_save($post_id) {
245 245
 
246 246
 		// Verify the nonce before proceeding.
247
-		if ( ( get_post_type( $post_id ) != $this->token ) || !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta' ) ) {
247
+		if ((get_post_type($post_id) != $this->token) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
248 248
 			return $post_id;
249 249
 		} // End If Statement
250 250
 		// Get the post type object.
251
-		$post_type = get_post_type_object( get_post_type( $post_id ) );
251
+		$post_type = get_post_type_object(get_post_type($post_id));
252 252
 		// Check if the current user has permission to edit the post.
253
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
253
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
254 254
 			return $post_id;
255 255
 		} // End If Statement
256 256
 		// Check if the current post type is a page
257
-		if ( 'page' == $_POST[ 'post_type' ] ) {
258
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
257
+		if ('page' == $_POST['post_type']) {
258
+			if ( ! current_user_can('edit_page', $post_id)) {
259 259
 				return $post_id;
260 260
 			} // End If Statement
261 261
 		} else {
262
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
262
+			if ( ! current_user_can('edit_post', $post_id)) {
263 263
 				return $post_id;
264 264
 			} // End If Statement
265 265
 		} // End If Statement
266 266
 		// Save the post meta data fields
267
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
268
-			foreach ( $this->meta_fields as $meta_key ) {
269
-				$this->save_post_meta( $meta_key, $post_id );
267
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
268
+			foreach ($this->meta_fields as $meta_key) {
269
+				$this->save_post_meta($meta_key, $post_id);
270 270
 			} // End For Loop
271 271
 		} // End If Statement
272 272
 	} // End meta_box_save()
@@ -278,37 +278,37 @@  discard block
 block discarded – undo
278 278
 	 * @access public
279 279
 	 * @return void
280 280
 	 */
281
-	public function quiz_update( $post_id ) {
281
+	public function quiz_update($post_id) {
282 282
 		global $post;
283 283
 		// Verify the nonce before proceeding.
284
-		if ( ( 'lesson' != get_post_type( $post_id ) )|| !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta') ) {
285
-			if ( isset($post->ID) ) {
284
+		if (('lesson' != get_post_type($post_id)) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
285
+			if (isset($post->ID)) {
286 286
 				return $post->ID;
287 287
 			} else {
288 288
 				return false;
289 289
 			} // End If Statement
290 290
 		} // End If Statement
291 291
 
292
-		if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
292
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
293 293
 			return;
294 294
 		}
295 295
 
296 296
 		// Temporarily disable the filter
297
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
297
+        remove_action('save_post', array($this, 'quiz_update'));
298 298
 		// Save the Quiz
299
-		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
299
+		$quiz_id = $this->lesson_quizzes($post_id, 'any');
300 300
 
301 301
 		 // Sanitize and setup the post data
302
-		$_POST = stripslashes_deep( $_POST );
303
-		if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) {
304
-			$quiz_id = absint( $_POST[ 'quiz_id' ] );
302
+		$_POST = stripslashes_deep($_POST);
303
+		if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) {
304
+			$quiz_id = absint($_POST['quiz_id']);
305 305
 		} // End If Statement
306
-		$post_title = esc_html( $_POST[ 'post_title' ] );
307
-		$post_status = esc_html( $_POST[ 'post_status' ] );
306
+		$post_title = esc_html($_POST['post_title']);
307
+		$post_status = esc_html($_POST['post_status']);
308 308
 		$post_content = '';
309 309
 
310 310
 		// Setup Query Arguments
311
-		$post_type_args = array(	'post_content' => $post_content,
311
+		$post_type_args = array('post_content' => $post_content,
312 312
   		    						'post_status' => $post_status,
313 313
   		    						'post_title' => $post_title,
314 314
   		    						'post_type' => 'quiz',
@@ -318,84 +318,84 @@  discard block
 block discarded – undo
318 318
 		$settings = $this->get_quiz_settings();
319 319
 
320 320
   		// Update or Insert the Lesson Quiz
321
-		if ( 0 < $quiz_id ) {
321
+		if (0 < $quiz_id) {
322 322
 			// Update the Quiz
323
-			$post_type_args[ 'ID' ] = $quiz_id;
323
+			$post_type_args['ID'] = $quiz_id;
324 324
 		    wp_update_post($post_type_args);
325 325
 
326 326
 		    // Update the post meta data
327
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
327
+		    update_post_meta($quiz_id, '_quiz_lesson', $post_id);
328 328
 
329
-		    foreach( $settings as $field ) {
330
-		    	if( 'random_question_order' != $field['id'] ) {
331
-			    	$value = $this->get_submitted_setting_value( $field );
332
-			    	if( isset( $value ) ) {
333
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
329
+		    foreach ($settings as $field) {
330
+		    	if ('random_question_order' != $field['id']) {
331
+			    	$value = $this->get_submitted_setting_value($field);
332
+			    	if (isset($value)) {
333
+			    		update_post_meta($quiz_id, '_'.$field['id'], $value);
334 334
 			    	}
335 335
 			    }
336 336
 		    }
337 337
 
338 338
 		    // Set the post terms for quiz-type
339
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
339
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
340 340
 		} else {
341 341
 			// Create the Quiz
342 342
 		    $quiz_id = wp_insert_post($post_type_args);
343 343
 
344 344
 		    // Add the post meta data WP will add it if it doesn't exist
345
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
345
+            update_post_meta($quiz_id, '_quiz_lesson', $post_id);
346 346
 
347
-		    foreach( $settings as $field ) {
348
-		    	if( 'random_question_order' != $field['id'] ) {
347
+		    foreach ($settings as $field) {
348
+		    	if ('random_question_order' != $field['id']) {
349 349
 
350 350
                     //ignore values not posted to avoid
351 351
                     // overwriting with empty or default values
352 352
                     // when the values are posted from bulk edit or quick edit
353
-                    if( !isset( $_POST[ $field['id'] ] ) ){
353
+                    if ( ! isset($_POST[$field['id']])) {
354 354
                         continue;
355 355
                     }
356 356
 
357
-			    	$value = $this->get_submitted_setting_value( $field );
358
-			    	if( isset( $value ) ) {
359
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
357
+			    	$value = $this->get_submitted_setting_value($field);
358
+			    	if (isset($value)) {
359
+			    		add_post_meta($quiz_id, '_'.$field['id'], $value);
360 360
 			    	}
361 361
 			    }
362 362
 		    }
363 363
 
364 364
 		    // Set the post terms for quiz-type
365
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
365
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
366 366
 		} // End If Statement
367 367
 
368 368
 		// Add default lesson order meta value
369
-		$course_id = get_post_meta( $post_id, '_lesson_course', true );
370
-		if( $course_id ) {
371
-			if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) {
372
-				update_post_meta( $post_id, '_order_' . $course_id, 0 );
369
+		$course_id = get_post_meta($post_id, '_lesson_course', true);
370
+		if ($course_id) {
371
+			if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) {
372
+				update_post_meta($post_id, '_order_'.$course_id, 0);
373 373
 			}
374 374
 		}
375 375
 		// Add reference back to the Quiz
376
-		update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
376
+		update_post_meta($post_id, '_lesson_quiz', $quiz_id);
377 377
 		// Mark if the Lesson Quiz has questions
378
-		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
379
-		if( 0 < count( $quiz_questions ) ) {
380
-			update_post_meta( $post_id, '_quiz_has_questions', '1' );
378
+		$quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
379
+		if (0 < count($quiz_questions)) {
380
+			update_post_meta($post_id, '_quiz_has_questions', '1');
381 381
 		}
382 382
 		else {
383
-			delete_post_meta( $post_id, '_quiz_has_questions' );
383
+			delete_post_meta($post_id, '_quiz_has_questions');
384 384
 		}
385 385
 
386 386
 		// Restore the previously disabled filter
387
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
387
+        add_action('save_post', array($this, 'quiz_update'));
388 388
 
389 389
 	} // End post_updated()
390 390
 
391
-	public function get_submitted_setting_value( $field = false ) {
391
+	public function get_submitted_setting_value($field = false) {
392 392
 
393
-		if( ! $field ) return;
393
+		if ( ! $field) return;
394 394
 
395 395
 		$value = false;
396 396
 
397
-		if( 'quiz_grade_type' == $field['id'] ) {
398
-			if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) {
397
+		if ('quiz_grade_type' == $field['id']) {
398
+			if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) {
399 399
 				$value = 'auto';
400 400
 			} else {
401 401
 				$value = 'manual';
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 			return $value;
404 404
 		}
405 405
 
406
-		if ( isset( $_POST[ $field['id'] ] ) ) {
407
-			$value = $_POST[ $field['id'] ];
406
+		if (isset($_POST[$field['id']])) {
407
+			$value = $_POST[$field['id']];
408 408
 		} else {
409 409
 			$value = $field['default'];
410 410
 		}
@@ -420,18 +420,18 @@  discard block
 block discarded – undo
420 420
 	 * @param int $post_id (default: 0)
421 421
 	 * @return int|bool meta id or saved status
422 422
 	 */
423
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
423
+	private function save_post_meta($post_key = '', $post_id = 0) {
424 424
 		// Get the meta key.
425
-		$meta_key = '_' . $post_key;
425
+		$meta_key = '_'.$post_key;
426 426
 
427 427
         //ignore fields are not posted
428 428
 
429
-        if( !isset( $_POST[ $post_key ] ) ){
429
+        if ( ! isset($_POST[$post_key])) {
430 430
 
431 431
             // except for lesson preview checkbox field
432
-            if( 'lesson_preview' == $post_key ){
432
+            if ('lesson_preview' == $post_key) {
433 433
 
434
-                $_POST[ $post_key ] = '';
434
+                $_POST[$post_key] = '';
435 435
 
436 436
             } else {
437 437
 
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
         }
443 443
 
444 444
 		// Get the posted data and sanitize it for use as an HTML class.
445
-		if ( 'lesson_video_embed' == $post_key) {
446
-			$new_meta_value = esc_html( $_POST[$post_key] );
445
+		if ('lesson_video_embed' == $post_key) {
446
+			$new_meta_value = esc_html($_POST[$post_key]);
447 447
 		} else {
448
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
448
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
449 449
 		} // End If Statement
450 450
 
451 451
         // update field with the new value
452
-        if( -1 != $new_meta_value  ){
453
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
452
+        if ( -1 != $new_meta_value  ) {
453
+            return update_post_meta($post_id, $meta_key, $new_meta_value);
454 454
         }
455 455
 
456 456
 	} // End save_post_meta()
@@ -461,30 +461,30 @@  discard block
 block discarded – undo
461 461
 	 * @access public
462 462
 	 * @return void
463 463
 	 */
464
-	public function lesson_course_meta_box_content () {
464
+	public function lesson_course_meta_box_content() {
465 465
 		global $post;
466 466
 		// Setup Lesson Meta Data
467 467
 		$selected_lesson_course = 0;
468
-		if ( 0 < $post->ID ) {
469
-			$selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true );
468
+		if (0 < $post->ID) {
469
+			$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
470 470
 		} // End If Statement
471 471
 		// Handle preselected course
472
-		if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) {
473
-			$selected_lesson_course = absint( $_GET[ 'course_id' ] );
472
+		if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) {
473
+			$selected_lesson_course = absint($_GET['course_id']);
474 474
 		} // End If Statement
475 475
 		// Get the Lesson Posts
476
-		$post_args = array(	'post_type' 		=> 'course',
476
+		$post_args = array('post_type' 		=> 'course',
477 477
 							'posts_per_page' 		=> -1,
478 478
 							'orderby'         	=> 'title',
479 479
     						'order'           	=> 'ASC',
480 480
     						'post_status'      	=> 'any',
481 481
     						'suppress_filters' 	=> 0,
482 482
 							);
483
-		$posts_array = get_posts( $post_args );
483
+		$posts_array = get_posts($post_args);
484 484
 		// Buid the HTML to Output
485 485
 		$html = '';
486 486
 		// Nonce
487
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
487
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
488 488
 
489 489
         // Select the course for the lesson
490 490
         $drop_down_args = array(
@@ -494,67 +494,67 @@  discard block
 block discarded – undo
494 494
 
495 495
         $courses = WooThemes_Sensei_Course::get_all_courses();
496 496
         $courses_options = array();
497
-        foreach( $courses as $course ){
498
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
497
+        foreach ($courses as $course) {
498
+            $courses_options[$course->ID] = get_the_title($course);
499 499
         }
500
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
500
+        $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
501 501
 
502 502
         // Course Actions Panel
503
-		if ( current_user_can( 'publish_courses' )) {
503
+		if (current_user_can('publish_courses')) {
504 504
 				$html .= '<div id="lesson-course-actions">';
505 505
 					$html .= '<p>';
506 506
 						// Add a course action link
507
-						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>';
507
+						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>';
508 508
 					$html .= '</p>';
509 509
 				$html .= '</div>';
510 510
 				// Add a course input fields
511 511
 				$html .= '<div id="lesson-course-details" class="hidden">';
512 512
 					$html .= '<p>';
513 513
 						// Course Title input
514
-						$html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> ';
514
+						$html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> ';
515 515
 	  					$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
516 516
 	  					// Course Description input
517
-	  					$html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> ';
517
+	  					$html .= '<label>'.__('Description', 'woothemes-sensei').'</label> ';
518 518
 	  					$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
519 519
 	  					// Course Prerequisite
520
-	  					$html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> ';
521
-	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
522
-							$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
523
-							foreach ($posts_array as $post_item){
524
-								$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n";
520
+	  					$html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> ';
521
+	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
522
+							$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
523
+							foreach ($posts_array as $post_item) {
524
+								$html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n";
525 525
 							} // End For Loop
526
-						$html .= '</select>' . "\n";
526
+						$html .= '</select>'."\n";
527 527
 						// Course Product
528
-                        if ( Sensei_WC::is_woocommerce_active() ) {
528
+                        if (Sensei_WC::is_woocommerce_active()) {
529 529
 	  						// Get the Products
530
-							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
530
+							$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
531 531
 
532
-							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
532
+							$product_args = array('post_type' 		=> array('product', 'product_variation'),
533 533
 													'posts_per_page' 		=> -1,
534 534
 													'orderby'         	=> 'title',
535 535
 	    											'order'           	=> 'DESC',
536
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
536
+	    											'post_status'		=> array('publish', 'private', 'draft'),
537 537
 	    											'tax_query'			=> array(
538 538
 														array(
539 539
 															'taxonomy'	=> 'product_type',
540 540
 															'field'		=> 'slug',
541
-															'terms'		=> array( 'variable', 'grouped' ),
541
+															'terms'		=> array('variable', 'grouped'),
542 542
 															'operator'	=> 'NOT IN'
543 543
 														)
544 544
 													),
545 545
 	    											'suppress_filters' 	=> 0
546 546
 													);
547
-							$products_array = get_posts( $product_args );
548
-							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
549
-	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
550
-								$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
547
+							$products_array = get_posts($product_args);
548
+							$html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> ';
549
+	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
550
+								$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
551 551
 								$prev_parent_id = 0;
552
-								foreach ($products_array as $products_item){
552
+								foreach ($products_array as $products_item) {
553 553
 
554
-									if ( 'product_variation' == $products_item->post_type ) {
555
-										$product_object = get_product( $products_item->ID );
556
-										$parent_id = wp_get_post_parent_id( $products_item->ID );
557
-										$product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) );
554
+									if ('product_variation' == $products_item->post_type) {
555
+										$product_object = get_product($products_item->ID);
556
+										$parent_id = wp_get_post_parent_id($products_item->ID);
557
+										$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
558 558
 									} else {
559 559
 										$parent_id = false;
560 560
 										$prev_parent_id = 0;
@@ -562,32 +562,32 @@  discard block
 block discarded – undo
562 562
 									}
563 563
 
564 564
 									// Show variations in groups
565
-									if( $parent_id && $parent_id != $prev_parent_id ) {
566
-										if( 0 != $prev_parent_id ) {
565
+									if ($parent_id && $parent_id != $prev_parent_id) {
566
+										if (0 != $prev_parent_id) {
567 567
 											$html .= '</optgroup>';
568 568
 										}
569
-										$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
569
+										$html .= '<optgroup label="'.get_the_title($parent_id).'">';
570 570
 										$prev_parent_id = $parent_id;
571
-									} elseif( ! $parent_id && 0 == $prev_parent_id ) {
571
+									} elseif ( ! $parent_id && 0 == $prev_parent_id) {
572 572
 										$html .= '</optgroup>';
573 573
 									}
574 574
 
575
-									$html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n";
575
+									$html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n";
576 576
 								} // End For Loop
577
-							$html .= '</select>' . "\n";
577
+							$html .= '</select>'."\n";
578 578
 						} else {
579 579
 							// Default
580 580
 							$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
581 581
 						}
582 582
 						// Course Category
583
-	  					$html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> ';
584
-	  					$cat_args = array( 'echo' => false, 'hierarchical' => true, 'show_option_none' => __( 'None', 'woothemes-sensei' ), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat' );
585
-						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n";
583
+	  					$html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> ';
584
+	  					$cat_args = array('echo' => false, 'hierarchical' => true, 'show_option_none' => __('None', 'woothemes-sensei'), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat');
585
+						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n";
586 586
 	  					// Save the course action button
587
-	  					$html .= '<a title="' . esc_attr( __( 'Save Course', 'woothemes-sensei' ) ) . '" href="#add-course-metadata" class="lesson_course_save button button-highlighted">' . esc_html( __( 'Add Course', 'woothemes-sensei' ) ) . '</a>';
587
+	  					$html .= '<a title="'.esc_attr(__('Save Course', 'woothemes-sensei')).'" href="#add-course-metadata" class="lesson_course_save button button-highlighted">'.esc_html(__('Add Course', 'woothemes-sensei')).'</a>';
588 588
 						$html .= '&nbsp;&nbsp;&nbsp;';
589 589
 						// Cancel action link
590
-						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>';
590
+						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>';
591 591
 					$html .= '</p>';
592 592
 				$html .= '</div>';
593 593
 			} // End If Statement
@@ -596,20 +596,20 @@  discard block
 block discarded – undo
596 596
 		echo $html;
597 597
 	} // End lesson_course_meta_box_content()
598 598
 
599
-	public function quiz_panel( $quiz_id = 0 ) {
599
+	public function quiz_panel($quiz_id = 0) {
600 600
 
601
-		$html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
601
+		$html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
602 602
 		$html .= '<div id="add-quiz-main">';
603
-			if ( 0 == $quiz_id ) {
603
+			if (0 == $quiz_id) {
604 604
 				$html .= '<p>';
605 605
 					// Default message and Add a Quiz button
606
-					$html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) );
606
+					$html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei'));
607 607
 				$html .= '</p>';
608 608
 			}
609 609
 
610 610
 			// Quiz Panel CSS Class
611 611
 			$quiz_class = '';
612
-			if ( 0 == $quiz_id ) {
612
+			if (0 == $quiz_id) {
613 613
 				$quiz_class = ' class="hidden"';
614 614
 			} // End If Statement
615 615
 			// Build the HTML to Output
@@ -617,15 +617,15 @@  discard block
 block discarded – undo
617 617
 
618 618
 			// Setup Questions Query
619 619
 			$questions = array();
620
-			if ( 0 < $quiz_id ) {
621
-				$questions = $this->lesson_quiz_questions( $quiz_id );
620
+			if (0 < $quiz_id) {
621
+				$questions = $this->lesson_quiz_questions($quiz_id);
622 622
 			} // End If Statement
623 623
 
624 624
 			$question_count = 0;
625
-			foreach( $questions as $question ) {
625
+			foreach ($questions as $question) {
626 626
 
627
-				if( $question->post_type == 'multiple_question' ) {
628
-					$question_number = get_post_meta( $question->ID, 'number', true );
627
+				if ($question->post_type == 'multiple_question') {
628
+					$question_number = get_post_meta($question->ID, 'number', true);
629 629
 					$question_count += $question_number;
630 630
 				} else {
631 631
 					++$question_count;
@@ -634,68 +634,68 @@  discard block
 block discarded – undo
634 634
 			}
635 635
 
636 636
 			// Inner DIV
637
-			$html .= '<div id="add-quiz-metadata"' . $quiz_class . '>';
637
+			$html .= '<div id="add-quiz-metadata"'.$quiz_class.'>';
638 638
 
639 639
 				// Quiz ID
640
-				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />';
640
+				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />';
641 641
 
642 642
 				// Default Message
643
-				if ( 0 == $quiz_id ) {
643
+				if (0 == $quiz_id) {
644 644
 					$html .= '<p class="save-note">';
645
-						$html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) );
645
+						$html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei'));
646 646
 					$html .= '</p>';
647 647
 				} // End If Statement
648 648
 
649 649
 			$html .= '</div>';
650 650
 
651 651
 			// Question Container DIV
652
-			$html .= '<div id="add-question-main"' . $quiz_class . '>';
652
+			$html .= '<div id="add-question-main"'.$quiz_class.'>';
653 653
 				// Inner DIV
654 654
 				$html .= '<div id="add-question-metadata">';
655 655
 
656 656
 					// Count of questions
657
-					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />';
657
+					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />';
658 658
 					// Table headers
659 659
 					$html .= '<table class="widefat" id="sortable-questions">
660 660
 								<thead>
661 661
 								    <tr>
662 662
 								        <th class="question-count-column">#</th>
663
-								        <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
664
-								        <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th>
665
-								        <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th>
666
-								        <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th>
663
+								        <th>' . __('Question', 'woothemes-sensei').'</th>
664
+								        <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th>
665
+								        <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th>
666
+								        <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th>
667 667
 								    </tr>
668 668
 								</thead>
669 669
 								<tfoot>
670 670
 								    <tr>
671 671
 									    <th class="question-count-column">#</th>
672
-									    <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
673
-									    <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th>
674
-									    <th>' . __( 'Type', 'woothemes-sensei' ) . '</th>
675
-									    <th>' . __( 'Action', 'woothemes-sensei' ) . '</th>
672
+									    <th>' . __('Question', 'woothemes-sensei').'</th>
673
+									    <th>' . __('Grade', 'woothemes-sensei').'</th>
674
+									    <th>' . __('Type', 'woothemes-sensei').'</th>
675
+									    <th>' . __('Action', 'woothemes-sensei').'</th>
676 676
 								    </tr>
677 677
 								</tfoot>';
678 678
 
679 679
 					$message_class = '';
680
-					if ( 0 < $question_count ) { $message_class = 'hidden'; }
680
+					if (0 < $question_count) { $message_class = 'hidden'; }
681 681
 
682
-					$html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">';
682
+					$html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">';
683 683
 						$html .= '<tr>';
684
-							$html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>';
684
+							$html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>';
685 685
 						$html .= '</tr>';
686 686
 					$html .= '</tbody>';
687 687
 
688
-					if( 0 < $question_count ) {
689
-						$html .= $this->quiz_panel_questions( $questions );
688
+					if (0 < $question_count) {
689
+						$html .= $this->quiz_panel_questions($questions);
690 690
 					}
691 691
 
692 692
 					$html .= '</table>';
693 693
 
694
-					if( ! isset( $this->question_order ) ) {
694
+					if ( ! isset($this->question_order)) {
695 695
 						$this->question_order = '';
696 696
 					}
697 697
 
698
-					$html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />';
698
+					$html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />';
699 699
 
700 700
 				$html .= '</div>';
701 701
 
@@ -714,47 +714,47 @@  discard block
 block discarded – undo
714 714
 
715 715
 	}
716 716
 
717
-	public function quiz_panel_questions( $questions = array() ) {
717
+	public function quiz_panel_questions($questions = array()) {
718 718
 		global $quiz_questions;
719 719
 
720 720
 		$quiz_questions = $questions;
721 721
 
722 722
 		$html = '';
723 723
 
724
-		if( count( $questions ) > 0 ) {
724
+		if (count($questions) > 0) {
725 725
 
726 726
 			$question_class = '';
727 727
 			$question_counter = 1;
728 728
 
729
-			foreach ( $questions as $question ) {
729
+			foreach ($questions as $question) {
730 730
 
731 731
 				$question_id = $question->ID;
732 732
 
733
-				$question_type = Sensei()->question->get_question_type( $question_id );
733
+				$question_type = Sensei()->question->get_question_type($question_id);
734 734
 
735 735
 				$multiple_data = array();
736 736
 				$question_increment = 1;
737
-				if( 'multiple_question' == $question->post_type ) {
737
+				if ('multiple_question' == $question->post_type) {
738 738
 					$question_type = 'category';
739 739
 
740
-					$question_category = get_post_meta( $question->ID, 'category', true );
741
-					$question_cat = get_term( $question_category, 'question-category' );
740
+					$question_category = get_post_meta($question->ID, 'category', true);
741
+					$question_cat = get_term($question_category, 'question-category');
742 742
 
743
-					$question_number = get_post_meta( $question->ID, 'number', true );
743
+					$question_number = get_post_meta($question->ID, 'number', true);
744 744
 					$question_increment = $question_number;
745 745
 
746
-					$multiple_data = array( $question_cat->name, $question_number );
746
+					$multiple_data = array($question_cat->name, $question_number);
747 747
 				}
748 748
 
749
-				if( ! $question_type ) {
749
+				if ( ! $question_type) {
750 750
 					$question_type = 'multiple-choice';
751 751
 				}
752 752
 
753 753
 				// Row with question and actions
754
-				$html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data );
754
+				$html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data);
755 755
 				$question_counter += $question_increment;
756 756
 
757
-				if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; }
757
+				if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; }
758 758
 				$this->question_order .= $question_id;
759 759
 			} // End For Loop
760 760
 		}
@@ -763,161 +763,161 @@  discard block
 block discarded – undo
763 763
 
764 764
 	}
765 765
 
766
-	public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
767
-		global $row_counter,  $quiz_questions;
766
+	public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) {
767
+		global $row_counter, $quiz_questions;
768 768
 
769 769
 		$html = '';
770 770
 
771 771
 		$question_class = '';
772
-		if( 'quiz' == $context ) {
773
-			if( ! $row_counter || ! isset( $row_counter ) ) {
772
+		if ('quiz' == $context) {
773
+			if ( ! $row_counter || ! isset($row_counter)) {
774 774
 				$row_counter = 1;
775 775
 			}
776
-			if( $row_counter % 2 ) { $question_class = 'alternate'; }
776
+			if ($row_counter % 2) { $question_class = 'alternate'; }
777 777
 			++$row_counter;
778 778
 		}
779 779
 
780
-		if( $question_id ) {
780
+		if ($question_id) {
781 781
 
782
-			if( $question_type != 'category' ) {
782
+			if ($question_type != 'category') {
783 783
 
784
-				$question_grade = Sensei()->question->get_question_grade( $question_id );
784
+				$question_grade = Sensei()->question->get_question_grade($question_id);
785 785
 
786
-				$question_media = get_post_meta( $question_id, '_question_media', true );
786
+				$question_media = get_post_meta($question_id, '_question_media', true);
787 787
 				$question_media_type = $question_media_thumb = $question_media_link = $question_media_title = '';
788 788
 				$question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden';
789
-				$question_media_add_button = __( 'Add file', 'woothemes-sensei' );
790
-				if( 0 < intval( $question_media ) ) {
791
-					$mimetype = get_post_mime_type( $question_media );
792
-					if( $mimetype ) {
793
-						$mimetype_array = explode( '/', $mimetype);
794
-						if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
789
+				$question_media_add_button = __('Add file', 'woothemes-sensei');
790
+				if (0 < intval($question_media)) {
791
+					$mimetype = get_post_mime_type($question_media);
792
+					if ($mimetype) {
793
+						$mimetype_array = explode('/', $mimetype);
794
+						if (isset($mimetype_array[0]) && $mimetype_array[0]) {
795 795
 							$question_media_delete_class = '';
796 796
 							$question_media_type = $mimetype_array[0];
797
-							if( 'image' == $question_media_type ) {
798
-								$question_media_thumb = wp_get_attachment_thumb_url( $question_media );
799
-								if( $question_media_thumb ) {
797
+							if ('image' == $question_media_type) {
798
+								$question_media_thumb = wp_get_attachment_thumb_url($question_media);
799
+								if ($question_media_thumb) {
800 800
 									$question_media_thumb_class = '';
801 801
 								}
802 802
 							}
803
-							$question_media_url = wp_get_attachment_url( $question_media );
804
-							if( $question_media_url ) {
805
-								$attachment = get_post( $question_media );
803
+							$question_media_url = wp_get_attachment_url($question_media);
804
+							if ($question_media_url) {
805
+								$attachment = get_post($question_media);
806 806
 								$question_media_title = $attachment->post_title;
807 807
 
808
-								if( ! $question_media_title ) {
809
-									$question_media_filename = basename( $question_media_url );
808
+								if ( ! $question_media_title) {
809
+									$question_media_filename = basename($question_media_url);
810 810
 									$question_media_title = $question_media_filename;
811 811
 								}
812
-								$question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>';
812
+								$question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>';
813 813
 								$question_media_link_class = '';
814 814
 							}
815 815
 
816
-							$question_media_add_button = __( 'Change file', 'woothemes-sensei' );
816
+							$question_media_add_button = __('Change file', 'woothemes-sensei');
817 817
 						}
818 818
 					}
819 819
 				}
820 820
 
821
-				$random_order = get_post_meta( $question_id, '_random_order', true );
822
-				if( ! $random_order ) {
821
+				$random_order = get_post_meta($question_id, '_random_order', true);
822
+				if ( ! $random_order) {
823 823
 					$random_order = 'yes';
824 824
 				}
825 825
 
826
-				if( ! $question_type ) { $question_type = 'multiple-choice'; }
826
+				if ( ! $question_type) { $question_type = 'multiple-choice'; }
827 827
 			}
828 828
 
829
-			$html .= '<tbody class="' . $question_class . '">';
829
+			$html .= '<tbody class="'.$question_class.'">';
830 830
 
831
-				if( 'quiz' == $context ) {
831
+				if ('quiz' == $context) {
832 832
 					$html .= '<tr>';
833
-						if( $question_type != 'category' ) {
834
-							$question = get_post( $question_id );
835
-							$html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>';
836
-							$html .= '<td>' . esc_html( $question->post_title ) . '</td>';
837
-							$html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>';
838
-							$question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) );
839
-							$html .= '<td>' . esc_html( $question_types_filtered ) . '</td>';
840
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_delete">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
833
+						if ($question_type != 'category') {
834
+							$question = get_post($question_id);
835
+							$html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>';
836
+							$html .= '<td>'.esc_html($question->post_title).'</td>';
837
+							$html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>';
838
+							$question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type));
839
+							$html .= '<td>'.esc_html($question_types_filtered).'</td>';
840
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_delete">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
841 841
 
842 842
 						} else {
843 843
 
844
-							$end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1;
845
-							if( $question_counter == $end_number ) {
844
+							$end_number = intval($question_counter) + intval($multiple_data[1]) - 1;
845
+							if ($question_counter == $end_number) {
846 846
 								$row_numbers = $question_counter;
847 847
 							} else {
848
-								$row_numbers = $question_counter . ' - ' . $end_number;
848
+								$row_numbers = $question_counter.' - '.$end_number;
849 849
 							}
850
-							$row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] );
850
+							$row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]);
851 851
 
852
-							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">' . $question_counter . '</span><span class="hidden total-number">' . $multiple_data[1] . '</span><span class="row-numbers">' . esc_html( $row_numbers ) . '</span></td>';
853
-							$html .= '<td>' . esc_html( $row_title ) . '</td>';
852
+							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">'.$question_counter.'</span><span class="hidden total-number">'.$multiple_data[1].'</span><span class="row-numbers">'.esc_html($row_numbers).'</span></td>';
853
+							$html .= '<td>'.esc_html($row_title).'</td>';
854 854
 							$html .= '<td class="question-grade-column"></td>';
855
-							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>';
856
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit" style="visibility:hidden;">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question(s)', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_multiple_delete" rel="' . $question_id . '">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
855
+							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>';
856
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit" style="visibility:hidden;">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question(s)', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_multiple_delete" rel="'.$question_id.'">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
857 857
 
858 858
 						}
859 859
 					$html .= '</tr>';
860 860
 				}
861 861
 
862
-				if( $question_type != 'category' ) {
862
+				if ($question_type != 'category') {
863 863
 
864 864
 					$edit_class = '';
865
-					if( 'quiz' == $context ) {
865
+					if ('quiz' == $context) {
866 866
 						$edit_class = 'hidden';
867 867
 					}
868 868
 
869
-					$question = get_post( $question_id );
870
-					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
869
+					$question = get_post($question_id);
870
+					$html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">';
871 871
 						$html .= '<td colspan="5">';
872
-							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
872
+							$html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>';
873 873
 					    	$html .= '<div class="question_required_fields">';
874 874
 
875 875
 						    	// Question title
876 876
 						    	$html .= '<div>';
877
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
878
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
877
+							    	$html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> ';
878
+							    	$html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />';
879 879
 						    	$html .= '</div>';
880 880
 
881 881
 						    	// Question description
882 882
 						    	$html .= '<div>';
883
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
883
+							    	$html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
884 884
 						    	$html .= '</div>';
885
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
885
+							    	$html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>';
886 886
 
887 887
 						    	// Question grade
888 888
 						    	$html .= '<div>';
889
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
890
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
889
+							    	$html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> ';
890
+							    	$html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />';
891 891
 						    	$html .= '</div>';
892 892
 
893 893
 						    	// Random order
894
-						    	if( $question_type == 'multiple-choice' ) {
894
+						    	if ($question_type == 'multiple-choice') {
895 895
 						    		$html .= '<div>';
896
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
896
+						    			$html .= '<label for="'.$question_counter.'_random_order"><input type="checkbox" name="random_order" class="random_order" id="'.$question_counter.'_random_order" value="yes" '.checked($random_order, 'yes', false).' /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
897 897
 						    		$html .= '</div>';
898 898
 						    	}
899 899
 
900 900
 						    	// Question media
901 901
 						    	$html .= '<div>';
902
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
903
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
904
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
905
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
906
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
907
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
902
+							    	$html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
903
+							    	$html .= '<button id="question_'.$question_counter.'_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.$question_media_add_button.'</button>';
904
+							    	$html .= '<button id="question_'.$question_counter.'_media_button_delete" class="delete_media_file_button button-secondary '.$question_media_delete_class.'">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
905
+							    	$html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>';
906
+							    	$html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>';
907
+							    	$html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />';
908 908
 						    	$html .= '</div>';
909 909
 
910 910
 						    $html .= '</div>';
911 911
 
912
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
912
+						    $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter);
913 913
 
914
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
915
-							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
914
+						    $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />';
915
+							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />';
916 916
 
917
-							if( 'quiz' == $context ) {
917
+							if ('quiz' == $context) {
918 918
 					    		$html .= '<div class="update-question">';
919
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
920
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
919
+						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> ';
920
+						    		$html .= '<a title="'.esc_attr(__('Update Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_save button button-highlighted">'.esc_html(__('Update', 'woothemes-sensei')).'</a>';
921 921
 					    		$html .= '</div>';
922 922
 					    	}
923 923
 
@@ -932,79 +932,79 @@  discard block
 block discarded – undo
932 932
 		return $html;
933 933
 	}
934 934
 
935
-	public function quiz_panel_add( $context = 'quiz' ) {
935
+	public function quiz_panel_add($context = 'quiz') {
936 936
 
937 937
 
938 938
 		$html = '<div id="add-new-question">';
939 939
 
940 940
 			$question_types = Sensei()->question->question_types();
941 941
 
942
-			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
942
+			$question_cats = get_terms('question-category', array('hide_empty' => false));
943 943
 
944
-			if( 'quiz' == $context ) {
944
+			if ('quiz' == $context) {
945 945
 	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
946
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
947
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
948
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
949
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
946
+	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>';
947
+	    			$html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>';
948
+                    if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) {
949
+	    				$html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>';
950 950
 	    			}
951 951
 	    		$html .= '</h2>';
952 952
 	    	}
953 953
 
954 954
 	    	$html .= '<div class="tab-content" id="tab-new-content">';
955 955
 
956
-	    		if( 'quiz' == $context ) {
957
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
956
+	    		if ('quiz' == $context) {
957
+	    			$html .= '<p><em>'.sprintf(__('Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
958 958
 	    		}
959 959
 
960 960
 				$html .= '<div class="question">';
961 961
 					$html .= '<div class="question_required_fields">';
962 962
 
963 963
 						// Question title
964
-						$html .= '<p><label>' . __( 'Question:'  , 'woothemes-sensei' ) . '</label> ';
964
+						$html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> ';
965 965
 	  					$html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>';
966 966
 
967 967
 						// Question description
968 968
 						$html .= '<p>';
969
-							$html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
969
+							$html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
970 970
 						$html .= '</p>';
971 971
 						$html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>';
972 972
 
973 973
 	  					// Question type
974
-						$html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> ';
975
-						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n";
976
-							foreach ( $question_types as $type => $label ) {
977
-								$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n";
974
+						$html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> ';
975
+						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n";
976
+							foreach ($question_types as $type => $label) {
977
+								$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n";
978 978
 							} // End For Loop
979
-						$html .= '</select></p>' . "\n";
979
+						$html .= '</select></p>'."\n";
980 980
 
981 981
 						// Question category
982
-						if( 'quiz' == $context ) {
983
-							if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
984
-								$html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> ';
985
-								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n";
986
-								$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n";
987
-								foreach( $question_cats as $cat ) {
988
-									$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
982
+						if ('quiz' == $context) {
983
+							if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
984
+								$html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> ';
985
+								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n";
986
+								$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n";
987
+								foreach ($question_cats as $cat) {
988
+									$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
989 989
 								} // End For Loop
990
-								$html .= '</select></p>' . "\n";
990
+								$html .= '</select></p>'."\n";
991 991
 							}
992 992
 						}
993 993
 
994 994
 	  					// Question grade
995
-						$html .= '<p><label>' . __( 'Question Grade:'  , 'woothemes-sensei' ) . '</label> ';
996
-						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n";
995
+						$html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> ';
996
+						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n";
997 997
 
998 998
 						// Random order
999 999
 						$html .= '<p class="add_question_random_order">';
1000
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1000
+			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
1001 1001
 			    		$html .= '</p>';
1002 1002
 
1003 1003
 			    		// Question media
1004 1004
 						$html .= '<p>';
1005
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1006
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1007
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1005
+					    	$html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
1006
+					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.__('Add file', 'woothemes-sensei').'</button>';
1007
+					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
1008 1008
 					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1009 1009
 					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1010 1010
 					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
@@ -1013,44 +1013,44 @@  discard block
 block discarded – undo
1013 1013
 					$html .= '</div>';
1014 1014
 				$html .= '</div>';
1015 1015
 
1016
-				foreach ( $question_types as $type => $label ) {
1017
-					$html .= $this->quiz_panel_question_field( $type );
1016
+				foreach ($question_types as $type => $label) {
1017
+					$html .= $this->quiz_panel_question_field($type);
1018 1018
 				}
1019 1019
 
1020
-				if( 'quiz' == $context ) {
1020
+				if ('quiz' == $context) {
1021 1021
 					$html .= '<div class="add-question">';
1022
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1022
+			    		$html .= '<a title="'.esc_attr(__('Add Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">'.esc_html(__('Add Question', 'woothemes-sensei')).'</a>';
1023 1023
 		    		$html .= '</div>';
1024 1024
 		    	}
1025 1025
 
1026 1026
 		    $html .= '</div>';
1027 1027
 
1028
-		    if( 'quiz' == $context ) {
1028
+		    if ('quiz' == $context) {
1029 1029
 
1030 1030
 			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1031 1031
 
1032
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1032
+			    	$html .= '<p><em>'.sprintf(__('Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
1033 1033
 
1034 1034
 			    	$html .= '<div id="existing-filters" class="alignleft actions">
1035 1035
 			    				<select id="existing-status">
1036
-			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1037
-			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
1038
-			    					<option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option>
1036
+			    					<option value="all">' . __('All', 'woothemes-sensei').'</option>
1037
+			    					<option value="unused">' . __('Unused', 'woothemes-sensei').'</option>
1038
+			    					<option value="used">' . __('Used', 'woothemes-sensei').'</option>
1039 1039
 			    				</select>
1040 1040
 			    				<select id="existing-type">
1041
-			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1042
-							    	foreach ( $question_types as $type => $label ) {
1043
-										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1041
+			    					<option value="">' . __('All Types', 'woothemes-sensei').'</option>';
1042
+							    	foreach ($question_types as $type => $label) {
1043
+										$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>';
1044 1044
 									}
1045 1045
     				$html .= '</select>
1046 1046
     							<select id="existing-category">
1047
-			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1048
-				    				foreach( $question_cats as $cat ) {
1049
-										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1047
+			    					<option value="">' . __('All Categories', 'woothemes-sensei').'</option>';
1048
+				    				foreach ($question_cats as $cat) {
1049
+										$html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>';
1050 1050
 									}
1051 1051
     				$html .= '</select>
1052
-    							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1053
-    							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1052
+    							<input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" />
1053
+    							<a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a>
1054 1054
 			    			</div>';
1055 1055
 
1056 1056
 			    	$html .= '<table id="existing-table" class="widefat">';
@@ -1058,17 +1058,17 @@  discard block
 block discarded – undo
1058 1058
 			    		$html .= '<thead>
1059 1059
 									    <tr>
1060 1060
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1061
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1062
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1063
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1061
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1062
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1063
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1064 1064
 									    </tr>
1065 1065
 									</thead>
1066 1066
 									<tfoot>
1067 1067
 									    <tr>
1068 1068
 										    <th scope="col" class="check-column"><input type="checkbox" /></th>
1069
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1070
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1071
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1069
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1070
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1071
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1072 1072
 									    </tr>
1073 1073
 									</tfoot>';
1074 1074
 						$html .= '<tbody id="existing-questions">';
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 						$questions = $this->quiz_panel_get_existing_questions();
1077 1077
 
1078 1078
 						$row = 1;
1079
-						foreach( $questions['questions'] as $question ) {
1080
-							$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1079
+						foreach ($questions['questions'] as $question) {
1080
+							$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1081 1081
 							++$row;
1082 1082
 						}
1083 1083
 
@@ -1086,36 +1086,36 @@  discard block
 block discarded – undo
1086 1086
 			    	$html .= '</table>';
1087 1087
 
1088 1088
 			    	$next_class = '';
1089
-			    	if( $questions['count'] <= 10 ) {
1089
+			    	if ($questions['count'] <= 10) {
1090 1090
 			    		$next_class = 'hidden';
1091 1091
 			    	}
1092 1092
 
1093 1093
 			    	$html .= '<div id="existing-pagination">';
1094 1094
 			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1095
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1095
+			    		$html .= '<a class="prev no-paging">&larr; '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' &rarr;</a>';
1096 1096
 			    	$html .= '</div>';
1097 1097
 
1098 1098
 			    	$html .= '<div class="existing-actions">';
1099
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1099
+			    		$html .= '<a title="'.esc_attr(__('Add Selected Question(s)', 'woothemes-sensei')).'" class="add_existing_save button button-primary button-highlighted">'.esc_html(__('Add Selected Question(s)', 'woothemes-sensei')).'</a></p>';
1100 1100
 			    	$html .= '</div>';
1101 1101
 
1102 1102
 			    $html .= '</div>';
1103 1103
 
1104
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1104
+			    if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
1105 1105
 				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1106 1106
 
1107
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1107
+				    	$html .= '<p><em>'.sprintf(__('Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit-tags.php?taxonomy=question-category&post_type=question').'">', '</a>').'</em></p>';
1108 1108
 
1109
-						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1110
-						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
1111
-						foreach( $question_cats as $cat ) {
1112
-							$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
1109
+						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n";
1110
+						$html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n";
1111
+						foreach ($question_cats as $cat) {
1112
+							$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1113 1113
 						} // End For Loop
1114
-						$html .= '</select></p>' . "\n";
1114
+						$html .= '</select></p>'."\n";
1115 1115
 
1116
-						$html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1116
+						$html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1117 1117
 
1118
-						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1118
+						$html .= '<a title="'.esc_attr(__('Add Question(s)', 'woothemes-sensei')).'" class="add_multiple_save button button-primary button-highlighted">'.esc_html(__('Add Question(s)', 'woothemes-sensei')).'</a></p>';
1119 1119
 
1120 1120
 				    $html .= '</div>';
1121 1121
 				}
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 		return $html;
1127 1127
 	}
1128 1128
 
1129
-	public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) {
1129
+	public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) {
1130 1130
 
1131 1131
 		$args = array(
1132 1132
 			'post_type' => 'question',
@@ -1135,14 +1135,14 @@  discard block
 block discarded – undo
1135 1135
 			'suppress_filters' => 0,
1136 1136
 		);
1137 1137
 
1138
-		switch( $question_status ) {
1138
+		switch ($question_status) {
1139 1139
 			case 'unused': $quiz_status = 'NOT EXISTS'; break;
1140 1140
 			case 'used': $quiz_status = 'EXISTS'; break;
1141 1141
 			default: $quiz_status = ''; break;
1142 1142
 		}
1143 1143
 
1144
-		if( $quiz_status ) {
1145
-			switch( $quiz_status ) {
1144
+		if ($quiz_status) {
1145
+			switch ($quiz_status) {
1146 1146
 				case 'EXISTS':
1147 1147
 					$args['meta_query'][] = array(
1148 1148
 						'key' => '_quiz_id',
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 			}
1161 1161
 		}
1162 1162
 
1163
-		if( $question_type ) {
1163
+		if ($question_type) {
1164 1164
 			$args['tax_query'][] = array(
1165 1165
 				'taxonomy' => 'question-type',
1166 1166
 				'field' => 'slug',
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			);
1169 1169
 		}
1170 1170
 
1171
-		if( $question_category ) {
1171
+		if ($question_category) {
1172 1172
 			$args['tax_query'][] = array(
1173 1173
 				'taxonomy' => 'question-category',
1174 1174
 				'field' => 'slug',
@@ -1176,19 +1176,19 @@  discard block
 block discarded – undo
1176 1176
 			);
1177 1177
 		}
1178 1178
 
1179
-		if( $question_type && $question_category ) {
1179
+		if ($question_type && $question_category) {
1180 1180
 			$args['tax_query']['relation'] = 'AND';
1181 1181
 		}
1182 1182
 
1183
-		if( $question_search ) {
1183
+		if ($question_search) {
1184 1184
 			$args['s'] = $question_search;
1185 1185
 		}
1186 1186
 
1187
-		if( $page ) {
1187
+		if ($page) {
1188 1188
 			$args['paged'] = $page;
1189 1189
 		}
1190 1190
 
1191
-		$qry = new WP_Query( $args );
1191
+		$qry = new WP_Query($args);
1192 1192
 
1193 1193
         /**
1194 1194
          * Filter existing questions query
@@ -1197,39 +1197,39 @@  discard block
 block discarded – undo
1197 1197
          *
1198 1198
          * @param WP_Query $wp_query
1199 1199
          */
1200
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1200
+        $qry = apply_filters('sensei_existing_questions_query_results', $qry);
1201 1201
 
1202 1202
 		$questions['questions'] = $qry->posts;
1203
-		$questions['count'] = intval( $qry->found_posts );
1203
+		$questions['count'] = intval($qry->found_posts);
1204 1204
 		$questions['page'] = $page;
1205 1205
 
1206 1206
 		return $questions;
1207 1207
 	}
1208 1208
 
1209
-	public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) {
1209
+	public function quiz_panel_add_existing_question($question_id = 0, $row = 1) {
1210 1210
 
1211 1211
 		$html = '';
1212 1212
 
1213
-		if( ! $question_id ) {
1213
+		if ( ! $question_id) {
1214 1214
 
1215 1215
             return;
1216 1216
 
1217 1217
         }
1218 1218
 
1219 1219
 		$existing_class = '';
1220
-		if( $row % 2 ) {
1220
+		if ($row % 2) {
1221 1221
             $existing_class = 'alternate';
1222 1222
         }
1223 1223
 
1224
-		$question_type = Sensei()->question->get_question_type( $question_id );
1224
+		$question_type = Sensei()->question->get_question_type($question_id);
1225 1225
 
1226
-		$question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) );
1226
+		$question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', ''));
1227 1227
 
1228
-		$html .= '<tr class="' . esc_attr( $existing_class ) . '">
1229
-					<td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td>
1230
-					<td>' . get_the_title( $question_id ) . '</td>
1231
-					<td>' . esc_html( $question_type ) . '</td>
1232
-					<td>' . esc_html( $question_cat_list ) . '</td>
1228
+		$html .= '<tr class="'.esc_attr($existing_class).'">
1229
+					<td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td>
1230
+					<td>' . get_the_title($question_id).'</td>
1231
+					<td>' . esc_html($question_type).'</td>
1232
+					<td>' . esc_html($question_cat_list).'</td>
1233 1233
 				  </tr>';
1234 1234
 
1235 1235
 		return $html;
@@ -1242,58 +1242,58 @@  discard block
 block discarded – undo
1242 1242
 
1243 1243
 		//Add nonce security to the request
1244 1244
 		$nonce = '';
1245
-		if( isset( $_POST['filter_existing_questions_nonce'] ) ) {
1246
-			$nonce = esc_html( $_POST['filter_existing_questions_nonce'] );
1245
+		if (isset($_POST['filter_existing_questions_nonce'])) {
1246
+			$nonce = esc_html($_POST['filter_existing_questions_nonce']);
1247 1247
 		} // End If Statement
1248 1248
 
1249
-		if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) {
1250
-			die( $return );
1249
+		if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) {
1250
+			die($return);
1251 1251
 		} // End If Statement
1252 1252
 
1253 1253
 		// Parse POST data
1254 1254
 		$data = $_POST['data'];
1255 1255
 		$question_data = array();
1256
-		parse_str( $data, $question_data );
1256
+		parse_str($data, $question_data);
1257 1257
 
1258
-		if( 0 < count( $question_data ) ) {
1258
+		if (0 < count($question_data)) {
1259 1259
 
1260 1260
 			$question_status = '';
1261
-			if( isset( $question_data['question_status'] ) ) {
1261
+			if (isset($question_data['question_status'])) {
1262 1262
 				$question_status = $question_data['question_status'];
1263 1263
 			}
1264 1264
 
1265 1265
 			$question_type = '';
1266
-			if( isset( $question_data['question_type'] ) ) {
1266
+			if (isset($question_data['question_type'])) {
1267 1267
 				$question_type = $question_data['question_type'];
1268 1268
 			}
1269 1269
 
1270 1270
 			$question_category = '';
1271
-			if( isset( $question_data['question_category'] ) ) {
1271
+			if (isset($question_data['question_category'])) {
1272 1272
 				$question_category = $question_data['question_category'];
1273 1273
 			}
1274 1274
 
1275 1275
 			$question_search = '';
1276
-			if( isset( $question_data['question_search'] ) ) {
1276
+			if (isset($question_data['question_search'])) {
1277 1277
 				$question_search = $question_data['question_search'];
1278 1278
 			}
1279 1279
 
1280 1280
 			$question_page = 1;
1281
-			if( isset( $question_data['question_page'] ) ) {
1282
-				$question_page = intval( $question_data['question_page'] );
1281
+			if (isset($question_data['question_page'])) {
1282
+				$question_page = intval($question_data['question_page']);
1283 1283
 			}
1284 1284
 
1285
-			$questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page );
1285
+			$questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page);
1286 1286
 
1287 1287
 			$row = 1;
1288 1288
 			$html = '';
1289
-			foreach( $questions['questions'] as $question ) {
1290
-				$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1289
+			foreach ($questions['questions'] as $question) {
1290
+				$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1291 1291
 				++$row;
1292 1292
 			}
1293 1293
 
1294
-			if( ! $html ) {
1294
+			if ( ! $html) {
1295 1295
 				$html = '<tr class="alternate">
1296
-								<td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td>
1296
+								<td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td>
1297 1297
 							  </tr>';
1298 1298
 			}
1299 1299
 
@@ -1301,53 +1301,53 @@  discard block
 block discarded – undo
1301 1301
 			$return['count'] = $questions['count'];
1302 1302
 			$return['page'] = $questions['page'];
1303 1303
 
1304
-			wp_send_json( $return );
1304
+			wp_send_json($return);
1305 1305
 		}
1306 1306
 
1307
-		die( $return );
1307
+		die($return);
1308 1308
 	}
1309 1309
 
1310
-	public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) {
1310
+	public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) {
1311 1311
 
1312 1312
 		$html = '';
1313 1313
 
1314
-		if( $question_type ) {
1314
+		if ($question_type) {
1315 1315
 
1316 1316
 			$right_answer = '';
1317 1317
 			$wrong_answers = array();
1318 1318
 			$answer_order_string = '';
1319 1319
 			$answer_order = array();
1320
-			if( $question_id ) {
1321
-				$right_answer = get_post_meta( $question_id, '_question_right_answer', true);
1322
-				$wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true);
1323
-				$answer_order_string = get_post_meta( $question_id, '_answer_order', true );
1324
-				$answer_order = array_filter( explode( ',', $answer_order_string ) );
1320
+			if ($question_id) {
1321
+				$right_answer = get_post_meta($question_id, '_question_right_answer', true);
1322
+				$wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true);
1323
+				$answer_order_string = get_post_meta($question_id, '_answer_order', true);
1324
+				$answer_order = array_filter(explode(',', $answer_order_string));
1325 1325
 				$question_class = '';
1326 1326
 			} else {
1327 1327
 				$question_id = '';
1328 1328
 				$question_class = 'answer-fields question_required_fields hidden';
1329 1329
 			}
1330 1330
 
1331
-			switch ( $question_type ) {
1331
+			switch ($question_type) {
1332 1332
 				case 'multiple-choice':
1333
-					$html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">';
1333
+					$html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">';
1334 1334
 
1335 1335
 						$right_answers = (array) $right_answer;
1336 1336
 						// Calculate total right answers available (defaults to 1)
1337 1337
 						$total_right = 0;
1338
-						if( $question_id ) {
1339
-							$total_right = get_post_meta( $question_id, '_right_answer_count', true );
1338
+						if ($question_id) {
1339
+							$total_right = get_post_meta($question_id, '_right_answer_count', true);
1340 1340
 						}
1341
-						if( 0 == intval( $total_right ) ) {
1341
+						if (0 == intval($total_right)) {
1342 1342
 							$total_right = 1;
1343 1343
 						}
1344
-						for ( $i = 0; $i < $total_right; $i++ ) {
1345
-							if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; }
1346
-							$right_answer_id = $this->get_answer_id( $right_answers[ $i ] );
1344
+						for ($i = 0; $i < $total_right; $i++) {
1345
+							if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; }
1346
+							$right_answer_id = $this->get_answer_id($right_answers[$i]);
1347 1347
 							// Right Answer
1348
-							$right_answer = '<label class="answer" for="question_' . $question_counter . '_right_answer_' . $i . '"><span>' . __( 'Right:' , 'woothemes-sensei' ) . '</span> <input rel="' . esc_attr( $right_answer_id ) . '" type="text" id="question_' . $question_counter . '_right_answer_' . $i . '" name="question_right_answers[]" value="' . esc_attr( $right_answers[ $i ] ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1349
-							if( $question_id ) {
1350
-								$answers[ $right_answer_id ] = $right_answer;
1348
+							$right_answer = '<label class="answer" for="question_'.$question_counter.'_right_answer_'.$i.'"><span>'.__('Right:', 'woothemes-sensei').'</span> <input rel="'.esc_attr($right_answer_id).'" type="text" id="question_'.$question_counter.'_right_answer_'.$i.'" name="question_right_answers[]" value="'.esc_attr($right_answers[$i]).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1349
+							if ($question_id) {
1350
+								$answers[$right_answer_id] = $right_answer;
1351 1351
 							} else {
1352 1352
 								$answers[] = $right_answer;
1353 1353
 							}
@@ -1355,23 +1355,23 @@  discard block
 block discarded – undo
1355 1355
 
1356 1356
 				    	// Calculate total wrong answers available (defaults to 4)
1357 1357
 				    	$total_wrong = 0;
1358
-				    	if( $question_id ) {
1359
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1358
+				    	if ($question_id) {
1359
+				    		$total_wrong = get_post_meta($question_id, '_wrong_answer_count', true);
1360 1360
 				    	}
1361
-				    	if( 0 == intval( $total_wrong ) ) {
1361
+				    	if (0 == intval($total_wrong)) {
1362 1362
 				    		$total_wrong = 1;
1363 1363
 				    	}
1364 1364
 
1365 1365
                         // Setup Wrong Answer HTML
1366
-                        foreach ( $wrong_answers as $i => $answer ){
1366
+                        foreach ($wrong_answers as $i => $answer) {
1367 1367
 
1368
-                            $answer_id = $this->get_answer_id( $answer );
1369
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1370
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1371
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1372
-                            if( $question_id ) {
1368
+                            $answer_id = $this->get_answer_id($answer);
1369
+                            $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei');
1370
+                            $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i;
1371
+                            $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1372
+                            if ($question_id) {
1373 1373
 
1374
-                                $answers[ $answer_id ] = $wrong_answer;
1374
+                                $answers[$answer_id] = $wrong_answer;
1375 1375
 
1376 1376
                             } else {
1377 1377
 
@@ -1382,115 +1382,115 @@  discard block
 block discarded – undo
1382 1382
                         } // end for each
1383 1383
 
1384 1384
 				    	$answers_sorted = $answers;
1385
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1385
+				    	if ($question_id && count($answer_order) > 0) {
1386 1386
 				    		$answers_sorted = array();
1387
-				    		foreach( $answer_order as $answer_id ) {
1388
-				    			if( isset( $answers[ $answer_id ] ) ) {
1389
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1390
-				    				unset( $answers[ $answer_id ] );
1387
+				    		foreach ($answer_order as $answer_id) {
1388
+				    			if (isset($answers[$answer_id])) {
1389
+				    				$answers_sorted[$answer_id] = $answers[$answer_id];
1390
+				    				unset($answers[$answer_id]);
1391 1391
 				    			}
1392 1392
 				    		}
1393 1393
 
1394
-				    		if( count( $answers ) > 0 ) {
1395
-						    	foreach( $answers as $id => $answer ) {
1396
-						    		$answers_sorted[ $id ] = $answer;
1394
+				    		if (count($answers) > 0) {
1395
+						    	foreach ($answers as $id => $answer) {
1396
+						    		$answers_sorted[$id] = $answer;
1397 1397
 						    	}
1398 1398
 						    }
1399 1399
 				    	}
1400 1400
 
1401
-						foreach( $answers_sorted as $id => $answer ) {
1401
+						foreach ($answers_sorted as $id => $answer) {
1402 1402
 				    		$html .= $answer;
1403 1403
 				    	}
1404 1404
 
1405
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1406
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1407
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1405
+				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />';
1406
+				    	$html .= '<span class="hidden right_answer_count">'.$total_right.'</span>';
1407
+				    	$html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>';
1408 1408
 
1409 1409
 				    	$html .= '<div class="add_answer_options">';
1410
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1411
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1410
+					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>';
1411
+					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>';
1412 1412
 				    	$html .= '</div>';
1413 1413
 
1414
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1414
+                        $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice');
1415 1415
 
1416 1416
 			    	$html .= '</div>';
1417 1417
 				break;
1418 1418
 				case 'boolean':
1419
-					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
1420
-						if( $question_id ) {
1421
-							$field_name = 'question_' . $question_id . '_right_answer_boolean';
1419
+					$html .= '<div class="question_boolean_fields '.$question_class.'">';
1420
+						if ($question_id) {
1421
+							$field_name = 'question_'.$question_id.'_right_answer_boolean';
1422 1422
 						} else {
1423 1423
 							$field_name = 'question_right_answer_boolean';
1424 1424
 							$right_answer = 'true';
1425 1425
 						}
1426
-						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1427
-						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1426
+						$html .= '<label for="question_'.$question_id.'_boolean_true"><input id="question_'.$question_id.'_boolean_true" type="radio" name="'.$field_name.'" value="true" '.checked($right_answer, 'true', false).' /> '.__('True', 'woothemes-sensei').'</label>';
1427
+						$html .= '<label for="question_'.$question_id.'_boolean_false"><input id="question_'.$question_id.'_boolean_false" type="radio" name="'.$field_name.'" value="false" '.checked($right_answer, 'false', false).' /> '.__('False', 'woothemes-sensei').'</label>';
1428 1428
 
1429
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1429
+                    $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean');
1430 1430
 
1431 1431
 					$html .= '</div>';
1432 1432
 				break;
1433 1433
 				case 'gap-fill':
1434
-					$gapfill_array = explode( '||', $right_answer );
1435
-					if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1436
-					if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1437
-					if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1438
-					$html .= '<div class="question_gapfill_fields ' . $question_class . '">';
1434
+					$gapfill_array = explode('||', $right_answer);
1435
+					if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1436
+					if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1437
+					if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1438
+					$html .= '<div class="question_gapfill_fields '.$question_class.'">';
1439 1439
 						// Fill in the Gaps
1440
-						$html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> ';
1441
-						$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="' . $gapfill_pre . '" size="25" class="widefat gapfill-field" />';
1442
-	  					$html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> ';
1443
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="' . $gapfill_gap . '" size="25" class="widefat gapfill-field" />';
1444
-	  					$html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> ';
1445
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="' . $gapfill_post . '" size="25" class="widefat gapfill-field" />';
1446
-	  					$html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> ';
1447
-	  					$html .= '<p class="gapfill-preview">' . $gapfill_pre . '&nbsp;<u>' . $gapfill_gap . '</u>&nbsp;' . $gapfill_post . '</p>';
1440
+						$html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> ';
1441
+						$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="'.$gapfill_pre.'" size="25" class="widefat gapfill-field" />';
1442
+	  					$html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> ';
1443
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="'.$gapfill_gap.'" size="25" class="widefat gapfill-field" />';
1444
+	  					$html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> ';
1445
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="'.$gapfill_post.'" size="25" class="widefat gapfill-field" />';
1446
+	  					$html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> ';
1447
+	  					$html .= '<p class="gapfill-preview">'.$gapfill_pre.'&nbsp;<u>'.$gapfill_gap.'</u>&nbsp;'.$gapfill_post.'</p>';
1448 1448
 	  				$html .= '</div>';
1449 1449
 				break;
1450 1450
 				case 'multi-line':
1451
-					$html .= '<div class="question_multiline_fields ' . $question_class . '">';
1451
+					$html .= '<div class="question_multiline_fields '.$question_class.'">';
1452 1452
 						// Guides for grading
1453
-						if( $question_counter ) {
1454
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline';
1453
+						if ($question_counter) {
1454
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline';
1455 1455
 						} else {
1456 1456
 							$field_id = 'add_question_right_answer_multiline';
1457 1457
 						}
1458
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> ';
1459
-						$html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1458
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> ';
1459
+						$html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1460 1460
 					$html .= '</div>';
1461 1461
 				break;
1462 1462
 				case 'single-line':
1463
-					$html .= '<div class="question_singleline_fields ' . $question_class . '">';
1463
+					$html .= '<div class="question_singleline_fields '.$question_class.'">';
1464 1464
 						// Recommended Answer
1465
-						if( $question_counter ) {
1466
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline';
1465
+						if ($question_counter) {
1466
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline';
1467 1467
 						} else {
1468 1468
 							$field_id = 'add_question_right_answer_singleline';
1469 1469
 						}
1470
-						$html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> ';
1471
-						$html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />';
1470
+						$html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> ';
1471
+						$html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />';
1472 1472
 					$html .= '</div>';
1473 1473
 				break;
1474 1474
 				case 'file-upload':
1475
-					$html .= '<div class="question_fileupload_fields ' . $question_class . '">';
1476
-						if( $question_counter ) {
1477
-							$right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload';
1478
-							$wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload';
1475
+					$html .= '<div class="question_fileupload_fields '.$question_class.'">';
1476
+						if ($question_counter) {
1477
+							$right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload';
1478
+							$wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload';
1479 1479
 						} else {
1480 1480
 							$right_field_id = 'add_question_right_answer_fileupload';
1481 1481
 							$wrong_field_id = 'add_question_wrong_answer_fileupload';
1482 1482
 						}
1483 1483
 
1484 1484
 						$wrong_answer = '';
1485
-						if( isset( $wrong_answers[0] ) ) {
1485
+						if (isset($wrong_answers[0])) {
1486 1486
 							$wrong_answer = $wrong_answers[0];
1487 1487
 						}
1488
-						$html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> ';
1489
-						$html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>';
1488
+						$html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> ';
1489
+						$html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>';
1490 1490
 
1491 1491
 						// Guides for grading
1492
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> ';
1493
-						$html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1492
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> ';
1493
+						$html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1494 1494
 					$html .= '</div>';
1495 1495
 				break;
1496 1496
 			}
@@ -1499,32 +1499,32 @@  discard block
 block discarded – undo
1499 1499
 		return $html;
1500 1500
 	}
1501 1501
 
1502
-	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1502
+	public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') {
1503 1503
 
1504 1504
         // default field name
1505 1505
         $field_name = 'answer_feedback';
1506
-        if( 'boolean' == $question_type ){
1506
+        if ('boolean' == $question_type) {
1507 1507
 
1508 1508
             $field_name = 'answer_feedback_boolean';
1509 1509
 
1510
-        }elseif( 'multiple-choice' == $question_type ){
1510
+        }elseif ('multiple-choice' == $question_type) {
1511 1511
 
1512 1512
             $field_name = 'answer_feedback_multiple_choice';
1513 1513
 
1514 1514
         }// end if
1515 1515
 
1516
-		if( $question_counter ) {
1517
-			$field_name = 'answer_' . $question_counter . '_feedback';
1516
+		if ($question_counter) {
1517
+			$field_name = 'answer_'.$question_counter.'_feedback';
1518 1518
 		}
1519 1519
 
1520 1520
 		$feedback = '';
1521
-		if( $question_id ) {
1522
-			$feedback = get_post_meta( $question_id, '_answer_feedback', true );
1521
+		if ($question_id) {
1522
+			$feedback = get_post_meta($question_id, '_answer_feedback', true);
1523 1523
 		}
1524 1524
 
1525
-		$html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">';
1526
-		$html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>';
1527
-		$html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>';
1525
+		$html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">';
1526
+		$html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>';
1527
+		$html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>';
1528 1528
 		$html .= '</p>';
1529 1529
 
1530 1530
 		return $html;
@@ -1533,19 +1533,19 @@  discard block
 block discarded – undo
1533 1533
 	public function question_get_answer_id() {
1534 1534
 		$data = $_POST['data'];
1535 1535
 		$answer_data = array();
1536
-		parse_str( $data, $answer_data );
1536
+		parse_str($data, $answer_data);
1537 1537
 		$answer = $answer_data['answer_value'];
1538
-		$answer_id = $this->get_answer_id( $answer );
1538
+		$answer_id = $this->get_answer_id($answer);
1539 1539
 		echo $answer_id;
1540 1540
 		die();
1541 1541
 	}
1542 1542
 
1543
-	public function get_answer_id( $answer = '' ) {
1543
+	public function get_answer_id($answer = '') {
1544 1544
 
1545 1545
 		$answer_id = '';
1546 1546
 
1547
-		if( $answer ) {
1548
-			$answer_id = md5( $answer );
1547
+		if ($answer) {
1548
+			$answer_id = md5($answer);
1549 1549
 		}
1550 1550
 
1551 1551
 		return $answer_id;
@@ -1558,17 +1558,17 @@  discard block
 block discarded – undo
1558 1558
 	 * @access public
1559 1559
 	 * @return void
1560 1560
 	 */
1561
-	public function lesson_quiz_meta_box_content () {
1561
+	public function lesson_quiz_meta_box_content() {
1562 1562
 		global $post;
1563 1563
 
1564 1564
 		// Get quiz panel
1565 1565
 		$quiz_id = 0;
1566 1566
 		$quizzes = array();
1567
-		if ( 0 < $post->ID ) {
1568
-			$quiz_id = $this->lesson_quizzes( $post->ID, 'any' );
1567
+		if (0 < $post->ID) {
1568
+			$quiz_id = $this->lesson_quizzes($post->ID, 'any');
1569 1569
 		}
1570 1570
 
1571
-		echo $this->quiz_panel( $quiz_id );
1571
+		echo $this->quiz_panel($quiz_id);
1572 1572
 
1573 1573
 	} // End lesson_quiz_meta_box_content()
1574 1574
 
@@ -1585,53 +1585,53 @@  discard block
 block discarded – undo
1585 1585
 		$quiz_id = 0;
1586 1586
 		$lesson_id = $post->ID;
1587 1587
 		$quizzes = array();
1588
-		if ( 0 < $lesson_id ) {
1589
-			$quiz_id = $this->lesson_quizzes( $lesson_id, 'any' );
1588
+		if (0 < $lesson_id) {
1589
+			$quiz_id = $this->lesson_quizzes($lesson_id, 'any');
1590 1590
 		}
1591 1591
 
1592
-		if( $quiz_id ) {
1593
-			$html .= $this->quiz_settings_panel( $lesson_id, $quiz_id );
1592
+		if ($quiz_id) {
1593
+			$html .= $this->quiz_settings_panel($lesson_id, $quiz_id);
1594 1594
 		} else {
1595
-			$html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>';
1595
+			$html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>';
1596 1596
 		}
1597 1597
 
1598 1598
 		echo $html;
1599 1599
 	}
1600 1600
 
1601
-	public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) {
1601
+	public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) {
1602 1602
 
1603 1603
 
1604 1604
 		$html = '';
1605 1605
 
1606
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1606
+		if ( ! $lesson_id && ! $quiz_id) return $html;
1607 1607
 
1608
-		$settings = $this->get_quiz_settings( $quiz_id );
1608
+		$settings = $this->get_quiz_settings($quiz_id);
1609 1609
 
1610
-		$html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' );
1610
+		$html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings');
1611 1611
 
1612 1612
 		return $html;
1613 1613
 
1614 1614
 	}
1615 1615
 
1616
-	public function get_quiz_settings( $quiz_id = 0 ) {
1616
+	public function get_quiz_settings($quiz_id = 0) {
1617 1617
 
1618 1618
 		$disable_passmark = '';
1619
-		$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1620
-		if( ! $pass_required ) {
1619
+		$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1620
+		if ( ! $pass_required) {
1621 1621
 			$disable_passmark = 'hidden';
1622 1622
 		}
1623 1623
 
1624 1624
 		// Setup Questions Query
1625 1625
 		$questions = array();
1626
-		if ( 0 < $quiz_id ) {
1627
-			$questions = $this->lesson_quiz_questions( $quiz_id );
1626
+		if (0 < $quiz_id) {
1627
+			$questions = $this->lesson_quiz_questions($quiz_id);
1628 1628
 		}
1629 1629
 
1630 1630
 		// Count questions
1631 1631
 		$question_count = 0;
1632
-		foreach( $questions as $question ) {
1633
-			if( $question->post_type == 'multiple_question' ) {
1634
-				$question_number = get_post_meta( $question->ID, 'number', true );
1632
+		foreach ($questions as $question) {
1633
+			if ($question->post_type == 'multiple_question') {
1634
+				$question_number = get_post_meta($question->ID, 'number', true);
1635 1635
 				$question_count += $question_number;
1636 1636
 			} else {
1637 1637
 				++$question_count;
@@ -1641,15 +1641,15 @@  discard block
 block discarded – undo
1641 1641
 		$settings = array(
1642 1642
 			array(
1643 1643
 				'id' 			=> 'pass_required',
1644
-				'label'			=> __( 'Pass required to complete lesson', 'woothemes-sensei' ),
1645
-				'description'	=> __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ),
1644
+				'label'			=> __('Pass required to complete lesson', 'woothemes-sensei'),
1645
+				'description'	=> __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'),
1646 1646
 				'type'			=> 'checkbox',
1647 1647
 				'default'		=> '',
1648 1648
 				'checked'		=> 'on',
1649 1649
 			),
1650 1650
 			array(
1651 1651
 				'id' 			=> 'quiz_passmark',
1652
-				'label'			=> __( 'Quiz passmark percentage', 'woothemes-sensei' ),
1652
+				'label'			=> __('Quiz passmark percentage', 'woothemes-sensei'),
1653 1653
 				'description'	=> '',
1654 1654
 				'type'			=> 'number',
1655 1655
 				'default'		=> 0,
@@ -1660,17 +1660,17 @@  discard block
 block discarded – undo
1660 1660
 			),
1661 1661
 			array(
1662 1662
 				'id' 			=> 'show_questions',
1663
-				'label'			=> __( 'Number of questions to show', 'woothemes-sensei' ),
1664
-				'description'	=> __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ),
1663
+				'label'			=> __('Number of questions to show', 'woothemes-sensei'),
1664
+				'description'	=> __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'),
1665 1665
 				'type'			=> 'number',
1666 1666
 				'default'		=> '',
1667
-				'placeholder'	=> __( 'All', 'woothemes-sensei' ),
1667
+				'placeholder'	=> __('All', 'woothemes-sensei'),
1668 1668
 				'min'			=> 1,
1669 1669
 				'max'			=> $question_count,
1670 1670
 			),
1671 1671
 			array(
1672 1672
 				'id' 			=> 'random_question_order',
1673
-				'label'			=> __( 'Randomise question order', 'woothemes-sensei' ),
1673
+				'label'			=> __('Randomise question order', 'woothemes-sensei'),
1674 1674
 				'description'	=> '',
1675 1675
 				'type'			=> 'checkbox',
1676 1676
 				'default'		=> 'no',
@@ -1678,23 +1678,23 @@  discard block
 block discarded – undo
1678 1678
 			),
1679 1679
 			array(
1680 1680
 				'id' 			=> 'quiz_grade_type',
1681
-				'label'			=> __( 'Grade quiz automatically', 'woothemes-sensei' ),
1682
-				'description'	=> __( 'Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei' ),
1681
+				'label'			=> __('Grade quiz automatically', 'woothemes-sensei'),
1682
+				'description'	=> __('Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei'),
1683 1683
 				'type'			=> 'checkbox',
1684 1684
 				'default'		=> 'auto',
1685 1685
 				'checked'		=> 'auto',
1686 1686
 			),
1687 1687
 			array(
1688 1688
 				'id' 			=> 'enable_quiz_reset',
1689
-				'label'			=> __( 'Allow user to retake the quiz', 'woothemes-sensei' ),
1690
-				'description'	=> __( 'Enables the quiz reset button.', 'woothemes-sensei' ),
1689
+				'label'			=> __('Allow user to retake the quiz', 'woothemes-sensei'),
1690
+				'description'	=> __('Enables the quiz reset button.', 'woothemes-sensei'),
1691 1691
 				'type'			=> 'checkbox',
1692 1692
 				'default'		=> '',
1693 1693
 				'checked'		=> 'on',
1694 1694
 			),
1695 1695
 		);
1696 1696
 
1697
-		return apply_filters( 'sensei_quiz_settings', $settings );
1697
+		return apply_filters('sensei_quiz_settings', $settings);
1698 1698
 	}
1699 1699
 
1700 1700
 	/**
@@ -1703,38 +1703,38 @@  discard block
 block discarded – undo
1703 1703
 	 * @access public
1704 1704
 	 * @return void
1705 1705
 	 */
1706
-	public function enqueue_scripts( $hook ) {
1706
+	public function enqueue_scripts($hook) {
1707 1707
 		global  $post_type;
1708 1708
 
1709
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
1710
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1711
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) );
1709
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
1710
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1711
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order'));
1712 1712
 
1713 1713
 		// Test for Write Panel Pages
1714
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1714
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1715 1715
 
1716
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1716
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1717 1717
 
1718 1718
 			// Load the lessons script
1719 1719
             wp_enqueue_media();
1720
-			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1721
-			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1722
-			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1720
+			wp_enqueue_script('sensei-lesson-metadata', Sensei()->plugin_url.'assets/js/lesson-metadata'.$suffix.'.js', array('jquery', 'select2', 'jquery-ui-sortable'), Sensei()->version, true);
1721
+			wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1722
+			wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true);
1723 1723
 
1724 1724
             // Load the bulk edit screen script
1725
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1726
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1725
+            if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) {
1726
+                wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1727 1727
             }
1728 1728
 
1729 1729
 			// Localise script
1730
-			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
1731
-			$ajax_vars = array( 'lesson_update_question_nonce' => wp_create_nonce( 'lesson_update_question_nonce' ), 'lesson_add_course_nonce' => wp_create_nonce( 'lesson_add_course_nonce' ), 'lesson_update_grade_type_nonce' => wp_create_nonce( 'lesson_update_grade_type_nonce' ), 'lesson_update_question_order_nonce' => wp_create_nonce( 'lesson_update_question_order_nonce' ), 'lesson_update_question_order_random_nonce' => wp_create_nonce( 'lesson_update_question_order_random_nonce' ), 'lesson_add_multiple_questions_nonce' => wp_create_nonce( 'lesson_add_multiple_questions_nonce' ), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce( 'lesson_remove_multiple_questions_nonce' ), 'lesson_add_existing_questions_nonce' => wp_create_nonce( 'lesson_add_existing_questions_nonce' ), 'filter_existing_questions_nonce' => wp_create_nonce( 'filter_existing_questions_nonce' ) );
1732
-			$data = array_merge( $translation_strings, $ajax_vars );
1733
-			wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data );
1730
+			$translation_strings = array('right_colon' => __('Right:', 'woothemes-sensei'), 'wrong_colon' => __('Wrong:', 'woothemes-sensei'), 'add_file' => __('Add file', 'woothemes-sensei'), 'change_file' => __('Change file', 'woothemes-sensei'), 'confirm_remove' => __('Are you sure you want to remove this question?', 'woothemes-sensei'), 'confirm_remove_multiple' => __('Are you sure you want to remove these questions?', 'woothemes-sensei'), 'too_many_for_cat' => __('You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei'));
1731
+			$ajax_vars = array('lesson_update_question_nonce' => wp_create_nonce('lesson_update_question_nonce'), 'lesson_add_course_nonce' => wp_create_nonce('lesson_add_course_nonce'), 'lesson_update_grade_type_nonce' => wp_create_nonce('lesson_update_grade_type_nonce'), 'lesson_update_question_order_nonce' => wp_create_nonce('lesson_update_question_order_nonce'), 'lesson_update_question_order_random_nonce' => wp_create_nonce('lesson_update_question_order_random_nonce'), 'lesson_add_multiple_questions_nonce' => wp_create_nonce('lesson_add_multiple_questions_nonce'), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce('lesson_remove_multiple_questions_nonce'), 'lesson_add_existing_questions_nonce' => wp_create_nonce('lesson_add_existing_questions_nonce'), 'filter_existing_questions_nonce' => wp_create_nonce('filter_existing_questions_nonce'));
1732
+			$data = array_merge($translation_strings, $ajax_vars);
1733
+			wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data);
1734 1734
 
1735 1735
 			// Chosen RTL
1736
-			if ( is_rtl() ) {
1737
-				wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1736
+			if (is_rtl()) {
1737
+				wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1738 1738
 			}
1739 1739
 
1740 1740
 		}
@@ -1748,16 +1748,16 @@  discard block
 block discarded – undo
1748 1748
 	 * @since  1.4.0
1749 1749
 	 * @return void
1750 1750
 	 */
1751
-	public function enqueue_styles ( $hook ) {
1751
+	public function enqueue_styles($hook) {
1752 1752
 		global  $post_type;
1753 1753
 
1754
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) );
1755
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1756
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) );
1754
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message'));
1755
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1756
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings'));
1757 1757
 
1758 1758
 		// Test for Write Panel Pages
1759
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1760
-			wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version );
1759
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1760
+			wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version);
1761 1761
 		}
1762 1762
 
1763 1763
 	} // End enqueue_styles()
@@ -1769,12 +1769,12 @@  discard block
 block discarded – undo
1769 1769
 	 * @param  array $defaults
1770 1770
 	 * @return array $new_columns
1771 1771
 	 */
1772
-	public function add_column_headings ( $defaults ) {
1772
+	public function add_column_headings($defaults) {
1773 1773
 		$new_columns['cb'] = '<input type="checkbox" />';
1774
-		$new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' );
1775
-		$new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' );
1776
-		$new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' );
1777
-		if ( isset( $defaults['date'] ) ) {
1774
+		$new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei');
1775
+		$new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei');
1776
+		$new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei');
1777
+		if (isset($defaults['date'])) {
1778 1778
 			$new_columns['date'] = $defaults['date'];
1779 1779
 		}
1780 1780
 		return $new_columns;
@@ -1788,23 +1788,23 @@  discard block
 block discarded – undo
1788 1788
 	 * @param  int $id
1789 1789
 	 * @return void
1790 1790
 	 */
1791
-	public function add_column_data ( $column_name, $id ) {
1791
+	public function add_column_data($column_name, $id) {
1792 1792
 		global $wpdb, $post;
1793 1793
 
1794
-		switch ( $column_name ) {
1794
+		switch ($column_name) {
1795 1795
 			case 'id':
1796 1796
 				echo $id;
1797 1797
 			break;
1798 1798
 			case 'lesson-course':
1799
-				$lesson_course_id = get_post_meta( $id, '_lesson_course', true);
1800
-				if ( 0 < absint( $lesson_course_id ) ) {
1801
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_course_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_course_id ) ) ) ) . '">' . get_the_title( absint( $lesson_course_id ) ) . '</a>';
1799
+				$lesson_course_id = get_post_meta($id, '_lesson_course', true);
1800
+				if (0 < absint($lesson_course_id)) {
1801
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_course_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_course_id)))).'">'.get_the_title(absint($lesson_course_id)).'</a>';
1802 1802
 				} // End If Statement
1803 1803
 			break;
1804 1804
 			case 'lesson-prerequisite':
1805
-				$lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true);
1806
-				if ( 0 < absint( $lesson_prerequisite_id ) ) {
1807
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $lesson_prerequisite_id ) ) . '</a>';
1805
+				$lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true);
1806
+				if (0 < absint($lesson_prerequisite_id)) {
1807
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_prerequisite_id)))).'">'.get_the_title(absint($lesson_prerequisite_id)).'</a>';
1808 1808
 				} // End If Statement
1809 1809
 			break;
1810 1810
 			default:
@@ -1818,13 +1818,13 @@  discard block
 block discarded – undo
1818 1818
 	 * @access public
1819 1819
 	 * @return void
1820 1820
 	 */
1821
-	public function lesson_add_course () {
1821
+	public function lesson_add_course() {
1822 1822
 		global $current_user;
1823 1823
 		//Add nonce security to the request
1824
-		if ( isset($_POST['lesson_add_course_nonce']) ) {
1825
-			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1824
+		if (isset($_POST['lesson_add_course_nonce'])) {
1825
+			$nonce = esc_html($_POST['lesson_add_course_nonce']);
1826 1826
 		} // End If Statement
1827
-		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' ) ) {
1827
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')) {
1828 1828
 			die('');
1829 1829
 		} // End If Statement
1830 1830
 		// Parse POST data
@@ -1846,43 +1846,43 @@  discard block
 block discarded – undo
1846 1846
 	 * @access public
1847 1847
 	 * @return void
1848 1848
 	 */
1849
-	public function lesson_update_question () {
1849
+	public function lesson_update_question() {
1850 1850
 		global $current_user;
1851 1851
 		//Add nonce security to the request
1852
-		if ( isset($_POST['lesson_update_question_nonce']) ) {
1853
-			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1852
+		if (isset($_POST['lesson_update_question_nonce'])) {
1853
+			$nonce = esc_html($_POST['lesson_update_question_nonce']);
1854 1854
 		} // End If Statement
1855
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' ) ) {
1855
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')) {
1856 1856
 			die('');
1857 1857
 		} // End If Statement
1858 1858
 		// Parse POST data
1859 1859
 		// WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that
1860 1860
 		// even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed.
1861 1861
 		// So first restore the original unslashed apostrophes by removing those slashes
1862
-		$data = wp_unslash( $_POST['data'] );
1862
+		$data = wp_unslash($_POST['data']);
1863 1863
 		// Then parse the string to an array (note that parse_str automatically urldecodes all the variables)
1864 1864
 		$question_data = array();
1865 1865
 		parse_str($data, $question_data);
1866 1866
 		// Finally re-slash all elements to ensure consistancy for lesson_save_question()
1867
-		$question_data = wp_slash( $question_data );
1867
+		$question_data = wp_slash($question_data);
1868 1868
 		// Save the question
1869 1869
 		$return = false;
1870 1870
 		// Question Save and Delete logic
1871
-		if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) {
1871
+		if (isset($question_data['action']) && ($question_data['action'] == 'delete')) {
1872 1872
 			// Delete the Question
1873 1873
 			$return = $this->lesson_delete_question($question_data);
1874 1874
 		} else {
1875 1875
 			// Save the Question
1876
-			if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1876
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1877 1877
 				$current_user = wp_get_current_user();
1878 1878
 				$question_data['post_author'] = $current_user->ID;
1879
-				$question_id = $this->lesson_save_question( $question_data );
1880
-				$question_type = Sensei()->question->get_question_type( $question_id );
1879
+				$question_id = $this->lesson_save_question($question_data);
1880
+				$question_type = Sensei()->question->get_question_type($question_id);
1881 1881
 
1882
-				$question_count = intval( $question_data['question_count'] );
1882
+				$question_count = intval($question_data['question_count']);
1883 1883
 				++$question_count;
1884 1884
 
1885
-				$return = $this->quiz_panel_question( $question_type, $question_count, $question_id );
1885
+				$return = $this->quiz_panel_question($question_type, $question_count, $question_id);
1886 1886
 			} // End If Statement
1887 1887
 		} // End If Statement
1888 1888
 
@@ -1897,48 +1897,48 @@  discard block
 block discarded – undo
1897 1897
 
1898 1898
 		//Add nonce security to the request
1899 1899
 		$nonce = '';
1900
-		if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) {
1901
-			$nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] );
1900
+		if (isset($_POST['lesson_add_multiple_questions_nonce'])) {
1901
+			$nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']);
1902 1902
 		} // End If Statement
1903 1903
 
1904
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' ) ) {
1905
-			die( $return );
1904
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')) {
1905
+			die($return);
1906 1906
 		} // End If Statement
1907 1907
 
1908 1908
 		// Parse POST data
1909 1909
 		$data = $_POST['data'];
1910 1910
 		$question_data = array();
1911
-		parse_str( $data, $question_data );
1911
+		parse_str($data, $question_data);
1912 1912
 
1913
-		if( is_array( $question_data ) ) {
1914
-			if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1913
+		if (is_array($question_data)) {
1914
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1915 1915
 
1916
-				$quiz_id = intval( $question_data['quiz_id'] );
1917
-				$question_number = intval( $question_data['question_number'] );
1918
-				$question_category = intval( $question_data['question_category'] );
1916
+				$quiz_id = intval($question_data['quiz_id']);
1917
+				$question_number = intval($question_data['question_number']);
1918
+				$question_category = intval($question_data['question_category']);
1919 1919
 
1920
-				$question_counter = intval( $question_data['question_count'] );
1920
+				$question_counter = intval($question_data['question_count']);
1921 1921
 				++$question_counter;
1922 1922
 
1923
-				$cat = get_term( $question_category, 'question-category' );
1923
+				$cat = get_term($question_category, 'question-category');
1924 1924
 
1925 1925
 				$post_data = array(
1926 1926
 					'post_content' => '',
1927 1927
 					'post_status' => 'publish',
1928
-					'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ),
1928
+					'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name),
1929 1929
 					'post_type' => 'multiple_question'
1930 1930
 				);
1931 1931
 
1932
-				$multiple_id = wp_insert_post( $post_data );
1932
+				$multiple_id = wp_insert_post($post_data);
1933 1933
 
1934
-				if( $multiple_id && ! is_wp_error( $multiple_id ) ) {
1935
-					add_post_meta( $multiple_id, 'category', $question_category );
1936
-					add_post_meta( $multiple_id, 'number', $question_number );
1937
-					add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false );
1938
-					add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter );
1939
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1940
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
1941
-					$return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) );
1934
+				if ($multiple_id && ! is_wp_error($multiple_id)) {
1935
+					add_post_meta($multiple_id, 'category', $question_category);
1936
+					add_post_meta($multiple_id, 'number', $question_number);
1937
+					add_post_meta($multiple_id, '_quiz_id', $quiz_id, false);
1938
+					add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter);
1939
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1940
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
1941
+					$return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number));
1942 1942
 				}
1943 1943
 			}
1944 1944
 		}
@@ -1952,24 +1952,24 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		//Add nonce security to the request
1954 1954
 		$nonce = '';
1955
-		if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) {
1956
-			$nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] );
1955
+		if (isset($_POST['lesson_remove_multiple_questions_nonce'])) {
1956
+			$nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']);
1957 1957
 		} // End If Statement
1958 1958
 
1959
-		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' ) ) {
1959
+		if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')) {
1960 1960
 			die('');
1961 1961
 		} // End If Statement
1962 1962
 
1963 1963
 		// Parse POST data
1964 1964
 		$data = $_POST['data'];
1965 1965
 		$question_data = array();
1966
-		parse_str( $data, $question_data );
1966
+		parse_str($data, $question_data);
1967 1967
 
1968
-		if( is_array( $question_data ) ) {
1969
-			wp_delete_post( $question_data['question_id'], true );
1968
+		if (is_array($question_data)) {
1969
+			wp_delete_post($question_data['question_id'], true);
1970 1970
 		}
1971 1971
 
1972
-		die( 'Deleted' );
1972
+		die('Deleted');
1973 1973
 	}
1974 1974
 
1975 1975
 	public function get_question_category_limit() {
@@ -1980,11 +1980,11 @@  discard block
 block discarded – undo
1980 1980
 		// Parse POST data
1981 1981
 		$data = $_POST['data'];
1982 1982
 		$cat_data = array();
1983
-		parse_str( $data, $cat_data );
1983
+		parse_str($data, $cat_data);
1984 1984
 
1985
-		if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) {
1986
-			$cat = get_term( $cat_data['cat'], 'question-category' );
1987
-			if( isset( $cat->count ) ) {
1985
+		if (isset($cat_data['cat']) && '' != $cat_data['cat']) {
1986
+			$cat = get_term($cat_data['cat'], 'question-category');
1987
+			if (isset($cat->count)) {
1988 1988
 				$return = $cat->count;
1989 1989
 			}
1990 1990
 		}
@@ -1998,44 +1998,44 @@  discard block
 block discarded – undo
1998 1998
 
1999 1999
 		//Add nonce security to the request
2000 2000
 		$nonce = '';
2001
-		if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) {
2002
-			$nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] );
2001
+		if (isset($_POST['lesson_add_existing_questions_nonce'])) {
2002
+			$nonce = esc_html($_POST['lesson_add_existing_questions_nonce']);
2003 2003
 		} // End If Statement
2004 2004
 
2005
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' ) ) {
2005
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')) {
2006 2006
 			die('');
2007 2007
 		} // End If Statement
2008 2008
 
2009 2009
 		// Parse POST data
2010 2010
 		$data = $_POST['data'];
2011 2011
 		$question_data = array();
2012
-		parse_str( $data, $question_data );
2012
+		parse_str($data, $question_data);
2013 2013
 
2014 2014
 		$return = '';
2015 2015
 
2016
-		if( is_array( $question_data ) ) {
2016
+		if (is_array($question_data)) {
2017 2017
 
2018
-			if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) {
2018
+			if (isset($question_data['questions']) && '' != $question_data['questions']) {
2019 2019
 
2020
-				$questions = explode( ',', trim( $question_data['questions'], ',' ) );
2020
+				$questions = explode(',', trim($question_data['questions'], ','));
2021 2021
 				$quiz_id = $question_data['quiz_id'];
2022
-				$question_count = intval( $question_data['question_count'] );
2022
+				$question_count = intval($question_data['question_count']);
2023 2023
 
2024
-				foreach( $questions as $question_id ) {
2024
+				foreach ($questions as $question_id) {
2025 2025
 
2026 2026
 					++$question_count;
2027 2027
 
2028
-					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2029
-					if( ! in_array( $quiz_id, $quizzes ) ) {
2030
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2031
-						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2032
-						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2028
+					$quizzes = get_post_meta($question_id, '_quiz_id', false);
2029
+					if ( ! in_array($quiz_id, $quizzes)) {
2030
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2031
+						$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2032
+						update_post_meta($lesson_id, '_quiz_has_questions', '1');
2033 2033
 			    	}
2034 2034
 
2035
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2036
-					$question_type = Sensei()->question->get_question_type( $question_id );
2035
+			    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2036
+					$question_type = Sensei()->question->get_question_type($question_id);
2037 2037
 
2038
-					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
2038
+					$return .= $this->quiz_panel_question($question_type, $question_count, $question_id);
2039 2039
 				}
2040 2040
 			}
2041 2041
 		}
@@ -2047,57 +2047,57 @@  discard block
 block discarded – undo
2047 2047
 
2048 2048
 	public function lesson_update_grade_type() {
2049 2049
 		//Add nonce security to the request
2050
-		if ( isset($_POST['lesson_update_grade_type_nonce']) ) {
2051
-			$nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] );
2050
+		if (isset($_POST['lesson_update_grade_type_nonce'])) {
2051
+			$nonce = esc_html($_POST['lesson_update_grade_type_nonce']);
2052 2052
 		} // End If Statement
2053
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' ) ) {
2053
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')) {
2054 2054
 			die('');
2055 2055
 		} // End If Statement
2056 2056
 		// Parse POST data
2057 2057
 		$data = $_POST['data'];
2058 2058
 		$quiz_data = array();
2059 2059
 		parse_str($data, $quiz_data);
2060
-		update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] );
2060
+		update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']);
2061 2061
 		die();
2062 2062
 	}
2063 2063
 
2064 2064
 	public function lesson_update_question_order() {
2065 2065
 		// Add nonce security to the request
2066
-		if ( isset($_POST['lesson_update_question_order_nonce']) ) {
2067
-			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2066
+		if (isset($_POST['lesson_update_question_order_nonce'])) {
2067
+			$nonce = esc_html($_POST['lesson_update_question_order_nonce']);
2068 2068
 		} // End If Statement
2069
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' ) ) {
2069
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')) {
2070 2070
 			die('');
2071 2071
 		} // End If Statement
2072 2072
 		// Parse POST data
2073 2073
 		$data = $_POST['data'];
2074 2074
 		$quiz_data = array();
2075 2075
 		parse_str($data, $quiz_data);
2076
-		if( strlen( $quiz_data['question_order'] ) > 0 ) {
2077
-			$questions = explode( ',', $quiz_data['question_order'] );
2076
+		if (strlen($quiz_data['question_order']) > 0) {
2077
+			$questions = explode(',', $quiz_data['question_order']);
2078 2078
 			$o = 1;
2079
-			foreach( $questions as $question_id ) {
2080
-				update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o );
2079
+			foreach ($questions as $question_id) {
2080
+				update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o);
2081 2081
 				++$o;
2082 2082
 			}
2083
-			update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions );
2083
+			update_post_meta($quiz_data['quiz_id'], '_question_order', $questions);
2084 2084
 		}
2085 2085
 		die();
2086 2086
 	}
2087 2087
 
2088 2088
 	public function lesson_update_question_order_random() {
2089 2089
 		//Add nonce security to the request
2090
-		if ( isset($_POST['lesson_update_question_order_random_nonce']) ) {
2091
-			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2090
+		if (isset($_POST['lesson_update_question_order_random_nonce'])) {
2091
+			$nonce = esc_html($_POST['lesson_update_question_order_random_nonce']);
2092 2092
 		} // End If Statement
2093
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' ) ) {
2093
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')) {
2094 2094
 			die('');
2095 2095
 		} // End If Statement
2096 2096
 		// Parse POST data
2097 2097
 		$data = $_POST['data'];
2098 2098
 		$quiz_data = array();
2099 2099
 		parse_str($data, $quiz_data);
2100
-		update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] );
2100
+		update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']);
2101 2101
 		die();
2102 2102
 	}
2103 2103
 
@@ -2108,7 +2108,7 @@  discard block
 block discarded – undo
2108 2108
 	 * @param array $data (default: array())
2109 2109
 	 * @return void
2110 2110
 	 */
2111
-	private function lesson_save_course( $data = array() ) {
2111
+	private function lesson_save_course($data = array()) {
2112 2112
 		global $current_user;
2113 2113
 		$return = false;
2114 2114
 		// Setup the course data
@@ -2117,58 +2117,58 @@  discard block
 block discarded – undo
2117 2117
 		$course_title = '';
2118 2118
 		$course_prerequisite = 0;
2119 2119
 		$course_category = 0;
2120
-		if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) {
2121
-			$course_id = absint( $data[ 'course_id' ] );
2120
+		if (isset($data['course_id']) && (0 < absint($data['course_id']))) {
2121
+			$course_id = absint($data['course_id']);
2122 2122
 		} // End If Statement
2123
-		if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) {
2124
-			$course_title = $data[ 'course_title' ];
2123
+		if (isset($data['course_title']) && ('' != $data['course_title'])) {
2124
+			$course_title = $data['course_title'];
2125 2125
 		} // End If Statement
2126 2126
 		$post_title = $course_title;
2127
-		if ( isset($data[ 'post_author' ]) ) {
2128
-			$post_author = $data[ 'post_author' ];
2127
+		if (isset($data['post_author'])) {
2128
+			$post_author = $data['post_author'];
2129 2129
 		} else {
2130 2130
 			$current_user = wp_get_current_user();
2131 2131
 			$post_author = $current_user->ID;
2132 2132
 		} // End If Statement
2133 2133
 		$post_status = 'publish';
2134 2134
 		$post_type = 'course';
2135
-		if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) {
2136
-			$course_content = $data[ 'course_content' ];
2135
+		if (isset($data['course_content']) && ('' != $data['course_content'])) {
2136
+			$course_content = $data['course_content'];
2137 2137
 		} // End If Statement
2138 2138
 		$post_content = $course_content;
2139 2139
 		// Course Query Arguments
2140
-		$post_type_args = array(	'post_content' => $post_content,
2140
+		$post_type_args = array('post_content' => $post_content,
2141 2141
   		    						'post_status' => $post_status,
2142 2142
   		    						'post_title' => $post_title,
2143 2143
   		    						'post_type' => $post_type
2144 2144
   		    						);
2145 2145
   		// Only save if there is a valid title
2146
-  		if ( $post_title != '' ) {
2146
+  		if ($post_title != '') {
2147 2147
   		    // Check for prerequisite courses & product id
2148
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2149
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2150
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2151
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2148
+  		    $course_prerequisite_id = absint($data['course_prerequisite']);
2149
+  		    $course_woocommerce_product_id = absint($data['course_woocommerce_product']);
2150
+  		    $course_category_id = absint($data['course_category']);
2151
+  		    if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; }
2152 2152
   		    // Insert or Update the Lesson Quiz
2153
-		    if ( 0 < $course_id ) {
2154
-		    	$post_type_args[ 'ID' ] = $course_id;
2153
+		    if (0 < $course_id) {
2154
+		    	$post_type_args['ID'] = $course_id;
2155 2155
 		    	$course_id = wp_update_post($post_type_args);
2156
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2157
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2158
-		    	if ( 0 < $course_category_id ) {
2159
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2156
+		    	update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2157
+		    	update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2158
+		    	if (0 < $course_category_id) {
2159
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2160 2160
 		    	} // End If Statement
2161 2161
 		    } else {
2162 2162
 		    	$course_id = wp_insert_post($post_type_args);
2163
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2164
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2165
-		    	if ( 0 < $course_category_id ) {
2166
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2163
+		    	add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2164
+		    	add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2165
+		    	if (0 < $course_category_id) {
2166
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2167 2167
 		    	} // End If Statement
2168 2168
 		    } // End If Statement
2169 2169
 		} // End If Statement
2170 2170
   		// Check that the insert or update saved by testing the post id
2171
-  		if ( 0 < $course_id ) {
2171
+  		if (0 < $course_id) {
2172 2172
   			$return = $course_id;
2173 2173
   		} // End If Statement
2174 2174
   		return $return;
@@ -2182,7 +2182,7 @@  discard block
 block discarded – undo
2182 2182
 	 * @param array $data (default: array())
2183 2183
 	 * @return void
2184 2184
 	 */
2185
-	public function lesson_save_question( $data = array(), $context = 'quiz' ) {
2185
+	public function lesson_save_question($data = array(), $context = 'quiz') {
2186 2186
 		$return = false;
2187 2187
 		// Save the Questions
2188 2188
 		// Setup the Question data
@@ -2194,130 +2194,130 @@  discard block
 block discarded – undo
2194 2194
 		$question_category = '';
2195 2195
 
2196 2196
 		// Handle Question Type
2197
-		if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) {
2198
-			$question_type = $data[ 'question_type' ];
2197
+		if (isset($data['question_type']) && ('' != $data['question_type'])) {
2198
+			$question_type = $data['question_type'];
2199 2199
 		} // End If Statement
2200 2200
 
2201
-		if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) {
2202
-			$question_category = $data[ 'question_category' ];
2201
+		if (isset($data['question_category']) && ('' != $data['question_category'])) {
2202
+			$question_category = $data['question_category'];
2203 2203
 		} // End If Statement
2204 2204
 
2205
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2206
-			$question_id = absint( $data[ 'question_id' ] );
2205
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2206
+			$question_id = absint($data['question_id']);
2207 2207
 		} // End If Statement
2208
-		if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) {
2209
-			$question_text = $data[ 'question' ];
2208
+		if (isset($data['question']) && ('' != $data['question'])) {
2209
+			$question_text = $data['question'];
2210 2210
 		} // End If Statement
2211 2211
 		$post_title = $question_text;
2212 2212
 		// Handle Default Fields (multiple choice)
2213
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) {
2214
-			$question_right_answers = $data[ 'question_right_answers' ];
2213
+		if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) {
2214
+			$question_right_answers = $data['question_right_answers'];
2215 2215
 		} // End If Statement
2216
-		elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) {
2217
-			$question_right_answer = $data[ 'question_right_answer' ];
2216
+		elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) {
2217
+			$question_right_answer = $data['question_right_answer'];
2218 2218
 		} // End If Statement
2219
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) {
2220
-			$question_wrong_answers = $data[ 'question_wrong_answers' ];
2219
+		if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) {
2220
+			$question_wrong_answers = $data['question_wrong_answers'];
2221 2221
 		} // End If Statement
2222 2222
 		// Handle Boolean Fields - Edit
2223
-		if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) {
2224
-			$question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ];
2223
+		if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) {
2224
+			$question_right_answer = $data['question_'.$question_id.'_right_answer_boolean'];
2225 2225
 		} // End If Statement
2226 2226
 		// Handle Boolean Fields - Add
2227
-		if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) {
2228
-			$question_right_answer = $data[ 'question_right_answer_boolean' ];
2227
+		if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) {
2228
+			$question_right_answer = $data['question_right_answer_boolean'];
2229 2229
 		} // End If Statement
2230 2230
 		// Handle Gap Fill Fields
2231
-		if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) {
2232
-			$question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ];
2231
+		if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) {
2232
+			$question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post'];
2233 2233
 		} // End If Statement
2234 2234
 		// Handle Multi Line Fields
2235
-		if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) {
2236
-			$question_right_answer = $data[ 'add_question_right_answer_multiline' ];
2235
+		if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) {
2236
+			$question_right_answer = $data['add_question_right_answer_multiline'];
2237 2237
 		} // End If Statement
2238 2238
 		// Handle Single Line Fields
2239
-		if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) {
2240
-			$question_right_answer = $data[ 'add_question_right_answer_singleline' ];
2239
+		if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) {
2240
+			$question_right_answer = $data['add_question_right_answer_singleline'];
2241 2241
 		} // End If Statement
2242 2242
 		// Handle File Upload Fields
2243
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) {
2244
-			$question_right_answer = $data[ 'add_question_right_answer_fileupload' ];
2243
+		if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) {
2244
+			$question_right_answer = $data['add_question_right_answer_fileupload'];
2245 2245
 		} // End If Statement
2246
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) {
2247
-			$question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] );
2246
+		if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) {
2247
+			$question_wrong_answers = array($data['add_question_wrong_answer_fileupload']);
2248 2248
 		} // End If Statement
2249 2249
 
2250 2250
 		// Handle Question Grade
2251
-		if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) {
2252
-			$question_grade = $data[ 'question_grade' ];
2251
+		if (isset($data['question_grade']) && ('' != $data['question_grade'])) {
2252
+			$question_grade = $data['question_grade'];
2253 2253
 		} // End If Statement
2254 2254
 
2255 2255
 		// Handle Answer Feedback
2256 2256
 		$answer_feedback = '';
2257
-		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2257
+		if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) {
2258 2258
 
2259
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2259
+            $answer_feedback = $data['answer_feedback_boolean'];
2260 2260
 
2261
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2261
+		}elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) {
2262 2262
 
2263
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2263
+            $answer_feedback = $data['answer_feedback_multiple_choice'];
2264 2264
 
2265
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2265
+        }elseif (isset($data['answer_feedback'])) {
2266 2266
 
2267
-            $answer_feedback = $data[ 'answer_feedback' ];
2267
+            $answer_feedback = $data['answer_feedback'];
2268 2268
 
2269 2269
         } // End If Statement
2270 2270
 
2271 2271
 		$post_title = $question_text;
2272
-		$post_author = $data[ 'post_author' ];
2272
+		$post_author = $data['post_author'];
2273 2273
 		$post_status = 'publish';
2274 2274
 		$post_type = 'question';
2275 2275
 		// Handle the extended question text
2276
-		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2277
-			$post_content = $data[ 'question_description' ];
2276
+		if (isset($data['question_description']) && ('' != $data['question_description'])) {
2277
+			$post_content = $data['question_description'];
2278 2278
 		}
2279 2279
 		else {
2280 2280
 			$post_content = '';
2281 2281
 		}
2282 2282
 		// Question Query Arguments
2283
-		$post_type_args = array(	'post_content' => $post_content,
2283
+		$post_type_args = array('post_content' => $post_content,
2284 2284
   		    						'post_status' => $post_status,
2285 2285
   		    						'post_title' => $post_title,
2286 2286
   		    						'post_type' => $post_type
2287 2287
   		    						);
2288 2288
 
2289 2289
   		// Remove empty values and reindex the array
2290
-  		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
2291
-  			$question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) );
2290
+  		if (is_array($question_right_answers) && 0 < count($question_right_answers)) {
2291
+  			$question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen'));
2292 2292
   			$question_right_answers = array();
2293 2293
 
2294
-  			foreach( $question_right_answers_array as $answer ) {
2295
-  				if( ! in_array( $answer, $question_right_answers ) ) {
2294
+  			foreach ($question_right_answers_array as $answer) {
2295
+  				if ( ! in_array($answer, $question_right_answers)) {
2296 2296
   					$question_right_answers[] = $answer;
2297 2297
   				}
2298 2298
   			}
2299
-  			if ( 0 < count($question_right_answers) ) {
2299
+  			if (0 < count($question_right_answers)) {
2300 2300
   				$question_right_answer = $question_right_answers;
2301 2301
   			}
2302 2302
   		} // End If Statement
2303
-  		$right_answer_count = count( $question_right_answer );
2303
+  		$right_answer_count = count($question_right_answer);
2304 2304
 
2305 2305
 		// Remove empty values and reindex the array
2306
-  		if ( is_array( $question_wrong_answers ) ) {
2307
-  			$question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) );
2306
+  		if (is_array($question_wrong_answers)) {
2307
+  			$question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen'));
2308 2308
   			$question_wrong_answers = array();
2309 2309
   		} // End If Statement
2310 2310
 
2311
-  		foreach( $question_wrong_answers_array as $answer ) {
2312
-  			if( ! in_array( $answer, $question_wrong_answers ) ) {
2311
+  		foreach ($question_wrong_answers_array as $answer) {
2312
+  			if ( ! in_array($answer, $question_wrong_answers)) {
2313 2313
   				$question_wrong_answers[] = $answer;
2314 2314
   			}
2315 2315
   		}
2316 2316
 
2317
-  		$wrong_answer_count = count( $question_wrong_answers );
2317
+  		$wrong_answer_count = count($question_wrong_answers);
2318 2318
 
2319 2319
   		// Only save if there is a valid title
2320
-  		if ( $post_title != '' ) {
2320
+  		if ($post_title != '') {
2321 2321
 
2322 2322
   			// Get Quiz ID for the question
2323 2323
   		    $quiz_id = $data['quiz_id'];
@@ -2327,86 +2327,86 @@  discard block
 block discarded – undo
2327 2327
 
2328 2328
   		    // Get answer order
2329 2329
   		    $answer_order = '';
2330
-  		    if( isset( $data['answer_order'] ) ) {
2330
+  		    if (isset($data['answer_order'])) {
2331 2331
 				$answer_order = $data['answer_order'];
2332 2332
 			}
2333 2333
 
2334 2334
 			// Get random order selection
2335 2335
 			$random_order = 'no';
2336
-			if( isset( $data['random_order'] ) ) {
2336
+			if (isset($data['random_order'])) {
2337 2337
 				$random_order = $data['random_order'];
2338 2338
 			}
2339 2339
 
2340 2340
   		    // Insert or Update the question
2341
-  		    if ( 0 < $question_id ) {
2341
+  		    if (0 < $question_id) {
2342 2342
 
2343
-  		    	$post_type_args[ 'ID' ] = $question_id;
2344
-		    	$question_id = wp_update_post( $post_type_args );
2343
+  		    	$post_type_args['ID'] = $question_id;
2344
+		    	$question_id = wp_update_post($post_type_args);
2345 2345
 
2346 2346
 		    	// Update poast meta
2347
-		    	if( 'quiz' == $context ) {
2348
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2349
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2350
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2347
+		    	if ('quiz' == $context) {
2348
+		    		$quizzes = get_post_meta($question_id, '_quiz_id', false);
2349
+		    		if ( ! in_array($quiz_id, $quizzes)) {
2350
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2351 2351
 			    	}
2352 2352
 		    	}
2353 2353
 
2354
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2355
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2356
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2357
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2358
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2359
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2360
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2361
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2362
-
2363
-		    	if( 'quiz' != $context ) {
2364
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2354
+		    	update_post_meta($question_id, '_question_grade', $question_grade);
2355
+		    	update_post_meta($question_id, '_question_right_answer', $question_right_answer);
2356
+		    	update_post_meta($question_id, '_right_answer_count', $right_answer_count);
2357
+		    	update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2358
+		    	update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2359
+		    	update_post_meta($question_id, '_question_media', $question_media);
2360
+		    	update_post_meta($question_id, '_answer_order', $answer_order);
2361
+		    	update_post_meta($question_id, '_random_order', $random_order);
2362
+
2363
+		    	if ('quiz' != $context) {
2364
+		    		wp_set_post_terms($question_id, array($question_type), 'question-type', false);
2365 2365
 		    	}
2366 2366
 				// Don't store empty value, no point
2367
-				if ( !empty($answer_feedback) ) {
2368
-					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2367
+				if ( ! empty($answer_feedback)) {
2368
+					update_post_meta($question_id, '_answer_feedback', $answer_feedback);
2369 2369
 				}
2370 2370
 
2371 2371
 		    } else {
2372
-				$question_id = wp_insert_post( $post_type_args );
2373
-				$question_count = intval( $data['question_count'] );
2372
+				$question_id = wp_insert_post($post_type_args);
2373
+				$question_count = intval($data['question_count']);
2374 2374
 				++$question_count;
2375 2375
 
2376 2376
 				// Set post meta
2377
-				if( 'quiz' == $context ) {
2378
-					add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2379
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2380
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2377
+				if ('quiz' == $context) {
2378
+					add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2379
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2380
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
2381 2381
 				}
2382 2382
 
2383
-				if( isset( $question_grade ) ) {
2384
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2383
+				if (isset($question_grade)) {
2384
+		    		add_post_meta($question_id, '_question_grade', $question_grade);
2385 2385
 		    	}
2386
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2387
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2388
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2389
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2390
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2391
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2392
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2393
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2386
+		    	add_post_meta($question_id, '_question_right_answer', $question_right_answer);
2387
+		    	add_post_meta($question_id, '_right_answer_count', $right_answer_count);
2388
+		    	add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2389
+		    	add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2390
+		    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2391
+		    	add_post_meta($question_id, '_question_media', $question_media);
2392
+		    	add_post_meta($question_id, '_answer_order', $answer_order);
2393
+		    	add_post_meta($question_id, '_random_order', $random_order);
2394 2394
 				// Don't store empty value, no point
2395
-				if ( !empty($answer_feedback) ) {
2396
-					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2395
+				if ( ! empty($answer_feedback)) {
2396
+					add_post_meta($question_id, '_answer_feedback', $answer_feedback);
2397 2397
 				}
2398 2398
 
2399 2399
 		    	// Set the post terms for question-type
2400
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2400
+			    wp_set_post_terms($question_id, array($question_type), 'question-type');
2401 2401
 
2402
-			    if( $question_category ) {
2403
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2402
+			    if ($question_category) {
2403
+	    			wp_set_post_terms($question_id, array($question_category), 'question-category');
2404 2404
 	    		}
2405 2405
 
2406 2406
 		    } // End If Statement
2407 2407
 		} // End If Statement
2408 2408
   		// Check that the insert or update saved by testing the post id
2409
-  		if ( 0 < $question_id ) {
2409
+  		if (0 < $question_id) {
2410 2410
   			$return = $question_id;
2411 2411
   		} // End If Statement
2412 2412
   		return $return;
@@ -2420,20 +2420,20 @@  discard block
 block discarded – undo
2420 2420
 	 * @param array $data (default: array())
2421 2421
 	 * @return void
2422 2422
 	 */
2423
-	private function lesson_delete_question( $data = array() ) {
2423
+	private function lesson_delete_question($data = array()) {
2424 2424
 
2425 2425
 		// Get which question to delete
2426 2426
 		$question_id = 0;
2427
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2428
-			$question_id = absint( $data[ 'question_id' ] );
2427
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2428
+			$question_id = absint($data['question_id']);
2429 2429
 		} // End If Statement
2430 2430
 		// Delete the question
2431
-		if ( 0 < $question_id ) {
2432
-			$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2431
+		if (0 < $question_id) {
2432
+			$quizzes = get_post_meta($question_id, '_quiz_id', false);
2433 2433
 
2434
-			foreach( $quizzes as $quiz_id ) {
2435
-				if( $quiz_id == $data['quiz_id'] ) {
2436
-					delete_post_meta( $question_id, '_quiz_id', $quiz_id );
2434
+			foreach ($quizzes as $quiz_id) {
2435
+				if ($quiz_id == $data['quiz_id']) {
2436
+					delete_post_meta($question_id, '_quiz_id', $quiz_id);
2437 2437
 				}
2438 2438
 			}
2439 2439
 
@@ -2452,9 +2452,9 @@  discard block
 block discarded – undo
2452 2452
 	public function lesson_complexities() {
2453 2453
 
2454 2454
 		// V2 - make filter for this array
2455
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2456
-									'std' => __( 'Standard', 'woothemes-sensei' ),
2457
-									'hard' => __( 'Hard', 'woothemes-sensei' )
2455
+        $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'),
2456
+									'std' => __('Standard', 'woothemes-sensei'),
2457
+									'hard' => __('Hard', 'woothemes-sensei')
2458 2458
 									);
2459 2459
 
2460 2460
 		return $lesson_complexities;
@@ -2469,9 +2469,9 @@  discard block
 block discarded – undo
2469 2469
 	 * @param string $post_status (default: 'publish')
2470 2470
 	 * @return int
2471 2471
 	 */
2472
-	public function lesson_count( $post_status = 'publish', $course_id = false ) {
2472
+	public function lesson_count($post_status = 'publish', $course_id = false) {
2473 2473
 
2474
-		$post_args = array(	'post_type'         => 'lesson',
2474
+		$post_args = array('post_type'         => 'lesson',
2475 2475
 							'posts_per_page'    => -1,
2476 2476
 //							'orderby'           => 'menu_order date',
2477 2477
 //							'order'             => 'ASC',
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 							'suppress_filters'  => 0,
2480 2480
 							'fields'            => 'ids',
2481 2481
 							);
2482
-		if( $course_id ) {
2482
+		if ($course_id) {
2483 2483
 			$post_args['meta_query'][] = array(
2484 2484
 				'key' => '_lesson_course',
2485 2485
 				'value' => $course_id,
@@ -2496,10 +2496,10 @@  discard block
 block discarded – undo
2496 2496
 
2497 2497
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
2498 2498
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2499
-		$lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) );
2499
+		$lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args));
2500 2500
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2501 2501
 
2502
-		return count( $lessons_query->posts );
2502
+		return count($lessons_query->posts);
2503 2503
 	} // End lesson_count()
2504 2504
 
2505 2505
 
@@ -2512,11 +2512,11 @@  discard block
 block discarded – undo
2512 2512
 	 * @param string $fields (default: 'ids')
2513 2513
 	 * @return int $quiz_id
2514 2514
 	 */
2515
-	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2515
+	public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') {
2516 2516
 
2517 2517
 		$posts_array = array();
2518 2518
 
2519
-		$post_args = array(	'post_type' 		=> 'quiz',
2519
+		$post_args = array('post_type' 		=> 'quiz',
2520 2520
 							'posts_per_page' 		=> 1,
2521 2521
 							'orderby'         	=> 'title',
2522 2522
     						'order'           	=> 'DESC',
@@ -2525,7 +2525,7 @@  discard block
 block discarded – undo
2525 2525
 							'suppress_filters' 	=> 0,
2526 2526
 							'fields'            => $fields
2527 2527
 							);
2528
-		$posts_array = get_posts( $post_args );
2528
+		$posts_array = get_posts($post_args);
2529 2529
         $quiz_id = array_shift($posts_array);
2530 2530
 
2531 2531
 		return $quiz_id;
@@ -2548,37 +2548,37 @@  discard block
 block discarded – undo
2548 2548
      *
2549 2549
 	 * @return array $questions { $question type WP_Post }
2550 2550
 	 */
2551
-	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2551
+	public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') {
2552 2552
 
2553 2553
 		$quiz_id = (string) $quiz_id;
2554
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2554
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
2555 2555
 
2556 2556
         // setup the user id
2557
-        if( is_admin() ) {
2558
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2557
+        if (is_admin()) {
2558
+            $user_id = isset($_GET['user']) ? $_GET['user'] : '';
2559 2559
         } else {
2560 2560
             $user_id = get_current_user_id();
2561 2561
         }
2562 2562
 
2563 2563
         // get the users current status on the lesson
2564
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2564
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id);
2565 2565
 
2566 2566
 		// Set the default question order if it has not already been set for this quiz
2567
-		$this->set_default_question_order( $quiz_id );
2567
+		$this->set_default_question_order($quiz_id);
2568 2568
 
2569 2569
 		// If viewing quiz on the frontend then show questions in random order if set
2570
-		if ( ! is_admin() ) {
2571
-			$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
2572
-			if( $random_order && $random_order == 'yes' ) {
2570
+		if ( ! is_admin()) {
2571
+			$random_order = get_post_meta($quiz_id, '_random_question_order', true);
2572
+			if ($random_order && $random_order == 'yes') {
2573 2573
 				$orderby = 'rand';
2574 2574
 			}
2575 2575
 		}
2576 2576
 
2577 2577
 		// Get all questions and multiple questions
2578 2578
 		$question_query_args = array(
2579
-			'post_type' 		=> array( 'question', 'multiple_question' ),
2579
+			'post_type' 		=> array('question', 'multiple_question'),
2580 2580
 			'posts_per_page' 	=> -1,
2581
-			'meta_key'        	=> '_quiz_question_order' . $quiz_id,
2581
+			'meta_key'        	=> '_quiz_question_order'.$quiz_id,
2582 2582
 			'orderby'         	=> $orderby,
2583 2583
 			'order'           	=> $order,
2584 2584
 			'meta_query'		=> array(
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 		);
2593 2593
 
2594 2594
         //query the questions
2595
-		$questions_query = new WP_Query( $question_query_args );
2595
+		$questions_query = new WP_Query($question_query_args);
2596 2596
 
2597 2597
         // Set return array to initially include all items
2598 2598
         $questions = $questions_query->posts;
@@ -2602,20 +2602,20 @@  discard block
 block discarded – undo
2602 2602
 
2603 2603
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2604 2604
 		$selected_questions = false;
2605
-		if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) {
2605
+		if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) {
2606 2606
 
2607 2607
 			// Fetch the questions that the user was asked in their quiz if they have already completed it
2608
-			$questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false;
2609
-			if( !empty($questions_asked_string) ) {
2608
+			$questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false;
2609
+			if ( ! empty($questions_asked_string)) {
2610 2610
 
2611
-				$selected_questions = explode( ',', $questions_asked_string );
2611
+				$selected_questions = explode(',', $questions_asked_string);
2612 2612
 
2613 2613
 				// Fetch each question in the order in which they were asked
2614 2614
 				$questions = array();
2615
-				foreach( $selected_questions as $question_id ) {
2616
-					if( ! $question_id ) continue;
2617
-					$question = get_post( $question_id );
2618
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2615
+				foreach ($selected_questions as $question_id) {
2616
+					if ( ! $question_id) continue;
2617
+					$question = get_post($question_id);
2618
+					if ( ! isset($question) || ! isset($question->ID)) continue;
2619 2619
 					$questions[] = $question;
2620 2620
 				}
2621 2621
 
@@ -2627,24 +2627,24 @@  discard block
 block discarded – undo
2627 2627
 				$existing_questions = array();
2628 2628
 
2629 2629
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2630
-				foreach( $questions_array as $question ) {
2631
-					if( 'question' != $question->post_type ) continue;
2630
+				foreach ($questions_array as $question) {
2631
+					if ('question' != $question->post_type) continue;
2632 2632
 					$existing_questions[] = $question->ID;
2633 2633
 				}
2634 2634
 
2635 2635
 				// Include only single questions in the return array
2636 2636
 				$questions_loop = $questions_array;
2637 2637
 				$questions_array = array();
2638
-				foreach( $questions_loop as $k => $question ) {
2638
+				foreach ($questions_loop as $k => $question) {
2639 2639
 
2640 2640
 					// If this is a single question then include it
2641
-					if( 'question' == $question->post_type ) {
2641
+					if ('question' == $question->post_type) {
2642 2642
 						$questions_array[] = $question;
2643 2643
 					} else {
2644 2644
 
2645 2645
 						// If this is a multiple question then get the specified amount of questions from the specified category
2646
-						$question_cat = intval( get_post_meta( $question->ID, 'category', true ) );
2647
-						$question_number = intval( get_post_meta( $question->ID, 'number', true ) );
2646
+						$question_cat = intval(get_post_meta($question->ID, 'category', true));
2647
+						$question_number = intval(get_post_meta($question->ID, 'number', true));
2648 2648
 
2649 2649
 						$qargs = array(
2650 2650
 							'post_type' 		=> 'question',
@@ -2661,14 +2661,14 @@  discard block
 block discarded – undo
2661 2661
 							'suppress_filters' 	=> 0,
2662 2662
 							'post__not_in'		=> $existing_questions,
2663 2663
 						);
2664
-						$cat_questions = get_posts( $qargs );
2664
+						$cat_questions = get_posts($qargs);
2665 2665
 
2666 2666
 						// Merge results into return array
2667
-						$questions_array = array_merge( $questions_array, $cat_questions );
2667
+						$questions_array = array_merge($questions_array, $cat_questions);
2668 2668
 
2669 2669
 						// Add selected questions to existing questions array to prevent duplicates from being added
2670
-						foreach( $questions_array as $cat_question ) {
2671
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2670
+						foreach ($questions_array as $cat_question) {
2671
+							if (in_array($cat_question->ID, $existing_questions)) continue;
2672 2672
 							$existing_questions[] = $cat_question->ID;
2673 2673
 						}
2674 2674
 					}
@@ -2680,29 +2680,29 @@  discard block
 block discarded – undo
2680 2680
 		}
2681 2681
 
2682 2682
 		// If user has not already taken the quiz and a limited number of questions are to be shown, then show a random selection of the specified amount of questions
2683
-		if( ! $selected_questions ) {
2683
+		if ( ! $selected_questions) {
2684 2684
 
2685 2685
 			// Only limit questions like this on the frontend
2686
-			if( ! is_admin() ) {
2686
+			if ( ! is_admin()) {
2687 2687
 
2688 2688
 				// Get number of questions to show
2689
-				$show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) );
2690
-				if( $show_questions ) {
2689
+				$show_questions = intval(get_post_meta($quiz_id, '_show_questions', true));
2690
+				if ($show_questions) {
2691 2691
 
2692 2692
 					// Get random set of array keys from selected questions array
2693
-					$selected_questions = array_rand( $questions_array, $show_questions );
2693
+					$selected_questions = array_rand($questions_array, $show_questions);
2694 2694
 
2695 2695
 					// Loop through all questions and pick the the ones to be shown based on the random key selection
2696 2696
 					$questions = array();
2697
-					foreach( $questions_array as $k => $question ) {
2697
+					foreach ($questions_array as $k => $question) {
2698 2698
 
2699 2699
 						// Random keys will always be an array, unless only one question is to be shown
2700
-						if( is_array( $selected_questions ) ) {
2701
-							if( in_array( $k, $selected_questions ) ) {
2700
+						if (is_array($selected_questions)) {
2701
+							if (in_array($k, $selected_questions)) {
2702 2702
 								$questions[] = $question;
2703 2703
 							}
2704
-						} elseif( 1 == $show_questions ) {
2705
-							if ( $selected_questions == $k ) {
2704
+						} elseif (1 == $show_questions) {
2705
+							if ($selected_questions == $k) {
2706 2706
 								$questions[] = $question;
2707 2707
 							}
2708 2708
 						}
@@ -2713,12 +2713,12 @@  discard block
 block discarded – undo
2713 2713
 
2714 2714
         // Save the questions that will be asked for the current user
2715 2715
         // this happens only once per user/quiz, unless the user resets the quiz
2716
-        if( ! is_admin() ){
2716
+        if ( ! is_admin()) {
2717 2717
 
2718
-            if( $user_lesson_status ) {
2718
+            if ($user_lesson_status) {
2719 2719
 
2720 2720
                 $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2721
-                if ( empty($questions_asked) && $user_lesson_status) {
2721
+                if (empty($questions_asked) && $user_lesson_status) {
2722 2722
 
2723 2723
                     $questions_asked = array();
2724 2724
                     foreach ($questions as $question) {
@@ -2741,7 +2741,7 @@  discard block
 block discarded – undo
2741 2741
          * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2742 2742
          * @since 1.8.0
2743 2743
          */
2744
-		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2744
+		return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id);
2745 2745
 
2746 2746
 	} // End lesson_quiz_questions()
2747 2747
 
@@ -2749,13 +2749,13 @@  discard block
 block discarded – undo
2749 2749
 	 * Set the default quiz order
2750 2750
 	 * @param integer $quiz_id ID of quiz
2751 2751
 	 */
2752
-	public function set_default_question_order( $quiz_id = 0 ) {
2752
+	public function set_default_question_order($quiz_id = 0) {
2753 2753
 
2754
-		if( $quiz_id ) {
2754
+		if ($quiz_id) {
2755 2755
 
2756
-			$question_order = get_post_meta( $quiz_id, '_question_order', true );
2756
+			$question_order = get_post_meta($quiz_id, '_question_order', true);
2757 2757
 
2758
-			if( ! $question_order ) {
2758
+			if ( ! $question_order) {
2759 2759
 
2760 2760
 				$args = array(
2761 2761
 					'post_type' 		=> 'question',
@@ -2771,11 +2771,11 @@  discard block
 block discarded – undo
2771 2771
 					'post_status'		=> 'any',
2772 2772
 					'suppress_filters' 	=> 0
2773 2773
 				);
2774
-				$questions = get_posts( $args );
2774
+				$questions = get_posts($args);
2775 2775
 
2776 2776
 				$o = 1;
2777
-				foreach( $questions as $question ) {
2778
-					add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true );
2777
+				foreach ($questions as $question) {
2778
+					add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true);
2779 2779
 					$o++;
2780 2780
 				}
2781 2781
 			}
@@ -2794,36 +2794,36 @@  discard block
 block discarded – undo
2794 2794
 	 * @param string $height (default: '100')
2795 2795
 	 * @return string
2796 2796
 	 */
2797
-	public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) {
2797
+	public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) {
2798 2798
 
2799 2799
 		$html = '';
2800 2800
 
2801 2801
 		// Get Width and Height settings
2802
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
2802
+		if (($width == '100') && ($height == '100')) {
2803 2803
 
2804
-			if ( is_singular( 'lesson' ) ) {
2804
+			if (is_singular('lesson')) {
2805 2805
 
2806
-				if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) {
2806
+				if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) {
2807 2807
 
2808 2808
 					return '';
2809 2809
 
2810 2810
 				} // End If Statement
2811 2811
 
2812 2812
 				$image_thumb_size = 'lesson_single_image';
2813
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2813
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2814 2814
 				$width = $dimensions['width'];
2815 2815
 				$height = $dimensions['height'];
2816 2816
 				$crop = $dimensions['crop'];
2817 2817
 
2818 2818
 			} else {
2819 2819
 
2820
-				if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) {
2820
+				if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) {
2821 2821
 
2822 2822
 					return '';
2823 2823
 				} // End If Statement
2824 2824
 
2825 2825
 				$image_thumb_size = 'lesson_archive_image';
2826
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2826
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2827 2827
 				$width = $dimensions['width'];
2828 2828
 				$height = $dimensions['height'];
2829 2829
 				$crop = $dimensions['crop'];
@@ -2834,23 +2834,23 @@  discard block
 block discarded – undo
2834 2834
 
2835 2835
 		$img_url = '';
2836 2836
 
2837
-		if ( has_post_thumbnail( $lesson_id ) ) {
2837
+		if (has_post_thumbnail($lesson_id)) {
2838 2838
 
2839 2839
    			// Get Featured Image
2840
-   			$img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
2840
+   			$img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
2841 2841
 
2842 2842
  		} else {
2843 2843
 
2844 2844
  			// Display Image Placeholder if none
2845
-			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2845
+			if (Sensei()->settings->settings['placeholder_images_enable']) {
2846 2846
 
2847
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2847
+                $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
2848 2848
 
2849 2849
 			} // End If Statement
2850 2850
 
2851 2851
 		} // End If Statement
2852 2852
 
2853
-		$html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>';
2853
+		$html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>';
2854 2854
 
2855 2855
 		return $html;
2856 2856
 
@@ -2863,17 +2863,17 @@  discard block
 block discarded – undo
2863 2863
      * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2864 2864
 	 * @return string
2865 2865
 	 */
2866
-	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2866
+	public static function lesson_excerpt($lesson = null, $add_p_tags = true) {
2867 2867
 		$html = '';
2868
-		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2868
+		if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) {
2869 2869
 
2870
-            $excerpt =  $lesson->post_excerpt;
2870
+            $excerpt = $lesson->post_excerpt;
2871 2871
 
2872 2872
             // if $add_p_tags true wrap with <p> else return the excerpt as is
2873
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2873
+            $html = $add_p_tags ? wpautop($excerpt) : $excerpt;
2874 2874
 
2875 2875
 		}
2876
-		return apply_filters( 'sensei_lesson_excerpt', $html );
2876
+		return apply_filters('sensei_lesson_excerpt', $html);
2877 2877
 
2878 2878
 	} // End lesson_excerpt()
2879 2879
 
@@ -2886,20 +2886,20 @@  discard block
 block discarded – undo
2886 2886
      * @param int $lesson_id
2887 2887
      * @return int|bool $course_id or bool when nothing is found.
2888 2888
      */
2889
-     public function get_course_id( $lesson_id ){
2889
+     public function get_course_id($lesson_id) {
2890 2890
 
2891
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2892
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2891
+         if ( ! isset($lesson_id) || empty($lesson_id)
2892
+         ||  'lesson' != get_post_type($lesson_id)) {
2893 2893
              return false;
2894 2894
          }
2895 2895
 
2896
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2896
+         $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
2897 2897
 
2898 2898
          // make sure the course id is valid
2899
-         if( empty( $lesson_course_id )
2900
-             || is_array( $lesson_course_id )
2901
-             || intval( $lesson_course_id ) < 1
2902
-             || 'course' != get_post_type( $lesson_course_id ) ){
2899
+         if (empty($lesson_course_id)
2900
+             || is_array($lesson_course_id)
2901
+             || intval($lesson_course_id) < 1
2902
+             || 'course' != get_post_type($lesson_course_id)) {
2903 2903
 
2904 2904
              return false;
2905 2905
 
@@ -2926,10 +2926,10 @@  discard block
 block discarded – undo
2926 2926
      * @param string $post_type
2927 2927
      * @return void
2928 2928
      */
2929
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2929
+    public function all_lessons_edit_fields($column_name, $post_type) {
2930 2930
 
2931 2931
         // only show these options ont he lesson post type edit screen
2932
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2932
+        if ('lesson' != $post_type || 'lesson-course' != $column_name) {
2933 2933
             return;
2934 2934
         }
2935 2935
 
@@ -2937,41 +2937,41 @@  discard block
 block discarded – undo
2937 2937
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2938 2938
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2939 2939
                     <?php
2940
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2940
+                    echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>';
2941 2941
                     // create a nonce field to be  used as a security measure when saving the data
2942
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2943
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2942
+                    wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce');
2943
+                    wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce');
2944 2944
 
2945 2945
                     // unchanged option - we need this in because
2946 2946
                     // the default option in bulk edit should not be empty. If it is
2947 2947
                     // the user will erase data they didn't want to touch.
2948
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2948
+                    $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --';
2949 2949
 
2950 2950
                     //
2951 2951
                     //course selection
2952 2952
                     //
2953
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2953
+                    $courses = WooThemes_Sensei_Course::get_all_courses();
2954 2954
                     $course_options = array();
2955
-                    if ( count( $courses ) > 0 ) {
2956
-                        foreach ($courses as $course ){
2957
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2955
+                    if (count($courses) > 0) {
2956
+                        foreach ($courses as $course) {
2957
+                            $course_options[$course->ID] = get_the_title($course->ID);
2958 2958
                         }
2959 2959
                     }
2960 2960
                     //pre-append the no change option
2961
-                    $course_options['-1']=  $no_change_text;
2962
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2963
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2964
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2961
+                    $course_options['-1'] = $no_change_text;
2962
+                    $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' ');
2963
+                    $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes);
2964
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field);
2965 2965
 
2966 2966
                     //
2967 2967
                     // lesson complexity selection
2968 2968
                     //
2969
-                    $lesson_complexities =  $this->lesson_complexities();
2969
+                    $lesson_complexities = $this->lesson_complexities();
2970 2970
                     //pre-append the no change option
2971
-                    $lesson_complexities['-1']=  $no_change_text;
2972
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2973
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2974
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2971
+                    $lesson_complexities['-1'] = $no_change_text;
2972
+                    $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' ');
2973
+                    $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes);
2974
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed);
2975 2975
 
2976 2976
                     ?>
2977 2977
 
@@ -2984,34 +2984,34 @@  discard block
 block discarded – undo
2984 2984
                     //
2985 2985
                     $pass_required_options = array(
2986 2986
                         '-1' => $no_change_text,
2987
-                         '0' => __('No','woothemes'),
2988
-                         '1' => __('Yes','woothemes'),
2987
+                         '0' => __('No', 'woothemes'),
2988
+                         '1' => __('Yes', 'woothemes'),
2989 2989
                     );
2990 2990
 
2991
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
2991
+                    $pass_required_select_attributes = array('name'=> 'pass_required',
2992 2992
                                                                 'id'=> 'sensei-edit-lesson-pass-required',
2993
-                                                                'class'=>' '   );
2994
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
2995
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
2993
+                                                                'class'=>' ');
2994
+                    $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false);
2995
+                    echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field);
2996 2996
 
2997 2997
                     //
2998 2998
                     // Quiz pass percentage
2999 2999
                     //
3000 3000
                     $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3001
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3001
+                    echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field);
3002 3002
 
3003 3003
                     //
3004 3004
                     // Enable quiz reset button
3005 3005
                     //
3006 3006
                     $quiz_reset_select__options = array(
3007 3007
                         '-1' => $no_change_text,
3008
-                        '0' => __('No','woothemes'),
3009
-                        '1' => __('Yes','woothemes'),
3008
+                        '0' => __('No', 'woothemes'),
3009
+                        '1' => __('Yes', 'woothemes'),
3010 3010
                     );
3011 3011
                     $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3012
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3013
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3014
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3012
+                    $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ');
3013
+                    $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false);
3014
+                    echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field);
3015 3015
 
3016 3016
                     ?>
3017 3017
             </div>
@@ -3030,17 +3030,17 @@  discard block
 block discarded – undo
3030 3030
      * @param string $field type markup for the field that must be wrapped.
3031 3031
      * @return string $field_html
3032 3032
      */
3033
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3033
+    public function generate_all_lessons_edit_field($title, $field) {
3034 3034
 
3035 3035
         $html = '';
3036 3036
         $html = '<div class="inline-edit-group" >';
3037
-        $html .=  '<span class="title">'. $title .'</span> ';
3037
+        $html .= '<span class="title">'.$title.'</span> ';
3038 3038
         $html .= '<span class="input-text-wrap">';
3039 3039
         $html .= $field;
3040 3040
         $html .= '</span>';
3041 3041
         $html .= '</label></div>';
3042 3042
 
3043
-        return $html ;
3043
+        return $html;
3044 3044
 
3045 3045
     }//end generate_all_lessons_edit_field
3046 3046
 
@@ -3054,48 +3054,48 @@  discard block
 block discarded – undo
3054 3054
     function save_all_lessons_edit_fields() {
3055 3055
 
3056 3056
         // verify all the data before attempting to save
3057
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3058
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3057
+        if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security')
3058
+            ||  empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) {
3059 3059
             die();
3060 3060
         }
3061 3061
 
3062 3062
         // get our variables
3063
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3064
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3065
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3066
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3067
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3063
+        $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']);
3064
+        $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']);
3065
+        $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']);
3066
+        $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']);
3067
+        $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']);
3068 3068
         // store the values for all selected posts
3069
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3069
+        foreach ($_POST['post_ids'] as $lesson_id) {
3070 3070
 
3071 3071
             // get the quiz id needed for the quiz meta
3072
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3072
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
3073 3073
 
3074 3074
             // do not save the items if the value is -1 as this
3075 3075
             // means it was not changed
3076 3076
 
3077 3077
             // update lesson course
3078
-            if( -1 != $new_course ){
3079
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3078
+            if ( -1 != $new_course ) {
3079
+                update_post_meta($lesson_id, '_lesson_course', $new_course);
3080 3080
             }
3081 3081
             // update lesson complexity
3082
-            if( -1 != $new_complexity ){
3083
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3082
+            if ( -1 != $new_complexity ) {
3083
+                update_post_meta($lesson_id, '_lesson_complexity', $new_complexity);
3084 3084
             }
3085 3085
 
3086 3086
             // Quiz Related settings
3087
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3087
+            if (isset($quiz_id) && 0 < intval($quiz_id)) {
3088 3088
 
3089 3089
                 // update pass required
3090 3090
                 if (-1 != $new_pass_required) {
3091 3091
 
3092
-                    $checked = $new_pass_required  ? 'on' : '';
3092
+                    $checked = $new_pass_required ? 'on' : '';
3093 3093
                     update_post_meta($quiz_id, '_pass_required', $checked);
3094
-                    unset( $checked );
3094
+                    unset($checked);
3095 3095
                 }
3096 3096
 
3097 3097
                 // update pass percentage
3098
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3098
+                if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) {
3099 3099
 
3100 3100
                         update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3101 3101
 
@@ -3106,9 +3106,9 @@  discard block
 block discarded – undo
3106 3106
                 //
3107 3107
                 if (-1 != $new_enable_quiz_reset ) {
3108 3108
 
3109
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3109
+                    $checked = $new_enable_quiz_reset ? 'on' : '';
3110 3110
                     update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3111
-                    unset( $checked );
3111
+                    unset($checked);
3112 3112
 
3113 3113
                 }
3114 3114
 
@@ -3132,31 +3132,31 @@  discard block
 block discarded – undo
3132 3132
      * @since 1.8.0
3133 3133
      * @return void
3134 3134
      */
3135
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3135
+    public function set_quick_edit_admin_defaults($column_name, $post_id) {
3136 3136
 
3137
-        if( 'lesson-course' != $column_name ){
3137
+        if ('lesson-course' != $column_name) {
3138 3138
             return;
3139 3139
         }
3140 3140
         // load the script
3141
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3142
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3141
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3142
+        wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
3143 3143
 
3144 3144
         // setup the values for all meta fields
3145 3145
         $data = array();
3146
-        foreach( $this->meta_fields as $field ){
3146
+        foreach ($this->meta_fields as $field) {
3147 3147
 
3148
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3148
+            $data[$field] = get_post_meta($post_id, '_'.$field, true);
3149 3149
 
3150 3150
         }
3151 3151
         // add quiz meta fields
3152
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3153
-        foreach( Sensei()->quiz->meta_fields as $field ){
3152
+        $quiz_id = Sensei()->lesson->lesson_quizzes($post_id);
3153
+        foreach (Sensei()->quiz->meta_fields as $field) {
3154 3154
 
3155
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3155
+            $data[$field] = get_post_meta($quiz_id, '_'.$field, true);
3156 3156
 
3157 3157
         }
3158 3158
 
3159
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3159
+        wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data);
3160 3160
 
3161 3161
     }// end quick edit admin defaults
3162 3162
 
@@ -3169,19 +3169,19 @@  discard block
 block discarded – undo
3169 3169
      * @param array $classes
3170 3170
      * @return array $classes
3171 3171
      */
3172
-    public static function single_course_lessons_classes( $classes ){
3172
+    public static function single_course_lessons_classes($classes) {
3173 3173
 
3174
-        if(  is_singular('course') ){
3174
+        if (is_singular('course')) {
3175 3175
 
3176 3176
             global $post;
3177 3177
             $course_id = $post->ID;
3178 3178
 
3179
-            $lesson_classes = array( 'course', 'post' );
3180
-            if ( is_user_logged_in() ) {
3179
+            $lesson_classes = array('course', 'post');
3180
+            if (is_user_logged_in()) {
3181 3181
 
3182 3182
                 // Check if Lesson is complete
3183
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3184
-                if ( $single_lesson_complete ) {
3183
+                $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
3184
+                if ($single_lesson_complete) {
3185 3185
 
3186 3186
                     $lesson_classes[] = 'lesson-completed';
3187 3187
 
@@ -3189,14 +3189,14 @@  discard block
 block discarded – undo
3189 3189
 
3190 3190
             } // End If Statement
3191 3191
 
3192
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3193
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3192
+            $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3193
+            if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) {
3194 3194
 
3195 3195
                 $lesson_classes[] = 'lesson-preview';
3196 3196
 
3197 3197
             }
3198 3198
 
3199
-            $classes = array_merge( $classes, $lesson_classes  );
3199
+            $classes = array_merge($classes, $lesson_classes);
3200 3200
 
3201 3201
         }
3202 3202
 
@@ -3210,56 +3210,56 @@  discard block
 block discarded – undo
3210 3210
      * @since 1.9.0
3211 3211
      * @param $lesson_id
3212 3212
      */
3213
-    public static function the_lesson_meta( $lesson_id ){
3213
+    public static function the_lesson_meta($lesson_id) {
3214 3214
 
3215 3215
         global $wp_query;
3216 3216
         $loop_lesson_number = $wp_query->current_post + 1;
3217 3217
 
3218
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3218
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
3219 3219
         $single_lesson_complete = false;
3220
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3220
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3221 3221
 
3222 3222
         // Get Lesson data
3223 3223
         $complexity_array = Sensei()->lesson->lesson_complexities();
3224 3224
 
3225
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3226
-        if ( '' != $lesson_complexity ) {
3225
+        $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true);
3226
+        if ('' != $lesson_complexity) {
3227 3227
 
3228 3228
             $lesson_complexity = $complexity_array[$lesson_complexity];
3229 3229
 
3230 3230
         }
3231
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3232
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3231
+        $user_info = get_userdata(absint(get_post()->post_author));
3232
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3233 3233
         $preview_label = '';
3234
-        if ( $is_preview && !$is_user_taking_course ) {
3234
+        if ($is_preview && ! $is_user_taking_course) {
3235 3235
 
3236
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3237
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3236
+            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id);
3237
+            $preview_label = '<span class="preview-heading">'.$preview_label.'</span>';
3238 3238
 
3239 3239
         }
3240 3240
 
3241 3241
 
3242
-        $count_markup= '';
3242
+        $count_markup = '';
3243 3243
         /**
3244 3244
          * Filter for if you want the $lesson_count to show next to the lesson.
3245 3245
          *
3246 3246
          * @since 1.0
3247 3247
          * @param bool default false.
3248 3248
          */
3249
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3249
+        if (apply_filters('sensei_show_lesson_numbers', false)) {
3250 3250
 
3251
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3251
+            $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>';
3252 3252
 
3253 3253
         }
3254 3254
 
3255
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3255
+        $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id));
3256 3256
 
3257 3257
         ?>
3258 3258
         <header>
3259 3259
             <h2>
3260
-                <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
3261
-                   title="<?php esc_attr_e( $heading_link_title ) ?>" >
3262
-                    <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?>
3260
+                <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>"
3261
+                   title="<?php esc_attr_e($heading_link_title) ?>" >
3262
+                    <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?>
3263 3263
                 </a>
3264 3264
             </h2>
3265 3265
 
@@ -3268,33 +3268,33 @@  discard block
 block discarded – undo
3268 3268
                 <?php
3269 3269
 
3270 3270
                 $meta_html = '';
3271
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3271
+                $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id());
3272 3272
 
3273
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3274
-                if ( '' != $lesson_length ) {
3273
+                $lesson_length = get_post_meta($lesson_id, '_lesson_length', true);
3274
+                if ('' != $lesson_length) {
3275 3275
 
3276
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3276
+                    $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>';
3277 3277
 
3278 3278
                 }
3279 3279
 
3280
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3280
+                if (Sensei()->settings->get('lesson_author')) {
3281 3281
 
3282
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3282
+                    $meta_html .= '<span class="lesson-author">'.__('Author: ', 'woothemes-sensei').'<a href="'.get_author_posts_url(absint(get_post()->post_author)).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
3283 3283
 
3284 3284
                 } // End If Statement
3285
-                if ( '' != $lesson_complexity ) {
3285
+                if ('' != $lesson_complexity) {
3286 3286
 
3287
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3287
+                    $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>';
3288 3288
 
3289 3289
                 }
3290 3290
 
3291
-                if ( $single_lesson_complete ) {
3291
+                if ($single_lesson_complete) {
3292 3292
 
3293
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3293
+                    $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>';
3294 3294
 
3295
-                } elseif ( $user_lesson_status ) {
3295
+                } elseif ($user_lesson_status) {
3296 3296
 
3297
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3297
+                    $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
3298 3298
 
3299 3299
                 } // End If Statement
3300 3300
 
@@ -3317,19 +3317,19 @@  discard block
 block discarded – undo
3317 3317
      *
3318 3318
      * @param $lesson_id
3319 3319
      */
3320
-    public static function the_lesson_thumbnail( $lesson_id ){
3320
+    public static function the_lesson_thumbnail($lesson_id) {
3321 3321
 
3322
-        if( empty( $lesson_id ) ){
3322
+        if (empty($lesson_id)) {
3323 3323
 
3324 3324
             $lesson_id = get_the_ID();
3325 3325
 
3326 3326
         }
3327 3327
 
3328
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3328
+        if ('lesson' != get_post_type($lesson_id)) {
3329 3329
             return;
3330 3330
         }
3331 3331
 
3332
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3332
+        echo Sensei()->lesson->lesson_image($lesson_id);
3333 3333
     }
3334 3334
 
3335 3335
 
@@ -3340,14 +3340,14 @@  discard block
 block discarded – undo
3340 3340
      * @param string $excerpt
3341 3341
      * @return string $excerpt
3342 3342
      */
3343
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3343
+    public static function alter_the_lesson_excerpt($excerpt) {
3344 3344
 
3345
-        if ('lesson' == get_post_type(get_the_ID())){
3345
+        if ('lesson' == get_post_type(get_the_ID())) {
3346 3346
 
3347 3347
             // remove this hooks to avoid an infinite loop.
3348
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3348
+            remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt'));
3349 3349
 
3350
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3350
+            return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID()));
3351 3351
         }
3352 3352
 
3353 3353
         return $excerpt;
@@ -3362,20 +3362,20 @@  discard block
 block discarded – undo
3362 3362
      * @param $current_lesson_id
3363 3363
      * @return mixed | bool | int $prerequisite_lesson_id or false
3364 3364
      */
3365
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3365
+    public static function get_lesson_prerequisite_id($current_lesson_id) {
3366 3366
 
3367
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3367
+        $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true);
3368 3368
 
3369 3369
         // set ti to false if not a valid prerequisite lesson id
3370
-        if(  empty( $prerequisite_lesson_id )
3371
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3372
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3370
+        if (empty($prerequisite_lesson_id)
3371
+            || 'lesson' != get_post_type($prerequisite_lesson_id)
3372
+            || $prerequisite_lesson_id == $current_lesson_id) {
3373 3373
 
3374 3374
             $prerequisite_lesson_id = false;
3375 3375
 
3376 3376
         }
3377 3377
 
3378
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3378
+        return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id);
3379 3379
 
3380 3380
     }
3381 3381
 
@@ -3390,27 +3390,27 @@  discard block
 block discarded – undo
3390 3390
      * @param $user_id
3391 3391
      * @return bool
3392 3392
      */
3393
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3393
+    public  static function is_prerequisite_complete($lesson_id, $user_id) {
3394 3394
 
3395
-        if( empty( $lesson_id ) || empty( $user_id )
3396
-        || 'lesson' != get_post_type( $lesson_id )
3397
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3395
+        if (empty($lesson_id) || empty($user_id)
3396
+        || 'lesson' != get_post_type($lesson_id)
3397
+        ||  ! is_a(get_user_by('id', $user_id), 'WP_User')) {
3398 3398
 
3399 3399
             return false;
3400 3400
 
3401 3401
         }
3402 3402
 
3403
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3403
+        $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id);
3404 3404
 
3405 3405
         // not a valid pre-requisite so pre-requisite is completed
3406
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3407
-            || ! is_numeric( $pre_requisite_id ) ){
3406
+        if ('lesson' != get_post_type($pre_requisite_id)
3407
+            || ! is_numeric($pre_requisite_id)) {
3408 3408
 
3409 3409
             return true;
3410 3410
 
3411 3411
         }
3412 3412
 
3413
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3413
+        return  Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id);
3414 3414
 
3415 3415
     }// end is_prerequisite_complete
3416 3416
 
@@ -3419,20 +3419,20 @@  discard block
 block discarded – undo
3419 3419
      *
3420 3420
      * @since 1.9.0
3421 3421
      */
3422
-    public  static function user_not_taking_course_message(){
3422
+    public  static function user_not_taking_course_message() {
3423 3423
 
3424 3424
         $lesson_id = get_the_ID();
3425 3425
 
3426
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3426
+        if ('lesson' != get_post_type($lesson_id)) {
3427 3427
             return;
3428 3428
         }
3429 3429
 
3430
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3431
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3432
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3433
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3430
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3431
+        $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id());
3432
+        $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
3433
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
3434 3434
 
3435
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3435
+        if ($pre_requisite_complete && $is_preview && ! $user_taking_course) {
3436 3436
             ?>
3437 3437
 
3438 3438
             <div class="sensei-message alert">
@@ -3452,11 +3452,11 @@  discard block
 block discarded – undo
3452 3452
      *
3453 3453
      * @since 1.9.0
3454 3454
      */
3455
-    public static function course_signup_link( ){
3455
+    public static function course_signup_link( ) {
3456 3456
 
3457
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3457
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3458 3458
 
3459
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3459
+        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
3460 3460
 
3461 3461
             return;
3462 3462
 
@@ -3466,24 +3466,24 @@  discard block
 block discarded – undo
3466 3466
         <section class="course-signup lesson-meta">
3467 3467
 
3468 3468
             <?php
3469
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3469
+            $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
3470 3470
 
3471
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3471
+            if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
3472 3472
 
3473 3473
                 global $current_user;
3474
-                if( is_user_logged_in() ) {
3474
+                if (is_user_logged_in()) {
3475 3475
                     wp_get_current_user();
3476 3476
 
3477
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3477
+                    $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
3478 3478
 
3479
-                    if( $course_purchased ) {
3479
+                    if ($course_purchased) {
3480 3480
 
3481
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3482
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3481
+                        $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
3482
+                        $course_link = '<a href="'.esc_url(get_permalink($prereq_course_id)).'" title="'.esc_attr(get_the_title($prereq_course_id)).'">'.__('the previous course', 'woothemes-sensei').'</a>';
3483 3483
                         ?>
3484 3484
                             <div class="sensei-message info">
3485 3485
 
3486
-                                <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
3486
+                                <?php  echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); ?>
3487 3487
 
3488 3488
                             </div>
3489 3489
 
@@ -3492,12 +3492,12 @@  discard block
 block discarded – undo
3492 3492
                         <div class="sensei-message info">
3493 3493
 
3494 3494
                             <?php
3495
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3496
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3497
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3495
+                            $course_link = '<a href="'.esc_url(get_permalink($course_id))
3496
+                                            . '"title="'.__('Sign Up', 'woothemes-sensei')
3497
+                                            . '">'.__('course', 'woothemes-sensei')
3498 3498
                                             . '</a>';
3499 3499
 
3500
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3500
+                            echo  sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3501 3501
 
3502 3502
                             ?>
3503 3503
 
@@ -3506,23 +3506,23 @@  discard block
 block discarded – undo
3506 3506
 
3507 3507
                 <?php } else { ?>
3508 3508
 
3509
-                    <div class="sensei-message info"><?php echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">' . __( 'course', 'woothemes-sensei' ) . '</a>' ); ?></div>
3509
+                    <div class="sensei-message info"><?php echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">'.__('course', 'woothemes-sensei').'</a>'); ?></div>
3510 3510
 
3511 3511
                 <?php } ?>
3512 3512
 
3513 3513
             <?php } else { ?>
3514 3514
 
3515
-            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) ) : ?>
3515
+            <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id())) : ?>
3516 3516
 
3517 3517
                 <div class="sensei-message info">
3518 3518
                     <?php
3519
-                    $course_link =  '<a href="'
3520
-                                        . esc_url( get_permalink( $course_id ) )
3521
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3522
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3519
+                    $course_link = '<a href="'
3520
+                                        . esc_url(get_permalink($course_id))
3521
+                                        . '" title="'.__('Sign Up', 'woothemes-sensei')
3522
+                                        . '">'.__('course', 'woothemes-sensei')
3523 3523
                                     . '</a>';
3524 3524
 
3525
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3525
+                    echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3526 3526
                     ?>
3527 3527
                 </div>
3528 3528
 
@@ -3540,14 +3540,14 @@  discard block
 block discarded – undo
3540 3540
      *
3541 3541
      * @since 1.9.0
3542 3542
      */
3543
-    public  static function prerequisite_complete_message(){
3543
+    public  static function prerequisite_complete_message() {
3544 3544
 
3545
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3545
+        $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID());
3546 3546
         $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3547
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3547
+        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) {
3548 3548
 
3549
-            $prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3550
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3549
+            $prerequisite_lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite)).'" title="'.esc_attr(sprintf(__('You must first complete: %1$s', 'woothemes-sensei'), get_the_title($lesson_prerequisite))).'">'.get_the_title($lesson_prerequisite).'</a>';
3550
+            echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link);
3551 3551
 
3552 3552
         }
3553 3553
 
@@ -3559,7 +3559,7 @@  discard block
 block discarded – undo
3559 3559
      *
3560 3560
      * @deprecated since 1.9.0
3561 3561
      */
3562
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3562
+    public static function deprecate_sensei_lesson_archive_header_hook() {
3563 3563
 
3564 3564
         sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3565 3565
 
@@ -3575,9 +3575,9 @@  discard block
 block discarded – undo
3575 3575
 
3576 3576
         $before_html = '<header class="archive-header"><h1>';
3577 3577
         $after_html = '</h1></header>';
3578
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3578
+        $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html;
3579 3579
 
3580
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3580
+        echo apply_filters('sensei_lesson_archive_title', $html);
3581 3581
 
3582 3582
     } // sensei_course_archive_header()
3583 3583
 
@@ -3587,7 +3587,7 @@  discard block
 block discarded – undo
3587 3587
      * @global $post
3588 3588
      * @since 1.9.0
3589 3589
      */
3590
-    public static function the_title(){
3590
+    public static function the_title() {
3591 3591
 
3592 3592
         global $post;
3593 3593
 
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
                 /**
3601 3601
                  * Filter documented in class-sensei-messages.php the_title
3602 3602
                  */
3603
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3603
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
3604 3604
                 ?>
3605 3605
 
3606 3606
             </h1>
@@ -3618,16 +3618,16 @@  discard block
 block discarded – undo
3618 3618
      *
3619 3619
      * @param $post_id
3620 3620
      */
3621
-    public static function flush_rewrite_rules( $post_id ){
3621
+    public static function flush_rewrite_rules($post_id) {
3622 3622
 
3623
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3623
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3624 3624
 
3625 3625
             return;
3626 3626
 
3627 3627
         }
3628 3628
 
3629 3629
 
3630
-        if( 'lesson' == get_post_type( $post_id )  ){
3630
+        if ('lesson' == get_post_type($post_id)) {
3631 3631
 
3632 3632
             Sensei()->initiate_rewrite_rules_flush();
3633 3633
 
@@ -3644,21 +3644,21 @@  discard block
 block discarded – undo
3644 3644
      * @param int $lesson_id
3645 3645
      * @param int $user_id
3646 3646
      */
3647
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3647
+    public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) {
3648 3648
 
3649 3649
 
3650
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3651
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3652
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3653
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3654
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3655
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3650
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3651
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3652
+        $lesson_prerequisite       = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
3653
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3654
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3655
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3656 3656
         $show_actions              = is_user_logged_in() ? true : false;
3657 3657
 
3658
-        if( intval( $lesson_prerequisite ) > 0 ) {
3658
+        if (intval($lesson_prerequisite) > 0) {
3659 3659
 
3660 3660
             // If the user hasn't completed the prereq then hide the current actions
3661
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3661
+            $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
3662 3662
 
3663 3663
         }
3664 3664
         ?>
@@ -3666,19 +3666,19 @@  discard block
 block discarded – undo
3666 3666
         <footer>
3667 3667
 
3668 3668
             <?php
3669
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3669
+            if ($show_actions && $quiz_id && Sensei()->access_settings()) {
3670 3670
 
3671
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3672
-                if( $has_quiz_questions ) {
3671
+                $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3672
+                if ($has_quiz_questions) {
3673 3673
                     ?>
3674 3674
 
3675 3675
                     <p>
3676 3676
 
3677 3677
                         <a class="button"
3678
-                           href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>"
3679
-                           title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei'  ); ?>">
3678
+                           href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>"
3679
+                           title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>">
3680 3680
 
3681
-                            <?php  _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>
3681
+                            <?php  _e('View the Lesson Quiz', 'woothemes-sensei'); ?>
3682 3682
 
3683 3683
                         </a>
3684 3684
 
@@ -3689,11 +3689,11 @@  discard block
 block discarded – undo
3689 3689
 
3690 3690
             } // End If Statement
3691 3691
 
3692
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3692
+            if ($show_actions && ! $has_user_completed_lesson) {
3693 3693
 
3694 3694
                 sensei_complete_lesson_button();
3695 3695
 
3696
-            } elseif( $show_actions ) {
3696
+            } elseif ($show_actions) {
3697 3697
 
3698 3698
                 sensei_reset_lesson_button();
3699 3699
 
@@ -3710,20 +3710,20 @@  discard block
 block discarded – undo
3710 3710
      *
3711 3711
      * @since 1.9.0
3712 3712
      */
3713
-    public static function output_comments(){
3713
+    public static function output_comments() {
3714 3714
 
3715
-        if( ! is_user_logged_in() ){
3715
+        if ( ! is_user_logged_in()) {
3716 3716
             return;
3717 3717
         }
3718 3718
 
3719
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3720
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3721
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3722
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3719
+        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id());
3720
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3721
+        $allow_comments = Sensei()->settings->settings['lesson_comments'];
3722
+        $user_taking_course = Sensei_Utils::user_started_course($course_id);
3723 3723
 
3724
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3724
+        $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course;
3725 3725
 
3726
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3726
+        if ($lesson_allow_comments || is_singular('sensei_message')) {
3727 3727
 
3728 3728
             comments_template();
3729 3729
 
@@ -3739,26 +3739,26 @@  discard block
 block discarded – undo
3739 3739
      *
3740 3740
      * @since 1.9.0
3741 3741
      */
3742
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3742
+    public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) {
3743 3743
 
3744
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3745
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3746
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3747
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3748
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3744
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3745
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3746
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3747
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3748
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3749 3749
 
3750 3750
 
3751
-        if ( $quiz_id && is_user_logged_in()
3752
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3751
+        if ($quiz_id && is_user_logged_in()
3752
+            && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) {
3753 3753
 
3754 3754
             $no_quiz_count = 0;
3755
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3755
+            $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3756 3756
 
3757 3757
             // Display lesson quiz status message
3758
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3759
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3760
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3761
-                if( $has_quiz_questions ) {
3758
+            if ($has_user_completed_lesson || $has_quiz_questions) {
3759
+                $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true);
3760
+                echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
3761
+                if ($has_quiz_questions) {
3762 3762
                    // echo $status['extra'];
3763 3763
                 } // End If Statement
3764 3764
             } // End If Statement
@@ -3774,4 +3774,4 @@  discard block
 block discarded – undo
3774 3774
  * for backward compatibility
3775 3775
  * @since 1.9.0
3776 3776
  */
3777
-class WooThemes_Sensei_Lesson extends Sensei_Lesson{}
3777
+class WooThemes_Sensei_Lesson extends Sensei_Lesson {}
Please login to merge, or discard this patch.
Indentation   +1018 added lines, -1018 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public function __construct () {
24 24
 
25
-        $this->token = 'lesson';
25
+		$this->token = 'lesson';
26 26
 
27 27
 		// Setup meta fields for this post type
28 28
 		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
29 29
 
30
-        $this->question_order = '';
30
+		$this->question_order = '';
31 31
 
32 32
 		// Admin actions
33 33
 		if ( is_admin() ) {
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
86 86
 			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
87 87
 
88
-            // output bulk edit fields
89
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
90
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
88
+			// output bulk edit fields
89
+			add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
90
+			add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
91 91
 
92
-            // load quick edit default values
93
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
92
+			// load quick edit default values
93
+			add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
94 94
 
95
-            // save bulk edit fields
96
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
95
+			// save bulk edit fields
96
+			add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
97 97
 
98
-            // flush rewrite rules when saving a lesson
99
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
98
+			// flush rewrite rules when saving a lesson
99
+			add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
100 100
 
101 101
 		} else {
102 102
 			// Frontend actions
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 		$post_args = array(	'post_type' 		=> 'lesson',
191 191
 							'posts_per_page' 		=> -1,
192 192
 							'orderby'         	=> 'title',
193
-    						'order'           	=> 'ASC',
194
-    						'exclude' 			=> $post->ID,
193
+							'order'           	=> 'ASC',
194
+							'exclude' 			=> $post->ID,
195 195
 							'suppress_filters' 	=> 0
196 196
 							);
197 197
 		$posts_array = get_posts( $post_args );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$checked = '';
229 229
 		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
230
-	 	    $checked = checked( 'preview', $lesson_preview, false );
230
+	 		$checked = checked( 'preview', $lesson_preview, false );
231 231
 	 	} // End If Statement
232 232
 
233 233
 	 	$html .= '<label for="lesson_preview">';
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 
278 278
 	/**
279
-     * Update the lesson quiz and all the post meta
279
+	 * Update the lesson quiz and all the post meta
280 280
 	 *
281 281
 	 * @access public
282 282
 	 * @return void
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		}
298 298
 
299 299
 		// Temporarily disable the filter
300
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
300
+		remove_action( 'save_post', array( $this, 'quiz_update' ) );
301 301
 		// Save the Quiz
302 302
 		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
303 303
 
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 
313 313
 		// Setup Query Arguments
314 314
 		$post_type_args = array(	'post_content' => $post_content,
315
-  		    						'post_status' => $post_status,
316
-  		    						'post_title' => $post_title,
317
-  		    						'post_type' => 'quiz',
318
-                                    'post_parent' => $post_id,
319
-  		    						);
315
+  									'post_status' => $post_status,
316
+  									'post_title' => $post_title,
317
+  									'post_type' => 'quiz',
318
+									'post_parent' => $post_id,
319
+  									);
320 320
 
321 321
 		$settings = $this->get_quiz_settings();
322 322
 
@@ -324,48 +324,48 @@  discard block
 block discarded – undo
324 324
 		if ( 0 < $quiz_id ) {
325 325
 			// Update the Quiz
326 326
 			$post_type_args[ 'ID' ] = $quiz_id;
327
-		    wp_update_post($post_type_args);
328
-
329
-		    // Update the post meta data
330
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
331
-
332
-		    foreach( $settings as $field ) {
333
-		    	if( 'random_question_order' != $field['id'] ) {
334
-			    	$value = $this->get_submitted_setting_value( $field );
335
-			    	if( isset( $value ) ) {
336
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
337
-			    	}
338
-			    }
339
-		    }
340
-
341
-		    // Set the post terms for quiz-type
342
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
327
+			wp_update_post($post_type_args);
328
+
329
+			// Update the post meta data
330
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
331
+
332
+			foreach( $settings as $field ) {
333
+				if( 'random_question_order' != $field['id'] ) {
334
+					$value = $this->get_submitted_setting_value( $field );
335
+					if( isset( $value ) ) {
336
+						update_post_meta( $quiz_id, '_' . $field['id'], $value );
337
+					}
338
+				}
339
+			}
340
+
341
+			// Set the post terms for quiz-type
342
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
343 343
 		} else {
344 344
 			// Create the Quiz
345
-		    $quiz_id = wp_insert_post($post_type_args);
346
-
347
-		    // Add the post meta data WP will add it if it doesn't exist
348
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
349
-
350
-		    foreach( $settings as $field ) {
351
-		    	if( 'random_question_order' != $field['id'] ) {
352
-
353
-                    //ignore values not posted to avoid
354
-                    // overwriting with empty or default values
355
-                    // when the values are posted from bulk edit or quick edit
356
-                    if( !isset( $_POST[ $field['id'] ] ) ){
357
-                        continue;
358
-                    }
359
-
360
-			    	$value = $this->get_submitted_setting_value( $field );
361
-			    	if( isset( $value ) ) {
362
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
363
-			    	}
364
-			    }
365
-		    }
366
-
367
-		    // Set the post terms for quiz-type
368
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
345
+			$quiz_id = wp_insert_post($post_type_args);
346
+
347
+			// Add the post meta data WP will add it if it doesn't exist
348
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
349
+
350
+			foreach( $settings as $field ) {
351
+				if( 'random_question_order' != $field['id'] ) {
352
+
353
+					//ignore values not posted to avoid
354
+					// overwriting with empty or default values
355
+					// when the values are posted from bulk edit or quick edit
356
+					if( !isset( $_POST[ $field['id'] ] ) ){
357
+						continue;
358
+					}
359
+
360
+					$value = $this->get_submitted_setting_value( $field );
361
+					if( isset( $value ) ) {
362
+						add_post_meta( $quiz_id, '_' . $field['id'], $value );
363
+					}
364
+				}
365
+			}
366
+
367
+			// Set the post terms for quiz-type
368
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
369 369
 		} // End If Statement
370 370
 
371 371
 		// Add default lesson order meta value
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 		}
388 388
 
389 389
 		// Restore the previously disabled filter
390
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
390
+		add_action( 'save_post', array( $this, 'quiz_update' ) );
391 391
 
392 392
 	} // End post_updated()
393 393
 
@@ -427,22 +427,22 @@  discard block
 block discarded – undo
427 427
 		// Get the meta key.
428 428
 		$meta_key = '_' . $post_key;
429 429
 
430
-        //ignore fields are not posted
430
+		//ignore fields are not posted
431 431
 
432
-        if( !isset( $_POST[ $post_key ] ) ){
432
+		if( !isset( $_POST[ $post_key ] ) ){
433 433
 
434
-            // except for lesson preview checkbox field
435
-            if( 'lesson_preview' == $post_key ){
434
+			// except for lesson preview checkbox field
435
+			if( 'lesson_preview' == $post_key ){
436 436
 
437
-                $_POST[ $post_key ] = '';
437
+				$_POST[ $post_key ] = '';
438 438
 
439
-            } else {
439
+			} else {
440 440
 
441
-                return false;
441
+				return false;
442 442
 
443
-            }
443
+			}
444 444
 
445
-        }
445
+		}
446 446
 
447 447
 		// Get the posted data and sanitize it for use as an HTML class.
448 448
 		if ( 'lesson_video_embed' == $post_key) {
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
 			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
452 452
 		} // End If Statement
453 453
 
454
-        // update field with the new value
455
-        if( -1 != $new_meta_value  ){
456
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
457
-        }
454
+		// update field with the new value
455
+		if( -1 != $new_meta_value  ){
456
+			return update_post_meta( $post_id, $meta_key, $new_meta_value );
457
+		}
458 458
 
459 459
 	} // End save_post_meta()
460 460
 
@@ -479,9 +479,9 @@  discard block
 block discarded – undo
479 479
 		$post_args = array(	'post_type' 		=> 'course',
480 480
 							'posts_per_page' 		=> -1,
481 481
 							'orderby'         	=> 'title',
482
-    						'order'           	=> 'ASC',
483
-    						'post_status'      	=> 'any',
484
-    						'suppress_filters' 	=> 0,
482
+							'order'           	=> 'ASC',
483
+							'post_status'      	=> 'any',
484
+							'suppress_filters' 	=> 0,
485 485
 							);
486 486
 		$posts_array = get_posts( $post_args );
487 487
 		// Buid the HTML to Output
@@ -489,20 +489,20 @@  discard block
 block discarded – undo
489 489
 		// Nonce
490 490
 		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
491 491
 
492
-        // Select the course for the lesson
493
-        $drop_down_args = array(
494
-            'name'=>'lesson_course',
495
-            'id' => 'lesson-course-options'
496
-        );
492
+		// Select the course for the lesson
493
+		$drop_down_args = array(
494
+			'name'=>'lesson_course',
495
+			'id' => 'lesson-course-options'
496
+		);
497 497
 
498
-        $courses = WooThemes_Sensei_Course::get_all_courses();
499
-        $courses_options = array();
500
-        foreach( $courses as $course ){
501
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
502
-        }
503
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
498
+		$courses = WooThemes_Sensei_Course::get_all_courses();
499
+		$courses_options = array();
500
+		foreach( $courses as $course ){
501
+			$courses_options[ $course->ID ] = get_the_title( $course ) ;
502
+		}
503
+		$html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
504 504
 
505
-        // Course Actions Panel
505
+		// Course Actions Panel
506 506
 		if ( current_user_can( 'publish_courses' )) {
507 507
 				$html .= '<div id="lesson-course-actions">';
508 508
 					$html .= '<p>';
@@ -528,16 +528,16 @@  discard block
 block discarded – undo
528 528
 							} // End For Loop
529 529
 						$html .= '</select>' . "\n";
530 530
 						// Course Product
531
-                        if ( Sensei_WC::is_woocommerce_active() ) {
531
+						if ( Sensei_WC::is_woocommerce_active() ) {
532 532
 	  						// Get the Products
533 533
 							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
534 534
 
535 535
 							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
536 536
 													'posts_per_page' 		=> -1,
537 537
 													'orderby'         	=> 'title',
538
-	    											'order'           	=> 'DESC',
539
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
540
-	    											'tax_query'			=> array(
538
+													'order'           	=> 'DESC',
539
+													'post_status'		=> array( 'publish', 'private', 'draft' ),
540
+													'tax_query'			=> array(
541 541
 														array(
542 542
 															'taxonomy'	=> 'product_type',
543 543
 															'field'		=> 'slug',
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 															'operator'	=> 'NOT IN'
546 546
 														)
547 547
 													),
548
-	    											'suppress_filters' 	=> 0
548
+													'suppress_filters' 	=> 0
549 549
 													);
550 550
 							$products_array = get_posts( $product_args );
551 551
 							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
@@ -873,58 +873,58 @@  discard block
 block discarded – undo
873 873
 					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
874 874
 						$html .= '<td colspan="5">';
875 875
 							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
876
-					    	$html .= '<div class="question_required_fields">';
877
-
878
-						    	// Question title
879
-						    	$html .= '<div>';
880
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
881
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
882
-						    	$html .= '</div>';
883
-
884
-						    	// Question description
885
-						    	$html .= '<div>';
886
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
887
-						    	$html .= '</div>';
888
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
889
-
890
-						    	// Question grade
891
-						    	$html .= '<div>';
892
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
893
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
894
-						    	$html .= '</div>';
895
-
896
-						    	// Random order
897
-						    	if( $question_type == 'multiple-choice' ) {
898
-						    		$html .= '<div>';
899
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
900
-						    		$html .= '</div>';
901
-						    	}
902
-
903
-						    	// Question media
904
-						    	$html .= '<div>';
905
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
906
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
907
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
908
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
909
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
910
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
911
-						    	$html .= '</div>';
912
-
913
-						    $html .= '</div>';
914
-
915
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
916
-
917
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
876
+							$html .= '<div class="question_required_fields">';
877
+
878
+								// Question title
879
+								$html .= '<div>';
880
+									$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
881
+									$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
882
+								$html .= '</div>';
883
+
884
+								// Question description
885
+								$html .= '<div>';
886
+									$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
887
+								$html .= '</div>';
888
+									$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
889
+
890
+								// Question grade
891
+								$html .= '<div>';
892
+									$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
893
+									$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
894
+								$html .= '</div>';
895
+
896
+								// Random order
897
+								if( $question_type == 'multiple-choice' ) {
898
+									$html .= '<div>';
899
+										$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
900
+									$html .= '</div>';
901
+								}
902
+
903
+								// Question media
904
+								$html .= '<div>';
905
+									$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
906
+									$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
907
+									$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
908
+									$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
909
+									$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
910
+									$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
911
+								$html .= '</div>';
912
+
913
+							$html .= '</div>';
914
+
915
+							$html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
916
+
917
+							$html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
918 918
 							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
919 919
 
920 920
 							if( 'quiz' == $context ) {
921
-					    		$html .= '<div class="update-question">';
922
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
923
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
924
-					    		$html .= '</div>';
925
-					    	}
921
+								$html .= '<div class="update-question">';
922
+									$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
923
+									$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
924
+								$html .= '</div>';
925
+							}
926 926
 
927
-			    		$html .= '</td>';
927
+						$html .= '</td>';
928 928
 					$html .= '</tr>';
929 929
 				}
930 930
 
@@ -945,20 +945,20 @@  discard block
 block discarded – undo
945 945
 			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
946 946
 
947 947
 			if( 'quiz' == $context ) {
948
-	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
949
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
950
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
951
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
952
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
953
-	    			}
954
-	    		$html .= '</h2>';
955
-	    	}
948
+				$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
949
+					$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
950
+					$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
951
+					if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
952
+						$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
953
+					}
954
+				$html .= '</h2>';
955
+			}
956 956
 
957
-	    	$html .= '<div class="tab-content" id="tab-new-content">';
957
+			$html .= '<div class="tab-content" id="tab-new-content">';
958 958
 
959
-	    		if( 'quiz' == $context ) {
960
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
961
-	    		}
959
+				if( 'quiz' == $context ) {
960
+					$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
961
+				}
962 962
 
963 963
 				$html .= '<div class="question">';
964 964
 					$html .= '<div class="question_required_fields">';
@@ -1000,18 +1000,18 @@  discard block
 block discarded – undo
1000 1000
 
1001 1001
 						// Random order
1002 1002
 						$html .= '<p class="add_question_random_order">';
1003
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1004
-			    		$html .= '</p>';
1003
+							$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1004
+						$html .= '</p>';
1005 1005
 
1006
-			    		// Question media
1006
+						// Question media
1007 1007
 						$html .= '<p>';
1008
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1009
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1010
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1011
-					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1012
-					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1013
-					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1014
-				    	$html .= '</p>';
1008
+							$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1009
+							$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1010
+							$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1011
+							$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1012
+							$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1013
+							$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1014
+						$html .= '</p>';
1015 1015
 
1016 1016
 					$html .= '</div>';
1017 1017
 				$html .= '</div>';
@@ -1022,19 +1022,19 @@  discard block
 block discarded – undo
1022 1022
 
1023 1023
 				if( 'quiz' == $context ) {
1024 1024
 					$html .= '<div class="add-question">';
1025
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1026
-		    		$html .= '</div>';
1027
-		    	}
1025
+						$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1026
+					$html .= '</div>';
1027
+				}
1028 1028
 
1029
-		    $html .= '</div>';
1029
+			$html .= '</div>';
1030 1030
 
1031
-		    if( 'quiz' == $context ) {
1031
+			if( 'quiz' == $context ) {
1032 1032
 
1033
-			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1033
+				$html .= '<div class="tab-content hidden" id="tab-existing-content">';
1034 1034
 
1035
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1035
+					$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1036 1036
 
1037
-			    	$html .= '<div id="existing-filters" class="alignleft actions">
1037
+					$html .= '<div id="existing-filters" class="alignleft actions">
1038 1038
 			    				<select id="existing-status">
1039 1039
 			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1040 1040
 			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
@@ -1042,23 +1042,23 @@  discard block
 block discarded – undo
1042 1042
 			    				</select>
1043 1043
 			    				<select id="existing-type">
1044 1044
 			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1045
-							    	foreach ( $question_types as $type => $label ) {
1045
+									foreach ( $question_types as $type => $label ) {
1046 1046
 										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1047 1047
 									}
1048
-    				$html .= '</select>
1048
+					$html .= '</select>
1049 1049
     							<select id="existing-category">
1050 1050
 			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1051
-				    				foreach( $question_cats as $cat ) {
1051
+									foreach( $question_cats as $cat ) {
1052 1052
 										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1053 1053
 									}
1054
-    				$html .= '</select>
1054
+					$html .= '</select>
1055 1055
     							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1056 1056
     							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1057 1057
 			    			</div>';
1058 1058
 
1059
-			    	$html .= '<table id="existing-table" class="widefat">';
1059
+					$html .= '<table id="existing-table" class="widefat">';
1060 1060
 
1061
-			    		$html .= '<thead>
1061
+						$html .= '<thead>
1062 1062
 									    <tr>
1063 1063
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1064 1064
 									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
@@ -1086,28 +1086,28 @@  discard block
 block discarded – undo
1086 1086
 
1087 1087
 						$html .= '</tbody>';
1088 1088
 
1089
-			    	$html .= '</table>';
1089
+					$html .= '</table>';
1090 1090
 
1091
-			    	$next_class = '';
1092
-			    	if( $questions['count'] <= 10 ) {
1093
-			    		$next_class = 'hidden';
1094
-			    	}
1091
+					$next_class = '';
1092
+					if( $questions['count'] <= 10 ) {
1093
+						$next_class = 'hidden';
1094
+					}
1095 1095
 
1096
-			    	$html .= '<div id="existing-pagination">';
1097
-			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1098
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1099
-			    	$html .= '</div>';
1096
+					$html .= '<div id="existing-pagination">';
1097
+						$html .= '<input type="hidden" id="existing-page" value="1" />';
1098
+						$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1099
+					$html .= '</div>';
1100 1100
 
1101
-			    	$html .= '<div class="existing-actions">';
1102
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1103
-			    	$html .= '</div>';
1101
+					$html .= '<div class="existing-actions">';
1102
+						$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1103
+					$html .= '</div>';
1104 1104
 
1105
-			    $html .= '</div>';
1105
+				$html .= '</div>';
1106 1106
 
1107
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1108
-				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1107
+				if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1108
+					$html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1109 1109
 
1110
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1110
+						$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1111 1111
 
1112 1112
 						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1113 1113
 						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 
1121 1121
 						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1122 1122
 
1123
-				    $html .= '</div>';
1123
+					$html .= '</div>';
1124 1124
 				}
1125 1125
 			}
1126 1126
 
@@ -1193,14 +1193,14 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
 		$qry = new WP_Query( $args );
1195 1195
 
1196
-        /**
1197
-         * Filter existing questions query
1198
-         *
1199
-         * @since 1.8.0
1200
-         *
1201
-         * @param WP_Query $wp_query
1202
-         */
1203
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1196
+		/**
1197
+		 * Filter existing questions query
1198
+		 *
1199
+		 * @since 1.8.0
1200
+		 *
1201
+		 * @param WP_Query $wp_query
1202
+		 */
1203
+		$qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1204 1204
 
1205 1205
 		$questions['questions'] = $qry->posts;
1206 1206
 		$questions['count'] = intval( $qry->found_posts );
@@ -1215,14 +1215,14 @@  discard block
 block discarded – undo
1215 1215
 
1216 1216
 		if( ! $question_id ) {
1217 1217
 
1218
-            return;
1218
+			return;
1219 1219
 
1220
-        }
1220
+		}
1221 1221
 
1222 1222
 		$existing_class = '';
1223 1223
 		if( $row % 2 ) {
1224
-            $existing_class = 'alternate';
1225
-        }
1224
+			$existing_class = 'alternate';
1225
+		}
1226 1226
 
1227 1227
 		$question_type = Sensei()->question->get_question_type( $question_id );
1228 1228
 
@@ -1356,67 +1356,67 @@  discard block
 block discarded – undo
1356 1356
 							}
1357 1357
 						}
1358 1358
 
1359
-				    	// Calculate total wrong answers available (defaults to 4)
1360
-				    	$total_wrong = 0;
1361
-				    	if( $question_id ) {
1362
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1363
-				    	}
1364
-				    	if( 0 == intval( $total_wrong ) ) {
1365
-				    		$total_wrong = 1;
1366
-				    	}
1359
+						// Calculate total wrong answers available (defaults to 4)
1360
+						$total_wrong = 0;
1361
+						if( $question_id ) {
1362
+							$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1363
+						}
1364
+						if( 0 == intval( $total_wrong ) ) {
1365
+							$total_wrong = 1;
1366
+						}
1367 1367
 
1368
-                        // Setup Wrong Answer HTML
1369
-                        foreach ( $wrong_answers as $i => $answer ){
1368
+						// Setup Wrong Answer HTML
1369
+						foreach ( $wrong_answers as $i => $answer ){
1370 1370
 
1371
-                            $answer_id = $this->get_answer_id( $answer );
1372
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1373
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1374
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1375
-                            if( $question_id ) {
1371
+							$answer_id = $this->get_answer_id( $answer );
1372
+							$wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1373
+							$wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1374
+							$wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1375
+							if( $question_id ) {
1376 1376
 
1377
-                                $answers[ $answer_id ] = $wrong_answer;
1377
+								$answers[ $answer_id ] = $wrong_answer;
1378 1378
 
1379
-                            } else {
1379
+							} else {
1380 1380
 
1381
-                                $answers[] = $wrong_answer;
1381
+								$answers[] = $wrong_answer;
1382 1382
 
1383
-                            }
1383
+							}
1384 1384
 
1385
-                        } // end for each
1385
+						} // end for each
1386 1386
 
1387
-				    	$answers_sorted = $answers;
1388
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1389
-				    		$answers_sorted = array();
1390
-				    		foreach( $answer_order as $answer_id ) {
1391
-				    			if( isset( $answers[ $answer_id ] ) ) {
1392
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1393
-				    				unset( $answers[ $answer_id ] );
1394
-				    			}
1395
-				    		}
1387
+						$answers_sorted = $answers;
1388
+						if( $question_id && count( $answer_order ) > 0 ) {
1389
+							$answers_sorted = array();
1390
+							foreach( $answer_order as $answer_id ) {
1391
+								if( isset( $answers[ $answer_id ] ) ) {
1392
+									$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1393
+									unset( $answers[ $answer_id ] );
1394
+								}
1395
+							}
1396 1396
 
1397
-				    		if( count( $answers ) > 0 ) {
1398
-						    	foreach( $answers as $id => $answer ) {
1399
-						    		$answers_sorted[ $id ] = $answer;
1400
-						    	}
1401
-						    }
1402
-				    	}
1397
+							if( count( $answers ) > 0 ) {
1398
+								foreach( $answers as $id => $answer ) {
1399
+									$answers_sorted[ $id ] = $answer;
1400
+								}
1401
+							}
1402
+						}
1403 1403
 
1404 1404
 						foreach( $answers_sorted as $id => $answer ) {
1405
-				    		$html .= $answer;
1406
-				    	}
1405
+							$html .= $answer;
1406
+						}
1407 1407
 
1408
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1409
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1410
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1408
+						$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1409
+						$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1410
+						$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1411 1411
 
1412
-				    	$html .= '<div class="add_answer_options">';
1413
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1414
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1415
-				    	$html .= '</div>';
1412
+						$html .= '<div class="add_answer_options">';
1413
+							$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1414
+							$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1415
+						$html .= '</div>';
1416 1416
 
1417
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1417
+						$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1418 1418
 
1419
-			    	$html .= '</div>';
1419
+					$html .= '</div>';
1420 1420
 				break;
1421 1421
 				case 'boolean':
1422 1422
 					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
@@ -1429,7 +1429,7 @@  discard block
 block discarded – undo
1429 1429
 						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1430 1430
 						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1431 1431
 
1432
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1432
+					$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1433 1433
 
1434 1434
 					$html .= '</div>';
1435 1435
 				break;
@@ -1504,17 +1504,17 @@  discard block
 block discarded – undo
1504 1504
 
1505 1505
 	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1506 1506
 
1507
-        // default field name
1508
-        $field_name = 'answer_feedback';
1509
-        if( 'boolean' == $question_type ){
1507
+		// default field name
1508
+		$field_name = 'answer_feedback';
1509
+		if( 'boolean' == $question_type ){
1510 1510
 
1511
-            $field_name = 'answer_feedback_boolean';
1511
+			$field_name = 'answer_feedback_boolean';
1512 1512
 
1513
-        }elseif( 'multiple-choice' == $question_type ){
1513
+		}elseif( 'multiple-choice' == $question_type ){
1514 1514
 
1515
-            $field_name = 'answer_feedback_multiple_choice';
1515
+			$field_name = 'answer_feedback_multiple_choice';
1516 1516
 
1517
-        }// end if
1517
+		}// end if
1518 1518
 
1519 1519
 		if( $question_counter ) {
1520 1520
 			$field_name = 'answer_' . $question_counter . '_feedback';
@@ -1719,15 +1719,15 @@  discard block
 block discarded – undo
1719 1719
 			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1720 1720
 
1721 1721
 			// Load the lessons script
1722
-            wp_enqueue_media();
1722
+			wp_enqueue_media();
1723 1723
 			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1724 1724
 			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1725 1725
 			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1726 1726
 
1727
-            // Load the bulk edit screen script
1728
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1729
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1730
-            }
1727
+			// Load the bulk edit screen script
1728
+			if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1729
+				wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1730
+			}
1731 1731
 
1732 1732
 			// Localise script
1733 1733
 			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
@@ -2030,12 +2030,12 @@  discard block
 block discarded – undo
2030 2030
 
2031 2031
 					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2032 2032
 					if( ! in_array( $quiz_id, $quizzes ) ) {
2033
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2033
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2034 2034
 						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2035 2035
 						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2036
-			    	}
2036
+					}
2037 2037
 
2038
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2038
+					add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2039 2039
 					$question_type = Sensei()->question->get_question_type( $question_id );
2040 2040
 
2041 2041
 					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
@@ -2141,34 +2141,34 @@  discard block
 block discarded – undo
2141 2141
 		$post_content = $course_content;
2142 2142
 		// Course Query Arguments
2143 2143
 		$post_type_args = array(	'post_content' => $post_content,
2144
-  		    						'post_status' => $post_status,
2145
-  		    						'post_title' => $post_title,
2146
-  		    						'post_type' => $post_type
2147
-  		    						);
2144
+  									'post_status' => $post_status,
2145
+  									'post_title' => $post_title,
2146
+  									'post_type' => $post_type
2147
+  									);
2148 2148
   		// Only save if there is a valid title
2149 2149
   		if ( $post_title != '' ) {
2150
-  		    // Check for prerequisite courses & product id
2151
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2152
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2153
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2154
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2155
-  		    // Insert or Update the Lesson Quiz
2156
-		    if ( 0 < $course_id ) {
2157
-		    	$post_type_args[ 'ID' ] = $course_id;
2158
-		    	$course_id = wp_update_post($post_type_args);
2159
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2160
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2161
-		    	if ( 0 < $course_category_id ) {
2162
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2163
-		    	} // End If Statement
2164
-		    } else {
2165
-		    	$course_id = wp_insert_post($post_type_args);
2166
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2167
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2168
-		    	if ( 0 < $course_category_id ) {
2169
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2170
-		    	} // End If Statement
2171
-		    } // End If Statement
2150
+  			// Check for prerequisite courses & product id
2151
+  			$course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2152
+  			$course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2153
+  			$course_category_id = absint( $data[ 'course_category' ] );
2154
+  			if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2155
+  			// Insert or Update the Lesson Quiz
2156
+			if ( 0 < $course_id ) {
2157
+				$post_type_args[ 'ID' ] = $course_id;
2158
+				$course_id = wp_update_post($post_type_args);
2159
+				update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2160
+				update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2161
+				if ( 0 < $course_category_id ) {
2162
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2163
+				} // End If Statement
2164
+			} else {
2165
+				$course_id = wp_insert_post($post_type_args);
2166
+				add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2167
+				add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2168
+				if ( 0 < $course_category_id ) {
2169
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2170
+				} // End If Statement
2171
+			} // End If Statement
2172 2172
 		} // End If Statement
2173 2173
   		// Check that the insert or update saved by testing the post id
2174 2174
   		if ( 0 < $course_id ) {
@@ -2259,17 +2259,17 @@  discard block
 block discarded – undo
2259 2259
 		$answer_feedback = '';
2260 2260
 		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2261 2261
 
2262
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2262
+			$answer_feedback = $data[ 'answer_feedback_boolean' ];
2263 2263
 
2264 2264
 		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2265 2265
 
2266
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2266
+			$answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2267 2267
 
2268
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2268
+		}elseif( isset( $data[ 'answer_feedback' ] )  ){
2269 2269
 
2270
-            $answer_feedback = $data[ 'answer_feedback' ];
2270
+			$answer_feedback = $data[ 'answer_feedback' ];
2271 2271
 
2272
-        } // End If Statement
2272
+		} // End If Statement
2273 2273
 
2274 2274
 		$post_title = $question_text;
2275 2275
 		$post_author = $data[ 'post_author' ];
@@ -2284,10 +2284,10 @@  discard block
 block discarded – undo
2284 2284
 		}
2285 2285
 		// Question Query Arguments
2286 2286
 		$post_type_args = array(	'post_content' => $post_content,
2287
-  		    						'post_status' => $post_status,
2288
-  		    						'post_title' => $post_title,
2289
-  		    						'post_type' => $post_type
2290
-  		    						);
2287
+  									'post_status' => $post_status,
2288
+  									'post_title' => $post_title,
2289
+  									'post_type' => $post_type
2290
+  									);
2291 2291
 
2292 2292
   		// Remove empty values and reindex the array
2293 2293
   		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
@@ -2323,14 +2323,14 @@  discard block
 block discarded – undo
2323 2323
   		if ( $post_title != '' ) {
2324 2324
 
2325 2325
   			// Get Quiz ID for the question
2326
-  		    $quiz_id = $data['quiz_id'];
2326
+  			$quiz_id = $data['quiz_id'];
2327 2327
 
2328
-  		    // Get question media
2328
+  			// Get question media
2329 2329
 			$question_media = $data['question_media'];
2330 2330
 
2331
-  		    // Get answer order
2332
-  		    $answer_order = '';
2333
-  		    if( isset( $data['answer_order'] ) ) {
2331
+  			// Get answer order
2332
+  			$answer_order = '';
2333
+  			if( isset( $data['answer_order'] ) ) {
2334 2334
 				$answer_order = $data['answer_order'];
2335 2335
 			}
2336 2336
 
@@ -2340,38 +2340,38 @@  discard block
 block discarded – undo
2340 2340
 				$random_order = $data['random_order'];
2341 2341
 			}
2342 2342
 
2343
-  		    // Insert or Update the question
2344
-  		    if ( 0 < $question_id ) {
2345
-
2346
-  		    	$post_type_args[ 'ID' ] = $question_id;
2347
-		    	$question_id = wp_update_post( $post_type_args );
2348
-
2349
-		    	// Update poast meta
2350
-		    	if( 'quiz' == $context ) {
2351
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2352
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2353
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2354
-			    	}
2355
-		    	}
2356
-
2357
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2358
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2359
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2360
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2361
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2362
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2363
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2364
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2365
-
2366
-		    	if( 'quiz' != $context ) {
2367
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2368
-		    	}
2343
+  			// Insert or Update the question
2344
+  			if ( 0 < $question_id ) {
2345
+
2346
+  				$post_type_args[ 'ID' ] = $question_id;
2347
+				$question_id = wp_update_post( $post_type_args );
2348
+
2349
+				// Update poast meta
2350
+				if( 'quiz' == $context ) {
2351
+					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2352
+					if( ! in_array( $quiz_id, $quizzes ) ) {
2353
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2354
+					}
2355
+				}
2356
+
2357
+				update_post_meta( $question_id, '_question_grade', $question_grade );
2358
+				update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2359
+				update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2360
+				update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2361
+				update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2362
+				update_post_meta( $question_id, '_question_media', $question_media );
2363
+				update_post_meta( $question_id, '_answer_order', $answer_order );
2364
+				update_post_meta( $question_id, '_random_order', $random_order );
2365
+
2366
+				if( 'quiz' != $context ) {
2367
+					wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2368
+				}
2369 2369
 				// Don't store empty value, no point
2370 2370
 				if ( !empty($answer_feedback) ) {
2371 2371
 					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2372 2372
 				}
2373 2373
 
2374
-		    } else {
2374
+			} else {
2375 2375
 				$question_id = wp_insert_post( $post_type_args );
2376 2376
 				$question_count = intval( $data['question_count'] );
2377 2377
 				++$question_count;
@@ -2384,29 +2384,29 @@  discard block
 block discarded – undo
2384 2384
 				}
2385 2385
 
2386 2386
 				if( isset( $question_grade ) ) {
2387
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2388
-		    	}
2389
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2390
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2391
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2392
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2393
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2394
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2395
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2396
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2387
+					add_post_meta( $question_id, '_question_grade', $question_grade );
2388
+				}
2389
+				add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2390
+				add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2391
+				add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2392
+				add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2393
+				add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2394
+				add_post_meta( $question_id, '_question_media', $question_media );
2395
+				add_post_meta( $question_id, '_answer_order', $answer_order );
2396
+				add_post_meta( $question_id, '_random_order', $random_order );
2397 2397
 				// Don't store empty value, no point
2398 2398
 				if ( !empty($answer_feedback) ) {
2399 2399
 					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2400 2400
 				}
2401 2401
 
2402
-		    	// Set the post terms for question-type
2403
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2402
+				// Set the post terms for question-type
2403
+				wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2404 2404
 
2405
-			    if( $question_category ) {
2406
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2407
-	    		}
2405
+				if( $question_category ) {
2406
+					wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2407
+				}
2408 2408
 
2409
-		    } // End If Statement
2409
+			} // End If Statement
2410 2410
 		} // End If Statement
2411 2411
   		// Check that the insert or update saved by testing the post id
2412 2412
   		if ( 0 < $question_id ) {
@@ -2455,7 +2455,7 @@  discard block
 block discarded – undo
2455 2455
 	public function lesson_complexities() {
2456 2456
 
2457 2457
 		// V2 - make filter for this array
2458
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2458
+		$lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2459 2459
 									'std' => __( 'Standard', 'woothemes-sensei' ),
2460 2460
 									'hard' => __( 'Hard', 'woothemes-sensei' )
2461 2461
 									);
@@ -2522,14 +2522,14 @@  discard block
 block discarded – undo
2522 2522
 		$post_args = array(	'post_type' 		=> 'quiz',
2523 2523
 							'posts_per_page' 		=> 1,
2524 2524
 							'orderby'         	=> 'title',
2525
-    						'order'           	=> 'DESC',
2526
-    						'post_parent'      	=> $lesson_id,
2527
-    						'post_status'		=> $post_status,
2525
+							'order'           	=> 'DESC',
2526
+							'post_parent'      	=> $lesson_id,
2527
+							'post_status'		=> $post_status,
2528 2528
 							'suppress_filters' 	=> 0,
2529 2529
 							'fields'            => $fields
2530 2530
 							);
2531 2531
 		$posts_array = get_posts( $post_args );
2532
-        $quiz_id = array_shift($posts_array);
2532
+		$quiz_id = array_shift($posts_array);
2533 2533
 
2534 2534
 		return $quiz_id;
2535 2535
 	} // End lesson_quizzes()
@@ -2537,34 +2537,34 @@  discard block
 block discarded – undo
2537 2537
 
2538 2538
 	/**
2539 2539
 	 * Fetches all the questions for a quiz depending on certain conditions.
2540
-     *
2541
-     * Determine which questions should be shown depending on:
2542
-     * - admin/teacher selected questions to be shown
2543
-     * - questions shown to a user previously (saved as asked questions)
2544
-     * - limit number of questions lesson setting
2545 2540
 	 *
2546
-     * @since 1.0
2541
+	 * Determine which questions should be shown depending on:
2542
+	 * - admin/teacher selected questions to be shown
2543
+	 * - questions shown to a user previously (saved as asked questions)
2544
+	 * - limit number of questions lesson setting
2545
+	 *
2546
+	 * @since 1.0
2547 2547
 	 * @param int $quiz_id (default: 0)
2548 2548
 	 * @param string $post_status (default: 'publish')
2549 2549
 	 * @param string $orderby (default: 'meta_value_num title')
2550 2550
 	 * @param string $order (default: 'ASC')
2551
-     *
2551
+	 *
2552 2552
 	 * @return array $questions { $question type WP_Post }
2553 2553
 	 */
2554 2554
 	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2555 2555
 
2556 2556
 		$quiz_id = (string) $quiz_id;
2557
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2557
+		$quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2558 2558
 
2559
-        // setup the user id
2560
-        if( is_admin() ) {
2561
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2562
-        } else {
2563
-            $user_id = get_current_user_id();
2564
-        }
2559
+		// setup the user id
2560
+		if( is_admin() ) {
2561
+			$user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2562
+		} else {
2563
+			$user_id = get_current_user_id();
2564
+		}
2565 2565
 
2566
-        // get the users current status on the lesson
2567
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2566
+		// get the users current status on the lesson
2567
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2568 2568
 
2569 2569
 		// Set the default question order if it has not already been set for this quiz
2570 2570
 		$this->set_default_question_order( $quiz_id );
@@ -2594,14 +2594,14 @@  discard block
 block discarded – undo
2594 2594
 			'suppress_filters' 	=> 0
2595 2595
 		);
2596 2596
 
2597
-        //query the questions
2597
+		//query the questions
2598 2598
 		$questions_query = new WP_Query( $question_query_args );
2599 2599
 
2600
-        // Set return array to initially include all items
2601
-        $questions = $questions_query->posts;
2600
+		// Set return array to initially include all items
2601
+		$questions = $questions_query->posts;
2602 2602
 
2603
-        // set the questions array that will be manipulated within this function
2604
-        $questions_array = $questions_query->posts;
2603
+		// set the questions array that will be manipulated within this function
2604
+		$questions_array = $questions_query->posts;
2605 2605
 
2606 2606
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2607 2607
 		$selected_questions = false;
@@ -2714,36 +2714,36 @@  discard block
 block discarded – undo
2714 2714
 			}
2715 2715
 		}
2716 2716
 
2717
-        // Save the questions that will be asked for the current user
2718
-        // this happens only once per user/quiz, unless the user resets the quiz
2719
-        if( ! is_admin() ){
2717
+		// Save the questions that will be asked for the current user
2718
+		// this happens only once per user/quiz, unless the user resets the quiz
2719
+		if( ! is_admin() ){
2720 2720
 
2721
-            if( $user_lesson_status ) {
2721
+			if( $user_lesson_status ) {
2722 2722
 
2723
-                $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2724
-                if ( empty($questions_asked) && $user_lesson_status) {
2723
+				$questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2724
+				if ( empty($questions_asked) && $user_lesson_status) {
2725 2725
 
2726
-                    $questions_asked = array();
2727
-                    foreach ($questions as $question) {
2726
+					$questions_asked = array();
2727
+					foreach ($questions as $question) {
2728 2728
 
2729
-                        $questions_asked[] = $question->ID;
2729
+						$questions_asked[] = $question->ID;
2730 2730
 
2731
-                    }
2731
+					}
2732 2732
 
2733
-                    // save the questions asked id
2734
-                    $questions_asked_csv = implode(',', $questions_asked);
2735
-                    update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2733
+					// save the questions asked id
2734
+					$questions_asked_csv = implode(',', $questions_asked);
2735
+					update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2736 2736
 
2737
-                }
2738
-            }
2739
-        }
2737
+				}
2738
+			}
2739
+		}
2740 2740
 
2741
-        /**
2742
-         * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2743
-         *
2744
-         * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2745
-         * @since 1.8.0
2746
-         */
2741
+		/**
2742
+		 * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2743
+		 *
2744
+		 * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2745
+		 * @since 1.8.0
2746
+		 */
2747 2747
 		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2748 2748
 
2749 2749
 	} // End lesson_quiz_questions()
@@ -2847,7 +2847,7 @@  discard block
 block discarded – undo
2847 2847
  			// Display Image Placeholder if none
2848 2848
 			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2849 2849
 
2850
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2850
+				$img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2851 2851
 
2852 2852
 			} // End If Statement
2853 2853
 
@@ -2863,401 +2863,401 @@  discard block
 block discarded – undo
2863 2863
 	 * Returns the the lesson excerpt.
2864 2864
 	 *
2865 2865
 	 * @param WP_Post $lesson
2866
-     * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2866
+	 * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2867 2867
 	 * @return string
2868 2868
 	 */
2869 2869
 	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2870 2870
 		$html = '';
2871 2871
 		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2872 2872
 
2873
-            $excerpt =  $lesson->post_excerpt;
2873
+			$excerpt =  $lesson->post_excerpt;
2874 2874
 
2875
-            // if $add_p_tags true wrap with <p> else return the excerpt as is
2876
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2875
+			// if $add_p_tags true wrap with <p> else return the excerpt as is
2876
+			$html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2877 2877
 
2878 2878
 		}
2879 2879
 		return apply_filters( 'sensei_lesson_excerpt', $html );
2880 2880
 
2881 2881
 	} // End lesson_excerpt()
2882 2882
 
2883
-    /**
2884
-     * Returns the course for a given lesson
2885
-     *
2886
-     * @since 1.7.4
2887
-     * @access public
2888
-     *
2889
-     * @param int $lesson_id
2890
-     * @return int|bool $course_id or bool when nothing is found.
2891
-     */
2892
-     public function get_course_id( $lesson_id ){
2893
-
2894
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2895
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2896
-             return false;
2897
-         }
2898
-
2899
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2900
-
2901
-         // make sure the course id is valid
2902
-         if( empty( $lesson_course_id )
2903
-             || is_array( $lesson_course_id )
2904
-             || intval( $lesson_course_id ) < 1
2905
-             || 'course' != get_post_type( $lesson_course_id ) ){
2906
-
2907
-             return false;
2908
-
2909
-         }
2910
-
2911
-         return $lesson_course_id;
2912
-
2913
-     }// en get_course_id
2914
-
2915
-    /**
2916
-     * Add the admin all lessons screen edit options.
2917
-     *
2918
-     * The fields in this function work for both quick and bulk edit. The ID attributes is used
2919
-     * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2920
-     * name attribute is will be used by the quick edit and submitted via standard POST. This
2921
-     * will use this classes save_post_meta function to save the new field data.
2922
-     *
2923
-     * @hooked quick_edit_custom_box
2924
-     * @hooked bulk_edit_custom_box
2925
-     *
2926
-     * @since 1.8.0
2927
-     *
2928
-     * @param string $column_name
2929
-     * @param string $post_type
2930
-     * @return void
2931
-     */
2932
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2933
-
2934
-        // only show these options ont he lesson post type edit screen
2935
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2936
-            return;
2937
-        }
2938
-
2939
-        ?>
2883
+	/**
2884
+	 * Returns the course for a given lesson
2885
+	 *
2886
+	 * @since 1.7.4
2887
+	 * @access public
2888
+	 *
2889
+	 * @param int $lesson_id
2890
+	 * @return int|bool $course_id or bool when nothing is found.
2891
+	 */
2892
+	 public function get_course_id( $lesson_id ){
2893
+
2894
+		 if( ! isset( $lesson_id ) || empty( $lesson_id )
2895
+		 ||  'lesson' != get_post_type( $lesson_id ) ){
2896
+			 return false;
2897
+		 }
2898
+
2899
+		 $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2900
+
2901
+		 // make sure the course id is valid
2902
+		 if( empty( $lesson_course_id )
2903
+			 || is_array( $lesson_course_id )
2904
+			 || intval( $lesson_course_id ) < 1
2905
+			 || 'course' != get_post_type( $lesson_course_id ) ){
2906
+
2907
+			 return false;
2908
+
2909
+		 }
2910
+
2911
+		 return $lesson_course_id;
2912
+
2913
+	 }// en get_course_id
2914
+
2915
+	/**
2916
+	 * Add the admin all lessons screen edit options.
2917
+	 *
2918
+	 * The fields in this function work for both quick and bulk edit. The ID attributes is used
2919
+	 * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2920
+	 * name attribute is will be used by the quick edit and submitted via standard POST. This
2921
+	 * will use this classes save_post_meta function to save the new field data.
2922
+	 *
2923
+	 * @hooked quick_edit_custom_box
2924
+	 * @hooked bulk_edit_custom_box
2925
+	 *
2926
+	 * @since 1.8.0
2927
+	 *
2928
+	 * @param string $column_name
2929
+	 * @param string $post_type
2930
+	 * @return void
2931
+	 */
2932
+	public function all_lessons_edit_fields( $column_name, $post_type ) {
2933
+
2934
+		// only show these options ont he lesson post type edit screen
2935
+		if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2936
+			return;
2937
+		}
2938
+
2939
+		?>
2940 2940
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2941 2941
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2942 2942
                     <?php
2943
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2944
-                    // create a nonce field to be  used as a security measure when saving the data
2945
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2946
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2947
-
2948
-                    // unchanged option - we need this in because
2949
-                    // the default option in bulk edit should not be empty. If it is
2950
-                    // the user will erase data they didn't want to touch.
2951
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2952
-
2953
-                    //
2954
-                    //course selection
2955
-                    //
2956
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2957
-                    $course_options = array();
2958
-                    if ( count( $courses ) > 0 ) {
2959
-                        foreach ($courses as $course ){
2960
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2961
-                        }
2962
-                    }
2963
-                    //pre-append the no change option
2964
-                    $course_options['-1']=  $no_change_text;
2965
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2966
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2967
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2968
-
2969
-                    //
2970
-                    // lesson complexity selection
2971
-                    //
2972
-                    $lesson_complexities =  $this->lesson_complexities();
2973
-                    //pre-append the no change option
2974
-                    $lesson_complexities['-1']=  $no_change_text;
2975
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2976
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2977
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2978
-
2979
-                    ?>
2943
+					echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2944
+					// create a nonce field to be  used as a security measure when saving the data
2945
+					wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2946
+					wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2947
+
2948
+					// unchanged option - we need this in because
2949
+					// the default option in bulk edit should not be empty. If it is
2950
+					// the user will erase data they didn't want to touch.
2951
+					$no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2952
+
2953
+					//
2954
+					//course selection
2955
+					//
2956
+					$courses =  WooThemes_Sensei_Course::get_all_courses();
2957
+					$course_options = array();
2958
+					if ( count( $courses ) > 0 ) {
2959
+						foreach ($courses as $course ){
2960
+							$course_options[ $course->ID ] = get_the_title( $course->ID );
2961
+						}
2962
+					}
2963
+					//pre-append the no change option
2964
+					$course_options['-1']=  $no_change_text;
2965
+					$course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2966
+					$course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2967
+					echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2968
+
2969
+					//
2970
+					// lesson complexity selection
2971
+					//
2972
+					$lesson_complexities =  $this->lesson_complexities();
2973
+					//pre-append the no change option
2974
+					$lesson_complexities['-1']=  $no_change_text;
2975
+					$complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2976
+					$complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2977
+					echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2978
+
2979
+					?>
2980 2980
 
2981 2981
                     <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4>
2982 2982
 
2983 2983
                     <?php
2984 2984
 
2985
-                    //
2986
-                    // Lesson require pass to complete
2987
-                    //
2988
-                    $pass_required_options = array(
2989
-                        '-1' => $no_change_text,
2990
-                         '0' => __('No','woothemes'),
2991
-                         '1' => __('Yes','woothemes'),
2992
-                    );
2993
-
2994
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
2995
-                                                                'id'=> 'sensei-edit-lesson-pass-required',
2996
-                                                                'class'=>' '   );
2997
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
2998
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
2999
-
3000
-                    //
3001
-                    // Quiz pass percentage
3002
-                    //
3003
-                    $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3004
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3005
-
3006
-                    //
3007
-                    // Enable quiz reset button
3008
-                    //
3009
-                    $quiz_reset_select__options = array(
3010
-                        '-1' => $no_change_text,
3011
-                        '0' => __('No','woothemes'),
3012
-                        '1' => __('Yes','woothemes'),
3013
-                    );
3014
-                    $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3015
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3016
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3017
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3018
-
3019
-                    ?>
2985
+					//
2986
+					// Lesson require pass to complete
2987
+					//
2988
+					$pass_required_options = array(
2989
+						'-1' => $no_change_text,
2990
+						 '0' => __('No','woothemes'),
2991
+						 '1' => __('Yes','woothemes'),
2992
+					);
2993
+
2994
+					$pass_required_select_attributes = array( 'name'=> 'pass_required',
2995
+																'id'=> 'sensei-edit-lesson-pass-required',
2996
+																'class'=>' '   );
2997
+					$require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
2998
+					echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
2999
+
3000
+					//
3001
+					// Quiz pass percentage
3002
+					//
3003
+					$quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3004
+					echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3005
+
3006
+					//
3007
+					// Enable quiz reset button
3008
+					//
3009
+					$quiz_reset_select__options = array(
3010
+						'-1' => $no_change_text,
3011
+						'0' => __('No','woothemes'),
3012
+						'1' => __('Yes','woothemes'),
3013
+					);
3014
+					$quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3015
+					$quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3016
+					$quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3017
+					echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3018
+
3019
+					?>
3020 3020
             </div>
3021 3021
         </fieldset>
3022 3022
     <?php
3023
-    }// all_lessons_edit_fields
3024
-
3025
-    /**
3026
-     * Create the html for the edit field
3027
-     *
3028
-     * Wraps the passed in field and title combination with the correct html.
3029
-     *
3030
-     * @since 1.8.0
3031
-     *
3032
-     * @param string $title that will stand to the left of the field.
3033
-     * @param string $field type markup for the field that must be wrapped.
3034
-     * @return string $field_html
3035
-     */
3036
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3037
-
3038
-        $html = '';
3039
-        $html = '<div class="inline-edit-group" >';
3040
-        $html .=  '<span class="title">'. $title .'</span> ';
3041
-        $html .= '<span class="input-text-wrap">';
3042
-        $html .= $field;
3043
-        $html .= '</span>';
3044
-        $html .= '</label></div>';
3045
-
3046
-        return $html ;
3047
-
3048
-    }//end generate_all_lessons_edit_field
3049
-
3050
-    /**
3051
-     * Respond to the ajax call from the bulk edit save function. This comes
3052
-     * from the admin all lesson screen.
3053
-     *
3054
-     * @since 1.8.0
3055
-     * @return void
3056
-     */
3057
-    function save_all_lessons_edit_fields() {
3058
-
3059
-        // verify all the data before attempting to save
3060
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3061
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3062
-            die();
3063
-        }
3064
-
3065
-        // get our variables
3066
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3067
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3068
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3069
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3070
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3071
-        // store the values for all selected posts
3072
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3073
-
3074
-            // get the quiz id needed for the quiz meta
3075
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3076
-
3077
-            // do not save the items if the value is -1 as this
3078
-            // means it was not changed
3079
-
3080
-            // update lesson course
3081
-            if( -1 != $new_course ){
3082
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3083
-            }
3084
-            // update lesson complexity
3085
-            if( -1 != $new_complexity ){
3086
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3087
-            }
3088
-
3089
-            // Quiz Related settings
3090
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3091
-
3092
-                // update pass required
3093
-                if (-1 != $new_pass_required) {
3094
-
3095
-                    $checked = $new_pass_required  ? 'on' : '';
3096
-                    update_post_meta($quiz_id, '_pass_required', $checked);
3097
-                    unset( $checked );
3098
-                }
3023
+	}// all_lessons_edit_fields
3024
+
3025
+	/**
3026
+	 * Create the html for the edit field
3027
+	 *
3028
+	 * Wraps the passed in field and title combination with the correct html.
3029
+	 *
3030
+	 * @since 1.8.0
3031
+	 *
3032
+	 * @param string $title that will stand to the left of the field.
3033
+	 * @param string $field type markup for the field that must be wrapped.
3034
+	 * @return string $field_html
3035
+	 */
3036
+	public function generate_all_lessons_edit_field( $title  ,$field ){
3037
+
3038
+		$html = '';
3039
+		$html = '<div class="inline-edit-group" >';
3040
+		$html .=  '<span class="title">'. $title .'</span> ';
3041
+		$html .= '<span class="input-text-wrap">';
3042
+		$html .= $field;
3043
+		$html .= '</span>';
3044
+		$html .= '</label></div>';
3045
+
3046
+		return $html ;
3047
+
3048
+	}//end generate_all_lessons_edit_field
3049
+
3050
+	/**
3051
+	 * Respond to the ajax call from the bulk edit save function. This comes
3052
+	 * from the admin all lesson screen.
3053
+	 *
3054
+	 * @since 1.8.0
3055
+	 * @return void
3056
+	 */
3057
+	function save_all_lessons_edit_fields() {
3099 3058
 
3100
-                // update pass percentage
3101
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3059
+		// verify all the data before attempting to save
3060
+		if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3061
+			||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3062
+			die();
3063
+		}
3102 3064
 
3103
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3065
+		// get our variables
3066
+		$new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3067
+		$new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3068
+		$new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3069
+		$new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3070
+		$new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3071
+		// store the values for all selected posts
3072
+		foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3104 3073
 
3105
-                }
3074
+			// get the quiz id needed for the quiz meta
3075
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3106 3076
 
3107
-                //
3108
-                // update enable quiz reset
3109
-                //
3110
-                if (-1 != $new_enable_quiz_reset ) {
3077
+			// do not save the items if the value is -1 as this
3078
+			// means it was not changed
3111 3079
 
3112
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3113
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3114
-                    unset( $checked );
3080
+			// update lesson course
3081
+			if( -1 != $new_course ){
3082
+				update_post_meta( $lesson_id, '_lesson_course', $new_course );
3083
+			}
3084
+			// update lesson complexity
3085
+			if( -1 != $new_complexity ){
3086
+				update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3087
+			}
3115 3088
 
3116
-                }
3089
+			// Quiz Related settings
3090
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3117 3091
 
3092
+				// update pass required
3093
+				if (-1 != $new_pass_required) {
3118 3094
 
3119
-            } // end if quiz
3095
+					$checked = $new_pass_required  ? 'on' : '';
3096
+					update_post_meta($quiz_id, '_pass_required', $checked);
3097
+					unset( $checked );
3098
+				}
3120 3099
 
3121
-        }// end for each
3100
+				// update pass percentage
3101
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3122 3102
 
3123
-        die();
3103
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3124 3104
 
3125
-    } // end save_all_lessons_edit_fields
3105
+				}
3126 3106
 
3127
-    /**
3128
-     * Loading the quick edit fields defaults.
3129
-     *
3130
-     * This function will localise the default values along with the script that will
3131
-     * add these values to the inputs.
3132
-     *
3133
-     * NOTE: this function runs for each row in the edit column
3134
-     *
3135
-     * @since 1.8.0
3136
-     * @return void
3137
-     */
3138
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3107
+				//
3108
+				// update enable quiz reset
3109
+				//
3110
+				if (-1 != $new_enable_quiz_reset ) {
3139 3111
 
3140
-        if( 'lesson-course' != $column_name ){
3141
-            return;
3142
-        }
3143
-        // load the script
3144
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3145
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3112
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3113
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3114
+					unset( $checked );
3146 3115
 
3147
-        // setup the values for all meta fields
3148
-        $data = array();
3149
-        foreach( $this->meta_fields as $field ){
3116
+				}
3150 3117
 
3151
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3152 3118
 
3153
-        }
3154
-        // add quiz meta fields
3155
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3156
-        foreach( Sensei()->quiz->meta_fields as $field ){
3119
+			} // end if quiz
3157 3120
 
3158
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3121
+		}// end for each
3159 3122
 
3160
-        }
3123
+		die();
3161 3124
 
3162
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3125
+	} // end save_all_lessons_edit_fields
3163 3126
 
3164
-    }// end quick edit admin defaults
3127
+	/**
3128
+	 * Loading the quick edit fields defaults.
3129
+	 *
3130
+	 * This function will localise the default values along with the script that will
3131
+	 * add these values to the inputs.
3132
+	 *
3133
+	 * NOTE: this function runs for each row in the edit column
3134
+	 *
3135
+	 * @since 1.8.0
3136
+	 * @return void
3137
+	 */
3138
+	public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3165 3139
 
3166
-    /**
3167
-     * Filter the classes for lessons on the single course page.
3168
-     *
3169
-     * Adds the nesecary classes depending on the user data
3170
-     *
3171
-     * @since 1.9.0
3172
-     * @param array $classes
3173
-     * @return array $classes
3174
-     */
3175
-    public static function single_course_lessons_classes( $classes ){
3140
+		if( 'lesson-course' != $column_name ){
3141
+			return;
3142
+		}
3143
+		// load the script
3144
+		$suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3145
+		wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3146
+
3147
+		// setup the values for all meta fields
3148
+		$data = array();
3149
+		foreach( $this->meta_fields as $field ){
3150
+
3151
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3152
+
3153
+		}
3154
+		// add quiz meta fields
3155
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3156
+		foreach( Sensei()->quiz->meta_fields as $field ){
3157
+
3158
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3159
+
3160
+		}
3161
+
3162
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3163
+
3164
+	}// end quick edit admin defaults
3165
+
3166
+	/**
3167
+	 * Filter the classes for lessons on the single course page.
3168
+	 *
3169
+	 * Adds the nesecary classes depending on the user data
3170
+	 *
3171
+	 * @since 1.9.0
3172
+	 * @param array $classes
3173
+	 * @return array $classes
3174
+	 */
3175
+	public static function single_course_lessons_classes( $classes ){
3176 3176
 
3177
-        if(  is_singular('course') ){
3177
+		if(  is_singular('course') ){
3178 3178
 
3179
-            global $post;
3180
-            $course_id = $post->ID;
3179
+			global $post;
3180
+			$course_id = $post->ID;
3181 3181
 
3182
-            $lesson_classes = array( 'course', 'post' );
3183
-            if ( is_user_logged_in() ) {
3182
+			$lesson_classes = array( 'course', 'post' );
3183
+			if ( is_user_logged_in() ) {
3184 3184
 
3185
-                // Check if Lesson is complete
3186
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3187
-                if ( $single_lesson_complete ) {
3185
+				// Check if Lesson is complete
3186
+				$single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3187
+				if ( $single_lesson_complete ) {
3188 3188
 
3189
-                    $lesson_classes[] = 'lesson-completed';
3189
+					$lesson_classes[] = 'lesson-completed';
3190 3190
 
3191
-                } // End If Statement
3191
+				} // End If Statement
3192 3192
 
3193
-            } // End If Statement
3193
+			} // End If Statement
3194 3194
 
3195
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3196
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3195
+			$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3196
+			if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3197 3197
 
3198
-                $lesson_classes[] = 'lesson-preview';
3198
+				$lesson_classes[] = 'lesson-preview';
3199 3199
 
3200
-            }
3200
+			}
3201 3201
 
3202
-            $classes = array_merge( $classes, $lesson_classes  );
3202
+			$classes = array_merge( $classes, $lesson_classes  );
3203 3203
 
3204
-        }
3204
+		}
3205 3205
 
3206
-        return $classes;
3206
+		return $classes;
3207 3207
 
3208
-    }// end single_course_lessons_classes
3208
+	}// end single_course_lessons_classes
3209 3209
 
3210
-    /**
3211
-     * Output the lesson meta for the given lesson
3212
-     *
3213
-     * @since 1.9.0
3214
-     * @param $lesson_id
3215
-     */
3216
-    public static function the_lesson_meta( $lesson_id ){
3210
+	/**
3211
+	 * Output the lesson meta for the given lesson
3212
+	 *
3213
+	 * @since 1.9.0
3214
+	 * @param $lesson_id
3215
+	 */
3216
+	public static function the_lesson_meta( $lesson_id ){
3217 3217
 
3218
-        global $wp_query;
3219
-        $loop_lesson_number = $wp_query->current_post + 1;
3218
+		global $wp_query;
3219
+		$loop_lesson_number = $wp_query->current_post + 1;
3220 3220
 
3221
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3222
-        $single_lesson_complete = false;
3223
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3221
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
3222
+		$single_lesson_complete = false;
3223
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3224 3224
 
3225
-        // Get Lesson data
3226
-        $complexity_array = Sensei()->lesson->lesson_complexities();
3225
+		// Get Lesson data
3226
+		$complexity_array = Sensei()->lesson->lesson_complexities();
3227 3227
 
3228
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3229
-        if ( '' != $lesson_complexity ) {
3228
+		$lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3229
+		if ( '' != $lesson_complexity ) {
3230 3230
 
3231
-            $lesson_complexity = $complexity_array[$lesson_complexity];
3231
+			$lesson_complexity = $complexity_array[$lesson_complexity];
3232 3232
 
3233
-        }
3234
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3235
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3236
-        $preview_label = '';
3237
-        if ( $is_preview && !$is_user_taking_course ) {
3233
+		}
3234
+		$user_info = get_userdata( absint( get_post()->post_author ) );
3235
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3236
+		$preview_label = '';
3237
+		if ( $is_preview && !$is_user_taking_course ) {
3238 3238
 
3239
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3240
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3239
+			$preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3240
+			$preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3241 3241
 
3242
-        }
3242
+		}
3243 3243
 
3244 3244
 
3245
-        $count_markup= '';
3246
-        /**
3247
-         * Filter for if you want the $lesson_count to show next to the lesson.
3248
-         *
3249
-         * @since 1.0
3250
-         * @param bool default false.
3251
-         */
3252
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3245
+		$count_markup= '';
3246
+		/**
3247
+		 * Filter for if you want the $lesson_count to show next to the lesson.
3248
+		 *
3249
+		 * @since 1.0
3250
+		 * @param bool default false.
3251
+		 */
3252
+		if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3253 3253
 
3254
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3254
+			$count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3255 3255
 
3256
-        }
3256
+		}
3257 3257
 
3258
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3258
+		$heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3259 3259
 
3260
-        ?>
3260
+		?>
3261 3261
         <header>
3262 3262
             <h2>
3263 3263
                 <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
@@ -3270,40 +3270,40 @@  discard block
 block discarded – undo
3270 3270
 
3271 3271
                 <?php
3272 3272
 
3273
-                $meta_html = '';
3274
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3273
+				$meta_html = '';
3274
+				$user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3275 3275
 
3276
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3277
-                if ( '' != $lesson_length ) {
3276
+				$lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3277
+				if ( '' != $lesson_length ) {
3278 3278
 
3279
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3279
+					$meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3280 3280
 
3281
-                }
3281
+				}
3282 3282
 
3283
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3283
+				if ( Sensei()->settings->get( 'lesson_author' ) ) {
3284 3284
 
3285
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3285
+					$meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3286 3286
 
3287
-                } // End If Statement
3288
-                if ( '' != $lesson_complexity ) {
3287
+				} // End If Statement
3288
+				if ( '' != $lesson_complexity ) {
3289 3289
 
3290
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3290
+					$meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3291 3291
 
3292
-                }
3292
+				}
3293 3293
 
3294
-                if ( $single_lesson_complete ) {
3294
+				if ( $single_lesson_complete ) {
3295 3295
 
3296
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3296
+					$meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3297 3297
 
3298
-                } elseif ( $user_lesson_status ) {
3298
+				} elseif ( $user_lesson_status ) {
3299 3299
 
3300
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3300
+					$meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3301 3301
 
3302
-                } // End If Statement
3302
+				} // End If Statement
3303 3303
 
3304
-                echo $meta_html;
3304
+				echo $meta_html;
3305 3305
 
3306
-                ?>
3306
+				?>
3307 3307
 
3308 3308
             </p> <!-- lesson meta -->
3309 3309
 
@@ -3311,132 +3311,132 @@  discard block
 block discarded – undo
3311 3311
 
3312 3312
     <?php
3313 3313
 
3314
-    } // end the_lesson_meta
3314
+	} // end the_lesson_meta
3315 3315
 
3316
-    /**
3317
-     * Output the lessons thumbnail
3318
-     *
3319
-     * 1.9.0
3320
-     *
3321
-     * @param $lesson_id
3322
-     */
3323
-    public static function the_lesson_thumbnail( $lesson_id ){
3316
+	/**
3317
+	 * Output the lessons thumbnail
3318
+	 *
3319
+	 * 1.9.0
3320
+	 *
3321
+	 * @param $lesson_id
3322
+	 */
3323
+	public static function the_lesson_thumbnail( $lesson_id ){
3324 3324
 
3325
-        if( empty( $lesson_id ) ){
3325
+		if( empty( $lesson_id ) ){
3326 3326
 
3327
-            $lesson_id = get_the_ID();
3327
+			$lesson_id = get_the_ID();
3328 3328
 
3329
-        }
3329
+		}
3330 3330
 
3331
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3332
-            return;
3333
-        }
3331
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3332
+			return;
3333
+		}
3334 3334
 
3335
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3336
-    }
3335
+		echo Sensei()->lesson->lesson_image( $lesson_id );
3336
+	}
3337 3337
 
3338 3338
 
3339
-    /**
3340
-     * Alter the sensei lesson excerpt.
3341
-     *
3342
-     * @since 1.9.0
3343
-     * @param string $excerpt
3344
-     * @return string $excerpt
3345
-     */
3346
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3339
+	/**
3340
+	 * Alter the sensei lesson excerpt.
3341
+	 *
3342
+	 * @since 1.9.0
3343
+	 * @param string $excerpt
3344
+	 * @return string $excerpt
3345
+	 */
3346
+	public static function alter_the_lesson_excerpt( $excerpt ) {
3347 3347
 
3348
-        if ('lesson' == get_post_type(get_the_ID())){
3348
+		if ('lesson' == get_post_type(get_the_ID())){
3349 3349
 
3350
-            // remove this hooks to avoid an infinite loop.
3351
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3350
+			// remove this hooks to avoid an infinite loop.
3351
+			remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3352 3352
 
3353
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3354
-        }
3353
+			return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3354
+		}
3355 3355
 
3356
-        return $excerpt;
3356
+		return $excerpt;
3357 3357
 
3358
-    }// end the_lesson_excerpt
3358
+	}// end the_lesson_excerpt
3359 3359
 
3360
-    /**
3361
-     * Returns the lesson prerequisite for the given lesson id.
3362
-     *
3363
-     * @since 1.9.0
3364
-     *
3365
-     * @param $current_lesson_id
3366
-     * @return mixed | bool | int $prerequisite_lesson_id or false
3367
-     */
3368
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3360
+	/**
3361
+	 * Returns the lesson prerequisite for the given lesson id.
3362
+	 *
3363
+	 * @since 1.9.0
3364
+	 *
3365
+	 * @param $current_lesson_id
3366
+	 * @return mixed | bool | int $prerequisite_lesson_id or false
3367
+	 */
3368
+	public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3369 3369
 
3370
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3370
+		$prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3371 3371
 
3372
-        // set ti to false if not a valid prerequisite lesson id
3373
-        if(  empty( $prerequisite_lesson_id )
3374
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3375
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3372
+		// set ti to false if not a valid prerequisite lesson id
3373
+		if(  empty( $prerequisite_lesson_id )
3374
+			|| 'lesson' != get_post_type( $prerequisite_lesson_id )
3375
+			|| $prerequisite_lesson_id == $current_lesson_id  ) {
3376 3376
 
3377
-            $prerequisite_lesson_id = false;
3377
+			$prerequisite_lesson_id = false;
3378 3378
 
3379
-        }
3379
+		}
3380 3380
 
3381
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3381
+		return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3382 3382
 
3383
-    }
3383
+	}
3384 3384
 
3385
-    /**
3386
-     * This function requires that you pass in the lesson you would like to check for
3387
-     * a pre-requisite and not the pre-requisite. It will check if the
3388
-     * lesson has a pre-requiste and then check if it is completed.
3389
-     *
3390
-     * @since 1.9.0
3391
-     *
3392
-     * @param $lesson_id
3393
-     * @param $user_id
3394
-     * @return bool
3395
-     */
3396
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3385
+	/**
3386
+	 * This function requires that you pass in the lesson you would like to check for
3387
+	 * a pre-requisite and not the pre-requisite. It will check if the
3388
+	 * lesson has a pre-requiste and then check if it is completed.
3389
+	 *
3390
+	 * @since 1.9.0
3391
+	 *
3392
+	 * @param $lesson_id
3393
+	 * @param $user_id
3394
+	 * @return bool
3395
+	 */
3396
+	public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3397 3397
 
3398
-        if( empty( $lesson_id ) || empty( $user_id )
3399
-        || 'lesson' != get_post_type( $lesson_id )
3400
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3398
+		if( empty( $lesson_id ) || empty( $user_id )
3399
+		|| 'lesson' != get_post_type( $lesson_id )
3400
+		||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3401 3401
 
3402
-            return false;
3402
+			return false;
3403 3403
 
3404
-        }
3404
+		}
3405 3405
 
3406
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3406
+		$pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3407 3407
 
3408
-        // not a valid pre-requisite so pre-requisite is completed
3409
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3410
-            || ! is_numeric( $pre_requisite_id ) ){
3408
+		// not a valid pre-requisite so pre-requisite is completed
3409
+		if( 'lesson' != get_post_type( $pre_requisite_id )
3410
+			|| ! is_numeric( $pre_requisite_id ) ){
3411 3411
 
3412
-            return true;
3412
+			return true;
3413 3413
 
3414
-        }
3414
+		}
3415 3415
 
3416
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3416
+		return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3417 3417
 
3418
-    }// end is_prerequisite_complete
3418
+	}// end is_prerequisite_complete
3419 3419
 
3420
-    /**
3421
-     * Show the user not taking course message if it is the case
3422
-     *
3423
-     * @since 1.9.0
3424
-     */
3425
-    public  static function user_not_taking_course_message(){
3420
+	/**
3421
+	 * Show the user not taking course message if it is the case
3422
+	 *
3423
+	 * @since 1.9.0
3424
+	 */
3425
+	public  static function user_not_taking_course_message(){
3426 3426
 
3427
-        $lesson_id = get_the_ID();
3427
+		$lesson_id = get_the_ID();
3428 3428
 
3429
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3430
-            return;
3431
-        }
3429
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3430
+			return;
3431
+		}
3432 3432
 
3433
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3434
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3435
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3436
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3433
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3434
+		$pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3435
+		$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3436
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3437 3437
 
3438
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3439
-            ?>
3438
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3439
+			?>
3440 3440
 
3441 3441
             <div class="sensei-message alert">
3442 3442
                 <?php echo Sensei()->permissions_message['message']; ?>
@@ -3444,46 +3444,46 @@  discard block
 block discarded – undo
3444 3444
 
3445 3445
             <?php
3446 3446
 
3447
-        }// end if
3447
+		}// end if
3448 3448
 
3449
-    } // end user_not_taking_course_message
3449
+	} // end user_not_taking_course_message
3450 3450
 
3451
-    /**
3452
-     * Outputs the lessons course signup lingk
3453
-     *
3454
-     * This hook runs inside the single lesson page.
3455
-     *
3456
-     * @since 1.9.0
3457
-     */
3458
-    public static function course_signup_link( ){
3451
+	/**
3452
+	 * Outputs the lessons course signup lingk
3453
+	 *
3454
+	 * This hook runs inside the single lesson page.
3455
+	 *
3456
+	 * @since 1.9.0
3457
+	 */
3458
+	public static function course_signup_link( ){
3459 3459
 
3460
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3460
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3461 3461
 
3462
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3462
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3463 3463
 
3464
-            return;
3464
+			return;
3465 3465
 
3466
-        }
3467
-        ?>
3466
+		}
3467
+		?>
3468 3468
 
3469 3469
         <section class="course-signup lesson-meta">
3470 3470
 
3471 3471
             <?php
3472
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3472
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3473 3473
 
3474
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3474
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3475 3475
 
3476
-                global $current_user;
3477
-                if( is_user_logged_in() ) {
3478
-                    wp_get_current_user();
3476
+				global $current_user;
3477
+				if( is_user_logged_in() ) {
3478
+					wp_get_current_user();
3479 3479
 
3480
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3480
+					$course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3481 3481
 
3482
-                    if( $course_purchased ) {
3482
+					if( $course_purchased ) {
3483 3483
 
3484
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3485
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3486
-                        ?>
3484
+						$prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3485
+						$course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3486
+						?>
3487 3487
                             <div class="sensei-message info">
3488 3488
 
3489 3489
                                 <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
@@ -3495,14 +3495,14 @@  discard block
 block discarded – undo
3495 3495
                         <div class="sensei-message info">
3496 3496
 
3497 3497
                             <?php
3498
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3499
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3500
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3501
-                                            . '</a>';
3498
+							$course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3499
+											. '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3500
+											. '">' . __( 'course', 'woothemes-sensei' )
3501
+											. '</a>';
3502 3502
 
3503
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3503
+							echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3504 3504
 
3505
-                            ?>
3505
+							?>
3506 3506
 
3507 3507
                         </div>
3508 3508
                     <?php } ?>
@@ -3519,14 +3519,14 @@  discard block
 block discarded – undo
3519 3519
 
3520 3520
                 <div class="sensei-message info">
3521 3521
                     <?php
3522
-                    $course_link =  '<a href="'
3523
-                                        . esc_url( get_permalink( $course_id ) )
3524
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3525
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3526
-                                    . '</a>';
3527
-
3528
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3529
-                    ?>
3522
+					$course_link =  '<a href="'
3523
+										. esc_url( get_permalink( $course_id ) )
3524
+										. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3525
+										. '">' . __( 'course', 'woothemes-sensei' )
3526
+									. '</a>';
3527
+
3528
+					echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3529
+					?>
3530 3530
                 </div>
3531 3531
 
3532 3532
             <?php endif; ?>
@@ -3536,75 +3536,75 @@  discard block
 block discarded – undo
3536 3536
         </section>
3537 3537
 
3538 3538
         <?php
3539
-    }// end course_signup_link
3539
+	}// end course_signup_link
3540 3540
 
3541
-    /**
3542
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3543
-     *
3544
-     * @since 1.9.0
3545
-     */
3546
-    public  static function prerequisite_complete_message(){
3541
+	/**
3542
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3543
+	 *
3544
+	 * @since 1.9.0
3545
+	 */
3546
+	public  static function prerequisite_complete_message(){
3547 3547
 
3548
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3549
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3550
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3548
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3549
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3550
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3551 3551
 
3552
-            $prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3553
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3552
+			$prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3553
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3554 3554
 
3555
-        }
3555
+		}
3556 3556
 
3557
-    }
3557
+	}
3558 3558
 
3559
-    /**
3560
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3561
-     * active for backwards compatibility.
3562
-     *
3563
-     * @deprecated since 1.9.0
3564
-     */
3565
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3559
+	/**
3560
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3561
+	 * active for backwards compatibility.
3562
+	 *
3563
+	 * @deprecated since 1.9.0
3564
+	 */
3565
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3566 3566
 
3567
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3567
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3568 3568
 
3569
-    }
3569
+	}
3570 3570
 
3571
-    /**
3572
-     * Outputs the the lesson archive header.
3573
-     *
3574
-     * @since  1.9.0
3575
-     * @return void
3576
-     */
3577
-    public function the_archive_header( ) {
3571
+	/**
3572
+	 * Outputs the the lesson archive header.
3573
+	 *
3574
+	 * @since  1.9.0
3575
+	 * @return void
3576
+	 */
3577
+	public function the_archive_header( ) {
3578 3578
 
3579
-        $before_html = '<header class="archive-header"><h1>';
3580
-        $after_html = '</h1></header>';
3581
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3579
+		$before_html = '<header class="archive-header"><h1>';
3580
+		$after_html = '</h1></header>';
3581
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3582 3582
 
3583
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3583
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3584 3584
 
3585
-    } // sensei_course_archive_header()
3585
+	} // sensei_course_archive_header()
3586 3586
 
3587
-    /**
3588
-     * Output the title for the single lesson page
3589
-     *
3590
-     * @global $post
3591
-     * @since 1.9.0
3592
-     */
3593
-    public static function the_title(){
3587
+	/**
3588
+	 * Output the title for the single lesson page
3589
+	 *
3590
+	 * @global $post
3591
+	 * @since 1.9.0
3592
+	 */
3593
+	public static function the_title(){
3594 3594
 
3595
-        global $post;
3595
+		global $post;
3596 3596
 
3597
-        ?>
3597
+		?>
3598 3598
         <header>
3599 3599
 
3600 3600
             <h1>
3601 3601
 
3602 3602
                 <?php
3603
-                /**
3604
-                 * Filter documented in class-sensei-messages.php the_title
3605
-                 */
3606
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3607
-                ?>
3603
+				/**
3604
+				 * Filter documented in class-sensei-messages.php the_title
3605
+				 */
3606
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3607
+				?>
3608 3608
 
3609 3609
             </h1>
3610 3610
 
@@ -3612,68 +3612,68 @@  discard block
 block discarded – undo
3612 3612
 
3613 3613
         <?php
3614 3614
 
3615
-    }//the_title
3615
+	}//the_title
3616 3616
 
3617
-    /**
3618
-     * Flush the rewrite rules for a lesson post type
3619
-     *
3620
-     * @since 1.9.0
3621
-     *
3622
-     * @param $post_id
3623
-     */
3624
-    public static function flush_rewrite_rules( $post_id ){
3617
+	/**
3618
+	 * Flush the rewrite rules for a lesson post type
3619
+	 *
3620
+	 * @since 1.9.0
3621
+	 *
3622
+	 * @param $post_id
3623
+	 */
3624
+	public static function flush_rewrite_rules( $post_id ){
3625 3625
 
3626
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3626
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3627 3627
 
3628
-            return;
3628
+			return;
3629 3629
 
3630
-        }
3630
+		}
3631 3631
 
3632 3632
 
3633
-        if( 'lesson' == get_post_type( $post_id )  ){
3633
+		if( 'lesson' == get_post_type( $post_id )  ){
3634 3634
 
3635
-            Sensei()->initiate_rewrite_rules_flush();
3635
+			Sensei()->initiate_rewrite_rules_flush();
3636 3636
 
3637
-        }
3637
+		}
3638 3638
 
3639
-    }
3639
+	}
3640 3640
 
3641
-    /**
3642
-     * Output the quiz specific buttons and messaging on the single lesson page
3643
-     *
3644
-     *
3645
-     * @since 1.0.0 moved here from frontend class
3646
-     *
3647
-     * @param int $lesson_id
3648
-     * @param int $user_id
3649
-     */
3650
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3641
+	/**
3642
+	 * Output the quiz specific buttons and messaging on the single lesson page
3643
+	 *
3644
+	 *
3645
+	 * @since 1.0.0 moved here from frontend class
3646
+	 *
3647
+	 * @param int $lesson_id
3648
+	 * @param int $user_id
3649
+	 */
3650
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3651 3651
 
3652 3652
 
3653
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3654
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3655
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3656
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3657
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3658
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3659
-        $show_actions              = is_user_logged_in() ? true : false;
3653
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3654
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3655
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3656
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3657
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3658
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3659
+		$show_actions              = is_user_logged_in() ? true : false;
3660 3660
 
3661
-        if( intval( $lesson_prerequisite ) > 0 ) {
3661
+		if( intval( $lesson_prerequisite ) > 0 ) {
3662 3662
 
3663
-            // If the user hasn't completed the prereq then hide the current actions
3664
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3663
+			// If the user hasn't completed the prereq then hide the current actions
3664
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3665 3665
 
3666
-        }
3667
-        ?>
3666
+		}
3667
+		?>
3668 3668
 
3669 3669
         <footer>
3670 3670
 
3671 3671
             <?php
3672
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3672
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3673 3673
 
3674
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3675
-                if( $has_quiz_questions ) {
3676
-                    ?>
3674
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3675
+				if( $has_quiz_questions ) {
3676
+					?>
3677 3677
 
3678 3678
                     <p>
3679 3679
 
@@ -3688,87 +3688,87 @@  discard block
 block discarded – undo
3688 3688
                     </p>
3689 3689
 
3690 3690
                     <?php
3691
-                }
3691
+				}
3692 3692
 
3693
-            } // End If Statement
3693
+			} // End If Statement
3694 3694
 
3695
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3695
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3696 3696
 
3697
-                sensei_complete_lesson_button();
3697
+				sensei_complete_lesson_button();
3698 3698
 
3699
-            } elseif( $show_actions ) {
3699
+			} elseif( $show_actions ) {
3700 3700
 
3701
-                sensei_reset_lesson_button();
3701
+				sensei_reset_lesson_button();
3702 3702
 
3703
-            } // End If Statement
3704
-            ?>
3703
+			} // End If Statement
3704
+			?>
3705 3705
 
3706 3706
         </footer>
3707 3707
 
3708 3708
         <?php
3709
-    } // End sensei_lesson_quiz_meta()
3709
+	} // End sensei_lesson_quiz_meta()
3710 3710
 
3711
-    /**
3712
-     * Show the lesson comments. This should be used in the loop.
3713
-     *
3714
-     * @since 1.9.0
3715
-     */
3716
-    public static function output_comments(){
3711
+	/**
3712
+	 * Show the lesson comments. This should be used in the loop.
3713
+	 *
3714
+	 * @since 1.9.0
3715
+	 */
3716
+	public static function output_comments(){
3717 3717
 
3718
-        if( ! is_user_logged_in() ){
3719
-            return;
3720
-        }
3718
+		if( ! is_user_logged_in() ){
3719
+			return;
3720
+		}
3721 3721
 
3722
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3723
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3724
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3725
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3722
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3723
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3724
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3725
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3726 3726
 
3727
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3727
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3728 3728
 
3729
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3729
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3730 3730
 
3731
-            comments_template();
3731
+			comments_template();
3732 3732
 
3733
-        } // End If Statement
3733
+		} // End If Statement
3734 3734
 
3735
-    } //output_comments
3735
+	} //output_comments
3736 3736
 
3737
-    /**
3738
-     * Display the leeson quiz status if it should be shown
3739
-     *
3740
-     * @param int $lesson_id defaults to the global lesson id
3741
-     * @param int $user_id defaults to the current user id
3742
-     *
3743
-     * @since 1.9.0
3744
-     */
3745
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3737
+	/**
3738
+	 * Display the leeson quiz status if it should be shown
3739
+	 *
3740
+	 * @param int $lesson_id defaults to the global lesson id
3741
+	 * @param int $user_id defaults to the current user id
3742
+	 *
3743
+	 * @since 1.9.0
3744
+	 */
3745
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3746 3746
 
3747
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3748
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3749
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3750
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3751
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3747
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3748
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3749
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3750
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3751
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3752 3752
 
3753 3753
 
3754
-        if ( $quiz_id && is_user_logged_in()
3755
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3754
+		if ( $quiz_id && is_user_logged_in()
3755
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3756 3756
 
3757
-            $no_quiz_count = 0;
3758
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3757
+			$no_quiz_count = 0;
3758
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3759 3759
 
3760
-            // Display lesson quiz status message
3761
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3762
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3763
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3764
-                if( $has_quiz_questions ) {
3765
-                   // echo $status['extra'];
3766
-                } // End If Statement
3767
-            } // End If Statement
3760
+			// Display lesson quiz status message
3761
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3762
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3763
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3764
+				if( $has_quiz_questions ) {
3765
+				   // echo $status['extra'];
3766
+				} // End If Statement
3767
+			} // End If Statement
3768 3768
 
3769
-        }
3769
+		}
3770 3770
 
3771
-    }
3771
+	}
3772 3772
 
3773 3773
 } // End Class
3774 3774
 
Please login to merge, or discard this patch.
includes/class-sensei-analysis-user-profile-list-table.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
 
202 202
 		if( 'complete' == $item->comment_approved ) {
203 203
 
204
-            $status =  __( 'Completed', 'woothemes-sensei' );
204
+			$status =  __( 'Completed', 'woothemes-sensei' );
205 205
 			$status_class = 'graded';
206 206
 
207 207
 			$course_end_date = $item->comment_date;
Please login to merge, or discard this patch.
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   +78 added lines, -78 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 Analysis User Profile List Table Class
@@ -21,17 +21,17 @@  discard block
 block discarded – undo
21 21
 	 * @since  1.2.0
22 22
 	 * @return  void
23 23
 	 */
24
-	public function __construct ( $user_id = 0 ) {
25
-		$this->user_id = intval( $user_id );
24
+	public function __construct($user_id = 0) {
25
+		$this->user_id = intval($user_id);
26 26
 
27 27
 		// Load Parent token into constructor
28
-		parent::__construct( 'analysis_user_profile' );
28
+		parent::__construct('analysis_user_profile');
29 29
 
30 30
 		// Actions
31
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
32
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
31
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
32
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
33 33
 
34
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
34
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
35 35
 	} // End __construct()
36 36
 
37 37
 	/**
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	function get_columns() {
43 43
 		$columns = array(
44
-			'title' => __( 'Course', 'woothemes-sensei' ),
45
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
46
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
47
-			'status' => __( 'Status', 'woothemes-sensei' ),
44
+			'title' => __('Course', 'woothemes-sensei'),
45
+			'started' => __('Date Started', 'woothemes-sensei'),
46
+			'completed' => __('Date Completed', 'woothemes-sensei'),
47
+			'status' => __('Status', 'woothemes-sensei'),
48 48
 //			'grade' => __( 'Grade', 'woothemes-sensei' ),
49
-			'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
49
+			'percent' => __('Percent Complete', 'woothemes-sensei'),
50 50
 		);
51
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns', $columns );
51
+		$columns = apply_filters('sensei_analysis_user_profile_columns', $columns);
52 52
 		return $columns;
53 53
 	}
54 54
 
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	function get_sortable_columns() {
61 61
 		$columns = array(
62
-			'title' => array( 'title', false ),
63
-			'started' => array( 'started', false ),
64
-			'completed' => array( 'completed', false ),
65
-			'status' => array( 'status', false ),
62
+			'title' => array('title', false),
63
+			'started' => array('started', false),
64
+			'completed' => array('completed', false),
65
+			'status' => array('status', false),
66 66
 //			'grade' => array( 'grade', false ),
67
-			'percent' => array( 'percent', false )
67
+			'percent' => array('percent', false)
68 68
 		);
69
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns_sortable', $columns );
69
+		$columns = apply_filters('sensei_analysis_user_profile_columns_sortable', $columns);
70 70
 		return $columns;
71 71
 	}
72 72
 
@@ -80,32 +80,32 @@  discard block
 block discarded – undo
80 80
 
81 81
 		// Handle orderby (needs work)
82 82
 		$orderby = '';
83
-		if ( !empty( $_GET['orderby'] ) ) {
84
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
85
-				$orderby = esc_html( $_GET['orderby'] );
83
+		if ( ! empty($_GET['orderby'])) {
84
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
85
+				$orderby = esc_html($_GET['orderby']);
86 86
 			} // End If Statement
87 87
 		}
88 88
 
89 89
 		// Handle order
90 90
 		$order = 'ASC';
91
-		if ( !empty( $_GET['order'] ) ) {
92
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
91
+		if ( ! empty($_GET['order'])) {
92
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
93 93
 		}
94 94
 
95 95
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
96 96
 		$search = false;
97
-		if ( !empty( $_GET['s'] ) ) {
98
-			$search = esc_html( $_GET['s'] );
97
+		if ( ! empty($_GET['s'])) {
98
+			$search = esc_html($_GET['s']);
99 99
 		} // End If Statement
100 100
 		$this->search = $search;
101 101
 
102
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
103
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
102
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
103
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
104 104
 
105 105
 		$paged = $this->get_pagenum();
106 106
 		$offset = 0;
107
-		if ( !empty($paged) ) {
108
-			$offset = $per_page * ( $paged - 1 );
107
+		if ( ! empty($paged)) {
108
+			$offset = $per_page * ($paged - 1);
109 109
 		} // End If Statement
110 110
 
111 111
 		$args = array(
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 			'orderby' => $orderby,
115 115
 			'order' => $order,
116 116
 		);
117
-		if ( $this->search ) {
117
+		if ($this->search) {
118 118
 			$args['search'] = $this->search;
119 119
 		} // End If Statement
120 120
 
121
-		$this->items = $this->get_course_statuses( $args );
121
+		$this->items = $this->get_course_statuses($args);
122 122
 
123 123
 		$total_items = $this->total_items;
124
-		$total_pages = ceil( $total_items / $per_page );
125
-		$this->set_pagination_args( array(
124
+		$total_pages = ceil($total_items / $per_page);
125
+		$this->set_pagination_args(array(
126 126
 			'total_items' => $total_items,
127 127
 			'total_pages' => $total_pages,
128 128
 			'per_page' => $per_page
129
-		) );
129
+		));
130 130
 	}
131 131
 
132 132
 	/**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @since  1.7.0
135 135
 	 * @return data
136 136
 	 */
137
-	public function generate_report( $report ) {
137
+	public function generate_report($report) {
138 138
 
139 139
 		$data = array();
140 140
 
@@ -142,22 +142,22 @@  discard block
 block discarded – undo
142 142
 
143 143
 		// Handle orderby
144 144
 		$orderby = '';
145
-		if ( !empty( $_GET['orderby'] ) ) {
146
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
147
-				$orderby = esc_html( $_GET['orderby'] );
145
+		if ( ! empty($_GET['orderby'])) {
146
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
147
+				$orderby = esc_html($_GET['orderby']);
148 148
 			} // End If Statement
149 149
 		}
150 150
 
151 151
 		// Handle order
152 152
 		$order = 'ASC';
153
-		if ( !empty( $_GET['order'] ) ) {
154
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
153
+		if ( ! empty($_GET['order'])) {
154
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
155 155
 		}
156 156
 
157 157
 		// Handle search
158 158
 		$search = false;
159
-		if ( !empty( $_GET['s'] ) ) {
160
-			$search = esc_html( $_GET['s'] );
159
+		if ( ! empty($_GET['s'])) {
160
+			$search = esc_html($_GET['s']);
161 161
 		} // End If Statement
162 162
 		$this->search = $search;
163 163
 
@@ -165,23 +165,23 @@  discard block
 block discarded – undo
165 165
 			'orderby' => $orderby,
166 166
 			'order' => $order,
167 167
 		);
168
-		if ( $this->search ) {
168
+		if ($this->search) {
169 169
 			$args['search'] = $this->search;
170 170
 		} // End If Statement
171 171
 
172 172
 		// Start the csv with the column headings
173 173
 		$column_headers = array();
174 174
 		$columns = $this->get_columns();
175
-		foreach( $columns AS $key => $title ) {
175
+		foreach ($columns AS $key => $title) {
176 176
 			$column_headers[] = $title;
177 177
 		}
178 178
 		$data[] = $column_headers;
179 179
 
180
-		$this->items = $this->get_course_statuses( $args );
180
+		$this->items = $this->get_course_statuses($args);
181 181
 
182 182
 		// Process each row
183
-		foreach( $this->items AS $item) {
184
-			$data[] = $this->get_row_data( $item );
183
+		foreach ($this->items AS $item) {
184
+			$data[] = $this->get_row_data($item);
185 185
 		}
186 186
 
187 187
 		return $data;
@@ -192,43 +192,43 @@  discard block
 block discarded – undo
192 192
 	 * @since  1.7.0
193 193
 	 * @param object $item The current item
194 194
 	 */
195
-	protected function get_row_data( $item ) {
195
+	protected function get_row_data($item) {
196 196
 
197
-		$course_title =  get_the_title( $item->comment_post_ID );
198
-		$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
199
-		$course_start_date = get_comment_meta( $item->comment_ID, 'start', true );
197
+		$course_title = get_the_title($item->comment_post_ID);
198
+		$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
199
+		$course_start_date = get_comment_meta($item->comment_ID, 'start', true);
200 200
 		$course_end_date = '';
201 201
 
202
-		if( 'complete' == $item->comment_approved ) {
202
+		if ('complete' == $item->comment_approved) {
203 203
 
204
-            $status =  __( 'Completed', 'woothemes-sensei' );
204
+            $status = __('Completed', 'woothemes-sensei');
205 205
 			$status_class = 'graded';
206 206
 
207 207
 			$course_end_date = $item->comment_date;
208 208
 
209 209
 		} else {
210 210
 
211
-			$status =  __( 'In Progress', 'woothemes-sensei' );
211
+			$status = __('In Progress', 'woothemes-sensei');
212 212
 			$status_class = 'in-progress';
213 213
 
214 214
 		}
215 215
 
216 216
 		// Output users data
217
-		if ( !$this->csv_output ) {
218
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) );
217
+		if ( ! $this->csv_output) {
218
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID), admin_url('admin.php'));
219 219
 
220
-			$course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $course_title . '</a></strong>';
221
-			$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
222
-			if ( is_numeric($course_percent) ) {
220
+			$course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.$course_title.'</a></strong>';
221
+			$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
222
+			if (is_numeric($course_percent)) {
223 223
 				$course_percent .= '%';
224 224
 			}
225 225
 		} // End If Statement
226
-		$column_data = apply_filters( 'sensei_analysis_user_profile_column_data', array( 'title' => $course_title,
226
+		$column_data = apply_filters('sensei_analysis_user_profile_column_data', array('title' => $course_title,
227 227
 										'started' => $course_start_date,
228 228
 										'completed' => $course_end_date,
229 229
 										'status' => $status,
230 230
 										'percent' => $course_percent,
231
-									), $item );
231
+									), $item);
232 232
 
233 233
 		return $column_data;
234 234
 	}
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @since  1.7.0
239 239
 	 * @return array statuses
240 240
 	 */
241
-	private function get_course_statuses( $args ) {
241
+	private function get_course_statuses($args) {
242 242
 
243 243
 		$activity_args = array( 
244 244
 				'user_id' => $this->user_id,
@@ -250,23 +250,23 @@  discard block
 block discarded – undo
250 250
 				'status' => 'any',
251 251
 			);
252 252
 
253
-		$activity_args = apply_filters( 'sensei_analysis_user_profile_filter_statuses', $activity_args );
253
+		$activity_args = apply_filters('sensei_analysis_user_profile_filter_statuses', $activity_args);
254 254
 
255 255
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
256
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
256
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
257 257
 
258 258
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
259
-		if ( $this->total_items < $activity_args['offset'] ) {
259
+		if ($this->total_items < $activity_args['offset']) {
260 260
 
261
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
261
+			$new_paged = floor($this->total_items / $activity_args['number']);
262 262
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
263 263
 
264 264
 		}
265
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
265
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
266 266
 
267 267
 		// Need to always return an array, even with only 1 item
268
-		if ( !is_array($statuses) ) {
269
-			$statuses = array( $statuses );
268
+		if ( ! is_array($statuses)) {
269
+			$statuses = array($statuses);
270 270
 		}
271 271
 
272 272
 		return $statuses;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return void
280 280
 	 */
281 281
 	public function no_items() {
282
-		echo  __( 'No courses found.', 'woothemes-sensei' );
282
+		echo  __('No courses found.', 'woothemes-sensei');
283 283
 	} // End no_items()
284 284
 
285 285
 	/**
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @return void
289 289
 	 */
290 290
 	public function data_table_header() {
291
-		echo '<strong>' . __( 'Courses', 'woothemes-sensei' ) . '</strong>';
291
+		echo '<strong>'.__('Courses', 'woothemes-sensei').'</strong>';
292 292
 	}
293 293
 
294 294
 	/**
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 	 * @return void
298 298
 	 */
299 299
 	public function data_table_footer() {
300
-		$user = get_user_by( 'id', $this->user_id );
301
-		$report = sanitize_title( $user->display_name ) . '-course-overview';
302
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
303
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
300
+		$user = get_user_by('id', $this->user_id);
301
+		$report = sanitize_title($user->display_name).'-course-overview';
302
+		$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report), admin_url('admin.php'));
303
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
304 304
 	}
305 305
 
306 306
 	/**
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	 * @since  1.7.0
309 309
 	 * @return void
310 310
 	 */
311
-	public function search_button( $text = '' ) {
312
-		return __( 'Search Courses', 'woothemes-sensei' );;
311
+	public function search_button($text = '') {
312
+		return __('Search Courses', 'woothemes-sensei'); ;
313 313
 	}
314 314
 
315 315
 } // End Class
Please login to merge, or discard this patch.
includes/class-sensei-admin.php 4 patches
Braces   +18 added lines, -9 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 Administration Class
@@ -210,13 +213,15 @@  discard block
 block discarded – undo
210 213
 
211 214
 		$option_value = get_option( $option );
212 215
 
213
-		if ( $option_value > 0 && get_post( $option_value ) )
214
-			return;
216
+		if ( $option_value > 0 && get_post( $option_value ) ) {
217
+					return;
218
+		}
215 219
 
216 220
 		$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );
217 221
 		if ( $page_found ) :
218
-			if ( ! $option_value )
219
-				update_option( $option, $page_found );
222
+			if ( ! $option_value ) {
223
+							update_option( $option, $page_found );
224
+			}
220 225
 			return;
221 226
 		endif;
222 227
 
@@ -723,7 +728,9 @@  discard block
 block discarded – undo
723 728
 		$types = array( 'course', 'lesson', 'question' );
724 729
 
725 730
 		foreach( $types as $type ) {
726
-			if( ! post_type_exists( $type ) ) continue;
731
+			if( ! post_type_exists( $type ) ) {
732
+				continue;
733
+			}
727 734
 
728 735
 			$num_posts = wp_count_posts( $type );
729 736
 
@@ -791,7 +798,9 @@  discard block
 block discarded – undo
791 798
 
792 799
 		$html = '';
793 800
 
794
-		if( 0 == count( $settings ) ) return $html;
801
+		if( 0 == count( $settings ) ) {
802
+			return $html;
803
+		}
795 804
 
796 805
 		$html .= '<div class="sensei-options-panel">' . "\n";
797 806
 
@@ -873,11 +882,11 @@  discard block
 block discarded – undo
873 882
                                     //backwards compatibility
874 883
                                     if( empty( $data ) || 'on' == $data ){
875 884
                                         $checked_value = 'on';
876
-                                    }elseif( 'yes' == $data  ) {
885
+                                    } elseif( 'yes' == $data  ) {
877 886
 
878 887
                                         $checked_value = 'yes';
879 888
 
880
-                                    }elseif( 'auto' == $data  ) {
889
+                                    } elseif( 'auto' == $data  ) {
881 890
 
882 891
                                         $checked_value = 'auto';
883 892
 
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @access public
201 201
 	 * @param mixed $slug
202
-	 * @param mixed $option
202
+	 * @param string $option
203 203
 	 * @param string $page_title (default: '')
204 204
 	 * @param string $page_content (default: '')
205 205
 	 * @param int $post_parent (default: 0)
@@ -1047,6 +1047,9 @@  discard block
 block discarded – undo
1047 1047
 		?></div><?php
1048 1048
 	}
1049 1049
 
1050
+	/**
1051
+	 * @return string
1052
+	 */
1050 1053
 	public function get_course_order() {
1051 1054
 		return get_option( 'sensei_course_order', '' );
1052 1055
 	}
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	public function __construct () {
22 22
 
23
-        //register admin styles
23
+		//register admin styles
24 24
 		add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) );
25 25
 
26
-        //register admin scripts
27
-        add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
26
+		//register admin scripts
27
+		add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
28 28
 
29 29
 		add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) );
30 30
 		add_action( 'settings_before_form', array( $this, 'install_pages_output' ) );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
34 34
 		add_action( 'admin_init', array( $this, 'page_redirect' ) );
35 35
 		add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
36
-        add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
36
+		add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
37 37
 
38 38
 		// Duplicate lesson & courses
39 39
 		add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 );
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 		if( $menu_cap ) {
86 86
 			$menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' );
87
-            add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
87
+			add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
88 88
 		}
89 89
 
90 90
 		add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) );
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
 			$submenu_file = 'edit-tags.php?taxonomy=course-category&amp;post_type=course';
142 142
 			$parent_file  = 'edit.php?post_type=course';
143 143
 
144
-        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
144
+		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
145 145
 
146
-            $submenu_file = 'edit-tags.php?taxonomy=module';
147
-            $parent_file  = 'edit.php?post_type=course';
146
+			$submenu_file = 'edit-tags.php?taxonomy=module';
147
+			$parent_file  = 'edit.php?post_type=course';
148 148
 
149 149
 		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) {
150 150
 
151
-            $submenu_file = 'edit.php?post_type=sensei_message';
151
+			$submenu_file = 'edit.php?post_type=sensei_message';
152 152
 			$parent_file  = 'sensei';
153 153
 
154 154
 		}
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	function install_pages_output() {
178 178
 
179
-        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
179
+		if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
180 180
 
181
-            ?>
181
+			?>
182 182
             <div id="message" class="updated sensei-message sensei-connect">
183 183
                 <p><?php _e( '<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p>
184 184
                 <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a>
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
             </div>
187 187
             <?php
188 188
 
189
-        }
189
+		}
190 190
 
191 191
 	} // End install_pages_output()
192 192
 
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
 		endif;
219 219
 
220 220
 		$page_data = array(
221
-	        'post_status' 		=> 'publish',
222
-	        'post_type' 		=> 'page',
223
-	        'post_author' 		=> 1,
224
-	        'post_name' 		=> $slug,
225
-	        'post_title' 		=> $page_title,
226
-	        'post_content' 		=> $page_content,
227
-	        'post_parent' 		=> $post_parent,
228
-	        'comment_status' 	=> 'closed'
229
-	    );
230
-	    $page_id = wp_insert_post( $page_data );
231
-
232
-	    update_option( $option, $page_id );
221
+			'post_status' 		=> 'publish',
222
+			'post_type' 		=> 'page',
223
+			'post_author' 		=> 1,
224
+			'post_name' 		=> $slug,
225
+			'post_title' 		=> $page_title,
226
+			'post_content' 		=> $page_content,
227
+			'post_parent' 		=> $post_parent,
228
+			'comment_status' 	=> 'closed'
229
+		);
230
+		$page_id = wp_insert_post( $page_data );
231
+
232
+		update_option( $option, $page_id );
233 233
 	} // End create_page()
234 234
 
235 235
 
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	function create_pages() {
243 243
 
244 244
 		// Courses page
245
-	    $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
245
+		$this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
246 246
 
247 247
 		// User Dashboard page
248
-	    $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
248
+		$this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
249 249
 
250 250
 	} // End create_pages()
251 251
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 		wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' );
267 267
 		wp_enqueue_style( 'woothemes-sensei-global' );
268 268
 
269
-        // Select 2 styles
270
-        wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
269
+		// Select 2 styles
270
+		wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
271 271
 
272 272
 		// Test for Write Panel Pages
273 273
 		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
@@ -280,32 +280,32 @@  discard block
 block discarded – undo
280 280
 	} // End admin_styles_global()
281 281
 
282 282
 
283
-    /**
284
-     * Globally register all scripts needed in admin.
285
-     *
286
-     * The script users should enqueue the script when needed.
287
-     *
288
-     * @since 1.8.2
289
-     * @access public
290
-     */
291
-    public function register_scripts( $hook ){
283
+	/**
284
+	 * Globally register all scripts needed in admin.
285
+	 *
286
+	 * The script users should enqueue the script when needed.
287
+	 *
288
+	 * @since 1.8.2
289
+	 * @access public
290
+	 */
291
+	public function register_scripts( $hook ){
292 292
 
293
-        $screen = get_current_screen();
293
+		$screen = get_current_screen();
294 294
 
295
-        // Allow developers to load non-minified versions of scripts
296
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
295
+		// Allow developers to load non-minified versions of scripts
296
+		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
297 297
 
298
-        // Select2 script used to enhance all select boxes
299
-        wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
298
+		// Select2 script used to enhance all select boxes
299
+		wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
300 300
 
301
-        // load edit module scripts
302
-        if( 'edit-module' ==  $screen->id ){
301
+		// load edit module scripts
302
+		if( 'edit-module' ==  $screen->id ){
303 303
 
304
-            wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
304
+			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
305 305
 
306
-        }
306
+		}
307 307
 
308
-    }
308
+	}
309 309
 
310 310
 
311 311
 	/**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @return void
316 316
 	 */
317 317
 	function admin_install_notice() {
318
-	    ?>
318
+		?>
319 319
 	    <div id="message" class="updated sensei-message sensei-connect">
320 320
 
321 321
             <p>
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 * @return void
351 351
 	 */
352 352
 	function admin_installed_notice() {
353
-	    ?>
353
+		?>
354 354
 	    <div id="message" class="updated sensei-message sensei-connect">
355 355
 
356 356
 	    	<p>
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	    </div>
379 379
 	    <?php
380 380
 
381
-	    // Set installed option
382
-	    update_option('sensei_installed', 0);
381
+		// Set installed option
382
+		update_option('sensei_installed', 0);
383 383
 	} // End admin_installed_notice()
384 384
 
385 385
 
@@ -411,21 +411,21 @@  discard block
 block discarded – undo
411 411
 	function admin_notices_styles() {
412 412
 
413 413
 		// Installed notices
414
-	    if ( 1 == get_option( 'sensei_installed' ) ) {
414
+		if ( 1 == get_option( 'sensei_installed' ) ) {
415 415
 
416
-	    	wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
416
+			wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
417 417
 
418
-	    	if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
419
-	    		add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
420
-	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
421
-	    		add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
422
-	    	} // End If Statement
418
+			if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
419
+				add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
420
+			} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
421
+				add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
422
+			} // End If Statement
423 423
 
424
-	    } // End If Statement
424
+		} // End If Statement
425 425
 
426
-	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
427
-	    	add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
428
-	    }
426
+		if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
427
+			add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
428
+		}
429 429
 
430 430
 	} // End admin_notices_styles()
431 431
 
@@ -541,30 +541,30 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) {
543 543
 
544
-        $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
545
-        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
544
+		$old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
545
+		$old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
546 546
 
547
-        // duplicate the generic wp post information
547
+		// duplicate the generic wp post information
548 548
 		$new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' );
549 549
 
550 550
 		//update the new lesson data
551
-        add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
551
+		add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
552 552
 
553 553
 		//update the new quiz data
554
-        add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
555
-        wp_update_post(
556
-            array(
557
-                'ID' => $new_quiz->ID,
558
-                'post_parent' => $new_lesson_id
559
-            )
560
-        );
554
+		add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
555
+		wp_update_post(
556
+			array(
557
+				'ID' => $new_quiz->ID,
558
+				'post_parent' => $new_lesson_id
559
+			)
560
+		);
561 561
 
562 562
 		foreach( $old_quiz_questions as $question ) {
563 563
 
564 564
 			// copy the question order over to the new quiz
565 565
 			$old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true );
566
-            $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
567
-            add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
566
+			$new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
567
+			add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
568 568
 
569 569
 			// Add question to quiz
570 570
 			add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false );
@@ -886,21 +886,21 @@  discard block
 block discarded – undo
886 886
 								break;
887 887
 
888 888
 								case 'checkbox':
889
-                                    //backwards compatibility
890
-                                    if( empty( $data ) || 'on' == $data ){
891
-                                        $checked_value = 'on';
892
-                                    }elseif( 'yes' == $data  ) {
889
+									//backwards compatibility
890
+									if( empty( $data ) || 'on' == $data ){
891
+										$checked_value = 'on';
892
+									}elseif( 'yes' == $data  ) {
893 893
 
894
-                                        $checked_value = 'yes';
894
+										$checked_value = 'yes';
895 895
 
896
-                                    }elseif( 'auto' == $data  ) {
896
+									}elseif( 'auto' == $data  ) {
897 897
 
898
-                                        $checked_value = 'auto';
898
+										$checked_value = 'auto';
899 899
 
900
-                                    } else {
901
-                                        $checked_value = 1;
902
-                                        $data = intval( $data );
903
-                                    }
900
+									} else {
901
+										$checked_value = 1;
902
+										$data = intval( $data );
903
+									}
904 904
 									$checked = checked( $checked_value, $data, false );
905 905
 									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n";
906 906
 								break;
@@ -1004,26 +1004,26 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
 		if( 0 < count( $courses ) ) {
1006 1006
 
1007
-            // order the courses as set by the users
1008
-            $all_course_ids = array();
1009
-            foreach( $courses as $course ){
1007
+			// order the courses as set by the users
1008
+			$all_course_ids = array();
1009
+			foreach( $courses as $course ){
1010 1010
 
1011
-                $all_course_ids[] = (string)$course->ID;
1011
+				$all_course_ids[] = (string)$course->ID;
1012 1012
 
1013
-            }
1014
-            $order_string = $this->get_course_order();
1013
+			}
1014
+			$order_string = $this->get_course_order();
1015 1015
 
1016
-            if( !empty( $order_string ) ){
1017
-                $ordered_course_ids = explode(',' , $order_string );
1018
-                $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1019
-            }
1016
+			if( !empty( $order_string ) ){
1017
+				$ordered_course_ids = explode(',' , $order_string );
1018
+				$all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1019
+			}
1020 1020
 
1021 1021
 
1022 1022
 			$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1023 1023
 			$html .= '<ul class="sortable-course-list">' . "\n";
1024 1024
 			$count = 0;
1025 1025
 			foreach ( $all_course_ids as $course_id ) {
1026
-                $course = get_post( $course_id );
1026
+				$course = get_post( $course_id );
1027 1027
 				$count++;
1028 1028
 				$class = 'course';
1029 1029
 				if ( $count == 1 ) { $class .= ' first'; }
@@ -1138,73 +1138,73 @@  discard block
 block discarded – undo
1138 1138
 
1139 1139
 				$displayed_lessons = array();
1140 1140
 
1141
-                $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1142
-
1143
-                foreach( $modules as $module ) {
1144
-
1145
-                    $args = array(
1146
-                        'post_type' => 'lesson',
1147
-                        'post_status' => 'publish',
1148
-                        'posts_per_page' => -1,
1149
-                        'meta_query' => array(
1150
-                            array(
1151
-                                'key' => '_lesson_course',
1152
-                                'value' => intval( $course_id ),
1153
-                                'compare' => '='
1154
-                            )
1155
-                        ),
1156
-                        'tax_query' => array(
1157
-                            array(
1158
-                                'taxonomy' => Sensei()->modules->taxonomy,
1159
-                                'field' => 'id',
1160
-                                'terms' => intval( $module->term_id )
1161
-                            )
1162
-                        ),
1163
-                        'meta_key' => '_order_module_' . $module->term_id,
1164
-                        'orderby' => 'meta_value_num date',
1165
-                        'order' => 'ASC',
1166
-                        'suppress_filters' => 0
1167
-                    );
1168
-
1169
-                    $lessons = get_posts( $args );
1170
-
1171
-                    if( count( $lessons ) > 0 ) {
1172
-                        $html .= '<h3>' . $module->name . '</h3>' . "\n";
1173
-                        $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1174
-
1175
-                        $count = 0;
1176
-                        foreach( $lessons as $lesson ) {
1177
-                            $count++;
1178
-                            $class = 'lesson';
1179
-                            if ( $count == 1 ) { $class .= ' first'; }
1180
-                            if ( $count == count( $lesson ) ) { $class .= ' last'; }
1181
-                            if ( $count % 2 != 0 ) {
1182
-                                $class .= ' alternate';
1183
-                            }
1184
-
1185
-                            $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1186
-
1187
-                            $displayed_lessons[] = $lesson->ID;
1188
-                        }
1189
-
1190
-                        $html .= '</ul>' . "\n";
1191
-
1192
-                        $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1193
-                    }
1194
-                }
1195
-
1196
-
1197
-                $lessons = Sensei()->course->course_lessons( $course_id );
1141
+				$modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1142
+
1143
+				foreach( $modules as $module ) {
1144
+
1145
+					$args = array(
1146
+						'post_type' => 'lesson',
1147
+						'post_status' => 'publish',
1148
+						'posts_per_page' => -1,
1149
+						'meta_query' => array(
1150
+							array(
1151
+								'key' => '_lesson_course',
1152
+								'value' => intval( $course_id ),
1153
+								'compare' => '='
1154
+							)
1155
+						),
1156
+						'tax_query' => array(
1157
+							array(
1158
+								'taxonomy' => Sensei()->modules->taxonomy,
1159
+								'field' => 'id',
1160
+								'terms' => intval( $module->term_id )
1161
+							)
1162
+						),
1163
+						'meta_key' => '_order_module_' . $module->term_id,
1164
+						'orderby' => 'meta_value_num date',
1165
+						'order' => 'ASC',
1166
+						'suppress_filters' => 0
1167
+					);
1168
+
1169
+					$lessons = get_posts( $args );
1170
+
1171
+					if( count( $lessons ) > 0 ) {
1172
+						$html .= '<h3>' . $module->name . '</h3>' . "\n";
1173
+						$html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1174
+
1175
+						$count = 0;
1176
+						foreach( $lessons as $lesson ) {
1177
+							$count++;
1178
+							$class = 'lesson';
1179
+							if ( $count == 1 ) { $class .= ' first'; }
1180
+							if ( $count == count( $lesson ) ) { $class .= ' last'; }
1181
+							if ( $count % 2 != 0 ) {
1182
+								$class .= ' alternate';
1183
+							}
1184
+
1185
+							$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1186
+
1187
+							$displayed_lessons[] = $lesson->ID;
1188
+						}
1189
+
1190
+						$html .= '</ul>' . "\n";
1191
+
1192
+						$html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1193
+					}
1194
+				}
1195
+
1196
+
1197
+				$lessons = Sensei()->course->course_lessons( $course_id );
1198 1198
 
1199 1199
 				if( 0 < count( $lessons ) ) {
1200 1200
 
1201
-                    //get module term ids, will be used to exclude lessons
1202
-                    $module_items_ids = array();
1203
-                    if( ! empty( $modules ) ) {
1204
-                        foreach ($modules as $module) {
1205
-                            $module_items_ids[] = $module->term_id;
1206
-                        }
1207
-                    }
1201
+					//get module term ids, will be used to exclude lessons
1202
+					$module_items_ids = array();
1203
+					if( ! empty( $modules ) ) {
1204
+						foreach ($modules as $module) {
1205
+							$module_items_ids[] = $module->term_id;
1206
+						}
1207
+					}
1208 1208
 
1209 1209
 					if( 0 < count( $displayed_lessons ) ) {
1210 1210
 						$html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n";
@@ -1214,13 +1214,13 @@  discard block
 block discarded – undo
1214 1214
 					$count = 0;
1215 1215
 					foreach ( $lessons as $lesson ) {
1216 1216
 
1217
-                        // if lesson belongs to one fo the course modules then exclude it here
1218
-                        // as it is listed above
1219
-                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1217
+						// if lesson belongs to one fo the course modules then exclude it here
1218
+						// as it is listed above
1219
+						if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1220 1220
 
1221
-                            continue;
1221
+							continue;
1222 1222
 
1223
-                        }
1223
+						}
1224 1224
 
1225 1225
 						$count++;
1226 1226
 						$class = 'lesson';
@@ -1264,23 +1264,23 @@  discard block
 block discarded – undo
1264 1264
 
1265 1265
 		if( $course_id ) {
1266 1266
 
1267
-            $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1267
+			$modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1268 1268
 
1269
-            foreach( $modules as $module ) {
1269
+			foreach( $modules as $module ) {
1270 1270
 
1271
-                $module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ];
1271
+				$module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ];
1272 1272
 
1273
-                if( $module_order_string ) {
1274
-                    $order = explode( ',', $module_order_string );
1275
-                    $i = 1;
1276
-                    foreach( $order as $lesson_id ) {
1277
-                        if( $lesson_id ) {
1278
-                            update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1279
-                            ++$i;
1280
-                        }
1281
-                    }
1282
-                }
1283
-            }
1273
+				if( $module_order_string ) {
1274
+					$order = explode( ',', $module_order_string );
1275
+					$i = 1;
1276
+					foreach( $order as $lesson_id ) {
1277
+						if( $lesson_id ) {
1278
+							update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1279
+							++$i;
1280
+						}
1281
+					}
1282
+				}
1283
+			}
1284 1284
 
1285 1285
 
1286 1286
 			if( $order_string ) {
@@ -1363,47 +1363,47 @@  discard block
 block discarded – undo
1363 1363
 
1364 1364
 	/**
1365 1365
 	 * Adding admin notice if the current
1366
-     * installed theme is not compatible
1367
-     *
1366
+	 * installed theme is not compatible
1367
+	 *
1368 1368
 	 * @return void
1369 1369
 	 */
1370 1370
 	public function theme_compatibility_notices() {
1371 1371
 
1372
-        if( isset( $_GET['sensei_hide_notice'] ) ) {
1373
-        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1372
+		if( isset( $_GET['sensei_hide_notice'] ) ) {
1373
+			switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1374 1374
 				case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break;
1375 1375
 				case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break;
1376 1376
 			}
1377
-        }
1377
+		}
1378 1378
 
1379
-        // white list templates that are already support by default and do not show notice for them
1380
-        $template = get_option( 'template' );
1379
+		// white list templates that are already support by default and do not show notice for them
1380
+		$template = get_option( 'template' );
1381 1381
 
1382
-        $white_list = array(    'twentyeleven',
1383
-                                'twentytwelve',
1384
-                                'twentyfourteen',
1385
-                                'twentyfifteen',
1386
-                                'twentysixteen',
1387
-                                'storefront',
1388
-                                                );
1382
+		$white_list = array(    'twentyeleven',
1383
+								'twentytwelve',
1384
+								'twentyfourteen',
1385
+								'twentyfifteen',
1386
+								'twentysixteen',
1387
+								'storefront',
1388
+												);
1389 1389
 
1390
-        if ( in_array( $template, $white_list ) ) {
1390
+		if ( in_array( $template, $white_list ) ) {
1391 1391
 
1392
-            return;
1392
+			return;
1393 1393
 
1394
-        }
1394
+		}
1395 1395
 
1396
-        // don't show the notice if the user chose to hide it
1397
-        $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1398
-        if(  $hide_theme_check_notice ) {
1396
+		// don't show the notice if the user chose to hide it
1397
+		$hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1398
+		if(  $hide_theme_check_notice ) {
1399 1399
 
1400
-            return;
1400
+			return;
1401 1401
 
1402
-        }
1402
+		}
1403 1403
 
1404
-        // show the notice for themes not supporting sensei
1405
-	    if ( ! current_theme_supports( 'sensei' ) ) {
1406
-            ?>
1404
+		// show the notice for themes not supporting sensei
1405
+		if ( ! current_theme_supports( 'sensei' ) ) {
1406
+			?>
1407 1407
 
1408 1408
             <div id="message" class="error sensei-message sensei-connect">
1409 1409
                     <p>
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
 	public function reset_theme_check_notices() {
1440 1440
 		global $current_user;
1441 1441
 		wp_get_current_user();
1442
-        $user_id = $current_user->ID;
1442
+		$user_id = $current_user->ID;
1443 1443
 
1444 1444
 		delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' );
1445 1445
 	}
@@ -1459,60 +1459,60 @@  discard block
 block discarded – undo
1459 1459
 		return $prevent_access;
1460 1460
 	}
1461 1461
 
1462
-    /**
1463
-     * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args
1464
-     * on the sensei settings page.
1465
-     *
1466
-     * The function
1467
-     *
1468
-     * @since 1.8.7
1469
-     */
1470
-    public  static function install_pages(){
1462
+	/**
1463
+	 * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args
1464
+	 * on the sensei settings page.
1465
+	 *
1466
+	 * The function
1467
+	 *
1468
+	 * @since 1.8.7
1469
+	 */
1470
+	public  static function install_pages(){
1471 1471
 
1472
-        // only fire on the settings page
1473
-        if( ! isset( $_GET['page'] )
1474
-            || 'woothemes-sensei-settings' != $_GET['page']
1475
-            || 1 == get_option('skip_install_sensei_pages') ){
1472
+		// only fire on the settings page
1473
+		if( ! isset( $_GET['page'] )
1474
+			|| 'woothemes-sensei-settings' != $_GET['page']
1475
+			|| 1 == get_option('skip_install_sensei_pages') ){
1476 1476
 
1477
-            return;
1477
+			return;
1478 1478
 
1479
-        }
1479
+		}
1480 1480
 
1481
-        // Install/page installer
1482
-        $install_complete = false;
1481
+		// Install/page installer
1482
+		$install_complete = false;
1483 1483
 
1484
-        // Add pages button
1485
-        $settings_url = '';
1486
-        if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) {
1484
+		// Add pages button
1485
+		$settings_url = '';
1486
+		if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) {
1487 1487
 
1488
-            Sensei()->admin->create_pages();
1489
-            update_option('skip_install_sensei_pages', 1);
1490
-            $install_complete = true;
1491
-            $settings_url = remove_query_arg('install_sensei_pages');
1488
+			Sensei()->admin->create_pages();
1489
+			update_option('skip_install_sensei_pages', 1);
1490
+			$install_complete = true;
1491
+			$settings_url = remove_query_arg('install_sensei_pages');
1492 1492
 
1493
-            // Skip button
1494
-        } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) {
1493
+			// Skip button
1494
+		} elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) {
1495 1495
 
1496
-            update_option('skip_install_sensei_pages', 1);
1497
-            $install_complete = true;
1498
-            $settings_url = remove_query_arg('skip_install_sensei_pages');
1496
+			update_option('skip_install_sensei_pages', 1);
1497
+			$install_complete = true;
1498
+			$settings_url = remove_query_arg('skip_install_sensei_pages');
1499 1499
 
1500
-        }
1500
+		}
1501 1501
 
1502
-        if ($install_complete) {
1502
+		if ($install_complete) {
1503 1503
 
1504
-            // Flush rules after install
1505
-            flush_rewrite_rules( true );
1504
+			// Flush rules after install
1505
+			flush_rewrite_rules( true );
1506 1506
 
1507
-            // Set installed option
1508
-            update_option('sensei_installed', 0);
1507
+			// Set installed option
1508
+			update_option('sensei_installed', 0);
1509 1509
 
1510
-            $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1511
-            wp_redirect( $complete_url );
1510
+			$complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1511
+			wp_redirect( $complete_url );
1512 1512
 
1513
-        }
1513
+		}
1514 1514
 
1515
-    }// end install_pages
1515
+	}// end install_pages
1516 1516
 
1517 1517
 } // End Class
1518 1518
 
Please login to merge, or discard this patch.
Spacing   +419 added lines, -419 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 Administration Class
@@ -18,51 +18,51 @@  discard block
 block discarded – undo
18 18
 	 * Constructor.
19 19
 	 * @since  1.0.0
20 20
 	 */
21
-	public function __construct () {
21
+	public function __construct() {
22 22
 
23 23
         //register admin styles
24
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) );
24
+		add_action('admin_enqueue_scripts', array($this, 'admin_styles_global'));
25 25
 
26 26
         //register admin scripts
27
-        add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
27
+        add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
28 28
 
29
-		add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) );
30
-		add_action( 'settings_before_form', array( $this, 'install_pages_output' ) );
31
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
32
-		add_action( 'menu_order', array( $this, 'admin_menu_order' ) );
33
-		add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
34
-		add_action( 'admin_init', array( $this, 'page_redirect' ) );
35
-		add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
36
-        add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
29
+		add_action('admin_print_styles', array($this, 'admin_notices_styles'));
30
+		add_action('settings_before_form', array($this, 'install_pages_output'));
31
+		add_action('admin_menu', array($this, 'admin_menu'), 10);
32
+		add_action('menu_order', array($this, 'admin_menu_order'));
33
+		add_action('admin_head', array($this, 'admin_menu_highlight'));
34
+		add_action('admin_init', array($this, 'page_redirect'));
35
+		add_action('admin_init', array($this, 'sensei_add_custom_menu_items'));
36
+        add_action('admin_init', array(__CLASS__, 'install_pages'));
37 37
 
38 38
 		// Duplicate lesson & courses
39
-		add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 );
40
-		add_action( 'admin_action_duplicate_lesson', array( $this, 'duplicate_lesson_action' ) );
41
-		add_action( 'admin_action_duplicate_course', array( $this, 'duplicate_course_action' ) );
42
-		add_action( 'admin_action_duplicate_course_with_lessons', array( $this, 'duplicate_course_with_lessons_action' ) );
39
+		add_filter('post_row_actions', array($this, 'duplicate_action_link'), 10, 2);
40
+		add_action('admin_action_duplicate_lesson', array($this, 'duplicate_lesson_action'));
41
+		add_action('admin_action_duplicate_course', array($this, 'duplicate_course_action'));
42
+		add_action('admin_action_duplicate_course_with_lessons', array($this, 'duplicate_course_with_lessons_action'));
43 43
 
44 44
 		// Handle lessons list table filtering
45
-		add_action( 'restrict_manage_posts', array( $this, 'lesson_filter_options' ) );
46
-		add_filter( 'request', array( $this, 'lesson_filter_actions' ) );
45
+		add_action('restrict_manage_posts', array($this, 'lesson_filter_options'));
46
+		add_filter('request', array($this, 'lesson_filter_actions'));
47 47
 
48 48
 		// Add Sensei items to 'at a glance' widget
49
-		add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
49
+		add_filter('dashboard_glance_items', array($this, 'glance_items'), 10, 1);
50 50
 
51 51
 		// Handle course and lesson deletions
52
-		add_action( 'trash_course', array( $this, 'delete_content' ), 10, 2 );
53
-		add_action( 'trash_lesson', array( $this, 'delete_content' ), 10, 2 );
52
+		add_action('trash_course', array($this, 'delete_content'), 10, 2);
53
+		add_action('trash_lesson', array($this, 'delete_content'), 10, 2);
54 54
 
55 55
 		// Delete user activity when user is deleted
56
-		add_action( 'deleted_user', array( $this, 'delete_user_activity' ), 10, 1 );
56
+		add_action('deleted_user', array($this, 'delete_user_activity'), 10, 1);
57 57
 
58 58
 		// Add notices to WP dashboard
59
-		add_action( 'admin_notices', array( $this, 'theme_compatibility_notices' ) );
59
+		add_action('admin_notices', array($this, 'theme_compatibility_notices'));
60 60
 
61 61
 		// Reset theme notices when switching themes
62
-		add_action( 'switch_theme', array( $this, 'reset_theme_check_notices' ) );
62
+		add_action('switch_theme', array($this, 'reset_theme_check_notices'));
63 63
 
64 64
 		// Allow Teacher access the admin area
65
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'admin_access' ) );
65
+		add_filter('woocommerce_prevent_admin_access', array($this, 'admin_access'));
66 66
 
67 67
 	} // End __construct()
68 68
 
@@ -74,21 +74,21 @@  discard block
 block discarded – undo
74 74
 	public function admin_menu() {
75 75
 		global $menu;
76 76
 		$menu_cap = '';
77
-		if( current_user_can( 'manage_sensei' ) ) {
77
+		if (current_user_can('manage_sensei')) {
78 78
 			$menu_cap = 'manage_sensei';
79 79
 		} else {
80
-			if( current_user_can( 'manage_sensei_grades' ) ) {
80
+			if (current_user_can('manage_sensei_grades')) {
81 81
 				$menu_cap = 'manage_sensei_grades';
82 82
 			}
83 83
 		}
84 84
 
85
-		if( $menu_cap ) {
86
-			$menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' );
87
-            add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
85
+		if ($menu_cap) {
86
+			$menu[] = array('', 'read', 'separator-sensei', '', 'wp-menu-separator sensei');
87
+            add_menu_page('Sensei', 'Sensei', $menu_cap, 'sensei', array(Sensei()->analysis, 'analysis_page'), '', '50');
88 88
 		}
89 89
 
90
-		add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) );
91
-		add_submenu_page( 'edit.php?post_type=lesson', __( 'Order Lessons', 'woothemes-sensei' ), __( 'Order Lessons', 'woothemes-sensei' ), 'edit_lessons', 'lesson-order', array( $this, 'lesson_order_screen' ) );
90
+		add_submenu_page('edit.php?post_type=course', __('Order Courses', 'woothemes-sensei'), __('Order Courses', 'woothemes-sensei'), 'manage_sensei', 'course-order', array($this, 'course_order_screen'));
91
+		add_submenu_page('edit.php?post_type=lesson', __('Order Lessons', 'woothemes-sensei'), __('Order Lessons', 'woothemes-sensei'), 'edit_lessons', 'lesson-order', array($this, 'lesson_order_screen'));
92 92
 	}
93 93
 
94 94
 	/**
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 	 * @param  array $menu_order Existing menu order
98 98
 	 * @return array 			 Modified menu order for Sensei
99 99
 	 */
100
-	public function admin_menu_order( $menu_order ) {
100
+	public function admin_menu_order($menu_order) {
101 101
 
102 102
 		// Initialize our custom order array
103 103
 		$sensei_menu_order = array();
104 104
 
105 105
 		// Get the index of our custom separator
106
-		$sensei_separator = array_search( 'separator-sensei', $menu_order );
106
+		$sensei_separator = array_search('separator-sensei', $menu_order);
107 107
 
108 108
 		// Loop through menu order and do some rearranging
109
-		foreach ( $menu_order as $index => $item ) :
109
+		foreach ($menu_order as $index => $item) :
110 110
 
111
-			if ( ( ( 'sensei' ) == $item ) ) :
111
+			if ((('sensei') == $item)) :
112 112
 				$sensei_menu_order[] = 'separator-sensei';
113 113
 				$sensei_menu_order[] = $item;
114
-				unset( $menu_order[$sensei_separator] );
115
-			elseif ( !in_array( $item, array( 'separator-sensei' ) ) ) :
114
+				unset($menu_order[$sensei_separator]);
115
+			elseif ( ! in_array($item, array('separator-sensei'))) :
116 116
 				$sensei_menu_order[] = $item;
117 117
 			endif;
118 118
 
@@ -132,24 +132,24 @@  discard block
 block discarded – undo
132 132
 
133 133
 		$screen = get_current_screen();
134 134
 
135
-		if ( $screen->base == 'post' && $post_type == 'course' ) {
135
+		if ($screen->base == 'post' && $post_type == 'course') {
136 136
 
137
-			$parent_file  = 'edit.php?post_type=course';
137
+			$parent_file = 'edit.php?post_type=course';
138 138
 
139
-		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) {
139
+		} elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') {
140 140
 
141 141
 			$submenu_file = 'edit-tags.php?taxonomy=course-category&amp;post_type=course';
142 142
 			$parent_file  = 'edit.php?post_type=course';
143 143
 
144
-        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
144
+        } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') {
145 145
 
146 146
             $submenu_file = 'edit-tags.php?taxonomy=module';
147 147
             $parent_file  = 'edit.php?post_type=course';
148 148
 
149
-		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) {
149
+		} elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) {
150 150
 
151 151
             $submenu_file = 'edit.php?post_type=sensei_message';
152
-			$parent_file  = 'sensei';
152
+			$parent_file = 'sensei';
153 153
 
154 154
 		}
155 155
 	}
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return void
161 161
 	 */
162 162
 	public function page_redirect() {
163
-		if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) {
164
-			wp_safe_redirect( 'admin.php?page=sensei_analysis' );
163
+		if (isset($_GET['page']) && $_GET['page'] == 'sensei') {
164
+			wp_safe_redirect('admin.php?page=sensei_analysis');
165 165
 			exit;
166 166
 		}
167 167
 	}
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	function install_pages_output() {
178 178
 
179
-        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
179
+        if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
180 180
 
181 181
             ?>
182 182
             <div id="message" class="updated sensei-message sensei-connect">
183
-                <p><?php _e( '<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p>
183
+                <p><?php _e('<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei'); ?></p>
184 184
                 <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a>
185 185
                 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
186 186
             </div>
@@ -202,18 +202,18 @@  discard block
 block discarded – undo
202 202
 	 * @param int $post_parent (default: 0)
203 203
 	 * @return void
204 204
 	 */
205
-	function create_page( $slug, $option, $page_title = '', $page_content = '', $post_parent = 0 ) {
205
+	function create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0) {
206 206
 		global $wpdb;
207 207
 
208
-		$option_value = get_option( $option );
208
+		$option_value = get_option($option);
209 209
 
210
-		if ( $option_value > 0 && get_post( $option_value ) )
210
+		if ($option_value > 0 && get_post($option_value))
211 211
 			return;
212 212
 
213
-		$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );
214
-		if ( $page_found ) :
215
-			if ( ! $option_value )
216
-				update_option( $option, $page_found );
213
+		$page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug));
214
+		if ($page_found) :
215
+			if ( ! $option_value)
216
+				update_option($option, $page_found);
217 217
 			return;
218 218
 		endif;
219 219
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	        'post_parent' 		=> $post_parent,
228 228
 	        'comment_status' 	=> 'closed'
229 229
 	    );
230
-	    $page_id = wp_insert_post( $page_data );
230
+	    $page_id = wp_insert_post($page_data);
231 231
 
232
-	    update_option( $option, $page_id );
232
+	    update_option($option, $page_id);
233 233
 	} // End create_page()
234 234
 
235 235
 
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	function create_pages() {
243 243
 
244 244
 		// Courses page
245
-	    $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
245
+	    $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]');
246 246
 
247 247
 		// User Dashboard page
248
-	    $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
248
+	    $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]');
249 249
 
250 250
 	} // End create_pages()
251 251
 
@@ -255,25 +255,25 @@  discard block
 block discarded – undo
255 255
 	 * @since 1.0.0
256 256
 	 * @return void
257 257
 	 */
258
-	public function admin_styles_global ( $hook ) {
258
+	public function admin_styles_global($hook) {
259 259
 		global $post_type;
260 260
 
261
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
262
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
263
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) );
261
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
262
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
263
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order'));
264 264
 
265 265
 		// Global Styles for icons and menu items
266
-		wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' );
267
-		wp_enqueue_style( 'woothemes-sensei-global' );
266
+		wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen');
267
+		wp_enqueue_style('woothemes-sensei-global');
268 268
 
269 269
         // Select 2 styles
270
-        wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
270
+        wp_enqueue_style('select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen');
271 271
 
272 272
 		// Test for Write Panel Pages
273
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
273
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
274 274
 
275
-			wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' );
276
-			wp_enqueue_style( 'woothemes-sensei-admin-custom' );
275
+			wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen');
276
+			wp_enqueue_style('woothemes-sensei-admin-custom');
277 277
 
278 278
 		}
279 279
 
@@ -288,20 +288,20 @@  discard block
 block discarded – undo
288 288
      * @since 1.8.2
289 289
      * @access public
290 290
      */
291
-    public function register_scripts( $hook ){
291
+    public function register_scripts($hook) {
292 292
 
293 293
         $screen = get_current_screen();
294 294
 
295 295
         // Allow developers to load non-minified versions of scripts
296
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
296
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
297 297
 
298 298
         // Select2 script used to enhance all select boxes
299
-        wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
299
+        wp_register_script('select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version);
300 300
 
301 301
         // load edit module scripts
302
-        if( 'edit-module' ==  $screen->id ){
302
+        if ('edit-module' == $screen->id) {
303 303
 
304
-            wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
304
+            wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true);
305 305
 
306 306
         }
307 307
 
@@ -319,19 +319,19 @@  discard block
 block discarded – undo
319 319
 	    <div id="message" class="updated sensei-message sensei-connect">
320 320
 
321 321
             <p>
322
-                <?php _e( '<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?>
322
+                <?php _e('<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei'); ?>
323 323
             </p>
324 324
 
325 325
             <p class="submit">
326 326
 
327
-                <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>"
327
+                <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>"
328 328
                    class="button-primary">
329 329
 
330
-                    <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?>
330
+                    <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?>
331 331
 
332 332
                 </a>
333 333
 
334
-                <a class="skip button" href="<?php echo esc_url( add_query_arg( 'skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings' ) ) ); ?>">
334
+                <a class="skip button" href="<?php echo esc_url(add_query_arg('skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>">
335 335
 
336 336
                     <?php _e('Skip setup', 'woothemes-sensei'); ?>
337 337
 
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
 	    <div id="message" class="updated sensei-message sensei-connect">
355 355
 
356 356
 	    	<p>
357
-                <?php _e( '<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei' ); ?>
357
+                <?php _e('<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei'); ?>
358 358
             </p>
359 359
 
360 360
 			<p class="submit">
361
-                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
361
+                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
362 362
                     <?php _e('Documentation', 'woothemes-sensei'); ?>
363 363
                 </a>
364 364
             </p>
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 	public function language_pack_install_notice() {
392 392
 		?>
393 393
 		<div id="message" class="updated sensei-message sensei-connect">
394
-				<p><?php _e( '<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei' ); ?><p>
394
+				<p><?php _e('<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei'); ?><p>
395 395
 
396 396
 				<p class="submit">
397
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a>
398
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a>
397
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a>
398
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a>
399 399
 				</p>
400 400
 		</div>
401 401
 		<?php
@@ -411,20 +411,20 @@  discard block
 block discarded – undo
411 411
 	function admin_notices_styles() {
412 412
 
413 413
 		// Installed notices
414
-	    if ( 1 == get_option( 'sensei_installed' ) ) {
414
+	    if (1 == get_option('sensei_installed')) {
415 415
 
416
-	    	wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
416
+	    	wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version);
417 417
 
418
-	    	if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
419
-	    		add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
420
-	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
421
-	    		add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
418
+	    	if (get_option('skip_install_sensei_pages') != 1 && Sensei()->get_page_id('course') < 1 && ! isset($_GET['install_sensei_pages']) && ! isset($_GET['skip_install_sensei_pages'])) {
419
+	    		add_action('admin_notices', array($this, 'admin_install_notice'));
420
+	    	} elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') {
421
+	    		add_action('admin_notices', array($this, 'admin_installed_notice'));
422 422
 	    	} // End If Statement
423 423
 
424 424
 	    } // End If Statement
425 425
 
426
-	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
427
-	    	add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
426
+	    if (Sensei_Language_Pack_Manager::has_language_pack_available()) {
427
+	    	add_action('admin_notices', array($this, 'language_pack_install_notice'));
428 428
 	    }
429 429
 
430 430
 	} // End admin_notices_styles()
@@ -435,17 +435,17 @@  discard block
 block discarded – undo
435 435
 	 * @param  object $post    Current post
436 436
 	 * @return array           Modified actions
437 437
 	 */
438
-	public function duplicate_action_link( $actions, $post ) {
439
-		switch( $post->post_type ) {
438
+	public function duplicate_action_link($actions, $post) {
439
+		switch ($post->post_type) {
440 440
 			case 'lesson':
441
-				$confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' );
442
-				$actions['duplicate'] = "<a onclick='return confirm(\"" . $confirm . "\");' href='" . $this->get_duplicate_link( $post->ID ) . "' title='" . esc_attr(__( 'Duplicate this lesson', 'woothemes-sensei' ) ) . "'>" .  __('Duplicate', 'woothemes-sensei' ) . "</a>";
441
+				$confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei');
442
+				$actions['duplicate'] = "<a onclick='return confirm(\"".$confirm."\");' href='".$this->get_duplicate_link($post->ID)."' title='".esc_attr(__('Duplicate this lesson', 'woothemes-sensei'))."'>".__('Duplicate', 'woothemes-sensei')."</a>";
443 443
 			break;
444 444
 
445 445
 			case 'course':
446
-				$confirm = __( 'This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei' );
447
-				$actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' .  __('Duplicate', 'woothemes-sensei' ) . '</a>';
448
-				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\'' . $confirm . '\');" href="' . $this->get_duplicate_link( $post->ID, true ) . '" title="' . esc_attr(__( 'Duplicate this course with its lessons', 'woothemes-sensei' ) ) . '">' .  __('Duplicate (with lessons)', 'woothemes-sensei' ) . '</a>';
446
+				$confirm = __('This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei');
447
+				$actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>';
448
+				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\''.$confirm.'\');" href="'.$this->get_duplicate_link($post->ID, true).'" title="'.esc_attr(__('Duplicate this course with its lessons', 'woothemes-sensei')).'">'.__('Duplicate (with lessons)', 'woothemes-sensei').'</a>';
449 449
 			break;
450 450
 		}
451 451
 
@@ -458,17 +458,17 @@  discard block
 block discarded – undo
458 458
 	 * @param  boolean $with_lessons Include lessons or not
459 459
 	 * @return string                Duplication link
460 460
 	 */
461
-	private function get_duplicate_link( $post_id = 0, $with_lessons = false ) {
461
+	private function get_duplicate_link($post_id = 0, $with_lessons = false) {
462 462
 
463
-		$post = get_post( $post_id );
463
+		$post = get_post($post_id);
464 464
 
465
-		$action = 'duplicate_' . $post->post_type;
465
+		$action = 'duplicate_'.$post->post_type;
466 466
 
467
-		if( 'course' == $post->post_type && $with_lessons ) {
467
+		if ('course' == $post->post_type && $with_lessons) {
468 468
 			$action .= '_with_lessons';
469 469
 		}
470 470
 
471
-		return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id );
471
+		return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id);
472 472
 	}
473 473
 
474 474
 	/**
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 * @return void
477 477
 	 */
478 478
 	public function duplicate_lesson_action() {
479
-		$this->duplicate_content( 'lesson' );
479
+		$this->duplicate_content('lesson');
480 480
 	}
481 481
 
482 482
 	/**
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * @return void
485 485
 	 */
486 486
 	public function duplicate_course_action() {
487
-		$this->duplicate_content( 'course' );
487
+		$this->duplicate_content('course');
488 488
 	}
489 489
 
490 490
 	/**
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * @return void
493 493
 	 */
494 494
 	public function duplicate_course_with_lessons_action() {
495
-		$this->duplicate_content( 'course', true );
495
+		$this->duplicate_content('course', true);
496 496
 	}
497 497
 
498 498
 	/**
@@ -501,34 +501,34 @@  discard block
 block discarded – undo
501 501
 	 * @param  boolean $with_lessons Include lessons or not
502 502
 	 * @return void
503 503
 	 */
504
-	private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) {
505
-		if ( ! isset( $_GET['post'] ) ) {
506
-			wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type );
504
+	private function duplicate_content($post_type = 'lesson', $with_lessons = false) {
505
+		if ( ! isset($_GET['post'])) {
506
+			wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type);
507 507
 		}
508 508
 
509 509
 		$post_id = $_GET['post'];
510
-		$post = get_post( $post_id );
510
+		$post = get_post($post_id);
511 511
 
512
-		if( ! is_wp_error( $post ) ) {
512
+		if ( ! is_wp_error($post)) {
513 513
 
514
-			$new_post = $this->duplicate_post( $post );
514
+			$new_post = $this->duplicate_post($post);
515 515
 
516
-			if( $new_post && ! is_wp_error( $new_post ) ) {
516
+			if ($new_post && ! is_wp_error($new_post)) {
517 517
 
518
-				if( 'lesson' == $new_post->post_type ) {
519
-					$this->duplicate_lesson_quizzes( $post_id, $new_post->ID );
518
+				if ('lesson' == $new_post->post_type) {
519
+					$this->duplicate_lesson_quizzes($post_id, $new_post->ID);
520 520
 				}
521 521
 
522
-				if( 'course' == $new_post->post_type && $with_lessons ) {
523
-					$this->duplicate_course_lessons( $post_id, $new_post->ID );
522
+				if ('course' == $new_post->post_type && $with_lessons) {
523
+					$this->duplicate_course_lessons($post_id, $new_post->ID);
524 524
 				}
525 525
 
526
-				$redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' );
526
+				$redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit');
527 527
 			} else {
528
-				$redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' );
528
+				$redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed');
529 529
 			}
530 530
 
531
-			wp_safe_redirect( esc_url_raw( $redirect_url ) );
531
+			wp_safe_redirect(esc_url_raw($redirect_url));
532 532
 			exit;
533 533
 		}
534 534
 	}
@@ -539,19 +539,19 @@  discard block
 block discarded – undo
539 539
 	 * @param  integer $new_lesson_id ID of duplicate lesson
540 540
 	 * @return void
541 541
 	 */
542
-	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) {
542
+	private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) {
543 543
 
544
-        $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
545
-        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
544
+        $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id);
545
+        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id);
546 546
 
547 547
         // duplicate the generic wp post information
548
-		$new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' );
548
+		$new_quiz = $this->duplicate_post(get_post($old_quiz_id), '');
549 549
 
550 550
 		//update the new lesson data
551
-        add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
551
+        add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID);
552 552
 
553 553
 		//update the new quiz data
554
-        add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
554
+        add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id);
555 555
         wp_update_post(
556 556
             array(
557 557
                 'ID' => $new_quiz->ID,
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
             )
560 560
         );
561 561
 
562
-		foreach( $old_quiz_questions as $question ) {
562
+		foreach ($old_quiz_questions as $question) {
563 563
 
564 564
 			// copy the question order over to the new quiz
565
-			$old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true );
566
-            $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
567
-            add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
565
+			$old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true);
566
+            $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order);
567
+            add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order);
568 568
 
569 569
 			// Add question to quiz
570
-			add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false );
570
+			add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false);
571 571
 
572 572
 		}
573 573
 	}
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	 * @param  integer $new_course_id ID of duplicated course
579 579
 	 * @return void
580 580
 	 */
581
-	private function duplicate_course_lessons( $old_course_id, $new_course_id ) {
581
+	private function duplicate_course_lessons($old_course_id, $new_course_id) {
582 582
 		$lesson_args = array(
583 583
 			'post_type' => 'lesson',
584 584
 			'posts_per_page' => -1,
@@ -586,13 +586,13 @@  discard block
 block discarded – undo
586 586
 			'meta_value' => $old_course_id,
587 587
 			'suppress_filters' 	=> 0
588 588
 		);
589
-		$lessons = get_posts( $lesson_args );
589
+		$lessons = get_posts($lesson_args);
590 590
 
591
-		foreach( $lessons as $lesson ) {
592
-			$new_lesson = $this->duplicate_post( $lesson, '', true );
593
-			add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id );
591
+		foreach ($lessons as $lesson) {
592
+			$new_lesson = $this->duplicate_post($lesson, '', true);
593
+			add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id);
594 594
 
595
-			$this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID );
595
+			$this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID);
596 596
 		}
597 597
 	}
598 598
 
@@ -603,24 +603,24 @@  discard block
 block discarded – undo
603 603
 	 * @param  boolean $ignore_course Ignore lesson course when dulicating
604 604
 	 * @return object                 Duplicate post object
605 605
 	 */
606
-	private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) {
606
+	private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) {
607 607
 
608 608
 		$new_post = array();
609 609
 
610
-		foreach( $post as $k => $v ) {
611
-			if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) {
612
-				$new_post[ $k ] = $v;
610
+		foreach ($post as $k => $v) {
611
+			if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) {
612
+				$new_post[$k] = $v;
613 613
 			}
614 614
 		}
615 615
 
616
-		$new_post['post_title'] .= __( $suffix, 'woothemes-sensei' );
616
+		$new_post['post_title'] .= __($suffix, 'woothemes-sensei');
617 617
 
618
-		$new_post['post_date'] = current_time( 'mysql' );
619
-		$new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] );
618
+		$new_post['post_date'] = current_time('mysql');
619
+		$new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']);
620 620
 		$new_post['post_modified'] = $new_post['post_date'];
621 621
 		$new_post['post_modified_gmt'] = $new_post['post_date_gmt'];
622 622
 
623
-		switch( $post->post_type ) {
623
+		switch ($post->post_type) {
624 624
 			case 'course': $new_post['post_status'] = 'draft'; break;
625 625
 			case 'lesson': $new_post['post_status'] = 'draft'; break;
626 626
 			case 'quiz': $new_post['post_status'] = 'publish'; break;
@@ -628,45 +628,45 @@  discard block
 block discarded – undo
628 628
 		}
629 629
 
630 630
 		// As per wp_update_post() we need to escape the data from the db.
631
-		$new_post = wp_slash( $new_post );
631
+		$new_post = wp_slash($new_post);
632 632
 
633
-		$new_post_id = wp_insert_post( $new_post );
633
+		$new_post_id = wp_insert_post($new_post);
634 634
 
635
-		if( ! is_wp_error( $new_post_id ) ) {
635
+		if ( ! is_wp_error($new_post_id)) {
636 636
 
637
-			$post_meta = get_post_custom( $post->ID );
638
-			if( $post_meta && count( $post_meta ) > 0 ) {
637
+			$post_meta = get_post_custom($post->ID);
638
+			if ($post_meta && count($post_meta) > 0) {
639 639
 
640
-				$ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' );
640
+				$ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz');
641 641
 
642
-				if( $ignore_course ) {
642
+				if ($ignore_course) {
643 643
 					$ignore_meta[] = '_lesson_course';
644 644
 				}
645 645
 
646
-				foreach( $post_meta as $key => $meta ) {
647
-					foreach( $meta as $value ) {
648
-						$value = maybe_unserialize( $value );
649
-						if( ! in_array( $key, $ignore_meta ) ) {
650
-							add_post_meta( $new_post_id, $key, $value );
646
+				foreach ($post_meta as $key => $meta) {
647
+					foreach ($meta as $value) {
648
+						$value = maybe_unserialize($value);
649
+						if ( ! in_array($key, $ignore_meta)) {
650
+							add_post_meta($new_post_id, $key, $value);
651 651
 						}
652 652
 					}
653 653
 				}
654 654
 			}
655 655
 
656
-			add_post_meta( $new_post_id, '_duplicate', $post->ID );
656
+			add_post_meta($new_post_id, '_duplicate', $post->ID);
657 657
 
658
-			$taxonomies = get_object_taxonomies( $post->post_type, 'objects' );
658
+			$taxonomies = get_object_taxonomies($post->post_type, 'objects');
659 659
 
660
-			foreach ( $taxonomies as $slug => $tax ) {
661
-				$terms = get_the_terms( $post->ID, $slug );
662
-				if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) {
663
-					foreach( $terms as $term ) {
664
-						wp_set_object_terms( $new_post_id, $term->term_id, $slug, true );
660
+			foreach ($taxonomies as $slug => $tax) {
661
+				$terms = get_the_terms($post->ID, $slug);
662
+				if (isset($terms) && is_array($terms) && 0 < count($terms)) {
663
+					foreach ($terms as $term) {
664
+						wp_set_object_terms($new_post_id, $term->term_id, $slug, true);
665 665
 					}
666 666
 				}
667 667
 			}
668 668
 
669
-			$new_post = get_post( $new_post_id );
669
+			$new_post = get_post($new_post_id);
670 670
 
671 671
 			return $new_post;
672 672
 		}
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	public function lesson_filter_options() {
682 682
 		global $typenow;
683 683
 
684
-		if( is_admin() && 'lesson' == $typenow ) {
684
+		if (is_admin() && 'lesson' == $typenow) {
685 685
 
686 686
 			$args = array(
687 687
 				'post_type' => 'course',
@@ -691,16 +691,16 @@  discard block
 block discarded – undo
691 691
 				'orderby' => 'menu_order date',
692 692
 				'order' => 'ASC',
693 693
 			);
694
-			$courses = get_posts( $args );
694
+			$courses = get_posts($args);
695 695
 
696
-			$selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
696
+			$selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
697 697
 			$course_options = '';
698
-			foreach( $courses as $course ) {
699
-				$course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>';
698
+			foreach ($courses as $course) {
699
+				$course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>';
700 700
 			}
701 701
 
702 702
 			$output = '<select name="lesson_course" id="dropdown_lesson_course">';
703
-			$output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>';
703
+			$output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>';
704 704
 			$output .= $course_options;
705 705
 			$output .= '</select>';
706 706
 
@@ -713,13 +713,13 @@  discard block
 block discarded – undo
713 713
 	 * @param  array $request Current request
714 714
 	 * @return array          Modified request
715 715
 	 */
716
-	public function lesson_filter_actions( $request ) {
716
+	public function lesson_filter_actions($request) {
717 717
 		global $typenow;
718 718
 
719
-		if( is_admin() && 'lesson' == $typenow ) {
720
-			$lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
719
+		if (is_admin() && 'lesson' == $typenow) {
720
+			$lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
721 721
 
722
-			if( $lesson_course ) {
722
+			if ($lesson_course) {
723 723
 				$request['meta_key'] = '_lesson_course';
724 724
 				$request['meta_value'] = $lesson_course;
725 725
 				$request['meta_compare'] = '=';
@@ -734,27 +734,27 @@  discard block
 block discarded – undo
734 734
 	 * @param  array $items Existing items
735 735
 	 * @return array        Updated items
736 736
 	 */
737
-	public function glance_items( $items = array() ) {
737
+	public function glance_items($items = array()) {
738 738
 
739
-		$types = array( 'course', 'lesson', 'question' );
739
+		$types = array('course', 'lesson', 'question');
740 740
 
741
-		foreach( $types as $type ) {
742
-			if( ! post_type_exists( $type ) ) continue;
741
+		foreach ($types as $type) {
742
+			if ( ! post_type_exists($type)) continue;
743 743
 
744
-			$num_posts = wp_count_posts( $type );
744
+			$num_posts = wp_count_posts($type);
745 745
 
746
-			if( $num_posts ) {
746
+			if ($num_posts) {
747 747
 
748
-				$published = intval( $num_posts->publish );
749
-				$post_type = get_post_type_object( $type );
748
+				$published = intval($num_posts->publish);
749
+				$post_type = get_post_type_object($type);
750 750
 
751
-				$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' );
752
-				$text = sprintf( $text, number_format_i18n( $published ) );
751
+				$text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei');
752
+				$text = sprintf($text, number_format_i18n($published));
753 753
 
754
-				if ( current_user_can( $post_type->cap->edit_posts ) ) {
755
-					$items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n";
754
+				if (current_user_can($post_type->cap->edit_posts)) {
755
+					$items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n";
756 756
 				} else {
757
-					$items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n";
757
+					$items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n";
758 758
 				}
759 759
 			}
760 760
 		}
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	 * @param  object  $post    Post object
769 769
 	 * @return void
770 770
 	 */
771
-	public function delete_content( $post_id, $post ) {
771
+	public function delete_content($post_id, $post) {
772 772
 
773 773
 		$type = $post->post_type;
774 774
 
775
-		if( in_array( $type, array( 'lesson', 'course' ) ) ) {
775
+		if (in_array($type, array('lesson', 'course'))) {
776 776
 
777
-			$meta_key = '_' . $type . '_prerequisite';
777
+			$meta_key = '_'.$type.'_prerequisite';
778 778
 
779 779
 			$args = array(
780 780
 				'post_type' => $type,
@@ -784,10 +784,10 @@  discard block
 block discarded – undo
784 784
 				'meta_value' => $post_id
785 785
 			);
786 786
 
787
-			$posts = get_posts( $args );
787
+			$posts = get_posts($args);
788 788
 
789
-			foreach( $posts as $post ) {
790
-				delete_post_meta( $post->ID, $meta_key );
789
+			foreach ($posts as $post) {
790
+				delete_post_meta($post->ID, $meta_key);
791 791
 			}
792 792
 		}
793 793
 	}
@@ -797,181 +797,181 @@  discard block
 block discarded – undo
797 797
 	 * @param  integer $user_id User ID
798 798
 	 * @return void
799 799
 	 */
800
-	public function delete_user_activity( $user_id = 0 ) {
801
-		if( $user_id ) {
802
-			Sensei_Utils::delete_all_user_activity( $user_id );
800
+	public function delete_user_activity($user_id = 0) {
801
+		if ($user_id) {
802
+			Sensei_Utils::delete_all_user_activity($user_id);
803 803
 		}
804 804
 	}
805 805
 
806
-	public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) {
806
+	public function render_settings($settings = array(), $post_id = 0, $group_id = '') {
807 807
 
808 808
 		$html = '';
809 809
 
810
-		if( 0 == count( $settings ) ) return $html;
810
+		if (0 == count($settings)) return $html;
811 811
 
812
-		$html .= '<div class="sensei-options-panel">' . "\n";
812
+		$html .= '<div class="sensei-options-panel">'."\n";
813 813
 
814
-			$html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n";
814
+			$html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n";
815 815
 
816
-				foreach( $settings as $field ) {
816
+				foreach ($settings as $field) {
817 817
 
818 818
 					$data = '';
819 819
 
820
-					if( $post_id ) {
821
-						$data = get_post_meta( $post_id, '_' . $field['id'], true );
822
-						if( ! $data && isset( $field['default'] ) ) {
820
+					if ($post_id) {
821
+						$data = get_post_meta($post_id, '_'.$field['id'], true);
822
+						if ( ! $data && isset($field['default'])) {
823 823
 							$data = $field['default'];
824 824
 						}
825 825
 					} else {
826
-						$option = get_option( $field['id'] );
827
-						if( isset( $field['default'] ) ) {
826
+						$option = get_option($field['id']);
827
+						if (isset($field['default'])) {
828 828
 							$data = $field['default'];
829
-							if( $option ) {
829
+							if ($option) {
830 830
 								$data = $option;
831 831
 							}
832 832
 						}
833 833
 					}
834 834
 
835 835
 					$disabled = '';
836
-					if( isset( $field['disabled'] ) && $field['disabled'] ) {
837
-						$disabled = disabled( $field['disabled'], true, false );
836
+					if (isset($field['disabled']) && $field['disabled']) {
837
+						$disabled = disabled($field['disabled'], true, false);
838 838
 					}
839 839
 
840
-					if( 'hidden' != $field['type'] ) {
840
+					if ('hidden' != $field['type']) {
841 841
 
842 842
 						$class_tail = '';
843 843
 
844
-						if( isset( $field['class'] ) ) {
844
+						if (isset($field['class'])) {
845 845
 							$class_tail .= $field['class'];
846 846
 						}
847 847
 
848
-						if( isset( $field['disabled'] ) && $field['disabled'] ) {
848
+						if (isset($field['disabled']) && $field['disabled']) {
849 849
 							$class_tail .= ' disabled';
850 850
 						}
851 851
 
852
-						$html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n";
852
+						$html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n";
853 853
 					}
854 854
 
855
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
856
-							$html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n";
855
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
856
+							$html .= '<label for="'.esc_attr($field['id']).'">'."\n";
857 857
 						}
858 858
 
859
-							if( $field['label'] ) {
860
-								$html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>';
859
+							if ($field['label']) {
860
+								$html .= '<span class="label">'.esc_html($field['label']).'</span>';
861 861
 							}
862 862
 
863
-							switch( $field['type'] ) {
863
+							switch ($field['type']) {
864 864
 								case 'text':
865 865
 								case 'password':
866
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n";
866
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n";
867 867
 								break;
868 868
 
869 869
 								case 'number':
870 870
 
871 871
 									$min = '';
872
-									if( isset( $field['min'] ) ) {
873
-										$min = 'min="' . esc_attr( $field['min'] ) . '"';
872
+									if (isset($field['min'])) {
873
+										$min = 'min="'.esc_attr($field['min']).'"';
874 874
 									}
875 875
 
876 876
 									$max = '';
877
-									if( isset( $field['max'] ) ) {
878
-										$max = 'max="' . esc_attr( $field['max'] ) . '"';
877
+									if (isset($field['max'])) {
878
+										$max = 'max="'.esc_attr($field['max']).'"';
879 879
 									}
880 880
 
881
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $min . '  ' . $max . ' class="small-text" ' . $disabled . ' />' . "\n";
881
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$min.'  '.$max.' class="small-text" '.$disabled.' />'."\n";
882 882
 								break;
883 883
 
884 884
 								case 'textarea':
885
-									$html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . $disabled . '>' . $data . '</textarea><br/>'. "\n";
885
+									$html .= '<textarea id="'.esc_attr($field['id']).'" rows="5" cols="50" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" '.$disabled.'>'.$data.'</textarea><br/>'."\n";
886 886
 								break;
887 887
 
888 888
 								case 'checkbox':
889 889
                                     //backwards compatibility
890
-                                    if( empty( $data ) || 'on' == $data ){
890
+                                    if (empty($data) || 'on' == $data) {
891 891
                                         $checked_value = 'on';
892
-                                    }elseif( 'yes' == $data  ) {
892
+                                    }elseif ('yes' == $data) {
893 893
 
894 894
                                         $checked_value = 'yes';
895 895
 
896
-                                    }elseif( 'auto' == $data  ) {
896
+                                    }elseif ('auto' == $data) {
897 897
 
898 898
                                         $checked_value = 'auto';
899 899
 
900 900
                                     } else {
901 901
                                         $checked_value = 1;
902
-                                        $data = intval( $data );
902
+                                        $data = intval($data);
903 903
                                     }
904
-									$checked = checked( $checked_value, $data, false );
905
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n";
904
+									$checked = checked($checked_value, $data, false);
905
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n";
906 906
 								break;
907 907
 
908 908
 								case 'checkbox_multi':
909
-									foreach( $field['options'] as $k => $v ) {
909
+									foreach ($field['options'] as $k => $v) {
910 910
 										$checked = false;
911
-										if( in_array( $k, $data ) ) {
911
+										if (in_array($k, $data)) {
912 912
 											$checked = true;
913 913
 										}
914
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
914
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="checkbox" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'[]" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
915 915
 									}
916 916
 								break;
917 917
 
918 918
 								case 'radio':
919
-									foreach( $field['options'] as $k => $v ) {
919
+									foreach ($field['options'] as $k => $v) {
920 920
 										$checked = false;
921
-										if( $k == $data ) {
921
+										if ($k == $data) {
922 922
 											$checked = true;
923 923
 										}
924
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
924
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="radio" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
925 925
 									}
926 926
 								break;
927 927
 
928 928
 								case 'select':
929
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n";
930
-									foreach( $field['options'] as $k => $v ) {
929
+									$html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n";
930
+									foreach ($field['options'] as $k => $v) {
931 931
 										$selected = false;
932
-										if( $k == $data ) {
932
+										if ($k == $data) {
933 933
 											$selected = true;
934 934
 										}
935
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n";
935
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n";
936 936
 									}
937
-									$html .= '</select><br/>' . "\n";
937
+									$html .= '</select><br/>'."\n";
938 938
 								break;
939 939
 
940 940
 								case 'select_multi':
941
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n";
942
-									foreach( $field['options'] as $k => $v ) {
941
+									$html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n";
942
+									foreach ($field['options'] as $k => $v) {
943 943
 										$selected = false;
944
-										if( in_array( $k, $data ) ) {
944
+										if (in_array($k, $data)) {
945 945
 											$selected = true;
946 946
 										}
947
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n";
947
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n";
948 948
 									}
949 949
 									$html .= '</select> . "\n"';
950 950
 								break;
951 951
 
952 952
 								case 'hidden':
953
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n";
953
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n";
954 954
 								break;
955 955
 
956 956
 							}
957 957
 
958
-							if( $field['description'] ) {
959
-								$html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n";
958
+							if ($field['description']) {
959
+								$html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n";
960 960
 							}
961 961
 
962
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
963
-							$html .= '</label>' . "\n";
962
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
963
+							$html .= '</label>'."\n";
964 964
 						}
965 965
 
966
-					if( 'hidden' != $field['type'] ) {
967
-						$html .= '</p>' . "\n";
966
+					if ('hidden' != $field['type']) {
967
+						$html .= '</p>'."\n";
968 968
 					}
969 969
 
970 970
 				}
971 971
 
972
-			$html .= '</div>' . "\n";
972
+			$html .= '</div>'."\n";
973 973
 
974
-		$html .= '</div>' . "\n";
974
+		$html .= '</div>'."\n";
975 975
 
976 976
 		return $html;
977 977
 	}
@@ -982,61 +982,61 @@  discard block
 block discarded – undo
982 982
 	 */
983 983
 	public function course_order_screen() {
984 984
 
985
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
986
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
985
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
986
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
987 987
 
988 988
 		?><div id="course-order" class="wrap course-order">
989
-		<h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php
989
+		<h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php
990 990
 
991 991
 		$html = '';
992 992
 
993
-		if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) {
994
-			$ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) );
993
+		if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) {
994
+			$ordered = $this->save_course_order(esc_attr($_POST['course-order']));
995 995
 
996
-			if( $ordered ) {
997
-				$html .= '<div class="updated fade">' . "\n";
998
-				$html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
999
-				$html .= '</div>' . "\n";
996
+			if ($ordered) {
997
+				$html .= '<div class="updated fade">'."\n";
998
+				$html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n";
999
+				$html .= '</div>'."\n";
1000 1000
 			}
1001 1001
 		}
1002 1002
 
1003 1003
 		$courses = Sensei()->course->get_all_courses();
1004 1004
 
1005
-		if( 0 < count( $courses ) ) {
1005
+		if (0 < count($courses)) {
1006 1006
 
1007 1007
             // order the courses as set by the users
1008 1008
             $all_course_ids = array();
1009
-            foreach( $courses as $course ){
1009
+            foreach ($courses as $course) {
1010 1010
 
1011
-                $all_course_ids[] = (string)$course->ID;
1011
+                $all_course_ids[] = (string) $course->ID;
1012 1012
 
1013 1013
             }
1014 1014
             $order_string = $this->get_course_order();
1015 1015
 
1016
-            if( !empty( $order_string ) ){
1017
-                $ordered_course_ids = explode(',' , $order_string );
1018
-                $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1016
+            if ( ! empty($order_string)) {
1017
+                $ordered_course_ids = explode(',', $order_string);
1018
+                $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids));
1019 1019
             }
1020 1020
 
1021 1021
 
1022
-			$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1023
-			$html .= '<ul class="sortable-course-list">' . "\n";
1022
+			$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1023
+			$html .= '<ul class="sortable-course-list">'."\n";
1024 1024
 			$count = 0;
1025
-			foreach ( $all_course_ids as $course_id ) {
1026
-                $course = get_post( $course_id );
1025
+			foreach ($all_course_ids as $course_id) {
1026
+                $course = get_post($course_id);
1027 1027
 				$count++;
1028 1028
 				$class = 'course';
1029
-				if ( $count == 1 ) { $class .= ' first'; }
1030
-				if ( $count == count( $course ) ) { $class .= ' last'; }
1031
-				if ( $count % 2 != 0 ) {
1029
+				if ($count == 1) { $class .= ' first'; }
1030
+				if ($count == count($course)) { $class .= ' last'; }
1031
+				if ($count % 2 != 0) {
1032 1032
 					$class .= ' alternate';
1033 1033
 				}
1034
-				$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n";
1034
+				$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n";
1035 1035
 			}
1036
-			$html .= '</ul>' . "\n";
1036
+			$html .= '</ul>'."\n";
1037 1037
 
1038
-			$html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1039
-			$html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n";
1038
+			$html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n";
1039
+			$html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n";
1040 1040
 		}
1041 1041
 
1042 1042
 		echo $html;
@@ -1045,25 +1045,25 @@  discard block
 block discarded – undo
1045 1045
 	}
1046 1046
 
1047 1047
 	public function get_course_order() {
1048
-		return get_option( 'sensei_course_order', '' );
1048
+		return get_option('sensei_course_order', '');
1049 1049
 	}
1050 1050
 
1051
-	public function save_course_order( $order_string = '' ) {
1052
-		$order = explode( ',', $order_string );
1051
+	public function save_course_order($order_string = '') {
1052
+		$order = explode(',', $order_string);
1053 1053
 
1054
-		update_option( 'sensei_course_order', $order_string );
1054
+		update_option('sensei_course_order', $order_string);
1055 1055
 
1056 1056
 		$i = 1;
1057
-		foreach( $order as $course_id ) {
1057
+		foreach ($order as $course_id) {
1058 1058
 
1059
-			if( $course_id ) {
1059
+			if ($course_id) {
1060 1060
 
1061 1061
 				$update_args = array(
1062 1062
 					'ID' => $course_id,
1063 1063
 					'menu_order' => $i,
1064 1064
 				);
1065 1065
 
1066
-				wp_update_post( $update_args );
1066
+				wp_update_post($update_args);
1067 1067
 
1068 1068
 				++$i;
1069 1069
 			}
@@ -1078,22 +1078,22 @@  discard block
 block discarded – undo
1078 1078
 	 */
1079 1079
 	public function lesson_order_screen() {
1080 1080
 
1081
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1082
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
1081
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1082
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
1083 1083
 
1084 1084
 		?><div id="lesson-order" class="wrap lesson-order">
1085
-		<h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php
1085
+		<h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php
1086 1086
 
1087 1087
 		$html = '';
1088 1088
 
1089
-		if( isset( $_POST['lesson-order'] ) ) {
1089
+		if (isset($_POST['lesson-order'])) {
1090 1090
 
1091
-			$ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) );
1091
+			$ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id']));
1092 1092
 
1093
-			if( $ordered ) {
1094
-				$html .= '<div class="updated fade">' . "\n";
1095
-				$html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
1096
-				$html .= '</div>' . "\n";
1093
+			if ($ordered) {
1094
+				$html .= '<div class="updated fade">'."\n";
1095
+				$html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n";
1096
+				$html .= '</div>'."\n";
1097 1097
 			}
1098 1098
 		}
1099 1099
 
@@ -1104,43 +1104,43 @@  discard block
 block discarded – undo
1104 1104
 			'orderby' => 'name',
1105 1105
 			'order' => 'ASC',
1106 1106
 		);
1107
-		$courses = get_posts( $args );
1107
+		$courses = get_posts($args);
1108 1108
 
1109
-		$html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n";
1110
-		$html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n";
1111
-		$html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n";
1112
-		$html .= '<select id="lesson-order-course" name="course_id">' . "\n";
1113
-		$html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n";
1109
+		$html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n";
1110
+		$html .= '<input type="hidden" name="post_type" value="lesson" />'."\n";
1111
+		$html .= '<input type="hidden" name="page" value="lesson-order" />'."\n";
1112
+		$html .= '<select id="lesson-order-course" name="course_id">'."\n";
1113
+		$html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n";
1114 1114
 
1115
-		foreach( $courses as $course ) {
1115
+		foreach ($courses as $course) {
1116 1116
 			$course_id = '';
1117
-			if( isset( $_GET['course_id'] ) ) {
1118
-				$course_id = intval( $_GET['course_id'] );
1117
+			if (isset($_GET['course_id'])) {
1118
+				$course_id = intval($_GET['course_id']);
1119 1119
 			}
1120
-			$html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n";
1120
+			$html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n";
1121 1121
 		}
1122 1122
 
1123
-		$html .= '</select>' . "\n";
1124
-		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n";
1125
-		$html .= '</form>' . "\n";
1123
+		$html .= '</select>'."\n";
1124
+		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n";
1125
+		$html .= '</form>'."\n";
1126 1126
 
1127
-		$html .= '<script type="text/javascript">' . "\n";
1128
-		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n";
1129
-		$html .= '</script>' . "\n";
1127
+		$html .= '<script type="text/javascript">'."\n";
1128
+		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n";
1129
+		$html .= '</script>'."\n";
1130 1130
 
1131
-		if( isset( $_GET['course_id'] ) ) {
1132
-			$course_id = intval( $_GET['course_id'] );
1133
-			if( $course_id > 0 ) {
1131
+		if (isset($_GET['course_id'])) {
1132
+			$course_id = intval($_GET['course_id']);
1133
+			if ($course_id > 0) {
1134 1134
 
1135
-				$order_string = $this->get_lesson_order( $course_id );
1135
+				$order_string = $this->get_lesson_order($course_id);
1136 1136
 
1137
-				$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1137
+				$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1138 1138
 
1139 1139
 				$displayed_lessons = array();
1140 1140
 
1141
-                $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1141
+                $modules = Sensei()->modules->get_course_modules(intval($course_id));
1142 1142
 
1143
-                foreach( $modules as $module ) {
1143
+                foreach ($modules as $module) {
1144 1144
 
1145 1145
                     $args = array(
1146 1146
                         'post_type' => 'lesson',
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
                         'meta_query' => array(
1150 1150
                             array(
1151 1151
                                 'key' => '_lesson_course',
1152
-                                'value' => intval( $course_id ),
1152
+                                'value' => intval($course_id),
1153 1153
                                 'compare' => '='
1154 1154
                             )
1155 1155
                         ),
@@ -1157,66 +1157,66 @@  discard block
 block discarded – undo
1157 1157
                             array(
1158 1158
                                 'taxonomy' => Sensei()->modules->taxonomy,
1159 1159
                                 'field' => 'id',
1160
-                                'terms' => intval( $module->term_id )
1160
+                                'terms' => intval($module->term_id)
1161 1161
                             )
1162 1162
                         ),
1163
-                        'meta_key' => '_order_module_' . $module->term_id,
1163
+                        'meta_key' => '_order_module_'.$module->term_id,
1164 1164
                         'orderby' => 'meta_value_num date',
1165 1165
                         'order' => 'ASC',
1166 1166
                         'suppress_filters' => 0
1167 1167
                     );
1168 1168
 
1169
-                    $lessons = get_posts( $args );
1169
+                    $lessons = get_posts($args);
1170 1170
 
1171
-                    if( count( $lessons ) > 0 ) {
1172
-                        $html .= '<h3>' . $module->name . '</h3>' . "\n";
1173
-                        $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1171
+                    if (count($lessons) > 0) {
1172
+                        $html .= '<h3>'.$module->name.'</h3>'."\n";
1173
+                        $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n";
1174 1174
 
1175 1175
                         $count = 0;
1176
-                        foreach( $lessons as $lesson ) {
1176
+                        foreach ($lessons as $lesson) {
1177 1177
                             $count++;
1178 1178
                             $class = 'lesson';
1179
-                            if ( $count == 1 ) { $class .= ' first'; }
1180
-                            if ( $count == count( $lesson ) ) { $class .= ' last'; }
1181
-                            if ( $count % 2 != 0 ) {
1179
+                            if ($count == 1) { $class .= ' first'; }
1180
+                            if ($count == count($lesson)) { $class .= ' last'; }
1181
+                            if ($count % 2 != 0) {
1182 1182
                                 $class .= ' alternate';
1183 1183
                             }
1184 1184
 
1185
-                            $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1185
+                            $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1186 1186
 
1187 1187
                             $displayed_lessons[] = $lesson->ID;
1188 1188
                         }
1189 1189
 
1190
-                        $html .= '</ul>' . "\n";
1190
+                        $html .= '</ul>'."\n";
1191 1191
 
1192
-                        $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1192
+                        $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n";
1193 1193
                     }
1194 1194
                 }
1195 1195
 
1196 1196
 
1197
-                $lessons = Sensei()->course->course_lessons( $course_id );
1197
+                $lessons = Sensei()->course->course_lessons($course_id);
1198 1198
 
1199
-				if( 0 < count( $lessons ) ) {
1199
+				if (0 < count($lessons)) {
1200 1200
 
1201 1201
                     //get module term ids, will be used to exclude lessons
1202 1202
                     $module_items_ids = array();
1203
-                    if( ! empty( $modules ) ) {
1203
+                    if ( ! empty($modules)) {
1204 1204
                         foreach ($modules as $module) {
1205 1205
                             $module_items_ids[] = $module->term_id;
1206 1206
                         }
1207 1207
                     }
1208 1208
 
1209
-					if( 0 < count( $displayed_lessons ) ) {
1210
-						$html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n";
1209
+					if (0 < count($displayed_lessons)) {
1210
+						$html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n";
1211 1211
 					}
1212 1212
 
1213
-					$html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n";
1213
+					$html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n";
1214 1214
 					$count = 0;
1215
-					foreach ( $lessons as $lesson ) {
1215
+					foreach ($lessons as $lesson) {
1216 1216
 
1217 1217
                         // if lesson belongs to one fo the course modules then exclude it here
1218 1218
                         // as it is listed above
1219
-                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1219
+                        if (has_term($module_items_ids, 'module', $lesson->ID)) {
1220 1220
 
1221 1221
                             continue;
1222 1222
 
@@ -1224,28 +1224,28 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
 						$count++;
1226 1226
 						$class = 'lesson';
1227
-						if ( $count == 1 ) { $class .= ' first'; }
1228
-						if ( $count == count( $lesson ) ) { $class .= ' last'; }
1229
-						if ( $count % 2 != 0 ) {
1227
+						if ($count == 1) { $class .= ' first'; }
1228
+						if ($count == count($lesson)) { $class .= ' last'; }
1229
+						if ($count % 2 != 0) {
1230 1230
 
1231 1231
 							$class .= ' alternate';
1232 1232
 
1233 1233
 						}
1234
-						$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1234
+						$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1235 1235
 
1236 1236
 						$displayed_lessons[] = $lesson->ID;
1237 1237
 					}
1238
-					$html .= '</ul>' . "\n";
1238
+					$html .= '</ul>'."\n";
1239 1239
 				} else {
1240
-					if( 0 == count( $displayed_lessons ) ) {
1241
-						$html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>';
1240
+					if (0 == count($displayed_lessons)) {
1241
+						$html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>';
1242 1242
 					}
1243 1243
 				}
1244 1244
 
1245
-				if( 0 < count( $displayed_lessons ) ) {
1246
-					$html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1247
-					$html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n";
1248
-					$html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n";
1245
+				if (0 < count($displayed_lessons)) {
1246
+					$html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n";
1247
+					$html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n";
1248
+					$html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n";
1249 1249
 				}
1250 1250
 			}
1251 1251
 		}
@@ -1255,27 +1255,27 @@  discard block
 block discarded – undo
1255 1255
 		?></div><?php
1256 1256
 	}
1257 1257
 
1258
-	public function get_lesson_order( $course_id = 0 ) {
1259
-		$order_string = get_post_meta( $course_id, '_lesson_order', true );
1258
+	public function get_lesson_order($course_id = 0) {
1259
+		$order_string = get_post_meta($course_id, '_lesson_order', true);
1260 1260
 		return $order_string;
1261 1261
 	}
1262 1262
 
1263
-	public function save_lesson_order( $order_string = '', $course_id = 0 ) {
1263
+	public function save_lesson_order($order_string = '', $course_id = 0) {
1264 1264
 
1265
-		if( $course_id ) {
1265
+		if ($course_id) {
1266 1266
 
1267
-            $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1267
+            $modules = Sensei()->modules->get_course_modules(intval($course_id));
1268 1268
 
1269
-            foreach( $modules as $module ) {
1269
+            foreach ($modules as $module) {
1270 1270
 
1271
-                $module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ];
1271
+                $module_order_string = $_POST['lesson-order-module-'.$module->term_id];
1272 1272
 
1273
-                if( $module_order_string ) {
1274
-                    $order = explode( ',', $module_order_string );
1273
+                if ($module_order_string) {
1274
+                    $order = explode(',', $module_order_string);
1275 1275
                     $i = 1;
1276
-                    foreach( $order as $lesson_id ) {
1277
-                        if( $lesson_id ) {
1278
-                            update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1276
+                    foreach ($order as $lesson_id) {
1277
+                        if ($lesson_id) {
1278
+                            update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i);
1279 1279
                             ++$i;
1280 1280
                         }
1281 1281
                     }
@@ -1283,15 +1283,15 @@  discard block
 block discarded – undo
1283 1283
             }
1284 1284
 
1285 1285
 
1286
-			if( $order_string ) {
1287
-				update_post_meta( $course_id, '_lesson_order', $order_string );
1286
+			if ($order_string) {
1287
+				update_post_meta($course_id, '_lesson_order', $order_string);
1288 1288
 
1289
-				$order = explode( ',', $order_string );
1289
+				$order = explode(',', $order_string);
1290 1290
 
1291 1291
 				$i = 1;
1292
-				foreach( $order as $lesson_id ) {
1293
-					if( $lesson_id ) {
1294
-						update_post_meta( $lesson_id, '_order_' . $course_id, $i );
1292
+				foreach ($order as $lesson_id) {
1293
+					if ($lesson_id) {
1294
+						update_post_meta($lesson_id, '_order_'.$course_id, $i);
1295 1295
 						++$i;
1296 1296
 					}
1297 1297
 				}
@@ -1306,54 +1306,54 @@  discard block
 block discarded – undo
1306 1306
 	function sensei_add_custom_menu_items() {
1307 1307
 		global $pagenow;
1308 1308
 
1309
-		if( 'nav-menus.php' == $pagenow ) {
1310
-			add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' );
1309
+		if ('nav-menus.php' == $pagenow) {
1310
+			add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low');
1311 1311
 		}
1312 1312
 	}
1313 1313
 
1314
-	function wp_nav_menu_item_sensei_links_meta_box( $object ) {
1314
+	function wp_nav_menu_item_sensei_links_meta_box($object) {
1315 1315
 		global $nav_menu_selected_id;
1316 1316
 
1317 1317
 		$menu_items = array(
1318
-			'#senseicourses' => __( 'Courses', 'woothemes-sensei' ),
1319
-			'#senseilessons' => __( 'Lessons', 'woothemes-sensei' ),
1320
-			'#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ),
1321
-			'#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ),
1322
-			'#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ),
1323
-			'#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' )
1318
+			'#senseicourses' => __('Courses', 'woothemes-sensei'),
1319
+			'#senseilessons' => __('Lessons', 'woothemes-sensei'),
1320
+			'#senseimycourses' => __('My Courses', 'woothemes-sensei'),
1321
+			'#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'),
1322
+			'#senseimymessages' => __('My Messages', 'woothemes-sensei'),
1323
+			'#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei')
1324 1324
 		);
1325 1325
 
1326 1326
 		$menu_items_obj = array();
1327
-		foreach ( $menu_items as $value => $title ) {
1327
+		foreach ($menu_items as $value => $title) {
1328 1328
 			$menu_items_obj[$title] = new stdClass;
1329
-			$menu_items_obj[$title]->object_id			= esc_attr( $value );
1330
-			$menu_items_obj[$title]->title				= esc_attr( $title );
1331
-			$menu_items_obj[$title]->url				= esc_attr( $value );
1332
-			$menu_items_obj[$title]->description 		= 'description';
1329
+			$menu_items_obj[$title]->object_id = esc_attr($value);
1330
+			$menu_items_obj[$title]->title = esc_attr($title);
1331
+			$menu_items_obj[$title]->url = esc_attr($value);
1332
+			$menu_items_obj[$title]->description = 'description';
1333 1333
 			$menu_items_obj[$title]->db_id 				= 0;
1334 1334
 			$menu_items_obj[$title]->object 			= 'sensei';
1335
-			$menu_items_obj[$title]->menu_item_parent 	= 0;
1336
-			$menu_items_obj[$title]->type 				= 'custom';
1335
+			$menu_items_obj[$title]->menu_item_parent = 0;
1336
+			$menu_items_obj[$title]->type = 'custom';
1337 1337
 			$menu_items_obj[$title]->target 			= '';
1338
-			$menu_items_obj[$title]->attr_title 		= '';
1339
-			$menu_items_obj[$title]->classes 			= array();
1340
-			$menu_items_obj[$title]->xfn 				= '';
1338
+			$menu_items_obj[$title]->attr_title = '';
1339
+			$menu_items_obj[$title]->classes = array();
1340
+			$menu_items_obj[$title]->xfn = '';
1341 1341
 		}
1342 1342
 
1343
-		$walker = new Walker_Nav_Menu_Checklist( array() );
1343
+		$walker = new Walker_Nav_Menu_Checklist(array());
1344 1344
 		?>
1345 1345
 
1346 1346
 		<div id="sensei-links" class="senseidiv taxonomydiv">
1347 1347
 			<div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
1348 1348
 
1349 1349
 				<ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear">
1350
-					<?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?>
1350
+					<?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?>
1351 1351
 				</ul>
1352 1352
 
1353 1353
 			</div>
1354 1354
 			<p class="button-controls">
1355 1355
 				<span class="add-to-menu">
1356
-					<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'woothemes-sensei' ); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1356
+					<input type="submit"<?php disabled($nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'woothemes-sensei'); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1357 1357
 					<span class="spinner"></span>
1358 1358
 				</span>
1359 1359
 			</p>
@@ -1369,17 +1369,17 @@  discard block
 block discarded – undo
1369 1369
 	 */
1370 1370
 	public function theme_compatibility_notices() {
1371 1371
 
1372
-        if( isset( $_GET['sensei_hide_notice'] ) ) {
1373
-        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1374
-				case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break;
1375
-				case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break;
1372
+        if (isset($_GET['sensei_hide_notice'])) {
1373
+        	switch (esc_attr($_GET['sensei_hide_notice'])) {
1374
+				case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break;
1375
+				case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break;
1376 1376
 			}
1377 1377
         }
1378 1378
 
1379 1379
         // white list templates that are already support by default and do not show notice for them
1380
-        $template = get_option( 'template' );
1380
+        $template = get_option('template');
1381 1381
 
1382
-        $white_list = array(    'twentyeleven',
1382
+        $white_list = array('twentyeleven',
1383 1383
                                 'twentytwelve',
1384 1384
                                 'twentyfourteen',
1385 1385
                                 'twentyfifteen',
@@ -1387,43 +1387,43 @@  discard block
 block discarded – undo
1387 1387
                                 'storefront',
1388 1388
                                                 );
1389 1389
 
1390
-        if ( in_array( $template, $white_list ) ) {
1390
+        if (in_array($template, $white_list)) {
1391 1391
 
1392 1392
             return;
1393 1393
 
1394 1394
         }
1395 1395
 
1396 1396
         // don't show the notice if the user chose to hide it
1397
-        $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1398
-        if(  $hide_theme_check_notice ) {
1397
+        $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true);
1398
+        if ($hide_theme_check_notice) {
1399 1399
 
1400 1400
             return;
1401 1401
 
1402 1402
         }
1403 1403
 
1404 1404
         // show the notice for themes not supporting sensei
1405
-	    if ( ! current_theme_supports( 'sensei' ) ) {
1405
+	    if ( ! current_theme_supports('sensei')) {
1406 1406
             ?>
1407 1407
 
1408 1408
             <div id="message" class="error sensei-message sensei-connect">
1409 1409
                     <p>
1410 1410
                         <strong>
1411 1411
 
1412
-                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?>
1412
+                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?>
1413 1413
 
1414 1414
                         </strong> &#8211;
1415 1415
 
1416
-                        <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?>
1416
+                        <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?>
1417 1417
 
1418
-                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a>
1418
+                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e('Sensei theme', 'woothemes-sensei') ?> </a>
1419 1419
 
1420 1420
                         :)
1421 1421
 
1422 1422
                     </p>
1423 1423
                     <p class="submit">
1424
-                        <a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility' ) ); ?>" class="button-primary">
1424
+                        <a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility')); ?>" class="button-primary">
1425 1425
 
1426
-                            <?php _e( 'Theme Integration Guide', 'woothemes-sensei' ); ?></a> <a class="skip button" href="<?php echo esc_url( add_query_arg( 'sensei_hide_notice', 'theme_check' ) ); ?>"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?>
1426
+                            <?php _e('Theme Integration Guide', 'woothemes-sensei'); ?></a> <a class="skip button" href="<?php echo esc_url(add_query_arg('sensei_hide_notice', 'theme_check')); ?>"><?php _e('Hide this notice', 'woothemes-sensei'); ?>
1427 1427
 
1428 1428
                         </a>
1429 1429
                     </p>
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 		wp_get_current_user();
1442 1442
         $user_id = $current_user->ID;
1443 1443
 
1444
-		delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' );
1444
+		delete_user_meta($user_id, 'sensei_hide_theme_check_notice');
1445 1445
 	}
1446 1446
 
1447 1447
 	/**
@@ -1451,8 +1451,8 @@  discard block
 block discarded – undo
1451 1451
 	 * @param  bool $prevent_access
1452 1452
 	 * @return bool
1453 1453
 	 */
1454
-	public function admin_access( $prevent_access ) {
1455
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
1454
+	public function admin_access($prevent_access) {
1455
+		if (current_user_can('manage_sensei_grades')) {
1456 1456
 			return false;
1457 1457
 		}
1458 1458
 
@@ -1467,12 +1467,12 @@  discard block
 block discarded – undo
1467 1467
      *
1468 1468
      * @since 1.8.7
1469 1469
      */
1470
-    public  static function install_pages(){
1470
+    public  static function install_pages() {
1471 1471
 
1472 1472
         // only fire on the settings page
1473
-        if( ! isset( $_GET['page'] )
1473
+        if ( ! isset($_GET['page'])
1474 1474
             || 'woothemes-sensei-settings' != $_GET['page']
1475
-            || 1 == get_option('skip_install_sensei_pages') ){
1475
+            || 1 == get_option('skip_install_sensei_pages')) {
1476 1476
 
1477 1477
             return;
1478 1478
 
@@ -1502,13 +1502,13 @@  discard block
 block discarded – undo
1502 1502
         if ($install_complete) {
1503 1503
 
1504 1504
             // Flush rules after install
1505
-            flush_rewrite_rules( true );
1505
+            flush_rewrite_rules(true);
1506 1506
 
1507 1507
             // Set installed option
1508 1508
             update_option('sensei_installed', 0);
1509 1509
 
1510
-            $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1511
-            wp_redirect( $complete_url );
1510
+            $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url);
1511
+            wp_redirect($complete_url);
1512 1512
 
1513 1513
         }
1514 1514
 
@@ -1521,4 +1521,4 @@  discard block
 block discarded – undo
1521 1521
  * for backward compatibility
1522 1522
  * @since 1.9.0
1523 1523
  */
1524
-class WooThemes_Sensei_Admin extends Sensei_Admin{ }
1524
+class WooThemes_Sensei_Admin extends Sensei_Admin { }
Please login to merge, or discard this patch.
templates/globals/wrapper-end.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * Content wrappers
5 5
  *
Please login to merge, or discard this patch.
templates/single-quiz/question_type-multi-line.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
 
15 15
 <?php
16 16
 
17
-    /**
18
-     * Get the question data with the current quiz id
19
-     * All data is loaded in this array to keep the template clean.
20
-     */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
17
+	/**
18
+	 * Get the question data with the current quiz id
19
+	 * All data is loaded in this array to keep the template clean.
20
+	 */
21
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+	Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
+												'textquestion' . $question_data[ 'ID' ] ,
29
+												'sensei_question[' . $question_data[ 'ID' ] . ']' );
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying Multi Line Questions.
5 5
  *
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
      * Get the question data with the current quiz id
19 19
      * All data is loaded in this array to keep the template clean.
20 20
      */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
21
+    $question_data = WooThemes_Sensei_Question::get_template_data(sensei_get_the_question_id(), get_the_ID());
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+    Sensei_Utils::sensei_text_editor($question_data['user_answer_entry'],
28
+                                                'textquestion'.$question_data['ID'],
29
+                                                'sensei_question['.$question_data['ID'].']');
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.
templates/course-results/lessons.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 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;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying all course lessons on the course results page.
5 5
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 global $course;
15 15
 ?>
16 16
 
17
-<?php if ( is_user_logged_in() ): ?>
17
+<?php if (is_user_logged_in()): ?>
18 18
 
19 19
     <?php
20 20
     /**
@@ -22,53 +22,53 @@  discard block
 block discarded – undo
22 22
      * is uer logged check, just above the lessons header.
23 23
      * @since 1.4.0
24 24
      */
25
-    do_action( 'sensei_course_results_before_lessons', $course->ID );
25
+    do_action('sensei_course_results_before_lessons', $course->ID);
26 26
     ?>
27 27
 
28 28
     <header>
29 29
 
30
-        <h2>  <?php _e( 'Lessons', 'woothemes-sensei' );  ?> </h2>
30
+        <h2>  <?php _e('Lessons', 'woothemes-sensei'); ?> </h2>
31 31
 
32 32
     </header>
33 33
 
34
-    <article class="<?php  esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ), $course->ID ) ) ); ?> ">
34
+    <article class="<?php  esc_attr_e(join(' ', get_post_class(array('course', 'post'), $course->ID))); ?> ">
35 35
 
36 36
         <?php
37 37
 
38 38
 		$displayed_lessons = array();
39
-        $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
39
+        $modules = Sensei()->modules->get_course_modules(intval($course->ID));
40 40
 
41 41
         // List modules with lessons
42
-        foreach( $modules as $module ) {
42
+        foreach ($modules as $module) {
43 43
 
44
-            $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
44
+            $lessons_query = Sensei()->modules->get_lessons_query($course->ID, $module->term_id);
45 45
             $lessons = $lessons_query->get_posts();
46 46
 
47
-            if( count( $lessons ) > 0 ) { ?>
47
+            if (count($lessons) > 0) { ?>
48 48
 
49 49
                 <h3> <?php echo $module->name; ?></h3>
50 50
 
51 51
                 <?php
52 52
                 $count = 0;
53
-                foreach( $lessons as $lesson ) {
53
+                foreach ($lessons as $lesson) {
54 54
 
55 55
                     $lesson_grade = 'n/a';
56
-                    $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
-                    if ( $has_questions ) {
58
-                        $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
56
+                    $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
57
+                    if ($has_questions) {
58
+                        $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id());
59 59
                         // Get user quiz grade
60
-                        $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
-                        if ( $lesson_grade ) {
60
+                        $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
61
+                        if ($lesson_grade) {
62 62
                             $lesson_grade .= '%';
63 63
                         }
64 64
                     }
65 65
                     ?>
66 66
                     <h2>
67 67
 
68
-                        <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>"
69
-                           title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>">
68
+                        <a href="<?php esc_url_raw(get_permalink($lesson->ID)); ?>"
69
+                           title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)); ?>">
70 70
 
71
-                            <?php esc_html_e( $lesson->post_title ); ?>
71
+                            <?php esc_html_e($lesson->post_title); ?>
72 72
 
73 73
                         </a>
74 74
 
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 
90 90
         <?php
91 91
 
92
-        $lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
-        if( 0 < count( $lessons ) ): ?>
92
+        $lessons = Sensei()->modules->get_none_module_lessons($course->ID);
93
+        if (0 < count($lessons)): ?>
94 94
 
95 95
 			<h3>
96 96
 
97
-                <?php _e( 'Other Lessons', 'woothemes-sensei' ); ?>
97
+                <?php _e('Other Lessons', 'woothemes-sensei'); ?>
98 98
 
99 99
             </h3>
100 100
 
101
-            <?php foreach ( $lessons as $lesson ): ?>
101
+            <?php foreach ($lessons as $lesson): ?>
102 102
 
103 103
                 <?php
104 104
                 $lesson_grade = 'n/a';
105
-                $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
-                if ( $has_questions ) {
107
-                    $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
105
+                $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
106
+                if ($has_questions) {
107
+                    $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id());
108 108
                     // Get user quiz grade
109
-                    $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
-                    if ( $lesson_grade ) {
109
+                    $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
110
+                    if ($lesson_grade) {
111 111
                         $lesson_grade .= '%';
112 112
                     }
113 113
                 }
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 
116 116
                 <h2>
117 117
 
118
-                    <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ) ?>" title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ) ?>" >
118
+                    <a href="<?php esc_url_raw(get_permalink($lesson->ID)) ?>" title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)) ?>" >
119 119
 
120
-                        <?php esc_html_e( sprintf( __( '%s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>
120
+                        <?php esc_html_e(sprintf(__('%s', 'woothemes-sensei'), $lesson->post_title)); ?>
121 121
 
122 122
                     </a>
123 123
 
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 
133 133
         <h2 class="total-grade">
134 134
 
135
-            <?php _e( 'Total Grade', 'woothemes-sensei' ); ?>
135
+            <?php _e('Total Grade', 'woothemes-sensei'); ?>
136 136
             <span class="lesson-grade">
137 137
 
138 138
                 <?php
139 139
 
140
-                    $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
-                    echo $course_user_grade . '%';
140
+                    $course_user_grade = Sensei_Utils::sensei_course_user_grade($course->ID, get_current_user_id());
141
+                    echo $course_user_grade.'%';
142 142
 
143 143
                 ?>
144 144
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @since 1.4.0
157 157
      */
158
-	do_action( 'sensei_course_results_after_lessons', $course->ID );
158
+	do_action('sensei_course_results_after_lessons', $course->ID);
159 159
     ?>
160 160
 
161 161
 <?php endif; //user logged in ?>
162 162
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for displaying all course lessons on the course results page.
5
- *
6
- * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+		 * The Template for displaying all course lessons on the course results page.
5
+		 *
6
+		 * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php
7
+		 *
8
+		 * @author 		Automattic
9
+		 * @package 	Sensei
10
+		 * @category    Templates
11
+		 * @version     1.9.0
12
+		 */
13 13
 
14 14
 global $course;
15 15
 ?>
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 <?php if ( is_user_logged_in() ): ?>
18 18
 
19 19
     <?php
20
-    /**
21
-     * Fires inside course-results/lessons.php after the
22
-     * is uer logged check, just above the lessons header.
23
-     * @since 1.4.0
24
-     */
25
-    do_action( 'sensei_course_results_before_lessons', $course->ID );
26
-    ?>
20
+	/**
21
+	 * Fires inside course-results/lessons.php after the
22
+	 * is uer logged check, just above the lessons header.
23
+	 * @since 1.4.0
24
+	 */
25
+	do_action( 'sensei_course_results_before_lessons', $course->ID );
26
+	?>
27 27
 
28 28
     <header>
29 29
 
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
         <?php
37 37
 
38 38
 		$displayed_lessons = array();
39
-        $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
39
+		$modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
40 40
 
41
-        // List modules with lessons
42
-        foreach( $modules as $module ) {
41
+		// List modules with lessons
42
+		foreach( $modules as $module ) {
43 43
 
44
-            $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
45
-            $lessons = $lessons_query->get_posts();
44
+			$lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
45
+			$lessons = $lessons_query->get_posts();
46 46
 
47
-            if( count( $lessons ) > 0 ) { ?>
47
+			if( count( $lessons ) > 0 ) { ?>
48 48
 
49 49
                 <h3> <?php echo $module->name; ?></h3>
50 50
 
51 51
                 <?php
52
-                $count = 0;
53
-                foreach( $lessons as $lesson ) {
54
-
55
-                    $lesson_grade = 'n/a';
56
-                    $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
-                    if ( $has_questions ) {
58
-                        $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
59
-                        // Get user quiz grade
60
-                        $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
-                        if ( $lesson_grade ) {
62
-                            $lesson_grade .= '%';
63
-                        }
64
-                    }
65
-                    ?>
52
+				$count = 0;
53
+				foreach( $lessons as $lesson ) {
54
+
55
+					$lesson_grade = 'n/a';
56
+					$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
+					if ( $has_questions ) {
58
+						$lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
59
+						// Get user quiz grade
60
+						$lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
+						if ( $lesson_grade ) {
62
+							$lesson_grade .= '%';
63
+						}
64
+					}
65
+					?>
66 66
                     <h2>
67 67
 
68 68
                         <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>"
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 
81 81
                 <?php
82 82
 
83
-                }// end for each
83
+				}// end for each
84 84
 
85
-            }// end if count lesson
85
+			}// end if count lesson
86 86
 
87
-        } // end for each module
88
-        ?>
87
+		} // end for each module
88
+		?>
89 89
 
90 90
         <?php
91 91
 
92
-        $lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
-        if( 0 < count( $lessons ) ): ?>
92
+		$lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
+		if( 0 < count( $lessons ) ): ?>
94 94
 
95 95
 			<h3>
96 96
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
             <?php foreach ( $lessons as $lesson ): ?>
102 102
 
103 103
                 <?php
104
-                $lesson_grade = 'n/a';
105
-                $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
-                if ( $has_questions ) {
107
-                    $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
108
-                    // Get user quiz grade
109
-                    $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
-                    if ( $lesson_grade ) {
111
-                        $lesson_grade .= '%';
112
-                    }
113
-                }
114
-                ?>
104
+				$lesson_grade = 'n/a';
105
+				$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
+				if ( $has_questions ) {
107
+					$lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
108
+					// Get user quiz grade
109
+					$lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
+					if ( $lesson_grade ) {
111
+						$lesson_grade .= '%';
112
+					}
113
+				}
114
+				?>
115 115
 
116 116
                 <h2>
117 117
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
                 <?php
139 139
 
140
-                    $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
-                    echo $course_user_grade . '%';
140
+					$course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
+					echo $course_user_grade . '%';
142 142
 
143
-                ?>
143
+				?>
144 144
 
145 145
             </span>
146 146
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
     </article>
150 150
 
151 151
     <?php
152
-    /**
153
-     * Fires inside course-results/lessons.php after the
154
-     * is uer logged check, at the bottom of all lessons.
155
-     *
156
-     * @since 1.4.0
157
-     */
152
+	/**
153
+	 * Fires inside course-results/lessons.php after the
154
+	 * is uer logged check, at the bottom of all lessons.
155
+	 *
156
+	 * @since 1.4.0
157
+	 */
158 158
 	do_action( 'sensei_course_results_after_lessons', $course->ID );
159
-    ?>
159
+	?>
160 160
 
161 161
 <?php endif; //user logged in ?>
162 162
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-sensei-wc.php 4 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; // security check, don't load file outside WP
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// security check, don't load file outside WP
3 6
 /**
4 7
  * Sensei Autoloader Class
5 8
  *
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -817,7 +817,7 @@
 block discarded – undo
817 817
      * @param  int $user_id
818 818
      * @param  int $product_id
819 819
      *
820
-     * @return bool
820
+     * @return boolean|null
821 821
      */
822 822
     public static function has_customer_bought_product ( $user_id, $product_id ){
823 823
 
Please login to merge, or discard this patch.
Indentation   +745 added lines, -745 removed lines patch added patch discarded remove patch
@@ -12,735 +12,735 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 Class Sensei_WC{
15
-    /**
16
-     * Load the files needed for the woocommerce integration.
17
-     *
18
-     * @since 1.9.0
19
-     */
20
-    public static function load_woocommerce_integration_hooks(){
15
+	/**
16
+	 * Load the files needed for the woocommerce integration.
17
+	 *
18
+	 * @since 1.9.0
19
+	 */
20
+	public static function load_woocommerce_integration_hooks(){
21 21
 
22
-        require_once( __DIR__ . '/hooks/woocommerce.php' );
22
+		require_once( __DIR__ . '/hooks/woocommerce.php' );
23 23
 
24
-    }
25
-    /**
26
-     * check if WooCommerce plugin is loaded and allowed by Sensei
27
-     *
28
-     * @since 1.9.0
29
-     * @return bool
30
-     */
31
-    public static function is_woocommerce_active(){
24
+	}
25
+	/**
26
+	 * check if WooCommerce plugin is loaded and allowed by Sensei
27
+	 *
28
+	 * @since 1.9.0
29
+	 * @return bool
30
+	 */
31
+	public static function is_woocommerce_active(){
32 32
 
33
-        $is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
34
-        return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
33
+		$is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
34
+		return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
35 35
 
36
-    } // end is_woocommerce_active
36
+	} // end is_woocommerce_active
37 37
 
38
-    /**
39
-     * Checks if the WooCommerce plugin is installed and activation.
40
-     *
41
-     * If you need to check if WooCommerce is activated use Sensei_Utils::is_woocommerce_active().
42
-     * This function does nott check to see if the Sensei setting for WooCommerce is enabled.
43
-     *
44
-     * @since 1.9.0
45
-     *
46
-     * @return bool
47
-     */
48
-    public static function is_woocommerce_present(){
38
+	/**
39
+	 * Checks if the WooCommerce plugin is installed and activation.
40
+	 *
41
+	 * If you need to check if WooCommerce is activated use Sensei_Utils::is_woocommerce_active().
42
+	 * This function does nott check to see if the Sensei setting for WooCommerce is enabled.
43
+	 *
44
+	 * @since 1.9.0
45
+	 *
46
+	 * @return bool
47
+	 */
48
+	public static function is_woocommerce_present(){
49 49
 
50
-        $active_plugins = (array) get_option( 'active_plugins', array() );
50
+		$active_plugins = (array) get_option( 'active_plugins', array() );
51 51
 
52
-        if ( is_multisite() ){
52
+		if ( is_multisite() ){
53 53
 
54
-            $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
54
+			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
55 55
 
56
-        }
56
+		}
57 57
 
58
-        $is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
58
+		$is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
59 59
 
60
-        return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
60
+		return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
61 61
 
62
-    }// end is_woocommerce_present
62
+	}// end is_woocommerce_present
63 63
 
64
-    /**
65
-     * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
66
-     *
67
-     * If multiple exist we will return the latest order.
68
-     *
69
-     * @param $user_id
70
-     * @param $course_id
71
-     * @return array $user_course_orders
72
-     */
73
-    public static function get_learner_course_active_order_id( $user_id, $course_id ){
64
+	/**
65
+	 * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
66
+	 *
67
+	 * If multiple exist we will return the latest order.
68
+	 *
69
+	 * @param $user_id
70
+	 * @param $course_id
71
+	 * @return array $user_course_orders
72
+	 */
73
+	public static function get_learner_course_active_order_id( $user_id, $course_id ){
74 74
 
75
-        $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
75
+		$course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
76 76
 
77
-        $orders_query = new WP_Query( array(
78
-            'post_type'   => 'shop_order',
79
-            'posts_per_page' => -1,
80
-            'post_status' => array( 'wc-processing', 'wc-completed' ),
81
-            'meta_key'=> '_customer_user',
82
-            'meta_value'=> $user_id,
83
-        ) );
77
+		$orders_query = new WP_Query( array(
78
+			'post_type'   => 'shop_order',
79
+			'posts_per_page' => -1,
80
+			'post_status' => array( 'wc-processing', 'wc-completed' ),
81
+			'meta_key'=> '_customer_user',
82
+			'meta_value'=> $user_id,
83
+		) );
84 84
 
85
-        if( $orders_query->post_count == 0 ){
85
+		if( $orders_query->post_count == 0 ){
86 86
 
87
-            return false;
87
+			return false;
88 88
 
89
-        }
89
+		}
90 90
 
91
-        foreach( $orders_query->get_posts() as $order ){
91
+		foreach( $orders_query->get_posts() as $order ){
92 92
 
93
-            $order = new WC_Order( $order->ID );
94
-            $items = $order->get_items();
93
+			$order = new WC_Order( $order->ID );
94
+			$items = $order->get_items();
95 95
 
96
-            $user_orders =  array();
96
+			$user_orders =  array();
97 97
 
98
-            foreach( $items as $item ){
98
+			foreach( $items as $item ){
99 99
 
100
-                // if the product id on the order and the one given to this function
101
-                // this order has been placed by the given user on the given course.
102
-                $product = wc_get_product( $item['product_id'] );
100
+				// if the product id on the order and the one given to this function
101
+				// this order has been placed by the given user on the given course.
102
+				$product = wc_get_product( $item['product_id'] );
103 103
 
104
-                if ( $product->is_type( 'variable' )) {
104
+				if ( $product->is_type( 'variable' )) {
105 105
 
106
-                    $item_product_id = $item['variation_id'];
106
+					$item_product_id = $item['variation_id'];
107 107
 
108
-                } else {
108
+				} else {
109 109
 
110
-                    $item_product_id =  $item['product_id'];
110
+					$item_product_id =  $item['product_id'];
111 111
 
112
-                }
112
+				}
113 113
 
114
-                if( $course_product_id == $item_product_id ){
114
+				if( $course_product_id == $item_product_id ){
115 115
 
116
-                    return $order->id;
116
+					return $order->id;
117 117
 
118
-                }
118
+				}
119 119
 
120 120
 
121
-            }//end for each order item
121
+			}//end for each order item
122 122
 
123
-        } // end for each order
123
+		} // end for each order
124 124
 
125
-        // if we reach this place we found no order
126
-        return false;
125
+		// if we reach this place we found no order
126
+		return false;
127 127
 
128
-    } // end get_learner_course_active_order_ids
128
+	} // end get_learner_course_active_order_ids
129 129
 
130
-    /**
131
-     * Output WooCommerce specific course filters
132
-     * Removing the paged argument
133
-     *
134
-     * @since 1.9.0
135
-     * @param $filter_links
136
-     * @return mixed
137
-     */
138
-    public static function add_course_archive_wc_filter_links( $filter_links ){
130
+	/**
131
+	 * Output WooCommerce specific course filters
132
+	 * Removing the paged argument
133
+	 *
134
+	 * @since 1.9.0
135
+	 * @param $filter_links
136
+	 * @return mixed
137
+	 */
138
+	public static function add_course_archive_wc_filter_links( $filter_links ){
139 139
 
140
-        $course_url = remove_query_arg('paged', Sensei_Utils::get_current_url() );
140
+		$course_url = remove_query_arg('paged', Sensei_Utils::get_current_url() );
141 141
 
142
-        $free_courses = self::get_free_courses();
143
-        $paid_courses = self::get_paid_courses();
142
+		$free_courses = self::get_free_courses();
143
+		$paid_courses = self::get_paid_courses();
144 144
 
145
-        if ( empty( $free_courses ) || empty( $paid_courses )  ){
146
-            // do not show any WooCommerce filters if all courses are
147
-            // free or if all courses are paid
148
-            return $filter_links;
145
+		if ( empty( $free_courses ) || empty( $paid_courses )  ){
146
+			// do not show any WooCommerce filters if all courses are
147
+			// free or if all courses are paid
148
+			return $filter_links;
149 149
 
150
-        }
150
+		}
151 151
 
152
-        $filter_links[] = array(    'id'=>'paid' ,
153
-                                    'url'=> add_query_arg('course_filter', 'paid', $course_url),
154
-                                    'title'=>__( 'Paid', 'woothemes-sensei' )
155
-        );
152
+		$filter_links[] = array(    'id'=>'paid' ,
153
+									'url'=> add_query_arg('course_filter', 'paid', $course_url),
154
+									'title'=>__( 'Paid', 'woothemes-sensei' )
155
+		);
156 156
 
157
-        $filter_links[] = array(    'id'=>'free',
158
-                                    'url'=>add_query_arg('course_filter', 'free', $course_url),
159
-                                    'title'=>__( 'Free', 'woothemes-sensei' )
160
-        );
157
+		$filter_links[] = array(    'id'=>'free',
158
+									'url'=>add_query_arg('course_filter', 'free', $course_url),
159
+									'title'=>__( 'Free', 'woothemes-sensei' )
160
+		);
161 161
 
162
-        return $filter_links;
162
+		return $filter_links;
163 163
 
164
-    }// end add_course_archive_wc_filter_links
164
+	}// end add_course_archive_wc_filter_links
165 165
 
166
-    /**
167
-     * Apply the free filter the the course query
168
-     * getting all course with no products or products with zero price
169
-     *
170
-     * hooked into pre_get_posts
171
-     *
172
-     * @since 1.9.0
173
-     * @param WP_Query $query
174
-     * @return WP_Query $query
175
-     */
176
-    public static function course_archive_wc_filter_free( $query ){
166
+	/**
167
+	 * Apply the free filter the the course query
168
+	 * getting all course with no products or products with zero price
169
+	 *
170
+	 * hooked into pre_get_posts
171
+	 *
172
+	 * @since 1.9.0
173
+	 * @param WP_Query $query
174
+	 * @return WP_Query $query
175
+	 */
176
+	public static function course_archive_wc_filter_free( $query ){
177 177
 
178
-        if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
-            && 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
178
+		if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
+			&& 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
180 180
 
181
-            // setup the course meta query
182
-            $meta_query = self::get_free_courses_meta_query_args();
181
+			// setup the course meta query
182
+			$meta_query = self::get_free_courses_meta_query_args();
183 183
 
184
-            // manipulate the query to return free courses
185
-            $query->set('meta_query', $meta_query );
184
+			// manipulate the query to return free courses
185
+			$query->set('meta_query', $meta_query );
186 186
 
187
-            // don't show any paid courses
188
-            $courses = self::get_paid_courses();
189
-            $ids = array();
190
-            foreach( $courses as $course ){
191
-                $ids[] = $course->ID;
192
-            }
193
-            $query->set( 'post__not_in', $ids );
187
+			// don't show any paid courses
188
+			$courses = self::get_paid_courses();
189
+			$ids = array();
190
+			foreach( $courses as $course ){
191
+				$ids[] = $course->ID;
192
+			}
193
+			$query->set( 'post__not_in', $ids );
194 194
 
195
-        }// end if course_filter
195
+		}// end if course_filter
196 196
 
197
-        return $query;
197
+		return $query;
198 198
 
199
-    }// course_archive_wc_filter_free
199
+	}// course_archive_wc_filter_free
200 200
 
201
-    /**
202
-     * Apply the paid filter to the course query on the courses page
203
-     * will include all course with a product attached with a price
204
-     * more than 0
205
-     *
206
-     * hooked into pre_get_posts
207
-     *
208
-     * @since 1.9.0
209
-     * @param WP_Query $query
210
-     * @return WP_Query $query
211
-     */
212
-    public static function course_archive_wc_filter_paid( $query ){
201
+	/**
202
+	 * Apply the paid filter to the course query on the courses page
203
+	 * will include all course with a product attached with a price
204
+	 * more than 0
205
+	 *
206
+	 * hooked into pre_get_posts
207
+	 *
208
+	 * @since 1.9.0
209
+	 * @param WP_Query $query
210
+	 * @return WP_Query $query
211
+	 */
212
+	public static function course_archive_wc_filter_paid( $query ){
213 213
 
214
-        if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
-            && 'course' == $query->get( 'post_type') && $query->is_main_query() ){
214
+		if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
+			&& 'course' == $query->get( 'post_type') && $query->is_main_query() ){
216 216
 
217
-            // setup the course meta query
218
-            $meta_query = self::get_paid_courses_meta_query_args();
217
+			// setup the course meta query
218
+			$meta_query = self::get_paid_courses_meta_query_args();
219 219
 
220
-            // manipulate the query to return free courses
221
-            $query->set('meta_query', $meta_query );
222
-
223
-        }
224
-
225
-        return $query;
226
-
227
-    }
228
-
229
-    /**
230
-     * Load the WooCommerce single product actions above
231
-     * single courses if woocommerce is active allowing purchase
232
-     * information and actions to be hooked from WooCommerce.
233
-     */
234
-    public static function do_single_course_wc_single_product_action(){
235
-
236
-        /**
237
-         * this hooks is documented within the WooCommerce plugin.
238
-         */
239
-        if ( Sensei_WC::is_woocommerce_active() ) {
240
-
241
-            do_action( 'woocommerce_before_single_product' );
242
-
243
-        } // End If Statement
244
-
245
-    }// end do_single_course_wc_single_product_action
246
-
247
-    /**
248
-     * Hooking into the single lesson page to alter the
249
-     * user access permissions based on if they have purchased the
250
-     * course the lesson belongs to.
251
-     *
252
-     * This function will only return false or the passed in user_access value.
253
-     * It doesn't return true in order to avoid altering other options.
254
-     *
255
-     * @since 1.9.0
256
-     *
257
-     * @param $can_user_view_lesson
258
-     * @param $lesson_id
259
-     * @param $user_id
260
-     * @return bool
261
-     */
262
-    public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
263
-
264
-        // check if the course has a valid product attached to it
265
-        // which the user should have purchased if they want to access
266
-        // the current lesson
267
-        $course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
-        $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
269
-        $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
-        if( isset ($product) && is_object($product) ){
271
-
272
-            // valid product found
273
-            $order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
274
-
275
-            // product has a successful order so this user may access the content
276
-            // this function may only return false or the default
277
-            // returning true may override other negatives which we don't want
278
-            if( ! $order_id ){
279
-
280
-                return false;
281
-
282
-            }
283
-
284
-        }
285
-
286
-        // return the passed in value
287
-        return $can_user_view_lesson;
288
-
289
-    }
290
-
291
-    /**
292
-     * Add course link to order thank you and details pages.
293
-     *
294
-     * @since  1.4.5
295
-     * @access public
296
-     *
297
-     * @return void
298
-     */
299
-    public static function course_link_from_order( ) {
300
-
301
-        if( ! is_order_received_page() ){
302
-            return;
303
-        }
304
-
305
-        $order_id = get_query_var( 'order-received' );
220
+			// manipulate the query to return free courses
221
+			$query->set('meta_query', $meta_query );
222
+
223
+		}
224
+
225
+		return $query;
226
+
227
+	}
228
+
229
+	/**
230
+	 * Load the WooCommerce single product actions above
231
+	 * single courses if woocommerce is active allowing purchase
232
+	 * information and actions to be hooked from WooCommerce.
233
+	 */
234
+	public static function do_single_course_wc_single_product_action(){
235
+
236
+		/**
237
+		 * this hooks is documented within the WooCommerce plugin.
238
+		 */
239
+		if ( Sensei_WC::is_woocommerce_active() ) {
240
+
241
+			do_action( 'woocommerce_before_single_product' );
242
+
243
+		} // End If Statement
244
+
245
+	}// end do_single_course_wc_single_product_action
246
+
247
+	/**
248
+	 * Hooking into the single lesson page to alter the
249
+	 * user access permissions based on if they have purchased the
250
+	 * course the lesson belongs to.
251
+	 *
252
+	 * This function will only return false or the passed in user_access value.
253
+	 * It doesn't return true in order to avoid altering other options.
254
+	 *
255
+	 * @since 1.9.0
256
+	 *
257
+	 * @param $can_user_view_lesson
258
+	 * @param $lesson_id
259
+	 * @param $user_id
260
+	 * @return bool
261
+	 */
262
+	public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
263
+
264
+		// check if the course has a valid product attached to it
265
+		// which the user should have purchased if they want to access
266
+		// the current lesson
267
+		$course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
+		$wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
269
+		$product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
+		if( isset ($product) && is_object($product) ){
271
+
272
+			// valid product found
273
+			$order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
274
+
275
+			// product has a successful order so this user may access the content
276
+			// this function may only return false or the default
277
+			// returning true may override other negatives which we don't want
278
+			if( ! $order_id ){
279
+
280
+				return false;
281
+
282
+			}
283
+
284
+		}
285
+
286
+		// return the passed in value
287
+		return $can_user_view_lesson;
288
+
289
+	}
290
+
291
+	/**
292
+	 * Add course link to order thank you and details pages.
293
+	 *
294
+	 * @since  1.4.5
295
+	 * @access public
296
+	 *
297
+	 * @return void
298
+	 */
299
+	public static function course_link_from_order( ) {
300
+
301
+		if( ! is_order_received_page() ){
302
+			return;
303
+		}
304
+
305
+		$order_id = get_query_var( 'order-received' );
306 306
 		$order = new WC_Order( $order_id );
307 307
 
308 308
 		// exit early if not wc-completed or wc-processing
309 309
 		if( 'wc-completed' != $order->post_status
310
-            && 'wc-processing' != $order->post_status  ) {
311
-            return;
312
-        }
310
+			&& 'wc-processing' != $order->post_status  ) {
311
+			return;
312
+		}
313 313
 
314
-        $course_links = array(); // store the for links for courses purchased
314
+		$course_links = array(); // store the for links for courses purchased
315 315
 		foreach ( $order->get_items() as $item ) {
316 316
 
317
-            if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
317
+			if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
318 318
 
319
-                // If item has variation_id then its a variation of the product
320
-                $item_id = $item['variation_id'];
319
+				// If item has variation_id then its a variation of the product
320
+				$item_id = $item['variation_id'];
321 321
 
322
-            } else {
322
+			} else {
323 323
 
324
-                //If not its real product set its id to item_id
325
-                $item_id = $item['product_id'];
324
+				//If not its real product set its id to item_id
325
+				$item_id = $item['product_id'];
326 326
 
327
-            } // End If Statement
327
+			} // End If Statement
328 328
 
329
-            $user_id = get_post_meta( $order->id, '_customer_user', true );
329
+			$user_id = get_post_meta( $order->id, '_customer_user', true );
330 330
 
331
-            if( $user_id ) {
331
+			if( $user_id ) {
332 332
 
333
-                // Get all courses for product
334
-                $args = Sensei_Course::get_default_query_args();
335
-                $args['meta_query'] = array( array(
336
-                            'key' => '_course_woocommerce_product',
337
-                            'value' => $item_id
338
-                        ) );
339
-                $args['orderby'] = 'menu_order date';
340
-                $args['order'] = 'ASC';
333
+				// Get all courses for product
334
+				$args = Sensei_Course::get_default_query_args();
335
+				$args['meta_query'] = array( array(
336
+							'key' => '_course_woocommerce_product',
337
+							'value' => $item_id
338
+						) );
339
+				$args['orderby'] = 'menu_order date';
340
+				$args['order'] = 'ASC';
341 341
 
342
-                // loop through courses
343
-                $courses = get_posts( $args );
344
-                if( $courses && count( $courses ) > 0 ) {
342
+				// loop through courses
343
+				$courses = get_posts( $args );
344
+				if( $courses && count( $courses ) > 0 ) {
345 345
 
346
-                    foreach( $courses as $course ) {
346
+					foreach( $courses as $course ) {
347 347
 
348
-                        $title = $course->post_title;
349
-                        $permalink = get_permalink( $course->ID );
350
-                        $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
348
+						$title = $course->post_title;
349
+						$permalink = get_permalink( $course->ID );
350
+						$course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
351 351
 
352
-                    } // end for each
352
+					} // end for each
353 353
 
354
-                    // close the message div
354
+					// close the message div
355 355
 
356
-                }// end if $courses check
357
-            }
358
-        }// end loop through orders
356
+				}// end if $courses check
357
+			}
358
+		}// end loop through orders
359 359
 
360
-        // add the courses to the WooCommerce notice
361
-        if( ! empty( $course_links) ){
360
+		// add the courses to the WooCommerce notice
361
+		if( ! empty( $course_links) ){
362 362
 
363
-            $courses_html = _nx(
364
-                'You have purchased the following course:',
365
-                'You have purchased the following courses:',
366
-                count( $course_links ),
367
-                'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368
-            );
363
+			$courses_html = _nx(
364
+				'You have purchased the following course:',
365
+				'You have purchased the following courses:',
366
+				count( $course_links ),
367
+				'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368
+			);
369 369
 
370
-            foreach( $course_links as $link ){
370
+			foreach( $course_links as $link ){
371 371
 
372
-                $courses_html .= '<li>' . $link . '</li>';
372
+				$courses_html .= '<li>' . $link . '</li>';
373 373
 
374
-            }
374
+			}
375 375
 
376
-            $courses_html .= ' </ul>';
376
+			$courses_html .= ' </ul>';
377 377
 
378
-            wc_add_notice( $courses_html, 'success' );
379
-        }
378
+			wc_add_notice( $courses_html, 'success' );
379
+		}
380 380
 
381 381
 	} // end course_link_order_form
382 382
 
383
-    /**
384
-     * Show the message that a user should complete
385
-     * their purchase if the course is in the cart
386
-     *
387
-     * This should be used within the course loop or single course page
388
-     *
389
-     * @since 1.9.0
390
-     */
391
-    public static function course_in_cart_message(){
383
+	/**
384
+	 * Show the message that a user should complete
385
+	 * their purchase if the course is in the cart
386
+	 *
387
+	 * This should be used within the course loop or single course page
388
+	 *
389
+	 * @since 1.9.0
390
+	 */
391
+	public static function course_in_cart_message(){
392 392
 
393
-        global $post;
393
+		global $post;
394 394
 
395
-        if( self::is_course_in_cart( $post->ID ) ){ ?>
395
+		if( self::is_course_in_cart( $post->ID ) ){ ?>
396 396
 
397 397
             <div class="sensei-message info">'
398 398
                 <?php
399 399
 
400
-                $cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
-                              . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
-                              . __('complete the purchase', 'woothemes-sensei') . '</a>';
400
+				$cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
+							  . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
+							  . __('complete the purchase', 'woothemes-sensei') . '</a>';
403 403
 
404
-                sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
404
+				sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
405 405
 
406
-                ?>
406
+				?>
407 407
             </div>
408 408
         <?php }
409 409
 
410
-    } // End sensei_woocommerce_in_cart_message()
410
+	} // End sensei_woocommerce_in_cart_message()
411 411
 
412
-    /**
413
-     * Checks the cart to see if a course is in the cart.
414
-     *
415
-     * @param $course_id
416
-     * @return bool
417
-     */
418
-    public static function is_course_in_cart( $course_id ){
419
-
420
-        $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
-        $user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
422
-
423
-        if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
424
-
425
-            if ( self::is_product_in_cart( $wc_post_id ) ) {
426
-
427
-                return true;
428
-
429
-            }
430
-
431
-        }
432
-
433
-        return false;
434
-
435
-    }// is_course_in_cart
436
-
437
-    /**
438
-     * Check the cart to see if the product is in the cart
439
-     *
440
-     * @param $product_id
441
-     * @return bool
442
-     */
443
-    public static function is_product_in_cart( $product_id ){
444
-
445
-        if ( 0 < $product_id ) {
446
-
447
-            $product = wc_get_product( $product_id );
448
-
449
-            $parent_id = '';
450
-            if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
451
-                $wc_product_id = $product->parent->id;
452
-            }
453
-            foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
454
-
455
-                $cart_product = $values['data'];
456
-                if( $product_id == $cart_product->id ) {
457
-
458
-                    return true;
459
-
460
-                }
461
-
462
-            }
463
-        } // End If Statement
464
-
465
-        return false;
466
-
467
-    } // end is_product_in_car
468
-
469
-    /**
470
-     * Get all free WooCommerce products
471
-     *
472
-     * @since 1.9.0
473
-     *
474
-     * @return array $free_products{
475
-     *  @type int $wp_post_id
476
-     * }
477
-     */
478
-    public static function get_free_product_ids(){
479
-
480
-        return  get_posts( array(
481
-            'post_type' => 'product',
482
-            'posts_per_page' => '1000',
483
-            'fields' => 'ids',
484
-            'meta_query'=> array(
485
-                'relation' => 'OR',
486
-                array(
487
-                    'key'=> '_regular_price',
488
-                    'value' => 0,
489
-                ),
490
-                array(
491
-                    'key'=> '_sale_price',
492
-                    'value' => 0,
493
-                ),
494
-            ),
495
-        ));
496
-
497
-    }// end get free product query
498
-
499
-    /**
500
-     * The metat query for courses that are free
501
-     *
502
-     * @since 1.9.0
503
-     * @return array $wp_meta_query_param
504
-     */
505
-    public static function get_free_courses_meta_query_args(){
506
-
507
-        return array(
508
-            'relation' => 'OR',
509
-            array(
510
-                'key'     => '_course_woocommerce_product',
511
-                'value' => '-',
512
-                'compare' => '=',
513
-            ),
514
-            array(
515
-                'key'     => '_course_woocommerce_product',
516
-                'value' => self::get_free_product_ids(),
517
-                'compare' => 'IN',
518
-            ),
519
-        );
520
-
521
-    }// get_free_courses_meta_query
522
-
523
-    /**
524
-     * The metat query for courses that are free
525
-     *
526
-     * @since 1.9.0
527
-     * @return array $wp_query_meta_query_args_param
528
-     */
529
-    public static function get_paid_courses_meta_query_args(){
530
-
531
-        $paid_product_ids = self::get_paid_product_ids();
532
-
533
-        return array(
534
-            array(
535
-                'key'     => '_course_woocommerce_product',
536
-                // when empty we give a false post_id to ensure the caller doesn't get any courses for their
537
-                // query
538
-                'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
539
-                'compare' => 'IN',
540
-            ),
541
-        );
542
-
543
-    }// get_free_courses_meta_query
544
-
545
-    /**
546
-     * The WordPress Query args
547
-     * for paid products on sale
548
-     *
549
-     * @since 1.9.0
550
-     * @return array $product_query_args
551
-     */
552
-    public static function get_paid_products_on_sale_query_args(){
553
-
554
-        $args = array(
555
-                   'post_type' 		=> 'product',
556
-                   'posts_per_page' 		=> 1000,
557
-                   'orderby'         	=> 'date',
558
-                   'order'           	=> 'DESC',
559
-                   'suppress_filters' 	=> 0
560
-        );
561
-
562
-        $args[ 'fields' ]     = 'ids';
563
-
564
-        $args[ 'meta_query' ] = array(
565
-            'relation' => 'AND',
566
-            array(
567
-                'key'=> '_regular_price',
568
-                'compare' => '>',
569
-                'value' => 0,
570
-            ),
571
-            array(
572
-                'key'=> '_sale_price',
573
-                'compare' => '>',
574
-                'value' => 0,
575
-            ),
576
-        );
577
-
578
-        return $args;
579
-
580
-    } // get_paid_products_on_sale_query_args
581
-
582
-
583
-    /**
584
-     * Return the WordPress query args for
585
-     * products not on sale but that is not a free
586
-     *
587
-     * @since 1.9.0
588
-     *
589
-     * @return array
590
-     */
591
-    public static function get_paid_products_not_on_sale_query_args(){
592
-
593
-        $args = array(
594
-            'post_type' 		=> 'product',
595
-            'posts_per_page' 		=> 1000,
596
-            'orderby'         	=> 'date',
597
-            'order'           	=> 'DESC',
598
-            'suppress_filters' 	=> 0
599
-        );
600
-
601
-        $args[ 'fields' ]     = 'ids';
602
-        $args[ 'meta_query' ] = array(
603
-            'relation' => 'AND',
604
-            array(
605
-                'key'=> '_regular_price',
606
-                'compare' => '>',
607
-                'value' => 0,
608
-            ),
609
-            array(
610
-                'key'=> '_sale_price',
611
-                'compare' => '=',
612
-                'value' => '',
613
-            ),
614
-        );
615
-
616
-        return $args;
617
-
618
-
619
-    } // get_paid_courses_meta_query
620
-
621
-    /**
622
-     * Get all WooCommerce non-free product id's
623
-     *
624
-     * @since 1.9.0
625
-     *
626
-     * @return array $woocommerce_paid_product_ids
627
-     */
628
-    public static function get_paid_product_ids(){
629
-
630
-        // get all the paid WooCommerce products that has regular
631
-        // and sale price greater than 0
632
-        // will be used later to check for course with the id as meta
633
-        $paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
634
-
635
-        // get all the paid WooCommerce products that has regular price
636
-        // greater than 0 without a sale price
637
-        // will be used later to check for course with the id as meta
638
-        $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
639
-
640
-        // combine products ID's with regular and sale price grater than zero and those without
641
-        // sale but regular price greater than zero
642
-        $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
643
-
644
-        // if
645
-        if( empty($woocommerce_paid_product_ids) ){
646
-            return array( );
647
-        }
648
-        return $woocommerce_paid_product_ids;
649
-
650
-    }
651
-
652
-    /**
653
-     * Get all free courses.
654
-     *
655
-     * This course that have a WC product attached
656
-     * that has a price or sale price of zero and
657
-     * other courses with no WooCommerce products
658
-     * attached.
659
-     *
660
-     * @since 1.9.0
661
-     *
662
-     * @return array
663
-     */
664
-    public static function get_free_courses(){
665
-
666
-        $free_course_query_args = Sensei_Course::get_default_query_args();
667
-        $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
668
-
669
-        // don't show any paid courses
670
-        $courses = self::get_paid_courses();
671
-        $ids = array();
672
-        foreach( $courses as $course ){
673
-            $ids[] = $course->ID;
674
-        }
675
-        $free_course_query_args[ 'post__not_in' ] =  $ids;
676
-
677
-        return get_posts( $free_course_query_args );
678
-
679
-    }
680
-
681
-    /**
682
-     * Return all products that are not free
683
-     *
684
-     * @since 1.9.0
685
-     * @return array
686
-     */
687
-    public static function get_paid_courses(){
688
-
689
-        $paid_course_query_args = Sensei_Course::get_default_query_args();
690
-
691
-        $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
692
-
693
-        return get_posts(  $paid_course_query_args );
694
-    }
695
-
696
-    /**
697
-     * Show the WooCommerce add to cart button for the  current course
698
-     *
699
-     * The function will only show the button if
700
-     * 1- the user can buy the course
701
-     * 2- if they have completed their pre-requisite
702
-     * 3- if the course has a valid product attached
703
-     *
704
-     * @since 1.9.0
705
-     * @param int $course_id
706
-     * @return string $html markup for the button or nothing if user not allowed to buy
707
-     */
708
-    public static function the_add_to_cart_button_html( $course_id ){
709
-
710
-        if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
711
-            return '';
712
-        }
713
-
714
-        $wc_post_id = self::get_course_product_id( $course_id );
715
-
716
-        // Check if customer purchased the product
717
-        if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
-            || empty( $wc_post_id ) ) {
719
-
720
-            return '';
721
-
722
-        }
723
-
724
-        // based on simple.php in WC templates/single-product/add-to-cart/
725
-        // Get the product
726
-        $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
727
-
728
-        // do not show the button for invalid products, non purchasable products, out
729
-        // of stock product or if course is already in cart
730
-        if ( ! isset ( $product )
731
-            || ! is_object( $product )
732
-            || ! $product->is_purchasable()
733
-            || ! $product->is_in_stock()
734
-            || self::is_course_in_cart( $wc_post_id ) ) {
735
-
736
-            return '';
737
-
738
-        }
739
-
740
-        //
741
-        // button  output:
742
-        //
743
-        ?>
412
+	/**
413
+	 * Checks the cart to see if a course is in the cart.
414
+	 *
415
+	 * @param $course_id
416
+	 * @return bool
417
+	 */
418
+	public static function is_course_in_cart( $course_id ){
419
+
420
+		$wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
+		$user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
422
+
423
+		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
424
+
425
+			if ( self::is_product_in_cart( $wc_post_id ) ) {
426
+
427
+				return true;
428
+
429
+			}
430
+
431
+		}
432
+
433
+		return false;
434
+
435
+	}// is_course_in_cart
436
+
437
+	/**
438
+	 * Check the cart to see if the product is in the cart
439
+	 *
440
+	 * @param $product_id
441
+	 * @return bool
442
+	 */
443
+	public static function is_product_in_cart( $product_id ){
444
+
445
+		if ( 0 < $product_id ) {
446
+
447
+			$product = wc_get_product( $product_id );
448
+
449
+			$parent_id = '';
450
+			if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
451
+				$wc_product_id = $product->parent->id;
452
+			}
453
+			foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
454
+
455
+				$cart_product = $values['data'];
456
+				if( $product_id == $cart_product->id ) {
457
+
458
+					return true;
459
+
460
+				}
461
+
462
+			}
463
+		} // End If Statement
464
+
465
+		return false;
466
+
467
+	} // end is_product_in_car
468
+
469
+	/**
470
+	 * Get all free WooCommerce products
471
+	 *
472
+	 * @since 1.9.0
473
+	 *
474
+	 * @return array $free_products{
475
+	 *  @type int $wp_post_id
476
+	 * }
477
+	 */
478
+	public static function get_free_product_ids(){
479
+
480
+		return  get_posts( array(
481
+			'post_type' => 'product',
482
+			'posts_per_page' => '1000',
483
+			'fields' => 'ids',
484
+			'meta_query'=> array(
485
+				'relation' => 'OR',
486
+				array(
487
+					'key'=> '_regular_price',
488
+					'value' => 0,
489
+				),
490
+				array(
491
+					'key'=> '_sale_price',
492
+					'value' => 0,
493
+				),
494
+			),
495
+		));
496
+
497
+	}// end get free product query
498
+
499
+	/**
500
+	 * The metat query for courses that are free
501
+	 *
502
+	 * @since 1.9.0
503
+	 * @return array $wp_meta_query_param
504
+	 */
505
+	public static function get_free_courses_meta_query_args(){
506
+
507
+		return array(
508
+			'relation' => 'OR',
509
+			array(
510
+				'key'     => '_course_woocommerce_product',
511
+				'value' => '-',
512
+				'compare' => '=',
513
+			),
514
+			array(
515
+				'key'     => '_course_woocommerce_product',
516
+				'value' => self::get_free_product_ids(),
517
+				'compare' => 'IN',
518
+			),
519
+		);
520
+
521
+	}// get_free_courses_meta_query
522
+
523
+	/**
524
+	 * The metat query for courses that are free
525
+	 *
526
+	 * @since 1.9.0
527
+	 * @return array $wp_query_meta_query_args_param
528
+	 */
529
+	public static function get_paid_courses_meta_query_args(){
530
+
531
+		$paid_product_ids = self::get_paid_product_ids();
532
+
533
+		return array(
534
+			array(
535
+				'key'     => '_course_woocommerce_product',
536
+				// when empty we give a false post_id to ensure the caller doesn't get any courses for their
537
+				// query
538
+				'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
539
+				'compare' => 'IN',
540
+			),
541
+		);
542
+
543
+	}// get_free_courses_meta_query
544
+
545
+	/**
546
+	 * The WordPress Query args
547
+	 * for paid products on sale
548
+	 *
549
+	 * @since 1.9.0
550
+	 * @return array $product_query_args
551
+	 */
552
+	public static function get_paid_products_on_sale_query_args(){
553
+
554
+		$args = array(
555
+				   'post_type' 		=> 'product',
556
+				   'posts_per_page' 		=> 1000,
557
+				   'orderby'         	=> 'date',
558
+				   'order'           	=> 'DESC',
559
+				   'suppress_filters' 	=> 0
560
+		);
561
+
562
+		$args[ 'fields' ]     = 'ids';
563
+
564
+		$args[ 'meta_query' ] = array(
565
+			'relation' => 'AND',
566
+			array(
567
+				'key'=> '_regular_price',
568
+				'compare' => '>',
569
+				'value' => 0,
570
+			),
571
+			array(
572
+				'key'=> '_sale_price',
573
+				'compare' => '>',
574
+				'value' => 0,
575
+			),
576
+		);
577
+
578
+		return $args;
579
+
580
+	} // get_paid_products_on_sale_query_args
581
+
582
+
583
+	/**
584
+	 * Return the WordPress query args for
585
+	 * products not on sale but that is not a free
586
+	 *
587
+	 * @since 1.9.0
588
+	 *
589
+	 * @return array
590
+	 */
591
+	public static function get_paid_products_not_on_sale_query_args(){
592
+
593
+		$args = array(
594
+			'post_type' 		=> 'product',
595
+			'posts_per_page' 		=> 1000,
596
+			'orderby'         	=> 'date',
597
+			'order'           	=> 'DESC',
598
+			'suppress_filters' 	=> 0
599
+		);
600
+
601
+		$args[ 'fields' ]     = 'ids';
602
+		$args[ 'meta_query' ] = array(
603
+			'relation' => 'AND',
604
+			array(
605
+				'key'=> '_regular_price',
606
+				'compare' => '>',
607
+				'value' => 0,
608
+			),
609
+			array(
610
+				'key'=> '_sale_price',
611
+				'compare' => '=',
612
+				'value' => '',
613
+			),
614
+		);
615
+
616
+		return $args;
617
+
618
+
619
+	} // get_paid_courses_meta_query
620
+
621
+	/**
622
+	 * Get all WooCommerce non-free product id's
623
+	 *
624
+	 * @since 1.9.0
625
+	 *
626
+	 * @return array $woocommerce_paid_product_ids
627
+	 */
628
+	public static function get_paid_product_ids(){
629
+
630
+		// get all the paid WooCommerce products that has regular
631
+		// and sale price greater than 0
632
+		// will be used later to check for course with the id as meta
633
+		$paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
634
+
635
+		// get all the paid WooCommerce products that has regular price
636
+		// greater than 0 without a sale price
637
+		// will be used later to check for course with the id as meta
638
+		$paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
639
+
640
+		// combine products ID's with regular and sale price grater than zero and those without
641
+		// sale but regular price greater than zero
642
+		$woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
643
+
644
+		// if
645
+		if( empty($woocommerce_paid_product_ids) ){
646
+			return array( );
647
+		}
648
+		return $woocommerce_paid_product_ids;
649
+
650
+	}
651
+
652
+	/**
653
+	 * Get all free courses.
654
+	 *
655
+	 * This course that have a WC product attached
656
+	 * that has a price or sale price of zero and
657
+	 * other courses with no WooCommerce products
658
+	 * attached.
659
+	 *
660
+	 * @since 1.9.0
661
+	 *
662
+	 * @return array
663
+	 */
664
+	public static function get_free_courses(){
665
+
666
+		$free_course_query_args = Sensei_Course::get_default_query_args();
667
+		$free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
668
+
669
+		// don't show any paid courses
670
+		$courses = self::get_paid_courses();
671
+		$ids = array();
672
+		foreach( $courses as $course ){
673
+			$ids[] = $course->ID;
674
+		}
675
+		$free_course_query_args[ 'post__not_in' ] =  $ids;
676
+
677
+		return get_posts( $free_course_query_args );
678
+
679
+	}
680
+
681
+	/**
682
+	 * Return all products that are not free
683
+	 *
684
+	 * @since 1.9.0
685
+	 * @return array
686
+	 */
687
+	public static function get_paid_courses(){
688
+
689
+		$paid_course_query_args = Sensei_Course::get_default_query_args();
690
+
691
+		$paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
692
+
693
+		return get_posts(  $paid_course_query_args );
694
+	}
695
+
696
+	/**
697
+	 * Show the WooCommerce add to cart button for the  current course
698
+	 *
699
+	 * The function will only show the button if
700
+	 * 1- the user can buy the course
701
+	 * 2- if they have completed their pre-requisite
702
+	 * 3- if the course has a valid product attached
703
+	 *
704
+	 * @since 1.9.0
705
+	 * @param int $course_id
706
+	 * @return string $html markup for the button or nothing if user not allowed to buy
707
+	 */
708
+	public static function the_add_to_cart_button_html( $course_id ){
709
+
710
+		if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
711
+			return '';
712
+		}
713
+
714
+		$wc_post_id = self::get_course_product_id( $course_id );
715
+
716
+		// Check if customer purchased the product
717
+		if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
+			|| empty( $wc_post_id ) ) {
719
+
720
+			return '';
721
+
722
+		}
723
+
724
+		// based on simple.php in WC templates/single-product/add-to-cart/
725
+		// Get the product
726
+		$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
727
+
728
+		// do not show the button for invalid products, non purchasable products, out
729
+		// of stock product or if course is already in cart
730
+		if ( ! isset ( $product )
731
+			|| ! is_object( $product )
732
+			|| ! $product->is_purchasable()
733
+			|| ! $product->is_in_stock()
734
+			|| self::is_course_in_cart( $wc_post_id ) ) {
735
+
736
+			return '';
737
+
738
+		}
739
+
740
+		//
741
+		// button  output:
742
+		//
743
+		?>
744 744
 
745 745
         <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"
746 746
               class="cart"
@@ -773,54 +773,54 @@  discard block
 block discarded – undo
773 773
         </form>
774 774
 
775 775
         <?php
776
-    } // end the_add_to_cart_button_html
776
+	} // end the_add_to_cart_button_html
777 777
 
778
-    /**
779
-     * Alter the no permissions message on the single course page
780
-     * Changes the message to a WooCommerce specific message.
781
-     *
782
-     * @since 1.9.0
783
-     *
784
-     * @param $message
785
-     * @param $post_id
786
-     *
787
-     * @return string $message
788
-     */
789
-    public static function alter_no_permissions_message( $message, $post_id ){
778
+	/**
779
+	 * Alter the no permissions message on the single course page
780
+	 * Changes the message to a WooCommerce specific message.
781
+	 *
782
+	 * @since 1.9.0
783
+	 *
784
+	 * @param $message
785
+	 * @param $post_id
786
+	 *
787
+	 * @return string $message
788
+	 */
789
+	public static function alter_no_permissions_message( $message, $post_id ){
790 790
 
791
-        if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
792
-            return  $message;
793
-        }
791
+		if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
792
+			return  $message;
793
+		}
794 794
 
795
-        $product_id = self::get_course_product_id( $post_id );
795
+		$product_id = self::get_course_product_id( $post_id );
796 796
 
797
-        if( ! $product_id
798
-            || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
797
+		if( ! $product_id
798
+			|| self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
799 799
 
800
-            return $message;
800
+			return $message;
801 801
 
802
-        }
802
+		}
803 803
 
804
-        ob_start();
805
-        self::the_course_no_permissions_message( $post_id );
806
-        $woocommerce_course_no_permissions_message = ob_get_clean();
804
+		ob_start();
805
+		self::the_course_no_permissions_message( $post_id );
806
+		$woocommerce_course_no_permissions_message = ob_get_clean();
807 807
 
808
-        return $woocommerce_course_no_permissions_message ;
808
+		return $woocommerce_course_no_permissions_message ;
809 809
 
810
-    }
811
-    /**
812
-     * Show the no permissions message when a user is logged in
813
-     * and have not yet purchased the current course
814
-     *
815
-     * @since 1.9.0
816
-     */
817
-    public static function the_course_no_permissions_message( $course_id ){
810
+	}
811
+	/**
812
+	 * Show the no permissions message when a user is logged in
813
+	 * and have not yet purchased the current course
814
+	 *
815
+	 * @since 1.9.0
816
+	 */
817
+	public static function the_course_no_permissions_message( $course_id ){
818 818
 
819
-        // login link
820
-        $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
-        $login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
819
+		// login link
820
+		$my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
+		$login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
822 822
 
823
-        ?>
823
+		?>
824 824
 
825 825
         <span class="add-to-cart-login">
826 826
             <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?>
@@ -828,110 +828,110 @@  discard block
 block discarded – undo
828 828
 
829 829
     <?php }
830 830
 
831
-    /**
832
-     * Checks if a user has bought a product item.
833
-     *
834
-     * @since  1.9.0
835
-     *
836
-     * @param  int $user_id
837
-     * @param  int $product_id
838
-     *
839
-     * @return bool
840
-     */
841
-    public static function has_customer_bought_product ( $user_id, $product_id ){
831
+	/**
832
+	 * Checks if a user has bought a product item.
833
+	 *
834
+	 * @since  1.9.0
835
+	 *
836
+	 * @param  int $user_id
837
+	 * @param  int $product_id
838
+	 *
839
+	 * @return bool
840
+	 */
841
+	public static function has_customer_bought_product ( $user_id, $product_id ){
842 842
 
843
-        $orders = get_posts( array(
844
-            'posts_per_page' => -1,
845
-            'meta_key'    => '_customer_user',
846
-            'meta_value'  => intval( $user_id ),
847
-            'post_type'   => 'shop_order',
848
-            'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
-        ) );
843
+		$orders = get_posts( array(
844
+			'posts_per_page' => -1,
845
+			'meta_key'    => '_customer_user',
846
+			'meta_value'  => intval( $user_id ),
847
+			'post_type'   => 'shop_order',
848
+			'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
+		) );
850 850
 
851
-        foreach ( $orders as $order_id ) {
851
+		foreach ( $orders as $order_id ) {
852 852
 
853
-            $order = new WC_Order( $order_id->ID );
853
+			$order = new WC_Order( $order_id->ID );
854 854
 
855
-            if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
855
+			if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
856 856
 
857
-                continue;
858
-            }
857
+				continue;
858
+			}
859 859
 
860
-            if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
860
+			if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
861 861
 
862
-                continue;
862
+				continue;
863 863
 
864
-            }
864
+			}
865 865
 
866
-            foreach( $order->get_items() as $item ) {
866
+			foreach( $order->get_items() as $item ) {
867 867
 
868
-                // Check if user has bought product
869
-                if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
868
+				// Check if user has bought product
869
+				if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
870 870
 
871
-                    // Check if user has an active subscription for product
872
-                    if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
-                        $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
-                        if( $sub_key ) {
875
-                            $sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
-                            if( $sub && isset( $sub['status'] ) ) {
877
-                                if( 'active' == $sub['status'] ) {
878
-                                    return true;
879
-                                } else {
880
-                                    return false;
881
-                                }
882
-                            }
883
-                        }
884
-                    }
871
+					// Check if user has an active subscription for product
872
+					if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
+						$sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
+						if( $sub_key ) {
875
+							$sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
+							if( $sub && isset( $sub['status'] ) ) {
877
+								if( 'active' == $sub['status'] ) {
878
+									return true;
879
+								} else {
880
+									return false;
881
+								}
882
+							}
883
+						}
884
+					}
885 885
 
886
-                    // Customer has bought product
887
-                    return true;
888
-                } // End If Statement
886
+					// Customer has bought product
887
+					return true;
888
+				} // End If Statement
889 889
 
890
-            } // End For each item
890
+			} // End For each item
891 891
 
892
-        } // End For each order
892
+		} // End For each order
893 893
 
894
-    } // end has customer bought product
894
+	} // end has customer bought product
895 895
 
896
-    /**
897
-     * Return the product id for the given course
898
-     *
899
-     * @since 1.9.0
900
-     *
901
-     * @param int $course_id
902
-     *
903
-     * @return string $woocommerce_product_id or false if none exist
904
-     *
905
-     */
906
-    public static function get_course_product_id( $course_id ){
896
+	/**
897
+	 * Return the product id for the given course
898
+	 *
899
+	 * @since 1.9.0
900
+	 *
901
+	 * @param int $course_id
902
+	 *
903
+	 * @return string $woocommerce_product_id or false if none exist
904
+	 *
905
+	 */
906
+	public static function get_course_product_id( $course_id ){
907 907
 
908
-        $product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
908
+		$product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
909 909
 
910
-        if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
911
-            return false;
912
-        }
910
+		if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
911
+			return false;
912
+		}
913 913
 
914
-        return $product_id;
914
+		return $product_id;
915 915
 
916
-    }
916
+	}
917 917
 
918
-    /**
919
-     * Alter the body classes adding WooCommerce to the body
920
-     *
921
-     * @param array $classes
922
-     * @return array
923
-     */
924
-    public static function add_woocommerce_body_class( $classes ){
918
+	/**
919
+	 * Alter the body classes adding WooCommerce to the body
920
+	 *
921
+	 * @param array $classes
922
+	 * @return array
923
+	 */
924
+	public static function add_woocommerce_body_class( $classes ){
925 925
 
926
-        if( ! in_array( 'woocommerce', $classes ) ){
926
+		if( ! in_array( 'woocommerce', $classes ) ){
927 927
 
928
-            $classes[] ='woocommerce';
928
+			$classes[] ='woocommerce';
929 929
 
930
-        }
930
+		}
931 931
 
932 932
 
933
-        return $classes;
933
+		return $classes;
934 934
 
935
-    }
935
+	}
936 936
 
937 937
 }// end Sensei_WC
Please login to merge, or discard this patch.
Spacing   +163 added lines, -163 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; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 
4 4
 /**
5 5
  * Sensei WooCommerce class
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
  * @since 1.9.0
12 12
  */
13 13
 
14
-Class Sensei_WC{
14
+Class Sensei_WC {
15 15
     /**
16 16
      * Load the files needed for the woocommerce integration.
17 17
      *
18 18
      * @since 1.9.0
19 19
      */
20
-    public static function load_woocommerce_integration_hooks(){
20
+    public static function load_woocommerce_integration_hooks() {
21 21
 
22
-        require_once( __DIR__ . '/hooks/woocommerce.php' );
22
+        require_once(__DIR__.'/hooks/woocommerce.php');
23 23
 
24 24
     }
25 25
     /**
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * @since 1.9.0
29 29
      * @return bool
30 30
      */
31
-    public static function is_woocommerce_active(){
31
+    public static function is_woocommerce_active() {
32 32
 
33
-        $is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
33
+        $is_woocommerce_enabled_in_settings = isset(Sensei()->settings->settings['woocommerce_enabled']) && Sensei()->settings->settings['woocommerce_enabled'];
34 34
         return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
35 35
 
36 36
     } // end is_woocommerce_active
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return bool
47 47
      */
48
-    public static function is_woocommerce_present(){
48
+    public static function is_woocommerce_present() {
49 49
 
50
-        $active_plugins = (array) get_option( 'active_plugins', array() );
50
+        $active_plugins = (array) get_option('active_plugins', array());
51 51
 
52
-        if ( is_multisite() ){
52
+        if (is_multisite()) {
53 53
 
54
-            $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
54
+            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
55 55
 
56 56
         }
57 57
 
58
-        $is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
58
+        $is_woocommerce_plugin_present_and_activated = in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
59 59
 
60
-        return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
60
+        return class_exists('Woocommerce') || $is_woocommerce_plugin_present_and_activated;
61 61
 
62 62
     }// end is_woocommerce_present
63 63
 
@@ -70,48 +70,48 @@  discard block
 block discarded – undo
70 70
      * @param $course_id
71 71
      * @return array $user_course_orders
72 72
      */
73
-    public static function get_learner_course_active_order_id( $user_id, $course_id ){
73
+    public static function get_learner_course_active_order_id($user_id, $course_id) {
74 74
 
75
-        $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
75
+        $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
76 76
 
77
-        $orders_query = new WP_Query( array(
77
+        $orders_query = new WP_Query(array(
78 78
             'post_type'   => 'shop_order',
79 79
             'posts_per_page' => -1,
80
-            'post_status' => array( 'wc-processing', 'wc-completed' ),
80
+            'post_status' => array('wc-processing', 'wc-completed'),
81 81
             'meta_key'=> '_customer_user',
82 82
             'meta_value'=> $user_id,
83
-        ) );
83
+        ));
84 84
 
85
-        if( $orders_query->post_count == 0 ){
85
+        if ($orders_query->post_count == 0) {
86 86
 
87 87
             return false;
88 88
 
89 89
         }
90 90
 
91
-        foreach( $orders_query->get_posts() as $order ){
91
+        foreach ($orders_query->get_posts() as $order) {
92 92
 
93
-            $order = new WC_Order( $order->ID );
93
+            $order = new WC_Order($order->ID);
94 94
             $items = $order->get_items();
95 95
 
96
-            $user_orders =  array();
96
+            $user_orders = array();
97 97
 
98
-            foreach( $items as $item ){
98
+            foreach ($items as $item) {
99 99
 
100 100
                 // if the product id on the order and the one given to this function
101 101
                 // this order has been placed by the given user on the given course.
102
-                $product = wc_get_product( $item['product_id'] );
102
+                $product = wc_get_product($item['product_id']);
103 103
 
104
-                if ( $product->is_type( 'variable' )) {
104
+                if ($product->is_type('variable')) {
105 105
 
106 106
                     $item_product_id = $item['variation_id'];
107 107
 
108 108
                 } else {
109 109
 
110
-                    $item_product_id =  $item['product_id'];
110
+                    $item_product_id = $item['product_id'];
111 111
 
112 112
                 }
113 113
 
114
-                if( $course_product_id == $item_product_id ){
114
+                if ($course_product_id == $item_product_id) {
115 115
 
116 116
                     return $order->id;
117 117
 
@@ -135,28 +135,28 @@  discard block
 block discarded – undo
135 135
      * @param $filter_links
136 136
      * @return mixed
137 137
      */
138
-    public static function add_course_archive_wc_filter_links( $filter_links ){
138
+    public static function add_course_archive_wc_filter_links($filter_links) {
139 139
 
140
-        $course_url = remove_query_arg('paged', Sensei_Utils::get_current_url() );
140
+        $course_url = remove_query_arg('paged', Sensei_Utils::get_current_url());
141 141
 
142 142
         $free_courses = self::get_free_courses();
143 143
         $paid_courses = self::get_paid_courses();
144 144
 
145
-        if ( empty( $free_courses ) || empty( $paid_courses )  ){
145
+        if (empty($free_courses) || empty($paid_courses)) {
146 146
             // do not show any WooCommerce filters if all courses are
147 147
             // free or if all courses are paid
148 148
             return $filter_links;
149 149
 
150 150
         }
151 151
 
152
-        $filter_links[] = array(    'id'=>'paid' ,
152
+        $filter_links[] = array('id'=>'paid',
153 153
                                     'url'=> add_query_arg('course_filter', 'paid', $course_url),
154
-                                    'title'=>__( 'Paid', 'woothemes-sensei' )
154
+                                    'title'=>__('Paid', 'woothemes-sensei')
155 155
         );
156 156
 
157
-        $filter_links[] = array(    'id'=>'free',
157
+        $filter_links[] = array('id'=>'free',
158 158
                                     'url'=>add_query_arg('course_filter', 'free', $course_url),
159
-                                    'title'=>__( 'Free', 'woothemes-sensei' )
159
+                                    'title'=>__('Free', 'woothemes-sensei')
160 160
         );
161 161
 
162 162
         return $filter_links;
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
      * @param WP_Query $query
174 174
      * @return WP_Query $query
175 175
      */
176
-    public static function course_archive_wc_filter_free( $query ){
176
+    public static function course_archive_wc_filter_free($query) {
177 177
 
178
-        if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
-            && 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
178
+        if (isset($_GET['course_filter']) && 'free' == $_GET['course_filter']
179
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
180 180
 
181 181
             // setup the course meta query
182 182
             $meta_query = self::get_free_courses_meta_query_args();
183 183
 
184 184
             // manipulate the query to return free courses
185
-            $query->set('meta_query', $meta_query );
185
+            $query->set('meta_query', $meta_query);
186 186
 
187 187
             // don't show any paid courses
188 188
             $courses = self::get_paid_courses();
189 189
             $ids = array();
190
-            foreach( $courses as $course ){
190
+            foreach ($courses as $course) {
191 191
                 $ids[] = $course->ID;
192 192
             }
193
-            $query->set( 'post__not_in', $ids );
193
+            $query->set('post__not_in', $ids);
194 194
 
195 195
         }// end if course_filter
196 196
 
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
      * @param WP_Query $query
210 210
      * @return WP_Query $query
211 211
      */
212
-    public static function course_archive_wc_filter_paid( $query ){
212
+    public static function course_archive_wc_filter_paid($query) {
213 213
 
214
-        if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
-            && 'course' == $query->get( 'post_type') && $query->is_main_query() ){
214
+        if (isset($_GET['course_filter']) && 'paid' == $_GET['course_filter']
215
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
216 216
 
217 217
             // setup the course meta query
218 218
             $meta_query = self::get_paid_courses_meta_query_args();
219 219
 
220 220
             // manipulate the query to return free courses
221
-            $query->set('meta_query', $meta_query );
221
+            $query->set('meta_query', $meta_query);
222 222
 
223 223
         }
224 224
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
      * single courses if woocommerce is active allowing purchase
232 232
      * information and actions to be hooked from WooCommerce.
233 233
      */
234
-    public static function do_single_course_wc_single_product_action(){
234
+    public static function do_single_course_wc_single_product_action() {
235 235
 
236 236
         /**
237 237
          * this hooks is documented within the WooCommerce plugin.
238 238
          */
239
-        if ( Sensei_WC::is_woocommerce_active() ) {
239
+        if (Sensei_WC::is_woocommerce_active()) {
240 240
 
241
-            do_action( 'woocommerce_before_single_product' );
241
+            do_action('woocommerce_before_single_product');
242 242
 
243 243
         } // End If Statement
244 244
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
      * @param $user_id
260 260
      * @return bool
261 261
      */
262
-    public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
262
+    public static function alter_can_user_view_lesson($can_user_view_lesson, $lesson_id, $user_id) {
263 263
 
264 264
         // check if the course has a valid product attached to it
265 265
         // which the user should have purchased if they want to access
266 266
         // the current lesson
267
-        $course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
-        $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
267
+        $course_id = get_post_meta($lesson_id, '_lesson_course', true);
268
+        $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true);
269 269
         $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
-        if( isset ($product) && is_object($product) ){
270
+        if (isset ($product) && is_object($product)) {
271 271
 
272 272
             // valid product found
273
-            $order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
273
+            $order_id = self::get_learner_course_active_order_id($user_id, $course_id);
274 274
 
275 275
             // product has a successful order so this user may access the content
276 276
             // this function may only return false or the default
277 277
             // returning true may override other negatives which we don't want
278
-            if( ! $order_id ){
278
+            if ( ! $order_id) {
279 279
 
280 280
                 return false;
281 281
 
@@ -298,23 +298,23 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public static function course_link_from_order( ) {
300 300
 
301
-        if( ! is_order_received_page() ){
301
+        if ( ! is_order_received_page()) {
302 302
             return;
303 303
         }
304 304
 
305
-        $order_id = get_query_var( 'order-received' );
306
-		$order = new WC_Order( $order_id );
305
+        $order_id = get_query_var('order-received');
306
+		$order = new WC_Order($order_id);
307 307
 
308 308
 		// exit early if not wc-completed or wc-processing
309
-		if( 'wc-completed' != $order->post_status
310
-            && 'wc-processing' != $order->post_status  ) {
309
+		if ('wc-completed' != $order->post_status
310
+            && 'wc-processing' != $order->post_status) {
311 311
             return;
312 312
         }
313 313
 
314 314
         $course_links = array(); // store the for links for courses purchased
315
-		foreach ( $order->get_items() as $item ) {
315
+		foreach ($order->get_items() as $item) {
316 316
 
317
-            if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
317
+            if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
318 318
 
319 319
                 // If item has variation_id then its a variation of the product
320 320
                 $item_id = $item['variation_id'];
@@ -326,28 +326,28 @@  discard block
 block discarded – undo
326 326
 
327 327
             } // End If Statement
328 328
 
329
-            $user_id = get_post_meta( $order->id, '_customer_user', true );
329
+            $user_id = get_post_meta($order->id, '_customer_user', true);
330 330
 
331
-            if( $user_id ) {
331
+            if ($user_id) {
332 332
 
333 333
                 // Get all courses for product
334 334
                 $args = Sensei_Course::get_default_query_args();
335
-                $args['meta_query'] = array( array(
335
+                $args['meta_query'] = array(array(
336 336
                             'key' => '_course_woocommerce_product',
337 337
                             'value' => $item_id
338
-                        ) );
338
+                        ));
339 339
                 $args['orderby'] = 'menu_order date';
340 340
                 $args['order'] = 'ASC';
341 341
 
342 342
                 // loop through courses
343
-                $courses = get_posts( $args );
344
-                if( $courses && count( $courses ) > 0 ) {
343
+                $courses = get_posts($args);
344
+                if ($courses && count($courses) > 0) {
345 345
 
346
-                    foreach( $courses as $course ) {
346
+                    foreach ($courses as $course) {
347 347
 
348 348
                         $title = $course->post_title;
349
-                        $permalink = get_permalink( $course->ID );
350
-                        $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
349
+                        $permalink = get_permalink($course->ID);
350
+                        $course_links[] .= '<a href="'.esc_url($permalink).'" >'.$title.'</a> ';
351 351
 
352 352
                     } // end for each
353 353
 
@@ -358,24 +358,24 @@  discard block
 block discarded – undo
358 358
         }// end loop through orders
359 359
 
360 360
         // add the courses to the WooCommerce notice
361
-        if( ! empty( $course_links) ){
361
+        if ( ! empty($course_links)) {
362 362
 
363 363
             $courses_html = _nx(
364 364
                 'You have purchased the following course:',
365 365
                 'You have purchased the following courses:',
366
-                count( $course_links ),
366
+                count($course_links),
367 367
                 'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368 368
             );
369 369
 
370
-            foreach( $course_links as $link ){
370
+            foreach ($course_links as $link) {
371 371
 
372
-                $courses_html .= '<li>' . $link . '</li>';
372
+                $courses_html .= '<li>'.$link.'</li>';
373 373
 
374 374
             }
375 375
 
376 376
             $courses_html .= ' </ul>';
377 377
 
378
-            wc_add_notice( $courses_html, 'success' );
378
+            wc_add_notice($courses_html, 'success');
379 379
         }
380 380
 
381 381
 	} // end course_link_order_form
@@ -388,20 +388,20 @@  discard block
 block discarded – undo
388 388
      *
389 389
      * @since 1.9.0
390 390
      */
391
-    public static function course_in_cart_message(){
391
+    public static function course_in_cart_message() {
392 392
 
393 393
         global $post;
394 394
 
395
-        if( self::is_course_in_cart( $post->ID ) ){ ?>
395
+        if (self::is_course_in_cart($post->ID)) { ?>
396 396
 
397 397
             <div class="sensei-message info">'
398 398
                 <?php
399 399
 
400
-                $cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
-                              . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
-                              . __('complete the purchase', 'woothemes-sensei') . '</a>';
400
+                $cart_link = '<a class="cart-complete" href="'.WC()->cart->get_checkout_url()
401
+                              . '" title="'.__('complete purchase', 'woothemes-sensei').'">'
402
+                              . __('complete the purchase', 'woothemes-sensei').'</a>';
403 403
 
404
-                sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
404
+                sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link);
405 405
 
406 406
                 ?>
407 407
             </div>
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
      * @param $course_id
416 416
      * @return bool
417 417
      */
418
-    public static function is_course_in_cart( $course_id ){
418
+    public static function is_course_in_cart($course_id) {
419 419
 
420
-        $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
-        $user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
420
+        $wc_post_id = absint(get_post_meta($course_id, '_course_woocommerce_product', true));
421
+        $user_course_status_id = Sensei_Utils::user_started_course($course_id, get_current_user_id());
422 422
 
423
-        if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
423
+        if (0 < intval($wc_post_id) && ! $user_course_status_id) {
424 424
 
425
-            if ( self::is_product_in_cart( $wc_post_id ) ) {
425
+            if (self::is_product_in_cart($wc_post_id)) {
426 426
 
427 427
                 return true;
428 428
 
@@ -440,20 +440,20 @@  discard block
 block discarded – undo
440 440
      * @param $product_id
441 441
      * @return bool
442 442
      */
443
-    public static function is_product_in_cart( $product_id ){
443
+    public static function is_product_in_cart($product_id) {
444 444
 
445
-        if ( 0 < $product_id ) {
445
+        if (0 < $product_id) {
446 446
 
447
-            $product = wc_get_product( $product_id );
447
+            $product = wc_get_product($product_id);
448 448
 
449 449
             $parent_id = '';
450
-            if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
450
+            if (isset($product->variation_id) && 0 < intval($product->variation_id)) {
451 451
                 $wc_product_id = $product->parent->id;
452 452
             }
453
-            foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
453
+            foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
454 454
 
455 455
                 $cart_product = $values['data'];
456
-                if( $product_id == $cart_product->id ) {
456
+                if ($product_id == $cart_product->id) {
457 457
 
458 458
                     return true;
459 459
 
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
      *  @type int $wp_post_id
476 476
      * }
477 477
      */
478
-    public static function get_free_product_ids(){
478
+    public static function get_free_product_ids() {
479 479
 
480
-        return  get_posts( array(
480
+        return  get_posts(array(
481 481
             'post_type' => 'product',
482 482
             'posts_per_page' => '1000',
483 483
             'fields' => 'ids',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
      * @since 1.9.0
503 503
      * @return array $wp_meta_query_param
504 504
      */
505
-    public static function get_free_courses_meta_query_args(){
505
+    public static function get_free_courses_meta_query_args() {
506 506
 
507 507
         return array(
508 508
             'relation' => 'OR',
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
      * @since 1.9.0
527 527
      * @return array $wp_query_meta_query_args_param
528 528
      */
529
-    public static function get_paid_courses_meta_query_args(){
529
+    public static function get_paid_courses_meta_query_args() {
530 530
 
531 531
         $paid_product_ids = self::get_paid_product_ids();
532 532
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
                 'key'     => '_course_woocommerce_product',
536 536
                 // when empty we give a false post_id to ensure the caller doesn't get any courses for their
537 537
                 // query
538
-                'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
538
+                'value' => empty($paid_product_ids) ? '-1000' : $paid_product_ids,
539 539
                 'compare' => 'IN',
540 540
             ),
541 541
         );
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      * @since 1.9.0
550 550
      * @return array $product_query_args
551 551
      */
552
-    public static function get_paid_products_on_sale_query_args(){
552
+    public static function get_paid_products_on_sale_query_args() {
553 553
 
554 554
         $args = array(
555 555
                    'post_type' 		=> 'product',
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
                    'suppress_filters' 	=> 0
560 560
         );
561 561
 
562
-        $args[ 'fields' ]     = 'ids';
562
+        $args['fields']     = 'ids';
563 563
 
564
-        $args[ 'meta_query' ] = array(
564
+        $args['meta_query'] = array(
565 565
             'relation' => 'AND',
566 566
             array(
567 567
                 'key'=> '_regular_price',
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
      *
589 589
      * @return array
590 590
      */
591
-    public static function get_paid_products_not_on_sale_query_args(){
591
+    public static function get_paid_products_not_on_sale_query_args() {
592 592
 
593 593
         $args = array(
594 594
             'post_type' 		=> 'product',
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
             'suppress_filters' 	=> 0
599 599
         );
600 600
 
601
-        $args[ 'fields' ]     = 'ids';
602
-        $args[ 'meta_query' ] = array(
601
+        $args['fields']     = 'ids';
602
+        $args['meta_query'] = array(
603 603
             'relation' => 'AND',
604 604
             array(
605 605
                 'key'=> '_regular_price',
@@ -625,24 +625,24 @@  discard block
 block discarded – undo
625 625
      *
626 626
      * @return array $woocommerce_paid_product_ids
627 627
      */
628
-    public static function get_paid_product_ids(){
628
+    public static function get_paid_product_ids() {
629 629
 
630 630
         // get all the paid WooCommerce products that has regular
631 631
         // and sale price greater than 0
632 632
         // will be used later to check for course with the id as meta
633
-        $paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
633
+        $paid_product_ids_with_sale = get_posts(self::get_paid_products_on_sale_query_args());
634 634
 
635 635
         // get all the paid WooCommerce products that has regular price
636 636
         // greater than 0 without a sale price
637 637
         // will be used later to check for course with the id as meta
638
-        $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
638
+        $paid_product_ids_without_sale = get_posts(self::get_paid_products_not_on_sale_query_args());
639 639
 
640 640
         // combine products ID's with regular and sale price grater than zero and those without
641 641
         // sale but regular price greater than zero
642
-        $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
642
+        $woocommerce_paid_product_ids = array_merge($paid_product_ids_with_sale, $paid_product_ids_without_sale);
643 643
 
644 644
         // if
645
-        if( empty($woocommerce_paid_product_ids) ){
645
+        if (empty($woocommerce_paid_product_ids)) {
646 646
             return array( );
647 647
         }
648 648
         return $woocommerce_paid_product_ids;
@@ -661,20 +661,20 @@  discard block
 block discarded – undo
661 661
      *
662 662
      * @return array
663 663
      */
664
-    public static function get_free_courses(){
664
+    public static function get_free_courses() {
665 665
 
666 666
         $free_course_query_args = Sensei_Course::get_default_query_args();
667
-        $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
667
+        $free_course_query_args['meta_query'] = self::get_free_courses_meta_query_args();
668 668
 
669 669
         // don't show any paid courses
670 670
         $courses = self::get_paid_courses();
671 671
         $ids = array();
672
-        foreach( $courses as $course ){
672
+        foreach ($courses as $course) {
673 673
             $ids[] = $course->ID;
674 674
         }
675
-        $free_course_query_args[ 'post__not_in' ] =  $ids;
675
+        $free_course_query_args['post__not_in'] = $ids;
676 676
 
677
-        return get_posts( $free_course_query_args );
677
+        return get_posts($free_course_query_args);
678 678
 
679 679
     }
680 680
 
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
      * @since 1.9.0
685 685
      * @return array
686 686
      */
687
-    public static function get_paid_courses(){
687
+    public static function get_paid_courses() {
688 688
 
689 689
         $paid_course_query_args = Sensei_Course::get_default_query_args();
690 690
 
691
-        $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
691
+        $paid_course_query_args['meta_query'] = self::get_paid_courses_meta_query_args();
692 692
 
693
-        return get_posts(  $paid_course_query_args );
693
+        return get_posts($paid_course_query_args);
694 694
     }
695 695
 
696 696
     /**
@@ -705,17 +705,17 @@  discard block
 block discarded – undo
705 705
      * @param int $course_id
706 706
      * @return string $html markup for the button or nothing if user not allowed to buy
707 707
      */
708
-    public static function the_add_to_cart_button_html( $course_id ){
708
+    public static function the_add_to_cart_button_html($course_id) {
709 709
 
710
-        if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
710
+        if ( ! Sensei_Course::is_prerequisite_complete($course_id)) {
711 711
             return '';
712 712
         }
713 713
 
714
-        $wc_post_id = self::get_course_product_id( $course_id );
714
+        $wc_post_id = self::get_course_product_id($course_id);
715 715
 
716 716
         // Check if customer purchased the product
717
-        if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
-            || empty( $wc_post_id ) ) {
717
+        if (self::has_customer_bought_product(get_current_user_id(), $wc_post_id)
718
+            || empty($wc_post_id)) {
719 719
 
720 720
             return '';
721 721
 
@@ -723,15 +723,15 @@  discard block
 block discarded – undo
723 723
 
724 724
         // based on simple.php in WC templates/single-product/add-to-cart/
725 725
         // Get the product
726
-        $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
726
+        $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
727 727
 
728 728
         // do not show the button for invalid products, non purchasable products, out
729 729
         // of stock product or if course is already in cart
730
-        if ( ! isset ( $product )
731
-            || ! is_object( $product )
730
+        if ( ! isset ($product)
731
+            || ! is_object($product)
732 732
             || ! $product->is_purchasable()
733 733
             || ! $product->is_in_stock()
734
-            || self::is_course_in_cart( $wc_post_id ) ) {
734
+            || self::is_course_in_cart($wc_post_id)) {
735 735
 
736 736
             return '';
737 737
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
         //
743 743
         ?>
744 744
 
745
-        <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"
745
+        <form action="<?php echo esc_url($product->add_to_cart_url()); ?>"
746 746
               class="cart"
747 747
               method="post"
748 748
               enctype="multipart/form-data">
749 749
 
750
-            <input type="hidden" name="product_id" value="<?php echo esc_attr( $product->id ); ?>" />
750
+            <input type="hidden" name="product_id" value="<?php echo esc_attr($product->id); ?>" />
751 751
 
752 752
             <input type="hidden" name="quantity" value="1" />
753 753
 
754
-            <?php if ( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) { ?>
754
+            <?php if (isset($product->variation_id) && 0 < intval($product->variation_id)) { ?>
755 755
 
756 756
                 <input type="hidden" name="variation_id" value="<?php echo $product->variation_id; ?>" />
757
-                <?php if( isset( $product->variation_data ) && is_array( $product->variation_data ) && count( $product->variation_data ) > 0 ) { ?>
757
+                <?php if (isset($product->variation_data) && is_array($product->variation_data) && count($product->variation_data) > 0) { ?>
758 758
 
759
-                    <?php foreach( $product->variation_data as $att => $val ) { ?>
759
+                    <?php foreach ($product->variation_data as $att => $val) { ?>
760 760
 
761
-                        <input type="hidden" name="<?php echo esc_attr( $att ); ?>" id="<?php echo esc_attr( str_replace( 'attribute_', '', $att ) ); ?>" value="<?php echo esc_attr( $val ); ?>" />
761
+                        <input type="hidden" name="<?php echo esc_attr($att); ?>" id="<?php echo esc_attr(str_replace('attribute_', '', $att)); ?>" value="<?php echo esc_attr($val); ?>" />
762 762
 
763 763
                     <?php } ?>
764 764
 
@@ -786,26 +786,26 @@  discard block
 block discarded – undo
786 786
      *
787 787
      * @return string $message
788 788
      */
789
-    public static function alter_no_permissions_message( $message, $post_id ){
789
+    public static function alter_no_permissions_message($message, $post_id) {
790 790
 
791
-        if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
791
+        if (empty($post_id) || 'course' != get_post_type($post_id)) {
792 792
             return  $message;
793 793
         }
794 794
 
795
-        $product_id = self::get_course_product_id( $post_id );
795
+        $product_id = self::get_course_product_id($post_id);
796 796
 
797
-        if( ! $product_id
798
-            || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
797
+        if ( ! $product_id
798
+            || self::has_customer_bought_product(get_current_user_id(), $product_id)) {
799 799
 
800 800
             return $message;
801 801
 
802 802
         }
803 803
 
804 804
         ob_start();
805
-        self::the_course_no_permissions_message( $post_id );
805
+        self::the_course_no_permissions_message($post_id);
806 806
         $woocommerce_course_no_permissions_message = ob_get_clean();
807 807
 
808
-        return $woocommerce_course_no_permissions_message ;
808
+        return $woocommerce_course_no_permissions_message;
809 809
 
810 810
     }
811 811
     /**
@@ -814,16 +814,16 @@  discard block
 block discarded – undo
814 814
      *
815 815
      * @since 1.9.0
816 816
      */
817
-    public static function the_course_no_permissions_message( $course_id ){
817
+    public static function the_course_no_permissions_message($course_id) {
818 818
 
819 819
         // login link
820
-        $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
-        $login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
820
+        $my_courses_page_id = intval(Sensei()->settings->settings['my_course_page']);
821
+        $login_link = '<a href="'.esc_url(get_permalink($my_courses_page_id)).'">'.__('log in', 'woothemes-sensei').'</a>';
822 822
 
823 823
         ?>
824 824
 
825 825
         <span class="add-to-cart-login">
826
-            <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?>
826
+            <?php echo sprintf(__('Or %1$s to access your purchased courses', 'woothemes-sensei'), $login_link); ?>
827 827
         </span>
828 828
 
829 829
     <?php }
@@ -838,43 +838,43 @@  discard block
 block discarded – undo
838 838
      *
839 839
      * @return bool
840 840
      */
841
-    public static function has_customer_bought_product ( $user_id, $product_id ){
841
+    public static function has_customer_bought_product($user_id, $product_id) {
842 842
 
843
-        $orders = get_posts( array(
843
+        $orders = get_posts(array(
844 844
             'posts_per_page' => -1,
845 845
             'meta_key'    => '_customer_user',
846
-            'meta_value'  => intval( $user_id ),
846
+            'meta_value'  => intval($user_id),
847 847
             'post_type'   => 'shop_order',
848
-            'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
-        ) );
848
+            'post_status' =>  array('wc-processing', 'wc-completed'),
849
+        ));
850 850
 
851
-        foreach ( $orders as $order_id ) {
851
+        foreach ($orders as $order_id) {
852 852
 
853
-            $order = new WC_Order( $order_id->ID );
853
+            $order = new WC_Order($order_id->ID);
854 854
 
855
-            if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
855
+            if ($order->post_status != 'wc-completed' && $order->post_status != 'wc-processing') {
856 856
 
857 857
                 continue;
858 858
             }
859 859
 
860
-            if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
860
+            if ( ! (0 < sizeof($order->get_items()))) {
861 861
 
862 862
                 continue;
863 863
 
864 864
             }
865 865
 
866
-            foreach( $order->get_items() as $item ) {
866
+            foreach ($order->get_items() as $item) {
867 867
 
868 868
                 // Check if user has bought product
869
-                if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
869
+                if ($item['product_id'] == $product_id || $item['variation_id'] == $product_id) {
870 870
 
871 871
                     // Check if user has an active subscription for product
872
-                    if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
-                        $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
-                        if( $sub_key ) {
875
-                            $sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
-                            if( $sub && isset( $sub['status'] ) ) {
877
-                                if( 'active' == $sub['status'] ) {
872
+                    if (class_exists('WC_Subscriptions_Manager')) {
873
+                        $sub_key = WC_Subscriptions_Manager::get_subscription_key($order_id->ID, $product_id);
874
+                        if ($sub_key) {
875
+                            $sub = WC_Subscriptions_Manager::get_subscription($sub_key);
876
+                            if ($sub && isset($sub['status'])) {
877
+                                if ('active' == $sub['status']) {
878 878
                                     return true;
879 879
                                 } else {
880 880
                                     return false;
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
      * @return string $woocommerce_product_id or false if none exist
904 904
      *
905 905
      */
906
-    public static function get_course_product_id( $course_id ){
906
+    public static function get_course_product_id($course_id) {
907 907
 
908
-        $product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
908
+        $product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
909 909
 
910
-        if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
910
+        if (empty($product_id) || 'product' != get_post_type($product_id)) {
911 911
             return false;
912 912
         }
913 913
 
@@ -921,11 +921,11 @@  discard block
 block discarded – undo
921 921
      * @param array $classes
922 922
      * @return array
923 923
      */
924
-    public static function add_woocommerce_body_class( $classes ){
924
+    public static function add_woocommerce_body_class($classes) {
925 925
 
926
-        if( ! in_array( 'woocommerce', $classes ) ){
926
+        if ( ! in_array('woocommerce', $classes)) {
927 927
 
928
-            $classes[] ='woocommerce';
928
+            $classes[] = 'woocommerce';
929 929
 
930 930
         }
931 931
 
Please login to merge, or discard this patch.
includes/class-sensei-course-results.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   +40 added lines, -40 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 Course Results Class
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 * Constructor.
22 22
 	 * @since  1.4.0
23 23
 	 */
24
-	public function __construct () {
24
+	public function __construct() {
25 25
 
26 26
 		// Setup learner profile URL base
27
-		$this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) );
27
+		$this->courses_url_base = apply_filters('sensei_course_slug', _x('course', 'post type single url slug', 'woothemes-sensei'));
28 28
 
29 29
 		// Setup permalink structure for course results
30
-		add_action( 'init', array( $this, 'setup_permastruct' ) );
31
-		add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 );
30
+		add_action('init', array($this, 'setup_permastruct'));
31
+		add_filter('wp_title', array($this, 'page_title'), 10, 2);
32 32
 
33 33
 		// Load course results
34
-		add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 );
34
+		add_action('sensei_course_results_content_inside_before', array($this, 'deprecate_course_result_info_hook'), 10);
35 35
 
36 36
 		// Add class to body tag
37
-		add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 );
37
+		add_filter('body_class', array($this, 'body_class'), 10, 1);
38 38
 
39 39
 	} // End __construct()
40 40
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @return void
45 45
 	 */
46 46
 	public function setup_permastruct() {
47
-		add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' );
48
-		add_rewrite_tag( '%course_results%', '([^&]+)' );
47
+		add_rewrite_rule('^'.$this->courses_url_base.'/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top');
48
+		add_rewrite_tag('%course_results%', '([^&]+)');
49 49
 	}
50 50
 
51 51
 	/**
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 * @param  string $sep   Seeparator string
55 55
 	 * @return string        Modified title
56 56
 	 */
57
-	public function page_title( $title, $sep = null ) {
57
+	public function page_title($title, $sep = null) {
58 58
 		global $wp_query;
59
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
60
-			$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' );
61
-			$title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' ';
59
+		if (isset($wp_query->query_vars['course_results'])) {
60
+			$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course');
61
+			$title = __('Course Results: ', 'woothemes-sensei').$course->post_title.' '.$sep.' ';
62 62
 		}
63 63
 		return $title;
64 64
 	}
@@ -69,18 +69,18 @@  discard block
 block discarded – undo
69 69
 	 * @param  integer $course_id ID of course
70 70
 	 * @return string             The course results page permalink
71 71
 	 */
72
-	public function get_permalink( $course_id = 0 ) {
72
+	public function get_permalink($course_id = 0) {
73 73
 
74 74
 		$permalink = '';
75 75
 
76
-		if( $course_id > 0 ) {
76
+		if ($course_id > 0) {
77 77
 
78
-			$course = get_post( $course_id );
78
+			$course = get_post($course_id);
79 79
 
80
-			if ( get_option('permalink_structure') ) {
81
-				$permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/';
80
+			if (get_option('permalink_structure')) {
81
+				$permalink = trailingslashit(get_home_url()).$this->courses_url_base.'/'.$course->post_name.'/results/';
82 82
 			} else {
83
-				$permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name;
83
+				$permalink = trailingslashit(get_home_url()).'?course_results='.$course->post_name;
84 84
 			}
85 85
 		}
86 86
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	 * @return void
94 94
 	 */
95 95
 	public function content() {
96
-		global $wp_query,  $current_user;
96
+		global $wp_query, $current_user;
97 97
 
98
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
99
-            Sensei_Templates::get_template( 'course-results/course-info.php' );
98
+		if (isset($wp_query->query_vars['course_results'])) {
99
+            Sensei_Templates::get_template('course-results/course-info.php');
100 100
 		}
101 101
 
102 102
 	}
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 
111 111
 		global $course;
112 112
 
113
-		$course_status = Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id());
114
-		echo '<div class="sensei-message ' . $course_status['box_class'] . '">' . $course_status['message'] . '</div>';
113
+		$course_status = Sensei_Utils::sensei_user_course_status_message($course->ID, get_current_user_id());
114
+		echo '<div class="sensei-message '.$course_status['box_class'].'">'.$course_status['message'].'</div>';
115 115
 
116
-		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
116
+		sensei_do_deprecated_action('sensei_course_results_lessons', '1.9.', 'sensei_course_results_content_inside_after', $course);
117 117
 
118
-        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
118
+        sensei_do_deprecated_action('sensei_course_results_bottom', '1.9.', 'sensei_course_results_content_inside_after', $course->ID);
119 119
 
120 120
 	}
121 121
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	public function course_lessons() {
129 129
 
130 130
 		global $course;
131
-        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
131
+        _deprecated_function('Sensei_modules course_lessons ', '1.9.0');
132 132
 
133 133
 	}
134 134
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 * @param  array $classes Existing classes
138 138
 	 * @return array          Modified classes
139 139
 	 */
140
-	public function body_class( $classes ) {
140
+	public function body_class($classes) {
141 141
 		global $wp_query;
142
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
142
+		if (isset($wp_query->query_vars['course_results'])) {
143 143
 			$classes[] = 'course-results';
144 144
 		}
145 145
 		return $classes;
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
      *
151 151
      * @deprecated since 1.9.0
152 152
      */
153
-    public static function deprecate_sensei_course_results_content_hook(){
153
+    public static function deprecate_sensei_course_results_content_hook() {
154 154
 
155
-        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
155
+        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0', 'sensei_course_results_content_before');
156 156
 
157 157
     }
158 158
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
      *
162 162
      * @since 1.9.0
163 163
      */
164
-    public static function fire_sensei_message_hook(){
164
+    public static function fire_sensei_message_hook() {
165 165
 
166
-        do_action( 'sensei_frontend_messages' );
166
+        do_action('sensei_frontend_messages');
167 167
 
168 168
     }
169 169
 
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @since 1.9.0
174 174
      */
175
-    public static function deprecate_course_result_info_hook(){
175
+    public static function deprecate_course_result_info_hook() {
176 176
 
177
-        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
177
+        sensei_do_deprecated_action('sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before');
178 178
 
179 179
     }
180 180
 
@@ -183,10 +183,10 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @deprecate since 1.9.0
185 185
      */
186
-    public static function deprecate_course_results_top_hook(){
186
+    public static function deprecate_course_results_top_hook() {
187 187
 
188 188
         global $course;
189
-        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
189
+        sensei_do_deprecated_action('sensei_course_results_top', '1.9.0', 'sensei_course_results_content_inside_before', $course->ID);
190 190
 
191 191
     }
192 192
 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
      *
196 196
      * @since 1.8.0
197 197
      */
198
-    public static function fire_course_image_hook(){
198
+    public static function fire_course_image_hook() {
199 199
 
200 200
         global $course;
201
-        do_action( 'sensei_course_image', $course->ID );
201
+        do_action('sensei_course_image', $course->ID);
202 202
 
203 203
     }
204 204
 
@@ -209,4 +209,4 @@  discard block
 block discarded – undo
209 209
  * for backward compatibility
210 210
  * @since 1.9.0
211 211
  */
212
-class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{}
212
+class WooThemes_Sensei_Course_Results extends Sensei_Course_Results {}
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Sensei_Course_Results {
16 16
 
17
-    /**
18
-     * @var string
19
-     */
20
-    public  $courses_url_base;
17
+	/**
18
+	 * @var string
19
+	 */
20
+	public  $courses_url_base;
21 21
 
22 22
 	/**
23 23
 	 * Constructor.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		global $wp_query,  $current_user;
99 99
 
100 100
 		if( isset( $wp_query->query_vars['course_results'] ) ) {
101
-            Sensei_Templates::get_template( 'course-results/course-info.php' );
101
+			Sensei_Templates::get_template( 'course-results/course-info.php' );
102 102
 		}
103 103
 
104 104
 	}
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
 
118 118
 		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
119 119
 
120
-        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
120
+		sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
121 121
 
122 122
 	}
123 123
 
124 124
 	/**
125 125
 	 * Load template for displaying course lessons
126
-     *
126
+	 *
127 127
 	 * @since  1.4.0
128 128
 	 * @return void
129 129
 	 */
130 130
 	public function course_lessons() {
131 131
 
132 132
 		global $course;
133
-        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
133
+		_deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
134 134
 
135 135
 	}
136 136
 
@@ -147,62 +147,62 @@  discard block
 block discarded – undo
147 147
 		return $classes;
148 148
 	}
149 149
 
150
-    /**
151
-     * Deprecate the sensei_course_results_content hook
152
-     *
153
-     * @deprecated since 1.9.0
154
-     */
155
-    public static function deprecate_sensei_course_results_content_hook(){
150
+	/**
151
+	 * Deprecate the sensei_course_results_content hook
152
+	 *
153
+	 * @deprecated since 1.9.0
154
+	 */
155
+	public static function deprecate_sensei_course_results_content_hook(){
156 156
 
157
-        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
157
+		sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
158 158
 
159
-    }
159
+	}
160 160
 
161
-    /**
162
-     * Fire the sensei frontend message hook
163
-     *
164
-     * @since 1.9.0
165
-     */
166
-    public static function fire_sensei_message_hook(){
161
+	/**
162
+	 * Fire the sensei frontend message hook
163
+	 *
164
+	 * @since 1.9.0
165
+	 */
166
+	public static function fire_sensei_message_hook(){
167 167
 
168
-        do_action( 'sensei_frontend_messages' );
168
+		do_action( 'sensei_frontend_messages' );
169 169
 
170
-    }
170
+	}
171 171
 
172
-    /**
173
-     * Deprecate the course_results info hook
174
-     *
175
-     * @since 1.9.0
176
-     */
177
-    public static function deprecate_course_result_info_hook(){
172
+	/**
173
+	 * Deprecate the course_results info hook
174
+	 *
175
+	 * @since 1.9.0
176
+	 */
177
+	public static function deprecate_course_result_info_hook(){
178 178
 
179
-        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
179
+		sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
180 180
 
181
-    }
181
+	}
182 182
 
183
-    /**
184
-     * Deprecate the sensei_course_results_top hook
185
-     *
186
-     * @deprecate since 1.9.0
187
-     */
188
-    public static function deprecate_course_results_top_hook(){
183
+	/**
184
+	 * Deprecate the sensei_course_results_top hook
185
+	 *
186
+	 * @deprecate since 1.9.0
187
+	 */
188
+	public static function deprecate_course_results_top_hook(){
189 189
 
190
-        global $course;
191
-        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
190
+		global $course;
191
+		sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
192 192
 
193
-    }
193
+	}
194 194
 
195
-    /**
196
-     * Fire the course image hook
197
-     *
198
-     * @since 1.8.0
199
-     */
200
-    public static function fire_course_image_hook(){
195
+	/**
196
+	 * Fire the course image hook
197
+	 *
198
+	 * @since 1.8.0
199
+	 */
200
+	public static function fire_course_image_hook(){
201 201
 
202
-        global $course;
203
-        do_action( 'sensei_course_image', $course->ID );
202
+		global $course;
203
+		do_action( 'sensei_course_image', $course->ID );
204 204
 
205
-    }
205
+	}
206 206
 
207 207
 } // End Class
208 208
 
Please login to merge, or discard this patch.
includes/class-sensei-settings.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   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,43 +21,43 @@  discard block
 block discarded – undo
21 21
 	 * @return void
22 22
 	 */
23 23
 	public function __construct () {
24
-	    parent::__construct(); // Required in extended classes.
24
+		parent::__construct(); // Required in extended classes.
25 25
 
26
-        $this->token = 'woothemes-sensei-settings';
27
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
26
+		$this->token = 'woothemes-sensei-settings';
27
+		add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
28 28
 
29
-        // Setup Admin Settings data
30
-        if ( is_admin() ) {
29
+		// Setup Admin Settings data
30
+		if ( is_admin() ) {
31 31
 
32
-            $this->has_tabs 	= true;
33
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
35
-            $this->page_slug	= 'woothemes-sensei-settings';
32
+			$this->has_tabs 	= true;
33
+			$this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
+			$this->menu_label	= __( 'Settings', 'woothemes-sensei' );
35
+			$this->page_slug	= 'woothemes-sensei-settings';
36 36
 
37
-        } // End If Statement
37
+		} // End If Statement
38 38
 
39
-        $this->register_hook_listener();
40
-        $this->get_settings();
39
+		$this->register_hook_listener();
40
+		$this->get_settings();
41 41
 
42 42
 	} // End __construct()
43 43
 
44
-    /**
45
-     * Get settings value
46
-     *
47
-     * @since 1.9.0
48
-     * @param string $setting_name
49
-     * @return mixed
50
-     */
51
-    public function get( $setting_name ){
44
+	/**
45
+	 * Get settings value
46
+	 *
47
+	 * @since 1.9.0
48
+	 * @param string $setting_name
49
+	 * @return mixed
50
+	 */
51
+	public function get( $setting_name ){
52 52
 
53
-        if( isset( $this->settings[ $setting_name ] ) ){
53
+		if( isset( $this->settings[ $setting_name ] ) ){
54 54
 
55
-            return $this->settings[ $setting_name ];
55
+			return $this->settings[ $setting_name ];
56 56
 
57
-        }
57
+		}
58 58
 
59
-        return false;
60
-    }
59
+		return false;
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * Register the settings screen within the WordPress admin.
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
146 146
 		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
147 147
 
148
-	    $fields = array();
148
+		$fields = array();
149 149
 
150 150
 		$fields['access_permission'] = array(
151 151
 								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 								'section' => 'default-settings'
208 208
 								);
209 209
 
210
-    	// Course Settings
210
+		// Course Settings
211 211
 
212
-    	$fields['course_completion'] = array(
212
+		$fields['course_completion'] = array(
213 213
 								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
214 214
 								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
215 215
 								'type' => 'select',
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 								'options' => $complete_settings
220 220
 								);
221 221
 
222
-    	$fields['course_author'] = array(
222
+		$fields['course_author'] = array(
223 223
 								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
224 224
 								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
225 225
 								'type' => 'checkbox',
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
 		);
448 448
 
449 449
 		$teacher_email_options = array(
450
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
450
+			'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
+			'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
+			'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
+			'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
454 454
 			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
455 455
 		);
456 456
 
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 
560 560
 		if ( Sensei_WC::is_woocommerce_active() ) {
561 561
 			// WooCommerce Settings
562
-    		$fields['woocommerce_enabled'] = array(
562
+			$fields['woocommerce_enabled'] = array(
563 563
 									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
564 564
 									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
565 565
 									'type' => 'checkbox',
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
648 648
 
649 649
 		foreach ( $pages_split as $k => $v ) {
650
-		    $id = '';
651
-		    // Get the ID value.
652
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
653
-
654
-		    if ( isset( $matches[1] ) ) {
655
-		        $id = $matches[1];
656
-		        $page_items[$id] = trim( strip_tags( $v ) );
657
-		    } // End If Statement
650
+			$id = '';
651
+			// Get the ID value.
652
+			preg_match( '/value="(.*?)"/i', $v, $matches );
653
+
654
+			if ( isset( $matches[1] ) ) {
655
+				$id = $matches[1];
656
+				$page_items[$id] = trim( strip_tags( $v ) );
657
+			} // End If Statement
658 658
 		} // End For Loop
659 659
 
660 660
 		$pages_array = $page_items;
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
 		Sensei_Language_Pack_Manager::messages();
672 672
 	}
673 673
 
674
-    /**
675
-     * Flush the rewrite rules after the settings have been updated.
676
-     * This is to ensure that the
677
-     *
678
-     * @since 1.9.0
679
-     */
680
-    public static function flush_rewrite_rules(){
674
+	/**
675
+	 * Flush the rewrite rules after the settings have been updated.
676
+	 * This is to ensure that the
677
+	 *
678
+	 * @since 1.9.0
679
+	 */
680
+	public static function flush_rewrite_rules(){
681 681
 
682
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
682
+		if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
+			&& isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
684 684
 
685
-            Sensei()->initiate_rewrite_rules_flush();
685
+			Sensei()->initiate_rewrite_rules_flush();
686 686
 
687
-        }
687
+		}
688 688
 
689
-    }//end  flush_cache
689
+	}//end  flush_cache
690 690
 } // End Class
691 691
 
692 692
 /**
Please login to merge, or discard this patch.
Spacing   +177 added lines, -177 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 Settings Class
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
 	 * @since 1.0.0
21 21
 	 * @return void
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 	    parent::__construct(); // Required in extended classes.
25 25
 
26 26
         $this->token = 'woothemes-sensei-settings';
27
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
27
+        add_action('init', array(__CLASS__, 'flush_rewrite_rules'));
28 28
 
29 29
         // Setup Admin Settings data
30
-        if ( is_admin() ) {
30
+        if (is_admin()) {
31 31
 
32 32
             $this->has_tabs 	= true;
33
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
33
+            $this->name = __('Sensei Settings', 'woothemes-sensei');
34
+            $this->menu_label = __('Settings', 'woothemes-sensei');
35 35
             $this->page_slug	= 'woothemes-sensei-settings';
36 36
 
37 37
         } // End If Statement
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      * @param string $setting_name
49 49
      * @return mixed
50 50
      */
51
-    public function get( $setting_name ){
51
+    public function get($setting_name) {
52 52
 
53
-        if( isset( $this->settings[ $setting_name ] ) ){
53
+        if (isset($this->settings[$setting_name])) {
54 54
 
55
-            return $this->settings[ $setting_name ];
55
+            return $this->settings[$setting_name];
56 56
 
57 57
         }
58 58
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 	 * @since  1.0.0
66 66
 	 * @return void
67 67
 	 */
68
-	public function register_settings_screen () {
68
+	public function register_settings_screen() {
69 69
 
70 70
 		$this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen.
71
-		$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
71
+		$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
72 72
 		$this->hook = $hook;
73 73
 
74
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
75
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
76
-			add_action( 'admin_notices', array( $this, 'language_pack_notices' ) );
77
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
78
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
74
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
75
+			add_action('admin_notices', array($this, 'settings_errors'));
76
+			add_action('admin_notices', array($this, 'language_pack_notices'));
77
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
78
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
79 79
 		}
80 80
 	} // End register_settings_screen()
81 81
 
@@ -85,49 +85,49 @@  discard block
 block discarded – undo
85 85
 	 * @since  1.0.0
86 86
 	 * @return void
87 87
 	 */
88
-	public function init_sections () {
88
+	public function init_sections() {
89 89
 		$sections = array();
90 90
 
91 91
 		$sections['default-settings'] = array(
92
-			'name' 			=> __( 'General', 'woothemes-sensei' ),
93
-			'description'	=> __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' )
92
+			'name' 			=> __('General', 'woothemes-sensei'),
93
+			'description'	=> __('Settings that apply to the entire plugin.', 'woothemes-sensei')
94 94
 		);
95 95
 
96 96
 		$sections['course-settings'] = array(
97
-			'name' 			=> __( 'Courses', 'woothemes-sensei' ),
98
-			'description'	=> __( 'Settings that apply to all Courses.', 'woothemes-sensei' )
97
+			'name' 			=> __('Courses', 'woothemes-sensei'),
98
+			'description'	=> __('Settings that apply to all Courses.', 'woothemes-sensei')
99 99
 		);
100 100
 
101 101
 		$sections['lesson-settings'] = array(
102
-			'name' 			=> __( 'Lessons', 'woothemes-sensei' ),
103
-			'description'	=> __( 'Settings that apply to all Lessons.', 'woothemes-sensei' )
102
+			'name' 			=> __('Lessons', 'woothemes-sensei'),
103
+			'description'	=> __('Settings that apply to all Lessons.', 'woothemes-sensei')
104 104
 		);
105 105
 
106 106
 		$sections['email-notification-settings'] = array(
107
-			'name' 			=> __( 'Email Notifications', 'woothemes-sensei' ),
108
-			'description'	=> __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' )
107
+			'name' 			=> __('Email Notifications', 'woothemes-sensei'),
108
+			'description'	=> __('Settings for email notifications sent from your site.', 'woothemes-sensei')
109 109
 		);
110 110
 
111 111
 		$sections['learner-profile-settings'] = array(
112
-			'name' 			=> __( 'Learner Profiles', 'woothemes-sensei' ),
113
-			'description'	=> __( 'Settings for public Learner Profiles.', 'woothemes-sensei' )
112
+			'name' 			=> __('Learner Profiles', 'woothemes-sensei'),
113
+			'description'	=> __('Settings for public Learner Profiles.', 'woothemes-sensei')
114 114
 		);
115 115
 
116
-		if ( Sensei_WC::is_woocommerce_present() ) {
116
+		if (Sensei_WC::is_woocommerce_present()) {
117 117
 			$sections['woocommerce-settings'] = array(
118
-				'name' 			=> __( 'WooCommerce', 'woothemes-sensei' ),
119
-				'description'	=> __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' )
118
+				'name' 			=> __('WooCommerce', 'woothemes-sensei'),
119
+				'description'	=> __('Optional settings for WooCommerce functions.', 'woothemes-sensei')
120 120
 			);
121 121
 		} // End If Statement
122 122
 
123
-		if ( 'en_US' !== get_locale() ) {
123
+		if ('en_US' !== get_locale()) {
124 124
 			$sections['language-settings'] = array(
125
-				'name' 			=> __( 'Language', 'woothemes-sensei' ),
126
-				'description'	=> __( 'Language options.', 'woothemes-sensei' )
125
+				'name' 			=> __('Language', 'woothemes-sensei'),
126
+				'description'	=> __('Language options.', 'woothemes-sensei')
127 127
 			);
128 128
 		}
129 129
 
130
-		$this->sections = apply_filters( 'sensei_settings_tabs', $sections );
130
+		$this->sections = apply_filters('sensei_settings_tabs', $sections);
131 131
 	} // End init_sections()
132 132
 
133 133
 	/**
@@ -137,71 +137,71 @@  discard block
 block discarded – undo
137 137
 	 * @uses   Sensei_Utils::get_slider_types()
138 138
 	 * @return void
139 139
 	 */
140
-	public function init_fields () {
140
+	public function init_fields() {
141 141
 		global $pagenow;
142 142
 
143 143
 		$pages_array = $this->pages_array();
144
-		$posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' );
145
-		$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
146
-		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
144
+		$posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20');
145
+		$complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei'));
146
+		$course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei'));
147 147
 
148 148
 	    $fields = array();
149 149
 
150 150
 		$fields['access_permission'] = array(
151
-								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
152
-								'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ),
151
+								'name' => __('Access Permissions', 'woothemes-sensei'),
152
+								'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'),
153 153
 								'type' => 'checkbox',
154 154
 								'default' => true,
155 155
 								'section' => 'default-settings'
156 156
 								);
157 157
 
158 158
 		$fields['messages_disable'] = array(
159
-								'name' => __( 'Disable Private Messages', 'woothemes-sensei' ),
160
-								'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ),
159
+								'name' => __('Disable Private Messages', 'woothemes-sensei'),
160
+								'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'),
161 161
 								'type' => 'checkbox',
162 162
 								'default' => false,
163 163
 								'section' => 'default-settings'
164 164
 								);
165 165
 
166 166
 		$fields['course_page'] = array(
167
-								'name' => __( 'Course Archive Page', 'woothemes-sensei' ),
168
-								'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ),
167
+								'name' => __('Course Archive Page', 'woothemes-sensei'),
168
+								'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'),
169 169
 								'type' => 'select',
170
-								'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ),
170
+								'default' => get_option('woothemes-sensei_courses_page_id', 0),
171 171
 								'section' => 'default-settings',
172 172
 								'required' => 0,
173 173
 								'options' => $pages_array
174 174
 								);
175 175
 
176 176
 		$fields['my_course_page'] = array(
177
-								'name' => __( 'My Courses Page', 'woothemes-sensei' ),
178
-								'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ),
177
+								'name' => __('My Courses Page', 'woothemes-sensei'),
178
+								'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'),
179 179
 								'type' => 'select',
180
-								'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ),
180
+								'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0),
181 181
 								'section' => 'default-settings',
182 182
 								'required' => 0,
183 183
 								'options' => $pages_array
184 184
 								);
185 185
 
186 186
 		$fields['placeholder_images_enable'] = array(
187
-								'name' => __( 'Use placeholder images', 'woothemes-sensei' ),
188
-								'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ),
187
+								'name' => __('Use placeholder images', 'woothemes-sensei'),
188
+								'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'),
189 189
 								'type' => 'checkbox',
190 190
 								'default' => false,
191 191
 								'section' => 'default-settings'
192 192
 								);
193 193
 
194 194
 		$fields['styles_disable'] = array(
195
-								'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ),
196
-								'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ),
195
+								'name' => __('Disable Sensei Styles', 'woothemes-sensei'),
196
+								'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'),
197 197
 								'type' => 'checkbox',
198 198
 								'default' => false,
199 199
 								'section' => 'default-settings'
200 200
 								);
201 201
 
202 202
 		$fields['js_disable'] = array(
203
-								'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ),
204
-								'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ),
203
+								'name' => __('Disable Sensei Javascript', 'woothemes-sensei'),
204
+								'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'),
205 205
 								'type' => 'checkbox',
206 206
 								'default' => false,
207 207
 								'section' => 'default-settings'
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
     	// Course Settings
211 211
 
212 212
     	$fields['course_completion'] = array(
213
-								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
214
-								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
213
+								'name' => __('Courses are complete:', 'woothemes-sensei'),
214
+								'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'),
215 215
 								'type' => 'select',
216 216
 								'default' => 'passed',
217 217
 								'section' => 'course-settings',
@@ -220,16 +220,16 @@  discard block
 block discarded – undo
220 220
 								);
221 221
 
222 222
     	$fields['course_author'] = array(
223
-								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
224
-								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
223
+								'name' => __('Display Course Author', 'woothemes-sensei'),
224
+								'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'),
225 225
 								'type' => 'checkbox',
226 226
 								'default' => true,
227 227
 								'section' => 'course-settings'
228 228
 								);
229 229
 
230 230
 		$fields['my_course_amount'] = array(
231
-								'name' => __( 'My Courses Pagination', 'woothemes-sensei' ),
232
-								'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ),
231
+								'name' => __('My Courses Pagination', 'woothemes-sensei'),
232
+								'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'),
233 233
 								'type' => 'range',
234 234
 								'default' => '0',
235 235
 								'section' => 'course-settings',
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 								);
239 239
 
240 240
 		$fields['course_archive_image_enable'] = array(
241
-								'name' => __( 'Course Archive Image', 'woothemes-sensei' ),
242
-								'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ),
241
+								'name' => __('Course Archive Image', 'woothemes-sensei'),
242
+								'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'),
243 243
 								'type' => 'checkbox',
244 244
 								'default' => true,
245 245
 								'section' => 'course-settings'
246 246
 								);
247 247
 
248 248
 		$fields['course_archive_image_width'] = array(
249
-								'name' => __( 'Image Width - Archive', 'woothemes-sensei' ),
250
-								'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
249
+								'name' => __('Image Width - Archive', 'woothemes-sensei'),
250
+								'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
251 251
 								'type' => 'text',
252 252
 								'default' => '100',
253 253
 								'section' => 'course-settings',
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 								);
256 256
 
257 257
 		$fields['course_archive_image_height'] = array(
258
-								'name' => __( 'Image Height - Archive', 'woothemes-sensei' ),
259
-								'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
258
+								'name' => __('Image Height - Archive', 'woothemes-sensei'),
259
+								'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
260 260
 								'type' => 'text',
261 261
 								'default' => '100',
262 262
 								'section' => 'course-settings',
@@ -264,24 +264,24 @@  discard block
 block discarded – undo
264 264
 								);
265 265
 
266 266
 		$fields['course_archive_image_hard_crop'] = array(
267
-								'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ),
268
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
267
+								'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'),
268
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
269 269
 								'type' => 'checkbox',
270 270
 								'default' => false,
271 271
 								'section' => 'course-settings'
272 272
 								);
273 273
 
274 274
 		$fields['course_single_image_enable'] = array(
275
-								'name' => __( 'Single Course Image', 'woothemes-sensei' ),
276
-								'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ),
275
+								'name' => __('Single Course Image', 'woothemes-sensei'),
276
+								'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'),
277 277
 								'type' => 'checkbox',
278 278
 								'default' => false,
279 279
 								'section' => 'course-settings'
280 280
 								);
281 281
 
282 282
 		$fields['course_single_image_width'] = array(
283
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
284
-								'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
283
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
284
+								'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
285 285
 								'type' => 'text',
286 286
 								'default' => '100',
287 287
 								'section' => 'course-settings',
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 								);
290 290
 
291 291
 		$fields['course_single_image_height'] = array(
292
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
293
-								'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
292
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
293
+								'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
294 294
 								'type' => 'text',
295 295
 								'default' => '100',
296 296
 								'section' => 'course-settings',
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 								);
299 299
 
300 300
 		$fields['course_single_image_hard_crop'] = array(
301
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
302
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
301
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
302
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
303 303
 								'type' => 'checkbox',
304 304
 								'default' => false,
305 305
 								'section' => 'course-settings'
306 306
 								);
307 307
 
308 308
 		$fields['course_single_content_display'] = array(
309
-								'name' => __( 'Single Course page displays:', 'woothemes-sensei' ),
310
-								'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ),
309
+								'name' => __('Single Course page displays:', 'woothemes-sensei'),
310
+								'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'),
311 311
 								'type' => 'select',
312 312
 								'default' => 'excerpt',
313 313
 								'section' => 'course-settings',
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
 								);
317 317
 
318 318
 		$fields['course_archive_featured_enable'] = array(
319
-								'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ),
320
-								'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
319
+								'name' => __('Featured Courses Panel', 'woothemes-sensei'),
320
+								'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
321 321
 								'type' => 'checkbox',
322 322
 								'default' => true,
323 323
 								'section' => 'course-settings'
324 324
 								);
325 325
 
326 326
 		$fields['course_archive_more_link_text'] = array(
327
-								'name' => __( 'More link text', 'woothemes-sensei' ),
328
-								'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ),
327
+								'name' => __('More link text', 'woothemes-sensei'),
328
+								'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'),
329 329
 								'type' => 'text',
330
-								'default' => __ ( 'More', 'woothemes-sensei' ),
330
+								'default' => __('More', 'woothemes-sensei'),
331 331
 								'section' => 'course-settings',
332 332
 								'required' => 0
333 333
 								);
@@ -335,32 +335,32 @@  discard block
 block discarded – undo
335 335
 		// Lesson Settings
336 336
 
337 337
 		$fields['lesson_comments'] = array(
338
-								'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ),
339
-								'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ),
338
+								'name' => __('Allow Comments for Lessons', 'woothemes-sensei'),
339
+								'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'),
340 340
 								'type' => 'checkbox',
341 341
 								'default' => true,
342 342
 								'section' => 'lesson-settings'
343 343
 								);
344 344
 
345 345
 		$fields['lesson_author'] = array(
346
-								'name' => __( 'Display Lesson Author', 'woothemes-sensei' ),
347
-								'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ),
346
+								'name' => __('Display Lesson Author', 'woothemes-sensei'),
347
+								'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'),
348 348
 								'type' => 'checkbox',
349 349
 								'default' => true,
350 350
 								'section' => 'lesson-settings'
351 351
 								);
352 352
 
353 353
 		$fields['course_lesson_image_enable'] = array(
354
-								'name' => __( 'Course Lesson Images', 'woothemes-sensei' ),
355
-								'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ),
354
+								'name' => __('Course Lesson Images', 'woothemes-sensei'),
355
+								'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'),
356 356
 								'type' => 'checkbox',
357 357
 								'default' => false,
358 358
 								'section' => 'lesson-settings'
359 359
 								);
360 360
 
361 361
 		$fields['lesson_archive_image_width'] = array(
362
-								'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ),
363
-								'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
362
+								'name' => __('Image Width - Course Lessons', 'woothemes-sensei'),
363
+								'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
364 364
 								'type' => 'text',
365 365
 								'default' => '100',
366 366
 								'section' => 'lesson-settings',
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 								);
369 369
 
370 370
 		$fields['lesson_archive_image_height'] = array(
371
-								'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ),
372
-								'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
371
+								'name' => __('Image Height - Course Lessons', 'woothemes-sensei'),
372
+								'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
373 373
 								'type' => 'text',
374 374
 								'default' => '100',
375 375
 								'section' => 'lesson-settings',
@@ -377,24 +377,24 @@  discard block
 block discarded – undo
377 377
 								);
378 378
 
379 379
 		$fields['lesson_archive_image_hard_crop'] = array(
380
-								'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ),
381
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
380
+								'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'),
381
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
382 382
 								'type' => 'checkbox',
383 383
 								'default' => false,
384 384
 								'section' => 'lesson-settings'
385 385
 								);
386 386
 
387 387
 		$fields['lesson_single_image_enable'] = array(
388
-								'name' => __( 'Single Lesson Images', 'woothemes-sensei' ),
389
-								'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ),
388
+								'name' => __('Single Lesson Images', 'woothemes-sensei'),
389
+								'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'),
390 390
 								'type' => 'checkbox',
391 391
 								'default' => false,
392 392
 								'section' => 'lesson-settings'
393 393
 								);
394 394
 
395 395
 		$fields['lesson_single_image_width'] = array(
396
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
397
-								'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
396
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
397
+								'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
398 398
 								'type' => 'text',
399 399
 								'default' => '100',
400 400
 								'section' => 'lesson-settings',
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 								);
403 403
 
404 404
 		$fields['lesson_single_image_height'] = array(
405
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
406
-								'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
405
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
406
+								'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
407 407
 								'type' => 'text',
408 408
 								'default' => '100',
409 409
 								'section' => 'lesson-settings',
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 								);
412 412
 
413 413
 		$fields['lesson_single_image_hard_crop'] = array(
414
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
415
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
414
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
415
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
416 416
 								'type' => 'checkbox',
417 417
 								'default' => false,
418 418
 								'section' => 'lesson-settings'
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 
421 421
 		// Learner Profile settings
422 422
 
423
-		$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
424
-		$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%';
423
+		$profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
424
+		$profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%';
425 425
 
426 426
 		$fields['learner_profile_enable'] = array(
427
-							'name' => __( 'Public learner profiles', 'woothemes-sensei' ),
428
-							'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ),
427
+							'name' => __('Public learner profiles', 'woothemes-sensei'),
428
+							'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example),
429 429
 							'type' => 'checkbox',
430 430
 							'default' => true,
431 431
 							'section' => 'learner-profile-settings'
432 432
 							);
433 433
 
434 434
 		$fields['learner_profile_show_courses'] = array(
435
-							'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ),
436
-							'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ),
435
+							'name' => __('Show learner\'s courses', 'woothemes-sensei'),
436
+							'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'),
437 437
 							'type' => 'checkbox',
438 438
 							'default' => true,
439 439
 							'section' => 'learner-profile-settings'
@@ -442,70 +442,70 @@  discard block
 block discarded – undo
442 442
 		// Email notifications
443 443
 
444 444
 		$learner_email_options = array(
445
-			'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ),
446
-			'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ),
445
+			'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'),
446
+			'learner-completed-course' => __('They complete a course', 'woothemes-sensei'),
447 447
 		);
448 448
 
449 449
 		$teacher_email_options = array(
450
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
454
-			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
450
+            'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'),
451
+            'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'),
452
+            'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'),
453
+            'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'),
454
+			'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'),
455 455
 		);
456 456
 
457 457
 		$global_email_options = array(
458
-			'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ),
458
+			'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'),
459 459
 		);
460 460
 
461 461
 		$fields['email_learners'] = array(
462
-								'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ),
463
-								'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ),
462
+								'name' => __('Emails Sent to Learners', 'woothemes-sensei'),
463
+								'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'),
464 464
 								'type' => 'multicheck',
465 465
 								'options' => $learner_email_options,
466
-								'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ),
466
+								'defaults' => array('learner-graded-quiz', 'learner-completed-course'),
467 467
 								'section' => 'email-notification-settings'
468 468
 								);
469 469
 
470 470
 		$fields['email_teachers'] = array(
471
-								'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ),
472
-								'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ),
471
+								'name' => __('Emails Sent to Teachers', 'woothemes-sensei'),
472
+								'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'),
473 473
 								'type' => 'multicheck',
474 474
 								'options' => $teacher_email_options,
475
-								'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ),
475
+								'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'),
476 476
 								'section' => 'email-notification-settings'
477 477
 								);
478 478
 
479 479
 		$fields['email_global'] = array(
480
-								'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ),
481
-								'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ),
480
+								'name' => __('Emails Sent to All Users', 'woothemes-sensei'),
481
+								'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'),
482 482
 								'type' => 'multicheck',
483 483
 								'options' => $global_email_options,
484
-								'defaults' => array( 'new-message-reply' ),
484
+								'defaults' => array('new-message-reply'),
485 485
 								'section' => 'email-notification-settings'
486 486
 								);
487 487
 
488 488
 		$fields['email_from_name'] = array(
489
-								'name' => __( '"From" Name', 'woothemes-sensei' ),
490
-								'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ),
489
+								'name' => __('"From" Name', 'woothemes-sensei'),
490
+								'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'),
491 491
 								'type' => 'text',
492
-								'default' => get_bloginfo( 'name' ),
492
+								'default' => get_bloginfo('name'),
493 493
 								'section' => 'email-notification-settings',
494 494
 								'required' => 1
495 495
 								);
496 496
 
497 497
 		$fields['email_from_address'] = array(
498
-								'name' => __( '"From" Address', 'woothemes-sensei' ),
499
-								'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ),
498
+								'name' => __('"From" Address', 'woothemes-sensei'),
499
+								'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'),
500 500
 								'type' => 'text',
501
-								'default' => get_bloginfo( 'admin_email' ),
501
+								'default' => get_bloginfo('admin_email'),
502 502
 								'section' => 'email-notification-settings',
503 503
 								'required' => 1
504 504
 								);
505 505
 
506 506
 		$fields['email_header_image'] = array(
507
-								'name' => __( 'Header Image', 'woothemes-sensei' ),
508
-								'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ),
507
+								'name' => __('Header Image', 'woothemes-sensei'),
508
+								'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'),
509 509
 								'type' => 'text',
510 510
 								'default' => '',
511 511
 								'section' => 'email-notification-settings',
@@ -513,17 +513,17 @@  discard block
 block discarded – undo
513 513
 								);
514 514
 
515 515
 		$fields['email_footer_text'] = array(
516
-								'name' => __( 'Email Footer Text', 'woothemes-sensei' ),
517
-								'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ),
516
+								'name' => __('Email Footer Text', 'woothemes-sensei'),
517
+								'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'),
518 518
 								'type' => 'textarea',
519
-								'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ),
519
+								'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')),
520 520
 								'section' => 'email-notification-settings',
521 521
 								'required' => 0
522 522
 								);
523 523
 
524 524
 		$fields['email_base_color'] = array(
525
-								'name' => __( 'Base Colour', 'woothemes-sensei' ),
526
-								'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
525
+								'name' => __('Base Colour', 'woothemes-sensei'),
526
+								'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
527 527
 								'type' => 'color',
528 528
 								'default' => '#557da1',
529 529
 								'section' => 'email-notification-settings',
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 								);
532 532
 
533 533
 		$fields['email_background_color'] = array(
534
-								'name' => __( 'Background Colour', 'woothemes-sensei' ),
535
-								'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
534
+								'name' => __('Background Colour', 'woothemes-sensei'),
535
+								'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
536 536
 								'type' => 'color',
537 537
 								'default' => '#f5f5f5',
538 538
 								'section' => 'email-notification-settings',
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 								);
541 541
 
542 542
 		$fields['email_body_background_color'] = array(
543
-								'name' => __( 'Body Background Colour', 'woothemes-sensei' ),
544
-								'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
543
+								'name' => __('Body Background Colour', 'woothemes-sensei'),
544
+								'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
545 545
 								'type' => 'color',
546 546
 								'default' => '#fdfdfd',
547 547
 								'section' => 'email-notification-settings',
@@ -549,35 +549,35 @@  discard block
 block discarded – undo
549 549
 								);
550 550
 
551 551
 		$fields['email_text_color'] = array(
552
-								'name' => __( 'Body Text Colour', 'woothemes-sensei' ),
553
-								'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
552
+								'name' => __('Body Text Colour', 'woothemes-sensei'),
553
+								'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
554 554
 								'type' => 'color',
555 555
 								'default' => '#505050',
556 556
 								'section' => 'email-notification-settings',
557 557
 								'required' => 1
558 558
 								);
559 559
 
560
-		if ( Sensei_WC::is_woocommerce_active() ) {
560
+		if (Sensei_WC::is_woocommerce_active()) {
561 561
 			// WooCommerce Settings
562 562
     		$fields['woocommerce_enabled'] = array(
563
-									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
564
-									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
563
+									'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'),
564
+									'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'),
565 565
 									'type' => 'checkbox',
566 566
 									'default' => true,
567 567
 									'section' => 'woocommerce-settings'
568 568
 									);
569 569
 
570 570
 			$fields['course_archive_free_enable'] = array(
571
-									'name' => __( 'Free Courses Panel', 'woothemes-sensei' ),
572
-									'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
571
+									'name' => __('Free Courses Panel', 'woothemes-sensei'),
572
+									'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
573 573
 									'type' => 'checkbox',
574 574
 									'default' => true,
575 575
 									'section' => 'woocommerce-settings'
576 576
 									);
577 577
 
578 578
 			$fields['course_archive_paid_enable'] = array(
579
-									'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ),
580
-									'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
579
+									'name' => __('Paid Courses Panel', 'woothemes-sensei'),
580
+									'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
581 581
 									'type' => 'checkbox',
582 582
 									'default' => true,
583 583
 									'section' => 'woocommerce-settings'
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
 
586 586
 		} // End If Statement
587 587
 
588
-		if ( 'en_US' !== get_locale() ) {
588
+		if ('en_US' !== get_locale()) {
589 589
 			$fields['install_language_pack'] = array(
590
-				'name'        => __( 'Install Language Pack', 'woothemes-sensei' ),
591
-				'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ),
590
+				'name'        => __('Install Language Pack', 'woothemes-sensei'),
591
+				'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'),
592 592
 				'type'        => 'button',
593 593
 				'section'     => 'language-settings',
594 594
 				'target'      => Sensei_Language_Pack_Manager::get_install_uri(),
595
-				'label'       => __( 'Install', 'woothemes-sensei' )
595
+				'label'       => __('Install', 'woothemes-sensei')
596 596
 			);
597 597
 		}
598 598
 
599
-		$this->fields = apply_filters( 'sensei_settings_fields', $fields );
599
+		$this->fields = apply_filters('sensei_settings_fields', $fields);
600 600
 
601 601
 	} // End init_fields()
602 602
 
@@ -606,20 +606,20 @@  discard block
 block discarded – undo
606 606
 	 * @param  $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1.
607 607
 	 * @return array Options between 0.1 and 10 seconds.
608 608
 	 */
609
-	private function get_duration_options ( $include_milliseconds = true ) {
610
-		$numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' );
609
+	private function get_duration_options($include_milliseconds = true) {
610
+		$numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0');
611 611
 		$options = array();
612 612
 
613
-		if ( true == (bool)$include_milliseconds ) {
614
-			$milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' );
615
-			foreach ( $milliseconds as $k => $v ) {
613
+		if (true == (bool) $include_milliseconds) {
614
+			$milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9');
615
+			foreach ($milliseconds as $k => $v) {
616 616
 				$options[$v] = $v;
617 617
 			}
618 618
 		} else {
619 619
 			$options['0.5'] = '0.5';
620 620
 		}
621 621
 
622
-		foreach ( $numbers as $k => $v ) {
622
+		foreach ($numbers as $k => $v) {
623 623
 			$options[$v] = $v;
624 624
 		}
625 625
 
@@ -635,25 +635,25 @@  discard block
 block discarded – undo
635 635
 	private function pages_array() {
636 636
 		// REFACTOR - Transform this into a field type instead.
637 637
 		// Setup an array of portfolio gallery terms for a dropdown.
638
-		$args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' );
639
-		$pages_dropdown = wp_dropdown_pages( $args );
638
+		$args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC');
639
+		$pages_dropdown = wp_dropdown_pages($args);
640 640
 		$page_items = array();
641 641
 
642 642
 		// Quick string hack to make sure we get the pages with the indents.
643
-		$pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown );
644
-		$pages_dropdown = str_replace( '</select>', '', $pages_dropdown );
645
-		$pages_split = explode( '</option>', $pages_dropdown );
643
+		$pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown);
644
+		$pages_dropdown = str_replace('</select>', '', $pages_dropdown);
645
+		$pages_split = explode('</option>', $pages_dropdown);
646 646
 
647
-		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
647
+		$page_items[] = __('Select a Page:', 'woothemes-sensei');
648 648
 
649
-		foreach ( $pages_split as $k => $v ) {
649
+		foreach ($pages_split as $k => $v) {
650 650
 		    $id = '';
651 651
 		    // Get the ID value.
652
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
652
+		    preg_match('/value="(.*?)"/i', $v, $matches);
653 653
 
654
-		    if ( isset( $matches[1] ) ) {
654
+		    if (isset($matches[1])) {
655 655
 		        $id = $matches[1];
656
-		        $page_items[$id] = trim( strip_tags( $v ) );
656
+		        $page_items[$id] = trim(strip_tags($v));
657 657
 		    } // End If Statement
658 658
 		} // End For Loop
659 659
 
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
      *
678 678
      * @since 1.9.0
679 679
      */
680
-    public static function flush_rewrite_rules(){
680
+    public static function flush_rewrite_rules() {
681 681
 
682
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
682
+        if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page']
683
+            && isset($_POST['action']) && 'update' == $_POST['action']) {
684 684
 
685 685
             Sensei()->initiate_rewrite_rules_flush();
686 686
 
@@ -694,4 +694,4 @@  discard block
 block discarded – undo
694 694
  * for backward compatibility
695 695
  * @since 1.9.0
696 696
  */
697
-class WooThemes_Sensei_Settings extends Sensei_Settings{}
697
+class WooThemes_Sensei_Settings extends Sensei_Settings {}
Please login to merge, or discard this patch.