Completed
Push — master ( c847f3...1a4e84 )
by Dwain
05:11
created
includes/class-sensei-posttypes.php 3 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Post Types Class
@@ -146,7 +149,7 @@  discard block
 block discarded – undo
146 149
 
147 150
              return get_page_uri( $settings_course_page->ID );
148 151
 
149
-        }else{
152
+        } else{
150 153
 
151 154
             return 'courses';
152 155
 
Please login to merge, or discard this patch.
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@  discard block
 block discarded – undo
16 16
 	public $slider_labels;
17 17
 	public $role_caps;
18 18
 
19
-    /**
20
-     * @var Sensei_Course
21
-     */
22
-    public $course;
23
-
24
-    /**
25
-     * @var Sensei_Lesson
26
-     */
27
-    public $lesson;
28
-
29
-    /**
30
-     * @var Sensei_Question
31
-     */
32
-    public $question;
33
-
34
-    /**
35
-     * @var Sensei_Quiz
36
-     */
37
-    public $quiz;
19
+	/**
20
+	 * @var Sensei_Course
21
+	 */
22
+	public $course;
23
+
24
+	/**
25
+	 * @var Sensei_Lesson
26
+	 */
27
+	public $lesson;
28
+
29
+	/**
30
+	 * @var Sensei_Question
31
+	 */
32
+	public $question;
33
+
34
+	/**
35
+	 * @var Sensei_Quiz
36
+	 */
37
+	public $quiz;
38 38
 
39 39
 	/**
40 40
 	 * Constructor
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 		// Setup Post Types
46 46
 		$this->labels = array();
47
-        $this->token = 'woothemes-sensei-posttypes';
47
+		$this->token = 'woothemes-sensei-posttypes';
48 48
 
49 49
 		$this->setup_post_type_labels_base();
50 50
 		add_action( 'init', array( $this, 'setup_course_post_type' ), 100 );
@@ -103,94 +103,94 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * Setup the "course" post type, it's admin menu item and the appropriate labels and permissions.
105 105
 	 * @since  1.0.0
106
-     * @uses  Sensei()
106
+	 * @uses  Sensei()
107 107
 	 * @return void
108 108
 	 */
109 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'] ),
113
-		    'public'              => true,
114
-		    'publicly_queryable'  => true,
115
-		    'show_ui'             => true,
116
-		    'show_in_menu'        => true,
117
-		    'show_in_admin_bar'   => true,
118
-		    'query_var'           => true,
119
-		    'rewrite'             => array(
120
-                'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) ,
121
-                'with_front' => true,
122
-                'feeds' => true,
123
-                'pages' => true
124
-            ),
125
-		    'map_meta_cap'        => true,
126
-		    'capability_type'     => 'course',
127
-            'has_archive'         => $this->get_course_post_type_archive_slug(),
128
-		    'hierarchical'        => false,
129
-		    'menu_position'       => 51,
130
-		    'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail' )
112
+			'labels'              => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ),
113
+			'public'              => true,
114
+			'publicly_queryable'  => true,
115
+			'show_ui'             => true,
116
+			'show_in_menu'        => true,
117
+			'show_in_admin_bar'   => true,
118
+			'query_var'           => true,
119
+			'rewrite'             => array(
120
+				'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) ,
121
+				'with_front' => true,
122
+				'feeds' => true,
123
+				'pages' => true
124
+			),
125
+			'map_meta_cap'        => true,
126
+			'capability_type'     => 'course',
127
+			'has_archive'         => $this->get_course_post_type_archive_slug(),
128
+			'hierarchical'        => false,
129
+			'menu_position'       => 51,
130
+			'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail' )
131 131
 		);
132 132
 
133
-        /**
134
-         * Filter the arguments passed in when registering the Sensei Course post type.
135
-         *
136
-         * @since 1.9.0
137
-         * @param array $args
138
-         */
133
+		/**
134
+		 * Filter the arguments passed in when registering the Sensei Course post type.
135
+		 *
136
+		 * @since 1.9.0
137
+		 * @param array $args
138
+		 */
139 139
 		register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) );
140 140
 
141 141
 	} // End setup_course_post_type()
142 142
 
143
-    /**
144
-     * Figure out of the course post type has an archive and what it should be.
145
-     *
146
-     * This function should return 'courses' or the page_uri for the course page setting.
147
-     *
148
-     * For backward compatibility  sake ( pre 1.9 )If the course page set in settings
149
-     * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the
150
-     * page slug will not be returned. For any other pages without it the page URI will be returned.
151
-     *
152
-     *
153
-     * @sine 1.9.0
154
-     *
155
-     *
156
-     * @return false|string
157
-     */
158
-    public function get_course_post_type_archive_slug(){
143
+	/**
144
+	 * Figure out of the course post type has an archive and what it should be.
145
+	 *
146
+	 * This function should return 'courses' or the page_uri for the course page setting.
147
+	 *
148
+	 * For backward compatibility  sake ( pre 1.9 )If the course page set in settings
149
+	 * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the
150
+	 * page slug will not be returned. For any other pages without it the page URI will be returned.
151
+	 *
152
+	 *
153
+	 * @sine 1.9.0
154
+	 *
155
+	 *
156
+	 * @return false|string
157
+	 */
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
-        // for a valid post that doesn't have any of the old short codes set the archive the same
163
-        // as the page URI
164
-        if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){
162
+		// for a valid post that doesn't have any of the old short codes set the archive the same
163
+		// as the page URI
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
-            return 'courses';
170
+			return 'courses';
171 171
 
172
-        }
172
+		}
173 173
 
174
-    }// end course_post_type_determine_archive
174
+	}// end course_post_type_determine_archive
175 175
 
176
-    /**
177
-     * Check if given content has any of these old shortcodes:
178
-     * [newcourses][featuredcourses][freecourses][paidcourses]
179
-     *
180
-     * @since 1.9.0
181
-     *
182
-     * @param string $content
183
-     *
184
-     * @return bool
185
-     */
186
-    public function has_old_shortcodes( $content ){
176
+	/**
177
+	 * Check if given content has any of these old shortcodes:
178
+	 * [newcourses][featuredcourses][freecourses][paidcourses]
179
+	 *
180
+	 * @since 1.9.0
181
+	 *
182
+	 * @param string $content
183
+	 *
184
+	 * @return bool
185
+	 */
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
-    }// end has old shortcodes
193
+	}// end has old shortcodes
194 194
 
195 195
 
196 196
 	/**
@@ -211,32 +211,32 @@  discard block
 block discarded – undo
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'] ),
215
-		    'public' => true,
216
-		    'publicly_queryable' => true,
217
-		    'show_ui' => true,
218
-		    'show_in_menu' => true,
219
-		    'query_var' => true,
220
-		    'rewrite' => array(
221
-                'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) ,
222
-                'with_front' =>  true,
223
-                'feeds' => true,
224
-                'pages' => true
225
-            ),
226
-		    'map_meta_cap' => true,
227
-		    'capability_type' => 'lesson',
228
-		    'has_archive' => true,
229
-		    'hierarchical' => false,
230
-		    'menu_position' => 52,
231
-		    'supports' => $supports_array
214
+			'labels' => $this->create_post_type_labels(  $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ),
215
+			'public' => true,
216
+			'publicly_queryable' => true,
217
+			'show_ui' => true,
218
+			'show_in_menu' => true,
219
+			'query_var' => true,
220
+			'rewrite' => array(
221
+				'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) ,
222
+				'with_front' =>  true,
223
+				'feeds' => true,
224
+				'pages' => true
225
+			),
226
+			'map_meta_cap' => true,
227
+			'capability_type' => 'lesson',
228
+			'has_archive' => true,
229
+			'hierarchical' => false,
230
+			'menu_position' => 52,
231
+			'supports' => $supports_array
232 232
 		);
233 233
 
234
-        /**
235
-         * Filter the arguments passed in when registering the Sensei Lesson post type.
236
-         *
237
-         * @since 1.9.0
238
-         * @param array $args
239
-         */
234
+		/**
235
+		 * Filter the arguments passed in when registering the Sensei Lesson post type.
236
+		 *
237
+		 * @since 1.9.0
238
+		 * @param array $args
239
+		 */
240 240
 		register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) );
241 241
 
242 242
 	} // End setup_lesson_post_type()
@@ -244,44 +244,44 @@  discard block
 block discarded – undo
244 244
 	/**
245 245
 	 * Setup the "quiz" post type, it's admin menu item and the appropriate labels and permissions.
246 246
 	 * @since  1.0.0
247
-     * @uses  Sensei()
247
+	 * @uses  Sensei()
248 248
 	 * @return void
249 249
 	 */
250 250
 	public function setup_quiz_post_type () {
251 251
 
252 252
 		$args = array(
253
-		    'labels' => $this->create_post_type_labels(
254
-                $this->labels['quiz']['singular'],
255
-                $this->labels['quiz']['plural'],
256
-                $this->labels['quiz']['menu']
257
-            ),
258
-		    'public' => true,
259
-		    'publicly_queryable' => true,
260
-		    'show_ui' => true,
261
-		    'show_in_menu' => false,
262
-		    'show_in_nav_menus' => false,
263
-		    'query_var' => true,
264
-		    'exclude_from_search' => true,
265
-		    'rewrite' => array(
266
-                'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) ,
267
-                'with_front' =>  true,
268
-                'feeds' => true,
269
-                'pages' => true
270
-            ),
271
-		    'map_meta_cap' => true,
272
-		    'capability_type' => 'quiz',
273
-		    'has_archive' => false,
274
-		    'hierarchical' => false,
275
-		    'menu_position' => 20, // Below "Pages"
276
-		    'supports' => array( '' )
253
+			'labels' => $this->create_post_type_labels(
254
+				$this->labels['quiz']['singular'],
255
+				$this->labels['quiz']['plural'],
256
+				$this->labels['quiz']['menu']
257
+			),
258
+			'public' => true,
259
+			'publicly_queryable' => true,
260
+			'show_ui' => true,
261
+			'show_in_menu' => false,
262
+			'show_in_nav_menus' => false,
263
+			'query_var' => true,
264
+			'exclude_from_search' => true,
265
+			'rewrite' => array(
266
+				'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) ,
267
+				'with_front' =>  true,
268
+				'feeds' => true,
269
+				'pages' => true
270
+			),
271
+			'map_meta_cap' => true,
272
+			'capability_type' => 'quiz',
273
+			'has_archive' => false,
274
+			'hierarchical' => false,
275
+			'menu_position' => 20, // Below "Pages"
276
+			'supports' => array( '' )
277 277
 		);
278 278
 
279
-        /**
280
-         * Filter the arguments passed in when registering the Sensei Quiz post type.
281
-         *
282
-         * @since 1.9.0
283
-         * @param array $args
284
-         */
279
+		/**
280
+		 * Filter the arguments passed in when registering the Sensei Quiz post type.
281
+		 *
282
+		 * @since 1.9.0
283
+		 * @param array $args
284
+		 */
285 285
 		register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) );
286 286
 
287 287
 	} // End setup_quiz_post_type()
@@ -295,34 +295,34 @@  discard block
 block discarded – undo
295 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'] ),
299
-		    'public' => false,
300
-		    'publicly_queryable' => true,
301
-		    'show_ui' => true,
302
-		    'show_in_menu' => true,
303
-		    'show_in_nav_menus' => false,
304
-		    'query_var' => true,
305
-		    'exclude_from_search' => true,
306
-		    'rewrite' => array(
307
-                'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
308
-                'with_front' =>  true,
309
-                'feeds' => true,
310
-                'pages' => true
311
-            ),
312
-		    'map_meta_cap' => true,
313
-		    'capability_type' => 'question',
314
-		    'has_archive' => true,
315
-		    'hierarchical' => false,
316
-		    'menu_position' => 51,
317
-		    'supports' => array( 'title' )
298
+			'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ),
299
+			'public' => false,
300
+			'publicly_queryable' => true,
301
+			'show_ui' => true,
302
+			'show_in_menu' => true,
303
+			'show_in_nav_menus' => false,
304
+			'query_var' => true,
305
+			'exclude_from_search' => true,
306
+			'rewrite' => array(
307
+				'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
308
+				'with_front' =>  true,
309
+				'feeds' => true,
310
+				'pages' => true
311
+			),
312
+			'map_meta_cap' => true,
313
+			'capability_type' => 'question',
314
+			'has_archive' => true,
315
+			'hierarchical' => false,
316
+			'menu_position' => 51,
317
+			'supports' => array( 'title' )
318 318
 		);
319 319
 
320
-        /**
321
-         * Filter the arguments passed in when registering the Sensei Question post type.
322
-         *
323
-         * @since 1.9.0
324
-         * @param array $args
325
-         */
320
+		/**
321
+		 * Filter the arguments passed in when registering the Sensei Question post type.
322
+		 *
323
+		 * @since 1.9.0
324
+		 * @param array $args
325
+		 */
326 326
 		register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) );
327 327
 
328 328
 	} // End setup_question_post_type()
@@ -335,26 +335,26 @@  discard block
 block discarded – undo
335 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'] ),
339
-		    'public' => false,
340
-		    'publicly_queryable' => false,
341
-		    'show_ui' => false,
342
-		    'show_in_menu' => false,
343
-		    'show_in_nav_menus' => false,
344
-		    'query_var' => false,
345
-		    'exclude_from_search' => true,
346
-		    'rewrite' => array(
347
-                'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
348
-                'with_front' =>  false,
349
-                'feeds' => false,
350
-                'pages' => false
351
-            ),
352
-		    'map_meta_cap' => true,
353
-		    'capability_type' => 'question',
354
-		    'has_archive' => false,
355
-		    'hierarchical' => false,
356
-		    'menu_position' => 51,
357
-		    'supports' => array( 'title', 'custom-fields' )
338
+			'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ),
339
+			'public' => false,
340
+			'publicly_queryable' => false,
341
+			'show_ui' => false,
342
+			'show_in_menu' => false,
343
+			'show_in_nav_menus' => false,
344
+			'query_var' => false,
345
+			'exclude_from_search' => true,
346
+			'rewrite' => array(
347
+				'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) ,
348
+				'with_front' =>  false,
349
+				'feeds' => false,
350
+				'pages' => false
351
+			),
352
+			'map_meta_cap' => true,
353
+			'capability_type' => 'question',
354
+			'has_archive' => false,
355
+			'hierarchical' => false,
356
+			'menu_position' => 51,
357
+			'supports' => array( 'title', 'custom-fields' )
358 358
 		);
359 359
 
360 360
 		register_post_type( 'multiple_question', $args );
@@ -370,34 +370,34 @@  discard block
 block discarded – undo
370 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'] ),
374
-			    'public' => true,
375
-			    'publicly_queryable' => true,
376
-			    'show_ui' => true,
377
-			    'show_in_menu' => 'admin.php?page=sensei',
378
-			    'show_in_nav_menus' => true,
379
-			    'query_var' => true,
380
-			    'exclude_from_search' => true,
381
-			    'rewrite' => array(
382
-                    'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) ,
383
-                    'with_front' =>  false,
384
-                    'feeds' => false,
385
-                    'pages' => true
386
-                ),
387
-			    'map_meta_cap' => true,
388
-			    'capability_type' => 'question',
389
-			    'has_archive' => true,
390
-			    'hierarchical' => false,
391
-			    'menu_position' => 50,
392
-			    'supports' => array( 'title', 'editor', 'comments' ),
373
+				'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ),
374
+				'public' => true,
375
+				'publicly_queryable' => true,
376
+				'show_ui' => true,
377
+				'show_in_menu' => 'admin.php?page=sensei',
378
+				'show_in_nav_menus' => true,
379
+				'query_var' => true,
380
+				'exclude_from_search' => true,
381
+				'rewrite' => array(
382
+					'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) ,
383
+					'with_front' =>  false,
384
+					'feeds' => false,
385
+					'pages' => true
386
+				),
387
+				'map_meta_cap' => true,
388
+				'capability_type' => 'question',
389
+				'has_archive' => true,
390
+				'hierarchical' => false,
391
+				'menu_position' => 50,
392
+				'supports' => array( 'title', 'editor', 'comments' ),
393 393
 			);
394 394
 
395
-            /**
396
-             * Filter the arguments passed in when registering the Sensei sensei_message post type.
397
-             *
398
-             * @since 1.9.0
399
-             * @param array $args
400
-             */
395
+			/**
396
+			 * Filter the arguments passed in when registering the Sensei sensei_message post type.
397
+			 *
398
+			 * @since 1.9.0
399
+			 * @param array $args
400
+			 */
401 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()
@@ -430,11 +430,11 @@  discard block
 block discarded – undo
430 430
 			'show_ui' => true,
431 431
 			'query_var' => true,
432 432
 			'show_in_nav_menus' => true,
