Completed
Push — master ( f45963...ffd8a9 )
by Dwain
05:01
created
templates/globals/pagination-posts.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Pagination - Posts
4
- *
5
- * @author 		WooThemes
6
- * @package 	Sensei/Templates
7
- * @version     1.1.0
8
- */
3
+	 * Pagination - Posts
4
+	 *
5
+	 * @author 		WooThemes
6
+	 * @package 	Sensei/Templates
7
+	 * @version     1.1.0
8
+	 */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) exit;
11 11
 
Please login to merge, or discard this patch.
templates/loop-message.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for outputting Message Archive items
5
- *
6
- * Override this template by copying it to yourtheme/sensei/loop-message.php
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+	 * The Template for outputting Message Archive items
5
+	 *
6
+	 * Override this template by copying it to yourtheme/sensei/loop-message.php
7
+	 *
8
+	 * @author 		Automattic
9
+	 * @package 	Sensei
10
+	 * @category    Templates
11
+	 * @version     1.9.0
12
+	 */
13 13
 ?>
14 14
 
15 15
 <?php
16 16
 /**
17
- * This runs before the the message loop items in the loop-message.php template. It runs
18
- * only only for the message post type. This loop will not run if the current wp_query
19
- * has no posts.
20
- *
21
- * @since 1.9.0
22
- */
17
+	 * This runs before the the message loop items in the loop-message.php template. It runs
18
+	 * only only for the message post type. This loop will not run if the current wp_query
19
+	 * has no posts.
20
+	 *
21
+	 * @since 1.9.0
22
+	 */
23 23
 do_action( 'sensei_loop_message_before' );
24 24
 ?>
25 25
 
26 26
 <div class="message-container" >
27 27
 
28 28
     <?php
29
-    /**
30
-     * This runs before the post type items in the loop.php template. It
31
-     * runs within the message loop <ul> tag.
32
-     *
33
-     * @since 1.9.0
34
-     */
35
-    do_action( 'sensei_loop_message_inside_before' );
36
-    ?>
29
+	/**
30
+	 * This runs before the post type items in the loop.php template. It
31
+	 * runs within the message loop <ul> tag.
32
+	 *
33
+	 * @since 1.9.0
34
+	 */
35
+	do_action( 'sensei_loop_message_inside_before' );
36
+	?>
37 37
 
38 38
     <?php
39
-    // loop through all messages
40
-    while ( have_posts() ) { the_post();
39
+	// loop through all messages
40
+	while ( have_posts() ) { the_post();
41 41
 
42
-        sensei_load_template_part('content','message');
42
+		sensei_load_template_part('content','message');
43 43
 
44
-    }
45
-    ?>
44
+	}
45
+	?>
46 46
 
47 47
     <?php
48
-    /**
49
-     * This runs after the post type items in the loop.php template. It runs
50
-     * only for the specified post type
51
-     *
52
-     * @since 1.9.0
53
-     */
54
-    do_action( 'sensei_loop_message_inside_after' );
55
-    ?>
48
+	/**
49
+	 * This runs after the post type items in the loop.php template. It runs
50
+	 * only for the specified post type
51
+	 *
52
+	 * @since 1.9.0
53
+	 */
54
+	do_action( 'sensei_loop_message_inside_after' );
55
+	?>
56 56
 
57 57
 </div>
58 58
 
59 59
 <?php
60 60
 /**
61
- * This runs after the post type items in the loop.php template. It runs
62
- * only for the specified post type
63
- *
64
- * @since 1.9.0
65
- */
61
+	 * This runs after the post type items in the loop.php template. It runs
62
+	 * only for the specified post type
63
+	 *
64
+	 * @since 1.9.0
65
+	 */
66 66
 do_action( 'sensei_loop_message_after' );
67 67
 ?>
Please login to merge, or discard this patch.
templates/emails/admin-teacher-new-course-created.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Teacher new message email
4
- *
5
- * @author WooThemes
6
- * @package Sensei/Templates/Emails/HTML
7
- */
3
+	 * Teacher new message email
4
+	 *
5
+	 * @author WooThemes
6
+	 * @package Sensei/Templates/Emails/HTML
7
+	 */
8 8
 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9 9
 
10 10
 // Get data for email content
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 <p style="<?php echo esc_attr( $style_small ); ?>">
36 36
     <?php
37 37
 
38
-    echo __( 'You can review and publish the new course here:  ', 'woothemes-sensei' ) . '<a href="' . esc_url( $sensei_email_data['course_edit_link'] ) . '">'. $sensei_email_data['course_name']. '</a>';
38
+	echo __( 'You can review and publish the new course here:  ', 'woothemes-sensei' ) . '<a href="' . esc_url( $sensei_email_data['course_edit_link'] ) . '">'. $sensei_email_data['course_name']. '</a>';
39 39
 
40
-    ?>
40
+	?>
41 41
 </p>
42 42
 
43 43
 <?php
Please login to merge, or discard this patch.
templates/single-quiz/question_type-file-upload.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for displaying File Upload Questions.
5
- *
6
- * Override this template by copying it to yourtheme/sensei/single-quiz/question_type-file-upload.php
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+	 * The Template for displaying File Upload Questions.
5
+	 *
6
+	 * Override this template by copying it to yourtheme/sensei/single-quiz/question_type-file-upload.php
7
+	 *
8
+	 * @author 		Automattic
9
+	 * @package 	Sensei
10
+	 * @category    Templates
11
+	 * @version     1.9.0
12
+	 */
13 13
 ?>
14 14
 
15 15
 <?php
16 16
 
17
-    /**
18
-     * Get the question data with the current quiz id
19
-     * All data is loaded in this array to keep the template clean.
20
-     */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
17
+	/**
18
+	 * Get the question data with the current quiz id
19
+	 * All data is loaded in this array to keep the template clean.
20
+	 */
21
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
22 22
 
23 23
 ?>
24 24
 
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 
35 35
         <?php
36 36
 
37
-        printf( __( 'Submitted file: %1$s', 'woothemes-sensei' ), '<a href="' . esc_url(  $question_data[ 'answer_media_url' ] )
38
-            . '" target="_blank">'
39
-            . esc_html(  $question_data[ 'answer_media_filename' ] ) . '</a>' );
37
+		printf( __( 'Submitted file: %1$s', 'woothemes-sensei' ), '<a href="' . esc_url(  $question_data[ 'answer_media_url' ] )
38
+			. '" target="_blank">'
39
+			. esc_html(  $question_data[ 'answer_media_filename' ] ) . '</a>' );
40 40
 
41
-        ?>
41
+		?>
42 42
 
43 43
     </p>
