Completed
Push — master ( b89b53...97debb )
by Dwain
04:52
created
templates/single-quiz/question_type-boolean.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * The Template for displaying True/False ( Boolean ) Question type.
5
- *
6
- * @author 		Automattic
7
- * @package 	Sensei
8
- * @category    Templates
9
- * @version     1.9.0
10
- */
4
+	 * The Template for displaying True/False ( Boolean ) Question type.
5
+	 *
6
+	 * @author 		Automattic
7
+	 * @package 	Sensei
8
+	 * @category    Templates
9
+	 * @version     1.9.0
10
+	 */
11 11
 ?>
12 12
 
13 13
 <?php
14 14
 
15
-    /**
16
-     * Get the question data with the current quiz id
17
-     * All data is loaded in this array to keep the template clean.
18
-     */
19
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
20
-    $boolean_options = array( 'true', 'false' );
15
+	/**
16
+	 * Get the question data with the current quiz id
17
+	 * All data is loaded in this array to keep the template clean.
18
+	 */
19
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
20
+	$boolean_options = array( 'true', 'false' );
21 21
 
22 22
 ?>
23 23
 
@@ -25,44 +25,44 @@  discard block
 block discarded – undo
25 25
 
26 26
     <?php
27 27
 
28
-    // setup the options the right answer set by the admin/teacher
29
-    // will be compared to.
30
-    $boolean_options = array( true, false );
28
+	// setup the options the right answer set by the admin/teacher
29
+	// will be compared to.
30
+	$boolean_options = array( true, false );
31 31
 
32
-    //loop through the 2 boolean options and compare them with
33
-    // the selected right answer
34
-    foreach ( $boolean_options as $option ){
32
+	//loop through the 2 boolean options and compare them with
33
+	// the selected right answer
34
+	foreach ( $boolean_options as $option ){
35 35
 
36
-        $answer_class = '';
36
+		$answer_class = '';
37 37
 
38
-        // Add classes to indicate correctness, only if there is a grade
39
-        if( isset( $question_data[ 'user_correct' ] ) && 0 < $question_data['question_grade'] ) {
38
+		// Add classes to indicate correctness, only if there is a grade
39
+		if( isset( $question_data[ 'user_correct' ] ) && 0 < $question_data['question_grade'] ) {
40 40
 
41
-            if( $question_right_answer == $question_data[ 'question_right_answer' ] ) {
41
+			if( $question_right_answer == $question_data[ 'question_right_answer' ] ) {
42 42
 
43
-                if( $question_data[ 'user_correct' ] ) {
43
+				if( $question_data[ 'user_correct' ] ) {
44 44
 
45
-                    $answer_class = 'user_right';
45
+					$answer_class = 'user_right';
46 46
 
47
-                }
47
+				}
48 48
 
49
-                $answer_class .= ' right_answer';
49
+				$answer_class .= ' right_answer';
50 50
 
51
-            } else {
51
+			} else {
52 52
 
53
-                if( ! $question_data[ 'user_correct' ] ) {
53
+				if( ! $question_data[ 'user_correct' ] ) {
54 54
 
55
-                    $answer_class = 'user_wrong';
55
+					$answer_class = 'user_wrong';
56 56
 
57
-                }
57
+				}
58 58
 
59
-            } // end if right answer == current booloean options
59
+			} // end if right answer == current booloean options
60 60
 
61
-        }// end if $user_correct .. $question_grade
61
+		}// end if $user_correct .. $question_grade
62 62
 
63
-	    $option_value = $option ? 'true' : 'false';
63
+		$option_value = $option ? 'true' : 'false';
64 64
 
65
-    ?>
65
+	?>
66 66
 
67 67
     <li class="<?php esc_attr_e( $answer_class ); ?>">
68 68
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
         <label for="<?php echo esc_attr( 'question_' . $question_data[ 'ID' ]  ) . '-option-' . $option_value; ?>">
77 77
             <?php
78 78
 
79
-            if( 'true' == $option ){
79
+			if( 'true' == $option ){
80 80
 
81
-                _e( 'True', 'woothemes-sensei' );
81
+				_e( 'True', 'woothemes-sensei' );
82 82
 
83
-            }else{
83
+			}else{
84 84
 
85
-                _e( 'False', 'woothemes-sensei' );
85
+				_e( 'False', 'woothemes-sensei' );
86 86
 
87
-            }
87
+			}
88 88
 
89
-            ?>
89
+			?>
90 90
 
91 91
 
92 92
         </label>
Please login to merge, or discard this patch.
woothemes-sensei.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -30,80 +30,80 @@
 block discarded – undo
30 30
 
31 31
 	if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
32 32
 
33
-    require_once( 'includes/class-sensei-autoloader.php' );
34
-    require_once( 'includes/lib/woo-functions.php' );
35
-    require_once( 'includes/sensei-functions.php' );
33
+	require_once( 'includes/class-sensei-autoloader.php' );
34
+	require_once( 'includes/lib/woo-functions.php' );
35
+	require_once( 'includes/sensei-functions.php' );
36 36
 
37
-    if ( ! is_admin() ) {
38
-        require_once( 'includes/template-functions.php' );
39
-    }
37
+	if ( ! is_admin() ) {
38
+		require_once( 'includes/template-functions.php' );
39
+	}
40 40
 
41
-    /**
42
-     * Returns the global Sensei Instance.
43
-     *
44
-     * @since 1.8.0
45
-     */
46
-    function Sensei(){
41
+	/**
42
+	 * Returns the global Sensei Instance.
43
+	 *
44
+	 * @since 1.8.0
45
+	 */
46
+	function Sensei(){
47 47
 
48
-        return Sensei_Main::instance();
48
+		return Sensei_Main::instance();
49 49
 
50
-    }
50
+	}
51 51
 
52 52
 	// set the sensei version number
53 53
 	Sensei()->version = '1.9.1';
54 54
 
55
-    //backwards compatibility
56
-    global $woothemes_sensei;
57
-    $woothemes_sensei = Sensei();
58
-
59
-    /**
60
-    * Hook in WooCommerce functionality
61
-    */
62
-    if( Sensei_WC::is_woocommerce_active() ){
63
-        add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) );
64
-    }
65
-
66
-    /**
67
-     * Load all Template hooks
68
-    */
69
-    if(! is_admin() ){
70
-
71
-        require_once( 'includes/hooks/template.php' );
72
-
73
-    }
74
-
75
-    /**
76
-     * Plugin updates
77
-     * @since  1.0.1
78
-     */
79
-    woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 );
80
-
81
-    /**
82
-     * Sensei Activation Hook registration
83
-     * @since 1.8.0
84
-     */
85
-    register_activation_hook( __FILE__, 'activate_sensei' );
86
-
87
-    /**
88
-     * Activate_sensei
89
-     *
90
-     * All the activation checks needed to ensure Sensei is ready for use
91
-     * @since 1.8.0
92
-     */
93
-    function activate_sensei () {
94
-
95
-        // create the teacher role on activation and ensure that it has all the needed capabilities
96
-        Sensei()->teacher->create_role();
97
-
98
-        //Setup all the role capabilities needed
99
-        Sensei()->updates->add_sensei_caps();
100
-        Sensei()->updates->add_editor_caps();
101
-        Sensei()->updates->assign_role_caps();
102
-
103
-        //Flush rules
104
-        add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 );
105
-
106
-        //Load the Welcome Screen
107
-        add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 );
108
-
109
-    }// end activate_sensei
55
+	//backwards compatibility
56
+	global $woothemes_sensei;
57
+	$woothemes_sensei = Sensei();
58
+
59
+	/**
60
+	 * Hook in WooCommerce functionality
61
+	 */
62
+	if( Sensei_WC::is_woocommerce_active() ){
63
+		add_action('init', array( 'Sensei_WC', 'load_woocommerce_integration_hooks' ) );
64
+	}
65
+
66
+	/**
67
+	 * Load all Template hooks
68
+	 */
69
+	if(! is_admin() ){
70
+
71
+		require_once( 'includes/hooks/template.php' );
72
+
73
+	}
74
+
75
+	/**
76
+	 * Plugin updates
77
+	 * @since  1.0.1
78
+	 */
79
+	woothemes_queue_update( plugin_basename( __FILE__ ), 'bad2a02a063555b7e2bee59924690763', 152116 );
80
+
81
+	/**
82
+	 * Sensei Activation Hook registration
83
+	 * @since 1.8.0
84
+	 */
85
+	register_activation_hook( __FILE__, 'activate_sensei' );
86
+
87
+	/**
88
+	 * Activate_sensei
89
+	 *
90
+	 * All the activation checks needed to ensure Sensei is ready for use
91
+	 * @since 1.8.0
92
+	 */
93
+	function activate_sensei () {
94
+
95
+		// create the teacher role on activation and ensure that it has all the needed capabilities
96
+		Sensei()->teacher->create_role();
97
+
98
+		//Setup all the role capabilities needed
99
+		Sensei()->updates->add_sensei_caps();
100
+		Sensei()->updates->add_editor_caps();
101
+		Sensei()->updates->assign_role_caps();
102
+
103
+		//Flush rules
104
+		add_action( 'activated_plugin' , array( 'Sensei_Main','activation_flush_rules' ), 10 );
105
+
106
+		//Load the Welcome Screen
107
+		add_action( 'activated_plugin' , array( 'Sensei_Welcome','redirect' ), 20 );
108
+
109
+	}// end activate_sensei
Please login to merge, or discard this patch.
includes/class-sensei-frontend.php 1 patch
Indentation   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		// Only show course & lesson excerpts in search results
70 70
 		add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) );
71 71
 
72
-        //Use WooCommerce filter to show admin bar to Teachers.
73
-        add_action( 'init', array( $this, 'sensei_show_admin_bar') );
72
+		//Use WooCommerce filter to show admin bar to Teachers.
73
+		add_action( 'init', array( $this, 'sensei_show_admin_bar') );
74 74
 
75
-        // Remove course from active courses if an order is cancelled or refunded
75
+		// Remove course from active courses if an order is cancelled or refunded
76 76
 		add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
77 77
 		add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
78 78
 		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 			wp_enqueue_script( Sensei()->token . '-user-dashboard' );
134 134
 
135 135
 
136
-            // Course Archive javascript
137
-            if( is_post_type_archive( 'course' ) ){
136
+			// Course Archive javascript
137
+			if( is_post_type_archive( 'course' ) ){
138 138
 
139
-                wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true );
140
-                wp_enqueue_script( 'sensei-course-archive-js' );
139
+				wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true );
140
+				wp_enqueue_script( 'sensei-course-archive-js' );
141 141
 
142
-            }
142
+			}
143 143
 
144 144
 
145 145
 			// Allow additional scripts to be loaded
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	/**
181 181
 	 * sensei_get_template_part function.
182 182
 	 *
183
-     * @deprecated sine 1.9.0
183
+	 * @deprecated sine 1.9.0
184 184
 	 * @access public
185 185
 	 * @param mixed $slug
186 186
 	 * @param string $name (default: '')
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	function sensei_get_template_part( $slug, $name = '' ) {
190 190
 
191
-        _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' );
192
-        Sensei_Templates::get_part( $slug, $name );
191
+		_deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' );
192
+		Sensei_Templates::get_part( $slug, $name );
193 193
 
194 194
 	} // End sensei_get_template_part()
195 195
 
196 196
 	/**
197 197
 	 * sensei_get_template function.
198 198
 	 *
199
-     * @deprecated since 1.9.0
199
+	 * @deprecated since 1.9.0
200 200
 	 * @access public
201 201
 	 * @param mixed $template_name
202 202
 	 * @param array $args (default: array())
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
208 208
 
209
-        _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' );
210
-        Sensei_Templates::get_template($template_name, $args, $template_path, $default_path  );
209
+		_deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' );
210
+		Sensei_Templates::get_template($template_name, $args, $template_path, $default_path  );
211 211
 
212 212
 	} // End sensei_get_template()
213 213
 
@@ -223,33 +223,33 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) {
225 225
 
226
-        _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' );
227
-        Sensei_Templates::locate_template( $template_name, $template_path, $default_path );
226
+		_deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' );
227
+		Sensei_Templates::locate_template( $template_name, $template_path, $default_path );
228 228
 
229 229
 	} // End sensei_locate_template()
230 230
 
231 231
 
232 232
 	/**
233 233
 	 * sensei_output_content_wrapper function.
234
-     *
234
+	 *
235 235
 	 * @access public
236 236
 	 * @return void
237 237
 	 */
238 238
 	function sensei_output_content_wrapper() {
239 239
 
240
-	    // backwards compatibility check for old location under the wrappers directory of the active theme
241
-        $backwards_compatible_wrapper_location =   array(
242
-            Sensei()->template_url . 'wrappers/wrapper-start.php',
243
-            'wrappers/wrapper-start.php'
244
-        );
240
+		// backwards compatibility check for old location under the wrappers directory of the active theme
241
+		$backwards_compatible_wrapper_location =   array(
242
+			Sensei()->template_url . 'wrappers/wrapper-start.php',
243
+			'wrappers/wrapper-start.php'
244
+		);
245 245
 
246
-        $template = locate_template( $backwards_compatible_wrapper_location );
247
-        if( !empty( $template ) ){
246
+		$template = locate_template( $backwards_compatible_wrapper_location );
247
+		if( !empty( $template ) ){
248 248
 
249
-            Sensei_Templates::get_template( 'wrappers/wrapper-start.php' );
250
-            return;
249
+			Sensei_Templates::get_template( 'wrappers/wrapper-start.php' );
250
+			return;
251 251
 
252
-        }
252
+		}
253 253
 
254 254
 		Sensei_Templates::get_template( 'globals/wrapper-start.php' );
255 255
 
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
 
259 259
 	/**
260 260
 	 * sensei_output_content_wrapper_end function.
261
-     *
261
+	 *
262 262
 	 * @access public
263 263
 	 * @return void
264 264
 	 */
265 265
 	function sensei_output_content_wrapper_end() {
266 266
 
267
-	    // backwards compatibility check for old location under the wrappers directory of the active theme
268
-        $backwards_compatible_wrapper_location =   array(
269
-            Sensei()->template_url . 'wrappers/wrapper-end.php',
270
-            'wrappers/wrapper-end.php'
271
-        );
267
+		// backwards compatibility check for old location under the wrappers directory of the active theme
268
+		$backwards_compatible_wrapper_location =   array(
269
+			Sensei()->template_url . 'wrappers/wrapper-end.php',
270
+			'wrappers/wrapper-end.php'
271
+		);
272 272
 
273
-        $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location );
274
-        if( !empty( $backwards_compatible_template ) ){
273
+		$backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location );
274
+		if( !empty( $backwards_compatible_template ) ){
275 275
 
276
-            Sensei_Templates::get_template( 'wrappers/wrapper-end.php' );
277
-            return;
276
+			Sensei_Templates::get_template( 'wrappers/wrapper-end.php' );
277
+			return;
278 278
 
279
-        }
279
+		}
280 280
 
281 281
 
282 282
 		Sensei_Templates::get_template( 'globals/wrapper-end.php' );
@@ -292,55 +292,55 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public static function load_content_pagination() {
294 294
 
295
-        if( is_singular('course') ) {
295
+		if( is_singular('course') ) {
296 296
 
297
-            // backwards compatibility check for old location under the wrappers directory of the active theme
298
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) );
299
-            if( !empty( $template ) ){
297
+			// backwards compatibility check for old location under the wrappers directory of the active theme
298
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) );
299
+			if( !empty( $template ) ){
300 300
 
301
-                Sensei_Templates::get_template( 'wrappers/pagination-posts.php' );
302
-                return;
301
+				Sensei_Templates::get_template( 'wrappers/pagination-posts.php' );
302
+				return;
303 303
 
304
-            }
304
+			}
305 305
 
306 306
 			Sensei_Templates::get_template( 'globals/pagination-posts.php' );
307 307
 
308 308
 		} elseif( is_singular('lesson') ) {
309 309
 
310
-		    // backwards compatibility check for old location under the wrappers directory of the active theme
311
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) );
312
-            if( !empty( $template ) ){
310
+			// backwards compatibility check for old location under the wrappers directory of the active theme
311
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) );
312
+			if( !empty( $template ) ){
313 313
 
314
-                Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' );
315
-                return;
314
+				Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' );
315
+				return;
316 316
 
317
-            }
317
+			}
318 318
 
319 319
 			Sensei_Templates::get_template( 'globals/pagination-lesson.php' );
320 320
 
321 321
 		} elseif( is_singular('quiz') ) {
322 322
 
323
-		    // backwards compatibility check for old location under the wrappers directory of the active theme
324
-		    $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) );
325
-            if( !empty( $template ) ){
323
+			// backwards compatibility check for old location under the wrappers directory of the active theme
324
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) );
325
+			if( !empty( $template ) ){
326 326
 
327
-                Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' );
328
-                return;
327
+				Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' );
328
+				return;
329 329
 
330
-            }
330
+			}
331 331
 
332 332
 			Sensei_Templates::get_template( 'globals/pagination-quiz.php' );
333 333
 
334 334
 		} else {
335 335
 
336
-            // backwards compatibility check for old location under the wrappers directory of the active theme
337
-            $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) );
338
-            if( !empty( $template ) ){
336
+			// backwards compatibility check for old location under the wrappers directory of the active theme
337
+			$template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) );
338
+			if( !empty( $template ) ){
339 339
 
340
-                Sensei_Templates::get_template( 'wrappers/pagination.php' );
341
-                return;
340
+				Sensei_Templates::get_template( 'wrappers/pagination.php' );
341
+				return;
342 342
 
343
-            }
343
+			}
344 344
 
345 345
 			Sensei_Templates::get_template( 'globals/pagination.php' );
346 346
 
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 
398 398
 				case '#senseimymessages':
399 399
 					$item->url = $my_messages_url;
400
-                    // if no archive link exist for sensei_message
401
-                    // set it back to the place holder
402
-                    if( ! $item->url ){
400
+					// if no archive link exist for sensei_message
401
+					// set it back to the place holder
402
+					if( ! $item->url ){
403 403
 
404
-                        $item->url = '#senseimymessages';
404
+						$item->url = '#senseimymessages';
405 405
 
406
-                    }
406
+					}
407 407
 					break;
408 408
 
409 409
 				case '#senseilearnerprofile':
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 
470 470
 			// Remove the My Messages link for logged out users or if Private Messages are disabled
471 471
 			if( ! get_post_type_archive_link( 'sensei_message' )
472
-                && '#senseimymessages' == $item->url ) {
472
+				&& '#senseimymessages' == $item->url ) {
473 473
 
474 474
 				if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) {
475 475
 
@@ -492,42 +492,42 @@  discard block
 block discarded – undo
492 492
 
493 493
 	// add category nicenames in body and post class
494 494
 	function sensei_search_results_classes($classes) {
495
-	    global $post;
496
-	    // Handle Search Classes for Courses, Lessons, and WC Products
497
-	    if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) {
498
-	    	$classes[] = 'post';
495
+		global $post;
496
+		// Handle Search Classes for Courses, Lessons, and WC Products
497
+		if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) {
498
+			$classes[] = 'post';
499 499
 		} // End If Statement
500
-	    return $classes;
500
+		return $classes;
501 501
 	} // End sensei_search_results_classes()
502 502
 
503
-    /**
504
-     * sensei_single_title output for single page title
505
-     * @since  1.1.0
506
-     * @return void
507
-     * @deprecated
508
-     */
509
-    function the_single_title() {
503
+	/**
504
+	 * sensei_single_title output for single page title
505
+	 * @since  1.1.0
506
+	 * @return void
507
+	 * @deprecated
508
+	 */
509
+	function the_single_title() {
510 510
 
511
-        _deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0');
511
+		_deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0');
512 512
 
513
-    } // End sensei_single_title()
513
+	} // End sensei_single_title()
514 514
 
515 515
 	/**
516 516
 	 * sensei_course_image output for course image Please use Sensei()->course->course_image instead.
517
-     *
518
-     * @deprecated since 1.9.0
519
-     * @param $course_id
520
-     * @param string $width
521
-     * @param string $height
522
-     * @param bool|false $return
523
-     * @return string|void
517
+	 *
518
+	 * @deprecated since 1.9.0
519
+	 * @param $course_id
520
+	 * @param string $width
521
+	 * @param string $height
522
+	 * @param bool|false $return
523
+	 * @return string|void
524 524
 	 */
525 525
 	function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) {
526 526
 
527
-    	if ( ! $return ) {
527
+		if ( ! $return ) {
528 528
 
529 529
 			echo Sensei()->course->course_image( $course_id, $width, $height );
530
-            return '';
530
+			return '';
531 531
 
532 532
 		} // End If Statement
533 533
 
@@ -538,31 +538,31 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * sensei_lesson_image output for lesson image
540 540
 	 * @since  1.2.0
541
-     * @deprecated since 1.9.0
542
-     * @param $lesson_id
543
-     * @param string $width
544
-     * @param string $height
545
-     * @param bool|false $return
546
-     * @param bool|false $widget
547
-     * @return string
541
+	 * @deprecated since 1.9.0
542
+	 * @param $lesson_id
543
+	 * @param string $width
544
+	 * @param string $height
545
+	 * @param bool|false $return
546
+	 * @param bool|false $widget
547
+	 * @return string
548 548
 	 */
549 549
 	function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) {
550 550
 
551
-        if( ! $return ){
551
+		if( ! $return ){
552 552
 
553
-            echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
554
-            return '';
555
-        }
553
+			echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
554
+			return '';
555
+		}
556 556
 
557
-        return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
557
+		return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget );
558 558
 
559 559
 	} // End sensei_lesson_image()
560 560
 
561
-    /**
562
-     * @since 1.0.0
563
-     * @param WP_Query $query
564
-     */
565
-    function sensei_course_archive_pagination( $query ) {
561
+	/**
562
+	 * @since 1.0.0
563
+	 * @param WP_Query $query
564
+	 */
565
+	function sensei_course_archive_pagination( $query ) {
566 566
 
567 567
 		if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) {
568 568
 
@@ -585,50 +585,50 @@  discard block
 block discarded – undo
585 585
 	 *
586 586
 	 * @access public
587 587
 	 * @since  1.2.0
588
-     * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header
588
+	 * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header
589 589
 	 * @return void
590 590
 	 */
591 591
 	function sensei_course_archive_header(  ) {
592 592
 
593
-        trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header ');
594
-        WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' );
593
+		trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header ');
594
+		WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' );
595 595
 
596 596
 	} // sensei_course_archive_header()
597 597
 
598 598
 	/**
599 599
 	 * sensei_lesson_archive_header function.
600 600
 	 *
601
-     * @deprecated since 1.9.0
601
+	 * @deprecated since 1.9.0
602 602
 	 * @access public
603 603
 	 * @since  1.2.1
604 604
 	 * @return void
605 605
 	 */
606 606
 	public function sensei_lesson_archive_header( ) {
607
-        _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' );
608
-        Sensei()->lesson->the_archive_header();
607
+		_deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' );
608
+		Sensei()->lesson->the_archive_header();
609 609
 	} // sensei_course_archive_header()
610 610
 
611
-    /**
612
-     * @deprecated since 1.9.0
613
-     */
611
+	/**
612
+	 * @deprecated since 1.9.0
613
+	 */
614 614
 	public function sensei_message_archive_header( ){
615
-        _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
616
-        Sensei_Messages::the_archive_header();
615
+		_deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
616
+		Sensei_Messages::the_archive_header();
617 617
 	} // sensei_message_archive_header()
618 618
 
619 619
 	/**
620 620
 	 * sensei_course_archive_course_title output for course archive page individual course title
621 621
 	 * @since  1.2.0
622
-     * @param WP_Post $post_item
622
+	 * @param WP_Post $post_item
623 623
 	 * @return void
624 624
 	 */
625 625
 	function sensei_course_archive_course_title( $post_item ) {
626 626
 		if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) {
627 627
 			$post_id = absint( $post_item->ID );
628
-    		$post_title = $post_item->post_title;
628
+			$post_title = $post_item->post_title;
629 629
 		} else {
630 630
 			$post_id = get_the_ID();
631
-    		$post_title = get_the_title();
631
+			$post_title = get_the_title();
632 632
 		} // End If Statement
633 633
 		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
634 634
 	} // End sensei_course_archive_course_title()
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 */
641 641
 	public function sensei_lesson_archive_lesson_title() {
642 642
 		$post_id = get_the_ID();
643
-    	$post_title = get_the_title();
643
+		$post_title = get_the_title();
644 644
 		?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php
645 645
 	} // End sensei_lesson_archive_lesson_title()
646 646
 
@@ -657,9 +657,9 @@  discard block
 block discarded – undo
657 657
 
658 658
 		if( empty( $id )  ){
659 659
 
660
-            $id = get_the_ID();
660
+			$id = get_the_ID();
661 661
 
662
-        }
662
+		}
663 663
 
664 664
 		$sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' );
665 665
 		$separator = apply_filters( 'sensei_breadcrumb_separator', '&gt;' );
@@ -672,31 +672,31 @@  discard block
 block discarded – undo
672 672
 				return;
673 673
 			}
674 674
 			$html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>';
675
-    	} // End If Statement
676
-    	// Quiz
675
+		} // End If Statement
676
+		// Quiz
677 677
 		if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) {
678 678
 			$lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) );
679 679
 			if( ! $lesson_id ) {
680 680
 				return;
681 681
 			}
682 682
 			 $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' .  __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>';
683
-    	} // End If Statement
683
+		} // End If Statement
684 684
 
685
-    	// Allow other plugins to filter html
686
-    	$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
687
-    	$html .= '</section>';
685
+		// Allow other plugins to filter html
686
+		$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
687
+		$html .= '</section>';
688 688
 
689
-    	echo $html;
689
+		echo $html;
690 690
 	} // End sensei_breadcrumb()
691 691
 
692 692
 
693
-    /**
694
-     * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead
695
-     */
693
+	/**
694
+	 * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead
695
+	 */
696 696
 	public function sensei_lesson_course_signup_link( ) {
697 697
 
698
-        _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' );
699
-        WooThemes_Sensei_Lesson::course_signup_link();
698
+		_deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' );
699
+		WooThemes_Sensei_Lesson::course_signup_link();
700 700
 	}
701 701
 
702 702
 	public function lesson_tags_display( $lesson_id = 0 ) {
@@ -715,27 +715,27 @@  discard block
 block discarded – undo
715 715
 					?><section class="lesson-tags">
716 716
 		    			<?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?>
717 717
 		    		</section><?php
718
-		    	}
719
-	    	}
718
+				}
719
+			}
720 720
 		}
721 721
 	}
722 722
 
723
-    /**
724
-     * @param WP_Query $query
725
-     */
723
+	/**
724
+	 * @param WP_Query $query
725
+	 */
726 726
 	public function lesson_tag_archive_filter( $query ) {
727
-    	if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
728
-    		// Limit to lessons only
729
-    		$query->set( 'post_type', 'lesson' );
727
+		if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
728
+			// Limit to lessons only
729
+			$query->set( 'post_type', 'lesson' );
730 730
 
731
-    		// Set order of lessons
732
-    		$query->set( 'orderby', 'menu_order' );
733
-    		$query->set( 'order', 'ASC' );
731
+			// Set order of lessons
732
+			$query->set( 'orderby', 'menu_order' );
733
+			$query->set( 'order', 'ASC' );
734 734
 
735
-    	}
736
-    }
735
+		}
736
+	}
737 737
 
738
-    public function lesson_tag_archive_header( $title ) {
738
+	public function lesson_tag_archive_header( $title ) {
739 739
 		if( is_tax( 'lesson-tag' ) ) {
740 740
 			$title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) );
741 741
 		}
@@ -757,13 +757,13 @@  discard block
 block discarded – undo
757 757
 			$sanitized_submit = esc_html( $_POST['quiz_action'] );
758 758
 
759 759
 			switch ($sanitized_submit) {
760
-                case 'lesson-complete':
760
+				case 'lesson-complete':
761 761
 
762 762
 					Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true );
763 763
 
764 764
 					break;
765 765
 
766
-                case 'lesson-reset':
766
+				case 'lesson-reset':
767 767
 
768 768
 					Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID );
769 769
 
@@ -875,13 +875,13 @@  discard block
 block discarded – undo
875 875
 		if ( 0 < intval( $post_id ) ) {
876 876
 			$lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true );
877 877
 			if ( 'http' == substr( $lesson_video_embed, 0, 4) ) {
878
-        		// V2 - make width and height a setting for video embed
879
-        		$lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ );
880
-        	} // End If Statement
881
-        	if ( '' != $lesson_video_embed ) {
882
-        	?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883
-        	} // End If Statement
884
-        } // End If Statement
878
+				// V2 - make width and height a setting for video embed
879
+				$lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ );
880
+			} // End If Statement
881
+			if ( '' != $lesson_video_embed ) {
882
+			?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883
+			} // End If Statement
884
+		} // End If Statement
885 885
 	} // End sensei_lesson_video()
886 886
 
887 887
 	public function sensei_complete_lesson_button() {
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 		$pass_required = true;
895 895
 		if( $quiz_id ) {
896 896
 			// Get quiz pass setting
897
-	    	$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
898
-	    }
897
+			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
898
+		}
899 899
 		if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) {
900 900
 			?>
901 901
 			<form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
@@ -948,12 +948,12 @@  discard block
 block discarded – undo
948 948
 		} // End If Statement
949 949
 	} // End sensei_reset_lesson_button()
950 950
 
951
-    /**
952
-     * @deprecated since 1.9.0
953
-     */
954
-    public function sensei_lesson_quiz_meta( ) {
951
+	/**
952
+	 * @deprecated since 1.9.0
953
+	 */
954
+	public function sensei_lesson_quiz_meta( ) {
955 955
 
956
-        Sensei_Lesson::footer_quiz_call_to_action();
956
+		Sensei_Lesson::footer_quiz_call_to_action();
957 957
 
958 958
 	} // End sensei_lesson_quiz_meta()
959 959
 
@@ -979,38 +979,38 @@  discard block
 block discarded – undo
979 979
         	</p>
980 980
         	<p class="course-excerpt"><?php the_excerpt(); ?></p>
981 981
         	<?php if ( 0 < $free_lesson_count ) {
982
-                $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
982
+				$free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?>
983 983
                 <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p>
984 984
             <?php } ?>
985 985
 		</section><?php
986 986
 	} // End sensei_course_archive_meta()
987 987
 
988
-    /**
989
-     * @deprecated since 1.9.0
990
-     */
988
+	/**
989
+	 * @deprecated since 1.9.0
990
+	 */
991 991
 	public function sensei_single_main_content() {
992
-	    _deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0');
992
+		_deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0');
993 993
 	} // End sensei_single_main_content()
994 994
 
995
-    /**
996
-    * @deprecated since 1.9.0
997
-    */
995
+	/**
996
+	 * @deprecated since 1.9.0
997
+	 */
998 998
 	public function sensei_lesson_archive_main_content() {
999
-        _deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly');
999
+		_deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly');
1000 1000
 	} // End sensei_lesson_archive_main_content()
1001 1001
 
1002
-    /**
1003
-    * @deprecated since 1.9.0
1004
-    */
1002
+	/**
1003
+	 * @deprecated since 1.9.0
1004
+	 */
1005 1005
 	public function sensei_message_archive_main_content() {
1006 1006
 		_deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' );
1007 1007
 	} // End sensei_lesson_archive_main_content()
1008 1008
 
1009
-    /**
1010
-    * @deprecated since 1.9.0
1011
-    */
1009
+	/**
1010
+	 * @deprecated since 1.9.0
1011
+	 */
1012 1012
 	public function sensei_no_permissions_main_content() {
1013
-        _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' );
1013
+		_deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' );
1014 1014
 	} // End sensei_no_permissions_main_content()
1015 1015
 
1016 1016
 	public function sensei_course_category_main_content() {
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 				<div class="col-1">
1059 1059
 					<?php
1060 1060
 					// output the actual form markup
1061
-                    Sensei_Templates::get_template( 'user/login-form.php');
1061
+					Sensei_Templates::get_template( 'user/login-form.php');
1062 1062
 					?>
1063 1063
 				</div>
1064 1064
 
@@ -1139,12 +1139,12 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		//if this is a paid course
1141 1141
 		if ( Sensei_WC::is_woocommerce_active() ) {
1142
-    	    $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
1143
-    	    if ( 0 < $wc_post_id ) {
1144
-    	    	$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
1145
-    	    } // End If Statement
1146
-    	}
1147
-    	return $preview_text;
1142
+			$wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true );
1143
+			if ( 0 < $wc_post_id ) {
1144
+				$preview_text = __( ' (Free Preview)', 'woothemes-sensei' );
1145
+			} // End If Statement
1146
+		}
1147
+		return $preview_text;
1148 1148
 	}