433
-            'capabilities' => array(
434
-                'manage_terms' => 'manage_categories',
435
-                'edit_terms'   => 'edit_courses',
436
-                'delete_terms' => 'manage_categories',
437
-                'assign_terms' => 'edit_courses',),
433
+			'capabilities' => array(
434
+				'manage_terms' => 'manage_categories',
435
+				'edit_terms'   => 'edit_courses',
436
+				'delete_terms' => 'manage_categories',
437
+				'assign_terms' => 'edit_courses',),
438 438
 			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
439 439
 		);
440 440
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 			'show_ui' => true, /* TO DO - future releases */
472 472
 			'query_var' => true,
473 473
 			'show_in_nav_menus' => false,
474
-            'public' => false,
474
+			'public' => false,
475 475
 			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
476 476
 		);
477 477
 
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 			'query_var' => false,
545 545
 			'show_in_nav_menus' => false,
546 546
 			'show_admin_column' => true,
547
-            'capabilities' => array(
548
-                'manage_terms' => 'manage_categories',
549
-                'edit_terms'   => 'edit_questions',
550
-                'delete_terms' => 'manage_categories',
551
-                'assign_terms' => 'edit_questions',),
547
+			'capabilities' => array(
548
+				'manage_terms' => 'manage_categories',
549
+				'edit_terms'   => 'edit_questions',
550
+				'delete_terms' => 'manage_categories',
551
+				'assign_terms' => 'edit_questions',),
552 552
 			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
553 553
 		);
554 554
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
 			'show_ui' => true,
583 583
 			'query_var' => true,
584 584
 			'show_in_nav_menus' => true,
585
-            'capabilities' => array(
586
-                'manage_terms' => 'manage_categories',
587
-                'edit_terms'   => 'edit_lessons',
588
-                'delete_terms' => 'manage_categories',
589
-                'assign_terms' => 'edit_lessons',),
585
+			'capabilities' => array(
586
+				'manage_terms' => 'manage_categories',
587
+				'edit_terms'   => 'edit_lessons',
588
+				'delete_terms' => 'manage_categories',
589
+				'assign_terms' => 'edit_lessons',),
590 590
 			'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) )
591 591
 		);
592 592
 
@@ -623,19 +623,19 @@  discard block
 block discarded – undo
623 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 ),
637
-		    'parent_item_colon' => '',
638
-		    'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu )
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
+			'parent_item_colon' => '',
638
+			'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu )
639 639
 		  );
640 640
 
641 641
 		return $labels;
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	 * Assigns the defaults for each user role capabilities.
709 709
 	 *
710 710
 	 * @since  1.1.0
711
-     *
711
+	 *
712 712
 	 * @param array $post_types
713 713
 	 * @return void
714 714
 	 */
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 	 * Adds a 'Edit Quiz' link to the admin bar when viewing a Quiz linked to a corresponding Lesson
777 777
 	 * 
778 778
 	 * @since  1.7.0
779
-     * @param WP_Admin_Bar $bar
779
+	 * @param WP_Admin_Bar $bar
780 780
 	 * @return void
781 781
 	 */
782 782
 	public function quiz_admin_bar_menu( $bar ) {
Please login to merge, or discard this 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.
includes/class-sensei-notices.php 4 patches
Spacing   +11 added lines, -11 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
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @since 1.6.3
14 14
  */
15 15
 
16
-class Sensei_Notices{
16
+class Sensei_Notices {
17 17
 
18 18
 	/**
19 19
 	*  @var $notices
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	*  constructor 
25 25
  	*/
26
-	public function __construct(){
26
+	public function __construct() {
27 27
 		//initialize the notices variable
28 28
 		$this->notices = array();
29 29
 	}
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	* @return void
40 40
 	*/
41 41
 
42
-	public function add_notice( $content ,  $type = 'alert'   ){
42
+	public function add_notice($content, $type = 'alert') {
43 43
 		// append the new notice
44
-		$this->notices[] = array('content' => $content , 'type'=> $type );
44
+		$this->notices[] = array('content' => $content, 'type'=> $type);
45 45
 	} // end add_notice()
46 46
 
47 47
 	/**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	* @return void
54 54
 	*/
55 55
 
56
-	public function print_notices(){
57
-		if(  count( $this->notices ) > 0  ){
56
+	public function print_notices() {
57
+		if (count($this->notices) > 0) {
58 58
 			foreach ($this->notices  as  $notice) {
59 59
 
60
-				$classes = 'sensei-message '. $notice['type'];
61
-				$html = '<div class="'. $classes . '">'. $notice['content'] . '</div>';
60
+				$classes = 'sensei-message '.$notice['type'];
61
+				$html = '<div class="'.$classes.'">'.$notice['content'].'</div>';
62 62
 
63 63
 				echo $html; 
64 64
 			}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	* @return void
74 74
 	*/
75 75
 
76
-	public function clear_notices(){
76
+	public function clear_notices() {
77 77
 		// assign an empty array to clear all existing notices
78 78
 		$this->notices = array();
79 79
 	} // end clear_notices()
@@ -85,4 +85,4 @@  discard block
 block discarded – undo
85 85
  * for backward compatibility
86 86
  * @since 1.9.0
87 87
  */
88
-class Woothemes_Sensei_Notices extends Sensei_Notices{}
88
+class Woothemes_Sensei_Notices extends Sensei_Notices {}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Doc Comments   -8 removed lines patch added patch discarded remove patch
@@ -33,10 +33,6 @@  discard block
 block discarded – undo
33 33
 	* 
34 34
 	*
35 35
 	* 
36
-	* @param string $message 
37
-	* @param string $type defaults to alert options( alert, tick , download , info   )
38
-	*
39
-	* @return void
40 36
 	*/
41 37
 
42 38
 	public function add_notice( $content ,  $type = 'alert'   ){
@@ -47,10 +43,6 @@  discard block
 block discarded – undo
47 43
 	/**
48 44
 	*  Output all notices added 
49 45
 	* 
50
-	* @param string $message 
51
-	* @param string $type
52
-	*
53
-	* @return void
54 46
 	*/
55 47
 
56 48
 	public function print_notices(){
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,28 +16,28 @@  discard block
 block discarded – undo
16 16
 class Sensei_Notices{
17 17
 
18 18
 	/**
19
-	*  @var $notices
20
-	*/
19
+	 *  @var $notices
20
+	 */
21 21
 	protected $notices;
22 22
 
23 23
 	/**
24
-	*  constructor 
25
- 	*/
24
+	 *  constructor 
25
+	 */
26 26
 	public function __construct(){
27 27
 		//initialize the notices variable
28 28
 		$this->notices = array();
29 29
 	}
30 30
 
31 31
 	/**
32
-	*  Add a notice to the array of notices for display at a later stage.
33
-	* 
34
-	*
35
-	* 
36
-	* @param string $message 
37
-	* @param string $type defaults to alert options( alert, tick , download , info   )
38
-	*
39
-	* @return void
40
-	*/
32
+	 *  Add a notice to the array of notices for display at a later stage.
33
+	 * 
34
+	 *
35
+	 * 
36
+	 * @param string $message 
37
+	 * @param string $type defaults to alert options( alert, tick , download , info   )
38
+	 *
39
+	 * @return void
40
+	 */
41 41
 
42 42
 	public function add_notice( $content ,  $type = 'alert'   ){
43 43
 		// append the new notice
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	} // end add_notice()
46 46
 
47 47
 	/**
48
-	*  Output all notices added 
49
-	* 
50
-	* @param string $message 
51
-	* @param string $type
52
-	*
53
-	* @return void
54
-	*/
48
+	 *  Output all notices added 
49
+	 * 
50
+	 * @param string $message 
51
+	 * @param string $type
52
+	 *
53
+	 * @return void
54
+	 */
55 55
 
56 56
 	public function print_notices(){
57 57
 		if(  count( $this->notices ) > 0  ){
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 	} // end print_notice()
69 69
 
70 70
 	/**
71
-	*  Clear all notices  
72
-	* 
73
-	* @return void
74
-	*/
71
+	 *  Clear all notices  
72
+	 * 
73
+	 * @return void
74
+	 */
75 75
 
76 76
 	public function clear_notices(){
77 77
 		// assign an empty array to clear all existing notices
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-teacher-completed-lesson.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Completed_Lesson' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Completed_Lesson')) :
6 6
 
7 7
 /**
8 8
  * Teacher Completed Lesson
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function __construct() {
33 33
 		$this->template = 'teacher-completed-lesson';
34
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has completed a lesson', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
35
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has completed a lesson', 'woothemes-sensei' ), $this->template );
34
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has completed a lesson', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
35
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has completed a lesson', 'woothemes-sensei'), $this->template);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,31 +41,31 @@  discard block
 block discarded – undo
41 41
 	 * @access public
42 42
 	 * @return void
43 43
 	 */
44
-	function trigger( $learner_id = 0, $lesson_id = 0 ) {
44
+	function trigger($learner_id = 0, $lesson_id = 0) {
45 45
 		global $sensei_email_data;
46 46
 
47 47
 		// Get learner user object
48
-		$this->learner = new WP_User( $learner_id );
48
+		$this->learner = new WP_User($learner_id);
49 49
 
50 50
 		// Get teacher ID and user object
51
-		$teacher_id = get_post_field( 'post_author', $lesson_id, 'raw' );
52
-		$this->teacher = new WP_User( $teacher_id );
51
+		$teacher_id = get_post_field('post_author', $lesson_id, 'raw');
52
+		$this->teacher = new WP_User($teacher_id);
53 53
 
54 54
         // Construct data array
55
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
55
+		$sensei_email_data = apply_filters('sensei_email_data', array(
56 56
 			'template'			=> $this->template,
57 57
 			'heading'			=> $this->heading,
58 58
 			'teacher_id'		=> $teacher_id,
59 59
 			'learner_id'		=> $learner_id,
60 60
 			'learner_name'		=> $this->learner->display_name,
61 61
 			'lesson_id'			=> $lesson_id,
62
-		), $this->template );
62
+		), $this->template);
63 63
 
64 64
 		// Set recipient (teacher)
65
-		$this->recipient = stripslashes( $this->teacher->user_email );
65
+		$this->recipient = stripslashes($this->teacher->user_email);
66 66
 
67 67
 		// Send mail
68
-        Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
68
+        Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
69 69
 	}
70 70
 }
71 71
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * trigger function.
37 37
 	 *
38
-     * @param int $learner_id
39
-     * @param int $lesson_id
40
-     *
38
+	 * @param int $learner_id
39
+	 * @param int $lesson_id
40
+	 *
41 41
 	 * @return void
42 42
 	 */
43 43
 	function trigger( $learner_id = 0, $lesson_id = 0 ) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$teacher_id = get_post_field( 'post_author', $lesson_id, 'raw' );
52 52
 		$this->teacher = new WP_User( $teacher_id );
53 53
 
54
-        // Construct data array
54
+		// Construct data array
55 55
 		$sensei_email_data = apply_filters( 'sensei_email_data', array(
56 56
 			'template'			=> $this->template,
57 57
 			'heading'			=> $this->heading,
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->recipient = stripslashes( $this->teacher->user_email );
66 66
 
67 67
 		// Send mail
68
-        Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
68
+		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
69 69
 	}
70 70
 }
71 71
 
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-teacher-quiz-submitted.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Quiz_Submitted' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Quiz_Submitted')) :
6 6
 
7 7
 /**
8 8
  * Teacher Quiz Submitted
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function __construct() {
33 33
 		$this->template = 'teacher-quiz-submitted';
34
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has submitted a quiz for grading', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
35
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has submitted a quiz for grading', 'woothemes-sensei' ), $this->template );
34
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has submitted a quiz for grading', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
35
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has submitted a quiz for grading', 'woothemes-sensei'), $this->template);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	 * @access public
42 42
 	 * @return void
43 43
 	 */
44
-	function trigger( $learner_id = 0, $quiz_id = 0 ) {
44
+	function trigger($learner_id = 0, $quiz_id = 0) {
45 45
 		global  $sensei_email_data;
46 46
 
47 47
 		// Get learner user object
48
-		$this->learner = new WP_User( $learner_id );
48
+		$this->learner = new WP_User($learner_id);
49 49
 
50 50
 		// Get teacher ID and user object
51
-        $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
52
-        $course_id = get_post_meta( $lesson_id, '_lesson_course', true );
53
-		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
54
-		$this->teacher = new WP_User( $teacher_id );
51
+        $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
52
+        $course_id = get_post_meta($lesson_id, '_lesson_course', true);
53
+		$teacher_id = get_post_field('post_author', $course_id, 'raw');
54
+		$this->teacher = new WP_User($teacher_id);
55 55
 
56 56
 		// Construct data array
57
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
57
+		$sensei_email_data = apply_filters('sensei_email_data', array(
58 58
 			'template'			=> $this->template,
59 59
 			'heading'			=> $this->heading,
60 60
 			'teacher_id'		=> $teacher_id,
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 			'learner_name'		=> $this->learner->display_name,
63 63
 			'quiz_id'			=> $quiz_id,
64 64
 			'lesson_id'			=> $lesson_id,
65
-		), $this->template );
65
+		), $this->template);
66 66
 
67 67
 		// Set recipient (teacher)
68
-		$this->recipient = stripslashes( $this->teacher->user_email );
68
+		$this->recipient = stripslashes($this->teacher->user_email);
69 69
 
70 70
 		// Send mail
71
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
71
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
72 72
 	}
73 73
 }
74 74
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 
35 35
 	/**
36 36
 	 * trigger function.
37
-     *
38
-     * @param integer $learner_id
39
-     * @param integer $quiz_id
40
-     *
37
+	 *
38
+	 * @param integer $learner_id
39
+	 * @param integer $quiz_id
40
+	 *
41 41
 	 * @return void
42 42
 	 */
43 43
 	function trigger( $learner_id = 0, $quiz_id = 0 ) {
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 		$this->learner = new WP_User( $learner_id );
48 48
 
49 49
 		// Get teacher ID and user object
50
-        $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
51
-        $course_id = get_post_meta( $lesson_id, '_lesson_course', true );
50
+		$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
51
+		$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
52 52
 		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
53 53
 		$this->teacher = new WP_User( $teacher_id );
54 54
 
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-teacher-new-message.php 3 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_New_Message' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_New_Message')) :
6 6
 
7 7
 /**
8 8
  * Teacher New Message
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	function __construct() {
34 34
 		$this->template = 'teacher-new-message';
35
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have received a new private message', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
36
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has sent you a private message', 'woothemes-sensei' ), $this->template );
35
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have received a new private message', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
36
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has sent you a private message', 'woothemes-sensei'), $this->template);
37 37
 	}
38 38
 
39 39
 	/**
@@ -42,29 +42,29 @@  discard block
 block discarded – undo
42 42
 	 * @access public
43 43
 	 * @return void
44 44
 	 */
45
-	function trigger( $message_id = 0 ) {
45
+	function trigger($message_id = 0) {
46 46
 		global  $sensei_email_data;
47 47
 
48
-		$this->message = get_post( $message_id );
48
+		$this->message = get_post($message_id);
49 49
 
50
-		$learner_username = get_post_meta( $message_id, '_sender', true );
51
-		$this->learner = get_user_by( 'login', $learner_username );
50
+		$learner_username = get_post_meta($message_id, '_sender', true);
51
+		$this->learner = get_user_by('login', $learner_username);
52 52
 
53
-		$teacher_username = get_post_meta( $message_id, '_receiver', true );
54
-		$this->teacher = get_user_by( 'login', $teacher_username );
53
+		$teacher_username = get_post_meta($message_id, '_receiver', true);
54
+		$this->teacher = get_user_by('login', $teacher_username);
55 55
 
56
-		$content_type = get_post_meta( $message_id, '_posttype', true );
57
-		$content_id = get_post_meta( $message_id, '_post', true );
58
-		$content_title = get_the_title( $content_id );
56
+		$content_type = get_post_meta($message_id, '_posttype', true);
57
+		$content_id = get_post_meta($message_id, '_post', true);
58
+		$content_title = get_the_title($content_id);
59 59
 
60 60
         // setup the post type parameter
61
-        $content_type = get_post_type( $content_id );
62
-        if( !$content_type ){
63
-            $content_type ='';
61
+        $content_type = get_post_type($content_id);
62
+        if ( ! $content_type) {
63
+            $content_type = '';
64 64
         }
65 65
 
66 66
 		// Construct data array
67
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
67
+		$sensei_email_data = apply_filters('sensei_email_data', array(
68 68
 			'template'			=> $this->template,
69 69
             $content_type.'_id' => $content_id,
70 70
 			'heading'			=> $this->heading,
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
 			'message'			=> $this->message->post_content,
76 76
 			'content_title'		=> $content_title,
77 77
 			'content_type'		=> $content_type,
78
-		), $this->template );
78
+		), $this->template);
79 79
 
80 80
 		// Set recipient (teacher)
81
-		$this->recipient = stripslashes( $this->teacher->user_email );
81
+		$this->recipient = stripslashes($this->teacher->user_email);
82 82
 
83 83
 		// Send mail
84
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
84
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
85 85
 
86
-		wp_safe_redirect( esc_url_raw( add_query_arg( array( 'send' => 'complete' ) ) ) );
86
+		wp_safe_redirect(esc_url_raw(add_query_arg(array('send' => 'complete'))));
87 87
 		exit;
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * trigger function.
38 38
 	 *
39 39
 	 * @access public
40
-     * @param integer $message_id
40
+	 * @param integer $message_id
41 41
 	 * @return void
42 42
 	 */
43 43
 	function trigger( $message_id = 0 ) {
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
 		$content_id = get_post_meta( $message_id, '_post', true );
56 56
 		$content_title = get_the_title( $content_id );
57 57
 
58
-        // setup the post type parameter
59
-        $content_type = get_post_type( $content_id );
60
-        if( !$content_type ){
61
-            $content_type ='';
62
-        }
58
+		// setup the post type parameter
59
+		$content_type = get_post_type( $content_id );
60
+		if( !$content_type ){
61
+			$content_type ='';
62
+		}
63 63
 
64 64
 		// Construct data array
65 65
 		$sensei_email_data = apply_filters( 'sensei_email_data', array(
66 66
 			'template'			=> $this->template,
67
-            $content_type.'_id' => $content_id,
67
+			$content_type.'_id' => $content_id,
68 68
 			'heading'			=> $this->heading,
69 69
 			'teacher_id'		=> $this->teacher->ID,
70 70
 			'learner_id'		=> $this->learner->ID,
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-teacher-started-course.php 3 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Started_Course' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Started_Course')) :
6 6
 
7 7
 /**
8 8
  * Teacher Started Course
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function __construct() {
33 33
 		$this->template = 'teacher-started-course';
34
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has started a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
35
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has started a course', 'woothemes-sensei' ), $this->template );
34
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has started a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
35
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has started a course', 'woothemes-sensei'), $this->template);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,31 +41,31 @@  discard block
 block discarded – undo
41 41
 	 * @access public
42 42
 	 * @return void
43 43
 	 */
44
-	function trigger( $learner_id = 0, $course_id = 0 ) {
44
+	function trigger($learner_id = 0, $course_id = 0) {
45 45
 		global  $sensei_email_data;
46 46
 
47 47
 		// Get learner user object
48
-		$this->learner = new WP_User( $learner_id );
48
+		$this->learner = new WP_User($learner_id);
49 49
 
50 50
 		// Get teacher ID and user object
51
-		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
52
-		$this->teacher = new WP_User( $teacher_id );
51
+		$teacher_id = get_post_field('post_author', $course_id, 'raw');
52
+		$this->teacher = new WP_User($teacher_id);
53 53
 
54 54
 		// Construct data array
55
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
55
+		$sensei_email_data = apply_filters('sensei_email_data', array(
56 56
 			'template'			=> $this->template,
57 57
 			'heading'			=> $this->heading,
58 58
 			'teacher_id'		=> $teacher_id,
59 59
 			'learner_id'		=> $learner_id,
60 60
 			'learner_name'		=> $this->learner->display_name,
61 61
 			'course_id'			=> $course_id,
62
-		), $this->template );
62
+		), $this->template);
63 63
 
64 64
 		// Set recipient (learner)
65
-		$this->recipient = stripslashes( $this->teacher->user_email );
65
+		$this->recipient = stripslashes($this->teacher->user_email);
66 66
 
67 67
 		// Send mail
68
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
68
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
69 69
 	}
70 70
 }
71 71
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@
 block discarded – undo
37 37
 	/**
38 38
 	 * trigger function.
39 39
 	 *
40
-     * @param int $learner_id
41
-     * @param int $course_id
42
-     *
40
+	 * @param int $learner_id
41
+	 * @param int $course_id
42
+	 *
43 43
 	 * @return void
44 44
 	 */
45 45
 	function trigger( $learner_id = 0, $course_id = 0 ) {
Please login to merge, or discard this patch.
includes/class-sensei-grading.php 4 patches
Braces   +20 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Grading Class
@@ -130,8 +133,7 @@  discard block
 block discarded – undo
130 133
 		$object_name = 'WooThemes_Sensei_Grading_' . $name;
131 134
 		if ( is_null($optional_data) ) {
132 135
 			$sensei_grading_object = new $object_name( $data );
133
-		}
134
-		else {
136
+		} else {
135 137
 			$sensei_grading_object = new $object_name( $data, $optional_data );
136 138
 		} // End If Statement
137 139
 		if ( 'Main' == $name ) {
@@ -150,8 +152,7 @@  discard block
 block discarded – undo
150 152
 
151 153
 		if ( isset( $_GET['quiz_id'] ) && 0 < intval( $_GET['quiz_id'] ) && isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) {
152 154
 			$this->grading_user_quiz_view();
153
-		}
154
-		else {
155
+		} else {
155 156
 			$this->grading_default_view();
156 157
 		} // End If Statement
157 158
 	} // End grading_page()
@@ -273,8 +274,7 @@  discard block
 block discarded – undo
273 274
 			if ( version_compare($wp_version, '4.1', '>=') ) {
274 275
 				$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
275 276
 				$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 ) );
276
-			}
277
-			else {
277
+			} else {
278 278
 				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title( $course_id ) ); 
279 279
 			}
280 280
 		}
@@ -309,8 +309,7 @@  discard block
 block discarded – undo
309 309
 			if ( version_compare($wp_version, '4.1', '>=') ) {
310 310
 				$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
311 311
 				$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 ) );
312
-			}
313
-			else {
312
+			} else {
314 313
 				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', get_the_title( $course_id ) ); 
315 314
 			}
316 315
 			$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) );
