Completed
Pull Request — master (#1233)
by Dan
07:34
created
templates/globals/wrapper-end.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * Content wrappers
5 5
  *
Please login to merge, or discard this patch.
templates/single-quiz/question_type-multi-line.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying Multi Line Questions.
5 5
  *
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
      * Get the question data with the current quiz id
19 19
      * All data is loaded in this array to keep the template clean.
20 20
      */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
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.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for displaying Multi Line Questions.
5
- *
6
- * Override this template by copying it to yourtheme/sensei/single-quiz/question_type-multi-line.php
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+	 * The Template for displaying Multi Line Questions.
5
+	 *
6
+	 * Override this template by copying it to yourtheme/sensei/single-quiz/question_type-multi-line.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
 
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.
templates/content-course.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,51 +1,51 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * Content-course.php template file
5
- *
6
- * responsible for content on archive like pages. Only shows the course excerpt.
7
- *
8
- * For single course content please see single-course.php
9
- *
10
- * @author 		Automattic
11
- * @package 	Sensei
12
- * @category    Templates
13
- * @version     1.9.0
14
- */
4
+	 * Content-course.php template file
5
+	 *
6
+	 * responsible for content on archive like pages. Only shows the course excerpt.
7
+	 *
8
+	 * For single course content please see single-course.php
9
+	 *
10
+	 * @author 		Automattic
11
+	 * @package 	Sensei
12
+	 * @category    Templates
13
+	 * @version     1.9.0
14
+	 */
15 15
 ?>
16 16
 
17 17
 <li <?php post_class(  WooThemes_Sensei_Course::get_course_loop_content_class() ); ?> >
18 18
 
19 19
     <?php
20
-    /**
21
-     * This action runs before the sensei course content. It runs inside the sensei
22
-     * content-course.php template.
23
-     *
24
-     * @since 1.9
25
-     *
26
-     * @param integer $course_id
27
-     */
28
-    do_action( 'sensei_course_content_before', get_the_ID() );
29
-    ?>
20
+	/**
21
+	 * This action runs before the sensei course content. It runs inside the sensei
22
+	 * content-course.php template.
23
+	 *
24
+	 * @since 1.9
25
+	 *
26
+	 * @param integer $course_id
27
+	 */
28
+	do_action( 'sensei_course_content_before', get_the_ID() );
29
+	?>
30 30
 
31 31
     <section class="course-content">
32 32
 
33 33
         <section class="entry">
34 34
 
35 35
             <?php
36
-            /**
37
-             * Fires just before the course content in the content-course.php file.
38
-             *
39
-             * @since 1.9
40
-             *
41
-             * @param integer $course_id
42
-             *
43
-             * @hooked Sensei_Templates::the_title          - 5
44
-             * @hooked Sensei()->course->course_image       - 10
45
-             * @hooked  Sensei()->course->the_course_meta   - 20
46
-             */
47
-            do_action('sensei_course_content_inside_before', get_the_ID() );
48
-            ?>
36
+			/**
37
+			 * Fires just before the course content in the content-course.php file.
38
+			 *
39
+			 * @since 1.9
40
+			 *
41
+			 * @param integer $course_id
42
+			 *
43
+			 * @hooked Sensei_Templates::the_title          - 5
44
+			 * @hooked Sensei()->course->course_image       - 10
45
+			 * @hooked  Sensei()->course->the_course_meta   - 20
46
+			 */
47
+			do_action('sensei_course_content_inside_before', get_the_ID() );
48
+			?>
49 49
 
50 50
             <p class="course-excerpt">
51 51
 
@@ -54,34 +54,34 @@  discard block
 block discarded – undo
54 54
             </p>
55 55
 
56 56
             <?php
57
-            /**
58
-             * Fires just after the course content in the content-course.php file.
59
-             *
60
-             * @since 1.9
61
-             *
62
-             * @param integer $course_id
63
-             *
64
-             * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
65
-             */
66
-            do_action('sensei_course_content_inside_after', get_the_ID() );
67
-            ?>
57
+			/**
58
+			 * Fires just after the course content in the content-course.php file.
59
+			 *
60
+			 * @since 1.9
61
+			 *
62
+			 * @param integer $course_id
63
+			 *
64
+			 * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
65
+			 */
66
+			do_action('sensei_course_content_inside_after', get_the_ID() );
67
+			?>
68 68
 
69 69
         </section> <!-- section .entry -->
70 70
 
71 71
     </section> <!-- section .course-content -->
72 72
 
73 73
     <?php
74
-    /**
75
-     * Fires after the course block in the content-course.php file.
76
-     *
77
-     * @since 1.9
78
-     *
79
-     * @param integer $course_id
80
-     *
81
-     * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
82
-     */
83
-    do_action('sensei_course_content_after', get_the_ID() );
84
-    ?>
74
+	/**
75
+	 * Fires after the course block in the content-course.php file.
76
+	 *
77
+	 * @since 1.9
78
+	 *
79
+	 * @param integer $course_id
80
+	 *
81
+	 * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
82
+	 */
83
+	do_action('sensei_course_content_after', get_the_ID() );
84
+	?>
85 85
 
86 86
 
87 87
 </li> <!-- article .(<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ) ) ) ); ?>  -->
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * Content-course.php template file
5 5
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 ?>
16 16
 
17
-<li <?php post_class(  WooThemes_Sensei_Course::get_course_loop_content_class() ); ?> >
17
+<li <?php post_class(WooThemes_Sensei_Course::get_course_loop_content_class()); ?> >
18 18
 
19 19
     <?php
20 20
     /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      *
26 26
      * @param integer $course_id
27 27
      */
28
-    do_action( 'sensei_course_content_before', get_the_ID() );
28
+    do_action('sensei_course_content_before', get_the_ID());
29 29
     ?>
30 30
 
31 31
     <section class="course-content">
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
              * @hooked Sensei()->course->course_image       - 10
45 45
              * @hooked  Sensei()->course->the_course_meta   - 20
46 46
              */
47
-            do_action('sensei_course_content_inside_before', get_the_ID() );
47
+            do_action('sensei_course_content_inside_before', get_the_ID());
48 48
             ?>
49 49
 
50 50
             <p class="course-excerpt">
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
              *
64 64
              * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
65 65
              */
66
-            do_action('sensei_course_content_inside_after', get_the_ID() );
66
+            do_action('sensei_course_content_inside_after', get_the_ID());
67 67
             ?>
68 68
 
69 69
         </section> <!-- section .entry -->
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @hooked  Sensei()->course->the_course_free_lesson_preview - 20
82 82
      */
83
-    do_action('sensei_course_content_after', get_the_ID() );
83
+    do_action('sensei_course_content_after', get_the_ID());
84 84
     ?>
85 85
 
86 86
 
87
-</li> <!-- article .(<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ) ) ) ); ?>  -->
88 87
\ No newline at end of file
88
+</li> <!-- article .(<?php esc_attr_e(join(' ', get_post_class(array('course', 'post')))); ?>  -->
89 89
\ No newline at end of file
Please login to merge, or discard this patch.
templates/course-results/lessons.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying all course lessons on the course results page.
5 5
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 global $course;
15 15
 ?>
16 16
 
17
-<?php if ( is_user_logged_in() ): ?>
17
+<?php if (is_user_logged_in()): ?>
18 18
 
19 19
     <?php
20 20
     /**
@@ -22,53 +22,53 @@  discard block
 block discarded – undo
22 22
      * is uer logged check, just above the lessons header.
23 23
      * @since 1.4.0
24 24
      */
25
-    do_action( 'sensei_course_results_before_lessons', $course->ID );
25
+    do_action('sensei_course_results_before_lessons', $course->ID);
26 26
     ?>
27 27
 
28 28
     <header>
29 29
 
30
-        <h2>  <?php _e( 'Lessons', 'woothemes-sensei' );  ?> </h2>
30
+        <h2>  <?php _e('Lessons', 'woothemes-sensei'); ?> </h2>
31 31
 
32 32
     </header>
33 33
 
34
-    <article class="<?php  esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ), $course->ID ) ) ); ?> ">
34
+    <article class="<?php  esc_attr_e(join(' ', get_post_class(array('course', 'post'), $course->ID))); ?> ">
35 35
 
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 41
         // List modules with lessons
42
-        foreach( $modules as $module ) {
42
+        foreach ($modules as $module) {
43 43
 
44
-            $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
44
+            $lessons_query = Sensei()->modules->get_lessons_query($course->ID, $module->term_id);
45 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 52
                 $count = 0;
53
-                foreach( $lessons as $lesson ) {
53
+                foreach ($lessons as $lesson) {
54 54
 
55 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() );
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 59
                         // Get user quiz grade
60
-                        $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
-                        if ( $lesson_grade ) {
60
+                        $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
61
+                        if ($lesson_grade) {
62 62
                             $lesson_grade .= '%';
63 63
                         }
64 64
                     }
65 65
                     ?>
66 66
                     <h2>
67 67
 
68
-                        <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>"
69
-                           title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>">
68
+                        <a href="<?php esc_url_raw(get_permalink($lesson->ID)); ?>"
69
+                           title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)); ?>">
70 70
 
71
-                            <?php esc_html_e( $lesson->post_title ); ?>
71
+                            <?php esc_html_e($lesson->post_title); ?>
72 72
 
73 73
                         </a>
74 74
 
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
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
 
97
-                <?php _e( 'Other Lessons', 'woothemes-sensei' ); ?>
97
+                <?php _e('Other Lessons', 'woothemes-sensei'); ?>
98 98
 
99 99
             </h3>
100 100
 
101
-            <?php foreach ( $lessons as $lesson ): ?>
101
+            <?php foreach ($lessons as $lesson): ?>
102 102
 
103 103
                 <?php
104 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());
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 108
                     // Get user quiz grade
109
-                    $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
-                    if ( $lesson_grade ) {
109
+                    $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
110
+                    if ($lesson_grade) {
111 111
                         $lesson_grade .= '%';
112 112
                     }
113 113
                 }
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 
116 116
                 <h2>
117 117
 
118
-                    <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ) ?>" title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ) ?>" >
118
+                    <a href="<?php esc_url_raw(get_permalink($lesson->ID)) ?>" title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)) ?>" >
119 119
 