1149 1149
 
1150 1150
 	public function sensei_lesson_preview_title( $title = '', $id = 0 ) {
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 		$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
1177 1177
 		// Handle user starting the course
1178 1178
 		if ( isset( $_POST['course_start'] )
1179
-		    && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' )
1180
-		    && !$is_user_taking_course ) {
1179
+			&& wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' )
1180
+			&& !$is_user_taking_course ) {
1181 1181
 
1182 1182
 			// Start the course
1183 1183
 			$activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID );
@@ -1196,35 +1196,35 @@  discard block
 block discarded – undo
1196 1196
 		} // End If Statement
1197 1197
 	} // End sensei_course_start()
1198 1198
 
1199
-    /**
1200
-     * @deprecated since 1.9.0
1201
-     */
1199
+	/**
1200
+	 * @deprecated since 1.9.0
1201
+	 */
1202 1202
 	public function sensei_course_meta() {
1203
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' );
1204
-        Sensei()->course->the_course_meta( get_post() );
1203
+		_deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' );
1204
+		Sensei()->course->the_course_meta( get_post() );
1205 1205
 	} // End sensei_course_meta()
1206 1206
 
1207
-    /**
1208
-     * @deprecated since 1.9.0
1209
-     */
1207
+	/**
1208
+	 * @deprecated since 1.9.0
1209
+	 */
1210 1210
 	public function sensei_course_meta_video() {
1211
-        _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' );
1212
-        Sensei_Course::the_course_video();
1211
+		_deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' );
1212
+		Sensei_Course::the_course_video();
1213 1213
 	} // End sensei_course_meta_video()
1214 1214
 
1215
-    /**
1216
-     * This function shows the WooCommerce cart notice if the user has
1217
-     * added the current course to cart. It does not show if the user is already taking
1218
-     * the course.
1219
-     *
1220
-     * @since 1.0.2
1221
-     * @return void;
1222
-     */
1223
-    public function sensei_woocommerce_in_cart_message() {
1215
+	/**
1216
+	 * This function shows the WooCommerce cart notice if the user has
1217
+	 * added the current course to cart. It does not show if the user is already taking
1218
+	 * the course.
1219
+	 *
1220
+	 * @since 1.0.2
1221
+	 * @return void;
1222
+	 */
1223
+	public function sensei_woocommerce_in_cart_message() {
1224 1224
 		global $post, $woocommerce;
1225 1225
 
1226 1226
 		$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
1227
-        $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() );
1227
+		$user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() );
1228 1228
 		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
1229 1229
 
1230 1230
 			if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) {
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 				$item_id = $item['product_id'];
1273 1273
 			} 
1274 1274
 
1275
-            if ( $item_id > 0 ) {
1275
+			if ( $item_id > 0 ) {
1276 1276
 
1277 1277
 				$user_id = get_post_meta( $order_id, '_customer_user', true );
1278 1278
 
@@ -1352,15 +1352,15 @@  discard block
 block discarded – undo
1352 1352
 
1353 1353
 					$items = $order->get_items();
1354 1354
 					foreach( $items as $item ) {
1355
-                                            if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356
-                                                $item_id = $item['variation_id'];
1357
-                                                $product_type = 'variation';
1358
-                                            } else {
1359
-                                                $item_id = $item['product_id'];
1360
-                                            }
1355
+											if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356
+												$item_id = $item['variation_id'];
1357
+												$product_type = 'variation';
1358
+											} else {
1359
+												$item_id = $item['product_id'];
1360
+											}
1361 1361
 
1362
-                                            $product_ids[] = $item_id;
1363
-                                            }
1362
+											$product_ids[] = $item_id;
1363
+											}
1364 1364
 
1365 1365
 					$order_ids[] = $post_id;
1366 1366
 				}
@@ -1468,32 +1468,32 @@  discard block
 block discarded – undo
1468 1468
 				$items = $order->get_items();
1469 1469
 				foreach( $items as $item ) {
1470 1470
 
1471
-                    $product = wc_get_product( $item['product_id'] );
1471
+					$product = wc_get_product( $item['product_id'] );
1472 1472
 
1473
-                    // handle product bundles
1474
-                    if( is_object( $product ) &&  $product->is_type('bundle') ){
1473
+					// handle product bundles
1474
+					if( is_object( $product ) &&  $product->is_type('bundle') ){
1475 1475
 
1476
-                        $bundled_product = new WC_Product_Bundle( $product->id );
1477
-                        $bundled_items = $bundled_product->get_bundled_items();
1476
+						$bundled_product = new WC_Product_Bundle( $product->id );
1477
+						$bundled_items = $bundled_product->get_bundled_items();
1478 1478
 
1479
-                        foreach( $bundled_items as $bundled_item ){
1479
+						foreach( $bundled_items as $bundled_item ){
1480 1480
 
1481
-                            if( $bundled_item->product_id == $course_product_id ) {
1482
-                                Sensei_Utils::user_start_course( $user_id, $course_id );
1483
-                                return;
1484
-                            }
1481
+							if( $bundled_item->product_id == $course_product_id ) {
1482
+								Sensei_Utils::user_start_course( $user_id, $course_id );
1483
+								return;
1484
+							}
1485 1485
 
1486
-                        }
1486
+						}
1487 1487
 
1488
-                    } else {
1488
+					} else {
1489 1489
 
1490
-                    // handle regular products
1491
-                        if( $item['product_id'] == $course_product_id ) {
1492
-                            Sensei_Utils::user_start_course( $user_id, $course_id );
1493
-                            return;
1494
-                        }
1490
+					// handle regular products
1491
+						if( $item['product_id'] == $course_product_id ) {
1492
+							Sensei_Utils::user_start_course( $user_id, $course_id );
1493
+							return;
1494
+						}
1495 1495
 
1496
-                    }
1496
+					}
1497 1497
 				}
1498 1498
 			}
1499 1499
 
@@ -1524,21 +1524,21 @@  discard block
 block discarded – undo
1524 1524
 
1525 1525
 		//if not posted from the sensei login form let
1526 1526
 		// WordPress or any other party handle the failed request
1527
-	    if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form']  ){
1527
+		if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form']  ){
1528 1528
 
1529
-	    	return ;
1529
+			return ;
1530 1530
 
1531
-	    }
1531
+		}
1532 1532
 
1533
-    	// Get the reffering page, where did the post submission come from?
1534
-    	$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);
1533
+		// Get the reffering page, where did the post submission come from?
1534
+		$referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']);
1535 1535
 
1536 1536
    		 // if there's a valid referrer, and it's not the default log-in screen
1537
-	    if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
1538
-	        // let's append some information (login=failed) to the URL for the theme to use
1539
-	        wp_redirect( esc_url_raw( add_query_arg('login', 'failed',  $referrer) ) );
1540
-	    	exit;
1541
-    	}
1537
+		if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
1538
+			// let's append some information (login=failed) to the URL for the theme to use
1539
+			wp_redirect( esc_url_raw( add_query_arg('login', 'failed',  $referrer) ) );
1540
+			exit;
1541
+		}
1542 1542
 	}// End sensei_login_fail_redirect_to_front_end_login
1543 1543
 
1544 1544
 	/**
@@ -1549,92 +1549,92 @@  discard block
 block discarded – undo
1549 1549
 	function sensei_handle_login_request( ) {
1550 1550
 
1551 1551
 		// Check that it is a sensei login request and if it has a valid nonce
1552
-	    if(  isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) {
1552
+		if(  isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) {
1553 1553
 
1554
-	    	// Validate the login request nonce
1555
-		    if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1556
-		    	return;
1557
-		    }
1554
+			// Validate the login request nonce
1555
+			if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1556
+				return;
1557
+			}
1558 1558
 
1559
-		    //get the page where the sensei log form is located
1560
-		    $referrer = $_REQUEST['_wp_http_referer'];
1561
-		    //$redirect = $_REQUEST['_sensei_redirect'];
1559
+			//get the page where the sensei log form is located
1560
+			$referrer = $_REQUEST['_wp_http_referer'];
1561
+			//$redirect = $_REQUEST['_sensei_redirect'];
1562 1562
 
1563
-		    if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
1564
-		    	 && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){
1563
+			if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) )
1564
+				 && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){
1565 1565
 
1566
-		    	// when the user has entered a password or username do the sensei login
1567
-		    	$creds = array();
1566
+				// when the user has entered a password or username do the sensei login
1567
+				$creds = array();
1568 1568
 
1569
-		    	// check if the requests login is an email address
1570
-		    	if( is_email(  trim( $_REQUEST['log'] ) )  ){
1571
-		    		// query wordpress for the users details
1572
-		    		$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1569
+				// check if the requests login is an email address
1570
+				if( is_email(  trim( $_REQUEST['log'] ) )  ){
1571
+					// query wordpress for the users details
1572
+					$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1573 1573
 
1574
-		    		// validate the user object
1575
-		    		if( !$user ){
1574
+					// validate the user object
1575
+					if( !$user ){
1576 1576
 
1577
-		    			// the email doesnt exist
1578
-                        wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1579
-		        		exit;
1577
+						// the email doesnt exist
1578
+						wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1579
+						exit;
1580 1580
 
1581
-		    		}
1581
+					}
1582 1582
 
1583
-		    		//assigne the username to the creds array for further processing
1584
-		    		$creds['user_login'] =  $user->user_login ;
1583
+					//assigne the username to the creds array for further processing
1584
+					$creds['user_login'] =  $user->user_login ;
1585 1585
 
1586
-		    	}else{
1586
+				}else{
1587 1587
 
1588
-		    		// process this as a default username login
1589
-		    		$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
1588
+					// process this as a default username login
1589
+					$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
1590 1590
 
1591
-		    	}
1591
+				}
1592 1592
 
1593 1593
 				// get setup the rest of the creds array
1594 1594
 				$creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] );
1595 1595
 				$creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ;
1596 1596
 
1597 1597
 				//attempt logging in with the given details
1598
-			    $secure_cookie = is_ssl() ? true : false;
1599
-			    $user = wp_signon( $creds, $secure_cookie );
1598
+				$secure_cookie = is_ssl() ? true : false;
1599
+				$user = wp_signon( $creds, $secure_cookie );
1600 1600
 
1601 1601
 				if ( is_wp_error($user) ){ // on login failure
1602
-                    wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1603
-                    exit;
1602
+					wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1603
+					exit;
1604 1604
 				}else{ // on login success
1605 1605
 
1606 1606
 					/**
1607
-					* change the redirect url programatically
1608
-					*
1609
-					* @since 1.6.1
1610
-					*
1611
-					* @param string $referrer the page where the current url wheresensei login form was posted from
1612
-					*/
1607
+					 * change the redirect url programatically
1608
+					 *
1609
+					 * @since 1.6.1
1610
+					 *
1611
+					 * @param string $referrer the page where the current url wheresensei login form was posted from
1612
+					 */
1613 1613
 
1614 1614
 					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) );
1615 1615
 
1616 1616
 					wp_redirect( esc_url_raw( $success_redirect_url ) );
1617
-		        	exit;
1617
+					exit;
1618 1618
 
1619 1619
 				}	// end is_wp_error($user)
1620 1620
 
1621
-		    }else{ // if username or password is empty
1621
+			}else{ // if username or password is empty
1622 1622
 
1623
-                wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1624
-		        exit;
1623
+				wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) );
1624
+				exit;
1625 1625
 
1626
-		    } // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1626
+			} // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1627 1627
 
1628
-	    }elseif( ( isset( $_GET['login'] ) ) ) {
1629
-	    	// else if this request is a redircect from a previously faile login request
1630
-	    	$this->login_message_process();
1628
+		}elseif( ( isset( $_GET['login'] ) ) ) {
1629
+			// else if this request is a redircect from a previously faile login request
1630
+			$this->login_message_process();
1631 1631
 
1632 1632
 			//exit the handle login request function
1633 1633
 			return;
1634
-	    }
1634
+		}
1635 1635
 
1636
-	    // if none of the above
1637
-	    return;
1636
+		// if none of the above
1637
+		return;
1638 1638
 
1639 1639
 	} // End  sensei_login_fail_redirect_to_front_end_login
1640 1640
 
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 	 */
1738 1738
 	public function login_message_process(){
1739 1739
 
1740
-            // setup the message variables
1740
+			// setup the message variables
1741 1741
 			$message = '';
1742 1742
 
1743 1743
 			//only output message if the url contains login=failed and login=emptyfields
@@ -1756,22 +1756,22 @@  discard block
 block discarded – undo
1756 1756
 	}// end login_message_process
1757 1757
 
1758 1758
 
1759
-    /**
1760
-     * sensei_show_admin_bar(). Use WooCommerce filter
1761
-     * to show admin bar to Teachers as well.
1762
-     *
1763
-     * @return void redirect
1764
-     *
1765
-     */
1766
-    public function sensei_show_admin_bar () {
1759
+	/**
1760
+	 * sensei_show_admin_bar(). Use WooCommerce filter
1761
+	 * to show admin bar to Teachers as well.
1762
+	 *
1763
+	 * @return void redirect
1764
+	 *
1765
+	 */
1766
+	public function sensei_show_admin_bar () {
1767 1767
 
1768
-        if (current_user_can('edit_courses')) {
1768
+		if (current_user_can('edit_courses')) {
1769 1769
 
1770
-            add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1);
1770
+			add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1);
1771 1771
 
1772
-        }
1772
+		}
1773 1773
 
1774
-    }
1774
+	}
1775 1775
 
1776 1776
 } // End Class
1777 1777
 
Please login to merge, or discard this patch.
includes/template-functions.php 1 patch
Indentation   +320 added lines, -321 removed lines patch added patch discarded remove patch
@@ -5,18 +5,18 @@  discard block
 block discarded – undo
5 5
 	 * 	Output tags.
6 6
 	 ***************************************************************************************************/
7 7
 
8
-    /**
9
-     * sensei_course_archive_next_link function.
10
-     *
11
-     * @access public
12
-     * @param string $type (default: 'newcourses')
13
-     * @return void
14
-     */
15
-    function sensei_course_archive_next_link( $type = 'newcourses' ) {
8
+	/**
9
+	 * sensei_course_archive_next_link function.
10
+	 *
11
+	 * @access public
12
+	 * @param string $type (default: 'newcourses')
13
+	 * @return void
14
+	 */
15
+	function sensei_course_archive_next_link( $type = 'newcourses' ) {
16 16
 
17
-        _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
17
+		_deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.');
18 18
 
19
-    } // End sensei_course_archive_next_link()
19
+	} // End sensei_course_archive_next_link()
20 20
 
21 21
 	 /**
22 22
 	  * course_single_lessons function.
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 	  */
27 27
 	 function course_single_lessons() {
28 28
 
29
-         // load backwards compatible template name if it exists in the users theme
30
-         $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
-         if( $located_template ){
29
+		 // load backwards compatible template name if it exists in the users theme
30
+		 $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' );
31
+		 if( $located_template ){
32 32
 
33
-             Sensei_Templates::get_template( 'single-course/course-lessons.php' );
34
-             return;
33
+			 Sensei_Templates::get_template( 'single-course/course-lessons.php' );
34
+			 return;
35 35
 
36
-        }
36
+		}
37 37
 
38 38
 		Sensei_Templates::get_template( 'single-course/lessons.php' );
39 39
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	  */
49 49
 	 function lesson_single_meta() {
50 50
 
51
-         _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
52
-         sensei_the_single_lesson_meta();
51
+		 _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' );
52
+		 sensei_the_single_lesson_meta();
53 53
 
54 54
 	 } // End lesson_single_meta()
55 55
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	  * @access public
61 61
 	  * @param bool $return (default: false)
62 62
 	  * @return void
63
-      * @deprecated since 1.9.0
63
+	  * @deprecated since 1.9.0
64 64
 	  */
65 65
 	 function quiz_questions( $return = false ) {
66 66
 
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 	  * @access public
75 75
 	  * @since  1.3.0
76 76
 	  * @return void
77
-      * @deprecated
77
+	  * @deprecated
78 78
 	  */
79 79
 	 function quiz_question_type( $question_type = 'multiple-choice' ) {
80 80
 
81
-         Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
81
+		 Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' );
82 82
 
83 83
 	 } // End lesson_single_meta()
84 84
 
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 	/**
90 90
 	 * sensei_check_prerequisite_course function.
91 91
 	 *
92
-     * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id );
92
+	 * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id );
93 93
 	 * @access public
94 94
 	 * @param mixed $course_id
95 95
 	 * @return bool
96 96
 	 */
97 97
 	function sensei_check_prerequisite_course( $course_id ) {
98 98
 
99
-        return Sensei_Course::is_prerequisite_complete( $course_id );
99
+		return Sensei_Course::is_prerequisite_complete( $course_id );
100 100
 
101 101
 	} // End sensei_check_prerequisite_course()
102 102
 
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
     			<span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span>
121 121
 
122 122
     		</form><?php
123
-    	} // End If Statement
123
+		} // End If Statement
124 124
 	} // End sensei_start_course_form()
125 125
 
126 126
 
127 127
 	/**
128 128
 	 * sensei_wc_add_to_cart function.
129 129
 	 *
130
-     * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id );
130
+	 * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id );
131 131
 	 * @access public
132 132
 	 * @param mixed $course_id
133 133
 	 * @return void
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return bool
148 148
 	 */
149 149
 	function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) {
150
-        return Sensei_WC::is_product_in_cart( $wc_product_id );
150
+		return Sensei_WC::is_product_in_cart( $wc_product_id );
151 151
 	} // End sensei_check_if_product_is_in_cart()
152 152
 
153 153
 	/**
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	function sensei_simple_course_price( $post_id ) {
161 161
 
162 162
 		//WooCommerce Pricing
163
-        if ( Sensei_WC::is_woocommerce_active() ) {
164
-    	    $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
-    	    if ( 0 < $wc_post_id ) {
166
-    	    	// Get the product
167
-    	    	$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
163
+		if ( Sensei_WC::is_woocommerce_active() ) {
164
+			$wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true );
165
+			if ( 0 < $wc_post_id ) {
166
+				// Get the product
167
+				$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
168 168
 
169
-    	    	if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
169
+				if ( isset( $product ) && !empty( $product )  &&  $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?>
170 170
     	    		<span class="course-price"><?php echo $product->get_price_html(); ?></span>
171 171
     	    	<?php } // End If Statement
172
-    	    } // End If Statement
173
-    	} // End If Statement
172
+			} // End If Statement
173
+		} // End If Statement
174 174
 	} // End sensei_simple_course_price()
175 175
 
176 176
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 		if ( ! $query->is_main_query() )
200
-        	return;
200
+			return;
201 201
 
202 202
 		// Apply Filter only if on frontend and when course archive is running
203 203
 		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 		if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) {
206 206
 			// Check for pagination settings
207 207
    			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
208
-    			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
209
-    		} else {
210
-    			$amount = $query->get( 'posts_per_page' );
211
-    		} // End If Statement
212
-    		$query->set( 'posts_per_page', $amount );
208
+				$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
209
+			} else {
210
+				$amount = $query->get( 'posts_per_page' );
211
+			} // End If Statement
212
+			$query->set( 'posts_per_page', $amount );
213 213
 		} // End If Statement
214 214
 	} // End sensei_course_archive_filter()
215 215
 	add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
@@ -248,70 +248,70 @@  discard block
 block discarded – undo
248 248
 			$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
249 249
 			$all_lessons = array();
250 250
 
251
-            $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
252
-
253
-            if( !empty( $modules )  ){
254
-                foreach( (array) $modules as $module ) {
255
-
256
-                    $args = array(
257
-                        'post_type' => 'lesson',
258
-                        'post_status' => 'publish',
259
-                        'posts_per_page' => -1,
260
-                        'meta_query' => array(
261
-                            array(
262
-                                'key' => '_lesson_course',
263
-                                'value' => intval( $lesson_course_id ),
264
-                                'compare' => '='
265
-                            )
266
-                        ),
267
-                        'tax_query' => array(
268
-                            array(
269
-                                'taxonomy' => Sensei()->modules->taxonomy,
270
-                                'field' => 'id',
271
-                                'terms' => intval( $module->term_id )
272
-                            )
273
-                        ),
274
-                        'meta_key' => '_order_module_' . $module->term_id,
275
-                        'orderby' => 'meta_value_num date',
276
-                        'order' => 'ASC',
277
-                        'suppress_filters' => 0
278
-                    );
279
-
280
-                    $lessons = get_posts( $args );
281
-                    if ( 0 < count( $lessons ) ) {
282
-                        foreach ($lessons as $lesson_item){
283
-                            $all_lessons[] = $lesson_item->ID;
284
-                        } // End For Loop
285
-                    } // End If Statement
286
-
287
-                }//end for each
288
-
289
-            }// end if empty modules
290
-
291
-            $args = array(
292
-                'post_type' => 'lesson',
293
-                'posts_per_page' => -1,
294
-                'suppress_filters' => 0,
295
-                'meta_key' => '_order_' . $lesson_course_id,
296
-                'orderby' => 'meta_value_num date',
297
-                'order' => 'ASC',
298
-                'meta_query' => array(
299
-                    array(
300
-                        'key' => '_lesson_course',
301
-                        'value' => intval( $lesson_course_id ),
302
-                    ),
303
-                ),
304
-                'post__not_in' => $all_lessons,
305
-            );
306
-
307
-            $other_lessons = get_posts( $args );
308
-            if ( 0 < count( $other_lessons ) ) {
251
+			$modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) );
252
+
253
+			if( !empty( $modules )  ){
254
+				foreach( (array) $modules as $module ) {
255
+
256
+					$args = array(
257
+						'post_type' => 'lesson',
258
+						'post_status' => 'publish',
259
+						'posts_per_page' => -1,
260
+						'meta_query' => array(
261
+							array(
262
+								'key' => '_lesson_course',
263
+								'value' => intval( $lesson_course_id ),
264
+								'compare' => '='
265
+							)
266
+						),
267
+						'tax_query' => array(
268
+							array(
269
+								'taxonomy' => Sensei()->modules->taxonomy,
270
+								'field' => 'id',
271
+								'terms' => intval( $module->term_id )
272
+							)
273
+						),
274
+						'meta_key' => '_order_module_' . $module->term_id,
275
+						'orderby' => 'meta_value_num date',
276
+						'order' => 'ASC',
277
+						'suppress_filters' => 0
278
+					);
279
+
280
+					$lessons = get_posts( $args );
281
+					if ( 0 < count( $lessons ) ) {
282
+						foreach ($lessons as $lesson_item){
283
+							$all_lessons[] = $lesson_item->ID;
284
+						} // End For Loop
285
+					} // End If Statement
286
+
287
+				}//end for each
288
+
289
+			}// end if empty modules
290
+
291
+			$args = array(
292
+				'post_type' => 'lesson',
293
+				'posts_per_page' => -1,
294
+				'suppress_filters' => 0,
295
+				'meta_key' => '_order_' . $lesson_course_id,
296
+				'orderby' => 'meta_value_num date',
297
+				'order' => 'ASC',
298
+				'meta_query' => array(
299
+					array(
300
+						'key' => '_lesson_course',
301
+						'value' => intval( $lesson_course_id ),
302
+					),
303
+				),
304
+				'post__not_in' => $all_lessons,
305
+			);
306
+
307
+			$other_lessons = get_posts( $args );
308
+			if ( 0 < count( $other_lessons ) ) {
309 309
 				foreach ($other_lessons as $lesson_item){
310 310
 					$all_lessons[] = $lesson_item->ID;
311 311
 				} // End For Loop
312 312
 			} // End If Statement
313 313
 
314
-            if ( 0 < count( $all_lessons ) ) {
314
+			if ( 0 < count( $all_lessons ) ) {
315 315
 				$found_index = false;
316 316
 				foreach ( $all_lessons as $lesson ){
317 317
 					if ( $found_index && $return_values['next_lesson'] == 0 ) {
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
    */
343 343
   function sensei_get_excerpt( $post_id = '' ) {
344 344
 
345
-      global $post;
346
-      _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
347
-      return get_the_excerpt();
345
+	  global $post;
346
+	  _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.');
347
+	  return get_the_excerpt();
348 348
 
349 349
   }
350 350
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 */
370 370
 function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) {
371 371
 
372
-    return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
372
+	return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id );
373 373
 
374 374
 } // End sensei_has_user_completed_prerequisite_lesson()
375 375
 
@@ -484,27 +484,27 @@  discard block
 block discarded – undo
484 484
 
485 485
 	}else{
486 486
 
487
-        // if the loop has not been initiated check the first module has lessons
488
-        if( -1 == $sensei_modules_loop[ 'current' ]  ){
487
+		// if the loop has not been initiated check the first module has lessons
488
+		if( -1 == $sensei_modules_loop[ 'current' ]  ){
489 489
 
490
-            $index = 0;
490
+			$index = 0;
491 491
 
492
-            if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
493
-                // setup the query for the module lessons
494
-                $course_id = $sensei_modules_loop['course_id'];
492
+			if( isset( $sensei_modules_loop['modules'][ $index ] ) ) {
493
+				// setup the query for the module lessons
494
+				$course_id = $sensei_modules_loop['course_id'];
495 495
 
496
-                $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
497
-                $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
496
+				$module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id;
497
+				$modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id );
498 498
 
499
-                // setup the global wp-query only if the lessons
500
-                if( $modules_query->have_posts() ){
499
+				// setup the global wp-query only if the lessons
500
+				if( $modules_query->have_posts() ){
501 501
 
502
-                    return true;
502
+					return true;
503 503
 
504
-                }
505
-            }
506
-        }
507
-        // default to false if the first module doesn't have posts
504
+				}
505
+			}
506
+		}
507
+		// default to false if the first module doesn't have posts
508 508
 		return false;
509 509
 
510 510
 	}
@@ -612,46 +612,46 @@  discard block
 block discarded – undo
612 612
 		return '';
613 613
 	}
614 614
 
615
-    global $sensei_modules_loop;
616
-    $module_title = $sensei_modules_loop['current_module']->name;
617
-    $module_term_id = $sensei_modules_loop['current_module']->term_id;
618
-    $course_id = $sensei_modules_loop['course_id'];
619
-    $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() );
615
+	global $sensei_modules_loop;
616
+	$module_title = $sensei_modules_loop['current_module']->name;
617
+	$module_term_id = $sensei_modules_loop['current_module']->term_id;
618
+	$course_id = $sensei_modules_loop['course_id'];
619
+	$module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() );
620 620
 
621
-    $module_status =  '';
622
-    if ( $module_progress && $module_progress > 0) {
621
+	$module_status =  '';
622
+	if ( $module_progress && $module_progress > 0) {
623 623
 
624
-        $module_status = __('Completed', 'woothemes-sensei');
624
+		$module_status = __('Completed', 'woothemes-sensei');
625 625
 
626
-        if ($module_progress < 100) {
626
+		if ($module_progress < 100) {
627 627
 
628
-            $module_status = __('In progress', 'woothemes-sensei');
628
+			$module_status = __('In progress', 'woothemes-sensei');
629 629
 
630
-        }
630
+		}
631 631
 
632
-    }
632
+	}
633 633
 
634 634
 	if ( empty( $module_status ) ){
635 635
 		return '';
636 636
 	}
637 637
 
638 638
 	$status_class = strtolower( str_replace( ' ', '-', $module_status  ) );
639
-    $module_status_html = '<p class="status module-status ' . $status_class . '">'
640
-                            . $module_status
641
-                            . '</p>';
642
-
643
-    /**
644
-     * Filter the module status.
645
-     *
646
-     * This fires within the sensei_get_the_module_status function.
647
-     *
648
-     * @since 1.9.0
649
-     *
650
-     * @param $module_status_html
651
-     * @param $module_term_id
652
-     * @param $course_id
653
-     */
654
-    return apply_filters( 'sensei_the_module_status_html',  $module_status_html , $module_term_id, $course_id );
639
+	$module_status_html = '<p class="status module-status ' . $status_class . '">'
640
+							. $module_status
641
+							. '</p>';
642
+
643
+	/**
644
+	 * Filter the module status.
645
+	 *
646
+	 * This fires within the sensei_get_the_module_status function.
647
+	 *
648
+	 * @since 1.9.0
649
+	 *
650
+	 * @param $module_status_html
651
+	 * @param $module_term_id
652
+	 * @param $course_id
653
+	 */
654
+	return apply_filters( 'sensei_the_module_status_html',  $module_status_html , $module_term_id, $course_id );
655 655
 
656 656
 }
657 657
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
  */
662 662
 function sensei_the_module_status(){
663 663
 
664
-    echo sensei_get_the_module_status();
664
+	echo sensei_get_the_module_status();
665 665
 
666 666
 }
667 667
 
@@ -682,21 +682,21 @@  discard block
 block discarded – undo
682 682
  */
683 683
 function sensei_quiz_has_questions(){
684 684
 
685
-    global $sensei_question_loop;
685
+	global $sensei_question_loop;
686 686
 
687
-    if( !isset( $sensei_question_loop['total'] ) ){
688
-        return false;
689
-    }
687
+	if( !isset( $sensei_question_loop['total'] ) ){
688
+		return false;
689
+	}
690 690
 
691
-    if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
691
+	if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total']  ){
692 692
 
693
-        return true;
693
+		return true;
694 694
 
695
-    }else{
695
+	}else{
696 696
 
697
-        return false;
697
+		return false;
698 698
 
699
-    }
699
+	}
700 700
 
701 701
 }// end sensei_quiz_has_questions
702 702
 
@@ -707,15 +707,14 @@  discard block
 block discarded – undo
707 707
  * execution.
708 708
  *
709 709
  * @since 1.9.0
710
-
711 710
  */
712 711
 function sensei_setup_the_question(){
713 712
 
714
-    global $sensei_question_loop;
713
+	global $sensei_question_loop;
715 714
 
716
-    $sensei_question_loop['current']++;
717
-    $index = $sensei_question_loop['current'];
718
-    $sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
715
+	$sensei_question_loop['current']++;
716
+	$index = $sensei_question_loop['current'];
717
+	$sensei_question_loop['current_question'] =  $sensei_question_loop['questions'][ $index ] ;
719 718
 
720 719
 
721 720
 }// end sensei_setup_the_question
@@ -728,12 +727,12 @@  discard block
 block discarded – undo
728 727
  */
729 728
 function sensei_the_question_content(){
730 729
 
731
-    global $sensei_question_loop;
730
+	global $sensei_question_loop;
732 731
 
733
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
732
+	$question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
734 733
 
735
-    // load the template that displays the question information.
736
-    WooThemes_Sensei_Question::load_question_template( $question_type );
734
+	// load the template that displays the question information.
735
+	WooThemes_Sensei_Question::load_question_template( $question_type );
737 736
 
738 737
 }// end sensei_the_question_content
739 738
 
@@ -744,26 +743,26 @@  discard block
 block discarded – undo
744 743
  */
745 744
 function sensei_the_question_class(){
746 745
 
747
-    global $sensei_question_loop;
746
+	global $sensei_question_loop;
748 747
 
749
-    $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
748
+	$question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID );
750 749
 
751
-    /**
752
-     * filter the sensei question class within
753
-     * the quiz question loop.
754
-     *
755
-     * @since 1.9.0
756
-     */
757
-     $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
750
+	/**
751
+	 * filter the sensei question class within
752
+	 * the quiz question loop.
753
+	 *
754
+	 * @since 1.9.0
755
+	 */
756
+	 $classes = apply_filters( 'sensei_question_classes', array( $question_type ) );
758 757
 
759
-    $html_classes = '';
760
-    foreach( $classes as $class ){
758
+	$html_classes = '';
759
+	foreach( $classes as $class ){
761 760
 
762
-        $html_classes .= $class . ' ';
761
+		$html_classes .= $class . ' ';
763 762
 
764
-    }// end foreach
763
+	}// end foreach
765 764
 
766
-    esc_attr_e( trim( $html_classes ) );
765
+	esc_attr_e( trim( $html_classes ) );
767 766
 
768 767
 }
769 768
 
@@ -774,12 +773,12 @@  discard block
 block discarded – undo
774 773
  */
775 774
 function sensei_get_the_question_id( ){
776 775
 
777
-    global $sensei_question_loop;
778
-    if( isset( $sensei_question_loop['current_question']->ID ) ){
776
+	global $sensei_question_loop;
777
+	if( isset( $sensei_question_loop['current_question']->ID ) ){
779 778
 
780
-        return $sensei_question_loop['current_question']->ID;
779
+		return $sensei_question_loop['current_question']->ID;
781 780
 
782
-    }
781
+	}
783 782
 
784 783
 }// end sensei_the_question_id