44 44
     <?php if( !  $question_data[ 'lesson_complete' ]  ) { ?>
Please login to merge, or discard this patch.
templates/single-quiz/question_type-single-line.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@
 block discarded – undo
14 14
 
15 15
 <?php
16 16
 
17
-    /**
18
-     * Get the question data with the current quiz id
19
-     * All data is loaded in this array to keep the template clean.
20
-     */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
17
+	/**
18
+	 * Get the question data with the current quiz id
19
+	 * All data is loaded in this array to keep the template clean.
20
+	 */
21
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
22 22
 
23 23
 ?>
24 24
 
Please login to merge, or discard this patch.
templates/single-quiz/question_type-multi-line.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
 
15 15
 <?php
16 16
 
17
-    /**
18
-     * Get the question data with the current quiz id
19
-     * All data is loaded in this array to keep the template clean.
20
-     */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
17
+	/**
18
+	 * Get the question data with the current quiz id
19
+	 * All data is loaded in this array to keep the template clean.
20
+	 */
21
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+	Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
+												'textquestion' . $question_data[ 'ID' ] ,
29
+												'sensei_question[' . $question_data[ 'ID' ] . ']' );
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.
includes/class-sensei-utils.php 1 patch
Indentation   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	/**
28 28
 	 * Check if WooCommerce is present.
29
-     *
30
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
29
+	 *
30
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
31 31
 	 * @access public
32 32
 	 * @since  1.0.2
33 33
 	 * @static
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function sensei_is_woocommerce_present () {
37 37
 
38
-        return Sensei_WC::is_woocommerce_present();
38
+		return Sensei_WC::is_woocommerce_present();
39 39
 
40 40
 	} // End sensei_is_woocommerce_present()
41 41
 
42 42
 	/**
43 43
 	 * Check if WooCommerce is active.
44
-     *
45
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
44
+	 *
45
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
46 46
 	 * @access public
47 47
 	 * @since  1.0.2
48 48
 	 * @static
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 			add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
188 188
 		}
189 189
 
190
-        //Get the comments
191
-        /**
192
-         * This filter runs inside Sensei_Utils::sensei_check_for_activity
193
-         *
194
-         * It runs while getting the comments for the given request.
195
-         *
196
-         * @param int|array $comments
197
-         */
198
-        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
190
+		//Get the comments
191
+		/**
192
+		 * This filter runs inside Sensei_Utils::sensei_check_for_activity
193
+		 *
194
+		 * It runs while getting the comments for the given request.
195
+		 *
196
+		 * @param int|array $comments
197
+		 */
198
+		$comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
199 199
 
200 200
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
201 201
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
@@ -280,18 +280,18 @@  discard block
 block discarded – undo
280 280
 		return $dataset_changes;
281 281
 	} // End sensei_delete_activities()
282 282
 
283
-    /**
284
-     * Delete all activity for specified user
285
-     * @access public
283
+	/**
284
+	 * Delete all activity for specified user
285
+	 * @access public
286 286
 	 * @since  1.5.0
287
-     * @param  integer $user_id User ID
288
-     * @return boolean
289
-     */
290
-    public static function delete_all_user_activity( $user_id = 0 ) {
287
+	 * @param  integer $user_id User ID
288
+	 * @return boolean
289
+	 */
290
+	public static function delete_all_user_activity( $user_id = 0 ) {
291 291
 
292
-    	$dataset_changes = false;
292
+		$dataset_changes = false;
293 293
 
294
-    	if( $user_id ) {
294
+		if( $user_id ) {
295 295
 
296 296
 			$activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true );
297 297
 
@@ -336,35 +336,35 @@  discard block
 block discarded – undo
336 336
 		return $activity_value;
337 337
 	} // End sensei_get_activity_value()
338 338
 
339
-    /**
340
-     * Checks if a user (by email) has bought an item.
341
-     *
342
-     * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
343
-     * @access public
344
-     * @since  1.0.0
345
-     * @param  string $customer_email
346
-     * @param  int $user_id
347
-     * @param  int $product_id
348
-     * @return bool
349
-     */
350
-    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
339
+	/**
340
+	 * Checks if a user (by email) has bought an item.
341
+	 *
342
+	 * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
343
+	 * @access public
344
+	 * @since  1.0.0
345
+	 * @param  string $customer_email
346
+	 * @param  int $user_id
347
+	 * @param  int $product_id
348
+	 * @return bool
349
+	 */
350
+	public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
351 351
 
352
-        $emails = array();
352
+		$emails = array();
353 353
 
354
-        if ( $user_id ) {
355
-            $user = get_user_by( 'id', intval( $user_id ) );
356
-            $emails[] = $user->user_email;
357
-        }
354
+		if ( $user_id ) {
355
+			$user = get_user_by( 'id', intval( $user_id ) );
356
+			$emails[] = $user->user_email;
357
+		}
358 358
 
359
-        if ( is_email( $customer_email ) )
360
-            $emails[] = $customer_email;
359
+		if ( is_email( $customer_email ) )
360
+			$emails[] = $customer_email;
361 361
 
362
-        if ( sizeof( $emails ) == 0 )
363
-            return false;
362
+		if ( sizeof( $emails ) == 0 )
363
+			return false;
364 364
 
365
-        return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
365
+		return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
366 366
 
367
-    } // End sensei_customer_bought_product()
367
+	} // End sensei_customer_bought_product()
368 368
 
369 369
 	/**
370 370
 	 * Load the WordPress rich text editor
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	/**
401 401
 	 * Save quiz answers submitted by users
402 402
 	 * @param  array $submitted User's quiz answers
403
-     * @param int $user_id
403
+	 * @param int $user_id
404 404
 	 * @return boolean            Whether the answers were saved or not
405 405
 	 */
406 406
 	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) {
@@ -468,72 +468,72 @@  discard block
 block discarded – undo
468 468
 
469 469
 		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
470 470
 
471
-        /**
472
-         * Filter the data array for the Sensei wp_handle_upload function call
473
-         *
474
-         * This filter was mainly added for Unit Testing purposes.
475
-         *
476
-         * @since 1.7.4
477
-         *
478
-         * @param array  $file_upload_args {
479
-         *      array of current values
480
-         *
481
-         *     @type string test_form set to false by default
482
-         * }
483
-         */
484
-        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
485
-
486
-        $file_return = wp_handle_upload( $file, $file_upload_args );
487
-
488
-        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
489
-            return false;
490
-        } else {
471
+		/**
472
+		 * Filter the data array for the Sensei wp_handle_upload function call
473
+		 *
474
+		 * This filter was mainly added for Unit Testing purposes.
475
+		 *
476
+		 * @since 1.7.4
477
+		 *
478
+		 * @param array  $file_upload_args {
479
+		 *      array of current values
480
+		 *
481
+		 *     @type string test_form set to false by default
482
+		 * }
483
+		 */
484
+		$file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
485
+
486
+		$file_return = wp_handle_upload( $file, $file_upload_args );
487
+
488
+		if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
489
+			return false;
490
+		} else {
491 491
 
492
-            $filename = $file_return['file'];
492
+			$filename = $file_return['file'];
493 493
 
494
-            $attachment = array(
495
-                'post_mime_type' => $file_return['type'],
496
-                'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
497
-                'post_content' => '',
498
-                'post_status' => 'inherit',
499
-                'guid' => $file_return['url']
500
-            );
494
+			$attachment = array(
495
+				'post_mime_type' => $file_return['type'],
496
+				'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
497
+				'post_content' => '',
498
+				'post_status' => 'inherit',
499
+				'guid' => $file_return['url']
500
+			);
501 501
 
502
-            $attachment_id = wp_insert_attachment( $attachment, $filename );
502
+			$attachment_id = wp_insert_attachment( $attachment, $filename );
503 503
 
504
-            require_once(ABSPATH . 'wp-admin/includes/image.php');
505
-            $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
506
-            wp_update_attachment_metadata( $attachment_id, $attachment_data );
504
+			require_once(ABSPATH . 'wp-admin/includes/image.php');
505
+			$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
506
+			wp_update_attachment_metadata( $attachment_id, $attachment_data );
507 507
 
508
-            if( 0 < intval( $attachment_id ) ) {
509
-            	return $attachment_id;
510
-            }
511
-        }
508
+			if( 0 < intval( $attachment_id ) ) {
509
+				return $attachment_id;
510
+			}
511
+		}
512 512
 
513
-        return false;
513
+		return false;
514 514
 	}
515 515
 
516 516
 	/**
517 517
 	 * Grade quiz automatically
518
-     *
519
-     * This function grades each question automatically if the are auto gradable.
520
-     * It store all question grades.
521
-     *
522
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
523
-     *
518
+	 *
519
+	 * This function grades each question automatically if the are auto gradable.
520
+	 * It store all question grades.
521
+	 *
522
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
523
+	 *
524 524
 	 * @param  integer $quiz_id         ID of quiz
525 525
 	 * @param  array $submitted questions id ans answers {
526
-     *          @type int $question_id
527
-     *          @type mixed $answer
528
-     * }
526
+	 *          @type int $question_id
527
+	 *          @type mixed $answer
528
+	 * }
529 529
 	 * @param  integer $total_questions Total questions in quiz (not used)
530
-     * @param string $quiz_grade_type Optional defaults to auto
531
-     *
530
+	 * @param string $quiz_grade_type Optional defaults to auto
531
+	 *
532 532
 	 * @return int $quiz_grade total sum of all question grades
533 533
 	 */