@@ -379,8 +378,7 @@  discard block
 block discarded – undo
379 378
 
380 379
 		if ( 'course' == $args['type'] ) {
381 380
 			$type = 'sensei_course_status';
382
-		}
383
-		else {
381
+		} else {
384 382
 			$type = 'sensei_lesson_status';
385 383
 		}
386 384
 		$cache_key = 'sensei-' . $args['type'] . '-statuses';
@@ -390,15 +388,13 @@  discard block
 block discarded – undo
390 388
         // Restrict to specific posts
391 389
 		if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) {
392 390
 			$query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')';
393
-		}
394
-		elseif ( !empty( $args['post_id'] ) ) {
391
+		} elseif ( !empty( $args['post_id'] ) ) {
395 392
 			$query .= $wpdb->prepare( ' AND comment_post_ID = %d', $args['post_id'] );
396 393
 		}
397 394
 		// Restrict to specific users
398 395
 		if ( isset( $args['user_id'] ) && is_array( $args['user_id'] ) ) {
399 396
 			$query .= ' AND user_id IN (' . implode( ',', array_map( 'absint', $args['user_id'] ) ) . ')';
400
-		}
401
-		elseif ( !empty( $args['user_id'] ) ) {
397
+		} elseif ( !empty( $args['user_id'] ) ) {
402 398
 			$query .= $wpdb->prepare( ' AND user_id = %d', $args['user_id'] );
403 399
 		}
404 400
 		$query .= ' GROUP BY comment_approved';
@@ -601,8 +597,7 @@  discard block
 block discarded – undo
601 597
             // set the users total quiz grade
602 598
 			if ( 0 < intval( $quiz_grade_total ) ) {
603 599
             $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
604
-			}
605
-			else {
600
+			} else {
606 601
 				$grade = 0;
607 602
 			}
608 603
             WooThemes_Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id );
@@ -615,8 +610,7 @@  discard block
 block discarded – undo
615 610
                 // Student has reached the pass mark and lesson is complete
616 611
                 if ( $quiz_passmark <= $grade ) {
617 612
                     $lesson_status = 'passed';
618
-                }
619
-                else {
613
+                } else {
620 614
                     $lesson_status = 'failed';
621 615
                 } // End If Statement
622 616
             }
@@ -761,8 +755,7 @@  discard block
 block discarded – undo
761 755
 			// Question has a zero grade, so skip grading
762 756
 			if ( 0 == $achievable_grade ) {
763 757
 				$all_question_grades[ $question_id ] = $achievable_grade;
764
-			}
765
-            elseif ( in_array( $question_type, $autogradable_question_types ) ) {
758
+			} elseif ( in_array( $question_type, $autogradable_question_types ) ) {
766 759
                 // Get user question grade
767 760
                 $question_grade = WooThemes_Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id );
768 761
                 $all_question_grades[ $question_id ] = $question_grade;
@@ -784,8 +777,7 @@  discard block
 block discarded – undo
784 777
 			// Check for zero total from grades
785 778
 			if ( 0 < $quiz_total ) {
786 779
             $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
787
-			}
788
-			else {
780
+			} else {
789 781
 				$grade = 0;
790 782
 			}
791 783
             WooThemes_Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type );
@@ -945,19 +937,19 @@  discard block
 block discarded – undo
945 937
 
946 938
                     return Sensei()->question->get_question_grade($question_id);
947 939
 
948
-                }else{
940
+                } else{
949 941
 
950 942
                     return false;
951 943
 
952 944
                 }
953 945
 
954
-            }else{
946
+            } else{
955 947
 
956 948
                 return false;
957 949
 
958 950
             }
959 951
 
960
-        }else{
952
+        } else{
961 953
 
962 954
             // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
963 955
             if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) {
@@ -970,13 +962,13 @@  discard block
 block discarded – undo
970 962
 
971 963
                     return  Sensei()->question->get_question_grade( $question_id );
972 964
 
973
-                }else{
965
+                } else{
974 966
 
975 967
                     return false;
976 968
 
977 969
                 }
978 970
 
979
-            }else{
971
+            } else{
980 972
 
981 973
                 return false;
982 974
 
Please login to merge, or discard this patch.
Doc Comments   +9 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * Constructor
22 22
 	 * @since  1.3.0
23 23
      *
24
-     * @param $file
24
+     * @param string $file
25 25
 	 */
26 26
 	public function __construct ( $file ) {
27 27
 		$this->name = __( 'Grading', 'woothemes-sensei' );
@@ -328,6 +328,7 @@  discard block
 block discarded – undo
328 328
 	/**
329 329
 	 * Return array of valid statuses for either Course or Lesson
330 330
 	 * @since  1.7.0
331
+	 * @param string $type
331 332
 	 * @return array
332 333
 	 */
333 334
 	public function get_stati( $type ) {
@@ -527,7 +528,7 @@  discard block
 block discarded – undo
527 528
      * the grades as the Grader selected theme and saves the total grade and
528 529
      * individual question grades.
529 530
      *
530
-     * @return bool
531
+     * @return false|null
531 532
      */
532 533
     public function admin_process_grading_submission() {
533 534
 
@@ -904,8 +905,8 @@  discard block
 block discarded – undo
904 905
      * Grading logic specifically for the gap fill questions
905 906
      *
906 907
      * @since 1.9.0
907
-     * @param $question_id
908
-     * @param $user_answer
908
+     * @param integer $question_id
909
+     * @param string $user_answer
909 910
      *
910 911
      * @return bool | int false or the grade given to the user answer
911 912
      */
@@ -1009,7 +1010,7 @@  discard block
 block discarded – undo
1009 1010
      * Add together all the graded lesson grades
1010 1011
      *
1011 1012
      * @since 1.9.0
1012
-     * @return double $sum_of_all_grades
1013
+     * @return integer $sum_of_all_grades
1013 1014
      */
1014 1015
     public static function get_graded_lessons_sum(){
1015 1016
 
@@ -1032,7 +1033,7 @@  discard block
 block discarded – undo
1032 1033
      *
1033 1034
      * @since 1.9.0
1034 1035
      * @param $user_id
1035
-     * @return double
1036
+     * @return integer
1036 1037
      */
1037 1038
     public static function get_user_graded_lessons_sum( $user_id ){
1038 1039
         global $wpdb;
@@ -1055,7 +1056,7 @@  discard block
 block discarded – undo
1055 1056
      * @since 1.9.0
1056 1057
      *
1057 1058
      * @param int lesson_id
1058
-     * @return double
1059
+     * @return integer
1059 1060
      */
1060 1061
     public static function get_lessons_users_grades_sum( $lesson_id ){
1061 1062
 
@@ -1080,7 +1081,7 @@  discard block
 block discarded – undo
1080 1081
      * @since 1.9.0
1081 1082
      *
1082 1083
      * @param int $course_id
1083
-     * @return double
1084
+     * @return integer
1084 1085
      */
1085 1086
     public static function get_course_users_grades_sum( $course_id ){
1086 1087
 
Please login to merge, or discard this patch.
Indentation   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * Constructor
22 22
 	 * @since  1.3.0
23
-     *
24
-     * @param $file
23
+	 *
24
+	 * @param $file
25 25
 	 */
26 26
 	public function __construct ( $file ) {
27 27
 		$this->name = __( 'Grading', 'woothemes-sensei' );
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	/**
231 231
 	 * Outputs Grading general headers
232 232
 	 * @since  1.3.0
233
-     * @param array $args
233
+	 * @param array $args
234 234
 	 * @return void
235 235
 	 */
236 236
 	public function grading_headers( $args = array( 'nav' => 'default' ) ) {
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		}
283 283
 		if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) {
284 284
 
285
-            $user_name = Sensei_Learner::get_full_name( $_GET['user_id'] );
285
+			$user_name = Sensei_Learner::get_full_name( $_GET['user_id'] );
286 286
 			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
287 287
 
288 288
 		} // End If Statement
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		}
317 317
 		if ( isset( $_GET['user'] ) && 0 < intval( $_GET['user'] ) ) {
318 318
 
319
-            $user_name = Sensei_Learner::get_full_name( $_GET['user'] );
319
+			$user_name = Sensei_Learner::get_full_name( $_GET['user'] );
320 320
 			$title .= '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;' . $user_name . '</span>';
321 321
 
322 322
 		} // End If Statement
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 	public function count_statuses( $args = array() ) {
366 366
 		global  $wpdb;
367 367
 
368
-        /**
369
-         * Filter fires inside Sensei_Grading::count_statuses
370
-         *
371
-         * Alter the the post_in array to determine which posts the
372
-         * comment query should be limited to.
373
-         * @since 1.8.0
374
-         * @param array $args
375
-         */
376
-        $args = apply_filters( 'sensei_count_statuses_args', $args );
368
+		/**
369
+		 * Filter fires inside Sensei_Grading::count_statuses
370
+		 *
371
+		 * Alter the the post_in array to determine which posts the
372
+		 * comment query should be limited to.
373
+		 * @since 1.8.0
374
+		 * @param array $args
375
+		 */
376
+		$args = apply_filters( 'sensei_count_statuses_args', $args );
377 377
 
378 378
 		if ( 'course' == $args['type'] ) {
379 379
 			$type = 'sensei_course_status';
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 
386 386
 		$query = "SELECT comment_approved, COUNT( * ) AS total FROM {$wpdb->comments} WHERE comment_type = %s ";
387 387
 
388
-        // Restrict to specific posts
388
+		// Restrict to specific posts
389 389
 		if ( isset( $args['post__in'] ) && !empty( $args['post__in'] ) && is_array( $args['post__in'] ) ) {
390 390
 			$query .= ' AND comment_post_ID IN (' . implode( ',', array_map( 'absint', $args['post__in'] ) ) . ')';
391 391
 		}
@@ -520,148 +520,148 @@  discard block
 block discarded – undo
520 520
 		return $html;
521 521
 	} // End lessons_drop_down_html()
522 522
 
523
-    /**
524
-     * The process grading function handles admin grading submissions.
525
-     *
526
-     * This function is hooked on to admin_init. It simply accepts
527
-     * the grades as the Grader selected theme and saves the total grade and
528
-     * individual question grades.
529
-     *
530
-     * @return bool
531
-     */
532
-    public function admin_process_grading_submission() {
523
+	/**
524
+	 * The process grading function handles admin grading submissions.
525
+	 *
526
+	 * This function is hooked on to admin_init. It simply accepts
527
+	 * the grades as the Grader selected theme and saves the total grade and
528
+	 * individual question grades.
529
+	 *
530
+	 * @return bool
531
+	 */
532
+	public function admin_process_grading_submission() {
533 533
 
534
-        // NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry
535
-        if( ! isset( $_POST['sensei_manual_grade'] )
536
-            || ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' )
537
-            || ! isset( $_GET['quiz_id'] )
538
-            || $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) {
534
+		// NEEDS REFACTOR/OPTIMISING, such as combining the various meta data stored against the sensei_user_answer entry
535
+		if( ! isset( $_POST['sensei_manual_grade'] )
536
+			|| ! wp_verify_nonce( $_POST['_wp_sensei_manual_grading_nonce'], 'sensei_manual_grading' )
537
+			|| ! isset( $_GET['quiz_id'] )
538
+			|| $_GET['quiz_id'] != $_POST['sensei_manual_grade'] ) {
539 539
 
540
-            return false; //exit and do not grade
540
+			return false; //exit and do not grade
541 541
 
542
-        }
542
+		}
543 543
 
544
-        $quiz_id = $_GET['quiz_id'];
545
-        $user_id = $_GET['user'];
544
+		$quiz_id = $_GET['quiz_id'];
545
+		$user_id = $_GET['user'];
546 546
 
547 547
 
548
-        $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
549
-        $quiz_lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
550
-        $quiz_grade = 0;
551
-        $count = 0;
552
-        $quiz_grade_total = $_POST['quiz_grade_total'];
553
-        $all_question_grades = array();
554
-        $all_answers_feedback = array();
548
+		$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
549
+		$quiz_lesson_id =  Sensei()->quiz->get_lesson_id( $quiz_id );
550
+		$quiz_grade = 0;
551
+		$count = 0;
552
+		$quiz_grade_total = $_POST['quiz_grade_total'];
553
+		$all_question_grades = array();
554
+		$all_answers_feedback = array();
555 555
 
556
-        foreach( $questions as $question ) {
556
+		foreach( $questions as $question ) {
557 557
 
558
-            ++$count;
559
-            $question_id = $question->ID;
558
+			++$count;
559
+			$question_id = $question->ID;
560 560
 
561
-            if( isset( $_POST[ 'question_' . $question_id ] ) ) {
561
+			if( isset( $_POST[ 'question_' . $question_id ] ) ) {
562 562
 
563
-                $question_grade = 0;
564
-                if( $_POST[ 'question_' . $question_id ] == 'right' ) {
563
+				$question_grade = 0;
564
+				if( $_POST[ 'question_' . $question_id ] == 'right' ) {
565 565
 
566
-                    $question_grade = $_POST[ 'question_' . $question_id . '_grade' ];
566
+					$question_grade = $_POST[ 'question_' . $question_id . '_grade' ];
567 567
 
568
-                }
568
+				}
569 569
 
570
-                // add data to the array that will, after the loop, be stored on the lesson status
571
-                $all_question_grades[ $question_id ] = $question_grade;
570
+				// add data to the array that will, after the loop, be stored on the lesson status
571
+				$all_question_grades[ $question_id ] = $question_grade;
572 572
 
573
-                // tally up the total quiz grade
574
-                $quiz_grade += $question_grade;
573
+				// tally up the total quiz grade
574
+				$quiz_grade += $question_grade;
575 575
 
576
-            } // endif
576
+			} // endif
577 577
 
578
-            // Question answer feedback / notes
579
-            $question_feedback = '';
580
-            if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){
578
+			// Question answer feedback / notes
579
+			$question_feedback = '';
580
+			if( isset( $_POST[ 'questions_feedback' ][ $question_id ] ) ){
581 581
 
582
-                $question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] );
582
+				$question_feedback = wp_unslash( $_POST[ 'questions_feedback' ][ $question_id ] );
583 583
 
584
-            }
585
-            $all_answers_feedback[ $question_id ] = $question_feedback;
584
+			}
585
+			$all_answers_feedback[ $question_id ] = $question_feedback;
586 586
 
587
-        } // end for each $questions
587
+		} // end for each $questions
588 588
 
589
-        //store all question grades on the lesson status
590
-        Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id );
589
+		//store all question grades on the lesson status
590
+		Sensei()->quiz->set_user_grades( $all_question_grades, $quiz_lesson_id , $user_id );
591 591
 
592
-        //store the feedback from grading
593
-        Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id );
592
+		//store the feedback from grading
593
+		Sensei()->quiz->save_user_answers_feedback( $all_answers_feedback, $quiz_lesson_id , $user_id );
594 594
 
595
-        // $_POST['all_questions_graded'] is set when all questions have been graded
596
-        // in the class sensei grading user quiz -> display()
597
-        if( $_POST['all_questions_graded'] == 'yes' ) {
595
+		// $_POST['all_questions_graded'] is set when all questions have been graded
596
+		// in the class sensei grading user quiz -> display()
597
+		if( $_POST['all_questions_graded'] == 'yes' ) {
598 598
 
599
-            // set the users total quiz grade
599
+			// set the users total quiz grade
600 600
 			if ( 0 < intval( $quiz_grade_total ) ) {
601
-            $grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
601
+			$grade = abs( round( ( doubleval( $quiz_grade ) * 100 ) / ( $quiz_grade_total ), 2 ) );
602 602
 			}
603 603
 			else {
604 604
 				$grade = 0;
605 605
 			}
606
-            Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id );
607
-
608
-            // Duplicating what Frontend->sensei_complete_quiz() does
609
-            $pass_required = get_post_meta( $quiz_id, '_pass_required', true );
610
-            $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
611
-            $lesson_metadata = array();
612
-            if ( $pass_required ) {
613
-                // Student has reached the pass mark and lesson is complete
614
-                if ( $quiz_passmark <= $grade ) {
615
-                    $lesson_status = 'passed';
616
-                }
617
-                else {
618
-                    $lesson_status = 'failed';
619
-                } // End If Statement
620
-            }
621
-            // Student only has to partake the quiz
622
-            else {
623
-                $lesson_status = 'graded';
624
-            }
625
-            $lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above
606
+			Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id );
607
+
608
+			// Duplicating what Frontend->sensei_complete_quiz() does
609
+			$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
610
+			$quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) );
611
+			$lesson_metadata = array();
612
+			if ( $pass_required ) {
613
+				// Student has reached the pass mark and lesson is complete
614
+				if ( $quiz_passmark <= $grade ) {
615
+					$lesson_status = 'passed';
616
+				}
617
+				else {
618
+					$lesson_status = 'failed';
619
+				} // End If Statement
620
+			}
621
+			// Student only has to partake the quiz
622
+			else {
623
+				$lesson_status = 'graded';
624
+			}
625
+			$lesson_metadata['grade'] = $grade; // Technically already set as part of "WooThemes_Sensei_Utils::sensei_grade_quiz()" above
626 626
 
627
-            Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata );
627
+			Sensei_Utils::update_lesson_status( $user_id, $quiz_lesson_id, $lesson_status, $lesson_metadata );
628 628
 
629
-            if(  in_array( $lesson_status, array( 'passed', 'graded'  ) ) ) {
629
+			if(  in_array( $lesson_status, array( 'passed', 'graded'  ) ) ) {
630 630
 
631
-                /**
632
-                 * Summary.
633
-                 *
634
-                 * Description.
635
-                 *
636
-                 * @since 1.7.0
637
-                 *
638
-                 * @param int  $user_id
639
-                 * @param int $quiz_lesson_id
640
-                 */
641
-                do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id );
631
+				/**
632
+				 * Summary.
633
+				 *
634
+				 * Description.
635
+				 *
636
+				 * @since 1.7.0
637
+				 *
638
+				 * @param int  $user_id
639
+				 * @param int $quiz_lesson_id
640
+				 */
641
+				do_action( 'sensei_user_lesson_end', $user_id, $quiz_lesson_id );
642 642
 
643
-            } // end if in_array
643
+			} // end if in_array
644 644
 
645
-        }// end if $_POST['all_que...
645
+		}// end if $_POST['all_que...
646 646
 
