Completed
Push — master ( e3266d...1e8c99 )
by Dwain
06:18
created
includes/class-sensei-quiz.php 1 patch
Spacing   +286 added lines, -286 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 Quiz Class
@@ -23,24 +23,24 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param $file
25 25
 	 */
26
-	public function __construct ( $file = __FILE__ ) {
26
+	public function __construct($file = __FILE__) {
27 27
 		$this->file = $file;
28
-		$this->meta_fields = array( 'quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required','enable_quiz_reset' );
29
-		add_action( 'save_post', array( $this, 'update_author' ));
28
+		$this->meta_fields = array('quiz_passmark', 'quiz_lesson', 'quiz_type', 'quiz_grade_type', 'pass_required', 'enable_quiz_reset');
29
+		add_action('save_post', array($this, 'update_author'));
30 30
 
31 31
 		// listen to the reset button click
32
-		add_action( 'template_redirect', array( $this, 'reset_button_click_listener'  ) );
32
+		add_action('template_redirect', array($this, 'reset_button_click_listener'));
33 33
 
34 34
         // fire the complete quiz button submit for grading action
35
-        add_action( 'sensei_complete_quiz', array( $this, 'user_quiz_submit_listener' ) );
35
+        add_action('sensei_complete_quiz', array($this, 'user_quiz_submit_listener'));
36 36
 
37 37
 		// fire the save user answers quiz button click responder
38
-		add_action( 'sensei_complete_quiz', array( $this, 'user_save_quiz_answers_listener' ) );
38
+		add_action('sensei_complete_quiz', array($this, 'user_save_quiz_answers_listener'));
39 39
 
40 40
         // fire the load global data function
41
-        add_action( 'sensei_complete_quiz', array( $this, 'load_global_quiz_data' ), 80 );
41
+        add_action('sensei_complete_quiz', array($this, 'load_global_quiz_data'), 80);
42 42
 
43
-        add_action( 'template_redirect', array ( $this, 'quiz_has_no_questions') );
43
+        add_action('template_redirect', array($this, 'quiz_has_no_questions'));
44 44
 
45 45
 
46 46
     } // End __construct()
@@ -51,26 +51,26 @@  discard block
 block discarded – undo
51 51
 	* @param int $post_id
52 52
 	* @return void
53 53
 	*/
54
-	public function update_author( $post_id ){
54
+	public function update_author($post_id) {
55 55
 
56 56
 
57 57
 		// If this isn't a 'lesson' post, don't update it.
58 58
         // if this is a revision don't save it
59
-	    if ( isset( $_POST['post_type'] ) && 'lesson' != $_POST['post_type']
60
-            || wp_is_post_revision( $post_id ) ) {
59
+	    if (isset($_POST['post_type']) && 'lesson' != $_POST['post_type']
60
+            || wp_is_post_revision($post_id)) {
61 61
 
62 62
                 return;
63 63
 
64 64
         }
65 65
 	    // get the lesson author id to be use late
66
-	    $saved_post = get_post( $post_id );
67
-	    $new_lesson_author_id =  $saved_post->post_author;
66
+	    $saved_post = get_post($post_id);
67
+	    $new_lesson_author_id = $saved_post->post_author;
68 68
 
69 69
 	    //get the lessons quiz
70
-		$lesson_quizzes = Sensei()->lesson->lesson_quizzes( $post_id );
71
-	    foreach ( (array) $lesson_quizzes as $quiz_item ) {
70
+		$lesson_quizzes = Sensei()->lesson->lesson_quizzes($post_id);
71
+	    foreach ((array) $lesson_quizzes as $quiz_item) {
72 72
 
73
-	    	if( ! $quiz_item ) {
73
+	    	if ( ! $quiz_item) {
74 74
 	    		continue;
75 75
 	    	}
76 76
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			);
82 82
 
83 83
             // remove the action so that it doesn't fire again
84
-            remove_action( 'save_post', array( $this, 'update_author' ));
84
+            remove_action('save_post', array($this, 'update_author'));
85 85
 
86 86
 			// Update the post into the database
87
-		  	wp_update_post( $my_post );
87
+		  	wp_update_post($my_post);
88 88
 	    }
89 89
 
90 90
 	    return;
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	 * @param int $quiz_id
99 99
 	 * @return int @lesson_id
100 100
 	 */
101
-	public function get_lesson_id( $quiz_id ){
101
+	public function get_lesson_id($quiz_id) {
102 102
 
103
-		if( empty( $quiz_id ) || ! intval( $quiz_id ) > 0 ){
103
+		if (empty($quiz_id) || ! intval($quiz_id) > 0) {
104 104
 			global $post;
105
-			if( 'quiz' == get_post_type( $post ) ){
105
+			if ('quiz' == get_post_type($post)) {
106 106
 				$quiz_id = $post->ID;
107
-			}else{
107
+			} else {
108 108
 				return false;
109 109
 			}
110 110
 
111 111
 		}
112 112
 
113
-		$quiz = get_post( $quiz_id );
113
+		$quiz = get_post($quiz_id);
114 114
 		$lesson_id = $quiz->post_parent;
115 115
 
116 116
 		return $lesson_id;
@@ -125,23 +125,23 @@  discard block
 block discarded – undo
125 125
      * @since 1.7.3
126 126
      * @return bool $saved;
127 127
      */
128
-    public function user_save_quiz_answers_listener(){
128
+    public function user_save_quiz_answers_listener() {
129 129
 
130
-        if( ! isset( $_POST[ 'quiz_save' ])
131
-            || !isset( $_POST[ 'sensei_question' ] )
132
-            || empty( $_POST[ 'sensei_question' ] )
133
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce'  ) > 1 ) {
130
+        if ( ! isset($_POST['quiz_save'])
131
+            || ! isset($_POST['sensei_question'])
132
+            || empty($_POST['sensei_question'])
133
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce') > 1) {
134 134
             return;
135 135
         }
136 136
 
137 137
         global $post;
138
-        $lesson_id = $this->get_lesson_id( $post->ID );
139
-        $quiz_answers = $_POST[ 'sensei_question' ];
138
+        $lesson_id = $this->get_lesson_id($post->ID);
139
+        $quiz_answers = $_POST['sensei_question'];
140 140
         // call the save function
141
-        self::save_user_answers( $quiz_answers, $_FILES , $lesson_id  , get_current_user_id() );
141
+        self::save_user_answers($quiz_answers, $_FILES, $lesson_id, get_current_user_id());
142 142
 
143 143
         // remove the hook as it should only fire once per click
144
-        remove_action( 'sensei_complete_quiz', 'user_save_quiz_answers_listener' );
144
+        remove_action('sensei_complete_quiz', 'user_save_quiz_answers_listener');
145 145
 
146 146
     } // end user_save_quiz_answers_listener
147 147
 
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return false or int $answers_saved
162 162
 	 */
163
-	public static function save_user_answers( $quiz_answers, $files = array(), $lesson_id , $user_id = 0 ){
163
+	public static function save_user_answers($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
164 164
 
165
-        if( ! ( $user_id > 0 ) ){
165
+        if ( ! ($user_id > 0)) {
166 166
             $user_id = get_current_user_id();
167 167
         }
168 168
 
169 169
         // make sure the parameters are valid before continuing
170
-		if( empty( $lesson_id ) || empty( $user_id )
171
-			|| 'lesson' != get_post_type( $lesson_id )
172
-			||!get_userdata( $user_id )
173
-			|| !is_array( $quiz_answers ) ){
170
+		if (empty($lesson_id) || empty($user_id)
171
+			|| 'lesson' != get_post_type($lesson_id)
172
+			||! get_userdata($user_id)
173
+			|| ! is_array($quiz_answers)) {
174 174
 
175 175
 			return false;
176 176
 
@@ -178,23 +178,23 @@  discard block
 block discarded – undo
178 178
 
179 179
 
180 180
         // start the lesson before saving the data in case the user has not started the lesson
181
-        $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
181
+        $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
182 182
 
183 183
 		//prepare the answers
184
-		$prepared_answers = self::prepare_form_submitted_answers( $quiz_answers , $files );
184
+		$prepared_answers = self::prepare_form_submitted_answers($quiz_answers, $files);
185 185
 
186 186
 		// save the user data
187
-        $answers_saved = Sensei_Utils::add_user_data( 'quiz_answers', $lesson_id, $prepared_answers, $user_id ) ;
187
+        $answers_saved = Sensei_Utils::add_user_data('quiz_answers', $lesson_id, $prepared_answers, $user_id);
188 188
 
189 189
 		// were the answers saved correctly?
190
-		if( intval( $answers_saved ) > 0){
190
+		if (intval($answers_saved) > 0) {
191 191
 
192 192
             // save transient to make retrieval faster
193 193
             $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
194
-            set_transient( $transient_key, $prepared_answers, 10 * DAY_IN_SECONDS );
194
+            set_transient($transient_key, $prepared_answers, 10 * DAY_IN_SECONDS);
195 195
 
196 196
             // update the message showed to user
197
-            Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Saved Successfully.', 'woothemes-sensei' )  . '</div>';
197
+            Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Saved Successfully.', 'woothemes-sensei').'</div>';
198 198
         }
199 199
 
200 200
 		return $answers_saved;
@@ -216,41 +216,41 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @return array $answers or false
218 218
 	 */
219
-	public function get_user_answers( $lesson_id, $user_id ){
219
+	public function get_user_answers($lesson_id, $user_id) {
220 220
 
221 221
 		$answers = false;
222 222
 
223
-		if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
224
-		|| ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
223
+		if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
224
+		|| ! intval($user_id) > 0 || ! get_userdata($user_id)) {
225 225
 			return false;
226 226
 		}
227 227
 
228 228
         // save some time and get the transient cached data
229 229
         $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
230
-        $transient_cached_answers = get_transient( $transient_key );
230
+        $transient_cached_answers = get_transient($transient_key);
231 231
 
232 232
         // return the transient or get the values get the values from the comment meta
233
-        if( !empty( $transient_cached_answers  ) && false != $transient_cached_answers ){
233
+        if ( ! empty($transient_cached_answers) && false != $transient_cached_answers) {
234 234
 
235 235
             $encoded_user_answers = $transient_cached_answers;
236 236
 
237
-        }else{
237
+        } else {
238 238
 
239
-            $encoded_user_answers = Sensei_Utils::get_user_data( 'quiz_answers', $lesson_id  , $user_id );
239
+            $encoded_user_answers = Sensei_Utils::get_user_data('quiz_answers', $lesson_id, $user_id);
240 240
 
241 241
         } // end if transient check
242 242
 
243
-		if( ! is_array( $encoded_user_answers ) ){
243
+		if ( ! is_array($encoded_user_answers)) {
244 244
 			return false;
245 245
 		}
246 246
 
247 247
         //set the transient with the new valid data for faster retrieval in future
248
-        set_transient( $transient_key,  $encoded_user_answers, 10 * DAY_IN_SECONDS);
248
+        set_transient($transient_key, $encoded_user_answers, 10 * DAY_IN_SECONDS);
249 249
 
250 250
 		// decode an unserialize all answers
251
-		foreach( $encoded_user_answers as $question_id => $encoded_answer ) {
252
-			$decoded_answer = base64_decode( $encoded_answer );
253
-			$answers[$question_id] = maybe_unserialize( $decoded_answer );
251
+		foreach ($encoded_user_answers as $question_id => $encoded_answer) {
252
+			$decoded_answer = base64_decode($encoded_answer);
253
+			$answers[$question_id] = maybe_unserialize($decoded_answer);
254 254
 		}
255 255
 
256 256
 		return $answers;
@@ -267,23 +267,23 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return void;
269 269
 	 */
270
-	public function reset_button_click_listener( ){
270
+	public function reset_button_click_listener( ) {
271 271
 
272
-		if( ! isset( $_POST[ 'quiz_reset' ])
273
-			||  ! wp_verify_nonce( $_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce'  ) > 1 ) {
272
+		if ( ! isset($_POST['quiz_reset'])
273
+			||  ! wp_verify_nonce($_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce') > 1) {
274 274
 
275 275
 			return; // exit
276 276
 		}
277 277
 
278 278
 		global $post;
279 279
 		$current_quiz_id = $post->ID;
280
-		$lesson_id = $this->get_lesson_id( $current_quiz_id );
280
+		$lesson_id = $this->get_lesson_id($current_quiz_id);
281 281
 
282 282
         // reset all user data
283
-        $this->reset_user_lesson_data( $lesson_id, get_current_user_id() );
283
+        $this->reset_user_lesson_data($lesson_id, get_current_user_id());
284 284
 
285 285
 		//this function should only run once
286
-		remove_action( 'template_redirect', array( $this, 'reset_button_click_listener'  ) );
286
+		remove_action('template_redirect', array($this, 'reset_button_click_listener'));
287 287
 
288 288
 	} // end reset_button_click_listener
289 289
 
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
 	public function user_quiz_submit_listener() {
303 303
 
304 304
         // only respond to valid quiz completion submissions
305
-        if( ! isset( $_POST[ 'quiz_complete' ])
306
-            || !isset( $_POST[ 'sensei_question' ] )
307
-            || empty( $_POST[ 'sensei_question' ] )
308
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce'  ) > 1 ) {
305
+        if ( ! isset($_POST['quiz_complete'])
306
+            || ! isset($_POST['sensei_question'])
307
+            || empty($_POST['sensei_question'])
308
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce') > 1) {
309 309
             return;
310 310
         }
311 311
 
312 312
         global $post, $current_user;
313
-        $lesson_id = $this->get_lesson_id( $post->ID );
314
-        $quiz_answers = $_POST[ 'sensei_question' ];
313
+        $lesson_id = $this->get_lesson_id($post->ID);
314
+        $quiz_answers = $_POST['sensei_question'];
315 315
 
316
-        self::submit_answers_for_grading( $quiz_answers, $_FILES ,  $lesson_id  , $current_user->ID );
316
+        self::submit_answers_for_grading($quiz_answers, $_FILES, $lesson_id, $current_user->ID);
317 317
 
318 318
 	} // End sensei_complete_quiz()
319 319
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      * @access public
328 328
      *
329 329
      */
330
-    public function load_global_quiz_data(){
330
+    public function load_global_quiz_data() {
331 331
 
332 332
         global  $post, $current_user;
333 333
         $this->data = new stdClass();
@@ -336,46 +336,46 @@  discard block
 block discarded – undo
336 336
         $grade = 0;
337 337
 
338 338
         // Get Quiz Questions
339
-        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $post->ID );
339
+        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($post->ID);
340 340
 
341
-        $quiz_lesson_id = absint( get_post_meta( $post->ID, '_quiz_lesson', true ) );
341
+        $quiz_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
342 342
 
343 343
         // Get quiz grade type
344
-        $quiz_grade_type = get_post_meta( $post->ID, '_quiz_grade_type', true );
344
+        $quiz_grade_type = get_post_meta($post->ID, '_quiz_grade_type', true);
345 345
 
346 346
         // Get quiz pass setting
347
-        $pass_required = get_post_meta( $post->ID, '_pass_required', true );
347
+        $pass_required = get_post_meta($post->ID, '_pass_required', true);
348 348
 
349 349
         // Get quiz pass mark
350
-        $quiz_passmark = abs( round( doubleval( get_post_meta( $post->ID, '_quiz_passmark', true ) ), 2 ) );
350
+        $quiz_passmark = abs(round(doubleval(get_post_meta($post->ID, '_quiz_passmark', true)), 2));
351 351
 
352 352
         // Get latest quiz answers and grades
353
-        $lesson_id = Sensei()->quiz->get_lesson_id( $post->ID );
354
-        $user_quizzes = Sensei()->quiz->get_user_answers( $lesson_id, get_current_user_id() );
355
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $current_user->ID );
353
+        $lesson_id = Sensei()->quiz->get_lesson_id($post->ID);
354
+        $user_quizzes = Sensei()->quiz->get_user_answers($lesson_id, get_current_user_id());
355
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $current_user->ID);
356 356
         $user_quiz_grade = 0;
357
-        if( isset( $user_lesson_status->comment_ID ) ) {
358
-            $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
357
+        if (isset($user_lesson_status->comment_ID)) {
358
+            $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
359 359
         }
360 360
 
361
-        if ( ! is_array($user_quizzes) ) { $user_quizzes = array(); }
361
+        if ( ! is_array($user_quizzes)) { $user_quizzes = array(); }
362 362
 
363 363
         // Check again that the lesson is complete
364
-        $user_lesson_end = Sensei_Utils::user_completed_lesson( $user_lesson_status );
364
+        $user_lesson_end = Sensei_Utils::user_completed_lesson($user_lesson_status);
365 365
         $user_lesson_complete = false;
366
-        if ( $user_lesson_end ) {
366
+        if ($user_lesson_end) {
367 367
             $user_lesson_complete = true;
368 368
         } // End If Statement
369 369
 
370
-        $reset_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true );
370
+        $reset_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
371 371
         //backwards compatibility
372
-        if( 'on' == $reset_allowed ) {
372
+        if ('on' == $reset_allowed) {
373 373
             $reset_allowed = 1;
374 374
         }
375 375
 
376 376
         // Build frontend data object for backwards compatibility
377 377
         // using this is no longer recommended
378
-        $this->data->user_quiz_grade = $user_quiz_grade;// Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
378
+        $this->data->user_quiz_grade = $user_quiz_grade; // Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
379 379
         $this->data->quiz_passmark = $quiz_passmark;
380 380
         $this->data->quiz_lesson = $quiz_lesson_id;
381 381
         $this->data->quiz_grade_type = $quiz_grade_type; // get_post_meta( $quiz_id, '_quiz_grade_type', true );
@@ -400,41 +400,41 @@  discard block
 block discarded – undo
400 400
 	 * @param $files
401 401
 	 * @return array
402 402
 	 */
403
-	public static function prepare_form_submitted_answers( $unprepared_answers,  $files ){
403
+	public static function prepare_form_submitted_answers($unprepared_answers, $files) {
404 404
 
405 405
 
406 406
 		$prepared_answers = array();
407 407
 
408 408
 		// validate incoming answers
409
-		if( empty( $unprepared_answers  ) || ! is_array( $unprepared_answers ) ){
409
+		if (empty($unprepared_answers) || ! is_array($unprepared_answers)) {
410 410
 			return false;
411 411
 		}
412 412
 
413 413
 		// Loop through submitted quiz answers and save them appropriately
414
-		foreach( $unprepared_answers as $question_id => $answer ) {
414
+		foreach ($unprepared_answers as $question_id => $answer) {
415 415
 
416 416
 			//get the current questions question type
417
-            $question_type = Sensei()->question->get_question_type( $question_id );
417
+            $question_type = Sensei()->question->get_question_type($question_id);
418 418
 
419 419
 			// Sanitise answer
420
-			if( 0 == get_magic_quotes_gpc() ) {
421
-				$answer = wp_unslash( $answer );
420
+			if (0 == get_magic_quotes_gpc()) {
421
+				$answer = wp_unslash($answer);
422 422
 			}
423 423
 
424 424
             // compress the answer for saving
425
-			if( 'multi-line' == $question_type ) {
426
-                $answer = esc_html( $answer );
427
-            }elseif( 'file-upload' == $question_type  ){
428
-                $file_key = 'file_upload_' . $question_id;
429
-                if( isset( $files[ $file_key ] ) ) {
430
-                        $attachment_id = Sensei_Utils::upload_file(  $files[ $file_key ] );
431
-                        if( $attachment_id ) {
425
+			if ('multi-line' == $question_type) {
426
+                $answer = esc_html($answer);
427
+            }elseif ('file-upload' == $question_type) {
428
+                $file_key = 'file_upload_'.$question_id;
429
+                if (isset($files[$file_key])) {
430
+                        $attachment_id = Sensei_Utils::upload_file($files[$file_key]);
431
+                        if ($attachment_id) {
432 432
                             $answer = $attachment_id;
433 433
                         }
434 434
                     }
435 435
             } // end if
436 436
 
437
-			$prepared_answers[ $question_id ] =  base64_encode( maybe_serialize( $answer ) );
437
+			$prepared_answers[$question_id] = base64_encode(maybe_serialize($answer));
438 438
 
439 439
 		}// end for each $quiz_answers
440 440
 
@@ -454,54 +454,54 @@  discard block
 block discarded – undo
454 454
      * @param int $user_id
455 455
      * @param int $lesson_id
456 456
      */
457
-    public function reset_user_lesson_data( $lesson_id , $user_id = 0 ){
457
+    public function reset_user_lesson_data($lesson_id, $user_id = 0) {
458 458
 
459 459
         //make sure the parameters are valid
460
-        if( empty( $lesson_id ) || empty( $user_id )
461
-            || 'lesson' != get_post_type( $lesson_id )
462
-            || ! get_userdata( $user_id ) ){
460
+        if (empty($lesson_id) || empty($user_id)
461
+            || 'lesson' != get_post_type($lesson_id)
462
+            || ! get_userdata($user_id)) {
463 463
             return false;
464 464
         }
465 465
 
466 466
 
467 467
 
468 468
         //get the users lesson status to make
469
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
470
-        if( ! isset( $user_lesson_status->comment_ID ) ) {
469
+        $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
470
+        if ( ! isset($user_lesson_status->comment_ID)) {
471 471
             // this user is not taking this lesson so this process is not needed
472 472
             return false;
473 473
         }
474 474
 
475 475
         //get the lesson quiz and course
476
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
477
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
476
+        $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
477
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
478 478
 
479 479
         // reset the transients
480 480
         $answers_transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
481 481
         $grades_transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
482 482
         $answers_feedback_transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
483
-        delete_transient( $answers_transient_key );
484
-        delete_transient( $grades_transient_key );
485
-        delete_transient( $answers_feedback_transient_key );
483
+        delete_transient($answers_transient_key);
484
+        delete_transient($grades_transient_key);
485
+        delete_transient($answers_feedback_transient_key);
486 486
 
487 487
         // reset the quiz answers and feedback notes
488
-        $deleted_answers = Sensei_Utils::delete_user_data( 'quiz_answers', $lesson_id, $user_id );
489
-        $deleted_grades = Sensei_Utils::delete_user_data( 'quiz_grades', $lesson_id, $user_id );
490
-        $deleted_user_feedback = Sensei_Utils::delete_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
488
+        $deleted_answers = Sensei_Utils::delete_user_data('quiz_answers', $lesson_id, $user_id);
489
+        $deleted_grades = Sensei_Utils::delete_user_data('quiz_grades', $lesson_id, $user_id);
490
+        $deleted_user_feedback = Sensei_Utils::delete_user_data('quiz_answers_feedback', $lesson_id, $user_id);
491 491
 
492 492
         // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade
493
-        Sensei_Utils::sensei_delete_quiz_answers( $quiz_id, $user_id );
493
+        Sensei_Utils::sensei_delete_quiz_answers($quiz_id, $user_id);
494 494
 
495
-        Sensei_Utils::update_lesson_status( $user_id , $lesson_id, 'in-progress', array( 'questions_asked' => '', 'grade' => '' ) );
495
+        Sensei_Utils::update_lesson_status($user_id, $lesson_id, 'in-progress', array('questions_asked' => '', 'grade' => ''));
496 496
 
497 497
         // Update course completion
498
-        Sensei_Utils::update_course_status( $user_id, $course_id );
498
+        Sensei_Utils::update_course_status($user_id, $course_id);
499 499
 
500 500
         // Run any action on quiz/lesson reset (previously this didn't occur on resetting a quiz, see resetting a lesson in sensei_complete_lesson()
501
-        do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id );
502
-        Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Reset Successfully.', 'woothemes-sensei' ) . '</div>';
501
+        do_action('sensei_user_lesson_reset', $user_id, $lesson_id);
502
+        Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Reset Successfully.', 'woothemes-sensei').'</div>';
503 503
 
504
-        return ( $deleted_answers && $deleted_grades ) ;
504
+        return ($deleted_answers && $deleted_grades);
505 505
 
506 506
     } // end reset_user_lesson_data
507 507
 
@@ -521,20 +521,20 @@  discard block
 block discarded – undo
521 521
       *
522 522
       * @return bool $answers_submitted
523 523
       */
524
-     public static function submit_answers_for_grading( $quiz_answers , $files = array() , $lesson_id , $user_id = 0 ){
524
+     public static function submit_answers_for_grading($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
525 525
 
526 526
          $answers_submitted = false;
527 527
 
528 528
          // get the user_id if none was passed in use the current logged in user
529
-         if( ! intval( $user_id ) > 0 ) {
529
+         if ( ! intval($user_id) > 0) {
530 530
              $user_id = get_current_user_id();
531 531
          }
532 532
 
533 533
          // make sure the parameters are valid before continuing
534
-         if( empty( $lesson_id ) || empty( $user_id )
535
-             || 'lesson' != get_post_type( $lesson_id )
536
-             ||!get_userdata( $user_id )
537
-             || !is_array( $quiz_answers ) ){
534
+         if (empty($lesson_id) || empty($user_id)
535
+             || 'lesson' != get_post_type($lesson_id)
536
+             ||! get_userdata($user_id)
537
+             || ! is_array($quiz_answers)) {
538 538
 
539 539
              return false;
540 540
 
@@ -544,38 +544,38 @@  discard block
 block discarded – undo
544 544
          $grade = 0;
545 545
 
546 546
          // Get Quiz ID
547
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
547
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
548 548
 
549 549
          // Get quiz grade type
550
-         $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
550
+         $quiz_grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true);
551 551
 
552 552
          // Get quiz pass setting
553
-         $pass_required = get_post_meta( $quiz_id, '_pass_required', true );
553
+         $pass_required = get_post_meta($quiz_id, '_pass_required', true);
554 554
 
555 555
          // Get the minimum percentage need to pass this quiz
556
-         $quiz_pass_percentage = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
556
+         $quiz_pass_percentage = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
557 557
 
558 558
          // Handle Quiz Questions asked
559 559
          // This is to ensure we save the questions that we've asked this user and that this can't be change unless
560 560
          // the quiz is reset by admin or user( user: only if the setting is enabled ).
561 561
          // get the questions asked when when the quiz questions were generated for the user : Sensei_Lesson::lesson_quiz_questions
562
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
563
-         $questions_asked = get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true );
564
-         if( empty( $questions_asked ) ){
562
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
563
+         $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
564
+         if (empty($questions_asked)) {
565 565
 
566
-             $questions_asked = array_keys( $quiz_answers );
567
-             $questions_asked_string = implode( ',', $questions_asked );
566
+             $questions_asked = array_keys($quiz_answers);
567
+             $questions_asked_string = implode(',', $questions_asked);
568 568
 
569 569
              // Save questions that were asked in this quiz
570
-             update_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string );
570
+             update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string);
571 571
 
572 572
          }
573 573
 
574 574
          // Save Quiz Answers for grading, the save function also calls the sensei_start_lesson
575
-         self::save_user_answers( $quiz_answers , $files , $lesson_id , $user_id );
575
+         self::save_user_answers($quiz_answers, $files, $lesson_id, $user_id);
576 576
 
577 577
          // Grade quiz
578
-         $grade = Sensei_Grading::grade_quiz_auto( $quiz_id, $quiz_answers, 0 , $quiz_grade_type );
578
+         $grade = Sensei_Grading::grade_quiz_auto($quiz_id, $quiz_answers, 0, $quiz_grade_type);
579 579
 
580 580
          // Get Lesson Grading Setting
581 581
          $lesson_metadata = array();
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
          $answers_submitted = true;
586 586
 
587 587
          // if this condition is false the quiz should manually be graded by admin
588
-         if ('auto' == $quiz_grade_type && ! is_wp_error( $grade )  ) {
588
+         if ('auto' == $quiz_grade_type && ! is_wp_error($grade)) {
589 589
 
590 590
              // Quiz has been automatically Graded
591
-             if ( 'on' == $pass_required ) {
591
+             if ('on' == $pass_required) {
592 592
 
593 593
                  // Student has reached the pass mark and lesson is complete
594
-                 if ( $quiz_pass_percentage <= $grade ) {
594
+                 if ($quiz_pass_percentage <= $grade) {
595 595
 
596 596
                      $lesson_status = 'passed';
597 597
 
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 
613 613
          } // end if ! is_wp_error( $grade ...
614 614
 
615
-         Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $lesson_status, $lesson_metadata );
615
+         Sensei_Utils::update_lesson_status($user_id, $lesson_id, $lesson_status, $lesson_metadata);
616 616
 
617
-         if( 'passed' == $lesson_status || 'graded' == $lesson_status ){
617
+         if ('passed' == $lesson_status || 'graded' == $lesson_status) {
618 618
 
619 619
              /**
620 620
               * Lesson end action hook
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
               * @param int $user_id
625 625
               * @param int $lesson_id
626 626
               */
627
-             do_action( 'sensei_user_lesson_end', $user_id, $lesson_id );
627
+             do_action('sensei_user_lesson_end', $user_id, $lesson_id);
628 628
 
629 629
          }
630 630
 
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
           * @param string $quiz_pass_percentage
641 641
           * @param string $quiz_grade_type
642 642
           */
643
-         do_action( 'sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type );
643
+         do_action('sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type);
644 644
 
645 645
          return $answers_submitted;
646 646
 
@@ -660,38 +660,38 @@  discard block
 block discarded – undo
660 660
       *
661 661
       * @return bool $answers_submitted
662 662
       */
663
-     public function get_user_question_answer( $lesson_id, $question_id, $user_id = 0 ){
663
+     public function get_user_question_answer($lesson_id, $question_id, $user_id = 0) {
664 664
 
665 665
          // parameter validation
666
-         if( empty( $lesson_id ) || empty( $question_id )
667
-             || ! ( intval( $lesson_id  ) > 0 )
668
-             || ! ( intval( $question_id  ) > 0 )
669
-             || 'lesson' != get_post_type( $lesson_id )
670
-             || 'question' != get_post_type( $question_id )) {
666
+         if (empty($lesson_id) || empty($question_id)
667
+             || ! (intval($lesson_id) > 0)
668
+             || ! (intval($question_id) > 0)
669
+             || 'lesson' != get_post_type($lesson_id)
670
+             || 'question' != get_post_type($question_id)) {
671 671
 
672 672
              return false;
673 673
          }
674 674
 
675
-         if( ! ( intval( $user_id ) > 0 )   ){
675
+         if ( ! (intval($user_id) > 0)) {
676 676
              $user_id = get_current_user_id();
677 677
          }
678 678
 
679
-         $users_answers = $this->get_user_answers( $lesson_id, $user_id );
679
+         $users_answers = $this->get_user_answers($lesson_id, $user_id);
680 680
 
681
-         if( !$users_answers || empty( $users_answers )
682
-         ||  ! is_array( $users_answers ) || ! isset( $users_answers[ $question_id ] ) ){
681
+         if ( ! $users_answers || empty($users_answers)
682
+         ||  ! is_array($users_answers) || ! isset($users_answers[$question_id])) {
683 683
 
684 684
              //Fallback for pre 1.7.4 data
685
-             $comment =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ), true );
685
+             $comment = Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer'), true);
686 686
 
687
-             if( ! isset( $comment->comment_content ) ){
687
+             if ( ! isset($comment->comment_content)) {
688 688
                  return false;
689 689
              }
690 690
 
691
-             return maybe_unserialize( base64_decode( $comment->comment_content ) );
691
+             return maybe_unserialize(base64_decode($comment->comment_content));
692 692
          }
693 693
 
694
-         return $users_answers[ $question_id ];
694
+         return $users_answers[$question_id];
695 695
 
696 696
      }// end get_user_question_answer
697 697
 
@@ -712,18 +712,18 @@  discard block
 block discarded – undo
712 712
       *
713 713
       * @return bool
714 714
       */
715
-     public function set_user_grades( $quiz_grades, $lesson_id, $user_id = 0 ){
715
+     public function set_user_grades($quiz_grades, $lesson_id, $user_id = 0) {
716 716
 
717 717
          // get the user_id if none was passed in use the current logged in user
718
-         if( ! intval( $user_id ) > 0 ) {
718
+         if ( ! intval($user_id) > 0) {
719 719
              $user_id = get_current_user_id();
720 720
          }
721 721
 
722 722
          // make sure the parameters are valid before continuing
723
-         if( empty( $lesson_id ) || empty( $user_id )
724
-             || 'lesson' != get_post_type( $lesson_id )
725
-             ||!get_userdata( $user_id )
726
-             || !is_array( $quiz_grades ) ){
723
+         if (empty($lesson_id) || empty($user_id)
724
+             || 'lesson' != get_post_type($lesson_id)
725
+             ||! get_userdata($user_id)
726
+             || ! is_array($quiz_grades)) {
727 727
 
728 728
              return false;
729 729
 
@@ -732,15 +732,15 @@  discard block
 block discarded – undo
732 732
          $success = false;
733 733
 
734 734
          // save that data for the user on the lesson comment meta
735
-         $comment_meta_id = Sensei_Utils::add_user_data( 'quiz_grades', $lesson_id, $quiz_grades, $user_id   );
735
+         $comment_meta_id = Sensei_Utils::add_user_data('quiz_grades', $lesson_id, $quiz_grades, $user_id);
736 736
 
737 737
          // were the grades save successfully ?
738
-         if( intval( $comment_meta_id ) > 0 ) {
738
+         if (intval($comment_meta_id) > 0) {
739 739
 
740 740
              $success = true;
741 741
              // save transient
742
-             $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
743
-             set_transient( $transient_key, $quiz_grades, 10 * DAY_IN_SECONDS );
742
+             $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
743
+             set_transient($transient_key, $quiz_grades, 10 * DAY_IN_SECONDS);
744 744
          }
745 745
 
746 746
          return $success;
@@ -759,36 +759,36 @@  discard block
 block discarded – undo
759 759
       *
760 760
       * @return array $user_quiz_grades or false if none exists for this users
761 761
       */
762
-     public function get_user_grades( $lesson_id, $user_id = 0 ){
762
+     public function get_user_grades($lesson_id, $user_id = 0) {
763 763
 
764 764
          $user_grades = array();
765 765
 
766 766
          // get the user_id if none was passed in use the current logged in user
767
-         if( ! intval( $user_id ) > 0 ) {
767
+         if ( ! intval($user_id) > 0) {
768 768
              $user_id = get_current_user_id();
769 769
          }
770 770
 
771
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
772
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
771
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
772
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
773 773
              return false;
774 774
          }
775 775
 
776 776
          // save some time and get the transient cached data
777
-         $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
778
-         $user_grades = get_transient( $transient_key );
777
+         $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
778
+         $user_grades = get_transient($transient_key);
779 779
 
780 780
          // get the data if nothing was stored in the transient
781
-         if( empty( $user_grades  ) || false != $user_grades ){
781
+         if (empty($user_grades) || false != $user_grades) {
782 782
 
783
-             $user_grades = Sensei_Utils::get_user_data( 'quiz_grades', $lesson_id, $user_id );
783
+             $user_grades = Sensei_Utils::get_user_data('quiz_grades', $lesson_id, $user_id);
784 784
 
785 785
              //set the transient with the new valid data for faster retrieval in future
786
-             set_transient( $transient_key,  $user_grades, 10 * DAY_IN_SECONDS );
786
+             set_transient($transient_key, $user_grades, 10 * DAY_IN_SECONDS);
787 787
 
788 788
          } // end if transient check
789 789
 
790 790
          // if there is no data for this user
791
-         if( ! is_array( $user_grades ) ){
791
+         if ( ! is_array($user_grades)) {
792 792
              return false;
793 793
          }
794 794
 
@@ -811,21 +811,21 @@  discard block
 block discarded – undo
811 811
       *
812 812
       * @return bool $question_grade
813 813
       */
814
-     public function get_user_question_grade( $lesson_id, $question_id, $user_id = 0 ){
814
+     public function get_user_question_grade($lesson_id, $question_id, $user_id = 0) {
815 815
 
816 816
          // parameter validation
817
-         if( empty( $lesson_id ) || empty( $question_id )
818
-             || ! ( intval( $lesson_id  ) > 0 )
819
-             || ! ( intval( $question_id  ) > 0 )
820
-             || 'lesson' != get_post_type( $lesson_id )
821
-             || 'question' != get_post_type( $question_id )) {
817
+         if (empty($lesson_id) || empty($question_id)
818
+             || ! (intval($lesson_id) > 0)
819
+             || ! (intval($question_id) > 0)
820
+             || 'lesson' != get_post_type($lesson_id)
821
+             || 'question' != get_post_type($question_id)) {
822 822
 
823 823
              return false;
824 824
          }
825 825
 
826
-         $all_user_grades = self::get_user_grades( $lesson_id,$user_id );
826
+         $all_user_grades = self::get_user_grades($lesson_id, $user_id);
827 827
 
828
-         if( ! $all_user_grades || ! isset(  $all_user_grades[ $question_id ] ) ){
828
+         if ( ! $all_user_grades || ! isset($all_user_grades[$question_id])) {
829 829
 
830 830
              //fallback to data pre 1.7.4
831 831
              $args = array(
@@ -834,17 +834,17 @@  discard block
 block discarded – undo
834 834
                  'type'    => 'sensei_user_answer'
835 835
              );
836 836
 
837
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
837
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
838 838
              $fall_back_grade = false;
839
-             if( isset( $question_activity->comment_ID ) ){
840
-                 $fall_back_grade = get_comment_meta(  $question_activity->comment_ID , 'user_grade', true );
839
+             if (isset($question_activity->comment_ID)) {
840
+                 $fall_back_grade = get_comment_meta($question_activity->comment_ID, 'user_grade', true);
841 841
              }
842 842
 
843 843
              return $fall_back_grade;
844 844
 
845 845
          } // end if $all_user_grades...
846 846
 
847
-         return $all_user_grades[ $question_id ];
847
+         return $all_user_grades[$question_id];
848 848
 
849 849
      }// end get_user_question_grade
850 850
 
@@ -866,13 +866,13 @@  discard block
 block discarded – undo
866 866
       *
867 867
       * @return false or int $feedback_saved
868 868
       */
869
-    public function save_user_answers_feedback( $answers_feedback, $lesson_id , $user_id = 0 ){
869
+    public function save_user_answers_feedback($answers_feedback, $lesson_id, $user_id = 0) {
870 870
 
871 871
         // make sure the parameters are valid before continuing
872
-        if( empty( $lesson_id ) || empty( $user_id )
873
-            || 'lesson' != get_post_type( $lesson_id )
874
-            ||!get_userdata( $user_id )
875
-            || !is_array( $answers_feedback ) ){
872
+        if (empty($lesson_id) || empty($user_id)
873
+            || 'lesson' != get_post_type($lesson_id)
874
+            ||! get_userdata($user_id)
875
+            || ! is_array($answers_feedback)) {
876 876
 
877 877
             return false;
878 878
 
@@ -880,25 +880,25 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
         // check if the lesson is started before saving, if not start the lesson for the user
883
-        if ( !( 0 < intval( Sensei_Utils::user_started_lesson( $lesson_id, $user_id) ) ) ) {
884
-            Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
883
+        if ( ! (0 < intval(Sensei_Utils::user_started_lesson($lesson_id, $user_id)))) {
884
+            Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
885 885
         }
886 886
 
887 887
         // encode the feedback
888
-        $encoded_answers_feedback =  array();
889
-        foreach( $answers_feedback as $question_id => $feedback ){
890
-            $encoded_answers_feedback[ $question_id ] = base64_encode( $feedback );
888
+        $encoded_answers_feedback = array();
889
+        foreach ($answers_feedback as $question_id => $feedback) {
890
+            $encoded_answers_feedback[$question_id] = base64_encode($feedback);
891 891
         }
892 892
 
893 893
         // save the user data
894
-        $feedback_saved = Sensei_Utils::add_user_data( 'quiz_answers_feedback', $lesson_id , $encoded_answers_feedback, $user_id ) ;
894
+        $feedback_saved = Sensei_Utils::add_user_data('quiz_answers_feedback', $lesson_id, $encoded_answers_feedback, $user_id);
895 895
 
896 896
         //Were the the question feedback save correctly?
897
-        if( intval( $feedback_saved ) > 0){
897
+        if (intval($feedback_saved) > 0) {
898 898
 
899 899
             // save transient to make retrieval faster in future
900 900
              $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
901
-             set_transient( $transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS );
901
+             set_transient($transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS);
902 902
 
903 903
         }
904 904
 
@@ -923,42 +923,42 @@  discard block
 block discarded – undo
923 923
       *  $type string $question_feedback
924 924
       * }
925 925
       */
926
-     public function get_user_answers_feedback( $lesson_id , $user_id = 0 ){
926
+     public function get_user_answers_feedback($lesson_id, $user_id = 0) {
927 927
 
928 928
          $answers_feedback = array();
929 929
 
930 930
          // get the user_id if none was passed in use the current logged in user
931
-         if( ! intval( $user_id ) > 0 ) {
931
+         if ( ! intval($user_id) > 0) {
932 932
              $user_id = get_current_user_id();
933 933
          }
934 934
 
935
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
936
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
935
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
936
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
937 937
              return false;
938 938
          }
939 939
 
940 940
          // first check the transient to save a few split seconds
941 941
          $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
942
-         $encoded_feedback = get_transient( $transient_key );
942
+         $encoded_feedback = get_transient($transient_key);
943 943
 
944 944
          // get the data if nothing was stored in the transient
945
-         if( empty( $encoded_feedback  ) || !$encoded_feedback ){
945
+         if (empty($encoded_feedback) || ! $encoded_feedback) {
946 946
 
947
-             $encoded_feedback = Sensei_Utils::get_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
947
+             $encoded_feedback = Sensei_Utils::get_user_data('quiz_answers_feedback', $lesson_id, $user_id);
948 948
 
949 949
              //set the transient with the new valid data for faster retrieval in future
950
-             set_transient( $transient_key,  $encoded_feedback, 10 * DAY_IN_SECONDS);
950
+             set_transient($transient_key, $encoded_feedback, 10 * DAY_IN_SECONDS);
951 951
 
952 952
          } // end if transient check
953 953
 
954 954
          // if there is no data for this user
955
-         if( ! is_array( $encoded_feedback ) ){
955
+         if ( ! is_array($encoded_feedback)) {
956 956
              return false;
957 957
          }
958 958
 
959
-         foreach( $encoded_feedback as $question_id => $feedback ){
959
+         foreach ($encoded_feedback as $question_id => $feedback) {
960 960
 
961
-             $answers_feedback[ $question_id ] = base64_decode( $feedback );
961
+             $answers_feedback[$question_id] = base64_decode($feedback);
962 962
 
963 963
          }
964 964
 
@@ -981,25 +981,25 @@  discard block
 block discarded – undo
981 981
       *
982 982
       * @return string $feedback or bool if false
983 983
       */
984
-     public function get_user_question_feedback( $lesson_id, $question_id, $user_id = 0 ){
984
+     public function get_user_question_feedback($lesson_id, $question_id, $user_id = 0) {
985 985
 
986 986
          $feedback = false;
987 987
 
988 988
          // parameter validation
989
-         if( empty( $lesson_id ) || empty( $question_id )
990
-             || ! ( intval( $lesson_id  ) > 0 )
991
-             || ! ( intval( $question_id  ) > 0 )
992
-             || 'lesson' != get_post_type( $lesson_id )
993
-             || 'question' != get_post_type( $question_id )) {
989
+         if (empty($lesson_id) || empty($question_id)
990
+             || ! (intval($lesson_id) > 0)
991
+             || ! (intval($question_id) > 0)
992
+             || 'lesson' != get_post_type($lesson_id)
993
+             || 'question' != get_post_type($question_id)) {
994 994
 
995 995
              return false;
996 996
          }
997 997
 
998 998
          // get all the feedback for the user on the given lesson
999
-         $all_feedback = $this->get_user_answers_feedback( $lesson_id, $user_id );
999
+         $all_feedback = $this->get_user_answers_feedback($lesson_id, $user_id);
1000 1000
 
1001
-         if( !$all_feedback || empty( $all_feedback )
1002
-             || ! is_array( $all_feedback ) || ! isset( $all_feedback[ $question_id ] ) ){
1001
+         if ( ! $all_feedback || empty($all_feedback)
1002
+             || ! is_array($all_feedback) || ! isset($all_feedback[$question_id])) {
1003 1003
 
1004 1004
              //fallback to data pre 1.7.4
1005 1005
 
@@ -1009,23 +1009,23 @@  discard block
 block discarded – undo
1009 1009
                  'user_id' => $user_id,
1010 1010
                  'type'    => 'sensei_user_answer'
1011 1011
              );
1012
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
1012
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
1013 1013
 
1014 1014
              // set the default to false and return that if no old data is available.
1015
-             if( isset( $question_activity->comment_ID ) ){
1016
-                 $feedback = base64_decode( get_comment_meta(  $question_activity->comment_ID , 'answer_note', true ) );
1015
+             if (isset($question_activity->comment_ID)) {
1016
+                 $feedback = base64_decode(get_comment_meta($question_activity->comment_ID, 'answer_note', true));
1017 1017
              }
1018 1018
 
1019 1019
              // finally use the default question feedback
1020
-             if( empty( $feedback ) ){
1021
-                 $feedback = get_post_meta( $question_id, '_answer_feedback', true );
1020
+             if (empty($feedback)) {
1021
+                 $feedback = get_post_meta($question_id, '_answer_feedback', true);
1022 1022
              }
1023 1023
 
1024 1024
              return $feedback;
1025 1025
 
1026 1026
          }
1027 1027
 
1028
-         return $all_feedback[ $question_id ];
1028
+         return $all_feedback[$question_id];
1029 1029
 
1030 1030
      } // end get_user_question_feedback
1031 1031
 
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      public function quiz_has_no_questions() {
1045 1045
 
1046 1046
 
1047
-         if( ! is_singular( 'quiz' ) )  {
1047
+         if ( ! is_singular('quiz')) {
1048 1048
              return;
1049 1049
          }
1050 1050
 
@@ -1052,11 +1052,11 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
          $lesson_id = $this->get_lesson_id($post->ID);
1054 1054
 
1055
-         $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
1055
+         $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
1056 1056
 
1057 1057
          $lesson = get_post($lesson_id);
1058 1058
 
1059
-         if ( is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name" ) {
1059
+         if (is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name") {
1060 1060
 
1061 1061
              wp_redirect(get_permalink($lesson->ID), 301);
1062 1062
              exit;
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
   *
1071 1071
   * @deprecated since 1.9.0
1072 1072
   */
1073
- public static function deprecate_quiz_sensei_single_main_content_hook(){
1073
+ public static function deprecate_quiz_sensei_single_main_content_hook() {
1074 1074
 
1075 1075
      sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_quiz_content_inside_before or sensei_single_quiz_content_inside_after');
1076 1076
 
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
      *
1081 1081
      * @deprecated since 1.9.0
1082 1082
      */
1083
-     public static function deprecate_quiz_sensei_quiz_single_title_hook(){
1083
+     public static function deprecate_quiz_sensei_quiz_single_title_hook() {
1084 1084
 
1085 1085
          sensei_do_deprecated_action('sensei_quiz_single_title', '1.9.0', 'sensei_single_quiz_content_inside_before ');
1086 1086
 
@@ -1093,29 +1093,29 @@  discard block
 block discarded – undo
1093 1093
       * @param int $id title post id
1094 1094
       * @return string $quiz_title
1095 1095
       */
1096
-     public static function single_quiz_title( $title, $post_id ){
1096
+     public static function single_quiz_title($title, $post_id) {
1097 1097
 
1098
-         if( 'quiz' == get_post_type( $post_id ) ){
1098
+         if ('quiz' == get_post_type($post_id)) {
1099 1099
 
1100 1100
              $title_with_no_quizzes = $title;
1101 1101
 
1102 1102
              // if the title has quiz, remove it: legacy titles have the word quiz stored.
1103
-             if( 1 < substr_count( strtoupper( $title_with_no_quizzes ), 'QUIZ' ) ){
1103
+             if (1 < substr_count(strtoupper($title_with_no_quizzes), 'QUIZ')) {
1104 1104
 
1105 1105
                  // remove all possible appearances of quiz
1106
-                 $title_with_no_quizzes = str_replace( 'quiz', '', $title  );
1107
-                 $title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes  );
1108
-                 $title_with_no_quizzes = str_replace( 'QUIZ', '', $title_with_no_quizzes  );
1106
+                 $title_with_no_quizzes = str_replace('quiz', '', $title);
1107
+                 $title_with_no_quizzes = str_replace('Quiz', '', $title_with_no_quizzes);
1108
+                 $title_with_no_quizzes = str_replace('QUIZ', '', $title_with_no_quizzes);
1109 1109
 
1110 1110
              }
1111 1111
 
1112
-             $title = $title_with_no_quizzes .  ' ' . __( 'Quiz', 'woothemes-sensei' );
1112
+             $title = $title_with_no_quizzes.' '.__('Quiz', 'woothemes-sensei');
1113 1113
          }
1114 1114
 
1115 1115
          /**
1116 1116
           * hook document in class-woothemes-sensei-message.php
1117 1117
           */
1118
-         return apply_filters( 'sensei_single_title', $title, get_post_type( ) );
1118
+         return apply_filters('sensei_single_title', $title, get_post_type( ));
1119 1119
 
1120 1120
      }
1121 1121
 
@@ -1127,21 +1127,21 @@  discard block
 block discarded – undo
1127 1127
       * @since 1.9.0
1128 1128
       *
1129 1129
       */
1130
-     public static function start_quiz_questions_loop(){
1130
+     public static function start_quiz_questions_loop() {
1131 1131
 
1132 1132
          global $sensei_question_loop;
1133 1133
 
1134 1134
          //intialize the questions loop object
1135 1135
          $sensei_question_loop['current'] = -1;
1136
-         $sensei_question_loop['total']   =  0;
1136
+         $sensei_question_loop['total']   = 0;
1137 1137
          $sensei_question_loop['questions'] = array();
1138 1138
 
1139 1139
 
1140
-         $questions = Sensei()->lesson->lesson_quiz_questions( get_the_ID() );
1140
+         $questions = Sensei()->lesson->lesson_quiz_questions(get_the_ID());
1141 1141
 
1142
-         if( count( $questions  ) > 0  ){
1142
+         if (count($questions) > 0) {
1143 1143
 
1144
-             $sensei_question_loop['total']   =  count( $questions );
1144
+             $sensei_question_loop['total']   = count($questions);
1145 1145
              $sensei_question_loop['questions'] = $questions;
1146 1146
              $sensei_question_loop['quiz_id'] = get_the_ID();
1147 1147
 
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
       * @since 1.9.0
1158 1158
       *
1159 1159
       */
1160
-     public static function stop_quiz_questions_loop(){
1160
+     public static function stop_quiz_questions_loop() {
1161 1161
 
1162
-         $sensei_question_loop['total']   =  0;
1162
+         $sensei_question_loop['total']   = 0;
1163 1163
          $sensei_question_loop['questions'] = array();
1164 1164
          $sensei_question_loop['quiz_id'] = '';
1165 1165
 
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
       *
1171 1171
       * @since 1.9.0
1172 1172
       */
1173
-     public static function the_title(){
1173
+     public static function the_title() {
1174 1174
          ?>
1175 1175
          <header>
1176 1176
 
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
                  /**
1181 1181
                   * Filter documented in class-sensei-messages.php the_title
1182 1182
                   */
1183
-                 echo apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) );
1183
+                 echo apply_filters('sensei_single_title', get_the_title(get_post()), get_post_type(get_the_ID()));
1184 1184
                  ?>
1185 1185
 
1186 1186
              </h1>
@@ -1195,11 +1195,11 @@  discard block
 block discarded – undo
1195 1195
       *
1196 1196
       * @param $quiz_id
1197 1197
       */
1198
-    public static function  the_user_status_message( $quiz_id ){
1198
+    public static function  the_user_status_message($quiz_id) {
1199 1199
 
1200
-        $lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
1201
-        $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id , get_current_user_id() );
1202
-        echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
1200
+        $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
1201
+        $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, get_current_user_id());
1202
+        echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
1203 1203
 
1204 1204
     }
1205 1205
 
@@ -1210,9 +1210,9 @@  discard block
 block discarded – undo
1210 1210
       * @since 1.9.0
1211 1211
       * @deprecated
1212 1212
       */
1213
-     public static function deprecate_sensei_quiz_action_buttons_hook(){
1213
+     public static function deprecate_sensei_quiz_action_buttons_hook() {
1214 1214
 
1215
-         sensei_do_deprecated_action( 'sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1215
+         sensei_do_deprecated_action('sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1216 1216
 
1217 1217
      }
1218 1218
 
@@ -1226,50 +1226,50 @@  discard block
 block discarded – undo
1226 1226
 
1227 1227
          global $post, $current_user;
1228 1228
 
1229
-         $lesson_id = (int) get_post_meta( $post->ID, '_quiz_lesson', true );
1230
-         $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true );
1231
-         $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
1229
+         $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true);
1230
+         $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true);
1231
+         $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
1232 1232
          $show_actions = true;
1233
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $current_user->ID );
1233
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $current_user->ID);
1234 1234
 
1235 1235
          //setup quiz grade
1236 1236
          $user_quiz_grade = '';
1237
-         if( ! empty( $user_lesson_status  ) ){
1238
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1237
+         if ( ! empty($user_lesson_status)) {
1238
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1239 1239
          }
1240 1240
 
1241 1241
 
1242
-         if( intval( $lesson_prerequisite ) > 0 ) {
1242
+         if (intval($lesson_prerequisite) > 0) {
1243 1243
 
1244 1244
              // If the user hasn't completed the prereq then hide the current actions
1245
-             $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $current_user->ID );
1245
+             $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
1246 1246
 
1247 1247
          }
1248
-         if ( $show_actions && is_user_logged_in() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
1248
+         if ($show_actions && is_user_logged_in() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
1249 1249
 
1250 1250
              // Get Reset Settings
1251
-             $reset_quiz_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true ); ?>
1251
+             $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true); ?>
1252 1252
 
1253 1253
              <!-- Action Nonce's -->
1254 1254
              <input type="hidden" name="woothemes_sensei_complete_quiz_nonce" id="woothemes_sensei_complete_quiz_nonce"
1255
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_complete_quiz_nonce' ) ); ?>" />
1255
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_nonce')); ?>" />
1256 1256
              <input type="hidden" name="woothemes_sensei_reset_quiz_nonce" id="woothemes_sensei_reset_quiz_nonce"
1257
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_reset_quiz_nonce' ) ); ?>" />
1257
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_reset_quiz_nonce')); ?>" />
1258 1258
              <input type="hidden" name="woothemes_sensei_save_quiz_nonce" id="woothemes_sensei_save_quiz_nonce"
1259
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_save_quiz_nonce' ) ); ?>" />
1259
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_save_quiz_nonce')); ?>" />
1260 1260
              <!--#end Action Nonce's -->
1261 1261
 
1262
-             <?php if ( '' == $user_quiz_grade) { ?>
1262
+             <?php if ('' == $user_quiz_grade) { ?>
1263 1263
 
1264
-                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e( 'Complete Quiz', 'woothemes-sensei' ); ?>"/></span>
1264
+                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e('Complete Quiz', 'woothemes-sensei'); ?>"/></span>
1265 1265
 
1266
-                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e( 'Save Quiz', 'woothemes-sensei' ); ?>"/></span>
1266
+                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e('Save Quiz', 'woothemes-sensei'); ?>"/></span>
1267 1267
 
1268 1268
              <?php } // End If Statement ?>
1269 1269
 
1270
-             <?php if ( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { ?>
1270
+             <?php if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { ?>
1271 1271
 
1272
-                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e( 'Reset Quiz', 'woothemes-sensei' ); ?>"/></span>
1272
+                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e('Reset Quiz', 'woothemes-sensei'); ?>"/></span>
1273 1273
 
1274 1274
              <?php } ?>
1275 1275
 
@@ -1287,13 +1287,13 @@  discard block
 block discarded – undo
1287 1287
       *
1288 1288
       * @return double $user_quiz_grade
1289 1289
       */
1290
-     public static function get_user_quiz_grade( $lesson_id, $user_id ){
1290
+     public static function get_user_quiz_grade($lesson_id, $user_id) {
1291 1291
 
1292 1292
          // get the quiz grade
1293
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1293
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1294 1294
          $user_quiz_grade = 0;
1295
-         if( isset( $user_lesson_status->comment_ID ) ) {
1296
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1295
+         if (isset($user_lesson_status->comment_ID)) {
1296
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1297 1297
          }
1298 1298
 
1299 1299
          return (double) $user_quiz_grade;
@@ -1311,13 +1311,13 @@  discard block
 block discarded – undo
1311 1311
       * @param int $lesson_id
1312 1312
       * @return bool
1313 1313
       */
1314
-     public static function is_reset_allowed( $lesson_id ){
1314
+     public static function is_reset_allowed($lesson_id) {
1315 1315
 
1316
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1316
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1317 1317
 
1318
-         $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
1318
+         $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true);
1319 1319
          //backwards compatibility
1320
-         if( 'on' == $reset_allowed ) {
1320
+         if ('on' == $reset_allowed) {
1321 1321
              $reset_allowed = 1;
1322 1322
          }
1323 1323
 
@@ -1334,4 +1334,4 @@  discard block
 block discarded – undo
1334 1334
  * for backward compatibility
1335 1335
  * @since 1.9.0
1336 1336
  */
1337
-class WooThemes_Sensei_Quiz extends Sensei_Quiz{}
1337
+class WooThemes_Sensei_Quiz extends Sensei_Quiz {}
Please login to merge, or discard this patch.
widgets/widget-woothemes-sensei-course-component.php 1 patch
Spacing   +72 added lines, -72 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 Component Widget
@@ -26,30 +26,30 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_course_component';
29
-		$this->woo_widget_description = __( 'This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_course_component';
31
-		$this->woo_widget_title = __( 'Sensei - Course Component', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Course Component', 'woothemes-sensei');
32 32
 
33 33
 		$this->woo_widget_componentslist = array(
34
-												'usercourses' => __( 'New Courses', 'woothemes-sensei' ),
35
-												'featuredcourses' => __( 'Featured Courses', 'woothemes-sensei' ),
36
-												'activecourses' => __( 'My Active Courses', 'woothemes-sensei' ),
37
-												'completedcourses' => __( 'My Completed Courses', 'woothemes-sensei' ),
34
+												'usercourses' => __('New Courses', 'woothemes-sensei'),
35
+												'featuredcourses' => __('Featured Courses', 'woothemes-sensei'),
36
+												'activecourses' => __('My Active Courses', 'woothemes-sensei'),
37
+												'completedcourses' => __('My Completed Courses', 'woothemes-sensei'),
38 38
 												);
39 39
 
40 40
 		// Add support for the WooCommerce shelf.
41
-		if ( Sensei_WC::is_woocommerce_active() ) {
42
-			$this->woo_widget_componentslist['freecourses'] = __( 'Free Courses', 'woothemes-sensei' );
43
-			$this->woo_widget_componentslist['paidcourses'] = __( 'Paid Courses', 'woothemes-sensei' );
41
+		if (Sensei_WC::is_woocommerce_active()) {
42
+			$this->woo_widget_componentslist['freecourses'] = __('Free Courses', 'woothemes-sensei');
43
+			$this->woo_widget_componentslist['paidcourses'] = __('Paid Courses', 'woothemes-sensei');
44 44
 		}
45 45
 		/* Widget settings. */
46
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
46
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
47 47
 
48 48
 		/* Widget control settings. */
49
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
49
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
50 50
 
51 51
 		/* Create the widget. */
52
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
52
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
53 53
 	} // End __construct()
54 54
 
55 55
 	/**
@@ -59,44 +59,44 @@  discard block
 block discarded – undo
59 59
 	 * @param  array $instance Widget settings for this instance.
60 60
 	 * @return void
61 61
 	 */
62
-	public function widget( $args, $instance ) {
62
+	public function widget($args, $instance) {
63 63
 
64
-		remove_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
64
+		remove_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
65 65
 
66
-		if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) )
67
-            && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] )
68
-            && !is_user_logged_in() ) {
66
+		if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))
67
+            && ('activecourses' == $instance['component'] || 'completedcourses' == $instance['component'])
68
+            && ! is_user_logged_in()) {
69 69
 
70 70
 			// No Output
71 71
             return;
72 72
 
73 73
 		} else {
74 74
 			/* Our variables from the widget settings. */
75
-			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
75
+			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
76 76
 
77 77
 			/* Before widget (defined by themes). */
78 78
 			echo $args['before_widget'];
79 79
 
80 80
 			/* Display the widget title if one was input (before and after defined by themes). */
81
-			if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; }
81
+			if ($title) { echo $args['before_title'].$title.$args['after_title']; }
82 82
 
83 83
 			/* Widget content. */
84 84
 			// Add actions for plugins/themes to hook onto.
85
-			do_action( $this->woo_widget_cssclass . '_top' );
85
+			do_action($this->woo_widget_cssclass.'_top');
86 86
 
87
-			if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) ) {
88
-				$this->load_component( $instance );
87
+			if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))) {
88
+				$this->load_component($instance);
89 89
 			}
90 90
 
91 91
 			// Add actions for plugins/themes to hook onto.
92
-			do_action( $this->woo_widget_cssclass . '_bottom' );
92
+			do_action($this->woo_widget_cssclass.'_bottom');
93 93
 
94 94
 			/* After widget (defined by themes). */
95 95
 			echo $args['after_widget'];
96 96
 
97 97
 		} // End If Statement
98 98
 
99
-		add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
99
+		add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
100 100
 
101 101
 	} // End widget()
102 102
 
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 * @param  array $old_instance Previous settings.
108 108
 	 * @return array               Updated settings.
109 109
 	 */
110
-	public function update ( $new_instance, $old_instance ) {
110
+	public function update($new_instance, $old_instance) {
111 111
 		$instance = $old_instance;
112 112
 
113 113
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
114
-		$instance['title'] = strip_tags( $new_instance['title'] );
114
+		$instance['title'] = strip_tags($new_instance['title']);
115 115
 
116 116
 		/* The select box is returning a text value, so we escape it. */
117
-		$instance['component'] = esc_attr( $new_instance['component'] );
117
+		$instance['component'] = esc_attr($new_instance['component']);
118 118
 
119 119
 		/* The select box is returning a text value, so we escape it. */
120
-		$instance['limit'] = esc_attr( $new_instance['limit'] );
120
+		$instance['limit'] = esc_attr($new_instance['limit']);
121 121
 
122 122
 
123 123
 		return $instance;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @param  array $instance The settings for this instance.
131 131
 	 * @return void
132 132
 	 */
133
-    public function form( $instance ) {
133
+    public function form($instance) {
134 134
 
135 135
 		/* Set up some default widget settings. */
136 136
 		/* Make sure all keys are added here, even with empty string values. */
@@ -140,26 +140,26 @@  discard block
 block discarded – undo
140 140
 						'limit' => 3
141 141
 					);
142 142
 
143
-		$instance = wp_parse_args( (array) $instance, $defaults );
143
+		$instance = wp_parse_args((array) $instance, $defaults);
144 144
 ?>
145 145
 		<!-- Widget Title: Text Input -->
146 146
 		<p>
147
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
148
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
147
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
148
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
149 149
 		</p>
150 150
 		<!-- Widget Component: Select Input -->
151 151
 		<p>
152
-			<label for="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"><?php _e( 'Component:', 'woothemes-sensei' ); ?></label>
153
-			<select name="<?php echo esc_attr( $this->get_field_name( 'component' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>">
154
-			<?php foreach ( $this->woo_widget_componentslist as $k => $v ) { ?>
155
-				<option value="<?php echo esc_attr( $k ); ?>"<?php selected( $instance['component'], $k ); ?>><?php echo $v; ?></option>
152
+			<label for="<?php echo esc_attr($this->get_field_id('component')); ?>"><?php _e('Component:', 'woothemes-sensei'); ?></label>
153
+			<select name="<?php echo esc_attr($this->get_field_name('component')); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('component')); ?>">
154
+			<?php foreach ($this->woo_widget_componentslist as $k => $v) { ?>
155
+				<option value="<?php echo esc_attr($k); ?>"<?php selected($instance['component'], $k); ?>><?php echo $v; ?></option>
156 156
 			<?php } ?>
157 157
 			</select>
158 158
 		</p>
159 159
 		<!-- Widget Limit: Text Input -->
160 160
 		<p>
161
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Courses (optional):', 'woothemes-sensei' ); ?></label>
162
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
161
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Courses (optional):', 'woothemes-sensei'); ?></label>
162
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
163 163
 		</p>
164 164
 
165 165
 <?php
@@ -172,28 +172,28 @@  discard block
 block discarded – undo
172 172
 	 * @since  1.0.0
173 173
 	 * @return void
174 174
 	 */
175
-	protected function load_component ( $instance ) {
175
+	protected function load_component($instance) {
176 176
 		global  $current_user;
177 177
 
178 178
 		get_currentuserinfo();
179 179
 
180 180
 		$course_ids = array();
181
-		if ( 'activecourses' == esc_attr( $instance['component'] ) ) {
182
-			$courses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'in-progress' ), true );
181
+		if ('activecourses' == esc_attr($instance['component'])) {
182
+			$courses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'in-progress'), true);
183 183
 			// Need to always return an array, even with only 1 item
184
-			if ( !is_array($courses) ) {
185
-				$courses = array( $courses );
184
+			if ( ! is_array($courses)) {
185
+				$courses = array($courses);
186 186
 			}
187
-			foreach( $courses AS $course ) {
187
+			foreach ($courses AS $course) {
188 188
 				$course_ids[] = $course->comment_post_ID;
189 189
 			}
190
-		} elseif( 'completedcourses' == esc_attr( $instance['component'] ) ) {
191
-			$courses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'complete' ), true );
190
+		} elseif ('completedcourses' == esc_attr($instance['component'])) {
191
+			$courses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'complete'), true);
192 192
 			// Need to always return an array, even with only 1 item
193
-			if ( !is_array($courses) ) {
194
-				$courses = array( $courses );
193
+			if ( ! is_array($courses)) {
194
+				$courses = array($courses);
195 195
 			}
196
-			foreach( $courses AS $course ) {
196
+			foreach ($courses AS $course) {
197 197
 				$course_ids[] = $course->comment_post_ID;
198 198
 			}
199 199
 		} // End If Statement
@@ -201,19 +201,19 @@  discard block
 block discarded – undo
201 201
 		$posts_array = array();
202 202
 
203 203
 		// course_query() is buggy, it doesn't honour the 1st arg if includes are provided, so instead slice the includes
204
-		if ( !empty($instance['limit']) && intval( $instance['limit'] ) >= 1 && intval( $instance['limit'] ) < count($course_ids) ) {
204
+		if ( ! empty($instance['limit']) && intval($instance['limit']) >= 1 && intval($instance['limit']) < count($course_ids)) {
205 205
 
206
-			$course_ids = array_slice( $course_ids, 0, intval( $instance['limit'] ) ); // This does mean the order by is effectively ignored
206
+			$course_ids = array_slice($course_ids, 0, intval($instance['limit'])); // This does mean the order by is effectively ignored
207 207
 
208 208
 		}
209 209
 
210
-        if ( ! empty( $course_ids ) ) {
210
+        if ( ! empty($course_ids)) {
211 211
 
212
-            $posts_array = Sensei()->course->course_query( intval( $instance['limit'] ), esc_attr( $instance['component'] ), $course_ids );
212
+            $posts_array = Sensei()->course->course_query(intval($instance['limit']), esc_attr($instance['component']), $course_ids);
213 213
 
214 214
 		} else {
215 215
 
216
-            if ( 'activecourses' == esc_attr( $instance['component'] ) || 'completedcourses' == esc_attr( $instance['component'] ) ) {
216
+            if ('activecourses' == esc_attr($instance['component']) || 'completedcourses' == esc_attr($instance['component'])) {
217 217
 				$posts_array = array();
218 218
 
219 219
             } else {
@@ -226,43 +226,43 @@  discard block
 block discarded – undo
226 226
                     'posts_per_page' => $instance['limit'],
227 227
                 );
228 228
 
229
-				$posts_array = get_posts( $course_args );
229
+				$posts_array = get_posts($course_args);
230 230
 			}
231 231
 
232 232
 		} // End If Statement
233 233
 
234
-		if ( count( $posts_array ) > 0 ) { ?>
234
+		if (count($posts_array) > 0) { ?>
235 235
 			<ul>
236
-			<?php foreach ($posts_array as $post_item){
237
-		    	$post_id = absint( $post_item->ID );
236
+			<?php foreach ($posts_array as $post_item) {
237
+		    	$post_id = absint($post_item->ID);
238 238
 		    	$post_title = $post_item->post_title;
239
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
240
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
239
+		    	$user_info = get_userdata(absint($post_item->post_author));
240
+		    	$author_link = get_author_posts_url(absint($post_item->post_author));
241 241
 		    	$author_display_name = $user_info->display_name;
242 242
 		    	$author_id = $post_item->post_author;
243 243
 		    ?>
244 244
 		    	<li class="fix">
245
-		    		<?php do_action( 'sensei_course_image', $post_id ); ?>
246
-		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
245
+		    		<?php do_action('sensei_course_image', $post_id); ?>
246
+		    		<a href="<?php echo esc_url(get_permalink($post_id)); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a>
247 247
 		    		<br />
248
-		    		<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
249
-    					<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name ); ?></a></span>
248
+		    		<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
249
+    					<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
250 250
     					<br />
251 251
     				<?php } // End If Statement ?>
252
-    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' . __( 'Lessons', 'woothemes-sensei' ); ?></span>
252
+    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
253 253
     				<br />
254
-    				<?php sensei_simple_course_price( $post_id ); ?>
254
+    				<?php sensei_simple_course_price($post_id); ?>
255 255
 		    	</li>
256 256
 		    <?php } // End For Loop ?>
257
-		    <?php if ( 'activecourses' == esc_attr( $instance['component'] ) || 'completedcourses' == esc_attr( $instance['component'] ) ) {
258
-		    	$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
259
-		    	echo '<li class="my-account fix"><a href="'. esc_url( get_permalink( $my_account_page_id ) ) .'">'.__('My Courses', 'woothemes-sensei').' <span class="meta-nav"></span></a></li>';
257
+		    <?php if ('activecourses' == esc_attr($instance['component']) || 'completedcourses' == esc_attr($instance['component'])) {
258
+		    	$my_account_page_id = intval(Sensei()->settings->settings['my_course_page']);
259
+		    	echo '<li class="my-account fix"><a href="'.esc_url(get_permalink($my_account_page_id)).'">'.__('My Courses', 'woothemes-sensei').' <span class="meta-nav"></span></a></li>';
260 260
 		    } // End If Statement ?>
261 261
 		</ul>
262 262
 		<?php } else {
263 263
 			// No posts returned. This means the user either has no active or no completed courses.
264
-			$course_status = substr( esc_attr( $instance['component'] ) , 0, -7);
265
-			echo sprintf( __( 'You have no %1s courses.', 'woothemes-sensei' ), $course_status );
264
+			$course_status = substr(esc_attr($instance['component']), 0, -7);
265
+			echo sprintf(__('You have no %1s courses.', 'woothemes-sensei'), $course_status);
266 266
 		} // End If Statement
267 267
 	} // End load_component()
268 268
 } // End Class
269 269
\ No newline at end of file
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-shortcode-user-messages.php 1 patch
Spacing   +12 added lines, -12 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
  * Renders the [sensei_user_messages] shortcode. The current users messages.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @param string $content
30 30
      * @param string $shortcode the shortcode that was called for this instance
31 31
      */
32
-    public function __construct( $attributes, $content, $shortcode ){
32
+    public function __construct($attributes, $content, $shortcode) {
33 33
 
34 34
         $this->setup_messages_query();
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @return mixed
42 42
      */
43
-    public function setup_messages_query(){
43
+    public function setup_messages_query() {
44 44
 
45 45
         $user = wp_get_current_user();
46 46
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             ),
60 60
         );
61 61
 
62
-        $this->messages_query  = new WP_Query( $args );
62
+        $this->messages_query = new WP_Query($args);
63 63
     }
64 64
 
65 65
     /**
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @return string $content
69 69
      */
70
-    public function render(){
70
+    public function render() {
71 71
 
72
-        if( !is_user_logged_in() ){
72
+        if ( ! is_user_logged_in()) {
73 73
 
74
-            Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert'  );
74
+            Sensei()->notices->add_notice(__('Please login to view your messages.', 'woothemes-sensei'), 'alert');
75 75
 
76
-        } elseif( 0 == $this->messages_query->post_count ){
76
+        } elseif (0 == $this->messages_query->post_count) {
77 77
 
78
-            Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert'  );
78
+            Sensei()->notices->add_notice(__('You do not have any messages.', 'woothemes-sensei'), 'alert');
79 79
         }
80 80
 
81
-        $messages_disabled_in_settings =  ! ( ! isset( Sensei()->settings->settings['messages_disable'] )
82
-                                            || ! Sensei()->settings->settings['messages_disable'] ) ;
81
+        $messages_disabled_in_settings = ! ( ! isset(Sensei()->settings->settings['messages_disable'])
82
+                                            || ! Sensei()->settings->settings['messages_disable']);
83 83
 
84 84
         // don't show anything if messages are disable
85
-        if( $messages_disabled_in_settings ){
85
+        if ($messages_disabled_in_settings) {
86 86
             return '';
87 87
         }
88 88
 
Please login to merge, or discard this patch.
includes/class-sensei-autoloader.php 1 patch
Spacing   +21 added lines, -21 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
  * Sensei Autoloader Class
5 5
  *
@@ -27,21 +27,21 @@  discard block
 block discarded – undo
27 27
      * Constructor
28 28
      * @since 1.9.0
29 29
      */
30
-    public function __construct(){
30
+    public function __construct() {
31 31
 
32 32
         // make sure we do not override an existing autoload function
33
-        if( function_exists('__autoload') ){
34
-           spl_autoload_register( '__autoload' );
33
+        if (function_exists('__autoload')) {
34
+           spl_autoload_register('__autoload');
35 35
         }
36 36
 
37 37
         // setup a relative path for the current autoload instance
38
-        $this->include_path = trailingslashit( untrailingslashit( dirname( __FILE__ ) ) );
38
+        $this->include_path = trailingslashit(untrailingslashit(dirname(__FILE__)));
39 39
 
40 40
         //setup the class file map
41 41
         $this->initialize_class_file_map();
42 42
 
43 43
         // add Sensei custom auto loader
44
-        spl_autoload_register( array( $this, 'autoload' )  );
44
+        spl_autoload_register(array($this, 'autoload'));
45 45
 
46 46
     }
47 47
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @since 1.9.0
53 53
      */
54
-    public function initialize_class_file_map(){
54
+    public function initialize_class_file_map() {
55 55
 
56 56
         $this->class_file_map = array(
57 57
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
             /**
64 64
              * Admin
65 65
              */
66
-            'Sensei_Welcome'            => 'admin/class-sensei-welcome.php' ,
67
-            'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php' ,
66
+            'Sensei_Welcome'            => 'admin/class-sensei-welcome.php',
67
+            'Sensei_Learner_Management' => 'admin/class-sensei-learner-management.php',
68 68
 
69 69
             /**
70 70
              * Shortcodes
@@ -93,38 +93,38 @@  discard block
 block discarded – undo
93 93
     /**
94 94
      * Autoload all sensei files as the class names are used.
95 95
      */
96
-    public function autoload( $class ){
96
+    public function autoload($class) {
97 97
 
98 98
         // only handle classes with the word `sensei` in it
99
-        if( ! is_numeric( strpos ( strtolower( $class ), 'sensei') ) ){
99
+        if ( ! is_numeric(strpos(strtolower($class), 'sensei'))) {
100 100
 
101 101
             return;
102 102
 
103 103
         }
104 104
 
105 105
         // exit if we didn't provide mapping for this class
106
-        if( isset( $this->class_file_map[ $class ] ) ){
106
+        if (isset($this->class_file_map[$class])) {
107 107
 
108
-            $file_location = $this->include_path . $this->class_file_map[ $class ];
109
-            require_once( $file_location);
108
+            $file_location = $this->include_path.$this->class_file_map[$class];
109
+            require_once($file_location);
110 110
             return;
111 111
 
112 112
         }
113 113
 
114 114
         // check for file in the main includes directory
115
-        $class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $class ) ) . '.php';
116
-        if( file_exists( $class_file_path ) ){
115
+        $class_file_path = $this->include_path.'class-'.str_replace('_', '-', strtolower($class)).'.php';
116
+        if (file_exists($class_file_path)) {
117 117
 
118
-            require_once( $class_file_path );
118
+            require_once($class_file_path);
119 119
             return;
120 120
         }
121 121
 
122 122
         // lastly check legacy types
123
-        $stripped_woothemes_from_class = str_replace( 'woothemes_','', strtolower( $class ) ); // remove woothemes
124
-        $legacy_class_file_path = $this->include_path . 'class-'.str_replace( '_','-', strtolower( $stripped_woothemes_from_class ) ) . '.php';
125
-        if( file_exists( $legacy_class_file_path ) ){
123
+        $stripped_woothemes_from_class = str_replace('woothemes_', '', strtolower($class)); // remove woothemes
124
+        $legacy_class_file_path = $this->include_path.'class-'.str_replace('_', '-', strtolower($stripped_woothemes_from_class)).'.php';
125
+        if (file_exists($legacy_class_file_path)) {
126 126
 
127
-            require_once( $legacy_class_file_path );
127
+            require_once($legacy_class_file_path);
128 128
             return;
129 129
         }
130 130
 
Please login to merge, or discard this patch.
includes/class-sensei-posttypes.php 1 patch
Spacing   +237 added lines, -237 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 Post Types Class
@@ -41,43 +41,43 @@  discard block
 block discarded – undo
41 41
 	 * Constructor
42 42
 	 * @since  1.0.0
43 43
 	 */
44
-	public function __construct () {
44
+	public function __construct() {
45 45
 
46 46
 		// Setup Post Types
47 47
 		$this->labels = array();
48 48
         $this->token = 'woothemes-sensei-posttypes';
49 49
 
50 50
 		$this->setup_post_type_labels_base();
51
-		add_action( 'init', array( $this, 'setup_course_post_type' ), 100 );
52
-		add_action( 'init', array( $this, 'setup_lesson_post_type' ), 100 );
53
-		add_action( 'init', array( $this, 'setup_quiz_post_type' ), 100 );
54
-		add_action( 'init', array( $this, 'setup_question_post_type' ), 100 );
55
-		add_action( 'init', array( $this, 'setup_multiple_question_post_type' ), 100 );
56
-		add_action( 'init', array( $this, 'setup_sensei_message_post_type' ), 100 );
51
+		add_action('init', array($this, 'setup_course_post_type'), 100);
52
+		add_action('init', array($this, 'setup_lesson_post_type'), 100);
53
+		add_action('init', array($this, 'setup_quiz_post_type'), 100);
54
+		add_action('init', array($this, 'setup_question_post_type'), 100);
55
+		add_action('init', array($this, 'setup_multiple_question_post_type'), 100);
56
+		add_action('init', array($this, 'setup_sensei_message_post_type'), 100);
57 57
 
58 58
 		// Setup Taxonomies
59
-		add_action( 'init', array( $this, 'setup_course_category_taxonomy' ), 100 );
60
-		add_action( 'init', array( $this, 'setup_quiz_type_taxonomy' ), 100 );
61
-		add_action( 'init', array( $this, 'setup_question_type_taxonomy' ), 100 );
62
-		add_action( 'init', array( $this, 'setup_question_category_taxonomy' ), 100 );
63
-		add_action( 'init', array( $this, 'setup_lesson_tag_taxonomy' ), 100 );
59
+		add_action('init', array($this, 'setup_course_category_taxonomy'), 100);
60
+		add_action('init', array($this, 'setup_quiz_type_taxonomy'), 100);
61
+		add_action('init', array($this, 'setup_question_type_taxonomy'), 100);
62
+		add_action('init', array($this, 'setup_question_category_taxonomy'), 100);
63
+		add_action('init', array($this, 'setup_lesson_tag_taxonomy'), 100);
64 64
 
65 65
 		// Load Post Type Objects
66
-		$default_post_types = array( 'course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages' ) ;
67
-		$this->load_posttype_objects( $default_post_types );
66
+		$default_post_types = array('course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages');
67
+		$this->load_posttype_objects($default_post_types);
68 68
 
69 69
 		// Admin functions
70
-		if ( is_admin() ) {
71
-			$this->set_role_cap_defaults( $default_post_types );
70
+		if (is_admin()) {
71
+			$this->set_role_cap_defaults($default_post_types);
72 72
 			global $pagenow;
73
-			if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) {
74
-				add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10 );
75
-				add_filter( 'post_updated_messages', array( $this, 'setup_post_type_messages' ) );
73
+			if (($pagenow == 'post.php' || $pagenow == 'post-new.php')) {
74
+				add_filter('enter_title_here', array($this, 'enter_title_here'), 10);
75
+				add_filter('post_updated_messages', array($this, 'setup_post_type_messages'));
76 76
 			} // End If Statement
77 77
 		} // End If Statement
78 78
 
79 79
 		// Add 'Edit Quiz' link to admin bar
80
-		add_action( 'admin_bar_menu', array( $this, 'quiz_admin_bar_menu' ), 81 );
80
+		add_action('admin_bar_menu', array($this, 'quiz_admin_bar_menu'), 81);
81 81
 
82 82
 	} // End __construct()
83 83
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 * @param array $posttypes (default: array())
89 89
 	 * @return void
90 90
 	 */
91
-	public function load_posttype_objects( $posttypes = array() ) {
91
+	public function load_posttype_objects($posttypes = array()) {
92 92
 
93
-		foreach ( $posttypes as $posttype_token => $posttype_name ) {
93
+		foreach ($posttypes as $posttype_token => $posttype_name) {
94 94
 
95 95
 			// Load the files
96
-			$class_name = 'WooThemes_Sensei_' . $posttype_name;
96
+			$class_name = 'WooThemes_Sensei_'.$posttype_name;
97 97
 			$this->$posttype_token = new $class_name();
98 98
 			$this->$posttype_token->token = $posttype_token;
99 99
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
      * @uses  Sensei()
108 108
 	 * @return void
109 109
 	 */
110
-	public function setup_course_post_type () {
110
+	public function setup_course_post_type() {
111 111
 
112 112
 		$args = array(
113
-		    'labels'              => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ),
113
+		    'labels'              => $this->create_post_type_labels($this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu']),
114 114
 		    'public'              => true,
115 115
 		    'publicly_queryable'  => true,
116 116
 		    'show_ui'             => true,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		    'show_in_admin_bar'   => true,
119 119
 		    'query_var'           => true,
120 120
 		    'rewrite'             => array(
121
-                'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) ,
121
+                'slug' => esc_attr(apply_filters('sensei_course_slug', _x('course', 'post type single url base', 'woothemes-sensei'))),
122 122
                 'with_front' => true,
123 123
                 'feeds' => true,
124 124
                 'pages' => true
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             'has_archive'         => $this->get_course_post_type_archive_slug(),
129 129
 		    'hierarchical'        => false,
130 130
 		    'menu_position'       => 51,
131
-		    'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail' )
131
+		    'supports'            => array('title', 'editor', 'excerpt', 'thumbnail')
132 132
 		);
133 133
 
134 134
         /**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
          * @since 1.9.0
138 138
          * @param array $args
139 139
          */
140
-		register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) );
140
+		register_post_type('course', apply_filters('sensei_register_post_type_course', $args));
141 141
 
142 142
 	} // End setup_course_post_type()
143 143
 
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
      *
157 157
      * @return false|string
158 158
      */
159
-    public function get_course_post_type_archive_slug(){
159
+    public function get_course_post_type_archive_slug() {
160 160
 
161
-        $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) );
161
+        $settings_course_page = get_post(Sensei()->settings->get('course_page'));
162 162
 
163 163
         // for a valid post that doesn't have any of the old short codes set the archive the same
164 164
         // as the page URI
165
-        if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){
165
+        if (is_a($settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes($settings_course_page->post_content)) {
166 166
 
167
-             return get_page_uri( $settings_course_page->ID );
167
+             return get_page_uri($settings_course_page->ID);
168 168
 
169
-        }else{
169
+        } else {
170 170
 
171 171
             return 'courses';
172 172
 
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @return bool
186 186
      */
187
-    public function has_old_shortcodes( $content ){
187
+    public function has_old_shortcodes($content) {
188 188
 
189
-        return  ( has_shortcode( $content, 'newcourses')
190
-        || has_shortcode( $content, 'featuredcourses')
191
-        || has_shortcode( $content, 'freecourses')
192
-        || has_shortcode( $content, 'paidcourses') );
189
+        return  (has_shortcode($content, 'newcourses')
190
+        || has_shortcode($content, 'featuredcourses')
191
+        || has_shortcode($content, 'freecourses')
192
+        || has_shortcode($content, 'paidcourses'));
193 193
 
194 194
     }// end has old shortcodes
195 195
 
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
 	 * @uses  Sensei()
201 201
 	 * @return void
202 202
 	 */
203
-	public function setup_lesson_post_type () {
203
+	public function setup_lesson_post_type() {
204 204
 
205 205
 
206
-		$supports_array = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' );
206
+		$supports_array = array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes');
207 207
 		$allow_comments = false;
208
-		if ( isset( Sensei()->settings->settings[ 'lesson_comments' ] ) ) {
209
-			$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
208
+		if (isset(Sensei()->settings->settings['lesson_comments'])) {
209
+			$allow_comments = Sensei()->settings->settings['lesson_comments'];
210 210
 		} // End If Statement
211
-		if ( $allow_comments ) {
212
-			array_push( $supports_array, 'comments' );
211
+		if ($allow_comments) {
212
+			array_push($supports_array, 'comments');
213 213
 		} // End If Statement
214 214
 
215 215
 		$args = array(
216
-		    'labels' => $this->create_post_type_labels(  $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ),
216
+		    'labels' => $this->create_post_type_labels($this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu']),
217 217
 		    'public' => true,
218 218
 		    'publicly_queryable' => true,
219 219
 		    'show_ui' => true,
220 220
 		    'show_in_menu' => true,
221 221
 		    'query_var' => true,
222 222
 		    'rewrite' => array(
223
-                'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) ,
223
+                'slug' => esc_attr(apply_filters('sensei_lesson_slug', _x('lesson', 'post type single slug', 'woothemes-sensei'))),
224 224
                 'with_front' =>  true,
225 225
                 'feeds' => true,
226 226
                 'pages' => true
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
          * @since 1.9.0
240 240
          * @param array $args
241 241
          */
242
-		register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) );
242
+		register_post_type('lesson', apply_filters('sensei_register_post_type_lesson', $args));
243 243
 
244 244
 	} // End setup_lesson_post_type()
245 245
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
      * @uses  Sensei()
250 250
 	 * @return void
251 251
 	 */
252
-	public function setup_quiz_post_type () {
252
+	public function setup_quiz_post_type() {
253 253
 
254 254
 
255 255
 		$args = array(
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		    'query_var' => true,
267 267
 		    'exclude_from_search' => true,
268 268
 		    'rewrite' => array(
269
-                'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) ,
269
+                'slug' => esc_attr(apply_filters('sensei_quiz_slug', _x('quiz', 'post type single slug', 'woothemes-sensei'))),
270 270
                 'with_front' =>  true,
271 271
                 'feeds' => true,
272 272
                 'pages' => true
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 		    'has_archive' => false,
277 277
 		    'hierarchical' => false,
278 278
 		    'menu_position' => 20, // Below "Pages"
279
-		    'supports' => array( '' )
279
+		    'supports' => array('')
280 280
 		);
281 281
 
282 282
         /**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
          * @since 1.9.0
286 286
          * @param array $args
287 287
          */
288
-		register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) );
288
+		register_post_type('quiz', apply_filters('sensei_register_post_type_quiz', $args));
289 289
 
290 290
 	} // End setup_quiz_post_type()
291 291
 
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 	 * @since  1.0.0
296 296
 	 * @return void
297 297
 	 */
298
-	public function setup_question_post_type () {
298
+	public function setup_question_post_type() {
299 299
 
300 300
 		$args = array(
301
-		    'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ),
301
+		    'labels' => $this->create_post_type_labels($this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu']),
302 302
 		    'public' => false,
303 303
 		    'publicly_queryable' => true,
304 304
 		    'show_ui' => true,
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		    'query_var' => true,
308 308
 		    'exclude_from_search' => true,
309 309
 		    'rewrite' => array(
310
-                'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
310
+                'slug' => esc_attr(apply_filters('sensei_question_slug', _x('question', 'post type single slug', 'woothemes-sensei'))),
311 311
                 'with_front' =>  true,
312 312
                 'feeds' => true,
313 313
                 'pages' => true
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		    'has_archive' => true,
318 318
 		    'hierarchical' => false,
319 319
 		    'menu_position' => 51,
320
-		    'supports' => array( 'title' )
320
+		    'supports' => array('title')
321 321
 		);
322 322
 
323 323
         /**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
          * @since 1.9.0
327 327
          * @param array $args
328 328
          */
329
-		register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) );
329
+		register_post_type('question', apply_filters('sensei_register_post_type_question', $args));
330 330
 
331 331
 	} // End setup_question_post_type()
332 332
 
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 	 * @since  1.6.0
336 336
 	 * @return void
337 337
 	 */
338
-	public function setup_multiple_question_post_type () {
338
+	public function setup_multiple_question_post_type() {
339 339
 
340 340
 		$args = array(
341
-		    'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ),
341
+		    'labels' => $this->create_post_type_labels($this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu']),
342 342
 		    'public' => false,
343 343
 		    'publicly_queryable' => false,
344 344
 		    'show_ui' => false,
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		    'query_var' => false,
348 348
 		    'exclude_from_search' => true,
349 349
 		    'rewrite' => array(
350
-                'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
350
+                'slug' => esc_attr(apply_filters('sensei_multiple_question_slug', _x('multiple_question', 'post type single slug', 'woothemes-sensei'))),
351 351
                 'with_front' =>  false,
352 352
                 'feeds' => false,
353 353
                 'pages' => false
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 		    'has_archive' => false,
358 358
 		    'hierarchical' => false,
359 359
 		    'menu_position' => 51,
360
-		    'supports' => array( 'title', 'custom-fields' )
360
+		    'supports' => array('title', 'custom-fields')
361 361
 		);
362 362
 
363
-		register_post_type( 'multiple_question', $args );
363
+		register_post_type('multiple_question', $args);
364 364
 	} // End setup_multiple_question_post_type()
365 365
 
366 366
 	/**
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 	 * @since  1.6.0
369 369
 	 * @return void
370 370
 	 */
371
-	public function setup_sensei_message_post_type () {
371
+	public function setup_sensei_message_post_type() {
372 372
 
373 373
 
374
-		if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) {
374
+		if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) {
375 375
 
376 376
 			$args = array(
377
-			    'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ),
377
+			    'labels' => $this->create_post_type_labels($this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu']),
378 378
 			    'public' => true,
379 379
 			    'publicly_queryable' => true,
380 380
 			    'show_ui' => true,
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 			    'query_var' => true,
384 384
 			    'exclude_from_search' => true,
385 385
 			    'rewrite' => array(
386
-                    'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) ,
386
+                    'slug' => esc_attr(apply_filters('sensei_messages_slug', _x('messages', 'post type single slug', 'woothemes-sensei'))),
387 387
                     'with_front' =>  false,
388 388
                     'feeds' => false,
389 389
                     'pages' => true
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			    'has_archive' => true,
394 394
 			    'hierarchical' => false,
395 395
 			    'menu_position' => 50,
396
-			    'supports' => array( 'title', 'editor', 'comments' ),
396
+			    'supports' => array('title', 'editor', 'comments'),
397 397
 			);
398 398
 
399 399
             /**
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
              * @since 1.9.0
403 403
              * @param array $args
404 404
              */
405
-			register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message',  $args ) );
405
+			register_post_type('sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args));
406 406
 		}
407 407
 	} // End setup_sensei_message_post_type()
408 408
 
@@ -411,20 +411,20 @@  discard block
 block discarded – undo
411 411
 	 * @since  1.1.0
412 412
 	 * @return void
413 413
 	 */
414
-	public function setup_course_category_taxonomy () {
414
+	public function setup_course_category_taxonomy() {
415 415
 		// "Course Categories" Custom Taxonomy
416 416
 		$labels = array(
417
-			'name' => _x( 'Course Categories', 'taxonomy general name', 'woothemes-sensei' ),
418
-			'singular_name' => _x( 'Course Category', 'taxonomy singular name', 'woothemes-sensei' ),
419
-			'search_items' =>  __( 'Search Course Categories', 'woothemes-sensei' ),
420
-			'all_items' => __( 'All Course Categories', 'woothemes-sensei' ),
421
-			'parent_item' => __( 'Parent Course Category', 'woothemes-sensei' ),
422
-			'parent_item_colon' => __( 'Parent Course Category:', 'woothemes-sensei' ),
423
-			'edit_item' => __( 'Edit Course Category', 'woothemes-sensei' ),
424
-			'update_item' => __( 'Update Course Category', 'woothemes-sensei' ),
425
-			'add_new_item' => __( 'Add New Course Category', 'woothemes-sensei' ),
426
-			'new_item_name' => __( 'New Course Category Name', 'woothemes-sensei' ),
427
-			'menu_name' => __( 'Course Categories', 'woothemes-sensei' ),
417
+			'name' => _x('Course Categories', 'taxonomy general name', 'woothemes-sensei'),
418
+			'singular_name' => _x('Course Category', 'taxonomy singular name', 'woothemes-sensei'),
419
+			'search_items' =>  __('Search Course Categories', 'woothemes-sensei'),
420
+			'all_items' => __('All Course Categories', 'woothemes-sensei'),
421
+			'parent_item' => __('Parent Course Category', 'woothemes-sensei'),
422
+			'parent_item_colon' => __('Parent Course Category:', 'woothemes-sensei'),
423
+			'edit_item' => __('Edit Course Category', 'woothemes-sensei'),
424
+			'update_item' => __('Update Course Category', 'woothemes-sensei'),
425
+			'add_new_item' => __('Add New Course Category', 'woothemes-sensei'),
426
+			'new_item_name' => __('New Course Category Name', 'woothemes-sensei'),
427
+			'menu_name' => __('Course Categories', 'woothemes-sensei'),
428 428
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
429 429
 		);
430 430
 
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
                 'edit_terms'   => 'edit_courses',
440 440
                 'delete_terms' => 'manage_categories',
441 441
                 'assign_terms' => 'edit_courses',),
442
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
442
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_course_category_slug', _x('course-category', 'taxonomy archive slug', 'woothemes-sensei'))))
443 443
 		);
444 444
 
445
-		register_taxonomy( 'course-category', array( 'course' ), $args );
445
+		register_taxonomy('course-category', array('course'), $args);
446 446
 
447 447
 	} // End setup_course_category_taxonomy()
448 448
 
@@ -451,20 +451,20 @@  discard block
 block discarded – undo
451 451
 	 * @since  1.0.0
452 452
 	 * @return void
453 453
 	 */
454
-	public function setup_quiz_type_taxonomy () {
454
+	public function setup_quiz_type_taxonomy() {
455 455
 		// "Quiz Types" Custom Taxonomy
456 456
 		$labels = array(
457
-			'name' => _x( 'Quiz Types', 'taxonomy general name', 'woothemes-sensei' ),
458
-			'singular_name' => _x( 'Quiz Type', 'taxonomy singular name', 'woothemes-sensei' ),
459
-			'search_items' =>  __( 'Search Quiz Types', 'woothemes-sensei' ),
460
-			'all_items' => __( 'All Quiz Types', 'woothemes-sensei' ),
461
-			'parent_item' => __( 'Parent Quiz Type', 'woothemes-sensei' ),
462
-			'parent_item_colon' => __( 'Parent Quiz Type:', 'woothemes-sensei' ),
463
-			'edit_item' => __( 'Edit Quiz Type', 'woothemes-sensei' ),
464
-			'update_item' => __( 'Update Quiz Type', 'woothemes-sensei' ),
465
-			'add_new_item' => __( 'Add New Quiz Type', 'woothemes-sensei' ),
466
-			'new_item_name' => __( 'New Quiz Type Name', 'woothemes-sensei' ),
467
-			'menu_name' => __( 'Quiz Types', 'woothemes-sensei' ),
457
+			'name' => _x('Quiz Types', 'taxonomy general name', 'woothemes-sensei'),
458
+			'singular_name' => _x('Quiz Type', 'taxonomy singular name', 'woothemes-sensei'),
459
+			'search_items' =>  __('Search Quiz Types', 'woothemes-sensei'),
460
+			'all_items' => __('All Quiz Types', 'woothemes-sensei'),
461
+			'parent_item' => __('Parent Quiz Type', 'woothemes-sensei'),
462
+			'parent_item_colon' => __('Parent Quiz Type:', 'woothemes-sensei'),
463
+			'edit_item' => __('Edit Quiz Type', 'woothemes-sensei'),
464
+			'update_item' => __('Update Quiz Type', 'woothemes-sensei'),
465
+			'add_new_item' => __('Add New Quiz Type', 'woothemes-sensei'),
466
+			'new_item_name' => __('New Quiz Type Name', 'woothemes-sensei'),
467
+			'menu_name' => __('Quiz Types', 'woothemes-sensei'),
468 468
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
469 469
 		);
470 470
 
@@ -475,10 +475,10 @@  discard block
 block discarded – undo
475 475
 			'query_var' => true,
476 476
 			'show_in_nav_menus' => false,
477 477
             'public' => false,
478
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
478
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_quiz_type_slug', _x('quiz-type', 'taxonomy archive slug', 'woothemes-sensei'))))
479 479
 		);
480 480
 
481
-		register_taxonomy( 'quiz-type', array( 'quiz' ), $args );
481
+		register_taxonomy('quiz-type', array('quiz'), $args);
482 482
 	} // End setup_quiz_type_taxonomy()
483 483
 
484 484
 	/**
@@ -486,20 +486,20 @@  discard block
 block discarded – undo
486 486
 	 * @since  1.3.0
487 487
 	 * @return void
488 488
 	 */
489
-	public function setup_question_type_taxonomy () {
489
+	public function setup_question_type_taxonomy() {
490 490
 		// "Question Types" Custom Taxonomy
491 491
 		$labels = array(
492
-			'name' => _x( 'Question Types', 'taxonomy general name', 'woothemes-sensei' ),
493
-			'singular_name' => _x( 'Question Type', 'taxonomy singular name', 'woothemes-sensei' ),
494
-			'search_items' =>  __( 'Search Question Types', 'woothemes-sensei' ),
495
-			'all_items' => __( 'All Question Types', 'woothemes-sensei' ),
496
-			'parent_item' => __( 'Parent Question Type', 'woothemes-sensei' ),
497
-			'parent_item_colon' => __( 'Parent Question Type:', 'woothemes-sensei' ),
498
-			'edit_item' => __( 'Edit Question Type', 'woothemes-sensei' ),
499
-			'update_item' => __( 'Update Question Type', 'woothemes-sensei' ),
500
-			'add_new_item' => __( 'Add New Question Type', 'woothemes-sensei' ),
501
-			'new_item_name' => __( 'New Question Type Name', 'woothemes-sensei' ),
502
-			'menu_name' => __( 'Question Types', 'woothemes-sensei' ),
492
+			'name' => _x('Question Types', 'taxonomy general name', 'woothemes-sensei'),
493
+			'singular_name' => _x('Question Type', 'taxonomy singular name', 'woothemes-sensei'),
494
+			'search_items' =>  __('Search Question Types', 'woothemes-sensei'),
495
+			'all_items' => __('All Question Types', 'woothemes-sensei'),
496
+			'parent_item' => __('Parent Question Type', 'woothemes-sensei'),
497
+			'parent_item_colon' => __('Parent Question Type:', 'woothemes-sensei'),
498
+			'edit_item' => __('Edit Question Type', 'woothemes-sensei'),
499
+			'update_item' => __('Update Question Type', 'woothemes-sensei'),
500
+			'add_new_item' => __('Add New Question Type', 'woothemes-sensei'),
501
+			'new_item_name' => __('New Question Type Name', 'woothemes-sensei'),
502
+			'menu_name' => __('Question Types', 'woothemes-sensei'),
503 503
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
504 504
 		);
505 505
 
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 			'query_var' => false,
512 512
 			'show_in_nav_menus' => false,
513 513
 			'show_admin_column' => true,
514
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_type_slug', _x( 'question-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
514
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_type_slug', _x('question-type', 'taxonomy archive slug', 'woothemes-sensei'))))
515 515
 		);
516 516
 
517
-		register_taxonomy( 'question-type', array( 'question' ), $args );
517
+		register_taxonomy('question-type', array('question'), $args);
518 518
 	} // End setup_question_type_taxonomy()
519 519
 
520 520
 	/**
@@ -522,20 +522,20 @@  discard block
 block discarded – undo
522 522
 	 * @since  1.3.0
523 523
 	 * @return void
524 524
 	 */
525
-	public function setup_question_category_taxonomy () {
525
+	public function setup_question_category_taxonomy() {
526 526
 		// "Question Categories" Custom Taxonomy
527 527
 		$labels = array(
528
-			'name' => _x( 'Question Categories', 'taxonomy general name', 'woothemes-sensei' ),
529
-			'singular_name' => _x( 'Question Category', 'taxonomy singular name', 'woothemes-sensei' ),
530
-			'search_items' =>  __( 'Search Question Categories', 'woothemes-sensei' ),
531
-			'all_items' => __( 'All Question Categories', 'woothemes-sensei' ),
532
-			'parent_item' => __( 'Parent Question Category', 'woothemes-sensei' ),
533
-			'parent_item_colon' => __( 'Parent Question Category:', 'woothemes-sensei' ),
534
-			'edit_item' => __( 'Edit Question Category', 'woothemes-sensei' ),
535
-			'update_item' => __( 'Update Question Category', 'woothemes-sensei' ),
536
-			'add_new_item' => __( 'Add New Question Category', 'woothemes-sensei' ),
537
-			'new_item_name' => __( 'New Question Category Name', 'woothemes-sensei' ),
538
-			'menu_name' => __( 'Categories', 'woothemes-sensei' ),
528
+			'name' => _x('Question Categories', 'taxonomy general name', 'woothemes-sensei'),
529
+			'singular_name' => _x('Question Category', 'taxonomy singular name', 'woothemes-sensei'),
530
+			'search_items' =>  __('Search Question Categories', 'woothemes-sensei'),
531
+			'all_items' => __('All Question Categories', 'woothemes-sensei'),
532
+			'parent_item' => __('Parent Question Category', 'woothemes-sensei'),
533
+			'parent_item_colon' => __('Parent Question Category:', 'woothemes-sensei'),
534
+			'edit_item' => __('Edit Question Category', 'woothemes-sensei'),
535
+			'update_item' => __('Update Question Category', 'woothemes-sensei'),
536
+			'add_new_item' => __('Add New Question Category', 'woothemes-sensei'),
537
+			'new_item_name' => __('New Question Category Name', 'woothemes-sensei'),
538
+			'menu_name' => __('Categories', 'woothemes-sensei'),
539 539
 		);
540 540
 
541 541
 		$args = array(
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
                 'edit_terms'   => 'edit_questions',
552 552
                 'delete_terms' => 'manage_categories',
553 553
                 'assign_terms' => 'edit_questions',),
554
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
554
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_category_slug', _x('question-category', 'taxonomy archive slug', 'woothemes-sensei'))))
555 555
 		);
556 556
 
557
-		register_taxonomy( 'question-category', array( 'question' ), $args );
557
+		register_taxonomy('question-category', array('question'), $args);
558 558
 	} // End setup_question_type_taxonomy()
559 559
 
560 560
 	/**
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
 	 * @since  1.5.0
563 563
 	 * @return void
564 564
 	 */
565
-	public function setup_lesson_tag_taxonomy () {
565
+	public function setup_lesson_tag_taxonomy() {
566 566
 		// "Lesson Tags" Custom Taxonomy
567 567
 		$labels = array(
568
-			'name' => _x( 'Lesson Tags', 'taxonomy general name', 'woothemes-sensei' ),
569
-			'singular_name' => _x( 'Lesson Tag', 'taxonomy singular name', 'woothemes-sensei' ),
570
-			'search_items' =>  __( 'Search Lesson Tags', 'woothemes-sensei' ),
571
-			'all_items' => __( 'All Lesson Tags', 'woothemes-sensei' ),
572
-			'parent_item' => __( 'Parent Tag', 'woothemes-sensei' ),
573
-			'parent_item_colon' => __( 'Parent Tag:', 'woothemes-sensei' ),
574
-			'edit_item' => __( 'Edit Lesson Tag', 'woothemes-sensei' ),
575
-			'update_item' => __( 'Update Lesson Tag', 'woothemes-sensei' ),
576
-			'add_new_item' => __( 'Add New Lesson Tag', 'woothemes-sensei' ),
577
-			'new_item_name' => __( 'New Tag Name', 'woothemes-sensei' ),
578
-			'menu_name' => __( 'Lesson Tags', 'woothemes-sensei' )
568
+			'name' => _x('Lesson Tags', 'taxonomy general name', 'woothemes-sensei'),
569
+			'singular_name' => _x('Lesson Tag', 'taxonomy singular name', 'woothemes-sensei'),
570
+			'search_items' =>  __('Search Lesson Tags', 'woothemes-sensei'),
571
+			'all_items' => __('All Lesson Tags', 'woothemes-sensei'),
572
+			'parent_item' => __('Parent Tag', 'woothemes-sensei'),
573
+			'parent_item_colon' => __('Parent Tag:', 'woothemes-sensei'),
574
+			'edit_item' => __('Edit Lesson Tag', 'woothemes-sensei'),
575
+			'update_item' => __('Update Lesson Tag', 'woothemes-sensei'),
576
+			'add_new_item' => __('Add New Lesson Tag', 'woothemes-sensei'),
577
+			'new_item_name' => __('New Tag Name', 'woothemes-sensei'),
578
+			'menu_name' => __('Lesson Tags', 'woothemes-sensei')
579 579
 		);
580 580
 
581 581
 		$args = array(
@@ -589,10 +589,10 @@  discard block
 block discarded – undo
589 589
                 'edit_terms'   => 'edit_lessons',
590 590
                 'delete_terms' => 'manage_categories',
591 591
                 'assign_terms' => 'edit_lessons',),
592
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
592
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_lesson_tag_slug', _x('lesson-tag', 'taxonomy archive slug', 'woothemes-sensei'))))
593 593
 		);
594 594
 
595
-		register_taxonomy( 'lesson-tag', array( 'lesson' ), $args );
595
+		register_taxonomy('lesson-tag', array('lesson'), $args);
596 596
 	} // End setup_lesson_tag_taxonomy()
597 597
 
598 598
 	/**
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
 	 * @since  1.0.0
601 601
 	 * @return void
602 602
 	 */
603
-	private function setup_post_type_labels_base () {
604
-		$this->labels = array( 'course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array() );
603
+	private function setup_post_type_labels_base() {
604
+		$this->labels = array('course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array());
605 605
 
606
-		$this->labels['course'] = array( 'singular' => __( 'Course', 'woothemes-sensei' ), 'plural' => __( 'Courses', 'woothemes-sensei' ), 'menu' => __( 'Courses', 'woothemes-sensei' ) );
607
-		$this->labels['lesson'] = array( 'singular' => __( 'Lesson', 'woothemes-sensei' ), 'plural' => __( 'Lessons', 'woothemes-sensei' ), 'menu' => __( 'Lessons', 'woothemes-sensei' ) );
608
-		$this->labels['quiz'] = array( 'singular' => __( 'Quiz', 'woothemes-sensei' ), 'plural' => __( 'Quizzes', 'woothemes-sensei' ), 'menu' => __( 'Quizzes', 'woothemes-sensei' ) );
609
-		$this->labels['question'] = array( 'singular' => __( 'Question', 'woothemes-sensei' ), 'plural' => __( 'Questions', 'woothemes-sensei' ), 'menu' => __( 'Questions', 'woothemes-sensei' ) );
610
-		$this->labels['multiple_question'] = array( 'singular' => __( 'Multiple Question', 'woothemes-sensei' ), 'plural' => __( 'Multiple Questions', 'woothemes-sensei' ), 'menu' => __( 'Multiple Questions', 'woothemes-sensei' ) );
611
-		$this->labels['sensei_message'] = array( 'singular' => __( 'Message', 'woothemes-sensei' ), 'plural' => __( 'Messages', 'woothemes-sensei' ), 'menu' => __( 'Messages', 'woothemes-sensei' ) );
606
+		$this->labels['course'] = array('singular' => __('Course', 'woothemes-sensei'), 'plural' => __('Courses', 'woothemes-sensei'), 'menu' => __('Courses', 'woothemes-sensei'));
607
+		$this->labels['lesson'] = array('singular' => __('Lesson', 'woothemes-sensei'), 'plural' => __('Lessons', 'woothemes-sensei'), 'menu' => __('Lessons', 'woothemes-sensei'));
608
+		$this->labels['quiz'] = array('singular' => __('Quiz', 'woothemes-sensei'), 'plural' => __('Quizzes', 'woothemes-sensei'), 'menu' => __('Quizzes', 'woothemes-sensei'));
609
+		$this->labels['question'] = array('singular' => __('Question', 'woothemes-sensei'), 'plural' => __('Questions', 'woothemes-sensei'), 'menu' => __('Questions', 'woothemes-sensei'));
610
+		$this->labels['multiple_question'] = array('singular' => __('Multiple Question', 'woothemes-sensei'), 'plural' => __('Multiple Questions', 'woothemes-sensei'), 'menu' => __('Multiple Questions', 'woothemes-sensei'));
611
+		$this->labels['sensei_message'] = array('singular' => __('Message', 'woothemes-sensei'), 'plural' => __('Messages', 'woothemes-sensei'), 'menu' => __('Messages', 'woothemes-sensei'));
612 612
 
613 613
 	} // End setup_post_type_labels_base()
614 614
 
@@ -620,21 +620,21 @@  discard block
 block discarded – undo
620 620
 	 * @param  string $menu     The menu item label
621 621
 	 * @return array            An array of the labels to be used
622 622
 	 */
623
-	private function create_post_type_labels ( $singular, $plural, $menu ) {
623
+	private function create_post_type_labels($singular, $plural, $menu) {
624 624
 		$labels = array(
625
-		    'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ),
626
-		    'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ),
627
-		    'add_new' => __( 'Add New', 'woothemes-sensei' ),
628
-		    'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ),
629
-		    'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ),
630
-		    'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ),
631
-		    'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ),
632
-		    'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ),
633
-		    'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ),
634
-		    'not_found' =>  sprintf( __( 'No %s found', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ),
635
-		    'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ),
625
+		    'name' => sprintf(_x('%s', 'post type general name', 'woothemes-sensei'), $plural),
626
+		    'singular_name' => sprintf(_x('%s', 'post type singular name', 'woothemes-sensei'), $singular),
627
+		    'add_new' => __('Add New', 'woothemes-sensei'),
628
+		    'add_new_item' => sprintf(__('Add New %s', 'woothemes-sensei'), $singular),
629
+		    'edit_item' => sprintf(__('Edit %s', 'woothemes-sensei'), $singular),
630
+		    'new_item' => sprintf(__('New %s', 'woothemes-sensei'), $singular),
631
+		    'all_items' => sprintf(__('All %s', 'woothemes-sensei'), $plural),
632
+		    'view_item' => sprintf(__('View %s', 'woothemes-sensei'), $singular),
633
+		    'search_items' => sprintf(__('Search %s', 'woothemes-sensei'), $plural),
634
+		    'not_found' =>  sprintf(__('No %s found', 'woothemes-sensei'), mb_strtolower($plural, 'UTF-8')),
635
+		    'not_found_in_trash' => sprintf(__('No %s found in Trash', 'woothemes-sensei'), mb_strtolower($plural, 'UTF-8')),
636 636
 		    'parent_item_colon' => '',
637
-		    'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu )
637
+		    'menu_name' => sprintf(__('%s', 'woothemes-sensei'), $menu)
638 638
 		  );
639 639
 
640 640
 		return $labels;
@@ -646,14 +646,14 @@  discard block
 block discarded – undo
646 646
 	 * @param  array $messages The existing array of messages for post types.
647 647
 	 * @return array           The modified array of messages for post types.
648 648
 	 */
649
-	public function setup_post_type_messages ( $messages ) {
649
+	public function setup_post_type_messages($messages) {
650 650
 		global $post, $post_ID;
651 651
 
652
-		$messages['course'] = $this->create_post_type_messages( 'course' );
653
-		$messages['lesson'] = $this->create_post_type_messages( 'lesson' );
654
-		$messages['quiz'] = $this->create_post_type_messages( 'quiz' );
655
-		$messages['question'] = $this->create_post_type_messages( 'question' );
656
-		$messages['multiple_question'] = $this->create_post_type_messages( 'multiple_question' );
652
+		$messages['course'] = $this->create_post_type_messages('course');
653
+		$messages['lesson'] = $this->create_post_type_messages('lesson');
654
+		$messages['quiz'] = $this->create_post_type_messages('quiz');
655
+		$messages['question'] = $this->create_post_type_messages('question');
656
+		$messages['multiple_question'] = $this->create_post_type_messages('multiple_question');
657 657
 
658 658
 		return $messages;
659 659
 	} // End setup_post_type_messages()
@@ -664,23 +664,23 @@  discard block
 block discarded – undo
664 664
 	 * @param  string $post_type The post type for which to create messages.
665 665
 	 * @return array            An array of messages (empty array if the post type isn't one we're looking to work with).
666 666
 	 */
667
-	private function create_post_type_messages ( $post_type ) {
667
+	private function create_post_type_messages($post_type) {
668 668
 		global $post, $post_ID;
669 669
 
670
-		if ( ! isset( $this->labels[$post_type] ) ) { return array(); }
670
+		if ( ! isset($this->labels[$post_type])) { return array(); }
671 671
 
672 672
 		$messages = array(
673 673
 			0 => '',
674
-			1 => sprintf( __( '%1$s updated. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
675
-			2 => __( 'Custom field updated.' , 'woothemes-sensei' ),
676
-			3 => __( 'Custom field deleted.' , 'woothemes-sensei' ),
677
-			4 => sprintf( __( '%1$s updated.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
678
-			5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
679
-			6 => sprintf( __( '%1$s published. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
680
-			7 => sprintf( __( '%1$s saved.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
681
-			8 => sprintf( __( '%1$s submitted. %2$sPreview %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', '</a>' ),
682
-			9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'woothemes-sensei' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
683
-			10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
674
+			1 => sprintf(__('%1$s updated. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'),
675
+			2 => __('Custom field updated.', 'woothemes-sensei'),
676
+			3 => __('Custom field deleted.', 'woothemes-sensei'),
677
+			4 => sprintf(__('%1$s updated.', 'woothemes-sensei'), $this->labels[$post_type]['singular']),
678
+			5 => isset($_GET['revision']) ? sprintf(__('%1$s restored to revision from %2$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], wp_post_revision_title((int) $_GET['revision'], false)) : false,
679
+			6 => sprintf(__('%1$s published. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'),
680
+			7 => sprintf(__('%1$s saved.', 'woothemes-sensei'), $this->labels[$post_type]['singular']),
681
+			8 => sprintf(__('%1$s submitted. %2$sPreview %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', '</a>'),
682
+			9 => sprintf(__('%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<strong>'.date_i18n(__('M j, Y @ G:i', 'woothemes-sensei'), strtotime($post->post_date)).'</strong>', '<a target="_blank" href="'.esc_url(get_permalink($post_ID)).'">', $this->labels[$post_type]['singular'], '</a>'),
683
+			10 => sprintf(__('%1$s draft updated. %2$sPreview %3$s%4$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', $this->labels[$post_type]['singular'], '</a>'),
684 684
 		);
685 685
 
686 686
 		return $messages;
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
 	 * @param  string $title
694 694
 	 * @return string $title
695 695
 	 */
696
-	public function enter_title_here ( $title ) {
697
-		if ( get_post_type() == 'course' ) {
698
-			$title = __( 'Enter a title for this course here', 'woothemes-sensei' );
699
-		} elseif ( get_post_type() == 'lesson' ) {
700
-			$title = __( 'Enter a title for this lesson here', 'woothemes-sensei' );
696
+	public function enter_title_here($title) {
697
+		if (get_post_type() == 'course') {
698
+			$title = __('Enter a title for this course here', 'woothemes-sensei');
699
+		} elseif (get_post_type() == 'lesson') {
700
+			$title = __('Enter a title for this lesson here', 'woothemes-sensei');
701 701
 		}
702 702
 
703 703
 		return $title;
@@ -711,60 +711,60 @@  discard block
 block discarded – undo
711 711
 	 * @param array $post_types
712 712
 	 * @return void
713 713
 	 */
714
-	public function set_role_cap_defaults( $post_types = array() ) {
714
+	public function set_role_cap_defaults($post_types = array()) {
715 715
 
716
-		foreach ( $post_types as $post_type_item => $post_type_name ) {
716
+		foreach ($post_types as $post_type_item => $post_type_name) {
717 717
 			// Super Admin
718
-			$this->role_caps[] =  array(	'administrator' 	=> array( 	'edit_' . $post_type_item,
719
-																			'read_' . $post_type_item,
720
-																			'delete_' . $post_type_item,
721
-																			'create_' . $post_type_item . 's',
722
-																			'edit_' . $post_type_item . 's',
723
-																			'edit_others_' . $post_type_item . 's',
724
-																			'publish_' . $post_type_item . 's',
725
-																			'read_private_' . $post_type_item . 's',
718
+			$this->role_caps[] = array('administrator' 	=> array('edit_'.$post_type_item,
719
+																			'read_'.$post_type_item,
720
+																			'delete_'.$post_type_item,
721
+																			'create_'.$post_type_item.'s',
722
+																			'edit_'.$post_type_item.'s',
723
+																			'edit_others_'.$post_type_item.'s',
724
+																			'publish_'.$post_type_item.'s',
725
+																			'read_private_'.$post_type_item.'s',
726 726
 																			'read',
727
-																			'delete_' . $post_type_item . 's',
728
-																			'delete_private_' . $post_type_item . 's',
729
-																			'delete_published_' . $post_type_item . 's',
730
-																			'delete_others_' . $post_type_item . 's',
731
-																			'edit_private_' . $post_type_item . 's',
732
-																			'edit_published_' . $post_type_item . 's',
727
+																			'delete_'.$post_type_item.'s',
728
+																			'delete_private_'.$post_type_item.'s',
729
+																			'delete_published_'.$post_type_item.'s',
730
+																			'delete_others_'.$post_type_item.'s',
731
+																			'edit_private_'.$post_type_item.'s',
732
+																			'edit_published_'.$post_type_item.'s',
733 733
 																			'manage_sensei',
734
-																			'manage_sensei_grades' ),
735
-											'editor' 			=> array(	'edit_' . $post_type_item,
736
-																			'read_' . $post_type_item,
737
-																			'delete_' . $post_type_item,
738
-																			'create_' . $post_type_item . 's',
739
-																		 	'edit_' . $post_type_item . 's',
740
-																			'edit_others_' . $post_type_item . 's',
741
-																			'publish_' . $post_type_item . 's',
742
-																			'read_private_' . $post_type_item . 's',
734
+																			'manage_sensei_grades'),
735
+											'editor' 			=> array('edit_'.$post_type_item,
736
+																			'read_'.$post_type_item,
737
+																			'delete_'.$post_type_item,
738
+																			'create_'.$post_type_item.'s',
739
+																		 	'edit_'.$post_type_item.'s',
740
+																			'edit_others_'.$post_type_item.'s',
741
+																			'publish_'.$post_type_item.'s',
742
+																			'read_private_'.$post_type_item.'s',
743 743
 																			'read',
744
-																			'delete_' . $post_type_item . 's',
745
-																			'delete_private_' . $post_type_item . 's',
746
-																			'delete_published_' . $post_type_item . 's',
747
-																			'delete_others_' . $post_type_item . 's',
748
-																			'edit_private_' . $post_type_item . 's',
749
-																			'edit_published_' . $post_type_item . 's' ),
750
-											'author' 			=> array( 	'edit_' . $post_type_item,
751
-																			'read_' . $post_type_item,
752
-																			'delete_' . $post_type_item,
753
-																			'create_' . $post_type_item . 's',
754
-																			'edit_' . $post_type_item . 's',
755
-																			'publish_' . $post_type_item . 's',
744
+																			'delete_'.$post_type_item.'s',
745
+																			'delete_private_'.$post_type_item.'s',
746
+																			'delete_published_'.$post_type_item.'s',
747
+																			'delete_others_'.$post_type_item.'s',
748
+																			'edit_private_'.$post_type_item.'s',
749
+																			'edit_published_'.$post_type_item.'s'),
750
+											'author' 			=> array('edit_'.$post_type_item,
751
+																			'read_'.$post_type_item,
752
+																			'delete_'.$post_type_item,
753
+																			'create_'.$post_type_item.'s',
754
+																			'edit_'.$post_type_item.'s',
755
+																			'publish_'.$post_type_item.'s',
756 756
 																			'read',
757
-																			'delete_' . $post_type_item . 's',
758
-																			'delete_published_' . $post_type_item . 's',
759
-																			'edit_published_' . $post_type_item . 's' ),
760
-											'contributor' 		=> array( 	'edit_' . $post_type_item,
761
-																			'read_' . $post_type_item,
762
-																			'delete_' . $post_type_item,
763
-																			'create_' . $post_type_item . 's',
764
-																			'edit_' . $post_type_item . 's',
757
+																			'delete_'.$post_type_item.'s',
758
+																			'delete_published_'.$post_type_item.'s',
759
+																			'edit_published_'.$post_type_item.'s'),
760
+											'contributor' 		=> array('edit_'.$post_type_item,
761
+																			'read_'.$post_type_item,
762
+																			'delete_'.$post_type_item,
763
+																			'create_'.$post_type_item.'s',
764
+																			'edit_'.$post_type_item.'s',
765 765
 																			'read',
766
-																			'delete_' . $post_type_item . 's' ),
767
-											'subscriber' 		=> array( 	'read' )
766
+																			'delete_'.$post_type_item.'s'),
767
+											'subscriber' 		=> array('read')
768 768
 
769 769
 										);
770 770
 		} // End For Loop
@@ -778,16 +778,16 @@  discard block
 block discarded – undo
778 778
      * @param WP_Admin_Bar $bar
779 779
 	 * @return void
780 780
 	 */
781
-	public function quiz_admin_bar_menu( $bar ) {
782
-		if ( is_single() && 'quiz' == get_queried_object()->post_type ) {
783
-			$lesson_id = get_post_meta( get_queried_object()->ID, '_quiz_lesson', true );
784
-			if ( $lesson_id ) {
781
+	public function quiz_admin_bar_menu($bar) {
782
+		if (is_single() && 'quiz' == get_queried_object()->post_type) {
783
+			$lesson_id = get_post_meta(get_queried_object()->ID, '_quiz_lesson', true);
784
+			if ($lesson_id) {
785 785
 				$object_type = get_post_type_object('quiz');
786
-				$bar->add_menu( array(
786
+				$bar->add_menu(array(
787 787
 					'id' => 'edit',
788 788
 					'title' => $object_type->labels->edit_item,
789
-					'href' => get_edit_post_link( $lesson_id ),
790
-				) );
789
+					'href' => get_edit_post_link($lesson_id),
790
+				));
791 791
 			}
792 792
 		}
793 793
 	}
@@ -799,4 +799,4 @@  discard block
 block discarded – undo
799 799
  * for backward compatibility
800 800
  * @since 1.9.0
801 801
  */
802
-class WooThemes_Sensei_PostTypes extends Sensei_PostTypes{}
802
+class WooThemes_Sensei_PostTypes extends Sensei_PostTypes {}
Please login to merge, or discard this patch.
includes/class-sensei-updates.php 1 patch
Spacing   +481 added lines, -481 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 Updates Class
@@ -27,59 +27,59 @@  discard block
 block discarded – undo
27 27
 	 * @param   string $parent The main Sensei object by Ref.
28 28
 	 * @return  void
29 29
 	 */
30
-	public function __construct ( $parent ) {
30
+	public function __construct($parent) {
31 31
 
32 32
 		// Setup object data
33 33
 		$this->parent = $parent;
34
-		$this->updates_run = get_option( 'woothemes-sensei-upgrades', array() );
34
+		$this->updates_run = get_option('woothemes-sensei-upgrades', array());
35 35
 
36 36
 		// The list of upgrades to run
37
-		$this->updates = array( '1.1.0' => array( 	'auto' 		=> array( 'assign_role_caps' => array( 'title' => __( 'Assign role capabilities', 'woothemes-sensei' ), 'desc' => __( 'Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei' ), 'product' => 'Sensei' ) ),
37
+		$this->updates = array('1.1.0' => array('auto' 		=> array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')),
38 38
 													'manual' 	=> array()
39 39
 												),
40
-								'1.3.0' => array( 	'auto' 		=> array( 'set_default_quiz_grade_type' => array( 'title' => __( 'Set default quiz grade type', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei' ) ),
41
-																		  'set_default_question_type' => array( 'title' => __( 'Set default question type', 'woothemes-sensei' ), 'desc' => __( 'Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei' ) )
40
+								'1.3.0' => array('auto' 		=> array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')),
41
+																		  'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei'))
42 42
 													),
43
-													'manual' 	=> array( 'update_question_answer_data' => array( 'title' => __( 'Update question answer data', 'woothemes-sensei' ), 'desc' => __( 'Updates questions to use the new question types structure.', 'woothemes-sensei' ) ) )
43
+													'manual' 	=> array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei')))
44 44
 												),
45
-								'1.4.0' => array( 	'auto' 		=> array( 'update_question_grade_points' => array( 'title' => __( 'Update question grade points', 'woothemes-sensei' ), 'desc' => __( 'Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei' ) ) ),
45
+								'1.4.0' => array('auto' 		=> array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))),
46 46
 													'manual' 	=> array()
47 47
 												),
48
-								'1.5.0' => array( 	'auto' 		=> array( 'convert_essay_paste_questions' => array( 'title' => __( 'Convert essay paste questions into multi-line questions', 'woothemes-sensei' ), 'desc' => __( 'Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei' ) ) ),
49
-													'manual' 	=> array( 'set_random_question_order' => array( 'title' => __( 'Set all quizzes to have a random question order', 'woothemes-sensei' ), 'desc' => __( 'Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei' ) ),
50
-																		  'set_default_show_question_count' => array( 'title' => __( 'Set all quizzes to show all questions', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei' ) ),
51
-																		  'remove_deleted_user_activity' => array( 'title' => __( 'Remove Sensei activity for deleted users', 'woothemes-sensei' ), 'desc' => __( 'Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei' ) ) )
48
+								'1.5.0' => array('auto' 		=> array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))),
49
+													'manual' 	=> array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')),
50
+																		  'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')),
51
+																		  'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei')))
52 52
 												),
53
-								'1.6.0' => array( 	'auto' 		=> array( 'add_teacher_role' => array( 'title' => __( 'Add \'Teacher\' role', 'woothemes-sensei' ), 'desc' => __( 'Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei' ) ),
54
-																		  'add_sensei_caps' => array( 'title' => __( 'Add administrator capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei' ) ),
55
-																		  'restructure_question_meta' => array( 'title' => __( 'Restructure question meta data', 'woothemes-sensei' ), 'desc' => __( 'Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei' ) ),
56
-																		  'update_quiz_settings' => array( 'title' => __( 'Add new quiz settings', 'woothemes-sensei' ), 'desc' => __( 'Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei' ) ),
57
-																		  'reset_lesson_order_meta' => array( 'title' => __( 'Set default order of lessons', 'woothemes-sensei' ), 'desc' => __( 'Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei' ) ), ),
53
+								'1.6.0' => array('auto' 		=> array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')),
54
+																		  'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')),
55
+																		  'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')),
56
+																		  'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')),
57
+																		  'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),),
58 58
 													'manual' 	=> array()
59 59
 												),
60
-								'1.7.0' => array( 	'auto' 		=> array( 'add_editor_caps' => array( 'title' => __( 'Add Editor capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei' ) ), ),
61
-													'forced' 	=> array(  'update_question_gap_fill_separators' => array( 'title' => __( 'Update Gap Fill questions', 'woothemes-sensei' ), 'desc' => __( 'Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei' ) ),
62
-																		  'update_quiz_lesson_relationship' => array( 'title' => __( 'Restructure quiz lesson relationship', 'woothemes-sensei' ), 'desc' => __( 'Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei' ) ),
63
-																		  'status_changes_fix_lessons' => array( 'title' => __( 'Update lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Update existing lesson statuses.', 'woothemes-sensei' ) ),
64
-																		  'status_changes_convert_lessons' => array( 'title' => __( 'Convert lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new lesson statuses.', 'woothemes-sensei' ) ),
65
-																		  'status_changes_convert_courses' => array( 'title' => __( 'Convert course statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new course statuses.', 'woothemes-sensei' ) ),
66
-																		  'status_changes_convert_questions' => array( 'title' => __( 'Convert question statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new question statuses.', 'woothemes-sensei' ) ),
67
-																		  'update_legacy_sensei_comments_status' => array( 'title' => __( 'Convert legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei' ) ),
68
-																		  'update_comment_course_lesson_comment_counts' => array( 'title' => __( 'Update comment counts', 'woothemes-sensei' ), 'desc' => __( 'Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei' ) ), ),
60
+								'1.7.0' => array('auto' 		=> array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),),
61
+													'forced' 	=> array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')),
62
+																		  'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')),
63
+																		  'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')),
64
+																		  'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')),
65
+																		  'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')),
66
+																		  'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')),
67
+																		  'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')),
68
+																		  'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),),
69 69
 												),
70
-								'1.7.2' => array( 	'auto' 		=> array( 'index_comment_status_field' => array( 'title' => __( 'Add database index to comment statuses', 'woothemes-sensei' ), 'desc' => __( 'This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei' ) ), ),
70
+								'1.7.2' => array('auto' 		=> array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),),
71 71
 													/*'manual' 		=> array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/
72 72
 												),
73
-                                '1.8.0' => array(   'auto' => array( 'enhance_teacher_role' => array( 'title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.' ), ),
73
+                                '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),),
74 74
                             						'manual' 	=> array()
75 75
                     							),
76 76
 							);
77 77
 
78
-		$this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates );
79
-		$this->version = get_option( 'woothemes-sensei-version' );
78
+		$this->updates = apply_filters('sensei_upgrade_functions', $this->updates, $this->updates);
79
+		$this->version = get_option('woothemes-sensei-version');
80 80
 
81 81
 		// Manual Update Screen
82
-		add_action('admin_menu', array( $this, 'add_update_admin_screen' ), 50 );
82
+		add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
83 83
 
84 84
 	} // End __construct()
85 85
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @return void
92 92
 	 */
93 93
 	public function add_update_admin_screen() {
94
-		if ( current_user_can( 'manage_options' ) ) {
95
-			add_submenu_page( 'sensei', __( 'Sensei Updates', 'woothemes-sensei' ), __( 'Data Updates', 'woothemes-sensei' ), 'manage_options', 'sensei_updates', array( $this, 'sensei_updates_page' ) );
94
+		if (current_user_can('manage_options')) {
95
+			add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page'));
96 96
 		}
97 97
 	} // End add_update_admin_screen()
98 98
 
@@ -106,80 +106,80 @@  discard block
 block discarded – undo
106 106
 	public function sensei_updates_page() {
107 107
 
108 108
 		// Only allow admins to load this page and run the update functions
109
-		if( current_user_can( 'manage_options' ) ) {
109
+		if (current_user_can('manage_options')) {
110 110
 			?>
111 111
 			<div class="wrap">
112 112
 
113 113
 				<div id="icon-woothemes-sensei" class="icon32"><br></div>
114
-				<h2><?php _e( 'Sensei Updates', 'woothemes-sensei' ); ?></h2>
114
+				<h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2>
115 115
 
116 116
 				<?php
117
-				if ( isset( $_GET['action'] ) && $_GET['action'] == 'update' && isset( $_GET['n'] ) && intval( $_GET['n'] ) >= 0 && ( ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) || ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) ) ) {
117
+				if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($_GET['n']) && intval($_GET['n']) >= 0 && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
118 118
 
119 119
 					// Setup the data variables
120
-					$n = intval( $_GET['n'] );
120
+					$n = intval($_GET['n']);
121 121
 					$functions_list = '';
122 122
 					$done_processing = false;
123 123
 
124 124
 					// Check for updates to run
125
-					if ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) {
125
+					if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) {
126 126
 
127
-						foreach ( $_POST['checked'] as $key => $value ) {
127
+						foreach ($_POST['checked'] as $key => $value) {
128 128
 
129 129
 							// Dynamic function call
130
-							if ( method_exists( $this, $value) ) {
131
-								$done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) );
130
+							if (method_exists($this, $value)) {
131
+								$done_processing = call_user_func_array(array($this, $value), array(50, $n));
132 132
 							} else {
133
-								$done_processing = call_user_func_array( $value, array( 50, $n ) );
133
+								$done_processing = call_user_func_array($value, array(50, $n));
134 134
 							} // End If Statement
135 135
 
136 136
 							// Add to functions list get args
137
-							if ( '' == $functions_list ) {
137
+							if ('' == $functions_list) {
138 138
 								$functions_list .= $value;
139 139
 							} else {
140
-								$functions_list .= '+' . $value;
140
+								$functions_list .= '+'.$value;
141 141
 							} // End If Statement
142 142
 
143 143
 							// Mark update has having been run
144
-							$this->set_update_run( $value );
144
+							$this->set_update_run($value);
145 145
 
146 146
 						} // End For Loop
147 147
 
148 148
 					} // End If Statement
149 149
 
150 150
 					// Check for updates to run
151
-					if ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) {
151
+					if (isset($_GET['functions']) && '' != $_GET['functions']) {
152 152
 
153 153
 						// Existing functions from GET variables instead of POST
154 154
 						$functions_array = $_GET['functions'];
155 155
 
156
-						foreach ( $functions_array as $key => $value ) {
156
+						foreach ($functions_array as $key => $value) {
157 157
 
158 158
 							// Dynamic function call
159
-							if ( method_exists( $this, $value) ) {
160
-								$done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) );
159
+							if (method_exists($this, $value)) {
160
+								$done_processing = call_user_func_array(array($this, $value), array(50, $n));
161 161
 							} else {
162
-								$done_processing = call_user_func_array( $value, array( 50, $n ) );
162
+								$done_processing = call_user_func_array($value, array(50, $n));
163 163
 							} // End If Statement
164 164
 
165 165
 							// Add to functions list get args
166
-							if ( '' == $functions_list ) {
166
+							if ('' == $functions_list) {
167 167
 								$functions_list .= $value;
168 168
 							} else {
169
-								$functions_list .= '+' . $value;
169
+								$functions_list .= '+'.$value;
170 170
 							} // End If Statement
171 171
 
172
-							$this->set_update_run( $value );
172
+							$this->set_update_run($value);
173 173
 
174 174
 						} // End For Loop
175 175
 
176 176
 					} // End If Statement
177 177
 
178
-					if ( ! $done_processing ) { ?>
178
+					if ( ! $done_processing) { ?>
179 179
 
180
-						<h3><?php _e( 'Processing Updates...', 'woothemes-sensei' ); ?></h3>
180
+						<h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3>
181 181
 
182
-						<p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this button:', 'woothemes-sensei' ); ?>&nbsp;&nbsp;<a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e( 'Next', 'woothemes-sensei' ); ?></a></p>
182
+						<p><?php _e('If your browser doesn&#8217;t start loading the next page automatically, click this button:', 'woothemes-sensei'); ?>&nbsp;&nbsp;<a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e('Next', 'woothemes-sensei'); ?></a></p>
183 183
 						<script type='text/javascript'>
184 184
 						<!--
185 185
 						function sensei_nextpage() {
@@ -191,48 +191,48 @@  discard block
 block discarded – undo
191 191
 
192 192
 					} else { ?>
193 193
 
194
-						<p><strong><?php _e( 'Update completed successfully!', 'woothemes-sensei' ); ?></strong></p>
195
-						<p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e( 'Create a new lesson', 'woothemes-sensei' ); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e( 'run some more updates', 'woothemes-sensei' ); ?></a>.</p>
194
+						<p><strong><?php _e('Update completed successfully!', 'woothemes-sensei'); ?></strong></p>
195
+						<p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e('Create a new lesson', 'woothemes-sensei'); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e('run some more updates', 'woothemes-sensei'); ?></a>.</p>
196 196
 
197 197
 					<?php } // End If Statement
198 198
 
199 199
 				} else { ?>
200 200
 
201
-					<h3><?php _e( 'Updates', 'woothemes-sensei' ); ?></h3>
202
-					<p><?php printf( __( 'These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei' ), '<code>', '</code>' ); ?></p>
201
+					<h3><?php _e('Updates', 'woothemes-sensei'); ?></h3>
202
+					<p><?php printf(__('These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei'), '<code>', '</code>'); ?></p>
203 203
 
204
-					<div class="updated"><p><strong><?php _e( 'Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei' ); ?></strong></p></div>
204
+					<div class="updated"><p><strong><?php _e('Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei'); ?></strong></p></div>
205 205
 
206 206
 					<table class="widefat" cellspacing="0" id="update-plugins-table">
207 207
 
208 208
 						<thead>
209 209
 							<tr>
210
-								<th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th>
211
-								<th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th>
212
-								<th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th>
210
+								<th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th>
211
+								<th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th>
212
+								<th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th>
213 213
 							</tr>
214 214
 						</thead>
215 215
 
216 216
 						<tfoot>
217 217
 							<tr>
218
-								<th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th>
219
-								<th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th>
220
-								<th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th>
218
+								<th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th>
219
+								<th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th>
220
+								<th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th>
221 221
 							</tr>
222 222
 						</tfoot>
223 223
 
224 224
 						<tbody class="updates">
225 225
 							<?php
226 226
 							// Sort updates with the latest at the top
227
-							uksort( $this->updates, array( $this, 'sort_updates' ) );
228
-							$this->updates = array_reverse( $this->updates, true );
227
+							uksort($this->updates, array($this, 'sort_updates'));
228
+							$this->updates = array_reverse($this->updates, true);
229 229
 							$class = 'alternate';
230
-							foreach( $this->updates as $version => $version_updates ) {
231
-								foreach( $version_updates as $type => $updates ) {
232
-									foreach( $updates as $update => $data ) {
233
-										$update_run = $this->has_update_run( $update );
230
+							foreach ($this->updates as $version => $version_updates) {
231
+								foreach ($version_updates as $type => $updates) {
232
+									foreach ($updates as $update => $data) {
233
+										$update_run = $this->has_update_run($update);
234 234
 										$product = 'Sensei';
235
-										if ( isset( $data['product'] ) && '' != $data['product'] ) {
235
+										if (isset($data['product']) && '' != $data['product']) {
236 236
 											$product = $data['product'];
237 237
 										} // End If Statement
238 238
 										?>
@@ -242,21 +242,21 @@  discard block
 block discarded – undo
242 242
 													<p>
243 243
 														<input type="hidden" name="checked[]" value="<?php echo $update; ?>">
244 244
 														<strong><?php echo $data['title']; ?></strong><br><?php echo $data['desc']; ?><br>
245
-														<em><?php printf( __( 'Originally included in %s v%s', 'woothemes-sensei' ), $product, $version ); ?></em>
245
+														<em><?php printf(__('Originally included in %s v%s', 'woothemes-sensei'), $product, $version); ?></em>
246 246
 													</p>
247 247
 												</td>
248 248
 												<?php
249
-												$type_label = __( 'Auto', 'woothemes-sensei' );
250
-												if( $type != 'auto' ) {
251
-													$type_label = __( 'Manual', 'woothemes-sensei' );
249
+												$type_label = __('Auto', 'woothemes-sensei');
250
+												if ($type != 'auto') {
251
+													$type_label = __('Manual', 'woothemes-sensei');
252 252
 												}
253 253
 												?>
254 254
 												<td><p><?php echo $type_label; ?></p></td>
255
-												<td><p><input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');" id="update-sensei" class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>" type="submit" value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>" name="update"></p></td>
255
+												<td><p><input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');" id="update-sensei" class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>" type="submit" value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>" name="update"></p></td>
256 256
 											</tr>
257 257
 										</form>
258 258
 										<?php
259
-										if( 'alternate' == $class ) {
259
+										if ('alternate' == $class) {
260 260
 											$class = '';
261 261
 										} else {
262 262
 											$class = 'alternate';
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param  string $b Second key
284 284
 	 * @return integer
285 285
 	 */
286
-	private function sort_updates( $a, $b ) {
287
-		return strcmp( $a, $b );
286
+	private function sort_updates($a, $b) {
287
+		return strcmp($a, $b);
288 288
 	}
289 289
 
290 290
 	/**
@@ -295,32 +295,32 @@  discard block
 block discarded – undo
295 295
 	 * @access public
296 296
 	 * @return boolean
297 297
 	 */
298
-	public function update ( $type = 'auto' ) {
298
+	public function update($type = 'auto') {
299 299
 
300 300
 		// Only allow admins to run update functions
301
-		if( current_user_can( 'manage_options' ) ) {
301
+		if (current_user_can('manage_options')) {
302 302
 
303 303
 			$this->force_updates();
304 304
 
305 305
 			// Run through all functions
306
-			foreach ( $this->updates as $version => $value ) {
307
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
308
-					if ( $upgrade_type == $type ) {
306
+			foreach ($this->updates as $version => $value) {
307
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
308
+					if ($upgrade_type == $type) {
309 309
 						$updated = false;
310 310
 						// Run the update function
311
-						foreach ( $function_to_run as $function_name => $update_data ) {
312
-							if ( isset( $function_name ) && '' != $function_name ) {
313
-								if ( ! in_array( $function_name, $this->updates_run ) ) {
311
+						foreach ($function_to_run as $function_name => $update_data) {
312
+							if (isset($function_name) && '' != $function_name) {
313
+								if ( ! in_array($function_name, $this->updates_run)) {
314 314
 									$updated = false;
315
-									if ( method_exists( $this, $function_name ) ) {
316
-										$updated = call_user_func( array( $this, $function_name ) );
317
-									} elseif( function_exists( $function_name ) ) {
318
-										$updated = call_user_func( $function_name );
315
+									if (method_exists($this, $function_name)) {
316
+										$updated = call_user_func(array($this, $function_name));
317
+									} elseif (function_exists($function_name)) {
318
+										$updated = call_user_func($function_name);
319 319
 									} else {
320 320
 										// Nothing to see here...
321 321
 									} // End If Statement
322
-									if ( $updated ) {
323
-										array_push( $this->updates_run, $function_name );
322
+									if ($updated) {
323
+										array_push($this->updates_run, $function_name);
324 324
 									} // End If Statement
325 325
 								}
326 326
 							} // End If Statement
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 				} // End For Loop
330 330
 			} // End For Loop
331 331
 
332
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
333
-			update_option( Sensei()->token . '-upgrades', $this->updates_run );
332
+            $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
333
+			update_option(Sensei()->token.'-upgrades', $this->updates_run);
334 334
 			return true;
335 335
 
336 336
 		}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
 	private function force_updates() {
341 341
 
342
-		if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) {
342
+		if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) {
343 343
 
344 344
 			// $skip_forced_updates = false;
345 345
 			// if( ! get_option( 'woothemes-sensei-force-updates', false ) ) {
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 
349 349
 			// Force critical updates if only if lessons already exist
350 350
 			$skip_forced_updates = false;
351
-			$lesson_posts = wp_count_posts( 'lesson' );
352
-			if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) {
351
+			$lesson_posts = wp_count_posts('lesson');
352
+			if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) {
353 353
 				$skip_forced_updates = true;
354 354
 			}
355 355
 
@@ -357,69 +357,69 @@  discard block
 block discarded – undo
357 357
 
358 358
 			$updates_to_run = array();
359 359
 
360
-			foreach ( $this->updates as $version => $value ) {
361
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
362
-					if ( $upgrade_type == 'forced' ) {
363
-						foreach ( $function_to_run as $function_name => $update_data ) {
360
+			foreach ($this->updates as $version => $value) {
361
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
362
+					if ($upgrade_type == 'forced') {
363
+						foreach ($function_to_run as $function_name => $update_data) {
364 364
 
365
-							if( $skip_forced_updates ) {
366
-								$this->set_update_run( $function_name );
365
+							if ($skip_forced_updates) {
366
+								$this->set_update_run($function_name);
367 367
 								continue;
368 368
 							}
369 369
 
370
-							$update_run = $this->has_update_run( $function_name );
370
+							$update_run = $this->has_update_run($function_name);
371 371
 
372
-							if( ! $update_run ) {
372
+							if ( ! $update_run) {
373 373
 								$use_the_force = true;
374
-								$updates_to_run[ $function_name ] = $update_data;
374
+								$updates_to_run[$function_name] = $update_data;
375 375
 							}
376 376
 						}
377 377
 					}
378 378
 				}
379 379
 			}
380 380
 
381
-			if( $skip_forced_updates ) {
381
+			if ($skip_forced_updates) {
382 382
 				return;
383 383
 			}
384 384
 
385
-			if( $use_the_force && 0 < count( $updates_to_run ) ) {
385
+			if ($use_the_force && 0 < count($updates_to_run)) {
386 386
 
387
-				$update_title = __( 'Important Sensei updates required', 'woothemes-sensei' );
387
+				$update_title = __('Important Sensei updates required', 'woothemes-sensei');
388 388
 
389
-				$update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n";
389
+				$update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n";
390 390
 
391 391
 				// $update_message .= '<h4>' . sprintf( __( 'These updates are only required if you are updating from a previous version of Sensei. If you are installing Sensei for the first time, %1$syou can dismiss this page by clicking here%2$s.', 'woothemes-sensei' ), '<a href="' . add_query_arg( array( 'sensei_skip_forced_updates' => 'true' ) ) . '">', '</a>' ) . '</h4>' ."\n";
392 392
 
393
-				$update_message .= '<p>' . __( 'The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei' ) . '</p>' . "\n";
393
+				$update_message .= '<p>'.__('The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei').'</p>'."\n";
394 394
 
395
-				$update_message .= '<p><b>' . __( 'To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei' ) . '</b></p>' . "\n";
395
+				$update_message .= '<p><b>'.__('To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei').'</b></p>'."\n";
396 396
 
397
-				$update_message .= '<p>' . __( 'Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei' ) . '</p>' . "\n";
397
+				$update_message .= '<p>'.__('Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei').'</p>'."\n";
398 398
 
399
-				$update_message .= '<p><b>' . __( 'Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei' ) . '</b></p>' . "\n";
399
+				$update_message .= '<p><b>'.__('Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei').'</b></p>'."\n";
400 400
 
401
-				$update_message .= '<ol>' . "\n";
401
+				$update_message .= '<ol>'."\n";
402 402
 
403
-					foreach( $updates_to_run as $function => $data ) {
403
+					foreach ($updates_to_run as $function => $data) {
404 404
 
405
-						if( ! isset( $data['title'] ) ) {
405
+						if ( ! isset($data['title'])) {
406 406
 							break;
407 407
 						}
408 408
 
409
-						$update_message .= '<li style="margin:5px 0;"><a href="' . admin_url( 'admin.php?page=sensei_updates&action=update&n=0&functions[]=' . $function ) . '" target="_blank">' . $data['title'] . '</a></li>';
409
+						$update_message .= '<li style="margin:5px 0;"><a href="'.admin_url('admin.php?page=sensei_updates&action=update&n=0&functions[]='.$function).'" target="_blank">'.$data['title'].'</a></li>';
410 410
 					}
411 411
 
412
-				$update_message .= '</ol>' . "\n";
412
+				$update_message .= '</ol>'."\n";
413 413
 
414
-				switch( $version ) {
414
+				switch ($version) {
415 415
 
416 416
 					case '1.7.0':
417
-						$update_message .= '<p><em>' . sprintf( __( 'Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei' ), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>' ) . '</em></p>' . "\n";
417
+						$update_message .= '<p><em>'.sprintf(__('Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei'), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>').'</em></p>'."\n";
418 418
 					break;
419 419
 
420 420
 				}
421 421
 
422
-				wp_die( $update_message, $update_title );
422
+				wp_die($update_message, $update_title);
423 423
 			}
424 424
 		}
425 425
 	}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @since  1.4.0
432 432
 	 * @return boolean
433 433
 	 */
434
-	private function has_update_run( $update ) {
435
-		if ( in_array( $update, $this->updates_run ) ) {
434
+	private function has_update_run($update) {
435
+		if (in_array($update, $this->updates_run)) {
436 436
 			return true;
437 437
 		}
438 438
 		return false;
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
 	 * @param string $update Update to process
445 445
 	 * @since  1.4.0
446 446
 	 */
447
-	private function set_update_run( $update ) {
448
-		array_push( $this->updates_run, $update );
449
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
450
-		update_option( Sensei()->token . '-upgrades', $this->updates_run );
447
+	private function set_update_run($update) {
448
+		array_push($this->updates_run, $update);
449
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
450
+		update_option(Sensei()->token.'-upgrades', $this->updates_run);
451 451
 	}
452 452
 
453 453
 	/**
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 	 * @return void
459 459
 	 */
460 460
 	public function assign_role_caps() {
461
-		foreach ( $this->parent->post_types->role_caps as $role_cap_set  ) {
462
-			foreach ( $role_cap_set as $role_key => $capabilities_array ) {
461
+		foreach ($this->parent->post_types->role_caps as $role_cap_set) {
462
+			foreach ($role_cap_set as $role_key => $capabilities_array) {
463 463
 				/* Get the role. */
464
-				$role = get_role( $role_key );
465
-				foreach ( $capabilities_array as $cap_name  ) {
464
+				$role = get_role($role_key);
465
+				foreach ($capabilities_array as $cap_name) {
466 466
 					/* If the role exists, add required capabilities for the plugin. */
467
-					if ( !empty( $role ) ) {
468
-						if ( !$role->has_cap( $cap_name ) ) {
469
-							$role->add_cap( $cap_name );
467
+					if ( ! empty($role)) {
468
+						if ( ! $role->has_cap($cap_name)) {
469
+							$role->add_cap($cap_name);
470 470
 						} // End If Statement
471 471
 					} // End If Statement
472 472
 				} // End For Loop
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
 	 * @return void
484 484
 	 */
485 485
 	public function set_default_quiz_grade_type() {
486
-		$args = array(	'post_type' 		=> 'quiz',
486
+		$args = array('post_type' 		=> 'quiz',
487 487
 						'posts_per_page' 		=> -1,
488 488
 						'post_status'		=> 'publish',
489 489
 						'suppress_filters' 	=> 0
490 490
 						);
491
-		$quizzes = get_posts( $args );
491
+		$quizzes = get_posts($args);
492 492
 
493
-		foreach( $quizzes as $quiz ) {
494
-			update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' );
495
-			update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' );
493
+		foreach ($quizzes as $quiz) {
494
+			update_post_meta($quiz->ID, '_quiz_grade_type', 'auto');
495
+			update_post_meta($quiz->ID, '_quiz_grade_type_disabled', '');
496 496
 		}
497 497
 		return true;
498 498
 	} // End set_default_quiz_grade_type
@@ -505,23 +505,23 @@  discard block
 block discarded – undo
505 505
 	 * @return void
506 506
 	 */
507 507
 	public function set_default_question_type() {
508
-		$args = array(	'post_type' 		=> 'question',
508
+		$args = array('post_type' 		=> 'question',
509 509
 						'posts_per_page' 		=> -1,
510 510
 						'post_status'		=> 'publish',
511 511
 						'suppress_filters' 	=> 0
512 512
 						);
513
-		$questions = get_posts( $args );
513
+		$questions = get_posts($args);
514 514
 
515 515
 		$already_run = true;
516
-		foreach( $questions as $question ) {
517
-			if( $already_run ) {
518
-				$terms = wp_get_post_terms( $question->ID, 'question-type' );
519
-				if( is_array( $terms ) && count( $terms ) > 0 ) {
516
+		foreach ($questions as $question) {
517
+			if ($already_run) {
518
+				$terms = wp_get_post_terms($question->ID, 'question-type');
519
+				if (is_array($terms) && count($terms) > 0) {
520 520
 					break;
521 521
 				}
522 522
 			}
523 523
 			$already_run = false;
524
-			wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' );
524
+			wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type');
525 525
 		}
526 526
 
527 527
 		return true;
@@ -534,90 +534,90 @@  discard block
 block discarded – undo
534 534
 	 * @access public
535 535
 	 * @return void
536 536
 	 */
537
-	public function update_question_answer_data( $n = 50, $offset = 0 ) {
537
+	public function update_question_answer_data($n = 50, $offset = 0) {
538 538
 
539 539
 		// Get Total Number of Updates to run
540
-		$quiz_count_object = wp_count_posts( 'quiz' );
540
+		$quiz_count_object = wp_count_posts('quiz');
541 541
 		$quiz_count_published = $quiz_count_object->publish;
542 542
 
543 543
 		// Calculate if this is the last page
544
-		if ( 0 == $offset ) {
544
+		if (0 == $offset) {
545 545
 			$current_page = 1;
546 546
 		} else {
547
-			$current_page = intval( $offset / $n );
547
+			$current_page = intval($offset / $n);
548 548
 		} // End If Statement
549
-		$total_pages = intval( $quiz_count_published / $n );
549
+		$total_pages = intval($quiz_count_published / $n);
550 550
 
551 551
 
552
-		$args = array(	'post_type' 		=> 'quiz',
552
+		$args = array('post_type' 		=> 'quiz',
553 553
 						'posts_per_page' 		=> $n,
554 554
 						'offset'			=> $offset,
555 555
 						'post_status'		=> 'publish',
556 556
 						'suppress_filters' 	=> 0
557 557
 						);
558
-		$quizzes = get_posts( $args );
558
+		$quizzes = get_posts($args);
559 559
 
560 560
 		$old_answers = array();
561 561
 		$right_answers = array();
562 562
 		$old_user_answers = array();
563 563
 
564
-		if( is_array( $quizzes ) ) {
565
-			foreach( $quizzes as $quiz ) {
564
+		if (is_array($quizzes)) {
565
+			foreach ($quizzes as $quiz) {
566 566
 				$quiz_id = $quiz->ID;
567 567
 
568 568
 				// Get current user answers
569
-				$comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true  );
569
+				$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true);
570 570
 				// Need to always return an array, even with only 1 item
571
-				if ( !is_array($comments) ) {
572
-					$comments = array( $comments );
571
+				if ( ! is_array($comments)) {
572
+					$comments = array($comments);
573 573
 				}
574
-				foreach ( $comments as $comment ) {
574
+				foreach ($comments as $comment) {
575 575
 					$user_id = $comment->user_id;
576
-					$content = maybe_unserialize( base64_decode( $comment->comment_content ) );
577
-					$old_user_answers[ $quiz_id ][ $user_id ] = $content;
576
+					$content = maybe_unserialize(base64_decode($comment->comment_content));
577
+					$old_user_answers[$quiz_id][$user_id] = $content;
578 578
 				}
579 579
 
580 580
 				// Get correct answers
581
-				$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
582
-				if( is_array( $questions ) ) {
583
-					foreach( $questions as $question ) {
584
-						$right_answer = get_post_meta( $question->ID, '_question_right_answer', true );
585
-						$right_answers[ $quiz_id ][ $question->ID ] = $right_answer;
581
+				$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
582
+				if (is_array($questions)) {
583
+					foreach ($questions as $question) {
584
+						$right_answer = get_post_meta($question->ID, '_question_right_answer', true);
585
+						$right_answers[$quiz_id][$question->ID] = $right_answer;
586 586
 					}
587 587
 				}
588 588
 			}
589 589
 		}
590 590
 
591
-		if( is_array( $right_answers ) ) {
592
-			foreach( $right_answers as $quiz_id => $question ) {
591
+		if (is_array($right_answers)) {
592
+			foreach ($right_answers as $quiz_id => $question) {
593 593
 				$count = 0;
594
-				if( is_array( $question ) ) {
595
-					foreach( $question as $question_id => $answer ) {
594
+				if (is_array($question)) {
595
+					foreach ($question as $question_id => $answer) {
596 596
 						++$count;
597
-						if( isset( $old_user_answers[ $quiz_id ] ) ) {
598
-							$answers_linkup[ $quiz_id ][ $count ] = $question_id;
597
+						if (isset($old_user_answers[$quiz_id])) {
598
+							$answers_linkup[$quiz_id][$count] = $question_id;
599 599
 						}
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 
605
-		if( is_array( $old_user_answers ) ) {
606
-			foreach( $old_user_answers as $quiz_id => $user_answers ) {
607
-				foreach( $user_answers as $user_id => $answers ) {
608
-					foreach( $answers as $answer_id => $user_answer ) {
609
-						$question_id = $answers_linkup[ $quiz_id ][ $answer_id ];
610
-						$new_user_answers[ $question_id ] = $user_answer;
611
-						Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id );
605
+		if (is_array($old_user_answers)) {
606
+			foreach ($old_user_answers as $quiz_id => $user_answers) {
607
+				foreach ($user_answers as $user_id => $answers) {
608
+					foreach ($answers as $answer_id => $user_answer) {
609
+						$question_id = $answers_linkup[$quiz_id][$answer_id];
610
+						$new_user_answers[$question_id] = $user_answer;
611
+						Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id);
612 612
 					}
613
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
614
-					Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
615
-					Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id );
613
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
614
+					Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
615
+					Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id);
616 616
 				}
617 617
 			}
618 618
 		}
619 619
 
620
-		if ( $current_page == $total_pages ) {
620
+		if ($current_page == $total_pages) {
621 621
 			return true;
622 622
 		} else {
623 623
 			return false;
@@ -632,15 +632,15 @@  discard block
 block discarded – undo
632 632
 	 * @return boolean
633 633
 	 */
634 634
 	public function update_question_grade_points() {
635
-		$args = array(	'post_type' 		=> 'question',
635
+		$args = array('post_type' 		=> 'question',
636 636
 						'posts_per_page' 		=> -1,
637 637
 						'post_status'		=> 'publish',
638 638
 						'suppress_filters' 	=> 0
639 639
 						);
640
-		$questions = get_posts( $args );
640
+		$questions = get_posts($args);
641 641
 
642
-		foreach( $questions as $question ) {
643
-			update_post_meta( $question->ID, '_question_grade', '1' );
642
+		foreach ($questions as $question) {
643
+			update_post_meta($question->ID, '_question_grade', '1');
644 644
 		}
645 645
 		return true;
646 646
 	} // End update_question_grade_points
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 * @return boolean
653 653
 	 */
654 654
 	public function convert_essay_paste_questions() {
655
-		$args = array(	'post_type' 		=> 'question',
655
+		$args = array('post_type' 		=> 'question',
656 656
 						'posts_per_page' 		=> -1,
657 657
 						'post_status'		=> 'publish',
658 658
 						'tax_query'			=> array(
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
 						),
665 665
 						'suppress_filters' 	=> 0
666 666
 						);
667
-		$questions = get_posts( $args );
667
+		$questions = get_posts($args);
668 668
 
669
-		foreach( $questions as $question ) {
670
-			wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false );
669
+		foreach ($questions as $question) {
670
+			wp_set_object_terms($question->ID, 'multi-line', 'question-type', false);
671 671
 
672
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
673
-			if( 0 < intval( $quiz_id ) ) {
674
-				add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true );
672
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
673
+			if (0 < intval($quiz_id)) {
674
+				add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true);
675 675
 			}
676 676
 		}
677 677
 		return true;
@@ -683,33 +683,33 @@  discard block
 block discarded – undo
683 683
 	 * @since  1.5.0
684 684
 	 * @return boolean
685 685
 	 */
686
-	public function set_random_question_order( $n = 50, $offset = 0 ) {
686
+	public function set_random_question_order($n = 50, $offset = 0) {
687 687
 
688 688
 		// Get Total Number of Updates to run
689
-		$quiz_count_object = wp_count_posts( 'quiz' );
689
+		$quiz_count_object = wp_count_posts('quiz');
690 690
 		$quiz_count_published = $quiz_count_object->publish;
691 691
 
692 692
 		// Calculate if this is the last page
693
-		if ( 0 == $offset ) {
693
+		if (0 == $offset) {
694 694
 			$current_page = 1;
695 695
 		} else {
696
-			$current_page = intval( $offset / $n );
696
+			$current_page = intval($offset / $n);
697 697
 		} // End If Statement
698
-		$total_pages = intval( $quiz_count_published / $n );
698
+		$total_pages = intval($quiz_count_published / $n);
699 699
 
700
-		$args = array(	'post_type' 		=> 'quiz',
700
+		$args = array('post_type' 		=> 'quiz',
701 701
 						'post_status'		=> 'any',
702 702
 						'posts_per_page' 		=> $n,
703 703
 						'offset'			=> $offset,
704 704
 						'suppress_filters' 	=> 0
705 705
 						);
706
-		$quizzes = get_posts( $args );
706
+		$quizzes = get_posts($args);
707 707
 
708
-		foreach( $quizzes as $quiz ) {
709
-			update_post_meta( $quiz->ID, '_random_question_order', 'yes' );
708
+		foreach ($quizzes as $quiz) {
709
+			update_post_meta($quiz->ID, '_random_question_order', 'yes');
710 710
 		}
711 711
 
712
-		if ( $current_page == $total_pages ) {
712
+		if ($current_page == $total_pages) {
713 713
 			return true;
714 714
 		} else {
715 715
 			return false;
@@ -723,37 +723,37 @@  discard block
 block discarded – undo
723 723
 	 * @since  1.5.0
724 724
 	 * @return boolean
725 725
 	 */
726
-	public function set_default_show_question_count( $n = 50, $offset = 0 ) {
726
+	public function set_default_show_question_count($n = 50, $offset = 0) {
727 727
 
728
-		$args = array(	'post_type' 		=> 'quiz',
728
+		$args = array('post_type' 		=> 'quiz',
729 729
 						'post_status'		=> 'any',
730 730
 						'posts_per_page' 		=> $n,
731 731
 						'offset'			=> $offset,
732 732
 						'meta_key'			=> '_show_questions',
733 733
 						'suppress_filters' 	=> 0
734 734
 						);
735
-		$quizzes = get_posts( $args );
735
+		$quizzes = get_posts($args);
736 736
 
737
-		$total_quizzes = count( $quizzes );
737
+		$total_quizzes = count($quizzes);
738 738
 
739
-		if( 0 == intval( $total_quizzes ) ) {
739
+		if (0 == intval($total_quizzes)) {
740 740
 			return true;
741 741
 		}
742 742
 
743
-		foreach( $quizzes as $quiz ) {
744
-			delete_post_meta( $quiz->ID, '_show_questions' );
743
+		foreach ($quizzes as $quiz) {
744
+			delete_post_meta($quiz->ID, '_show_questions');
745 745
 		}
746 746
 
747
-		$total_pages = intval( $total_quizzes / $n );
747
+		$total_pages = intval($total_quizzes / $n);
748 748
 
749 749
 		// Calculate if this is the last page
750
-		if ( 0 == $offset ) {
750
+		if (0 == $offset) {
751 751
 			$current_page = 1;
752 752
 		} else {
753
-			$current_page = intval( $offset / $n );
753
+			$current_page = intval($offset / $n);
754 754
 		} // End If Statement
755 755
 
756
-		if ( $current_page == $total_pages ) {
756
+		if ($current_page == $total_pages) {
757 757
 			return true;
758 758
 		} else {
759 759
 			return false;
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
 
762 762
 	}
763 763
 
764
-	public function remove_deleted_user_activity( $n = 50, $offset = 0 ) {
764
+	public function remove_deleted_user_activity($n = 50, $offset = 0) {
765 765
 
766 766
 
767 767
 //		remove_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) );
768 768
 
769
-		$all_activity = get_comments( array( 'status' => 'approve' ) );
769
+		$all_activity = get_comments(array('status' => 'approve'));
770 770
 		$activity_count = array();
771
-		foreach( $all_activity as $activity ) {
772
-			if( '' == $activity->comment_type ) continue;
773
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
774
-			if( 0 == $activity->user_id ) continue;
771
+		foreach ($all_activity as $activity) {
772
+			if ('' == $activity->comment_type) continue;
773
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
774
+			if (0 == $activity->user_id) continue;
775 775
 			$activity_count[] = $activity->comment_ID;
776 776
 		}
777 777
 
@@ -781,35 +781,35 @@  discard block
 block discarded – undo
781 781
 			'status' => 'approve'
782 782
 		);
783 783
 
784
-		$activities = get_comments( $args );
784
+		$activities = get_comments($args);
785 785
 
786
-		foreach( $activities as $activity ) {
787
-			if( '' == $activity->comment_type ) continue;
788
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
789
-			if( 0 == $activity->user_id ) continue;
786
+		foreach ($activities as $activity) {
787
+			if ('' == $activity->comment_type) continue;
788
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
789
+			if (0 == $activity->user_id) continue;
790 790
 
791
-			$user_exists = get_userdata( $activity->user_id );
791
+			$user_exists = get_userdata($activity->user_id);
792 792
 
793
-			if( ! $user_exists ) {
794
-				wp_delete_comment( intval( $activity->comment_ID ), true );
793
+			if ( ! $user_exists) {
794
+				wp_delete_comment(intval($activity->comment_ID), true);
795 795
 				wp_cache_flush();
796 796
 			}
797 797
 		}
798 798
 
799
-		$total_activities = count( $activity_count );
799
+		$total_activities = count($activity_count);
800 800
 
801
-		$total_pages = intval( $total_activities / $n );
801
+		$total_pages = intval($total_activities / $n);
802 802
 
803 803
 		// Calculate if this is the last page
804
-		if ( 0 == $offset ) {
804
+		if (0 == $offset) {
805 805
 			$current_page = 1;
806 806
 		} else {
807
-			$current_page = intval( $offset / $n );
807
+			$current_page = intval($offset / $n);
808 808
 		} // End If Statement
809 809
 
810 810
 //		add_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) );
811 811
 
812
-		if ( $current_page >= $total_pages ) {
812
+		if ($current_page >= $total_pages) {
813 813
 			return true;
814 814
 		} else {
815 815
 			return false;
@@ -818,16 +818,16 @@  discard block
 block discarded – undo
818 818
 	}
819 819
 
820 820
 	public function add_teacher_role() {
821
-		add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) );
821
+		add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true));
822 822
 		return true;
823 823
 	}
824 824
 
825 825
 	public function add_sensei_caps() {
826
-		$role = get_role( 'administrator' );
826
+		$role = get_role('administrator');
827 827
 
828
-		if( ! is_null( $role ) ) {
829
-			$role->add_cap( 'manage_sensei' );
830
-			$role->add_cap( 'manage_sensei_grades' );
828
+		if ( ! is_null($role)) {
829
+			$role->add_cap('manage_sensei');
830
+			$role->add_cap('manage_sensei_grades');
831 831
 		}
832 832
 
833 833
 		return true;
@@ -841,16 +841,16 @@  discard block
 block discarded – undo
841 841
 			'suppress_filters' 	=> 0
842 842
 		);
843 843
 
844
-		$questions = get_posts( $args );
844
+		$questions = get_posts($args);
845 845
 
846
-		foreach( $questions as $question ) {
846
+		foreach ($questions as $question) {
847 847
 
848
-			if( ! isset( $question->ID ) ) continue;
848
+			if ( ! isset($question->ID)) continue;
849 849
 
850
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
850
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
851 851
 
852
-			$question_order = get_post_meta( $question->ID, '_quiz_question_order', true );
853
-			update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order );
852
+			$question_order = get_post_meta($question->ID, '_quiz_question_order', true);
853
+			update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order);
854 854
 
855 855
 		}
856 856
 
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
 
860 860
 	public function update_quiz_settings() {
861 861
 
862
-		$settings = get_option( 'woothemes-sensei-settings', array() );
862
+		$settings = get_option('woothemes-sensei-settings', array());
863 863
 
864 864
 		$lesson_completion = false;
865
-		if( isset( $settings['lesson_completion'] ) ) {
865
+		if (isset($settings['lesson_completion'])) {
866 866
 			$lesson_completion = $settings['lesson_completion'];
867 867
 		}
868 868
 
869 869
 		$reset_quiz_allowed = false;
870
-		if( isset( $settings['quiz_reset_allowed'] ) ) {
870
+		if (isset($settings['quiz_reset_allowed'])) {
871 871
 			$reset_quiz_allowed = $settings['quiz_reset_allowed'];
872 872
 		}
873 873
 
@@ -878,20 +878,20 @@  discard block
 block discarded – undo
878 878
 			'suppress_filters' 	=> 0
879 879
 		);
880 880
 
881
-		$quizzes = get_posts( $args );
881
+		$quizzes = get_posts($args);
882 882
 
883
-		foreach( $quizzes as $quiz ) {
883
+		foreach ($quizzes as $quiz) {
884 884
 
885
-			if( ! isset( $quiz->ID ) ) continue;
885
+			if ( ! isset($quiz->ID)) continue;
886 886
 
887
-			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
888
-				update_post_meta( $quiz->ID, '_pass_required', 'on' );
887
+			if (isset($lesson_completion) && 'passed' == $lesson_completion) {
888
+				update_post_meta($quiz->ID, '_pass_required', 'on');
889 889
 			} else {
890
-				update_post_meta( $quiz->ID, '_quiz_passmark', 0 );
890
+				update_post_meta($quiz->ID, '_quiz_passmark', 0);
891 891
 			}
892 892
 
893
-			if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) {
894
-				update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' );
893
+			if (isset($reset_quiz_allowed) && $reset_quiz_allowed) {
894
+				update_post_meta($quiz->ID, '_enable_quiz_reset', 'on');
895 895
 			}
896 896
 		}
897 897
 
@@ -906,22 +906,22 @@  discard block
 block discarded – undo
906 906
 			'suppress_filters' 	=> 0
907 907
 		);
908 908
 
909
-		$lessons = get_posts( $args );
909
+		$lessons = get_posts($args);
910 910
 
911
-		foreach( $lessons as $lesson ) {
911
+		foreach ($lessons as $lesson) {
912 912
 
913
-			if( ! isset( $lesson->ID ) ) continue;
913
+			if ( ! isset($lesson->ID)) continue;
914 914
 
915
-			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
915
+			$course_id = get_post_meta($lesson->ID, '_lesson_course', true);
916 916
 
917
-			if( $course_id ) {
918
-				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
917
+			if ($course_id) {
918
+				update_post_meta($lesson->ID, '_order_'.$course_id, 0);
919 919
 			}
920 920
 
921
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
921
+            $module = Sensei()->modules->get_lesson_module($lesson->ID);
922 922
 
923
-            if( $module ) {
924
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
923
+            if ($module) {
924
+                update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0);
925 925
             }
926 926
 
927 927
 		}
@@ -930,10 +930,10 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
 	public function add_editor_caps() {
933
-		$role = get_role( 'editor' );
933
+		$role = get_role('editor');
934 934
 
935
-		if( ! is_null( $role ) ) {
936
-			$role->add_cap( 'manage_sensei_grades' );
935
+		if ( ! is_null($role)) {
936
+			$role->add_cap('manage_sensei_grades');
937 937
 		}
938 938
 
939 939
 		return true;
@@ -952,26 +952,26 @@  discard block
 block discarded – undo
952 952
 					WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%'
953 953
 						AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id
954 954
 						AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'";
955
-		$wpdb->query( $sql );
955
+		$wpdb->query($sql);
956 956
 
957 957
 		return true;
958 958
 	}
959 959
 
960
-	public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) {
961
-		$count_object = wp_count_posts( 'quiz' );
960
+	public function update_quiz_lesson_relationship($n = 50, $offset = 0) {
961
+		$count_object = wp_count_posts('quiz');
962 962
 
963 963
 		$count_published = 0;
964
-		foreach ( $count_object AS $status => $count ) {
964
+		foreach ($count_object AS $status => $count) {
965 965
 			$count_published += $count;
966 966
 		}
967 967
 
968 968
 		// Calculate if this is the last page
969
-		if ( 0 == $offset ) {
969
+		if (0 == $offset) {
970 970
 			$current_page = 1;
971 971
 		} else {
972
-			$current_page = intval( $offset / $n );
972
+			$current_page = intval($offset / $n);
973 973
 		}
974
-		$total_pages = ceil( $count_published / $n );
974
+		$total_pages = ceil($count_published / $n);
975 975
 
976 976
 		$args = array(
977 977
 			'post_type' => 'quiz',
@@ -980,52 +980,52 @@  discard block
 block discarded – undo
980 980
 			'post_status' => 'any'
981 981
 		);
982 982
 
983
-		$quizzes = get_posts( $args );
983
+		$quizzes = get_posts($args);
984 984
 
985
-		foreach( $quizzes as $quiz ) {
985
+		foreach ($quizzes as $quiz) {
986 986
 
987
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
987
+			if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue;
988 988
 
989
-			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
989
+			$lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true);
990 990
 
991
-			if( empty( $lesson_id ) ) continue;
991
+			if (empty($lesson_id)) continue;
992 992
 
993 993
 			$data = array(
994 994
 				'ID' => $quiz->ID,
995 995
 				'post_parent' => $lesson_id,
996 996
 			);
997
-			wp_update_post( $data );
997
+			wp_update_post($data);
998 998
 
999
-			update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID );
999
+			update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID);
1000 1000
 		}
1001 1001
 
1002
-		if ( $current_page == $total_pages || 0 == $total_pages ) {
1002
+		if ($current_page == $total_pages || 0 == $total_pages) {
1003 1003
 			return true;
1004 1004
 		} else {
1005 1005
 			return false;
1006 1006
 		}
1007 1007
 	}
1008 1008
 
1009
-	function status_changes_fix_lessons( $n = 50, $offset = 0 ) {
1009
+	function status_changes_fix_lessons($n = 50, $offset = 0) {
1010 1010
 		global $wpdb;
1011 1011
 
1012
-		$count_object = wp_count_posts( 'lesson' );
1012
+		$count_object = wp_count_posts('lesson');
1013 1013
 		$count_published = 0;
1014
-		foreach ( $count_object AS $status => $count ) {
1014
+		foreach ($count_object AS $status => $count) {
1015 1015
 			$count_published += $count;
1016 1016
 		}
1017 1017
 
1018
-		if ( 0 == $count_published ) {
1018
+		if (0 == $count_published) {
1019 1019
 			return true;
1020 1020
 		}
1021 1021
 
1022 1022
 		// Calculate if this is the last page
1023
-		if ( 0 == $offset ) {
1023
+		if (0 == $offset) {
1024 1024
 			$current_page = 1;
1025 1025
 		} else {
1026
-			$current_page = intval( $offset / $n );
1026
+			$current_page = intval($offset / $n);
1027 1027
 		}
1028
-		$total_pages = ceil( $count_published / $n );
1028
+		$total_pages = ceil($count_published / $n);
1029 1029
 
1030 1030
 		// Get all Lessons with (and without) Quizzes...
1031 1031
 		$args = array(
@@ -1035,26 +1035,26 @@  discard block
 block discarded – undo
1035 1035
 			'offset' => $offset,
1036 1036
 			'fields' => 'ids'
1037 1037
 		);
1038
-		$lesson_ids = get_posts( $args );
1038
+		$lesson_ids = get_posts($args);
1039 1039
 
1040 1040
 		// ...get all Quiz IDs for the above Lessons
1041
-		$id_list = join( ',', $lesson_ids );
1042
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1041
+		$id_list = join(',', $lesson_ids);
1042
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1043 1043
 		$lesson_quiz_ids = array();
1044
-		if ( !empty($meta_list) ) {
1045
-			foreach ( $meta_list as $metarow ) {
1044
+		if ( ! empty($meta_list)) {
1045
+			foreach ($meta_list as $metarow) {
1046 1046
 				$lesson_id = $metarow['meta_value'];
1047 1047
 				$quiz_id = $metarow['post_id'];
1048
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1048
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1049 1049
 			}
1050 1050
 		}
1051 1051
 
1052 1052
 		// ...check all Quiz IDs for questions
1053
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1054
-		$meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A );
1053
+		$id_list = join(',', array_values($lesson_quiz_ids));
1054
+		$meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A);
1055 1055
 		$lesson_quiz_ids_with_questions = array();
1056
-		if ( !empty($meta_list) ) {
1057
-			foreach ( $meta_list as $metarow ) {
1056
+		if ( ! empty($meta_list)) {
1057
+			foreach ($meta_list as $metarow) {
1058 1058
 				$quiz_id = $metarow['meta_value'];
1059 1059
 				$lesson_quiz_ids_with_questions[] = $quiz_id;
1060 1060
 			}
@@ -1062,49 +1062,49 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 		// For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons
1064 1064
 		// if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons
1065
-		$d_count = $a_count =0;
1066
-		foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) {
1067
-			if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1065
+		$d_count = $a_count = 0;
1066
+		foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) {
1067
+			if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1068 1068
 
1069 1069
 				// Quiz has no questions, drop the corresponding data
1070
-				delete_post_meta( $quiz_id, '_pass_required' );
1071
-				delete_post_meta( $quiz_id, '_quiz_passmark' );
1072
-				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1070
+				delete_post_meta($quiz_id, '_pass_required');
1071
+				delete_post_meta($quiz_id, '_quiz_passmark');
1072
+				delete_post_meta($lesson_id, '_quiz_has_questions');
1073 1073
 				$d_count++;
1074 1074
 			}
1075
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1075
+			else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1076 1076
 
1077 1077
 				// Quiz has no questions, drop the corresponding data
1078
-				update_post_meta( $lesson_id, '_quiz_has_questions', true );
1078
+				update_post_meta($lesson_id, '_quiz_has_questions', true);
1079 1079
 				$a_count++;
1080 1080
 			}
1081 1081
 		}
1082 1082
 
1083
-		if ( $current_page == $total_pages ) {
1083
+		if ($current_page == $total_pages) {
1084 1084
 			return true;
1085 1085
 		} else {
1086 1086
 			return false;
1087 1087
 		}
1088 1088
 	}
1089 1089
 
1090
-	function status_changes_convert_lessons( $n = 50, $offset = 0 ) {
1090
+	function status_changes_convert_lessons($n = 50, $offset = 0) {
1091 1091
 		global $wpdb;
1092 1092
 
1093
-		wp_defer_comment_counting( true );
1093
+		wp_defer_comment_counting(true);
1094 1094
 
1095
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1095
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1096 1096
 
1097
-		if ( 0 == $user_count_result ) {
1097
+		if (0 == $user_count_result) {
1098 1098
 			return true;
1099 1099
 		}
1100 1100
 
1101
-		if ( 0 == $offset ) {
1101
+		if (0 == $offset) {
1102 1102
 			$current_page = 1;
1103 1103
 		} else {
1104
-			$current_page = intval( $offset / $n );
1104
+			$current_page = intval($offset / $n);
1105 1105
 		}
1106 1106
 
1107
-		$total_pages = ceil( $user_count_result / $n );
1107
+		$total_pages = ceil($user_count_result / $n);
1108 1108
 
1109 1109
 		// Get all Lessons with Quizzes...
1110 1110
 		$args = array(
@@ -1119,34 +1119,34 @@  discard block
 block discarded – undo
1119 1119
 			),
1120 1120
 			'fields' => 'ids'
1121 1121
 		);
1122
-		$lesson_ids_with_quizzes = get_posts( $args );
1122
+		$lesson_ids_with_quizzes = get_posts($args);
1123 1123
 		// ...get all Quiz IDs for the above Lessons
1124
-		$id_list = join( ',', $lesson_ids_with_quizzes );
1125
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1124
+		$id_list = join(',', $lesson_ids_with_quizzes);
1125
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1126 1126
 		$lesson_quiz_ids = array();
1127
-		if ( !empty($meta_list) ) {
1128
-			foreach ( $meta_list as $metarow ) {
1127
+		if ( ! empty($meta_list)) {
1128
+			foreach ($meta_list as $metarow) {
1129 1129
 				$lesson_id = $metarow['meta_value'];
1130 1130
 				$quiz_id = $metarow['post_id'];
1131
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1131
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1132 1132
 			}
1133 1133
 		}
1134 1134
 
1135 1135
 		// ...get all Pass Required & Passmarks for the above Lesson/Quizzes
1136
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1137
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A );
1136
+		$id_list = join(',', array_values($lesson_quiz_ids));
1137
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A);
1138 1138
 		$quizzes_pass_required = $quizzes_passmarks = array();
1139
-		if ( !empty($meta_list) ) {
1140
-			foreach ( $meta_list as $metarow ) {
1141
-				if ( !empty($metarow['meta_value']) ) {
1139
+		if ( ! empty($meta_list)) {
1140
+			foreach ($meta_list as $metarow) {
1141
+				if ( ! empty($metarow['meta_value'])) {
1142 1142
 					$quiz_id = $metarow['post_id'];
1143 1143
 					$key = $metarow['meta_key'];
1144 1144
 					$value = $metarow['meta_value'];
1145
-					if ( '_pass_required' == $key ) {
1146
-						$quizzes_pass_required[ $quiz_id ] = $value;
1145
+					if ('_pass_required' == $key) {
1146
+						$quizzes_pass_required[$quiz_id] = $value;
1147 1147
 					}
1148
-					if ( '_quiz_passmark' == $key ) {
1149
-						$quizzes_passmarks[ $quiz_id ] = $value;
1148
+					if ('_quiz_passmark' == $key) {
1149
+						$quizzes_passmarks[$quiz_id] = $value;
1150 1150
 					}
1151 1151
 				}
1152 1152
 			}
@@ -1160,41 +1160,41 @@  discard block
 block discarded – undo
1160 1160
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' ";
1161 1161
 
1162 1162
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1163
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1163
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1164 1164
 
1165
-		foreach ( $user_ids AS $user_id ) {
1165
+		foreach ($user_ids AS $user_id) {
1166 1166
 
1167 1167
 			$lesson_ends = $lesson_grades = $lesson_answers = array();
1168 1168
 
1169 1169
 			// Pre-process the lesson ends
1170
-			$_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A );
1171
-			foreach ( $_lesson_ends as $lesson_end ) {
1170
+			$_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A);
1171
+			foreach ($_lesson_ends as $lesson_end) {
1172 1172
 				// This will overwrite existing entries with the newer ones
1173
-				$lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date'];
1173
+				$lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date'];
1174 1174
 			}
1175
-			unset( $_lesson_ends );
1175
+			unset($_lesson_ends);
1176 1176
 
1177 1177
 			// Pre-process the lesson grades
1178
-			$_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A );
1179
-			foreach ( $_lesson_grades as $lesson_grade ) {
1178
+			$_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A);
1179
+			foreach ($_lesson_grades as $lesson_grade) {
1180 1180
 				// This will overwrite existing entries with the newer ones (assuming the grade is higher)
1181
-				if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) {
1182
-					$lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content'];
1181
+				if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) {
1182
+					$lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content'];
1183 1183
 				}
1184 1184
 			}
1185
-			unset( $_lesson_grades );
1185
+			unset($_lesson_grades);
1186 1186
 
1187 1187
 			// Pre-process the lesson answers
1188
-			$_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A );
1189
-			foreach ( $_lesson_answers as $lesson_answer ) {
1188
+			$_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A);
1189
+			foreach ($_lesson_answers as $lesson_answer) {
1190 1190
 				// This will overwrite existing entries with the newer ones
1191
-				$lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content'];
1191
+				$lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content'];
1192 1192
 			}
1193
-			unset( $_lesson_answers );
1193
+			unset($_lesson_answers);
1194 1194
 
1195 1195
 			// Grab all the lesson starts for the user
1196
-			$lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1197
-			foreach ( $lesson_starts as $lesson_log ) {
1196
+			$lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1197
+			foreach ($lesson_starts as $lesson_log) {
1198 1198
 
1199 1199
 				$lesson_id = $lesson_log['comment_post_ID'];
1200 1200
 
@@ -1207,23 +1207,23 @@  discard block
 block discarded – undo
1207 1207
 					'start' => $status_date,
1208 1208
 				);
1209 1209
 				// Check if there is a lesson end
1210
-				if ( !empty($lesson_ends[$lesson_id]) ) {
1210
+				if ( ! empty($lesson_ends[$lesson_id])) {
1211 1211
 					$status_date = $lesson_ends[$lesson_id];
1212 1212
 					// Check lesson has quiz
1213
-					if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) {
1213
+					if ( ! empty($lesson_quiz_ids[$lesson_id])) {
1214 1214
 						// Check for the quiz answers
1215
-						if ( !empty($lesson_answers[$quiz_id]) ) {
1215
+						if ( ! empty($lesson_answers[$quiz_id])) {
1216 1216
 							$meta_data['questions_asked'] = $lesson_answers[$quiz_id];
1217 1217
 						}
1218 1218
 						// Check if there is a quiz grade
1219 1219
 						$quiz_id = $lesson_quiz_ids[$lesson_id];
1220
-						if ( !empty($lesson_grades[$quiz_id]) ) {
1220
+						if ( ! empty($lesson_grades[$quiz_id])) {
1221 1221
 							$meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id];
1222 1222
 							// Check if the user has to get the passmark and has or not
1223
-							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1223
+							if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) {
1224 1224
 								$status = 'passed';
1225 1225
 							}
1226
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1226
+							elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) {
1227 1227
 								$status = 'failed';
1228 1228
 							}
1229 1229
 							else {
@@ -1251,26 +1251,26 @@  discard block
 block discarded – undo
1251 1251
 						'comment_author' => '',
1252 1252
 					);
1253 1253
 				// Check it doesn't already exist
1254
-				$sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id );
1255
-				$comment_ID = $wpdb->get_var( $sql );
1256
-				if ( !$comment_ID ) {
1254
+				$sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id);
1255
+				$comment_ID = $wpdb->get_var($sql);
1256
+				if ( ! $comment_ID) {
1257 1257
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1258 1258
 					$wpdb->insert($wpdb->comments, $data);
1259 1259
 					$comment_ID = (int) $wpdb->insert_id;
1260 1260
 
1261
-					if ( $comment_ID && !empty($meta_data) ) {
1262
-						foreach ( $meta_data as $key => $value ) {
1261
+					if ($comment_ID && ! empty($meta_data)) {
1262
+						foreach ($meta_data as $key => $value) {
1263 1263
 							// Bypassing WP add_comment_meta(() so no actions/filters are run
1264
-							if ( $wpdb->get_var( $wpdb->prepare(
1264
+							if ($wpdb->get_var($wpdb->prepare(
1265 1265
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1266
-									$comment_ID, $key ) ) ) {
1266
+									$comment_ID, $key ))) {
1267 1267
 									continue; // Found the meta data already
1268 1268
 							}
1269
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1269
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1270 1270
 								'comment_id' => $comment_ID,
1271 1271
 								'meta_key' => $key,
1272 1272
 								'meta_value' => $value
1273
-							) );
1273
+							));
1274 1274
 						}
1275 1275
 					}
1276 1276
 				}
@@ -1278,40 +1278,40 @@  discard block
 block discarded – undo
1278 1278
 		}
1279 1279
 		$wpdb->flush();
1280 1280
 
1281
-		if ( $current_page == $total_pages ) {
1281
+		if ($current_page == $total_pages) {
1282 1282
 			return true;
1283 1283
 		} else {
1284 1284
 			return false;
1285 1285
 		}
1286 1286
 	}
1287 1287
 
1288
-	function status_changes_convert_courses( $n = 50, $offset = 0 ) {
1288
+	function status_changes_convert_courses($n = 50, $offset = 0) {
1289 1289
 		global $wpdb;
1290 1290
 
1291
-		wp_defer_comment_counting( true );
1291
+		wp_defer_comment_counting(true);
1292 1292
 
1293
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1293
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1294 1294
 
1295
-		if ( 0 == $user_count_result ) {
1295
+		if (0 == $user_count_result) {
1296 1296
 			return true;
1297 1297
 		}
1298 1298
 
1299
-		if ( 0 == $offset ) {
1299
+		if (0 == $offset) {
1300 1300
 			$current_page = 1;
1301 1301
 		} else {
1302
-			$current_page = intval( $offset / $n );
1302
+			$current_page = intval($offset / $n);
1303 1303
 		}
1304 1304
 
1305
-		$total_pages = ceil( $user_count_result / $n );
1305
+		$total_pages = ceil($user_count_result / $n);
1306 1306
 
1307 1307
 		// Get all Lesson => Course relationships
1308
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A );
1308
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A);
1309 1309
 		$course_lesson_ids = array();
1310
-		if ( !empty($meta_list) ) {
1311
-			foreach ( $meta_list as $metarow ) {
1310
+		if ( ! empty($meta_list)) {
1311
+			foreach ($meta_list as $metarow) {
1312 1312
 				$lesson_id = $metarow['post_id'];
1313 1313
 				$course_id = $metarow['meta_value'];
1314
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1314
+				$course_lesson_ids[$course_id][] = $lesson_id;
1315 1315
 			}
1316 1316
 		}
1317 1317
 
@@ -1321,13 +1321,13 @@  discard block
 block discarded – undo
1321 1321
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' ";
1322 1322
 
1323 1323
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1324
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1324
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1325 1325
 
1326
-		foreach ( $user_ids AS $user_id ) {
1326
+		foreach ($user_ids AS $user_id) {
1327 1327
 
1328 1328
 			// Grab all the course starts for the user
1329
-			$course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1330
-			foreach ( $course_starts as $course_log ) {
1329
+			$course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1330
+			foreach ($course_starts as $course_log) {
1331 1331
 
1332 1332
 				$course_id = $course_log['comment_post_ID'];
1333 1333
 
@@ -1342,23 +1342,23 @@  discard block
 block discarded – undo
1342 1342
 					'percent' => 0,
1343 1343
 				);
1344 1344
 				// Check if the course has lessons
1345
-				if ( !empty( $course_lesson_ids[$course_id] ) ) {
1345
+				if ( ! empty($course_lesson_ids[$course_id])) {
1346 1346
 
1347 1347
 					$lessons_completed = 0;
1348
-					$total_lessons = count( $course_lesson_ids[ $course_id ] );
1348
+					$total_lessons = count($course_lesson_ids[$course_id]);
1349 1349
 
1350 1350
 					// Don't use prepare as we need to provide the id join
1351
-					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) );
1351
+					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id]));
1352 1352
 					// Get all lesson statuses for this Courses' lessons
1353
-					$lesson_statuses = $wpdb->get_results( $sql, ARRAY_A );
1353
+					$lesson_statuses = $wpdb->get_results($sql, ARRAY_A);
1354 1354
 					// Not enough lesson statuses, thus cannot be complete
1355
-					if ( $total_lessons > count($lesson_statuses) ) {
1355
+					if ($total_lessons > count($lesson_statuses)) {
1356 1356
 						$status = 'in-progress';
1357 1357
 					}
1358 1358
 					// Count each lesson to work out the overall percentage
1359
-					foreach ( $lesson_statuses as $lesson_status ) {
1359
+					foreach ($lesson_statuses as $lesson_status) {
1360 1360
 						$status_date = $lesson_status['comment_date'];
1361
-						switch ( $lesson_status['status'] ) {
1361
+						switch ($lesson_status['status']) {
1362 1362
 							case 'complete': // Lesson has no quiz/questions
1363 1363
 							case 'graded': // Lesson has quiz, but it's not important what the grade was
1364 1364
 							case 'passed':
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 						}
1374 1374
 					}
1375 1375
 					$meta_data['complete'] = $lessons_completed;
1376
-					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1376
+					$meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1377 1377
 				}
1378 1378
 				else {
1379 1379
 					// Course has no lessons, therefore cannot be 'complete'
@@ -1390,26 +1390,26 @@  discard block
 block discarded – undo
1390 1390
 						'comment_author' => '',
1391 1391
 					);
1392 1392
 				// Check it doesn't already exist
1393
-				$sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id );
1394
-				$comment_ID = $wpdb->get_var( $sql );
1395
-				if ( !$comment_ID ) {
1393
+				$sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id);
1394
+				$comment_ID = $wpdb->get_var($sql);
1395
+				if ( ! $comment_ID) {
1396 1396
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1397 1397
 					$wpdb->insert($wpdb->comments, $data);
1398 1398
 					$comment_ID = (int) $wpdb->insert_id;
1399 1399
 
1400
-					if ( $comment_ID && !empty($meta_data) ) {
1401
-						foreach ( $meta_data as $key => $value ) {
1400
+					if ($comment_ID && ! empty($meta_data)) {
1401
+						foreach ($meta_data as $key => $value) {
1402 1402
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1403
-							if ( $wpdb->get_var( $wpdb->prepare(
1403
+							if ($wpdb->get_var($wpdb->prepare(
1404 1404
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1405
-									$comment_ID, $key ) ) ) {
1405
+									$comment_ID, $key ))) {
1406 1406
 									continue; // Found the meta data already
1407 1407
 							}
1408
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1408
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1409 1409
 								'comment_id' => $comment_ID,
1410 1410
 								'meta_key' => $key,
1411 1411
 								'meta_value' => $value
1412
-							) );
1412
+							));
1413 1413
 						}
1414 1414
 					}
1415 1415
 				}
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 		}
1418 1418
 		$wpdb->flush();
1419 1419
 
1420
-		if ( $current_page == $total_pages ) {
1420
+		if ($current_page == $total_pages) {
1421 1421
 			return true;
1422 1422
 		} else {
1423 1423
 			return false;
@@ -1433,70 +1433,70 @@  discard block
 block discarded – undo
1433 1433
 	 * @param type $offset
1434 1434
 	 * @return boolean
1435 1435
 	 */
1436
-	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
1436
+	function status_changes_repair_course_statuses($n = 50, $offset = 0) {
1437 1437
 		global $wpdb;
1438 1438
 
1439
-		$count_object = wp_count_posts( 'lesson' );
1439
+		$count_object = wp_count_posts('lesson');
1440 1440
 		$count_published = $count_object->publish;
1441 1441
 
1442
-		if ( 0 == $count_published ) {
1442
+		if (0 == $count_published) {
1443 1443
 			return true;
1444 1444
 		}
1445 1445
 
1446 1446
 		// Calculate if this is the last page
1447
-		if ( 0 == $offset ) {
1447
+		if (0 == $offset) {
1448 1448
 			$current_page = 1;
1449 1449
 		} else {
1450
-			$current_page = intval( $offset / $n );
1450
+			$current_page = intval($offset / $n);
1451 1451
 		}
1452
-		$total_pages = ceil( $count_published / $n );
1452
+		$total_pages = ceil($count_published / $n);
1453 1453
 
1454 1454
 		$course_lesson_ids = $lesson_user_statuses = array();
1455 1455
 
1456 1456
 		// Get all Lesson => Course relationships
1457
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A );
1458
-		if ( !empty($meta_list) ) {
1459
-			foreach ( $meta_list as $metarow ) {
1457
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A);
1458
+		if ( ! empty($meta_list)) {
1459
+			foreach ($meta_list as $metarow) {
1460 1460
 				$lesson_id = $metarow['post_id'];
1461 1461
 				$course_id = $metarow['meta_value'];
1462
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1462
+				$course_lesson_ids[$course_id][] = $lesson_id;
1463 1463
 			}
1464 1464
 		}
1465 1465
 
1466 1466
 		// Get all Lesson => Course relationships
1467
-		$status_list = $wpdb->get_results( "SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A );
1468
-		if ( !empty($status_list) ) {
1469
-			foreach ( $status_list as $status ) {
1470
-				$lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved'];
1467
+		$status_list = $wpdb->get_results("SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A);
1468
+		if ( ! empty($status_list)) {
1469
+			foreach ($status_list as $status) {
1470
+				$lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved'];
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474
-		$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1474
+		$course_completion = Sensei()->settings->settings['course_completion'];
1475 1475
 
1476 1476
 		$per_page = 40;
1477 1477
 		$comment_id_offset = $count = 0;
1478 1478
 
1479 1479
 		$course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page";
1480 1480
 		// $per_page users at a time
1481
-		while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) {
1481
+		while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) {
1482 1482
 
1483
-			foreach ( $course_statuses AS $course_status ) {
1483
+			foreach ($course_statuses AS $course_status) {
1484 1484
 				$user_id = $course_status->user_id;
1485 1485
 				$course_id = $course_status->comment_post_ID;
1486
-				$total_lessons = count( $course_lesson_ids[ $course_id ] );
1487
-				if ( $total_lessons <= 0 ) {
1486
+				$total_lessons = count($course_lesson_ids[$course_id]);
1487
+				if ($total_lessons <= 0) {
1488 1488
 					$total_lessons = 1; // Fix division of zero error, some courses have no lessons
1489 1489
 				}
1490 1490
 				$lessons_completed = 0;
1491 1491
 				$status = 'in-progress';
1492 1492
 
1493 1493
 				// Some Courses have no lessons... (can they ever be complete?)
1494
-				if ( !empty($course_lesson_ids[ $course_id ]) ) {
1495
-					foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) {
1496
-						$lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ];
1494
+				if ( ! empty($course_lesson_ids[$course_id])) {
1495
+					foreach ($course_lesson_ids[$course_id] AS $lesson_id) {
1496
+						$lesson_status = $lesson_user_statuses[$lesson_id][$user_id];
1497 1497
 						// If lessons are complete without needing quizzes to be passed
1498
-						if ( 'passed' != $course_completion ) {
1499
-							switch ( $lesson_status ) {
1498
+						if ('passed' != $course_completion) {
1499
+							switch ($lesson_status) {
1500 1500
 								// A user cannot 'complete' a course if a lesson...
1501 1501
 								case 'in-progress': // ...is still in progress
1502 1502
 								case 'ungraded': // ...hasn't yet been graded
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 							}
1509 1509
 						}
1510 1510
 						else {
1511
-							switch ( $lesson_status ) {
1511
+							switch ($lesson_status) {
1512 1512
 								case 'complete': // Lesson has no quiz/questions
1513 1513
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
1514 1514
 								case 'passed': // Lesson has quiz and the user passed
@@ -1523,79 +1523,79 @@  discard block
 block discarded – undo
1523 1523
 						}
1524 1524
 					} // Each lesson
1525 1525
 				} // Check for lessons
1526
-				if ( $lessons_completed == $total_lessons ) {
1526
+				if ($lessons_completed == $total_lessons) {
1527 1527
 					$status = 'complete';
1528 1528
 				}
1529 1529
 				// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1530 1530
 				$metadata = array(
1531 1531
 					'complete' => $lessons_completed,
1532
-					'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ),
1532
+					'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)),
1533 1533
 				);
1534
-				Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata );
1534
+				Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata);
1535 1535
 				$count++;
1536 1536
 
1537 1537
 			} // per course status
1538 1538
 			$comment_id_offset = $course_status->comment_ID;
1539 1539
 		} // all course statuses
1540 1540
 
1541
-		if ( $current_page == $total_pages ) {
1541
+		if ($current_page == $total_pages) {
1542 1542
 			return true;
1543 1543
 		} else {
1544 1544
 			return false;
1545 1545
 		}
1546 1546
 	}
1547 1547
 
1548
-	function status_changes_convert_questions( $n = 50, $offset = 0 ) {
1548
+	function status_changes_convert_questions($n = 50, $offset = 0) {
1549 1549
 		global $wpdb;
1550 1550
 
1551
-		wp_defer_comment_counting( true );
1551
+		wp_defer_comment_counting(true);
1552 1552
 
1553
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1553
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1554 1554
 
1555
-		if ( 0 == $user_count_result ) {
1555
+		if (0 == $user_count_result) {
1556 1556
 			return true;
1557 1557
 		}
1558 1558
 
1559 1559
 		// Calculate if this is the last page
1560
-		if ( 0 == $offset ) {
1560
+		if (0 == $offset) {
1561 1561
 			$current_page = 1;
1562 1562
 		} else {
1563
-			$current_page = intval( $offset / $n );
1563
+			$current_page = intval($offset / $n);
1564 1564
 		}
1565 1565
 
1566
-		$total_pages = ceil( $user_count_result / $n );
1566
+		$total_pages = ceil($user_count_result / $n);
1567 1567
 
1568 1568
 		$users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d";
1569 1569
 		$answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID ";
1570 1570
 		$grades_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID ";
1571 1571
 		$notes_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID ";
1572 1572
 
1573
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1573
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1574 1574
 
1575
-		foreach ( $user_ids AS $user_id ) {
1575
+		foreach ($user_ids AS $user_id) {
1576 1576
 
1577 1577
 			$answer_grades = $answer_notes = array();
1578 1578
 
1579 1579
 			// Pre-process the answer grades
1580
-			$_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A );
1581
-			foreach ( $_answer_grades as $answer_grade ) {
1580
+			$_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A);
1581
+			foreach ($_answer_grades as $answer_grade) {
1582 1582
 				// This will overwrite existing entries with the newer ones
1583
-				$answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content'];
1583
+				$answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content'];
1584 1584
 			}
1585
-			unset( $_answer_grades );
1585
+			unset($_answer_grades);
1586 1586
 
1587 1587
 			// Pre-process the answer notes
1588
-			$_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A );
1589
-			foreach ( $_answer_notes as $answer_note ) {
1588
+			$_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A);
1589
+			foreach ($_answer_notes as $answer_note) {
1590 1590
 				// This will overwrite existing entries with the newer ones
1591
-				$answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content'];
1591
+				$answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content'];
1592 1592
 			}
1593
-			unset( $_answer_notes );
1593
+			unset($_answer_notes);
1594 1594
 
1595 1595
 			// Grab all the questions for the user
1596 1596
 			$sql = $wpdb->prepare($answers_sql, $user_id);
1597
-			$answers = $wpdb->get_results( $sql, ARRAY_A );
1598
-			foreach ( $answers as $answer ) {
1597
+			$answers = $wpdb->get_results($sql, ARRAY_A);
1598
+			foreach ($answers as $answer) {
1599 1599
 
1600 1600
 				// Excape data
1601 1601
 				$answer = wp_slash($answer);
@@ -1605,12 +1605,12 @@  discard block
 block discarded – undo
1605 1605
 				$meta_data = array();
1606 1606
 
1607 1607
 				// Check if the question has been graded, add as meta
1608
-				if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) {
1609
-					$meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ];
1608
+				if ( ! empty($answer_grades[$answer['comment_post_ID']])) {
1609
+					$meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']];
1610 1610
 				}
1611 1611
 				// Check if there is an answer note, add as meta
1612
-				if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) {
1613
-					$meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ];
1612
+				if ( ! empty($answer_notes[$answer['comment_post_ID']])) {
1613
+					$meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']];
1614 1614
 				}
1615 1615
 
1616 1616
 				// Wipe the unnessary data from the main comment
@@ -1623,21 +1623,21 @@  discard block
 block discarded – undo
1623 1623
 					);
1624 1624
 				$data = array_merge($answer, $data);
1625 1625
 
1626
-				$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
1627
-				if ( $rval ) {
1628
-					if ( !empty($meta_data) ) {
1629
-						foreach ( $meta_data as $key => $value ) {
1626
+				$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
1627
+				if ($rval) {
1628
+					if ( ! empty($meta_data)) {
1629
+						foreach ($meta_data as $key => $value) {
1630 1630
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1631
-							if ( $wpdb->get_var( $wpdb->prepare(
1631
+							if ($wpdb->get_var($wpdb->prepare(
1632 1632
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1633
-									$comment_ID, $key ) ) ) {
1633
+									$comment_ID, $key ))) {
1634 1634
 									continue; // Found the meta data already
1635 1635
 							}
1636
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1636
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1637 1637
 								'comment_id' => $comment_ID,
1638 1638
 								'meta_key' => $key,
1639 1639
 								'meta_value' => $value
1640
-							) );
1640
+							));
1641 1641
 						}
1642 1642
 					}
1643 1643
 				}
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 		}
1646 1646
 		$wpdb->flush();
1647 1647
 
1648
-		if ( $current_page == $total_pages ) {
1648
+		if ($current_page == $total_pages) {
1649 1649
 			return true;
1650 1650
 		} else {
1651 1651
 			return false;
@@ -1662,10 +1662,10 @@  discard block
 block discarded – undo
1662 1662
 		global $wpdb;
1663 1663
 
1664 1664
 		// Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts
1665
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " );
1665
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' ");
1666 1666
 
1667 1667
 		// Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required
1668
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') " );
1668
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') ");
1669 1669
 
1670 1670
 		return true;
1671 1671
 	}
@@ -1678,50 +1678,50 @@  discard block
 block discarded – undo
1678 1678
 	 * @param type $offset
1679 1679
 	 * @return boolean
1680 1680
 	 */
1681
-	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
1681
+	public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) {
1682 1682
 		global $wpdb;
1683 1683
 
1684
-		$item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " );
1684
+		$item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') ");
1685 1685
 
1686
-		if ( 0 == $item_count_result ) {
1686
+		if (0 == $item_count_result) {
1687 1687
 			return true;
1688 1688
 		}
1689 1689
 
1690 1690
 		// Calculate if this is the last page
1691
-		if ( 0 == $offset ) {
1691
+		if (0 == $offset) {
1692 1692
 			$current_page = 1;
1693 1693
 		} else {
1694
-			$current_page = intval( $offset / $n );
1694
+			$current_page = intval($offset / $n);
1695 1695
 		}
1696 1696
 
1697
-		$total_pages = ceil( $item_count_result / $n );
1697
+		$total_pages = ceil($item_count_result / $n);
1698 1698
 
1699 1699
 		// Recalculate all counts
1700
-		$items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) );
1701
-		foreach ( (array) $items as $post ) {
1700
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset));
1701
+		foreach ((array) $items as $post) {
1702 1702
 			// Code copied from wp_update_comment_count_now()
1703
-			$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) );
1704
-			$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) );
1703
+			$new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID));
1704
+			$wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID));
1705 1705
 
1706
-			clean_post_cache( $post->ID );
1706
+			clean_post_cache($post->ID);
1707 1707
 		}
1708 1708
 
1709
-		if ( $current_page == $total_pages ) {
1709
+		if ($current_page == $total_pages) {
1710 1710
 			return true;
1711 1711
 		} else {
1712 1712
 			return false;
1713 1713
 		}
1714 1714
 	}
1715 1715
 
1716
-	public function remove_legacy_comments () {
1716
+	public function remove_legacy_comments() {
1717 1717
 		global $wpdb;
1718 1718
 
1719
-		$result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) );
1719
+		$result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy'));
1720 1720
 
1721 1721
 		return true;
1722 1722
 	}
1723 1723
 
1724
-	public function index_comment_status_field () {
1724
+	public function index_comment_status_field() {
1725 1725
 		global $wpdb;
1726 1726
 
1727 1727
 		$wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )");
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
      * @since 1.8.0
1741 1741
      * @return bool;
1742 1742
      */
1743
-    public  function enhance_teacher_role ( ) {
1743
+    public  function enhance_teacher_role( ) {
1744 1744
 
1745 1745
         require_once('class-sensei-teacher.php');
1746 1746
         $teacher = new Sensei_Teacher();
Please login to merge, or discard this patch.
includes/class-sensei-settings.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /*
5 5
  * Sensei Settings Class
@@ -20,18 +20,18 @@  discard block
 block discarded – undo
20 20
 	 * @since 1.0.0
21 21
 	 * @return void
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 	    parent::__construct(); // Required in extended classes.
25 25
 
26 26
         $this->token = 'woothemes-sensei-settings';
27
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
27
+        add_action('init', array(__CLASS__, 'flush_rewrite_rules'));
28 28
 
29 29
         // Setup Admin Settings data
30
-        if ( is_admin() ) {
30
+        if (is_admin()) {
31 31
 
32 32
             $this->has_tabs 	= true;
33
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
34
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
33
+            $this->name = __('Sensei Settings', 'woothemes-sensei');
34
+            $this->menu_label = __('Settings', 'woothemes-sensei');
35 35
             $this->page_slug	= 'woothemes-sensei-settings';
36 36
 
37 37
         } // End If Statement
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
      * @param string $setting_name
49 49
      * @return mixed
50 50
      */
51
-    public function get( $setting_name ){
51
+    public function get($setting_name) {
52 52
 
53
-        if( isset( $this->settings[ $setting_name ] ) ){
53
+        if (isset($this->settings[$setting_name])) {
54 54
 
55
-            return $this->settings[ $setting_name ];
55
+            return $this->settings[$setting_name];
56 56
 
57 57
         }
58 58
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 	 * @since  1.0.0
66 66
 	 * @return void
67 67
 	 */
68
-	public function register_settings_screen () {
68
+	public function register_settings_screen() {
69 69
 
70 70
 		$this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen.
71
-		$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
71
+		$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
72 72
 		$this->hook = $hook;
73 73
 
74
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
75
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
76
-			add_action( 'admin_notices', array( $this, 'language_pack_notices' ) );
77
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
78
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
74
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
75
+			add_action('admin_notices', array($this, 'settings_errors'));
76
+			add_action('admin_notices', array($this, 'language_pack_notices'));
77
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
78
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
79 79
 		}
80 80
 	} // End register_settings_screen()
81 81
 
@@ -85,49 +85,49 @@  discard block
 block discarded – undo
85 85
 	 * @since  1.0.0
86 86
 	 * @return void
87 87
 	 */
88
-	public function init_sections () {
88
+	public function init_sections() {
89 89
 		$sections = array();
90 90
 
91 91
 		$sections['default-settings'] = array(
92
-			'name' 			=> __( 'General', 'woothemes-sensei' ),
93
-			'description'	=> __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' )
92
+			'name' 			=> __('General', 'woothemes-sensei'),
93
+			'description'	=> __('Settings that apply to the entire plugin.', 'woothemes-sensei')
94 94
 		);
95 95
 
96 96
 		$sections['course-settings'] = array(
97
-			'name' 			=> __( 'Courses', 'woothemes-sensei' ),
98
-			'description'	=> __( 'Settings that apply to all Courses.', 'woothemes-sensei' )
97
+			'name' 			=> __('Courses', 'woothemes-sensei'),
98
+			'description'	=> __('Settings that apply to all Courses.', 'woothemes-sensei')
99 99
 		);
100 100
 
101 101
 		$sections['lesson-settings'] = array(
102
-			'name' 			=> __( 'Lessons', 'woothemes-sensei' ),
103
-			'description'	=> __( 'Settings that apply to all Lessons.', 'woothemes-sensei' )
102
+			'name' 			=> __('Lessons', 'woothemes-sensei'),
103
+			'description'	=> __('Settings that apply to all Lessons.', 'woothemes-sensei')
104 104
 		);
105 105
 
106 106
 		$sections['email-notification-settings'] = array(
107
-			'name' 			=> __( 'Email Notifications', 'woothemes-sensei' ),
108
-			'description'	=> __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' )
107
+			'name' 			=> __('Email Notifications', 'woothemes-sensei'),
108
+			'description'	=> __('Settings for email notifications sent from your site.', 'woothemes-sensei')
109 109
 		);
110 110
 
111 111
 		$sections['learner-profile-settings'] = array(
112
-			'name' 			=> __( 'Learner Profiles', 'woothemes-sensei' ),
113
-			'description'	=> __( 'Settings for public Learner Profiles.', 'woothemes-sensei' )
112
+			'name' 			=> __('Learner Profiles', 'woothemes-sensei'),
113
+			'description'	=> __('Settings for public Learner Profiles.', 'woothemes-sensei')
114 114
 		);
115 115
 
116
-		if ( Sensei_WC::is_woocommerce_present() ) {
116
+		if (Sensei_WC::is_woocommerce_present()) {
117 117
 			$sections['woocommerce-settings'] = array(
118
-				'name' 			=> __( 'WooCommerce', 'woothemes-sensei' ),
119
-				'description'	=> __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' )
118
+				'name' 			=> __('WooCommerce', 'woothemes-sensei'),
119
+				'description'	=> __('Optional settings for WooCommerce functions.', 'woothemes-sensei')
120 120
 			);
121 121
 		} // End If Statement
122 122
 
123
-		if ( 'en_US' !== get_locale() ) {
123
+		if ('en_US' !== get_locale()) {
124 124
 			$sections['language-settings'] = array(
125
-				'name' 			=> __( 'Language', 'woothemes-sensei' ),
126
-				'description'	=> __( 'Language options.', 'woothemes-sensei' )
125
+				'name' 			=> __('Language', 'woothemes-sensei'),
126
+				'description'	=> __('Language options.', 'woothemes-sensei')
127 127
 			);
128 128
 		}
129 129
 
130
-		$this->sections = apply_filters( 'sensei_settings_tabs', $sections );
130
+		$this->sections = apply_filters('sensei_settings_tabs', $sections);
131 131
 	} // End init_sections()
132 132
 
133 133
 	/**
@@ -137,71 +137,71 @@  discard block
 block discarded – undo
137 137
 	 * @uses   Sensei_Utils::get_slider_types()
138 138
 	 * @return void
139 139
 	 */
140
-	public function init_fields () {
140
+	public function init_fields() {
141 141
 		global $pagenow;
142 142
 
143 143
 		$pages_array = $this->pages_array();
144
-		$posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' );
145
-		$complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) );
146
-		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
144
+		$posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20');
145
+		$complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei'));
146
+		$course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei'));
147 147
 
148 148
 	    $fields = array();
149 149
 
150 150
 		$fields['access_permission'] = array(
151
-								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
152
-								'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ),
151
+								'name' => __('Access Permissions', 'woothemes-sensei'),
152
+								'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'),
153 153
 								'type' => 'checkbox',
154 154
 								'default' => true,
155 155
 								'section' => 'default-settings'
156 156
 								);
157 157
 
158 158
 		$fields['messages_disable'] = array(
159
-								'name' => __( 'Disable Private Messages', 'woothemes-sensei' ),
160
-								'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ),
159
+								'name' => __('Disable Private Messages', 'woothemes-sensei'),
160
+								'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'),
161 161
 								'type' => 'checkbox',
162 162
 								'default' => false,
163 163
 								'section' => 'default-settings'
164 164
 								);
165 165
 
166 166
 		$fields['course_page'] = array(
167
-								'name' => __( 'Course Archive Page', 'woothemes-sensei' ),
168
-								'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ),
167
+								'name' => __('Course Archive Page', 'woothemes-sensei'),
168
+								'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'),
169 169
 								'type' => 'select',
170
-								'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ),
170
+								'default' => get_option('woothemes-sensei_courses_page_id', 0),
171 171
 								'section' => 'default-settings',
172 172
 								'required' => 0,
173 173
 								'options' => $pages_array
174 174
 								);
175 175
 
176 176
 		$fields['my_course_page'] = array(
177
-								'name' => __( 'My Courses Page', 'woothemes-sensei' ),
178
-								'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ),
177
+								'name' => __('My Courses Page', 'woothemes-sensei'),
178
+								'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'),
179 179
 								'type' => 'select',
180
-								'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ),
180
+								'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0),
181 181
 								'section' => 'default-settings',
182 182
 								'required' => 0,
183 183
 								'options' => $pages_array
184 184
 								);
185 185
 
186 186
 		$fields['placeholder_images_enable'] = array(
187
-								'name' => __( 'Use placeholder images', 'woothemes-sensei' ),
188
-								'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ),
187
+								'name' => __('Use placeholder images', 'woothemes-sensei'),
188
+								'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'),
189 189
 								'type' => 'checkbox',
190 190
 								'default' => false,
191 191
 								'section' => 'default-settings'
192 192
 								);
193 193
 
194 194
 		$fields['styles_disable'] = array(
195
-								'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ),
196
-								'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ),
195
+								'name' => __('Disable Sensei Styles', 'woothemes-sensei'),
196
+								'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'),
197 197
 								'type' => 'checkbox',
198 198
 								'default' => false,
199 199
 								'section' => 'default-settings'
200 200
 								);
201 201
 
202 202
 		$fields['js_disable'] = array(
203
-								'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ),
204
-								'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ),
203
+								'name' => __('Disable Sensei Javascript', 'woothemes-sensei'),
204
+								'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'),
205 205
 								'type' => 'checkbox',
206 206
 								'default' => false,
207 207
 								'section' => 'default-settings'
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
     	// Course Settings
211 211
 
212 212
     	$fields['course_completion'] = array(
213
-								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
214
-								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
213
+								'name' => __('Courses are complete:', 'woothemes-sensei'),
214
+								'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'),
215 215
 								'type' => 'select',
216 216
 								'default' => 'passed',
217 217
 								'section' => 'course-settings',
@@ -220,16 +220,16 @@  discard block
 block discarded – undo
220 220
 								);
221 221
 
222 222
     	$fields['course_author'] = array(
223
-								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
224
-								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
223
+								'name' => __('Display Course Author', 'woothemes-sensei'),
224
+								'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'),
225 225
 								'type' => 'checkbox',
226 226
 								'default' => true,
227 227
 								'section' => 'course-settings'
228 228
 								);
229 229
 
230 230
 		$fields['my_course_amount'] = array(
231
-								'name' => __( 'My Courses Pagination', 'woothemes-sensei' ),
232
-								'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ),
231
+								'name' => __('My Courses Pagination', 'woothemes-sensei'),
232
+								'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'),
233 233
 								'type' => 'range',
234 234
 								'default' => '0',
235 235
 								'section' => 'course-settings',
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 								);
239 239
 
240 240
 		$fields['course_archive_image_enable'] = array(
241
-								'name' => __( 'Course Archive Image', 'woothemes-sensei' ),
242
-								'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ),
241
+								'name' => __('Course Archive Image', 'woothemes-sensei'),
242
+								'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'),
243 243
 								'type' => 'checkbox',
244 244
 								'default' => true,
245 245
 								'section' => 'course-settings'
246 246
 								);
247 247
 
248 248
 		$fields['course_archive_image_width'] = array(
249
-								'name' => __( 'Image Width - Archive', 'woothemes-sensei' ),
250
-								'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
249
+								'name' => __('Image Width - Archive', 'woothemes-sensei'),
250
+								'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
251 251
 								'type' => 'text',
252 252
 								'default' => '100',
253 253
 								'section' => 'course-settings',
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 								);
256 256
 
257 257
 		$fields['course_archive_image_height'] = array(
258
-								'name' => __( 'Image Height - Archive', 'woothemes-sensei' ),
259
-								'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
258
+								'name' => __('Image Height - Archive', 'woothemes-sensei'),
259
+								'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
260 260
 								'type' => 'text',
261 261
 								'default' => '100',
262 262
 								'section' => 'course-settings',
@@ -264,24 +264,24 @@  discard block
 block discarded – undo
264 264
 								);
265 265
 
266 266
 		$fields['course_archive_image_hard_crop'] = array(
267
-								'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ),
268
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
267
+								'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'),
268
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
269 269
 								'type' => 'checkbox',
270 270
 								'default' => false,
271 271
 								'section' => 'course-settings'
272 272
 								);
273 273
 
274 274
 		$fields['course_single_image_enable'] = array(
275
-								'name' => __( 'Single Course Image', 'woothemes-sensei' ),
276
-								'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ),
275
+								'name' => __('Single Course Image', 'woothemes-sensei'),
276
+								'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'),
277 277
 								'type' => 'checkbox',
278 278
 								'default' => false,
279 279
 								'section' => 'course-settings'
280 280
 								);
281 281
 
282 282
 		$fields['course_single_image_width'] = array(
283
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
284
-								'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
283
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
284
+								'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
285 285
 								'type' => 'text',
286 286
 								'default' => '100',
287 287
 								'section' => 'course-settings',
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 								);
290 290
 
291 291
 		$fields['course_single_image_height'] = array(
292
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
293
-								'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
292
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
293
+								'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
294 294
 								'type' => 'text',
295 295
 								'default' => '100',
296 296
 								'section' => 'course-settings',
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 								);
299 299
 
300 300
 		$fields['course_single_image_hard_crop'] = array(
301
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
302
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
301
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
302
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
303 303
 								'type' => 'checkbox',
304 304
 								'default' => false,
305 305
 								'section' => 'course-settings'
306 306
 								);
307 307
 
308 308
 		$fields['course_single_content_display'] = array(
309
-								'name' => __( 'Single Course page displays:', 'woothemes-sensei' ),
310
-								'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ),
309
+								'name' => __('Single Course page displays:', 'woothemes-sensei'),
310
+								'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'),
311 311
 								'type' => 'select',
312 312
 								'default' => 'excerpt',
313 313
 								'section' => 'course-settings',
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
 								);
317 317
 
318 318
 		$fields['course_archive_featured_enable'] = array(
319
-								'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ),
320
-								'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
319
+								'name' => __('Featured Courses Panel', 'woothemes-sensei'),
320
+								'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
321 321
 								'type' => 'checkbox',
322 322
 								'default' => true,
323 323
 								'section' => 'course-settings'
324 324
 								);
325 325
 
326 326
 		$fields['course_archive_more_link_text'] = array(
327
-								'name' => __( 'More link text', 'woothemes-sensei' ),
328
-								'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ),
327
+								'name' => __('More link text', 'woothemes-sensei'),
328
+								'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'),
329 329
 								'type' => 'text',
330
-								'default' => __ ( 'More', 'woothemes-sensei' ),
330
+								'default' => __('More', 'woothemes-sensei'),
331 331
 								'section' => 'course-settings',
332 332
 								'required' => 0
333 333
 								);
@@ -335,32 +335,32 @@  discard block
 block discarded – undo
335 335
 		// Lesson Settings
336 336
 
337 337
 		$fields['lesson_comments'] = array(
338
-								'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ),
339
-								'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ),
338
+								'name' => __('Allow Comments for Lessons', 'woothemes-sensei'),
339
+								'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'),
340 340
 								'type' => 'checkbox',
341 341
 								'default' => true,
342 342
 								'section' => 'lesson-settings'
343 343
 								);
344 344
 
345 345
 		$fields['lesson_author'] = array(
346
-								'name' => __( 'Display Lesson Author', 'woothemes-sensei' ),
347
-								'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ),
346
+								'name' => __('Display Lesson Author', 'woothemes-sensei'),
347
+								'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'),
348 348
 								'type' => 'checkbox',
349 349
 								'default' => true,
350 350
 								'section' => 'lesson-settings'
351 351
 								);
352 352
 
353 353
 		$fields['course_lesson_image_enable'] = array(
354
-								'name' => __( 'Course Lesson Images', 'woothemes-sensei' ),
355
-								'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ),
354
+								'name' => __('Course Lesson Images', 'woothemes-sensei'),
355
+								'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'),
356 356
 								'type' => 'checkbox',
357 357
 								'default' => false,
358 358
 								'section' => 'lesson-settings'
359 359
 								);
360 360
 
361 361
 		$fields['lesson_archive_image_width'] = array(
362
-								'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ),
363
-								'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
362
+								'name' => __('Image Width - Course Lessons', 'woothemes-sensei'),
363
+								'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
364 364
 								'type' => 'text',
365 365
 								'default' => '100',
366 366
 								'section' => 'lesson-settings',
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 								);
369 369
 
370 370
 		$fields['lesson_archive_image_height'] = array(
371
-								'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ),
372
-								'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
371
+								'name' => __('Image Height - Course Lessons', 'woothemes-sensei'),
372
+								'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
373 373
 								'type' => 'text',
374 374
 								'default' => '100',
375 375
 								'section' => 'lesson-settings',
@@ -377,24 +377,24 @@  discard block
 block discarded – undo
377 377
 								);
378 378
 
379 379
 		$fields['lesson_archive_image_hard_crop'] = array(
380
-								'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ),
381
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
380
+								'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'),
381
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
382 382
 								'type' => 'checkbox',
383 383
 								'default' => false,
384 384
 								'section' => 'lesson-settings'
385 385
 								);
386 386
 
387 387
 		$fields['lesson_single_image_enable'] = array(
388
-								'name' => __( 'Single Lesson Images', 'woothemes-sensei' ),
389
-								'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ),
388
+								'name' => __('Single Lesson Images', 'woothemes-sensei'),
389
+								'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'),
390 390
 								'type' => 'checkbox',
391 391
 								'default' => false,
392 392
 								'section' => 'lesson-settings'
393 393
 								);
394 394
 
395 395
 		$fields['lesson_single_image_width'] = array(
396
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
397
-								'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
396
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
397
+								'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
398 398
 								'type' => 'text',
399 399
 								'default' => '100',
400 400
 								'section' => 'lesson-settings',
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 								);
403 403
 
404 404
 		$fields['lesson_single_image_height'] = array(
405
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
406
-								'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
405
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
406
+								'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
407 407
 								'type' => 'text',
408 408
 								'default' => '100',
409 409
 								'section' => 'lesson-settings',
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 								);
412 412
 
413 413
 		$fields['lesson_single_image_hard_crop'] = array(
414
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
415
-								'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ),
414
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
415
+								'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'),
416 416
 								'type' => 'checkbox',
417 417
 								'default' => false,
418 418
 								'section' => 'lesson-settings'
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 
421 421
 		// Learner Profile settings
422 422
 
423
-		$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
424
-		$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%';
423
+		$profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
424
+		$profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%';
425 425
 
426 426
 		$fields['learner_profile_enable'] = array(
427
-							'name' => __( 'Public learner profiles', 'woothemes-sensei' ),
428
-							'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ),
427
+							'name' => __('Public learner profiles', 'woothemes-sensei'),
428
+							'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example),
429 429
 							'type' => 'checkbox',
430 430
 							'default' => true,
431 431
 							'section' => 'learner-profile-settings'
432 432
 							);
433 433
 
434 434
 		$fields['learner_profile_show_courses'] = array(
435
-							'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ),
436
-							'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ),
435
+							'name' => __('Show learner\'s courses', 'woothemes-sensei'),
436
+							'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'),
437 437
 							'type' => 'checkbox',
438 438
 							'default' => true,
439 439
 							'section' => 'learner-profile-settings'
@@ -442,70 +442,70 @@  discard block
 block discarded – undo
442 442
 		// Email notifications
443 443
 
444 444
 		$learner_email_options = array(
445
-			'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ),
446
-			'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ),
445
+			'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'),
446
+			'learner-completed-course' => __('They complete a course', 'woothemes-sensei'),
447 447
 		);
448 448
 
449 449
 		$teacher_email_options = array(
450
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
451
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
452
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
453
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
454
-			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
450
+            'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'),
451
+            'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'),
452
+            'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'),
453
+            'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'),
454
+			'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'),
455 455
 		);
456 456
 
457 457
 		$global_email_options = array(
458
-			'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ),
458
+			'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'),
459 459
 		);
460 460
 
461 461
 		$fields['email_learners'] = array(
462
-								'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ),
463
-								'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ),
462
+								'name' => __('Emails Sent to Learners', 'woothemes-sensei'),
463
+								'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'),
464 464
 								'type' => 'multicheck',
465 465
 								'options' => $learner_email_options,
466
-								'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ),
466
+								'defaults' => array('learner-graded-quiz', 'learner-completed-course'),
467 467
 								'section' => 'email-notification-settings'
468 468
 								);
469 469
 
470 470
 		$fields['email_teachers'] = array(
471
-								'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ),
472
-								'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ),
471
+								'name' => __('Emails Sent to Teachers', 'woothemes-sensei'),
472
+								'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'),
473 473
 								'type' => 'multicheck',
474 474
 								'options' => $teacher_email_options,
475
-								'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ),
475
+								'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'),
476 476
 								'section' => 'email-notification-settings'
477 477
 								);
478 478
 
479 479
 		$fields['email_global'] = array(
480
-								'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ),
481
-								'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ),
480
+								'name' => __('Emails Sent to All Users', 'woothemes-sensei'),
481
+								'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'),
482 482
 								'type' => 'multicheck',
483 483
 								'options' => $global_email_options,
484
-								'defaults' => array( 'new-message-reply' ),
484
+								'defaults' => array('new-message-reply'),
485 485
 								'section' => 'email-notification-settings'
486 486
 								);
487 487
 
488 488
 		$fields['email_from_name'] = array(
489
-								'name' => __( '"From" Name', 'woothemes-sensei' ),
490
-								'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ),
489
+								'name' => __('"From" Name', 'woothemes-sensei'),
490
+								'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'),
491 491
 								'type' => 'text',
492
-								'default' => get_bloginfo( 'name' ),
492
+								'default' => get_bloginfo('name'),
493 493
 								'section' => 'email-notification-settings',
494 494
 								'required' => 1
495 495
 								);
496 496
 
497 497
 		$fields['email_from_address'] = array(
498
-								'name' => __( '"From" Address', 'woothemes-sensei' ),
499
-								'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ),
498
+								'name' => __('"From" Address', 'woothemes-sensei'),
499
+								'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'),
500 500
 								'type' => 'text',
501
-								'default' => get_bloginfo( 'admin_email' ),
501
+								'default' => get_bloginfo('admin_email'),
502 502
 								'section' => 'email-notification-settings',
503 503
 								'required' => 1
504 504
 								);
505 505
 
506 506
 		$fields['email_header_image'] = array(
507
-								'name' => __( 'Header Image', 'woothemes-sensei' ),
508
-								'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ),
507
+								'name' => __('Header Image', 'woothemes-sensei'),
508
+								'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'),
509 509
 								'type' => 'text',
510 510
 								'default' => '',
511 511
 								'section' => 'email-notification-settings',
@@ -513,17 +513,17 @@  discard block
 block discarded – undo
513 513
 								);
514 514
 
515 515
 		$fields['email_footer_text'] = array(
516
-								'name' => __( 'Email Footer Text', 'woothemes-sensei' ),
517
-								'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ),
516
+								'name' => __('Email Footer Text', 'woothemes-sensei'),
517
+								'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'),
518 518
 								'type' => 'textarea',
519
-								'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ),
519
+								'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')),
520 520
 								'section' => 'email-notification-settings',
521 521
 								'required' => 0
522 522
 								);
523 523
 
524 524
 		$fields['email_base_color'] = array(
525
-								'name' => __( 'Base Colour', 'woothemes-sensei' ),
526
-								'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
525
+								'name' => __('Base Colour', 'woothemes-sensei'),
526
+								'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
527 527
 								'type' => 'color',
528 528
 								'default' => '#557da1',
529 529
 								'section' => 'email-notification-settings',
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 								);
532 532
 
533 533
 		$fields['email_background_color'] = array(
534
-								'name' => __( 'Background Colour', 'woothemes-sensei' ),
535
-								'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
534
+								'name' => __('Background Colour', 'woothemes-sensei'),
535
+								'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
536 536
 								'type' => 'color',
537 537
 								'default' => '#f5f5f5',
538 538
 								'section' => 'email-notification-settings',
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 								);
541 541
 
542 542
 		$fields['email_body_background_color'] = array(
543
-								'name' => __( 'Body Background Colour', 'woothemes-sensei' ),
544
-								'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
543
+								'name' => __('Body Background Colour', 'woothemes-sensei'),
544
+								'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
545 545
 								'type' => 'color',
546 546
 								'default' => '#fdfdfd',
547 547
 								'section' => 'email-notification-settings',
@@ -549,35 +549,35 @@  discard block
 block discarded – undo
549 549
 								);
550 550
 
551 551
 		$fields['email_text_color'] = array(
552
-								'name' => __( 'Body Text Colour', 'woothemes-sensei' ),
553
-								'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
552
+								'name' => __('Body Text Colour', 'woothemes-sensei'),
553
+								'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
554 554
 								'type' => 'color',
555 555
 								'default' => '#505050',
556 556
 								'section' => 'email-notification-settings',
557 557
 								'required' => 1
558 558
 								);
559 559
 
560
-		if ( Sensei_WC::is_woocommerce_active() ) {
560
+		if (Sensei_WC::is_woocommerce_active()) {
561 561
 			// WooCommerce Settings
562 562
     		$fields['woocommerce_enabled'] = array(
563
-									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
564
-									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
563
+									'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'),
564
+									'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'),
565 565
 									'type' => 'checkbox',
566 566
 									'default' => true,
567 567
 									'section' => 'woocommerce-settings'
568 568
 									);
569 569
 
570 570
 			$fields['course_archive_free_enable'] = array(
571
-									'name' => __( 'Free Courses Panel', 'woothemes-sensei' ),
572
-									'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
571
+									'name' => __('Free Courses Panel', 'woothemes-sensei'),
572
+									'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
573 573
 									'type' => 'checkbox',
574 574
 									'default' => true,
575 575
 									'section' => 'woocommerce-settings'
576 576
 									);
577 577
 
578 578
 			$fields['course_archive_paid_enable'] = array(
579
-									'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ),
580
-									'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
579
+									'name' => __('Paid Courses Panel', 'woothemes-sensei'),
580
+									'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
581 581
 									'type' => 'checkbox',
582 582
 									'default' => true,
583 583
 									'section' => 'woocommerce-settings'
@@ -585,18 +585,18 @@  discard block
 block discarded – undo
585 585
 
586 586
 		} // End If Statement
587 587
 
588
-		if ( 'en_US' !== get_locale() ) {
588
+		if ('en_US' !== get_locale()) {
589 589
 			$fields['install_language_pack'] = array(
590
-				'name'        => __( 'Install Language Pack', 'woothemes-sensei' ),
591
-				'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ),
590
+				'name'        => __('Install Language Pack', 'woothemes-sensei'),
591
+				'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'),
592 592
 				'type'        => 'button',
593 593
 				'section'     => 'language-settings',
594 594
 				'target'      => Sensei_Language_Pack_Manager::get_install_uri(),
595
-				'label'       => __( 'Install', 'woothemes-sensei' )
595
+				'label'       => __('Install', 'woothemes-sensei')
596 596
 			);
597 597
 		}
598 598
 
599
-		$this->fields = apply_filters( 'sensei_settings_fields', $fields );
599
+		$this->fields = apply_filters('sensei_settings_fields', $fields);
600 600
 
601 601
 	} // End init_fields()
602 602
 
@@ -606,20 +606,20 @@  discard block
 block discarded – undo
606 606
 	 * @param  $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1.
607 607
 	 * @return array Options between 0.1 and 10 seconds.
608 608
 	 */
609
-	private function get_duration_options ( $include_milliseconds = true ) {
610
-		$numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' );
609
+	private function get_duration_options($include_milliseconds = true) {
610
+		$numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0');
611 611
 		$options = array();
612 612
 
613
-		if ( true == (bool)$include_milliseconds ) {
614
-			$milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' );
615
-			foreach ( $milliseconds as $k => $v ) {
613
+		if (true == (bool) $include_milliseconds) {
614
+			$milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9');
615
+			foreach ($milliseconds as $k => $v) {
616 616
 				$options[$v] = $v;
617 617
 			}
618 618
 		} else {
619 619
 			$options['0.5'] = '0.5';
620 620
 		}
621 621
 
622
-		foreach ( $numbers as $k => $v ) {
622
+		foreach ($numbers as $k => $v) {
623 623
 			$options[$v] = $v;
624 624
 		}
625 625
 
@@ -635,25 +635,25 @@  discard block
 block discarded – undo
635 635
 	private function pages_array() {
636 636
 		// REFACTOR - Transform this into a field type instead.
637 637
 		// Setup an array of portfolio gallery terms for a dropdown.
638
-		$args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' );
639
-		$pages_dropdown = wp_dropdown_pages( $args );
638
+		$args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC');
639
+		$pages_dropdown = wp_dropdown_pages($args);
640 640
 		$page_items = array();
641 641
 
642 642
 		// Quick string hack to make sure we get the pages with the indents.
643
-		$pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown );
644
-		$pages_dropdown = str_replace( '</select>', '', $pages_dropdown );
645
-		$pages_split = explode( '</option>', $pages_dropdown );
643
+		$pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown);
644
+		$pages_dropdown = str_replace('</select>', '', $pages_dropdown);
645
+		$pages_split = explode('</option>', $pages_dropdown);
646 646
 
647
-		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
647
+		$page_items[] = __('Select a Page:', 'woothemes-sensei');
648 648
 
649
-		foreach ( $pages_split as $k => $v ) {
649
+		foreach ($pages_split as $k => $v) {
650 650
 		    $id = '';
651 651
 		    // Get the ID value.
652
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
652
+		    preg_match('/value="(.*?)"/i', $v, $matches);
653 653
 
654
-		    if ( isset( $matches[1] ) ) {
654
+		    if (isset($matches[1])) {
655 655
 		        $id = $matches[1];
656
-		        $page_items[$id] = trim( strip_tags( $v ) );
656
+		        $page_items[$id] = trim(strip_tags($v));
657 657
 		    } // End If Statement
658 658
 		} // End For Loop
659 659
 
@@ -677,10 +677,10 @@  discard block
 block discarded – undo
677 677
      *
678 678
      * @since 1.9.0
679 679
      */
680
-    public static function flush_rewrite_rules(){
680
+    public static function flush_rewrite_rules() {
681 681
 
682
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
683
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
682
+        if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page']
683
+            && isset($_POST['action']) && 'update' == $_POST['action']) {
684 684
 
685 685
             Sensei()->initiate_rewrite_rules_flush();
686 686
 
@@ -694,4 +694,4 @@  discard block
 block discarded – undo
694 694
  * for backward compatibility
695 695
  * @since 1.9.0
696 696
  */
697
-class WooThemes_Sensei_Settings extends Sensei_Settings{}
697
+class WooThemes_Sensei_Settings extends Sensei_Settings {}
Please login to merge, or discard this patch.
includes/theme-integrations/theme-integration-loader.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @since 1.9.0
37 37
      */
38
-    private function setup_themes(){
38
+    private function setup_themes() {
39 39
 
40 40
         $this->themes = array(
41 41
             'twentyeleven',
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      *
55 55
      * @since 1.9.0
56 56
      */
57
-    private function setup_currently_active_theme(){
57
+    private function setup_currently_active_theme() {
58 58
 
59 59
         $this->active_theme = get_option('template');
60 60
 
@@ -67,33 +67,33 @@  discard block
 block discarded – undo
67 67
      *
68 68
      * @since 1.9.0
69 69
      */
70
-    private function possibly_load_supported_theme_wrappers(){
70
+    private function possibly_load_supported_theme_wrappers() {
71 71
 
72
-        if ( in_array( $this->active_theme, $this->themes ) ){
72
+        if (in_array($this->active_theme, $this->themes)) {
73 73
 
74 74
             // setup file and class names
75
-            $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php';
76
-            $supported_theme_class_name  = 'Sensei_'. ucfirst( $this->active_theme  );
75
+            $supported_theme_class_file = trailingslashit(Sensei()->plugin_path).'includes/theme-integrations/'.$this->active_theme.'.php';
76
+            $supported_theme_class_name = 'Sensei_'.ucfirst($this->active_theme);
77 77
 
78 78
             // load the file or exit if there is no file for this theme
79
-            if( ! file_exists( $supported_theme_class_file ) ){
79
+            if ( ! file_exists($supported_theme_class_file)) {
80 80
                 return;
81 81
             }
82
-            include_once( $supported_theme_class_file );
83
-            include_once( 'twentytwelve.php' );
82
+            include_once($supported_theme_class_file);
83
+            include_once('twentytwelve.php');
84 84
             //initialize the class or exit if there is no class for this theme
85
-            if( ! class_exists( $supported_theme_class_name ) ){
85
+            if ( ! class_exists($supported_theme_class_name)) {
86 86
                 return;
87 87
             }
88 88
             $supported_theme = new $supported_theme_class_name;
89 89
 
90 90
             // remove default wrappers
91
-            remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 );
92
-            remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 );
91
+            remove_action('sensei_before_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper'), 10);
92
+            remove_action('sensei_after_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper_end'), 10);
93 93
 
94 94
             // load the supported theme wrappers
95
-            add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 );
96
-            add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 );
95
+            add_action('sensei_before_main_content', array($supported_theme, 'wrapper_start'), 10);
96
+            add_action('sensei_after_main_content', array($supported_theme, 'wrapper_end'), 10);
97 97
         }
98 98
     }
99 99
 
Please login to merge, or discard this patch.
includes/theme-integrations/twentyfifteen.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      * Output opening wrappers
14 14
      * @since 1.9.0
15 15
      */
16
-    public function wrapper_start(){
16
+    public function wrapper_start() {
17 17
 
18 18
         // output inline styles
19 19
         $this->print_styles();
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @since 1.9.0
32 32
      */
33
-    private function print_styles(){?>
33
+    private function print_styles() {?>
34 34
 
35 35
         <style>
36 36
             @media screen and (min-width: 59.6875em){
Please login to merge, or discard this patch.