534 534
 	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
535 535
 
536
-        return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
536
+		return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
537 537
 
538 538
 	} // End sensei_grade_quiz_auto()
539 539
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 	 * @param  integer $quiz_id ID of quiz
543 543
 	 * @param  integer $grade   Grade received
544 544
 	 * @param  integer $user_id ID of user being graded
545
-     * @param  string $quiz_grade_type default 'auto'
545
+	 * @param  string $quiz_grade_type default 'auto'
546 546
 	 * @return boolean
547 547
 	 */
548 548
 	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) {
@@ -566,21 +566,21 @@  discard block
 block discarded – undo
566 566
 
567 567
 	/**
568 568
 	 * Grade question automatically
569
-     *
570
-     * This function checks the question typ and then grades it accordingly.
571
-     *
572
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
573
-     *
569
+	 *
570
+	 * This function checks the question typ and then grades it accordingly.
571
+	 *
572
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
573
+	 *
574 574
 	 * @param integer $question_id
575
-     * @param string $question_type of the standard Sensei question types
575
+	 * @param string $question_type of the standard Sensei question types
576 576
 	 * @param string $answer
577
-     * @param int $user_id
578
-     *
577
+	 * @param int $user_id
578
+	 *
579 579
 	 * @return int $question_grade
580 580
 	 */
581 581
 	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
582 582
 
583
-       return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
583
+	   return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
584 584
 
585 585
 	} // end sensei_grade_question_auto
586 586
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 	 * Grade question
589 589
 	 * @param  integer $question_id ID of question
590 590
 	 * @param  integer $grade       Grade received
591
-     * @param int $user_id
591
+	 * @param int $user_id
592 592
 	 * @return boolean
593 593
 	 */
594 594
 	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) {
@@ -627,35 +627,35 @@  discard block
 block discarded – undo
627 627
 	}
628 628
 
629 629
 
630
-    /**
631
-     * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
632
-     *
633
-     * @since 1.7.4
634
-     *
635
-     * @param integer $user_id
636
-     * @param integer $lesson_id
637
-     * @param bool $complete
638
-     *
639
-     * @return mixed boolean or comment_ID
640
-     */
641
-    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
630
+	/**
631
+	 * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
632
+	 *
633
+	 * @since 1.7.4
634
+	 *
635
+	 * @param integer $user_id
636
+	 * @param integer $lesson_id
637
+	 * @param bool $complete
638
+	 *
639
+	 * @return mixed boolean or comment_ID
640
+	 */
641
+	public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
642 642
 
643
-        return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
643
+		return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
644 644
 
645
-    }// end user_start_lesson()
645
+	}// end user_start_lesson()
646 646
 
647 647
 	/**
648 648
 	 * Mark a lesson as started for user
649
-     *
650
-     * Will also start the lesson course for the user if the user hans't started taking it already.
651
-     *
652
-     * @since 1.6.0
653
-     *
649
+	 *
650
+	 * Will also start the lesson course for the user if the user hans't started taking it already.
651
+	 *
652
+	 * @since 1.6.0
653
+	 *
654 654
 	 * @param  integer $lesson_id ID of lesson
655 655
 	 * @param int| string $user_id default 0
656
-     * @param bool $complete default false
657
-     *
658
-     * @return mixed boolean or comment_ID
656
+	 * @param bool $complete default false
657
+	 *
658
+	 * @return mixed boolean or comment_ID
659 659
 	 */
660 660
 	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
661 661
 
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
 				$metadata['start'] = current_time('mysql');
702 702
 				$activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata );
703 703
 
704
-            } else {
704
+			} else {
705 705
 
706
-                // if users is already taking the lesson  and the status changes to complete update it
707
-                $current_user_activity = get_comment($activity_logged);
708
-                if( $status=='complete' &&
709
-                    $status != $current_user_activity->comment_approved  ){
706
+				// if users is already taking the lesson  and the status changes to complete update it
707
+				$current_user_activity = get_comment($activity_logged);
708
+				if( $status=='complete' &&
709
+					$status != $current_user_activity->comment_approved  ){
710 710
 
711
-                    $comment = array();
712
-                    $comment['comment_ID'] = $activity_logged;
713
-                    $comment['comment_approved'] = $status;
714
-                    wp_update_comment( $comment );
711
+					$comment = array();
712
+					$comment['comment_ID'] = $activity_logged;
713
+					$comment['comment_approved'] = $status;
714
+					wp_update_comment( $comment );
715 715
 
716
-                }
716
+				}
717 717
 
718
-            }
718
+			}
719 719
 
720 720
 			if ( $complete ) {
721 721
 				// Run this *after* the lesson status has been created/updated
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	/**
862 862
 	 * Returns the answer_notes for a specific question and user, or sensei_user_answer entry
863 863
 	 *
864
-     * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
864
+	 * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
865 865
 	 * @param mixed $question
866 866
 	 * @param int $user_id
867 867
 	 * @return string
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 * Add answer notes to question
922 922
 	 * @param  integer $question_id ID of question
923 923
 	 * @param  integer $user_id     ID of user
924
-     * @param string $notes
924
+	 * @param string $notes
925 925
 	 * @return boolean
926 926
 	 */
927 927
 	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) {
@@ -979,17 +979,17 @@  discard block
 block discarded – undo
979 979
 	 * @return void
980 980
 	 */
981 981
 	public static function sort_array_by_key( $array, $key ) {
982
-	    $sorter = array();
983
-	    $ret = array();
984
-	    reset( $array );
985
-	    foreach ( $array as $ii => $va ) {
986
-	        $sorter[$ii] = $va[$key];
987
-	    } // End For Loop
988
-	    asort( $sorter );
989
-	    foreach ( $sorter as $ii => $va ) {
990
-	        $ret[$ii] = $array[$ii];
991
-	    } // End For Loop
992
-	    $array = $ret;
982
+		$sorter = array();
983
+		$ret = array();
984
+		reset( $array );
985
+		foreach ( $array as $ii => $va ) {
986
+			$sorter[$ii] = $va[$key];
987
+		} // End For Loop
988
+		asort( $sorter );
989
+		foreach ( $sorter as $ii => $va ) {
990
+			$ret[$ii] = $array[$ii];
991
+		} // End For Loop
992
+		$array = $ret;
993 993
 	} // End sort_array_by_key()
994 994
 
995 995
 	/**
@@ -1002,21 +1002,21 @@  discard block
 block discarded – undo
1002 1002
 		$questions_array = array();
1003 1003
 		if ( 0 < $quiz_id ) {
1004 1004
 			$question_args = array( 'post_type'         => 'question',
1005
-                                    'posts_per_page'       => -1,
1006
-                                    'orderby'           => 'ID',
1007
-                                    'order'             => 'ASC',
1008
-                                    'meta_query'		=> array(
1005
+									'posts_per_page'       => -1,
1006
+									'orderby'           => 'ID',
1007
+									'order'             => 'ASC',
1008
+									'meta_query'		=> array(
1009 1009
 										array(
1010 1010
 											'key'       => '_quiz_id',
1011 1011
 											'value'     => $quiz_id,
1012 1012
 										)
1013 1013
 									),
1014
-                                    'post_status'       => 'any',
1015
-                                    'suppress_filters'  => 0
1016
-                                );
1017
-            $questions_array = get_posts( $question_args );
1018
-        } // End If Statement
1019
-        return $questions_array;
1014
+									'post_status'       => 'any',
1015
+									'suppress_filters'  => 0
1016
+								);
1017
+			$questions_array = get_posts( $question_args );
1018
+		} // End If Statement
1019
+		return $questions_array;
1020 1020
 	} // End lesson_quiz_questions()
1021 1021
 
1022 1022
 	/**
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 	 * Set the status message displayed to the user for a quiz
1175 1175
 	 * @param  integer $lesson_id ID of quiz lesson
1176 1176
 	 * @param  integer $user_id   ID of user
1177
-     * @param  bool $is_lesson
1177
+	 * @param  bool $is_lesson
1178 1178
 	 * @return array              Status code and message
1179 1179
 	 */
1180 1180
 	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) {
@@ -1257,20 +1257,20 @@  discard block
 block discarded – undo
1257 1257
 					}
