Completed
Push — master ( b09b8b...45e17f )
by Dwain
07:46
created
includes/class-sensei-updates.php 1 patch
Spacing   +436 added lines, -436 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
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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 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')),
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
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 82
         add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
         <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2>
121 121
 
122 122
         <?php
123
-        $function_name= '';
124
-        if ( isset($_GET['action']) && $_GET['action'] == 'update'
123
+        $function_name = '';
124
+        if (isset($_GET['action']) && $_GET['action'] == 'update'
125 125
             && isset($_GET['n']) && intval($_GET['n']) >= 0
126
-            && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
126
+            && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
127 127
 
128 128
             // Setup the data variables
129 129
             $n = intval($_GET['n']);
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 
136 136
                 foreach ($_POST['checked'] as $key => $function_name) {
137 137
 
138
-                    if( ! isset(  $_POST[ $function_name.'_nonce_field' ] ) 
139
-                        || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){
138
+                    if ( ! isset($_POST[$function_name.'_nonce_field']) 
139
+                        || ! wp_verify_nonce($_POST[$function_name.'_nonce_field'], 'run_'.$function_name)) {
140 140
 
141 141
                         wp_die(
142
-                            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
143
-                            '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
142
+                            '<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
143
+                            '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>',
144 144
                             403
145 145
                         );
146 146
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
                     } else {
159 159
 
160
-                        _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
160
+                        _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
161 161
                         return;
162 162
 
163 163
                     }// End If Statement
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 if ('' == $functions_list) {
167 167
                     $functions_list .= $function_name;
168 168
                 } else {
169
-                    $functions_list .= '+' . $function_name;
169
+                    $functions_list .= '+'.$function_name;
170 170
                 } // End If Statement
171 171
 
172 172
                 // Mark update has having been run
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 
185 185
             foreach ($functions_array as $key => $function_name) {
186 186
 
187
-                if( ! isset( $_GET[ $function_name.'_nonce' ] )
188
-                    || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){
187
+                if ( ! isset($_GET[$function_name.'_nonce'])
188
+                    || ! wp_verify_nonce($_GET[$function_name.'_nonce'], 'run_'.$function_name)) {
189 189
 
190 190
                     wp_die(
191
-                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
192
-                        '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
191
+                        '<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
192
+                        '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>',
193 193
                         403
194 194
                     );
195 195
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
                 } else {
208 208
 
209
-                    _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
209
+                    _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
210 210
                     return;
211 211
 
212 212
                 } // End If Statement
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 if ('' == $functions_list) {
216 216
                     $functions_list .= $function_name;
217 217
                 } else {
218
-                    $functions_list .= '+' . $function_name;
218
+                    $functions_list .= '+'.$function_name;
219 219
                 } // End If Statement
220 220
 
221 221
                 $this->set_update_run($function_name);
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
 
225 225
         } // End If Statement
226 226
 
227
-        if (!$done_processing) { ?>
227
+        if ( ! $done_processing) { ?>
228 228
 
229 229
             <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3>
230 230
 
231 231
             <p>
232 232
 
233
-                <?php _e( "If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei' ); ?>
233
+                <?php _e("If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei'); ?>
234 234
 
235 235
                 <?php
236
-                $next_action_url = add_query_arg( array(
236
+                $next_action_url = add_query_arg(array(
237 237
                     'page' => 'sensei_updates',
238 238
                     'action' => 'update',
239 239
                     'n' => $n + 50,
240
-                    'functions' => array( $functions_list ),
241
-                    $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ),
242
-                ), admin_url( 'admin.php' ) );
240
+                    'functions' => array($functions_list),
241
+                    $function_name.'_nonce' => wp_create_nonce('run_'.$function_name),
242
+                ), admin_url('admin.php'));
243 243
                 ?>
244 244
 
245
-                <a class="button"  href="<?php echo esc_url( $next_action_url ); ?>">
245
+                <a class="button"  href="<?php echo esc_url($next_action_url); ?>">
246 246
 
247
-                    <?php _e( 'Next', 'woothemes-sensei' ); ?>
247
+                    <?php _e('Next', 'woothemes-sensei'); ?>
248 248
 
249 249
                 </a>
250 250
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             <script type='text/javascript'>
253 253
                 <!--
254 254
                 function js_sensei_nextpage() {
255
-                    location.href = "<?php echo esc_url_raw(  $next_action_url );?>";
255
+                    location.href = "<?php echo esc_url_raw($next_action_url); ?>";
256 256
                 }
257 257
                 setTimeout( "js_sensei_nextpage()", 250 );
258 258
                 //-->
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
                                     <td><p><?php echo $type_label; ?></p></td>
332 332
                                     <td>
333 333
                                         <p>
334
-                                            <input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');"
334
+                                            <input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');"
335 335
                                                    id="update-sensei"
336
-                                                   class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>"
336
+                                                   class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>"
337 337
                                                    type="submit"
338
-                                                   value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>"
338
+                                                   value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>"
339 339
                                                    name="update">
340 340
 
341 341
                                             <?php
342 342
                                             $nonce_action = 'run_'.$update;
343 343
                                             $nonce_field_name = $update.'_nonce_field';
344
-                                            wp_nonce_field( $nonce_action, $nonce_field_name, false, true );
344
+                                            wp_nonce_field($nonce_action, $nonce_field_name, false, true);
345 345
                                             ?>
346 346
                                         </p>
347 347
                                     </td>
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      *
376 376
      * @param string $function_name
377 377
      */
378
-    public function function_in_whitelist( $function_name ){
378
+    public function function_in_whitelist($function_name) {
379 379
 
380 380
         $function_whitelist = array(
381 381
             'status_changes_convert_questions',
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
         );
388 388
 
389
-        return in_array($function_name, $function_whitelist );
389
+        return in_array($function_name, $function_whitelist);
390 390
 
391 391
     }// end function_in_whitelist
392 392
 
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	 * @param  string $b Second key
398 398
 	 * @return integer
399 399
 	 */
400
-	private function sort_updates( $a, $b ) {
401
-		return strcmp( $a, $b );
400
+	private function sort_updates($a, $b) {
401
+		return strcmp($a, $b);
402 402
 	}
403 403
 
404 404
 	/**
@@ -409,39 +409,39 @@  discard block
 block discarded – undo
409 409
 	 * @access public
410 410
 	 * @return boolean
411 411
 	 */
412
-	public function update ( $type = 'auto' ) {
412
+	public function update($type = 'auto') {
413 413
 
414 414
 		// Only allow admins to run update functions
415
-		if( ! current_user_can( 'manage_options' ) ) {
415
+		if ( ! current_user_can('manage_options')) {
416 416
             return false;
417 417
         }
418 418
 
419 419
         $this->force_updates();
420 420
 
421 421
         // Run through all functions
422
-        foreach ( $this->updates as $version => $value ) {
423
-            foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
424
-                if ( $upgrade_type == $type ) {
422
+        foreach ($this->updates as $version => $value) {
423
+            foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
424
+                if ($upgrade_type == $type) {
425 425
                     $updated = false;
426 426
                     // Run the update function
427
-                    foreach ( $function_to_run as $function_name => $update_data ) {
428
-                        if ( isset( $function_name ) && '' != $function_name ) {
429
-                            if ( ! in_array( $function_name, $this->updates_run ) ) {
427
+                    foreach ($function_to_run as $function_name => $update_data) {
428
+                        if (isset($function_name) && '' != $function_name) {
429
+                            if ( ! in_array($function_name, $this->updates_run)) {
430 430
                                 $updated = false;
431
-                                if ( method_exists( $this, $function_name ) ) {
431
+                                if (method_exists($this, $function_name)) {
432 432
 
433
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
434
-			update_option( Sensei()->token . '-upgrades', $this->updates_run );
433
+            $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
434
+			update_option(Sensei()->token.'-upgrades', $this->updates_run);
435 435
 			return true;
436 436
 
437
-                                } elseif( $this->function_in_whitelist( $function_name ) ) {
437
+                                } elseif ($this->function_in_whitelist($function_name)) {
438 438
 
439
-                                    $updated = call_user_func( $function_name );
439
+                                    $updated = call_user_func($function_name);
440 440
 
441 441
                                 }  // End If Statement
442 442
 
443
-                                if ( $updated ) {
444
-                                    array_push( $this->updates_run, $function_name );
443
+                                if ($updated) {
444
+                                    array_push($this->updates_run, $function_name);
445 445
                                 } // End If Statement
446 446
                             }
447 447
                         } // End If Statement
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
             } // End For Loop
451 451
         } // End For Loop
452 452
 
453
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
454
-        update_option( $this->token . '-upgrades', $this->updates_run );
453
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
454
+        update_option($this->token.'-upgrades', $this->updates_run);
455 455
 
456 456
         return true;
457 457
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 	private function force_updates() {
461 461
 
462
-		if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) {
462
+		if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) {
463 463
 
464 464
 			// $skip_forced_updates = false;
465 465
 			// if( ! get_option( 'woothemes-sensei-force-updates', false ) ) {
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 
469 469
 			// Force critical updates if only if lessons already exist
470 470
 			$skip_forced_updates = false;
471
-			$lesson_posts = wp_count_posts( 'lesson' );
472
-			if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) {
471
+			$lesson_posts = wp_count_posts('lesson');
472
+			if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) {
473 473
 				$skip_forced_updates = true;
474 474
 			}
475 475
 
@@ -477,69 +477,69 @@  discard block
 block discarded – undo
477 477
 
478 478
 			$updates_to_run = array();
479 479
 
480
-			foreach ( $this->updates as $version => $value ) {
481
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
482
-					if ( $upgrade_type == 'forced' ) {
483
-						foreach ( $function_to_run as $function_name => $update_data ) {
480
+			foreach ($this->updates as $version => $value) {
481
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
482
+					if ($upgrade_type == 'forced') {
483
+						foreach ($function_to_run as $function_name => $update_data) {
484 484
 
485
-							if( $skip_forced_updates ) {
486
-								$this->set_update_run( $function_name );
485
+							if ($skip_forced_updates) {
486
+								$this->set_update_run($function_name);
487 487
 								continue;
488 488
 							}
489 489
 
490
-							$update_run = $this->has_update_run( $function_name );
490
+							$update_run = $this->has_update_run($function_name);
491 491
 
492
-							if( ! $update_run ) {
492
+							if ( ! $update_run) {
493 493
 								$use_the_force = true;
494
-								$updates_to_run[ $function_name ] = $update_data;
494
+								$updates_to_run[$function_name] = $update_data;
495 495
 							}
496 496
 						}
497 497
 					}
498 498
 				}
499 499
 			}
500 500
 
501
-			if( $skip_forced_updates ) {
501
+			if ($skip_forced_updates) {
502 502
 				return;
503 503
 			}
504 504
 
505
-			if( $use_the_force && 0 < count( $updates_to_run ) ) {
505
+			if ($use_the_force && 0 < count($updates_to_run)) {
506 506
 
507
-				$update_title = __( 'Important Sensei updates required', 'woothemes-sensei' );
507
+				$update_title = __('Important Sensei updates required', 'woothemes-sensei');
508 508
 
509
-				$update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n";
509
+				$update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n";
510 510
 
511 511
 				// $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";
512 512
 
513
-				$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";
513
+				$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";
514 514
 
515
-				$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";
515
+				$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";
516 516
 
517
-				$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";
517
+				$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";
518 518
 
519
-				$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";
519
+				$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";
520 520
 
521
-				$update_message .= '<ol>' . "\n";
521
+				$update_message .= '<ol>'."\n";
522 522
 
523
-					foreach( $updates_to_run as $function => $data ) {
523
+					foreach ($updates_to_run as $function => $data) {
524 524
 
525
-						if( ! isset( $data['title'] ) ) {
525
+						if ( ! isset($data['title'])) {
526 526
 							break;
527 527
 						}
528 528
 
529
-						$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>';
529
+						$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>';
530 530
 					}
531 531
 
532
-				$update_message .= '</ol>' . "\n";
532
+				$update_message .= '</ol>'."\n";
533 533
 
534
-				switch( $version ) {
534
+				switch ($version) {
535 535
 
536 536
 					case '1.7.0':
537
-						$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";
537
+						$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";
538 538
 					break;
539 539
 
540 540
 				}
541 541
 
542
-				wp_die( $update_message, $update_title );
542
+				wp_die($update_message, $update_title);
543 543
 			}
544 544
 		}
545 545
 	}
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @since  1.4.0
552 552
 	 * @return boolean
553 553
 	 */
554
-	private function has_update_run( $update ) {
555
-		if ( in_array( $update, $this->updates_run ) ) {
554
+	private function has_update_run($update) {
555
+		if (in_array($update, $this->updates_run)) {
556 556
 			return true;
557 557
 		}
558 558
 		return false;
@@ -564,10 +564,10 @@  discard block
 block discarded – undo
564 564
 	 * @param string $update Update to process
565 565
 	 * @since  1.4.0
566 566
 	 */
567
-	private function set_update_run( $update ) {
568
-		array_push( $this->updates_run, $update );
569
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
570
-		update_option( Sensei()->token . '-upgrades', $this->updates_run );
567
+	private function set_update_run($update) {
568
+		array_push($this->updates_run, $update);
569
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
570
+		update_option(Sensei()->token.'-upgrades', $this->updates_run);
571 571
 	}
572 572
 
573 573
 	/**
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 	 * @return void
579 579
 	 */
580 580
 	public function assign_role_caps() {
581
-		foreach ( $this->parent->post_types->role_caps as $role_cap_set  ) {
582
-			foreach ( $role_cap_set as $role_key => $capabilities_array ) {
581
+		foreach ($this->parent->post_types->role_caps as $role_cap_set) {
582
+			foreach ($role_cap_set as $role_key => $capabilities_array) {
583 583
 				/* Get the role. */
584
-				$role = get_role( $role_key );
585
-				foreach ( $capabilities_array as $cap_name  ) {
584
+				$role = get_role($role_key);
585
+				foreach ($capabilities_array as $cap_name) {
586 586
 					/* If the role exists, add required capabilities for the plugin. */
587
-					if ( !empty( $role ) ) {
588
-						if ( !$role->has_cap( $cap_name ) ) {
589
-							$role->add_cap( $cap_name );
587
+					if ( ! empty($role)) {
588
+						if ( ! $role->has_cap($cap_name)) {
589
+							$role->add_cap($cap_name);
590 590
 						} // End If Statement
591 591
 					} // End If Statement
592 592
 				} // End For Loop
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
 	 * @return void
603 603
 	 */
604 604
 	public function set_default_quiz_grade_type() {
605
-		$args = array(	'post_type' 		=> 'quiz',
605
+		$args = array('post_type' 		=> 'quiz',
606 606
 						'posts_per_page' 		=> -1,
607 607
 						'post_status'		=> 'publish',
608 608
 						'suppress_filters' 	=> 0
609 609
 						);
610
-		$quizzes = get_posts( $args );
610
+		$quizzes = get_posts($args);
611 611
 
612
-		foreach( $quizzes as $quiz ) {
613
-			update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' );
614
-			update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' );
612
+		foreach ($quizzes as $quiz) {
613
+			update_post_meta($quiz->ID, '_quiz_grade_type', 'auto');
614
+			update_post_meta($quiz->ID, '_quiz_grade_type_disabled', '');
615 615
 		}
616 616
 	} // End set_default_quiz_grade_type
617 617
 
@@ -623,23 +623,23 @@  discard block
 block discarded – undo
623 623
 	 * @return void
624 624
 	 */
625 625
 	public function set_default_question_type() {
626
-		$args = array(	'post_type' 		=> 'question',
626
+		$args = array('post_type' 		=> 'question',
627 627
 						'posts_per_page' 		=> -1,
628 628
 						'post_status'		=> 'publish',
629 629
 						'suppress_filters' 	=> 0
630 630
 						);
631
-		$questions = get_posts( $args );
631
+		$questions = get_posts($args);
632 632
 
633 633
 		$already_run = true;
634
-		foreach( $questions as $question ) {
635
-			if( $already_run ) {
636
-				$terms = wp_get_post_terms( $question->ID, 'question-type' );
637
-				if( is_array( $terms ) && count( $terms ) > 0 ) {
634
+		foreach ($questions as $question) {
635
+			if ($already_run) {
636
+				$terms = wp_get_post_terms($question->ID, 'question-type');
637
+				if (is_array($terms) && count($terms) > 0) {
638 638
 					break;
639 639
 				}
640 640
 			}
641 641
 			$already_run = false;
642
-			wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' );
642
+			wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type');
643 643
 		}
644 644
 
645 645
 	} // End set_default_question_type
@@ -651,90 +651,90 @@  discard block
 block discarded – undo
651 651
 	 * @access public
652 652
 	 * @return boolean
653 653
 	 */
654
-	public function update_question_answer_data( $n = 50, $offset = 0 ) {
654
+	public function update_question_answer_data($n = 50, $offset = 0) {
655 655
 
656 656
 		// Get Total Number of Updates to run
657
-		$quiz_count_object = wp_count_posts( 'quiz' );
657
+		$quiz_count_object = wp_count_posts('quiz');
658 658
 		$quiz_count_published = $quiz_count_object->publish;
659 659
 
660 660
 		// Calculate if this is the last page
661
-		if ( 0 == $offset ) {
661
+		if (0 == $offset) {
662 662
 			$current_page = 1;
663 663
 		} else {
664
-			$current_page = intval( $offset / $n );
664
+			$current_page = intval($offset / $n);
665 665
 		} // End If Statement
666
-		$total_pages = intval( $quiz_count_published / $n );
666
+		$total_pages = intval($quiz_count_published / $n);
667 667
 
668 668
 
669
-		$args = array(	'post_type' 		=> 'quiz',
669
+		$args = array('post_type' 		=> 'quiz',
670 670
 						'posts_per_page' 		=> $n,
671 671
 						'offset'			=> $offset,
672 672
 						'post_status'		=> 'publish',
673 673
 						'suppress_filters' 	=> 0
674 674
 						);
675
-		$quizzes = get_posts( $args );
675
+		$quizzes = get_posts($args);
676 676
 
677 677
 		$old_answers = array();
678 678
 		$right_answers = array();
679 679
 		$old_user_answers = array();
680 680
 
681
-		if( is_array( $quizzes ) ) {
682
-			foreach( $quizzes as $quiz ) {
681
+		if (is_array($quizzes)) {
682
+			foreach ($quizzes as $quiz) {
683 683
 				$quiz_id = $quiz->ID;
684 684
 
685 685
 				// Get current user answers
686
-				$comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true  );
686
+				$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true);
687 687
 				// Need to always return an array, even with only 1 item
688
-				if ( !is_array($comments) ) {
689
-					$comments = array( $comments );
688
+				if ( ! is_array($comments)) {
689
+					$comments = array($comments);
690 690
 				}
691
-				foreach ( $comments as $comment ) {
691
+				foreach ($comments as $comment) {
692 692
 					$user_id = $comment->user_id;
693
-					$content = maybe_unserialize( base64_decode( $comment->comment_content ) );
694
-					$old_user_answers[ $quiz_id ][ $user_id ] = $content;
693
+					$content = maybe_unserialize(base64_decode($comment->comment_content));
694
+					$old_user_answers[$quiz_id][$user_id] = $content;
695 695
 				}
696 696
 
697 697
 				// Get correct answers
698
-				$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
699
-				if( is_array( $questions ) ) {
700
-					foreach( $questions as $question ) {
701
-						$right_answer = get_post_meta( $question->ID, '_question_right_answer', true );
702
-						$right_answers[ $quiz_id ][ $question->ID ] = $right_answer;
698
+				$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
699
+				if (is_array($questions)) {
700
+					foreach ($questions as $question) {
701
+						$right_answer = get_post_meta($question->ID, '_question_right_answer', true);
702
+						$right_answers[$quiz_id][$question->ID] = $right_answer;
703 703
 					}
704 704
 				}
705 705
 			}
706 706
 		}
707 707
 
708
-		if( is_array( $right_answers ) ) {
709
-			foreach( $right_answers as $quiz_id => $question ) {
708
+		if (is_array($right_answers)) {
709
+			foreach ($right_answers as $quiz_id => $question) {
710 710
 				$count = 0;
711
-				if( is_array( $question ) ) {
712
-					foreach( $question as $question_id => $answer ) {
711
+				if (is_array($question)) {
712
+					foreach ($question as $question_id => $answer) {
713 713
 						++$count;
714
-						if( isset( $old_user_answers[ $quiz_id ] ) ) {
715
-							$answers_linkup[ $quiz_id ][ $count ] = $question_id;
714
+						if (isset($old_user_answers[$quiz_id])) {
715
+							$answers_linkup[$quiz_id][$count] = $question_id;
716 716
 						}
717 717
 					}
718 718
 				}
719 719
 			}
720 720
 		}
721 721
 
722
-		if( is_array( $old_user_answers ) ) {
723
-			foreach( $old_user_answers as $quiz_id => $user_answers ) {
724
-				foreach( $user_answers as $user_id => $answers ) {
725
-					foreach( $answers as $answer_id => $user_answer ) {
726
-						$question_id = $answers_linkup[ $quiz_id ][ $answer_id ];
727
-						$new_user_answers[ $question_id ] = $user_answer;
728
-						Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id );
722
+		if (is_array($old_user_answers)) {
723
+			foreach ($old_user_answers as $quiz_id => $user_answers) {
724
+				foreach ($user_answers as $user_id => $answers) {
725
+					foreach ($answers as $answer_id => $user_answer) {
726
+						$question_id = $answers_linkup[$quiz_id][$answer_id];
727
+						$new_user_answers[$question_id] = $user_answer;
728
+						Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id);
729 729
 					}
730
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
731
-					Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
732
-					Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id );
730
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
731
+					Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
732
+					Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id);
733 733
 				}
734 734
 			}
735 735
 		}
736 736
 
737
-		if ( $current_page == $total_pages ) {
737
+		if ($current_page == $total_pages) {
738 738
 			return true;
739 739
 		} else {
740 740
 			return false;
@@ -749,15 +749,15 @@  discard block
 block discarded – undo
749 749
 	 * @return boolean
750 750
 	 */
751 751
 	public function update_question_grade_points() {
752
-		$args = array(	'post_type' 		=> 'question',
752
+		$args = array('post_type' 		=> 'question',
753 753
 						'posts_per_page' 		=> -1,
754 754
 						'post_status'		=> 'publish',
755 755
 						'suppress_filters' 	=> 0
756 756
 						);
757
-		$questions = get_posts( $args );
757
+		$questions = get_posts($args);
758 758
 
759
-		foreach( $questions as $question ) {
760
-			update_post_meta( $question->ID, '_question_grade', '1' );
759
+		foreach ($questions as $question) {
760
+			update_post_meta($question->ID, '_question_grade', '1');
761 761
 		}
762 762
 		return true;
763 763
 	} // End update_question_grade_points
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 * @return boolean
770 770
 	 */
771 771
 	public function convert_essay_paste_questions() {
772
-		$args = array(	'post_type' 		=> 'question',
772
+		$args = array('post_type' 		=> 'question',
773 773
 						'posts_per_page' 		=> -1,
774 774
 						'post_status'		=> 'publish',
775 775
 						'tax_query'			=> array(
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 						),
782 782
 						'suppress_filters' 	=> 0
783 783
 						);
784
-		$questions = get_posts( $args );
784
+		$questions = get_posts($args);
785 785
 
786
-		foreach( $questions as $question ) {
787
-			wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false );
786
+		foreach ($questions as $question) {
787
+			wp_set_object_terms($question->ID, 'multi-line', 'question-type', false);
788 788
 
789
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
790
-			if( 0 < intval( $quiz_id ) ) {
791
-				add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true );
789
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
790
+			if (0 < intval($quiz_id)) {
791
+				add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true);
792 792
 			}
793 793
 		}
794 794
 		return true;
@@ -800,33 +800,33 @@  discard block
 block discarded – undo
800 800
 	 * @since  1.5.0
801 801
 	 * @return boolean
802 802
 	 */
803
-	public function set_random_question_order( $n = 50, $offset = 0 ) {
803
+	public function set_random_question_order($n = 50, $offset = 0) {
804 804
 
805 805
 		// Get Total Number of Updates to run
806
-		$quiz_count_object = wp_count_posts( 'quiz' );
806
+		$quiz_count_object = wp_count_posts('quiz');
807 807
 		$quiz_count_published = $quiz_count_object->publish;
808 808
 
809 809
 		// Calculate if this is the last page
810
-		if ( 0 == $offset ) {
810
+		if (0 == $offset) {
811 811
 			$current_page = 1;
812 812
 		} else {
813
-			$current_page = intval( $offset / $n );
813
+			$current_page = intval($offset / $n);
814 814
 		} // End If Statement
815
-		$total_pages = intval( $quiz_count_published / $n );
815
+		$total_pages = intval($quiz_count_published / $n);
816 816
 
817
-		$args = array(	'post_type' 		=> 'quiz',
817
+		$args = array('post_type' 		=> 'quiz',
818 818
 						'post_status'		=> 'any',
819 819
 						'posts_per_page' 		=> $n,
820 820
 						'offset'			=> $offset,
821 821
 						'suppress_filters' 	=> 0
822 822
 						);
823
-		$quizzes = get_posts( $args );
823
+		$quizzes = get_posts($args);
824 824
 
825
-		foreach( $quizzes as $quiz ) {
826
-			update_post_meta( $quiz->ID, '_random_question_order', 'yes' );
825
+		foreach ($quizzes as $quiz) {
826
+			update_post_meta($quiz->ID, '_random_question_order', 'yes');
827 827
 		}
828 828
 
829
-		if ( $current_page == $total_pages ) {
829
+		if ($current_page == $total_pages) {
830 830
 			return true;
831 831
 		} else {
832 832
 			return false;
@@ -840,37 +840,37 @@  discard block
 block discarded – undo
840 840
 	 * @since  1.5.0
841 841
 	 * @return boolean
842 842
 	 */
843
-	public function set_default_show_question_count( $n = 50, $offset = 0 ) {
843
+	public function set_default_show_question_count($n = 50, $offset = 0) {
844 844
 
845
-		$args = array(	'post_type' 		=> 'quiz',
845
+		$args = array('post_type' 		=> 'quiz',
846 846
 						'post_status'		=> 'any',
847 847
 						'posts_per_page' 		=> $n,
848 848
 						'offset'			=> $offset,
849 849
 						'meta_key'			=> '_show_questions',
850 850
 						'suppress_filters' 	=> 0
851 851
 						);
852
-		$quizzes = get_posts( $args );
852
+		$quizzes = get_posts($args);
853 853
 
854
-		$total_quizzes = count( $quizzes );
854
+		$total_quizzes = count($quizzes);
855 855
 
856
-		if( 0 == intval( $total_quizzes ) ) {
856
+		if (0 == intval($total_quizzes)) {
857 857
 			return true;
858 858
 		}
859 859
 
860
-		foreach( $quizzes as $quiz ) {
861
-			delete_post_meta( $quiz->ID, '_show_questions' );
860
+		foreach ($quizzes as $quiz) {
861
+			delete_post_meta($quiz->ID, '_show_questions');
862 862
 		}
863 863
 
864
-		$total_pages = intval( $total_quizzes / $n );
864
+		$total_pages = intval($total_quizzes / $n);
865 865
 
866 866
 		// Calculate if this is the last page
867
-		if ( 0 == $offset ) {
867
+		if (0 == $offset) {
868 868
 			$current_page = 1;
869 869
 		} else {
870
-			$current_page = intval( $offset / $n );
870
+			$current_page = intval($offset / $n);
871 871
 		} // End If Statement
872 872
 
873
-		if ( $current_page == $total_pages ) {
873
+		if ($current_page == $total_pages) {
874 874
 			return true;
875 875
 		} else {
876 876
 			return false;
@@ -878,14 +878,14 @@  discard block
 block discarded – undo
878 878
 
879 879
 	}
880 880
 
881
-	public function remove_deleted_user_activity( $n = 50, $offset = 0 ) {
881
+	public function remove_deleted_user_activity($n = 50, $offset = 0) {
882 882
 
883
-		$all_activity = get_comments( array( 'status' => 'approve' ) );
883
+		$all_activity = get_comments(array('status' => 'approve'));
884 884
 		$activity_count = array();
885
-		foreach( $all_activity as $activity ) {
886
-			if( '' == $activity->comment_type ) continue;
887
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
888
-			if( 0 == $activity->user_id ) continue;
885
+		foreach ($all_activity as $activity) {
886
+			if ('' == $activity->comment_type) continue;
887
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
888
+			if (0 == $activity->user_id) continue;
889 889
 			$activity_count[] = $activity->comment_ID;
890 890
 		}
891 891
 
@@ -895,33 +895,33 @@  discard block
 block discarded – undo
895 895
 			'status' => 'approve'
896 896
 		);
897 897
 
898
-		$activities = get_comments( $args );
898
+		$activities = get_comments($args);
899 899
 
900
-		foreach( $activities as $activity ) {
901
-			if( '' == $activity->comment_type ) continue;
902
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
903
-			if( 0 == $activity->user_id ) continue;
900
+		foreach ($activities as $activity) {
901
+			if ('' == $activity->comment_type) continue;
902
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
903
+			if (0 == $activity->user_id) continue;
904 904
 
905
-			$user_exists = get_userdata( $activity->user_id );
905
+			$user_exists = get_userdata($activity->user_id);
906 906
 
907
-			if( ! $user_exists ) {
908
-				wp_delete_comment( intval( $activity->comment_ID ), true );
907
+			if ( ! $user_exists) {
908
+				wp_delete_comment(intval($activity->comment_ID), true);
909 909
 				wp_cache_flush();
910 910
 			}
911 911
 		}
912 912
 
913
-		$total_activities = count( $activity_count );
913
+		$total_activities = count($activity_count);
914 914
 
915
-		$total_pages = intval( $total_activities / $n );
915
+		$total_pages = intval($total_activities / $n);
916 916
 
917 917
 		// Calculate if this is the last page
918
-		if ( 0 == $offset ) {
918
+		if (0 == $offset) {
919 919
 			$current_page = 1;
920 920
 		} else {
921
-			$current_page = intval( $offset / $n );
921
+			$current_page = intval($offset / $n);
922 922
 		} // End If Statement
923 923
 
924
-		if ( $current_page >= $total_pages ) {
924
+		if ($current_page >= $total_pages) {
925 925
 			return true;
926 926
 		} else {
927 927
 			return false;
@@ -930,16 +930,16 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
 	public function add_teacher_role() {
933
-		add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) );
933
+		add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true));
934 934
 		return true;
935 935
 	}
936 936
 
937 937
 	public function add_sensei_caps() {
938
-		$role = get_role( 'administrator' );
938
+		$role = get_role('administrator');
939 939
 
940
-		if( ! is_null( $role ) ) {
941
-			$role->add_cap( 'manage_sensei' );
942
-			$role->add_cap( 'manage_sensei_grades' );
940
+		if ( ! is_null($role)) {
941
+			$role->add_cap('manage_sensei');
942
+			$role->add_cap('manage_sensei_grades');
943 943
 		}
944 944
 
945 945
 		return true;
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 			'suppress_filters' 	=> 0
954 954
 		);
955 955
 
956
-		$questions = get_posts( $args );
956
+		$questions = get_posts($args);
957 957
 
958
-		foreach( $questions as $question ) {
958
+		foreach ($questions as $question) {
959 959
 
960
-			if( ! isset( $question->ID ) ) continue;
960
+			if ( ! isset($question->ID)) continue;
961 961
 
962
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
962
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
963 963
 
964
-			$question_order = get_post_meta( $question->ID, '_quiz_question_order', true );
965
-			update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order );
964
+			$question_order = get_post_meta($question->ID, '_quiz_question_order', true);
965
+			update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order);
966 966
 
967 967
 		}
968 968
 
@@ -971,15 +971,15 @@  discard block
 block discarded – undo
971 971
 
972 972
 	public function update_quiz_settings() {
973 973
 
974
-		$settings = get_option( 'woothemes-sensei-settings', array() );
974
+		$settings = get_option('woothemes-sensei-settings', array());
975 975
 
976 976
 		$lesson_completion = false;
977
-		if( isset( $settings['lesson_completion'] ) ) {
977
+		if (isset($settings['lesson_completion'])) {
978 978
 			$lesson_completion = $settings['lesson_completion'];
979 979
 		}
980 980
 
981 981
 		$reset_quiz_allowed = false;
982
-		if( isset( $settings['quiz_reset_allowed'] ) ) {
982
+		if (isset($settings['quiz_reset_allowed'])) {
983 983
 			$reset_quiz_allowed = $settings['quiz_reset_allowed'];
984 984
 		}
985 985
 
@@ -990,20 +990,20 @@  discard block
 block discarded – undo
990 990
 			'suppress_filters' 	=> 0
991 991
 		);
992 992
 
993
-		$quizzes = get_posts( $args );
993
+		$quizzes = get_posts($args);
994 994
 
995
-		foreach( $quizzes as $quiz ) {
995
+		foreach ($quizzes as $quiz) {
996 996
 
997
-			if( ! isset( $quiz->ID ) ) continue;
997
+			if ( ! isset($quiz->ID)) continue;
998 998
 
999
-			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
1000
-				update_post_meta( $quiz->ID, '_pass_required', 'on' );
999
+			if (isset($lesson_completion) && 'passed' == $lesson_completion) {
1000
+				update_post_meta($quiz->ID, '_pass_required', 'on');
1001 1001
 			} else {
1002
-				update_post_meta( $quiz->ID, '_quiz_passmark', 0 );
1002
+				update_post_meta($quiz->ID, '_quiz_passmark', 0);
1003 1003
 			}
1004 1004
 
1005
-			if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) {
1006
-				update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' );
1005
+			if (isset($reset_quiz_allowed) && $reset_quiz_allowed) {
1006
+				update_post_meta($quiz->ID, '_enable_quiz_reset', 'on');
1007 1007
 			}
1008 1008
 		}
1009 1009
 
@@ -1018,22 +1018,22 @@  discard block
 block discarded – undo
1018 1018
 			'suppress_filters' 	=> 0
1019 1019
 		);
1020 1020
 
1021
-		$lessons = get_posts( $args );
1021
+		$lessons = get_posts($args);
1022 1022
 
1023
-		foreach( $lessons as $lesson ) {
1023
+		foreach ($lessons as $lesson) {
1024 1024
 
1025
-			if( ! isset( $lesson->ID ) ) continue;
1025
+			if ( ! isset($lesson->ID)) continue;
1026 1026
 
1027
-			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
1027
+			$course_id = get_post_meta($lesson->ID, '_lesson_course', true);
1028 1028
 
1029
-			if( $course_id ) {
1030
-				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
1029
+			if ($course_id) {
1030
+				update_post_meta($lesson->ID, '_order_'.$course_id, 0);
1031 1031
 			}
1032 1032
 
1033
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
1033
+            $module = Sensei()->modules->get_lesson_module($lesson->ID);
1034 1034
 
1035
-            if( $module ) {
1036
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
1035
+            if ($module) {
1036
+                update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0);
1037 1037
             }
1038 1038
 
1039 1039
 		}
@@ -1042,10 +1042,10 @@  discard block
 block discarded – undo
1042 1042
 	}
1043 1043
 
1044 1044
 	public function add_editor_caps() {
1045
-		$role = get_role( 'editor' );
1045
+		$role = get_role('editor');
1046 1046
 
1047
-		if( ! is_null( $role ) ) {
1048
-			$role->add_cap( 'manage_sensei_grades' );
1047
+		if ( ! is_null($role)) {
1048
+			$role->add_cap('manage_sensei_grades');
1049 1049
 		}
1050 1050
 
1051 1051
 		return true;
@@ -1064,26 +1064,26 @@  discard block
 block discarded – undo
1064 1064
 					WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%'
1065 1065
 						AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id
1066 1066
 						AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'";
1067
-		$wpdb->query( $sql );
1067
+		$wpdb->query($sql);
1068 1068
 
1069 1069
 		return true;
1070 1070
 	}
1071 1071
 
1072
-	public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) {
1073
-		$count_object = wp_count_posts( 'quiz' );
1072
+	public function update_quiz_lesson_relationship($n = 50, $offset = 0) {
1073
+		$count_object = wp_count_posts('quiz');
1074 1074
 
1075 1075
 		$count_published = 0;
1076
-		foreach ( $count_object AS $status => $count ) {
1076
+		foreach ($count_object AS $status => $count) {
1077 1077
 			$count_published += $count;
1078 1078
 		}
1079 1079
 
1080 1080
 		// Calculate if this is the last page
1081
-		if ( 0 == $offset ) {
1081
+		if (0 == $offset) {
1082 1082
 			$current_page = 1;
1083 1083
 		} else {
1084
-			$current_page = intval( $offset / $n );
1084
+			$current_page = intval($offset / $n);
1085 1085
 		}
1086
-		$total_pages = ceil( $count_published / $n );
1086
+		$total_pages = ceil($count_published / $n);
1087 1087
 
1088 1088
 		$args = array(
1089 1089
 			'post_type' => 'quiz',
@@ -1092,52 +1092,52 @@  discard block
 block discarded – undo
1092 1092
 			'post_status' => 'any'
1093 1093
 		);
1094 1094
 
1095
-		$quizzes = get_posts( $args );
1095
+		$quizzes = get_posts($args);
1096 1096
 
1097
-		foreach( $quizzes as $quiz ) {
1097
+		foreach ($quizzes as $quiz) {
1098 1098
 
1099
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
1099
+			if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue;
1100 1100
 
1101
-			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
1101
+			$lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true);
1102 1102
 
1103
-			if( empty( $lesson_id ) ) continue;
1103
+			if (empty($lesson_id)) continue;
1104 1104
 
1105 1105
 			$data = array(
1106 1106
 				'ID' => $quiz->ID,
1107 1107
 				'post_parent' => $lesson_id,
1108 1108
 			);
1109
-			wp_update_post( $data );
1109
+			wp_update_post($data);
1110 1110
 
1111
-			update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID );
1111
+			update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID);
1112 1112
 		}
1113 1113
 
1114
-		if ( $current_page == $total_pages || 0 == $total_pages ) {
1114
+		if ($current_page == $total_pages || 0 == $total_pages) {
1115 1115
 			return true;
1116 1116
 		} else {
1117 1117
 			return false;
1118 1118
 		}
1119 1119
 	}
1120 1120
 
1121
-	function status_changes_fix_lessons( $n = 50, $offset = 0 ) {
1121
+	function status_changes_fix_lessons($n = 50, $offset = 0) {
1122 1122
 		global $wpdb;
1123 1123
 
1124
-		$count_object = wp_count_posts( 'lesson' );
1124
+		$count_object = wp_count_posts('lesson');
1125 1125
 		$count_published = 0;
1126
-		foreach ( $count_object AS $status => $count ) {
1126
+		foreach ($count_object AS $status => $count) {
1127 1127
 			$count_published += $count;
1128 1128
 		}
1129 1129
 
1130
-		if ( 0 == $count_published ) {
1130
+		if (0 == $count_published) {
1131 1131
 			return true;
1132 1132
 		}
1133 1133
 
1134 1134
 		// Calculate if this is the last page
1135
-		if ( 0 == $offset ) {
1135
+		if (0 == $offset) {
1136 1136
 			$current_page = 1;
1137 1137
 		} else {
1138
-			$current_page = intval( $offset / $n );
1138
+			$current_page = intval($offset / $n);
1139 1139
 		}
1140
-		$total_pages = ceil( $count_published / $n );
1140
+		$total_pages = ceil($count_published / $n);
1141 1141
 
1142 1142
 		// Get all Lessons with (and without) Quizzes...
1143 1143
 		$args = array(
@@ -1147,26 +1147,26 @@  discard block
 block discarded – undo
1147 1147
 			'offset' => $offset,
1148 1148
 			'fields' => 'ids'
1149 1149
 		);
1150
-		$lesson_ids = get_posts( $args );
1150
+		$lesson_ids = get_posts($args);
1151 1151
 
1152 1152
 		// ...get all Quiz IDs for the above Lessons
1153
-		$id_list = join( ',', $lesson_ids );
1154
-		$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 );
1153
+		$id_list = join(',', $lesson_ids);
1154
+		$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);
1155 1155
 		$lesson_quiz_ids = array();
1156
-		if ( !empty($meta_list) ) {
1157
-			foreach ( $meta_list as $metarow ) {
1156
+		if ( ! empty($meta_list)) {
1157
+			foreach ($meta_list as $metarow) {
1158 1158
 				$lesson_id = $metarow['meta_value'];
1159 1159
 				$quiz_id = $metarow['post_id'];
1160
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1160
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1161 1161
 			}
1162 1162
 		}
1163 1163
 
1164 1164
 		// ...check all Quiz IDs for questions
1165
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1166
-		$meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A );
1165
+		$id_list = join(',', array_values($lesson_quiz_ids));
1166
+		$meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A);
1167 1167
 		$lesson_quiz_ids_with_questions = array();
1168
-		if ( !empty($meta_list) ) {
1169
-			foreach ( $meta_list as $metarow ) {
1168
+		if ( ! empty($meta_list)) {
1169
+			foreach ($meta_list as $metarow) {
1170 1170
 				$quiz_id = $metarow['meta_value'];
1171 1171
 				$lesson_quiz_ids_with_questions[] = $quiz_id;
1172 1172
 			}
@@ -1174,49 +1174,49 @@  discard block
 block discarded – undo
1174 1174
 
1175 1175
 		// For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons
1176 1176
 		// if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons
1177
-		$d_count = $a_count =0;
1178
-		foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) {
1179
-			if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1177
+		$d_count = $a_count = 0;
1178
+		foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) {
1179
+			if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1180 1180
 
1181 1181
 				// Quiz has no questions, drop the corresponding data
1182
-				delete_post_meta( $quiz_id, '_pass_required' );
1183
-				delete_post_meta( $quiz_id, '_quiz_passmark' );
1184
-				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1182
+				delete_post_meta($quiz_id, '_pass_required');
1183
+				delete_post_meta($quiz_id, '_quiz_passmark');
1184
+				delete_post_meta($lesson_id, '_quiz_has_questions');
1185 1185
 				$d_count++;
1186 1186
 			}
1187
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1187
+			else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1188 1188
 
1189 1189
 				// Quiz has no questions, drop the corresponding data
1190
-				update_post_meta( $lesson_id, '_quiz_has_questions', true );
1190
+				update_post_meta($lesson_id, '_quiz_has_questions', true);
1191 1191
 				$a_count++;
1192 1192
 			}
1193 1193
 		}
1194 1194
 
1195
-		if ( $current_page == $total_pages ) {
1195
+		if ($current_page == $total_pages) {
1196 1196
 			return true;
1197 1197
 		} else {
1198 1198
 			return false;
1199 1199
 		}
1200 1200
 	}
1201 1201
 
1202
-	function status_changes_convert_lessons( $n = 50, $offset = 0 ) {
1202
+	function status_changes_convert_lessons($n = 50, $offset = 0) {
1203 1203
 		global $wpdb;
1204 1204
 
1205
-		wp_defer_comment_counting( true );
1205
+		wp_defer_comment_counting(true);
1206 1206
 
1207
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1207
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1208 1208
 
1209
-		if ( 0 == $user_count_result ) {
1209
+		if (0 == $user_count_result) {
1210 1210
 			return true;
1211 1211
 		}
1212 1212
 
1213
-		if ( 0 == $offset ) {
1213
+		if (0 == $offset) {
1214 1214
 			$current_page = 1;
1215 1215
 		} else {
1216
-			$current_page = intval( $offset / $n );
1216
+			$current_page = intval($offset / $n);
1217 1217
 		}
1218 1218
 
1219
-		$total_pages = ceil( $user_count_result / $n );
1219
+		$total_pages = ceil($user_count_result / $n);
1220 1220
 
1221 1221
 		// Get all Lessons with Quizzes...
1222 1222
 		$args = array(
@@ -1231,34 +1231,34 @@  discard block
 block discarded – undo
1231 1231
 			),
1232 1232
 			'fields' => 'ids'
1233 1233
 		);
1234
-		$lesson_ids_with_quizzes = get_posts( $args );
1234
+		$lesson_ids_with_quizzes = get_posts($args);
1235 1235
 		// ...get all Quiz IDs for the above Lessons
1236
-		$id_list = join( ',', $lesson_ids_with_quizzes );
1237
-		$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 );
1236
+		$id_list = join(',', $lesson_ids_with_quizzes);
1237
+		$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);
1238 1238
 		$lesson_quiz_ids = array();
1239
-		if ( !empty($meta_list) ) {
1240
-			foreach ( $meta_list as $metarow ) {
1239
+		if ( ! empty($meta_list)) {
1240
+			foreach ($meta_list as $metarow) {
1241 1241
 				$lesson_id = $metarow['meta_value'];
1242 1242
 				$quiz_id = $metarow['post_id'];
1243
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1243
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1244 1244
 			}
1245 1245
 		}
1246 1246
 
1247 1247
 		// ...get all Pass Required & Passmarks for the above Lesson/Quizzes
1248
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1249
-		$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 );
1248
+		$id_list = join(',', array_values($lesson_quiz_ids));
1249
+		$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);
1250 1250
 		$quizzes_pass_required = $quizzes_passmarks = array();
1251
-		if ( !empty($meta_list) ) {
1252
-			foreach ( $meta_list as $metarow ) {
1253
-				if ( !empty($metarow['meta_value']) ) {
1251
+		if ( ! empty($meta_list)) {
1252
+			foreach ($meta_list as $metarow) {
1253
+				if ( ! empty($metarow['meta_value'])) {
1254 1254
 					$quiz_id = $metarow['post_id'];
1255 1255
 					$key = $metarow['meta_key'];
1256 1256
 					$value = $metarow['meta_value'];
1257
-					if ( '_pass_required' == $key ) {
1258
-						$quizzes_pass_required[ $quiz_id ] = $value;
1257
+					if ('_pass_required' == $key) {
1258
+						$quizzes_pass_required[$quiz_id] = $value;
1259 1259
 					}
1260
-					if ( '_quiz_passmark' == $key ) {
1261
-						$quizzes_passmarks[ $quiz_id ] = $value;
1260
+					if ('_quiz_passmark' == $key) {
1261
+						$quizzes_passmarks[$quiz_id] = $value;
1262 1262
 					}
1263 1263
 				}
1264 1264
 			}
@@ -1272,41 +1272,41 @@  discard block
 block discarded – undo
1272 1272
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' ";
1273 1273
 
1274 1274
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1275
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1275
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1276 1276
 
1277
-		foreach ( $user_ids AS $user_id ) {
1277
+		foreach ($user_ids AS $user_id) {
1278 1278
 
1279 1279
 			$lesson_ends = $lesson_grades = $lesson_answers = array();
1280 1280
 
1281 1281
 			// Pre-process the lesson ends
1282
-			$_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A );
1283
-			foreach ( $_lesson_ends as $lesson_end ) {
1282
+			$_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A);
1283
+			foreach ($_lesson_ends as $lesson_end) {
1284 1284
 				// This will overwrite existing entries with the newer ones
1285
-				$lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date'];
1285
+				$lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date'];
1286 1286
 			}
1287
-			unset( $_lesson_ends );
1287
+			unset($_lesson_ends);
1288 1288
 
1289 1289
 			// Pre-process the lesson grades
1290
-			$_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A );
1291
-			foreach ( $_lesson_grades as $lesson_grade ) {
1290
+			$_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A);
1291
+			foreach ($_lesson_grades as $lesson_grade) {
1292 1292
 				// This will overwrite existing entries with the newer ones (assuming the grade is higher)
1293
-				if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) {
1294
-					$lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content'];
1293
+				if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) {
1294
+					$lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content'];
1295 1295
 				}
1296 1296
 			}
1297
-			unset( $_lesson_grades );
1297
+			unset($_lesson_grades);
1298 1298
 
1299 1299
 			// Pre-process the lesson answers
1300
-			$_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A );
1301
-			foreach ( $_lesson_answers as $lesson_answer ) {
1300
+			$_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A);
1301
+			foreach ($_lesson_answers as $lesson_answer) {
1302 1302
 				// This will overwrite existing entries with the newer ones
1303
-				$lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content'];
1303
+				$lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content'];
1304 1304
 			}
1305
-			unset( $_lesson_answers );
1305
+			unset($_lesson_answers);
1306 1306
 
1307 1307
 			// Grab all the lesson starts for the user
1308
-			$lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1309
-			foreach ( $lesson_starts as $lesson_log ) {
1308
+			$lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1309
+			foreach ($lesson_starts as $lesson_log) {
1310 1310
 
1311 1311
 				$lesson_id = $lesson_log['comment_post_ID'];
1312 1312
 
@@ -1319,23 +1319,23 @@  discard block
 block discarded – undo
1319 1319
 					'start' => $status_date,
1320 1320
 				);
1321 1321
 				// Check if there is a lesson end
1322
-				if ( !empty($lesson_ends[$lesson_id]) ) {
1322
+				if ( ! empty($lesson_ends[$lesson_id])) {
1323 1323
 					$status_date = $lesson_ends[$lesson_id];
1324 1324
 					// Check lesson has quiz
1325
-					if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) {
1325
+					if ( ! empty($lesson_quiz_ids[$lesson_id])) {
1326 1326
 						// Check for the quiz answers
1327
-						if ( !empty($lesson_answers[$quiz_id]) ) {
1327
+						if ( ! empty($lesson_answers[$quiz_id])) {
1328 1328
 							$meta_data['questions_asked'] = $lesson_answers[$quiz_id];
1329 1329
 						}
1330 1330
 						// Check if there is a quiz grade
1331 1331
 						$quiz_id = $lesson_quiz_ids[$lesson_id];
1332
-						if ( !empty($lesson_grades[$quiz_id]) ) {
1332
+						if ( ! empty($lesson_grades[$quiz_id])) {
1333 1333
 							$meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id];
1334 1334
 							// Check if the user has to get the passmark and has or not
1335
-							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1335
+							if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) {
1336 1336
 								$status = 'passed';
1337 1337
 							}
1338
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1338
+							elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) {
1339 1339
 								$status = 'failed';
1340 1340
 							}
1341 1341
 							else {
@@ -1363,26 +1363,26 @@  discard block
 block discarded – undo
1363 1363
 						'comment_author' => '',
1364 1364
 					);
1365 1365
 				// Check it doesn't already exist
1366
-				$sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id );
1367
-				$comment_ID = $wpdb->get_var( $sql );
1368
-				if ( !$comment_ID ) {
1366
+				$sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id);
1367
+				$comment_ID = $wpdb->get_var($sql);
1368
+				if ( ! $comment_ID) {
1369 1369
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1370 1370
 					$wpdb->insert($wpdb->comments, $data);
1371 1371
 					$comment_ID = (int) $wpdb->insert_id;
1372 1372
 
1373
-					if ( $comment_ID && !empty($meta_data) ) {
1374
-						foreach ( $meta_data as $key => $value ) {
1373
+					if ($comment_ID && ! empty($meta_data)) {
1374
+						foreach ($meta_data as $key => $value) {
1375 1375
 							// Bypassing WP add_comment_meta(() so no actions/filters are run
1376
-							if ( $wpdb->get_var( $wpdb->prepare(
1376
+							if ($wpdb->get_var($wpdb->prepare(
1377 1377
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1378
-									$comment_ID, $key ) ) ) {
1378
+									$comment_ID, $key ))) {
1379 1379
 									continue; // Found the meta data already
1380 1380
 							}
1381
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1381
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1382 1382
 								'comment_id' => $comment_ID,
1383 1383
 								'meta_key' => $key,
1384 1384
 								'meta_value' => $value
1385
-							) );
1385
+							));
1386 1386
 						}
1387 1387
 					}
1388 1388
 				}
@@ -1390,40 +1390,40 @@  discard block
 block discarded – undo
1390 1390
 		}
1391 1391
 		$wpdb->flush();
1392 1392
 
1393
-		if ( $current_page == $total_pages ) {
1393
+		if ($current_page == $total_pages) {
1394 1394
 			return true;
1395 1395
 		} else {
1396 1396
 			return false;
1397 1397
 		}
1398 1398
 	}
1399 1399
 
1400
-	function status_changes_convert_courses( $n = 50, $offset = 0 ) {
1400
+	function status_changes_convert_courses($n = 50, $offset = 0) {
1401 1401
 		global $wpdb;
1402 1402
 
1403
-		wp_defer_comment_counting( true );
1403
+		wp_defer_comment_counting(true);
1404 1404
 
1405
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1405
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1406 1406
 
1407
-		if ( 0 == $user_count_result ) {
1407
+		if (0 == $user_count_result) {
1408 1408
 			return true;
1409 1409
 		}
1410 1410
 
1411
-		if ( 0 == $offset ) {
1411
+		if (0 == $offset) {
1412 1412
 			$current_page = 1;
1413 1413
 		} else {
1414
-			$current_page = intval( $offset / $n );
1414
+			$current_page = intval($offset / $n);
1415 1415
 		}
1416 1416
 
1417
-		$total_pages = ceil( $user_count_result / $n );
1417
+		$total_pages = ceil($user_count_result / $n);
1418 1418
 
1419 1419
 		// Get all Lesson => Course relationships
1420
-		$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 );
1420
+		$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);
1421 1421
 		$course_lesson_ids = array();
1422
-		if ( !empty($meta_list) ) {
1423
-			foreach ( $meta_list as $metarow ) {
1422
+		if ( ! empty($meta_list)) {
1423
+			foreach ($meta_list as $metarow) {
1424 1424
 				$lesson_id = $metarow['post_id'];
1425 1425
 				$course_id = $metarow['meta_value'];
1426
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1426
+				$course_lesson_ids[$course_id][] = $lesson_id;
1427 1427
 			}
1428 1428
 		}
1429 1429
 
@@ -1433,13 +1433,13 @@  discard block
 block discarded – undo
1433 1433
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' ";
1434 1434
 
1435 1435
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1436
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1436
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1437 1437
 
1438
-		foreach ( $user_ids AS $user_id ) {
1438
+		foreach ($user_ids AS $user_id) {
1439 1439
 
1440 1440
 			// Grab all the course starts for the user
1441
-			$course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1442
-			foreach ( $course_starts as $course_log ) {
1441
+			$course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1442
+			foreach ($course_starts as $course_log) {
1443 1443
 
1444 1444
 				$course_id = $course_log['comment_post_ID'];
1445 1445
 
@@ -1454,23 +1454,23 @@  discard block
 block discarded – undo
1454 1454
 					'percent' => 0,
1455 1455
 				);
1456 1456
 				// Check if the course has lessons
1457
-				if ( !empty( $course_lesson_ids[$course_id] ) ) {
1457
+				if ( ! empty($course_lesson_ids[$course_id])) {
1458 1458
 
1459 1459
 					$lessons_completed = 0;
1460
-					$total_lessons = count( $course_lesson_ids[ $course_id ] );
1460
+					$total_lessons = count($course_lesson_ids[$course_id]);
1461 1461
 
1462 1462
 					// Don't use prepare as we need to provide the id join
1463
-					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) );
1463
+					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id]));
1464 1464
 					// Get all lesson statuses for this Courses' lessons
1465
-					$lesson_statuses = $wpdb->get_results( $sql, ARRAY_A );
1465
+					$lesson_statuses = $wpdb->get_results($sql, ARRAY_A);
1466 1466
 					// Not enough lesson statuses, thus cannot be complete
1467
-					if ( $total_lessons > count($lesson_statuses) ) {
1467
+					if ($total_lessons > count($lesson_statuses)) {
1468 1468
 						$status = 'in-progress';
1469 1469
 					}
1470 1470
 					// Count each lesson to work out the overall percentage
1471
-					foreach ( $lesson_statuses as $lesson_status ) {
1471
+					foreach ($lesson_statuses as $lesson_status) {
1472 1472
 						$status_date = $lesson_status['comment_date'];
1473
-						switch ( $lesson_status['status'] ) {
1473
+						switch ($lesson_status['status']) {
1474 1474
 							case 'complete': // Lesson has no quiz/questions
1475 1475
 							case 'graded': // Lesson has quiz, but it's not important what the grade was
1476 1476
 							case 'passed':
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 						}
1486 1486
 					}
1487 1487
 					$meta_data['complete'] = $lessons_completed;
1488
-					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1488
+					$meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1489 1489
 				}
1490 1490
 				else {
1491 1491
 					// Course has no lessons, therefore cannot be 'complete'
@@ -1502,26 +1502,26 @@  discard block
 block discarded – undo
1502 1502
 						'comment_author' => '',
1503 1503
 					);
1504 1504
 				// Check it doesn't already exist
1505
-				$sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id );
1506
-				$comment_ID = $wpdb->get_var( $sql );
1507
-				if ( !$comment_ID ) {
1505
+				$sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id);
1506
+				$comment_ID = $wpdb->get_var($sql);
1507
+				if ( ! $comment_ID) {
1508 1508
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1509 1509
 					$wpdb->insert($wpdb->comments, $data);
1510 1510
 					$comment_ID = (int) $wpdb->insert_id;
1511 1511
 
1512
-					if ( $comment_ID && !empty($meta_data) ) {
1513
-						foreach ( $meta_data as $key => $value ) {
1512
+					if ($comment_ID && ! empty($meta_data)) {
1513
+						foreach ($meta_data as $key => $value) {
1514 1514
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1515
-							if ( $wpdb->get_var( $wpdb->prepare(
1515
+							if ($wpdb->get_var($wpdb->prepare(
1516 1516
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1517
-									$comment_ID, $key ) ) ) {
1517
+									$comment_ID, $key ))) {
1518 1518
 									continue; // Found the meta data already
1519 1519
 							}
1520
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1520
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1521 1521
 								'comment_id' => $comment_ID,
1522 1522
 								'meta_key' => $key,
1523 1523
 								'meta_value' => $value
1524
-							) );
1524
+							));
1525 1525
 						}
1526 1526
 					}
1527 1527
 				}
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		}
1530 1530
 		$wpdb->flush();
1531 1531
 
1532
-		if ( $current_page == $total_pages ) {
1532
+		if ($current_page == $total_pages) {
1533 1533
 			return true;
1534 1534
 		} else {
1535 1535
 			return false;
@@ -1545,70 +1545,70 @@  discard block
 block discarded – undo
1545 1545
 	 * @param type $offset
1546 1546
 	 * @return boolean
1547 1547
 	 */
1548
-	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
1548
+	function status_changes_repair_course_statuses($n = 50, $offset = 0) {
1549 1549
 		global $wpdb;
1550 1550
 
1551
-		$count_object = wp_count_posts( 'lesson' );
1551
+		$count_object = wp_count_posts('lesson');
1552 1552
 		$count_published = $count_object->publish;
1553 1553
 
1554
-		if ( 0 == $count_published ) {
1554
+		if (0 == $count_published) {
1555 1555
 			return true;
1556 1556
 		}
1557 1557
 
1558 1558
 		// Calculate if this is the last page
1559
-		if ( 0 == $offset ) {
1559
+		if (0 == $offset) {
1560 1560
 			$current_page = 1;
1561 1561
 		} else {
1562
-			$current_page = intval( $offset / $n );
1562
+			$current_page = intval($offset / $n);
1563 1563
 		}
1564
-		$total_pages = ceil( $count_published / $n );
1564
+		$total_pages = ceil($count_published / $n);
1565 1565
 
1566 1566
 		$course_lesson_ids = $lesson_user_statuses = array();
1567 1567
 
1568 1568
 		// Get all Lesson => Course relationships
1569
-		$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 );
1570
-		if ( !empty($meta_list) ) {
1571
-			foreach ( $meta_list as $metarow ) {
1569
+		$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);
1570
+		if ( ! empty($meta_list)) {
1571
+			foreach ($meta_list as $metarow) {
1572 1572
 				$lesson_id = $metarow['post_id'];
1573 1573
 				$course_id = $metarow['meta_value'];
1574
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1574
+				$course_lesson_ids[$course_id][] = $lesson_id;
1575 1575
 			}
1576 1576
 		}
1577 1577
 
1578 1578
 		// Get all Lesson => Course relationships
1579
-		$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 );
1580
-		if ( !empty($status_list) ) {
1581
-			foreach ( $status_list as $status ) {
1582
-				$lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved'];
1579
+		$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);
1580
+		if ( ! empty($status_list)) {
1581
+			foreach ($status_list as $status) {
1582
+				$lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved'];
1583 1583
 			}
1584 1584
 		}
1585 1585
 
1586
-		$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1586
+		$course_completion = Sensei()->settings->settings['course_completion'];
1587 1587
 
1588 1588
 		$per_page = 40;
1589 1589
 		$comment_id_offset = $count = 0;
1590 1590
 
1591 1591
 		$course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page";
1592 1592
 		// $per_page users at a time
1593
-		while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) {
1593
+		while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) {
1594 1594
 
1595
-			foreach ( $course_statuses AS $course_status ) {
1595
+			foreach ($course_statuses AS $course_status) {
1596 1596
 				$user_id = $course_status->user_id;
1597 1597
 				$course_id = $course_status->comment_post_ID;
1598
-				$total_lessons = count( $course_lesson_ids[ $course_id ] );
1599
-				if ( $total_lessons <= 0 ) {
1598
+				$total_lessons = count($course_lesson_ids[$course_id]);
1599
+				if ($total_lessons <= 0) {
1600 1600
 					$total_lessons = 1; // Fix division of zero error, some courses have no lessons
1601 1601
 				}
1602 1602
 				$lessons_completed = 0;
1603 1603
 				$status = 'in-progress';
1604 1604
 
1605 1605
 				// Some Courses have no lessons... (can they ever be complete?)
1606
-				if ( !empty($course_lesson_ids[ $course_id ]) ) {
1607
-					foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) {
1608
-						$lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ];
1606
+				if ( ! empty($course_lesson_ids[$course_id])) {
1607
+					foreach ($course_lesson_ids[$course_id] AS $lesson_id) {
1608
+						$lesson_status = $lesson_user_statuses[$lesson_id][$user_id];
1609 1609
 						// If lessons are complete without needing quizzes to be passed
1610
-						if ( 'passed' != $course_completion ) {
1611
-							switch ( $lesson_status ) {
1610
+						if ('passed' != $course_completion) {
1611
+							switch ($lesson_status) {
1612 1612
 								// A user cannot 'complete' a course if a lesson...
1613 1613
 								case 'in-progress': // ...is still in progress
1614 1614
 								case 'ungraded': // ...hasn't yet been graded
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 							}
1621 1621
 						}
1622 1622
 						else {
1623
-							switch ( $lesson_status ) {
1623
+							switch ($lesson_status) {
1624 1624
 								case 'complete': // Lesson has no quiz/questions
1625 1625
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
1626 1626
 								case 'passed': // Lesson has quiz and the user passed
@@ -1635,79 +1635,79 @@  discard block
 block discarded – undo
1635 1635
 						}
1636 1636
 					} // Each lesson
1637 1637
 				} // Check for lessons
1638
-				if ( $lessons_completed == $total_lessons ) {
1638
+				if ($lessons_completed == $total_lessons) {
1639 1639
 					$status = 'complete';
1640 1640
 				}
1641 1641
 				// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1642 1642
 				$metadata = array(
1643 1643
 					'complete' => $lessons_completed,
1644
-					'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ),
1644
+					'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)),
1645 1645
 				);
1646
-				Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata );
1646
+				Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata);
1647 1647
 				$count++;
1648 1648
 
1649 1649
 			} // per course status
1650 1650
 			$comment_id_offset = $course_status->comment_ID;
1651 1651
 		} // all course statuses
1652 1652
 
1653
-		if ( $current_page == $total_pages ) {
1653
+		if ($current_page == $total_pages) {
1654 1654
 			return true;
1655 1655
 		} else {
1656 1656
 			return false;
1657 1657
 		}
1658 1658
 	}
1659 1659
 
1660
-	function status_changes_convert_questions( $n = 50, $offset = 0 ) {
1660
+	function status_changes_convert_questions($n = 50, $offset = 0) {
1661 1661
 		global $wpdb;
1662 1662
 
1663
-		wp_defer_comment_counting( true );
1663
+		wp_defer_comment_counting(true);
1664 1664
 
1665
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1665
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1666 1666
 
1667
-		if ( 0 == $user_count_result ) {
1667
+		if (0 == $user_count_result) {
1668 1668
 			return true;
1669 1669
 		}
1670 1670
 
1671 1671
 		// Calculate if this is the last page
1672
-		if ( 0 == $offset ) {
1672
+		if (0 == $offset) {
1673 1673
 			$current_page = 1;
1674 1674
 		} else {
1675
-			$current_page = intval( $offset / $n );
1675
+			$current_page = intval($offset / $n);
1676 1676
 		}
1677 1677
 
1678
-		$total_pages = ceil( $user_count_result / $n );
1678
+		$total_pages = ceil($user_count_result / $n);
1679 1679
 
1680 1680
 		$users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d";
1681 1681
 		$answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID ";
1682 1682
 		$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 ";
1683 1683
 		$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 ";
1684 1684
 
1685
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1685
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1686 1686
 
1687
-		foreach ( $user_ids AS $user_id ) {
1687
+		foreach ($user_ids AS $user_id) {
1688 1688
 
1689 1689
 			$answer_grades = $answer_notes = array();
1690 1690
 
1691 1691
 			// Pre-process the answer grades
1692
-			$_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A );
1693
-			foreach ( $_answer_grades as $answer_grade ) {
1692
+			$_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A);
1693
+			foreach ($_answer_grades as $answer_grade) {
1694 1694
 				// This will overwrite existing entries with the newer ones
1695
-				$answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content'];
1695
+				$answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content'];
1696 1696
 			}
1697
-			unset( $_answer_grades );
1697
+			unset($_answer_grades);
1698 1698
 
1699 1699
 			// Pre-process the answer notes
1700
-			$_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A );
1701
-			foreach ( $_answer_notes as $answer_note ) {
1700
+			$_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A);
1701
+			foreach ($_answer_notes as $answer_note) {
1702 1702
 				// This will overwrite existing entries with the newer ones
1703
-				$answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content'];
1703
+				$answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content'];
1704 1704
 			}
1705
-			unset( $_answer_notes );
1705
+			unset($_answer_notes);
1706 1706
 
1707 1707
 			// Grab all the questions for the user
1708 1708
 			$sql = $wpdb->prepare($answers_sql, $user_id);
1709
-			$answers = $wpdb->get_results( $sql, ARRAY_A );
1710
-			foreach ( $answers as $answer ) {
1709
+			$answers = $wpdb->get_results($sql, ARRAY_A);
1710
+			foreach ($answers as $answer) {
1711 1711
 
1712 1712
 				// Excape data
1713 1713
 				$answer = wp_slash($answer);
@@ -1717,12 +1717,12 @@  discard block
 block discarded – undo
1717 1717
 				$meta_data = array();
1718 1718
 
1719 1719
 				// Check if the question has been graded, add as meta
1720
-				if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) {
1721
-					$meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ];
1720
+				if ( ! empty($answer_grades[$answer['comment_post_ID']])) {
1721
+					$meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']];
1722 1722
 				}
1723 1723
 				// Check if there is an answer note, add as meta
1724
-				if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) {
1725
-					$meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ];
1724
+				if ( ! empty($answer_notes[$answer['comment_post_ID']])) {
1725
+					$meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']];
1726 1726
 				}
1727 1727
 
1728 1728
 				// Wipe the unnessary data from the main comment
@@ -1735,21 +1735,21 @@  discard block
 block discarded – undo
1735 1735
 					);
1736 1736
 				$data = array_merge($answer, $data);
1737 1737
 
1738
-				$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
1739
-				if ( $rval ) {
1740
-					if ( !empty($meta_data) ) {
1741
-						foreach ( $meta_data as $key => $value ) {
1738
+				$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
1739
+				if ($rval) {
1740
+					if ( ! empty($meta_data)) {
1741
+						foreach ($meta_data as $key => $value) {
1742 1742
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1743
-							if ( $wpdb->get_var( $wpdb->prepare(
1743
+							if ($wpdb->get_var($wpdb->prepare(
1744 1744
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1745
-									$comment_ID, $key ) ) ) {
1745
+									$comment_ID, $key ))) {
1746 1746
 									continue; // Found the meta data already
1747 1747
 							}
1748
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1748
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1749 1749
 								'comment_id' => $comment_ID,
1750 1750
 								'meta_key' => $key,
1751 1751
 								'meta_value' => $value
1752
-							) );
1752
+							));
1753 1753
 						}
1754 1754
 					}
1755 1755
 				}
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 		}
1758 1758
 		$wpdb->flush();
1759 1759
 
1760
-		if ( $current_page == $total_pages ) {
1760
+		if ($current_page == $total_pages) {
1761 1761
 			return true;
1762 1762
 		} else {
1763 1763
 			return false;
@@ -1774,10 +1774,10 @@  discard block
 block discarded – undo
1774 1774
 		global $wpdb;
1775 1775
 
1776 1776
 		// Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts
1777
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " );
1777
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' ");
1778 1778
 
1779 1779
 		// Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required
1780
-		$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') " );
1780
+		$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') ");
1781 1781
 
1782 1782
 		return true;
1783 1783
 	}
@@ -1790,50 +1790,50 @@  discard block
 block discarded – undo
1790 1790
 	 * @param type $offset
1791 1791
 	 * @return boolean
1792 1792
 	 */
1793
-	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
1793
+	public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) {
1794 1794
 		global $wpdb;
1795 1795
 
1796
-		$item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " );
1796
+		$item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') ");
1797 1797
 
1798
-		if ( 0 == $item_count_result ) {
1798
+		if (0 == $item_count_result) {
1799 1799
 			return true;
1800 1800
 		}
1801 1801
 
1802 1802
 		// Calculate if this is the last page
1803
-		if ( 0 == $offset ) {
1803
+		if (0 == $offset) {
1804 1804
 			$current_page = 1;
1805 1805
 		} else {
1806
-			$current_page = intval( $offset / $n );
1806
+			$current_page = intval($offset / $n);
1807 1807
 		}
1808 1808
 
1809
-		$total_pages = ceil( $item_count_result / $n );
1809
+		$total_pages = ceil($item_count_result / $n);
1810 1810
 
1811 1811
 		// Recalculate all counts
1812
-		$items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) );
1813
-		foreach ( (array) $items as $post ) {
1812
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset));
1813
+		foreach ((array) $items as $post) {
1814 1814
 			// Code copied from wp_update_comment_count_now()
1815
-			$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) );
1816
-			$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) );
1815
+			$new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID));
1816
+			$wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID));
1817 1817
 
1818
-			clean_post_cache( $post->ID );
1818
+			clean_post_cache($post->ID);
1819 1819
 		}
1820 1820
 
1821
-		if ( $current_page == $total_pages ) {
1821
+		if ($current_page == $total_pages) {
1822 1822
 			return true;
1823 1823
 		} else {
1824 1824
 			return false;
1825 1825
 		}
1826 1826
 	}
1827 1827
 
1828
-	public function remove_legacy_comments () {
1828
+	public function remove_legacy_comments() {
1829 1829
 		global $wpdb;
1830 1830
 
1831
-		$result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) );
1831
+		$result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy'));
1832 1832
 
1833 1833
 		return true;
1834 1834
 	}
1835 1835
 
1836
-	public function index_comment_status_field () {
1836
+	public function index_comment_status_field() {
1837 1837
 		global $wpdb;
1838 1838
 
1839 1839
 		$wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )");
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
      * @since 1.8.0
1853 1853
      * @return bool;
1854 1854
      */
1855
-    public  function enhance_teacher_role ( ) {
1855
+    public  function enhance_teacher_role( ) {
1856 1856
 
1857 1857
         require_once('class-sensei-teacher.php');
1858 1858
         $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
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 	 * @access public
19 19
 	 * @since 1.0.0
20 20
 	 */
21
-	public function __construct () {
21
+	public function __construct() {
22 22
 	    parent::__construct(); // Required in extended classes.
23 23
 
24 24
         $this->token = 'woothemes-sensei-settings';
25
-        add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) );
25
+        add_action('init', array(__CLASS__, 'flush_rewrite_rules'));
26 26
 
27 27
         // Setup Admin Settings data
28
-        if ( is_admin() ) {
28
+        if (is_admin()) {
29 29
 
30 30
             $this->has_tabs 	= true;
31
-            $this->name 		= __( 'Sensei Settings', 'woothemes-sensei' );
32
-            $this->menu_label	= __( 'Settings', 'woothemes-sensei' );
31
+            $this->name = __('Sensei Settings', 'woothemes-sensei');
32
+            $this->menu_label = __('Settings', 'woothemes-sensei');
33 33
             $this->page_slug	= 'woothemes-sensei-settings';
34 34
 
35 35
         } // End If Statement
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
      * @param string $setting_name
47 47
      * @return mixed
48 48
      */
49
-    public function get( $setting_name ){
49
+    public function get($setting_name) {
50 50
 
51
-        if( isset( $this->settings[ $setting_name ] ) ){
51
+        if (isset($this->settings[$setting_name])) {
52 52
 
53
-            return $this->settings[ $setting_name ];
53
+            return $this->settings[$setting_name];
54 54
 
55 55
         }
56 56
 
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 	 * @since  1.0.0
64 64
 	 * @return void
65 65
 	 */
66
-	public function register_settings_screen () {
66
+	public function register_settings_screen() {
67 67
 
68 68
 		$this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen.
69
-		$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
69
+		$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
70 70
 		$this->hook = $hook;
71 71
 
72
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
73
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
74
-			add_action( 'admin_notices', array( $this, 'language_pack_notices' ) );
75
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
76
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
72
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
73
+			add_action('admin_notices', array($this, 'settings_errors'));
74
+			add_action('admin_notices', array($this, 'language_pack_notices'));
75
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
76
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
77 77
 		}
78 78
 	} // End register_settings_screen()
79 79
 
@@ -83,49 +83,49 @@  discard block
 block discarded – undo
83 83
 	 * @since  1.0.0
84 84
 	 * @return void
85 85
 	 */
86
-	public function init_sections () {
86
+	public function init_sections() {
87 87
 		$sections = array();
88 88
 
89 89
 		$sections['default-settings'] = array(
90
-			'name' 			=> __( 'General', 'woothemes-sensei' ),
91
-			'description'	=> __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' )
90
+			'name' 			=> __('General', 'woothemes-sensei'),
91
+			'description'	=> __('Settings that apply to the entire plugin.', 'woothemes-sensei')
92 92
 		);
93 93
 
94 94
 		$sections['course-settings'] = array(
95
-			'name' 			=> __( 'Courses', 'woothemes-sensei' ),
96
-			'description'	=> __( 'Settings that apply to all Courses.', 'woothemes-sensei' )
95
+			'name' 			=> __('Courses', 'woothemes-sensei'),
96
+			'description'	=> __('Settings that apply to all Courses.', 'woothemes-sensei')
97 97
 		);
98 98
 
99 99
 		$sections['lesson-settings'] = array(
100
-			'name' 			=> __( 'Lessons', 'woothemes-sensei' ),
101
-			'description'	=> __( 'Settings that apply to all Lessons.', 'woothemes-sensei' )
100
+			'name' 			=> __('Lessons', 'woothemes-sensei'),
101
+			'description'	=> __('Settings that apply to all Lessons.', 'woothemes-sensei')
102 102
 		);
103 103
 
104 104
 		$sections['email-notification-settings'] = array(
105
-			'name' 			=> __( 'Email Notifications', 'woothemes-sensei' ),
106
-			'description'	=> __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' )
105
+			'name' 			=> __('Email Notifications', 'woothemes-sensei'),
106
+			'description'	=> __('Settings for email notifications sent from your site.', 'woothemes-sensei')
107 107
 		);
108 108
 
109 109
 		$sections['learner-profile-settings'] = array(
110
-			'name' 			=> __( 'Learner Profiles', 'woothemes-sensei' ),
111
-			'description'	=> __( 'Settings for public Learner Profiles.', 'woothemes-sensei' )
110
+			'name' 			=> __('Learner Profiles', 'woothemes-sensei'),
111
+			'description'	=> __('Settings for public Learner Profiles.', 'woothemes-sensei')
112 112
 		);
113 113
 
114
-		if ( Sensei_WC::is_woocommerce_present() ) {
114
+		if (Sensei_WC::is_woocommerce_present()) {
115 115
 			$sections['woocommerce-settings'] = array(
116
-				'name' 			=> __( 'WooCommerce', 'woothemes-sensei' ),
117
-				'description'	=> __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' )
116
+				'name' 			=> __('WooCommerce', 'woothemes-sensei'),
117
+				'description'	=> __('Optional settings for WooCommerce functions.', 'woothemes-sensei')
118 118
 			);
119 119
 		} // End If Statement
120 120
 
121
-		if ( 'en_US' !== get_locale() ) {
121
+		if ('en_US' !== get_locale()) {
122 122
 			$sections['language-settings'] = array(
123
-				'name' 			=> __( 'Language', 'woothemes-sensei' ),
124
-				'description'	=> __( 'Language options.', 'woothemes-sensei' )
123
+				'name' 			=> __('Language', 'woothemes-sensei'),
124
+				'description'	=> __('Language options.', 'woothemes-sensei')
125 125
 			);
126 126
 		}
127 127
 
128
-		$this->sections = apply_filters( 'sensei_settings_tabs', $sections );
128
+		$this->sections = apply_filters('sensei_settings_tabs', $sections);
129 129
 	} // End init_sections()
130 130
 
131 131
 	/**
@@ -135,71 +135,71 @@  discard block
 block discarded – undo
135 135
 	 * @uses   Sensei_Utils::get_slider_types()
136 136
 	 * @return void
137 137
 	 */
138
-	public function init_fields () {
138
+	public function init_fields() {
139 139
 		global $pagenow;
140 140
 
141 141
 		$pages_array = $this->pages_array();
142
-		$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' );
143
-		$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' ) );
144
-		$course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) );
142
+		$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');
143
+		$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'));
144
+		$course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei'));
145 145
 
146 146
 	    $fields = array();
147 147
 
148 148
 		$fields['access_permission'] = array(
149
-								'name' => __( 'Access Permissions', 'woothemes-sensei' ),
150
-								'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ),
149
+								'name' => __('Access Permissions', 'woothemes-sensei'),
150
+								'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'),
151 151
 								'type' => 'checkbox',
152 152
 								'default' => true,
153 153
 								'section' => 'default-settings'
154 154
 								);
155 155
 
156 156
 		$fields['messages_disable'] = array(
157
-								'name' => __( 'Disable Private Messages', 'woothemes-sensei' ),
158
-								'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ),
157
+								'name' => __('Disable Private Messages', 'woothemes-sensei'),
158
+								'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'),
159 159
 								'type' => 'checkbox',
160 160
 								'default' => false,
161 161
 								'section' => 'default-settings'
162 162
 								);
163 163
 
164 164
 		$fields['course_page'] = array(
165
-								'name' => __( 'Course Archive Page', 'woothemes-sensei' ),
166
-								'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ),
165
+								'name' => __('Course Archive Page', 'woothemes-sensei'),
166
+								'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'),
167 167
 								'type' => 'select',
168
-								'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ),
168
+								'default' => get_option('woothemes-sensei_courses_page_id', 0),
169 169
 								'section' => 'default-settings',
170 170
 								'required' => 0,
171 171
 								'options' => $pages_array
172 172
 								);
173 173
 
174 174
 		$fields['my_course_page'] = array(
175
-								'name' => __( 'My Courses Page', 'woothemes-sensei' ),
176
-								'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' ),
175
+								'name' => __('My Courses Page', 'woothemes-sensei'),
176
+								'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 177
 								'type' => 'select',
178
-								'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ),
178
+								'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0),
179 179
 								'section' => 'default-settings',
180 180
 								'required' => 0,
181 181
 								'options' => $pages_array
182 182
 								);
183 183
 
184 184
 		$fields['placeholder_images_enable'] = array(
185
-								'name' => __( 'Use placeholder images', 'woothemes-sensei' ),
186
-								'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ),
185
+								'name' => __('Use placeholder images', 'woothemes-sensei'),
186
+								'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'),
187 187
 								'type' => 'checkbox',
188 188
 								'default' => false,
189 189
 								'section' => 'default-settings'
190 190
 								);
191 191
 
192 192
 		$fields['styles_disable'] = array(
193
-								'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ),
194
-								'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ),
193
+								'name' => __('Disable Sensei Styles', 'woothemes-sensei'),
194
+								'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'),
195 195
 								'type' => 'checkbox',
196 196
 								'default' => false,
197 197
 								'section' => 'default-settings'
198 198
 								);
199 199
 
200 200
 		$fields['js_disable'] = array(
201
-								'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ),
202
-								'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ),
201
+								'name' => __('Disable Sensei Javascript', 'woothemes-sensei'),
202
+								'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'),
203 203
 								'type' => 'checkbox',
204 204
 								'default' => false,
205 205
 								'section' => 'default-settings'
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
     	// Course Settings
209 209
 
210 210
     	$fields['course_completion'] = array(
211
-								'name' => __( 'Courses are complete:', 'woothemes-sensei' ),
212
-								'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ),
211
+								'name' => __('Courses are complete:', 'woothemes-sensei'),
212
+								'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'),
213 213
 								'type' => 'select',
214 214
 								'default' => 'passed',
215 215
 								'section' => 'course-settings',
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 								);
219 219
 
220 220
     	$fields['course_author'] = array(
221
-								'name' => __( 'Display Course Author', 'woothemes-sensei' ),
222
-								'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ),
221
+								'name' => __('Display Course Author', 'woothemes-sensei'),
222
+								'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'),
223 223
 								'type' => 'checkbox',
224 224
 								'default' => true,
225 225
 								'section' => 'course-settings'
226 226
 								);
227 227
 
228 228
 		$fields['my_course_amount'] = array(
229
-								'name' => __( 'My Courses Pagination', 'woothemes-sensei' ),
230
-								'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ),
229
+								'name' => __('My Courses Pagination', 'woothemes-sensei'),
230
+								'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'),
231 231
 								'type' => 'range',
232 232
 								'default' => '0',
233 233
 								'section' => 'course-settings',
@@ -236,16 +236,16 @@  discard block
 block discarded – undo
236 236
 								);
237 237
 
238 238
 		$fields['course_archive_image_enable'] = array(
239
-								'name' => __( 'Course Archive Image', 'woothemes-sensei' ),
240
-								'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ),
239
+								'name' => __('Course Archive Image', 'woothemes-sensei'),
240
+								'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'),
241 241
 								'type' => 'checkbox',
242 242
 								'default' => true,
243 243
 								'section' => 'course-settings'
244 244
 								);
245 245
 
246 246
 		$fields['course_archive_image_width'] = array(
247
-								'name' => __( 'Image Width - Archive', 'woothemes-sensei' ),
248
-								'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
247
+								'name' => __('Image Width - Archive', 'woothemes-sensei'),
248
+								'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
249 249
 								'type' => 'text',
250 250
 								'default' => '100',
251 251
 								'section' => 'course-settings',
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 								);
254 254
 
255 255
 		$fields['course_archive_image_height'] = array(
256
-								'name' => __( 'Image Height - Archive', 'woothemes-sensei' ),
257
-								'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ),
256
+								'name' => __('Image Height - Archive', 'woothemes-sensei'),
257
+								'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'),
258 258
 								'type' => 'text',
259 259
 								'default' => '100',
260 260
 								'section' => 'course-settings',
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
 								);
263 263
 
264 264
 		$fields['course_archive_image_hard_crop'] = array(
265
-								'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ),
266
-								'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>' ),
265
+								'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'),
266
+								'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 267
 								'type' => 'checkbox',
268 268
 								'default' => false,
269 269
 								'section' => 'course-settings'
270 270
 								);
271 271
 
272 272
 		$fields['course_single_image_enable'] = array(
273
-								'name' => __( 'Single Course Image', 'woothemes-sensei' ),
274
-								'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ),
273
+								'name' => __('Single Course Image', 'woothemes-sensei'),
274
+								'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'),
275 275
 								'type' => 'checkbox',
276 276
 								'default' => false,
277 277
 								'section' => 'course-settings'
278 278
 								);
279 279
 
280 280
 		$fields['course_single_image_width'] = array(
281
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
282
-								'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
281
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
282
+								'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
283 283
 								'type' => 'text',
284 284
 								'default' => '100',
285 285
 								'section' => 'course-settings',
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 								);
288 288
 
289 289
 		$fields['course_single_image_height'] = array(
290
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
291
-								'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ),
290
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
291
+								'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'),
292 292
 								'type' => 'text',
293 293
 								'default' => '100',
294 294
 								'section' => 'course-settings',
@@ -296,16 +296,16 @@  discard block
 block discarded – undo
296 296
 								);
297 297
 
298 298
 		$fields['course_single_image_hard_crop'] = array(
299
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
300
-								'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>' ),
299
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
300
+								'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 301
 								'type' => 'checkbox',
302 302
 								'default' => false,
303 303
 								'section' => 'course-settings'
304 304
 								);
305 305
 
306 306
 		$fields['course_single_content_display'] = array(
307
-								'name' => __( 'Single Course page displays:', 'woothemes-sensei' ),
308
-								'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ),
307
+								'name' => __('Single Course page displays:', 'woothemes-sensei'),
308
+								'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'),
309 309
 								'type' => 'select',
310 310
 								'default' => 'excerpt',
311 311
 								'section' => 'course-settings',
@@ -314,18 +314,18 @@  discard block
 block discarded – undo
314 314
 								);
315 315
 
316 316
 		$fields['course_archive_featured_enable'] = array(
317
-								'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ),
318
-								'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
317
+								'name' => __('Featured Courses Panel', 'woothemes-sensei'),
318
+								'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
319 319
 								'type' => 'checkbox',
320 320
 								'default' => true,
321 321
 								'section' => 'course-settings'
322 322
 								);
323 323
 
324 324
 		$fields['course_archive_more_link_text'] = array(
325
-								'name' => __( 'More link text', 'woothemes-sensei' ),
326
-								'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ),
325
+								'name' => __('More link text', 'woothemes-sensei'),
326
+								'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'),
327 327
 								'type' => 'text',
328
-								'default' => __ ( 'More', 'woothemes-sensei' ),
328
+								'default' => __('More', 'woothemes-sensei'),
329 329
 								'section' => 'course-settings',
330 330
 								'required' => 0
331 331
 								);
@@ -333,32 +333,32 @@  discard block
 block discarded – undo
333 333
 		// Lesson Settings
334 334
 
335 335
 		$fields['lesson_comments'] = array(
336
-								'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ),
337
-								'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' ),
336
+								'name' => __('Allow Comments for Lessons', 'woothemes-sensei'),
337
+								'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 338
 								'type' => 'checkbox',
339 339
 								'default' => true,
340 340
 								'section' => 'lesson-settings'
341 341
 								);
342 342
 
343 343
 		$fields['lesson_author'] = array(
344
-								'name' => __( 'Display Lesson Author', 'woothemes-sensei' ),
345
-								'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ),
344
+								'name' => __('Display Lesson Author', 'woothemes-sensei'),
345
+								'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'),
346 346
 								'type' => 'checkbox',
347 347
 								'default' => true,
348 348
 								'section' => 'lesson-settings'
349 349
 								);
350 350
 
351 351
 		$fields['course_lesson_image_enable'] = array(
352
-								'name' => __( 'Course Lesson Images', 'woothemes-sensei' ),
353
-								'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ),
352
+								'name' => __('Course Lesson Images', 'woothemes-sensei'),
353
+								'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'),
354 354
 								'type' => 'checkbox',
355 355
 								'default' => false,
356 356
 								'section' => 'lesson-settings'
357 357
 								);
358 358
 
359 359
 		$fields['lesson_archive_image_width'] = array(
360
-								'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ),
361
-								'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
360
+								'name' => __('Image Width - Course Lessons', 'woothemes-sensei'),
361
+								'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
362 362
 								'type' => 'text',
363 363
 								'default' => '100',
364 364
 								'section' => 'lesson-settings',
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 								);
367 367
 
368 368
 		$fields['lesson_archive_image_height'] = array(
369
-								'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ),
370
-								'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ),
369
+								'name' => __('Image Height - Course Lessons', 'woothemes-sensei'),
370
+								'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'),
371 371
 								'type' => 'text',
372 372
 								'default' => '100',
373 373
 								'section' => 'lesson-settings',
@@ -375,24 +375,24 @@  discard block
 block discarded – undo
375 375
 								);
376 376
 
377 377
 		$fields['lesson_archive_image_hard_crop'] = array(
378
-								'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ),
379
-								'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>' ),
378
+								'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'),
379
+								'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 380
 								'type' => 'checkbox',
381 381
 								'default' => false,
382 382
 								'section' => 'lesson-settings'
383 383
 								);
384 384
 
385 385
 		$fields['lesson_single_image_enable'] = array(
386
-								'name' => __( 'Single Lesson Images', 'woothemes-sensei' ),
387
-								'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ),
386
+								'name' => __('Single Lesson Images', 'woothemes-sensei'),
387
+								'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'),
388 388
 								'type' => 'checkbox',
389 389
 								'default' => false,
390 390
 								'section' => 'lesson-settings'
391 391
 								);
392 392
 
393 393
 		$fields['lesson_single_image_width'] = array(
394
-								'name' => __( 'Image Width - Single', 'woothemes-sensei' ),
395
-								'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
394
+								'name' => __('Image Width - Single', 'woothemes-sensei'),
395
+								'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
396 396
 								'type' => 'text',
397 397
 								'default' => '100',
398 398
 								'section' => 'lesson-settings',
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 								);
401 401
 
402 402
 		$fields['lesson_single_image_height'] = array(
403
-								'name' => __( 'Image Height - Single', 'woothemes-sensei' ),
404
-								'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ),
403
+								'name' => __('Image Height - Single', 'woothemes-sensei'),
404
+								'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'),
405 405
 								'type' => 'text',
406 406
 								'default' => '100',
407 407
 								'section' => 'lesson-settings',
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 								);
410 410
 
411 411
 		$fields['lesson_single_image_hard_crop'] = array(
412
-								'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ),
413
-								'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>' ),
412
+								'name' => __('Image Hard Crop - Single', 'woothemes-sensei'),
413
+								'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 414
 								'type' => 'checkbox',
415 415
 								'default' => false,
416 416
 								'section' => 'lesson-settings'
@@ -418,20 +418,20 @@  discard block
 block discarded – undo
418 418
 
419 419
 		// Learner Profile settings
420 420
 
421
-		$profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
422
-		$profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%';
421
+		$profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
422
+		$profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%';
423 423
 
424 424
 		$fields['learner_profile_enable'] = array(
425
-							'name' => __( 'Public learner profiles', 'woothemes-sensei' ),
426
-							'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ),
425
+							'name' => __('Public learner profiles', 'woothemes-sensei'),
426
+							'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example),
427 427
 							'type' => 'checkbox',
428 428
 							'default' => true,
429 429
 							'section' => 'learner-profile-settings'
430 430
 							);
431 431
 
432 432
 		$fields['learner_profile_show_courses'] = array(
433
-							'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ),
434
-							'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ),
433
+							'name' => __('Show learner\'s courses', 'woothemes-sensei'),
434
+							'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'),
435 435
 							'type' => 'checkbox',
436 436
 							'default' => true,
437 437
 							'section' => 'learner-profile-settings'
@@ -440,70 +440,70 @@  discard block
 block discarded – undo
440 440
 		// Email notifications
441 441
 
442 442
 		$learner_email_options = array(
443
-			'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ),
444
-			'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ),
443
+			'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'),
444
+			'learner-completed-course' => __('They complete a course', 'woothemes-sensei'),
445 445
 		);
446 446
 
447 447
 		$teacher_email_options = array(
448
-            'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ),
449
-            'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ),
450
-            'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ),
451
-            'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ),
452
-			'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ),
448
+            'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'),
449
+            'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'),
450
+            'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'),
451
+            'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'),
452
+			'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'),
453 453
 		);
454 454
 
455 455
 		$global_email_options = array(
456
-			'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ),
456
+			'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'),
457 457
 		);
458 458
 
459 459
 		$fields['email_learners'] = array(
460
-								'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ),
461
-								'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ),
460
+								'name' => __('Emails Sent to Learners', 'woothemes-sensei'),
461
+								'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'),
462 462
 								'type' => 'multicheck',
463 463
 								'options' => $learner_email_options,
464
-								'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ),
464
+								'defaults' => array('learner-graded-quiz', 'learner-completed-course'),
465 465
 								'section' => 'email-notification-settings'
466 466
 								);
467 467
 
468 468
 		$fields['email_teachers'] = array(
469
-								'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ),
470
-								'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ),
469
+								'name' => __('Emails Sent to Teachers', 'woothemes-sensei'),
470
+								'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'),
471 471
 								'type' => 'multicheck',
472 472
 								'options' => $teacher_email_options,
473
-								'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ),
473
+								'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'),
474 474
 								'section' => 'email-notification-settings'
475 475
 								);
476 476
 
477 477
 		$fields['email_global'] = array(
478
-								'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ),
479
-								'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ),
478
+								'name' => __('Emails Sent to All Users', 'woothemes-sensei'),
479
+								'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'),
480 480
 								'type' => 'multicheck',
481 481
 								'options' => $global_email_options,
482
-								'defaults' => array( 'new-message-reply' ),
482
+								'defaults' => array('new-message-reply'),
483 483
 								'section' => 'email-notification-settings'
484 484
 								);
485 485
 
486 486
 		$fields['email_from_name'] = array(
487
-								'name' => __( '"From" Name', 'woothemes-sensei' ),
488
-								'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ),
487
+								'name' => __('"From" Name', 'woothemes-sensei'),
488
+								'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'),
489 489
 								'type' => 'text',
490
-								'default' => get_bloginfo( 'name' ),
490
+								'default' => get_bloginfo('name'),
491 491
 								'section' => 'email-notification-settings',
492 492
 								'required' => 1
493 493
 								);
494 494
 
495 495
 		$fields['email_from_address'] = array(
496
-								'name' => __( '"From" Address', 'woothemes-sensei' ),
497
-								'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ),
496
+								'name' => __('"From" Address', 'woothemes-sensei'),
497
+								'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'),
498 498
 								'type' => 'text',
499
-								'default' => get_bloginfo( 'admin_email' ),
499
+								'default' => get_bloginfo('admin_email'),
500 500
 								'section' => 'email-notification-settings',
501 501
 								'required' => 1
502 502
 								);
503 503
 
504 504
 		$fields['email_header_image'] = array(
505
-								'name' => __( 'Header Image', 'woothemes-sensei' ),
506
-								'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>' ),
505
+								'name' => __('Header Image', 'woothemes-sensei'),
506
+								'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 507
 								'type' => 'text',
508 508
 								'default' => '',
509 509
 								'section' => 'email-notification-settings',
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 								);
512 512
 
513 513
 		$fields['email_footer_text'] = array(
514
-								'name' => __( 'Email Footer Text', 'woothemes-sensei' ),
515
-								'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ),
514
+								'name' => __('Email Footer Text', 'woothemes-sensei'),
515
+								'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'),
516 516
 								'type' => 'textarea',
517
-								'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ),
517
+								'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')),
518 518
 								'section' => 'email-notification-settings',
519 519
 								'required' => 0
520 520
 								);
521 521
 
522 522
 		$fields['email_base_color'] = array(
523
-								'name' => __( 'Base Colour', 'woothemes-sensei' ),
524
-								'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
523
+								'name' => __('Base Colour', 'woothemes-sensei'),
524
+								'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
525 525
 								'type' => 'color',
526 526
 								'default' => '#557da1',
527 527
 								'section' => 'email-notification-settings',
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 								);
530 530
 
531 531
 		$fields['email_background_color'] = array(
532
-								'name' => __( 'Background Colour', 'woothemes-sensei' ),
533
-								'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
532
+								'name' => __('Background Colour', 'woothemes-sensei'),
533
+								'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
534 534
 								'type' => 'color',
535 535
 								'default' => '#f5f5f5',
536 536
 								'section' => 'email-notification-settings',
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 								);
539 539
 
540 540
 		$fields['email_body_background_color'] = array(
541
-								'name' => __( 'Body Background Colour', 'woothemes-sensei' ),
542
-								'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
541
+								'name' => __('Body Background Colour', 'woothemes-sensei'),
542
+								'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
543 543
 								'type' => 'color',
544 544
 								'default' => '#fdfdfd',
545 545
 								'section' => 'email-notification-settings',
@@ -547,35 +547,35 @@  discard block
 block discarded – undo
547 547
 								);
548 548
 
549 549
 		$fields['email_text_color'] = array(
550
-								'name' => __( 'Body Text Colour', 'woothemes-sensei' ),
551
-								'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ),
550
+								'name' => __('Body Text Colour', 'woothemes-sensei'),
551
+								'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'),
552 552
 								'type' => 'color',
553 553
 								'default' => '#505050',
554 554
 								'section' => 'email-notification-settings',
555 555
 								'required' => 1
556 556
 								);
557 557
 
558
-		if ( Sensei_WC::is_woocommerce_present() ) {
558
+		if (Sensei_WC::is_woocommerce_present()) {
559 559
 			// WooCommerce Settings
560 560
     		$fields['woocommerce_enabled'] = array(
561
-									'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ),
562
-									'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ),
561
+									'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'),
562
+									'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'),
563 563
 									'type' => 'checkbox',
564 564
 									'default' => true,
565 565
 									'section' => 'woocommerce-settings'
566 566
 									);
567 567
 
568 568
 			$fields['course_archive_free_enable'] = array(
569
-									'name' => __( 'Free Courses Panel', 'woothemes-sensei' ),
570
-									'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
569
+									'name' => __('Free Courses Panel', 'woothemes-sensei'),
570
+									'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
571 571
 									'type' => 'checkbox',
572 572
 									'default' => true,
573 573
 									'section' => 'woocommerce-settings'
574 574
 									);
575 575
 
576 576
 			$fields['course_archive_paid_enable'] = array(
577
-									'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ),
578
-									'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ),
577
+									'name' => __('Paid Courses Panel', 'woothemes-sensei'),
578
+									'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'),
579 579
 									'type' => 'checkbox',
580 580
 									'default' => true,
581 581
 									'section' => 'woocommerce-settings'
@@ -583,18 +583,18 @@  discard block
 block discarded – undo
583 583
 
584 584
 		} // End If Statement
585 585
 
586
-		if ( 'en_US' !== get_locale() ) {
586
+		if ('en_US' !== get_locale()) {
587 587
 			$fields['install_language_pack'] = array(
588
-				'name'        => __( 'Install Language Pack', 'woothemes-sensei' ),
589
-				'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ),
588
+				'name'        => __('Install Language Pack', 'woothemes-sensei'),
589
+				'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'),
590 590
 				'type'        => 'button',
591 591
 				'section'     => 'language-settings',
592 592
 				'target'      => Sensei_Language_Pack_Manager::get_install_uri(),
593
-				'label'       => __( 'Install', 'woothemes-sensei' )
593
+				'label'       => __('Install', 'woothemes-sensei')
594 594
 			);
595 595
 		}
596 596
 
597
-		$this->fields = apply_filters( 'sensei_settings_fields', $fields );
597
+		$this->fields = apply_filters('sensei_settings_fields', $fields);
598 598
 
599 599
 	} // End init_fields()
600 600
 
@@ -604,20 +604,20 @@  discard block
 block discarded – undo
604 604
 	 * @param  $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1.
605 605
 	 * @return array Options between 0.1 and 10 seconds.
606 606
 	 */
607
-	private function get_duration_options ( $include_milliseconds = true ) {
608
-		$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' );
607
+	private function get_duration_options($include_milliseconds = true) {
608
+		$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 609
 		$options = array();
610 610
 
611
-		if ( true == (bool)$include_milliseconds ) {
612
-			$milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' );
613
-			foreach ( $milliseconds as $k => $v ) {
611
+		if (true == (bool) $include_milliseconds) {
612
+			$milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9');
613
+			foreach ($milliseconds as $k => $v) {
614 614
 				$options[$v] = $v;
615 615
 			}
616 616
 		} else {
617 617
 			$options['0.5'] = '0.5';
618 618
 		}
619 619
 
620
-		foreach ( $numbers as $k => $v ) {
620
+		foreach ($numbers as $k => $v) {
621 621
 			$options[$v] = $v;
622 622
 		}
623 623
 
@@ -633,25 +633,25 @@  discard block
 block discarded – undo
633 633
 	private function pages_array() {
634 634
 		// REFACTOR - Transform this into a field type instead.
635 635
 		// Setup an array of portfolio gallery terms for a dropdown.
636
-		$args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' );
637
-		$pages_dropdown = wp_dropdown_pages( $args );
636
+		$args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC');
637
+		$pages_dropdown = wp_dropdown_pages($args);
638 638
 		$page_items = array();
639 639
 
640 640
 		// Quick string hack to make sure we get the pages with the indents.
641
-		$pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown );
642
-		$pages_dropdown = str_replace( '</select>', '', $pages_dropdown );
643
-		$pages_split = explode( '</option>', $pages_dropdown );
641
+		$pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown);
642
+		$pages_dropdown = str_replace('</select>', '', $pages_dropdown);
643
+		$pages_split = explode('</option>', $pages_dropdown);
644 644
 
645
-		$page_items[] = __( 'Select a Page:', 'woothemes-sensei' );
645
+		$page_items[] = __('Select a Page:', 'woothemes-sensei');
646 646
 
647
-		foreach ( $pages_split as $k => $v ) {
647
+		foreach ($pages_split as $k => $v) {
648 648
 		    $id = '';
649 649
 		    // Get the ID value.
650
-		    preg_match( '/value="(.*?)"/i', $v, $matches );
650
+		    preg_match('/value="(.*?)"/i', $v, $matches);
651 651
 
652
-		    if ( isset( $matches[1] ) ) {
652
+		    if (isset($matches[1])) {
653 653
 		        $id = $matches[1];
654
-		        $page_items[$id] = trim( strip_tags( $v ) );
654
+		        $page_items[$id] = trim(strip_tags($v));
655 655
 		    } // End If Statement
656 656
 		} // End For Loop
657 657
 
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
      *
676 676
      * @since 1.9.0
677 677
      */
678
-    public static function flush_rewrite_rules(){
678
+    public static function flush_rewrite_rules() {
679 679
 
680
-        if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ]
681
-            && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) {
680
+        if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page']
681
+            && isset($_POST['action']) && 'update' == $_POST['action']) {
682 682
 
683 683
             Sensei()->initiate_rewrite_rules_flush();
684 684
 
@@ -692,4 +692,4 @@  discard block
 block discarded – undo
692 692
  * @ignore only for backward compatibility
693 693
  * @since 1.9.0
694 694
  */
695
-class WooThemes_Sensei_Settings extends Sensei_Settings{}
695
+class WooThemes_Sensei_Settings extends Sensei_Settings {}
Please login to merge, or discard this patch.
includes/class-sensei-admin.php 1 patch
Spacing   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Handles all admin views, assets and navigation.
@@ -14,51 +14,51 @@  discard block
 block discarded – undo
14 14
 	 * Constructor.
15 15
 	 * @since  1.0.0
16 16
 	 */
17
-	public function __construct () {
17
+	public function __construct() {
18 18
 
19 19
         //register admin styles
20
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) );
20
+		add_action('admin_enqueue_scripts', array($this, 'admin_styles_global'));
21 21
 
22 22
         //register admin scripts
23
-        add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) );
23
+        add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
24 24
 
25
-		add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) );
26
-		add_action( 'settings_before_form', array( $this, 'install_pages_output' ) );
27
-		add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
28
-		add_action( 'menu_order', array( $this, 'admin_menu_order' ) );
29
-		add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) );
30
-		add_action( 'admin_init', array( $this, 'page_redirect' ) );
31
-		add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) );
32
-        add_action( 'admin_init', array( __CLASS__, 'install_pages' ));
25
+		add_action('admin_print_styles', array($this, 'admin_notices_styles'));
26
+		add_action('settings_before_form', array($this, 'install_pages_output'));
27
+		add_action('admin_menu', array($this, 'admin_menu'), 10);
28
+		add_action('menu_order', array($this, 'admin_menu_order'));
29
+		add_action('admin_head', array($this, 'admin_menu_highlight'));
30
+		add_action('admin_init', array($this, 'page_redirect'));
31
+		add_action('admin_init', array($this, 'sensei_add_custom_menu_items'));
32
+        add_action('admin_init', array(__CLASS__, 'install_pages'));
33 33
 
34 34
 		// Duplicate lesson & courses
35
-		add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 );
36
-		add_action( 'admin_action_duplicate_lesson', array( $this, 'duplicate_lesson_action' ) );
37
-		add_action( 'admin_action_duplicate_course', array( $this, 'duplicate_course_action' ) );
38
-		add_action( 'admin_action_duplicate_course_with_lessons', array( $this, 'duplicate_course_with_lessons_action' ) );
35
+		add_filter('post_row_actions', array($this, 'duplicate_action_link'), 10, 2);
36
+		add_action('admin_action_duplicate_lesson', array($this, 'duplicate_lesson_action'));
37
+		add_action('admin_action_duplicate_course', array($this, 'duplicate_course_action'));
38
+		add_action('admin_action_duplicate_course_with_lessons', array($this, 'duplicate_course_with_lessons_action'));
39 39
 
40 40
 		// Handle lessons list table filtering
41
-		add_action( 'restrict_manage_posts', array( $this, 'lesson_filter_options' ) );
42
-		add_filter( 'request', array( $this, 'lesson_filter_actions' ) );
41
+		add_action('restrict_manage_posts', array($this, 'lesson_filter_options'));
42
+		add_filter('request', array($this, 'lesson_filter_actions'));
43 43
 
44 44
 		// Add Sensei items to 'at a glance' widget
45
-		add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 );
45
+		add_filter('dashboard_glance_items', array($this, 'glance_items'), 10, 1);
46 46
 
47 47
 		// Handle course and lesson deletions
48
-		add_action( 'trash_course', array( $this, 'delete_content' ), 10, 2 );
49
-		add_action( 'trash_lesson', array( $this, 'delete_content' ), 10, 2 );
48
+		add_action('trash_course', array($this, 'delete_content'), 10, 2);
49
+		add_action('trash_lesson', array($this, 'delete_content'), 10, 2);
50 50
 
51 51
 		// Delete user activity when user is deleted
52
-		add_action( 'deleted_user', array( $this, 'delete_user_activity' ), 10, 1 );
52
+		add_action('deleted_user', array($this, 'delete_user_activity'), 10, 1);
53 53
 
54 54
 		// Add notices to WP dashboard
55
-		add_action( 'admin_notices', array( $this, 'theme_compatibility_notices' ) );
55
+		add_action('admin_notices', array($this, 'theme_compatibility_notices'));
56 56
 
57 57
 		// Reset theme notices when switching themes
58
-		add_action( 'switch_theme', array( $this, 'reset_theme_check_notices' ) );
58
+		add_action('switch_theme', array($this, 'reset_theme_check_notices'));
59 59
 
60 60
 		// Allow Teacher access the admin area
61
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'admin_access' ) );
61
+		add_filter('woocommerce_prevent_admin_access', array($this, 'admin_access'));
62 62
 
63 63
 	} // End __construct()
64 64
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	public function admin_menu() {
71 71
 		global $menu;
72 72
 		$menu_cap = '';
73
-		if( current_user_can( 'manage_sensei' ) ) {
73
+		if (current_user_can('manage_sensei')) {
74 74
 			$menu_cap = 'manage_sensei';
75 75
 		} else {
76
-			if( current_user_can( 'manage_sensei_grades' ) ) {
76
+			if (current_user_can('manage_sensei_grades')) {
77 77
 				$menu_cap = 'manage_sensei_grades';
78 78
 			}
79 79
 		}
80 80
 
81
-		if( $menu_cap ) {
82
-			$menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' );
83
-            add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' );
81
+		if ($menu_cap) {
82
+			$menu[] = array('', 'read', 'separator-sensei', '', 'wp-menu-separator sensei');
83
+            add_menu_page('Sensei', 'Sensei', $menu_cap, 'sensei', array(Sensei()->analysis, 'analysis_page'), '', '50');
84 84
 		}
85 85
 
86
-		add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) );
87
-		add_submenu_page( 'edit.php?post_type=lesson', __( 'Order Lessons', 'woothemes-sensei' ), __( 'Order Lessons', 'woothemes-sensei' ), 'edit_lessons', 'lesson-order', array( $this, 'lesson_order_screen' ) );
86
+		add_submenu_page('edit.php?post_type=course', __('Order Courses', 'woothemes-sensei'), __('Order Courses', 'woothemes-sensei'), 'manage_sensei', 'course-order', array($this, 'course_order_screen'));
87
+		add_submenu_page('edit.php?post_type=lesson', __('Order Lessons', 'woothemes-sensei'), __('Order Lessons', 'woothemes-sensei'), 'edit_lessons', 'lesson-order', array($this, 'lesson_order_screen'));
88 88
 	}
89 89
 
90 90
 	/**
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
 	 * @param  array $menu_order Existing menu order
94 94
 	 * @return array 			 Modified menu order for Sensei
95 95
 	 */
96
-	public function admin_menu_order( $menu_order ) {
96
+	public function admin_menu_order($menu_order) {
97 97
 
98 98
 		// Initialize our custom order array
99 99
 		$sensei_menu_order = array();
100 100
 
101 101
 		// Get the index of our custom separator
102
-		$sensei_separator = array_search( 'separator-sensei', $menu_order );
102
+		$sensei_separator = array_search('separator-sensei', $menu_order);
103 103
 
104 104
 		// Loop through menu order and do some rearranging
105
-		foreach ( $menu_order as $index => $item ) :
105
+		foreach ($menu_order as $index => $item) :
106 106
 
107
-			if ( ( ( 'sensei' ) == $item ) ) :
107
+			if ((('sensei') == $item)) :
108 108
 				$sensei_menu_order[] = 'separator-sensei';
109 109
 				$sensei_menu_order[] = $item;
110
-				unset( $menu_order[$sensei_separator] );
111
-			elseif ( !in_array( $item, array( 'separator-sensei' ) ) ) :
110
+				unset($menu_order[$sensei_separator]);
111
+			elseif ( ! in_array($item, array('separator-sensei'))) :
112 112
 				$sensei_menu_order[] = $item;
113 113
 			endif;
114 114
 
@@ -128,24 +128,24 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$screen = get_current_screen();
130 130
 
131
-		if ( $screen->base == 'post' && $post_type == 'course' ) {
131
+		if ($screen->base == 'post' && $post_type == 'course') {
132 132
 
133
-			$parent_file  = 'edit.php?post_type=course';
133
+			$parent_file = 'edit.php?post_type=course';
134 134
 
135
-		} elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) {
135
+		} elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') {
136 136
 
137 137
 			$submenu_file = 'edit-tags.php?taxonomy=course-category&amp;post_type=course';
138 138
 			$parent_file  = 'edit.php?post_type=course';
139 139
 
140
-        } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) {
140
+        } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') {
141 141
 
142 142
             $submenu_file = 'edit-tags.php?taxonomy=module';
143 143
             $parent_file  = 'edit.php?post_type=course';
144 144
 
145
-		} elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) {
145
+		} elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) {
146 146
 
147 147
             $submenu_file = 'edit.php?post_type=sensei_message';
148
-			$parent_file  = 'sensei';
148
+			$parent_file = 'sensei';
149 149
 
150 150
 		}
151 151
 	}
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 * @return void
157 157
 	 */
158 158
 	public function page_redirect() {
159
-		if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) {
160
-			wp_safe_redirect( 'admin.php?page=sensei_analysis' );
159
+		if (isset($_GET['page']) && $_GET['page'] == 'sensei') {
160
+			wp_safe_redirect('admin.php?page=sensei_analysis');
161 161
 			exit;
162 162
 		}
163 163
 	}
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	function install_pages_output() {
174 174
 
175
-        if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
175
+        if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) {
176 176
 
177 177
             ?>
178 178
             <div id="message" class="updated sensei-message sensei-connect">
179
-                <p><?php _e( '<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p>
179
+                <p><?php _e('<strong>Congratulations!</strong> &#8211; Sensei has been installed and set up.', 'woothemes-sensei'); ?></p>
180 180
                 <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a>
181 181
                 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
182 182
             </div>
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	 * @param int $post_parent (default: 0)
199 199
 	 * @return void
200 200
 	 */
201
-	function create_page( $slug, $option, $page_title = '', $page_content = '', $post_parent = 0 ) {
201
+	function create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0) {
202 202
 		global $wpdb;
203 203
 
204
-		$option_value = get_option( $option );
204
+		$option_value = get_option($option);
205 205
 
206
-		if ( $option_value > 0 && get_post( $option_value ) )
206
+		if ($option_value > 0 && get_post($option_value))
207 207
 			return;
208 208
 
209
-		$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );
210
-		if ( $page_found ) :
211
-			if ( ! $option_value )
212
-				update_option( $option, $page_found );
209
+		$page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug));
210
+		if ($page_found) :
211
+			if ( ! $option_value)
212
+				update_option($option, $page_found);
213 213
 			return;
214 214
 		endif;
215 215
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	        'post_parent' 		=> $post_parent,
224 224
 	        'comment_status' 	=> 'closed'
225 225
 	    );
226
-	    $page_id = wp_insert_post( $page_data );
226
+	    $page_id = wp_insert_post($page_data);
227 227
 
228
-	    update_option( $option, $page_id );
228
+	    update_option($option, $page_id);
229 229
 	} // End create_page()
230 230
 
231 231
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 	function create_pages() {
239 239
 
240 240
 		// Courses page
241
-	    $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' );
241
+	    $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]');
242 242
 
243 243
 		// User Dashboard page
244
-	    $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' );
244
+	    $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]');
245 245
 
246 246
 	} // End create_pages()
247 247
 
@@ -251,25 +251,25 @@  discard block
 block discarded – undo
251 251
 	 * @since 1.0.0
252 252
 	 * @return void
253 253
 	 */
254
-	public function admin_styles_global ( $hook ) {
254
+	public function admin_styles_global($hook) {
255 255
 		global $post_type;
256 256
 
257
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
258
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
259
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) );
257
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
258
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
259
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order'));
260 260
 
261 261
 		// Global Styles for icons and menu items
262
-		wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' );
263
-		wp_enqueue_style( 'woothemes-sensei-global' );
262
+		wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen');
263
+		wp_enqueue_style('woothemes-sensei-global');
264 264
 
265 265
         // Select 2 styles
266
-        wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' );
266
+        wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen');
267 267
 
268 268
 		// Test for Write Panel Pages
269
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
269
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
270 270
 
271
-			wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' );
272
-			wp_enqueue_style( 'woothemes-sensei-admin-custom' );
271
+			wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen');
272
+			wp_enqueue_style('woothemes-sensei-admin-custom');
273 273
 
274 274
 		}
275 275
 
@@ -284,20 +284,20 @@  discard block
 block discarded – undo
284 284
      * @since 1.8.2
285 285
      * @access public
286 286
      */
287
-    public function register_scripts( $hook ){
287
+    public function register_scripts($hook) {
288 288
 
289 289
         $screen = get_current_screen();
290 290
 
291 291
         // Allow developers to load non-minified versions of scripts
292
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
292
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
293 293
 
294 294
         // Select2 script used to enhance all select boxes
295
-        wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
295
+        wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version);
296 296
 
297 297
         // load edit module scripts
298
-        if( 'edit-module' ==  $screen->id ){
298
+        if ('edit-module' == $screen->id) {
299 299
 
300
-            wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true );
300
+            wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true);
301 301
 
302 302
         }
303 303
 
@@ -315,19 +315,19 @@  discard block
 block discarded – undo
315 315
 	    <div id="message" class="updated sensei-message sensei-connect">
316 316
 
317 317
             <p>
318
-                <?php _e( '<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?>
318
+                <?php _e('<strong>Welcome to Sensei</strong> &#8211; You\'re almost ready to create some courses!', 'woothemes-sensei'); ?>
319 319
             </p>
320 320
 
321 321
             <p class="submit">
322 322
 
323
-                <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>"
323
+                <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>"
324 324
                    class="button-primary">
325 325
 
326
-                    <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?>
326
+                    <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?>
327 327
 
328 328
                 </a>
329 329
 
330
-                <a class="skip button" href="<?php echo esc_url( add_query_arg( 'skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings' ) ) ); ?>">
330
+                <a class="skip button" href="<?php echo esc_url(add_query_arg('skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>">
331 331
 
332 332
                     <?php _e('Skip setup', 'woothemes-sensei'); ?>
333 333
 
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
 	    <div id="message" class="updated sensei-message sensei-connect">
351 351
 
352 352
 	    	<p>
353
-                <?php _e( '<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei' ); ?>
353
+                <?php _e('<strong>Sensei has been installed</strong> &#8211; You\'re ready to start creating courses!', 'woothemes-sensei'); ?>
354 354
             </p>
355 355
 
356 356
 			<p class="submit">
357
-                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
357
+                <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/">
358 358
                     <?php _e('Documentation', 'woothemes-sensei'); ?>
359 359
                 </a>
360 360
             </p>
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	public function language_pack_install_notice() {
388 388
 		?>
389 389
 		<div id="message" class="updated sensei-message sensei-connect">
390
-				<p><?php _e( '<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei' ); ?><p>
390
+				<p><?php _e('<strong>Sensei in your language</strong> &#8211; There is a translation available for your language.', 'woothemes-sensei'); ?><p>
391 391
 
392 392
 				<p class="submit">
393
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a>
394
-					<a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a>
393
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a>
394
+					<a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a>
395 395
 				</p>
396 396
 		</div>
397 397
 		<?php
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
 	function admin_notices_styles() {
408 408
 
409 409
 		// Installed notices
410
-	    if ( 1 == get_option( 'sensei_installed' ) ) {
410
+	    if (1 == get_option('sensei_installed')) {
411 411
 
412
-	    	wp_enqueue_style( 'sensei-activation', plugins_url(  '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version );
412
+	    	wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version);
413 413
 
414
-	    	if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) {
415
-	    		add_action( 'admin_notices', array( $this, 'admin_install_notice' ) );
416
-	    	} elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) {
417
-	    		add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) );
414
+	    	if (get_option('skip_install_sensei_pages') != 1 && Sensei()->get_page_id('course') < 1 && ! isset($_GET['install_sensei_pages']) && ! isset($_GET['skip_install_sensei_pages'])) {
415
+	    		add_action('admin_notices', array($this, 'admin_install_notice'));
416
+	    	} elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') {
417
+	    		add_action('admin_notices', array($this, 'admin_installed_notice'));
418 418
 	    	} // End If Statement
419 419
 
420 420
 	    } // End If Statement
421 421
 
422
-	    if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) {
423
-	    	add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) );
422
+	    if (Sensei_Language_Pack_Manager::has_language_pack_available()) {
423
+	    	add_action('admin_notices', array($this, 'language_pack_install_notice'));
424 424
 	    }
425 425
 
426 426
 	} // End admin_notices_styles()
@@ -431,17 +431,17 @@  discard block
 block discarded – undo
431 431
 	 * @param  object $post    Current post
432 432
 	 * @return array           Modified actions
433 433
 	 */
434
-	public function duplicate_action_link( $actions, $post ) {
435
-		switch( $post->post_type ) {
434
+	public function duplicate_action_link($actions, $post) {
435
+		switch ($post->post_type) {
436 436
 			case 'lesson':
437
-				$confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' );
438
-				$actions['duplicate'] = "<a onclick='return confirm(\"" . $confirm . "\");' href='" . $this->get_duplicate_link( $post->ID ) . "' title='" . esc_attr(__( 'Duplicate this lesson', 'woothemes-sensei' ) ) . "'>" .  __('Duplicate', 'woothemes-sensei' ) . "</a>";
437
+				$confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei');
438
+				$actions['duplicate'] = "<a onclick='return confirm(\"".$confirm."\");' href='".$this->get_duplicate_link($post->ID)."' title='".esc_attr(__('Duplicate this lesson', 'woothemes-sensei'))."'>".__('Duplicate', 'woothemes-sensei')."</a>";
439 439
 			break;
440 440
 
441 441
 			case 'course':
442
-				$confirm = __( 'This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei' );
443
-				$actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' .  __('Duplicate', 'woothemes-sensei' ) . '</a>';
444
-				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\'' . $confirm . '\');" href="' . $this->get_duplicate_link( $post->ID, true ) . '" title="' . esc_attr(__( 'Duplicate this course with its lessons', 'woothemes-sensei' ) ) . '">' .  __('Duplicate (with lessons)', 'woothemes-sensei' ) . '</a>';
442
+				$confirm = __('This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei');
443
+				$actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>';
444
+				$actions['duplicate_with_lessons'] = '<a onclick="return confirm(\''.$confirm.'\');" href="'.$this->get_duplicate_link($post->ID, true).'" title="'.esc_attr(__('Duplicate this course with its lessons', 'woothemes-sensei')).'">'.__('Duplicate (with lessons)', 'woothemes-sensei').'</a>';
445 445
 			break;
446 446
 		}
447 447
 
@@ -454,17 +454,17 @@  discard block
 block discarded – undo
454 454
 	 * @param  boolean $with_lessons Include lessons or not
455 455
 	 * @return string                Duplication link
456 456
 	 */
457
-	private function get_duplicate_link( $post_id = 0, $with_lessons = false ) {
457
+	private function get_duplicate_link($post_id = 0, $with_lessons = false) {
458 458
 
459
-		$post = get_post( $post_id );
459
+		$post = get_post($post_id);
460 460
 
461
-		$action = 'duplicate_' . $post->post_type;
461
+		$action = 'duplicate_'.$post->post_type;
462 462
 
463
-		if( 'course' == $post->post_type && $with_lessons ) {
463
+		if ('course' == $post->post_type && $with_lessons) {
464 464
 			$action .= '_with_lessons';
465 465
 		}
466 466
 
467
-		return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id );
467
+		return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id);
468 468
 	}
469 469
 
470 470
 	/**
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @return void
473 473
 	 */
474 474
 	public function duplicate_lesson_action() {
475
-		$this->duplicate_content( 'lesson' );
475
+		$this->duplicate_content('lesson');
476 476
 	}
477 477
 
478 478
 	/**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return void
481 481
 	 */
482 482
 	public function duplicate_course_action() {
483
-		$this->duplicate_content( 'course' );
483
+		$this->duplicate_content('course');
484 484
 	}
485 485
 
486 486
 	/**
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 	 * @return void
489 489
 	 */
490 490
 	public function duplicate_course_with_lessons_action() {
491
-		$this->duplicate_content( 'course', true );
491
+		$this->duplicate_content('course', true);
492 492
 	}
493 493
 
494 494
 	/**
@@ -497,34 +497,34 @@  discard block
 block discarded – undo
497 497
 	 * @param  boolean $with_lessons Include lessons or not
498 498
 	 * @return void
499 499
 	 */
500
-	private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) {
501
-		if ( ! isset( $_GET['post'] ) ) {
502
-			wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type );
500
+	private function duplicate_content($post_type = 'lesson', $with_lessons = false) {
501
+		if ( ! isset($_GET['post'])) {
502
+			wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type);
503 503
 		}
504 504
 
505 505
 		$post_id = $_GET['post'];
506
-		$post = get_post( $post_id );
506
+		$post = get_post($post_id);
507 507
 
508
-		if( ! is_wp_error( $post ) ) {
508
+		if ( ! is_wp_error($post)) {
509 509
 
510
-			$new_post = $this->duplicate_post( $post );
510
+			$new_post = $this->duplicate_post($post);
511 511
 
512
-			if( $new_post && ! is_wp_error( $new_post ) ) {
512
+			if ($new_post && ! is_wp_error($new_post)) {
513 513
 
514
-				if( 'lesson' == $new_post->post_type ) {
515
-					$this->duplicate_lesson_quizzes( $post_id, $new_post->ID );
514
+				if ('lesson' == $new_post->post_type) {
515
+					$this->duplicate_lesson_quizzes($post_id, $new_post->ID);
516 516
 				}
517 517
 
518
-				if( 'course' == $new_post->post_type && $with_lessons ) {
519
-					$this->duplicate_course_lessons( $post_id, $new_post->ID );
518
+				if ('course' == $new_post->post_type && $with_lessons) {
519
+					$this->duplicate_course_lessons($post_id, $new_post->ID);
520 520
 				}
521 521
 
522
-				$redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' );
522
+				$redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit');
523 523
 			} else {
524
-				$redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' );
524
+				$redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed');
525 525
 			}
526 526
 
527
-			wp_safe_redirect( esc_url_raw( $redirect_url ) );
527
+			wp_safe_redirect(esc_url_raw($redirect_url));
528 528
 			exit;
529 529
 		}
530 530
 	}
@@ -535,19 +535,19 @@  discard block
 block discarded – undo
535 535
 	 * @param  integer $new_lesson_id ID of duplicate lesson
536 536
 	 * @return void
537 537
 	 */
538
-	private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) {
538
+	private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) {
539 539
 
540
-        $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id );
541
-        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id );
540
+        $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id);
541
+        $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id);
542 542
 
543 543
         // duplicate the generic wp post information
544
-		$new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' );
544
+		$new_quiz = $this->duplicate_post(get_post($old_quiz_id), '');
545 545
 
546 546
 		//update the new lesson data
547
-        add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID );
547
+        add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID);
548 548
 
549 549
 		//update the new quiz data
550
-        add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id );
550
+        add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id);
551 551
         wp_update_post(
552 552
             array(
553 553
                 'ID' => $new_quiz->ID,
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
             )
556 556
         );
557 557
 
558
-		foreach( $old_quiz_questions as $question ) {
558
+		foreach ($old_quiz_questions as $question) {
559 559
 
560 560
 			// copy the question order over to the new quiz
561
-			$old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true );
562
-            $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order );
563
-            add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order );
561
+			$old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true);
562
+            $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order);
563
+            add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order);
564 564
 
565 565
 			// Add question to quiz
566
-			add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false );
566
+			add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false);
567 567
 
568 568
 		}
569 569
 	}
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 * @param  integer $new_course_id ID of duplicated course
575 575
 	 * @return void
576 576
 	 */
577
-	private function duplicate_course_lessons( $old_course_id, $new_course_id ) {
577
+	private function duplicate_course_lessons($old_course_id, $new_course_id) {
578 578
 		$lesson_args = array(
579 579
 			'post_type' => 'lesson',
580 580
 			'posts_per_page' => -1,
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
 			'meta_value' => $old_course_id,
583 583
 			'suppress_filters' 	=> 0
584 584
 		);
585
-		$lessons = get_posts( $lesson_args );
585
+		$lessons = get_posts($lesson_args);
586 586
 
587
-		foreach( $lessons as $lesson ) {
588
-			$new_lesson = $this->duplicate_post( $lesson, '', true );
589
-			add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id );
587
+		foreach ($lessons as $lesson) {
588
+			$new_lesson = $this->duplicate_post($lesson, '', true);
589
+			add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id);
590 590
 
591
-			$this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID );
591
+			$this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID);
592 592
 		}
593 593
 	}
594 594
 
@@ -599,24 +599,24 @@  discard block
 block discarded – undo
599 599
 	 * @param  boolean $ignore_course Ignore lesson course when dulicating
600 600
 	 * @return object                 Duplicate post object
601 601
 	 */
602
-	private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) {
602
+	private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) {
603 603
 
604 604
 		$new_post = array();
605 605
 
606
-		foreach( $post as $k => $v ) {
607
-			if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) {
608
-				$new_post[ $k ] = $v;
606
+		foreach ($post as $k => $v) {
607
+			if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) {
608
+				$new_post[$k] = $v;
609 609
 			}
610 610
 		}
611 611
 
612
-		$new_post['post_title'] .= __( $suffix, 'woothemes-sensei' );
612
+		$new_post['post_title'] .= __($suffix, 'woothemes-sensei');
613 613
 
614
-		$new_post['post_date'] = current_time( 'mysql' );
615
-		$new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] );
614
+		$new_post['post_date'] = current_time('mysql');
615
+		$new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']);
616 616
 		$new_post['post_modified'] = $new_post['post_date'];
617 617
 		$new_post['post_modified_gmt'] = $new_post['post_date_gmt'];
618 618
 
619
-		switch( $post->post_type ) {
619
+		switch ($post->post_type) {
620 620
 			case 'course': $new_post['post_status'] = 'draft'; break;
621 621
 			case 'lesson': $new_post['post_status'] = 'draft'; break;
622 622
 			case 'quiz': $new_post['post_status'] = 'publish'; break;
@@ -624,45 +624,45 @@  discard block
 block discarded – undo
624 624
 		}
625 625
 
626 626
 		// As per wp_update_post() we need to escape the data from the db.
627
-		$new_post = wp_slash( $new_post );
627
+		$new_post = wp_slash($new_post);
628 628
 
629
-		$new_post_id = wp_insert_post( $new_post );
629
+		$new_post_id = wp_insert_post($new_post);
630 630
 
631
-		if( ! is_wp_error( $new_post_id ) ) {
631
+		if ( ! is_wp_error($new_post_id)) {
632 632
 
633
-			$post_meta = get_post_custom( $post->ID );
634
-			if( $post_meta && count( $post_meta ) > 0 ) {
633
+			$post_meta = get_post_custom($post->ID);
634
+			if ($post_meta && count($post_meta) > 0) {
635 635
 
636
-				$ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' );
636
+				$ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz');
637 637
 
638
-				if( $ignore_course ) {
638
+				if ($ignore_course) {
639 639
 					$ignore_meta[] = '_lesson_course';
640 640
 				}
641 641
 
642
-				foreach( $post_meta as $key => $meta ) {
643
-					foreach( $meta as $value ) {
644
-						$value = maybe_unserialize( $value );
645
-						if( ! in_array( $key, $ignore_meta ) ) {
646
-							add_post_meta( $new_post_id, $key, $value );
642
+				foreach ($post_meta as $key => $meta) {
643
+					foreach ($meta as $value) {
644
+						$value = maybe_unserialize($value);
645
+						if ( ! in_array($key, $ignore_meta)) {
646
+							add_post_meta($new_post_id, $key, $value);
647 647
 						}
648 648
 					}
649 649
 				}
650 650
 			}
651 651
 
652
-			add_post_meta( $new_post_id, '_duplicate', $post->ID );
652
+			add_post_meta($new_post_id, '_duplicate', $post->ID);
653 653
 
654
-			$taxonomies = get_object_taxonomies( $post->post_type, 'objects' );
654
+			$taxonomies = get_object_taxonomies($post->post_type, 'objects');
655 655
 
656
-			foreach ( $taxonomies as $slug => $tax ) {
657
-				$terms = get_the_terms( $post->ID, $slug );
658
-				if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) {
659
-					foreach( $terms as $term ) {
660
-						wp_set_object_terms( $new_post_id, $term->term_id, $slug, true );
656
+			foreach ($taxonomies as $slug => $tax) {
657
+				$terms = get_the_terms($post->ID, $slug);
658
+				if (isset($terms) && is_array($terms) && 0 < count($terms)) {
659
+					foreach ($terms as $term) {
660
+						wp_set_object_terms($new_post_id, $term->term_id, $slug, true);
661 661
 					}
662 662
 				}
663 663
 			}
664 664
 
665
-			$new_post = get_post( $new_post_id );
665
+			$new_post = get_post($new_post_id);
666 666
 
667 667
 			return $new_post;
668 668
 		}
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	public function lesson_filter_options() {
678 678
 		global $typenow;
679 679
 
680
-		if( is_admin() && 'lesson' == $typenow ) {
680
+		if (is_admin() && 'lesson' == $typenow) {
681 681
 
682 682
 			$args = array(
683 683
 				'post_type' => 'course',
@@ -687,16 +687,16 @@  discard block
 block discarded – undo
687 687
 				'orderby' => 'menu_order date',
688 688
 				'order' => 'ASC',
689 689
 			);
690
-			$courses = get_posts( $args );
690
+			$courses = get_posts($args);
691 691
 
692
-			$selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
692
+			$selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
693 693
 			$course_options = '';
694
-			foreach( $courses as $course ) {
695
-				$course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>';
694
+			foreach ($courses as $course) {
695
+				$course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>';
696 696
 			}
697 697
 
698 698
 			$output = '<select name="lesson_course" id="dropdown_lesson_course">';
699
-			$output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>';
699
+			$output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>';
700 700
 			$output .= $course_options;
701 701
 			$output .= '</select>';
702 702
 
@@ -709,13 +709,13 @@  discard block
 block discarded – undo
709 709
 	 * @param  array $request Current request
710 710
 	 * @return array          Modified request
711 711
 	 */
712
-	public function lesson_filter_actions( $request ) {
712
+	public function lesson_filter_actions($request) {
713 713
 		global $typenow;
714 714
 
715
-		if( is_admin() && 'lesson' == $typenow ) {
716
-			$lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : '';
715
+		if (is_admin() && 'lesson' == $typenow) {
716
+			$lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : '';
717 717
 
718
-			if( $lesson_course ) {
718
+			if ($lesson_course) {
719 719
 				$request['meta_key'] = '_lesson_course';
720 720
 				$request['meta_value'] = $lesson_course;
721 721
 				$request['meta_compare'] = '=';
@@ -730,27 +730,27 @@  discard block
 block discarded – undo
730 730
 	 * @param  array $items Existing items
731 731
 	 * @return array        Updated items
732 732
 	 */
733
-	public function glance_items( $items = array() ) {
733
+	public function glance_items($items = array()) {
734 734
 
735
-		$types = array( 'course', 'lesson', 'question' );
735
+		$types = array('course', 'lesson', 'question');
736 736
 
737
-		foreach( $types as $type ) {
738
-			if( ! post_type_exists( $type ) ) continue;
737
+		foreach ($types as $type) {
738
+			if ( ! post_type_exists($type)) continue;
739 739
 
740
-			$num_posts = wp_count_posts( $type );
740
+			$num_posts = wp_count_posts($type);
741 741
 
742
-			if( $num_posts ) {
742
+			if ($num_posts) {
743 743
 
744
-				$published = intval( $num_posts->publish );
745
-				$post_type = get_post_type_object( $type );
744
+				$published = intval($num_posts->publish);
745
+				$post_type = get_post_type_object($type);
746 746
 
747
-				$text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' );
748
-				$text = sprintf( $text, number_format_i18n( $published ) );
747
+				$text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei');
748
+				$text = sprintf($text, number_format_i18n($published));
749 749
 
750
-				if ( current_user_can( $post_type->cap->edit_posts ) ) {
751
-					$items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n";
750
+				if (current_user_can($post_type->cap->edit_posts)) {
751
+					$items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n";
752 752
 				} else {
753
-					$items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n";
753
+					$items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n";
754 754
 				}
755 755
 			}
756 756
 		}
@@ -764,13 +764,13 @@  discard block
 block discarded – undo
764 764
 	 * @param  object  $post    Post object
765 765
 	 * @return void
766 766
 	 */
767
-	public function delete_content( $post_id, $post ) {
767
+	public function delete_content($post_id, $post) {
768 768
 
769 769
 		$type = $post->post_type;
770 770
 
771
-		if( in_array( $type, array( 'lesson', 'course' ) ) ) {
771
+		if (in_array($type, array('lesson', 'course'))) {
772 772
 
773
-			$meta_key = '_' . $type . '_prerequisite';
773
+			$meta_key = '_'.$type.'_prerequisite';
774 774
 
775 775
 			$args = array(
776 776
 				'post_type' => $type,
@@ -780,10 +780,10 @@  discard block
 block discarded – undo
780 780
 				'meta_value' => $post_id
781 781
 			);
782 782
 
783
-			$posts = get_posts( $args );
783
+			$posts = get_posts($args);
784 784
 
785
-			foreach( $posts as $post ) {
786
-				delete_post_meta( $post->ID, $meta_key );
785
+			foreach ($posts as $post) {
786
+				delete_post_meta($post->ID, $meta_key);
787 787
 			}
788 788
 		}
789 789
 	}
@@ -793,181 +793,181 @@  discard block
 block discarded – undo
793 793
 	 * @param  integer $user_id User ID
794 794
 	 * @return void
795 795
 	 */
796
-	public function delete_user_activity( $user_id = 0 ) {
797
-		if( $user_id ) {
798
-			Sensei_Utils::delete_all_user_activity( $user_id );
796
+	public function delete_user_activity($user_id = 0) {
797
+		if ($user_id) {
798
+			Sensei_Utils::delete_all_user_activity($user_id);
799 799
 		}
800 800
 	}
801 801
 
802
-	public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) {
802
+	public function render_settings($settings = array(), $post_id = 0, $group_id = '') {
803 803
 
804 804
 		$html = '';
805 805
 
806
-		if( 0 == count( $settings ) ) return $html;
806
+		if (0 == count($settings)) return $html;
807 807
 
808
-		$html .= '<div class="sensei-options-panel">' . "\n";
808
+		$html .= '<div class="sensei-options-panel">'."\n";
809 809
 
810
-			$html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n";
810
+			$html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n";
811 811
 
812
-				foreach( $settings as $field ) {
812
+				foreach ($settings as $field) {
813 813
 
814 814
 					$data = '';
815 815
 
816
-					if( $post_id ) {
817
-						$data = get_post_meta( $post_id, '_' . $field['id'], true );
818
-						if( ! $data && isset( $field['default'] ) ) {
816
+					if ($post_id) {
817
+						$data = get_post_meta($post_id, '_'.$field['id'], true);
818
+						if ( ! $data && isset($field['default'])) {
819 819
 							$data = $field['default'];
820 820
 						}
821 821
 					} else {
822
-						$option = get_option( $field['id'] );
823
-						if( isset( $field['default'] ) ) {
822
+						$option = get_option($field['id']);
823
+						if (isset($field['default'])) {
824 824
 							$data = $field['default'];
825
-							if( $option ) {
825
+							if ($option) {
826 826
 								$data = $option;
827 827
 							}
828 828
 						}
829 829
 					}
830 830
 
831 831
 					$disabled = '';
832
-					if( isset( $field['disabled'] ) && $field['disabled'] ) {
833
-						$disabled = disabled( $field['disabled'], true, false );
832
+					if (isset($field['disabled']) && $field['disabled']) {
833
+						$disabled = disabled($field['disabled'], true, false);
834 834
 					}
835 835
 
836
-					if( 'hidden' != $field['type'] ) {
836
+					if ('hidden' != $field['type']) {
837 837
 
838 838
 						$class_tail = '';
839 839
 
840
-						if( isset( $field['class'] ) ) {
840
+						if (isset($field['class'])) {
841 841
 							$class_tail .= $field['class'];
842 842
 						}
843 843
 
844
-						if( isset( $field['disabled'] ) && $field['disabled'] ) {
844
+						if (isset($field['disabled']) && $field['disabled']) {
845 845
 							$class_tail .= ' disabled';
846 846
 						}
847 847
 
848
-						$html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n";
848
+						$html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n";
849 849
 					}
850 850
 
851
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
852
-							$html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n";
851
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
852
+							$html .= '<label for="'.esc_attr($field['id']).'">'."\n";
853 853
 						}
854 854
 
855
-							if( $field['label'] ) {
856
-								$html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>';
855
+							if ($field['label']) {
856
+								$html .= '<span class="label">'.esc_html($field['label']).'</span>';
857 857
 							}
858 858
 
859
-							switch( $field['type'] ) {
859
+							switch ($field['type']) {
860 860
 								case 'text':
861 861
 								case 'password':
862
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n";
862
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n";
863 863
 								break;
864 864
 
865 865
 								case 'number':
866 866
 
867 867
 									$min = '';
868
-									if( isset( $field['min'] ) ) {
869
-										$min = 'min="' . esc_attr( $field['min'] ) . '"';
868
+									if (isset($field['min'])) {
869
+										$min = 'min="'.esc_attr($field['min']).'"';
870 870
 									}
871 871
 
872 872
 									$max = '';
873
-									if( isset( $field['max'] ) ) {
874
-										$max = 'max="' . esc_attr( $field['max'] ) . '"';
873
+									if (isset($field['max'])) {
874
+										$max = 'max="'.esc_attr($field['max']).'"';
875 875
 									}
876 876
 
877
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $min . '  ' . $max . ' class="small-text" ' . $disabled . ' />' . "\n";
877
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$min.'  '.$max.' class="small-text" '.$disabled.' />'."\n";
878 878
 								break;
879 879
 
880 880
 								case 'textarea':
881
-									$html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . $disabled . '>' . $data . '</textarea><br/>'. "\n";
881
+									$html .= '<textarea id="'.esc_attr($field['id']).'" rows="5" cols="50" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" '.$disabled.'>'.$data.'</textarea><br/>'."\n";
882 882
 								break;
883 883
 
884 884
 								case 'checkbox':
885 885
                                     //backwards compatibility
886
-                                    if( empty( $data ) || 'on' == $data ){
886
+                                    if (empty($data) || 'on' == $data) {
887 887
                                         $checked_value = 'on';
888
-                                    }elseif( 'yes' == $data  ) {
888
+                                    }elseif ('yes' == $data) {
889 889
 
890 890
                                         $checked_value = 'yes';
891 891
 
892
-                                    }elseif( 'auto' == $data  ) {
892
+                                    }elseif ('auto' == $data) {
893 893
 
894 894
                                         $checked_value = 'auto';
895 895
 
896 896
                                     } else {
897 897
                                         $checked_value = 1;
898
-                                        $data = intval( $data );
898
+                                        $data = intval($data);
899 899
                                     }
900
-									$checked = checked( $checked_value, $data, false );
901
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n";
900
+									$checked = checked($checked_value, $data, false);
901
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n";
902 902
 								break;
903 903
 
904 904
 								case 'checkbox_multi':
905
-									foreach( $field['options'] as $k => $v ) {
905
+									foreach ($field['options'] as $k => $v) {
906 906
 										$checked = false;
907
-										if( in_array( $k, $data ) ) {
907
+										if (in_array($k, $data)) {
908 908
 											$checked = true;
909 909
 										}
910
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
910
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="checkbox" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'[]" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
911 911
 									}
912 912
 								break;
913 913
 
914 914
 								case 'radio':
915
-									foreach( $field['options'] as $k => $v ) {
915
+									foreach ($field['options'] as $k => $v) {
916 916
 										$checked = false;
917
-										if( $k == $data ) {
917
+										if ($k == $data) {
918 918
 											$checked = true;
919 919
 										}
920
-										$html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n";
920
+										$html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="radio" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n";
921 921
 									}
922 922
 								break;
923 923
 
924 924
 								case 'select':
925
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n";
926
-									foreach( $field['options'] as $k => $v ) {
925
+									$html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n";
926
+									foreach ($field['options'] as $k => $v) {
927 927
 										$selected = false;
928
-										if( $k == $data ) {
928
+										if ($k == $data) {
929 929
 											$selected = true;
930 930
 										}
931
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n";
931
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n";
932 932
 									}
933
-									$html .= '</select><br/>' . "\n";
933
+									$html .= '</select><br/>'."\n";
934 934
 								break;
935 935
 
936 936
 								case 'select_multi':
937
-									$html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n";
938
-									foreach( $field['options'] as $k => $v ) {
937
+									$html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n";
938
+									foreach ($field['options'] as $k => $v) {
939 939
 										$selected = false;
940
-										if( in_array( $k, $data ) ) {
940
+										if (in_array($k, $data)) {
941 941
 											$selected = true;
942 942
 										}
943
-										$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n";
943
+										$html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n";
944 944
 									}
945 945
 									$html .= '</select> . "\n"';
946 946
 								break;
947 947
 
948 948
 								case 'hidden':
949
-									$html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n";
949
+									$html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n";
950 950
 								break;
951 951
 
952 952
 							}
953 953
 
954
-							if( $field['description'] ) {
955
-								$html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n";
954
+							if ($field['description']) {
955
+								$html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n";
956 956
 							}
957 957
 
958
-						if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) {
959
-							$html .= '</label>' . "\n";
958
+						if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) {
959
+							$html .= '</label>'."\n";
960 960
 						}
961 961
 
962
-					if( 'hidden' != $field['type'] ) {
963
-						$html .= '</p>' . "\n";
962
+					if ('hidden' != $field['type']) {
963
+						$html .= '</p>'."\n";
964 964
 					}
965 965
 
966 966
 				}
967 967
 
968
-			$html .= '</div>' . "\n";
968
+			$html .= '</div>'."\n";
969 969
 
970
-		$html .= '</div>' . "\n";
970
+		$html .= '</div>'."\n";
971 971
 
972 972
 		return $html;
973 973
 	}
@@ -978,61 +978,61 @@  discard block
 block discarded – undo
978 978
 	 */
979 979
 	public function course_order_screen() {
980 980
 
981
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
982
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
981
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
982
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
983 983
 
984 984
 		?><div id="course-order" class="wrap course-order">
985
-		<h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php
985
+		<h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php
986 986
 
987 987
 		$html = '';
988 988
 
989
-		if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) {
990
-			$ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) );
989
+		if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) {
990
+			$ordered = $this->save_course_order(esc_attr($_POST['course-order']));
991 991
 
992
-			if( $ordered ) {
993
-				$html .= '<div class="updated fade">' . "\n";
994
-				$html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
995
-				$html .= '</div>' . "\n";
992
+			if ($ordered) {
993
+				$html .= '<div class="updated fade">'."\n";
994
+				$html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n";
995
+				$html .= '</div>'."\n";
996 996
 			}
997 997
 		}
998 998
 
999 999
 		$courses = Sensei()->course->get_all_courses();
1000 1000
 
1001
-		if( 0 < count( $courses ) ) {
1001
+		if (0 < count($courses)) {
1002 1002
 
1003 1003
             // order the courses as set by the users
1004 1004
             $all_course_ids = array();
1005
-            foreach( $courses as $course ){
1005
+            foreach ($courses as $course) {
1006 1006
 
1007
-                $all_course_ids[] = (string)$course->ID;
1007
+                $all_course_ids[] = (string) $course->ID;
1008 1008
 
1009 1009
             }
1010 1010
             $order_string = $this->get_course_order();
1011 1011
 
1012
-            if( !empty( $order_string ) ){
1013
-                $ordered_course_ids = explode(',' , $order_string );
1014
-                $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) );
1012
+            if ( ! empty($order_string)) {
1013
+                $ordered_course_ids = explode(',', $order_string);
1014
+                $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids));
1015 1015
             }
1016 1016
 
1017 1017
 
1018
-			$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1019
-			$html .= '<ul class="sortable-course-list">' . "\n";
1018
+			$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1019
+			$html .= '<ul class="sortable-course-list">'."\n";
1020 1020
 			$count = 0;
1021
-			foreach ( $all_course_ids as $course_id ) {
1022
-                $course = get_post( $course_id );
1021
+			foreach ($all_course_ids as $course_id) {
1022
+                $course = get_post($course_id);
1023 1023
 				$count++;
1024 1024
 				$class = 'course';
1025
-				if ( $count == 1 ) { $class .= ' first'; }
1026
-				if ( $count == count( $course ) ) { $class .= ' last'; }
1027
-				if ( $count % 2 != 0 ) {
1025
+				if ($count == 1) { $class .= ' first'; }
1026
+				if ($count == count($course)) { $class .= ' last'; }
1027
+				if ($count % 2 != 0) {
1028 1028
 					$class .= ' alternate';
1029 1029
 				}
1030
-				$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n";
1030
+				$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n";
1031 1031
 			}
1032
-			$html .= '</ul>' . "\n";
1032
+			$html .= '</ul>'."\n";
1033 1033
 
1034
-			$html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1035
-			$html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n";
1034
+			$html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n";
1035
+			$html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n";
1036 1036
 		}
1037 1037
 
1038 1038
 		echo $html;
@@ -1041,25 +1041,25 @@  discard block
 block discarded – undo
1041 1041
 	}
1042 1042
 
1043 1043
 	public function get_course_order() {
1044
-		return get_option( 'sensei_course_order', '' );
1044
+		return get_option('sensei_course_order', '');
1045 1045
 	}
1046 1046
 
1047
-	public function save_course_order( $order_string = '' ) {
1048
-		$order = explode( ',', $order_string );
1047
+	public function save_course_order($order_string = '') {
1048
+		$order = explode(',', $order_string);
1049 1049
 
1050
-		update_option( 'sensei_course_order', $order_string );
1050
+		update_option('sensei_course_order', $order_string);
1051 1051
 
1052 1052
 		$i = 1;
1053
-		foreach( $order as $course_id ) {
1053
+		foreach ($order as $course_id) {
1054 1054
 
1055
-			if( $course_id ) {
1055
+			if ($course_id) {
1056 1056
 
1057 1057
 				$update_args = array(
1058 1058
 					'ID' => $course_id,
1059 1059
 					'menu_order' => $i,
1060 1060
 				);
1061 1061
 
1062
-				wp_update_post( $update_args );
1062
+				wp_update_post($update_args);
1063 1063
 
1064 1064
 				++$i;
1065 1065
 			}
@@ -1074,22 +1074,22 @@  discard block
 block discarded – undo
1074 1074
 	 */
1075 1075
 	public function lesson_order_screen() {
1076 1076
 
1077
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1078
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version );
1077
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1078
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version);
1079 1079
 
1080 1080
 		?><div id="lesson-order" class="wrap lesson-order">
1081
-		<h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php
1081
+		<h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php
1082 1082
 
1083 1083
 		$html = '';
1084 1084
 
1085
-		if( isset( $_POST['lesson-order'] ) ) {
1085
+		if (isset($_POST['lesson-order'])) {
1086 1086
 
1087
-			$ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) );
1087
+			$ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id']));
1088 1088
 
1089
-			if( $ordered ) {
1090
-				$html .= '<div class="updated fade">' . "\n";
1091
-				$html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n";
1092
-				$html .= '</div>' . "\n";
1089
+			if ($ordered) {
1090
+				$html .= '<div class="updated fade">'."\n";
1091
+				$html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n";
1092
+				$html .= '</div>'."\n";
1093 1093
 			}
1094 1094
 		}
1095 1095
 
@@ -1100,43 +1100,43 @@  discard block
 block discarded – undo
1100 1100
 			'orderby' => 'name',
1101 1101
 			'order' => 'ASC',
1102 1102
 		);
1103
-		$courses = get_posts( $args );
1103
+		$courses = get_posts($args);
1104 1104
 
1105
-		$html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n";
1106
-		$html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n";
1107
-		$html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n";
1108
-		$html .= '<select id="lesson-order-course" name="course_id">' . "\n";
1109
-		$html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n";
1105
+		$html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n";
1106
+		$html .= '<input type="hidden" name="post_type" value="lesson" />'."\n";
1107
+		$html .= '<input type="hidden" name="page" value="lesson-order" />'."\n";
1108
+		$html .= '<select id="lesson-order-course" name="course_id">'."\n";
1109
+		$html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n";
1110 1110
 
1111
-		foreach( $courses as $course ) {
1111
+		foreach ($courses as $course) {
1112 1112
 			$course_id = '';
1113
-			if( isset( $_GET['course_id'] ) ) {
1114
-				$course_id = intval( $_GET['course_id'] );
1113
+			if (isset($_GET['course_id'])) {
1114
+				$course_id = intval($_GET['course_id']);
1115 1115
 			}
1116
-			$html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n";
1116
+			$html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n";
1117 1117
 		}
1118 1118
 
1119
-		$html .= '</select>' . "\n";
1120
-		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n";
1121
-		$html .= '</form>' . "\n";
1119
+		$html .= '</select>'."\n";
1120
+		$html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n";
1121
+		$html .= '</form>'."\n";
1122 1122
 
1123
-		$html .= '<script type="text/javascript">' . "\n";
1124
-		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n";
1125
-		$html .= '</script>' . "\n";
1123
+		$html .= '<script type="text/javascript">'."\n";
1124
+		$html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n";
1125
+		$html .= '</script>'."\n";
1126 1126
 
1127
-		if( isset( $_GET['course_id'] ) ) {
1128
-			$course_id = intval( $_GET['course_id'] );
1129
-			if( $course_id > 0 ) {
1127
+		if (isset($_GET['course_id'])) {
1128
+			$course_id = intval($_GET['course_id']);
1129
+			if ($course_id > 0) {
1130 1130
 
1131
-				$order_string = $this->get_lesson_order( $course_id );
1131
+				$order_string = $this->get_lesson_order($course_id);
1132 1132
 
1133
-				$html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n";
1133
+				$html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n";
1134 1134
 
1135 1135
 				$displayed_lessons = array();
1136 1136
 
1137
-                $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1137
+                $modules = Sensei()->modules->get_course_modules(intval($course_id));
1138 1138
 
1139
-                foreach( $modules as $module ) {
1139
+                foreach ($modules as $module) {
1140 1140
 
1141 1141
                     $args = array(
1142 1142
                         'post_type' => 'lesson',
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
                         'meta_query' => array(
1146 1146
                             array(
1147 1147
                                 'key' => '_lesson_course',
1148
-                                'value' => intval( $course_id ),
1148
+                                'value' => intval($course_id),
1149 1149
                                 'compare' => '='
1150 1150
                             )
1151 1151
                         ),
@@ -1153,66 +1153,66 @@  discard block
 block discarded – undo
1153 1153
                             array(
1154 1154
                                 'taxonomy' => Sensei()->modules->taxonomy,
1155 1155
                                 'field' => 'id',
1156
-                                'terms' => intval( $module->term_id )
1156
+                                'terms' => intval($module->term_id)
1157 1157
                             )
1158 1158
                         ),
1159
-                        'meta_key' => '_order_module_' . $module->term_id,
1159
+                        'meta_key' => '_order_module_'.$module->term_id,
1160 1160
                         'orderby' => 'meta_value_num date',
1161 1161
                         'order' => 'ASC',
1162 1162
                         'suppress_filters' => 0
1163 1163
                     );
1164 1164
 
1165
-                    $lessons = get_posts( $args );
1165
+                    $lessons = get_posts($args);
1166 1166
 
1167
-                    if( count( $lessons ) > 0 ) {
1168
-                        $html .= '<h3>' . $module->name . '</h3>' . "\n";
1169
-                        $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n";
1167
+                    if (count($lessons) > 0) {
1168
+                        $html .= '<h3>'.$module->name.'</h3>'."\n";
1169
+                        $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n";
1170 1170
 
1171 1171
                         $count = 0;
1172
-                        foreach( $lessons as $lesson ) {
1172
+                        foreach ($lessons as $lesson) {
1173 1173
                             $count++;
1174 1174
                             $class = 'lesson';
1175
-                            if ( $count == 1 ) { $class .= ' first'; }
1176
-                            if ( $count == count( $lesson ) ) { $class .= ' last'; }
1177
-                            if ( $count % 2 != 0 ) {
1175
+                            if ($count == 1) { $class .= ' first'; }
1176
+                            if ($count == count($lesson)) { $class .= ' last'; }
1177
+                            if ($count % 2 != 0) {
1178 1178
                                 $class .= ' alternate';
1179 1179
                             }
1180 1180
 
1181
-                            $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1181
+                            $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1182 1182
 
1183 1183
                             $displayed_lessons[] = $lesson->ID;
1184 1184
                         }
1185 1185
 
1186
-                        $html .= '</ul>' . "\n";
1186
+                        $html .= '</ul>'."\n";
1187 1187
 
1188
-                        $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n";
1188
+                        $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n";
1189 1189
                     }
1190 1190
                 }
1191 1191
 
1192 1192
 
1193
-                $lessons = Sensei()->course->course_lessons( $course_id );
1193
+                $lessons = Sensei()->course->course_lessons($course_id);
1194 1194
 
1195
-				if( 0 < count( $lessons ) ) {
1195
+				if (0 < count($lessons)) {
1196 1196
 
1197 1197
                     //get module term ids, will be used to exclude lessons
1198 1198
                     $module_items_ids = array();
1199
-                    if( ! empty( $modules ) ) {
1199
+                    if ( ! empty($modules)) {
1200 1200
                         foreach ($modules as $module) {
1201 1201
                             $module_items_ids[] = $module->term_id;
1202 1202
                         }
1203 1203
                     }
1204 1204
 
1205
-					if( 0 < count( $displayed_lessons ) ) {
1206
-						$html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n";
1205
+					if (0 < count($displayed_lessons)) {
1206
+						$html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n";
1207 1207
 					}
1208 1208
 
1209
-					$html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n";
1209
+					$html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n";
1210 1210
 					$count = 0;
1211
-					foreach ( $lessons as $lesson ) {
1211
+					foreach ($lessons as $lesson) {
1212 1212
 
1213 1213
                         // if lesson belongs to one fo the course modules then exclude it here
1214 1214
                         // as it is listed above
1215
-                        if( has_term( $module_items_ids, 'module', $lesson->ID )  ){
1215
+                        if (has_term($module_items_ids, 'module', $lesson->ID)) {
1216 1216
 
1217 1217
                             continue;
1218 1218
 
@@ -1220,28 +1220,28 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
 						$count++;
1222 1222
 						$class = 'lesson';
1223
-						if ( $count == 1 ) { $class .= ' first'; }
1224
-						if ( $count == count( $lesson ) ) { $class .= ' last'; }
1225
-						if ( $count % 2 != 0 ) {
1223
+						if ($count == 1) { $class .= ' first'; }
1224
+						if ($count == count($lesson)) { $class .= ' last'; }
1225
+						if ($count % 2 != 0) {
1226 1226
 
1227 1227
 							$class .= ' alternate';
1228 1228
 
1229 1229
 						}
1230
-						$html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n";
1230
+						$html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n";
1231 1231
 
1232 1232
 						$displayed_lessons[] = $lesson->ID;
1233 1233
 					}
1234
-					$html .= '</ul>' . "\n";
1234
+					$html .= '</ul>'."\n";
1235 1235
 				} else {
1236
-					if( 0 == count( $displayed_lessons ) ) {
1237
-						$html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>';
1236
+					if (0 == count($displayed_lessons)) {
1237
+						$html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>';
1238 1238
 					}
1239 1239
 				}
1240 1240
 
1241
-				if( 0 < count( $displayed_lessons ) ) {
1242
-					$html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n";
1243
-					$html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n";
1244
-					$html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n";
1241
+				if (0 < count($displayed_lessons)) {
1242
+					$html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n";
1243
+					$html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n";
1244
+					$html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n";
1245 1245
 				}
1246 1246
 			}
1247 1247
 		}
@@ -1251,29 +1251,29 @@  discard block
 block discarded – undo
1251 1251
 		?></div><?php
1252 1252
 	}
1253 1253
 
1254
-	public function get_lesson_order( $course_id = 0 ) {
1255
-		$order_string = get_post_meta( $course_id, '_lesson_order', true );
1254
+	public function get_lesson_order($course_id = 0) {
1255
+		$order_string = get_post_meta($course_id, '_lesson_order', true);
1256 1256
 		return $order_string;
1257 1257
 	}
1258 1258
 
1259
-	public function save_lesson_order( $order_string = '', $course_id = 0 ) {
1259
+	public function save_lesson_order($order_string = '', $course_id = 0) {
1260 1260
 
1261
-		if( $course_id ) {
1261
+		if ($course_id) {
1262 1262
 
1263
-            $modules = Sensei()->modules->get_course_modules( intval( $course_id ) );
1263
+            $modules = Sensei()->modules->get_course_modules(intval($course_id));
1264 1264
 
1265
-            foreach( $modules as $module ) {
1265
+            foreach ($modules as $module) {
1266 1266
 
1267 1267
 
1268
-                if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] )
1269
-                    && $_POST[ 'lesson-order-module-' . $module->term_id ] ) {
1268
+                if (isset($_POST['lesson-order-module-'.$module->term_id])
1269
+                    && $_POST['lesson-order-module-'.$module->term_id]) {
1270 1270
 
1271
-                    $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] );
1271
+                    $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]);
1272 1272
                     $i = 1;
1273
-                    foreach( $order as $lesson_id ) {
1273
+                    foreach ($order as $lesson_id) {
1274 1274
 
1275
-                        if( $lesson_id ) {
1276
-                            update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i );
1275
+                        if ($lesson_id) {
1276
+                            update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i);
1277 1277
                             ++$i;
1278 1278
                         }
1279 1279
 
@@ -1284,15 +1284,15 @@  discard block
 block discarded – undo
1284 1284
             } // end for each modules
1285 1285
 
1286 1286
 
1287
-			if( $order_string ) {
1288
-				update_post_meta( $course_id, '_lesson_order', $order_string );
1287
+			if ($order_string) {
1288
+				update_post_meta($course_id, '_lesson_order', $order_string);
1289 1289
 
1290
-				$order = explode( ',', $order_string );
1290
+				$order = explode(',', $order_string);
1291 1291
 
1292 1292
 				$i = 1;
1293
-				foreach( $order as $lesson_id ) {
1294
-					if( $lesson_id ) {
1295
-						update_post_meta( $lesson_id, '_order_' . $course_id, $i );
1293
+				foreach ($order as $lesson_id) {
1294
+					if ($lesson_id) {
1295
+						update_post_meta($lesson_id, '_order_'.$course_id, $i);
1296 1296
 						++$i;
1297 1297
 					}
1298 1298
 				}
@@ -1307,54 +1307,54 @@  discard block
 block discarded – undo
1307 1307
 	function sensei_add_custom_menu_items() {
1308 1308
 		global $pagenow;
1309 1309
 
1310
-		if( 'nav-menus.php' == $pagenow ) {
1311
-			add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' );
1310
+		if ('nav-menus.php' == $pagenow) {
1311
+			add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low');
1312 1312
 		}
1313 1313
 	}
1314 1314
 
1315
-	function wp_nav_menu_item_sensei_links_meta_box( $object ) {
1315
+	function wp_nav_menu_item_sensei_links_meta_box($object) {
1316 1316
 		global $nav_menu_selected_id;
1317 1317
 
1318 1318
 		$menu_items = array(
1319
-			'#senseicourses' => __( 'Courses', 'woothemes-sensei' ),
1320
-			'#senseilessons' => __( 'Lessons', 'woothemes-sensei' ),
1321
-			'#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ),
1322
-			'#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ),
1323
-			'#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ),
1324
-			'#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' )
1319
+			'#senseicourses' => __('Courses', 'woothemes-sensei'),
1320
+			'#senseilessons' => __('Lessons', 'woothemes-sensei'),
1321
+			'#senseimycourses' => __('My Courses', 'woothemes-sensei'),
1322
+			'#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'),
1323
+			'#senseimymessages' => __('My Messages', 'woothemes-sensei'),
1324
+			'#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei')
1325 1325
 		);
1326 1326
 
1327 1327
 		$menu_items_obj = array();
1328
-		foreach ( $menu_items as $value => $title ) {
1328
+		foreach ($menu_items as $value => $title) {
1329 1329
 			$menu_items_obj[$title] = new stdClass;
1330
-			$menu_items_obj[$title]->object_id			= esc_attr( $value );
1331
-			$menu_items_obj[$title]->title				= esc_attr( $title );
1332
-			$menu_items_obj[$title]->url				= esc_attr( $value );
1333
-			$menu_items_obj[$title]->description 		= 'description';
1330
+			$menu_items_obj[$title]->object_id = esc_attr($value);
1331
+			$menu_items_obj[$title]->title = esc_attr($title);
1332
+			$menu_items_obj[$title]->url = esc_attr($value);
1333
+			$menu_items_obj[$title]->description = 'description';
1334 1334
 			$menu_items_obj[$title]->db_id 				= 0;
1335 1335
 			$menu_items_obj[$title]->object 			= 'sensei';
1336
-			$menu_items_obj[$title]->menu_item_parent 	= 0;
1337
-			$menu_items_obj[$title]->type 				= 'custom';
1336
+			$menu_items_obj[$title]->menu_item_parent = 0;
1337
+			$menu_items_obj[$title]->type = 'custom';
1338 1338
 			$menu_items_obj[$title]->target 			= '';
1339
-			$menu_items_obj[$title]->attr_title 		= '';
1340
-			$menu_items_obj[$title]->classes 			= array();
1341
-			$menu_items_obj[$title]->xfn 				= '';
1339
+			$menu_items_obj[$title]->attr_title = '';
1340
+			$menu_items_obj[$title]->classes = array();
1341
+			$menu_items_obj[$title]->xfn = '';
1342 1342
 		}
1343 1343
 
1344
-		$walker = new Walker_Nav_Menu_Checklist( array() );
1344
+		$walker = new Walker_Nav_Menu_Checklist(array());
1345 1345
 		?>
1346 1346
 
1347 1347
 		<div id="sensei-links" class="senseidiv taxonomydiv">
1348 1348
 			<div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active">
1349 1349
 
1350 1350
 				<ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear">
1351
-					<?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?>
1351
+					<?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?>
1352 1352
 				</ul>
1353 1353
 
1354 1354
 			</div>
1355 1355
 			<p class="button-controls">
1356 1356
 				<span class="add-to-menu">
1357
-					<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'woothemes-sensei' ); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1357
+					<input type="submit"<?php disabled($nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'woothemes-sensei'); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" />
1358 1358
 					<span class="spinner"></span>
1359 1359
 				</span>
1360 1360
 			</p>
@@ -1370,17 +1370,17 @@  discard block
 block discarded – undo
1370 1370
 	 */
1371 1371
 	public function theme_compatibility_notices() {
1372 1372
 
1373
-        if( isset( $_GET['sensei_hide_notice'] ) ) {
1374
-        	switch( esc_attr( $_GET['sensei_hide_notice'] ) ) {
1375
-				case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break;
1376
-				case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break;
1373
+        if (isset($_GET['sensei_hide_notice'])) {
1374
+        	switch (esc_attr($_GET['sensei_hide_notice'])) {
1375
+				case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break;
1376
+				case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break;
1377 1377
 			}
1378 1378
         }
1379 1379
 
1380 1380
         // white list templates that are already support by default and do not show notice for them
1381
-        $template = get_option( 'template' );
1381
+        $template = get_option('template');
1382 1382
 
1383
-        $white_list = array(    'twentyeleven',
1383
+        $white_list = array('twentyeleven',
1384 1384
                                 'twentytwelve',
1385 1385
                                 'twentyfourteen',
1386 1386
                                 'twentyfifteen',
@@ -1388,43 +1388,43 @@  discard block
 block discarded – undo
1388 1388
                                 'storefront',
1389 1389
                                                 );
1390 1390
 
1391
-        if ( in_array( $template, $white_list ) ) {
1391
+        if (in_array($template, $white_list)) {
1392 1392
 
1393 1393
             return;
1394 1394
 
1395 1395
         }
1396 1396
 
1397 1397
         // don't show the notice if the user chose to hide it
1398
-        $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true );
1399
-        if(  $hide_theme_check_notice ) {
1398
+        $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true);
1399
+        if ($hide_theme_check_notice) {
1400 1400
 
1401 1401
             return;
1402 1402
 
1403 1403
         }
1404 1404
 
1405 1405
         // show the notice for themes not supporting sensei
1406
-	    if ( ! current_theme_supports( 'sensei' ) ) {
1406
+	    if ( ! current_theme_supports('sensei')) {
1407 1407
             ?>
1408 1408
 
1409 1409
             <div id="message" class="error sensei-message sensei-connect">
1410 1410
                     <p>
1411 1411
                         <strong>
1412 1412
 
1413
-                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?>
1413
+                            <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?>
1414 1414
 
1415 1415
                         </strong> &#8211;
1416 1416
 
1417
-                        <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?>
1417
+                        <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?>
1418 1418
 
1419
-                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a>
1419
+                        <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php  _e('Sensei theme', 'woothemes-sensei') ?> </a>
1420 1420
 
1421 1421
                         :)
1422 1422
 
1423 1423
                     </p>
1424 1424
                     <p class="submit">
1425
-                        <a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility' ) ); ?>" class="button-primary">
1425
+                        <a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility')); ?>" class="button-primary">
1426 1426
 
1427
-                            <?php _e( 'Theme Integration Guide', 'woothemes-sensei' ); ?></a> <a class="skip button" href="<?php echo esc_url( add_query_arg( 'sensei_hide_notice', 'theme_check' ) ); ?>"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?>
1427
+                            <?php _e('Theme Integration Guide', 'woothemes-sensei'); ?></a> <a class="skip button" href="<?php echo esc_url(add_query_arg('sensei_hide_notice', 'theme_check')); ?>"><?php _e('Hide this notice', 'woothemes-sensei'); ?>
1428 1428
 
1429 1429
                         </a>
1430 1430
                     </p>
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 		wp_get_current_user();
1443 1443
         $user_id = $current_user->ID;
1444 1444
 
1445
-		delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' );
1445
+		delete_user_meta($user_id, 'sensei_hide_theme_check_notice');
1446 1446
 	}
1447 1447
 
1448 1448
 	/**
@@ -1452,8 +1452,8 @@  discard block
 block discarded – undo
1452 1452
 	 * @param  bool $prevent_access
1453 1453
 	 * @return bool
1454 1454
 	 */
1455
-	public function admin_access( $prevent_access ) {
1456
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
1455
+	public function admin_access($prevent_access) {
1456
+		if (current_user_can('manage_sensei_grades')) {
1457 1457
 			return false;
1458 1458
 		}
1459 1459
 
@@ -1468,12 +1468,12 @@  discard block
 block discarded – undo
1468 1468
      *
1469 1469
      * @since 1.8.7
1470 1470
      */
1471
-    public  static function install_pages(){
1471
+    public  static function install_pages() {
1472 1472
 
1473 1473
         // only fire on the settings page
1474
-        if( ! isset( $_GET['page'] )
1474
+        if ( ! isset($_GET['page'])
1475 1475
             || 'woothemes-sensei-settings' != $_GET['page']
1476
-            || 1 == get_option('skip_install_sensei_pages') ){
1476
+            || 1 == get_option('skip_install_sensei_pages')) {
1477 1477
 
1478 1478
             return;
1479 1479
 
@@ -1503,13 +1503,13 @@  discard block
 block discarded – undo
1503 1503
         if ($install_complete) {
1504 1504
 
1505 1505
             // Flush rules after install
1506
-            flush_rewrite_rules( true );
1506
+            flush_rewrite_rules(true);
1507 1507
 
1508 1508
             // Set installed option
1509 1509
             update_option('sensei_installed', 0);
1510 1510
 
1511
-            $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url  );
1512
-            wp_redirect( $complete_url );
1511
+            $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url);
1512
+            wp_redirect($complete_url);
1513 1513
 
1514 1514
         }
1515 1515
 
@@ -1523,4 +1523,4 @@  discard block
 block discarded – undo
1523 1523
  * @since 1.9.0
1524 1524
  * @ignore
1525 1525
  */
1526
-class WooThemes_Sensei_Admin extends Sensei_Admin{ }
1526
+class WooThemes_Sensei_Admin extends Sensei_Admin { }
Please login to merge, or discard this patch.
templates/single-course/lessons.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying all single course meta information.
5 5
  *
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
          * @hooked WooThemes_Sensei_Course::load_single_course_lessons_query
23 23
          * @since 1.9.0
24 24
          */
25
-        do_action( 'sensei_single_course_lessons_before' );
25
+        do_action('sensei_single_course_lessons_before');
26 26
 
27 27
     ?>
28 28
 
29 29
     <?php
30 30
 
31 31
     //lessons loaded into loop in the sensei_single_course_lessons_before hook
32
-    if( have_posts() ):
32
+    if (have_posts()):
33 33
 
34 34
         // start course lessons loop
35
-        while ( have_posts() ): the_post();  ?>
35
+        while (have_posts()): the_post(); ?>
36 36
 
37 37
             <article <?php post_class(); ?> >
38 38
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                      * @hooked WooThemes_Sensei_Lesson::the_lesson_thumbnail - 8
51 51
                      *
52 52
                      */
53
-                    do_action( 'sensei_single_course_inside_before_lesson', get_the_ID() );
53
+                    do_action('sensei_single_course_inside_before_lesson', get_the_ID());
54 54
 
55 55
                 ?>
56 56
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                      *
76 76
                      * @since 1.9.0
77 77
                      */
78
-                    do_action( 'sensei_single_course_inside_after_lesson', get_the_ID() );
78
+                    do_action('sensei_single_course_inside_after_lesson', get_the_ID());
79 79
 
80 80
                 ?>
81 81
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
          *
95 95
          * @since 1.9.0
96 96
          */
97
-        do_action( 'sensei_single_course_lessons_after' );
97
+        do_action('sensei_single_course_lessons_after');
98 98
 
99 99
     ?>
100 100
 
Please login to merge, or discard this patch.
templates/course-results.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 ?>
13 13
 
14
-<?php  get_sensei_header();  ?>
14
+<?php  get_sensei_header(); ?>
15 15
 
16 16
 <?php
17 17
 /**
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @hooked Sensei_Course_Results::deprecate_sensei_course_results_content_hook() - 20
23 23
  */
24
-do_action( 'sensei_course_results_content_before' );
24
+do_action('sensei_course_results_content_before');
25 25
 ?>
26 26
 
27 27
 <?php
28 28
 global $course;
29
-$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' );
29
+$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course');
30 30
 ?>
31 31
 
32
-<article <?php post_class( array( 'course', 'post','course-results' ) ); ?> >
32
+<article <?php post_class(array('course', 'post', 'course-results')); ?> >
33 33
 
34 34
     <section class="entry fix">
35 35
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
          * @param integer $course_id
43 43
          *
44 44
          */
45
-        do_action( 'sensei_course_results_content_inside_before', $course->ID );
45
+        do_action('sensei_course_results_content_inside_before', $course->ID);
46 46
         ?>
47 47
 
48 48
         <header>
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
         </header>
55 55
 
56
-        <?php if ( is_user_logged_in() ):?>
56
+        <?php if (is_user_logged_in()):?>
57 57
 
58 58
             <?php
59 59
             /**
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
              *
66 66
              * @hooked Sensei_Course_Results::course_info() - 20
67 67
              */
68
-            do_action( 'sensei_course_results_content_inside_before_lessons', $course->ID );
68
+            do_action('sensei_course_results_content_inside_before_lessons', $course->ID);
69 69
             ?>
70 70
 
71 71
 
72 72
             <section class="course-results-lessons">
73 73
                 <?php
74
-                $started_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
75
-                if( $started_course ) {
74
+                $started_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id());
75
+                if ($started_course) {
76 76
 
77 77
                     sensei_the_course_results_lessons();
78 78
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
          *
93 93
          * @hooked Sensei()->course_results->course_info - 20
94 94
          */
95
-        do_action( 'sensei_course_results_content_inside_after', $course->ID );
95
+        do_action('sensei_course_results_content_inside_after', $course->ID);
96 96
         ?>
97 97
 
98 98
     </section>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  * @since 1.9.0
107 107
  *
108 108
  */
109
-do_action( 'sensei_course_results_content_after' );
109
+do_action('sensei_course_results_content_after');
110 110
 ?>
111 111
 
112 112
 
Please login to merge, or discard this patch.
includes/hooks/template.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
  *
19 19
  ***************************/
20 20
 //This hook allow us to change the template WordPress loads for a given page/post_type @since 1.9.0
21
-add_filter( 'template_include', array ( 'Sensei_Templates', 'template_loader' ), 10, 1 );
21
+add_filter('template_include', array('Sensei_Templates', 'template_loader'), 10, 1);
22 22
 
23 23
 //This hook adds the sensei pagination to the pagination hook
24
-add_action( 'sensei_pagination', array( 'Sensei_Frontend', 'load_content_pagination' ), 30 );
24
+add_action('sensei_pagination', array('Sensei_Frontend', 'load_content_pagination'), 30);
25 25
 
26 26
 
27 27
 /***************************
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
  *
33 33
  ***************************/
34 34
 // deprecate the archive content hook @since 1.9.0
35
-add_action( 'sensei_archive_before_course_loop', array ( 'Sensei_Templates', 'deprecated_archive_course_content_hook' ), 10, 1 );
35
+add_action('sensei_archive_before_course_loop', array('Sensei_Templates', 'deprecated_archive_course_content_hook'), 10, 1);
36 36
 
37 37
 // Course archive title hook @since 1.9.0
38
-add_action('sensei_archive_before_course_loop', array( 'Sensei_Course', 'archive_header' ), 10, 0 );
38
+add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'archive_header'), 10, 0);
39 39
 
40 40
 // add the course image above the content
41
-add_action('sensei_course_content_inside_before', array( Sensei()->course, 'course_image' ) ,10, 1 );
41
+add_action('sensei_course_content_inside_before', array(Sensei()->course, 'course_image'), 10, 1);
42 42
 
43 43
 // add course content title to the courses on the archive page
44
-add_action('sensei_course_content_inside_before', array( 'Sensei_Templates', 'the_title' ) ,5, 1 );
44
+add_action('sensei_course_content_inside_before', array('Sensei_Templates', 'the_title'), 5, 1);
45 45
 
46 46
 /***************************
47 47
  *
@@ -53,33 +53,33 @@  discard block
 block discarded – undo
53 53
 // @1.9.0
54 54
 // add deprecated action hooks for backwards compatibility sake
55 55
 // hooks on single course page: sensei_course_image , sensei_course_single_title, sensei_course_single_meta
56
-add_action('sensei_single_course_content_inside_before', array( 'Sensei_Templates', 'deprecated_single_course_inside_before_hooks' ), 80);
56
+add_action('sensei_single_course_content_inside_before', array('Sensei_Templates', 'deprecated_single_course_inside_before_hooks'), 80);
57 57
 
58 58
 // @1.9.0
59 59
 // hook the single course title on the single course page
60
-add_action( 'sensei_single_course_content_inside_before',array( 'Sensei_Course', 'the_title'), 10 );
60
+add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_title'), 10);
61 61
 
62 62
 // @1.9.0
63 63
 // hook the single course title on the single course page
64
-add_action( 'sensei_single_course_content_inside_before', array( Sensei()->course , 'course_image'), 20 );
64
+add_action('sensei_single_course_content_inside_before', array(Sensei()->course, 'course_image'), 20);
65 65
 
66 66
 
67 67
 // @1.9.0
68 68
 //Add legacy hooks deprecated in 1.9.0
69
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Templates','deprecate_course_single_meta_hooks'), 10 );
69
+add_action('sensei_single_course_content_inside_before', array('Sensei_Templates', 'deprecate_course_single_meta_hooks'), 10);
70 70
 
71 71
 // @1.9.0
72 72
 // Filter the content and replace it with the excerpt if the user doesn't have full access
73
-add_filter( 'the_content', array('Sensei_Course', 'single_course_content' ) );
73
+add_filter('the_content', array('Sensei_Course', 'single_course_content'));
74 74
 
75 75
 // @1.9.0
76 76
 // Deprecate lessons specific single course hooks
77
-add_action( 'sensei_single_course_content_inside_after', array( 'Sensei_Templates','deprecate_sensei_course_single_lessons_hook' ) );
77
+add_action('sensei_single_course_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_course_single_lessons_hook'));
78 78
 
79 79
 // @1.9.0
80 80
 // Deprecate single main content hooks
81
-add_action( 'sensei_single_course_content_inside_after', array( 'Sensei_Templates', 'deprecated_single_main_content_hook') );
82
-add_action( 'sensei_single_message_content_inside_after', array( 'Sensei_Templates', 'deprecated_single_main_content_hook') );
81
+add_action('sensei_single_course_content_inside_after', array('Sensei_Templates', 'deprecated_single_main_content_hook'));
82
+add_action('sensei_single_message_content_inside_after', array('Sensei_Templates', 'deprecated_single_main_content_hook'));
83 83
 
84 84
 /**
85 85
  * Deprecate all the post type single titile hooks in favor of before content and after content hooks
@@ -87,62 +87,62 @@  discard block
 block discarded – undo
87 87
  * @deprecate 1.9.0
88 88
  * @1.9.0
89 89
  */
90
-add_action('sensei_single_message_content_inside_before', array( 'Sensei_Templates', 'deprecate_all_post_type_single_title_hooks' ) );
90
+add_action('sensei_single_message_content_inside_before', array('Sensei_Templates', 'deprecate_all_post_type_single_title_hooks'));
91 91
 
92 92
 /**
93 93
  * Deprecate hooks into the single course modules
94 94
  * @deprecated since 1.9.0
95 95
  */
96
-add_action('sensei_single_course_modules_before', array('Sensei_Templates','deprecate_module_before_hook' ) );
97
-add_action('sensei_single_course_modules_after', array('Sensei_Templates','deprecate_module_after_hook' ) );
96
+add_action('sensei_single_course_modules_before', array('Sensei_Templates', 'deprecate_module_before_hook'));
97
+add_action('sensei_single_course_modules_after', array('Sensei_Templates', 'deprecate_module_after_hook'));
98 98
 
99 99
 // @since 1.9.0
100 100
 // add the single course lessons title
101
-add_action( 'sensei_single_course_content_inside_after' , array( 'Sensei_Course','the_course_lessons_title'), 9 );
101
+add_action('sensei_single_course_content_inside_after', array('Sensei_Course', 'the_course_lessons_title'), 9);
102 102
 
103 103
 // @since 1.9.0
104 104
 // hooks in the course lessons query and remove it at the end
105 105
 // also loading the course lessons template in the middle
106
-add_action( 'sensei_single_course_lessons_before', array('Sensei_Course','load_single_course_lessons_query' ) );
107
-add_action( 'sensei_single_course_content_inside_after', 'course_single_lessons', 10 );
108
-add_action( 'sensei_single_course_lessons_after', array( 'Sensei_Utils','restore_wp_query' ));
106
+add_action('sensei_single_course_lessons_before', array('Sensei_Course', 'load_single_course_lessons_query'));
107
+add_action('sensei_single_course_content_inside_after', 'course_single_lessons', 10);
108
+add_action('sensei_single_course_lessons_after', array('Sensei_Utils', 'restore_wp_query'));
109 109
 
110 110
 // @since 1.9.0
111 111
 // add post classes to the lessons on the single course page
112
-add_filter( 'post_class', array( 'Sensei_Lesson', 'single_course_lessons_classes' ) );
112
+add_filter('post_class', array('Sensei_Lesson', 'single_course_lessons_classes'));
113 113
 
114 114
 // @since 1.9.0
115 115
 // lesson meta information on the single course page
116
-add_action( 'sensei_single_course_inside_before_lesson', array('Sensei_Lesson','the_lesson_meta') , 5);
116
+add_action('sensei_single_course_inside_before_lesson', array('Sensei_Lesson', 'the_lesson_meta'), 5);
117 117
 
118 118
 //@since 1.9.0
119 119
 // lesson image
120
-add_action( 'sensei_single_course_inside_before_lesson', array('Sensei_Lesson','the_lesson_thumbnail') , 8);
120
+add_action('sensei_single_course_inside_before_lesson', array('Sensei_Lesson', 'the_lesson_thumbnail'), 8);
121 121
 
122 122
 //@since 1.9.0
123 123
 // lesson custom excerpts
124
-add_filter( 'get_the_excerpt', array( 'Sensei_Lesson', 'alter_the_lesson_excerpt' ) );
124
+add_filter('get_the_excerpt', array('Sensei_Lesson', 'alter_the_lesson_excerpt'));
125 125
 
126 126
 // @since 1.9.0
127 127
 // run a deprecated hook for backwards compatibility sake
128
-add_action( 'sensei_single_course_modules_before', array( 'Sensei_Core_Modules', 'deprecate_sensei_single_course_modules_content'  ) );
128
+add_action('sensei_single_course_modules_before', array('Sensei_Core_Modules', 'deprecate_sensei_single_course_modules_content'));
129 129
 
130 130
 // @since 1.9.0
131 131
 // hook in the module loop intialization functionality
132
-add_action( 'sensei_single_course_modules_before', array( 'Sensei_Core_Modules', 'setup_single_course_module_loop' ) );
132
+add_action('sensei_single_course_modules_before', array('Sensei_Core_Modules', 'setup_single_course_module_loop'));
133 133
 
134 134
 // @since 1.9.0
135 135
 // hook in the module loop destructor functionality
136
-add_action( 'sensei_single_course_modules_after', array( 'Sensei_Core_Modules', 'teardown_single_course_module_loop' ) );
136
+add_action('sensei_single_course_modules_after', array('Sensei_Core_Modules', 'teardown_single_course_module_loop'));
137 137
 
138 138
 // @since 1.9.0
139 139
 // hook in the possible full content override to show instead of excerpt
140
-add_filter('get_the_excerpt', array( 'Sensei_Course', 'full_content_excerpt_override' ) );
140
+add_filter('get_the_excerpt', array('Sensei_Course', 'full_content_excerpt_override'));
141 141
 
142 142
 //@since 1.9.0
143 143
 //Course meta
144
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Course', 'the_course_enrolment_actions' ), 30 );
145
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_Course' , 'the_course_video' ), 40 );
144
+add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_course_enrolment_actions'), 30);
145
+add_action('sensei_single_course_content_inside_before', array('Sensei_Course', 'the_course_video'), 40);
146 146
 
147 147
 /***************************
148 148
  *
@@ -153,54 +153,54 @@  discard block
 block discarded – undo
153 153
  ***************************/
154 154
 //@since 1.9.0
155 155
 // deprecate hooks no longer needed
156
-add_action( 'sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_single_main_content_hook' ) );
157
-add_action( 'sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_quiz_single_title_hook' ) );
156
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_single_main_content_hook'));
157
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'deprecate_quiz_sensei_quiz_single_title_hook'));
158 158
 
159 159
 //@since 1.9.0
160 160
 // Single quiz title
161
-add_filter( 'the_title', array( 'Sensei_Quiz' , 'single_quiz_title' ), 20 , 2 ); // append Quiz
162
-add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'the_title' ), 20 ); //output single quiz
161
+add_filter('the_title', array('Sensei_Quiz', 'single_quiz_title'), 20, 2); // append Quiz
162
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'the_title'), 20); //output single quiz
163 163
 
164 164
 // since 1.9.0
165 165
 // initialize the quiz questions loop
166
-add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'start_quiz_questions_loop') );
166
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'start_quiz_questions_loop'));
167 167
 
168 168
 // since 1.9.0
169 169
 // hook in the quiz user message
170
-add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Quiz', 'the_user_status_message' ), 40 );
170
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Quiz', 'the_user_status_message'), 40);
171 171
 
172 172
 //@since 1.9.0
173 173
 // hook in the question title, description and quesiton media
174
-add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_title' ), 10 );
175
-add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_description' ), 20 );
176
-add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_media' ), 30 );
177
-add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question','the_question_hidden_fields' ), 40 );
174
+add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_title'), 10);
175
+add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_description'), 20);
176
+add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_media'), 30);
177
+add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_question_hidden_fields'), 40);
178 178
 
179 179
 //@since 1.9.0
180 180
 // hook in incorrect / correct message above questions if the quiz has been graded
181
-add_action( 'sensei_quiz_question_inside_before', array( 'Sensei_Question', 'the_answer_result_indication' ), 50 );
181
+add_action('sensei_quiz_question_inside_before', array('Sensei_Question', 'the_answer_result_indication'), 50);
182 182
 
183 183
 //@since 1.9.0
184 184
 // add answer grading feedback at the bottom of the question
185
-add_action( 'sensei_quiz_question_inside_after', array( 'Sensei_Question', 'answer_feedback_notes' ) );
185
+add_action('sensei_quiz_question_inside_after', array('Sensei_Question', 'answer_feedback_notes'));
186 186
 
187 187
 //@since 1.9.0
188 188
 // add extra question data for different quesiton types when get_question_template_data_is_called.
189
-add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','multiple_choice_load_question_data'), 10, 3);
190
-add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','gap_fill_load_question_data'), 10, 3);
191
-add_filter( 'sensei_get_question_template_data', array( 'Sensei_Question','file_upload_load_question_data'), 10, 3);
189
+add_filter('sensei_get_question_template_data', array('Sensei_Question', 'multiple_choice_load_question_data'), 10, 3);
190
+add_filter('sensei_get_question_template_data', array('Sensei_Question', 'gap_fill_load_question_data'), 10, 3);
191
+add_filter('sensei_get_question_template_data', array('Sensei_Question', 'file_upload_load_question_data'), 10, 3);
192 192
 
193 193
 //@since 1.9.0
194 194
 // deprecate the quiz button action
195
-add_action( 'sensei_single_quiz_questions_after', array( 'Sensei_Quiz', 'action_buttons' ), 10, 0 );
195
+add_action('sensei_single_quiz_questions_after', array('Sensei_Quiz', 'action_buttons'), 10, 0);
196 196
 
197 197
 //@since 1.9.0
198 198
 // deprecate the sensei_complete_quiz hook
199
-add_action( 'sensei_single_quiz_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_complete_quiz_action' ));
199
+add_action('sensei_single_quiz_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_complete_quiz_action'));
200 200
 
201 201
 //@since 1.9.0
202 202
 // deprecate the sensei_quiz_question_type hook
203
-add_action( 'sensei_quiz_question_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_quiz_question_type_action' ));
203
+add_action('sensei_quiz_question_inside_after', array('Sensei_Templates', 'deprecate_sensei_quiz_question_type_action'));
204 204
 
205 205
 /***************************
206 206
  *
@@ -211,63 +211,63 @@  discard block
 block discarded – undo
211 211
  ***************************/
212 212
 //@since 1.9.0
213 213
 // deprecate the main content hook on the single lesson page
214
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates', 'deprecate_lesson_single_main_content_hook' ), 20);
214
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_lesson_single_main_content_hook'), 20);
215 215
 
216 216
 //@since 1.9.0
217 217
 // hook in the lesson image on the single lesson
218
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'the_lesson_image' ), 17 );
218
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'the_lesson_image'), 17);
219 219
 
220 220
 //@since 1.9.0
221 221
 // hook in the lesson image on the single lesson deprecated hook function
222
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates','deprecate_lesson_image_hook' ), 10 );
222
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_lesson_image_hook'), 10);
223 223
 
224 224
 //@since 1.9.0
225 225
 // hook in the lesson single title deprecated function
226
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_lesson_single_title' ), 15 );
226
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_lesson_single_title'), 15);
227 227
 
228 228
 // @since 1.9.0
229 229
 // hook in the sensei lesson user notices
230
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'user_not_taking_course_message' ), 15 );
230
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'user_not_taking_course_message'), 15);
231 231
 
232 232
 // @since 1.9.0
233 233
 // attach the lesson title
234
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'the_title' ), 15 );
234
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'the_title'), 15);
235 235
 
236 236
 //@since 1.9.0
237 237
 // hook in the lesson image on the single lesson
238
-add_action( 'sensei_single_lesson_content_inside_before', array( 'Sensei_Lesson', 'user_lesson_quiz_status_message' ), 20 );
238
+add_action('sensei_single_lesson_content_inside_before', array('Sensei_Lesson', 'user_lesson_quiz_status_message'), 20);
239 239
 
240 240
 // @since 1.9.0
241 241
 // add the single lesson meta
242
-add_action( 'sensei_single_lesson_content_inside_after', 'sensei_the_single_lesson_meta', 10 );
242
+add_action('sensei_single_lesson_content_inside_after', 'sensei_the_single_lesson_meta', 10);
243 243
 
244 244
 // @since 1.9.0
245 245
 // deprecate the sensei_lesson_single_meta hook
246
-add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_lesson_single_meta_hook' ), 15 );
246
+add_action('sensei_single_lesson_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_lesson_single_meta_hook'), 15);
247 247
 
248 248
 // @since 1.9.0
249 249
 // deprecate the sensei_lesson_course_signup hook
250
-add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Templates','deprecate_sensei_lesson_course_signup_hook' ), 20 );
250
+add_action('sensei_single_lesson_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_lesson_course_signup_hook'), 20);
251 251
 
252 252
 // @since 1.9.0
253 253
 // hook in the lesson prerequisite completion message
254
-add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Lesson', 'prerequisite_complete_message' ), 20 );
254
+add_action('sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'prerequisite_complete_message'), 20);
255 255
 
256 256
 // @since 1.9.0
257 257
 // hook the single lesson course_signup_link
258
-add_action( 'sensei_single_lesson_content_inside_after', array( 'Sensei_Lesson', 'course_signup_link' ), 30 );
258
+add_action('sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'course_signup_link'), 30);
259 259
 
260 260
 // @since 1.9.0
261 261
 // hook the deprecate breadcrumbs and comments hooks
262
-add_action( 'sensei_after_main_content', array( 'Sensei_Templates', 'deprecate_single_lesson_breadcrumbs_and_comments_hooks'), 5 );
262
+add_action('sensei_after_main_content', array('Sensei_Templates', 'deprecate_single_lesson_breadcrumbs_and_comments_hooks'), 5);
263 263
 
264 264
 // @since 1.9.0
265 265
 // Add the quiz specific buttons and notices to the lesson
266
-add_action( 'sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'footer_quiz_call_to_action' ));
266
+add_action('sensei_single_lesson_content_inside_after', array('Sensei_Lesson', 'footer_quiz_call_to_action'));
267 267
 
268 268
 // @since 1.9.0
269 269
 // hook in the comments on the single lessons page
270
-add_action( 'sensei_pagination', array( 'Sensei_Lesson', 'output_comments' ), 90 );
270
+add_action('sensei_pagination', array('Sensei_Lesson', 'output_comments'), 90);
271 271
 
272 272
 /**********************
273 273
  *
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
  *
278 278
  ************************/
279 279
 
280
-add_action( 'sensei_single_message_content_inside_before', array( 'Sensei_Messages', 'the_title' ), 20 );
280
+add_action('sensei_single_message_content_inside_before', array('Sensei_Messages', 'the_title'), 20);
281 281
 
282
-add_action( 'sensei_single_message_content_inside_before', array( 'Sensei_Messages', 'the_message_sent_by_title' ), 40 );
282
+add_action('sensei_single_message_content_inside_before', array('Sensei_Messages', 'the_message_sent_by_title'), 40);
283 283
 
284 284
 /*************************
285 285
  *
@@ -291,15 +291,15 @@  discard block
 block discarded – undo
291 291
 
292 292
 // deprecate the sensei_lesson_archive_header hook
293 293
 // @deprecated since 1.9.0
294
-add_action( 'sensei_loop_lesson_inside_before', array( 'Sensei_Lesson', 'deprecate_sensei_lesson_archive_header_hook' ), 20 );
294
+add_action('sensei_loop_lesson_inside_before', array('Sensei_Lesson', 'deprecate_sensei_lesson_archive_header_hook'), 20);
295 295
 
296 296
 // @1.9.0
297 297
 //The archive title header on the lesson archive loop
298
-add_action( 'sensei_loop_lesson_inside_before', array( Sensei()->lesson, 'the_archive_header' ), 20 );
298
+add_action('sensei_loop_lesson_inside_before', array(Sensei()->lesson, 'the_archive_header'), 20);
299 299
 
300 300
 // @since 1.9.0
301 301
 //Output the lesson header on the content-lesson.php which runs inside the lessons loop
302
-add_action( 'sensei_content_lesson_inside_before', array( 'Sensei_Lesson', 'the_lesson_meta' ), 20 );
302
+add_action('sensei_content_lesson_inside_before', array('Sensei_Lesson', 'the_lesson_meta'), 20);
303 303
 
304 304
 /**************************
305 305
  *
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
  **************************/
311 311
 // @since 1.9.0
312 312
 // deprecate the learner profile content hook as the markup code is added in the template directly.
313
-add_action('sensei_learner_profile_content_before', array( 'Sensei_Learner_Profiles', 'deprecate_sensei_learner_profile_content_hook' ) );
313
+add_action('sensei_learner_profile_content_before', array('Sensei_Learner_Profiles', 'deprecate_sensei_learner_profile_content_hook'));
314 314
 
315 315
 // @since 1.9.0
316 316
 // do the sensei complete course action on the learner profiles page.
317
-add_action('sensei_learner_profile_content_before', array( 'Sensei_Templates', 'fire_sensei_complete_course_hook' ) );
317
+add_action('sensei_learner_profile_content_before', array('Sensei_Templates', 'fire_sensei_complete_course_hook'));
318 318
 
319 319
 // @since 1.9.0
320 320
 // fire the frontend messages hook before the profile content
321
-add_action('sensei_learner_profile_inside_content_before', array( 'Sensei_Templates', 'fire_frontend_messages_hook' ) );
321
+add_action('sensei_learner_profile_inside_content_before', array('Sensei_Templates', 'fire_frontend_messages_hook'));
322 322
 
323 323
 
324 324
 /**********************************
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
 
332 332
 // @since 1.9.0
333 333
 // fire the deprecated hook function within the course-result.php file
334
-add_action( 'sensei_course_results_content_before', array('Sensei_Course_Results','deprecate_sensei_course_results_content_hook') );
334
+add_action('sensei_course_results_content_before', array('Sensei_Course_Results', 'deprecate_sensei_course_results_content_hook'));
335 335
 
336 336
 // @since 1.9.0
337 337
 // fire the sensei message hooke inside the course-result.php file
338
-add_action( 'sensei_course_results_content_inside_before', array('Sensei_Course_Results','fire_sensei_message_hook') );
338
+add_action('sensei_course_results_content_inside_before', array('Sensei_Course_Results', 'fire_sensei_message_hook'));
339 339
 
340 340
 // @since 1.9.0
341 341
 // load the course information on the course results page
342
-add_action( 'sensei_course_results_content_inside_before_lessons', array( Sensei()->course_results,'course_info') );
342
+add_action('sensei_course_results_content_inside_before_lessons', array(Sensei()->course_results, 'course_info'));
343 343
 
344 344
 // @since 1.9.0
345
-add_action( 'sensei_course_results_content_inside_before', array( Sensei()->course,'course_image') );
345
+add_action('sensei_course_results_content_inside_before', array(Sensei()->course, 'course_image'));
346 346
 
347 347
 // @since 1.9.0
348 348
 // deprecate the course results top hook in favour of a new hook
349
-add_action( 'sensei_course_results_content_inside_before', array( 'Sensei_Course_Results', 'deprecate_course_results_top_hook') );
349
+add_action('sensei_course_results_content_inside_before', array('Sensei_Course_Results', 'deprecate_course_results_top_hook'));
350 350
 
351 351
 // @since 1.9.0
352 352
 // Fire the course image hook within the course results page
353
-add_action( 'sensei_course_results_content_inside_before', array( 'Sensei_Course_Results', 'fire_course_image_hook') );
353
+add_action('sensei_course_results_content_inside_before', array('Sensei_Course_Results', 'fire_course_image_hook'));
354 354
 
355 355
 
356 356
 /**********************************
@@ -362,19 +362,19 @@  discard block
 block discarded – undo
362 362
  ********************************/
363 363
 // @since 1.9.0
364 364
 // fire the sensei complete course action on the my courses template
365
-add_action( 'sensei_my_courses_before', array( 'Sensei_Templates', 'fire_sensei_complete_course_hook' ) );
365
+add_action('sensei_my_courses_before', array('Sensei_Templates', 'fire_sensei_complete_course_hook'));
366 366
 
367 367
 // @since 1.9.0
368 368
 // fire the sensei frontend messages hook before the my-courses content
369
-add_action('sensei_my_courses_content_inside_before', array( 'Sensei_Templates', 'fire_frontend_messages_hook' ) );
369
+add_action('sensei_my_courses_content_inside_before', array('Sensei_Templates', 'fire_frontend_messages_hook'));
370 370
 
371 371
 // @since 1.9.0
372 372
 // deprecate the sensei_before_user_course_content hook
373
-add_action('sensei_my_courses_content_inside_before', array( 'Sensei_Templates', 'deprecate_sensei_before_user_course_content_hook' ) );
373
+add_action('sensei_my_courses_content_inside_before', array('Sensei_Templates', 'deprecate_sensei_before_user_course_content_hook'));
374 374
 
375 375
 // @since 1.9.0
376 376
 // deprecate the sensei_after_user_course_content hook
377
-add_action('sensei_my_courses_content_inside_after', array( 'Sensei_Templates', 'deprecate_sensei_after_user_course_content_hook' ) );
377
+add_action('sensei_my_courses_content_inside_after', array('Sensei_Templates', 'deprecate_sensei_after_user_course_content_hook'));
378 378
 
379 379
 /**********************************
380 380
  *
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 // @since 1.9.0
387 387
 // deprecate the sensei_login_form hok which was use to load the login form.
388 388
 // This now loads independent of the my-courses template which helps keep templates free from logic
389
-add_action( 'sensei_login_form_before', array( 'Sensei_Templates', 'deprecate_sensei_login_form_hook' ) );
389
+add_action('sensei_login_form_before', array('Sensei_Templates', 'deprecate_sensei_login_form_hook'));
390 390
 
391 391
 /**********************************
392 392
  *
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
  ********************************/
398 398
 // @since 1.9.0
399 399
 // Deprecate the archive messages hooks no longer supported
400
-add_action( 'sensei_archive_before_message_loop', array( 'Sensei_Templates', 'deprecated_archive_message_hooks' ) );
400
+add_action('sensei_archive_before_message_loop', array('Sensei_Templates', 'deprecated_archive_message_hooks'));
401 401
 
402 402
 // @since 1.9.0
403 403
 // Deprecate the archive messages hooks no longer supported
404
-add_action( 'sensei_archive_before_message_loop', array( 'Sensei_Messages', 'the_archive_header' ) );
404
+add_action('sensei_archive_before_message_loop', array('Sensei_Messages', 'the_archive_header'));
405 405
 
406 406
 // @since 1.9.0
407 407
 // output the message title and the message sensei
408
-add_action( 'sensei_content_message_before', array( 'Sensei_Messages', 'the_message_title' ), 10, 1 );
409
-add_action( 'sensei_content_message_before', array( 'Sensei_Messages', 'the_message_sender' ), 20 , 1 );
408
+add_action('sensei_content_message_before', array('Sensei_Messages', 'the_message_title'), 10, 1);
409
+add_action('sensei_content_message_before', array('Sensei_Messages', 'the_message_sender'), 20, 1);
410 410
 
411 411
 /**********************************
412 412
  *
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
  *
416 416
  *
417 417
  **********************************/
418
-add_action( 'sensei_loop_course_before', array( 'Sensei_Course', 'course_category_title' ), 70 , 1 );
418
+add_action('sensei_loop_course_before', array('Sensei_Course', 'course_category_title'), 70, 1);
419 419
 
420 420
 /**********************************
421 421
  *
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
  **********************************/
427 427
 //@since 1.9.0
428 428
 //add a title to the teacher archive page when viewn siteurl/author/{teacher-username}
429
-add_action( 'sensei_teacher_archive_course_loop_before', array( 'Sensei_Teacher', 'archive_title' ) );
429
+add_action('sensei_teacher_archive_course_loop_before', array('Sensei_Teacher', 'archive_title'));
430 430
 
431 431
 //@since 1.9.0
432 432
 // remove course meta from the teacher page until it can be refactored to allow only removing the
433 433
 // teacher name and not all lessons
434
-add_action( 'sensei_teacher_archive_course_loop_before', array( 'Sensei_Teacher', 'remove_course_meta_on_teacher_archive' ) );
434
+add_action('sensei_teacher_archive_course_loop_before', array('Sensei_Teacher', 'remove_course_meta_on_teacher_archive'));
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-shortcode-user-courses.php 1 patch
Spacing   +61 added lines, -61 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
  * This class is loaded int WP by the shortcode loader class.
5 5
  *
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
      * @param string $content
62 62
      * @param string $shortcode the shortcode that was called for this instance
63 63
      */
64
-    public function __construct( $attributes, $content, $shortcode ){
64
+    public function __construct($attributes, $content, $shortcode) {
65 65
 
66
-        if(!  is_user_logged_in() ) {
66
+        if ( ! is_user_logged_in()) {
67 67
             // show the login form
68 68
             Sensei_Templates::get_template('user/login-form.php');
69 69
             return;
70 70
         }
71 71
 
72 72
         // set up all argument need for constructing the course query
73
-        $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '10';
74
-        $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title';
75
-        $this->status = isset( $attributes['status'] ) ? $attributes['status'] : 'all';
73
+        $this->number = isset($attributes['number']) ? $attributes['number'] : '10';
74
+        $this->orderby = isset($attributes['orderby']) ? $attributes['orderby'] : 'title';
75
+        $this->status = isset($attributes['status']) ? $attributes['status'] : 'all';
76 76
 
77 77
         // set the default for menu_order to be ASC
78
-        if( 'menu_order' == $this->orderby && !isset( $attributes['order']  ) ){
78
+        if ('menu_order' == $this->orderby && ! isset($attributes['order'])) {
79 79
 
80
-            $this->order =  'ASC';
80
+            $this->order = 'ASC';
81 81
 
82
-        }else{
82
+        } else {
83 83
 
84 84
             // for everything else use the value passed or the default DESC
85
-            $this->order = isset( $attributes['order']  ) ? $attributes['order'] : 'ASC';
85
+            $this->order = isset($attributes['order']) ? $attributes['order'] : 'ASC';
86 86
 
87 87
         }
88 88
 
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @since 1.9.0
98 98
      */
99
-    protected function setup_course_query(){
99
+    protected function setup_course_query() {
100 100
 
101
-        $status_query = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status' );
102
-        $user_courses_logs = Sensei_Utils::sensei_check_for_activity( $status_query , true );
103
-        if ( !is_array($user_courses_logs) ) {
101
+        $status_query = array('user_id' => get_current_user_id(), 'type' => 'sensei_course_status');
102
+        $user_courses_logs = Sensei_Utils::sensei_check_for_activity($status_query, true);
103
+        if ( ! is_array($user_courses_logs)) {
104 104
 
105
-            $user_courses_logs = array( $user_courses_logs );
105
+            $user_courses_logs = array($user_courses_logs);
106 106
 
107 107
         }
108 108
 
109 109
         $completed_ids = $active_ids = array();
110
-        foreach( $user_courses_logs as $course_status ) {
110
+        foreach ($user_courses_logs as $course_status) {
111 111
 
112
-            if ( Sensei_Utils::user_completed_course( $course_status, get_current_user_id() ) ) {
112
+            if (Sensei_Utils::user_completed_course($course_status, get_current_user_id())) {
113 113
 
114 114
                 $completed_ids[] = $course_status->comment_post_ID;
115 115
 
@@ -120,34 +120,34 @@  discard block
 block discarded – undo
120 120
             }
121 121
         }
122 122
 
123
-        if( 'completed' == $this->status ){
123
+        if ('completed' == $this->status) {
124 124
 
125
-            $included_courses =  $completed_ids;
125
+            $included_courses = $completed_ids;
126 126
 
127 127
 
128
-        }elseif( 'active'==$this->status ){
128
+        }elseif ('active' == $this->status) {
129 129
 
130
-            $included_courses =  $active_ids;
130
+            $included_courses = $active_ids;
131 131
 
132
-        }else{ // all courses
132
+        } else { // all courses
133 133
 
134
-            if( empty( $completed_ids ) ){
134
+            if (empty($completed_ids)) {
135 135
 
136
-                add_action( 'sensei_loop_course_inside_before', array( $this, 'completed_no_course_message_output' ) );
136
+                add_action('sensei_loop_course_inside_before', array($this, 'completed_no_course_message_output'));
137 137
             }
138 138
 
139
-            if( empty( $active_ids ) ){
139
+            if (empty($active_ids)) {
140 140
 
141
-                add_action( 'sensei_loop_course_inside_before', array( $this, 'active_no_course_message_output' ) );
141
+                add_action('sensei_loop_course_inside_before', array($this, 'active_no_course_message_output'));
142 142
 
143 143
             }
144 144
 
145
-            if( empty( $completed_ids ) &&  empty( $active_ids )  ){
145
+            if (empty($completed_ids) && empty($active_ids)) {
146 146
 
147 147
                 $included_courses = array('-1000'); // don't show any courses
148 148
 
149
-            }else{
150
-                $included_courses = Sensei_Utils::array_zip_merge( (array)$active_ids, (array)$completed_ids );
149
+            } else {
150
+                $included_courses = Sensei_Utils::array_zip_merge((array) $active_ids, (array) $completed_ids);
151 151
             }
152 152
 
153 153
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         // if the shortcode is not active or in active and the active and completed
159 159
         // tabs show up.
160 160
         $number_of_posts = $this->number;
161
-        if( 'active' != $this->status && 'complete' != $this->status  ){
161
+        if ('active' != $this->status && 'complete' != $this->status) {
162 162
             $number_of_posts = 1000;
163 163
         }
164 164
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
             'post_status'      => 'publish',
170 170
             'orderby'          => $this->orderby,
171 171
             'order'            => $this->order,
172
-            'paged' => empty( $query_var_paged )? 1 : $query_var_paged,
172
+            'paged' => empty($query_var_paged) ? 1 : $query_var_paged,
173 173
             'posts_per_page'   => $number_of_posts,
174 174
             'post__in'         => $included_courses,
175 175
         );
176 176
 
177
-        $this->query = new WP_Query( $query_args );
177
+        $this->query = new WP_Query($query_args);
178 178
 
179 179
     }// end setup _course_query
180 180
 
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @since 1.9.0
186 186
      */
187
-    public function completed_no_course_message_output(){
187
+    public function completed_no_course_message_output() {
188 188
         ?>
189 189
         <li class="user-completed">
190 190
             <div class="sensei-message info">
191 191
 
192
-                <?php _e( 'You have not completed any courses yet.', 'woothemes-sensei' ); ?>
192
+                <?php _e('You have not completed any courses yet.', 'woothemes-sensei'); ?>
193 193
 
194 194
             </div>
195 195
         </li>
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @since 1.9.0
204 204
      */
205
-    public function active_no_course_message_output(){
205
+    public function active_no_course_message_output() {
206 206
         ?>
207 207
 
208 208
         <li class="user-active">
209 209
             <div class="sensei-message info">
210 210
 
211
-                <?php _e( 'You have no active courses.', 'woothemes-sensei' ); ?>
211
+                <?php _e('You have no active courses.', 'woothemes-sensei'); ?>
212 212
 
213
-                <a href="<?php esc_attr_e( Sensei_Course::get_courses_page_url() ); ?>">
213
+                <a href="<?php esc_attr_e(Sensei_Course::get_courses_page_url()); ?>">
214 214
 
215
-                    <?php  _e( 'Start a Course!', 'woothemes-sensei' ); ?>
215
+                    <?php  _e('Start a Course!', 'woothemes-sensei'); ?>
216 216
 
217 217
                 </a>
218 218
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string $content
228 228
      */
229
-    public function render(){
229
+    public function render() {
230 230
 
231 231
         global $wp_query;
232 232
 
233
-        if(!  is_user_logged_in() ) {
233
+        if ( ! is_user_logged_in()) {
234 234
             return '';
235 235
         }
236 236
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         Sensei_Templates::get_template('globals/pagination.php');
250 250
         echo '</section>';
251 251
 
252
-        $shortcode_output =  ob_get_clean();
252
+        $shortcode_output = ob_get_clean();
253 253
 
254 254
         $this->detach_shortcode_hooks();
255 255
 
@@ -265,23 +265,23 @@  discard block
 block discarded – undo
265 265
      *
266 266
      * @since 1.9.0
267 267
      */
268
-    public function attach_shortcode_hooks(){
268
+    public function attach_shortcode_hooks() {
269 269
 
270 270
         // attach the toggle functionality
271 271
         // don't show the toggle action if the user specified complete or active for this shortcode
272
-        if( ! in_array( $this->status, array( 'active', 'complete' ) ) ){
272
+        if ( ! in_array($this->status, array('active', 'complete'))) {
273 273
 
274
-            add_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) );
275
-            add_action( 'wp_footer', array( $this, 'print_course_toggle_actions_inline_script' ), 90 );
274
+            add_action('sensei_loop_course_before', array($this, 'course_toggle_actions'));
275
+            add_action('wp_footer', array($this, 'print_course_toggle_actions_inline_script'), 90);
276 276
 
277 277
         }
278 278
 
279 279
         // add extra classes to distinguish the course based on user completed or active
280
-        add_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 );
280
+        add_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2);
281 281
 
282 282
         // attach progress meter below course
283
-        add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) );
284
-        add_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) );
283
+        add_action('sensei_course_content_inside_after', array($this, 'attach_course_progress'));
284
+        add_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons'));
285 285
 
286 286
     }
287 287
 
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * @since 1.9.0
292 292
      */
293
-    public function detach_shortcode_hooks(){
293
+    public function detach_shortcode_hooks() {
294 294
 
295 295
         //remove all hooks after the output is generated
296
-        remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_progress' ) );
297
-        remove_action( 'sensei_course_content_inside_after', array( $this, 'attach_course_buttons' ) );
298
-        remove_filter( 'sensei_course_loop_content_class', array( $this, 'course_status_class_tagging' ), 20, 2 );
299
-        remove_action( 'sensei_loop_course_before', array( $this, 'course_toggle_actions' ) );
296
+        remove_action('sensei_course_content_inside_after', array($this, 'attach_course_progress'));
297
+        remove_action('sensei_course_content_inside_after', array($this, 'attach_course_buttons'));
298
+        remove_filter('sensei_course_loop_content_class', array($this, 'course_status_class_tagging'), 20, 2);
299
+        remove_action('sensei_loop_course_before', array($this, 'course_toggle_actions'));
300 300
     }
301 301
 
302 302
     /**
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
      *
305 305
      * @param $course
306 306
      */
307
-    public function attach_course_progress( $course_id ){
307
+    public function attach_course_progress($course_id) {
308 308
 
309
-        $percentage = Sensei()->course->get_completion_percentage( $course_id, get_current_user_id() );
310
-        echo Sensei()->course->get_progress_meter( $percentage );
309
+        $percentage = Sensei()->course->get_completion_percentage($course_id, get_current_user_id());
310
+        echo Sensei()->course->get_progress_meter($percentage);
311 311
 
312 312
     }// attach_course_progress
313 313
 
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @param integer $course_id
321 321
      */
322
-    public function attach_course_buttons( $course_id ){
322
+    public function attach_course_buttons($course_id) {
323 323
 
324
-        Sensei()->course->the_course_action_buttons( get_post( $course_id ) );
324
+        Sensei()->course->the_course_action_buttons(get_post($course_id));
325 325
 
326 326
     }// attach_course_buttons
327 327
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      * @param WP_Post $course
335 335
      * @return array $classes
336 336
      */
337
-    public function course_status_class_tagging($classes, $course){
337
+    public function course_status_class_tagging($classes, $course) {
338 338
 
339
-        if ( Sensei_Utils::user_completed_course( $course, get_current_user_id() ) ) {
339
+        if (Sensei_Utils::user_completed_course($course, get_current_user_id())) {
340 340
 
341 341
             $classes[] = 'user-completed';
342 342
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
     /**
354 354
      * Output the course toggle functionality
355 355
      */
356
-    public function course_toggle_actions(){ ?>
356
+    public function course_toggle_actions() { ?>
357 357
 
358 358
         <section id="user-course-status-toggle">
359 359
             <a id="sensei-user-courses-active-action" href=""><?php _e('Active Courses'); ?></a>
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-legacy-shortcodes.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @since 1.9.0
24 24
      */
25
-    public static function init(){
25
+    public static function init() {
26 26
 
27
-        add_shortcode( 'allcourses',      array( __CLASS__, 'all_courses' ) );
28
-        add_shortcode( 'newcourses',      array( __CLASS__,'new_courses' ) );
29
-        add_shortcode( 'featuredcourses', array( __CLASS__,'featured_courses') );
30
-        add_shortcode( 'freecourses',     array( __CLASS__,'free_courses') );
31
-        add_shortcode( 'paidcourses',     array( __CLASS__,'paid_courses') );
32
-        add_shortcode( 'usercourses',     array( __CLASS__,'user_courses' ) );
27
+        add_shortcode('allcourses', array(__CLASS__, 'all_courses'));
28
+        add_shortcode('newcourses', array(__CLASS__, 'new_courses'));
29
+        add_shortcode('featuredcourses', array(__CLASS__, 'featured_courses'));
30
+        add_shortcode('freecourses', array(__CLASS__, 'free_courses'));
31
+        add_shortcode('paidcourses', array(__CLASS__, 'paid_courses'));
32
+        add_shortcode('usercourses', array(__CLASS__, 'user_courses'));
33 33
 
34 34
     }
35 35
     /**
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
      * @param mixed $content (default: null)
43 43
      * @return string
44 44
      */
45
-    public static function all_courses( $atts, $content = null ) {
45
+    public static function all_courses($atts, $content = null) {
46 46
 
47
-        return self::generate_shortcode_courses( '', 'allcourses' ); // all courses but no title
47
+        return self::generate_shortcode_courses('', 'allcourses'); // all courses but no title
48 48
 
49 49
     } // all_courses()
50 50
 
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      * @param mixed $content (default: null)
57 57
      * @return string
58 58
      */
59
-    public static function paid_courses( $atts, $content = null ) {
59
+    public static function paid_courses($atts, $content = null) {
60 60
 
61
-        return self::generate_shortcode_courses( 'Paid Courses', 'paidcourses' );
61
+        return self::generate_shortcode_courses('Paid Courses', 'paidcourses');
62 62
 
63 63
     } // End paid_courses()
64 64
 
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
      * @param mixed $content (default: null)
72 72
      * @return string
73 73
      */
74
-    public static function featured_courses( $atts, $content = null ) {
74
+    public static function featured_courses($atts, $content = null) {
75 75
 
76
-        return self::generate_shortcode_courses( 'Featured Courses', 'featuredcourses' );
76
+        return self::generate_shortcode_courses('Featured Courses', 'featuredcourses');
77 77
 
78 78
     } // End featured_courses()
79 79
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      * @param mixed $content (default: null)
86 86
      * @return string
87 87
      */
88
-    public static function free_courses( $atts, $content = null ) {
88
+    public static function free_courses($atts, $content = null) {
89 89
 
90
-        return self::generate_shortcode_courses( 'Free Courses', 'freecourses' );
90
+        return self::generate_shortcode_courses('Free Courses', 'freecourses');
91 91
 
92 92
     } // End free_courses()
93 93
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
      * @param mixed $content (default: null)
100 100
      * @return string
101 101
      */
102
-    public static function new_courses( $atts, $content = null ) {
102
+    public static function new_courses($atts, $content = null) {
103 103
 
104
-        return self::generate_shortcode_courses( 'New Courses', 'newcourses' );
104
+        return self::generate_shortcode_courses('New Courses', 'newcourses');
105 105
 
106 106
     } // End new_courses()
107 107
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      * @param $shortcode_specific_override
115 115
      * @return string
116 116
      */
117
-    public static function generate_shortcode_courses( $title , $shortcode_specific_override  ){
117
+    public static function generate_shortcode_courses($title, $shortcode_specific_override) {
118 118
 
119 119
         global  $shortcode_override, $posts_array;
120 120
 
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
         // do not show this short code if there is a shortcode int he url and
124 124
         // this specific shortcode is not the one requested in the ur.
125
-        $specific_shortcode_requested = isset( $_GET['action'] ) ?  sanitize_text_field(  $_GET['action']  ) : '';
126
-        if( ! empty( $specific_shortcode_requested) &&
127
-            $specific_shortcode_requested != $shortcode_override ){
125
+        $specific_shortcode_requested = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
126
+        if ( ! empty($specific_shortcode_requested) &&
127
+            $specific_shortcode_requested != $shortcode_override) {
128 128
 
129 129
             return '';
130 130
 
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
         $courses = ob_get_clean();
137 137
 
138 138
         $content = '';
139
-        if( count( $posts_array ) > 0 ){
139
+        if (count($posts_array) > 0) {
140 140
 
141
-            $before = empty($title)? '' : '<header class="archive-header"><h2>'. $title .'</h2></header>';
141
+            $before = empty($title) ? '' : '<header class="archive-header"><h2>'.$title.'</h2></header>';
142 142
             $before .= '<section id="main-course" class="course-container">';
143 143
 
144 144
             $after = '</section>';
145 145
 
146 146
             //assemble
147
-            $content = $before . $courses . $after;
147
+            $content = $before.$courses.$after;
148 148
 
149 149
         }
150 150
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
      * @param mixed $content (default: null)
162 162
      * @return string
163 163
      */
164
-    public static function user_courses( $atts, $content = null ) {
164
+    public static function user_courses($atts, $content = null) {
165 165
         global $shortcode_override;
166
-        extract( shortcode_atts( array(	'amount' => 0 ), $atts ) );
166
+        extract(shortcode_atts(array('amount' => 0), $atts));
167 167
 
168 168
         $shortcode_override = 'usercourses';
169 169
 
170 170
         ob_start();
171 171
 
172
-        if( is_user_logged_in() ){
172
+        if (is_user_logged_in()) {
173 173
 
174
-            Sensei_Templates::get_template( 'user/my-courses.php' );
174
+            Sensei_Templates::get_template('user/my-courses.php');
175 175
 
176
-        }else{
176
+        } else {
177 177
 
178 178
             Sensei()->frontend->sensei_login_form();
179 179
 
@@ -189,54 +189,54 @@  discard block
 block discarded – undo
189 189
      * loop-course.php for the old shortcodes.
190 190
      * @since 1.9.0
191 191
      */
192
-    public static function initialise_legacy_course_loop(){
192
+    public static function initialise_legacy_course_loop() {
193 193
 
194 194
         global  $post, $wp_query, $shortcode_override, $course_excludes;
195 195
 
196 196
         // Handle Query Type
197 197
         $query_type = '';
198 198
 
199
-        if ( isset( $_GET[ 'action' ] ) && ( '' != esc_html( $_GET[ 'action' ] ) ) ) {
200
-            $query_type = esc_html( $_GET[ 'action' ] );
199
+        if (isset($_GET['action']) && ('' != esc_html($_GET['action']))) {
200
+            $query_type = esc_html($_GET['action']);
201 201
         } // End If Statement
202 202
 
203
-        if ( '' != $shortcode_override ) {
203
+        if ('' != $shortcode_override) {
204 204
             $query_type = $shortcode_override;
205 205
         } // End If Statement
206 206
 
207
-        if ( !is_array( $course_excludes ) ) { $course_excludes = array(); }
207
+        if ( ! is_array($course_excludes)) { $course_excludes = array(); }
208 208
 
209 209
         // Check that query returns results
210 210
         // Handle Pagination
211
-        $paged = $wp_query->get( 'paged' );
212
-        $paged = empty( $paged ) ? 1 : $paged;
211
+        $paged = $wp_query->get('paged');
212
+        $paged = empty($paged) ? 1 : $paged;
213 213
 
214 214
 
215 215
         // Check for pagination settings
216
-        if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
216
+        if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
217 217
 
218
-            $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
218
+            $amount = absint(Sensei()->settings->settings['course_archive_amount']);
219 219
 
220 220
         } else {
221 221
 
222
-            $amount = $wp_query->get( 'posts_per_page' );
222
+            $amount = $wp_query->get('posts_per_page');
223 223
 
224 224
         } // End If Statement
225 225
 
226 226
         // This is not a paginated page (or it's simply the first page of a paginated page/post)
227 227
 
228 228
         global $posts_array;
229
-        $course_includes   = array();
229
+        $course_includes = array();
230 230
 
231
-        $query_args = Sensei()->course->get_archive_query_args( $shortcode_override, $amount, $course_includes, $course_excludes );
232
-        $course_query = new WP_Query( $query_args );
231
+        $query_args = Sensei()->course->get_archive_query_args($shortcode_override, $amount, $course_includes, $course_excludes);
232
+        $course_query = new WP_Query($query_args);
233 233
         $posts_array = $course_query->get_posts();
234 234
 
235 235
         // output the courses
236
-        if( ! empty( $posts_array ) ) {
236
+        if ( ! empty($posts_array)) {
237 237
 
238 238
             //output all courses for current query
239
-            self::loop_courses( $course_query, $amount );
239
+            self::loop_courses($course_query, $amount);
240 240
 
241 241
         }
242 242
 
@@ -249,31 +249,31 @@  discard block
 block discarded – undo
249 249
      *
250 250
      * @param WP_Query $course_query
251 251
      */
252
-    public static function loop_courses( $course_query, $amount ){
252
+    public static function loop_courses($course_query, $amount) {
253 253
 
254 254
         global $shortcode_override, $posts_array, $post, $wp_query, $shortcode_override, $course_excludes, $course_includes;
255 255
 
256
-        if ( count( $course_query->get_posts() ) > 0 ) {
256
+        if (count($course_query->get_posts()) > 0) {
257 257
 
258
-            do_action( 'sensei_course_archive_header', $shortcode_override );
258
+            do_action('sensei_course_archive_header', $shortcode_override);
259 259
 
260
-            foreach ( $course_query->get_posts() as $course){
260
+            foreach ($course_query->get_posts() as $course) {
261 261
 
262 262
                 // Make sure the other loops dont include the same post twice!
263
-                array_push( $course_excludes, $course->ID );
263
+                array_push($course_excludes, $course->ID);
264 264
 
265 265
                 // output the course markup
266
-                self::the_course( $course->ID );
266
+                self::the_course($course->ID);
267 267
 
268 268
             } // End For Loop
269 269
 
270 270
             // More and Prev links
271
-            $posts_array_query = new WP_Query(Sensei()->course->course_query( $shortcode_override, $amount, $course_includes, $course_excludes ) );
271
+            $posts_array_query = new WP_Query(Sensei()->course->course_query($shortcode_override, $amount, $course_includes, $course_excludes));
272 272
             $posts_array       = $posts_array_query->get_posts();
273 273
             $max_pages = $course_query->found_posts / $amount;
274
-            if ( '' != $shortcode_override && ( $max_pages > $course_query->get( 'paged' ) ) ) {
274
+            if ('' != $shortcode_override && ($max_pages > $course_query->get('paged'))) {
275 275
 
276
-                switch( $shortcode_override ){
276
+                switch ($shortcode_override) {
277 277
                     case 'paidcourses':
278 278
                         $filter = 'paid';
279 279
                         break;
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
                 }
290 290
 
291 291
                 $quer_args = array();
292
-                $quer_args[ 'paged' ] = '2';
293
-                if( !empty( $filter ) ){
294
-                    $quer_args[ 'course_filter' ] = $filter;
292
+                $quer_args['paged'] = '2';
293
+                if ( ! empty($filter)) {
294
+                    $quer_args['course_filter'] = $filter;
295 295
                 }
296 296
 
297
-                $course_pagination_link = get_post_type_archive_link( 'course' );
298
-                $more_link_text = esc_html( Sensei()->settings->settings[ 'course_archive_more_link_text' ] );
299
-                $more_link_url =  esc_url( add_query_arg( $quer_args, $course_pagination_link ) );
297
+                $course_pagination_link = get_post_type_archive_link('course');
298
+                $more_link_text = esc_html(Sensei()->settings->settings['course_archive_more_link_text']);
299
+                $more_link_url = esc_url(add_query_arg($quer_args, $course_pagination_link));
300 300
 
301 301
                 // next/more
302 302
                 $html  = '<div class="navigation"><div class="nav-next">';
303
-                $html .= '<a href="' . $more_link_url . '">';
303
+                $html .= '<a href="'.$more_link_url.'">';
304 304
                 $html .= $more_link_text;
305 305
                 $html .= '<span class="meta-nav"></span></a></div>';
306 306
 
307
-                echo apply_filters( 'course_archive_next_link', $html );
307
+                echo apply_filters('course_archive_next_link', $html);
308 308
 
309 309
             } // End If Statement
310 310
 
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
      *
317 317
      * @param $course_id
318 318
      */
319
-    public static function the_course( $course_id ){
319
+    public static function the_course($course_id) {
320 320
 
321 321
         // Get meta data
322
-        $course =  get_post( $course_id );
323
-        $user_info = get_userdata( absint( $course->post_author ) );
324
-        $author_link = get_author_posts_url( absint( $course->post_author ) );
322
+        $course = get_post($course_id);
323
+        $user_info = get_userdata(absint($course->post_author));
324
+        $author_link = get_author_posts_url(absint($course->post_author));
325 325
         $author_display_name = $user_info->display_name;
326 326
         $author_id = $course->post_author;
327
-        $category_output = get_the_term_list( $course_id, 'course-category', '', ', ', '' );
328
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course_id ) );
329
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
327
+        $category_output = get_the_term_list($course_id, 'course-category', '', ', ', '');
328
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course_id));
329
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
330 330
         ?>
331 331
 
332
-        <article class="<?php echo esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_id ) ) ); ?>">
332
+        <article class="<?php echo esc_attr(join(' ', get_post_class(array('course', 'post'), $course_id))); ?>">
333 333
             <?php
334 334
             // so that legacy shortcodes work with the party plugins that wants to hook in
335
-            do_action('sensei_course_content_before',$course->ID );
335
+            do_action('sensei_course_content_before', $course->ID);
336 336
             ?>
337 337
             <div class="course-content">
338 338
 
@@ -348,19 +348,19 @@  discard block
 block discarded – undo
348 348
 
349 349
                     <p class="sensei-course-meta">
350 350
 
351
-                        <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
352
-                            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name   ); ?></a></span>
351
+                        <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
352
+                            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
353 353
                         <?php } // End If Statement ?>
354 354
 
355 355
                         <span class="course-lesson-count">
356
-                                    <?php echo Sensei()->course->course_lesson_count( $course_id ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?>
356
+                                    <?php echo Sensei()->course->course_lesson_count($course_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?>
357 357
                                 </span>
358 358
 
359
-                        <?php if ( '' != $category_output ) { ?>
360
-                            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
359
+                        <?php if ('' != $category_output) { ?>
360
+                            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
361 361
                         <?php } // End If Statement ?>
362 362
 
363
-                        <?php sensei_simple_course_price( $course_id ); ?>
363
+                        <?php sensei_simple_course_price($course_id); ?>
364 364
 
365 365
                     </p>
366 366
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 
369 369
                     </p>
370 370
 
371
-                    <?php if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
372
-                        $preview_lessons = sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ); ?>
371
+                    <?php if (0 < $preview_lesson_count && ! $is_user_taking_course) {
372
+                        $preview_lessons = sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
373 373
                         <p class="sensei-free-lessons">
374
-                            <a href="<?php echo get_permalink( $course_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
374
+                            <a href="<?php echo get_permalink($course_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?>
375 375
                             </a> - <?php echo $preview_lessons; ?>
376 376
                         </p>
377 377
                     <?php } ?>
Please login to merge, or discard this patch.
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
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param $file
24 24
 	 */
25
-	public function __construct ( $file = __FILE__ ) {
25
+	public function __construct($file = __FILE__) {
26 26
 		$this->file = $file;
27 27
         $this->token = 'quiz';
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_single_quiz_content_inside_before', array( $this, 'user_quiz_submit_listener' ) );
35
+        add_action('sensei_single_quiz_content_inside_before', array($this, 'user_quiz_submit_listener'));
36 36
 
37 37
 		// fire the save user answers quiz button click responder
38
-		add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_save_quiz_answers_listener' ) );
38
+		add_action('sensei_single_quiz_content_inside_before', array($this, 'user_save_quiz_answers_listener'));
39 39
 
40 40
         // fire the load global data function
41
-        add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'load_global_quiz_data' ), 80 );
41
+        add_action('sensei_single_quiz_content_inside_before', 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,25 +51,25 @@  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
 		// If this isn't a 'lesson' post, don't update it.
57 57
         // if this is a revision don't save it
58
-	    if ( isset( $_POST['post_type'] ) && 'lesson' != $_POST['post_type']
59
-            || wp_is_post_revision( $post_id ) ) {
58
+	    if (isset($_POST['post_type']) && 'lesson' != $_POST['post_type']
59
+            || wp_is_post_revision($post_id)) {
60 60
 
61 61
                 return;
62 62
 
63 63
         }
64 64
 	    // get the lesson author id to be use late
65
-	    $saved_post = get_post( $post_id );
66
-	    $new_lesson_author_id =  $saved_post->post_author;
65
+	    $saved_post = get_post($post_id);
66
+	    $new_lesson_author_id = $saved_post->post_author;
67 67
 
68 68
 	    //get the lessons quiz
69
-		$lesson_quizzes = Sensei()->lesson->lesson_quizzes( $post_id );
70
-	    foreach ( (array) $lesson_quizzes as $quiz_item ) {
69
+		$lesson_quizzes = Sensei()->lesson->lesson_quizzes($post_id);
70
+	    foreach ((array) $lesson_quizzes as $quiz_item) {
71 71
 
72
-	    	if( ! $quiz_item ) {
72
+	    	if ( ! $quiz_item) {
73 73
 	    		continue;
74 74
 	    	}
75 75
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 			);
81 81
 
82 82
             // remove the action so that it doesn't fire again
83
-            remove_action( 'save_post', array( $this, 'update_author' ));
83
+            remove_action('save_post', array($this, 'update_author'));
84 84
 
85 85
 			// Update the post into the database
86
-		  	wp_update_post( $my_post );
86
+		  	wp_update_post($my_post);
87 87
 	    }
88 88
 
89 89
 	    return;
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 * @param int $quiz_id
98 98
 	 * @return int @lesson_id
99 99
 	 */
100
-	public function get_lesson_id( $quiz_id ){
100
+	public function get_lesson_id($quiz_id) {
101 101
 
102
-		if( empty( $quiz_id ) || ! intval( $quiz_id ) > 0 ){
102
+		if (empty($quiz_id) || ! intval($quiz_id) > 0) {
103 103
 			global $post;
104
-			if( 'quiz' == get_post_type( $post ) ){
104
+			if ('quiz' == get_post_type($post)) {
105 105
 				$quiz_id = $post->ID;
106
-			}else{
106
+			} else {
107 107
 				return false;
108 108
 			}
109 109
 
110 110
 		}
111 111
 
112
-		$quiz = get_post( $quiz_id );
112
+		$quiz = get_post($quiz_id);
113 113
 		$lesson_id = $quiz->post_parent;
114 114
 
115 115
 		return $lesson_id;
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
      * @since 1.7.3
125 125
      * @return bool $saved;
126 126
      */
127
-    public function user_save_quiz_answers_listener(){
127
+    public function user_save_quiz_answers_listener() {
128 128
 
129
-        if( ! isset( $_POST[ 'quiz_save' ])
130
-            || !isset( $_POST[ 'sensei_question' ] )
131
-            || empty( $_POST[ 'sensei_question' ] )
132
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce'  ) > 1 ) {
129
+        if ( ! isset($_POST['quiz_save'])
130
+            || ! isset($_POST['sensei_question'])
131
+            || empty($_POST['sensei_question'])
132
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_save_quiz_nonce'], 'woothemes_sensei_save_quiz_nonce') > 1) {
133 133
             return;
134 134
         }
135 135
 
136 136
         global $post;
137
-        $lesson_id = $this->get_lesson_id( $post->ID );
138
-        $quiz_answers = $_POST[ 'sensei_question' ];
137
+        $lesson_id = $this->get_lesson_id($post->ID);
138
+        $quiz_answers = $_POST['sensei_question'];
139 139
         // call the save function
140
-        self::save_user_answers( $quiz_answers, $_FILES , $lesson_id  , get_current_user_id() );
140
+        self::save_user_answers($quiz_answers, $_FILES, $lesson_id, get_current_user_id());
141 141
 
142 142
         // remove the hook as it should only fire once per click
143
-        remove_action( 'sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener' );
143
+        remove_action('sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener');
144 144
 
145 145
     } // end user_save_quiz_answers_listener
146 146
 
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return false or int $answers_saved
161 161
 	 */
162
-	public static function save_user_answers( $quiz_answers, $files = array(), $lesson_id , $user_id = 0 ){
162
+	public static function save_user_answers($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
163 163
 
164
-        if( ! ( $user_id > 0 ) ){
164
+        if ( ! ($user_id > 0)) {
165 165
             $user_id = get_current_user_id();
166 166
         }
167 167
 
168 168
         // make sure the parameters are valid before continuing
169
-		if( empty( $lesson_id ) || empty( $user_id )
170
-			|| 'lesson' != get_post_type( $lesson_id )
171
-			||!get_userdata( $user_id )
172
-			|| !is_array( $quiz_answers ) ){
169
+		if (empty($lesson_id) || empty($user_id)
170
+			|| 'lesson' != get_post_type($lesson_id)
171
+			||! get_userdata($user_id)
172
+			|| ! is_array($quiz_answers)) {
173 173
 
174 174
 			return false;
175 175
 
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
         // start the lesson before saving the data in case the user has not started the lesson
180
-        $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
180
+        $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
181 181
 
182 182
 		//prepare the answers
183
-		$prepared_answers = self::prepare_form_submitted_answers( $quiz_answers , $files );
183
+		$prepared_answers = self::prepare_form_submitted_answers($quiz_answers, $files);
184 184
 
185 185
 		// save the user data
186
-        $answers_saved = Sensei_Utils::add_user_data( 'quiz_answers', $lesson_id, $prepared_answers, $user_id ) ;
186
+        $answers_saved = Sensei_Utils::add_user_data('quiz_answers', $lesson_id, $prepared_answers, $user_id);
187 187
 
188 188
 		// were the answers saved correctly?
189
-		if( intval( $answers_saved ) > 0){
189
+		if (intval($answers_saved) > 0) {
190 190
 
191 191
             // save transient to make retrieval faster
192 192
             $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
193
-            set_transient( $transient_key, $prepared_answers, 10 * DAY_IN_SECONDS );
193
+            set_transient($transient_key, $prepared_answers, 10 * DAY_IN_SECONDS);
194 194
 
195 195
             // update the message showed to user
196
-            Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Saved Successfully.', 'woothemes-sensei' )  . '</div>';
196
+            Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Saved Successfully.', 'woothemes-sensei').'</div>';
197 197
         }
198 198
 
199 199
 		return $answers_saved;
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array $answers or false
217 217
 	 */
218
-	public function get_user_answers( $lesson_id, $user_id ){
218
+	public function get_user_answers($lesson_id, $user_id) {
219 219
 
220 220
 		$answers = false;
221 221
 
222
-		if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
223
-		|| ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
222
+		if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
223
+		|| ! intval($user_id) > 0 || ! get_userdata($user_id)) {
224 224
 			return false;
225 225
 		}
226 226
 
227 227
         // save some time and get the transient cached data
228 228
         $transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
229
-        $transient_cached_answers = get_transient( $transient_key );
229
+        $transient_cached_answers = get_transient($transient_key);
230 230
 
231 231
         // return the transient or get the values get the values from the comment meta
232
-        if( !empty( $transient_cached_answers  ) && false != $transient_cached_answers ){
232
+        if ( ! empty($transient_cached_answers) && false != $transient_cached_answers) {
233 233
 
234 234
             $encoded_user_answers = $transient_cached_answers;
235 235
 
236
-        }else{
236
+        } else {
237 237
 
238
-            $encoded_user_answers = Sensei_Utils::get_user_data( 'quiz_answers', $lesson_id  , $user_id );
238
+            $encoded_user_answers = Sensei_Utils::get_user_data('quiz_answers', $lesson_id, $user_id);
239 239
 
240 240
         } // end if transient check
241 241
 
242
-		if( ! is_array( $encoded_user_answers ) ){
242
+		if ( ! is_array($encoded_user_answers)) {
243 243
 			return false;
244 244
 		}
245 245
 
246 246
         //set the transient with the new valid data for faster retrieval in future
247
-        set_transient( $transient_key,  $encoded_user_answers, 10 * DAY_IN_SECONDS);
247
+        set_transient($transient_key, $encoded_user_answers, 10 * DAY_IN_SECONDS);
248 248
 
249 249
 		// decode an unserialize all answers
250
-		foreach( $encoded_user_answers as $question_id => $encoded_answer ) {
251
-			$decoded_answer = base64_decode( $encoded_answer );
252
-			$answers[$question_id] = maybe_unserialize( $decoded_answer );
250
+		foreach ($encoded_user_answers as $question_id => $encoded_answer) {
251
+			$decoded_answer = base64_decode($encoded_answer);
252
+			$answers[$question_id] = maybe_unserialize($decoded_answer);
253 253
 		}
254 254
 
255 255
 		return $answers;
@@ -266,23 +266,23 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return void;
268 268
 	 */
269
-	public function reset_button_click_listener( ){
269
+	public function reset_button_click_listener( ) {
270 270
 
271
-		if( ! isset( $_POST[ 'quiz_reset' ])
272
-			||  ! wp_verify_nonce( $_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce'  ) > 1 ) {
271
+		if ( ! isset($_POST['quiz_reset'])
272
+			||  ! wp_verify_nonce($_POST['woothemes_sensei_reset_quiz_nonce'], 'woothemes_sensei_reset_quiz_nonce') > 1) {
273 273
 
274 274
 			return; // exit
275 275
 		}
276 276
 
277 277
 		global $post;
278 278
 		$current_quiz_id = $post->ID;
279
-		$lesson_id = $this->get_lesson_id( $current_quiz_id );
279
+		$lesson_id = $this->get_lesson_id($current_quiz_id);
280 280
 
281 281
         // reset all user data
282
-        $this->reset_user_lesson_data( $lesson_id, get_current_user_id() );
282
+        $this->reset_user_lesson_data($lesson_id, get_current_user_id());
283 283
 
284 284
 		//this function should only run once
285
-		remove_action( 'template_redirect', array( $this, 'reset_button_click_listener'  ) );
285
+		remove_action('template_redirect', array($this, 'reset_button_click_listener'));
286 286
 
287 287
 	} // end reset_button_click_listener
288 288
 
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	public function user_quiz_submit_listener() {
302 302
 
303 303
         // only respond to valid quiz completion submissions
304
-        if( ! isset( $_POST[ 'quiz_complete' ])
305
-            || !isset( $_POST[ 'sensei_question' ] )
306
-            || empty( $_POST[ 'sensei_question' ] )
307
-            ||  ! wp_verify_nonce( $_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce'  ) > 1 ) {
304
+        if ( ! isset($_POST['quiz_complete'])
305
+            || ! isset($_POST['sensei_question'])
306
+            || empty($_POST['sensei_question'])
307
+            ||  ! wp_verify_nonce($_POST['woothemes_sensei_complete_quiz_nonce'], 'woothemes_sensei_complete_quiz_nonce') > 1) {
308 308
             return;
309 309
         }
310 310
 
311 311
         global $post, $current_user;
312
-        $lesson_id = $this->get_lesson_id( $post->ID );
313
-        $quiz_answers = $_POST[ 'sensei_question' ];
312
+        $lesson_id = $this->get_lesson_id($post->ID);
313
+        $quiz_answers = $_POST['sensei_question'];
314 314
 
315
-        self::submit_answers_for_grading( $quiz_answers, $_FILES ,  $lesson_id  , $current_user->ID );
315
+        self::submit_answers_for_grading($quiz_answers, $_FILES, $lesson_id, $current_user->ID);
316 316
 
317 317
 	} // End sensei_complete_quiz()
318 318
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      * @access public
327 327
      *
328 328
      */
329
-    public function load_global_quiz_data(){
329
+    public function load_global_quiz_data() {
330 330
 
331 331
         global  $post, $current_user;
332 332
         $this->data = new stdClass();
@@ -335,46 +335,46 @@  discard block
 block discarded – undo
335 335
         $grade = 0;
336 336
 
337 337
         // Get Quiz Questions
338
-        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $post->ID );
338
+        $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($post->ID);
339 339
 
340
-        $quiz_lesson_id = absint( get_post_meta( $post->ID, '_quiz_lesson', true ) );
340
+        $quiz_lesson_id = absint(get_post_meta($post->ID, '_quiz_lesson', true));
341 341
 
342 342
         // Get quiz grade type
343
-        $quiz_grade_type = get_post_meta( $post->ID, '_quiz_grade_type', true );
343
+        $quiz_grade_type = get_post_meta($post->ID, '_quiz_grade_type', true);
344 344
 
345 345
         // Get quiz pass setting
346
-        $pass_required = get_post_meta( $post->ID, '_pass_required', true );
346
+        $pass_required = get_post_meta($post->ID, '_pass_required', true);
347 347
 
348 348
         // Get quiz pass mark
349
-        $quiz_passmark = abs( round( doubleval( get_post_meta( $post->ID, '_quiz_passmark', true ) ), 2 ) );
349
+        $quiz_passmark = abs(round(doubleval(get_post_meta($post->ID, '_quiz_passmark', true)), 2));
350 350
 
351 351
         // Get latest quiz answers and grades
352
-        $lesson_id = Sensei()->quiz->get_lesson_id( $post->ID );
353
-        $user_quizzes = Sensei()->quiz->get_user_answers( $lesson_id, get_current_user_id() );
354
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $current_user->ID );
352
+        $lesson_id = Sensei()->quiz->get_lesson_id($post->ID);
353
+        $user_quizzes = Sensei()->quiz->get_user_answers($lesson_id, get_current_user_id());
354
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $current_user->ID);
355 355
         $user_quiz_grade = 0;
356
-        if( isset( $user_lesson_status->comment_ID ) ) {
357
-            $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
356
+        if (isset($user_lesson_status->comment_ID)) {
357
+            $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
358 358
         }
359 359
 
360
-        if ( ! is_array($user_quizzes) ) { $user_quizzes = array(); }
360
+        if ( ! is_array($user_quizzes)) { $user_quizzes = array(); }
361 361
 
362 362
         // Check again that the lesson is complete
363
-        $user_lesson_end = Sensei_Utils::user_completed_lesson( $user_lesson_status );
363
+        $user_lesson_end = Sensei_Utils::user_completed_lesson($user_lesson_status);
364 364
         $user_lesson_complete = false;
365
-        if ( $user_lesson_end ) {
365
+        if ($user_lesson_end) {
366 366
             $user_lesson_complete = true;
367 367
         } // End If Statement
368 368
 
369
-        $reset_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true );
369
+        $reset_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true);
370 370
         //backwards compatibility
371
-        if( 'on' == $reset_allowed ) {
371
+        if ('on' == $reset_allowed) {
372 372
             $reset_allowed = 1;
373 373
         }
374 374
 
375 375
         // Build frontend data object for backwards compatibility
376 376
         // using this is no longer recommended
377
-        $this->data->user_quiz_grade = $user_quiz_grade;// Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
377
+        $this->data->user_quiz_grade = $user_quiz_grade; // Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() );
378 378
         $this->data->quiz_passmark = $quiz_passmark;
379 379
         $this->data->quiz_lesson = $quiz_lesson_id;
380 380
         $this->data->quiz_grade_type = $quiz_grade_type; // get_post_meta( $quiz_id, '_quiz_grade_type', true );
@@ -399,41 +399,41 @@  discard block
 block discarded – undo
399 399
 	 * @param $files
400 400
 	 * @return array
401 401
 	 */
402
-	public static function prepare_form_submitted_answers( $unprepared_answers,  $files ){
402
+	public static function prepare_form_submitted_answers($unprepared_answers, $files) {
403 403
 
404 404
 
405 405
 		$prepared_answers = array();
406 406
 
407 407
 		// validate incoming answers
408
-		if( empty( $unprepared_answers  ) || ! is_array( $unprepared_answers ) ){
408
+		if (empty($unprepared_answers) || ! is_array($unprepared_answers)) {
409 409
 			return false;
410 410
 		}
411 411
 
412 412
 		// Loop through submitted quiz answers and save them appropriately
413
-		foreach( $unprepared_answers as $question_id => $answer ) {
413
+		foreach ($unprepared_answers as $question_id => $answer) {
414 414
 
415 415
 			//get the current questions question type
416
-            $question_type = Sensei()->question->get_question_type( $question_id );
416
+            $question_type = Sensei()->question->get_question_type($question_id);
417 417
 
418 418
 			// Sanitise answer
419
-			if( 0 == get_magic_quotes_gpc() ) {
420
-				$answer = wp_unslash( $answer );
419
+			if (0 == get_magic_quotes_gpc()) {
420
+				$answer = wp_unslash($answer);
421 421
 			}
422 422
 
423 423
             // compress the answer for saving
424
-			if( 'multi-line' == $question_type ) {
425
-                $answer = esc_html( $answer );
426
-            }elseif( 'file-upload' == $question_type  ){
427
-                $file_key = 'file_upload_' . $question_id;
428
-                if( isset( $files[ $file_key ] ) ) {
429
-                        $attachment_id = Sensei_Utils::upload_file(  $files[ $file_key ] );
430
-                        if( $attachment_id ) {
424
+			if ('multi-line' == $question_type) {
425
+                $answer = esc_html($answer);
426
+            }elseif ('file-upload' == $question_type) {
427
+                $file_key = 'file_upload_'.$question_id;
428
+                if (isset($files[$file_key])) {
429
+                        $attachment_id = Sensei_Utils::upload_file($files[$file_key]);
430
+                        if ($attachment_id) {
431 431
                             $answer = $attachment_id;
432 432
                         }
433 433
                     }
434 434
             } // end if
435 435
 
436
-			$prepared_answers[ $question_id ] =  base64_encode( maybe_serialize( $answer ) );
436
+			$prepared_answers[$question_id] = base64_encode(maybe_serialize($answer));
437 437
 
438 438
 		}// end for each $quiz_answers
439 439
 
@@ -453,54 +453,54 @@  discard block
 block discarded – undo
453 453
      * @param int $user_id
454 454
      * @param int $lesson_id
455 455
      */
456
-    public function reset_user_lesson_data( $lesson_id , $user_id = 0 ){
456
+    public function reset_user_lesson_data($lesson_id, $user_id = 0) {
457 457
 
458 458
         //make sure the parameters are valid
459
-        if( empty( $lesson_id ) || empty( $user_id )
460
-            || 'lesson' != get_post_type( $lesson_id )
461
-            || ! get_userdata( $user_id ) ){
459
+        if (empty($lesson_id) || empty($user_id)
460
+            || 'lesson' != get_post_type($lesson_id)
461
+            || ! get_userdata($user_id)) {
462 462
             return false;
463 463
         }
464 464
 
465 465
 
466 466
 
467 467
         //get the users lesson status to make
468
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
469
-        if( ! isset( $user_lesson_status->comment_ID ) ) {
468
+        $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
469
+        if ( ! isset($user_lesson_status->comment_ID)) {
470 470
             // this user is not taking this lesson so this process is not needed
471 471
             return false;
472 472
         }
473 473
 
474 474
         //get the lesson quiz and course
475
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
476
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
475
+        $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
476
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
477 477
 
478 478
         // reset the transients
479 479
         $answers_transient_key = 'sensei_answers_'.$user_id.'_'.$lesson_id;
480 480
         $grades_transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
481 481
         $answers_feedback_transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
482
-        delete_transient( $answers_transient_key );
483
-        delete_transient( $grades_transient_key );
484
-        delete_transient( $answers_feedback_transient_key );
482
+        delete_transient($answers_transient_key);
483
+        delete_transient($grades_transient_key);
484
+        delete_transient($answers_feedback_transient_key);
485 485
 
486 486
         // reset the quiz answers and feedback notes
487
-        $deleted_answers = Sensei_Utils::delete_user_data( 'quiz_answers', $lesson_id, $user_id );
488
-        $deleted_grades = Sensei_Utils::delete_user_data( 'quiz_grades', $lesson_id, $user_id );
489
-        $deleted_user_feedback = Sensei_Utils::delete_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
487
+        $deleted_answers = Sensei_Utils::delete_user_data('quiz_answers', $lesson_id, $user_id);
488
+        $deleted_grades = Sensei_Utils::delete_user_data('quiz_grades', $lesson_id, $user_id);
489
+        $deleted_user_feedback = Sensei_Utils::delete_user_data('quiz_answers_feedback', $lesson_id, $user_id);
490 490
 
491 491
         // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade
492
-        Sensei_Utils::sensei_delete_quiz_answers( $quiz_id, $user_id );
492
+        Sensei_Utils::sensei_delete_quiz_answers($quiz_id, $user_id);
493 493
 
494
-        Sensei_Utils::update_lesson_status( $user_id , $lesson_id, 'in-progress', array( 'questions_asked' => '', 'grade' => '' ) );
494
+        Sensei_Utils::update_lesson_status($user_id, $lesson_id, 'in-progress', array('questions_asked' => '', 'grade' => ''));
495 495
 
496 496
         // Update course completion
497
-        Sensei_Utils::update_course_status( $user_id, $course_id );
497
+        Sensei_Utils::update_course_status($user_id, $course_id);
498 498
 
499 499
         // Run any action on quiz/lesson reset (previously this didn't occur on resetting a quiz, see resetting a lesson in sensei_complete_lesson()
500
-        do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id );
501
-        Sensei()->frontend->messages = '<div class="sensei-message note">' . __( 'Quiz Reset Successfully.', 'woothemes-sensei' ) . '</div>';
500
+        do_action('sensei_user_lesson_reset', $user_id, $lesson_id);
501
+        Sensei()->frontend->messages = '<div class="sensei-message note">'.__('Quiz Reset Successfully.', 'woothemes-sensei').'</div>';
502 502
 
503
-        return ( $deleted_answers && $deleted_grades ) ;
503
+        return ($deleted_answers && $deleted_grades);
504 504
 
505 505
     } // end reset_user_lesson_data
506 506
 
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
       *
521 521
       * @return bool $answers_submitted
522 522
       */
523
-     public static function submit_answers_for_grading( $quiz_answers , $files = array() , $lesson_id , $user_id = 0 ){
523
+     public static function submit_answers_for_grading($quiz_answers, $files = array(), $lesson_id, $user_id = 0) {
524 524
 
525 525
          $answers_submitted = false;
526 526
 
527 527
          // get the user_id if none was passed in use the current logged in user
528
-         if( ! intval( $user_id ) > 0 ) {
528
+         if ( ! intval($user_id) > 0) {
529 529
              $user_id = get_current_user_id();
530 530
          }
531 531
 
532 532
          // make sure the parameters are valid before continuing
533
-         if( empty( $lesson_id ) || empty( $user_id )
534
-             || 'lesson' != get_post_type( $lesson_id )
535
-             ||!get_userdata( $user_id )
536
-             || !is_array( $quiz_answers ) ){
533
+         if (empty($lesson_id) || empty($user_id)
534
+             || 'lesson' != get_post_type($lesson_id)
535
+             ||! get_userdata($user_id)
536
+             || ! is_array($quiz_answers)) {
537 537
 
538 538
              return false;
539 539
 
@@ -543,38 +543,38 @@  discard block
 block discarded – undo
543 543
          $grade = 0;
544 544
 
545 545
          // Get Quiz ID
546
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
546
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
547 547
 
548 548
          // Get quiz grade type
549
-         $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true );
549
+         $quiz_grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true);
550 550
 
551 551
          // Get quiz pass setting
552
-         $pass_required = get_post_meta( $quiz_id, '_pass_required', true );
552
+         $pass_required = get_post_meta($quiz_id, '_pass_required', true);
553 553
 
554 554
          // Get the minimum percentage need to pass this quiz
555
-         $quiz_pass_percentage = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
555
+         $quiz_pass_percentage = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2));
556 556
 
557 557
          // Handle Quiz Questions asked
558 558
          // This is to ensure we save the questions that we've asked this user and that this can't be change unless
559 559
          // the quiz is reset by admin or user( user: only if the setting is enabled ).
560 560
          // get the questions asked when when the quiz questions were generated for the user : Sensei_Lesson::lesson_quiz_questions
561
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
562
-         $questions_asked = get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true );
563
-         if( empty( $questions_asked ) ){
561
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
562
+         $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
563
+         if (empty($questions_asked)) {
564 564
 
565
-             $questions_asked = array_keys( $quiz_answers );
566
-             $questions_asked_string = implode( ',', $questions_asked );
565
+             $questions_asked = array_keys($quiz_answers);
566
+             $questions_asked_string = implode(',', $questions_asked);
567 567
 
568 568
              // Save questions that were asked in this quiz
569
-             update_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string );
569
+             update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_string);
570 570
 
571 571
          }
572 572
 
573 573
          // Save Quiz Answers for grading, the save function also calls the sensei_start_lesson
574
-         self::save_user_answers( $quiz_answers , $files , $lesson_id , $user_id );
574
+         self::save_user_answers($quiz_answers, $files, $lesson_id, $user_id);
575 575
 
576 576
          // Grade quiz
577
-         $grade = Sensei_Grading::grade_quiz_auto( $quiz_id, $quiz_answers, 0 , $quiz_grade_type );
577
+         $grade = Sensei_Grading::grade_quiz_auto($quiz_id, $quiz_answers, 0, $quiz_grade_type);
578 578
 
579 579
          // Get Lesson Grading Setting
580 580
          $lesson_metadata = array();
@@ -584,13 +584,13 @@  discard block
 block discarded – undo
584 584
          $answers_submitted = true;
585 585
 
586 586
          // if this condition is false the quiz should manually be graded by admin
587
-         if ('auto' == $quiz_grade_type && ! is_wp_error( $grade )  ) {
587
+         if ('auto' == $quiz_grade_type && ! is_wp_error($grade)) {
588 588
 
589 589
              // Quiz has been automatically Graded
590
-             if ( 'on' == $pass_required ) {
590
+             if ('on' == $pass_required) {
591 591
 
592 592
                  // Student has reached the pass mark and lesson is complete
593
-                 if ( $quiz_pass_percentage <= $grade ) {
593
+                 if ($quiz_pass_percentage <= $grade) {
594 594
 
595 595
                      $lesson_status = 'passed';
596 596
 
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
 
612 612
          } // end if ! is_wp_error( $grade ...
613 613
 
614
-         Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $lesson_status, $lesson_metadata );
614
+         Sensei_Utils::update_lesson_status($user_id, $lesson_id, $lesson_status, $lesson_metadata);
615 615
 
616
-         if( 'passed' == $lesson_status || 'graded' == $lesson_status ){
616
+         if ('passed' == $lesson_status || 'graded' == $lesson_status) {
617 617
 
618 618
              /**
619 619
               * Lesson end action hook
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
               * @param int $user_id
624 624
               * @param int $lesson_id
625 625
               */
626
-             do_action( 'sensei_user_lesson_end', $user_id, $lesson_id );
626
+             do_action('sensei_user_lesson_end', $user_id, $lesson_id);
627 627
 
628 628
          }
629 629
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
           * @param string $quiz_pass_percentage
640 640
           * @param string $quiz_grade_type
641 641
           */
642
-         do_action( 'sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type );
642
+         do_action('sensei_user_quiz_submitted', $user_id, $quiz_id, $grade, $quiz_pass_percentage, $quiz_grade_type);
643 643
 
644 644
          return $answers_submitted;
645 645
 
@@ -659,38 +659,38 @@  discard block
 block discarded – undo
659 659
       *
660 660
       * @return bool $answers_submitted
661 661
       */
662
-     public function get_user_question_answer( $lesson_id, $question_id, $user_id = 0 ){
662
+     public function get_user_question_answer($lesson_id, $question_id, $user_id = 0) {
663 663
 
664 664
          // parameter validation
665
-         if( empty( $lesson_id ) || empty( $question_id )
666
-             || ! ( intval( $lesson_id  ) > 0 )
667
-             || ! ( intval( $question_id  ) > 0 )
668
-             || 'lesson' != get_post_type( $lesson_id )
669
-             || 'question' != get_post_type( $question_id )) {
665
+         if (empty($lesson_id) || empty($question_id)
666
+             || ! (intval($lesson_id) > 0)
667
+             || ! (intval($question_id) > 0)
668
+             || 'lesson' != get_post_type($lesson_id)
669
+             || 'question' != get_post_type($question_id)) {
670 670
 
671 671
              return false;
672 672
          }
673 673
 
674
-         if( ! ( intval( $user_id ) > 0 )   ){
674
+         if ( ! (intval($user_id) > 0)) {
675 675
              $user_id = get_current_user_id();
676 676
          }
677 677
 
678
-         $users_answers = $this->get_user_answers( $lesson_id, $user_id );
678
+         $users_answers = $this->get_user_answers($lesson_id, $user_id);
679 679
 
680
-         if( !$users_answers || empty( $users_answers )
681
-         ||  ! is_array( $users_answers ) || ! isset( $users_answers[ $question_id ] ) ){
680
+         if ( ! $users_answers || empty($users_answers)
681
+         ||  ! is_array($users_answers) || ! isset($users_answers[$question_id])) {
682 682
 
683 683
              //Fallback for pre 1.7.4 data
684
-             $comment =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ), true );
684
+             $comment = Sensei_Utils::sensei_check_for_activity(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer'), true);
685 685
 
686
-             if( ! isset( $comment->comment_content ) ){
686
+             if ( ! isset($comment->comment_content)) {
687 687
                  return false;
688 688
              }
689 689
 
690
-             return maybe_unserialize( base64_decode( $comment->comment_content ) );
690
+             return maybe_unserialize(base64_decode($comment->comment_content));
691 691
          }
692 692
 
693
-         return $users_answers[ $question_id ];
693
+         return $users_answers[$question_id];
694 694
 
695 695
      }// end get_user_question_answer
696 696
 
@@ -711,18 +711,18 @@  discard block
 block discarded – undo
711 711
       *
712 712
       * @return bool
713 713
       */
714
-     public function set_user_grades( $quiz_grades, $lesson_id, $user_id = 0 ){
714
+     public function set_user_grades($quiz_grades, $lesson_id, $user_id = 0) {
715 715
 
716 716
          // get the user_id if none was passed in use the current logged in user
717
-         if( ! intval( $user_id ) > 0 ) {
717
+         if ( ! intval($user_id) > 0) {
718 718
              $user_id = get_current_user_id();
719 719
          }
720 720
 
721 721
          // make sure the parameters are valid before continuing
722
-         if( empty( $lesson_id ) || empty( $user_id )
723
-             || 'lesson' != get_post_type( $lesson_id )
724
-             ||!get_userdata( $user_id )
725
-             || !is_array( $quiz_grades ) ){
722
+         if (empty($lesson_id) || empty($user_id)
723
+             || 'lesson' != get_post_type($lesson_id)
724
+             ||! get_userdata($user_id)
725
+             || ! is_array($quiz_grades)) {
726 726
 
727 727
              return false;
728 728
 
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
          $success = false;
732 732
 
733 733
          // save that data for the user on the lesson comment meta
734
-         $comment_meta_id = Sensei_Utils::add_user_data( 'quiz_grades', $lesson_id, $quiz_grades, $user_id   );
734
+         $comment_meta_id = Sensei_Utils::add_user_data('quiz_grades', $lesson_id, $quiz_grades, $user_id);
735 735
 
736 736
          // were the grades save successfully ?
737
-         if( intval( $comment_meta_id ) > 0 ) {
737
+         if (intval($comment_meta_id) > 0) {
738 738
 
739 739
              $success = true;
740 740
              // save transient
741
-             $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
742
-             set_transient( $transient_key, $quiz_grades, 10 * DAY_IN_SECONDS );
741
+             $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
742
+             set_transient($transient_key, $quiz_grades, 10 * DAY_IN_SECONDS);
743 743
          }
744 744
 
745 745
          return $success;
@@ -758,36 +758,36 @@  discard block
 block discarded – undo
758 758
       *
759 759
       * @return array $user_quiz_grades or false if none exists for this users
760 760
       */
761
-     public function get_user_grades( $lesson_id, $user_id = 0 ){
761
+     public function get_user_grades($lesson_id, $user_id = 0) {
762 762
 
763 763
          $user_grades = array();
764 764
 
765 765
          // get the user_id if none was passed in use the current logged in user
766
-         if( ! intval( $user_id ) > 0 ) {
766
+         if ( ! intval($user_id) > 0) {
767 767
              $user_id = get_current_user_id();
768 768
          }
769 769
 
770
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
771
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
770
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
771
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
772 772
              return false;
773 773
          }
774 774
 
775 775
          // save some time and get the transient cached data
776
-         $transient_key = 'quiz_grades_'. $user_id . '_' . $lesson_id;
777
-         $user_grades = get_transient( $transient_key );
776
+         $transient_key = 'quiz_grades_'.$user_id.'_'.$lesson_id;
777
+         $user_grades = get_transient($transient_key);
778 778
 
779 779
          // get the data if nothing was stored in the transient
780
-         if( empty( $user_grades  ) || false != $user_grades ){
780
+         if (empty($user_grades) || false != $user_grades) {
781 781
 
782
-             $user_grades = Sensei_Utils::get_user_data( 'quiz_grades', $lesson_id, $user_id );
782
+             $user_grades = Sensei_Utils::get_user_data('quiz_grades', $lesson_id, $user_id);
783 783
 
784 784
              //set the transient with the new valid data for faster retrieval in future
785
-             set_transient( $transient_key,  $user_grades, 10 * DAY_IN_SECONDS );
785
+             set_transient($transient_key, $user_grades, 10 * DAY_IN_SECONDS);
786 786
 
787 787
          } // end if transient check
788 788
 
789 789
          // if there is no data for this user
790
-         if( ! is_array( $user_grades ) ){
790
+         if ( ! is_array($user_grades)) {
791 791
              return false;
792 792
          }
793 793
 
@@ -810,21 +810,21 @@  discard block
 block discarded – undo
810 810
       *
811 811
       * @return bool $question_grade
812 812
       */
813
-     public function get_user_question_grade( $lesson_id, $question_id, $user_id = 0 ){
813
+     public function get_user_question_grade($lesson_id, $question_id, $user_id = 0) {
814 814
 
815 815
          // parameter validation
816
-         if( empty( $lesson_id ) || empty( $question_id )
817
-             || ! ( intval( $lesson_id  ) > 0 )
818
-             || ! ( intval( $question_id  ) > 0 )
819
-             || 'lesson' != get_post_type( $lesson_id )
820
-             || 'question' != get_post_type( $question_id )) {
816
+         if (empty($lesson_id) || empty($question_id)
817
+             || ! (intval($lesson_id) > 0)
818
+             || ! (intval($question_id) > 0)
819
+             || 'lesson' != get_post_type($lesson_id)
820
+             || 'question' != get_post_type($question_id)) {
821 821
 
822 822
              return false;
823 823
          }
824 824
 
825
-         $all_user_grades = self::get_user_grades( $lesson_id,$user_id );
825
+         $all_user_grades = self::get_user_grades($lesson_id, $user_id);
826 826
 
827
-         if( ! $all_user_grades || ! isset(  $all_user_grades[ $question_id ] ) ){
827
+         if ( ! $all_user_grades || ! isset($all_user_grades[$question_id])) {
828 828
 
829 829
              //fallback to data pre 1.7.4
830 830
              $args = array(
@@ -833,17 +833,17 @@  discard block
 block discarded – undo
833 833
                  'type'    => 'sensei_user_answer'
834 834
              );
835 835
 
836
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
836
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
837 837
              $fall_back_grade = false;
838
-             if( isset( $question_activity->comment_ID ) ){
839
-                 $fall_back_grade = get_comment_meta(  $question_activity->comment_ID , 'user_grade', true );
838
+             if (isset($question_activity->comment_ID)) {
839
+                 $fall_back_grade = get_comment_meta($question_activity->comment_ID, 'user_grade', true);
840 840
              }
841 841
 
842 842
              return $fall_back_grade;
843 843
 
844 844
          } // end if $all_user_grades...
845 845
 
846
-         return $all_user_grades[ $question_id ];
846
+         return $all_user_grades[$question_id];
847 847
 
848 848
      }// end get_user_question_grade
849 849
 
@@ -865,13 +865,13 @@  discard block
 block discarded – undo
865 865
       *
866 866
       * @return false or int $feedback_saved
867 867
       */
868
-    public function save_user_answers_feedback( $answers_feedback, $lesson_id , $user_id = 0 ){
868
+    public function save_user_answers_feedback($answers_feedback, $lesson_id, $user_id = 0) {
869 869
 
870 870
         // make sure the parameters are valid before continuing
871
-        if( empty( $lesson_id ) || empty( $user_id )
872
-            || 'lesson' != get_post_type( $lesson_id )
873
-            ||!get_userdata( $user_id )
874
-            || !is_array( $answers_feedback ) ){
871
+        if (empty($lesson_id) || empty($user_id)
872
+            || 'lesson' != get_post_type($lesson_id)
873
+            ||! get_userdata($user_id)
874
+            || ! is_array($answers_feedback)) {
875 875
 
876 876
             return false;
877 877
 
@@ -879,25 +879,25 @@  discard block
 block discarded – undo
879 879
 
880 880
 
881 881
         // check if the lesson is started before saving, if not start the lesson for the user
882
-        if ( !( 0 < intval( Sensei_Utils::user_started_lesson( $lesson_id, $user_id) ) ) ) {
883
-            Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
882
+        if ( ! (0 < intval(Sensei_Utils::user_started_lesson($lesson_id, $user_id)))) {
883
+            Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
884 884
         }
885 885
 
886 886
         // encode the feedback
887
-        $encoded_answers_feedback =  array();
888
-        foreach( $answers_feedback as $question_id => $feedback ){
889
-            $encoded_answers_feedback[ $question_id ] = base64_encode( $feedback );
887
+        $encoded_answers_feedback = array();
888
+        foreach ($answers_feedback as $question_id => $feedback) {
889
+            $encoded_answers_feedback[$question_id] = base64_encode($feedback);
890 890
         }
891 891
 
892 892
         // save the user data
893
-        $feedback_saved = Sensei_Utils::add_user_data( 'quiz_answers_feedback', $lesson_id , $encoded_answers_feedback, $user_id ) ;
893
+        $feedback_saved = Sensei_Utils::add_user_data('quiz_answers_feedback', $lesson_id, $encoded_answers_feedback, $user_id);
894 894
 
895 895
         //Were the the question feedback save correctly?
896
-        if( intval( $feedback_saved ) > 0){
896
+        if (intval($feedback_saved) > 0) {
897 897
 
898 898
             // save transient to make retrieval faster in future
899 899
              $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
900
-             set_transient( $transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS );
900
+             set_transient($transient_key, $encoded_answers_feedback, 10 * DAY_IN_SECONDS);
901 901
 
902 902
         }
903 903
 
@@ -922,42 +922,42 @@  discard block
 block discarded – undo
922 922
       *  $type string $question_feedback
923 923
       * }
924 924
       */
925
-     public function get_user_answers_feedback( $lesson_id , $user_id = 0 ){
925
+     public function get_user_answers_feedback($lesson_id, $user_id = 0) {
926 926
 
927 927
          $answers_feedback = array();
928 928
 
929 929
          // get the user_id if none was passed in use the current logged in user
930
-         if( ! intval( $user_id ) > 0 ) {
930
+         if ( ! intval($user_id) > 0) {
931 931
              $user_id = get_current_user_id();
932 932
          }
933 933
 
934
-         if ( ! intval( $lesson_id ) > 0 || 'lesson' != get_post_type( $lesson_id )
935
-             || ! intval( $user_id )  > 0 || !get_userdata( $user_id )  ) {
934
+         if ( ! intval($lesson_id) > 0 || 'lesson' != get_post_type($lesson_id)
935
+             || ! intval($user_id) > 0 || ! get_userdata($user_id)) {
936 936
              return false;
937 937
          }
938 938
 
939 939
          // first check the transient to save a few split seconds
940 940
          $transient_key = 'sensei_answers_feedback_'.$user_id.'_'.$lesson_id;
941
-         $encoded_feedback = get_transient( $transient_key );
941
+         $encoded_feedback = get_transient($transient_key);
942 942
 
943 943
          // get the data if nothing was stored in the transient
944
-         if( empty( $encoded_feedback  ) || !$encoded_feedback ){
944
+         if (empty($encoded_feedback) || ! $encoded_feedback) {
945 945
 
946
-             $encoded_feedback = Sensei_Utils::get_user_data( 'quiz_answers_feedback', $lesson_id, $user_id );
946
+             $encoded_feedback = Sensei_Utils::get_user_data('quiz_answers_feedback', $lesson_id, $user_id);
947 947
 
948 948
              //set the transient with the new valid data for faster retrieval in future
949
-             set_transient( $transient_key,  $encoded_feedback, 10 * DAY_IN_SECONDS);
949
+             set_transient($transient_key, $encoded_feedback, 10 * DAY_IN_SECONDS);
950 950
 
951 951
          } // end if transient check
952 952
 
953 953
          // if there is no data for this user
954
-         if( ! is_array( $encoded_feedback ) ){
954
+         if ( ! is_array($encoded_feedback)) {
955 955
              return false;
956 956
          }
957 957
 
958
-         foreach( $encoded_feedback as $question_id => $feedback ){
958
+         foreach ($encoded_feedback as $question_id => $feedback) {
959 959
 
960
-             $answers_feedback[ $question_id ] = base64_decode( $feedback );
960
+             $answers_feedback[$question_id] = base64_decode($feedback);
961 961
 
962 962
          }
963 963
 
@@ -980,25 +980,25 @@  discard block
 block discarded – undo
980 980
       *
981 981
       * @return string $feedback or bool if false
982 982
       */
983
-     public function get_user_question_feedback( $lesson_id, $question_id, $user_id = 0 ){
983
+     public function get_user_question_feedback($lesson_id, $question_id, $user_id = 0) {
984 984
 
985 985
          $feedback = false;
986 986
 
987 987
          // parameter validation
988
-         if( empty( $lesson_id ) || empty( $question_id )
989
-             || ! ( intval( $lesson_id  ) > 0 )
990
-             || ! ( intval( $question_id  ) > 0 )
991
-             || 'lesson' != get_post_type( $lesson_id )
992
-             || 'question' != get_post_type( $question_id )) {
988
+         if (empty($lesson_id) || empty($question_id)
989
+             || ! (intval($lesson_id) > 0)
990
+             || ! (intval($question_id) > 0)
991
+             || 'lesson' != get_post_type($lesson_id)
992
+             || 'question' != get_post_type($question_id)) {
993 993
 
994 994
              return false;
995 995
          }
996 996
 
997 997
          // get all the feedback for the user on the given lesson
998
-         $all_feedback = $this->get_user_answers_feedback( $lesson_id, $user_id );
998
+         $all_feedback = $this->get_user_answers_feedback($lesson_id, $user_id);
999 999
 
1000
-         if( !$all_feedback || empty( $all_feedback )
1001
-             || ! is_array( $all_feedback ) || ! isset( $all_feedback[ $question_id ] ) ){
1000
+         if ( ! $all_feedback || empty($all_feedback)
1001
+             || ! is_array($all_feedback) || ! isset($all_feedback[$question_id])) {
1002 1002
 
1003 1003
              //fallback to data pre 1.7.4
1004 1004
 
@@ -1008,23 +1008,23 @@  discard block
 block discarded – undo
1008 1008
                  'user_id' => $user_id,
1009 1009
                  'type'    => 'sensei_user_answer'
1010 1010
              );
1011
-             $question_activity = Sensei_Utils::sensei_check_for_activity( $args , true );
1011
+             $question_activity = Sensei_Utils::sensei_check_for_activity($args, true);
1012 1012
 
1013 1013
              // set the default to false and return that if no old data is available.
1014
-             if( isset( $question_activity->comment_ID ) ){
1015
-                 $feedback = base64_decode( get_comment_meta(  $question_activity->comment_ID , 'answer_note', true ) );
1014
+             if (isset($question_activity->comment_ID)) {
1015
+                 $feedback = base64_decode(get_comment_meta($question_activity->comment_ID, 'answer_note', true));
1016 1016
              }
1017 1017
 
1018 1018
              // finally use the default question feedback
1019
-             if( empty( $feedback ) ){
1020
-                 $feedback = get_post_meta( $question_id, '_answer_feedback', true );
1019
+             if (empty($feedback)) {
1020
+                 $feedback = get_post_meta($question_id, '_answer_feedback', true);
1021 1021
              }
1022 1022
 
1023 1023
              return $feedback;
1024 1024
 
1025 1025
          }
1026 1026
 
1027
-         return $all_feedback[ $question_id ];
1027
+         return $all_feedback[$question_id];
1028 1028
 
1029 1029
      } // end get_user_question_feedback
1030 1030
 
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
      public function quiz_has_no_questions() {
1044 1044
 
1045
-         if( ! is_singular( 'quiz' ) )  {
1045
+         if ( ! is_singular('quiz')) {
1046 1046
              return;
1047 1047
          }
1048 1048
 
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
          $lesson_id = $this->get_lesson_id($post->ID);
1052 1052
 
1053
-         $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
1053
+         $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
1054 1054
 
1055 1055
          $lesson = get_post($lesson_id);
1056 1056
 
1057
-         if ( is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name" ) {
1057
+         if (is_singular('quiz') && ! $has_questions && $_SERVER['REQUEST_URI'] != "/lesson/$lesson->post_name") {
1058 1058
 
1059 1059
              wp_redirect(get_permalink($lesson->ID), 301);
1060 1060
              exit;
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
   *
1069 1069
   * @deprecated since 1.9.0
1070 1070
   */
1071
- public static function deprecate_quiz_sensei_single_main_content_hook(){
1071
+ public static function deprecate_quiz_sensei_single_main_content_hook() {
1072 1072
 
1073 1073
      sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_quiz_content_inside_before or sensei_single_quiz_content_inside_after');
1074 1074
 
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
      *
1079 1079
      * @deprecated since 1.9.0
1080 1080
      */
1081
-     public static function deprecate_quiz_sensei_quiz_single_title_hook(){
1081
+     public static function deprecate_quiz_sensei_quiz_single_title_hook() {
1082 1082
 
1083 1083
          sensei_do_deprecated_action('sensei_quiz_single_title', '1.9.0', 'sensei_single_quiz_content_inside_before ');
1084 1084
 
@@ -1091,29 +1091,29 @@  discard block
 block discarded – undo
1091 1091
       * @param int $id title post id
1092 1092
       * @return string $quiz_title
1093 1093
       */
1094
-     public static function single_quiz_title( $title, $post_id ){
1094
+     public static function single_quiz_title($title, $post_id) {
1095 1095
 
1096
-         if( 'quiz' == get_post_type( $post_id ) ){
1096
+         if ('quiz' == get_post_type($post_id)) {
1097 1097
 
1098 1098
              $title_with_no_quizzes = $title;
1099 1099
 
1100 1100
              // if the title has quiz, remove it: legacy titles have the word quiz stored.
1101
-             if( 1 < substr_count( strtoupper( $title_with_no_quizzes ), 'QUIZ' ) ){
1101
+             if (1 < substr_count(strtoupper($title_with_no_quizzes), 'QUIZ')) {
1102 1102
 
1103 1103
                  // remove all possible appearances of quiz
1104
-                 $title_with_no_quizzes = str_replace( 'quiz', '', $title  );
1105
-                 $title_with_no_quizzes = str_replace( 'Quiz', '', $title_with_no_quizzes  );
1106
-                 $title_with_no_quizzes = str_replace( 'QUIZ', '', $title_with_no_quizzes  );
1104
+                 $title_with_no_quizzes = str_replace('quiz', '', $title);
1105
+                 $title_with_no_quizzes = str_replace('Quiz', '', $title_with_no_quizzes);
1106
+                 $title_with_no_quizzes = str_replace('QUIZ', '', $title_with_no_quizzes);
1107 1107
 
1108 1108
              }
1109 1109
 
1110
-             $title = $title_with_no_quizzes .  ' ' . __( 'Quiz', 'woothemes-sensei' );
1110
+             $title = $title_with_no_quizzes.' '.__('Quiz', 'woothemes-sensei');
1111 1111
          }
1112 1112
 
1113 1113
          /**
1114 1114
           * hook document in class-woothemes-sensei-message.php
1115 1115
           */
1116
-         return apply_filters( 'sensei_single_title', $title, get_post_type( ) );
1116
+         return apply_filters('sensei_single_title', $title, get_post_type( ));
1117 1117
 
1118 1118
      }
1119 1119
 
@@ -1125,21 +1125,21 @@  discard block
 block discarded – undo
1125 1125
       * @since 1.9.0
1126 1126
       *
1127 1127
       */
1128
-     public static function start_quiz_questions_loop(){
1128
+     public static function start_quiz_questions_loop() {
1129 1129
 
1130 1130
          global $sensei_question_loop;
1131 1131
 
1132 1132
          //intialize the questions loop object
1133 1133
          $sensei_question_loop['current'] = -1;
1134
-         $sensei_question_loop['total']   =  0;
1134
+         $sensei_question_loop['total']   = 0;
1135 1135
          $sensei_question_loop['questions'] = array();
1136 1136
 
1137 1137
 
1138
-         $questions = Sensei()->lesson->lesson_quiz_questions( get_the_ID() );
1138
+         $questions = Sensei()->lesson->lesson_quiz_questions(get_the_ID());
1139 1139
 
1140
-         if( count( $questions  ) > 0  ){
1140
+         if (count($questions) > 0) {
1141 1141
 
1142
-             $sensei_question_loop['total']   =  count( $questions );
1142
+             $sensei_question_loop['total']   = count($questions);
1143 1143
              $sensei_question_loop['questions'] = $questions;
1144 1144
              $sensei_question_loop['quiz_id'] = get_the_ID();
1145 1145
 
@@ -1155,9 +1155,9 @@  discard block
 block discarded – undo
1155 1155
       * @since 1.9.0
1156 1156
       *
1157 1157
       */
1158
-     public static function stop_quiz_questions_loop(){
1158
+     public static function stop_quiz_questions_loop() {
1159 1159
 
1160
-         $sensei_question_loop['total']   =  0;
1160
+         $sensei_question_loop['total']   = 0;
1161 1161
          $sensei_question_loop['questions'] = array();
1162 1162
          $sensei_question_loop['quiz_id'] = '';
1163 1163
 
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
       *
1169 1169
       * @since 1.9.0
1170 1170
       */
1171
-     public static function the_title(){
1171
+     public static function the_title() {
1172 1172
          ?>
1173 1173
          <header>
1174 1174
 
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
                  /**
1179 1179
                   * Filter documented in class-sensei-messages.php the_title
1180 1180
                   */
1181
-                 echo apply_filters( 'sensei_single_title', get_the_title( get_post() ), get_post_type( get_the_ID() ) );
1181
+                 echo apply_filters('sensei_single_title', get_the_title(get_post()), get_post_type(get_the_ID()));
1182 1182
                  ?>
1183 1183
 
1184 1184
              </h1>
@@ -1193,11 +1193,11 @@  discard block
 block discarded – undo
1193 1193
       *
1194 1194
       * @param $quiz_id
1195 1195
       */
1196
-    public static function  the_user_status_message( $quiz_id ){
1196
+    public static function  the_user_status_message($quiz_id) {
1197 1197
 
1198
-        $lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
1199
-        $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id , get_current_user_id() );
1200
-        echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
1198
+        $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
1199
+        $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, get_current_user_id());
1200
+        echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
1201 1201
 
1202 1202
     }
1203 1203
 
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
       * @since 1.9.0
1209 1209
       * @deprecated
1210 1210
       */
1211
-     public static function deprecate_sensei_quiz_action_buttons_hook(){
1211
+     public static function deprecate_sensei_quiz_action_buttons_hook() {
1212 1212
 
1213
-         sensei_do_deprecated_action( 'sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1213
+         sensei_do_deprecated_action('sensei_quiz_action_buttons', '1.9.0', 'sensei_single_quiz_questions_after');
1214 1214
 
1215 1215
      }
1216 1216
 
@@ -1224,50 +1224,50 @@  discard block
 block discarded – undo
1224 1224
 
1225 1225
          global $post, $current_user;
1226 1226
 
1227
-         $lesson_id = (int) get_post_meta( $post->ID, '_quiz_lesson', true );
1228
-         $lesson_course_id = (int) get_post_meta( $lesson_id, '_lesson_course', true );
1229
-         $lesson_prerequisite = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
1227
+         $lesson_id = (int) get_post_meta($post->ID, '_quiz_lesson', true);
1228
+         $lesson_course_id = (int) get_post_meta($lesson_id, '_lesson_course', true);
1229
+         $lesson_prerequisite = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
1230 1230
          $show_actions = true;
1231
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $current_user->ID );
1231
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $current_user->ID);
1232 1232
 
1233 1233
          //setup quiz grade
1234 1234
          $user_quiz_grade = '';
1235
-         if( ! empty( $user_lesson_status  ) ){
1236
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1235
+         if ( ! empty($user_lesson_status)) {
1236
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1237 1237
          }
1238 1238
 
1239 1239
 
1240
-         if( intval( $lesson_prerequisite ) > 0 ) {
1240
+         if (intval($lesson_prerequisite) > 0) {
1241 1241
 
1242 1242
              // If the user hasn't completed the prereq then hide the current actions
1243
-             $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $current_user->ID );
1243
+             $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $current_user->ID);
1244 1244
 
1245 1245
          }
1246
-         if ( $show_actions && is_user_logged_in() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
1246
+         if ($show_actions && is_user_logged_in() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) {
1247 1247
 
1248 1248
              // Get Reset Settings
1249
-             $reset_quiz_allowed = get_post_meta( $post->ID, '_enable_quiz_reset', true ); ?>
1249
+             $reset_quiz_allowed = get_post_meta($post->ID, '_enable_quiz_reset', true); ?>
1250 1250
 
1251 1251
              <!-- Action Nonce's -->
1252 1252
              <input type="hidden" name="woothemes_sensei_complete_quiz_nonce" id="woothemes_sensei_complete_quiz_nonce"
1253
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_complete_quiz_nonce' ) ); ?>" />
1253
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_quiz_nonce')); ?>" />
1254 1254
              <input type="hidden" name="woothemes_sensei_reset_quiz_nonce" id="woothemes_sensei_reset_quiz_nonce"
1255
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_reset_quiz_nonce' ) ); ?>" />
1255
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_reset_quiz_nonce')); ?>" />
1256 1256
              <input type="hidden" name="woothemes_sensei_save_quiz_nonce" id="woothemes_sensei_save_quiz_nonce"
1257
-                    value="<?php echo esc_attr(  wp_create_nonce( 'woothemes_sensei_save_quiz_nonce' ) ); ?>" />
1257
+                    value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_save_quiz_nonce')); ?>" />
1258 1258
              <!--#end Action Nonce's -->
1259 1259
 
1260
-             <?php if ( '' == $user_quiz_grade) { ?>
1260
+             <?php if ('' == $user_quiz_grade) { ?>
1261 1261
 
1262
-                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e( 'Complete Quiz', 'woothemes-sensei' ); ?>"/></span>
1262
+                 <span><input type="submit" name="quiz_complete" class="quiz-submit complete" value="<?php  _e('Complete Quiz', 'woothemes-sensei'); ?>"/></span>
1263 1263
 
1264
-                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e( 'Save Quiz', 'woothemes-sensei' ); ?>"/></span>
1264
+                 <span><input type="submit" name="quiz_save" class="quiz-submit save" value="<?php _e('Save Quiz', 'woothemes-sensei'); ?>"/></span>
1265 1265
 
1266 1266
              <?php } // End If Statement ?>
1267 1267
 
1268
-             <?php if ( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { ?>
1268
+             <?php if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { ?>
1269 1269
 
1270
-                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e( 'Reset Quiz', 'woothemes-sensei' ); ?>"/></span>
1270
+                 <span><input type="submit" name="quiz_reset" class="quiz-submit reset" value="<?php _e('Reset Quiz', 'woothemes-sensei'); ?>"/></span>
1271 1271
 
1272 1272
              <?php } ?>
1273 1273
 
@@ -1285,13 +1285,13 @@  discard block
 block discarded – undo
1285 1285
       *
1286 1286
       * @return double $user_quiz_grade
1287 1287
       */
1288
-     public static function get_user_quiz_grade( $lesson_id, $user_id ){
1288
+     public static function get_user_quiz_grade($lesson_id, $user_id) {
1289 1289
 
1290 1290
          // get the quiz grade
1291
-         $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id );
1291
+         $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id);
1292 1292
          $user_quiz_grade = 0;
1293
-         if( isset( $user_lesson_status->comment_ID ) ) {
1294
-             $user_quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true );
1293
+         if (isset($user_lesson_status->comment_ID)) {
1294
+             $user_quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true);
1295 1295
          }
1296 1296
 
1297 1297
          return (double) $user_quiz_grade;
@@ -1309,13 +1309,13 @@  discard block
 block discarded – undo
1309 1309
       * @param int $lesson_id
1310 1310
       * @return bool
1311 1311
       */
1312
-     public static function is_reset_allowed( $lesson_id ){
1312
+     public static function is_reset_allowed($lesson_id) {
1313 1313
 
1314
-         $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1314
+         $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
1315 1315
 
1316
-         $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
1316
+         $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true);
1317 1317
          //backwards compatibility
1318
-         if( 'on' == $reset_allowed ) {
1318
+         if ('on' == $reset_allowed) {
1319 1319
              $reset_allowed = 1;
1320 1320
          }
1321 1321
 
@@ -1332,4 +1332,4 @@  discard block
 block discarded – undo
1332 1332
  * @ignore only for backward compatibility
1333 1333
  * @since 1.9.0
1334 1334
  */
1335
-class WooThemes_Sensei_Quiz extends Sensei_Quiz{}
1335
+class WooThemes_Sensei_Quiz extends Sensei_Quiz {}
Please login to merge, or discard this patch.