647
-        if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) {
647
+		if( isset( $_POST['sensei_grade_next_learner'] ) && strlen( $_POST['sensei_grade_next_learner'] ) > 0 ) {
648 648
 
649
-            $load_url = add_query_arg( array( 'message' => 'graded' ) );
649
+			$load_url = add_query_arg( array( 'message' => 'graded' ) );
650 650
 
651
-        } elseif ( isset( $_POST['_wp_http_referer'] ) ) {
651
+		} elseif ( isset( $_POST['_wp_http_referer'] ) ) {
652 652
 
653
-            $load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] );
653
+			$load_url = add_query_arg( array( 'message' => 'graded' ), $_POST['_wp_http_referer'] );
654 654
 
655
-        } else {
655
+		} else {
656 656
 
657
-            $load_url = add_query_arg( array( 'message' => 'graded' ) );
657
+			$load_url = add_query_arg( array( 'message' => 'graded' ) );
658 658
 
659
-        }
659
+		}
660 660
 
661
-        wp_safe_redirect( esc_url_raw( $load_url ) );
662
-        exit;
661
+		wp_safe_redirect( esc_url_raw( $load_url ) );
662
+		exit;
663 663
 
664
-    } // end admin_process_grading_submission
664
+	} // end admin_process_grading_submission
665 665
 
666 666
 	public function get_redirect_url() {
667 667
 		// Parse POST data
@@ -706,398 +706,398 @@  discard block
 block discarded – undo
706 706
 		} // End If Statement
707 707
 	} // End sensei_grading_notices()
708 708
 
709
-    /**
710
-     * Grade quiz automatically
711
-     *
712
-     * This function grades each question automatically if there all questions are auto gradable. If not
713
-     * the quiz will not be auto gradable.
714
-     *
715
-     * @since 1.7.4
716
-     *
717
-     * @param  integer $quiz_id         ID of quiz
718
-     * @param  array $submitted questions id ans answers {
719
-     *          @type int $question_id
720
-     *          @type mixed $answer
721
-     * }
722
-     * @param  integer $total_questions Total questions in quiz (not used)
723
-     * @param string $quiz_grade_type Optional defaults to auto
724
-     *
725
-     * @return int $quiz_grade total sum of all question grades
726
-     */
727
-    public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
728
-
729
-        if( ! ( intval( $quiz_id ) > 0 )  || ! $submitted
730
-            || $quiz_grade_type != 'auto' ) {
731
-            return false; // exit early
732
-        }
733
-
734
-
735
-        $user_id = get_current_user_id();
736
-        $lesson_id =  Sensei()->quiz->get_lesson_id(  $quiz_id ) ;
737
-        $quiz_autogradable = true;
738
-
739
-        /**
740
-         * Filter the types of question types that can be automatically graded.
741
-         *
742
-         * This filter fires inside the auto grade quiz function and provides you with the default list.
743
-         *
744
-         * @param array {
745
-         *      'multiple-choice',
746
-         *      'boolean',
747
-         *      'gap-fill'.
748
-         * }
749
-         */
750
-        $autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) );
751
-
752
-        $grade_total = 0;
753
-        $all_question_grades = array();
754
-        foreach( $submitted as $question_id => $answer ) {
755
-
756
-            // check if the question is autogradable, either by type, or because the grade is 0
757
-            $question_type = Sensei()->question->get_question_type( $question_id );
709
+	/**
710
+	 * Grade quiz automatically
711
+	 *
712
+	 * This function grades each question automatically if there all questions are auto gradable. If not
713
+	 * the quiz will not be auto gradable.
714
+	 *
715
+	 * @since 1.7.4
716
+	 *
717
+	 * @param  integer $quiz_id         ID of quiz
718
+	 * @param  array $submitted questions id ans answers {
719
+	 *          @type int $question_id
720
+	 *          @type mixed $answer
721
+	 * }
722
+	 * @param  integer $total_questions Total questions in quiz (not used)
723
+	 * @param string $quiz_grade_type Optional defaults to auto
724
+	 *
725
+	 * @return int $quiz_grade total sum of all question grades
726
+	 */
727
+	public static function grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) {
728
+
729
+		if( ! ( intval( $quiz_id ) > 0 )  || ! $submitted
730
+			|| $quiz_grade_type != 'auto' ) {
731
+			return false; // exit early
732
+		}
733
+
734
+
735
+		$user_id = get_current_user_id();
736
+		$lesson_id =  Sensei()->quiz->get_lesson_id(  $quiz_id ) ;
737
+		$quiz_autogradable = true;
738
+
739
+		/**
740
+		 * Filter the types of question types that can be automatically graded.
741
+		 *
742
+		 * This filter fires inside the auto grade quiz function and provides you with the default list.
743
+		 *
744
+		 * @param array {
745
+		 *      'multiple-choice',
746
+		 *      'boolean',
747
+		 *      'gap-fill'.
748
+		 * }
749
+		 */
750
+		$autogradable_question_types = apply_filters( 'sensei_autogradable_question_types', array( 'multiple-choice', 'boolean', 'gap-fill' ) );
751
+
752
+		$grade_total = 0;
753
+		$all_question_grades = array();
754
+		foreach( $submitted as $question_id => $answer ) {
755
+
756
+			// check if the question is autogradable, either by type, or because the grade is 0
757
+			$question_type = Sensei()->question->get_question_type( $question_id );
758 758
 			$achievable_grade = Sensei()->question->get_question_grade( $question_id );
759 759
 			// Question has a zero grade, so skip grading
760 760
 			if ( 0 == $achievable_grade ) {
761 761
 				$all_question_grades[ $question_id ] = $achievable_grade;
762 762
 			}
763
-            elseif ( in_array( $question_type, $autogradable_question_types ) ) {
764
-                // Get user question grade
765
-                $question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id );
766
-                $all_question_grades[ $question_id ] = $question_grade;
767
-                $grade_total += $question_grade;
763
+			elseif ( in_array( $question_type, $autogradable_question_types ) ) {
764
+				// Get user question grade
765
+				$question_grade = Sensei_Utils::sensei_grade_question_auto( $question_id, $question_type, $answer, $user_id );
766
+				$all_question_grades[ $question_id ] = $question_grade;
767
+				$grade_total += $question_grade;
768 768
 
769
-            } else {
769
+			} else {
770 770
 
771
-                // There is a question that cannot be autograded
772
-                $quiz_autogradable = false;
771
+				// There is a question that cannot be autograded
772
+				$quiz_autogradable = false;
773 773
 
774
-            } // end if in_array( $question_type...
774
+			} // end if in_array( $question_type...
775 775
 
776
-        }// end for each question
776
+		}// end for each question
777 777
 
778
-        // Only if the whole quiz was autogradable do we set a grade
779
-        if ( $quiz_autogradable ) {
778
+		// Only if the whole quiz was autogradable do we set a grade
779
+		if ( $quiz_autogradable ) {
780 780
 
781
-            $quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id );
781
+			$quiz_total = Sensei_Utils::sensei_get_quiz_total( $quiz_id );
782 782
 			// Check for zero total from grades
783 783
 			if ( 0 < $quiz_total ) {
784
-            $grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
784
+			$grade = abs( round( ( doubleval( $grade_total ) * 100 ) / ( $quiz_total ), 2 ) );
785 785
 			}
786 786
 			else {
787 787
 				$grade = 0;
788 788
 			}
789
-            Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type );
789
+			Sensei_Utils::sensei_grade_quiz( $quiz_id, $grade, $user_id, $quiz_grade_type );
790 790
 
791
-        } else {
791
+		} else {
792 792
 
793
-            $grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) );
793
+			$grade = new WP_Error( 'autograde', __( 'This quiz is not able to be automatically graded.', 'woothemes-sensei' ) );
794 794
 
795
-        }
796
-
797
-        // store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default
798
-        // when doing manual grading.
799
-        Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id );
795
+		}
800 796
 
801
-        return $grade;
797
+		// store the auto gradable grades. If the quiz is not auto gradable the grades can be use as the default
798
+		// when doing manual grading.
799
+		Sensei()->quiz-> set_user_grades( $all_question_grades, $lesson_id, $user_id );
802 800
 
803
-    } // End grade_quiz_auto()
801
+		return $grade;
804 802
 
805
-    /**
806
-     * Grade question automatically
807
-     *
808
-     * This function checks the question typ and then grades it accordingly.
809
-     *
810
-     * @since 1.7.4
811
-     *
812
-     * @param integer $question_id
813
-     * @param string $question_type of the standard Sensei question types
814
-     * @param string $answer
815
-     * @param int $user_id
816
-     *
817
-     * @return int $question_grade
818
-     */
819
-    public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
820
-
821
-        if( intval( $user_id ) == 0 ) {
822
-
823
-            $user_id = get_current_user_id();
824
-
825
-        }
826
-
827
-        if( ! ( intval( $question_id ) > 0 ) ) {
828
-
829
-            return false;
830
-
831
-        }
832
-
833
-
834
-        Sensei()->question->get_question_type( $question_id );
835
-
836
-        /**
837
-         * Applying a grade before the auto grading takes place.
838
-         *
839
-         * This filter is applied just before the question is auto graded. It fires in the context of a single question
840
-         * in the sensei_grade_question_auto function. It fires irrespective of the question type. If you return a value
841
-         * other than false the auto grade functionality will be ignored and your supplied grade will be user for this question.
842
-         *
843
-         * @param int $question_grade default false
844
-         * @param int $question_id
845
-         * @param string $question_type one of the Sensei question type.
846
-         * @param string $answer user supplied question answer
847
-         */
848
-        $question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer );
803
+	} // End grade_quiz_auto()
849 804
 