1258 1258
 				}
1259 1259
 
1260
-                // add next lesson button
1261
-                $nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1262
-                $next_lesson_id = absint( $nav_id_array['next_lesson'] );
1260
+				// add next lesson button
1261
+				$nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1262
+				$next_lesson_id = absint( $nav_id_array['next_lesson'] );
1263 1263
 
1264
-                // Output HTML
1265
-                if ( ( 0 < $next_lesson_id ) ) {
1266
-                    $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1267
-                                . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1268
-                                .'</a>';
1264
+				// Output HTML
1265
+				if ( ( 0 < $next_lesson_id ) ) {
1266
+					$message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1267
+								. '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1268
+								.'</a>';
1269 1269
 
1270
-                }
1270
+				}
1271 1271
 
1272 1272
 			}
1273
-            // Lesson/Quiz not complete
1273
+			// Lesson/Quiz not complete
1274 1274
 			else {
1275 1275
 				// Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
1276 1276
 				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) {
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		$message = apply_filters( 'sensei_user_quiz_status_' . $status, $message );
1311 1311
 
1312 1312
 		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) {
1313
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1313
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1314 1314
 			$extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' .  __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' .  __( 'View the lesson quiz', 'woothemes-sensei' )  . '</a></p>';
1315 1315
 		}
1316 1316
 
@@ -1368,9 +1368,9 @@  discard block
 block discarded – undo
1368 1368
 				$user_id = get_current_user_id();
1369 1369
 			}
1370 1370
 
1371
-            if( ! $user_id > 0 ){
1372
-                return false;
1373
-            }
1371
+			if( ! $user_id > 0 ){
1372
+				return false;
1373
+			}
1374 1374
 
1375 1375
 			$user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) );
1376 1376
 			if( $user_course_status_id ) {
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 	 * Check if a user has completed a course or not
1495 1495
 	 *
1496 1496
 	 * @param int | WP_Post | WP_Comment $course course_id or sensei_course_status entry
1497
-     *
1497
+	 *
1498 1498
 	 * @param int $user_id
1499 1499
 	 * @return boolean
1500 1500
 	 */
@@ -1512,14 +1512,14 @@  discard block
 block discarded – undo
1512 1512
 					$user_id = get_current_user_id();
1513 1513
 				}
1514 1514
 
1515
-                if( is_a( $course, 'WP_Post' ) ){
1516
-                    $course =   $course->ID;
1517
-                }
1515
+				if( is_a( $course, 'WP_Post' ) ){
1516
+					$course =   $course->ID;
1517
+				}
1518 1518
 
1519 1519
 				$user_course_status = Sensei_Utils::user_course_status( $course , $user_id );
1520 1520
 				if( isset( $user_course_status->comment_approved ) ){
1521
-                    $user_course_status = $user_course_status->comment_approved;
1522
-                }
1521
+					$user_course_status = $user_course_status->comment_approved;
1522
+				}
1523 1523
 
1524 1524
 			}
1525 1525
 			if( $user_course_status && 'complete' == $user_course_status ) {
@@ -1544,11 +1544,11 @@  discard block
 block discarded – undo
1544 1544
 				$user_id = get_current_user_id();
1545 1545
 			}
1546 1546
 
1547
-            $activity_args = array(
1548
-                'post_id' => $lesson_id,
1549
-                'user_id' => $user_id,
1550
-                'type' => 'sensei_lesson_status',
1551
-                'field' => 'comment_ID' );
1547
+			$activity_args = array(
1548
+				'post_id' => $lesson_id,
1549
+				'user_id' => $user_id,
1550
+				'type' => 'sensei_lesson_status',
1551
+				'field' => 'comment_ID' );
1552 1552
 
1553 1553
 			$user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args );