785 784
 
@@ -806,63 +805,63 @@  discard block
 block discarded – undo
806 805
  */
807 806
 function sensei_can_user_view_lesson( $lesson_id = '', $user_id = ''  ){
808 807
 
809
-    if( empty( $lesson_id ) ){
808
+	if( empty( $lesson_id ) ){
810 809
 
811
-        $lesson_id = get_the_ID();
810
+		$lesson_id = get_the_ID();
812 811
 
813
-    }
812
+	}
814 813
 
815
-    if( empty( $user_id ) ){
814
+	if( empty( $user_id ) ){
816 815
 
817
-        $user_id = get_current_user_id();
816
+		$user_id = get_current_user_id();
818 817
 
819
-    }
818
+	}
820 819
 
821
-    // Check for prerequisite lesson completions
822
-    $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
823
-    $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
824
-    $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
820
+	// Check for prerequisite lesson completions
821
+	$pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id );
822
+	$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
823
+	$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id );
825 824
 
826
-    $is_preview = false;
827
-    if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
825
+	$is_preview = false;
826
+	if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) {
828 827
 
829
-        $is_preview = true;
830
-        $pre_requisite_complete = true;
828
+		$is_preview = true;
829
+		$pre_requisite_complete = true;
831 830
 
832
-    };
831
+	};
833 832
 
834 833
 
835
-    $user_can_access_lesson =  false;
834
+	$user_can_access_lesson =  false;
836 835
 
837
-    if( is_user_logged_in() && $user_taking_course ){
836
+	if( is_user_logged_in() && $user_taking_course ){
838 837
 
839
-        $user_can_access_lesson =  true;
838
+		$user_can_access_lesson =  true;
840 839
 
841
-    }
840
+	}
842 841
 
843 842
 
844
-    $access_permission = false;
843
+	$access_permission = false;
845 844
 
846
-    if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
845
+	if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
847 846
 
848
-        $access_permission = true;
847
+		$access_permission = true;
849 848
 
850
-    }
849
+	}
851 850
 
852
-    $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
851
+	$can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview;
853 852
 
854
-    /**
855
-     * Filter the can user view lesson function
856
-     *
857
-     * @since 1.9.0
858
-     *
859
-     * @hooked Sensei_WC::alter_can_user_view_lesson
860
-     *
861
-     * @param bool $can_user_view_lesson
862
-     * @param string $lesson_id
863
-     * @param string $user_id
864
-     */
865
-    return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
853
+	/**
854
+	 * Filter the can user view lesson function
855
+	 *
856
+	 * @since 1.9.0
857
+	 *
858
+	 * @hooked Sensei_WC::alter_can_user_view_lesson
859
+	 *
860
+	 * @param bool $can_user_view_lesson
861
+	 * @param string $lesson_id
862
+	 * @param string $user_id
863
+	 */
864
+	return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id );
866 865
 
867 866
 } // end sensei_can_current_user_view_lesson
868 867
 
@@ -874,49 +873,49 @@  discard block
 block discarded – undo
874 873
  */
875 874
 function sensei_the_single_lesson_meta(){
876 875
 
877
-    // if the lesson meta is included within theme load that instead of the function content
878
-    $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
879
-    if( ! empty( $template ) ){
876
+	// if the lesson meta is included within theme load that instead of the function content
877
+	$template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' );
878
+	if( ! empty( $template ) ){
880 879
 
881
-        Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
882
-        return;
880
+		Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' );
881
+		return;
883 882
 
884
-    }
885
-
886
-    // Get the meta info
887
-    $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
888
-    $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() );
883
+	}
889 884
 
890
-    // Complete Lesson Logic
891
-    do_action( 'sensei_complete_lesson' );
892
-    // Check that the course has been started
893
-    if ( Sensei()->access_settings()
894
-        || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
895
-        || $is_preview ) {
896
-        ?>
885
+	// Get the meta info
886
+	$lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) );
887
+	$is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() );
888
+
889
+	// Complete Lesson Logic
890
+	do_action( 'sensei_complete_lesson' );
891
+	// Check that the course has been started
892
+	if ( Sensei()->access_settings()
893
+		|| Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id())
894
+		|| $is_preview ) {
895
+		?>
897 896
         <section class="lesson-meta">
898 897
             <?php
899
-            if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
898
+			if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) {
900 899
 
901
-                do_action( 'sensei_lesson_video', get_the_ID() );
900
+				do_action( 'sensei_lesson_video', get_the_ID() );
902 901
 
903
-            }
904
-            ?>
902
+			}
903
+			?>
905 904
             <?php do_action( 'sensei_frontend_messages' ); ?>
906 905
 
907 906
             <?php if ( ! $is_preview
908
-                || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
907
+				|| Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) {
909 908
 
910
-                sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
909
+				sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() )  );
911 910
 
912
-            } ?>
911
+			} ?>
913 912
         </section>
914 913
 
915 914
         <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?>
916 915
 
917 916
     <?php }
918 917
 
919
-    do_action( 'sensei_lesson_meta_extra', get_the_ID() );
918
+	do_action( 'sensei_lesson_meta_extra', get_the_ID() );
920 919
 
921 920
 } // end the_single_lesson_meta
922 921
 
@@ -932,16 +931,16 @@  discard block
 block discarded – undo
932 931
  */
933 932
 function get_sensei_header(){
934 933
 
935
-    if ( ! defined( 'ABSPATH' ) ) exit;
934
+	if ( ! defined( 'ABSPATH' ) ) exit;
936 935
 
937
-    get_header();
936
+	get_header();
938 937
 
939
-    /**
940
-     * sensei_before_main_content hook
941
-     *
942
-     * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
943
-     */
944
-    do_action( 'sensei_before_main_content' );
938
+	/**
939
+	 * sensei_before_main_content hook
940
+	 *
941
+	 * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content)
942
+	 */
943
+	do_action( 'sensei_before_main_content' );
945 944
 
946 945
 }// end get_sensei_header
947 946
 
@@ -957,28 +956,28 @@  discard block
 block discarded – undo
957 956
  */
958 957
 function get_sensei_footer(){
959 958
 
960
-    /**
961
-     * sensei_pagination hook
962
-     *
963
-     * @hooked sensei_pagination - 10 (outputs pagination)
964
-     */
965
-    do_action( 'sensei_pagination' );
966
-
967
-    /**
968
-     * sensei_after_main_content hook
969
-     *
970
-     * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
971
-     */
972
-    do_action( 'sensei_after_main_content' );
973
-
974
-    /**
975
-     * sensei_sidebar hook
976
-     *
977
-     * @hooked sensei_get_sidebar - 10
978
-     */
979
-    do_action( 'sensei_sidebar' );
980
-
981
-    get_footer();
959
+	/**
960
+	 * sensei_pagination hook
961
+	 *
962
+	 * @hooked sensei_pagination - 10 (outputs pagination)
963
+	 */
964
+	do_action( 'sensei_pagination' );
965
+
966
+	/**
967
+	 * sensei_after_main_content hook
968
+	 *
969
+	 * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content)
970
+	 */
971
+	do_action( 'sensei_after_main_content' );
972
+
973
+	/**
974
+	 * sensei_sidebar hook
975
+	 *
976
+	 * @hooked sensei_get_sidebar - 10
977
+	 */
978
+	do_action( 'sensei_sidebar' );
979
+
980
+	get_footer();
982 981
 
983 982
 }// end get_sensei_header
984 983
 
@@ -990,14 +989,14 @@  discard block
 block discarded – undo
990 989
  */
991 990
 function the_no_permissions_title(){
992 991
 
993
-    /**
994
-     * Filter the no permissions title just before it is echo'd on the
995
-     * no-permissions.php file.
996
-     *
997
-     * @since 1.9.0
998
-     * @param $no_permissions_title
999
-     */
1000
-    echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
992
+	/**
993
+	 * Filter the no permissions title just before it is echo'd on the
994
+	 * no-permissions.php file.
995
+	 *
996
+	 * @since 1.9.0
997
+	 * @param $no_permissions_title
998
+	 */
999
+	echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] );
1001 1000
 
1002 1001
 }
1003 1002
 
@@ -1008,14 +1007,14 @@  discard block
 block discarded – undo
1008 1007
  */
1009 1008
 function the_no_permissions_message( $post_id ){
1010 1009
 
1011
-    /**
1012
-     * Filter the no permissions message just before it is echo'd on the
1013
-     * no-permissions.php file.
1014
-     *
1015
-     * @since 1.9.0
1016
-     * @param $no_permissions_message
1017
-     */
1018
-    echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
1010
+	/**
1011
+	 * Filter the no permissions message just before it is echo'd on the
1012
+	 * no-permissions.php file.
1013
+	 *
1014
+	 * @since 1.9.0
1015
+	 * @param $no_permissions_message
1016
+	 */
1017
+	echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id );
1019 1018
 
1020 1019
 }
1021 1020
 
@@ -1026,8 +1025,8 @@  discard block
 block discarded – undo
1026 1025
  */
1027 1026
 function sensei_the_excerpt( $post_id ){
1028 1027
 
1029
-    global $post;
1030
-    the_excerpt( $post );
1028
+	global $post;
1029
+	the_excerpt( $post );
1031 1030
 
1032 1031
 }
1033 1032
 
@@ -1041,9 +1040,9 @@  discard block
 block discarded – undo
1041 1040
  */
1042 1041
  function sensei_get_current_page_url(){
1043 1042
 
1044
-     global $wp;
1045
-     $current_page_url =  home_url( $wp->request );
1046
-     return $current_page_url;
1043
+	 global $wp;
1044
+	 $current_page_url =  home_url( $wp->request );
1045
+	 return $current_page_url;
1047 1046
 
1048 1047
  }
1049 1048
 
@@ -1055,7 +1054,7 @@  discard block
 block discarded – undo
1055 1054
  */
1056 1055
 function sensei_the_my_courses_content(){
1057 1056
 
1058
-    echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
1057
+	echo Sensei()->course->load_user_courses_content( wp_get_current_user() );
1059 1058
 
1060 1059
 } // sensei_the_my_courses_content
1061 1060
 
@@ -1070,7 +1069,7 @@  discard block
 block discarded – undo
1070 1069
  */
1071 1070
 function sensei_load_template( $template_name ){
1072 1071
 
1073
-    Sensei_Templates::get_template( $template_name );
1072
+	Sensei_Templates::get_template( $template_name );
1074 1073
 
1075 1074
 }
1076 1075
 
@@ -1084,7 +1083,7 @@  discard block
 block discarded – undo
1084 1083
  */
1085 1084
 function sensei_load_template_part( $slug, $name ){
1086 1085
 
1087
-    Sensei_Templates::get_part( $slug, $name );
1086
+	Sensei_Templates::get_part( $slug, $name );
1088 1087
 
1089 1088
 }
1090 1089
 
@@ -1103,17 +1102,17 @@  discard block
 block discarded – undo
1103 1102
  */
1104 1103
 function sensei_the_lesson_excerpt( $lesson_id = '' ) {
1105 1104
 
1106
-    if( empty( $lesson_id )){
1105
+	if( empty( $lesson_id )){
1107 1106
 
1108
-        $lesson_id = get_the_ID();
1107
+		$lesson_id = get_the_ID();
1109 1108
 
1110
-    }
1109
+	}
1111 1110
 
1112
-    if( 'lesson' != get_post_type( $lesson_id ) ){
1113
-        return;
1114
-    }
1111
+	if( 'lesson' != get_post_type( $lesson_id ) ){
1112
+		return;
1113
+	}
1115 1114
 
1116
-    echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1115
+	echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false );
1117 1116
 
1118 1117
 }// End lesson_excerpt()
1119 1118
 
@@ -1123,16 +1122,16 @@  discard block
 block discarded – undo
1123 1122
  * @since 1.9.0
1124 1123
  */
1125 1124
 function sensei_the_course_results_lessons(){
1126
-    // load backwards compatible template name if it exists in the users theme
1127
-    $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1128
-    if( $located_template ){
1125
+	// load backwards compatible template name if it exists in the users theme
1126
+	$located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' );
1127
+	if( $located_template ){
1129 1128
 
1130
-        Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1131
-        return;
1129
+		Sensei_Templates::get_template( 'course-results/course-lessons.php' );
1130
+		return;
1132 1131
 
1133
-    }
1132
+	}
1134 1133
 
1135
-    Sensei_Templates::get_template( 'course-results/lessons.php' );
1134
+	Sensei_Templates::get_template( 'course-results/lessons.php' );
1136 1135
 }
1137 1136
 
1138 1137
 /**
@@ -1144,7 +1143,7 @@  discard block
 block discarded – undo
1144 1143
  */
1145 1144
 function sensei_courses_per_row(){
1146 1145
 
1147
-    echo Sensei_Course::get_loop_number_of_columns();
1146
+	echo Sensei_Course::get_loop_number_of_columns();
1148 1147
 
1149 1148
 }
1150 1149
 
@@ -1158,7 +1157,7 @@  discard block
 block discarded – undo
1158 1157
  */
1159 1158
 function sensei_get_template( $template_name, $args, $path ){
1160 1159
 
1161
-    Sensei_Templates::get_template( $template_name, $args, $path );
1160
+	Sensei_Templates::get_template( $template_name, $args, $path );
1162 1161
 
1163 1162
 }
1164 1163
 
@@ -1172,14 +1171,14 @@  discard block
 block discarded – undo
1172 1171
  */
1173 1172
 function get_the_lesson_status_class(){
1174 1173
 
1175
-    $status_class = '';
1176
-    $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
1174
+	$status_class = '';
1175
+	$lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
1177 1176
 
1178
-    if ( $lesson_completed ) {
1179
-        $status_class = 'completed';
1180
-    }
1177
+	if ( $lesson_completed ) {
1178
+		$status_class = 'completed';
1179
+	}
1181 1180
 
1182
-    return  $status_class;
1181
+	return  $status_class;
1183 1182
 
1184 1183
 }// end get_the_lesson_status_class
1185 1184
 /**
@@ -1191,5 +1190,5 @@  discard block
 block discarded – undo
1191 1190
  */
1192 1191
 function sensei_the_lesson_status_class(){
1193 1192
 
1194
-    echo get_the_lesson_status_class();
1193
+	echo get_the_lesson_status_class();
1195 1194
 }
Please login to merge, or discard this patch.
includes/class-sensei-grading.php 1 patch
Indentation   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * Constructor
22 22
 	 * @since  1.3.0
23
-     *
24
-     * @param $file
23
+	 *
24
+	 * @param $file
25 25
 	 */
26 26
 	public function __construct ( $file ) {
27 27
 		$this->name = __( 'Grading', 'woothemes-sensei' );
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	/**
231 231
 	 * Outputs Grading general headers
232 232
 	 * @since  1.3.0
233
-     * @param array $args
233
+	 * @param array $args
234 234
 	 * @return void
235 235
 	 */
236 236
 	public function grading_headers( $args = array( 'nav' => 'default' ) ) {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		}
283 283
 		if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) {
284 284
 
285
-            $user_name = Sensei_Learner::get_full_name( $_GET['user_id'] );
285
+			$user_name = Sensei_Learner::get_full_name( $_GET['user_id'] );
286 286
 			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
287 287
 
288 288
 		} // End If Statement
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		}
317 317
 		if ( isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) {
318 318
 
319
-            $user_name = Sensei_Learner::get_full_name( $_GET['user'] );
319
+			$user_name = Sensei_Learner::get_full_name( $_GET['user'] );
320 320
 			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
321 321
 
322 322
 		} // End If Statement
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 	public function count_statuses( $args = array() ) {
366 366
 		global  $wpdb;
367 367
 
368
-        /**
369
-         * Filter fires inside Sensei_Grading::count_statuses
370
-         *
371
-         * Alter the the post_in array to determine which posts the
372
-         * comment query should be limited to.
373
-         * @since 1.8.0
374
-         * @param array $args
375
-         */
376
-        $args = apply_filters( 'sensei_count_statuses_args', $args );
368
+		/**
369
+		 * Filter fires inside Sensei_Grading::count_statuses
370
+		 *
371
+		 * Alter the the post_in array to determine which posts the
372
+		 * comment query should be limited to.
373
+		 * @since 1.8.0
374
+		 * @param array $args
375
+		 */
376
+		$args = apply_filters( 'sensei_count_statuses_args', $args );
377 377
 
378 378
 		if ( 'course' == $args['type'] ) {
379 379
 			$type = 'sensei_course_status';
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 
386 386
 		$query = "SELECT comment_approved, COUNT( * ) AS total FROM {$wpdb->comments} WHERE comment_type = %s ";
387 387
 
388
-        // Restrict to specific posts
388
+		// Restrict to specific posts
389 389
 		if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) {
390 390
 			$query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')';
391 391
 		}
@@ -520,148 +520,148 @@  discard block
 block discarded – undo
520 520
 		return $html;
521 521
 	} // End lessons_drop_down_html()
522 522
 
523
-    /**
524
-     * The process grading function handles admin grading submissions.
525
-     *
526
-     * This function is hooked on to admin_init. It simply accepts
527
-     * the grades as the Grader selected theme and saves the total grade and
528
-     * individual question grades.
529
-     *
530
-     * @return bool
531
-     */
532
-    public function admin_process_grading_submission() {
523
+	/**
524
+	 * The process grading function handles admin grading submissions.
525
+	 *
526
+	 * This function is hooked on to admin_init. It simply accepts
527
+	 * the grades as the Grader selected theme and saves the total grade and
528
+	 * individual question grades.
529
+	 *
530
+	 * @return bool
531
+	 */
532
+	public function admin_process_grading_submission() {
533 533
 
534
-        // NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry
535
-        if( ! isset( $_POST['sensei_manual_grade'] )
536
-            || ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' )
537
-            || ! isset( $_GET['quiz_id'] )
538
-            || $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) {
534
+		// NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry
535
+		if( ! isset( $_POST['sensei_manual_grade'] )
536
+			|| ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' )
537
+			|| ! isset( $_GET['quiz_id'] )
538
+			|| $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) {
539 539
 
540
-            return false; //exit and do not grade
540
+			return false; //exit and do not grade
541 541
 
542
-        }
542
+		}
543 543
 
544
-        $quiz_id = $_GET['quiz_id'];
545
-        $user_id = $_GET['user'];
544
+		$quiz_id = $_GET['quiz_id'];
545
+		$user_id = $_GET['user'];
546 546
 
547 547
 
548
-        $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
549
-        $quiz_lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
550
-        $quiz_grade = 0;
551
-        $count = 0;
552
-        $quiz_grade_total = $_POST['quiz_grade_total'];
553
-        $all_question_grades = array();
554
-        $all_answers_feedback = array();
548
+		$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
549
+		$quiz_lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
550
+		$quiz_grade = 0;
551
+		$count = 0;
552
+		$quiz_grade_total = $_POST['quiz_grade_total'];
553
+		$all_question_grades = array();
554
+		$all_answers_feedback = array();
555 555
 
556
-        foreach( $questions as $question ) {
556
+		foreach( $questions as $question ) {
557 557
 
558
-            ++$count;
559
-            $question_id = $question->ID;
558
+			++$count;
559
+			$question_id = $question->ID;
560 560
 
561
-            if( isset( $_POST[ 'question_' . $question_id ] ) ) {
561
+			if( isset( $_POST[ 'question_' . $question_id ] ) ) {
562 562
 
563
-                $question_grade = 0;
564
-                if( $_POST[ 'question_' . $question_id ] == 'right' ) {
563
+				$question_grade = 0;
564
+				if( $_POST[ 'question_' . $question_id ] == 'right' ) {
565 565
 
566
-                    $question_grade = $_POST[ 'question_' . $question_id . '_grade' ];
566
+					$question_grade = $_POST[ 'question_' . $question_id . '_grade' ];
567 567
 
568
-                }
568
+				}
569 569
 
570
-                // add data to the array that will, after the loop, be stored on the lesson status
571
-                $all_question_grades[ $question_id ] = $question_grade;
570
+				// add data to the array that will, after the loop, be stored on the lesson status
571
+				$all_question_grades[ $question_id ] = $question_grade;
572 572
 
573
-                // tally up the total quiz grade
574
-                $quiz_grade += $question_grade;
573
+				// tally up the total quiz grade
574
+				$quiz_grade += $question_grade;
575 575
 
576
-            } // endif
576
+			} // endif
577 577
 
578
-            // Question answer feedback / notes
579
-            $question_feedback = '';
580
-            if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){
578
+			// Question answer feedback / notes
579
+			$question_feedback = '';
580
+			if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){
581 581
 
582
-                $question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] );
582
+				$question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] );
583 583
 
584
-            }
585
-            $all_answers_feedback[ $question_id ] = $question_feedback;
584
+			}
585
+			$all_answers_feedback[ $question_id ] = $question_feedback;
586 586
 
587
-        } // end for each $questions
587
+		} // end for each $questions
588 588
 
589
-        //store all question grades on the lesson status
590
-        Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id );
589
+		//store all question grades on the lesson status
590
+		Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id );
591 591
 
592
-        //store the feedback from grading
593
-        Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id );
592
+		//store the feedback from grading
593
+		Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id );
594 594
 
595
-        // $_POST['all_questions_graded'] is set when all questions have been graded
596
-        // in the class sensei grading user quiz -> display()
597
-        if( $_POST['all_questions_graded'] == 'yes' ) {
595
+		// $_POST['all_questions_graded'] is set when all questions have been graded
596
+		// in the class sensei grading user quiz -> display()
597
+		if( $_POST['all_questions_graded'] == 'yes' ) {
598 598
 
599
-            // set the users total quiz grade
599
+			// set the users total quiz grade
600 600
 			if ( 0 < intval( $quiz_grade_total ) ) {
601
-            $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
601
+			$grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
602 602
 			}
603 603
 			else {
604 604
 				$grade = 0;
605 605
 			}
606
-            Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id );
607
-
608
-            // Duplicating what Frontend->sensei_complete_quiz() does
609
-            $pass_required = get_post_meta( $quiz_id, '_pass_required', true );
610
-            $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
611
-            $lesson_metadata = array();
612
-            if ( $pass_required ) {
613
-                // Student has reached the pass mark and lesson is complete
614
-                if ( $quiz_passmark <= $grade ) {
615
-                    $lesson_status = 'passed';
616
-                }
617
-                else {
618
-                    $lesson_status = 'failed';
619
-                } // End If Statement
620
-            }
621
-            // Student only has to partake the quiz
622
-            else {
623
-                $lesson_status = 'graded';
624
-            }
625
-            $lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above
606
+			Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id );
607
+
608
+			// Duplicating what Frontend->sensei_complete_quiz() does
609
+			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
610
+			$quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
611
+			$lesson_metadata = array();
612
+			if ( $pass_required ) {
613
+				// Student has reached the pass mark and lesson is complete
614
+				if ( $quiz_passmark <= $grade ) {
615
+					$lesson_status = 'passed';
616
+				}
617
+				else {
618
+					$lesson_status = 'failed';
619
+				} // End If Statement
620
+			}
621
+			// Student only has to partake the quiz
622
+			else {
623
+				$lesson_status = 'graded';
624
+			}
625
+			$lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above
626 626
 
627
-            Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata );
627
+			Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata );
628 628
 
629
-            if(  in_array( $lesson_status, array( 'passed', 'graded'  ) ) ) {
629
+			if(  in_array( $lesson_status, array( 'passed', 'graded'  ) ) ) {
630 630
 
631
-                /**
632
-                 * Summary.
633
-                 *
634
-                 * Description.
635
-                 *
636
-                 * @since 1.7.0
637
-                 *
638
-                 * @param int  $user_id
639
-                 * @param int $quiz_lesson_id
640
-                 */
641
-                do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id );
631
+				/**
632
+				 * Summary.
633
+				 *
634
+				 * Description.
635
+				 *
636
+				 * @since 1.7.0
637
+				 *
638
+				 * @param int  $user_id
639
+				 * @param int $quiz_lesson_id
640
+				 */
641
+				do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id );
642 642
 
643
-            } // end if in_array
643
+			} // end if in_array
644 644
 
645
-        }// end if $_POST['all_que...
645
+		}// end if $_POST['all_que...
646 646
 
647
-        if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) {
647
+		if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) {
648 648
 
649
-            $load_url = add_query_arg( array( 'message' => 'graded' ) );
649
+			$load_url = add_query_arg( array( 'message' => 'graded' ) );
650 650
 
651
-        } elseif ( isset( $_POST['_wp_http_referer'] ) ) {
651
+		} elseif ( isset( $_POST['_wp_http_referer'] ) ) {
652 652
 
653
-            $load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] );
653
+			$load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] );
654 654
 
655
-        } else {
655
+		} else {
656 656
 
657
-            $load_url = add_query_arg( array( 'message' => 'graded' ) );
657
+			$load_url = add_query_arg( array( 'message' => 'graded' ) );
658 658
 
659
-        }
659
+		}
660 660
 
661
-        wp_safe_redirect( esc_url_raw( $load_url ) );
662
-        exit;
661
+		wp_safe_redirect( esc_url_raw( $load_url ) );
662
+		exit;
663 663
 
664
-    } // end admin_process_grading_submission
664
+	} // end admin_process_grading_submission
665 665
 
666 666
 	public function get_redirect_url() {
667 667
 		// Parse POST data
@@ -706,398 +706,398 @@  discard block
 block discarded – undo
706 706
 		} // End If Statement
707 707
 	} // End sensei_grading_notices()
708 708
 
709
-    /**
710
-     * Grade quiz automatically
711
-     *
712
-     * This function grades each question automatically if there all questions are auto gradable. If not
713
-     * the quiz will not be auto gradable.
714
-     *
715
-     * @since 1.7.4
716
-     *
717
-     * @param  integer $quiz_id         ID of quiz
718
-     * @param  array $submitted questions id ans answers {
719
-     *          @type int $question_id
720
-     *          @type mixed $answer
721
-     * }
722
-     * @param  integer $total_questions Total questions in quiz (not used)
723
-     * @param string $quiz_grade_type Optional defaults to auto
724
-     *
725
-     * @return int $quiz_grade total sum of all question grades
726
-     */
727
-    public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
728
-
729
-        if( ! ( intval( $quiz_id ) > 0 )  || ! $submitted
730
-            || $quiz_grade_type != 'auto' ) {
731
-            return false; // exit early
732
-        }
733
-
734
-
735
-        $user_id = get_current_user_id();
736
-        $lesson_id =  Sensei()->quiz->get_lesson_id(  $quiz_id ) ;
737
-        $quiz_autogradable = true;
738
-
739
-        /**
740
-         * Filter the types of question types that can be automatically graded.
741
-         *
742
-         * This filter fires inside the auto grade quiz function and provides you with the default list.
743
-         *
744
-         * @param array {
745
-         *      'multiple-choice',
746
-         *      'boolean',
747
-         *      'gap-fill'.
748
-         * }
749
-         */
750
-        $autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) );
751
-
752
-        $grade_total = 0;
753
-        $all_question_grades = array();
754
-        foreach( $submitted as $question_id => $answer ) {
755
-
756
-            // check if the question is autogradable, either by type, or because the grade is 0
757
-            $question_type = Sensei()->question->get_question_type( $question_id );
709
+	/**
710
+	 * Grade quiz automatically
711
+	 *
712
+	 * This function grades each question automatically if there all questions are auto gradable. If not
713
+	 * the quiz will not be auto gradable.
714
+	 *
715
+	 * @since 1.7.4
716
+	 *
717
+	 * @param  integer $quiz_id         ID of quiz
718
+	 * @param  array $submitted questions id ans answers {
719
+	 *          @type int $question_id
720
+	 *          @type mixed $answer
721
+	 * }
722
+	 * @param  integer $total_questions Total questions in quiz (not used)
723
+	 * @param string $quiz_grade_type Optional defaults to auto
724
+	 *
725
+	 * @return int $quiz_grade total sum of all question grades
726
+	 */
727
+	public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
728
+
729
+		if( ! ( intval( $quiz_id ) > 0 )  || ! $submitted
730
+			|| $quiz_grade_type != 'auto' ) {
731
+			return false; // exit early
732
+		}
733
+
734
+
735
+		$user_id = get_current_user_id();
736
+		$lesson_id =  Sensei()->quiz->get_lesson_id(  $quiz_id ) ;
737
+		$quiz_autogradable = true;
738
+
739
+		/**
740
+		 * Filter the types of question types that can be automatically graded.
741
+		 *
742
+		 * This filter fires inside the auto grade quiz function and provides you with the default list.
743
+		 *
744
+		 * @param array {
745
+		 *      'multiple-choice',
746
+		 *      'boolean',
747
+		 *      'gap-fill'.
748
+		 * }
749
+		 */
750
+		$autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) );
751
+
752
+		$grade_total = 0;
753
+		$all_question_grades = array();
754
+		foreach( $submitted as $question_id => $answer ) {
755
+
756
+			// check if the question is autogradable, either by type, or because the grade is 0
757
+			$question_type = Sensei()->question->get_question_type( $question_id );
758 758
 			$achievable_grade = Sensei()->question->get_question_grade( $question_id );
759 759
 			// Question has a zero grade, so skip grading
760 760
 			if ( 0 == $achievable_grade ) {
761 761
 				$all_question_grades[ $question_id ] = $achievable_grade;
762 762
 			}
763
-            elseif ( in_array( $question_type, $autogradable_question_types ) ) {
764
-                // Get user question grade
765
-                $question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id );
766
-                $all_question_grades[ $question_id ] = $question_grade;
767
-                $grade_total += $question_grade;
763
+			elseif ( in_array( $question_type, $autogradable_question_types ) ) {
764
+				// Get user question grade
765
+				$question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id );
766
+				$all_question_grades[ $question_id ] = $question_grade;
767
+				$grade_total += $question_grade;
768 768
 
769
-            } else {
769
+			} else {
770 770
 
771
-                // There is a question that cannot be autograded
772
-                $quiz_autogradable = false;
771
+				// There is a question that cannot be autograded
772
+				$quiz_autogradable = false;
773 773
 
774
-            } // end if in_array( $question_type...
774
+			} // end if in_array( $question_type...
775 775
 
776
-        }// end for each question
776
+		}// end for each question
777 777
 
778
-        // Only if the whole quiz was autogradable do we set a grade
779
-        if ( $quiz_autogradable ) {
778
+		// Only if the whole quiz was autogradable do we set a grade
779
+		if ( $quiz_autogradable ) {
780 780
 
781
-            $quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id );
781
+			$quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id );
782 782
 			// Check for zero total from grades
783 783
 			if ( 0 < $quiz_total ) {
784
-            $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
784
+			$grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
785 785
 			}
786 786
 			else {
787 787
 				$grade = 0;
788 788
 			}
789
-            Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type );
789
+			Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type );
790 790
 
791
-        } else {
791
+		} else {
792 792
 
793
-            $grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) );
793
+			$grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) );
794 794
 
795
-        }
796
-
797
-        // store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default
798
-        // when doing manual grading.
799
-        Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id );
795
+		}
800 796
 
801
-        return $grade;
797
+		// store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default
798
+		// when doing manual grading.
799
+		Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id );
802 800
 
803
-    } // End grade_quiz_auto()
801
+		return $grade;
804 802
 
805
-    /**
806
-     * Grade question automatically
807
-     *
808
-     * This function checks the question typ and then grades it accordingly.
809
-     *
810
-     * @since 1.7.4
811
-     *
812
-     * @param integer $question_id
813
-     * @param string $question_type of the standard Sensei question types
814
-     * @param string $answer
815
-     * @param int $user_id
816
-     *
817
-     * @return int $question_grade
818
-     */
819
-    public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
820
-
821
-        if( intval( $user_id ) == 0 ) {
822
-
823
-            $user_id = get_current_user_id();
824
-
825
-        }
826
-
827
-        if( ! ( intval( $question_id ) > 0 ) ) {
828
-
829
-            return false;
830
-
831
-        }
832
-
833
-
834
-        Sensei()->question->get_question_type( $question_id );
835
-
836
-        /**
837
-         * Applying a grade before the auto grading takes place.
838
-         *
839
-         * This filter is applied just before the question is auto graded. It fires in the context of a single question
840
-         * in the sensei_grade_question_auto function. It fires irrespective of the question type. If you return a value
841
-         * other than false the auto grade functionality will be ignored and your supplied grade will be user for this question.
842
-         *
843
-         * @param int $question_grade default false
844
-         * @param int $question_id
845
-         * @param string $question_type one of the Sensei question type.
846
-         * @param string $answer user supplied question answer
847
-         */
848
-        $question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer );
803
+	} // End grade_quiz_auto()
849 804
 