120
-                        <?php esc_html_e( sprintf( __( '%s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>
120
+                        <?php esc_html_e(sprintf(__('%s', 'woothemes-sensei'), $lesson->post_title)); ?>
121 121
 
122 122
                     </a>
123 123
 
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 
133 133
         <h2 class="total-grade">
134 134
 
135
-            <?php _e( 'Total Grade', 'woothemes-sensei' ); ?>
135
+            <?php _e('Total Grade', 'woothemes-sensei'); ?>
136 136
             <span class="lesson-grade">
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
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @since 1.4.0
157 157
      */
158
-	do_action( 'sensei_course_results_after_lessons', $course->ID );
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.
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.
widgets/widget-woothemes-sensei-lesson-component.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly.
3 6
 
4 7
 /**
5 8
  * Sensei Course Component Widget
Please login to merge, or discard this patch.
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-course-categories.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly.
3 6
 
4 7
 /**
5 8
  * Sensei Course Component Widget
Please login to merge, or discard this patch.
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.
widgets/widget-woothemes-sensei-category-courses.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly.
3 6
 
4 7
 /**
5 8
  * Sensei Course Component Widget
Please login to merge, or discard this patch.
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.
includes/class-sensei-wc.php 4 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// security check, don't load file outside WP
3 6
 /**
4 7
  * Sensei Autoloader Class
5 8
  *
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -817,7 +817,7 @@
 block discarded – undo
817 817
      * @param  int $user_id
818 818
      * @param  int $product_id
819 819
      *
820
-     * @return bool
820
+     * @return boolean|null
821 821
      */
822 822
     public static function has_customer_bought_product ( $user_id, $product_id ){
823 823
 
Please login to merge, or discard this patch.
Indentation   +748 added lines, -748 removed lines patch added patch discarded remove patch
@@ -12,735 +12,735 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 Class Sensei_WC{
15
-    /**
16
-     * Load the files needed for the woocommerce integration.
17
-     *
18
-     * @since 1.9.0
19
-     */
20
-    public static function load_woocommerce_integration_hooks(){
15
+	/**
16
+	 * Load the files needed for the woocommerce integration.
17
+	 *
18
+	 * @since 1.9.0
19
+	 */
20
+	public static function load_woocommerce_integration_hooks(){
21 21
 
22
-        require_once( __DIR__ . '/hooks/woocommerce.php' );
22
+		require_once( __DIR__ . '/hooks/woocommerce.php' );
23 23
 
24
-    }
25
-    /**
26
-     * check if WooCommerce plugin is loaded and allowed by Sensei
27
-     *
28
-     * @since 1.9.0
29
-     * @return bool
30
-     */
31
-    public static function is_woocommerce_active(){
24
+	}
25
+	/**
26
+	 * check if WooCommerce plugin is loaded and allowed by Sensei
27
+	 *
28
+	 * @since 1.9.0
29
+	 * @return bool
30
+	 */
31
+	public static function is_woocommerce_active(){
32 32
 
33
-        $is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
34
-        return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
33
+		$is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
34
+		return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
35 35
 
36
-    } // end is_woocommerce_active
36
+	} // end is_woocommerce_active
37 37
 
38
-    /**
39
-     * Checks if the WooCommerce plugin is installed and activation.
40
-     *
41
-     * If you need to check if WooCommerce is activated use Sensei_Utils::is_woocommerce_active().
42
-     * This function does nott check to see if the Sensei setting for WooCommerce is enabled.
43
-     *
44
-     * @since 1.9.0
45
-     *
46
-     * @return bool
47
-     */
48
-    public static function is_woocommerce_present(){
38
+	/**
39
+	 * Checks if the WooCommerce plugin is installed and activation.
40
+	 *
41
+	 * If you need to check if WooCommerce is activated use Sensei_Utils::is_woocommerce_active().
42
+	 * This function does nott check to see if the Sensei setting for WooCommerce is enabled.
43
+	 *
44
+	 * @since 1.9.0
45
+	 *
46
+	 * @return bool
47
+	 */
48
+	public static function is_woocommerce_present(){
49 49
 
50
-        $active_plugins = (array) get_option( 'active_plugins', array() );
50
+		$active_plugins = (array) get_option( 'active_plugins', array() );
51 51
 
52
-        if ( is_multisite() ){
52
+		if ( is_multisite() ){
53 53
 
54
-            $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
54
+			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
55 55
 
56
-        }
56
+		}
57 57
 
58
-        $is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
58
+		$is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
59 59
 
60
-        return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
60
+		return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
61 61
 
62
-    }// end is_woocommerce_present
62
+	}// end is_woocommerce_present
63 63
 
64
-    /**
65
-     * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
66
-     *
67
-     * If multiple exist we will return the latest order.
68
-     *
69
-     * @param $user_id
70
-     * @param $course_id
71
-     * @return array $user_course_orders
72
-     */
73
-    public static function get_learner_course_active_order_id( $user_id, $course_id ){
64
+	/**
65
+	 * Find the order active number (completed or processing ) for a given user on a course. It will return the latest order.
66
+	 *
67
+	 * If multiple exist we will return the latest order.
68
+	 *
69
+	 * @param $user_id
70
+	 * @param $course_id
71
+	 * @return array $user_course_orders
72
+	 */
73
+	public static function get_learner_course_active_order_id( $user_id, $course_id ){
74 74
 
75
-        $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
75
+		$course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
76 76
 
77
-        $orders_query = new WP_Query( array(
78
-            'post_type'   => 'shop_order',
79
-            'posts_per_page' => -1,
80
-            'post_status' => array( 'wc-processing', 'wc-completed' ),
81
-            'meta_key'=> '_customer_user',
82
-            'meta_value'=> $user_id,
83
-        ) );
77
+		$orders_query = new WP_Query( array(
78
+			'post_type'   => 'shop_order',
79
+			'posts_per_page' => -1,
80
+			'post_status' => array( 'wc-processing', 'wc-completed' ),
81
+			'meta_key'=> '_customer_user',
82
+			'meta_value'=> $user_id,
83
+		) );
84 84
 
85
-        if( $orders_query->post_count == 0 ){
85
+		if( $orders_query->post_count == 0 ){
86 86
 
87
-            return false;
87
+			return false;
88 88
 
89
-        }
89
+		}
90 90
 
91
-        foreach( $orders_query->get_posts() as $order ){
91
+		foreach( $orders_query->get_posts() as $order ){
92 92
 
93
-            $order = new WC_Order( $order->ID );
94
-            $items = $order->get_items();
93
+			$order = new WC_Order( $order->ID );
94
+			$items = $order->get_items();
95 95
 
96
-            $user_orders =  array();
96
+			$user_orders =  array();
97 97
 
98
-            foreach( $items as $item ){
98
+			foreach( $items as $item ){
99 99
 
100
-                // if the product id on the order and the one given to this function
101
-                // this order has been placed by the given user on the given course.
102
-                $product = wc_get_product( $item['product_id'] );
100
+				// if the product id on the order and the one given to this function
101
+				// this order has been placed by the given user on the given course.
102
+				$product = wc_get_product( $item['product_id'] );
103 103
 
104
-                if ( $product->is_type( 'variable' )) {
104
+				if ( $product->is_type( 'variable' )) {
105 105
 
106
-                    $item_product_id = $item['variation_id'];
106
+					$item_product_id = $item['variation_id'];
107 107
 
108
-                } else {
108
+				} else {
109 109
 
110
-                    $item_product_id =  $item['product_id'];
110
+					$item_product_id =  $item['product_id'];
111 111
 
112
-                }
112
+				}
113 113
 
114
-                if( $course_product_id == $item_product_id ){
114
+				if( $course_product_id == $item_product_id ){
115 115
 
116
-                    return $order->id;
116
+					return $order->id;
117 117
 
118
-                }
118
+				}
119 119
 
120 120
 
121
-            }//end for each order item
121
+			}//end for each order item
122 122
 
123
-        } // end for each order
123
+		} // end for each order
124 124
 
125
-        // if we reach this place we found no order
126
-        return false;
125
+		// if we reach this place we found no order
126
+		return false;
127 127
 
128
-    } // end get_learner_course_active_order_ids
128
+	} // end get_learner_course_active_order_ids
129 129
 
130
-    /**
131
-     * Output WooCommerce specific course filters
132
-     * Removing the paged argument
133
-     *
134
-     * @since 1.9.0
135
-     * @param $filter_links
136
-     * @return mixed
137
-     */
138
-    public static function add_course_archive_wc_filter_links( $filter_links ){
130
+	/**
131
+	 * Output WooCommerce specific course filters
132
+	 * Removing the paged argument
133
+	 *
134
+	 * @since 1.9.0
135
+	 * @param $filter_links
136
+	 * @return mixed
137
+	 */
138
+	public static function add_course_archive_wc_filter_links( $filter_links ){
139 139
 
140
-        $free_courses = self::get_free_courses();
141
-        $paid_courses = self::get_paid_courses();
140
+		$free_courses = self::get_free_courses();
141
+		$paid_courses = self::get_paid_courses();
142 142
 
143
-        if ( empty( $free_courses ) || empty( $paid_courses )  ){
144
-            // do not show any WooCommerce filters if all courses are
145
-            // free or if all courses are paid
146
-            return $filter_links;
143
+		if ( empty( $free_courses ) || empty( $paid_courses )  ){
144
+			// do not show any WooCommerce filters if all courses are
145
+			// free or if all courses are paid
146
+			return $filter_links;
147 147
 
148
-        }
148
+		}
149 149
 
150
-        $filter_links[] = array(
151
-            'id'=>'paid' ,
152
-            'url'=> add_query_arg( array( 'course_filter'=>'paid'), Sensei_Course::get_courses_page_url() ),
153
-            'title'=>__( 'Paid', 'woothemes-sensei' )
154
-        );
150
+		$filter_links[] = array(
151
+			'id'=>'paid' ,
152
+			'url'=> add_query_arg( array( 'course_filter'=>'paid'), Sensei_Course::get_courses_page_url() ),
153
+			'title'=>__( 'Paid', 'woothemes-sensei' )
154
+		);
155 155
 
156
-        $filter_links[] = array(
157
-            'id'=>'free',
158
-            'url'=> add_query_arg( array( 'course_filter'=>'free'), Sensei_Course::get_courses_page_url() ),
159
-            'title'=>__( 'Free', 'woothemes-sensei' )
160
-        );
156
+		$filter_links[] = array(
157
+			'id'=>'free',
158
+			'url'=> add_query_arg( array( 'course_filter'=>'free'), Sensei_Course::get_courses_page_url() ),
159
+			'title'=>__( 'Free', 'woothemes-sensei' )
160
+		);
161 161
 
162
-        return $filter_links;
162
+		return $filter_links;
163 163
 
164
-    }// end add_course_archive_wc_filter_links
164
+	}// end add_course_archive_wc_filter_links
165 165
 
166
-    /**
167
-     * Apply the free filter the the course query
168
-     * getting all course with no products or products with zero price
169
-     *
170
-     * hooked into pre_get_posts
171
-     *
172
-     * @since 1.9.0
173
-     * @param WP_Query $query
174
-     * @return WP_Query $query
175
-     */
176
-    public static function course_archive_wc_filter_free( $query ){
166
+	/**
167
+	 * Apply the free filter the the course query
168
+	 * getting all course with no products or products with zero price
169
+	 *
170
+	 * hooked into pre_get_posts
171
+	 *
172
+	 * @since 1.9.0
173
+	 * @param WP_Query $query
174
+	 * @return WP_Query $query
175
+	 */
176
+	public static function course_archive_wc_filter_free( $query ){
177 177
 
178
-        if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
-            && 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
178
+		if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
+			&& 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
180 180
 
181
-            // setup the course meta query
182
-            $meta_query = self::get_free_courses_meta_query_args();
181
+			// setup the course meta query
182
+			$meta_query = self::get_free_courses_meta_query_args();
183 183
 
184
-            // manipulate the query to return free courses
185
-            $query->set('meta_query', $meta_query );
184
+			// manipulate the query to return free courses
185
+			$query->set('meta_query', $meta_query );
186 186
 
187
-            // don't show any paid courses
188
-            $courses = self::get_paid_courses();
189
-            $ids = array();
190
-            foreach( $courses as $course ){
191
-                $ids[] = $course->ID;
192
-            }
193
-            $query->set( 'post__not_in', $ids );
187
+			// don't show any paid courses
188
+			$courses = self::get_paid_courses();
189
+			$ids = array();
190
+			foreach( $courses as $course ){
191
+				$ids[] = $course->ID;
192
+			}
193
+			$query->set( 'post__not_in', $ids );
194 194
 
195
-        }// end if course_filter
195
+		}// end if course_filter
196 196
 
197
-        return $query;
197
+		return $query;
198 198
 
199
-    }// course_archive_wc_filter_free
199
+	}// course_archive_wc_filter_free
200 200
 
201
-    /**
202
-     * Apply the paid filter to the course query on the courses page
203
-     * will include all course with a product attached with a price
204
-     * more than 0
205
-     *
206
-     * hooked into pre_get_posts
207
-     *
208
-     * @since 1.9.0
209
-     * @param WP_Query $query
210
-     * @return WP_Query $query
211
-     */
212
-    public static function course_archive_wc_filter_paid( $query ){
201
+	/**
202
+	 * Apply the paid filter to the course query on the courses page
203
+	 * will include all course with a product attached with a price
204
+	 * more than 0
205
+	 *
206
+	 * hooked into pre_get_posts
207
+	 *
208
+	 * @since 1.9.0
209
+	 * @param WP_Query $query
210
+	 * @return WP_Query $query
211
+	 */
212
+	public static function course_archive_wc_filter_paid( $query ){
213 213
 
214
-        if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
-            && 'course' == $query->get( 'post_type') && $query->is_main_query() ){
216
-
217
-            // setup the course meta query
218
-            $meta_query = self::get_paid_courses_meta_query_args();
219
-
220
-            // manipulate the query to return free courses
221
-            $query->set('meta_query', $meta_query );
222
-
223
-        }
224
-
225
-        return $query;
226
-
227
-    }
228
-
229
-    /**
230
-     * Load the WooCommerce single product actions above
231
-     * single courses if woocommerce is active allowing purchase
232
-     * information and actions to be hooked from WooCommerce.
233
-     */
234
-    public static function do_single_course_wc_single_product_action(){
235
-
236
-        /**
237
-         * this hooks is documented within the WooCommerce plugin.
238
-         */
239
-        if ( Sensei_WC::is_woocommerce_active() ) {
240
-
241
-            do_action( 'woocommerce_before_single_product' );
242
-
243
-        } // End If Statement
244
-
245
-    }// end do_single_course_wc_single_product_action
246
-
247
-    /**
248
-     * Hooking into the single lesson page to alter the
249
-     * user access permissions based on if they have purchased the
250
-     * course the lesson belongs to.
251
-     *
252
-     * This function will only return false or the passed in user_access value.
253
-     * It doesn't return true in order to avoid altering other options.
254
-     *
255
-     * @since 1.9.0
256
-     *
257
-     * @param $can_user_view_lesson
258
-     * @param $lesson_id
259
-     * @param $user_id
260
-     * @return bool
261
-     */
262
-    public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
263
-
264
-        // check if the course has a valid product attached to it
265
-        // which the user should have purchased if they want to access
266
-        // the current lesson
267
-        $course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
-        $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
269
-        $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
-        if( isset ($product) && is_object($product) ){
271
-
272
-            // valid product found
273
-            $order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
274
-
275
-            // product has a successful order so this user may access the content
276
-            // this function may only return false or the default
277
-            // returning true may override other negatives which we don't want
278
-            if( ! $order_id ){
279
-
280
-                return false;
281
-
282
-            }
283
-
284
-        }
285
-
286
-        // return the passed in value
287
-        return $can_user_view_lesson;
288
-
289
-    }
290
-
291
-    /**
292
-     * Add course link to order thank you and details pages.
293
-     *
294
-     * @since  1.4.5
295
-     * @access public
296
-     *
297
-     * @return void
298
-     */
299
-    public static function course_link_from_order( ) {
300
-
301
-        if( ! is_order_received_page() ){
302
-            return;
303
-        }
304
-
305
-        $order_id = get_query_var( 'order-received' );
214
+		if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
+			&& 'course' == $query->get( 'post_type') && $query->is_main_query() ){
216
+
217
+			// setup the course meta query
218
+			$meta_query = self::get_paid_courses_meta_query_args();
219
+
220
+			// manipulate the query to return free courses
221
+			$query->set('meta_query', $meta_query );
222
+
223
+		}
224
+
225
+		return $query;
226
+
227
+	}
228
+
229
+	/**
230
+	 * Load the WooCommerce single product actions above
231
+	 * single courses if woocommerce is active allowing purchase
232
+	 * information and actions to be hooked from WooCommerce.
233
+	 */
234
+	public static function do_single_course_wc_single_product_action(){
235
+
236
+		/**
237
+		 * this hooks is documented within the WooCommerce plugin.
238
+		 */
239
+		if ( Sensei_WC::is_woocommerce_active() ) {
240
+
241
+			do_action( 'woocommerce_before_single_product' );
242
+
243
+		} // End If Statement
244
+
245
+	}// end do_single_course_wc_single_product_action
246
+
247
+	/**
248
+	 * Hooking into the single lesson page to alter the
249
+	 * user access permissions based on if they have purchased the
250
+	 * course the lesson belongs to.
251
+	 *
252
+	 * This function will only return false or the passed in user_access value.
253
+	 * It doesn't return true in order to avoid altering other options.
254
+	 *
255
+	 * @since 1.9.0
256
+	 *
257
+	 * @param $can_user_view_lesson
258
+	 * @param $lesson_id
259
+	 * @param $user_id
260
+	 * @return bool
261
+	 */
262
+	public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
263
+
264
+		// check if the course has a valid product attached to it
265
+		// which the user should have purchased if they want to access
266
+		// the current lesson
267
+		$course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
+		$wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
269
+		$product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
+		if( isset ($product) && is_object($product) ){
271
+
272
+			// valid product found
273
+			$order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
274
+
275
+			// product has a successful order so this user may access the content
276
+			// this function may only return false or the default
277
+			// returning true may override other negatives which we don't want
278
+			if( ! $order_id ){
279
+
280
+				return false;
281
+
282
+			}
283
+
284
+		}
285
+
286
+		// return the passed in value
287
+		return $can_user_view_lesson;
288
+
289
+	}
290
+
291
+	/**
292
+	 * Add course link to order thank you and details pages.
293
+	 *
294
+	 * @since  1.4.5
295
+	 * @access public
296
+	 *
297
+	 * @return void
298
+	 */
299
+	public static function course_link_from_order( ) {
300
+
301
+		if( ! is_order_received_page() ){
302
+			return;
303
+		}
304
+
305
+		$order_id = get_query_var( 'order-received' );
306 306
 		$order = new WC_Order( $order_id );
307 307
 
308 308
 		// exit early if not wc-completed or wc-processing
309 309
 		if( 'wc-completed' != $order->post_status
310
-            && 'wc-processing' != $order->post_status  ) {
311
-            return;
312
-        }
310
+			&& 'wc-processing' != $order->post_status  ) {
311
+			return;
312
+		}
313 313
 