1554 1554
 			if( $user_lesson_status_id ) {
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 	/**
1562 1562
 	 * Check if a user has completed a lesson or not
1563 1563
 	 *
1564
-     * @uses  Sensei()
1564
+	 * @uses  Sensei()
1565 1565
 	 * @param mixed $lesson lesson_id or sensei_lesson_status entry
1566 1566
 	 * @param int $user_id
1567 1567
 	 * @return boolean
@@ -1582,10 +1582,10 @@  discard block
 block discarded – undo
1582 1582
 					$user_id = get_current_user_id();
1583 1583
 				}
1584 1584
 
1585
-                // the user is not logged in
1586
-                if( ! $user_id > 0 ){
1587
-                    return false;
1588
-                }
1585
+				// the user is not logged in
1586
+				if( ! $user_id > 0 ){
1587
+					return false;
1588
+				}
1589 1589
 				$_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id );
1590 1590
 
1591 1591
 				if ( $_user_lesson_status ) {
@@ -1664,9 +1664,9 @@  discard block
 block discarded – undo
1664 1664
 	 */
1665 1665
 	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1666 1666
 
1667
-        if( ! $user_id ) {
1668
-            $user_id = get_current_user_id();
1669
-        }
1667
+		if( ! $user_id ) {
1668
+			$user_id = get_current_user_id();
1669
+		}
1670 1670
 
1671 1671
 		if( $lesson_id > 0 && $user_id > 0 ) {
1672 1672
 
@@ -1717,12 +1717,12 @@  discard block
 block discarded – undo
1717 1717
 	 * Sets the status for the lesson
1718 1718
 	 *
1719 1719
 	 * @since  1.7.0
1720
-     *
1720
+	 *
1721 1721
 	 * @param int|string $user_id
1722 1722
 	 * @param int|string $lesson_id
1723 1723
 	 * @param string $status
1724 1724
 	 * @param array $metadata
1725
-     *
1725
+	 *
1726 1726
 	 * @return mixed false or comment_ID
1727 1727
 	 */
1728 1728
 	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 	/**
1839 1839
 	 * Adjust the comment query to be faster on the database, used by Analysis admin
1840 1840
 	 * @since  1.7.0
1841
-     * @param array $pieces
1841
+	 * @param array $pieces
1842 1842
 	 * @return array $pieces
1843 1843
 	 */
1844 1844
 	public static function comment_total_sum_meta_value_filter( $pieces ) {
@@ -1873,360 +1873,360 @@  discard block
 block discarded – undo
1873 1873
 		return $pieces;
1874 1874
 	}
1875 1875
 
1876
-    /**
1877
-     *
1878
-     * Alias to Woothemes_Sensei_Utils::update_user_data
1879
-     * @since 1.7.4
1880
-     *
1881
-     * @param string $data_key maximum 39 characters allowed
1882
-     * @param int $post_id
1883
-     * @param mixed $value
1884
-     * @param int $user_id
1885
-     *
1886
-     * @return bool $success
1887
-     */
1888
-    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1889
-
1890
-        return self::update_user_data( $data_key, $post_id, $value , $user_id );
1891
-
1892
-    }// end add_user_data
1893
-
1894
-    /**
1895
-     * add user specific data to the passed in sensei post type id
1896
-     *
1897
-     * This function saves comment meta on the users current status. If no status is available
1898
-     * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1899
-     *
1900
-     * @since 1.7.4
1901
-     *
1902
-     * @param string $data_key maximum 39 characters allowed
1903
-     * @param int $post_id
1904
-     * @param mixed $value
1905
-     * @param int $user_id
1906
-     *
1907
-     * @return bool $success
1908
-     */
1909
-    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1910
-
1911
-        if( ! ( $user_id > 0 ) ){
1912
-            $user_id = get_current_user_id();
1913
-        }
1914
-
1915
-        $supported_post_types = array( 'course', 'lesson' );
1916
-        $post_type = get_post_type( $post_id );
1917
-        if( empty( $post_id ) || empty( $data_key )
1918
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1919
-            || !get_userdata( $user_id )
1920
-            || ! in_array( $post_type, $supported_post_types )  ){
1921
-
1922
-            return false;
1923
-        }
1924
-
1925
-        // check if there and existing Sensei status on this post type if not create it
1926
-        // and get the  activity ID
1927
-        $status_function = 'user_'.$post_type.'_status';
1928
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1929
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1930
-
1931
-            $start_function = 'user_start_'.$post_type;
1932
-            $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1933
-
1934
-        }else{
1935
-
1936
-            $sensei_user_activity_id = $sensei_user_status->comment_ID;
1937
-
1938
-        }
1939
-
1940
-        // store the data
1941
-        $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1942
-
1943
-       return $success;
1944
-
1945
-    }//update_user_data
1946
-
1947
-    /**
1948
-     * Get the user data stored on the passed in post type
1949
-     *
1950
-     * This function gets the comment meta on the lesson or course status
1951
-     *
1952
-     * @since 1.7.4
1953
-     *
1954
-     * @param $data_key
1955
-     * @param $post_id
1956
-     * @param int $user_id
1957
-     *
1958
-     * @return mixed $user_data_value
1959
-     */
1960
-    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1961
-
1962
-        $user_data_value = true;
1963
-
1964
-        if( ! ( $user_id > 0 ) ){
1965
-            $user_id = get_current_user_id();
1966
-        }
1967
-
1968
-        $supported_post_types = array( 'course', 'lesson' );
1969
-        $post_type = get_post_type( $post_id );
1970
-        if( empty( $post_id ) || empty( $data_key )
1971
-            || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1972
-            || ! get_userdata( $user_id )
1973
-            || !in_array( $post_type, $supported_post_types )  ){
1974
-
1975
-            return false;
1976
-        }
1977
-
1978
-        // check if there and existing Sensei status on this post type if not create it
1979
-        // and get the  activity ID
1980
-        $status_function = 'user_'.$post_type.'_status';
1981
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1982
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1983
-            return false;
1984
-        }
1985
-
1986
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
1987
-        $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1988
-
1989
-        return $user_data_value;
1990
-
1991
-    }// end get_user_data
1992
-
1993
-    /**
1994
-     * Delete the Sensei user data for the given key, Sensei post type and user combination.
1995
-     *
1996
-     * @param int $data_key
1997
-     * @param int $post_id
1998
-     * @param int $user_id
1999
-     *
2000
-     * @return bool $deleted
2001
-     */
2002
-    public static function delete_user_data( $data_key, $post_id , $user_id ){
2003
-        $deleted = true;
1876
+	/**
1877
+	 *
1878
+	 * Alias to Woothemes_Sensei_Utils::update_user_data
1879
+	 * @since 1.7.4
1880
+	 *
1881
+	 * @param string $data_key maximum 39 characters allowed
1882
+	 * @param int $post_id
1883
+	 * @param mixed $value
1884
+	 * @param int $user_id
1885
+	 *
1886
+	 * @return bool $success
1887
+	 */
1888
+	public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1889
+
1890
+		return self::update_user_data( $data_key, $post_id, $value , $user_id );
1891
+
1892
+	}// end add_user_data
1893
+
1894
+	/**
1895
+	 * add user specific data to the passed in sensei post type id
1896
+	 *
1897
+	 * This function saves comment meta on the users current status. If no status is available
1898
+	 * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1899
+	 *
1900
+	 * @since 1.7.4
1901
+	 *
1902
+	 * @param string $data_key maximum 39 characters allowed
1903
+	 * @param int $post_id
1904
+	 * @param mixed $value
1905
+	 * @param int $user_id
1906
+	 *
1907
+	 * @return bool $success
1908
+	 */
1909
+	public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1910
+
1911
+		if( ! ( $user_id > 0 ) ){
1912
+			$user_id = get_current_user_id();
1913
+		}
1914
+
1915
+		$supported_post_types = array( 'course', 'lesson' );
1916
+		$post_type = get_post_type( $post_id );
1917
+		if( empty( $post_id ) || empty( $data_key )
1918
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1919
+			|| !get_userdata( $user_id )
1920
+			|| ! in_array( $post_type, $supported_post_types )  ){
1921
+
1922
+			return false;
1923
+		}
1924
+
1925
+		// check if there and existing Sensei status on this post type if not create it
1926
+		// and get the  activity ID
1927
+		$status_function = 'user_'.$post_type.'_status';
1928
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
1929
+		if( ! isset( $sensei_user_status->comment_ID ) ){
1930
+
1931
+			$start_function = 'user_start_'.$post_type;
1932
+			$sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1933
+
1934
+		}else{
1935
+
1936
+			$sensei_user_activity_id = $sensei_user_status->comment_ID;
1937
+
1938
+		}
1939
+
1940
+		// store the data
1941
+		$success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1942
+
1943
+	   return $success;
1944
+
1945
+	}//update_user_data
1946
+
1947
+	/**
1948
+	 * Get the user data stored on the passed in post type
1949
+	 *
1950
+	 * This function gets the comment meta on the lesson or course status
1951
+	 *
1952
+	 * @since 1.7.4
1953
+	 *
1954
+	 * @param $data_key
1955
+	 * @param $post_id
1956
+	 * @param int $user_id
1957
+	 *
1958
+	 * @return mixed $user_data_value
1959
+	 */
1960
+	public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1961
+
1962
+		$user_data_value = true;
1963
+
1964
+		if( ! ( $user_id > 0 ) ){
1965
+			$user_id = get_current_user_id();
1966
+		}
1967
+
1968
+		$supported_post_types = array( 'course', 'lesson' );
1969
+		$post_type = get_post_type( $post_id );
1970
+		if( empty( $post_id ) || empty( $data_key )
1971
+			|| ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1972
+			|| ! get_userdata( $user_id )
1973
+			|| !in_array( $post_type, $supported_post_types )  ){
2004 1974
 
2005
-        if( ! ( $user_id > 0 ) ){
2006
-            $user_id = get_current_user_id();
2007
-        }
1975
+			return false;
1976
+		}
2008 1977
 
