Completed
Push — master ( 78b9e3...efb4fd )
by Dwain
04:49
created
includes/class-sensei-posttypes.php 1 patch
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Post Types Class
@@ -40,43 +40,43 @@  discard block
 block discarded – undo
40 40
 	 * Constructor
41 41
 	 * @since  1.0.0
42 42
 	 */
43
-	public function __construct () {
43
+	public function __construct() {
44 44
 
45 45
 		// Setup Post Types
46 46
 		$this->labels = array();
47 47
         $this->token = 'woothemes-sensei-posttypes';
48 48
 
49 49
 		$this->setup_post_type_labels_base();
50
-		add_action( 'init', array( $this, 'setup_course_post_type' ), 100 );
51
-		add_action( 'init', array( $this, 'setup_lesson_post_type' ), 100 );
52
-		add_action( 'init', array( $this, 'setup_quiz_post_type' ), 100 );
53
-		add_action( 'init', array( $this, 'setup_question_post_type' ), 100 );
54
-		add_action( 'init', array( $this, 'setup_multiple_question_post_type' ), 100 );
55
-		add_action( 'init', array( $this, 'setup_sensei_message_post_type' ), 100 );
50
+		add_action('init', array($this, 'setup_course_post_type'), 100);
51
+		add_action('init', array($this, 'setup_lesson_post_type'), 100);
52
+		add_action('init', array($this, 'setup_quiz_post_type'), 100);
53
+		add_action('init', array($this, 'setup_question_post_type'), 100);
54
+		add_action('init', array($this, 'setup_multiple_question_post_type'), 100);
55
+		add_action('init', array($this, 'setup_sensei_message_post_type'), 100);
56 56
 
57 57
 		// Setup Taxonomies
58
-		add_action( 'init', array( $this, 'setup_course_category_taxonomy' ), 100 );
59
-		add_action( 'init', array( $this, 'setup_quiz_type_taxonomy' ), 100 );
60
-		add_action( 'init', array( $this, 'setup_question_type_taxonomy' ), 100 );
61
-		add_action( 'init', array( $this, 'setup_question_category_taxonomy' ), 100 );
62
-		add_action( 'init', array( $this, 'setup_lesson_tag_taxonomy' ), 100 );
58
+		add_action('init', array($this, 'setup_course_category_taxonomy'), 100);
59
+		add_action('init', array($this, 'setup_quiz_type_taxonomy'), 100);
60
+		add_action('init', array($this, 'setup_question_type_taxonomy'), 100);
61
+		add_action('init', array($this, 'setup_question_category_taxonomy'), 100);
62
+		add_action('init', array($this, 'setup_lesson_tag_taxonomy'), 100);
63 63
 
64 64
 		// Load Post Type Objects
65
-		$default_post_types = array( 'course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages' ) ;
66
-		$this->load_posttype_objects( $default_post_types );
65
+		$default_post_types = array('course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages');
66
+		$this->load_posttype_objects($default_post_types);
67 67
 
68 68
 		// Admin functions
69
-		if ( is_admin() ) {
70
-			$this->set_role_cap_defaults( $default_post_types );
69
+		if (is_admin()) {
70
+			$this->set_role_cap_defaults($default_post_types);
71 71
 			global $pagenow;
72
-			if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) {
73
-				add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10 );
74
-				add_filter( 'post_updated_messages', array( $this, 'setup_post_type_messages' ) );
72
+			if (($pagenow == 'post.php' || $pagenow == 'post-new.php')) {
73
+				add_filter('enter_title_here', array($this, 'enter_title_here'), 10);
74
+				add_filter('post_updated_messages', array($this, 'setup_post_type_messages'));
75 75
 			} // End If Statement
76 76
 		} // End If Statement
77 77
 
78 78
 		// Add 'Edit Quiz' link to admin bar
79
-		add_action( 'admin_bar_menu', array( $this, 'quiz_admin_bar_menu' ), 81 );
79
+		add_action('admin_bar_menu', array($this, 'quiz_admin_bar_menu'), 81);
80 80
 
81 81
 	} // End __construct()
82 82
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	 * @param array $posttypes (default: array())
88 88
 	 * @return void
89 89
 	 */
90
-	public function load_posttype_objects( $posttypes = array() ) {
90
+	public function load_posttype_objects($posttypes = array()) {
91 91
 
92
-		foreach ( $posttypes as $posttype_token => $posttype_name ) {
92
+		foreach ($posttypes as $posttype_token => $posttype_name) {
93 93
 
94 94
 			// Load the files
95
-			$class_name = 'WooThemes_Sensei_' . $posttype_name;
95
+			$class_name = 'WooThemes_Sensei_'.$posttype_name;
96 96
 			$this->$posttype_token = new $class_name();
97 97
 			$this->$posttype_token->token = $posttype_token;
98 98
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
      * @uses  Sensei()
107 107
 	 * @return void
108 108
 	 */
109
-	public function setup_course_post_type () {
109
+	public function setup_course_post_type() {
110 110
 
111 111
 		$args = array(
112
-		    'labels'              => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ),
112
+		    'labels'              => $this->create_post_type_labels($this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu']),
113 113
 		    'public'              => true,
114 114
 		    'publicly_queryable'  => true,
115 115
 		    'show_ui'             => true,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		    'show_in_admin_bar'   => true,
118 118
 		    'query_var'           => true,
119 119
 		    'rewrite'             => array(
120
-                'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) ,
120
+                'slug' => esc_attr(apply_filters('sensei_course_slug', _x('course', 'post type single url base', 'woothemes-sensei'))),
121 121
                 'with_front' => true,
122 122
                 'feeds' => true,
123 123
                 'pages' => true
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             'has_archive'         => $this->get_course_post_type_archive_slug(),
128 128
 		    'hierarchical'        => false,
129 129
 		    'menu_position'       => 51,
130
-		    'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail' )
130
+		    'supports'            => array('title', 'editor', 'excerpt', 'thumbnail')
131 131
 		);
132 132
 
133 133
         /**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
          * @since 1.9.0
137 137
          * @param array $args
138 138
          */
139
-		register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) );
139
+		register_post_type('course', apply_filters('sensei_register_post_type_course', $args));
140 140
 
141 141
 	} // End setup_course_post_type()
142 142
 
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @return false|string
157 157
      */
158
-    public function get_course_post_type_archive_slug(){
158
+    public function get_course_post_type_archive_slug() {
159 159
 
160
-        $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) );
160
+        $settings_course_page = get_post(Sensei()->settings->get('course_page'));
161 161
 
162 162
         // for a valid post that doesn't have any of the old short codes set the archive the same
163 163
         // as the page URI
164
-        if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){
164
+        if (is_a($settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes($settings_course_page->post_content)) {
165 165
 
166
-             return get_page_uri( $settings_course_page->ID );
166
+             return get_page_uri($settings_course_page->ID);
167 167
 
168
-        }else{
168
+        } else {
169 169
 
170 170
             return 'courses';
171 171
 
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return bool
185 185
      */
186
-    public function has_old_shortcodes( $content ){
186
+    public function has_old_shortcodes($content) {
187 187
 
188
-        return  ( has_shortcode( $content, 'newcourses')
189
-        || has_shortcode( $content, 'featuredcourses')
190
-        || has_shortcode( $content, 'freecourses')
191
-        || has_shortcode( $content, 'paidcourses') );
188
+        return  (has_shortcode($content, 'newcourses')
189
+        || has_shortcode($content, 'featuredcourses')
190
+        || has_shortcode($content, 'freecourses')
191
+        || has_shortcode($content, 'paidcourses'));
192 192
 
193 193
     }// end has old shortcodes
194 194
 
@@ -199,26 +199,26 @@  discard block
 block discarded – undo
199 199
 	 * @uses  Sensei()
200 200
 	 * @return void
201 201
 	 */
202
-	public function setup_lesson_post_type () {
202
+	public function setup_lesson_post_type() {
203 203
 
204
-		$supports_array = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' );
204
+		$supports_array = array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes');
205 205
 		$allow_comments = false;
206
-		if ( isset( Sensei()->settings->settings[ 'lesson_comments' ] ) ) {
207
-			$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
206
+		if (isset(Sensei()->settings->settings['lesson_comments'])) {
207
+			$allow_comments = Sensei()->settings->settings['lesson_comments'];
208 208
 		} // End If Statement
209
-		if ( $allow_comments ) {
210
-			array_push( $supports_array, 'comments' );
209
+		if ($allow_comments) {
210
+			array_push($supports_array, 'comments');
211 211
 		} // End If Statement
212 212
 
213 213
 		$args = array(
214
-		    'labels' => $this->create_post_type_labels(  $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ),
214
+		    'labels' => $this->create_post_type_labels($this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu']),
215 215
 		    'public' => true,
216 216
 		    'publicly_queryable' => true,
217 217
 		    'show_ui' => true,
218 218
 		    'show_in_menu' => true,
219 219
 		    'query_var' => true,
220 220
 		    'rewrite' => array(
221
-                'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) ,
221
+                'slug' => esc_attr(apply_filters('sensei_lesson_slug', _x('lesson', 'post type single slug', 'woothemes-sensei'))),
222 222
                 'with_front' =>  true,
223 223
                 'feeds' => true,
224 224
                 'pages' => true
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
          * @since 1.9.0
238 238
          * @param array $args
239 239
          */
240
-		register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) );
240
+		register_post_type('lesson', apply_filters('sensei_register_post_type_lesson', $args));
241 241
 
242 242
 	} // End setup_lesson_post_type()
243 243
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * @uses  Sensei()
248 248
 	 * @return void
249 249
 	 */
250
-	public function setup_quiz_post_type () {
250
+	public function setup_quiz_post_type() {
251 251
 
252 252
 		$args = array(
253 253
 		    'labels' => $this->create_post_type_labels(
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		    'query_var' => true,
264 264
 		    'exclude_from_search' => true,
265 265
 		    'rewrite' => array(
266
-                'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) ,
266
+                'slug' => esc_attr(apply_filters('sensei_quiz_slug', _x('quiz', 'post type single slug', 'woothemes-sensei'))),
267 267
                 'with_front' =>  true,
268 268
                 'feeds' => true,
269 269
                 'pages' => true
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		    'has_archive' => false,
274 274
 		    'hierarchical' => false,
275 275
 		    'menu_position' => 20, // Below "Pages"
276
-		    'supports' => array( '' )
276
+		    'supports' => array('')
277 277
 		);
278 278
 
279 279
         /**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
          * @since 1.9.0
283 283
          * @param array $args
284 284
          */
285
-		register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) );
285
+		register_post_type('quiz', apply_filters('sensei_register_post_type_quiz', $args));
286 286
 
287 287
 	} // End setup_quiz_post_type()
288 288
 
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 	 * @since  1.0.0
293 293
 	 * @return void
294 294
 	 */
295
-	public function setup_question_post_type () {
295
+	public function setup_question_post_type() {
296 296
 
297 297
 		$args = array(
298
-		    'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ),
298
+		    'labels' => $this->create_post_type_labels($this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu']),
299 299
 		    'public' => false,
300 300
 		    'publicly_queryable' => true,
301 301
 		    'show_ui' => true,
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 		    'query_var' => true,
305 305
 		    'exclude_from_search' => true,
306 306
 		    'rewrite' => array(
307
-                'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
307
+                'slug' => esc_attr(apply_filters('sensei_question_slug', _x('question', 'post type single slug', 'woothemes-sensei'))),
308 308
                 'with_front' =>  true,
309 309
                 'feeds' => true,
310 310
                 'pages' => true
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		    'has_archive' => true,
315 315
 		    'hierarchical' => false,
316 316
 		    'menu_position' => 51,
317
-		    'supports' => array( 'title' )
317
+		    'supports' => array('title')
318 318
 		);
319 319
 
320 320
         /**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
          * @since 1.9.0
324 324
          * @param array $args
325 325
          */
326
-		register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) );
326
+		register_post_type('question', apply_filters('sensei_register_post_type_question', $args));
327 327
 
328 328
 	} // End setup_question_post_type()
329 329
 
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 	 * @since  1.6.0
333 333
 	 * @return void
334 334
 	 */
335
-	public function setup_multiple_question_post_type () {
335
+	public function setup_multiple_question_post_type() {
336 336
 
337 337
 		$args = array(
338
-		    'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ),
338
+		    'labels' => $this->create_post_type_labels($this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu']),
339 339
 		    'public' => false,
340 340
 		    'publicly_queryable' => false,
341 341
 		    'show_ui' => false,
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		    'query_var' => false,
345 345
 		    'exclude_from_search' => true,
346 346
 		    'rewrite' => array(
347
-                'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
347
+                'slug' => esc_attr(apply_filters('sensei_multiple_question_slug', _x('multiple_question', 'post type single slug', 'woothemes-sensei'))),
348 348
                 'with_front' =>  false,
349 349
                 'feeds' => false,
350 350
                 'pages' => false
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 		    'has_archive' => false,
355 355
 		    'hierarchical' => false,
356 356
 		    'menu_position' => 51,
357
-		    'supports' => array( 'title', 'custom-fields' )
357
+		    'supports' => array('title', 'custom-fields')
358 358
 		);
359 359
 
360
-		register_post_type( 'multiple_question', $args );
360
+		register_post_type('multiple_question', $args);
361 361
 	} // End setup_multiple_question_post_type()
362 362
 
363 363
 	/**
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
 	 * @since  1.6.0
366 366
 	 * @return void
367 367
 	 */
368
-	public function setup_sensei_message_post_type () {
368
+	public function setup_sensei_message_post_type() {
369 369
 
370
-		if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) {
370
+		if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) {
371 371
 
372 372
 			$args = array(
373
-			    'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ),
373
+			    'labels' => $this->create_post_type_labels($this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu']),
374 374
 			    'public' => true,
375 375
 			    'publicly_queryable' => true,
376 376
 			    'show_ui' => true,
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 			    'query_var' => true,
380 380
 			    'exclude_from_search' => true,
381 381
 			    'rewrite' => array(
382
-                    'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) ,
382
+                    'slug' => esc_attr(apply_filters('sensei_messages_slug', _x('messages', 'post type single slug', 'woothemes-sensei'))),
383 383
                     'with_front' =>  false,
384 384
                     'feeds' => false,
385 385
                     'pages' => true
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			    'has_archive' => true,
390 390
 			    'hierarchical' => false,
391 391
 			    'menu_position' => 50,
392
-			    'supports' => array( 'title', 'editor', 'comments' ),
392
+			    'supports' => array('title', 'editor', 'comments'),
393 393
 			);
394 394
 
395 395
             /**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
              * @since 1.9.0
399 399
              * @param array $args
400 400
              */
401
-			register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message',  $args ) );
401
+			register_post_type('sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args));
402 402
 		}
403 403
 	} // End setup_sensei_message_post_type()
404 404
 
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
 	 * @since  1.1.0
408 408
 	 * @return void
409 409
 	 */
410
-	public function setup_course_category_taxonomy () {
410
+	public function setup_course_category_taxonomy() {
411 411
 		// "Course Categories" Custom Taxonomy
412 412
 		$labels = array(
413
-			'name' => _x( 'Course Categories', 'taxonomy general name', 'woothemes-sensei' ),
414
-			'singular_name' => _x( 'Course Category', 'taxonomy singular name', 'woothemes-sensei' ),
415
-			'search_items' =>  __( 'Search Course Categories', 'woothemes-sensei' ),
416
-			'all_items' => __( 'All Course Categories', 'woothemes-sensei' ),
417
-			'parent_item' => __( 'Parent Course Category', 'woothemes-sensei' ),
418
-			'parent_item_colon' => __( 'Parent Course Category:', 'woothemes-sensei' ),
419
-			'edit_item' => __( 'Edit Course Category', 'woothemes-sensei' ),
420
-			'update_item' => __( 'Update Course Category', 'woothemes-sensei' ),
421
-			'add_new_item' => __( 'Add New Course Category', 'woothemes-sensei' ),
422
-			'new_item_name' => __( 'New Course Category Name', 'woothemes-sensei' ),
423
-			'menu_name' => __( 'Course Categories', 'woothemes-sensei' ),
413
+			'name' => _x('Course Categories', 'taxonomy general name', 'woothemes-sensei'),
414
+			'singular_name' => _x('Course Category', 'taxonomy singular name', 'woothemes-sensei'),
415
+			'search_items' =>  __('Search Course Categories', 'woothemes-sensei'),
416
+			'all_items' => __('All Course Categories', 'woothemes-sensei'),
417
+			'parent_item' => __('Parent Course Category', 'woothemes-sensei'),
418
+			'parent_item_colon' => __('Parent Course Category:', 'woothemes-sensei'),
419
+			'edit_item' => __('Edit Course Category', 'woothemes-sensei'),
420
+			'update_item' => __('Update Course Category', 'woothemes-sensei'),
421
+			'add_new_item' => __('Add New Course Category', 'woothemes-sensei'),
422
+			'new_item_name' => __('New Course Category Name', 'woothemes-sensei'),
423
+			'menu_name' => __('Course Categories', 'woothemes-sensei'),
424 424
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
425 425
 		);
426 426
 
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
                 'edit_terms'   => 'edit_courses',
436 436
                 'delete_terms' => 'manage_categories',
437 437
                 'assign_terms' => 'edit_courses',),
438
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
438
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_course_category_slug', _x('course-category', 'taxonomy archive slug', 'woothemes-sensei'))))
439 439
 		);
440 440
 
441
-		register_taxonomy( 'course-category', array( 'course' ), $args );
441
+		register_taxonomy('course-category', array('course'), $args);
442 442
 
443 443
 	} // End setup_course_category_taxonomy()
444 444
 
@@ -447,21 +447,21 @@  discard block
 block discarded – undo
447 447
 	 * @since  1.0.0
448 448
 	 * @return void
449 449
 	 */
450
-	public function setup_quiz_type_taxonomy () {
450
+	public function setup_quiz_type_taxonomy() {
451 451
 
452 452
 		// "Quiz Types" Custom Taxonomy
453 453
 		$labels = array(
454
-			'name' => _x( 'Quiz Types', 'taxonomy general name', 'woothemes-sensei' ),
455
-			'singular_name' => _x( 'Quiz Type', 'taxonomy singular name', 'woothemes-sensei' ),
456
-			'search_items' =>  __( 'Search Quiz Types', 'woothemes-sensei' ),
457
-			'all_items' => __( 'All Quiz Types', 'woothemes-sensei' ),
458
-			'parent_item' => __( 'Parent Quiz Type', 'woothemes-sensei' ),
459
-			'parent_item_colon' => __( 'Parent Quiz Type:', 'woothemes-sensei' ),
460
-			'edit_item' => __( 'Edit Quiz Type', 'woothemes-sensei' ),
461
-			'update_item' => __( 'Update Quiz Type', 'woothemes-sensei' ),
462
-			'add_new_item' => __( 'Add New Quiz Type', 'woothemes-sensei' ),
463
-			'new_item_name' => __( 'New Quiz Type Name', 'woothemes-sensei' ),
464
-			'menu_name' => __( 'Quiz Types', 'woothemes-sensei' ),
454
+			'name' => _x('Quiz Types', 'taxonomy general name', 'woothemes-sensei'),
455
+			'singular_name' => _x('Quiz Type', 'taxonomy singular name', 'woothemes-sensei'),
456
+			'search_items' =>  __('Search Quiz Types', 'woothemes-sensei'),
457
+			'all_items' => __('All Quiz Types', 'woothemes-sensei'),
458
+			'parent_item' => __('Parent Quiz Type', 'woothemes-sensei'),
459
+			'parent_item_colon' => __('Parent Quiz Type:', 'woothemes-sensei'),
460
+			'edit_item' => __('Edit Quiz Type', 'woothemes-sensei'),
461
+			'update_item' => __('Update Quiz Type', 'woothemes-sensei'),
462
+			'add_new_item' => __('Add New Quiz Type', 'woothemes-sensei'),
463
+			'new_item_name' => __('New Quiz Type Name', 'woothemes-sensei'),
464
+			'menu_name' => __('Quiz Types', 'woothemes-sensei'),
465 465
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
466 466
 		);
467 467
 
@@ -472,10 +472,10 @@  discard block
 block discarded – undo
472 472
 			'query_var' => true,
473 473
 			'show_in_nav_menus' => false,
474 474
             'public' => false,
475
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
475
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_quiz_type_slug', _x('quiz-type', 'taxonomy archive slug', 'woothemes-sensei'))))
476 476
 		);
477 477
 
478
-		register_taxonomy( 'quiz-type', array( 'quiz' ), $args );
478
+		register_taxonomy('quiz-type', array('quiz'), $args);
479 479
 	} // End setup_quiz_type_taxonomy()
480 480
 
481 481
 	/**
@@ -483,21 +483,21 @@  discard block
 block discarded – undo
483 483
 	 * @since  1.3.0
484 484
 	 * @return void
485 485
 	 */
486
-	public function setup_question_type_taxonomy () {
486
+	public function setup_question_type_taxonomy() {
487 487
 
488 488
 		// "Question Types" Custom Taxonomy
489 489
 		$labels = array(
490
-			'name' => _x( 'Question Types', 'taxonomy general name', 'woothemes-sensei' ),
491
-			'singular_name' => _x( 'Question Type', 'taxonomy singular name', 'woothemes-sensei' ),
492
-			'search_items' =>  __( 'Search Question Types', 'woothemes-sensei' ),
493
-			'all_items' => __( 'All Question Types', 'woothemes-sensei' ),
494
-			'parent_item' => __( 'Parent Question Type', 'woothemes-sensei' ),
495
-			'parent_item_colon' => __( 'Parent Question Type:', 'woothemes-sensei' ),
496
-			'edit_item' => __( 'Edit Question Type', 'woothemes-sensei' ),
497
-			'update_item' => __( 'Update Question Type', 'woothemes-sensei' ),
498
-			'add_new_item' => __( 'Add New Question Type', 'woothemes-sensei' ),
499
-			'new_item_name' => __( 'New Question Type Name', 'woothemes-sensei' ),
500
-			'menu_name' => __( 'Question Types', 'woothemes-sensei' ),
490
+			'name' => _x('Question Types', 'taxonomy general name', 'woothemes-sensei'),
491
+			'singular_name' => _x('Question Type', 'taxonomy singular name', 'woothemes-sensei'),
492
+			'search_items' =>  __('Search Question Types', 'woothemes-sensei'),
493
+			'all_items' => __('All Question Types', 'woothemes-sensei'),
494
+			'parent_item' => __('Parent Question Type', 'woothemes-sensei'),
495
+			'parent_item_colon' => __('Parent Question Type:', 'woothemes-sensei'),
496
+			'edit_item' => __('Edit Question Type', 'woothemes-sensei'),
497
+			'update_item' => __('Update Question Type', 'woothemes-sensei'),
498
+			'add_new_item' => __('Add New Question Type', 'woothemes-sensei'),
499
+			'new_item_name' => __('New Question Type Name', 'woothemes-sensei'),
500
+			'menu_name' => __('Question Types', 'woothemes-sensei'),
501 501
 			'popular_items' => null // Hides the "Popular" section above the "add" form in the admin.
502 502
 		);
503 503
 
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 			'query_var' => false,
510 510
 			'show_in_nav_menus' => false,
511 511
 			'show_admin_column' => true,
512
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_type_slug', _x( 'question-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
512
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_type_slug', _x('question-type', 'taxonomy archive slug', 'woothemes-sensei'))))
513 513
 		);
514 514
 
515
-		register_taxonomy( 'question-type', array( 'question' ), $args );
515
+		register_taxonomy('question-type', array('question'), $args);
516 516
 	} // End setup_question_type_taxonomy()
517 517
 
518 518
 	/**
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
 	 * @since  1.3.0
521 521
 	 * @return void
522 522
 	 */
523
-	public function setup_question_category_taxonomy () {
523
+	public function setup_question_category_taxonomy() {
524 524
 		// "Question Categories" Custom Taxonomy
525 525
 		$labels = array(
526
-			'name' => _x( 'Question Categories', 'taxonomy general name', 'woothemes-sensei' ),
527
-			'singular_name' => _x( 'Question Category', 'taxonomy singular name', 'woothemes-sensei' ),
528
-			'search_items' =>  __( 'Search Question Categories', 'woothemes-sensei' ),
529
-			'all_items' => __( 'All Question Categories', 'woothemes-sensei' ),
530
-			'parent_item' => __( 'Parent Question Category', 'woothemes-sensei' ),
531
-			'parent_item_colon' => __( 'Parent Question Category:', 'woothemes-sensei' ),
532
-			'edit_item' => __( 'Edit Question Category', 'woothemes-sensei' ),
533
-			'update_item' => __( 'Update Question Category', 'woothemes-sensei' ),
534
-			'add_new_item' => __( 'Add New Question Category', 'woothemes-sensei' ),
535
-			'new_item_name' => __( 'New Question Category Name', 'woothemes-sensei' ),
536
-			'menu_name' => __( 'Categories', 'woothemes-sensei' ),
526
+			'name' => _x('Question Categories', 'taxonomy general name', 'woothemes-sensei'),
527
+			'singular_name' => _x('Question Category', 'taxonomy singular name', 'woothemes-sensei'),
528
+			'search_items' =>  __('Search Question Categories', 'woothemes-sensei'),
529
+			'all_items' => __('All Question Categories', 'woothemes-sensei'),
530
+			'parent_item' => __('Parent Question Category', 'woothemes-sensei'),
531
+			'parent_item_colon' => __('Parent Question Category:', 'woothemes-sensei'),
532
+			'edit_item' => __('Edit Question Category', 'woothemes-sensei'),
533
+			'update_item' => __('Update Question Category', 'woothemes-sensei'),
534
+			'add_new_item' => __('Add New Question Category', 'woothemes-sensei'),
535
+			'new_item_name' => __('New Question Category Name', 'woothemes-sensei'),
536
+			'menu_name' => __('Categories', 'woothemes-sensei'),
537 537
 		);
538 538
 
539 539
 		$args = array(
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
                 'edit_terms'   => 'edit_questions',
550 550
                 'delete_terms' => 'manage_categories',
551 551
                 'assign_terms' => 'edit_questions',),
552
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
552
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_category_slug', _x('question-category', 'taxonomy archive slug', 'woothemes-sensei'))))
553 553
 		);
554 554
 
555
-		register_taxonomy( 'question-category', array( 'question' ), $args );
555
+		register_taxonomy('question-category', array('question'), $args);
556 556
 	} // End setup_question_type_taxonomy()
557 557
 
558 558
 	/**
@@ -560,20 +560,20 @@  discard block
 block discarded – undo
560 560
 	 * @since  1.5.0
561 561
 	 * @return void
562 562
 	 */
563
-	public function setup_lesson_tag_taxonomy () {
563
+	public function setup_lesson_tag_taxonomy() {
564 564
 		// "Lesson Tags" Custom Taxonomy
565 565
 		$labels = array(
566
-			'name' => _x( 'Lesson Tags', 'taxonomy general name', 'woothemes-sensei' ),
567
-			'singular_name' => _x( 'Lesson Tag', 'taxonomy singular name', 'woothemes-sensei' ),
568
-			'search_items' =>  __( 'Search Lesson Tags', 'woothemes-sensei' ),
569
-			'all_items' => __( 'All Lesson Tags', 'woothemes-sensei' ),
570
-			'parent_item' => __( 'Parent Tag', 'woothemes-sensei' ),
571
-			'parent_item_colon' => __( 'Parent Tag:', 'woothemes-sensei' ),
572
-			'edit_item' => __( 'Edit Lesson Tag', 'woothemes-sensei' ),
573
-			'update_item' => __( 'Update Lesson Tag', 'woothemes-sensei' ),
574
-			'add_new_item' => __( 'Add New Lesson Tag', 'woothemes-sensei' ),
575
-			'new_item_name' => __( 'New Tag Name', 'woothemes-sensei' ),
576
-			'menu_name' => __( 'Lesson Tags', 'woothemes-sensei' )
566
+			'name' => _x('Lesson Tags', 'taxonomy general name', 'woothemes-sensei'),
567
+			'singular_name' => _x('Lesson Tag', 'taxonomy singular name', 'woothemes-sensei'),
568
+			'search_items' =>  __('Search Lesson Tags', 'woothemes-sensei'),
569
+			'all_items' => __('All Lesson Tags', 'woothemes-sensei'),
570
+			'parent_item' => __('Parent Tag', 'woothemes-sensei'),
571
+			'parent_item_colon' => __('Parent Tag:', 'woothemes-sensei'),
572
+			'edit_item' => __('Edit Lesson Tag', 'woothemes-sensei'),
573
+			'update_item' => __('Update Lesson Tag', 'woothemes-sensei'),
574
+			'add_new_item' => __('Add New Lesson Tag', 'woothemes-sensei'),
575
+			'new_item_name' => __('New Tag Name', 'woothemes-sensei'),
576
+			'menu_name' => __('Lesson Tags', 'woothemes-sensei')
577 577
 		);
578 578
 
579 579
 		$args = array(
@@ -587,10 +587,10 @@  discard block
 block discarded – undo
587 587
                 'edit_terms'   => 'edit_lessons',
588 588
                 'delete_terms' => 'manage_categories',
589 589
                 'assign_terms' => 'edit_lessons',),
590
-			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
590
+			'rewrite' => array('slug' => esc_attr(apply_filters('sensei_lesson_tag_slug', _x('lesson-tag', 'taxonomy archive slug', 'woothemes-sensei'))))
591 591
 		);
592 592
 
593
-		register_taxonomy( 'lesson-tag', array( 'lesson' ), $args );
593
+		register_taxonomy('lesson-tag', array('lesson'), $args);
594 594
 	} // End setup_lesson_tag_taxonomy()
595 595
 
596 596
 	/**
@@ -598,15 +598,15 @@  discard block
 block discarded – undo
598 598
 	 * @since  1.0.0
599 599
 	 * @return void
600 600
 	 */
601
-	private function setup_post_type_labels_base () {
602
-		$this->labels = array( 'course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array() );
601
+	private function setup_post_type_labels_base() {
602
+		$this->labels = array('course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array());
603 603
 
604
-		$this->labels['course'] = array( 'singular' => __( 'Course', 'woothemes-sensei' ), 'plural' => __( 'Courses', 'woothemes-sensei' ), 'menu' => __( 'Courses', 'woothemes-sensei' ) );
605
-		$this->labels['lesson'] = array( 'singular' => __( 'Lesson', 'woothemes-sensei' ), 'plural' => __( 'Lessons', 'woothemes-sensei' ), 'menu' => __( 'Lessons', 'woothemes-sensei' ) );
606
-		$this->labels['quiz'] = array( 'singular' => __( 'Quiz', 'woothemes-sensei' ), 'plural' => __( 'Quizzes', 'woothemes-sensei' ), 'menu' => __( 'Quizzes', 'woothemes-sensei' ) );
607
-		$this->labels['question'] = array( 'singular' => __( 'Question', 'woothemes-sensei' ), 'plural' => __( 'Questions', 'woothemes-sensei' ), 'menu' => __( 'Questions', 'woothemes-sensei' ) );
608
-		$this->labels['multiple_question'] = array( 'singular' => __( 'Multiple Question', 'woothemes-sensei' ), 'plural' => __( 'Multiple Questions', 'woothemes-sensei' ), 'menu' => __( 'Multiple Questions', 'woothemes-sensei' ) );
609
-		$this->labels['sensei_message'] = array( 'singular' => __( 'Message', 'woothemes-sensei' ), 'plural' => __( 'Messages', 'woothemes-sensei' ), 'menu' => __( 'Messages', 'woothemes-sensei' ) );
604
+		$this->labels['course'] = array('singular' => __('Course', 'woothemes-sensei'), 'plural' => __('Courses', 'woothemes-sensei'), 'menu' => __('Courses', 'woothemes-sensei'));
605
+		$this->labels['lesson'] = array('singular' => __('Lesson', 'woothemes-sensei'), 'plural' => __('Lessons', 'woothemes-sensei'), 'menu' => __('Lessons', 'woothemes-sensei'));
606
+		$this->labels['quiz'] = array('singular' => __('Quiz', 'woothemes-sensei'), 'plural' => __('Quizzes', 'woothemes-sensei'), 'menu' => __('Quizzes', 'woothemes-sensei'));
607
+		$this->labels['question'] = array('singular' => __('Question', 'woothemes-sensei'), 'plural' => __('Questions', 'woothemes-sensei'), 'menu' => __('Questions', 'woothemes-sensei'));
608
+		$this->labels['multiple_question'] = array('singular' => __('Multiple Question', 'woothemes-sensei'), 'plural' => __('Multiple Questions', 'woothemes-sensei'), 'menu' => __('Multiple Questions', 'woothemes-sensei'));
609
+		$this->labels['sensei_message'] = array('singular' => __('Message', 'woothemes-sensei'), 'plural' => __('Messages', 'woothemes-sensei'), 'menu' => __('Messages', 'woothemes-sensei'));
610 610
 
611 611
 	} // End setup_post_type_labels_base()
612 612
 
@@ -618,24 +618,24 @@  discard block
 block discarded – undo
618 618
 	 * @param  string $menu     The menu item label
619 619
 	 * @return array            An array of the labels to be used
620 620
 	 */
621
-	private function create_post_type_labels ( $singular, $plural, $menu ) {
621
+	private function create_post_type_labels($singular, $plural, $menu) {
622 622
 
623
-		$lower_case_plural =  function_exists( 'mb_strtolower' ) ? mb_strtolower( $plural, 'UTF-8') :  strtolower( $plural );
623
+		$lower_case_plural = function_exists('mb_strtolower') ? mb_strtolower($plural, 'UTF-8') : strtolower($plural);
624 624
 
625 625
 		$labels = array(
626
-		    'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ),
627
-		    'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ),
628
-		    'add_new' => __( 'Add New', 'woothemes-sensei' ),
629
-		    'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ),
630
-		    'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ),
631
-		    'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ),
632
-		    'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ),
633
-		    'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ),
634
-		    'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ),
635
-		    'not_found' =>  sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) ,
636
-		    'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ),  $lower_case_plural ),
626
+		    'name' => sprintf(_x('%s', 'post type general name', 'woothemes-sensei'), $plural),
627
+		    'singular_name' => sprintf(_x('%s', 'post type singular name', 'woothemes-sensei'), $singular),
628
+		    'add_new' => __('Add New', 'woothemes-sensei'),
629
+		    'add_new_item' => sprintf(__('Add New %s', 'woothemes-sensei'), $singular),
630
+		    'edit_item' => sprintf(__('Edit %s', 'woothemes-sensei'), $singular),
631
+		    'new_item' => sprintf(__('New %s', 'woothemes-sensei'), $singular),
632
+		    'all_items' => sprintf(__('All %s', 'woothemes-sensei'), $plural),
633
+		    'view_item' => sprintf(__('View %s', 'woothemes-sensei'), $singular),
634
+		    'search_items' => sprintf(__('Search %s', 'woothemes-sensei'), $plural),
635
+		    'not_found' =>  sprintf(__('No %s found', 'woothemes-sensei'), $lower_case_plural),
636
+		    'not_found_in_trash' => sprintf(__('No %s found in Trash', 'woothemes-sensei'), $lower_case_plural),
637 637
 		    'parent_item_colon' => '',
638
-		    'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu )
638
+		    'menu_name' => sprintf(__('%s', 'woothemes-sensei'), $menu)
639 639
 		  );
640 640
 
641 641
 		return $labels;
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 	 * @param  array $messages The existing array of messages for post types.
648 648
 	 * @return array           The modified array of messages for post types.
649 649
 	 */
650
-	public function setup_post_type_messages ( $messages ) {
650
+	public function setup_post_type_messages($messages) {
651 651
 		global $post, $post_ID;
652 652
 
653
-		$messages['course'] = $this->create_post_type_messages( 'course' );
654
-		$messages['lesson'] = $this->create_post_type_messages( 'lesson' );
655
-		$messages['quiz'] = $this->create_post_type_messages( 'quiz' );
656
-		$messages['question'] = $this->create_post_type_messages( 'question' );
657
-		$messages['multiple_question'] = $this->create_post_type_messages( 'multiple_question' );
653
+		$messages['course'] = $this->create_post_type_messages('course');
654
+		$messages['lesson'] = $this->create_post_type_messages('lesson');
655
+		$messages['quiz'] = $this->create_post_type_messages('quiz');
656
+		$messages['question'] = $this->create_post_type_messages('question');
657
+		$messages['multiple_question'] = $this->create_post_type_messages('multiple_question');
658 658
 
659 659
 		return $messages;
660 660
 	} // End setup_post_type_messages()
@@ -665,23 +665,23 @@  discard block
 block discarded – undo
665 665
 	 * @param  string $post_type The post type for which to create messages.
666 666
 	 * @return array            An array of messages (empty array if the post type isn't one we're looking to work with).
667 667
 	 */
668
-	private function create_post_type_messages ( $post_type ) {
668
+	private function create_post_type_messages($post_type) {
669 669
 		global $post, $post_ID;
670 670
 
671
-		if ( ! isset( $this->labels[$post_type] ) ) { return array(); }
671
+		if ( ! isset($this->labels[$post_type])) { return array(); }
672 672
 
673 673
 		$messages = array(
674 674
 			0 => '',
675
-			1 => sprintf( __( '%1$s updated. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
676
-			2 => __( 'Custom field updated.' , 'woothemes-sensei' ),
677
-			3 => __( 'Custom field deleted.' , 'woothemes-sensei' ),
678
-			4 => sprintf( __( '%1$s updated.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
679
-			5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
680
-			6 => sprintf( __( '%1$s published. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ),
681
-			7 => sprintf( __( '%1$s saved.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ),
682
-			8 => sprintf( __( '%1$s submitted. %2$sPreview %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', '</a>' ),
683
-			9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'woothemes-sensei' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
684
-			10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ),
675
+			1 => sprintf(__('%1$s updated. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'),
676
+			2 => __('Custom field updated.', 'woothemes-sensei'),
677
+			3 => __('Custom field deleted.', 'woothemes-sensei'),
678
+			4 => sprintf(__('%1$s updated.', 'woothemes-sensei'), $this->labels[$post_type]['singular']),
679
+			5 => isset($_GET['revision']) ? sprintf(__('%1$s restored to revision from %2$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], wp_post_revision_title((int) $_GET['revision'], false)) : false,
680
+			6 => sprintf(__('%1$s published. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'),
681
+			7 => sprintf(__('%1$s saved.', 'woothemes-sensei'), $this->labels[$post_type]['singular']),
682
+			8 => sprintf(__('%1$s submitted. %2$sPreview %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', '</a>'),
683
+			9 => sprintf(__('%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<strong>'.date_i18n(__('M j, Y @ G:i', 'woothemes-sensei'), strtotime($post->post_date)).'</strong>', '<a target="_blank" href="'.esc_url(get_permalink($post_ID)).'">', $this->labels[$post_type]['singular'], '</a>'),
684
+			10 => sprintf(__('%1$s draft updated. %2$sPreview %3$s%4$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', $this->labels[$post_type]['singular'], '</a>'),
685 685
 		);
686 686
 
687 687
 		return $messages;
@@ -694,11 +694,11 @@  discard block
 block discarded – undo
694 694
 	 * @param  string $title
695 695
 	 * @return string $title
696 696
 	 */
697
-	public function enter_title_here ( $title ) {
698
-		if ( get_post_type() == 'course' ) {
699
-			$title = __( 'Enter a title for this course here', 'woothemes-sensei' );
700
-		} elseif ( get_post_type() == 'lesson' ) {
701
-			$title = __( 'Enter a title for this lesson here', 'woothemes-sensei' );
697
+	public function enter_title_here($title) {
698
+		if (get_post_type() == 'course') {
699
+			$title = __('Enter a title for this course here', 'woothemes-sensei');
700
+		} elseif (get_post_type() == 'lesson') {
701
+			$title = __('Enter a title for this lesson here', 'woothemes-sensei');
702 702
 		}
703 703
 
704 704
 		return $title;
@@ -712,60 +712,60 @@  discard block
 block discarded – undo
712 712
 	 * @param array $post_types
713 713
 	 * @return void
714 714
 	 */
715
-	public function set_role_cap_defaults( $post_types = array() ) {
715
+	public function set_role_cap_defaults($post_types = array()) {
716 716
 
717
-		foreach ( $post_types as $post_type_item => $post_type_name ) {
717
+		foreach ($post_types as $post_type_item => $post_type_name) {
718 718
 			// Super Admin
719
-			$this->role_caps[] =  array(	'administrator' 	=> array( 	'edit_' . $post_type_item,
720
-																			'read_' . $post_type_item,
721
-																			'delete_' . $post_type_item,
722
-																			'create_' . $post_type_item . 's',
723
-																			'edit_' . $post_type_item . 's',
724
-																			'edit_others_' . $post_type_item . 's',
725
-																			'publish_' . $post_type_item . 's',
726
-																			'read_private_' . $post_type_item . 's',
719
+			$this->role_caps[] = array('administrator' 	=> array('edit_'.$post_type_item,
720
+																			'read_'.$post_type_item,
721
+																			'delete_'.$post_type_item,
722
+																			'create_'.$post_type_item.'s',
723
+																			'edit_'.$post_type_item.'s',
724
+																			'edit_others_'.$post_type_item.'s',
725
+																			'publish_'.$post_type_item.'s',
726
+																			'read_private_'.$post_type_item.'s',
727 727
 																			'read',
728
-																			'delete_' . $post_type_item . 's',
729
-																			'delete_private_' . $post_type_item . 's',
730
-																			'delete_published_' . $post_type_item . 's',
731
-																			'delete_others_' . $post_type_item . 's',
732
-																			'edit_private_' . $post_type_item . 's',
733
-																			'edit_published_' . $post_type_item . 's',
728
+																			'delete_'.$post_type_item.'s',
729
+																			'delete_private_'.$post_type_item.'s',
730
+																			'delete_published_'.$post_type_item.'s',
731
+																			'delete_others_'.$post_type_item.'s',
732
+																			'edit_private_'.$post_type_item.'s',
733
+																			'edit_published_'.$post_type_item.'s',
734 734
 																			'manage_sensei',
735
-																			'manage_sensei_grades' ),
736
-											'editor' 			=> array(	'edit_' . $post_type_item,
737
-																			'read_' . $post_type_item,
738
-																			'delete_' . $post_type_item,
739
-																			'create_' . $post_type_item . 's',
740
-																		 	'edit_' . $post_type_item . 's',
741
-																			'edit_others_' . $post_type_item . 's',
742
-																			'publish_' . $post_type_item . 's',
743
-																			'read_private_' . $post_type_item . 's',
735
+																			'manage_sensei_grades'),
736
+											'editor' 			=> array('edit_'.$post_type_item,
737
+																			'read_'.$post_type_item,
738
+																			'delete_'.$post_type_item,
739
+																			'create_'.$post_type_item.'s',
740
+																		 	'edit_'.$post_type_item.'s',
741
+																			'edit_others_'.$post_type_item.'s',
742
+																			'publish_'.$post_type_item.'s',
743
+																			'read_private_'.$post_type_item.'s',
744 744
 																			'read',
745
-																			'delete_' . $post_type_item . 's',
746
-																			'delete_private_' . $post_type_item . 's',
747
-																			'delete_published_' . $post_type_item . 's',
748
-																			'delete_others_' . $post_type_item . 's',
749
-																			'edit_private_' . $post_type_item . 's',
750
-																			'edit_published_' . $post_type_item . 's' ),
751
-											'author' 			=> array( 	'edit_' . $post_type_item,
752
-																			'read_' . $post_type_item,
753
-																			'delete_' . $post_type_item,
754
-																			'create_' . $post_type_item . 's',
755
-																			'edit_' . $post_type_item . 's',
756
-																			'publish_' . $post_type_item . 's',
745
+																			'delete_'.$post_type_item.'s',
746
+																			'delete_private_'.$post_type_item.'s',
747
+																			'delete_published_'.$post_type_item.'s',
748
+																			'delete_others_'.$post_type_item.'s',
749
+																			'edit_private_'.$post_type_item.'s',
750
+																			'edit_published_'.$post_type_item.'s'),
751
+											'author' 			=> array('edit_'.$post_type_item,
752
+																			'read_'.$post_type_item,
753
+																			'delete_'.$post_type_item,
754
+																			'create_'.$post_type_item.'s',
755
+																			'edit_'.$post_type_item.'s',
756
+																			'publish_'.$post_type_item.'s',
757 757
 																			'read',
758
-																			'delete_' . $post_type_item . 's',
759
-																			'delete_published_' . $post_type_item . 's',
760
-																			'edit_published_' . $post_type_item . 's' ),
761
-											'contributor' 		=> array( 	'edit_' . $post_type_item,
762
-																			'read_' . $post_type_item,
763
-																			'delete_' . $post_type_item,
764
-																			'create_' . $post_type_item . 's',
765
-																			'edit_' . $post_type_item . 's',
758
+																			'delete_'.$post_type_item.'s',
759
+																			'delete_published_'.$post_type_item.'s',
760
+																			'edit_published_'.$post_type_item.'s'),
761
+											'contributor' 		=> array('edit_'.$post_type_item,
762
+																			'read_'.$post_type_item,
763
+																			'delete_'.$post_type_item,
764
+																			'create_'.$post_type_item.'s',
765
+																			'edit_'.$post_type_item.'s',
766 766
 																			'read',
767
-																			'delete_' . $post_type_item . 's' ),
768
-											'subscriber' 		=> array( 	'read' )
767
+																			'delete_'.$post_type_item.'s'),
768
+											'subscriber' 		=> array('read')
769 769
 
770 770
 										);
771 771
 		} // End For Loop
@@ -779,16 +779,16 @@  discard block
 block discarded – undo
779 779
      * @param WP_Admin_Bar $bar
780 780
 	 * @return void
781 781
 	 */
782
-	public function quiz_admin_bar_menu( $bar ) {
783
-		if ( is_single() && 'quiz' == get_queried_object()->post_type ) {
784
-			$lesson_id = get_post_meta( get_queried_object()->ID, '_quiz_lesson', true );
785
-			if ( $lesson_id ) {
782
+	public function quiz_admin_bar_menu($bar) {
783
+		if (is_single() && 'quiz' == get_queried_object()->post_type) {
784
+			$lesson_id = get_post_meta(get_queried_object()->ID, '_quiz_lesson', true);
785
+			if ($lesson_id) {
786 786
 				$object_type = get_post_type_object('quiz');
787
-				$bar->add_menu( array(
787
+				$bar->add_menu(array(
788 788
 					'id' => 'edit',
789 789
 					'title' => $object_type->labels->edit_item,
790
-					'href' => get_edit_post_link( $lesson_id ),
791
-				) );
790
+					'href' => get_edit_post_link($lesson_id),
791
+				));
792 792
 			}
793 793
 		}
794 794
 	}
@@ -800,4 +800,4 @@  discard block
 block discarded – undo
800 800
  * @ignore only for backward compatibility
801 801
  * @since 1.9.0
802 802
  */
803
-class WooThemes_Sensei_PostTypes extends Sensei_PostTypes{}
803
+class WooThemes_Sensei_PostTypes extends Sensei_PostTypes {}
Please login to merge, or discard this patch.
widgets/widget-woothemes-sensei-course-component.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
3 3
 
4 4
 /**
5 5
  * Sensei Course Component Widget
@@ -26,30 +26,30 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_course_component';
29
-		$this->woo_widget_description = __( 'This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_course_component';
31
-		$this->woo_widget_title = __( 'Sensei - Course Component', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Course Component', 'woothemes-sensei');
32 32
 
33 33
 		$this->woo_widget_componentslist = array(
34
-												'usercourses' => __( 'New Courses', 'woothemes-sensei' ),
35
-												'featuredcourses' => __( 'Featured Courses', 'woothemes-sensei' ),
36
-												'activecourses' => __( 'My Active Courses', 'woothemes-sensei' ),
37
-												'completedcourses' => __( 'My Completed Courses', 'woothemes-sensei' ),
34
+												'usercourses' => __('New Courses', 'woothemes-sensei'),
35
+												'featuredcourses' => __('Featured Courses', 'woothemes-sensei'),
36
+												'activecourses' => __('My Active Courses', 'woothemes-sensei'),
37
+												'completedcourses' => __('My Completed Courses', 'woothemes-sensei'),
38 38
 												);
39 39
 
40 40
 		// Add support for the WooCommerce shelf.
41
-		if ( Sensei_WC::is_woocommerce_active() ) {
42
-			$this->woo_widget_componentslist['freecourses'] = __( 'Free Courses', 'woothemes-sensei' );
43
-			$this->woo_widget_componentslist['paidcourses'] = __( 'Paid Courses', 'woothemes-sensei' );
41
+		if (Sensei_WC::is_woocommerce_active()) {
42
+			$this->woo_widget_componentslist['freecourses'] = __('Free Courses', 'woothemes-sensei');
43
+			$this->woo_widget_componentslist['paidcourses'] = __('Paid Courses', 'woothemes-sensei');
44 44
 		}
45 45
 		/* Widget settings. */
46
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
46
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
47 47
 
48 48
 		/* Widget control settings. */
49
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
49
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
50 50
 
51 51
 		/* Create the widget. */
52
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
52
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
53 53
 	} // End __construct()
54 54
 
55 55
 	/**
@@ -59,44 +59,44 @@  discard block
 block discarded – undo
59 59
 	 * @param  array $instance Widget settings for this instance.
60 60
 	 * @return void
61 61
 	 */
62
-	public function widget( $args, $instance ) {
62
+	public function widget($args, $instance) {
63 63
 
64
-		remove_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
64
+		remove_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
65 65
 
66
-		if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) )
67
-            && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] )
68
-            && !is_user_logged_in() ) {
66
+		if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))
67
+            && ('activecourses' == $instance['component'] || 'completedcourses' == $instance['component'])
68
+            && ! is_user_logged_in()) {
69 69
 
70 70
 			// No Output
71 71
             return;
72 72
 
73 73
 		} else {
74 74
 			/* Our variables from the widget settings. */
75
-			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
75
+			$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
76 76
 
77 77
 			/* Before widget (defined by themes). */
78 78
 			echo $args['before_widget'];
79 79
 
80 80
 			/* Display the widget title if one was input (before and after defined by themes). */
81
-			if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; }
81
+			if ($title) { echo $args['before_title'].$title.$args['after_title']; }
82 82
 
83 83
 			/* Widget content. */
84 84
 			// Add actions for plugins/themes to hook onto.
85
-			do_action( $this->woo_widget_cssclass . '_top' );
85
+			do_action($this->woo_widget_cssclass.'_top');
86 86
 
87
-			if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) ) {
88
-				$this->load_component( $instance );
87
+			if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))) {
88
+				$this->load_component($instance);
89 89
 			}
90 90
 
91 91
 			// Add actions for plugins/themes to hook onto.
92
-			do_action( $this->woo_widget_cssclass . '_bottom' );
92
+			do_action($this->woo_widget_cssclass.'_bottom');
93 93
 
94 94
 			/* After widget (defined by themes). */
95 95
 			echo $args['after_widget'];
96 96
 
97 97
 		} // End If Statement
98 98
 
99
-		add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
99
+		add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
100 100
 
101 101
 	} // End widget()
102 102
 
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 * @param  array $old_instance Previous settings.
108 108
 	 * @return array               Updated settings.
109 109
 	 */
110
-	public function update ( $new_instance, $old_instance ) {
110
+	public function update($new_instance, $old_instance) {
111 111
 		$instance = $old_instance;
112 112
 
113 113
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
114
-		$instance['title'] = strip_tags( $new_instance['title'] );
114
+		$instance['title'] = strip_tags($new_instance['title']);
115 115
 
116 116
 		/* The select box is returning a text value, so we escape it. */
117
-		$instance['component'] = esc_attr( $new_instance['component'] );
117
+		$instance['component'] = esc_attr($new_instance['component']);
118 118
 
119 119
 		/* The select box is returning a text value, so we escape it. */
120
-		$instance['limit'] = esc_attr( $new_instance['limit'] );
120
+		$instance['limit'] = esc_attr($new_instance['limit']);
121 121
 
122 122
 
123 123
 		return $instance;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @param  array $instance The settings for this instance.
131 131
 	 * @return void
132 132
 	 */
133
-    public function form( $instance ) {
133
+    public function form($instance) {
134 134
 
135 135
 		/* Set up some default widget settings. */
136 136
 		/* Make sure all keys are added here, even with empty string values. */
@@ -140,26 +140,26 @@  discard block
 block discarded – undo
140 140
 						'limit' => 3
141 141
 					);
142 142
 
143
-		$instance = wp_parse_args( (array) $instance, $defaults );
143
+		$instance = wp_parse_args((array) $instance, $defaults);
144 144
 ?>
145 145
 		<!-- Widget Title: Text Input -->
146 146
 		<p>
147
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
148
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
147
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
148
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
149 149
 		</p>
150 150
 		<!-- Widget Component: Select Input -->
151 151
 		<p>
152
-			<label for="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"><?php _e( 'Component:', 'woothemes-sensei' ); ?></label>
153
-			<select name="<?php echo esc_attr( $this->get_field_name( 'component' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>">
154
-			<?php foreach ( $this->woo_widget_componentslist as $k => $v ) { ?>
155
-				<option value="<?php echo esc_attr( $k ); ?>"<?php selected( $instance['component'], $k ); ?>><?php echo $v; ?></option>
152
+			<label for="<?php echo esc_attr($this->get_field_id('component')); ?>"><?php _e('Component:', 'woothemes-sensei'); ?></label>
153
+			<select name="<?php echo esc_attr($this->get_field_name('component')); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('component')); ?>">
154
+			<?php foreach ($this->woo_widget_componentslist as $k => $v) { ?>
155
+				<option value="<?php echo esc_attr($k); ?>"<?php selected($instance['component'], $k); ?>><?php echo $v; ?></option>
156 156
 			<?php } ?>
157 157
 			</select>
158 158
 		</p>
159 159
 		<!-- Widget Limit: Text Input -->
160 160
 		<p>
161
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Courses (optional):', 'woothemes-sensei' ); ?></label>
162
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
161
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Courses (optional):', 'woothemes-sensei'); ?></label>
162
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
163 163
 		</p>
164 164
 
165 165
 <?php
@@ -172,26 +172,26 @@  discard block
 block discarded – undo
172 172
 	 * @since  1.0.0
173 173
 	 * @return void
174 174
 	 */
175
-	protected function load_component ( $instance ) {
175
+	protected function load_component($instance) {
176 176
 		global  $current_user;
177 177
 
178 178
 		$course_ids = array();
179
-		if ( 'activecourses' == esc_attr( $instance['component'] ) ) {
180
-			$courses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'in-progress' ), true );
179
+		if ('activecourses' == esc_attr($instance['component'])) {
180
+			$courses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'in-progress'), true);
181 181
 			// Need to always return an array, even with only 1 item
182
-			if ( !is_array($courses) ) {
183
-				$courses = array( $courses );
182
+			if ( ! is_array($courses)) {
183
+				$courses = array($courses);
184 184
 			}
185
-			foreach( $courses AS $course ) {
185
+			foreach ($courses AS $course) {
186 186
 				$course_ids[] = $course->comment_post_ID;
187 187
 			}
188
-		} elseif( 'completedcourses' == esc_attr( $instance['component'] ) ) {
189
-			$courses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'complete' ), true );
188
+		} elseif ('completedcourses' == esc_attr($instance['component'])) {
189
+			$courses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $current_user->ID, 'type' => 'sensei_course_status', 'status' => 'complete'), true);
190 190
 			// Need to always return an array, even with only 1 item
191
-			if ( !is_array($courses) ) {
192
-				$courses = array( $courses );
191
+			if ( ! is_array($courses)) {
192
+				$courses = array($courses);
193 193
 			}
194
-			foreach( $courses AS $course ) {
194
+			foreach ($courses AS $course) {
195 195
 				$course_ids[] = $course->comment_post_ID;
196 196
 			}
197 197
 		} // End If Statement
@@ -199,19 +199,19 @@  discard block
 block discarded – undo
199 199
 		$posts_array = array();
200 200
 
201 201
 		// course_query() is buggy, it doesn't honour the 1st arg if includes are provided, so instead slice the includes
202
-		if ( !empty($instance['limit']) && intval( $instance['limit'] ) >= 1 && intval( $instance['limit'] ) < count($course_ids) ) {
202
+		if ( ! empty($instance['limit']) && intval($instance['limit']) >= 1 && intval($instance['limit']) < count($course_ids)) {
203 203
 
204
-			$course_ids = array_slice( $course_ids, 0, intval( $instance['limit'] ) ); // This does mean the order by is effectively ignored
204
+			$course_ids = array_slice($course_ids, 0, intval($instance['limit'])); // This does mean the order by is effectively ignored
205 205
 
206 206
 		}
207 207
 
208
-        if ( ! empty( $course_ids ) ) {
208
+        if ( ! empty($course_ids)) {
209 209
 
210
-            $posts_array = Sensei()->course->course_query( intval( $instance['limit'] ), esc_attr( $instance['component'] ), $course_ids );
210
+            $posts_array = Sensei()->course->course_query(intval($instance['limit']), esc_attr($instance['component']), $course_ids);
211 211
 
212 212
 		} else {
213 213
 
214
-            if ( 'activecourses' == esc_attr( $instance['component'] ) || 'completedcourses' == esc_attr( $instance['component'] ) ) {
214
+            if ('activecourses' == esc_attr($instance['component']) || 'completedcourses' == esc_attr($instance['component'])) {
215 215
 				$posts_array = array();
216 216
 
217 217
             } else {
@@ -224,57 +224,57 @@  discard block
 block discarded – undo
224 224
                     'posts_per_page' => $instance['limit'],
225 225
                 );
226 226
 
227
-				$posts_array = get_posts( $course_args );
227
+				$posts_array = get_posts($course_args);
228 228
 			}
229 229
 
230 230
 		} // End If Statement
231 231
 
232
-		if ( count( $posts_array ) > 0 ) { ?>
232
+		if (count($posts_array) > 0) { ?>
233 233
 			<ul>
234
-			<?php foreach ($posts_array as $post_item){
235
-		    	$post_id = absint( $post_item->ID );
234
+			<?php foreach ($posts_array as $post_item) {
235
+		    	$post_id = absint($post_item->ID);
236 236
 		    	$post_title = $post_item->post_title;
237
-		    	$user_info = get_userdata( absint( $post_item->post_author ) );
238
-		    	$author_link = get_author_posts_url( absint( $post_item->post_author ) );
237
+		    	$user_info = get_userdata(absint($post_item->post_author));
238
+		    	$author_link = get_author_posts_url(absint($post_item->post_author));
239 239
 		    	$author_display_name = $user_info->display_name;
240 240
 		    	$author_id = $post_item->post_author;
241 241
 		    ?>
242 242
 		    	<li class="fix">
243
-		    		<?php do_action( 'sensei_course_image', $post_id ); ?>
244
-		    		<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a>
243
+		    		<?php do_action('sensei_course_image', $post_id); ?>
244
+		    		<a href="<?php echo esc_url(get_permalink($post_id)); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a>
245 245
 		    		<br />
246
-		    		<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
247
-    					<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name ); ?></a></span>
246
+		    		<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
247
+    					<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
248 248
     					<br />
249 249
     				<?php } // End If Statement ?>
250
-    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' . __( 'Lessons', 'woothemes-sensei' ); ?></span>
250
+    				<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
251 251
     				<br />
252
-    				<?php sensei_simple_course_price( $post_id ); ?>
252
+    				<?php sensei_simple_course_price($post_id); ?>
253 253
 		    	</li>
254 254
 		    <?php } // End For Loop ?>
255
-		    <?php if ( 'activecourses' == esc_attr( $instance['component'] ) || 'completedcourses' == esc_attr( $instance['component'] ) ) {
256
-		    	$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
257
-		    	echo '<li class="my-account fix"><a href="'. esc_url( get_permalink( $my_account_page_id ) ) .'">'.__('My Courses', 'woothemes-sensei').' <span class="meta-nav"></span></a></li>';
255
+		    <?php if ('activecourses' == esc_attr($instance['component']) || 'completedcourses' == esc_attr($instance['component'])) {
256
+		    	$my_account_page_id = intval(Sensei()->settings->settings['my_course_page']);
257
+		    	echo '<li class="my-account fix"><a href="'.esc_url(get_permalink($my_account_page_id)).'">'.__('My Courses', 'woothemes-sensei').' <span class="meta-nav"></span></a></li>';
258 258
 		    } // End If Statement ?>
259 259
 		</ul>
260 260
 		<?php } else {
261 261
 			// No posts returned. This means the user either has no active or no completed courses.
262
-			if( isset( $instance['component']  ) ) {
262
+			if (isset($instance['component'])) {
263 263
 
264
-				if ( 'featuredcourses' == $instance['component'] ) {
264
+				if ('featuredcourses' == $instance['component']) {
265 265
 
266
-					_e( 'You have no featured courses.', 'woothemes-sensei' );
266
+					_e('You have no featured courses.', 'woothemes-sensei');
267 267
 
268
-				} elseif ( 'activecourses' == $instance['component'] ) {
268
+				} elseif ('activecourses' == $instance['component']) {
269 269
 
270
-					_e( 'You have no active courses.', 'woothemes-sensei' );
270
+					_e('You have no active courses.', 'woothemes-sensei');
271 271
 
272
-				} elseif ( 'completedcourses' == $instance['component'] ) {
273
-					_e( 'You have no completed courses.', 'woothemes-sensei' );
272
+				} elseif ('completedcourses' == $instance['component']) {
273
+					_e('You have no completed courses.', 'woothemes-sensei');
274 274
 
275
-				}else{
275
+				} else {
276 276
 
277
-					_e( 'You have no courses.', 'woothemes-sensei' );
277
+					_e('You have no courses.', 'woothemes-sensei');
278 278
 
279 279
 				}
280 280
 
Please login to merge, or discard this patch.
includes/class-sensei-frontend.php 1 patch
Spacing   +450 added lines, -450 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Frontend Class
@@ -20,78 +20,78 @@  discard block
 block discarded – undo
20 20
 	 * Constructor.
21 21
 	 * @since  1.0.0
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 
25 25
 		// Template output actions
26
-		add_action( 'sensei_before_main_content', array( $this, 'sensei_output_content_wrapper' ), 10 );
27
-		add_action( 'sensei_after_main_content', array( $this, 'sensei_output_content_wrapper_end' ), 10 );
28
-		add_action( 'sensei_lesson_archive_lesson_title', array( $this, 'sensei_lesson_archive_lesson_title' ), 10 );
26
+		add_action('sensei_before_main_content', array($this, 'sensei_output_content_wrapper'), 10);
27
+		add_action('sensei_after_main_content', array($this, 'sensei_output_content_wrapper_end'), 10);
28
+		add_action('sensei_lesson_archive_lesson_title', array($this, 'sensei_lesson_archive_lesson_title'), 10);
29 29
 
30 30
 		// 1.2.1
31
-		add_action( 'wp_head', array( $this, 'sensei_complete_lesson' ), 10 );
32
-		add_action( 'wp_head', array( $this, 'sensei_complete_course' ), 10 );
33
-		add_action( 'sensei_frontend_messages', array( $this, 'sensei_frontend_messages' ) );
34
-		add_action( 'sensei_lesson_video', array( $this, 'sensei_lesson_video' ), 10, 1 );
35
-		add_action( 'sensei_complete_lesson_button', array( $this, 'sensei_complete_lesson_button' ) );
36
-		add_action( 'sensei_reset_lesson_button', array( $this, 'sensei_reset_lesson_button' ) );
31
+		add_action('wp_head', array($this, 'sensei_complete_lesson'), 10);
32
+		add_action('wp_head', array($this, 'sensei_complete_course'), 10);
33
+		add_action('sensei_frontend_messages', array($this, 'sensei_frontend_messages'));
34
+		add_action('sensei_lesson_video', array($this, 'sensei_lesson_video'), 10, 1);
35
+		add_action('sensei_complete_lesson_button', array($this, 'sensei_complete_lesson_button'));
36
+		add_action('sensei_reset_lesson_button', array($this, 'sensei_reset_lesson_button'));
37 37
 
38
-		add_action( 'sensei_course_archive_meta', array( $this, 'sensei_course_archive_meta' ) );
38
+		add_action('sensei_course_archive_meta', array($this, 'sensei_course_archive_meta'));
39 39
 
40
-		add_action( 'sensei_lesson_tag_main_content', array( $this, 'sensei_lesson_archive_main_content' ), 10 );
41
-		add_action( 'sensei_no_permissions_main_content', array( $this, 'sensei_no_permissions_main_content' ), 10 );
40
+		add_action('sensei_lesson_tag_main_content', array($this, 'sensei_lesson_archive_main_content'), 10);
41
+		add_action('sensei_no_permissions_main_content', array($this, 'sensei_no_permissions_main_content'), 10);
42 42
 
43
-		add_action( 'sensei_lesson_meta', array( $this, 'sensei_lesson_meta' ), 10 );
44
-		add_action( 'sensei_single_course_content_inside_before', array( $this, 'sensei_course_start' ), 10 );
43
+		add_action('sensei_lesson_meta', array($this, 'sensei_lesson_meta'), 10);
44
+		add_action('sensei_single_course_content_inside_before', array($this, 'sensei_course_start'), 10);
45 45
 
46 46
 		// add_filter( 'get_comments_number', array( $this, 'sensei_lesson_comment_count' ), 1 );
47
-		add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 );
47
+		add_filter('the_title', array($this, 'sensei_lesson_preview_title'), 10, 2);
48 48
 
49 49
 		//1.6.2
50
-		add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 );
51
-		add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 );
50
+		add_filter('wp_login_failed', array($this, 'sensei_login_fail_redirect'), 10);
51
+		add_filter('init', array($this, 'sensei_handle_login_request'), 10);
52 52
 		//1.6.3
53
-		add_action( 'init', array( $this, 'sensei_process_registration' ), 2 );
53
+		add_action('init', array($this, 'sensei_process_registration'), 2);
54 54
 		//1.7.0
55
-		add_action( 'sensei_pagination', array( $this, 'sensei_breadcrumb' ), 80, 1 );
55
+		add_action('sensei_pagination', array($this, 'sensei_breadcrumb'), 80, 1);
56 56
 
57 57
 		// Fix pagination for course archive pages when filtering by course type
58
-		add_filter( 'pre_get_posts', array( $this, 'sensei_course_archive_pagination' ) );
58
+		add_filter('pre_get_posts', array($this, 'sensei_course_archive_pagination'));
59 59
 
60 60
 		// Scripts and Styles
61
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
62
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
61
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_styles'));
62
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
63 63
 
64 64
 		// Custom Menu Item filters
65
-		add_filter( 'wp_setup_nav_menu_item', array( $this, 'sensei_setup_nav_menu_item' ) );
66
-		add_filter( 'wp_nav_menu_objects', array( $this, 'sensei_wp_nav_menu_objects' ) );
65
+		add_filter('wp_setup_nav_menu_item', array($this, 'sensei_setup_nav_menu_item'));
66
+		add_filter('wp_nav_menu_objects', array($this, 'sensei_wp_nav_menu_objects'));
67 67
 		// Search Results filters
68
-		add_filter( 'post_class', array( $this, 'sensei_search_results_classes' ), 10 );
68
+		add_filter('post_class', array($this, 'sensei_search_results_classes'), 10);
69 69
 		// Only show course & lesson excerpts in search results
70
-		add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) );
70
+		add_filter('the_content', array($this, 'sensei_search_results_excerpt'));
71 71
 
72 72
         //Use WooCommerce filter to show admin bar to Teachers.
73
-        add_action( 'init', array( $this, 'sensei_show_admin_bar') );
73
+        add_action('init', array($this, 'sensei_show_admin_bar'));
74 74
 
75 75
         // Remove course from active courses if an order is cancelled or refunded
76
-		add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
77
-		add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
78
-		add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 );
79
-		add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
80
-		add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
81
-		add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'remove_active_course' ), 10, 1 );
76
+		add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'remove_active_course'), 10, 1);
77
+		add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'remove_active_course'), 10, 1);
78
+		add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'remove_active_course'), 10, 1);
79
+		add_action('woocommerce_order_status_processing_to_refunded', array($this, 'remove_active_course'), 10, 1);
80
+		add_action('woocommerce_order_status_completed_to_refunded', array($this, 'remove_active_course'), 10, 1);
81
+		add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'remove_active_course'), 10, 1);
82 82
 
83 83
 		// Make sure correct courses are marked as active for users
84
-		add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 );
85
-		add_action( 'sensei_single_course_content_inside_before', array( $this, 'activate_purchased_single_course' ), 10 );
84
+		add_action('sensei_before_my_courses', array($this, 'activate_purchased_courses'), 10, 1);
85
+		add_action('sensei_single_course_content_inside_before', array($this, 'activate_purchased_single_course'), 10);
86 86
 
87 87
 		// Lesson tags
88
-		add_action( 'sensei_lesson_meta_extra', array( $this, 'lesson_tags_display' ), 10, 1 );
89
-		add_action( 'pre_get_posts', array( $this, 'lesson_tag_archive_filter' ), 10, 1 );
90
-		add_filter( 'sensei_lessons_archive_text', array( $this, 'lesson_tag_archive_header' ) );
91
-		add_action( 'sensei_loop_lesson_inside_before', array( $this, 'lesson_tag_archive_description' ), 11 );
88
+		add_action('sensei_lesson_meta_extra', array($this, 'lesson_tags_display'), 10, 1);
89
+		add_action('pre_get_posts', array($this, 'lesson_tag_archive_filter'), 10, 1);
90
+		add_filter('sensei_lessons_archive_text', array($this, 'lesson_tag_archive_header'));
91
+		add_action('sensei_loop_lesson_inside_before', array($this, 'lesson_tag_archive_description'), 11);
92 92
 
93 93
 		// Hide Sensei activity comments from lesson and course pages
94
-		add_filter( 'wp_list_comments_args', array( $this, 'hide_sensei_activity' ) );
94
+		add_filter('wp_list_comments_args', array($this, 'hide_sensei_activity'));
95 95
 	} // End __construct()
96 96
 
97 97
 	/**
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @since  1.7.3
102 102
 	 * @return array|mixed
103 103
 	 */
104
-	public function __get( $key ) {
104
+	public function __get($key) {
105 105
 
106
-		if ( 'lesson' == $key || 'course' == $key ) {
107
-			if ( WP_DEBUG ) {
108
-				trigger_error( sprintf( 'Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3' ) );
106
+		if ('lesson' == $key || 'course' == $key) {
107
+			if (WP_DEBUG) {
108
+				trigger_error(sprintf('Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3'));
109 109
 			}
110 110
 			return Sensei()->$key;
111 111
 		}
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
 	 * @since  1.0.0
119 119
 	 * @return void
120 120
 	 */
121
-	public function enqueue_scripts () {
121
+	public function enqueue_scripts() {
122 122
 
123 123
 		$disable_js = false;
124
-		if ( isset( Sensei()->settings->settings[ 'js_disable' ] ) ) {
125
-			$disable_js = Sensei()->settings->settings[ 'js_disable' ];
124
+		if (isset(Sensei()->settings->settings['js_disable'])) {
125
+			$disable_js = Sensei()->settings->settings['js_disable'];
126 126
 		} // End If Statement
127
-		if ( ! $disable_js ) {
127
+		if ( ! $disable_js) {
128 128
 
129
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
129
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
130 130
 
131 131
 			// My Courses tabs script
132
-			wp_register_script( Sensei()->token . '-user-dashboard', esc_url( Sensei()->plugin_url . 'assets/js/user-dashboard' . $suffix . '.js' ), array( 'jquery-ui-tabs' ), Sensei()->version, true );
133
-			wp_enqueue_script( Sensei()->token . '-user-dashboard' );
132
+			wp_register_script(Sensei()->token.'-user-dashboard', esc_url(Sensei()->plugin_url.'assets/js/user-dashboard'.$suffix.'.js'), array('jquery-ui-tabs'), Sensei()->version, true);
133
+			wp_enqueue_script(Sensei()->token.'-user-dashboard');
134 134
 
135 135
 
136 136
             // Course Archive javascript
137
-            if( is_post_type_archive( 'course' ) ){
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
146
-			do_action( 'sensei_additional_scripts' );
146
+			do_action('sensei_additional_scripts');
147 147
 
148 148
 		} // End If Statement
149 149
 
@@ -154,23 +154,23 @@  discard block
 block discarded – undo
154 154
 	 * @since  1.0.0
155 155
 	 * @return void
156 156
 	 */
157
-	public function enqueue_styles () {
157
+	public function enqueue_styles() {
158 158
 
159 159
 		$disable_styles = false;
160
-		if ( isset( Sensei()->settings->settings[ 'styles_disable' ] ) ) {
161
-			$disable_styles = Sensei()->settings->settings[ 'styles_disable' ];
160
+		if (isset(Sensei()->settings->settings['styles_disable'])) {
161
+			$disable_styles = Sensei()->settings->settings['styles_disable'];
162 162
 		} // End If Statement
163 163
 
164 164
 		// Add filter for theme overrides
165
-		$disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles );
165
+		$disable_styles = apply_filters('sensei_disable_styles', $disable_styles);
166 166
 
167
-		if ( ! $disable_styles ) {
167
+		if ( ! $disable_styles) {
168 168
 
169
-			wp_register_style( Sensei()->token . '-frontend', Sensei()->plugin_url . 'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen' );
170
-			wp_enqueue_style( Sensei()->token . '-frontend' );
169
+			wp_register_style(Sensei()->token.'-frontend', Sensei()->plugin_url.'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen');
170
+			wp_enqueue_style(Sensei()->token.'-frontend');
171 171
 
172 172
 			// Allow additional stylesheets to be loaded
173
-			do_action( 'sensei_additional_styles' );
173
+			do_action('sensei_additional_styles');
174 174
 
175 175
 		} // End If Statement
176 176
 
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 	 * @param string $name (default: '')
187 187
 	 * @return void
188 188
 	 */
189
-	function sensei_get_template_part( $slug, $name = '' ) {
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
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	 * @param string $default_path (default: '')
205 205
 	 * @return void
206 206
 	 */
207
-	function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
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
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 * @param string $default_path (default: '')
222 222
 	 * @return void
223 223
 	 */
224
-	function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) {
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
 
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 	function sensei_output_content_wrapper() {
239 239
 
240 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',
241
+        $backwards_compatible_wrapper_location = array(
242
+            Sensei()->template_url.'wrappers/wrapper-start.php',
243 243
             'wrappers/wrapper-start.php'
244 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' );
249
+            Sensei_Templates::get_template('wrappers/wrapper-start.php');
250 250
             return;
251 251
 
252 252
         }
253 253
 
254
-		Sensei_Templates::get_template( 'globals/wrapper-start.php' );
254
+		Sensei_Templates::get_template('globals/wrapper-start.php');
255 255
 
256 256
 	} // End sensei_output_content_wrapper()
257 257
 
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	function sensei_output_content_wrapper_end() {
266 266
 
267 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',
268
+        $backwards_compatible_wrapper_location = array(
269
+            Sensei()->template_url.'wrappers/wrapper-end.php',
270 270
             'wrappers/wrapper-end.php'
271 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' );
276
+            Sensei_Templates::get_template('wrappers/wrapper-end.php');
277 277
             return;
278 278
 
279 279
         }
280 280
 
281 281
 
282
-		Sensei_Templates::get_template( 'globals/wrapper-end.php' );
282
+		Sensei_Templates::get_template('globals/wrapper-end.php');
283 283
 
284 284
 	} // End sensei_output_content_wrapper_end()
285 285
 
@@ -292,57 +292,57 @@  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 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 ) ){
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' );
301
+                Sensei_Templates::get_template('wrappers/pagination-posts.php');
302 302
                 return;
303 303
 
304 304
             }
305 305
 
306
-			Sensei_Templates::get_template( 'globals/pagination-posts.php' );
306
+			Sensei_Templates::get_template('globals/pagination-posts.php');
307 307
 
308
-		} elseif( is_singular('lesson') ) {
308
+		} elseif (is_singular('lesson')) {
309 309
 
310 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 ) ){
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' );
314
+                Sensei_Templates::get_template('wrappers/pagination-lesson.php');
315 315
                 return;
316 316
 
317 317
             }
318 318
 
319
-			Sensei_Templates::get_template( 'globals/pagination-lesson.php' );
319
+			Sensei_Templates::get_template('globals/pagination-lesson.php');
320 320
 
321
-		} elseif( is_singular('quiz') ) {
321
+		} elseif (is_singular('quiz')) {
322 322
 
323 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 ) ){
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' );
327
+                Sensei_Templates::get_template('wrappers/pagination-quiz.php');
328 328
                 return;
329 329
 
330 330
             }
331 331
 
332
-			Sensei_Templates::get_template( 'globals/pagination-quiz.php' );
332
+			Sensei_Templates::get_template('globals/pagination-quiz.php');
333 333
 
334 334
 		} else {
335 335
 
336 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 ) ){
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' );
340
+                Sensei_Templates::get_template('wrappers/pagination.php');
341 341
                 return;
342 342
 
343 343
             }
344 344
 
345
-			Sensei_Templates::get_template( 'globals/pagination.php' );
345
+			Sensei_Templates::get_template('globals/pagination.php');
346 346
 
347 347
 		} // End If Statement
348 348
 
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 	 * @param object $item
369 369
 	 * @return object $item
370 370
 	 */
371
-	public function sensei_setup_nav_menu_item( $item ) {
371
+	public function sensei_setup_nav_menu_item($item) {
372 372
 		global $pagenow, $wp_rewrite;
373 373
 
374
-		if( 'nav-menus.php' != $pagenow && !defined('DOING_AJAX') && isset( $item->url ) && 'custom' == $item->type ) {
374
+		if ('nav-menus.php' != $pagenow && ! defined('DOING_AJAX') && isset($item->url) && 'custom' == $item->type) {
375 375
 
376 376
 			// Set up Sensei menu links
377
-			$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
378
-			$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
377
+			$course_page_id = intval(Sensei()->settings->settings['course_page']);
378
+			$my_account_page_id = intval(Sensei()->settings->settings['my_course_page']);
379 379
 
380 380
 			$course_page_url = Sensei_Course::get_courses_page_url();
381
-			$lesson_archive_url = get_post_type_archive_link( 'lesson' );
382
-			$my_courses_url = get_permalink( $my_account_page_id );
383
-			$my_messages_url = get_post_type_archive_link( 'sensei_message' );
381
+			$lesson_archive_url = get_post_type_archive_link('lesson');
382
+			$my_courses_url = get_permalink($my_account_page_id);
383
+			$my_messages_url = get_post_type_archive_link('sensei_message');
384 384
 
385
-			switch ( $item->url ) {
385
+			switch ($item->url) {
386 386
 				case '#senseicourses':
387 387
 					$item->url = $course_page_url;
388 388
 					break;
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 					$item->url = $my_messages_url;
400 400
                     // if no archive link exist for sensei_message
401 401
                     // set it back to the place holder
402
-                    if( ! $item->url ){
402
+                    if ( ! $item->url) {
403 403
 
404 404
                         $item->url = '#senseimymessages';
405 405
 
@@ -407,21 +407,21 @@  discard block
 block discarded – undo
407 407
 					break;
408 408
 
409 409
 				case '#senseilearnerprofile':
410
-					$item->url = esc_url( Sensei()->learner_profiles->get_permalink() );
410
+					$item->url = esc_url(Sensei()->learner_profiles->get_permalink());
411 411
 					break;
412 412
 
413 413
 				case '#senseiloginlogout':
414
-						$logout_url = wp_logout_url( home_url() );
414
+						$logout_url = wp_logout_url(home_url());
415 415
 						// Login link links to the My Courses page, to avoid the WP dashboard.
416 416
 						$login_url = $my_courses_url;
417 417
 
418
-						$item->url = ( is_user_logged_in() ? $logout_url : $login_url );
418
+						$item->url = (is_user_logged_in() ? $logout_url : $login_url);
419 419
 
420 420
 						// determine the menu title login or logout
421
-						if ( is_user_logged_in() ) {
422
-							$menu_title =  __( 'Logout'  ,'woothemes-sensei');
421
+						if (is_user_logged_in()) {
422
+							$menu_title = __('Logout', 'woothemes-sensei');
423 423
 						} else {
424
-							$menu_title =  __( 'Login'  ,'woothemes-sensei');
424
+							$menu_title = __('Login', 'woothemes-sensei');
425 425
 						}
426 426
 
427 427
 						/**
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 						 *
432 432
 						 * @param $menu_title
433 433
 						 */
434
-						$item->title = apply_filters( 'sensei_login_logout_menu_title', $menu_title );
434
+						$item->title = apply_filters('sensei_login_logout_menu_title', $menu_title);
435 435
 
436 436
 					break;
437 437
 
@@ -439,12 +439,12 @@  discard block
 block discarded – undo
439 439
 					break;
440 440
 			}
441 441
 
442
-			$_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] );
443
-			$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current );
444
-			$item_url = untrailingslashit( $item->url );
445
-			$_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) );
442
+			$_root_relative_current = untrailingslashit($_SERVER['REQUEST_URI']);
443
+			$current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_root_relative_current);
444
+			$item_url = untrailingslashit($item->url);
445
+			$_indexless_current = untrailingslashit(preg_replace('/'.preg_quote($wp_rewrite->index, '/').'$/', '', $current_url));
446 446
 			// Highlight current menu item
447
-			if ( $item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) {
447
+			if ($item_url && in_array($item_url, array($current_url, $_indexless_current, $_root_relative_current))) {
448 448
 				$item->classes[] = 'current-menu-item current_page_item';
449 449
 			}
450 450
 
@@ -463,26 +463,26 @@  discard block
 block discarded – undo
463 463
 	 * @param object $sorted_menu_items
464 464
 	 * @return object $sorted_menu_items
465 465
 	 */
466
-	public function sensei_wp_nav_menu_objects( $sorted_menu_items ) {
466
+	public function sensei_wp_nav_menu_objects($sorted_menu_items) {
467 467
 
468
-		foreach( $sorted_menu_items as $k=>$item ) {
468
+		foreach ($sorted_menu_items as $k=>$item) {
469 469
 
470 470
 			// Remove the My Messages link for logged out users or if Private Messages are disabled
471
-			if( ! get_post_type_archive_link( 'sensei_message' )
472
-                && '#senseimymessages' == $item->url ) {
471
+			if ( ! get_post_type_archive_link('sensei_message')
472
+                && '#senseimymessages' == $item->url) {
473 473
 
474
-				if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) {
474
+				if ( ! is_user_logged_in() || (isset(Sensei()->settings->settings['messages_disable']) && Sensei()->settings->settings['messages_disable'])) {
475 475
 
476
-					unset( $sorted_menu_items[$k] );
476
+					unset($sorted_menu_items[$k]);
477 477
 
478 478
 				}
479 479
 			}
480 480
 			// Remove the My Profile link for logged out users.
481
-			if( Sensei()->learner_profiles->get_permalink() == $item->url ) {
481
+			if (Sensei()->learner_profiles->get_permalink() == $item->url) {
482 482
 
483
-				if ( !is_user_logged_in() || ! ( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) ) {
483
+				if ( ! is_user_logged_in() || ! (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable'])) {
484 484
 
485
-					unset( $sorted_menu_items[$k] );
485
+					unset($sorted_menu_items[$k]);
486 486
 
487 487
 				}
488 488
 			}
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 	function sensei_search_results_classes($classes) {
495 495
 	    global $post;
496 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 ) ) ) {
497
+	    if (isset($post->post_type) && (('course' == $post->post_type) || ('lesson' == $post->post_type) || ('product' == $post->post_type))) {
498 498
 	    	$classes[] = 'post';
499 499
 		} // End If Statement
500 500
 	    return $classes;
@@ -522,16 +522,16 @@  discard block
 block discarded – undo
522 522
      * @param bool|false $return
523 523
      * @return string|void
524 524
 	 */
525
-	function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) {
525
+	function sensei_course_image($course_id, $width = '100', $height = '100', $return = false) {
526 526
 
527
-    	if ( ! $return ) {
527
+    	if ( ! $return) {
528 528
 
529
-			echo Sensei()->course->course_image( $course_id, $width, $height );
529
+			echo Sensei()->course->course_image($course_id, $width, $height);
530 530
             return '';
531 531
 
532 532
 		} // End If Statement
533 533
 
534
-		return Sensei()->course->course_image( $course_id, $width, $height );
534
+		return Sensei()->course->course_image($course_id, $width, $height);
535 535
 
536 536
 	} // End sensei_course_image()
537 537
 
@@ -546,15 +546,15 @@  discard block
 block discarded – undo
546 546
      * @param bool|false $widget
547 547
      * @return string
548 548
 	 */
549
-	function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) {
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 );
553
+            echo Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget);
554 554
             return '';
555 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
 
@@ -562,20 +562,20 @@  discard block
 block discarded – undo
562 562
      * @since 1.0.0
563 563
      * @param WP_Query $query
564 564
      */
565
-    function sensei_course_archive_pagination( $query ) {
565
+    function sensei_course_archive_pagination($query) {
566 566
 
567
-		if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) {
567
+		if ( ! is_admin() && $query->is_main_query() && isset($_GET['action']) && in_array($_GET['action'], array('newcourses', 'featuredcourses', 'freecourses', 'paidcourses'))) {
568 568
 
569 569
 			$amount = 0;
570
-			if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
571
-				$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
570
+			if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
571
+				$amount = absint(Sensei()->settings->settings['course_archive_amount']);
572 572
 			}
573 573
 
574
-			if( $amount ) {
575
-				$query->set( 'posts_per_page', $amount );
574
+			if ($amount) {
575
+				$query->set('posts_per_page', $amount);
576 576
 			}
577 577
 
578
-			$query->set( 'orderby', 'menu_order date' );
578
+			$query->set('orderby', 'menu_order date');
579 579
 
580 580
 		}
581 581
 	}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	function sensei_course_archive_header(  ) {
592 592
 
593 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>' );
594
+        WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>');
595 595
 
596 596
 	} // sensei_course_archive_header()
597 597
 
@@ -604,15 +604,15 @@  discard block
 block discarded – undo
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' );
607
+        _deprecated_function('WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header');
608 608
         Sensei()->lesson->the_archive_header();
609 609
 	} // sensei_course_archive_header()
610 610
 
611 611
     /**
612 612
      * @deprecated since 1.9.0
613 613
      */
614
-	public function sensei_message_archive_header( ){
615
-        _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense');
614
+	public function sensei_message_archive_header( ) {
615
+        _deprecated_function('Sensei_Frontend::sensei_message_archive_header', 'Please use: Sense');
616 616
         Sensei_Messages::the_archive_header();
617 617
 	} // sensei_message_archive_header()
618 618
 
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
      * @param WP_Post $post_item
623 623
 	 * @return void
624 624
 	 */
625
-	function sensei_course_archive_course_title( $post_item ) {
626
-		if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) {
627
-			$post_id = absint( $post_item->ID );
625
+	function sensei_course_archive_course_title($post_item) {
626
+		if (isset($post_item->ID) && (0 < $post_item->ID)) {
627
+			$post_id = absint($post_item->ID);
628 628
     		$post_title = $post_item->post_title;
629 629
 		} else {
630 630
 			$post_id = get_the_ID();
631 631
     		$post_title = get_the_title();
632 632
 		} // End If Statement
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
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()
635 635
 
636 636
 	/**
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 	public function sensei_lesson_archive_lesson_title() {
642 642
 		$post_id = get_the_ID();
643 643
     	$post_title = get_the_title();
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
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
 
647 647
 	/**
@@ -650,40 +650,40 @@  discard block
 block discarded – undo
650 650
 	 * @param  integer $id course, lesson or quiz id
651 651
 	 * @return void
652 652
 	 */
653
-	public function sensei_breadcrumb( $id = 0 ) {
653
+	public function sensei_breadcrumb($id = 0) {
654 654
 
655 655
 		// Only output on lesson, quiz and taxonomy (module) pages
656
-		if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return;
656
+		if ( ! (is_tax('module') || is_singular('lesson') || is_singular('quiz'))) return;
657 657
 
658
-		if( empty( $id )  ){
658
+		if (empty($id)) {
659 659
 
660 660
             $id = get_the_ID();
661 661
 
662 662
         }
663 663
 
664
-		$sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' );
665
-		$separator = apply_filters( 'sensei_breadcrumb_separator', '&gt;' );
664
+		$sensei_breadcrumb_prefix = __('Back to: ', 'woothemes-sensei');
665
+		$separator = apply_filters('sensei_breadcrumb_separator', '&gt;');
666 666
 
667
-		$html = '<section class="sensei-breadcrumb">' . $sensei_breadcrumb_prefix;
667
+		$html = '<section class="sensei-breadcrumb">'.$sensei_breadcrumb_prefix;
668 668
 		// Lesson
669
-		if ( is_singular( 'lesson' ) && 0 < intval( $id ) ) {
670
-			$course_id = intval( get_post_meta( $id, '_lesson_course', true ) );
671
-			if( ! $course_id ) {
669
+		if (is_singular('lesson') && 0 < intval($id)) {
670
+			$course_id = intval(get_post_meta($id, '_lesson_course', true));
671
+			if ( ! $course_id) {
672 672
 				return;
673 673
 			}
674
-			$html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>';
674
+			$html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>';
675 675
     	} // End If Statement
676 676
     	// Quiz
677
-		if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) {
678
-			$lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) );
679
-			if( ! $lesson_id ) {
677
+		if (is_singular('quiz') && 0 < intval($id)) {
678
+			$lesson_id = intval(get_post_meta($id, '_quiz_lesson', true));
679
+			if ( ! $lesson_id) {
680 680
 				return;
681 681
 			}
682
-			 $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' .  __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>';
682
+			 $html .= '<a href="'.esc_url(get_permalink($lesson_id)).'" title="'.__('Back to the lesson', 'woothemes-sensei').'">'.get_the_title($lesson_id).'</a>';
683 683
     	} // End If Statement
684 684
 
685 685
     	// Allow other plugins to filter html
686
-    	$html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator );
686
+    	$html = apply_filters('sensei_breadcrumb_output', $html, $separator);
687 687
     	$html .= '</section>';
688 688
 
689 689
     	echo $html;
@@ -695,25 +695,25 @@  discard block
 block discarded – undo
695 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' );
698
+        _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link');
699 699
         WooThemes_Sensei_Lesson::course_signup_link();
700 700
 	}
701 701
 
702
-	public function lesson_tags_display( $lesson_id = 0 ) {
703
-		if( $lesson_id ) {
704
-			$tags = wp_get_post_terms( $lesson_id, 'lesson-tag' );
705
-			if( $tags && count( $tags ) > 0 ) {
702
+	public function lesson_tags_display($lesson_id = 0) {
703
+		if ($lesson_id) {
704
+			$tags = wp_get_post_terms($lesson_id, 'lesson-tag');
705
+			if ($tags && count($tags) > 0) {
706 706
 				$tag_list = '';
707
-				foreach( $tags as $tag ) {
708
-					$tag_link = get_term_link( $tag, 'lesson-tag' );
709
-					if( ! is_wp_error( $tag_link ) ) {
710
-						if( $tag_list ) { $tag_list .= ', '; }
711
-						$tag_list .= '<a href="' . $tag_link . '">' . $tag->name . '</a>';
707
+				foreach ($tags as $tag) {
708
+					$tag_link = get_term_link($tag, 'lesson-tag');
709
+					if ( ! is_wp_error($tag_link)) {
710
+						if ($tag_list) { $tag_list .= ', '; }
711
+						$tag_list .= '<a href="'.$tag_link.'">'.$tag->name.'</a>';
712 712
 					}
713 713
 				}
714
-				if( $tag_list ) {
714
+				if ($tag_list) {
715 715
 					?><section class="lesson-tags">
716
-		    			<?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?>
716
+		    			<?php printf(__('Lesson tags: %1$s', 'woothemes-sensei'), $tag_list); ?>
717 717
 		    		</section><?php
718 718
 		    	}
719 719
 	    	}
@@ -723,51 +723,51 @@  discard block
 block discarded – undo
723 723
     /**
724 724
      * @param WP_Query $query
725 725
      */
726
-	public function lesson_tag_archive_filter( $query ) {
727
-    	if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) {
726
+	public function lesson_tag_archive_filter($query) {
727
+    	if (is_tax('lesson-tag') && $query->is_main_query()) {
728 728
     		// Limit to lessons only
729
-    		$query->set( 'post_type', 'lesson' );
729
+    		$query->set('post_type', 'lesson');
730 730
 
731 731
     		// Set order of lessons
732
-    		$query->set( 'orderby', 'menu_order' );
733
-    		$query->set( 'order', 'ASC' );
732
+    		$query->set('orderby', 'menu_order');
733
+    		$query->set('order', 'ASC');
734 734
 
735 735
     	}
736 736
     }
737 737
 
738
-    public function lesson_tag_archive_header( $title ) {
739
-		if( is_tax( 'lesson-tag' ) ) {
740
-			$title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) );
738
+    public function lesson_tag_archive_header($title) {
739
+		if (is_tax('lesson-tag')) {
740
+			$title = sprintf(__('Lesson tag: %1$s', 'woothemes-sensei'), apply_filters('sensei_lesson_tag_archive_title', get_queried_object()->name));
741 741
 		}
742 742
 		return $title;
743 743
 	}
744 744
 
745 745
 	public function lesson_tag_archive_description() {
746
-		if( is_tax( 'lesson-tag' ) ) {
746
+		if (is_tax('lesson-tag')) {
747 747
 			$tag = get_queried_object();
748
-			echo '<p class="archive-description lesson-description">' . apply_filters( 'sensei_lesson_tag_archive_description', nl2br( $tag->description ), $tag->term_id ) . '</p>';
748
+			echo '<p class="archive-description lesson-description">'.apply_filters('sensei_lesson_tag_archive_description', nl2br($tag->description), $tag->term_id).'</p>';
749 749
 		}
750 750
 	}
751 751
 
752 752
 	public function sensei_complete_lesson() {
753
-		global $post,  $current_user;
753
+		global $post, $current_user;
754 754
 		// Handle Quiz Completion
755
-		if ( isset( $_POST['quiz_action'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_lesson_noonce' ], 'woothemes_sensei_complete_lesson_noonce' ) ) {
755
+		if (isset($_POST['quiz_action']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) {
756 756
 
757
-			$sanitized_submit = esc_html( $_POST['quiz_action'] );
757
+			$sanitized_submit = esc_html($_POST['quiz_action']);
758 758
 
759 759
 			switch ($sanitized_submit) {
760 760
                 case 'lesson-complete':
761 761
 
762
-					Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true );
762
+					Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true);
763 763
 
764 764
 					break;
765 765
 
766 766
                 case 'lesson-reset':
767 767
 
768
-					Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID );
768
+					Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID);
769 769
 
770
-					$this->messages = '<div class="sensei-message note">' .  __( 'Lesson Reset Successfully.', 'woothemes-sensei' ) . '</div>';
770
+					$this->messages = '<div class="sensei-message note">'.__('Lesson Reset Successfully.', 'woothemes-sensei').'</div>';
771 771
 					break;
772 772
 
773 773
 				default:
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	} // End sensei_complete_lesson()
782 782
 
783 783
 	public function sensei_complete_course() {
784
-		global $post,  $current_user, $wp_query;
785
-		if ( isset( $_POST['course_complete'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_course_noonce' ], 'woothemes_sensei_complete_course_noonce' ) ) {
784
+		global $post, $current_user, $wp_query;
785
+		if (isset($_POST['course_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_course_noonce'], 'woothemes_sensei_complete_course_noonce')) {
786 786
 
787
-			$sanitized_submit = esc_html( $_POST['course_complete'] );
788
-			$sanitized_course_id = absint( esc_html( $_POST['course_complete_id'] ) );
787
+			$sanitized_submit = esc_html($_POST['course_complete']);
788
+			$sanitized_course_id = absint(esc_html($_POST['course_complete_id']));
789 789
 			// Handle submit data
790 790
 			switch ($sanitized_submit) {
791
-				case __( 'Mark as Complete', 'woothemes-sensei' ):
791
+				case __('Mark as Complete', 'woothemes-sensei'):
792 792
 
793 793
 					// Add user to course
794 794
 					$course_metadata = array(
@@ -796,15 +796,15 @@  discard block
 block discarded – undo
796 796
 						'percent' => 0, // No completed lessons yet
797 797
 						'complete' => 0,
798 798
 					);
799
-					$activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata );
799
+					$activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata);
800 800
 
801
-					if ( $activity_logged ) {
801
+					if ($activity_logged) {
802 802
 						// Get all course lessons
803
-						$course_lesson_ids = Sensei()->course->course_lessons( $sanitized_course_id, 'any', 'ids' );
803
+						$course_lesson_ids = Sensei()->course->course_lessons($sanitized_course_id, 'any', 'ids');
804 804
 						// Mark all quiz user meta lessons as complete
805
-						foreach ( $course_lesson_ids as $lesson_item_id ){
805
+						foreach ($course_lesson_ids as $lesson_item_id) {
806 806
 							// Mark lesson as complete
807
-							$activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_item_id, $current_user->ID, $complete = true );
807
+							$activity_logged = Sensei_Utils::sensei_start_lesson($lesson_item_id, $current_user->ID, $complete = true);
808 808
 						} // End For Loop
809 809
 
810 810
 						// Update with final stats
@@ -812,22 +812,22 @@  discard block
 block discarded – undo
812 812
 							'percent' => 100,
813 813
 							'complete' => count($course_lesson_ids),
814 814
 						);
815
-						$activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'complete', $course_metadata );
815
+						$activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'complete', $course_metadata);
816 816
 
817
-						do_action( 'sensei_user_course_end', $current_user->ID, $sanitized_course_id );
817
+						do_action('sensei_user_course_end', $current_user->ID, $sanitized_course_id);
818 818
 
819 819
 						// Success message
820
-						$this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s marked as complete.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>';
820
+						$this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s marked as complete.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>';
821 821
 					} // End If Statement
822 822
 
823 823
 					break;
824 824
 
825
-				case __( 'Delete Course', 'woothemes-sensei' ):
825
+				case __('Delete Course', 'woothemes-sensei'):
826 826
 
827
-					Sensei_Utils::sensei_remove_user_from_course( $sanitized_course_id, $current_user->ID );
827
+					Sensei_Utils::sensei_remove_user_from_course($sanitized_course_id, $current_user->ID);
828 828
 
829 829
 					// Success message
830
-					$this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s deleted.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>';
830
+					$this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s deleted.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>';
831 831
 					break;
832 832
 
833 833
 				default:
@@ -843,25 +843,25 @@  discard block
 block discarded – undo
843 843
 	 * @param int $lesson_id
844 844
 	 * @return array
845 845
 	 */
846
-	public function sensei_get_user_quiz_answers( $lesson_id = 0 ) {
846
+	public function sensei_get_user_quiz_answers($lesson_id = 0) {
847 847
 		global $current_user;
848 848
 
849 849
 		$user_answers = array();
850 850
 
851
-		if ( 0 < intval( $lesson_id ) ) {
852
-			$lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $lesson_id );
853
-			foreach( $lesson_quiz_questions as $question ) {
854
-				$answer = maybe_unserialize( base64_decode( Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content' ) ) ) );
855
-				$user_answers[ $question->ID ] = $answer;
851
+		if (0 < intval($lesson_id)) {
852
+			$lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($lesson_id);
853
+			foreach ($lesson_quiz_questions as $question) {
854
+				$answer = maybe_unserialize(base64_decode(Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content'))));
855
+				$user_answers[$question->ID] = $answer;
856 856
 			}
857 857
 		}
858 858
 
859 859
 		return $user_answers;
860 860
 	} // End sensei_get_user_quiz_answers()
861 861
 
862
-	public function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) {
863
-		_deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" );
864
-		return Sensei_Utils::user_completed_lesson( $post_id, $user_id );
862
+	public function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) {
863
+		_deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()");
864
+		return Sensei_Utils::user_completed_lesson($post_id, $user_id);
865 865
 	} // End sensei_has_user_completed_lesson()
866 866
 
867 867
 /**
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
 		Sensei()->notices->print_notices();
872 872
 	} // End sensei_frontend_messages()
873 873
 
874
-	public function sensei_lesson_video( $post_id = 0 ) {
875
-		if ( 0 < intval( $post_id ) ) {
876
-			$lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true );
877
-			if ( 'http' == substr( $lesson_video_embed, 0, 4) ) {
874
+	public function sensei_lesson_video($post_id = 0) {
875
+		if (0 < intval($post_id)) {
876
+			$lesson_video_embed = get_post_meta($post_id, '_lesson_video_embed', true);
877
+			if ('http' == substr($lesson_video_embed, 0, 4)) {
878 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)*/ );
879
+        		$lesson_video_embed = wp_oembed_get(esc_url($lesson_video_embed)/*, array( 'width' => 100 , 'height' => 100)*/);
880 880
         	} // End If Statement
881
-        	if ( '' != $lesson_video_embed ) {
881
+        	if ('' != $lesson_video_embed) {
882 882
         	?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php
883 883
         	} // End If Statement
884 884
         } // End If Statement
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
 		$quiz_id = 0;
891 891
 
892 892
 		// Lesson quizzes
893
-		$quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID );
893
+		$quiz_id = Sensei()->lesson->lesson_quizzes($post->ID);
894 894
 		$pass_required = true;
895
-		if( $quiz_id ) {
895
+		if ($quiz_id) {
896 896
 			// Get quiz pass setting
897
-	    	$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
897
+	    	$pass_required = get_post_meta($quiz_id, '_pass_required', true);
898 898
 	    }
899
-		if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) {
899
+		if ( ! $quiz_id || ($quiz_id && ! $pass_required)) {
900 900
 			?>
901
-			<form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
901
+			<form class="lesson_button_form" method="POST" action="<?php echo esc_url(get_permalink()); ?>">
902 902
 	            <input type="hidden"
903 903
                        name="woothemes_sensei_complete_lesson_noonce"
904 904
                        id="woothemes_sensei_complete_lesson_noonce"
905
-                       value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>"
905
+                       value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>"
906 906
                 />
907 907
 
908 908
 	            <input type="hidden" name="quiz_action" value="lesson-complete" />
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                 <input type="submit"
911 911
                        name="quiz_complete"
912 912
                        class="quiz-submit complete"
913
-                       value="<?php _e( 'Complete Lesson', 'woothemes-sensei' ); ?>"/>
913
+                       value="<?php _e('Complete Lesson', 'woothemes-sensei'); ?>"/>
914 914
 
915 915
 	        </form>
916 916
 			<?php
@@ -923,25 +923,25 @@  discard block
 block discarded – undo
923 923
 		$quiz_id = 0;
924 924
 
925 925
 		// Lesson quizzes
926
-		$quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID );
926
+		$quiz_id = Sensei()->lesson->lesson_quizzes($post->ID);
927 927
 		$reset_allowed = true;
928
-		if( $quiz_id ) {
928
+		if ($quiz_id) {
929 929
 			// Get quiz pass setting
930
-			$reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true );
930
+			$reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true);
931 931
 		}
932
-		if ( ! $quiz_id || !empty($reset_allowed) ) {
932
+		if ( ! $quiz_id || ! empty($reset_allowed)) {
933 933
 		?>
934
-		<form method="POST" action="<?php echo esc_url( get_permalink() ); ?>">
934
+		<form method="POST" action="<?php echo esc_url(get_permalink()); ?>">
935 935
 
936 936
             <input
937 937
             type="hidden"
938
-            name="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>"
939
-            id="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>"
940
-            value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" />
938
+            name="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>"
939
+            id="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>"
940
+            value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" />
941 941
 
942 942
             <input type="hidden" name="quiz_action" value="lesson-reset" />
943 943
 
944
-            <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e( 'Reset Lesson', 'woothemes-sensei' ); ?>"/>
944
+            <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e('Reset Lesson', 'woothemes-sensei'); ?>"/>
945 945
 
946 946
         </form>
947 947
 		<?php
@@ -964,23 +964,23 @@  discard block
 block discarded – undo
964 964
 		$post_title = get_the_title();
965 965
 		$author_display_name = get_the_author();
966 966
 		$author_id = get_the_author_meta('ID');
967
-		$category_output = get_the_term_list( $post_id, 'course-category', '', ', ', '' );
968
-		$free_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $post_id ) );
967
+		$category_output = get_the_term_list($post_id, 'course-category', '', ', ', '');
968
+		$free_lesson_count = intval(Sensei()->course->course_lesson_preview_count($post_id));
969 969
 		?><section class="entry">
970 970
         	<p class="sensei-course-meta">
971
-           	<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
972
-		   	<span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span>
971
+           	<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
972
+		   	<span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span>
973 973
 		   	<?php } // End If Statement ?>
974
-		   	<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' . __( 'Lessons', 'woothemes-sensei' ); ?></span>
975
-		   	<?php if ( '' != $category_output ) { ?>
976
-		   	<span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
974
+		   	<span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
975
+		   	<?php if ('' != $category_output) { ?>
976
+		   	<span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
977 977
 		   	<?php } // End If Statement ?>
978
-		   	<?php sensei_simple_course_price( $post_id ); ?>
978
+		   	<?php sensei_simple_course_price($post_id); ?>
979 979
         	</p>
980 980
         	<p class="course-excerpt"><?php the_excerpt(); ?></p>
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 ); ?>
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>
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); ?>
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()
@@ -1003,33 +1003,33 @@  discard block
 block discarded – undo
1003 1003
     * @deprecated since 1.9.0
1004 1004
     */
1005 1005
 	public function sensei_message_archive_main_content() {
1006
-		_deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' );
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 1009
     /**
1010 1010
     * @deprecated since 1.9.0
1011 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() {
1017 1017
 		global $post;
1018
-		if ( have_posts() ) { ?>
1018
+		if (have_posts()) { ?>
1019 1019
 
1020 1020
 			<section id="main-course" class="course-container">
1021 1021
 
1022
-                <?php do_action( 'sensei_course_archive_header' ); ?>
1022
+                <?php do_action('sensei_course_archive_header'); ?>
1023 1023
 
1024
-                <?php while ( have_posts() ) { the_post(); ?>
1024
+                <?php while (have_posts()) { the_post(); ?>
1025 1025
 
1026
-                    <article class="<?php echo join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ); ?>">
1026
+                    <article class="<?php echo join(' ', get_post_class(array('course', 'post'), get_the_ID())); ?>">
1027 1027
 
1028
-	    			    <?php sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', get_the_ID() ); ?>
1028
+	    			    <?php sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', get_the_ID()); ?>
1029 1029
 
1030
-	    			    <?php sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before', $post ); ?>
1030
+	    			    <?php sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before', $post); ?>
1031 1031
 
1032
-	    			    <?php do_action( 'sensei_course_archive_meta' ); ?>
1032
+	    			    <?php do_action('sensei_course_archive_meta'); ?>
1033 1033
 
1034 1034
 	    		    </article>
1035 1035
 
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 
1042 1042
 			<p>
1043 1043
 
1044
-                <?php _e( 'No courses found that match your selection.', 'woothemes-sensei' ); ?>
1044
+                <?php _e('No courses found that match your selection.', 'woothemes-sensei'); ?>
1045 1045
 
1046 1046
             </p>
1047 1047
 
@@ -1058,12 +1058,12 @@  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
 
1065 1065
 			<?php
1066
-			if ( get_option('users_can_register') ) {
1066
+			if (get_option('users_can_register')) {
1067 1067
 
1068 1068
 				// get current url
1069 1069
 				$action_url = get_permalink();
@@ -1071,38 +1071,38 @@  discard block
 block discarded – undo
1071 1071
 				?>
1072 1072
 
1073 1073
 				<div class="col-2">
1074
-					<h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2>
1074
+					<h2><?php _e('Register', 'woothemes-sensei'); ?></h2>
1075 1075
 
1076
-					<form method="post" class="register"  action="<?php echo esc_url( $action_url ); ?>" >
1076
+					<form method="post" class="register"  action="<?php echo esc_url($action_url); ?>" >
1077 1077
 
1078
-						<?php do_action( 'sensei_register_form_start' ); ?>
1078
+						<?php do_action('sensei_register_form_start'); ?>
1079 1079
 
1080 1080
 						<p class="form-row form-row-wide">
1081
-							<label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1082
-							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" />
1081
+							<label for="sensei_reg_username"><?php _e('Username', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1082
+							<input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty($_POST['sensei_reg_username'])) esc_attr_e($_POST['sensei_reg_username']); ?>" />
1083 1083
 						</p>
1084 1084
 
1085 1085
 						<p class="form-row form-row-wide">
1086
-							<label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1087
-							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" />
1086
+							<label for="sensei_reg_email"><?php _e('Email address', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1087
+							<input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty($_POST['sensei_reg_email'])) esc_attr_e($_POST['sensei_reg_email']); ?>" />
1088 1088
 						</p>
1089 1089
 
1090 1090
 						<p class="form-row form-row-wide">
1091
-							<label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label>
1092
-							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" />
1091
+							<label for="sensei_reg_password"><?php _e('Password', 'woothemes-sensei'); ?> <span class="required">*</span></label>
1092
+							<input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty($_POST['sensei_reg_password'])) esc_attr_e($_POST['sensei_reg_password']); ?>" />
1093 1093
 						</p>
1094 1094
 
1095 1095
 						<!-- Spam Trap -->
1096
-						<div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woothemes-sensei' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
1096
+						<div style="left:-999em; position:absolute;"><label for="trap"><?php _e('Anti-spam', 'woothemes-sensei'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div>
1097 1097
 
1098
-						<?php do_action( 'sensei_register_form_fields' ); ?>
1099
-						<?php do_action( 'register_form' ); ?>
1098
+						<?php do_action('sensei_register_form_fields'); ?>
1099
+						<?php do_action('register_form'); ?>
1100 1100
 
1101 1101
 						<p class="form-row">
1102
-							<input type="submit" class="button" name="register" value="<?php _e( 'Register', 'woothemes-sensei' ); ?>" />
1102
+							<input type="submit" class="button" name="register" value="<?php _e('Register', 'woothemes-sensei'); ?>" />
1103 1103
 						</p>
1104 1104
 
1105
-						<?php do_action( 'sensei_register_form_end' ); ?>
1105
+						<?php do_action('sensei_register_form_end'); ?>
1106 1106
 
1107 1107
 					</form>
1108 1108
 				</div>
@@ -1115,17 +1115,17 @@  discard block
 block discarded – undo
1115 1115
 		<?php
1116 1116
 	} // End sensei_login_form()
1117 1117
 
1118
-	public function sensei_lesson_meta( $post_id = 0 ) {
1118
+	public function sensei_lesson_meta($post_id = 0) {
1119 1119
 		global $post;
1120
-		if ( 0 < intval( $post_id ) ) {
1121
-		$lesson_course_id = absint( get_post_meta( $post_id, '_lesson_course', true ) );
1120
+		if (0 < intval($post_id)) {
1121
+		$lesson_course_id = absint(get_post_meta($post_id, '_lesson_course', true));
1122 1122
 		?><section class="entry">
1123 1123
             <p class="sensei-course-meta">
1124
-			    <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?>
1125
-			    <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span>
1124
+			    <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?>
1125
+			    <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span>
1126 1126
 			    <?php } ?>
1127
-                <?php if ( 0 < intval( $lesson_course_id ) ) { ?>
1128
-                <span class="lesson-course"><?php echo '&nbsp;' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . __( 'View course', 'woothemes-sensei' ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span>
1127
+                <?php if (0 < intval($lesson_course_id)) { ?>
1128
+                <span class="lesson-course"><?php echo '&nbsp;'.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.__('View course', 'woothemes-sensei').'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span>
1129 1129
                 <?php } ?>
1130 1130
             </p>
1131 1131
             <p class="lesson-excerpt"><?php the_excerpt( ); ?></p>
@@ -1133,36 +1133,36 @@  discard block
 block discarded – undo
1133 1133
 		} // End If Statement
1134 1134
 	} // sensei_lesson_meta()
1135 1135
 
1136
-	public function sensei_lesson_preview_title_text( $course_id ) {
1136
+	public function sensei_lesson_preview_title_text($course_id) {
1137 1137
 
1138
-		$preview_text = __( ' (Preview)', 'woothemes-sensei' );
1138
+		$preview_text = __(' (Preview)', 'woothemes-sensei');
1139 1139
 
1140 1140
 		//if this is a paid course
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' );
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 1145
     	    } // End If Statement
1146 1146
     	}
1147 1147
     	return $preview_text;
1148 1148
 	}
1149 1149
 
1150
-	public function sensei_lesson_preview_title( $title = '', $id = 0 ) {
1150
+	public function sensei_lesson_preview_title($title = '', $id = 0) {
1151 1151
 		global $post, $current_user;
1152 1152
 
1153 1153
 		// Limit to lessons and check if lesson ID matches filtered post ID
1154 1154
 		// @see https://github.com/woothemes/sensei/issues/574
1155
-		if( isset( $post->ID ) && $id == $post->ID && 'lesson' == get_post_type( $post ) ) {
1155
+		if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) {
1156 1156
 
1157 1157
 			// Limit to main query only
1158
-			if( is_main_query() ) {
1158
+			if (is_main_query()) {
1159 1159
 
1160 1160
 				// Get the course ID
1161
-				$course_id = get_post_meta( $post->ID, '_lesson_course', true );
1161
+				$course_id = get_post_meta($post->ID, '_lesson_course', true);
1162 1162
 
1163 1163
 				// Check if the user is taking the course
1164
-				if( is_singular( 'lesson' ) && Sensei_Utils::is_preview_lesson( $post->ID ) && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID ) && $post->ID == $id ) {
1165
-					$title .= ' ' . $this->sensei_lesson_preview_title_text( $course_id );
1164
+				if (is_singular('lesson') && Sensei_Utils::is_preview_lesson($post->ID) && ! Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) {
1165
+					$title .= ' '.$this->sensei_lesson_preview_title_text($course_id);
1166 1166
 				}
1167 1167
 			}
1168 1168
 		}
@@ -1173,23 +1173,23 @@  discard block
 block discarded – undo
1173 1173
 		global $post, $current_user;
1174 1174
 
1175 1175
 		// Check if the user is taking the course
1176
-		$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
1176
+		$is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID);
1177 1177
 		// Handle user starting the course
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 ) {
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) {
1181 1181
 
1182 1182
 			// Start the course
1183
-			$activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID );
1183
+			$activity_logged = Sensei_Utils::user_start_course($current_user->ID, $post->ID);
1184 1184
 			$this->data = new stdClass();
1185 1185
 			$this->data->is_user_taking_course = false;
1186
-			if ( $activity_logged ) {
1186
+			if ($activity_logged) {
1187 1187
 				$this->data->is_user_taking_course = true;
1188 1188
 
1189 1189
 				// Refresh page to avoid re-posting
1190 1190
 				?>
1191 1191
 
1192
-			    <script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script>
1192
+			    <script type="text/javascript"> window.location = '<?php echo get_permalink($post->ID); ?>'; </script>
1193 1193
 
1194 1194
 			    <?php
1195 1195
 			} // End If Statement
@@ -1200,15 +1200,15 @@  discard block
 block discarded – undo
1200 1200
      * @deprecated since 1.9.0
1201 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 1207
     /**
1208 1208
      * @deprecated since 1.9.0
1209 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()' );
1211
+        _deprecated_function('Sensei_Frontend::sensei_course_meta_video', '1.9.0', 'Sensei_Course::the_course_video()');
1212 1212
         Sensei_Course::the_course_video();
1213 1213
 	} // End sensei_course_meta_video()
1214 1214
 
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
     public function sensei_woocommerce_in_cart_message() {
1224 1224
 		global $post, $woocommerce;
1225 1225
 
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() );
1228
-		if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) {
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());
1228
+		if (0 < intval($wc_post_id) && ! $user_course_status_id) {
1229 1229
 
1230
-			if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) {
1231
-				echo '<div class="sensei-message info">' . sprintf(  __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' );
1230
+			if (Sensei_WC::is_product_in_cart($wc_post_id)) {
1231
+				echo '<div class="sensei-message info">'.sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei').'</div>', '<a class="cart-complete" href="'.$woocommerce->cart->get_checkout_url().'" title="'.__('complete the purchase', 'woothemes-sensei').'">'.__('complete the purchase', 'woothemes-sensei').'</a>');
1232 1232
 			} // End If Statement
1233 1233
 
1234 1234
 		} // End If Statement
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 	} // End sensei_woocommerce_in_cart_message()
1237 1237
 
1238 1238
 	// Deprecated
1239
-	public function sensei_lesson_comment_count( $count ) {
1239
+	public function sensei_lesson_comment_count($count) {
1240 1240
 		return $count;
1241 1241
 	} // End sensei_lesson_comment_count()
1242 1242
 
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $content Original content
1246 1246
 	 * @return string          Modified content
1247 1247
 	 */
1248
-	public function sensei_search_results_excerpt( $content ) {
1248
+	public function sensei_search_results_excerpt($content) {
1249 1249
 		global $post;
1250 1250
 
1251
-		if( is_search() && in_array( $post->post_type, array( 'course', 'lesson' ) ) ) {
1252
-			$content = '<p class="course-excerpt">' . the_excerpt( ) . '</p>';
1251
+		if (is_search() && in_array($post->post_type, array('course', 'lesson'))) {
1252
+			$content = '<p class="course-excerpt">'.the_excerpt( ).'</p>';
1253 1253
 		}
1254 1254
 
1255 1255
 		return $content;
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
 	 * @param  integer $order_id ID of order
1261 1261
 	 * @return void
1262 1262
 	 */
1263
-	public function remove_active_course( $order_id ) {
1264
-		$order = new WC_Order( $order_id );
1263
+	public function remove_active_course($order_id) {
1264
+		$order = new WC_Order($order_id);
1265 1265
 
1266
-		foreach ( $order->get_items() as $item ) {
1267
-			if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) {
1266
+		foreach ($order->get_items() as $item) {
1267
+			if (isset($item['variation_id']) && (0 < $item['variation_id'])) {
1268 1268
 				// If item has variation_id then its a variation of the product
1269 1269
 				$item_id = $item['variation_id'];
1270 1270
 			} else {
@@ -1272,11 +1272,11 @@  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
-				$user_id = get_post_meta( $order_id, '_customer_user', true );
1277
+				$user_id = get_post_meta($order_id, '_customer_user', true);
1278 1278
 
1279
-				if( $user_id ) {
1279
+				if ($user_id) {
1280 1280
 
1281 1281
 					// Get all courses for product
1282 1282
 					$args = array(
@@ -1292,13 +1292,13 @@  discard block
 block discarded – undo
1292 1292
 						'order' => 'ASC',
1293 1293
 						'fields' => 'ids',
1294 1294
 					);
1295
-					$course_ids = get_posts( $args );
1295
+					$course_ids = get_posts($args);
1296 1296
 
1297
-					if( $course_ids && count( $course_ids ) > 0 ) {
1298
-						foreach( $course_ids as $course_id ) {
1297
+					if ($course_ids && count($course_ids) > 0) {
1298
+						foreach ($course_ids as $course_id) {
1299 1299
 
1300 1300
 							// Remove all course user meta
1301
-							Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id );
1301
+							Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id);
1302 1302
 
1303 1303
 						} // End For Loop
1304 1304
 					} // End If Statement
@@ -1314,16 +1314,16 @@  discard block
 block discarded – undo
1314 1314
 	 * @param  integer $user_id User ID
1315 1315
 	 * @return void
1316 1316
 	 */
1317
-	public function activate_purchased_courses( $user_id = 0 ) {
1317
+	public function activate_purchased_courses($user_id = 0) {
1318 1318
 
1319
-		if( $user_id ) {
1319
+		if ($user_id) {
1320 1320
 
1321
-			if( Sensei_WC::is_woocommerce_active() ) {
1321
+			if (Sensei_WC::is_woocommerce_active()) {
1322 1322
 
1323 1323
 				// Get all user's orders
1324 1324
 				$order_args = array(
1325 1325
 					'post_type' => 'shop_order',
1326
-					'post_status' =>  array( 'wc-processing', 'wc-completed' ),
1326
+					'post_status' =>  array('wc-processing', 'wc-completed'),
1327 1327
 					'posts_per_page' => -1,
1328 1328
 					'meta_query' => array(
1329 1329
 						array(
@@ -1333,25 +1333,25 @@  discard block
 block discarded – undo
1333 1333
 					),
1334 1334
 				);
1335 1335
 
1336
-				$orders = get_posts( $order_args );
1336
+				$orders = get_posts($order_args);
1337 1337
 
1338 1338
 				$product_ids = array();
1339 1339
 				$order_ids = array();
1340 1340
 
1341
-				foreach( $orders as $post_id ) {
1341
+				foreach ($orders as $post_id) {
1342 1342
 
1343 1343
 					// Only process each order once
1344
-					$processed = get_post_meta( $post_id, 'sensei_products_processed', true );
1344
+					$processed = get_post_meta($post_id, 'sensei_products_processed', true);
1345 1345
 
1346
-					if( $processed && $processed == 'processed' ) {
1346
+					if ($processed && $processed == 'processed') {
1347 1347
 						continue;
1348 1348
 					}
1349 1349
 
1350 1350
 					// Get course product IDs from order
1351
-					$order = new WC_Order( $post_id );
1351
+					$order = new WC_Order($post_id);
1352 1352
 
1353 1353
 					$items = $order->get_items();
1354
-					foreach( $items as $item ) {
1354
+					foreach ($items as $item) {
1355 1355
                                             if (isset($item['variation_id']) && $item['variation_id'] > 0) {
1356 1356
                                                 $item_id = $item['variation_id'];
1357 1357
                                                 $product_type = 'variation';
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 					$order_ids[] = $post_id;
1366 1366
 				}
1367 1367
 
1368
-				if( count( $product_ids ) > 0 ) {
1368
+				if (count($product_ids) > 0) {
1369 1369
 
1370 1370
 					// Get all courses from user's orders
1371 1371
 					$course_args = array(
@@ -1382,31 +1382,31 @@  discard block
 block discarded – undo
1382 1382
 						'order' => 'ASC',
1383 1383
 						'fields' => 'ids',
1384 1384
 					);
1385
-					$course_ids = get_posts( $course_args );
1385
+					$course_ids = get_posts($course_args);
1386 1386
 
1387
-					foreach( $course_ids as $course_id ) {
1387
+					foreach ($course_ids as $course_id) {
1388 1388
 
1389
-						$user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id );
1389
+						$user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id);
1390 1390
 
1391 1391
 						// Ignore course if already completed
1392
-						if( Sensei_Utils::user_completed_course( $user_course_status ) ) {
1392
+						if (Sensei_Utils::user_completed_course($user_course_status)) {
1393 1393
 							continue;
1394 1394
 						}
1395 1395
 
1396 1396
 						// Ignore course if already started
1397
-						if( $user_course_status ) {
1397
+						if ($user_course_status) {
1398 1398
 							continue;
1399 1399
 						}
1400 1400
 
1401 1401
 						// Mark course as started by user
1402
-						Sensei_Utils::user_start_course( $user_id, $course_id );
1402
+						Sensei_Utils::user_start_course($user_id, $course_id);
1403 1403
 					}
1404 1404
 				}
1405 1405
 
1406
-				if( count( $order_ids ) > 0 ) {
1407
-					foreach( $order_ids as $order_id ) {
1406
+				if (count($order_ids) > 0) {
1407
+					foreach ($order_ids as $order_id) {
1408 1408
 						// Mark order as processed
1409
-						update_post_meta( $order_id, 'sensei_products_processed', 'processed' );
1409
+						update_post_meta($order_id, 'sensei_products_processed', 'processed');
1410 1410
 					}
1411 1411
 				}
1412 1412
 			}
@@ -1420,28 +1420,28 @@  discard block
 block discarded – undo
1420 1420
 	public function activate_purchased_single_course() {
1421 1421
 		global $post, $current_user;
1422 1422
 
1423
-		if( Sensei_WC::is_woocommerce_active() ) {
1423
+		if (Sensei_WC::is_woocommerce_active()) {
1424 1424
 
1425
-			if( ! is_user_logged_in() ) return;
1426
-			if( ! isset( $post->ID ) ) return;
1425
+			if ( ! is_user_logged_in()) return;
1426
+			if ( ! isset($post->ID)) return;
1427 1427
 
1428 1428
 			$user_id = $current_user->ID;
1429 1429
 			$course_id = $post->ID;
1430
-			$course_product_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
1431
-			if( ! $course_product_id ) {
1430
+			$course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
1431
+			if ( ! $course_product_id) {
1432 1432
 				return;
1433 1433
 			}
1434 1434
 
1435
-			$user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id );
1435
+			$user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id);
1436 1436
 
1437 1437
 			// Ignore course if already completed
1438
-			if( Sensei_Utils::user_completed_course( $user_course_status ) ) {
1438
+			if (Sensei_Utils::user_completed_course($user_course_status)) {
1439 1439
 
1440 1440
 				return;
1441 1441
 			}
1442 1442
 
1443 1443
 			// Ignore course if already started
1444
-			if( $user_course_status ) {
1444
+			if ($user_course_status) {
1445 1445
 				return;
1446 1446
 			}
1447 1447
 
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 			$order_args = array(
1450 1450
 				'post_type' => 'shop_order',
1451 1451
 				'posts_per_page' => -1,
1452
-				'post_status' => array( 'wc-processing', 'wc-completed' ),
1452
+				'post_status' => array('wc-processing', 'wc-completed'),
1453 1453
 				'meta_query' => array(
1454 1454
 					array(
1455 1455
 						'key' => '_customer_user',
@@ -1458,28 +1458,28 @@  discard block
 block discarded – undo
1458 1458
 				),
1459 1459
 				'fields' => 'ids',
1460 1460
 			);
1461
-			$orders = get_posts( $order_args );
1461
+			$orders = get_posts($order_args);
1462 1462
 
1463
-			foreach( $orders as $order_post_id ) {
1463
+			foreach ($orders as $order_post_id) {
1464 1464
 
1465 1465
 				// Get course product IDs from order
1466
-				$order = new WC_Order( $order_post_id );
1466
+				$order = new WC_Order($order_post_id);
1467 1467
 
1468 1468
 				$items = $order->get_items();
1469
-				foreach( $items as $item ) {
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 1473
                     // handle product bundles
1474
-                    if( is_object( $product ) &&  $product->is_type('bundle') ){
1474
+                    if (is_object($product) && $product->is_type('bundle')) {
1475 1475
 
1476
-                        $bundled_product = new WC_Product_Bundle( $product->id );
1476
+                        $bundled_product = new WC_Product_Bundle($product->id);
1477 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 );
1481
+                            if ($bundled_item->product_id == $course_product_id) {
1482
+                                Sensei_Utils::user_start_course($user_id, $course_id);
1483 1483
                                 return;
1484 1484
                             }
1485 1485
 
@@ -1488,8 +1488,8 @@  discard block
 block discarded – undo
1488 1488
                     } else {
1489 1489
 
1490 1490
                     // handle regular products
1491
-                        if( $item['product_id'] == $course_product_id ) {
1492
-                            Sensei_Utils::user_start_course( $user_id, $course_id );
1491
+                        if ($item['product_id'] == $course_product_id) {
1492
+                            Sensei_Utils::user_start_course($user_id, $course_id);
1493 1493
                             return;
1494 1494
                         }
1495 1495
 
@@ -1505,9 +1505,9 @@  discard block
 block discarded – undo
1505 1505
 	 * @param  array  $args Default arguments
1506 1506
 	 * @return array        Modified arguments
1507 1507
 	 */
1508
-	public function hide_sensei_activity( $args = array() ) {
1508
+	public function hide_sensei_activity($args = array()) {
1509 1509
 
1510
-		if( is_singular( 'lesson' ) || is_singular( 'course' ) ) {
1510
+		if (is_singular('lesson') || is_singular('course')) {
1511 1511
 			$args['type'] = 'comment';
1512 1512
 		}
1513 1513
 
@@ -1524,9 +1524,9 @@  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
 
@@ -1534,9 +1534,9 @@  discard block
 block discarded – undo
1534 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')){
1537
+	    if ( ! empty($referrer) && ! strstr($referrer, 'wp-login') && ! strstr($referrer, 'wp-admin')) {
1538 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) ) );
1539
+	        wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1540 1540
 	    	exit;
1541 1541
     	}
1542 1542
 	}// End sensei_login_fail_redirect_to_front_end_login
@@ -1549,10 +1549,10 @@  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 1554
 	    	// Validate the login request nonce
1555
-		    if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){
1555
+		    if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'sensei-login')) {
1556 1556
 		    	return;
1557 1557
 		    }
1558 1558
 
@@ -1560,48 +1560,48 @@  discard block
 block discarded – undo
1560 1560
 		    $referrer = $_REQUEST['_wp_http_referer'];
1561 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 1566
 		    	// when the user has entered a password or username do the sensei login
1567 1567
 		    	$creds = array();
1568 1568
 
1569 1569
 		    	// check if the requests login is an email address
1570
-		    	if( is_email(  trim( $_REQUEST['log'] ) )  ){
1570
+		    	if (is_email(trim($_REQUEST['log']))) {
1571 1571
 		    		// query wordpress for the users details
1572
-		    		$user =	get_user_by( 'email', sanitize_email( $_REQUEST['log'] )  );
1572
+		    		$user = get_user_by('email', sanitize_email($_REQUEST['log']));
1573 1573
 
1574 1574
 		    		// validate the user object
1575
-		    		if( !$user ){
1575
+		    		if ( ! $user) {
1576 1576
 
1577 1577
 		    			// the email doesnt exist
1578
-                        wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1578
+                        wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1579 1579
 		        		exit;
1580 1580
 
1581 1581
 		    		}
1582 1582
 
1583 1583
 		    		//assigne the username to the creds array for further processing
1584
-		    		$creds['user_login'] =  $user->user_login ;
1584
+		    		$creds['user_login'] = $user->user_login;
1585 1585
 
1586
-		    	}else{
1586
+		    	} else {
1587 1587
 
1588 1588
 		    		// process this as a default username login
1589
-		    		$creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ;
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
-				$creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] );
1595
-				$creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ;
1594
+				$creds['user_password'] = sanitize_text_field($_REQUEST['pwd']);
1595
+				$creds['remember'] = isset($_REQUEST['rememberme']) ? true : false;
1596 1596
 
1597 1597
 				//attempt logging in with the given details
1598 1598
 			    $secure_cookie = is_ssl() ? true : false;
1599
-			    $user = wp_signon( $creds, $secure_cookie );
1599
+			    $user = wp_signon($creds, $secure_cookie);
1600 1600
 
1601
-				if ( is_wp_error($user) ){ // on login failure
1602
-                    wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) );
1601
+				if (is_wp_error($user)) { // on login failure
1602
+                    wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer)));
1603 1603
                     exit;
1604
-				}else{ // on login success
1604
+				} else { // on login success
1605 1605
 
1606 1606
 					/**
1607 1607
 					* change the redirect url programatically
@@ -1611,21 +1611,21 @@  discard block
 block discarded – undo
1611 1611
 					* @param string $referrer the page where the current url wheresensei login form was posted from
1612 1612
 					*/
1613 1613
 
1614
-					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) );
1614
+					$success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg('login', $referrer));
1615 1615
 
1616
-					wp_redirect( esc_url_raw( $success_redirect_url ) );
1616
+					wp_redirect(esc_url_raw($success_redirect_url));
1617 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) ) );
1623
+                wp_redirect(esc_url_raw(add_query_arg('login', 'emptyfields', $referrer)));
1624 1624
 		        exit;
1625 1625
 
1626 1626
 		    } // end if username $_REQUEST['log']  and password $_REQUEST['pwd'] is empty
1627 1627
 
1628
-	    }elseif( ( isset( $_GET['login'] ) ) ) {
1628
+	    }elseif ((isset($_GET['login']))) {
1629 1629
 	    	// else if this request is a redircect from a previously faile login request
1630 1630
 	    	$this->login_message_process();
1631 1631
 
@@ -1644,87 +1644,87 @@  discard block
 block discarded – undo
1644 1644
 	 * @return void redirect
1645 1645
 	 *
1646 1646
 	 */
1647
-	public function sensei_process_registration(){
1647
+	public function sensei_process_registration() {
1648 1648
 		global 	 $current_user;
1649 1649
 		// check the for the sensei specific registration requests
1650
-		if( !isset( $_POST['sensei_reg_username'] ) && ! isset( $_POST['sensei_reg_email'] ) && !isset( $_POST['sensei_reg_password'] )){
1650
+		if ( ! isset($_POST['sensei_reg_username']) && ! isset($_POST['sensei_reg_email']) && ! isset($_POST['sensei_reg_password'])) {
1651 1651
 			// exit if this is not a sensei registration request
1652
-			return ;
1652
+			return;
1653 1653
 		}
1654 1654
 		// check for spam throw cheating huh
1655
-		if( isset( $_POST['email_2'] ) &&  '' !== $_POST['email_2']   ){
1655
+		if (isset($_POST['email_2']) && '' !== $_POST['email_2']) {
1656 1656
 			$message = 'Error:  The spam field should be empty';
1657
-			Sensei()->notices->add_notice( $message, 'alert');
1657
+			Sensei()->notices->add_notice($message, 'alert');
1658 1658
 			return;
1659 1659
 		}
1660 1660
 
1661 1661
 		// retreive form variables
1662
-		$new_user_name		= sanitize_user( $_POST['sensei_reg_username'] );
1663
-		$new_user_email		= $_POST['sensei_reg_email'];
1664
-		$new_user_password	= $_POST['sensei_reg_password'];
1662
+		$new_user_name = sanitize_user($_POST['sensei_reg_username']);
1663
+		$new_user_email = $_POST['sensei_reg_email'];
1664
+		$new_user_password = $_POST['sensei_reg_password'];
1665 1665
 
1666 1666
 		// Check the username
1667 1667
 		$username_error_notice = '';
1668
-		if ( $new_user_name == '' ) {
1669
-			$username_error_notice =  __( '<strong>ERROR</strong>: Please enter a username.' );
1670
-		} elseif ( ! validate_username( $new_user_name ) ) {
1671
-			$username_error_notice =  __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' );
1672
-		} elseif ( username_exists( $new_user_name ) ) {
1673
-			$username_error_notice =  __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' );
1668
+		if ($new_user_name == '') {
1669
+			$username_error_notice = __('<strong>ERROR</strong>: Please enter a username.');
1670
+		} elseif ( ! validate_username($new_user_name)) {
1671
+			$username_error_notice = __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.');
1672
+		} elseif (username_exists($new_user_name)) {
1673
+			$username_error_notice = __('<strong>ERROR</strong>: This username is already registered. Please choose another one.');
1674 1674
 		}
1675 1675
 
1676 1676
 		// exit on username error
1677
-		if( '' !== $username_error_notice ){
1678
-			Sensei()->notices->add_notice( $username_error_notice , 'alert');
1677
+		if ('' !== $username_error_notice) {
1678
+			Sensei()->notices->add_notice($username_error_notice, 'alert');
1679 1679
 			return;
1680 1680
 		}
1681 1681
 
1682 1682
 		// Check the e-mail address
1683 1683
 		$email_error_notice = '';
1684
-		if ( $new_user_email == '' ) {
1685
-			$email_error_notice = __( '<strong>ERROR</strong>: Please type your e-mail address.' );
1686
-		} elseif ( ! is_email( $new_user_email ) ) {
1687
-			$email_error_notice = __( '<strong>ERROR</strong>: The email address isn&#8217;t correct.' );
1688
-		} elseif ( email_exists( $new_user_email ) ) {
1689
-			$email_error_notice = __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' );
1684
+		if ($new_user_email == '') {
1685
+			$email_error_notice = __('<strong>ERROR</strong>: Please type your e-mail address.');
1686
+		} elseif ( ! is_email($new_user_email)) {
1687
+			$email_error_notice = __('<strong>ERROR</strong>: The email address isn&#8217;t correct.');
1688
+		} elseif (email_exists($new_user_email)) {
1689
+			$email_error_notice = __('<strong>ERROR</strong>: This email is already registered, please choose another one.');
1690 1690
 		}
1691 1691
 
1692 1692
 		// exit on email address error
1693
-		if( '' !== $email_error_notice ){
1694
-			Sensei()->notices->add_notice( $email_error_notice , 'alert');
1693
+		if ('' !== $email_error_notice) {
1694
+			Sensei()->notices->add_notice($email_error_notice, 'alert');
1695 1695
 			return;
1696 1696
 		}
1697 1697
 
1698 1698
 		//check user password
1699 1699
 
1700 1700
 		// exit on email address error
1701
-		if( empty( $new_user_password ) ){
1702
-			Sensei()->notices->add_notice(  __( '<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.' )  , 'alert');
1701
+		if (empty($new_user_password)) {
1702
+			Sensei()->notices->add_notice(__('<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.'), 'alert');
1703 1703
 			return;
1704 1704
 		}
1705 1705
 
1706 1706
 		// register user
1707
-		$user_id = wp_create_user( $new_user_name, $new_user_password, $new_user_email );
1708
-		if ( ! $user_id || is_wp_error( $user_id ) ) {
1709
-			Sensei()->notices->add_notice( sprintf( __( '<strong>ERROR</strong>: Couldn\'t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ), 'alert');
1707
+		$user_id = wp_create_user($new_user_name, $new_user_password, $new_user_email);
1708
+		if ( ! $user_id || is_wp_error($user_id)) {
1709
+			Sensei()->notices->add_notice(sprintf(__('<strong>ERROR</strong>: Couldn\'t register you&hellip; please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')), 'alert');
1710 1710
 		}
1711 1711
 
1712 1712
 		// notify the user
1713
-		wp_new_user_notification( $user_id, $new_user_password );
1713
+		wp_new_user_notification($user_id, $new_user_password);
1714 1714
 
1715 1715
 		// set global current user aka log the user in
1716
-		$current_user = get_user_by( 'id', $user_id );
1717
-		wp_set_auth_cookie( $user_id, true );
1716
+		$current_user = get_user_by('id', $user_id);
1717
+		wp_set_auth_cookie($user_id, true);
1718 1718
 
1719 1719
 		// Redirect
1720 1720
 		global $wp;
1721
-		if ( wp_get_referer() ) {
1722
-			$redirect = esc_url( wp_get_referer() );
1721
+		if (wp_get_referer()) {
1722
+			$redirect = esc_url(wp_get_referer());
1723 1723
 		} else {
1724
-			$redirect = esc_url( home_url( $wp->request ) );
1724
+			$redirect = esc_url(home_url($wp->request));
1725 1725
 		}
1726 1726
 
1727
-		wp_redirect( apply_filters( 'sensei_registration_redirect', $redirect ) );
1727
+		wp_redirect(apply_filters('sensei_registration_redirect', $redirect));
1728 1728
 		exit;
1729 1729
 
1730 1730
 	} // end  sensei_process_registration)()
@@ -1735,23 +1735,23 @@  discard block
 block discarded – undo
1735 1735
 	 * @return void redirect
1736 1736
 	 * @since 1.7.0
1737 1737
 	 */
1738
-	public function login_message_process(){
1738
+	public function login_message_process() {
1739 1739
 
1740 1740
             // setup the message variables
1741 1741
 			$message = '';
1742 1742
 
1743 1743
 			//only output message if the url contains login=failed and login=emptyfields
1744 1744
 
1745
-			if( $_GET['login'] == 'failed' ){
1745
+			if ($_GET['login'] == 'failed') {
1746 1746
 
1747
-				$message = __('Incorrect login details', 'woothemes-sensei' );
1747
+				$message = __('Incorrect login details', 'woothemes-sensei');
1748 1748
 
1749
-			}elseif( $_GET['login'] == 'emptyfields'  ){
1749
+			}elseif ($_GET['login'] == 'emptyfields') {
1750 1750
 
1751
-				$message= __('Please enter your username and password', 'woothemes-sensei' );
1751
+				$message = __('Please enter your username and password', 'woothemes-sensei');
1752 1752
 			}
1753 1753
 
1754
-			Sensei()->notices->add_notice( $message, 'alert');
1754
+			Sensei()->notices->add_notice($message, 'alert');
1755 1755
 
1756 1756
 	}// end login_message_process
1757 1757
 
@@ -1763,11 +1763,11 @@  discard block
 block discarded – undo
1763 1763
      * @return void redirect
1764 1764
      *
1765 1765
      */
1766
-    public function sensei_show_admin_bar () {
1766
+    public function sensei_show_admin_bar() {
1767 1767
 
1768 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
 
@@ -1780,4 +1780,4 @@  discard block
 block discarded – undo
1780 1780
  * @ignore only for backward compatibility
1781 1781
  * @since 1.9.0
1782 1782
  */
1783
-class WooThemes_Sensei_Frontend extends Sensei_Frontend{}
1783
+class WooThemes_Sensei_Frontend extends Sensei_Frontend {}
Please login to merge, or discard this patch.
includes/class-sensei-grading.php 1 patch
Spacing   +280 added lines, -280 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Grading Class
@@ -23,30 +23,30 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param $file
25 25
 	 */
26
-	public function __construct ( $file ) {
27
-		$this->name = __( 'Grading', 'woothemes-sensei' );
26
+	public function __construct($file) {
27
+		$this->name = __('Grading', 'woothemes-sensei');
28 28
 		$this->file = $file;
29 29
 		$this->page_slug = 'sensei_grading';
30 30
 
31 31
 		// Admin functions
32
-		if ( is_admin() ) {
33
-			add_action( 'admin_menu', array( $this, 'grading_admin_menu' ), 20);
34
-			add_action( 'grading_wrapper_container', array( $this, 'wrapper_container'  ) );
35
-			if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
36
-				add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) );
37
-				add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
32
+		if (is_admin()) {
33
+			add_action('admin_menu', array($this, 'grading_admin_menu'), 20);
34
+			add_action('grading_wrapper_container', array($this, 'wrapper_container'));
35
+			if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
36
+				add_action('admin_print_scripts', array($this, 'enqueue_scripts'));
37
+				add_action('admin_print_styles', array($this, 'enqueue_styles'));
38 38
 			}
39 39
 
40
-			add_action( 'admin_init', array( $this, 'admin_process_grading_submission' ) );
40
+			add_action('admin_init', array($this, 'admin_process_grading_submission'));
41 41
 
42
-			add_action( 'admin_notices', array( $this, 'add_grading_notices' ) );
42
+			add_action('admin_notices', array($this, 'add_grading_notices'));
43 43
 //			add_action( 'sensei_grading_notices', array( $this, 'sensei_grading_notices' ) );
44 44
 		} // End If Statement
45 45
 
46 46
 		// Ajax functions
47
-		if ( is_admin() ) {
48
-			add_action( 'wp_ajax_get_lessons_dropdown', array( $this, 'get_lessons_dropdown' ) );
49
-			add_action( 'wp_ajax_get_redirect_url', array( $this, 'get_redirect_url' ) );
47
+		if (is_admin()) {
48
+			add_action('wp_ajax_get_lessons_dropdown', array($this, 'get_lessons_dropdown'));
49
+			add_action('wp_ajax_get_redirect_url', array($this, 'get_redirect_url'));
50 50
 		} // End If Statement
51 51
 	} // End __construct()
52 52
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 	public function grading_admin_menu() {
60 60
 		global $menu;
61 61
 
62
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
63
-			$grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'),  __('Grading', 'woothemes-sensei') , 'manage_sensei_grades', $this->page_slug, array( $this, 'grading_page' ) );
62
+		if (current_user_can('manage_sensei_grades')) {
63
+			$grading_page = add_submenu_page('sensei', __('Grading', 'woothemes-sensei'), __('Grading', 'woothemes-sensei'), 'manage_sensei_grades', $this->page_slug, array($this, 'grading_page'));
64 64
 		}
65 65
 
66 66
 	} // End grading_admin_menu()
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 * @since 1.3.0
74 74
 	 * @return void
75 75
 	 */
76
-	public function enqueue_scripts () {
76
+	public function enqueue_scripts() {
77 77
 
78
-		$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
78
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
79 79
 
80 80
 		// Load Grading JS
81
-		wp_enqueue_script( 'sensei-grading-general', Sensei()->plugin_url . 'assets/js/grading-general' . $suffix . '.js', array( 'jquery' ), Sensei()->version );
81
+		wp_enqueue_script('sensei-grading-general', Sensei()->plugin_url.'assets/js/grading-general'.$suffix.'.js', array('jquery'), Sensei()->version);
82 82
 
83 83
 	} // End enqueue_scripts()
84 84
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 * @since 1.0.0
91 91
 	 * @return void
92 92
 	 */
93
-	public function enqueue_styles () {
93
+	public function enqueue_styles() {
94 94
 
95
-		wp_enqueue_style( Sensei()->token . '-admin' );
95
+		wp_enqueue_style(Sensei()->token.'-admin');
96 96
 
97
-		wp_enqueue_style( 'woothemes-sensei-settings-api', Sensei()->plugin_url . 'assets/css/settings.css', '', Sensei()->version );
97
+		wp_enqueue_style('woothemes-sensei-settings-api', Sensei()->plugin_url.'assets/css/settings.css', '', Sensei()->version);
98 98
 
99 99
 	} // End enqueue_styles()
100 100
 
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	public function load_data_table_files() {
107 107
 
108 108
 		// Load Grading Classes
109
-		$classes_to_load = array(	'list-table',
109
+		$classes_to_load = array('list-table',
110 110
 									'grading-main',
111 111
 									'grading-user-quiz'
112 112
 									);
113
-		foreach ( $classes_to_load as $class_file ) {
114
-			Sensei()->load_class( $class_file );
113
+		foreach ($classes_to_load as $class_file) {
114
+			Sensei()->load_class($class_file);
115 115
 		} // End For Loop
116 116
 	} // End load_data_table_files()
117 117
 
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 	 * @param  undefined  $optional_data optional constructor arguments
124 124
 	 * @return object                 class instance object
125 125
 	 */
126
-	public function load_data_object( $name = '', $data = 0, $optional_data = null ) {
126
+	public function load_data_object($name = '', $data = 0, $optional_data = null) {
127 127
 		// Load Analysis data
128
-		$object_name = 'WooThemes_Sensei_Grading_' . $name;
129
-		if ( is_null($optional_data) ) {
130
-			$sensei_grading_object = new $object_name( $data );
128
+		$object_name = 'WooThemes_Sensei_Grading_'.$name;
129
+		if (is_null($optional_data)) {
130
+			$sensei_grading_object = new $object_name($data);
131 131
 		}
132 132
 		else {
133
-			$sensei_grading_object = new $object_name( $data, $optional_data );
133
+			$sensei_grading_object = new $object_name($data, $optional_data);
134 134
 		} // End If Statement
135
-		if ( 'Main' == $name ) {
135
+		if ('Main' == $name) {
136 136
 			$sensei_grading_object->prepare_items();
137 137
 		} // End If Statement
138 138
 		return $sensei_grading_object;
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function grading_page() {
148 148
 
149
-		if ( isset( $_GET['quiz_id'] ) && 0 < intval( $_GET['quiz_id'] ) && isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) {
149
+		if (isset($_GET['quiz_id']) && 0 < intval($_GET['quiz_id']) && isset($_GET['user']) && 0 < intval($_GET['user'])) {
150 150
 			$this->grading_user_quiz_view();
151 151
 		}
152 152
 		else {
@@ -162,23 +162,23 @@  discard block
 block discarded – undo
162 162
 	public function grading_default_view() {
163 163
 
164 164
 		// Load Grading data
165
-		if( !empty( $_GET['course_id'] ) ) {
166
-			$course_id = intval( $_GET['course_id'] );
165
+		if ( ! empty($_GET['course_id'])) {
166
+			$course_id = intval($_GET['course_id']);
167 167
 		}
168
-		if( !empty( $_GET['lesson_id'] ) ) {
169
-			$lesson_id = intval( $_GET['lesson_id'] );
168
+		if ( ! empty($_GET['lesson_id'])) {
169
+			$lesson_id = intval($_GET['lesson_id']);
170 170
 		}
171
-		if( !empty( $_GET['user_id'] ) ) {
172
-			$user_id = intval( $_GET['user_id'] );
171
+		if ( ! empty($_GET['user_id'])) {
172
+			$user_id = intval($_GET['user_id']);
173 173
 		}
174
-		if( !empty( $_GET['view'] ) ) {
175
-			$view = esc_html( $_GET['view'] );
174
+		if ( ! empty($_GET['view'])) {
175
+			$view = esc_html($_GET['view']);
176 176
 		}
177
-		$sensei_grading_overview = $this->load_data_object( 'Main', compact( 'course_id', 'lesson_id', 'user_id', 'view' ) );
177
+		$sensei_grading_overview = $this->load_data_object('Main', compact('course_id', 'lesson_id', 'user_id', 'view'));
178 178
 
179 179
 		// Wrappers
180
-		do_action( 'grading_before_container' );
181
-		do_action( 'grading_wrapper_container', 'top' );
180
+		do_action('grading_before_container');
181
+		do_action('grading_wrapper_container', 'top');
182 182
 		$this->grading_headers();
183 183
 		?>
184 184
 		<div id="poststuff" class="sensei-grading-wrap">
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 				<?php $sensei_grading_overview->display(); ?>
187 187
 			</div>
188 188
 			<div class="sensei-grading-extra">
189
-				<?php do_action( 'sensei_grading_extra' ); ?>
189
+				<?php do_action('sensei_grading_extra'); ?>
190 190
 			</div>
191 191
 		</div>
192 192
 		<?php
193
-		do_action( 'grading_wrapper_container', 'bottom' );
194
-		do_action( 'grading_after_container' );
193
+		do_action('grading_wrapper_container', 'bottom');
194
+		do_action('grading_after_container');
195 195
 	} // End grading_default_view()
196 196
 
197 197
 	/**
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 		// Load Grading data
205 205
 		$user_id = 0;
206 206
 		$quiz_id = 0;
207
-		if( isset( $_GET['user'] ) ) {
208
-			$user_id = intval( $_GET['user'] );
207
+		if (isset($_GET['user'])) {
208
+			$user_id = intval($_GET['user']);
209 209
 		}
210
-		if( isset( $_GET['quiz_id'] ) ) {
211
-			$quiz_id = intval( $_GET['quiz_id'] );
210
+		if (isset($_GET['quiz_id'])) {
211
+			$quiz_id = intval($_GET['quiz_id']);
212 212
 		}
213
-		$sensei_grading_user_profile = $this->load_data_object( 'User_Quiz', $user_id, $quiz_id );
213
+		$sensei_grading_user_profile = $this->load_data_object('User_Quiz', $user_id, $quiz_id);
214 214
 		// Wrappers
215
-		do_action( 'grading_before_container' );
216
-		do_action( 'grading_wrapper_container', 'top' );
217
-		$this->grading_headers( array( 'nav' => 'user_quiz' ) );
215
+		do_action('grading_before_container');
216
+		do_action('grading_wrapper_container', 'top');
217
+		$this->grading_headers(array('nav' => 'user_quiz'));
218 218
 		?>
219 219
 		<div id="poststuff" class="sensei-grading-wrap user-profile">
220 220
 			<div class="sensei-grading-main">
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 			</div>
224 224
 		</div>
225 225
 		<?php
226
-		do_action( 'grading_wrapper_container', 'bottom' );
227
-		do_action( 'grading_after_container' );
226
+		do_action('grading_wrapper_container', 'bottom');
227
+		do_action('grading_after_container');
228 228
 	} // End grading_user_quiz_view()
229 229
 
230 230
 	/**
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
      * @param array $args
234 234
 	 * @return void
235 235
 	 */
236
-	public function grading_headers( $args = array( 'nav' => 'default' ) ) {
236
+	public function grading_headers($args = array('nav' => 'default')) {
237 237
 
238
-		$function = 'grading_' . $args['nav'] . '_nav';
238
+		$function = 'grading_'.$args['nav'].'_nav';
239 239
 		$this->$function();
240 240
 		?>
241
-			<p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
241
+			<p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p>
242 242
 		<?php
243
-		do_action( 'sensei_grading_after_headers' );
243
+		do_action('sensei_grading_after_headers');
244 244
 	} // End grading_headers()
245 245
 
246 246
 	/**
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 	 * @param $which string
250 250
 	 * @return void
251 251
 	 */
252
-	public function wrapper_container( $which ) {
253
-		if ( 'top' == $which ) {
252
+	public function wrapper_container($which) {
253
+		if ('top' == $which) {
254 254
 			?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php
255
-		} elseif ( 'bottom' == $which ) {
255
+		} elseif ('bottom' == $which) {
256 256
 			?></div><!--/#woothemes-sensei--><?php
257 257
 		} // End If Statement
258 258
 	} // End wrapper_container()
@@ -265,29 +265,29 @@  discard block
 block discarded – undo
265 265
 	public function grading_default_nav() {
266 266
 		global  $wp_version;
267 267
 
268
-		$title = sprintf( '<a href="%s">%s</a>', esc_url(add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ) ), esc_html( $this->name ) );
269
-		if ( isset( $_GET['course_id'] ) ) { 
270
-			$course_id = intval( $_GET['course_id'] );
271
-			if ( version_compare($wp_version, '4.1', '>=') ) {
272
-				$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
273
-				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) );
268
+		$title = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('page' => $this->page_slug), admin_url('admin.php'))), esc_html($this->name));
269
+		if (isset($_GET['course_id'])) { 
270
+			$course_id = intval($_GET['course_id']);
271
+			if (version_compare($wp_version, '4.1', '>=')) {
272
+				$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
273
+				$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id));
274 274
 			}
275 275
 			else {
276
-				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title( $course_id ) ); 
276
+				$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title($course_id)); 
277 277
 			}
278 278
 		}
279
-		if ( isset( $_GET['lesson_id'] ) ) { 
280
-			$lesson_id = intval( $_GET['lesson_id'] );
281
-			$title .= '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;' . get_the_title( intval( $lesson_id ) ) . '</span>'; 
279
+		if (isset($_GET['lesson_id'])) { 
280
+			$lesson_id = intval($_GET['lesson_id']);
281
+			$title .= '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;'.get_the_title(intval($lesson_id)).'</span>'; 
282 282
 		}
283
-		if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) {
283
+		if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) {
284 284
 
285
-            $user_name = Sensei_Learner::get_full_name( $_GET['user_id'] );
286
-			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
285
+            $user_name = Sensei_Learner::get_full_name($_GET['user_id']);
286
+			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;'.$user_name.'</span>';
287 287
 
288 288
 		} // End If Statement
289 289
 		?>
290
-			<h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2>
290
+			<h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2>
291 291
 		<?php
292 292
 	} // End grading_default_nav()
293 293
 
@@ -299,29 +299,29 @@  discard block
 block discarded – undo
299 299
 	public function grading_user_quiz_nav() {
300 300
 		global  $wp_version;
301 301
 
302
-		$title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) );
303
-		if ( isset( $_GET['quiz_id'] ) ) { 
304
-			$quiz_id = intval( $_GET['quiz_id'] );
305
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
306
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
307
-			if ( version_compare($wp_version, '4.1', '>=') ) {
308
-				$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
309
-				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) );
302
+		$title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name));
303
+		if (isset($_GET['quiz_id'])) { 
304
+			$quiz_id = intval($_GET['quiz_id']);
305
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
306
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
307
+			if (version_compare($wp_version, '4.1', '>=')) {
308
+				$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
309
+				$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id));
310 310
 			}
311 311
 			else {
312
-				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title( $course_id ) ); 
312
+				$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title($course_id)); 
313 313
 			}
314
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) );
315
-			$title .= sprintf( '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $lesson_id ) );
314
+			$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id), admin_url('admin.php'));
315
+			$title .= sprintf('&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url($url), get_the_title($lesson_id));
316 316
 		}
317
-		if ( isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) {
317
+		if (isset($_GET['user']) && 0 < intval($_GET['user'])) {
318 318
 
319
-            $user_name = Sensei_Learner::get_full_name( $_GET['user'] );
320
-			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
319
+            $user_name = Sensei_Learner::get_full_name($_GET['user']);
320
+			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;'.$user_name.'</span>';
321 321
 
322 322
 		} // End If Statement
323 323
 		?>
324
-			<h2><?php echo apply_filters( 'sensei_grading_nav_title', $title ); ?></h2>
324
+			<h2><?php echo apply_filters('sensei_grading_nav_title', $title); ?></h2>
325 325
 		<?php
326 326
 	} // End grading_user_quiz_nav()
327 327
 
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 	 * @since  1.7.0
331 331
 	 * @return array
332 332
 	 */
333
-	public function get_stati( $type ) {
333
+	public function get_stati($type) {
334 334
 		$statuses = array();
335
-		switch( $type ) {
335
+		switch ($type) {
336 336
 			case 'course' :
337 337
 				$statuses = array(
338 338
 					'in-progress',
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 	 * @param  array $args (default: array())
363 363
 	 * @return object
364 364
 	 */
365
-	public function count_statuses( $args = array() ) {
365
+	public function count_statuses($args = array()) {
366 366
 		global  $wpdb;
367 367
 
368 368
         /**
@@ -373,71 +373,71 @@  discard block
 block discarded – undo
373 373
          * @since 1.8.0
374 374
          * @param array $args
375 375
          */
376
-        $args = apply_filters( 'sensei_count_statuses_args', $args );
376
+        $args = apply_filters('sensei_count_statuses_args', $args);
377 377
 
378
-		if ( 'course' == $args['type'] ) {
378
+		if ('course' == $args['type']) {
379 379
 			$type = 'sensei_course_status';
380 380
 		}
381 381
 		else {
382 382
 			$type = 'sensei_lesson_status';
383 383
 		}
384
-		$cache_key = 'sensei-' . $args['type'] . '-statuses';
384
+		$cache_key = 'sensei-'.$args['type'].'-statuses';
385 385
 
386 386
 		$query = "SELECT comment_approved, COUNT( * ) AS total FROM {$wpdb->comments} WHERE comment_type = %s ";
387 387
 
388 388
         // Restrict to specific posts
389
-		if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) {
390
-			$query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')';
389
+		if (isset($args['post__in']) && ! empty($args['post__in']) && is_array($args['post__in'])) {
390
+			$query .= ' AND comment_post_ID IN ('.implode(',', array_map('absint', $args['post__in'])).')';
391 391
 		}
392
-		elseif ( !empty( $args['post_id'] ) ) {
393
-			$query .= $wpdb->prepare( ' AND comment_post_ID = %d', $args['post_id'] );
392
+		elseif ( ! empty($args['post_id'])) {
393
+			$query .= $wpdb->prepare(' AND comment_post_ID = %d', $args['post_id']);
394 394
 		}
395 395
 		// Restrict to specific users
396
-		if ( isset( $args['user_id'] ) && is_array( $args['user_id'] ) ) {
397
-			$query .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $args['user_id'] ) ) . ')';
396
+		if (isset($args['user_id']) && is_array($args['user_id'])) {
397
+			$query .= ' AND user_id IN ('.implode(',', array_map('absint', $args['user_id'])).')';
398 398
 		}
399
-		elseif ( !empty( $args['user_id'] ) ) {
400
-			$query .= $wpdb->prepare( ' AND user_id = %d', $args['user_id'] );
399
+		elseif ( ! empty($args['user_id'])) {
400
+			$query .= $wpdb->prepare(' AND user_id = %d', $args['user_id']);
401 401
 		}
402 402
 		$query .= ' GROUP BY comment_approved';
403 403
 
404
-		$counts = wp_cache_get( $cache_key, 'counts' );
405
-		if ( false === $counts ) {
406
-			$sql = $wpdb->prepare( $query, $type );
407
-			$results = (array) $wpdb->get_results( $sql, ARRAY_A );
408
-			$counts = array_fill_keys( $this->get_stati( $type ), 0 );
404
+		$counts = wp_cache_get($cache_key, 'counts');
405
+		if (false === $counts) {
406
+			$sql = $wpdb->prepare($query, $type);
407
+			$results = (array) $wpdb->get_results($sql, ARRAY_A);
408
+			$counts = array_fill_keys($this->get_stati($type), 0);
409 409
 
410
-			foreach ( $results as $row ) {
411
-				$counts[ $row['comment_approved'] ] = $row['total'];
410
+			foreach ($results as $row) {
411
+				$counts[$row['comment_approved']] = $row['total'];
412 412
 			}
413
-			wp_cache_set( $cache_key, $counts, 'counts' );
413
+			wp_cache_set($cache_key, $counts, 'counts');
414 414
 		}
415 415
 
416
-		if( ! isset( $counts['graded'] ) ) {
416
+		if ( ! isset($counts['graded'])) {
417 417
 			$counts['graded'] = 0;
418 418
 		}
419 419
 
420
-		if( ! isset( $counts['ungraded'] ) ) {
420
+		if ( ! isset($counts['ungraded'])) {
421 421
 			$counts['ungraded'] = 0;
422 422
 		}
423 423
 
424
-		if( ! isset( $counts['passed'] ) ) {
424
+		if ( ! isset($counts['passed'])) {
425 425
 			$counts['passed'] = 0;
426 426
 		}
427 427
 
428
-		if( ! isset( $counts['failed'] ) ) {
428
+		if ( ! isset($counts['failed'])) {
429 429
 			$counts['failed'] = 0;
430 430
 		}
431 431
 
432
-		if( ! isset( $counts['in-progress'] ) ) {
432
+		if ( ! isset($counts['in-progress'])) {
433 433
 			$counts['in-progress'] = 0;
434 434
 		}
435 435
 
436
-		if( ! isset( $counts['complete'] ) ) {
436
+		if ( ! isset($counts['complete'])) {
437 437
 			$counts['complete'] = 0;
438 438
 		}
439 439
 
440
-		return apply_filters( 'sensei_count_statuses', $counts, $type );
440
+		return apply_filters('sensei_count_statuses', $counts, $type);
441 441
 	} // End sensei_count_statuses()
442 442
 
443 443
 	/**
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
 	 * @since  1.7.0
446 446
 	 * @return string
447 447
 	 */
448
-	public function courses_drop_down_html( $selected_course_id = 0 ) {
448
+	public function courses_drop_down_html($selected_course_id = 0) {
449 449
 
450 450
 		$html = '';
451 451
 
452
-		$course_args = array(   'post_type'         => 'course',
452
+		$course_args = array('post_type'         => 'course',
453 453
 								'posts_per_page'       => -1,
454 454
 								'orderby'           => 'title',
455 455
 								'order'             => 'ASC',
@@ -457,12 +457,12 @@  discard block
 block discarded – undo
457 457
 								'suppress_filters'  => 0,
458 458
 								'fields'            => 'ids',
459 459
 							);
460
-		$courses = get_posts( apply_filters( 'sensei_grading_filter_courses', $course_args ) );
460
+		$courses = get_posts(apply_filters('sensei_grading_filter_courses', $course_args));
461 461
 
462
-		$html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>';
463
-		if ( count( $courses ) > 0 ) {
464
-			foreach ($courses as $course_id){
465
-				$html .= '<option value="' . esc_attr( absint( $course_id ) ) . '" ' . selected( $course_id, $selected_course_id, false ) . '>' . esc_html( get_the_title( $course_id ) ) . '</option>' . "\n";
462
+		$html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>';
463
+		if (count($courses) > 0) {
464
+			foreach ($courses as $course_id) {
465
+				$html .= '<option value="'.esc_attr(absint($course_id)).'" '.selected($course_id, $selected_course_id, false).'>'.esc_html(get_the_title($course_id)).'</option>'."\n";
466 466
 			} // End For Loop
467 467
 		} // End If Statement
468 468
 
@@ -483,20 +483,20 @@  discard block
 block discarded – undo
483 483
 		$course_data = array();
484 484
 		parse_str($data, $course_data);
485 485
 
486
-		$course_id = intval( $course_data['course_id'] );
486
+		$course_id = intval($course_data['course_id']);
487 487
 
488
-		$html = $this->lessons_drop_down_html( $course_id );
488
+		$html = $this->lessons_drop_down_html($course_id);
489 489
 
490 490
 		echo $html;
491 491
 		die(); // WordPress may print out a spurious zero without this can be particularly bad if using JSON
492 492
 	}
493 493
 
494
-	public function lessons_drop_down_html( $course_id = 0, $selected_lesson_id = 0 ) {
494
+	public function lessons_drop_down_html($course_id = 0, $selected_lesson_id = 0) {
495 495
 
496 496
 		$html = '';
497
-		if ( 0 < intval( $course_id ) ) {
497
+		if (0 < intval($course_id)) {
498 498
 
499
-			$lesson_args = array( 'post_type'       => 'lesson',
499
+			$lesson_args = array('post_type'       => 'lesson',
500 500
 								'posts_per_page'       => -1,
501 501
 								'orderby'           => 'title',
502 502
 								'order'             => 'ASC',
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
 								'suppress_filters'  => 0,
507 507
 								'fields'            => 'ids',
508 508
 								);
509
-			$lessons = get_posts( apply_filters( 'sensei_grading_filter_lessons', $lesson_args ) );
509
+			$lessons = get_posts(apply_filters('sensei_grading_filter_lessons', $lesson_args));
510 510
 
511
-			$html .= '<option value="">' . __( 'Select a lesson', 'woothemes-sensei' ) . '</option>';
512
-			if ( count( $lessons ) > 0 ) {
513
-				foreach ( $lessons as $lesson_id ){
514
-					$html .= '<option value="' . esc_attr( absint( $lesson_id ) ) . '" ' . selected( $lesson_id, $selected_lesson_id, false ) . '>' . esc_html( get_the_title( $lesson_id ) ) . '</option>' . "\n";
511
+			$html .= '<option value="">'.__('Select a lesson', 'woothemes-sensei').'</option>';
512
+			if (count($lessons) > 0) {
513
+				foreach ($lessons as $lesson_id) {
514
+					$html .= '<option value="'.esc_attr(absint($lesson_id)).'" '.selected($lesson_id, $selected_lesson_id, false).'>'.esc_html(get_the_title($lesson_id)).'</option>'."\n";
515 515
 				} // End For Loop
516 516
 			} // End If Statement
517 517
 
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
     public function admin_process_grading_submission() {
533 533
 
534 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'] ) {
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 540
             return false; //exit and do not grade
541 541
 
@@ -545,30 +545,30 @@  discard block
 block discarded – undo
545 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 );
548
+        $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
549
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
550 550
         $quiz_grade = 0;
551 551
         $count = 0;
552 552
         $quiz_grade_total = $_POST['quiz_grade_total'];
553 553
         $all_question_grades = array();
554 554
         $all_answers_feedback = array();
555 555
 
556
-        foreach( $questions as $question ) {
556
+        foreach ($questions as $question) {
557 557
 
558 558
             ++$count;
559 559
             $question_id = $question->ID;
560 560
 
561
-            if( isset( $_POST[ 'question_' . $question_id ] ) ) {
561
+            if (isset($_POST['question_'.$question_id])) {
562 562
 
563 563
                 $question_grade = 0;
564
-                if( $_POST[ 'question_' . $question_id ] == 'right' ) {
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 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;
571
+                $all_question_grades[$question_id] = $question_grade;
572 572
 
573 573
                 // tally up the total quiz grade
574 574
                 $quiz_grade += $question_grade;
@@ -577,41 +577,41 @@  discard block
 block discarded – undo
577 577
 
578 578
             // Question answer feedback / notes
579 579
             $question_feedback = '';
580
-            if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){
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 584
             }
585
-            $all_answers_feedback[ $question_id ] = $question_feedback;
585
+            $all_answers_feedback[$question_id] = $question_feedback;
586 586
 
587 587
         } // end for each $questions
588 588
 
589 589
         //store all question grades on the lesson status
590
-        Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id );
590
+        Sensei()->quiz->set_user_grades($all_question_grades, $quiz_lesson_id, $user_id);
591 591
 
592 592
         //store the feedback from grading
593
-        Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id );
593
+        Sensei()->quiz->save_user_answers_feedback($all_answers_feedback, $quiz_lesson_id, $user_id);
594 594
 
595 595
         // $_POST['all_questions_graded'] is set when all questions have been graded
596 596
         // in the class sensei grading user quiz -> display()
597
-        if( $_POST['all_questions_graded'] == 'yes' ) {
597
+        if ($_POST['all_questions_graded'] == 'yes') {
598 598
 
599 599
             // set the users total quiz grade
600
-			if ( 0 < intval( $quiz_grade_total ) ) {
601
-            $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
600
+			if (0 < intval($quiz_grade_total)) {
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 );
606
+            Sensei_Utils::sensei_grade_quiz($quiz_id, $grade, $user_id);
607 607
 
608 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 ) );
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 611
             $lesson_metadata = array();
612
-            if ( $pass_required ) {
612
+            if ($pass_required) {
613 613
                 // Student has reached the pass mark and lesson is complete
614
-                if ( $quiz_passmark <= $grade ) {
614
+                if ($quiz_passmark <= $grade) {
615 615
                     $lesson_status = 'passed';
616 616
                 }
617 617
                 else {
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
             }
625 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 631
                 /**
632 632
                  * Summary.
@@ -638,27 +638,27 @@  discard block
 block discarded – undo
638 638
                  * @param int  $user_id
639 639
                  * @param int $quiz_lesson_id
640 640
                  */
641
-                do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id );
641
+                do_action('sensei_user_lesson_end', $user_id, $quiz_lesson_id);
642 642
 
643 643
             } // end if in_array
644 644
 
645 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 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 ) );
661
+        wp_safe_redirect(esc_url_raw($load_url));
662 662
         exit;
663 663
 
664 664
     } // end admin_process_grading_submission
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
 		$lesson_data = array();
670 670
 		parse_str($data, $lesson_data);
671 671
 
672
-		$lesson_id = intval( $lesson_data['lesson_id'] );
673
-		$course_id = intval( $lesson_data['course_id'] );
674
-		$grading_view = sanitize_text_field( $lesson_data['view'] );
672
+		$lesson_id = intval($lesson_data['lesson_id']);
673
+		$course_id = intval($lesson_data['course_id']);
674
+		$grading_view = sanitize_text_field($lesson_data['view']);
675 675
 
676 676
 		$redirect_url = '';
677
-		if ( 0 < $lesson_id && 0 < $course_id ) {
678
-			$redirect_url = esc_url_raw( apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view ), admin_url( 'admin.php' ) ) ) );
677
+		if (0 < $lesson_id && 0 < $course_id) {
678
+			$redirect_url = esc_url_raw(apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id, 'course_id' => $course_id, 'view' => $grading_view), admin_url('admin.php'))));
679 679
 		} // End If Statement
680 680
 
681 681
 		echo $redirect_url;
@@ -683,11 +683,11 @@  discard block
 block discarded – undo
683 683
 	}
684 684
 
685 685
 	public function add_grading_notices() {
686
-		if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) {
687
-			if( 'graded' == $_GET['message'] ) {
686
+		if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) {
687
+			if ('graded' == $_GET['message']) {
688 688
 				$msg = array(
689 689
 					'updated',
690
-					__( 'Quiz Graded Successfully!', 'woothemes-sensei' ),
690
+					__('Quiz Graded Successfully!', 'woothemes-sensei'),
691 691
 				);
692 692
 			}
693 693
 			?>
@@ -699,9 +699,9 @@  discard block
 block discarded – undo
699 699
 	}
700 700
 
701 701
 	public function sensei_grading_notices() {
702
-		if ( isset( $_GET['action'] ) && 'graded' == $_GET['action'] ) {
702
+		if (isset($_GET['action']) && 'graded' == $_GET['action']) {
703 703
 			echo '<div class="grading-notice updated">';
704
-				echo '<p>' . __( 'Quiz Graded Successfully!', 'woothemes-sensei' ) . '</p>';
704
+				echo '<p>'.__('Quiz Graded Successfully!', 'woothemes-sensei').'</p>';
705 705
 			echo '</div>';
706 706
 		} // End If Statement
707 707
 	} // End sensei_grading_notices()
@@ -724,16 +724,16 @@  discard block
 block discarded – undo
724 724
      *
725 725
      * @return int $quiz_grade total sum of all question grades
726 726
      */
727
-    public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
727
+    public static function grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') {
728 728
 
729
-        if( ! ( intval( $quiz_id ) > 0 )  || ! $submitted
730
-            || $quiz_grade_type != 'auto' ) {
729
+        if ( ! (intval($quiz_id) > 0) || ! $submitted
730
+            || $quiz_grade_type != 'auto') {
731 731
             return false; // exit early
732 732
         }
733 733
 
734 734
 
735 735
         $user_id = get_current_user_id();
736
-        $lesson_id =  Sensei()->quiz->get_lesson_id(  $quiz_id ) ;
736
+        $lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
737 737
         $quiz_autogradable = true;
738 738
 
739 739
         /**
@@ -747,23 +747,23 @@  discard block
 block discarded – undo
747 747
          *      'gap-fill'.
748 748
          * }
749 749
          */
750
-        $autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) );
750
+        $autogradable_question_types = apply_filters('sensei_autogradable_question_types', array('multiple-choice', 'boolean', 'gap-fill'));
751 751
 
752 752
         $grade_total = 0;
753 753
         $all_question_grades = array();
754
-        foreach( $submitted as $question_id => $answer ) {
754
+        foreach ($submitted as $question_id => $answer) {
755 755
 
756 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
-			$achievable_grade = Sensei()->question->get_question_grade( $question_id );
757
+            $question_type = Sensei()->question->get_question_type($question_id);
758
+			$achievable_grade = Sensei()->question->get_question_grade($question_id);
759 759
 			// Question has a zero grade, so skip grading
760
-			if ( 0 == $achievable_grade ) {
761
-				$all_question_grades[ $question_id ] = $achievable_grade;
760
+			if (0 == $achievable_grade) {
761
+				$all_question_grades[$question_id] = $achievable_grade;
762 762
 			}
763
-            elseif ( in_array( $question_type, $autogradable_question_types ) ) {
763
+            elseif (in_array($question_type, $autogradable_question_types)) {
764 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;
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 767
                 $grade_total += $question_grade;
768 768
 
769 769
             } else {
@@ -776,27 +776,27 @@  discard block
 block discarded – undo
776 776
         }// end for each question
777 777
 
778 778
         // Only if the whole quiz was autogradable do we set a grade
779
-        if ( $quiz_autogradable ) {
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
-			if ( 0 < $quiz_total ) {
784
-            $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
783
+			if (0 < $quiz_total) {
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 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 795
         }
796 796
 
797 797
         // store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default
798 798
         // when doing manual grading.
799
-        Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id );
799
+        Sensei()->quiz-> set_user_grades($all_question_grades, $lesson_id, $user_id);
800 800
 
801 801
         return $grade;
802 802
 
@@ -816,22 +816,22 @@  discard block
 block discarded – undo
816 816
      *
817 817
      * @return int $question_grade
818 818
      */
819
-    public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
819
+    public static function grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) {
820 820
 
821
-        if( intval( $user_id ) == 0 ) {
821
+        if (intval($user_id) == 0) {
822 822
 
823 823
             $user_id = get_current_user_id();
824 824
 
825 825
         }
826 826
 
827
-        if( ! ( intval( $question_id ) > 0 ) ) {
827
+        if ( ! (intval($question_id) > 0)) {
828 828
 
829 829
             return false;
830 830
 
831 831
         }
832 832
 
833 833
 
834
-        Sensei()->question->get_question_type( $question_id );
834
+        Sensei()->question->get_question_type($question_id);
835 835
 
836 836
         /**
837 837
          * Applying a grade before the auto grading takes place.
@@ -845,42 +845,42 @@  discard block
 block discarded – undo
845 845
          * @param string $question_type one of the Sensei question type.
846 846
          * @param string $answer user supplied question answer
847 847
          */
848
-        $question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer );
848
+        $question_grade = apply_filters('sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer);
849 849
 
850
-        if ( false !== $question_grade ) {
850
+        if (false !== $question_grade) {
851 851
 
852 852
             return $question_grade;
853 853
 
854 854
         }
855 855
 
856 856
         // auto grading core
857
-        if( in_array( $question_type ,  array( 'multiple-choice'  , 'boolean'  ) )   ){
857
+        if (in_array($question_type, array('multiple-choice', 'boolean'))) {
858 858
 
859
-            $right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true );
859
+            $right_answer = (array) get_post_meta($question_id, '_question_right_answer', true);
860 860
 
861
-            if( 0 == get_magic_quotes_gpc() ) {
862
-                $answer = wp_unslash( $answer );
861
+            if (0 == get_magic_quotes_gpc()) {
862
+                $answer = wp_unslash($answer);
863 863
             }
864 864
             $answer = (array) $answer;
865
-            if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) {
865
+            if (is_array($right_answer) && count($right_answer) == count($answer)) {
866 866
                 // Loop through all answers ensure none are 'missing'
867 867
                 $all_correct = true;
868
-                foreach ( $answer as $check_answer ) {
869
-                    if ( !in_array( $check_answer, $right_answer ) ) {
868
+                foreach ($answer as $check_answer) {
869
+                    if ( ! in_array($check_answer, $right_answer)) {
870 870
                         $all_correct = false;
871 871
                     }
872 872
                 }
873 873
                 // If all correct then grade
874
-                if ( $all_correct ) {
875
-                    $question_grade = Sensei()->question->get_question_grade( $question_id );
874
+                if ($all_correct) {
875
+                    $question_grade = Sensei()->question->get_question_grade($question_id);
876 876
                 }
877 877
             }
878 878
 
879
-        } elseif( 'gap-fill' == $question_type ){
879
+        } elseif ('gap-fill' == $question_type) {
880 880
 
881
-            $question_grade = self::grade_gap_fill_question( $question_id ,$answer );
881
+            $question_grade = self::grade_gap_fill_question($question_id, $answer);
882 882
 
883
-        } else{
883
+        } else {
884 884
 
885 885
             /**
886 886
              * Grading questions that are not auto gradable.
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
              * @param string $question_type one of the Sensei question type.
894 894
              * @param string $answer user supplied question answer
895 895
              */
896
-            $question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer );
896
+            $question_grade = (int) apply_filters('sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer);
897 897
 
898 898
         } // end if $question_type
899 899
 
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
      *
910 910
      * @return bool | int false or the grade given to the user answer
911 911
      */
912
-    public static function grade_gap_fill_question( $question_id, $user_answer ){
912
+    public static function grade_gap_fill_question($question_id, $user_answer) {
913 913
 
914
-        $right_answer = get_post_meta( $question_id, '_question_right_answer', true );
915
-        $gapfill_array = explode( '||', $right_answer );
914
+        $right_answer = get_post_meta($question_id, '_question_right_answer', true);
915
+        $gapfill_array = explode('||', $right_answer);
916 916
 
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 );
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 919
         }
920 920
 
921 921
         /**
@@ -928,53 +928,53 @@  discard block
 block discarded – undo
928 928
          *
929 929
          * @since 1.9.0
930 930
          */
931
-        $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false );
931
+        $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false);
932 932
 
933
-        if( $do_case_sensitive_comparison ){
933
+        if ($do_case_sensitive_comparison) {
934 934
 
935 935
             // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
936
-            if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) {
936
+            if (trim(($gapfill_array[1])) == trim($user_answer)) {
937 937
 
938
-                return Sensei()->question->get_question_grade( $question_id );
938
+                return Sensei()->question->get_question_grade($question_id);
939 939
 
940
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
940
+            } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) {
941 941
 
942
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
942
+                if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) {
943 943
 
944 944
                     return Sensei()->question->get_question_grade($question_id);
945 945
 
946
-                }else{
946
+                } else {
947 947
 
948 948
                     return false;
949 949
 
950 950
                 }
951 951
 
952
-            }else{
952
+            } else {
953 953
 
954 954
                 return false;
955 955
 
956 956
             }
957 957
 
958
-        }else{
958
+        } else {
959 959
 
960 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 )) ) {
961
+            if (trim(strtolower($gapfill_array[1])) == trim(strtolower($user_answer))) {
962 962
 
963
-               return Sensei()->question->get_question_grade( $question_id );
963
+               return Sensei()->question->get_question_grade($question_id);
964 964
 
965
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
965
+            } else if (@preg_match('/'.$gapfill_array[1].'/i', null) !== FALSE) {
966 966
 
967
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
967
+                if (preg_match('/'.$gapfill_array[1].'/i', $user_answer)) {
968 968
 
969
-                    return  Sensei()->question->get_question_grade( $question_id );
969
+                    return  Sensei()->question->get_question_grade($question_id);
970 970
 
971
-                }else{
971
+                } else {
972 972
 
973 973
                     return false;
974 974
 
975 975
                 }
976 976
 
977
-            }else{
977
+            } else {
978 978
 
979 979
                 return false;
980 980
 
@@ -990,17 +990,17 @@  discard block
 block discarded – undo
990 990
      * @since 1.9.0
991 991
      * @return int $number_of_graded_lessons
992 992
      */
993
-    public static function get_graded_lessons_count(){
993
+    public static function get_graded_lessons_count() {
994 994
 
995 995
         global $wpdb;
996 996
 
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 ";
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 ";
1001 1001
 
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 ) );
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));
1004 1004
 
1005 1005
         return $number_of_graded_lessons;
1006 1006
     }
@@ -1011,17 +1011,17 @@  discard block
 block discarded – undo
1011 1011
      * @since 1.9.0
1012 1012
      * @return double $sum_of_all_grades
1013 1013
      */
1014
-    public static function get_graded_lessons_sum(){
1014
+    public static function get_graded_lessons_sum() {
1015 1015
 
1016 1016
         global $wpdb;
1017 1017
 
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 ";
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 ";
1022 1022
 
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 ) );
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));
1025 1025
 
1026 1026
         return $sum_of_all_grades;
1027 1027
 
@@ -1034,17 +1034,17 @@  discard block
 block discarded – undo
1034 1034
      * @param $user_id
1035 1035
      * @return double
1036 1036
      */
1037
-    public static function get_user_graded_lessons_sum( $user_id ){
1037
+    public static function get_user_graded_lessons_sum($user_id) {
1038 1038
         global $wpdb;
1039 1039
 
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 ";
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 ";
1045 1045
 
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 ) );
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));
1048 1048
 
1049 1049
         return $sum_of_all_grades;
1050 1050
     }
@@ -1057,18 +1057,18 @@  discard block
 block discarded – undo
1057 1057
      * @param int lesson_id
1058 1058
      * @return double
1059 1059
      */
1060
-    public static function get_lessons_users_grades_sum( $lesson_id ){
1060
+    public static function get_lessons_users_grades_sum($lesson_id) {
1061 1061
 
1062 1062
         global $wpdb;
1063 1063
 
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 ";
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 ";
1069 1069
 
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 ) );
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));
1072 1072
 
1073 1073
         return $sum_of_all_grades;
1074 1074
 
@@ -1082,18 +1082,18 @@  discard block
 block discarded – undo
1082 1082
      * @param int $course_id
1083 1083
      * @return double
1084 1084
      */
1085
-    public static function get_course_users_grades_sum( $course_id ){
1085
+    public static function get_course_users_grades_sum($course_id) {
1086 1086
 
1087 1087
         global $wpdb;
1088 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 ";
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 ";
1094 1094
 
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 ) );
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 1097
 
1098 1098
         return $sum_of_all_grades;
1099 1099
 
@@ -1106,4 +1106,4 @@  discard block
 block discarded – undo
1106 1106
  * @ignore only for backward compatibility
1107 1107
  * @since 1.9.0
1108 1108
  */
1109
-class WooThemes_Sensei_Grading extends Sensei_Grading{}
1109
+class WooThemes_Sensei_Grading extends Sensei_Grading {}
Please login to merge, or discard this patch.
includes/hooks/woocommerce.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
  * show the WooCommerce course filter links above the courses
8 8
  * @since 1.9.0
9 9
  */
10
-add_filter( 'sensei_archive_course_filter_by_options', array( 'Sensei_WC', 'add_course_archive_wc_filter_links' ) );
10
+add_filter('sensei_archive_course_filter_by_options', array('Sensei_WC', 'add_course_archive_wc_filter_links'));
11 11
 
12 12
 /**
13 13
  * filter the queries for paid and free course based on the users selection.
14 14
  * @since 1.9.0
15 15
  */
16
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_free'));
17
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_paid'));
16
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_free'));
17
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_paid'));
18 18
 
19 19
 /**
20 20
  * Add woocommerce action above single course the action
21 21
  * @since 1.9.0
22 22
  */
23
-add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action') ,50) ;
23
+add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action'), 50);
24 24
 
25 25
 
26 26
 /******************************
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * Single Lesson Hooks
29 29
  *
30 30
  ******************************/
31
-add_filter( 'sensei_can_user_view_lesson', array( 'Sensei_WC','alter_can_user_view_lesson' ), 20, 3 );
31
+add_filter('sensei_can_user_view_lesson', array('Sensei_WC', 'alter_can_user_view_lesson'), 20, 3);
32 32
 
33 33
 /******************************
34 34
  *
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *
37 37
  ******************************/
38 38
 // add a notice on the checkout page to tell users about the course they've purchase
39
-add_action( 'template_redirect', array( 'Sensei_WC','course_link_from_order' ) );
39
+add_action('template_redirect', array('Sensei_WC', 'course_link_from_order'));
40 40
 
41 41
 /******************************
42 42
  *
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  ******************************/
46 46
 //@since 1.9.0
47 47
 //show a notice if the user has already added the current course to their cart
48
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_WC', 'course_in_cart_message' ), 20 );
48
+add_action('sensei_single_course_content_inside_before', array('Sensei_WC', 'course_in_cart_message'), 20);
49 49
 
50 50
 /******************************
51 51
  *
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
  ******************************/
55 55
 //@since 1.9.0
56 56
 // alter the no permissions message to show the woocommerce message instead
57
-add_filter( 'sensei_the_no_permissions_message', array( 'Sensei_WC', 'alter_no_permissions_message' ), 20, 2 );
57
+add_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2);
58 58
 
59 59
 // @since 1.9.0
60 60
 // add  woocommerce class to the the no permission body class to ensure WooCommerce elements are styled
61
-add_filter( 'body_class', array( 'Sensei_WC', 'add_woocommerce_body_class' ), 20, 1);
61
+add_filter('body_class', array('Sensei_WC', 'add_woocommerce_body_class'), 20, 1);
62 62
 
63 63
 
64 64
 /************************************
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  *
68 68
  ************************************/
69 69
 // Add Email link to course orders
70
-add_action( 'woocommerce_email_after_order_table', array( 'Sensei_WC', 'email_course_details' ), 10, 1 );
70
+add_action('woocommerce_email_after_order_table', array('Sensei_WC', 'email_course_details'), 10, 1);
71 71
 
72 72
 /************************************
73 73
  *
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
  ************************************/
77 77
 //add_action( 'woocommerce_payment_complete',                 array( 'Sensei_WC', 'complete_order' ) );
78 78
 //add_action( 'woocommerce_thankyou' ,                        array( 'Sensei_WC', 'complete_order' ) );
79
-add_action( 'woocommerce_delete_shop_order_transients',           array( 'Sensei_WC', 'complete_order' ) );
80
-add_action( 'woocommerce_delete_shop_order_transients',            array( 'Sensei_WC', 'cancel_order' ) );
79
+add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'complete_order'));
80
+add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'cancel_order'));
81 81
 // Disable guest checkout if a course is in the cart as we need a valid user to store data for
82
-add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( 'Sensei_WC', 'disable_guest_checkout' ) );
82
+add_filter('pre_option_woocommerce_enable_guest_checkout', array('Sensei_WC', 'disable_guest_checkout'));
83 83
 // Mark orders with virtual products as complete rather then stay processing
84
-add_filter( 'woocommerce_payment_complete_order_status',    array( 'Sensei_WC', 'virtual_order_payment_complete' ), 10, 2 );
84
+add_filter('woocommerce_payment_complete_order_status', array('Sensei_WC', 'virtual_order_payment_complete'), 10, 2);
85 85
 
86 86
 /************************************
87 87
  *
88 88
  * WooCommerce Subscriptions
89 89
  *
90 90
  ************************************/
91
-add_action( 'woocommerce_subscription_status_pending_to_active', array( 'Sensei_WC', 'activate_subscription' ), 50, 3 );
91
+add_action('woocommerce_subscription_status_pending_to_active', array('Sensei_WC', 'activate_subscription'), 50, 3);
92 92
 // filter the user permission of the subscription is not valid
93
-add_filter( 'sensei_access_permissions',               array( 'Sensei_WC', 'get_subscription_permission' ), 10, 2 );
93
+add_filter('sensei_access_permissions', array('Sensei_WC', 'get_subscription_permission'), 10, 2);
Please login to merge, or discard this patch.
includes/class-sensei-course-results.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * All functionality pertaining to the course results pages in Sensei.
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
 	 * Constructor.
21 21
 	 * @since  1.4.0
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 
25 25
 		// Setup learner profile URL base
26
-		$this->courses_url_base = apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url slug', 'woothemes-sensei' ) );
26
+		$this->courses_url_base = apply_filters('sensei_course_slug', _x('course', 'post type single url slug', 'woothemes-sensei'));
27 27
 
28 28
 		// Setup permalink structure for course results
29
-		add_action( 'init', array( $this, 'setup_permastruct' ) );
30
-		add_filter( 'wp_title', array( $this, 'page_title' ), 10, 2 );
29
+		add_action('init', array($this, 'setup_permastruct'));
30
+		add_filter('wp_title', array($this, 'page_title'), 10, 2);
31 31
 
32 32
 		// Load course results
33
-		add_action( 'sensei_course_results_content_inside_before', array( $this, 'deprecate_course_result_info_hook' ), 10 );
33
+		add_action('sensei_course_results_content_inside_before', array($this, 'deprecate_course_result_info_hook'), 10);
34 34
 
35 35
 		// Add class to body tag
36
-		add_filter( 'body_class', array( $this, 'body_class' ), 10, 1 );
36
+		add_filter('body_class', array($this, 'body_class'), 10, 1);
37 37
 
38 38
 	} // End __construct()
39 39
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @return void
44 44
 	 */
45 45
 	public function setup_permastruct() {
46
-		add_rewrite_rule( '^' . $this->courses_url_base . '/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top' );
47
-		add_rewrite_tag( '%course_results%', '([^&]+)' );
46
+		add_rewrite_rule('^'.$this->courses_url_base.'/([^/]*)/results/?', 'index.php?course_results=$matches[1]', 'top');
47
+		add_rewrite_tag('%course_results%', '([^&]+)');
48 48
 	}
49 49
 
50 50
 	/**
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 * @param  string $sep   Seeparator string
54 54
 	 * @return string        Modified title
55 55
 	 */
56
-	public function page_title( $title, $sep = null ) {
56
+	public function page_title($title, $sep = null) {
57 57
 		global $wp_query;
58
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
59
-			$course = get_page_by_path( $wp_query->query_vars['course_results'], OBJECT, 'course' );
60
-			$title = __( 'Course Results: ', 'woothemes-sensei' ) . $course->post_title . ' ' . $sep . ' ';
58
+		if (isset($wp_query->query_vars['course_results'])) {
59
+			$course = get_page_by_path($wp_query->query_vars['course_results'], OBJECT, 'course');
60
+			$title = __('Course Results: ', 'woothemes-sensei').$course->post_title.' '.$sep.' ';
61 61
 		}
62 62
 		return $title;
63 63
 	}
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 	 * @param  integer $course_id ID of course
69 69
 	 * @return string             The course results page permalink
70 70
 	 */
71
-	public function get_permalink( $course_id = 0 ) {
71
+	public function get_permalink($course_id = 0) {
72 72
 
73 73
 		$permalink = '';
74 74
 
75
-		if( $course_id > 0 ) {
75
+		if ($course_id > 0) {
76 76
 
77
-			$course = get_post( $course_id );
77
+			$course = get_post($course_id);
78 78
 
79
-			if ( get_option('permalink_structure') ) {
80
-				$permalink = trailingslashit( get_home_url() ) . $this->courses_url_base . '/' . $course->post_name . '/results/';
79
+			if (get_option('permalink_structure')) {
80
+				$permalink = trailingslashit(get_home_url()).$this->courses_url_base.'/'.$course->post_name.'/results/';
81 81
 			} else {
82
-				$permalink = trailingslashit( get_home_url() ) . '?course_results=' . $course->post_name;
82
+				$permalink = trailingslashit(get_home_url()).'?course_results='.$course->post_name;
83 83
 			}
84 84
 		}
85 85
 
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 	 * @return void
93 93
 	 */
94 94
 	public function content() {
95
-		global $wp_query,  $current_user;
95
+		global $wp_query, $current_user;
96 96
 
97
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
98
-            Sensei_Templates::get_template( 'course-results/course-info.php' );
97
+		if (isset($wp_query->query_vars['course_results'])) {
98
+            Sensei_Templates::get_template('course-results/course-info.php');
99 99
 		}
100 100
 
101 101
 	}
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 
110 110
 		global $course;
111 111
 
112
-		Sensei_Utils::sensei_user_course_status_message( $course->ID, get_current_user_id());
112
+		Sensei_Utils::sensei_user_course_status_message($course->ID, get_current_user_id());
113 113
 
114
-		sensei_do_deprecated_action( 'sensei_course_results_lessons','1.9.','sensei_course_results_content_inside_after', $course );
114
+		sensei_do_deprecated_action('sensei_course_results_lessons', '1.9.', 'sensei_course_results_content_inside_after', $course);
115 115
 
116
-        sensei_do_deprecated_action( 'sensei_course_results_bottom','1.9.','sensei_course_results_content_inside_after', $course->ID );
116
+        sensei_do_deprecated_action('sensei_course_results_bottom', '1.9.', 'sensei_course_results_content_inside_after', $course->ID);
117 117
 
118 118
 	}
119 119
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	public function course_lessons() {
127 127
 
128 128
 		global $course;
129
-        _deprecated_function( 'Sensei_modules course_lessons ', '1.9.0' );
129
+        _deprecated_function('Sensei_modules course_lessons ', '1.9.0');
130 130
 
131 131
 	}
132 132
 
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 	 * @param  array $classes Existing classes
136 136
 	 * @return array          Modified classes
137 137
 	 */
138
-	public function body_class( $classes ) {
138
+	public function body_class($classes) {
139 139
 		global $wp_query;
140
-		if( isset( $wp_query->query_vars['course_results'] ) ) {
140
+		if (isset($wp_query->query_vars['course_results'])) {
141 141
 			$classes[] = 'course-results';
142 142
 		}
143 143
 		return $classes;
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @deprecated since 1.9.0
150 150
      */
151
-    public static function deprecate_sensei_course_results_content_hook(){
151
+    public static function deprecate_sensei_course_results_content_hook() {
152 152
 
153
-        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0','sensei_course_results_content_before');
153
+        sensei_do_deprecated_action('sensei_course_results_content', '1.9.0', 'sensei_course_results_content_before');
154 154
 
155 155
     }
156 156
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @since 1.9.0
161 161
      */
162
-    public static function fire_sensei_message_hook(){
162
+    public static function fire_sensei_message_hook() {
163 163
 
164
-        do_action( 'sensei_frontend_messages' );
164
+        do_action('sensei_frontend_messages');
165 165
 
166 166
     }
167 167
 
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
      *
171 171
      * @since 1.9.0
172 172
      */
173
-    public static function deprecate_course_result_info_hook(){
173
+    public static function deprecate_course_result_info_hook() {
174 174
 
175
-        sensei_do_deprecated_action( 'sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before' );
175
+        sensei_do_deprecated_action('sensei_course_results_info', '1.9.0', 'sensei_course_results_content_inside_before');
176 176
 
177 177
     }
178 178
 
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @deprecate since 1.9.0
183 183
      */
184
-    public static function deprecate_course_results_top_hook(){
184
+    public static function deprecate_course_results_top_hook() {
185 185
 
186 186
         global $course;
187
-        sensei_do_deprecated_action( 'sensei_course_results_top', '1.9.0' ,'sensei_course_results_content_inside_before',$course->ID );
187
+        sensei_do_deprecated_action('sensei_course_results_top', '1.9.0', 'sensei_course_results_content_inside_before', $course->ID);
188 188
 
189 189
     }
190 190
 
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
      *
194 194
      * @since 1.8.0
195 195
      */
196
-    public static function fire_course_image_hook(){
196
+    public static function fire_course_image_hook() {
197 197
 
198 198
         global $course;
199
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
199
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID()));
200 200
 
201 201
     }
202 202
 
@@ -207,4 +207,4 @@  discard block
 block discarded – undo
207 207
  * @ignore only for backward compatibility
208 208
  * @since 1.9.0
209 209
  */
210
-class WooThemes_Sensei_Course_Results extends Sensei_Course_Results{}
210
+class WooThemes_Sensei_Course_Results extends Sensei_Course_Results {}
Please login to merge, or discard this patch.
includes/class-sensei-course.php 1 patch
Spacing   +668 added lines, -668 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Course Class
@@ -32,72 +32,72 @@  discard block
 block discarded – undo
32 32
 	 * Constructor.
33 33
 	 * @since  1.0.0
34 34
 	 */
35
-	public function __construct () {
35
+	public function __construct() {
36 36
 
37 37
         $this->token = 'course';
38 38
 
39 39
 		// Setup meta fields for this post type
40
-		$this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' );
40
+		$this->meta_fields = array('course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product');
41 41
 		// Admin actions
42
-		if ( is_admin() ) {
42
+		if (is_admin()) {
43 43
 			// Metabox functions
44
-            add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 );
45
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
44
+            add_action('add_meta_boxes', array($this, 'meta_box_setup'), 20);
45
+			add_action('save_post', array($this, 'meta_box_save'));
46 46
 			// Custom Write Panel Columns
47
-			add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 );
48
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
47
+			add_filter('manage_edit-course_columns', array($this, 'add_column_headings'), 10, 1);
48
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
49 49
 		} else {
50 50
 			$this->my_courses_page = false;
51 51
 		} // End If Statement
52 52
 
53 53
 		// Update course completion upon completion of a lesson
54
-		add_action( 'sensei_user_lesson_end', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
54
+		add_action('sensei_user_lesson_end', array($this, 'update_status_after_lesson_change'), 10, 2);
55 55
 		// Update course completion upon reset of a lesson
56
-		add_action( 'sensei_user_lesson_reset', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
56
+		add_action('sensei_user_lesson_reset', array($this, 'update_status_after_lesson_change'), 10, 2);
57 57
 		// Update course completion upon grading of a quiz
58
-		add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 );
58
+		add_action('sensei_user_quiz_grade', array($this, 'update_status_after_quiz_submission'), 10, 2);
59 59
 
60 60
         // show the progress bar ont he single course page
61
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 );
62
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 );
61
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_statement'), 15);
62
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_meter'), 16);
63 63
 
64 64
         // provide an option to block all emails related to a selected course
65
-        add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) );
66
-        add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) );
65
+        add_filter('sensei_send_emails', array($this, 'block_notification_emails'));
66
+        add_action('save_post', array($this, 'save_course_notification_meta_box'));
67 67
 
68 68
         // preview lessons on the course content
69
-        add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) );
69
+        add_action('sensei_course_content_inside_after', array($this, 'the_course_free_lesson_preview'));
70 70
 
71 71
         // the course meta
72
-        add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) );
72
+        add_action('sensei_course_content_inside_before', array($this, 'the_course_meta'));
73 73
 
74 74
         // backwards compatible template hooks
75
-        add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' ));
76
-        add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) );
75
+        add_action('sensei_course_content_inside_before', array($this, 'content_before_backwards_compatibility_hooks'));
76
+        add_action('sensei_loop_course_before', array($this, 'loop_before_backwards_compatibility_hooks'));
77 77
 
78 78
         // add the user status on the course to the markup as a class
79
-        add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 );
79
+        add_filter('post_class', array(__CLASS__, 'add_course_user_status_class'), 20, 3);
80 80
 
81 81
         //filter the course query in Sensei specific instances
82
-        add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) );
82
+        add_filter('pre_get_posts', array(__CLASS__, 'course_query_filter'));
83 83
 
84 84
         //attache the sorting to the course archive
85
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) );
85
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_sorting'));
86 86
 
87 87
         //attach the filter links to the course archive
88
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) );
88
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_filters'));
89 89
 
90 90
         //filter the course query when featured filter is applied
91
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_featured_filter'));
91
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_featured_filter'));
92 92
 
93 93
         // handle the order by title post submission
94
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_order_by_title'));
94
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_order_by_title'));
95 95
 
96 96
         // ensure the course category page respects the manual order set for courses
97
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'alter_course_category_order'));
97
+        add_filter('pre_get_posts', array(__CLASS__, 'alter_course_category_order'));
98 98
 
99 99
         // flush rewrite rules when saving a course
100
-        add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) );
100
+        add_action('save_post', array('Sensei_Course', 'flush_rewrite_rules'));
101 101
 
102 102
 	} // End __construct()
103 103
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 * @param type $user_id
108 108
 	 * @param type $quiz_id
109 109
 	 */
110
-	public function update_status_after_quiz_submission( $user_id, $quiz_id ) {
111
-		if ( intval( $user_id ) > 0 && intval( $quiz_id ) > 0 ) {
112
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
113
-			$this->update_status_after_lesson_change( $user_id, $lesson_id );
110
+	public function update_status_after_quiz_submission($user_id, $quiz_id) {
111
+		if (intval($user_id) > 0 && intval($quiz_id) > 0) {
112
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
113
+			$this->update_status_after_lesson_change($user_id, $lesson_id);
114 114
 		}
115 115
 	}
116 116
 
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param int $user_id
121 121
 	 * @param int $lesson_id
122 122
 	 */
123
-	public function update_status_after_lesson_change( $user_id, $lesson_id ) {
124
-		if ( intval( $user_id ) > 0 && intval( $lesson_id ) > 0 ) {
125
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
126
-			if ( intval( $course_id ) > 0 ) {
123
+	public function update_status_after_lesson_change($user_id, $lesson_id) {
124
+		if (intval($user_id) > 0 && intval($lesson_id) > 0) {
125
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
126
+			if (intval($course_id) > 0) {
127 127
 				// Updates the Course status and it's meta data
128
-				Sensei_Utils::user_complete_course( $course_id, $user_id );
128
+				Sensei_Utils::user_complete_course($course_id, $user_id);
129 129
 			}
130 130
 		}
131 131
 	}
@@ -136,27 +136,27 @@  discard block
 block discarded – undo
136 136
 	 * @access public
137 137
 	 * @return void
138 138
 	 */
139
-	public function meta_box_setup () {
139
+	public function meta_box_setup() {
140 140
 
141
-		if ( Sensei_WC::is_woocommerce_active() ) {
141
+		if (Sensei_WC::is_woocommerce_active()) {
142 142
 			// Add Meta Box for WooCommerce Course
143
-			add_meta_box( 'course-wc-product', __( 'WooCommerce Product', 'woothemes-sensei' ), array( $this, 'course_woocommerce_product_meta_box_content' ), $this->token, 'side', 'default' );
143
+			add_meta_box('course-wc-product', __('WooCommerce Product', 'woothemes-sensei'), array($this, 'course_woocommerce_product_meta_box_content'), $this->token, 'side', 'default');
144 144
 		} // End If Statement
145 145
 		// Add Meta Box for Prerequisite Course
146
-		add_meta_box( 'course-prerequisite', __( 'Course Prerequisite', 'woothemes-sensei' ), array( $this, 'course_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
146
+		add_meta_box('course-prerequisite', __('Course Prerequisite', 'woothemes-sensei'), array($this, 'course_prerequisite_meta_box_content'), $this->token, 'side', 'default');
147 147
 		// Add Meta Box for Featured Course
148
-		add_meta_box( 'course-featured', __( 'Featured Course', 'woothemes-sensei' ), array( $this, 'course_featured_meta_box_content' ), $this->token, 'side', 'default' );
148
+		add_meta_box('course-featured', __('Featured Course', 'woothemes-sensei'), array($this, 'course_featured_meta_box_content'), $this->token, 'side', 'default');
149 149
 		// Add Meta Box for Course Meta
150
-		add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' );
150
+		add_meta_box('course-video', __('Course Video', 'woothemes-sensei'), array($this, 'course_video_meta_box_content'), $this->token, 'normal', 'default');
151 151
 		// Add Meta Box for Course Lessons
152
-		add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' );
152
+		add_meta_box('course-lessons', __('Course Lessons', 'woothemes-sensei'), array($this, 'course_lessons_meta_box_content'), $this->token, 'normal', 'default');
153 153
         // Add Meta Box to link to Manage Learners
154
-        add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' );
154
+        add_meta_box('course-manage', __('Course Management', 'woothemes-sensei'), array($this, 'course_manage_meta_box_content'), $this->token, 'side', 'default');
155 155
         // Remove "Custom Settings" meta box.
156
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
156
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
157 157
 
158 158
         // add Disable email notification box
159
-        add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' );
159
+        add_meta_box('course-notifications', __('Course Notifications', 'woothemes-sensei'), array($this, 'course_notification_meta_box_content'), 'course', 'normal', 'default');
160 160
 
161 161
 	} // End meta_box_setup()
162 162
 
@@ -166,58 +166,58 @@  discard block
 block discarded – undo
166 166
 	 * @access public
167 167
 	 * @return void
168 168
 	 */
169
-	public function course_woocommerce_product_meta_box_content () {
169
+	public function course_woocommerce_product_meta_box_content() {
170 170
 		global $post;
171 171
 
172
-		$select_course_woocommerce_product = get_post_meta( $post->ID, '_course_woocommerce_product', true );
172
+		$select_course_woocommerce_product = get_post_meta($post->ID, '_course_woocommerce_product', true);
173 173
 
174
-		$post_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
174
+		$post_args = array('post_type' 		=> array('product', 'product_variation'),
175 175
 							'posts_per_page' 		=> -1,
176 176
 							'orderby'         	=> 'title',
177 177
     						'order'           	=> 'DESC',
178 178
     						'exclude' 			=> $post->ID,
179
-    						'post_status'		=> array( 'publish', 'private', 'draft' ),
179
+    						'post_status'		=> array('publish', 'private', 'draft'),
180 180
     						'tax_query'			=> array(
181 181
 								array(
182 182
 									'taxonomy'	=> 'product_type',
183 183
 									'field'		=> 'slug',
184
-									'terms'		=> array( 'variable', 'grouped' ),
184
+									'terms'		=> array('variable', 'grouped'),
185 185
 									'operator'	=> 'NOT IN'
186 186
 								)
187 187
 							),
188 188
 							'suppress_filters' 	=> 0
189 189
 							);
190
-		$posts_array = get_posts( $post_args );
190
+		$posts_array = get_posts($post_args);
191 191
 
192 192
 		$html = '';
193 193
 
194
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
194
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
195 195
 
196
-		if ( count( $posts_array ) > 0 ) {
196
+		if (count($posts_array) > 0) {
197 197
 
198
-			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
199
-			$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
198
+			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
199
+			$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
200 200
 				$prev_parent_id = 0;
201
-				foreach ( $posts_array as $post_item ) {
201
+				foreach ($posts_array as $post_item) {
202 202
 
203
-					if ( 'product_variation' == $post_item->post_type ) {
203
+					if ('product_variation' == $post_item->post_type) {
204 204
 
205
-						$product_object = get_product( $post_item->ID );
206
-						$parent_id = wp_get_post_parent_id( $post_item->ID );
205
+						$product_object = get_product($post_item->ID);
206
+						$parent_id = wp_get_post_parent_id($post_item->ID);
207 207
 
208
-                        if( sensei_check_woocommerce_version( '2.1' ) ) {
209
-							$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
208
+                        if (sensei_check_woocommerce_version('2.1')) {
209
+							$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
210 210
 
211 211
 						} else {
212 212
                             // fall back to pre wc 2.1
213
-							$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
213
+							$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
214 214
 
215 215
 						}
216 216
 
217
-                        $product_name = ucwords( $formatted_variation );
218
-                        if( empty( $product_name ) ){
217
+                        $product_name = ucwords($formatted_variation);
218
+                        if (empty($product_name)) {
219 219
 
220
-                            $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id;
220
+                            $product_name = __('Variation #', 'woothemes-sensei').$product_object->variation_id;
221 221
 
222 222
                         }
223 223
 
@@ -230,47 +230,47 @@  discard block
 block discarded – undo
230 230
 					}
231 231
 
232 232
 					// Show variations in groups
233
-					if( $parent_id && $parent_id != $prev_parent_id ) {
233
+					if ($parent_id && $parent_id != $prev_parent_id) {
234 234
 
235
-						if( 0 != $prev_parent_id ) {
235
+						if (0 != $prev_parent_id) {
236 236
 
237 237
 							$html .= '</optgroup>';
238 238
 
239 239
 						}
240
-						$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
240
+						$html .= '<optgroup label="'.get_the_title($parent_id).'">';
241 241
 						$prev_parent_id = $parent_id;
242 242
 
243
-					} elseif( ! $parent_id && 0 == $prev_parent_id ) {
243
+					} elseif ( ! $parent_id && 0 == $prev_parent_id) {
244 244
 
245 245
 						$html .= '</optgroup>';
246 246
 
247 247
 					}
248 248
 
249
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_woocommerce_product, false ) . '>' . esc_html( $product_name ) . '</option>' . "\n";
249
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_woocommerce_product, false).'>'.esc_html($product_name).'</option>'."\n";
250 250
 
251 251
 				} // End For Loop
252 252
 
253
-			$html .= '</select>' . "\n";
254
-			if ( current_user_can( 'publish_product' )) {
253
+			$html .= '</select>'."\n";
254
+			if (current_user_can('publish_product')) {
255 255
 
256
-				$html .= '<p>' . "\n";
257
-					$html .= '<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Add a Product', 'woothemes-sensei' ) . '</a>' . "\n";
256
+				$html .= '<p>'."\n";
257
+					$html .= '<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Add a Product', 'woothemes-sensei').'</a>'."\n";
258 258
 				$html .= '</p>'."\n";
259 259
 
260 260
 			} // End If Statement
261 261
 
262 262
 		} else {
263 263
 
264
-			if ( current_user_can( 'publish_product' )) {
264
+			if (current_user_can('publish_product')) {
265 265
 
266
-				$html .= '<p>' . "\n";
267
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . '&nbsp;<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Please add some first', 'woothemes-sensei' ) . '</a>' . "\n";
266
+				$html .= '<p>'."\n";
267
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei')).'&nbsp;<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Please add some first', 'woothemes-sensei').'</a>'."\n";
268 268
 				$html .= '</p>'."\n";
269 269
 
270 270
 			} else {
271 271
 
272
-                $html .= '<p>' . "\n";
273
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n";
272
+                $html .= '<p>'."\n";
273
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei'))."\n";
274 274
 				$html .= '</p>'."\n";
275 275
 
276 276
 			} // End If Statement
@@ -287,33 +287,33 @@  discard block
 block discarded – undo
287 287
 	 * @access public
288 288
 	 * @return void
289 289
 	 */
290
-	public function course_prerequisite_meta_box_content () {
290
+	public function course_prerequisite_meta_box_content() {
291 291
 		global $post;
292 292
 
293
-		$select_course_prerequisite = get_post_meta( $post->ID, '_course_prerequisite', true );
293
+		$select_course_prerequisite = get_post_meta($post->ID, '_course_prerequisite', true);
294 294
 
295
-		$post_args = array(	'post_type' 		=> 'course',
295
+		$post_args = array('post_type' 		=> 'course',
296 296
 							'posts_per_page' 		=> -1,
297 297
 							'orderby'         	=> 'title',
298 298
     						'order'           	=> 'DESC',
299 299
     						'exclude' 			=> $post->ID,
300 300
 							'suppress_filters' 	=> 0
301 301
 							);
302
-		$posts_array = get_posts( $post_args );
302
+		$posts_array = get_posts($post_args);
303 303
 
304 304
 		$html = '';
305 305
 
306
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
306
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
307 307
 
308
-		if ( count( $posts_array ) > 0 ) {
309
-			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
310
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
311
-				foreach ($posts_array as $post_item){
312
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
308
+		if (count($posts_array) > 0) {
309
+			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
310
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
311
+				foreach ($posts_array as $post_item) {
312
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
313 313
 				} // End For Loop
314
-			$html .= '</select>' . "\n";
314
+			$html .= '</select>'."\n";
315 315
 		} else {
316
-			$html .= '<p>' . esc_html( __( 'No courses exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
316
+			$html .= '<p>'.esc_html(__('No courses exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
317 317
 		} // End If Statement
318 318
 
319 319
 		echo $html;
@@ -326,21 +326,21 @@  discard block
 block discarded – undo
326 326
 	 * @access public
327 327
 	 * @return void
328 328
 	 */
329
-	public function course_featured_meta_box_content () {
329
+	public function course_featured_meta_box_content() {
330 330
 		global $post;
331 331
 
332
-		$course_featured = get_post_meta( $post->ID, '_course_featured', true );
332
+		$course_featured = get_post_meta($post->ID, '_course_featured', true);
333 333
 
334 334
 		$html = '';
335 335
 
336
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
336
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
337 337
 
338 338
 		$checked = '';
339
-		if ( isset( $course_featured ) && ( '' != $course_featured ) ) {
340
-	 	    $checked = checked( 'featured', $course_featured, false );
339
+		if (isset($course_featured) && ('' != $course_featured)) {
340
+	 	    $checked = checked('featured', $course_featured, false);
341 341
 	 	} // End If Statement
342 342
 
343
-	 	$html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '>&nbsp;' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>';
343
+	 	$html .= '<input type="checkbox" name="course_featured" value="featured" '.$checked.'>&nbsp;'.__('Feature this course', 'woothemes-sensei').'<br>';
344 344
 
345 345
 		echo $html;
346 346
 
@@ -352,16 +352,16 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 * @return void
354 354
 	 */
355
-	public function course_video_meta_box_content () {
355
+	public function course_video_meta_box_content() {
356 356
 		global $post;
357 357
 
358
-		$course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
358
+		$course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
359 359
 
360 360
 		$html = '';
361 361
 
362
-		$html .= '<label class="screen-reader-text" for="course_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . '</label>';
363
-		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">' . $course_video_embed . '</textarea>';
364
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
362
+		$html .= '<label class="screen-reader-text" for="course_video_embed">'.__('Video Embed Code', 'woothemes-sensei').'</label>';
363
+		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">'.$course_video_embed.'</textarea>';
364
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
365 365
 
366 366
 		echo $html;
367 367
 
@@ -376,36 +376,36 @@  discard block
 block discarded – undo
376 376
 	 * @param int $post_id
377 377
 	 * @return int
378 378
 	 */
379
-	public function meta_box_save ( $post_id ) {
379
+	public function meta_box_save($post_id) {
380 380
 		global $post;
381 381
 
382 382
 		/* Verify the nonce before proceeding. */
383
-		if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) {
383
+		if ((get_post_type() != $this->token) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_noonce'], plugin_basename(__FILE__))) {
384 384
 			return $post_id;
385 385
 		}
386 386
 
387 387
 		/* Get the post type object. */
388
-		$post_type = get_post_type_object( $post->post_type );
388
+		$post_type = get_post_type_object($post->post_type);
389 389
 
390 390
 		/* Check if the current user has permission to edit the post. */
391
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
391
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
392 392
 			return $post_id;
393 393
 		} // End If Statement
394 394
 
395
-		if ( 'page' == $_POST['post_type'] ) {
396
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
395
+		if ('page' == $_POST['post_type']) {
396
+			if ( ! current_user_can('edit_page', $post_id)) {
397 397
 				return $post_id;
398 398
 			} // End If Statement
399 399
 		} else {
400
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
400
+			if ( ! current_user_can('edit_post', $post_id)) {
401 401
 				return $post_id;
402 402
 			} // End If Statement
403 403
 		} // End If Statement
404 404
 
405 405
 		// Save the post meta data fields
406
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
407
-			foreach ( $this->meta_fields as $meta_key ) {
408
-				$this->save_post_meta( $meta_key, $post_id );
406
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
407
+			foreach ($this->meta_fields as $meta_key) {
408
+				$this->save_post_meta($meta_key, $post_id);
409 409
 			} // End For Loop
410 410
 		} // End If Statement
411 411
 
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 	 * @param int $post_id (default: 0)
423 423
 	 * @return int new meta id | bool meta value saved status
424 424
 	 */
425
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
425
+	private function save_post_meta($post_key = '', $post_id = 0) {
426 426
 		// Get the meta key.
427
-		$meta_key = '_' . $post_key;
427
+		$meta_key = '_'.$post_key;
428 428
 		// Get the posted data and sanitize it for use as an HTML class.
429
-		if ( 'course_video_embed' == $post_key) {
430
-			$new_meta_value = esc_html( $_POST[$post_key] );
429
+		if ('course_video_embed' == $post_key) {
430
+			$new_meta_value = esc_html($_POST[$post_key]);
431 431
 		} else {
432
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
432
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
433 433
 		} // End If Statement
434 434
 
435 435
         // update field with the new value
436
-        return update_post_meta( $post_id, $meta_key, $new_meta_value );
436
+        return update_post_meta($post_id, $meta_key, $new_meta_value);
437 437
 
438 438
 	} // End save_post_meta()
439 439
 
@@ -443,31 +443,31 @@  discard block
 block discarded – undo
443 443
 	 * @access public
444 444
 	 * @return void
445 445
 	 */
446
-	public function course_lessons_meta_box_content () {
446
+	public function course_lessons_meta_box_content() {
447 447
 
448 448
 		global $post;
449 449
 
450 450
 		// Setup Lesson Query
451 451
 		$posts_array = array();
452
-		if ( 0 < $post->ID ) {
452
+		if (0 < $post->ID) {
453 453
 
454
-			$posts_array = $this->course_lessons( $post->ID, 'any' );
454
+			$posts_array = $this->course_lessons($post->ID, 'any');
455 455
 
456 456
 		} // End If Statement
457 457
 
458 458
 		$html = '';
459
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="'
460
-                 . esc_attr( 'woo_' . $this->token . '_noonce' )
461
-                 . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
459
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'
460
+                 . esc_attr('woo_'.$this->token.'_noonce')
461
+                 . '" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
462 462
 
463
-		if ( count( $posts_array ) > 0 ) {
463
+		if (count($posts_array) > 0) {
464 464
 
465
-			foreach ($posts_array as $post_item){
465
+			foreach ($posts_array as $post_item) {
466 466
 
467 467
 				$html .= '<p>'."\n";
468 468
 
469 469
 					$html .= $post_item->post_title."\n";
470
-					$html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>';
470
+					$html .= '<a href="'.esc_url(get_edit_post_link($post_item->ID)).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $post_item->post_title)).'" class="edit-lesson-action">'.__('Edit this lesson', 'woothemes-sensei').'</a>';
471 471
 
472 472
 				$html .= '</p>'."\n";
473 473
 
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
 
476 476
 		} else {
477 477
 			$course_id = '';
478
-			if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; }
479
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n";
478
+			if (0 < $post->ID) { $course_id = '&course_id='.$post->ID; }
479
+			$html .= '<p>'.esc_html(__('No lessons exist yet for this course.', 'woothemes-sensei'))."\n";
480 480
 
481
-				$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id )
482
-                         . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">'
483
-                         . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n";
481
+				$html .= '<a href="'.admin_url('post-new.php?post_type=lesson'.$course_id)
482
+                         . '" title="'.esc_attr(__('Add a Lesson', 'woothemes-sensei')).'">'
483
+                         . __('Please add some.', 'woothemes-sensei').'</a>'."\n";
484 484
 
485 485
 			$html .= '</p>'."\n";
486 486
 		} // End If Statement
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
      * @return void
498 498
      */
499 499
 
500
-    public function course_manage_meta_box_content () {
500
+    public function course_manage_meta_box_content() {
501 501
         global $post;
502 502
         
503
-        $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
503
+        $manage_url = esc_url(add_query_arg(array('page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
504 504
 
505
-        $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
505
+        $grading_url = esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
506 506
 
507 507
 
508 508
         echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>";
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
 	 * @param  array $defaults
521 521
 	 * @return array $new_columns
522 522
 	 */
523
-	public function add_column_headings ( $defaults ) {
523
+	public function add_column_headings($defaults) {
524 524
 		$new_columns['cb'] = '<input type="checkbox" />';
525 525
 		// $new_columns['id'] = __( 'ID' );
526
-		$new_columns['title'] = _x( 'Course Title', 'column name', 'woothemes-sensei' );
527
-		$new_columns['course-prerequisite'] = _x( 'Pre-requisite Course', 'column name', 'woothemes-sensei' );
528
-		if ( Sensei_WC::is_woocommerce_active() ) {
529
-			$new_columns['course-woocommerce-product'] = _x( 'WooCommerce Product', 'column name', 'woothemes-sensei' );
526
+		$new_columns['title'] = _x('Course Title', 'column name', 'woothemes-sensei');
527
+		$new_columns['course-prerequisite'] = _x('Pre-requisite Course', 'column name', 'woothemes-sensei');
528
+		if (Sensei_WC::is_woocommerce_active()) {
529
+			$new_columns['course-woocommerce-product'] = _x('WooCommerce Product', 'column name', 'woothemes-sensei');
530 530
 		} // End If Statement
531
-		$new_columns['course-category'] = _x( 'Category', 'column name', 'woothemes-sensei' );
532
-		if ( isset( $defaults['date'] ) ) {
531
+		$new_columns['course-category'] = _x('Category', 'column name', 'woothemes-sensei');
532
+		if (isset($defaults['date'])) {
533 533
 			$new_columns['date'] = $defaults['date'];
534 534
 		}
535 535
 
@@ -544,45 +544,45 @@  discard block
 block discarded – undo
544 544
 	 * @param  int $id
545 545
 	 * @return void
546 546
 	 */
547
-	public function add_column_data ( $column_name, $id ) {
547
+	public function add_column_data($column_name, $id) {
548 548
 		global $wpdb, $post;
549 549
 
550
-		switch ( $column_name ) {
550
+		switch ($column_name) {
551 551
 			case 'id':
552 552
 				echo $id;
553 553
 			break;
554 554
 
555 555
 			case 'course-prerequisite':
556
-				$course_prerequisite_id = get_post_meta( $id, '_course_prerequisite', true);
557
-				if ( 0 < absint( $course_prerequisite_id ) ) { echo '<a href="' . esc_url( get_edit_post_link( absint( $course_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $course_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $course_prerequisite_id ) ) . '</a>'; }
556
+				$course_prerequisite_id = get_post_meta($id, '_course_prerequisite', true);
557
+				if (0 < absint($course_prerequisite_id)) { echo '<a href="'.esc_url(get_edit_post_link(absint($course_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($course_prerequisite_id)))).'">'.get_the_title(absint($course_prerequisite_id)).'</a>'; }
558 558
 
559 559
 			break;
560 560
 
561 561
 			case 'course-woocommerce-product':
562
-				if ( Sensei_WC::is_woocommerce_active() ) {
563
-					$course_woocommerce_product_id = get_post_meta( $id, '_course_woocommerce_product', true);
564
-					if ( 0 < absint( $course_woocommerce_product_id ) ) {
565
-						if ( 'product_variation' == get_post_type( $course_woocommerce_product_id ) ) {
566
-							$product_object = get_product( $course_woocommerce_product_id );
567
-							if( sensei_check_woocommerce_version( '2.1' ) ) {
568
-								$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
562
+				if (Sensei_WC::is_woocommerce_active()) {
563
+					$course_woocommerce_product_id = get_post_meta($id, '_course_woocommerce_product', true);
564
+					if (0 < absint($course_woocommerce_product_id)) {
565
+						if ('product_variation' == get_post_type($course_woocommerce_product_id)) {
566
+							$product_object = get_product($course_woocommerce_product_id);
567
+							if (sensei_check_woocommerce_version('2.1')) {
568
+								$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
569 569
 							} else {
570
-								$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
570
+								$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
571 571
 							}
572 572
 							$course_woocommerce_product_id = $product_object->parent->post->ID;
573
-							$product_name = $product_object->parent->post->post_title . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . ucwords( $formatted_variation );
573
+							$product_name = $product_object->parent->post->post_title.'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.ucwords($formatted_variation);
574 574
 						} else {
575
-							$product_name = get_the_title( absint( $course_woocommerce_product_id ) );
575
+							$product_name = get_the_title(absint($course_woocommerce_product_id));
576 576
 						} // End If Statement
577
-						echo '<a href="' . esc_url( get_edit_post_link( absint( $course_woocommerce_product_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $product_name ) ) . '">' . $product_name . '</a>';
577
+						echo '<a href="'.esc_url(get_edit_post_link(absint($course_woocommerce_product_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $product_name)).'">'.$product_name.'</a>';
578 578
 					} // End If Statement
579 579
 				} // End If Statement
580 580
 			break;
581 581
 
582 582
 			case 'course-category':
583
-				$output = get_the_term_list( $id, 'course-category', '', ', ', '' );
584
-				if ( '' == $output ) {
585
-					$output = __( 'None', 'woothemes-sensei' );
583
+				$output = get_the_term_list($id, 'course-category', '', ', ', '');
584
+				if ('' == $output) {
585
+					$output = __('None', 'woothemes-sensei');
586 586
 				} // End If Statement
587 587
 				echo $output;
588 588
 			break;
@@ -602,29 +602,29 @@  discard block
 block discarded – undo
602 602
 	 * @param array $includes (default: array())
603 603
 	 * @return array
604 604
 	 */
605
-	public function course_query( $amount = 0, $type = 'default', $includes = array(), $excludes = array() ) {
606
-		global $my_courses_page ;
605
+	public function course_query($amount = 0, $type = 'default', $includes = array(), $excludes = array()) {
606
+		global $my_courses_page;
607 607
 
608 608
 		$results_array = array();
609 609
 
610
-		if( $my_courses_page ) { add_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
610
+		if ($my_courses_page) { add_action('pre_get_posts', array($this, 'filter_my_courses')); }
611 611
 
612
-		$post_args = $this->get_archive_query_args( $type, $amount, $includes, $excludes );
612
+		$post_args = $this->get_archive_query_args($type, $amount, $includes, $excludes);
613 613
 
614 614
 		// get the posts
615
-		if( empty( $post_args ) ) {
615
+		if (empty($post_args)) {
616 616
 
617 617
 			return $results_array;
618 618
 
619
-		}else{
619
+		} else {
620 620
 
621 621
 			//reset the pagination as this widgets do not need it
622 622
 			$post_args['paged'] = 1;
623
-			$results_array = get_posts( $post_args );
623
+			$results_array = get_posts($post_args);
624 624
 
625 625
 		}
626 626
 
627
-		if( $my_courses_page ) { remove_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
627
+		if ($my_courses_page) { remove_action('pre_get_posts', array($this, 'filter_my_courses')); }
628 628
 
629 629
 		return $results_array;
630 630
 
@@ -640,22 +640,22 @@  discard block
 block discarded – undo
640 640
 	 * @param array $includes (default: array())
641 641
 	 * @return array
642 642
 	 */
643
-	public function get_archive_query_args( $type = '', $amount = 0 , $includes = array(), $excludes = array() ) {
643
+	public function get_archive_query_args($type = '', $amount = 0, $includes = array(), $excludes = array()) {
644 644
 
645 645
 		global $wp_query;
646 646
 
647
-		if ( 0 == $amount && ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && 'usercourses' != $type && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) ) {
648
-			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
647
+		if (0 == $amount && (isset(Sensei()->settings->settings['course_archive_amount']) && 'usercourses' != $type && (0 < absint(Sensei()->settings->settings['course_archive_amount'])))) {
648
+			$amount = absint(Sensei()->settings->settings['course_archive_amount']);
649 649
 		} else {
650
-			if ( 0 == $amount) {
651
-				$amount = $wp_query->get( 'posts_per_page' );
650
+			if (0 == $amount) {
651
+				$amount = $wp_query->get('posts_per_page');
652 652
 			} // End If Statement
653 653
 		} // End If Statement
654 654
 
655
-        $stored_order = get_option( 'sensei_course_order', '' );
655
+        $stored_order = get_option('sensei_course_order', '');
656 656
         $order = 'ASC';
657 657
         $orderby = 'menu_order';
658
-        if( empty( $stored_order ) ){
658
+        if (empty($stored_order)) {
659 659
 
660 660
             $order = 'DESC';
661 661
             $orderby = 'date';
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 		switch ($type) {
666 666
 
667 667
 			case 'usercourses':
668
-				$post_args = array(	'post_type' 		=> 'course',
668
+				$post_args = array('post_type' 		=> 'course',
669 669
 									'orderby'         	=> $orderby,
670 670
     								'order'           	=> $order,
671 671
     								'post_status'      	=> 'publish',
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 				break;
707 707
 
708 708
 			case 'featuredcourses':
709
-                $post_args = array(	'post_type' 		=> 'course',
709
+                $post_args = array('post_type' 		=> 'course',
710 710
                                     'orderby'         	=> $orderby,
711 711
                                     'order'           	=> $order,
712 712
     								'post_status'      	=> 'publish',
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 									);
719 719
 				break;
720 720
 			default:
721
-				$post_args = array(	'post_type' 		=> 'course',
721
+				$post_args = array('post_type' 		=> 'course',
722 722
                                     'orderby'         	=> $orderby,
723 723
                                     'order'           	=> $order,
724 724
     								'post_status'      	=> 'publish',
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
 		}
731 731
 
732 732
         $post_args['posts_per_page'] = $amount;
733
-        $paged = $wp_query->get( 'paged' );
734
-        $post_args['paged'] = empty( $paged) ? 1 : $paged;
733
+        $paged = $wp_query->get('paged');
734
+        $post_args['paged'] = empty($paged) ? 1 : $paged;
735 735
 
736
-        if( 'newcourses' == $type ){
736
+        if ('newcourses' == $type) {
737 737
 
738
-            $post_args[ 'orderby' ] = 'date';
739
-            $post_args[ 'order' ] = 'DESC';
738
+            $post_args['orderby'] = 'date';
739
+            $post_args['order'] = 'DESC';
740 740
         }
741 741
 
742 742
 		return $post_args;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
      *
759 759
 	 * @return string | void
760 760
 	 */
761
-	public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) {
761
+	public function course_image($course_id = 0, $width = '100', $height = '100', $return = false) {
762 762
 
763
-        if ( is_a( $course_id, 'WP_Post' ) ) {
763
+        if (is_a($course_id, 'WP_Post')) {
764 764
 
765 765
 	        $course_id = $course_id->ID;
766 766
 
767 767
         }
768 768
 
769
-		if ( 'course' !== get_post_type( $course_id )  ){
769
+		if ('course' !== get_post_type($course_id)) {
770 770
 
771 771
 			return;
772 772
 
@@ -775,26 +775,26 @@  discard block
 block discarded – undo
775 775
 		$html = '';
776 776
 
777 777
 		// Get Width and Height settings
778
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
778
+		if (($width == '100') && ($height == '100')) {
779 779
 
780
-			if ( is_singular( 'course' ) ) {
780
+			if (is_singular('course')) {
781 781
 
782
-				if ( !Sensei()->settings->settings[ 'course_single_image_enable' ] ) {
782
+				if ( ! Sensei()->settings->settings['course_single_image_enable']) {
783 783
 					return '';
784 784
 				} // End If Statement
785 785
 				$image_thumb_size = 'course_single_image';
786
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
786
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
787 787
 				$width = $dimensions['width'];
788 788
 				$height = $dimensions['height'];
789 789
 
790 790
 			} else {
791 791
 
792
-				if ( !Sensei()->settings->settings[ 'course_archive_image_enable' ] ) {
792
+				if ( ! Sensei()->settings->settings['course_archive_image_enable']) {
793 793
 					return '';
794 794
 				} // End If Statement
795 795
 
796 796
 				$image_thumb_size = 'course_archive_image';
797
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
797
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
798 798
 				$width = $dimensions['width'];
799 799
 				$height = $dimensions['height'];
800 800
 
@@ -803,31 +803,31 @@  discard block
 block discarded – undo
803 803
 		} // End If Statement
804 804
 
805 805
 		$img_url = '';
806
-		if ( has_post_thumbnail( $course_id ) ) {
806
+		if (has_post_thumbnail($course_id)) {
807 807
    			// Get Featured Image
808
-   			$img_url = get_the_post_thumbnail( $course_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
808
+   			$img_url = get_the_post_thumbnail($course_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
809 809
  		} else {
810 810
 
811 811
 			// Check for a Lesson Image
812
-			$course_lessons = $this->course_lessons( $course_id );
812
+			$course_lessons = $this->course_lessons($course_id);
813 813
 
814
-			foreach ($course_lessons as $lesson_item){
815
-				if ( has_post_thumbnail( $lesson_item->ID ) ) {
814
+			foreach ($course_lessons as $lesson_item) {
815
+				if (has_post_thumbnail($lesson_item->ID)) {
816 816
 					// Get Featured Image
817
-					$img_url = get_the_post_thumbnail( $lesson_item->ID, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
818
-					if ( '' != $img_url ) {
817
+					$img_url = get_the_post_thumbnail($lesson_item->ID, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
818
+					if ('' != $img_url) {
819 819
 						break;
820 820
 					} // End If Statement
821 821
 
822 822
 				} // End If Statement
823 823
 			} // End For Loop
824 824
 
825
- 			if ( '' == $img_url ) {
825
+ 			if ('' == $img_url) {
826 826
 
827 827
  				// Display Image Placeholder if none
828
-				if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) {
828
+				if (Sensei()->settings->get('placeholder_images_enable')) {
829 829
 
830
-                    $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
830
+                    $img_url = apply_filters('sensei_course_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
831 831
 
832 832
 				} // End If Statement
833 833
 
@@ -835,17 +835,17 @@  discard block
 block discarded – undo
835 835
 
836 836
 		} // End If Statement
837 837
 
838
-		if ( '' != $img_url ) {
838
+		if ('' != $img_url) {
839 839
 
840
-			$html .= '<a href="' . get_permalink( $course_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $course_id ) ) . '">' . $img_url  .'</a>';
840
+			$html .= '<a href="'.get_permalink($course_id).'" title="'.esc_attr(get_post_field('post_title', $course_id)).'">'.$img_url.'</a>';
841 841
 
842 842
 		} // End If Statement
843 843
 
844
-        if( $return ){
844
+        if ($return) {
845 845
 
846 846
             return $html;
847 847
 
848
-        }else{
848
+        } else {
849 849
 
850 850
             echo $html;
851 851
 
@@ -862,9 +862,9 @@  discard block
 block discarded – undo
862 862
 	 * @param string $post_status (default: 'publish')
863 863
 	 * @return int
864 864
 	 */
865
-	public function course_count( $post_status = 'publish' ) {
865
+	public function course_count($post_status = 'publish') {
866 866
 
867
-		$post_args = array(	'post_type'         => 'course',
867
+		$post_args = array('post_type'         => 'course',
868 868
 							'posts_per_page'    => -1,
869 869
 //							'orderby'           => 'menu_order date',
870 870
 //							'order'             => 'ASC',
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
 
876 876
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
877 877
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
878
-		$courses_query = new WP_Query( apply_filters( 'sensei_course_count', $post_args ) );
878
+		$courses_query = new WP_Query(apply_filters('sensei_course_count', $post_args));
879 879
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
880 880
 
881
-		return count( $courses_query->posts );
881
+		return count($courses_query->posts);
882 882
 	} // End course_count()
883 883
 
884 884
 
@@ -891,42 +891,42 @@  discard block
 block discarded – undo
891 891
 	 * @param string $fields (default: 'all'). WP only allows 3 types, but we will limit it to only 'ids' or 'all'
892 892
 	 * @return array{ type WP_Post }  $posts_array
893 893
 	 */
894
-	public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) {
894
+	public function course_lessons($course_id = 0, $post_status = 'publish', $fields = 'all') {
895 895
 
896
-        if( is_a( $course_id, 'WP_Post' ) ){
896
+        if (is_a($course_id, 'WP_Post')) {
897 897
             $course_id = $course_id->ID;
898 898
         }
899 899
 
900
-		$post_args = array(	'post_type'         => 'lesson',
900
+		$post_args = array('post_type'         => 'lesson',
901 901
 							'posts_per_page'       => -1,
902 902
 							'orderby'           => 'date',
903 903
 							'order'             => 'ASC',
904 904
 							'meta_query'        => array(
905 905
 								array(
906 906
 									'key' => '_lesson_course',
907
-									'value' => intval( $course_id ),
907
+									'value' => intval($course_id),
908 908
 								),
909 909
 							),
910 910
 							'post_status'       => $post_status,
911 911
 							'suppress_filters'  => 0,
912 912
 							);
913
-		$query_results = new WP_Query( $post_args );
913
+		$query_results = new WP_Query($post_args);
914 914
         $lessons = $query_results->posts;
915 915
 
916 916
         // re order the lessons. This could not be done via the OR meta query as there may be lessons
917 917
         // with the course order for a different course and this should not be included. It could also not
918 918
         // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but
919 919
         // that have been added to the course.
920
-        if( count( $lessons) > 1  ){
920
+        if (count($lessons) > 1) {
921 921
 
922
-            foreach( $lessons as $lesson ){
922
+            foreach ($lessons as $lesson) {
923 923
 
924
-                $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) );
924
+                $order = intval(get_post_meta($lesson->ID, '_order_'.$course_id, true));
925 925
                 // for lessons with no order set it to be 10000 so that it show up at the end
926 926
                 $lesson->course_order = $order ? $order : 100000;
927 927
             }
928 928
 
929
-            uasort( $lessons, array( $this, '_short_course_lessons_callback' )   );
929
+            uasort($lessons, array($this, '_short_course_lessons_callback'));
930 930
         }
931 931
 
932 932
         /**
@@ -937,12 +937,12 @@  discard block
 block discarded – undo
937 937
          * @param array $lessons
938 938
          * @param int $course_id
939 939
          */
940
-        $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id  );
940
+        $lessons = apply_filters('sensei_course_get_lessons', $lessons, $course_id);
941 941
 
942 942
         //return the requested fields
943 943
         // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson
944 944
         // objects
945
-        if( 'ids' == $fields ) {
945
+        if ('ids' == $fields) {
946 946
             $lesson_objects = $lessons;
947 947
             $lessons = array();
948 948
 
@@ -964,9 +964,9 @@  discard block
 block discarded – undo
964 964
      * @param array $lesson_2
965 965
      * @return int
966 966
      */
967
-    protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){
967
+    protected function _short_course_lessons_callback($lesson_1, $lesson_2) {
968 968
 
969
-        if ( $lesson_1->course_order == $lesson_2->course_order ) {
969
+        if ($lesson_1->course_order == $lesson_2->course_order) {
970 970
             return 0;
971 971
         }
972 972
 
@@ -980,21 +980,21 @@  discard block
 block discarded – undo
980 980
 	 * @param  boolean $boolean_check True if a simple yes/no is required
981 981
 	 * @return array              Array of quiz post objects
982 982
 	 */
983
-	public function course_quizzes( $course_id = 0, $boolean_check = false ) {
983
+	public function course_quizzes($course_id = 0, $boolean_check = false) {
984 984
 
985 985
 
986 986
 		$course_quizzes = array();
987 987
 
988
-		if( $course_id ) {
989
-			$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
988
+		if ($course_id) {
989
+			$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
990 990
 
991
-			foreach( $lesson_ids as $lesson_id ) {
992
-				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
993
-				if ( $has_questions && $boolean_check ) {
991
+			foreach ($lesson_ids as $lesson_id) {
992
+				$has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
993
+				if ($has_questions && $boolean_check) {
994 994
 					return true;
995 995
 				}
996
-				elseif ( $has_questions ) {
997
-					$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
996
+				elseif ($has_questions) {
997
+					$quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
998 998
 //					$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
999 999
 //					if( count( $questions ) > 0 ) {
1000 1000
 						$course_quizzes[] = $quiz_id;
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 				}
1003 1003
 			}
1004 1004
 		}
1005
-		if ( $boolean_check && empty($course_quizzes) ) {
1005
+		if ($boolean_check && empty($course_quizzes)) {
1006 1006
 			$course_quizzes = false;
1007 1007
 		}
1008 1008
 		return $course_quizzes;
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  string $post_status (default: 'publish')
1018 1018
 	 * @return array
1019 1019
 	 */
1020
-	public function course_lessons_completed( $course_id = 0, $post_status = 'publish' ) {
1020
+	public function course_lessons_completed($course_id = 0, $post_status = 'publish') {
1021 1021
 
1022
-		return $this->course_lessons( $course_id, $post_status );
1022
+		return $this->course_lessons($course_id, $post_status);
1023 1023
 
1024 1024
 	} // End course_lessons_completed()
1025 1025
 
@@ -1032,9 +1032,9 @@  discard block
 block discarded – undo
1032 1032
 	 * @param  int $course_id (default: 0)
1033 1033
 	 * @return int
1034 1034
 	 */
1035
-	public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) {
1035
+	public function course_author_lesson_count($author_id = 0, $course_id = 0) {
1036 1036
 
1037
-        $lesson_args = array(	'post_type' 		=> 'lesson',
1037
+        $lesson_args = array('post_type' 		=> 'lesson',
1038 1038
 								'posts_per_page' 		=> -1,
1039 1039
 		    					'author'         	=> $author_id,
1040 1040
 		    					'meta_key'        	=> '_lesson_course',
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
     	    					'suppress_filters' 	=> 0,
1044 1044
 								'fields'            => 'ids', // less data to retrieve
1045 1045
 		    				);
1046
-		$lessons_array = get_posts( $lesson_args );
1047
-		$count = count( $lessons_array );
1046
+		$lessons_array = get_posts($lesson_args);
1047
+		$count = count($lessons_array);
1048 1048
 		return $count;
1049 1049
 
1050 1050
 	} // End course_author_lesson_count()
@@ -1056,9 +1056,9 @@  discard block
 block discarded – undo
1056 1056
 	 * @param  int $course_id (default: 0)
1057 1057
 	 * @return int
1058 1058
 	 */
1059
-	public function course_lesson_count( $course_id = 0 ) {
1059
+	public function course_lesson_count($course_id = 0) {
1060 1060
 
1061
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1061
+		$lesson_args = array('post_type' 		=> 'lesson',
1062 1062
 								'posts_per_page' 		=> -1,
1063 1063
 		    					'meta_key'        	=> '_lesson_course',
1064 1064
     							'meta_value'      	=> $course_id,
@@ -1066,9 +1066,9 @@  discard block
 block discarded – undo
1066 1066
     	    					'suppress_filters' 	=> 0,
1067 1067
 								'fields'            => 'ids', // less data to retrieve
1068 1068
 		    				);
1069
-		$lessons_array = get_posts( $lesson_args );
1069
+		$lessons_array = get_posts($lesson_args);
1070 1070
 
1071
-        $count = count( $lessons_array );
1071
+        $count = count($lessons_array);
1072 1072
 
1073 1073
         return $count;
1074 1074
 
@@ -1081,9 +1081,9 @@  discard block
 block discarded – undo
1081 1081
 	 * @param  int $course_id (default: 0)
1082 1082
 	 * @return int
1083 1083
 	 */
1084
-	public function course_lesson_preview_count( $course_id = 0 ) {
1084
+	public function course_lesson_preview_count($course_id = 0) {
1085 1085
 
1086
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1086
+		$lesson_args = array('post_type' 		=> 'lesson',
1087 1087
 								'posts_per_page' 		=> -1,
1088 1088
     	    					'post_status'      	=> 'publish',
1089 1089
     	    					'suppress_filters' 	=> 0,
@@ -1099,9 +1099,9 @@  discard block
 block discarded – undo
1099 1099
 								),
1100 1100
 								'fields'            => 'ids', // less data to retrieve
1101 1101
 		    				);
1102
-		$lessons_array = get_posts( $lesson_args );
1102
+		$lessons_array = get_posts($lesson_args);
1103 1103
 
1104
-		$count = count( $lessons_array );
1104
+		$count = count($lessons_array);
1105 1105
 
1106 1106
         return $count;
1107 1107
 
@@ -1114,12 +1114,12 @@  discard block
 block discarded – undo
1114 1114
 	 * @param  int $product_id (default: 0)
1115 1115
 	 * @return array
1116 1116
 	 */
1117
-	public function get_product_courses( $product_id = 0 ) {
1117
+	public function get_product_courses($product_id = 0) {
1118 1118
 
1119 1119
 		$posts_array = array();
1120 1120
 		// Check for WooCommerce
1121
-		if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) {
1122
-			$post_args = array(	'post_type' 		=> 'course',
1121
+		if (Sensei_WC::is_woocommerce_active() && 0 < $product_id) {
1122
+			$post_args = array('post_type' 		=> 'course',
1123 1123
 								'posts_per_page' 		=> -1,
1124 1124
 								'meta_key'        	=> '_course_woocommerce_product',
1125 1125
 	    						'meta_value'      	=> $product_id,
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 								'orderby' 			=> 'menu_order date',
1129 1129
 								'order' 			=> 'ASC',
1130 1130
 								);
1131
-			$posts_array = get_posts( $post_args );
1131
+			$posts_array = get_posts($post_args);
1132 1132
 		} // End If Statement
1133 1133
 		return $posts_array;
1134 1134
 
@@ -1139,17 +1139,17 @@  discard block
 block discarded – undo
1139 1139
 	 * @param  WP_Query $query
1140 1140
 	 * @return void
1141 1141
 	 */
1142
-	public function filter_my_courses( $query ) {
1142
+	public function filter_my_courses($query) {
1143 1143
 		global  $my_courses_section;
1144 1144
 
1145
-		if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1146
-			$amount = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1147
-			$query->set( 'posts_per_page', $amount );
1145
+		if (isset(Sensei()->settings->settings['my_course_amount']) && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1146
+			$amount = absint(Sensei()->settings->settings['my_course_amount']);
1147
+			$query->set('posts_per_page', $amount);
1148 1148
 		}
1149 1149
 
1150
-		if( isset( $_GET[ $my_courses_section . '_page' ] ) && 0 < intval( $_GET[ $my_courses_section . '_page' ] ) ) {
1151
-			$page = intval( $_GET[ $my_courses_section . '_page' ] );
1152
-			$query->set( 'paged', $page );
1150
+		if (isset($_GET[$my_courses_section.'_page']) && 0 < intval($_GET[$my_courses_section.'_page'])) {
1151
+			$page = intval($_GET[$my_courses_section.'_page']);
1152
+			$query->set('paged', $page);
1153 1153
 		}
1154 1154
 	}
1155 1155
 
@@ -1163,48 +1163,48 @@  discard block
 block discarded – undo
1163 1163
 	 * @param  boolean $manage Whether the user has permission to manage the courses
1164 1164
 	 * @return string          HTML displayng course data
1165 1165
 	 */
1166
-	public function load_user_courses_content( $user = false ) {
1166
+	public function load_user_courses_content($user = false) {
1167 1167
 		global $course, $my_courses_page, $my_courses_section;
1168 1168
 
1169
-        if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] )
1170
-            || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) {
1169
+        if ( ! isset(Sensei()->settings->settings['learner_profile_show_courses'])
1170
+            || ! Sensei()->settings->settings['learner_profile_show_courses']) {
1171 1171
 
1172 1172
             // do not show the content if the settings doesn't allow for it
1173 1173
             return;
1174 1174
 
1175 1175
         }
1176 1176
 
1177
-        $manage = ( $user->ID == get_current_user_id() ) ? true : false;
1177
+        $manage = ($user->ID == get_current_user_id()) ? true : false;
1178 1178
 
1179
-        do_action( 'sensei_before_learner_course_content', $user );
1179
+        do_action('sensei_before_learner_course_content', $user);
1180 1180
 
1181 1181
 		// Build Output HTML
1182 1182
 		$complete_html = $active_html = '';
1183 1183
 
1184
-		if( is_a( $user, 'WP_User' ) ) {
1184
+		if (is_a($user, 'WP_User')) {
1185 1185
 
1186 1186
 			$my_courses_page = true;
1187 1187
 
1188 1188
 			// Allow action to be run before My Courses content has loaded
1189
-			do_action( 'sensei_before_my_courses', $user->ID );
1189
+			do_action('sensei_before_my_courses', $user->ID);
1190 1190
 
1191 1191
 			// Logic for Active and Completed Courses
1192 1192
 			$per_page = 20;
1193
-			if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] )
1194
-                && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1193
+			if (isset(Sensei()->settings->settings['my_course_amount'])
1194
+                && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1195 1195
 
1196
-				$per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1196
+				$per_page = absint(Sensei()->settings->settings['my_course_amount']);
1197 1197
 
1198 1198
 			}
1199 1199
 
1200
-			$course_statuses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user->ID, 'type' => 'sensei_course_status' ), true );
1200
+			$course_statuses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true);
1201 1201
 			// User may only be on 1 Course
1202
-			if ( !is_array($course_statuses) ) {
1203
-				$course_statuses = array( $course_statuses );
1202
+			if ( ! is_array($course_statuses)) {
1203
+				$course_statuses = array($course_statuses);
1204 1204
 			}
1205 1205
 			$completed_ids = $active_ids = array();
1206
-			foreach( $course_statuses as $course_status ) {
1207
-				if ( Sensei_Utils::user_completed_course( $course_status, $user->ID ) ) {
1206
+			foreach ($course_statuses as $course_status) {
1207
+				if (Sensei_Utils::user_completed_course($course_status, $user->ID)) {
1208 1208
 					$completed_ids[] = $course_status->comment_post_ID;
1209 1209
 				} else {
1210 1210
 					$active_ids[] = $course_status->comment_post_ID;
@@ -1214,41 +1214,41 @@  discard block
 block discarded – undo
1214 1214
 			$active_count = $completed_count = 0;
1215 1215
 
1216 1216
 			$active_courses = array();
1217
-			if ( 0 < intval( count( $active_ids ) ) ) {
1217
+			if (0 < intval(count($active_ids))) {
1218 1218
 				$my_courses_section = 'active';
1219
-				$active_courses = Sensei()->course->course_query( $per_page, 'usercourses', $active_ids );
1220
-				$active_count = count( $active_ids );
1219
+				$active_courses = Sensei()->course->course_query($per_page, 'usercourses', $active_ids);
1220
+				$active_count = count($active_ids);
1221 1221
 			} // End If Statement
1222 1222
 
1223 1223
 			$completed_courses = array();
1224
-			if ( 0 < intval( count( $completed_ids ) ) ) {
1224
+			if (0 < intval(count($completed_ids))) {
1225 1225
 				$my_courses_section = 'completed';
1226
-				$completed_courses = Sensei()->course->course_query( $per_page, 'usercourses', $completed_ids );
1227
-				$completed_count = count( $completed_ids );
1226
+				$completed_courses = Sensei()->course->course_query($per_page, 'usercourses', $completed_ids);
1227
+				$completed_count = count($completed_ids);
1228 1228
 			} // End If Statement
1229 1229
 
1230
-			foreach ( $active_courses as $course_item ) {
1230
+			foreach ($active_courses as $course_item) {
1231 1231
 
1232
-				$course_lessons =  Sensei()->course->course_lessons( $course_item->ID );
1232
+				$course_lessons = Sensei()->course->course_lessons($course_item->ID);
1233 1233
 				$lessons_completed = 0;
1234
-				foreach ( $course_lessons as $lesson ) {
1235
-					if ( Sensei_Utils::user_completed_lesson( $lesson->ID, $user->ID ) ) {
1234
+				foreach ($course_lessons as $lesson) {
1235
+					if (Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) {
1236 1236
 						++$lessons_completed;
1237 1237
 					}
1238 1238
 				}
1239 1239
 
1240 1240
 			    // Get Course Categories
1241
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1241
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1242 1242
 
1243
-                $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">';
1243
+                $active_html .= '<article class="'.esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))).'">';
1244 1244
 
1245 1245
                 // Image
1246
-                $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true );
1246
+                $active_html .= Sensei()->course->course_image(absint($course_item->ID), '100', '100', true);
1247 1247
 
1248 1248
                 // Title
1249 1249
                 $active_html .= '<header>';
1250 1250
 
1251
-                $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1251
+                $active_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1252 1252
 
1253 1253
                 $active_html .= '</header>';
1254 1254
 
@@ -1257,74 +1257,74 @@  discard block
 block discarded – undo
1257 1257
                 $active_html .= '<p class="sensei-course-meta">';
1258 1258
 
1259 1259
                 // Author
1260
-                $user_info = get_userdata( absint( $course_item->post_author ) );
1261
-                if ( isset( Sensei()->settings->settings[ 'course_author' ] )
1262
-                    && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1260
+                $user_info = get_userdata(absint($course_item->post_author));
1261
+                if (isset(Sensei()->settings->settings['course_author'])
1262
+                    && (Sensei()->settings->settings['course_author'])) {
1263 1263
 
1264 1264
                     $active_html .= '<span class="course-author">'
1265
-                        . __( 'by ', 'woothemes-sensei' )
1266
-                        . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) )
1267
-                        . '" title="' . esc_attr( $user_info->display_name ) . '">'
1268
-                        . esc_html( $user_info->display_name )
1265
+                        . __('by ', 'woothemes-sensei')
1266
+                        . '<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author)))
1267
+                        . '" title="'.esc_attr($user_info->display_name).'">'
1268
+                        . esc_html($user_info->display_name)
1269 1269
                         . '</a></span>';
1270 1270
 
1271 1271
                 } // End If Statement
1272 1272
 
1273 1273
                 // Lesson count for this author
1274
-                $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) );
1274
+                $lesson_count = Sensei()->course->course_lesson_count(absint($course_item->ID));
1275 1275
                 // Handle Division by Zero
1276
-                if ( 0 == $lesson_count ) {
1276
+                if (0 == $lesson_count) {
1277 1277
 
1278 1278
                     $lesson_count = 1;
1279 1279
 
1280 1280
                 } // End If Statement
1281
-                $active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ) . '</span>';
1281
+                $active_html .= '<span class="course-lesson-count">'.$lesson_count.'&nbsp;'.__('Lessons', 'woothemes-sensei').'</span>';
1282 1282
                 // Course Categories
1283
-                if ( '' != $category_output ) {
1283
+                if ('' != $category_output) {
1284 1284
 
1285
-                    $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1285
+                    $active_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1286 1286
 
1287 1287
                 } // End If Statement
1288
-                $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count  ) . '</span>';
1288
+                $active_html .= '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count).'</span>';
1289 1289
 
1290 1290
                 $active_html .= '</p>';
1291 1291
 
1292
-                $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1292
+                $active_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1293 1293
 
1294 1294
 
1295 1295
 
1296
-                $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) );
1296
+                $progress_percentage = abs(round((doubleval($lessons_completed) * 100) / ($lesson_count), 0));
1297 1297
 
1298
-                $active_html .= $this->get_progress_meter( $progress_percentage );
1298
+                $active_html .= $this->get_progress_meter($progress_percentage);
1299 1299
 
1300 1300
                 $active_html .= '</section>';
1301 1301
 
1302
-                if( is_user_logged_in() ) {
1302
+                if (is_user_logged_in()) {
1303 1303
 
1304 1304
                     $active_html .= '<section class="entry-actions">';
1305 1305
 
1306
-                    $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">';
1306
+                    $active_html .= '<form method="POST" action="'.esc_url(remove_query_arg(array('active_page', 'completed_page'))).'">';
1307 1307
 
1308
-                    $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />';
1308
+                    $active_html .= '<input type="hidden" name="'.esc_attr('woothemes_sensei_complete_course_noonce').'" id="'.esc_attr('woothemes_sensei_complete_course_noonce').'" value="'.esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')).'" />';
1309 1309
 
1310
-                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />';
1310
+                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="'.esc_attr(absint($course_item->ID)).'" />';
1311 1311
 
1312
-                    if ( 0 < absint( count( $course_lessons ) )
1313
-                        && Sensei()->settings->settings['course_completion'] == 'complete' ){
1312
+                    if (0 < absint(count($course_lessons))
1313
+                        && Sensei()->settings->settings['course_completion'] == 'complete') {
1314 1314
 
1315 1315
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="'
1316
-                            .  __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>';
1316
+                            .  __('Mark as Complete', 'woothemes-sensei').'"/> </span>';
1317 1317
 
1318 1318
                     } // End If Statement
1319 1319
 
1320 1320
                     $course_purchased = false;
1321
-                    if ( Sensei_WC::is_woocommerce_active() ) {
1321
+                    if (Sensei_WC::is_woocommerce_active()) {
1322 1322
 
1323 1323
                         // Get the product ID
1324
-                        $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true );
1325
-                        if ( 0 < $wc_post_id ) {
1324
+                        $wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true);
1325
+                        if (0 < $wc_post_id) {
1326 1326
 
1327
-                            $course_purchased = Sensei_WC::has_customer_bought_product(  $user->ID, $wc_post_id );
1327
+                            $course_purchased = Sensei_WC::has_customer_bought_product($user->ID, $wc_post_id);
1328 1328
 
1329 1329
                         } // End If Statement
1330 1330
 
@@ -1333,12 +1333,12 @@  discard block
 block discarded – undo
1333 1333
 	                /**
1334 1334
 	                 * documented in class-sensei-course.php the_course_action_buttons function
1335 1335
 	                 */
1336
-	                $show_delete_course_button = apply_filters( 'sensei_show_delete_course_button', false );
1336
+	                $show_delete_course_button = apply_filters('sensei_show_delete_course_button', false);
1337 1337
 
1338
-                    if ( false == $course_purchased && $show_delete_course_button ) {
1338
+                    if (false == $course_purchased && $show_delete_course_button) {
1339 1339
 
1340 1340
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="'
1341
-                            .  __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>';
1341
+                            .  __('Delete Course', 'woothemes-sensei').'"/></span>';
1342 1342
 
1343 1343
                     } // End If Statement
1344 1344
 
@@ -1351,54 +1351,54 @@  discard block
 block discarded – undo
1351 1351
 			}
1352 1352
 
1353 1353
 			// Active pagination
1354
-			if( $active_count > $per_page ) {
1354
+			if ($active_count > $per_page) {
1355 1355
 
1356 1356
 				$current_page = 1;
1357
-				if( isset( $_GET['active_page'] ) && 0 < intval( $_GET['active_page'] ) ) {
1357
+				if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
1358 1358
 					$current_page = $_GET['active_page'];
1359 1359
 				}
1360 1360
 
1361 1361
 				$active_html .= '<nav class="pagination woo-pagination">';
1362
-				$total_pages = ceil( $active_count / $per_page );
1362
+				$total_pages = ceil($active_count / $per_page);
1363 1363
 
1364
-				if( $current_page > 1 ) {
1365
-					$prev_link = add_query_arg( 'active_page', $current_page - 1 );
1366
-					$active_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1364
+				if ($current_page > 1) {
1365
+					$prev_link = add_query_arg('active_page', $current_page - 1);
1366
+					$active_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1367 1367
 				}
1368 1368
 
1369
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1370
-					$link = add_query_arg( 'active_page', $i );
1369
+				for ($i = 1; $i <= $total_pages; $i++) {
1370
+					$link = add_query_arg('active_page', $i);
1371 1371
 
1372
-					if( $i == $current_page ) {
1373
-						$active_html .= '<span class="page-numbers current">' . $i . '</span> ';
1372
+					if ($i == $current_page) {
1373
+						$active_html .= '<span class="page-numbers current">'.$i.'</span> ';
1374 1374
 					} else {
1375
-						$active_html .= '<a class="page-numbers" href="' . esc_url( $link ). '">' . $i . '</a> ';
1375
+						$active_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1376 1376
 					}
1377 1377
 				}
1378 1378
 
1379
-				if( $current_page < $total_pages ) {
1380
-					$next_link = add_query_arg( 'active_page', $current_page + 1 );
1381
-					$active_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1379
+				if ($current_page < $total_pages) {
1380
+					$next_link = add_query_arg('active_page', $current_page + 1);
1381
+					$active_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1382 1382
 				}
1383 1383
 
1384 1384
 				$active_html .= '</nav>';
1385 1385
 			}
1386 1386
 
1387
-			foreach ( $completed_courses as $course_item ) {
1387
+			foreach ($completed_courses as $course_item) {
1388 1388
 				$course = $course_item;
1389 1389
 
1390 1390
 			    // Get Course Categories
1391
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1391
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1392 1392
 
1393
-		    	$complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">';
1393
+		    	$complete_html .= '<article class="'.join(' ', get_post_class(array('course', 'post'), $course_item->ID)).'">';
1394 1394
 
1395 1395
 		    	    // Image
1396
-		    		$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true );
1396
+		    		$complete_html .= Sensei()->course->course_image(absint($course_item->ID), 100, 100, true);
1397 1397
 
1398 1398
 		    		// Title
1399 1399
 		    		$complete_html .= '<header>';
1400 1400
 
1401
-		    		    $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1401
+		    		    $complete_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1402 1402
 
1403 1403
 		    		$complete_html .= '</header>';
1404 1404
 
@@ -1407,49 +1407,49 @@  discard block
 block discarded – undo
1407 1407
 		    			$complete_html .= '<p class="sensei-course-meta">';
1408 1408
 
1409 1409
 		    		    	// Author
1410
-		    		    	$user_info = get_userdata( absint( $course_item->post_author ) );
1411
-		    		    	if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1412
-		    		    		$complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
1410
+		    		    	$user_info = get_userdata(absint($course_item->post_author));
1411
+		    		    	if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {
1412
+		    		    		$complete_html .= '<span class="course-author">'.__('by ', 'woothemes-sensei').'<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
1413 1413
 		    		    	} // End If Statement
1414 1414
 
1415 1415
 		    		    	// Lesson count for this author
1416 1416
 		    		    	$complete_html .= '<span class="course-lesson-count">'
1417
-                                . Sensei()->course->course_lesson_count( absint( $course_item->ID ) )
1418
-                                . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' )
1417
+                                . Sensei()->course->course_lesson_count(absint($course_item->ID))
1418
+                                . '&nbsp;'.__('Lessons', 'woothemes-sensei')
1419 1419
                                 . '</span>';
1420 1420
 
1421 1421
 		    		    	// Course Categories
1422
-		    		    	if ( '' != $category_output ) {
1422
+		    		    	if ('' != $category_output) {
1423 1423
 
1424
-		    		    		$complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1424
+		    		    		$complete_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1425 1425
 
1426 1426
 		    		    	} // End If Statement
1427 1427
 
1428 1428
 						$complete_html .= '</p>';
1429 1429
 
1430
-						$complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1430
+						$complete_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1431 1431
 
1432
-                        $complete_html .= $this->get_progress_meter( 100 );
1432
+                        $complete_html .= $this->get_progress_meter(100);
1433 1433
 
1434
-						if( $manage ) {
1435
-							$has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true );
1434
+						if ($manage) {
1435
+							$has_quizzes = Sensei()->course->course_quizzes($course_item->ID, true);
1436 1436
 							// Output only if there is content to display
1437
-							if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) {
1437
+							if (has_filter('sensei_results_links') || $has_quizzes) {
1438 1438
 
1439 1439
 
1440 1440
 								$complete_html .= '<p class="sensei-results-links">';
1441 1441
 								$results_link = '';
1442
-								if( $has_quizzes ) {
1442
+								if ($has_quizzes) {
1443 1443
 
1444 1444
 									$results_link = '<a class="button view-results" href="'
1445
-                                        . Sensei()->course_results->get_permalink( $course_item->ID )
1446
-                                        . '">' . __( 'View results', 'woothemes-sensei' )
1445
+                                        . Sensei()->course_results->get_permalink($course_item->ID)
1446
+                                        . '">'.__('View results', 'woothemes-sensei')
1447 1447
                                         . '</a>';
1448 1448
 								}
1449 1449
                                 /**
1450 1450
                                  * Filter documented in Sensei_Course::the_course_action_buttons
1451 1451
                                  */
1452
-								$complete_html .= apply_filters( 'sensei_results_links', $results_link, $course_item->ID );
1452
+								$complete_html .= apply_filters('sensei_results_links', $results_link, $course_item->ID);
1453 1453
 								$complete_html .= '</p>';
1454 1454
 
1455 1455
 							}
@@ -1461,35 +1461,35 @@  discard block
 block discarded – undo
1461 1461
 			}
1462 1462
 
1463 1463
 			// Active pagination
1464
-			if( $completed_count > $per_page ) {
1464
+			if ($completed_count > $per_page) {
1465 1465
 
1466 1466
 				$current_page = 1;
1467
-				if( isset( $_GET['completed_page'] ) && 0 < intval( $_GET['completed_page'] ) ) {
1467
+				if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) {
1468 1468
 					$current_page = $_GET['completed_page'];
1469 1469
 				}
1470 1470
 
1471 1471
 				$complete_html .= '<nav class="pagination woo-pagination">';
1472
-				$total_pages = ceil( $completed_count / $per_page );
1472
+				$total_pages = ceil($completed_count / $per_page);
1473 1473
 
1474 1474
 
1475
-				if( $current_page > 1 ) {
1476
-					$prev_link = add_query_arg( 'completed_page', $current_page - 1 );
1477
-					$complete_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1475
+				if ($current_page > 1) {
1476
+					$prev_link = add_query_arg('completed_page', $current_page - 1);
1477
+					$complete_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1478 1478
 				}
1479 1479
 
1480
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1481
-					$link = add_query_arg( 'completed_page', $i );
1480
+				for ($i = 1; $i <= $total_pages; $i++) {
1481
+					$link = add_query_arg('completed_page', $i);
1482 1482
 
1483
-					if( $i == $current_page ) {
1484
-						$complete_html .= '<span class="page-numbers current">' . $i . '</span> ';
1483
+					if ($i == $current_page) {
1484
+						$complete_html .= '<span class="page-numbers current">'.$i.'</span> ';
1485 1485
 					} else {
1486
-						$complete_html .= '<a class="page-numbers" href="' . esc_url( $link ) . '">' . $i . '</a> ';
1486
+						$complete_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1487 1487
 					}
1488 1488
 				}
1489 1489
 
1490
-				if( $current_page < $total_pages ) {
1491
-					$next_link = add_query_arg( 'completed_page', $current_page + 1 );
1492
-					$complete_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1490
+				if ($current_page < $total_pages) {
1491
+					$next_link = add_query_arg('completed_page', $current_page + 1);
1492
+					$complete_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1493 1493
 				}
1494 1494
 
1495 1495
 				$complete_html .= '</nav>';
@@ -1497,26 +1497,26 @@  discard block
 block discarded – undo
1497 1497
 
1498 1498
 		} // End If Statement
1499 1499
 
1500
-		if( $manage ) {
1501
-			$no_active_message = __( 'You have no active courses.', 'woothemes-sensei' );
1502
-			$no_complete_message = __( 'You have not completed any courses yet.', 'woothemes-sensei' );
1500
+		if ($manage) {
1501
+			$no_active_message = __('You have no active courses.', 'woothemes-sensei');
1502
+			$no_complete_message = __('You have not completed any courses yet.', 'woothemes-sensei');
1503 1503
 		} else {
1504
-			$no_active_message =  __( 'This learner has no active courses.', 'woothemes-sensei' );
1505
-			$no_complete_message =  __( 'This learner has not completed any courses yet.', 'woothemes-sensei' );
1504
+			$no_active_message = __('This learner has no active courses.', 'woothemes-sensei');
1505
+			$no_complete_message = __('This learner has not completed any courses yet.', 'woothemes-sensei');
1506 1506
 		}
1507 1507
 
1508 1508
 		ob_start();
1509 1509
 		?>
1510 1510
 
1511
-		<?php do_action( 'sensei_before_user_courses' ); ?>
1511
+		<?php do_action('sensei_before_user_courses'); ?>
1512 1512
 
1513 1513
 		<?php
1514
-		if( $manage && ( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) ) {
1514
+		if ($manage && ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable'])) {
1515 1515
 			?>
1516 1516
 			<p class="my-messages-link-container">
1517
-                <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>"
1518
-                   title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>">
1519
-                    <?php _e( 'My Messages', 'woothemes-sensei' ); ?>
1517
+                <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>"
1518
+                   title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>">
1519
+                    <?php _e('My Messages', 'woothemes-sensei'); ?>
1520 1520
                 </a>
1521 1521
             </p>
1522 1522
 			<?php
@@ -1525,11 +1525,11 @@  discard block
 block discarded – undo
1525 1525
 		<div id="my-courses">
1526 1526
 
1527 1527
 		    <ul>
1528
-		    	<li><a href="#active-courses"><?php  _e( 'Active Courses', 'woothemes-sensei' ); ?></a></li>
1529
-		    	<li><a href="#completed-courses"><?php  _e( 'Completed Courses', 'woothemes-sensei' ); ?></a></li>
1528
+		    	<li><a href="#active-courses"><?php  _e('Active Courses', 'woothemes-sensei'); ?></a></li>
1529
+		    	<li><a href="#completed-courses"><?php  _e('Completed Courses', 'woothemes-sensei'); ?></a></li>
1530 1530
 		    </ul>
1531 1531
 
1532
-		    <?php do_action( 'sensei_before_active_user_courses' ); ?>
1532
+		    <?php do_action('sensei_before_active_user_courses'); ?>
1533 1533
 
1534 1534
 		    <?php
1535 1535
             $course_page_url = Sensei_Course::get_courses_page_url();
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 
1538 1538
 		    <div id="active-courses">
1539 1539
 
1540
-		    	<?php if ( '' != $active_html ) {
1540
+		    	<?php if ('' != $active_html) {
1541 1541
 
1542 1542
 		    		echo $active_html;
1543 1543
 
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
 
1550 1550
                         <a href="<?php echo $course_page_url; ?>">
1551 1551
 
1552
-                            <?php  _e( 'Start a Course!', 'woothemes-sensei' ); ?>
1552
+                            <?php  _e('Start a Course!', 'woothemes-sensei'); ?>
1553 1553
 
1554 1554
                         </a>
1555 1555
 
@@ -1559,13 +1559,13 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
 		    </div>
1561 1561
 
1562
-		    <?php do_action( 'sensei_after_active_user_courses' ); ?>
1562
+		    <?php do_action('sensei_after_active_user_courses'); ?>
1563 1563
 
1564
-		    <?php do_action( 'sensei_before_completed_user_courses' ); ?>
1564
+		    <?php do_action('sensei_before_completed_user_courses'); ?>
1565 1565
 
1566 1566
 		    <div id="completed-courses">
1567 1567
 
1568
-		    	<?php if ( '' != $complete_html ) {
1568
+		    	<?php if ('' != $complete_html) {
1569 1569
 
1570 1570
 		    		echo $complete_html;
1571 1571
 
@@ -1581,16 +1581,16 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
 		    </div>
1583 1583
 
1584
-		    <?php do_action( 'sensei_after_completed_user_courses' ); ?>
1584
+		    <?php do_action('sensei_after_completed_user_courses'); ?>
1585 1585
 
1586 1586
 		</div>
1587 1587
 
1588
-		<?php do_action( 'sensei_after_user_courses' ); ?>
1588
+		<?php do_action('sensei_after_user_courses'); ?>
1589 1589
 
1590 1590
 		<?php
1591 1591
         echo ob_get_clean();
1592 1592
 
1593
-        do_action( 'sensei_after_learner_course_content', $user );
1593
+        do_action('sensei_after_learner_course_content', $user);
1594 1594
 
1595 1595
 	} // end load_user_courses_content
1596 1596
 
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
      *  @type $course WP_Post
1603 1603
      * }
1604 1604
      */
1605
-    public static function get_all_courses(){
1605
+    public static function get_all_courses() {
1606 1606
 
1607 1607
         $args = array(
1608 1608
                'post_type' => 'course',
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
                 'suppress_filters' 	=> 0,
1614 1614
         );
1615 1615
 
1616
-        $wp_query_obj =  new WP_Query( $args );
1616
+        $wp_query_obj = new WP_Query($args);
1617 1617
 
1618 1618
         /**
1619 1619
          * sensei_get_all_courses filter
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
          * }
1626 1626
          * @param array $attributes
1627 1627
          */
1628
-        return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts );
1628
+        return apply_filters('sensei_get_all_courses', $wp_query_obj->posts);
1629 1629
 
1630 1630
     }// end get_all_courses
1631 1631
 
@@ -1636,16 +1636,16 @@  discard block
 block discarded – undo
1636 1636
      * @param int $progress_percentage 0 - 100
1637 1637
      * @return string $progress_bar_html
1638 1638
      */
1639
-    public function get_progress_meter( $progress_percentage ){
1639
+    public function get_progress_meter($progress_percentage) {
1640 1640
 
1641
-        if ( 50 < $progress_percentage ) {
1641
+        if (50 < $progress_percentage) {
1642 1642
             $class = ' green';
1643
-        } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) {
1643
+        } elseif (25 <= $progress_percentage && 50 >= $progress_percentage) {
1644 1644
             $class = ' orange';
1645 1645
         } else {
1646 1646
             $class = ' red';
1647 1647
         }
1648
-        $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>';
1648
+        $progress_bar_html = '<div class="meter'.esc_attr($class).'"><span style="width: '.$progress_percentage.'%">'.round($progress_percentage).'%</span></div>';
1649 1649
 
1650 1650
         return $progress_bar_html;
1651 1651
 
@@ -1660,17 +1660,17 @@  discard block
 block discarded – undo
1660 1660
      *
1661 1661
      * @return string $statement_html
1662 1662
      */
1663
-    public function get_progress_statement( $course_id, $user_id ){
1663
+    public function get_progress_statement($course_id, $user_id) {
1664 1664
 
1665
-        if( empty( $course_id ) || empty( $user_id )
1666
-        || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){
1665
+        if (empty($course_id) || empty($user_id)
1666
+        || ! Sensei_Utils::user_started_course($course_id, $user_id)) {
1667 1667
             return '';
1668 1668
         }
1669 1669
 
1670
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1671
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1670
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1671
+        $total_lessons = count($this->course_lessons($course_id));
1672 1672
 
1673
-        $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons );
1673
+        $statement = sprintf(_n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons);
1674 1674
 
1675 1675
         /**
1676 1676
          * Filter the course completion statement.
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
          *
1679 1679
          * @param string $statement
1680 1680
          */
1681
-        return apply_filters( 'sensei_course_completion_statement', $statement );
1681
+        return apply_filters('sensei_course_completion_statement', $statement);
1682 1682
 
1683 1683
     }// end generate_progress_statement
1684 1684
 
@@ -1688,17 +1688,17 @@  discard block
 block discarded – undo
1688 1688
      * @param $course_id
1689 1689
      * @return void
1690 1690
      */
1691
-    public function the_progress_statement( $course_id = 0, $user_id = 0 ){
1692
-        if( empty( $course_id ) ){
1691
+    public function the_progress_statement($course_id = 0, $user_id = 0) {
1692
+        if (empty($course_id)) {
1693 1693
             global $post;
1694 1694
             $course_id = $post->ID;
1695 1695
         }
1696 1696
 
1697
-        if( empty( $user_id ) ){
1697
+        if (empty($user_id)) {
1698 1698
             $user_id = get_current_user_id();
1699 1699
         }
1700 1700
 
1701
-        echo '<span class="progress statement  course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id  ) . '</span>';
1701
+        echo '<span class="progress statement  course-completion-rate">'.$this->get_progress_statement($course_id, $user_id).'</span>';
1702 1702
     }
1703 1703
 
1704 1704
     /**
@@ -1707,24 +1707,24 @@  discard block
 block discarded – undo
1707 1707
      * @param $course_id
1708 1708
      * @return void
1709 1709
      */
1710
-    public function the_progress_meter( $course_id = 0, $user_id = 0 ){
1710
+    public function the_progress_meter($course_id = 0, $user_id = 0) {
1711 1711
 
1712
-        if( empty( $course_id ) ){
1712
+        if (empty($course_id)) {
1713 1713
             global $post;
1714 1714
             $course_id = $post->ID;
1715 1715
         }
1716 1716
 
1717
-        if( empty( $user_id ) ){
1717
+        if (empty($user_id)) {
1718 1718
             $user_id = get_current_user_id();
1719 1719
         }
1720 1720
 
1721
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id )
1722
-            || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){
1721
+        if ('course' != get_post_type($course_id) || ! get_userdata($user_id)
1722
+            || ! Sensei_Utils::user_started_course($course_id, $user_id)) {
1723 1723
             return;
1724 1724
         }
1725
-        $percentage_completed = $this->get_completion_percentage( $course_id, $user_id );
1725
+        $percentage_completed = $this->get_completion_percentage($course_id, $user_id);
1726 1726
 
1727
-        echo $this->get_progress_meter( $percentage_completed );
1727
+        echo $this->get_progress_meter($percentage_completed);
1728 1728
 
1729 1729
     }// end the_progress_meter
1730 1730
 
@@ -1737,20 +1737,20 @@  discard block
 block discarded – undo
1737 1737
      * @param int $user_id
1738 1738
      * @return array $completed_lesson_ids
1739 1739
      */
1740
-    public function get_completed_lesson_ids( $course_id, $user_id = 0 ){
1740
+    public function get_completed_lesson_ids($course_id, $user_id = 0) {
1741 1741
 
1742
-        if( !( intval( $user_id ) ) > 0 ){
1742
+        if ( ! (intval($user_id)) > 0) {
1743 1743
             $user_id = get_current_user_id();
1744 1744
         }
1745 1745
 
1746 1746
         $completed_lesson_ids = array();
1747 1747
 
1748
-        $course_lessons = $this->course_lessons( $course_id );
1748
+        $course_lessons = $this->course_lessons($course_id);
1749 1749
 
1750
-        foreach( $course_lessons as $lesson ){
1750
+        foreach ($course_lessons as $lesson) {
1751 1751
 
1752
-            $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id );
1753
-            if( $is_lesson_completed ){
1752
+            $is_lesson_completed = Sensei_Utils::user_completed_lesson($lesson->ID, $user_id);
1753
+            if ($is_lesson_completed) {
1754 1754
                 $completed_lesson_ids[] = $lesson->ID;
1755 1755
             }
1756 1756
 
@@ -1769,19 +1769,19 @@  discard block
 block discarded – undo
1769 1769
      * @param int $user_id
1770 1770
      * @return int $percentage
1771 1771
      */
1772
-    public function get_completion_percentage( $course_id, $user_id = 0 ){
1772
+    public function get_completion_percentage($course_id, $user_id = 0) {
1773 1773
 
1774
-        if( !( intval( $user_id ) ) > 0 ){
1774
+        if ( ! (intval($user_id)) > 0) {
1775 1775
             $user_id = get_current_user_id();
1776 1776
         }
1777 1777
 
1778
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1778
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1779 1779
 
1780
-        if( ! (  $completed  > 0 ) ){
1780
+        if ( ! ($completed > 0)) {
1781 1781
             return 0;
1782 1782
         }
1783 1783
 
1784
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1784
+        $total_lessons = count($this->course_lessons($course_id));
1785 1785
         $percentage = $completed / $total_lessons * 100;
1786 1786
 
1787 1787
         /**
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
          * @param $user_id
1794 1794
          * @since 1.8.0
1795 1795
          */
1796
-        return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id );
1796
+        return apply_filters('sensei_course_completion_percentage', $percentage, $course_id, $user_id);
1797 1797
 
1798 1798
     }// end get_completed_lesson_ids
1799 1799
 
@@ -1805,28 +1805,28 @@  discard block
 block discarded – undo
1805 1805
      * @param $should_send
1806 1806
      * @return bool
1807 1807
      */
1808
-    public function block_notification_emails( $should_send ){
1808
+    public function block_notification_emails($should_send) {
1809 1809
         global $sensei_email_data;
1810 1810
         $email = $sensei_email_data;
1811 1811
 
1812 1812
         $course_id = '';
1813 1813
 
1814
-        if( isset( $email['course_id'] ) ){
1814
+        if (isset($email['course_id'])) {
1815 1815
 
1816 1816
             $course_id = $email['course_id'];
1817 1817
 
1818
-        }elseif( isset( $email['lesson_id'] ) ){
1818
+        }elseif (isset($email['lesson_id'])) {
1819 1819
 
1820
-            $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1820
+            $course_id = Sensei()->lesson->get_course_id($email['lesson_id']);
1821 1821
 
1822
-        }elseif( isset( $email['quiz_id'] ) ){
1822
+        }elseif (isset($email['quiz_id'])) {
1823 1823
 
1824
-            $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1825
-            $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1824
+            $lesson_id = Sensei()->quiz->get_lesson_id($email['quiz_id']);
1825
+            $course_id = Sensei()->lesson->get_course_id($lesson_id);
1826 1826
 
1827 1827
         }
1828 1828
 
1829
-        if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) {
1829
+        if ( ! empty($course_id) && 'course' == get_post_type($course_id)) {
1830 1830
 
1831 1831
             $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true);
1832 1832
 
@@ -1847,19 +1847,19 @@  discard block
 block discarded – undo
1847 1847
      * @since 1.8.0
1848 1848
      * @param $course
1849 1849
      */
1850
-    public function course_notification_meta_box_content( $course ){
1850
+    public function course_notification_meta_box_content($course) {
1851 1851
 
1852
-        $checked = get_post_meta( $course->ID , 'disable_notification', true );
1852
+        $checked = get_post_meta($course->ID, 'disable_notification', true);
1853 1853
 
1854 1854
         // generate checked html
1855 1855
         $checked_html = '';
1856
-        if( $checked ){
1856
+        if ($checked) {
1857 1857
             $checked_html = 'checked="checked"';
1858 1858
         }
1859
-        wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' );
1859
+        wp_nonce_field('update-course-notification-setting', '_sensei_course_notification');
1860 1860
 
1861
-        echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >';
1862
-        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>';
1861
+        echo '<input id="disable_sensei_course_notification" '.$checked_html.' type="checkbox" name="disable_sensei_course_notification" >';
1862
+        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei').'</label>';
1863 1863
 
1864 1864
     }// end course_notification_meta_box_content
1865 1865
 
@@ -1871,20 +1871,20 @@  discard block
 block discarded – undo
1871 1871
      *
1872 1872
      * @param $course_id
1873 1873
      */
1874
-    public function save_course_notification_meta_box( $course_id ){
1874
+    public function save_course_notification_meta_box($course_id) {
1875 1875
 
1876
-        if( !isset( $_POST['_sensei_course_notification']  )
1877
-            || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){
1876
+        if ( ! isset($_POST['_sensei_course_notification'])
1877
+            || ! wp_verify_nonce($_POST['_sensei_course_notification'], 'update-course-notification-setting')) {
1878 1878
             return;
1879 1879
         }
1880 1880
 
1881
-        if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1881
+        if (isset($_POST['disable_sensei_course_notification']) && 'on' == $_POST['disable_sensei_course_notification']) {
1882 1882
             $new_val = true;
1883
-        }else{
1883
+        } else {
1884 1884
             $new_val = false;
1885 1885
         }
1886 1886
 
1887
-       update_post_meta( $course_id , 'disable_notification', $new_val );
1887
+       update_post_meta($course_id, 'disable_notification', $new_val);
1888 1888
 
1889 1889
     }// end save notification meta box
1890 1890
 
@@ -1898,10 +1898,10 @@  discard block
 block discarded – undo
1898 1898
      *
1899 1899
      * @param WP_Post $post
1900 1900
      */
1901
-    public function content_before_backwards_compatibility_hooks( $post_id ){
1901
+    public function content_before_backwards_compatibility_hooks($post_id) {
1902 1902
 
1903
-        sensei_do_deprecated_action( 'sensei_course_image','1.9.0','sensei_course_content_inside_before' );
1904
-        sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before' );
1903
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_course_content_inside_before');
1904
+        sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before');
1905 1905
 
1906 1906
     }
1907 1907
 
@@ -1914,10 +1914,10 @@  discard block
 block discarded – undo
1914 1914
      *
1915 1915
      * @global WP_Post $post
1916 1916
      */
1917
-    public  function loop_before_backwards_compatibility_hooks( ){
1917
+    public  function loop_before_backwards_compatibility_hooks( ) {
1918 1918
 
1919 1919
         global $post;
1920
-        sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type  );
1920
+        sensei_do_deprecated_action('sensei_course_archive_header', '1.9.0', 'sensei_course_content_inside_before', $post->post_type);
1921 1921
 
1922 1922
     }
1923 1923
 
@@ -1930,19 +1930,19 @@  discard block
 block discarded – undo
1930 1930
      *
1931 1931
      * @param integer $course_id
1932 1932
      */
1933
-    public function the_course_free_lesson_preview( $course_id ){
1933
+    public function the_course_free_lesson_preview($course_id) {
1934 1934
         // Meta data
1935
-        $course = get_post( $course_id );
1936
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) );
1937
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
1935
+        $course = get_post($course_id);
1936
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID));
1937
+        $is_user_taking_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id());
1938 1938
 
1939
-        if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
1939
+        if (0 < $preview_lesson_count && ! $is_user_taking_course) {
1940 1940
             ?>
1941 1941
             <p class="sensei-free-lessons">
1942 1942
                 <a href="<?php echo get_permalink(); ?>">
1943
-                    <?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
1943
+                    <?php _e('Preview this course', 'woothemes-sensei') ?>
1944 1944
                 </a>
1945
-                - <?php echo sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) ; ?>
1945
+                - <?php echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
1946 1946
             </p>
1947 1947
 
1948 1948
         <?php
@@ -1955,42 +1955,42 @@  discard block
 block discarded – undo
1955 1955
      * @since 1.9.0
1956 1956
      * @param integer $course_id
1957 1957
      */
1958
-    public function the_course_meta( $course_id ){
1958
+    public function the_course_meta($course_id) {
1959 1959
         echo '<p class="sensei-course-meta">';
1960 1960
 
1961
-        $course = get_post( $course_id );
1962
-        $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' );
1963
-        $author_display_name = get_the_author_meta( 'display_name', $course->post_author  );
1961
+        $course = get_post($course_id);
1962
+        $category_output = get_the_term_list($course->ID, 'course-category', '', ', ', '');
1963
+        $author_display_name = get_the_author_meta('display_name', $course->post_author);
1964 1964
 
1965
-        if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?>
1965
+        if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {?>
1966 1966
 
1967
-            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?>
1967
+            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?>
1968 1968
 
1969
-                <a href="<?php esc_attr_e( get_author_posts_url( $course->post_author ) ); ?>" title="<?php esc_attr_e( $author_display_name ); ?>"><?php esc_attr_e( $author_display_name   ); ?></a>
1969
+                <a href="<?php esc_attr_e(get_author_posts_url($course->post_author)); ?>" title="<?php esc_attr_e($author_display_name); ?>"><?php esc_attr_e($author_display_name); ?></a>
1970 1970
 
1971 1971
             </span>
1972 1972
 
1973 1973
         <?php } // End If Statement ?>
1974 1974
 
1975
-        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $course->ID ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?></span>
1975
+        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($course->ID).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
1976 1976
 
1977
-       <?php if ( '' != $category_output ) { ?>
1977
+       <?php if ('' != $category_output) { ?>
1978 1978
 
1979
-            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
1979
+            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
1980 1980
 
1981 1981
         <?php } // End If Statement
1982 1982
 
1983 1983
         // number of completed lessons
1984
-        if( Sensei_Utils::user_started_course( $course->ID,  get_current_user_id() )
1985
-            || Sensei_Utils::user_completed_course( $course->ID,  get_current_user_id() )  ){
1984
+        if (Sensei_Utils::user_started_course($course->ID, get_current_user_id())
1985
+            || Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {
1986 1986
 
1987
-            $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) );
1988
-            $lesson_count = count( $this->course_lessons( $course->ID ) );
1989
-            echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count  ) . '</span>';
1987
+            $completed = count($this->get_completed_lesson_ids($course->ID, get_current_user_id()));
1988
+            $lesson_count = count($this->course_lessons($course->ID));
1989
+            echo '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $completed, $lesson_count).'</span>';
1990 1990
 
1991 1991
         }
1992 1992
 
1993
-        sensei_simple_course_price( $course->ID );
1993
+        sensei_simple_course_price($course->ID);
1994 1994
 
1995 1995
         echo '</p>';
1996 1996
     } // end the course meta
@@ -2005,15 +2005,15 @@  discard block
 block discarded – undo
2005 2005
      *
2006 2006
      * @return array $classes
2007 2007
      */
2008
-    public static function add_course_user_status_class( $classes, $class, $course_id ){
2008
+    public static function add_course_user_status_class($classes, $class, $course_id) {
2009 2009
 
2010
-        if( 'course' == get_post_type( $course_id )  &&  is_user_logged_in() ){
2010
+        if ('course' == get_post_type($course_id) && is_user_logged_in()) {
2011 2011
 
2012
-            if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){
2012
+            if (Sensei_Utils::user_completed_course($course_id, get_current_user_id())) {
2013 2013
 
2014 2014
                 $classes[] = 'user-status-completed';
2015 2015
 
2016
-            }else{
2016
+            } else {
2017 2017
 
2018 2018
                 $classes[] = 'user-status-active';
2019 2019
 
@@ -2033,37 +2033,37 @@  discard block
 block discarded – undo
2033 2033
      *
2034 2034
      * @param WP_Post $course
2035 2035
      */
2036
-    public static function the_course_action_buttons( $course ){
2036
+    public static function the_course_action_buttons($course) {
2037 2037
 
2038
-        if( is_user_logged_in() ) { ?>
2038
+        if (is_user_logged_in()) { ?>
2039 2039
 
2040 2040
             <section class="entry-actions">
2041
-                <form method="POST" action="<?php  echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>">
2041
+                <form method="POST" action="<?php  echo esc_url(remove_query_arg(array('active_page', 'completed_page'))); ?>">
2042 2042
 
2043 2043
                     <input type="hidden"
2044
-                           name="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ) ?>"
2045
-                           id="<?php  esc_attr_e( 'woothemes_sensei_complete_course_noonce' ); ?>"
2046
-                           value="<?php esc_attr_e( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ); ?>"
2044
+                           name="<?php esc_attr_e('woothemes_sensei_complete_course_noonce') ?>"
2045
+                           id="<?php  esc_attr_e('woothemes_sensei_complete_course_noonce'); ?>"
2046
+                           value="<?php esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce')); ?>"
2047 2047
                         />
2048 2048
 
2049
-                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e( intval( $course->ID ) ); ?>" />
2049
+                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e(intval($course->ID)); ?>" />
2050 2050
 
2051
-                    <?php if ( 0 < absint( count( Sensei()->course->course_lessons( $course->ID ) ) )
2051
+                    <?php if (0 < absint(count(Sensei()->course->course_lessons($course->ID)))
2052 2052
                         && Sensei()->settings->settings['course_completion'] == 'complete'
2053
-                        && ! Sensei_Utils::user_completed_course( $course, get_current_user_id() )) { ?>
2053
+                        && ! Sensei_Utils::user_completed_course($course, get_current_user_id())) { ?>
2054 2054
 
2055
-                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e( 'Mark as Complete', 'woothemes-sensei' ); ?>" /></span>
2055
+                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e('Mark as Complete', 'woothemes-sensei'); ?>" /></span>
2056 2056
 
2057 2057
                    <?php  } // End If Statement
2058 2058
 
2059 2059
                     $course_purchased = false;
2060
-                    if ( Sensei_WC::is_woocommerce_active() ) {
2060
+                    if (Sensei_WC::is_woocommerce_active()) {
2061 2061
                         // Get the product ID
2062
-                        $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true );
2063
-                        if ( 0 < $wc_post_id ) {
2062
+                        $wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true);
2063
+                        if (0 < $wc_post_id) {
2064 2064
 
2065 2065
                             $user = wp_get_current_user();
2066
-                            $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id );
2066
+                            $course_purchased = Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
2067 2067
 
2068 2068
                         } // End If Statement
2069 2069
                     } // End If Statement
@@ -2077,24 +2077,24 @@  discard block
 block discarded – undo
2077 2077
                      * @since 1.9.0
2078 2078
                      * @param bool $show_delete_course_button defaults to false
2079 2079
                      */
2080
-                    $show_delete_course_button = apply_filters( 'sensei_show_delete_course_button', false );
2080
+                    $show_delete_course_button = apply_filters('sensei_show_delete_course_button', false);
2081 2081
 
2082 2082
                     if ( ! $course_purchased
2083
-                         && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() )
2084
-                         && $show_delete_course_button ) { ?>
2083
+                         && ! Sensei_Utils::user_completed_course($course->ID, get_current_user_id())
2084
+                         && $show_delete_course_button) { ?>
2085 2085
 
2086
-                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span>
2086
+                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __('Delete Course', 'woothemes-sensei'); ?>"/></span>
2087 2087
 
2088 2088
                     <?php } // End If Statement
2089 2089
 
2090
-                    $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true );
2090
+                    $has_quizzes = Sensei()->course->course_quizzes($course->ID, true);
2091 2091
                     $results_link = '';
2092
-                    if( $has_quizzes ){
2093
-                        $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>';
2092
+                    if ($has_quizzes) {
2093
+                        $results_link = '<a class="button view-results" href="'.Sensei()->course_results->get_permalink($course->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2094 2094
                     }
2095 2095
 
2096 2096
                     // Output only if there is content to display
2097
-                    if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2097
+                    if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2098 2098
 
2099 2099
                         <p class="sensei-results-links">
2100 2100
                             <?php
@@ -2104,7 +2104,7 @@  discard block
 block discarded – undo
2104 2104
                              * @param string $results_links_html
2105 2105
                              * @param integer $course_id
2106 2106
                              */
2107
-                            echo apply_filters( 'sensei_results_links', $results_link, $course->ID );
2107
+                            echo apply_filters('sensei_results_links', $results_link, $course->ID);
2108 2108
                             ?>
2109 2109
                         </p>
2110 2110
 
@@ -2130,17 +2130,17 @@  discard block
 block discarded – undo
2130 2130
      * @param WP_Query $query
2131 2131
      * @return WP_Query $query
2132 2132
      */
2133
-    public static function course_query_filter( $query ){
2133
+    public static function course_query_filter($query) {
2134 2134
 
2135 2135
         // exit early for no course queries and admin queries
2136
-        if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){
2136
+        if (is_admin( ) || 'course' != $query->get('post_type')) {
2137 2137
             return $query;
2138 2138
         }
2139 2139
 
2140 2140
         global $post; // used to get the current page id for my courses
2141 2141
 
2142 2142
         // for the course archive page
2143
-        if( $query->is_main_query() && is_post_type_archive('course') )
2143
+        if ($query->is_main_query() && is_post_type_archive('course'))
2144 2144
         {
2145 2145
             /**
2146 2146
              * sensei_archive_courses_per_page
@@ -2151,11 +2151,11 @@  discard block
 block discarded – undo
2151 2151
              * @since 1.9.0
2152 2152
              * @param integer $posts_per_page default 10
2153 2153
              */
2154
-            $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', 10 ) );
2154
+            $query->set('posts_per_page', apply_filters('sensei_archive_courses_per_page', 10));
2155 2155
 
2156 2156
         }
2157 2157
         // for the my courses page
2158
-        elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID  )
2158
+        elseif (is_page() && Sensei()->settings->get('my_course_page') == $post->ID)
2159 2159
         {
2160 2160
             /**
2161 2161
              * sensei_my_courses_per_page
@@ -2166,7 +2166,7 @@  discard block
 block discarded – undo
2166 2166
              * @since 1.9.0
2167 2167
              * @param integer $posts_per_page default 10
2168 2168
              */
2169
-            $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', 10 ) );
2169
+            $query->set('posts_per_page', apply_filters('sensei_my_courses_per_page', 10));
2170 2170
 
2171 2171
         }
2172 2172
 
@@ -2182,21 +2182,21 @@  discard block
 block discarded – undo
2182 2182
      * @return array $extra_classes
2183 2183
      * @since 1.9.0
2184 2184
      */
2185
-    public static function get_course_loop_content_class ()
2185
+    public static function get_course_loop_content_class()
2186 2186
     {
2187 2187
 
2188 2188
         global $sensei_course_loop;
2189 2189
 
2190 2190
 
2191
-        if( !isset( $sensei_course_loop ) ){
2191
+        if ( ! isset($sensei_course_loop)) {
2192 2192
             $sensei_course_loop = array();
2193 2193
         }
2194 2194
 
2195
-        if (!isset($sensei_course_loop['counter'])) {
2195
+        if ( ! isset($sensei_course_loop['counter'])) {
2196 2196
             $sensei_course_loop['counter'] = 0;
2197 2197
         }
2198 2198
 
2199
-        if (!isset($sensei_course_loop['columns'])) {
2199
+        if ( ! isset($sensei_course_loop['columns'])) {
2200 2200
             $sensei_course_loop['columns'] = self::get_loop_number_of_columns();
2201 2201
         }
2202 2202
 
@@ -2204,16 +2204,16 @@  discard block
 block discarded – undo
2204 2204
         $sensei_course_loop['counter']++;
2205 2205
 
2206 2206
         $extra_classes = array();
2207
-        if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']  ){
2207
+        if (0 == ($sensei_course_loop['counter'] - 1) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']) {
2208 2208
             $extra_classes[] = 'first';
2209 2209
         }
2210 2210
 
2211
-        if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']  ){
2211
+        if (0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']) {
2212 2212
             $extra_classes[] = 'last';
2213 2213
         }
2214 2214
 
2215 2215
         // add the item number to the classes as well.
2216
-        $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter'];
2216
+        $extra_classes[] = 'loop-item-number-'.$sensei_course_loop['counter'];
2217 2217
 
2218 2218
         /**
2219 2219
          * Filter the course loop class the fires in the  in get_course_loop_content_class function
@@ -2224,7 +2224,7 @@  discard block
 block discarded – undo
2224 2224
          * @param array $extra_classes
2225 2225
          * @param WP_Post $loop_current_course
2226 2226
          */
2227
-        return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() );
2227
+        return apply_filters('sensei_course_loop_content_class', $extra_classes, get_post());
2228 2228
 
2229 2229
     }// end get_course_loop_class
2230 2230
 
@@ -2234,7 +2234,7 @@  discard block
 block discarded – undo
2234 2234
      * @since 1.9.0
2235 2235
      * @return mixed|void
2236 2236
      */
2237
-    public static function get_loop_number_of_columns(){
2237
+    public static function get_loop_number_of_columns() {
2238 2238
 
2239 2239
         /**
2240 2240
          * Filter the number of columns on the course archive page.
@@ -2254,10 +2254,10 @@  discard block
 block discarded – undo
2254 2254
      * @since 1.9.0
2255 2255
      * @param
2256 2256
      */
2257
-    public static function course_archive_sorting( $query ){
2257
+    public static function course_archive_sorting($query) {
2258 2258
 
2259 2259
         // don't show on category pages and other pages
2260
-        if( ! is_archive(  'course ') || is_tax('course-category') ){
2260
+        if ( ! is_archive('course ') || is_tax('course-category')) {
2261 2261
             return;
2262 2262
         }
2263 2263
 
@@ -2270,27 +2270,27 @@  discard block
 block discarded – undo
2270 2270
          *  @type string $option_string
2271 2271
          * }
2272 2272
          */
2273
-        $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array(
2274
-            "newness"     => __( "Sort by newest first", "woothemes-sensei"),
2275
-            "title"       => __( "Sort by title A-Z", "woothemes-sensei" ),
2273
+        $course_order_by_options = apply_filters('sensei_archive_course_order_by_options', array(
2274
+            "newness"     => __("Sort by newest first", "woothemes-sensei"),
2275
+            "title"       => __("Sort by title A-Z", "woothemes-sensei"),
2276 2276
         ));
2277 2277
 
2278 2278
         // setup the currently selected item
2279 2279
         $selected = 'newness';
2280
-        if( isset( $_GET['orderby'] ) ){
2280
+        if (isset($_GET['orderby'])) {
2281 2281
 
2282
-            $selected =  $_GET[ 'orderby' ];
2282
+            $selected = $_GET['orderby'];
2283 2283
 
2284 2284
         }
2285 2285
 
2286 2286
         ?>
2287 2287
 
2288
-        <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST">
2288
+        <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr(Sensei_Utils::get_current_url()); ?>" method="POST">
2289 2289
             <select name="course-orderby" class="orderby">
2290 2290
                 <?php
2291
-                foreach( $course_order_by_options as $value => $text ){
2291
+                foreach ($course_order_by_options as $value => $text) {
2292 2292
 
2293
-                    echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>';
2293
+                    echo '<option value="'.$value.' "'.selected($selected, $value, false).'>'.$text.'</option>';
2294 2294
 
2295 2295
                 }
2296 2296
                 ?>
@@ -2308,10 +2308,10 @@  discard block
 block discarded – undo
2308 2308
      * @since 1.9.0
2309 2309
      * @param
2310 2310
      */
2311
-    public static function course_archive_filters( $query ){
2311
+    public static function course_archive_filters($query) {
2312 2312
 
2313 2313
         // don't show on category pages
2314
-        if( is_tax('course-category') ){
2314
+        if (is_tax('course-category')) {
2315 2315
             return;
2316 2316
         }
2317 2317
 
@@ -2324,9 +2324,9 @@  discard block
 block discarded – undo
2324 2324
          * }
2325 2325
          *
2326 2326
          */
2327
-        $filters = apply_filters( 'sensei_archive_course_filter_by_options', array(
2328
-            array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ),
2329
-            array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url()  ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ),
2327
+        $filters = apply_filters('sensei_archive_course_filter_by_options', array(
2328
+            array('id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __('All', 'woothemes-sensei')),
2329
+            array('id' => 'featured', 'url' => add_query_arg(array('course_filter'=>'featured'), self::get_courses_page_url()), 'title'=> __('Featured', 'woothemes-sensei')),
2330 2330
         ));
2331 2331
 
2332 2332
 
@@ -2337,11 +2337,11 @@  discard block
 block discarded – undo
2337 2337
             //determine the current active url
2338 2338
             $current_url = Sensei_Utils::get_current_url();
2339 2339
 
2340
-            foreach( $filters as $filter ) {
2340
+            foreach ($filters as $filter) {
2341 2341
 
2342
-                $active_class =  $current_url == $filter['url'] ? ' class="active" ' : '';
2342
+                $active_class = $current_url == $filter['url'] ? ' class="active" ' : '';
2343 2343
 
2344
-                echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title']  .'</a></li>';
2344
+                echo '<li><a '.$active_class.' id="'.$filter['id'].'" href="'.esc_url($filter['url']).'" >'.$filter['title'].'</a></li>';
2345 2345
 
2346 2346
             }
2347 2347
             ?>
@@ -2362,13 +2362,13 @@  discard block
 block discarded – undo
2362 2362
      * @param WP_Query $query
2363 2363
      * @return WP_Query $query
2364 2364
      */
2365
-    public static function course_archive_featured_filter( $query ){
2365
+    public static function course_archive_featured_filter($query) {
2366 2366
 
2367
-        if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query()  ){
2367
+        if (isset ($_GET['course_filter']) && 'featured' == $_GET['course_filter'] && $query->is_main_query()) {
2368 2368
             //setup meta query for featured courses
2369
-            $query->set( 'meta_value', 'featured'  );
2370
-            $query->set( 'meta_key', '_course_featured'  );
2371
-            $query->set( 'meta_compare', '='  );
2369
+            $query->set('meta_value', 'featured');
2370
+            $query->set('meta_key', '_course_featured');
2371
+            $query->set('meta_compare', '=');
2372 2372
         }
2373 2373
 
2374 2374
         return $query;
@@ -2383,13 +2383,13 @@  discard block
 block discarded – undo
2383 2383
      * @param WP_Query $query
2384 2384
      * @return WP_Query $query
2385 2385
      */
2386
-    public static function course_archive_order_by_title( $query ){
2386
+    public static function course_archive_order_by_title($query) {
2387 2387
 
2388
-        if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby']
2389
-            && 'course'== $query->get('post_type') && $query->is_main_query()  ){
2388
+        if (isset ($_POST['course-orderby']) && 'title ' == $_POST['course-orderby']
2389
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
2390 2390
             // setup the order by title for this query
2391
-            $query->set( 'orderby', 'title'  );
2392
-            $query->set( 'order', 'ASC'  );
2391
+            $query->set('orderby', 'title');
2392
+            $query->set('order', 'ASC');
2393 2393
         }
2394 2394
 
2395 2395
         return $query;
@@ -2403,10 +2403,10 @@  discard block
 block discarded – undo
2403 2403
      * @since 1.9.0
2404 2404
      * @return string $course_page_url
2405 2405
      */
2406
-    public static function get_courses_page_url(){
2406
+    public static function get_courses_page_url() {
2407 2407
 
2408
-        $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
2409
-        $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id );
2408
+        $course_page_id = intval(Sensei()->settings->settings['course_page']);
2409
+        $course_page_url = empty($course_page_id) ? get_post_type_archive_link('course') : get_permalink($course_page_id);
2410 2410
 
2411 2411
         return $course_page_url;
2412 2412
 
@@ -2423,61 +2423,61 @@  discard block
 block discarded – undo
2423 2423
      * @param string $after_html
2424 2424
      * @return void
2425 2425
      */
2426
-    public static function archive_header( $query_type ='' , $before_html='', $after_html =''  ){
2426
+    public static function archive_header($query_type = '', $before_html = '', $after_html = '') {
2427 2427
 
2428
-        if( ! is_post_type_archive('course') ){
2428
+        if ( ! is_post_type_archive('course')) {
2429 2429
             return;
2430 2430
         }
2431 2431
 
2432 2432
         // deprecated since 1.9.0
2433
-        sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop');
2433
+        sensei_do_deprecated_action('sensei_archive_title', '1.9.0', 'sensei_archive_before_course_loop');
2434 2434
 
2435 2435
         $html = '';
2436 2436
 
2437
-        if( empty( $before_html ) ){
2437
+        if (empty($before_html)) {
2438 2438
 
2439 2439
             $before_html = '<header class="archive-header"><h1>';
2440 2440
 
2441 2441
         }
2442 2442
 
2443
-        if( empty( $after_html ) ){
2443
+        if (empty($after_html)) {
2444 2444
 
2445 2445
             $after_html = '</h1></header>';
2446 2446
 
2447 2447
         }
2448 2448
 
2449
-        if ( is_tax( 'course-category' ) ) {
2449
+        if (is_tax('course-category')) {
2450 2450
 
2451 2451
             global $wp_query;
2452 2452
 
2453 2453
             $taxonomy_obj = $wp_query->get_queried_object();
2454 2454
             $taxonomy_short_name = $taxonomy_obj->taxonomy;
2455
-            $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
2456
-            $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
2457
-            echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html );
2455
+            $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name);
2456
+            $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name);
2457
+            echo apply_filters('course_category_archive_title', $before_html.$title.$after_html);
2458 2458
             return;
2459 2459
 
2460 2460
         } // End If Statement
2461 2461
 
2462
-        switch ( $query_type ) {
2462
+        switch ($query_type) {
2463 2463
             case 'newcourses':
2464
-                $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html;
2464
+                $html .= $before_html.__('New Courses', 'woothemes-sensei').$after_html;
2465 2465
                 break;
2466 2466
             case 'featuredcourses':
2467
-                $html .= $before_html .  __( 'Featured Courses', 'woothemes-sensei' ) . $after_html;
2467
+                $html .= $before_html.__('Featured Courses', 'woothemes-sensei').$after_html;
2468 2468
                 break;
2469 2469
             case 'freecourses':
2470
-                $html .= $before_html .  __( 'Free Courses', 'woothemes-sensei' ) . $after_html;
2470
+                $html .= $before_html.__('Free Courses', 'woothemes-sensei').$after_html;
2471 2471
                 break;
2472 2472
             case 'paidcourses':
2473
-                $html .= $before_html .  __( 'Paid Courses', 'woothemes-sensei' ) . $after_html;
2473
+                $html .= $before_html.__('Paid Courses', 'woothemes-sensei').$after_html;
2474 2474
                 break;
2475 2475
             default:
2476
-                $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html;
2476
+                $html .= $before_html.__('Courses', 'woothemes-sensei').$after_html;
2477 2477
                 break;
2478 2478
         } // End Switch Statement
2479 2479
 
2480
-        echo apply_filters( 'course_archive_title', $html );
2480
+        echo apply_filters('course_archive_title', $html);
2481 2481
 
2482 2482
     }//course_archive_header
2483 2483
 
@@ -2491,9 +2491,9 @@  discard block
 block discarded – undo
2491 2491
      * @param string $content
2492 2492
      * @return string $content or $excerpt
2493 2493
      */
2494
-    public static function single_course_content( $content ){
2494
+    public static function single_course_content($content) {
2495 2495
 
2496
-        if( ! is_singular('course') ){
2496
+        if ( ! is_singular('course')) {
2497 2497
 
2498 2498
             return $content;
2499 2499
 
@@ -2502,21 +2502,21 @@  discard block
 block discarded – undo
2502 2502
         // Content Access Permissions
2503 2503
         $access_permission = false;
2504 2504
 
2505
-        if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
2505
+        if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) {
2506 2506
 
2507 2507
             $access_permission = true;
2508 2508
 
2509 2509
         } // End If Statement
2510 2510
 
2511 2511
         // Check if the user is taking the course
2512
-        $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() );
2512
+        $is_user_taking_course = Sensei_Utils::user_started_course(get_the_ID(), get_current_user_id());
2513 2513
 
2514
-        if(Sensei_WC::is_woocommerce_active()) {
2514
+        if (Sensei_WC::is_woocommerce_active()) {
2515 2515
 
2516
-            $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true );
2517
-            $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
2516
+            $wc_post_id = get_post_meta(get_the_ID(), '_course_woocommerce_product', true);
2517
+            $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
2518 2518
 
2519
-            $has_product_attached = isset ( $product ) && is_object ( $product );
2519
+            $has_product_attached = isset ($product) && is_object($product);
2520 2520
 
2521 2521
         } else {
2522 2522
 
@@ -2524,17 +2524,17 @@  discard block
 block discarded – undo
2524 2524
 
2525 2525
         }
2526 2526
 
2527
-        if ( ( is_user_logged_in() && $is_user_taking_course )
2528
-            || ( $access_permission && !$has_product_attached)
2529
-            || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) {
2527
+        if ((is_user_logged_in() && $is_user_taking_course)
2528
+            || ($access_permission && ! $has_product_attached)
2529
+            || 'full' == Sensei()->settings->get('course_single_content_display')) {
2530 2530
 
2531 2531
 	        // compensate for core providing and empty $content
2532 2532
 
2533
-	        if( empty( $content ) ){
2534
-		        remove_filter( 'the_content', array( 'Sensei_Course', 'single_course_content') );
2535
-		        $course = get_post( get_the_ID() );
2533
+	        if (empty($content)) {
2534
+		        remove_filter('the_content', array('Sensei_Course', 'single_course_content'));
2535
+		        $course = get_post(get_the_ID());
2536 2536
 
2537
-		        $content = apply_filters( 'the_content', $course->post_content );
2537
+		        $content = apply_filters('the_content', $course->post_content);
2538 2538
 
2539 2539
 	        }
2540 2540
 
@@ -2542,7 +2542,7 @@  discard block
 block discarded – undo
2542 2542
 
2543 2543
         } else {
2544 2544
 
2545
-            return '<p class="course-excerpt">' . get_post(  get_the_ID() )->post_excerpt . '</p>';
2545
+            return '<p class="course-excerpt">'.get_post(get_the_ID())->post_excerpt.'</p>';
2546 2546
 
2547 2547
         }
2548 2548
 
@@ -2553,25 +2553,25 @@  discard block
 block discarded – undo
2553 2553
      *
2554 2554
      * @since 1.9.0
2555 2555
      */
2556
-    public static function the_course_lessons_title(){
2556
+    public static function the_course_lessons_title() {
2557 2557
 
2558
-	    if ( ! is_singular( 'course' )  ) {
2558
+	    if ( ! is_singular('course')) {
2559 2559
 		    return;
2560 2560
 	    }
2561 2561
 
2562 2562
         global $post;
2563
-        $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID  );
2564
-        $course_lessons = Sensei()->course->course_lessons( $post->ID );
2563
+        $none_module_lessons = Sensei()->modules->get_none_module_lessons($post->ID);
2564
+        $course_lessons = Sensei()->course->course_lessons($post->ID);
2565 2565
 
2566 2566
         // title should be Other Lessons if there are lessons belonging to models.
2567 2567
         $title = __('Other Lessons', 'woothemes-sensei');
2568 2568
 
2569 2569
         // show lessons if the number of lesson in the course is the same as those that isn't assigned to a module
2570
-        if( count( $course_lessons ) == count( $none_module_lessons )  ){
2570
+        if (count($course_lessons) == count($none_module_lessons)) {
2571 2571
 
2572 2572
             $title = __('Lessons', 'woothemes-sensei');
2573 2573
 
2574
-        }elseif( empty( $none_module_lessons ) ){ // if the none module lessons are simply empty the title should not be shown
2574
+        }elseif (empty($none_module_lessons)) { // if the none module lessons are simply empty the title should not be shown
2575 2575
 
2576 2576
             $title = '';
2577 2577
         }
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
         /**
2580 2580
          * hook document in class-woothemes-sensei-message.php
2581 2581
          */
2582
-        $title = apply_filters( 'sensei_single_title', $title, $post->post_type );
2582
+        $title = apply_filters('sensei_single_title', $title, $post->post_type);
2583 2583
 
2584 2584
         ob_start(); // start capturing the following output.
2585 2585
 
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
          * @since 1.9.0
2599 2599
          * @param string $lessons_title_html
2600 2600
          */
2601
-        echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing.
2601
+        echo apply_filters('the_course_lessons_title', ob_get_clean()); // output and filter the captured output and stop capturing.
2602 2602
 
2603 2603
     }// end the_course_lessons_title
2604 2604
 
@@ -2613,13 +2613,13 @@  discard block
 block discarded – undo
2613 2613
      * @since 1.9.0
2614 2614
      * @global $wp_query
2615 2615
      */
2616
-    public static function load_single_course_lessons_query(){
2616
+    public static function load_single_course_lessons_query() {
2617 2617
 
2618 2618
         global $post, $wp_query;
2619 2619
 
2620 2620
         $course_id = $post->ID;
2621 2621
 
2622
-        if( 'course' != get_post_type( $course_id ) ){
2622
+        if ('course' != get_post_type($course_id)) {
2623 2623
             return;
2624 2624
         }
2625 2625
 
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
             'meta_query'        => array(
2632 2632
                 array(
2633 2633
                     'key' => '_lesson_course',
2634
-                    'value' => intval( $course_id ),
2634
+                    'value' => intval($course_id),
2635 2635
                 ),
2636 2636
             ),
2637 2637
             'post_status'       => 'public',
@@ -2639,17 +2639,17 @@  discard block
 block discarded – undo
2639 2639
         );
2640 2640
 
2641 2641
         // Exclude lessons belonging to modules as they are queried along with the modules.
2642
-        $modules = Sensei()->modules->get_course_modules( $course_id );
2643
-        if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){
2642
+        $modules = Sensei()->modules->get_course_modules($course_id);
2643
+        if ( ! is_wp_error($modules) && ! empty($modules) && is_array($modules)) {
2644 2644
 
2645 2645
             $terms_ids = array();
2646
-            foreach( $modules as $term ){
2646
+            foreach ($modules as $term) {
2647 2647
 
2648 2648
                 $terms_ids[] = $term->term_id;
2649 2649
 
2650 2650
             }
2651 2651
 
2652
-            $course_lesson_query_args[ 'tax_query'] = array(
2652
+            $course_lesson_query_args['tax_query'] = array(
2653 2653
                 array(
2654 2654
                     'taxonomy' => 'module',
2655 2655
                     'field'    => 'id',
@@ -2660,16 +2660,16 @@  discard block
 block discarded – undo
2660 2660
         }
2661 2661
 
2662 2662
         //setting lesson order
2663
-        $course_lesson_order = get_post_meta( $course_id, '_lesson_order', true);
2664
-        if( !empty( $course_lesson_order ) ){
2663
+        $course_lesson_order = get_post_meta($course_id, '_lesson_order', true);
2664
+        if ( ! empty($course_lesson_order)) {
2665 2665
 
2666
-            $course_lesson_query_args['post__in'] = explode( ',', $course_lesson_order );
2667
-            $course_lesson_query_args['orderby']= 'post__in' ;
2668
-            unset( $course_lesson_query_args['order'] );
2666
+            $course_lesson_query_args['post__in'] = explode(',', $course_lesson_order);
2667
+            $course_lesson_query_args['orderby'] = 'post__in';
2668
+            unset($course_lesson_query_args['order']);
2669 2669
 
2670 2670
         }
2671 2671
 
2672
-        $wp_query = new WP_Query( $course_lesson_query_args );
2672
+        $wp_query = new WP_Query($course_lesson_query_args);
2673 2673
 
2674 2674
     }// load_single_course_lessons
2675 2675
 
@@ -2680,16 +2680,16 @@  discard block
 block discarded – undo
2680 2680
      *
2681 2681
      * @param $post_id
2682 2682
      */
2683
-    public static function flush_rewrite_rules( $post_id ){
2683
+    public static function flush_rewrite_rules($post_id) {
2684 2684
 
2685
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
2685
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
2686 2686
 
2687 2687
             return;
2688 2688
 
2689 2689
         }
2690 2690
 
2691 2691
 
2692
-        if( 'course' == get_post_type( $post_id )  ){
2692
+        if ('course' == get_post_type($post_id)) {
2693 2693
 
2694 2694
             Sensei()->initiate_rewrite_rules_flush();
2695 2695
 
@@ -2705,10 +2705,10 @@  discard block
 block discarded – undo
2705 2705
      * @param $excerpt
2706 2706
      * @return string
2707 2707
      */
2708
-    public static function full_content_excerpt_override( $excerpt ){
2708
+    public static function full_content_excerpt_override($excerpt) {
2709 2709
 
2710
-        if (   is_singular('course')  &&
2711
-                'full' == Sensei()->settings->get( 'course_single_content_display' ) ){
2710
+        if (is_singular('course') &&
2711
+                'full' == Sensei()->settings->get('course_single_content_display')) {
2712 2712
 
2713 2713
             return get_the_content();
2714 2714
 
@@ -2725,11 +2725,11 @@  discard block
 block discarded – undo
2725 2725
      *
2726 2726
      * @since 1.9.0
2727 2727
      */
2728
-    public static function the_course_enrolment_actions(){
2728
+    public static function the_course_enrolment_actions() {
2729 2729
 
2730 2730
 	    global $post;
2731 2731
 
2732
-	    if ( 'course' != $post->post_type ) {
2732
+	    if ('course' != $post->post_type) {
2733 2733
 			return;
2734 2734
 	    }
2735 2735
 
@@ -2737,15 +2737,15 @@  discard block
 block discarded – undo
2737 2737
         <section class="course-meta course-enrolment">
2738 2738
         <?php
2739 2739
         global  $post, $current_user;
2740
-        $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
2740
+        $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID);
2741 2741
 
2742
-	    if ( is_user_logged_in() && ! $is_user_taking_course ) {
2742
+	    if (is_user_logged_in() && ! $is_user_taking_course) {
2743 2743
 
2744 2744
 	        // Get the product ID
2745
-	        $wc_product = wc_get_product( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2745
+	        $wc_product = wc_get_product(get_post_meta($post->ID, '_course_woocommerce_product', true));
2746 2746
 
2747 2747
 	        // Check for woocommerce
2748
-	        if ( Sensei_WC::is_woocommerce_active() && ( isset( $wc_product->price  ) ) ) {
2748
+	        if (Sensei_WC::is_woocommerce_active() && (isset($wc_product->price))) {
2749 2749
 
2750 2750
                 Sensei_WC::the_add_to_cart_button_html($post->ID);
2751 2751
 
@@ -2755,53 +2755,53 @@  discard block
 block discarded – undo
2755 2755
 
2756 2756
             } // End If Statement
2757 2757
 
2758
-        } elseif ( is_user_logged_in() ) {
2758
+        } elseif (is_user_logged_in()) {
2759 2759
 
2760 2760
             // Check if course is completed
2761
-            $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID );
2762
-            $completed_course = Sensei_Utils::user_completed_course( $user_course_status );
2761
+            $user_course_status = Sensei_Utils::user_course_status($post->ID, $current_user->ID);
2762
+            $completed_course = Sensei_Utils::user_completed_course($user_course_status);
2763 2763
             // Success message
2764
-            if ( $completed_course ) { ?>
2765
-                <div class="status completed"><?php  _e( 'Completed', 'woothemes-sensei' ); ?></div>
2764
+            if ($completed_course) { ?>
2765
+                <div class="status completed"><?php  _e('Completed', 'woothemes-sensei'); ?></div>
2766 2766
                 <?php
2767
-                $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true );
2768
-                if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2767
+                $has_quizzes = Sensei()->course->course_quizzes($post->ID, true);
2768
+                if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2769 2769
                     <p class="sensei-results-links">
2770 2770
                         <?php
2771 2771
                         $results_link = '';
2772
-                        if( $has_quizzes ) {
2773
-                            $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' .  __( 'View results', 'woothemes-sensei' ) . '</a>';
2772
+                        if ($has_quizzes) {
2773
+                            $results_link = '<a class="view-results" href="'.Sensei()->course_results->get_permalink($post->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2774 2774
                         }
2775 2775
                         /**
2776 2776
                          * Filter documented in Sensei_Course::the_course_action_buttons
2777 2777
                          */
2778
-                        $results_link = apply_filters( 'sensei_results_links', $results_link, $post->ID );
2778
+                        $results_link = apply_filters('sensei_results_links', $results_link, $post->ID);
2779 2779
                         echo $results_link;
2780 2780
                         ?></p>
2781 2781
                 <?php } ?>
2782 2782
             <?php } else { ?>
2783
-                <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div>
2783
+                <div class="status in-progress"><?php echo __('In Progress', 'woothemes-sensei'); ?></div>
2784 2784
             <?php }
2785 2785
 
2786 2786
         } else {
2787 2787
 
2788 2788
 	        // Get the product ID
2789
-            $wc_product = wc_get_product( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2789
+            $wc_product = wc_get_product(get_post_meta($post->ID, '_course_woocommerce_product', true));
2790 2790
 
2791 2791
             // Check for woocommerce
2792
-            if ( Sensei_WC::is_woocommerce_active() && ( isset( $wc_product->price  ) ) ) {
2792
+            if (Sensei_WC::is_woocommerce_active() && (isset($wc_product->price))) {
2793 2793
 
2794
-	            $login_link =  '<a href="' . sensei_user_login_url() . '">' . __( 'log in', 'woothemes-sensei' ) . '</a>';
2795
-	            $message = sprintf( __( 'Or %1$s to access your purchased courses', 'woothemes-sensei' ), $login_link );
2796
-	            Sensei()->notices->add_notice( $message, 'info' ) ;
2797
-	            Sensei_WC::the_add_to_cart_button_html( $post->ID );
2794
+	            $login_link = '<a href="'.sensei_user_login_url().'">'.__('log in', 'woothemes-sensei').'</a>';
2795
+	            $message = sprintf(__('Or %1$s to access your purchased courses', 'woothemes-sensei'), $login_link);
2796
+	            Sensei()->notices->add_notice($message, 'info');
2797
+	            Sensei_WC::the_add_to_cart_button_html($post->ID);
2798 2798
 
2799 2799
             } else {
2800 2800
 
2801
-                if( get_option( 'users_can_register') ) {
2801
+                if (get_option('users_can_register')) {
2802 2802
 
2803 2803
 	                // set the permissions message
2804
-	                $anchor_before = '<a href="' . esc_url( sensei_user_login_url() ) . '" >';
2804
+	                $anchor_before = '<a href="'.esc_url(sensei_user_login_url()).'" >';
2805 2805
 	                $anchor_after = '</a>';
2806 2806
 	                $notice = sprintf(
2807 2807
 		                __('or log in to view this courses. Click here to %slogin%s.'),
@@ -2810,8 +2810,8 @@  discard block
 block discarded – undo
2810 2810
 	                );
2811 2811
 
2812 2812
 	                // register the notice to display
2813
-	                if( Sensei()->settings->get( 'access_permission' ) ){
2814
-		                Sensei()->notices->add_notice( $notice, 'info' ) ;
2813
+	                if (Sensei()->settings->get('access_permission')) {
2814
+		                Sensei()->notices->add_notice($notice, 'info');
2815 2815
 	                }
2816 2816
 
2817 2817
 
@@ -2828,24 +2828,24 @@  discard block
 block discarded – undo
2828 2828
                     $wp_register_link = apply_filters('sensei_use_wp_register_link', false);
2829 2829
 
2830 2830
                     $settings = Sensei()->settings->get_settings();
2831
-                    if( isset( $settings[ 'my_course_page' ] )
2832
-                        && 0 < intval( $settings[ 'my_course_page' ] ) ){
2831
+                    if (isset($settings['my_course_page'])
2832
+                        && 0 < intval($settings['my_course_page'])) {
2833 2833
 
2834
-                        $my_courses_page_id = $settings[ 'my_course_page' ];
2834
+                        $my_courses_page_id = $settings['my_course_page'];
2835 2835
 
2836 2836
                     }
2837 2837
 
2838 2838
                     // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
2839 2839
                     // is false, link to My Courses. If not, link to default WordPress registration page.
2840
-                    if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){
2840
+                    if ( ! empty($my_courses_page_id) && $my_courses_page_id && ! $wp_register_link) {
2841 2841
 
2842
-                        $my_courses_url = get_permalink( $my_courses_page_id  );
2843
-                        $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
2844
-                        echo '<div class="status register">' . $register_link . '</div>' ;
2842
+                        $my_courses_url = get_permalink($my_courses_page_id);
2843
+                        $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>';
2844
+                        echo '<div class="status register">'.$register_link.'</div>';
2845 2845
 
2846
-                    } else{
2846
+                    } else {
2847 2847
 
2848
-                        wp_register( '<div class="status register">', '</div>' );
2848
+                        wp_register('<div class="status register">', '</div>');
2849 2849
 
2850 2850
                     }
2851 2851
 
@@ -2864,23 +2864,23 @@  discard block
 block discarded – undo
2864 2864
      *
2865 2865
      * @since 1.9.0
2866 2866
      */
2867
-    public static function the_course_video(){
2867
+    public static function the_course_video() {
2868 2868
 
2869 2869
         global $post;
2870 2870
 
2871
-	    if ( ! is_singular( 'course' )  ) {
2871
+	    if ( ! is_singular('course')) {
2872 2872
 		    return;
2873 2873
 	    }
2874 2874
         // Get the meta info
2875
-        $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
2875
+        $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
2876 2876
 
2877
-        if ( 'http' == substr( $course_video_embed, 0, 4) ) {
2877
+        if ('http' == substr($course_video_embed, 0, 4)) {
2878 2878
 
2879
-            $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) );
2879
+            $course_video_embed = wp_oembed_get(esc_url($course_video_embed));
2880 2880
 
2881 2881
         } // End If Statement
2882 2882
 
2883
-        if ( '' != $course_video_embed ) { ?>
2883
+        if ('' != $course_video_embed) { ?>
2884 2884
 
2885 2885
             <div class="course-video">
2886 2886
                 <?php echo html_entity_decode($course_video_embed); ?>
@@ -2895,9 +2895,9 @@  discard block
 block discarded – undo
2895 2895
      * @global $post
2896 2896
      * @since 1.9.0
2897 2897
      */
2898
-    public static function the_title(){
2898
+    public static function the_title() {
2899 2899
 
2900
-	    if( ! is_singular( 'course' ) ){
2900
+	    if ( ! is_singular('course')) {
2901 2901
 			return;
2902 2902
 	    }
2903 2903
         global $post;
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
                 /**
2912 2912
                  * Filter documented in class-sensei-messages.php the_title
2913 2913
                  */
2914
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
2914
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
2915 2915
                 ?>
2916 2916
 
2917 2917
             </h1>
@@ -2927,30 +2927,30 @@  discard block
 block discarded – undo
2927 2927
      *
2928 2928
      * @since 1.9.0
2929 2929
      */
2930
-    public static function course_category_title(){
2930
+    public static function course_category_title() {
2931 2931
 
2932
-        if( ! is_tax( 'course-category' ) ){
2932
+        if ( ! is_tax('course-category')) {
2933 2933
             return;
2934 2934
         }
2935 2935
 
2936 2936
         $category_slug = get_query_var('course-category');
2937
-        $term  = get_term_by('slug',$category_slug,'course-category');
2937
+        $term = get_term_by('slug', $category_slug, 'course-category');
2938 2938
 
2939
-        if( ! empty($term) ){
2939
+        if ( ! empty($term)) {
2940 2940
 
2941 2941
             $title = $term->name;
2942 2942
 
2943
-        }else{
2943
+        } else {
2944 2944
 
2945 2945
             $title = 'Course Category';
2946 2946
 
2947 2947
         }
2948 2948
 
2949 2949
         $html = '<h2 class="sensei-category-title">';
2950
-        $html .= __('Category') . ' ' . $title;
2950
+        $html .= __('Category').' '.$title;
2951 2951
         $html .= '</h2>';
2952 2952
 
2953
-        echo apply_filters( 'course_category_title', $html , $term->term_id );
2953
+        echo apply_filters('course_category_title', $html, $term->term_id);
2954 2954
 
2955 2955
     }// course_category_title
2956 2956
 
@@ -2963,16 +2963,16 @@  discard block
 block discarded – undo
2963 2963
      * @param WP_Query $query
2964 2964
      * @return WP_Query
2965 2965
      */
2966
-    public static function alter_course_category_order( $query ){
2966
+    public static function alter_course_category_order($query) {
2967 2967
 
2968
-        if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){
2968
+        if ( ! is_tax('course-category') || ! $query->is_main_query()) {
2969 2969
             return $query;
2970 2970
         }
2971 2971
 
2972
-        $order = get_option( 'sensei_course_order', '' );
2973
-        if( !empty( $order )  ){
2974
-            $query->set('orderby', 'menu_order' );
2975
-            $query->set('order', 'ASC' );
2972
+        $order = get_option('sensei_course_order', '');
2973
+        if ( ! empty($order)) {
2974
+            $query->set('orderby', 'menu_order');
2975
+            $query->set('order', 'ASC');
2976 2976
         }
2977 2977
 
2978 2978
         return $query;
@@ -2993,7 +2993,7 @@  discard block
 block discarded – undo
2993 2993
      *
2994 2994
      * @return array
2995 2995
      */
2996
-    public static function get_default_query_args(){
2996
+    public static function get_default_query_args() {
2997 2997
         return array(
2998 2998
             'post_type' 		=> 'course',
2999 2999
             'posts_per_page' 		=> 1000,
@@ -3011,14 +3011,14 @@  discard block
 block discarded – undo
3011 3011
      * @param $course_id
3012 3012
      * @return bool
3013 3013
      */
3014
-    public static function is_prerequisite_complete( $course_id ){
3014
+    public static function is_prerequisite_complete($course_id) {
3015 3015
 
3016
-        $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true );
3016
+        $course_prerequisite_id = get_post_meta($course_id, '_course_prerequisite', true);
3017 3017
 
3018 3018
         // if it has a pre requisite course check it
3019
-        if( ! empty(  $course_prerequisite_id ) ){
3019
+        if ( ! empty($course_prerequisite_id)) {
3020 3020
 
3021
-            return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() );
3021
+            return Sensei_Utils::user_completed_course($course_prerequisite_id, get_current_user_id());
3022 3022
 
3023 3023
         }
3024 3024
 
@@ -3034,4 +3034,4 @@  discard block
 block discarded – undo
3034 3034
  * @ignore only for backward compatibility
3035 3035
  * @since 1.9.0
3036 3036
  */
3037
-class WooThemes_Sensei_Course extends Sensei_Course{}
3037
+class WooThemes_Sensei_Course extends Sensei_Course {}
Please login to merge, or discard this patch.
includes/class-sensei-notices.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Notices Class
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  *
12 12
  * @since 1.6.3
13 13
  */
14
-class Sensei_Notices{
14
+class Sensei_Notices {
15 15
 
16 16
 	/**
17 17
 	*  @var $notices
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	*  constructor 
28 28
  	*/
29
-	public function __construct(){
29
+	public function __construct() {
30 30
 		//initialize the notices variable
31 31
 		$this->notices = array();
32 32
 		$this->has_printed = false;
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 * @return void
43 43
 	 */
44 44
 
45
-	public function add_notice( $content ,  $type = 'alert'   ){
45
+	public function add_notice($content, $type = 'alert') {
46 46
 		// append the new notice
47
-		$this->notices[] = array('content' => $content , 'type'=> $type );
47
+		$this->notices[] = array('content' => $content, 'type'=> $type);
48 48
 
49 49
 		// if a notice is added after we've printed print it immediately.
50
-		if( $this->has_printed  ){
50
+		if ($this->has_printed) {
51 51
 			$this->maybe_print_notices();
52 52
 		}
53 53
 
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
 	 * @return void
60 60
 	 */
61 61
 
62
-	public function maybe_print_notices(){
63
-		if(  count( $this->notices ) > 0  ){
62
+	public function maybe_print_notices() {
63
+		if (count($this->notices) > 0) {
64 64
 			foreach ($this->notices  as  $notice) {
65 65
 
66
-				$classes = 'sensei-message '. $notice['type'];
67
-				$html = '<div class="'. $classes . '">'. $notice['content'] . '</div>';
66
+				$classes = 'sensei-message '.$notice['type'];
67
+				$html = '<div class="'.$classes.'">'.$notice['content'].'</div>';
68 68
 
69 69
 				echo $html; 
70 70
 			}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	* 
84 84
 	* @return void
85 85
 	*/
86
-	public function clear_notices(){
86
+	public function clear_notices() {
87 87
 		// assign an empty array to clear all existing notices
88 88
 		$this->notices = array();
89 89
 	} // end clear_notices()
@@ -95,4 +95,4 @@  discard block
 block discarded – undo
95 95
  * @ignore only for backward compatibility
96 96
  * @since 1.9.0
97 97
  */
98
-class Woothemes_Sensei_Notices extends Sensei_Notices{}
98
+class Woothemes_Sensei_Notices extends Sensei_Notices {}
Please login to merge, or discard this patch.
includes/class-sensei-templates.php 1 patch
Spacing   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 /**
4 4
  * Sensei Template Class
5 5
  *
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @return void
23 23
      */
24
-    public static function get_part(  $slug, $name = ''  ){
24
+    public static function get_part($slug, $name = '') {
25 25
 
26 26
         $template = '';
27 27
         $plugin_template_url = Sensei()->template_url;
28
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
28
+        $plugin_template_path = Sensei()->plugin_path()."/templates/";
29 29
 
30 30
         // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
-        if ( $name ){
31
+        if ($name) {
32 32
 
33
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
33
+            $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php"));
34 34
 
35 35
         }
36 36
 
37 37
         // Get default slug-name.php
38
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$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 45
         // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
-        if ( !$template ){
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
 
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
      * @param string $template_path
69 69
      * @param string $default_path
70 70
      */
71
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
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
 
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
      *
99 99
      * @return mixed|void
100 100
      */
101
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
101
+    public static function locate_template($template_name, $template_path = '', $default_path = '') {
102 102
 
103
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
104
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
103
+        if ( ! $template_path) $template_path = Sensei()->template_url;
104
+        if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/';
105 105
 
106 106
         // Look within passed path within the theme - this is priority
107 107
         $template = locate_template(
108 108
             array(
109
-                $template_path . $template_name,
109
+                $template_path.$template_name,
110 110
                 $template_name
111 111
             )
112 112
         );
113 113
 
114 114
         // Get default template
115
-        if ( ! $template ){
115
+        if ( ! $template) {
116 116
 
117
-            $template = $default_path . $template_name;
117
+            $template = $default_path.$template_name;
118 118
 
119 119
         }
120 120
         // return nothing for file that do not exist
121
-        if( !file_exists( $template ) ){
121
+        if ( ! file_exists($template)) {
122 122
             $template = '';
123 123
         }
124 124
 
125 125
         // Return what we found
126
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
126
+        return apply_filters('sensei_locate_template', $template, $template_name, $template_path);
127 127
 
128 128
     } // end locate
129 129
 
@@ -136,122 +136,122 @@  discard block
 block discarded – undo
136 136
      * @param string $template
137 137
      * @return string $template
138 138
      */
139
-    public static function template_loader ( $template = '' ) {
139
+    public static function template_loader($template = '') {
140 140
 
141 141
         global $wp_query, $email_template;
142 142
 
143
-        $find = array( 'woothemes-sensei.php' );
143
+        $find = array('woothemes-sensei.php');
144 144
         $file = '';
145 145
 
146
-        if ( isset( $email_template ) && $email_template ) {
146
+        if (isset($email_template) && $email_template) {
147 147
 
148
-            $file 	= 'emails/' . $email_template;
148
+            $file = 'emails/'.$email_template;
149 149
             $find[] = $file;
150
-            $find[] = Sensei()->template_url . $file;
150
+            $find[] = Sensei()->template_url.$file;
151 151
 
152
-        } elseif ( is_single() && get_post_type() == 'course' ) {
152
+        } elseif (is_single() && get_post_type() == 'course') {
153 153
 
154 154
             // possible backward compatible template include if theme overrides content-single-course.php
155 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 );
156
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true);
157 157
 
158
-            $file 	= 'single-course.php';
158
+            $file = 'single-course.php';
159 159
             $find[] = $file;
160
-            $find[] = Sensei()->template_url . $file;
160
+            $find[] = Sensei()->template_url.$file;
161 161
 
162 162
 
163
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {  // check
163
+        } elseif (is_single() && get_post_type() == 'lesson') {  // check
164 164
 
165 165
             // possible backward compatible template include if theme overrides content-single-lesson.php
166 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 );
167
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true);
168 168
 
169
-            $file 	= 'single-lesson.php';
169
+            $file = 'single-lesson.php';
170 170
             $find[] = $file;
171
-            $find[] = Sensei()->template_url . $file;
171
+            $find[] = Sensei()->template_url.$file;
172 172
 
173
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {  // check
173
+        } elseif (is_single() && get_post_type() == 'quiz') {  // check
174 174
 
175 175
             // possible backward compatible template include if theme overrides content-single-quiz.php
176 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);
177
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true);
178 178
 
179
-            $file 	= 'single-quiz.php';
179
+            $file = 'single-quiz.php';
180 180
             $find[] = $file;
181
-            $find[] = Sensei()->template_url . $file;
181
+            $find[] = Sensei()->template_url.$file;
182 182
 
183 183
 
184
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) { //// check
184
+        } elseif (is_single() && get_post_type() == 'sensei_message') { //// check
185 185
 
186 186
             // possible backward compatible template include if theme overrides content-single-message.php
187 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 );
188
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true);
189 189
 
190
-            $file 	= 'single-message.php';
190
+            $file = 'single-message.php';
191 191
             $find[] = $file;
192
-            $find[] = Sensei()->template_url . $file;
192
+            $find[] = Sensei()->template_url.$file;
193 193
 
194
-        } elseif ( is_post_type_archive( 'course' )
195
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
196
-                    || is_tax( 'course-category' )) {
194
+        } elseif (is_post_type_archive('course')
195
+                    || is_page(Sensei()->get_page_id('courses'))
196
+                    || is_tax('course-category')) {
197 197
 
198 198
             // possible backward compatible template include if theme overrides 'taxonomy-course-category'
199 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');
200
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php');
201 201
 
202
-            $file 	= 'archive-course.php';
202
+            $file = 'archive-course.php';
203 203
             $find[] = $file;
204
-            $find[] = Sensei()->template_url . $file;
204
+            $find[] = Sensei()->template_url.$file;
205 205
 
206
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
206
+        } elseif (is_post_type_archive('sensei_message')) {
207 207
 
208
-            $file 	= 'archive-message.php';
208
+            $file = 'archive-message.php';
209 209
             $find[] = $file;
210
-            $find[] = Sensei()->template_url . $file;
210
+            $find[] = Sensei()->template_url.$file;
211 211
 
212
-        } elseif( is_tax( 'lesson-tag' ) ) {
212
+        } elseif (is_tax('lesson-tag')) {
213 213
 
214 214
             // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
215 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' );
216
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php');
217 217
 
218
-            $file 	= 'archive-lesson.php';
218
+            $file = 'archive-lesson.php';
219 219
             $find[] = $file;
220
-            $find[] = Sensei()->template_url . $file;
220
+            $find[] = Sensei()->template_url.$file;
221 221
 
222
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
222
+        } elseif (isset($wp_query->query_vars['learner_profile'])) {
223 223
 
224 224
             // Override for sites with static home page
225 225
             $wp_query->is_home = false;
226 226
 
227
-            $file 	= 'learner-profile.php';
227
+            $file = 'learner-profile.php';
228 228
             $find[] = $file;
229
-            $find[] = Sensei()->template_url . $file;
229
+            $find[] = Sensei()->template_url.$file;
230 230
 
231
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
231
+        } elseif (isset($wp_query->query_vars['course_results'])) {
232 232
 
233 233
             // Override for sites with static home page
234 234
             $wp_query->is_home = false;
235 235
 
236 236
             $file = 'course-results.php';
237 237
             $find[] = $file;
238
-            $find[] = Sensei()->template_url . $file;
238
+            $find[] = Sensei()->template_url.$file;
239 239
 
240
-        }elseif( is_author()
241
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
242
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
240
+        }elseif (is_author()
241
+                 && Sensei_Teacher::is_a_teacher(get_query_var('author'))
242
+                 && ! user_can(get_query_var('author'), 'manage_options')) {
243 243
 
244 244
             $file = 'teacher-archive.php';
245 245
             $find[] = $file;
246
-            $find[] = Sensei()->template_url . $file;
246
+            $find[] = Sensei()->template_url.$file;
247 247
 
248 248
         } // Load the template file
249 249
 
250 250
 	    // if file is present set it to be loaded otherwise continue with the initial template given by WP
251
-        if ( $file ) {
251
+        if ($file) {
252 252
 
253
-            $template = locate_template( $find );
254
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
253
+            $template = locate_template($find);
254
+            if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
255 255
 
256 256
         } // End If Statement
257 257
 
@@ -271,21 +271,21 @@  discard block
 block discarded – undo
271 271
      *
272 272
      * @since 1.9.0
273 273
      */
274
-    public static function get_no_permission_template( ){
274
+    public static function get_no_permission_template( ) {
275 275
 
276 276
         // possible backward compatible template loading
277 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 );
278
+        self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true);
279 279
 
280
-        $file 	= 'no-permissions.php';
280
+        $file = 'no-permissions.php';
281 281
         $find[] = $file;
282
-        $find[] = Sensei()->template_url . $file;
282
+        $find[] = Sensei()->template_url.$file;
283 283
 
284
-        $template = locate_template( $find );
285
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
284
+        $template = locate_template($find);
285
+        if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
286 286
 
287 287
 	    // set a global constant so that we know that we're in this template
288
-	    define('SENSEI_NO_PERMISSION', true );
288
+	    define('SENSEI_NO_PERMISSION', true);
289 289
 
290 290
         return $template;
291 291
 
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
      * @param string $template
305 305
      * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
306 306
      */
307
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
307
+    public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) {
308 308
 
309
-        $found_template = locate_template( array( $template ) );
310
-        if( $found_template ){
309
+        $found_template = locate_template(array($template));
310
+        if ($found_template) {
311 311
 
312
-            if( $load_header_footer ){
312
+            if ($load_header_footer) {
313 313
 
314 314
                 get_sensei_header();
315
-                include( $found_template );
315
+                include($found_template);
316 316
                 get_sensei_footer();
317 317
 
318
-            }else{
318
+            } else {
319 319
 
320
-                include( $found_template );
320
+                include($found_template);
321 321
 
322 322
             }
323 323
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      *
335 335
      * @deprecated since 1.9.0
336 336
      */
337
-    public static function deprecated_archive_course_content_hook(){
337
+    public static function deprecated_archive_course_content_hook() {
338 338
 
339
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
339
+        sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before');
340 340
 
341 341
     }// end deprecated_archive_hook
342 342
 
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
      * @since 1.9.0
347 347
      * @param  WP_Post $post
348 348
      */
349
-    public static function the_title( $post ){
349
+    public static function the_title($post) {
350 350
 
351 351
         // ID passed in
352
-        if( is_numeric( $post ) ){
353
-            $post = get_post( $post );
352
+        if (is_numeric($post)) {
353
+            $post = get_post($post);
354 354
         }
355 355
 
356 356
         /**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
          *
361 361
          * @param $title_html_tag default is 'h3'
362 362
          */
363
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
363
+        $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3');
364 364
 
365 365
         /**
366 366
          * Filter the title classes
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
          * @since 1.9.0
369 369
          * @param string $title_classes defaults to $post_type-title
370 370
          */
371
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
371
+        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title');
372 372
 
373
-        $html= '';
374
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
375
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
376
-        $html .= $post->post_title ;
373
+        $html = '';
374
+        $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >';
375
+        $html .= '<a href="'.get_permalink($post->ID).'" >';
376
+        $html .= $post->post_title;
377 377
         $html .= '</a>';
378
-        $html .= '</'. $title_html_tag. '>';
378
+        $html .= '</'.$title_html_tag.'>';
379 379
         echo $html;
380 380
 
381 381
     }// end the title
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
      * @since 1.9.0
388 388
      * @deprecated 1.9.0
389 389
      */
390
-    public static function deprecated_single_course_inside_before_hooks(){
390
+    public static function deprecated_single_course_inside_before_hooks() {
391 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' );
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 395
 
396 396
     }// end deprecated_single_course_inside_before_hooks
397 397
 
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
      * @since 1.9.0
403 403
      * @deprecated 1.9.0
404 404
      */
405
-    public static function deprecate_sensei_course_single_lessons_hook(){
405
+    public static function deprecate_sensei_course_single_lessons_hook() {
406 406
 
407
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
407
+        sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after');
408 408
 
409 409
     }// deprecate_sensei_course_single_lessons_hook
410 410
 
@@ -416,13 +416,13 @@  discard block
 block discarded – undo
416 416
      * @since 1.9.0
417 417
      * @deprecated 1.9.0
418 418
      */
419
-    public static function deprecated_single_main_content_hook(){
419
+    public static function deprecated_single_main_content_hook() {
420 420
 
421
-            if( is_singular( 'course' ) ) {
421
+            if (is_singular('course')) {
422 422
 
423 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 424
 
425
-            } elseif( is_singular( 'message' ) ){
425
+            } elseif (is_singular('message')) {
426 426
 
427 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 428
             }
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
      * @since 1.9.0
435 435
      * @deprecated since 1.9.0
436 436
      */
437
-    public static function deprecate_module_before_hook(){
437
+    public static function deprecate_module_before_hook() {
438 438
 
439
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
439
+        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after');
440 440
 
441 441
     }
442 442
 
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
      * @since 1.9.0
446 446
      * @deprecated since 1.9.0
447 447
      */
448
-    public static function deprecate_module_after_hook(){
448
+    public static function deprecate_module_after_hook() {
449 449
 
450
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
450
+        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after');
451 451
 
452 452
     }
453 453
 
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
      * @since 1.9.0
458 458
      * @deprecated since 1.9.0
459 459
      */
460
-    public static function deprecate_all_post_type_single_title_hooks(){
460
+    public static function deprecate_all_post_type_single_title_hooks() {
461 461
 
462
-        if( is_singular( 'sensei_message' ) ){
462
+        if (is_singular('sensei_message')) {
463 463
 
464
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
464
+            sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before');
465 465
 
466 466
         }
467 467
 
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
     public static function deprecate_course_single_meta_hooks() {
478 478
 
479 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' );
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');
484 484
 
485 485
     } // End deprecate_course_single_meta_hooks
486 486
 
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
      */
491 491
     public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
492 492
 
493
-        if( is_singular( 'lesson' ) ){
493
+        if (is_singular('lesson')) {
494 494
 
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() );
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());
497 497
 
498 498
         }
499 499
 
@@ -507,14 +507,14 @@  discard block
 block discarded – undo
507 507
      *
508 508
      * @deprecated since 1.9.0
509 509
      */
510
-    public static function deprecate_sensei_lesson_course_signup_hook(){
510
+    public static function deprecate_sensei_lesson_course_signup_hook() {
511 511
 
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() );
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());
514 514
 
515
-        if(  !$user_taking_course ) {
515
+        if ( ! $user_taking_course) {
516 516
 
517
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
517
+            sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id);
518 518
 
519 519
         }
520 520
     }// end deprecate_sensei_lesson_course_signup_hook
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
      * @since 1.9.0
526 526
      * @deprecated since 1.9.0
527 527
      */
528
-    public static function deprecate_sensei_lesson_single_meta_hook(){
528
+    public static function deprecate_sensei_lesson_single_meta_hook() {
529 529
 
530
-        if ( sensei_can_user_view_lesson()  ) {
530
+        if (sensei_can_user_view_lesson()) {
531 531
 
532
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
532
+            sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after');
533 533
 
534 534
 
535 535
         }
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
      * Deprecate the sensei lesson single title hook
541 541
      * @deprecated since 1.9.0
542 542
      */
543
-    public static function deprecate_sensei_lesson_single_title(){
543
+    public static function deprecate_sensei_lesson_single_title() {
544 544
 
545
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
545
+        sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
546 546
 
547 547
     }// end deprecate_sensei_lesson_single_title
548 548
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
      * hook in the deperecated single main content to the lesson
551 551
      * @deprecated since 1.9.0
552 552
      */
553
-    public  static function deprecate_lesson_single_main_content_hook(){
553
+    public  static function deprecate_lesson_single_main_content_hook() {
554 554
 
555
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
555
+        sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before');
556 556
 
557 557
     }// end sensei_deprecate_lesson_single_main_content_hook
558 558
 
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
      * hook in the deperecated single main content to the lesson
561 561
      * @deprecated since 1.9.0
562 562
      */
563
-    public  static function deprecate_lesson_image_hook(){
563
+    public  static function deprecate_lesson_image_hook() {
564 564
 
565
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
565
+        sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
566 566
 
567 567
     }// end sensei_deprecate_lesson_single_main_content_hook
568 568
 
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
      * @since 1.9.0
574 574
      * @deprecated since 1.9.0
575 575
      */
576
-    public static function deprecate_sensei_login_form_hook(){
576
+    public static function deprecate_sensei_login_form_hook() {
577 577
 
578
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
578
+        sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before');
579 579
 
580 580
     } // end deprecate_sensei_login_form_hook
581 581
 
@@ -588,9 +588,9 @@  discard block
 block discarded – undo
588 588
      *
589 589
      * @since 1.9.0
590 590
      */
591
-    public static function  fire_sensei_complete_course_hook(){
591
+    public static function  fire_sensei_complete_course_hook() {
592 592
 
593
-        do_action( 'sensei_complete_course' );
593
+        do_action('sensei_complete_course');
594 594
 
595 595
     } //fire_sensei_complete_course_hook
596 596
 
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
      *
600 600
      * @since 1.9.0
601 601
      */
602
-    public static function  fire_frontend_messages_hook(){
602
+    public static function  fire_frontend_messages_hook() {
603 603
 
604
-        do_action( 'sensei_frontend_messages' );
604
+        do_action('sensei_frontend_messages');
605 605
 
606 606
     }// end sensei_complete_course_action
607 607
 
@@ -611,9 +611,9 @@  discard block
 block discarded – undo
611 611
      *
612 612
      * @deprected since 1.9.0
613 613
      */
614
-    public static function  deprecate_sensei_before_user_course_content_hook(){
614
+    public static function  deprecate_sensei_before_user_course_content_hook() {
615 615
 
616
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
616
+        sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user());
617 617
 
618 618
     }// deprecate_sensei_before_user_course_content_hook
619 619
 
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
      *
624 624
      * @deprected since 1.9.0
625 625
      */
626
-    public static function  deprecate_sensei_after_user_course_content_hook(){
626
+    public static function  deprecate_sensei_after_user_course_content_hook() {
627 627
 
628
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
628
+        sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user());
629 629
 
630 630
     }// deprecate_sensei_after_user_course_content_hook
631 631
 
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
      * @deprecated since 1.9.0
636 636
      * @since 1.9.0
637 637
      */
638
-    public static function deprecated_archive_message_hooks (){
638
+    public static function deprecated_archive_message_hooks() {
639 639
 
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' );
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');
642 642
 
643 643
     }
644 644
 
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
      *
649 649
      * @deprecated since 1.9.0
650 650
      */
651
-    public static function deprecate_sensei_complete_quiz_action(){
651
+    public static function deprecate_sensei_complete_quiz_action() {
652 652
 
653
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
653
+        sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before');
654 654
 
655 655
     }
656 656
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
      *
661 661
      * @deprecated since 1.9.0
662 662
      */
663
-    public static function deprecate_sensei_quiz_question_type_action(){
663
+    public static function deprecate_sensei_quiz_question_type_action() {
664 664
 
665 665
         // Question Type
666 666
         global $sensei_question_loop;
@@ -670,14 +670,14 @@  discard block
 block discarded – undo
670 670
     }
671 671
 
672 672
 
673
-	public static function the_register_button( $post_id = "" ){
673
+	public static function the_register_button($post_id = "") {
674 674
 
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
 
@@ -687,15 +687,15 @@  discard block
 block discarded – undo
687 687
 
688 688
 		// show a link to the my_courses page or the WordPress register page if
689 689
 		// not my courses page was set in the settings
690
-		if( !empty( $my_courses_page_id ) && $my_courses_page_id ){
690
+		if ( ! empty($my_courses_page_id) && $my_courses_page_id) {
691 691
 
692
-			$my_courses_url = get_permalink( $my_courses_page_id  );
693
-			$register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
694
-			echo '<div class="status register">' . $register_link . '</div>' ;
692
+			$my_courses_url = get_permalink($my_courses_page_id);
693
+			$register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>';
694
+			echo '<div class="status register">'.$register_link.'</div>';
695 695
 
696
-		} else{
696
+		} else {
697 697
 
698
-			wp_register( '<div class="status register">', '</div>' );
698
+			wp_register('<div class="status register">', '</div>');
699 699
 
700 700
 		}
701 701
 
Please login to merge, or discard this patch.