314
-        $course_links = array(); // store the for links for courses purchased
314
+		$course_links = array(); // store the for links for courses purchased
315 315
 		foreach ( $order->get_items() as $item ) {
316 316
 
317
-            if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
317
+			if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
318 318
 
319
-                // If item has variation_id then its a variation of the product
320
-                $item_id = $item['variation_id'];
319
+				// If item has variation_id then its a variation of the product
320
+				$item_id = $item['variation_id'];
321 321
 
322
-            } else {
322
+			} else {
323 323
 
324
-                //If not its real product set its id to item_id
325
-                $item_id = $item['product_id'];
324
+				//If not its real product set its id to item_id
325
+				$item_id = $item['product_id'];
326 326
 
327
-            } // End If Statement
327
+			} // End If Statement
328 328
 
329
-            $user_id = get_post_meta( $order->id, '_customer_user', true );
329
+			$user_id = get_post_meta( $order->id, '_customer_user', true );
330 330
 
331
-            if( $user_id ) {
331
+			if( $user_id ) {
332 332
 
333
-                // Get all courses for product
334
-                $args = Sensei_Course::get_default_query_args();
335
-                $args['meta_query'] = array( array(
336
-                            'key' => '_course_woocommerce_product',
337
-                            'value' => $item_id
338
-                        ) );
339
-                $args['orderby'] = 'menu_order date';
340
-                $args['order'] = 'ASC';
333
+				// Get all courses for product
334
+				$args = Sensei_Course::get_default_query_args();
335
+				$args['meta_query'] = array( array(
336
+							'key' => '_course_woocommerce_product',
337
+							'value' => $item_id
338
+						) );
339
+				$args['orderby'] = 'menu_order date';
340
+				$args['order'] = 'ASC';
341 341
 
342
-                // loop through courses
343
-                $courses = get_posts( $args );
344
-                if( $courses && count( $courses ) > 0 ) {
342
+				// loop through courses
343
+				$courses = get_posts( $args );
344
+				if( $courses && count( $courses ) > 0 ) {
345 345
 
346
-                    foreach( $courses as $course ) {
346
+					foreach( $courses as $course ) {
347 347
 
348
-                        $title = $course->post_title;
349
-                        $permalink = get_permalink( $course->ID );
350
-                        $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
348
+						$title = $course->post_title;
349
+						$permalink = get_permalink( $course->ID );
350
+						$course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
351 351
 
352
-                    } // end for each
352
+					} // end for each
353 353
 
354
-                    // close the message div
354
+					// close the message div
355 355
 
356
-                }// end if $courses check
357
-            }
358
-        }// end loop through orders
356
+				}// end if $courses check
357
+			}
358
+		}// end loop through orders
359 359
 
360
-        // add the courses to the WooCommerce notice
361
-        if( ! empty( $course_links) ){
360
+		// add the courses to the WooCommerce notice
361
+		if( ! empty( $course_links) ){
362 362
 
363
-            $courses_html = _nx(
364
-                'You have purchased the following course:',
365
-                'You have purchased the following courses:',
366
-                count( $course_links ),
367
-                'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368
-            );
363
+			$courses_html = _nx(
364
+				'You have purchased the following course:',
365
+				'You have purchased the following courses:',
366
+				count( $course_links ),
367
+				'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368
+			);
369 369
 
370
-            foreach( $course_links as $link ){
370
+			foreach( $course_links as $link ){
371 371
 
372
-                $courses_html .= '<li>' . $link . '</li>';
372
+				$courses_html .= '<li>' . $link . '</li>';
373 373
 
374
-            }
374
+			}
375 375
 
376
-            $courses_html .= ' </ul>';
376
+			$courses_html .= ' </ul>';
377 377
 
378
-            wc_add_notice( $courses_html, 'success' );
379
-        }
378
+			wc_add_notice( $courses_html, 'success' );
379
+		}
380 380
 
381 381
 	} // end course_link_order_form
382 382
 