2009
-        $supported_post_types = array( 'course', 'lesson' );
2010
-        $post_type = get_post_type( $post_id );
2011
-        if( empty( $post_id ) || empty( $data_key )
2012
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2013
-            || ! get_userdata( $user_id )
2014
-            || !in_array( $post_type, $supported_post_types )  ){
1978
+		// check if there and existing Sensei status on this post type if not create it
1979
+		// and get the  activity ID
1980
+		$status_function = 'user_'.$post_type.'_status';
1981
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
1982
+		if( ! isset( $sensei_user_status->comment_ID ) ){
1983
+			return false;
1984
+		}
2015 1985
 
2016
-            return false;
2017
-        }
1986
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
1987
+		$user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
1988
+
1989
+		return $user_data_value;
1990
+
1991
+	}// end get_user_data
1992
+
1993
+	/**
1994
+	 * Delete the Sensei user data for the given key, Sensei post type and user combination.
1995
+	 *
1996
+	 * @param int $data_key
1997
+	 * @param int $post_id
1998
+	 * @param int $user_id
1999
+	 *
2000
+	 * @return bool $deleted
2001
+	 */
2002
+	public static function delete_user_data( $data_key, $post_id , $user_id ){
2003
+		$deleted = true;
2004
+
2005
+		if( ! ( $user_id > 0 ) ){
2006
+			$user_id = get_current_user_id();
2007
+		}
2008
+
2009
+		$supported_post_types = array( 'course', 'lesson' );
2010
+		$post_type = get_post_type( $post_id );
2011
+		if( empty( $post_id ) || empty( $data_key )
2012
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2013
+			|| ! get_userdata( $user_id )
2014
+			|| !in_array( $post_type, $supported_post_types )  ){
2015
+
2016
+			return false;
2017
+		}
2018 2018
 
2019
-        // check if there and existing Sensei status on this post type if not create it
2020
-        // and get the  activity ID
2021
-        $status_function = 'user_'.$post_type.'_status';
2022
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2023
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2024
-            return false;
2025
-        }
2019
+		// check if there and existing Sensei status on this post type if not create it
2020
+		// and get the  activity ID
2021
+		$status_function = 'user_'.$post_type.'_status';
2022
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
2023
+		if( ! isset( $sensei_user_status->comment_ID ) ){
2024
+			return false;
2025
+		}
2026 2026
 
2027
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
2028
-        $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2027
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
2028
+		$deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2029 2029
 
2030
-        return $deleted;
2030
+		return $deleted;
2031 2031
 
2032
-    }// end delete_user_data
2032
+	}// end delete_user_data
2033 2033
 
2034 2034
 
2035
-    /**
2036
-     * The function creates a drop down. Never write up a Sensei select statement again.
2037
-     *
2038
-     * @since 1.8.0
2039
-     *
2040
-     * @param string $selected_value
2041
-     * @param $options{
2042
-     *    @type string $value the value saved in the database
2043
-     *    @type string $option what the user will see in the list of items
2044
-     * }
2045
-     * @param array $attributes{
2046
-     *   @type string $attribute  type such name or id etc.
2047
-     *  @type string $value
2048
-     * }
2049
-     * @param bool $enable_none_option
2050
-     *
2051
-     * @return string $drop_down_element
2052
-     */
2053
-    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2035
+	/**
2036
+	 * The function creates a drop down. Never write up a Sensei select statement again.
2037
+	 *
2038
+	 * @since 1.8.0
2039
+	 *
2040
+	 * @param string $selected_value
2041
+	 * @param $options{
2042
+	 *    @type string $value the value saved in the database
2043
+	 *    @type string $option what the user will see in the list of items
2044
+	 * }
2045
+	 * @param array $attributes{
2046
+	 *   @type string $attribute  type such name or id etc.
2047
+	 *  @type string $value
2048
+	 * }
2049
+	 * @param bool $enable_none_option
2050
+	 *
2051
+	 * @return string $drop_down_element
2052
+	 */
2053
+	public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2054 2054
 
2055
-        $drop_down_element = '';
2055
+		$drop_down_element = '';
2056 2056
 
2057
-        // setup the basic attributes
2058
-        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2057
+		// setup the basic attributes
2058
+		if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2059 2059
 
2060
-            $attributes['name'] = 'sensei-options';
2060
+			$attributes['name'] = 'sensei-options';
2061 2061
 
2062
-        }
2062
+		}
2063 2063
 
2064
-        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2064
+		if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2065 2065
 
2066
-            $attributes['id'] = 'sensei-options';
2066
+			$attributes['id'] = 'sensei-options';
2067 2067
 
2068
-        }
2068
+		}
2069 2069
 
2070
-        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2070
+		if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2071 2071
 
2072
-            $attributes['class'] ='chosen_select widefat';
2072
+			$attributes['class'] ='chosen_select widefat';
2073 2073
 
2074
-        }
2074
+		}
2075 2075
 
2076
-        // create element attributes
2077
-        $combined_attributes = '';
2078
-        foreach( $attributes as $attribute => $value ){
2076
+		// create element attributes
2077
+		$combined_attributes = '';
2078
+		foreach( $attributes as $attribute => $value ){
2079 2079
 
2080
-            $combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2080
+			$combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2081 2081
 
2082
-        }// end for each
2082
+		}// end for each
2083 2083
 
2084 2084
 
2085
-        // create the select element
2086
-        $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2085
+		// create the select element
2086
+		$drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2087 2087
 
2088
-        // show the none option if the client requested
2089
-        if( $enable_none_option ) {
2090
-            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2091
-        }
2088
+		// show the none option if the client requested
2089
+		if( $enable_none_option ) {
2090
+			$drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2091
+		}
2092 2092
 
2093
-        if ( count( $options ) > 0 ) {
2093
+		if ( count( $options ) > 0 ) {
2094 2094
 
2095
-            foreach ($options as $value => $option ){
2095
+			foreach ($options as $value => $option ){
2096 2096
 
2097
-                $element = '';
2098
-                $element.= '<option value="' . esc_attr( $value ) . '"';
2099
-                $element .= selected( $value, $selected_value, false ) . '>';
2100
-                $element .= esc_html(  $option ) . '</option>' . "\n";
2097
+				$element = '';
2098
+				$element.= '<option value="' . esc_attr( $value ) . '"';
2099
+				$element .= selected( $value, $selected_value, false ) . '>';
2100
+				$element .= esc_html(  $option ) . '</option>' . "\n";
2101 2101
 
2102
-                // add the element to the select html
2103
-                $drop_down_element.= $element;
2104
-            } // End For Loop
2102
+				// add the element to the select html
2103
+				$drop_down_element.= $element;
2104
+			} // End For Loop
2105 2105
 
2106
-        } // End If Statement
2106
+		} // End If Statement
2107 2107
 
2108
-        $drop_down_element .= '</select>' . "\n";
2108
+		$drop_down_element .= '</select>' . "\n";
2109 2109
 
2110
-        return $drop_down_element;
2110
+		return $drop_down_element;
2111 2111
 
2112
-    }// generate_drop_down
2112
+	}// generate_drop_down
2113 2113
 
2114
-    /**
2115
-     * Wrapper for the default php round() function.
2116
-     * This allows us to give more control to a user on how they can round Sensei
2117
-     * decimals passed through this function.
2118
-     *
2119
-     * @since 1.8.5
2120
-     *
2121
-     * @param double $val
2122
-     * @param int $precision
2123
-     * @param $mode
2124
-     * @param string $context
2125
-     *
2126
-     * @return double $val
2127
-     */
2128
-    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2114
+	/**
2115
+	 * Wrapper for the default php round() function.
2116
+	 * This allows us to give more control to a user on how they can round Sensei
2117
+	 * decimals passed through this function.
2118
+	 *
2119
+	 * @since 1.8.5
2120
+	 *
2121
+	 * @param double $val
2122
+	 * @param int $precision
2123
+	 * @param $mode
2124
+	 * @param string $context
2125
+	 *
2126
+	 * @return double $val
2127
+	 */
2128
+	public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2129 2129
 
2130
-        /**å
2130
+		/**å
2131 2131
          * Change the precision for the Sensei_Utils::round function.
2132 2132
          * the precision given will be passed into the php round function
2133 2133
          * @since 1.8.5
2134 2134
          */
2135
-        $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2136
-
2137
-        /**
2138
-         * Change the mode for the Sensei_Utils::round function.
2139
-         * the mode given will be passed into the php round function
2140
-         *
2141
-         * This applies only to PHP version 5.3.0 and greater
2142
-         *
2143
-         * @since 1.8.5
2144
-         */
2145
-        $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2135
+		$precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2136
+
2137
+		/**
2138
+		 * Change the mode for the Sensei_Utils::round function.
2139
+		 * the mode given will be passed into the php round function
2140
+		 *
2141
+		 * This applies only to PHP version 5.3.0 and greater
2142
+		 *
2143
+		 * @since 1.8.5
2144
+		 */
2145
+		$mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2146 2146
 