850
-        if ( false !== $question_grade ) {
805
+	/**
806
+	 * Grade question automatically
807
+	 *
808
+	 * This function checks the question typ and then grades it accordingly.
809
+	 *
810
+	 * @since 1.7.4
811
+	 *
812
+	 * @param integer $question_id
813
+	 * @param string $question_type of the standard Sensei question types
814
+	 * @param string $answer
815
+	 * @param int $user_id
816
+	 *
817
+	 * @return int $question_grade
818
+	 */
819
+	public static function grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) {
851 820
 
852
-            return $question_grade;
821
+		if( intval( $user_id ) == 0 ) {
853 822
 
854
-        }
823
+			$user_id = get_current_user_id();
855 824
 
856
-        // auto grading core
857
-        if( in_array( $question_type ,  array( 'multiple-choice'  , 'boolean'  ) )   ){
825
+		}
858 826
 
859
-            $right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true );
827
+		if( ! ( intval( $question_id ) > 0 ) ) {
860 828
 
861
-            if( 0 == get_magic_quotes_gpc() ) {
862
-                $answer = wp_unslash( $answer );
863
-            }
864
-            $answer = (array) $answer;
865
-            if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) {
866
-                // Loop through all answers ensure none are 'missing'
867
-                $all_correct = true;
868
-                foreach ( $answer as $check_answer ) {
869
-                    if ( !in_array( $check_answer, $right_answer ) ) {
870
-                        $all_correct = false;
871
-                    }
872
-                }
873
-                // If all correct then grade
874
-                if ( $all_correct ) {
875
-                    $question_grade = Sensei()->question->get_question_grade( $question_id );
876
-                }
877
-            }
829
+			return false;
878 830
 
879
-        } elseif( 'gap-fill' == $question_type ){
831
+		}
880 832
 
881
-            $question_grade = self::grade_gap_fill_question( $question_id ,$answer );
882 833
 
883
-        } else{
834
+		Sensei()->question->get_question_type( $question_id );
884 835
 
885
-            /**
886
-             * Grading questions that are not auto gradable.
887
-             *
888
-             * This filter is applied the context of ta single question within the sensei_grade_question_auto function.
889
-             * It fires for all other questions types. It does not apply to 'multiple-choice'  , 'boolean' and gap-fill.
890
-             *
891
-             * @param int $question_grade default zero
892
-             * @param int $question_id
893
-             * @param string $question_type one of the Sensei question type.
894
-             * @param string $answer user supplied question answer
895
-             */
896
-            $question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer );
836
+		/**
837
+		 * Applying a grade before the auto grading takes place.
838
+		 *
839
+		 * This filter is applied just before the question is auto graded. It fires in the context of a single question
840
+		 * in the sensei_grade_question_auto function. It fires irrespective of the question type. If you return a value
841
+		 * other than false the auto grade functionality will be ignored and your supplied grade will be user for this question.
842
+		 *
843
+		 * @param int $question_grade default false
844
+		 * @param int $question_id
845
+		 * @param string $question_type one of the Sensei question type.
846
+		 * @param string $answer user supplied question answer
847
+		 */
848
+		$question_grade = apply_filters( 'sensei_pre_grade_question_auto', false, $question_id, $question_type, $answer );
897 849
 
898
-        } // end if $question_type
850
+		if ( false !== $question_grade ) {
899 851
 
900
-        return $question_grade;
901
-    } // end grade_question_auto
852
+			return $question_grade;
902 853
 
903
-    /**
904
-     * Grading logic specifically for the gap fill questions
905
-     *
906
-     * @since 1.9.0
907
-     * @param $question_id
908
-     * @param $user_answer
909
-     *
910
-     * @return bool | int false or the grade given to the user answer
911
-     */
912
-    public static function grade_gap_fill_question( $question_id, $user_answer ){
854
+		}
913 855
 
914
-        $right_answer = get_post_meta( $question_id, '_question_right_answer', true );
915
-        $gapfill_array = explode( '||', $right_answer );
856
+		// auto grading core
857
+		if( in_array( $question_type ,  array( 'multiple-choice'  , 'boolean'  ) )   ){
916 858
 
917
-        if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2
918
-            $user_answer = wp_unslash( $user_answer );
919
-        }
859
+			$right_answer = (array) get_post_meta( $question_id, '_question_right_answer', true );
920 860
 
921
-        /**
922
-         * case sensitive grading filter
923
-         *
924
-         * alter the value simply use this code in your plugin or the themes functions.php
925
-         * add_filter( 'sensei_gap_fill_case_sensitive_grading','__return_true' );
926
-         *
927
-         * @param bool $do_case_sensitive_comparison default false.
928
-         *
929
-         * @since 1.9.0
930
-         */
931
-        $do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false );
861
+			if( 0 == get_magic_quotes_gpc() ) {
862
+				$answer = wp_unslash( $answer );
863
+			}
864
+			$answer = (array) $answer;
865
+			if ( is_array( $right_answer ) && count( $right_answer ) == count( $answer ) ) {
866
+				// Loop through all answers ensure none are 'missing'
867
+				$all_correct = true;
868
+				foreach ( $answer as $check_answer ) {
869
+					if ( !in_array( $check_answer, $right_answer ) ) {
870
+						$all_correct = false;
871
+					}
872
+				}
873
+				// If all correct then grade
874
+				if ( $all_correct ) {
875
+					$question_grade = Sensei()->question->get_question_grade( $question_id );
876
+				}
877
+			}
932 878
 
933
-        if( $do_case_sensitive_comparison ){
879
+		} elseif( 'gap-fill' == $question_type ){
934 880
 
935
-            // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
936
-            if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) {
881
+			$question_grade = self::grade_gap_fill_question( $question_id ,$answer );
937 882
 
938
-                return Sensei()->question->get_question_grade( $question_id );
883
+		} else{
939 884
 
940
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
885
+			/**
886
+			 * Grading questions that are not auto gradable.
887
+			 *
888
+			 * This filter is applied the context of ta single question within the sensei_grade_question_auto function.
889
+			 * It fires for all other questions types. It does not apply to 'multiple-choice'  , 'boolean' and gap-fill.
890
+			 *
891
+			 * @param int $question_grade default zero
892
+			 * @param int $question_id
893
+			 * @param string $question_type one of the Sensei question type.
894
+			 * @param string $answer user supplied question answer
895
+			 */
896
+			$question_grade = ( int ) apply_filters( 'sensei_grade_question_auto', $question_grade, $question_id, $question_type, $answer );
941 897
 
942
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
898
+		} // end if $question_type
943 899
 
944
-                    return Sensei()->question->get_question_grade($question_id);
900
+		return $question_grade;
901
+	} // end grade_question_auto
945 902
 
946
-                }else{
903
+	/**
904
+	 * Grading logic specifically for the gap fill questions
905
+	 *
906
+	 * @since 1.9.0
907
+	 * @param $question_id
908
+	 * @param $user_answer
909
+	 *
910
+	 * @return bool | int false or the grade given to the user answer
911
+	 */
912
+	public static function grade_gap_fill_question( $question_id, $user_answer ){
947 913
 
948
-                    return false;
914
+		$right_answer = get_post_meta( $question_id, '_question_right_answer', true );
915
+		$gapfill_array = explode( '||', $right_answer );
949 916
 
950
-                }
917
+		if( 0 == get_magic_quotes_gpc() ) { // deprecated from PHP 5.4 but we still support PHP 5.2
918
+			$user_answer = wp_unslash( $user_answer );
919
+		}
951 920
 
952
-            }else{
921
+		/**
922
+		 * case sensitive grading filter
923
+		 *
924
+		 * alter the value simply use this code in your plugin or the themes functions.php
925
+		 * add_filter( 'sensei_gap_fill_case_sensitive_grading','__return_true' );
926
+		 *
927
+		 * @param bool $do_case_sensitive_comparison default false.
928
+		 *
929
+		 * @since 1.9.0
930
+		 */
931
+		$do_case_sensitive_comparison = apply_filters('sensei_gap_fill_case_sensitive_grading', false );
953 932
 
954
-                return false;
933
+		if( $do_case_sensitive_comparison ){
955 934
 
956
-            }
935
+			// Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
936
+			if ( trim(($gapfill_array[1])) == trim( $user_answer ) ) {
957 937
 
958
-        }else{
938
+				return Sensei()->question->get_question_grade( $question_id );
959 939
 
960
-            // Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
961
-            if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) {
940
+			} else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
962 941
 
963
-               return Sensei()->question->get_question_grade( $question_id );
942
+				if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
964 943
 
965
-            } else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
944
+					return Sensei()->question->get_question_grade($question_id);
966 945
 
967
-                if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
946
+				}else{
968 947
 
969
-                    return  Sensei()->question->get_question_grade( $question_id );
948
+					return false;
970 949
 
971
-                }else{
950
+				}
972 951
 
973
-                    return false;
952
+			}else{
974 953
 
975
-                }
954
+				return false;
976 955
 
977
-            }else{
956
+			}
957
+
958
+		}else{
959
+
960
+			// Case Sensitive Check that the 'gap' is "exactly" equal to the given answer
961
+			if ( trim(strtolower($gapfill_array[1])) == trim(strtolower( $user_answer )) ) {
962
+
963
+			   return Sensei()->question->get_question_grade( $question_id );
964
+
965
+			} else if (@preg_match('/' . $gapfill_array[1] . '/i', null) !== FALSE) {
966
+
967
+				if (preg_match('/' . $gapfill_array[1] . '/i', $user_answer)) {
968
+
969
+					return  Sensei()->question->get_question_grade( $question_id );
970
+
971
+				}else{
972
+
973
+					return false;
974
+
975
+				}
978 976
 
979
-                return false;
977
+			}else{
978
+
979
+				return false;
980
+
981
+			}
982
+
983
+		}
984
+
985
+	}
986
+
987
+	/**
988
+	 * Counts the lessons that have been graded manually and automatically
989
+	 *
990
+	 * @since 1.9.0
991
+	 * @return int $number_of_graded_lessons
992
+	 */
993
+	public static function get_graded_lessons_count(){
980 994
 
981
-            }
995
+		global $wpdb;
982 996
 
983
-        }
997
+		$comment_query_piece[ 'select']  = "SELECT   COUNT(*) AS total";
998
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
999
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( wp_commentmeta.meta_key = 'grade')";
1000
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
984 1001
 
985
-    }
1002
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1003
+		$number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
986 1004
 
987
-    /**
988
-     * Counts the lessons that have been graded manually and automatically
989
-     *
990
-     * @since 1.9.0
991
-     * @return int $number_of_graded_lessons
992
-     */
993
-    public static function get_graded_lessons_count(){
1005
+		return $number_of_graded_lessons;
1006
+	}
994 1007
 
995
-        global $wpdb;
1008
+	/**
1009
+	 * Add together all the graded lesson grades
1010
+	 *
1011
+	 * @since 1.9.0
1012
+	 * @return double $sum_of_all_grades
1013
+	 */
1014
+	public static function get_graded_lessons_sum(){
996 1015
 
997
-        $comment_query_piece[ 'select']  = "SELECT   COUNT(*) AS total";
998
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
999
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( wp_commentmeta.meta_key = 'grade')";
1000
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1016
+		global $wpdb;
1001 1017
 
1002
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1003
-        $number_of_graded_lessons = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1018
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1019
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1020
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1021
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1004 1022
 
1005
-        return $number_of_graded_lessons;
1006
-    }
1023
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1024
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1007 1025
 
1008
-    /**
1009
-     * Add together all the graded lesson grades
1010
-     *
1011
-     * @since 1.9.0
1012
-     * @return double $sum_of_all_grades
1013
-     */
1014
-    public static function get_graded_lessons_sum(){
1026
+		return $sum_of_all_grades;
1015 1027
 
1016
-        global $wpdb;
1028
+	}
1017 1029
 
1018
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1019
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1020
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade')";
1021
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1030
+	/**
1031
+	 * Get the sum of all grades for the given user.
1032
+	 *
1033
+	 * @since 1.9.0
1034
+	 * @param $user_id
1035
+	 * @return double
1036
+	 */
1037
+	public static function get_user_graded_lessons_sum( $user_id ){
1038
+		global $wpdb;
1022 1039
 
1023
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1024
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1040
+		$clean_user_id = esc_sql( $user_id);
1041
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1042
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1043
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} ";
1044
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1025 1045
 
1026
-        return $sum_of_all_grades;
1046
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1047
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1027 1048
 
1028
-    }
1049
+		return $sum_of_all_grades;
1050
+	}
1029 1051
 
1030
-    /**
1031
-     * Get the sum of all grades for the given user.
1032
-     *
1033
-     * @since 1.9.0
1034
-     * @param $user_id
1035
-     * @return double
1036
-     */
1037
-    public static function get_user_graded_lessons_sum( $user_id ){
1038
-        global $wpdb;
1052
+	/**
1053
+	 * Get the sum of all user grades for the given lesson.
1054
+	 *
1055
+	 * @since 1.9.0
1056
+	 *
1057
+	 * @param int lesson_id
1058
+	 * @return double
1059
+	 */
1060
+	public static function get_lessons_users_grades_sum( $lesson_id ){
1039 1061
 
1040
-        $clean_user_id = esc_sql( $user_id);
1041
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1042
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1043
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.user_id = {$clean_user_id} ";
1044
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1062
+		global $wpdb;
1045 1063
 
1046
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1047
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1064
+		$clean_lesson_id = esc_sql( $lesson_id);
1065
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1066
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1067
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} ";
1068
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1048 1069
 
1049
-        return $sum_of_all_grades;
1050
-    }
1070
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1071
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1051 1072
 
1052
-    /**
1053
-     * Get the sum of all user grades for the given lesson.
1054
-     *
1055
-     * @since 1.9.0
1056
-     *
1057
-     * @param int lesson_id
1058
-     * @return double
1059
-     */
1060
-    public static function get_lessons_users_grades_sum( $lesson_id ){
1073
+		return $sum_of_all_grades;
1061 1074
 
1062
-        global $wpdb;
1075
+	}//get_lessons_user_grades_sum
1063 1076
 
1064
-        $clean_lesson_id = esc_sql( $lesson_id);
1065
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1066
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1067
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_lesson_status') AND ( {$wpdb->commentmeta}.meta_key = 'grade') AND {$wpdb->comments}.comment_post_ID = {$clean_lesson_id} ";
1068
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1077
+	/**
1078
+	 * Get the sum of all user grades for the given course.
1079
+	 *
1080
+	 * @since 1.9.0
1081
+	 *
1082
+	 * @param int $course_id
1083
+	 * @return double
1084
+	 */
1085
+	public static function get_course_users_grades_sum( $course_id ){
1069 1086
 
1070
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1071
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1087
+		global $wpdb;
1072 1088
 
1073
-        return $sum_of_all_grades;
1089
+		$clean_course_id = esc_sql( $course_id);
1090
+		$comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1091
+		$comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1092
+		$comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} ";
1093
+		$comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1074 1094
 
1075
-    }//get_lessons_user_grades_sum
1095
+		$comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1096
+		$sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1076 1097
 
1077
-    /**
1078
-     * Get the sum of all user grades for the given course.
1079
-     *
1080
-     * @since 1.9.0
1081
-     *
1082
-     * @param int $course_id
1083
-     * @return double
1084
-     */
1085
-    public static function get_course_users_grades_sum( $course_id ){
1086
-
1087
-        global $wpdb;
1088
-
1089
-        $clean_course_id = esc_sql( $course_id);
1090
-        $comment_query_piece[ 'select']  = "SELECT SUM({$wpdb->commentmeta}.meta_value) AS meta_sum";
1091
-        $comment_query_piece[ 'from']    = " FROM {$wpdb->comments}  INNER JOIN {$wpdb->commentmeta}  ON ( {$wpdb->comments}.comment_ID = {$wpdb->commentmeta}.comment_id ) ";
1092
-        $comment_query_piece[ 'where']   = " WHERE {$wpdb->comments}.comment_type IN ('sensei_course_status') AND ( {$wpdb->commentmeta}.meta_key = 'percent') AND {$wpdb->comments}.comment_post_ID = {$clean_course_id} ";
1093
-        $comment_query_piece[ 'orderby'] = " ORDER BY {$wpdb->comments}.comment_date_gmt DESC ";
1098
+		return $sum_of_all_grades;
1094 1099
 
1095
-        $comment_query = $comment_query_piece['select'] . $comment_query_piece['from'] . $comment_query_piece['where'] . $comment_query_piece['orderby'];
1096
-        $sum_of_all_grades = intval( $wpdb->get_var( $comment_query, 0, 0 ) );
1097
-
1098
-        return $sum_of_all_grades;
1099
-
1100
-    }//get_lessons_user_grades_sum
1100
+	}//get_lessons_user_grades_sum
1101 1101
 
1102 1102
 } // End Class
1103 1103
 