383
-    /**
384
-     * Show the message that a user should complete
385
-     * their purchase if the course is in the cart
386
-     *
387
-     * This should be used within the course loop or single course page
388
-     *
389
-     * @since 1.9.0
390
-     */
391
-    public static function course_in_cart_message(){
383
+	/**
384
+	 * Show the message that a user should complete
385
+	 * their purchase if the course is in the cart
386
+	 *
387
+	 * This should be used within the course loop or single course page
388
+	 *
389
+	 * @since 1.9.0
390
+	 */
391
+	public static function course_in_cart_message(){
392 392
 
393
-        global $post;
393
+		global $post;
394 394
 
395
-        if( self::is_course_in_cart( $post->ID ) ){ ?>
395
+		if( self::is_course_in_cart( $post->ID ) ){ ?>
396 396
 
397 397
             <div class="sensei-message info">
398 398
                 <?php
399 399
 
400
-                $cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
-                              . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
-                              . __('complete the purchase', 'woothemes-sensei') . '</a>';
400
+				$cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
+							  . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
+							  . __('complete the purchase', 'woothemes-sensei') . '</a>';
403 403
 
404
-                echo sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
404
+				echo sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
405 405
 
406
-                ?>
406
+				?>
407 407
             </div>
408 408
         <?php }
409 409
 
410
-    } // End sensei_woocommerce_in_cart_message()
410
+	} // End sensei_woocommerce_in_cart_message()
411 411
 
412
-    /**
413
-     * Checks the cart to see if a course is in the cart.
414
-     *
415
-     * @param $course_id
416
-     * @return bool
417
-     */
418
-    public static function is_course_in_cart( $course_id ){
419
-
420
-        $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
-        $user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
422
-
423
-        if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
424
-
425
-            if ( self::is_product_in_cart( $wc_post_id ) ) {
426
-
427
-                return true;
428
-
429
-            }
430
-
431
-        }
432
-
433
-        return false;
434
-
435
-    }// is_course_in_cart
436
-
437
-    /**
438
-     * Check the cart to see if the product is in the cart
439
-     *
440
-     * @param $product_id
441
-     * @return bool
442
-     */
443
-    public static function is_product_in_cart( $product_id ){
444
-
445
-        if ( 0 < $product_id ) {
446
-
447
-            $product = wc_get_product( $product_id );
448
-
449
-            $parent_id = '';
450
-            if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
451
-                $wc_product_id = $product->parent->id;
452
-            }
453
-            foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
454
-
455
-                $cart_product = $values['data'];
456
-                if( $product_id == $cart_product->id ) {
457
-
458
-                    return true;
459
-
460
-                }
461
-
462
-            }
463
-        } // End If Statement
464
-
465
-        return false;
466
-
467
-    } // end is_product_in_car
468
-
469
-    /**
470
-     * Get all free WooCommerce products
471
-     *
472
-     * @since 1.9.0
473
-     *
474
-     * @return array $free_products{
475
-     *  @type int $wp_post_id
476
-     * }
477
-     */
478
-    public static function get_free_product_ids(){
479
-
480
-        return  get_posts( array(
481
-            'post_type' => 'product',
482
-            'posts_per_page' => '1000',
483
-            'fields' => 'ids',
484
-            'meta_query'=> array(
485
-                'relation' => 'OR',
486
-                array(
487
-                    'key'=> '_regular_price',
488
-                    'value' => 0,
489
-                ),
490
-                array(
491
-                    'key'=> '_sale_price',
492
-                    'value' => 0,
493
-                ),
494
-            ),
495
-        ));
496
-
497
-    }// end get free product query
498
-
499
-    /**
500
-     * The metat query for courses that are free
501
-     *
502
-     * @since 1.9.0
503
-     * @return array $wp_meta_query_param
504
-     */
505
-    public static function get_free_courses_meta_query_args(){
506
-
507
-        return array(
508
-            'relation' => 'OR',
509
-            array(
510
-                'key'     => '_course_woocommerce_product',
511
-                'value' => '-',
512
-                'compare' => '=',
513
-            ),
514
-            array(
515
-                'key'     => '_course_woocommerce_product',
516
-                'value' => self::get_free_product_ids(),
517
-                'compare' => 'IN',
518
-            ),
519
-        );
520
-
521
-    }// get_free_courses_meta_query
522
-
523
-    /**
524
-     * The metat query for courses that are free
525
-     *
526
-     * @since 1.9.0
527
-     * @return array $wp_query_meta_query_args_param
528
-     */
529
-    public static function get_paid_courses_meta_query_args(){
530
-
531
-        $paid_product_ids = self::get_paid_product_ids();
532
-
533
-        return array(
534
-            array(
535
-                'key'     => '_course_woocommerce_product',
536
-                // when empty we give a false post_id to ensure the caller doesn't get any courses for their
537
-                // query
538
-                'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
539
-                'compare' => 'IN',
540
-            ),
541
-        );
542
-
543
-    }// get_free_courses_meta_query
544
-
545
-    /**
546
-     * The WordPress Query args
547
-     * for paid products on sale
548
-     *
549
-     * @since 1.9.0
550
-     * @return array $product_query_args
551
-     */
552
-    public static function get_paid_products_on_sale_query_args(){
553
-
554
-        $args = array(
555
-                   'post_type' 		=> 'product',
556
-                   'posts_per_page' 		=> 1000,
557
-                   'orderby'         	=> 'date',
558
-                   'order'           	=> 'DESC',
559
-                   'suppress_filters' 	=> 0
560
-        );
561
-
562
-        $args[ 'fields' ]     = 'ids';
563
-
564
-        $args[ 'meta_query' ] = array(
565
-            'relation' => 'AND',
566
-            array(
567
-                'key'=> '_regular_price',
568
-                'compare' => '>',
569
-                'value' => 0,
570
-            ),
571
-            array(
572
-                'key'=> '_sale_price',
573
-                'compare' => '>',
574
-                'value' => 0,
575
-            ),
576
-        );
577
-
578
-        return $args;
579
-
580
-    } // get_paid_products_on_sale_query_args
581
-
582
-
583
-    /**
584
-     * Return the WordPress query args for
585
-     * products not on sale but that is not a free
586
-     *
587
-     * @since 1.9.0
588
-     *
589
-     * @return array
590
-     */
591
-    public static function get_paid_products_not_on_sale_query_args(){
592
-
593
-        $args = array(
594
-            'post_type' 		=> 'product',
595
-            'posts_per_page' 		=> 1000,
596
-            'orderby'         	=> 'date',
597
-            'order'           	=> 'DESC',
598
-            'suppress_filters' 	=> 0
599
-        );
600
-
601
-        $args[ 'fields' ]     = 'ids';
602
-        $args[ 'meta_query' ] = array(
603
-            'relation' => 'AND',
604
-            array(
605
-                'key'=> '_regular_price',
606
-                'compare' => '>',
607
-                'value' => 0,
608
-            ),
609
-            array(
610
-                'key'=> '_sale_price',
611
-                'compare' => '=',
612
-                'value' => '',
613
-            ),
614
-        );
615
-
616
-        return $args;
617
-
618
-
619
-    } // get_paid_courses_meta_query
620
-
621
-    /**
622
-     * Get all WooCommerce non-free product id's
623
-     *
624
-     * @since 1.9.0
625
-     *
626
-     * @return array $woocommerce_paid_product_ids
627
-     */
628
-    public static function get_paid_product_ids(){
629
-
630
-        // get all the paid WooCommerce products that has regular
631
-        // and sale price greater than 0
632
-        // will be used later to check for course with the id as meta
633
-        $paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
634
-
635
-        // get all the paid WooCommerce products that has regular price
636
-        // greater than 0 without a sale price
637
-        // will be used later to check for course with the id as meta
638
-        $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
639
-
640
-        // combine products ID's with regular and sale price grater than zero and those without
641
-        // sale but regular price greater than zero
642
-        $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
643
-
644
-        // if
645
-        if( empty($woocommerce_paid_product_ids) ){
646
-            return array( );
647
-        }
648
-        return $woocommerce_paid_product_ids;
649
-
650
-    }
651
-
652
-    /**
653
-     * Get all free courses.
654
-     *
655
-     * This course that have a WC product attached
656
-     * that has a price or sale price of zero and
657
-     * other courses with no WooCommerce products
658
-     * attached.
659
-     *
660
-     * @since 1.9.0
661
-     *
662
-     * @return array
663
-     */
664
-    public static function get_free_courses(){
665
-
666
-        $free_course_query_args = Sensei_Course::get_default_query_args();
667
-        $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
668
-
669
-        // don't show any paid courses
670
-        $courses = self::get_paid_courses();
671
-        $ids = array();
672
-        foreach( $courses as $course ){
673
-            $ids[] = $course->ID;
674
-        }
675
-        $free_course_query_args[ 'post__not_in' ] =  $ids;
676
-
677
-        return get_posts( $free_course_query_args );
678
-
679
-    }
680
-
681
-    /**
682
-     * Return all products that are not free
683
-     *
684
-     * @since 1.9.0
685
-     * @return array
686
-     */
687
-    public static function get_paid_courses(){
688
-
689
-        $paid_course_query_args = Sensei_Course::get_default_query_args();
690
-
691
-        $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
692
-
693
-        return get_posts(  $paid_course_query_args );
694
-    }
695
-
696
-    /**
697
-     * Show the WooCommerce add to cart button for the  current course
698
-     *
699
-     * The function will only show the button if
700
-     * 1- the user can buy the course
701
-     * 2- if they have completed their pre-requisite
702
-     * 3- if the course has a valid product attached
703
-     *
704
-     * @since 1.9.0
705
-     * @param int $course_id
706
-     * @return string $html markup for the button or nothing if user not allowed to buy
707
-     */
708
-    public static function the_add_to_cart_button_html( $course_id ){
709
-
710
-        if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
711
-            return '';
712
-        }
713
-
714
-        $wc_post_id = self::get_course_product_id( $course_id );
715
-
716
-        // Check if customer purchased the product
717
-        if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
-            || empty( $wc_post_id ) ) {
719
-
720
-            return '';
721
-
722
-        }
723
-
724
-        // based on simple.php in WC templates/single-product/add-to-cart/
725
-        // Get the product
726
-        $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
727
-
728
-        // do not show the button for invalid products, non purchasable products, out
729
-        // of stock product or if course is already in cart
730
-        if ( ! isset ( $product )
731
-            || ! is_object( $product )
732
-            || ! $product->is_purchasable()
733
-            || ! $product->is_in_stock()
734
-            || self::is_course_in_cart( $wc_post_id ) ) {
735
-
736
-            return '';
737
-
738
-        }
739
-
740
-        //
741
-        // button  output:
742
-        //
743
-        ?>
412
+	/**
413
+	 * Checks the cart to see if a course is in the cart.
414
+	 *
415
+	 * @param $course_id
416
+	 * @return bool
417
+	 */
418
+	public static function is_course_in_cart( $course_id ){
419
+
420
+		$wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
+		$user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
422
+
423
+		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
424
+
425
+			if ( self::is_product_in_cart( $wc_post_id ) ) {
426
+
427
+				return true;
428
+
429
+			}
430
+
431
+		}
432
+
433
+		return false;
434
+
435
+	}// is_course_in_cart
436
+
437
+	/**
438
+	 * Check the cart to see if the product is in the cart
439
+	 *
440
+	 * @param $product_id
441
+	 * @return bool
442
+	 */
443
+	public static function is_product_in_cart( $product_id ){
444
+
445
+		if ( 0 < $product_id ) {
446
+
447
+			$product = wc_get_product( $product_id );
448
+
449
+			$parent_id = '';
450
+			if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
451
+				$wc_product_id = $product->parent->id;
452
+			}
453
+			foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
454
+
455
+				$cart_product = $values['data'];
456
+				if( $product_id == $cart_product->id ) {
457
+
458
+					return true;
459
+
460
+				}
461
+
462
+			}
463
+		} // End If Statement
464
+
465
+		return false;
466
+
467
+	} // end is_product_in_car
468
+
469
+	/**
470
+	 * Get all free WooCommerce products
471
+	 *
472
+	 * @since 1.9.0
473
+	 *
474
+	 * @return array $free_products{
475
+	 *  @type int $wp_post_id
476
+	 * }
477
+	 */
478
+	public static function get_free_product_ids(){
479
+
480
+		return  get_posts( array(
481
+			'post_type' => 'product',
482
+			'posts_per_page' => '1000',
483
+			'fields' => 'ids',
484
+			'meta_query'=> array(
485
+				'relation' => 'OR',
486
+				array(
487
+					'key'=> '_regular_price',
488
+					'value' => 0,
489
+				),
490
+				array(
491
+					'key'=> '_sale_price',
492
+					'value' => 0,
493
+				),
494
+			),
495
+		));
496
+
497
+	}// end get free product query
498
+
499
+	/**
500
+	 * The metat query for courses that are free
501
+	 *
502
+	 * @since 1.9.0
503
+	 * @return array $wp_meta_query_param
504
+	 */
505
+	public static function get_free_courses_meta_query_args(){
506
+
507
+		return array(
508
+			'relation' => 'OR',
509
+			array(
510
+				'key'     => '_course_woocommerce_product',
511
+				'value' => '-',
512
+				'compare' => '=',
513
+			),
514
+			array(
515
+				'key'     => '_course_woocommerce_product',
516
+				'value' => self::get_free_product_ids(),
517
+				'compare' => 'IN',
518
+			),
519
+		);
520
+
521
+	}// get_free_courses_meta_query
522
+
523
+	/**
524
+	 * The metat query for courses that are free
525
+	 *
526
+	 * @since 1.9.0
527
+	 * @return array $wp_query_meta_query_args_param
528
+	 */
529
+	public static function get_paid_courses_meta_query_args(){
530
+
531
+		$paid_product_ids = self::get_paid_product_ids();
532
+
533
+		return array(
534
+			array(
535
+				'key'     => '_course_woocommerce_product',
536
+				// when empty we give a false post_id to ensure the caller doesn't get any courses for their
537
+				// query
538
+				'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
539
+				'compare' => 'IN',
540
+			),
541
+		);
542
+
543
+	}// get_free_courses_meta_query
544
+
545
+	/**
546
+	 * The WordPress Query args
547
+	 * for paid products on sale
548
+	 *
549
+	 * @since 1.9.0
550
+	 * @return array $product_query_args
551
+	 */
552
+	public static function get_paid_products_on_sale_query_args(){
553
+
554
+		$args = array(
555
+				   'post_type' 		=> 'product',
556
+				   'posts_per_page' 		=> 1000,
557
+				   'orderby'         	=> 'date',
558
+				   'order'           	=> 'DESC',
559
+				   'suppress_filters' 	=> 0
560
+		);
561
+
562
+		$args[ 'fields' ]     = 'ids';
563
+
564
+		$args[ 'meta_query' ] = array(
565
+			'relation' => 'AND',
566
+			array(
567
+				'key'=> '_regular_price',
568
+				'compare' => '>',
569
+				'value' => 0,
570
+			),
571
+			array(
572
+				'key'=> '_sale_price',
573
+				'compare' => '>',
574
+				'value' => 0,
575
+			),
576
+		);
577
+
578
+		return $args;
579
+
580
+	} // get_paid_products_on_sale_query_args
581
+
582
+
583
+	/**
584
+	 * Return the WordPress query args for
585
+	 * products not on sale but that is not a free
586
+	 *
587
+	 * @since 1.9.0
588
+	 *
589
+	 * @return array
590
+	 */
591
+	public static function get_paid_products_not_on_sale_query_args(){
592
+
593
+		$args = array(
594
+			'post_type' 		=> 'product',
595
+			'posts_per_page' 		=> 1000,
596
+			'orderby'         	=> 'date',
597
+			'order'           	=> 'DESC',
598
+			'suppress_filters' 	=> 0
599
+		);
600
+
601
+		$args[ 'fields' ]     = 'ids';
602
+		$args[ 'meta_query' ] = array(
603
+			'relation' => 'AND',
604
+			array(
605
+				'key'=> '_regular_price',
606
+				'compare' => '>',
607
+				'value' => 0,
608
+			),
609
+			array(
610
+				'key'=> '_sale_price',
611
+				'compare' => '=',
612
+				'value' => '',
613
+			),
614
+		);
615
+
616
+		return $args;
617
+
618
+
619
+	} // get_paid_courses_meta_query
620
+
621
+	/**
622
+	 * Get all WooCommerce non-free product id's
623
+	 *
624
+	 * @since 1.9.0
625
+	 *
626
+	 * @return array $woocommerce_paid_product_ids
627
+	 */
628
+	public static function get_paid_product_ids(){
629
+
630
+		// get all the paid WooCommerce products that has regular
631
+		// and sale price greater than 0
632
+		// will be used later to check for course with the id as meta
633
+		$paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
634
+
635
+		// get all the paid WooCommerce products that has regular price
636
+		// greater than 0 without a sale price
637
+		// will be used later to check for course with the id as meta
638
+		$paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
639
+
640
+		// combine products ID's with regular and sale price grater than zero and those without
641
+		// sale but regular price greater than zero
642
+		$woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
643
+
644
+		// if
645
+		if( empty($woocommerce_paid_product_ids) ){
646
+			return array( );
647
+		}
648
+		return $woocommerce_paid_product_ids;
649
+
650
+	}
651
+
652
+	/**
653
+	 * Get all free courses.
654
+	 *
655
+	 * This course that have a WC product attached
656
+	 * that has a price or sale price of zero and
657
+	 * other courses with no WooCommerce products
658
+	 * attached.
659
+	 *
660
+	 * @since 1.9.0
661
+	 *
662
+	 * @return array
663
+	 */
664
+	public static function get_free_courses(){
665
+
666
+		$free_course_query_args = Sensei_Course::get_default_query_args();
667
+		$free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
668
+
669
+		// don't show any paid courses
670
+		$courses = self::get_paid_courses();
671
+		$ids = array();
672
+		foreach( $courses as $course ){
673
+			$ids[] = $course->ID;
674
+		}
675
+		$free_course_query_args[ 'post__not_in' ] =  $ids;
676
+
677
+		return get_posts( $free_course_query_args );
678
+
679
+	}
680
+
681
+	/**
682
+	 * Return all products that are not free
683
+	 *
684
+	 * @since 1.9.0
685
+	 * @return array
686
+	 */
687
+	public static function get_paid_courses(){
688
+
689
+		$paid_course_query_args = Sensei_Course::get_default_query_args();
690
+
691
+		$paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
692
+
693
+		return get_posts(  $paid_course_query_args );
694
+	}
695
+
696
+	/**
697
+	 * Show the WooCommerce add to cart button for the  current course
698
+	 *
699
+	 * The function will only show the button if
700
+	 * 1- the user can buy the course
701
+	 * 2- if they have completed their pre-requisite
702
+	 * 3- if the course has a valid product attached
703
+	 *
704
+	 * @since 1.9.0
705
+	 * @param int $course_id
706
+	 * @return string $html markup for the button or nothing if user not allowed to buy
707
+	 */
708
+	public static function the_add_to_cart_button_html( $course_id ){
709
+
710
+		if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
711
+			return '';
712
+		}
713
+
714
+		$wc_post_id = self::get_course_product_id( $course_id );
715
+
716
+		// Check if customer purchased the product
717
+		if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
+			|| empty( $wc_post_id ) ) {
719
+
720
+			return '';
721
+
722
+		}
723
+
724
+		// based on simple.php in WC templates/single-product/add-to-cart/
725
+		// Get the product
726
+		$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
727
+
728
+		// do not show the button for invalid products, non purchasable products, out
729
+		// of stock product or if course is already in cart
730
+		if ( ! isset ( $product )
731
+			|| ! is_object( $product )
732
+			|| ! $product->is_purchasable()
733
+			|| ! $product->is_in_stock()
734
+			|| self::is_course_in_cart( $wc_post_id ) ) {
735
+
736
+			return '';
737
+
738
+		}
739
+
740
+		//
741
+		// button  output:
742
+		//
743
+		?>
744 744
 