2147
-        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2147
+		if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2148 2148
 
2149
-            return round( $val, $precision, $mode );
2149
+			return round( $val, $precision, $mode );
2150 2150
 
2151
-        }else{
2151
+		}else{
2152 2152
 
2153
-            return round( $val, $precision );
2153
+			return round( $val, $precision );
2154 2154
 
2155
-        }
2155
+		}
2156 2156
 
2157
-    }
2157
+	}
2158 2158
 
2159
-    /**
2160
-     * Returns the current url with all the query vars
2161
-     *
2162
-     * @since 1.9.0
2163
-     * @return string $url
2164
-     */
2165
-    public static function get_current_url(){
2159
+	/**
2160
+	 * Returns the current url with all the query vars
2161
+	 *
2162
+	 * @since 1.9.0
2163
+	 * @return string $url
2164
+	 */
2165
+	public static function get_current_url(){
2166 2166
 
2167
-        global $wp;
2168
-        $current_url = trailingslashit( home_url( $wp->request ) );
2169
-        if ( isset( $_GET ) ) {
2167
+		global $wp;
2168
+		$current_url = trailingslashit( home_url( $wp->request ) );
2169
+		if ( isset( $_GET ) ) {
2170 2170
 
2171
-            foreach ($_GET as $param => $val ) {
2171
+			foreach ($_GET as $param => $val ) {
2172 2172
 
2173
-                $current_url = add_query_arg( $param, $val , $current_url );
2173
+				$current_url = add_query_arg( $param, $val , $current_url );
2174 2174
 
2175
-            }
2176
-        }
2175
+			}
2176
+		}
2177 2177
 
2178
-        return $current_url;
2179
-    }
2178
+		return $current_url;
2179
+	}
2180 2180
 
2181
-    /**
2182
-     * Restore the global WP_Query
2183
-     *
2184
-     * @since 1.9.0
2185
-     */
2186
-    public static function restore_wp_query() {
2181
+	/**
2182
+	 * Restore the global WP_Query
2183
+	 *
2184
+	 * @since 1.9.0
2185
+	 */
2186
+	public static function restore_wp_query() {
2187 2187
 
2188
-        wp_reset_query();
2188
+		wp_reset_query();
2189 2189
 
2190
-    }
2190
+	}
2191 2191
 
2192
-    /**
2193
-     * Merge two arrays in a zip like fashion.
2194
-     * If one array is longer than the other the elements will be apended
2195
-     * to the end of the resulting array.
2196
-     *
2197
-     * @since 1.9.0
2198
-     *
2199
-     * @param array $array_a
2200
-     * @param array $array_b
2201
-     * @return array $merged_array
2202
-     */
2203
-    public static function array_zip_merge( $array_a, $array_b ){
2192
+	/**
2193
+	 * Merge two arrays in a zip like fashion.
2194
+	 * If one array is longer than the other the elements will be apended
2195
+	 * to the end of the resulting array.
2196
+	 *
2197
+	 * @since 1.9.0
2198
+	 *
2199
+	 * @param array $array_a
2200
+	 * @param array $array_b
2201
+	 * @return array $merged_array
2202
+	 */
2203
+	public static function array_zip_merge( $array_a, $array_b ){
2204 2204
 
2205
-        if( ! isset( $array_a[0]  ) || ! isset( $array_b[0] )  ){
2206
-            trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2207
-        }
2205
+		if( ! isset( $array_a[0]  ) || ! isset( $array_b[0] )  ){
2206
+			trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2207
+		}
2208 2208
 
2209
-        $merged_array = array();
2210
-        $total_elements = count( $array_a )  + count( $array_b );
2209
+		$merged_array = array();
2210
+		$total_elements = count( $array_a )  + count( $array_b );
2211 2211
 
2212
-        // Zip arrays
2213
-        for ( $i = 0; $i < $total_elements; $i++) {
2212
+		// Zip arrays
2213
+		for ( $i = 0; $i < $total_elements; $i++) {
2214 2214
 
2215
-            // if has an element at current index push a on top
2216
-            if( isset( $array_a[ $i ] ) ){
2217
-                $merged_array[] = $array_a[ $i ]  ;
2218
-            }
2215
+			// if has an element at current index push a on top
2216
+			if( isset( $array_a[ $i ] ) ){
2217
+				$merged_array[] = $array_a[ $i ]  ;
2218
+			}
2219 2219
 
2220
-            // next if $array_b has an element at current index push a on top of the element
2221
-            // from a if there was one, if not the element before that.
2222
-            if( isset( $array_b[ $i ] ) ){
2223
-                $merged_array[] = $array_b[ $i ]  ;
2224
-            }
2220
+			// next if $array_b has an element at current index push a on top of the element
2221
+			// from a if there was one, if not the element before that.
2222
+			if( isset( $array_b[ $i ] ) ){
2223
+				$merged_array[] = $array_b[ $i ]  ;
2224
+			}
2225 2225
 
2226
-        }
2226
+		}
2227 2227
 
2228
-        return $merged_array;
2229
-    }
2228
+		return $merged_array;
2229
+	}
2230 2230
 
2231 2231
 } // End Class
2232 2232
 
Please login to merge, or discard this patch.
templates/course-results/lessons.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for displaying all course lessons on the course results page.
5
- *
6
- * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+	 * The Template for displaying all course lessons on the course results page.
5
+	 *
6
+	 * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php
7
+	 *
8
+	 * @author 		Automattic
9
+	 * @package 	Sensei
10
+	 * @category    Templates
11
+	 * @version     1.9.0
12
+	 */
13 13
 
14 14
 global $course;
15 15
 ?>
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 <?php if ( is_user_logged_in() ): ?>
18 18
 
19 19
     <?php
20
-    /**
21
-     * Fires inside course-results/lessons.php after the
22
-     * is uer logged check, just above the lessons header.
23
-     * @since 1.4.0
24
-     */
25
-    do_action( 'sensei_course_results_before_lessons', $course->ID );
26
-    ?>
20
+	/**
21
+	 * Fires inside course-results/lessons.php after the
22
+	 * is uer logged check, just above the lessons header.
23
+	 * @since 1.4.0
24
+	 */
25
+	do_action( 'sensei_course_results_before_lessons', $course->ID );
26
+	?>
27 27
 
28 28
     <header>
29 29
 
@@ -36,33 +36,33 @@  discard block
 block discarded – undo
36 36
         <?php
37 37
 
38 38
 		$displayed_lessons = array();
39
-        $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
39
+		$modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
40 40
 
41
-        // List modules with lessons
42
-        foreach( $modules as $module ) {
41
+		// List modules with lessons
42
+		foreach( $modules as $module ) {
43 43
 
44
-            $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
45
-            $lessons = $lessons_query->get_posts();
44
+			$lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
45
+			$lessons = $lessons_query->get_posts();
46 46
 
47
-            if( count( $lessons ) > 0 ) { ?>
47
+			if( count( $lessons ) > 0 ) { ?>
48 48
 
49 49
                 <h3> <?php echo $module->name; ?></h3>
50 50
 
51 51
                 <?php
52
-                $count = 0;
53
-                foreach( $lessons as $lesson ) {
54
-
55
-                    $lesson_grade = 'n/a';
56
-                    $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
-                    if ( $has_questions ) {
58
-                        $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
59
-                        // Get user quiz grade
60
-                        $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
-                        if ( $lesson_grade ) {
62
-                            $lesson_grade .= '%';
63
-                        }
64
-                    }
65
-                    ?>
52
+				$count = 0;
53
+				foreach( $lessons as $lesson ) {
54
+
55
+					$lesson_grade = 'n/a';
56
+					$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
+					if ( $has_questions ) {
58
+						$lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
59
+						// Get user quiz grade
60
+						$lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
+						if ( $lesson_grade ) {
62
+							$lesson_grade .= '%';
63
+						}
64
+					}
65
+					?>
66 66
                     <h2>
67 67
 
68 68
                         <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>"
@@ -80,17 +80,17 @@  discard block
 block discarded – undo
80 80
 
81 81
                 <?php
82 82
 
83
-                }// end for each
83
+				}// end for each
84 84
 
85
-            }// end if count lesson
85
+			}// end if count lesson
86 86
 
87
-        } // end for each module
88
-        ?>
87
+		} // end for each module
88
+		?>
89 89
 
