Completed
Pull Request — master (#1233)
by Dan
07:34
created
includes/class-sensei-analysis.php 1 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 = 'WooThemes_Sensei_Analysis_' . $name . '_List_Table';
106
-		if ( is_null($optional_data) ) {
107
-			$sensei_analysis_object = new $object_name( $data );
105
+		$object_name = 'WooThemes_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.