850
-        if ( false !== $question_grade ) {
805
+	/**
806
+	 * Grade question automatically
807
+	 *
808
+	 * This function checks the question typ and then grades it accordingly.
809
+	 *
810
+	 * @since 1.7.4
811
+	 *
812
+	 * @param integer $question_id
813
+	 * @param string $question_type of the standard Sensei question types
814
+	 * @param string $answer
815
+	 * @param int $user_id
816
+	 *
817
+	 * @return int $question_grade
818
+	 */
819
+	public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
851 820
 
852
-            return $question_grade;
821
+		if( intval( $user_id ) == 0 ) {
853 822
 
854
-        }
823
+			$user_id = get_current_user_id();
855 824
 
856
-        // auto grading core
857
-        if( in_array( $question_type ,  array( 'multiple-choice'  , 'boolean'  ) )   ){
825
+		}
858 826
 
859
-            $right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true );
827
+		if( ! ( intval( $question_id ) > 0 ) ) {
860 828
 
861
-            if( 0 == get_magic_quotes_gpc() ) {
862
-                $answer = wp_unslash( $answer );
863
-            }
864
-            $answer = (array) $answer;
865
-            if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) {
866
-                // Loop through all answers ensure none are 'missing'
867
-                $all_correct = true;
868
-                foreach ( $answer as $check_answer ) {
869
-                    if ( !in_array( $check_answer, $right_answer ) ) {
870
-                        $all_correct = false;
871
-                    }
872
-                }
873
-                // If all correct then grade
874
-                if ( $all_correct ) {
875
-                    $question_grade = Sensei()->question->get_question_grade( $question_id );
876
-                }
877
-            }
829
+			return false;
878 830
 
879
-        } elseif( 'gap-fill' == $question_type ){
831
+		}
880 832
 
881
-            $question_grade = self::grade_gap_fill_question( $question_id ,$answer );
882 833
 
883
-        } else{
834
+		Sensei()->question->get_question_type( $question_id );
884 835
 
885
-            /**
886
-             * Grading questions that are not auto gradable.
887
-             *
888
-             * This filter is applied the context of ta single question within the sensei_grade_question_auto function.
889
-             * It fires for all other questions types. It does not apply to 'multiple-choice'  , 'boolean' and gap-fill.
890
-             *
891
-             * @param int $question_grade default zero
892
-             * @param int $question_id
893
-             * @param string $question_type one of the Sensei question type.
894
-             * @param string $answer user supplied question answer
895
-             */
896
-            $question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer );
836
+		/**
837
+		 * Applying a grade before the auto grading takes place.
838
+		 *
839
+		 * This filter is applied just before the question is auto graded. It fires in the context of a single question
840
+		 * in the sensei_grade_question_auto function. It fires irrespective of the question type. If you return a value
841
+		 * other than false the auto grade functionality will be ignored and your supplied grade will be user for this question.
842
+		 *
843
+		 * @param int $question_grade default false
844
+		 * @param int $question_id
845
+		 * @param string $question_type one of the Sensei question type.
846
+		 * @param string $answer user supplied question answer
847
+		 */
848
+		$question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer );
897 849
 
898
-        } // end if $question_type
850
+		if ( false !== $question_grade ) {
899 851
 
900
-        return $question_grade;
901
-    } // end grade_question_auto
852
+			return $question_grade;
902 853
 
903
-    /**
904
-     * Grading logic specifically for the gap fill questions
905
-     *
906
-     * @since 1.9.0
907
-     * @param $question_id
908
-     * @param $user_answer
909
-     *
910
-     * @return bool | int false or the grade given to the user answer
911
-     */
912
-    public static function grade_gap_fill_question( $question_id, $user_answer ){
854
+		}
913 855
 
914
-        $right_answer = get_post_meta( $question_id, '_question_right_answer', true );
915
-        $gapfill_array = explode( '||', $right_answer );
856
+		// auto grading core
857
+		if( in_array( $question_type ,  array( 'multiple-choice'  , 'boolean'  ) )   ){
916 858
 
917
-        if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2
918
-            $user_answer = wp_unslash( $user_answer );
919
-        }
859
+			$right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true );
920 860
 
921
-        /**
922
-         * case sensitive grading filter
923
-         *
924
-         * alter the value simply use this code in your plugin or the themes functions.php
925
-         * add_filter( 'sensei_gap_fill_case_sensitive_grading','__return_true' );
926
-         *
927
-         * @param bool $do_case_sensitive_comparison default false.
928
-         *
929
-         * @since 1.9.0
930
-         */
931
-        $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false );
861
+			if( 0 == get_magic_quotes_gpc() ) {
862
+				$answer = wp_unslash( $answer );
863
+			}
864
+			$answer = (array) $answer;
865
+			if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) {
866
+				// Loop through all answers ensure none are 'missing'
867
+				$all_correct = true;
868
+				foreach ( $answer as $check_answer ) {
869
+					if ( !in_array( $check_answer, $right_answer ) ) {
870
+						$all_correct = false;
871
+					}
872
+				}
873
+				// If all correct then grade
874
+				if ( $all_correct ) {
875
+					$question_grade = Sensei()->question->get_question_grade( $question_id );
876
+				}
877
+			}
932 878
 
933
-        if( $do_case_sensitive_comparison ){
879
+		} elseif( 'gap-fill' == $question_type ){
934 880
 
935
-            // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
936
-            if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) {
881
+			$question_grade = self::grade_gap_fill_question( $question_id ,$answer );
937 882
 
938
-                return Sensei()->question->get_question_grade( $question_id );
883
+		} else{
939 884
 
940
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
885
+			/**
886
+			 * Grading questions that are not auto gradable.
887
+			 *
888
+			 * This filter is applied the context of ta single question within the sensei_grade_question_auto function.
889
+			 * It fires for all other questions types. It does not apply to 'multiple-choice'  , 'boolean' and gap-fill.
890
+			 *
891
+			 * @param int $question_grade default zero
892
+			 * @param int $question_id
893
+			 * @param string $question_type one of the Sensei question type.
894
+			 * @param string $answer user supplied question answer
895
+			 */
896
+			$question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer );
941 897
 
942
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
898
+		} // end if $question_type
943 899
 
944
-                    return Sensei()->question->get_question_grade($question_id);
900
+		return $question_grade;
901
+	} // end grade_question_auto
945 902
 
946
-                }else{
903
+	/**
904
+	 * Grading logic specifically for the gap fill questions
905
+	 *
906
+	 * @since 1.9.0
907
+	 * @param $question_id
908
+	 * @param $user_answer
909
+	 *
910
+	 * @return bool | int false or the grade given to the user answer
911
+	 */
912
+	public static function grade_gap_fill_question( $question_id, $user_answer ){
947 913
 
948
-                    return false;
914
+		$right_answer = get_post_meta( $question_id, '_question_right_answer', true );
915
+		$gapfill_array = explode( '||', $right_answer );
949 916
 
950
-                }
917
+		if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2
918
+			$user_answer = wp_unslash( $user_answer );
919
+		}
951 920
 
952
-            }else{
921
+		/**
922
+		 * case sensitive grading filter
923
+		 *
924
+		 * alter the value simply use this code in your plugin or the themes functions.php
925
+		 * add_filter( 'sensei_gap_fill_case_sensitive_grading','__return_true' );
926
+		 *
927
+		 * @param bool $do_case_sensitive_comparison default false.
928
+		 *
929
+		 * @since 1.9.0
930
+		 */
931
+		$do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false );
953 932
 
954
-                return false;
933
+		if( $do_case_sensitive_comparison ){
955 934
 
956
-            }
935
+			// Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
936
+			if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) {
957 937
 
958
-        }else{
938
+				return Sensei()->question->get_question_grade( $question_id );
959 939
 
960
-            // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
961
-            if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) {
940
+			} else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
962 941
 
963
-               return Sensei()->question->get_question_grade( $question_id );
942
+				if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
964 943
 
965
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
944
+					return Sensei()->question->get_question_grade($question_id);
966 945
 
967
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
946
+				}else{
968 947
 
969
-                    return  Sensei()->question->get_question_grade( $question_id );
948
+					return false;
970 949
 
971
-                }else{
950
+				}
972 951
 
973
-                    return false;
952
+			}else{
974 953
 
975
-                }
954
+				return false;
976 955
 
977
-            }else{
956
+			}
957
+
958
+		}else{
959
+
960
+			// Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
961
+			if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) {
962
+
963
+			   return Sensei()->question->get_question_grade( $question_id );
964
+
965
+			} else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
966
+
967
+				if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
968
+
969
+					return  Sensei()->question->get_question_grade( $question_id );
970
+
971
+				}else{
972
+
973
+					return false;
974
+
975
+				}
978 976
 
979
-                return false;
977
+			}else{
978
+
979
+				return false;
980
+
981
+			}
982
+
983
+		}
984
+
985
+	}
986
+
987
+	/**
988
+	 * Counts the lessons that have been graded manually and automatically
989
+	 *
990
+	 * @since 1.9.0
991
+	 * @return int $number_of_graded_lessons
992
+	 */
993
+	public static function get_graded_lessons_count(){
980 994
 
981
-            }
995
+		global $wpdb;
982 996
 
983
-        }
997
+		$comment_query_piece[ 'select']  = "SELECT   COUNT(*) AS total";
998
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
999
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1000
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
984 1001
 
985
-    }
1002
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1003
+		$number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
986 1004
 
987
-    /**
988
-     * Counts the lessons that have been graded manually and automatically
989
-     *
990
-     * @since 1.9.0
991
-     * @return int $number_of_graded_lessons
992
-     */
993
-    public static function get_graded_lessons_count(){
1005
+		return $number_of_graded_lessons;
1006
+	}
994 1007
 
995
-        global $wpdb;
1008
+	/**
1009
+	 * Add together all the graded lesson grades
1010
+	 *
1011
+	 * @since 1.9.0
1012
+	 * @return double $sum_of_all_grades
1013
+	 */
1014
+	public static function get_graded_lessons_sum(){
996 1015
 
997
-        $comment_query_piece[ 'select']  = "SELECT   COUNT(*) AS total";
998
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
999
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1000
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1016
+		global $wpdb;
1001 1017
 
1002
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1003
-        $number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1018
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1019
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1020
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1021
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1004 1022
 
1005
-        return $number_of_graded_lessons;
1006
-    }
1023
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1024
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1007 1025
 
1008
-    /**
1009
-     * Add together all the graded lesson grades
1010
-     *
1011
-     * @since 1.9.0
1012
-     * @return double $sum_of_all_grades
1013
-     */
1014
-    public static function get_graded_lessons_sum(){
1026
+		return $sum_of_all_grades;
1015 1027
 
1016
-        global $wpdb;
1028
+	}
1017 1029
 
1018
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1019
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1020
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1021
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1030
+	/**
1031
+	 * Get the sum of all grades for the given user.
1032
+	 *
1033
+	 * @since 1.9.0
1034
+	 * @param $user_id
1035
+	 * @return double
1036
+	 */
1037
+	public static function get_user_graded_lessons_sum( $user_id ){
1038
+		global $wpdb;
1022 1039
 
1023
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1024
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1040
+		$clean_user_id = esc_sql( $user_id);
1041
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1042
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1043
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} ";
1044
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1025 1045
 
1026
-        return $sum_of_all_grades;
1046
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1047
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1027 1048
 
1028
-    }
1049
+		return $sum_of_all_grades;
1050
+	}
1029 1051
 
1030
-    /**
1031
-     * Get the sum of all grades for the given user.
1032
-     *
1033
-     * @since 1.9.0
1034
-     * @param $user_id
1035
-     * @return double
1036
-     */
1037
-    public static function get_user_graded_lessons_sum( $user_id ){
1038
-        global $wpdb;
1052
+	/**
1053
+	 * Get the sum of all user grades for the given lesson.
1054
+	 *
1055
+	 * @since 1.9.0
1056
+	 *
1057
+	 * @param int lesson_id
1058
+	 * @return double
1059
+	 */
1060
+	public static function get_lessons_users_grades_sum( $lesson_id ){
1039 1061
 
1040
-        $clean_user_id = esc_sql( $user_id);
1041
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1042
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1043
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} ";
1044
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1062
+		global $wpdb;
1045 1063
 
1046
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1047
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1064
+		$clean_lesson_id = esc_sql( $lesson_id);
1065
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1066
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1067
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} ";
1068
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1048 1069
 
1049
-        return $sum_of_all_grades;
1050
-    }
1070
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1071
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1051 1072
 
1052
-    /**
1053
-     * Get the sum of all user grades for the given lesson.
1054
-     *
1055
-     * @since 1.9.0
1056
-     *
1057
-     * @param int lesson_id
1058
-     * @return double
1059
-     */
1060
-    public static function get_lessons_users_grades_sum( $lesson_id ){
1073
+		return $sum_of_all_grades;
1061 1074
 
1062
-        global $wpdb;
1075
+	}//get_lessons_user_grades_sum
1063 1076
 
1064
-        $clean_lesson_id = esc_sql( $lesson_id);
1065
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1066
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1067
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} ";
1068
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1077
+	/**
1078
+	 * Get the sum of all user grades for the given course.
1079
+	 *
1080
+	 * @since 1.9.0
1081
+	 *
1082
+	 * @param int $course_id
1083
+	 * @return double
1084
+	 */
1085
+	public static function get_course_users_grades_sum( $course_id ){
1069 1086
 
1070
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1071
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1087
+		global $wpdb;
1072 1088
 
1073
-        return $sum_of_all_grades;
1089
+		$clean_course_id = esc_sql( $course_id);
1090
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1091
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1092
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} ";
1093
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1074 1094
 
1075
-    }//get_lessons_user_grades_sum
1095
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1096
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1076 1097
 
1077
-    /**
1078
-     * Get the sum of all user grades for the given course.
1079
-     *
1080
-     * @since 1.9.0
1081
-     *
1082
-     * @param int $course_id
1083
-     * @return double
1084
-     */
1085
-    public static function get_course_users_grades_sum( $course_id ){
1086
-
1087
-        global $wpdb;
1088
-
1089
-        $clean_course_id = esc_sql( $course_id);
1090
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1091
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1092
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} ";
1093
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1098
+		return $sum_of_all_grades;
1094 1099
 
1095
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1096
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1097
-
1098
-        return $sum_of_all_grades;
1099
-
1100
-    }//get_lessons_user_grades_sum
1100
+	}//get_lessons_user_grades_sum
1101 1101
 
1102 1102
 } // End Class
1103 1103
 
Please login to merge, or discard this patch.
includes/class-sensei-notices.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 class Sensei_Notices{
15 15
 
16 16
 	/**
17
-	*  @var $notices
18
-	*/
17
+	 *  @var $notices
18
+	 */
19 19
 	protected $notices;
20 20
 
21 21
 	/**
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 	protected $has_printed;
25 25
 
26 26
 	/**
27
-	*  constructor 
28
- 	*/
27
+	 *  constructor 
28
+	 */
29 29
 	public function __construct(){
30 30
 		//initialize the notices variable
31 31
 		$this->notices = array();
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	} // end print_notice()
80 80
 
81 81
 	/**
82
-	*  Clear all notices  
83
-	* 
84
-	* @return void
85
-	*/
82
+	 *  Clear all notices  
83
+	 * 
84
+	 * @return void
85
+	 */
86 86
 	public function clear_notices(){
87 87
 		// assign an empty array to clear all existing notices
88 88
 		$this->notices = array();
Please login to merge, or discard this patch.
includes/class-sensei-templates.php 1 patch
Indentation   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -12,662 +12,662 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Sensei_Templates {
14 14
 
15
-    /**
16
-     *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
17
-     *
18
-     * @since 1.9.0
19
-     * @param string $slug
20
-     * @param string $name default: ''
21
-     *
22
-     * @return void
23
-     */
24
-    public static function get_part(  $slug, $name = ''  ){
15
+	/**
16
+	 *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
17
+	 *
18
+	 * @since 1.9.0
19
+	 * @param string $slug
20
+	 * @param string $name default: ''
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public static function get_part(  $slug, $name = ''  ){
25
+
26
+		$template = '';
27
+		$plugin_template_url = Sensei()->template_url;
28
+		$plugin_template_path = Sensei()->plugin_path() . "/templates/";
29
+
30
+		// Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
+		if ( $name ){
32
+
33
+			$template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
25 34
 
26
-        $template = '';
27
-        $plugin_template_url = Sensei()->template_url;
28
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
29
-
30
-        // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
-        if ( $name ){
32
-
33
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
34
-
35
-        }
35
+		}
36 36
 
37
-        // Get default slug-name.php
38
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
37
+		// Get default slug-name.php
38
+		if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
39 39
 
40
-            $template = $plugin_template_path . "{$slug}-{$name}.php";
40
+			$template = $plugin_template_path . "{$slug}-{$name}.php";
41 41
 
42
-        }
42
+		}
43 43
 
44 44
 
45
-        // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
-        if ( !$template ){
45
+		// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
+		if ( !$template ){
47 47
 
48
-            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
48
+			$template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
49 49
 
50
-        }
50
+		}
51 51
 
52 52
 
53
-        if ( $template ){
53
+		if ( $template ){
54 54
 
55
-            load_template( $template, false );
55
+			load_template( $template, false );
56 56
 
57
-        }
57
+		}
58 58
 
59
-    } // end get part
59
+	} // end get part
60 60
 
61
-    /**
62
-     * Get the template.
63
-     *
64
-     * @since 1.9.0
65
-     *
66
-     * @param $template_name
67
-     * @param array $args
68
-     * @param string $template_path
69
-     * @param string $default_path
70
-     */
71
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
61
+	/**
62
+	 * Get the template.
63
+	 *
64
+	 * @since 1.9.0
65
+	 *
66
+	 * @param $template_name
67
+	 * @param array $args
68
+	 * @param string $template_path
69
+	 * @param string $default_path
70
+	 */
71
+	public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
72 72
 
73
-        if ( $args && is_array($args) )
74
-            extract( $args );
73
+		if ( $args && is_array($args) )
74
+			extract( $args );
75 75
 
76
-        $located = self::locate_template( $template_name, $template_path, $default_path );
76
+		$located = self::locate_template( $template_name, $template_path, $default_path );
77 77
 
78
-        if( ! empty( $located ) ){
78
+		if( ! empty( $located ) ){
79 79
 
80
-            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
80
+			do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
81 81
 
82
-            include( $located );
82
+			include( $located );
83 83
 
84
-            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
84
+			do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
85 85
 
86
-        }
86
+		}
87 87
 
88
-    } // end get template
88
+	} // end get template
89
+
90
+	/**
91
+	 * Check if the template file exists. A wrapper for WP locate_template.
92
+	 *
93
+	 * @since 1.9.0
94
+	 *
95
+	 * @param $template_name
96
+	 * @param string $template_path
97
+	 * @param string $default_path
98
+	 *
99
+	 * @return mixed|void
100
+	 */
101
+	public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
102
+
103
+		if ( ! $template_path ) $template_path = Sensei()->template_url;
104
+		if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
105
+
106
+		// Look within passed path within the theme - this is priority
107
+		$template = locate_template(
108
+			array(
109
+				$template_path . $template_name,
110
+				$template_name
111
+			)
112
+		);
113
+
114
+		// Get default template
115
+		if ( ! $template ){
116
+
117
+			$template = $default_path . $template_name;
89 118
 
90
-    /**
91
-     * Check if the template file exists. A wrapper for WP locate_template.
92
-     *
93
-     * @since 1.9.0
94
-     *
95
-     * @param $template_name
96
-     * @param string $template_path
97
-     * @param string $default_path
98
-     *
99
-     * @return mixed|void
100
-     */
101
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
119
+		}
120
+		// return nothing for file that do not exist
121
+		if( !file_exists( $template ) ){
122
+			$template = '';
123
+		}
102 124
 
103
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
104
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
125
+		// Return what we found
126
+		return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
105 127
 
106
-        // Look within passed path within the theme - this is priority
107
-        $template = locate_template(
108
-            array(
109
-                $template_path . $template_name,
110
-                $template_name
111
-            )
112
-        );
128
+	} // end locate
113 129
 
114
-        // Get default template
115
-        if ( ! $template ){
130
+	/**
131
+	 * Determine which Sensei template to load based on the
132
+	 * current page context.
133
+	 *
134
+	 * @since 1.0
135
+	 *
136
+	 * @param string $template
137
+	 * @return string $template
138
+	 */
139
+	public static function template_loader ( $template = '' ) {
116 140
 
117
-            $template = $default_path . $template_name;
141
+		global $wp_query, $email_template;
118 142
 
119
-        }
120
-        // return nothing for file that do not exist
121
-        if( !file_exists( $template ) ){
122
-            $template = '';
123
-        }
143
+		$find = array( 'woothemes-sensei.php' );
144
+		$file = '';
124 145
 
125
-        // Return what we found
126
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
146
+		if ( isset( $email_template ) && $email_template ) {
127 147
 
128
-    } // end locate
148
+			$file 	= 'emails/' . $email_template;
149
+			$find[] = $file;
150
+			$find[] = Sensei()->template_url . $file;
129 151
 
130
-    /**
131
-     * Determine which Sensei template to load based on the
132
-     * current page context.
133
-     *
134
-     * @since 1.0
135
-     *
136
-     * @param string $template
137
-     * @return string $template
138
-     */
139
-    public static function template_loader ( $template = '' ) {
152
+		} elseif ( is_single() && get_post_type() == 'course' ) {
140 153
 
141
-        global $wp_query, $email_template;
154
+			// possible backward compatible template include if theme overrides content-single-course.php
155
+			// this template was removed in 1.9.0 and code all moved into the main single-course.php file
156
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
142 157
 
143
-        $find = array( 'woothemes-sensei.php' );
144
-        $file = '';
158
+			$file 	= 'single-course.php';
159
+			$find[] = $file;
160
+			$find[] = Sensei()->template_url . $file;
145 161
 
146
-        if ( isset( $email_template ) && $email_template ) {
147 162
 
148
-            $file 	= 'emails/' . $email_template;
149
-            $find[] = $file;
150
-            $find[] = Sensei()->template_url . $file;
163
+		} elseif ( is_single() && get_post_type() == 'lesson' ) {  // check
151 164
 
152
-        } elseif ( is_single() && get_post_type() == 'course' ) {
165
+			// possible backward compatible template include if theme overrides content-single-lesson.php
166
+			// this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
167
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
153 168
 
154
-            // possible backward compatible template include if theme overrides content-single-course.php
155
-            // this template was removed in 1.9.0 and code all moved into the main single-course.php file
156
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
169
+			$file 	= 'single-lesson.php';
170
+			$find[] = $file;
171
+			$find[] = Sensei()->template_url . $file;
157 172
 
158
-            $file 	= 'single-course.php';
159
-            $find[] = $file;
160
-            $find[] = Sensei()->template_url . $file;
173
+		} elseif ( is_single() && get_post_type() == 'quiz' ) {  // check
161 174
 
175
+			// possible backward compatible template include if theme overrides content-single-quiz.php
176
+			// this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
177
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
162 178
 
163
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {  // check
179
+			$file 	= 'single-quiz.php';
180
+			$find[] = $file;
181
+			$find[] = Sensei()->template_url . $file;
164 182
 
165
-            // possible backward compatible template include if theme overrides content-single-lesson.php
166
-            // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
167
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
168 183
 
169
-            $file 	= 'single-lesson.php';
170
-            $find[] = $file;
171
-            $find[] = Sensei()->template_url . $file;
184
+		} elseif ( is_single() && get_post_type() == 'sensei_message' ) { //// check
172 185
 
173
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {  // check
186
+			// possible backward compatible template include if theme overrides content-single-message.php
187
+			// this template was removed in 1.9.0 and code all moved into the main single-message.php file
188
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
174 189
 
175
-            // possible backward compatible template include if theme overrides content-single-quiz.php
176
-            // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
177
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
190
+			$file 	= 'single-message.php';
191
+			$find[] = $file;
192
+			$find[] = Sensei()->template_url . $file;
178 193
 
179
-            $file 	= 'single-quiz.php';
180
-            $find[] = $file;
181
-            $find[] = Sensei()->template_url . $file;
194
+		} elseif ( is_post_type_archive( 'course' )
195
+					|| is_page( Sensei()->get_page_id( 'courses' ) )
196
+					|| is_tax( 'course-category' )) {
182 197
 
198
+			// possible backward compatible template include if theme overrides 'taxonomy-course-category'
199
+			// this template was removed in 1.9.0 and replaced by archive-course.php
200
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
183 201
 
184
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) { //// check
202
+			$file 	= 'archive-course.php';
203
+			$find[] = $file;
204
+			$find[] = Sensei()->template_url . $file;
185 205
 
186
-            // possible backward compatible template include if theme overrides content-single-message.php
187
-            // this template was removed in 1.9.0 and code all moved into the main single-message.php file
188
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
206
+		} elseif ( is_post_type_archive( 'sensei_message' ) ) {
189 207
 
190
-            $file 	= 'single-message.php';
191
-            $find[] = $file;
192
-            $find[] = Sensei()->template_url . $file;
208
+			$file 	= 'archive-message.php';
209
+			$find[] = $file;
210
+			$find[] = Sensei()->template_url . $file;
193 211
 
194
-        } elseif ( is_post_type_archive( 'course' )
195
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
196
-                    || is_tax( 'course-category' )) {
212
+		} elseif( is_tax( 'lesson-tag' ) ) {
197 213
 
198
-            // possible backward compatible template include if theme overrides 'taxonomy-course-category'
199
-            // this template was removed in 1.9.0 and replaced by archive-course.php
200
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
214
+			// possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
215
+			// this template was removed in 1.9.0 and replaced by archive-lesson.php
216
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
201 217
 
202
-            $file 	= 'archive-course.php';
203
-            $find[] = $file;
204
-            $find[] = Sensei()->template_url . $file;
218
+			$file 	= 'archive-lesson.php';
219
+			$find[] = $file;
220
+			$find[] = Sensei()->template_url . $file;
205 221
 
206
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
222
+		} elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
207 223
 
208
-            $file 	= 'archive-message.php';
209
-            $find[] = $file;
210
-            $find[] = Sensei()->template_url . $file;
224
+			// Override for sites with static home page
225
+			$wp_query->is_home = false;
211 226
 
212
-        } elseif( is_tax( 'lesson-tag' ) ) {
227
+			$file 	= 'learner-profile.php';
228
+			$find[] = $file;
229
+			$find[] = Sensei()->template_url . $file;
213 230
 
214
-            // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
215
-            // this template was removed in 1.9.0 and replaced by archive-lesson.php
216
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
231
+		} elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
217 232
 
218
-            $file 	= 'archive-lesson.php';
219
-            $find[] = $file;
220
-            $find[] = Sensei()->template_url . $file;
233
+			// Override for sites with static home page
234
+			$wp_query->is_home = false;
221 235
 
222
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
236
+			$file = 'course-results.php';
237
+			$find[] = $file;
238
+			$find[] = Sensei()->template_url . $file;
223 239
 
224
-            // Override for sites with static home page
225
-            $wp_query->is_home = false;
240
+		}elseif( is_author()
241
+				 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
242
+				 && ! user_can( get_query_var('author'), 'manage_options' ) ){
226 243
 
227
-            $file 	= 'learner-profile.php';
228
-            $find[] = $file;
229
-            $find[] = Sensei()->template_url . $file;
244
+			$file = 'teacher-archive.php';
245
+			$find[] = $file;
246
+			$find[] = Sensei()->template_url . $file;
230 247
 
231
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
248
+		} // Load the template file
232 249
 
233
-            // Override for sites with static home page
234
-            $wp_query->is_home = false;
250
+		// if file is present set it to be loaded otherwise continue with the initial template given by WP
251
+		if ( $file ) {
235 252
 
236
-            $file = 'course-results.php';
237
-            $find[] = $file;
238
-            $find[] = Sensei()->template_url . $file;
253
+			$template = locate_template( $find );
254
+			if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
239 255
 
240
-        }elseif( is_author()
241
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
242
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
256
+		} // End If Statement
243 257
 
244
-            $file = 'teacher-archive.php';
245
-            $find[] = $file;
246
-            $find[] = Sensei()->template_url . $file;
258
+		return $template;
247 259
 
248
-        } // Load the template file
260
+	} // End template_loader()
249 261
 
250
-	    // if file is present set it to be loaded otherwise continue with the initial template given by WP
251
-        if ( $file ) {
262
+	/**
263
+	 * This function loads the no-permissions template for users with no access
264
+	 * if a Sensei template was loaded.
265
+	 *
266
+	 * This function doesn't determine the permissions. Permissions must be determined
267
+	 * before loading this function as it only gets the template.
268
+	 *
269
+	 * This function also checks the user theme for overrides to ensure the right template
270
+	 * file is returned.
271
+	 *
272
+	 * @since 1.9.0
273
+	 */
274
+	public static function get_no_permission_template( ){
252 275
 
253
-            $template = locate_template( $find );
254
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
276
+		// possible backward compatible template loading
277
+		// this template was removed in 1.9.0 and code all moved into the no-permissions.php file
278
+		self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
255 279
 
256
-        } // End If Statement
280
+		$file 	= 'no-permissions.php';
281
+		$find[] = $file;
282
+		$find[] = Sensei()->template_url . $file;
257 283
 
258
-        return $template;
284
+		$template = locate_template( $find );
285
+		if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
259 286
 
260
-    } // End template_loader()
287
+		// set a global constant so that we know that we're in this template
288
+		define('SENSEI_NO_PERMISSION', true );
261 289
 
262
-    /**
263
-     * This function loads the no-permissions template for users with no access
264
-     * if a Sensei template was loaded.
265
-     *
266
-     * This function doesn't determine the permissions. Permissions must be determined
267
-     * before loading this function as it only gets the template.
268
-     *
269
-     * This function also checks the user theme for overrides to ensure the right template
270
-     * file is returned.
271
-     *
272
-     * @since 1.9.0
273
-     */
274
-    public static function get_no_permission_template( ){
290
+		return $template;
275 291
 
276
-        // possible backward compatible template loading
277
-        // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
278
-        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
292
+	}
279 293
 
280
-        $file 	= 'no-permissions.php';
281
-        $find[] = $file;
282
-        $find[] = Sensei()->template_url . $file;
294
+	/**
295
+	 * This function is specifically created for loading template files from the theme.
296
+	 *
297
+	 * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
298
+	 * around the singular content file from their theme and exit.
299
+	 *
300
+	 * If none is found this function will do nothing. If a template is found this funciton
301
+	 * will exit execution of the script an not continue.
302
+	 *
303
+	 * @since 1.9.0
304
+	 * @param string $template
305
+	 * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
306
+	 */
307
+	public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
283 308
 
284
-        $template = locate_template( $find );
285
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
309
+		$found_template = locate_template( array( $template ) );
310
+		if( $found_template ){
286 311
 
287
-	    // set a global constant so that we know that we're in this template
288
-	    define('SENSEI_NO_PERMISSION', true );
312
+			if( $load_header_footer ){
289 313
 
290
-        return $template;
314
+				get_sensei_header();
315
+				include( $found_template );
316
+				get_sensei_footer();
291 317
 
292
-    }
318
+			}else{
293 319
 
294
-    /**
295
-     * This function is specifically created for loading template files from the theme.
296
-     *
297
-     * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
298
-     * around the singular content file from their theme and exit.
299
-     *
300
-     * If none is found this function will do nothing. If a template is found this funciton
301
-     * will exit execution of the script an not continue.
302
-     *
303
-     * @since 1.9.0
304
-     * @param string $template
305
-     * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
306
-     */
307
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
320
+				include( $found_template );
308 321
 
309
-        $found_template = locate_template( array( $template ) );
310
-        if( $found_template ){
322
+			}
311 323
 
312
-            if( $load_header_footer ){
324
+			exit;
313 325
 
314
-                get_sensei_header();
315
-                include( $found_template );
316
-                get_sensei_footer();
317
-
318
-            }else{
319
-
320
-                include( $found_template );
321
-
322
-            }
323
-
324
-            exit;
325
-
326
-        }
327
-
328
-    }
326
+		}
329 327
 
328
+	}
330 329
 
331
-    /**
332
-     * Hooks the deprecated archive content hook into the hook again just in
333
-     * case other developers have used it.
334
-     *
335
-     * @deprecated since 1.9.0
336
-     */
337
-    public static function deprecated_archive_course_content_hook(){
338
-
339
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
340
-
341
-    }// end deprecated_archive_hook
342 330
 