90 90
         <?php
91 91
 
92
-        $lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
-        if( 0 < count( $lessons ) ): ?>
92
+		$lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
+		if( 0 < count( $lessons ) ): ?>
94 94
 
95 95
 			<h3>
96 96
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
             <?php foreach ( $lessons as $lesson ): ?>
102 102
 
103 103
                 <?php
104
-                $lesson_grade = 'n/a';
105
-                $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
-                if ( $has_questions ) {
107
-                    $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
108
-                    // Get user quiz grade
109
-                    $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
-                    if ( $lesson_grade ) {
111
-                        $lesson_grade .= '%';
112
-                    }
113
-                }
114
-                ?>
104
+				$lesson_grade = 'n/a';
105
+				$has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
+				if ( $has_questions ) {
107
+					$lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
108
+					// Get user quiz grade
109
+					$lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
+					if ( $lesson_grade ) {
111
+						$lesson_grade .= '%';
112
+					}
113
+				}
114
+				?>
115 115
 
116 116
                 <h2>
117 117
 
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 
138 138
                 <?php
139 139
 
140
-                    $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
-                    echo $course_user_grade . '%';
140
+					$course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
+					echo $course_user_grade . '%';
142 142
 
143
-                ?>
143
+				?>
144 144
 
145 145
             </span>
146 146
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
     </article>
150 150
 
151 151
     <?php
152
-    /**
153
-     * Fires inside course-results/lessons.php after the
154
-     * is uer logged check, at the bottom of all lessons.
155
-     *
156
-     * @since 1.4.0
157
-     */
152
+	/**
153
+	 * Fires inside course-results/lessons.php after the
154
+	 * is uer logged check, at the bottom of all lessons.
155
+	 *
156
+	 * @since 1.4.0
157
+	 */
158 158
 	do_action( 'sensei_course_results_after_lessons', $course->ID );
159
-    ?>
159
+	?>
160 160
 
161 161
 <?php endif; //user logged in ?>
162 162
\ No newline at end of file
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-shortcode-user-messages.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -15,91 +15,91 @@
 block discarded – undo
15 15
  */
16 16
 class Sensei_Shortcode_User_Messages implements Sensei_Shortcode_Interface {
17 17
 
18
-    /**
19
-     * @var WP_Query
20
-     * messages for the current user
21
-     */
22
-    protected $messages_query;
23
-
24
-    /**
25
-     * Setup the shortcode object
26
-     *
27
-     * @since 1.9.0
28
-     * @param array $attributes
29
-     * @param string $content
30
-     * @param string $shortcode the shortcode that was called for this instance
31
-     */
32
-    public function __construct( $attributes, $content, $shortcode ){
33
-
34
-        $this->setup_messages_query();
35
-
36
-    }
37
-
38
-    /**
39
-     * create the messages query .
40
-     *
41
-     * @return mixed
42
-     */
43
-    public function setup_messages_query(){
44
-
45
-        $user = wp_get_current_user();
46
-
47
-        $args = array(
48
-            'post_type' => 'sensei_message',
49
-            'posts_per_page' => 500,
50
-            'orderby' => 'date',
51
-            'order' => 'DESC',
52
-            'post_status' => 'publish',
53
-            'meta_query' => array(
54
-                array(
55
-                    'key'     => '_sender',
56
-                    'value'   => $user->user_login,
57
-                    'compare' => '=',
58
-                ),
59
-            ),
60
-        );
61
-
62
-        $this->messages_query  = new WP_Query( $args );
63
-    }
64
-
65
-    /**
66
-     * Rendering the shortcode this class is responsible for.
67
-     *
68
-     * @return string $content
69
-     */
70
-    public function render(){
71
-
72
-        if( !is_user_logged_in() ){
73
-
74
-            Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert'  );
75
-
76
-        } elseif( 0 == $this->messages_query->post_count ){
77
-
78
-            Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert'  );
79
-        }
80
-
81
-        $messages_disabled_in_settings =  ! ( ! isset( Sensei()->settings->settings['messages_disable'] )
82
-                                            || ! Sensei()->settings->settings['messages_disable'] ) ;
83
-
84
-        // don't show anything if messages are disable
85
-        if( $messages_disabled_in_settings ){
86
-            return '';
87
-        }
88
-
89
-        //set the wp_query to the current messages query
90
-        global $wp_query;
91
-        $wp_query = $this->messages_query;
92
-
93
-        ob_start();
94
-        Sensei()->notices->print_notices();
95
-        Sensei_Templates::get_part('loop', 'message');
96
-        $messages_html = ob_get_clean();
97
-
98
-        // set back the global query
99
-        wp_reset_query();
100
-
101
-        return $messages_html;
102
-
103
-    }// end render
18
+	/**
19
+	 * @var WP_Query
20
+	 * messages for the current user
21
+	 */
22
+	protected $messages_query;
23
+
24
+	/**
25
+	 * Setup the shortcode object
26
+	 *
27
+	 * @since 1.9.0
28
+	 * @param array $attributes
29
+	 * @param string $content
30
+	 * @param string $shortcode the shortcode that was called for this instance
31
+	 */
32
+	public function __construct( $attributes, $content, $shortcode ){
33
+
34
+		$this->setup_messages_query();
35
+
36
+	}
37
+
38
+	/**
39
+	 * create the messages query .
40
+	 *
41
+	 * @return mixed
42
+	 */
43
+	public function setup_messages_query(){
44
+
45
+		$user = wp_get_current_user();
46
+
47
+		$args = array(
48
+			'post_type' => 'sensei_message',
49
+			'posts_per_page' => 500,
50
+			'orderby' => 'date',
51
+			'order' => 'DESC',
52
+			'post_status' => 'publish',
53
+			'meta_query' => array(
54
+				array(
55
+					'key'     => '_sender',
56
+					'value'   => $user->user_login,
57
+					'compare' => '=',
58
+				),
59
+			),
60
+		);
61
+
62
+		$this->messages_query  = new WP_Query( $args );
63
+	}
64
+
65
+	/**
66
+	 * Rendering the shortcode this class is responsible for.
67
+	 *
68
+	 * @return string $content
69
+	 */
70
+	public function render(){
71
+
72
+		if( !is_user_logged_in() ){
73
+
74
+			Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert'  );
75
+
76
+		} elseif( 0 == $this->messages_query->post_count ){
77
+
78
+			Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert'  );
79
+		}
80
+
81
+		$messages_disabled_in_settings =  ! ( ! isset( Sensei()->settings->settings['messages_disable'] )
82
+											|| ! Sensei()->settings->settings['messages_disable'] ) ;
83
+
84
+		// don't show anything if messages are disable
85
+		if( $messages_disabled_in_settings ){
86
+			return '';
87
+		}
88
+
89
+		//set the wp_query to the current messages query
90
+		global $wp_query;
91
+		$wp_query = $this->messages_query;
92
+
93
+		ob_start();
94
+		Sensei()->notices->print_notices();
95
+		Sensei_Templates::get_part('loop', 'message');
96
+		$messages_html = ob_get_clean();
97
+
98
+		// set back the global query
99
+		wp_reset_query();
100
+
101
+		return $messages_html;
102
+
103
+	}// end render
104 104
 
105 105
 }// end class
106 106
\ No newline at end of file
Please login to merge, or discard this patch.