Completed
Push — master ( 7d92ba...201c1b )
by Dwain
05:05
created
includes/class-sensei-course.php 1 patch
Spacing   +641 added lines, -641 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 Class
@@ -33,69 +33,69 @@  discard block
 block discarded – undo
33 33
 	 * Constructor.
34 34
 	 * @since  1.0.0
35 35
 	 */
36
-	public function __construct () {
36
+	public function __construct() {
37 37
 		// Setup meta fields for this post type
38
-		$this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' );
38
+		$this->meta_fields = array('course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product');
39 39
 		// Admin actions
40
-		if ( is_admin() ) {
40
+		if (is_admin()) {
41 41
 			// Metabox functions
42
-            add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 );
43
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
42
+            add_action('add_meta_boxes', array($this, 'meta_box_setup'), 20);
43
+			add_action('save_post', array($this, 'meta_box_save'));
44 44
 			// Custom Write Panel Columns
45
-			add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 );
46
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
45
+			add_filter('manage_edit-course_columns', array($this, 'add_column_headings'), 10, 1);
46
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
47 47
 		} else {
48 48
 			$this->my_courses_page = false;
49 49
 		} // End If Statement
50 50
 
51 51
 		// Update course completion upon completion of a lesson
52
-		add_action( 'sensei_user_lesson_end', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
52
+		add_action('sensei_user_lesson_end', array($this, 'update_status_after_lesson_change'), 10, 2);
53 53
 		// Update course completion upon reset of a lesson
54
-		add_action( 'sensei_user_lesson_reset', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
54
+		add_action('sensei_user_lesson_reset', array($this, 'update_status_after_lesson_change'), 10, 2);
55 55
 		// Update course completion upon grading of a quiz
56
-		add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 );
56
+		add_action('sensei_user_quiz_grade', array($this, 'update_status_after_quiz_submission'), 10, 2);
57 57
 
58 58
         // show the progress bar ont he single course page
59
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 );
60
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 );
59
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_statement'), 15);
60
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_meter'), 16);
61 61
 
62 62
         // provide an option to block all emails related to a selected course
63
-        add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) );
64
-        add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) );
63
+        add_filter('sensei_send_emails', array($this, 'block_notification_emails'));
64
+        add_action('save_post', array($this, 'save_course_notification_meta_box'));
65 65
 
66 66
         // preview lessons on the course content
67
-        add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) );
67
+        add_action('sensei_course_content_inside_after', array($this, 'the_course_free_lesson_preview'));
68 68
 
69 69
         // the course meta
70
-        add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) );
70
+        add_action('sensei_course_content_inside_before', array($this, 'the_course_meta'));
71 71
 
72 72
         // backwards compatible template hooks
73
-        add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' ));
74
-        add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) );
73
+        add_action('sensei_course_content_inside_before', array($this, 'content_before_backwards_compatibility_hooks'));
74
+        add_action('sensei_loop_course_before', array($this, 'loop_before_backwards_compatibility_hooks'));
75 75
 
76 76
         // add the user status on the course to the markup as a class
77
-        add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 );
77
+        add_filter('post_class', array(__CLASS__, 'add_course_user_status_class'), 20, 3);
78 78
 
79 79
         //filter the course query in Sensei specific instances
80
-        add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) );
80
+        add_filter('pre_get_posts', array(__CLASS__, 'course_query_filter'));
81 81
 
82 82
         //attache the sorting to the course archive
83
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) );
83
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_sorting'));
84 84
 
85 85
         //attach the filter links to the course archive
86
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) );
86
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_filters'));
87 87
 
88 88
         //filter the course query when featured filter is applied
89
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_featured_filter'));
89
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_featured_filter'));
90 90
 
91 91
         // handle the order by title post submission
92
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_order_by_title'));
92
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_order_by_title'));
93 93
 
94 94
         // ensure the course category page respects the manual order set for courses
95
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'alter_course_category_order'));
95
+        add_filter('pre_get_posts', array(__CLASS__, 'alter_course_category_order'));
96 96
 
97 97
         // flush rewrite rules when saving a course
98
-        add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) );
98
+        add_action('save_post', array('Sensei_Course', 'flush_rewrite_rules'));
99 99
 
100 100
 	} // End __construct()
101 101
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	 * @param type $user_id
106 106
 	 * @param type $quiz_id
107 107
 	 */