745 745
         <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"
746 746
               class="cart"
@@ -773,54 +773,54 @@  discard block
 block discarded – undo
773 773
         </form>
774 774
 
775 775
         <?php
776
-    } // end the_add_to_cart_button_html
776
+	} // end the_add_to_cart_button_html
777 777
 
778
-    /**
779
-     * Alter the no permissions message on the single course page
780
-     * Changes the message to a WooCommerce specific message.
781
-     *
782
-     * @since 1.9.0
783
-     *
784
-     * @param $message
785
-     * @param $post_id
786
-     *
787
-     * @return string $message
788
-     */
789
-    public static function alter_no_permissions_message( $message, $post_id ){
778
+	/**
779
+	 * Alter the no permissions message on the single course page
780
+	 * Changes the message to a WooCommerce specific message.
781
+	 *
782
+	 * @since 1.9.0
783
+	 *
784
+	 * @param $message
785
+	 * @param $post_id
786
+	 *
787
+	 * @return string $message
788
+	 */
789
+	public static function alter_no_permissions_message( $message, $post_id ){
790 790
 
791
-        if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
792
-            return  $message;
793
-        }
791
+		if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
792
+			return  $message;
793
+		}
794 794
 
795
-        $product_id = self::get_course_product_id( $post_id );
795
+		$product_id = self::get_course_product_id( $post_id );
796 796
 
797
-        if( ! $product_id
798
-            || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
797
+		if( ! $product_id
798
+			|| self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
799 799
 
800
-            return $message;
800
+			return $message;
801 801
 
802
-        }
802
+		}
803 803
 
804
-        ob_start();
805
-        self::the_course_no_permissions_message( $post_id );
806
-        $woocommerce_course_no_permissions_message = ob_get_clean();
804
+		ob_start();
805
+		self::the_course_no_permissions_message( $post_id );
806
+		$woocommerce_course_no_permissions_message = ob_get_clean();
807 807
 
808
-        return $woocommerce_course_no_permissions_message ;
808
+		return $woocommerce_course_no_permissions_message ;
809 809
 
810
-    }
811
-    /**
812
-     * Show the no permissions message when a user is logged in
813
-     * and have not yet purchased the current course
814
-     *
815
-     * @since 1.9.0
816
-     */
817
-    public static function the_course_no_permissions_message( $course_id ){
810
+	}
811
+	/**
812
+	 * Show the no permissions message when a user is logged in
813
+	 * and have not yet purchased the current course
814
+	 *
815
+	 * @since 1.9.0
816
+	 */
817
+	public static function the_course_no_permissions_message( $course_id ){
818 818
 
819
-        // login link
820
-        $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
-        $login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
819
+		// login link
820
+		$my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
+		$login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
822 822
 
823
-        ?>
823
+		?>
824 824
 
825 825
         <span class="add-to-cart-login">
826 826
             <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?>
@@ -828,110 +828,110 @@  discard block
 block discarded – undo
828 828
 
829 829
     <?php }
830 830
 
831
-    /**
832
-     * Checks if a user has bought a product item.
833
-     *
834
-     * @since  1.9.0
835
-     *
836
-     * @param  int $user_id
837
-     * @param  int $product_id
838
-     *
839
-     * @return bool
840
-     */
841
-    public static function has_customer_bought_product ( $user_id, $product_id ){
831
+	/**
832
+	 * Checks if a user has bought a product item.
833
+	 *
834
+	 * @since  1.9.0
835
+	 *
836
+	 * @param  int $user_id
837
+	 * @param  int $product_id
838
+	 *
839
+	 * @return bool
840
+	 */
841
+	public static function has_customer_bought_product ( $user_id, $product_id ){
842 842
 
843
-        $orders = get_posts( array(
844
-            'posts_per_page' => -1,
845
-            'meta_key'    => '_customer_user',
846
-            'meta_value'  => intval( $user_id ),
847
-            'post_type'   => 'shop_order',
848
-            'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
-        ) );
843
+		$orders = get_posts( array(
844
+			'posts_per_page' => -1,
845
+			'meta_key'    => '_customer_user',
846
+			'meta_value'  => intval( $user_id ),
847
+			'post_type'   => 'shop_order',
848
+			'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
+		) );
850 850
 
851
-        foreach ( $orders as $order_id ) {
851
+		foreach ( $orders as $order_id ) {
852 852
 
853
-            $order = new WC_Order( $order_id->ID );
853
+			$order = new WC_Order( $order_id->ID );
854 854
 
855
-            if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
855
+			if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
856 856
 
857
-                continue;
858
-            }
857
+				continue;
858
+			}
859 859
 
860
-            if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
860
+			if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
861 861
 
862
-                continue;
862
+				continue;
863 863
 
864
-            }
864
+			}
865 865
 
866
-            foreach( $order->get_items() as $item ) {
866
+			foreach( $order->get_items() as $item ) {
867 867
 
868
-                // Check if user has bought product
869
-                if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
868
+				// Check if user has bought product
869
+				if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
870 870
 
871
-                    // Check if user has an active subscription for product
872
-                    if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
-                        $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
-                        if( $sub_key ) {
875
-                            $sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
-                            if( $sub && isset( $sub['status'] ) ) {
877
-                                if( 'active' == $sub['status'] ) {
878
-                                    return true;
879
-                                } else {
880
-                                    return false;
881
-                                }
882
-                            }
883
-                        }
884
-                    }
871
+					// Check if user has an active subscription for product
872
+					if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
+						$sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
+						if( $sub_key ) {
875
+							$sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
+							if( $sub && isset( $sub['status'] ) ) {
877
+								if( 'active' == $sub['status'] ) {
878
+									return true;
879
+								} else {
880
+									return false;
881
+								}
882
+							}
883
+						}
884
+					}
885 885
 
886
-                    // Customer has bought product
887
-                    return true;
888
-                } // End If Statement
886
+					// Customer has bought product
887
+					return true;
888
+				} // End If Statement
889 889
 
890
-            } // End For each item
890
+			} // End For each item
891 891
 
892
-        } // End For each order
892
+		} // End For each order
893 893
 
894
-    } // end has customer bought product
894
+	} // end has customer bought product
895 895
 
896
-    /**
897
-     * Return the product id for the given course
898
-     *
899
-     * @since 1.9.0
900
-     *
901
-     * @param int $course_id
902
-     *
903
-     * @return string $woocommerce_product_id or false if none exist
904
-     *
905
-     */
906
-    public static function get_course_product_id( $course_id ){
896
+	/**
897
+	 * Return the product id for the given course
898
+	 *
899
+	 * @since 1.9.0
900
+	 *
901
+	 * @param int $course_id
902
+	 *
903
+	 * @return string $woocommerce_product_id or false if none exist
904
+	 *
905
+	 */
906
+	public static function get_course_product_id( $course_id ){
907 907
 
908
-        $product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
908
+		$product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
909 909
 
910
-        if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
911
-            return false;
912
-        }
910
+		if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
911
+			return false;
912
+		}
913 913
 
914
-        return $product_id;
914
+		return $product_id;
915 915
 
916
-    }
916
+	}
917 917
 
918
-    /**
919
-     * Alter the body classes adding WooCommerce to the body
920
-     *
921
-     * @param array $classes
922
-     * @return array
923
-     */
924
-    public static function add_woocommerce_body_class( $classes ){
918
+	/**
919
+	 * Alter the body classes adding WooCommerce to the body
920
+	 *
921
+	 * @param array $classes
922
+	 * @return array
923
+	 */
924
+	public static function add_woocommerce_body_class( $classes ){
925 925
 
926
-        if( ! in_array( 'woocommerce', $classes ) ){
926
+		if( ! in_array( 'woocommerce', $classes ) ){
927 927
 
928
-            $classes[] ='woocommerce';
928
+			$classes[] ='woocommerce';
929 929
 
930
-        }
930
+		}
931 931
 
932 932
 
933
-        return $classes;
933
+		return $classes;
934 934
 
935
-    }
935
+	}
936 936
 
937 937
 }// end Sensei_WC
Please login to merge, or discard this patch.
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 
4 4
 /**
5 5
  * Sensei WooCommerce class
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
  * @since 1.9.0
12 12
  */
13 13
 