343
-    /**
344
-     * A generic function for echoing the post title
345
-     *
346
-     * @since 1.9.0
347
-     * @param  WP_Post $post
348
-     */
349
-    public static function the_title( $post ){
350
-
351
-        // ID passed in
352
-        if( is_numeric( $post ) ){
353
-            $post = get_post( $post );
354
-        }
355
-
356
-        /**
357
-         * Filter the template html tag for the title
358
-         *
359
-         * @since 1.9.0
360
-         *
361
-         * @param $title_html_tag default is 'h3'
362
-         */
363
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
364
-
365
-        /**
366
-         * Filter the title classes
367
-         *
368
-         * @since 1.9.0
369
-         * @param string $title_classes defaults to $post_type-title
370
-         */
371
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
331
+	/**
332
+	 * Hooks the deprecated archive content hook into the hook again just in
333
+	 * case other developers have used it.
334
+	 *
335
+	 * @deprecated since 1.9.0
336
+	 */
337
+	public static function deprecated_archive_course_content_hook(){
372 338
 
373
-        $html= '';
374
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
375
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
376
-        $html .= $post->post_title ;
377
-        $html .= '</a>';
378
-        $html .= '</'. $title_html_tag. '>';
379
-        echo $html;
380
-
381
-    }// end the title
382
-
383
-    /**
384
-     * This function adds the hooks inside and above the single course content for
385
-     * backwards compatibility sake.
386
-     *
387
-     * @since 1.9.0
388
-     * @deprecated 1.9.0
389
-     */
390
-    public static function deprecated_single_course_inside_before_hooks(){
391
-
392
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
393
-        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
394
-        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
395
-
396
-    }// end deprecated_single_course_inside_before_hooks
397
-
398
-    /**
399
-     * This function adds the hooks to sensei_course_single_lessons for
400
-     * backwards compatibility sake.  and provides developers with an alternative.
401
-     *
402
-     * @since 1.9.0
403
-     * @deprecated 1.9.0
404
-     */
405
-    public static function deprecate_sensei_course_single_lessons_hook(){
339
+		sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
406 340
 
407
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
341
+	}// end deprecated_archive_hook
408 342
 
409
-    }// deprecate_sensei_course_single_lessons_hook
343
+	/**
344
+	 * A generic function for echoing the post title
345
+	 *
346
+	 * @since 1.9.0
347
+	 * @param  WP_Post $post
348
+	 */
349
+	public static function the_title( $post ){
410 350
 
411
-    /**
412
-     * Deprecated all deprecated_single_main_content_hook hooked actions.
413
-     *
414
-     * The content must be dealt with inside the respective templates.
415
-     *
416
-     * @since 1.9.0
417
-     * @deprecated 1.9.0
418
-     */
419
-    public static function deprecated_single_main_content_hook(){
351
+		// ID passed in
352
+		if( is_numeric( $post ) ){
353
+			$post = get_post( $post );
354
+		}
420 355
 
421
-            if( is_singular( 'course' ) ) {
356
+		/**
357
+		 * Filter the template html tag for the title
358
+		 *
359
+		 * @since 1.9.0
360
+		 *
361
+		 * @param $title_html_tag default is 'h3'
362
+		 */
363
+		$title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
364
+
365
+		/**
366
+		 * Filter the title classes
367
+		 *
368
+		 * @since 1.9.0
369
+		 * @param string $title_classes defaults to $post_type-title
370
+		 */
371
+		$title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
372
+
373
+		$html= '';
374
+		$html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
375
+		$html .= '<a href="' . get_permalink( $post->ID ) . '" >';
376
+		$html .= $post->post_title ;
377
+		$html .= '</a>';
378
+		$html .= '</'. $title_html_tag. '>';
379
+		echo $html;
380
+
381
+	}// end the title
382
+
383
+	/**
384
+	 * This function adds the hooks inside and above the single course content for
385
+	 * backwards compatibility sake.
386
+	 *
387
+	 * @since 1.9.0
388
+	 * @deprecated 1.9.0
389
+	 */
390
+	public static function deprecated_single_course_inside_before_hooks(){
391
+
392
+		sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
393
+		sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
394
+		sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
395
+
396
+	}// end deprecated_single_course_inside_before_hooks
397
+
398
+	/**
399
+	 * This function adds the hooks to sensei_course_single_lessons for
400
+	 * backwards compatibility sake.  and provides developers with an alternative.
401
+	 *
402
+	 * @since 1.9.0
403
+	 * @deprecated 1.9.0
404
+	 */
405
+	public static function deprecate_sensei_course_single_lessons_hook(){
406
+
407
+		sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
408
+
409
+	}// deprecate_sensei_course_single_lessons_hook
410
+
411
+	/**
412
+	 * Deprecated all deprecated_single_main_content_hook hooked actions.
413
+	 *
414
+	 * The content must be dealt with inside the respective templates.
415
+	 *
416
+	 * @since 1.9.0
417
+	 * @deprecated 1.9.0
418
+	 */
419
+	public static function deprecated_single_main_content_hook(){
420
+
421
+			if( is_singular( 'course' ) ) {
422
+
423
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
424
+
425
+			} elseif( is_singular( 'message' ) ){
426
+
427
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
428
+			}
429
+
430
+	}// end deprecated_single_course_single_main_content_hook
431
+
432
+	/**
433
+	 * Deprecate the  old sensei modules
434
+	 * @since 1.9.0
435
+	 * @deprecated since 1.9.0
436
+	 */
437
+	public static function deprecate_module_before_hook(){
438
+
439
+		sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
422 440
 
423
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
424
-
425
-            } elseif( is_singular( 'message' ) ){
426
-
427
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
428
-            }
429
-
430
-    }// end deprecated_single_course_single_main_content_hook
431
-
432
-    /**
433
-     * Deprecate the  old sensei modules
434
-     * @since 1.9.0
435
-     * @deprecated since 1.9.0
436
-     */
437
-    public static function deprecate_module_before_hook(){
441
+	}
438 442
 
439
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
443
+	/**
444
+	 * Deprecate the  old sensei modules after hooks
445
+	 * @since 1.9.0
446
+	 * @deprecated since 1.9.0
447
+	 */
448
+	public static function deprecate_module_after_hook(){
440 449
 
441
-    }
442
-
443
-    /**
444
-     * Deprecate the  old sensei modules after hooks
445
-     * @since 1.9.0
446
-     * @deprecated since 1.9.0
447
-     */
448
-    public static function deprecate_module_after_hook(){
450
+		sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
449 451
 
450
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
452
+	}
451 453
 
452
-    }
454
+	/**
455
+	 * Deprecate the single message hooks for post types.
456
+	 *
457
+	 * @since 1.9.0
458
+	 * @deprecated since 1.9.0
459
+	 */
460
+	public static function deprecate_all_post_type_single_title_hooks(){
453 461
 
454
-    /**
455
-     * Deprecate the single message hooks for post types.
456
-     *
457
-     * @since 1.9.0
458
-     * @deprecated since 1.9.0
459
-     */
460
-    public static function deprecate_all_post_type_single_title_hooks(){
462
+		if( is_singular( 'sensei_message' ) ){
461 463
 
462
-        if( is_singular( 'sensei_message' ) ){
464
+			sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
463 465
 
464
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
466
+		}
465 467
 
466
-        }
468
+	}
467 469
 
468
-    }
470
+	/**
471
+	 * course_single_meta function.
472
+	 *
473
+	 * @access public
474
+	 * @return void
475
+	 * @deprecated since 1.9.0
476
+	 */
477
+	public static function deprecate_course_single_meta_hooks() {
469 478
 
470
-    /**
471
-     * course_single_meta function.
472
-     *
473
-     * @access public
474
-     * @return void
475
-     * @deprecated since 1.9.0
476
-     */
477
-    public static function deprecate_course_single_meta_hooks() {
479
+		// deprecate all these hooks
480
+		sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
481
+		sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
482
+		sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
483
+		sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
478 484
 
479
-        // deprecate all these hooks
480
-        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
481
-        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
482
-        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
483
-        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
485
+	} // End deprecate_course_single_meta_hooks
484 486
 
485
-    } // End deprecate_course_single_meta_hooks
487
+	/**
488
+	 * Run the deprecated hooks on the single lesson page
489
+	 * @deprecated since 1.9.0
490
+	 */
491
+	public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
486 492
 
487
-    /**
488
-     * Run the deprecated hooks on the single lesson page
489
-     * @deprecated since 1.9.0
490
-     */
491
-    public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
493
+		if( is_singular( 'lesson' ) ){
492 494
 
493
-        if( is_singular( 'lesson' ) ){
495
+			sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
496
+			sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
494 497
 
495
-            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
496
-            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
498
+		}
497 499
 
498
-        }
500
+	}// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
499 501
 
500
-    }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
502
+	/**
503
+	 * Deprecate the hook sensei_lesson_course_signup.
504
+	 *
505
+	 * The hook content will be linked directly on the recommended
506
+	 * sensei_single_lesson_content_inside_after
507
+	 *
508
+	 * @deprecated since 1.9.0
509
+	 */
510
+	public static function deprecate_sensei_lesson_course_signup_hook(){
501 511
 
502
-    /**
503
-     * Deprecate the hook sensei_lesson_course_signup.
504
-     *
505
-     * The hook content will be linked directly on the recommended
506
-     * sensei_single_lesson_content_inside_after
507
-     *
508
-     * @deprecated since 1.9.0
509
-     */
510
-    public static function deprecate_sensei_lesson_course_signup_hook(){
512
+		$lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
513
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
511 514
 
512
-        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
513
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
515
+		if(  !$user_taking_course ) {
514 516
 
515
-        if(  !$user_taking_course ) {
517
+			sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
516 518
 
517
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
519
+		}
520
+	}// end deprecate_sensei_lesson_course_signup_hook
518 521
 
519
-        }
520
-    }// end deprecate_sensei_lesson_course_signup_hook
522
+	/**
523
+	 * Running the deprecated hook: sensei_lesson_single_meta
524
+	 *
525
+	 * @since 1.9.0
526
+	 * @deprecated since 1.9.0
527
+	 */
528
+	public static function deprecate_sensei_lesson_single_meta_hook(){
521 529
 
522
-    /**
523
-     * Running the deprecated hook: sensei_lesson_single_meta
524
-     *
525
-     * @since 1.9.0
526
-     * @deprecated since 1.9.0
527
-     */
528
-    public static function deprecate_sensei_lesson_single_meta_hook(){
530
+		if ( sensei_can_user_view_lesson()  ) {
529 531
 
530
-        if ( sensei_can_user_view_lesson()  ) {
532
+			sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
531 533
 
532
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
533 534
 
535
+		}
534 536
 
535
-        }
537
+	}// end deprecate_sensei_lesson_single_meta_hook
536 538
 
537
-    }// end deprecate_sensei_lesson_single_meta_hook
539
+	/**
540
+	 * Deprecate the sensei lesson single title hook
541
+	 * @deprecated since 1.9.0
542
+	 */
543
+	public static function deprecate_sensei_lesson_single_title(){
538 544
 
539
-    /**
540
-     * Deprecate the sensei lesson single title hook
541
-     * @deprecated since 1.9.0
542
-     */
543
-    public static function deprecate_sensei_lesson_single_title(){
545
+		sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
544 546
 
545
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
547
+	}// end deprecate_sensei_lesson_single_title
546 548
 
547
-    }// end deprecate_sensei_lesson_single_title
549
+	/**
550
+	 * hook in the deperecated single main content to the lesson
551
+	 * @deprecated since 1.9.0
552
+	 */
553
+	public  static function deprecate_lesson_single_main_content_hook(){
548 554
 
549
-    /**
550
-     * hook in the deperecated single main content to the lesson
551
-     * @deprecated since 1.9.0
552
-     */
553
-    public  static function deprecate_lesson_single_main_content_hook(){
555
+		sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
554 556
 
555
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
557
+	}// end sensei_deprecate_lesson_single_main_content_hook
556 558
 
557
-    }// end sensei_deprecate_lesson_single_main_content_hook
559
+	/**
560
+	 * hook in the deperecated single main content to the lesson
561
+	 * @deprecated since 1.9.0
562
+	 */
563
+	public  static function deprecate_lesson_image_hook(){
558 564
 
559
-    /**
560
-     * hook in the deperecated single main content to the lesson
561
-     * @deprecated since 1.9.0
562
-     */
563
-    public  static function deprecate_lesson_image_hook(){
565
+		sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
564 566
 
565
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
567
+	}// end sensei_deprecate_lesson_single_main_content_hook
566 568
 
567
-    }// end sensei_deprecate_lesson_single_main_content_hook
569
+	/**
570
+	 * hook in the deprecated sensei_login_form hook for backwards
571
+	 * compatibility
572
+	 *
573
+	 * @since 1.9.0
574
+	 * @deprecated since 1.9.0
575
+	 */
576
+	public static function deprecate_sensei_login_form_hook(){
568 577
 
569
-    /**
570
-     * hook in the deprecated sensei_login_form hook for backwards
571
-     * compatibility
572
-     *
573
-     * @since 1.9.0
574
-     * @deprecated since 1.9.0
575
-     */
576
-    public static function deprecate_sensei_login_form_hook(){
578
+		sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
577 579
 
578
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
580
+	} // end deprecate_sensei_login_form_hook
579 581
 
580
-    } // end deprecate_sensei_login_form_hook
582
+	/**
583
+	 * Fire the sensei_complete_course action.
584
+	 *
585
+	 * This is just a backwards compatible function to add the action
586
+	 * to a template. This should not be used as the function from this
587
+	 * hook will be added directly to my-courses page via one of the hooks there.
588
+	 *
589
+	 * @since 1.9.0
590
+	 */
591
+	public static function  fire_sensei_complete_course_hook(){
581 592
 
582
-    /**
583
-     * Fire the sensei_complete_course action.
584
-     *
585
-     * This is just a backwards compatible function to add the action
586
-     * to a template. This should not be used as the function from this
587
-     * hook will be added directly to my-courses page via one of the hooks there.
588
-     *
589
-     * @since 1.9.0
590
-     */
591
-    public static function  fire_sensei_complete_course_hook(){
593
+		do_action( 'sensei_complete_course' );
592 594
 
593
-        do_action( 'sensei_complete_course' );
595
+	} //fire_sensei_complete_course_hook
594 596
 
595
-    } //fire_sensei_complete_course_hook
597
+	/**
598
+	 * Fire the frontend message hook
599
+	 *
600
+	 * @since 1.9.0
601
+	 */
602
+	public static function  fire_frontend_messages_hook(){
596 603
 
597
-    /**
598
-     * Fire the frontend message hook
599
-     *
600
-     * @since 1.9.0
601
-     */
602
-    public static function  fire_frontend_messages_hook(){
604
+		do_action( 'sensei_frontend_messages' );
603 605
 
604
-        do_action( 'sensei_frontend_messages' );
606
+	}// end sensei_complete_course_action
605 607
 
606
-    }// end sensei_complete_course_action
608
+	/**
609
+	 * deprecate the sensei_before_user_course_content hook in favor
610
+	 * of sensei_my_courses_content_inside_before.
611
+	 *
612
+	 * @deprected since 1.9.0
613
+	 */
614
+	public static function  deprecate_sensei_before_user_course_content_hook(){
607 615
 
608
-    /**
609
-     * deprecate the sensei_before_user_course_content hook in favor
610
-     * of sensei_my_courses_content_inside_before.
611
-     *
612
-     * @deprected since 1.9.0
613
-     */
614
-    public static function  deprecate_sensei_before_user_course_content_hook(){
616
+		sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
615 617
 
616
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
618
+	}// deprecate_sensei_before_user_course_content_hook
617 619
 
618
-    }// deprecate_sensei_before_user_course_content_hook
620
+	/**
621
+	 * deprecate the sensei_before_user_course_content hook in favor
622
+	 * of sensei_my_courses_content_inside_after hook.
623
+	 *
624
+	 * @deprected since 1.9.0
625
+	 */
626
+	public static function  deprecate_sensei_after_user_course_content_hook(){
619 627
 
620
-    /**
621
-     * deprecate the sensei_before_user_course_content hook in favor
622
-     * of sensei_my_courses_content_inside_after hook.
623
-     *
624
-     * @deprected since 1.9.0
625
-     */
626
-    public static function  deprecate_sensei_after_user_course_content_hook(){
628
+		sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
627 629
 
628
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
630
+	}// deprecate_sensei_after_user_course_content_hook
629 631
 
630
-    }// deprecate_sensei_after_user_course_content_hook
632
+	/**
633
+	 * Deprecate the 2 main hooks on the archive message template
634
+	 *
635
+	 * @deprecated since 1.9.0
636
+	 * @since 1.9.0
637
+	 */
638
+	public static function deprecated_archive_message_hooks (){
631 639
 
632
-    /**
633
-     * Deprecate the 2 main hooks on the archive message template
634
-     *
635
-     * @deprecated since 1.9.0
636
-     * @since 1.9.0
637
-     */
638
-    public static function deprecated_archive_message_hooks (){
640
+		sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
641
+		sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
639 642
 
640
-        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
641
-        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
643
+	}
642 644
 
643
-    }
645
+	/**
646
+	 * Run the sensei_complete_quiz for those still hooking
647
+	 * into but deprecated it.
648
+	 *
649
+	 * @deprecated since 1.9.0
650
+	 */
651
+	public static function deprecate_sensei_complete_quiz_action(){
644 652
 
645
-    /**
646
-     * Run the sensei_complete_quiz for those still hooking
647
-     * into but deprecated it.
648
-     *
649
-     * @deprecated since 1.9.0
650
-     */
651
-    public static function deprecate_sensei_complete_quiz_action(){
653
+		sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
652 654
 
653
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
655
+	}
654 656
 
655
-    }
657
+	/**
658
+	 * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
659
+	 * it to provide user with a better alternative.
660
+	 *
661
+	 * @deprecated since 1.9.0
662
+	 */
663
+	public static function deprecate_sensei_quiz_question_type_action(){
656 664
 
657
-    /**
658
-     * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
659
-     * it to provide user with a better alternative.
660
-     *
661
-     * @deprecated since 1.9.0
662
-     */
663
-    public static function deprecate_sensei_quiz_question_type_action(){
665
+		// Question Type
666
+		global $sensei_question_loop;
667
+		$question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
668
+		sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
664 669
 
665
-        // Question Type
666
-        global $sensei_question_loop;
667
-        $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
668
-        sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
669
-
670
-    }
670
+	}
671 671
 
672 672
 
673 673
 	public static function the_register_button( $post_id = "" ){
@@ -675,9 +675,9 @@  discard block
 block discarded – undo
675 675
 		global $current_user, $post;
676 676
 
677 677
 		if ( ! get_option('users_can_register')
678
-		     || 'course' != get_post_type( $post_id )
679
-		     || ! empty( $current_user->caps )
680
-		     || ! Sensei()->settings->get('access_permission')  ) {
678
+			 || 'course' != get_post_type( $post_id )
679
+			 || ! empty( $current_user->caps )
680
+			 || ! Sensei()->settings->get('access_permission')  ) {
681 681
 
682 682
 			return;
683 683
 
Please login to merge, or discard this patch.
includes/class-sensei-utils.php 1 patch
Indentation   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
 	/**
27 27
 	 * Check if WooCommerce is present.
28
-     *
29
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
28
+	 *
29
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present()
30 30
 	 * @access public
31 31
 	 * @since  1.0.2
32 32
 	 * @static
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public static function sensei_is_woocommerce_present () {
36 36
 
37
-        return Sensei_WC::is_woocommerce_present();
37
+		return Sensei_WC::is_woocommerce_present();
38 38
 
39 39
 	} // End sensei_is_woocommerce_present()
40 40
 
41 41
 	/**
42 42
 	 * Check if WooCommerce is active.
43
-     *
44
-     * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
43
+	 *
44
+	 * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active
45 45
 	 * @access public
46 46
 	 * @since  1.0.2
47 47
 	 * @static
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 			add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
187 187
 		}
188 188
 
189
-        //Get the comments
190
-        /**
191
-         * This filter runs inside Sensei_Utils::sensei_check_for_activity
192
-         *
193
-         * It runs while getting the comments for the given request.
194
-         *
195
-         * @param int|array $comments
196
-         */
197
-        $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
189
+		//Get the comments
190
+		/**
191
+		 * This filter runs inside Sensei_Utils::sensei_check_for_activity
192
+		 *
193
+		 * It runs while getting the comments for the given request.
194
+		 *
195
+		 * @param int|array $comments
196
+		 */
197
+		$comments = apply_filters('sensei_check_for_activity', get_comments( $args ) );
198 198
 
199 199
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) );
200 200
 		remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) );
@@ -279,18 +279,18 @@  discard block
 block discarded – undo
279 279
 		return $dataset_changes;
280 280
 	} // End sensei_delete_activities()
281 281
 
282
-    /**
283
-     * Delete all activity for specified user
284
-     * @access public
282
+	/**
283
+	 * Delete all activity for specified user
284
+	 * @access public
285 285
 	 * @since  1.5.0
286
-     * @param  integer $user_id User ID
287
-     * @return boolean
288
-     */
289
-    public static function delete_all_user_activity( $user_id = 0 ) {
286
+	 * @param  integer $user_id User ID
287
+	 * @return boolean
288
+	 */
289
+	public static function delete_all_user_activity( $user_id = 0 ) {
290 290
 
291
-    	$dataset_changes = false;
291
+		$dataset_changes = false;
292 292
 
293
-    	if( $user_id ) {
293
+		if( $user_id ) {
294 294
 
295 295
 			$activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true );
296 296
 
@@ -334,35 +334,35 @@  discard block
 block discarded – undo
334 334
 		return $activity_value;
335 335
 	} // End sensei_get_activity_value()
336 336
 
337
-    /**
338
-     * Checks if a user (by email) has bought an item.
339
-     *
340
-     * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
341
-     * @access public
342
-     * @since  1.0.0
343
-     * @param  string $customer_email
344
-     * @param  int $user_id
345
-     * @param  int $product_id
346
-     * @return bool
347
-     */
348
-    public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
337
+	/**
338
+	 * Checks if a user (by email) has bought an item.
339
+	 *
340
+	 * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id)
341
+	 * @access public
342
+	 * @since  1.0.0
343
+	 * @param  string $customer_email
344
+	 * @param  int $user_id
345
+	 * @param  int $product_id
346
+	 * @return bool
347
+	 */
348
+	public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) {
349 349
 
350
-        $emails = array();
350
+		$emails = array();
351 351
 
352
-        if ( $user_id ) {
353
-            $user = get_user_by( 'id', intval( $user_id ) );
354
-            $emails[] = $user->user_email;
355
-        }
352
+		if ( $user_id ) {
353
+			$user = get_user_by( 'id', intval( $user_id ) );
354
+			$emails[] = $user->user_email;
355
+		}
356 356
 
357
-        if ( is_email( $customer_email ) )
358
-            $emails[] = $customer_email;
357
+		if ( is_email( $customer_email ) )
358
+			$emails[] = $customer_email;
359 359
 
360
-        if ( sizeof( $emails ) == 0 )
361
-            return false;
360
+		if ( sizeof( $emails ) == 0 )
361
+			return false;
362 362
 
363
-        return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
363
+		return Sensei_WC::has_customer_bought_product( $user_id, $product_id );
364 364
 
365
-    } // End sensei_customer_bought_product()
365
+	} // End sensei_customer_bought_product()
366 366
 
367 367
 	/**
368 368
 	 * Load the WordPress rich text editor
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	/**
399 399
 	 * Save quiz answers submitted by users
400 400
 	 * @param  array $submitted User's quiz answers
401
-     * @param int $user_id
401
+	 * @param int $user_id
402 402
 	 * @return boolean            Whether the answers were saved or not
403 403
 	 */
404 404
 	public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) {
@@ -467,72 +467,72 @@  discard block
 block discarded – undo
467 467
 
468 468
 		require_once( ABSPATH . 'wp-admin/includes/admin.php' );
469 469
 
470
-        /**
471
-         * Filter the data array for the Sensei wp_handle_upload function call
472
-         *
473
-         * This filter was mainly added for Unit Testing purposes.
474
-         *
475
-         * @since 1.7.4
476
-         *
477
-         * @param array  $file_upload_args {
478
-         *      array of current values
479
-         *
480
-         *     @type string test_form set to false by default
481
-         * }
482
-         */
483
-        $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
484
-
485
-        $file_return = wp_handle_upload( $file, $file_upload_args );
486
-
487
-        if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
488
-            return false;
489
-        } else {
470
+		/**
471
+		 * Filter the data array for the Sensei wp_handle_upload function call
472
+		 *
473
+		 * This filter was mainly added for Unit Testing purposes.
474
+		 *
475
+		 * @since 1.7.4
476
+		 *
477
+		 * @param array  $file_upload_args {
478
+		 *      array of current values
479
+		 *
480
+		 *     @type string test_form set to false by default
481
+		 * }
482
+		 */
483
+		$file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) );
484
+
485
+		$file_return = wp_handle_upload( $file, $file_upload_args );
486
+
487
+		if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) {
488
+			return false;
489
+		} else {
490 490
 
491
-            $filename = $file_return['file'];
491
+			$filename = $file_return['file'];
492 492
 
493
-            $attachment = array(
494
-                'post_mime_type' => $file_return['type'],
495
-                'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
496
-                'post_content' => '',
497
-                'post_status' => 'inherit',
498
-                'guid' => $file_return['url']
499
-            );
493
+			$attachment = array(
494
+				'post_mime_type' => $file_return['type'],
495
+				'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
496
+				'post_content' => '',
497
+				'post_status' => 'inherit',
498
+				'guid' => $file_return['url']
499
+			);
500 500
 
501
-            $attachment_id = wp_insert_attachment( $attachment, $filename );
501
+			$attachment_id = wp_insert_attachment( $attachment, $filename );
502 502
 
503
-            require_once(ABSPATH . 'wp-admin/includes/image.php');
504
-            $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
505
-            wp_update_attachment_metadata( $attachment_id, $attachment_data );
503
+			require_once(ABSPATH . 'wp-admin/includes/image.php');
504
+			$attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename );
505
+			wp_update_attachment_metadata( $attachment_id, $attachment_data );
506 506
 
507
-            if( 0 < intval( $attachment_id ) ) {
508
-            	return $attachment_id;
509
-            }
510
-        }
507
+			if( 0 < intval( $attachment_id ) ) {
508
+				return $attachment_id;
509
+			}
510
+		}
511 511
 
512
-        return false;
512
+		return false;
513 513
 	}
514 514
 
515 515
 	/**
516 516
 	 * Grade quiz automatically
517
-     *
518
-     * This function grades each question automatically if the are auto gradable.
519
-     * It store all question grades.
520
-     *
521
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
522
-     *
517
+	 *
518
+	 * This function grades each question automatically if the are auto gradable.
519
+	 * It store all question grades.
520
+	 *
521
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead
522
+	 *
523 523
 	 * @param  integer $quiz_id         ID of quiz
524 524
 	 * @param  array $submitted questions id ans answers {
525
-     *          @type int $question_id
526
-     *          @type mixed $answer
527
-     * }
525
+	 *          @type int $question_id
526
+	 *          @type mixed $answer
527
+	 * }
528 528
 	 * @param  integer $total_questions Total questions in quiz (not used)
529
-     * @param string $quiz_grade_type Optional defaults to auto
530
-     *
529
+	 * @param string $quiz_grade_type Optional defaults to auto
530
+	 *
531 531
 	 * @return int $quiz_grade total sum of all question grades
532 532
 	 */
533 533
 	public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
534 534
 
535
-        return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
535
+		return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type );
536 536
 
537 537
 	} // End sensei_grade_quiz_auto()
538 538
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 * @param  integer $quiz_id ID of quiz
542 542
 	 * @param  integer $grade   Grade received
543 543
 	 * @param  integer $user_id ID of user being graded
544
-     * @param  string $quiz_grade_type default 'auto'
544
+	 * @param  string $quiz_grade_type default 'auto'
545 545
 	 * @return boolean
546 546
 	 */
547 547
 	public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) {
@@ -565,21 +565,21 @@  discard block
 block discarded – undo
565 565
 
566 566
 	/**
567 567
 	 * Grade question automatically
568
-     *
569
-     * This function checks the question typ and then grades it accordingly.
570
-     *
571
-     * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
572
-     *
568
+	 *
569
+	 * This function checks the question typ and then grades it accordingly.
570
+	 *
571
+	 * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead
572
+	 *
573 573
 	 * @param integer $question_id
574
-     * @param string $question_type of the standard Sensei question types
574
+	 * @param string $question_type of the standard Sensei question types
575 575
 	 * @param string $answer
576
-     * @param int $user_id
577
-     *
576
+	 * @param int $user_id
577
+	 *
578 578
 	 * @return int $question_grade
579 579
 	 */
580 580
 	public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
581 581
 
582
-       return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
582
+	   return  WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id  );
583 583
 
584 584
 	} // end sensei_grade_question_auto
585 585
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * Grade question
588 588
 	 * @param  integer $question_id ID of question
589 589
 	 * @param  integer $grade       Grade received
590
-     * @param int $user_id
590
+	 * @param int $user_id
591 591
 	 * @return boolean
592 592
 	 */
593 593
 	public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) {
@@ -626,35 +626,35 @@  discard block
 block discarded – undo
626 626
 	}
627 627
 
628 628
 
629
-    /**
630
-     * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
631
-     *
632
-     * @since 1.7.4
633
-     *
634
-     * @param integer $user_id
635
-     * @param integer $lesson_id
636
-     * @param bool $complete
637
-     *
638
-     * @return mixed boolean or comment_ID
639
-     */
640
-    public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
629
+	/**
630
+	 * Alias to Woothemes_Sensei_Utils::sensei_start_lesson
631
+	 *
632
+	 * @since 1.7.4
633
+	 *
634
+	 * @param integer $user_id
635
+	 * @param integer $lesson_id
636
+	 * @param bool $complete
637
+	 *
638
+	 * @return mixed boolean or comment_ID
639
+	 */
640
+	public static function user_start_lesson(  $user_id = 0, $lesson_id = 0, $complete = false ) {
641 641
 
642
-        return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
642
+		return self::sensei_start_lesson( $lesson_id, $user_id, $complete );
643 643
 
644
-    }// end user_start_lesson()
644
+	}// end user_start_lesson()
645 645
 
646 646
 	/**
647 647
 	 * Mark a lesson as started for user
648
-     *
649
-     * Will also start the lesson course for the user if the user hans't started taking it already.
650
-     *
651
-     * @since 1.6.0
652
-     *
648
+	 *
649
+	 * Will also start the lesson course for the user if the user hans't started taking it already.
650
+	 *
651
+	 * @since 1.6.0
652
+	 *
653 653
 	 * @param  integer $lesson_id ID of lesson
654 654
 	 * @param int| string $user_id default 0
655
-     * @param bool $complete default false
656
-     *
657
-     * @return mixed boolean or comment_ID
655
+	 * @param bool $complete default false
656
+	 *
657
+	 * @return mixed boolean or comment_ID
658 658
 	 */
659 659
 	public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) {
660 660
 
@@ -700,21 +700,21 @@  discard block
 block discarded – undo
700 700
 				$metadata['start'] = current_time('mysql');
701 701
 				$activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata );
702 702
 
703
-            } else {
703
+			} else {
704 704
 
705
-                // if users is already taking the lesson  and the status changes to complete update it
706
-                $current_user_activity = get_comment($activity_logged);
707
-                if( $status=='complete' &&
708
-                    $status != $current_user_activity->comment_approved  ){
705
+				// if users is already taking the lesson  and the status changes to complete update it
706
+				$current_user_activity = get_comment($activity_logged);
707
+				if( $status=='complete' &&
708
+					$status != $current_user_activity->comment_approved  ){
709 709
 
710
-                    $comment = array();
711
-                    $comment['comment_ID'] = $activity_logged;
712
-                    $comment['comment_approved'] = $status;
713
-                    wp_update_comment( $comment );
710
+					$comment = array();
711
+					$comment['comment_ID'] = $activity_logged;
712
+					$comment['comment_approved'] = $status;
713
+					wp_update_comment( $comment );
714 714
 
715
-                }
715
+				}
716 716
 
717
-            }
717
+			}
718 718
 