Please login to merge, or discard this patch.
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 ( wp_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 ( wp_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/class-sensei-analysis.php 3 patches
Braces   +13 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis Class
@@ -153,24 +156,19 @@  discard block
 block discarded – undo
153 156
 		if ( 0 < $lesson_id ) {
154 157
 			// Viewing a specific Lesson and all its Learners
155 158
 			$this->analysis_lesson_users_view( $lesson_id );
156
-		}
157
-		elseif ( 0 < $course_id && !$user_id && 'user' == $type ) {
159
+		} elseif ( 0 < $course_id && !$user_id && 'user' == $type ) {
158 160
 			// Viewing a specific Course and all its Learners
159 161
 			$this->analysis_course_users_view( $course_id );
160
-		}
161
-		elseif ( 0 < $course_id && 0 < $user_id ) {
162
+		} elseif ( 0 < $course_id && 0 < $user_id ) {
162 163
 			// Viewing a specific Learner on a specific Course, showing their Lessons
163 164
 			$this->analysis_user_course_view( $course_id, $user_id );
164
-		}
165
-		elseif( 0 < $course_id ) {
165
+		} elseif( 0 < $course_id ) {
166 166
 			// Viewing a specific Course and all it's Lessons
167 167
 			$this->analysis_course_view( $course_id );
168
-		}
169
-		elseif ( 0 < $user_id ) {
168
+		} elseif ( 0 < $user_id ) {
170 169
 			// Viewing a specific Learner, and their Courses
171 170
 			$this->analysis_user_profile_view( $user_id );
172
-		}
173
-		else {
171
+		} else {
174 172
 			// Overview of all Learners, all Courses, or all Lessons
175 173
 			$this->analysis_default_view( $type );
176 174
 		} // End If Statement
@@ -569,20 +567,16 @@  discard block
 block discarded – undo
569 567
 			if ( 0 < $lesson_id ) {
570 568
 				// Viewing a specific Lesson and all its Learners
571 569
 				$sensei_analysis_report_object = $this->load_report_object( 'Lesson', $lesson_id );
572
-			}
573
-			elseif ( 0 < $course_id && 0 < $user_id ) {
570
+			} elseif ( 0 < $course_id && 0 < $user_id ) {
574 571
 				// Viewing a specific User on a specific Course
575 572
 				$sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id, $user_id );
576
-			}
577
-			elseif( 0 < $course_id ) {
573
+			} elseif( 0 < $course_id ) {
578 574
 				// Viewing a specific Course and all it's Lessons, or it's Learners
579 575
 				$sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id );
580
-			}
581
-			elseif ( 0 < $user_id ) {
576
+			} elseif ( 0 < $user_id ) {
582 577
 				// Viewing a specific Learner, and their Courses
583 578
 				$sensei_analysis_report_object = $this->load_report_object( 'User_Profile', $user_id );
584
-			}
585
-			else {
579
+			} else {
586 580
 				// Overview of all Learners, all Courses, or all Lessons
587 581
 				$sensei_analysis_report_object = $this->load_report_object( 'Overview', $type );
588 582
 			} // End If Statement
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 		if ( current_user_can( 'manage_sensei_grades' ) ) {
54 54
 
55
-            add_submenu_page( 'sensei', __('Analysis', 'woothemes-sensei'),  __('Analysis', 'woothemes-sensei') , 'manage_sensei_grades', 'sensei_analysis', array( $this, 'analysis_page' ) );
55
+			add_submenu_page( 'sensei', __('Analysis', 'woothemes-sensei'),  __('Analysis', 'woothemes-sensei') , 'manage_sensei_grades', 'sensei_analysis', array( $this, 'analysis_page' ) );
56 56
 
57 57
 		}
58 58
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 									'analysis-lesson'
90 90
 									);
91 91
 		foreach ( $classes_to_load as $class_file ) {
92
-            Sensei()->load_class( $class_file );
92
+			Sensei()->load_class( $class_file );
93 93
 		} // End For Loop
94 94
 	} // End load_data_table_files()
95 95
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 			$user_id = intval( $_GET['user_id'] );
435 435
 			$url = esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user' => $user_id ), admin_url( 'admin.php' ) ) );
436
-            $user_name = Sensei_Learner::get_full_name( $user_id );
436
+			$user_name = Sensei_Learner::get_full_name( $user_id );
437 437
 			$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name );
438 438
 
439 439
 		} // End If Statement
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 			$user_id = intval( $_GET['user_id'] );
455 455
 			$user_data = get_userdata( $user_id );
456 456
 			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $user_id ), admin_url( 'admin.php' ) );
457
-            $user_name = Sensei_Learner::get_full_name( $user_id );
458
-            $title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name );
457
+			$user_name = Sensei_Learner::get_full_name( $user_id );
458
+			$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name );
459 459
 			$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), $user_data->display_name );
460 460
 		} // End If Statement
461 461
 		if ( isset( $_GET['course_id'] ) ) { 
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 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 Admin Analysis in Sensei.
@@ -19,24 +19,24 @@  discard block
 block discarded – undo
19 19
 	 * @since  1.0.0
20 20
 	 * @param string $file
21 21
 	 */
22
-	public function __construct ( $file ) {
22
+	public function __construct($file) {
23 23
 		$this->name = __('Analysis', 'woothemes-sensei');
24 24
 		$this->file = $file;
25 25
 		$this->page_slug = 'sensei_analysis';
26 26
 
27 27
 		// Admin functions
28
-		if ( is_admin() ) {
29
-			add_action( 'admin_menu', array( $this, 'analysis_admin_menu' ), 10);
30
-			add_action( 'analysis_wrapper_container', array( $this, 'wrapper_container'  ) );
31
-			if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) {
28
+		if (is_admin()) {
29
+			add_action('admin_menu', array($this, 'analysis_admin_menu'), 10);
30
+			add_action('analysis_wrapper_container', array($this, 'wrapper_container'));
31
+			if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) {
32 32
 
33
-				add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) );
33
+				add_action('admin_print_styles', array($this, 'enqueue_styles'));
34 34
 
35 35
 			}
36 36
 
37
-			add_action( 'admin_init', array( $this, 'report_download_page' ) );
37
+			add_action('admin_init', array($this, 'report_download_page'));
38 38
 
39
-			add_filter( 'user_search_columns', array( $this, 'user_search_columns_filter' ), 10, 3 );
39
+			add_filter('user_search_columns', array($this, 'user_search_columns_filter'), 10, 3);
40 40
 		} // End If Statement
41 41
 	} // End __construct()