14
-Class Sensei_WC{
14
+Class Sensei_WC {
15 15
     /**
16 16
      * Load the files needed for the woocommerce integration.
17 17
      *
18 18
      * @since 1.9.0
19 19
      */
20
-    public static function load_woocommerce_integration_hooks(){
20
+    public static function load_woocommerce_integration_hooks() {
21 21
 
22
-        require_once( __DIR__ . '/hooks/woocommerce.php' );
22
+        require_once(__DIR__.'/hooks/woocommerce.php');
23 23
 
24 24
     }
25 25
     /**
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * @since 1.9.0
29 29
      * @return bool
30 30
      */
31
-    public static function is_woocommerce_active(){
31
+    public static function is_woocommerce_active() {
32 32
 
33
-        $is_woocommerce_enabled_in_settings = isset( Sensei()->settings->settings['woocommerce_enabled'] ) && Sensei()->settings->settings['woocommerce_enabled'];
33
+        $is_woocommerce_enabled_in_settings = isset(Sensei()->settings->settings['woocommerce_enabled']) && Sensei()->settings->settings['woocommerce_enabled'];
34 34
         return self::is_woocommerce_present() && $is_woocommerce_enabled_in_settings;
35 35
 
36 36
     } // end is_woocommerce_active
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @return bool
47 47
      */
48
-    public static function is_woocommerce_present(){
48
+    public static function is_woocommerce_present() {
49 49
 
50
-        $active_plugins = (array) get_option( 'active_plugins', array() );
50
+        $active_plugins = (array) get_option('active_plugins', array());
51 51
 
52
-        if ( is_multisite() ){
52
+        if (is_multisite()) {
53 53
 
54
-            $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
54
+            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
55 55
 
56 56
         }
57 57
 
58
-        $is_woocommerce_plugin_present_and_activated = in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );
58
+        $is_woocommerce_plugin_present_and_activated = in_array('woocommerce/woocommerce.php', $active_plugins) || array_key_exists('woocommerce/woocommerce.php', $active_plugins);
59 59
 
60
-        return class_exists( 'Woocommerce' ) || $is_woocommerce_plugin_present_and_activated;
60
+        return class_exists('Woocommerce') || $is_woocommerce_plugin_present_and_activated;
61 61
 
62 62
     }// end is_woocommerce_present
63 63
 
@@ -70,48 +70,48 @@  discard block
 block discarded – undo
70 70
      * @param $course_id
71 71
      * @return array $user_course_orders
72 72
      */
73
-    public static function get_learner_course_active_order_id( $user_id, $course_id ){
73
+    public static function get_learner_course_active_order_id($user_id, $course_id) {
74 74
 
75
-        $course_product_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
75
+        $course_product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
76 76
 
77
-        $orders_query = new WP_Query( array(
77
+        $orders_query = new WP_Query(array(
78 78
             'post_type'   => 'shop_order',
79 79
             'posts_per_page' => -1,
80
-            'post_status' => array( 'wc-processing', 'wc-completed' ),
80
+            'post_status' => array('wc-processing', 'wc-completed'),
81 81
             'meta_key'=> '_customer_user',
82 82
             'meta_value'=> $user_id,
83
-        ) );
83
+        ));
84 84
 
85
-        if( $orders_query->post_count == 0 ){
85
+        if ($orders_query->post_count == 0) {
86 86
 
87 87
             return false;
88 88
 
89 89
         }
90 90
 
91
-        foreach( $orders_query->get_posts() as $order ){
91
+        foreach ($orders_query->get_posts() as $order) {
92 92
 
93
-            $order = new WC_Order( $order->ID );
93
+            $order = new WC_Order($order->ID);
94 94
             $items = $order->get_items();
95 95
 
96
-            $user_orders =  array();
96
+            $user_orders = array();
97 97
 
98
-            foreach( $items as $item ){
98
+            foreach ($items as $item) {
99 99
 
100 100
                 // if the product id on the order and the one given to this function
101 101
                 // this order has been placed by the given user on the given course.
102
-                $product = wc_get_product( $item['product_id'] );
102
+                $product = wc_get_product($item['product_id']);
103 103
 
104
-                if ( $product->is_type( 'variable' )) {
104
+                if ($product->is_type('variable')) {
105 105
 
106 106
                     $item_product_id = $item['variation_id'];
107 107
 
108 108
                 } else {
109 109
 
110
-                    $item_product_id =  $item['product_id'];
110
+                    $item_product_id = $item['product_id'];
111 111
 
112 112
                 }
113 113
 
114
-                if( $course_product_id == $item_product_id ){
114
+                if ($course_product_id == $item_product_id) {
115 115
 
116 116
                     return $order->id;
117 117
 
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      * @param $filter_links
136 136
      * @return mixed
137 137
      */
138
-    public static function add_course_archive_wc_filter_links( $filter_links ){
138
+    public static function add_course_archive_wc_filter_links($filter_links) {
139 139
 
140 140
         $free_courses = self::get_free_courses();
141 141
         $paid_courses = self::get_paid_courses();
142 142
 
143
-        if ( empty( $free_courses ) || empty( $paid_courses )  ){
143
+        if (empty($free_courses) || empty($paid_courses)) {
144 144
             // do not show any WooCommerce filters if all courses are
145 145
             // free or if all courses are paid
146 146
             return $filter_links;
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
         }
149 149
 
150 150
         $filter_links[] = array(
151
-            'id'=>'paid' ,
152
-            'url'=> add_query_arg( array( 'course_filter'=>'paid'), Sensei_Course::get_courses_page_url() ),
153
-            'title'=>__( 'Paid', 'woothemes-sensei' )
151
+            'id'=>'paid',
152
+            'url'=> add_query_arg(array('course_filter'=>'paid'), Sensei_Course::get_courses_page_url()),
153
+            'title'=>__('Paid', 'woothemes-sensei')
154 154
         );
155 155
 
156 156
         $filter_links[] = array(
157 157
             'id'=>'free',
158
-            'url'=> add_query_arg( array( 'course_filter'=>'free'), Sensei_Course::get_courses_page_url() ),
159
-            'title'=>__( 'Free', 'woothemes-sensei' )
158
+            'url'=> add_query_arg(array('course_filter'=>'free'), Sensei_Course::get_courses_page_url()),
159
+            'title'=>__('Free', 'woothemes-sensei')
160 160
         );
161 161
 
162 162
         return $filter_links;
@@ -173,24 +173,24 @@  discard block
 block discarded – undo
173 173
      * @param WP_Query $query
174 174
      * @return WP_Query $query
175 175
      */
176
-    public static function course_archive_wc_filter_free( $query ){
176
+    public static function course_archive_wc_filter_free($query) {
177 177
 
178
-        if( isset( $_GET['course_filter'] ) && 'free' == $_GET['course_filter']
179
-            && 'course' == $query->get( 'post_type') && $query->is_main_query()  ){
178
+        if (isset($_GET['course_filter']) && 'free' == $_GET['course_filter']
179
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
180 180
 
181 181
             // setup the course meta query
182 182
             $meta_query = self::get_free_courses_meta_query_args();
183 183
 
184 184
             // manipulate the query to return free courses
185
-            $query->set('meta_query', $meta_query );
185
+            $query->set('meta_query', $meta_query);
186 186
 
187 187
             // don't show any paid courses
188 188
             $courses = self::get_paid_courses();
189 189
             $ids = array();
190
-            foreach( $courses as $course ){
190
+            foreach ($courses as $course) {
191 191
                 $ids[] = $course->ID;
192 192
             }
193
-            $query->set( 'post__not_in', $ids );
193
+            $query->set('post__not_in', $ids);
194 194
 
195 195
         }// end if course_filter
196 196
 
@@ -209,16 +209,16 @@  discard block
 block discarded – undo
209 209
      * @param WP_Query $query
210 210
      * @return WP_Query $query
211 211
      */
212
-    public static function course_archive_wc_filter_paid( $query ){
212
+    public static function course_archive_wc_filter_paid($query) {
213 213
 
214
-        if( isset( $_GET['course_filter'] ) && 'paid' == $_GET['course_filter']
215
-            && 'course' == $query->get( 'post_type') && $query->is_main_query() ){
214
+        if (isset($_GET['course_filter']) && 'paid' == $_GET['course_filter']
215
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
216 216
 
217 217
             // setup the course meta query
218 218
             $meta_query = self::get_paid_courses_meta_query_args();
219 219
 
220 220
             // manipulate the query to return free courses
221
-            $query->set('meta_query', $meta_query );
221
+            $query->set('meta_query', $meta_query);
222 222
 
223 223
         }
224 224
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
      * single courses if woocommerce is active allowing purchase
232 232
      * information and actions to be hooked from WooCommerce.
233 233
      */
234
-    public static function do_single_course_wc_single_product_action(){
234
+    public static function do_single_course_wc_single_product_action() {
235 235
 
236 236
         /**
237 237
          * this hooks is documented within the WooCommerce plugin.
238 238
          */
239
-        if ( Sensei_WC::is_woocommerce_active() ) {
239
+        if (Sensei_WC::is_woocommerce_active()) {
240 240
 
241
-            do_action( 'woocommerce_before_single_product' );
241
+            do_action('woocommerce_before_single_product');
242 242
 
243 243
         } // End If Statement
244 244
 
@@ -259,23 +259,23 @@  discard block
 block discarded – undo
259 259
      * @param $user_id
260 260
      * @return bool
261 261
      */
262
-    public static function alter_can_user_view_lesson ( $can_user_view_lesson, $lesson_id, $user_id  ){
262
+    public static function alter_can_user_view_lesson($can_user_view_lesson, $lesson_id, $user_id) {
263 263
 
264 264
         // check if the course has a valid product attached to it
265 265
         // which the user should have purchased if they want to access
266 266
         // the current lesson
267
-        $course_id = get_post_meta( $lesson_id , '_lesson_course', true);
268
-        $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
267
+        $course_id = get_post_meta($lesson_id, '_lesson_course', true);
268
+        $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true);
269 269
         $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
270
-        if( isset ($product) && is_object($product) ){
270
+        if (isset ($product) && is_object($product)) {
271 271
 
272 272
             // valid product found
273
-            $order_id = self::get_learner_course_active_order_id( $user_id, $course_id );
273
+            $order_id = self::get_learner_course_active_order_id($user_id, $course_id);
274 274
 
275 275
             // product has a successful order so this user may access the content
276 276
             // this function may only return false or the default
277 277
             // returning true may override other negatives which we don't want
278
-            if( ! $order_id ){
278
+            if ( ! $order_id) {
279 279
 
280 280
                 return false;
281 281
 
@@ -298,23 +298,23 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public static function course_link_from_order( ) {
300 300
 
301
-        if( ! is_order_received_page() ){
301
+        if ( ! is_order_received_page()) {
302 302
             return;
303 303
         }
304 304
 
305
-        $order_id = get_query_var( 'order-received' );
306
-		$order = new WC_Order( $order_id );
305
+        $order_id = get_query_var('order-received');
306
+		$order = new WC_Order($order_id);
307 307
 
308 308
 		// exit early if not wc-completed or wc-processing
309
-		if( 'wc-completed' != $order->post_status
310
-            && 'wc-processing' != $order->post_status  ) {
309
+		if ('wc-completed' != $order->post_status
310
+            && 'wc-processing' != $order->post_status) {
311 311
             return;
312 312
         }
313 313
 
314 314
         $course_links = array(); // store the for links for courses purchased
315
-		foreach ( $order->get_items() as $item ) {
315
+		foreach ($order->get_items() as $item) {
316 316
 
317
-            if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
317
+            if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
318 318
 
319 319
                 // If item has variation_id then its a variation of the product
320 320
                 $item_id = $item['variation_id'];
@@ -326,28 +326,28 @@  discard block
 block discarded – undo
326 326
 
327 327
             } // End If Statement
328 328
 
329
-            $user_id = get_post_meta( $order->id, '_customer_user', true );
329
+            $user_id = get_post_meta($order->id, '_customer_user', true);
330 330
 
331
-            if( $user_id ) {
331
+            if ($user_id) {
332 332
 
333 333
                 // Get all courses for product
334 334
                 $args = Sensei_Course::get_default_query_args();
335
-                $args['meta_query'] = array( array(
335
+                $args['meta_query'] = array(array(
336 336
                             'key' => '_course_woocommerce_product',
337 337
                             'value' => $item_id
338
-                        ) );
338
+                        ));
339 339
                 $args['orderby'] = 'menu_order date';
340 340
                 $args['order'] = 'ASC';
341 341
 
342 342
                 // loop through courses
343
-                $courses = get_posts( $args );
344
-                if( $courses && count( $courses ) > 0 ) {
343
+                $courses = get_posts($args);
344
+                if ($courses && count($courses) > 0) {
345 345
 
346
-                    foreach( $courses as $course ) {
346
+                    foreach ($courses as $course) {
347 347
 
348 348
                         $title = $course->post_title;
349
-                        $permalink = get_permalink( $course->ID );
350
-                        $course_links[] .= '<a href="' . esc_url( $permalink ) . '" >' . $title . '</a> ';
349
+                        $permalink = get_permalink($course->ID);
350
+                        $course_links[] .= '<a href="'.esc_url($permalink).'" >'.$title.'</a> ';
351 351
 
352 352
                     } // end for each
353 353
 
@@ -358,24 +358,24 @@  discard block
 block discarded – undo
358 358
         }// end loop through orders
359 359
 
360 360
         // add the courses to the WooCommerce notice
361
-        if( ! empty( $course_links) ){
361
+        if ( ! empty($course_links)) {
362 362
 
363 363
             $courses_html = _nx(
364 364
                 'You have purchased the following course:',
365 365
                 'You have purchased the following courses:',
366
-                count( $course_links ),
366
+                count($course_links),
367 367
                 'Purchase thank you note on Checkout page. The course link(s) will be show', 'woothemes-sensei'
368 368
             );
369 369
 
370
-            foreach( $course_links as $link ){
370
+            foreach ($course_links as $link) {
371 371
 
372
-                $courses_html .= '<li>' . $link . '</li>';
372
+                $courses_html .= '<li>'.$link.'</li>';
373 373
 
374 374
             }
375 375
 
376 376
             $courses_html .= ' </ul>';
377 377
 
378
-            wc_add_notice( $courses_html, 'success' );
378
+            wc_add_notice($courses_html, 'success');
379 379
         }
380 380
 
381 381
 	} // end course_link_order_form
@@ -388,20 +388,20 @@  discard block
 block discarded – undo
388 388
      *
389 389
      * @since 1.9.0
390 390
      */
391
-    public static function course_in_cart_message(){
391
+    public static function course_in_cart_message() {
392 392
 
393 393
         global $post;
394 394
 
395
-        if( self::is_course_in_cart( $post->ID ) ){ ?>
395
+        if (self::is_course_in_cart($post->ID)) { ?>
396 396
 
397 397
             <div class="sensei-message info">
398 398
                 <?php
399 399
 
400
-                $cart_link =  '<a class="cart-complete" href="' . WC()->cart->get_checkout_url()
401
-                              . '" title="' . __('complete purchase', 'woothemes-sensei') . '">'
402
-                              . __('complete the purchase', 'woothemes-sensei') . '</a>';
400
+                $cart_link = '<a class="cart-complete" href="'.WC()->cart->get_checkout_url()
401
+                              . '" title="'.__('complete purchase', 'woothemes-sensei').'">'
402
+                              . __('complete the purchase', 'woothemes-sensei').'</a>';
403 403
 
404
-                echo sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link );
404
+                echo sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei'), $cart_link);
405 405
 
406 406
                 ?>
407 407
             </div>
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
      * @param $course_id
416 416
      * @return bool
417 417
      */
418
-    public static function is_course_in_cart( $course_id ){
418
+    public static function is_course_in_cart($course_id) {
419 419
 
420
-        $wc_post_id = absint( get_post_meta( $course_id, '_course_woocommerce_product', true ) );
421
-        $user_course_status_id = Sensei_Utils::user_started_course( $course_id , get_current_user_id() );
420
+        $wc_post_id = absint(get_post_meta($course_id, '_course_woocommerce_product', true));
421
+        $user_course_status_id = Sensei_Utils::user_started_course($course_id, get_current_user_id());
422 422
 
423
-        if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
423
+        if (0 < intval($wc_post_id) && ! $user_course_status_id) {
424 424
 
425
-            if ( self::is_product_in_cart( $wc_post_id ) ) {
425
+            if (self::is_product_in_cart($wc_post_id)) {
426 426
 
427 427
                 return true;
428 428
 
@@ -440,20 +440,20 @@  discard block
 block discarded – undo
440 440
      * @param $product_id
441 441
      * @return bool
442 442
      */
443
-    public static function is_product_in_cart( $product_id ){
443
+    public static function is_product_in_cart($product_id) {
444 444
 
445
-        if ( 0 < $product_id ) {
445
+        if (0 < $product_id) {
446 446
 
447
-            $product = wc_get_product( $product_id );
447
+            $product = wc_get_product($product_id);
448 448
 
449 449
             $parent_id = '';
450
-            if( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) {
450
+            if (isset($product->variation_id) && 0 < intval($product->variation_id)) {
451 451
                 $wc_product_id = $product->parent->id;
452 452
             }
453
-            foreach( WC()->cart->get_cart() as $cart_item_key => $values ) {
453
+            foreach (WC()->cart->get_cart() as $cart_item_key => $values) {
454 454
 
455 455
                 $cart_product = $values['data'];
456
-                if( $product_id == $cart_product->id ) {
456
+                if ($product_id == $cart_product->id) {
457 457
 
458 458
                     return true;
459 459
 
@@ -475,9 +475,9 @@  discard block
 block discarded – undo
475 475
      *  @type int $wp_post_id
476 476
      * }
477 477
      */
478
-    public static function get_free_product_ids(){
478
+    public static function get_free_product_ids() {
479 479
 
480
-        return  get_posts( array(
480
+        return  get_posts(array(
481 481
             'post_type' => 'product',
482 482
             'posts_per_page' => '1000',
483 483
             'fields' => 'ids',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
      * @since 1.9.0
503 503
      * @return array $wp_meta_query_param
504 504
      */
505
-    public static function get_free_courses_meta_query_args(){
505
+    public static function get_free_courses_meta_query_args() {
506 506
 
507 507
         return array(
508 508
             'relation' => 'OR',
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
      * @since 1.9.0
527 527
      * @return array $wp_query_meta_query_args_param
528 528
      */
529
-    public static function get_paid_courses_meta_query_args(){
529
+    public static function get_paid_courses_meta_query_args() {
530 530
 
531 531
         $paid_product_ids = self::get_paid_product_ids();
532 532
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
                 'key'     => '_course_woocommerce_product',
536 536
                 // when empty we give a false post_id to ensure the caller doesn't get any courses for their
537 537
                 // query
538
-                'value' => empty( $paid_product_ids  )? '-1000' : $paid_product_ids,
538
+                'value' => empty($paid_product_ids) ? '-1000' : $paid_product_ids,
539 539
                 'compare' => 'IN',
540 540
             ),
541 541
         );
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      * @since 1.9.0
550 550
      * @return array $product_query_args
551 551
      */
552
-    public static function get_paid_products_on_sale_query_args(){
552
+    public static function get_paid_products_on_sale_query_args() {
553 553
 
554 554
         $args = array(
555 555
                    'post_type' 		=> 'product',
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
                    'suppress_filters' 	=> 0
560 560
         );
561 561
 
562
-        $args[ 'fields' ]     = 'ids';
562
+        $args['fields']     = 'ids';
563 563
 
564
-        $args[ 'meta_query' ] = array(
564
+        $args['meta_query'] = array(
565 565
             'relation' => 'AND',
566 566
             array(
567 567
                 'key'=> '_regular_price',
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
      *
589 589
      * @return array
590 590
      */
591
-    public static function get_paid_products_not_on_sale_query_args(){
591
+    public static function get_paid_products_not_on_sale_query_args() {
592 592
 
593 593
         $args = array(
594 594
             'post_type' 		=> 'product',
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
             'suppress_filters' 	=> 0
599 599
         );
600 600
 
601
-        $args[ 'fields' ]     = 'ids';
602
-        $args[ 'meta_query' ] = array(
601
+        $args['fields']     = 'ids';
602
+        $args['meta_query'] = array(
603 603
             'relation' => 'AND',
604 604
             array(
605 605
                 'key'=> '_regular_price',
@@ -625,24 +625,24 @@  discard block
 block discarded – undo
625 625
      *
626 626
      * @return array $woocommerce_paid_product_ids
627 627
      */
628
-    public static function get_paid_product_ids(){
628
+    public static function get_paid_product_ids() {
629 629
 
630 630
         // get all the paid WooCommerce products that has regular
631 631
         // and sale price greater than 0
632 632
         // will be used later to check for course with the id as meta
633
-        $paid_product_ids_with_sale =  get_posts( self::get_paid_products_on_sale_query_args() );
633
+        $paid_product_ids_with_sale = get_posts(self::get_paid_products_on_sale_query_args());
634 634
 
635 635
         // get all the paid WooCommerce products that has regular price
636 636
         // greater than 0 without a sale price
637 637
         // will be used later to check for course with the id as meta
638
-        $paid_product_ids_without_sale = get_posts( self::get_paid_products_not_on_sale_query_args() );
638
+        $paid_product_ids_without_sale = get_posts(self::get_paid_products_not_on_sale_query_args());
639 639
 
640 640
         // combine products ID's with regular and sale price grater than zero and those without
641 641
         // sale but regular price greater than zero
642
-        $woocommerce_paid_product_ids = array_merge( $paid_product_ids_with_sale, $paid_product_ids_without_sale );
642
+        $woocommerce_paid_product_ids = array_merge($paid_product_ids_with_sale, $paid_product_ids_without_sale);
643 643
 
644 644
         // if
645
-        if( empty($woocommerce_paid_product_ids) ){
645
+        if (empty($woocommerce_paid_product_ids)) {
646 646
             return array( );
647 647
         }
648 648
         return $woocommerce_paid_product_ids;
@@ -661,20 +661,20 @@  discard block
 block discarded – undo
661 661
      *
662 662
      * @return array
663 663
      */
664
-    public static function get_free_courses(){
664
+    public static function get_free_courses() {
665 665
 
666 666
         $free_course_query_args = Sensei_Course::get_default_query_args();
667
-        $free_course_query_args[ 'meta_query' ] = self::get_free_courses_meta_query_args();
667
+        $free_course_query_args['meta_query'] = self::get_free_courses_meta_query_args();
668 668
 
669 669
         // don't show any paid courses
670 670
         $courses = self::get_paid_courses();
671 671
         $ids = array();
672
-        foreach( $courses as $course ){
672
+        foreach ($courses as $course) {
673 673
             $ids[] = $course->ID;
674 674
         }
675
-        $free_course_query_args[ 'post__not_in' ] =  $ids;
675
+        $free_course_query_args['post__not_in'] = $ids;
676 676
 
677
-        return get_posts( $free_course_query_args );
677
+        return get_posts($free_course_query_args);
678 678
 
679 679
     }
680 680
 
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
      * @since 1.9.0
685 685
      * @return array
686 686
      */
687
-    public static function get_paid_courses(){
687
+    public static function get_paid_courses() {
688 688
 
689 689
         $paid_course_query_args = Sensei_Course::get_default_query_args();
690 690
 
691
-        $paid_course_query_args[ 'meta_query' ] = self::get_paid_courses_meta_query_args();
691
+        $paid_course_query_args['meta_query'] = self::get_paid_courses_meta_query_args();
692 692
 
693
-        return get_posts(  $paid_course_query_args );
693
+        return get_posts($paid_course_query_args);
694 694
     }
695 695
 
696 696
     /**
@@ -705,17 +705,17 @@  discard block
 block discarded – undo
705 705
      * @param int $course_id
706 706
      * @return string $html markup for the button or nothing if user not allowed to buy
707 707
      */
708
-    public static function the_add_to_cart_button_html( $course_id ){
708
+    public static function the_add_to_cart_button_html($course_id) {
709 709
 
710
-        if ( ! Sensei_Course::is_prerequisite_complete( $course_id )) {
710
+        if ( ! Sensei_Course::is_prerequisite_complete($course_id)) {
711 711
             return '';
712 712
         }
713 713
 
714
-        $wc_post_id = self::get_course_product_id( $course_id );
714
+        $wc_post_id = self::get_course_product_id($course_id);
715 715
 
716 716
         // Check if customer purchased the product
717
-        if ( self::has_customer_bought_product(  get_current_user_id(), $wc_post_id )
718
-            || empty( $wc_post_id ) ) {
717
+        if (self::has_customer_bought_product(get_current_user_id(), $wc_post_id)
718
+            || empty($wc_post_id)) {
719 719
 
720 720
             return '';
721 721
 
@@ -723,15 +723,15 @@  discard block
 block discarded – undo
723 723
 
724 724
         // based on simple.php in WC templates/single-product/add-to-cart/
725 725
         // Get the product
726
-        $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
726
+        $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
727 727
 
728 728
         // do not show the button for invalid products, non purchasable products, out
729 729
         // of stock product or if course is already in cart
730
-        if ( ! isset ( $product )
731
-            || ! is_object( $product )
730
+        if ( ! isset ($product)
731
+            || ! is_object($product)
732 732
             || ! $product->is_purchasable()
733 733
             || ! $product->is_in_stock()
734
-            || self::is_course_in_cart( $wc_post_id ) ) {
734
+            || self::is_course_in_cart($wc_post_id)) {
735 735
 
736 736
             return '';
737 737
 
@@ -742,23 +742,23 @@  discard block
 block discarded – undo
742 742
         //
743 743
         ?>
744 744
 
745
-        <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>"
745
+        <form action="<?php echo esc_url($product->add_to_cart_url()); ?>"
746 746
               class="cart"
747 747
               method="post"
748 748
               enctype="multipart/form-data">
749 749
 
750
-            <input type="hidden" name="product_id" value="<?php echo esc_attr( $product->id ); ?>" />
750
+            <input type="hidden" name="product_id" value="<?php echo esc_attr($product->id); ?>" />
751 751
 
752 752
             <input type="hidden" name="quantity" value="1" />
753 753
 
754
-            <?php if ( isset( $product->variation_id ) && 0 < intval( $product->variation_id ) ) { ?>
754
+            <?php if (isset($product->variation_id) && 0 < intval($product->variation_id)) { ?>
755 755
 
756 756
                 <input type="hidden" name="variation_id" value="<?php echo $product->variation_id; ?>" />
757
-                <?php if( isset( $product->variation_data ) && is_array( $product->variation_data ) && count( $product->variation_data ) > 0 ) { ?>
757
+                <?php if (isset($product->variation_data) && is_array($product->variation_data) && count($product->variation_data) > 0) { ?>
758 758
 
759
-                    <?php foreach( $product->variation_data as $att => $val ) { ?>
759
+                    <?php foreach ($product->variation_data as $att => $val) { ?>
760 760
 
761
-                        <input type="hidden" name="<?php echo esc_attr( $att ); ?>" id="<?php echo esc_attr( str_replace( 'attribute_', '', $att ) ); ?>" value="<?php echo esc_attr( $val ); ?>" />
761
+                        <input type="hidden" name="<?php echo esc_attr($att); ?>" id="<?php echo esc_attr(str_replace('attribute_', '', $att)); ?>" value="<?php echo esc_attr($val); ?>" />
762 762
 
763 763
                     <?php } ?>
764 764
 
@@ -786,26 +786,26 @@  discard block
 block discarded – undo
786 786
      *
787 787
      * @return string $message
788 788
      */
789
-    public static function alter_no_permissions_message( $message, $post_id ){
789
+    public static function alter_no_permissions_message($message, $post_id) {
790 790
 
791
-        if( empty( $post_id ) || 'course'!=get_post_type( $post_id ) ){
791
+        if (empty($post_id) || 'course' != get_post_type($post_id)) {
792 792
             return  $message;
793 793
         }
794 794
 
795
-        $product_id = self::get_course_product_id( $post_id );
795
+        $product_id = self::get_course_product_id($post_id);
796 796
 
797
-        if( ! $product_id
798
-            || self::has_customer_bought_product( get_current_user_id(),$product_id ) ){
797
+        if ( ! $product_id
798
+            || self::has_customer_bought_product(get_current_user_id(), $product_id)) {
799 799
 
800 800
             return $message;
801 801
 
802 802
         }
803 803
 
804 804
         ob_start();
805
-        self::the_course_no_permissions_message( $post_id );
805
+        self::the_course_no_permissions_message($post_id);
806 806
         $woocommerce_course_no_permissions_message = ob_get_clean();
807 807
 
808
-        return $woocommerce_course_no_permissions_message ;
808
+        return $woocommerce_course_no_permissions_message;
809 809
 
810 810
     }
811 811
     /**
@@ -814,16 +814,16 @@  discard block
 block discarded – undo
814 814
      *
815 815
      * @since 1.9.0
816 816
      */
817
-    public static function the_course_no_permissions_message( $course_id ){
817
+    public static function the_course_no_permissions_message($course_id) {
818 818
 
819 819
         // login link
820
-        $my_courses_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
821
-        $login_link =  '<a href="' . esc_url( get_permalink( $my_courses_page_id ) ) . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
820
+        $my_courses_page_id = intval(Sensei()->settings->settings['my_course_page']);
821
+        $login_link = '<a href="'.esc_url(get_permalink($my_courses_page_id)).'">'.__('log in', 'woothemes-sensei').'</a>';
822 822
 
823 823
         ?>
824 824
 
825 825
         <span class="add-to-cart-login">
826
-            <?php echo sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link ); ?>
826
+            <?php echo sprintf(__('Or %1$s to access your purchased courses', 'woothemes-sensei'), $login_link); ?>
827 827
         </span>
828 828
 
829 829
     <?php }
@@ -838,43 +838,43 @@  discard block
 block discarded – undo
838 838
      *
839 839
      * @return bool
840 840
      */
841
-    public static function has_customer_bought_product ( $user_id, $product_id ){
841
+    public static function has_customer_bought_product($user_id, $product_id) {
842 842
 
843
-        $orders = get_posts( array(
843
+        $orders = get_posts(array(
844 844
             'posts_per_page' => -1,
845 845
             'meta_key'    => '_customer_user',
846
-            'meta_value'  => intval( $user_id ),
846
+            'meta_value'  => intval($user_id),
847 847
             'post_type'   => 'shop_order',
848
-            'post_status' =>  array( 'wc-processing', 'wc-completed' ),
849
-        ) );
848
+            'post_status' =>  array('wc-processing', 'wc-completed'),
849
+        ));
850 850
 
851
-        foreach ( $orders as $order_id ) {
851
+        foreach ($orders as $order_id) {
852 852
 
853
-            $order = new WC_Order( $order_id->ID );
853
+            $order = new WC_Order($order_id->ID);
854 854
 
855
-            if ( $order->post_status != 'wc-completed' && $order->post_status != 'wc-processing' ) {
855
+            if ($order->post_status != 'wc-completed' && $order->post_status != 'wc-processing') {
856 856
 
857 857
                 continue;
858 858
             }
859 859
 
860
-            if ( ! ( 0 < sizeof( $order->get_items() ) ) ) {
860
+            if ( ! (0 < sizeof($order->get_items()))) {
861 861
 
862 862
                 continue;
863 863
 
864 864
             }
865 865
 
866
-            foreach( $order->get_items() as $item ) {
866
+            foreach ($order->get_items() as $item) {
867 867
 
868 868
                 // Check if user has bought product
869
-                if ( $item['product_id'] == $product_id || $item['variation_id'] == $product_id ) {
869
+                if ($item['product_id'] == $product_id || $item['variation_id'] == $product_id) {
870 870
 
871 871
                     // Check if user has an active subscription for product
872
-                    if( class_exists( 'WC_Subscriptions_Manager' ) ) {
873
-                        $sub_key = WC_Subscriptions_Manager::get_subscription_key( $order_id->ID, $product_id );
874
-                        if( $sub_key ) {
875
-                            $sub = WC_Subscriptions_Manager::get_subscription( $sub_key );
876
-                            if( $sub && isset( $sub['status'] ) ) {
877
-                                if( 'active' == $sub['status'] ) {
872
+                    if (class_exists('WC_Subscriptions_Manager')) {
873
+                        $sub_key = WC_Subscriptions_Manager::get_subscription_key($order_id->ID, $product_id);
874
+                        if ($sub_key) {
875
+                            $sub = WC_Subscriptions_Manager::get_subscription($sub_key);
876
+                            if ($sub && isset($sub['status'])) {
877
+                                if ('active' == $sub['status']) {
878 878
                                     return true;
879 879
                                 } else {
880 880
                                     return false;
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
      * @return string $woocommerce_product_id or false if none exist
904 904
      *
905 905
      */
906
-    public static function get_course_product_id( $course_id ){
906
+    public static function get_course_product_id($course_id) {
907 907
 
908
-        $product_id =  get_post_meta( $course_id, '_course_woocommerce_product', true );
908
+        $product_id = get_post_meta($course_id, '_course_woocommerce_product', true);
909 909
 
910
-        if( empty( $product_id ) || 'product' != get_post_type( $product_id ) ){
910
+        if (empty($product_id) || 'product' != get_post_type($product_id)) {
911 911
             return false;
912 912
         }
913 913
 
@@ -921,11 +921,11 @@  discard block
 block discarded – undo
921 921
      * @param array $classes
922 922
      * @return array
923 923
      */
924
-    public static function add_woocommerce_body_class( $classes ){
924
+    public static function add_woocommerce_body_class($classes) {
925 925
 
926
-        if( ! in_array( 'woocommerce', $classes ) ){
926
+        if ( ! in_array('woocommerce', $classes)) {
927 927
 
928
-            $classes[] ='woocommerce';
928
+            $classes[] = 'woocommerce';
929 929
 
930 930
         }
931 931
 
Please login to merge, or discard this patch.
includes/class-sensei-course-results.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class Sensei_Course_Results {
16 16
 
17
-    /**
18
-     * @var string
19
-     */
20
-    public  $courses_url_base;
17
+	/**
18
+	 * @var string
19
+	 */
20
+	public  $courses_url_base;
21 21
 
22 22
 	/**
23 23
 	 * Constructor.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		global $wp_query,  $current_user;
99 99
 
100 100
 		if( isset( $wp_query->query_vars['course_results'] ) ) {
101
-            Sensei_Templates::get_template( 'course-results/course-info.php' );
101
+			Sensei_Templates::get_template( 'course-results/course-info.php' );
102 102
 		}
103 103
 
104 104
 	}
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
 
118 118
 		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
119 119
 
120
-        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
120
+		sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
121 121
 
122 122
 	}
123 123
 
124 124
 	/**
125 125
 	 * Load template for displaying course lessons
126
-     *
126
+	 *
127 127
 	 * @since  1.4.0
128 128
 	 * @return void
129 129
 	 */
130 130
 	public function course_lessons() {
131 131
 
132 132
 		global $course;
133
-        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
133
+		_deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
134 134
 
135 135
 	}
136 136
 
@@ -147,62 +147,62 @@  discard block
 block discarded – undo
147 147
 		return $classes;
148 148
 	}
149 149
 
150
-    /**
151
-     * Deprecate the sensei_course_results_content hook
152
-     *
153
-     * @deprecated since 1.9.0
154
-     */
155
-    public static function deprecate_sensei_course_results_content_hook(){
150
+	/**
151
+	 * Deprecate the sensei_course_results_content hook
152
+	 *
153
+	 * @deprecated since 1.9.0
154
+	 */
155
+	public static function deprecate_sensei_course_results_content_hook(){
156 156
 
157
-        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
157
+		sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
158 158
 
159
-    }
159
+	}
160 160
 
161
-    /**
162
-     * Fire the sensei frontend message hook
163
-     *
164
-     * @since 1.9.0
165
-     */
166
-    public static function fire_sensei_message_hook(){
161
+	/**
162
+	 * Fire the sensei frontend message hook
163
+	 *
164
+	 * @since 1.9.0
165
+	 */
166
+	public static function fire_sensei_message_hook(){
167 167
 
168
-        do_action( 'sensei_frontend_messages' );
168
+		do_action( 'sensei_frontend_messages' );
169 169
 
170
-    }
170
+	}
171 171
 
172
-    /**
173
-     * Deprecate the course_results info hook
174
-     *
175
-     * @since 1.9.0
176
-     */
177
-    public static function deprecate_course_result_info_hook(){
172
+	/**
173
+	 * Deprecate the course_results info hook
174
+	 *
175
+	 * @since 1.9.0
176
+	 */
177
+	public static function deprecate_course_result_info_hook(){
178 178
 
179
-        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
179
+		sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
180 180
 
181
-    }
181
+	}
182 182
 
183
-    /**
184
-     * Deprecate the sensei_course_results_top hook
185
-     *
186
-     * @deprecate since 1.9.0
187
-     */
188
-    public static function deprecate_course_results_top_hook(){
183
+	/**
184
+	 * Deprecate the sensei_course_results_top hook
185
+	 *
186
+	 * @deprecate since 1.9.0
187
+	 */
188
+	public static function deprecate_course_results_top_hook(){
189 189
 
190
-        global $course;
191
-        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
190
+		global $course;
191
+		sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
192 192
 
193
-    }
193
+	}
194 194
 
195
-    /**
196
-     * Fire the course image hook
197
-     *
198
-     * @since 1.8.0
199
-     */
200
-    public static function fire_course_image_hook(){
195
+	/**
196
+	 * Fire the course image hook
197
+	 *
198
+	 * @since 1.8.0
199
+	 */
200
+	public static function fire_course_image_hook(){
201 201
 
202
-        global $course;
203
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
202
+		global $course;
203
+		sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
204 204
 
205
-    }
205
+	}
206 206
 
207 207
 } // End Class
208 208
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 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 Results Class
@@ -23,20 +23,20 @@  discard block
 block discarded – undo
23 23
 	 * Constructor.
24 24
 	 * @since  1.4.0
25 25
 	 */
26
-	public function __construct () {
26
+	public function __construct() {
27 27
 
28 28
 		// Setup learner profile URL base
29
-		$this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) );
29
+		$this->courses_url_base = apply_filters('sensei_course_slug', _x('course', 'post type single url slug', 'woothemes-sensei'));
30 30
 
31 31
 		// Setup permalink structure for course results
32
-		add_action( 'init', array( $this, 'setup_permastruct' ) );
33
-		add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 );
32
+		add_action('init', array($this, 'setup_permastruct'));
33
+		add_filter('wp_title', array($this, 'page_title'), 10, 2);
34 34
 
35 35
 		// Load course results
36
-		add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 );
36
+		add_action('sensei_course_results_content_inside_before', array($this, 'deprecate_course_result_info_hook'), 10);
37 37
 
38 38
 		// Add class to body tag
39
-		add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 );
39
+		add_filter('body_class', array($this, 'body_class'), 10, 1);
40 40
 
41 41
 	} // End __construct()
42 42
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @return void
47 47
 	 */
48 48
 	public function setup_permastruct() {
49
-		add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' );
50
-		add_rewrite_tag( '%course_results%', '([^&]+)' );
49
+		add_rewrite_rule('^'.$this->courses_url_base.'/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top');
50
+		add_rewrite_tag('%course_results%', '([^&]+)');
51 51
 	}
52 52
 
53 53
 	/**
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	 * @param  string $sep   Seeparator string
57 57
 	 * @return string        Modified title
58 58
 	 */
59
-	public function page_title( $title, $sep = null ) {
59
+	public function page_title($title, $sep = null) {
60 60
 		global $wp_query;
61
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
62
-			$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' );
63
-			$title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' ';
61
+		if (isset($wp_query->query_vars['course_results'])) {
62
+			$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course');
63
+			$title = __('Course Results: ', 'woothemes-sensei').$course->post_title.' '.$sep.' ';
64 64
 		}
65 65
 		return $title;
66 66
 	}
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
 	 * @param  integer $course_id ID of course
72 72
 	 * @return string             The course results page permalink
73 73
 	 */
74
-	public function get_permalink( $course_id = 0 ) {
74
+	public function get_permalink($course_id = 0) {
75 75
 
76 76
 		$permalink = '';
77 77
 
78
-		if( $course_id > 0 ) {
78
+		if ($course_id > 0) {
79 79
 
80
-			$course = get_post( $course_id );
80
+			$course = get_post($course_id);
81 81
 
82
-			if ( get_option('permalink_structure') ) {
83
-				$permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/';
82
+			if (get_option('permalink_structure')) {
83
+				$permalink = trailingslashit(get_home_url()).$this->courses_url_base.'/'.$course->post_name.'/results/';
84 84
 			} else {
85
-				$permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name;
85
+				$permalink = trailingslashit(get_home_url()).'?course_results='.$course->post_name;
86 86
 			}
87 87
 		}
88 88
 
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	public function content() {
98
-		global $wp_query,  $current_user;
98
+		global $wp_query, $current_user;
99 99
 
100
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
101
-            Sensei_Templates::get_template( 'course-results/course-info.php' );
100
+		if (isset($wp_query->query_vars['course_results'])) {
101
+            Sensei_Templates::get_template('course-results/course-info.php');
102 102
 		}
103 103
 
104 104
 	}
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 
113 113
 		global $course;
114 114
 
115
-		$course_status = Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id());
116
-		echo '<div class="sensei-message ' . $course_status['box_class'] . '">' . $course_status['message'] . '</div>';
115
+		$course_status = Sensei_Utils::sensei_user_course_status_message($course->ID, get_current_user_id());
116
+		echo '<div class="sensei-message '.$course_status['box_class'].'">'.$course_status['message'].'</div>';
117 117
 
118
-		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
118
+		sensei_do_deprecated_action('sensei_course_results_lessons', '1.9.', 'sensei_course_results_content_inside_after', $course);
119 119
 
120
-        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
120
+        sensei_do_deprecated_action('sensei_course_results_bottom', '1.9.', 'sensei_course_results_content_inside_after', $course->ID);
121 121
 
122 122
 	}
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	public function course_lessons() {
131 131
 
132 132
 		global $course;
133
-        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
133
+        _deprecated_function('Sensei_modules course_lessons ', '1.9.0');
134 134
 
135 135
 	}
136 136
 
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
 	 * @param  array $classes Existing classes
140 140
 	 * @return array          Modified classes
141 141
 	 */
142
-	public function body_class( $classes ) {
142
+	public function body_class($classes) {
143 143
 		global $wp_query;
144
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
144
+		if (isset($wp_query->query_vars['course_results'])) {
145 145
 			$classes[] = 'course-results';
146 146
 		}
147 147
 		return $classes;
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @deprecated since 1.9.0
154 154
      */
155
-    public static function deprecate_sensei_course_results_content_hook(){
155
+    public static function deprecate_sensei_course_results_content_hook() {
156 156
 
157
-        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
157
+        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0', 'sensei_course_results_content_before');
158 158
 
159 159
     }
160 160
 
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @since 1.9.0
165 165
      */
166
-    public static function fire_sensei_message_hook(){
166
+    public static function fire_sensei_message_hook() {
167 167
 
168
-        do_action( 'sensei_frontend_messages' );
168
+        do_action('sensei_frontend_messages');
169 169
 
170 170
     }
171 171
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
      *
175 175
      * @since 1.9.0
176 176
      */
177
-    public static function deprecate_course_result_info_hook(){
177
+    public static function deprecate_course_result_info_hook() {
178 178
 
179
-        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
179
+        sensei_do_deprecated_action('sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before');
180 180
 
181 181
     }
182 182
 
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
      *
186 186
      * @deprecate since 1.9.0
187 187
      */
188
-    public static function deprecate_course_results_top_hook(){
188
+    public static function deprecate_course_results_top_hook() {
189 189
 
190 190
         global $course;
191
-        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
191
+        sensei_do_deprecated_action('sensei_course_results_top', '1.9.0', 'sensei_course_results_content_inside_before', $course->ID);
192 192
 
193 193
     }
194 194
 
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
      *
198 198
      * @since 1.8.0
199 199
      */
200
-    public static function fire_course_image_hook(){
200
+    public static function fire_course_image_hook() {
201 201
 
202 202
         global $course;
203
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
203
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID()));
204 204
 
205 205
     }
206 206
 
@@ -211,4 +211,4 @@  discard block
 block discarded – undo
211 211
  * for backward compatibility
212 212
  * @since 1.9.0
213 213
  */
214
-class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{}
214
+class WooThemes_Sensei_Course_Results extends Sensei_Course_Results {}
Please login to merge, or discard this patch.