719 719
 			if ( $complete ) {
720 720
 				// Run this *after* the lesson status has been created/updated
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 	/**
861 861
 	 * Returns the answer_notes for a specific question and user, or sensei_user_answer entry
862 862
 	 *
863
-     * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
863
+	 * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead
864 864
 	 * @param mixed $question
865 865
 	 * @param int $user_id
866 866
 	 * @return string
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 	 * Add answer notes to question
921 921
 	 * @param  integer $question_id ID of question
922 922
 	 * @param  integer $user_id     ID of user
923
-     * @param string $notes
923
+	 * @param string $notes
924 924
 	 * @return boolean
925 925
 	 */
926 926
 	public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) {
@@ -978,17 +978,17 @@  discard block
 block discarded – undo
978 978
 	 * @return void
979 979
 	 */
980 980
 	public static function sort_array_by_key( $array, $key ) {
981
-	    $sorter = array();
982
-	    $ret = array();
983
-	    reset( $array );
984
-	    foreach ( $array as $ii => $va ) {
985
-	        $sorter[$ii] = $va[$key];
986
-	    } // End For Loop
987
-	    asort( $sorter );
988
-	    foreach ( $sorter as $ii => $va ) {
989
-	        $ret[$ii] = $array[$ii];
990
-	    } // End For Loop
991
-	    $array = $ret;
981
+		$sorter = array();
982
+		$ret = array();
983
+		reset( $array );
984
+		foreach ( $array as $ii => $va ) {
985
+			$sorter[$ii] = $va[$key];
986
+		} // End For Loop
987
+		asort( $sorter );
988
+		foreach ( $sorter as $ii => $va ) {
989
+			$ret[$ii] = $array[$ii];
990
+		} // End For Loop
991
+		$array = $ret;
992 992
 	} // End sort_array_by_key()
993 993
 
994 994
 	/**
@@ -1001,21 +1001,21 @@  discard block
 block discarded – undo
1001 1001
 		$questions_array = array();
1002 1002
 		if ( 0 < $quiz_id ) {
1003 1003
 			$question_args = array( 'post_type'         => 'question',
1004
-                                    'posts_per_page'       => -1,
1005
-                                    'orderby'           => 'ID',
1006
-                                    'order'             => 'ASC',
1007
-                                    'meta_query'		=> array(
1004
+									'posts_per_page'       => -1,
1005
+									'orderby'           => 'ID',
1006
+									'order'             => 'ASC',
1007
+									'meta_query'		=> array(
1008 1008
 										array(
1009 1009
 											'key'       => '_quiz_id',
1010 1010
 											'value'     => $quiz_id,
1011 1011
 										)
1012 1012
 									),
1013
-                                    'post_status'       => 'any',
1014
-                                    'suppress_filters'  => 0
1015
-                                );
1016
-            $questions_array = get_posts( $question_args );
1017
-        } // End If Statement
1018
-        return $questions_array;
1013
+									'post_status'       => 'any',
1014
+									'suppress_filters'  => 0
1015
+								);
1016
+			$questions_array = get_posts( $question_args );
1017
+		} // End If Statement
1018
+		return $questions_array;
1019 1019
 	} // End lesson_quiz_questions()
1020 1020
 
1021 1021
 	/**
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 	 * Set the status message displayed to the user for a quiz
1176 1176
 	 * @param  integer $lesson_id ID of quiz lesson
1177 1177
 	 * @param  integer $user_id   ID of user
1178
-     * @param  bool $is_lesson
1178
+	 * @param  bool $is_lesson
1179 1179
 	 * @return array              Status code and message
1180 1180
 	 */
1181 1181
 	public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) {
@@ -1258,20 +1258,20 @@  discard block
 block discarded – undo
1258 1258
 					}
1259 1259
 				}
1260 1260
 
1261
-                // add next lesson button
1262
-                $nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1263
-                $next_lesson_id = absint( $nav_id_array['next_lesson'] );
1261
+				// add next lesson button
1262
+				$nav_id_array = sensei_get_prev_next_lessons( $lesson_id );
1263
+				$next_lesson_id = absint( $nav_id_array['next_lesson'] );
1264 1264
 
1265
-                // Output HTML
1266
-                if ( ( 0 < $next_lesson_id ) ) {
1267
-                    $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1268
-                                . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1269
-                                .'</a>';
1265
+				// Output HTML
1266
+				if ( ( 0 < $next_lesson_id ) ) {
1267
+					$message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) )
1268
+								. '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei')
1269
+								.'</a>';
1270 1270
 
1271
-                }
1271
+				}
1272 1272
 
1273 1273
 			}
1274
-            // Lesson/Quiz not complete
1274
+			// Lesson/Quiz not complete
1275 1275
 			else {
1276 1276
 				// Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete)
1277 1277
 				if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) {
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 		$message = apply_filters( 'sensei_user_quiz_status_' . $status, $message );
1330 1330
 
1331 1331
 		if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) {
1332
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1332
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
1333 1333
 			$extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' .  __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' .  __( 'View the lesson quiz', 'woothemes-sensei' )  . '</a></p>';
1334 1334
 		}
1335 1335
 
@@ -1387,9 +1387,9 @@  discard block
 block discarded – undo
1387 1387
 				$user_id = get_current_user_id();
1388 1388
 			}
1389 1389
 
1390
-            if( ! $user_id > 0 ){
1391
-                return false;
1392
-            }
1390
+			if( ! $user_id > 0 ){
1391
+				return false;
1392
+			}
1393 1393
 
1394 1394
 			$user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) );
1395 1395
 			if( $user_course_status_id ) {
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 	 * Check if a user has completed a course or not
1514 1514
 	 *
1515 1515
 	 * @param int | WP_Post | WP_Comment $course course_id or sensei_course_status entry
1516
-     *
1516
+	 *
1517 1517
 	 * @param int $user_id
1518 1518
 	 * @return boolean
1519 1519
 	 */
@@ -1540,14 +1540,14 @@  discard block
 block discarded – undo
1540 1540
 					}
1541 1541
 				}
1542 1542
 
1543
-                if( is_a( $course, 'WP_Post' ) ){
1544
-                    $course =   $course->ID;
1545
-                }
1543
+				if( is_a( $course, 'WP_Post' ) ){
1544
+					$course =   $course->ID;
1545
+				}
1546 1546
 
1547 1547
 				$user_course_status = Sensei_Utils::user_course_status( $course , $user_id );
1548 1548
 				if( isset( $user_course_status->comment_approved ) ){
1549
-                    $user_course_status = $user_course_status->comment_approved;
1550
-                }
1549
+					$user_course_status = $user_course_status->comment_approved;
1550
+				}
1551 1551
 
1552 1552
 			}
1553 1553
 			if( $user_course_status && 'complete' == $user_course_status ) {
@@ -1572,11 +1572,11 @@  discard block
 block discarded – undo
1572 1572
 				$user_id = get_current_user_id();
1573 1573
 			}
1574 1574
 
1575
-            $activity_args = array(
1576
-                'post_id' => $lesson_id,
1577
-                'user_id' => $user_id,
1578
-                'type' => 'sensei_lesson_status',
1579
-                'field' => 'comment_ID' );
1575
+			$activity_args = array(
1576
+				'post_id' => $lesson_id,
1577
+				'user_id' => $user_id,
1578
+				'type' => 'sensei_lesson_status',
1579
+				'field' => 'comment_ID' );
1580 1580
 
1581 1581
 			$user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args );
1582 1582
 			if( $user_lesson_status_id ) {
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 	/**
1590 1590
 	 * Check if a user has completed a lesson or not
1591 1591
 	 *
1592
-     * @uses  Sensei()
1592
+	 * @uses  Sensei()
1593 1593
 	 * @param mixed $lesson lesson_id or sensei_lesson_status entry
1594 1594
 	 * @param int $user_id
1595 1595
 	 * @return boolean
@@ -1610,10 +1610,10 @@  discard block
 block discarded – undo
1610 1610
 					$user_id = get_current_user_id();
1611 1611
 				}
1612 1612
 
1613
-                // the user is not logged in
1614
-                if( ! $user_id > 0 ){
1615
-                    return false;
1616
-                }
1613
+				// the user is not logged in
1614
+				if( ! $user_id > 0 ){
1615
+					return false;
1616
+				}
1617 1617
 				$_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id );
1618 1618
 
1619 1619
 				if ( $_user_lesson_status ) {
@@ -1692,9 +1692,9 @@  discard block
 block discarded – undo
1692 1692
 	 */
1693 1693
 	public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) {
1694 1694
 
1695
-        if( ! $user_id ) {
1696
-            $user_id = get_current_user_id();
1697
-        }
1695
+		if( ! $user_id ) {
1696
+			$user_id = get_current_user_id();
1697
+		}
1698 1698
 
1699 1699
 		if( $lesson_id > 0 && $user_id > 0 ) {
1700 1700
 
@@ -1745,12 +1745,12 @@  discard block
 block discarded – undo
1745 1745
 	 * Sets the status for the lesson
1746 1746
 	 *
1747 1747
 	 * @since  1.7.0
1748
-     *
1748
+	 *
1749 1749
 	 * @param int|string $user_id
1750 1750
 	 * @param int|string $lesson_id
1751 1751
 	 * @param string $status
1752 1752
 	 * @param array $metadata
1753
-     *
1753
+	 *
1754 1754
 	 * @return mixed false or comment_ID
1755 1755
 	 */
1756 1756
 	public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) {
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 	/**
1867 1867
 	 * Adjust the comment query to be faster on the database, used by Analysis admin
1868 1868
 	 * @since  1.7.0
1869
-     * @param array $pieces
1869
+	 * @param array $pieces
1870 1870
 	 * @return array $pieces
1871 1871
 	 */
1872 1872
 	public static function comment_total_sum_meta_value_filter( $pieces ) {
@@ -1901,360 +1901,360 @@  discard block
 block discarded – undo
1901 1901
 		return $pieces;
1902 1902
 	}
1903 1903
 
1904
-    /**
1905
-     *
1906
-     * Alias to Woothemes_Sensei_Utils::update_user_data
1907
-     * @since 1.7.4
1908
-     *
1909
-     * @param string $data_key maximum 39 characters allowed
1910
-     * @param int $post_id
1911
-     * @param mixed $value
1912
-     * @param int $user_id
1913
-     *
1914
-     * @return bool $success
1915
-     */
1916
-    public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
1917
-
1918
-        return self::update_user_data( $data_key, $post_id, $value , $user_id );
1919
-
1920
-    }// end add_user_data
1921
-
1922
-    /**
1923
-     * add user specific data to the passed in sensei post type id
1924
-     *
1925
-     * This function saves comment meta on the users current status. If no status is available
1926
-     * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1927
-     *
1928
-     * @since 1.7.4
1929
-     *
1930
-     * @param string $data_key maximum 39 characters allowed
1931
-     * @param int $post_id
1932
-     * @param mixed $value
1933
-     * @param int $user_id
1934
-     *
1935
-     * @return bool $success
1936
-     */
1937
-    public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
1938
-
1939
-        if( ! ( $user_id > 0 ) ){
1940
-            $user_id = get_current_user_id();
1941
-        }
1942
-
1943
-        $supported_post_types = array( 'course', 'lesson' );
1944
-        $post_type = get_post_type( $post_id );
1945
-        if( empty( $post_id ) || empty( $data_key )
1946
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1947
-            || !get_userdata( $user_id )
1948
-            || ! in_array( $post_type, $supported_post_types )  ){
1949
-
1950
-            return false;
1951
-        }
1952
-
1953
-        // check if there and existing Sensei status on this post type if not create it
1954
-        // and get the  activity ID
1955
-        $status_function = 'user_'.$post_type.'_status';
1956
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
1957
-        if( ! isset( $sensei_user_status->comment_ID ) ){
1958
-
1959
-            $start_function = 'user_start_'.$post_type;
1960
-            $sensei_user_activity_id = self::$start_function( $user_id, $post_id );
1961
-
1962
-        }else{
1963
-
1964
-            $sensei_user_activity_id = $sensei_user_status->comment_ID;
1965
-
1966
-        }
1967
-
1968
-        // store the data
1969
-        $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
1970
-
1971
-       return $success;
1972
-
1973
-    }//update_user_data
1974
-
1975
-    /**
1976
-     * Get the user data stored on the passed in post type
1977
-     *
1978
-     * This function gets the comment meta on the lesson or course status
1979
-     *
1980
-     * @since 1.7.4
1981
-     *
1982
-     * @param $data_key
1983
-     * @param $post_id
1984
-     * @param int $user_id
1985
-     *
1986
-     * @return mixed $user_data_value
1987
-     */
1988
-    public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
1989
-
1990
-        $user_data_value = true;
1991
-
1992
-        if( ! ( $user_id > 0 ) ){
1993
-            $user_id = get_current_user_id();
1994
-        }
1995
-
1996
-        $supported_post_types = array( 'course', 'lesson' );
1997
-        $post_type = get_post_type( $post_id );
1998
-        if( empty( $post_id ) || empty( $data_key )
1999
-            || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2000
-            || ! get_userdata( $user_id )
2001
-            || !in_array( $post_type, $supported_post_types )  ){
2002
-
2003
-            return false;
2004
-        }
2005
-
2006
-        // check if there and existing Sensei status on this post type if not create it
2007
-        // and get the  activity ID
2008
-        $status_function = 'user_'.$post_type.'_status';
2009
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2010
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2011
-            return false;
2012
-        }
2013
-
2014
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
2015
-        $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
2016
-
2017
-        return $user_data_value;
2018
-
2019
-    }// end get_user_data
2020
-
2021
-    /**
2022
-     * Delete the Sensei user data for the given key, Sensei post type and user combination.
2023
-     *
2024
-     * @param int $data_key
2025
-     * @param int $post_id
2026
-     * @param int $user_id
2027
-     *
2028
-     * @return bool $deleted
2029
-     */
2030
-    public static function delete_user_data( $data_key, $post_id , $user_id ){
2031
-        $deleted = true;
1904
+	/**
1905
+	 *
1906
+	 * Alias to Woothemes_Sensei_Utils::update_user_data
1907
+	 * @since 1.7.4
1908
+	 *
1909
+	 * @param string $data_key maximum 39 characters allowed
1910
+	 * @param int $post_id
1911
+	 * @param mixed $value
1912
+	 * @param int $user_id
1913
+	 *
1914
+	 * @return bool $success
1915
+	 */
1916
+	public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0  ){
2032 1917
 
2033
-        if( ! ( $user_id > 0 ) ){
2034
-            $user_id = get_current_user_id();
2035
-        }
1918
+		return self::update_user_data( $data_key, $post_id, $value , $user_id );
2036 1919
 
2037
-        $supported_post_types = array( 'course', 'lesson' );
2038
-        $post_type = get_post_type( $post_id );
2039
-        if( empty( $post_id ) || empty( $data_key )
2040
-            || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2041
-            || ! get_userdata( $user_id )
2042
-            || !in_array( $post_type, $supported_post_types )  ){
1920
+	}// end add_user_data
2043 1921
 
2044
-            return false;
2045
-        }
1922
+	/**
1923
+	 * add user specific data to the passed in sensei post type id
1924
+	 *
1925
+	 * This function saves comment meta on the users current status. If no status is available
1926
+	 * status will be created. It only operates on the available sensei Post types: course, lesson, quiz.
1927
+	 *
1928
+	 * @since 1.7.4
1929
+	 *
1930
+	 * @param string $data_key maximum 39 characters allowed
1931
+	 * @param int $post_id
1932
+	 * @param mixed $value
1933
+	 * @param int $user_id
1934
+	 *
1935
+	 * @return bool $success
1936
+	 */
1937
+	public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0  ){
2046 1938
 
2047
-        // check if there and existing Sensei status on this post type if not create it
2048
-        // and get the  activity ID
2049
-        $status_function = 'user_'.$post_type.'_status';
2050
-        $sensei_user_status = self::$status_function( $post_id ,$user_id  );
2051
-        if( ! isset( $sensei_user_status->comment_ID ) ){
2052
-            return false;
2053
-        }
1939
+		if( ! ( $user_id > 0 ) ){
1940
+			$user_id = get_current_user_id();
1941
+		}
2054 1942
 
2055
-        $sensei_user_activity_id = $sensei_user_status->comment_ID;
2056
-        $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
1943
+		$supported_post_types = array( 'course', 'lesson' );
1944
+		$post_type = get_post_type( $post_id );
1945
+		if( empty( $post_id ) || empty( $data_key )
1946
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
1947
+			|| !get_userdata( $user_id )
1948
+			|| ! in_array( $post_type, $supported_post_types )  ){
2057 1949
 
2058
-        return $deleted;
1950
+			return false;
1951
+		}
2059 1952
 
2060
-    }// end delete_user_data
1953
+		// check if there and existing Sensei status on this post type if not create it
1954
+		// and get the  activity ID
1955
+		$status_function = 'user_'.$post_type.'_status';
1956
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
1957
+		if( ! isset( $sensei_user_status->comment_ID ) ){
2061 1958
 
1959
+			$start_function = 'user_start_'.$post_type;
1960
+			$sensei_user_activity_id = self::$start_function( $user_id, $post_id );
2062 1961
 
2063
-    /**
2064
-     * The function creates a drop down. Never write up a Sensei select statement again.
2065
-     *
2066
-     * @since 1.8.0
2067
-     *
2068
-     * @param string $selected_value
2069
-     * @param $options{
2070
-     *    @type string $value the value saved in the database
2071
-     *    @type string $option what the user will see in the list of items
2072
-     * }
2073
-     * @param array $attributes{
2074
-     *   @type string $attribute  type such name or id etc.
2075
-     *  @type string $value
2076
-     * }
2077
-     * @param bool $enable_none_option
2078
-     *
2079
-     * @return string $drop_down_element
2080
-     */
2081
-    public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
1962
+		}else{
2082 1963
 
2083
-        $drop_down_element = '';
1964
+			$sensei_user_activity_id = $sensei_user_status->comment_ID;
2084 1965
 
2085
-        // setup the basic attributes
2086
-        if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
1966
+		}
2087 1967
 
2088
-            $attributes['name'] = 'sensei-options';
1968
+		// store the data
1969
+		$success = update_comment_meta( $sensei_user_activity_id, $data_key, $value );
2089 1970
 
2090
-        }
1971
+	   return $success;
2091 1972
 
2092
-        if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
1973
+	}//update_user_data
2093 1974
 
2094
-            $attributes['id'] = 'sensei-options';
1975
+	/**
1976
+	 * Get the user data stored on the passed in post type
1977
+	 *
1978
+	 * This function gets the comment meta on the lesson or course status
1979
+	 *
1980
+	 * @since 1.7.4
1981
+	 *
1982
+	 * @param $data_key
1983
+	 * @param $post_id
1984
+	 * @param int $user_id
1985
+	 *
1986
+	 * @return mixed $user_data_value
1987
+	 */
1988
+	public static function get_user_data( $data_key, $post_id, $user_id = 0  ){
2095 1989
 
2096
-        }
1990
+		$user_data_value = true;
2097 1991
 
2098
-        if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
1992
+		if( ! ( $user_id > 0 ) ){
1993
+			$user_id = get_current_user_id();
1994
+		}
2099 1995
 
2100
-            $attributes['class'] ='chosen_select widefat';
1996
+		$supported_post_types = array( 'course', 'lesson' );
1997
+		$post_type = get_post_type( $post_id );
1998
+		if( empty( $post_id ) || empty( $data_key )
1999
+			|| ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2000
+			|| ! get_userdata( $user_id )
2001
+			|| !in_array( $post_type, $supported_post_types )  ){
2101 2002
 
2102
-        }
2003
+			return false;
2004
+		}
2103 2005
 
2104
-        // create element attributes
2105
-        $combined_attributes = '';
2106
-        foreach( $attributes as $attribute => $value ){
2006
+		// check if there and existing Sensei status on this post type if not create it
2007
+		// and get the  activity ID
2008
+		$status_function = 'user_'.$post_type.'_status';
2009
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
2010
+		if( ! isset( $sensei_user_status->comment_ID ) ){
2011
+			return false;
2012
+		}
2107 2013
 
2108
-            $combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2014
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
2015
+		$user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true );
2109 2016
 
2110
-        }// end for each
2017
+		return $user_data_value;
2111 2018
 
2019
+	}// end get_user_data
2112 2020
 
2113
-        // create the select element
2114
-        $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2021
+	/**
2022
+	 * Delete the Sensei user data for the given key, Sensei post type and user combination.
2023
+	 *
2024
+	 * @param int $data_key
2025
+	 * @param int $post_id
2026
+	 * @param int $user_id
2027
+	 *
2028
+	 * @return bool $deleted
2029
+	 */
2030
+	public static function delete_user_data( $data_key, $post_id , $user_id ){
2031
+		$deleted = true;
2115 2032
 
2116
-        // show the none option if the client requested
2117
-        if( $enable_none_option ) {
2118
-            $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2119
-        }
2033
+		if( ! ( $user_id > 0 ) ){
2034
+			$user_id = get_current_user_id();
2035
+		}
2120 2036
 
2121
-        if ( count( $options ) > 0 ) {
2037
+		$supported_post_types = array( 'course', 'lesson' );
2038
+		$post_type = get_post_type( $post_id );
2039
+		if( empty( $post_id ) || empty( $data_key )
2040
+			|| ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 )
2041
+			|| ! get_userdata( $user_id )
2042
+			|| !in_array( $post_type, $supported_post_types )  ){
2122 2043
 
2123
-            foreach ($options as $value => $option ){
2044
+			return false;
2045
+		}
2124 2046
 
2125
-                $element = '';
2126
-                $element.= '<option value="' . esc_attr( $value ) . '"';
2127
-                $element .= selected( $value, $selected_value, false ) . '>';
2128
-                $element .= esc_html(  $option ) . '</option>' . "\n";
2047
+		// check if there and existing Sensei status on this post type if not create it
2048
+		// and get the  activity ID
2049
+		$status_function = 'user_'.$post_type.'_status';
2050
+		$sensei_user_status = self::$status_function( $post_id ,$user_id  );
2051
+		if( ! isset( $sensei_user_status->comment_ID ) ){
2052
+			return false;
2053
+		}
2129 2054
 
2130
-                // add the element to the select html
2131
-                $drop_down_element.= $element;
2132
-            } // End For Loop
2055
+		$sensei_user_activity_id = $sensei_user_status->comment_ID;
2056
+		$deleted = delete_comment_meta( $sensei_user_activity_id , $data_key );
2133 2057
 
2134
-        } // End If Statement
2058
+		return $deleted;
2135 2059
 
2136
-        $drop_down_element .= '</select>' . "\n";
2060
+	}// end delete_user_data
2137 2061
 
2138
-        return $drop_down_element;
2139 2062
 
2140
-    }// generate_drop_down
2063
+	/**
2064
+	 * The function creates a drop down. Never write up a Sensei select statement again.
2065
+	 *
2066
+	 * @since 1.8.0
2067
+	 *
2068
+	 * @param string $selected_value
2069
+	 * @param $options{
2070
+	 *    @type string $value the value saved in the database
2071
+	 *    @type string $option what the user will see in the list of items
2072
+	 * }
2073
+	 * @param array $attributes{
2074
+	 *   @type string $attribute  type such name or id etc.
2075
+	 *  @type string $value
2076
+	 * }
2077
+	 * @param bool $enable_none_option
2078
+	 *
2079
+	 * @return string $drop_down_element
2080
+	 */
2081
+	public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) {
2082
+
2083
+		$drop_down_element = '';
2084
+
2085
+		// setup the basic attributes
2086
+		if( !isset( $attributes['name'] ) || empty( $attributes['name']  ) ) {
2087
+
2088
+			$attributes['name'] = 'sensei-options';
2141 2089
 
2142
-    /**
2143
-     * Wrapper for the default php round() function.
2144
-     * This allows us to give more control to a user on how they can round Sensei
2145
-     * decimals passed through this function.
2146
-     *
2147
-     * @since 1.8.5
2148
-     *
2149
-     * @param double $val
2150
-     * @param int $precision
2151
-     * @param $mode
2152
-     * @param string $context
2153
-     *
2154
-     * @return double $val
2155
-     */
2156
-    public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2090
+		}
2091
+
2092
+		if( !isset( $attributes['id'] ) || empty( $attributes['id']  ) ) {
2093
+
2094
+			$attributes['id'] = 'sensei-options';
2095
+
2096
+		}
2157 2097
 
2158
-        /**å
2098
+		if( !isset( $attributes['class'] ) || empty( $attributes['class']  ) ) {
2099
+
2100
+			$attributes['class'] ='chosen_select widefat';
2101
+
2102
+		}
2103
+
2104
+		// create element attributes
2105
+		$combined_attributes = '';
2106
+		foreach( $attributes as $attribute => $value ){
2107
+
2108
+			$combined_attributes .= $attribute . '="'.$value.'"' . ' ';
2109
+
2110
+		}// end for each
2111
+
2112
+
2113
+		// create the select element
2114
+		$drop_down_element .= '<select '. $combined_attributes . ' >' . "\n";
2115
+
2116
+		// show the none option if the client requested
2117
+		if( $enable_none_option ) {
2118
+			$drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>';
2119
+		}
2120
+
2121
+		if ( count( $options ) > 0 ) {
2122
+
2123
+			foreach ($options as $value => $option ){
2124
+
2125
+				$element = '';
2126
+				$element.= '<option value="' . esc_attr( $value ) . '"';
2127
+				$element .= selected( $value, $selected_value, false ) . '>';
2128
+				$element .= esc_html(  $option ) . '</option>' . "\n";
2129
+
2130
+				// add the element to the select html
2131
+				$drop_down_element.= $element;
2132
+			} // End For Loop
2133
+
2134
+		} // End If Statement
2135
+
2136
+		$drop_down_element .= '</select>' . "\n";
2137
+
2138
+		return $drop_down_element;
2139
+
2140
+	}// generate_drop_down
2141
+
2142
+	/**
2143
+	 * Wrapper for the default php round() function.
2144
+	 * This allows us to give more control to a user on how they can round Sensei
2145
+	 * decimals passed through this function.
2146
+	 *
2147
+	 * @since 1.8.5
2148
+	 *
2149
+	 * @param double $val
2150
+	 * @param int $precision
2151
+	 * @param $mode
2152
+	 * @param string $context
2153
+	 *
2154
+	 * @return double $val
2155
+	 */
2156
+	public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = ''  ){
2157
+
2158
+		/**å
2159 2159
          * Change the precision for the Sensei_Utils::round function.
2160 2160
          * the precision given will be passed into the php round function
2161 2161
          * @since 1.8.5
2162 2162
          */
2163
-        $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2164
-
2165
-        /**
2166
-         * Change the mode for the Sensei_Utils::round function.
2167
-         * the mode given will be passed into the php round function
2168
-         *
2169
-         * This applies only to PHP version 5.3.0 and greater
2170
-         *
2171
-         * @since 1.8.5
2172
-         */
2173
-        $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2163
+		$precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode );
2174 2164
 
2175
-        if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2165
+		/**
2166
+		 * Change the mode for the Sensei_Utils::round function.
2167
+		 * the mode given will be passed into the php round function
2168
+		 *
2169
+		 * This applies only to PHP version 5.3.0 and greater
2170
+		 *
2171
+		 * @since 1.8.5
2172
+		 */
2173
+		$mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision   );
2176 2174
 
2177
-            return round( $val, $precision, $mode );
2175
+		if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) {
2178 2176
 
2179
-        }else{
2177
+			return round( $val, $precision, $mode );
2178
+
2179
+		}else{
2180 2180
 
2181
-            return round( $val, $precision );
2181
+			return round( $val, $precision );
2182 2182
 
2183
-        }
2183
+		}
2184 2184
 
2185
-    }
2185
+	}
2186 2186
 
2187
-    /**
2188
-     * Returns the current url with all the query vars
2189
-     *
2190
-     * @since 1.9.0
2191
-     * @return string $url
2192
-     */
2193
-    public static function get_current_url(){
2187
+	/**
2188
+	 * Returns the current url with all the query vars
2189
+	 *
2190
+	 * @since 1.9.0
2191
+	 * @return string $url
2192
+	 */
2193
+	public static function get_current_url(){
2194 2194
 
2195
-        global $wp;
2196
-        $current_url = trailingslashit( home_url( $wp->request ) );
2197
-        if ( isset( $_GET ) ) {
2195
+		global $wp;
2196
+		$current_url = trailingslashit( home_url( $wp->request ) );
2197
+		if ( isset( $_GET ) ) {
2198 2198
 
2199
-            foreach ($_GET as $param => $val ) {
2199
+			foreach ($_GET as $param => $val ) {
2200 2200
 
2201
-                $current_url = add_query_arg( $param, $val , $current_url );
2201
+				$current_url = add_query_arg( $param, $val , $current_url );
2202 2202
 
2203
-            }
2204
-        }
2203
+			}
2204
+		}
2205 2205
 
2206
-        return $current_url;
2207
-    }
2206
+		return $current_url;
2207
+	}
2208 2208
 
2209
-    /**
2210
-     * Restore the global WP_Query
2211
-     *
2212
-     * @since 1.9.0
2213
-     */
2214
-    public static function restore_wp_query() {
2209
+	/**
2210
+	 * Restore the global WP_Query
2211
+	 *
2212
+	 * @since 1.9.0
2213
+	 */
2214
+	public static function restore_wp_query() {
2215 2215
 
2216
-        wp_reset_query();
2216
+		wp_reset_query();
2217 2217
 
2218
-    }
2218
+	}
2219 2219
 
2220
-    /**
2221
-     * Merge two arrays in a zip like fashion.
2222
-     * If one array is longer than the other the elements will be apended
2223
-     * to the end of the resulting array.
2224
-     *
2225
-     * @since 1.9.0
2226
-     *
2227
-     * @param array $array_a
2228
-     * @param array $array_b
2229
-     * @return array $merged_array
2230
-     */
2231
-    public static function array_zip_merge( $array_a, $array_b ){
2220
+	/**
2221
+	 * Merge two arrays in a zip like fashion.
2222
+	 * If one array is longer than the other the elements will be apended
2223
+	 * to the end of the resulting array.
2224
+	 *
2225
+	 * @since 1.9.0
2226
+	 *
2227
+	 * @param array $array_a
2228
+	 * @param array $array_b
2229
+	 * @return array $merged_array
2230
+	 */
2231
+	public static function array_zip_merge( $array_a, $array_b ){
2232 2232
 
2233
-        if( ! is_array( $array_a ) || ! is_array( $array_b )  ){
2234
-            trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2235
-        }
2233
+		if( ! is_array( $array_a ) || ! is_array( $array_b )  ){
2234
+			trigger_error('array_zip_merge requires both arrays to be indexed arrays ');
2235
+		}
2236 2236
 
2237
-        $merged_array = array();
2238
-        $total_elements = count( $array_a )  + count( $array_b );
2237
+		$merged_array = array();
2238
+		$total_elements = count( $array_a )  + count( $array_b );
2239 2239
 
2240
-        // Zip arrays
2241
-        for ( $i = 0; $i < $total_elements; $i++) {
2240
+		// Zip arrays
2241
+		for ( $i = 0; $i < $total_elements; $i++) {
2242 2242
 
2243
-            // if has an element at current index push a on top
2244
-            if( isset( $array_a[ $i ] ) ){
2245
-                $merged_array[] = $array_a[ $i ]  ;
2246
-            }
2243
+			// if has an element at current index push a on top
2244
+			if( isset( $array_a[ $i ] ) ){
2245
+				$merged_array[] = $array_a[ $i ]  ;
2246
+			}
2247 2247
 
2248
-            // next if $array_b has an element at current index push a on top of the element
2249
-            // from a if there was one, if not the element before that.
2250
-            if( isset( $array_b[ $i ] ) ){
2251
-                $merged_array[] = $array_b[ $i ]  ;
2252
-            }
2248
+			// next if $array_b has an element at current index push a on top of the element
2249
+			// from a if there was one, if not the element before that.
2250
+			if( isset( $array_b[ $i ] ) ){
2251
+				$merged_array[] = $array_b[ $i ]  ;
2252
+			}
2253 2253
 
2254
-        }
2254
+		}
2255 2255
 
2256
-        return $merged_array;
2257
-    }
2256
+		return $merged_array;
2257
+	}
2258 2258
 
2259 2259
 } // End Class
2260 2260
 