42 42
 
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	public function analysis_admin_menu() {
51 51
 		global $menu, $woocommerce;
52 52
 
53
-		if ( current_user_can( 'manage_sensei_grades' ) ) {
53
+		if (current_user_can('manage_sensei_grades')) {
54 54
 
55
-            add_submenu_page( 'sensei', __('Analysis', 'woothemes-sensei'),  __('Analysis', 'woothemes-sensei') , 'manage_sensei_grades', 'sensei_analysis', array( $this, 'analysis_page' ) );
55
+            add_submenu_page('sensei', __('Analysis', 'woothemes-sensei'), __('Analysis', 'woothemes-sensei'), 'manage_sensei_grades', 'sensei_analysis', array($this, 'analysis_page'));
56 56
 
57 57
 		}
58 58
 
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 * @since 1.0.0
67 67
 	 * @return void
68 68
 	 */
69
-	public function enqueue_styles () {
69
+	public function enqueue_styles() {
70 70
 
71
-		wp_enqueue_style( 'woothemes-sensei-admin' );
71
+		wp_enqueue_style('woothemes-sensei-admin');
72 72
 
73
-		wp_enqueue_style( 'woothemes-sensei-settings-api', Sensei()->plugin_url . 'assets/css/settings.css', '', Sensei()->version );
73
+		wp_enqueue_style('woothemes-sensei-settings-api', Sensei()->plugin_url.'assets/css/settings.css', '', Sensei()->version);
74 74
 
75 75
 	} // End enqueue_styles()
76 76
 
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	public function load_data_table_files() {
83 83
 
84 84
 		// Load Analysis Classes
85
-		$classes_to_load = array(	'list-table',
85
+		$classes_to_load = array('list-table',
86 86
 									'analysis-overview',
87 87
 									'analysis-user-profile',
88 88
 									'analysis-course',
89 89
 									'analysis-lesson'
90 90
 									);
91
-		foreach ( $classes_to_load as $class_file ) {
92
-            Sensei()->load_class( $class_file );
91
+		foreach ($classes_to_load as $class_file) {
92
+            Sensei()->load_class($class_file);
93 93
 		} // End For Loop
94 94
 	} // End load_data_table_files()
95 95
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 * @param  undefined  $optional_data optional constructor arguments
101 101
 	 * @return object                 class instance object
102 102
 	 */
103
-	public function load_data_object( $name = '', $data = 0, $optional_data = null ) {
103
+	public function load_data_object($name = '', $data = 0, $optional_data = null) {
104 104
 		// Load Analysis data
105
-		$object_name = 'Sensei_Analysis_' . $name . '_List_Table';
106
-		if ( is_null($optional_data) ) {
107
-			$sensei_analysis_object = new $object_name( $data );
105
+		$object_name = 'Sensei_Analysis_'.$name.'_List_Table';
106
+		if (is_null($optional_data)) {
107
+			$sensei_analysis_object = new $object_name($data);
108 108
 		} else {
109
-			$sensei_analysis_object = new $object_name( $data, $optional_data );
109
+			$sensei_analysis_object = new $object_name($data, $optional_data);
110 110
 		}
111 111
 		$sensei_analysis_object->prepare_items();
112 112
 		return $sensei_analysis_object;
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
 		$course_id = 0;
124 124
 		$lesson_id = 0;
125 125
 		$user_id = 0;
126
-		if( isset( $_GET['course_id'] ) ) {
127
-			$course_id = intval( $_GET['course_id'] );
126
+		if (isset($_GET['course_id'])) {
127
+			$course_id = intval($_GET['course_id']);
128 128
 		}
129
-		if( isset( $_GET['lesson_id'] ) ) {
130
-			$lesson_id = intval( $_GET['lesson_id'] );
129
+		if (isset($_GET['lesson_id'])) {
130
+			$lesson_id = intval($_GET['lesson_id']);
131 131
 		}
132
-		if( isset( $_GET['user_id'] ) ) {
133
-			$user_id = intval( $_GET['user_id'] );
132
+		if (isset($_GET['user_id'])) {
133
+			$user_id = intval($_GET['user_id']);
134 134
 		}
135
-		$type = isset( $_GET['view'] ) ? esc_html( $_GET['view'] ) : false;
135
+		$type = isset($_GET['view']) ? esc_html($_GET['view']) : false;
136 136
 
137
-		if ( 0 < $lesson_id ) {
137
+		if (0 < $lesson_id) {
138 138
 			// Viewing a specific Lesson and all its Learners
139
-			$this->analysis_lesson_users_view( $lesson_id );
139
+			$this->analysis_lesson_users_view($lesson_id);
140 140
 		}
141
-		elseif ( 0 < $course_id && !$user_id && 'user' == $type ) {
141
+		elseif (0 < $course_id && ! $user_id && 'user' == $type) {
142 142
 			// Viewing a specific Course and all its Learners
143
-			$this->analysis_course_users_view( $course_id );
143
+			$this->analysis_course_users_view($course_id);
144 144
 		}
145
-		elseif ( 0 < $course_id && 0 < $user_id ) {
145
+		elseif (0 < $course_id && 0 < $user_id) {
146 146
 			// Viewing a specific Learner on a specific Course, showing their Lessons
147
-			$this->analysis_user_course_view( $course_id, $user_id );
147
+			$this->analysis_user_course_view($course_id, $user_id);
148 148
 		}
149
-		elseif( 0 < $course_id ) {
149
+		elseif (0 < $course_id) {
150 150
 			// Viewing a specific Course and all it's Lessons
151
-			$this->analysis_course_view( $course_id );
151
+			$this->analysis_course_view($course_id);
152 152
 		}
153
-		elseif ( 0 < $user_id ) {
153
+		elseif (0 < $user_id) {
154 154
 			// Viewing a specific Learner, and their Courses
155
-			$this->analysis_user_profile_view( $user_id );
155
+			$this->analysis_user_profile_view($user_id);
156 156
 		}
157 157
 		else {
158 158
 			// Overview of all Learners, all Courses, or all Lessons
159
-			$this->analysis_default_view( $type );
159
+			$this->analysis_default_view($type);
160 160
 		} // End If Statement
161 161
 	} // End analysis_page()
162 162
 
@@ -165,35 +165,35 @@  discard block
 block discarded – undo
165 165
 	 * @since  1.2.0
166 166
 	 * @return void
167 167
 	 */
168
-	public function analysis_default_view( $type ) {
168
+	public function analysis_default_view($type) {
169 169
 
170 170
 		// Load Analysis data
171
-		$sensei_analysis_overview = $this->load_data_object( 'Overview', $type );
171
+		$sensei_analysis_overview = $this->load_data_object('Overview', $type);
172 172
 		// Wrappers
173
-		do_action( 'analysis_before_container' );
174
-		do_action( 'analysis_wrapper_container', 'top' );
173
+		do_action('analysis_before_container');
174
+		do_action('analysis_wrapper_container', 'top');
175 175
 		$this->analysis_headers();
176 176
 		?>
177 177
 		<div id="poststuff" class="sensei-analysis-wrap">
178 178
 			<div class="sensei-analysis-sidebar">
179 179
 				<?php
180
-				do_action( 'sensei_analysis_before_stats_boxes' );
181
-				foreach ( $sensei_analysis_overview->stats_boxes() as $key => $value ) {
182
-					$this->render_stats_box( esc_html( $key ), esc_html( $value ) );
180
+				do_action('sensei_analysis_before_stats_boxes');
181
+				foreach ($sensei_analysis_overview->stats_boxes() as $key => $value) {
182
+					$this->render_stats_box(esc_html($key), esc_html($value));
183 183
 				} // End For Loop
184
-				do_action( 'sensei_analysis_after_stats_boxes' );
184
+				do_action('sensei_analysis_after_stats_boxes');
185 185
 				?>
186 186
 			</div>
187 187
 			<div class="sensei-analysis-main">
188 188
 				<?php $sensei_analysis_overview->display(); ?>
189 189
 			</div>
190 190
 			<div class="sensei-analysis-extra">
191
-				<?php do_action( 'sensei_analysis_extra' ); ?>
191
+				<?php do_action('sensei_analysis_extra'); ?>
192 192
 			</div>
193 193
 		</div>
194 194
 		<?php
195
-		do_action( 'analysis_wrapper_container', 'bottom' );
196
-		do_action( 'analysis_after_container' );
195
+		do_action('analysis_wrapper_container', 'bottom');
196
+		do_action('analysis_after_container');
197 197
 	} // End analysis_default_view()
198 198
 
199 199
 	/**
@@ -202,26 +202,26 @@  discard block
 block discarded – undo
202 202
 	 * @param integer $user_id
203 203
 	 * @return void
204 204
 	 */
205
-	public function analysis_user_profile_view( $user_id ) {
205
+	public function analysis_user_profile_view($user_id) {
206 206
 
207 207
 		// Load Analysis data
208
-		$sensei_analysis_user_profile = $this->load_data_object( 'User_Profile', $user_id );
208
+		$sensei_analysis_user_profile = $this->load_data_object('User_Profile', $user_id);
209 209
 		// Wrappers
210
-		do_action( 'analysis_before_container' );
211
-		do_action( 'analysis_wrapper_container', 'top' );
212
-		$this->analysis_headers( array( 'nav' => 'user_profile' ) );
210
+		do_action('analysis_before_container');
211
+		do_action('analysis_wrapper_container', 'top');
212
+		$this->analysis_headers(array('nav' => 'user_profile'));
213 213
 		?>
214 214
 		<div id="poststuff" class="sensei-analysis-wrap user-profile">
215 215
 			<div class="sensei-analysis-main">
216 216
 				<?php $sensei_analysis_user_profile->display(); ?>
217 217
 			</div>
218 218
 			<div class="sensei-analysis-extra">
219
-				<?php do_action( 'sensei_analysis_extra' ); ?>
219
+				<?php do_action('sensei_analysis_extra'); ?>
220 220
 			</div>
221 221
 		</div>
222 222
 		<?php
223
-		do_action( 'analysis_wrapper_container', 'bottom' );
224
-		do_action( 'analysis_after_container' );
223
+		do_action('analysis_wrapper_container', 'bottom');
224
+		do_action('analysis_after_container');
225 225
 	} // End analysis_user_profile_view()
226 226
 
227 227
 	/**
@@ -230,26 +230,26 @@  discard block
 block discarded – undo
230 230
 	 * @param integer $course_id
231 231
 	 * @return void
232 232
 	 */
233
-	public function analysis_course_view( $course_id ) {
233
+	public function analysis_course_view($course_id) {
234 234
 
235 235
 		// Load Analysis data
236
-		$sensei_analysis_course = $this->load_data_object( 'Course', $course_id );
236
+		$sensei_analysis_course = $this->load_data_object('Course', $course_id);
237 237
 		// Wrappers
238
-		do_action( 'analysis_before_container' );
239
-		do_action( 'analysis_wrapper_container', 'top' );
240
-		$this->analysis_headers( array( 'nav' => 'course' ) );
238
+		do_action('analysis_before_container');
239
+		do_action('analysis_wrapper_container', 'top');
240
+		$this->analysis_headers(array('nav' => 'course'));
241 241
 		?>
242 242
 		<div id="poststuff" class="sensei-analysis-wrap course-profile">
243 243
 			<div class="sensei-analysis-main">
244 244
 				<?php $sensei_analysis_course->display(); ?>
245 245
 			</div>
246 246
 			<div class="sensei-analysis-extra">
247
-				<?php do_action( 'sensei_analysis_extra' ); ?>
247
+				<?php do_action('sensei_analysis_extra'); ?>
248 248
 			</div>
249 249
 		</div>
250 250
 		<?php
251
-		do_action( 'analysis_wrapper_container', 'bottom' );
252
-		do_action( 'analysis_after_container' );
251
+		do_action('analysis_wrapper_container', 'bottom');
252
+		do_action('analysis_after_container');
253 253
 	} // End analysis_course_view()
254 254
 
255 255
 	/**
@@ -259,26 +259,26 @@  discard block
 block discarded – undo
259 259
 	 * @param integer $user_id
260 260
 	 * @return void
261 261
 	 */
262
-	public function analysis_user_course_view( $course_id, $user_id ) {
262
+	public function analysis_user_course_view($course_id, $user_id) {
263 263
 
264 264
 		// Load Analysis data
265
-		$sensei_analysis_user_course = $this->load_data_object( 'Course', $course_id, $user_id );
265
+		$sensei_analysis_user_course = $this->load_data_object('Course', $course_id, $user_id);
266 266
 		// Wrappers
267
-		do_action( 'analysis_before_container' );
268
-		do_action( 'analysis_wrapper_container', 'top' );
269
-		$this->analysis_headers( array( 'nav' => 'user_course' ) );
267
+		do_action('analysis_before_container');
268
+		do_action('analysis_wrapper_container', 'top');
269
+		$this->analysis_headers(array('nav' => 'user_course'));
270 270
 		?>
271 271
 		<div id="poststuff" class="sensei-analysis-wrap course-profile">
272 272
 			<div class="sensei-analysis-main">
273 273
 				<?php $sensei_analysis_user_course->display(); ?>
274 274
 			</div>
275 275
 			<div class="sensei-analysis-extra">
276
-				<?php do_action( 'sensei_analysis_extra' ); ?>
276
+				<?php do_action('sensei_analysis_extra'); ?>
277 277
 			</div>
278 278
 		</div>
279 279
 		<?php
280
-		do_action( 'analysis_wrapper_container', 'bottom' );
281
-		do_action( 'analysis_after_container' );
280
+		do_action('analysis_wrapper_container', 'bottom');
281
+		do_action('analysis_after_container');
282 282
 	} // End analysis_user_course_view()
283 283
 
284 284
 	/**
@@ -287,26 +287,26 @@  discard block
 block discarded – undo
287 287
 	 * @param integer $course_id
288 288
 	 * @return void
289 289
 	 */
290
-	public function analysis_course_users_view( $course_id ) {
290
+	public function analysis_course_users_view($course_id) {
291 291
 
292 292
 		// Load Analysis data
293
-		$sensei_analysis_course_users = $this->load_data_object( 'Course', $course_id );
293
+		$sensei_analysis_course_users = $this->load_data_object('Course', $course_id);
294 294
 		// Wrappers
295
-		do_action( 'analysis_before_container' );
296
-		do_action( 'analysis_wrapper_container', 'top' );
297
-		$this->analysis_headers( array( 'nav' => 'course_users' ) );
295
+		do_action('analysis_before_container');
296
+		do_action('analysis_wrapper_container', 'top');
297
+		$this->analysis_headers(array('nav' => 'course_users'));
298 298
 		?>
299 299
 		<div id="poststuff" class="sensei-analysis-wrap course-profile">
300 300
 			<div class="sensei-analysis-main">
301 301
 				<?php $sensei_analysis_course_users->display(); ?>
302 302
 			</div>
303 303
 			<div class="sensei-analysis-extra">
304
-				<?php do_action( 'sensei_analysis_extra' ); ?>
304
+				<?php do_action('sensei_analysis_extra'); ?>
305 305
 			</div>
306 306
 		</div>
307 307
 		<?php
308
-		do_action( 'analysis_wrapper_container', 'bottom' );
309
-		do_action( 'analysis_after_container' );
308
+		do_action('analysis_wrapper_container', 'bottom');
309
+		do_action('analysis_after_container');
310 310
 	} // End analysis_course_users_view()
311 311
 
312 312
 	/**
@@ -315,26 +315,26 @@  discard block
 block discarded – undo
315 315
 	 * @param integer $lesson_id
316 316
 	 * @return void
317 317
 	 */
318
-	public function analysis_lesson_users_view( $lesson_id ) {
318
+	public function analysis_lesson_users_view($lesson_id) {
319 319
 
320 320
 		// Load Analysis data
321
-		$sensei_analysis_lesson_users = $this->load_data_object( 'Lesson', $lesson_id );
321
+		$sensei_analysis_lesson_users = $this->load_data_object('Lesson', $lesson_id);
322 322
 		// Wrappers
323
-		do_action( 'analysis_before_container' );
324
-		do_action( 'analysis_wrapper_container', 'top' );
325
-		$this->analysis_headers( array( 'nav' => 'lesson_users' ) );
323
+		do_action('analysis_before_container');
324
+		do_action('analysis_wrapper_container', 'top');
325
+		$this->analysis_headers(array('nav' => 'lesson_users'));
326 326
 		?>
327 327
 		<div id="poststuff" class="sensei-analysis-wrap course-profile">
328 328
 			<div class="sensei-analysis-main">
329 329
 				<?php $sensei_analysis_lesson_users->display(); ?>
330 330
 			</div>
331 331
 			<div class="sensei-analysis-extra">
332
-				<?php do_action( 'sensei_analysis_extra' ); ?>
332
+				<?php do_action('sensei_analysis_extra'); ?>
333 333
 			</div>
334 334
 		</div>
335 335
 		<?php
336
-		do_action( 'analysis_wrapper_container', 'bottom' );
337
-		do_action( 'analysis_after_container' );
336
+		do_action('analysis_wrapper_container', 'bottom');
337
+		do_action('analysis_after_container');
338 338
 	} // End analysis_lesson_users_view()
339 339
 
340 340
 	/**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 * @param  $data string stats data
345 345
 	 * @return void
346 346
 	 */
347
-	public function render_stats_box( $title, $data ) {
347
+	public function render_stats_box($title, $data) {
348 348
 		?><div class="postbox">
349 349
 			<h2><span><?php echo $title; ?></span></h2>
350 350
 			<div class="inside">
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 	 * @since  1.2.0
359 359
 	 * @return void
360 360
 	 */
361
-	public function analysis_headers( $args = array( 'nav' => 'default' ) ) {
361
+	public function analysis_headers($args = array('nav' => 'default')) {
362 362
 
363
-		$function = 'analysis_' . $args['nav'] . '_nav';
363
+		$function = 'analysis_'.$args['nav'].'_nav';
364 364
 		$this->$function();
365 365
 		?>
366 366
 			<p class="powered-by-woo">
367 367
 
368
-                <?php _e( 'Powered by', 'woothemes-sensei' ); ?>
368
+                <?php _e('Powered by', 'woothemes-sensei'); ?>
369 369
 
370 370
                 <a href="http://www.woothemes.com/" title="WooThemes">
371 371
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
             </p>
377 377
 
378 378
 		<?php
379
-		do_action( 'sensei_analysis_after_headers' );
379
+		do_action('sensei_analysis_after_headers');
380 380
 	} // End analysis_headers()
381 381
 
382 382
 	/**
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 	 * @param $which string
386 386
 	 * @return void
387 387
 	 */
388
-	public function wrapper_container( $which ) {
389
-		if ( 'top' == $which ) {
388
+	public function wrapper_container($which) {
389
+		if ('top' == $which) {
390 390
 			?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php
391
-		} elseif ( 'bottom' == $which ) {
391
+		} elseif ('bottom' == $which) {
392 392
 			?></div><!--/#woothemes-sensei--><?php
393 393
 		} // End If Statement
394 394
 	} // End wrapper_container()
@@ -400,24 +400,24 @@  discard block
 block discarded – undo
400 400
 	 */
401 401
 	public function analysis_default_nav() {
402 402
 
403
-		$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 ) );
404
-		$view = isset($_GET['view']) ? esc_html( $_GET['view'] ) : '';
405
-		switch ( $view ) { 
403
+		$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));
404
+		$view = isset($_GET['view']) ? esc_html($_GET['view']) : '';
405
+		switch ($view) { 
406 406
 			case 'courses' :
407
-				$title .= sprintf( '&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', __( 'Courses', 'woothemes-sensei' ) );
407
+				$title .= sprintf('&nbsp;&nbsp;<span class="course-title">&gt;&nbsp;&nbsp;%s</span>', __('Courses', 'woothemes-sensei'));
408 408
 				break;
409 409
 
410 410
 			case 'lessons' :
411
-				$title .= sprintf( '&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;%s</span>', __( 'Lessons', 'woothemes-sensei' ) );
411
+				$title .= sprintf('&nbsp;&nbsp;<span class="lesson-title">&gt;&nbsp;&nbsp;%s</span>', __('Lessons', 'woothemes-sensei'));
412 412
 				break;
413 413
 
414 414
 			case 'users' :
415 415
 			default :
416
-				$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;%s</span>', __( 'Learners', 'woothemes-sensei' ) );
416
+				$title .= sprintf('&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;%s</span>', __('Learners', 'woothemes-sensei'));
417 417
 				break;
418 418
 		}
419 419
 		?>
420
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
420
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
421 421
 		<?php
422 422
 	} // End analysis_default_nav()
423 423
 
@@ -428,17 +428,17 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	public function analysis_user_profile_nav() {
430 430
 
431
-		$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 ) );
432
-		if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) {
431
+		$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));
432
+		if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) {
433 433
 
434
-			$user_id = intval( $_GET['user_id'] );
435
-			$url = esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user' => $user_id ), admin_url( 'admin.php' ) ) );
436
-            $user_name = Sensei_Learner::get_full_name( $user_id );
437
-			$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name );
434
+			$user_id = intval($_GET['user_id']);
435
+			$url = esc_url(add_query_arg(array('page' => $this->page_slug, 'user' => $user_id), admin_url('admin.php')));
436
+            $user_name = Sensei_Learner::get_full_name($user_id);
437
+			$title .= sprintf('&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name);
438 438
 
439 439
 		} // End If Statement
440 440
 		?>
441
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
441
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
442 442
 		<?php
443 443
 	} // End analysis_user_profile_nav()
444 444
 
@@ -449,22 +449,22 @@  discard block
 block discarded – undo
449 449
 	 */
450 450
 	public function analysis_user_course_nav() {
451 451
 
452
-		$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 ) );
453
-		if ( isset( $_GET['user_id'] ) && 0 < intval( $_GET['user_id'] ) ) {
454
-			$user_id = intval( $_GET['user_id'] );
455
-			$user_data = get_userdata( $user_id );
456
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $user_id ), admin_url( 'admin.php' ) );
457
-            $user_name = Sensei_Learner::get_full_name( $user_id );
458
-            $title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name );
459
-			$title .= sprintf( '&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url( $url ), $user_data->display_name );
452
+		$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));
453
+		if (isset($_GET['user_id']) && 0 < intval($_GET['user_id'])) {
454
+			$user_id = intval($_GET['user_id']);
455
+			$user_data = get_userdata($user_id);
456
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $user_id), admin_url('admin.php'));
457
+            $user_name = Sensei_Learner::get_full_name($user_id);
458
+            $title .= sprintf('&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', $url, $user_name);
459
+			$title .= sprintf('&nbsp;&nbsp;<span class="user-title">&gt;&nbsp;&nbsp;<a href="%s">%s</a></span>', esc_url($url), $user_data->display_name);
460 460
 		} // End If Statement
461
-		if ( isset( $_GET['course_id'] ) ) { 
462
-			$course_id = intval( $_GET['course_id'] );
463
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
464
-			$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 ) );
461
+		if (isset($_GET['course_id'])) { 
462
+			$course_id = intval($_GET['course_id']);
463
+			$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
464
+			$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));
465 465
 		}
466 466
 		?>
467
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
467
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
468 468
 		<?php
469 469
 	} // End analysis_user_course_nav()
470 470
 
@@ -475,14 +475,14 @@  discard block
 block discarded – undo
475 475
 	 */
476 476
 	public function analysis_course_nav() {
477 477
 
478
-		$title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) );
479
-		if ( isset( $_GET['course_id'] ) ) { 
480
-			$course_id = intval( $_GET['course_id'] );
481
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
482
-			$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 ) );
478
+		$title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name));
479
+		if (isset($_GET['course_id'])) { 
480
+			$course_id = intval($_GET['course_id']);
481
+			$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
482
+			$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));
483 483
 		}
484 484
 		?>
485
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
485
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
486 486
 		<?php
487 487
 	} // End analysis_course_nav()
488 488
 
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	public function analysis_course_users_nav() {
495 495
 
496
-		$title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) );
497
-		if ( isset( $_GET['course_id'] ) ) { 
498
-			$course_id = intval( $_GET['course_id'] );
499
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
500
-			$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 ) );
496
+		$title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name));
497
+		if (isset($_GET['course_id'])) { 
498
+			$course_id = intval($_GET['course_id']);
499
+			$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
500
+			$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));
501 501
 		}
502 502
 		?>
503
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
503
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
504 504
 		<?php
505 505
 	} // End analysis_course_users_nav()
506 506
 
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 	 */
512 512
 	public function analysis_lesson_users_nav() {
513 513
 
514
-		$title = sprintf( '<a href="%s">%s</a>', add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ), esc_html( $this->name ) );
515
-		if ( isset( $_GET['lesson_id'] ) ) { 
516
-			$lesson_id = intval( $_GET['lesson_id'] );
517
-			$course_id = intval( get_post_meta( $lesson_id, '_lesson_course', true ) );
518
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) );
519
-			$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 ) );
520
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $lesson_id ), admin_url( 'admin.php' ) );
521
-			$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 ) );
514
+		$title = sprintf('<a href="%s">%s</a>', add_query_arg(array('page' => $this->page_slug), admin_url('admin.php')), esc_html($this->name));
515
+		if (isset($_GET['lesson_id'])) { 
516
+			$lesson_id = intval($_GET['lesson_id']);
517
+			$course_id = intval(get_post_meta($lesson_id, '_lesson_course', true));
518
+			$url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'));
519
+			$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));
520
+			$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $lesson_id), admin_url('admin.php'));
521
+			$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));
522 522
 		}
523 523
 		?>
524
-			<h1><?php echo apply_filters( 'sensei_analysis_nav_title', $title ); ?></h1>
524
+			<h1><?php echo apply_filters('sensei_analysis_nav_title', $title); ?></h1>
525 525
 		<?php
526 526
 	} // End analysis_lesson_users_nav()
527 527
 
@@ -532,59 +532,59 @@  discard block
 block discarded – undo
532 532
 	 */