108
-	public function update_status_after_quiz_submission( $user_id, $quiz_id ) {
109
-		if ( intval( $user_id ) > 0 && intval( $quiz_id ) > 0 ) {
110
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
111
-			$this->update_status_after_lesson_change( $user_id, $lesson_id );
108
+	public function update_status_after_quiz_submission($user_id, $quiz_id) {
109
+		if (intval($user_id) > 0 && intval($quiz_id) > 0) {
110
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
111
+			$this->update_status_after_lesson_change($user_id, $lesson_id);
112 112
 		}
113 113
 	}
114 114
 
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 * @param int $user_id
119 119
 	 * @param int $lesson_id
120 120
 	 */
121
-	public function update_status_after_lesson_change( $user_id, $lesson_id ) {
122
-		if ( intval( $user_id ) > 0 && intval( $lesson_id ) > 0 ) {
123
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
124
-			if ( intval( $course_id ) > 0 ) {
121
+	public function update_status_after_lesson_change($user_id, $lesson_id) {
122
+		if (intval($user_id) > 0 && intval($lesson_id) > 0) {
123
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
124
+			if (intval($course_id) > 0) {
125 125
 				// Updates the Course status and it's meta data
126
-				WooThemes_Sensei_Utils::user_complete_course( $course_id, $user_id );
126
+				WooThemes_Sensei_Utils::user_complete_course($course_id, $user_id);
127 127
 			}
128 128
 		}
129 129
 	}
@@ -134,27 +134,27 @@  discard block
 block discarded – undo
134 134
 	 * @access public
135 135
 	 * @return void
136 136
 	 */
137
-	public function meta_box_setup () {
137
+	public function meta_box_setup() {
138 138
 
139
-		if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
139
+		if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
140 140
 			// Add Meta Box for WooCommerce Course
141
-			add_meta_box( 'course-wc-product', __( 'WooCommerce Product', 'woothemes-sensei' ), array( $this, 'course_woocommerce_product_meta_box_content' ), $this->token, 'side', 'default' );
141
+			add_meta_box('course-wc-product', __('WooCommerce Product', 'woothemes-sensei'), array($this, 'course_woocommerce_product_meta_box_content'), $this->token, 'side', 'default');
142 142
 		} // End If Statement
143 143
 		// Add Meta Box for Prerequisite Course
144
-		add_meta_box( 'course-prerequisite', __( 'Course Prerequisite', 'woothemes-sensei' ), array( $this, 'course_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
144
+		add_meta_box('course-prerequisite', __('Course Prerequisite', 'woothemes-sensei'), array($this, 'course_prerequisite_meta_box_content'), $this->token, 'side', 'default');
145 145
 		// Add Meta Box for Featured Course
146
-		add_meta_box( 'course-featured', __( 'Featured Course', 'woothemes-sensei' ), array( $this, 'course_featured_meta_box_content' ), $this->token, 'side', 'default' );
146
+		add_meta_box('course-featured', __('Featured Course', 'woothemes-sensei'), array($this, 'course_featured_meta_box_content'), $this->token, 'side', 'default');
147 147
 		// Add Meta Box for Course Meta
148
-		add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' );
148
+		add_meta_box('course-video', __('Course Video', 'woothemes-sensei'), array($this, 'course_video_meta_box_content'), $this->token, 'normal', 'default');
149 149
 		// Add Meta Box for Course Lessons
150
-		add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' );
150
+		add_meta_box('course-lessons', __('Course Lessons', 'woothemes-sensei'), array($this, 'course_lessons_meta_box_content'), $this->token, 'normal', 'default');
151 151
         // Add Meta Box to link to Manage Learners
152
-        add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' );
152
+        add_meta_box('course-manage', __('Course Management', 'woothemes-sensei'), array($this, 'course_manage_meta_box_content'), $this->token, 'side', 'default');
153 153
         // Remove "Custom Settings" meta box.
154
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
154
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
155 155
 
156 156
         // add Disable email notification box
157
-        add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' );
157
+        add_meta_box('course-notifications', __('Course Notifications', 'woothemes-sensei'), array($this, 'course_notification_meta_box_content'), 'course', 'normal', 'default');
158 158
 
159 159
 	} // End meta_box_setup()
160 160
 
@@ -164,58 +164,58 @@  discard block
 block discarded – undo
164 164
 	 * @access public
165 165
 	 * @return void
166 166
 	 */
167
-	public function course_woocommerce_product_meta_box_content () {
167
+	public function course_woocommerce_product_meta_box_content() {
168 168
 		global $post;
169 169
 
170
-		$select_course_woocommerce_product = get_post_meta( $post->ID, '_course_woocommerce_product', true );
170
+		$select_course_woocommerce_product = get_post_meta($post->ID, '_course_woocommerce_product', true);
171 171
 
172
-		$post_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
172
+		$post_args = array('post_type' 		=> array('product', 'product_variation'),
173 173
 							'posts_per_page' 		=> -1,
174 174
 							'orderby'         	=> 'title',
175 175
     						'order'           	=> 'DESC',
176 176
     						'exclude' 			=> $post->ID,
177
-    						'post_status'		=> array( 'publish', 'private', 'draft' ),
177
+    						'post_status'		=> array('publish', 'private', 'draft'),
178 178
     						'tax_query'			=> array(
179 179
 								array(
180 180
 									'taxonomy'	=> 'product_type',
181 181
 									'field'		=> 'slug',
182
-									'terms'		=> array( 'variable', 'grouped' ),
182
+									'terms'		=> array('variable', 'grouped'),
183 183
 									'operator'	=> 'NOT IN'
184 184
 								)
185 185
 							),
186 186
 							'suppress_filters' 	=> 0
187 187
 							);
188
-		$posts_array = get_posts( $post_args );
188
+		$posts_array = get_posts($post_args);
189 189
 
190 190
 		$html = '';
191 191
 
192
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
192
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
193 193
 
194
-		if ( count( $posts_array ) > 0 ) {
194
+		if (count($posts_array) > 0) {
195 195
 
196
-			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
197
-			$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
196
+			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
197
+			$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
198 198
 				$prev_parent_id = 0;
199
-				foreach ( $posts_array as $post_item ) {
199
+				foreach ($posts_array as $post_item) {
200 200
 
201
-					if ( 'product_variation' == $post_item->post_type ) {
201
+					if ('product_variation' == $post_item->post_type) {
202 202
 
203
-						$product_object = get_product( $post_item->ID );
204
-						$parent_id = wp_get_post_parent_id( $post_item->ID );
203
+						$product_object = get_product($post_item->ID);
204
+						$parent_id = wp_get_post_parent_id($post_item->ID);
205 205
 
206
-                        if( sensei_check_woocommerce_version( '2.1' ) ) {
207
-							$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
206
+                        if (sensei_check_woocommerce_version('2.1')) {
207
+							$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
208 208
 
209 209
 						} else {
210 210
                             // fall back to pre wc 2.1
211
-							$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
211
+							$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
212 212
 
213 213
 						}
214 214
 
215
-                        $product_name = ucwords( $formatted_variation );
216
-                        if( empty( $product_name ) ){
215
+                        $product_name = ucwords($formatted_variation);
216
+                        if (empty($product_name)) {
217 217
 
218
-                            $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id;
218
+                            $product_name = __('Variation #', 'woothemes-sensei').$product_object->variation_id;
219 219
 
220 220
                         }
221 221
 
@@ -228,47 +228,47 @@  discard block
 block discarded – undo
228 228
 					}
229 229
 
230 230
 					// Show variations in groups
231
-					if( $parent_id && $parent_id != $prev_parent_id ) {
231
+					if ($parent_id && $parent_id != $prev_parent_id) {
232 232
 
233
-						if( 0 != $prev_parent_id ) {
233
+						if (0 != $prev_parent_id) {
234 234
 
235 235
 							$html .= '</optgroup>';
236 236
 
237 237
 						}
238
-						$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
238
+						$html .= '<optgroup label="'.get_the_title($parent_id).'">';
239 239
 						$prev_parent_id = $parent_id;
240 240
 
241
-					} elseif( ! $parent_id && 0 == $prev_parent_id ) {
241
+					} elseif ( ! $parent_id && 0 == $prev_parent_id) {
242 242
 
243 243
 						$html .= '</optgroup>';
244 244
 
245 245
 					}
246 246
 
247
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_woocommerce_product, false ) . '>' . esc_html( $product_name ) . '</option>' . "\n";
247
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_woocommerce_product, false).'>'.esc_html($product_name).'</option>'."\n";
248 248
 
249 249
 				} // End For Loop
250 250
 
251
-			$html .= '</select>' . "\n";
252
-			if ( current_user_can( 'publish_product' )) {
251
+			$html .= '</select>'."\n";
252
+			if (current_user_can('publish_product')) {
253 253
 
254
-				$html .= '<p>' . "\n";
255
-					$html .= '<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Add a Product', 'woothemes-sensei' ) . '</a>' . "\n";
254
+				$html .= '<p>'."\n";
255
+					$html .= '<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Add a Product', 'woothemes-sensei').'</a>'."\n";
256 256
 				$html .= '</p>'."\n";
257 257
 
258 258
 			} // End If Statement
259 259
 
260 260
 		} else {
261 261
 
262
-			if ( current_user_can( 'publish_product' )) {
262
+			if (current_user_can('publish_product')) {
263 263
 
264
-				$html .= '<p>' . "\n";
265
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . '&nbsp;<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Please add some first', 'woothemes-sensei' ) . '</a>' . "\n";
264
+				$html .= '<p>'."\n";
265
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei')).'&nbsp;<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Please add some first', 'woothemes-sensei').'</a>'."\n";
266 266
 				$html .= '</p>'."\n";
267 267
 
268 268
 			} else {
269 269
 
270
-                $html .= '<p>' . "\n";
271
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n";
270
+                $html .= '<p>'."\n";
271
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei'))."\n";
272 272
 				$html .= '</p>'."\n";
273 273
 
274 274
 			} // End If Statement
@@ -285,33 +285,33 @@  discard block
 block discarded – undo
285 285
 	 * @access public
286 286
 	 * @return void
287 287
 	 */
288
-	public function course_prerequisite_meta_box_content () {
288
+	public function course_prerequisite_meta_box_content() {
289 289
 		global $post;
290 290
 
291
-		$select_course_prerequisite = get_post_meta( $post->ID, '_course_prerequisite', true );
291
+		$select_course_prerequisite = get_post_meta($post->ID, '_course_prerequisite', true);
292 292
 
293
-		$post_args = array(	'post_type' 		=> 'course',
293
+		$post_args = array('post_type' 		=> 'course',
294 294
 							'posts_per_page' 		=> -1,
295 295
 							'orderby'         	=> 'title',
296 296
     						'order'           	=> 'DESC',
297 297
     						'exclude' 			=> $post->ID,
298 298
 							'suppress_filters' 	=> 0
299 299
 							);
300
-		$posts_array = get_posts( $post_args );
300
+		$posts_array = get_posts($post_args);
301 301
 
302 302
 		$html = '';
303 303
 
304
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
304
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
305 305
 
306
-		if ( count( $posts_array ) > 0 ) {
307
-			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
308
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
309
-				foreach ($posts_array as $post_item){
310
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
306
+		if (count($posts_array) > 0) {
307
+			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
308
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
309
+				foreach ($posts_array as $post_item) {
310
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
311 311
 				} // End For Loop
312
-			$html .= '</select>' . "\n";
312
+			$html .= '</select>'."\n";
313 313
 		} else {
314
-			$html .= '<p>' . esc_html( __( 'No courses exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
314
+			$html .= '<p>'.esc_html(__('No courses exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
315 315
 		} // End If Statement
316 316
 
317 317
 		echo $html;
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @access public
325 325
 	 * @return void
326 326
 	 */
327
-	public function course_featured_meta_box_content () {
327
+	public function course_featured_meta_box_content() {
328 328
 		global $post;
329 329
 
330
-		$course_featured = get_post_meta( $post->ID, '_course_featured', true );
330
+		$course_featured = get_post_meta($post->ID, '_course_featured', true);
331 331
 
332 332
 		$html = '';
333 333
 
334
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
334
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
335 335
 
336 336
 		$checked = '';
337
-		if ( isset( $course_featured ) && ( '' != $course_featured ) ) {
338
-	 	    $checked = checked( 'featured', $course_featured, false );
337
+		if (isset($course_featured) && ('' != $course_featured)) {
338
+	 	    $checked = checked('featured', $course_featured, false);
339 339
 	 	} // End If Statement
340 340
 
341
-	 	$html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '>&nbsp;' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>';
341
+	 	$html .= '<input type="checkbox" name="course_featured" value="featured" '.$checked.'>&nbsp;'.__('Feature this course', 'woothemes-sensei').'<br>';
342 342
 
343 343
 		echo $html;
344 344
 
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
 	 * @access public
351 351
 	 * @return void
352 352
 	 */
353
-	public function course_video_meta_box_content () {
353
+	public function course_video_meta_box_content() {
354 354
 		global $post;
355 355
 
356
-		$course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
356
+		$course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
357 357
 
358 358
 		$html = '';
359 359
 
360
-		$html .= '<label class="screen-reader-text" for="course_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . '</label>';
361
-		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">' . $course_video_embed . '</textarea>';
362
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
360
+		$html .= '<label class="screen-reader-text" for="course_video_embed">'.__('Video Embed Code', 'woothemes-sensei').'</label>';
361
+		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">'.$course_video_embed.'</textarea>';
362
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
363 363
 
364 364
 		echo $html;
365 365
 
@@ -374,36 +374,36 @@  discard block
 block discarded – undo
374 374
 	 * @param int $post_id
375 375
 	 * @return void
376 376
 	 */
377
-	public function meta_box_save ( $post_id ) {
377
+	public function meta_box_save($post_id) {
378 378
 		global $post, $messages;
379 379
 
380 380
 		/* Verify the nonce before proceeding. */
381
-		if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) {
381
+		if ((get_post_type() != $this->token) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_noonce'], plugin_basename(__FILE__))) {
382 382
 			return $post_id;
383 383
 		}
384 384
 
385 385
 		/* Get the post type object. */
386
-		$post_type = get_post_type_object( $post->post_type );
386
+		$post_type = get_post_type_object($post->post_type);
387 387
 
388 388
 		/* Check if the current user has permission to edit the post. */
389
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
389
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
390 390
 			return $post_id;
391 391
 		} // End If Statement
392 392
 
393
-		if ( 'page' == $_POST['post_type'] ) {
394
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
393
+		if ('page' == $_POST['post_type']) {
394
+			if ( ! current_user_can('edit_page', $post_id)) {
395 395
 				return $post_id;
396 396
 			} // End If Statement
397 397
 		} else {
398
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
398
+			if ( ! current_user_can('edit_post', $post_id)) {
399 399
 				return $post_id;
400 400
 			} // End If Statement
401 401
 		} // End If Statement
402 402
 
403 403
 		// Save the post meta data fields
404
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
405
-			foreach ( $this->meta_fields as $meta_key ) {
406
-				$this->save_post_meta( $meta_key, $post_id );
404
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
405
+			foreach ($this->meta_fields as $meta_key) {
406
+				$this->save_post_meta($meta_key, $post_id);
407 407
 			} // End For Loop
408 408
 		} // End If Statement
409 409
 
@@ -420,18 +420,18 @@  discard block
 block discarded – undo
420 420
 	 * @param int $post_id (default: 0)
421 421
 	 * @return int new meta id | bool meta value 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
 		// Get the posted data and sanitize it for use as an HTML class.
427
-		if ( 'course_video_embed' == $post_key) {
428
-			$new_meta_value = esc_html( $_POST[$post_key] );
427
+		if ('course_video_embed' == $post_key) {
428
+			$new_meta_value = esc_html($_POST[$post_key]);
429 429
 		} else {
430
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
430
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
431 431
 		} // End If Statement
432 432
 
433 433
         // update field with the new value
434
-        return update_post_meta( $post_id, $meta_key, $new_meta_value );
434
+        return update_post_meta($post_id, $meta_key, $new_meta_value);
435 435
 
436 436
 	} // End save_post_meta()
437 437
 
@@ -441,31 +441,31 @@  discard block
 block discarded – undo
441 441
 	 * @access public
442 442
 	 * @return void
443 443
 	 */
444
-	public function course_lessons_meta_box_content () {
444
+	public function course_lessons_meta_box_content() {
445 445
 
446 446
 		global $post;
447 447
 
448 448
 		// Setup Lesson Query
449 449
 		$posts_array = array();
450
-		if ( 0 < $post->ID ) {
450
+		if (0 < $post->ID) {
451 451
 
452
-			$posts_array = $this->course_lessons( $post->ID, 'any' );
452
+			$posts_array = $this->course_lessons($post->ID, 'any');
453 453
 
454 454
 		} // End If Statement
455 455
 
456 456
 		$html = '';
457
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="'
458
-                 . esc_attr( 'woo_' . $this->token . '_noonce' )
459
-                 . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
457
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'
458
+                 . esc_attr('woo_'.$this->token.'_noonce')
459
+                 . '" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
460 460
 
461
-		if ( count( $posts_array ) > 0 ) {
461
+		if (count($posts_array) > 0) {
462 462
 
463
-			foreach ($posts_array as $post_item){
463
+			foreach ($posts_array as $post_item) {
464 464
 
465 465
 				$html .= '<p>'."\n";
466 466
 
467 467
 					$html .= $post_item->post_title."\n";
468
-					$html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>';
468
+					$html .= '<a href="'.esc_url(get_edit_post_link($post_item->ID)).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $post_item->post_title)).'" class="edit-lesson-action">'.__('Edit this lesson', 'woothemes-sensei').'</a>';
469 469
 
470 470
 				$html .= '</p>'."\n";
471 471
 
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 
474 474
 		} else {
475 475
 			$course_id = '';
476
-			if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; }
477
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n";
476
+			if (0 < $post->ID) { $course_id = '&course_id='.$post->ID; }
477
+			$html .= '<p>'.esc_html(__('No lessons exist yet for this course.', 'woothemes-sensei'))."\n";
478 478
 
479
-				$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id )
480
-                         . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">'
481
-                         . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n";
479
+				$html .= '<a href="'.admin_url('post-new.php?post_type=lesson'.$course_id)
480
+                         . '" title="'.esc_attr(__('Add a Lesson', 'woothemes-sensei')).'">'
481
+                         . __('Please add some.', 'woothemes-sensei').'</a>'."\n";
482 482
 
483 483
 			$html .= '</p>'."\n";
484 484
 		} // End If Statement
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
      * @return void
496 496
      */
497 497
 
498
-    public function course_manage_meta_box_content () {
498
+    public function course_manage_meta_box_content() {
499 499
         global $post;
500 500
         
501
-        $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
501
+        $manage_url = esc_url(add_query_arg(array('page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
502 502
 
503
-        $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
503
+        $grading_url = esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
504 504
 
505 505
 
506 506
         echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>";
@@ -518,16 +518,16 @@  discard block
 block discarded – undo
518 518
 	 * @param  array $defaults
519 519
 	 * @return array $new_columns
520 520
 	 */
521
-	public function add_column_headings ( $defaults ) {
521
+	public function add_column_headings($defaults) {
522 522
 		$new_columns['cb'] = '<input type="checkbox" />';
523 523
 		// $new_columns['id'] = __( 'ID' );
524
-		$new_columns['title'] = _x( 'Course Title', 'column name', 'woothemes-sensei' );
525
-		$new_columns['course-prerequisite'] = _x( 'Pre-requisite Course', 'column name', 'woothemes-sensei' );
526
-		if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
527
-			$new_columns['course-woocommerce-product'] = _x( 'WooCommerce Product', 'column name', 'woothemes-sensei' );
524
+		$new_columns['title'] = _x('Course Title', 'column name', 'woothemes-sensei');
525
+		$new_columns['course-prerequisite'] = _x('Pre-requisite Course', 'column name', 'woothemes-sensei');
526
+		if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
527
+			$new_columns['course-woocommerce-product'] = _x('WooCommerce Product', 'column name', 'woothemes-sensei');
528 528
 		} // End If Statement
529
-		$new_columns['course-category'] = _x( 'Category', 'column name', 'woothemes-sensei' );
530
-		if ( isset( $defaults['date'] ) ) {
529
+		$new_columns['course-category'] = _x('Category', 'column name', 'woothemes-sensei');
530
+		if (isset($defaults['date'])) {
531 531
 			$new_columns['date'] = $defaults['date'];
532 532
 		}
533 533
 
@@ -542,45 +542,45 @@  discard block
 block discarded – undo
542 542
 	 * @param  int $id
543 543
 	 * @return void
544 544
 	 */
545
-	public function add_column_data ( $column_name, $id ) {
545
+	public function add_column_data($column_name, $id) {
546 546
 		global $wpdb, $post;
547 547
 
548
-		switch ( $column_name ) {
548
+		switch ($column_name) {
549 549
 			case 'id':
550 550
 				echo $id;
551 551
 			break;
552 552
 
553 553
 			case 'course-prerequisite':
554
-				$course_prerequisite_id = get_post_meta( $id, '_course_prerequisite', true);
555
-				if ( 0 < absint( $course_prerequisite_id ) ) { echo '<a href="' . esc_url( get_edit_post_link( absint( $course_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $course_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $course_prerequisite_id ) ) . '</a>'; }
554
+				$course_prerequisite_id = get_post_meta($id, '_course_prerequisite', true);
555
+				if (0 < absint($course_prerequisite_id)) { echo '<a href="'.esc_url(get_edit_post_link(absint($course_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($course_prerequisite_id)))).'">'.get_the_title(absint($course_prerequisite_id)).'</a>'; }
556 556
 
557 557
 			break;
558 558
 
559 559
 			case 'course-woocommerce-product':
560
-				if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
561
-					$course_woocommerce_product_id = get_post_meta( $id, '_course_woocommerce_product', true);
562
-					if ( 0 < absint( $course_woocommerce_product_id ) ) {
563
-						if ( 'product_variation' == get_post_type( $course_woocommerce_product_id ) ) {
564
-							$product_object = get_product( $course_woocommerce_product_id );
565
-							if( sensei_check_woocommerce_version( '2.1' ) ) {
566
-								$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
560
+				if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
561
+					$course_woocommerce_product_id = get_post_meta($id, '_course_woocommerce_product', true);
562
+					if (0 < absint($course_woocommerce_product_id)) {
563
+						if ('product_variation' == get_post_type($course_woocommerce_product_id)) {
564
+							$product_object = get_product($course_woocommerce_product_id);
565
+							if (sensei_check_woocommerce_version('2.1')) {
566
+								$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
567 567
 							} else {
568
-								$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
568
+								$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
569 569
 							}
570 570
 							$course_woocommerce_product_id = $product_object->parent->post->ID;
571
-							$product_name = $product_object->parent->post->post_title . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . ucwords( $formatted_variation );
571
+							$product_name = $product_object->parent->post->post_title.'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.ucwords($formatted_variation);
572 572
 						} else {
573
-							$product_name = get_the_title( absint( $course_woocommerce_product_id ) );
573
+							$product_name = get_the_title(absint($course_woocommerce_product_id));
574 574
 						} // End If Statement
575
-						echo '<a href="' . esc_url( get_edit_post_link( absint( $course_woocommerce_product_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $product_name ) ) . '">' . $product_name . '</a>';
575
+						echo '<a href="'.esc_url(get_edit_post_link(absint($course_woocommerce_product_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $product_name)).'">'.$product_name.'</a>';
576 576
 					} // End If Statement
577 577
 				} // End If Statement
578 578
 			break;
579 579
 
580 580
 			case 'course-category':
581
-				$output = get_the_term_list( $id, 'course-category', '', ', ', '' );
582
-				if ( '' == $output ) {
583
-					$output = __( 'None', 'woothemes-sensei' );
581
+				$output = get_the_term_list($id, 'course-category', '', ', ', '');
582
+				if ('' == $output) {
583
+					$output = __('None', 'woothemes-sensei');
584 584
 				} // End If Statement
585 585
 				echo $output;
586 586
 			break;
@@ -600,29 +600,29 @@  discard block
 block discarded – undo
600 600
 	 * @param array $includes (default: array())
601 601
 	 * @return array
602 602
 	 */
603
-	public function course_query( $amount = 0, $type = 'default', $includes = array(), $excludes = array() ) {
604
-		global $my_courses_page ;
603
+	public function course_query($amount = 0, $type = 'default', $includes = array(), $excludes = array()) {
604
+		global $my_courses_page;
605 605
 
606 606
 		$results_array = array();
607 607
 
608
-		if( $my_courses_page ) { add_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
608
+		if ($my_courses_page) { add_action('pre_get_posts', array($this, 'filter_my_courses')); }
609 609
 
610
-		$post_args = $this->get_archive_query_args( $type, $amount, $includes, $excludes );
610
+		$post_args = $this->get_archive_query_args($type, $amount, $includes, $excludes);
611 611
 
612 612
 		// get the posts
613
-		if( empty( $post_args ) ) {
613
+		if (empty($post_args)) {
614 614
 
615 615
 			return $results_array;
616 616
 
617
-		}else{
617
+		} else {
618 618
 
619 619
 			//reset the pagination as this widgets do not need it
620 620
 			$post_args['paged'] = 1;
621
-			$results_array = get_posts( $post_args );
621
+			$results_array = get_posts($post_args);
622 622
 
623 623
 		}
624 624
 
625
-		if( $my_courses_page ) { remove_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
625
+		if ($my_courses_page) { remove_action('pre_get_posts', array($this, 'filter_my_courses')); }
626 626
 
627 627
 		return $results_array;
628 628
 
@@ -638,22 +638,22 @@  discard block
 block discarded – undo
638 638
 	 * @param array $includes (default: array())
639 639
 	 * @return array
640 640
 	 */
641
-	public function get_archive_query_args( $type = '', $amount = 0 , $includes = array(), $excludes = array() ) {
641
+	public function get_archive_query_args($type = '', $amount = 0, $includes = array(), $excludes = array()) {
642 642
 
643 643
 		global $wp_query;
644 644
 
645
-		if ( 0 == $amount && ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && 'usercourses' != $type && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) ) {
646
-			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
645
+		if (0 == $amount && (isset(Sensei()->settings->settings['course_archive_amount']) && 'usercourses' != $type && (0 < absint(Sensei()->settings->settings['course_archive_amount'])))) {
646
+			$amount = absint(Sensei()->settings->settings['course_archive_amount']);
647 647
 		} else {
648
-			if ( 0 == $amount) {
649
-				$amount = $wp_query->get( 'posts_per_page' );
648
+			if (0 == $amount) {
649
+				$amount = $wp_query->get('posts_per_page');
650 650
 			} // End If Statement
651 651
 		} // End If Statement
652 652
 
653
-        $stored_order = get_option( 'sensei_course_order', '' );
653
+        $stored_order = get_option('sensei_course_order', '');
654 654
         $order = 'ASC';
655 655
         $orderby = 'menu_order';
656
-        if( empty( $stored_order ) ){
656
+        if (empty($stored_order)) {
657 657
 
658 658
             $order = 'DESC';
659 659
             $orderby = 'date';
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 		switch ($type) {
664 664
 
665 665
 			case 'usercourses':
666
-				$post_args = array(	'post_type' 		=> 'course',
666
+				$post_args = array('post_type' 		=> 'course',
667 667
 									'orderby'         	=> $orderby,
668 668
     								'order'           	=> $order,
669 669
     								'post_status'      	=> 'publish',
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 				break;
705 705
 
706 706
 			case 'featuredcourses':
707
-                $post_args = array(	'post_type' 		=> 'course',
707
+                $post_args = array('post_type' 		=> 'course',
708 708
                                     'orderby'         	=> $orderby,
709 709
                                     'order'           	=> $order,
710 710
     								'post_status'      	=> 'publish',
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 									);
717 717
 				break;
718 718
 			default:
719
-				$post_args = array(	'post_type' 		=> 'course',
719
+				$post_args = array('post_type' 		=> 'course',
720 720
                                     'orderby'         	=> $orderby,
721 721
                                     'order'           	=> $order,
722 722
     								'post_status'      	=> 'publish',
@@ -728,13 +728,13 @@  discard block
 block discarded – undo
728 728
 		}
729 729
 
730 730
         $post_args['posts_per_page'] = $amount;
731
-        $paged = $wp_query->get( 'paged' );
732
-        $post_args['paged'] = empty( $paged) ? 1 : $paged;
731
+        $paged = $wp_query->get('paged');
732
+        $post_args['paged'] = empty($paged) ? 1 : $paged;
733 733
 
734
-        if( 'newcourses' == $type ){
734
+        if ('newcourses' == $type) {
735 735
 
736
-            $post_args[ 'orderby' ] = 'date';
737
-            $post_args[ 'order' ] = 'DESC';
736
+            $post_args['orderby'] = 'date';
737
+            $post_args['order'] = 'DESC';
738 738
         }
739 739
 
740 740
 		return $post_args;
@@ -756,35 +756,35 @@  discard block
 block discarded – undo
756 756
      *
757 757
 	 * @return string | void
758 758
 	 */
759
-	public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) {
759
+	public function course_image($course_id = 0, $width = '100', $height = '100', $return = false) {
760 760
 
761
-        if( is_a( $course_id, 'WP_Post' ) ){
761
+        if (is_a($course_id, 'WP_Post')) {
762 762
             $course_id = $course_id->ID;
763 763
         }
764 764
 
765 765
 		$html = '';
766 766
 
767 767
 		// Get Width and Height settings
768
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
768
+		if (($width == '100') && ($height == '100')) {
769 769
 
770
-			if ( is_singular( 'course' ) ) {
770
+			if (is_singular('course')) {
771 771
 
772
-				if ( !Sensei()->settings->settings[ 'course_single_image_enable' ] ) {
772
+				if ( ! Sensei()->settings->settings['course_single_image_enable']) {
773 773
 					return '';
774 774
 				} // End If Statement
775 775
 				$image_thumb_size = 'course_single_image';
776
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
776
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
777 777
 				$width = $dimensions['width'];
778 778
 				$height = $dimensions['height'];
779 779
 
780 780
 			} else {
781 781
 
782
-				if ( !Sensei()->settings->settings[ 'course_archive_image_enable' ] ) {
782
+				if ( ! Sensei()->settings->settings['course_archive_image_enable']) {
783 783
 					return '';
784 784
 				} // End If Statement
785 785
 
786 786
 				$image_thumb_size = 'course_archive_image';
787
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
787
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
788 788
 				$width = $dimensions['width'];
789 789
 				$height = $dimensions['height'];
790 790
 
@@ -793,31 +793,31 @@  discard block
 block discarded – undo
793 793
 		} // End If Statement
794 794
 
795 795
 		$img_url = '';
796
-		if ( has_post_thumbnail( $course_id ) ) {
796
+		if (has_post_thumbnail($course_id)) {
797 797
    			// Get Featured Image
798
-   			$img_url = get_the_post_thumbnail( $course_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
798
+   			$img_url = get_the_post_thumbnail($course_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
799 799
  		} else {
800 800
 
801 801
 			// Check for a Lesson Image
802
-			$course_lessons = $this->course_lessons( $course_id );
802
+			$course_lessons = $this->course_lessons($course_id);
803 803
 
804
-			foreach ($course_lessons as $lesson_item){
805
-				if ( has_post_thumbnail( $lesson_item->ID ) ) {
804
+			foreach ($course_lessons as $lesson_item) {
805
+				if (has_post_thumbnail($lesson_item->ID)) {
806 806
 					// Get Featured Image
807
-					$img_url = get_the_post_thumbnail( $lesson_item->ID, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
808
-					if ( '' != $img_url ) {
807
+					$img_url = get_the_post_thumbnail($lesson_item->ID, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
808
+					if ('' != $img_url) {
809 809
 						break;
810 810
 					} // End If Statement
811 811
 
812 812
 				} // End If Statement
813 813
 			} // End For Loop
814 814
 
815
- 			if ( '' == $img_url ) {
815
+ 			if ('' == $img_url) {
816 816
 
817 817
  				// Display Image Placeholder if none
818
-				if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) {
818
+				if (Sensei()->settings->get('placeholder_images_enable')) {
819 819
 
820
-                    $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
820
+                    $img_url = apply_filters('sensei_course_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
821 821
 
822 822
 				} // End If Statement
823 823
 
@@ -825,17 +825,17 @@  discard block
 block discarded – undo
825 825
 
826 826
 		} // End If Statement
827 827
 
828
-		if ( '' != $img_url ) {
828
+		if ('' != $img_url) {
829 829
 
830
-			$html .= '<a href="' . get_permalink( $course_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $course_id ) ) . '">' . $img_url  .'</a>';
830
+			$html .= '<a href="'.get_permalink($course_id).'" title="'.esc_attr(get_post_field('post_title', $course_id)).'">'.$img_url.'</a>';
831 831
 
832 832
 		} // End If Statement
833 833
 
834
-        if( $return ){
834
+        if ($return) {
835 835
 
836 836
             return $html;
837 837
 
838
-        }else{
838
+        } else {
839 839
 
840 840
             echo $html;
841 841
 
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @param string $post_status (default: 'publish')
853 853
 	 * @return int
854 854
 	 */
855
-	public function course_count( $post_status = 'publish' ) {
855
+	public function course_count($post_status = 'publish') {
856 856
 
857
-		$post_args = array(	'post_type'         => 'course',
857
+		$post_args = array('post_type'         => 'course',
858 858
 							'posts_per_page'    => -1,
859 859
 //							'orderby'           => 'menu_order date',
860 860
 //							'order'             => 'ASC',
@@ -865,10 +865,10 @@  discard block
 block discarded – undo
865 865
 
866 866
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
867 867
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
868
-		$courses_query = new WP_Query( apply_filters( 'sensei_course_count', $post_args ) );
868
+		$courses_query = new WP_Query(apply_filters('sensei_course_count', $post_args));
869 869
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
870 870
 
871
-		return count( $courses_query->posts );
871
+		return count($courses_query->posts);
872 872
 	} // End course_count()
873 873
 
874 874
 
@@ -881,42 +881,42 @@  discard block
 block discarded – undo
881 881
 	 * @param string $fields (default: 'all'). WP only allows 3 types, but we will limit it to only 'ids' or 'all'
882 882
 	 * @return array{ type WP_Post }  $posts_array
883 883
 	 */
884
-	public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) {
884
+	public function course_lessons($course_id = 0, $post_status = 'publish', $fields = 'all') {
885 885
 
886
-        if( is_a( $course_id, 'WP_Post' ) ){
886
+        if (is_a($course_id, 'WP_Post')) {
887 887
             $course_id = $course_id->ID;
888 888
         }
889 889
 
890
-		$post_args = array(	'post_type'         => 'lesson',
890
+		$post_args = array('post_type'         => 'lesson',
891 891
 							'posts_per_page'       => -1,
892 892
 							'orderby'           => 'date',
893 893
 							'order'             => 'ASC',
894 894
 							'meta_query'        => array(
895 895
 								array(
896 896
 									'key' => '_lesson_course',
897
-									'value' => intval( $course_id ),
897
+									'value' => intval($course_id),
898 898
 								),
899 899
 							),
900 900
 							'post_status'       => $post_status,
901 901
 							'suppress_filters'  => 0,
902 902
 							);
903
-		$query_results = new WP_Query( $post_args );
903
+		$query_results = new WP_Query($post_args);
904 904
         $lessons = $query_results->posts;
905 905
 
906 906
         // re order the lessons. This could not be done via the OR meta query as there may be lessons
907 907
         // with the course order for a different course and this should not be included. It could also not
908 908
         // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but
909 909
         // that have been added to the course.
910
-        if( count( $lessons) > 1  ){
910
+        if (count($lessons) > 1) {
911 911
 
912
-            foreach( $lessons as $lesson ){
912
+            foreach ($lessons as $lesson) {
913 913
 
914
-                $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) );
914
+                $order = intval(get_post_meta($lesson->ID, '_order_'.$course_id, true));
915 915
                 // for lessons with no order set it to be 10000 so that it show up at the end
916 916
                 $lesson->course_order = $order ? $order : 100000;
917 917
             }
918 918
 
919
-            uasort( $lessons, array( $this, '_short_course_lessons_callback' )   );
919
+            uasort($lessons, array($this, '_short_course_lessons_callback'));
920 920
         }
921 921
 
922 922
         /**
@@ -927,12 +927,12 @@  discard block
 block discarded – undo
927 927
          * @param array $lessons
928 928
          * @param int $course_id
929 929
          */
930
-        $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id  );
930
+        $lessons = apply_filters('sensei_course_get_lessons', $lessons, $course_id);
931 931
 
932 932
         //return the requested fields
933 933
         // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson
934 934
         // objects
935
-        if( 'ids' == $fields ) {
935
+        if ('ids' == $fields) {
936 936
             $lesson_objects = $lessons;
937 937
             $lessons = array();
938 938
 
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
      * @param array $lesson_2
955 955
      * @return int
956 956
      */
957
-    protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){
957
+    protected function _short_course_lessons_callback($lesson_1, $lesson_2) {
958 958
 
959
-        if ( $lesson_1->course_order == $lesson_2->course_order ) {
959
+        if ($lesson_1->course_order == $lesson_2->course_order) {
960 960
             return 0;
961 961
         }
962 962
 
@@ -970,21 +970,21 @@  discard block
 block discarded – undo
970 970
 	 * @param  boolean $boolean_check True if a simple yes/no is required
971 971
 	 * @return array              Array of quiz post objects
972 972
 	 */
973
-	public function course_quizzes( $course_id = 0, $boolean_check = false ) {
973
+	public function course_quizzes($course_id = 0, $boolean_check = false) {
974 974
 
975 975
 
976 976
 		$course_quizzes = array();
977 977
 
978
-		if( $course_id ) {
979
-			$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
978
+		if ($course_id) {
979
+			$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
980 980
 
981
-			foreach( $lesson_ids as $lesson_id ) {
982
-				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
983
-				if ( $has_questions && $boolean_check ) {
981
+			foreach ($lesson_ids as $lesson_id) {
982
+				$has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
983
+				if ($has_questions && $boolean_check) {
984 984
 					return true;
985 985
 				}
986
-				elseif ( $has_questions ) {
987
-					$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
986
+				elseif ($has_questions) {
987
+					$quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
988 988
 //					$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
989 989
 //					if( count( $questions ) > 0 ) {
990 990
 						$course_quizzes[] = $quiz_id;
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 				}
993 993
 			}
994 994
 		}
995
-		if ( $boolean_check && empty($course_quizzes) ) {
995
+		if ($boolean_check && empty($course_quizzes)) {
996 996
 			$course_quizzes = false;
997 997
 		}
998 998
 		return $course_quizzes;
@@ -1007,9 +1007,9 @@  discard block
 block discarded – undo
1007 1007
 	 * @param  string $post_status (default: 'publish')
1008 1008
 	 * @return array
1009 1009
 	 */
1010
-	public function course_lessons_completed( $course_id = 0, $post_status = 'publish' ) {
1010
+	public function course_lessons_completed($course_id = 0, $post_status = 'publish') {
1011 1011
 
1012
-		return $this->course_lessons( $course_id, $post_status );
1012
+		return $this->course_lessons($course_id, $post_status);
1013 1013
 
1014 1014
 	} // End course_lessons_completed()
1015 1015
 
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 	 * @param  int $course_id (default: 0)
1023 1023
 	 * @return int
1024 1024
 	 */
1025
-	public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) {
1025
+	public function course_author_lesson_count($author_id = 0, $course_id = 0) {
1026 1026
 
1027
-        $lesson_args = array(	'post_type' 		=> 'lesson',
1027
+        $lesson_args = array('post_type' 		=> 'lesson',
1028 1028
 								'posts_per_page' 		=> -1,
1029 1029
 		    					'author'         	=> $author_id,
1030 1030
 		    					'meta_key'        	=> '_lesson_course',
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
     	    					'suppress_filters' 	=> 0,
1034 1034
 								'fields'            => 'ids', // less data to retrieve
1035 1035
 		    				);
1036
-		$lessons_array = get_posts( $lesson_args );
1037
-		$count = count( $lessons_array );
1036
+		$lessons_array = get_posts($lesson_args);
1037
+		$count = count($lessons_array);
1038 1038
 		return $count;
1039 1039
 
1040 1040
 	} // End course_author_lesson_count()
@@ -1046,9 +1046,9 @@  discard block
 block discarded – undo
1046 1046
 	 * @param  int $course_id (default: 0)
1047 1047
 	 * @return int
1048 1048
 	 */
1049
-	public function course_lesson_count( $course_id = 0 ) {
1049
+	public function course_lesson_count($course_id = 0) {
1050 1050
 
1051
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1051
+		$lesson_args = array('post_type' 		=> 'lesson',
1052 1052
 								'posts_per_page' 		=> -1,
1053 1053
 		    					'meta_key'        	=> '_lesson_course',
1054 1054
     							'meta_value'      	=> $course_id,
@@ -1056,9 +1056,9 @@  discard block
 block discarded – undo
1056 1056
     	    					'suppress_filters' 	=> 0,
1057 1057
 								'fields'            => 'ids', // less data to retrieve
1058 1058
 		    				);
1059
-		$lessons_array = get_posts( $lesson_args );
1059
+		$lessons_array = get_posts($lesson_args);
1060 1060
 
1061
-        $count = count( $lessons_array );
1061
+        $count = count($lessons_array);
1062 1062
 
1063 1063
         return $count;
1064 1064
 
@@ -1071,9 +1071,9 @@  discard block
 block discarded – undo
1071 1071
 	 * @param  int $course_id (default: 0)
1072 1072
 	 * @return int
1073 1073
 	 */
1074
-	public function course_lesson_preview_count( $course_id = 0 ) {
1074
+	public function course_lesson_preview_count($course_id = 0) {
1075 1075
 
1076
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1076
+		$lesson_args = array('post_type' 		=> 'lesson',
1077 1077
 								'posts_per_page' 		=> -1,
1078 1078
     	    					'post_status'      	=> 'publish',
1079 1079
     	    					'suppress_filters' 	=> 0,
@@ -1089,9 +1089,9 @@  discard block
 block discarded – undo
1089 1089
 								),
1090 1090
 								'fields'            => 'ids', // less data to retrieve
1091 1091
 		    				);
1092
-		$lessons_array = get_posts( $lesson_args );
1092
+		$lessons_array = get_posts($lesson_args);
1093 1093
 
1094
-		$count = count( $lessons_array );
1094
+		$count = count($lessons_array);
1095 1095
 
1096 1096
         return $count;
1097 1097
 
@@ -1104,12 +1104,12 @@  discard block
 block discarded – undo
1104 1104
 	 * @param  int $product_id (default: 0)
1105 1105
 	 * @return array
1106 1106
 	 */
1107
-	public function get_product_courses( $product_id = 0 ) {
1107
+	public function get_product_courses($product_id = 0) {
1108 1108
 
1109 1109
 		$posts_array = array();
1110 1110
 		// Check for WooCommerce
1111
-		if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < $product_id ) {
1112
-			$post_args = array(	'post_type' 		=> 'course',
1111
+		if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && 0 < $product_id) {
1112
+			$post_args = array('post_type' 		=> 'course',
1113 1113
 								'posts_per_page' 		=> -1,
1114 1114
 								'meta_key'        	=> '_course_woocommerce_product',
1115 1115
 	    						'meta_value'      	=> $product_id,
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 								'orderby' 			=> 'menu_order date',
1119 1119
 								'order' 			=> 'ASC',
1120 1120
 								);
1121
-			$posts_array = get_posts( $post_args );
1121
+			$posts_array = get_posts($post_args);
1122 1122
 		} // End If Statement
1123 1123
 		return $posts_array;
1124 1124
 
@@ -1138,17 +1138,17 @@  discard block
 block discarded – undo
1138 1138
 	 * @param  WP_Query $query
1139 1139
 	 * @return void
1140 1140
 	 */
1141
-	public function filter_my_courses( $query ) {
1141
+	public function filter_my_courses($query) {
1142 1142
 		global  $my_courses_section;
1143 1143
 
1144
-		if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1145
-			$amount = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1146
-			$query->set( 'posts_per_page', $amount );
1144
+		if (isset(Sensei()->settings->settings['my_course_amount']) && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1145
+			$amount = absint(Sensei()->settings->settings['my_course_amount']);
1146
+			$query->set('posts_per_page', $amount);
1147 1147
 		}
1148 1148
 
1149
-		if( isset( $_GET[ $my_courses_section . '_page' ] ) && 0 < intval( $_GET[ $my_courses_section . '_page' ] ) ) {
1150
-			$page = intval( $_GET[ $my_courses_section . '_page' ] );
1151
-			$query->set( 'paged', $page );
1149
+		if (isset($_GET[$my_courses_section.'_page']) && 0 < intval($_GET[$my_courses_section.'_page'])) {
1150
+			$page = intval($_GET[$my_courses_section.'_page']);
1151
+			$query->set('paged', $page);
1152 1152
 		}
1153 1153
 	}
1154 1154
 
@@ -1162,48 +1162,48 @@  discard block
 block discarded – undo
1162 1162
 	 * @param  boolean $manage Whether the user has permission to manage the courses
1163 1163
 	 * @return string          HTML displayng course data
1164 1164
 	 */
1165
-	public function load_user_courses_content( $user = false ) {
1165
+	public function load_user_courses_content($user = false) {
1166 1166
 		global $course, $my_courses_page, $my_courses_section;
1167 1167
 
1168
-        if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] )
1169
-            || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) {
1168
+        if ( ! isset(Sensei()->settings->settings['learner_profile_show_courses'])
1169
+            || ! Sensei()->settings->settings['learner_profile_show_courses']) {
1170 1170
 
1171 1171
             // do not show the content if the settings doesn't allow for it
1172 1172
             return;
1173 1173
 
1174 1174
         }
1175 1175
 
1176
-        $manage = ( $user->ID == get_current_user_id() ) ? true : false;
1176
+        $manage = ($user->ID == get_current_user_id()) ? true : false;
1177 1177
 
1178
-        do_action( 'sensei_before_learner_course_content', $user );
1178
+        do_action('sensei_before_learner_course_content', $user);
1179 1179
 
1180 1180
 		// Build Output HTML
1181 1181
 		$complete_html = $active_html = '';
1182 1182
 
1183
-		if( is_a( $user, 'WP_User' ) ) {
1183
+		if (is_a($user, 'WP_User')) {
1184 1184
 
1185 1185
 			$my_courses_page = true;
1186 1186
 
1187 1187
 			// Allow action to be run before My Courses content has loaded
1188
-			do_action( 'sensei_before_my_courses', $user->ID );
1188
+			do_action('sensei_before_my_courses', $user->ID);
1189 1189
 
1190 1190
 			// Logic for Active and Completed Courses
1191 1191
 			$per_page = 20;
1192
-			if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] )
1193
-                && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1192
+			if (isset(Sensei()->settings->settings['my_course_amount'])
1193
+                && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1194 1194
 
1195
-				$per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1195
+				$per_page = absint(Sensei()->settings->settings['my_course_amount']);
1196 1196
 
1197 1197
 			}
1198 1198
 
1199
-			$course_statuses = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user->ID, 'type' => 'sensei_course_status' ), true );
1199
+			$course_statuses = WooThemes_Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true);
1200 1200
 			// User may only be on 1 Course
1201
-			if ( !is_array($course_statuses) ) {
1202
-				$course_statuses = array( $course_statuses );
1201
+			if ( ! is_array($course_statuses)) {
1202
+				$course_statuses = array($course_statuses);
1203 1203
 			}
1204 1204
 			$completed_ids = $active_ids = array();
1205
-			foreach( $course_statuses as $course_status ) {
1206
-				if ( WooThemes_Sensei_Utils::user_completed_course( $course_status, $user->ID ) ) {
1205
+			foreach ($course_statuses as $course_status) {
1206
+				if (WooThemes_Sensei_Utils::user_completed_course($course_status, $user->ID)) {
1207 1207
 					$completed_ids[] = $course_status->comment_post_ID;
1208 1208
 				} else {
1209 1209
 					$active_ids[] = $course_status->comment_post_ID;
@@ -1213,41 +1213,41 @@  discard block
 block discarded – undo
1213 1213
 			$active_count = $completed_count = 0;
1214 1214
 
1215 1215
 			$active_courses = array();
1216
-			if ( 0 < intval( count( $active_ids ) ) ) {
1216
+			if (0 < intval(count($active_ids))) {
1217 1217
 				$my_courses_section = 'active';
1218
-				$active_courses = Sensei()->course->course_query( $per_page, 'usercourses', $active_ids );
1219
-				$active_count = count( $active_ids );
1218
+				$active_courses = Sensei()->course->course_query($per_page, 'usercourses', $active_ids);
1219
+				$active_count = count($active_ids);
1220 1220
 			} // End If Statement
1221 1221
 
1222 1222
 			$completed_courses = array();
1223
-			if ( 0 < intval( count( $completed_ids ) ) ) {
1223
+			if (0 < intval(count($completed_ids))) {
1224 1224
 				$my_courses_section = 'completed';
1225
-				$completed_courses = Sensei()->course->course_query( $per_page, 'usercourses', $completed_ids );
1226
-				$completed_count = count( $completed_ids );
1225
+				$completed_courses = Sensei()->course->course_query($per_page, 'usercourses', $completed_ids);
1226
+				$completed_count = count($completed_ids);
1227 1227
 			} // End If Statement
1228 1228
 
1229
-			foreach ( $active_courses as $course_item ) {
1229
+			foreach ($active_courses as $course_item) {
1230 1230
 
1231
-				$course_lessons =  Sensei()->course->course_lessons( $course_item->ID );
1231
+				$course_lessons = Sensei()->course->course_lessons($course_item->ID);
1232 1232
 				$lessons_completed = 0;
1233
-				foreach ( $course_lessons as $lesson ) {
1234
-					if ( WooThemes_Sensei_Utils::user_completed_lesson( $lesson->ID, $user->ID ) ) {
1233
+				foreach ($course_lessons as $lesson) {
1234
+					if (WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) {
1235 1235
 						++$lessons_completed;
1236 1236
 					}
1237 1237
 				}
1238 1238
 
1239 1239
 			    // Get Course Categories
1240
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1240
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1241 1241
 
1242
-                $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">';
1242
+                $active_html .= '<article class="'.esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))).'">';
1243 1243
 
1244 1244
                 // Image
1245
-                $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true );
1245
+                $active_html .= Sensei()->course->course_image(absint($course_item->ID), '100', '100', true);
1246 1246
 
1247 1247
                 // Title
1248 1248
                 $active_html .= '<header>';
1249 1249
 
1250
-                $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1250
+                $active_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1251 1251
 
1252 1252
                 $active_html .= '</header>';
1253 1253
 
@@ -1256,82 +1256,82 @@  discard block
 block discarded – undo
1256 1256
                 $active_html .= '<p class="sensei-course-meta">';
1257 1257
 
1258 1258
                 // Author
1259
-                $user_info = get_userdata( absint( $course_item->post_author ) );
1260
-                if ( isset( Sensei()->settings->settings[ 'course_author' ] )
1261
-                    && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1259
+                $user_info = get_userdata(absint($course_item->post_author));
1260
+                if (isset(Sensei()->settings->settings['course_author'])
1261
+                    && (Sensei()->settings->settings['course_author'])) {
1262 1262
 
1263 1263
                     $active_html .= '<span class="course-author">'
1264
-                        . __( 'by ', 'woothemes-sensei' )
1265
-                        . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) )
1266
-                        . '" title="' . esc_attr( $user_info->display_name ) . '">'
1267
-                        . esc_html( $user_info->display_name )
1264
+                        . __('by ', 'woothemes-sensei')
1265
+                        . '<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author)))
1266
+                        . '" title="'.esc_attr($user_info->display_name).'">'
1267
+                        . esc_html($user_info->display_name)
1268 1268
                         . '</a></span>';
1269 1269
 
1270 1270
                 } // End If Statement
1271 1271
 
1272 1272
                 // Lesson count for this author
1273
-                $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) );
1273
+                $lesson_count = Sensei()->course->course_lesson_count(absint($course_item->ID));
1274 1274
                 // Handle Division by Zero
1275
-                if ( 0 == $lesson_count ) {
1275
+                if (0 == $lesson_count) {
1276 1276
 
1277 1277
                     $lesson_count = 1;
1278 1278
 
1279 1279
                 } // End If Statement
1280
-                $active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ) . '</span>';
1280
+                $active_html .= '<span class="course-lesson-count">'.$lesson_count.'&nbsp;'.__('Lessons', 'woothemes-sensei').'</span>';
1281 1281
                 // Course Categories
1282
-                if ( '' != $category_output ) {
1282
+                if ('' != $category_output) {
1283 1283
 
1284
-                    $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1284
+                    $active_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1285 1285
 
1286 1286
                 } // End If Statement
1287
-                $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count  ) . '</span>';
1287
+                $active_html .= '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count).'</span>';
1288 1288
 
1289 1289
                 $active_html .= '</p>';
1290 1290
 
1291
-                $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1291
+                $active_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1292 1292
 
1293 1293
 
1294 1294
 
1295
-                $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) );
1295
+                $progress_percentage = abs(round((doubleval($lessons_completed) * 100) / ($lesson_count), 0));
1296 1296
 
1297
-                $active_html .= $this->get_progress_meter( $progress_percentage );
1297
+                $active_html .= $this->get_progress_meter($progress_percentage);
1298 1298
 
1299 1299
                 $active_html .= '</section>';
1300 1300
 
1301
-                if( is_user_logged_in() ) {
1301
+                if (is_user_logged_in()) {
1302 1302
 
1303 1303
                     $active_html .= '<section class="entry-actions">';
1304 1304
 
1305
-                    $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">';
1305
+                    $active_html .= '<form method="POST" action="'.esc_url(remove_query_arg(array('active_page', 'completed_page'))).'">';
1306 1306
 
1307
-                    $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />';
1307
+                    $active_html .= '<input type="hidden" name="'.esc_attr('woothemes_sensei_complete_course_noonce').'" id="'.esc_attr('woothemes_sensei_complete_course_noonce').'" value="'.esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')).'" />';
1308 1308
 
1309
-                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />';
1309
+                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="'.esc_attr(absint($course_item->ID)).'" />';
1310 1310
 
1311
-                    if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) {
1311
+                    if (0 < absint(count($course_lessons)) && Sensei()->settings->settings['course_completion'] == 'complete') {
1312 1312
 
1313 1313
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="'
1314
-                            .  __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>';
1314
+                            .  __('Mark as Complete', 'woothemes-sensei').'"/> </span>';
1315 1315
 
1316 1316
                     } // End If Statement
1317 1317
 
1318 1318
                     $course_purchased = false;
1319
-                    if ( Sensei_WC::is_woocommerce_active() ) {
1319
+                    if (Sensei_WC::is_woocommerce_active()) {
1320 1320
 
1321 1321
                         // Get the product ID
1322
-                        $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true );
1323
-                        if ( 0 < $wc_post_id ) {
1322
+                        $wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true);
1323
+                        if (0 < $wc_post_id) {
1324 1324
 
1325
-                            $course_purchased = Sensei_WC::has_customer_bought_product(  $user->ID, $wc_post_id );
1325
+                            $course_purchased = Sensei_WC::has_customer_bought_product($user->ID, $wc_post_id);
1326 1326
 
1327 1327
                         } // End If Statement
1328 1328
 
1329 1329
                     } // End If Statement
1330 1330
 
1331
-                    if ( false == $course_purchased ) {
1331
+                    if (false == $course_purchased) {
1332 1332
 
1333 1333
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="'
1334
-                            .  __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>';
1334
+                            .  __('Delete Course', 'woothemes-sensei').'"/></span>';
1335 1335
 
1336 1336
                     } // End If Statement
1337 1337
 
@@ -1344,54 +1344,54 @@  discard block
 block discarded – undo
1344 1344
 			}
1345 1345
 
1346 1346
 			// Active pagination
1347
-			if( $active_count > $per_page ) {
1347
+			if ($active_count > $per_page) {
1348 1348
 
1349 1349
 				$current_page = 1;
1350
-				if( isset( $_GET['active_page'] ) && 0 < intval( $_GET['active_page'] ) ) {
1350
+				if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
1351 1351
 					$current_page = $_GET['active_page'];
1352 1352
 				}
1353 1353
 
1354 1354
 				$active_html .= '<nav class="pagination woo-pagination">';
1355
-				$total_pages = ceil( $active_count / $per_page );
1355
+				$total_pages = ceil($active_count / $per_page);
1356 1356
 
1357
-				if( $current_page > 1 ) {
1358
-					$prev_link = add_query_arg( 'active_page', $current_page - 1 );
1359
-					$active_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1357
+				if ($current_page > 1) {
1358
+					$prev_link = add_query_arg('active_page', $current_page - 1);
1359
+					$active_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1360 1360
 				}
1361 1361
 
1362
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1363
-					$link = add_query_arg( 'active_page', $i );
1362
+				for ($i = 1; $i <= $total_pages; $i++) {
1363
+					$link = add_query_arg('active_page', $i);
1364 1364
 
1365
-					if( $i == $current_page ) {
1366
-						$active_html .= '<span class="page-numbers current">' . $i . '</span> ';
1365
+					if ($i == $current_page) {
1366
+						$active_html .= '<span class="page-numbers current">'.$i.'</span> ';
1367 1367
 					} else {
1368
-						$active_html .= '<a class="page-numbers" href="' . esc_url( $link ). '">' . $i . '</a> ';
1368
+						$active_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1369 1369
 					}
1370 1370
 				}
1371 1371
 
1372
-				if( $current_page < $total_pages ) {
1373
-					$next_link = add_query_arg( 'active_page', $current_page + 1 );
1374
-					$active_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1372
+				if ($current_page < $total_pages) {
1373
+					$next_link = add_query_arg('active_page', $current_page + 1);
1374
+					$active_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1375 1375
 				}
1376 1376
 
1377 1377
 				$active_html .= '</nav>';
1378 1378
 			}
1379 1379
 
1380
-			foreach ( $completed_courses as $course_item ) {
1380
+			foreach ($completed_courses as $course_item) {
1381 1381
 				$course = $course_item;
1382 1382
 
1383 1383
 			    // Get Course Categories
1384
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1384
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1385 1385
 
1386
-		    	$complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">';
1386
+		    	$complete_html .= '<article class="'.join(' ', get_post_class(array('course', 'post'), $course_item->ID)).'">';
1387 1387
 
1388 1388
 		    	    // Image
1389
-		    		$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true );
1389
+		    		$complete_html .= Sensei()->course->course_image(absint($course_item->ID), 100, 100, true);
1390 1390
 
1391 1391
 		    		// Title
1392 1392
 		    		$complete_html .= '<header>';
1393 1393
 
1394
-		    		    $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1394
+		    		    $complete_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1395 1395
 
1396 1396
 		    		$complete_html .= '</header>';
1397 1397
 
@@ -1400,46 +1400,46 @@  discard block
 block discarded – undo
1400 1400
 		    			$complete_html .= '<p class="sensei-course-meta">';
1401 1401
 
1402 1402
 		    		    	// Author
1403
-		    		    	$user_info = get_userdata( absint( $course_item->post_author ) );
1404
-		    		    	if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1405
-		    		    		$complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
1403
+		    		    	$user_info = get_userdata(absint($course_item->post_author));
1404
+		    		    	if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {
1405
+		    		    		$complete_html .= '<span class="course-author">'.__('by ', 'woothemes-sensei').'<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
1406 1406
 		    		    	} // End If Statement
1407 1407
 
1408 1408
 		    		    	// Lesson count for this author
1409 1409
 		    		    	$complete_html .= '<span class="course-lesson-count">'
1410
-                                . Sensei()->course->course_lesson_count( absint( $course_item->ID ) )
1411
-                                . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' )
1410
+                                . Sensei()->course->course_lesson_count(absint($course_item->ID))
1411
+                                . '&nbsp;'.__('Lessons', 'woothemes-sensei')
1412 1412
                                 . '</span>';
1413 1413
 
1414 1414
 		    		    	// Course Categories
1415
-		    		    	if ( '' != $category_output ) {
1415
+		    		    	if ('' != $category_output) {
1416 1416
 
1417
-		    		    		$complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1417
+		    		    		$complete_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1418 1418
 
1419 1419
 		    		    	} // End If Statement
1420 1420
 
1421 1421
 						$complete_html .= '</p>';
1422 1422
 
1423
-						$complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1423
+						$complete_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1424 1424
 
1425
-                        $complete_html .= $this->get_progress_meter( 100 );
1425
+                        $complete_html .= $this->get_progress_meter(100);
1426 1426
 
1427
-						if( $manage ) {
1428
-							$has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true );
1427
+						if ($manage) {
1428
+							$has_quizzes = Sensei()->course->course_quizzes($course_item->ID, true);
1429 1429
 							// Output only if there is content to display
1430
-							if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) {
1430
+							if (has_filter('sensei_results_links') || $has_quizzes) {
1431 1431
 
1432 1432
 
1433 1433
 								$complete_html .= '<p class="sensei-results-links">';
1434 1434
 								$results_link = '';
1435
-								if( $has_quizzes ) {
1435
+								if ($has_quizzes) {
1436 1436
 
1437 1437
 									$results_link = '<a class="button view-results" href="'
1438
-                                        . Sensei()->course_results->get_permalink( $course_item->ID )
1439
-                                        . '">' . __( 'View results', 'woothemes-sensei' )
1438
+                                        . Sensei()->course_results->get_permalink($course_item->ID)
1439
+                                        . '">'.__('View results', 'woothemes-sensei')
1440 1440
                                         . '</a>';
1441 1441
 								}
1442
-								$complete_html .= apply_filters( 'sensei_results_links', $results_link );
1442
+								$complete_html .= apply_filters('sensei_results_links', $results_link);
1443 1443
 								$complete_html .= '</p>';
1444 1444
 
1445 1445
 							}
@@ -1451,35 +1451,35 @@  discard block
 block discarded – undo
1451 1451
 			}
1452 1452
 
1453 1453
 			// Active pagination
1454
-			if( $completed_count > $per_page ) {
1454
+			if ($completed_count > $per_page) {
1455 1455
 
1456 1456
 				$current_page = 1;
1457
-				if( isset( $_GET['completed_page'] ) && 0 < intval( $_GET['completed_page'] ) ) {
1457
+				if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) {
1458 1458
 					$current_page = $_GET['completed_page'];
1459 1459
 				}
1460 1460
 
1461 1461
 				$complete_html .= '<nav class="pagination woo-pagination">';
1462
-				$total_pages = ceil( $completed_count / $per_page );
1462
+				$total_pages = ceil($completed_count / $per_page);
1463 1463
 
1464 1464
 
1465
-				if( $current_page > 1 ) {
1466
-					$prev_link = add_query_arg( 'completed_page', $current_page - 1 );
1467
-					$complete_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1465
+				if ($current_page > 1) {
1466
+					$prev_link = add_query_arg('completed_page', $current_page - 1);
1467
+					$complete_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1468 1468
 				}
1469 1469
 
1470
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1471
-					$link = add_query_arg( 'completed_page', $i );
1470
+				for ($i = 1; $i <= $total_pages; $i++) {
1471
+					$link = add_query_arg('completed_page', $i);
1472 1472
 
1473
-					if( $i == $current_page ) {
1474
-						$complete_html .= '<span class="page-numbers current">' . $i . '</span> ';
1473
+					if ($i == $current_page) {
1474
+						$complete_html .= '<span class="page-numbers current">'.$i.'</span> ';
1475 1475
 					} else {
1476
-						$complete_html .= '<a class="page-numbers" href="' . esc_url( $link ) . '">' . $i . '</a> ';
1476
+						$complete_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1477 1477
 					}
1478 1478
 				}
1479 1479
 
1480
-				if( $current_page < $total_pages ) {
1481
-					$next_link = add_query_arg( 'completed_page', $current_page + 1 );
1482
-					$complete_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1480
+				if ($current_page < $total_pages) {
1481
+					$next_link = add_query_arg('completed_page', $current_page + 1);
1482
+					$complete_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1483 1483
 				}
1484 1484
 
1485 1485
 				$complete_html .= '</nav>';
@@ -1487,26 +1487,26 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 		} // End If Statement
1489 1489
 
1490
-		if( $manage ) {
1491
-			$no_active_message = __( 'You have no active courses.', 'woothemes-sensei' );
1492
-			$no_complete_message = __( 'You have not completed any courses yet.', 'woothemes-sensei' );
1490
+		if ($manage) {
1491
+			$no_active_message = __('You have no active courses.', 'woothemes-sensei');
1492
+			$no_complete_message = __('You have not completed any courses yet.', 'woothemes-sensei');
1493 1493
 		} else {
1494
-			$no_active_message =  __( 'This learner has no active courses.', 'woothemes-sensei' );
1495
-			$no_complete_message =  __( 'This learner has not completed any courses yet.', 'woothemes-sensei' );
1494
+			$no_active_message = __('This learner has no active courses.', 'woothemes-sensei');
1495
+			$no_complete_message = __('This learner has not completed any courses yet.', 'woothemes-sensei');
1496 1496
 		}
1497 1497
 
1498 1498
 		ob_start();
1499 1499
 		?>
1500 1500
 
1501
-		<?php do_action( 'sensei_before_user_courses' ); ?>
1501
+		<?php do_action('sensei_before_user_courses'); ?>
1502 1502
 
1503 1503
 		<?php
1504
-		if( $manage && ( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) ) {
1504
+		if ($manage && ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable'])) {
1505 1505
 			?>
1506 1506
 			<p class="my-messages-link-container">
1507
-                <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>"
1508
-                   title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>">
1509
-                    <?php _e( 'My Messages', 'woothemes-sensei' ); ?>
1507
+                <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>"
1508
+                   title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>">
1509
+                    <?php _e('My Messages', 'woothemes-sensei'); ?>
1510 1510
                 </a>
1511 1511
             </p>
1512 1512
 			<?php
@@ -1515,11 +1515,11 @@  discard block
 block discarded – undo
1515 1515
 		<div id="my-courses">
1516 1516
 
1517 1517
 		    <ul>
1518
-		    	<li><a href="#active-courses"><?php  _e( 'Active Courses', 'woothemes-sensei' ); ?></a></li>
1519
-		    	<li><a href="#completed-courses"><?php  _e( 'Completed Courses', 'woothemes-sensei' ); ?></a></li>
1518
+		    	<li><a href="#active-courses"><?php  _e('Active Courses', 'woothemes-sensei'); ?></a></li>
1519
+		    	<li><a href="#completed-courses"><?php  _e('Completed Courses', 'woothemes-sensei'); ?></a></li>
1520 1520
 		    </ul>
1521 1521
 
1522
-		    <?php do_action( 'sensei_before_active_user_courses' ); ?>
1522
+		    <?php do_action('sensei_before_active_user_courses'); ?>
1523 1523
 
1524 1524
 		    <?php
1525 1525
             $course_page_url = Sensei_Course::get_courses_page_url();
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 
1528 1528
 		    <div id="active-courses">
1529 1529
 
1530
-		    	<?php if ( '' != $active_html ) {
1530
+		    	<?php if ('' != $active_html) {
1531 1531
 
1532 1532
 		    		echo $active_html;
1533 1533
 
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 
1540 1540
                         <a href="<?php echo $course_page_url; ?>">
1541 1541
 
1542
-                            <?php  _e( 'Start a Course!', 'woothemes-sensei' ); ?>
1542
+                            <?php  _e('Start a Course!', 'woothemes-sensei'); ?>
1543 1543
 
1544 1544
                         </a>
1545 1545
 
@@ -1549,13 +1549,13 @@  discard block
 block discarded – undo
1549 1549
 
1550 1550
 		    </div>
1551 1551
 
1552
-		    <?php do_action( 'sensei_after_active_user_courses' ); ?>
1552
+		    <?php do_action('sensei_after_active_user_courses'); ?>
1553 1553
 
1554
-		    <?php do_action( 'sensei_before_completed_user_courses' ); ?>
1554
+		    <?php do_action('sensei_before_completed_user_courses'); ?>
1555 1555
 
1556 1556
 		    <div id="completed-courses">
1557 1557
 
1558
-		    	<?php if ( '' != $complete_html ) {
1558
+		    	<?php if ('' != $complete_html) {
1559 1559
 
1560 1560
 		    		echo $complete_html;
1561 1561
 
@@ -1571,16 +1571,16 @@  discard block
 block discarded – undo
1571 1571
 
1572 1572
 		    </div>
1573 1573
 
1574
-		    <?php do_action( 'sensei_after_completed_user_courses' ); ?>
1574
+		    <?php do_action('sensei_after_completed_user_courses'); ?>
1575 1575
 
1576 1576
 		</div>
1577 1577
 
1578
-		<?php do_action( 'sensei_after_user_courses' ); ?>
1578
+		<?php do_action('sensei_after_user_courses'); ?>
1579 1579
 
1580 1580
 		<?php
1581 1581
         echo ob_get_clean();
1582 1582
 
1583
-        do_action( 'sensei_after_learner_course_content', $user );
1583
+        do_action('sensei_after_learner_course_content', $user);
1584 1584
 
1585 1585
 	} // end load_user_courses_content
1586 1586
 
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
      *  @type $course WP_Post
1593 1593
      * }
1594 1594
      */
1595
-    public static function get_all_courses(){
1595
+    public static function get_all_courses() {
1596 1596
 
1597 1597
         $args = array(
1598 1598
                'post_type' => 'course',
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
                 'suppress_filters' 	=> 0,
1604 1604
         );
1605 1605
 
1606
-        $wp_query_obj =  new WP_Query( $args );
1606
+        $wp_query_obj = new WP_Query($args);
1607 1607
 
1608 1608
         /**
1609 1609
          * sensei_get_all_courses filter
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
          * }
1616 1616
          * @param array $attributes
1617 1617
          */
1618
-        return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts );
1618
+        return apply_filters('sensei_get_all_courses', $wp_query_obj->posts);
1619 1619
 
1620 1620
     }// end get_all_courses
1621 1621
 
@@ -1626,16 +1626,16 @@  discard block
 block discarded – undo
1626 1626
      * @param int $progress_percentage 0 - 100
1627 1627
      * @return string $progress_bar_html
1628 1628
      */
1629
-    public function get_progress_meter( $progress_percentage ){
1629
+    public function get_progress_meter($progress_percentage) {
1630 1630
 
1631
-        if ( 50 < $progress_percentage ) {
1631
+        if (50 < $progress_percentage) {
1632 1632
             $class = ' green';
1633
-        } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) {
1633
+        } elseif (25 <= $progress_percentage && 50 >= $progress_percentage) {
1634 1634
             $class = ' orange';
1635 1635
         } else {
1636 1636
             $class = ' red';
1637 1637
         }
1638
-        $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>';
1638
+        $progress_bar_html = '<div class="meter'.esc_attr($class).'"><span style="width: '.$progress_percentage.'%">'.round($progress_percentage).'%</span></div>';
1639 1639
 
1640 1640
         return $progress_bar_html;
1641 1641
 
@@ -1650,17 +1650,17 @@  discard block
 block discarded – undo
1650 1650
      *
1651 1651
      * @return string $statement_html
1652 1652
      */
1653
-    public function get_progress_statement( $course_id, $user_id ){
1653
+    public function get_progress_statement($course_id, $user_id) {
1654 1654
 
1655
-        if( empty( $course_id ) || empty( $user_id )
1656
-        || ! WooThemes_Sensei_Utils::user_started_course( $course_id, $user_id ) ){
1655
+        if (empty($course_id) || empty($user_id)
1656
+        || ! WooThemes_Sensei_Utils::user_started_course($course_id, $user_id)) {
1657 1657
             return '';
1658 1658
         }
1659 1659
 
1660
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1661
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1660
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1661
+        $total_lessons = count($this->course_lessons($course_id));
1662 1662
 
1663
-        $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons );
1663
+        $statement = sprintf(_n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons);
1664 1664
 
1665 1665
         /**
1666 1666
          * Filter the course completion statement.
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
          *
1669 1669
          * @param string $statement
1670 1670
          */
1671
-        return apply_filters( 'sensei_course_completion_statement', $statement );
1671
+        return apply_filters('sensei_course_completion_statement', $statement);
1672 1672
 
1673 1673
     }// end generate_progress_statement
1674 1674
 
@@ -1678,17 +1678,17 @@  discard block
 block discarded – undo
1678 1678
      * @param $course_id
1679 1679
      * @return void
1680 1680
      */
1681
-    public function the_progress_statement( $course_id = 0, $user_id = 0 ){
1682
-        if( empty( $course_id ) ){
1681
+    public function the_progress_statement($course_id = 0, $user_id = 0) {
1682
+        if (empty($course_id)) {
1683 1683
             global $post;
1684 1684
             $course_id = $post->ID;
1685 1685
         }
1686 1686
 
1687
-        if( empty( $user_id ) ){
1687
+        if (empty($user_id)) {
1688 1688
             $user_id = get_current_user_id();
1689 1689
         }
1690 1690
 
1691
-        echo '<span class="progress statement  course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id  ) . '</span>';
1691
+        echo '<span class="progress statement  course-completion-rate">'.$this->get_progress_statement($course_id, $user_id).'</span>';
1692 1692
     }
1693 1693
 
1694 1694
     /**
@@ -1697,24 +1697,24 @@  discard block
 block discarded – undo
1697 1697
      * @param $course_id
1698 1698
      * @return void
1699 1699
      */
1700
-    public function the_progress_meter( $course_id = 0, $user_id = 0 ){
1700
+    public function the_progress_meter($course_id = 0, $user_id = 0) {
1701 1701
 
1702
-        if( empty( $course_id ) ){
1702
+        if (empty($course_id)) {
1703 1703
             global $post;
1704 1704
             $course_id = $post->ID;
1705 1705
         }
1706 1706
 
1707
-        if( empty( $user_id ) ){
1707
+        if (empty($user_id)) {
1708 1708
             $user_id = get_current_user_id();
1709 1709
         }
1710 1710
 
1711
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id )
1712
-            || ! WooThemes_Sensei_Utils::user_started_course( $course_id ,$user_id ) ){
1711
+        if ('course' != get_post_type($course_id) || ! get_userdata($user_id)
1712
+            || ! WooThemes_Sensei_Utils::user_started_course($course_id, $user_id)) {
1713 1713
             return;
1714 1714
         }
1715
-        $percentage_completed = $this->get_completion_percentage( $course_id, $user_id );
1715
+        $percentage_completed = $this->get_completion_percentage($course_id, $user_id);
1716 1716
 
1717
-        echo $this->get_progress_meter( $percentage_completed );
1717
+        echo $this->get_progress_meter($percentage_completed);
1718 1718
 
1719 1719
     }// end the_progress_meter
1720 1720
 
@@ -1727,20 +1727,20 @@  discard block
 block discarded – undo
1727 1727
      * @param int $user_id
1728 1728
      * @return array $completed_lesson_ids
1729 1729
      */
1730
-    public function get_completed_lesson_ids( $course_id, $user_id = 0 ){
1730
+    public function get_completed_lesson_ids($course_id, $user_id = 0) {
1731 1731
 
1732
-        if( !( intval( $user_id ) ) > 0 ){
1732
+        if ( ! (intval($user_id)) > 0) {
1733 1733
             $user_id = get_current_user_id();
1734 1734
         }
1735 1735
 
1736 1736
         $completed_lesson_ids = array();
1737 1737
 
1738
-        $course_lessons = $this->course_lessons( $course_id );
1738
+        $course_lessons = $this->course_lessons($course_id);
1739 1739
 
1740
-        foreach( $course_lessons as $lesson ){
1740
+        foreach ($course_lessons as $lesson) {
1741 1741
 
1742
-            $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id );
1743
-            if( $is_lesson_completed ){
1742
+            $is_lesson_completed = WooThemes_Sensei_Utils::user_completed_lesson($lesson->ID, $user_id);
1743
+            if ($is_lesson_completed) {
1744 1744
                 $completed_lesson_ids[] = $lesson->ID;
1745 1745
             }
1746 1746
 
@@ -1759,19 +1759,19 @@  discard block
 block discarded – undo
1759 1759
      * @param int $user_id
1760 1760
      * @return int $percentage
1761 1761
      */
1762
-    public function get_completion_percentage( $course_id, $user_id = 0 ){
1762
+    public function get_completion_percentage($course_id, $user_id = 0) {
1763 1763
 
1764
-        if( !( intval( $user_id ) ) > 0 ){
1764
+        if ( ! (intval($user_id)) > 0) {
1765 1765
             $user_id = get_current_user_id();
1766 1766
         }
1767 1767
 
1768
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1768
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1769 1769
 
1770
-        if( ! (  $completed  > 0 ) ){
1770
+        if ( ! ($completed > 0)) {
1771 1771
             return 0;
1772 1772
         }
1773 1773
 
1774
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1774
+        $total_lessons = count($this->course_lessons($course_id));
1775 1775
         $percentage = $completed / $total_lessons * 100;
1776 1776
 
1777 1777
         /**
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
          * @param $user_id
1784 1784
          * @since 1.8.0
1785 1785
          */
1786
-        return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id );
1786
+        return apply_filters('sensei_course_completion_percentage', $percentage, $course_id, $user_id);
1787 1787
 
1788 1788
     }// end get_completed_lesson_ids
1789 1789
 
@@ -1795,28 +1795,28 @@  discard block
 block discarded – undo
1795 1795
      * @param $should_send
1796 1796
      * @return bool
1797 1797
      */
1798
-    public function block_notification_emails( $should_send ){
1798
+    public function block_notification_emails($should_send) {
1799 1799
         global $sensei_email_data;
1800 1800
         $email = $sensei_email_data;
1801 1801
 
1802 1802
         $course_id = '';
1803 1803
 
1804
-        if( isset( $email['course_id'] ) ){
1804
+        if (isset($email['course_id'])) {
1805 1805
 
1806 1806
             $course_id = $email['course_id'];
1807 1807
 
1808
-        }elseif( isset( $email['lesson_id'] ) ){
1808
+        }elseif (isset($email['lesson_id'])) {
1809 1809
 
1810
-            $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1810
+            $course_id = Sensei()->lesson->get_course_id($email['lesson_id']);
1811 1811
 
1812
-        }elseif( isset( $email['quiz_id'] ) ){
1812
+        }elseif (isset($email['quiz_id'])) {
1813 1813
 
1814
-            $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1815
-            $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1814
+            $lesson_id = Sensei()->quiz->get_lesson_id($email['quiz_id']);
1815
+            $course_id = Sensei()->lesson->get_course_id($lesson_id);
1816 1816
 
1817 1817
         }
1818 1818
 
1819
-        if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) {
1819
+        if ( ! empty($course_id) && 'course' == get_post_type($course_id)) {
1820 1820
 
1821 1821
             $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true);
1822 1822
 
@@ -1837,19 +1837,19 @@  discard block
 block discarded – undo
1837 1837
      * @since 1.8.0
1838 1838
      * @param $course
1839 1839
      */
1840
-    public function course_notification_meta_box_content( $course ){
1840
+    public function course_notification_meta_box_content($course) {
1841 1841
 
1842
-        $checked = get_post_meta( $course->ID , 'disable_notification', true );
1842
+        $checked = get_post_meta($course->ID, 'disable_notification', true);
1843 1843
 
1844 1844
         // generate checked html
1845 1845
         $checked_html = '';
1846
-        if( $checked ){
1846
+        if ($checked) {
1847 1847
             $checked_html = 'checked="checked"';
1848 1848
         }
1849
-        wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' );
1849
+        wp_nonce_field('update-course-notification-setting', '_sensei_course_notification');
1850 1850
 
1851
-        echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >';
1852
-        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>';
1851
+        echo '<input id="disable_sensei_course_notification" '.$checked_html.' type="checkbox" name="disable_sensei_course_notification" >';
1852
+        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei').'</label>';
1853 1853
 
1854 1854
     }// end course_notification_meta_box_content
1855 1855
 
@@ -1861,20 +1861,20 @@  discard block
 block discarded – undo
1861 1861
      *
1862 1862
      * @param $course_id
1863 1863
      */
1864
-    public function save_course_notification_meta_box( $course_id ){
1864
+    public function save_course_notification_meta_box($course_id) {
1865 1865
 
1866
-        if( !isset( $_POST['_sensei_course_notification']  )
1867
-            || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){
1866
+        if ( ! isset($_POST['_sensei_course_notification'])
1867
+            || ! wp_verify_nonce($_POST['_sensei_course_notification'], 'update-course-notification-setting')) {
1868 1868
             return;
1869 1869
         }
1870 1870
 
1871
-        if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1871
+        if (isset($_POST['disable_sensei_course_notification']) && 'on' == $_POST['disable_sensei_course_notification']) {
1872 1872
             $new_val = true;
1873
-        }else{
1873
+        } else {
1874 1874
             $new_val = false;
1875 1875
         }
1876 1876
 
1877
-       update_post_meta( $course_id , 'disable_notification', $new_val );
1877
+       update_post_meta($course_id, 'disable_notification', $new_val);
1878 1878
 
1879 1879
     }// end save notification meta box
1880 1880
 
@@ -1888,19 +1888,19 @@  discard block
 block discarded – undo
1888 1888
      *
1889 1889
      * @param WP_Post $post
1890 1890
      */
1891
-    public function content_before_backwards_compatibility_hooks( $post ){
1891
+    public function content_before_backwards_compatibility_hooks($post) {
1892 1892
 
1893
-        if( has_action( 'sensei_course_image' ) ){
1893
+        if (has_action('sensei_course_image')) {
1894 1894
 
1895
-            _doing_it_wrong('sensei_course_image','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' );
1896
-            do_action('sensei_course_image', $post->ID );
1895
+            _doing_it_wrong('sensei_course_image', 'This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9');
1896
+            do_action('sensei_course_image', $post->ID);
1897 1897
 
1898 1898
         }
1899 1899
 
1900
-        if( has_action( 'sensei_course_archive_course_title' ) ){
1900
+        if (has_action('sensei_course_archive_course_title')) {
1901 1901
 
1902
-            _doing_it_wrong('sensei_course_archive_course_title','This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9' );
1903
-            do_action('sensei_course_archive_course_title', $post );
1902
+            _doing_it_wrong('sensei_course_archive_course_title', 'This action has been retired: . Please use sensei_course_content_inside_before instead.', '1.9');
1903
+            do_action('sensei_course_archive_course_title', $post);
1904 1904
 
1905 1905
         }
1906 1906
 
@@ -1915,10 +1915,10 @@  discard block
 block discarded – undo
1915 1915
      *
1916 1916
      * @global WP_Post $post
1917 1917
      */
1918
-    public  function loop_before_backwards_compatibility_hooks( ){
1918
+    public  function loop_before_backwards_compatibility_hooks( ) {
1919 1919
 
1920 1920
         global $post;
1921
-        sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type  );
1921
+        sensei_do_deprecated_action('sensei_course_archive_header', '1.9.0', 'sensei_course_content_inside_before', $post->post_type);
1922 1922
 
1923 1923
     }
1924 1924
 
@@ -1931,18 +1931,18 @@  discard block
 block discarded – undo
1931 1931
      *
1932 1932
      * @param WP_Post $course
1933 1933
      */
1934
-    public function the_course_free_lesson_preview( $course ){
1934
+    public function the_course_free_lesson_preview($course) {
1935 1935
         // Meta data
1936
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) );
1937
-        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
1936
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID));
1937
+        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($course->ID, get_current_user_id());
1938 1938
 
1939
-        if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
1939
+        if (0 < $preview_lesson_count && ! $is_user_taking_course) {
1940 1940
             ?>
1941 1941
             <p class="sensei-free-lessons">
1942 1942
                 <a href="<?php echo get_permalink(); ?>">
1943
-                    <?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
1943
+                    <?php _e('Preview this course', 'woothemes-sensei') ?>
1944 1944
                 </a>
1945
-                - <?php echo sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) ; ?>
1945
+                - <?php echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
1946 1946
             </p>
1947 1947
 
1948 1948
         <?php
@@ -1955,38 +1955,38 @@  discard block
 block discarded – undo
1955 1955
      * @since 1.9.0
1956 1956
      * @param WP_Post $course
1957 1957
      */
1958
-    public function the_course_meta( $course ){
1958
+    public function the_course_meta($course) {
1959 1959
         echo '<p class="sensei-course-meta">';
1960 1960
 
1961
-        $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' );
1962
-        $author_display_name = get_the_author_meta( 'display_name', $course->post_author  );
1961
+        $category_output = get_the_term_list($course->ID, 'course-category', '', ', ', '');
1962
+        $author_display_name = get_the_author_meta('display_name', $course->post_author);
1963 1963
 
1964
-        if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?>
1964
+        if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {?>
1965 1965
 
1966
-            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?>
1966
+            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?>
1967 1967
 
1968
-                <a href="<?php esc_attr_e( get_author_posts_url( $course->post_author ) ); ?>" title="<?php esc_attr_e( $author_display_name ); ?>"><?php esc_attr_e( $author_display_name   ); ?></a>
1968
+                <a href="<?php esc_attr_e(get_author_posts_url($course->post_author)); ?>" title="<?php esc_attr_e($author_display_name); ?>"><?php esc_attr_e($author_display_name); ?></a>
1969 1969
 
1970 1970
             </span>
1971 1971
 
1972 1972
         <?php } // End If Statement ?>
1973 1973
 
1974
-        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $course->ID ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?></span>
1974
+        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($course->ID).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
1975 1975
 
1976
-       <?php if ( '' != $category_output ) { ?>
1976
+       <?php if ('' != $category_output) { ?>
1977 1977
 
1978
-            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
1978
+            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
1979 1979
 
1980 1980
         <?php } // End If Statement
1981 1981
 
1982 1982
         // number of completed lessons
1983
-        if( is_user_logged_in() ){
1984
-            $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) );
1985
-            $lesson_count = count( $this->course_lessons( $course->ID ) );
1986
-            echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count  ) . '</span>';
1983
+        if (is_user_logged_in()) {
1984
+            $completed = count($this->get_completed_lesson_ids($course->ID, get_current_user_id()));
1985
+            $lesson_count = count($this->course_lessons($course->ID));
1986
+            echo '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $completed, $lesson_count).'</span>';
1987 1987
         }
1988 1988
 
1989
-        sensei_simple_course_price( $course->ID );
1989
+        sensei_simple_course_price($course->ID);
1990 1990
 
1991 1991
         echo '</p>';
1992 1992
     } // end the course meta
@@ -2001,15 +2001,15 @@  discard block
 block discarded – undo
2001 2001
      *
2002 2002
      * @return array $classes
2003 2003
      */
2004
-    public static function add_course_user_status_class( $classes, $class, $course_id ){
2004
+    public static function add_course_user_status_class($classes, $class, $course_id) {
2005 2005
 
2006
-        if( 'course' == get_post_type( $course_id )  &&  is_user_logged_in() ){
2006
+        if ('course' == get_post_type($course_id) && is_user_logged_in()) {
2007 2007
 
2008
-            if( WooThemes_Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){
2008
+            if (WooThemes_Sensei_Utils::user_completed_course($course_id, get_current_user_id())) {
2009 2009
 
2010 2010
                 $classes[] = 'user-status-completed';
2011 2011
 
2012
-            }else{
2012
+            } else {
2013 2013
 
2014 2014
                 $classes[] = 'user-status-active';
2015 2015
 
@@ -2029,56 +2029,56 @@  discard block
 block discarded – undo
2029 2029
      *
2030 2030
      * @param WP_Post $course
2031 2031
      */
2032
-    public static function the_course_action_buttons( $course ){
2032
+    public static function the_course_action_buttons($course) {
2033 2033
 
2034
-        if( is_user_logged_in() ) { ?>
2034
+        if (is_user_logged_in()) { ?>
2035 2035
 
2036 2036
             <section class="entry-actions">
2037
-                <form method="POST" action="<?php  echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>">
2037
+                <form method="POST" action="<?php  echo esc_url(remove_query_arg(array('active_page', 'completed_page'))); ?>">
2038 2038
 
2039 2039
                     <input type="hidden"
2040
-                           name="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ) ?>"
2041
-                           id="<?php  esc_attr_e( 'woothemes_sensei_complete_course_noonce' ); ?>"
2042
-                           value="<?php esc_attr_e( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ); ?>"
2040
+                           name="<?php esc_attr_e('woothemes_sensei_complete_course_noonce') ?>"
2041
+                           id="<?php  esc_attr_e('woothemes_sensei_complete_course_noonce'); ?>"
2042
+                           value="<?php esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce')); ?>"
2043 2043
                         />
2044 2044
 
2045
-                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e( intval( $course->ID ) ); ?>" />
2045
+                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e(intval($course->ID)); ?>" />
2046 2046
 
2047
-                    <?php if ( 0 < absint( count( Sensei()->course->course_lessons( $course->ID ) ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { ?>
2047
+                    <?php if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') { ?>
2048 2048
 
2049
-                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e( 'Mark as Complete', 'woothemes-sensei' ); ?>" /></span>
2049
+                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e('Mark as Complete', 'woothemes-sensei'); ?>" /></span>
2050 2050
 
2051 2051
                    <?php  } // End If Statement
2052 2052
 
2053 2053
                     $course_purchased = false;
2054
-                    if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
2054
+                    if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
2055 2055
                         // Get the product ID
2056
-                        $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true );
2057
-                        if ( 0 < $wc_post_id ) {
2056
+                        $wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true);
2057
+                        if (0 < $wc_post_id) {
2058 2058
 
2059 2059
                             $user = wp_get_current_user();
2060
-                            $course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id );
2060
+                            $course_purchased = WooThemes_Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
2061 2061
 
2062 2062
                         } // End If Statement
2063 2063
                     } // End If Statement
2064 2064
 
2065
-                    if ( ! $course_purchased && ! WooThemes_Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?>
2065
+                    if ( ! $course_purchased && ! WooThemes_Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {?>
2066 2066
 
2067
-                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span>
2067
+                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __('Delete Course', 'woothemes-sensei'); ?>"/></span>
2068 2068
 
2069 2069
                     <?php } // End If Statement
2070 2070
 
2071
-                    $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true );
2071
+                    $has_quizzes = Sensei()->course->course_quizzes($course->ID, true);
2072 2072
                     $results_link = '';
2073
-                    if( $has_quizzes ){
2074
-                        $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>';
2073
+                    if ($has_quizzes) {
2074
+                        $results_link = '<a class="button view-results" href="'.Sensei()->course_results->get_permalink($course->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2075 2075
                     }
2076 2076
 
2077 2077
                     // Output only if there is content to display
2078
-                    if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2078
+                    if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2079 2079
 
2080 2080
                         <p class="sensei-results-links">
2081
-                            <?php echo apply_filters( 'sensei_results_links', $results_link ); ?>
2081
+                            <?php echo apply_filters('sensei_results_links', $results_link); ?>
2082 2082
                         </p>
2083 2083
 
2084 2084
                     <?php } // end if has filter  ?>
@@ -2103,27 +2103,27 @@  discard block
 block discarded – undo
2103 2103
      * @param WP_Query $query
2104 2104
      * @return WP_Query $query
2105 2105
      */
2106
-    public static function course_query_filter( $query ){
2106
+    public static function course_query_filter($query) {
2107 2107
 
2108 2108
         // exit early for no course queries and admin queries
2109
-        if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){
2109
+        if (is_admin( ) || 'course' != $query->get('post_type')) {
2110 2110
             return $query;
2111 2111
         }
2112 2112
 
2113 2113
         global $post; // used to get the current page id for my courses
2114 2114
 
2115 2115
         // for the course archive page
2116
-        if( $query->is_main_query() && is_post_type_archive('course') )
2116
+        if ($query->is_main_query() && is_post_type_archive('course'))
2117 2117
         {
2118 2118
 
2119
-            $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', get_option( 'posts_per_page' ) ) );
2119
+            $query->set('posts_per_page', apply_filters('sensei_archive_courses_per_page', get_option('posts_per_page')));
2120 2120
 
2121 2121
         }
2122 2122
         // for the my courses page
2123
-        elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID  )
2123
+        elseif (is_page() && Sensei()->settings->get('my_course_page') == $post->ID)
2124 2124
         {
2125 2125
 
2126
-            $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', get_option( 'posts_per_page' ) ) );
2126
+            $query->set('posts_per_page', apply_filters('sensei_my_courses_per_page', get_option('posts_per_page')));
2127 2127
 
2128 2128
         }
2129 2129
 
@@ -2139,21 +2139,21 @@  discard block
 block discarded – undo
2139 2139
      * @return array $extra_classes
2140 2140
      * @since 1.9.0
2141 2141
      */
2142
-    public static function get_course_loop_content_class ()
2142
+    public static function get_course_loop_content_class()
2143 2143
     {
2144 2144
 
2145 2145
         global $sensei_course_loop;
2146 2146
 
2147 2147
 
2148
-        if( !isset( $sensei_course_loop ) ){
2148
+        if ( ! isset($sensei_course_loop)) {
2149 2149
             $sensei_course_loop = array();
2150 2150
         }
2151 2151
 
2152
-        if (!isset($sensei_course_loop['counter'])) {
2152
+        if ( ! isset($sensei_course_loop['counter'])) {
2153 2153
             $sensei_course_loop['counter'] = 0;
2154 2154
         }
2155 2155
 
2156
-        if (!isset($sensei_course_loop['columns'])) {
2156
+        if ( ! isset($sensei_course_loop['columns'])) {
2157 2157
             $sensei_course_loop['columns'] = self::get_loop_number_of_columns();
2158 2158
         }
2159 2159
 
@@ -2161,16 +2161,16 @@  discard block
 block discarded – undo
2161 2161
         $sensei_course_loop['counter']++;
2162 2162
 
2163 2163
         $extra_classes = array();
2164
-        if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']  ){
2164
+        if (0 == ($sensei_course_loop['counter'] - 1) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']) {
2165 2165
             $extra_classes[] = 'first';
2166 2166
         }
2167 2167
 
2168
-        if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']  ){
2168
+        if (0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']) {
2169 2169
             $extra_classes[] = 'last';
2170 2170
         }
2171 2171
 
2172 2172
         // add the item number to the classes as well.
2173
-        $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter'];
2173
+        $extra_classes[] = 'loop-item-number-'.$sensei_course_loop['counter'];
2174 2174
 
2175 2175
         /**
2176 2176
          * Filter the course loop class the fires in the  in get_course_loop_content_class function
@@ -2181,7 +2181,7 @@  discard block
 block discarded – undo
2181 2181
          * @param array $extra_classes
2182 2182
          * @param WP_Post $loop_current_course
2183 2183
          */
2184
-        return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() );
2184
+        return apply_filters('sensei_course_loop_content_class', $extra_classes, get_post());
2185 2185
 
2186 2186
     }// end get_course_loop_class
2187 2187
 
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
      * @since 1.9.0
2192 2192
      * @return mixed|void
2193 2193
      */
2194
-    public static function get_loop_number_of_columns(){
2194
+    public static function get_loop_number_of_columns() {
2195 2195
 
2196 2196
         /**
2197 2197
          * Filter the number of columns on the course archive page.
@@ -2211,10 +2211,10 @@  discard block
 block discarded – undo
2211 2211
      * @since 1.9.0
2212 2212
      * @param
2213 2213
      */
2214
-    public static function course_archive_sorting( $query ){
2214
+    public static function course_archive_sorting($query) {
2215 2215
 
2216 2216
         // don't show on category pages and other pages
2217
-        if( ! is_archive(  'course ') || is_tax('course-category') ){
2217
+        if ( ! is_archive('course ') || is_tax('course-category')) {
2218 2218
             return;
2219 2219
         }
2220 2220
 
@@ -2227,16 +2227,16 @@  discard block
 block discarded – undo
2227 2227
          *  @type string $option_string
2228 2228
          * }
2229 2229
          */
2230
-        $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array(
2231
-            "newness"     => __( "Sort by newest first", "woothemes-sensei"),
2232
-            "title"       => __( "Sort by title A-Z", "woothemes-sensei" ),
2230
+        $course_order_by_options = apply_filters('sensei_archive_course_order_by_options', array(
2231
+            "newness"     => __("Sort by newest first", "woothemes-sensei"),
2232
+            "title"       => __("Sort by title A-Z", "woothemes-sensei"),
2233 2233
         ));
2234 2234
 
2235 2235
         // setup the currently selected item
2236 2236
         $selected = 'newness';
2237
-        if( isset( $_GET['orderby'] ) ){
2237
+        if (isset($_GET['orderby'])) {
2238 2238
 
2239
-            $selected =  $_GET[ 'orderby' ];
2239
+            $selected = $_GET['orderby'];
2240 2240
 
2241 2241
         }
2242 2242
 
@@ -2245,9 +2245,9 @@  discard block
 block discarded – undo
2245 2245
         <form class="sensei-ordering" name="sensei-course-order" action="<?php echo WooThemes_Sensei_Utils::get_current_url(); ?>" method="POST">
2246 2246
             <select name="course-orderby" class="orderby">
2247 2247
                 <?php
2248
-                foreach( $course_order_by_options as $value => $text ){
2248
+                foreach ($course_order_by_options as $value => $text) {
2249 2249
 
2250
-                    echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>';
2250
+                    echo '<option value="'.$value.' "'.selected($selected, $value, false).'>'.$text.'</option>';
2251 2251
 
2252 2252
                 }
2253 2253
                 ?>
@@ -2265,10 +2265,10 @@  discard block
 block discarded – undo
2265 2265
      * @since 1.9.0
2266 2266
      * @param
2267 2267
      */
2268
-    public static function course_archive_filters( $query ){
2268
+    public static function course_archive_filters($query) {
2269 2269
 
2270 2270
         // don't show on category pages
2271
-        if( is_tax('course-category') ){
2271
+        if (is_tax('course-category')) {
2272 2272
             return;
2273 2273
         }
2274 2274
 
@@ -2281,9 +2281,9 @@  discard block
 block discarded – undo
2281 2281
          * }
2282 2282
          *
2283 2283
          */
2284
-        $filters = apply_filters( 'sensei_archive_course_filter_by_options', array(
2285
-            array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ),
2286
-            array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url()  ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ),
2284
+        $filters = apply_filters('sensei_archive_course_filter_by_options', array(
2285
+            array('id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __('All', 'woothemes-sensei')),
2286
+            array('id' => 'featured', 'url' => add_query_arg(array('course_filter'=>'featured'), self::get_courses_page_url()), 'title'=> __('Featured', 'woothemes-sensei')),
2287 2287
         ));
2288 2288
 
2289 2289
 
@@ -2294,11 +2294,11 @@  discard block
 block discarded – undo
2294 2294
             //determine the current active url
2295 2295
             $current_url = WooThemes_Sensei_Utils::get_current_url();
2296 2296
 
2297
-            foreach( $filters as $filter ) {
2297
+            foreach ($filters as $filter) {
2298 2298
 
2299
-                $active_class =  $current_url == $filter['url'] ? ' class="active" ' : '';
2299
+                $active_class = $current_url == $filter['url'] ? ' class="active" ' : '';
2300 2300
 
2301
-                echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title']  .'</a></li>';
2301
+                echo '<li><a '.$active_class.' id="'.$filter['id'].'" href="'.esc_url($filter['url']).'" >'.$filter['title'].'</a></li>';
2302 2302
 
2303 2303
             }
2304 2304
             ?>
@@ -2319,13 +2319,13 @@  discard block
 block discarded – undo
2319 2319
      * @param WP_Query $query
2320 2320
      * @return WP_Query $query
2321 2321
      */
2322
-    public static function course_archive_featured_filter( $query ){
2322
+    public static function course_archive_featured_filter($query) {
2323 2323
 
2324
-        if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query()  ){
2324
+        if (isset ($_GET['course_filter']) && 'featured' == $_GET['course_filter'] && $query->is_main_query()) {
2325 2325
             //setup meta query for featured courses
2326
-            $query->set( 'meta_value', 'featured'  );
2327
-            $query->set( 'meta_key', '_course_featured'  );
2328
-            $query->set( 'meta_compare', '='  );
2326
+            $query->set('meta_value', 'featured');
2327
+            $query->set('meta_key', '_course_featured');
2328
+            $query->set('meta_compare', '=');
2329 2329
         }
2330 2330
 
2331 2331
         return $query;
@@ -2340,13 +2340,13 @@  discard block
 block discarded – undo
2340 2340
      * @param WP_Query $query
2341 2341
      * @return WP_Query $query
2342 2342
      */
2343
-    public static function course_archive_order_by_title( $query ){
2343
+    public static function course_archive_order_by_title($query) {
2344 2344
 
2345
-        if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby']
2346
-            && 'course'== $query->get('post_type') && $query->is_main_query()  ){
2345
+        if (isset ($_POST['course-orderby']) && 'title ' == $_POST['course-orderby']
2346
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
2347 2347
             // setup the order by title for this query
2348
-            $query->set( 'orderby', 'title'  );
2349
-            $query->set( 'order', 'ASC'  );
2348
+            $query->set('orderby', 'title');
2349
+            $query->set('order', 'ASC');
2350 2350
         }
2351 2351
 
2352 2352
         return $query;
@@ -2360,10 +2360,10 @@  discard block
 block discarded – undo
2360 2360
      * @since 1.9.0
2361 2361
      * @return string $course_page_url
2362 2362
      */
2363
-    public static function get_courses_page_url(){
2363
+    public static function get_courses_page_url() {
2364 2364
 
2365
-        $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
2366
-        $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id );
2365
+        $course_page_id = intval(Sensei()->settings->settings['course_page']);
2366
+        $course_page_url = empty($course_page_id) ? get_post_type_archive_link('course') : get_permalink($course_page_id);
2367 2367
 
2368 2368
         return $course_page_url;
2369 2369
 
@@ -2380,61 +2380,61 @@  discard block
 block discarded – undo
2380 2380
      * @param string $after_html
2381 2381
      * @return void
2382 2382
      */
2383
-    public static function archive_header( $query_type ='' , $before_html='', $after_html =''  ){
2383
+    public static function archive_header($query_type = '', $before_html = '', $after_html = '') {
2384 2384
 
2385
-        if( ! is_post_type_archive('course') ){
2385
+        if ( ! is_post_type_archive('course')) {
2386 2386
             return;
2387 2387
         }
2388 2388
 
2389 2389
         // deprecated since 1.9.0
2390
-        sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop');
2390
+        sensei_do_deprecated_action('sensei_archive_title', '1.9.0', 'sensei_archive_before_course_loop');
2391 2391
 
2392 2392
         $html = '';
2393 2393
 
2394
-        if( empty( $before_html ) ){
2394
+        if (empty($before_html)) {
2395 2395
 
2396 2396
             $before_html = '<header class="archive-header"><h1>';
2397 2397
 
2398 2398
         }
2399 2399
 
2400
-        if( empty( $after_html ) ){
2400
+        if (empty($after_html)) {
2401 2401
 
2402 2402
             $after_html = '</h1></header>';
2403 2403
 
2404 2404
         }
2405 2405
 
2406
-        if ( is_tax( 'course-category' ) ) {
2406
+        if (is_tax('course-category')) {
2407 2407
 
2408 2408
             global $wp_query;
2409 2409
 
2410 2410
             $taxonomy_obj = $wp_query->get_queried_object();
2411 2411
             $taxonomy_short_name = $taxonomy_obj->taxonomy;
2412
-            $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
2413
-            $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
2414
-            echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html );
2412
+            $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name);
2413
+            $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name);
2414
+            echo apply_filters('course_category_archive_title', $before_html.$title.$after_html);
2415 2415
             return;
2416 2416
 
2417 2417
         } // End If Statement
2418 2418
 
2419
-        switch ( $query_type ) {
2419
+        switch ($query_type) {
2420 2420
             case 'newcourses':
2421
-                $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html;
2421
+                $html .= $before_html.__('New Courses', 'woothemes-sensei').$after_html;
2422 2422
                 break;
2423 2423
             case 'featuredcourses':
2424
-                $html .= $before_html .  __( 'Featured Courses', 'woothemes-sensei' ) . $after_html;
2424
+                $html .= $before_html.__('Featured Courses', 'woothemes-sensei').$after_html;
2425 2425
                 break;
2426 2426
             case 'freecourses':
2427
-                $html .= $before_html .  __( 'Free Courses', 'woothemes-sensei' ) . $after_html;
2427
+                $html .= $before_html.__('Free Courses', 'woothemes-sensei').$after_html;
2428 2428
                 break;
2429 2429
             case 'paidcourses':
2430
-                $html .= $before_html .  __( 'Paid Courses', 'woothemes-sensei' ) . $after_html;
2430
+                $html .= $before_html.__('Paid Courses', 'woothemes-sensei').$after_html;
2431 2431
                 break;
2432 2432
             default:
2433
-                $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html;
2433
+                $html .= $before_html.__('Courses', 'woothemes-sensei').$after_html;
2434 2434
                 break;
2435 2435
         } // End Switch Statement
2436 2436
 
2437
-        echo apply_filters( 'course_archive_title', $html );
2437
+        echo apply_filters('course_archive_title', $html);
2438 2438
 
2439 2439
     }//course_archive_header
2440 2440
 
@@ -2448,9 +2448,9 @@  discard block
 block discarded – undo
2448 2448
      * @param string $content
2449 2449
      * @return string $content or $excerpt
2450 2450
      */
2451
-    public static function single_course_content( $content ){
2451
+    public static function single_course_content($content) {
2452 2452
 
2453
-        if( ! is_singular('course') ){
2453
+        if ( ! is_singular('course')) {
2454 2454
 
2455 2455
             return $content;
2456 2456
 
@@ -2459,21 +2459,21 @@  discard block
 block discarded – undo
2459 2459
         // Content Access Permissions
2460 2460
         $access_permission = false;
2461 2461
 
2462
-        if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
2462
+        if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) {
2463 2463
 
2464 2464
             $access_permission = true;
2465 2465
 
2466 2466
         } // End If Statement
2467 2467
 
2468 2468
         // Check if the user is taking the course
2469
-        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() );
2469
+        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course(get_the_ID(), get_current_user_id());
2470 2470
 
2471
-        if(WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
2471
+        if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
2472 2472
 
2473
-            $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true );
2474
-            $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
2473
+            $wc_post_id = get_post_meta(get_the_ID(), '_course_woocommerce_product', true);
2474
+            $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
2475 2475
 
2476
-            $has_product_attached = isset ( $product ) && is_object ( $product );
2476
+            $has_product_attached = isset ($product) && is_object($product);
2477 2477
 
2478 2478
         } else {
2479 2479
 
@@ -2481,15 +2481,15 @@  discard block
 block discarded – undo
2481 2481
 
2482 2482
         }
2483 2483
 
2484
-        if ( ( is_user_logged_in() && $is_user_taking_course )
2485
-            || ( $access_permission && !$has_product_attached)
2486
-            || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) {
2484
+        if ((is_user_logged_in() && $is_user_taking_course)
2485
+            || ($access_permission && ! $has_product_attached)
2486
+            || 'full' == Sensei()->settings->get('course_single_content_display')) {
2487 2487
 
2488 2488
             return $content;
2489 2489
 
2490 2490
         } else {
2491 2491
 
2492
-            return '<p class="course-excerpt">' . get_post(  get_the_ID() )->post_excerpt . '</p>';
2492
+            return '<p class="course-excerpt">'.get_post(get_the_ID())->post_excerpt.'</p>';
2493 2493
 
2494 2494
         }
2495 2495
 
@@ -2500,14 +2500,14 @@  discard block
 block discarded – undo
2500 2500
      *
2501 2501
      * @since 1.9.0
2502 2502
      */
2503
-    public static function the_course_lessons_title(){
2503
+    public static function the_course_lessons_title() {
2504 2504
         global $post;
2505
-        $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID  );
2506
-        $course_lessons = Sensei()->course->course_lessons( $post->ID );
2505
+        $none_module_lessons = Sensei()->modules->get_none_module_lessons($post->ID);
2506
+        $course_lessons = Sensei()->course->course_lessons($post->ID);
2507 2507
 
2508 2508
         // title should be Other Lessons if there are lessons belonging to models.
2509 2509
         $title = __('Other Lessons', 'woothemes-sensei');
2510
-        if( count( $course_lessons ) == count( $none_module_lessons )  ){
2510
+        if (count($course_lessons) == count($none_module_lessons)) {
2511 2511
 
2512 2512
             $title = __('Lessons', 'woothemes-sensei');
2513 2513
 
@@ -2516,7 +2516,7 @@  discard block
 block discarded – undo
2516 2516
         /**
2517 2517
          * hook document in class-woothemes-sensei-message.php
2518 2518
          */
2519
-        $title = apply_filters( 'sensei_single_title', $title, $post->post_type );
2519
+        $title = apply_filters('sensei_single_title', $title, $post->post_type);
2520 2520
 
2521 2521
         ob_start(); // start capturing the following output.
2522 2522
 
@@ -2535,7 +2535,7 @@  discard block
 block discarded – undo
2535 2535
          * @since 1.9.0
2536 2536
          * @param string $lessons_title_html
2537 2537
          */
2538
-        echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing.
2538
+        echo apply_filters('the_course_lessons_title', ob_get_clean()); // output and filter the captured output and stop capturing.
2539 2539
 
2540 2540
     }// end the_course_lessons_title
2541 2541
 
@@ -2550,13 +2550,13 @@  discard block
 block discarded – undo
2550 2550
      * @since 1.9.0
2551 2551
      * @global $wp_query
2552 2552
      */
2553
-    public static function load_single_course_lessons_query(){
2553
+    public static function load_single_course_lessons_query() {
2554 2554
 
2555 2555
         global $post, $wp_query;
2556 2556
 
2557 2557
         $course_id = $post->ID;
2558 2558
 
2559
-        if( 'course' != get_post_type( $course_id ) ){
2559
+        if ('course' != get_post_type($course_id)) {
2560 2560
             return;
2561 2561
         }
2562 2562
 
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
             'meta_query'        => array(
2569 2569
                 array(
2570 2570
                     'key' => '_lesson_course',
2571
-                    'value' => intval( $course_id ),
2571
+                    'value' => intval($course_id),
2572 2572
                 ),
2573 2573
             ),
2574 2574
             'post_status'       => 'public',
@@ -2576,17 +2576,17 @@  discard block
 block discarded – undo
2576 2576
         );
2577 2577
 
2578 2578
         // Exclude lessons belonging to modules as they are queried along with the modules.
2579
-        $modules = Sensei()->modules->get_course_modules( $course_id );
2580
-        if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){
2579
+        $modules = Sensei()->modules->get_course_modules($course_id);
2580
+        if ( ! is_wp_error($modules) && ! empty($modules) && is_array($modules)) {
2581 2581
 
2582 2582
             $terms_ids = array();
2583
-            foreach( $modules as $term ){
2583
+            foreach ($modules as $term) {
2584 2584
 
2585 2585
                 $terms_ids[] = $term->term_id;
2586 2586
 
2587 2587
             }
2588 2588
 
2589
-            $course_lesson_query_args[ 'tax_query'] = array(
2589
+            $course_lesson_query_args['tax_query'] = array(
2590 2590
                 array(
2591 2591
                     'taxonomy' => 'module',
2592 2592
                     'field'    => 'id',
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
             );
2597 2597
         }
2598 2598
 
2599
-        $wp_query = new WP_Query( $course_lesson_query_args );
2599
+        $wp_query = new WP_Query($course_lesson_query_args);
2600 2600
 
2601 2601
     }// load_single_course_lessons
2602 2602
 
@@ -2607,16 +2607,16 @@  discard block
 block discarded – undo
2607 2607
      *
2608 2608
      * @param $post_id
2609 2609
      */
2610
-    public static function flush_rewrite_rules( $post_id ){
2610
+    public static function flush_rewrite_rules($post_id) {
2611 2611
 
2612
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
2612
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
2613 2613
 
2614 2614
             return;
2615 2615
 
2616 2616
         }
2617 2617
 
2618 2618
 
2619
-        if( 'course' == get_post_type( $post_id )  ){
2619
+        if ('course' == get_post_type($post_id)) {
2620 2620
 
2621 2621
             Sensei()->initiate_rewrite_rules_flush();
2622 2622
 
@@ -2632,10 +2632,10 @@  discard block
 block discarded – undo
2632 2632
      * @param $excerpt
2633 2633
      * @return string
2634 2634
      */
2635
-    public static function full_content_excerpt_override( $excerpt ){
2635
+    public static function full_content_excerpt_override($excerpt) {
2636 2636
 
2637
-        if (   is_singular('course')  &&
2638
-                'full' == Sensei()->settings->get( 'course_single_content_display' ) ){
2637
+        if (is_singular('course') &&
2638
+                'full' == Sensei()->settings->get('course_single_content_display')) {
2639 2639
 
2640 2640
             return get_the_content();
2641 2641
 
@@ -2652,60 +2652,60 @@  discard block
 block discarded – undo
2652 2652
      *
2653 2653
      * @since 1.9.0
2654 2654
      */
2655
-    public static function the_course_enrolment_actions(){
2655
+    public static function the_course_enrolment_actions() {
2656 2656
         ?>
2657 2657
         <section class="course-meta course-enrolment">
2658 2658
         <?php
2659 2659
         global  $post, $current_user;
2660
-        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
2661
-        if ( is_user_logged_in() && ! $is_user_taking_course ) {
2660
+        $is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($post->ID, $current_user->ID);
2661
+        if (is_user_logged_in() && ! $is_user_taking_course) {
2662 2662
 
2663 2663
             // Get the product ID
2664
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2664
+            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
2665 2665
 
2666 2666
             // Check for woocommerce
2667
-            if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && ( 0 < intval( $wc_post_id ) ) ) {
2667
+            if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && (0 < intval($wc_post_id))) {
2668 2668
                 sensei_wc_add_to_cart($post->ID);
2669 2669
             } else {
2670 2670
                 sensei_start_course_form($post->ID);
2671 2671
             } // End If Statement
2672 2672
 
2673
-        } elseif ( is_user_logged_in() ) {
2673
+        } elseif (is_user_logged_in()) {
2674 2674
 
2675 2675
             // Check if course is completed
2676
-            $user_course_status = WooThemes_Sensei_Utils::user_course_status( $post->ID, $current_user->ID );
2677
-            $completed_course = WooThemes_Sensei_Utils::user_completed_course( $user_course_status );
2676
+            $user_course_status = WooThemes_Sensei_Utils::user_course_status($post->ID, $current_user->ID);
2677
+            $completed_course = WooThemes_Sensei_Utils::user_completed_course($user_course_status);
2678 2678
             // Success message
2679
-            if ( $completed_course ) { ?>
2680
-                <div class="status completed"><?php  _e( 'Completed', 'woothemes-sensei' ); ?></div>
2679
+            if ($completed_course) { ?>
2680
+                <div class="status completed"><?php  _e('Completed', 'woothemes-sensei'); ?></div>
2681 2681
                 <?php
2682
-                $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true );
2683
-                if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2682
+                $has_quizzes = Sensei()->course->course_quizzes($post->ID, true);
2683
+                if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2684 2684
                     <p class="sensei-results-links">
2685 2685
                         <?php
2686 2686
                         $results_link = '';
2687
-                        if( $has_quizzes ) {
2688
-                            $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' .  __( 'View results', 'woothemes-sensei' ) . '</a>';
2687
+                        if ($has_quizzes) {
2688
+                            $results_link = '<a class="view-results" href="'.Sensei()->course_results->get_permalink($post->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2689 2689
                         }
2690
-                        $results_link = apply_filters( 'sensei_results_links', $results_link );
2690
+                        $results_link = apply_filters('sensei_results_links', $results_link);
2691 2691
                         echo $results_link;
2692 2692
                         ?></p>
2693 2693
                 <?php } ?>
2694 2694
             <?php } else { ?>
2695
-                <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div>
2695
+                <div class="status in-progress"><?php echo __('In Progress', 'woothemes-sensei'); ?></div>
2696 2696
             <?php }
2697 2697
 
2698 2698
         } else {
2699 2699
             // Get the product ID
2700
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2700
+            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
2701 2701
             // Check for woocommerce
2702
-            if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && ( 0 < intval( $wc_post_id ) ) ) {
2702
+            if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() && (0 < intval($wc_post_id))) {
2703 2703
 
2704 2704
                 sensei_wc_add_to_cart($post->ID);
2705 2705
 
2706 2706
             } else {
2707 2707
 
2708
-                if( get_option( 'users_can_register') ) {
2708
+                if (get_option('users_can_register')) {
2709 2709
 
2710 2710
 
2711 2711
                     $my_courses_page_id = '';
@@ -2721,24 +2721,24 @@  discard block
 block discarded – undo
2721 2721
                     $wp_register_link = apply_filters('sensei_use_wp_register_link', false);
2722 2722
 
2723 2723
                     $settings = Sensei()->settings->get_settings();
2724
-                    if( isset( $settings[ 'my_course_page' ] )
2725
-                        && 0 < intval( $settings[ 'my_course_page' ] ) ){
2724
+                    if (isset($settings['my_course_page'])
2725
+                        && 0 < intval($settings['my_course_page'])) {
2726 2726
 
2727
-                        $my_courses_page_id = $settings[ 'my_course_page' ];
2727
+                        $my_courses_page_id = $settings['my_course_page'];
2728 2728
 
2729 2729
                     }
2730 2730
 
2731 2731
                     // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
2732 2732
                     // is false, link to My Courses. If not, link to default WordPress registration page.
2733
-                    if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){
2733
+                    if ( ! empty($my_courses_page_id) && $my_courses_page_id && ! $wp_register_link) {
2734 2734
 
2735
-                        $my_courses_url = get_permalink( $my_courses_page_id  );
2736
-                        $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
2737
-                        echo '<div class="status register">' . $register_link . '</div>' ;
2735
+                        $my_courses_url = get_permalink($my_courses_page_id);
2736
+                        $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>';
2737
+                        echo '<div class="status register">'.$register_link.'</div>';
2738 2738
 
2739
-                    } else{
2739
+                    } else {
2740 2740
 
2741
-                        wp_register( '<div class="status register">', '</div>' );
2741
+                        wp_register('<div class="status register">', '</div>');
2742 2742
 
2743 2743
                     }
2744 2744
 
@@ -2757,19 +2757,19 @@  discard block
 block discarded – undo
2757 2757
      *
2758 2758
      * @since 1.9.0
2759 2759
      */
2760
-    public static function the_course_video(){
2760
+    public static function the_course_video() {
2761 2761
 
2762 2762
         global $post;
2763 2763
         // Get the meta info
2764
-        $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
2764
+        $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
2765 2765
 
2766
-        if ( 'http' == substr( $course_video_embed, 0, 4) ) {
2766
+        if ('http' == substr($course_video_embed, 0, 4)) {
2767 2767
 
2768
-            $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) );
2768
+            $course_video_embed = wp_oembed_get(esc_url($course_video_embed));
2769 2769
 
2770 2770
         } // End If Statement
2771 2771
 
2772
-        if ( '' != $course_video_embed ) { ?>
2772
+        if ('' != $course_video_embed) { ?>
2773 2773
 
2774 2774
             <div class="course-video">
2775 2775
                 <?php echo html_entity_decode($course_video_embed); ?>
@@ -2784,7 +2784,7 @@  discard block
 block discarded – undo
2784 2784
      * @global $post
2785 2785
      * @since 1.9.0
2786 2786
      */
2787
-    public static function the_title(){
2787
+    public static function the_title() {
2788 2788
 
2789 2789
         global $post;
2790 2790
 
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
                 /**
2798 2798
                  * Filter documented in class-sensei-messages.php the_title
2799 2799
                  */
2800
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
2800
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
2801 2801
                 ?>
2802 2802
 
2803 2803
             </h1>
@@ -2813,30 +2813,30 @@  discard block
 block discarded – undo
2813 2813
      *
2814 2814
      * @since 1.9.0
2815 2815
      */
2816
-    public static function course_category_title(){
2816
+    public static function course_category_title() {
2817 2817
 
2818
-        if( ! is_tax( 'course-category' ) ){
2818
+        if ( ! is_tax('course-category')) {
2819 2819
             return;
2820 2820
         }
2821 2821
 
2822 2822
         $category_slug = get_query_var('course-category');
2823
-        $term  = get_term_by('slug',$category_slug,'course-category');
2823
+        $term = get_term_by('slug', $category_slug, 'course-category');
2824 2824
 
2825
-        if( ! empty($term) ){
2825
+        if ( ! empty($term)) {
2826 2826
 
2827 2827
             $title = $term->name;
2828 2828
 
2829
-        }else{
2829
+        } else {
2830 2830
 
2831 2831
             $title = 'Course Category';
2832 2832
 
2833 2833
         }
2834 2834
 
2835 2835
         $html = '<h2 class="sensei-category-title">';
2836
-        $html .= __('Category') . ' ' . $title;
2836
+        $html .= __('Category').' '.$title;
2837 2837
         $html .= '</h2>';
2838 2838
 
2839
-        echo apply_filters( 'course_category_title', $html , $term->term_id );
2839
+        echo apply_filters('course_category_title', $html, $term->term_id);
2840 2840
 
2841 2841
     }// course_category_title
2842 2842
 
@@ -2849,16 +2849,16 @@  discard block
 block discarded – undo
2849 2849
      * @param WP_Query $query
2850 2850
      * @return WP_Query
2851 2851
      */
2852
-    public static function alter_course_category_order( $query ){
2852
+    public static function alter_course_category_order($query) {
2853 2853
 
2854
-        if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){
2854
+        if ( ! is_tax('course-category') || ! $query->is_main_query()) {
2855 2855
             return $query;
2856 2856
         }
2857 2857
 
2858
-        $order = get_option( 'sensei_course_order', '' );
2859
-        if( !empty( $order )  ){
2860
-            $query->set('orderby', 'menu_order' );
2861
-            $query->set('order', 'ASC' );
2858
+        $order = get_option('sensei_course_order', '');
2859
+        if ( ! empty($order)) {
2860
+            $query->set('orderby', 'menu_order');
2861
+            $query->set('order', 'ASC');
2862 2862
         }
2863 2863
 
2864 2864
         return $query;
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
      *
2880 2880
      * @return array
2881 2881
      */
2882
-    public static function get_default_query_args(){
2882
+    public static function get_default_query_args() {
2883 2883
         return array(
2884 2884
             'post_type' 		=> 'course',
2885 2885
             'posts_per_page' 		=> 1000,
@@ -2897,14 +2897,14 @@  discard block
 block discarded – undo
2897 2897
      * @param $course_id
2898 2898
      * @return bool
2899 2899
      */
2900
-    public static function is_prerequisite_complete( $course_id ){
2900
+    public static function is_prerequisite_complete($course_id) {
2901 2901
 
2902
-        $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true );
2902
+        $course_prerequisite_id = get_post_meta($course_id, '_course_prerequisite', true);
2903 2903
 
2904 2904
         // if it has a pre requisite course check it
2905
-        if( ! empty(  $course_prerequisite_id ) ){
2905
+        if ( ! empty($course_prerequisite_id)) {
2906 2906
 
2907
-            return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() );
2907
+            return Sensei_Utils::user_completed_course($course_prerequisite_id, get_current_user_id());
2908 2908
 
2909 2909
         }
2910 2910
 
@@ -2920,4 +2920,4 @@  discard block
 block discarded – undo
2920 2920
  * for backward compatibility
2921 2921
  * @since 1.9.0
2922 2922
  */
2923
-class WooThemes_Sensei_Course extends Sensei_Course{}
2923
+class WooThemes_Sensei_Course extends Sensei_Course {}
Please login to merge, or discard this patch.
includes/class-sensei-utils.php 1 patch
Spacing   +534 added lines, -534 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Utilities Class
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 	 * @since   1.0.0
20 20
 	 * @return  string The URL to the placeholder thumbnail image.
21 21
 	 */
22
-	public static function get_placeholder_image () {
22
+	public static function get_placeholder_image() {
23 23
 
24
-		return esc_url( apply_filters( 'sensei_placeholder_thumbnail', Sensei()->plugin_url . 'assets/images/placeholder.png' ) );
24
+		return esc_url(apply_filters('sensei_placeholder_thumbnail', Sensei()->plugin_url.'assets/images/placeholder.png'));
25 25
 	} // End get_placeholder_image()
26 26
 
27 27
 	/**
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @static
32 32
 	 * @return void
33 33
 	 */
34
-	public static function sensei_is_woocommerce_present () {
35
-		if ( class_exists( 'Woocommerce' ) ) {
34
+	public static function sensei_is_woocommerce_present() {
35
+		if (class_exists('Woocommerce')) {
36 36
 			return true;
37 37
 		} else {
38
-			$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
39
-			if ( is_array( $active_plugins ) && in_array( 'woocommerce/woocommerce.php', $active_plugins ) ) {
38
+			$active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
39
+			if (is_array($active_plugins) && in_array('woocommerce/woocommerce.php', $active_plugins)) {
40 40
 				return true;
41 41
 			} else {
42 42
 				return false;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @static
53 53
 	 * @return boolean
54 54
 	 */
55
-	public static function sensei_is_woocommerce_activated () {
55
+	public static function sensei_is_woocommerce_activated() {
56 56
 
57
-		return  WooThemes_Sensei_Utils::sensei_is_woocommerce_present() && isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
57
+		return  WooThemes_Sensei_Utils::sensei_is_woocommerce_present() && isset(Sensei()->settings->settings['woocommerce_enabled']) && Sensei()->settings->settings['woocommerce_enabled'];
58 58
 
59 59
 	} // End sensei_is_woocommerce_activated()
60 60
 
@@ -65,70 +65,70 @@  discard block
 block discarded – undo
65 65
 	 * @param  array $args (default: array())
66 66
 	 * @return void
67 67
 	 */
68
-	public static function sensei_log_activity ( $args = array() ) {
68
+	public static function sensei_log_activity($args = array()) {
69 69
 		global $wpdb;
70 70
 
71 71
 		// Args, minimum data required for WP
72 72
 		$data = array(
73
-					'comment_post_ID' => intval( $args['post_id'] ),
73
+					'comment_post_ID' => intval($args['post_id']),
74 74
 					'comment_author' => '', // Not needed
75 75
 					'comment_author_email' => '', // Not needed
76 76
 					'comment_author_url' => '', // Not needed
77
-					'comment_content' => !empty($args['data']) ? esc_html( $args['data'] ) : '',
78
-					'comment_type' => esc_attr( $args['type'] ),
79
-					'user_id' => intval( $args['user_id'] ),
80
-					'comment_approved' => !empty($args['status']) ? esc_html( $args['status'] ) : 'log', // 'log' == 'sensei_user_answer'
77
+					'comment_content' => ! empty($args['data']) ? esc_html($args['data']) : '',
78
+					'comment_type' => esc_attr($args['type']),
79
+					'user_id' => intval($args['user_id']),
80
+					'comment_approved' => ! empty($args['status']) ? esc_html($args['status']) : 'log', // 'log' == 'sensei_user_answer'
81 81
 				);
82 82
 		// Allow extra data
83
-		if ( !empty($args['username']) ) {
84
-			$data['comment_author'] = sanitize_user( $args['username'] );
83
+		if ( ! empty($args['username'])) {
84
+			$data['comment_author'] = sanitize_user($args['username']);
85 85
 		}
86
-		if ( !empty($args['user_email']) ) {
87
-			$data['comment_author_email'] = sanitize_email( $args['user_email'] );
86
+		if ( ! empty($args['user_email'])) {
87
+			$data['comment_author_email'] = sanitize_email($args['user_email']);
88 88
 		}
89
-		if ( !empty($args['user_url']) ) {
90
-			$data['comment_author_url'] = esc_url( $args['user_url'] );
89
+		if ( ! empty($args['user_url'])) {
90
+			$data['comment_author_url'] = esc_url($args['user_url']);
91 91
 		}
92
-		if ( !empty($args['parent']) ) {
92
+		if ( ! empty($args['parent'])) {
93 93
 			$data['comment_parent'] = $args['parent'];
94 94
 		}
95 95
 		// Sanity check
96
-		if ( empty($args['user_id']) ) {
97
-			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') );
96
+		if (empty($args['user_id'])) {
97
+			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei'));
98 98
 			return false;
99 99
 		}
100 100
 
101
-		do_action( 'sensei_log_activity_before', $args, $data );
101
+		do_action('sensei_log_activity_before', $args, $data);
102 102
 
103 103
 		$flush_cache = false;
104 104
 
105 105
 		// Custom Logic
106 106
 		// Check if comment exists first
107
-		$comment_id = $wpdb->get_var( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'] ) );
108
-		if ( ! $comment_id ) {
107
+		$comment_id = $wpdb->get_var($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type']));
108
+		if ( ! $comment_id) {
109 109
 			// Add the comment
110
-			$comment_id = wp_insert_comment( $data );
110
+			$comment_id = wp_insert_comment($data);
111 111
 
112 112
 			$flush_cache = true;
113
-		} elseif ( isset( $args['action'] ) && 'update' == $args['action'] ) {
113
+		} elseif (isset($args['action']) && 'update' == $args['action']) {
114 114
 			// Update the comment if an update was requested
115 115
 			$data['comment_ID'] = $comment_id;
116 116
 			// By default update the timestamp of the comment
117
-			if ( empty($args['keep_time']) ) {
117
+			if (empty($args['keep_time'])) {
118 118
 				$data['comment_date'] = current_time('mysql');
119 119
 			}
120
-			wp_update_comment( $data );
120
+			wp_update_comment($data);
121 121
 			$flush_cache = true;
122 122
 		} // End If Statement
123 123
 
124 124
 		// Manually Flush the Cache
125
-		if ( $flush_cache ) {
125
+		if ($flush_cache) {
126 126
 			wp_cache_flush();
127 127
 		}
128 128
 
129
-		do_action( 'sensei_log_activity_after', $args, $data,  $comment_id );
129
+		do_action('sensei_log_activity_after', $args, $data, $comment_id);
130 130
 
131
-		if ( 0 < $comment_id ) {
131
+		if (0 < $comment_id) {
132 132
 			// Return the ID so that it can be used for meta data storage
133 133
 			return $comment_id;
134 134
 		} else {
@@ -145,41 +145,41 @@  discard block
 block discarded – undo
145 145
 	 * @param  bool $return_comments (default: false)
146 146
 	 * @return mixed | int
147 147
 	 */
148
-	public static function sensei_check_for_activity ( $args = array(), $return_comments = false ) {
148
+	public static function sensei_check_for_activity($args = array(), $return_comments = false) {
149 149
 
150 150
 		global  $wp_version;
151
-		if ( !$return_comments ) {
151
+		if ( ! $return_comments) {
152 152
 			$args['count'] = true;
153 153
 		}
154 154
 
155 155
 		// Are we only retrieving a single entry, or not care about the order...
156
-		if ( isset( $args['count'] ) || isset( $args['post_id'] ) ){
156
+		if (isset($args['count']) || isset($args['post_id'])) {
157 157
 
158 158
 			// ...then we don't need to ask the db to order the results, this overrides WP default behaviour
159
-			if ( version_compare( $wp_version, '4.1', '>=' ) ) {
159
+			if (version_compare($wp_version, '4.1', '>=')) {
160 160
 				$args['order'] = false;
161 161
 				$args['orderby'] = false;
162 162
 			}
163 163
 		}
164 164
 
165 165
 		// A user ID of 0 is in valid, so shortcut this
166
-		if ( isset( $args['user_id'] ) && 0 == intval ( $args['user_id'] ) ) {
167
-			_deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') );
166
+		if (isset($args['user_id']) && 0 == intval($args['user_id'])) {
167
+			_deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei'));
168 168
 			return false;
169 169
 		}
170 170
 		// Check for legacy code
171
-		if ( isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes') ) ) {
172
-			_deprecated_argument( __FUNCTION__, '1.7', sprintf( __('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'] ) );
171
+		if (isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes'))) {
172
+			_deprecated_argument(__FUNCTION__, '1.7', sprintf(__('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type']));
173 173
 			return false;
174 174
 		}
175 175
 		// Are we checking for specific comment_approved statuses?
176
-		if ( isset($args['status']) ) {
176
+		if (isset($args['status'])) {
177 177
 			// Temporarily store as a custom status if requesting an array...
178
-			if ( is_array( $args['status'] ) && version_compare($wp_version, '4.1', '<') ) {
178
+			if (is_array($args['status']) && version_compare($wp_version, '4.1', '<')) {
179 179
 				// Encode now, decode later
180
-				$args['status'] = implode( ",", $args['status'] );
180
+				$args['status'] = implode(",", $args['status']);
181 181
 				// ...use a filter to switch the encoding back
182
-				add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
182
+				add_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter'));
183 183
 			}
184 184
 		}
185 185
 		else {
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 
189 189
 		// Take into account WP < 4.1 will automatically add ' comment_approved = 1 OR comment_approved = 0 '
190
-		if ( ( is_array( $args['status'] ) || 'any' == $args['status'] ) && version_compare($wp_version, '4.1', '<') ) {
191
-			add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
190
+		if ((is_array($args['status']) || 'any' == $args['status']) && version_compare($wp_version, '4.1', '<')) {
191
+			add_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter'));
192 192
 		}
193 193
 
194 194
         //Get the comments
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
          *
200 200
          * @param int|array $comments
201 201
          */
202
-        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
202
+        $comments = apply_filters('sensei_check_for_activity', get_comments($args));
203 203
 
204
-		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
205
-		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
204
+		remove_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter'));
205
+		remove_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter'));
206 206
 		// Return comments
207
-		if ( $return_comments ) {
207
+		if ($return_comments) {
208 208
 			// Could check for array of 1 and just return the 1 item?
209
-			if ( is_array($comments) && 1 == count($comments) ) {
209
+			if (is_array($comments) && 1 == count($comments)) {
210 210
 				$comments = array_shift($comments);
211 211
 			}
212 212
 
@@ -224,31 +224,31 @@  discard block
 block discarded – undo
224 224
 	 * @param  array $args (default: array())
225 225
 	 * @return void
226 226
 	 */
227
-	public static function sensei_activity_ids ( $args = array() ) {
227
+	public static function sensei_activity_ids($args = array()) {
228 228
 
229 229
 
230
-		$comments = WooThemes_Sensei_Utils::sensei_check_for_activity( $args, true );
230
+		$comments = WooThemes_Sensei_Utils::sensei_check_for_activity($args, true);
231 231
 		// Need to always use an array, even with only 1 item
232
-		if ( !is_array($comments) ) {
233
-			$comments = array( $comments );
232
+		if ( ! is_array($comments)) {
233
+			$comments = array($comments);
234 234
 		}
235 235
 
236 236
 		$post_ids = array();
237 237
 		// Count comments
238
-		if ( is_array( $comments ) && ( 0 < intval( count( $comments ) ) ) ) {
239
-			foreach ( $comments as $key => $value  ) {
238
+		if (is_array($comments) && (0 < intval(count($comments)))) {
239
+			foreach ($comments as $key => $value) {
240 240
 				// Add matches to id array
241
-				if ( isset( $args['field'] ) && 'comment' == $args['field'] ) {
242
-					array_push( $post_ids, $value->comment_ID );
243
-				} elseif( isset( $args['field'] ) && 'user_id' == $args['field'] ) {
244
-					array_push( $post_ids, $value->user_id );
241
+				if (isset($args['field']) && 'comment' == $args['field']) {
242
+					array_push($post_ids, $value->comment_ID);
243
+				} elseif (isset($args['field']) && 'user_id' == $args['field']) {
244
+					array_push($post_ids, $value->user_id);
245 245
 				} else {
246
-					array_push( $post_ids, $value->comment_post_ID );
246
+					array_push($post_ids, $value->comment_post_ID);
247 247
 				} // End If Statement
248 248
 			} // End For Loop
249 249
 			// Reset array indexes
250
-			$post_ids = array_unique( $post_ids );
251
-			$post_ids = array_values( $post_ids );
250
+			$post_ids = array_unique($post_ids);
251
+			$post_ids = array_values($post_ids);
252 252
 		} // End If Statement
253 253
 
254 254
 		return $post_ids;
@@ -262,20 +262,20 @@  discard block
 block discarded – undo
262 262
 	 * @param  array $args (default: array())
263 263
 	 * @return boolean
264 264
 	 */
265
-	public static function sensei_delete_activities ( $args = array() ) {
265
+	public static function sensei_delete_activities($args = array()) {
266 266
 
267 267
 		$dataset_changes = false;
268 268
 
269 269
 		// If activity exists remove activity from log
270
-		$comments = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'post_id' => intval( $args['post_id'] ), 'user_id' => intval( $args['user_id'] ), 'type' => esc_attr( $args['type'] ) ), true );
271
-		if( $comments ) {
270
+		$comments = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => intval($args['post_id']), 'user_id' => intval($args['user_id']), 'type' => esc_attr($args['type'])), true);
271
+		if ($comments) {
272 272
 			// Need to always return an array, even with only 1 item
273
-			if ( !is_array( $comments ) ) {
274
-				$comments = array( $comments );
273
+			if ( ! is_array($comments)) {
274
+				$comments = array($comments);
275 275
 			}
276
-			foreach ( $comments as $key => $value  ) {
277
-				if ( isset( $value->comment_ID ) && 0 < $value->comment_ID ) {
278
-					$dataset_changes = wp_delete_comment( intval( $value->comment_ID ), true );
276
+			foreach ($comments as $key => $value) {
277
+				if (isset($value->comment_ID) && 0 < $value->comment_ID) {
278
+					$dataset_changes = wp_delete_comment(intval($value->comment_ID), true);
279 279
 				} // End If Statement
280 280
 			} // End For Loop
281 281
 			// Manually flush the cache
@@ -291,25 +291,25 @@  discard block
 block discarded – undo
291 291
      * @param  integer $user_id User ID
292 292
      * @return boolean
293 293
      */
294
-    public static function delete_all_user_activity( $user_id = 0 ) {
294
+    public static function delete_all_user_activity($user_id = 0) {
295 295
 
296 296
     	$dataset_changes = false;
297 297
 
298
-    	if( $user_id ) {
298
+    	if ($user_id) {
299 299
 
300
-			$activities = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true );
300
+			$activities = WooThemes_Sensei_Utils::sensei_check_for_activity(array('user_id' => $user_id), true);
301 301
 
302
-			if( $activities ) {
302
+			if ($activities) {
303 303
 
304 304
 				// Need to always return an array, even with only 1 item
305
-				if ( ! is_array( $activities ) ) {
306
-					$activities = array( $activities );
305
+				if ( ! is_array($activities)) {
306
+					$activities = array($activities);
307 307
 				}
308 308
 
309
-				foreach( $activities as $activity ) {
310
-					if( '' == $activity->comment_type ) continue;
311
-					if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
312
-					$dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true );
309
+				foreach ($activities as $activity) {
310
+					if ('' == $activity->comment_type) continue;
311
+					if (strpos('sensei_', $activity->comment_type) != 0) continue;
312
+					$dataset_changes = wp_delete_comment(intval($activity->comment_ID), true);
313 313
 					wp_cache_flush();
314 314
 				}
315 315
 			}
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
 	 * @param  array $args (default: array())
327 327
 	 * @return string
328 328
 	 */
329
-	public static function sensei_get_activity_value ( $args = array() ) {
329
+	public static function sensei_get_activity_value($args = array()) {
330 330
 
331 331
 
332 332
 		$activity_value = false;
333
-		if ( !empty($args['field']) ) {
334
-			$comment = WooThemes_Sensei_Utils::sensei_check_for_activity( $args, true );
333
+		if ( ! empty($args['field'])) {
334
+			$comment = WooThemes_Sensei_Utils::sensei_check_for_activity($args, true);
335 335
 
336
-			if ( isset( $comment->{$args['field']} ) && '' != $comment->{$args['field']} ) {
336
+			if (isset($comment->{$args['field']} ) && '' != $comment->{$args['field']} ) {
337 337
 				$activity_value = $comment->{$args['field']};
338 338
 			} // End If Statement
339 339
 		}
@@ -351,22 +351,22 @@  discard block
 block discarded – undo
351 351
      * @param  int $product_id
352 352
      * @return bool
353 353
      */
354
-    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
354
+    public static function sensei_customer_bought_product($customer_email, $user_id, $product_id) {
355 355
 
356 356
         $emails = array();
357 357
 
358
-        if ( $user_id ) {
359
-            $user = get_user_by( 'id', intval( $user_id ) );
358
+        if ($user_id) {
359
+            $user = get_user_by('id', intval($user_id));
360 360
             $emails[] = $user->user_email;
361 361
         }
362 362
 
363
-        if ( is_email( $customer_email ) )
363
+        if (is_email($customer_email))
364 364
             $emails[] = $customer_email;
365 365
 
366
-        if ( sizeof( $emails ) == 0 )
366
+        if (sizeof($emails) == 0)
367 367
             return false;
368 368
 
369
-        return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
369
+        return Sensei_WC::has_customer_bought_product($user_id, $product_id);
370 370
 
371 371
     } // End sensei_customer_bought_product()
372 372
 
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $input_name Name for textarea form element
378 378
 	 * @return void
379 379
 	 */
380
-	public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) {
380
+	public static function sensei_text_editor($content = '', $editor_id = 'senseitexteditor', $input_name = '') {
381 381
 
382
-		if( ! $input_name ) $input_name = $editor_id;
382
+		if ( ! $input_name) $input_name = $editor_id;
383 383
 
384 384
 		$buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext';
385 385
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			'quicktags' => false
398 398
 		);
399 399
 
400
-		wp_editor( $content, $editor_id, $settings );
400
+		wp_editor($content, $editor_id, $settings);
401 401
 
402 402
 	} // End sensei_text_editor()
403 403
 
@@ -406,56 +406,56 @@  discard block
 block discarded – undo
406 406
 	 * @param  boolean $submitted User's quiz answers
407 407
 	 * @return boolean            Whether the answers were saved or not
408 408
 	 */
409
-	public static function sensei_save_quiz_answers( $submitted = false, $user_id = 0 ) {
410
-		if( intval( $user_id ) == 0 ) {
409
+	public static function sensei_save_quiz_answers($submitted = false, $user_id = 0) {
410
+		if (intval($user_id) == 0) {
411 411
 			$user_id = get_current_user_id();
412 412
 		}
413 413
 
414 414
 		$answers_saved = false;
415 415
 
416
-		if( $submitted && intval( $user_id ) > 0 ) {
416
+		if ($submitted && intval($user_id) > 0) {
417 417
 
418
-			foreach( $submitted as $question_id => $answer ) {
418
+			foreach ($submitted as $question_id => $answer) {
419 419
 
420 420
 				// Get question type
421
-				$question_type = Sensei()->question->get_question_type( $question_id );
421
+				$question_type = Sensei()->question->get_question_type($question_id);
422 422
 
423 423
 				// Sanitise answer
424
-				if( 0 == get_magic_quotes_gpc() ) {
425
-					$answer = wp_unslash( $answer );
424
+				if (0 == get_magic_quotes_gpc()) {
425
+					$answer = wp_unslash($answer);
426 426
 				}
427
-				switch( $question_type ) {
428
-					case 'multi-line': $answer = nl2br( $answer ); break;
427
+				switch ($question_type) {
428
+					case 'multi-line': $answer = nl2br($answer); break;
429 429
 					case 'single-line': break;
430 430
 					case 'gap-fill': break;
431
-					default: $answer = maybe_serialize( $answer ); break;
431
+					default: $answer = maybe_serialize($answer); break;
432 432
 				}
433 433
 				$args = array(
434 434
 							'post_id' => $question_id,
435
-							'data' => base64_encode( $answer ),
435
+							'data' => base64_encode($answer),
436 436
 							'type' => 'sensei_user_answer', /* FIELD SIZE 20 */
437 437
 							'user_id' => $user_id,
438 438
 							'action' => 'update'
439 439
 						);
440
-				$answers_saved = WooThemes_Sensei_Utils::sensei_log_activity( $args );
440
+				$answers_saved = WooThemes_Sensei_Utils::sensei_log_activity($args);
441 441
 			}
442 442
 
443 443
 			// Handle file upload questions
444
-			if( isset( $_FILES ) ) {
445
-				foreach( $_FILES as $field => $file ) {
446
-					if( strpos( $field, 'file_upload_' ) !== false ) {
447
-						$question_id = str_replace( 'file_upload_', '', $field );
448
-						if( $file && $question_id ) {
449
-							$attachment_id = self::upload_file( $file );
450
-							if( $attachment_id ) {
444
+			if (isset($_FILES)) {
445
+				foreach ($_FILES as $field => $file) {
446
+					if (strpos($field, 'file_upload_') !== false) {
447
+						$question_id = str_replace('file_upload_', '', $field);
448
+						if ($file && $question_id) {
449
+							$attachment_id = self::upload_file($file);
450
+							if ($attachment_id) {
451 451
 								$args = array(
452 452
 									'post_id' => $question_id,
453
-									'data' => base64_encode( $attachment_id ),
453
+									'data' => base64_encode($attachment_id),
454 454
 									'type' => 'sensei_user_answer', /* FIELD SIZE 20 */
455 455
 									'user_id' => $user_id,
456 456
 									'action' => 'update'
457 457
 								);
458
-								$answers_saved = WooThemes_Sensei_Utils::sensei_log_activity( $args );
458
+								$answers_saved = WooThemes_Sensei_Utils::sensei_log_activity($args);
459 459
 							}
460 460
 						}
461 461
 					}
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 
468 468
 	} // End sensei_save_quiz_answers()
469 469
 
470
-	public static function upload_file( $file = array() ) {
470
+	public static function upload_file($file = array()) {
471 471
 
472
-		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
472
+		require_once(ABSPATH.'wp-admin/includes/admin.php');
473 473
 
474 474
         /**
475 475
          * Filter the data array for the Sensei wp_handle_upload function call
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
          *     @type string test_form set to false by default
485 485
          * }
486 486
          */
487
-        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
487
+        $file_upload_args = apply_filters('sensei_file_upload_args', array('test_form' => false));
488 488
 
489
-        $file_return = wp_handle_upload( $file, $file_upload_args );
489
+        $file_return = wp_handle_upload($file, $file_upload_args);
490 490
 
491
-        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
491
+        if (isset($file_return['error']) || isset($file_return['upload_error_handler'])) {
492 492
             return false;
493 493
         } else {
494 494
 
@@ -496,19 +496,19 @@  discard block
 block discarded – undo
496 496
 
497 497
             $attachment = array(
498 498
                 'post_mime_type' => $file_return['type'],
499
-                'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
499
+                'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
500 500
                 'post_content' => '',
501 501
                 'post_status' => 'inherit',
502 502
                 'guid' => $file_return['url']
503 503
             );
504 504
 
505
-            $attachment_id = wp_insert_attachment( $attachment, $filename );
505
+            $attachment_id = wp_insert_attachment($attachment, $filename);
506 506
 
507
-            require_once(ABSPATH . 'wp-admin/includes/image.php');
508
-            $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
509
-            wp_update_attachment_metadata( $attachment_id, $attachment_data );
507
+            require_once(ABSPATH.'wp-admin/includes/image.php');
508
+            $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename);
509
+            wp_update_attachment_metadata($attachment_id, $attachment_data);
510 510
 
511
-            if( 0 < intval( $attachment_id ) ) {
511
+            if (0 < intval($attachment_id)) {
512 512
             	return $attachment_id;
513 513
             }
514 514
         }
@@ -534,9 +534,9 @@  discard block
 block discarded – undo
534 534
      *
535 535
 	 * @return int $quiz_grade total sum of all question grades
536 536
 	 */
537
-	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
537
+	public static function sensei_grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') {
538 538
 
539
-        return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
539
+        return Sensei_Grading::grade_quiz_auto($quiz_id, $submitted, $total_questions, $quiz_grade_type);
540 540
 
541 541
 	} // End sensei_grade_quiz_auto()
542 542
 
@@ -547,20 +547,20 @@  discard block
 block discarded – undo
547 547
 	 * @param  integer $user_id ID of user being graded
548 548
 	 * @return boolean
549 549
 	 */
550
-	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) {
551
-		if( intval( $user_id ) == 0 ) {
550
+	public static function sensei_grade_quiz($quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto') {
551
+		if (intval($user_id) == 0) {
552 552
 			$user_id = get_current_user_id();
553 553
 		}
554 554
 
555 555
 		$activity_logged = false;
556
-		if( intval( $quiz_id ) > 0 && intval( $user_id ) > 0 ) {
557
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
558
-			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
559
-			$activity_logged = update_comment_meta( $user_lesson_status->comment_ID, 'grade', $grade );
556
+		if (intval($quiz_id) > 0 && intval($user_id) > 0) {
557
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
558
+			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user_id);
559
+			$activity_logged = update_comment_meta($user_lesson_status->comment_ID, 'grade', $grade);
560 560
 
561
-			$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
561
+			$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
562 562
 
563
-			do_action( 'sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type );
563
+			do_action('sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type);
564 564
 		}
565 565
 
566 566
 		return $activity_logged;
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
      *
581 581
 	 * @return int $question_grade
582 582
 	 */
583
-	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
583
+	public static function sensei_grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) {
584 584
 
585
-       return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
585
+       return  WooThemes_Sensei_Grading::grade_question_auto($question_id, $question_type, $answer, $user_id);
586 586
 
587 587
 	} // end sensei_grade_question_auto
588 588
 
@@ -592,20 +592,20 @@  discard block
 block discarded – undo
592 592
 	 * @param  integer $grade       Grade received
593 593
 	 * @return boolean
594 594
 	 */
595
-	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) {
596
-		if( intval( $user_id ) == 0 ) {
595
+	public static function sensei_grade_question($question_id = 0, $grade = 0, $user_id = 0) {
596
+		if (intval($user_id) == 0) {
597 597
 			$user_id = get_current_user_id();
598 598
 		}
599 599
 
600 600
 		$activity_logged = false;
601
-		if( intval( $question_id ) > 0 && intval( $user_id ) > 0 ) {
601
+		if (intval($question_id) > 0 && intval($user_id) > 0) {
602 602
 
603
-			$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
604
-			$activity_logged = update_comment_meta( $user_answer_id, 'user_grade', $grade );
603
+			$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
604
+			$activity_logged = update_comment_meta($user_answer_id, 'user_grade', $grade);
605 605
 
606
-			$answer_notes = get_post_meta( $question_id, '_answer_feedback', true );
607
-			if ( !empty($answer_notes) ) {
608
-				update_comment_meta( $user_answer_id, 'answer_note', base64_encode( $answer_notes ) );
606
+			$answer_notes = get_post_meta($question_id, '_answer_feedback', true);
607
+			if ( ! empty($answer_notes)) {
608
+				update_comment_meta($user_answer_id, 'answer_note', base64_encode($answer_notes));
609 609
 			}
610 610
 
611 611
 		}
@@ -613,15 +613,15 @@  discard block
 block discarded – undo
613 613
 		return $activity_logged;
614 614
 	}
615 615
 
616
-	public static function sensei_delete_question_grade( $question_id = 0, $user_id = 0 ) {
617
-		if( intval( $user_id ) == 0 ) {
616
+	public static function sensei_delete_question_grade($question_id = 0, $user_id = 0) {
617
+		if (intval($user_id) == 0) {
618 618
 			$user_id = get_current_user_id();
619 619
 		}
620 620
 
621 621
 		$activity_logged = false;
622
-		if( intval( $question_id ) > 0 ) {
623
-			$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
624
-			$activity_logged = delete_comment_meta( $user_answer_id, 'user_grade' );
622
+		if (intval($question_id) > 0) {
623
+			$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
624
+			$activity_logged = delete_comment_meta($user_answer_id, 'user_grade');
625 625
 		}
626 626
 
627 627
 		return $activity_logged;
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
      *
640 640
      * @return mixed boolean or comment_ID
641 641
      */
642
-    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
642
+    public static function user_start_lesson($user_id = 0, $lesson_id = 0, $complete = false) {
643 643
 
644
-        return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
644
+        return self::sensei_start_lesson($lesson_id, $user_id, $complete);
645 645
 
646 646
     }// end user_start_lesson()
647 647
 
@@ -658,22 +658,22 @@  discard block
 block discarded – undo
658 658
      *
659 659
      * @return mixed boolean or comment_ID
660 660
 	 */
661
-	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
661
+	public static function sensei_start_lesson($lesson_id = 0, $user_id = 0, $complete = false) {
662 662
 
663 663
 
664
-		if( intval( $user_id ) == 0 ) {
664
+		if (intval($user_id) == 0) {
665 665
 			$user_id = get_current_user_id();
666 666
 		}
667 667
 
668 668
 		$activity_logged = false;
669 669
 
670
-		if( intval( $lesson_id ) > 0 ) {
670
+		if (intval($lesson_id) > 0) {
671 671
 
672
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
673
-			if( $course_id ) {
674
-				$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course( $course_id, $user_id );
675
-				if( ! $is_user_taking_course ) {
676
-					WooThemes_Sensei_Utils::user_start_course( $user_id, $course_id );
672
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
673
+			if ($course_id) {
674
+				$is_user_taking_course = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
675
+				if ( ! $is_user_taking_course) {
676
+					WooThemes_Sensei_Utils::user_start_course($user_id, $course_id);
677 677
 				}
678 678
 			}
679 679
 
@@ -681,12 +681,12 @@  discard block
 block discarded – undo
681 681
 			$status = 'in-progress';
682 682
 
683 683
 			// Note: When this action runs the lesson status may not yet exist
684
-			do_action( 'sensei_user_lesson_start', $user_id, $lesson_id );
684
+			do_action('sensei_user_lesson_start', $user_id, $lesson_id);
685 685
 
686
-			if( $complete ) {
686
+			if ($complete) {
687 687
 
688
-				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
689
-				if ( $has_questions ) {
688
+				$has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
689
+				if ($has_questions) {
690 690
 					$status = 'passed'; // Force a pass
691 691
 					$metadata['grade'] = 0;
692 692
 				}
@@ -696,31 +696,31 @@  discard block
 block discarded – undo
696 696
 			}
697 697
 
698 698
 			// Check if user is already taking the lesson
699
-			$activity_logged = WooThemes_Sensei_Utils::user_started_lesson( $lesson_id, $user_id );
700
-			if( ! $activity_logged ) {
699
+			$activity_logged = WooThemes_Sensei_Utils::user_started_lesson($lesson_id, $user_id);
700
+			if ( ! $activity_logged) {
701 701
 
702 702
 				$metadata['start'] = current_time('mysql');
703
-				$activity_logged = WooThemes_Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata );
703
+				$activity_logged = WooThemes_Sensei_Utils::update_lesson_status($user_id, $lesson_id, $status, $metadata);
704 704
 
705 705
             } else {
706 706
 
707 707
                 // if users is already taking the lesson  and the status changes to complete update it
708 708
                 $current_user_activity = get_comment($activity_logged);
709
-                if( $status=='complete' &&
710
-                    $status != $current_user_activity->comment_approved  ){
709
+                if ($status == 'complete' &&
710
+                    $status != $current_user_activity->comment_approved) {
711 711
 
712 712
                     $comment = array();
713 713
                     $comment['comment_ID'] = $activity_logged;
714 714
                     $comment['comment_approved'] = $status;
715
-                    wp_update_comment( $comment );
715
+                    wp_update_comment($comment);
716 716
 
717 717
                 }
718 718
 
719 719
             }
720 720
 
721
-			if ( $complete ) {
721
+			if ($complete) {
722 722
 				// Run this *after* the lesson status has been created/updated
723
-				do_action( 'sensei_user_lesson_end', $user_id, $lesson_id );
723
+				do_action('sensei_user_lesson_end', $user_id, $lesson_id);
724 724
 			}
725 725
 
726 726
 		}
@@ -735,20 +735,20 @@  discard block
 block discarded – undo
735 735
 	 * @param type $user_id
736 736
 	 * @return boolean
737 737
 	 */
738
-	public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) {
738
+	public static function sensei_remove_user_from_lesson($lesson_id = 0, $user_id = 0, $from_course = false) {
739 739
 
740 740
 
741
-		if( ! $lesson_id ) return false;
741
+		if ( ! $lesson_id) return false;
742 742
 
743
-		if( intval( $user_id ) == 0 ) {
743
+		if (intval($user_id) == 0) {
744 744
 			$user_id = get_current_user_id();
745 745
 		}
746 746
 
747 747
 		// Process quiz
748
-		$lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
748
+		$lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
749 749
 
750 750
 		// Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade
751
-		WooThemes_Sensei_Utils::sensei_delete_quiz_answers( $lesson_quiz_id, $user_id );
751
+		WooThemes_Sensei_Utils::sensei_delete_quiz_answers($lesson_quiz_id, $user_id);
752 752
 
753 753
 		// Delete lesson status
754 754
 		$args = array(
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 			'user_id' => $user_id,
758 758
 		);
759 759
 		// This auto deletes the corresponding meta data, such as the quiz grade, and questions asked
760
-		WooThemes_Sensei_Utils::sensei_delete_activities( $args );
760
+		WooThemes_Sensei_Utils::sensei_delete_activities($args);
761 761
 
762
-		if( ! $from_course ) {
763
-			do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id );
762
+		if ( ! $from_course) {
763
+			do_action('sensei_user_lesson_reset', $user_id, $lesson_id);
764 764
 		}
765 765
 
766 766
 		return true;
@@ -773,19 +773,19 @@  discard block
 block discarded – undo
773 773
 	 * @param type $user_id
774 774
 	 * @return boolean
775 775
 	 */
776
-	public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) {
776
+	public static function sensei_remove_user_from_course($course_id = 0, $user_id = 0) {
777 777
 
778 778
 
779
-		if( ! $course_id ) return false;
779
+		if ( ! $course_id) return false;
780 780
 
781
-		if( intval( $user_id ) == 0 ) {
781
+		if (intval($user_id) == 0) {
782 782
 			$user_id = get_current_user_id();
783 783
 		}
784 784
 
785
-		$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
785
+		$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
786 786
 
787
-		foreach( $lesson_ids as $lesson_id ) {
788
-			WooThemes_Sensei_Utils::sensei_remove_user_from_lesson( $lesson_id, $user_id, true );
787
+		foreach ($lesson_ids as $lesson_id) {
788
+			WooThemes_Sensei_Utils::sensei_remove_user_from_lesson($lesson_id, $user_id, true);
789 789
 		}
790 790
 
791 791
 		// Delete course status
@@ -795,36 +795,36 @@  discard block
 block discarded – undo
795 795
 			'user_id' => $user_id,
796 796
 		);
797 797
 
798
-		WooThemes_Sensei_Utils::sensei_delete_activities( $args );
798
+		WooThemes_Sensei_Utils::sensei_delete_activities($args);
799 799
 
800
-		do_action( 'sensei_user_course_reset', $user_id, $course_id );
800
+		do_action('sensei_user_course_reset', $user_id, $course_id);
801 801
 
802 802
 		return true;
803 803
 	}
804 804
 
805
-	public static function sensei_get_quiz_questions( $quiz_id = 0 ) {
805
+	public static function sensei_get_quiz_questions($quiz_id = 0) {
806 806
 
807 807
 
808 808
 		$questions = array();
809 809
 
810
-		if( intval( $quiz_id ) > 0 ) {
811
-			$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
812
-			$questions = WooThemes_Sensei_Utils::array_sort_reorder( $questions );
810
+		if (intval($quiz_id) > 0) {
811
+			$questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
812
+			$questions = WooThemes_Sensei_Utils::array_sort_reorder($questions);
813 813
 		}
814 814
 
815 815
 		return $questions;
816 816
 	}
817 817
 
818
-	public static function sensei_get_quiz_total( $quiz_id = 0 ) {
818
+	public static function sensei_get_quiz_total($quiz_id = 0) {
819 819
 
820 820
 
821 821
 		$quiz_total = 0;
822 822
 
823
-		if( $quiz_id > 0 ) {
824
-			$questions = WooThemes_Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
823
+		if ($quiz_id > 0) {
824
+			$questions = WooThemes_Sensei_Utils::sensei_get_quiz_questions($quiz_id);
825 825
 			$question_grade = 0;
826
-			foreach( $questions as $question ) {
827
-				$question_grade = Sensei()->question->get_question_grade( $question->ID );
826
+			foreach ($questions as $question) {
827
+				$question_grade = Sensei()->question->get_question_grade($question->ID);
828 828
 				$quiz_total += $question_grade;
829 829
 			}
830 830
 		}
@@ -839,20 +839,20 @@  discard block
 block discarded – undo
839 839
 	 * @param int $user_id
840 840
 	 * @return string
841 841
 	 */
842
-	public static function sensei_get_user_question_grade( $question = 0, $user_id = 0 ) {
842
+	public static function sensei_get_user_question_grade($question = 0, $user_id = 0) {
843 843
 		$question_grade = false;
844
-		if( $question ) {
845
-			if ( is_object( $question ) ) {
844
+		if ($question) {
845
+			if (is_object($question)) {
846 846
 				$user_answer_id = $question->comment_ID;
847 847
 			}
848 848
 			else {
849
-				if( intval( $user_id ) == 0 ) {
849
+				if (intval($user_id) == 0) {
850 850
 					$user_id = get_current_user_id();
851 851
 				}
852
-				$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
852
+				$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
853 853
 			}
854
-			if ( $user_answer_id ) {
855
-				$question_grade = get_comment_meta( $user_answer_id, 'user_grade', true );
854
+			if ($user_answer_id) {
855
+				$question_grade = get_comment_meta($user_answer_id, 'user_grade', true);
856 856
 			}
857 857
 		}
858 858
 
@@ -867,52 +867,52 @@  discard block
 block discarded – undo
867 867
 	 * @param int $user_id
868 868
 	 * @return string
869 869
 	 */
870
-	public static function sensei_get_user_question_answer_notes( $question = 0, $user_id = 0 ) {
870
+	public static function sensei_get_user_question_answer_notes($question = 0, $user_id = 0) {
871 871
 		$answer_notes = false;
872
-		if( $question ) {
873
-			if ( is_object( $question ) ) {
872
+		if ($question) {
873
+			if (is_object($question)) {
874 874
 				$user_answer_id = $question->comment_ID;
875 875
 			}
876 876
 			else {
877
-				if( intval( $user_id ) == 0 ) {
877
+				if (intval($user_id) == 0) {
878 878
 					$user_id = get_current_user_id();
879 879
 				}
880
-				$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
880
+				$user_answer_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
881 881
 			}
882
-			if ( $user_answer_id ) {
883
-				$answer_notes = base64_decode( get_comment_meta( $user_answer_id, 'answer_note', true ) );
882
+			if ($user_answer_id) {
883
+				$answer_notes = base64_decode(get_comment_meta($user_answer_id, 'answer_note', true));
884 884
 			}
885 885
 		}
886 886
 
887 887
 		return $answer_notes;
888 888
 	}
889 889
 
890
-	public static function sensei_delete_quiz_answers( $quiz_id = 0, $user_id = 0 ) {
891
-		if( intval( $user_id ) == 0 ) {
890
+	public static function sensei_delete_quiz_answers($quiz_id = 0, $user_id = 0) {
891
+		if (intval($user_id) == 0) {
892 892
 			$user_id = get_current_user_id();
893 893
 		}
894 894
 
895 895
 		$delete_answers = false;
896
-		if( intval( $quiz_id ) > 0 ) {
897
-			$questions = WooThemes_Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
898
-			foreach( $questions as $question ) {
899
-				$delete_answers = WooThemes_Sensei_Utils::sensei_delete_activities( array( 'post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ) );
896
+		if (intval($quiz_id) > 0) {
897
+			$questions = WooThemes_Sensei_Utils::sensei_get_quiz_questions($quiz_id);
898
+			foreach ($questions as $question) {
899
+				$delete_answers = WooThemes_Sensei_Utils::sensei_delete_activities(array('post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer'));
900 900
 			}
901 901
 		}
902 902
 
903 903
 		return $delete_answers;
904 904
 	}
905 905
 
906
-	public static function sensei_delete_quiz_grade( $quiz_id = 0, $user_id = 0 ) {
907
-		if( intval( $user_id ) == 0 ) {
906
+	public static function sensei_delete_quiz_grade($quiz_id = 0, $user_id = 0) {
907
+		if (intval($user_id) == 0) {
908 908
 			$user_id = get_current_user_id();
909 909
 		}
910 910
 
911 911
 		$delete_grade = false;
912
-		if( intval( $quiz_id ) > 0 ) {
913
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
914
-			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
915
-			$delete_grade = delete_comment_meta( $user_lesson_status->comment_ID, 'grade' );
912
+		if (intval($quiz_id) > 0) {
913
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
914
+			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user_id);
915
+			$delete_grade = delete_comment_meta($user_lesson_status->comment_ID, 'grade');
916 916
 		}
917 917
 
918 918
 		return $delete_grade;
@@ -924,20 +924,20 @@  discard block
 block discarded – undo
924 924
 	 * @param  integer $user_id     ID of user
925 925
 	 * @return boolean
926 926
 	 */
927
-	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) {
928
-		if( intval( $user_id ) == 0 ) {
927
+	public static function sensei_add_answer_notes($question_id = 0, $user_id = 0, $notes = '') {
928
+		if (intval($user_id) == 0) {
929 929
 			$user_id = get_current_user_id();
930 930
 		}
931 931
 
932 932
 		$activity_logged = false;
933 933
 
934
-		if( intval( $question_id ) > 0 ) {
935
-			$notes = base64_encode( $notes );
934
+		if (intval($question_id) > 0) {
935
+			$notes = base64_encode($notes);
936 936
 
937 937
 			// Don't store empty values, no point
938
-			if ( !empty($notes) ) {
939
-				$user_lesson_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) );
940
-				$activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes );
938
+			if ( ! empty($notes)) {
939
+				$user_lesson_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID'));
940
+				$activity_logged = update_comment_meta($user_lesson_id, 'answer_note', $notes);
941 941
 			}
942 942
 			else {
943 943
 				$activity_logged = true;
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 	 * @param  array $return_array data to be ordered
954 954
 	 * @return array $return_array ordered data
955 955
 	 */
956
-	public static function array_sort_reorder( $return_array ) {
957
-		if ( isset( $_GET['orderby'] ) && '' != esc_html( $_GET['orderby'] ) ) {
956
+	public static function array_sort_reorder($return_array) {
957
+		if (isset($_GET['orderby']) && '' != esc_html($_GET['orderby'])) {
958 958
 			$sort_key = '';
959 959
 			// if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->sortable_columns ) ) {
960 960
 			// 	$sort_key = esc_html( $_GET['orderby'] );
961 961
 			// } // End If Statement
962
-			if ( '' != $sort_key ) {
963
-					WooThemes_Sensei_Utils::sort_array_by_key($return_array,$sort_key);
964
-				if ( isset( $_GET['order'] ) && 'desc' == esc_html( $_GET['order'] ) ) {
965
-					$return_array = array_reverse( $return_array, true );
962
+			if ('' != $sort_key) {
963
+					WooThemes_Sensei_Utils::sort_array_by_key($return_array, $sort_key);
964
+				if (isset($_GET['order']) && 'desc' == esc_html($_GET['order'])) {
965
+					$return_array = array_reverse($return_array, true);
966 966
 				} // End If Statement
967 967
 			} // End If Statement
968 968
 			return $return_array;
@@ -978,15 +978,15 @@  discard block
 block discarded – undo
978 978
 	 * @param  $key string column name in array
979 979
 	 * @return void
980 980
 	 */
981
-	public static function sort_array_by_key( $array, $key ) {
981
+	public static function sort_array_by_key($array, $key) {
982 982
 	    $sorter = array();
983 983
 	    $ret = array();
984
-	    reset( $array );
985
-	    foreach ( $array as $ii => $va ) {
984
+	    reset($array);
985
+	    foreach ($array as $ii => $va) {
986 986
 	        $sorter[$ii] = $va[$key];
987 987
 	    } // End For Loop
988
-	    asort( $sorter );
989
-	    foreach ( $sorter as $ii => $va ) {
988
+	    asort($sorter);
989
+	    foreach ($sorter as $ii => $va) {
990 990
 	        $ret[$ii] = $array[$ii];
991 991
 	    } // End For Loop
992 992
 	    $array = $ret;
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 	 * @param  integer $quiz_id
999 999
 	 * @return array of quiz questions
1000 1000
 	 */
1001
-	public static function lesson_quiz_questions( $quiz_id = 0 ) {
1001
+	public static function lesson_quiz_questions($quiz_id = 0) {
1002 1002
 		$questions_array = array();
1003
-		if ( 0 < $quiz_id ) {
1004
-			$question_args = array( 'post_type'         => 'question',
1003
+		if (0 < $quiz_id) {
1004
+			$question_args = array('post_type'         => 'question',
1005 1005
                                     'posts_per_page'       => -1,
1006 1006
                                     'orderby'           => 'ID',
1007 1007
                                     'order'             => 'ASC',
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
                                     'post_status'       => 'any',
1015 1015
                                     'suppress_filters'  => 0
1016 1016
                                 );
1017
-            $questions_array = get_posts( $question_args );
1017
+            $questions_array = get_posts($question_args);
1018 1018
         } // End If Statement
1019 1019
         return $questions_array;
1020 1020
 	} // End lesson_quiz_questions()
@@ -1024,25 +1024,25 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  integer $course_id ID of course
1025 1025
 	 * @return integer            Pass mark for course
1026 1026
 	 */
1027
-	public static function sensei_course_pass_grade( $course_id = 0 ) {
1027
+	public static function sensei_course_pass_grade($course_id = 0) {
1028 1028
 
1029 1029
 
1030 1030
 		$course_passmark = 0;
1031 1031
 
1032
-		if( $course_id > 0 ) {
1033
-			$lessons = Sensei()->course->course_lessons( $course_id );
1032
+		if ($course_id > 0) {
1033
+			$lessons = Sensei()->course->course_lessons($course_id);
1034 1034
 			$lesson_count = 0;
1035 1035
 			$total_passmark = 0;
1036
-			foreach( $lessons as $lesson ) {
1036
+			foreach ($lessons as $lesson) {
1037 1037
 
1038 1038
 				// Get Quiz ID
1039
-				$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID );
1039
+				$quiz_id = Sensei()->lesson->lesson_quizzes($lesson->ID);
1040 1040
 
1041 1041
 				// Check for a pass being required
1042
-				$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1043
-				if ( $pass_required ) {
1042
+				$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1043
+				if ($pass_required) {
1044 1044
 					// Get quiz passmark
1045
-					$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
1045
+					$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
1046 1046
 
1047 1047
 					// Add up total passmark
1048 1048
 					$total_passmark += $quiz_passmark;
@@ -1051,12 +1051,12 @@  discard block
 block discarded – undo
1051 1051
 				}
1052 1052
 			}
1053 1053
 			// Might be a case of no required lessons
1054
-			if ( $lesson_count ) {
1055
-				$course_passmark = ( $total_passmark / $lesson_count );
1054
+			if ($lesson_count) {
1055
+				$course_passmark = ($total_passmark / $lesson_count);
1056 1056
 			}
1057 1057
 		}
1058 1058
 
1059
-		return Woothemes_Sensei_Utils::round( $course_passmark );
1059
+		return Woothemes_Sensei_Utils::round($course_passmark);
1060 1060
 	}
1061 1061
 
1062 1062
 	/**
@@ -1065,27 +1065,27 @@  discard block
 block discarded – undo
1065 1065
 	 * @param  integer $user_id   ID of user
1066 1066
 	 * @return integer            User's total grade
1067 1067
 	 */
1068
-	public static function sensei_course_user_grade( $course_id = 0, $user_id = 0 ) {
1068
+	public static function sensei_course_user_grade($course_id = 0, $user_id = 0) {
1069 1069
 
1070 1070
 
1071
-		if( intval( $user_id ) == 0 ) {
1071
+		if (intval($user_id) == 0) {
1072 1072
 			$user_id = get_current_user_id();
1073 1073
 		}
1074 1074
 
1075 1075
 		$total_grade = 0;
1076 1076
 
1077
-		if( $course_id > 0 && $user_id > 0 ) {
1078
-			$lessons = Sensei()->course->course_lessons( $course_id );
1077
+		if ($course_id > 0 && $user_id > 0) {
1078
+			$lessons = Sensei()->course->course_lessons($course_id);
1079 1079
 			$lesson_count = 0;
1080 1080
 			$total_grade = 0;
1081
-			foreach( $lessons as $lesson ) {
1081
+			foreach ($lessons as $lesson) {
1082 1082
 
1083 1083
 				// Check for lesson having questions, thus a quiz, thus having a grade
1084
-				$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
1085
-				if ( $has_questions ) {
1086
-					$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson->ID, $user_id );
1084
+				$has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
1085
+				if ($has_questions) {
1086
+					$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson->ID, $user_id);
1087 1087
 					// Get user quiz grade
1088
-					$quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1088
+					$quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1089 1089
 
1090 1090
 					// Add up total grade
1091 1091
 					$total_grade += $quiz_grade;
@@ -1095,13 +1095,13 @@  discard block
 block discarded – undo
1095 1095
 			}
1096 1096
 
1097 1097
 			// Might be a case of no lessons with quizzes
1098
-			if ( $lesson_count ) {
1099
-				$total_grade = ( $total_grade / $lesson_count );
1098
+			if ($lesson_count) {
1099
+				$total_grade = ($total_grade / $lesson_count);
1100 1100
 			}
1101 1101
 
1102 1102
 		}
1103 1103
 
1104
-		return WooThemes_Sensei_Utils::round( $total_grade );
1104
+		return WooThemes_Sensei_Utils::round($total_grade);
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1110,18 +1110,18 @@  discard block
 block discarded – undo
1110 1110
 	 * @param  integer $user_id   ID of user
1111 1111
 	 * @return boolean
1112 1112
 	 */
1113
-	public static function sensei_user_passed_course( $course_id = 0, $user_id = 0 ) {
1114
-		if( intval( $user_id ) == 0 ) {
1113
+	public static function sensei_user_passed_course($course_id = 0, $user_id = 0) {
1114
+		if (intval($user_id) == 0) {
1115 1115
 			$user_id = get_current_user_id();
1116 1116
 		}
1117 1117
 
1118 1118
 		$pass = false;
1119 1119
 
1120
-		if( $course_id > 0 && $user_id > 0 ) {
1121
-			$passmark = WooThemes_Sensei_Utils::sensei_course_pass_grade( $course_id );
1122
-			$user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade( $course_id, $user_id );
1120
+		if ($course_id > 0 && $user_id > 0) {
1121
+			$passmark = WooThemes_Sensei_Utils::sensei_course_pass_grade($course_id);
1122
+			$user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($course_id, $user_id);
1123 1123
 
1124
-			if( $user_grade >= $passmark ) {
1124
+			if ($user_grade >= $passmark) {
1125 1125
 				$pass = true;
1126 1126
 			}
1127 1127
 		}
@@ -1136,38 +1136,38 @@  discard block
 block discarded – undo
1136 1136
 	 * @param  integer $user_id   ID of user
1137 1137
 	 * @return array              Status code and message
1138 1138
 	 */
1139
-	public static function sensei_user_course_status_message( $course_id = 0, $user_id = 0 ) {
1140
-		if( intval( $user_id ) == 0 ) {
1139
+	public static function sensei_user_course_status_message($course_id = 0, $user_id = 0) {
1140
+		if (intval($user_id) == 0) {
1141 1141
 			$user_id = get_current_user_id();
1142 1142
 		}
1143 1143
 
1144 1144
 		$status = 'not_started';
1145 1145
 		$box_class = 'info';
1146
-		$message = __( 'You have not started this course yet.', 'woothemes-sensei' );
1146
+		$message = __('You have not started this course yet.', 'woothemes-sensei');
1147 1147
 
1148
-		if( $course_id > 0 && $user_id > 0 ) {
1148
+		if ($course_id > 0 && $user_id > 0) {
1149 1149
 
1150
-			$started_course = WooThemes_Sensei_Utils::user_started_course( $course_id, $user_id );
1150
+			$started_course = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
1151 1151
 
1152
-			if( $started_course ) {
1153
-				$passmark = WooThemes_Sensei_Utils::sensei_course_pass_grade( $course_id ); // This happens inside sensei_user_passed_course()!
1154
-				$user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); // This happens inside sensei_user_passed_course()!
1155
-				if( $user_grade >= $passmark ) {
1152
+			if ($started_course) {
1153
+				$passmark = WooThemes_Sensei_Utils::sensei_course_pass_grade($course_id); // This happens inside sensei_user_passed_course()!
1154
+				$user_grade = WooThemes_Sensei_Utils::sensei_course_user_grade($course_id, $user_id); // This happens inside sensei_user_passed_course()!
1155
+				if ($user_grade >= $passmark) {
1156 1156
 					$status = 'passed';
1157 1157
 					$box_class = 'tick';
1158
-					$message = sprintf( __( 'You have passed this course with a grade of %1$d%%.', 'woothemes-sensei' ), $user_grade );
1158
+					$message = sprintf(__('You have passed this course with a grade of %1$d%%.', 'woothemes-sensei'), $user_grade);
1159 1159
 				} else {
1160 1160
 					$status = 'failed';
1161 1161
 					$box_class = 'alert';
1162
-					$message = sprintf( __( 'You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei' ), $passmark, $user_grade );
1162
+					$message = sprintf(__('You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei'), $passmark, $user_grade);
1163 1163
 				}
1164 1164
 			}
1165 1165
 
1166 1166
 		}
1167 1167
 
1168
-		$message = apply_filters( 'sensei_user_course_status_' . $status, $message );
1168
+		$message = apply_filters('sensei_user_course_status_'.$status, $message);
1169 1169
 
1170
-		return array( 'status' => $status, 'box_class' => $box_class, 'message' => $message );
1170
+		return array('status' => $status, 'box_class' => $box_class, 'message' => $message);
1171 1171
 	}
1172 1172
 
1173 1173
 	/**
@@ -1176,94 +1176,94 @@  discard block
 block discarded – undo
1176 1176
 	 * @param  integer $user_id   ID of user
1177 1177
 	 * @return array              Status code and message
1178 1178
 	 */
1179
-	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) {
1179
+	public static function sensei_user_quiz_status_message($lesson_id = 0, $user_id = 0, $is_lesson = false) {
1180 1180
 		global  $current_user;
1181
-		if( intval( $user_id ) == 0 ) {
1181
+		if (intval($user_id) == 0) {
1182 1182
 			$user_id = $current_user->ID;
1183 1183
 		}
1184 1184
 
1185 1185
 		$status = 'not_started';
1186 1186
 		$box_class = 'info';
1187
-		$message = __( "You have not taken this lesson's quiz yet", 'woothemes-sensei' );
1187
+		$message = __("You have not taken this lesson's quiz yet", 'woothemes-sensei');
1188 1188
 		$extra = '';
1189 1189
 
1190
-		if( $lesson_id > 0 && $user_id > 0 ) {
1190
+		if ($lesson_id > 0 && $user_id > 0) {
1191 1191
 
1192 1192
 			// Prerequisite lesson
1193
-			$prerequisite = get_post_meta( $lesson_id, '_lesson_prerequisite', true );
1193
+			$prerequisite = get_post_meta($lesson_id, '_lesson_prerequisite', true);
1194 1194
 
1195 1195
 			// Course ID
1196
-			$course_id = absint( get_post_meta( $lesson_id, '_lesson_course', true ) );
1196
+			$course_id = absint(get_post_meta($lesson_id, '_lesson_course', true));
1197 1197
 
1198 1198
 			// Has user started course
1199
-			$started_course = WooThemes_Sensei_Utils::user_started_course( $course_id, $user_id );
1199
+			$started_course = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
1200 1200
 
1201 1201
 			// Has user completed lesson
1202
-			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1203
-			$lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson( $user_lesson_status );
1202
+			$user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1203
+			$lesson_complete = WooThemes_Sensei_Utils::user_completed_lesson($user_lesson_status);
1204 1204
 
1205 1205
 			// Quiz ID
1206
-			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1206
+			$quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1207 1207
 
1208 1208
 			// Quiz grade
1209 1209
 			$quiz_grade = 0;
1210
-			if ( $user_lesson_status ) {
1211
-				$quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1210
+			if ($user_lesson_status) {
1211
+				$quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1212 1212
 			}
1213 1213
 
1214 1214
 			// Quiz passmark
1215
-			$quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) );
1215
+			$quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true));
1216 1216
 			$quiz_passmark_float = (float) $quiz_passmark;
1217 1217
 
1218 1218
 			// Pass required
1219
-			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1219
+			$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1220 1220
 
1221 1221
 			// Quiz questions
1222
-			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
1222
+			$has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
1223 1223
 
1224
-			if ( ! $started_course ) {
1224
+			if ( ! $started_course) {
1225 1225
 
1226 1226
 				$status = 'not_started_course';
1227 1227
 				$box_class = 'info';
1228
-				$message = sprintf( __( 'Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . esc_attr( __( 'Sign Up', 'woothemes-sensei' ) ) . '">', '</a>' );
1228
+				$message = sprintf(__('Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.esc_attr(__('Sign Up', 'woothemes-sensei')).'">', '</a>');
1229 1229
 
1230
-			} elseif ( ! is_user_logged_in() ) {
1230
+			} elseif ( ! is_user_logged_in()) {
1231 1231
 
1232 1232
 				$status = 'login_required';
1233 1233
 				$box_class = 'info';
1234
-				$message = __( 'You must be logged in to take this quiz', 'woothemes-sensei' );
1234
+				$message = __('You must be logged in to take this quiz', 'woothemes-sensei');
1235 1235
 
1236 1236
 			}
1237 1237
 			// Lesson/Quiz is marked as complete thus passing any quiz restrictions
1238
-			elseif ( $lesson_complete ) {
1238
+			elseif ($lesson_complete) {
1239 1239
 
1240 1240
 				$status = 'passed';
1241 1241
 				$box_class = 'tick';
1242 1242
 				// Lesson status will be "complete" (has no Quiz)
1243
-				if ( ! $has_quiz_questions ) {
1244
-					$message = sprintf( __( 'Congratulations! You have passed this lesson.', 'woothemes-sensei' ) );
1243
+				if ( ! $has_quiz_questions) {
1244
+					$message = sprintf(__('Congratulations! You have passed this lesson.', 'woothemes-sensei'));
1245 1245
 				}
1246 1246
 				// Lesson status will be "graded" (no passmark required so might have failed all the questions)
1247
-				elseif ( empty( $quiz_grade ) ) {
1248
-					$message = sprintf( __( 'Congratulations! You have completed this lesson.', 'woothemes-sensei' ) );
1247
+				elseif (empty($quiz_grade)) {
1248
+					$message = sprintf(__('Congratulations! You have completed this lesson.', 'woothemes-sensei'));
1249 1249
 				}
1250 1250
 				// Lesson status will be "passed" (passmark reached)
1251
-				elseif ( ! empty( $quiz_grade ) && abs( $quiz_grade ) >= 0 ) {
1252
-					if( $is_lesson ) {
1253
-						$message = sprintf( __( 'Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei' ), WooThemes_Sensei_Utils::round( $quiz_grade ) );
1251
+				elseif ( ! empty($quiz_grade) && abs($quiz_grade) >= 0) {
1252
+					if ($is_lesson) {
1253
+						$message = sprintf(__('Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_grade));
1254 1254
 					} else {
1255
-						$message = sprintf( __( 'Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_grade ) );
1255
+						$message = sprintf(__('Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_grade));
1256 1256
 					}
1257 1257
 				}
1258 1258
 
1259 1259
                 // add next lesson button
1260
-                $nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1261
-                $next_lesson_id = absint( $nav_id_array['next_lesson'] );
1260
+                $nav_id_array = sensei_get_prev_next_lessons($lesson_id);
1261
+                $next_lesson_id = absint($nav_id_array['next_lesson']);
1262 1262
 
1263 1263
                 // Output HTML
1264
-                if ( ( 0 < $next_lesson_id ) ) {
1265
-                    $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1266
-                                . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1264
+                if ((0 < $next_lesson_id)) {
1265
+                    $message .= ' '.'<a class="next-lesson" href="'.esc_url(get_permalink($next_lesson_id))
1266
+                                . '" rel="next"><span class="meta-nav"></span>'.__('Next Lesson', 'woothemes-sensei')
1267 1267
                                 .'</a>';
1268 1268
 
1269 1269
                 }
@@ -1272,33 +1272,33 @@  discard block
 block discarded – undo
1272 1272
             // Lesson/Quiz not complete
1273 1273
 			else {
1274 1274
 				// Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
1275
-				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) {
1275
+				if (isset($user_lesson_status->comment_approved) && 'ungraded' == $user_lesson_status->comment_approved) {
1276 1276
 					$status = 'complete';
1277 1277
 					$box_class = 'info';
1278
-					if( $is_lesson ) {
1279
-						$message = sprintf( __( 'You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . esc_attr( get_the_title( $quiz_id ) ) . '">', '</a>' );
1278
+					if ($is_lesson) {
1279
+						$message = sprintf(__('You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($quiz_id)).'" title="'.esc_attr(get_the_title($quiz_id)).'">', '</a>');
1280 1280
 					} else {
1281
-						$message = sprintf( __( 'You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_passmark ) );
1281
+						$message = sprintf(__('You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
1282 1282
 					}
1283 1283
 				}
1284 1284
 				// Lesson status must be "failed"
1285
-				elseif ( isset( $user_lesson_status->comment_approved ) && 'failed' == $user_lesson_status->comment_approved ) {
1285
+				elseif (isset($user_lesson_status->comment_approved) && 'failed' == $user_lesson_status->comment_approved) {
1286 1286
 					$status = 'failed';
1287 1287
 					$box_class = 'alert';
1288
-					if( $is_lesson ) {
1289
-						$message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_passmark ),  WooThemes_Sensei_Utils::round( $quiz_grade ) );
1288
+					if ($is_lesson) {
1289
+						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark), WooThemes_Sensei_Utils::round($quiz_grade));
1290 1290
 					} else {
1291
-						$message = sprintf( __( 'You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_passmark ),  WooThemes_Sensei_Utils::round( $quiz_grade ) );
1291
+						$message = sprintf(__('You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark), WooThemes_Sensei_Utils::round($quiz_grade));
1292 1292
 					}
1293 1293
 				}
1294 1294
 				// Lesson/Quiz requires a pass
1295
-				elseif( $pass_required ) {
1295
+				elseif ($pass_required) {
1296 1296
 					$status = 'not_started';
1297 1297
 					$box_class = 'info';
1298
-					if( $is_lesson ) {
1299
-						$message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_passmark ) );
1298
+					if ($is_lesson) {
1299
+						$message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
1300 1300
 					} else {
1301
-						$message = sprintf( __( 'You require %1$d%% to pass this quiz.', 'woothemes-sensei' ),  WooThemes_Sensei_Utils::round( $quiz_passmark ) );
1301
+						$message = sprintf(__('You require %1$d%% to pass this quiz.', 'woothemes-sensei'), WooThemes_Sensei_Utils::round($quiz_passmark));
1302 1302
 					}
1303 1303
 				}
1304 1304
 			}
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 		}
1307 1307
 
1308 1308
 		// Legacy filter
1309
-		$message = apply_filters( 'sensei_user_quiz_status_' . $status, $message );
1309
+		$message = apply_filters('sensei_user_quiz_status_'.$status, $message);
1310 1310
 
1311
-		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) {
1312
-			$extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' .  __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' .  __( 'View the lesson quiz', 'woothemes-sensei' )  . '</a></p>';
1311
+		if ($is_lesson && ! in_array($status, array('login_required', 'not_started_course'))) {
1312
+			$extra = '<p><a class="button" href="'.esc_url(get_permalink($quiz_id)).'" title="'.__('View the lesson quiz', 'woothemes-sensei').'">'.__('View the lesson quiz', 'woothemes-sensei').'</a></p>';
1313 1313
 		}
1314 1314
 
1315 1315
 		// Filter of all messages
1316
-		return apply_filters( 'sensei_user_quiz_status', array( 'status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra ), $lesson_id, $user_id, $is_lesson );
1316
+		return apply_filters('sensei_user_quiz_status', array('status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra), $lesson_id, $user_id, $is_lesson);
1317 1317
 	}
1318 1318
 
1319 1319
 	/**
@@ -1323,14 +1323,14 @@  discard block
 block discarded – undo
1323 1323
 	 * @param  integer $course_id Course ID
1324 1324
 	 * @return mixed boolean or comment_ID
1325 1325
 	 */
1326
-	public static function user_start_course( $user_id = 0, $course_id = 0 ) {
1326
+	public static function user_start_course($user_id = 0, $course_id = 0) {
1327 1327
 
1328 1328
 		$activity_logged = false;
1329 1329
 
1330
-		if( $user_id && $course_id ) {
1330
+		if ($user_id && $course_id) {
1331 1331
 			// Check if user is already on the Course
1332
-			$activity_logged = WooThemes_Sensei_Utils::user_started_course( $course_id, $user_id );
1333
-			if ( ! $activity_logged ) {
1332
+			$activity_logged = WooThemes_Sensei_Utils::user_started_course($course_id, $user_id);
1333
+			if ( ! $activity_logged) {
1334 1334
 
1335 1335
 				// Add user to course
1336 1336
 				$course_metadata = array(
@@ -1339,11 +1339,11 @@  discard block
 block discarded – undo
1339 1339
 					'complete' => 0,
1340 1340
 				);
1341 1341
 
1342
-				$activity_logged = WooThemes_Sensei_Utils::update_course_status( $user_id, $course_id, $course_status = 'in-progress', $course_metadata );
1342
+				$activity_logged = WooThemes_Sensei_Utils::update_course_status($user_id, $course_id, $course_status = 'in-progress', $course_metadata);
1343 1343
 
1344 1344
 				// Allow further actions
1345
-				if ( $activity_logged ) {
1346
-					do_action( 'sensei_user_course_start', $user_id, $course_id );
1345
+				if ($activity_logged) {
1346
+					do_action('sensei_user_course_start', $user_id, $course_id);
1347 1347
 				}
1348 1348
 			}
1349 1349
 		}
@@ -1359,19 +1359,19 @@  discard block
 block discarded – undo
1359 1359
 	 * @param type $user_id
1360 1360
 	 * @return mixed false or comment_ID
1361 1361
 	 */
1362
-	public static function user_started_course( $course_id = 0, $user_id = 0 ) {
1362
+	public static function user_started_course($course_id = 0, $user_id = 0) {
1363 1363
 
1364
-		if( $course_id ) {
1365
-			if( ! $user_id ) {
1364
+		if ($course_id) {
1365
+			if ( ! $user_id) {
1366 1366
 				$user_id = get_current_user_id();
1367 1367
 			}
1368 1368
 
1369
-            if( ! $user_id > 0 ){
1369
+            if ( ! $user_id > 0) {
1370 1370
                 return false;
1371 1371
             }
1372 1372
 
1373
-			$user_course_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) );
1374
-			if( $user_course_status_id ) {
1373
+			$user_course_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID'));
1374
+			if ($user_course_status_id) {
1375 1375
 				return $user_course_status_id;
1376 1376
 			}
1377 1377
 		}
@@ -1386,17 +1386,17 @@  discard block
 block discarded – undo
1386 1386
 	 * @param  integer $user_id   User ID
1387 1387
 	 * @return int
1388 1388
 	 */
1389
-	public static function user_complete_course( $course_id = 0, $user_id = 0 ) {
1389
+	public static function user_complete_course($course_id = 0, $user_id = 0) {
1390 1390
 		global  $wp_version;
1391 1391
 
1392
-		if( $course_id ) {
1393
-			if( ! $user_id ) {
1392
+		if ($course_id) {
1393
+			if ( ! $user_id) {
1394 1394
 				$user_id = get_current_user_id();
1395 1395
 			}
1396 1396
 
1397 1397
 			$course_status = 'in-progress';
1398 1398
 			$course_metadata = array();
1399
-			$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1399
+			$course_completion = Sensei()->settings->settings['course_completion'];
1400 1400
 			$lessons_completed = $total_lessons = 0;
1401 1401
 			$lesson_status_args = array(
1402 1402
 					'user_id' => $user_id,
@@ -1405,8 +1405,8 @@  discard block
 block discarded – undo
1405 1405
 				);
1406 1406
 
1407 1407
 			// Grab all of this Courses' lessons, looping through each...
1408
-			$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
1409
-			$total_lessons = count( $lesson_ids );
1408
+			$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
1409
+			$total_lessons = count($lesson_ids);
1410 1410
 				// ...if course completion not set to 'passed', and all lessons are complete or graded,
1411 1411
 				// ......then all lessons are 'passed'
1412 1412
 				// ...else if course completion is set to 'passed', check if each lesson has questions...
@@ -1419,29 +1419,29 @@  discard block
 block discarded – undo
1419 1419
 			// The below checks if a lesson is fully completed, though maybe should be Utils::user_completed_lesson()
1420 1420
 			$all_lesson_statuses = array();
1421 1421
 			// In WordPress 4.1 get_comments() allows a single query to cover multiple comment_post_IDs
1422
-			if ( version_compare($wp_version, '4.1', '>=') ) {
1422
+			if (version_compare($wp_version, '4.1', '>=')) {
1423 1423
 				$lesson_status_args['post__in'] = $lesson_ids;
1424
-				$all_lesson_statuses = WooThemes_Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true );
1424
+				$all_lesson_statuses = WooThemes_Sensei_Utils::sensei_check_for_activity($lesson_status_args, true);
1425 1425
 				// Need to always return an array, even with only 1 item
1426
-				if ( !is_array($all_lesson_statuses) ) {
1427
-					$all_lesson_statuses = array( $all_lesson_statuses );
1426
+				if ( ! is_array($all_lesson_statuses)) {
1427
+					$all_lesson_statuses = array($all_lesson_statuses);
1428 1428
 				}
1429 1429
 			}
1430 1430
 			// ...otherwise check each one
1431 1431
 			else {
1432
-				foreach( $lesson_ids as $lesson_id ) {
1432
+				foreach ($lesson_ids as $lesson_id) {
1433 1433
 					$lesson_status_args['post_id'] = $lesson_id;
1434
-					$each_lesson_status = WooThemes_Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true );
1434
+					$each_lesson_status = WooThemes_Sensei_Utils::sensei_check_for_activity($lesson_status_args, true);
1435 1435
 					// Check for valid return before using
1436
-					if ( !empty($each_lesson_status->comment_approved) ) {
1436
+					if ( ! empty($each_lesson_status->comment_approved)) {
1437 1437
 						$all_lesson_statuses[] = $each_lesson_status;
1438 1438
 					}
1439 1439
 				}
1440 1440
 			}
1441
-			foreach( $all_lesson_statuses as $lesson_status ) {
1441
+			foreach ($all_lesson_statuses as $lesson_status) {
1442 1442
 				// If lessons are complete without needing quizzes to be passed
1443
-				if ( 'passed' != $course_completion ) {
1444
-					switch ( $lesson_status->comment_approved ) {
1443
+				if ('passed' != $course_completion) {
1444
+					switch ($lesson_status->comment_approved) {
1445 1445
 						// A user cannot 'complete' a course if a lesson...
1446 1446
 						case 'in-progress': // ...is still in progress
1447 1447
 						case 'ungraded': // ...hasn't yet been graded
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 					}
1454 1454
 				}
1455 1455
 				else {
1456
-					switch ( $lesson_status->comment_approved ) {
1456
+					switch ($lesson_status->comment_approved) {
1457 1457
 						case 'complete': // Lesson has no quiz/questions
1458 1458
 						case 'graded': // Lesson has quiz, but it's not important what the grade was
1459 1459
 						case 'passed': // Lesson has quiz and the user passed
@@ -1467,20 +1467,20 @@  discard block
 block discarded – undo
1467 1467
 					}
1468 1468
 				}
1469 1469
 			} // Each lesson
1470
-			if ( $lessons_completed == $total_lessons ) {
1470
+			if ($lessons_completed == $total_lessons) {
1471 1471
 				$course_status = 'complete';
1472 1472
 			}
1473 1473
 
1474 1474
 			// Update meta data on how many lessons have been completed
1475 1475
 			$course_metadata['complete'] = $lessons_completed;
1476 1476
 			// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1477
-			$course_metadata['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1477
+			$course_metadata['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1478 1478
 
1479
-			$activity_logged = WooThemes_Sensei_Utils::update_course_status( $user_id, $course_id, $course_status, $course_metadata );
1479
+			$activity_logged = WooThemes_Sensei_Utils::update_course_status($user_id, $course_id, $course_status, $course_metadata);
1480 1480
 
1481 1481
 			// Allow further actions
1482
-			if ( 'complete' == $course_status ) {
1483
-				do_action( 'sensei_user_course_end', $user_id, $course_id );
1482
+			if ('complete' == $course_status) {
1483
+				do_action('sensei_user_course_end', $user_id, $course_id);
1484 1484
 			}
1485 1485
 			return $activity_logged;
1486 1486
 		}
@@ -1495,31 +1495,31 @@  discard block
 block discarded – undo
1495 1495
 	 * @param int $user_id
1496 1496
 	 * @return boolean
1497 1497
 	 */
1498
-	public static function user_completed_course( $course = 0, $user_id = 0 ) {
1498
+	public static function user_completed_course($course = 0, $user_id = 0) {
1499 1499
 
1500
-		if( $course ) {
1501
-			if ( is_object( $course ) && is_a( $course,'WP_Comment') ) {
1500
+		if ($course) {
1501
+			if (is_object($course) && is_a($course, 'WP_Comment')) {
1502 1502
 				$user_course_status = $course->comment_approved;
1503 1503
 			}
1504
-			elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) {
1504
+			elseif ( ! is_numeric($course) && ! is_a($course, 'WP_Post')) {
1505 1505
 				$user_course_status = $course;
1506 1506
 			}
1507 1507
 			else {
1508
-				if( ! $user_id ) {
1508
+				if ( ! $user_id) {
1509 1509
 					$user_id = get_current_user_id();
1510 1510
 				}
1511 1511
 
1512
-                if( is_a( $course, 'WP_Post' ) ){
1513
-                    $course =   $course->ID;
1512
+                if (is_a($course, 'WP_Post')) {
1513
+                    $course = $course->ID;
1514 1514
                 }
1515 1515
 
1516
-				$user_course_status = WooThemes_Sensei_Utils::user_course_status( $course , $user_id );
1517
-				if( isset( $user_course_status->comment_approved ) ){
1516
+				$user_course_status = WooThemes_Sensei_Utils::user_course_status($course, $user_id);
1517
+				if (isset($user_course_status->comment_approved)) {
1518 1518
                     $user_course_status = $user_course_status->comment_approved;
1519 1519
                 }
1520 1520
 
1521 1521
 			}
1522
-			if( $user_course_status && 'complete' == $user_course_status ) {
1522
+			if ($user_course_status && 'complete' == $user_course_status) {
1523 1523
 				return true;
1524 1524
 			}
1525 1525
 		}
@@ -1534,15 +1534,15 @@  discard block
 block discarded – undo
1534 1534
 	 * @param type $user_id
1535 1535
 	 * @return mixed false or comment_ID
1536 1536
 	 */
1537
-	public static function user_started_lesson( $lesson_id = 0, $user_id = 0 ) {
1537
+	public static function user_started_lesson($lesson_id = 0, $user_id = 0) {
1538 1538
 
1539
-		if( $lesson_id ) {
1540
-			if( ! $user_id ) {
1539
+		if ($lesson_id) {
1540
+			if ( ! $user_id) {
1541 1541
 				$user_id = get_current_user_id();
1542 1542
 			}
1543 1543
 
1544
-			$user_lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID' ) );
1545
-			if( $user_lesson_status_id ) {
1544
+			$user_lesson_status_id = WooThemes_Sensei_Utils::sensei_get_activity_value(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status', 'field' => 'comment_ID'));
1545
+			if ($user_lesson_status_id) {
1546 1546
 				return $user_lesson_status_id;
1547 1547
 			}
1548 1548
 		}
@@ -1557,29 +1557,29 @@  discard block
 block discarded – undo
1557 1557
 	 * @param int $user_id
1558 1558
 	 * @return boolean
1559 1559
 	 */
1560
-	public static function user_completed_lesson( $lesson = 0, $user_id = 0 ) {
1560
+	public static function user_completed_lesson($lesson = 0, $user_id = 0) {
1561 1561
 
1562
-		if( $lesson ) {
1562
+		if ($lesson) {
1563 1563
 			$lesson_id = 0;
1564
-			if ( is_object( $lesson ) ) {
1564
+			if (is_object($lesson)) {
1565 1565
 				$user_lesson_status = $lesson->comment_approved;
1566 1566
 				$lesson_id = $lesson->comment_post_ID;
1567 1567
 			}
1568
-			elseif ( ! is_numeric( $lesson ) ) {
1568
+			elseif ( ! is_numeric($lesson)) {
1569 1569
 				$user_lesson_status = $lesson;
1570 1570
 			}
1571 1571
 			else {
1572
-				if( ! $user_id ) {
1572
+				if ( ! $user_id) {
1573 1573
 					$user_id = get_current_user_id();
1574 1574
 				}
1575 1575
 
1576 1576
                 // the user is not logged in
1577
-                if( ! $user_id > 0 ){
1577
+                if ( ! $user_id > 0) {
1578 1578
                     return false;
1579 1579
                 }
1580
-				$_user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson, $user_id );
1580
+				$_user_lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson, $user_id);
1581 1581
 
1582
-				if ( $_user_lesson_status ) {
1582
+				if ($_user_lesson_status) {
1583 1583
 					$user_lesson_status = $_user_lesson_status->comment_approved;
1584 1584
 				}
1585 1585
 				else {
@@ -1587,12 +1587,12 @@  discard block
 block discarded – undo
1587 1587
 				}
1588 1588
 				$lesson_id = $lesson;
1589 1589
 			}
1590
-			if ( 'in-progress' != $user_lesson_status ) {
1590
+			if ('in-progress' != $user_lesson_status) {
1591 1591
 				// Check for Passed or Completed Setting
1592 1592
 				// Should we be checking for the Course completion setting? Surely that should only affect the Course completion, not bypass each Lesson setting
1593 1593
 //				$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1594 1594
 //				if ( 'passed' == $course_completion ) {
1595
-					switch( $user_lesson_status ) {
1595
+					switch ($user_lesson_status) {
1596 1596
 						case 'complete':
1597 1597
 						case 'graded':
1598 1598
 						case 'passed':
@@ -1601,13 +1601,13 @@  discard block
 block discarded – undo
1601 1601
 
1602 1602
 						case 'failed':
1603 1603
 							// This may be 'completed' depending on...
1604
-							if ( $lesson_id ) {
1604
+							if ($lesson_id) {
1605 1605
 								// Get Quiz ID, this won't be needed once all Quiz meta fields are stored on the Lesson
1606
-								$lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1607
-								if ( $lesson_quiz_id ) {
1606
+								$lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1607
+								if ($lesson_quiz_id) {
1608 1608
 									// ...the quiz pass setting
1609
-									$pass_required = get_post_meta( $lesson_quiz_id, '_pass_required', true );
1610
-									if ( empty($pass_required) ) {
1609
+									$pass_required = get_post_meta($lesson_quiz_id, '_pass_required', true);
1610
+									if (empty($pass_required)) {
1611 1611
 										// We just require the user to have done the quiz, not to have passed
1612 1612
 										return true;
1613 1613
 									}
@@ -1630,15 +1630,15 @@  discard block
 block discarded – undo
1630 1630
 	 * @param type $user_id
1631 1631
 	 * @return object
1632 1632
 	 */
1633
-	public static function user_course_status( $course_id = 0, $user_id = 0 ) {
1633
+	public static function user_course_status($course_id = 0, $user_id = 0) {
1634 1634
 
1635 1635
 
1636
-		if( $course_id ) {
1637
-			if( ! $user_id ) {
1636
+		if ($course_id) {
1637
+			if ( ! $user_id) {
1638 1638
 				$user_id = get_current_user_id();
1639 1639
 			}
1640 1640
 
1641
-			$user_course_status = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status' ), true );
1641
+			$user_course_status = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status'), true);
1642 1642
 			return $user_course_status;
1643 1643
 		}
1644 1644
 
@@ -1653,27 +1653,27 @@  discard block
 block discarded – undo
1653 1653
 	 * @param int $user_id
1654 1654
 	 * @return object | bool
1655 1655
 	 */
1656
-	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1656
+	public static function user_lesson_status($lesson_id = 0, $user_id = 0) {
1657 1657
 
1658
-        if( ! $user_id ) {
1658
+        if ( ! $user_id) {
1659 1659
             $user_id = get_current_user_id();
1660 1660
         }
1661 1661
 
1662
-		if( $lesson_id > 0 && $user_id > 0 ) {
1662
+		if ($lesson_id > 0 && $user_id > 0) {
1663 1663
 
1664
-			$user_lesson_status = WooThemes_Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status' ), true );
1664
+			$user_lesson_status = WooThemes_Sensei_Utils::sensei_check_for_activity(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status'), true);
1665 1665
 			return $user_lesson_status;
1666 1666
 		}
1667 1667
 
1668 1668
 		return false;
1669 1669
 	}
1670 1670
 
1671
-	public static function is_preview_lesson( $lesson_id ) {
1671
+	public static function is_preview_lesson($lesson_id) {
1672 1672
 		$is_preview = false;
1673 1673
 
1674
-		if( 'lesson' == get_post_type( $lesson_id ) ) {
1675
-			$lesson_preview = get_post_meta( $lesson_id, '_lesson_preview', true );
1676
-			if ( isset( $lesson_preview ) && '' != $lesson_preview ) {
1674
+		if ('lesson' == get_post_type($lesson_id)) {
1675
+			$lesson_preview = get_post_meta($lesson_id, '_lesson_preview', true);
1676
+			if (isset($lesson_preview) && '' != $lesson_preview) {
1677 1677
 				$is_preview = true;
1678 1678
 			}
1679 1679
 		}
@@ -1681,22 +1681,22 @@  discard block
 block discarded – undo
1681 1681
 		return $is_preview;
1682 1682
 	}
1683 1683
 
1684
-	public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) {
1684
+	public static function user_passed_quiz($quiz_id = 0, $user_id = 0) {
1685 1685
 
1686
-		if( ! $quiz_id  ) return false;
1686
+		if ( ! $quiz_id) return false;
1687 1687
 
1688
-		if( ! $user_id ) {
1688
+		if ( ! $user_id) {
1689 1689
 			$user_id = get_current_user_id();
1690 1690
 		}
1691
-		$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1691
+		$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1692 1692
 
1693 1693
 		// Quiz Grade
1694
-		$lesson_status = WooThemes_Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1695
-		$quiz_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
1694
+		$lesson_status = WooThemes_Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1695
+		$quiz_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
1696 1696
 
1697 1697
 		// Check if Grade is greater than or equal to pass percentage
1698
-		$quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
1699
-		if ( $quiz_passmark <= intval( $quiz_grade ) ) {
1698
+		$quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
1699
+		if ($quiz_passmark <= intval($quiz_grade)) {
1700 1700
 			return true;
1701 1701
 		}
1702 1702
 
@@ -1716,9 +1716,9 @@  discard block
 block discarded – undo
1716 1716
      *
1717 1717
 	 * @return mixed false or comment_ID
1718 1718
 	 */
1719
-	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
1719
+	public static function update_lesson_status($user_id, $lesson_id, $status = 'in-progress', $metadata = array()) {
1720 1720
 		$comment_id = false;
1721
-		if ( !empty($status) ) {
1721
+		if ( ! empty($status)) {
1722 1722
 			$args = array(
1723 1723
 					'user_id'   => $user_id,
1724 1724
 					'post_id'   => $lesson_id,
@@ -1727,18 +1727,18 @@  discard block
 block discarded – undo
1727 1727
 					'action'    => 'update', // Update the existing status...
1728 1728
 					'keep_time' => true, // ...but don't change the existing timestamp
1729 1729
 				);
1730
-			if( 'in-progress' == $status ) {
1731
-				unset( $args['keep_time'] ); // Keep updating what's happened
1730
+			if ('in-progress' == $status) {
1731
+				unset($args['keep_time']); // Keep updating what's happened
1732 1732
 			}
1733 1733
 
1734
-			$comment_id = WooThemes_Sensei_Utils::sensei_log_activity( $args );
1735
-			if ( $comment_id && !empty($metadata) ) {
1736
-				foreach( $metadata as $key => $value ) {
1737
-					update_comment_meta( $comment_id, $key, $value );
1734
+			$comment_id = WooThemes_Sensei_Utils::sensei_log_activity($args);
1735
+			if ($comment_id && ! empty($metadata)) {
1736
+				foreach ($metadata as $key => $value) {
1737
+					update_comment_meta($comment_id, $key, $value);
1738 1738
 				}
1739 1739
 			}
1740 1740
 
1741
-			do_action( 'sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id );
1741
+			do_action('sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id);
1742 1742
 		}
1743 1743
 		return $comment_id;
1744 1744
 	}
@@ -1754,9 +1754,9 @@  discard block
 block discarded – undo
1754 1754
 	 * @param type $metadata
1755 1755
 	 * @return mixed false or comment_ID
1756 1756
 	 */
1757
-	public static function update_course_status( $user_id, $course_id, $status = 'in-progress', $metadata = array() ) {
1757
+	public static function update_course_status($user_id, $course_id, $status = 'in-progress', $metadata = array()) {
1758 1758
 		$comment_id = false;
1759
-		if ( !empty($status) ) {
1759
+		if ( ! empty($status)) {
1760 1760
 			$args = array(
1761 1761
 					'user_id'   => $user_id,
1762 1762
 					'post_id'   => $course_id,
@@ -1765,17 +1765,17 @@  discard block
 block discarded – undo
1765 1765
 					'action'    => 'update', // Update the existing status...
1766 1766
 					'keep_time' => true, // ...but don't change the existing timestamp
1767 1767
 				);
1768
-			if( 'in-progress' == $status ) {
1769
-				unset( $args['keep_time'] ); // Keep updating what's happened
1768
+			if ('in-progress' == $status) {
1769
+				unset($args['keep_time']); // Keep updating what's happened
1770 1770
 			}
1771 1771
 
1772
-			$comment_id = WooThemes_Sensei_Utils::sensei_log_activity( $args );
1773
-			if ( $comment_id && !empty($metadata) ) {
1774
-				foreach( $metadata as $key => $value ) {
1775
-					update_comment_meta( $comment_id, $key, $value );
1772
+			$comment_id = WooThemes_Sensei_Utils::sensei_log_activity($args);
1773
+			if ($comment_id && ! empty($metadata)) {
1774
+				foreach ($metadata as $key => $value) {
1775
+					update_comment_meta($comment_id, $key, $value);
1776 1776
 				}
1777 1777
 			}
1778
-			do_action( 'sensei_course_status_updated', $status, $user_id, $course_id, $comment_id );
1778
+			do_action('sensei_course_status_updated', $status, $user_id, $course_id, $comment_id);
1779 1779
 		}
1780 1780
 		return $comment_id;
1781 1781
 	}
@@ -1787,9 +1787,9 @@  discard block
 block discarded – undo
1787 1787
 	 * @param  array $pieces (default: array())
1788 1788
 	 * @return array
1789 1789
 	 */
1790
-	public static function single_comment_filter( $pieces ) {
1791
-		unset( $pieces['orderby'] );
1792
-		unset( $pieces['order'] );
1790
+	public static function single_comment_filter($pieces) {
1791
+		unset($pieces['orderby']);
1792
+		unset($pieces['order']);
1793 1793
 
1794 1794
 		return $pieces;
1795 1795
 	}
@@ -1801,9 +1801,9 @@  discard block
 block discarded – undo
1801 1801
 	 * @param  array $pieces (default: array())
1802 1802
 	 * @return array
1803 1803
 	 */
1804
-	public static function comment_any_status_filter( $pieces ) {
1804
+	public static function comment_any_status_filter($pieces) {
1805 1805
 
1806
-		$pieces['where'] = str_replace( array( "( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND" ), '', $pieces['where'] );
1806
+		$pieces['where'] = str_replace(array("( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND"), '', $pieces['where']);
1807 1807
 
1808 1808
 		return $pieces;
1809 1809
 	}
@@ -1815,12 +1815,12 @@  discard block
 block discarded – undo
1815 1815
 	 * @param  array $pieces (default: array())
1816 1816
 	 * @return array
1817 1817
 	 */
1818
-	public static function comment_multiple_status_filter( $pieces ) {
1818
+	public static function comment_multiple_status_filter($pieces) {
1819 1819
 
1820
-		preg_match( "/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder );
1821
-		if ( !empty($placeholder[1]) ) {
1822
-			$statuses = explode( ',', $placeholder[1] );
1823
-			$pieces['where'] = str_replace( "comment_approved = '" . $placeholder[1] . "'", "comment_approved IN ('". implode( "', '", $statuses ) . "')", $pieces['where'] );
1820
+		preg_match("/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder);
1821
+		if ( ! empty($placeholder[1])) {
1822
+			$statuses = explode(',', $placeholder[1]);
1823
+			$pieces['where'] = str_replace("comment_approved = '".$placeholder[1]."'", "comment_approved IN ('".implode("', '", $statuses)."')", $pieces['where']);
1824 1824
 		}
1825 1825
 
1826 1826
 		return $pieces;
@@ -1831,12 +1831,12 @@  discard block
 block discarded – undo
1831 1831
 	 * @since  1.7.0
1832 1832
 	 * @return array
1833 1833
 	 */
1834
-	public static function comment_total_sum_meta_value_filter( $pieces ) {
1834
+	public static function comment_total_sum_meta_value_filter($pieces) {
1835 1835
 		global $wpdb, $wp_version;
1836 1836
 
1837 1837
 		$pieces['fields'] = " COUNT(*) AS total, SUM($wpdb->commentmeta.meta_value) AS meta_sum ";
1838
-		unset( $pieces['groupby'] );
1839
-		if ( version_compare($wp_version, '4.1', '>=') ) {
1838
+		unset($pieces['groupby']);
1839
+		if (version_compare($wp_version, '4.1', '>=')) {
1840 1840
 			$args['order'] = false;
1841 1841
 			$args['orderby'] = false;
1842 1842
 		}
@@ -1851,12 +1851,12 @@  discard block
 block discarded – undo
1851 1851
 	 * @param  array $pieces (default: array())
1852 1852
 	 * @return array
1853 1853
 	 */
1854
-	public static function get_posts_count_only_filter( $pieces ) {
1854
+	public static function get_posts_count_only_filter($pieces) {
1855 1855
 		global $wp_version;
1856 1856
 
1857 1857
 		$pieces['fields'] = " COUNT(*) AS total ";
1858
-		unset( $pieces['groupby'] );
1859
-		if ( version_compare($wp_version, '4.1', '>=') ) {
1858
+		unset($pieces['groupby']);
1859
+		if (version_compare($wp_version, '4.1', '>=')) {
1860 1860
 			$args['order'] = false;
1861 1861
 			$args['orderby'] = false;
1862 1862
 		}
@@ -1875,9 +1875,9 @@  discard block
 block discarded – undo
1875 1875
      *
1876 1876
      * @return bool $success
1877 1877
      */
1878
-    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1878
+    public static function add_user_data($data_key, $post_id, $value = '', $user_id = 0) {
1879 1879
 
1880
-        return self::update_user_data( $data_key, $post_id, $value , $user_id );
1880
+        return self::update_user_data($data_key, $post_id, $value, $user_id);
1881 1881
 
1882 1882
     }// end add_user_data
1883 1883
 
@@ -1896,18 +1896,18 @@  discard block
 block discarded – undo
1896 1896
      *
1897 1897
      * @return bool $success
1898 1898
      */
1899
-    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1899
+    public static function update_user_data($data_key, $post_id, $value = '', $user_id = 0) {
1900 1900
 
1901
-        if( ! ( $user_id > 0 ) ){
1901
+        if ( ! ($user_id > 0)) {
1902 1902
             $user_id = get_current_user_id();
1903 1903
         }
1904 1904
 
1905
-        $supported_post_types = array( 'course', 'lesson' );
1906
-        $post_type = get_post_type( $post_id );
1907
-        if( empty( $post_id ) || empty( $data_key )
1908
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1909
-            || !get_userdata( $user_id )
1910
-            || ! in_array( $post_type, $supported_post_types )  ){
1905
+        $supported_post_types = array('course', 'lesson');
1906
+        $post_type = get_post_type($post_id);
1907
+        if (empty($post_id) || empty($data_key)
1908
+            || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
1909
+            || ! get_userdata($user_id)
1910
+            || ! in_array($post_type, $supported_post_types)) {
1911 1911
 
1912 1912
             return false;
1913 1913
         }
@@ -1915,20 +1915,20 @@  discard block
 block discarded – undo
1915 1915
         // check if there and existing Sensei status on this post type if not create it
1916 1916
         // and get the  activity ID
1917 1917
         $status_function = 'user_'.$post_type.'_status';
1918
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1919
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1918
+        $sensei_user_status = self::$status_function($post_id, $user_id);
1919
+        if ( ! isset($sensei_user_status->comment_ID)) {
1920 1920
 
1921 1921
             $start_function = 'user_start_'.$post_type;
1922
-            $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1922
+            $sensei_user_activity_id = self::$start_function($user_id, $post_id);
1923 1923
 
1924
-        }else{
1924
+        } else {
1925 1925
 
1926 1926
             $sensei_user_activity_id = $sensei_user_status->comment_ID;
1927 1927
 
1928 1928
         }
1929 1929
 
1930 1930
         // store the data
1931
-        $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1931
+        $success = update_comment_meta($sensei_user_activity_id, $data_key, $value);
1932 1932
 
1933 1933
        return $success;
1934 1934
 
@@ -1947,20 +1947,20 @@  discard block
 block discarded – undo
1947 1947
      *
1948 1948
      * @return mixed $user_data_value
1949 1949
      */
1950
-    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1950
+    public static function get_user_data($data_key, $post_id, $user_id = 0) {
1951 1951
 
1952 1952
         $user_data_value = true;
1953 1953
 
1954
-        if( ! ( $user_id > 0 ) ){
1954
+        if ( ! ($user_id > 0)) {
1955 1955
             $user_id = get_current_user_id();
1956 1956
         }
1957 1957
 
1958
-        $supported_post_types = array( 'course', 'lesson' );
1959
-        $post_type = get_post_type( $post_id );
1960
-        if( empty( $post_id ) || empty( $data_key )
1961
-            || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1962
-            || ! get_userdata( $user_id )
1963
-            || !in_array( $post_type, $supported_post_types )  ){
1958
+        $supported_post_types = array('course', 'lesson');
1959
+        $post_type = get_post_type($post_id);
1960
+        if (empty($post_id) || empty($data_key)
1961
+            || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
1962
+            || ! get_userdata($user_id)
1963
+            || ! in_array($post_type, $supported_post_types)) {
1964 1964
 
1965 1965
             return false;
1966 1966
         }
@@ -1968,13 +1968,13 @@  discard block
 block discarded – undo
1968 1968
         // check if there and existing Sensei status on this post type if not create it
1969 1969
         // and get the  activity ID
1970 1970
         $status_function = 'user_'.$post_type.'_status';
1971
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1972
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1971
+        $sensei_user_status = self::$status_function($post_id, $user_id);
1972
+        if ( ! isset($sensei_user_status->comment_ID)) {
1973 1973
             return false;
1974 1974
         }
1975 1975
 
1976 1976
         $sensei_user_activity_id = $sensei_user_status->comment_ID;
1977
-        $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1977
+        $user_data_value = get_comment_meta($sensei_user_activity_id, $data_key, true);
1978 1978
 
1979 1979
         return $user_data_value;
1980 1980
 
@@ -1989,19 +1989,19 @@  discard block
 block discarded – undo
1989 1989
      *
1990 1990
      * @return bool $deleted
1991 1991
      */
1992
-    public static function delete_user_data( $data_key, $post_id , $user_id ){
1992
+    public static function delete_user_data($data_key, $post_id, $user_id) {
1993 1993
         $deleted = true;
1994 1994
 
1995
-        if( ! ( $user_id > 0 ) ){
1995
+        if ( ! ($user_id > 0)) {
1996 1996
             $user_id = get_current_user_id();
1997 1997
         }
1998 1998
 
1999
-        $supported_post_types = array( 'course', 'lesson' );
2000
-        $post_type = get_post_type( $post_id );
2001
-        if( empty( $post_id ) || empty( $data_key )
2002
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2003
-            || ! get_userdata( $user_id )
2004
-            || !in_array( $post_type, $supported_post_types )  ){
1999
+        $supported_post_types = array('course', 'lesson');
2000
+        $post_type = get_post_type($post_id);
2001
+        if (empty($post_id) || empty($data_key)
2002
+            || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0)
2003
+            || ! get_userdata($user_id)
2004
+            || ! in_array($post_type, $supported_post_types)) {
2005 2005
 
2006 2006
             return false;
2007 2007
         }
@@ -2009,13 +2009,13 @@  discard block
 block discarded – undo
2009 2009
         // check if there and existing Sensei status on this post type if not create it
2010 2010
         // and get the  activity ID
2011 2011
         $status_function = 'user_'.$post_type.'_status';
2012
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2013
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2012
+        $sensei_user_status = self::$status_function($post_id, $user_id);
2013
+        if ( ! isset($sensei_user_status->comment_ID)) {
2014 2014
             return false;
2015 2015
         }
2016 2016
 
2017 2017
         $sensei_user_activity_id = $sensei_user_status->comment_ID;
2018
-        $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2018
+        $deleted = delete_comment_meta($sensei_user_activity_id, $data_key);
2019 2019
 
2020 2020
         return $deleted;
2021 2021
 
@@ -2040,62 +2040,62 @@  discard block
 block discarded – undo
2040 2040
      *
2041 2041
      * @return string $drop_down_element
2042 2042
      */
2043
-    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2043
+    public static function generate_drop_down($selected_value, $options = array(), $attributes = array(), $enable_none_option = true) {
2044 2044
 
2045 2045
         $drop_down_element = '';
2046 2046
 
2047 2047
         // setup the basic attributes
2048
-        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2048
+        if ( ! isset($attributes['name']) || empty($attributes['name'])) {
2049 2049
 
2050 2050
             $attributes['name'] = 'sensei-options';
2051 2051
 
2052 2052
         }
2053 2053
 
2054
-        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2054
+        if ( ! isset($attributes['id']) || empty($attributes['id'])) {
2055 2055
 
2056 2056
             $attributes['id'] = 'sensei-options';
2057 2057
 
2058 2058
         }
2059 2059
 
2060
-        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2060
+        if ( ! isset($attributes['class']) || empty($attributes['class'])) {
2061 2061
 
2062
-            $attributes['class'] ='chosen_select widefat';
2062
+            $attributes['class'] = 'chosen_select widefat';
2063 2063
 
2064 2064
         }
2065 2065
 
2066 2066
         // create element attributes
2067 2067
         $combined_attributes = '';
2068
-        foreach( $attributes as $attribute => $value ){
2068
+        foreach ($attributes as $attribute => $value) {
2069 2069
 
2070
-            $combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2070
+            $combined_attributes .= $attribute.'="'.$value.'"'.' ';
2071 2071
 
2072 2072
         }// end for each
2073 2073
 
2074 2074
 
2075 2075
         // create the select element
2076
-        $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2076
+        $drop_down_element .= '<select '.$combined_attributes.' >'."\n";
2077 2077
 
2078 2078
         // show the none option if the client requested
2079
-        if( $enable_none_option ) {
2080
-            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2079
+        if ($enable_none_option) {
2080
+            $drop_down_element .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
2081 2081
         }
2082 2082
 
2083
-        if ( count( $options ) > 0 ) {
2083
+        if (count($options) > 0) {
2084 2084
 
2085
-            foreach ($options as $value => $option ){
2085
+            foreach ($options as $value => $option) {
2086 2086
 
2087 2087
                 $element = '';
2088
-                $element.= '<option value="' . esc_attr( $value ) . '"';
2089
-                $element .= selected( $value, $selected_value, false ) . '>';
2090
-                $element .= esc_html(  $option ) . '</option>' . "\n";
2088
+                $element .= '<option value="'.esc_attr($value).'"';
2089
+                $element .= selected($value, $selected_value, false).'>';
2090
+                $element .= esc_html($option).'</option>'."\n";
2091 2091
 
2092 2092
                 // add the element to the select html
2093
-                $drop_down_element.= $element;
2093
+                $drop_down_element .= $element;
2094 2094
             } // End For Loop
2095 2095
 
2096 2096
         } // End If Statement
2097 2097
 
2098
-        $drop_down_element .= '</select>' . "\n";
2098
+        $drop_down_element .= '</select>'."\n";
2099 2099
 
2100 2100
         return $drop_down_element;
2101 2101
 
@@ -2115,14 +2115,14 @@  discard block
 block discarded – undo
2115 2115
      *
2116 2116
      * @return double $val
2117 2117
      */
2118
-    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2118
+    public static function round($val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '') {
2119 2119
 
2120 2120
         /**å
2121 2121
          * Change the precision for the Sensei_Utils::round function.
2122 2122
          * the precision given will be passed into the php round function
2123 2123
          * @since 1.8.5
2124 2124
          */
2125
-        $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2125
+        $precision = apply_filters('sensei_round_precision', $precision, $val, $context, $mode);
2126 2126
 
2127 2127
         /**
2128 2128
          * Change the mode for the Sensei_Utils::round function.
@@ -2132,15 +2132,15 @@  discard block
 block discarded – undo
2132 2132
          *
2133 2133
          * @since 1.8.5
2134 2134
          */
2135
-        $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2135
+        $mode = apply_filters('sensei_round_mode', $mode, $val, $context, $precision);
2136 2136
 
2137
-        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2137
+        if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
2138 2138
 
2139
-            return round( $val, $precision, $mode );
2139
+            return round($val, $precision, $mode);
2140 2140
 
2141
-        }else{
2141
+        } else {
2142 2142
 
2143
-            return round( $val, $precision );
2143
+            return round($val, $precision);
2144 2144
 
2145 2145
         }
2146 2146
 
@@ -2152,15 +2152,15 @@  discard block
 block discarded – undo
2152 2152
      * @since 1.9.0
2153 2153
      * @return string $url
2154 2154
      */
2155
-    public static function get_current_url(){
2155
+    public static function get_current_url() {
2156 2156
 
2157 2157
         global $wp;
2158
-        $current_url = trailingslashit( home_url( $wp->request ) );
2159
-        if ( isset( $_GET ) ) {
2158
+        $current_url = trailingslashit(home_url($wp->request));
2159
+        if (isset($_GET)) {
2160 2160
 
2161
-            foreach ($_GET as $param => $val ) {
2161
+            foreach ($_GET as $param => $val) {
2162 2162
 
2163
-                $current_url = add_query_arg( $param, $val , $current_url );
2163
+                $current_url = add_query_arg($param, $val, $current_url);
2164 2164
 
2165 2165
             }
2166 2166
         }
@@ -2190,27 +2190,27 @@  discard block
 block discarded – undo
2190 2190
      * @param array $array_b
2191 2191
      * @return array $merged_array
2192 2192
      */
2193
-    public static function array_zip_merge( $array_a, $array_b ){
2193
+    public static function array_zip_merge($array_a, $array_b) {
2194 2194
 
2195
-        if( ! isset( $array_a[0]  ) || ! isset( $array_b[0] )  ){
2195
+        if ( ! isset($array_a[0]) || ! isset($array_b[0])) {
2196 2196
             trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2197 2197
         }
2198 2198
 
2199 2199
         $merged_array = array();
2200
-        $total_elements = count( $array_a )  + count( $array_b );
2200
+        $total_elements = count($array_a) + count($array_b);
2201 2201
 
2202 2202
         // Zip arrays
2203
-        for ( $i = 0; $i < $total_elements; $i++) {
2203
+        for ($i = 0; $i < $total_elements; $i++) {
2204 2204
 
2205 2205
             // if has an element at current index push a on top
2206
-            if( isset( $array_a[ $i ] ) ){
2207
-                $merged_array[] = $array_a[ $i ]  ;
2206
+            if (isset($array_a[$i])) {
2207
+                $merged_array[] = $array_a[$i];
2208 2208
             }
2209 2209
 
2210 2210
             // next if $array_b has an element at current index push a on top of the element
2211 2211
             // from a if there was one, if not the element before that.
2212
-            if( isset( $array_b[ $i ] ) ){
2213
-                $merged_array[] = $array_b[ $i ]  ;
2212
+            if (isset($array_b[$i])) {
2213
+                $merged_array[] = $array_b[$i];
2214 2214
             }
2215 2215
 
2216 2216
         }
@@ -2225,4 +2225,4 @@  discard block
 block discarded – undo
2225 2225
  * for backward compatibility
2226 2226
  * @since 1.9.0
2227 2227
  */
2228
-class WooThemes_Sensei_Utils extends Sensei_Utils{}
2228
+class WooThemes_Sensei_Utils extends Sensei_Utils {}
Please login to merge, or discard this patch.
includes/class-sensei-wc.php 1 patch
Spacing   +160 added lines, -160 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,17 +28,17 @@  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
-        $active_plugins = (array) get_option( 'active_plugins', array() );
33
+        $active_plugins = (array) get_option('active_plugins', array());
34 34
 
35
-        if ( is_multisite() ){
35
+        if (is_multisite()) {
36 36
 
37
-            $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
37
+            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
38 38
 
39 39
         }
40 40
 
41
-        return in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
41
+        return in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
42 42
 
43 43
     } // end is_woocommerce_active
44 44
 
@@ -51,48 +51,48 @@  discard block
 block discarded – undo
51 51
      * @param $course_id
52 52
      * @return array $user_course_orders
53 53
      */
54
-    public static function get_learner_course_active_order_id( $user_id, $course_id ){
54
+    public static function get_learner_course_active_order_id($user_id, $course_id) {
55 55
 
56
-        $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
56
+        $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
57 57
 
58
-        $orders_query = new WP_Query( array(
58
+        $orders_query = new WP_Query(array(
59 59
             'post_type'   => 'shop_order',
60 60
             'posts_per_page' => -1,
61
-            'post_status' => array( 'wc-processing', 'wc-completed' ),
61
+            'post_status' => array('wc-processing', 'wc-completed'),
62 62
             'meta_key'=> '_customer_user',
63 63
             'meta_value'=> $user_id,
64
-        ) );
64
+        ));
65 65
 
66
-        if( $orders_query->post_count == 0 ){
66
+        if ($orders_query->post_count == 0) {
67 67
 
68 68
             return false;
69 69
 
70 70
         }
71 71
 
72
-        foreach( $orders_query->get_posts() as $order ){
72
+        foreach ($orders_query->get_posts() as $order) {
73 73
 
74
-            $order = new WC_Order( $order->ID );
74
+            $order = new WC_Order($order->ID);
75 75
             $items = $order->get_items();
76 76
 
77
-            $user_orders =  array();
77
+            $user_orders = array();
78 78
 
79
-            foreach( $items as $item ){
79
+            foreach ($items as $item) {
80 80
 
81 81
                 // if the product id on the order and the one given to this function
82 82
                 // this order has been placed by the given user on the given course.
83
-                $product = wc_get_product( $item['product_id'] );
83
+                $product = wc_get_product($item['product_id']);
84 84
 
85
-                if ( $product->is_type( 'variable' )) {
85
+                if ($product->is_type('variable')) {
86 86
 
87 87
                     $item_product_id = $item['variation_id'];
88 88
 
89 89
                 } else {
90 90
 
91
-                    $item_product_id =  $item['product_id'];
91
+                    $item_product_id = $item['product_id'];
92 92
 
93 93
                 }
94 94
 
95
-                if( $course_product_id == $item_product_id ){
95
+                if ($course_product_id == $item_product_id) {
96 96
 
97 97
                     return $order->id;
98 98
 
@@ -116,28 +116,28 @@  discard block
 block discarded – undo
116 116
      * @param $filter_links
117 117
      * @return mixed
118 118
      */
119
-    public static function add_course_archive_wc_filter_links( $filter_links ){
119
+    public static function add_course_archive_wc_filter_links($filter_links) {
120 120
 
121
-        $course_url = remove_query_arg('paged', WooThemes_Sensei_Utils::get_current_url() );
121
+        $course_url = remove_query_arg('paged', WooThemes_Sensei_Utils::get_current_url());
122 122
 
123 123
         $free_courses = self::get_free_courses();
124 124
         $paid_courses = self::get_paid_courses();
125 125
 
126
-        if ( empty( $free_courses ) || empty( $paid_courses )  ){
126
+        if (empty($free_courses) || empty($paid_courses)) {
127 127
             // do not show any WooCommerce filters if all courses are
128 128
             // free or if all courses are paid
129 129
             return $filter_links;
130 130
 
131 131
         }
132 132
 
133
-        $filter_links[] = array(    'id'=>'paid' ,
133
+        $filter_links[] = array('id'=>'paid',
134 134
                                     'url'=> add_query_arg('course_filter', 'paid', $course_url),
135
-                                    'title'=>__( 'Paid', 'woothemes-sensei' )
135
+                                    'title'=>__('Paid', 'woothemes-sensei')
136 136
         );
137 137
 
138
-        $filter_links[] = array(    'id'=>'free',
138
+        $filter_links[] = array('id'=>'free',
139 139
                                     'url'=>add_query_arg('course_filter', 'free', $course_url),
140
-                                    'title'=>__( 'Free', 'woothemes-sensei' )
140
+                                    'title'=>__('Free', 'woothemes-sensei')
141 141
         );
142 142
 
143 143
         return $filter_links;
@@ -154,24 +154,24 @@  discard block
 block discarded – undo
154 154
      * @param WP_Query $query
155 155
      * @return WP_Query $query
156 156
      */
157
-    public static function course_archive_wc_filter_free( $query ){
157
+    public static function course_archive_wc_filter_free($query) {
158 158
 
159
-        if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
160
-            && 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
159
+        if (isset($_GET['course_filter']) && 'free' == $_GET['course_filter']
160
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
161 161
 
162 162
             // setup the course meta query
163 163
             $meta_query = self::get_free_courses_meta_query_args();
164 164
 
165 165
             // manipulate the query to return free courses
166
-            $query->set('meta_query', $meta_query );
166
+            $query->set('meta_query', $meta_query);
167 167
 
168 168
             // don't show any paid courses
169 169
             $courses = self::get_paid_courses();
170 170
             $ids = array();
171
-            foreach( $courses as $course ){
171
+            foreach ($courses as $course) {
172 172
                 $ids[] = $course->ID;
173 173
             }
174
-            $query->set( 'post__not_in', $ids );
174
+            $query->set('post__not_in', $ids);
175 175
 
176 176
         }// end if course_filter
177 177
 
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
      * @param WP_Query $query
191 191
      * @return WP_Query $query
192 192
      */
193
-    public static function course_archive_wc_filter_paid( $query ){
193
+    public static function course_archive_wc_filter_paid($query) {
194 194
 
195
-        if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
196
-            && 'course' == $query->get( 'post_type') && $query->is_main_query() ){
195
+        if (isset($_GET['course_filter']) && 'paid' == $_GET['course_filter']
196
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
197 197
 
198 198
             // setup the course meta query
199 199
             $meta_query = self::get_paid_courses_meta_query_args();
200 200
 
201 201
             // manipulate the query to return free courses
202
-            $query->set('meta_query', $meta_query );
202
+            $query->set('meta_query', $meta_query);
203 203
 
204 204
         }
205 205
 
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
      * single courses if woocommerce is active allowing purchase
213 213
      * information and actions to be hooked from WooCommerce.
214 214
      */
215
-    public static function do_single_course_wc_single_product_action(){
215
+    public static function do_single_course_wc_single_product_action() {
216 216
 
217 217
         /**
218 218
          * this hooks is documented within the WooCommerce plugin.
219 219
          */
220
-        if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
220
+        if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
221 221
 
222
-            do_action( 'woocommerce_before_single_product' );
222
+            do_action('woocommerce_before_single_product');
223 223
 
224 224
         } // End If Statement
225 225
 
@@ -240,23 +240,23 @@  discard block
 block discarded – undo
240 240
      * @param $user_id
241 241
      * @return bool
242 242
      */
243
-    public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
243
+    public static function alter_can_user_view_lesson($can_user_view_lesson, $lesson_id, $user_id) {
244 244
 
245 245
         // check if the course has a valid product attached to it
246 246
         // which the user should have purchased if they want to access
247 247
         // the current lesson
248
-        $course_id = get_post_meta( $lesson_id , '_lesson_course', true);
249
-        $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
248
+        $course_id = get_post_meta($lesson_id, '_lesson_course', true);
249
+        $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true);
250 250
         $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
251
-        if( isset ($product) && is_object($product) ){
251
+        if (isset ($product) && is_object($product)) {
252 252
 
253 253
             // valid product found
254
-            $order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
254
+            $order_id = self::get_learner_course_active_order_id($user_id, $course_id);
255 255
 
256 256
             // product has a successful order so this user may access the content
257 257
             // this function may only return false or the default
258 258
             // returning true may override other negatives which we don't want
259
-            if( ! $order_id ){
259
+            if ( ! $order_id) {
260 260
 
261 261
                 return false;
262 262
 
@@ -279,23 +279,23 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public static function course_link_from_order( ) {
281 281
 
282
-        if( ! is_order_received_page() ){
282
+        if ( ! is_order_received_page()) {
283 283
             return;
284 284
         }
285 285
 
286
-        $order_id = get_query_var( 'order-received' );
287
-		$order = new WC_Order( $order_id );
286
+        $order_id = get_query_var('order-received');
287
+		$order = new WC_Order($order_id);
288 288
 
289 289
 		// exit early if not wc-completed or wc-processing
290
-		if( 'wc-completed' != $order->post_status
291
-            && 'wc-processing' != $order->post_status  ) {
290
+		if ('wc-completed' != $order->post_status
291
+            && 'wc-processing' != $order->post_status) {
292 292
             return;
293 293
         }
294 294
 
295 295
         $course_links = array(); // store the for links for courses purchased
296
-		foreach ( $order->get_items() as $item ) {
296
+		foreach ($order->get_items() as $item) {
297 297
 
298
-            if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
298
+            if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
299 299
 
300 300
                 // If item has variation_id then its a variation of the product
301 301
                 $item_id = $item['variation_id'];
@@ -307,28 +307,28 @@  discard block
 block discarded – undo
307 307
 
308 308
             } // End If Statement
309 309
 
310
-            $user_id = get_post_meta( $order->id, '_customer_user', true );
310
+            $user_id = get_post_meta($order->id, '_customer_user', true);
311 311
 
312
-            if( $user_id ) {
312
+            if ($user_id) {
313 313
 
314 314
                 // Get all courses for product
315 315
                 $args = Sensei_Course::get_default_query_args();
316
-                $args['meta_query'] = array( array(
316
+                $args['meta_query'] = array(array(
317 317
                             'key' => '_course_woocommerce_product',
318 318
                             'value' => $item_id
319
-                        ) );
319
+                        ));
320 320
                 $args['orderby'] = 'menu_order date';
321 321
                 $args['order'] = 'ASC';
322 322
 
323 323
                 // loop through courses
324
-                $courses = get_posts( $args );
325
-                if( $courses && count( $courses ) > 0 ) {
324
+                $courses = get_posts($args);
325
+                if ($courses && count($courses) > 0) {
326 326
 
327
-                    foreach( $courses as $course ) {
327
+                    foreach ($courses as $course) {
328 328
 
329 329
                         $title = $course->post_title;
330
-                        $permalink = get_permalink( $course->ID );
331
-                        $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
330
+                        $permalink = get_permalink($course->ID);
331
+                        $course_links[] .= '<a href="'.esc_url($permalink).'" >'.$title.'</a> ';
332 332
 
333 333
                     } // end for each
334 334
 
@@ -339,24 +339,24 @@  discard block
 block discarded – undo
339 339
         }// end loop through orders
340 340
 
341 341
         // add the courses to the WooCommerce notice
342
-        if( ! empty( $course_links) ){
342
+        if ( ! empty($course_links)) {
343 343
 
344 344
             $courses_html = _nx(
345 345
                 'You have purchased the following course:',
346 346
                 'You have purchased the following courses:',
347
-                count( $course_links ),
347
+                count($course_links),
348 348
                 'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
349 349
             );
350 350
 
351
-            foreach( $course_links as $link ){
351
+            foreach ($course_links as $link) {
352 352
 
353
-                $courses_html .= '<li>' . $link . '</li>';
353
+                $courses_html .= '<li>'.$link.'</li>';
354 354
 
355 355
             }
356 356
 
357 357
             $courses_html .= ' </ul>';
358 358
 
359
-            wc_add_notice( $courses_html, 'success' );
359
+            wc_add_notice($courses_html, 'success');
360 360
         }
361 361
 
362 362
 	} // end course_link_order_form
@@ -369,20 +369,20 @@  discard block
 block discarded – undo
369 369
      *
370 370
      * @since 1.9.0
371 371
      */
372
-    public static function course_in_cart_message(){
372
+    public static function course_in_cart_message() {
373 373
 
374 374
         global $post;
375 375
 
376
-        if( self::is_course_in_cart( $post->ID ) ){ ?>
376
+        if (self::is_course_in_cart($post->ID)) { ?>
377 377
 
378 378
             <div class="sensei-message info">'
379 379
                 <?php
380 380
 
381
-                $cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
382
-                              . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
383
-                              . __('complete the purchase', 'woothemes-sensei') . '</a>';
381
+                $cart_link = '<a class="cart-complete" href="'.WC()->cart->get_checkout_url()
382
+                              . '" title="'.__('complete purchase', 'woothemes-sensei').'">'
383
+                              . __('complete the purchase', 'woothemes-sensei').'</a>';
384 384
 
385
-                sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
385
+                sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link);
386 386
 
387 387
                 ?>
388 388
             </div>
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
      * @param $course_id
397 397
      * @return bool
398 398
      */
399
-    public static function is_course_in_cart( $course_id ){
399
+    public static function is_course_in_cart($course_id) {
400 400
 
401
-        $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
402
-        $user_course_status_id = WooThemes_Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
401
+        $wc_post_id = absint(get_post_meta($course_id, '_course_woocommerce_product', true));
402
+        $user_course_status_id = WooThemes_Sensei_Utils::user_started_course($course_id, get_current_user_id());
403 403
 
404
-        if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
404
+        if (0 < intval($wc_post_id) && ! $user_course_status_id) {
405 405
 
406
-            if ( self::is_product_in_cart( $wc_post_id ) ) {
406
+            if (self::is_product_in_cart($wc_post_id)) {
407 407
 
408 408
                 return true;
409 409
 
@@ -421,20 +421,20 @@  discard block
 block discarded – undo
421 421
      * @param $product_id
422 422
      * @return bool
423 423
      */
424
-    public static function is_product_in_cart( $product_id ){
424
+    public static function is_product_in_cart($product_id) {
425 425
 
426
-        if ( 0 < $product_id ) {
426
+        if (0 < $product_id) {
427 427
 
428
-            $product = wc_get_product( $product_id );
428
+            $product = wc_get_product($product_id);
429 429
 
430 430
             $parent_id = '';
431
-            if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
431
+            if (isset($product->variation_id) && 0 < intval($product->variation_id)) {
432 432
                 $wc_product_id = $product->parent->id;
433 433
             }
434
-            foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
434
+            foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
435 435
 
436 436
                 $cart_product = $values['data'];
437
-                if( $product_id == $cart_product->id ) {
437
+                if ($product_id == $cart_product->id) {
438 438
 
439 439
                     return true;
440 440
 
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
      *  @type int $wp_post_id
457 457
      * }
458 458
      */
459
-    public static function get_free_product_ids(){
459
+    public static function get_free_product_ids() {
460 460
 
461
-        return  get_posts( array(
461
+        return  get_posts(array(
462 462
             'post_type' => 'product',
463 463
             'posts_per_page' => '1000',
464 464
             'fields' => 'ids',
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
      * @since 1.9.0
484 484
      * @return array $wp_meta_query_param
485 485
      */
486
-    public static function get_free_courses_meta_query_args(){
486
+    public static function get_free_courses_meta_query_args() {
487 487
 
488 488
         return array(
489 489
             'relation' => 'OR',
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
      * @since 1.9.0
508 508
      * @return array $wp_query_meta_query_args_param
509 509
      */
510
-    public static function get_paid_courses_meta_query_args(){
510
+    public static function get_paid_courses_meta_query_args() {
511 511
 
512 512
         $paid_product_ids = self::get_paid_product_ids();
513 513
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
                 'key'     => '_course_woocommerce_product',
517 517
                 // when empty we give a false post_id to ensure the caller doesn't get any courses for their
518 518
                 // query
519
-                'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
519
+                'value' => empty($paid_product_ids) ? '-1000' : $paid_product_ids,
520 520
                 'compare' => 'IN',
521 521
             ),
522 522
         );
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
      * @since 1.9.0
531 531
      * @return array $product_query_args
532 532
      */
533
-    public static function get_paid_products_on_sale_query_args(){
533
+    public static function get_paid_products_on_sale_query_args() {
534 534
 
535 535
         $args = array(
536 536
                    'post_type' 		=> 'product',
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
                    'suppress_filters' 	=> 0
541 541
         );
542 542
 
543
-        $args[ 'fields' ]     = 'ids';
543
+        $args['fields']     = 'ids';
544 544
 
545
-        $args[ 'meta_query' ] = array(
545
+        $args['meta_query'] = array(
546 546
             'relation' => 'AND',
547 547
             array(
548 548
                 'key'=> '_regular_price',
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
      *
570 570
      * @return array
571 571
      */
572
-    public static function get_paid_products_not_on_sale_query_args(){
572
+    public static function get_paid_products_not_on_sale_query_args() {
573 573
 
574 574
         $args = array(
575 575
             'post_type' 		=> 'product',
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
             'suppress_filters' 	=> 0
580 580
         );
581 581
 
582
-        $args[ 'fields' ]     = 'ids';
583
-        $args[ 'meta_query' ] = array(
582
+        $args['fields']     = 'ids';
583
+        $args['meta_query'] = array(
584 584
             'relation' => 'AND',
585 585
             array(
586 586
                 'key'=> '_regular_price',
@@ -606,24 +606,24 @@  discard block
 block discarded – undo
606 606
      *
607 607
      * @return array $woocommerce_paid_product_ids
608 608
      */
609
-    public static function get_paid_product_ids(){
609
+    public static function get_paid_product_ids() {
610 610
 
611 611
         // get all the paid WooCommerce products that has regular
612 612
         // and sale price greater than 0
613 613
         // will be used later to check for course with the id as meta
614
-        $paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
614
+        $paid_product_ids_with_sale = get_posts(self::get_paid_products_on_sale_query_args());
615 615
 
616 616
         // get all the paid WooCommerce products that has regular price
617 617
         // greater than 0 without a sale price
618 618
         // will be used later to check for course with the id as meta
619
-        $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
619
+        $paid_product_ids_without_sale = get_posts(self::get_paid_products_not_on_sale_query_args());
620 620
 
621 621
         // combine products ID's with regular and sale price grater than zero and those without
622 622
         // sale but regular price greater than zero
623
-        $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
623
+        $woocommerce_paid_product_ids = array_merge($paid_product_ids_with_sale, $paid_product_ids_without_sale);
624 624
 
625 625
         // if
626
-        if( empty($woocommerce_paid_product_ids) ){
626
+        if (empty($woocommerce_paid_product_ids)) {
627 627
             return array( );
628 628
         }
629 629
         return $woocommerce_paid_product_ids;
@@ -642,20 +642,20 @@  discard block
 block discarded – undo
642 642
      *
643 643
      * @return array
644 644
      */
645
-    public static function get_free_courses(){
645
+    public static function get_free_courses() {
646 646
 
647 647
         $free_course_query_args = Sensei_Course::get_default_query_args();
648
-        $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
648
+        $free_course_query_args['meta_query'] = self::get_free_courses_meta_query_args();
649 649
 
650 650
         // don't show any paid courses
651 651
         $courses = self::get_paid_courses();
652 652
         $ids = array();
653
-        foreach( $courses as $course ){
653
+        foreach ($courses as $course) {
654 654
             $ids[] = $course->ID;
655 655
         }
656
-        $free_course_query_args[ 'post__not_in' ] =  $ids;
656
+        $free_course_query_args['post__not_in'] = $ids;
657 657
 
658
-        return get_posts( $free_course_query_args );
658
+        return get_posts($free_course_query_args);
659 659
 
660 660
     }
661 661
 
@@ -665,13 +665,13 @@  discard block
 block discarded – undo
665 665
      * @since 1.9.0
666 666
      * @return array
667 667
      */
668
-    public static function get_paid_courses(){
668
+    public static function get_paid_courses() {
669 669
 
670 670
         $paid_course_query_args = Sensei_Course::get_default_query_args();
671 671
 
672
-        $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
672
+        $paid_course_query_args['meta_query'] = self::get_paid_courses_meta_query_args();
673 673
 
674
-        return get_posts(  $paid_course_query_args );
674
+        return get_posts($paid_course_query_args);
675 675
     }
676 676
 
677 677
     /**
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
      * @param int $course_id
687 687
      * @return string $html markup for the button or nothing if user not allowed to buy
688 688
      */
689
-    public static function the_add_to_cart_button_html( $course_id ){
689
+    public static function the_add_to_cart_button_html($course_id) {
690 690
 
691
-        if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
691
+        if ( ! Sensei_Course::is_prerequisite_complete($course_id)) {
692 692
             return '';
693 693
         }
694 694
 
695
-        $wc_post_id = self::get_course_product_id( $course_id );
695
+        $wc_post_id = self::get_course_product_id($course_id);
696 696
 
697 697
         // Check if customer purchased the product
698
-        if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
699
-            || empty( $wc_post_id ) ) {
698
+        if (self::has_customer_bought_product(get_current_user_id(), $wc_post_id)
699
+            || empty($wc_post_id)) {
700 700
 
701 701
             return '';
702 702
 
@@ -704,15 +704,15 @@  discard block
 block discarded – undo
704 704
 
705 705
         // based on simple.php in WC templates/single-product/add-to-cart/
706 706
         // Get the product
707
-        $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
707
+        $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
708 708
 
709 709
         // do not show the button for invalid products, non purchasable products, out
710 710
         // of stock product or if course is already in cart
711
-        if ( ! isset ( $product )
712
-            || ! is_object( $product )
711
+        if ( ! isset ($product)
712
+            || ! is_object($product)
713 713
             || ! $product->is_purchasable()
714 714
             || ! $product->is_in_stock()
715
-            || self::is_course_in_cart( $wc_post_id ) ) {
715
+            || self::is_course_in_cart($wc_post_id)) {
716 716
 
717 717
             return '';
718 718
 
@@ -723,23 +723,23 @@  discard block
 block discarded – undo
723 723
         //
724 724
         ?>
725 725
 
726
-        <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"
726
+        <form action="<?php echo esc_url($product->add_to_cart_url()); ?>"
727 727
               class="cart"
728 728
               method="post"
729 729
               enctype="multipart/form-data">
730 730
 
731
-            <input type="hidden" name="product_id" value="<?php echo esc_attr( $product->id ); ?>" />
731
+            <input type="hidden" name="product_id" value="<?php echo esc_attr($product->id); ?>" />
732 732
 
733 733
             <input type="hidden" name="quantity" value="1" />
734 734
 
735
-            <?php if ( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) { ?>
735
+            <?php if (isset($product->variation_id) && 0 < intval($product->variation_id)) { ?>
736 736
 
737 737
                 <input type="hidden" name="variation_id" value="<?php echo $product->variation_id; ?>" />
738
-                <?php if( isset( $product->variation_data ) && is_array( $product->variation_data ) && count( $product->variation_data ) > 0 ) { ?>
738
+                <?php if (isset($product->variation_data) && is_array($product->variation_data) && count($product->variation_data) > 0) { ?>
739 739
 
740
-                    <?php foreach( $product->variation_data as $att => $val ) { ?>
740
+                    <?php foreach ($product->variation_data as $att => $val) { ?>
741 741
 
742
-                        <input type="hidden" name="<?php echo esc_attr( $att ); ?>" id="<?php echo esc_attr( str_replace( 'attribute_', '', $att ) ); ?>" value="<?php echo esc_attr( $val ); ?>" />
742
+                        <input type="hidden" name="<?php echo esc_attr($att); ?>" id="<?php echo esc_attr(str_replace('attribute_', '', $att)); ?>" value="<?php echo esc_attr($val); ?>" />
743 743
 
744 744
                     <?php } ?>
745 745
 
@@ -767,26 +767,26 @@  discard block
 block discarded – undo
767 767
      *
768 768
      * @return string $message
769 769
      */
770
-    public static function alter_no_permissions_message( $message, $post_id ){
770
+    public static function alter_no_permissions_message($message, $post_id) {
771 771
 
772
-        if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
772
+        if (empty($post_id) || 'course' != get_post_type($post_id)) {
773 773
             return  $message;
774 774
         }
775 775
 
776
-        $product_id = self::get_course_product_id( $post_id );
776
+        $product_id = self::get_course_product_id($post_id);
777 777
 
778
-        if( ! $product_id
779
-            || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
778
+        if ( ! $product_id
779
+            || self::has_customer_bought_product(get_current_user_id(), $product_id)) {
780 780
 
781 781
             return $message;
782 782
 
783 783
         }
784 784
 
785 785
         ob_start();
786
-        self::the_course_no_permissions_message( $post_id );
786
+        self::the_course_no_permissions_message($post_id);
787 787
         $woocommerce_course_no_permissions_message = ob_get_clean();
788 788
 
789
-        return $woocommerce_course_no_permissions_message ;
789
+        return $woocommerce_course_no_permissions_message;
790 790
 
791 791
     }
792 792
     /**
@@ -795,16 +795,16 @@  discard block
 block discarded – undo
795 795
      *
796 796
      * @since 1.9.0
797 797
      */
798
-    public static function the_course_no_permissions_message( $course_id ){
798
+    public static function the_course_no_permissions_message($course_id) {
799 799
 
800 800
         // login link
801
-        $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
802
-        $login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
801
+        $my_courses_page_id = intval(Sensei()->settings->settings['my_course_page']);
802
+        $login_link = '<a href="'.esc_url(get_permalink($my_courses_page_id)).'">'.__('log in', 'woothemes-sensei').'</a>';
803 803
 
804 804
         ?>
805 805
 
806 806
         <span class="add-to-cart-login">
807
-            <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?>
807
+            <?php echo sprintf(__('Or %1$s to access your purchased courses', 'woothemes-sensei'), $login_link); ?>
808 808
         </span>
809 809
 
810 810
     <?php }
@@ -819,43 +819,43 @@  discard block
 block discarded – undo
819 819
      *
820 820
      * @return bool
821 821
      */
822
-    public static function has_customer_bought_product ( $user_id, $product_id ){
822
+    public static function has_customer_bought_product($user_id, $product_id) {
823 823
 
824
-        $orders = get_posts( array(
824
+        $orders = get_posts(array(
825 825
             'posts_per_page' => -1,
826 826
             'meta_key'    => '_customer_user',
827
-            'meta_value'  => intval( $user_id ),
827
+            'meta_value'  => intval($user_id),
828 828
             'post_type'   => 'shop_order',
829
-            'post_status' =>  array( 'wc-processing', 'wc-completed' ),
830
-        ) );
829
+            'post_status' =>  array('wc-processing', 'wc-completed'),
830
+        ));
831 831
 
832
-        foreach ( $orders as $order_id ) {
832
+        foreach ($orders as $order_id) {
833 833
 
834
-            $order = new WC_Order( $order_id->ID );
834
+            $order = new WC_Order($order_id->ID);
835 835
 
836
-            if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
836
+            if ($order->post_status != 'wc-completed' && $order->post_status != 'wc-processing') {
837 837
 
838 838
                 continue;
839 839
             }
840 840
 
841
-            if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
841
+            if ( ! (0 < sizeof($order->get_items()))) {
842 842
 
843 843
                 continue;
844 844
 
845 845
             }
846 846
 
847
-            foreach( $order->get_items() as $item ) {
847
+            foreach ($order->get_items() as $item) {
848 848
 
849 849
                 // Check if user has bought product
850
-                if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
850
+                if ($item['product_id'] == $product_id || $item['variation_id'] == $product_id) {
851 851
 
852 852
                     // Check if user has an active subscription for product
853
-                    if( class_exists( 'WC_Subscriptions_Manager' ) ) {
854
-                        $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
855
-                        if( $sub_key ) {
856
-                            $sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
857
-                            if( $sub && isset( $sub['status'] ) ) {
858
-                                if( 'active' == $sub['status'] ) {
853
+                    if (class_exists('WC_Subscriptions_Manager')) {
854
+                        $sub_key = WC_Subscriptions_Manager::get_subscription_key($order_id->ID, $product_id);
855
+                        if ($sub_key) {
856
+                            $sub = WC_Subscriptions_Manager::get_subscription($sub_key);
857
+                            if ($sub && isset($sub['status'])) {
858
+                                if ('active' == $sub['status']) {
859 859
                                     return true;
860 860
                                 } else {
861 861
                                     return false;
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
      * @return string $woocommerce_product_id or false if none exist
885 885
      *
886 886
      */
887
-    public static function get_course_product_id( $course_id ){
887
+    public static function get_course_product_id($course_id) {
888 888
 
889
-        $product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
889
+        $product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
890 890
 
891
-        if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
891
+        if (empty($product_id) || 'product' != get_post_type($product_id)) {
892 892
             return false;
893 893
         }
894 894
 
@@ -902,11 +902,11 @@  discard block
 block discarded – undo
902 902
      * @param array $classes
903 903
      * @return array
904 904
      */
905
-    public static function add_woocommerce_body_class( $classes ){
905
+    public static function add_woocommerce_body_class($classes) {
906 906
 
907
-        if( ! in_array( 'woocommerce', $classes ) ){
907
+        if ( ! in_array('woocommerce', $classes)) {
908 908
 
909
-            $classes[] ='woocommerce';
909
+            $classes[] = 'woocommerce';
910 910
 
911 911
         }
912 912
 
Please login to merge, or discard this patch.
includes/hooks/woocommerce.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@  discard block
 block discarded – undo
7 7
  * show the WooCommerce course filter links above the courses
8 8
  * @since 1.9.0
9 9
  */
10
-add_filter( 'sensei_archive_course_filter_by_options', array( 'Sensei_WC', 'add_course_archive_wc_filter_links' ) );
10
+add_filter('sensei_archive_course_filter_by_options', array('Sensei_WC', 'add_course_archive_wc_filter_links'));
11 11
 
12 12
 /**
13 13
  * filter the queries for paid and free course based on the users selection.
14 14
  * @since 1.9.0
15 15
  */
16
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_free'));
17
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_paid'));
16
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_free'));
17
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_paid'));
18 18
 
19 19
 /**
20 20
  * Add woocommerce action above single course the action
21 21
  * @since 1.9.0
22 22
  */
23
-add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action') ,50) ;
23
+add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action'), 50);
24 24
 
25 25
 /******************************
26 26
  *
27 27
  * Single Lesson Hooks
28 28
  *
29 29
  ******************************/
30
-add_filter( 'sensei_can_user_view_lesson', array( 'Sensei_WC','alter_can_user_view_lesson' ), 20, 3 );
30
+add_filter('sensei_can_user_view_lesson', array('Sensei_WC', 'alter_can_user_view_lesson'), 20, 3);
31 31
 
32 32
 /******************************
33 33
  *
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  *
36 36
  ******************************/
37 37
 // add a notice on the checkout page to tell users about the course they've purchase
38
-add_action( 'template_redirect', array( 'Sensei_WC','course_link_from_order' ) );
38
+add_action('template_redirect', array('Sensei_WC', 'course_link_from_order'));
39 39
 
40 40
 /******************************
41 41
  *
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  ******************************/
45 45
 //@since 1.9.0
46 46
 //show a notice if the user has already added the current course to their cart
47
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_WC', 'course_in_cart_message' ), 20 );
47
+add_action('sensei_single_course_content_inside_before', array('Sensei_WC', 'course_in_cart_message'), 20);
48 48
 
49 49
 /******************************
50 50
  *
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
  ******************************/
54 54
 //@since 1.9.0
55 55
 // alter the no permissions message to show the woocommerce message instead
56
-add_filter( 'sensei_the_no_permissions_message', array( 'Sensei_WC', 'alter_no_permissions_message' ), 20, 2 );
56
+add_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2);
57 57
 
58 58
 //@since 1.9.0
59 59
 // add the add to cart button for a valid purchasable course
60
-add_action( 'sensei_no_permissions_inside_before_content', array( 'Sensei_WC', 'the_add_to_cart_button_html' ), 20, 1);
60
+add_action('sensei_no_permissions_inside_before_content', array('Sensei_WC', 'the_add_to_cart_button_html'), 20, 1);
61 61
 
62 62
 // @since 1.9.0
63 63
 // add  woocommerce class to the the no permission body class to ensure WooCommerce elements are styled
64
-add_filter( 'body_class', array( 'Sensei_WC', 'add_woocommerce_body_class' ), 20, 1);
64
+add_filter('body_class', array('Sensei_WC', 'add_woocommerce_body_class'), 20, 1);
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ){ exit; } // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) { exit; } // Exit if accessed directly
3 3
 
4 4
 	/***************************************************************************************************
5 5
 	 * 	Output tags.
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
      * @param string $type (default: 'newcourses')
13 13
      * @return void
14 14
      */
15
-    function sensei_course_archive_next_link( $type = 'newcourses' ) {
15
+    function sensei_course_archive_next_link($type = 'newcourses') {
16 16
 
17
-        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
17
+        _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.');
18 18
 
19 19
     } // End sensei_course_archive_next_link()
20 20
 
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 function course_single_lessons() {
28 28
 
29 29
          // load backwards compatible template name if it exists in the users theme
30
-         $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
-         if( $located_template ){
30
+         $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php');
31
+         if ($located_template) {
32 32
 
33
-             Sensei_Templates::get_template( 'single-course/course-lessons.php' );
33
+             Sensei_Templates::get_template('single-course/course-lessons.php');
34 34
              return;
35 35
 
36 36
         }
37 37
 
38
-		Sensei_Templates::get_template( 'single-course/lessons.php' );
38
+		Sensei_Templates::get_template('single-course/lessons.php');
39 39
 
40 40
 	 } // End course_single_lessons()
41 41
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	  */
49 49
 	 function lesson_single_meta() {
50 50
 
51
-         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
51
+         _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta');
52 52
          sensei_the_single_lesson_meta();
53 53
 
54 54
 	 } // End lesson_single_meta()
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	  * @return void
63 63
       * @deprecated since 1.9.0
64 64
 	  */
65
-	 function quiz_questions( $return = false ) {
65
+	 function quiz_questions($return = false) {
66 66
 
67
-	 	Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' );
67
+	 	Sensei_Templates::get_template('single-quiz/quiz-questions.php');
68 68
 
69 69
 	 } // End quiz_questions()
70 70
 
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	  * @return void
77 77
       * @deprecated
78 78
 	  */
79
-	 function quiz_question_type( $question_type = 'multiple-choice' ) {
79
+	 function quiz_question_type($question_type = 'multiple-choice') {
80 80
 
81
-         Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
81
+         Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php');
82 82
 
83 83
 	 } // End lesson_single_meta()
84 84
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param mixed $course_id
95 95
 	 * @return bool
96 96
 	 */
97
-	function sensei_check_prerequisite_course( $course_id ) {
97
+	function sensei_check_prerequisite_course($course_id) {
98 98
 
99
-        return Sensei_Course::is_prerequisite_complete( $course_id );
99
+        return Sensei_Course::is_prerequisite_complete($course_id);
100 100
 
101 101
 	} // End sensei_check_prerequisite_course()
102 102
 
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
 	 * @param mixed $course_id
109 109
 	 * @return void
110 110
 	 */
111
-	function sensei_start_course_form( $course_id ) {
111
+	function sensei_start_course_form($course_id) {
112 112
 
113
-		$prerequisite_complete = sensei_check_prerequisite_course( $course_id );
113
+		$prerequisite_complete = sensei_check_prerequisite_course($course_id);
114 114
 
115
-		if ( $prerequisite_complete ) {
116
-		?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
115
+		if ($prerequisite_complete) {
116
+		?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>">
117 117
 
118
-    			<input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" />
118
+    			<input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" />
119 119
 
120
-    			<span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span>
120
+    			<span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span>
121 121
 
122 122
     		</form><?php
123 123
     	} // End If Statement
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 	 * @param mixed $course_id
133 133
 	 * @return void
134 134
 	 */
135
-	function sensei_wc_add_to_cart( $course_id ) {
135
+	function sensei_wc_add_to_cart($course_id) {
136 136
 
137
-		Sensei_WC::the_add_to_cart_button_html( $course_id );
137
+		Sensei_WC::the_add_to_cart_button_html($course_id);
138 138
 
139 139
 	} // End sensei_wc_add_to_cart()
140 140
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @param int $wc_post_id (default: 0)
147 147
 	 * @return void
148 148
 	 */
149
-	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) {
150
-        return Sensei_WC::is_product_in_cart( $wc_product_id );
149
+	function sensei_check_if_product_is_in_cart($wc_product_id = 0) {
150
+        return Sensei_WC::is_product_in_cart($wc_product_id);
151 151
 	} // End sensei_check_if_product_is_in_cart()
152 152
 
153 153
 	/**
@@ -157,16 +157,16 @@  discard block
 block discarded – undo
157 157
 	 * @param mixed $post_id
158 158
 	 * @return void
159 159
 	 */
160
-	function sensei_simple_course_price( $post_id ) {
160
+	function sensei_simple_course_price($post_id) {
161 161
 
162 162
 		//WooCommerce Pricing
163
-    	if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
164
-    	    $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
-    	    if ( 0 < $wc_post_id ) {
163
+    	if (WooThemes_Sensei_Utils::sensei_is_woocommerce_activated()) {
164
+    	    $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true);
165
+    	    if (0 < $wc_post_id) {
166 166
     	    	// Get the product
167
-    	    	$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
167
+    	    	$product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
168 168
 
169
-    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
169
+    	    	if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?>
170 170
     	    		<span class="course-price"><?php echo $product->get_price_html(); ?></span>
171 171
     	    	<?php } // End If Statement
172 172
     	    } // End If Statement
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 * @param array $widget_args (default: array())
181 181
 	 * @return void
182 182
 	 */
183
-	function sensei_recent_comments_widget_filter( $widget_args = array() ) {
184
-		if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' );
183
+	function sensei_recent_comments_widget_filter($widget_args = array()) {
184
+		if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page');
185 185
 		return $widget_args;
186 186
 	} // End sensei_recent_comments_widget_filter()
187
-	add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 );
187
+	add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1);
188 188
 
189 189
 	/**
190 190
 	 * sensei_course_archive_filter function.
@@ -193,26 +193,26 @@  discard block
 block discarded – undo
193 193
 	 * @param array $query ( default: array ( ) )
194 194
 	 * @return void
195 195
 	 */
196
-	function sensei_course_archive_filter( $query ) {
196
+	function sensei_course_archive_filter($query) {
197 197
 
198 198
 
199
-		if ( ! $query->is_main_query() )
199
+		if ( ! $query->is_main_query())
200 200
         	return;
201 201
 
202 202
 		// Apply Filter only if on frontend and when course archive is running
203
-		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
203
+		$course_page_id = intval(Sensei()->settings->settings['course_page']);
204 204
 
205
-		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) {
205
+		if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) {
206 206
 			// Check for pagination settings
207
-   			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
208
-    			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
207
+   			if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
208
+    			$amount = absint(Sensei()->settings->settings['course_archive_amount']);
209 209
     		} else {
210
-    			$amount = $query->get( 'posts_per_page' );
210
+    			$amount = $query->get('posts_per_page');
211 211
     		} // End If Statement
212
-    		$query->set( 'posts_per_page', $amount );
212
+    		$query->set('posts_per_page', $amount);
213 213
 		} // End If Statement
214 214
 	} // End sensei_course_archive_filter()
215
-	add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
215
+	add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
216 216
 
217 217
 	/**
218 218
 	 * sensei_complete_lesson_button description
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return html
221 221
 	 */
222 222
 	function sensei_complete_lesson_button() {
223
-		do_action( 'sensei_complete_lesson_button' );
223
+		do_action('sensei_complete_lesson_button');
224 224
 	} // End sensei_complete_lesson_button()
225 225
 
226 226
 	/**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return html
230 230
 	 */
231 231
 	function sensei_reset_lesson_button() {
232
-		do_action( 'sensei_reset_lesson_button' );
232
+		do_action('sensei_reset_lesson_button');
233 233
 	} // End sensei_reset_lesson_button()
234 234
 
235 235
 	/**
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 	 * @param  integer $lesson_id
239 239
 	 * @return array $return_values
240 240
 	 */
241
-	function sensei_get_prev_next_lessons( $lesson_id = 0 ) {
241
+	function sensei_get_prev_next_lessons($lesson_id = 0) {
242 242
 
243 243
 		$return_values = array();
244 244
 		$return_values['prev_lesson'] = 0;
245 245
 		$return_values['next_lesson'] = 0;
246
-		if ( 0 < $lesson_id ) {
246
+		if (0 < $lesson_id) {
247 247
 			// Get the List of Lessons in the Course
248
-			$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
248
+			$lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
249 249
 			$all_lessons = array();
250 250
 
251
-            $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
251
+            $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id));
252 252
 
253
-            foreach( (array) $modules as $module ) {
253
+            foreach ((array) $modules as $module) {
254 254
 
255 255
                 $args = array(
256 256
                     'post_type' => 'lesson',
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                     'meta_query' => array(
260 260
                         array(
261 261
                             'key' => '_lesson_course',
262
-                            'value' => intval( $lesson_course_id ),
262
+                            'value' => intval($lesson_course_id),
263 263
                             'compare' => '='
264 264
                         )
265 265
                     ),
@@ -267,18 +267,18 @@  discard block
 block discarded – undo
267 267
                         array(
268 268
                             'taxonomy' => Sensei()->modules->taxonomy,
269 269
                             'field' => 'id',
270
-                            'terms' => intval( $module->term_id )
270
+                            'terms' => intval($module->term_id)
271 271
                         )
272 272
                     ),
273
-                    'meta_key' => '_order_module_' . $module->term_id,
273
+                    'meta_key' => '_order_module_'.$module->term_id,
274 274
                     'orderby' => 'meta_value_num date',
275 275
                     'order' => 'ASC',
276 276
                     'suppress_filters' => 0
277 277
                 );
278 278
 
279
-                $lessons = get_posts( $args );
280
-                if ( 0 < count( $lessons ) ) {
281
-                    foreach ($lessons as $lesson_item){
279
+                $lessons = get_posts($args);
280
+                if (0 < count($lessons)) {
281
+                    foreach ($lessons as $lesson_item) {
282 282
                         $all_lessons[] = $lesson_item->ID;
283 283
                     } // End For Loop
284 284
                 } // End If Statement
@@ -288,36 +288,36 @@  discard block
 block discarded – undo
288 288
                 'post_type' => 'lesson',
289 289
                 'posts_per_page' => -1,
290 290
                 'suppress_filters' => 0,
291
-                'meta_key' => '_order_' . $lesson_course_id,
291
+                'meta_key' => '_order_'.$lesson_course_id,
292 292
                 'orderby' => 'meta_value_num date',
293 293
                 'order' => 'ASC',
294 294
                 'meta_query' => array(
295 295
                     array(
296 296
                         'key' => '_lesson_course',
297
-                        'value' => intval( $lesson_course_id ),
297
+                        'value' => intval($lesson_course_id),
298 298
                     ),
299 299
                 ),
300 300
                 'post__not_in' => $all_lessons,
301 301
             );
302 302
 
303
-            $other_lessons = get_posts( $args );
304
-            if ( 0 < count( $other_lessons ) ) {
305
-				foreach ($other_lessons as $lesson_item){
303
+            $other_lessons = get_posts($args);
304
+            if (0 < count($other_lessons)) {
305
+				foreach ($other_lessons as $lesson_item) {
306 306
 					$all_lessons[] = $lesson_item->ID;
307 307
 				} // End For Loop
308 308
 			} // End If Statement
309 309
 
310
-            if ( 0 < count( $all_lessons ) ) {
310
+            if (0 < count($all_lessons)) {
311 311
 				$found_index = false;
312
-				foreach ( $all_lessons as $lesson ){
313
-					if ( $found_index && $return_values['next_lesson'] == 0 ) {
312
+				foreach ($all_lessons as $lesson) {
313
+					if ($found_index && $return_values['next_lesson'] == 0) {
314 314
 						$return_values['next_lesson'] = $lesson;
315 315
 					} // End If Statement
316
-					if ( $lesson == $lesson_id ) {
316
+					if ($lesson == $lesson_id) {
317 317
 						// Is the current post
318 318
 						$found_index = true;
319 319
 					} // End If Statement
320
-					if ( !$found_index ) {
320
+					if ( ! $found_index) {
321 321
 						$return_values['prev_lesson'] = $lesson;
322 322
 					} // End If Statement
323 323
 				} // End For Loop
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
    * @param  int|WP_Post $post_id Optional. Defaults to current post
337 337
    * @return string $excerpt
338 338
    */
339
-  function sensei_get_excerpt( $post_id = '' ) {
339
+  function sensei_get_excerpt($post_id = '') {
340 340
 
341 341
       global $post;
342 342
       _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 
345 345
   }
346 346
 
347
-	function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) {
348
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" );
349
-		return WooThemes_Sensei_Utils::user_started_course( $post_id, $user_id );
347
+	function sensei_has_user_started_course($post_id = 0, $user_id = 0) {
348
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()");
349
+		return WooThemes_Sensei_Utils::user_started_course($post_id, $user_id);
350 350
 	} // End sensei_has_user_started_course()
351 351
 
352
-	function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) {
353
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" );
354
-		return WooThemes_Sensei_Utils::user_completed_lesson( $post_id, $user_id );
352
+	function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) {
353
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()");
354
+		return WooThemes_Sensei_Utils::user_completed_lesson($post_id, $user_id);
355 355
 	} // End sensei_has_user_completed_lesson()
356 356
 
357 357
 /**
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
  * @param int $user_id
364 364
  * @return bool
365 365
 */
366
-function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) {
366
+function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) {
367 367
 
368
-    return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
368
+    return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id);
369 369
 
370 370
 } // End sensei_has_user_completed_prerequisite_lesson()
371 371
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
  * @return bool
389 389
  *
390 390
  */
391
-function sensei_have_modules( $course_post_id = '' ){
391
+function sensei_have_modules($course_post_id = '') {
392 392
 
393 393
 	global $post, $wp_query, $sensei_modules_loop;
394 394
 
@@ -396,23 +396,23 @@  discard block
 block discarded – undo
396 396
 	wp_reset_query();
397 397
 	$post = $wp_query->post;
398 398
 
399
-	if( empty( $course_post_id ) ){
399
+	if (empty($course_post_id)) {
400 400
 
401 401
 		$course_id = $post->ID;
402 402
 
403 403
 	}
404 404
 
405 405
 	// doesn't apply to none course post types
406
-	if( ! sensei_is_a_course( $course_id )  ){
406
+	if ( ! sensei_is_a_course($course_id)) {
407 407
 		return false;
408 408
 	}
409 409
 
410 410
 	// check the current item compared to the total number of modules
411
-	if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ]  ){
411
+	if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) {
412 412
 
413 413
 		return false;
414 414
 
415
-	}else{
415
+	} else {
416 416
 
417 417
 		return true;
418 418
 
@@ -426,27 +426,27 @@  discard block
 block discarded – undo
426 426
  *
427 427
  * @since 1.9.0
428 428
  */
429
-function sensei_setup_module(){
429
+function sensei_setup_module() {
430 430
 
431 431
 	global  $sensei_modules_loop, $wp_query;
432 432
 
433 433
 	// increment the index
434
-	$sensei_modules_loop[ 'current' ]++;
435
-	$index = $sensei_modules_loop[ 'current' ];
436
-	if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
434
+	$sensei_modules_loop['current']++;
435
+	$index = $sensei_modules_loop['current'];
436
+	if (isset($sensei_modules_loop['modules'][$index])) {
437 437
 
438 438
 		$sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index];
439 439
 		// setup the query for the module lessons
440 440
 		$course_id = $sensei_modules_loop['course_id'];
441 441
 		$module_term_id = $sensei_modules_loop['current_module']->term_id;
442
-		$modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
442
+		$modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id);
443 443
 
444 444
 		// setup the global wp-query only if the lessons
445
-		if( $modules_query->have_posts() ){
445
+		if ($modules_query->have_posts()) {
446 446
 
447 447
 			$wp_query = $modules_query;
448 448
 
449
-		}else{
449
+		} else {
450 450
 
451 451
 			wp_reset_query();
452 452
 
@@ -470,30 +470,30 @@  discard block
 block discarded – undo
470 470
  *
471 471
  * @return bool
472 472
  */
473
-function sensei_module_has_lessons(){
473
+function sensei_module_has_lessons() {
474 474
 
475 475
 	global $wp_query, $sensei_modules_loop;
476 476
 
477
-	if( 'lesson' == $wp_query->get('post_type') ){
477
+	if ('lesson' == $wp_query->get('post_type')) {
478 478
 
479 479
 		return have_posts();
480 480
 
481
-	}else{
481
+	} else {
482 482
 
483 483
         // if the loop has not been initiated check the first module has lessons
484
-        if( -1 == $sensei_modules_loop[ 'current' ]  ){
484
+        if ( -1 == $sensei_modules_loop['current']  ) {
485 485
 
486 486
             $index = 0;
487 487
 
488
-            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
488
+            if (isset($sensei_modules_loop['modules'][$index])) {
489 489
                 // setup the query for the module lessons
490 490
                 $course_id = $sensei_modules_loop['course_id'];
491 491
 
492
-                $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
493
-                $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
492
+                $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id;
493
+                $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id);
494 494
 
495 495
                 // setup the global wp-query only if the lessons
496
-                if( $modules_query->have_posts() ){
496
+                if ($modules_query->have_posts()) {
497 497
 
498 498
                     return true;
499 499
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
  * @uses sensei_the_module_title
518 518
  * @return string
519 519
  */
520
-function sensei_the_module_title_attribute(){
520
+function sensei_the_module_title_attribute() {
521 521
 
522
-	esc_attr_e( sensei_get_the_module_title() );
522
+	esc_attr_e(sensei_get_the_module_title());
523 523
 
524 524
 }
525 525
 
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
  *
531 531
  * @return string
532 532
  */
533
-function sensei_the_module_permalink(){
533
+function sensei_the_module_permalink() {
534 534
 
535 535
 	global $sensei_modules_loop;
536 536
 	$course_id = $sensei_modules_loop['course_id'];
537
-	$module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) );
537
+	$module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module'));
538 538
 	$module_term_id = $sensei_modules_loop['current_module']->term_id;
539 539
 
540 540
 	/**
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	 * @param int $module_term_id
547 547
 	 * @param string $course_id
548 548
 	 */
549
-	 echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id  ,$course_id ) );
549
+	 echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id));
550 550
 
551 551
 }// end sensei_the_module_permalink
552 552
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
  *
559 559
  * @return string
560 560
  */
561
-function sensei_get_the_module_title(){
561
+function sensei_get_the_module_title() {
562 562
 
563 563
 	global $sensei_modules_loop;
564 564
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * @param $module_term_id
578 578
 	 * @param $course_id
579 579
 	 */
580
-	return apply_filters( 'sensei_the_module_title',  $module_title , $module_term_id, $course_id );
580
+	return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id);
581 581
 
582 582
 }
583 583
 
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
  * @uses sensei_get_the_module_title
590 590
  * @return string
591 591
  */
592
-function sensei_the_module_title(){
592
+function sensei_the_module_title() {
593 593
 
594 594
 	echo sensei_get_the_module_title();
595 595
 
@@ -610,19 +610,19 @@  discard block
 block discarded – undo
610 610
  *
611 611
  * @return bool
612 612
  */
613
-function sensei_quiz_has_questions(){
613
+function sensei_quiz_has_questions() {
614 614
 
615 615
     global $sensei_question_loop;
616 616
 
617
-    if( !isset( $sensei_question_loop['total'] ) ){
617
+    if ( ! isset($sensei_question_loop['total'])) {
618 618
         return false;
619 619
     }
620 620
 
621
-    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
621
+    if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) {
622 622
 
623 623
         return true;
624 624
 
625
-    }else{
625
+    } else {
626 626
 
627 627
         return false;
628 628
 
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
  * @since 1.9.0
640 640
 
641 641
  */
642
-function sensei_setup_the_question(){
642
+function sensei_setup_the_question() {
643 643
 
644 644
     global $sensei_question_loop;
645 645
 
646 646
     $sensei_question_loop['current']++;
647 647
     $index = $sensei_question_loop['current'];
648
-    $sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
648
+    $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index];
649 649
 
650 650
 
651 651
 }// end sensei_setup_the_question
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
  * This function gets the type and loads the template that will handle it.
657 657
  *
658 658
  */
659
-function sensei_the_question_content(){
659
+function sensei_the_question_content() {
660 660
 
661 661
     global $sensei_question_loop;
662 662
 
663
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
663
+    $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
664 664
 
665 665
     // load the template that displays the question information.
666
-    WooThemes_Sensei_Question::load_question_template( $question_type );
666
+    WooThemes_Sensei_Question::load_question_template($question_type);
667 667
 
668 668
 }// end sensei_the_question_content
669 669
 
@@ -672,11 +672,11 @@  discard block
 block discarded – undo
672 672
  *
673 673
  * @since 1.9.0
674 674
  */
675
-function sensei_the_question_class(){
675
+function sensei_the_question_class() {
676 676
 
677 677
     global $sensei_question_loop;
678 678
 
679
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
679
+    $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
680 680
 
681 681
     /**
682 682
      * filter the sensei question class within
@@ -684,16 +684,16 @@  discard block
 block discarded – undo
684 684
      *
685 685
      * @since 1.9.0
686 686
      */
687
-     $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
687
+     $classes = apply_filters('sensei_question_classes', array($question_type));
688 688
 
689 689
     $html_classes = '';
690
-    foreach( $classes as $class ){
690
+    foreach ($classes as $class) {
691 691
 
692
-        $html_classes .= $class . ' ';
692
+        $html_classes .= $class.' ';
693 693
 
694 694
     }// end foreach
695 695
 
696
-    esc_attr_e( trim( $html_classes ) );
696
+    esc_attr_e(trim($html_classes));
697 697
 
698 698
 }
699 699
 
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
  *
703 703
  * @since 1.9.0
704 704
  */
705
-function sensei_get_the_question_id( ){
705
+function sensei_get_the_question_id( ) {
706 706
 
707 707
     global $sensei_question_loop;
708
-    if( isset( $sensei_question_loop['current_question']->ID ) ){
708
+    if (isset($sensei_question_loop['current_question']->ID)) {
709 709
 
710 710
         return $sensei_question_loop['current_question']->ID;
711 711
 
@@ -734,27 +734,27 @@  discard block
 block discarded – undo
734 734
  * @param string $lesson_id
735 735
  * @return bool
736 736
  */
737
-function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){
737
+function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') {
738 738
 
739
-    if( empty( $lesson_id ) ){
739
+    if (empty($lesson_id)) {
740 740
 
741 741
         $lesson_id = get_the_ID();
742 742
 
743 743
     }
744 744
 
745
-    if( empty( $user_id ) ){
745
+    if (empty($user_id)) {
746 746
 
747 747
         $user_id = get_current_user_id();
748 748
 
749 749
     }
750 750
 
751 751
     // Check for prerequisite lesson completions
752
-    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
753
-    $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
754
-    $user_taking_course = WooThemes_Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
752
+    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id);
753
+    $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
754
+    $user_taking_course = WooThemes_Sensei_Utils::user_started_course($lesson_course_id, $user_id);
755 755
 
756 756
     $is_preview = false;
757
-    if( WooThemes_Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
757
+    if (WooThemes_Sensei_Utils::is_preview_lesson($lesson_id)) {
758 758
 
759 759
         $is_preview = true;
760 760
         $pre_requisite_complete = true;
@@ -762,24 +762,24 @@  discard block
 block discarded – undo
762 762
     };
763 763
 
764 764
 
765
-    $user_can_access_lesson =  false;
765
+    $user_can_access_lesson = false;
766 766
 
767
-    if( is_user_logged_in() && $user_taking_course ){
767
+    if (is_user_logged_in() && $user_taking_course) {
768 768
 
769
-        $user_can_access_lesson =  true;
769
+        $user_can_access_lesson = true;
770 770
 
771 771
     }
772 772
 
773 773
 
774 774
     $access_permission = false;
775 775
 
776
-    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
776
+    if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) {
777 777
 
778 778
         $access_permission = true;
779 779
 
780 780
     }
781 781
 
782
-    $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
782
+    $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview;
783 783
 
784 784
     /**
785 785
      * Filter the can user view lesson function
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
      * @param string $lesson_id
793 793
      * @param string $user_id
794 794
      */
795
-    return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
795
+    return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id);
796 796
 
797 797
 } // end sensei_can_current_user_view_lesson
798 798
 
@@ -802,54 +802,54 @@  discard block
 block discarded – undo
802 802
  * The function should only be called on the single lesson
803 803
  *
804 804
  */
805
-function sensei_the_single_lesson_meta(){
805
+function sensei_the_single_lesson_meta() {
806 806
 
807 807
     // if the lesson meta is included within theme load that instead of the function content
808
-    $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
809
-    if( ! empty( $template ) ){
808
+    $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php');
809
+    if ( ! empty($template)) {
810 810
 
811
-        Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
811
+        Sensei_Templates::get_template('single-lesson/lesson-meta.php');
812 812
         return;
813 813
 
814 814
     }
815 815
 
816 816
     // Get the meta info
817
-    $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
818
-    $is_preview = WooThemes_Sensei_Utils::is_preview_lesson( get_the_ID() );
817
+    $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true));
818
+    $is_preview = WooThemes_Sensei_Utils::is_preview_lesson(get_the_ID());
819 819
 
820 820
     // Get User Meta
821 821
     get_currentuserinfo();
822 822
 
823 823
     // Complete Lesson Logic
824
-    do_action( 'sensei_complete_lesson' );
824
+    do_action('sensei_complete_lesson');
825 825
     // Check that the course has been started
826
-    if ( Sensei()->access_settings()
827
-        || WooThemes_Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
828
-        || $is_preview ) {
826
+    if (Sensei()->access_settings()
827
+        || WooThemes_Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())
828
+        || $is_preview) {
829 829
         ?>
830 830
         <section class="lesson-meta">
831 831
             <?php
832
-            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
832
+            if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') {
833 833
 
834
-                do_action( 'sensei_lesson_video', get_the_ID() );
834
+                do_action('sensei_lesson_video', get_the_ID());
835 835
 
836 836
             }
837 837
             ?>
838
-            <?php do_action( 'sensei_frontend_messages' ); ?>
838
+            <?php do_action('sensei_frontend_messages'); ?>
839 839
 
840 840
             <?php if ( ! $is_preview
841
-                || WooThemes_Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
841
+                || WooThemes_Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) {
842 842
 
843
-                sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
843
+                sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id()));
844 844
 
845 845
             } ?>
846 846
         </section>
847 847
 
848
-        <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?>
848
+        <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?>
849 849
 
850 850
     <?php }
851 851
 
852
-    do_action( 'sensei_lesson_meta_extra', get_the_ID() );
852
+    do_action('sensei_lesson_meta_extra', get_the_ID());
853 853
 
854 854
 } // end the_single_lesson_meta
855 855
 
@@ -863,9 +863,9 @@  discard block
 block discarded – undo
863 863
  *
864 864
  * @since 1.9.0
865 865
  */
866
-function get_sensei_header(){
866
+function get_sensei_header() {
867 867
 
868
-    if ( ! defined( 'ABSPATH' ) ) exit;
868
+    if ( ! defined('ABSPATH')) exit;
869 869
 
870 870
     get_header();
871 871
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
      *
875 875
      * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
876 876
      */
877
-    do_action( 'sensei_before_main_content' );
877
+    do_action('sensei_before_main_content');
878 878
 
879 879
 }// end get_sensei_header
880 880
 
@@ -888,28 +888,28 @@  discard block
 block discarded – undo
888 888
  *
889 889
  * @since 1.9.0
890 890
  */
891
-function get_sensei_footer(){
891
+function get_sensei_footer() {
892 892
 
893 893
     /**
894 894
      * sensei_pagination hook
895 895
      *
896 896
      * @hooked sensei_pagination - 10 (outputs pagination)
897 897
      */
898
-    do_action( 'sensei_pagination' );
898
+    do_action('sensei_pagination');
899 899
 
900 900
     /**
901 901
      * sensei_after_main_content hook
902 902
      *
903 903
      * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
904 904
      */
905
-    do_action( 'sensei_after_main_content' );
905
+    do_action('sensei_after_main_content');
906 906
 
907 907
     /**
908 908
      * sensei_sidebar hook
909 909
      *
910 910
      * @hooked sensei_get_sidebar - 10
911 911
      */
912
-    do_action( 'sensei_sidebar' );
912
+    do_action('sensei_sidebar');
913 913
 
914 914
     get_footer();
915 915
 
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
  *
922 922
  * @since 1.9.0
923 923
  */
924
-function the_no_permissions_title(){
924
+function the_no_permissions_title() {
925 925
 
926 926
     /**
927 927
      * Filter the no permissions title just before it is echo'd on the
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
      * @since 1.9.0
931 931
      * @param $no_permissions_title
932 932
      */
933
-    echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
933
+    echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']);
934 934
 
935 935
 }
936 936
 
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
  *
940 940
  * @since 1.9.0
941 941
  */
942
-function the_no_permissions_message( $post_id ){
942
+function the_no_permissions_message($post_id) {
943 943
 
944 944
     /**
945 945
      * Filter the no permissions message just before it is echo'd on the
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
      * @since 1.9.0
949 949
      * @param $no_permissions_message
950 950
      */
951
-    echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
951
+    echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id);
952 952
 
953 953
 }
954 954
 
@@ -957,10 +957,10 @@  discard block
 block discarded – undo
957 957
  *
958 958
  * @since 1.9.0
959 959
  */
960
-function sensei_the_excerpt( $post_id ){
960
+function sensei_the_excerpt($post_id) {
961 961
 
962 962
     global $post;
963
-    the_excerpt( $post );
963
+    the_excerpt($post);
964 964
 
965 965
 }
966 966
 
@@ -972,10 +972,10 @@  discard block
 block discarded – undo
972 972
  * @global WP $wp
973 973
  * @return string $current_page_url
974 974
  */
975
- function sensei_get_current_page_url(){
975
+ function sensei_get_current_page_url() {
976 976
 
977 977
      global $wp;
978
-     $current_page_url =  home_url( $wp->request );
978
+     $current_page_url = home_url($wp->request);
979 979
      return $current_page_url;
980 980
 
981 981
  }
@@ -986,9 +986,9 @@  discard block
 block discarded – undo
986 986
  *
987 987
  * @since 1.9.0
988 988
  */
989
-function sensei_the_my_courses_content(){
989
+function sensei_the_my_courses_content() {
990 990
 
991
-    echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
991
+    echo Sensei()->course->load_user_courses_content(wp_get_current_user());
992 992
 
993 993
 } // sensei_the_my_courses_content
994 994
 
@@ -1001,9 +1001,9 @@  discard block
 block discarded – undo
1001 1001
  *
1002 1002
  * @since 1.9.0
1003 1003
  */
1004
-function sensei_load_template( $template_name ){
1004
+function sensei_load_template($template_name) {
1005 1005
 
1006
-    Sensei_Templates::get_template( $template_name );
1006
+    Sensei_Templates::get_template($template_name);
1007 1007
 
1008 1008
 }
1009 1009
 
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
  * @param string $name the name of the template.
1016 1016
  * @since 1.9.0
1017 1017
  */
1018
-function sensei_load_template_part( $slug, $name ){
1018
+function sensei_load_template_part($slug, $name) {
1019 1019
 
1020
-    Sensei_Templates::get_part( $slug, $name );
1020
+    Sensei_Templates::get_part($slug, $name);
1021 1021
 
1022 1022
 }
1023 1023
 
@@ -1034,19 +1034,19 @@  discard block
 block discarded – undo
1034 1034
  * @access public
1035 1035
  * @param string $lesson_id
1036 1036
  */
1037
-function sensei_the_lesson_excerpt( $lesson_id = '' ) {
1037
+function sensei_the_lesson_excerpt($lesson_id = '') {
1038 1038
 
1039
-    if( empty( $lesson_id )){
1039
+    if (empty($lesson_id)) {
1040 1040
 
1041 1041
         $lesson_id = get_the_ID();
1042 1042
 
1043 1043
     }
1044 1044
 
1045
-    if( 'lesson' != get_post_type( $lesson_id ) ){
1045
+    if ('lesson' != get_post_type($lesson_id)) {
1046 1046
         return;
1047 1047
     }
1048 1048
 
1049
-    echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1049
+    echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false);
1050 1050
 
1051 1051
 }// End lesson_excerpt()
1052 1052
 
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
  *
1056 1056
  * @since 1.9.0
1057 1057
  */
1058
-function sensei_the_course_results_lessons(){
1058
+function sensei_the_course_results_lessons() {
1059 1059
     // load backwards compatible template name if it exists in the users theme
1060
-    $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1061
-    if( $located_template ){
1060
+    $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php');
1061
+    if ($located_template) {
1062 1062
 
1063
-        Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1063
+        Sensei_Templates::get_template('course-results/course-lessons.php');
1064 1064
         return;
1065 1065
 
1066 1066
     }
1067 1067
 
1068
-    Sensei_Templates::get_template( 'course-results/lessons.php' );
1068
+    Sensei_Templates::get_template('course-results/lessons.php');
1069 1069
 }
1070 1070
 
1071 1071
 /**
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
  * @uses Sensei_Course::get_loop_number_of_columns
1076 1076
  * @since 1.9.0
1077 1077
  */
1078
-function sensei_courses_per_row(){
1078
+function sensei_courses_per_row() {
1079 1079
 
1080 1080
     echo Sensei_Course::get_loop_number_of_columns();
1081 1081
 
Please login to merge, or discard this patch.
templates/no-permissions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 ?>
13 13
 
14
-<?php  get_sensei_header();  ?>
14
+<?php  get_sensei_header(); ?>
15 15
 
16 16
 <?php
17 17
 /**
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  * @since 1.9.0
22 22
  * @param $post_id
23 23
  */
24
-do_action('sensei_no_permissions_before_content', get_the_ID() );
24
+do_action('sensei_no_permissions_before_content', get_the_ID());
25 25
 ?>
26 26
 
27
-<article <?php post_class( 'no-permission' ) ?> >
27
+<article <?php post_class('no-permission') ?> >
28 28
 
29 29
     <header>
30 30
 
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
      * @since 1.9.0
41 41
      * @param $post_id
42 42
      */
43
-    do_action('sensei_no_permissions_inside_before_content', get_the_ID() );
43
+    do_action('sensei_no_permissions_inside_before_content', get_the_ID());
44 44
     ?>
45 45
 
46 46
     <section class="entry fix">
47 47
 
48 48
         <div class="sensei-message alert">
49 49
 
50
-            <?php the_no_permissions_message( get_the_ID() ); ?>
50
+            <?php the_no_permissions_message(get_the_ID()); ?>
51 51
 
52 52
         </div>
53 53
 
54 54
         <p class="excerpt">
55 55
 
56
-            <?php sensei_the_excerpt( get_the_ID() ); ?>
56
+            <?php sensei_the_excerpt(get_the_ID()); ?>
57 57
 
58 58
         </p>
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @since 1.9.0
68 68
      * @param $post_id
69 69
      */
70
-    do_action('sensei_no_permissions_inside_after_content', get_the_ID() );
70
+    do_action('sensei_no_permissions_inside_after_content', get_the_ID());
71 71
     ?>
72 72
 
73 73
 </article><!-- .no-permissions -->
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @since 1.9.0
81 81
  * @param $post_id
82 82
  */
83
-do_action('sensei_no_permissions_after_content', get_the_ID() );
83
+do_action('sensei_no_permissions_after_content', get_the_ID());
84 84
 ?>
85 85
 
86 86
 <?php get_sensei_footer(); ?>
87 87
\ No newline at end of file
Please login to merge, or discard this patch.