Please login to merge, or discard this patch.
includes/class-sensei.php 1 patch
Indentation   +1007 added lines, -1007 removed lines patch added patch discarded remove patch
@@ -10,910 +10,910 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Sensei_Main {
12 12
 
13
-    /**
14
-     * @var string
15
-     * Reference to the main plugin file
16
-     */
17
-    private $file;
18
-
19
-    /**
20
-     * @var Sensei_Main $_instance to the the main and only instance of the Sensei class.
21
-     * @since 1.8.0
22
-     */
23
-    protected static $_instance = null;
24
-
25
-    /**
26
-     * Main reference to the plugins current version
27
-     */
28
-    public $version;
29
-
30
-    /**
31
-     * Public token, referencing for the text domain.
32
-     */
33
-    public $token = 'woothemes-sensei';
34
-
35
-    /**
36
-     * Plugin url and path for use when access resources.
37
-     */
38
-    public $plugin_url;
39
-    public $plugin_path;
40
-    public $template_url;
41
-
42
-    /**
43
-     * @var Sensei_PostTypes
44
-     * All Sensei sub classes. Currently used to access functionality contained within
45
-     * within Sensei sub classes e.g. Sensei()->course->all_courses()
46
-     */
47
-    public $post_types;
48
-
49
-    /**
50
-     * @var WooThemes_Sensei_Settings
51
-     */
52
-    public $settings;
53
-
54
-    /**
55
-     * @var WooThemes_Sensei_Course_Results
56
-     */
57
-    public $course_results;
58
-
59
-    /**
60
-     * @var Sensei_Updates
61
-     */
62
-    public $updates;
63
-    /**
64
-     * @var WooThemes_Sensei_Course
65
-     */
66
-    public $course;
67
-
68
-    /**
69
-     * @var WooThemes_Sensei_Lesson
70
-     */
71
-    public $lesson;
72
-
73
-    /**
74
-     * @var WooThemes_Sensei_Quiz
75
-     */
76
-    public $quiz;
77
-
78
-    /**
79
-     * @var WooThemes_Sensei_Question
80
-     */
81
-    public $question;
82
-
83
-    /**
84
-     * @var WooThemes_Sensei_Admin
85
-     */
86
-    public $admin;
87
-
88
-    /**
89
-     * @var WooThemes_Sensei_Frontend
90
-     */
91
-    public $frontend;
92
-
93
-    /**
94
-     * @var Sensei_Notices
95
-     */
96
-    public $notices;
97
-
98
-    /**
99
-     * @var WooThemes_Sensei_Grading
100
-     */
101
-    public $grading;
102
-
103
-    /**
104
-     * @var WooThemes_Sensei_Emails
105
-     */
106
-    public $emails;
107
-
108
-    /**
109
-     * @var WooThemes_Sensei_Learner_Profiles
110
-     */
111
-    public $learner_profiles;
112
-
113
-    /**
114
-     * @var Sensei_Teacher
115
-     */
116
-    public $teacher;
117
-
118
-    /**
119
-     * @var WooThemes_Sensei_Learners
120
-     */
121
-    public $learners;
122
-
123
-    /**
124
-     * @var array
125
-     * Global instance for access to the permissions message shown
126
-     * when users do not have the right privileges to access resources.
127
-     */
128
-    public $permissions_message;
129
-
130
-    /**
131
-     * @var Sensei_Core_Modules Sensei Modules functionality
132
-     */
133
-    public $modules;
134
-
135
-    /**
136
-     * @var Sensei_Analysis
137
-     */
138
-    public $analysis;
139
-
140
-    /**
141
-     * Constructor method.
142
-     * @param  string $file The base file of the plugin.
143
-     * @since  1.0.0
144
-     */
145
-    public function __construct ( $file ) {
146
-
147
-        // Setup object data
148
-        $this->file = $file;
149
-        $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) );
150
-        $this->plugin_path = trailingslashit( dirname( $file ) );
151
-        $this->template_url	= apply_filters( 'sensei_template_url', 'sensei/' );
152
-
153
-        // Initialize the core Sensei functionality
154
-        $this->init();
155
-
156
-        // Installation
157
-        if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install();
158
-
159
-        // Run this on activation.
160
-        register_activation_hook( $this->file, array( $this, 'activation' ) );
161
-
162
-        // Image Sizes
163
-        $this->init_image_sizes();
164
-
165
-        // load all hooks
166
-        $this->load_hooks();
167
-
168
-    } // End __construct()
169
-
170
-    /**
171
-     * Load the foundations of Sensei.
172
-     * @since 1.9.0
173
-     */
174
-    protected function init(){
175
-
176
-        // Localisation
177
-        $this->load_plugin_textdomain();
178
-        add_action( 'init', array( $this, 'load_localisation' ), 0 );
179
-
180
-        // Setup settings
181
-        $this->settings = new Sensei_Settings();
182
-
183
-        // load the shortcode loader into memory, so as to listen to all for
184
-        // all shortcodes on the front end
185
-        new Sensei_Shortcode_Loader();
186
-
187
-    }
188
-
189
-    /**
190
-     * Global Sensei Instance
191
-     *
192
-     * Ensure that only one instance of the main Sensei class can be loaded.
193
-     *
194
-     * @since 1.8.0
195
-     * @static
196
-     * @see WC()
197
-     * @return WooThemes_Sensei Instance.
198
-     */
199
-    public static function instance() {
13
+	/**
14
+	 * @var string
15
+	 * Reference to the main plugin file
16
+	 */
17
+	private $file;
18
+
19
+	/**
20
+	 * @var Sensei_Main $_instance to the the main and only instance of the Sensei class.
21
+	 * @since 1.8.0
22
+	 */
23
+	protected static $_instance = null;
24
+
25
+	/**
26
+	 * Main reference to the plugins current version
27
+	 */
28
+	public $version;
29
+
30
+	/**
31
+	 * Public token, referencing for the text domain.
32
+	 */
33
+	public $token = 'woothemes-sensei';
34
+
35
+	/**
36
+	 * Plugin url and path for use when access resources.
37
+	 */
38
+	public $plugin_url;
39
+	public $plugin_path;
40
+	public $template_url;
41
+
42
+	/**
43
+	 * @var Sensei_PostTypes
44
+	 * All Sensei sub classes. Currently used to access functionality contained within
45
+	 * within Sensei sub classes e.g. Sensei()->course->all_courses()
46
+	 */
47
+	public $post_types;
48
+
49
+	/**
50
+	 * @var WooThemes_Sensei_Settings
51
+	 */
52
+	public $settings;
53
+
54
+	/**
55
+	 * @var WooThemes_Sensei_Course_Results
56
+	 */
57
+	public $course_results;
58
+
59
+	/**
60
+	 * @var Sensei_Updates
61
+	 */
62
+	public $updates;
63
+	/**
64
+	 * @var WooThemes_Sensei_Course
65
+	 */
66
+	public $course;
67
+
68
+	/**
69
+	 * @var WooThemes_Sensei_Lesson
70
+	 */
71
+	public $lesson;
72
+
73
+	/**
74
+	 * @var WooThemes_Sensei_Quiz
75
+	 */
76
+	public $quiz;
77
+
78
+	/**
79
+	 * @var WooThemes_Sensei_Question
80
+	 */
81
+	public $question;
82
+
83
+	/**
84
+	 * @var WooThemes_Sensei_Admin
85
+	 */
86
+	public $admin;
87
+
88
+	/**
89
+	 * @var WooThemes_Sensei_Frontend
90
+	 */
91
+	public $frontend;
92
+
93
+	/**
94
+	 * @var Sensei_Notices
95
+	 */
96
+	public $notices;
97
+
98
+	/**
99
+	 * @var WooThemes_Sensei_Grading
100
+	 */
101
+	public $grading;
102
+
103
+	/**
104
+	 * @var WooThemes_Sensei_Emails
105
+	 */
106
+	public $emails;
107
+
108
+	/**
109
+	 * @var WooThemes_Sensei_Learner_Profiles
110
+	 */
111
+	public $learner_profiles;
112
+
113
+	/**
114
+	 * @var Sensei_Teacher
115
+	 */
116
+	public $teacher;
117
+
118
+	/**
119
+	 * @var WooThemes_Sensei_Learners
120
+	 */
121
+	public $learners;
122
+
123
+	/**
124
+	 * @var array
125
+	 * Global instance for access to the permissions message shown
126
+	 * when users do not have the right privileges to access resources.
127
+	 */
128
+	public $permissions_message;
129
+
130
+	/**
131
+	 * @var Sensei_Core_Modules Sensei Modules functionality
132
+	 */
133
+	public $modules;
134
+
135
+	/**
136
+	 * @var Sensei_Analysis
137
+	 */
138
+	public $analysis;
139
+
140
+	/**
141
+	 * Constructor method.
142
+	 * @param  string $file The base file of the plugin.
143
+	 * @since  1.0.0
144
+	 */
145
+	public function __construct ( $file ) {
146
+
147
+		// Setup object data
148
+		$this->file = $file;
149
+		$this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) );
150
+		$this->plugin_path = trailingslashit( dirname( $file ) );
151
+		$this->template_url	= apply_filters( 'sensei_template_url', 'sensei/' );
152
+
153
+		// Initialize the core Sensei functionality
154
+		$this->init();
155
+
156
+		// Installation
157
+		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install();
158
+
159
+		// Run this on activation.
160
+		register_activation_hook( $this->file, array( $this, 'activation' ) );
161
+
162
+		// Image Sizes
163
+		$this->init_image_sizes();
164
+
165
+		// load all hooks
166
+		$this->load_hooks();
167
+
168
+	} // End __construct()
169
+
170
+	/**
171
+	 * Load the foundations of Sensei.
172
+	 * @since 1.9.0
173
+	 */
174
+	protected function init(){
175
+
176
+		// Localisation
177
+		$this->load_plugin_textdomain();
178
+		add_action( 'init', array( $this, 'load_localisation' ), 0 );
179
+
180
+		// Setup settings
181
+		$this->settings = new Sensei_Settings();
182
+
183
+		// load the shortcode loader into memory, so as to listen to all for
184
+		// all shortcodes on the front end
185
+		new Sensei_Shortcode_Loader();
186
+
187
+	}
188
+
189
+	/**
190
+	 * Global Sensei Instance
191
+	 *
192
+	 * Ensure that only one instance of the main Sensei class can be loaded.
193
+	 *
194
+	 * @since 1.8.0
195
+	 * @static
196
+	 * @see WC()
197
+	 * @return WooThemes_Sensei Instance.
198
+	 */
199
+	public static function instance() {
200 200
 
201
-        if ( is_null( self::$_instance ) ) {
201
+		if ( is_null( self::$_instance ) ) {
202 202
 
203
-            //Sensei requires a reference to the main Sensei plugin file
204
-            $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php';
203
+			//Sensei requires a reference to the main Sensei plugin file
204
+			$sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php';
205 205
 
206
-            self::$_instance = new self( $sensei_main_plugin_file  );
206
+			self::$_instance = new self( $sensei_main_plugin_file  );
207 207
 
208
-            // load the global class objects needed throughout Sensei
209
-            self::$_instance->initialize_global_objects();
208
+			// load the global class objects needed throughout Sensei
209
+			self::$_instance->initialize_global_objects();
210 210
 
211
-        }
211
+		}
212 212
 
213
-        return self::$_instance;
213
+		return self::$_instance;
214 214
 
215
-    } // end instance()
215
+	} // end instance()
216 216
 
217
-    /**
218
-     * This function is linked into the activation
219
-     * hook to reset flush the urls to ensure Sensei post types show up.
220
-     *
221
-     * @since 1.9.0
222
-     *
223
-     * @param $plugin
224
-     */
225
-    public static function activation_flush_rules( $plugin ){
217
+	/**
218
+	 * This function is linked into the activation
219
+	 * hook to reset flush the urls to ensure Sensei post types show up.
220
+	 *
221
+	 * @since 1.9.0
222
+	 *
223
+	 * @param $plugin
224
+	 */
225
+	public static function activation_flush_rules( $plugin ){
226 226
 
227
-        if( strpos( $plugin, '/woothemes-sensei.php' ) > 0  ){
227
+		if( strpos( $plugin, '/woothemes-sensei.php' ) > 0  ){
228 228
 
229
-            flush_rewrite_rules(true);
229
+			flush_rewrite_rules(true);
230 230
 
231
-        }
231
+		}
232 232
 
233
-    }
233
+	}
234 234
 
235
-    /**
236
-     * Cloning is forbidden.
237
-     * @since 1.8.0
238
-     */
239
-    public function __clone() {
240
-        _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
241
-    }
235
+	/**
236
+	 * Cloning is forbidden.
237
+	 * @since 1.8.0
238
+	 */
239
+	public function __clone() {
240
+		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
241
+	}
242 242
 
243
-    /**
244
-     * Unserializing instances of this class is forbidden.
245
-     * @since 1.8.0
246
-     */
247
-    public function __wakeup() {
248
-        _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
249
-    }
243
+	/**
244
+	 * Unserializing instances of this class is forbidden.
245
+	 * @since 1.8.0
246
+	 */
247
+	public function __wakeup() {
248
+		_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woothemes-sensei' ), '1.8' );
249
+	}
250 250
 
251
-    /**
252
-     * Load the properties for the main Sensei object
253
-     *
254
-     * @since 1.9.0
255
-     */
256
-    public function initialize_global_objects(){
251
+	/**
252
+	 * Load the properties for the main Sensei object
253
+	 *
254
+	 * @since 1.9.0
255
+	 */
256
+	public function initialize_global_objects(){
257 257
 
258
-        // Setup post types.
259
-        $this->post_types = new Sensei_PostTypes();
258
+		// Setup post types.
259
+		$this->post_types = new Sensei_PostTypes();
260 260
 
261
-        // Lad the updates class
262
-        $this->updates = new Sensei_Updates( $this );
261
+		// Lad the updates class
262
+		$this->updates = new Sensei_Updates( $this );
263 263
 
264
-        // Load Course Results Class
265
-        $this->course_results = new Sensei_Course_Results();
264
+		// Load Course Results Class
265
+		$this->course_results = new Sensei_Course_Results();
266 266
 
267
-        // Load the teacher role
268
-        $this->teacher = new Sensei_Teacher();
267
+		// Load the teacher role
268
+		$this->teacher = new Sensei_Teacher();
269 269
 
270
-        // Add the Course class
271
-        $this->course = $this->post_types->course;
270
+		// Add the Course class
271
+		$this->course = $this->post_types->course;
272 272
 
273
-        // Add the lesson class
274
-        $this->lesson = $this->post_types->lesson;
273
+		// Add the lesson class
274
+		$this->lesson = $this->post_types->lesson;
275 275
 
276
-        // Add the question class
277
-        $this->question = $this->post_types->question;
276
+		// Add the question class
277
+		$this->question = $this->post_types->question;
278 278
 
279
-        //Add the quiz class
280
-        $this->quiz = $this->post_types->quiz;
279
+		//Add the quiz class
280
+		$this->quiz = $this->post_types->quiz;
281 281
 
282
-        // load the modules class after all plugsin are loaded
283
-	    $this->load_modules_class();
282
+		// load the modules class after all plugsin are loaded
283
+		$this->load_modules_class();
284 284
 
285
-        // Load Learner Management Functionality
286
-        $this->learners = new Sensei_Learner_Management( $this->file );
285
+		// Load Learner Management Functionality
286
+		$this->learners = new Sensei_Learner_Management( $this->file );
287 287
 
288
-        // Differentiate between administration and frontend logic.
289
-        if ( is_admin() ) {
288
+		// Differentiate between administration and frontend logic.
289
+		if ( is_admin() ) {
290 290
 
291
-            // Load Admin Welcome class
292
-            new Sensei_Welcome();
291
+			// Load Admin Welcome class
292
+			new Sensei_Welcome();
293 293
 
294
-            // Load Admin Class
295
-            $this->admin = new Sensei_Admin( $this->file );
294
+			// Load Admin Class
295
+			$this->admin = new Sensei_Admin( $this->file );
296 296
 
297
-            // Load Analysis Reports
298
-            $this->analysis = new Sensei_Analysis( $this->file );
297
+			// Load Analysis Reports
298
+			$this->analysis = new Sensei_Analysis( $this->file );
299 299
 
300
-        } else {
300
+		} else {
301 301
 
302
-            // Load Frontend Class
303
-            $this->frontend = new Sensei_Frontend();
302
+			// Load Frontend Class
303
+			$this->frontend = new Sensei_Frontend();
304 304
 
305
-            // Load notice Class
306
-            $this->notices = new Sensei_Notices();
305
+			// Load notice Class
306
+			$this->notices = new Sensei_Notices();
307 307
 
308
-            // Load built in themes support integration
309
-            new Sensei_Theme_Integration_Loader();
308
+			// Load built in themes support integration
309
+			new Sensei_Theme_Integration_Loader();
310 310
 
311 311
 
312
-        }
312
+		}
313 313
 
314
-        // Load Grading Functionality
315
-        $this->grading = new Sensei_Grading( $this->file );
314
+		// Load Grading Functionality
315
+		$this->grading = new Sensei_Grading( $this->file );
316 316
 
317
-        // Load Email Class
318
-        $this->emails = new Sensei_Emails( $this->file );
317
+		// Load Email Class
318
+		$this->emails = new Sensei_Emails( $this->file );
319 319
 
320
-        // Load Learner Profiles Class
321
-        $this->learner_profiles = new Sensei_Learner_Profiles();
320
+		// Load Learner Profiles Class
321
+		$this->learner_profiles = new Sensei_Learner_Profiles();
322 322
 
323
-    }
323
+	}
324 324
 
325
-    /**
326
-     * Initialize all Sensei hooks
327
-     *
328
-     * @since 1.9.0
329
-     */
330
-    public function load_hooks(){
325
+	/**
326
+	 * Initialize all Sensei hooks
327
+	 *
328
+	 * @since 1.9.0
329
+	 */
330
+	public function load_hooks(){
331 331
 
332
-        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
333
-        add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) );
332
+		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
333
+		add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) );
334 334
 
335
-        // Filter comment counts
336
-        add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 );
335
+		// Filter comment counts
336
+		add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 );
337 337
 
338
-        add_action( 'body_class', array( $this, 'body_class' ) );
338
+		add_action( 'body_class', array( $this, 'body_class' ) );
339 339
 
340
-        // Check for and activate JetPack LaTeX support
341
-        add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules
340
+		// Check for and activate JetPack LaTeX support
341
+		add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules
342 342
 
343
-        // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1
344
-        add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 );
343
+		// check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1
344
+		add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 );
345 345
 
346
-    }
346
+	}
347 347
 
348
-    /**
349
-     * Run Sensei updates.
350
-     * @access  public
351
-     * @since   1.1.0
352
-     * @return  void
353
-     */
354
-    public function run_updates() {
355
-        // Run updates if administrator
356
-        if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) {
348
+	/**
349
+	 * Run Sensei updates.
350
+	 * @access  public
351
+	 * @since   1.1.0
352
+	 * @return  void
353
+	 */
354
+	public function run_updates() {
355
+		// Run updates if administrator
356
+		if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) {
357 357
 
358
-            $this->updates->update();
358
+			$this->updates->update();
359 359
 
360
-        } // End If Statement
361
-    } // End run_updates()
360
+		} // End If Statement
361
+	} // End run_updates()
362 362
 
363
-    /**
364
-     * Register the widgets.
365
-     * @access public
366
-     * @since  1.0.0
367
-     * @return void
368
-     */
369
-    public function register_widgets () {
370
-        // Widget List (key => value is filename => widget class).
371
-        $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 	'course-component' 	=> 'Course_Component',
372
-                'lesson-component' 	=> 'Lesson_Component',
373
-                'course-categories' => 'Course_Categories',
374
-                'category-courses' 	=> 'Category_Courses' )
375
-        );
376
-        foreach ( $widget_list as $key => $value ) {
377
-            if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' ) ) {
378
-                require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' );
379
-                register_widget( 'WooThemes_Sensei_' . $value . '_Widget' );
380
-            }
381
-        } // End For Loop
363
+	/**
364
+	 * Register the widgets.
365
+	 * @access public
366
+	 * @since  1.0.0
367
+	 * @return void
368
+	 */
369
+	public function register_widgets () {
370
+		// Widget List (key => value is filename => widget class).
371
+		$widget_list = apply_filters( 'sensei_registered_widgets_list', array( 	'course-component' 	=> 'Course_Component',
372
+				'lesson-component' 	=> 'Lesson_Component',
373
+				'course-categories' => 'Course_Categories',
374
+				'category-courses' 	=> 'Category_Courses' )
375
+		);
376
+		foreach ( $widget_list as $key => $value ) {
377
+			if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' ) ) {
378
+				require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key  . '.php' );
379
+				register_widget( 'WooThemes_Sensei_' . $value . '_Widget' );
380
+			}
381
+		} // End For Loop
382 382
 
383
-        do_action( 'sensei_register_widgets' );
383
+		do_action( 'sensei_register_widgets' );
384 384
 
385
-    } // End register_widgets()
385
+	} // End register_widgets()
386 386
 
387
-    /**
388
-     * Load the plugin's localisation file.
389
-     * @access public
390
-     * @since  1.0.0
391
-     * @return void
392
-     */
393
-    public function load_localisation () {
387
+	/**
388
+	 * Load the plugin's localisation file.
389
+	 * @access public
390
+	 * @since  1.0.0
391
+	 * @return void
392
+	 */
393
+	public function load_localisation () {
394 394
 
395
-        load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
395
+		load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' );
396 396
 
397
-    } // End load_localisation()
397
+	} // End load_localisation()
398 398
 
399
-    /**
400
-     * Load the plugin textdomain from the main WordPress "languages" folder.
401
-     * @access  public
402
-     * @since   1.0.0
403
-     * @return  void
404
-     */
405
-    public function load_plugin_textdomain () {
406
-
407
-        $domain = 'woothemes-sensei';
408
-        // The "plugin_locale" filter is also used in load_plugin_textdomain()
409
-        $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
410
-        load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
411
-        load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' );
412
-
413
-    } // End load_plugin_textdomain()
414
-
415
-    /**
416
-     * Run on activation.
417
-     * @access public
418
-     * @since  1.0.0
419
-     * @return void
420
-     */
421
-    public function activation () {
422
-
423
-        $this->register_plugin_version();
424
-
425
-    } // End activation()
426
-
427
-
428
-    /**
429
-     * Register activation hooks.
430
-     * @access public
431
-     * @since  1.0.0
432
-     * @return void
433
-     */
434
-    public function install () {
435
-
436
-        register_activation_hook( $this->file, array( $this, 'activate_sensei' ) );
437
-        register_activation_hook( $this->file, 'flush_rewrite_rules' );
438
-
439
-    } // End install()
440
-
441
-
442
-    /**
443
-     * Run on activation of the plugin.
444
-     * @access public
445
-     * @since  1.0.0
446
-     * @return void
447
-     */
448
-    public function activate_sensei () {
449
-
450
-        update_option( 'skip_install_sensei_pages', 0 );
451
-        update_option( 'sensei_installed', 1 );
452
-
453
-    } // End activate_sensei()
454
-
455
-    /**
456
-     * Register the plugin's version.
457
-     * @access public
458
-     * @since  1.0.0
459
-     * @return void
460
-     */
461
-    private function register_plugin_version () {
462
-        if ( $this->version != '' ) {
463
-
464
-            update_option( 'woothemes-sensei-version', $this->version );
465
-
466
-        }
467
-    } // End register_plugin_version()
468
-
469
-    /**
470
-     * Ensure that "post-thumbnails" support is available for those themes that don't register it.
471
-     * @access  public
472
-     * @since   1.0.1
473
-     * @return  void
474
-     */
475
-    public function ensure_post_thumbnails_support () {
399
+	/**
400
+	 * Load the plugin textdomain from the main WordPress "languages" folder.
401
+	 * @access  public
402
+	 * @since   1.0.0
403
+	 * @return  void
404
+	 */
405
+	public function load_plugin_textdomain () {
406
+
407
+		$domain = 'woothemes-sensei';
408
+		// The "plugin_locale" filter is also used in load_plugin_textdomain()
409
+		$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
410
+		load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' );
411
+		load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' );
412
+
413
+	} // End load_plugin_textdomain()
414
+
415
+	/**
416
+	 * Run on activation.
417
+	 * @access public
418
+	 * @since  1.0.0
419
+	 * @return void
420
+	 */
421
+	public function activation () {
422
+
423
+		$this->register_plugin_version();
424
+
425
+	} // End activation()
426
+
427
+
428
+	/**
429
+	 * Register activation hooks.
430
+	 * @access public
431
+	 * @since  1.0.0
432
+	 * @return void
433
+	 */
434
+	public function install () {
435
+
436
+		register_activation_hook( $this->file, array( $this, 'activate_sensei' ) );
437
+		register_activation_hook( $this->file, 'flush_rewrite_rules' );
438
+
439
+	} // End install()
440
+
441
+
442
+	/**
443
+	 * Run on activation of the plugin.
444
+	 * @access public
445
+	 * @since  1.0.0
446
+	 * @return void
447
+	 */
448
+	public function activate_sensei () {
449
+
450
+		update_option( 'skip_install_sensei_pages', 0 );
451
+		update_option( 'sensei_installed', 1 );
452
+
453
+	} // End activate_sensei()
454
+
455
+	/**
456
+	 * Register the plugin's version.
457
+	 * @access public
458
+	 * @since  1.0.0
459
+	 * @return void
460
+	 */
461
+	private function register_plugin_version () {
462
+		if ( $this->version != '' ) {
463
+
464
+			update_option( 'woothemes-sensei-version', $this->version );
465
+
466
+		}
467
+	} // End register_plugin_version()
468
+
469
+	/**
470
+	 * Ensure that "post-thumbnails" support is available for those themes that don't register it.
471
+	 * @access  public
472
+	 * @since   1.0.1
473
+	 * @return  void
474
+	 */
475
+	public function ensure_post_thumbnails_support () {
476 476
 
477
-        if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); }
477
+		if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); }
478 478
 
479
-    } // End ensure_post_thumbnails_support()
479
+	} // End ensure_post_thumbnails_support()
480 480
 
481
-    /**
482
-     * template_loader function.
483
-     *
484
-     * @access public
485
-     * @param mixed $template
486
-     * @return void
487
-     * @deprecated
488
-     */
489
-    public function template_loader ( $template = '' ) {
481
+	/**
482
+	 * template_loader function.
483
+	 *
484
+	 * @access public
485
+	 * @param mixed $template
486
+	 * @return void
487
+	 * @deprecated
488
+	 */
489
+	public function template_loader ( $template = '' ) {
490 490
 
491
-        _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' );
492
-        Sensei_Templates::template_loader( $template );
491
+		_deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' );
492
+		Sensei_Templates::template_loader( $template );
493 493
 
494
-    } // End template_loader()
494
+	} // End template_loader()
495 495
 
496
-    /**
497
-     * Determine the relative path to the plugin's directory.
498
-     * @access public
499
-     * @since  1.0.0
500
-     * @return string $sensei_plugin_path
501
-     */
502
-    public function plugin_path () {
496
+	/**
497
+	 * Determine the relative path to the plugin's directory.
498
+	 * @access public
499
+	 * @since  1.0.0
500
+	 * @return string $sensei_plugin_path
501
+	 */
502
+	public function plugin_path () {
503 503
 
504
-        if ( $this->plugin_path ) {
504
+		if ( $this->plugin_path ) {
505 505
 
506
-            $sensei_plugin_path =  $this->plugin_path;
506
+			$sensei_plugin_path =  $this->plugin_path;
507 507
 
508
-        }else{
508
+		}else{
509 509
 
510
-            $sensei_plugin_path = plugin_dir_path( __FILE__ );
510
+			$sensei_plugin_path = plugin_dir_path( __FILE__ );
511 511
 
512
-        }
512
+		}
513 513
 
514
-        return $sensei_plugin_path;
514
+		return $sensei_plugin_path;
515 515
 
516
-    } // End plugin_path()
516
+	} // End plugin_path()
517 517
 
518
-    /**
519
-     * Retrieve the ID of a specified page setting.
520
-     * @access public
521
-     * @since  1.0.0
522
-     * @param  string $page
523
-     * @return int
524
-     */
525
-    public function get_page_id ( $page ) {
526
-        $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) );
527
-        return ( $page ) ? $page : -1;
528
-    } // End get_page_id()
518
+	/**
519
+	 * Retrieve the ID of a specified page setting.
520
+	 * @access public
521
+	 * @since  1.0.0
522
+	 * @param  string $page
523
+	 * @return int
524
+	 */
525
+	public function get_page_id ( $page ) {
526
+		$page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) );
527
+		return ( $page ) ? $page : -1;
528
+	} // End get_page_id()
529 529
 
530
-    /**
531
-     * check_user_permissions function.
532
-     *
533
-     * @access public
534
-     * @param string $page (default: '')
535
-     *
536
-     * @return bool
537
-     */
538
-    public function check_user_permissions ( $page = '' ) {
530
+	/**
531
+	 * check_user_permissions function.
532
+	 *
533
+	 * @access public
534
+	 * @param string $page (default: '')
535
+	 *
536
+	 * @return bool
537
+	 */
538
+	public function check_user_permissions ( $page = '' ) {
539 539
 
540
-        global $current_user, $post;
540
+		global $current_user, $post;
541 541
 
542
-        $user_allowed = false;
542
+		$user_allowed = false;
543 543
 
544
-        switch ( $page ) {
545
-	        case 'course-single':
546
-		        // check for prerequisite course or lesson,
547
-		        $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true );
548
-		        $update_course          = Sensei_WC::course_update( $post->ID );
544
+		switch ( $page ) {
545
+			case 'course-single':
546
+				// check for prerequisite course or lesson,
547
+				$course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true );
548
+				$update_course          = Sensei_WC::course_update( $post->ID );
549 549
 
550
-		        // Count completed lessons
551
-		        if ( 0 < absint( $course_prerequisite_id ) ) {
550
+				// Count completed lessons
551
+				if ( 0 < absint( $course_prerequisite_id ) ) {
552 552
 
553
-			        $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID );
553
+					$prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID );
554 554
 
555
-		        } else {
556
-			        $prerequisite_complete = true;
557
-		        } // End If Statement
555
+				} else {
556
+					$prerequisite_complete = true;
557
+				} // End If Statement
558 558
 
