Completed
Push — master ( f1dc7e...f45963 )
by Dwain
05:41
created
includes/class-sensei-lesson.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2898,7 +2898,7 @@
 block discarded – undo
2898 2898
      * @access public
2899 2899
      *
2900 2900
      * @param int $lesson_id
2901
-     * @return int|bool $course_id or bool when nothing is found.
2901
+     * @return integer $course_id or bool when nothing is found.
2902 2902
      */
2903 2903
      public function get_course_id( $lesson_id ){
2904 2904
 
Please login to merge, or discard this patch.
Indentation   +1027 added lines, -1027 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct () {
23 23
 
24
-        $this->token = 'lesson';
24
+		$this->token = 'lesson';
25 25
 
26 26
 		// Setup meta fields for this post type
27 27
 		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
28 28
 
29
-        $this->question_order = '';
29
+		$this->question_order = '';
30 30
 
31 31
 		// Admin actions
32 32
 		if ( is_admin() ) {
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
85 85
 			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
86 86
 
87
-            // output bulk edit fields
88
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
87
+			// output bulk edit fields
88
+			add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
+			add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
90 90
 
91
-            // load quick edit default values
92
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
91
+			// load quick edit default values
92
+			add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
93 93
 
94
-            // save bulk edit fields
95
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
94
+			// save bulk edit fields
95
+			add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
96 96
 
97
-            // flush rewrite rules when saving a lesson
98
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
97
+			// flush rewrite rules when saving a lesson
98
+			add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
99 99
 
100 100
 		} else {
101 101
 			// Frontend actions
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 		$post_args = array(	'post_type' 		=> 'lesson',
190 190
 							'posts_per_page' 		=> -1,
191 191
 							'orderby'         	=> 'title',
192
-    						'order'           	=> 'ASC',
193
-    						'exclude' 			=> $post->ID,
192
+							'order'           	=> 'ASC',
193
+							'exclude' 			=> $post->ID,
194 194
 							'suppress_filters' 	=> 0
195 195
 							);
196 196
 		$posts_array = get_posts( $post_args );
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 		$checked = '';
228 228
 		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
229
-	 	    $checked = checked( 'preview', $lesson_preview, false );
229
+	 		$checked = checked( 'preview', $lesson_preview, false );
230 230
 	 	} // End If Statement
231 231
 
232 232
 	 	$html .= '<label for="lesson_preview">';
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 
277 277
 	/**
278
-     * Update the lesson quiz and all the post meta
278
+	 * Update the lesson quiz and all the post meta
279 279
 	 *
280 280
 	 * @access public
281 281
 	 * @return integer|boolean $post_id or false
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		}
297 297
 
298 298
 		// Temporarily disable the filter
299
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
299
+		remove_action( 'save_post', array( $this, 'quiz_update' ) );
300 300
 		// Save the Quiz
301 301
 		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
302 302
 
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 
312 312
 		// Setup Query Arguments
313 313
 		$post_type_args = array(	'post_content' => $post_content,
314
-  		    						'post_status' => $post_status,
315
-  		    						'post_title' => $post_title,
316
-  		    						'post_type' => 'quiz',
317
-                                    'post_parent' => $post_id,
318
-  		    						);
314
+  									'post_status' => $post_status,
315
+  									'post_title' => $post_title,
316
+  									'post_type' => 'quiz',
317
+									'post_parent' => $post_id,
318
+  									);
319 319
 
320 320
 		$settings = $this->get_quiz_settings();
321 321
 
@@ -323,48 +323,48 @@  discard block
 block discarded – undo
323 323
 		if ( 0 < $quiz_id ) {
324 324
 			// Update the Quiz
325 325
 			$post_type_args[ 'ID' ] = $quiz_id;
326
-		    wp_update_post($post_type_args);
327
-
328
-		    // Update the post meta data
329
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
330
-
331
-		    foreach( $settings as $field ) {
332
-		    	if( 'random_question_order' != $field['id'] ) {
333
-			    	$value = $this->get_submitted_setting_value( $field );
334
-			    	if( isset( $value ) ) {
335
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
336
-			    	}
337
-			    }
338
-		    }
339
-
340
-		    // Set the post terms for quiz-type
341
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
326
+			wp_update_post($post_type_args);
327
+
328
+			// Update the post meta data
329
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
330
+
331
+			foreach( $settings as $field ) {
332
+				if( 'random_question_order' != $field['id'] ) {
333
+					$value = $this->get_submitted_setting_value( $field );
334
+					if( isset( $value ) ) {
335
+						update_post_meta( $quiz_id, '_' . $field['id'], $value );
336
+					}
337
+				}
338
+			}
339
+
340
+			// Set the post terms for quiz-type
341
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
342 342
 		} else {
343 343
 			// Create the Quiz
344
-		    $quiz_id = wp_insert_post($post_type_args);
345
-
346
-		    // Add the post meta data WP will add it if it doesn't exist
347
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
348
-
349
-		    foreach( $settings as $field ) {
350
-		    	if( 'random_question_order' != $field['id'] ) {
351
-
352
-                    //ignore values not posted to avoid
353
-                    // overwriting with empty or default values
354
-                    // when the values are posted from bulk edit or quick edit
355
-                    if( !isset( $_POST[ $field['id'] ] ) ){
356
-                        continue;
357
-                    }
358
-
359
-			    	$value = $this->get_submitted_setting_value( $field );
360
-			    	if( isset( $value ) ) {
361
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
362
-			    	}
363
-			    }
364
-		    }
365
-
366
-		    // Set the post terms for quiz-type
367
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
344
+			$quiz_id = wp_insert_post($post_type_args);
345
+
346
+			// Add the post meta data WP will add it if it doesn't exist
347
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
348
+
349
+			foreach( $settings as $field ) {
350
+				if( 'random_question_order' != $field['id'] ) {
351
+
352
+					//ignore values not posted to avoid
353
+					// overwriting with empty or default values
354
+					// when the values are posted from bulk edit or quick edit
355
+					if( !isset( $_POST[ $field['id'] ] ) ){
356
+						continue;
357
+					}
358
+
359
+					$value = $this->get_submitted_setting_value( $field );
360
+					if( isset( $value ) ) {
361
+						add_post_meta( $quiz_id, '_' . $field['id'], $value );
362
+					}
363
+				}
364
+			}
365
+
366
+			// Set the post terms for quiz-type
367
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
368 368
 		} // End If Statement
369 369
 
370 370
 		// Add default lesson order meta value
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		}
387 387
 
388 388
 		// Restore the previously disabled filter
389
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
389
+		add_action( 'save_post', array( $this, 'quiz_update' ) );
390 390
 
391 391
 	} // End post_updated()
392 392
 
@@ -426,22 +426,22 @@  discard block
 block discarded – undo
426 426
 		// Get the meta key.
427 427
 		$meta_key = '_' . $post_key;
428 428
 
429
-        //ignore fields are not posted
429
+		//ignore fields are not posted
430 430
 
431
-        if( !isset( $_POST[ $post_key ] ) ){
431
+		if( !isset( $_POST[ $post_key ] ) ){
432 432
 
433
-            // except for lesson preview checkbox field
434
-            if( 'lesson_preview' == $post_key ){
433
+			// except for lesson preview checkbox field
434
+			if( 'lesson_preview' == $post_key ){
435 435
 
436
-                $_POST[ $post_key ] = '';
436
+				$_POST[ $post_key ] = '';
437 437
 
438
-            } else {
438
+			} else {
439 439
 
440
-                return false;
440
+				return false;
441 441
 
442
-            }
442
+			}
443 443
 
444
-        }
444
+		}
445 445
 
446 446
 		// Get the posted data and sanitize it for use as an HTML class.
447 447
 		if ( 'lesson_video_embed' == $post_key) {
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
 			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
451 451
 		} // End If Statement
452 452
 
453
-        // update field with the new value
454
-        if( -1 != $new_meta_value  ){
455
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
456
-        }
453
+		// update field with the new value
454
+		if( -1 != $new_meta_value  ){
455
+			return update_post_meta( $post_id, $meta_key, $new_meta_value );
456
+		}
457 457
 
458 458
 	} // End save_post_meta()
459 459
 
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
 		$post_args = array(	'post_type' 		=> 'course',
479 479
 							'posts_per_page' 		=> -1,
480 480
 							'orderby'         	=> 'title',
481
-    						'order'           	=> 'ASC',
482
-    						'post_status'      	=> 'any',
483
-    						'suppress_filters' 	=> 0,
481
+							'order'           	=> 'ASC',
482
+							'post_status'      	=> 'any',
483
+							'suppress_filters' 	=> 0,
484 484
 							);
485 485
 		$posts_array = get_posts( $post_args );
486 486
 		// Buid the HTML to Output
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		// Nonce
489 489
 		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
490 490
 
491
-        // Select the course for the lesson
492
-        $drop_down_args = array(
493
-            'name'=>'lesson_course',
494
-            'id' => 'lesson-course-options'
495
-        );
491
+		// Select the course for the lesson
492
+		$drop_down_args = array(
493
+			'name'=>'lesson_course',
494
+			'id' => 'lesson-course-options'
495
+		);
496 496
 
497
-        $courses = WooThemes_Sensei_Course::get_all_courses();
498
-        $courses_options = array();
499
-        foreach( $courses as $course ){
500
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
501
-        }
502
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
497
+		$courses = WooThemes_Sensei_Course::get_all_courses();
498
+		$courses_options = array();
499
+		foreach( $courses as $course ){
500
+			$courses_options[ $course->ID ] = get_the_title( $course ) ;
501
+		}
502
+		$html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
503 503
 
504
-        // Course Actions Panel
504
+		// Course Actions Panel
505 505
 		if ( current_user_can( 'publish_courses' )) {
506 506
 				$html .= '<div id="lesson-course-actions">';
507 507
 					$html .= '<p>';
@@ -527,16 +527,16 @@  discard block
 block discarded – undo
527 527
 							} // End For Loop
528 528
 						$html .= '</select>' . "\n";
529 529
 						// Course Product
530
-                        if ( Sensei_WC::is_woocommerce_active() ) {
530
+						if ( Sensei_WC::is_woocommerce_active() ) {
531 531
 	  						// Get the Products
532 532
 							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
533 533
 
534 534
 							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
535 535
 													'posts_per_page' 		=> -1,
536 536
 													'orderby'         	=> 'title',
537
-	    											'order'           	=> 'DESC',
538
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
539
-	    											'tax_query'			=> array(
537
+													'order'           	=> 'DESC',
538
+													'post_status'		=> array( 'publish', 'private', 'draft' ),
539
+													'tax_query'			=> array(
540 540
 														array(
541 541
 															'taxonomy'	=> 'product_type',
542 542
 															'field'		=> 'slug',
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 															'operator'	=> 'NOT IN'
545 545
 														)
546 546
 													),
547
-	    											'suppress_filters' 	=> 0
547
+													'suppress_filters' 	=> 0
548 548
 													);
549 549
 							$products_array = get_posts( $product_args );
550 550
 							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
@@ -872,58 +872,58 @@  discard block
 block discarded – undo
872 872
 					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
873 873
 						$html .= '<td colspan="5">';
874 874
 							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
875
-					    	$html .= '<div class="question_required_fields">';
876
-
877
-						    	// Question title
878
-						    	$html .= '<div>';
879
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
881
-						    	$html .= '</div>';
882
-
883
-						    	// Question description
884
-						    	$html .= '<div>';
885
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
886
-						    	$html .= '</div>';
887
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
888
-
889
-						    	// Question grade
890
-						    	$html .= '<div>';
891
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
893
-						    	$html .= '</div>';
894
-
895
-						    	// Random order
896
-						    	if( $question_type == 'multiple-choice' ) {
897
-						    		$html .= '<div>';
898
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
899
-						    		$html .= '</div>';
900
-						    	}
901
-
902
-						    	// Question media
903
-						    	$html .= '<div>';
904
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
910
-						    	$html .= '</div>';
911
-
912
-						    $html .= '</div>';
913
-
914
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
915
-
916
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
875
+							$html .= '<div class="question_required_fields">';
876
+
877
+								// Question title
878
+								$html .= '<div>';
879
+									$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
+									$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
881
+								$html .= '</div>';
882
+
883
+								// Question description
884
+								$html .= '<div>';
885
+									$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
886
+								$html .= '</div>';
887
+									$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
888
+
889
+								// Question grade
890
+								$html .= '<div>';
891
+									$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
+									$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
893
+								$html .= '</div>';
894
+
895
+								// Random order
896
+								if( $question_type == 'multiple-choice' ) {
897
+									$html .= '<div>';
898
+										$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
899
+									$html .= '</div>';
900
+								}
901
+
902
+								// Question media
903
+								$html .= '<div>';
904
+									$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
+									$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
+									$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
+									$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
+									$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
+									$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
910
+								$html .= '</div>';
911
+
912
+							$html .= '</div>';
913
+
914
+							$html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
915
+
916
+							$html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
917 917
 							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
918 918
 
919 919
 							if( 'quiz' == $context ) {
920
-					    		$html .= '<div class="update-question">';
921
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
923
-					    		$html .= '</div>';
924
-					    	}
920
+								$html .= '<div class="update-question">';
921
+									$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
+									$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
923
+								$html .= '</div>';
924
+							}
925 925
 
926
-			    		$html .= '</td>';
926
+						$html .= '</td>';
927 927
 					$html .= '</tr>';
928 928
 				}
929 929
 
@@ -944,20 +944,20 @@  discard block
 block discarded – undo
944 944
 			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
945 945
 
946 946
 			if( 'quiz' == $context ) {
947
-	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
952
-	    			}
953
-	    		$html .= '</h2>';
954
-	    	}
947
+				$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
+					$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
+					$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
+					if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
+						$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
952
+					}
953
+				$html .= '</h2>';
954
+			}
955 955
 
956
-	    	$html .= '<div class="tab-content" id="tab-new-content">';
956
+			$html .= '<div class="tab-content" id="tab-new-content">';
957 957
 
958
-	    		if( 'quiz' == $context ) {
959
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
960
-	    		}
958
+				if( 'quiz' == $context ) {
959
+					$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
960
+				}
961 961
 
962 962
 				$html .= '<div class="question">';
963 963
 					$html .= '<div class="question_required_fields">';
@@ -999,18 +999,18 @@  discard block
 block discarded – undo
999 999
 
1000 1000
 						// Random order
1001 1001
 						$html .= '<p class="add_question_random_order">';
1002
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1003
-			    		$html .= '</p>';
1002
+							$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1003
+						$html .= '</p>';
1004 1004
 
1005
-			    		// Question media
1005
+						// Question media
1006 1006
 						$html .= '<p>';
1007
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1010
-					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011
-					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012
-					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1013
-				    	$html .= '</p>';
1007
+							$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
+							$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
+							$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1010
+							$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011
+							$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012
+							$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1013
+						$html .= '</p>';
1014 1014
 
1015 1015
 					$html .= '</div>';
1016 1016
 				$html .= '</div>';
@@ -1021,19 +1021,19 @@  discard block
 block discarded – undo
1021 1021
 
1022 1022
 				if( 'quiz' == $context ) {
1023 1023
 					$html .= '<div class="add-question">';
1024
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1025
-		    		$html .= '</div>';
1026
-		    	}
1024
+						$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1025
+					$html .= '</div>';
1026
+				}
1027 1027
 
1028
-		    $html .= '</div>';
1028
+			$html .= '</div>';
1029 1029
 
1030
-		    if( 'quiz' == $context ) {
1030
+			if( 'quiz' == $context ) {
1031 1031
 
1032
-			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1032
+				$html .= '<div class="tab-content hidden" id="tab-existing-content">';
1033 1033
 
1034
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1034
+					$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1035 1035
 
1036
-			    	$html .= '<div id="existing-filters" class="alignleft actions">
1036
+					$html .= '<div id="existing-filters" class="alignleft actions">
1037 1037
 			    				<select id="existing-status">
1038 1038
 			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1039 1039
 			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
@@ -1041,23 +1041,23 @@  discard block
 block discarded – undo
1041 1041
 			    				</select>
1042 1042
 			    				<select id="existing-type">
1043 1043
 			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1044
-							    	foreach ( $question_types as $type => $label ) {
1044
+									foreach ( $question_types as $type => $label ) {
1045 1045
 										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1046 1046
 									}
1047
-    				$html .= '</select>
1047
+					$html .= '</select>
1048 1048
     							<select id="existing-category">
1049 1049
 			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1050
-				    				foreach( $question_cats as $cat ) {
1050
+									foreach( $question_cats as $cat ) {
1051 1051
 										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1052 1052
 									}
1053
-    				$html .= '</select>
1053
+					$html .= '</select>
1054 1054
     							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1055 1055
     							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1056 1056
 			    			</div>';
1057 1057
 
1058
-			    	$html .= '<table id="existing-table" class="widefat">';
1058
+					$html .= '<table id="existing-table" class="widefat">';
1059 1059
 
1060
-			    		$html .= '<thead>
1060
+						$html .= '<thead>
1061 1061
 									    <tr>
1062 1062
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1063 1063
 									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
@@ -1085,28 +1085,28 @@  discard block
 block discarded – undo
1085 1085
 
1086 1086
 						$html .= '</tbody>';
1087 1087
 
1088
-			    	$html .= '</table>';
1088
+					$html .= '</table>';
1089 1089
 
1090
-			    	$next_class = '';
1091
-			    	if( $questions['count'] <= 10 ) {
1092
-			    		$next_class = 'hidden';
1093
-			    	}
1090
+					$next_class = '';
1091
+					if( $questions['count'] <= 10 ) {
1092
+						$next_class = 'hidden';
1093
+					}
1094 1094
 
1095
-			    	$html .= '<div id="existing-pagination">';
1096
-			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1098
-			    	$html .= '</div>';
1095
+					$html .= '<div id="existing-pagination">';
1096
+						$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
+						$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1098
+					$html .= '</div>';
1099 1099
 
1100
-			    	$html .= '<div class="existing-actions">';
1101
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1102
-			    	$html .= '</div>';
1100
+					$html .= '<div class="existing-actions">';
1101
+						$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1102
+					$html .= '</div>';
1103 1103
 
1104
-			    $html .= '</div>';
1104
+				$html .= '</div>';
1105 1105
 
1106
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1107
-				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1106
+				if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1107
+					$html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1108 1108
 
1109
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1109
+						$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1110 1110
 
1111 1111
 						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1112 1112
 						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 
1120 1120
 						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1121 1121
 
1122
-				    $html .= '</div>';
1122
+					$html .= '</div>';
1123 1123
 				}
1124 1124
 			}
1125 1125
 
@@ -1192,14 +1192,14 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 		$qry = new WP_Query( $args );
1194 1194
 
1195
-        /**
1196
-         * Filter existing questions query
1197
-         *
1198
-         * @since 1.8.0
1199
-         *
1200
-         * @param WP_Query $wp_query
1201
-         */
1202
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1195
+		/**
1196
+		 * Filter existing questions query
1197
+		 *
1198
+		 * @since 1.8.0
1199
+		 *
1200
+		 * @param WP_Query $wp_query
1201
+		 */
1202
+		$qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1203 1203
 
1204 1204
 		$questions['questions'] = $qry->posts;
1205 1205
 		$questions['count'] = intval( $qry->found_posts );
@@ -1214,14 +1214,14 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 		if( ! $question_id ) {
1216 1216
 
1217
-            return;
1217
+			return;
1218 1218
 
1219
-        }
1219
+		}
1220 1220
 
1221 1221
 		$existing_class = '';
1222 1222
 		if( $row % 2 ) {
1223
-            $existing_class = 'alternate';
1224
-        }
1223
+			$existing_class = 'alternate';
1224
+		}
1225 1225
 
1226 1226
 		$question_type = Sensei()->question->get_question_type( $question_id );
1227 1227
 
@@ -1355,67 +1355,67 @@  discard block
 block discarded – undo
1355 1355
 							}
1356 1356
 						}
1357 1357
 
1358
-				    	// Calculate total wrong answers available (defaults to 4)
1359
-				    	$total_wrong = 0;
1360
-				    	if( $question_id ) {
1361
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1362
-				    	}
1363
-				    	if( 0 == intval( $total_wrong ) ) {
1364
-				    		$total_wrong = 1;
1365
-				    	}
1358
+						// Calculate total wrong answers available (defaults to 4)
1359
+						$total_wrong = 0;
1360
+						if( $question_id ) {
1361
+							$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1362
+						}
1363
+						if( 0 == intval( $total_wrong ) ) {
1364
+							$total_wrong = 1;
1365
+						}
1366 1366
 
1367
-                        // Setup Wrong Answer HTML
1368
-                        foreach ( $wrong_answers as $i => $answer ){
1367
+						// Setup Wrong Answer HTML
1368
+						foreach ( $wrong_answers as $i => $answer ){
1369 1369
 
1370
-                            $answer_id = $this->get_answer_id( $answer );
1371
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
-                            if( $question_id ) {
1370
+							$answer_id = $this->get_answer_id( $answer );
1371
+							$wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
+							$wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
+							$wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
+							if( $question_id ) {
1375 1375
 
1376
-                                $answers[ $answer_id ] = $wrong_answer;
1376
+								$answers[ $answer_id ] = $wrong_answer;
1377 1377
 
1378
-                            } else {
1378
+							} else {
1379 1379
 
1380
-                                $answers[] = $wrong_answer;
1380
+								$answers[] = $wrong_answer;
1381 1381
 
1382
-                            }
1382
+							}
1383 1383
 
1384
-                        } // end for each
1384
+						} // end for each
1385 1385
 
1386
-				    	$answers_sorted = $answers;
1387
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1388
-				    		$answers_sorted = array();
1389
-				    		foreach( $answer_order as $answer_id ) {
1390
-				    			if( isset( $answers[ $answer_id ] ) ) {
1391
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
-				    				unset( $answers[ $answer_id ] );
1393
-				    			}
1394
-				    		}
1386
+						$answers_sorted = $answers;
1387
+						if( $question_id && count( $answer_order ) > 0 ) {
1388
+							$answers_sorted = array();
1389
+							foreach( $answer_order as $answer_id ) {
1390
+								if( isset( $answers[ $answer_id ] ) ) {
1391
+									$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
+									unset( $answers[ $answer_id ] );
1393
+								}
1394
+							}
1395 1395
 
1396
-				    		if( count( $answers ) > 0 ) {
1397
-						    	foreach( $answers as $id => $answer ) {
1398
-						    		$answers_sorted[ $id ] = $answer;
1399
-						    	}
1400
-						    }
1401
-				    	}
1396
+							if( count( $answers ) > 0 ) {
1397
+								foreach( $answers as $id => $answer ) {
1398
+									$answers_sorted[ $id ] = $answer;
1399
+								}
1400
+							}
1401
+						}
1402 1402
 
1403 1403
 						foreach( $answers_sorted as $id => $answer ) {
1404
-				    		$html .= $answer;
1405
-				    	}
1404
+							$html .= $answer;
1405
+						}
1406 1406
 
1407
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1407
+						$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
+						$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
+						$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1410 1410
 
1411
-				    	$html .= '<div class="add_answer_options">';
1412
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1414
-				    	$html .= '</div>';
1411
+						$html .= '<div class="add_answer_options">';
1412
+							$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
+							$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1414
+						$html .= '</div>';
1415 1415
 
1416
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1416
+						$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1417 1417
 
1418
-			    	$html .= '</div>';
1418
+					$html .= '</div>';
1419 1419
 				break;
1420 1420
 				case 'boolean':
1421 1421
 					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1429 1429
 						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1430 1430
 
1431
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1431
+					$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1432 1432
 
1433 1433
 					$html .= '</div>';
1434 1434
 				break;
@@ -1503,17 +1503,17 @@  discard block
 block discarded – undo
1503 1503
 
1504 1504
 	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1505 1505
 
1506
-        // default field name
1507
-        $field_name = 'answer_feedback';
1508
-        if( 'boolean' == $question_type ){
1506
+		// default field name
1507
+		$field_name = 'answer_feedback';
1508
+		if( 'boolean' == $question_type ){
1509 1509
 
1510
-            $field_name = 'answer_feedback_boolean';
1510
+			$field_name = 'answer_feedback_boolean';
1511 1511
 
1512
-        }elseif( 'multiple-choice' == $question_type ){
1512
+		}elseif( 'multiple-choice' == $question_type ){
1513 1513
 
1514
-            $field_name = 'answer_feedback_multiple_choice';
1514
+			$field_name = 'answer_feedback_multiple_choice';
1515 1515
 
1516
-        }// end if
1516
+		}// end if
1517 1517
 
1518 1518
 		if( $question_counter ) {
1519 1519
 			$field_name = 'answer_' . $question_counter . '_feedback';
@@ -1718,15 +1718,15 @@  discard block
 block discarded – undo
1718 1718
 			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1719 1719
 
1720 1720
 			// Load the lessons script
1721
-            wp_enqueue_media();
1721
+			wp_enqueue_media();
1722 1722
 			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1723 1723
 			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1724 1724
 			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1725 1725
 
1726
-            // Load the bulk edit screen script
1727
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1729
-            }
1726
+			// Load the bulk edit screen script
1727
+			if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
+				wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1729
+			}
1730 1730
 
1731 1731
 			// Localise script
1732 1732
 			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
@@ -2029,12 +2029,12 @@  discard block
 block discarded – undo
2029 2029
 
2030 2030
 					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2031 2031
 					if( ! in_array( $quiz_id, $quizzes ) ) {
2032
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2032
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2033 2033
 						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2034 2034
 						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2035
-			    	}
2035
+					}
2036 2036
 
2037
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2037
+					add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2038 2038
 					$question_type = Sensei()->question->get_question_type( $question_id );
2039 2039
 
2040 2040
 					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
@@ -2140,34 +2140,34 @@  discard block
 block discarded – undo
2140 2140
 		$post_content = $course_content;
2141 2141
 		// Course Query Arguments
2142 2142
 		$post_type_args = array(	'post_content' => $post_content,
2143
-  		    						'post_status' => $post_status,
2144
-  		    						'post_title' => $post_title,
2145
-  		    						'post_type' => $post_type
2146
-  		    						);
2143
+  									'post_status' => $post_status,
2144
+  									'post_title' => $post_title,
2145
+  									'post_type' => $post_type
2146
+  									);
2147 2147
   		// Only save if there is a valid title
2148 2148
   		if ( $post_title != '' ) {
2149
-  		    // Check for prerequisite courses & product id
2150
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2151
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2152
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2153
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2154
-  		    // Insert or Update the Lesson Quiz
2155
-		    if ( 0 < $course_id ) {
2156
-		    	$post_type_args[ 'ID' ] = $course_id;
2157
-		    	$course_id = wp_update_post($post_type_args);
2158
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2159
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2160
-		    	if ( 0 < $course_category_id ) {
2161
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2162
-		    	} // End If Statement
2163
-		    } else {
2164
-		    	$course_id = wp_insert_post($post_type_args);
2165
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2166
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2167
-		    	if ( 0 < $course_category_id ) {
2168
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2169
-		    	} // End If Statement
2170
-		    } // End If Statement
2149
+  			// Check for prerequisite courses & product id
2150
+  			$course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2151
+  			$course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2152
+  			$course_category_id = absint( $data[ 'course_category' ] );
2153
+  			if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2154
+  			// Insert or Update the Lesson Quiz
2155
+			if ( 0 < $course_id ) {
2156
+				$post_type_args[ 'ID' ] = $course_id;
2157
+				$course_id = wp_update_post($post_type_args);
2158
+				update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2159
+				update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2160
+				if ( 0 < $course_category_id ) {
2161
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2162
+				} // End If Statement
2163
+			} else {
2164
+				$course_id = wp_insert_post($post_type_args);
2165
+				add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2166
+				add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2167
+				if ( 0 < $course_category_id ) {
2168
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2169
+				} // End If Statement
2170
+			} // End If Statement
2171 2171
 		} // End If Statement
2172 2172
   		// Check that the insert or update saved by testing the post id
2173 2173
   		if ( 0 < $course_id ) {
@@ -2258,17 +2258,17 @@  discard block
 block discarded – undo
2258 2258
 		$answer_feedback = '';
2259 2259
 		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2260 2260
 
2261
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2261
+			$answer_feedback = $data[ 'answer_feedback_boolean' ];
2262 2262
 
2263 2263
 		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2264 2264
 
2265
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2265
+			$answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2266 2266
 
2267
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2267
+		}elseif( isset( $data[ 'answer_feedback' ] )  ){
2268 2268
 
2269
-            $answer_feedback = $data[ 'answer_feedback' ];
2269
+			$answer_feedback = $data[ 'answer_feedback' ];
2270 2270
 
2271
-        } // End If Statement
2271
+		} // End If Statement
2272 2272
 
2273 2273
 		$post_title = $question_text;
2274 2274
 		$post_author = $data[ 'post_author' ];
@@ -2283,10 +2283,10 @@  discard block
 block discarded – undo
2283 2283
 		}
2284 2284
 		// Question Query Arguments
2285 2285
 		$post_type_args = array(	'post_content' => $post_content,
2286
-  		    						'post_status' => $post_status,
2287
-  		    						'post_title' => $post_title,
2288
-  		    						'post_type' => $post_type
2289
-  		    						);
2286
+  									'post_status' => $post_status,
2287
+  									'post_title' => $post_title,
2288
+  									'post_type' => $post_type
2289
+  									);
2290 2290
 
2291 2291
   		// Remove empty values and reindex the array
2292 2292
   		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
@@ -2322,14 +2322,14 @@  discard block
 block discarded – undo
2322 2322
   		if ( $post_title != '' ) {
2323 2323
 
2324 2324
   			// Get Quiz ID for the question
2325
-  		    $quiz_id = $data['quiz_id'];
2325
+  			$quiz_id = $data['quiz_id'];
2326 2326
 
2327
-  		    // Get question media
2327
+  			// Get question media
2328 2328
 			$question_media = $data['question_media'];
2329 2329
 
2330
-  		    // Get answer order
2331
-  		    $answer_order = '';
2332
-  		    if( isset( $data['answer_order'] ) ) {
2330
+  			// Get answer order
2331
+  			$answer_order = '';
2332
+  			if( isset( $data['answer_order'] ) ) {
2333 2333
 				$answer_order = $data['answer_order'];
2334 2334
 			}
2335 2335
 
@@ -2339,38 +2339,38 @@  discard block
 block discarded – undo
2339 2339
 				$random_order = $data['random_order'];
2340 2340
 			}
2341 2341
 
2342
-  		    // Insert or Update the question
2343
-  		    if ( 0 < $question_id ) {
2344
-
2345
-  		    	$post_type_args[ 'ID' ] = $question_id;
2346
-		    	$question_id = wp_update_post( $post_type_args );
2347
-
2348
-		    	// Update poast meta
2349
-		    	if( 'quiz' == $context ) {
2350
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2351
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2352
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2353
-			    	}
2354
-		    	}
2355
-
2356
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2357
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2358
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2359
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2360
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2361
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2362
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2363
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2364
-
2365
-		    	if( 'quiz' != $context ) {
2366
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2367
-		    	}
2342
+  			// Insert or Update the question
2343
+  			if ( 0 < $question_id ) {
2344
+
2345
+  				$post_type_args[ 'ID' ] = $question_id;
2346
+				$question_id = wp_update_post( $post_type_args );
2347
+
2348
+				// Update poast meta
2349
+				if( 'quiz' == $context ) {
2350
+					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2351
+					if( ! in_array( $quiz_id, $quizzes ) ) {
2352
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2353
+					}
2354
+				}
2355
+
2356
+				update_post_meta( $question_id, '_question_grade', $question_grade );
2357
+				update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2358
+				update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2359
+				update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2360
+				update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2361
+				update_post_meta( $question_id, '_question_media', $question_media );
2362
+				update_post_meta( $question_id, '_answer_order', $answer_order );
2363
+				update_post_meta( $question_id, '_random_order', $random_order );
2364
+
2365
+				if( 'quiz' != $context ) {
2366
+					wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2367
+				}
2368 2368
 				// Don't store empty value, no point
2369 2369
 				if ( !empty($answer_feedback) ) {
2370 2370
 					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2371 2371
 				}
2372 2372
 
2373
-		    } else {
2373
+			} else {
2374 2374
 				$question_id = wp_insert_post( $post_type_args );
2375 2375
 				$question_count = intval( $data['question_count'] );
2376 2376
 				++$question_count;
@@ -2383,29 +2383,29 @@  discard block
 block discarded – undo
2383 2383
 				}
2384 2384
 
2385 2385
 				if( isset( $question_grade ) ) {
2386
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2387
-		    	}
2388
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2389
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2390
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2391
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2392
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2393
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2394
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2395
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2386
+					add_post_meta( $question_id, '_question_grade', $question_grade );
2387
+				}
2388
+				add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2389
+				add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2390
+				add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2391
+				add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2392
+				add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2393
+				add_post_meta( $question_id, '_question_media', $question_media );
2394
+				add_post_meta( $question_id, '_answer_order', $answer_order );
2395
+				add_post_meta( $question_id, '_random_order', $random_order );
2396 2396
 				// Don't store empty value, no point
2397 2397
 				if ( !empty($answer_feedback) ) {
2398 2398
 					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2399 2399
 				}
2400 2400
 
2401
-		    	// Set the post terms for question-type
2402
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2401
+				// Set the post terms for question-type
2402
+				wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2403 2403
 
2404
-			    if( $question_category ) {
2405
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2406
-	    		}
2404
+				if( $question_category ) {
2405
+					wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2406
+				}
2407 2407
 
2408
-		    } // End If Statement
2408
+			} // End If Statement
2409 2409
 		} // End If Statement
2410 2410
   		// Check that the insert or update saved by testing the post id
2411 2411
   		if ( 0 < $question_id ) {
@@ -2454,7 +2454,7 @@  discard block
 block discarded – undo
2454 2454
 	public function lesson_complexities() {
2455 2455
 
2456 2456
 		// V2 - make filter for this array
2457
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2457
+		$lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2458 2458
 									'std' => __( 'Standard', 'woothemes-sensei' ),
2459 2459
 									'hard' => __( 'Hard', 'woothemes-sensei' )
2460 2460
 									);
@@ -2521,14 +2521,14 @@  discard block
 block discarded – undo
2521 2521
 		$post_args = array(	'post_type' 		=> 'quiz',
2522 2522
 							'posts_per_page' 		=> 1,
2523 2523
 							'orderby'         	=> 'title',
2524
-    						'order'           	=> 'DESC',
2525
-    						'post_parent'      	=> $lesson_id,
2526
-    						'post_status'		=> $post_status,
2524
+							'order'           	=> 'DESC',
2525
+							'post_parent'      	=> $lesson_id,
2526
+							'post_status'		=> $post_status,
2527 2527
 							'suppress_filters' 	=> 0,
2528 2528
 							'fields'            => $fields
2529 2529
 							);
2530 2530
 		$posts_array = get_posts( $post_args );
2531
-        $quiz_id = array_shift($posts_array);
2531
+		$quiz_id = array_shift($posts_array);
2532 2532
 
2533 2533
 		return $quiz_id;
2534 2534
 	} // End lesson_quizzes()
@@ -2536,34 +2536,34 @@  discard block
 block discarded – undo
2536 2536
 
2537 2537
 	/**
2538 2538
 	 * Fetches all the questions for a quiz depending on certain conditions.
2539
-     *
2540
-     * Determine which questions should be shown depending on:
2541
-     * - admin/teacher selected questions to be shown
2542
-     * - questions shown to a user previously (saved as asked questions)
2543
-     * - limit number of questions lesson setting
2544 2539
 	 *
2545
-     * @since 1.0
2540
+	 * Determine which questions should be shown depending on:
2541
+	 * - admin/teacher selected questions to be shown
2542
+	 * - questions shown to a user previously (saved as asked questions)
2543
+	 * - limit number of questions lesson setting
2544
+	 *
2545
+	 * @since 1.0
2546 2546
 	 * @param int $quiz_id (default: 0)
2547 2547
 	 * @param string $post_status (default: 'publish')
2548 2548
 	 * @param string $orderby (default: 'meta_value_num title')
2549 2549
 	 * @param string $order (default: 'ASC')
2550
-     *
2550
+	 *
2551 2551
 	 * @return array $questions { $question type WP_Post }
2552 2552
 	 */
2553 2553
 	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2554 2554
 
2555 2555
 		$quiz_id = (string) $quiz_id;
2556
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2556
+		$quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2557 2557
 
2558
-        // setup the user id
2559
-        if( is_admin() ) {
2560
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2561
-        } else {
2562
-            $user_id = get_current_user_id();
2563
-        }
2558
+		// setup the user id
2559
+		if( is_admin() ) {
2560
+			$user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2561
+		} else {
2562
+			$user_id = get_current_user_id();
2563
+		}
2564 2564
 
2565
-        // get the users current status on the lesson
2566
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2565
+		// get the users current status on the lesson
2566
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2567 2567
 
2568 2568
 		// Set the default question order if it has not already been set for this quiz
2569 2569
 		$this->set_default_question_order( $quiz_id );
@@ -2593,14 +2593,14 @@  discard block
 block discarded – undo
2593 2593
 			'suppress_filters' 	=> 0
2594 2594
 		);
2595 2595
 
2596
-        //query the questions
2596
+		//query the questions
2597 2597
 		$questions_query = new WP_Query( $question_query_args );
2598 2598
 
2599
-        // Set return array to initially include all items
2600
-        $questions = $questions_query->posts;
2599
+		// Set return array to initially include all items
2600
+		$questions = $questions_query->posts;
2601 2601
 
2602
-        // set the questions array that will be manipulated within this function
2603
-        $questions_array = $questions_query->posts;
2602
+		// set the questions array that will be manipulated within this function
2603
+		$questions_array = $questions_query->posts;
2604 2604
 
2605 2605
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2606 2606
 		$selected_questions = false;
@@ -2713,36 +2713,36 @@  discard block
 block discarded – undo
2713 2713
 			}
2714 2714
 		}
2715 2715
 
2716
-        // Save the questions that will be asked for the current user
2717
-        // this happens only once per user/quiz, unless the user resets the quiz
2718
-        if( ! is_admin() ){
2716
+		// Save the questions that will be asked for the current user
2717
+		// this happens only once per user/quiz, unless the user resets the quiz
2718
+		if( ! is_admin() ){
2719 2719
 
2720
-            if( $user_lesson_status ) {
2720
+			if( $user_lesson_status ) {
2721 2721
 
2722
-                $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2723
-                if ( empty($questions_asked) && $user_lesson_status) {
2722
+				$questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2723
+				if ( empty($questions_asked) && $user_lesson_status) {
2724 2724
 
2725
-                    $questions_asked = array();
2726
-                    foreach ($questions as $question) {
2725
+					$questions_asked = array();
2726
+					foreach ($questions as $question) {
2727 2727
 
2728
-                        $questions_asked[] = $question->ID;
2728
+						$questions_asked[] = $question->ID;
2729 2729
 
2730
-                    }
2730
+					}
2731 2731
 
2732
-                    // save the questions asked id
2733
-                    $questions_asked_csv = implode(',', $questions_asked);
2734
-                    update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2732
+					// save the questions asked id
2733
+					$questions_asked_csv = implode(',', $questions_asked);
2734
+					update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2735 2735
 
2736
-                }
2737
-            }
2738
-        }
2736
+				}
2737
+			}
2738
+		}
2739 2739
 
2740
-        /**
2741
-         * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2742
-         *
2743
-         * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2744
-         * @since 1.8.0
2745
-         */
2740
+		/**
2741
+		 * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2742
+		 *
2743
+		 * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2744
+		 * @since 1.8.0
2745
+		 */
2746 2746
 		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2747 2747
 
2748 2748
 	} // End lesson_quiz_questions()
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
  			// Display Image Placeholder if none
2847 2847
 			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2848 2848
 
2849
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2849
+				$img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2850 2850
 
2851 2851
 			} // End If Statement
2852 2852
 
@@ -2858,417 +2858,417 @@  discard block
 block discarded – undo
2858 2858
 
2859 2859
 	} // End lesson_image()
2860 2860
 
2861
-    /**
2862
-     * Ooutpu the lesson image
2863
-     *
2864
-     * @since 1.9.0
2865
-     * @param integer $lesson_id
2866
-     */
2867
-    public static function the_lesson_image( $lesson_id = 0 ){
2861
+	/**
2862
+	 * Ooutpu the lesson image
2863
+	 *
2864
+	 * @since 1.9.0
2865
+	 * @param integer $lesson_id
2866
+	 */
2867
+	public static function the_lesson_image( $lesson_id = 0 ){
2868 2868
 
2869
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2869
+		echo Sensei()->lesson->lesson_image( $lesson_id );
2870 2870
 
2871
-    }
2871
+	}
2872 2872
 
2873 2873
 	/**
2874 2874
 	 * Returns the the lesson excerpt.
2875 2875
 	 *
2876 2876
 	 * @param WP_Post $lesson
2877
-     * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2877
+	 * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2878 2878
 	 * @return string
2879 2879
 	 */
2880 2880
 	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2881 2881
 		$html = '';
2882 2882
 		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2883 2883
 
2884
-            $excerpt =  $lesson->post_excerpt;
2884
+			$excerpt =  $lesson->post_excerpt;
2885 2885
 
2886
-            // if $add_p_tags true wrap with <p> else return the excerpt as is
2887
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2886
+			// if $add_p_tags true wrap with <p> else return the excerpt as is
2887
+			$html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2888 2888
 
2889 2889
 		}
2890 2890
 		return apply_filters( 'sensei_lesson_excerpt', $html );
2891 2891
 
2892 2892
 	} // End lesson_excerpt()
2893 2893
 
2894
-    /**
2895
-     * Returns the course for a given lesson
2896
-     *
2897
-     * @since 1.7.4
2898
-     * @access public
2899
-     *
2900
-     * @param int $lesson_id
2901
-     * @return int|bool $course_id or bool when nothing is found.
2902
-     */
2903
-     public function get_course_id( $lesson_id ){
2904
-
2905
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2906
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2907
-             return false;
2908
-         }
2909
-
2910
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2911
-
2912
-         // make sure the course id is valid
2913
-         if( empty( $lesson_course_id )
2914
-             || is_array( $lesson_course_id )
2915
-             || intval( $lesson_course_id ) < 1
2916
-             || 'course' != get_post_type( $lesson_course_id ) ){
2917
-
2918
-             return false;
2919
-
2920
-         }
2921
-
2922
-         return $lesson_course_id;
2923
-
2924
-     }// en get_course_id
2925
-
2926
-    /**
2927
-     * Add the admin all lessons screen edit options.
2928
-     *
2929
-     * The fields in this function work for both quick and bulk edit. The ID attributes is used
2930
-     * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2931
-     * name attribute is will be used by the quick edit and submitted via standard POST. This
2932
-     * will use this classes save_post_meta function to save the new field data.
2933
-     *
2934
-     * @hooked quick_edit_custom_box
2935
-     * @hooked bulk_edit_custom_box
2936
-     *
2937
-     * @since 1.8.0
2938
-     *
2939
-     * @param string $column_name
2940
-     * @param string $post_type
2941
-     * @return void
2942
-     */
2943
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2944
-
2945
-        // only show these options ont he lesson post type edit screen
2946
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2947
-            return;
2948
-        }
2949
-
2950
-        ?>
2894
+	/**
2895
+	 * Returns the course for a given lesson
2896
+	 *
2897
+	 * @since 1.7.4
2898
+	 * @access public
2899
+	 *
2900
+	 * @param int $lesson_id
2901
+	 * @return int|bool $course_id or bool when nothing is found.
2902
+	 */
2903
+	 public function get_course_id( $lesson_id ){
2904
+
2905
+		 if( ! isset( $lesson_id ) || empty( $lesson_id )
2906
+		 ||  'lesson' != get_post_type( $lesson_id ) ){
2907
+			 return false;
2908
+		 }
2909
+
2910
+		 $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2911
+
2912
+		 // make sure the course id is valid
2913
+		 if( empty( $lesson_course_id )
2914
+			 || is_array( $lesson_course_id )
2915
+			 || intval( $lesson_course_id ) < 1
2916
+			 || 'course' != get_post_type( $lesson_course_id ) ){
2917
+
2918
+			 return false;
2919
+
2920
+		 }
2921
+
2922
+		 return $lesson_course_id;
2923
+
2924
+	 }// en get_course_id
2925
+
2926
+	/**
2927
+	 * Add the admin all lessons screen edit options.
2928
+	 *
2929
+	 * The fields in this function work for both quick and bulk edit. The ID attributes is used
2930
+	 * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2931
+	 * name attribute is will be used by the quick edit and submitted via standard POST. This
2932
+	 * will use this classes save_post_meta function to save the new field data.
2933
+	 *
2934
+	 * @hooked quick_edit_custom_box
2935
+	 * @hooked bulk_edit_custom_box
2936
+	 *
2937
+	 * @since 1.8.0
2938
+	 *
2939
+	 * @param string $column_name
2940
+	 * @param string $post_type
2941
+	 * @return void
2942
+	 */
2943
+	public function all_lessons_edit_fields( $column_name, $post_type ) {
2944
+
2945
+		// only show these options ont he lesson post type edit screen
2946
+		if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2947
+			return;
2948
+		}
2949
+
2950
+		?>
2951 2951
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2952 2952
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2953 2953
                     <?php
2954
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2955
-                    // create a nonce field to be  used as a security measure when saving the data
2956
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2957
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2958
-
2959
-                    // unchanged option - we need this in because
2960
-                    // the default option in bulk edit should not be empty. If it is
2961
-                    // the user will erase data they didn't want to touch.
2962
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2963
-
2964
-                    //
2965
-                    //course selection
2966
-                    //
2967
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2968
-                    $course_options = array();
2969
-                    if ( count( $courses ) > 0 ) {
2970
-                        foreach ($courses as $course ){
2971
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2972
-                        }
2973
-                    }
2974
-                    //pre-append the no change option
2975
-                    $course_options['-1']=  $no_change_text;
2976
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2977
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2978
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2979
-
2980
-                    //
2981
-                    // lesson complexity selection
2982
-                    //
2983
-                    $lesson_complexities =  $this->lesson_complexities();
2984
-                    //pre-append the no change option
2985
-                    $lesson_complexities['-1']=  $no_change_text;
2986
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2987
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2988
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2989
-
2990
-                    ?>
2954
+					echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2955
+					// create a nonce field to be  used as a security measure when saving the data
2956
+					wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2957
+					wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2958
+
2959
+					// unchanged option - we need this in because
2960
+					// the default option in bulk edit should not be empty. If it is
2961
+					// the user will erase data they didn't want to touch.
2962
+					$no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2963
+
2964
+					//
2965
+					//course selection
2966
+					//
2967
+					$courses =  WooThemes_Sensei_Course::get_all_courses();
2968
+					$course_options = array();
2969
+					if ( count( $courses ) > 0 ) {
2970
+						foreach ($courses as $course ){
2971
+							$course_options[ $course->ID ] = get_the_title( $course->ID );
2972
+						}
2973
+					}
2974
+					//pre-append the no change option
2975
+					$course_options['-1']=  $no_change_text;
2976
+					$course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2977
+					$course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2978
+					echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2979
+
2980
+					//
2981
+					// lesson complexity selection
2982
+					//
2983
+					$lesson_complexities =  $this->lesson_complexities();
2984
+					//pre-append the no change option
2985
+					$lesson_complexities['-1']=  $no_change_text;
2986
+					$complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2987
+					$complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2988
+					echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2989
+
2990
+					?>
2991 2991
 
2992 2992
                     <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4>
2993 2993
 
2994 2994
                     <?php
2995 2995
 
2996
-                    //
2997
-                    // Lesson require pass to complete
2998
-                    //
2999
-                    $pass_required_options = array(
3000
-                        '-1' => $no_change_text,
3001
-                         '0' => __('No','woothemes'),
3002
-                         '1' => __('Yes','woothemes'),
3003
-                    );
3004
-
3005
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3006
-                                                                'id'=> 'sensei-edit-lesson-pass-required',
3007
-                                                                'class'=>' '   );
3008
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3009
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3010
-
3011
-                    //
3012
-                    // Quiz pass percentage
3013
-                    //
3014
-                    $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3015
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3016
-
3017
-                    //
3018
-                    // Enable quiz reset button
3019
-                    //
3020
-                    $quiz_reset_select__options = array(
3021
-                        '-1' => $no_change_text,
3022
-                        '0' => __('No','woothemes'),
3023
-                        '1' => __('Yes','woothemes'),
3024
-                    );
3025
-                    $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3026
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3027
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3028
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3029
-
3030
-                    ?>
2996
+					//
2997
+					// Lesson require pass to complete
2998
+					//
2999
+					$pass_required_options = array(
3000
+						'-1' => $no_change_text,
3001
+						 '0' => __('No','woothemes'),
3002
+						 '1' => __('Yes','woothemes'),
3003
+					);
3004
+
3005
+					$pass_required_select_attributes = array( 'name'=> 'pass_required',
3006
+																'id'=> 'sensei-edit-lesson-pass-required',
3007
+																'class'=>' '   );
3008
+					$require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3009
+					echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3010
+
3011
+					//
3012
+					// Quiz pass percentage
3013
+					//
3014
+					$quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3015
+					echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3016
+
3017
+					//
3018
+					// Enable quiz reset button
3019
+					//
3020
+					$quiz_reset_select__options = array(
3021
+						'-1' => $no_change_text,
3022
+						'0' => __('No','woothemes'),
3023
+						'1' => __('Yes','woothemes'),
3024
+					);
3025
+					$quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3026
+					$quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3027
+					$quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3028
+					echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3029
+
3030
+					?>
3031 3031
             </div>
3032 3032
         </fieldset>
3033 3033
     <?php
3034
-    }// all_lessons_edit_fields
3035
-
3036
-    /**
3037
-     * Create the html for the edit field
3038
-     *
3039
-     * Wraps the passed in field and title combination with the correct html.
3040
-     *
3041
-     * @since 1.8.0
3042
-     *
3043
-     * @param string $title that will stand to the left of the field.
3044
-     * @param string $field type markup for the field that must be wrapped.
3045
-     * @return string $field_html
3046
-     */
3047
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3048
-
3049
-        $html = '';
3050
-        $html = '<div class="inline-edit-group" >';
3051
-        $html .=  '<span class="title">'. $title .'</span> ';
3052
-        $html .= '<span class="input-text-wrap">';
3053
-        $html .= $field;
3054
-        $html .= '</span>';
3055
-        $html .= '</label></div>';
3056
-
3057
-        return $html ;
3058
-
3059
-    }//end generate_all_lessons_edit_field
3060
-
3061
-    /**
3062
-     * Respond to the ajax call from the bulk edit save function. This comes
3063
-     * from the admin all lesson screen.
3064
-     *
3065
-     * @since 1.8.0
3066
-     * @return void
3067
-     */
3068
-    function save_all_lessons_edit_fields() {
3069
-
3070
-        // verify all the data before attempting to save
3071
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3072
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3073
-            die();
3074
-        }
3075
-
3076
-        // get our variables
3077
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3078
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3079
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3080
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3081
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3082
-        // store the values for all selected posts
3083
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3084
-
3085
-            // get the quiz id needed for the quiz meta
3086
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3087
-
3088
-            // do not save the items if the value is -1 as this
3089
-            // means it was not changed
3090
-
3091
-            // update lesson course
3092
-            if( -1 != $new_course ){
3093
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3094
-            }
3095
-            // update lesson complexity
3096
-            if( -1 != $new_complexity ){
3097
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3098
-            }
3099
-
3100
-            // Quiz Related settings
3101
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3102
-
3103
-                // update pass required
3104
-                if (-1 != $new_pass_required) {
3105
-
3106
-                    $checked = $new_pass_required  ? 'on' : '';
3107
-                    update_post_meta($quiz_id, '_pass_required', $checked);
3108
-                    unset( $checked );
3109
-                }
3034
+	}// all_lessons_edit_fields
3110 3035
 
3111
-                // update pass percentage
3112
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3036
+	/**
3037
+	 * Create the html for the edit field
3038
+	 *
3039
+	 * Wraps the passed in field and title combination with the correct html.
3040
+	 *
3041
+	 * @since 1.8.0
3042
+	 *
3043
+	 * @param string $title that will stand to the left of the field.
3044
+	 * @param string $field type markup for the field that must be wrapped.
3045
+	 * @return string $field_html
3046
+	 */
3047
+	public function generate_all_lessons_edit_field( $title  ,$field ){
3113 3048
 
3114
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3049
+		$html = '';
3050
+		$html = '<div class="inline-edit-group" >';
3051
+		$html .=  '<span class="title">'. $title .'</span> ';
3052
+		$html .= '<span class="input-text-wrap">';
3053
+		$html .= $field;
3054
+		$html .= '</span>';
3055
+		$html .= '</label></div>';
3115 3056
 
3116
-                }
3057
+		return $html ;
3117 3058
 
3118
-                //
3119
-                // update enable quiz reset
3120
-                //
3121
-                if (-1 != $new_enable_quiz_reset ) {
3059
+	}//end generate_all_lessons_edit_field
3122 3060
 
3123
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3124
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3125
-                    unset( $checked );
3061
+	/**
3062
+	 * Respond to the ajax call from the bulk edit save function. This comes
3063
+	 * from the admin all lesson screen.
3064
+	 *
3065
+	 * @since 1.8.0
3066
+	 * @return void
3067
+	 */
3068
+	function save_all_lessons_edit_fields() {
3126 3069
 
3127
-                }
3070
+		// verify all the data before attempting to save
3071
+		if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3072
+			||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3073
+			die();
3074
+		}
3128 3075
 
3076
+		// get our variables
3077
+		$new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3078
+		$new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3079
+		$new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3080
+		$new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3081
+		$new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3082
+		// store the values for all selected posts
3083
+		foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3129 3084
 
3130
-            } // end if quiz
3085
+			// get the quiz id needed for the quiz meta
3086
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3131 3087
 
3132
-        }// end for each
3088
+			// do not save the items if the value is -1 as this
3089
+			// means it was not changed
3133 3090
 
3134
-        die();
3091
+			// update lesson course
3092
+			if( -1 != $new_course ){
3093
+				update_post_meta( $lesson_id, '_lesson_course', $new_course );
3094
+			}
3095
+			// update lesson complexity
3096
+			if( -1 != $new_complexity ){
3097
+				update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3098
+			}
3135 3099
 
3136
-    } // end save_all_lessons_edit_fields
3100
+			// Quiz Related settings
3101
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3137 3102
 
3138
-    /**
3139
-     * Loading the quick edit fields defaults.
3140
-     *
3141
-     * This function will localise the default values along with the script that will
3142
-     * add these values to the inputs.
3143
-     *
3144
-     * NOTE: this function runs for each row in the edit column
3145
-     *
3146
-     * @since 1.8.0
3147
-     * @return void
3148
-     */
3149
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3103
+				// update pass required
3104
+				if (-1 != $new_pass_required) {
3150 3105
 
3151
-        if( 'lesson-course' != $column_name ){
3152
-            return;
3153
-        }
3154
-        // load the script
3155
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3156
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3106
+					$checked = $new_pass_required  ? 'on' : '';
3107
+					update_post_meta($quiz_id, '_pass_required', $checked);
3108
+					unset( $checked );
3109
+				}
3157 3110
 
3158
-        // setup the values for all meta fields
3159
-        $data = array();
3160
-        foreach( $this->meta_fields as $field ){
3111
+				// update pass percentage
3112
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3161 3113
 
3162
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3114
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3163 3115
 
3164
-        }
3165
-        // add quiz meta fields
3166
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3167
-        foreach( Sensei()->quiz->meta_fields as $field ){
3116
+				}
3168 3117
 
3169
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3118
+				//
3119
+				// update enable quiz reset
3120
+				//
3121
+				if (-1 != $new_enable_quiz_reset ) {
3170 3122
 
3171
-        }
3123
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3124
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3125
+					unset( $checked );
3172 3126
 
3173
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3127
+				}
3174 3128
 
3175
-    }// end quick edit admin defaults
3176 3129
 
3177
-    /**
3178
-     * Filter the classes for lessons on the single course page.
3179
-     *
3180
-     * Adds the nesecary classes depending on the user data
3181
-     *
3182
-     * @since 1.9.0
3183
-     * @param array $classes
3184
-     * @return array $classes
3185
-     */
3186
-    public static function single_course_lessons_classes( $classes ){
3130
+			} // end if quiz
3187 3131
 
3188
-        if(  is_singular('course') ){
3132
+		}// end for each
3189 3133
 
3190
-            global $post;
3191
-            $course_id = $post->ID;
3134
+		die();
3192 3135
 
3193
-            $lesson_classes = array( 'course', 'post' );
3194
-            if ( is_user_logged_in() ) {
3136
+	} // end save_all_lessons_edit_fields
3195 3137
 
3196
-                // Check if Lesson is complete
3197
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3198
-                if ( $single_lesson_complete ) {
3138
+	/**
3139
+	 * Loading the quick edit fields defaults.
3140
+	 *
3141
+	 * This function will localise the default values along with the script that will
3142
+	 * add these values to the inputs.
3143
+	 *
3144
+	 * NOTE: this function runs for each row in the edit column
3145
+	 *
3146
+	 * @since 1.8.0
3147
+	 * @return void
3148
+	 */
3149
+	public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3199 3150
 
3200
-                    $lesson_classes[] = 'lesson-completed';
3151
+		if( 'lesson-course' != $column_name ){
3152
+			return;
3153
+		}
3154
+		// load the script
3155
+		$suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3156
+		wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3201 3157
 
3202
-                } // End If Statement
3158
+		// setup the values for all meta fields
3159
+		$data = array();
3160
+		foreach( $this->meta_fields as $field ){
3203 3161
 
3204
-            } // End If Statement
3162
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3205 3163
 
3206
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3207
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3164
+		}
3165
+		// add quiz meta fields
3166
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3167
+		foreach( Sensei()->quiz->meta_fields as $field ){
3208 3168
 
3209
-                $lesson_classes[] = 'lesson-preview';
3169
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3210 3170
 
3211
-            }
3171
+		}
3172
+
3173
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3174
+
3175
+	}// end quick edit admin defaults
3176
+
3177
+	/**
3178
+	 * Filter the classes for lessons on the single course page.
3179
+	 *
3180
+	 * Adds the nesecary classes depending on the user data
3181
+	 *
3182
+	 * @since 1.9.0
3183
+	 * @param array $classes
3184
+	 * @return array $classes
3185
+	 */
3186
+	public static function single_course_lessons_classes( $classes ){
3212 3187
 
3213
-            $classes = array_merge( $classes, $lesson_classes  );
3188
+		if(  is_singular('course') ){
3214 3189
 
3215
-        }
3190
+			global $post;
3191
+			$course_id = $post->ID;
3216 3192
 
3217
-        return $classes;
3193
+			$lesson_classes = array( 'course', 'post' );
3194
+			if ( is_user_logged_in() ) {
3218 3195
 
3219
-    }// end single_course_lessons_classes
3196
+				// Check if Lesson is complete
3197
+				$single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3198
+				if ( $single_lesson_complete ) {
3220 3199
 
3221
-    /**
3222
-     * Output the lesson meta for the given lesson
3223
-     *
3224
-     * @since 1.9.0
3225
-     * @param $lesson_id
3226
-     */
3227
-    public static function the_lesson_meta( $lesson_id ){
3200
+					$lesson_classes[] = 'lesson-completed';
3228 3201
 
3229
-        global $wp_query;
3230
-        $loop_lesson_number = $wp_query->current_post + 1;
3202
+				} // End If Statement
3203
+
3204
+			} // End If Statement
3231 3205
 
3232
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3233
-        $single_lesson_complete = false;
3234
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3206
+			$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3207
+			if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3235 3208
 
3236
-        // Get Lesson data
3237
-        $complexity_array = Sensei()->lesson->lesson_complexities();
3209
+				$lesson_classes[] = 'lesson-preview';
3238 3210
 
3239
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3240
-        if ( '' != $lesson_complexity ) {
3211
+			}
3241 3212
 
3242
-            $lesson_complexity = $complexity_array[$lesson_complexity];
3213
+			$classes = array_merge( $classes, $lesson_classes  );
3243 3214
 
3244
-        }
3245
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3246
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3247
-        $preview_label = '';
3248
-        if ( $is_preview && !$is_user_taking_course ) {
3215
+		}
3249 3216
 
3250
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3251
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3217
+		return $classes;
3252 3218
 
3253
-        }
3219
+	}// end single_course_lessons_classes
3254 3220
 
3221
+	/**
3222
+	 * Output the lesson meta for the given lesson
3223
+	 *
3224
+	 * @since 1.9.0
3225
+	 * @param $lesson_id
3226
+	 */
3227
+	public static function the_lesson_meta( $lesson_id ){
3255 3228
 
3256
-        $count_markup= '';
3257
-        /**
3258
-         * Filter for if you want the $lesson_count to show next to the lesson.
3259
-         *
3260
-         * @since 1.0
3261
-         * @param bool default false.
3262
-         */
3263
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3229
+		global $wp_query;
3230
+		$loop_lesson_number = $wp_query->current_post + 1;
3264 3231
 
3265
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3232
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
3233
+		$single_lesson_complete = false;
3234
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3266 3235
 
3267
-        }
3236
+		// Get Lesson data
3237
+		$complexity_array = Sensei()->lesson->lesson_complexities();
3268 3238
 
3269
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3239
+		$lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3240
+		if ( '' != $lesson_complexity ) {
3270 3241
 
3271
-        ?>
3242
+			$lesson_complexity = $complexity_array[$lesson_complexity];
3243
+
3244
+		}
3245
+		$user_info = get_userdata( absint( get_post()->post_author ) );
3246
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3247
+		$preview_label = '';
3248
+		if ( $is_preview && !$is_user_taking_course ) {
3249
+
3250
+			$preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3251
+			$preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3252
+
3253
+		}
3254
+
3255
+
3256
+		$count_markup= '';
3257
+		/**
3258
+		 * Filter for if you want the $lesson_count to show next to the lesson.
3259
+		 *
3260
+		 * @since 1.0
3261
+		 * @param bool default false.
3262
+		 */
3263
+		if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3264
+
3265
+			$count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3266
+
3267
+		}
3268
+
3269
+		$heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3270
+
3271
+		?>
3272 3272
         <header>
3273 3273
             <h2>
3274 3274
                 <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
@@ -3281,40 +3281,40 @@  discard block
 block discarded – undo
3281 3281
 
3282 3282
                 <?php
3283 3283
 
3284
-                $meta_html = '';
3285
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3284
+				$meta_html = '';
3285
+				$user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3286 3286
 
3287
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3288
-                if ( '' != $lesson_length ) {
3287
+				$lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3288
+				if ( '' != $lesson_length ) {
3289 3289
 
3290
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3290
+					$meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3291 3291
 
3292
-                }
3292
+				}
3293 3293
 
3294
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3294
+				if ( Sensei()->settings->get( 'lesson_author' ) ) {
3295 3295
 
3296
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3296
+					$meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3297 3297
 
3298
-                } // End If Statement
3299
-                if ( '' != $lesson_complexity ) {
3298
+				} // End If Statement
3299
+				if ( '' != $lesson_complexity ) {
3300 3300
 
3301
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3301
+					$meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3302 3302
 
3303
-                }
3303
+				}
3304 3304
 
3305
-                if ( $single_lesson_complete ) {
3305
+				if ( $single_lesson_complete ) {
3306 3306
 
3307
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3307
+					$meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3308 3308
 
3309
-                } elseif ( $user_lesson_status ) {
3309
+				} elseif ( $user_lesson_status ) {
3310 3310
 
3311
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3311
+					$meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3312 3312
 
3313
-                } // End If Statement
3313
+				} // End If Statement
3314 3314
 
3315
-                echo $meta_html;
3315
+				echo $meta_html;
3316 3316
 
3317
-                ?>
3317
+				?>
3318 3318
 
3319 3319
             </p> <!-- lesson meta -->
3320 3320
 
@@ -3322,132 +3322,132 @@  discard block
 block discarded – undo
3322 3322
 
3323 3323
     <?php
3324 3324
 
3325
-    } // end the_lesson_meta
3325
+	} // end the_lesson_meta
3326 3326
 
3327
-    /**
3328
-     * Output the lessons thumbnail
3329
-     *
3330
-     * 1.9.0
3331
-     *
3332
-     * @param $lesson_id
3333
-     */
3334
-    public static function the_lesson_thumbnail( $lesson_id ){
3327
+	/**
3328
+	 * Output the lessons thumbnail
3329
+	 *
3330
+	 * 1.9.0
3331
+	 *
3332
+	 * @param $lesson_id
3333
+	 */
3334
+	public static function the_lesson_thumbnail( $lesson_id ){
3335 3335
 
3336
-        if( empty( $lesson_id ) ){
3336
+		if( empty( $lesson_id ) ){
3337 3337
 
3338
-            $lesson_id = get_the_ID();
3338
+			$lesson_id = get_the_ID();
3339 3339
 
3340
-        }
3340
+		}
3341 3341
 
3342
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3343
-            return;
3344
-        }
3342
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3343
+			return;
3344
+		}
3345 3345
 
3346
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3347
-    }
3346
+		echo Sensei()->lesson->lesson_image( $lesson_id );
3347
+	}
3348 3348
 
3349 3349
 
3350
-    /**
3351
-     * Alter the sensei lesson excerpt.
3352
-     *
3353
-     * @since 1.9.0
3354
-     * @param string $excerpt
3355
-     * @return string $excerpt
3356
-     */
3357
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3350
+	/**
3351
+	 * Alter the sensei lesson excerpt.
3352
+	 *
3353
+	 * @since 1.9.0
3354
+	 * @param string $excerpt
3355
+	 * @return string $excerpt
3356
+	 */
3357
+	public static function alter_the_lesson_excerpt( $excerpt ) {
3358 3358
 
3359
-        if ('lesson' == get_post_type(get_the_ID())){
3359
+		if ('lesson' == get_post_type(get_the_ID())){
3360 3360
 
3361
-            // remove this hooks to avoid an infinite loop.
3362
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3361
+			// remove this hooks to avoid an infinite loop.
3362
+			remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3363 3363
 
3364
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3365
-        }
3364
+			return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3365
+		}
3366 3366
 
3367
-        return $excerpt;
3367
+		return $excerpt;
3368 3368
 
3369
-    }// end the_lesson_excerpt
3369
+	}// end the_lesson_excerpt
3370 3370
 
3371
-    /**
3372
-     * Returns the lesson prerequisite for the given lesson id.
3373
-     *
3374
-     * @since 1.9.0
3375
-     *
3376
-     * @param $current_lesson_id
3377
-     * @return mixed | bool | int $prerequisite_lesson_id or false
3378
-     */
3379
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3371
+	/**
3372
+	 * Returns the lesson prerequisite for the given lesson id.
3373
+	 *
3374
+	 * @since 1.9.0
3375
+	 *
3376
+	 * @param $current_lesson_id
3377
+	 * @return mixed | bool | int $prerequisite_lesson_id or false
3378
+	 */
3379
+	public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3380 3380
 
3381
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3381
+		$prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3382 3382
 
3383
-        // set ti to false if not a valid prerequisite lesson id
3384
-        if(  empty( $prerequisite_lesson_id )
3385
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3386
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3383
+		// set ti to false if not a valid prerequisite lesson id
3384
+		if(  empty( $prerequisite_lesson_id )
3385
+			|| 'lesson' != get_post_type( $prerequisite_lesson_id )
3386
+			|| $prerequisite_lesson_id == $current_lesson_id  ) {
3387 3387
 
3388
-            $prerequisite_lesson_id = false;
3388
+			$prerequisite_lesson_id = false;
3389 3389
 
3390
-        }
3390
+		}
3391 3391
 
3392
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3392
+		return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3393 3393
 
3394
-    }
3394
+	}
3395 3395
 
3396
-    /**
3397
-     * This function requires that you pass in the lesson you would like to check for
3398
-     * a pre-requisite and not the pre-requisite. It will check if the
3399
-     * lesson has a pre-requiste and then check if it is completed.
3400
-     *
3401
-     * @since 1.9.0
3402
-     *
3403
-     * @param $lesson_id
3404
-     * @param $user_id
3405
-     * @return bool
3406
-     */
3407
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3396
+	/**
3397
+	 * This function requires that you pass in the lesson you would like to check for
3398
+	 * a pre-requisite and not the pre-requisite. It will check if the
3399
+	 * lesson has a pre-requiste and then check if it is completed.
3400
+	 *
3401
+	 * @since 1.9.0
3402
+	 *
3403
+	 * @param $lesson_id
3404
+	 * @param $user_id
3405
+	 * @return bool
3406
+	 */
3407
+	public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3408 3408
 
3409
-        if( empty( $lesson_id ) || empty( $user_id )
3410
-        || 'lesson' != get_post_type( $lesson_id )
3411
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3409
+		if( empty( $lesson_id ) || empty( $user_id )
3410
+		|| 'lesson' != get_post_type( $lesson_id )
3411
+		||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3412 3412
 
3413
-            return false;
3413
+			return false;
3414 3414
 
3415
-        }
3415
+		}
3416 3416
 
3417
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3417
+		$pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3418 3418
 
3419
-        // not a valid pre-requisite so pre-requisite is completed
3420
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3421
-            || ! is_numeric( $pre_requisite_id ) ){
3419
+		// not a valid pre-requisite so pre-requisite is completed
3420
+		if( 'lesson' != get_post_type( $pre_requisite_id )
3421
+			|| ! is_numeric( $pre_requisite_id ) ){
3422 3422
 
3423
-            return true;
3423
+			return true;
3424 3424
 
3425
-        }
3425
+		}
3426 3426
 
3427
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3427
+		return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3428 3428
 
3429
-    }// end is_prerequisite_complete
3429
+	}// end is_prerequisite_complete
3430 3430
 
3431
-    /**
3432
-     * Show the user not taking course message if it is the case
3433
-     *
3434
-     * @since 1.9.0
3435
-     */
3436
-    public  static function user_not_taking_course_message(){
3431
+	/**
3432
+	 * Show the user not taking course message if it is the case
3433
+	 *
3434
+	 * @since 1.9.0
3435
+	 */
3436
+	public  static function user_not_taking_course_message(){
3437 3437
 
3438
-        $lesson_id = get_the_ID();
3438
+		$lesson_id = get_the_ID();
3439 3439
 
3440
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3441
-            return;
3442
-        }
3440
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3441
+			return;
3442
+		}
3443 3443
 
3444
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3445
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3446
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3447
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3444
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3445
+		$pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3446
+		$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3447
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3448 3448
 
3449
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3450
-            ?>
3449
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3450
+			?>
3451 3451
 
3452 3452
             <div class="sensei-message alert">
3453 3453
                 <?php echo Sensei()->permissions_message['message']; ?>
@@ -3455,46 +3455,46 @@  discard block
 block discarded – undo
3455 3455
 
3456 3456
             <?php
3457 3457
 
3458
-        }// end if
3458
+		}// end if
3459 3459
 
3460
-    } // end user_not_taking_course_message
3460
+	} // end user_not_taking_course_message
3461 3461
 
3462
-    /**
3463
-     * Outputs the lessons course signup lingk
3464
-     *
3465
-     * This hook runs inside the single lesson page.
3466
-     *
3467
-     * @since 1.9.0
3468
-     */
3469
-    public static function course_signup_link( ){
3462
+	/**
3463
+	 * Outputs the lessons course signup lingk
3464
+	 *
3465
+	 * This hook runs inside the single lesson page.
3466
+	 *
3467
+	 * @since 1.9.0
3468
+	 */
3469
+	public static function course_signup_link( ){
3470 3470
 
3471
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3471
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3472 3472
 
3473
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3473
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3474 3474
 
3475
-            return;
3475
+			return;
3476 3476
 
3477
-        }
3478
-        ?>
3477
+		}
3478
+		?>
3479 3479
 
3480 3480
         <section class="course-signup lesson-meta">
3481 3481
 
3482 3482
             <?php
3483
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3483
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3484 3484
 
3485
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3485
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3486 3486
 
3487
-                global $current_user;
3488
-                if( is_user_logged_in() ) {
3489
-                    wp_get_current_user();
3487
+				global $current_user;
3488
+				if( is_user_logged_in() ) {
3489
+					wp_get_current_user();
3490 3490
 
3491
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3491
+					$course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3492 3492
 
3493
-                    if( $course_purchased ) {
3493
+					if( $course_purchased ) {
3494 3494
 
3495
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3496
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3497
-                        ?>
3495
+						$prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3496
+						$course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3497
+						?>
3498 3498
                             <div class="sensei-message info">
3499 3499
 
3500 3500
                                 <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
@@ -3506,14 +3506,14 @@  discard block
 block discarded – undo
3506 3506
                         <div class="sensei-message info">
3507 3507
 
3508 3508
                             <?php
3509
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3510
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3511
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3512
-                                            . '</a>';
3509
+							$course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3510
+											. '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3511
+											. '">' . __( 'course', 'woothemes-sensei' )
3512
+											. '</a>';
3513 3513
 
3514
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3514
+							echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3515 3515
 
3516
-                            ?>
3516
+							?>
3517 3517
 
3518 3518
                         </div>
3519 3519
                     <?php } ?>
@@ -3530,14 +3530,14 @@  discard block
 block discarded – undo
3530 3530
 
3531 3531
                 <div class="sensei-message info">
3532 3532
                     <?php
3533
-                    $course_link =  '<a href="'
3534
-                                        . esc_url( get_permalink( $course_id ) )
3535
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3536
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3537
-                                    . '</a>';
3538
-
3539
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3540
-                    ?>
3533
+					$course_link =  '<a href="'
3534
+										. esc_url( get_permalink( $course_id ) )
3535
+										. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3536
+										. '">' . __( 'course', 'woothemes-sensei' )
3537
+									. '</a>';
3538
+
3539
+					echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3540
+					?>
3541 3541
                 </div>
3542 3542
 
3543 3543
             <?php endif; ?>
@@ -3547,75 +3547,75 @@  discard block
 block discarded – undo
3547 3547
         </section>
3548 3548
 
3549 3549
         <?php
3550
-    }// end course_signup_link
3550
+	}// end course_signup_link
3551 3551
 
3552
-    /**
3553
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3554
-     *
3555
-     * @since 1.9.0
3556
-     */
3557
-    public  static function prerequisite_complete_message(){
3552
+	/**
3553
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3554
+	 *
3555
+	 * @since 1.9.0
3556
+	 */
3557
+	public  static function prerequisite_complete_message(){
3558 3558
 
3559
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3560
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3561
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3559
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3560
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3561
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3562 3562
 
3563
-            $prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3564
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3563
+			$prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3564
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3565 3565
 
3566
-        }
3566
+		}
3567 3567
 
3568
-    }
3568
+	}
3569 3569
 
3570
-    /**
3571
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3572
-     * active for backwards compatibility.
3573
-     *
3574
-     * @deprecated since 1.9.0
3575
-     */
3576
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3570
+	/**
3571
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3572
+	 * active for backwards compatibility.
3573
+	 *
3574
+	 * @deprecated since 1.9.0
3575
+	 */
3576
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3577 3577
 
3578
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3578
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3579 3579
 
3580
-    }
3580
+	}
3581 3581
 
3582
-    /**
3583
-     * Outputs the the lesson archive header.
3584
-     *
3585
-     * @since  1.9.0
3586
-     * @return void
3587
-     */
3588
-    public function the_archive_header( ) {
3582
+	/**
3583
+	 * Outputs the the lesson archive header.
3584
+	 *
3585
+	 * @since  1.9.0
3586
+	 * @return void
3587
+	 */
3588
+	public function the_archive_header( ) {
3589 3589
 
3590
-        $before_html = '<header class="archive-header"><h1>';
3591
-        $after_html = '</h1></header>';
3592
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3590
+		$before_html = '<header class="archive-header"><h1>';
3591
+		$after_html = '</h1></header>';
3592
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3593 3593
 
3594
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3594
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3595 3595
 
3596
-    } // sensei_course_archive_header()
3596
+	} // sensei_course_archive_header()
3597 3597
 
3598
-    /**
3599
-     * Output the title for the single lesson page
3600
-     *
3601
-     * @global $post
3602
-     * @since 1.9.0
3603
-     */
3604
-    public static function the_title(){
3598
+	/**
3599
+	 * Output the title for the single lesson page
3600
+	 *
3601
+	 * @global $post
3602
+	 * @since 1.9.0
3603
+	 */
3604
+	public static function the_title(){
3605 3605
 
3606
-        global $post;
3606
+		global $post;
3607 3607
 
3608
-        ?>
3608
+		?>
3609 3609
         <header>
3610 3610
 
3611 3611
             <h1>
3612 3612
 
3613 3613
                 <?php
3614
-                /**
3615
-                 * Filter documented in class-sensei-messages.php the_title
3616
-                 */
3617
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3618
-                ?>
3614
+				/**
3615
+				 * Filter documented in class-sensei-messages.php the_title
3616
+				 */
3617
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3618
+				?>
3619 3619
 
3620 3620
             </h1>
3621 3621
 
@@ -3623,68 +3623,68 @@  discard block
 block discarded – undo
3623 3623
 
3624 3624
         <?php
3625 3625
 
3626
-    }//the_title
3626
+	}//the_title
3627 3627
 
3628
-    /**
3629
-     * Flush the rewrite rules for a lesson post type
3630
-     *
3631
-     * @since 1.9.0
3632
-     *
3633
-     * @param $post_id
3634
-     */
3635
-    public static function flush_rewrite_rules( $post_id ){
3628
+	/**
3629
+	 * Flush the rewrite rules for a lesson post type
3630
+	 *
3631
+	 * @since 1.9.0
3632
+	 *
3633
+	 * @param $post_id
3634
+	 */
3635
+	public static function flush_rewrite_rules( $post_id ){
3636 3636
 
3637
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3637
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3638 3638
 
3639
-            return;
3639
+			return;
3640 3640
 
3641
-        }
3641
+		}
3642 3642
 
3643 3643
 
3644
-        if( 'lesson' == get_post_type( $post_id )  ){
3644
+		if( 'lesson' == get_post_type( $post_id )  ){
3645 3645
 
3646
-            Sensei()->initiate_rewrite_rules_flush();
3646
+			Sensei()->initiate_rewrite_rules_flush();
3647 3647
 
3648
-        }
3648
+		}
3649 3649
 
3650
-    }
3650
+	}
3651 3651
 
3652
-    /**
3653
-     * Output the quiz specific buttons and messaging on the single lesson page
3654
-     *
3655
-     *
3656
-     * @since 1.0.0 moved here from frontend class
3657
-     *
3658
-     * @param int $lesson_id
3659
-     * @param int $user_id
3660
-     */
3661
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3652
+	/**
3653
+	 * Output the quiz specific buttons and messaging on the single lesson page
3654
+	 *
3655
+	 *
3656
+	 * @since 1.0.0 moved here from frontend class
3657
+	 *
3658
+	 * @param int $lesson_id
3659
+	 * @param int $user_id
3660
+	 */
3661
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3662 3662
 
3663 3663
 
3664
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3665
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3666
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3667
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3668
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3669
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3670
-        $show_actions              = is_user_logged_in() ? true : false;
3664
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3665
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3666
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3667
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3668
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3669
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3670
+		$show_actions              = is_user_logged_in() ? true : false;
3671 3671
 
3672
-        if( intval( $lesson_prerequisite ) > 0 ) {
3672
+		if( intval( $lesson_prerequisite ) > 0 ) {
3673 3673
 
3674
-            // If the user hasn't completed the prereq then hide the current actions
3675
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3674
+			// If the user hasn't completed the prereq then hide the current actions
3675
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3676 3676
 
3677
-        }
3678
-        ?>
3677
+		}
3678
+		?>
3679 3679
 
3680 3680
         <footer>
3681 3681
 
3682 3682
             <?php
3683
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3683
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3684 3684
 
3685
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3686
-                if( $has_quiz_questions ) {
3687
-                    ?>
3685
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3686
+				if( $has_quiz_questions ) {
3687
+					?>
3688 3688
 
3689 3689
                     <p>
3690 3690
 
@@ -3699,87 +3699,87 @@  discard block
 block discarded – undo
3699 3699
                     </p>
3700 3700
 
3701 3701
                     <?php
3702
-                }
3702
+				}
3703 3703
 
3704
-            } // End If Statement
3704
+			} // End If Statement
3705 3705
 
3706
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3706
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3707 3707
 
3708
-                sensei_complete_lesson_button();
3708
+				sensei_complete_lesson_button();
3709 3709
 
3710
-            } elseif( $show_actions ) {
3710
+			} elseif( $show_actions ) {
3711 3711
 
3712
-                sensei_reset_lesson_button();
3712
+				sensei_reset_lesson_button();
3713 3713
 
3714
-            } // End If Statement
3715
-            ?>
3714
+			} // End If Statement
3715
+			?>
3716 3716
 
3717 3717
         </footer>
3718 3718
 
3719 3719
         <?php
3720
-    } // End sensei_lesson_quiz_meta()
3720
+	} // End sensei_lesson_quiz_meta()
3721 3721
 
3722
-    /**
3723
-     * Show the lesson comments. This should be used in the loop.
3724
-     *
3725
-     * @since 1.9.0
3726
-     */
3727
-    public static function output_comments(){
3722
+	/**
3723
+	 * Show the lesson comments. This should be used in the loop.
3724
+	 *
3725
+	 * @since 1.9.0
3726
+	 */
3727
+	public static function output_comments(){
3728 3728
 
3729
-        if( ! is_user_logged_in() ){
3730
-            return;
3731
-        }
3729
+		if( ! is_user_logged_in() ){
3730
+			return;
3731
+		}
3732 3732
 
3733
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3734
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3735
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3736
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3733
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3734
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3735
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3736
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3737 3737
 
3738
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3738
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3739 3739
 
3740
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3740
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3741 3741
 
3742
-            comments_template();
3742
+			comments_template();
3743 3743
 
3744
-        } // End If Statement
3744
+		} // End If Statement
3745 3745
 
3746
-    } //output_comments
3746
+	} //output_comments
3747 3747
 
3748
-    /**
3749
-     * Display the leeson quiz status if it should be shown
3750
-     *
3751
-     * @param int $lesson_id defaults to the global lesson id
3752
-     * @param int $user_id defaults to the current user id
3753
-     *
3754
-     * @since 1.9.0
3755
-     */
3756
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3748
+	/**
3749
+	 * Display the leeson quiz status if it should be shown
3750
+	 *
3751
+	 * @param int $lesson_id defaults to the global lesson id
3752
+	 * @param int $user_id defaults to the current user id
3753
+	 *
3754
+	 * @since 1.9.0
3755
+	 */
3756
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3757 3757
 
3758
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3759
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3760
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3761
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3762
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3758
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3759
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3760
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3761
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3762
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3763 3763
 
3764 3764
 
3765
-        if ( $quiz_id && is_user_logged_in()
3766
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3765
+		if ( $quiz_id && is_user_logged_in()
3766
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3767 3767
 
3768
-            $no_quiz_count = 0;
3769
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3768
+			$no_quiz_count = 0;
3769
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3770 3770
 
3771
-            // Display lesson quiz status message
3772
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3773
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3774
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3775
-                if( $has_quiz_questions ) {
3776
-                   // echo $status['extra'];
3777
-                } // End If Statement
3778
-            } // End If Statement
3771
+			// Display lesson quiz status message
3772
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3773
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3774
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3775
+				if( $has_quiz_questions ) {
3776
+				   // echo $status['extra'];
3777
+				} // End If Statement
3778
+			} // End If Statement
3779 3779
 
3780
-        }
3780
+		}
3781 3781
 
3782
-    }
3782
+	}
3783 3783
 
3784 3784
 } // End Class
3785 3785
 
Please login to merge, or discard this patch.
includes/class-sensei-settings-api.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -796,7 +796,7 @@
 block discarded – undo
796 796
 	 * Return an array of field types expecting an array value returned.
797 797
 	 * @access protected
798 798
 	 * @since  1.0.0
799
-	 * @return array
799
+	 * @return string[]
800 800
 	 */
801 801
 	protected function get_array_field_types () {
802 802
 		return array( 'multicheck' );
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function register_hook_listener() {
59 59
 
60
-        add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 );
60
+		add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 );
61 61
 		add_action( 'admin_init', array( $this, 'settings_fields' ) );
62 62
 		add_action( 'init', array( $this, 'general_init' ) );
63 63
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 	 * @return void
354 354
 	 */
355 355
 	public function settings_errors () {
356
-        settings_errors( $this->token . '-errors' );
356
+		settings_errors( $this->token . '-errors' );
357 357
 	} // End settings_errors()
358 358
 
359 359
 	/**
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 		echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n";
420 420
 		if ( $has_description ) {
421 421
 			echo wp_kses( $args['data']['description'], array( 'a' => array(
422
-																	        'href' => array(),
423
-																	        'title' => array()
424
-																	    )
422
+																			'href' => array(),
423
+																			'title' => array()
424
+																		)
425 425
 															)
426 426
 						) . '</label>' . "\n";
427 427
 		}
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 	 */
811 811
 	public function enqueue_scripts () {
812 812
 
813
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
813
+		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
814 814
 
815 815
 		wp_enqueue_script( 'farbtastic' );
816 816
 		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version );
Please login to merge, or discard this patch.
Spacing   +227 added lines, -227 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
  * A settings API (wrapping the WordPress Settings API).
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @access public
32 32
 	 * @since  1.0.0
33 33
 	 */
34
-	public function __construct () {
34
+	public function __construct() {
35 35
 
36 36
 		$this->token = 'woothemes-sensei-settings';
37 37
 		$this->page_slug = 'woothemes-sensei-settings-api';
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function register_hook_listener() {
59 59
 
60
-        add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 );
61
-		add_action( 'admin_init', array( $this, 'settings_fields' ) );
62
-		add_action( 'init', array( $this, 'general_init' ) );
60
+        add_action('admin_menu', array($this, 'register_settings_screen'), 60);
61
+		add_action('admin_init', array($this, 'settings_fields'));
62
+		add_action('init', array($this, 'general_init'));
63 63
 
64 64
 	} // End setup_settings()
65 65
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 		$this->init_sections();
74 74
 		$this->init_fields();
75 75
 		$this->get_settings();
76
-		if ( $this->has_tabs == true ) {
76
+		if ($this->has_tabs == true) {
77 77
 			$this->create_tabs();
78 78
 		} // End If Statement
79 79
 	} // End general_init()
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @since  1.0.0
85 85
 	 * @return void
86 86
 	 */
87
-	public function init_sections () {
87
+	public function init_sections() {
88 88
 		// Override this function in your class and assign the array of sections to $this->sections.
89
-		_e( 'Override init_sections() in your class.', 'woothemes-sensei' );
89
+		_e('Override init_sections() in your class.', 'woothemes-sensei');
90 90
 	} // End init_sections()
91 91
 
92 92
 	/**
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	 * @since  1.0.0
96 96
 	 * @return void
97 97
 	 */
98
-	public function init_fields () {
98
+	public function init_fields() {
99 99
 		// Override this function in your class and assign the array of sections to $this->fields.
100
-		_e( 'Override init_fields() in your class.', 'woothemes-sensei' );
100
+		_e('Override init_fields() in your class.', 'woothemes-sensei');
101 101
 	} // End init_fields()
102 102
 
103 103
 	/**
@@ -106,34 +106,34 @@  discard block
 block discarded – undo
106 106
 	 * @since  1.1.0
107 107
 	 * @return void
108 108
 	 */
109
-	public function settings_tabs () {
109
+	public function settings_tabs() {
110 110
 
111
-		if ( ! $this->has_tabs ) { return; }
111
+		if ( ! $this->has_tabs) { return; }
112 112
 
113
-		if ( count( $this->tabs ) > 0 ) {
113
+		if (count($this->tabs) > 0) {
114 114
 			$html = '';
115 115
 
116
-			$html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n";
116
+			$html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">'."\n";
117 117
 
118 118
 			$sections = array(
119
-						'all' => array( 'href' => '#all', 'name' => __( 'All', 'woothemes-sensei' ), 'class' => 'current all tab' )
119
+						'all' => array('href' => '#all', 'name' => __('All', 'woothemes-sensei'), 'class' => 'current all tab')
120 120
 					);
121 121
 
122
-			foreach ( $this->tabs as $k => $v ) {
123
-				$sections[$k] = array( 'href' => '#' . esc_attr( $k ), 'name' => esc_attr( $v['name'] ), 'class' => 'tab' );
122
+			foreach ($this->tabs as $k => $v) {
123
+				$sections[$k] = array('href' => '#'.esc_attr($k), 'name' => esc_attr($v['name']), 'class' => 'tab');
124 124
 			}
125 125
 
126 126
 			$count = 1;
127
-			foreach ( $sections as $k => $v ) {
127
+			foreach ($sections as $k => $v) {
128 128
 				$count++;
129
-				$html .= '<li><a href="' . $v['href'] . '"';
130
-				if ( isset( $v['class'] ) && ( $v['class'] != '' ) ) { $html .= ' class="' . esc_attr( $v['class'] ) . '"'; }
131
-				$html .= '>' . esc_attr( $v['name'] ) . '</a>';
132
-				if ( $count <= count( $sections ) ) { $html .= ' | '; }
133
-				$html .= '</li>' . "\n";
129
+				$html .= '<li><a href="'.$v['href'].'"';
130
+				if (isset($v['class']) && ($v['class'] != '')) { $html .= ' class="'.esc_attr($v['class']).'"'; }
131
+				$html .= '>'.esc_attr($v['name']).'</a>';
132
+				if ($count <= count($sections)) { $html .= ' | '; }
133
+				$html .= '</li>'."\n";
134 134
 			}
135 135
 
136
-			$html .= '</ul><div class="clear"></div>' . "\n";
136
+			$html .= '</ul><div class="clear"></div>'."\n";
137 137
 
138 138
 			echo $html;
139 139
 		}
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 	 * @since  1.1.0
146 146
 	 * @return void
147 147
 	 */
148
-	private function create_tabs () {
149
-		if ( count( $this->sections ) > 0 ) {
148
+	private function create_tabs() {
149
+		if (count($this->sections) > 0) {
150 150
 			$tabs = array();
151
-			foreach ( $this->sections as $k => $v ) {
151
+			foreach ($this->sections as $k => $v) {
152 152
 				$tabs[$k] = $v;
153 153
 			}
154 154
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	 * @since  1.0.0
163 163
 	 * @return void
164 164
 	 */
165
-	public function create_sections () {
166
-		if ( count( $this->sections ) > 0 ) {
167
-			foreach ( $this->sections as $k => $v ) {
168
-				add_settings_section( $k, $v['name'], array( $this, 'section_description' ), $this->token );
165
+	public function create_sections() {
166
+		if (count($this->sections) > 0) {
167
+			foreach ($this->sections as $k => $v) {
168
+				add_settings_section($k, $v['name'], array($this, 'section_description'), $this->token);
169 169
 			}
170 170
 		}
171 171
 	} // End create_sections()
@@ -176,18 +176,18 @@  discard block
 block discarded – undo
176 176
 	 * @since  1.0.0
177 177
 	 * @return void
178 178
 	 */
179
-	public function create_fields () {
180
-		if ( count( $this->sections ) > 0 ) {
179
+	public function create_fields() {
180
+		if (count($this->sections) > 0) {
181 181
 			// $this->parse_fields( $this->fields );
182 182
 
183
-			foreach ( $this->fields as $k => $v ) {
184
-				$method = $this->determine_method( $v, 'form' );
183
+			foreach ($this->fields as $k => $v) {
184
+				$method = $this->determine_method($v, 'form');
185 185
 				$name = $v['name'];
186
-				if ( $v['type'] == 'info' ) { $name = ''; }
187
-				add_settings_field( $k, $name, $method, $this->token, $v['section'], array( 'key' => $k, 'data' => $v ) );
186
+				if ($v['type'] == 'info') { $name = ''; }
187
+				add_settings_field($k, $name, $method, $this->token, $v['section'], array('key' => $k, 'data' => $v));
188 188
 
189 189
 				// Let the API know that we have a colourpicker field.
190
-				if ( $v['type'] == 'range' && $this->has_range == false ) { $this->has_range = true; }
190
+				if ($v['type'] == 'range' && $this->has_range == false) { $this->has_range = true; }
191 191
 			}
192 192
 		}
193 193
 	} // End create_fields()
@@ -199,43 +199,43 @@  discard block
 block discarded – undo
199 199
 	 * @param  array $data
200 200
 	 * @return callable,  array or string
201 201
 	 */
202
-	protected function determine_method ( $data, $type = 'form' ) {
202
+	protected function determine_method($data, $type = 'form') {
203 203
 		$method = '';
204 204
 
205
-		if ( ! in_array( $type, array( 'form', 'validate', 'check' ) ) ) { return; }
205
+		if ( ! in_array($type, array('form', 'validate', 'check'))) { return; }
206 206
 
207 207
 		// Check for custom functions.
208
-		if ( isset( $data[$type] ) ) {
209
-			if ( function_exists( $data[$type] ) ) {
208
+		if (isset($data[$type])) {
209
+			if (function_exists($data[$type])) {
210 210
 				$method = $data[$type];
211 211
 			}
212 212
 
213
-			if ( $method == '' && method_exists( $this, $data[$type] ) ) {
214
-				if ( $type == 'form' ) {
215
-					$method = array( $this, $data[$type] );
213
+			if ($method == '' && method_exists($this, $data[$type])) {
214
+				if ($type == 'form') {
215
+					$method = array($this, $data[$type]);
216 216
 				} else {
217 217
 					$method = $data[$type];
218 218
 				}
219 219
 			}
220 220
 		}
221 221
 
222
-		if ( $method == '' && method_exists ( $this, $type . '_field_' . $data['type'] ) ) {
223
-			if ( $type == 'form' ) {
224
-				$method = array( $this, $type . '_field_' . $data['type'] );
222
+		if ($method == '' && method_exists($this, $type.'_field_'.$data['type'])) {
223
+			if ($type == 'form') {
224
+				$method = array($this, $type.'_field_'.$data['type']);
225 225
 			} else {
226
-				$method = $type . '_field_' . $data['type'];
226
+				$method = $type.'_field_'.$data['type'];
227 227
 			}
228 228
 		}
229 229
 
230
-		if ( $method == '' && function_exists ( $this->token . '_' . $type . '_field_' . $data['type'] ) ) {
231
-			$method = $this->token . '_' . $type . '_field_' . $data['type'];
230
+		if ($method == '' && function_exists($this->token.'_'.$type.'_field_'.$data['type'])) {
231
+			$method = $this->token.'_'.$type.'_field_'.$data['type'];
232 232
 		}
233 233
 
234
-		if ( $method == '' ) {
235
-			if ( $type == 'form' ) {
236
-				$method = array( $this, $type . '_field_text' );
234
+		if ($method == '') {
235
+			if ($type == 'form') {
236
+				$method = array($this, $type.'_field_text');
237 237
 			} else {
238
-				$method = $type . '_field_text';
238
+				$method = $type.'_field_text';
239 239
 			}
240 240
 		}
241 241
 
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 	 * @param  array $fields
250 250
 	 * @return void
251 251
 	 */
252
-	public function parse_fields ( $fields ) {
253
-		foreach ( $fields as $k => $v ) {
254
-			if ( isset( $v['section'] ) && ( $v['section'] != '' ) && ( isset( $this->sections[$v['section']] ) ) ) {
255
-				if ( ! isset( $this->sections[$v['section']]['fields'] ) ) {
252
+	public function parse_fields($fields) {
253
+		foreach ($fields as $k => $v) {
254
+			if (isset($v['section']) && ($v['section'] != '') && (isset($this->sections[$v['section']]))) {
255
+				if ( ! isset($this->sections[$v['section']]['fields'])) {
256 256
 					$this->sections[$v['section']]['fields'] = array();
257 257
 				}
258 258
 
@@ -269,19 +269,19 @@  discard block
 block discarded – undo
269 269
 	 * @since 1.0.0
270 270
 	 * @return void
271 271
 	 */
272
-	public function register_settings_screen () {
272
+	public function register_settings_screen() {
273 273
 
274
-		if ( current_user_can( 'manage_sensei' ) ) {
275
-			$hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) );
274
+		if (current_user_can('manage_sensei')) {
275
+			$hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen'));
276 276
 
277 277
 			$this->hook = $hook;
278 278
 		}
279 279
 
280
-		if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
280
+		if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
281 281
 
282
-			add_action( 'admin_notices', array( $this, 'settings_errors' ) );
283
-			add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
284
-			add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
282
+			add_action('admin_notices', array($this, 'settings_errors'));
283
+			add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
284
+			add_action('admin_print_styles', array($this, 'enqueue_styles'));
285 285
 
286 286
 		}
287 287
 	} // End register_settings_screen()
@@ -292,21 +292,21 @@  discard block
 block discarded – undo
292 292
 	 * @since  1.0.0
293 293
 	 * @return void
294 294
 	 */
295
-	public function settings_screen () {
295
+	public function settings_screen() {
296 296
 
297 297
 ?>
298
-<div id="woothemes-sensei" class="wrap <?php echo esc_attr( $this->token ); ?>">
299
-	<?php screen_icon( 'woothemes-sensei' ); ?>
300
-	<h2><?php echo esc_html( $this->name ); ?><?php if ( '' != $this->settings_version ) { echo ' <span class="version">' . $this->settings_version . '</span>'; } ?></h2>
301
-	<p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
302
-	<?php do_action( 'settings_before_form' ); ?>
298
+<div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>">
299
+	<?php screen_icon('woothemes-sensei'); ?>
300
+	<h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { echo ' <span class="version">'.$this->settings_version.'</span>'; } ?></h2>
301
+	<p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
302
+	<?php do_action('settings_before_form'); ?>
303 303
 	<form action="options.php" method="post">
304 304
 		<?php $this->settings_tabs(); ?>
305
-		<?php settings_fields( $this->token ); ?>
306
-		<?php do_settings_sections( $this->token ); ?>
305
+		<?php settings_fields($this->token); ?>
306
+		<?php do_settings_sections($this->token); ?>
307 307
 		<?php submit_button(); ?>
308 308
 	</form>
309
-	<?php do_action( 'settings_after_form' ); ?>
309
+	<?php do_action('settings_after_form'); ?>
310 310
 </div><!--/#woothemes-sensei-->
311 311
 <?php
312 312
 	} // End settings_screen()
@@ -317,16 +317,16 @@  discard block
 block discarded – undo
317 317
 	 * @since  1.0.0
318 318
 	 * @return array
319 319
 	 */
320
-	public function get_settings () {
321
-		if ( ! is_array( $this->settings ) ) {
322
-			$this->settings = get_option( $this->token, array() );
320
+	public function get_settings() {
321
+		if ( ! is_array($this->settings)) {
322
+			$this->settings = get_option($this->token, array());
323 323
 		}
324 324
 
325
-		foreach ( $this->fields as $k => $v ) {
326
-			if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) {
325
+		foreach ($this->fields as $k => $v) {
326
+			if ( ! isset($this->settings[$k]) && isset($v['default'])) {
327 327
 				$this->settings[$k] = $v['default'];
328 328
 			}
329
-			if ( $v['type'] == 'checkbox' && $this->settings[$k] != true ) {
329
+			if ($v['type'] == 'checkbox' && $this->settings[$k] != true) {
330 330
 				$this->settings[$k] = 0;
331 331
 			}
332 332
 		}
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
 	 * @since  1.0.0
341 341
 	 * @return void
342 342
 	 */
343
-	public function settings_fields () {
344
-		register_setting( $this->token, $this->token, array( $this, 'validate_fields' ) );
343
+	public function settings_fields() {
344
+		register_setting($this->token, $this->token, array($this, 'validate_fields'));
345 345
 		$this->create_sections();
346 346
 		$this->create_fields();
347 347
 	} // End settings_fields()
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
 	 * @since  1.0.0
353 353
 	 * @return void
354 354
 	 */
355
-	public function settings_errors () {
356
-        settings_errors( $this->token . '-errors' );
355
+	public function settings_errors() {
356
+        settings_errors($this->token.'-errors');
357 357
 	} // End settings_errors()
358 358
 
359 359
 	/**
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 * @since  1.0.0
363 363
 	 * @return void
364 364
 	 */
365
-	public function section_description ( $section ) {
366
-		if ( isset( $this->sections[$section['id']]['description'] ) ) {
367
-			echo wpautop( $this->sections[$section['id']]['description'] );
365
+	public function section_description($section) {
366
+		if (isset($this->sections[$section['id']]['description'])) {
367
+			echo wpautop($this->sections[$section['id']]['description']);
368 368
 		}
369 369
 	} // End section_description_main()
370 370
 
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
 	 * @param  array $args
376 376
 	 * @return void
377 377
 	 */
378
-	public function form_field_text ( $args ) {
378
+	public function form_field_text($args) {
379 379
 		$options = $this->get_settings();
380 380
 
381
-		echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n";
382
-		if ( isset( $args['data']['description'] ) ) {
383
-			echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n";
381
+		echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" value="'.esc_attr($options[$args['key']]).'" />'."\n";
382
+		if (isset($args['data']['description'])) {
383
+			echo '<span class="description">'.$args['data']['description'].'</span>'."\n";
384 384
 		}
385 385
 	} // End form_field_text()
386 386
 
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 	 * @param  array $args
392 392
 	 * @return void
393 393
 	 */
394
-	public function form_field_color ( $args ) {
394
+	public function form_field_color($args) {
395 395
 		$options = $this->get_settings();
396 396
 
397
-		echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" class="color" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n";
397
+		echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" class="color" value="'.esc_attr($options[$args['key']]).'" />'."\n";
398 398
 		echo '<div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div>';
399
-		if ( isset( $args['data']['description'] ) ) {
400
-			echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n";
399
+		if (isset($args['data']['description'])) {
400
+			echo '<span class="description">'.$args['data']['description'].'</span>'."\n";
401 401
 		}
402 402
 	} // End form_field_text()
403 403
 
@@ -408,22 +408,22 @@  discard block
 block discarded – undo
408 408
 	 * @param  array $args
409 409
 	 * @return void
410 410
 	 */
411
-	public function form_field_checkbox ( $args ) {
411
+	public function form_field_checkbox($args) {
412 412
 		$options = $this->get_settings();
413 413
 
414 414
 		$has_description = false;
415
-		if ( isset( $args['data']['description'] ) ) {
415
+		if (isset($args['data']['description'])) {
416 416
 			$has_description = true;
417
-			echo '<label for="' . esc_attr( $args['key'] ) . '">' . "\n";
417
+			echo '<label for="'.esc_attr($args['key']).'">'."\n";
418 418
 		}
419
-		echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n";
420
-		if ( $has_description ) {
421
-			echo wp_kses( $args['data']['description'], array( 'a' => array(
419
+		echo '<input id="'.$args['key'].'" name="'.$this->token.'['.esc_attr($args['key']).']" type="checkbox" value="1"'.checked(esc_attr($options[$args['key']]), '1', false).' />'."\n";
420
+		if ($has_description) {
421
+			echo wp_kses($args['data']['description'], array('a' => array(
422 422
 																	        'href' => array(),
423 423
 																	        'title' => array()
424 424
 																	    )
425 425
 															)
426
-						) . '</label>' . "\n";
426
+						).'</label>'."\n";
427 427
 		}
428 428
 	} // End form_field_checkbox()
429 429
 
@@ -434,12 +434,12 @@  discard block
 block discarded – undo
434 434
 	 * @param  array $args
435 435
 	 * @return void
436 436
 	 */
437
-	public function form_field_textarea ( $args ) {
437
+	public function form_field_textarea($args) {
438 438
 		$options = $this->get_settings();
439 439
 
440
-		echo '<textarea id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" cols="42" rows="5">' . esc_html( $options[$args['key']] ) . '</textarea>' . "\n";
441
-		if ( isset( $args['data']['description'] ) ) {
442
-			echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
440
+		echo '<textarea id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" cols="42" rows="5">'.esc_html($options[$args['key']]).'</textarea>'."\n";
441
+		if (isset($args['data']['description'])) {
442
+			echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
443 443
 		}
444 444
 	} // End form_field_textarea()
445 445
 
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
 	 * @param  array $args
451 451
 	 * @return void
452 452
 	 */
453
-	public function form_field_select ( $args ) {
453
+	public function form_field_select($args) {
454 454
 		$options = $this->get_settings();
455 455
 
456
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
456
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
457 457
 			$html = '';
458
-			$html .= '<select class="" id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']">' . "\n";
459
-				foreach ( $args['data']['options'] as $k => $v ) {
460
-					$html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n";
458
+			$html .= '<select class="" id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']">'."\n";
459
+				foreach ($args['data']['options'] as $k => $v) {
460
+					$html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n";
461 461
 				}
462
-			$html .= '</select>' . "\n";
462
+			$html .= '</select>'."\n";
463 463
 			echo $html;
464 464
 
465
-			if ( isset( $args['data']['description'] ) ) {
466
-				echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
465
+			if (isset($args['data']['description'])) {
466
+				echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
467 467
 			}
468 468
 		}
469 469
 	} // End form_field_select()
@@ -475,18 +475,18 @@  discard block
 block discarded – undo
475 475
 	 * @param  array $args
476 476
 	 * @return void
477 477
 	 */
478
-	public function form_field_radio ( $args ) {
478
+	public function form_field_radio($args) {
479 479
 		$options = $this->get_settings();
480 480
 
481
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
481
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
482 482
 			$html = '';
483
-			foreach ( $args['data']['options'] as $k => $v ) {
484
-				$html .= '<input type="radio" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n";
483
+			foreach ($args['data']['options'] as $k => $v) {
484
+				$html .= '<input type="radio" name="'.$this->token.'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n";
485 485
 			}
486 486
 			echo $html;
487 487
 
488
-			if ( isset( $args['data']['description'] ) ) {
489
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
488
+			if (isset($args['data']['description'])) {
489
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
490 490
 			}
491 491
 		}
492 492
 	} // End form_field_radio()
@@ -498,28 +498,28 @@  discard block
 block discarded – undo
498 498
 	 * @param  array $args
499 499
 	 * @return void
500 500
 	 */
501
-	public function form_field_multicheck ( $args ) {
501
+	public function form_field_multicheck($args) {
502 502
 		$options = $this->get_settings();
503 503
 
504
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
505
-			$html = '<div class="multicheck-container" style="margin-bottom:10px;">' . "\n";
506
-			foreach ( $args['data']['options'] as $k => $v ) {
504
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
505
+			$html = '<div class="multicheck-container" style="margin-bottom:10px;">'."\n";
506
+			foreach ($args['data']['options'] as $k => $v) {
507 507
 				$checked = '';
508 508
 
509
-				if( isset( $options[ $args['key'] ] ) ) {
510
-					if ( in_array( $k, (array)$options[ $args['key'] ] ) ) { $checked = ' checked="checked"'; }
509
+				if (isset($options[$args['key']])) {
510
+					if (in_array($k, (array) $options[$args['key']])) { $checked = ' checked="checked"'; }
511 511
 				} else {
512
-					if ( in_array( $k, $args['data']['defaults'] ) ) { $checked = ' checked="checked"'; }
512
+					if (in_array($k, $args['data']['defaults'])) { $checked = ' checked="checked"'; }
513 513
 				}
514
-				$html .= '<label for="checkbox-' . esc_attr( $k ) . '">' . "\n";
515
-				$html .= '<input type="checkbox" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . '][]" class="multicheck multicheck-' . esc_attr( $args['key'] ) . '" value="' . esc_attr( $k ) . '" id="checkbox-' . esc_attr( $k ) . '" ' . $checked . ' /> ' . $v . "\n";
516
-				$html .= '</label><br />' . "\n";
514
+				$html .= '<label for="checkbox-'.esc_attr($k).'">'."\n";
515
+				$html .= '<input type="checkbox" name="'.esc_attr($this->token).'['.esc_attr($args['key']).'][]" class="multicheck multicheck-'.esc_attr($args['key']).'" value="'.esc_attr($k).'" id="checkbox-'.esc_attr($k).'" '.$checked.' /> '.$v."\n";
516
+				$html .= '</label><br />'."\n";
517 517
 			}
518
-			$html .= '</div>' . "\n";
518
+			$html .= '</div>'."\n";
519 519
 			echo $html;
520 520
 
521
-			if ( isset( $args['data']['description'] ) ) {
522
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
521
+			if (isset($args['data']['description'])) {
522
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
523 523
 			}
524 524
 		}
525 525
 	} // End form_field_multicheck()
@@ -531,20 +531,20 @@  discard block
 block discarded – undo
531 531
 	 * @param  array $args
532 532
 	 * @return void
533 533
 	 */
534
-	public function form_field_range ( $args ) {
534
+	public function form_field_range($args) {
535 535
 		$options = $this->get_settings();
536 536
 
537
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
537
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
538 538
 			$html = '';
539
-			$html .= '<select id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" class="range-input">' . "\n";
540
-				foreach ( $args['data']['options'] as $k => $v ) {
541
-					$html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n";
539
+			$html .= '<select id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" class="range-input">'."\n";
540
+				foreach ($args['data']['options'] as $k => $v) {
541
+					$html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n";
542 542
 				}
543
-			$html .= '</select>' . "\n";
543
+			$html .= '</select>'."\n";
544 544
 			echo $html;
545 545
 
546
-			if ( isset( $args['data']['description'] ) ) {
547
-				echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n";
546
+			if (isset($args['data']['description'])) {
547
+				echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n";
548 548
 			}
549 549
 		}
550 550
 	} // End form_field_range()
@@ -556,18 +556,18 @@  discard block
 block discarded – undo
556 556
 	 * @param  array $args
557 557
 	 * @return void
558 558
 	 */
559
-	public function form_field_images ( $args ) {
559
+	public function form_field_images($args) {
560 560
 		$options = $this->get_settings();
561 561
 
562
-		if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) {
562
+		if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) {
563 563
 			$html = '';
564
-			foreach ( $args['data']['options'] as $k => $v ) {
565
-				$html .= '<input type="radio" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n";
564
+			foreach ($args['data']['options'] as $k => $v) {
565
+				$html .= '<input type="radio" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n";
566 566
 			}
567 567
 			echo $html;
568 568
 
569
-			if ( isset( $args['data']['description'] ) ) {
570
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
569
+			if (isset($args['data']['description'])) {
570
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
571 571
 			}
572 572
 		}
573 573
 	} // End form_field_images()
@@ -579,19 +579,19 @@  discard block
 block discarded – undo
579 579
 	 * @param  array $args
580 580
 	 * @return void
581 581
 	 */
582
-	public function form_field_info ( $args ) {
582
+	public function form_field_info($args) {
583 583
 		$class = '';
584
-		if ( isset( $args['data']['class'] ) ) {
585
-			$class = ' ' . esc_attr( $args['data']['class'] );
584
+		if (isset($args['data']['class'])) {
585
+			$class = ' '.esc_attr($args['data']['class']);
586 586
 		}
587
-		$html = '<div id="' . $args['key'] . '" class="info-box' . $class . '">' . "\n";
588
-		if ( isset( $args['data']['name'] ) && ( $args['data']['name'] != '' ) ) {
589
-			$html .= '<h3 class="title">' . esc_html( $args['data']['name'] ) . '</h3>' . "\n";
587
+		$html = '<div id="'.$args['key'].'" class="info-box'.$class.'">'."\n";
588
+		if (isset($args['data']['name']) && ($args['data']['name'] != '')) {
589
+			$html .= '<h3 class="title">'.esc_html($args['data']['name']).'</h3>'."\n";
590 590
 		}
591
-		if ( isset( $args['data']['description'] ) && ( $args['data']['description'] != '' ) ) {
592
-			$html .= '<p>' . esc_html( $args['data']['description'] ) . '</p>' . "\n";
591
+		if (isset($args['data']['description']) && ($args['data']['description'] != '')) {
592
+			$html .= '<p>'.esc_html($args['data']['description']).'</p>'."\n";
593 593
 		}
594
-		$html .= '</div>' . "\n";
594
+		$html .= '</div>'."\n";
595 595
 
596 596
 		echo $html;
597 597
 	} // End form_field_info()
@@ -603,14 +603,14 @@  discard block
 block discarded – undo
603 603
 	 * @since  1.9.0
604 604
 	 * @param  array $args
605 605
 	 */
606
-	public function form_field_button( $args ) {
606
+	public function form_field_button($args) {
607 607
 		$options = $this->get_settings();
608 608
 
609
-		if ( isset( $args['data']['target'] ) && isset( $args['data']['label'] ) ) {
610
-			printf( '<a href="%s" class="button button-secondary">%s</a> ', esc_url( $args['data']['target'] ), esc_html( $args['data']['label'] ) );
609
+		if (isset($args['data']['target']) && isset($args['data']['label'])) {
610
+			printf('<a href="%s" class="button button-secondary">%s</a> ', esc_url($args['data']['target']), esc_html($args['data']['label']));
611 611
 
612
-			if ( isset( $args['data']['description'] ) ) {
613
-				echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n";
612
+			if (isset($args['data']['description'])) {
613
+				echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n";
614 614
 			}
615 615
 		}
616 616
 	} // End form_field_button()
@@ -624,23 +624,23 @@  discard block
 block discarded – undo
624 624
 	 * @uses   $this->parse_errors()
625 625
 	 * @return array $options
626 626
 	 */
627
-	public function validate_fields ( $input ) {
627
+	public function validate_fields($input) {
628 628
 		$options = $this->get_settings();
629 629
 
630
-		foreach ( $this->fields as $k => $v ) {
630
+		foreach ($this->fields as $k => $v) {
631 631
 			// Make sure checkboxes are present even when false.
632
-			if ( $v['type'] == 'checkbox' && ! isset( $input[$k] ) ) { $input[$k] = false; }
633
-			if ( $v['type'] == 'multicheck' && ! isset( $input[$k] ) ) { $input[$k] = false; }
632
+			if ($v['type'] == 'checkbox' && ! isset($input[$k])) { $input[$k] = false; }
633
+			if ($v['type'] == 'multicheck' && ! isset($input[$k])) { $input[$k] = false; }
634 634
 
635
-			if ( isset( $input[$k] ) ) {
635
+			if (isset($input[$k])) {
636 636
 				// Perform checks on required fields.
637
-				if ( isset( $v['required'] ) && ( $v['required'] == true ) ) {
638
-					if ( in_array( $v['type'], $this->get_array_field_types() ) && ( count( (array) $input[$k] ) <= 0 ) ) {
639
-						$this->add_error( $k, $v );
637
+				if (isset($v['required']) && ($v['required'] == true)) {
638
+					if (in_array($v['type'], $this->get_array_field_types()) && (count((array) $input[$k]) <= 0)) {
639
+						$this->add_error($k, $v);
640 640
 						continue;
641 641
 					} else {
642
-						if ( $input[$k] == '' ) {
643
-							$this->add_error( $k, $v );
642
+						if ($input[$k] == '') {
643
+							$this->add_error($k, $v);
644 644
 							continue;
645 645
 						}
646 646
 					}
@@ -649,28 +649,28 @@  discard block
 block discarded – undo
649 649
 				$value = $input[$k];
650 650
 
651 651
 				// Check if the field is valid.
652
-				$method = $this->determine_method( $v, 'check' );
652
+				$method = $this->determine_method($v, 'check');
653 653
 
654
-				if ( function_exists ( $method ) ) {
655
-					$is_valid = $method( $value );
654
+				if (function_exists($method)) {
655
+					$is_valid = $method($value);
656 656
 				} else {
657
-					if ( method_exists( $this, $method ) ) {
658
-						$is_valid = $this->$method( $value );
657
+					if (method_exists($this, $method)) {
658
+						$is_valid = $this->$method($value);
659 659
 					}
660 660
 				}
661 661
 
662
-				if ( ! $is_valid ) {
663
-					$this->add_error( $k, $v );
662
+				if ( ! $is_valid) {
663
+					$this->add_error($k, $v);
664 664
 					continue;
665 665
 				}
666 666
 
667
-				$method = $this->determine_method( $v, 'validate' );
667
+				$method = $this->determine_method($v, 'validate');
668 668
 
669
-				if ( function_exists ( $method ) ) {
670
-					$options[$k] = $method( $value );
669
+				if (function_exists($method)) {
670
+					$options[$k] = $method($value);
671 671
 				} else {
672
-					if ( method_exists( $this, $method ) ) {
673
-						$options[$k] = $this->$method( $value );
672
+					if (method_exists($this, $method)) {
673
+						$options[$k] = $this->$method($value);
674 674
 					}
675 675
 				}
676 676
 			}
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 	 * @param  string $input
689 689
 	 * @return string
690 690
 	 */
691
-	public function validate_field_text ( $input ) {
692
-		return trim( esc_attr( $input ) );
691
+	public function validate_field_text($input) {
692
+		return trim(esc_attr($input));
693 693
 	} // End validate_field_text()
694 694
 
695 695
 	/**
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
 	 * @param  string $input
700 700
 	 * @return string
701 701
 	 */
702
-	public function validate_field_checkbox ( $input ) {
703
-		if ( ! isset( $input ) ) {
702
+	public function validate_field_checkbox($input) {
703
+		if ( ! isset($input)) {
704 704
 			return 0;
705 705
 		} else {
706
-			return (bool)$input;
706
+			return (bool) $input;
707 707
 		}
708 708
 	} // End validate_field_checkbox()
709 709
 
@@ -714,10 +714,10 @@  discard block
 block discarded – undo
714 714
 	 * @param  string $input
715 715
 	 * @return string
716 716
 	 */
717
-	public function validate_field_multicheck ( $input ) {
717
+	public function validate_field_multicheck($input) {
718 718
 		$input = (array) $input;
719 719
 
720
-		$input = array_map( 'esc_attr', $input );
720
+		$input = array_map('esc_attr', $input);
721 721
 
722 722
 		return $input;
723 723
 	} // End validate_field_multicheck()
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
 	 * @param  string $input
730 730
 	 * @return string
731 731
 	 */
732
-	public function validate_field_range ( $input ) {
733
-		$input = number_format( floatval( $input ), 0 );
732
+	public function validate_field_range($input) {
733
+		$input = number_format(floatval($input), 0);
734 734
 
735 735
 		return $input;
736 736
 	} // End validate_field_range()
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $input
743 743
 	 * @return string
744 744
 	 */
745
-	public function validate_field_url ( $input ) {
746
-		return trim( esc_url( $input ) );
745
+	public function validate_field_url($input) {
746
+		return trim(esc_url($input));
747 747
 	} // End validate_field_url()
748 748
 
749 749
 	/**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @since  1.1.0
753 753
 	 * @return boolean Is the value valid?
754 754
 	 */
755
-	public function check_field_text ( $input ) {
755
+	public function check_field_text($input) {
756 756
 		$is_valid = true;
757 757
 
758 758
 		return $is_valid;
@@ -766,11 +766,11 @@  discard block
 block discarded – undo
766 766
 	 * @param  array $data
767 767
 	 * @return void
768 768
 	 */
769
-	protected function add_error ( $key, $data ) {
770
-		if ( isset( $data['error_message'] ) ) {
769
+	protected function add_error($key, $data) {
770
+		if (isset($data['error_message'])) {
771 771
 			$message = $data['error_message'];
772 772
 		} else {
773
-			$message = sprintf( __( '%s is a required field', 'woothemes-sensei' ), $data['name'] );
773
+			$message = sprintf(__('%s is a required field', 'woothemes-sensei'), $data['name']);
774 774
 		}
775 775
 		$this->errors[$key] = $message;
776 776
 	} // End add_error()
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	 * @since   1.0.0
782 782
 	 * @return  void
783 783
 	 */
784
-	protected function parse_errors () {
785
-		if ( count ( $this->errors ) > 0 ) {
786
-			foreach ( $this->errors as $k => $v ) {
787
-				add_settings_error( $this->token . '-errors', $k, $v, 'error' );
784
+	protected function parse_errors() {
785
+		if (count($this->errors) > 0) {
786
+			foreach ($this->errors as $k => $v) {
787
+				add_settings_error($this->token.'-errors', $k, $v, 'error');
788 788
 			}
789 789
 		} else {
790
-			$message = sprintf( __( '%s updated', 'woothemes-sensei' ), $this->name );
791
-			add_settings_error( $this->token . '-errors', $this->token, $message, 'updated' );
790
+			$message = sprintf(__('%s updated', 'woothemes-sensei'), $this->name);
791
+			add_settings_error($this->token.'-errors', $this->token, $message, 'updated');
792 792
 		}
793 793
 	} // End parse_errors()
794 794
 
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
 	 * @since  1.0.0
799 799
 	 * @return array
800 800
 	 */
801
-	protected function get_array_field_types () {
802
-		return array( 'multicheck' );
801
+	protected function get_array_field_types() {
802
+		return array('multicheck');
803 803
 	} // End get_array_field_types()
804 804
 
805 805
 	/**
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
 	 * @since  1.0.0
809 809
 	 * @return void
810 810
 	 */
811
-	public function enqueue_scripts () {
811
+	public function enqueue_scripts() {
812 812
 
813
-        $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
813
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
814 814
 
815
-		wp_enqueue_script( 'farbtastic' );
816
-		wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version );
815
+		wp_enqueue_script('farbtastic');
816
+		wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'farbtastic'), Sensei()->version);
817 817
 
818
-		if ( $this->has_range ) {
819
-			wp_enqueue_script( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/js/ranges' . $suffix . '.js' ), array( 'jquery-ui-slider' ), Sensei()->version );
818
+		if ($this->has_range) {
819
+			wp_enqueue_script('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/js/ranges'.$suffix.'.js'), array('jquery-ui-slider'), Sensei()->version);
820 820
 		}
821 821
 
822
-		wp_register_script( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/js/image-selectors' . $suffix . '.js' ), array( 'jquery' ), Sensei()->version );
822
+		wp_register_script('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/js/image-selectors'.$suffix.'.js'), array('jquery'), Sensei()->version);
823 823
 
824
-		if ( $this->has_imageselector ) {
825
-			wp_enqueue_script( 'woothemes-sensei-settings-imageselectors' );
824
+		if ($this->has_imageselector) {
825
+			wp_enqueue_script('woothemes-sensei-settings-imageselectors');
826 826
 		}
827 827
 
828 828
 	} // End enqueue_scripts()
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
 	 * @since  1.0.0
834 834
 	 * @return void
835 835
 	 */
836
-	public function enqueue_styles () {
836
+	public function enqueue_styles() {
837 837
 
838
-		wp_enqueue_style( $this->token . '-admin' );
838
+		wp_enqueue_style($this->token.'-admin');
839 839
 
840
-		wp_enqueue_style( 'farbtastic' );
841
-		wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), array( 'farbtastic' ), Sensei()->version );
840
+		wp_enqueue_style('farbtastic');
841
+		wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), array('farbtastic'), Sensei()->version);
842 842
 
843 843
 		$this->enqueue_field_styles();
844 844
 	} // End enqueue_styles()
@@ -849,16 +849,16 @@  discard block
 block discarded – undo
849 849
 	 * @since  1.0.0
850 850
 	 * @return void
851 851
 	 */
852
-	public function enqueue_field_styles () {
852
+	public function enqueue_field_styles() {
853 853
 
854
-		if ( $this->has_range ) {
855
-			wp_enqueue_style( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/css/ranges.css' ), '', Sensei()->version );
854
+		if ($this->has_range) {
855
+			wp_enqueue_style('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/css/ranges.css'), '', Sensei()->version);
856 856
 		}
857 857
 
858
-		wp_register_style( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/css/image-selectors.css' ), '', Sensei()->version );
858
+		wp_register_style('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/css/image-selectors.css'), '', Sensei()->version);
859 859
 
860
-		if ( $this->has_imageselector ) {
861
-			wp_enqueue_style( 'woothemes-sensei-settings-imageselectors' );
860
+		if ($this->has_imageselector) {
861
+			wp_enqueue_style('woothemes-sensei-settings-imageselectors');
862 862
 		}
863 863
 	} // End enqueue_field_styles()
864 864
 } // End Class
@@ -868,4 +868,4 @@  discard block
 block discarded – undo
868 868
  * @ignore only for backward compatibility
869 869
  * @since 1.9.0
870 870
  */
871
-class WooThemes_Sensei_Settings_API extends Sensei_Settings_API{}
871
+class WooThemes_Sensei_Settings_API extends Sensei_Settings_API {}
Please login to merge, or discard this patch.
includes/class-sensei-teacher.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      * @since 1.8.0
453 453
      * @access public
454 454
      * @parameters
455
-     * @return array $users user id array
455
+     * @return boolean $users user id array
456 456
      */
457 457
     public function update_course_lessons_author ( $course_id, $new_author  ){
458 458
 
@@ -841,8 +841,7 @@  discard block
 block discarded – undo
841 841
      * This function hooks into wp_insert_post
842 842
      *
843 843
      * @since 1.8.0
844
-     * @param int $course_id
845
-     * @return bool
844
+     * @return false|null
846 845
      */
847 846
     public function notify_admin_teacher_course_creation( $new_status, $old_status, $post ){
848 847
 
Please login to merge, or discard this patch.
Indentation   +1339 added lines, -1339 removed lines patch added patch discarded remove patch
@@ -12,251 +12,251 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Sensei_Teacher {
14 14
 
15
-    /**
16
-     * $teacher_role
17
-     *
18
-     * Keeps a reference to the teacher role object
19
-     *
20
-     * @access protected
21
-     * @since 1.8.0
22
-     */
23
-    protected $teacher_role;
24
-
25
-    /**
26
-     * $token
27
-     *
28
-     * Keeps a reference to the global sensei token
29
-     *
30
-     * @access protected
31
-     * @since 1.8.0
32
-     */
33
-    public  $token;
34
-
35
-    /**
36
-     * Sensei_Teacher::__constructor
37
-     *
38
-     * Constructor Function
39
-     *
40
-     * @since 1.8.0
41
-     * @access public
42
-     */
43
-    public function __construct ( ) {
44
-
45
-        add_action( 'add_meta_boxes', array( $this , 'add_teacher_meta_boxes' ) , 10, 2 );
46
-        add_action( 'save_post',  array( $this, 'save_teacher_meta_box' ) );
47
-        add_filter( 'parse_query', array( $this, 'limit_teacher_edit_screen_post_types' ));
48
-        add_filter( 'pre_get_posts', array( $this, 'course_analysis_teacher_access_limit' ) );
49
-        add_filter( 'wp_count_posts', array( $this, 'list_table_counts' ), 10, 3 );
50
-
51
-        add_action( 'pre_get_posts', array( $this, 'filter_queries' ) );
52
-
53
-        //filter the quiz submissions
54
-        add_filter( 'sensei_check_for_activity' , array( $this, 'filter_grading_activity_queries') );
55
-
56
-        //grading totals count only those belonging to the teacher
57
-        add_filter('sensei_count_statuses_args', array( $this, 'limit_grading_totals' ) );
58
-
59
-        // show the courses owned by a user on his author archive page
60
-        add_filter( 'pre_get_posts', array( $this, 'add_courses_to_author_archive' ) );
61
-
62
-        // notify admin when a teacher creates a course
63
-        add_action( 'transition_post_status',array( $this, 'notify_admin_teacher_course_creation' ), 10, 3 );
64
-
65
-        // limit the analysis view to only the users taking courses belong to this teacher
66
-        add_filter( 'sensei_analysis_overview_filter_users',array( $this, 'limit_analysis_learners' ) , 5, 1 );
67
-
68
-        // give teacher access to question post type
69
-        add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20, 2 );
70
-
71
-        // Teacher column on the courses list on the admin edit screen
72
-        add_filter('manage_edit-course_columns' , array( $this, 'course_column_heading'), 10,1 );
73
-        add_filter('manage_course_posts_custom_column' , array( $this, 'course_column_data'), 10,2 );
74
-
75
-        //admin edit messages query limit teacher
76
-        add_filter( 'pre_get_posts', array( $this, 'limit_edit_messages_query' ) );
77
-
78
-        //add filter by teacher on courses list
79
-        add_action( 'restrict_manage_posts', array( $this, 'course_teacher_filter_options' ) );
80
-        add_filter( 'request', array( $this, 'teacher_filter_query_modify' ) );
81
-
82
-        // Handle media library restrictions
83
-        add_filter( 'request', array( $this, 'restrict_media_library' ), 10, 1 );
84
-        add_filter( 'ajax_query_attachments_args', array( $this, 'restrict_media_library_modal' ), 10, 1 );
85
-
86
-        // update lesson owner to course teacher when saved
87
-        add_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
88
-
89
-        // If a Teacher logs in, redirect to /wp-admin/
90
-        add_filter( 'wp_login', array( $this, 'teacher_login_redirect') , 10, 2 );
91
-
92
-
93
-        add_action( 'admin_menu', array( $this, 'restrict_posts_menu_page'), 10);
94
-        add_filter('pre_get_comments',  array ($this, 'restrict_comment_moderation'), 10, 1);
95
-
96
-
97
-    } // end __constructor()
98
-
99
-    /**
100
-     * Sensei_Teacher::create_teacher_role
101
-     *
102
-     * This function checks if the role exist, if not it creates it.
103
-     * for the teacher role
104
-     *
105
-     * @since 1.8.0
106
-     * @access public
107
-     * @return void
108
-     */
109
-    public function create_role ( ) {
110
-
111
-        // check if the role exists
112
-        $this->teacher_role = get_role( 'teacher' );
113
-
114
-        // if the the teacher is not a valid WordPress role create it
115
-       if ( ! is_a( $this->teacher_role, 'WP_Role' ) ) {
116
-           // create the role
117
-           $this->teacher_role = add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ) );
118
-       }
119
-
120
-       // add the capabilities before returning
121
-        $this->add_capabilities();
122
-
123
-    }// end create_teacher_role
124
-
125
-    /**
126
-     * Sensei_Teacher::add_capabilities
127
-     *
128
-     * @since 1.8.0
129
-     * @access protected
130
-     */
131
-    protected function add_capabilities ( ) {
132
-
133
-        // if this is not a valid WP_Role object exit without adding anything
134
-        if(  ! is_a( $this->teacher_role, 'WP_Role' ) || empty( $this->teacher_role ) ) {
135
-            return;
136
-        }
137
-
138
-        /**
139
-         * Sensei teachers capabilities array filter
140
-         *
141
-         * These capabilities will be applied to the teacher role
142
-         * @param array $capabilities
143
-         * keys: (string) $cap_name => (bool) $grant
144
-         */
145
-        $caps = apply_filters( 'sensei_teacher_role_capabilities', array(
146
-            // General access rules
147
-            'read' => true,
148
-            'manage_sensei_grades' => true,
149
-            'moderate_comments'=> true,
150
-            'upload_files'	=> true,
151
-            'edit_files'	=> true,
152
-
153
-            //Lessons
154
-            'publish_lessons'	 => true,
155
-            'manage_lesson_categories'	 => true,
156
-            'edit_lessons'	 => true,
157
-            'edit_published_lessons'  => true,
158
-            'edit_private_lessons' => true,
159
-            'read_private_lessons' => true,
160
-            'delete_published_lessons' => true,
161
-
162
-            // Courses
163
-            'create_courses' => true,
164
-            'publish_courses'	 => false,
165
-            'manage_course_categories'	 => true,
166
-            'edit_courses'	 => true,
167
-            'edit_published_courses'  => true,
168
-            'edit_private_courses' => true,
169
-            'read_private_courses' => true,
170
-            'delete_published_courses' => true,
171
-
172
-            // Quiz
173
-            'publish_quizzes'	 => true,
174
-            'edit_quizzes'	 => true,
175
-            'edit_published_quizzes'  => true,
176
-            'edit_private_quizzes' => true,
177
-            'read_private_quizzes' => true,
178
-
179
-            // Questions
180
-            'publish_questions'	 => true,
181
-            'edit_questions'	 => true,
182
-            'edit_published_questions'  => true,
183
-            'edit_private_questions' => true,
184
-            'read_private_questions' => true,
185
-
186
-            //messages
187
-            'publish_sensei_messages'	 => true,
188
-            'edit_sensei_messages'	 => true,
189
-            'edit_published_sensei_messages'  => true,
190
-            'edit_private_sensei_messages' => true,
191
-            'read_private_sensei_messages' => true,
192
-
193
-            // Comments -
194
-            // Necessary cap so Teachers can moderate comments
195
-            // on their own lessons. We restrict access to other
196
-            // post types in $this->restrict_posts_menu_page()
197
-
198
-            'edit_posts' => true,
199
-
200
-        ));
201
-
202
-        foreach ( $caps as $cap => $grant ) {
203
-
204
-            // load the capability on to the teacher role
205
-            $this->teacher_role->add_cap($cap, $grant);
206
-
207
-        } // end for each
208
-
209
-    }// end add_cap
210
-
211
-    /**
212
-     * Sensei_Teacher::teacher_meta_box
213
-     *
214
-     * Add the teacher metabox to the course post type edit screen
215
-     *
216
-     * @since 1.8.0
217
-     * @access public
218
-     * @parameter string $post_type
219
-     * @parameter WP_Post $post
220
-     * @return void
221
-     */
222
-    public function add_teacher_meta_boxes ( $post ) {
223
-
224
-        if( !current_user_can('manage_options') ){
225
-            return;
226
-        }
227
-        add_meta_box( 'sensei-teacher',  __( 'Teacher' , 'woothemes-sensei'),  array( $this , 'teacher_meta_box_content' ),
228
-            'course',
229
-            'side',
230
-            'core'
231
-        );
232
-
233
-    } // end teacher_meta_box()
234
-
235
-    /**
236
-     * Sensei_Teacher::teacher_meta_box_content
237
-     *
238
-     * Render the teacher meta box markup
239
-     *
240
-     * @since 1.8.0
241
-     * @access public
242
-     * @parameters
243
-     */
244
-    public function teacher_meta_box_content ( $post ) {
245
-
246
-        // get the current author
247
-        $current_author = $post->post_author;
248
-
249
-        //get the users authorised to author courses
250
-        $users = $this->get_teachers_and_authors();
251
-
252
-    ?>
15
+	/**
16
+	 * $teacher_role
17
+	 *
18
+	 * Keeps a reference to the teacher role object
19
+	 *
20
+	 * @access protected
21
+	 * @since 1.8.0
22
+	 */
23
+	protected $teacher_role;
24
+
25
+	/**
26
+	 * $token
27
+	 *
28
+	 * Keeps a reference to the global sensei token
29
+	 *
30
+	 * @access protected
31
+	 * @since 1.8.0
32
+	 */
33
+	public  $token;
34
+
35
+	/**
36
+	 * Sensei_Teacher::__constructor
37
+	 *
38
+	 * Constructor Function
39
+	 *
40
+	 * @since 1.8.0
41
+	 * @access public
42
+	 */
43
+	public function __construct ( ) {
44
+
45
+		add_action( 'add_meta_boxes', array( $this , 'add_teacher_meta_boxes' ) , 10, 2 );
46
+		add_action( 'save_post',  array( $this, 'save_teacher_meta_box' ) );
47
+		add_filter( 'parse_query', array( $this, 'limit_teacher_edit_screen_post_types' ));
48
+		add_filter( 'pre_get_posts', array( $this, 'course_analysis_teacher_access_limit' ) );
49
+		add_filter( 'wp_count_posts', array( $this, 'list_table_counts' ), 10, 3 );
50
+
51
+		add_action( 'pre_get_posts', array( $this, 'filter_queries' ) );
52
+
53
+		//filter the quiz submissions
54
+		add_filter( 'sensei_check_for_activity' , array( $this, 'filter_grading_activity_queries') );
55
+
56
+		//grading totals count only those belonging to the teacher
57
+		add_filter('sensei_count_statuses_args', array( $this, 'limit_grading_totals' ) );
58
+
59
+		// show the courses owned by a user on his author archive page
60
+		add_filter( 'pre_get_posts', array( $this, 'add_courses_to_author_archive' ) );
61
+
62
+		// notify admin when a teacher creates a course
63
+		add_action( 'transition_post_status',array( $this, 'notify_admin_teacher_course_creation' ), 10, 3 );
64
+
65
+		// limit the analysis view to only the users taking courses belong to this teacher
66
+		add_filter( 'sensei_analysis_overview_filter_users',array( $this, 'limit_analysis_learners' ) , 5, 1 );
67
+
68
+		// give teacher access to question post type
69
+		add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20, 2 );
70
+
71
+		// Teacher column on the courses list on the admin edit screen
72
+		add_filter('manage_edit-course_columns' , array( $this, 'course_column_heading'), 10,1 );
73
+		add_filter('manage_course_posts_custom_column' , array( $this, 'course_column_data'), 10,2 );
74
+
75
+		//admin edit messages query limit teacher
76
+		add_filter( 'pre_get_posts', array( $this, 'limit_edit_messages_query' ) );
77
+
78
+		//add filter by teacher on courses list
79
+		add_action( 'restrict_manage_posts', array( $this, 'course_teacher_filter_options' ) );
80
+		add_filter( 'request', array( $this, 'teacher_filter_query_modify' ) );
81
+
82
+		// Handle media library restrictions
83
+		add_filter( 'request', array( $this, 'restrict_media_library' ), 10, 1 );
84
+		add_filter( 'ajax_query_attachments_args', array( $this, 'restrict_media_library_modal' ), 10, 1 );
85
+
86
+		// update lesson owner to course teacher when saved
87
+		add_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
88
+
89
+		// If a Teacher logs in, redirect to /wp-admin/
90
+		add_filter( 'wp_login', array( $this, 'teacher_login_redirect') , 10, 2 );
91
+
92
+
93
+		add_action( 'admin_menu', array( $this, 'restrict_posts_menu_page'), 10);
94
+		add_filter('pre_get_comments',  array ($this, 'restrict_comment_moderation'), 10, 1);
95
+
96
+
97
+	} // end __constructor()
98
+
99
+	/**
100
+	 * Sensei_Teacher::create_teacher_role
101
+	 *
102
+	 * This function checks if the role exist, if not it creates it.
103
+	 * for the teacher role
104
+	 *
105
+	 * @since 1.8.0
106
+	 * @access public
107
+	 * @return void
108
+	 */
109
+	public function create_role ( ) {
110
+
111
+		// check if the role exists
112
+		$this->teacher_role = get_role( 'teacher' );
113
+
114
+		// if the the teacher is not a valid WordPress role create it
115
+	   if ( ! is_a( $this->teacher_role, 'WP_Role' ) ) {
116
+		   // create the role
117
+		   $this->teacher_role = add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ) );
118
+	   }
119
+
120
+	   // add the capabilities before returning
121
+		$this->add_capabilities();
122
+
123
+	}// end create_teacher_role
124
+
125
+	/**
126
+	 * Sensei_Teacher::add_capabilities
127
+	 *
128
+	 * @since 1.8.0
129
+	 * @access protected
130
+	 */
131
+	protected function add_capabilities ( ) {
132
+
133
+		// if this is not a valid WP_Role object exit without adding anything
134
+		if(  ! is_a( $this->teacher_role, 'WP_Role' ) || empty( $this->teacher_role ) ) {
135
+			return;
136
+		}
137
+
138
+		/**
139
+		 * Sensei teachers capabilities array filter
140
+		 *
141
+		 * These capabilities will be applied to the teacher role
142
+		 * @param array $capabilities
143
+		 * keys: (string) $cap_name => (bool) $grant
144
+		 */
145
+		$caps = apply_filters( 'sensei_teacher_role_capabilities', array(
146
+			// General access rules
147
+			'read' => true,
148
+			'manage_sensei_grades' => true,
149
+			'moderate_comments'=> true,
150
+			'upload_files'	=> true,
151
+			'edit_files'	=> true,
152
+
153
+			//Lessons
154
+			'publish_lessons'	 => true,
155
+			'manage_lesson_categories'	 => true,
156
+			'edit_lessons'	 => true,
157
+			'edit_published_lessons'  => true,
158
+			'edit_private_lessons' => true,
159
+			'read_private_lessons' => true,
160
+			'delete_published_lessons' => true,
161
+
162
+			// Courses
163
+			'create_courses' => true,
164
+			'publish_courses'	 => false,
165
+			'manage_course_categories'	 => true,
166
+			'edit_courses'	 => true,
167
+			'edit_published_courses'  => true,
168
+			'edit_private_courses' => true,
169
+			'read_private_courses' => true,
170
+			'delete_published_courses' => true,
171
+
172
+			// Quiz
173
+			'publish_quizzes'	 => true,
174
+			'edit_quizzes'	 => true,
175
+			'edit_published_quizzes'  => true,
176
+			'edit_private_quizzes' => true,
177
+			'read_private_quizzes' => true,
178
+
179
+			// Questions
180
+			'publish_questions'	 => true,
181
+			'edit_questions'	 => true,
182
+			'edit_published_questions'  => true,
183
+			'edit_private_questions' => true,
184
+			'read_private_questions' => true,
185
+
186
+			//messages
187
+			'publish_sensei_messages'	 => true,
188
+			'edit_sensei_messages'	 => true,
189
+			'edit_published_sensei_messages'  => true,
190
+			'edit_private_sensei_messages' => true,
191
+			'read_private_sensei_messages' => true,
192
+
193
+			// Comments -
194
+			// Necessary cap so Teachers can moderate comments
195
+			// on their own lessons. We restrict access to other
196
+			// post types in $this->restrict_posts_menu_page()
197
+
198
+			'edit_posts' => true,
199
+
200
+		));
201
+
202
+		foreach ( $caps as $cap => $grant ) {
203
+
204
+			// load the capability on to the teacher role
205
+			$this->teacher_role->add_cap($cap, $grant);
206
+
207
+		} // end for each
208
+
209
+	}// end add_cap
210
+
211
+	/**
212
+	 * Sensei_Teacher::teacher_meta_box
213
+	 *
214
+	 * Add the teacher metabox to the course post type edit screen
215
+	 *
216
+	 * @since 1.8.0
217
+	 * @access public
218
+	 * @parameter string $post_type
219
+	 * @parameter WP_Post $post
220
+	 * @return void
221
+	 */
222
+	public function add_teacher_meta_boxes ( $post ) {
223
+
224
+		if( !current_user_can('manage_options') ){
225
+			return;
226
+		}
227
+		add_meta_box( 'sensei-teacher',  __( 'Teacher' , 'woothemes-sensei'),  array( $this , 'teacher_meta_box_content' ),
228
+			'course',
229
+			'side',
230
+			'core'
231
+		);
232
+
233
+	} // end teacher_meta_box()
234
+
235
+	/**
236
+	 * Sensei_Teacher::teacher_meta_box_content
237
+	 *
238
+	 * Render the teacher meta box markup
239
+	 *
240
+	 * @since 1.8.0
241
+	 * @access public
242
+	 * @parameters
243
+	 */
244
+	public function teacher_meta_box_content ( $post ) {
245
+
246
+		// get the current author
247
+		$current_author = $post->post_author;
248
+
249
+		//get the users authorised to author courses
250
+		$users = $this->get_teachers_and_authors();
251
+
252
+	?>
253 253
         <select name="sensei-course-teacher-author" class="sensei course teacher">
254 254
 
255 255
             <?php foreach ( $users as $user_id ) { ?>
256 256
 
257 257
                     <?php
258
-                        $user = get_user_by('id', $user_id);
259
-                    ?>
258
+						$user = get_user_by('id', $user_id);
259
+					?>
260 260
                     <option <?php selected(  $current_author , $user_id , true ); ?> value="<?php echo $user_id; ?>" >
261 261
                         <?php echo  $user->display_name; ?>
262 262
                     </option>
@@ -267,1289 +267,1289 @@  discard block
 block discarded – undo
267 267
 
268 268
         <?php
269 269
 
270
-    } // end render_teacher_meta_box()
271
-
272
-    /**
273
-     * Sensei_Teacher::get_teachers_and_authors
274
-     *
275
-     * Get a list of users who can author courses, lessons and quizes.
276
-     *
277
-     * @since 1.8.0
278
-     * @access public
279
-     * @parameters
280
-     * @return array $users user id array
281
-     */
282
-    public function get_teachers_and_authors ( ){
283
-
284
-        $author_query_args = array(
285
-            'blog_id'      => $GLOBALS['blog_id'],
286
-            'fields'       => 'any',
287
-            'who'          => 'authors'
288
-        );
289
-
290
-        $authors = get_users( $author_query_args );
291
-
292
-        $teacher_query_args = array(
293
-            'blog_id'      => $GLOBALS['blog_id'],
294
-            'fields'       => 'any',
295
-            'role'         => 'teacher',
296
-        );
297
-
298
-        $teachers = get_users( $teacher_query_args );
299
-
300
-        return  array_unique( array_merge( $teachers, $authors ) );
301
-
302
-    }// end get_teachers_and_authors
303
-
304
-    /**
305
-     * Sensei_Teacher::save_teacher_meta_box
306
-     *
307
-     * Save the new teacher / author to course and all lessons
308
-     *
309
-     * Hooked into admin_init
310
-     *
311
-     * @since 1.8.0
312
-     * @access public
313
-     * @parameters
314
-     * @return array $users user id array
315
-     */
316
-    public function save_teacher_meta_box ( $course_id ){
270
+	} // end render_teacher_meta_box()
271
+
272
+	/**
273
+	 * Sensei_Teacher::get_teachers_and_authors
274
+	 *
275
+	 * Get a list of users who can author courses, lessons and quizes.
276
+	 *
277
+	 * @since 1.8.0
278
+	 * @access public
279
+	 * @parameters
280
+	 * @return array $users user id array
281
+	 */
282
+	public function get_teachers_and_authors ( ){
283
+
284
+		$author_query_args = array(
285
+			'blog_id'      => $GLOBALS['blog_id'],
286
+			'fields'       => 'any',
287
+			'who'          => 'authors'
288
+		);
289
+
290
+		$authors = get_users( $author_query_args );
291
+
292
+		$teacher_query_args = array(
293
+			'blog_id'      => $GLOBALS['blog_id'],
294
+			'fields'       => 'any',
295
+			'role'         => 'teacher',
296
+		);
297
+
298
+		$teachers = get_users( $teacher_query_args );
299
+
300
+		return  array_unique( array_merge( $teachers, $authors ) );
301
+
302
+	}// end get_teachers_and_authors
303
+
304
+	/**
305
+	 * Sensei_Teacher::save_teacher_meta_box
306
+	 *
307
+	 * Save the new teacher / author to course and all lessons
308
+	 *
309
+	 * Hooked into admin_init
310
+	 *
311
+	 * @since 1.8.0
312
+	 * @access public
313
+	 * @parameters
314
+	 * @return array $users user id array
315
+	 */
316
+	public function save_teacher_meta_box ( $course_id ){
317 317
 
318
-        // check if this is a post from saving the teacher, if not exit early
319
-        if(! isset( $_POST[ 'sensei-course-teacher-author' ] ) || ! isset( $_POST['post_ID'] )  ){
320
-            return;
321
-        }
318
+		// check if this is a post from saving the teacher, if not exit early
319
+		if(! isset( $_POST[ 'sensei-course-teacher-author' ] ) || ! isset( $_POST['post_ID'] )  ){
320
+			return;
321
+		}
322 322
 
323
-        //don't fire this hook again
324
-        remove_action('save_post', array( $this, 'save_teacher_meta_box' ) );
323
+		//don't fire this hook again
324
+		remove_action('save_post', array( $this, 'save_teacher_meta_box' ) );
325 325
 
326
-        // get the current post object
327
-        $post = get_post( $course_id );
326
+		// get the current post object
327
+		$post = get_post( $course_id );
328 328
 
329
-        // get the current teacher/author
330
-        $current_author = absint( $post->post_author );
331
-        $new_author = absint( $_POST[ 'sensei-course-teacher-author' ] );
329
+		// get the current teacher/author
330
+		$current_author = absint( $post->post_author );
331
+		$new_author = absint( $_POST[ 'sensei-course-teacher-author' ] );
332 332
 
333
-        // loop through all post lessons to update their authors as well
334
-        $this->update_course_lessons_author( $course_id , $new_author );
333
+		// loop through all post lessons to update their authors as well
334
+		$this->update_course_lessons_author( $course_id , $new_author );
335 335
 
336
-        // do not do any processing if the selected author is the same as the current author
337
-        if( $current_author == $new_author ){
338
-            return;
339
-        }
336
+		// do not do any processing if the selected author is the same as the current author
337
+		if( $current_author == $new_author ){
338
+			return;
339
+		}
340 340
 
341
-        // save the course  author
342
-        $post_updates = array(
343
-            'ID' => $post->ID ,
344
-            'post_author' => $new_author
345
-        );
346
-        wp_update_post( $post_updates );
341
+		// save the course  author
342
+		$post_updates = array(
343
+			'ID' => $post->ID ,
344
+			'post_author' => $new_author
345
+		);
346
+		wp_update_post( $post_updates );
347 347
 
348
-        // ensure the the modules are update so that then new teacher has access to them
349
-        Sensei_Teacher::update_course_modules_author( $course_id, $new_author );
348
+		// ensure the the modules are update so that then new teacher has access to them
349
+		Sensei_Teacher::update_course_modules_author( $course_id, $new_author );
350 350
 
351
-        // notify the new teacher
352
-        $this->teacher_course_assigned_notification( $new_author, $course_id );
351
+		// notify the new teacher
352
+		$this->teacher_course_assigned_notification( $new_author, $course_id );
353 353
 
354
-    } // end save_teacher_meta_box
354
+	} // end save_teacher_meta_box
355 355
 
356
-    /**
357
-     * Update all the course terms set(selected) on the given course. Moving course term ownership to
358
-     * the new author. Making sure the course terms are maintained.
359
-     *
360
-     * This function also checks if terms are shared, with other courses
361
-     *
362
-     * @param $course_id
363
-     * @param $new_teacher_id
364
-     * @return void
365
-     */
366
-    public static function update_course_modules_author( $course_id ,$new_teacher_id ){
356
+	/**
357
+	 * Update all the course terms set(selected) on the given course. Moving course term ownership to
358
+	 * the new author. Making sure the course terms are maintained.
359
+	 *
360
+	 * This function also checks if terms are shared, with other courses
361
+	 *
362
+	 * @param $course_id
363
+	 * @param $new_teacher_id
364
+	 * @return void
365
+	 */
366
+	public static function update_course_modules_author( $course_id ,$new_teacher_id ){
367 367
 
368
-        if( empty( $course_id ) || empty( $new_teacher_id ) ){
369
-            return;
370
-        }
368
+		if( empty( $course_id ) || empty( $new_teacher_id ) ){
369
+			return;
370
+		}
371 371
 
372
-        $terms_selected_on_course = wp_get_object_terms( $course_id, 'module' );
372
+		$terms_selected_on_course = wp_get_object_terms( $course_id, 'module' );
373 373
 
374
-        if( empty( $terms_selected_on_course ) ){
375
-            return;
376
-        }
374
+		if( empty( $terms_selected_on_course ) ){
375
+			return;
376
+		}
377 377
 
378
-        foreach( $terms_selected_on_course as $term ){
378
+		foreach( $terms_selected_on_course as $term ){
379 379
 
380
-            $term_author = Sensei_Core_Modules::get_term_author( $term->slug );
381
-            if( $new_teacher_id != $term_author->ID  ){
380
+			$term_author = Sensei_Core_Modules::get_term_author( $term->slug );
381
+			if( $new_teacher_id != $term_author->ID  ){
382 382
 
383
-                $new_term = '';
383
+				$new_term = '';
384 384
 
385
-                //if the new teacher is admin first check to see if the term with this name already exists
386
-                if( user_can( $new_teacher_id, 'manage_options' ) ){
385
+				//if the new teacher is admin first check to see if the term with this name already exists
386
+				if( user_can( $new_teacher_id, 'manage_options' ) ){
387 387
 
388
-                    $slug_without_teacher_id = str_ireplace(' ', '-', trim( $term->name ) );
389
-                    $term_args = array( 'slug'=> $slug_without_teacher_id, 'hide_empty' => false, );
390
-                    $existing_admin_terms = get_terms( 'module', $term_args );
391
-                    if( !empty( $existing_admin_terms ) ){
392
-                        // insert it even if it exists
393
-                        $new_term = get_term( $existing_admin_terms[0]->term_id, 'module', ARRAY_A );
394
-                    }
395
-                }
388
+					$slug_without_teacher_id = str_ireplace(' ', '-', trim( $term->name ) );
389
+					$term_args = array( 'slug'=> $slug_without_teacher_id, 'hide_empty' => false, );
390
+					$existing_admin_terms = get_terms( 'module', $term_args );
391
+					if( !empty( $existing_admin_terms ) ){
392
+						// insert it even if it exists
393
+						$new_term = get_term( $existing_admin_terms[0]->term_id, 'module', ARRAY_A );
394
+					}
395
+				}
396 396
 
397
-                if( empty ( $new_term ) ){
397
+				if( empty ( $new_term ) ){
398 398
 
399
-                   //setup the new slug
400
-                   $new_author_term_slug =  $new_teacher_id . '-' . str_ireplace(' ', '-', trim( $term->name ) );
401
-
402
-                   // create new term and set it
403
-                   $new_term = wp_insert_term( $term->name,'module', array('slug'=> $new_author_term_slug )  );
404
-
405
-                }
399
+				   //setup the new slug
400
+				   $new_author_term_slug =  $new_teacher_id . '-' . str_ireplace(' ', '-', trim( $term->name ) );
401
+
402
+				   // create new term and set it
403
+				   $new_term = wp_insert_term( $term->name,'module', array('slug'=> $new_author_term_slug )  );
404
+
405
+				}
406 406
 
407 407
 
408 408
 
409
-                // if term exists
410
-                if( is_wp_error( $new_term ) && isset( $new_term->errors['term_exists'] ) ){
409
+				// if term exists
410
+				if( is_wp_error( $new_term ) && isset( $new_term->errors['term_exists'] ) ){
411 411
 
412
-                    $existing_term = get_term_by( 'slug', $new_author_term_slug, 'module');
413
-                    $term_id = $existing_term->term_id;
412
+					$existing_term = get_term_by( 'slug', $new_author_term_slug, 'module');
413
+					$term_id = $existing_term->term_id;
414 414
 
415
-                }else{
415
+				}else{
416 416
 
417
-                    // for a new term simply get the term from the returned value
418
-                    $term_id = $new_term['term_id'];
417
+					// for a new term simply get the term from the returned value
418
+					$term_id = $new_term['term_id'];
419 419
 
420
-                } // end if term exist
420
+				} // end if term exist
421 421
 
422
-                // set the terms selected on the course
423
-                wp_set_object_terms( $course_id, $term_id , 'module', true );
422
+				// set the terms selected on the course
423
+				wp_set_object_terms( $course_id, $term_id , 'module', true );
424 424
 
425
-                // remove old term
426
-                wp_remove_object_terms( $course_id, $term->term_id, 'module' );
425
+				// remove old term
426
+				wp_remove_object_terms( $course_id, $term->term_id, 'module' );
427 427
 
428
-                // update the lessons within the current module term
429
-                $lessons = Sensei()->course->course_lessons( $course_id );
430
-                foreach( $lessons as $lesson  ){
428
+				// update the lessons within the current module term
429
+				$lessons = Sensei()->course->course_lessons( $course_id );
430
+				foreach( $lessons as $lesson  ){
431 431
 
432
-                    if( has_term( $term->slug, 'module', $lesson ) ){
432
+					if( has_term( $term->slug, 'module', $lesson ) ){
433 433
 
434
-                        // add the new term, the false at the end says to replace all terms on this module
435
-                        // with the new term.
436
-                        wp_set_object_terms( $lesson->ID, $term_id , 'module', false );
437
-                        update_post_meta( $lesson->ID, '_order_module_' . intval( $term_id ), 0 );
438
-                    }
434
+						// add the new term, the false at the end says to replace all terms on this module
435
+						// with the new term.
436
+						wp_set_object_terms( $lesson->ID, $term_id , 'module', false );
437
+						update_post_meta( $lesson->ID, '_order_module_' . intval( $term_id ), 0 );
438
+					}
439 439
 
440
-                }// end for each
440
+				}// end for each
441 441
 
442
-            }
443
-        }
442
+			}
443
+		}
444 444
 
445
-    }// end update_course_module_terms_author
445
+	}// end update_course_module_terms_author
446 446
 
447
-    /**
448
-     * Sensei_Teacher::update_course_lessons_author
449
-     *
450
-     * Update all course lessons and their quiz with a new author
451
-     *
452
-     * @since 1.8.0
453
-     * @access public
454
-     * @parameters
455
-     * @return array $users user id array
456
-     */
457
-    public function update_course_lessons_author ( $course_id, $new_author  ){
447
+	/**
448
+	 * Sensei_Teacher::update_course_lessons_author
449
+	 *
450
+	 * Update all course lessons and their quiz with a new author
451
+	 *
452
+	 * @since 1.8.0
453
+	 * @access public
454
+	 * @parameters
455
+	 * @return array $users user id array
456
+	 */
457
+	public function update_course_lessons_author ( $course_id, $new_author  ){
458 458
 
459 459
 
460
-        if( empty( $course_id ) || empty( $new_author ) ){
461
-            return false;
462
-        }
460
+		if( empty( $course_id ) || empty( $new_author ) ){
461
+			return false;
462
+		}
463 463
 
464
-        //get a list of course lessons
465
-        $lessons = Sensei()->course->course_lessons( $course_id );
464
+		//get a list of course lessons
465
+		$lessons = Sensei()->course->course_lessons( $course_id );
466 466
 
467
-        if( empty( $lessons )  ||  ! is_array( $lessons )  ){
468
-            return false;
469
-        }
467
+		if( empty( $lessons )  ||  ! is_array( $lessons )  ){
468
+			return false;
469
+		}
470 470
 
471
-        // update each lesson and quiz author
472
-        foreach( $lessons as $lesson ){
471
+		// update each lesson and quiz author
472
+		foreach( $lessons as $lesson ){
473 473
 
474
-            // don't update if the author is tha same as the new author
475
-            if( $new_author == $lesson->post_author ){
476
-                continue;
477
-            }
474
+			// don't update if the author is tha same as the new author
475
+			if( $new_author == $lesson->post_author ){
476
+				continue;
477
+			}
478 478
 
479
-            // update lesson author
480
-            wp_update_post( array(
481
-                'ID'=> $lesson->ID,
482
-                'post_author' => $new_author
483
-                ) );
479
+			// update lesson author
480
+			wp_update_post( array(
481
+				'ID'=> $lesson->ID,
482
+				'post_author' => $new_author
483
+				) );
484 484
 
485
-            // update quiz author
486
-            //get the lessons quiz
487
-            $lesson_quizzes = Sensei()->lesson->lesson_quizzes( $lesson->ID );
488
-            if( is_array( $lesson_quizzes ) ){
489
-                foreach ( $lesson_quizzes as $quiz_id ) {
490
-                    // update quiz with new author
491
-                    wp_update_post( array(
492
-                        'ID'           => $quiz_id,
493
-                        'post_author' =>  $new_author
494
-                    ) );
495
-                }
496
-            }else{
497
-                wp_update_post( array(
498
-                    'ID'           => $lesson_quizzes,
499
-                    'post_author' =>  $new_author
500
-                ) );
501
-            }
485
+			// update quiz author
486
+			//get the lessons quiz
487
+			$lesson_quizzes = Sensei()->lesson->lesson_quizzes( $lesson->ID );
488
+			if( is_array( $lesson_quizzes ) ){
489
+				foreach ( $lesson_quizzes as $quiz_id ) {
490
+					// update quiz with new author
491
+					wp_update_post( array(
492
+						'ID'           => $quiz_id,
493
+						'post_author' =>  $new_author
494
+					) );
495
+				}
496
+			}else{
497
+				wp_update_post( array(
498
+					'ID'           => $lesson_quizzes,
499
+					'post_author' =>  $new_author
500
+				) );
501
+			}
502 502
 
503
-        } // end for each lessons
503
+		} // end for each lessons
504 504
 
505
-        return true;
505
+		return true;
506 506
 
507
-    }// end update_course_lessons_author
508
-
509
-
510
-
511
-    /**
512
-     * Sensei_Teacher::course_analysis_teacher_access_limit
513
-     *
514
-     * Alter the query so that users can only see their courses on the analysis page
515
-     *
516
-     * @since 1.8.0
517
-     * @access public
518
-     * @parameters $query
519
-     * @return array $users user id array
520
-     */
521
-    public function course_analysis_teacher_access_limit ( $query ) {
522
-
523
-        if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
524
-            return $query;
525
-        }
526
-
527
-        if ( ! function_exists( 'get_current_screen' ) ) {
528
-            return $query;
529
-        }
530
-
531
-        $screen = get_current_screen();
532
-        $sensei_post_types = array('course', 'lesson', 'question' );
533
-
534
-        // exit early for the following conditions
535
-        $limit_screen_ids = array( 'sensei_page_sensei_analysis', 'course_page_module-order' );
536
-
537
-        if( ! $this->is_admin_teacher() || empty( $screen ) || ! in_array( $screen->id ,$limit_screen_ids )
538
-            || ! in_array( $query->query['post_type'], $sensei_post_types ) ){
539
-            return $query;
540
-        }
541
-
542
-        global $current_user;
543
-        // set the query author to the current user to only show those those posts
544
-        $query->set( 'author', $current_user->ID );
545
-        return $query;
546
-
547
-    }// end course_analysis_teacher_access_limit
548
-
549
-
550
-    /**
551
-     * Sensei_Teacher::limit_teacher_edit_screen_post_types
552
-     *
553
-     * Determine if we're in admin and the current logged in use is a teacher
554
-     *
555
-     * @since 1.8.0
556
-     * @access public
557
-     * @parameters array $wp_query
558
-     * @return bool $is_admin_teacher
559
-     */
560
-    public function is_admin_teacher ( ){
561
-
562
-        if( ! is_user_logged_in()){
563
-            return false;
564
-        }
565
-        $is_admin_teacher = false;
566
-
567
-        if( is_admin() && Sensei_Teacher::is_a_teacher( get_current_user_id() )  ){
568
-
569
-            $is_admin_teacher = true;
570
-
571
-        }
572
-
573
-        return $is_admin_teacher;
574
-
575
-    } // end is_admin_teacher
576
-
577
-    /**
578
-     * Show correct post counts on list table for Sensei post types
579
-     *
580
-     * @since 1.8.0
581
-     *
582
-     * @param  object $counts Default status counts
583
-     * @param  string $type   Current post type
584
-     * @param  string $perm   User permission level
585
-     * @return object         Modified status counts
586
-     */
587
-    public function list_table_counts( $counts, $type, $perm ) {
588
-        global $current_user;
589
-
590
-        if( ! in_array( $type, array( 'course', 'lesson', 'question' ) ) ) {
591
-            return $counts;
592
-        }
593
-
594
-        if( ! $this->is_admin_teacher() ) {
595
-            return $counts;
596
-        }
597
-
598
-        $args = array(
599
-            'post_type' => $type,
600
-            'author' => $current_user->ID,
601
-            'posts_per_page' => -1
602
-        );
603
-
604
-         // Get all available statuses
605
-        $stati = get_post_stati();
606
-
607
-        // Update count object
608
-        foreach( $stati as $status ) {
609
-            $args['post_status'] = $status;
610
-            $posts = get_posts( $args );
611
-            $counts->$status = count( $posts );
612
-        }
613
-
614
-        return $counts;
615
-    }
616
-
617
-    /**
618
-     * Filter the post queries to show
619
-     * only lesson /course and users that belong
620
-     * to the current logged teacher.
621
-     *
622
-     * @since 1.8.0
623
-     *
624
-     */
625
-    public function filter_queries ( $query ) {
626
-        global $current_user;
627
-
628
-        if( ! $this->is_admin_teacher() ) {
629
-            return;
630
-        }
631
-
632
-        if ( ! function_exists( 'get_current_screen' ) ) {
633
-            return;
634
-        }
635
-
636
-        $screen = get_current_screen();
637
-        if( empty( $screen ) ) {
638
-            return $query;
639
-        }
640
-        switch( $screen->id ) {
641
-            case 'sensei_page_sensei_grading':
642
-            case 'sensei_page_sensei_analysis':
643
-            case 'sensei_page_sensei_learners':
644
-            case 'lesson':
645
-            case 'course':
646
-            case 'question':
647
-            case 'lesson_page_module-order':
648
-
649
-            /**
650
-             * sensei_filter_queries_set_author
651
-             * Filter the author Sensei set for queries
652
-             *
653
-             * @since 1.8.0
654
-             *
655
-             * @param int $user_id
656
-             * @param string $screen_id
657
-             *
658
-             */
659
-            $query->set( 'author', apply_filters( 'sensei_filter_queries_set_author', $current_user->ID, $screen->id ) );
660
-            break;
661
-        }
662
-    }
663
-
664
-    /**
665
-     * Limit grading quizzes to only those within courses belonging to the current teacher
666
-     * . This excludes the admin user.
667
-     *
668
-     * @since 1.8.0
669
-     * @hooked into the_comments
670
-     * @param array  $comments
671
-     *
672
-     * @return array $comments
673
-     */
674
-    public function filter_grading_activity_queries( $comments ){
675
-
676
-        if( !is_admin() || ! $this->is_admin_teacher() || is_numeric( $comments ) || ! is_array( $comments ) ){
677
-            return $comments ;
678
-        }
679
-
680
-        //check if we're on the grading screen
681
-        $screen = get_current_screen();
682
-
683
-        if( empty( $screen ) || 'sensei_page_sensei_grading' != $screen->id ){
684
-            return $comments;
685
-        }
686
-
687
-        // get the course and determine if the current teacher is the owner
688
-        // if not remove it from the list of comments to be returned
689
-        foreach( $comments as $key => $comment){
690
-            $lesson = get_post( $comment->comment_post_ID );
691
-            $course_id = Sensei()->lesson->get_course_id( $lesson->ID );
692
-            $course = get_post( $course_id );
693
-            if( ! isset( $course->post_author ) || intval( $course->post_author) != intval( get_current_user_id() ) ){
694
-                //remove this as the teacher should see this.
695
-                unset( $comments[ $key ] );
696
-            }
697
-        }
698
-        return $comments ;
699
-
700
-    }// end function filter grading
701
-
702
-    /**
703
-     * Limit the grading screen totals to only show lessons in the course
704
-     * belonging to the currently logged in teacher. This only applies to
705
-     * the teacher role.
706
-     *
707
-     * @since 1.8.0
708
-     *
709
-     * @hooked into sensei_count_statuses_args
710
-     * @param array $args
711
-     *
712
-     * @return array  $args
713
-     */
714
-    public function limit_grading_totals( $args ){
715
-
716
-        if( !is_admin() || ! $this->is_admin_teacher() || ! is_array( $args ) ){
717
-            return $args ;
718
-        }
719
-
720
-        //get the teachers courses
721
-        // the query is already filtered to only the teacher
722
-        $courses =  Sensei()->course->get_all_courses();
723
-
724
-        if( empty(  $courses ) || ! is_array( $courses ) ){
725
-            return $args;
726
-        }
727
-
728
-        //setup the lessons quizzes  to limit the grading totals to
729
-        $quiz_scope = array();
730
-        foreach( $courses as $course ){
731
-
732
-            $course_lessons = Sensei()->course->course_lessons( $course->ID );
733
-
734
-            if( ! empty( $course_lessons ) && is_array( $course_lessons  ) ){
735
-
736
-                foreach(  $course_lessons as $lesson ){
737
-
738
-                    $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID );
739
-                    if( !empty( $quiz_id ) ) {
740
-
741
-                        array_push( $quiz_scope, $quiz_id );
742
-
743
-                    }
744
-
745
-                }
746
-
747
-            }
748
-
749
-        }
750
-
751
-        $args['post__in'] = $quiz_scope;
752
-
753
-        return $args;
754
-    }
755
-
756
-    /**
757
-     * It ensures that the author archive shows course by the current user.
758
-     *
759
-     * This function is hooked into the pre_get_posts filter
760
-     *
761
-     * @param WP_Query $query
762
-     * @return WP_Query $query
763
-     */
764
-    public function add_courses_to_author_archive( $query ) {
765
-
766
-        if ( is_admin() || ! $query->is_author() ){
767
-            return $query;
768
-        }
769
-
770
-        // this should only apply to users with the teacher role
771
-        $current_page_user = get_user_by('login', $query->get('author_name') );
772
-        if( ! $current_page_user || ! in_array('teacher', $current_page_user->roles ) )     {
773
-
774
-            return $query;
775
-
776
-        }
777
-
778
-        // Change post types depending on what is set already
779
-        $current_post_types = $query->get( 'post_type' );
780
-        if( empty( $current_post_types  ) ){
781
-
782
-            // if empty it means post by default, so add post so that it also includes that for now
783
-            $new_post_types = array( 'post', 'course' );
784
-
785
-        } elseif( is_array( $current_post_types  ) ) {
786
-
787
-            // merge the post types instead of overwriting it
788
-            $new_post_types = array_merge( $current_post_types, array( 'course' ) );
789
-
790
-        }else{
791
-
792
-            // in this instance it is probably just one post type in string format
793
-            $new_post_types =  array( $current_post_types , 'course');
794
-
795
-        }
796
-
797
-        // change the query before returning it
798
-        $query->set('post_type', $new_post_types );
799
-
800
-        /**
801
-         * Change the query on the teacher author archive template
802
-         *
803
-         * @since 1.8.4
804
-         * @param WP_Query $query
805
-         */
806
-        return apply_filters( 'sensei_teacher_archive_query', $query );
807
-
808
-    }
809
-
810
-    /**
811
-     * Notify teacher when someone assigns a course to their account.
812
-     *
813
-     * @since 1.8.0
814
-     *
815
-     * @param $teacher_id
816
-     * @param $course_id
817
-     * @return bool
818
-     */
819
-    public function teacher_course_assigned_notification( $teacher_id, $course_id ){
820
-
821
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $teacher_id ) ){
822
-            return false;
823
-        }
824
-
825
-        // if new user is the same as the current logged user, they don't need an email
826
-        if( $teacher_id == get_current_user_id() ){
827
-            return true;
828
-        }
829
-
830
-        // load the email class
831
-        include('emails/class-sensei-email-teacher-new-course-assignment.php');
832
-        $email = new Sensei_Email_Teacher_New_Course_Assignment();
833
-        $email->trigger( $teacher_id, $course_id );
834
-
835
-        return true;
836
-    } // end  teacher_course_assigned_notification
837
-
838
-    /**
839
-     * Email the admin when a teacher creates a new course
840
-     *
841
-     * This function hooks into wp_insert_post
842
-     *
843
-     * @since 1.8.0
844
-     * @param int $course_id
845
-     * @return bool
846
-     */
847
-    public function notify_admin_teacher_course_creation( $new_status, $old_status, $post ){
848
-
849
-        $course_id = $post->ID;
850
-
851
-        if( 'course' != get_post_type( $course_id ) || 'auto-draft' == get_post_status( $course_id )
852
-            || 'trash' == get_post_status( $course_id ) || 'draft' == get_post_status( $course_id ) ) {
853
-
854
-            return false;
855
-
856
-        }
857
-
858
-        /**
859
-         * Filter the option to send admin notification emails when teachers creation
860
-         * course.
861
-         *
862
-         * @since 1.8.0
863
-         *
864
-         * @param bool $on default true
865
-         */
866
-        if( ! apply_filters('sensei_notify_admin_new_course_creation', true ) ){
867
-            return false;
868
-        }
869
-
870
-        // setting up the data needed by the email template
871
-        global $sensei_email_data;
872
-        $template = 'admin-teacher-new-course-created';
873
-        $course = get_post( $course_id );
874
-        $teacher = new WP_User( $course->post_author );
875
-        $recipient = get_option('admin_email', true);
876
-
877
-        // don't send if the course is created by admin
878
-        if( $recipient == $teacher->user_email ){
879
-            return;
880
-        }
881
-
882
-        /**
883
-         * Filter the email Header for the admin-teacher-new-course-created template
884
-         *
885
-         * @since 1.8.0
886
-         * @param string $template
887
-         */
888
-        $heading = apply_filters( 'sensei_email_heading', __( 'New course created.', 'woothemes-sensei' ), $template );
889
-
890
-        /**
891
-         * Filter the email subject for the the
892
-         * admin-teacher-new-course-created template
893
-         *
894
-         * @since 1.8.0
895
-         * @param string $subject default New course assigned to you
896
-         * @param string $template
897
-         */
898
-        $subject = apply_filters('sensei_email_subject',
899
-                                '['. get_bloginfo( 'name', 'display' ) .'] '. __( 'New course created by', 'woothemes-sensei' ) . ' ' . $teacher->display_name ,
900
-                                $template );
901
-
902
-        //course edit link
903
-        $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' );
904
-
905
-        // Construct data array
906
-        $email_data = array(
907
-            'template'			=> $template,
908
-            'heading' =>  $heading,
909
-            'teacher'		=> $teacher,
910
-            'course_id'			=> $course_id,
911
-            'course_name'			=> $course->post_title,
912
-            'course_edit_link' => $course_edit_link,
913
-        );
914
-
915
-        /**
916
-         * Filter the sensei email data for the admin-teacher-new-course-created template
917
-         *
918
-         * @since 1.8.0
919
-         * @param array $email_data
920
-         * @param string $template
921
-         */
922
-        $sensei_email_data = apply_filters( 'sensei_email_data', $email_data , $template );
923
-
924
-        // Send mail
925
-        Sensei()->emails->send( $recipient, $subject , Sensei()->emails->get_content( $template ) );
926
-
927
-    }// end notify admin of course creation
928
-
929
-    /**
930
-     * Limit the analysis view to only the users taking courses belong to this teacher
931
-     *
932
-     * Hooked into sensei_analysis_get_learners
933
-     * @param array $args WP_User_Query arguments
934
-     * @return array $learners_query_results
935
-     */
936
-    public function limit_analysis_learners( $args ){
937
-
938
-        // show default for none teachers
939
-        if( ! Sensei()->teacher->is_admin_teacher() ) {
940
-                return $args;
941
-        }
942
-
943
-        // for teachers all courses only return those which belong to the teacher
944
-        // as they don't have access to course belonging to other users
945
-        $teacher_courses = Sensei()->course->get_all_courses();
507
+	}// end update_course_lessons_author
508
+
509
+
510
+
511
+	/**
512
+	 * Sensei_Teacher::course_analysis_teacher_access_limit
513
+	 *
514
+	 * Alter the query so that users can only see their courses on the analysis page
515
+	 *
516
+	 * @since 1.8.0
517
+	 * @access public
518
+	 * @parameters $query
519
+	 * @return array $users user id array
520
+	 */
521
+	public function course_analysis_teacher_access_limit ( $query ) {
522
+
523
+		if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
524
+			return $query;
525
+		}
526
+
527
+		if ( ! function_exists( 'get_current_screen' ) ) {
528
+			return $query;
529
+		}
530
+
531
+		$screen = get_current_screen();
532
+		$sensei_post_types = array('course', 'lesson', 'question' );
533
+
534
+		// exit early for the following conditions
535
+		$limit_screen_ids = array( 'sensei_page_sensei_analysis', 'course_page_module-order' );
536
+
537
+		if( ! $this->is_admin_teacher() || empty( $screen ) || ! in_array( $screen->id ,$limit_screen_ids )
538
+			|| ! in_array( $query->query['post_type'], $sensei_post_types ) ){
539
+			return $query;
540
+		}
541
+
542
+		global $current_user;
543
+		// set the query author to the current user to only show those those posts
544
+		$query->set( 'author', $current_user->ID );
545
+		return $query;
546
+
547
+	}// end course_analysis_teacher_access_limit
548
+
549
+
550
+	/**
551
+	 * Sensei_Teacher::limit_teacher_edit_screen_post_types
552
+	 *
553
+	 * Determine if we're in admin and the current logged in use is a teacher
554
+	 *
555
+	 * @since 1.8.0
556
+	 * @access public
557
+	 * @parameters array $wp_query
558
+	 * @return bool $is_admin_teacher
559
+	 */
560
+	public function is_admin_teacher ( ){
561
+
562
+		if( ! is_user_logged_in()){
563
+			return false;
564
+		}
565
+		$is_admin_teacher = false;
566
+
567
+		if( is_admin() && Sensei_Teacher::is_a_teacher( get_current_user_id() )  ){
568
+
569
+			$is_admin_teacher = true;
570
+
571
+		}
572
+
573
+		return $is_admin_teacher;
574
+
575
+	} // end is_admin_teacher
576
+
577
+	/**
578
+	 * Show correct post counts on list table for Sensei post types
579
+	 *
580
+	 * @since 1.8.0
581
+	 *
582
+	 * @param  object $counts Default status counts
583
+	 * @param  string $type   Current post type
584
+	 * @param  string $perm   User permission level
585
+	 * @return object         Modified status counts
586
+	 */
587
+	public function list_table_counts( $counts, $type, $perm ) {
588
+		global $current_user;
589
+
590
+		if( ! in_array( $type, array( 'course', 'lesson', 'question' ) ) ) {
591
+			return $counts;
592
+		}
593
+
594
+		if( ! $this->is_admin_teacher() ) {
595
+			return $counts;
596
+		}
597
+
598
+		$args = array(
599
+			'post_type' => $type,
600
+			'author' => $current_user->ID,
601
+			'posts_per_page' => -1
602
+		);
603
+
604
+		 // Get all available statuses
605
+		$stati = get_post_stati();
606
+
607
+		// Update count object
608
+		foreach( $stati as $status ) {
609
+			$args['post_status'] = $status;
610
+			$posts = get_posts( $args );
611
+			$counts->$status = count( $posts );
612
+		}
613
+
614
+		return $counts;
615
+	}
616
+
617
+	/**
618
+	 * Filter the post queries to show
619
+	 * only lesson /course and users that belong
620
+	 * to the current logged teacher.
621
+	 *
622
+	 * @since 1.8.0
623
+	 *
624
+	 */
625
+	public function filter_queries ( $query ) {
626
+		global $current_user;
627
+
628
+		if( ! $this->is_admin_teacher() ) {
629
+			return;
630
+		}
631
+
632
+		if ( ! function_exists( 'get_current_screen' ) ) {
633
+			return;
634
+		}
635
+
636
+		$screen = get_current_screen();
637
+		if( empty( $screen ) ) {
638
+			return $query;
639
+		}
640
+		switch( $screen->id ) {
641
+			case 'sensei_page_sensei_grading':
642
+			case 'sensei_page_sensei_analysis':
643
+			case 'sensei_page_sensei_learners':
644
+			case 'lesson':
645
+			case 'course':
646
+			case 'question':
647
+			case 'lesson_page_module-order':
648
+
649
+			/**
650
+			 * sensei_filter_queries_set_author
651
+			 * Filter the author Sensei set for queries
652
+			 *
653
+			 * @since 1.8.0
654
+			 *
655
+			 * @param int $user_id
656
+			 * @param string $screen_id
657
+			 *
658
+			 */
659
+			$query->set( 'author', apply_filters( 'sensei_filter_queries_set_author', $current_user->ID, $screen->id ) );
660
+			break;
661
+		}
662
+	}
663
+
664
+	/**
665
+	 * Limit grading quizzes to only those within courses belonging to the current teacher
666
+	 * . This excludes the admin user.
667
+	 *
668
+	 * @since 1.8.0
669
+	 * @hooked into the_comments
670
+	 * @param array  $comments
671
+	 *
672
+	 * @return array $comments
673
+	 */
674
+	public function filter_grading_activity_queries( $comments ){
675
+
676
+		if( !is_admin() || ! $this->is_admin_teacher() || is_numeric( $comments ) || ! is_array( $comments ) ){
677
+			return $comments ;
678
+		}
679
+
680
+		//check if we're on the grading screen
681
+		$screen = get_current_screen();
682
+
683
+		if( empty( $screen ) || 'sensei_page_sensei_grading' != $screen->id ){
684
+			return $comments;
685
+		}
686
+
687
+		// get the course and determine if the current teacher is the owner
688
+		// if not remove it from the list of comments to be returned
689
+		foreach( $comments as $key => $comment){
690
+			$lesson = get_post( $comment->comment_post_ID );
691
+			$course_id = Sensei()->lesson->get_course_id( $lesson->ID );
692
+			$course = get_post( $course_id );
693
+			if( ! isset( $course->post_author ) || intval( $course->post_author) != intval( get_current_user_id() ) ){
694
+				//remove this as the teacher should see this.
695
+				unset( $comments[ $key ] );
696
+			}
697
+		}
698
+		return $comments ;
699
+
700
+	}// end function filter grading
701
+
702
+	/**
703
+	 * Limit the grading screen totals to only show lessons in the course
704
+	 * belonging to the currently logged in teacher. This only applies to
705
+	 * the teacher role.
706
+	 *
707
+	 * @since 1.8.0
708
+	 *
709
+	 * @hooked into sensei_count_statuses_args
710
+	 * @param array $args
711
+	 *
712
+	 * @return array  $args
713
+	 */
714
+	public function limit_grading_totals( $args ){
715
+
716
+		if( !is_admin() || ! $this->is_admin_teacher() || ! is_array( $args ) ){
717
+			return $args ;
718
+		}
719
+
720
+		//get the teachers courses
721
+		// the query is already filtered to only the teacher
722
+		$courses =  Sensei()->course->get_all_courses();
723
+
724
+		if( empty(  $courses ) || ! is_array( $courses ) ){
725
+			return $args;
726
+		}
727
+
728
+		//setup the lessons quizzes  to limit the grading totals to
729
+		$quiz_scope = array();
730
+		foreach( $courses as $course ){
731
+
732
+			$course_lessons = Sensei()->course->course_lessons( $course->ID );
733
+
734
+			if( ! empty( $course_lessons ) && is_array( $course_lessons  ) ){
735
+
736
+				foreach(  $course_lessons as $lesson ){
737
+
738
+					$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID );
739
+					if( !empty( $quiz_id ) ) {
740
+
741
+						array_push( $quiz_scope, $quiz_id );
742
+
743
+					}
744
+
745
+				}
746
+
747
+			}
748
+
749
+		}
750
+
751
+		$args['post__in'] = $quiz_scope;
752
+
753
+		return $args;
754
+	}
755
+
756
+	/**
757
+	 * It ensures that the author archive shows course by the current user.
758
+	 *
759
+	 * This function is hooked into the pre_get_posts filter
760
+	 *
761
+	 * @param WP_Query $query
762
+	 * @return WP_Query $query
763
+	 */
764
+	public function add_courses_to_author_archive( $query ) {
765
+
766
+		if ( is_admin() || ! $query->is_author() ){
767
+			return $query;
768
+		}
769
+
770
+		// this should only apply to users with the teacher role
771
+		$current_page_user = get_user_by('login', $query->get('author_name') );
772
+		if( ! $current_page_user || ! in_array('teacher', $current_page_user->roles ) )     {
773
+
774
+			return $query;
775
+
776
+		}
777
+
778
+		// Change post types depending on what is set already
779
+		$current_post_types = $query->get( 'post_type' );
780
+		if( empty( $current_post_types  ) ){
781
+
782
+			// if empty it means post by default, so add post so that it also includes that for now
783
+			$new_post_types = array( 'post', 'course' );
784
+
785
+		} elseif( is_array( $current_post_types  ) ) {
786
+
787
+			// merge the post types instead of overwriting it
788
+			$new_post_types = array_merge( $current_post_types, array( 'course' ) );
789
+
790
+		}else{
791
+
792
+			// in this instance it is probably just one post type in string format
793
+			$new_post_types =  array( $current_post_types , 'course');
794
+
795
+		}
796
+
797
+		// change the query before returning it
798
+		$query->set('post_type', $new_post_types );
799
+
800
+		/**
801
+		 * Change the query on the teacher author archive template
802
+		 *
803
+		 * @since 1.8.4
804
+		 * @param WP_Query $query
805
+		 */
806
+		return apply_filters( 'sensei_teacher_archive_query', $query );
807
+
808
+	}
809
+
810
+	/**
811
+	 * Notify teacher when someone assigns a course to their account.
812
+	 *
813
+	 * @since 1.8.0
814
+	 *
815
+	 * @param $teacher_id
816
+	 * @param $course_id
817
+	 * @return bool
818
+	 */
819
+	public function teacher_course_assigned_notification( $teacher_id, $course_id ){
820
+
821
+		if( 'course' != get_post_type( $course_id ) || ! get_userdata( $teacher_id ) ){
822
+			return false;
823
+		}
824
+
825
+		// if new user is the same as the current logged user, they don't need an email
826
+		if( $teacher_id == get_current_user_id() ){
827
+			return true;
828
+		}
829
+
830
+		// load the email class
831
+		include('emails/class-sensei-email-teacher-new-course-assignment.php');
832
+		$email = new Sensei_Email_Teacher_New_Course_Assignment();
833
+		$email->trigger( $teacher_id, $course_id );
834
+
835
+		return true;
836
+	} // end  teacher_course_assigned_notification
837
+
838
+	/**
839
+	 * Email the admin when a teacher creates a new course
840
+	 *
841
+	 * This function hooks into wp_insert_post
842
+	 *
843
+	 * @since 1.8.0
844
+	 * @param int $course_id
845
+	 * @return bool
846
+	 */
847
+	public function notify_admin_teacher_course_creation( $new_status, $old_status, $post ){
848
+
849
+		$course_id = $post->ID;
850
+
851
+		if( 'course' != get_post_type( $course_id ) || 'auto-draft' == get_post_status( $course_id )
852
+			|| 'trash' == get_post_status( $course_id ) || 'draft' == get_post_status( $course_id ) ) {
853
+
854
+			return false;
855
+
856
+		}
857
+
858
+		/**
859
+		 * Filter the option to send admin notification emails when teachers creation
860
+		 * course.
861
+		 *
862
+		 * @since 1.8.0
863
+		 *
864
+		 * @param bool $on default true
865
+		 */
866
+		if( ! apply_filters('sensei_notify_admin_new_course_creation', true ) ){
867
+			return false;
868
+		}
869
+
870
+		// setting up the data needed by the email template
871
+		global $sensei_email_data;
872
+		$template = 'admin-teacher-new-course-created';
873
+		$course = get_post( $course_id );
874
+		$teacher = new WP_User( $course->post_author );
875
+		$recipient = get_option('admin_email', true);
876
+
877
+		// don't send if the course is created by admin
878
+		if( $recipient == $teacher->user_email ){
879
+			return;
880
+		}
881
+
882
+		/**
883
+		 * Filter the email Header for the admin-teacher-new-course-created template
884
+		 *
885
+		 * @since 1.8.0
886
+		 * @param string $template
887
+		 */
888
+		$heading = apply_filters( 'sensei_email_heading', __( 'New course created.', 'woothemes-sensei' ), $template );
889
+
890
+		/**
891
+		 * Filter the email subject for the the
892
+		 * admin-teacher-new-course-created template
893
+		 *
894
+		 * @since 1.8.0
895
+		 * @param string $subject default New course assigned to you
896
+		 * @param string $template
897
+		 */
898
+		$subject = apply_filters('sensei_email_subject',
899
+								'['. get_bloginfo( 'name', 'display' ) .'] '. __( 'New course created by', 'woothemes-sensei' ) . ' ' . $teacher->display_name ,
900
+								$template );
901
+
902
+		//course edit link
903
+		$course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' );
904
+
905
+		// Construct data array
906
+		$email_data = array(
907
+			'template'			=> $template,
908
+			'heading' =>  $heading,
909
+			'teacher'		=> $teacher,
910
+			'course_id'			=> $course_id,
911
+			'course_name'			=> $course->post_title,
912
+			'course_edit_link' => $course_edit_link,
913
+		);
914
+
915
+		/**
916
+		 * Filter the sensei email data for the admin-teacher-new-course-created template
917
+		 *
918
+		 * @since 1.8.0
919
+		 * @param array $email_data
920
+		 * @param string $template
921
+		 */
922
+		$sensei_email_data = apply_filters( 'sensei_email_data', $email_data , $template );
923
+
924
+		// Send mail
925
+		Sensei()->emails->send( $recipient, $subject , Sensei()->emails->get_content( $template ) );
926
+
927
+	}// end notify admin of course creation
928
+
929
+	/**
930
+	 * Limit the analysis view to only the users taking courses belong to this teacher
931
+	 *
932
+	 * Hooked into sensei_analysis_get_learners
933
+	 * @param array $args WP_User_Query arguments
934
+	 * @return array $learners_query_results
935
+	 */
936
+	public function limit_analysis_learners( $args ){
937
+
938
+		// show default for none teachers
939
+		if( ! Sensei()->teacher->is_admin_teacher() ) {
940
+				return $args;
941
+		}
942
+
943
+		// for teachers all courses only return those which belong to the teacher
944
+		// as they don't have access to course belonging to other users
945
+		$teacher_courses = Sensei()->course->get_all_courses();
946 946
 
947
-        // if the user has no courses they should see no users
948
-        if( empty( $teacher_courses ) ||  ! is_array( $teacher_courses ) ){
949
-            // tell the query to return 0 students
950
-            $args[ 'include'] = array( 0 );
951
-            return $args;
952
-
953
-        }
954
-
955
-        $learner_ids_for_teacher_courses = array();
956
-        foreach( $teacher_courses as $course ){
957
-
958
-            $course_learner_ids = array();
959
-            $activity_comments =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course->ID, 'type' => 'sensei_course_status', 'field' => 'user_id' ), true );
960
-
961
-            if( empty( $activity_comments ) ||  ( is_array( $activity_comments  ) && ! ( count( $activity_comments ) > 0 ) ) ){
962
-                continue; // skip to the next course as there are no users on this course
963
-            }
964
-
965
-            // it could be an array of comments or a single comment
966
-            if( is_array( $activity_comments ) ){
947
+		// if the user has no courses they should see no users
948
+		if( empty( $teacher_courses ) ||  ! is_array( $teacher_courses ) ){
949
+			// tell the query to return 0 students
950
+			$args[ 'include'] = array( 0 );
951
+			return $args;
952
+
953
+		}
954
+
955
+		$learner_ids_for_teacher_courses = array();
956
+		foreach( $teacher_courses as $course ){
957
+
958
+			$course_learner_ids = array();
959
+			$activity_comments =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course->ID, 'type' => 'sensei_course_status', 'field' => 'user_id' ), true );
960
+
961
+			if( empty( $activity_comments ) ||  ( is_array( $activity_comments  ) && ! ( count( $activity_comments ) > 0 ) ) ){
962
+				continue; // skip to the next course as there are no users on this course
963
+			}
964
+
965
+			// it could be an array of comments or a single comment
966
+			if( is_array( $activity_comments ) ){
967 967
 
968
-                foreach( $activity_comments as $comment ){
968
+				foreach( $activity_comments as $comment ){
969 969
 
970
-                    $user = get_userdata( $comment->user_id );
970
+					$user = get_userdata( $comment->user_id );
971 971
 
972
-                    if( empty( $user ) ){
973
-                        // next comment in this array
974
-                        continue;
975
-                    }
972
+					if( empty( $user ) ){
973
+						// next comment in this array
974
+						continue;
975
+					}
976 976
 
977
-                    $course_learner_ids[] = $user->ID;
978
-                }
977
+					$course_learner_ids[] = $user->ID;
978
+				}
979 979
 
980
-            }else{
980
+			}else{
981 981
 
982
-                $user = get_userdata( $activity_comments->user_id );
983
-                $course_learner_ids[] = $user->ID;
982
+				$user = get_userdata( $activity_comments->user_id );
983
+				$course_learner_ids[] = $user->ID;
984 984
 
985
-            }
985
+			}
986 986
 
987
-            // add learners on this course to the all courses learner list
988
-            $learner_ids_for_teacher_courses = array_merge( $learner_ids_for_teacher_courses, $course_learner_ids );
987
+			// add learners on this course to the all courses learner list
988
+			$learner_ids_for_teacher_courses = array_merge( $learner_ids_for_teacher_courses, $course_learner_ids );
989 989
 
990
-        }
990
+		}
991 991
 
992
-        // if there are no students taking the courses by this teacher don't show them any of the other users
993
-        if( empty( $learner_ids_for_teacher_courses ) ){
992
+		// if there are no students taking the courses by this teacher don't show them any of the other users
993
+		if( empty( $learner_ids_for_teacher_courses ) ){
994 994
 
995
-            $args[ 'include'] = array( 0 );
995
+			$args[ 'include'] = array( 0 );
996 996
 
997
-        }else{
997
+		}else{
998 998
 
999
-            $args[ 'include'] = $learner_ids_for_teacher_courses;
999
+			$args[ 'include'] = $learner_ids_for_teacher_courses;
1000 1000
 
1001
-        }
1001
+		}
1002 1002
 
1003
-        // return the WP_Use_Query arguments
1004
-        return $args;
1003
+		// return the WP_Use_Query arguments
1004
+		return $args;
1005 1005
 
1006
-    }// end limit_analysis_learners
1006
+	}// end limit_analysis_learners
1007 1007
 
1008
-    /**
1009
-     * Give teacher full admin access to the question post type
1010
-     * in certain cases.
1011
-     *
1012
-     * @since 1.8.0
1013
-     * @param $questions
1014
-     * @return mixed
1015
-     */
1016
-    public function allow_teacher_access_to_questions( $questions, $quiz_id ){
1008
+	/**
1009
+	 * Give teacher full admin access to the question post type
1010
+	 * in certain cases.
1011
+	 *
1012
+	 * @since 1.8.0
1013
+	 * @param $questions
1014
+	 * @return mixed
1015
+	 */
1016
+	public function allow_teacher_access_to_questions( $questions, $quiz_id ){
1017 1017
 
1018
-        if( ! $this->is_admin_teacher() ){
1019
-            return $questions;
1020
-        }
1018
+		if( ! $this->is_admin_teacher() ){
1019
+			return $questions;
1020
+		}
1021 1021
 
1022
-        $screen = get_current_screen();
1022
+		$screen = get_current_screen();
1023 1023
 
1024
-        // don't run this filter within this functions call to Sensei()->lesson->lesson_quiz_questions
1025
-        remove_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20 );
1024
+		// don't run this filter within this functions call to Sensei()->lesson->lesson_quiz_questions
1025
+		remove_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20 );
1026 1026
 
1027
-        if( ! empty( $screen ) && 'lesson'== $screen->post_type ){
1027
+		if( ! empty( $screen ) && 'lesson'== $screen->post_type ){
1028 1028
 
1029
-            $admin_user = get_user_by('email', get_bloginfo('admin_email'));
1030
-            if( ! empty($admin_user) ){
1029
+			$admin_user = get_user_by('email', get_bloginfo('admin_email'));
1030
+			if( ! empty($admin_user) ){
1031 1031
 
1032
-                $current_teacher_id = get_current_user_id();
1032
+				$current_teacher_id = get_current_user_id();
1033 1033
 
1034
-                // set current user to admin so teacher can view all questions
1035
-                wp_set_current_user( $admin_user->ID  );
1036
-                $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id  );
1034
+				// set current user to admin so teacher can view all questions
1035
+				wp_set_current_user( $admin_user->ID  );
1036
+				$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id  );
1037 1037
 
1038
-                // set the teacher as the current use again
1039
-                wp_set_current_user( $current_teacher_id );
1040
-            }
1038
+				// set the teacher as the current use again
1039
+				wp_set_current_user( $current_teacher_id );
1040
+			}
1041 1041
 
1042
-        }
1043
-        // attach the filter again for other funtion calls to Sensei()->lesson->lesson_quiz_questions
1044
-        add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20,2 );
1042
+		}
1043
+		// attach the filter again for other funtion calls to Sensei()->lesson->lesson_quiz_questions
1044
+		add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20,2 );
1045 1045
 
1046
-        return $questions;
1047
-    }
1046
+		return $questions;
1047
+	}
1048 1048
 
1049
-    /**
1050
-     * Give the teacher role access to questions from the question bank
1051
-     *
1052
-     * @since 1.8.0
1053
-     * @param $wp_query
1054
-     * @return mixed
1055
-     */
1056
-    public function give_access_to_all_questions( $wp_query ){
1049
+	/**
1050
+	 * Give the teacher role access to questions from the question bank
1051
+	 *
1052
+	 * @since 1.8.0
1053
+	 * @param $wp_query
1054
+	 * @return mixed
1055
+	 */
1056
+	public function give_access_to_all_questions( $wp_query ){
1057 1057
 
1058
-        if( ! $this->is_admin_teacher() || !function_exists( 'get_current_screen') || 'question' != $wp_query->get('post_type') ){
1058
+		if( ! $this->is_admin_teacher() || !function_exists( 'get_current_screen') || 'question' != $wp_query->get('post_type') ){
1059 1059
 
1060
-            return $wp_query;
1061
-        }
1060
+			return $wp_query;
1061
+		}
1062 1062
 
1063
-        $screen = get_current_screen();
1064
-        if( ( isset($screen->id) && 'lesson' == $screen->id )
1065
-            || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
1063
+		$screen = get_current_screen();
1064
+		if( ( isset($screen->id) && 'lesson' == $screen->id )
1065
+			|| ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
1066 1066
 
1067
-            $admin_user = get_user_by('email', get_bloginfo('admin_email'));
1068
-            if( ! empty($admin_user) ){
1067
+			$admin_user = get_user_by('email', get_bloginfo('admin_email'));
1068
+			if( ! empty($admin_user) ){
1069 1069
 
1070
-                $current_teacher_id = get_current_user_id();
1070
+				$current_teacher_id = get_current_user_id();
1071 1071
 
1072
-                // set current user to admin so teacher can view all questions
1073
-                wp_set_current_user( $admin_user->ID  );
1072
+				// set current user to admin so teacher can view all questions
1073
+				wp_set_current_user( $admin_user->ID  );
1074 1074
 
1075
-                //run new query as admin
1076
-                $wp_query = new WP_Query( $wp_query->query );
1075
+				//run new query as admin
1076
+				$wp_query = new WP_Query( $wp_query->query );
1077 1077
 
1078
-                //set the teache as current use again
1079
-                wp_set_current_user( $current_teacher_id );
1078
+				//set the teache as current use again
1079
+				wp_set_current_user( $current_teacher_id );
1080 1080
 
1081
-            }
1082
-        }
1081
+			}
1082
+		}
1083 1083
 
1084
-        return $wp_query;
1085
-    }// end give_access_to_all_questions
1084
+		return $wp_query;
1085
+	}// end give_access_to_all_questions
1086 1086
 
1087
-    /**
1088
-     * Add new column heading to the course admin edit list
1089
-     *
1090
-     * @since 1.8.0
1091
-     * @param $columns
1092
-     * @return array
1093
-     */
1094
-    public function course_column_heading($columns) {
1087
+	/**
1088
+	 * Add new column heading to the course admin edit list
1089
+	 *
1090
+	 * @since 1.8.0
1091
+	 * @param $columns
1092
+	 * @return array
1093
+	 */
1094
+	public function course_column_heading($columns) {
1095 1095
 
1096
-        if( $this->is_admin_teacher() ){
1097
-            return $columns;
1098
-        }
1099
-        $new_columns = array(
1100
-            'teacher' => __('Teacher', 'woothemes-sensei'),
1101
-        );
1102
-        return array_merge($columns, $new_columns);
1096
+		if( $this->is_admin_teacher() ){
1097
+			return $columns;
1098
+		}
1099
+		$new_columns = array(
1100
+			'teacher' => __('Teacher', 'woothemes-sensei'),
1101
+		);
1102
+		return array_merge($columns, $new_columns);
1103 1103
 
1104
-    }// end teacher column add
1104
+	}// end teacher column add
1105 1105
 
1106
-    /**
1107
-     * Print out  teacher column data
1108
-     *
1109
-     * @since 1.8.0
1110
-     * @param $column
1111
-     * @param $course_id
1112
-     */
1113
-    public function course_column_data( $column, $course_id  ){
1106
+	/**
1107
+	 * Print out  teacher column data
1108
+	 *
1109
+	 * @since 1.8.0
1110
+	 * @param $column
1111
+	 * @param $course_id
1112
+	 */
1113
+	public function course_column_data( $column, $course_id  ){
1114 1114
 
1115
-        if( $this->is_admin_teacher() || 'teacher' != $column  ){
1116
-            return;
1117
-        }
1115
+		if( $this->is_admin_teacher() || 'teacher' != $column  ){
1116
+			return;
1117
+		}
1118 1118
 
1119
-        $course = get_post( $course_id );
1120
-        $teacher = get_userdata( $course->post_author );
1119
+		$course = get_post( $course_id );
1120
+		$teacher = get_userdata( $course->post_author );
1121 1121
 
1122
-        if( !$teacher ){
1123
-            return;
1124
-        }
1122
+		if( !$teacher ){
1123
+			return;
1124
+		}
1125 1125
 
1126
-        echo '<a href="'. get_edit_user_link( $teacher->ID ) .'" >'. $teacher->display_name.'</a>';
1126
+		echo '<a href="'. get_edit_user_link( $teacher->ID ) .'" >'. $teacher->display_name.'</a>';
1127 1127
 
1128
-    }// end course_column_ data
1128
+	}// end course_column_ data
1129 1129
 
1130
-    /**
1131
-     * Return only courses belonging to the given teacher.
1132
-     *
1133
-     *
1134
-     * @since 1.8.0
1135
-     *
1136
-     * @param int $teacher_id
1137
-     * @param bool $return_ids_only
1138
-     *
1139
-     * @return array $teachers_courses
1140
-     */
1141
-    public function get_teacher_courses( $teacher_id, $return_ids_only= false){
1130
+	/**
1131
+	 * Return only courses belonging to the given teacher.
1132
+	 *
1133
+	 *
1134
+	 * @since 1.8.0
1135
+	 *
1136
+	 * @param int $teacher_id
1137
+	 * @param bool $return_ids_only
1138
+	 *
1139
+	 * @return array $teachers_courses
1140
+	 */
1141
+	public function get_teacher_courses( $teacher_id, $return_ids_only= false){
1142 1142
 
1143
-        $teachers_courses = array();
1143
+		$teachers_courses = array();
1144 1144
 
1145
-        if( empty( $teacher_id  ) ){
1146
-            $teacher_id = get_current_user_id();
1147
-        }
1145
+		if( empty( $teacher_id  ) ){
1146
+			$teacher_id = get_current_user_id();
1147
+		}
1148 1148
 
1149
-        $all_courses = Sensei()->course->get_all_courses();
1149
+		$all_courses = Sensei()->course->get_all_courses();
1150 1150
 
1151
-        if( empty( $all_courses ) ){
1152
-            return $all_courses;
1153
-        }
1151
+		if( empty( $all_courses ) ){
1152
+			return $all_courses;
1153
+		}
1154 1154
 
1155
-        foreach( $all_courses as $course ){
1155
+		foreach( $all_courses as $course ){
1156 1156
 
1157
-            if( $course->post_author != $teacher_id  ){
1158
-                continue;
1159
-            }
1157
+			if( $course->post_author != $teacher_id  ){
1158
+				continue;
1159
+			}
1160 1160
 
1161
-            if( $return_ids_only ){
1161
+			if( $return_ids_only ){
1162 1162
 
1163
-                $teachers_courses[] = $course->ID;
1163
+				$teachers_courses[] = $course->ID;
1164 1164
 
1165
-            }else{
1165
+			}else{
1166 1166
 
1167
-                $teachers_courses[] = $course;
1167
+				$teachers_courses[] = $course;
1168 1168
 
1169
-            }
1169
+			}
1170 1170
 
1171
-        }
1171
+		}
1172 1172
 
1173
-        return $teachers_courses;
1173
+		return $teachers_courses;
1174 1174
 
1175
-    }
1175
+	}
1176 1176
 
1177
-    /**
1178
-     * Limit the message display to only those sent to the current teacher
1179
-     *
1180
-     * @since 1.8.0
1181
-     *
1182
-     * @param $query
1183
-     * @return mixed
1184
-     */
1185
-    public function limit_edit_messages_query( $query ){
1186
-        if( ! $this->is_admin_teacher() || 'sensei_message' != $query->get('post_type') ){
1187
-            return $query;
1188
-        }
1189
-
1190
-        $teacher = wp_get_current_user();
1191
-
1192
-        $query->set( 'meta_key', '_receiver' );
1193
-        $meta_query_args = array(
1194
-            'key'     => '_receiver',
1195
-            'value'   => $teacher->get('user_login') ,
1196
-            'compare' => '='
1197
-        );
1177
+	/**
1178
+	 * Limit the message display to only those sent to the current teacher
1179
+	 *
1180
+	 * @since 1.8.0
1181
+	 *
1182
+	 * @param $query
1183
+	 * @return mixed
1184
+	 */
1185
+	public function limit_edit_messages_query( $query ){
1186
+		if( ! $this->is_admin_teacher() || 'sensei_message' != $query->get('post_type') ){
1187
+			return $query;
1188
+		}
1189
+
1190
+		$teacher = wp_get_current_user();
1191
+
1192
+		$query->set( 'meta_key', '_receiver' );
1193
+		$meta_query_args = array(
1194
+			'key'     => '_receiver',
1195
+			'value'   => $teacher->get('user_login') ,
1196
+			'compare' => '='
1197
+		);
1198 1198
 
1199
-        $query->set('meta_query', $meta_query_args  );
1199
+		$query->set('meta_query', $meta_query_args  );
1200 1200
 
1201
-        return $query;
1202
-    }
1201
+		return $query;
1202
+	}
1203 1203
 
1204 1204
 
1205
-    /**
1206
-     * Add options to filter courses by teacher
1207
-     *
1208
-     * @since 1.8.0
1209
-     *
1210
-     * @return void
1211
-     */
1212
-    public function course_teacher_filter_options() {
1213
-        global $typenow;
1205
+	/**
1206
+	 * Add options to filter courses by teacher
1207
+	 *
1208
+	 * @since 1.8.0
1209
+	 *
1210
+	 * @return void
1211
+	 */
1212
+	public function course_teacher_filter_options() {
1213
+		global $typenow;
1214 1214
 
1215
-        if( ! is_admin() || 'course' != $typenow || ! current_user_can('manage_sensei') ) {
1216
-            return;
1217
-        }
1215
+		if( ! is_admin() || 'course' != $typenow || ! current_user_can('manage_sensei') ) {
1216
+			return;
1217
+		}
1218 1218
 
1219
-        // get all roles
1220
-        $roles = get_editable_roles();
1219
+		// get all roles
1220
+		$roles = get_editable_roles();
1221 1221
 
1222
-        // get roles with the course edit capability
1223
-        // and then get the users with those roles
1224
-        $users_who_can_edit_courses = array();
1225
-        foreach( $roles as $role_item ){
1222
+		// get roles with the course edit capability
1223
+		// and then get the users with those roles
1224
+		$users_who_can_edit_courses = array();
1225
+		foreach( $roles as $role_item ){
1226 1226
 
1227
-            $role = get_role( strtolower( $role_item['name'] ) );
1227
+			$role = get_role( strtolower( $role_item['name'] ) );
1228 1228
 
1229
-            if( is_a( $role, 'WP_Role' ) && $role->has_cap('edit_courses') ){
1229
+			if( is_a( $role, 'WP_Role' ) && $role->has_cap('edit_courses') ){
1230 1230
 
1231
-                $user_query_args = array( 'role' => $role->name, 'fields' => array( 'ID', 'display_name' ) );
1232
-                $role_users_who_can_edit_courses = get_users( $user_query_args );
1231
+				$user_query_args = array( 'role' => $role->name, 'fields' => array( 'ID', 'display_name' ) );
1232
+				$role_users_who_can_edit_courses = get_users( $user_query_args );
1233 1233
 
1234
-                // add user from the current $user_role to all users
1235
-                $users_who_can_edit_courses = array_merge( $users_who_can_edit_courses, $role_users_who_can_edit_courses );
1234
+				// add user from the current $user_role to all users
1235
+				$users_who_can_edit_courses = array_merge( $users_who_can_edit_courses, $role_users_who_can_edit_courses );
1236 1236
 
1237
-            }
1237
+			}
1238 1238
 
1239
-        }
1239
+		}
1240 1240
 
1241
-        // Create the select element with the given users who can edit course
1242
-        $selected = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1243
-        $course_options = '';
1244
-        foreach( $users_who_can_edit_courses as $user ) {
1245
-            $course_options .= '<option value="' . esc_attr( $user->ID ) . '" ' . selected( $selected, $user->ID, false ) . '>' .  $user->display_name . '</option>';
1246
-        }
1241
+		// Create the select element with the given users who can edit course
1242
+		$selected = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1243
+		$course_options = '';
1244
+		foreach( $users_who_can_edit_courses as $user ) {
1245
+			$course_options .= '<option value="' . esc_attr( $user->ID ) . '" ' . selected( $selected, $user->ID, false ) . '>' .  $user->display_name . '</option>';
1246
+		}
1247 1247
 
1248
-        $output = '<select name="course_teacher" id="dropdown_course_teachers">';
1249
-        $output .= '<option value="">'.__( 'Show all teachers', 'woothemes-sensei' ).'</option>';
1250
-        $output .= $course_options;
1251
-        $output .= '</select>';
1248
+		$output = '<select name="course_teacher" id="dropdown_course_teachers">';
1249
+		$output .= '<option value="">'.__( 'Show all teachers', 'woothemes-sensei' ).'</option>';
1250
+		$output .= $course_options;
1251
+		$output .= '</select>';
1252 1252
 
1253
-        echo $output;
1254
-    }
1253
+		echo $output;
1254
+	}
1255 1255
 
1256
-    /**
1257
-     * Modify the main query on the admin course list screen
1258
-     *
1259
-     * @since 1.8.0
1260
-     *
1261
-     * @param $query
1262
-     * @return $query
1263
-     */
1264
-    public function teacher_filter_query_modify( $query ){
1265
-        global $typenow;
1256
+	/**
1257
+	 * Modify the main query on the admin course list screen
1258
+	 *
1259
+	 * @since 1.8.0
1260
+	 *
1261
+	 * @param $query
1262
+	 * @return $query
1263
+	 */
1264
+	public function teacher_filter_query_modify( $query ){
1265
+		global $typenow;
1266 1266
 
1267
-        if( ! is_admin() && 'course' != $typenow  || ! current_user_can('manage_sensei')  ) {
1268
-            return $query;
1269
-        }
1270
-        $course_teacher = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1271
-
1272
-        if( empty( $course_teacher ) ) {
1273
-            return $query;
1274
-        }
1275
-
1276
-        $query['author'] = $course_teacher;
1277
-        return $query;
1278
-    }
1279
-
1280
-    /**
1281
-     * Only show current teacher's media in the media library
1282
-     * @param  array $request Default request arguments
1283
-     * @return array          Modified request arguments
1284
-     */
1285
-    public function restrict_media_library( $request = array() ) {
1286
-
1287
-        if( ! is_admin() ) {
1288
-            return $request;
1289
-        }
1290
-
1291
-        if( ! $this->is_admin_teacher() ) {
1292
-            return $request;
1293
-        }
1294
-
1295
-        $screen = get_current_screen();
1296
-
1297
-        if( in_array( $screen->id, array( 'upload', 'course', 'lesson', 'question' ) ) ) {
1298
-            $teacher = intval( get_current_user_id() );
1299
-
1300
-            if( $teacher ) {
1301
-                $request['author__in'] = array( $teacher );
1302
-            }
1303
-        }
1304
-
1305
-        return $request;
1306
-    } // End restrict_media_library()
1307
-
1308
-    /**
1309
-     * Only show current teacher's media in the media library modal on the course/lesson/quesion edit screen
1310
-     * @param  array $query Default query arguments
1311
-     * @return array        Modified query arguments
1312
-     */
1313
-    public function restrict_media_library_modal( $query = array() ) {
1314
-
1315
-        if( ! is_admin() ) {
1316
-            return $query;
1317
-        }
1318
-
1319
-        if( ! $this->is_admin_teacher() ) {
1320
-            return $query;
1321
-        }
1322
-
1323
-        $teacher = intval( get_current_user_id() );
1324
-
1325
-        if( $teacher ) {
1326
-            $query['author__in'] = array( $teacher );
1327
-        }
1328
-
1329
-        return $query;
1330
-    } // End restrict_media_library_modal()
1331
-
1332
-    /**
1333
-     * When saving the lesson, update the teacher if the lesson belongs to a course
1334
-     *
1335
-     * @since 1.8.0
1336
-     *
1337
-     * @param int $lesson_id
1338
-     */
1339
-    public function update_lesson_teacher( $lesson_id ){
1340
-
1341
-        if( 'lesson'!= get_post_type() ){
1342
-            return;
1343
-        }
1267
+		if( ! is_admin() && 'course' != $typenow  || ! current_user_can('manage_sensei')  ) {
1268
+			return $query;
1269
+		}
1270
+		$course_teacher = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1271
+
1272
+		if( empty( $course_teacher ) ) {
1273
+			return $query;
1274
+		}
1275
+
1276
+		$query['author'] = $course_teacher;
1277
+		return $query;
1278
+	}
1279
+
1280
+	/**
1281
+	 * Only show current teacher's media in the media library
1282
+	 * @param  array $request Default request arguments
1283
+	 * @return array          Modified request arguments
1284
+	 */
1285
+	public function restrict_media_library( $request = array() ) {
1286
+
1287
+		if( ! is_admin() ) {
1288
+			return $request;
1289
+		}
1290
+
1291
+		if( ! $this->is_admin_teacher() ) {
1292
+			return $request;
1293
+		}
1294
+
1295
+		$screen = get_current_screen();
1296
+
1297
+		if( in_array( $screen->id, array( 'upload', 'course', 'lesson', 'question' ) ) ) {
1298
+			$teacher = intval( get_current_user_id() );
1299
+
1300
+			if( $teacher ) {
1301
+				$request['author__in'] = array( $teacher );
1302
+			}
1303
+		}
1304
+
1305
+		return $request;
1306
+	} // End restrict_media_library()
1307
+
1308
+	/**
1309
+	 * Only show current teacher's media in the media library modal on the course/lesson/quesion edit screen
1310
+	 * @param  array $query Default query arguments
1311
+	 * @return array        Modified query arguments
1312
+	 */
1313
+	public function restrict_media_library_modal( $query = array() ) {
1314
+
1315
+		if( ! is_admin() ) {
1316
+			return $query;
1317
+		}
1318
+
1319
+		if( ! $this->is_admin_teacher() ) {
1320
+			return $query;
1321
+		}
1322
+
1323
+		$teacher = intval( get_current_user_id() );
1324
+
1325
+		if( $teacher ) {
1326
+			$query['author__in'] = array( $teacher );
1327
+		}
1328
+
1329
+		return $query;
1330
+	} // End restrict_media_library_modal()
1331
+
1332
+	/**
1333
+	 * When saving the lesson, update the teacher if the lesson belongs to a course
1334
+	 *
1335
+	 * @since 1.8.0
1336
+	 *
1337
+	 * @param int $lesson_id
1338
+	 */
1339
+	public function update_lesson_teacher( $lesson_id ){
1340
+
1341
+		if( 'lesson'!= get_post_type() ){
1342
+			return;
1343
+		}
1344 1344
 
1345
-        // this should only run once per request cycle
1346
-        remove_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
1345
+		// this should only run once per request cycle
1346
+		remove_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
1347 1347
 
1348
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1348
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
1349 1349
 
1350
-        if(  empty( $course_id ) || ! $course_id ){
1351
-            return;
1352
-        }
1350
+		if(  empty( $course_id ) || ! $course_id ){
1351
+			return;
1352
+		}
1353 1353
 
1354
-        $course = get_post( $course_id );
1354
+		$course = get_post( $course_id );
1355 1355
 
1356
-        $lesson_update_args= array(
1357
-            'ID' => $lesson_id ,
1358
-            'post_author' => $course->post_author
1359
-        );
1360
-        wp_update_post( $lesson_update_args );
1356
+		$lesson_update_args= array(
1357
+			'ID' => $lesson_id ,
1358
+			'post_author' => $course->post_author
1359
+		);
1360
+		wp_update_post( $lesson_update_args );
1361 1361
 
1362
-    } // end update_lesson_teacher
1362
+	} // end update_lesson_teacher
1363 1363
 
1364
-    /**
1365
-     * Sensei_Teacher::limit_teacher_edit_screen_post_types
1366
-     *
1367
-     * Limit teachers to only see their courses, lessons and questions
1368
-     *
1369
-     * @since 1.8.0
1370
-     * @access public
1371
-     * @parameters array $wp_query
1372
-     * @return WP_Query $wp_query
1373
-     */
1374
-    public function limit_teacher_edit_screen_post_types( $wp_query ) {
1375
-        global $current_user;
1364
+	/**
1365
+	 * Sensei_Teacher::limit_teacher_edit_screen_post_types
1366
+	 *
1367
+	 * Limit teachers to only see their courses, lessons and questions
1368
+	 *
1369
+	 * @since 1.8.0
1370
+	 * @access public
1371
+	 * @parameters array $wp_query
1372
+	 * @return WP_Query $wp_query
1373
+	 */
1374
+	public function limit_teacher_edit_screen_post_types( $wp_query ) {
1375
+		global $current_user;
1376 1376
 
1377
-        //exit early
1378
-        if( ! $this->is_admin_teacher() ){
1379
-            return $wp_query;
1380
-        }
1377
+		//exit early
1378
+		if( ! $this->is_admin_teacher() ){
1379
+			return $wp_query;
1380
+		}
1381 1381
 
1382
-        if ( ! function_exists( 'get_current_screen' ) ) {
1383
-            return $wp_query;
1384
-        }
1382
+		if ( ! function_exists( 'get_current_screen' ) ) {
1383
+			return $wp_query;
1384
+		}
1385 1385
 
1386
-        $screen = get_current_screen();
1386
+		$screen = get_current_screen();
1387 1387
 
1388
-        if( empty( $screen ) ){
1389
-            return $wp_query;
1390
-        }
1388
+		if( empty( $screen ) ){
1389
+			return $wp_query;
1390
+		}
1391 1391
 
1392
-        // for any of these conditions limit what the teacher will see
1393
-        $limit_screens = array(
1394
-            'edit-lesson',
1395
-            'edit-course',
1396
-            'edit-question',
1397
-            'course_page_course-order',
1398
-            'lesson_page_lesson-order',
1399
-        );
1392
+		// for any of these conditions limit what the teacher will see
1393
+		$limit_screens = array(
1394
+			'edit-lesson',
1395
+			'edit-course',
1396
+			'edit-question',
1397
+			'course_page_course-order',
1398
+			'lesson_page_lesson-order',
1399
+		);
1400 1400
 
1401
-        if(  in_array($screen->id  , $limit_screens ) ) {
1401
+		if(  in_array($screen->id  , $limit_screens ) ) {
1402 1402
 
1403
-            // set the query author to the current user to only show those those posts
1404
-            $wp_query->set( 'author', $current_user->ID );
1405
-        }
1403
+			// set the query author to the current user to only show those those posts
1404
+			$wp_query->set( 'author', $current_user->ID );
1405
+		}
1406 1406
 
1407
-        return $wp_query;
1407
+		return $wp_query;
1408 1408
 
1409
-    } // end limit_teacher_edit_screen_post_types()
1409
+	} // end limit_teacher_edit_screen_post_types()
1410 1410
 
1411 1411
 
1412
-    /**
1413
-     * Sensei_Teacher::teacher_login_redirect
1414
-     *
1415
-     * Redirect teachers to /wp-admin/ after login
1416
-     *
1417
-     * @since 1.8.7
1418
-     * @access public
1419
-     * @param string $user_login
1420
-     * @param object $user
1421
-     * @return void
1422
-     */
1412
+	/**
1413
+	 * Sensei_Teacher::teacher_login_redirect
1414
+	 *
1415
+	 * Redirect teachers to /wp-admin/ after login
1416
+	 *
1417
+	 * @since 1.8.7
1418
+	 * @access public
1419
+	 * @param string $user_login
1420
+	 * @param object $user
1421
+	 * @return void
1422
+	 */
1423 1423
 
1424
-    public function teacher_login_redirect( $user_login, $user  ) {
1424
+	public function teacher_login_redirect( $user_login, $user  ) {
1425 1425
 
1426
-        if (user_can($user, 'edit_courses')) {
1426
+		if (user_can($user, 'edit_courses')) {
1427 1427
 
1428
-            if (isset($_POST['redirect_to'])) {
1428
+			if (isset($_POST['redirect_to'])) {
1429 1429
 
1430
-                wp_redirect($_POST['redirect_to'], 303);
1430
+				wp_redirect($_POST['redirect_to'], 303);
1431 1431
 
1432
-                exit;
1432
+				exit;
1433 1433
 
1434
-            } else {
1434
+			} else {
1435 1435
 
1436
-                wp_redirect(admin_url(), 303);
1436
+				wp_redirect(admin_url(), 303);
1437 1437
 
1438
-                exit;
1438
+				exit;
1439 1439
 
1440
-            }
1441
-        }
1440
+			}
1441
+		}
1442 1442
 
1443
-    } // end teacher_login_redirect()
1443
+	} // end teacher_login_redirect()
1444 1444
 
1445 1445
 
1446 1446
 
1447
-    /**
1448
-     * Sensei_Teacher::restrict_posts_menu_page()
1449
-     *
1450
-     * Remove the Posts menu page for teachers and restrict access to it.
1451
-     * We have to do this because we give teachers the 'edit_posts' cap
1452
-     * so they can 'moderate_comments' as well.
1453
-     *
1454
-     * @since 1.8.7
1455
-     * @access public
1456
-     * @parameters void
1457
-     * @return void
1458
-     */
1447
+	/**
1448
+	 * Sensei_Teacher::restrict_posts_menu_page()
1449
+	 *
1450
+	 * Remove the Posts menu page for teachers and restrict access to it.
1451
+	 * We have to do this because we give teachers the 'edit_posts' cap
1452
+	 * so they can 'moderate_comments' as well.
1453
+	 *
1454
+	 * @since 1.8.7
1455
+	 * @access public
1456
+	 * @parameters void
1457
+	 * @return void
1458
+	 */
1459 1459
 
1460
-    public function restrict_posts_menu_page() {
1460
+	public function restrict_posts_menu_page() {
1461 1461
 
1462
-        global $pagenow, $typenow;
1462
+		global $pagenow, $typenow;
1463 1463
 
1464
-        $user = wp_get_current_user();
1464
+		$user = wp_get_current_user();
1465 1465
 
1466
-        /**
1467
-         * Filter the option to hide the Posts menu page.
1468
-         *
1469
-         * @since 1.8.7
1470
-         *
1471
-         * @param bool $restrict default true
1472
-         */
1466
+		/**
1467
+		 * Filter the option to hide the Posts menu page.
1468
+		 *
1469
+		 * @since 1.8.7
1470
+		 *
1471
+		 * @param bool $restrict default true
1472
+		 */
1473 1473
 
1474
-        $restrict = apply_filters('sensei_restrict_posts_menu_page', true );
1474
+		$restrict = apply_filters('sensei_restrict_posts_menu_page', true );
1475 1475
 
1476
-        if ( in_array( 'teacher', (array) $user->roles ) && !current_user_can('delete_posts') && $restrict) {
1476
+		if ( in_array( 'teacher', (array) $user->roles ) && !current_user_can('delete_posts') && $restrict) {
1477 1477
 
1478
-            remove_menu_page('edit.php');
1478
+			remove_menu_page('edit.php');
1479 1479
 
1480
-            if ($pagenow == "edit.php" || $pagenow == "post-new.php") {
1480
+			if ($pagenow == "edit.php" || $pagenow == "post-new.php") {
1481 1481
 
1482
-                if ($typenow == '' || $typenow == 'post' || $typenow == 'page') {
1482
+				if ($typenow == '' || $typenow == 'post' || $typenow == 'page') {
1483 1483
 
1484
-                    wp_die('You do not have sufficient permissions to access this page.');
1484
+					wp_die('You do not have sufficient permissions to access this page.');
1485 1485
 
1486
-                }
1486
+				}
1487 1487
 
1488
-            }
1488
+			}
1489 1489
 
1490
-        }
1490
+		}
1491 1491
 
1492
-    } // end restrict_posts_menu_page()
1492
+	} // end restrict_posts_menu_page()
1493 1493
 
1494
-    /**
1495
-     * Sensei_Teacher::restrict_comment_moderation()
1496
-     *
1497
-     * Restrict commendation moderation for teachers
1498
-     * so they can only moderate comments made to posts they own.
1499
-     *
1500
-     * @since 1.8.7
1501
-     * @access public
1502
-     * @parameters obj $clauses
1503
-     * @return WP_Comment_Query  $clauses
1504
-     */
1494
+	/**
1495
+	 * Sensei_Teacher::restrict_comment_moderation()
1496
+	 *
1497
+	 * Restrict commendation moderation for teachers
1498
+	 * so they can only moderate comments made to posts they own.
1499
+	 *
1500
+	 * @since 1.8.7
1501
+	 * @access public
1502
+	 * @parameters obj $clauses
1503
+	 * @return WP_Comment_Query  $clauses
1504
+	 */
1505 1505
 
1506
-    public function restrict_comment_moderation ( $clauses ) {
1506
+	public function restrict_comment_moderation ( $clauses ) {
1507 1507
 
1508
-        global $pagenow;
1508
+		global $pagenow;
1509 1509
 
1510
-        if( self::is_a_teacher( get_current_user_id() ) && $pagenow == "edit-comments.php") {
1510
+		if( self::is_a_teacher( get_current_user_id() ) && $pagenow == "edit-comments.php") {
1511 1511
 
1512
-            $clauses->query_vars['post_author'] = get_current_user_id();
1512
+			$clauses->query_vars['post_author'] = get_current_user_id();
1513 1513
 
1514
-        }
1514
+		}
1515 1515
 
1516
-        return $clauses;
1516
+		return $clauses;
1517 1517
 
1518
-    }   // end restrict_comment_moderation()
1518
+	}   // end restrict_comment_moderation()
1519 1519
 
1520
-    /**
1521
-     * Determine if a user is a teacher by ID
1522
-     *
1523
-     * @param int $user_id
1524
-     *
1525
-     * @return bool
1526
-     */
1527
-    public static function is_a_teacher( $user_id ){
1520
+	/**
1521
+	 * Determine if a user is a teacher by ID
1522
+	 *
1523
+	 * @param int $user_id
1524
+	 *
1525
+	 * @return bool
1526
+	 */
1527
+	public static function is_a_teacher( $user_id ){
1528 1528
 
1529
-        $user = get_user_by('id', $user_id);
1529
+		$user = get_user_by('id', $user_id);
1530 1530
 
1531
-        if( isset( $user->roles ) && in_array(  'teacher',  $user->roles )   ){
1531
+		if( isset( $user->roles ) && in_array(  'teacher',  $user->roles )   ){
1532 1532
 
1533
-            return true;
1533
+			return true;
1534 1534
 
1535
-        }else{
1535
+		}else{
1536 1536
 
1537
-            return false;
1537
+			return false;
1538 1538
 
1539
-        }
1539
+		}
1540 1540
 
1541
-    }// end is_a_teacher
1541
+	}// end is_a_teacher
1542 1542
 
1543
-    /**
1544
-     * The archive title on the teacher archive filter
1545
-     *
1546
-     * @since 1.9.0
1547
-     */
1548
-    public static function archive_title(){
1543
+	/**
1544
+	 * The archive title on the teacher archive filter
1545
+	 *
1546
+	 * @since 1.9.0
1547
+	 */
1548
+	public static function archive_title(){
1549 1549
 
1550
-        $author = get_user_by( 'id', get_query_var( 'author' ) );
1551
-        $author_name = $author->display_name;
1552
-        ?>
1550
+		$author = get_user_by( 'id', get_query_var( 'author' ) );
1551
+		$author_name = $author->display_name;
1552
+		?>
1553 1553
             <h2 class="teacher-archive-title">
1554 1554
 
1555 1555
                 <?php echo sprintf( __( 'All courses by %s', 'woothemes-sensei') , $author_name ); ?>
@@ -1557,17 +1557,17 @@  discard block
 block discarded – undo
1557 1557
             </h2>
1558 1558
         <?php
1559 1559
 
1560
-    }// archive title
1560
+	}// archive title
1561 1561
 
1562
-    /**
1563
-     * Removing course meta on the teacher archive page
1564
-     *
1565
-     * @since 1.9.0
1566
-     */
1567
-    public static function remove_course_meta_on_teacher_archive(){
1562
+	/**
1563
+	 * Removing course meta on the teacher archive page
1564
+	 *
1565
+	 * @since 1.9.0
1566
+	 */
1567
+	public static function remove_course_meta_on_teacher_archive(){
1568 1568
 
1569
-        remove_action('sensei_course_content_inside_before', array( Sensei()->course, 'the_course_meta' ) );
1569
+		remove_action('sensei_course_content_inside_before', array( Sensei()->course, 'the_course_meta' ) );
1570 1570
 
1571
-    }
1571
+	}
1572 1572
 
1573 1573
 } // End Class
Please login to merge, or discard this patch.
Spacing   +283 added lines, -283 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 Teacher class
@@ -40,58 +40,58 @@  discard block
 block discarded – undo
40 40
      * @since 1.8.0
41 41
      * @access public
42 42
      */
43
-    public function __construct ( ) {
43
+    public function __construct( ) {
44 44
 
45
-        add_action( 'add_meta_boxes', array( $this , 'add_teacher_meta_boxes' ) , 10, 2 );
46
-        add_action( 'save_post',  array( $this, 'save_teacher_meta_box' ) );
47
-        add_filter( 'parse_query', array( $this, 'limit_teacher_edit_screen_post_types' ));
48
-        add_filter( 'pre_get_posts', array( $this, 'course_analysis_teacher_access_limit' ) );
49
-        add_filter( 'wp_count_posts', array( $this, 'list_table_counts' ), 10, 3 );
45
+        add_action('add_meta_boxes', array($this, 'add_teacher_meta_boxes'), 10, 2);
46
+        add_action('save_post', array($this, 'save_teacher_meta_box'));
47
+        add_filter('parse_query', array($this, 'limit_teacher_edit_screen_post_types'));
48
+        add_filter('pre_get_posts', array($this, 'course_analysis_teacher_access_limit'));
49
+        add_filter('wp_count_posts', array($this, 'list_table_counts'), 10, 3);
50 50
 
51
-        add_action( 'pre_get_posts', array( $this, 'filter_queries' ) );
51
+        add_action('pre_get_posts', array($this, 'filter_queries'));
52 52
 
53 53
         //filter the quiz submissions
54
-        add_filter( 'sensei_check_for_activity' , array( $this, 'filter_grading_activity_queries') );
54
+        add_filter('sensei_check_for_activity', array($this, 'filter_grading_activity_queries'));
55 55
 
56 56
         //grading totals count only those belonging to the teacher
57
-        add_filter('sensei_count_statuses_args', array( $this, 'limit_grading_totals' ) );
57
+        add_filter('sensei_count_statuses_args', array($this, 'limit_grading_totals'));
58 58
 
59 59
         // show the courses owned by a user on his author archive page
60
-        add_filter( 'pre_get_posts', array( $this, 'add_courses_to_author_archive' ) );
60
+        add_filter('pre_get_posts', array($this, 'add_courses_to_author_archive'));
61 61
 
62 62
         // notify admin when a teacher creates a course
63
-        add_action( 'transition_post_status',array( $this, 'notify_admin_teacher_course_creation' ), 10, 3 );
63
+        add_action('transition_post_status', array($this, 'notify_admin_teacher_course_creation'), 10, 3);
64 64
 
65 65
         // limit the analysis view to only the users taking courses belong to this teacher
66
-        add_filter( 'sensei_analysis_overview_filter_users',array( $this, 'limit_analysis_learners' ) , 5, 1 );
66
+        add_filter('sensei_analysis_overview_filter_users', array($this, 'limit_analysis_learners'), 5, 1);
67 67
 
68 68
         // give teacher access to question post type
69
-        add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20, 2 );
69
+        add_filter('sensei_lesson_quiz_questions', array($this, 'allow_teacher_access_to_questions'), 20, 2);
70 70
 
71 71
         // Teacher column on the courses list on the admin edit screen
72
-        add_filter('manage_edit-course_columns' , array( $this, 'course_column_heading'), 10,1 );
73
-        add_filter('manage_course_posts_custom_column' , array( $this, 'course_column_data'), 10,2 );
72
+        add_filter('manage_edit-course_columns', array($this, 'course_column_heading'), 10, 1);
73
+        add_filter('manage_course_posts_custom_column', array($this, 'course_column_data'), 10, 2);
74 74
 
75 75
         //admin edit messages query limit teacher
76
-        add_filter( 'pre_get_posts', array( $this, 'limit_edit_messages_query' ) );
76
+        add_filter('pre_get_posts', array($this, 'limit_edit_messages_query'));
77 77
 
78 78
         //add filter by teacher on courses list
79
-        add_action( 'restrict_manage_posts', array( $this, 'course_teacher_filter_options' ) );
80
-        add_filter( 'request', array( $this, 'teacher_filter_query_modify' ) );
79
+        add_action('restrict_manage_posts', array($this, 'course_teacher_filter_options'));
80
+        add_filter('request', array($this, 'teacher_filter_query_modify'));
81 81
 
82 82
         // Handle media library restrictions
83
-        add_filter( 'request', array( $this, 'restrict_media_library' ), 10, 1 );
84
-        add_filter( 'ajax_query_attachments_args', array( $this, 'restrict_media_library_modal' ), 10, 1 );
83
+        add_filter('request', array($this, 'restrict_media_library'), 10, 1);
84
+        add_filter('ajax_query_attachments_args', array($this, 'restrict_media_library_modal'), 10, 1);
85 85
 
86 86
         // update lesson owner to course teacher when saved
87
-        add_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
87
+        add_action('save_post', array($this, 'update_lesson_teacher'));
88 88
 
89 89
         // If a Teacher logs in, redirect to /wp-admin/
90
-        add_filter( 'wp_login', array( $this, 'teacher_login_redirect') , 10, 2 );
90
+        add_filter('wp_login', array($this, 'teacher_login_redirect'), 10, 2);
91 91
 
92 92
 
93
-        add_action( 'admin_menu', array( $this, 'restrict_posts_menu_page'), 10);
94
-        add_filter('pre_get_comments',  array ($this, 'restrict_comment_moderation'), 10, 1);
93
+        add_action('admin_menu', array($this, 'restrict_posts_menu_page'), 10);
94
+        add_filter('pre_get_comments', array($this, 'restrict_comment_moderation'), 10, 1);
95 95
 
96 96
 
97 97
     } // end __constructor()
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
      * @access public
107 107
      * @return void
108 108
      */
109
-    public function create_role ( ) {
109
+    public function create_role( ) {
110 110
 
111 111
         // check if the role exists
112
-        $this->teacher_role = get_role( 'teacher' );
112
+        $this->teacher_role = get_role('teacher');
113 113
 
114 114
         // if the the teacher is not a valid WordPress role create it
115
-       if ( ! is_a( $this->teacher_role, 'WP_Role' ) ) {
115
+       if ( ! is_a($this->teacher_role, 'WP_Role')) {
116 116
            // create the role
117
-           $this->teacher_role = add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ) );
117
+           $this->teacher_role = add_role('teacher', __('Teacher', 'woothemes-sensei'));
118 118
        }
119 119
 
120 120
        // add the capabilities before returning
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
      * @since 1.8.0
129 129
      * @access protected
130 130
      */
131
-    protected function add_capabilities ( ) {
131
+    protected function add_capabilities( ) {
132 132
 
133 133
         // if this is not a valid WP_Role object exit without adding anything
134
-        if(  ! is_a( $this->teacher_role, 'WP_Role' ) || empty( $this->teacher_role ) ) {
134
+        if ( ! is_a($this->teacher_role, 'WP_Role') || empty($this->teacher_role)) {
135 135
             return;
136 136
         }
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
          * @param array $capabilities
143 143
          * keys: (string) $cap_name => (bool) $grant
144 144
          */
145
-        $caps = apply_filters( 'sensei_teacher_role_capabilities', array(
145
+        $caps = apply_filters('sensei_teacher_role_capabilities', array(
146 146
             // General access rules
147 147
             'read' => true,
148 148
             'manage_sensei_grades' => true,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
         ));
201 201
 
202
-        foreach ( $caps as $cap => $grant ) {
202
+        foreach ($caps as $cap => $grant) {
203 203
 
204 204
             // load the capability on to the teacher role
205 205
             $this->teacher_role->add_cap($cap, $grant);
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
      * @parameter WP_Post $post
220 220
      * @return void
221 221
      */
222
-    public function add_teacher_meta_boxes ( $post ) {
222
+    public function add_teacher_meta_boxes($post) {
223 223
 
224
-        if( !current_user_can('manage_options') ){
224
+        if ( ! current_user_can('manage_options')) {
225 225
             return;
226 226
         }
227
-        add_meta_box( 'sensei-teacher',  __( 'Teacher' , 'woothemes-sensei'),  array( $this , 'teacher_meta_box_content' ),
227
+        add_meta_box('sensei-teacher', __('Teacher', 'woothemes-sensei'), array($this, 'teacher_meta_box_content'),
228 228
             'course',
229 229
             'side',
230 230
             'core'
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      * @access public
242 242
      * @parameters
243 243
      */
244
-    public function teacher_meta_box_content ( $post ) {
244
+    public function teacher_meta_box_content($post) {
245 245
 
246 246
         // get the current author
247 247
         $current_author = $post->post_author;
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
     ?>
253 253
         <select name="sensei-course-teacher-author" class="sensei course teacher">
254 254
 
255
-            <?php foreach ( $users as $user_id ) { ?>
255
+            <?php foreach ($users as $user_id) { ?>
256 256
 
257 257
                     <?php
258 258
                         $user = get_user_by('id', $user_id);
259 259
                     ?>
260
-                    <option <?php selected(  $current_author , $user_id , true ); ?> value="<?php echo $user_id; ?>" >
260
+                    <option <?php selected($current_author, $user_id, true); ?> value="<?php echo $user_id; ?>" >
261 261
                         <?php echo  $user->display_name; ?>
262 262
                     </option>
263 263
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      * @parameters
280 280
      * @return array $users user id array
281 281
      */
282
-    public function get_teachers_and_authors ( ){
282
+    public function get_teachers_and_authors( ) {
283 283
 
284 284
         $author_query_args = array(
285 285
             'blog_id'      => $GLOBALS['blog_id'],
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
             'who'          => 'authors'
288 288
         );
289 289
 
290
-        $authors = get_users( $author_query_args );
290
+        $authors = get_users($author_query_args);
291 291
 
292 292
         $teacher_query_args = array(
293 293
             'blog_id'      => $GLOBALS['blog_id'],
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
             'role'         => 'teacher',
296 296
         );
297 297
 
298
-        $teachers = get_users( $teacher_query_args );
298
+        $teachers = get_users($teacher_query_args);
299 299
 
300
-        return  array_unique( array_merge( $teachers, $authors ) );
300
+        return  array_unique(array_merge($teachers, $authors));
301 301
 
302 302
     }// end get_teachers_and_authors
303 303
 
@@ -313,43 +313,43 @@  discard block
 block discarded – undo
313 313
      * @parameters
314 314
      * @return array $users user id array
315 315
      */
316
-    public function save_teacher_meta_box ( $course_id ){
316
+    public function save_teacher_meta_box($course_id) {
317 317
 
318 318
         // check if this is a post from saving the teacher, if not exit early
319
-        if(! isset( $_POST[ 'sensei-course-teacher-author' ] ) || ! isset( $_POST['post_ID'] )  ){
319
+        if ( ! isset($_POST['sensei-course-teacher-author']) || ! isset($_POST['post_ID'])) {
320 320
             return;
321 321
         }
322 322
 
323 323
         //don't fire this hook again
324
-        remove_action('save_post', array( $this, 'save_teacher_meta_box' ) );
324
+        remove_action('save_post', array($this, 'save_teacher_meta_box'));
325 325
 
326 326
         // get the current post object
327
-        $post = get_post( $course_id );
327
+        $post = get_post($course_id);
328 328
 
329 329
         // get the current teacher/author
330
-        $current_author = absint( $post->post_author );
331
-        $new_author = absint( $_POST[ 'sensei-course-teacher-author' ] );
330
+        $current_author = absint($post->post_author);
331
+        $new_author = absint($_POST['sensei-course-teacher-author']);
332 332
 
333 333
         // loop through all post lessons to update their authors as well
334
-        $this->update_course_lessons_author( $course_id , $new_author );
334
+        $this->update_course_lessons_author($course_id, $new_author);
335 335
 
336 336
         // do not do any processing if the selected author is the same as the current author
337
-        if( $current_author == $new_author ){
337
+        if ($current_author == $new_author) {
338 338
             return;
339 339
         }
340 340
 
341 341
         // save the course  author
342 342
         $post_updates = array(
343
-            'ID' => $post->ID ,
343
+            'ID' => $post->ID,
344 344
             'post_author' => $new_author
345 345
         );
346
-        wp_update_post( $post_updates );
346
+        wp_update_post($post_updates);
347 347
 
348 348
         // ensure the the modules are update so that then new teacher has access to them
349
-        Sensei_Teacher::update_course_modules_author( $course_id, $new_author );
349
+        Sensei_Teacher::update_course_modules_author($course_id, $new_author);
350 350
 
351 351
         // notify the new teacher
352
-        $this->teacher_course_assigned_notification( $new_author, $course_id );
352
+        $this->teacher_course_assigned_notification($new_author, $course_id);
353 353
 
354 354
     } // end save_teacher_meta_box
355 355
 
@@ -363,56 +363,56 @@  discard block
 block discarded – undo
363 363
      * @param $new_teacher_id
364 364
      * @return void
365 365
      */
366
-    public static function update_course_modules_author( $course_id ,$new_teacher_id ){
366
+    public static function update_course_modules_author($course_id, $new_teacher_id) {
367 367
 
368
-        if( empty( $course_id ) || empty( $new_teacher_id ) ){
368
+        if (empty($course_id) || empty($new_teacher_id)) {
369 369
             return;
370 370
         }
371 371
 
372
-        $terms_selected_on_course = wp_get_object_terms( $course_id, 'module' );
372
+        $terms_selected_on_course = wp_get_object_terms($course_id, 'module');
373 373
 
374
-        if( empty( $terms_selected_on_course ) ){
374
+        if (empty($terms_selected_on_course)) {
375 375
             return;
376 376
         }
377 377
 
378
-        foreach( $terms_selected_on_course as $term ){
378
+        foreach ($terms_selected_on_course as $term) {
379 379
 
380
-            $term_author = Sensei_Core_Modules::get_term_author( $term->slug );
381
-            if( $new_teacher_id != $term_author->ID  ){
380
+            $term_author = Sensei_Core_Modules::get_term_author($term->slug);
381
+            if ($new_teacher_id != $term_author->ID) {
382 382
 
383 383
                 $new_term = '';
384 384
 
385 385
                 //if the new teacher is admin first check to see if the term with this name already exists
386
-                if( user_can( $new_teacher_id, 'manage_options' ) ){
386
+                if (user_can($new_teacher_id, 'manage_options')) {
387 387
 
388
-                    $slug_without_teacher_id = str_ireplace(' ', '-', trim( $term->name ) );
389
-                    $term_args = array( 'slug'=> $slug_without_teacher_id, 'hide_empty' => false, );
390
-                    $existing_admin_terms = get_terms( 'module', $term_args );
391
-                    if( !empty( $existing_admin_terms ) ){
388
+                    $slug_without_teacher_id = str_ireplace(' ', '-', trim($term->name));
389
+                    $term_args = array('slug'=> $slug_without_teacher_id, 'hide_empty' => false,);
390
+                    $existing_admin_terms = get_terms('module', $term_args);
391
+                    if ( ! empty($existing_admin_terms)) {
392 392
                         // insert it even if it exists
393
-                        $new_term = get_term( $existing_admin_terms[0]->term_id, 'module', ARRAY_A );
393
+                        $new_term = get_term($existing_admin_terms[0]->term_id, 'module', ARRAY_A);
394 394
                     }
395 395
                 }
396 396
 
397
-                if( empty ( $new_term ) ){
397
+                if (empty ($new_term)) {
398 398
 
399 399
                    //setup the new slug
400
-                   $new_author_term_slug =  $new_teacher_id . '-' . str_ireplace(' ', '-', trim( $term->name ) );
400
+                   $new_author_term_slug = $new_teacher_id.'-'.str_ireplace(' ', '-', trim($term->name));
401 401
 
402 402
                    // create new term and set it
403
-                   $new_term = wp_insert_term( $term->name,'module', array('slug'=> $new_author_term_slug )  );
403
+                   $new_term = wp_insert_term($term->name, 'module', array('slug'=> $new_author_term_slug));
404 404
 
405 405
                 }
406 406
 
407 407
 
408 408
 
409 409
                 // if term exists
410
-                if( is_wp_error( $new_term ) && isset( $new_term->errors['term_exists'] ) ){
410
+                if (is_wp_error($new_term) && isset($new_term->errors['term_exists'])) {
411 411
 
412
-                    $existing_term = get_term_by( 'slug', $new_author_term_slug, 'module');
412
+                    $existing_term = get_term_by('slug', $new_author_term_slug, 'module');
413 413
                     $term_id = $existing_term->term_id;
414 414
 
415
-                }else{
415
+                } else {
416 416
 
417 417
                     // for a new term simply get the term from the returned value
418 418
                     $term_id = $new_term['term_id'];
@@ -420,21 +420,21 @@  discard block
 block discarded – undo
420 420
                 } // end if term exist
421 421
 
422 422
                 // set the terms selected on the course
423
-                wp_set_object_terms( $course_id, $term_id , 'module', true );
423
+                wp_set_object_terms($course_id, $term_id, 'module', true);
424 424
 
425 425
                 // remove old term
426
-                wp_remove_object_terms( $course_id, $term->term_id, 'module' );
426
+                wp_remove_object_terms($course_id, $term->term_id, 'module');
427 427
 
428 428
                 // update the lessons within the current module term
429
-                $lessons = Sensei()->course->course_lessons( $course_id );
430
-                foreach( $lessons as $lesson  ){
429
+                $lessons = Sensei()->course->course_lessons($course_id);
430
+                foreach ($lessons as $lesson) {
431 431
 
432
-                    if( has_term( $term->slug, 'module', $lesson ) ){
432
+                    if (has_term($term->slug, 'module', $lesson)) {
433 433
 
434 434
                         // add the new term, the false at the end says to replace all terms on this module
435 435
                         // with the new term.
436
-                        wp_set_object_terms( $lesson->ID, $term_id , 'module', false );
437
-                        update_post_meta( $lesson->ID, '_order_module_' . intval( $term_id ), 0 );
436
+                        wp_set_object_terms($lesson->ID, $term_id, 'module', false);
437
+                        update_post_meta($lesson->ID, '_order_module_'.intval($term_id), 0);
438 438
                     }
439 439
 
440 440
                 }// end for each
@@ -454,50 +454,50 @@  discard block
 block discarded – undo
454 454
      * @parameters
455 455
      * @return array $users user id array
456 456
      */
457
-    public function update_course_lessons_author ( $course_id, $new_author  ){
457
+    public function update_course_lessons_author($course_id, $new_author) {
458 458
 
459 459
 
460
-        if( empty( $course_id ) || empty( $new_author ) ){
460
+        if (empty($course_id) || empty($new_author)) {
461 461
             return false;
462 462
         }
463 463
 
464 464
         //get a list of course lessons
465
-        $lessons = Sensei()->course->course_lessons( $course_id );
465
+        $lessons = Sensei()->course->course_lessons($course_id);
466 466
 
467
-        if( empty( $lessons )  ||  ! is_array( $lessons )  ){
467
+        if (empty($lessons) || ! is_array($lessons)) {
468 468
             return false;
469 469
         }
470 470
 
471 471
         // update each lesson and quiz author
472
-        foreach( $lessons as $lesson ){
472
+        foreach ($lessons as $lesson) {
473 473
 
474 474
             // don't update if the author is tha same as the new author
475
-            if( $new_author == $lesson->post_author ){
475
+            if ($new_author == $lesson->post_author) {
476 476
                 continue;
477 477
             }
478 478
 
479 479
             // update lesson author
480
-            wp_update_post( array(
480
+            wp_update_post(array(
481 481
                 'ID'=> $lesson->ID,
482 482
                 'post_author' => $new_author
483
-                ) );
483
+                ));
484 484
 
485 485
             // update quiz author
486 486
             //get the lessons quiz
487
-            $lesson_quizzes = Sensei()->lesson->lesson_quizzes( $lesson->ID );
488
-            if( is_array( $lesson_quizzes ) ){
489
-                foreach ( $lesson_quizzes as $quiz_id ) {
487
+            $lesson_quizzes = Sensei()->lesson->lesson_quizzes($lesson->ID);
488
+            if (is_array($lesson_quizzes)) {
489
+                foreach ($lesson_quizzes as $quiz_id) {
490 490
                     // update quiz with new author
491
-                    wp_update_post( array(
491
+                    wp_update_post(array(
492 492
                         'ID'           => $quiz_id,
493 493
                         'post_author' =>  $new_author
494
-                    ) );
494
+                    ));
495 495
                 }
496
-            }else{
497
-                wp_update_post( array(
496
+            } else {
497
+                wp_update_post(array(
498 498
                     'ID'           => $lesson_quizzes,
499 499
                     'post_author' =>  $new_author
500
-                ) );
500
+                ));
501 501
             }
502 502
 
503 503
         } // end for each lessons
@@ -518,30 +518,30 @@  discard block
 block discarded – undo
518 518
      * @parameters $query
519 519
      * @return array $users user id array
520 520
      */
521
-    public function course_analysis_teacher_access_limit ( $query ) {
521
+    public function course_analysis_teacher_access_limit($query) {
522 522
 
523
-        if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
523
+        if ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
524 524
             return $query;
525 525
         }
526 526
 
527
-        if ( ! function_exists( 'get_current_screen' ) ) {
527
+        if ( ! function_exists('get_current_screen')) {
528 528
             return $query;
529 529
         }
530 530
 
531 531
         $screen = get_current_screen();
532
-        $sensei_post_types = array('course', 'lesson', 'question' );
532
+        $sensei_post_types = array('course', 'lesson', 'question');
533 533
 
534 534
         // exit early for the following conditions
535
-        $limit_screen_ids = array( 'sensei_page_sensei_analysis', 'course_page_module-order' );
535
+        $limit_screen_ids = array('sensei_page_sensei_analysis', 'course_page_module-order');
536 536
 
537
-        if( ! $this->is_admin_teacher() || empty( $screen ) || ! in_array( $screen->id ,$limit_screen_ids )
538
-            || ! in_array( $query->query['post_type'], $sensei_post_types ) ){
537
+        if ( ! $this->is_admin_teacher() || empty($screen) || ! in_array($screen->id, $limit_screen_ids)
538
+            || ! in_array($query->query['post_type'], $sensei_post_types)) {
539 539
             return $query;
540 540
         }
541 541
 
542 542
         global $current_user;
543 543
         // set the query author to the current user to only show those those posts
544
-        $query->set( 'author', $current_user->ID );
544
+        $query->set('author', $current_user->ID);
545 545
         return $query;
546 546
 
547 547
     }// end course_analysis_teacher_access_limit
@@ -557,14 +557,14 @@  discard block
 block discarded – undo
557 557
      * @parameters array $wp_query
558 558
      * @return bool $is_admin_teacher
559 559
      */
560
-    public function is_admin_teacher ( ){
560
+    public function is_admin_teacher( ) {
561 561
 
562
-        if( ! is_user_logged_in()){
562
+        if ( ! is_user_logged_in()) {
563 563
             return false;
564 564
         }
565 565
         $is_admin_teacher = false;
566 566
 
567
-        if( is_admin() && Sensei_Teacher::is_a_teacher( get_current_user_id() )  ){
567
+        if (is_admin() && Sensei_Teacher::is_a_teacher(get_current_user_id())) {
568 568
 
569 569
             $is_admin_teacher = true;
570 570
 
@@ -584,14 +584,14 @@  discard block
 block discarded – undo
584 584
      * @param  string $perm   User permission level
585 585
      * @return object         Modified status counts
586 586
      */
587
-    public function list_table_counts( $counts, $type, $perm ) {
587
+    public function list_table_counts($counts, $type, $perm) {
588 588
         global $current_user;
589 589
 
590
-        if( ! in_array( $type, array( 'course', 'lesson', 'question' ) ) ) {
590
+        if ( ! in_array($type, array('course', 'lesson', 'question'))) {
591 591
             return $counts;
592 592
         }
593 593
 
594
-        if( ! $this->is_admin_teacher() ) {
594
+        if ( ! $this->is_admin_teacher()) {
595 595
             return $counts;
596 596
         }
597 597
 
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
         $stati = get_post_stati();
606 606
 
607 607
         // Update count object
608
-        foreach( $stati as $status ) {
608
+        foreach ($stati as $status) {
609 609
             $args['post_status'] = $status;
610
-            $posts = get_posts( $args );
611
-            $counts->$status = count( $posts );
610
+            $posts = get_posts($args);
611
+            $counts->$status = count($posts);
612 612
         }
613 613
 
614 614
         return $counts;
@@ -622,22 +622,22 @@  discard block
 block discarded – undo
622 622
      * @since 1.8.0
623 623
      *
624 624
      */
625
-    public function filter_queries ( $query ) {
625
+    public function filter_queries($query) {
626 626
         global $current_user;
627 627
 
628
-        if( ! $this->is_admin_teacher() ) {
628
+        if ( ! $this->is_admin_teacher()) {
629 629
             return;
630 630
         }
631 631
 
632
-        if ( ! function_exists( 'get_current_screen' ) ) {
632
+        if ( ! function_exists('get_current_screen')) {
633 633
             return;
634 634
         }
635 635
 
636 636
         $screen = get_current_screen();
637
-        if( empty( $screen ) ) {
637
+        if (empty($screen)) {
638 638
             return $query;
639 639
         }
640
-        switch( $screen->id ) {
640
+        switch ($screen->id) {
641 641
             case 'sensei_page_sensei_grading':
642 642
             case 'sensei_page_sensei_analysis':
643 643
             case 'sensei_page_sensei_learners':
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
              * @param string $screen_id
657 657
              *
658 658
              */
659
-            $query->set( 'author', apply_filters( 'sensei_filter_queries_set_author', $current_user->ID, $screen->id ) );
659
+            $query->set('author', apply_filters('sensei_filter_queries_set_author', $current_user->ID, $screen->id));
660 660
             break;
661 661
         }
662 662
     }
@@ -671,31 +671,31 @@  discard block
 block discarded – undo
671 671
      *
672 672
      * @return array $comments
673 673
      */
674
-    public function filter_grading_activity_queries( $comments ){
674
+    public function filter_grading_activity_queries($comments) {
675 675
 
676
-        if( !is_admin() || ! $this->is_admin_teacher() || is_numeric( $comments ) || ! is_array( $comments ) ){
677
-            return $comments ;
676
+        if ( ! is_admin() || ! $this->is_admin_teacher() || is_numeric($comments) || ! is_array($comments)) {
677
+            return $comments;
678 678
         }
679 679
 
680 680
         //check if we're on the grading screen
681 681
         $screen = get_current_screen();
682 682
 
683
-        if( empty( $screen ) || 'sensei_page_sensei_grading' != $screen->id ){
683
+        if (empty($screen) || 'sensei_page_sensei_grading' != $screen->id) {
684 684
             return $comments;
685 685
         }
686 686
 
687 687
         // get the course and determine if the current teacher is the owner
688 688
         // if not remove it from the list of comments to be returned
689
-        foreach( $comments as $key => $comment){
690
-            $lesson = get_post( $comment->comment_post_ID );
691
-            $course_id = Sensei()->lesson->get_course_id( $lesson->ID );
692
-            $course = get_post( $course_id );
693
-            if( ! isset( $course->post_author ) || intval( $course->post_author) != intval( get_current_user_id() ) ){
689
+        foreach ($comments as $key => $comment) {
690
+            $lesson = get_post($comment->comment_post_ID);
691
+            $course_id = Sensei()->lesson->get_course_id($lesson->ID);
692
+            $course = get_post($course_id);
693
+            if ( ! isset($course->post_author) || intval($course->post_author) != intval(get_current_user_id())) {
694 694
                 //remove this as the teacher should see this.
695
-                unset( $comments[ $key ] );
695
+                unset($comments[$key]);
696 696
             }
697 697
         }
698
-        return $comments ;
698
+        return $comments;
699 699
 
700 700
     }// end function filter grading
701 701
 
@@ -711,34 +711,34 @@  discard block
 block discarded – undo
711 711
      *
712 712
      * @return array  $args
713 713
      */
714
-    public function limit_grading_totals( $args ){
714
+    public function limit_grading_totals($args) {
715 715
 
716
-        if( !is_admin() || ! $this->is_admin_teacher() || ! is_array( $args ) ){
717
-            return $args ;
716
+        if ( ! is_admin() || ! $this->is_admin_teacher() || ! is_array($args)) {
717
+            return $args;
718 718
         }
719 719
 
720 720
         //get the teachers courses
721 721
         // the query is already filtered to only the teacher
722
-        $courses =  Sensei()->course->get_all_courses();
722
+        $courses = Sensei()->course->get_all_courses();
723 723
 
724
-        if( empty(  $courses ) || ! is_array( $courses ) ){
724
+        if (empty($courses) || ! is_array($courses)) {
725 725
             return $args;
726 726
         }
727 727
 
728 728
         //setup the lessons quizzes  to limit the grading totals to
729 729
         $quiz_scope = array();
730
-        foreach( $courses as $course ){
730
+        foreach ($courses as $course) {
731 731
 
732
-            $course_lessons = Sensei()->course->course_lessons( $course->ID );
732
+            $course_lessons = Sensei()->course->course_lessons($course->ID);
733 733
 
734
-            if( ! empty( $course_lessons ) && is_array( $course_lessons  ) ){
734
+            if ( ! empty($course_lessons) && is_array($course_lessons)) {
735 735
 
736
-                foreach(  $course_lessons as $lesson ){
736
+                foreach ($course_lessons as $lesson) {
737 737
 
738
-                    $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID );
739
-                    if( !empty( $quiz_id ) ) {
738
+                    $quiz_id = Sensei()->lesson->lesson_quizzes($lesson->ID);
739
+                    if ( ! empty($quiz_id)) {
740 740
 
741
-                        array_push( $quiz_scope, $quiz_id );
741
+                        array_push($quiz_scope, $quiz_id);
742 742
 
743 743
                     }
744 744
 
@@ -761,41 +761,41 @@  discard block
 block discarded – undo
761 761
      * @param WP_Query $query
762 762
      * @return WP_Query $query
763 763
      */
764
-    public function add_courses_to_author_archive( $query ) {
764
+    public function add_courses_to_author_archive($query) {
765 765
 
766
-        if ( is_admin() || ! $query->is_author() ){
766
+        if (is_admin() || ! $query->is_author()) {
767 767
             return $query;
768 768
         }
769 769
 
770 770
         // this should only apply to users with the teacher role
771
-        $current_page_user = get_user_by('login', $query->get('author_name') );
772
-        if( ! $current_page_user || ! in_array('teacher', $current_page_user->roles ) )     {
771
+        $current_page_user = get_user_by('login', $query->get('author_name'));
772
+        if ( ! $current_page_user || ! in_array('teacher', $current_page_user->roles)) {
773 773
 
774 774
             return $query;
775 775
 
776 776
         }
777 777
 
778 778
         // Change post types depending on what is set already
779
-        $current_post_types = $query->get( 'post_type' );
780
-        if( empty( $current_post_types  ) ){
779
+        $current_post_types = $query->get('post_type');
780
+        if (empty($current_post_types)) {
781 781
 
782 782
             // if empty it means post by default, so add post so that it also includes that for now
783
-            $new_post_types = array( 'post', 'course' );
783
+            $new_post_types = array('post', 'course');
784 784
 
785
-        } elseif( is_array( $current_post_types  ) ) {
785
+        } elseif (is_array($current_post_types)) {
786 786
 
787 787
             // merge the post types instead of overwriting it
788
-            $new_post_types = array_merge( $current_post_types, array( 'course' ) );
788
+            $new_post_types = array_merge($current_post_types, array('course'));
789 789
 
790
-        }else{
790
+        } else {
791 791
 
792 792
             // in this instance it is probably just one post type in string format
793
-            $new_post_types =  array( $current_post_types , 'course');
793
+            $new_post_types = array($current_post_types, 'course');
794 794
 
795 795
         }
796 796
 
797 797
         // change the query before returning it
798
-        $query->set('post_type', $new_post_types );
798
+        $query->set('post_type', $new_post_types);
799 799
 
800 800
         /**
801 801
          * Change the query on the teacher author archive template
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
          * @since 1.8.4
804 804
          * @param WP_Query $query
805 805
          */
806
-        return apply_filters( 'sensei_teacher_archive_query', $query );
806
+        return apply_filters('sensei_teacher_archive_query', $query);
807 807
 
808 808
     }
809 809
 
@@ -816,21 +816,21 @@  discard block
 block discarded – undo
816 816
      * @param $course_id
817 817
      * @return bool
818 818
      */
819
-    public function teacher_course_assigned_notification( $teacher_id, $course_id ){
819
+    public function teacher_course_assigned_notification($teacher_id, $course_id) {
820 820
 
821
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $teacher_id ) ){
821
+        if ('course' != get_post_type($course_id) || ! get_userdata($teacher_id)) {
822 822
             return false;
823 823
         }
824 824
 
825 825
         // if new user is the same as the current logged user, they don't need an email
826
-        if( $teacher_id == get_current_user_id() ){
826
+        if ($teacher_id == get_current_user_id()) {
827 827
             return true;
828 828
         }
829 829
 
830 830
         // load the email class
831 831
         include('emails/class-sensei-email-teacher-new-course-assignment.php');
832 832
         $email = new Sensei_Email_Teacher_New_Course_Assignment();
833
-        $email->trigger( $teacher_id, $course_id );
833
+        $email->trigger($teacher_id, $course_id);
834 834
 
835 835
         return true;
836 836
     } // end  teacher_course_assigned_notification
@@ -844,12 +844,12 @@  discard block
 block discarded – undo
844 844
      * @param int $course_id
845 845
      * @return bool
846 846
      */
847
-    public function notify_admin_teacher_course_creation( $new_status, $old_status, $post ){
847
+    public function notify_admin_teacher_course_creation($new_status, $old_status, $post) {
848 848
 
849 849
         $course_id = $post->ID;
850 850
 
851
-        if( 'course' != get_post_type( $course_id ) || 'auto-draft' == get_post_status( $course_id )
852
-            || 'trash' == get_post_status( $course_id ) || 'draft' == get_post_status( $course_id ) ) {
851
+        if ('course' != get_post_type($course_id) || 'auto-draft' == get_post_status($course_id)
852
+            || 'trash' == get_post_status($course_id) || 'draft' == get_post_status($course_id)) {
853 853
 
854 854
             return false;
855 855
 
@@ -863,19 +863,19 @@  discard block
 block discarded – undo
863 863
          *
864 864
          * @param bool $on default true
865 865
          */
866
-        if( ! apply_filters('sensei_notify_admin_new_course_creation', true ) ){
866
+        if ( ! apply_filters('sensei_notify_admin_new_course_creation', true)) {
867 867
             return false;
868 868
         }
869 869
 
870 870
         // setting up the data needed by the email template
871 871
         global $sensei_email_data;
872 872
         $template = 'admin-teacher-new-course-created';
873
-        $course = get_post( $course_id );
874
-        $teacher = new WP_User( $course->post_author );
873
+        $course = get_post($course_id);
874
+        $teacher = new WP_User($course->post_author);
875 875
         $recipient = get_option('admin_email', true);
876 876
 
877 877
         // don't send if the course is created by admin
878
-        if( $recipient == $teacher->user_email ){
878
+        if ($recipient == $teacher->user_email) {
879 879
             return;
880 880
         }
881 881
 
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
          * @since 1.8.0
886 886
          * @param string $template
887 887
          */
888
-        $heading = apply_filters( 'sensei_email_heading', __( 'New course created.', 'woothemes-sensei' ), $template );
888
+        $heading = apply_filters('sensei_email_heading', __('New course created.', 'woothemes-sensei'), $template);
889 889
 
890 890
         /**
891 891
          * Filter the email subject for the the
@@ -896,11 +896,11 @@  discard block
 block discarded – undo
896 896
          * @param string $template
897 897
          */
898 898
         $subject = apply_filters('sensei_email_subject',
899
-                                '['. get_bloginfo( 'name', 'display' ) .'] '. __( 'New course created by', 'woothemes-sensei' ) . ' ' . $teacher->display_name ,
900
-                                $template );
899
+                                '['.get_bloginfo('name', 'display').'] '.__('New course created by', 'woothemes-sensei').' '.$teacher->display_name,
900
+                                $template);
901 901
 
902 902
         //course edit link
903
-        $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' );
903
+        $course_edit_link = admin_url('post.php?post='.$course_id.'&action=edit');
904 904
 
905 905
         // Construct data array
906 906
         $email_data = array(
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
          * @param array $email_data
920 920
          * @param string $template
921 921
          */
922
-        $sensei_email_data = apply_filters( 'sensei_email_data', $email_data , $template );
922
+        $sensei_email_data = apply_filters('sensei_email_data', $email_data, $template);
923 923
 
924 924
         // Send mail
925
-        Sensei()->emails->send( $recipient, $subject , Sensei()->emails->get_content( $template ) );
925
+        Sensei()->emails->send($recipient, $subject, Sensei()->emails->get_content($template));
926 926
 
927 927
     }// end notify admin of course creation
928 928
 
@@ -933,10 +933,10 @@  discard block
 block discarded – undo
933 933
      * @param array $args WP_User_Query arguments
934 934
      * @return array $learners_query_results
935 935
      */
936
-    public function limit_analysis_learners( $args ){
936
+    public function limit_analysis_learners($args) {
937 937
 
938 938
         // show default for none teachers
939
-        if( ! Sensei()->teacher->is_admin_teacher() ) {
939
+        if ( ! Sensei()->teacher->is_admin_teacher()) {
940 940
                 return $args;
941 941
         }
942 942
 
@@ -945,31 +945,31 @@  discard block
 block discarded – undo
945 945
         $teacher_courses = Sensei()->course->get_all_courses();
946 946
 
947 947
         // if the user has no courses they should see no users
948
-        if( empty( $teacher_courses ) ||  ! is_array( $teacher_courses ) ){
948
+        if (empty($teacher_courses) || ! is_array($teacher_courses)) {
949 949
             // tell the query to return 0 students
950
-            $args[ 'include'] = array( 0 );
950
+            $args['include'] = array(0);
951 951
             return $args;
952 952
 
953 953
         }
954 954
 
955 955
         $learner_ids_for_teacher_courses = array();
956
-        foreach( $teacher_courses as $course ){
956
+        foreach ($teacher_courses as $course) {
957 957
 
958 958
             $course_learner_ids = array();
959
-            $activity_comments =  Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course->ID, 'type' => 'sensei_course_status', 'field' => 'user_id' ), true );
959
+            $activity_comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $course->ID, 'type' => 'sensei_course_status', 'field' => 'user_id'), true);
960 960
 
961
-            if( empty( $activity_comments ) ||  ( is_array( $activity_comments  ) && ! ( count( $activity_comments ) > 0 ) ) ){
961
+            if (empty($activity_comments) || (is_array($activity_comments) && ! (count($activity_comments) > 0))) {
962 962
                 continue; // skip to the next course as there are no users on this course
963 963
             }
964 964
 
965 965
             // it could be an array of comments or a single comment
966
-            if( is_array( $activity_comments ) ){
966
+            if (is_array($activity_comments)) {
967 967
 
968
-                foreach( $activity_comments as $comment ){
968
+                foreach ($activity_comments as $comment) {
969 969
 
970
-                    $user = get_userdata( $comment->user_id );
970
+                    $user = get_userdata($comment->user_id);
971 971
 
972
-                    if( empty( $user ) ){
972
+                    if (empty($user)) {
973 973
                         // next comment in this array
974 974
                         continue;
975 975
                     }
@@ -977,26 +977,26 @@  discard block
 block discarded – undo
977 977
                     $course_learner_ids[] = $user->ID;
978 978
                 }
979 979
 
980
-            }else{
980
+            } else {
981 981
 
982
-                $user = get_userdata( $activity_comments->user_id );
982
+                $user = get_userdata($activity_comments->user_id);
983 983
                 $course_learner_ids[] = $user->ID;
984 984
 
985 985
             }
986 986
 
987 987
             // add learners on this course to the all courses learner list
988
-            $learner_ids_for_teacher_courses = array_merge( $learner_ids_for_teacher_courses, $course_learner_ids );
988
+            $learner_ids_for_teacher_courses = array_merge($learner_ids_for_teacher_courses, $course_learner_ids);
989 989
 
990 990
         }
991 991
 
992 992
         // if there are no students taking the courses by this teacher don't show them any of the other users
993
-        if( empty( $learner_ids_for_teacher_courses ) ){
993
+        if (empty($learner_ids_for_teacher_courses)) {
994 994
 
995
-            $args[ 'include'] = array( 0 );
995
+            $args['include'] = array(0);
996 996
 
997
-        }else{
997
+        } else {
998 998
 
999
-            $args[ 'include'] = $learner_ids_for_teacher_courses;
999
+            $args['include'] = $learner_ids_for_teacher_courses;
1000 1000
 
1001 1001
         }
1002 1002
 
@@ -1013,35 +1013,35 @@  discard block
 block discarded – undo
1013 1013
      * @param $questions
1014 1014
      * @return mixed
1015 1015
      */
1016
-    public function allow_teacher_access_to_questions( $questions, $quiz_id ){
1016
+    public function allow_teacher_access_to_questions($questions, $quiz_id) {
1017 1017
 
1018
-        if( ! $this->is_admin_teacher() ){
1018
+        if ( ! $this->is_admin_teacher()) {
1019 1019
             return $questions;
1020 1020
         }
1021 1021
 
1022 1022
         $screen = get_current_screen();
1023 1023
 
1024 1024
         // don't run this filter within this functions call to Sensei()->lesson->lesson_quiz_questions
1025
-        remove_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20 );
1025
+        remove_filter('sensei_lesson_quiz_questions', array($this, 'allow_teacher_access_to_questions'), 20);
1026 1026
 
1027
-        if( ! empty( $screen ) && 'lesson'== $screen->post_type ){
1027
+        if ( ! empty($screen) && 'lesson' == $screen->post_type) {
1028 1028
 
1029 1029
             $admin_user = get_user_by('email', get_bloginfo('admin_email'));
1030
-            if( ! empty($admin_user) ){
1030
+            if ( ! empty($admin_user)) {
1031 1031
 
1032 1032
                 $current_teacher_id = get_current_user_id();
1033 1033
 
1034 1034
                 // set current user to admin so teacher can view all questions
1035
-                wp_set_current_user( $admin_user->ID  );
1036
-                $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id  );
1035
+                wp_set_current_user($admin_user->ID);
1036
+                $questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
1037 1037
 
1038 1038
                 // set the teacher as the current use again
1039
-                wp_set_current_user( $current_teacher_id );
1039
+                wp_set_current_user($current_teacher_id);
1040 1040
             }
1041 1041
 
1042 1042
         }
1043 1043
         // attach the filter again for other funtion calls to Sensei()->lesson->lesson_quiz_questions
1044
-        add_filter( 'sensei_lesson_quiz_questions', array( $this, 'allow_teacher_access_to_questions' ), 20,2 );
1044
+        add_filter('sensei_lesson_quiz_questions', array($this, 'allow_teacher_access_to_questions'), 20, 2);
1045 1045
 
1046 1046
         return $questions;
1047 1047
     }
@@ -1053,30 +1053,30 @@  discard block
 block discarded – undo
1053 1053
      * @param $wp_query
1054 1054
      * @return mixed
1055 1055
      */
1056
-    public function give_access_to_all_questions( $wp_query ){
1056
+    public function give_access_to_all_questions($wp_query) {
1057 1057
 
1058
-        if( ! $this->is_admin_teacher() || !function_exists( 'get_current_screen') || 'question' != $wp_query->get('post_type') ){
1058
+        if ( ! $this->is_admin_teacher() || ! function_exists('get_current_screen') || 'question' != $wp_query->get('post_type')) {
1059 1059
 
1060 1060
             return $wp_query;
1061 1061
         }
1062 1062
 
1063 1063
         $screen = get_current_screen();
1064
-        if( ( isset($screen->id) && 'lesson' == $screen->id )
1065
-            || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
1064
+        if ((isset($screen->id) && 'lesson' == $screen->id)
1065
+            || (defined('DOING_AJAX') && DOING_AJAX)) {
1066 1066
 
1067 1067
             $admin_user = get_user_by('email', get_bloginfo('admin_email'));
1068
-            if( ! empty($admin_user) ){
1068
+            if ( ! empty($admin_user)) {
1069 1069
 
1070 1070
                 $current_teacher_id = get_current_user_id();
1071 1071
 
1072 1072
                 // set current user to admin so teacher can view all questions
1073
-                wp_set_current_user( $admin_user->ID  );
1073
+                wp_set_current_user($admin_user->ID);
1074 1074
 
1075 1075
                 //run new query as admin
1076
-                $wp_query = new WP_Query( $wp_query->query );
1076
+                $wp_query = new WP_Query($wp_query->query);
1077 1077
 
1078 1078
                 //set the teache as current use again
1079
-                wp_set_current_user( $current_teacher_id );
1079
+                wp_set_current_user($current_teacher_id);
1080 1080
 
1081 1081
             }
1082 1082
         }
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      */
1094 1094
     public function course_column_heading($columns) {
1095 1095
 
1096
-        if( $this->is_admin_teacher() ){
1096
+        if ($this->is_admin_teacher()) {
1097 1097
             return $columns;
1098 1098
         }
1099 1099
         $new_columns = array(
@@ -1110,20 +1110,20 @@  discard block
 block discarded – undo
1110 1110
      * @param $column
1111 1111
      * @param $course_id
1112 1112
      */
1113
-    public function course_column_data( $column, $course_id  ){
1113
+    public function course_column_data($column, $course_id) {
1114 1114
 
1115
-        if( $this->is_admin_teacher() || 'teacher' != $column  ){
1115
+        if ($this->is_admin_teacher() || 'teacher' != $column) {
1116 1116
             return;
1117 1117
         }
1118 1118
 
1119
-        $course = get_post( $course_id );
1120
-        $teacher = get_userdata( $course->post_author );
1119
+        $course = get_post($course_id);
1120
+        $teacher = get_userdata($course->post_author);
1121 1121
 
1122
-        if( !$teacher ){
1122
+        if ( ! $teacher) {
1123 1123
             return;
1124 1124
         }
1125 1125
 
1126
-        echo '<a href="'. get_edit_user_link( $teacher->ID ) .'" >'. $teacher->display_name.'</a>';
1126
+        echo '<a href="'.get_edit_user_link($teacher->ID).'" >'.$teacher->display_name.'</a>';
1127 1127
 
1128 1128
     }// end course_column_ data
1129 1129
 
@@ -1138,31 +1138,31 @@  discard block
 block discarded – undo
1138 1138
      *
1139 1139
      * @return array $teachers_courses
1140 1140
      */
1141
-    public function get_teacher_courses( $teacher_id, $return_ids_only= false){
1141
+    public function get_teacher_courses($teacher_id, $return_ids_only = false) {
1142 1142
 
1143 1143
         $teachers_courses = array();
1144 1144
 
1145
-        if( empty( $teacher_id  ) ){
1145
+        if (empty($teacher_id)) {
1146 1146
             $teacher_id = get_current_user_id();
1147 1147
         }
1148 1148
 
1149 1149
         $all_courses = Sensei()->course->get_all_courses();
1150 1150
 
1151
-        if( empty( $all_courses ) ){
1151
+        if (empty($all_courses)) {
1152 1152
             return $all_courses;
1153 1153
         }
1154 1154
 
1155
-        foreach( $all_courses as $course ){
1155
+        foreach ($all_courses as $course) {
1156 1156
 
1157
-            if( $course->post_author != $teacher_id  ){
1157
+            if ($course->post_author != $teacher_id) {
1158 1158
                 continue;
1159 1159
             }
1160 1160
 
1161
-            if( $return_ids_only ){
1161
+            if ($return_ids_only) {
1162 1162
 
1163 1163
                 $teachers_courses[] = $course->ID;
1164 1164
 
1165
-            }else{
1165
+            } else {
1166 1166
 
1167 1167
                 $teachers_courses[] = $course;
1168 1168
 
@@ -1182,21 +1182,21 @@  discard block
 block discarded – undo
1182 1182
      * @param $query
1183 1183
      * @return mixed
1184 1184
      */
1185
-    public function limit_edit_messages_query( $query ){
1186
-        if( ! $this->is_admin_teacher() || 'sensei_message' != $query->get('post_type') ){
1185
+    public function limit_edit_messages_query($query) {
1186
+        if ( ! $this->is_admin_teacher() || 'sensei_message' != $query->get('post_type')) {
1187 1187
             return $query;
1188 1188
         }
1189 1189
 
1190 1190
         $teacher = wp_get_current_user();
1191 1191
 
1192
-        $query->set( 'meta_key', '_receiver' );
1192
+        $query->set('meta_key', '_receiver');
1193 1193
         $meta_query_args = array(
1194 1194
             'key'     => '_receiver',
1195
-            'value'   => $teacher->get('user_login') ,
1195
+            'value'   => $teacher->get('user_login'),
1196 1196
             'compare' => '='
1197 1197
         );
1198 1198
 
1199
-        $query->set('meta_query', $meta_query_args  );
1199
+        $query->set('meta_query', $meta_query_args);
1200 1200
 
1201 1201
         return $query;
1202 1202
     }
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
     public function course_teacher_filter_options() {
1213 1213
         global $typenow;
1214 1214
 
1215
-        if( ! is_admin() || 'course' != $typenow || ! current_user_can('manage_sensei') ) {
1215
+        if ( ! is_admin() || 'course' != $typenow || ! current_user_can('manage_sensei')) {
1216 1216
             return;
1217 1217
         }
1218 1218
 
@@ -1222,31 +1222,31 @@  discard block
 block discarded – undo
1222 1222
         // get roles with the course edit capability
1223 1223
         // and then get the users with those roles
1224 1224
         $users_who_can_edit_courses = array();
1225
-        foreach( $roles as $role_item ){
1225
+        foreach ($roles as $role_item) {
1226 1226
 
1227
-            $role = get_role( strtolower( $role_item['name'] ) );
1227
+            $role = get_role(strtolower($role_item['name']));
1228 1228
 
1229
-            if( is_a( $role, 'WP_Role' ) && $role->has_cap('edit_courses') ){
1229
+            if (is_a($role, 'WP_Role') && $role->has_cap('edit_courses')) {
1230 1230
 
1231
-                $user_query_args = array( 'role' => $role->name, 'fields' => array( 'ID', 'display_name' ) );
1232
-                $role_users_who_can_edit_courses = get_users( $user_query_args );
1231
+                $user_query_args = array('role' => $role->name, 'fields' => array('ID', 'display_name'));
1232
+                $role_users_who_can_edit_courses = get_users($user_query_args);
1233 1233
 
1234 1234
                 // add user from the current $user_role to all users
1235
-                $users_who_can_edit_courses = array_merge( $users_who_can_edit_courses, $role_users_who_can_edit_courses );
1235
+                $users_who_can_edit_courses = array_merge($users_who_can_edit_courses, $role_users_who_can_edit_courses);
1236 1236
 
1237 1237
             }
1238 1238
 
1239 1239
         }
1240 1240
 
1241 1241
         // Create the select element with the given users who can edit course
1242
-        $selected = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1242
+        $selected = isset($_GET['course_teacher']) ? $_GET['course_teacher'] : '';
1243 1243
         $course_options = '';
1244
-        foreach( $users_who_can_edit_courses as $user ) {
1245
-            $course_options .= '<option value="' . esc_attr( $user->ID ) . '" ' . selected( $selected, $user->ID, false ) . '>' .  $user->display_name . '</option>';
1244
+        foreach ($users_who_can_edit_courses as $user) {
1245
+            $course_options .= '<option value="'.esc_attr($user->ID).'" '.selected($selected, $user->ID, false).'>'.$user->display_name.'</option>';
1246 1246
         }
1247 1247
 
1248 1248
         $output = '<select name="course_teacher" id="dropdown_course_teachers">';
1249
-        $output .= '<option value="">'.__( 'Show all teachers', 'woothemes-sensei' ).'</option>';
1249
+        $output .= '<option value="">'.__('Show all teachers', 'woothemes-sensei').'</option>';
1250 1250
         $output .= $course_options;
1251 1251
         $output .= '</select>';
1252 1252
 
@@ -1261,15 +1261,15 @@  discard block
 block discarded – undo
1261 1261
      * @param $query
1262 1262
      * @return $query
1263 1263
      */
1264
-    public function teacher_filter_query_modify( $query ){
1264
+    public function teacher_filter_query_modify($query) {
1265 1265
         global $typenow;
1266 1266
 
1267
-        if( ! is_admin() && 'course' != $typenow  || ! current_user_can('manage_sensei')  ) {
1267
+        if ( ! is_admin() && 'course' != $typenow || ! current_user_can('manage_sensei')) {
1268 1268
             return $query;
1269 1269
         }
1270
-        $course_teacher = isset( $_GET['course_teacher'] ) ? $_GET['course_teacher'] : '';
1270
+        $course_teacher = isset($_GET['course_teacher']) ? $_GET['course_teacher'] : '';
1271 1271
 
1272
-        if( empty( $course_teacher ) ) {
1272
+        if (empty($course_teacher)) {
1273 1273
             return $query;
1274 1274
         }
1275 1275
 
@@ -1282,23 +1282,23 @@  discard block
 block discarded – undo
1282 1282
      * @param  array $request Default request arguments
1283 1283
      * @return array          Modified request arguments
1284 1284
      */
1285
-    public function restrict_media_library( $request = array() ) {
1285
+    public function restrict_media_library($request = array()) {
1286 1286
 
1287
-        if( ! is_admin() ) {
1287
+        if ( ! is_admin()) {
1288 1288
             return $request;
1289 1289
         }
1290 1290
 
1291
-        if( ! $this->is_admin_teacher() ) {
1291
+        if ( ! $this->is_admin_teacher()) {
1292 1292
             return $request;
1293 1293
         }
1294 1294
 
1295 1295
         $screen = get_current_screen();
1296 1296
 
1297
-        if( in_array( $screen->id, array( 'upload', 'course', 'lesson', 'question' ) ) ) {
1298
-            $teacher = intval( get_current_user_id() );
1297
+        if (in_array($screen->id, array('upload', 'course', 'lesson', 'question'))) {
1298
+            $teacher = intval(get_current_user_id());
1299 1299
 
1300
-            if( $teacher ) {
1301
-                $request['author__in'] = array( $teacher );
1300
+            if ($teacher) {
1301
+                $request['author__in'] = array($teacher);
1302 1302
             }
1303 1303
         }
1304 1304
 
@@ -1310,20 +1310,20 @@  discard block
 block discarded – undo
1310 1310
      * @param  array $query Default query arguments
1311 1311
      * @return array        Modified query arguments
1312 1312
      */
1313
-    public function restrict_media_library_modal( $query = array() ) {
1313
+    public function restrict_media_library_modal($query = array()) {
1314 1314
 
1315
-        if( ! is_admin() ) {
1315
+        if ( ! is_admin()) {
1316 1316
             return $query;
1317 1317
         }
1318 1318
 
1319
-        if( ! $this->is_admin_teacher() ) {
1319
+        if ( ! $this->is_admin_teacher()) {
1320 1320
             return $query;
1321 1321
         }
1322 1322
 
1323
-        $teacher = intval( get_current_user_id() );
1323
+        $teacher = intval(get_current_user_id());
1324 1324
 
1325
-        if( $teacher ) {
1326
-            $query['author__in'] = array( $teacher );
1325
+        if ($teacher) {
1326
+            $query['author__in'] = array($teacher);
1327 1327
         }
1328 1328
 
1329 1329
         return $query;
@@ -1336,28 +1336,28 @@  discard block
 block discarded – undo
1336 1336
      *
1337 1337
      * @param int $lesson_id
1338 1338
      */
1339
-    public function update_lesson_teacher( $lesson_id ){
1339
+    public function update_lesson_teacher($lesson_id) {
1340 1340
 
1341
-        if( 'lesson'!= get_post_type() ){
1341
+        if ('lesson' != get_post_type()) {
1342 1342
             return;
1343 1343
         }
1344 1344
 
1345 1345
         // this should only run once per request cycle
1346
-        remove_action( 'save_post',  array( $this, 'update_lesson_teacher' ) );
1346
+        remove_action('save_post', array($this, 'update_lesson_teacher'));
1347 1347
 
1348
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1348
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
1349 1349
 
1350
-        if(  empty( $course_id ) || ! $course_id ){
1350
+        if (empty($course_id) || ! $course_id) {
1351 1351
             return;
1352 1352
         }
1353 1353
 
1354
-        $course = get_post( $course_id );
1354
+        $course = get_post($course_id);
1355 1355
 
1356
-        $lesson_update_args= array(
1357
-            'ID' => $lesson_id ,
1356
+        $lesson_update_args = array(
1357
+            'ID' => $lesson_id,
1358 1358
             'post_author' => $course->post_author
1359 1359
         );
1360
-        wp_update_post( $lesson_update_args );
1360
+        wp_update_post($lesson_update_args);
1361 1361
 
1362 1362
     } // end update_lesson_teacher
1363 1363
 
@@ -1371,21 +1371,21 @@  discard block
 block discarded – undo
1371 1371
      * @parameters array $wp_query
1372 1372
      * @return WP_Query $wp_query
1373 1373
      */
1374
-    public function limit_teacher_edit_screen_post_types( $wp_query ) {
1374
+    public function limit_teacher_edit_screen_post_types($wp_query) {
1375 1375
         global $current_user;
1376 1376
 
1377 1377
         //exit early
1378
-        if( ! $this->is_admin_teacher() ){
1378
+        if ( ! $this->is_admin_teacher()) {
1379 1379
             return $wp_query;
1380 1380
         }
1381 1381
 
1382
-        if ( ! function_exists( 'get_current_screen' ) ) {
1382
+        if ( ! function_exists('get_current_screen')) {
1383 1383
             return $wp_query;
1384 1384
         }
1385 1385
 
1386 1386
         $screen = get_current_screen();
1387 1387
 
1388
-        if( empty( $screen ) ){
1388
+        if (empty($screen)) {
1389 1389
             return $wp_query;
1390 1390
         }
1391 1391
 
@@ -1398,10 +1398,10 @@  discard block
 block discarded – undo
1398 1398
             'lesson_page_lesson-order',
1399 1399
         );
1400 1400
 
1401
-        if(  in_array($screen->id  , $limit_screens ) ) {
1401
+        if (in_array($screen->id, $limit_screens)) {
1402 1402
 
1403 1403
             // set the query author to the current user to only show those those posts
1404
-            $wp_query->set( 'author', $current_user->ID );
1404
+            $wp_query->set('author', $current_user->ID);
1405 1405
         }
1406 1406
 
1407 1407
         return $wp_query;
@@ -1421,7 +1421,7 @@  discard block
 block discarded – undo
1421 1421
      * @return void
1422 1422
      */
1423 1423
 
1424
-    public function teacher_login_redirect( $user_login, $user  ) {
1424
+    public function teacher_login_redirect($user_login, $user) {
1425 1425
 
1426 1426
         if (user_can($user, 'edit_courses')) {
1427 1427
 
@@ -1471,9 +1471,9 @@  discard block
 block discarded – undo
1471 1471
          * @param bool $restrict default true
1472 1472
          */
1473 1473
 
1474
-        $restrict = apply_filters('sensei_restrict_posts_menu_page', true );
1474
+        $restrict = apply_filters('sensei_restrict_posts_menu_page', true);
1475 1475
 
1476
-        if ( in_array( 'teacher', (array) $user->roles ) && !current_user_can('delete_posts') && $restrict) {
1476
+        if (in_array('teacher', (array) $user->roles) && ! current_user_can('delete_posts') && $restrict) {
1477 1477
 
1478 1478
             remove_menu_page('edit.php');
1479 1479
 
@@ -1503,11 +1503,11 @@  discard block
 block discarded – undo
1503 1503
      * @return WP_Comment_Query  $clauses
1504 1504
      */
1505 1505
 
1506
-    public function restrict_comment_moderation ( $clauses ) {
1506
+    public function restrict_comment_moderation($clauses) {
1507 1507
 
1508 1508
         global $pagenow;
1509 1509
 
1510
-        if( self::is_a_teacher( get_current_user_id() ) && $pagenow == "edit-comments.php") {
1510
+        if (self::is_a_teacher(get_current_user_id()) && $pagenow == "edit-comments.php") {
1511 1511
 
1512 1512
             $clauses->query_vars['post_author'] = get_current_user_id();
1513 1513
 
@@ -1524,15 +1524,15 @@  discard block
 block discarded – undo
1524 1524
      *
1525 1525
      * @return bool
1526 1526
      */
1527
-    public static function is_a_teacher( $user_id ){
1527
+    public static function is_a_teacher($user_id) {
1528 1528
 
1529 1529
         $user = get_user_by('id', $user_id);
1530 1530
 
1531
-        if( isset( $user->roles ) && in_array(  'teacher',  $user->roles )   ){
1531
+        if (isset($user->roles) && in_array('teacher', $user->roles)) {
1532 1532
 
1533 1533
             return true;
1534 1534
 
1535
-        }else{
1535
+        } else {
1536 1536
 
1537 1537
             return false;
1538 1538
 
@@ -1545,14 +1545,14 @@  discard block
 block discarded – undo
1545 1545
      *
1546 1546
      * @since 1.9.0
1547 1547
      */
1548
-    public static function archive_title(){
1548
+    public static function archive_title() {
1549 1549
 
1550
-        $author = get_user_by( 'id', get_query_var( 'author' ) );
1550
+        $author = get_user_by('id', get_query_var('author'));
1551 1551
         $author_name = $author->display_name;
1552 1552
         ?>
1553 1553
             <h2 class="teacher-archive-title">
1554 1554
 
1555
-                <?php echo sprintf( __( 'All courses by %s', 'woothemes-sensei') , $author_name ); ?>
1555
+                <?php echo sprintf(__('All courses by %s', 'woothemes-sensei'), $author_name); ?>
1556 1556
 
1557 1557
             </h2>
1558 1558
         <?php
@@ -1564,9 +1564,9 @@  discard block
 block discarded – undo
1564 1564
      *
1565 1565
      * @since 1.9.0
1566 1566
      */
1567
-    public static function remove_course_meta_on_teacher_archive(){
1567
+    public static function remove_course_meta_on_teacher_archive() {
1568 1568
 
1569
-        remove_action('sensei_course_content_inside_before', array( Sensei()->course, 'the_course_meta' ) );
1569
+        remove_action('sensei_course_content_inside_before', array(Sensei()->course, 'the_course_meta'));
1570 1570
 
1571 1571
     }
1572 1572
 
Please login to merge, or discard this patch.
includes/class-sensei-updates.php 1 patch
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 *
1425 1425
 	 * @global type $woothemes_sensei
1426 1426
 	 * @global type $wpdb
1427
-	 * @param type $n
1428
-	 * @param type $offset
1427
+	 * @param integer $n
1428
+	 * @param integer $offset
1429 1429
 	 * @return boolean
1430 1430
 	 */
1431 1431
 	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
@@ -1669,8 +1669,8 @@  discard block
 block discarded – undo
1669 1669
 	 * Update the comment counts for all Courses and Lessons now that sensei comments will no longer be counted.
1670 1670
 	 *
1671 1671
 	 * @global type $wpdb
1672
-	 * @param type $n
1673
-	 * @param type $offset
1672
+	 * @param integer $n
1673
+	 * @param integer $offset
1674 1674
 	 * @return boolean
1675 1675
 	 */
1676 1676
 	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
Please login to merge, or discard this patch.
widgets/widget-woothemes-sensei-lesson-component.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function widget( $args, $instance ) {
55 55
 
56
-        $before_widget = $args[ 'before_widget' ];
57
-        $before_title  = $args[ 'before_title' ];
58
-        $after_title   = $args[ 'after_title' ];
59
-        $after_widget  = $args[ 'after_widget' ];
56
+		$before_widget = $args[ 'before_widget' ];
57
+		$before_title  = $args[ 'before_title' ];
58
+		$after_title   = $args[ 'after_title' ];
59
+		$after_widget  = $args[ 'after_widget' ];
60 60
 
61 61
 		if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) && !is_user_logged_in() ) {
62 62
 			// No Output
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param  array $instance The settings for this instance.
118 118
 	 * @return void
119 119
 	 */
120
-    public function form( $instance ) {
120
+	public function form( $instance ) {
121 121
 
122 122
 		/* Set up some default widget settings. */
123 123
 		/* Make sure all keys are added here, even with empty string values. */
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 		$post_args = array(	'post_type' 		=> 'lesson',
173 173
 							'posts_per_page' 		=> intval( $instance[ 'limit' ] ),
174 174
 							'orderby'         	=> 'menu_order date',
175
-    						'order'           	=> 'DESC',
176
-    						'post_status'       => 'publish',
175
+							'order'           	=> 'DESC',
176
+							'post_status'       => 'publish',
177 177
 							'suppress_filters' 	=> 0
178 178
 							);
179 179
 		$posts_array = get_posts( $post_args );
@@ -181,14 +181,14 @@  discard block
 block discarded – undo
181 181
 		if ( count( $posts_array ) > 0 ) { ?>
182 182
 			<ul>
183 183
 			<?php foreach ($posts_array as $post_item){
184
-		    	$post_id = absint( $post_item->ID );
185
-		    	$post_title = $post_item->post_title;
186
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
187
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
188
-		    	$author_display_name = $user_info->display_name;
189
-		    	$author_id = $post_item->post_author;
190
-		    	$lesson_course_id = get_post_meta( $post_id, '_lesson_course', true );
191
-		    ?>
184
+				$post_id = absint( $post_item->ID );
185
+				$post_title = $post_item->post_title;
186
+				$user_info = get_userdata( absint( $post_item->post_author ) );
187
+				$author_link = get_author_posts_url( absint( $post_item->post_author ) );
188
+				$author_display_name = $user_info->display_name;
189
+				$author_id = $post_item->post_author;
190
+				$lesson_course_id = get_post_meta( $post_id, '_lesson_course', true );
191
+			?>
192 192
 		    	<li class="fix">
193 193
 		    		<?php do_action( 'sensei_lesson_image', $post_id, '100', '100', false, true ); ?>
194 194
 		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 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 Lesson Component Widget
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_lesson_component';
29
-		$this->woo_widget_description = __( 'This widget will output a list of the latest Lessons.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of the latest Lessons.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_lesson_component';
31
-		$this->woo_widget_title = __( 'Sensei - Lesson Component', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Lesson Component', 'woothemes-sensei');
32 32
 
33 33
 		$this->woo_widget_componentslist = array(
34
-												'newlessons' => __( 'New Lessons', 'woothemes-sensei' ),
34
+												'newlessons' => __('New Lessons', 'woothemes-sensei'),
35 35
 												);
36 36
 
37 37
 		/* Widget settings. */
38
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
38
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
39 39
 
40 40
 		/* Widget control settings. */
41
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
41
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
42 42
 
43 43
 		/* Create the widget. */
44
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
44
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
45 45
 	} // End __construct()
46 46
 
47 47
 	/**
@@ -51,35 +51,35 @@  discard block
 block discarded – undo
51 51
 	 * @param  array $instance Widget settings for this instance.
52 52
 	 * @return void
53 53
 	 */
54
-	public function widget( $args, $instance ) {
54
+	public function widget($args, $instance) {
55 55
 
56
-        $before_widget = $args[ 'before_widget' ];
57
-        $before_title  = $args[ 'before_title' ];
58
-        $after_title   = $args[ 'after_title' ];
59
-        $after_widget  = $args[ 'after_widget' ];
56
+        $before_widget = $args['before_widget'];
57
+        $before_title  = $args['before_title'];
58
+        $after_title   = $args['after_title'];
59
+        $after_widget  = $args['after_widget'];
60 60
 
61
-		if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) && !is_user_logged_in() ) {
61
+		if (in_array($instance['component'], array_keys($this->woo_widget_componentslist)) && ('activecourses' == $instance['component'] || 'completedcourses' == $instance['component']) && ! is_user_logged_in()) {
62 62
 			// No Output
63 63
 		} else {
64 64
 			/* Our variables from the widget settings. */
65
-			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
65
+			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
66 66
 
67 67
 			/* Before widget (defined by themes). */
68 68
 			echo $before_widget;
69 69
 
70 70
 			/* Display the widget title if one was input (before and after defined by themes). */
71
-			if ( $title ) { echo $before_title . $title . $after_title; }
71
+			if ($title) { echo $before_title.$title.$after_title; }
72 72
 
73 73
 			/* Widget content. */
74 74
 			// Add actions for plugins/themes to hook onto.
75
-			do_action( $this->woo_widget_cssclass . '_top' );
75
+			do_action($this->woo_widget_cssclass.'_top');
76 76
 
77
-			if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) ) {
78
-				$this->load_component( $instance );
77
+			if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))) {
78
+				$this->load_component($instance);
79 79
 			}
80 80
 
81 81
 			// Add actions for plugins/themes to hook onto.
82
-			do_action( $this->woo_widget_cssclass . '_bottom' );
82
+			do_action($this->woo_widget_cssclass.'_bottom');
83 83
 
84 84
 			/* After widget (defined by themes). */
85 85
 			echo $after_widget;
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 	 * @param  array $old_instance Previous settings.
95 95
 	 * @return array               Updated settings.
96 96
 	 */
97
-	public function update ( $new_instance, $old_instance ) {
97
+	public function update($new_instance, $old_instance) {
98 98
 		$instance = $old_instance;
99 99
 
100 100
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
101
-		$instance['title'] = strip_tags( $new_instance['title'] );
101
+		$instance['title'] = strip_tags($new_instance['title']);
102 102
 
103 103
 		/* The select box is returning a text value, so we escape it. */
104
-		$instance['component'] = esc_attr( $new_instance['component'] );
104
+		$instance['component'] = esc_attr($new_instance['component']);
105 105
 
106 106
 		/* The select box is returning a text value, so we escape it. */
107
-		$instance['limit'] = esc_attr( $new_instance['limit'] );
107
+		$instance['limit'] = esc_attr($new_instance['limit']);
108 108
 
109 109
 
110 110
 		return $instance;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param  array $instance The settings for this instance.
118 118
 	 * @return void
119 119
 	 */
120
-    public function form( $instance ) {
120
+    public function form($instance) {
121 121
 
122 122
 		/* Set up some default widget settings. */
123 123
 		/* Make sure all keys are added here, even with empty string values. */
@@ -127,26 +127,26 @@  discard block
 block discarded – undo
127 127
 						'limit' => 3
128 128
 					);
129 129
 
130
-		$instance = wp_parse_args( (array) $instance, $defaults );
130
+		$instance = wp_parse_args((array) $instance, $defaults);
131 131
 ?>
132 132
 		<!-- Widget Title: Text Input -->
133 133
 		<p>
134
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
135
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
134
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
135
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
136 136
 		</p>
137 137
 		<!-- Widget Component: Select Input -->
138 138
 		<p>
139
-			<label for="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"><?php _e( 'Component:', 'woothemes-sensei' ); ?></label>
140
-			<select name="<?php echo esc_attr( $this->get_field_name( 'component' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>">
141
-			<?php foreach ( $this->woo_widget_componentslist as $k => $v ) { ?>
142
-				<option value="<?php echo esc_attr( $k ); ?>"<?php selected( $instance['component'], $k ); ?>><?php echo $v; ?></option>
139
+			<label for="<?php echo esc_attr($this->get_field_id('component')); ?>"><?php _e('Component:', 'woothemes-sensei'); ?></label>
140
+			<select name="<?php echo esc_attr($this->get_field_name('component')); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('component')); ?>">
141
+			<?php foreach ($this->woo_widget_componentslist as $k => $v) { ?>
142
+				<option value="<?php echo esc_attr($k); ?>"<?php selected($instance['component'], $k); ?>><?php echo $v; ?></option>
143 143
 			<?php } ?>
144 144
 			</select>
145 145
 		</p>
146 146
 		<!-- Widget Limit: Text Input -->
147 147
 		<p>
148
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Lessons (optional):', 'woothemes-sensei' ); ?></label>
149
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
148
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Lessons (optional):', 'woothemes-sensei'); ?></label>
149
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
150 150
 		</p>
151 151
 
152 152
 <?php
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @since  5.0.8
159 159
 	 * @return void
160 160
 	 */
161
-	protected function load_component ( $instance ) {
161
+	protected function load_component($instance) {
162 162
 
163 163
 		global  $current_user;
164 164
 		// Get User Meta
@@ -169,41 +169,41 @@  discard block
 block discarded – undo
169 169
 
170 170
 		$posts_array = array();
171 171
 
172
-		$post_args = array(	'post_type' 		=> 'lesson',
173
-							'posts_per_page' 		=> intval( $instance[ 'limit' ] ),
172
+		$post_args = array('post_type' 		=> 'lesson',
173
+							'posts_per_page' 		=> intval($instance['limit']),
174 174
 							'orderby'         	=> 'menu_order date',
175 175
     						'order'           	=> 'DESC',
176 176
     						'post_status'       => 'publish',
177 177
 							'suppress_filters' 	=> 0
178 178
 							);
179
-		$posts_array = get_posts( $post_args );
179
+		$posts_array = get_posts($post_args);
180 180
 
181
-		if ( count( $posts_array ) > 0 ) { ?>
181
+		if (count($posts_array) > 0) { ?>
182 182
 			<ul>
183
-			<?php foreach ($posts_array as $post_item){
184
-		    	$post_id = absint( $post_item->ID );
183
+			<?php foreach ($posts_array as $post_item) {
184
+		    	$post_id = absint($post_item->ID);
185 185
 		    	$post_title = $post_item->post_title;
186
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
187
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
186
+		    	$user_info = get_userdata(absint($post_item->post_author));
187
+		    	$author_link = get_author_posts_url(absint($post_item->post_author));
188 188
 		    	$author_display_name = $user_info->display_name;
189 189
 		    	$author_id = $post_item->post_author;
190
-		    	$lesson_course_id = get_post_meta( $post_id, '_lesson_course', true );
190
+		    	$lesson_course_id = get_post_meta($post_id, '_lesson_course', true);
191 191
 		    ?>
192 192
 		    	<li class="fix">
193
-		    		<?php do_action( 'sensei_lesson_image', $post_id, '100', '100', false, true ); ?>
194
-		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
193
+		    		<?php do_action('sensei_lesson_image', $post_id, '100', '100', false, true); ?>
194
+		    		<a href="<?php echo esc_url(get_permalink($post_id)); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a>
195 195
 		    		<br />
196
-		    		<?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?>
197
-    					<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name ); ?></a></span>
196
+		    		<?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?>
197
+    					<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
198 198
     					<br />
199 199
     				<?php } // End If Statement ?>
200
-    				<?php if ( 0 < $lesson_course_id ) { ?>
201
-                        <span class="lesson-course"><?php echo ' ' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . esc_attr( __( 'View course', 'woothemes-sensei' ) ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span>
200
+    				<?php if (0 < $lesson_course_id) { ?>
201
+                        <span class="lesson-course"><?php echo ' '.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.esc_attr(__('View course', 'woothemes-sensei')).'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span>
202 202
                     <?php } ?>
203 203
     				<br />
204 204
 		    	</li>
205 205
 		    <?php } // End For Loop ?>
206
-		    <?php echo '<li class="my-account fix"><a class="button" href="'. esc_url( get_post_type_archive_link( 'lesson' ) ) .'">'.__('More Lessons', 'woothemes-sensei').'</a></li>'; ?>
206
+		    <?php echo '<li class="my-account fix"><a class="button" href="'.esc_url(get_post_type_archive_link('lesson')).'">'.__('More Lessons', 'woothemes-sensei').'</a></li>'; ?>
207 207
 		</ul>
208 208
 		<?php } // End If Statement
209 209
 	} // End load_component()
Please login to merge, or discard this patch.
widgets/widget-woothemes-sensei-category-courses.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function widget( $args, $instance ) {
52 52
 
53
-        $before_widget = $args[ 'before_widget' ];
54
-        $before_title  = $args[ 'before_title' ];
55
-        $after_title   = $args[ 'after_title' ];
56
-        $after_widget  = $args[ 'after_widget' ];
53
+		$before_widget = $args[ 'before_widget' ];
54
+		$before_title  = $args[ 'before_title' ];
55
+		$after_title   = $args[ 'after_title' ];
56
+		$after_widget  = $args[ 'after_widget' ];
57 57
 
58 58
 		/* Our variables from the widget settings. */
59 59
 		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param  array $instance The settings for this instance.
111 111
 	 * @return void
112 112
 	 */
113
-    public function form( $instance ) {
113
+	public function form( $instance ) {
114 114
 
115 115
 		/* Set up some default widget settings. */
116 116
 		/* Make sure all keys are added here, even with empty string values. */
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 		$post_args = array(	'post_type' 		=> 'course',
158 158
 							'posts_per_page' 		=> intval( $instance[ 'limit' ] ),
159 159
 							'orderby'         	=> 'menu_order date',
160
-    						'order'           	=> 'ASC',
161
-    						'post_status'       => 'publish',
160
+							'order'           	=> 'ASC',
161
+							'post_status'       => 'publish',
162 162
 							'suppress_filters' 	=> 0,
163 163
 							);
164 164
 
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		if ( count( $posts_array ) > 0 ) { ?>
176 176
 			<ul>
177 177
 			<?php foreach ($posts_array as $post_item){
178
-		    	$post_id = absint( $post_item->ID );
179
-		    	$post_title = $post_item->post_title;
180
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
181
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
182
-		    	$author_display_name = $user_info->display_name;
183
-		    	$author_id = $post_item->post_author;
184
-		    ?>
178
+				$post_id = absint( $post_item->ID );
179
+				$post_title = $post_item->post_title;
180
+				$user_info = get_userdata( absint( $post_item->post_author ) );
181
+				$author_link = get_author_posts_url( absint( $post_item->post_author ) );
182
+				$author_display_name = $user_info->display_name;
183
+				$author_id = $post_item->post_author;
184
+			?>
185 185
 		    	<li class="fix">
186 186
 		    		<?php do_action( 'sensei_course_image', $post_id ); ?>
187 187
 		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 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 Category Courses Widget
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_category_courses';
29
-		$this->woo_widget_description = __( 'This widget will output a list of Courses for a specific category.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of Courses for a specific category.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_category_courses';
31
-		$this->woo_widget_title = __( 'Sensei - Category Courses', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Category Courses', 'woothemes-sensei');
32 32
 
33 33
 		/* Widget settings. */
34
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
34
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
35 35
 
36 36
 		/* Widget control settings. */
37
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
37
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
38 38
 
39 39
 		/* Create the widget. */
40
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
40
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
41 41
 
42 42
 	} // End __construct()
43 43
 
@@ -48,32 +48,32 @@  discard block
 block discarded – undo
48 48
 	 * @param  array $instance Widget settings for this instance.
49 49
 	 * @return void
50 50
 	 */
51
-	public function widget( $args, $instance ) {
51
+	public function widget($args, $instance) {
52 52
 
53
-        $before_widget = $args[ 'before_widget' ];
54
-        $before_title  = $args[ 'before_title' ];
55
-        $after_title   = $args[ 'after_title' ];
56
-        $after_widget  = $args[ 'after_widget' ];
53
+        $before_widget = $args['before_widget'];
54
+        $before_title  = $args['before_title'];
55
+        $after_title   = $args['after_title'];
56
+        $after_widget  = $args['after_widget'];
57 57
 
58 58
 		/* Our variables from the widget settings. */
59
-		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
59
+		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
60 60
 
61 61
 		/* Before widget (defined by themes). */
62 62
 		echo $before_widget;
63 63
 
64 64
 		/* Display the widget title if one was input (before and after defined by themes). */
65
-		if ( $title ) { echo $before_title . $title . $after_title; }
65
+		if ($title) { echo $before_title.$title.$after_title; }
66 66
 
67 67
 		/* Widget content. */
68 68
 		// Add actions for plugins/themes to hook onto.
69
-		do_action( $this->woo_widget_cssclass . '_top' );
69
+		do_action($this->woo_widget_cssclass.'_top');
70 70
 
71
-		if ( 0 < intval( $instance['course_category'] ) ) {
72
-			$this->load_component( $instance );
71
+		if (0 < intval($instance['course_category'])) {
72
+			$this->load_component($instance);
73 73
 		} // End If Statement
74 74
 
75 75
 		// Add actions for plugins/themes to hook onto.
76
-		do_action( $this->woo_widget_cssclass . '_bottom' );
76
+		do_action($this->woo_widget_cssclass.'_bottom');
77 77
 
78 78
 		/* After widget (defined by themes). */
79 79
 		echo $after_widget;
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 	 * @param  array $old_instance Previous settings.
88 88
 	 * @return array               Updated settings.
89 89
 	 */
90
-	public function update ( $new_instance, $old_instance ) {
90
+	public function update($new_instance, $old_instance) {
91 91
 		$instance = $old_instance;
92 92
 
93 93
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
94
-		$instance['title'] = strip_tags( $new_instance['title'] );
94
+		$instance['title'] = strip_tags($new_instance['title']);
95 95
 
96 96
 		/* The select box is returning a text value, so we escape it. */
97
-		$instance['course_category'] = esc_attr( $new_instance['course_category'] );
97
+		$instance['course_category'] = esc_attr($new_instance['course_category']);
98 98
 
99 99
 		/* Strip tags for limit to remove HTML (important for text inputs). */
100
-		$instance['limit'] = strip_tags( $new_instance['limit'] );
100
+		$instance['limit'] = strip_tags($new_instance['limit']);
101 101
 
102 102
 
103 103
 		return $instance;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param  array $instance The settings for this instance.
111 111
 	 * @return void
112 112
 	 */
113
-    public function form( $instance ) {
113
+    public function form($instance) {
114 114
 
115 115
 		/* Set up some default widget settings. */
116 116
 		/* Make sure all keys are added here, even with empty string values. */
@@ -120,25 +120,25 @@  discard block
 block discarded – undo
120 120
 						'limit' => 3
121 121
 					);
122 122
 
123
-		$instance = wp_parse_args( (array) $instance, $defaults );
123
+		$instance = wp_parse_args((array) $instance, $defaults);
124 124
 ?>
125 125
 		<!-- Widget Title: Text Input -->
126 126
 		<p>
127
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
128
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
127
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
128
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
129 129
 		</p>
130 130
 		<!-- Widget Course Category: Select Input -->
131 131
 		<p>
132
-			<label for="<?php echo esc_attr( $this->get_field_id( 'course_category' ) ); ?>"><?php _e( 'Course Category:', 'woothemes-sensei' ); ?></label>
132
+			<label for="<?php echo esc_attr($this->get_field_id('course_category')); ?>"><?php _e('Course Category:', 'woothemes-sensei'); ?></label>
133 133
 			<?php
134
-			$cat_args = array( 'hierarchical' => true, 'show_option_none' => __( 'Select Category:', 'woothemes-sensei' ), 'taxonomy' => 'course-category', 'orderby' => 'name', 'selected' => intval( $instance['course_category'] ), 'id' => $this->get_field_id( 'course_category' ), 'name' => $this->get_field_name( 'course_category' ), 'class' => 'widefat' );
134
+			$cat_args = array('hierarchical' => true, 'show_option_none' => __('Select Category:', 'woothemes-sensei'), 'taxonomy' => 'course-category', 'orderby' => 'name', 'selected' => intval($instance['course_category']), 'id' => $this->get_field_id('course_category'), 'name' => $this->get_field_name('course_category'), 'class' => 'widefat');
135 135
 			wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args));
136 136
 			?>
137 137
 		</p>
138 138
 		<!-- Widget Limit: Text Input -->
139 139
 		<p>
140
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Courses (optional):', 'woothemes-sensei' ); ?></label>
141
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
140
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Courses (optional):', 'woothemes-sensei'); ?></label>
141
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
142 142
 		</p>
143 143
 
144 144
 <?php
@@ -150,49 +150,49 @@  discard block
 block discarded – undo
150 150
 	 * @since  1.1.0
151 151
 	 * @return void
152 152
 	 */
153
-	protected function load_component ( $instance ) {
153
+	protected function load_component($instance) {
154 154
 
155 155
 
156 156
 		$posts_array = array();
157
-		$post_args = array(	'post_type' 		=> 'course',
158
-							'posts_per_page' 		=> intval( $instance[ 'limit' ] ),
157
+		$post_args = array('post_type' 		=> 'course',
158
+							'posts_per_page' 		=> intval($instance['limit']),
159 159
 							'orderby'         	=> 'menu_order date',
160 160
     						'order'           	=> 'ASC',
161 161
     						'post_status'       => 'publish',
162 162
 							'suppress_filters' 	=> 0,
163 163
 							);
164 164
 
165
-		$post_args[ 'tax_query' ] = array(
165
+		$post_args['tax_query'] = array(
166 166
 											array(
167 167
 												'taxonomy' => 'course-category',
168 168
 												'field' => 'id',
169
-												'terms' => intval( $instance['course_category'] )
169
+												'terms' => intval($instance['course_category'])
170 170
 											)
171 171
 										);
172 172
 
173
-		$posts_array = get_posts( $post_args );
173
+		$posts_array = get_posts($post_args);
174 174
 
175
-		if ( count( $posts_array ) > 0 ) { ?>
175
+		if (count($posts_array) > 0) { ?>
176 176
 			<ul>
177
-			<?php foreach ($posts_array as $post_item){
178
-		    	$post_id = absint( $post_item->ID );
177
+			<?php foreach ($posts_array as $post_item) {
178
+		    	$post_id = absint($post_item->ID);
179 179
 		    	$post_title = $post_item->post_title;
180
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
181
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
180
+		    	$user_info = get_userdata(absint($post_item->post_author));
181
+		    	$author_link = get_author_posts_url(absint($post_item->post_author));
182 182
 		    	$author_display_name = $user_info->display_name;
183 183
 		    	$author_id = $post_item->post_author;
184 184
 		    ?>
185 185
 		    	<li class="fix">
186
-		    		<?php do_action( 'sensei_course_image', $post_id ); ?>
187
-		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
186
+		    		<?php do_action('sensei_course_image', $post_id); ?>
187
+		    		<a href="<?php echo esc_url(get_permalink($post_id)); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a>
188 188
 		    		<br />
189
-		    		<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
190
-    					<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name ); ?></a></span>
189
+		    		<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
190
+    					<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
191 191
     					<br />
192 192
     				<?php } // End If Statement ?>
193
-    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?></span>
193
+    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
194 194
     				<br />
195
-    				<?php sensei_simple_course_price( $post_id ); ?>
195
+    				<?php sensei_simple_course_price($post_id); ?>
196 196
 		    	</li>
197 197
 		    <?php } // End For Loop ?>
198 198
 			</ul>
Please login to merge, or discard this patch.
widgets/widget-woothemes-sensei-course-categories.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -49,31 +49,31 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function widget( $args, $instance ) {
51 51
 
52
-        $before_widget = $args[ 'before_widget' ];
53
-        $before_title  = $args[ 'before_title' ];
54
-        $after_title   = $args[ 'after_title' ];
55
-        $after_widget  = $args[ 'after_widget' ];
52
+		$before_widget = $args[ 'before_widget' ];
53
+		$before_title  = $args[ 'before_title' ];
54
+		$after_title   = $args[ 'after_title' ];
55
+		$after_widget  = $args[ 'after_widget' ];
56 56
 
57
-        /* Our variables from the widget settings. */
58
-        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
57
+		/* Our variables from the widget settings. */
58
+		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
59 59
 
60
-        /* Before widget (defined by themes). */
61
-        echo $before_widget;
60
+		/* Before widget (defined by themes). */
61
+		echo $before_widget;
62 62
 
63
-        /* Display the widget title if one was input (before and after defined by themes). */
64
-        if ( $title ) { echo $before_title . $title . $after_title; }
63
+		/* Display the widget title if one was input (before and after defined by themes). */
64
+		if ( $title ) { echo $before_title . $title . $after_title; }
65 65
 
66
-        /* Widget content. */
67
-        // Add actions for plugins/themes to hook onto.
68
-        do_action( $this->woo_widget_cssclass . '_top' );
66
+		/* Widget content. */
67
+		// Add actions for plugins/themes to hook onto.
68
+		do_action( $this->woo_widget_cssclass . '_top' );
69 69
 
70
-        $this->load_component( $instance );
70
+		$this->load_component( $instance );
71 71
 
72
-        // Add actions for plugins/themes to hook onto.
73
-        do_action( $this->woo_widget_cssclass . '_bottom' );
72
+		// Add actions for plugins/themes to hook onto.
73
+		do_action( $this->woo_widget_cssclass . '_bottom' );
74 74
 
75
-        /* After widget (defined by themes). */
76
-        echo $after_widget;
75
+		/* After widget (defined by themes). */
76
+		echo $after_widget;
77 77
 
78 78
 	} // End widget()
79 79
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @param  array $instance The settings for this instance.
108 108
 	 * @return void
109 109
 	 */
110
-    public function form( $instance ) {
110
+	public function form( $instance ) {
111 111
 
112 112
 		/* Set up some default widget settings. */
113 113
 		/* Make sure all keys are added here, even with empty string values. */
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
3 3
 
4 4
 /**
5 5
  * Sensei Course Categories Widget
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_course_categories';
29
-		$this->woo_widget_description = __( 'This widget will output a list of Course Categories.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of Course Categories.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_course_categories';
31
-		$this->woo_widget_title = __( 'Sensei - Course Categories', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Course Categories', 'woothemes-sensei');
32 32
 
33 33
 		/* Widget settings. */
34
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
34
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
35 35
 
36 36
 		/* Widget control settings. */
37
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
37
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
38 38
 
39 39
 		/* Create the widget. */
40
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
40
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
41 41
 	} // End __construct()
42 42
 
43 43
 	/**
@@ -47,30 +47,30 @@  discard block
 block discarded – undo
47 47
 	 * @param  array $instance Widget settings for this instance.
48 48
 	 * @return void
49 49
 	 */
50
-	public function widget( $args, $instance ) {
50
+	public function widget($args, $instance) {
51 51
 
52
-        $before_widget = $args[ 'before_widget' ];
53
-        $before_title  = $args[ 'before_title' ];
54
-        $after_title   = $args[ 'after_title' ];
55
-        $after_widget  = $args[ 'after_widget' ];
52
+        $before_widget = $args['before_widget'];
53
+        $before_title  = $args['before_title'];
54
+        $after_title   = $args['after_title'];
55
+        $after_widget  = $args['after_widget'];
56 56
 
57 57
         /* Our variables from the widget settings. */
58
-        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
58
+        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
59 59
 
60 60
         /* Before widget (defined by themes). */
61 61
         echo $before_widget;
62 62
 
63 63
         /* Display the widget title if one was input (before and after defined by themes). */
64
-        if ( $title ) { echo $before_title . $title . $after_title; }
64
+        if ($title) { echo $before_title.$title.$after_title; }
65 65
 
66 66
         /* Widget content. */
67 67
         // Add actions for plugins/themes to hook onto.
68
-        do_action( $this->woo_widget_cssclass . '_top' );
68
+        do_action($this->woo_widget_cssclass.'_top');
69 69
 
70
-        $this->load_component( $instance );
70
+        $this->load_component($instance);
71 71
 
72 72
         // Add actions for plugins/themes to hook onto.
73
-        do_action( $this->woo_widget_cssclass . '_bottom' );
73
+        do_action($this->woo_widget_cssclass.'_bottom');
74 74
 
75 75
         /* After widget (defined by themes). */
76 76
         echo $after_widget;
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	 * @param  array $old_instance Previous settings.
85 85
 	 * @return array               Updated settings.
86 86
 	 */
87
-	public function update ( $new_instance, $old_instance ) {
87
+	public function update($new_instance, $old_instance) {
88 88
 		$instance = $old_instance;
89 89
 
90 90
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
91
-		$instance['title'] = strip_tags( $new_instance['title'] );
91
+		$instance['title'] = strip_tags($new_instance['title']);
92 92
 
93 93
 		/* The select box is returning a text value, so we escape it. */
94
-		$instance['limit'] = esc_attr( $new_instance['limit'] );
94
+		$instance['limit'] = esc_attr($new_instance['limit']);
95 95
 
96 96
 		/* The check box is returning a boolean value. */
97 97
 		$instance['count'] = $new_instance['count'];
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @param  array $instance The settings for this instance.
108 108
 	 * @return void
109 109
 	 */
110
-    public function form( $instance ) {
110
+    public function form($instance) {
111 111
 
112 112
 		/* Set up some default widget settings. */
113 113
 		/* Make sure all keys are added here, even with empty string values. */
@@ -118,27 +118,27 @@  discard block
 block discarded – undo
118 118
 						'hierarchical' => false
119 119
 					);
120 120
 
121
-		$instance = wp_parse_args( (array) $instance, $defaults );
121
+		$instance = wp_parse_args((array) $instance, $defaults);
122 122
 ?>
123 123
 		<!-- Widget Title: Text Input -->
124 124
 		<p>
125
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
126
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
125
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
126
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
127 127
 		</p>
128 128
 		<!-- Widget Limit: Text Input -->
129 129
 		<p>
130
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Categories (optional):', 'woothemes-sensei' ); ?></label>
131
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
130
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Categories (optional):', 'woothemes-sensei'); ?></label>
131
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
132 132
 		</p>
133 133
 		<!-- Widget Show Count: Checkbox Input -->
134 134
 		<p>
135
-			<input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('count') ); ?>" name="<?php echo esc_attr( $this->get_field_name('count') ); ?>"<?php checked( $instance['count'], 'on' ); ?> />
136
-			<label for="<?php echo esc_attr( $this->get_field_id('count') ); ?>"><?php _e( 'Show post counts', 'woothemes-sensei' ); ?></label><br />
135
+			<input type="checkbox" class="checkbox" id="<?php echo esc_attr($this->get_field_id('count')); ?>" name="<?php echo esc_attr($this->get_field_name('count')); ?>"<?php checked($instance['count'], 'on'); ?> />
136
+			<label for="<?php echo esc_attr($this->get_field_id('count')); ?>"><?php _e('Show post counts', 'woothemes-sensei'); ?></label><br />
137 137
 		</p>
138 138
 		<!-- Widget Show Hierarchy: Checkbox Input -->
139 139
 		<p>
140
-			<input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id('hierarchical') ); ?>" name="<?php echo esc_attr( $this->get_field_name('hierarchical') ); ?>"<?php checked( $instance['hierarchical'], 'on' ); ?> />
141
-			<label for="<?php echo esc_attr( $this->get_field_id('hierarchical') ); ?>"><?php _e( 'Show hierarchy', 'woothemes-sensei' ); ?></label></p>
140
+			<input type="checkbox" class="checkbox" id="<?php echo esc_attr($this->get_field_id('hierarchical')); ?>" name="<?php echo esc_attr($this->get_field_name('hierarchical')); ?>"<?php checked($instance['hierarchical'], 'on'); ?> />
141
+			<label for="<?php echo esc_attr($this->get_field_id('hierarchical')); ?>"><?php _e('Show hierarchy', 'woothemes-sensei'); ?></label></p>
142 142
 		</p>
143 143
 <?php
144 144
 	} // End form()
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 * @since  1.1.0
150 150
 	 * @return void
151 151
 	 */
152
-	protected function load_component ( $instance ) {
152
+	protected function load_component($instance) {
153 153
 
154
-		$limit = intval( $instance['limit'] );
155
-		$count = isset($instance['count']) ? (bool) $instance['count'] :false;
156
-		$hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false;
154
+		$limit = intval($instance['limit']);
155
+		$count = isset($instance['count']) ? (bool) $instance['count'] : false;
156
+		$hierarchical = isset($instance['hierarchical']) ? (bool) $instance['hierarchical'] : false;
157 157
 
158
-		$cat_args = array( 'title_li' => '', 'taxonomy' => 'course-category', 'orderby' => 'name', 'show_count' => $count, 'hierarchical' => $hierarchical);
159
-		if ( 0 < $limit ) {
160
-			$cat_args[ 'number' ] = $limit;
158
+		$cat_args = array('title_li' => '', 'taxonomy' => 'course-category', 'orderby' => 'name', 'show_count' => $count, 'hierarchical' => $hierarchical);
159
+		if (0 < $limit) {
160
+			$cat_args['number'] = $limit;
161 161
 		} // End If Statement
162 162
 		echo '<ul>';
163
-			wp_list_categories( apply_filters('widget_course_categories_args', $cat_args) );
163
+			wp_list_categories(apply_filters('widget_course_categories_args', $cat_args));
164 164
 		echo '</ul>';
165 165
 	} // End load_component()
166 166
 } // End Class
167 167
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-sensei-learner-profiles.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
  * @since 1.4.0
11 11
  */
12 12
 class Sensei_Learner_Profiles {
13
-    /**
14
-     * @var string
15
-     */
16
-    private $profile_url_base;
13
+	/**
14
+	 * @var string
15
+	 */
16
+	private $profile_url_base;
17 17
 
18 18
 	/**
19 19
 	 * Constructor.
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function setup_permastruct() {
44 44
 
45
-        if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] )
46
-            && Sensei()->settings->settings[ 'learner_profile_enable' ] ) {
45
+		if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] )
46
+			&& Sensei()->settings->settings[ 'learner_profile_enable' ] ) {
47 47
 
48 48
 			add_rewrite_rule( '^' . $this->profile_url_base . '/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top' );
49 49
 			add_rewrite_tag( '%learner_profile%', '([^&]+)' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		if( isset( $wp_query->query_vars['learner_profile'] ) ) {
63 63
 			$learner_user = get_user_by( 'login', $wp_query->query_vars['learner_profile'] );
64 64
 
65
-            $name = Sensei_Learner::get_full_name( $learner_user->ID );
65
+			$name = Sensei_Learner::get_full_name( $learner_user->ID );
66 66
 
67 67
 			$title = apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . ' ' . $sep . ' ';
68 68
 		}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 			if( isset( $wp_query->query_vars['learner_profile'] ) ) {
112 112
 
113
-                Sensei_Templates::get_template( 'learner-profile/learner-info.php' );
113
+				Sensei_Templates::get_template( 'learner-profile/learner-info.php' );
114 114
 
115 115
 			}
116 116
 		}
@@ -140,43 +140,43 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public static function user_info( $user ) {
142 142
 
143
-        /**
144
-         * This hooke fires inside the Sensei_Learner_Profiles::user_info function.
145
-         * just before the htmls is generated.
146
-         * @since 1.0.0
147
-         */
148
-        do_action( 'sensei_learner_profile_info', $user );
149
-
150
-        /**
151
-         * This filter runs inside the Sensei_Learner_Profiles::user_info function.
152
-         * Here you can change the user avatar.
153
-         *
154
-         * @since 1.0.0
155
-         *
156
-         * @param false|string `<img>` $user_avatar
157
-         */
143
+		/**
144
+		 * This hooke fires inside the Sensei_Learner_Profiles::user_info function.
145
+		 * just before the htmls is generated.
146
+		 * @since 1.0.0
147
+		 */
148
+		do_action( 'sensei_learner_profile_info', $user );
149
+
150
+		/**
151
+		 * This filter runs inside the Sensei_Learner_Profiles::user_info function.
152
+		 * Here you can change the user avatar.
153
+		 *
154
+		 * @since 1.0.0
155
+		 *
156
+		 * @param false|string `<img>` $user_avatar
157
+		 */
158 158
 		$learner_avatar = apply_filters( 'sensei_learner_profile_info_avatar', get_avatar( $user->ID, 120 ), $user->ID );
159 159
 
160
-        /**
161
-         * This filter runs inside the Sensei_Learner_Profiles::user_info function.
162
-         * Here you can change the learner profile user display name.
163
-         * @since 1.0.0
164
-         *
165
-         * @param string $user_display_name
166
-         * @param string $user_id
167
-         */
160
+		/**
161
+		 * This filter runs inside the Sensei_Learner_Profiles::user_info function.
162
+		 * Here you can change the learner profile user display name.
163
+		 * @since 1.0.0
164
+		 *
165
+		 * @param string $user_display_name
166
+		 * @param string $user_id
167
+		 */
168 168
 		$learner_name = apply_filters( 'sensei_learner_profile_info_name', $user->display_name, $user->ID );
169 169
 
170
-        /**
171
-         * This filter runs inside the Sensei_Learner_Profiles::user_info function.
172
-         * With this filter can change the users description on the learner user info
173
-         * output.
174
-         *
175
-         * @since 1.0.0
176
-         *
177
-         * @param string $user_description
178
-         * @param string $user_id
179
-         */
170
+		/**
171
+		 * This filter runs inside the Sensei_Learner_Profiles::user_info function.
172
+		 * With this filter can change the users description on the learner user info
173
+		 * output.
174
+		 *
175
+		 * @since 1.0.0
176
+		 *
177
+		 * @param string $user_description
178
+		 * @param string $user_id
179
+		 */
180 180
 		$learner_bio = apply_filters( 'sensei_learner_profile_info_bio', $user->description, $user->ID );
181 181
 		?>
182 182
 
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
 		return $classes;
211 211
 	}
212 212
 
213
-    /**
214
-     * Deprecate the deprecate_sensei_learner_profile_content hook
215
-     *
216
-     * @since 1.9.0
217
-     */
218
-    public static function deprecate_sensei_learner_profile_content_hook(){
213
+	/**
214
+	 * Deprecate the deprecate_sensei_learner_profile_content hook
215
+	 *
216
+	 * @since 1.9.0
217
+	 */
218
+	public static function deprecate_sensei_learner_profile_content_hook(){
219 219
 
220
-        sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' );
220
+		sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' );
221 221
 
222
-    }
222
+	}
223 223
 
224 224
 
225 225
 } // End Class
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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
  * All functionality pertaining to the learner profiles in Sensei.
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
 	 * Constructor.
20 20
 	 * @since  1.4.0
21 21
 	 */
22
-	public function __construct () {
22
+	public function __construct() {
23 23
 
24 24
 		// Setup learner profile URL base
25
-		$this->profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') );
25
+		$this->profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei'));
26 26
 
27 27
 		// Setup permalink structure for learner profiles
28
-		add_action( 'init', array( $this, 'setup_permastruct' ) );
29
-		add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 );
28
+		add_action('init', array($this, 'setup_permastruct'));
29
+		add_filter('wp_title', array($this, 'page_title'), 10, 2);
30 30
 
31 31
 		// Set heading for courses section of learner profiles
32
-		add_action( 'sensei_learner_profile_info', array( $this, 'learner_profile_courses_heading' ), 30, 1 );
32
+		add_action('sensei_learner_profile_info', array($this, 'learner_profile_courses_heading'), 30, 1);
33 33
 
34 34
 		// Add class to body tag
35
-		add_filter( 'body_class', array( $this, 'learner_profile_body_class' ), 10, 1 );
35
+		add_filter('body_class', array($this, 'learner_profile_body_class'), 10, 1);
36 36
 	} // End __construct()
37 37
 
38 38
 	/**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function setup_permastruct() {
44 44
 
45
-        if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] )
46
-            && Sensei()->settings->settings[ 'learner_profile_enable' ] ) {
45
+        if (isset(Sensei()->settings->settings['learner_profile_enable'])
46
+            && Sensei()->settings->settings['learner_profile_enable']) {
47 47
 
48
-			add_rewrite_rule( '^' . $this->profile_url_base . '/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top' );
49
-			add_rewrite_tag( '%learner_profile%', '([^&]+)' );
48
+			add_rewrite_rule('^'.$this->profile_url_base.'/([^/]*)/?', 'index.php?learner_profile=$matches[1]', 'top');
49
+			add_rewrite_tag('%learner_profile%', '([^&]+)');
50 50
 
51 51
 		}
52 52
 	}
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	 * @param  string $sep   Seeparator string
58 58
 	 * @return string        Modified title
59 59
 	 */
60
-	public function page_title( $title, $sep = null ) {
60
+	public function page_title($title, $sep = null) {
61 61
 		global $wp_query;
62
-		if( isset( $wp_query->query_vars['learner_profile'] ) ) {
63
-			$learner_user = get_user_by( 'login', $wp_query->query_vars['learner_profile'] );
62
+		if (isset($wp_query->query_vars['learner_profile'])) {
63
+			$learner_user = get_user_by('login', $wp_query->query_vars['learner_profile']);
64 64
 
65
-            $name = Sensei_Learner::get_full_name( $learner_user->ID );
65
+            $name = Sensei_Learner::get_full_name($learner_user->ID);
66 66
 
67
-			$title = apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . ' ' . $sep . ' ';
67
+			$title = apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).' '.$sep.' ';
68 68
 		}
69 69
 		return $title;
70 70
 	}
@@ -75,23 +75,23 @@  discard block
 block discarded – undo
75 75
 	 * @param  integer $user_id ID of user
76 76
 	 * @return string           The learner profile permalink
77 77
 	 */
78
-	public function get_permalink( $user_id = 0 ) {
78
+	public function get_permalink($user_id = 0) {
79 79
 		$user = false;
80
-		if( $user_id == 0 ) {
80
+		if ($user_id == 0) {
81 81
 			global $current_user;
82 82
 			wp_get_current_user();
83 83
 			$user = $current_user;
84 84
 		} else {
85
-			$user = get_userdata( $user_id );
85
+			$user = get_userdata($user_id);
86 86
 		}
87 87
 
88 88
 		$permalink = '';
89 89
 
90
-		if( $user ) {
91
-			if ( get_option('permalink_structure') ) {
92
-				$permalink = trailingslashit( get_site_url() ) . $this->profile_url_base . '/' . $user->user_nicename;
90
+		if ($user) {
91
+			if (get_option('permalink_structure')) {
92
+				$permalink = trailingslashit(get_site_url()).$this->profile_url_base.'/'.$user->user_nicename;
93 93
 			} else {
94
-				$permalink = trailingslashit( get_site_url() ) . '?learner_profile=' . $user->user_nicename;
94
+				$permalink = trailingslashit(get_site_url()).'?learner_profile='.$user->user_nicename;
95 95
 			}
96 96
 		}
97 97
 
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 */
106 106
 	public function content() {
107
-		global $wp_query,  $learner_user, $current_user;
107
+		global $wp_query, $learner_user, $current_user;
108 108
 
109
-		if( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) {
109
+		if (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable']) {
110 110
 
111
-			if( isset( $wp_query->query_vars['learner_profile'] ) ) {
111
+			if (isset($wp_query->query_vars['learner_profile'])) {
112 112
 
113
-                Sensei_Templates::get_template( 'learner-profile/learner-info.php' );
113
+                Sensei_Templates::get_template('learner-profile/learner-info.php');
114 114
 
115 115
 			}
116 116
 		}
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 	 * @param  object $user Queried user object
123 123
 	 * @return void
124 124
 	 */
125
-	public function learner_profile_courses_heading( $user ) {
126
-		if( strlen( $user->first_name ) > 0 ) {
125
+	public function learner_profile_courses_heading($user) {
126
+		if (strlen($user->first_name) > 0) {
127 127
 			$name = $user->first_name;
128 128
 		} else {
129 129
 			$name = $user->display_name;
130 130
 		}
131
-		$name = apply_filters( 'sensei_learner_profile_courses_heading_name', $name );
132
-		echo '<h2>' . apply_filters( 'sensei_learner_profile_courses_heading', sprintf( __( 'Courses %s is taking', 'woothemes-sensei' ), $name ) ) . '</h2>';
131
+		$name = apply_filters('sensei_learner_profile_courses_heading_name', $name);
132
+		echo '<h2>'.apply_filters('sensei_learner_profile_courses_heading', sprintf(__('Courses %s is taking', 'woothemes-sensei'), $name)).'</h2>';
133 133
 	}
134 134
 
135 135
 	/**
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	 * @param  object $user Queried user object
139 139
 	 * @return void
140 140
 	 */
141
-	public static function user_info( $user ) {
141
+	public static function user_info($user) {
142 142
 
143 143
         /**
144 144
          * This hooke fires inside the Sensei_Learner_Profiles::user_info function.
145 145
          * just before the htmls is generated.
146 146
          * @since 1.0.0
147 147
          */
148
-        do_action( 'sensei_learner_profile_info', $user );
148
+        do_action('sensei_learner_profile_info', $user);
149 149
 
150 150
         /**
151 151
          * This filter runs inside the Sensei_Learner_Profiles::user_info function.
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
          *
156 156
          * @param false|string `<img>` $user_avatar
157 157
          */
158
-		$learner_avatar = apply_filters( 'sensei_learner_profile_info_avatar', get_avatar( $user->ID, 120 ), $user->ID );
158
+		$learner_avatar = apply_filters('sensei_learner_profile_info_avatar', get_avatar($user->ID, 120), $user->ID);
159 159
 
160 160
         /**
161 161
          * This filter runs inside the Sensei_Learner_Profiles::user_info function.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
          * @param string $user_display_name
166 166
          * @param string $user_id
167 167
          */
168
-		$learner_name = apply_filters( 'sensei_learner_profile_info_name', $user->display_name, $user->ID );
168
+		$learner_name = apply_filters('sensei_learner_profile_info_name', $user->display_name, $user->ID);
169 169
 
170 170
         /**
171 171
          * This filter runs inside the Sensei_Learner_Profiles::user_info function.
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
          * @param string $user_description
178 178
          * @param string $user_id
179 179
          */
180
-		$learner_bio = apply_filters( 'sensei_learner_profile_info_bio', $user->description, $user->ID );
180
+		$learner_bio = apply_filters('sensei_learner_profile_info_bio', $user->description, $user->ID);
181 181
 		?>
182 182
 
183 183
 		<div id="learner-info">
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
 				<h2><?php echo $learner_name; ?></h2>
190 190
 
191
-				<div class="description"><?php echo wpautop( $learner_bio ); ?></div>
191
+				<div class="description"><?php echo wpautop($learner_bio); ?></div>
192 192
 
193 193
 			</div>
194 194
 
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 	 * @param  array $classes Existing classes
203 203
 	 * @return array          Modified classes
204 204
 	 */
205
-	public function learner_profile_body_class( $classes ) {
205
+	public function learner_profile_body_class($classes) {
206 206
 		global $wp_query;
207
-		if( isset( $wp_query->query_vars['learner_profile'] ) ) {
207
+		if (isset($wp_query->query_vars['learner_profile'])) {
208 208
 			$classes[] = 'learner-profile';
209 209
 		}
210 210
 		return $classes;
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
      *
216 216
      * @since 1.9.0
217 217
      */
218
-    public static function deprecate_sensei_learner_profile_content_hook(){
218
+    public static function deprecate_sensei_learner_profile_content_hook() {
219 219
 
220
-        sensei_do_deprecated_action( 'sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before' );
220
+        sensei_do_deprecated_action('sensei_learner_profile_content', '1.9.0', 'sensei_learner_profile_content_before');
221 221
 
222 222
     }
223 223
 
Please login to merge, or discard this patch.
includes/class-sensei-grading-main.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Sensei_Grading_Main extends WooThemes_Sensei_List_Table {
12 12
 
13
-    public $user_id;
13
+	public $user_id;
14 14
 	public $course_id;
15 15
 	public $lesson_id;
16 16
 	public $view;
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			$grade = __( 'N/A', 'woothemes-sensei' );
250 250
 		}
251 251
 
252
-        $title = Sensei_Learner::get_full_name( $item->user_id );
252
+		$title = Sensei_Learner::get_full_name( $item->user_id );
253 253
 
254 254
 		// QuizID to be deprecated
255 255
 		$quiz_id = get_post_meta( $item->comment_post_ID, '_lesson_quiz', true );
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function no_items() {
301 301
 
302
-        _e( 'No submissions found.', 'woothemes-sensei' );
302
+		_e( 'No submissions found.', 'woothemes-sensei' );
303 303
 
304 304
 	} // End no_items()
305 305
 
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 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
  * Admin Grading Overview Data Table in Sensei.
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * Constructor
22 22
 	 * @since  1.3.0
23 23
 	 */
24
-	public function __construct ( $args = null ) {
24
+	public function __construct($args = null) {
25 25
 
26 26
 		$defaults = array(
27 27
 			'course_id' => 0,
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
 			'user_id' => false,
30 30
 			'view' => 'ungraded',
31 31
 		);
32
-		$args = wp_parse_args( $args, $defaults );
32
+		$args = wp_parse_args($args, $defaults);
33 33
 
34
-		$this->course_id = intval( $args['course_id'] );
35
-		$this->lesson_id = intval( $args['lesson_id'] );
36
-		if ( !empty($args['user_id']) ) {
37
-			$this->user_id = intval( $args['user_id'] );
34
+		$this->course_id = intval($args['course_id']);
35
+		$this->lesson_id = intval($args['lesson_id']);
36
+		if ( ! empty($args['user_id'])) {
37
+			$this->user_id = intval($args['user_id']);
38 38
 		}
39 39
 
40
-		if( !empty( $args['view'] ) && in_array( $args['view'], array( 'in-progress', 'graded', 'ungraded', 'all' ) ) ) {
40
+		if ( ! empty($args['view']) && in_array($args['view'], array('in-progress', 'graded', 'ungraded', 'all'))) {
41 41
 			$this->view = $args['view'];
42 42
 		}
43 43
 
44 44
 		// Load Parent token into constructor
45
-		parent::__construct( 'grading_main' );
45
+		parent::__construct('grading_main');
46 46
 
47 47
 		// Actions
48
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
49
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
48
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
49
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
50 50
 	} // End __construct()
51 51
 
52 52
 	/**
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_columns() {
58 58
 		$columns = array(
59
-			'title' => __( 'Learner', 'woothemes-sensei' ),
60
-			'course' => __( 'Course', 'woothemes-sensei' ),
61
-			'lesson' => __( 'Lesson', 'woothemes-sensei' ),
62
-			'updated' => __( 'Updated', 'woothemes-sensei' ),
63
-			'user_status' => __( 'Status', 'woothemes-sensei' ),
64
-			'user_grade' => __( 'Grade', 'woothemes-sensei' ),
59
+			'title' => __('Learner', 'woothemes-sensei'),
60
+			'course' => __('Course', 'woothemes-sensei'),
61
+			'lesson' => __('Lesson', 'woothemes-sensei'),
62
+			'updated' => __('Updated', 'woothemes-sensei'),
63
+			'user_status' => __('Status', 'woothemes-sensei'),
64
+			'user_grade' => __('Grade', 'woothemes-sensei'),
65 65
 			'action' => '',
66 66
 		);
67 67
 
68
-		$columns = apply_filters( 'sensei_grading_default_columns', $columns, $this );
68
+		$columns = apply_filters('sensei_grading_default_columns', $columns, $this);
69 69
 		return $columns;
70 70
 	}
71 71
 
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	function get_sortable_columns() {
78 78
 		$columns = array(
79
-			'title' => array( 'title', false ),
80
-			'course' => array( 'course', false ),
81
-			'lesson' => array( 'lesson', false ),
82
-			'updated' => array( 'updated', false ),
83
-			'user_status' => array( 'user_status', false ),
84
-			'user_grade' => array( 'user_grade', false ),
79
+			'title' => array('title', false),
80
+			'course' => array('course', false),
81
+			'lesson' => array('lesson', false),
82
+			'updated' => array('updated', false),
83
+			'user_status' => array('user_status', false),
84
+			'user_grade' => array('user_grade', false),
85 85
 		);
86
-		$columns = apply_filters( 'sensei_grading_default_columns_sortable', $columns, $this );
86
+		$columns = apply_filters('sensei_grading_default_columns_sortable', $columns, $this);
87 87
 		return $columns;
88 88
 	}
89 89
 
@@ -97,47 +97,47 @@  discard block
 block discarded – undo
97 97
 
98 98
 		// Handle orderby
99 99
 		$orderby = '';
100
-		if ( !empty( $_GET['orderby'] ) ) {
101
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
102
-				$orderby = esc_html( $_GET['orderby'] );
100
+		if ( ! empty($_GET['orderby'])) {
101
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
102
+				$orderby = esc_html($_GET['orderby']);
103 103
 			} // End If Statement
104 104
 		}
105 105
 
106 106
 		// Handle order
107 107
 		$order = 'DESC';
108
-		if ( !empty( $_GET['order'] ) ) {
109
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
108
+		if ( ! empty($_GET['order'])) {
109
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
110 110
 		}
111 111
 
112 112
 		// Handle search
113 113
 		$search = false;
114
-		if ( !empty( $_GET['s'] ) ) {
115
-			$search = esc_html( $_GET['s'] );
114
+		if ( ! empty($_GET['s'])) {
115
+			$search = esc_html($_GET['s']);
116 116
 		} // End If Statement
117 117
 		$this->search = $search;
118 118
 
119 119
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
120
-		if ( $this->search ) {
120
+		if ($this->search) {
121 121
 			$user_args = array(
122
-				'search' => '*' . $this->search . '*',
122
+				'search' => '*'.$this->search.'*',
123 123
 				'fields' => 'ID',
124 124
 			);
125 125
 			// Filter for extending
126
-			$user_args = apply_filters( 'sensei_grading_search_users', $user_args );
127
-			if ( !empty( $user_args ) ) {
128
-				$learners_search = new WP_User_Query( $user_args );
126
+			$user_args = apply_filters('sensei_grading_search_users', $user_args);
127
+			if ( ! empty($user_args)) {
128
+				$learners_search = new WP_User_Query($user_args);
129 129
 				// Store for reuse on counts
130 130
 				$this->user_ids = $learners_search->get_results();
131 131
 			}
132 132
 		} // End If Statement
133 133
 
134
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
135
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
134
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
135
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
136 136
 
137 137
 		$paged = $this->get_pagenum();
138 138
 		$offset = 0;
139
-		if ( !empty($paged) ) {
140
-			$offset = $per_page * ( $paged - 1 );
139
+		if ( ! empty($paged)) {
140
+			$offset = $per_page * ($paged - 1);
141 141
 		} // End If Statement
142 142
 
143 143
 		$activity_args = array(
@@ -149,27 +149,27 @@  discard block
 block discarded – undo
149 149
 			'status' => 'any',
150 150
 		);
151 151
 
152
-		if( $this->lesson_id ) {
152
+		if ($this->lesson_id) {
153 153
 			$activity_args['post_id'] = $this->lesson_id;
154 154
 		}
155
-		elseif( $this->course_id ) {
155
+		elseif ($this->course_id) {
156 156
 			// Currently not possible to restrict to a single Course, as that requires WP_Comment to support multiple
157 157
 			// post_ids (i.e. every lesson within the Course), WP 4.1 ( https://core.trac.wordpress.org/changeset/29808 )
158
-			if ( version_compare($wp_version, '4.1', '>=') ) {
159
-				$activity_args['post__in'] = Sensei()->course->course_lessons( $this->course_id, 'any', 'ids' );
158
+			if (version_compare($wp_version, '4.1', '>=')) {
159
+				$activity_args['post__in'] = Sensei()->course->course_lessons($this->course_id, 'any', 'ids');
160 160
 			}
161 161
 		}
162 162
 		// Sub select to group of learners
163
-		if ( $this->user_ids ) {
163
+		if ($this->user_ids) {
164 164
 			$activity_args['user_id'] = (array) $this->user_ids;
165 165
 		}
166 166
 		// Restrict to a single Learner
167
-		if( $this->user_id ) {
167
+		if ($this->user_id) {
168 168
 			$activity_args['user_id'] = $this->user_id;
169 169
 		}
170 170
 
171 171
 
172
-		switch( $this->view ) {
172
+		switch ($this->view) {
173 173
 			case 'in-progress' :
174 174
 				$activity_args['status'] = 'in-progress';
175 175
 				break;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 				break;
180 180
 
181 181
 			case 'graded' :
182
-				$activity_args['status'] = array( 'graded', 'passed', 'failed' );
182
+				$activity_args['status'] = array('graded', 'passed', 'failed');
183 183
 				break;
184 184
 
185 185
 			case 'all' :
@@ -188,31 +188,31 @@  discard block
 block discarded – undo
188 188
 				break;
189 189
 		} // End switch
190 190
 
191
-		$activity_args = apply_filters( 'sensei_grading_filter_statuses', $activity_args );
191
+		$activity_args = apply_filters('sensei_grading_filter_statuses', $activity_args);
192 192
 
193 193
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
194
-		$total_statuses = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
194
+		$total_statuses = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
195 195
 
196 196
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
197
-		if ( $total_statuses < $activity_args['offset'] ) {
198
-			$new_paged = floor( $total_statuses / $activity_args['number'] );
197
+		if ($total_statuses < $activity_args['offset']) {
198
+			$new_paged = floor($total_statuses / $activity_args['number']);
199 199
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
200 200
 		}
201
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
201
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
202 202
 		// Need to always return an array, even with only 1 item
203
-		if ( !is_array($statuses) ) {
204
-			$statuses = array( $statuses );
203
+		if ( ! is_array($statuses)) {
204
+			$statuses = array($statuses);
205 205
 		}
206 206
 		$this->total_items = $total_statuses;
207 207
 		$this->items = $statuses;
208 208
 
209 209
 		$total_items = $this->total_items;
210
-		$total_pages = ceil( $total_items / $per_page );
211
-		$this->set_pagination_args( array(
210
+		$total_pages = ceil($total_items / $per_page);
211
+		$this->set_pagination_args(array(
212 212
 			'total_items' => $total_items,
213 213
 			'total_pages' => $total_pages,
214 214
 			'per_page' => $per_page
215
-		) );
215
+		));
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,73 +220,73 @@  discard block
 block discarded – undo
220 220
 	 * @since  1.7.0
221 221
 	 * @param object $item The current item
222 222
 	 */
223
-	protected function get_row_data( $item ) {
223
+	protected function get_row_data($item) {
224 224
 		global $wp_version;
225 225
 
226 226
 		$grade = '';
227
-		if( 'complete' == $item->comment_approved ) {
228
-			$status_html = '<span class="graded">' . __( 'Completed', 'woothemes-sensei' ) . '</span>';
229
-			$grade =  __( 'No Grade', 'woothemes-sensei' );
227
+		if ('complete' == $item->comment_approved) {
228
+			$status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>';
229
+			$grade = __('No Grade', 'woothemes-sensei');
230 230
 		}
231
-		elseif( 'graded' == $item->comment_approved ) {
232
-			$status_html = '<span class="graded">' .  __( 'Graded', 'woothemes-sensei' )  . '</span>';
233
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%';
231
+		elseif ('graded' == $item->comment_approved) {
232
+			$status_html = '<span class="graded">'.__('Graded', 'woothemes-sensei').'</span>';
233
+			$grade = get_comment_meta($item->comment_ID, 'grade', true).'%';
234 234
 		}
235
-		elseif( 'passed' == $item->comment_approved ) {
236
-			$status_html = '<span class="passed">' .  __( 'Passed', 'woothemes-sensei' )  . '</span>';
237
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%';
235
+		elseif ('passed' == $item->comment_approved) {
236
+			$status_html = '<span class="passed">'.__('Passed', 'woothemes-sensei').'</span>';
237
+			$grade = get_comment_meta($item->comment_ID, 'grade', true).'%';
238 238
 		}
239
-		elseif( 'failed' == $item->comment_approved ) {
240
-			$status_html = '<span class="failed">' .  __( 'Failed', 'woothemes-sensei' )  . '</span>';
241
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%';
239
+		elseif ('failed' == $item->comment_approved) {
240
+			$status_html = '<span class="failed">'.__('Failed', 'woothemes-sensei').'</span>';
241
+			$grade = get_comment_meta($item->comment_ID, 'grade', true).'%';
242 242
 		}
243
-		elseif( 'ungraded' == $item->comment_approved ) {
244
-			$status_html = '<span class="ungraded">' .  __( 'Ungraded', 'woothemes-sensei' )  . '</span>';
245
-			$grade = __( 'N/A', 'woothemes-sensei' );
243
+		elseif ('ungraded' == $item->comment_approved) {
244
+			$status_html = '<span class="ungraded">'.__('Ungraded', 'woothemes-sensei').'</span>';
245
+			$grade = __('N/A', 'woothemes-sensei');
246 246
 		}
247 247
 		else {
248
-			$status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
249
-			$grade = __( 'N/A', 'woothemes-sensei' );
248
+			$status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
249
+			$grade = __('N/A', 'woothemes-sensei');
250 250
 		}
251 251
 
252
-        $title = Sensei_Learner::get_full_name( $item->user_id );
252
+        $title = Sensei_Learner::get_full_name($item->user_id);
253 253
 
254 254
 		// QuizID to be deprecated
255
-		$quiz_id = get_post_meta( $item->comment_post_ID, '_lesson_quiz', true );
256
-		$quiz_link = esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user' => $item->user_id, 'quiz_id' => $quiz_id ), admin_url( 'admin.php' ) ) );
255
+		$quiz_id = get_post_meta($item->comment_post_ID, '_lesson_quiz', true);
256
+		$quiz_link = esc_url(add_query_arg(array('page' => $this->page_slug, 'user' => $item->user_id, 'quiz_id' => $quiz_id), admin_url('admin.php')));
257 257
 
258 258
 		$grade_link = '';
259
-		switch( $item->comment_approved ) {
259
+		switch ($item->comment_approved) {
260 260
 			case 'ungraded':
261
-				$grade_link = '<a class="button-primary button" href="' . $quiz_link . '">' . __('Grade quiz', 'woothemes-sensei' ) . '</a>';
261
+				$grade_link = '<a class="button-primary button" href="'.$quiz_link.'">'.__('Grade quiz', 'woothemes-sensei').'</a>';
262 262
 				break;
263 263
 
264 264
 			case 'graded':
265 265
 			case 'passed':
266 266
 			case 'failed':
267
-				$grade_link = '<a class="button-secondary button" href="' . $quiz_link . '">' . __('Review grade', 'woothemes-sensei' ) . '</a>';
267
+				$grade_link = '<a class="button-secondary button" href="'.$quiz_link.'">'.__('Review grade', 'woothemes-sensei').'</a>';
268 268
 				break;
269 269
 		}
270 270
 
271
-		$course_id = get_post_meta( $item->comment_post_ID, '_lesson_course', true );
271
+		$course_id = get_post_meta($item->comment_post_ID, '_lesson_course', true);
272 272
 		$course_title = '';
273
-		if ( !empty($course_id) && version_compare($wp_version, '4.1', '>=') ) {
274
-			$course_title = '<a href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ) ) . '">' . get_the_title( $course_id ) . '</a>';
273
+		if ( ! empty($course_id) && version_compare($wp_version, '4.1', '>=')) {
274
+			$course_title = '<a href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'))).'">'.get_the_title($course_id).'</a>';
275 275
 		}
276
-		else if ( !empty($course_id) ) {
277
-			$course_title = get_the_title( $course_id );
276
+		else if ( ! empty($course_id)) {
277
+			$course_title = get_the_title($course_id);
278 278
 		}
279
-		$lesson_title = '<a href="' . add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) ) . '">' . get_the_title( $item->comment_post_ID ) . '</a>';
279
+		$lesson_title = '<a href="'.add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->comment_post_ID), admin_url('admin.php')).'">'.get_the_title($item->comment_post_ID).'</a>';
280 280
 
281
-		$column_data = apply_filters( 'sensei_grading_main_column_data', array(
282
-				'title' => '<strong><a class="row-title" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id ), admin_url( 'admin.php' ) ) ) . '"">' . $title . '</a></strong>',
281
+		$column_data = apply_filters('sensei_grading_main_column_data', array(
282
+				'title' => '<strong><a class="row-title" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id), admin_url('admin.php'))).'"">'.$title.'</a></strong>',
283 283
 				'course' => $course_title,
284 284
 				'lesson' => $lesson_title,
285 285
 				'updated' => $item->comment_date,
286 286
 				'user_status' => $status_html,
287 287
 				'user_grade' => $grade,
288 288
 				'action' => $grade_link,
289
-			), $item, $course_id );
289
+			), $item, $course_id);
290 290
 
291 291
 		return $column_data;
292 292
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function no_items() {
301 301
 
302
-        _e( 'No submissions found.', 'woothemes-sensei' );
302
+        _e('No submissions found.', 'woothemes-sensei');
303 303
 
304 304
 	} // End no_items()
305 305
 
@@ -312,35 +312,35 @@  discard block
 block discarded – undo
312 312
 		global  $wp_version;
313 313
 
314 314
 		echo '<div class="grading-selects">';
315
-		do_action( 'sensei_grading_before_dropdown_filters' );
315
+		do_action('sensei_grading_before_dropdown_filters');
316 316
 
317
-		echo '<div class="select-box">' . "\n";
317
+		echo '<div class="select-box">'."\n";
318 318
 
319
-			echo '<select id="grading-course-options" name="grading_course" class="chosen_select widefat">' . "\n";
319
+			echo '<select id="grading-course-options" name="grading_course" class="chosen_select widefat">'."\n";
320 320
 
321
-				echo Sensei()->grading->courses_drop_down_html( $this->course_id );
321
+				echo Sensei()->grading->courses_drop_down_html($this->course_id);
322 322
 
323
-			echo '</select>' . "\n";
323
+			echo '</select>'."\n";
324 324
 
325
-		echo '</div>' . "\n";
325
+		echo '</div>'."\n";
326 326
 
327
-		echo '<div class="select-box">' . "\n";
327
+		echo '<div class="select-box">'."\n";
328 328
 
329
-			echo '<select id="grading-lesson-options" data-placeholder="&larr; ' . __( 'Select a course', 'woothemes-sensei' ) . '" name="grading_lesson" class="chosen_select widefat">' . "\n";
329
+			echo '<select id="grading-lesson-options" data-placeholder="&larr; '.__('Select a course', 'woothemes-sensei').'" name="grading_lesson" class="chosen_select widefat">'."\n";
330 330
 
331
-				echo Sensei()->grading->lessons_drop_down_html( $this->course_id, $this->lesson_id );
331
+				echo Sensei()->grading->lessons_drop_down_html($this->course_id, $this->lesson_id);
332 332
 
333
-			echo '</select>' . "\n";
333
+			echo '</select>'."\n";
334 334
 
335
-		echo '</div>' . "\n";
335
+		echo '</div>'."\n";
336 336
 
337
-		if( $this->course_id && $this->lesson_id ) {
337
+		if ($this->course_id && $this->lesson_id) {
338 338
 
339
-			echo '<div class="select-box reset-filter">' . "\n";
339
+			echo '<div class="select-box reset-filter">'."\n";
340 340
 
341
-				echo '<a class="button-secondary" href="' . esc_url( remove_query_arg( array( 'lesson_id', 'course_id' ) ) ) . '">' . __( 'Reset filter', 'woothemes-sensei' ) . '</a>' . "\n";
341
+				echo '<a class="button-secondary" href="'.esc_url(remove_query_arg(array('lesson_id', 'course_id'))).'">'.__('Reset filter', 'woothemes-sensei').'</a>'."\n";
342 342
 
343
-			echo '</div>' . "\n";
343
+			echo '</div>'."\n";
344 344
 
345 345
 		}
346 346
 
@@ -355,26 +355,26 @@  discard block
 block discarded – undo
355 355
 		$query_args = array(
356 356
 			'page' => $this->page_slug,
357 357
 		);
358
-		if( $this->course_id ) {
358
+		if ($this->course_id) {
359 359
 			// Currently not possible to restrict to a single Course, as that requires WP_Comment to support multiple
360 360
 			// post_ids (i.e. every lesson within the Course), WP 4.1 ( https://core.trac.wordpress.org/changeset/29808 )
361 361
 			$query_args['course_id'] = $this->course_id;
362
-			if ( version_compare($wp_version, '4.1', '>=') ) {
363
-				$count_args['post__in'] = Sensei()->course->course_lessons( $this->course_id, 'any', 'ids' );
362
+			if (version_compare($wp_version, '4.1', '>=')) {
363
+				$count_args['post__in'] = Sensei()->course->course_lessons($this->course_id, 'any', 'ids');
364 364
 			}
365 365
 		}
366
-		if( $this->lesson_id ) {
366
+		if ($this->lesson_id) {
367 367
 			$query_args['lesson_id'] = $this->lesson_id;
368 368
 			// Restrict to a single lesson
369 369
 			$count_args['post_id'] = $this->lesson_id;
370 370
 		}
371
-		if( $this->search ) {
371
+		if ($this->search) {
372 372
 			$query_args['s'] = $this->search;
373 373
 		}
374
-		if ( !empty($this->user_ids) ) {
374
+		if ( ! empty($this->user_ids)) {
375 375
 			$count_args['user_id'] = $this->user_ids;
376 376
 		}
377
-		if( !empty($this->user_id) ) {
377
+		if ( ! empty($this->user_id)) {
378 378
 			$query_args['user_id'] = $this->user_id;
379 379
 			$count_args['user_id'] = $this->user_id;
380 380
 		}
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		$all_lessons_count = $ungraded_lessons_count = $graded_lessons_count = $inprogress_lessons_count = 0;
383 383
 		$all_class = $ungraded_class = $graded_class = $inprogress_class = '';
384 384
 
385
-		switch( $this->view ) :
385
+		switch ($this->view) :
386 386
 			case 'all':
387 387
 				$all_class = 'current';
388 388
 				break;
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 				break;
399 399
 		endswitch;
400 400
 
401
-		$counts = Sensei()->grading->count_statuses( apply_filters( 'sensei_grading_count_statues', $count_args ) );
401
+		$counts = Sensei()->grading->count_statuses(apply_filters('sensei_grading_count_statues', $count_args));
402 402
 
403 403
 		$inprogress_lessons_count = $counts['in-progress'];
404 404
 		$ungraded_lessons_count = $counts['ungraded'];
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
 		$inprogress_args['view'] = 'in-progress';
415 415
 
416 416
 		$format = '<a class="%s" href="%s">%s <span class="count">(%s)</span></a>';
417
-		$menu['all'] = sprintf( $format, $all_class, esc_url( add_query_arg( $all_args, admin_url( 'admin.php' ) ) ), __( 'All', 'woothemes-sensei' ), number_format( (int) $all_lessons_count ) );
418
-		$menu['ungraded'] = sprintf( $format, $ungraded_class, esc_url( add_query_arg( $ungraded_args, admin_url( 'admin.php' ) ) ), __( 'Ungraded', 'woothemes-sensei' ), number_format( (int) $ungraded_lessons_count ) );
419
-		$menu['graded'] = sprintf( $format, $graded_class, esc_url( add_query_arg( $graded_args, admin_url( 'admin.php' ) ) ), __( 'Graded', 'woothemes-sensei' ), number_format( (int) $graded_lessons_count ) );
420
-		$menu['in-progress'] = sprintf( $format, $inprogress_class, esc_url( add_query_arg( $inprogress_args, admin_url( 'admin.php' ) ) ), __( 'In Progress', 'woothemes-sensei' ), number_format( (int) $inprogress_lessons_count ) );
421
-
422
-		$menu = apply_filters( 'sensei_grading_sub_menu', $menu );
423
-		if ( !empty($menu) ) {
424
-			echo '<ul class="subsubsub">' . "\n";
425
-			foreach ( $menu as $class => $item ) {
426
-				$menu[ $class ] = "\t<li class='$class'>$item";
417
+		$menu['all'] = sprintf($format, $all_class, esc_url(add_query_arg($all_args, admin_url('admin.php'))), __('All', 'woothemes-sensei'), number_format((int) $all_lessons_count));
418
+		$menu['ungraded'] = sprintf($format, $ungraded_class, esc_url(add_query_arg($ungraded_args, admin_url('admin.php'))), __('Ungraded', 'woothemes-sensei'), number_format((int) $ungraded_lessons_count));
419
+		$menu['graded'] = sprintf($format, $graded_class, esc_url(add_query_arg($graded_args, admin_url('admin.php'))), __('Graded', 'woothemes-sensei'), number_format((int) $graded_lessons_count));
420
+		$menu['in-progress'] = sprintf($format, $inprogress_class, esc_url(add_query_arg($inprogress_args, admin_url('admin.php'))), __('In Progress', 'woothemes-sensei'), number_format((int) $inprogress_lessons_count));
421
+
422
+		$menu = apply_filters('sensei_grading_sub_menu', $menu);
423
+		if ( ! empty($menu)) {
424
+			echo '<ul class="subsubsub">'."\n";
425
+			foreach ($menu as $class => $item) {
426
+				$menu[$class] = "\t<li class='$class'>$item";
427 427
 			}
428
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
429
-			echo '</ul>' . "\n";
428
+			echo implode(" |</li>\n", $menu)."</li>\n";
429
+			echo '</ul>'."\n";
430 430
 		}
431 431
 
432 432
 	} // End data_table_header()
@@ -447,4 +447,4 @@  discard block
 block discarded – undo
447 447
  * @ignore only for backward compatibility
448 448
  * @since 1.9.0
449 449
  */
450
-class WooThemes_Sensei_Grading_Main extends Sensei_Grading_Main{}
450
+class WooThemes_Sensei_Grading_Main extends Sensei_Grading_Main {}
Please login to merge, or discard this patch.