533 533
 	public function report_download_page() {
534 534
 		// Check if is a report
535
-		if ( !empty( $_GET['sensei_report_download'] ) ) {
536
-			$report = sanitize_text_field( $_GET['sensei_report_download'] );
535
+		if ( ! empty($_GET['sensei_report_download'])) {
536
+			$report = sanitize_text_field($_GET['sensei_report_download']);
537 537
 
538 538
 			// Simple verification to ensure intent, Note that a Nonce is per user, so the URL can't be shared
539
-			if ( !wp_verify_nonce( $_REQUEST['_sdl_nonce'], 'sensei_csv_download-' . $report ) ) {
540
-				wp_die( __('Invalid request', 'woothemes-sensei') );
539
+			if ( ! wp_verify_nonce($_REQUEST['_sdl_nonce'], 'sensei_csv_download-'.$report)) {
540
+				wp_die(__('Invalid request', 'woothemes-sensei'));
541 541
 			}
542 542
 
543 543
 			// Setup the variables we might need
544
-			$filename = apply_filters( 'sensei_csv_export_filename', $report );
544
+			$filename = apply_filters('sensei_csv_export_filename', $report);
545 545
 			$course_id = 0;
546 546
 			$lesson_id = 0;
547 547
 			$user_id = 0;
548
-			if( isset( $_GET['course_id'] ) ) {
549
-				$course_id = intval( $_GET['course_id'] );
548
+			if (isset($_GET['course_id'])) {
549
+				$course_id = intval($_GET['course_id']);
550 550
 			}
551
-			if( isset( $_GET['lesson_id'] ) ) {
552
-				$lesson_id = intval( $_GET['lesson_id'] );
551
+			if (isset($_GET['lesson_id'])) {
552
+				$lesson_id = intval($_GET['lesson_id']);
553 553
 			}
554
-			if( isset( $_GET['user_id'] ) ) {
555
-				$user_id = intval( $_GET['user_id'] );
554
+			if (isset($_GET['user_id'])) {
555
+				$user_id = intval($_GET['user_id']);
556 556
 			}
557
-			$type = isset( $_GET['view'] ) ? esc_html( $_GET['view'] ) : false;
557
+			$type = isset($_GET['view']) ? esc_html($_GET['view']) : false;
558 558
 
559
-			if ( 0 < $lesson_id ) {
559
+			if (0 < $lesson_id) {
560 560
 				// Viewing a specific Lesson and all its Learners
561
-				$sensei_analysis_report_object = $this->load_report_object( 'Lesson', $lesson_id );
561
+				$sensei_analysis_report_object = $this->load_report_object('Lesson', $lesson_id);
562 562
 			}
563
-			elseif ( 0 < $course_id && 0 < $user_id ) {
563
+			elseif (0 < $course_id && 0 < $user_id) {
564 564
 				// Viewing a specific User on a specific Course
565
-				$sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id, $user_id );
565
+				$sensei_analysis_report_object = $this->load_report_object('Course', $course_id, $user_id);
566 566
 			}
567
-			elseif( 0 < $course_id ) {
567
+			elseif (0 < $course_id) {
568 568
 				// Viewing a specific Course and all it's Lessons, or it's Learners
569
-				$sensei_analysis_report_object = $this->load_report_object( 'Course', $course_id );
569
+				$sensei_analysis_report_object = $this->load_report_object('Course', $course_id);
570 570
 			}
571
-			elseif ( 0 < $user_id ) {
571
+			elseif (0 < $user_id) {
572 572
 				// Viewing a specific Learner, and their Courses
573
-				$sensei_analysis_report_object = $this->load_report_object( 'User_Profile', $user_id );
573
+				$sensei_analysis_report_object = $this->load_report_object('User_Profile', $user_id);
574 574
 			}
575 575
 			else {
576 576
 				// Overview of all Learners, all Courses, or all Lessons
577
-				$sensei_analysis_report_object = $this->load_report_object( 'Overview', $type );
577
+				$sensei_analysis_report_object = $this->load_report_object('Overview', $type);
578 578
 			} // End If Statement
579 579
 
580 580
 			// Handle the headers
581
-			$this->report_set_headers( $filename );
581
+			$this->report_set_headers($filename);
582 582
 
583 583
 			// Collate the data, there could be many different reports for a single object
584
-			$report_data_array = $sensei_analysis_report_object->generate_report( $report );
584
+			$report_data_array = $sensei_analysis_report_object->generate_report($report);
585 585
 
586 586
 			// Output the data
587
-			$this->report_write_download( $report_data_array );
587
+			$this->report_write_download($report_data_array);
588 588
 
589 589
 			// Cleanly exit
590 590
 			exit;
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
 	 * @param  string $filename name of report file
598 598
 	 * @return void
599 599
 	 */
600
-	public function report_set_headers( $filename = '' ) {
601
-		header( 'Content-Type: text/csv' );
602
-		header( 'Content-Disposition: attachment;filename=' . $filename . '.csv');
600
+	public function report_set_headers($filename = '') {
601
+		header('Content-Type: text/csv');
602
+		header('Content-Disposition: attachment;filename='.$filename.'.csv');
603 603
 	} // End report_set_headers()
604 604
 
605 605
 	/**
@@ -610,12 +610,12 @@  discard block
 block discarded – undo
610 610
 	 * @param  undefined  $optional_data optional constructor arguments
611 611
 	 * @return object                 class instance object
612 612
 	 */
613
-	public function load_report_object( $name = '', $data = 0, $optional_data = null ) {
614
-		$object_name = 'WooThemes_Sensei_Analysis_' . $name . '_List_Table';
615
-		if ( is_null($optional_data) ) {
616
-			$sensei_analysis_report_object = new $object_name( $data );
613
+	public function load_report_object($name = '', $data = 0, $optional_data = null) {
614
+		$object_name = 'WooThemes_Sensei_Analysis_'.$name.'_List_Table';
615
+		if (is_null($optional_data)) {
616
+			$sensei_analysis_report_object = new $object_name($data);
617 617
 		} else {
618
-			$sensei_analysis_report_object = new $object_name( $data, $optional_data );
618
+			$sensei_analysis_report_object = new $object_name($data, $optional_data);
619 619
 		}
620 620
 		return $sensei_analysis_report_object;
621 621
 	} // End load_report_object()
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 * @param  array  $report_data data array
627 627
 	 * @return void
628 628
 	 */
629
-	public function report_write_download( $report_data = array() ) {
629
+	public function report_write_download($report_data = array()) {
630 630
 		$fp = fopen('php://output', 'w');
631 631
 		foreach ($report_data as $row) {
632 632
 			fputcsv($fp, $row);
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
 	 * @param  object $user_query_object     WP_User_Query Object
643 643
 	 * @return array $search_columns         array of user columns to search
644 644
 	 */
645
-	public function user_search_columns_filter( $search_columns, $search, $user_query_object ) {
645
+	public function user_search_columns_filter($search_columns, $search, $user_query_object) {
646 646
 		// Alter $search_columns to include the fields you want to search on
647
-		array_push( $search_columns, 'display_name' );
647
+		array_push($search_columns, 'display_name');
648 648
 		return $search_columns;
649 649
 	}
650 650
 
Please login to merge, or discard this patch.
includes/admin/class-sensei-welcome.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @version     1.8.0
13 13
 */
14 14
 
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit; // Exit if accessed directly
17 17
 }
18 18
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct() {
31 31
 
32
-        add_action( 'admin_menu', array( $this, 'admin_menus') );
33
-		add_action( 'admin_head', array( $this, 'admin_head' ) );
32
+        add_action('admin_menu', array($this, 'admin_menus'));
33
+		add_action('admin_head', array($this, 'admin_head'));
34 34
 
35 35
 	}
36 36
 
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
      * Hooked into activated_plugin
41 41
      * @since 1.8.0
42 42
      */
43
-    public static function redirect( $plugin ) {
43
+    public static function redirect($plugin) {
44 44
 
45 45
         // Bail if activating from network, or bulk, or within an iFrame
46
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
46
+        if (is_network_admin() || isset($_GET['activate-multi']) || defined('IFRAME_REQUEST')) {
47 47
 
48 48
             return;
49 49
 
50 50
         }
51 51
         // don't run for upgrades and for pages already on the welcome screen
52
-        if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] )
53
-            || ( ! empty( $_GET['page'] ) && $_GET['page'] === 'sensei-welcome' ) ) {
52
+        if ((isset($_GET['action']) && 'upgrade-plugin' == $_GET['action'])
53
+            || ( ! empty($_GET['page']) && $_GET['page'] === 'sensei-welcome')) {
54 54
 
55 55
             return;
56 56
 
57 57
         }
58 58
 
59
-        wp_redirect( admin_url( 'index.php?page=sensei-welcome' ) );
59
+        wp_redirect(admin_url('index.php?page=sensei-welcome'));
60 60
         exit;
61 61
     }
62 62
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function admin_menus() {
69 69
 
70
-		if ( ! isset( $_GET['page'] ) || 'sensei-welcome' != $_GET[ 'page' ] ) {
70
+		if ( ! isset($_GET['page']) || 'sensei-welcome' != $_GET['page']) {
71 71
 			return;
72 72
 		}
73 73
 
74
-		$welcome_page_name  = __( 'Sensei Activation', 'woothemes-sensei' );
75
-		$welcome_page_title = __( 'Welcome to Sensei', 'woothemes-sensei' );
76
-        add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sensei-welcome', array( $this, 'welcome_screen' ) );
74
+		$welcome_page_name  = __('Sensei Activation', 'woothemes-sensei');
75
+		$welcome_page_title = __('Welcome to Sensei', 'woothemes-sensei');
76
+        add_dashboard_page($welcome_page_title, $welcome_page_name, 'manage_options', 'sensei-welcome', array($this, 'welcome_screen'));
77 77
 
78 78
 	}
79 79
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             <hr />
133 133
 
134 134
             <div class="return-to-dashboard">
135
-                <a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'woothemes-sensei-settings' ), 'admin.php' ) ) ); ?>"><?php _e( 'Go to Sensei Settings', 'woothemes-sensei' ); ?></a>
135
+                <a href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'woothemes-sensei-settings'), 'admin.php'))); ?>"><?php _e('Go to Sensei Settings', 'woothemes-sensei'); ?></a>
136 136
             </div>
137 137
         </div>
138 138
     <?php
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function admin_head() {
145 145
         // remove the menu page so it is not visible in the admin side bar
146
-		remove_submenu_page( 'index.php', 'sensei-welcome' );
146
+		remove_submenu_page('index.php', 'sensei-welcome');
147 147
 		?>
148 148
 		<style type="text/css">
149 149
 			/*<![CDATA[*/
@@ -262,47 +262,47 @@  discard block
 block discarded – undo
262 262
 	private function intro() {
263 263
 
264 264
 		// Drop minor version if 0
265
-		$major_version = substr( Sensei()->version, 0, 3 );
265
+		$major_version = substr(Sensei()->version, 0, 3);
266 266
 
267 267
 		// Random tweet - must be kept to 102 chars to "fit"
268 268
 		$tweets        = array(
269 269
             'I\'ve just installed Sensei - A premium Learning Management plugin for #WordPress.'
270 270
 		);
271
-		shuffle( $tweets );
271
+		shuffle($tweets);
272 272
 		?>
273
-		<h1><?php printf( __( 'Welcome to Sensei %s', 'woothemes-sensei' ), $major_version ); ?></h1>
273
+		<h1><?php printf(__('Welcome to Sensei %s', 'woothemes-sensei'), $major_version); ?></h1>
274 274
 
275 275
 		<div class="about-text sensei-about-text">
276 276
 			<?php
277
-				if ( ! empty( $_GET['sensei-installed'] ) ) {
278
-					$message = __( 'Thanks, all done!', 'woothemes-sensei' );
279
-				} elseif ( ! empty( $_GET['sensei-updated'] ) ) {
280
-					$message = __( 'Thank you for updating to the latest version!', 'woothemes-sensei' );
277
+				if ( ! empty($_GET['sensei-installed'])) {
278
+					$message = __('Thanks, all done!', 'woothemes-sensei');
279
+				} elseif ( ! empty($_GET['sensei-updated'])) {
280
+					$message = __('Thank you for updating to the latest version!', 'woothemes-sensei');
281 281
 				} else {
282
-					$message = __( 'Thanks for installing!', 'woothemes-sensei' );
282
+					$message = __('Thanks for installing!', 'woothemes-sensei');
283 283
 				}
284 284
 
285
-				printf( __( '%s We hope you enjoy using Sensei %s.', 'woothemes-sensei' ), $message, $major_version );
285
+				printf(__('%s We hope you enjoy using Sensei %s.', 'woothemes-sensei'), $message, $major_version);
286 286
 			?>
287 287
 		</div>
288 288
 
289 289
 		<div class="sensei-badge">
290 290
             <?php
291
-                _e('Sensei by WooThemes','woothemes-sensei');
291
+                _e('Sensei by WooThemes', 'woothemes-sensei');
292 292
                 echo '<br />';
293 293
 
294
-                printf( __( 'Version %s', 'woothemes-sensei' ), Sensei()->version );
294
+                printf(__('Version %s', 'woothemes-sensei'), Sensei()->version);
295 295
             ?>
296 296
         </div>
297 297
 
298 298
 		<p class="sensei-actions">
299
-			<a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a>
300
-			<a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/documentation/plugins/sensei/', 'woothemes-sensei' ) ); ?>" class="docs button button-primary"><?php _e( 'Docs', 'woothemes-sensei' ); ?></a>
301
-			<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/products/sensei" data-text="<?php echo esc_attr( $tweets[0] ); ?>" data-via="WooThemes" data-size="large">Tweet</a>
299
+			<a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a>
300
+			<a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/documentation/plugins/sensei/', 'woothemes-sensei')); ?>" class="docs button button-primary"><?php _e('Docs', 'woothemes-sensei'); ?></a>
301
+			<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/products/sensei" data-text="<?php echo esc_attr($tweets[0]); ?>" data-via="WooThemes" data-size="large">Tweet</a>
302 302
 			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
303 303
 		</p>
304 304
 
305
-		<h2 > <?php _e( "What's New", 'woothemes-sensei' ); ?> </h2>
305
+		<h2 > <?php _e("What's New", 'woothemes-sensei'); ?> </h2>
306 306
 
307 307
 		<?php
308 308
 	}
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-    exit; // Exit if accessed directly
3
+	exit; // Exit if accessed directly
4 4
 }
5 5
 
6 6
 /**
@@ -17,45 +17,45 @@  discard block
 block discarded – undo
17 17
 
18 18
 	/**
19 19
 	 * Hook in tabs.
20
-     * @since 1.8.0
20
+	 * @since 1.8.0
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-        add_action( 'admin_menu', array( $this, 'admin_menus') );
24
+		add_action( 'admin_menu', array( $this, 'admin_menus') );
25 25
 		add_action( 'admin_head', array( $this, 'admin_head' ) );
26 26
 
27 27
 	}
28 28
 
29
-    /**
30
-     * Sends user to the welcome page on first activation.
31
-     *
32
-     * Hooked into activated_plugin
33
-     * @since 1.8.0
34
-     */
35
-    public static function redirect( $plugin ) {
29
+	/**
30
+	 * Sends user to the welcome page on first activation.
31
+	 *
32
+	 * Hooked into activated_plugin
33
+	 * @since 1.8.0
34
+	 */
35
+	public static function redirect( $plugin ) {
36 36
 
37
-        // Bail if activating from network, or bulk, or within an iFrame
38
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
37
+		// Bail if activating from network, or bulk, or within an iFrame
38
+		if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) ) {
39 39
 
40
-            return;
40
+			return;
41 41
 
42
-        }
43
-        // don't run for upgrades and for pages already on the welcome screen
44
-        if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] )
45
-            || ( ! empty( $_GET['page'] ) && $_GET['page'] === 'sensei-welcome' ) ) {
42
+		}
43
+		// don't run for upgrades and for pages already on the welcome screen
44
+		if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] )
45
+			|| ( ! empty( $_GET['page'] ) && $_GET['page'] === 'sensei-welcome' ) ) {
46 46
 
47
-            return;
47
+			return;
48 48
 
49
-        }
49
+		}
50 50
 
51
-        wp_redirect( admin_url( 'index.php?page=sensei-welcome' ) );
52
-        exit;
53
-    }
51
+		wp_redirect( admin_url( 'index.php?page=sensei-welcome' ) );
52
+		exit;
53
+	}
54 54
 
55 55
 	/**
56 56
 	 * Add admin menus/screens.
57
-     *
58
-     * @since 1.8.0
57
+	 *
58
+	 * @since 1.8.0
59 59
 	 */
60 60
 	public function admin_menus() {
61 61
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 
66 66
 		$welcome_page_name  = __( 'Sensei Activation', 'woothemes-sensei' );
67 67
 		$welcome_page_title = __( 'Welcome to Sensei', 'woothemes-sensei' );
68
-        add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sensei-welcome', array( $this, 'welcome_screen' ) );
68
+		add_dashboard_page( $welcome_page_title, $welcome_page_name, 'manage_options', 'sensei-welcome', array( $this, 'welcome_screen' ) );
69 69
 
70 70
 	}
71 71
 
72
-    /**
73
-     * Output the Welcome  screen.
74
-     *
75
-     * @since 1.8.0
76
-     */
77
-    public function welcome_screen() {
78
-        ?>
72
+	/**
73
+	 * Output the Welcome  screen.
74
+	 *
75
+	 * @since 1.8.0
76
+	 */
77
+	public function welcome_screen() {
78
+		?>
79 79
         <div class="wrap about-wrap">
80 80
 
81 81
             <?php  $this->intro(); ?>
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
             </div>
129 129
         </div>
130 130
     <?php
131
-    }
131
+	}
132 132
 
133 133
 	/**
134 134
 	 * Add styles just for this page, and remove dashboard page links.
135 135
 	 */
136 136
 	public function admin_head() {
137
-        // remove the menu page so it is not visible in the admin side bar
137
+		// remove the menu page so it is not visible in the admin side bar
138 138
 		remove_submenu_page( 'index.php', 'sensei-welcome' );
139 139
 		?>
140 140
 		<style type="text/css">
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
 		// Random tweet - must be kept to 102 chars to "fit"
260 260
 		$tweets        = array(
261
-            'I\'ve just installed Sensei - A premium Learning Management plugin for #WordPress.'
261
+			'I\'ve just installed Sensei - A premium Learning Management plugin for #WordPress.'
262 262
 		);
263 263
 		shuffle( $tweets );
264 264
 		?>
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 
281 281
 		<div class="sensei-badge">
282 282
             <?php
283
-                _e('Sensei by WooThemes','woothemes-sensei');
284
-                echo '<br />';
283
+				_e('Sensei by WooThemes','woothemes-sensei');
284
+				echo '<br />';
285 285
 
286
-                printf( __( 'Version %s', 'woothemes-sensei' ), Sensei()->version );
287
-            ?>
286
+				printf( __( 'Version %s', 'woothemes-sensei' ), Sensei()->version );
287
+			?>
288 288
         </div>
289 289
 
290 290
 		<p class="sensei-actions">
Please login to merge, or discard this patch.