559
-		        // Handles restrictions on the course
560
-		        if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) {
559
+				// Handles restrictions on the course
560
+				if ( ( ! $prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) ) {
561 561
 
562
-			        $user_allowed = false;
563
-			        $course_link  = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
564
-			        $this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' );
562
+					$user_allowed = false;
563
+					$course_link  = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
564
+					$this->notices->add_notice( sprintf( __( 'Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ), 'info' );
565 565
 
566
-		        } elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID )  ) {
566
+				} elseif( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $post->ID ) && ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID )  ) {
567 567
 
568
-			        $message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' );
569
-			        $this->notices->add_notice( $message, 'info' );
568
+					$message = sprintf( __( 'Or %1$s login %2$s to access your purchased courses', 'woothemes-sensei' ), '<a href="'.sensei_user_login_url().'">', '</a>' );
569
+					$this->notices->add_notice( $message, 'info' );
570 570
 
571 571
 
572
-		        } elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID )  ) {
572
+				} elseif ( ! Sensei_Utils::user_started_course( $post->ID, $current_user->ID )  ) {
573 573
 
574 574
 					// users who haven't started the course are allowed to view it
575
-			        $user_allowed                         = true;
576
-
577
-
578
-
579
-		        } else  {
580
-
581
-                    $user_allowed = true;
582
-
583
-                } // End If Statement
584
-                break;
585
-            case 'lesson-single':
586
-                // Check for WC purchase
587
-                $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true );
588
-
589
-                $update_course = Sensei_WC::course_update( $lesson_course_id );
590
-                $is_preview = Sensei_Utils::is_preview_lesson( $post->ID );
591
-
592
-                if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
593
-                    $user_allowed = true;
594
-                } elseif( $this->access_settings() && false == $is_preview ) {
595
-
596
-                    $user_allowed = true;
597
-
598
-                } else {
599
-                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
600
-                    $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
601
-                    $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
602
-                    if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
603
-                        if ( $is_preview ) {
604
-                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
605
-                        } else {
606
-                            $this->permissions_message['message'] =  sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link );
607
-                        }
608
-                    } else {
609
-                        if ( $is_preview ) {
610
-                            $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
611
-                        } else {
612
-                            /** This filter is documented in class-woothemes-sensei-frontend.php */
613
-                            $this->permissions_message['message'] =  sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
614
-                        }
615
-                    } // End If Statement
616
-                } // End If Statement
617
-                break;
618
-            case 'quiz-single':
619
-                $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true );
620
-                $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true );
621
-
622
-                $update_course = Sensei_WC::course_update( $lesson_course_id );
623
-                if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) {
624
-
625
-                    // Check for prerequisite lesson for this quiz
626
-                    $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true);
627
-                    $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID);
628
-
629
-                    // Handle restrictions
630
-                    if( sensei_all_access() ) {
631
-
632
-                        $user_allowed = true;
633
-
634
-                    } else {
635
-
636
-                        if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) {
637
-
638
-                            $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
639
-                            $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>';
640
-                            $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link );
641
-
642
-                        } else {
643
-
644
-                            $user_allowed = true;
645
-
646
-                        } // End If Statement
647
-                    } // End If Statement
648
-                } elseif( $this->access_settings() ) {
649
-                    // Check if the user has started the course
650
-
651
-                    if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) {
652
-
653
-                        $user_allowed = false;
654
-                        $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
655
-                        $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
656
-                        $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
657
-                        if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
658
-                            $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
659
-                        } else {
660
-                            $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
661
-                        } // End If Statement
662
-                    } else {
663
-                        $user_allowed = true;
664
-                    } // End If Statement
665
-                } else {
666
-                    $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
667
-                    $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
668
-                    $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link );
669
-                } // End If Statement
670
-                break;
671
-            default:
672
-                $user_allowed = true;
673
-                break;
674
-
675
-        } // End Switch Statement
676
-
677
-        /**
678
-         * filter the permissions message shown on sensei post types.
679
-         *
680
-         * @since 1.8.7
681
-         *
682
-         * @param array $permissions_message{
683
-         *
684
-         *   @type string $title
685
-         *   @type string $message
686
-         *
687
-         * }
688
-         * @param string $post_id
689
-         */
690
-        $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID );
575
+					$user_allowed                         = true;
576
+
577
+
578
+
579
+				} else  {
580
+
581
+					$user_allowed = true;
582
+
583
+				} // End If Statement
584
+				break;
585
+			case 'lesson-single':
586
+				// Check for WC purchase
587
+				$lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true );
588
+
589
+				$update_course = Sensei_WC::course_update( $lesson_course_id );
590
+				$is_preview = Sensei_Utils::is_preview_lesson( $post->ID );
591
+
592
+				if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) {
593
+					$user_allowed = true;
594
+				} elseif( $this->access_settings() && false == $is_preview ) {
595
+
596
+					$user_allowed = true;
597
+
598
+				} else {
599
+					$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
600
+					$course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
601
+					$wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
602
+					if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
603
+						if ( $is_preview ) {
604
+							$this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
605
+						} else {
606
+							$this->permissions_message['message'] =  sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link );
607
+						}
608
+					} else {
609
+						if ( $is_preview ) {
610
+							$this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link );
611
+						} else {
612
+							/** This filter is documented in class-woothemes-sensei-frontend.php */
613
+							$this->permissions_message['message'] =  sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
614
+						}
615
+					} // End If Statement
616
+				} // End If Statement
617
+				break;
618
+			case 'quiz-single':
619
+				$lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true );
620
+				$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true );
621
+
622
+				$update_course = Sensei_WC::course_update( $lesson_course_id );
623
+				if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) {
624
+
625
+					// Check for prerequisite lesson for this quiz
626
+					$lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true);
627
+					$user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID);
628
+
629
+					// Handle restrictions
630
+					if( sensei_all_access() ) {
631
+
632
+						$user_allowed = true;
633
+
634
+					} else {
635
+
636
+						if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) {
637
+
638
+							$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
639
+							$lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>';
640
+							$this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link );
641
+
642
+						} else {
643
+
644
+							$user_allowed = true;
645
+
646
+						} // End If Statement
647
+					} // End If Statement
648
+				} elseif( $this->access_settings() ) {
649
+					// Check if the user has started the course
650
+
651
+					if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) {
652
+
653
+						$user_allowed = false;
654
+						$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
655
+						$course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
656
+						$wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true );
657
+						if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
658
+							$this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
659
+						} else {
660
+							$this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link );
661
+						} // End If Statement
662
+					} else {
663
+						$user_allowed = true;
664
+					} // End If Statement
665
+				} else {
666
+					$this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' );
667
+					$course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>';
668
+					$this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link );
669
+				} // End If Statement
670
+				break;
671
+			default:
672
+				$user_allowed = true;
673
+				break;
674
+
675
+		} // End Switch Statement
676
+
677
+		/**
678
+		 * filter the permissions message shown on sensei post types.
679
+		 *
680
+		 * @since 1.8.7
681
+		 *
682
+		 * @param array $permissions_message{
683
+		 *
684
+		 *   @type string $title
685
+		 *   @type string $message
686
+		 *
687
+		 * }
688
+		 * @param string $post_id
689
+		 */
690
+		$this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID );
691 691
 
692 692
 		// add the permissions message to the stack
693 693
 
694
-        if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) {
695
-            $user_allowed = true;
696
-        }
697
-
698
-        /**
699
-         * Filter the permissions check final result. Which determines if the user has
700
-         * access to the given page.
701
-         *
702
-         * @since 1.0
703
-         *
704
-         * @param boolean $user_allowed
705
-         * @param integer $user_id
706
-         *
707
-         */
708
-        return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID );
709
-
710
-    } // End get_placeholder_image()
711
-
712
-
713
-    /**
714
-     * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check.
715
-     * @since  1.0.0
716
-     * @access public
717
-     * @return bool
718
-     */
719
-    public function access_settings () {
720
-
721
-        if( sensei_all_access() ) return true;
722
-
723
-        if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) {
724
-            if ( is_user_logged_in() ) {
725
-                return true;
726
-            } else {
727
-                return false;
728
-            } // End If Statement
729
-        } else {
730
-            return true;
731
-        } // End If Statement
732
-    } // End access_settings()
733
-
734
-    /**
735
-     * load_class loads in class files
736
-     * @since   1.2.0
737
-     * @access  public
738
-     * @return  void
739
-     */
740
-    public function load_class ( $class_name = '' ) {
741
-        if ( '' != $class_name && '' != $this->token ) {
742
-            require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' );
743
-        } // End If Statement
744
-    } // End load_class()
745
-
746
-    /**
747
-     * Filtering wp_count_comments to ensure that Sensei comments are ignored
748
-     * @since   1.4.0
749
-     * @access  public
750
-     * @param  array   $comments
751
-     * @param  integer $post_id
752
-     * @return array
753
-     */
754
-    public function sensei_count_comments( $comments, $post_id ) {
755
-        global $wpdb;
756
-
757
-        $post_id = (int) $post_id;
758
-
759
-        $count = wp_cache_get("comments-{$post_id}", 'counts');
760
-
761
-        if ( false !== $count ) {
762
-            return $count;
763
-        }
764
-
765
-        $statuses = array( '' ); // Default to the WP normal comments
766
-        $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A );
767
-        foreach ( (array) $stati AS $status ) {
768
-            if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) {
769
-                $statuses[] = $status['comment_type'];
770
-            }
771
-        }
772
-        $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')";
773
-
774
-        if ( $post_id > 0 )
775
-            $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
776
-
777
-        $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
778
-
779
-        $total = 0;
780
-        $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
781
-        foreach ( (array) $count as $row ) {
782
-            // Don't count post-trashed toward totals
783
-            if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
784
-                $total += $row['num_comments'];
785
-            if ( isset( $approved[$row['comment_approved']] ) )
786
-                $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
787
-        }
788
-
789
-        $stats['total_comments'] = $total;
790
-        foreach ( $approved as $key ) {
791
-            if ( empty($stats[$key]) )
792
-                $stats[$key] = 0;
793
-        }
794
-
795
-        $stats = (object) $stats;
796
-        wp_cache_set("comments-{$post_id}", $stats, 'counts');
797
-
798
-        return $stats;
799
-    }
800
-
801
-    /**
802
-     * Init images.
803
-     *
804
-     * @since 1.4.5
805
-     * @access public
806
-     * @return void
807
-     */
808
-    public function init_image_sizes() {
809
-        $course_archive_thumbnail 	= $this->get_image_size( 'course_archive_image' );
810
-        $course_single_thumbnail	= $this->get_image_size( 'course_single_image' );
811
-        $lesson_archive_thumbnail 	= $this->get_image_size( 'lesson_archive_image' );
812
-        $lesson_single_thumbnail	= $this->get_image_size( 'lesson_single_image' );
813
-
814
-        add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] );
815
-        add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] );
816
-        add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] );
817
-        add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] );
818
-    }
819
-
820
-    /**
821
-     * Get an image size.
822
-     *
823
-     * Variable is filtered by sensei_get_image_size_{image_size}
824
-     *
825
-     * @since 1.4.5
826
-     * @access public
827
-     * @param mixed $image_size
828
-     * @return string
829
-     */
830
-    public function get_image_size( $image_size ) {
831
-
832
-        // Only return sizes we define in settings
833
-        if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) )
834
-            return apply_filters( 'sensei_get_image_size_' . $image_size, '' );
835
-
836
-        if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) {
837
-            $this->settings->settings[ $image_size . '_width' ] = false;
838
-        }
839
-        if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) {
840
-            $this->settings->settings[ $image_size . '_height' ] = false;
841
-        }
842
-        if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) {
843
-            $this->settings->settings[ $image_size . '_hard_crop' ] = false;
844
-        }
845
-
846
-        $size = array_filter( array(
847
-            'width' => $this->settings->settings[ $image_size . '_width' ],
848
-            'height' => $this->settings->settings[ $image_size . '_height' ],
849
-            'crop' => $this->settings->settings[ $image_size . '_hard_crop' ]
850
-        ) );
851
-
852
-        $size['width'] 	= isset( $size['width'] ) ? $size['width'] : '100';
853
-        $size['height'] = isset( $size['height'] ) ? $size['height'] : '100';
854
-        $size['crop'] 	= isset( $size['crop'] ) ? $size['crop'] : 0;
855
-
856
-        return apply_filters( 'sensei_get_image_size_' . $image_size, $size );
857
-    }
858
-
859
-    public function body_class( $classes ) {
860
-        if( is_sensei() ) {
861
-            $classes[] = 'sensei';
862
-        }
863
-        return $classes;
864
-    }
865
-
866
-    /**
867
-     * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers
868
-     *
869
-     * @return null
870
-     * @since 1.7.0
871
-     */
872
-    public function jetpack_latex_support() {
873
-        if ( function_exists( 'latex_markup') ) {
874
-            add_filter( 'sensei_question_title', 'latex_markup' );
875
-            add_filter( 'sensei_answer_text', 'latex_markup' );
876
-        }
877
-    }
878
-
879
-    /**
880
-     * Load the module functionality.
881
-     *
882
-     * This function is hooked into plugins_loaded to avoid conflicts with
883
-     * the retired modules extension.
884
-     *
885
-     * @since 1.8.0
886
-     */
887
-    public function load_modules_class(){
888
-        global $sensei_modules;
889
-
890
-        if( !class_exists( 'Sensei_Modules' )
891
-            &&  'Sensei_Modules' != get_class( $sensei_modules ) ) {
892
-
893
-            //Load the modules class
894
-            require_once( 'class-sensei-modules.php');
895
-            Sensei()->modules = new Sensei_Core_Modules( $this->file );
896
-
897
-        }else{
898
-            // fallback for people still using the modules extension.
899
-            global $sensei_modules;
900
-            Sensei()->modules = $sensei_modules;
901
-            add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 );
902
-        }
903
-    }
904
-
905
-    /**
906
-     * Tell the user to that the modules extension is no longer needed.
907
-     *
908
-     * @since 1.8.0
909
-     */
910
-    public function disable_sensei_modules_extension(){ ?>
694
+		if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) {
695
+			$user_allowed = true;
696
+		}
697
+
698
+		/**
699
+		 * Filter the permissions check final result. Which determines if the user has
700
+		 * access to the given page.
701
+		 *
702
+		 * @since 1.0
703
+		 *
704
+		 * @param boolean $user_allowed
705
+		 * @param integer $user_id
706
+		 *
707
+		 */
708
+		return apply_filters( 'sensei_access_permissions', $user_allowed, $current_user->ID );
709
+
710
+	} // End get_placeholder_image()
711
+
712
+
713
+	/**
714
+	 * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check.
715
+	 * @since  1.0.0
716
+	 * @access public
717
+	 * @return bool
718
+	 */
719
+	public function access_settings () {
720
+
721
+		if( sensei_all_access() ) return true;
722
+
723
+		if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) {
724
+			if ( is_user_logged_in() ) {
725
+				return true;
726
+			} else {
727
+				return false;
728
+			} // End If Statement
729
+		} else {
730
+			return true;
731
+		} // End If Statement
732
+	} // End access_settings()
733
+
734
+	/**
735
+	 * load_class loads in class files
736
+	 * @since   1.2.0
737
+	 * @access  public
738
+	 * @return  void
739
+	 */
740
+	public function load_class ( $class_name = '' ) {
741
+		if ( '' != $class_name && '' != $this->token ) {
742
+			require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' );
743
+		} // End If Statement
744
+	} // End load_class()
745
+
746
+	/**
747
+	 * Filtering wp_count_comments to ensure that Sensei comments are ignored
748
+	 * @since   1.4.0
749
+	 * @access  public
750
+	 * @param  array   $comments
751
+	 * @param  integer $post_id
752
+	 * @return array
753
+	 */
754
+	public function sensei_count_comments( $comments, $post_id ) {
755
+		global $wpdb;
756
+
757
+		$post_id = (int) $post_id;
758
+
759
+		$count = wp_cache_get("comments-{$post_id}", 'counts');
760
+
761
+		if ( false !== $count ) {
762
+			return $count;
763
+		}
764
+
765
+		$statuses = array( '' ); // Default to the WP normal comments
766
+		$stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A );
767
+		foreach ( (array) $stati AS $status ) {
768
+			if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) {
769
+				$statuses[] = $status['comment_type'];
770
+			}
771
+		}
772
+		$where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')";
773
+
774
+		if ( $post_id > 0 )
775
+			$where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id );
776
+
777
+		$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
778
+
779
+		$total = 0;
780
+		$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
781
+		foreach ( (array) $count as $row ) {
782
+			// Don't count post-trashed toward totals
783
+			if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
784
+				$total += $row['num_comments'];
785
+			if ( isset( $approved[$row['comment_approved']] ) )
786
+				$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
787
+		}
788
+
789
+		$stats['total_comments'] = $total;
790
+		foreach ( $approved as $key ) {
791
+			if ( empty($stats[$key]) )
792
+				$stats[$key] = 0;
793
+		}
794
+
795
+		$stats = (object) $stats;
796
+		wp_cache_set("comments-{$post_id}", $stats, 'counts');
797
+
798
+		return $stats;
799
+	}
800
+
801
+	/**
802
+	 * Init images.
803
+	 *
804
+	 * @since 1.4.5
805
+	 * @access public
806
+	 * @return void
807
+	 */
808
+	public function init_image_sizes() {
809
+		$course_archive_thumbnail 	= $this->get_image_size( 'course_archive_image' );
810
+		$course_single_thumbnail	= $this->get_image_size( 'course_single_image' );
811
+		$lesson_archive_thumbnail 	= $this->get_image_size( 'lesson_archive_image' );
812
+		$lesson_single_thumbnail	= $this->get_image_size( 'lesson_single_image' );
813
+
814
+		add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] );
815
+		add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] );
816
+		add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] );
817
+		add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] );
818
+	}
819
+
820
+	/**
821
+	 * Get an image size.
822
+	 *
823
+	 * Variable is filtered by sensei_get_image_size_{image_size}
824
+	 *
825
+	 * @since 1.4.5
826
+	 * @access public
827
+	 * @param mixed $image_size
828
+	 * @return string
829
+	 */
830
+	public function get_image_size( $image_size ) {
831
+
832
+		// Only return sizes we define in settings
833
+		if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) )
834
+			return apply_filters( 'sensei_get_image_size_' . $image_size, '' );
835
+
836
+		if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) {
837
+			$this->settings->settings[ $image_size . '_width' ] = false;
838
+		}
839
+		if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) {
840
+			$this->settings->settings[ $image_size . '_height' ] = false;
841
+		}
842
+		if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) {
843
+			$this->settings->settings[ $image_size . '_hard_crop' ] = false;
844
+		}
845
+
846
+		$size = array_filter( array(
847
+			'width' => $this->settings->settings[ $image_size . '_width' ],
848
+			'height' => $this->settings->settings[ $image_size . '_height' ],
849
+			'crop' => $this->settings->settings[ $image_size . '_hard_crop' ]
850
+		) );
851
+
852
+		$size['width'] 	= isset( $size['width'] ) ? $size['width'] : '100';
853
+		$size['height'] = isset( $size['height'] ) ? $size['height'] : '100';
854
+		$size['crop'] 	= isset( $size['crop'] ) ? $size['crop'] : 0;
855
+
856
+		return apply_filters( 'sensei_get_image_size_' . $image_size, $size );
857
+	}
858
+
859
+	public function body_class( $classes ) {
860
+		if( is_sensei() ) {
861
+			$classes[] = 'sensei';
862
+		}
863
+		return $classes;
864
+	}
865
+
866
+	/**
867
+	 * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers
868
+	 *
869
+	 * @return null
870
+	 * @since 1.7.0
871
+	 */
872
+	public function jetpack_latex_support() {
873
+		if ( function_exists( 'latex_markup') ) {
874
+			add_filter( 'sensei_question_title', 'latex_markup' );
875
+			add_filter( 'sensei_answer_text', 'latex_markup' );
876
+		}
877
+	}
878
+
879
+	/**
880
+	 * Load the module functionality.
881
+	 *
882
+	 * This function is hooked into plugins_loaded to avoid conflicts with
883
+	 * the retired modules extension.
884
+	 *
885
+	 * @since 1.8.0
886
+	 */
887
+	public function load_modules_class(){
888
+		global $sensei_modules;
889
+
890
+		if( !class_exists( 'Sensei_Modules' )
891
+			&&  'Sensei_Modules' != get_class( $sensei_modules ) ) {
892
+
893
+			//Load the modules class
894
+			require_once( 'class-sensei-modules.php');
895
+			Sensei()->modules = new Sensei_Core_Modules( $this->file );
896
+
897
+		}else{
898
+			// fallback for people still using the modules extension.
899
+			global $sensei_modules;
900
+			Sensei()->modules = $sensei_modules;
901
+			add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 );
902
+		}
903
+	}
904
+
905
+	/**
906
+	 * Tell the user to that the modules extension is no longer needed.
907
+	 *
908
+	 * @since 1.8.0
909
+	 */
910
+	public function disable_sensei_modules_extension(){ ?>
911 911
         <div class="notice updated fade">
912 912
             <p>
913 913
                 <?php
914
-                $plugin_manage_url = admin_url().'plugins.php#sensei-modules';
915
-                $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> ';
916
-                ?>
914
+				$plugin_manage_url = admin_url().'plugins.php#sensei-modules';
915
+				$plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> ';
916
+				?>
917 917
                 <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension.
918 918
                 Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules).
919 919
             </p>
@@ -921,200 +921,200 @@  discard block
 block discarded – undo
921 921
 
922 922
     <?php }// end function
923 923
 
924
-    /**
925
-     * Sensei wide rewrite flush call.
926
-     *
927
-     * To use this simply update the option 'sensei_flush_rewrite_rules' to 1
928
-     *
929
-     * After the option is one the Rules will be flushed.
930
-     *
931
-     * @since 1.9.0
932
-     */
933
-    public function flush_rewrite_rules(){
934
-
935
-        // ensures that the rewrite rules are flushed on the second
936
-        // attempt. This ensure that the settings for any other process
937
-        // have been completed and saved to the database before we refresh the
938
-        // rewrite rules.
939
-        $option =  get_option('sensei_flush_rewrite_rules');
940
-        if( '1' == $option ) {
941
-
942
-            update_option('sensei_flush_rewrite_rules', '2');
943
-
944
-        }elseif( '2' == $option ) {
945
-
946
-            flush_rewrite_rules();
947
-            update_option('sensei_flush_rewrite_rules', '0');
948
-
949
-        }
950
-
951
-    } // end flush_rewrite_rules
952
-
953
-    /**
954
-     * Calling this function will tell Sensei to flush rewrite
955
-     * rules on the next load.
956
-     *
957
-     * @since 1.9.0
958
-     */
959
-    public function initiate_rewrite_rules_flush(){
960
-
961
-        update_option('sensei_flush_rewrite_rules', '1');
962
-
963
-    }
964
-
965
-    /**
966
-     * sensei_woocommerce_email_course_details adds detail to email
967
-     *
968
-     * @deprecated since 1.9.0 use Sensei_WC::email_course_details
969
-     *
970
-     * @since   1.4.5
971
-     * @access  public
972
-     * @param   WC_Order $order
973
-     *
974
-     * @return  void
975
-     */
976
-    public function sensei_woocommerce_email_course_details( $order ) {
977
-
978
-        Sensei_WC::email_course_details( $order );
979
-
980
-    } // end func email course details
981
-
982
-    /**
983
-     * @deprecated since 1.9.0, movde to the Sensei_WC class
984
-     * @param $user_id
985
-     * @param $subscription_key
986
-     */
987
-    public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){
988
-
989
-        Sensei_WC::reactivate_subscription( $user_id, $subscription_key );
990
-    }
991
-
992
-    /**
993
-     * @deprecated since 1.9.0, movde to the Sensei_WC class
994
-     * @param $user_id
995
-     * @param $subscription_key
996
-     */
997
-    public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){
998
-
999
-        Sensei_WC::end_subscription( $user_id, $subscription_key );
1000
-    }
1001
-
1002
-    /**
1003
-     * sensei_woocommerce_complete_order description
1004
-     *
1005
-     * @deprecated since 1.9.0 use Sensei_WC::complete_order( $order_id );
1006
-     * @since   1.0.3
1007
-     * @access  public
1008
-     * @param   int $order_id WC order ID
1009
-     *
1010
-     * @return  void
1011
-     */
1012
-    public function sensei_woocommerce_complete_order ( $order_id = 0 ) {
1013
-
1014
-        Sensei_WC::complete_order( $order_id );
1015
-
1016
-    } // End sensei_woocommerce_complete_order()
1017
-
1018
-    /**
1019
-     * Runs when an order is cancelled.
1020
-     *
1021
-     * @deprecated since 1.9.0
1022
-     *
1023
-     * @since   1.2.0
1024
-     * @param   integer $order_id order ID
1025
-     * @return  void
1026
-     */
1027
-    public function sensei_woocommerce_cancel_order ( $order_id ) {
1028
-
1029
-        Sensei_WC::cancel_order( $order_id );
1030
-
1031
-    } // End sensei_woocommerce_cancel_order()
1032
-
1033
-    /**
1034
-     * sensei_activate_subscription runs when a subscription product is purchased
1035
-     * @deprecated since 1.9.0
1036
-     * @since   1.2.0
1037
-     * @access  public
1038
-     * @param   integer $order_id order ID
1039
-     * @return  void
1040
-     */
1041
-    public function sensei_activate_subscription(  $order_id = 0 ) {
1042
-
1043
-        Sensei_WC::activate_subscription( $order_id );
1044
-
1045
-    } // End sensei_activate_subscription()
1046
-
1047
-    /**
1048
-     * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course.
1049
-     * @deprecated since 1.9.0
1050
-     * @since  1.0.0
1051
-     * @param  int 			$course_id  (default: 0)
1052
-     * @param  array/Object $order_user (default: array()) Specific user's data.
1053
-     * @return bool|int
1054
-     */
1055
-    public function woocommerce_course_update ( $course_id = 0, $order_user = array()  ) {
1056
-
1057
-        return Sensei_WC::course_update( $course_id, $order_user );
1058
-
1059
-    } // End woocommerce_course_update()
1060
-
1061
-    /**
1062
-     * Returns the WooCommerce Product Object
1063
-     *
1064
-     * The code caters for pre and post WooCommerce 2.2 installations.
1065
-     *
1066
-     * @deprecated since 1.9.0
1067
-     * @since   1.1.1
1068
-     *
1069
-     * @param   integer $wc_product_id Product ID or Variation ID
1070
-     * @param   string  $product_type  '' or 'variation'
1071
-     *
1072
-     * @return   WC_Product $wc_product_object
1073
-     */
1074
-    public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) {
1075
-
1076
-        return Sensei_WC::get_product_object( $wc_product_id, $product_type );
1077
-
1078
-    } // End sensei_get_woocommerce_product_object()
1079
-
1080
-    /**
1081
-     * Setup required WooCommerce settings.
1082
-     * @access  public
1083
-     * @since   1.1.0
1084
-     * @return  void
1085
-     */
1086
-    public function set_woocommerce_functionality() {
1087
-
1088
-        _deprecated_function('Sensei()->set_woocommerce_functionality', 'Sensei 1.9.0');
1089
-
1090
-    } // End set_woocommerce_functionality()
1091
-
1092
-    /**
1093
-     * Disable guest checkout if a course product is in the cart
1094
-     * @deprecated since 1.9.0
1095
-     * @param  boolean $guest_checkout Current guest checkout setting
1096
-     * @return boolean                 Modified guest checkout setting
1097
-     */
1098
-    public function disable_guest_checkout( $guest_checkout ) {
1099
-
1100
-        return Sensei_WC::disable_guest_checkout( $guest_checkout );
1101
-
1102
-    }// end disable_guest_checkout
1103
-
1104
-    /**
1105
-     * Change order status with virtual products to completed
1106
-     *
1107
-     * @deprecated since 1.9.0 use Sensei_WC::virtual_order_payment_complete( $order_status, $order_id )
1108
-     *
1109
-     * @since  1.1.0
1110
-     * @param string $order_status
1111
-     * @param int $order_id
1112
-     * @return string
1113
-     **/
1114
-    public function virtual_order_payment_complete( $order_status, $order_id ) {
1115
-
1116
-        return  Sensei_WC::virtual_order_payment_complete( $order_status, $order_id );
1117
-    }
924
+	/**
925
+	 * Sensei wide rewrite flush call.
926
+	 *
927
+	 * To use this simply update the option 'sensei_flush_rewrite_rules' to 1
928
+	 *
929
+	 * After the option is one the Rules will be flushed.
930
+	 *
931
+	 * @since 1.9.0
932
+	 */
933
+	public function flush_rewrite_rules(){
934
+
935
+		// ensures that the rewrite rules are flushed on the second
936
+		// attempt. This ensure that the settings for any other process
937
+		// have been completed and saved to the database before we refresh the
938
+		// rewrite rules.
939
+		$option =  get_option('sensei_flush_rewrite_rules');
940
+		if( '1' == $option ) {
941
+
942
+			update_option('sensei_flush_rewrite_rules', '2');
943
+
944
+		}elseif( '2' == $option ) {
945
+
946
+			flush_rewrite_rules();
947
+			update_option('sensei_flush_rewrite_rules', '0');
948
+
949
+		}
950
+
951
+	} // end flush_rewrite_rules
952
+
953
+	/**
954
+	 * Calling this function will tell Sensei to flush rewrite
955
+	 * rules on the next load.
956
+	 *
957
+	 * @since 1.9.0
958
+	 */
959
+	public function initiate_rewrite_rules_flush(){
960
+
961
+		update_option('sensei_flush_rewrite_rules', '1');
962
+
963
+	}
964
+
965
+	/**
966
+	 * sensei_woocommerce_email_course_details adds detail to email
967
+	 *
968
+	 * @deprecated since 1.9.0 use Sensei_WC::email_course_details
969
+	 *
970
+	 * @since   1.4.5
971
+	 * @access  public
972
+	 * @param   WC_Order $order
973
+	 *
974
+	 * @return  void
975
+	 */
976
+	public function sensei_woocommerce_email_course_details( $order ) {
977
+
978
+		Sensei_WC::email_course_details( $order );
979
+
980
+	} // end func email course details
981
+
982
+	/**
983
+	 * @deprecated since 1.9.0, movde to the Sensei_WC class
984
+	 * @param $user_id
985
+	 * @param $subscription_key
986
+	 */
987
+	public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ){
988
+
989
+		Sensei_WC::reactivate_subscription( $user_id, $subscription_key );
990
+	}
991
+
992
+	/**
993
+	 * @deprecated since 1.9.0, movde to the Sensei_WC class
994
+	 * @param $user_id
995
+	 * @param $subscription_key
996
+	 */
997
+	public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ){
998
+
999
+		Sensei_WC::end_subscription( $user_id, $subscription_key );
1000
+	}
1001
+
1002
+	/**
1003
+	 * sensei_woocommerce_complete_order description
1004
+	 *
1005
+	 * @deprecated since 1.9.0 use Sensei_WC::complete_order( $order_id );
1006
+	 * @since   1.0.3
1007
+	 * @access  public
1008
+	 * @param   int $order_id WC order ID
1009
+	 *
1010
+	 * @return  void
1011
+	 */
1012
+	public function sensei_woocommerce_complete_order ( $order_id = 0 ) {
1013
+
1014
+		Sensei_WC::complete_order( $order_id );
1015
+
1016
+	} // End sensei_woocommerce_complete_order()
1017
+
1018
+	/**
1019
+	 * Runs when an order is cancelled.
1020
+	 *
1021
+	 * @deprecated since 1.9.0
1022
+	 *
1023
+	 * @since   1.2.0
1024
+	 * @param   integer $order_id order ID
1025
+	 * @return  void
1026
+	 */
1027
+	public function sensei_woocommerce_cancel_order ( $order_id ) {
1028
+
1029
+		Sensei_WC::cancel_order( $order_id );
1030
+
1031
+	} // End sensei_woocommerce_cancel_order()
1032
+
1033
+	/**
1034
+	 * sensei_activate_subscription runs when a subscription product is purchased
1035
+	 * @deprecated since 1.9.0
1036
+	 * @since   1.2.0
1037
+	 * @access  public
1038
+	 * @param   integer $order_id order ID
1039
+	 * @return  void
1040
+	 */
1041
+	public function sensei_activate_subscription(  $order_id = 0 ) {
1042
+
1043
+		Sensei_WC::activate_subscription( $order_id );
1044
+
1045
+	} // End sensei_activate_subscription()
1046
+
1047
+	/**
1048
+	 * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course.
1049
+	 * @deprecated since 1.9.0
1050
+	 * @since  1.0.0
1051
+	 * @param  int 			$course_id  (default: 0)
1052
+	 * @param  array/Object $order_user (default: array()) Specific user's data.
1053
+	 * @return bool|int
1054
+	 */
1055
+	public function woocommerce_course_update ( $course_id = 0, $order_user = array()  ) {
1056
+
1057
+		return Sensei_WC::course_update( $course_id, $order_user );
1058
+
1059
+	} // End woocommerce_course_update()
1060
+
1061
+	/**
1062
+	 * Returns the WooCommerce Product Object
1063
+	 *
1064
+	 * The code caters for pre and post WooCommerce 2.2 installations.
1065
+	 *
1066
+	 * @deprecated since 1.9.0
1067
+	 * @since   1.1.1
1068
+	 *
1069
+	 * @param   integer $wc_product_id Product ID or Variation ID
1070
+	 * @param   string  $product_type  '' or 'variation'
1071
+	 *
1072
+	 * @return   WC_Product $wc_product_object
1073
+	 */
1074
+	public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) {
1075
+
1076
+		return Sensei_WC::get_product_object( $wc_product_id, $product_type );
1077
+
1078
+	} // End sensei_get_woocommerce_product_object()
1079
+
1080
+	/**
1081
+	 * Setup required WooCommerce settings.
1082
+	 * @access  public
1083
+	 * @since   1.1.0
1084
+	 * @return  void
1085
+	 */
1086
+	public function set_woocommerce_functionality() {
1087
+
1088
+		_deprecated_function('Sensei()->set_woocommerce_functionality', 'Sensei 1.9.0');
1089
+
1090
+	} // End set_woocommerce_functionality()
1091
+
1092
+	/**
1093
+	 * Disable guest checkout if a course product is in the cart
1094
+	 * @deprecated since 1.9.0
1095
+	 * @param  boolean $guest_checkout Current guest checkout setting
1096
+	 * @return boolean                 Modified guest checkout setting
1097
+	 */
1098
+	public function disable_guest_checkout( $guest_checkout ) {
1099
+
1100
+		return Sensei_WC::disable_guest_checkout( $guest_checkout );
1101
+
1102
+	}// end disable_guest_checkout
1103
+
1104
+	/**
1105
+	 * Change order status with virtual products to completed
1106
+	 *
1107
+	 * @deprecated since 1.9.0 use Sensei_WC::virtual_order_payment_complete( $order_status, $order_id )
1108
+	 *
1109
+	 * @since  1.1.0
1110
+	 * @param string $order_status
1111
+	 * @param int $order_id
1112
+	 * @return string
1113
+	 **/
1114
+	public function virtual_order_payment_complete( $order_status, $order_id ) {
1115
+
1116
+		return  Sensei_WC::virtual_order_payment_complete( $order_status, $order_id );
1117
+	}
1118 1118
 
1119 1119
 } // End Class
1120 1120
 
Please login to merge, or discard this patch.